I answered the wrong question! Here is a definition of allsame. The easy way is to use notation [A,B|R], which is a list that starts [A,B,...], where the part after B is R.

  allsame([]).
  allsame([A]).
  allsame([A,A|R]) :- allsame([A|R]).

If you are restricted to [A|R], you can write it as follows.

  equal(X,X).

  allsame([]).
  allsame([A]).
  allsame([A|S]) :- equal(S, [A|R]), allsame([A|R]).

Here is a definition of prefix, where prefix(X,Y) is true if X is a prefix of Y. We did not have a chance to go over Prolog. In Prolog

Here is a definition of prefix in Prolog.

  prefix([],Y).
  prefix([A|X], [A|Y]) :- prefix(X,Y).

The first axiom says that the empty list is a prefix of any list. The second axiom says that A.X is a prefix of A.Y when X is a prefix of Y.

It is instructive to look at the same thing written in a functional style. Here it is, with an attempt to make it look similar to the Prolog definition.

  prefix([],x) = true
  prefix(a::x, a::y) = prefix(x,y)

  prefix(a::x, []) = false
  prefix(a::x, b::y) = false  when a =/= b

Notice that the first two cases, which handle positive information (about when one list is a prefix of another list) correspond closely to the Prolog axioms. The last two cases are concerned with negative information (when one list is not a prefix of another list). In Prolog, you do not state negative information. It is implicit by the fact that you have not stated it.