0% found this document useful (0 votes)
13 views152 pages

AI Unit 1

The document outlines a course on Artificial Intelligence (AI) taught by Dr. M. Shobha Rani, covering topics such as AI definitions, problems, techniques, and search methods. It discusses various AI problems, including mundane tasks, formal tasks, and expert tasks, and provides examples like Tic-Tac-Toe and question-answering systems. The document also emphasizes the importance of defining problems, analyzing them, and selecting appropriate techniques for problem-solving in AI.

Uploaded by

Grishma G
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)
13 views152 pages

AI Unit 1

The document outlines a course on Artificial Intelligence (AI) taught by Dr. M. Shobha Rani, covering topics such as AI definitions, problems, techniques, and search methods. It discusses various AI problems, including mundane tasks, formal tasks, and expert tasks, and provides examples like Tic-Tac-Toe and question-answering systems. The document also emphasizes the importance of defining problems, analyzing them, and selecting appropriate techniques for problem-solving in AI.

Uploaded by

Grishma G
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/ 152

School of Computer Science and Engineering

Course Delivery

By

Dr.M.Shobha Rani
UNIT -1
PROBLEMS & SEARCH
COURSE CONTENT
1. What is AI
2. AI Problems
3. AI Techniques
4. Space and Problem Search techniques
5. Defining the problem as a state space search
6. Production systems
7. Problem characteristics
8. Production system characteristics
9. Issues in the design of search programs
10. Heuristic search techniques
11. generate-and-test
12. Hill climbing, BFS, DFS
13. Problem reduction; Constraint satisfaction
1. WHAT IS AI?
Definition:

“Artificial Intelligence is the study of how to


make computers do things which, at the
moment, people do better”
2. AI PROBLEMS
MUNDANE TASKS FORMAL TASKS
• Perception • Games
• Vision • Chess, Checkers-go
• Speech • Mathematics
• Natural Language • Geometry, Logic,
• Understanding Calculus
• Generation EXPERT TASKS
• Translation
• Engineering
• Commonsense
Reasoning • Scientific Analysis
• Robot control • Medical Diagnosis
• Financial Analysis
ASSUMPTIONS
Before embarking on a study of AI problems and
solution techniques it is important to answer these
questions
1. What are our underlying assumptions about
intelligence?
2. What kinds of techniques will be useful for
solving AI problems?
3. At what level of detail, if at all, are we trying to
model human intelligence?
4. How will we know when we have succeeded in
building an intelligent program?
THE UNDERLYING ASSUMPTION
Physical Symbol system
• A Physical symbol system is a machine that
produces through time an evolving collection of
symbol structures.

Symbol Structure
• A symbol structure is composed of a number of
instances (or tokens) or symbols related in some
physical way.
PHYSICAL SYMBOL SYSTEM HYPOTHESIS

Hypothesis: A physical symbol system


has the necessary and sufficient means
for general intelligent action.
It is an explanation or solution to a problem based on
insufficient data
3. WHAT IS AN AI TECHNIQUE
AI technique is a method that exploits knowledge that should be
represented in such a way that
1. The knowledge captures generalizations. (situations that share
important properties are grouped together).
2. It can be understood by people who provide it.(most of the
knowledge the program must be provided by the people).
3. It can be easily modified to correct errors and to reflect
changes in the world and in our world view.
4. It can be used in a great many situations even if it is not totally
accurate or complete.
5. It can be used to help overcome its own sheer bulk by helping
to know the range of possibilities that must actually be
considered.
AI PROBLEMS
Examples

