1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs:...
-
Upload
irene-hart -
Category
Documents
-
view
213 -
download
0
Transcript of 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs:...
![Page 1: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/1.jpg)
1CSC 8520 Spring 2010. Paula Matuszek
• On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library.
• Download them and consult planner.pl, which will in turn consult adts.pl.
?- consult('planner.pl').
% adts compiled 0.00 sec, 6,364 bytes
% planner.pl compiled 0.00 sec, 11,456 bytes
true.
Lab Exercise 1
![Page 2: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/2.jpg)
2CSC 8520 Spring 2010. Paula Matuszek
• Test that it is working by typing “test.” at the prompt.• You should get a list of moves.
?- test.
moves are
pickup(a)
putdown(a)
pickup(b)
stack(b, c)
pickup(a)
stack(a, b)
true.
?-
![Page 3: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/3.jpg)
3CSC 8520 Spring 2010. Paula Matuszek
Planner• Planner is a very simple Prolog implementation
of a planner using a STRIPS-like notation.
• A state is a list of conditions.
• A problem has an initial state and a goal state. For instance:– the initial state for a blocks world might be:
– [handempty, ontable(b), ontable(c), on(a, b), clear(c), clear(a)]
– the goal state for the blocks world might be: [handempty, ontable(c), on(a,b), on(b, c), clear(a)]
![Page 4: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/4.jpg)
4CSC 8520 Spring 2010. Paula Matuszek
Moves• A move is an action, consisting of a name, a
list of preconditions, and an effect list of changes.
• Moves are included in the Prolog file. • For example:move(pickup(X), % move name
[handempty, clear(X), on(X, Y)], % preconditions
[del(handempty), del(clear(X)), % list of conditions
del(on(X, Y)), add(clear(Y)), % to be added and
add(holding(X))]). % deleted
![Page 5: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/5.jpg)
5CSC 8520 Spring 2010. Paula Matuszek
plan• plan takes a current state, a goal state, a list of
states which have already been reached (Been_list), and a list of moves which have already been carried out. It then– checks to see if the current state = goal state. If so, print
out list of moves.
– finds an applicable move
– does the adds and deletes
– checks to be sure we haven’t already been there
– adds the current state to the list of states and the current move to the list of moves
– recurs.
![Page 6: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/6.jpg)
6CSC 8520 Spring 2010. Paula Matuszek
Running it• go takes an initial state and a goal state
• it invokes plan with – current state = initial state– goal state = goal state– Been_list = initial state– Moves list empty.
• test is just there to give a way to test it, using the blocks world.
6
![Page 7: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/7.jpg)
7CSC 8520 Spring 2010. Paula Matuszek
Spare tire problem• Problem: you have a flat. Develop a plan to
fix it. – Initial condition is that the flat is on the axle and
the spare is in the trunk.
– Goal condition is that the flat is in the trunk and the spare is on the axle.
– Some possible actions include removing something from something, installing something in something.
– Some possible conditions include at(a,b) and clear(axle)
![Page 8: 1 CSC 8520 Spring 2010. Paula Matuszek On the syllabus page there are links to two Prolog programs: a simple Prolog planner and an ADT library. Download.](https://reader036.fdocuments.in/reader036/viewer/2022071806/56649cf75503460f949c6c8a/html5/thumbnails/8.jpg)
8CSC 8520 Spring 2010. Paula Matuszek
Lab exercise 2.• Develop the appropriate initial state, goal
state and move definitions for the Spare Tire Problem.
• Add to planner.pl your moves and a new predicate test2 which solves this problem.