female(lola).
female(bonnie).
female(bonnie_h).
female(carrie).
female(phyl).
female(rachel).
male(dave).
male(tom).
male(theo).
male(dennis).
male(bill).
male(tom_h).
parent(bill, tom).
parent(phyl, tom).
parent(tom, bonnie).
parent(tom, theo).
parent(tom, rachel).
parent(lola, bonnie).
parent(lola, theo).
parent(lola, rachel).
parent(carrie, adam).
parent(dennis, adam).
parent(bonnie_h, lola).
parent(bonnie_h, carrie).
parent(tom_h, lola).
parent(tom_h, carrie).
parent(phyl, dave).
husband(tom, lola).
husband(dennis, carrie).
husband(bill, phyl).
husband(tom_h, bonnie_h).

wife(X,Y) :- husband(Y,X).
spouse(X,Y) :- husband(X,Y).
spouse(X,Y) :- wife(X,Y).
mother(X,Y) :- female(X), parent(X,Y).
father(X,Y) :- male(X), parent(X,Y).
sibling(X,Y) :- mother(Z,X), mother(Z,Y), X \== Y.
brother(X,Y) :- male(X), sibling(X,Y).
sister(X,Y) :- female(X), sibling(X,Y).
brother_in_law(X,Y) :- brother(X, Z), spouse(Z, Y).
brother_in_law(X,Y) :- husband(X, Z), sister(Z, Y).
sister_in_law(X,Y) :- sister(X, Z), spouse(Z, Y).
sister_in_law(X,Y) :- wife(X, Z), brother(Z, Y).
ancestor(X,Y) :- parent(X,Y).
ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y).