• Tic-Tac Toe
• Question Answering Systems
TIC-TAC TOE
1. A nine element vector representing the board
2. Paper pencil playing game of 2 players Marking X &
O. Mark in 3X3 grid
BOARD STATES
The tic-Tac-Toe game can be solved in three ways. The
programs or solutions in the Series increase in,
• Their complexity
• Use of generalization
• Clarity of their knowledge
• Extensibility of their approach
PROGRAM 1
DATA STRUCTURES
1. Board: A nine-element vector representing the board, where the elements of
the vector correspond to the board positions as follows:
Element contains the value
0 – if the corresponding square is blank
1 – if filled with an ‘X’
2 – if filled with an ‘O’
2. Movetable: A large vector of 19,683 elements (3^9 = 19683) each element of
which is a nine-element vector.
ALGORITHM 1
To make a move do the following
1. View the vector board as a ternary (base three)
number. Convert it to a decimal number.
2. Use the number computed in Step 1 as an index into
Movetable and access the vector stored there.
3. The vector selected in step 2 represents the way the
board will look after the move that should be made.
So set board equal to that vector.
ADVANTAGES & DISADVANTAGES OF
ALGORITHM 1
Advantages
1. Program is efficient in terms of time.
Disadvantages
1. It takes a lot of space to store the table that specifies the
correct move to make from each board position.
2. Someone will have to do a lot work specifying all the
entries in the table.
3. It is very unlikely that all the required movetable entries
can be determined and entered without any errors.
4. If we extend the game to three dimensions, we would
have to store 3^27 board positions overwhelming the
computer memories
PROGRAM 2
Data Structures
1. Board: A nine element vector representing the
board
2 – if the corresponding square is blank
3 – if filled with an ‘X’
5 – if filled with an ‘O’
2. Turn: An integer indicating which move of the
game is about to be played, 1 indicating the first
move, 9 the last.
ALGORITHM 2
1. Make 2
Returns 5 if the center of the board is blank
(if board[5]=2)
2. Posswin(p)
• Returns 0 if player cannot win in his next move, otherwise it
returns the number of the square that constitutes a winning
move.
• Posswin operates by checking, one at a time, each of the rows,
columns and diagonals.
• To check for a win of either ‘O’ or ‘X’, multiplying the board
positions enables us to determine the win
✓ X wins when the product is 18 (3*3*2) 2 2 2 2 2 2

✓ O wins when the product is 50 (5*5*2) 2 3 2 2 5 2


2 3 5 2 2 5
3. Go(n)
• Makes a move in square n. This procedure sets board[n] to 3 if Turn is
odd, or 5 if Turn is even. It also increments Turn by one.
ADVANTAGES & DISADVANTAGES OF
ALGORITHM 2

ADVANTAGES
• Efficient in terms of space
• Lot easier to understand the program’s strategy or to
change the strategy if desired.
DISADVANTAGES
• Program has to check several conditions before making
each move
PROGRAM 2’
• This program is identical to Program 2 except for one
change in the representation of the board.
• This numbering of the board produces a magic square,
all the rows, columns and diagonals sum up to 15.
• This simplifies the process of checking for a possible
win.
Data Structures

1. Board: A nine element vector representing the board


2 – if the corresponding square is blank
3 – if filled with an ‘X’
5 – if filled with an ‘O’
2. Turn: An integer indicating which move of the game is about to
be played, 1 indicating the first move, 9 the last.
Algorithms
PROGRAM 3
Data Structure
• The structure of the data consists of BOARD which contains a nine
element vector.
• a list of board positions that could result from the next move and
a number representing an estimation of how the board position
leads to an ultimate win for the player to move.
• This algorithm looks ahead to make a decision on the next move
by deciding which the most promising move or the most suitable
move at any stage would be and selects the same.
• Consider all possible moves and replies that the program can
make.
• Continue this process for as long as time permits until a winner
emerges, and then choose the move that leads to the computer
program winning, if possible in the shortest time
Algorithm
Advantages & Disadvantages
Example 1
Example 2
QUESTION ANSWERING
• Question Answering systems that accept input in English and
provide answers also in English.
• This problem is harder than the previous one as it is more difficult
to specify the problem properly.
• Another area of difficulty concerns deciding whether the answer
obtained is correct, or not, and further what is meant by ‘correct’.
• For example, consider the following situation:
“Russia massed troops on the Czech border”
• Then either of the following question-answering dialogues might
occur
DIALOGUE 1
Q: Why did Russia do this?
A: Because Russia thought it could political control of
Czechoslovakia by sending troops
Q: What should the United states do?
A: The U.S should intervene militarily

DIALOGUE 2
Q: Why did Russia do this?
A: Because Russia wanted to increase its political influence over
Czechoslovakia.
Q: What should the United states do?
A: The U.S should denounce the Russian action in the U.N
Conclusion

• The general point is that defining a correct answer to a question


