1% Computational Intelligence: a logical approach.
    2% CILOG Code. Lists code from Section 3.5.
    3% Copyright (c) 1998, Poole, Mackworth, Goebel and Oxford University Press
    4
    5% append(X,Y,Z) is true when X, Y and Z are lists
    6% and Z contains the elements of X (in order)
    7% followed by the elements of Y (in order)
    8append([],Z,Z).
    9append([A|X],Y,[A|Z]) <-
   10   append(X,Y,Z).
   11
   12% member(X,L) is true if X is an element of list L
   13member(X,[X|L]).
   14member(X,[H|R])<-
   15   member(X,R).
   16
   17% notin(X,L) is true if X is not an element of list
   18% L --- or that X is different from every member of L.
   19notin(A,[]).
   20notin(A,[H|T])<-
   21   different(A, H) &
   22   notin(A,T).
   23
   24% rev(L,R) that is true if list R contains the same
   25% elements as list L, but in reverse order.
   26rev([],[]).
   27rev([H|T],R)<-
   28   rev(T,RT) &
   29   append(RT,[H],R).
   30
   31% reverse(L,R) is true if R contains the lements of
   32% L, but in reverse order.
   33reverse(L,R)<-
   34   rev3(L,[],R).
   35
   36% rev3(L,A,R) is true if R contains the elements of
   37% L in reverse order followed by the elements of A.
   38rev3([],L,L).
   39rev3([H|T],A,R)<-
   40   rev3(T,[H|A],R).
   41
   42% different(X,Y) is true if X and Y denote different objects
   43different(a,b).
   44different(a,c).
   45different(b,a).
   46different(b,c).
   47different(c,a).
   48different(c,b).
   49
   50% EXAMPLE QUERIES
   51% ask append([a,b],[c,d],L).
   52% ask append(X,Y,[a,b,c,d]).
   53% ask member(size(robin,S),[size(alan,big), color(grass,green),
   54%          size(robin,medium), sound(dog,woof)]).
   55% ask rev([a,b,c,d],L).
   56% ask reverse([a,b,c,d],L).