Unit I
Unit I
Systems that think like humans: The exciting new effort to make computers
These laws of thought were supposed to govern the operation of the mind, and initiated the
field of logic.
There are two main obstacles to this approach.
First, it is not easy to take informal knowledge and state it in the formal terms
required by logical notation, particularly when the knowledge is less than
100% certain.
Second, there is a big difference between being able to solve a problem "in
principle" and doing so in practice.
Acting rationally: The rational agent approach:
Acting rationally means acting so as to achieve one's goals, given one's
beliefs.
An agent is just something that perceives and acts.
In this approach, AI is viewed as the study and construction of rational agents.
In the ‗laws of thought" approach to AI, the whole emphasis was on correct
inferences.
Making correct inferences is sometimes part of being a rational agent, because
one way to act rationally is to reason logically to the conclusion that a given
action will achieve one's goals, and then to act on that conclusion.
Correct inference is only a useful mechanism for achieving rationality, and not
a necessary one.
Foundations of Artificial Intelligence:
AI itself is a young field; it has inherited many ideas, viewpoints, and techniques from
other disciplines.
Over 2000 years of tradition in philosophy, theories of reasoning and learning have
emerged, along with the viewpoint that the mind is constituted by the operation of a
physical system.
From over 400 years of mathematics, we have formal theories of logic, probability,
decision making, and computation.
From psychology, we have the tools with which to investigate the human mind, and a
scientific language within which to express the resulting theories.
From linguistics, we have theories of the structure and meaning of language.
From computer science, we have the tools with which to make AI a reality.
Philosophy (428 B.C.-present)
We have the idea of a set of rules that can describe the working of (at least part of) the
mind, the next step is to consider the mind as a physical system.
Mental processes and consciousness are therefore part of the physical world, but
inherently unknowable; they are beyond rational understanding.
Some philosophers critical of AI have adopted exactly this position.
Barring these possible objections to the aims of AI, philosophy had thus established a
tradition in which the mind was conceived of as a physical device operating
Rosenblatt proved the famous perceptron convergence theorem, showing that his
learning algorithm could adjust the connection strengths of a perceptron to match any
input data.
A dose of reality (1966-1974)
Most of the early AI programs worked by representing the basic facts about a problem
and trying out a series of steps to solve it, combining different combinations of steps
until the right one was found.
The early programs were feasible only because micro worlds contained very few
objects.
Before the theory of NP-completeness was developed, it was widely thought that
"scaling up" to larger problems was simply a matter of faster hardware and larger
memories.
Resolution theorem proving, was soon dampened when researchers failed to prove
theorems involving more than a few dozen facts.
A two-input perceptron could not be trained to recognize when its two inputs were
different.
Although their results did not apply to more complex, multilayer networks, solved the
problem.
The new back-propagation learning algorithms for multilayer networks that were to
cause an enormous resurgence in neural net research.
General-purpose search mechanism performs elementary reasoning steps to find
complete solutions. Such approaches are called weak methods, because they use weak
information about the domain.
The only way around this is to use knowledge more suited to making larger reasoning
steps and to solving typically occurring cases in narrow areas of expertise.
The DENDRAL program solves the problem of inferring molecular structure from
the information provided by a mass spectrometer.
The input to the program consists of the elementary formula of the molecule, and the
mass spectrum giving the masses of the various fragments of the molecule generated
when it is bombarded by an electron beam.
The naive version of the program generated all possible structures consistent with the
formula, and then predicted what mass spectrum would be observed for each.
The significance of DENDRAL was that it is the first successful knowledge-intensive
System.
MYCIN diagnoses blood infections. With about 450 rules, MYCIN was able to
perform as well as some experts, and considerably better than junior doctors.
It also contained two major differences from DENDRAL.:
o First, unlike the DENDRAL rules, no general theoretical model existed from
which the MYCIN rules could be deduced. They had to be acquired from
extensive interviewing of experts, who in turn acquired them from direct
experience of cases.
o Second, the rules had to reflect the uncertainty associated with medical
Reasoning − It is the set of processes that enables us to provide basis for judgement,
making decisions, and prediction.
High-frequency Trading. Many banks, funds, and proprietary trading firms now have entire
portfolios which are managed purely by AI systems.
Hospitals and medicine: used as clinical decision support systems for medical diagnosis.
Computer-aided interpretation of medical images help scan digital images, e.g. from
computed tomography, for typical appearances and to highlight conspicuous sections,
such as possible diseases. A typical application is the detection of a tumor.
Heart sound analysis
Companion robots for the care of the elderly
Mining medical records to provide more useful information.
Design treatment plans.
Assist in repetitive jobs including medication management.
Provide consultations.
Drug creation[27]
Using avatars in place of patients for clinical training[28]
Predict the likelihood of death from surgical procedures
Predict HIV progression
Media and E-commerce: Typical use case scenarios include:
analysis of images using object recognition or face recognition techniques
analysis of video for recognizing relevant scenes, objects or faces.
o facilitation of media search,
o creation of a set of descriptive keywords for a media item,
o media content policy monitoring (such as verifying the suitability of content
for a particular TV viewing time),
speech to text for archival or other purposes, and the detection of logos,
products or celebrity faces for the placement of relevant advertisements
AI is also widely used in E-commerce Industry for applications like Visual search,
Visually similar recommendation, Chatbots, Automated product tagging
etc
Music: At Sony CSL Research Laboratory, their Flow Machines software has created pop
songs by learning music styles from a huge database of songs. By analyzing unique
combinations of styles and optimizing techniques, it can compose in any style.
News, publishing and writing: Artificial intelligence is used to turn structured data into
intelligent comments and recommendations in natural language. We can be able to write
financial reports, executive summaries, personalized sales or marketing documents and more
at a speed of thousands of pages per second and in multiple languages including English,
Spanish, French & German.
Online and telephone customer service: Artificial intelligence is implemented in automated
online assistants which uses natural language processing.
Sensors: Artificial Intelligence has been combined with many sensor technologies,
such as Digital Spectrometry TM which enables many applications such as at home
water quality monitoring.
Telecommunications maintenance: Many telecommunications companies make use
of heuristic search in the management of their workforces, for example BT Group has
deployed heuristic search in a scheduling application that provides the work schedules
of 20,000 engineers.
Toys and games: AI has been applied to video games, for example video game bots,
which are designed to stand in as opponents where humans aren't available or desired.
Transportation: Fuzzy Logic controllers have been developed for automatic
gearboxes in automobiles. For example, the 2006 Audi TT, feature the DSP
transmission which utilizes Fuzzy Logic.
AI trends in various sectors
Healthcare:
o AI and ML technology has been particularly useful in the healthcare industry
because it generates massive amounts of data to train with and enables
algorithms to spot patterns faster than human analysts.
o Medecision developed an algorithm that detects 8 variables in diabetes
patients to determine if hospitalization is required.
o An app called BiliScreen utilizes a smartphone camera, ML tools, and
computer vision algorithms to detect increased levels of bilirubin in the sclera
(white portion) of a person‘s eye, which is used to screen people for pancreatic
cancer.
o This cancer has no telltale symptoms, hence it has one of the worst prognoses
of all cancers.
o NuMedii, a biopharma company, has developed a platform called Artificial
Intelligence for Drug Discovery (AIDD), which uses big data and AI to detect
the link between diseases and drugs at the systems level.
o GNS Healthcare uses ML algorithms to match patients with the most effective
treatments for them.
Entertainment:
o A familiar application of AI in everyday life is seen with services like Netflix
or Amazon, wherein ML algorithms analyze the user‘s activity and compare it
with that of other users to determine which shows or products to recommend.
The algorithms are becoming intelligent with time—to the extent of
understanding that a user may want to buy a product as a gift and not for
him/her, or that different family members have different watching preferences.
Finance:
o Financial services companies use AI-based natural language processing tools
to analyze brand sentiment from social media platforms and provide
actionable advice.
o Investment companies like Aidya and Nomura Securities use AI algorithms to
conduct trading autonomously and robo-traders to conduct high-frequency
The cells could be represent as Center square, Corner, Edge as like below:
We have to write a very large number of rules since there have to be a separate rule
for each of the 10120 possible board positions. Using so many rules poses two
serious practical difficulties:
o No person could ever supply a complete set of such rules. It would take too
long and could certainly not be done without mistakes.
o No program could easily handle all those rules. Although hashing scheme
could be used to find the relevant rules for each move fairly quickly, just
storing that many rules poses serious difficulties.
We should write the rules describing the legal moves in as general a way possible.
A problem can be defined in a ―State Space‖, where each state corresponds to a legal
position of the board.
o We can start 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 Al methods. Its structure
corresponds to the structure of problem solving in two important ways:
o It allows formal definition of a problem as the need to convert some given
situation into some desired situation using a set of permissible operations.
o It permits us to define the process of solving a particular problem as a
combination of known techniques) each represented as a role defining a single
step in the space) and search, the general technique of exploring the space 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 more direct
techniques are available.
Water Jug Problem
Consider the following problem: A Water Jug Problem: You are given two jugs, a 4-gallon
one and a 3-gallon one, a pump which has unlimited water which you can use to fill the jug,
and the ground on which water may be poured. Neither jug has any measuring markings on
it. How can you get exactly 2 gallons of water in the 4-gallon jug?
State Representation and Initial State – we will represent a state of the problem as a tuple
(x, y) where x represents the amount of water in the 4-gallon jug and y represents the amount
of water in the 3- gallon jug. Note 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3.
Our Initial state: (0,0) Goal state = (2,y) where 0 ≤ y ≤ 3.
To solve this we have to make some assumptions not mentioned in the problem. They are:
We can fill a jug from the pump.
We can pour water out of a jug to the ground.
We can pour water from one jug to another.
There is no measuring device available.
To solve the water jug problem, all we need is a control structure that loops through a simple
cycle in which some rule whose left side matches the current state is chosen. The appropriate
change to the state is made as described in the corresponding right side, and the resulting
state is checked to see ii ii corresponds to a goal state. As long as it does not, the cycle
continues. Clearly the speed with which the problem gets solved depends on the mechanism
that is used to select the next operation to be performed.
We must define a set of operators that will take us from one state to another:
The first step toward the design of a program to solve a problem must be the creation of a
formal and manipulable description of the problem itself. We should be able to write
programs that can themselves produce such formal descriptions from informal ones. This
process is called Operationalization.
In order to provide a formal description of a problem, we must do the following:
Define a state space that contains all the possible configurations of the relevant
objects (and perhaps some impossible ones). It is, of course, possible to define this
space without explicitly enumerating all of the states it contains.
Specify one or more states within that space that describes possible situations from
which the problem-solving process may start. These states are called the Initial states.
Specify one or more states that would be acceptable as solutions to the problem.
These states are called goal states.
Specify a set of rules that describe the actions (operators) available.
The problem can then be solved by using the rules, in combination with an
appropriate Control Strategy, to move through the problem space until a path from an
initial state to a goal state is found. Thus the process of search is fundamental to the
problem-solving process.
Control Strategies
It is important to decide which rule to apply next during the process of searching for a
solution to a problem. This question arises when more than one will have its left side
match the current state.
The decisions made will have a crucial impact on how quickly a problem is finally
solved.
The following are the requirements of a control strategy:
o The first requirement of a good control strategy is that it causes motion.
Consider again the water jug problem. Suppose we implemented the simple
control strategy of starting each time at the top of the list of rules and choosing
the first applicable one. If we did that, we would never solve the problem. We
would continue indefinitely filling the 4-gallon jug with water. Control
strategies that do not cause motion will never lead to a solution.
o The second requirement of a good control strategy is that it be systematic. Let
us consider a simple control strategy for the water jug problem. On each cycle,
choose at random from among the applicable rules. This strategy is better than
the first. It causes motion. It will lead to a solution eventually. Sometimes we
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. The requirement that a control strategy be systematic
corresponds to the need for global motion (over the course of several steps) as
well as for local motion (over the course of a single step).
Breadth First Search
For each leaf node, generate all its successors by applying all the rules that are
appropriate. Continue this process until some rule produces a goal state. This process,
called Breadth-First search.
Algorithm: Breadth-First Search
1. Create a variable called NODE-LIST and set it to the initial state.
2. Until a goal state is found or NODE-LIST is empty do:
(a) Remove the first element from NODE-LIST and call it E. If
(b) For each way that each rule can match the state described in E do:
i. Apply the rule to generate a new state.
ii. If the new state is a goal state, quit and return this state.
iii. Otherwise, add the new state to the end of' NODE-LIST.
Advantages of Breadth-First Search:
Breadth-first search will not get trapped exploring a blind alley.
If there is a solution, then breadth-first search is guaranteed to find it. Furthermore, if
there are multiple solutions, then a minimal solution will be found. This is guaranteed
by the fact that longer paths are never explored until all shorter ones have already
been examined.
Disadvantages of Breadth-First Search:
All of the tree that has so far been generated must be stored which requires more
memory.
In breadth-first search, all parts of the tree must be examined to level n before any
nodes on level n + 1 can be examined. This is particularly significant if many
acceptable solutions exist.
Depth First Search
We could pursue a single branch of the tree until it yields a solution or until a decision
to terminate the path is made.
It makes sense to terminate a path if it reaches a dead-end, produces a previous state,
or becomes longer than some pre-specified "futility" limit.
In such a case backtracking occurs. The most recently created state from which
alternative moves are available will be revisited and a new state will he created. This
form of backtracking is called Chronological Backtracking because the order in which
steps arc undone depends only on the temporal sequence in which the steps were
originally made.
The search procedure we have just described is called Depth-First search.
Algorithm: Depth-First Search
1. If the initial state is a goal state, quit and return success.
2. Otherwise, do the following until success or failure is signalled:
a. Generate a successor, E, of the initial state. It there are no more successors,
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.
We can solve this problem by breaking it down into three smaller problems each of which we
can then solve by using a small collection of specific rules.
The figure shows the problem tree that will be generated by the process of problem
decomposition as it can be exploited by a simple recursive integration program that works as
follows:
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. If it can, it creates those problems and calls
itself recursively on them. Using this technique of problem decomposition we can often
solve very large problems easily.
Example-Blocks World Problem: Assume that the following operators are available-
Applying the technique of problem decomposition to this simple blocks world example
would lead to a solution tree such as that shown below:
In the figure, goals are underlined. States that have been achieved are not underlined.
The idea of this solution is to reduce the problem of getting B on C and A on B to two
separate problems.
The first of these new problems, getting B on C. is simple, given the start state.
Simply put B on C. The second sub goal is not quite so simple. Since the only
operators we have allow us to pick up single blocks at a time, we have to clear off B
by removing C before we can pick up A and put it on B This can easily be done.
However, if we now try to combine the two sub solutions into one solution, we will
fail. Regardless of which one we do first, we will not be able to do the second as we
had planned.
In this problem, the two sub problems are not independent. They interact and those
interactions must be considered in order to arrive at a solution for the entire problem.
2. Can Solution Steps Be Ignored or Undone?
Theorem Proving: We proceed by first proving lemma that we think will be useful.
Eventually, we realize that the lemma is no help at all.
Everything we need to prove the theorem is still true. Any rules that could have been
applied can still be applied.
We can just proceed as we should have in the first place. All we have lost is the effort
that was spent exploring the blind alley.
The 8-Puzzle: The 8-puzzle is a square tray in which are placed eight square tiles. The
remaining ninth square is uncovered. Each tile has a number on it. A tile that is adjacent to
the blank space can he slid into that space. A game consists of a starting position and a
specified goal position. The goal is to transform the starting position into a goal position by
sliding the tiles around.
In attempting to solve the 8-puzzle, we might make a stupid move. We might start by
sliding tile 5 into the empty space. Having done that, we cannot change our mind
and immediately slide tile 6 into the empty space since the empty space will
essentially have moved.
But we can backtrack and undo the first move, sliding tile 5 back to where it was.
Then we can move tile 6. Mistakes can still be recovered from but not quite easily. An
additional step must be performed to undo each incorrect step
The control mechanism for an 8.puzzle solver must keep track of the order in which
operations are performed so that the operations can be undone one at a time if
necessary.
Chess: Now consider again the problem of playing chess. Suppose a chess-playing program
makes a stupid move and realizes it a couple of moves later. It cannot simply play as though
it had never made the stupid move. Nor can it simply back up and start the game over from
that point. All it can do is to try to make the best of the current situation and go on from there.
The three problems—theorem proving, the 8-puzzle, and chess—
illustrate the differences between three important classes of problems:
Ignorable(e.g... theorem proving), in which solution steps can be ignored
Recoverable(e.g... 8-puzzle), in which solution steps can be undone.
Irrecoverable(e.g... chess), in which solution steps cannot be undone
The recoverability of a problem plays an important role in
determining the complexity of the control structure necessary for the problem's solution.
Ignorable problems can be solved using a simple control structure that never
backtracks. Such a control structure is easy to implement.
Recoverable problems can be solved by a slightly more complicated control strategy
that does sometimes make mistakes. Backtracking will be necessary to recover from
such mistakes, so the control structure must be implemented using a push-down stack,
in which decisions are recorded in case they need to be undone later.
Irrecoverable problems, on the other hand, will need to be solved by a system that
expends a great deal of effort making each decision since the decision must be final
3. Is the Universe Predictable?
8-puzzle: Every time we make a move, we know exactly what will happen. This
means that it is possible to plan an entire sequence of moves and be confident that we
know what the resulting state will be. We can use planning to avoid having to undo
actual moves, although it still be necessary to backtrack past those moves one at a
time during the planning process. Thus a control structure that allows backtracking
will be necessary.
Play Bridge: One of the decisions we will have to make is which card to play on the
first trick. What we would like to do is to plan the entire hand before making that first
play. But now it is not possible to do such planning with certainty since we
cannot know exactly where all the cards are what the other players will do on their
turns. The best we can do is to investigate several plans and use probabilities of the
various outcomes to choose a plan that has the highest estimated probability of
leading to a good score on the hand.
Certain–outcome problems (e.g... 8-puzzle): The open-loop approach will work fine
since the result of an action can he predicted perfectly. Thus, planning can be used to
generate a sequence of operators that is guaranteed to lead to a solution.
Uncertain–outcome problems (e.g... Bridge): Planning can at best generate a
sequence of operators that has a good probability of leading to a solution. To solve
such problems, we need to allow for a process of plan revision to take place as the
plan is carried out and the necessary feedback is provided. In addition to providing
no guarantee of art actual solution, planning for uncertain -outcome problems has
the drawback that it is often very expensive since the number of solution paths
that need to be explored increases exponentially with the number of points at which
the outcome cannot be predicted.
4. Is a Good Solution Absolute or Relative?
Simple facts problem: Consider the problem of answering questions based on a database of
simple facts, such as the following:
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 79 A.D.
6. No mortal lives longer than 150 years.
7. 11 is now 1991 A.D.
Suppose we ask the question 'Is Marcus alive?'. By representing each of these facts
in a formal language such as predicate logic, and then using formal inference
methods we can fairly easily derive an answer to the question. Since all we are
interested in is the answer to the que7sion, it does not matter which path we follow. If
we do follow one path successfully to the answer, there is no reason to go back and
see it some other path might also lead to a solution.
Travelling salesman problem: Our goal is to find the shortest route that visits each city
exactly once. Suppose the cities to be visited and the distances between them are as shown:
One place the salesman could start is Boston. In that case, one path that might be followed is
shown, which is 8850 miles long. But is this the solution to the problem? The answer is that
we cannot be sure unless we also try all other paths to make sure that none of them is shorter.
In this case, the first path is definitely not the solution to the salesman's problem.
problems. No heuristic that could possibly miss the best solution can be used.
Any-path problems: can often be solved in a reasonable amount of time by using
heuristics that suggest good paths to explore. If the heuristics are not perfect, the
search for a solution may not be as direct as possible. So a much more exhaustive
search will be performed.
5. Is the Solution a State or a Path?
Consistent interpretation for the sentence (NLU): There are several components of this
sentence, each of which, in isolation, may have more than one interpretation.
―The Bank president ate a dish of pasta salad with the fork‖
Some of the sources of ambiguity in this sentence are the following:
The word "bank" may refer either to a financial institution or to a side of a river. But
only one of these may have a president.
The word "dish" is the object of the verb "eat." It is possible that a dish was eaten.
But it is more likely that the pasta salad in the dish was eaten.
Pasta salad is a salad containing pasta. But there are other ways meanings can be
formed from pair of nouns. For example, dog food does not normally contain dog.
Some search may be required to find a complete interpretation for the sentence. But to solve
the problem of finding the interpretation we need to produce only the interpretation itself. No
record of the processing by which the interpretation was found is necessary.
Water Jug Problem: It is not sufficient to report that we have solved the problem and that
the final state (2, 0). For this kind of problem, what we really must report is not the final state
but the path that we found to that state. Thus a statement of a solution to this problem must be
a sequence of operations called a ―plan‖ that produces the final state.
The difference between these problems is:
Problems whose solution is a state.
Problems whose solution is a path to a state.
In water jug problem, we must re-describe the states so that each state represents a partial
path to a solution rather than just a single state of the world.
6. What Is the Role of Knowledge?
Playing chess: Suppose you had unlimited computing power available.The
knowledge that would be required by a perfect program is very little—just the rules
for determining legal moves and some simple control mechanism that implements a
search procedure.
Additional knowledge about such things as good strategy, and tactics could of course
help considerably to constrain the search and speed up the execution of the program.
Scanning daily newspapers: to decide which are supporting the Democrats and which
are supporting the Republicans in some upcoming election. Again assuming unlimited
computing power, how much knowledge would be required by a computer trying to
solve this problem? It would have to know such things as:
o The names of the candidates in each party.
o The fact that if the major thing you want to see done is have taxes lowered,
Depth-first search is good because it allows a solution to be found without all competing
branches having to be expanded. Breadth-first search is good because it does not get trapped
on dead-end paths.
One way of combining the two is to follow a single path at a time, but switch paths whenever
some competing path looks more promising than the current one does.
At each step of the best-first search process, we select the most promising of the
nodes we have generated so far. This is done by applying an appropriate heuristic
function to each of them, We then expand the chosen node by using the rules to
generate its successors.
If one of them is a solution, we can quit. If not, all those new nodes are added to the
set of nodes generated so far. Again the most promising node is selected and the
process continues. A bit of depth first searching occurs as the most promising branch
is explored.
But eventually, it a solution is not found, that branch will start to look less promising
than one of the top-level branches that had been ignored. At that point, the now more
promising, previously ignored branch will be explored. But the old branch is not
forgotten, Its last node remains in the set of generated but unexpanded nodes. The
search can return to it whenever all the others get bad enough, that it is again the most
promising path.
Initially, there is only one node, so it will be expanded. Doing so generates three new
nodes. The heuristic function, is an estimate of the cost of getting to a solution
from a given node, is applied to each of these new nodes.
Since node D is the most promising, it is expanded next, producing two successor
nodes, E and F. Now the heuristic function is applied to them.
Now another path that going through node B looks more promising, so it is pursued,
generating nodes G and H. But again when these new nodes are evaluated they look
less promising than another path, so attention is returned to the path through D to E. E
is then expanded, yielding nodes I and J.
At the next step, J will be expanded, since it is the most promising. This process can
continue until a solution is found.
In best-first search, one move is selected, but the others are kept around so that they
can be revisited later if the selected path becomes less promising.
Further, the best available state is selected in best first search, even it that state has a
value that is lower than the value of the state that was just explored.
In a best-first search of a tree, it is sometimes important to search a graph instead so
that duplicate paths will not be pursued.
An algorithm to do this will operate by searching a directed graph in which each node
represents a point in the problem space. Each node will contain, in addition to a
description of the problem state it represents, an indication of how promising it is; a
parent link that points back to the best node from which it came, and a list of the
nodes that were generated from it.
The parent link will make it possible to recover the path to the goal once the goal is
found. The list of successors will make it possible, if a better path is found to an
already existing node, to propagate the improvement down to its successors.
We will call a graph of this sort an OR graph, since each of its branches represents an
alternative problem-solving path.
To implement such a graph-search procedure, we will need to use two lists of nodes:
o OPEN—nodes that have been generated and have had the heuristic function
applied to them but which have not yet been examined (i.e.. had their
successors generated) OPEN is actually a priority queue in which the
elements with the highest priority are those with the most promising value
of the heuristic function.
o CLOSED— -nodes that have already been examined. We need to keep
these nodes in memory if we want to search a graph rather than a tree, since
whenever a new node is generated; we need to check whether it has been
generated before.
We will also need a heuristic function that estimates the merits of each node we
generate. The function f1 that gives the true evaluation of the node.
We define this function as the sum of two components: g and h1.
The function g is a measure of the cost of getting from the initial state to the current
node.
The function h1 is an estimate of the additional cost of getting from the current node
to a goal state.
The combined function f1 represents an estimate of the cost of getting from the
initial state to a goal state along the path that generated the current node. If more than
one path is generated the node, then the algorithm will record the best one.
This process can be summarized as follows:
Algorithm: Best-First Search
1. Start with OPEN containing just the initial state.
2. Until a goal is found or there are no nodes left on OPEN do:
a. Pick the best node on OPEN.
b. Generate its successors.
The goal slate is problem state in which all letters have been assigned a digit in such a
way that all the initial constraints are satisfied.
The solution process proceeds in cycles. At each cycle, two significant things are
done :
o Constraints are propagated by using rules that correspond to the properties of
arithmetic.
o A value is guessed for some letter whose value is not yet determined.
In the first step, it does not usually matter a great deal what order the propagation is
done in, since all available propagations will be performed before the step ends.
In the second step, the order in which guesses are tried may have a substantial impact
on the degree of search that is necessary.
A few useful heuristics can help to select the best guess to try first.
For example, if there is a letter that has only two possible values and other with
possible values, there is a better chance of guessing right on the first than on the
second.
Another useful heuristic is that if there is a letter that participates in many constraints
then it is a good idea to prefer it to a letter that participates in a few. A guess on such
a highly constrained letter will usually lead quickly either to a contradiction (if it‘s
wrong) or to the generation of many additional constraints (if it is right). A guess on a
less constrained letter, on the other hand, provides less information.
Let Cl, C2, C3, and C4 indicate the carry bits out of the columns, numbering from the
right. Initially, rules for propagating constraints generate the following additional
constraints:
o M 1, since two single-digit numbers plus a carry cannot total more than 19;
S=8 or 9, since S+M+C3>9 (to generate the carry) and M=1, S+l+C3>9. So S
+ C3 > 8 and C3 is at most 1.
o O=0, since S + M(l)+C3(<= 1) must be at least 10 to generate a carry and it
can be at most 11. But M is already 1. So O must be 0.
o N = E or E+1, depending on the value of C2. But N cannot have the same
value as E. So, N=E+l and C2 is 1.
o In order for C2 to be1, the sum of N+ R+CI must be greater than 9, so N+ R
must be greater than 18.
o N + R cannot be greater than 18, even with a carry in, so E cannot be 9.
At this point, let us assume that no more constraints can be generated. Then, to make
progress from here, we must guess. Suppose E is assigned the value 2. (We chose to
guess a value for E because it occurs three times and thus interacts highly with the
other letters.) Now the next cycle begins. The constraint propagator now observes
that:
o N =3, since N = E+ 1.
o R= 8 o 9, since R + N (3) + C1 (1 or 0) = 2 or 12. But since N is already 3, the
sum of these n negative numbers cannot be less than 3. Thus R + 3 + (0
or 1)= 12 and R = 8 or 9.
o 2 + D= Y or 2 + D = 10 + Y, from the sum in the rightmost column.