may be very hard.
• Usually QA programs define what it means to produce a correct
answer by the procedure that is used to compute the answer.
• Then their author appeal to other people to agree that the
answers found “make sense” and so to confirm the model of
question answering defined in the program.
Another Example
“Mary went shopping for a new coat. She found a
red one she really liked. When she got it home,
she discovered that it went perfectly with her
favorite dress.”
The above input text will be illustrated with three different
definitions each with a corresponding program that implements
the definition.
The following questions will be attempted to answer with each
program
Q1: What did Mary go shopping for?
Q2: What did Mary find that she liked?
Q3: Did Mary buy anything?
PROGRAM 1
• This program simply matches text fragments in the questions
against the input text.
DATA STRUCTURES
1. QuestionPatterns
• A set of templates that match common questions and produce
patterns used to match against inputs.
• Templates and patterns are used so that a template that matches a
given question is associated with the corresponding pattern to find
the answer in the input text.
• For example, the template x y generates x y z if a match occurs and
z is the answer to the question. The given text and the question are
both stored as strings.
2. Text : The input text stored simply as a long character string.
3. Question: The current question also stored as a character string
ALGORITHM
1. Compare the template against the questions and store all
successful matches to produce a set of text patterns
2. Pass these text patterns through a substitution process to
change the person or voice and produce an expanded set of
text patterns.
3. Apply each of these patterns to the text; collect all the answers
and then print the answers
4. Reply with the set of answers just collected.
EXAMPLES
• QI
✓ The template "What did x v" matches this question and generates the
text pattern "Mary go shopping for z."
✓ After the pattern-substitution step, this pattern is expanded to a set of
patterns including "Mary goes shopping for z." and "Mary went
shopping for z."
✓ The latter pattern matches the input text the program, using a
convention that variables match the longest possible string up to a
sentence delimiter
• Q2
✓ Unless the template set is very large, allowing for the insertion of the
object of "find" between it and the modifying phrase "that she liked,"
the insertion of the word "really" in the text, and the substitution of
"she" for "Mary,“

• Q3 is not answerable since no related text is available in the


text.
PROGRAM 2
• This program first converts the input text into a structured
internal form that attempts to capture the meaning of the
sentences. It also converts questions into that form
• It finds answers by matching structured forms against each other.

DATA STRUCTURES
1. EnglishKnow
• A description of the words, grammar, and appropriate semantic
interpretations of a large enough subset of English to account for the input
texts that the system will see.
• EnglishKnow is used to map input sentences into an internal, meaning-
oriented form and to map from such internal forms back into English.
• The former process is used when English text is being read; the latter is
used to generate English answers from the meaning-oriented form that
constitutes the program's knowledge base.
2. InputText: The input text in a character form.
3. StructuredText:
• A structured representation of the content of the input text. This
structure attempts to capture the essential knowledge contained in the
text, independently of the exact way that the knowledge was stated in
English.
• Some things that were not explicit in the English text, such as the
referents of pronouns, have been made explicit in this form.
• Representing knowledge such as this is an important issue in the
design of almost all AI programs. Existing programs exploit a variety of
frameworks for doing this.
• There are three important families of such knowledge representation
systems: production rules (of the form "if x then y"), slot-and-filler
structures, and statements in mathematical logic
4. InputQuestion: The input question in character form
5. StructQuestion: A structured representation of the content of the user’s
question.
Structured Representation of a Sentence
ALGORITHM
1. Convert the question to structured form, using the knowledge
contained in EnglishKnow. Some special marker in the structure
is used to indicate the part of the structure that should be
returned as the answer. This marker will often correspond to
the occurrence of a question word (like "who" or "what") in the
sentence.
2. Match this structured form against StructuredText.
3. Return as the answer those parts of the text that match the
requested segment of the question.
Examples
Q1: This question is answered straightforwardly with, “a new coat”.
Q2: This one is also answered successfully with, “a red coat”.
Q3: This one, cannot be answered, since there is no direct response
to it in the text.
ADVANTAGES & DISADVANTAGES
• This approach can answer most questions to which replies are
contained in the text with respect to the exact forms of the text
and the questions.
• This increased flexibility due to the time spent searching the
various knowledge bases. (EnglishKnow, StructuredText)
• The problem of producing a knowledge base for English that is
powerful enough to handle a wide range of English inputs is very
difficult.
PROGRAM 3
• This program converts the input text into a structured form that
contains the meanings of the sentences in the text, and then it
combines that form with other structured forms that describe
prior knowledge about the objects and situations involved in the
text.
• It answers questions using the above augmented knowledge
structure.
DATA STRUCTURES
1. WorldModel:
• A structured representation of background world knowledge. This structure
contains knowledge about objects, actions and situations that are
described in the input text.
• This structure is used to construct IntegratedText from the input text

