s(P1,P3) :- np(P1,P2), vp(P2,P3). np(P1,P2) :- propernoun(P1,P2). vp(P1,P2) :- verb(P1,P2). vp(P1,P3) :- verb(P1,P2), adverb(P2,P3). % Terminal symbols propernoun(I,O) :- word(W,I,O), ispropernoun(W). verb(I,O) :- word(W,I,O), isverb(W). adverb(I,O) :- word(W,I,O), isadverb(W). adjective(I,O) :- word(W,I,O), isadverb(W). ispropernoun(bill). ispropernoun(steve). isverb(cries). isverb(smiles). isadverb(often). isadverb(slightly). isadjective(red). isadjective(sad). % Encoding of the sentence "Bill cries often" word(bill,1,2). word(cries,2,3). word(often,3,4).