DEPARTMENT OF COMPUTER SCIENCE
CMPS 401  Programming Languages
Spring 2007
Assignment #5
Due: May 3, 2007
In this assignment you will use Prolog, a nonprocedural logic programming language and will become familiar with the basics of logic programming and a specific environment for logic programming.
Part A: (In this part the objective is to use a Prolog system more than writing a Prolog Program) Consider the following facts and rules.
parent(alex,bob). parent(alex,jim). parent(bob, paul). parent(alice,paul). parent(jim,john). parent(marry,jim). parent(john,monty). parent(monty,alice).
descendent(X,Y):parent(Y,X). descendent(X,Y):parent(P,X),write(P),write(' is a parent of '),write(X),nl,descendent(P,Y).
Use a prolog interpreter of your choice to show how prolog will respond to the following input:
descendant(alex, monty)?
descendant(bob, monty)?
Part B: (In this part the objective is to actually write a basic Prolog Program) Using the same database as above, write rules that express the statement that two persons X and Y are assumed to be in the same family if at least one of the following is true:
Either X is parent of Y, or, Y is parent of X, or, there exists some other person D who is parent of both X and Y, or, there exists D for who both X and Y are parents.
Run your rules to obtain the answer to the following:
family(bob, alice)? family(jim, bob)? family(marry, paul)?
References
The following references should adequately recap what we have talked about in class:
www.geocities.com/firepower_50ae/vcc/PrologBasics.htm http://en.wikipedia.org/wiki/Logic_programming www.cs.auckland.ac.nz/~jhamer/07.363/SICStus/sicstus_toc.html http://ktiml.mff.cuni.cz/~bartak/prolog.old/learning.html
You may choose a Prolog compiler from the following source (or any other of your choice): www.thefreecountry.com/compilers/prolog.shtml
The objectives of this assignment are:
 To familiarize you with the logic programming paradigm and a nonprocedural logic programming language
 To familiarize you with a Logic Programming environment and the problem solving methodology used in logic Programming
 To familiarize you with propositional logic, predicate logic, and the basics of the Prolog programming language