2. EnglishKnow: Same as in Program2


3. InputText: The input text in character form.
4. IntegratedText:
• A structured representation of the knowledge contained in the input text
but combined with other background, related knowledge.

5. InputQuestion: The input question in character form.


6. StructQuestion: A structured representation of the question
A SHOPPING SCRIPT
CHAPTER-2
PROBLEMS, PROBLEM SPACES AND
SEARCH
What is Problems
Define a Problem
Steps to Solve a Problem
• Define the problem precisely.
• Must include precise specifications
• What final situations constitute acceptable solutions to the
problem. Both the initial and final state
• Analyze the problem
• appropriateness of various possible techniques for solving the
problem
• Isolate and represent the task knowledge that is
necessary to solve the problem.
• Choose the best problem-solving technique(s) and apply
it (them) to the particular problem.
PROBLEM SPACES AND SEARCH
• State space search is a problem-solving technique
used in Artificial Intelligence (AI) to find the solution
path from the initial state to the goal state by exploring
the various states.
• The state space search approach searches through all
possible states of a problem to find a solution.
• It is an essential part of Artificial Intelligence and is
used in various applications, from game-playing
algorithms to natural language processing.
CHESS PROBLEM
• Specify the starting position of the chess board
• The rules that define the legal moves
• Board positions that represent a win for one side or
the other.
• Formal and complete problem description
• The starting position can be described as an 8 x 8 array
where each position contains a symbol.
• We can define as a goal any board position in which the
opponent does not have a legal move and his or her king
is under attack.
• The legal moves provide the way of getting from the
initial state to a goal state
ONE LEGAL CHESS MOVE
The Set of rules can be considered
under two parts, Left and right side,
using these we can write a rules in
several ways
ISSUES WITH PREVIOUS TECHNIQUE
• If we write rules like the one above, there are roughly
10^20 possible board positions (and rules).
• These rules results in two serious practical problems.
1. No person can supply a complete set of such rules.
Also take too long time and cannot be done without
mistakes.
2. No program could easily handle all those rules.
Although a hashing scheme could be used to find the
relevant rules for each move fairly quickly, just
storing that many rules poses serious difficulties.
ALTERNATIVE of Chess Problem
CHESS PROBLEM DEFINED AS STATE SPACE
• Each state corresponds to a legal position of the
board.
• We can then play chess by starting at an initial state,
using a set of rules to move from one state to
another, and attempting to end up in one of a set of
final states.
• The state space representation forms the basis of
most of the AI methods.
State representation form corresponds to the
structure of problem used in solving problems in
two important ways:
• It allows for a formal definition of a problem as the need to
convert some given situation into some desired situation
using a set of permissible operations
• It permits us to define the process of solving a particular
problem as a combination of known techniques (each
represented as a rule defining a single step in the space) and
search
• The general technique of exploring the space is to try to find
some path from the current state to a goal state.
• Search is a very important process in the solution of hard
problems for which no direct techniques are available
EXAMPLE (THE WATER JUG PROBLEM)

You are given two jugs. a 4-gallon one and a 3-


