Professional Documents
Culture Documents
Artificial
intelligence
Master of Computer Applications
Asst.Prof
Artificial Intelligence
CHAPTER-1
WHAT IS ARTIFICIAL INTELLIGENCE
Artificial Intelligence(AI) is the key technology in many of today’s Novell
applications, ranging from banking system that detect attempted credit card framed, to
telephone systems that understand speech, to s/w systems that notice when you are having
problems and offer appropriate advice. These technologies would not exist today without
the sustained federal of fundamental AI research over the past 3 decades.
There is no clear definition of A.I .even the name is controversial, some people
prefer to call the subject of “computational Intelligence”.
The term A.I was coined in 1957 at a conference at Dartmouth New Hampshire
convened to discuss the possibilities of simulating human intelligence and thinking in
computers.
A.I is the part of computer science concerned with designing intelligent computer
systems, that is, computer systems that exhibit the characteristics we associate with
intelligence in human behavior understanding language, learning, reasoning and solving
problems. The study of AI by considering a number of alternative definitions.
1) AI is the study of how to make computers do things which at the moment people
do better. It refers to the current state of computer science and if excludes a major
area of problems that can not be solved well either by computers or by people at
the moment.
Asst.Prof
Artificial Intelligence
AI problems
Intelligence does not imply perfect understanding: every intelligent being has
limited perception, memory, and computation. AI seeks to understand the computations
required from intelligent behavior and to produce computer systems that exhibit
intelligence. Aspects of intelligence studied by AI include perception, motor control, and
communication using human languages, reasoning, planning, learning and memory.
Various AI problems are as follows.
Mundane Tasks
Perception
---Machine vision
---Speech understanding
---Language generation
---Machine translation
Commonsense reasoning
Robot control
Formal tasks
Games
---Chess
---Backgammon
Asst.Prof
Artificial Intelligence
---Checkers
Mathematics
---Geometry
---Logic
---Integral calculus
Expert tasks
Engineering
---Design
---Fault finding
---Manufacturing planning
Scientific analysis
Medical diagnosis
Financial analysis
Perception:
Machine vision:-
Perception of the world around us is crucial to our survival. Animals with much less
intelligence than people are capable of more sophisticated visual perception than are
current machines.
Speech understanding:
Asst.Prof
Artificial Intelligence
systems must be trained for the individual user and require pauses between words.
Understanding continuous speech with a larger vocabulary is harder.
The ability to use language to communicate a wide variety of ideas is perhaps the
most important thing that separates human from other animals.
Machine Translation:-
A text written in one language and then generate it in another language by means of
computers can be called as machine Translation. It is important for organizations that
operate in many countries.
A computer program that interacts with real world must be able to reason about
things like time, space and materials. As a fundamental and commonsensical as these
concepts may be modeling them turns out to present some problems.
Robot Control:-
Robots can process visual and auditory information, and they can also be equipped
with more special sensors, such as laser range finders, speedometers and radar. Although
industrial robots to date have been expensive, robot hardware can be cheap. What is needed
is perception and intelligence to tell robot effectors what to do; “bling” robots are limited
to very well-structured tasks like spray painting car bodies.
Planning:-
Asst.Prof
Artificial Intelligence
Expert Systems:-
Expert systems attempt to capture the knowledge of human expert and make it
available through a computer program.
Machine Learning:-
Learning has remained a challenging area of AI. Expert systems may perform costly
computations to solve problem. Unlike human beings it can’t remember the solution, if it is
given the same problem for second time one of the solutions for these problems for
programs is to learn on their own either from experience examples or analogy.
AI Technique:-
There AI techniques are:
1. Search
2. Use of knowledge
3. Abstraction
Search:-
Search programs find a solution for a problem by trying different sequences of
actions/operators until a solution is found.
The advantage of search is, to solve a program using search, it is only necessary to
code the operators that can be used: search will find the sequence of actions that will
provide the desired result. For example a program can be written to play chess using search
if one knows the rules of chess if is not necessary to know how to play good chess.
The disadvantage of search is, most problems have search so large that it is
impossible to search the whole space. Chess has been estimated to have 1020 possible
games.
Use of Knowledge:-
Use of knowledge provides a way of solving complex problems by exploiting of the
objects that are involved. Games can be good models of competitive situations, so
principles discovered in games playing programs may be applicable to practical problems.
Abstraction:-
Abstraction provides a way of separating important features and variations from the
many unimportant ones that would otherwise overwhelm any process.
CHAPTER - 2
Asst.Prof
Artificial Intelligence
To build a system to solve a particular problem, for that we need to do four things
1) Define the problem exactly. The definition must include precise specification of
what the initial situation will be as well as what final situations constitute
acceptable solutions to the problem.
2) Analyze the problem a few very important features can have an immense impact on
the appropriateness of various possible techniques for solving the problem.
3) Isolate and represent the task knowledge that is necessary to solve the problem.
4) Choose the best problem solving techniques and apply it to the particular problem.
1) A representation of the states the system can be in. in a chess game, for example,
any board position represents the current state of the game.
2) A set of operators that can change one state into another state. In chess game, the
operators are the legal moves from any given state. Often the operators are
representation to represent the new state.
3) An initial state.
4) A set of final states, some of these may be desirable others are undesirable this sets
often represented implicitly by a program that deletes terminal states.
Tic-tac-toe as a state space
State space is good representations for board games such as tic-tac-toe the state of a
game can be described by the contents of the board and the player whose turn is next. The
board can be represented as an array of 9 cells, each of which may contain a X or O or be
empty.
State:
Asst.Prof
Artificial Intelligence
X O
O X
Terminal states: Three X’s in arrow there O’s in arrow all the cells full.
Search tree: The sequence of states formed by possible moves is called a search tree each
level of the tree is called a play.
X X
X O X X
Asst.Prof
Artificial Intelligence
Since the same state may be reachable by different sequence of moves the state
space may be in a general graph it may be as a tree for simplicity at the cost of duplicating
states.
Time Complexity: How long (worst or average case) does it take to find a solution?
Usually measured in terms of the number of nodes expanded. Big O notation used for
measuring time complexity.
Space Complexity: How much space is used by the algorithm? Usually measured in term
of the maximum size that nodes list becomes during the search.
Asst.Prof
Artificial Intelligence
If x>0
6. (x, y) (x,0) empty the 3-g jug on the ground
If y>0
7. (x, y) (4,y-(4-x)) pour water from the 3-g jug into
If x + y >= 4 and y>0 the 4-g jug until the 4-g jug is full
Asst.Prof
Artificial Intelligence
If x + y>3 & x>0 the 3-g jug until the 3-g jug is full
9. (x, y) (x+y,0) pour all the water from 3-g jug into
10. (x, y) (0,x+y) pour all the water from the 4-g jug
11. (0, 2) (2, 0) pour the 2-g from 3-g jug into 4-g
Jug
the ground.
Gallon in the 4-g jug Gallon in the 3-g jug Rule Applied
0 0
0 3
9
3 0
2
3 3
4 2
5/12
0 2
9/11
1 0
Asst.Prof
Artificial Intelligence
Production Systems:
The search forms the basic intelligent process it is useful to structure. A.I programs
in a way that facilities describing and performing the search process. Production system
provides such structures.
1) A set of rules, each consisting on the left side that determines the applicability of the
rule and on a right side that describe the operation to be performed if the rule is applied.
2) One/more knowledge /database that contain what ever information is appropriate for
the particular task. a production system has two memories
a) A production memory or long-term memory contains the production rules.
b) A working memory or short-term memory containing data about the current
problem.
3) A control strategy that specifies the order in which the rules will be compared to the
database and a way of resolving conflicts that arise when several rules match at once.
4) A rule applier.
The production rules operate on the knowledge base/database. Each rule has a
precondition that is either satisfied by the knowledge base. If the precondition is satisfied,
the rule can be applied. Application of the rule changes knowledge base. The control
system chooses which applicable rule should be applied and causes computation when a
termination condition on the knowledge base.
8-Puzzle:
Give an initial configuration of 8 numbered tiles on a 3X3 board, move the files in
such a way so as to produce a desired goal configuration of the tiles.
Asst.Prof
Artificial Intelligence
2 1 3 1 2 3
7 8 9 4 5 6
4 7 7 8
Heuristic search:
A heuristic search is a technique that improves the efficiency of search process. One
example of a good general-purpose heuristic search that is useful for a variety of
combinational problems is the nearest heuristic. Applying it to the traveling salesman
problem. Then we produce the following procedure.
Problem characteristics:
Heuristic search is very general method applicable to a large class of problems. It
encompasses a variety of specific techniques, each of which is particularly effective for a
small class of problems in order to choose the most appropriate method for a particular
problem. It is necessary to analyze the problem along several key dimensions. The
following characteristics are nothing but problem characteristics:
Asst.Prof
Artificial Intelligence
∫(x3+x2+2x+3sinx) dx
This problem can be solved by breaking it into 4 smaller problems, each of which we can
solve by using a small collection of specific rules:
∫ (x3+x2+2x+3sinx) dx
2x2/2 -3cosx
Using the technique of problem decomposition, we can solve very large problems,
very easily. This can be considered as one of the intelligent behaviors.
Asst.Prof
Artificial Intelligence
Consider the 8-puzzel problem in attempting to solve the 8-puzzel, we might make
a stupid move and realize that mistake and found we have done wrong step. But still
mistakes can be recovered it may be as easy as in the theorem proving problem here the
control strategy must keep track of all the moves. so that we can backtrack to the initial
state and start with some new move.
Consider the problem of playing chess. Here once we make move we can never
recover from that step.
These three problems, i.e. theorem proving, 8-puzzel, chess illustrate the differences
b/w three important classes of problems.
Ex: 8-puzzle
Ex: chess
Consider 8-puzzle problem. Every time we make a move .we knows exactly what will
happen. This means that it is possible to plan an entire sequence of moves and be confident
what the resulting state will be. We can backtrack to undone moves if they prove unwise.
Suppose we want to play bridge. Here we need to plan the entire hand before making
the first play. But we can not play with certainty. The outcome in this game is very
uncertain. In case of 8-puzzlethe outcome is very certain. To solve uncertain outcome
problems we need to allow for a process of plan revision to tale place as the plan is carried
out and the necessary feedback is provided. The disadvantage is that the planning in these
cases is often very expensive.
Asst.Prof
Artificial Intelligence
Consider the problem of answering questions based on a database of simple facts, such
as the following:
Suppose the question is “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
easily derive an answer to the question. In fact we can use either of two methods to give
answer to the question, which as shown below.
5) Marcus is dead.
Since we are interested in the answer of the question it does not matter which path we
follow. If we follow one path successfully, to the answer, there is no reason to go back and
A.Rakesh Babu M.C.A., M.Tech 16
Asst.Prof
Artificial Intelligence
see if some other path might also lead to a solution. Now, consider the traveling salesman
problem our goal is to find the shortest route that visits each city exactly once. Suppose the
cities to be visited and the distance b/w they are as shown below.
Once place the sales person could start is Boston. In that case, one path might be
followed as shown below.
Boston
3000
San
Francisco
1700
Dallas
1500
New
York
1200
Miami
1450 Total=8850
Boston
Here the total distance is 8850kms.but this may not be a solution to the problem, may
be other paths may give shortest route.
A.Rakesh Babu M.C.A., M.Tech 17
Asst.Prof
Artificial Intelligence
These toe examples illustrate the difference b/w any path problems and best-path
problems. Any path problems can often be solved in a reasonable amount of time by using
heuristic techniques that give good solution to explore.
Different problem domains represent their goal in different ways such as states/paths.
Consider water jug problem, whose solution is a desired state and traveling salesman
problems solution is the shortest path. At one level the difference can be ignored and all
can be formulated as ones in which only a state is required to be reported as a solution.
The knowledge require to solve a particular problem is depending upon the problem it
self. for example take playing chess, for this we need acknowledge of legal moves and
some simple control mechanism that implements an appropriate search procedure on the
other side, take a problem of design a robot have the knowledge about the source and
destination, car driving rules, operating knowledge of car, weather knowledge and so on.
These two problems illustrate the difference b/w problems for which a lot of knowledge is
important only to constrain the search for a solution.
If the level of interaction b/w the computer and its human users is problem-in-solution-
out then we can program computers to solve problems into the ways that majority of people
additional input and additional reassurance then we need to go for progress that interacts
with people.
When computers move into the areas of human lives like medical diagnosis people will
not blindly accept the systems solution. They need to interact with it. This we can
distinguish two kinds of problems.
1) Solitary: Here computer is given a problem description and it produces the answer
with out any intermediate interaction.
2) Conversational: Here intermediate interaction between the user and a computer is
necessary either to provide additional assistance to the computer or to provide
additional information to the user.
Asst.Prof
Artificial Intelligence
Ex:
Partially
Theorem proving Robot navigation
Commutative
Commutative
Production system/
Chemical analysis Bridge
Non partially
Commutative
Asst.Prof
Artificial Intelligence
CHAPTER - 3
HEURISTIC SEARCH TECHNIQUES
The Generate and text algorithm is a DFS procedure since complete solution must be
generated before they can be tested. In this form it is also known as British museum
algorithm a reference to method for finding an object in British museum by wandering
randomly.
HILL CLIMBING:-
Hill Climbing is a variant of generate and test in which feedback from the test
procedure is used to help the generator decide, which direction to move in the search space.
Hill Climbing is often used when a good Heuristic Function is available for
evaluating states but when no other useful knowledge is available.
For example, suppose you are in an unfamiliar city without a map and you want to
get down town you simply aim for the tall buildings. The Heuristic Function is just distance
between the current locations of the tall buildings. Absolute solutions exist whenever it is
possible to recognize a goal state by just examining it.
Algorithm:-
i. Evaluate the initial state. If it is also a goal state, then return it and quit. Otherwise
continue with the initial state as the current state.
ii. Loop until a solution is found (or) until there are no new operators left to be applied
in the current state.
a) Select an operator that has not yet been applied to the current static and apply it to
produce a new state.
Asst.Prof
Artificial Intelligence
A
4
3
5
2
A A A
Algorithm:-
i. Evaluate the initial state. If it is also goal state, then return it and quit otherwise
continue with the initial state as the current state.
ii. Loop until a solution is found(or) until a complete iteration produces no change to
current state
a) Let succ be a state such that any possible successor of the current state will be better
than succ.
b) For each operator that applies to the current state do:
o Apply the operator and generate a new state.
o Evaluate the new state. If it is a goal state, then return it and & quit. If not,
compare it to succ. If it is better than set succ to this state. If it is not better
leave succ alone.
o If the succ is better than current state, then set current state to succ.
Both basic and steepest-ascent Hill Climbing fail to find a solution.
Local maximum is a state that is better that all its neighbors but is not better than some
other states further away.
Asst.Prof
Artificial Intelligence
EX:-
2 6
8
Plateau is a flat area of the search space in which a whole set of neighboring states has
the same value.
Ex:-
5
5
Ridge is a special kind of local maximum. It is an area of the search space that is higher
than the surrounding areas & itself has a slope.
Ex:-
Asst.Prof
Artificial Intelligence
Simulated annealing:-
T= temperature
K=constant
The rate at which the system is cooled is called the “Annealing schedule”.
Algorithm:-
i. Evaluate the initial state. If it is a goal state, then return it and quit. Otherwise
continue with the initial state as the current state.
ii. Initialize BEST-SO-FAR to the current state.
iii. Initialize T according to the annealing schedule.
iv. Loop until a solution is found or until no new operators are left to be applied.
a. Select an operator that has not yet been applied to the current state and apply
it to get a new state.
b. Evaluate this new state, compute
∆E = value of current state – value of new state.
o If the new state is a goal state, then return it & quit
o If it is not a goal state but is better than the current state, then make
it the current state. Also set BEST-SO-FAR to this new state.
o If the new state is not better than the current state, then make it the
current state with probability P`
o Revise T as necessary
v. return BEST-SO-FAR as the answer:
Here we need to do enough exploration of the whole space early so that the final
solution is relatively insensitive to the starting state. These lower the chances of getting
caught at a local maximum, a plateau or a ridge.
Asst.Prof
Artificial Intelligence
Best first search combines the advantage of both depth-first and breadth first search
methods. It selects the most promising node at each step by applying an approximate
heuristic function the successors of this node are generated using applicable rules if one of
them is a solution, we quit if not all these new nodes are added to the nodes. So far
generated, and the process continues.
Figure shows the beginning of a Best- First search procedure.
4 6
2 3 4 2
6
7 7
8
5 5 6 7
9 10
11
To implement such a graph-search procedure, we will need to use two lists of nodes.
Open:-
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.
Closed:-
Nodes that have been already been examined. We need to keep these nodes in
memory if we want to search a graph rather than a tree.
Asst.Prof
Artificial Intelligence
The A* provides general guidelines with which to estimate goal distances for the
search graphs. The A* algorithm generates all successor nodes and computes an estimate of
the distance from the start node to the goal through each of the successors. It chooses the
successor with the shortest estimated distances for further expansion. The successors or this
node are then generated, their distances estimated and this process continues until a goal is
found or the search ends in a failure. The form of heuristic function for A* is
F*(n)-g*(n) +h*(n)
Where g*(n) =h*(n) =estimates of the cost (or) distances from the start node to node n and
the distances from node n a goal node
Algorithm:-
Asst.Prof
Artificial Intelligence
PROBLEM REDUCTION:
1) If the given problem is a primitive sub problem return the solution to it.
2) Otherwise, try breaking the given problem into sets of simpler sub problems, and call
the program recursively to try to solve the sub-problems.
3) If a set of sub problems is found such that all the sub problems. Can be solved,
combine the sub problem solutions in an appropriate way to form the solution to the
current problem.
The given problem is reduced to a set of simpler sub problems, the solution of which
will allow the original problem to be solved.
This reduction applied recursively until permissive sub problems which are
immediately solvable are reached. The resulting is called an AND/OR graph.
AND node:-
All sub problems must be solved in order to solve the main problem. An arc is
drawn across branches of an and node
OR node:-
Solution of any sub-problem will solve the main problem. A state space search
graph consists entirely of OR nodes.
Asst.Prof
Artificial Intelligence
To
AND
Steal a car
Rent a car
Terminal nodes
An AND|OR graph is searched recursively until the root node is solved, to solve a
node, attempt to solve each successor of a non terminal node sequentially.
i. If any successor of an AND node fails, the AND node fails immediately.
A.Rakesh Babu M.C.A., M.Tech 27
Asst.Prof
Artificial Intelligence
AO* ALGORITHM:-
I. Let graph consists only one of the node representing the initial state compute
h`(INIT)
II. Until INIT is labeled solved or hi (INIT) and become greater than FUTILITY,
repeat the following procedure.
a. Trace the marked arcs from INIT and select an unbounded node NODE.
b. Generate the successors of NODE if there are no successors then assign
FUTILITY. As h` (NODE). This means that NODE is not solvable. If there
are successors then for each one called successor, that is not also an ancestor
of NODE do the following.
Add successor to graph G.
If successor is not a terminal node, mark it solved and assign zero to its
h value.
Propagate the newly discovered information up the graph by doing the
following. Let S be a set of nodes that have been marked SOLVED.
Initialize S to NODE. Until S is empty repeat the following procedure.
a) Select a node from S call if CURRENT and remove it from S.
b) Compute h` of each of arcs emerging from CURRENT, assign
minimum h` to CURRENT.
c) Mark the minimum cost path a S the best out of CURRENT.
CONSTRAINT SATISFACTION:-
Algorithm:-
1. Propagate available constraints. To do this, first see OPEN to the set of all objects
that must have values assigned to then in a complete solution. Then do until an
inconsistency is detected or until OPEN is empty.
Asst.Prof
Artificial Intelligence
2) If the union of the constraints discovered above defines a solution, they quit and report
the solution.
3) If the union of the constraints discovered above defines a contradiction, they return
failure.
4) If the union of the above occurs, there it is necessary to make a guess at something in
order to proceed. To do this, loop until a solution is found or all possible solutions have
been eliminated.
a. Select an object whose value is not yet determined and select a way of
strengthening the constraints on that object.
Problem:
SEND
+MORE
MONEY
Asst.Prof
Artificial Intelligence
Constraints:
Initial state:
Goal State:
The digits to the letters must be assigned in such a manner so that the sum is satisfied.
Solution Process:
M=1, since two single digit numbers plus a carry cannot total more than 19.
S=8 or 9.Since S+M+C3>9 and M=1, S+1+C3 >9, S+C3>8 and C3 is at most 1.
O=0, since S+M (1) +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.
N=E or E+1, depending on the value of C2.But N cannot have the same as E. So
N=E+1 and C2 is 1.
In order for C2 to be 1, the sum of N+R+C1 must be greater than 9, So N+R must
be greater than 8.
Asst.Prof
Artificial Intelligence
Suppose E is assigned to the value 2.now in the next cycle the constraint propagator
observes that.
R=8 or 9, since R+N (3) +C1 (1 or 0) =2 or12. But N is already 3; the sum of these
non negative numbers cannot be less than 3. Thus R+3+ (0 or 1) =12 and R=8 or 9.
9567
+1085
-----------
10652.
MEANS-ENDS ANALYSIS
For solving any problem we can approach two methods. One is forward searching
(Initial state- Goal state.) and second one is backward searching (Goal state to initial
State).But sometimes we need combination of these two techniques. It first solves the
major parts of a problem and then solves the small problems. Such type of technique is
known as MEANS-ENDS ANALYSIS.
Algorithm:
MEANS-ENDS ANALYSIS (CURRENT, GOAL)
1. Compare CURRENT to GOAL. If there is no difference between them then return.
2. Otherwise, select the most important difference and reduce it by doing the following
until success or failure is signaled.
a) Select an untried operator O that is applicable to the current difference. If there are
no operators then single failure.
Asst.Prof
Artificial Intelligence
EXAMPLE:
Consider that there is a robot, which can walk, push objects etc... All the operations can be
performed by the robot are given as follows.
Holding (obj1)
Asst.Prof
Artificial Intelligence
Suppose that a problem of moving a desk with two things on it from one place to
another place is given to the robot. In order to move the desk the robot can use either the
PUSH operation or the CARRY operation. In the CARRY operation the preconditions we
have objects that should be small. We need to remove two things on the desk. So first
robot walk to desk, then remove the two things, then PUSH the desk to the location we
want and then place two things back on the desk.
Initially, we use the WALK operator for it to move to the desk. Then we use
PICKUP & PUTDOWN to remove the two things on the desk, then PUSH operator
followed by WALK in order to go back to the two things, now use PICKUP and CARRY
to carry the things to the desk and use PLACE operator to place it on the table. The
progress of MEANS-ENDS ANALYSIS is as follows.
Asst.Prof
Artificial Intelligence
CHAPTER - 4
KNOWLEDGE REPRESENTATION ISSUES
REPRESENTATION AND MAPPING:
To solve complex problems in A.I, we needs
The mapping between facts representation are shown in the below figure. The
mappings that are having the links in the program are called as representation mappings.
*
Facts Internal
Reasoning programs
Representation
*
English
representation
Asst.Prof
Artificial Intelligence
Spot is a dog.
The fact is represented by English sentence can also be represented in logic as
Dog (Spot).
Suppose consider another fact as
All dogs have tails.
Forward Backward
* Represent Represent *
Mapping Mapping
Internal Internal
representation representation
of initial facts of final facts
Operation of program
Asst.Prof
Artificial Intelligence
In the figure there is a dotted line originating from initial facts to final facts. This is
an abstraction. In order to get final facts firstly, the initial facts are to be represented in
some logic done on this logic. And some reasoning has to be done on this logic. That gives
final fact in logic. Now using backward representation we convert the final facts, which are
in logic in the understandable way.
Representing the facts in this way is simple but it provides weak inference
capability because even if cannot answer a simple questions like “Who is a heaviest
player?” In order get the answer for this question we need to add some another procedure.
A.Rakesh Babu M.C.A., M.Tech 36
Asst.Prof
Artificial Intelligence
Inheritable Knowledge:-
Person Right
Handed
Adult-
Male 5-10
Height
Height 6-1
Equal to bats
Base-ball
Handed player batting-avg
252
Isa Isa
Bat-avg
.106 Pitcher Fielder
Instance Instance
Asst.Prof
Artificial Intelligence
The structure shown in figure is called slot-and-filter structures. It may also call as
“semantic network” or “collection of frames”. Two important attributes that we use in
the figure are
i. Isa: - used to show “class inclusion”, which means that which class is
derived from which class.
ii. Instance: - used to show “class membership”. That can be used to create an
object to a particular class. The following are the attributes for a base-ball
player.
Isa: Adult male
Instance: (Equal, Handed)
Height: 6-1”
Batting-avgas: 252.
Algorithm:
To retrieve value ‘V’ for instance A of an instance object ‘O’
1) Find ‘O’ in knowledge base.
2) If there is a value for the attribute A, report that value.
3) Otherwise, see if there is a value for the attribute instance. If not, then fail
4) Otherwise, move to the node corresponding to that value and look for a value for
the attribute A. if one is found, report it.
5) Otherwise, do until there is no value for the “Is a” attribute or until an answer is
found.
a) Get the value “Isa” attribute and move to the node.
b) See if there is no value for the attribute A. if there is a report.
If we apply this procedure to the base-ball example knowledge base to derive
answer to the following queries:
Team (pee-wee-Reese) = Brooklyn dodgers
This attribute value is directly obtained from the attribute team. This attribute has
a value stored explicit in the knowledge base.
Asst.Prof
Artificial Intelligence
Inferential Knowledge:-
Property of inheritance is a powerful from of inference but it is not only
the useful from some times the traditional logic like predicate logic is also used to derive
new facts from old facts.
Example: x, y batter(x) ^ batted (x, y) ^infield-fly (y)out(x)
Procedural knowledge:-
We can represent the knowledge in a procedural way also. Production rules are the
best techniques to represent the knowledge in a procedural ways.
Example: Water jug problem
If x < 4 then fill x.
If x < 3 then fill y.
Important attributes:
Isa and instance attributes are important because they are present in almost every
problem domain. These attributes are important because they support property inheritance.
Asst.Prof
Artificial Intelligence
Inverse.
Inverse: -
We can represent the relationship between entities in two ways.
a) The first is to represent both the relationship in a single representation.
Ex: team (pee-wee, Brooklyn dodgers).
b) Here we use attributes that focus on a single entity but use them in a pairs. One
is the inverse of the other. For example,
One associated with pee-wee-Reese
Team = Brooklyn-dodgers.
One associated with Brooklyn-dodgers
Team-members = pee-wee-Reese
As our primitives in a series of situations.
Existence in an isa hierarchy:
There are attributes and specification of attributes. For example the attribute height
is a specialized of general attribute physical size which is in turn a specialization of
physical attribute. This generalization-specialization relationship supports property
inheritance.
Techniques for Reasoning About values:
The reasoning system must reason about values that are not given explicitly.
Information that helps us in reasoning includes.
Asst.Prof
Artificial Intelligence
Example: Age of a person cannot be greater than the age of the person’s
parent.
c. Rule for computing the value whenever it is required. They cannot be backward
rules or they can also be forward rules.
Asst.Prof
Artificial Intelligence
Ex: an extensional definition of the set of our sun’s planets on which people live is [earth]
an intentional description is given as
The advantages that an intentional definition has over extensional definition are….
a. Intentional representations’, can be describe infinite sets and sets not all of
whose elements are explicitly know.
Ex: Sets of prime numbers or kings of England.
Intentional definition allows us to depend on parameters that can be change with time or
location.
Ex: “The president of U.S used to be pemcrot”.
Asst.Prof
Artificial Intelligence
In order to solve the problems given above, there are two methods.
c. Locate one major clue and use that to select an initial structure.
FRAME PROBLEM:-
Frame problem is a problem of representing the facts that change as well as
those that do not change. For example, consider a table with a plant on it under a window.
Suppose we move it to the centre of the room. Here we must infer that plant is now in the
centre but the window id not.
Frame axioms are used to describe all the things that do not change operator
is applied in state to go to another state say n+1.
Asst.Prof
Artificial Intelligence
CHAPTER - 5
USING PREDICATE LOGIC
The logical formalism is used to derive new knowledge from old. i.e., we called
mathematical deduction.
Not
“v” or
“^” and
For all
There exits
It is raining
RAINING
It is sunny.
SUNNY
It is windy.
WINDY
If it is raining, then it is not, sunny.
RAINING SUNNY
Asst.Prof
Artificial Intelligence
Socrates is a man.
We could write as
SOCRATESMAN and
Plato is a man.
PLATOMAN
The above facts can be represent as much better as
Man (Socrates)
Man (Plato)
But that representation is fails to capture the relationship between and individual
being a man and that individual being a mortal. We need variables and quantifiers to
represent logic. In predicate logic, we can represent real-world facts as statements
written as wff’s. So now we explore the use of predicate logic as a way of representing
knowledge by a specific example.
The above facts can be represented as a set of wff’s in predicate logic as follows.
1. Man (Marcus)
2. Pompeian (Marcus)
3. x: Pompeian(x)->roman(x)
4. Ruler (Caesar)
5. x: Roman(x) ->loyal to(x, Caesar) V hate(x, Caesar)
6. x: y: loyal to(x, y)
7. x: y: Person(x) ^ruler(y) ^ try assassinate(x, y)
8. Loyal to(x, y)
9. Tryasssainate (Marcus, Caesar)
Asst.Prof
Artificial Intelligence
Now suppose that we want to use these statements to answer the question.
Now let’s try to produce a formal proof, reasoning backward from the desired goal.
^ (7)
^ (4)
Person (Marcus)
^ (8)
Person (Marcus)
1. Man (Marcus)
2. Pompeian (Marcus)
3. x: Pompeian(x) ->roman(x)
4. Ruler (Caesar)
5. x: Roman(x) ->loyal to(x, Caesar) V hate(x, Caesar)
Asst.Prof
Artificial Intelligence
The class and super class membership are important facts that need to be represented,
those membership need not to be represented with predicates instance and Isa.
gt(1,0) lt(0,1)
gt(2,1) lt(1,2)
gt(3,2) lt(2,3)
| |
| | . .
For example the simple fact (2+3)>1 might be represented as gt(2+3,1).to calculate
the truth of gt(2+3,1) the value of the plus function is evaluated first and then the
arguments 2+3(=5) and 1 are sent to the computable predicate gt.The use of computable
functions and predicates is illustrated below.
Asst.Prof
Artificial Intelligence
7. It is now 1991
Now=1991
1. Man (Marcus)
2. Pompeian (Marcus)
3. Born (marcus,40)
4. x: men(x)mortal(x)
5. x: Pompeian(x)died(x,79)
6. Erupted (volcano, 79)
7. x: t1: t2: mortal(x)^born(x, t1)^ gt(t2-t1,150)died(x,t2)
8. Now=1991
9. x: t:[alive(x, t) dead(x, t)]^[ dead(x,t)alive(x, t)]
10. x: t1: t2:died(x,t1)^ gt(t2,t1)dead(x,t2)
Asst.Prof
Artificial Intelligence
Now let’s attempt to answer the question “Is Marcus alive?” By proving
alive(Marcus, now)
alive(Marcus, now)
(9)
(10)
(5)
(2)
gt (now, 79)
(8)
gt (1991, 79)
(Compute gt)
Nil
From looking at the proof we have just shown, two things should be clear.
(Modus ponenes is an important inference rule. it is the operation that produces the wff w2
from wff of the form w1 and w1->w2)
The term nil at the end of the proof indicates that the list of conditions remaining to
be proved to be approved is empty and so the proof has succeeded.
Asst.Prof
Artificial Intelligence
RESOLUTION:
Resolution is a procedure to prove a statement. It specifies the proof procedure by
first converting the statements into a clause form (convenient standard form).Further it
produces proofs by “refutation” i.e., it attempts to show that the negation of the statement
produces a contradiction with the known statements.
Winter V summer
~Winter V cold
In these two clauses either winter or ~winter is going to be true at any point. If
winter is true then cold must be true to guarantee the truth of the second clause. If ~winter
is true, then the summer must be true to guarantee the truth of the first clause. Thus from
these two clauses we can deduce the resolve.
Summer V cold
Resolution procedure operates by taking two clauses that each contains the same
literal. The literal must occur in positive from in one clause and in negative form in the
order. The resolving is obtained by combining all of the literals of the two parent clauses
except the ones that cancel. If the clause that is produced is
Algorithm:
Asst.Prof
Artificial Intelligence
( p) = p
(a ^ b) = av b
(a v b) = a^ b
x: a(x) = x: a(x)
x: a(x) = x: a(x)
x: p (a) v b: Q(b)
Asst.Prof
Artificial Intelligence
7. Convert the matrix into a conjunction of disjoints the formula produced in step(6) will
become as (here we can remove the brackets)
Roman(x) v know (x, Marcus) v
hate(x, Caesar) v hate(y, z)v thinkcrazy(x, y).
( we applied [a v (b v c) = (a v b) v c] (associative property))
It is also frequently necessary to exploit the distributive property
i.e. (a ^ b) v c = (a v c) ^ (b v c)
[winter v (summer ^ wearing sandals) ]
^ [wearing boots v (summer ^ wearing sandals)]
8. Create a separate clause corresponding to each conjunct.
9. Standardize apart the variables in the set of clauses which are generated in step (8).
2. Negate p and convert the result to clause form add it to the set of clauses obtained in
step1.
b. Resolve them together. The resulting clause, called the resolving, will be the
disjunction of all the literals of both of the parent clauses.
c. If the resolving is the empty clause, then a contradiction has been found. If it is
not, then add it to the set of clauses available to the procedure.
Asst.Prof
Artificial Intelligence
Example:
P P (1)
TVQ (4)
T T (5)
Pv qvR R
PV Q P
TvQ Q
T T
{ }
Asst.Prof
Artificial Intelligence
UNIFIACTION ALGORITHM:
In propositional logic, it is easy to determine that two literals cannot both be true at
the same time. Simply look for L and L. In predicate logic, this matching process is more
complicated since the arguments of the predicates must be considered. For example,
man (john) and man (john) is a contradiction, while man (john) and man (spot) is not.
To determine these contradictions, we need a matching procedure that compares two
literals and discovers whether there exists a set of substitutions that makes them identical.
There is a straight forward recursive procedure that does this matching. It is called
unification algorithm.
To unify two literals, we first check if their initial predicate symbols are the same. If
same, we proceed. Otherwise there is no way they can be unified. For example two literals
Cannot be unified. If the predicate symbols are match, then we check the arguments, one
pair at a time.
Algorithm:
Asst.Prof
Artificial Intelligence
2. If the initial predicate symbols in L1 and L2 are not identical, then return {FAIL}.
4. Set SUBST to NIL. (At the end of this procedure, SUBST will contain all the
substitutions used to Unify L1 and L2.
2. SUBST:=APPEND(S,SUBST)
6. Return SUBST.
Two literals are contradictory if one can be unified with the negation of the other.
for example man(x) and &man(spot) are contradictory, since man(x) and man(spot) can be
unified .in predicate logic unification algorithm is used to locate pairs of literals that cancel
out. if is important that of two instances of the same variable occur, they must be given
identical substitutions. The resolution algorithm for predicate logic as follows.
Asst.Prof
Artificial Intelligence
Algorithm:
2. Negate P and convert the result to clause form add it to the set of clauses obtained in
step1.
b) Remove them together. The resulting clause, called the resolvent, will be the
disjunction of all the literals of both of the parent clauses. If there is a pair of literals T1 and
T2 such that one parent clauses contains T1 and other contains T2 and if T1 and T2 are
unifable, then neither T1 nor T2 complementary literals.
c) If the resolving is the empty clause, then a contradiction has been found. If it is
not, then add it to the set of clauses available to the procedure.
1. Man (Marcus)
2. Pompeian (Marcus)
3. Pompeian(x1) ->roman(x1)
4. Ruler (Caesar)
6. loyalto(x3, f1(x3))
Asst.Prof
Artificial Intelligence
Marcus/x2
Marcus/x1
Marcus/x4, Caeser/y1
8 tryassasinate(marcus,Caeser)
{ }
Asst.Prof
Artificial Intelligence
Natural Deduction
The disadvantage of Predicate logic is i.e., it is not having any inference programs. So we
have to make use of a resolution outcome, but the resolution is in clause form. By using
clause form, the original meaning be destroyed or changed.
Ex: If we consider the statement ab means that b is depending only on existing of a. i.e.,
b is dependent on a. But as we convert the system into clause form we can has a v b. The
symbol “v” (OR) is we have to prove either a as true. i.e., the statement is true. The
whole statement is considered as b is not depends on a. So, this statement is reverse of the
first statement (a b).Suppose we represent the statement into natural deduction the
meaning of the sentence may not be changed.
Asst.Prof
Artificial Intelligence
CHAPTER - 6
REPRESENTING KNOWLEDGE USING RULES
We have to represent the knowledge in two ways. They are
1. Declarative knowledge
2. Procedural knowledge
1. Man (Caesar)
2. Man (Marcus)
3. person (Cleopatra)
4. x: man(x) person(x)
1. Man (Caesar)
2. Man (Marcus)
3. Person (Cleopatra)
4. x: man(x) person(x)
Asst.Prof
Artificial Intelligence
4. Poodle (fluffy)
The predicate logic forms can be converted into PROLOG programs as follows
2. a) pet(x):- cat(x)
b)Pet(x):- dog(x)
3. a)dog(x) :- poodle(x)
b)Small(x):- poodle(x)
4. Poodle (fluffy)
The following constrains can be used to convert the predicate logic statements into
PROLOG programs
(i) ab = b: -a
(ii) Implication before ^ => put, (comma)
(iii) Implication after ^ => write as 2 stmts
(iv) Implication before v => write as 2 stmts
(v) Implication after v => put , (comma)
2. x: Calico(x) Cat(x)
4. Tuna (Charley)
5. Tuna (Herb)
6. Calico (Pussy)
Asst.Prof
Artificial Intelligence
PROLOG programs:
Using backward chaining find “what does pussy likes to eat?” for this consider
likesto(x, y)
Cat(x), fish(y)
Fish(x) (3)
Tuna(x) (4)
{ } x= charley
Asst.Prof
Artificial Intelligence
PROLOG programs:
Horn clause
The logical assertion in the PROLOG language is the set of horn clauses. A positive
literal is called horn.
In the PROLOG statements, there is no logical assertion. The only assertion is horn
clause. In this stmts, the variables can be referred in capital letters and the constants are
denoted to small letters.
Asst.Prof
Artificial Intelligence
Apartment(x) (1)
{ } x=fluffy x=fluffy { }
In the above example we get 2 alternatives pelf(x), small(x). First we start with the
first sub goal pet(x). It again contains 2 sub goals dog(x), cat(x). If we go on proceeding
with cat(x) we get a dead end. PROLOG programming starts with root node.
It finds a fact (or) the left hands of the rules to match with the root node, if a rule is
found the R.H.S will be the resolvent.
In the above example three are 2 sub goals pet(x) and small(x) in the resolvent. If
both of the sub goals are true then a value for a variable ‘y’ can be found. Consider a sub
goal pet(y) with has 2 alternatives with
Pet(x); - dog(x)
Asst.Prof
Artificial Intelligence
A PROLOG tries with the first alternative until a dead end is reached or a solution
is found. The first alternative leads to a dead end in the above example and ‘y’ is bounded
to a value fluffy when second alternative is explores.
REASONING:
The aim of search procedure is to discover a path through a problem space from an
initial configuration to a goal state. There are actually 2 directions in which a search colud
proceed.
a) Forward Reasoning
b) Backward Reasoning
a). Forward Reasoning:
When we have set of input to prove current situation. Those are applied on the
initial state. The forward rules encode the knowledge when certain input conditions are
true.
These rules are used to sub goals-backward rules are the rules which encode the
knowledge when sub goals are true.
The following factors that influence the question of whether it is better to reason
forward or backward.
Asst.Prof
Artificial Intelligence
They are good for goal directed problem solving. For example a query system would
probably use backward chaining to reason about answer user questions.
Forward chaining rule system left sides of rules are matched against the state description.
Rules that match dump their right hand side assertion into the state, and process repeats.
Matching is typically more complex chaining system that backward once .
Matching:
Matching is a process of comparing two or more structures to discover their
difference or similarities. Matching is used to the best of a no of alternatives or retrieves
items from a database or knowledgebase. Different matching processes are,
Indexing
Matching with variables
Complex and approximate matching
Conflict resolution
Indexing:
In indexing the correct state is used as an index into the rules in order to select the
matching once. For example in chess, we assign a no to each board position. Then we use a
hosting function to treat the no as an index into the rules.
In this case we will match many rules against many elements in the state description
simultaneously. One efficient algorithm RETE, which gains efficiency from three major
sources.
Asst.Prof
Artificial Intelligence
Frame-I frameII
Similarities similarities
Mammal(x) stripes(x)
Carnivorous(x) sports(x)
In RETE process , first we have to verify the dissimilarities rules and after that we
verify the similar rules and also we have to identify which rule have less no of sub goals
and which rule has more no of sub goals.
Asst.Prof
Artificial Intelligence
Conflict Resolution:
The conflict resolution is a strategy in which we incorporate the decision making
into the matching process. We have three basic approaches.
Control Knowledge:
Knowledge about which paths are most likely to lead quickly to a goal state is often
called, search control knowledge. It can take many forms.
Asst.Prof
Artificial Intelligence
a) Long-term memory:
It contains all the set of productions or rules.
b) Short-term memory:
It is also called as working memory. In this the facts are deducted by rules.
c) All problems solving activity takes place as a state space traversal i.e. which rule to
be applied.
d) It keeps track of all the intermediate and the final result.
Asst.Prof