33
1 State-Space representation State-Space representation and Production Systems and Production Systems Introduction: what is State-space Introduction: what is State-space representation? representation? What are the important trade-offs? What are the important trade-offs? (E.Rich, Chapt.2) (E.Rich, Chapt.2) Basis search methods. Basis search methods. (Winston, Chapt.4 + (Winston, Chapt.4 + Russel&Norvig) Russel&Norvig) Optimal-path search methods. Optimal-path search methods. (Winston, Chapt.5 + (Winston, Chapt.5 + Russel&Norvig) Russel&Norvig) Advanced properties and variants. Advanced properties and variants. (Rich, Chapt.3 + (Rich, Chapt.3 + Russel&Norvig + Nilsson) Russel&Norvig + Nilsson)

State-Space representation and Production Systems

  • Upload
    jill

  • View
    43

  • Download
    1

Embed Size (px)

DESCRIPTION

State-Space representation and Production Systems. Introduction: what is State-space representation? What are the important trade-offs? (E.Rich, Chapt.2) Basis search methods. (Winston, Chapt.4 + Russel&Norvig) Optimal-path search methods. (Winston, Chapt.5 + Russel&Norvig) - PowerPoint PPT Presentation

Citation preview

Page 1: State-Space representation and  Production Systems

1

State-Space representationState-Space representationand Production Systemsand Production Systems

Introduction: what is State-space representation? Introduction: what is State-space representation?

What are the important trade-offs?What are the important trade-offs?(E.Rich, Chapt.2)(E.Rich, Chapt.2)

Basis search methods.Basis search methods.(Winston, Chapt.4 + Russel&Norvig)(Winston, Chapt.4 + Russel&Norvig)

Optimal-path search methods.Optimal-path search methods.(Winston, Chapt.5 + (Winston, Chapt.5 +

Russel&Norvig)Russel&Norvig)

Advanced properties and variants.Advanced properties and variants.(Rich, Chapt.3 + Russel&Norvig + (Rich, Chapt.3 + Russel&Norvig +

Nilsson)Nilsson)

Game PlayingGame Playing(Winston, Chapt.6 + Rich + (Winston, Chapt.6 + Rich +

Russel&Norvig Russel&Norvig ))

Page 2: State-Space representation and  Production Systems

2

Page 3: State-Space representation and  Production Systems

3

State-space representation:State-space representation:Introduction and trade-offsIntroduction and trade-offs

What is state-space representation?What is state-space representation?

Which are the technical issues that arise in Which are the technical issues that arise in that context?that context?

What are the alternatives that the paradigm What are the alternatives that the paradigm offers to solve a problem in the state-space offers to solve a problem in the state-space representation?representation?

Page 4: State-Space representation and  Production Systems

4

Example: the 8-puzzle.Example: the 8-puzzle.

Given:Given: a board situation for the 8-puzzle: a board situation for the 8-puzzle:

11 33 88

22 77

55 44 66

11 22 33

5566774488

ProblemProblem:: find a sequence of moves (allowed find a sequence of moves (allowed under the rules of the 8-puzzle game) that under the rules of the 8-puzzle game) that transform this board situation in a desired goal transform this board situation in a desired goal situation:situation:

Page 5: State-Space representation and  Production Systems

5

State-space representation:State-space representation:general outline:general outline:

Select some way to represent states in the Select some way to represent states in the problem in an unambiguous way.problem in an unambiguous way.

Formulate all actions that can be preformed in Formulate all actions that can be preformed in states:states: including their preconditions and effectsincluding their preconditions and effects

== PRODUCTION RULES== PRODUCTION RULES Represent the initial state (s).Represent the initial state (s). Formulate precisely when a state satisfies the goal Formulate precisely when a state satisfies the goal

of our problem.of our problem. Activate the production rules on the initial state Activate the production rules on the initial state

and its descendants, until a goal state is reached.and its descendants, until a goal state is reached.

Page 6: State-Space representation and  Production Systems

6

Initial issues to solve:Initial issues to solve:

How to formulate production rules?How to formulate production rules? (repr. 2(repr. 2)) ExEx.: .:

express how/when squares may be moved?express how/when squares may be moved? OrOr: express how/when the blank space is : express how/when the blank space is