gallon one. Neither has any measuring markers
on it. There is a pump that can be used to fill
the jugs with water. How can you get exactly 2
gallons of water into the 4-gallon jug?
STATE SPACE FOR THE PROBLEM
• Set of ordered pairs of integers (x, y).
such that x = 0, 1, 2, 3 or 4 and y = 0, 1, 2, or 3
• x represents the number of gallons of water in the 4-
gallon jug
• y represents the quantity of water in the 3-gallon
jug.
• The start state is (0,0).
• The goal state is (2,n) for any value of n (since the
problem does not specify how many gallons need to
be in the 3-gallon jug).
RULES
ONE SOLUTION
PRODUCTION SYSTEM
Production systems provide ways to structure Al programs in a way that
facilitates describing and performing the search process.
A production system consists of
• A set of rules, each consisting of a left side (a pattern) that determines the
applicability of the rule and Right side that describes the operation to be
performed if the rule is applied?
• database, which contains all the appropriate information for the particular task.
Some part of the database may be permanent while some part of this may pertain
only to the solution of the current problem.
• A control strategy that specifies order in which the rules will be compared to the
database of rules and a way of resolving the conflicts that arise when several rules
match simultaneously.
• A rule applier, which checks the capability of rule by matching the content state
with the left hand side of the rule and finds the appropriate rule from database of
rules.
CONTROL STRATEGY
• CONTROL STRATEGY : how to decide which rule to apply
next during the process of searching for a solution to a
problem.
Rules for Control Strategy
1. The first requirement of a good control strategy is that it
causes motion.
• For the water jug problem if we implemented the simple
control strategy of starting each time at the top of the list of
rules and choosing the first applicable one. (will never solve
the problem)
2. The second requirement of a good control strategy is that
it be systematic.
• On each cycle, if we choose at random from among
the applicable rules, (it causes motion). It will lead to a
solution eventually.
• But we are likely to arrive at the same state several
times during the process and to use many more steps
than are necessary.
• Because the control strategy is not systematic, we may
explore a particular useless sequence of operators
several times before we finally find a solution.
SYSTEMATIC CONTROL STRATEGY FOR
THE WATER JUG PROBLEM
• Construct a tree with initial state as its root. Generate
all the offspring of the root by applying each of the
applicable rules to the initial state. (fig a)
• For each leaf node, generate all its successors by
applying all the rules that are appropriate (fig b).
• Continue this process until some rule produces a goal
state. This process is called as breadth-first search.
Breadth First Search (BFS)
• Searches breadth-wise in the problem space.
• Breadth-First search is like traversing a tree where each node is a state which
may a be a potential candidate for solution. It expands nodes from the root of
the tree and then generates one level of the tree at a time until a solution is
found.
• Queue is used for implementation
Advantages of Breadth-First Search
• Breadth first search will never get trapped exploring the useless path
forever.
• If there is a solution, BFS will definitely find it out.
• If there is more than one solution then BFS can find the minimal one that
requires less number of steps.

Disadvantages of Breadth-First Search


• The main drawback of Breadth first search is its memory requirement.
Since each level of the tree must be saved in order to generate the next
level, and the amount of memory is proportional to the number of nodes
stored, the space complexity of BFS is O(bd). As a result, BFS is severely
space-bound in practice so will exhaust the memory available on typical
computers in a matter of minutes.
• If the solution is farther away from the root, breath first search will
consume lot of time.
Depth First Search (DFS)
• searches deeper into the problem space.
• Breadth-first search always generates successor of the deepest
unexpanded node.
• It uses last-in first-out stack for keeping the unexpanded nodes.
• More commonly, depth-first search is implemented recursively,
with the recursion stack taking the place of an explicit node stack.
Algorithm: Depth First Search
1.If the initial state is a goal state, quit and return success.
2.Otherwise, loop until success or failure is signaled.
a) Generate a state, say E, and let it be the successor of the initial state. If
there is no successor, signal failure.
b) Call Depth-First Search with E as the initial state.
c) If success is returned, signal success. Otherwise continue in this loop.
Advantages of Depth-First Search
• The advantage of depth-first Search is that memory requirement is only linear
with respect to the search graph.
• The time complexity of a depth-first Search to depth d is O(b^d) since it generates
the same set of nodes as breadth-first search, but simply in a different order. Thus
practically depth-first search is time-limited rather than space-limited.
• If depth-first search finds solution without exploring much in a path then the time
and space it takes will be very less.

Disadvantages of Depth-First Search


• The disadvantage of Depth-First Search is that there is a possibility that it may go
down the left-most path forever. Even a finite graph can generate an infinite tree.
Goes for Depth Cutoff.
• Depth-First Search is not guaranteed to find the solution.
• And there is no guarantee to find a minimal solution, if more than one solution
exists.
Solution for Water Jug Problems with Search:
HEURISTIC FUNCTION
• The purpose of the heuristic function is to guide the search process in the most
profitable direction by suggesting which path to follow first when more than one is
available.
• The more accurately the heuristic function estimates the true merits of each node in
the search tree (or graph), the more direct the solution process.
SOME SIMPLE HEURISTIC FUNCTIONS

