Unit-1 AI Problem Solving
Unit-1 AI Problem Solving
Sp
duliuis
2.1 INTRODUCTION
: the science
that ArtificialIntelligenceis
Inthe last chapter, we have triedto explain intelligent. The ultimate aim of
and technology applied to make machines match the intelligence
to
researchers is to develop universal intelligent system has been made and!
capabilities of human beings. In this regard, lot of progress
achieved. although, universal intelligent
considerable amount of success has been AIina limited
have developed techniques to use
system is still adream. Scientists developed many Al systems, which work ina
have successfully
domain and
domain and show expertise not only matching those of human
problem specific many ways and in many
applications. It should
experts, but also exceeding those in the most important application
ofAI is to
mind that for the time being, otherwise take
be kept in solvereal world problems, which
develop intelligent systems to human efforts, and hence, become uneconomical
considerable amount of time and major area of
as inefficient at times. Hence, problem solving becomes solving
as well
involves methods and various techniques used in problem
study, which
using AI. methods of solving real world problem3
we will discuss the
In this chapter, In realI world, there are different types
Artificial Intelligence(AI)techniques.
various characteristics of problems and their
using A We will try to explain
of problems.
solution methodologies. through AI invo!ves the process of defining
method of solving problem goal states and
The start and then finding the path from
searçh space, deciding search space. The movement from start state to
the through
start state to
goal state specifically designedIfor that
particular problem
guidedby settofrules
state is production rules). The production rules are nothing but valid
goal called
(sometimes problems.
Letdescribed bythesometermsrelatedIwith Al problem solution mnethodology:
usfirst discuss
moves
question which is to be
It is the to precisely
problemitneeds bestart
solved. For solving
Aroblem defining,the state, defined.
goal
The definition
means,
states andtransitions. state, other valid
Problem Solving Through AI 29
22REPRESENTATION OF AI PROBLEMS
Innhis scction, we would learn the techrnical aspects of problem representation
reaured fromcomputational perspcctive. From thisorientation, the representation
ofAl problems can be covercd in following föur parts: od VaLa sulay
1lexical part: that determineswhich symbols are allowd in the lexicon,
Teprescntations of the problem. Like the normal meaning of the
this part abstracts all fundamental fcatures of the [Link] can be
how the,
2 4 structural part: that describesconstraints on joining
arranged. This corresponds to finding out possibilities required for
these symbols and generating higher structural unit.
procedural part: that specifies acccss procedures that enable to create
A
descriptions, to modify them, and to answer questions using [Link] the
4A senantic part: that establishes a way of associating meaning
descriptions.
below:
Letus understand these steps by an cxample presented
define the problem, we
We arc given the problem of "playing chess". Torules that define the legal
the
shöuld spccify the starting position of chess board,
a win for one side or the others.
moves arnd the board positions that represent
Here, the:
which may be an 8 x 8 array
US Lexical part contains the board position, appropriate chess piece
where cach position contains a symbol indicating an
goal is any board position in
in the ofilicial chess opcning position. The
move and his king in under attack.
Which opPponent does not have a legal
moves. The legal moves provide the
2 The structural part describes the legal
goal state. They are described as
Way of getting from an initial state to a
that serves as a pattern to be
set of nules consisting of a left hand side
and a right hand side that
matched against the current board position
the move.
describes changes to be made to board position to reflcct
applying appropriate rule for
Ihe procedural part will be methods for winning moves
Winning the [Link] include representing the "set of
32 Artificial Intelligence
of standard chess playing. Out of all legal moves, only those moves, whio
bring the board position to a winning position of respective playerad
captured and stored in proccdural part.
However, in chess the total 'legal moves' are of the order of 10
Such a large number of moves are difficult to be written, so only 'usef:
moves' are written. should be noted that there is a difference betwee
legal moves and useful moves. The legal moves are all those moves whic
are permissible according to game rules and useful moves will be those
legal moves which bring the game in a winning position. Hence the usefi
moves' will be a subset of legal moves'. The state space is total vald
states possible in a problem and finding a problem solution is "starting a
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."
4. The semantic part is not required in "chess game" because, there is no
hidden meaning associated vwith any piece and all the move meanings are
explicit. However in natural language processing type of applications,where
there is meaning" .associated with words and "complete message
associated with sentence, the semantic part captures and stores, the meaning
of words and message conveyed by sentence.
Thus, in AI, to design a program for solution, the first step is the creation ofa
formal and manipulable description of problem itself. This includes performing
following activities:
A. Define a state space that contains all the possible configurations of the
relevant objects.
2. Specify one or more states within that space, which describe possible
situations from which problem solving process may start. These are called
initial states.
Specify one or more states that would be acceptable as solutions to the
problem. These are called goal states.
4. Specify a set of rules that describes the action (operators) available
PRODUCTION SYSTEM
Lo fhe above section, we have discussed basic aspects of Alproblem solution A
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 systemis usedfor application of rules and obtaining the solution.
of following componentg:
Aproductionsystem consists
rules, which are of the form
1. ofAset of production
a left hand side constituentthat P’Q.
represents the current Each rule state and
problem consists
aright hand side that represents a result or generated output state. Arule is
side matches with the current
applicable if its left hand
the left side of the rule determines the applicability problem state,andThus,
of the ule the
output, if rule is applied. It is
describes the
ight sidethat important to note
Problem Solving Through A1 33
therc may be nultiple constitucnts on the left hand side of arule (i.e.
hat2....P). In this situation, all constituents of lcft hand side should
be satisficdfor applying
the rule. After applying the rule, the left hand side
nule becomes the current state.
o the
Qne or more knowledge/data bases, that contain all the appropriate
sformation for the particular task. Some parts of the database may be
pemancnt while some part of this may pertain only to the solution of
structured in
Cuent problem. The information in these databases, may be
an appropriate way.
2control strategythat specifies order in whjh the rules will be compared
the database of rules and a way of -résolving the conflicts that arise
when several rules match simultaneously.
current
Aruleapplier, which checks the applicability of rule by matching the
rule from
state with the left hand side of the rule and finds the appropriate
the database of rules.
A51 Tic-Tac-Toe
Tic-Tac-Toe is a game involving two players. It is played by putting 'X' or 'O
alternately by two players, in any oneof the 9 board positions shown as follows
Playing means making the mark of X' or "0° in any one square. The player who
is able to make his marks in horizontal, vertical, or diagonal straight line first, is
declared [Link].
From AI viewpoint, the problem of playing Tic-Tac-Toe will be formulated as
follows:
The start state is all blank squares out of 9 squares. Player I can play in any
one square. As the game proceeds, blank squares remain the choice,which can
marked by the players. The data structure used to represent the board is a 9-elema
vector, with element positions shown in Fig 2.1:
2 3
4 5 6
7 8 9
X X X X
6 X
4 X
Any board position satisfying this condition would be declared as win for
coesponding player. The valid transitions of this problem are simply putting 1
or2 in any of the element position containing 0.
In practice, all the valid moves are defined and stored. While selecting amove
itistaken from this store: In this game, valid transition table will be a vector
(haying 3° entries), having 9 elements in each.
252_Water-Jug Problem
This problem is defined as:
"We are given two water jugs' having no measuring marks on these.
The capacities of jugs are 3 liter and 4 liter: It is required to fill the
bigger jug with exactly 2 liter of water The water can be filled in
a jug from a tap".
In this problem, the start state is that both jugs are empty and the final staté is
tiat 4-liter jug has exactly 2 liters of water. The productionrules involve filing a
Ug with some amount of water, filing the water from one jug to other or emptying
lie jug. The search will be finding the sequence ofpróduction rules which transform
lie initial state to final state.
Part of search tree of water jug problem is shown in Fig. 2.3.
38 Artificial Intelligence
0,0
4,0 0,3
0,3 1,0
Fig 2.3: Partial search tree of water jug problem
ordered pairs of
The state space for this problem can be described by set of
the 4-liter jug, andy
twovariables (x, y) where, variable x represents the water in
value 0, 1, 2, 3,4
represents the water in the 3-liter jug. Variable x can take the
and the goal
and variable y can take the value 0, 1, 2, 3. The start state is (0, 0)
follows:
state is (2, 0). The production rules are formulated as
2538-Puzzle Problem
The&-puzzle problem belongs to the category of"sliding-block puzzle" types of
problems. It is described as follows:
It has set of a 3x3 board having 9 block spaces out of which, 8
blocks are having tiles bearing number from I to 8. One space is
left blank. The tile ádjacent to blank space can move into it. We
have to arrange the tiles in asequence.
The start state is any situation of tiles, and goal state is tiles arranged in
specifi sequence. Solution of this problem isreporting of "moveiment of tiles"" in
order to reach the goal state. The transition function or legal move is any one tile
movement by one space in any direction (i.e. towards left or right or up or down)
ifthat space is blank. It is shown in following Fig: 2.4:
1 4 2 3
6 5 4 5 6
2 3 7 7 8
6 5 8
2 3 7
1 1 5 4 4
6 5 8 6 6 5
2 7 3 7 2 3 7
6 4 4 ’ Cycle.
5 6 5 8
2 3 7 2 3 7
2.5!4'8-Queens Problem
This problem is presented as follows:
"We have 8 queens and a 8'x 8chessboard having alternate black
and white squares. The queens are placed on the chessboard. Any
queen can attack any another queen pldçed on same rowy, or column.
of diagonal. We have tofind the proper placement of queens on the
chessboard in such a way that no queen attacks other queen",
The 8-queen problem is shown in following diagram:
Problem Solving Through A1 41
7||t||
6
a b d
White
C 9 h
Flg 2.7: Start state of chess game
42 Artificial Intelligenece
"Thnee missionaries and three connibals are present at one side of
available.
ariver and need to crOSs the river: Ther is only one boat
not outnumber
Atany' point of time, the mmber of cannibals should
known that only
the mumber of missionaries at that bank. It is also
nvopersONS can ocCupy the boat available at a time.
from one
The objective of the solution is to find the scquence of their transter
these
bank of river to other using the boat sailing through the river satisfying
constraints.
We can fom various production rules as presented in water-jug problem. Le
Missionary is denoted by 'M' and Cannibal, by '[Link] rules are described
below:
bank-2
Rule I: (0, M) One missionary sailing the boat from bank-1 to
Rule 2: (M, 0) On missionary sailing the boat from bank-2 to bank-l
Rule 3: (M, M) Two missionaries sailing the boat from bank-1 to bank-2
Rule 4: (M, M) Two missionaries sailing the boat from bank-2 to bank-1
Rule 5: (M, C) One missionary and one Cannibalsailing the boat from
bank-l to bank-2
Rule 6: (C, M) One missionary, and one Cannibal sailing the boat from
bank-2 to bank-1.
Rule 7: (C, C) TwoCannibals sailing the boat from bank-1 to bank-2
Rule 8: (C, C) Two Cannibals sailing the boat from bank-2 to bank-1
Rule 9: (0, C) One Cannibal sailing the boat fom bank-1to bank-2
Rule 10: (C,0) One Cannibal sailing the boat from bank-2 to bank-1
All or some of these production rules will have to be used in a particular
sequence to find the solution of the problem. The rules applied and their sequence
ispresented in the following Table 2.2.
Table 2.2: Rules applied and their sequence in Missionaries and Cannibals problem
After application persons in the persons in the boat position
of rule river bank-1 river bank-2