Presentation is loading. Please wait.

Presentation is loading. Please wait.

CA 208 Logic Ex8 Describe (i.e. axiomatise, define) the following situation as a Prolog programme (use parent/2 and john, mary etc. as your vocabulary):

Similar presentations


Presentation on theme: "CA 208 Logic Ex8 Describe (i.e. axiomatise, define) the following situation as a Prolog programme (use parent/2 and john, mary etc. as your vocabulary):"— Presentation transcript:

1 CA 208 Logic Ex8 Describe (i.e. axiomatise, define) the following situation as a Prolog programme (use parent/2 and john, mary etc. as your vocabulary): John is a parent of Kate. Mary is a parent of Kate. John is a parent of Mike. Mary is a parent of Mike. Kate is a parent of Lucy. Tom is a parent of Lucy. Lucy is a parent of Sean. Charles is a parent of Sean. Sean is a parent of Tracy. Fiona is a parent of Tracy. Given this, add information (use male/1 and female/1 predicates) to express that: John is male. Mary is female. Kate is female. Mike is male. Lucy is female. Tom is male. Sean is male. Charles is male. Tracy is female. Conor is male. Given your Prolog programme, add clauses defining the following relations: child(X,Y) % if X is a child of Y father(X,Y) % if X is a father of Y mother(X,Y) % if X is a mother of Y grandfather(X,Y) % if X is a grandfather of Y grandmother(X,Y) % if X is a grandmother of Y ancestor(X,Y) % if X is an ancestor of Y (define recursively) relative(X,Y) % if X is a relative of Y sibling(X,Y) % if X is a sibling of Y sister(X,Y) % if X is a sister of Y brother(X,Y) % if X is a brother of Y aunt(X,Y) % if X is an aunt of Y uncle(X,Y) % if X is an uncle of Y For some of these relations you may want to use negation “\+” to rule out that e.g. sombody is their own sister “\+(X=Y)”. Load you programme into Prolog, debug it and test it out using a number of queries.

2 CA 208 Logic Ex8 Which of the following (sequences of) unifications/matches succeed? (use Prolog to check ...) a = a. a = b. a = X. X = a. X = Y. X = Y, X = a. X = a, X = Y, Y = b. like(john,mary) = like(john,X). like(john,mary) = like(Y,X). like(john,mary) = like(X,X). like(john,mary) = like(Y,X,Z). like(john,mary) = like(X). line(point(2,2),point(2,5)) = line(point(X,X),point(X,5)). line(point(2,2),point(2,5)) = line(point(X,Y),point(Z,5)). line(X,point(2,5)) = line(point(2,2),point(2,5)). line(X,Y) = line(point(2,2),point(2,5)). line(X,X) = line(point(2,2),point(2,5)). line(X,point(2,5)) = line(point(2,2),point(2,Y)). line(X,point(2,5)) = line(point(2,2),point(X,Y)).


Download ppt "CA 208 Logic Ex8 Describe (i.e. axiomatise, define) the following situation as a Prolog programme (use parent/2 and john, mary etc. as your vocabulary):"

Similar presentations


Ads by Google