% the example grammar
s  --> np, vp.      
                   
np --> [john].

vp --> aux, neg, v.
  
aux, [not] --> [aint].

neg --> [not].

v --> [leaving].

% compiled result and tracing output:
%s(A, B)  :-  np(A, C),              | ?- trace,s(X,[]).
%             vp(C, B).                   Call: s(_1,[]) ? 
%                                         Call: np(_1,_2) ? 
%np(A, B) :- 'C'(A, john, B).             Call: 'C'(_1,john,_2) ? 
%                                         Exit: 'C'([john|_2],john,_2) ? 
%vp(A, B) :-  aux(A, C),                  Exit: np([john|_2],_2) ? 
%             neg(C, D),                  Call: vp(_2,[]) ? 
%             v(D, B).                    Call: aux(_2,_3) ? 
%                                         Call: 'C'(_2,aint,_4) ? 
%aux(A, B) :- 'C'(A, aint, C),            Exit: 'C'([aint|_4],aint,_4) ? 
%             'C'(B, not, C).             Call: 'C'(_3,not,_4) ? 
%                                         Exit: 'C'([not|_4],not,_4) ? 
%neg(A, B) :- 'C'(A, not, B).             Exit: aux([aint|_4],[not|_4]) ? 
%                                         Call: neg([not|_4],_5) ? 
%v(A, B) :- 'C'(A, leaving, B).           Call: 'C'([not|_4],not,_5) ? 
%                                         Exit: 'C'([not|_5],not,_5) ? 
%'C'([A|B],A,B).                          Exit: neg([not|_5],_5) ? 
%                                         Call: v(_5,[]) ? 
%                                         Call: 'C'(_5,leaving,[]) ? 
%                                         Exit: 'C'([leaving],leaving,[]) ? 
%                                         Exit: v([leaving],[]) ? 
%                                         Exit: vp([aint,leaving],[]) ? 
%                                         Exit: s([john,aint,leaving],[]) ? 
%                                     X = [john,aint,leaving] ? 
