Sunday, 18 January 2009

First Program

Rules:
In order to work, people must be full and delighted.
work(X) :- delighted(X), full(X).
In order to be full, people must eat something.
full(X) :- ate(X).
In order to be delighted, people must sleep and have fun.
delighted(X) :- slept(X), fun(X).
Facts:
Mustafa ate.
ate(mustafa).
Mustafa slept.
slept(mustafa).
Mustafa had fun.
fun(mustafa).
Query:
Can Mustafa work?




Facts:
eats(fred,oranges).
eats(tony,apple).
eats(john,apple).
Queries:
?- eats(fred,oranges). /* yes
?- eats(john,apple). /*yes
?- eats(mike,apple). /*no

No comments:

Post a Comment