CIS 554 Assignment 1: Logic Puzzles
Fall 2012, David Matuszek
Purposes of this assignment
- To give you some experience with logic programming.
- To introduce lists in Prolog.
- To emphasize the declarative nature of Prolog. (The entire program consists of a statement of the problem, not some algorithm to solve the problem.)
General idea of the assignment
Solve two standard (commercial) logic puzzles.
I am providing three such puzzles:
- It's a Tie -- I have provided a sample solution for this one. Use this as a model for your own solutions. (The "main" function is
- Telephone Conversation -- The first part of your assignment is to write (and turn in) a Prolog program to solve this logic puzzle. Once you understand the "It's a Tie" solution, this should be easy. Do this one first.
- Thank You For Whatever It Was -- The second part is to write (and turn in) a Prolog program to solve this logic puzzle.
- Use SWI-Prolog for this assignment (and the next).
- Here's an (old) Concise Guide to Prolog which I wrote up. Still accurate, but not very pretty.
- One of my problems in solving these was spelling errors. Prolog checks for singleton variables, but there is no such check for misspelled atoms, such as
spiegel instead of
speigel. Be especially careful of this.
- These problems make unusually extensive use of the "not" operator,
\+. Here's what you need to know about this operator:
\+ works as you would expect when all variables are completely instantiated (bound).
- Prolog tries to prove things, so if expression E contains unbound variables,
\+E will try to find variable bindings that will make E true.
- While a logic puzzle may be difficult to solve, it is easy to check whether a solution is correct: Just check whether it satisfies each of the numbered rules in the problem.
This one will be easy to grade; your program should produce the correct solution. We may deduct points if your formatting is egregiously bad.
Wednesday, September 12, before 6:00am. Please zip up and turn in three
files to Blackboard--your two
.pl files, along with a file containing the two solutions (copy from the output area and paste them into a text file). Note that I require a zip file, not .rar or some other form of compressed files.