%female(elizabeth).
%female(anne).

male(andrew).
male(charles).
male(edward).
male(harry).
male(william).

parent(charles, harry).
parent(charles, william).
parent(elizabeth, andrew).
parent(elizabeth, anne).
parent(elizabeth, charles).
parent(elizabeth, edward).
parent(diana, harry).
parent(diana, william).

female(diana).
female(elizabeth).
female(anne).

is_mother(M,  X) :- female(M), parent(M,X).
is_mother2(M, C) :- female(M),!, parent(M,C).

is_father(F,X) :- parent(F, X), male(F).

ancestor(A, D) :- parent(A, D).
ancestor(A, D) :- parent(P, D), ancestor(A, P).

mother(elisabeth, charles).
mother(elizabeth, andrew).
mother(elizabeth, anne).
mother(elizabeth, edward).
mother(diana, harry).
mother(diana, william).
father(charles, harry).
father(charles, william).

is_parent(P, C) :- mother(P, C) ; father(P, C).

is_parent2(P, C) :- mother(P, C), !.
is_parent2(P, C) :- father(P, C).


is_ancestor1(A, D) :- is_parent1(A, D).
is_ancestor1(A, D) :- is_parent1(P, D), is_ancestor1(A, P).

is_ancestor2(A, D) :- is_parent2(A, D).
is_ancestor2(A, D) :- is_parent2(P, D), is_ancestor2(A, P).


printall(X) :- X, display(X), nl, fail.
printall(_).
