male(abraham).
male(ishmael).
male(isaac).
male(esau).
male(jacob).
male(reuben).
male(levi).
male(judah).
male(joseph).
male(benjamin).
female(sarah).
female(hagar).
female(rebecca).
female(leah).
female(rachel).

father(abraham,ishmael).
father(abraham,isaac).
father(isaac,esau).
father(isaac,jacob).
father(jacob,reuben).
father(jacob,levi).
father(jacob,judah).
father(jacob,joseph).
father(jacob,benjamin).
mother(sarah,isaac).
mother(hagar,ishmael).
mother(rebeccca,esau).
mother(rebecca,jacob).
mother(leah,reuben).
mother(leah,levi).
mother(leah,judah).
mother(rachel,joseph).
mother(rachel,benjamin).

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

grandfather(X,Y) :- father(X,Z), parent(Z,Y).

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

full_brother(X,Y) :- male(X), father(F,X), father(F,Y),
                              mother(M,X), mother(M,Y), X\=Y.
half_brother(X,Y) :- brother(X,Y), not(full_brother(X,Y)).