moved?moved? When is a rule applicable to a state? When is a rule applicable to a state? (matching)(matching) How to formulate when the goal criterion is satified How to formulate when the goal criterion is satified

and how to verify that it is?and how to verify that it is? How/which rules to activate? How/which rules to activate? (control)(control)

11 33 8822 7755 44 66

How to represent states? How to represent states? (repr.1)(repr.1) ExEx.: using a 3 X 3 matrix.: using a 3 X 3 matrix

Page 7: State-Space representation and  Production Systems

7

The (implicit) search treeThe (implicit) search tree Each state-space representation defines a Each state-space representation defines a

search tree:search tree:

11 33 8822 7755 44 66

11 33 8822 77

55 44 66

11 33 8822 7755 44 66

1133

8822 7755 44 66

11 33 8822 7755

4466

9!/29!/2nodes!nodes!

goalgoal

But this tree is only IMPLICITLY available !!But this tree is only IMPLICITLY available !!

Page 8: State-Space representation and  Production Systems

8

A second example: ChessA second example: Chess ProblemProblem: develop a program that plays chess (well).: develop a program that plays chess (well).

1122334455667788

A B C D E F G A B C D E F G HH

1. A way to 1. A way to represent board situationsrepresent board situations in an in an unambiguous way: unambiguous way:

ExEx.:.:

List:List:(( king_black, 8, C),(( king_black, 8, C), ( knight_black, 7, B),( knight_black, 7, B), ( pawn_black, 7, G),( pawn_black, 7, G), ( pawn_black, 5, F),( pawn_black, 5, F), ( pawn_white, 2, H),( pawn_white, 2, H), ( king_white, 1, E))( king_white, 1, E))

Page 9: State-Space representation and  Production Systems

9

Chess (2):Chess (2):

2. Describe the 2. Describe the rules that represent allowed rules that represent allowed moves:moves:

Ex.:Ex.:

11223344

A B C D E F G A B C D E F G HH

( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) )( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) )

add( ( pawn_white, 4, x) ),add( ( pawn_white, 4, x) ),remove( (pawn_white, 2, x) )remove( (pawn_white, 2, x) )

Page 10: State-Space representation and  Production Systems

10

Chess (3):Chess (3): 3. Provide a way to check whether 3. Provide a way to check whether a rule isa rule is

applicable to some stateapplicable to some state:: Ex.:Ex.:

Matching mechanism !!Matching mechanism !!

( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) )( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) )add( ( pawn_white, 4, x) ),add( ( pawn_white, 4, x) ),remove( (pawn_white, 2, x) )remove( (pawn_white, 2, x) )

List:List:(( king_black, 8, C),(( king_black, 8, C), ( knight_black, 7, B),( knight_black, 7, B), ( pawn_black, 7, G),( pawn_black, 7, G), ( pawn_black, 5, F),( pawn_black, 5, F), ( pawn_white, 2, H)( pawn_white, 2, H),, ( king_white, 1, E))( king_white, 1, E))

1122334455667788

A B C D E F G HA B C D E F G H

Page 11: State-Space representation and  Production Systems

11

Chess (4):Chess (4): 4. How to 4. How to specifyspecify a state in which the a state in which the goal is goal is

reachedreached (= a winning state): (= a winning state): Ex.:Ex.:

win( black ) win( black ) attacked( king_white ) and attacked( king_white ) and

no_legal_move( king_white )no_legal_move( king_white )

+ similar definitions for:+ similar definitions for:

attacked( Piece ) attacked( Piece ) … …no_legal_move( Piece ) no_legal_move( Piece ) ... ...

Page 12: State-Space representation and  Production Systems

12

Chess (5):Chess (5):

5. A way to 5. A way to verifyverify whether a whether a winning state is winning state is reached.reached.

Ex.:Ex.:

?- ?- win( black ).win( black ).win( black ) win( black ) attacked( king_white ) and attacked( king_white ) and

no_legal_move( king_white )no_legal_move( king_white )

……

Need a theorem prover ( e.g. Prolog) to verifyNeed a theorem prover ( e.g. Prolog) to verifythat the state is a winning one.that the state is a winning one.

Page 13: State-Space representation and  Production Systems

13

Chess (6).Chess (6).

