CSci 541: Expert Systems and Logic Programming
Spring Semester 2008

Assignment #1
Due Thurs, 31 Jan, Midnight


Consider Figure 1.8, the family program, from the Bratko textook.

% Figure 1.8   The family program.

parent( pam, bob).       % Pam is a parent of Bob
parent( tom, bob).
parent( tom, liz).
parent( bob, ann).
parent( bob, pat).
parent( pat, jim).

female( pam).            % Pam is female
male( tom).              % Tom is male
male( bob).
female( liz).
female( ann).
female( pat).
male( jim).

offspring( Y, X)  :-     % Y is an offspring of X if
   parent( X, Y).        % X is a parent of Y

mother( X, Y)  :-        % X is the mother of Y if
   parent( X, Y),        % X is a parent of Y and
   female( X).           % X is female

grandparent( X, Z)  :-   % X is a grandparent of Z if
   parent( X, Y),        % X is a parent of Y and
   parent( Y, Z).        % Y is a parent of Z

sister( X, Y)  :-        % X is a sister of Y if
   parent( Z, X),
   parent( Z, Y),        % X and Y have the same parent and
   female( X),           % X is female and
   different( X, Y).     % X and Y are different

predecessor( X, Z)  :-   % Rule prl: X is a predecessor of Z
   parent( X, Z).
predecessor( X, Z)  :-   % Rule pr2: X is a predecessor of Z
   parent( X, Y),
   predecessor( Y, Z).
And add the following facts to the family program.
different(X,Y) :- X\=Y.
       
parent(pam,joe).
parent(tom,joe).
male(joe).

parent(pam,john).
male(john).

parent(sue,ann).
parent(sue,pat).
female(sue).

parent(george,mary).
parent(george,sue).
parent(george,marge).
male(george).
parent(martha,mary).
parent(martha,sue).
parent(martha,marge).
female(martha).
female(mary).
female(sue).
female(marge).

parent(joe,keith).
male(keith).

married_couple(tom,pam).
married_couple(bob,sue).
married_couple(joe,mary).
married_couple(george,martha).


UP to CSCI 541 assignments document?


Copyright © 2008, H. Conrad Cunningham
Last modified: Fri 25 Jan 2008