:- dynamic male/1, female/1, parentOf/2, married/2 % X is a mother of Y if X is a female parent of Y motherOf(X,Y) :- parentOf(X,Y), female(X). % X is a father of Y if X is a male parent of Y fatherOf(X,Y) :- parentOf(X,Y), male(X). % X and Y are siblings if they share a parent and are different siblings(X,Y) :- parentOf(P1,X), parentOf(P1,Y), X \= Y. isParent(X) :- parentOf(X,_). childLess(X) :- \+ isParent(X). spouse(X,Y) :- married(X,Y). spouse(X,Y) :- married(Y,X). grandparentOf(X, GP) :- parentOf(X, P), parentOf(P, GP). cousin(X,Y) :- grandparentOf(X, G), grandparentOf(Y,G), X \= Y, \+ siblings(X,Y).