/* EXAMPLE: Motherhood relation */
/*       file: mother.pl        */
   
/* Definition of the relation mother(X,Y) (X is mother of Y) */

mother(ann,betty).
mother(betty,carol).
mother(betty,diana).
mother(carol,elisa).
mother(elisa,francesca).

/* graphical representation of the above relation:

               ann
                |
              betty
              /   \
           carol diana
             |
           elisa
             |
         francesca
*/

/* Definition of the relation grandmother(X,Y) (X is grandmother of Y) */

grandmother(X,Y) :- mother(X,Z), mother(Z,Y).

/* Definition of the relation ancestor(X,Y) (X is the ancestor of Y) */

ancestor(X,Y) :- mother(X,Y).
ancestor(X,Y) :- mother(X,Z), ancestor(Z,Y).

/* Definition of the relation sister(X,Y) (X is the sister of Y) */

sister(X,Y) :- mother(Z,X), mother(Z,Y), not(X=Y).

