This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: answer. To get all the answers type a ';' and carriage return at the question mark. (b) Now, using the parent predicate formulate the following Prolog queries: 1. Who is Pat's parent? 2. Does Liz have a child? 3. Who is Pat's grandparent? (c) Given the above facts, extend the program by writing rules defining the following predicates: sister(X,Y) -- X is the sister of Y. son(X,Y) -- X is the son of Y. father(X,Y) -- X is the father of Y. grandmother(X,Y) -- X is the grandmother of Y. ancestor(X,Y) -- X is an ancestor of Y. (Hint: this predicate might come in handy: different(X,Y):- not(X=Y). Some predicate definitions might be recursive.) Demonstrate that your program works by posing the following queries: 4. ?- sister(X,pat). 5. ?- sister(X,Y). 6. ?- son(jim,X). 7. ?- father(X,bob). 8. ?- grandmother(X,ann). 9. ?- ancestor(X,jim). Hand in the source code of your prolog program and a proof of the program execution....
View Full Document
This note was uploaded on 10/03/2011 for the course CSC 301 taught by Professor Hamel during the Spring '08 term at Rhode Island.
- Spring '08