6. The 6. The initial stateinitial state..

A program that is A program that is ABLEABLE to play chess. to play chess.

The The control problemcontrol problem ! !

Main focus of this entireMain focus of this entirechapter of the course !!chapter of the course !!

7. A mechanism that 7. A mechanism that selects in each state an selects in each state an appropriate rule to apply.appropriate rule to apply.

Page 14: State-Space representation and  Production Systems

14

Chess (7).Chess (7).

Move 1Move 1

Move 2Move 2

Move 3Move 3

Implicit search treeImplicit search tree~15~15

~ (15)~ (15)22

~ (15)~ (15)33

Need Need very efficient searchvery efficient search techniques to find good techniques to find goodpaths in such combinatorial trees.paths in such combinatorial trees.

Page 15: State-Space representation and  Production Systems

15

Very many issues and trade-offs:Very many issues and trade-offs:

1. How to 1. How to choose the ruleschoose the rules? ?

2. Should we search through the 2. Should we search through the implicit treeimplicit tree or or through an through an implicit graphimplicit graph??

3. Do we need an 3. Do we need an optimal solutionoptimal solution, or just any , or just any solution?solution?

‘ ‘optimal path problems’optimal path problems’

4. Can we 4. Can we decompose states into componentsdecompose states into components on on which simple rules can in an independent way?which simple rules can in an independent way?

Problem reduction or decomposabilityProblem reduction or decomposability

5. Should we search 5. Should we search forwardsforwards from the initial state, from the initial state, or or backwardsbackwards from a goal state? from a goal state?

Page 16: State-Space representation and  Production Systems

16

1. Choice of the rules1. Choice of the rules

Example: The water jugs problem:Example: The water jugs problem:

Given:Given: 2 jugs: 2 jugs:

Problem:Problem: fill the 4 l jug with 2 l of water. fill the 4 l jug with 2 l of water.

4 l4 l 3 l3 l

Representation:Representation: a state:a state:

[content of large jug, content of small jug][content of large jug, content of small jug] initial state:initial state:

[ 0, 0 ][ 0, 0 ] goal state:goal state:

[ 2, x ][ 2, x ]

Page 17: State-Space representation and  Production Systems

17

Rules for the jugs example:Rules for the jugs example: Fill large:Fill large:

[[ x x,, y y ]] andand x x << 44 [[ 44, , y y ]]

Fill small:Fill small:

[[ x x,, y y ] ] andand y y << 33 [[ x x,, 33 ] ] Empty large:Empty large:

[[ x x,, y y ] ] andand x x >> 00 [[ 00,, y y ]] Remove some from large:Remove some from large:

[[ x x,, y y ] ] andand x x >> dd >> 0 0 [ [ x x - d- d, , y y ]] Empty (remove some from) small.Empty (remove some from) small.

Page 18: State-Space representation and  Production Systems

18

Rules for the jugs example (2):Rules for the jugs example (2):

Fill large from small:Fill large from small:

[[ x x,, y y ]] andand x x ++ y y 44 and and yy > > 00 [[ 44, , yy-(-(44--xx)) ]]

Fill small from large.Fill small from large.

Empty small in large:Empty small in large:

[[ x x,, y y ] ] andand x x ++ y y 44 and and y y >> 00 [ [ x x ++ y y , , 0 0 ]]

Empty large in small.Empty large in small.

Page 19: State-Space representation and  Production Systems

19

[ [ 00, , 00 ] ]

[ [ 00, , 33 ] ]

Fill smallFill small

[ [ 33, , 00 ] ]

Empty smallEmpty small in largein large

[ [ 33, , 33 ] ]

Fill smallFill small

[ [ 44, , 22 ] ]Fill largeFill largefrom smallfrom small

Part of the state space:Part of the state space:

[ [ 44, , 00 ] ] [ [ 00, , 00 ] ]

[ [ 00, , 3-d13-d1]]

[ [ 44, , 33]][ [ 00, , 00]]

[ [ 00, , 3-d1-d23-d1-d2]]

[ [ 3-d13-d1, , 00]][ [ 44, , 3-d13-d1]]

Redundant Redundant subspace !subspace !

**

**

[ [ 22, , 00 ] ]Empty small in largeEmpty small in large

