Question: 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 once were solvable only by human brains. In this assignment, you are asked to write a Prolog program to solve logic puzzle.
To load your program into Prolog, you can use the consult command, as in the following example: consultmyProgramplGnu Prolog on Microsoft Windows, use "File Consult..."
The Puzzle Adopted from Original Logic Problems published by PennyPress some years ago
In order to mooch some air conditioning. Jack braved the heat wave and came out to the Jefferson Decaplex. Taking a quick glance at the marquee, he can see that a different movie is playing on each screen through and that each film is a different genre one is a spy thriller Looking at all these choices, He feels like he is being given some kind of screen test! From the information provided, can you determine the genre of the
movie playing on each screen?
The screen on which Brisbane is playing is numbered exactly higher than the screen on which the historical epic is showing but exactly lower than the screen on which Long Shot is playing.
Jet Set is playing on a highernumbered screen than Pigeon but a lowernumbered screen than the Western.
The musical is playing on screen
The screen on which the comedy is playing is numbered exactly higher than the screen on which The Gentleman is showing but exactly lower than the screen on which Frostfire is playing.
The Gentleman is not a sciencefiction movie.
The horror movie is playing on the screen numbered exactly higher than the screen on which Newtons Laws is showing.
Vulture Gulch is playing on the screen numbered exactly higher than the screen on which the documentary is showing.
The documentary is playing on a highernumbered screen than the comedy.
The screen on which Ellipsis is playing is numbered exactly higher than the screen on which the action flick is showing but exactly lower than the screen on which the sciencefiction movie is playing.
The action film, the historical epic, and the romance movie are playing on screens and in some order; one of these films is Tower of London.
The difference between the numbers of the screen on which Newtons Laws and Vulture Gulch are playing is the same as the difference between the numbers of screen on which the Gentleman and Tower of London are showing.
Analysis
There are:
screens: through ;
movie titles: Brisbane, Ellipsis, Frostfire, Jet Set, Long Shot, Pigeon, Newtons Laws, The Gentleman, Tower of London, and Vulture Gulch;
genres: action flick, comedy, documentary, historical epic, horror, musical, romance, spy thriller, science fiction, and western.
Now lets define a data structure. The following is only one of the many possibilities: screenscreennumber, movietitle, genre
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 has two types of comments: multiline comments are enclosed in and you can also use single line comments which start with triple percentage sign
and extend until the end of the lineNext, we define an arrangement that contains the ten screens note that the underscore character by itself is used to represent a dont care or dont know value in Prolog:
arrangementscreen screen screen screen
screen screen screen screen screen screen
In our program, we will need to use variables to represent different screens. We will use the following system of variables:
We use the variables Brisbane, Ellipsis, Frostfire, JetSet, LongShot, Pigeon, NewtonsLaws, Gentleman, TowerofLondon, and VultureGulch to represent the screen number on which the movie Brisbane, Ellipsis, Frostfire, Jet Set, Long Shot, Pigeon, Newtons Laws, The Gentleman, Tower of London, and Vulture Gulch is playing, respectively.
We use the variables Action, Comedy, Documentary, Historical, Horror, Musical, Romance, Spy SciFi, and Western to represent the screen on which action flick, comedy, documentary, historical epic, horror, musical, romance, spy thriller, science fiction, and western movie is playing, respectively.
To define solution and encode variables:
solutionS : arrangementS
memberscreenBrisbanebrisbane, S
memberscreenActionaction S
The first line says that S is a solution if S is an arrangement. The comma at the end of the line means the rule is not complete yet. It still has other conditions to satisfy. These additional conditions are specified in the subsequent lines. The other groups of lines establish variable and fact relationships.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
