Showing posts with label first. Show all posts
Showing posts with label first. Show all posts

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

breadth first search algorithm

procedure breadth_first_search;
begin
OPEN:=[START];
CLOSED:=[ ];

while OPEN<>[ ] do
begin
X := dequeue (OPEN);
if final(X)
then return(success);
else
begin
add X to CLOSED
find successors of X
kill the successors of X that are in CLOSED or OPEN;
enqueue the surviving successors of X into OPEN;
end; {else}
end; {while}

return(failure);
end; {breadth_first_search}

Classification of Strategies for State Space Search

Blind (exhaustive, uninformed, naive) – explore the state space systematically without any “suspicion” where the final state might be and direction of the search to it.
Breadth-first search;
Depth-first search (depth-first search with leap-frogging (or just depth-first search), depth-first search with backtracking (or just Backtracking)
Uniform-cost search;
Iterative deepening;
Etc.
Heuristic (informed)- exploit state descriptions to select the “most promising” node