
% before(X,Y,L)
% -------------
% test if L contains X and Y, with X coming first
before(X,Y,[X|T]) :- contains(T,Y).
before(X,Y,[_|T]) :- before(X,Y,T).

% contains(L,A)
% -------------
% test if L contains A
contains([A|_],A).
contains([_|T],A) :- contains(T,A).

