Chapter 2 Artificial Intelligence Notes
Chapter 2 Artificial Intelligence Notes
Problem Solving
Introduction
A problem is a situation which is experienced by an agent and is solved by a sequence of actions that
reduce the different between the initial situation and the goal.
Four steps of problem solving are:
i. Goal Formulation: Helps to organize
behavior by isolating and representing
the task knowledge necessary to solve
problem.
ii. Problem Formulation: Define the
problem precisely with initial states,
final state and acceptable solutions.
iii. Searching: Find the most appropriate
techniques o sequence among all
possible techniques.
iv. Execution: Once the search algorithm
returns a solution to the problem, the solution is then executed by the agent.
There is no solid description plan for solving the problems because it varies with nature of problem,
various problem solving techniques, various level of problem complexity, priority of problem, etc. A
general strategy for problem solving can be seen on the figure.
Defining problem as a state space search
A set of all possible states for a given problem is known as state space for that problem. A state space
represents a problem in terms of states and operators that changes the states. A state space essentially
consists of a set of nodes representing each state of the problem, arcs between nodes representing the
legal moves from one state to another, an initial state and a goal state
The major components of state space representation are:
Initial state
Goal state, and
Operator or legal moves.
To explain the state space representation in more detailed manner, let us consider a problem of 8 puzzle
game. The puzzle consists of an 8-square frames and an empty slot. The tiles are numbered from 1-8. It is
possible to move the tiles in the square field by moving tile into the empty slot. The objective is to get
square in a numeric order.
Here,
Initial State
Operators
– UP: If the empty slot is not touching the up-frame, move it up.
– DOWN: If the empty slot is not touching down-frame, move it down.
– LEFT: If the empty slot is not touching left-frame, move it left.
– RIGHT: If the empty slot is not touching right-frame, move it right.
Final State
Operators
Fill 3-gallon from faucet, fill 4-gallon from faucet
Fill 3-gallon from 4-gallon , fill 4-gallon from 3-gallon
Empty 3-gallon into 4-gallon, empty 4-gallon into 3-gallon
Dump 3-gallon down drain, dump 4-gallon down drain
Final State
Goal state (0, 2)
Q. You are given two jars of a six gallons and eight gallons capacity. There is no marking on the
jars. There is a water tap, which can be used to fill jar. Your goal is to have exactly four gallons of
water in eight gallons jar without taking any other jar or measuring device. Model the above
problem as an AI production system and draw the search tree.
Q. 8 Puzzle-Game
The puzzle consists of an 8-square frames and an empty slot. The tiles are numbered from 1-8.
It is possible to move the tiles in the square field by moving tile into the empty slot. Manage the
tile square in a numeric order.
Here,
Initial State
Operators
– UP: If the empty slot is not touching the up-frame, move it up.
– DOWN: If the empty slot is not touching down-frame, move it down.
– LEFT: If the empty slot is not touching left-frame, move it left.
– RIGHT: If the empty slot is not touching right-frame, move it right.
Final State
Solution
- Step 1
- Step 2
- Step 3
- Step 4
Final State
W {ϕ}, E { H1, W1, W1’ and H2, W2, W2’}
Solution
Solution
- Step 1
- Step 2
- Step 3
- Step 4
- Step 5
- Step 6
- Step 7
Q. 8 queen’s problem
The problem is to place 8 queens on a chessboard so that no two queens are in the same row, column or
diagonal
Here,
Initial State
Operation
Add a queen in any square
Final State
A 2 4
+ D 8 9
G 1 3
Step 3:
Domain of A = {0, 5, 6, 7}
Domain of D = {0, 5, 6, 7}
So, Domain of G = {5, 6}
Select A = 0 & D = 5 Then G = 6 (with addition of Carry)
So,
Hence, the required solutions are:
A = 0, B = 2, C = 4, D = 5, E = 8, F = 9, G = 6, H = 1, I = 3.
Problem 2
T R U E
+ T R U E
F A L S E
Solution:
Step 1:
Domain of F = {1}
So, Select F = 1
Now we have,
T R U E
+T R U E
1 A L S E
Step 2:
Domain of E = {0}
So, Select E = 0
Now we have,
T R U 0
+ T R U 0
1 A L S 0
Step 3:
Domain of U = {2, 3, 4, 6, 7, 8, 9}
So, Domain of S = {2, 4, 6, 8}
Select U = 4 Then S = 8
So,
T R 4 0
+T R 4 0
1 A L 8 0
Step 4:
Domain of R = {3, 6}
So, Domain of L = {2, 6}
Select R = 6 Then L = 2 (Carry = 1)
So,
T 6 4 0
+ T 6 4 0
1 A 2 8 0
Step 5:
Domain of T = {7}
So, Domain of A = {5}
Finally we have,
7 6 4 0
+7 6 4 0
1 5 2 8 0
Hence, the required solutions are:
T = 7, R = 6, U = 4, E = 0, F = 1, A = 5, L = 2, S = 8.
Problem 3
S E N D
+ M O R E
M O N E Y
Solution:
Step 1:
Domain of M = {1}
Select M = 1
So we have,
S E N D
+ 1 O R E
1 O N E Y
Step 2:
Domain of S = {9}
Select S = 9 Then O = 0 (Carry = 1)
So,
9 E N D
+ 1 0 R E
1 0 N E Y
Step 3:
Domain of D = {2, 3, 4, 5, 6, 7, 8}
Domain of E = {2, 3, 4, 5, 6, 7, 8}
So, Domain of Y = {2, 3, 4, 5,}
Select D = 7 & E = 5 Then Y = 2 (Carry =1)
So,
9 5 N 7
+ 1 0 R 5
1 0 N 5 2
Step 4:
Domain of N = {3, 4, 6, 8}
Domain of R = {3, 4, 6, 8}
So, Domain of E will be 5 (with carry = 1) when we select N = 6 & R = 8.
Now we have,
9 5 6 7
+ 1 0 8 5
1 0 6 5 2
Hence, the required solutions are:
S = 9, E = 5, N = 6, D = 7, M = 1, O = 0, R = 8, Y = 2.
Production System
Production systems were among the earliest forward-chaining systems in widespread use. The word
production in production systems denotes a condition (or "IF" statement) which implies an action (or
"THEN") rule. If a production's precondition matches the current state of the world, then the production
is said to be triggered. If a production's action is executed, it is said to have fired. The IF-THEN rules are
found useful in automated planning, expert systems and action selection.
A production system has four basic components as enumerated below.
A set of production rules following the classical IF-THEN construct. If the conditions on the
left-hand side are satisfied, the rule is fired, resulting in the performance of actions on the right-
hand side of the rule.
A database (or working memory) of current facts established during the process of inference.
A control strategy which specifies the order in which the rules are selected for
matching of antecedents by comparing the facts in the database. It also specifies how
to resolve conflicts in selection of rules or selection of facts. The rule interpreter must provide a
mechanism for prioritizing productions when more than one is triggered
A rule firing module, which is the computational system that implements the control strategy
and applies the rules. The rules are generally applied either forward chaining or backward
chaining process.
A Production System is best suited AI Technique to solve the State Space Problems like Water Jug and
crossing river problem. These problems consist of:
State = Initial state of the Problem.
State space = Intermediate States between Initial State and Goal State.
Goal State = Final state of the problem.
Type of production system
Production systems describe the operations that can be performed in a search for a solution to the
problem. Four classes of production systems:
A monotonic production system
A no-monotonic production system
A partially commutative production system
A commutative production system.
Monotonic production system:
A system in which the application of a rule never prevents the later application of another rule that
could have also been applied at the time the first rule was selected. Monotonic reasoning is what a
knowledge base is of fixed size and cannot be updated. But in non-monotonic reasoning, a
Machine got a capability to learn self by getting possible operations on it so when u give some
clauses to it, it does update database if it doesn't create conflicting situations with the database.
Partially commutative production system:
A production system in which 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. Monotonic partially commutative systems are useful for problems in which changes occur but
can be reversed and in which the order of operation is not critical (ex: 8 puzzle problem). Playing
the game of bridge comes under non monotonic, not partially commutative system.
Advantages:
Production systems provide an excellent tool for structuring AI programs.
Production Systems are highly modular because the individual rules can be added,
removed or modified independently.
The production rules are expressed in a natural form, so the statements contained in the
knowledge base should the recording of an expert thinking out loud.
Disadvantages:
One important disadvantage is the fact that it may be very difficult to analyze the flow of control
within a production system because the individual rules don’t call each other.