all_query(Sentence) :-
  query(Sentence, Parse), 
  format("~n ~p.", [Parse]), 
  fail.
all_query(_Sentence).

query(Sentence, Parse) :- 
  test(Sentence, A, Parse),
  lj(A, (Parse,1)).

test('Every man saw a friend of his',
% every
      (q^(f2:q, f3:q, (f8: (\R1 @ q)) '-o' (f1: (\S1 @ q) '-o' f1: every(y, R1@y, S1@y))),
% man 
       (f2: \Man '-o' (f8: man(Man))),
%saw
       (f3: \X '-o' (f4: \Q1 '-o'  f1: see(X,Q1))),
%a
       yy^(f7:yy, f4:yy, (f6: (\R @ yy)) '-o' (f1: (\S @ yy) '-o' f1: a(z, R@z, S@z))),
%friend of
       (f7: \Friend '-o' (f9: \SomeOne '-o' f6: friend_of(Friend,SomeOne))),
% his
       (f3: \P '-o' (f3: P, f9:P))
      ),
      f1:_).

