Recursive predicate definitions

If you have not already done so, do the exercise about family relationships.

Extend the family tree that you defined in that exercise by adding great-grandparents for Harry.

Now, define a predicate ancestor_of/2. ancestor_of(X,Y) should be true if X is an ancestor of Y. Your predicate definition should work correctly even if you add Harry's great-great-grandparents, his great-great-great-grandparents, his great-great-... to the knowledge base.

Ask queries to test your definition. For example:

Hint

If Prolog does not come back with an answer, it has probably gone off into an endless loop. Stop it by pressing Ctrl-c. Then type a to abort.


Last modified: Wed Dec 1 16:53:32 CET 2004