% Family Tree of the Royal Family beginning with Queen Elizabeth II

% The following line allows us to add and remove later.

:- dynamic father/2, mother/2.

% RULES

parent(X,Y) :- father(X,Y).
parent(X,Y) :- mother(X,Y).

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

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

sibling(X,Y) :- mother(M,X), mother(M,Y),
                father(F,X), father(F,Y),
                X \= Y.

cousin(X,Y) :- parent(U,X), parent(V,Y), sibling(U,V).

% FACTS

father(philip, charles).
father(philip, anne).
father(philip, andrew).
father(philip, edward).

mother(elizabeth, charles).
mother(elizabeth, anne).
mother(elizabeth, andrew).
mother(elizabeth, edward).

father(charles, william).
father(charles, harry).

mother(diana, william).
mother(diana, harry).

father(mark, peter).
father(mark, zara).

mother(anne, peter).
mother(anne, zara).

father(andrew, beatrice).
father(andrew, eugenie).

mother(sarah, beatrice).
mother(sarah, eugenie).

father(edward, louise).
father(edward, james).

mother(sophie, louise).
mother(sophie, james).