CHESS The material advantage of our side over the


opponent
TRAVELING The sum of the distances so far
SALESMAN

Tic-Tac Toe 1 for each row in which we could win and in which we
already have one piece, plus 2 for each such row in
which we have two pieces
PROBLEM CHARACTERISTICS
In order to choose the most appropriate method (or
combination of methods) for a particular problem, it is
necessary to analyze the problem along several
dimensions
1. Is the problem decomposable into a set of (nearly)
independent smaller or easier subproblems?
2. Can solution steps be ignored or at least undone if they
prove unwise?
3. Is the problem’s universe predictable?
4. Is good solution absolute or relative?
5. IS THE SOLUTION A STATE OR A PATH
6. What is the role of Knowledge?
7. Does the task requires interaction with the
person.
8. Problem Classification
1. IS THE PROBLEM DECOMPOSABLE?

Example: BLOCKS WORLD PROBLEM


BLOCKS WORLD PROBLEM
Assume that the following operators are available.
1. CLEAR (x) {block x has nothing on it} → ON(x,
table) {pick up x and put it on the table}.
2. CLEAR(x) and CLEAR(y)→ ON(x,y) {put x on
y}

Applying the technique of problem decomposition


to this simple blocks world example would lead to
a solution tree
2. CAN SOLUTION STEPS BE IGNORED OR
UNDONE?
Suppose we are trying to prove a mathematical
theorem. We proceed by first proving a lemma
(subsidiary theorem) that we think is useful,
eventually it wasn’t helpful, can we recover?
There are three important classes of problems.
1. Ignorable
• Solution steps can be ignored (theorem proving)
2. Recoverable
• Solution steps can be undone (tic-tac toe & 8 Puzzle
Game)
3. Irrecoverable
• Solution steps cannot be undone (chess)
The eight tile puzzle problem
formulation

Statement:
The eight tile puzzle consist of a 3 by 3 (3*3) square
frame board which holds 8 movable tiles numbered 1
to 8. One square is empty, allowing the adjacent tiles to
be shifted. The objective of the puzzle is to find a
sequence of tile movements that leads from a starting
configuration to a goal configuration.
Formulation of 8 Puzzle Game
3. IS THE UNIVERSE PREDICTABLE
• For example, we are playing a 8-puzzle game, every
time we make a move it is possible to plan an entire
sequence of moves and eventually the resulting
state.
• We can use planning to avoid having to undo actual
moves, although it will still be necessary to
backtrack past those moves one at a time during
the planning process.
• Whereas while playing cards (eg. rummy), its hard
to figure out the next state in the game as it is
probabilistic in nature.
4. IS A GOOD SOLUTION ABSOLUTE OR
RELATIVE
• Problem of answering questions based on a database
of simple facts (any-path problem)
• By representing these facts in a formal language,
such as predicate logic and then using inference
methods to derive an answer to the question
S.NO FACT
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 79A.D
6 No mortal lives longer than 150 years
7 It is now 1991 A.D
TWO POSSIBLE SOLUTIONS
TRAVELING SALESMAN PROBLEM(best-path problem)
5. IS THE SOLUTION A STATE OR A PATH

Consider the problem of finding a consistent interpretation


