:- module(_,_,[]).

% Recursive database (datalog) programming examples

parent(X,Y) :- father_of(X,Y).
parent(X,Y) :- mother_of(X,Y).

ancestor(X,Y) :- parent(X,Y).
ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y).

father_of(john, peter).
father_of(john, mary).
father_of(peter, michael). 

mother_of(mary, david).
mother_of(jill, john).

% Some queries to try: 
% ?- ancestor(john,michael).
% ?- ancestor(john,elisabeth).
% ?- ancestor(john,X).
% ?- ancestor(X,elisabeth).
% ?- ancestor(X,michael).
% ?- ancestor(X,Y).