[ [ 00, , 22 ] ] Empty largeEmpty large

Page 20: State-Space representation and  Production Systems

20

Rules for the jugs example:Rules for the jugs example: Fill large:Fill large:

[[ x x,, y y ]] andand x x << 44 [[ 44, , y y ]] Fill small:Fill small:

[[ x x,, y y ] ] andand y y << 33 [[ x x,, 33 ] ] Empty large:Empty large:

[[ x x,, y y ] ] andand x x >> 00 [[ 00,, y y ]] Remove some from large:Remove some from large:

[[ x x,, y y ] ] andand x x >> dd >> 0 0 [ [ x x - d- d, , y y ]] Empty (remove some from) small.Empty (remove some from) small. **

Page 21: State-Space representation and  Production Systems

21

Part of the state space:Part of the state space:

[ [ 00, , 00 ] ]

[ [ 00, , 33 ] ]

[ [ 33, , 00 ] ]

[ [ 33, , 33 ] ]

[ [ 44, , 22 ] ]

[ [ 00, , 22 ] ]

[ [ 22, , 00 ] ]

Fill smallFill small

Empty smallEmpty small in largein large

Fill smallFill small

Fill largeFill largefrom smallfrom small

Empty largeEmpty large

Empty small in largeEmpty small in large

[ [ 00, , 00 ] ]

[ [ 00, , 33 ] ]

[ [ 00, , 00 ] ]

LOOP !LOOP !

Page 22: State-Space representation and  Production Systems

22

2. Avoiding loops:2. Avoiding loops:search in trees or graphs ?search in trees or graphs ?

[ [ 00, , 00 ] ]

[ [ 00, , 33 ] ][ [ 44, , 00 ] ]

Avoids generating loops: but needs to keepAvoids generating loops: but needs to keeptrack of ALL the nodes.track of ALL the nodes.

[ [ 11, , 33 ] ] [ [ 44, , 33 ] ] [ [ 33, , 00 ] ]

[ [ 11, , 00 ] ] [ [ 33, , 33 ] ]

......

Page 23: State-Space representation and  Production Systems

23

3. Any path, versus shortest 3. Any path, versus shortest path, versus best path:path, versus best path:

Ex.: 8-puzzleEx.: 8-puzzle: any or shortest path problem.: any or shortest path problem.

Ex.:Ex.: Traveling salesperson problem: Traveling salesperson problem:

Find a sequence of cities ABCDEA such that the Find a sequence of cities ABCDEA such that the total distance is MINIMAL.total distance is MINIMAL.

BostonBoston

MiamiMiami

NewYorkNewYork

SanFranciscoSanFrancisco

DallasDallas

30003000

250250

14501450

12001200 17001700

3300330029002900

15001500

16001600

17001700

Best path problemBest path problem

Page 24: State-Space representation and  Production Systems

24

State space representation:State space representation: State:State:

the list of cities that are already visitedthe list of cities that are already visited Ex.: Ex.: ( NewYork, Boston( NewYork, Boston ))

Initial state:Initial state: Ex.: Ex.: ( NewYork )( NewYork )

Rules:Rules: add 1 city to the list that is not yet a memberadd 1 city to the list that is not yet a member add the first city if you already have 5 membersadd the first city if you already have 5 members

Goal criterion:Goal criterion: first and last city are equalfirst and last city are equal

BostonBoston

MiamiMiami

NewYorkNewYork

SanFranciscoSanFrancisco

DallasDallas

Page 25: State-Space representation and  Production Systems

25

( NewYork )( NewYork )

( NewYork,( NewYork, Boston )Boston )

( NewYork,( NewYork, Miami )Miami )

( NewYork,( NewYork, Dallas )Dallas )

( NewYork,( NewYork, Frisco )Frisco )

( NewYork,( NewYork, Boston,Boston, Miami )Miami )

( NewYork,( NewYork, Frisco,Frisco, Miami )Miami )

250250 12001200 1500150029002900

00

250250 12001200 15001500 29002900

14501450 33003300

17001700 62006200

Keep track of Keep track of accumulated costsaccumulated costs in each state if you want in each state if you wantto be sure to get the best path.to be sure to get the best path.

Page 26: State-Space representation and  Production Systems

26

