CIS 554 Prolog 1: Logic Puzzles
Fall 2016, 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

Read and understand the following program:

• It's a Tie -- I have provided a sample solution for this one, and a page of notes on how it works. Use this as a model for your own solutions. (The "main" function is `solve`).

Solve two standard (commercial) logic puzzles.

## Notes

• 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:
• Prolog tries to prove things, so if expression E contains unbound variables,` \+E` will try to find variable bindings that will make E true. If it fails to make `E` true, no new bindings are formed; if it succeeds, then`\+E` will fail, and no new bindings are formed.
• Consequently, `\+E` will never result in additional bindings!
• `\+ `works as you would expect when all variables are completely instantiated (bound).
• 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.
• If you want to solve logic puzzles manually, here's how to do it. However, that isn't the way to do it by a computer!

There are two similar programs in this assignment, worth 50 points each. You earn full credit for each program that produces the correct solution, half credit for a program that appears to run but produces an incorrect solution.

How can you tell if your results are correct? Just manually check whether the solution satisfies all of the conditions of the problem! (Checking a solution is much easier than finding one.)

Although unlikely, we reserve the right to deduct points if your style is egregiously bad.

# Due date

Midnight Tuesday, September 8. Please zip up and turn in three files to Canvas--your two` .pl` files, along with a file containing the two solutions (copy from the output area and paste them into a text file).

Also see the late policy, especially as it applies to this first assignment.