male(a).
female(b).

parent(a,c).
parent(a,d).
parent(b,c).
parent(b,d).
parent(a,e).

father(X,Y) :- male(X), parent(X,Y).
mother(X,Y) :- female(X), parent(X,Y).

sibling(X,Y) :- father(Z,X), father(Z,Y), mother(W,X), mother(W,Y), X \= Y.

halfsibling(X,Y) :- parent(Z,X), parent(Z,Y), X\=Y, not(sibling(X,Y)).
