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

Hint

Note that the rule that the predicate path/2 has to express is very similar to the rule expressed by the predicate ancestor_of/2: in the first case, you can get from point X to point Y by chaining together an arbitrary number of connected/2 relations, and in the second case, X is an ancestor of Y if a chain of an arbitrary number of parent_of/2 relations connects them.

So, path(X,Y) should succeed if X is directly connected to Y. It should also succeed if X is directly connected to some Z from where in turn there is a path to Y.

Solution

Back to the exercise.