4. Problem reduction or problem 4. Problem reduction or problem decomposition:decomposition:

Ex.:Ex.: Computing symbolic integrals: Computing symbolic integrals: State:State: the integral to compute the integral to compute Rules:Rules: integration reduction rules integration reduction rules GoalGoal: all integrals have been eliminated: all integrals have been eliminated

AND-OR-tree searchAND-OR-tree search

xx22 + 3x + sin + 3x + sin22x . cosx . cos22x dxx dx

xx22 dx dx 3x3xdxdx sinsin22x . cosx . cos22x dxx dx

xx33/3/3 3 3 xdxxdx

((sin2x)/2)((sin2x)/2)22dxdx (1 - cos(1 - cos22x).cosx).cos22x dxx dx

ANDAND

...... ...... ...... ......

Page 27: State-Space representation and  Production Systems

27

Necessary for decomposition:Necessary for decomposition:independence of states:independence of states:

Ex.:Ex.: Blocks world problem. Blocks world problem. InitiallyInitially: : CC is onis on AA and and BB is onis on the tablethe table.. RulesRules: to move any free block to another or to the : to move any free block to another or to the

tabletable GoalGoal: : AA is onis on BB and and BB is onis on CC..

AACC

BBGoalGoal:: A A onon B B andand B B onon C C

AACC

BBGoalGoal:: A A onon B B

AACC

BBGoalGoal:: B B onon C C

AND-OR-tree?AND-OR-tree?

ANDAND

Page 28: State-Space representation and  Production Systems

28

AACC

BBGoalGoal:: A A onon B B

AACC

BBGoalGoal:: B B onon C C

ANDAND

AACC BBGoalGoal:: A A onon B B

AACCBB

AACC BB

ButBut: branches cannot be : branches cannot be combinedcombined

Page 29: State-Space representation and  Production Systems

29

5. Forward versus backward 5. Forward versus backward reasoning:reasoning:

Initial statesInitial states

Goal statesGoal states

Forward reasoning (or forward chaining):Forward reasoning (or forward chaining): from from initial states to goal states.initial states to goal states.

Page 30: State-Space representation and  Production Systems

30

5. Forward versus backward 5. Forward versus backward reasoning:reasoning:

Initial statesInitial states

Goal statesGoal states

Backward reasoning (or backward chaining):Backward reasoning (or backward chaining): from from goal states to initial states.goal states to initial states.

Page 31: State-Space representation and  Production Systems

31

Criteria:Criteria:

Branching factorBranching factor (Ex.: see previous slide)(Ex.: see previous slide) SometimesSometimes: no way to start from the goal states: no way to start from the goal states

because there are too many because there are too many (Ex.: chess)(Ex.: chess) because you can’t (easily) formulate the because you can’t (easily) formulate the

rules in 2 directions.rules in 2 directions.

11 33 88

22 77

55 44 66

11 22 33

5566774488

In this case: even the same rules !!In this case: even the same rules !!

Sometimes equivalentSometimes equivalent: : (Ex.: 8-puzzle:)(Ex.: 8-puzzle:)

Page 32: State-Space representation and  Production Systems

32

Criteria (2):Criteria (2):

Other possibilityOther possibility: middle-out reasoning.: middle-out reasoning.

The ratio of initial states versus goal states:The ratio of initial states versus goal states:

ExEx.: finding your way to some destination.: finding your way to some destination

Backward reasoning!Backward reasoning!

Providing explanation facilities:Providing explanation facilities: ((ExEx.: expert systems with user interaction).: expert systems with user interaction)

Page 33: State-Space representation and  Production Systems

33

Definition:Definition:

Programs that implement approaches to search Programs that implement approaches to search

problems using the state space representation. problems using the state space representation.

Production-rule systems:Production-rule systems:

Consist of:Consist of: A rule base,A rule base, a ‘working memory’, containing the state(s) a ‘working memory’, containing the state(s)

that have currently been reached,that have currently been reached, a control strategy for selecting the rules to a control strategy for selecting the rules to

apply next to the states in the ‘working apply next to the states in the ‘working memory’ memory’ (including techniques for matching, (including techniques for matching, verifying preconditions and whether a goal verifying preconditions and whether a goal state has been reached)state has been reached)