Scsa1702 - Ai - Unit V
Scsa1702 - Ai - Unit V
1.1 Introduction
Game playing:
IBM's Deep Blue became the first computer program to defeat the worldchampion in a chess match
when it bested Garry Kasparov by a score of 3.5 to 2.5 inan exhibition match (Goodman and Keene,
1997).
Diagnosis:
Medical diagnosis programs based on probabilistic analysis have been able toperform at the level of
an expert physician in several areas of medicine.
Robotics:
Many surgeons now use robot assistants in microsurgery. HipNav (DiGioia etal., 1996) is a system
that uses computer vision techniques to create a three-dimensional model of a patient's internal
anatomy and then uses robotic control toguide the insertion of a hip replacement prosthesis.
Language understanding and problem solving:
PROVERB (Littman et al., 1999) is a computer program that solves crosswordpuzzles better than
most humans, using constraints on possible word fillers, a largedatabase of past puzzles, and a variety
of information sources including dictionariesand online databases such as a list of movies and the
actors that appear in them.
Searching Techniques
Example
The 8-puzzle
An 8-puzzle consists of a 3x3 board with eight numbered tiles and a blank space. Atile adjacent to the
blank space can slide into the space. The object is to reach thegoal state ,as shown in figure 5.1
Example: The 8-puzzle
The 8-puzzle belongs to the family of sliding-block puzzles, which are oftenused as test problems for
new search algorithms in AI. This general class isknown as NP-complete.
The 8-puzzle has 9!/2 = 181,440 reachable states and is easily solved.
The 15 puzzle (4 x 4 board ) has around 1.3 trillion states, an the randominstances can be solved
optimally in few milli seconds by the best searchalgorithms.
The 24-puzzle (on a 5 x 5 board) has around 1025 states ,and random instancesare still quite
difficult to solve optimally with current machines and algorithms.
REAL-WORLD PROBLEMS
AIRLINE TRAVEL PROBLEM
The airline travel problem is specifies as follows :
o States: Each is represented by a location(e.g., an airport) and the currenttime.
o Initial state: This is specified by the problem.
o Successor function: This returns the states resulting from taking anyscheduled flight (further
specified by seat class and location),leaving laterthan the current time plus the within-airport transit
time, from the currentairport to another.
o Goal Test : Are we at the destination by some pre specified time?
o Path cost: This depends upon the monetary cost, waiting time, flight time,customs and immigration
procedures, seat quality, time of dat, type of airplane, frequent-flyer mileage awards, and so on.
Since it never generates a node in the tree until all the nodes at shallower levels have been
generated, breadth-first search always finds a shortest path to a goal. Since each node can be
generated in constant time, the amount of time used by Breadth first search is proportional to the
number of nodes generated, which is a function of the branching factor b and the solution d. Since the
number of nodes at level d is bd, the total number of nodes generated in the worst case is b + b 2 + b3 +
… + bd i.e. O(bd) , the asymptotic time complexity of breadth first search.
Look at the above tree with nodes starting from root node, R at the first level, A and B at the second
level and C, D, E and F at the third level. If we want to search for node E then BFS will search level
by level. First it will check if E exists at the root. Then it will check nodes at the second level. Finally
it will find E a the third level.
1.Breadth first search will never get trapped exploring the useless path forever.
2.If there is a solution, BFS will definitely find it out.
3.If there is more than one solution then BFS can find the minimal one that requires less
number of steps.
1.The main drawback of Breadth first search is its memoryrequirement. Since each level of the
tree must be saved in order to generate the next level, and the amount ofmemory is
proportional to the number of nodes stored, the space complexity of BFS is O(b d).
2.If the solution is farther away from the root, breath first search will consume lot of time.
Depth First Search (DFS) searches deeper into the problem space. Breadth-first search always
generates successor of the deepest unexpanded node. It uses last-in first-out stack for keeping the
unexpanded nodes. Depth-first search is implemented recursively, with the recursion stack taking the
place of an explicit node stack.
1.If the initial state is a goal state, quit and return success.
2.Otherwise, loop until success or failure is signaled.
a) Generate a state, say E, and let it be the successor of the initial state. If there is no successor, signal
failure.
b) Call Depth-First Search with E as the initial state.
c) If success is returned, signal success. Otherwise continue in this loop.
The advantage of depth-first Search is that memoryrequirement is only linear with respect to the
search graph. This is in contrast with breadth-first search which requires more space. The reason is
that the algorithm only needs to store a stack of nodes on the path from the root to the current node.
The time complexity of a depth-first Search to depth d is O(b^d) since it generates the same set of
nodes as breadth-first search, but simply in a different order. The depth-first search is time-limited
rather than space-limited.
If depth-first search finds solution without exploring much in a path then the time and space it takes
will be very less.
The disadvantage of Depth-First Search is that there is a possibility that it may go down the left-most
path forever. Even a finite graph can generate an infinite tree. One solution to this problem is to
impose a cutoff depth on the search. Although the ideal cutoff is the solution depth d and this value is
rarely known in advance of actually solving the problem. If the chosen cutoff depth is less than d, the
algorithm will fail to find a solution, whereas if the cutoff depth is greater than d, a large price is paid
in execution time, and the first solution found may not be an optimal one.
And there is no guarantee to find a minimal solution, if more than one solution exists.
Bidirectional Search
It searches forward from initial state and backward from goal state till both meet to identify a
common state.
The path from initial state is concatenated with the inverse path from the goal state. Each search is
done only up to half of the total path.
Disadvantage − There can be multiple long paths with the cost ≤ C*. Uniform Cost search must
explore them all.
It never creates a node until all lower nodes are generated. It only saves a stack of nodes. The
algorithm ends when it finds a solution at depth d. The number of nodes created at depth d is bd and
at depth d-1 is bd-1.
In each iteration, a node with a minimum heuristic value is expanded, all its child nodes are created
and placed in the closed list. Then, the heuristic function is applied to the child nodes and they are
placed in the open list according to their heuristic value. The shorter paths are saved and the longer
ones are disposed.
A * Search
It is best-known form of Best First search. It avoids expanding paths that are already expensive, but
expands most promising paths first.
Hill-Climbing Search
It is an iterative algorithm that starts with an arbitrary solution to a problem and attempts to find a
better solution by changing a single element of the solution incrementally. If the change produces a
better solution, an incremental change is taken as a new solution. This process is repeated until there
are no further improvements.
Otherwise the (initial k states and k number of successors of the states = 2k) states are placed in a
pool. The pool is then sorted numerically. The highest k states are selected as new initial states. This
process continues until a maximum value is reached.
Simulated Annealing
Annealing is the process of heating and cooling a metal to change its internal structure for modifying
its physical properties. When the metal cools, its new structure is seized, and the metal retains its
newly obtained properties. In simulated annealing process, the temperature is kept variable.
Initially set the temperature high and then allow it to ‘cool' slowly as the algorithm proceeds. When
the temperature is high, the algorithm is allowed to accept worse solutions with high frequency.
Start
End
Start
Find out all (n -1)! Possible solutions, where n is the total number of cities.
Determine the minimum cost by finding out the cost of each of these (n -1)! solutions.
Finally, keep the one with the minimum cost.
end
A sentence in first-order logic is written in the form Px or P(x), where P is the predicate and x is the
subject, represented as a variable. Complete sentences are logically combined and manipulated
according to the same rules as those used in Boolean algebra.
In first-order logic, a sentence can be structured using the universal quantifier (symbolized ) or the
existential quantifier ( ). Consider a subject that is a variable represented by x. Let A be a predicate
"is an apple," F be a predicate "is a fruit," S be a predicate "is sour"', and M be a predicate "is mushy."
Then we can say
x : Ax Fx
Propositional logic assumes world contains facts, first-order logic (like natural language)
assumes the world contains
• Objects: people, houses, numbers, theories, Ronald McDonald, colors, baseball games,
wars, centuries . . .
• Relations: red, round, bogus, prime, multistoried . . ., is the brother of, is bigger than, is
inside, is part of, has color, occurred after, owns, comes between, . . .
• Functions: father of, best friend, third inning of, one more than, end of
Variable symbols x, y, a, b, . . .
Connectives ∧ ∨ ¬ ⇒ ⇔
Equality =
Quantifiers ∀ ∃
Punctuation ( )
Atomic sentences
Complex sentences
Complex sentences are made from atomic sentences using connectives ¬S, S1 ∧ S2, S1 ∨ S2,
S1 ⇒ S2, S1 ⇔ S2
Universal quantification
∀<variables><sentence>
Existential quantification
∃<variables><sentence>
Properties of quantifiers
∀ x ∀ y is the same as ∀ y ∀ x
∃ x ∃ y is the same as ∃ y ∃ x
∃ x ∀ y Loves(x, y)
∀ y ∃ x Loves(x, y)
Examples of sentences
∀ x, y Brother(x, y) ⇒ Sibling(x, y)
“Sibling” is symmetric
∀ x, y Sibling(x, y) ⇔ Sibling(y, x)
For example, suppose that the goal is to conclude the color of a pet named Fritz, given that he croaks
and eats flies, and that the rule base contains the following four rules:
Let us illustrate forward chaining by following the pattern of a computer as it evaluates the rules.
Assume the following facts:
Fritz croaks
Fritz eats flies
With forward reasoning, the inference engine can derive that Fritz is green in a series of steps:
1. Since the base facts indicate that "Fritz croaks" and "Fritz eats flies", the antecedent of rule #1 is
satisfied by substituting Fritz for X, and the inference engine concludes:
Fritz is a frog
2. The antecedent of rule #3 is then satisfied by substituting Fritz for X, and the inference engine
concludes:
Fritz is green
The name "forward chaining" comes from the fact that the inference engine starts with the data and
reasons its way to the answer, as opposed to backward chaining, which works the other way around.
In the derivation, the rules are used in the opposite order as compared to backward chaining. In this
example, rules #2 and #4 were not used in determining that Fritz is green.
For example, suppose a new pet, Fritz, is delivered in an opaque box along with two facts about Fritz:
Fritz croaks
Fritz eats flies
The goal is to decide whether Fritz is green, based on a rule base containing the following four rules:
An Example of Backward Chaining.
With backward reasoning, an inference engine can determine whether Fritz is green in four steps. To
start, the query is phrased as a goal assertion that is to be proved: "Fritz is green".
1. Fritz is substituted for X in rule #3 to see if its consequent matches the goal, so rule #3 becomes:
If Fritz is a frog – Then Fritz is green
Since the consequent matches the goal ("Fritz is green"),the rules engine now needs to see if the
antecedent ("If Fritz is a frog") can be proved. The antecedent therefore becomes the new goal:
Fritz is a frog
Since the consequent matches the current goal ("Fritz is a frog"), the inference engine now needs to
see if the antecedent ("If Fritz croaks and eats flies") can be proved. The antecedent therefore
becomes the new goal:
Fritz croaks and Fritz eats flies
3. Since this goal is a conjunction of two statements, the inference engine breaks it into two sub-goals,
both of which must be proved:
Fritz croaks
Fritz eats flies
4. To prove both of these sub-goals, the inference engine sees that both of these sub-goals were given
as initial facts. Therefore, the conjunction is true:
Fritz croaks and Fritz eats flies
therefore the antecedent of rule #1 is true and the consequent must be true:
Fritz is a frog
therefore the antecedent of rule #3 is true and the consequent must be true:
Fritz is green
This derivation therefore allows the inference engine to prove that Fritz is green. Rules #2 and #4
were not used.
1.6 Semantic Networks
Semantic nets consist of nodes, links (edges) and link labels. In the semantic network
diagram, nodes appear as circles or ellipses or rectangles to represent objects such as physical objects,
concepts or situations. Links appear as arrows to express the relationships between objects, and link
labels specify particular relations. Relationships provide the basic structure for
organizing knowledge. The objects and relations involved need not be so concrete. As nodes are
associated with other nodes semantic nets are also referred to as associative nets.
INHERITANCE REASONING
Unless there is a specific evidence to the contrary, it is assumed that all members of a class (category)
will inherit all the properties of their superclasses. So semantic network allows us to perform
inheritance reasoning. For example Jill inherits the property of having two legs as she belongs to the
category of FemalePersons which in turn belongs to the category of Persons which has a boxed Legs
link with value 2. Semantic nets allows multiple inheritance. So an object can belong to more than one
category and a category can be a subset of more than one another category.
INVERSE LINKS
Semantic network allows a common form of inference known as inverse links. For example we can
have a HasSister link which is the inverse of SisterOf link.The inverse links make the job of inference
algorithms much easier to answer queries such as who the sister of Jack is. On discovering
that HasSister is the inverse of SisterOf the inference algorithm can follow that link HasSister
from Jack to Jill and answer the query.
1.One of the drawbacks of semantic network is that the links between the objects represent only
binary relations.
1.Semantic nets have the ability to represent default values for categories. In the above figure Jack has
one leg while he is a person and all persons have two legs. So persons have two legs has only default
status which can be overridden by a specific value.
1.7 Frames
Frames can also be regarded as an extension to Semantic nets. Semantic nets initially used to
represent labelled connections between objects. As tasks became more complex the representation
needs to be more structured. A frame is a collection of attributes or slots and associated values that
describe some real world entity. Each frame represents:
a class (set), or
an instance (an element of a class).
NEED OF FRAMES
Slots Fillers
publisher Thomson
title Expert Systems
author Giarratano
edition Third
year 1998
pages 600
Frames can represent either generic or frame. Following is the example for generic frame.
Slot Fillers
name computer
specialization_o a_kind_of machine
f
types (desktop, laptop,mainframe,super)
if-added: Procedure ADD_COMPUTER
speed default: faster
if-needed: Procedure FIND_SPEED
location (home,office,mobile)
under_warranty (yes, no)
The fillers may values such as computer in the name slot or a range of values as in types slot. The
procedures attached to the slots are called procedural attachments. There are mainly three types of
procedural attachments: if-needed, default and if-added. As the name implies if-needed types of
procedures will be executed when a filler value is needed. Default value is taken if no other value
exists. Defaults are used to represent commonsense knowledge.