% file: recurs
% query: sentence(john,on_the_table)?
% note that sentences such as 'john mary' and  'reads a_book' are also OK
% see the lesson on finite state grammars for a solution

follows(john, sleeps).
follows(john, reads).
follows(john, gives).
follows(john, puts).
follows(reads, a_book).
follows(gives, mary).
follows(puts, a_candle).
follows(mary, flowers).
follows(a_candle, on_the_table).

sentence(WordA,WordB) :-
    follows(WordA, WordB), !.

sentence(WordA, WordB) :-
    follows(WordA, WordC),
    sentence(WordC,WordB), !.


