Problems, Problem Spaces, and Search
Problems, Problem Spaces, and Search
Problems, Problem Spaces, and Search
Chapter 2:
Problems, Problem Spaces ,and Search
Problem:
45
Ex: A decomposable problem
(x2 + 3x + sin2x.cos2x)dx
(1 cos2x)cos2xdx
cos2xdx cos4xdx
46
Ex2: A simple Blocks World Problem
Start Goal
A
C B
A B C
Blocks World
ON(B, C) ON(A, B)
CLEAR(A) ON(A, B)
C B
A B C
48
Can solution steps be ignored or
undone?
• Suppose we are trying to prove a mathematical
theorem.
• We proceed by first proving a lemma that we think
will be useful.
Theorem Proving
A lemma that has been proved can be ignored for
next steps.
Ignorable!
in which solution steps can be ignored.
49
8-Puzzle Problem
• The Problem is 8-Puzzle is a square tray in
which 8 square tiles are placed. The remaining
9th square is uncovered. Each tile has a number
on it. A file that is adjacent to the blank space
can be slide into that space.
• The goal is to transform the starting position
into the goal position by sliding the tiles
around.
• In attempting to solve the 8 puzzle, we might
make a stupid move
• for example; we slide the tile 5 into an empty
space.
• We actually want to slide the tile 6 into empty
space but we can back track and
• undo the first move, sliding tile 5 back to where it
was then we can know tile 6 so mistake and
• still recovered from but not quit as easy as in the
theorem moving problem.
• An additional step must be performed to undo
each incorrect step.
Can solution steps be ignored or
undone?
The 8-Puzzle
2 8 3 1 2 3
1 6 4 8 4
7 5 7 6 5
Irrecoverable!
In which solution steps can be undone
54
Can solution steps be ignored or
undone?
• Ignorable problems can be solved using a
simple control structure that never backtracks.
55
Is the universe predictable?
The 8-Puzzle
Every time we make a move, we know exactly
what will happen.
Certain outcome!
56
Is the universe predictable?
Playing Bridge
We cannot know exactly where all the cards are
or what the other players will do on their
turns.
Uncertain outcome!
57
Is the universe predictable?
• For certain-outcome problems, planning can
used to generate a sequence of operators that
is guaranteed to lead to a solution.
• For uncertain-outcome problems, a sequence
of generated operators can only have a good
probability of leading to a solution.
Plan revision is made as the plan is carried out
and the necessary feedback is provided.
58
Is a good solution absolute or relative?
Consider the problem of answering questions based on a
database of simple facts such as the following:
1. Marcus was a man.
2. Marcus was a Pompeian.
3. Marcus was born in 40 A.D.
4. All men are mortal.
5. All Pompeians died when the volcano
erupted in 79 A.D.
6. No mortal lives longer than 150 years.
7. It is now 2004 A.D.
59
Is a good solution absolute or relative?
1. Marcus was a man.
2. Marcus was a Pompeian.
3. Marcus was born in 40 A.D.
4. All men are mortal.
5. All Pompeians died when the volcano
erupted in 79 A.D.
6. No mortal lives longer than 150 years.
7. It is now 2004 A.D.
Is Marcus alive?
60
Suppose we ask a question “Is Marcus alive?”
• By representing each of these facts in a formal language such as
predicate logic, and then using formal inference methods we
can fairly easily derive an answer to the question.
Is Marcus alive?
• Since we are interested in the answer to the
question, it does not matter which path we
follow.
• If we do follow one path successfully to the
answer,
• there is no reason to go back and see if some
other path might also lead to a solution.
• These types of problems are called as “Any
path Problems”.
62
Is a good solution absolute or relative?
The Travelling Salesman Problem
• Now consider the Travelling Salesman Problem.
• Our goal is to find the shortest path route that
visits each city exactly once.
• We have to try all paths to find the shortest one.
63
Is a good solution absolute or relative?
• Any-path problems can be solved using
heuristics that suggest good paths to explore.
66
Is the solution a state or a path?
Finding a consistent interpretation
“The bank president ate a dish of pasta salad with
the fork”.
– “bank” refers to a financial situation or to a side of a river?
– “dish” or “pasta salad” was eaten?
– Does “pasta salad” contain pasta, as “dog food” does not
contain “dog”?
– Which part of the sentence does “with the fork” modify?
What if “with vegetables” is there?
69
Is the solution a state or a path?
• A path-solution problem can be reformulated
as a state-solution problem by describing a
state as a partial path to a solution.
70
What is the role of knowledge
Playing Chess
Knowledge is important only to constrain the
search for a solution.
Reading Newspaper
Knowledge is required even to be able to
recognize a solution.
71
Does the task require human-interaction?
• Solitary problem, in which there is no
intermediate communication and no demand
for an explanation of the reasoning process.
72
Problem Classification
• There is a variety of problem-solving methods,
but there is no one single way of solving all
problems.
73
State Space Search: Water Jug Problem
74
State Space Search: Water Jug Problem
• State: (x, y)
– x = number of lts in 4 lts jug
– y = number of lts in 3 lts jug
x = 0, 1, 2, 3, or 4 y = 0, 1, 2, 3
• Start state: (0, 0).
• Goal state: (2, n) for any n.
• Attempting to end up in a goal state.
75
State Space Search: Water Jug Problem
1. (x, y) (4, y)
if x 4
2. (x, y) (x, 3)
if y 3
3. (x, y) (x d, y)
if x 0
4. (x, y) (x, y d)
if y 0
76
State Space Search: Water Jug Problem
5. (x, y) (0, y)
if x 0
6. (x, y) (x, 0)
if y 0
7. (x, y) (4, y (4 x))
if x y 4, y 0
8. (x, y) (x (3 y), 3)
if x y 3, x 0
77
State Space Search: Water Jug Problem
9. (x, y) (x y, 0)
if x y 4, y 0
10.(x, y) (0, x y)
if x y 3, x 0
11.(0, 2) (2, 0)
12.(2, y) (0, y)
78
State Space Search: Water Jug Problem
(0, 0)
(0, 3) 2
(3, 0) 9
(3, 3) 2
(4, 2) 7
(0, 2) 5
(2, 0) 11
79
Problem: 8-Puzzle
• The 8-Puzzle is a square tray in which 8 square
tiles are placed. The remaining 9th square is
uncovered. Each tile has a number on it. A file
that is adjacent to the blank space can be slide
into that space. The goal is to transform the
starting position into the goal position by
sliding the tiles around.
80
8-Puzzle Problem
• Goal State
1 2 3
8 4
7 6 5
81
8-Puzzle Problem Production Rules
2 3 2
3 4 3
2 3 2
2 + 3 + 2 + 3 + 4 + 3 + 2 + 3 + 2 = 24
83
2 8 3 2 8 3
IS 1 6 4 1 4
7 5 7 6 5
Step 1 Step 2
2 3 2 3
1 8 4 1 8 4
7 6 5 7 6 5
Step 3 Step 4
1 2 3 1 2 3
8 4 GS 8 4
7 6 5 7 6 5
Step 5 Step 6
84
Travelling Salesman Problem
• The salesman has a list of cities, each of which
he must visit exactly once. There are direct
roads between each pair of cities on the list.
Find the route the salesman should follow for
the shortest possible round trip that both
states and finishes at any one of the cities.
85
Travelling Salesman Problem
• Initial State
– Salesman starting at any arbitrary city in the given list of
cities
• Goal State
– Visiting all cities once and only and reaching his starting
state
86
Production Rules
89
Production Rules
• Top(T1)<Top(T2) • Top(T2)<Top(T3)
– PUSH(POP(T1),T2) – PUSH(POP(T2),T3)
• Top(T2)<Top(T1) • Top(T3)<Top(T2)
– PUSH(POP(T2),T1) – PUSH(POP(T3),T2)
• Top(T1)<Top(T3) • Empty(T1)
– PUSH(POP(T1),T3) – PUSH(POP(T2),T1)
• Top(T3)<Top(T1) • Empty(T1)
– PUSH(POP(T3),T1) – PUSH(POP(T3),T1)
90
Production Rules
• Empty(T2) - PUSH(POP(T1),T3)
• Empty(T2) - PUSH(POP(T3),T2)
• Empty(T3) - PUSH(POP(T1),T3)
• Empty(T3) - PUSH(POP(T2),T3)
91
Monkey & Bananas Problem
• A hungry monkey finds himself in a room in
which a branch of bananas is hanging from the
ceiling. The monkey unfortunately cannot reach
the bananas however in the room there are also
a chair and a stick. The ceiling is just right high so
that a monkey standing on a chair could knock
the bananas down with the stick. The monkey
knows how to move round, carry other things
around reach for the bananas and wave the stick
in the air. What is the best sequence of actions
for the monkey to acquire lunch?
92
State Space
• (M,C,S,F1,F2)
– M: position of the monkey
– C: position of the chair
– S: position of the stick
– F1: 0 or 1 depends on the monkey on the
chair or not
– F2: 0 or 1 depends on the monkey
holding the stick or not
93
Monkey & Bananas Problem
94
Production Rules
• (M,C,S,0,0) (A,C,S,0,0)
• (M,C,S,0,0) (C,C,S,0,0)
• (M,C,S,0,0) (S,S,S,0,0)
• (C,C,S,0,0) (A,A,S,0,0)
• (S,C,S,0,0) (A,C,A,0,1)
• (S,C,S,0,0) (C,C,S,0,0)
• (C,C,C,0,1) (C,C,C,1,1)
• (S,C,S,0,1) (C,C,C,0,1)
95
Solution
• (M,C,S,0,0)
• (C,C,S,0,0)
• (G,G,S,0,0)
• (S,G,S,0,0)
• (G,G,G,0,0)
• (G,G,G,0,1)
• (G,G,G,1,1)
96
Missionaries and Cannibals
3 missionaries and 3 cannibals find themselves one
side of the river.
They have agreed that they would like to get the
other side.
But the missionaries are not sure what else the
cannibals have agreed to.
So the missionaries want to manage the trip across
the river on either side of the river is never less than
the number of cannibals who are on the same side.
The only boat available hold only two people at a
time. How can every one get across without
missionaries risking hang eager?
97
State Space
• (C,M,C1,M1,B)
– C and M are number of cannibals and missionaries
on the starting bank
– C1 and M1 are number of cannibals and
missionaries on the destination bank
– B is the position of the boat wither left bank (L) or
right bank (R)
98
Missionaries and Cannibals
• Initial State
– C=3,M=3,B=L so (3,3,0,0,L)
99
Missionaries and Cannibals
• Goal State
– C1=3, M1=3, B=R so (0,0,3,3,R)
100
Production Systems
101
LEFT BANK RIGHT BANK
BOAT
C M C1 M1
POSITION
3 3 0 0
1 3 2 0
2 3 1 0
0 3 3 0
1 3 2 0
1 1 2 2
2 2 1 1
2 0 1 3
3 0 0 3
1 0 2 3
2 0 1 3
0 0 3 3
102
Classification of Production System:
Based on the direction they can be
1. Forward Production System
Moving from Initial State to Goal State
When there are number of goal states and only one
initial state, it is advantage to use forward production
system.
2. Backward Production System
Moving from Goal State to Initial State
If there is only one goal state and many initial states,
it is advantage to use backward production system.
Production System Characteristics
• Production system is a good way to describe the
operations that can be performed in a search for
solution of the problem.
• Two questions we might reasonably ask at this point
are:
Can production systems, like problems, be described
by a set of characteristics that shed some light on
how they can easily be implemented?
If so, what relationships are there between problem
types and the types of production systems best suited
to solving the problems?
The answer for the first question can be considered with the
following definitions of classes of production systems:
• A monotonic production system is a production system in
which the applications of a rule never prevents the later
application of another rule that could also have been
applied at the time the first rule was selected.
• A non-monotonic production system is one which this is
not true.
• A partially commutative production system is a production
system with the property that if the application of a
particular sequence of rules transforms state X into state Y,
then any permutation of those rules that is allowable also
transforms state X into state Y.
• A commutative production system is a production system
that is both monotonic and partially commutative.
• In a formal sense, there is no relationship
between kinds of problems and kinds of
production of systems, since all problems can be
solved by all kinds of systems.
• But in practical sense, there definitely is such a
relationship between kinds of problems and the
kinds of systems that led themselves naturally
to describing those problems.
The following figure shows the four categories of
production systems
• produced by the two dichotomies,
• monotonic versus non-monotonic and
• partially commutative versus non-partially
commutative along with some problems that can
be naturally be solved by each type of system.
• Partially commutative, monotonic production
systems are useful for solving ignorable
problems that involves creating new things
rather than changing old ones generally
ignorable.
• Theorem proving is one example of such a
creative process partially commutative.
• Monotonic production system are important for
a implementation stand point because they can
be implemented without the ability to backtrack
to previous states when it is discovered that an
incorrect path has been followed.
• Non-monotonic, partially commutative
production systems are useful for problems in
which changes occur but can be reversed and in
which order of operations is not critical.
• This is usually the case in physical manipulation
problems such as “Robot navigation on a flat
plane”.
• The 8-puzzle and blocks world problem can be
considered partially commutative production
systems from an implementation point of view
• because they tend to read too much duplication
of individual states during the search process.
• Production systems that are not partially
commutative are useful for many problems in
which changes occur.
For example “Chemical Synthesis”
• Non-partially commutative production system
less likely to produce the same node many times
in the search process.
Cryptarithmetic
• Consider an arithemetic problem represented
in letters