for the sentence.
“The bank president ate a dish of pasta salad with the fork”
Some of the sources of ambiguity in the sentence are the
following
• The word bank may refer either to a financial institution or
to a side of a river.
Because of the interaction among the interpretations of the
constituents of the sentence, some search may be required to
find a complete interpretation for the sentence. (solution is a
state)
THE WATER JUG PROBLEM
• Apart from stating that the problem has been
solved by reaching the goal or final state, it is also
important to mention the path leading to the goal
state.
• Thus a statement of a solution to this problem must
be a sequence of operations that produces the final
state.
6. What is the role of Knowledge?
• Though one could have unlimited computing power, the size
of the knowledge base available for solving the problem
does matter in arriving at a good solution.
• Take for example the game of playing chess, just the rues for
determining legal moves and some simple control
mechanism is sufficient to arrive at a solution.
• But additional knowledge about good strategy and tactics
could help to constrain the search and speed up the
execution of the program. The solution would then be
realistic.
• Consider the case of predicting the political trend. This
would require an enormous amount of knowledge even to
be able to recognize a solution , leave alone the best.
7. Does the task require interaction with the
person?
The problems can again be categorized under two heads.
1. Solitary
•in which the computer will be given a problem description and will produce
an answer, with no intermediate communication and with he demand for an
explanation of the reasoning process.
•Simple theorem proving falls under this category given the basic rules and
laws, the theorem could be proved, if one exists.
Ex:- Theorem proving (give basic rules & laws to computer)
2. Conversational
•in which there will be intermediate communication between a person and
the computer, whether to provide additional assistance to the computer or to
provide additional information to the user,
•both problems such as medical diagnosis fall under this category, where
people will be unwilling to accept the verdict of the program, if they cannot
follow its reasoning.
Ex:- Problems such as medical diagnosis.
8. Problem Classification

• Actual problems are examined from the point of


view, the task here is examine an input and decide
which of a set of known classes.

