Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Prolog is a language that is suitable for solving problems in the field of artificial intelligence. That is, it can be used to solve
Prolog is a language that is suitable for solving problems in the field of artificial intelligence. That is, it can be used to solve problems that used to be solvable only by human brains. In this assignment, you are asked to write a Prolog program to solve a logic puzzle. II. Using Prolog Gnu Prolog and SWI Prolog have been installed on most computers on campus. If you prefer to use prolog on your own computer, Gnu Prolog can be downloaded from http://www.gprolog.org and SWI Prolog can be downloaded from http://www.swi-prolog.org. To load your program into prolog, you can use the "consult" command, as in the following example: 1 ?- consult ('myProgram.pl'). If you are using Gnu Prolog on Microsoft Windows, you can also use the "File | Consult." menu selection to load the file from a chooser. III. The Puzzle The highlight of a recent conference on medieval literature was the talks given by five professors. Although each scholar (including Professor Santora) hails from a different dubious-sounding institute, he or she presented a different piece of evidence (one is a thank-you note) proving the factual existence of a different character from Beowulf (including Wiglaf). At the end of the seminar, the five professors announced their plans to travel to Scandinavia to unearth the mummified remains of Grendel himself! From the information provided, can you determine the character discussed and the piece of evidence presented by the professor from each institute? 1. The professor who discussed Unferth is not Professor Lund. 2. The professor who discussed Unferth is not the one who presented the canceled check. 3. The professor who presented the canceled check is not the professor from Mountebank University. 4. The professor from the Institute of Pseudoscience is not Professor Eccles. 5. Professor Eccles discussed Breca. 6. Professor Grove of the Charlatan Institute is not the scholar who presented an armory receipt that proved the existence of Hrothgar. 7. The professor from Quackerville University propounded the existence of Unferth. 8. The professor from Quackerville University is not Professor Ibanez. 9. Professor Ibanez presented the love letter. 10. The scholar who presented the grocery list is not the one who talked about Breca. 11. The scholar who talked about Breca is not the one from Hoaxtown College. 12. Professor Ibanez is not the scholar who proved he existence of Hygelac. 13. Professor Lund is not from Hoaxtown College. IV. Analysis Let's first do some book-keeping work, there are: 5 professors: Eccles, Grove, Ibanez, Lund, and Santora; 5 institutions: Charlatan Institute, Hoaxtown College, Institute of Pseudoscience, Mountebank University, and Quackerville Univeristy; 5 characters: Breca, Hrothgar, Hygelac, Unferth, and Wiglaf; and 5 evidences: armory receipt, canceled check, grocery list, love letter, and thank-you note. Now let's define a data structure to hold the information about the scholar. There are many ways to do this. The following is only one of the many possibilities: /* scholar (name, institution,character, evidence). */ Note that you only have to keep this structure in mind. You do not have to enter it into your Prolog program. That is why we put it here as a comment (Prolog comments are enclosed in "/" and "*/", you can also use the single line comments which start with triple percentage sign "*4" and extend until the end of the line). Next, we define a scholarList that contains the five scholars (note that the underscore character " " by itself is used to represent the "don't care" or "don't know" values in Prolog): scholarList ((scholar (eccles,, ), scholar (grove, ), scholar (ibanez,,,), scholar (lund, , , , scholar (santora,,_)1). In our program, we will need to use variables to represent different scholars. We will use the following system of variables: We use the variables Charlatan, Hoaxtown, Pseudoscience, Mountebank, and Quackerville to represent the scholars from Charlatan Institute, Hoaxtown College, Institute of Pseudoscience, Mountebank University, and Quackerville Univeristy, respectively. We use the variables Breca, Hrothgar, Hygelac, Unferth, and wiglaf to represent the scholars who discussed Breca, Hrothgar, Hygelac, Unferth, and Wiglaf, respectively. We use the variables Receipt, Check, List, Letter, and Note to represent the scholars who presented as evidence armory receipt, canceled check, grocery list, love letter, and thank-you note, respectively. We can now define the solution and encode the variables: solution (S) :- scholarList (S), member (scholar (Charlatan, charlatan institute,,_), S), member (scholar (Breca,, breca,_), S), member (scholar (Receipt,_,_armory_receipt), S), The first line says that s is a solution only if s is a scholarList. The comma at the end of the line means the rule is not completed yet. It still has other conditions to satisfy. These additional conditions are specified in the subsequent lines. The other lines establish the variables we will use in our program. Now we can encode the hints into the solution (Hint 1 is encoded below for you): solution (S) :- scholarList (S), member (scholar (Charlatan, charlatan_institute, ,_), S), member (scholar (Breca,_,breca,) , S), member (scholar (Armory,_ armory_receipt), S), /* Hint 1: The professor who discussed Unferth is not Professor Lund */ Unferth \= lund, The last condition in the rule should end with a period. Also note that in Prolog, names start with a lowercase letter are literals (constants), while names start with an uppercase letter are variables. Once your program is loaded into Prolog, simply issuing the following command should give you the answer (Hint: There is exactly one solution to this puzzle): solution (Ans). schedule ( [marriage (1,,_), marriage (2,,), marriage (3, , ), marriage (4,_,), marriage (5,__) ]). solution (S) :- schedule (S), member (marriage (Anne, anne, _), S), member (marriage (, cathy, ), S), member (marriage (Eve, eve, _), S), member (marriage (Fren, fren, ), S), member (marriage (Ida, ida, _), S), member (marriage (_, /* The brides */ /* Rule 6 */ - paul), S), /* The grooms */ /* Rule 5 */ member (marriage (Rob, member (marriage (Stan, member (marriage (Vern, member (marriage (Wally, Anne =:= 1, Wally =\= 1, Stan =:= 3, Rob =:- 5, Ida =\= 5, Vern =:= Fren, rob), S), stan), S), vern), S), _- wally), S), /* Rule 1 */ /* Rule 1 * / /* Rule 2 */ /* Rule 3 */ /* Rule 3 * / /* Rule 4 * / /* Rule 4 */ Vern =:= Eve + 1. Copy and paste your program in the box below: Copy and paste the output of your program in the box below: Solution of the puzzle: Professor Institution Character Evidence Eccles Grove Ibanez Lund Santora
Step by Step Solution
★★★★★
3.50 Rating (170 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started