
- Objective Learning About Logic Programming And Prolog In Particular You Need A Prolog Interpreter You Can Use Swi Pro 1 (557.16 KiB) Viewed 46 times
Objective: Learning about logic programming and Prolog in particular. You need a Prolog interpreter. You can use SWI-Prolog or Amzi Prolog which you need to download, or you can use online SWI-SH which does not require any download but is less powerful in general. Downloading an interpreter to your system is recommended Problem Definition You are a pet detective. A lovely parrot is kidnapped! The owner of the parrot hired you. The only clue is the security camera recordings. You've analyzed camera recordings and found a plate number that led to an address. There are six people living in this house. You've arrested them all, they are your suspects now. Six bags with different colors are found in this house, you don't know who owns which bag. And your suspects deny cooperating. A food item was carried in each bag, according to "criminal analysis". However, you are not sure about food items because one of the suspects managed to clear them before you arrested them. Your goal is to find who committed this horrible crime! For that, you must learn who owns which bags, as well as what was the food item that bag. As a result of your interrogations, you've ended up with som clues. The suspect who owns the bag which carried the food item nuts is guilty! • Men: Gencer, Can, Rasim. Women: Beyza, Canan, Meryem. • Bags: BlueBag, OrangeBag, RedBag, PurpleBag, GreenBag, YellowBag. • Food: Avocado, Onion, Nuts, Chocolate, Garlic, Cookies. Clues 1. The man who owns the RedBag did not carry Cookies, Chocolate, or Avocado. 2. Onion was not carried by using RedBag. 3. Beyza owns either the YellowBag or the BlueBag; Meryem owns the other. 4. The person who carried the Avocado, who was not Beyza nor Gencer, does not own BlueBag nor the OrangeBag. 5. The woman who carried the Cookies owns the YellowBag. 6. The food item carried with PurpleBag belongs to either Can or Gencer. 7. The Chocolate was not carried with OrangeBag. 8. Meryem did not carry a food item with the YellowBag nor the GreenBag. 9. Onion is carried by Gencer. 10. Nuts were carried with GreenBag and that person was guilty.
Assignment Your program should do the following; ● Define appropriate predicates, namely man, woman, person. Write a rule for each clue. Keep the clue numbers (e.g. clue1, clue2,...) Find the answer to final conjunctive query guilty(X), which will return the substition for the kidnapper. Query guilty (X) should also print all the relations (who owns which bag and which food item is carried by using which bag etc.), together with who the kidnapper is. ● Below is a sample clue but as long as you have a compact/readable approach, it can be different. For instance with person (name,carried, owns...) predicates etc. Clue9 (Carried Onion):- PersonCarriedOnion=gencer.