AI Unit 2
AI Unit 2
Unit-02
Problems, State Space
Search
Defining The Problems As A State Space Search: Chess, Water jug and 8-Puzzle
Production Systems
AI Problem Characteristics
Defining State & Search Space
Problem solving is the major area of concern in Artificial Intelligence.
To solve a particular problem, we need to build a system or a method which can generate
required solution.
A State space is the set of all states reachable from the initial state.
A state space forms a graph in which the nodes are states and the arcs between nodes are
actions.
The solution of a problem is part of the graph formed by the state space.
Defining State & Search Space
The state space representation forms the basis of most of the AI methods.
Its structure corresponds to the structure of problem solving in two important ways:
1. It allows for a formal definition of a problem as per the need to convert some given situation
into some desired situation using a set of permissible operations.
2. It permits the problem to be solved with the help of known techniques and control strategies to
move through the problem space until goal state is found.
Defining Problem & Search
A problem is described formally as:
Define a state space that contains all the possible configurations of relevant objects.
Specify one or more states within that space that describe possible situations form which the
problem solving process may start.
These states are called initial states.
Specify one or more states that would be acceptable as solutions to the problem. These states
are called goal states.
The steps to reach from initial state to goal state is called as problem space.
The steps we follow to reach from initial state to goal state is called as search.
Defining Problem & Search
The problem can then be solved by using the rules, in combination with an appropriate control
strategy, to move through the problem space until a path from an initial state to a goal state is
found.
Search is a general mechanism that can be used when more direct method is not known.
Search also provides the framework into which more direct methods for solving subparts of a
problem can be embedded.
Defining Problem State ,Space & Search: Tic Tac Toe
Defining Problem State ,Space & Search
Defining the Problem as a state space search
1) Initial State
2) Operators(Rules)
3) Goal State
Defining Problem State ,Space & Search: Chess Game
Defining Problem State ,Space & Search: Chess Game
Defining Problem State ,Space & Search: Chess Game
Defining Problem State ,Space & Search: Chess Game
Defining Problem State ,Space & Search: Chess Game
Defining Problem State ,Space & Search: Water Jug problem
You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which has unlimited water
which you can use to fill the jug, and the ground on which water may be poured.
How can you get exactly 2 gallons of water in the 4-gallon jug?
Here the initial state is (0, 0). The goal state is (2, n) for any value of n.
Defining Problem State ,Space & Search: Water Jug problem
State Space Representation:
we will represent a state of the problem as a tuple (x, y) where x represents the amount of water
in the 4-gallon jug and y represents the amount of water in the 3-gallon jug.
To solve this we have to make some assumptions not mentioned in the problem. They are:
The state space for this problem can be described as the set of ordered pairs of integers(x,y),
such that (4 gallon jug , 3 gallon jug)
x = 0,1,2,3,4
y = 0,1,2,3
Defining Problem State ,Space & Search: Water Jug problem
Operators – we must define a set of operators that will take us from one state to another.
Defining Problem State ,Space & Search: Water Jug problem
There are several sequences of operations that will solve the problem.
One of the possible solution is given as :
Defining Problem State ,Space & Search: Water Jug problem
If you have a 5-litre jug and a 3-litre jug, how would you measure exactly 4 litres?
Defining Problem State ,Space & Search: Water Jug problem
Examples:
If you have a 5-liter jug and a 7-litre jug, how would you measure exactly 1 liter in 7liters jug?
If you have a 5-liter jug and a 7-litre jug, how would you measure exactly 3 liter in 7liters jug?
Defining Problem State ,Space & Search: 8 puzzle problem
The 8 puzzle consists of eight numbered, movable tiles set in a 3x3 frame.
One cell of the frame is always empty thus making it possible to move an adjacent numbered tile
into the empty cell.
Such a puzzle is illustrated in following diagram.
8 puzzle problem
The program is to change the initial configuration into the goal configuration.
To solve a problem, we must specify the global database, the rules, and the control strategy.
For the 8-puzzle, a straight forward description is a 3X3 array of matrix of numbers.
The control strategy repeatedly applies rules to state descriptions until a description of a goal
state is produced.
It also keeps track of rules that have been applied so that it can compose them into sequence
representing the problem solution.
8 puzzle problem
Production System
An AI system developed for solution of any problem is called production system.
Once the problem is defined, analyzed and represented in a suitable formalism, the production
system is used for application of rules and obtaining the solution.
Production System is a computer program which is used to provide a solution for a problem
using a set of rules about behavior.
Along with the rules, it consists of the mechanism required to follow these rules.
A database contains all the necessary data and information required for the successful
completion of a task.
The permanent part of the database consists of fixed actions, whereas the temporary part alters
according to circumstances.
Components of a production system
2. Set of Production rules
Production rules in AI are the set of rules that operates on the data fetched from the global
database.
Also, these production rules are bound with precondition and post-condition that gets checked
by the database.
If a condition is passed through a production rule and gets satisfied by the global database, then
the rule is successfully applied.
The rules are of the form AB, where the right-hand side represents an outcome corresponding
to the problem state represented by the left-hand side.
Components of a production system
3. A control System/ Control Strategy
It helps decide which rule should be applied and terminates the process when the system gives
the correct output.
It also resolves the conflict of multiple conditions arriving at the same time.
The strategy of the control system specifies the sequence of rules that compares the condition
from the global database to reach the correct result.
Components of a production system
3. A Rule Applier
It is the computational system that implements the control strategy and applies the rules.
Requirements of good control strategy
Which rule to apply next in the process of search for a solution if multiple rules are applicable.
This is decided by control strategy.
It helps represent knowledge and reasoning in the simplest way possible to solve real-world
problems.
Also, it helps improve the readability and understanding of the production rules.
Characteristics of a Production System
Modularity
The modularity of a production rule helps in its incremental improvement as the production rule
can be in discrete parts.
The production rule is made from a collection of information and facts that may not have
dependencies unless there is a rule connecting them together.
The addition or deletion of single information will not have a major effect on the output.
Modularity helps enhance the performance of the production system by adjusting the
parameters of the rules.
Characteristics of a Production System
Modifiability
The feature of modifiability helps alter the rules as per requirements.
Initially, the skeletal form of the production system is created.
We then gather the requirements and make changes in the raw structure of the production
system.
This helps in the iterative improvement of the production system.
Knowledge-intensive
Production systems contain knowledge in the form of a human spoken language, i.e., English.
It is not built using any programming languages.
The knowledge is represented in plain English sentences.
Production rules help make productive conclusions from these sentences.
Benefits of Production System
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 be easily understandable.
Search Strategies
Two types:
1. Uninformed search (blind search) Having no information about the number of steps from the
current state to the goal. (BFS, DFS)
This can be done by breaking it into three smaller problems and solving each by applying specific rules. Adding
the results we can find the complete solution.
Problem Characteristics
1. Is the problem decomposable into a set of independent smaller or easier sub-problems?
But there are certain problems which cannot be decomposed into sub-problems.
Problem Characteristics
1. Is the problem decomposable into a set of independent smaller or easier sub-problems?
Problem Characteristics
2. Can solution steps be ignored or at least undone?
Problem fall under three classes, (i) ignorable, (ii) recoverable and (iii) irrecoverable.
(i) ignorable
Consider theorem proving. We may later find that it is of no use. We can still proceed further, since nothing is
lost by this redundant step.
(ii) recoverable
In 8-Puzzle problem, while moving from the start state towards goal state, we may make some stupid move but
we can backtrack and undo the unwanted move.
This only involves additional steps and the solution steps are recoverable.
(iii) irrecoverable.
In the game of chess, If a wrong move is made, it can neither be ignored nor be recovered.
The thing to do is to make the best use of current situation and proceed.
Ignorable problems can be solved using a simple control structure that never backtracks.
Recoverable problems can be solved by a slightly more complicated control strategy that allows backtracking.
Irrecoverable problems will need to be solved by a system that expends a great deal of effort making each
decision since decision must be final.
Problem Characteristics
3. Is the problem’s universe predictable?
Problems can be classified into those with certain outcome (eight puzzle and water jug problems) and those
with uncertain outcome (playing cards).
In certain – outcome problems, planning could be done to generate a sequence of operators that guarantees to
lead to a solution.
For uncertain outcome problems, planning can at best generate a sequence of operators that has a good
probability of leading to a solution.
Problem Characteristics
3. Is the problem’s universe predictable?
The uncertain outcome problems do not guarantee a solution and it is often very expensive since the number
of solution paths to be explored increases exponentially with the number of points at which the outcome
cannot be predicted.
Thus one of the hardest types of problems to solve is the irrecoverable, uncertain –outcome problems (Ex:-
Playing cards).
Problem Characteristics
4. Is a good solution absolute or relative?
There are two categories of problems - Any path problem and Best path problem.
In any path problem, like the water jug and 8 puzzle problems, we are satisfied with the solution, irrespective of
the solution path taken.
Whereas in the other category not just any solution is acceptable but we want the best path solution.
Like that of traveling sales man problem, which is the shortest path problem.
In any – path problems, by heuristic methods we obtain a solution and we do not explore alternatives.
Problem Characteristics
4. Is a good solution absolute or relative?
Any path problems can often be solved in a reasonable amount of time by using heuristics that suggest good
paths to explore.
For the best-path problems all possible paths are explored using an exhaustive search until the best path is
obtained.
Finding a consistent interpretation for the sentence “The bank president ate a dish of pasta salad with the
fork”.
In water jug problem, it is not sufficient to report that we have solved, but the path that we found to the state
(2, 0).
Thus the statement of a solution to this problem must be a sequence of operations that produces the final
state.
Playing chess
Assumption: Suppose you have unlimited computing power available.
How much knowledge required:
A set of rules for determining legal moves.
Some simple control mechanism that implement an appropriate search procedure.
Good strategy and tactics could help to constraint the search and speed up search procedure.
A lot of knowledge required for searching
Problem Characteristics
6. What is the role of knowledge?
Reading Newspaper
Problem of scanning daily newspaper to decide winner and percent of public supporting democratic and
republican party in next election.
Knowledge required: The names of candidates in each party.
A lot of knowledge is required to recognize a solution
Problem Characteristics
7. Does the task require interaction with a person?
It depends on problem, that task require interaction with person or not.
Solitary problem in which the computer will be given a problem description and will produce an
answer, with no intermediate communication.
Example: Fact derivation from given statements.
Conversational, in which there will be intermediate communication between a person and the
computer, either to provide additional assistance to the computer or to provide additional
information to the user, or both.
Example: Chess in which with each move human interaction is required.
THANK YOU