• Ex:- Problems such as medical diagnosis ,
engineering design.
Production System Characteristics
Production system is a program (method) used to
provide solution to particular problem concerned in AI.
It consists of following things:
i. Production rules
ii. Knowledge base
iii. Control strategy
Following are the classes of production system:
1. Monotonic production system
2. Non-monotonic production system
3. Partially Commutative production system
4. Commutative productions system
Production System Characteristics
1. A monotonic production system is when two rules are
simultaneously applied to the machine. Using one rule
doesn't affect the other rule in any way, which makes
their co-existence easy. (i.e, rules are independent)
2. Non-monotonic production system is opposite to
Monotonic production system.
3. Partially commutative production system : In this
production system if a set of rules is used to change state
A to state B then any allowable combination of these
rules will also produce the same results (convert state A
to state B)
4. A commutative production system is a production system
that is both monotonic and partially commutative.
• Partially commutative monotonic production system are useful for solving
ignorable problem. Problems that involve creating new things rather than
changing old ones are generally ignorable.
• Non-monotonic, partially commutative production system are useful for
problems in which changes occur but can reversed and in which, order of
operation is not critical.
• Not partially commutative production system are useful in which
irreversible changes occur. The order in which they are performed can be
very important in determining the final output.
• Not-partially commutative and non-monotonic production system are
useful in which reversible changes occur, order doesn’t matter.
Issues in Design of search programs
• In which direction to conduct search (forward Vs Backward): we
can search forward through the state space from the start state to
a goal state, or we can search backward from the goal state.
• How to select applicable rule (matching): Production systems
typically spend most of their time looking for rules to apply, so it
is critical to have efficient procedures for matching rules against
states.
• How to represent each node of the search process (the
knowledge representation problem and frame problem): For
problems like chess, a node can be fully represented by a simple
array. In more complex problem solving it is inefficient and/or
impossible to represent all of the facts in the world and to
determine all of the side effects an action may have.
CHAPTER-3
HEURISTIC SEARCH TECHNIQUES
• Heuristic Search, which is an integral part of Artificial
Intelligence.
• A Heuristic is a technique to solve a problem faster
than classic methods, or to find an approximate
solution when classic methods cannot.
• Heuristic function applied each step to evaluate the
available information and to make the decision to
follow the branch.
GENERATE AND TEST
The generate and test approach is the simplest of all
approaches.
Algorithm
1. Generate a possible solution.
2. Test to see if this is actually a solution by
comparing the chosen point or the endpoint of
the chosen path to the set of acceptable goal
states.
3. If a solution has been found, quit. return to step I.
GENERATE AND TEST
• If the generation of possible is done systematically
then a solution is found eventually.
• If the problem is very large, “eventually” may be a
very long time.
• The generate-and-test algorithm adopts DFS &
Backtracking approach since complete solutions
must be generated before they can be tested.
• In simple words it’s a exhaustive search of problem
• Generators can be in two ways: Complete solutions
that are possible or generate random solutions
HILL CLIMBING
• Hill climbing is a variant of generate-and-test algorithm, where it
is augmented with feedback from the test procedure, the generator
decides which direction to move in the search space.
• In a pure generate-and-test procedure the function responds with
only yes or no.
• For example a heuristic function to move from outskirts of the city
to the downtown without a map could be to keep moving towards
taller building until we reach downtown (desirable state).
• Hill climbing is unsuited for problems where the value of the
heuristic function drops off suddenly as we move from away from
a solution.
• Hill climbing is a local method, it decides what to do next by
looking only at the “immediate” consequences of its choice
rather than by exhaustively exploring all the consequences.
SIMPLE HILL CLIMBING
STEEPEST-ASCENT HILL CLIMBING
STEEPEST-ASCENT HILL CLIMBING
• In Basic Hill climbing algorithm, First applies one
operator and gets new state. Then evaluated is it is goal
state will stop otherwise we will select a better and
make that has a current new state.
• In steepest will consider all the moves from the current
state and selects the best one among them.
• This differs from the basic Hill climbing algorithm by
choosing the best successor rather than the first
successor that is better (BestFS).
• Both basic and steepest hill climbing may fail to find a
solution. Either algorithm may terminate not by
reaching the goal stat, but by getting into a state where
they cannot proceed further from.
• This will happen if the program has reached either a
local maxima, a plateau or a ridge.
Different regions in the State Space Diagram
Different regions in the State Space Diagram
1. Local maximum : It is a state which is better than its neighboring state however there
exists a state which is better than it(global maximum). This state is better because here
value of objective function is higher than its neighbors.
2. Global maximum : It is the best possible state in the state space diagram. This because at
this state, objective function has highest value.
3. Plateua/flat local maximum : It is a flat region of state space where neighboring states
have the same value.
4. Ridge : It is region which is higher than its neighbours but itself has a slope. It is a special
kind of local maximum.
5. Current state : The region of state space diagram where we are currently present during
the search.
6. Shoulder : It is a plateau that has an uphill edge.
Problems
• Local Maxima
• A state that is better than all of its neighbors, but not better
than some other states far away.
• Plateau
• A flat area of the search space in which all neighboring states
have the same value.
• Ridge
is a special kind of local maximum. It is an area of the
search space that is higher than surrounding areas and
that itself has a slope (which one would like to climb).
But the orientation of the high region compared to the
set of available moves and the directions in which they
move, makes it impossible to traverse a ridge by single
moves.
WAYS TO DEAL WITH THE PROBLEM
• Backtrack to some earlier node and try going in a
different direction.
• To implement the above strategy, maintain a list of
paths almost taken and go back to one of them if
the path taken leads to a dead end.
• Make a big jump in some direction to try to get to a
new section of the search space.
• Apply two or more rules before doing the test. This
corresponds to moving in several directions at
once. This is a particularly good strategy for dealing
with ridges.
HILL CLIMBING (DISADVANTAGES)
EXAMPLE : BLOCKS WORLD PROBLEM
GLOBAL APPROACH
Example 2
Problem Reduction
• Problem Reduction is a technique applicable for
problems represented using AND-OR graphs.
• When a problem can be divided into a set of sub
problems, where each sub problem can be solved
separately and a combination of these will be a
solution, AND-OR graphs are used for representing
the solution.
• The decomposition of the problem or problem
reduction generates AND arcs. One AND arc may
point to any number of successor nodes. All these
must be solved to arrive at a possible solution.
http://aimaterials.blogspot.com/p/and-or-
graph.html
Example 2
Constraint Satisfaction Problem(CSP)
Many problems in AI can be considered as problems of constraint satisfaction,
in which the goal state satisfies a given set of constraint.
constraint satisfaction problems can be solved by using any of the search
strategies.
The general form of the constraint satisfaction procedure is as follows:
Until a complete solution is found or until all paths have led to lead ends, do
1. select an unexpanded node of the search graph.
2. Apply the constraint inference rules to the selected node to generate all
possible new constraints.
3. If the set of constraints contains a contradiction, then report that this path is
a dead end.
4. If the set of constraints describes a complete solution then report success.
5. If neither a constraint nor a complete solution has been found then apply the
rules to generate new partial solutions. Insert these partial solutions into the
search graph.
Crypt Arithmetic Problem
Examples
Thank You

You might also like