CSE 505, Autumn 1996

D. Notkin

Homework #4
Assigned: 10/23/96

Due: 11/1/96

This assignment focuses on logic programming and constraint logic programming. The programming will be in CLPR; we'll send information to the mailing list about where to find the compiler, etc. You may work in pairs, turning in a single assignment with both names, receiving a single, shared grade. Assignments are due (non-electronically, watching for instructions from Kurt) by the beginning of class on the due date. This assignment is worth 10% of the quarter's assignments (which in turn are worth 50% of the total grade).

  1. (10 points) Assume that in addition to stating facts in a logic programming language, one could also state what is known not to be true. Discuss the consequences on logic programming computations and on the closed-world assumption.
  2. (10 points) Prolog provides primitives to add new facts and rules to the database. Explain how you can use this facility to create programs with state by simulating von Neumann variables. Briefly discuss whether this is an effective way to exploit the benefits logic programming.
  3. (10 points) Write a program to solve the following logic puzzle. There are five houses, each of a different color and inhabited by different students, with a different favorite pet, drink, and brand of candy.

a. Jeremy lives in the red house.

b. Molly owns the dog.

c. Coffee is drunk in the green house.

d. Brian drinks tea.

e. The green house is immediately to the right (your right) of the ivory house.

f. The Snickers eater owns snails.

g. Junior Mints are eaten in the yellow house.

h. Milk is drunk in the middle house.

i. Craig lives in the first house to on the left.

j. The student who eats Skittles lives in the house next to the student with the fox.

k. Junior Mints are eaten in the house next to the house where the horse is kept.

l. The Sweet Tarts eater drinks orange juice.

m. Todd eats M&M's.

n. Craig lives next to the blue house

Who owns the zebra? Who drinks water?

4. (10 points) /cse/courses/cse505/F96/clpr/examples2/points contains some basic CLPR code for manipulating cartesian points. Extend the definitions to include:

5. (10 points) Consider computing grades for a student. There are five assignments, a project, and a final. The assignments are worth 10%, 20%, 5%, 15%, and 10% respectively; the project is worth 25% and the final is worth 15%. Each assignment, the project, and the final is graded on its own scale from 0 to N (that is, N may vary for each). Write a CLPR program that computes a weighted final grade for the course on a scale of 0 to 1. In addition, your program should support queries such as, "How much do I have to get on the final to get a 0.85 or better?"

6. (10 points) For problems #3 and #4, discuss whether or not it would matter if you used Prolog or CLPR.