pr8 - female(X) /* X is female */ diff(X,Y) /* X and Y are...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCE 330 Fall 2010 Program 8 Assigned Wednesday 2010-11-10. Due Wednesday 2010-11-17 Write a Prolog program that describes your family tree. Your program should include facts and some rules for family relations going back two gen- erations (grandmother, grandfather, aunt, etc.). Remember that the names of constants in Prolog must start with a lower-case letter! Test your program using the SWI-Prolog interpreter. Turn in a hard copy with your program and a script or screen shots of your program running. Further details are given below. (Exercise 1.3 from [Clocksin and Mellish, 1994].) Suppose someone has al- ready written Prolog clauses that de±ne the following relationships: father(X,Y) /* X is the father of Y */ mother(X,Y) /* X is the mother of Y */ male(X) /* X is male */
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: female(X) /* X is female */ diff(X,Y) /* X and Y are different */ Write Prolog clauses to dene the following relationships: is_mother(X) /* X is a mother */ is_father(X) /* X is a father */ is_son(X) /* X is a son */ sister_of(X,Y) /* X is a sister of Y */ grandpa_of(X,Y) /* X is a grandfather of Y */ grandma_of(X,Y) /* X is a grandmother of Y */ sibling(X,Y) /* X is a sibling of Y */ aunt(X,Y) /* X is an aunt of Y */ For example, we could write a rule for aunt, provided that we were supplied with (or wrote) rules for female, sibling, and parent: aunt(X,Y) :- female(X), sibling(X,Z), parent(Z,Y). Reference: Clocksin W.F. and C.S. Mellish. Programming in Prolog (Fourth Edition) . Berlin: Springer-Verlag, 1994. 1...
View Full Document

This note was uploaded on 06/11/2011 for the course CSCE 330 taught by Professor Valtorta during the Spring '10 term at Columbia SC.

Ask a homework question - tutors are online