% P1 is the father of P2 if P1 is the parent of P2 and P1 is male. father(P1,P2) :- parent(P1,P2), male(P1). % P1 is a grandparent of P2 if P1 is the parent of some X and X is a % parent of P2. grandparent(P1,P2) :- parent(P1,X), parent(X,P2).