0% found this document useful (0 votes)
11 views68 pages

AI Unit 2

Uploaded by

hrp.bizconnect
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views68 pages

AI Unit 2

Uploaded by

hrp.bizconnect
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 68

Artificial Intelligence (AI)

Unit-02
Problems, State Space
Search

Computer Engineering Department


LJIET
Outline
 Looping
 Problem, Problem State ,Space and 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.

 It is the process of generating solution from given observed data.

 To solve a particular problem, we need to build a system or a method which can generate
required solution.

 Following four things are required for building such system.


 Define the problem precisely: This definition must precisely specify the initial situation (input).
 Analyze the problem: To identify those important features which can have an immense impact on
the appropriateness
 Isolate and represent the task knowledge that is necessary to solve the problem.
 Choose the best problem solving technique and apply it to the particular problem.
Defining State & Search Space
 A state is a representation of problem elements at a given moment.

 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.

 In the state space, a path is a sequence of states connected by a sequence of 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.

 Specify a set of rules that describe the actions available.


Defining Problem & Search
 The scenario which is given is called as problem.

 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.

 This process is known as search.

 Search is fundamental to the problem-solving process.

 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.

 Neither jug has any measuring markings on it.

 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.

 Note that 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3.

 To solve this we have to make some assumptions not mentioned in the problem. They are:

 We can fill a jug from the pump.


 We can pour water out of a jug to the ground.
 We can pour water from one jug to another.
 There is no measuring device available.
Defining Problem State ,Space & Search: Water Jug problem
 Here the initial state is (0, 0).
 The goal state is (2, n).

 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 problem that correspond to three components.

 These elements are the problem states, moves and goal.

 In this problem each tile configuration is a state.


8 puzzle problem
 The set of all possible configuration in the problem space, consists of 3,62,880 different
configurations of the 8 tiles and blank space.

 For the 8-puzzle, a straight forward description is a 3X3 array of matrix of numbers.

 Initial global database is this description of the initial problem state.

 Virtually any kind of data structure can be used to describe states.

 A move transforms one problem state into another state


8 puzzle problem
 The 8-puzzle is conveniently interpreted as having the following for moves.
 Move empty space (blank) to the left, move blank up, move blank to the right and move
blank down.
 These moves are modeled by production rules that operate on the state descriptions in
the appropriate manner.

 The goal condition forms the basis for the termination.

 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.

 It is sometimes also called a production rule system.


Components of a production system
1. A Global Database
2. Set of Production rules
3. A control System/ Control Strategy
4. Rule Applier
Components of a production system
1. A Global Database:

 A global database consists of the architecture used as a central data structure.

 A database contains all the necessary data and information required for the successful
completion of a task.

 It can be divided into two parts as permanent and temporary.

 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 AB, 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

 The control system checks the applicability of a rule.

 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.

 Requirements of good control strategy:


1. It should cause motion Otherwise, it will never lead to a solution.
2. It should be systematic Otherwise, it may use more steps than necessary
3. It is efficient Find a good, but not necessarily the best, answer.

Some well-known control strategies are BFS, DFS, Heuristic search….


Characteristics of a Production System
 There are mainly four characteristics of the production system in AI that is simplicity,
modifiability, modularity, and knowledge-intensive.
Characteristics of a Production System
 Simplicity

 The production rule in AI is in the form of an ‘IF-THEN’ statement.

 Every rule in the production system has a unique structure.

 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)

1. Informed search (heuristic search) More efficient than uninformed search.


Search Strategies: BFS
Search Strategies: BFS
Search Strategies: BFS
Search Strategies: DFS
Search Strategies: DFS
Search Strategies: DFS
Search Strategies: Heuristic
Search Strategies: Heuristic
Problem Characteristics
 In order to choose the most appropriate problem solving method, it is necessary to analyze the
problem along various key dimensions.

 These dimensions are referred to as problem characteristics discussed below.


1. Is the problem decomposable into a set of independent smaller or easier sub-problems?
2. Can solution steps be ignored or undone?
3. Is the problem’s universe predictable?
4. Is a good solution absolute or relative?
5. Is the desired solution a state of the world or a path?
6. What is the role of knowledge?
7. Does the task require interaction with a person?
Problem Characteristics
1. Is the problem decomposable into a set of independent smaller or easier sub-problems?
 A very large and composite problem can be easily solved if it can be broken into smaller problems and
recursion could be used.

 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

 This classification is with reference to the steps of the solution to a problem.

 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.

 In which solution steps can be ignored.

 This is an example of ignorable solutions steps.


Problem Characteristics
2. Can solution steps be ignored or at least undone?

 (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.

 This is an example of an irrecoverable solution steps.


Problem Characteristics
2. Can solution steps be ignored or at least undone if they prove unwise?

 Knowledge of these will help in determining the control structure.

 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.

 Planning helps to avoid unwanted solution steps.

 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.

 Best path problems are computationally harder.


Problem Characteristics
4. Is a good solution absolute or relative?
Problem Characteristics
4. Is a good solution absolute or relative?
Problem Characteristics
4. Is a good solution absolute or relative?
Problem Characteristics
5. Is the desired solution a state of the world or a path?

 Consider the problem of natural language processing.

 Finding a consistent interpretation for the sentence “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?

 In this example, the solution is a state,


 we need only the meaning of a sentence, not the way in which interpretation was found
Problem Characteristics
5. Is the desired solution a state of the world or a path?

 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.

 Water Jug Problem is the solution as a path.


Problem Characteristics
6. What is the role of knowledge?

 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

Computer Engineering Department


LJIET

You might also like