/* Filename: ancestor2.pro Author: Br. David Carlson Date: December 6, 1999 Revised: March 29, 2000 Added a sibling and a child predicate. This program creates a small set of facts and rules on who is the ancestor of whom. The user types the desired goal interactively when the program is run. */ child(C, P) :- parent(P, C). /* You might not think of the A not equal to B condition. So, I did not expect that you would include it. However, without that, the program would say that john is a sibling of john, etc. */ sibling(A, B) :- parent(P, A), parent(P, B), A \== B. /* Note that ancestor(A, B) means that A is an ancestor of B. */ ancestor(bob, susan). ancestor(A, X) :- parent(A, X). ancestor(A, X) :- parent(A, C), ancestor(C, X). /* Note that parent(P, C) means that P is a parent of C. */ parent(fred, sally). parent(tina, sally). parent(sally, john). parent(sally, diane). parent(sam, bill).