/* sentence/1 sentence(+S) The predicate sentence returns true if the list of tokens has a valid derivation according to the grammar rules. This definite clause grammar is written without the --> macro. Warren Sack May 2017 */ append([],List,List). append([First|Rest],List2,[First|List3]) :- append(Rest,List2,List3). sentence(S) :- append(NP,VP,S),noun_phrase(NP),verb_phrase(VP). noun_phrase(NP) :- append(A,N,NP),article(A),noun(N). verb_phrase(VP) :- append(V,NP,VP),verb(V),noun_phrase(NP). article([a]). article([the]). noun([man]). noun([ball]). verb([hit]). verb([took]).