Tuesday, July 17, 2012

Monkey- Banana Problem in Prolog

Monkey-Banana Problem is the famous problem in AI. Where there is a room containing a monkey, a chair, and bananas that have been hung from the center of the ceiling of the room; out of reach from monkey. If the monkey is cleaver enough, he can reach the bananas by placing the chair directly below the bananas and climbing on the top of the chair.
Now the problem is to use FOPL to represent this monkey-banana problem and prove that monkey can reach the bananas.
The program is given below. Before running the program, think carefully what are the essential objects of the problem and how should them be arranged in predicate logic. 

PREDICATES
in_room(symbol)
dexterous(symbol)
tall(symbol)
can_move(symbol,symbol,symbol)
can_reach(symbol,symbol)
get_on(symbol,symbol)
can_climb(symbol,symbol)
close(symbol,symbol)
under(symbol,symbol)
can_climb(symbol,symbol)
 
CLAUSES
in_room(bananas).
in_room(chair).
in_room(monkey).
dexterous(monkey).
tall(chair).
can_move(monkey,chair,bananas).
can_climb(monkey,chair).

can_reach(X,Y):-
            dexterous(X),close(X,Y).

close(X,Z):-
            get_on(X,Y),
            under(Y,Z),
            tall(Y).
get_on(X,Y):-
            can_climb(X,Y).

under(Y,Z):-
            in_room(X),
            in_room(Y),
            in_room(Z),
     can_move(X,Y,Z).

GOAL
can_reach(monkey,appple).

No comments:

Post a Comment