Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROLOG PROLOG NO LISP NO LSIP DO NOT COPY FROM OTHERS THOSE ARE LISP The Farmer Problem Consider the famous problem of a farmer having

PROLOG PROLOG NO LISP NO LSIP DO NOT COPY FROM OTHERS THOSE ARE LISP

The Farmer Problem Consider the famous problem of a farmer having a goat, a wolf, and a cabbage. The farmer wants to cross the river from the east shore to the west shore, but his boat is small. The boat has space for only the farmer with one of the items: cabbage, wolf, or goat. The farmer cannot leave the wolf alone with the goat or the goat alone with the cabbage.

The state space for this problem can be represented by the different situations of the four subjects that can be at any time either on the east or the west shore, but when moving from one state to another the items are subject to the conditions specified in the previous paragraph.

We can represent a state space by the relation s(X, Y), which is true only if there is a legal move from state X to state Y within the specified conditions.

Each state can be represented by the tuple (FP, GP, WP, CP), where the variables FP, GP, WP, CP can have only two values (e, w), which indicate the position east or west of the farmer, goat, wolf, and cabbage.

The initial state of the system can be represented by (e, e, e, e), where all subjects are on the east side.

The goal state of the system can be represented by (w, w, w, w), where all subjects have been moved to the west side.

Other intermediate states will be represented using combinations of these positions (e,w).

1. Write a depth-first search program IN PROLOGwith cycle detection to find and display different solution paths for the farmer problem. (20 marks)

2. Write a breadth-first search program IN PROLOG with cycle detection to find and display different solution paths for the farmer problem. (20 marks)

Note: all data about the state space and the initial state of the system should be defined in the program as facts. Your program should list for each path the possible steps the farmer may take to move his items across the river safely. You should explain how your predicate works and give some execution examples.

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

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions