18CS71 M1 Updated
18CS71 M1 Updated
18CS71 M1 Updated
Module-1
Course Notes
18CS71
Introduction to Artificial Intelligence
Syllabus: What is artificial intelligence? Problems, Problem Spaces and search, Heuristic Search
TextBook1: Ch 1, 2
1
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Intelligence: It is the knowledge in operation towards the solution – how to do? How to apply
the solution?
Artificial Intelligence: Artificial intelligence is the study of how make computers to do things
which people do better at the moment. It refers to the intelligence controlled by a computer
machine.
We will see the introduction of the systems which equal or exceed human abilities and see them
because an important part of most business and government operations as well as our daily
activities.
Definition of AI: Artificial Intelligence is a branch of computer science concerned with the study
and creation of computer systems that exhibit some form of intelligence such as systems that learn
new concepts and tasks, systems that can understand a natural language or perceive and
comprehend a visual scene, or systems that perform other types of feats that require human types
of intelligence.
To understand AI, we should understand
❑ Intelligence
❑ Knowledge
❑ Reasoning
2
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
❑ Thought
❑ Cognition: gaining knowledge by thought or perception learning
The definitions of AI vary along two main dimensions: thought process and reasoning and
behavior.
AI is not the study and creation of conventional computer systems. The study of the mind, the body,
and the languages as customarily found in the fields of psychology, physiology, cognitive science,
or linguistics.
In AI, the goal is to develop working computer systems that are truly capable of performing tasks
that require high levels of intelligence.
One View of AI is
• About designing systems that are as intelligent as humans
• Computers can be acquired with abilities nearly equal to human intelligence
• How system arrives at a conclusion or reasoning behind selection of actions
• How system acts and performs not so much on reasoning process.
4. The following are the figures showing some of the tasks that are the targets of work in AI:
3
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
First perceptual, linguistic and commonsense skills are learned. Later expert skills such as
engineering, medicine or finance are acquired.
This hypothesis is only a hypothesis there appears to be no way to prove or disprove it on logical
ground so, it must be subjected to empirical validation we find that it is false. We may find the bulk
of the evidence says that it is true but only way to determine its truth is by experimentation”.
Computers provide the perfect medium for this experimentation since they can be programmed to
simulate physical symbol system we like. The importance of the physical symbol system hypothesis
is twofold. It is a significant theory of the nature of human intelligence and so is of great interest to
psychologists.
Intelligence requires Knowledge. Knowledge possesses some less desirable properties including:
➢ It is voluminous
➢ It is hard to characterize accurately
➢ It is constantly changing
➢ It differs from data by being organized in a way that corresponds to the ways it willbe
used.
AI technique is a method that exploits knowledge that should be represented in such a way
that:
• The knowledge captures generalizations. In other words, it is not necessary to represent
each individual situation. Instead situations that share important properties are grouped
together.
• It can be understood by people who must provide it. Most of the knowledge a program has
must ultimately be provided by people in terms they understand.
• It can be easily be modified to correct errors and to reflect changes in the world and in our
world view.
• It can be used in a great many situations even if it is not totally accurate or complete.
• It can be used to help overcome its own sheer bulk by helping to narrow therange of
possibilities that must usually be considered.
5
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Fig 1.
A Formal Definition of the Game:
The board used to play the Tic-Tac-Toe game consists of 9 cells laid out in the form of a 3x3 matrix
(Fig. 1). The game is played by 2 players and either of them can start. Each of the two players is
assigned a unique symbol (generally 0 and X). Each player alternately gets a turn to make a move.
Making a move is compulsory and cannot be deferred. In each move a player places the symbol
assigned to him/her in a hitherto blank cell. Let a track be defined as any row, column or diagonal
on the board. Since the board is a square matrix with 9 cells, all rows, columns and diagonals have
exactly 3 cells. It can be easily observed that there are 3 rows, 3 columns and 2 diagonals, and
hence a total of 8 tracks on the board (Fig. 1). The goal of the game is to fill all the three cells of
any track on the board with the symbol assigned to one before the opponent does the same with the
symbol assigned to him/her. At any point of the game, if there exists a track whose all three cells
have been marked by the same symbol, then the player to whom that symbol have been assigned
wins and the game terminates. If there exist no track whose cells have been marked by the same
symbol when there is no more blank cell on the board then the game is drawn.
6
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Let the priority of a cell be defined as the number of tracks passing through it. The priorities of the
nine cells on the board according to this definition are tabulated in Table 1. Alternatively, let the
priority of a track be defined as the sum of the priorities of its three cells. The priorities of the eight
tracks on the board according to this definition are tabulated in Table 2. The prioritization of the
cells and the tracks lays the foundation of the heuristics to be used in this study. These heuristics
are somewhat similar to those proposed by Rich and Knight. Artificial Intelligence Page 17
Strategy 1:
Algorithm:
1. View the vector as a ternary number. Convert it to a decimal number.
2. Use the computed number as an index into Move-Table and access the vector stored there.
3. Set the new board to that vector.
Procedure:
1) Elements of vector:
0: Empty
1: X
2: O
→ the vector is a ternary number
2) Store inside the program a move-table (lookup table):
a) Elements in the table: 19683 (39)
b) Element = A vector which describes the most suitable move from the Data Structure
Comments:
1. A lot of space to store the Move-Table.
2. A lot of work to specify all the entries in the Move-Table.
3. Difficult to extend
7
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
8
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Algorithm:
1. Turn = 1: (X moves)
Go(1) //make a move at the left-top cell
2. Turn = 2: (O moves)
IF board[5] is empty THEN
Go(5)
ELSE
Go(1)
3. Turn = 3: (X moves)
IF board[9] is empty THEN
Go(9)
ELSE
Go(3).
4. Turn = 4: (O moves)
IF Posswin (X) <> 0 THEN
Go (Posswin (X))
//Prevent the opponent to win
ELSE Go (Make2)
5. Turn = 5: (X moves)
IF Posswin(X) <> 0 THEN
Go(Posswin(X))
//Win for X.
ELSE IF Posswin(O) <> THEN
Go(Posswin(O))
//Prevent the opponent to win
ELSE IF board[7] is empty THEN
Go(7)
ELSE Go(3).
Comments:
1. Not efficient in time, as it has to check several conditions before making each move.
2. Easier to understand the program’s strategy.
3. Hard to generalize.
Text
Rani went shopping for a new Coat. She found a red one she really liked.
When she got home, she found that it went perfectly with her favourite dress.
Question
1. What did Rani go shopping for?
2. What did Rani find that she liked?
3. Did Rani buy anything
Method 1
Data Structures
Question Pattens: 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 who did 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.
Algorithm
Answering a question requires the following four steps to be followed:
· Compare the template against the questions and store all successful matches to produce a set of
text patterns.
· Pass each of these text patterns through a substitution process that generates alternative forms of
verbs so that for example, “go” in a question might match “went” in the text. This step generates
a new, an expanded set of text patterns.
• Apply each of these patterns to the text; collect all the answers
• Reply with the set of answers just collected.
Example
In question 1 we use the template WHAT DID X Y which generates Rani go shopping for z and
after substitution we get Rani goes shopping for z and Rani went shopping for z giving z
[equivalence] a new coat
In question 2 we need a very large number of templates and also a scheme to allow the insertion
of ‘find’ between it and the modifying phrase ‘that she liked’;
the insertion of ‘really’ in the text; and the substitution of ‘she’ for ‘Rani’ this question is not
answerable. If all of these variations are accounted for and the questions can be answered then
the response is ‘a red one’.
Question 3 cannot be answered.
Comments
This is a very primitive approach basically not matching the criteria we set for
intelligence and worse than that, used in the game.
10
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Method 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
A structure called English consists of a dictionary, grammar and some semantics about the
vocabulary we are likely to come across.
This data structure provides the knowledge to convert English text into a storable internal form
and also to convert the response back into English. The structured representation of the text is a
processed form and defines the context of the input text by making explicit all references such as
pronouns.
There are three types of such knowledge representation systems: production rules of the form ‘if
x then y’, slot and filler systems and statements in mathematical logic. The system used here will be
the slot and filler system.
Algorithm
· Convert the question to a structured form using English know how, then use a marker to indicate
the substring (like ‘who’ or ‘what’) of the structure, that should be returned as an answer. If a slot
and filler system is used a special marker can be placed in more than one slot.
· The answer appears by matching this structured form against the structured text.
· The structured form is matched against the text and the requested segments of the question are
returned.
Examples
Both questions 1 and 2 generate answers via a new coat and a red coat respectively.
Question 3 cannot be answered, because there is no direct response.
Comments
This approach is more meaningful than the previous one and so is more effective. The extra power
11
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
given must be paid for by additional search time in the knowledge bases.
The problems of handling pronouns are difficult.
For example:
Rani walked up to the salesperson: she asked where the toy department was.
Rani walked up to the salesperson: she asked her if she needed any help.
Whereas in the original text the linkage of ‘she’ to ‘Rani’ is easy, linkage of ‘she’ in each of the
above sentences to Rani and to the salesperson requires additional knowledge about the context
via the people in a shop.
Method 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
this augmented knowledge structure.
Data Structures
World model contains knowledge about objects, actions and situations that are described in the input
text.
This structure is used to create integrated text from input text.
The diagram shows how the system’s knowledge of shopping might be represented and stored. This
information is known as a script and in this case is a shopping script.
Algorithm
Convert the question to a structured form using both the knowledge contained in Method 2 and the
World model, generating even more possible structures, since even more knowledge is being used.
Sometimes filters are introduced to prune the possible answers.
To answer a question, the scheme followed is: Convert the question to a structured form as before
but use the world model to resolve any ambiguities that may occur. The structured form is matched
against the text and the requested segments of the question are returned.
Example
Both questions 1 and 2 generate answers, as in the previous program. Question 3 can now be
answered. The shopping script is instantiated and from the last sentence the path through step 14
is the one used to form the representation. ‘M’ is bound to the red coat-got home. ‘Rani buys a
red coat’ comes from step 10 and the integrated text generates that she bought a red coat.
Comments
This program is more powerful than both the previous programs because it has more knowledge.
Thus, like the last game program it is exploiting AI techniques.
However, we are not yet in a position to handle any English question. The major omission is that of
a general reasoning mechanism known as inference to be used when the required answer is not
explicitly given in the input text.
But this approach can handle, with some modifications, questions of the following form with the
12
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
answer—Saturday morning Rani went shopping. Her brother tried to call her but she did not answer.
Question: Why couldn’t Rani’s brother reach her?
Answer: Because she was not in.
This answer is derived because we have supplied an additional fact that a person cannot be in two
places at once. This patch is not sufficiently general so as to work in all cases and does not provide
the type of solution we are really looking for.
1.3.3 Conclusion
Search: Provides a way of solving problems for which no more direct approach is available as
well as a framework into which any direct techniques that are available can be embedded.
Use of Knowledge: Provides a way of solving complex problems by exploiting the structures of
the objects that are involved.
Abstraction: Provides a way of separating important features and variations from the many
unimportant ones that would otherwise overwhelm any process
The goal of machine is to fool the interrogator into believing that it is the person. If the machine
succeeds, we conclude that the machine can think. The machine is allowed to do whatever it can
do to fool the interrogator.
For example, if asked the question “How much is 12,324 times 73,981?” The machine
could wait several minutes and then respond with wrong answer.
The interrogator receives two sets of responses, but does not know which set comes from
human and which from computer. After careful examination of responses, if interrogator cannot
definitely tell which set has come from the computer and which from human, then the computer
has passed the Turing Test. The more serious issue is the amount of knowledge that a machinewould need
to pass the Turing test.
Problem:
A problem, which can be caused for different reasons, and, if solvable, can usually be
solved in a number of different ways, is defined in a number of different ways.
It is a structured method for solving an unstructured problem. This approach consists of number of
states. The starting of the problem is “Initial State” of the problem. The last point in the
problem is called a “Goal State” or “Final State” of the problem.
State space is a set of legal positions, starting at the initial state, using the set of rules to
move from one state to another and attempting to end up in a goal state.
15
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Chess Problem
Problem of playing chess can be defined as a problem of moving around in a state space where
each state represents a legal position of the chess board.
The game start with an initial state described as an 8x8 of each position contains symbol standing
for the appropriate place in the official chess opening position. A set of rules is used to move from
one state to another and attempting to end up on one of a set of final states which is described as
any board position in which the opponent does not have a legal move as his/her king is under
attacks.
The state space representation is natural for chess. Since each state corresponds to a board position
i.e., artificial well organized.
Production Rules:
These rules are used to move around the state space. They can be described easily as a set of
rules consisting of two parts:
1. Left side serves as a pattern to be matching against the current board position.
2. Right side that serves decides the chess to be made to the board position to reflect themove.
To describe these rules, it is convenient to introduce a notation for pattern and substitutions
16
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
E.g.:
1. White pawn at
square (file e , rank2)
AND
Square (file e , rank3 ) Move pawn from
is empty Square (file e,rank 2)
AND to square(file e,rank 4)
Square (file e ,rank4)
is empty
PROBLEMS
Water-Jug Problem
Problem is “You are given two jugs, a 4-litre one and a 3-litre one. 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 litres of water into 4-litre jug?”
Solution:
The state space for the problem can be described as a set of states, where each staterepresents the
number of gallons in each state. The game start with the initial state described as a set of ordered
pairs of integers:
• 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) i.e., 4-litre and 3-litre jugs is empty initially.
• Goal state: (2, n) for any n that is 4-litre jug has 2 litres of water and 3-litre jug has anyvalue
from 0-3 since it is not specified.
• Attempting to end up in a goal state.
Production Rules: These rules are used as operators to solve the problem. They are represented as
rules whose left sides are used to describe new state that result from approaching the rule.
17
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
18
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
19
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
20
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
21
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Another strategy is, begin generating complete paths, keeping track of the shorter path so far and
neglecting the paths where partial length is greater than the shortest found. This method is better
than the first but it is inadequate.
The Problem is the salesman has a list of cities, each of which he must visit exactly once. There
22
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
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.
Solution:
State Space: The state space for this problem represents states in which the cities traversed by
salesman and state described as salesman starting at any city in the given list of cities. A set of
rules is applied such that the salesman will not traverse a city traversed once. These rules are
resulted to be states with the salesman will complex the round trip and return to his starting
position.
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
HEURISTIC SEARCH
Heuristic Function:
– It is a function applied to a state in a search space to indicate a likelihood of success if that
state is selected
– It is a function that maps from problem state descriptions to measures of desirability usually
represented by numbers – Heuristic function is problem specific.
The purpose of 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 (best promising way).
We can find the TSM problem in less exponential items. On the average Heuristic improve the
quality of the paths that are explored. Following procedure is to solve TRS problem
– Select a Arbitrary City as a starting city
– To select the next city, look at all cities not yet visited, and select one closest tothe
current city
– Repeat steps until all cities have been visited
23
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Heuristic search methods which are the general purpose control strategies for controlling searchis
often known as "weak methods" because of their generality and because they do not apply a great
deal of knowledge.
Some simple Heuristic Function
In order to choose the most appropriate method (or a combination of methods) for a particular
problem, it is necessary to analyze the problem along several key dimensions:
• Is the problem decomposable?
• Can solution steps be ignored or undone?
• Is the universe predictable?
• Is a good solution absolute or relative?
• Is the solution a state or a path?
• What is the role of knowledge?
• Does the task require human-interaction?
• Problem Classification
Is the problem decomposable?
Decomposable problem can be solved easily. Suppose we want to solve the problem of
computing the expression.
We can solve this problem by breaking it down into these smaller problems, each of which we
can then solve by using a small collection of specific rules the following figure shows problem
tree that as it can be exploited by a simple recursive integration program that works as follows.
24
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
At each step it checks to see whether the problem it is working on is immediately solvable.
If so, then the answer is returned directly.
If the problem is not easily solvable, the integrator checks to see whether it can decompose the
problem into smaller problems.
It can create those problems and calls itself recursively on using this technique of problem
decomposition we can often solve very large problem easily.
Now consider the 8-puzzle game. A sample game using the 8-puzzle is shown below:
In attempting to solve the 8 puzzles, 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.
Now consider the problem of playing chess. Suppose a chess playing problem makes a stupid move
and realize a couple of moves later. But here solutions steps cannot be undone.
25
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
The above three problems illustrate difference between three important classes of problems:
1) Ignorable: in which solution steps can be ignored.
Example: Theorem Proving
2) Recoverable: in which solution steps can be undone.
Example: 8-Puzzle
3) Irrecoverable: in which solution steps cannot be undone.
Example: Chess
The recoverability of a problem plays an important role in determining the complexity of the
control structure necessary for problem solution.
Ignorable problems can be solved using a simple control structure that never backtracks.
Recoverable problems can be solved by slightly complicated control strategy that does sometimes
make mistakes using backtracking. Irrecoverable problems can be solved by recoverable style
methods via planning that expands a great deal of effort making each decision since the decision is
final.
In the uncertain problems, this planning process may not be possible. Example: Bridge Game –
Playing Bridge. We cannot know exactly where all the cards are or what the other players will do
on their turns.
We can do fairly well since we have available accurate estimates of a probabilities of each of
the possible outcomes. A few examples of such problems are
➢ Controlling a robot arm: The outcome is uncertain for a variety of reasons. Someone might
move something into the path of the arm. The gears of the arm might stick.
➢ Helping a lawyer decide how to defend his client against a murder charge. Here we
probably cannot even list all the possible outcomes, which leads outcome to be uncertain.
26
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
❑ 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.
27
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Since we are interested in the answer to the question, it does not matter which path we follow. Ifwe
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”.
Now consider the Travelling Salesman Problem. Our goal is to find the shortest path route that
visits each city exactly once.
Suppose we find a path it may not be a solution to the problem. We also try all other paths. The
shortest path (best path) is called as a solution to the problem. These types of problems are
known as “Best path” problems. But path problems are computationally harder than any path
problems.
28
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
So the solution of natural language understanding problem is a state of the world. And the solution
of “Water jug” problem is a path to a state.
The above two problems illustrate the difference between the problems for which a lot of
knowledge is important only to constrain the search for a solution and those for which a lot of
knowledge is required even to be able to recognize a solution
29
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Problem Classification
When actual problems are examined from the point of view all of these questions it becomes
apparent that there are several broad classes into which the problem fall. The classes can be each
associated with a generic control strategy that is approached for solving the problem. There is a
variety of problem-solving methods, but there is no one single way of solving all problems. Not
all new problems should be considered as totally new. Solutions of similarproblems can be
exploited.
30
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Problems:
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.
Solution:
State Space: The state space for the problem can be written as a set of states where each stateis
position of the tiles on the tray.
Initial State: Square tray having 3x3 cells and 8 tiles number on it that are shuffled
2 8 3
1 6 4
7 5
Goal State
1 2 3
8 4
7 6 5
Production Rules: These rules are used to move from initial state to goal state. These are also
defined as two parts left side pattern should match with current position and left side will be
resulting position after applying the rule.
31
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Solution:
32
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Solution:
State Space: The state space for this problem represents states in which the cities traversed by
salesman and state described as salesman starting at any city in the given list of cities. A set of
rules is applied such that the salesman will not traverse a city traversed once. These rules are
resulted to be states with the salesman will complex the round trip and return to his starting
position.
Initial State
➢ Salesman starting at any arbitrary city in the given list of citiesGoal
State
➢ Visiting all cities once and only and reaching his starting state
Production rules:
These rules are used as operators to move from one state to another. Since there is a path between
any pair of cities in the city list, we write the production rules for this problem as
• Visited(city[i]) AND Not Visited(city[j])
– Traverse(city[i],city[j])
• Visited(city[i],city[j]) AND Not Visited(city[k])
– Traverse(city[j],city[k])
• Visited(city[j],city[i]) AND Not Visited(city[k])
– Traverse(city[i],city[k])
• Visited(city[i],city[j],city[k]) AND Not Visited(Nil)
– Traverse(city[k],city[i])
33
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Initial State:
➢ Full(T1) | Empty(T2)
Empty(T3)
Goal State:
➢ Empty(T1) | Full(T2) | Empty(T3)
Production Rules:
These are rules used to reach the Goal State. These rules use the following operations:
▪ POP(x) Remove top element x from the stack and update top
▪ PUSH(x,y) Push an element x into the stack and update top. [Push an element x on tothe y]
Now to solve the problem the production rules can be described as follows:
1. Top(T1)<Top(T2) PUSH(POP(T1),T2)
2. Top(T2)<Top(T1) PUSH(POP(T2),T1)
3. Top(T1)<Top(T3) PUSH(POP(T1),T3)
4. Top(T3)<Top(T1) PUSH(POP(T3),T1)
5. Top(T2)<Top(T3) PUSH(POP(T2),T3)
6. Top(T3)<Top(T2) PUSH(POP(T3),T2)
7. Empty(T1) PUSH(POP(T2),T1)
8. Empty(T1) PUSH(POP(T3),T1)
9. Empty(T2) PUSH(POP(T1),T3)
10. Empty(T3) PUSH(POP(T1),T3)
11. Empty(T2) PUSH(POP(T3),T2)
12. Empty(T3) PUSH(POP(T2),T3)
Solution: Example: 3 Disks, 3 Towers
1) T1 T2
2) T1 T3
3) T2 T3
4) T1 T2
5) T3 T1
6) T3 T2
7) T1 T2
Monkey and Bananas Problem
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,
34
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
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?
Solution: The state space for this problem is a set of states representing the position of the monkey,
position of chair, position of the stick and two flags whether monkey on the chair & whether
monkey holds the stick so there is a 5-tuple representation.
(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
7) (C,C,C,0,1) (C,C,C,1,1) {monkey and stick at the chair position, monkey on the
8) (S,C,S,0,1) (C,C,C,0,1)
35
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
Solution:
1) (M,C,S,0,0)
2) (C,C,S,0,0)
3) (G,G,S,0,0)
4) (S,G,S,0,0)
5) (G,G,G,0,0)
6) (G,G,G,0,1)
7) (G,G,G,1,1)
Solution:
The state space for the problem contains a set of states which represent the present number of
cannibals and missionaries on the either side of the bank of the river. (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)
Production System: These are the operations used to move from one state to other state. Since at
any bank the number of cannibals must less than or equal to missionaries we can write two
production rules for this problem as follows:
• (C,M,C1,M1,L / C=3, M=3) (C-2,M,C1+2,M1,R)
• (C,M,C1,M1,L / C=3, M=3) (C-1,M-1,C1+1,M1+1,R)
• (C,M,C1,M1,L / C=3, M=3) (C-1,M,C1+1,M1,R)
• (C,M,C1,M1,R / C=1, M=3) (C+1,M,C1-1,M1,L)
• (C,M,C1,M1,R / C=0, M=3,C1=3,M1=0) (C+1,M,C1-1,M1,L)
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
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 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.
Monotonic Non-monotonic
Chemical
Not Partially commutative Bridge
Synthesis
38
Dept of CSE, Vemana IT
Artificial Intelligence and Machine Learning (18CS71) Module 1
❑ 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.
❑ 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.
39
Dept of CSE, Vemana IT
FREQUENTLY ASKED QUESTIONS
1) Define Intelligence, Artificial Intelligence.
2) List four things to build a system to solve a problem.
3) What is Production System?
4) Explain water Jug problem as a state space search.
5) Explain production system characteristics.
6) Explain A* algorithm with example.
7) What is Means-Ends Analysis? Explain with an example.
8) What do you mean by heuristic?
9) Write a heuristic function for travelling salesman problem.
10) What is heuristic search?
11) Explain problem characteristics.
12) Write AO* algorithm and explain the steps in it.
13) What is constraint satisfaction problem? Explain it.
14) Explain annealing schedule.
15) Explain Breadth-first search and depth-first search. List down the
advantages anddisadvantages of both?
16) What do you mean by an AI technique?
17) Discuss the tic-tac-toe problem in detail and explain how it can be solved
using AItechniques.
18) What are the advantages of Heuristic Search?
19) Explain Turing Test as Criteria for success.
20) Explain Hill Climbing and give its disadvantages.
21) Define Control Strategy and requirements for good search strategy.
22) Define State Space Search. Write algorithm for state space.