General
Material
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5

A very simple sentence generator

Here is a tiny lexicon and mini grammar with only one rule which defines a sentence as consisting of five words: an article, a noun, a verb, and again an article and a noun.

word(article,a).
word(article,every).
word(noun,criminal).
word(noun,'big kahuna burger').
word(verb,eats).
word(verb,likes).
     
sentence(Word1,Word2,Word3,Word4,Word5) :-
        word(article,Word1),
        word(noun,Word2),
        word(verb,Word3),
        word(article,Word4),
        word(noun,Word5).
Download knowledge base here.

What query do you have to pose in order to find out which sentences the grammar can generate? In which order will Prolog generate the sentences? Make a prediction about the order, then try it out. If it is not clear for you why Prolog generates the sentence in the order that you are seeing, do a trace.
Solution

Back to the practical session of day 2.