Prolog code-missionary cannibal problem-water jug problem


Write Prolog programs for each of given problems. For each of your programs:

a) Execute your code and draw a graph of search space.
b) Modify the rule ordering to produce alternative solution paths.

Question 1: A Prolog code to answer Wirth’s “I am my own grandfather” problem:

I married a widow (let’s call her W) who has a grown-up daughter (call her D). My father (F), who visited us quite frequently, fell in love with my step-daughter and married her. Therefore my father became my son-in-law and my step-daughter became my mother. Some months later, my wife gave birth to a son (S1), who became the brother-in-law of my father, and also my uncle. The wife of my father, that is, my step-daughter, as well had a son (S2).

Question 2: A Prolog code to solve the farmer, wolf, goat and cabbage problem:

A farmer with his wolf, goat and cabbage come to the edge of the river they wish to cross. There is a boat at the river’s edge, however of course, only the farmer can row. The boat as well can carry only two things, including the rower, at a time. If the wolf is ever left alone with the goat, the wolf will eat the goat; likewise if the goat is left alone with the cabbage, the goat will eat the cabbage. Devise a series of crossings of the river so that all four characters arrive safely on the other side of river.

Question 3: A Prolog code for the missionary and cannibal problem:

Three missionaries and three cannibals come to the bank of a river they wish to cross. Three is a boat which will hold only two, and any of the group is capable to row. If there are ever more missionaries than cannibals on any side of the river the cannibals will get converted. Devise a series of moves to get all the people across the river with no conversions.

Question 4: A Prolog code for the water jugs problem:

There are two jugs, one holding 3 and the other 5 gallons of water. A number of things can be completed with the jugs: they can be filled, emptied and dumped one into the other either till the poured-into jug is full or till the poured-out-of jug is empty. Devise a sequence of actions which will produce 4 gallons of water in the larger jug.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Prolog code-missionary cannibal problem-water jug problem
Reference No:- TGS0896

Expected delivery within 24 Hours