Solution
The query that you have to pose is:
?- sentence(A,B,C,D,E).
The first answer that Prolog gives you is
A=a, B=criminal, C=eats, D=a, E=criminal.For each word, Prolog chooses the first one with the required properties that it can find in its knowledge base. Backtracking then first looks for alternatives of the last choice that has been made, i.e. the choice to instantiate
E
with
criminal
. The alternative that Prolog finds is
'big kahuna burger'
and the second answer is thus:
A=a, B=criminal, C=eats, D=a, E='big kahuna burger'.Then there are no other possibilities of instantiating
E
and backtracking hence looks at alternatives for
D
. And so on...