Next: List Processing Up: Tracing Prolog Execution Previous: Tracing Prolog Execution

Exercises:

1. for the following facts and recursive predicate, state what order solutions to the given query are returned:


on_top_of(prolog_book, desk).
on_top_of(ai_notes, prolog_book).
on_top_of(time_table, ai_notes).
on_top_of(ai_book, desk).

above(X,Y) :- on_top_of(X,Y).
above(X,Y) :- on_top_of(X,Z),
	      above(Z,Y).

?- above(Object, desk).

2. What will happen if you try the following program/query:


above(prolog_book, desk).
above(ai_notes, prolog_book).
above(time_table, ai_notes).

above(X,Y) :- above(X,Z),
	      above(Z,Y).

?- above(desk, ai_notes).


alison@
Fri Aug 19 10:42:17 BST 1994