father(elrond,earendil).
father(elros,earendil).
mother(elrond,elwing).
mother(elros,elwing).
mother(earendil,idril).
father(idril,turgon).
father(turgon,fingolfin).
father(gilgalad,fingon).
father(fingon,fingolfin).
mother(maeglin,aredhel).
father(maeglin,eol).
father(aredhel,fingolfin).
mother(fingolfin,indis).
mother(finarfin,indis).
father(fingolfin,finwe).
father(finrod,finarfin).
father(finduilas,orodreth).
father(orodreth,finarfin).
father(angrod,finarfin).
father(aegnor,finarfin).
father(galadriel,finarfin).
mother(finrod,earwen).
mother(orodreth,earwen).
mother(angrod,earwen).
mother(aegnor,earwen).
mother(galadriel,earwen).
father(feanor,finwe).
mother(feanor,miriel).
father(maedhros,feanor).
father(maglor,feanor).
father(celegorm,feanor).
father(caranthir,feanor).
father(curufin,feanor).
father(amrod,feanor).
father(amras,feanor).

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

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

sibling(X,Y) :- parent(X,Z), parent(Y,Z), X \== Y.

cousin(X,Y) :- parent(X,Z1), parent(Y,Z2), sibling(Z1,Z2).



