Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview The purpose of this assignment is to practice answer set programming by writing a logic program whos answer set(s) corre- spond to solution(s) to

image text in transcribed

image text in transcribed

Overview The purpose of this assignment is to practice answer set programming by writing a logic program whos answer set(s) corre- spond to solution(s) to Einstein's Riddle. Einstein's Riddle There are 5 houses in five different colors. In each house lives a person with a different nationality. These five owners drink a certain type of beverage, smoke a certain brand of cigar and keep a certain pet. No owners have the same pet, smoke the same brand of cigar or drink the same beverage. Who owns the fish? Hints 1. The Brit lives in the red house. 2. The Swede keeps dogs as pets. 3. The Dane drinks tea. 4. The green house is on the left of the white house. 5. The green house's owner drinks coffee. 6. The person who smokes Pall Mall rears birds. 7. The owner of the yellow house smokes Dunhill. 8. The man living in the center house drinks milk. 9. The Norwegian lives in the first house. 10. The man who smokes blends lives next to the one who keeps cats. 11. The man who keeps horses lives next to the man who smokes Dunhill. 12. The owner who smokes BlueMaster drinks beer. 13. The German smokes Prince. 14. The Norwegian lives next to the blue house. 15. The man who smokes blend has a neighbor who drinks water. Programming Hints To help get you started, let us suppose that we have the following vocabulary: 1. The relation color/1, where facts of the form color(C) are read as "C is a color." 2. The relation house/1, where facts of the form house(H) are read as "H is a house. 3. The relation color_of/2, where facts of the form color_of(H,C) are read as "c is the color of house H". In the language of the answer set solver clingo, the following pair of generation rules may be used to represent the facts that: Every house is associated with exactly one color, and every color is associated with exactly one house. 1 2 1{color_of(H,C) : color(C)}1 :- house(H). 1{color_of(H,C) : house(H)}1 :- color(C). Similar rules may be written for other relations that will benefit from this kind of "generation strategy." Similarly, let us take a look at the first hint: The Brit lives in the read house. If have the following additional relation: 1. lives_in/2, where facts of the form lives_in(H, P) are read as "person P lives in house H". We can represent the first clue via the following rule: 1 lives_in(H, brit) :- color_of(H, red). Overview The purpose of this assignment is to practice answer set programming by writing a logic program whos answer set(s) corre- spond to solution(s) to Einstein's Riddle. Einstein's Riddle There are 5 houses in five different colors. In each house lives a person with a different nationality. These five owners drink a certain type of beverage, smoke a certain brand of cigar and keep a certain pet. No owners have the same pet, smoke the same brand of cigar or drink the same beverage. Who owns the fish? Hints 1. The Brit lives in the red house. 2. The Swede keeps dogs as pets. 3. The Dane drinks tea. 4. The green house is on the left of the white house. 5. The green house's owner drinks coffee. 6. The person who smokes Pall Mall rears birds. 7. The owner of the yellow house smokes Dunhill. 8. The man living in the center house drinks milk. 9. The Norwegian lives in the first house. 10. The man who smokes blends lives next to the one who keeps cats. 11. The man who keeps horses lives next to the man who smokes Dunhill. 12. The owner who smokes BlueMaster drinks beer. 13. The German smokes Prince. 14. The Norwegian lives next to the blue house. 15. The man who smokes blend has a neighbor who drinks water. Programming Hints To help get you started, let us suppose that we have the following vocabulary: 1. The relation color/1, where facts of the form color(C) are read as "C is a color." 2. The relation house/1, where facts of the form house(H) are read as "H is a house. 3. The relation color_of/2, where facts of the form color_of(H,C) are read as "c is the color of house H". In the language of the answer set solver clingo, the following pair of generation rules may be used to represent the facts that: Every house is associated with exactly one color, and every color is associated with exactly one house. 1 2 1{color_of(H,C) : color(C)}1 :- house(H). 1{color_of(H,C) : house(H)}1 :- color(C). Similar rules may be written for other relations that will benefit from this kind of "generation strategy." Similarly, let us take a look at the first hint: The Brit lives in the read house. If have the following additional relation: 1. lives_in/2, where facts of the form lives_in(H, P) are read as "person P lives in house H". We can represent the first clue via the following rule: 1 lives_in(H, brit) :- color_of(H, red)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

Which form of proof do you find most persuasive? Why?

Answered: 1 week ago