/* FAMILY TREE */ /* famtree.pro */ /* by: LOUIS GUZIK Student #: 58831 Date: 9-18-93 Assignment: 1A */ /*** DATA ***/ father( orphin ). mother( orphin, me ). /* CHILD , PARENT */ father( zack, lou ). mother( zack, kathy ). father( lou, louis ). mother( lou, flo ). father( bruce, louis ). mother( bruce, flo ). father( roger, louis ). mother( roger, flo ). father( louis, frank ). mother( louis, catherin ). father( edward, frank ). mother( edward, catherin ). father( flo, george ). mother( flo, katherin ). father( barb, george ). mother( barb, katherin ). father( kathy, joe ). mother( kathy, nancy ). father( joey, joe ). mother( joey, nancy ). father( sue, joe ). mother( sue, nancy ). father( judy, joe ). mother( judy, nancy ). father( kevin, joe ). mother( kevin, nancy ). father( joe, james ). mother( joe, florence ). father( nancy, robert ). mother( nancy, annet ). /* */ /*** RULES ***/ diff( X, Y ) :- X \= Y. parents( Child, Father, Mother ) :- father( Child, Father ), mother( Child, Mother ). parents( Child ) :- parents( Child, Father, Mother ), print( '\n ', Child, '\'s father is ', Father, '.', '\n ', Child, '\'s mother is ', Mother, '.' ). parent( Child, Parent ) :- father( Child, Parent ). parent( Child, Parent ) :- mother( Child, Parent ). sibiling ( Person, Sibiling ) :- diff( Person, Sibiling ), father( Person, Father1 ), mother( Person, Mother1 ), father( Sibiling, Father2 ), mother( Sibiling, Mother2 ), Father1 = Father2, Mother1 = Mother2. /*** CHECK THE FATHER ***/ ancestor( Person, Ancestor ) :- parents( Person, Father, _ ), Ancestor = Father, !. /*** CHECK THE MOTHER ***/ ancestor( Person, Ancestor ) :- parents( Person, _ , Mother ), Ancestor = Mother, !. /*** CHECK THE FATHER'S SIBILINGS ***/ ancestor( Person, Ancestor ) :- parents( Person, Father, _ ), father( Children, Father ), Ancestor = Children, !. /*** CHECK THE MOTHER'S SIBILINGS ***/ ancestor( Person, Ancestor ) :- parents( Person, _ , Mother ), mother( Children, Mother ), Ancestor = Children, !. /*** ADVANCE THE FATHER TO THE PREVIOUS GENERATION ***/ ancestor( Person, Ancestor ) :- parents( Person, Father, _ ), ancestor( Father, Ancestor ). /*** ADVANCE THE MOTHER TO THE PREVIOUS GENERATION ***/ ancestor( Person, Ancestor ) :- parents( Person, _ , Mother ), ancestor( Mother, Ancestor). ancestors( Child, Ancestor ) :- father( Child, Ancestor ); /* OR */ mother( Child, Ancestor ). ancestors( Child, Ancestor ) :- father( Child, Parent ); /* OR */ mother( Child, Parent ), ancestors( Parent, Ancestor ). /* END OF FAMILY TREE. */