parent( pam,bob).
parent( tom,bob).
parent( tom,liz).
parent( bob,ann).
parent( bob,pat).
parent( pat,jim).

offspring( Y,X) :- parent( X,Y).

female( pam).  female( liz).  female( pat).  female(ann).

male( tom).  male( bob).  male( jim).

mother( X,Y) :- parent( X,Y), female( X).

grandparent( X,Z) :-  /* Bratko's (and SWI's) layout convention */
  parent( X,Y),
  parent( Y,Z).

sisterB( X,Y) :- parent( Z,X), parent( Z,Y), female( X). /* bad! */
sister( X,Y) :-  /* correct */
  parent( Z,X),
  parent( Z,Y),
  female( X),
  different( X,Y).

different( X,Y) :- X \= Y.  /* X does not unify with Y */


