Artificial Intelligence & Machine Learning
Artificial Intelligence & Machine Learning
Machine Learning
Class No-3:
State-space
representation (Contd.)
By:
Dr. Niranjan Panigrahi
CSE, PMEC, Berhampur,Odisha
Recap…
Identification & Definition of AI
problem
Typical NP-complete/NP-hard
problems
State-space representation
Examples of Classical AI problems
State-space representation method
Water-jug problem
2
State Vs Node
State represents Node represents a
physical suitable data
configuration of a structure to
given problem represent the state
of a given problem
3
Example-2 : 8-puzzle problem
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
4
Initial issues to solve:
How to represent states?
Ex.: 1 3 8 using a 3 X 3 matrix
2 7
5 4 6
How to formulate production rules?
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)
5
The (implicit) search tree
Each state-space representation defines a search
tree:
1 3 8
2 7
5 4 6
1 3 8 1 8 1 3 8 1 3 8
2 7 2 3 7 2 7 2 4 7
5 4 6 5 4 6 5 4 6 5 6
goal
8 List:
7 (( king_black, 8, C),
6 ( knight_black, 7, B),
5 ( pawn_black, 7, G),
4 ( pawn_black, 5, F),
3 ( pawn_white, 2, H),
2 ( king_white, 1, E))
1
A B C D E F G H 7
Chess (2):
2. Describe the rules that represent allowed
moves:
Ex.:
4
3
2
1
A B C D E F G H
add( ( pawn_white, 4, x) ),
remove( (pawn_white, 2, x) )
8
Chess (3):
3. Provide a way to check whether a rule is
applicable to some state:
Ex.:
List:
8
7 (( king_black, 8, C),
6 ( knight_black, 7, B),
5 ( pawn_black, 7, G),
4 ( pawn_black, 5, F),
3 ( pawn_white, 2, H),
2 ( king_white, 1, E))
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 !! 9
Chess (4):
4. How to specify a state in which the goal is
reached (= a winning state):
Ex.:
no_legal_move( king_white )
attacked( Piece ) …
no_legal_move( Piece ) ...
10
Chess (5):
5. A way to verify whether a winning state is
reached.
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.
11
Chess (6).
6. The initial state.
12
Chess (7).
Implicit search tree
~15
Move 1
Move 2
~ (15)2
~ (15)3 Move 3
14
1. Avoiding loops:
search in trees or graphs ?
[ 0, 0 ]
[ 4, 0 ] [ 0, 3 ]
[ 1, 3 ] [ 4, 3 ] [ 3, 0 ]
[ 1, 0 ] [ 3, 3 ]
...
Avoids generating loops: but needs to keep
track of ALL the nodes. 15
2. Any path, versus shortest
path, versus best path:
Ex.: 8-puzzle: any or shortest path problem.
Ex.: Traveling salesperson problem:
3000
Boston SanFrancisco
250 1700 2900
3300
1450 NewYork
1200 1700
1500
Miami 1600
Dallas
x3/3 3 xdx
((sin2x)/2)2dx (1 - cos2x).cos2x dx
... ... ... ...
AND-OR-tree search 17
Necessary for decomposition:
independence of states:
Ex.: Blocks world problem.
Initially: C is on A and B is on the table.
Rules: to move any free block to another or to the table
Goal: A is on B and B is on C.
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
18
AND
C C
A B A B
Goal: A on B Goal: B on C
C A B B
Goal: A on B C
A
19
4. Forward versus backward
reasoning:
Initial states
Goal states
Goal states