next up previous
Next: Pure Prolog Up: complete2 Previous: Unification

Exercises

Extend the program by adding rules for the following family relationships (add more people if necessary, so that you can check your results):
brother(X, Y) where X is Y's brother
sister(X, Y) where X is Y's sister
son(X, Y) where X is Y's son
daughter(X, Y) where X is Y's daughter
married(X, Y) where X is married to Y
ancestor(X, Y) where X is Y's ancestor

What problems do you encounter? What is the nature of the problems? What solutions (if any) can you suggest. (Reading the literature on Prolog will help.)
\begin{solution}Database problems
 
\noindent
\texttt{brother/2}

\noindent
Firs...
...ancestor refers to itself. It is a recursive definition.
\newpage
\end{solution}


Steve Harlow 2001-11-26