The ancestor relationship.
Source: The Art of Prolog
Program source code: ancestor.pl
/* ancestor(Ancestor,Descendant) :- Ancestor is an ancestor of Descendant. */ ancestor(Ancestor,Descendant) :- parent(Ancestor,Descendant). ancestor(Ancestor,Descendant) :- parent(Ancestor,Person), ancestor(Person,Descendant). % Program 2.5: The ancestor relationship