CSE 3302 ProgrammingLanguages
Summer 07
Programming project #4
(worth 10% of total grade)
Due August 7th (Monday) at class time - 1pm.
Turn in the lab by email to the TA plus write up bye-mail to Dr. T. Projects
turned in on or before midnight May 4th will receive up to 5 points extra credit.
Assignment:
Translate the following into a Prolog database. Save the program in a file called Òmyfamily.plÓ. Read this file into Prolog and then
formulate queries as listed below.
Starting with
the rules given in class as the Prolog example, write a set of rules and facts
about your family.
The rules for
the Prolog database should define all of the following relationships:
parent(X, Y)
grandparent(X,Y)
ancestor(X,Y)
grandmother(X,Y)
grandfather(X,Y)
grandchild(X,Y)
grandson(X,Y)
granddaughter(X,Y)
son(X,Y)
daughter(X,Y)
sibling(X,Y)
sister(X,Y)
brother(X,Y)
child(X,Y)
aunt(X,Y)
uncle(X,Y)
cousin(X,Y)
greataunt(X,Y)
greatuncle(X,Y)
Extra credit
(up to 5 points): relative(X,Y)
The facts may
be of four types Ð mother, father, female, male - as follows:
mother(mommy, me)
father(pops, me)
female(mommy)
male(pops)
female(me)
Remember that
constant values start with small letters.
For your database, the facts should be facts about your own family. You must include at least 15 individuals
in your facts. (If you are
uncomfortable using your own familyÕs names, then you may write facts related
to some fictional but well-known family with at least 15 individuals in the
fact base, ex. the Simpsons, the Brady Bunch, the
British Royal Family [yeah, I know they arenÕt fictionalÉ]) If you are using you own family
then the queries below relate to you.
If you are using a fictional family then pick one member to be the
ÒfocusÓ member (ex. Lisa Simpson) for the queries below.
1. Who is your grandmother? (or your focus
memberÕs grandmother?)
2. List all of your cousins.
3. Do you have any children?
4. Who are your aunts and greataunts?
You must turn in soft copy ONLY for
the following:
1) Your
source code for the program to the TA
2) A
script of the program execution and output Ð can be interpreter output Ð to the
TA
3) A
half-page single space write up of what you liked and disliked about using
Prolog and comparing it to Lisp as well as comparing it to C and C++ (or Java)
to Dr. T
Your program will be graded on the
quality of the code and the documentation (35%), the correctness and
completeness of the program output (50%), and your write up about using the
language (15%)
Notes:
There are many online references for Prolog.
Feel free to use these just make sure to cite them as sources if used for your
write up.