330 likes | 360 Views
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)
E N D
State-Space representationand 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) Advanced properties and variants. (Rich, Chapt.3 + Russel&Norvig + Nilsson) Game Playing (Winston, Chapt.6 + Rich + Russel&Norvig )
State-space representation:Introduction and trade-offs • What is state-space representation? • Which are the technical issues that arise in that context? • What are the alternatives that the paradigm offers to solve a problem in the state-space representation?
Example: the 8-puzzle. • Given: a board situation for the 8-puzzle: 1 3 8 2 7 5 4 6 • Problem: find a sequence of moves (allowed under the rules of the 8-puzzle game) that transform this board situation in a desired goal situation: 1 2 3 8 4 7 6 5
State-space representation:general outline: • Select some way to represent states in the problem in an unambiguous way. • Formulate all actions that can be preformed in states: • including their preconditions and effects • == PRODUCTION RULES • Represent the initial state (s). • Formulate precisely when a state satisfies the goal of our problem. • Activate the production rules on the initial state and its descendants, until a goal state is reached.
How to represent states? (repr.1) • Ex.: using a 3 X 3 matrix 1 3 8 2 7 5 4 6 Initial issues to solve: • How to formulate production rules?(repr. 2) • Ex.: • express how/when squares may be moved? • Or: express how/when the blank space is moved? • When is a rule applicable to a state? (matching) • How to formulate when the goal criterion is satified and how to verify that it is? • How/which rules to activate? (control)
1 3 8 1 3 8 9!/2 nodes! 2 7 2 7 5 5 5 5 4 4 4 4 6 6 6 6 1 3 8 1 8 1 3 8 goal 4 2 7 3 2 7 2 7 5 6 The (implicit) search tree • Each state-space representation defines a search tree: • But this tree is only IMPLICITLY available !!
1. A way to represent board situations in an unambiguous way: • Ex.: 8 List: (( king_black, 8, C), ( knight_black, 7, B), ( pawn_black, 7, G), ( pawn_black, 5, F), ( pawn_white, 2, H), ( king_white, 1, E)) 7 6 5 4 3 2 1 A B C D E F G H A second example: Chess • Problem: develop a program that plays chess (well).
4 3 2 1 A B C D E F G H ( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) ) add( ( pawn_white, 4, x) ), remove( (pawn_white, 2, x) ) Chess (2): • 2. Describe the rules that represent allowed moves: • Ex.:
List: (( king_black, 8, C), ( knight_black, 7, B), ( pawn_black, 7, G), ( pawn_black, 5, F), ( pawn_white, 2, H), ( king_white, 1, E)) 8 7 6 5 4 3 2 1 A B C D E F G H ( (pawn_white,2,x) , (blank, 3, x), (blank, 4, x) ) add( ( pawn_white, 4, x) ), remove( (pawn_white, 2, x) ) Matching mechanism !! Chess (3): • 3. Provide a way to check whether a rule isapplicable to some state: • Ex.:
win( black ) attacked( king_white ) and no_legal_move( king_white ) + similar definitions for: attacked( Piece ) … no_legal_move( Piece ) ... Chess (4): • 4. How to specify a state in which the goal is reached (= a winning state): • Ex.:
?- win( black ). win( black ) attacked( king_white ) and no_legal_move( king_white ) … Need a theorem prover ( e.g. Prolog) to verify that the state is a winning one. Chess (5): • 5. A way to verify whether a winning state is reached. • Ex.:
A program that is ABLE to play chess. • 7. A mechanism that selects in each state an appropriate rule to apply. The control problem ! Main focus of this entire chapter of the course !! Chess (6). • 6. The initial state.
Implicit search tree ~15 Move 1 Move 2 ~ (15)2 ~ (15)3 Move 3 Chess (7). Need very efficient search techniques to find good paths in such combinatorial trees.
Very many issues and trade-offs: 1. How to choose the rules? 2. Should we search through the implicit tree or through an implicit graph? 3. Do we need an optimal solution, or just any solution? ‘optimal path problems’ 4. Can we decompose states into components on which simple rules can in an independent way? Problem reduction or decomposability 5. Should we search forwards from the initial state, or backwards from a goal state?
Representation: • a state: • [content of large jug, content of small jug] • initial state: • [ 0, 0 ] • goal state: • [ 2, x ] 1. Choice of the rules Example: The water jugs problem: • Given: 2 jugs: • Problem: fill the 4 l jug with 2 l of water. 4 l 3 l
Rules for the jugs example: • Fill large: • [ x, y ]and x <4[4, y ] • Fill small: • [ x, y ]and y <3[ x,3 ] • Empty large: • [ x, y ] and x >0[0, y ] • Remove some from large: • [ x, y ] and x >d> 0 [ x - d, y ] • Empty (remove some from) small.
Rules for the jugs example (2): • Fill large from small: [ x, y ]and x + y 4 and y > 0[4, y-(4-x)] • Fill small from large. • Empty small in large: [ x, y ] and x + y 4and y >0[ x + y , 0 ] • Empty large in small.
Fill small [ 0, 0 ] Empty small in large [ 0, 3 ] [ 4, 0 ] [ 0, 0 ] * [ 0, 3-d1] [ 3, 0 ] [ 4, 3] [ 0, 0] Fill small * [ 3, 3 ] [ 0, 3-d1-d2] [ 3-d1, 0] Fill large from small [ 4, 2 ] [ 4, 3-d1] Redundant subspace ! Empty large [ 0, 2 ] Empty small in large [ 2, 0 ] Part of the state space:
Rules for the jugs example: • Fill large: • [ x, y ]and x <4[4, y ] • Fill small: • [ x, y ]and y <3[ x,3 ] • Empty large: • [ x, y ] and x >0[0, y ] • Remove some from large: • [ x, y ] and x >d> 0 [ x - d, y ] • Empty (remove some from) small. *
Fill small [ 0, 0 ] Empty small in large [ 0, 3 ] [ 0, 0 ] [ 3, 0 ] Fill small [ 3, 3 ] [ 0, 3 ] Fill large from small LOOP ! [ 4, 2 ] Empty large [ 0, 0 ] [ 0, 2 ] Empty small in large [ 2, 0 ] Part of the state space:
[ 0, 0 ] [ 4, 0 ] [ 0, 3 ] [ 1, 3 ] [ 4, 3 ] [ 3, 0 ] [ 1, 0 ] [ 3, 3 ] ... 2. Avoiding loops:search in trees or graphs ? Avoids generating loops: but needs to keep track of ALL the nodes.
3000 Boston SanFrancisco 250 1700 2900 3300 NewYork 1450 1200 1700 1500 Miami Dallas 1600 Best path problem 3. Any path, versus shortest path, versus best path: Ex.: 8-puzzle: any or shortest path problem. Ex.: Traveling salesperson problem: • Find a sequence of cities ABCDEA such that the total distance is MINIMAL.
Boston SanFrancisco NewYork Miami Dallas State space representation: • State: • the list of cities that are already visited • Ex.: ( NewYork, Boston) • Initial state: • Ex.: ( NewYork ) • Rules: • add 1 city to the list that is not yet a member • add the first city if you already have 5 members • Goal criterion: • first and last city are equal
0 ( NewYork ) 2900 1500 250 1200 250 1200 1500 2900 ( NewYork, Boston ) ( NewYork, Miami ) ( NewYork, Dallas ) ( NewYork, Frisco ) 1450 3300 1700 6200 ( NewYork, Boston, Miami ) ( NewYork, Frisco, Miami ) Keep track of accumulated costs in each state if you want to be sure to get the best path.
x2 + 3x + sin2x . cos2x dx AND x2 dx 3xdx sin2x . cos2x dx 3 xdx x3/3 ((sin2x)/2)2dx (1 - cos2x).cos2x dx ... ... ... ... AND-OR-tree search 4. Problem reduction or problem decomposition: Ex.: Computing symbolic integrals: • State: the integral to compute • Rules: integration reduction rules • Goal: all integrals have been eliminated
AND-OR-tree? C A B Goal: A on B and B on C AND C C A B A B Goal: A on B Goal: B on C Necessary for decomposition:independence of states: Ex.: Blocks world problem. • Initially: Cis onA and Bis onthe table. • Rules: to move any free block to another or to the table • Goal: Ais onB and Bis onC.
AND C C A B A B Goal: A on B Goal: B on C B C A B C Goal: A on B A A C B But: branches cannot be combined
Initial states Goal states • Forward reasoning (or forward chaining): from initial states to goal states. 5. Forward versus backward reasoning:
Initial states Goal states • Backward reasoning (or backward chaining): from goal states to initial states. 5. Forward versus backward reasoning:
Sometimes equivalent: (Ex.: 8-puzzle:) 1 3 8 2 7 5 4 6 In this case: even the same rules !! 1 2 3 8 4 7 6 5 Criteria: • Branching factor(Ex.: see previous slide) • Sometimes: no way to start from the goal states • because there are too many (Ex.: chess) • because you can’t (easily) formulate the rules in 2 directions.
The ratio of initial states versus goal states: Ex.: finding your way to some destination • Providing explanation facilities:(Ex.: expert systems with user interaction) Backward reasoning! Criteria (2): • Other possibility: middle-out reasoning.
Production-rule systems: • Definition: Programs that implement approaches to search problems using the state space representation. • Consist of: • A rule base, • a ‘working memory’, containing the state(s) that have currently been reached, • a control strategy for selecting the rules to apply next to the states in the ‘working memory’ (including techniques for matching, verifying preconditions and whether a goal state has been reached)