Question: Prolog Programming - CSP Problem Consider the following constraint satisfaction problem (CSP). Alice, Bob, Cindy, and Dan were seated at a table in a restaurant.

Prolog Programming - CSP Problem

Consider the following constraint satisfaction problem (CSP). Alice, Bob, Cindy, and Dan were seated at a table in a restaurant. The men sat across from each other, as did the women. They each ordered a different dessert (not respectively: cake, pie, ice-cream, fruit-cup) with a different beverage (again, in no particular order: milk, juice, tea, water). In addition,

1. Cindy never drinks milk.

2. The cake came with juice.

3. Dan sat beside the person who ordered pie.

4. The person with the ice cream sat across from the person with tea.

5. Bob drank water.

6. Alice did not eat pie.

Who ordered what, i.e find for each person which dessert and beverage the person ordered? Write a Prolog program that can find the orders (Do not waste time on solving this puzzle yourself: Prolog will solve it!).

Q1.a) Using the predicate person(X) characterize the finite domain of 4 people. Next introduce the predicate man(M) and the predicate woman(W) and write atomic statements to characterize gender of all the people. Then, consider a helping predicate across(P1,P2) that holds if a person P1 seats across a person P2 and write two rules that implements this predicate. Similarly, introduce a helping predicate beside (P1,P2) that holds if a person P1 seats beside a person P2 and write two rules that implements this predicate. (Hint: a person P1 is beside(P1,P2) can be either a man or a woman.)

Q1.b) Write a prolog program that solves this instance of CSP. You have to use the interleaving of generate and test technique in your program. Provide in-line comments indicating which constraints you implement where: Use the helping predicates and the predicate person in your program. Make sure that you implement both explicitly given and implicit constraints. If you use any other helping or system predicates in your program, then you have to implements them as well.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!