Module 1 AI
Module 1 AI
Module 1 AI
Artificial Intelligent
Module 1
By- Chandan Sharma
A2305219668 , 6CSE11Y
ASET, Amity University, Noida
Amity School of Engineering & Technology
Introduction
According to John McCarthy, who is known as the
father of AI,
“AI is the science and engineering of making
intelligent machines, especially computer programs.”
Artificial Intelligence
History
• Up-to early 80’s: Creation of expert systems
(systems specialized for one particular task
based on experts’ knowledge), wide industry
adoption
Modern AI
• Towards more scientific, formal/mathematical
• Divided into many subareas interested in
particular aspects
• More directly connected to theoretical
computer science, statistics, operations
research, biology, economics, psychology,
neuroscience etc
Amity School of Engineering & Technology
What is AI
• Artificial Intelligence is concerned with the design of
intelligence in an artificial device. The term was coined by
McCarthy in 1956.
• There are two ideas in the definition.
1. Intelligence
2. Artificial device
• What is intelligence?
• Is it that which characterize humans? Or is there an
absolute standard of judgement? – Accordingly there are
two possibilities:
• A system with intelligence is expected to behave as
intelligently as a human .
• A system with intelligence is expected to behave in the
best possible manner
Amity School of Engineering & Technology
What is Intelligence?
• Intelligence is a property of mind
that encompasses many related
mental abilities, such as the
capabilities to
• reason
• plan
• solve problems
• think abstractly
• comprehend ideas and language
and learn
Amity School of Engineering & Technology
Concept of AI
• Artificial Intelligence is the study of how to make
computers do things which, at the moment, people do
better”
• This definition is of course somewhat ephemeral because
of its reference to the current state of computer science.
And it fails to include some areas of potentially large
impact, namely problems that cannot now be solved well
by either computers or people. But it provides a good
outline of what constitutes artificial intelligence and it
avoids the philosophical issues that determines attempts
to define the meaning of either artificial or intelligence.
• “Also we can say AI is the study of techniques for
solving the exponentially hard problem in polynomial
time by exploiting knowledge about the problem
domain”.
Amity School of Engineering & Technology
Amity School of Engineering & Technology
AI Techniques
There are three important AI Techniques. They are:
AI Techniques Cont..
AI technique is a method that exploits knowledge that should be
represented in following manner.
• The knowledge captures generalizations.
That is : it is not necessary to represent separately each individual
situation. Instead situation, that share important role or properties are
grouped together. If knowledge does not have this property, inordinate
amount of memory and updating will be required.
• It can be understood by people who must provide it.
• It can easily be modified to correct errors and to reflect changes in the
world and our world view.
• It can be used in a great many situations even if it is not totally accurate.
Amity School of Engineering & Technology
• To exploit that knowledge we can gain from people. Since people are the
best known performance of most of the tasks with which we are dealing,
it makes a lot of sense to look to them for clues as to how to produce.
Amity School of Engineering & Technology
Human
Human ?
Interrogator
AI system
Amity School of Engineering & Technology
Game playing
• Game playing share the property that people who do them well are considered to be displaying
intelligence. Despite this, it appeared initially that computers could perform well act those tasks
simply by being fast at exploring a large number of solution paths and selecting the best one and if
we apply this rule to day to day life then we can understand that, it is basic rule of problem solving.
• Almost in every case for every problem in a particular situation we may have various possible
solutions but if we want to solve the problem correctly then we have to choose a right path then
only we can overcome the problem.
• Same strategy we adopt in game playing, if we want to be a winner then we have to select right
option among the various possible options.
• By adopting this approach we can design best possible game (AI based). But it may not be winner
all
• We can understand it by following examples: Tic- Tac- Toe
Amity School of Engineering & Technology
Theorem proving
• Theorem proving has the property that people who do them well are considered to
be displaying intelligence.
• The Logic Theorist was an early attempt to prove mathematical theorems.
• There are three types of problems in A.I.
• Ignorable problems, in which solution steps can be ignored
• Recoverable problems in which solution steps can be undone
• Irrecoverable in which solution steps cannot be undone.
• Theorem proving falls into the first category i.e. it is ignorable suppose we are
trying to solve a theorem, we proceed by first proving a lemma that we think will
be useful. Eventually we realize that the lemma is not help at all. In this case we
can simply ignore that lemma, and can start from beginning.
Amity School of Engineering & Technology
Future of NLP
• Human level or human readable natural language processing is an AI-complete problem .
• It is equivalent to solving the central artificial intelligence problem and making computers
as intelligent as people
• Make computers as they can solve problems like humans and think like humans as well as
perform activities that humans cant perform and making it more efficient than humans
• NLP's future is closely linked to the growth of Artificial intelligence
• As natural language understanding or readability improves, computers or machines or
devices will be able to learn from the information online and apply what they learned in the
real world
• Combined with natural language generation, computers will become more and more
capable of receiving and giving useful and resourceful information or data
Amity School of Engineering & Technology
NLP Applications
Applications
• Machine Translation
• Information Retrieval
• Question Answering
• Dialogue Systems
• Information Extraction
• Summarization
• Sentiment Analysis
Amity School of Engineering & Technology
Computer Vision
Image processing to computer vision progression
can be broken up into low-, mid- and high-level
processes
What is Robotics
• Robotics is a branch of AI, which is
composed of Electrical Engineering,
Mechanical Engineering, and Computer
Science for designing, construction, and
application of robots.
• Robots are the artificial agents acting in
real world environment
• Robots are aimed at manipulating the
objects by perceiving, picking, moving,
modifying the physical properties of
object, destroying it, or to have an effect
thereby freeing manpower from doing
repetitive functions without getting bored,
distracted, or exhausted.
Amity School of Engineering & Technology
Aspects of Robotics
• The robots have mechanical
construction, form, or shape
designed to accomplish a
particular task.
• They have electrical
components which power and
control the machinery.
• They contain some level
of computer program that
determines what, when and how a
robot does something.
Amity School of Engineering & Technology
Expert System(Cont..)
• An expert system is a system that
employs human knowledge
captured in a computer to solve
problems that ordinarily require
human expertise.(Turban)
• A computer program that emulates
the behaviour of human experts
who are solving real-world
problems associated with a
particular domain of knowledge.
(Pigford & Braur)
Amity School of Engineering & Technology
Expert System(Cont..)
Amity School of Engineering & Technology
Production Systems
Production system provide the structure for solving the AI problem. It
consist of :
• A set of rules each consisting of a left side determines the applicability
and right side that describes the operation to be performed.
• One or more knowledge/ database that convert whatever information is
appropriate for the particular task.
• A control strategy that specify the order in which the rules will be
compared to the database and a way of resolving the conflicts that arise
when several rules match at once.
• A rule applier
Amity School of Engineering & Technology
Control Strategies
Control Strategy deal with how to decide which rule to apply next during the
process of searching for a solution to a problem because it may happen more
than one rule will have its left side match the current state.
• The first requirement of a good control strategy is that because motion will
never lead to a solution.
• The second requirement of a good control strategy is that it be semantic. If its
not semantic we may explore a particular useless sequence of operators several
times before we finally find a solution. The requirement that a control strategy
be semantic corresponds to the need for global motion as well as for local
motion.
Amity School of Engineering & Technology
Assumptions
• We have assumed that we can fill a
jug from the pump and we can pour
water out of a jug onto the ground.
There are no measuring device:
• Sample Solution:
Amity School of Engineering & Technology
B: Boat
T: Tiger
G: Goat
Gr: Grass
Amity School of Engineering & Technology
Problem Decomposable
Amity School of Engineering & Technology
Block World Problem
Amity School of Engineering & Technology
Block World Problem(cont..)
• Soln. There are some actions given. According to that the robot arm that can manipulate
the blocks.
• UNSTACK (A, B): Pick block A from its current position on Block B. The arm must be empty and
block A must have no blocks on top of it.
• STACK (A, B): Place block A on block B. The arm must already be holding A and the surface
of B must be clear.
• PICK UP(A): Pickup block A from the table and hold it. The arm must be empty and therefore
must be nothing on top of block A.
• PUT DOWN (A): Put block A down on the table. The arm must have been holding block A.
• ON (A, B): block A is on block B.
• ON TABLE (A): block A is on the table.
• CLEAR(A): There is nothing on the top of block A
• HOLDING(A): The arm is holding block A.
• ARM EMPTY: The arm is holding nothing.
Amity School of Engineering & Technology
Solve Following
Amity School of Engineering & Technology
Problem 2 soln:
Amity School of Engineering & Technology
• Informed Search
• Informed search algorithms use domain knowledge. In an informed search, problem information is available which can guide the
search. Informed search strategies can find a solution more efficiently than an uninformed search strategy. Informed search is
also called a Heuristic search.
• A heuristic is a way which might not always be guaranteed for best solutions but guaranteed to find a good solution in reasonable
time.
• Informed search can solve much complex problem which could not be solved in another way.
• An example of informed search algorithms is a traveling salesman problem.
Amity School of Engineering & Technology
Heuristic Search
• Breadth-first search
Expand all the nodes of
one level first.
• Depth-first search
Expand one of the nodes at
the deepest level.
Amity School of Engineering and Technology
Amity School of Engineering & Technology
Time Complexity :
1 + b + b2 + b3 +…+……bd.
Hence Time complexity =O (bd)
Where b-> branching factor
d-> Depth of a tree
Space Complexity :
Hence Space complexity = O (d)
Amity School of Engineering and Technology
Amity School of Engineering & Technology
• Determination of the depth until which the search has to proceed. This
depth is called cut-off depth.
• If the cut-off depth is smaller, solution may not be found.
• If cut-off depth is large, time complexity will be more.
• And there is no guarantee to find a minimal solution, if more than one
solution exists.
Amity School of Engineering and Technology
Amity School of Engineering & Technology
Time Complexity :
1 + b + b2 + b3 +…+……bd.
Hence Time complexity = O (bd)
Space Complexity :
1 + b + b2 + b3 +…+……bd.
Hence Space complexity = O (bd)
Amity School of Engineering and Technology
Amity School of Engineering & Technology
• 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.
DFS Vs BFS
DFS BFS
It require less memory because only the It require more memory because all the tree
nodes on the current path are stored. that has so far been generated must be
stored.
It is one in which by luck solution can be While in BFS all parts of the tree must be
found without examining much of the examined to level n before any nodes on
search space at all. level n+1 can be examined.
It does not give optimal solution. It gives optimal solution.
DFS may find a long path to a solution in BFS guarantees to find a solution if it
one part of the tree, when a shorter path exists. Furthermore if there are multiple
exists in some other, unexplored part of the solutions, then a minimal solution will be
tree. found.
Time complexity: O(bd ) Time complexity: O(bd )
where b : branching factor, d: depth where b : branching factor, d: depth
Space complexity: O(d) , d: depth Space complexity: O(bd )
where b : branching factor, d: depth
Amity School of Engineering & Technology
Search Process
• Uniformed search is a searching technique which have no additional
information about the distance from current state to the goal.
• Informed Search is a another technique which have additional
information about the estimate distance from the current state to the goal.
• Difference between uniformed search and informed search are given :
• Uniformed search technique have access only to the problem definition
whereas Informed search technique have access to heuristic function as
well as problem definition.
Amity School of Engineering & Technology
Search Process(Cont..)
Heuristic Function
A Heuristic (or a heuristic function) takes a look at search algorithms. At each
branching step, it evaluates the available information and makes a decision on which
branch to follow.
It does so by ranking alternatives. The Heuristic is any device that is often effective but
will not guarantee work in every case.
So why do we need heuristics?
• One reason is to produce, in a reasonable amount of time, a solution that is good
enough for the problem in question. It doesn’t have to be the best- an approximate
solution will do since this is fast enough.
• Most problems are exponential. Heuristic Search let us reduce this to a rather
polynomial number. We use this in AI because we can put it to use in situations where
we can’t find known algorithms
Amity School of Engineering & Technology
SOLN:
Amity School of Engineering & Technology
Amity School of Engineering & Technology
SOLN:
Amity School of Engineering & Technology
Algorithms
The Key difference is that the use of evaluating function and the task specific knowledge into the control
process .
This algorithm also called as discrete optimization algorithm.
• Utilizes simple heuristic function.
• Hill Climbing = Depth First Search + Heuristic Function
• These is practically no difference between hill climbing and depth-first
search except that the children of the node that has been expanded are
sorted by the remaining distance.
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
1. OR-GRAPHS:-
• This algorithm will operate by searching a directed graph in which each node
represents a point in the problem space. Each node will contain to a description
of the problem state it represents and how promising node it is. The list of
successor will make it possible if a better node or path found to an existing
node then to propagate the improvement down to its successor. Hence this type
of graph called OR - graph. Since each of its branches represent an alternative
problem-solving path.
• In each step of the best first search process we select the most promising node
with the help appropriate heuristic function to each of them. After that we
expand the chosen node rules to generate its successor. If one of them is
solution then we quit otherwise again the most promising node if selecting and
process continues. This search can return to it whenever all other gets bad i.e.
the again most promising path.
Amity School of Engineering & Technology
OR-GRAPHS(cont..)
Amity School of Engineering & Technology
OR-GRAPHS(cont..)
• As shown above fig beginning of best first procedure there is one node we expand it . We
generate three nodes. The heuristic function, which is an estimate of the cost of getting to
solution from a given node, is applied to each of these new nodes. Since node D is most
promising node we expand it producing two-successor node E and F. But at this stage we
look another, which is going through B, is more promising. Hence we expand it and
generate G and H. But again when these two nodes are evaluated they look less promising
than other path. So the attention is returned to the path D and E and E is then expand
producing J and I. At next stage J is expanded since it is more promising. This process can
continue until a solution is found.
To implement such graph –search procedure we need two lists of nodes.
• OPEN: Open is actually a priority queue in which the elements with highest –priority are those with most
promising value of the heuristic function. Hence the nodes that has been generated and have heuristic function but
it is not examined.
• CLOSE: In this list we keep the node that already examined. We keep these nodes in memory because whenever a
new node is generated we need to check whether it has been generated before.
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
THE A* ALGORITHM
THE A* ALGORITHM
A* algorithm was given by Hart, Nilsson and Rafael in 1968.
• A* is a Best First Search algorithm with f(n) = 𝒈 𝒏 + 𝒉 (𝒏)
where𝑔(𝑛)= sum of edge costs from start to 𝑛.h(𝑛) = estimate of lowest cost
path from 𝑛 to goal. 𝑓(𝑛)= actual distance so far + estimated distance remaining.
• A* is Optimal and Admissible both.
Role of g function: This lets us choose which node toexpand next on the basis
of not only of how good the node
itself looks, but also on the basis of how good the path tothe node was.
h’: the distance of a node to the goal. If h’ is a perfectestimator of h, then A*
will converge immediately to the goal with no search.
Amity School of Engineering & Technology
THE A* ALGORITHM(cont..)
1. Start with OPEN containing only the initial node. Set the nodes g value to zero
then it h’ value to whatever it is and its f’ value to f=g+h’ 0+h=h’. Set closed
to empty list.
2. Until a goal node is found repeat the following procedure.
• If there are no node in OPEN report failure otherwise pick the node on OPEN
with lowest f’ value and call is BESTNODE.
• Remove it from OPEN and place on CLOSED and see if BESTNODE is a goal
state then exit otherwise generate the successor of BESTNODE.
• For each SUCCESSOR do the following
Amity School of Engineering & Technology
THE A* ALGORITHM(cont..)
• Set SUCCESSOR to point back to BESTNODE. These backwards links will make it possible to recover
the path once a solution is found.
• Compute g’ (SUCCESSOR) = g(BESTNODE) + the cost of getting from BESTNODE to SUCCESSOR.
• See if SUCCESSOR is the same as any node on OPEN then call node OLD because this node already
exists.
• We can throw SUCCESSOR away and add OLD to the list of BESTNODE’ s SUCCESSOR. At this
point we must decide whether OLD’ s parent link reset to the point of BESTNODE.
• We have just found SUCCESSOR is cheaper than the current best path to OLD.
• Hence we see whether it is cheaper to get to OLD via its current parent or to SUCCESSOR via
BESTNODE by comparing their g values. If OLD is cheaper then we do nothing.
• If SUCCESSOR is cheaper then reset OLD’ s parent link to point to BESTNODE record the new cheaper
path in g(OLD) and update f ‘(OLD).
Amity School of Engineering & Technology
THE A* ALGORITHM(cont..)
• If the SUCCESSOR was not an OPEN see if it is CLOSED, if so called node on CLOSED
OLD and add OLD to the list of BESTNODE’ s successor.
• At that time check to see if the new path or old path is better then set the parent link and g
and f’ values appropriately. If we have just found a better path to OLD we propagate the
improvement to OLD successor.
• TO propagate the new cost downward changing the each node g and f’ value and
terminating each branch when you reach either a node with no successor or a node to which
an equivalent or better path was already been found.
• If the successor was not already on either OPEN or CLOSED then put it on OPEN and add
it to the list of BESTNODES successor and compute
• F’ (SUCCESSOR)=g(SUCCESSOR)+h’(SUCCESSOR)
Amity School of Engineering & Technology
THE A* ALGORITHM(cont..)
Advantage of A* Algorithm:
• A* is both complete and admissible. Thus A* always finds
an optimal path, if one exists.
* Best serach algorithms.
* Solve complex problem easily.
Disadvantage of A* Algorithm:
• It is costly if the computation cost is high.
* does not always provide shortest path.
* Complexity issue.
* Requires memory
Amity School of Engineering & Technology
Amity School of Engineering & Technology
SOLN:
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
A* Example:
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Concept:
Branch and Bound: Step 1: Traverse the root node.
Step 2: Traverse any neighbour of the root node that is
maintaining least distance from the root node.
Step 3: Traverse any neighbour of the neighbour of the
root node that is maintaining least distance from the
root node.
Step 4: This process will continue until we are getting
the goal node.
Branch and Bound is an algorithmic technique which
finds the optimal solution by keeping the best solution
found so far. If partial solution can’t improve on the
best it is abandoned, by this method the number of
nodes which are explored can also be reduced. It also
deals with the optimization problems over a search
that can be presented as the leaves of the search tree.
The usual technique for eliminating the sub trees
from the search tree is called pruning. For Branch and
Bound algorithm we will use stack data structure.
Amity School of Engineering & Technology
PROBLEM REDUCTION :-
• Sometimes problems only seem hard to solve. A hard problem may be one
that can be reduced to a number of simple problems...and, when each of the
simple problems is solved, then the hard problem has been solved.
• Problem reduction may be defined as planning how best to solve a problem
that can be recursively decomposed into subproblems in multiple ways.
• 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 or AND - OR trees are used for representing the
solution.
Amity School of Engineering & Technology
1. AND- OR GRAPH
• AND-OR is useful for representing the solution of the problems that can be solved by
decomposing them into a set of smaller problems after that all of them solved.
• This decomposition or reduction generates arc that we call AND arcs.
• One AND arc may point to any number of successor nodes all of which must be
solved in order for the arc to point to a solution just as in OR graph.
• Hence different arc may come from single node indicating variety of ways in which
the original problem might be solved.
• Hence this type of structure is called AND-OR graph. AND arcs are indicated with a
line connecting to all the components
Amity School of Engineering & Technology
1. AND- OR GRAPH(cont..)
This type of algorithm finds a path from the starting node of the graph to a set of
nodes representing the solution.
Also it may be necessary to get to more than one solution state since each arm of
AND arc must lead to its own solution node.
The number at each node represent the value of f’ at that node.
Hence for every operation has a uniform cost so each arc with a single successor
has a cost of 1 and each AND arc with multiple successor has a cost of 1 for each
of its components. For example consider:
Amity School of Engineering & Technology
1. AND- OR GRAPH(cont..)
• Here we expand B with cost 5. In AND-OR algorithm we describe a node value and call
it FUTILITY.
• If the estimated cost of solution is greater than the value of FUTILITY then we quit the
search.
• FUTILITY is threshold such that any solution with a cost above it is too expensive to
be practical.
Amity School of Engineering & Technology
2. AO*(AO star) algorithms
AO*(AO star) algorithms(cont..)
• Initialise the graph to start node
• Traverse the graph following the current path accumulating nodes that have not yet been expanded or
solved
• Pick any of these nodes and expand it and if it has no successors call this value FUTILITY otherwise
calculate only f' for each of the successors.
• If f' is 0 then mark the node as SOLVED
• Change the value of f' for the newly created node to reflect its successors by back propagation.
• Wherever possible use the most promising routes and if a node is marked as SOLVED then mark the
parent node as SOLVED.
• If starting node is SOLVED or value greater than FUTILITY, stop, else repeat from 2.
Amity School of Engineering & Technology
AO* algorithm
1. Let G be a graph with only starting node INIT.
2. Repeat the followings until INIT is labeled SOLVED or h(INIT) >
FUTILITY
a) Select an unexpanded node from the most promising path from INIT (call it NODE)
b) Generate successors of NODE. If there are none, set h(NODE) = FUTILITY (i.e.,
NODE is unsolvable); otherwise for each SUCCESSOR that is not an ancestor of
NODE do the following:
i. Add SUCCESSSOR to G.
ii. If SUCCESSOR is a terminal node, label it SOLVED and set h(SUCCESSOR) = 0.
iii. If SUCCESSPR is not a terminal node, compute its h
Amity School of Engineering & Technology
AO* algorithm (Cont.)
c) Propagate the newly discovered information up the graph by doing the
following: let S be set of SOLVED nodes or nodes whose h values have been
changed and need to have values propagated back to their parents. Initialize S
to Node. Until S is empty repeat the followings:
An Example
Amity School of Engineering & Technology
An Example
(8) A
Amity School of Engineering & Technology
An Example
[12] A [13]
4 5
5
(1) B D (8)
(2)
C
Amity School of Engineering & Technology
An Example
[15] A [13]
4 5
5
(4) B 2 D (8)
(2)
C
Amity School of Engineering & Technology
[15] A [8]
An Example
4 5
5
(4) B 2 D (3)
(2)
C 2
4
(1) E
(0) G
Amity School of Engineering & Technology
An Example
[15] A [9]
4 5
5
(4) B 2 D (4)
(2)
C 2
2
4
(3) E
3
(0) G
Amity School of Engineering & Technology
(2)
C 2
2
4
(3) E
3
(0) G Solved
Amity School of Engineering & Technology
Assignment Question
Figure represents an AO graph with the values labeled as follows. The value in a single line circle is an estimate of
cost. The value in a double lined circle, a SOLVED node, is the actual value. Each edge is labeled with a different
cost. What is the value of the root node for the optimal solution for the AO graph?
Amity School of Engineering & Technology
Soln:
Amity School of Engineering & Technology
Advantages
• It is an optimal algorithm.
• If traverse according to the ordering of nodes.
• It can be used for both OR and AND graph.
Disadvantages
• Sometimes for unsolvable nodes, it can’t find the optimal path.
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Amity School of Engineering & Technology
Constraint Satisfaction
• In artificial intelligence and operations research, constraint satisfaction is the
process of finding a solution to a set of constraints that impose conditions that
the variables must satisfy.
• Constraint satisfaction problems (CSPs) are mathematical problems defined as a set of
objects whose state must satisfy a number of constraints or limitations.
• CSPs represent the entities in a problem as a homogeneous collection of finite constraints over
variables, which is solved by constraint satisfaction methods.
• CSPs are the subject of intense research in both artificial intelligence and operations research,
since the regularity in their formulation provides a common basis to analyse and solve problems.
Amity School of Engineering & Technology
Crypt-arithmetic puzzle
SEND
MORE
MONEY
Solution...
• Suppose E is assigned the value 2.
• The constraint propagator now observes that:
• N = 3 since N = E + 1.
• R = 8 or 9, since R + N (3) + C1 (1 or 0) = 2 or 12. But since N is
already 3, the sum of these nonnegative numbers cannot be less than 3.
Thus R + 3 +(0 or 1) = 12
and R = 8 or 9.
• 2 + D = Y or 2 + D = 10 + Y, fro the sum in rithmost
column.
Start
Amity School of Engineering & Technology
M=1
SEND
S = 8 or 9
Initial state: O=0
N=E+1
MORE
• No two letters have
the same value. C2 = 1 MONEY
N+R>8
• The sum of the digits E9
must be as shown. E=2
N=3
R = 8 or 9 M=1
2 + D = 10* C1 + Y R=
M=1 C1+N+R=10+E 8
R=9 C1 = 0 C1 = 1 S=9
M=1
S=8 R= E=2
E=2 2+D=Y 8 N=3
2 + D = 10 + Y
N=3 N + R = 10 + E S=9
D=8+Y O=0
O=0 R=9 E=2
N=3 R=8, S=9 D=9
D=4 S =8
O=0 D=8 Y=1
Y =6 D=8
Y=0 Y=0 Y=1
D=9
Conflict
17
Conflict Conflict
Start
Amity School of Engineering & Technology
M=1
SEND
S = 8 or 9
Initial state: O=0
N=E+1
MORE
• No two letters have
the same value. C2 = 1 MONEY
N+R>8
• The sum of the digits E9
must be as shown. E=5
N=6
R = 8 or 9
5 + D = 10* C1 + Y
M=1 C1+N+R=10+E
R=9 M=1
C1 = 0 C1 = 1 R=
S=8 8
E=5 5+D=Y S=9
N=6 N + R = 10 + E R=8, S=9
E=5
N=6
O=0 R=9 5 + D = 10 + Y O=0
D=2 S =8 D=5+Y D=7
Y =7 D=7 Y=2
Y=2
Conflict
Amity School of Engineering & Technology
• M=1
Final solution
• R=8
• S=9
• E=5
• N=6
• O=0
• D=7
• Y=2
• C1=1
• C2=1
• C3=0
• C4=1
Amity School of Engineering & Technology
SOLVE
• US +AS=ALL
• SHE +THE=BEST
• CROSS+ROADS=DANGER
• DAYS+TOO=SHORT
Amity School of Engineering & Technology
Exercise
Amity School of Engineering & Technology
Solution
Rule 1: Well you can see that the DANGER has one more letter than CROSS and ROADS, and the extra letter
is D. That means that C + R equals something more than 10. Which also means D is 1.
Rule 2: Oh look, S + S = R. That means that R must be even. We have a choice of 4, 6 and 8, because if R was 2,
S would have to be 1, and D is already 1. Let's try 6 for the value of R, because we need high numbers if we
want C
+ R to equal something more than 10. Oh look, if R is 6 and S is R divided by 2, then S must be 3!
Rule 3: S+D=E, 3+1=4, So, E=4
Rule 4: And since we now only have 4 spots in the key left, we choose the highest number for C, which is 9.
Again, we need high numbers to make C
+ R equal something more than 10.
Rule 5: In the equation, O + A = G. We have 2, 5, 7 and 8 vacant. Let's play around with these letters. Let's see if
we can find an equation in there. Yes! There is an equation there. 5 + 2 = 7! So G must equal 7. We know that
9 + 6 = 15, but it's missing the 5! So, A must equal 5. In turn, this leads to O having to be 2 (do the maths, O
+ 5 = 7). And last of all, O is 2, so 6 + 2 (6 + O) = N But 6 + 2 = 8, so now N is 8. We now have the following
equation...
Amity School of Engineering & Technology
• 96233
62513
158746
And the following key...
• C=9
• R=6
• O=2
• S=3
• A=5
• D=1
• E= 4
• N=8
G=7
Amity School of Engineering & Technology
Problem:
Amity School of Engineering & Technology
Problem Statement SEND
S E N D D+E = Y+10*C1
M O R E C1+N+R = E+10*C2
+ C3 C2 C1 C2+E+O = N+10*C3
---------------------- C3+S+M = O+10*M
M O N E Y
Amity School of Engineering & Technology
SOLUTION
Amity School of Engineering & Technology
How it works
• Evaluate the difference between Initial State and final State
• Select the various operators which can be applied for each difference
• Apply the operator at each difference, which reduces the difference
between the current state and goal state
Amity School of Engineering & Technology
Contd.
• Select a new operator O which is applicable for the current difference, and if
there is no such operator, then signal failure.
• Attempt to apply operator O to CURRENT. Make a description of two states.
i) O-Start, a state in which O?s preconditions are satisfied.
ii) O-Result, the state that would result if O were applied In O-start.
Amity School of Engineering & Technology
contd
• If
(First-Part <------ MEA (CURRENT, O-START)
And
(LAST-Part <----- MEA (O-Result, GOAL), are successful, then
signal Success and return the result of combining FIRST-PART, O, and
LAST-PART.
Amity School of Engineering & Technology
Example
Contd
Delete operator: The dot symbol at the top right corner in the initial state
does not exist in the goal state. The dot symbol can be removed by
applying the delete operator.
Amity School of Engineering & Technology
contd
• Move operator: compare the new state with the end state. The green
diamond in the new state is inside the circle while the green diamond
in the end state is at the top right corner. We will move this diamond
symbol to the right position by applying the move operator.
Amity School of Engineering & Technology
contd
• Expand operator: After evaluating the new state generated in step 2, we find that the
diamond symbol is smaller than the one in the end state. We can increase the size of
this symbol by applying the expand operator.