94%(16)94% нашли этот документ полезным (16 голосов)

4K просмотров68 страницJan 02, 2010

© Attribution Non-Commercial (BY-NC)

PDF, TXT или читайте онлайн в Scribd

Attribution Non-Commercial (BY-NC)

94%(16)94% нашли этот документ полезным (16 голосов)

4K просмотров68 страницAttribution Non-Commercial (BY-NC)

Вы находитесь на странице: 1из 68

Artificial

intelligence

Master of Computer Applications

Budampadu, Guntur

Affiliated to Acharya Nagarjuna University

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.

tasks that apparently require intelligence when performed by humans.

problems which can be solved by humans.

systems that is computer systems that exhibit the characteristics we associate with

intelligence in human behavior-understanding language, learning, reasoning and

solving problems.

Asst.Prof

Artificial Intelligence

monitoring.

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:-

applications include mobile robot navigation, complex manufacturing tasks, analysis of

satellite images, and medical image processing.

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.

problem is understanding what the image represents vision takes lots of computation.

Speech understanding:

computer interfaces. Speech understanding is available now on personal computers. These

A.Rakesh Babu M.C.A., M.Tech 4

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.

understand English allows non- program mess to use them with little training.

language generation. It is much easier than natural language understanding

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:-

applications include logistics; manufacturing scheduling planning steps in manufacturing is

to construct a desired product.

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

A.Rakesh Babu M.C.A., M.Tech 6

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.

A state space represents a problem in terms of states and operators that change states

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:

Board configuration.

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.

Space.

Make a representation for the initial state from the given data.

Write programs to represent operators that change a given state representation to

new state representations.

Write programs to delete terminal state.

2) How well structured is the domain?

3) What knowledge about the domain can be used to guide the search?

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.

with minimum cost?

Asst.Prof

Artificial Intelligence

There are two jugs a 4-Gallon one and 3-Gallon one. Neither has any measuring

marker on it. There is a pump that can be used to fill the jugs with water how can you get

exactly 2- Gallon water into the 4- Gallon jug?

The state space for this problem can be described as the set of ordered pairs of

integers(x, y) such that x=0, 1, 2, 3, 4 and y=0, 1, 2, 3.

X represents the number of gallons of water in the 4- Gallon jug.

Y represents the number of gallons of water in the 3- Gallon jug.

The state space is (0, 0).

The goal state is (2, n) for any value of n.

Operators:

1. (x, y) (4,y) fill the 4-g jug

If x<4

If y<3

3. (x, y) (x-d, y) pour some water out of the 4-g jug

If x>0

4. (x, y) (x, y-d) pour some water out of the 3-g jug

If y>0

5. (x, y) (0, y) empty the 4-g jug on the ground

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

Sales man has a list of cities, each of which he must visit exactly once. Three are

direct roads b/w each pair of cities on the list. Find the route the salesman should follows

for the shortest possible round trip that both starts and finishes at any of the cities.

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.

2) Select the next city, look at all cities not yet visited and select the one closet to the

current city go to it next

3) Repeat step2 until all cities have been visited.

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:

2) Can solution steps be ignored or undone if they do not move towards a solution?

3) Is the problem universe predictable?

4) Can we find a good solution to the problem with out comparing to all other possible

solution?

5) Is the desired solution is path/state?

A.Rakesh Babu M.C.A., M.Tech 13

Asst.Prof

Artificial Intelligence

search?

7) Can a system return the solution/will the solution of the problem require interaction

between the system and a person?

∫(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

lemma that will be useful. Later we may realize that the lemma is not at all useful. We may

start with another one to prove the theorem here we can simply ignore the first method we

have adopted to find the solution.

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: Theorem proving

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:

3) Marcus was born in 40 A.D.

4) All means are mortal.

5) All Pompeian’s died when the volcano erupted in 79 A.D.

6) No mortal lives longer than 150yers.

7) It is now 1991 A.D.

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.

2) All men are mortal.

3) Marcus is mortal.

4) Marcus was born in 40 A.D.

5) It is now 1991A.D.

6) Marcus age is 1951 years.

7) No mortal lives longer than 150 years.

8) Marcus id dead.

Or

2) All Pompeian’s died in 79 A.D.

3) All Pompeian’s are dead now.

4) Marcus was Pompeian.

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

Production system provide us with a good set of production rules, by using which we

can solve the problems. Two questions may a raise at this point of time.

2) Can we draw any relationship between the problem types and the types of

production systems suited to solve the problems?

There are four categories of production systems:

rule never prevents the later application of another rule that could have been applied at

the time the first rule is selected.

2) A non monotonic production system is one in which the application of a rule prevents

the later application of another rule that would have been applied at the time the first

rule was selected.

3) A partially commutative production system is a production system with the property

that if the application of a particular sequence of rules transforms state p into state q.

then any permutation of those rules is allowable also transforms state p into state q.

4) A commutative production system is production system that is both monotonic and

partially commutative.

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

Algorithm:-

ii. Text to see if this is actually a solution by comparing with goal.

iii. If solution has been found quit otherwise return to step1.

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

If it is a goal state, then return it and quit

If it is not a goal state but better than the current state, then make it the

current state.

If it is not better than the current state, then continue in the loop.

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:-

i. Back track to some earlier node and try going to different direction.

ii. Make a big jump in some direction to try. To get a new section of the search

space.

iii. Apply two (or) more rules before doing the test suppose we use the following

heuristic function operators:

Pick up one put it on the table

Pick up one it on the other

Asst.Prof

Artificial Intelligence

Simulated annealing:-

descending. Here we use the term objective function which aims at minimizing the value

simulated annealing is patterned after the physical process of annealing in which physical

substances such as metals are melted and then gradually cooled until some solid state is

reached. The goal is to produce a minimal energy final state.

There is some portability that a transition to a higher state will occur the probability

is given by

P=e-∆E/KT

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

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

c) For each success do:

If it has not been generated before, evaluate it add it to

OPEN, and record its parent.

If it has been generated before, change the parent if this new

path is better than the previous one.

A* ALGORITHM:-

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:-

the path).

2. Compute g(SUCCESSOR) = g( BESTNODE) cost of getting from BESTNODE to

SUCCESSOR.

3. If SUCCESSOR is same as any node to OPEN, call that node OLD and add OLD

to BESTNODE’S SUCCESSORS. Check g (OLD) AND g(SUCCESSOR).If

g(SUCCESSOR) is cheaper then rest OLD’S parent link to point to BESTNODE.

Update g (OLD) and f’ (OLD).

4. If SUCCESSOR was not on OPEN, see if it is on CLOSED. If so call the node

CLOSED OLD, and better as earlier and set the parent link and g and f’ values

approximately.

5. If SUCCESSOR was not already on earlier OPEN or CLOSED, then put it on

OPEN and add it to the list of BESTNODE’S successors.

Asst.Prof

Artificial Intelligence

PROBLEM REDUCTION:

problem to a set of easier sub problems whose solutions, if found, can be combined to form

a solution, to the hard problem, the procedure is as follows.

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

to JNU

OR

Drive Take a taxi

Take a

subway

Steal a car

Rent a car

number Phone Taxi

Terminal nodes

2) If a non terminal OR node has any solved successors, then it is a solved node.

3) If all of the successors of a non terminal AND node are solved, then it is a

solved node.

4) The problem is solved if the start node is solved.

5) A solution graph is a sub graph of solved nodes that demonstrates that the start

node is solved.

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

The search time may be improve by ordering consideration of the nodes:

To solve an AND node try first to solve those successors that are most likely

to fail.

To solve an OR node try first to solve those successors that are most likely

to succeed.

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:-

which the goal satisfies a given set of constraint satisfaction problems can be solved by

using any of the search strategies.

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

constraints that apply to OB.

b) If this set is different from the set that was assigned. The last time OB was

examined or if this is the first time OB has been examined, then adds to

OPEN all objects that share any constraints with OB.

c) Remove OB from OPEN.

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.

augmented by the strengthening constraint just selected.

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:

constraints.

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.

A.Rakesh Babu M.C.A., M.Tech 30

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.

Like this, we continue for further cycles we will get the solutions. Finally the values

can be assigned to the letters are as follows in the solutions state.

M =1 O=0 R=8 E=5 S=9 N=6 D=7 Y=2

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.

differences between the current state and the goal state. In backward chaining the operator

are selected and then sub goals are setup to establish the preconditions of operators is called

operator subgoaling. The main aim of means-ends analysis is apply the operator’s

recursively, which will reduce the difference between current states to goal state.

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

operators O to current. Generate two description O-START, a state in while O’s

preconditions are satisfied and O-RESULT that results when O is applied to O-

START.

(O-RESULT, GOAL)) are successful, then signal success and return the result of

concatenating FIRST-PART, O, and LAST-PART.

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.

PUSH (obj.loc) at (robot, obj) ^large (obj) ^ at (obj, loc) ^

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

ii. Mechanism for manipulating the knowledge is found a solution to the problem.

There are many ways of representing of knowledge, in any representation there are

two different kinds of entities:

b) Representation of facts in some logic

To structure the above two entities has two levels.

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

understand easily.

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.

From above two facts which are represented in logic. We can write as

Using backward mapping we could generate the English sentence.

The above explanation is clearer with following diagram.

Initial Initial

facts -- facts

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.

A good system for the representation of knowledge in a particular domain it should

contain following properties.

i. Representational Adequacy: - The ability of representation all kinds of

knowledge that are needed in that domain.

ii. Inferential Adequacy: - The ability to manipulated the representational structures

in such a way we can derive new structure from old.

iii. Inferential Efficiency: - The ability to add a new info the database to work in best

way.

iv. Acquisition Efficiency: - The ability acquires new information easily.

Simple Relational Knowledge:

The simple way to represent the facts is as a set of relations as we do in the

database.

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:-

values. But inheritable knowledge representation allows this type of representation.

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

Chicago Three-finger-

cubs brown Reese dodgers

A.Rakesh Babu M.C.A., M.Tech 37

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.

Because there is no value for batting average stored explicitly for three-finger-

brown. We have to follow the attribute instance to obtain the value of that attribute.

A.Rakesh Babu M.C.A., M.Tech 38

Asst.Prof

Artificial Intelligence

Because there is no explicit value for height we have to follow the value. So we

follow attribute ‘is a’ to obtained the value

Bats (three-finger-brown) =right

Because there is no value for data stores explicitly for the three-finger-brown we

have to follow the attribute instance to obtained the value of that attribute and there is ‘Is a’

to obtained value. This algorithm is so simple and we concentrate on only default values.

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.

To represent varies kinds of real –world knowledge. We need to discuss several

issues. They are as follows.

1) Important attributes.

2) Relationship among attributes.

3) Choosing the granularity of representation.

5) Finding the right structure as needed.

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

The four properties of attributes are:

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.

Example: Length must be a number.

b. Constraints on the value

A.Rakesh Babu M.C.A., M.Tech 40

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.

A specific attribute may sometime take unique value. For example, a base ball

player can be in only one team at one time. Similarly another example, a person can have

only one height at a given time.

We can break the details into lower level primitives. For example, john spotted sue

can be represented as

Spotted ((john)) object (sue) this may give answer to the question.

Who spotted sue?

The obvious answer that may give is ‘yes’

But for A.I to reason it out we need to add fact.

Spotted (x, y) saw (x, y)

Advantages:

The rules that are used to derive inferences from that knowledge must be written only

in the form of primitives rather than in the form of many other ways.

Disadvantages:

Simple high level facts may requires a lot of storage when broken down into low

level primitives.

Example: john punched Mary and Mary punched john.

Substantial work must be done to reduce the knowledge into primitive’s form, if

knowledge I in high level form.

In many domains, it is not clear what the low level primitives should be

Example: john broke the window.

Asst.Prof

Artificial Intelligence

We need to represent sets of object because there may be some properties which are

true of sets but are not true of individual members and also to see that if a property is true

of all elements of a set, then it is more efficient to associate it once with the set rather than

to associate it explicitly with every element of set.

Extensional definition: - This definition deals with listing the members.

Intentional definition: - It provides a rule such that, when a particular object is evaluated,

returns true or false depending on weather the object s belong to the set or not.

Ex: an extensional definition of the set of our sun’s planets on which people live is [earth]

an intentional description is given as

An extensional definition and intentional definition may not correspond one to one

with each other. In the above example the extensionally defined set {earth} may have any

intentional definitions.

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”.

In order to access the right structure for describing a situation, we need to solve the

following problems:

i. How to perform an initial selection of the most current structure?

ii. How to fill in the details?

iii. If the one chosen doesn’t turn out to be appropriate, then how do we go for a better

one?

iv. What to do if none of the structures that are available is appropriate?

v. When we can go for a new structure?

Asst.Prof

Artificial Intelligence

In order to solve the problems given above, there are two methods.

There are two important structures for selection of an initial structure.

a. Index structure directly by specific English words.

b. Consider a major concept as a pointer to all of the structure

Ex: the concept steak might point to two scripts, one for restaurant and other

for super script.

c. Locate one major clue and use that to select an initial structure.

Once we find a structure and if it doesn’t seem to be appropriate then we would opt

another choice. The different ways in which this can be done are:

Refer to specify links between the structures in order to follow new directions to

explore.

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

The use of propositional logic is used to represent the world knowledge.

Propositional logic is simple to deal a decision procedure for the facts. We can easily

represent real-world facts as logical propositions can be written as well-formed formulas

(wff’s) in Propositional logic. Some simple facts in propositional logic as follows.

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.

2. Marcus was a Pompeian

3. All Pompeian’s were Romans

4. Caesar was a ruler

5. All Romans were either loyal to Caesar or hated him

6. Everyone is loyal to someone.

7. People only try to assassinate ruler they are not loyal to

8. Marcus tried to assassinate Caesar

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)

The specific attributes instance and is a plays an important role in a particularly

useful form of reasoning, property inheritance. The predicate instance is a binary one,

whose first argument is an object and whose second argument is a class to which the object

belongs. But these representations don’t use an explicit is a predicate.

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)

2. Instance (Marcus, Pompeian)

3. x: instance(x, Pompeian) instance(x, Roman).

4. Instance (Caesar, ruler)

5. x: instance(x, Roman) loyalto(x, Caeser)V hate(x, Caeser)

Asst.Prof

Artificial Intelligence

2. Instance (Marcus, Pompeian)

3. Isa (Pompeian, Roman)

4. Instance (Caesar, ruler)

5. x: instance(x, roman)loyalto(x, Caesar) V hate(x, Caesar).

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.

In predicate calculus it is often useful to have computable a functions and

computable predicates for this we want to express simple facts. Such as the following

greater than and less than relationships:

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.

Man (Marcus)

Pompeian (Marcus)

Born (Marcus, 40 A.D)

x: Men(x) mortal(x)

Asst.Prof

Artificial Intelligence

Erupted (volcano, 79) ^ x :{ Pompeian(x) died(x, 79)}

x: t1: t2: mortal(x) ^ born(x, t1) ^ gt (t2-t1, 150) ->dead(x, t2)

7. It is now 1991

Now=1991

x: t: alive (x, t) ->&dead(x, t) ^ [ dead(x, t) ->alive(x,t)]

x: t1: t2:died(x,t1) ^gt(t2,t1)->dead(x,t2)

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.

- A variety of processes such as matching, substitution and application modus

pones are involved in the production of proof.

(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.

Resolution can be applied to certain class of wff’s called “clauses.” a clause is

defined as a wff’s consisting of a disjunction of literals. The resolution process when it is

applicable is applied to as pair of parent clauses to produce a derived clause.

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:

transformation on the well formed formula, then the formula will becomes as,

x: [Roman(x) ^ know(x, Marcus)] v

[ hate(x, Caesar) v ( y: ( y: hate(y, z)] v think crazy (x, y))]

2. Reduce the scope of search of each (negation) to a single term, using facts,

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: [ roman(x) v know(x ,Marcus)] v

[hate (x, Caesar) v ( y: z: hate(y, z) v thinkcrazy(x, y))]

3. Standardize variable so that each quantifier binds a unique variable. for example, the

formula

x: P (a) v a: Q (a) will be converted to

x: p (a) v b: Q(b)

4. Move all quantifiers to the left of the formula without changing their relative order.

performing this operation on the formula of step 2, gives

[hate (x, Caesar)v( hate (y ,z)v think crazy(x, y))]

5. Eliminate existential qualifiers. for example the formula

y: President(y)

Can be transformed into the formula,

President (S1)

Where S1 is a function with no arguments that somehow produces a value that satisfies

President.

6. Drop the prefix .the formula produced in step 4 will become as,

[ Roman(x) v know(x, Marcus)] v

[ hate(x, Caesar) v ( hate(y,z) v thinkcrazy(x, y))]

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).

In proposition logic, the procedure to produce a proof by resolution of preposition P

with respect to a set of axioms f is the following:

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.

can.

2. A variable can match another variable, any constants or a function or predicate

expression, subject to the condition that function must not contain any instance of

variable being matched.

3. The substitution must be consisting. substitute y for x now and then z for x later is

inconsistent(a substitution y for x written as y/x)

representing a composition of the substitutions that were performed that a match was found

any substitutions .if the list unification procedure failed.

Algorithm:

Asst.Prof

Artificial Intelligence

(L2/L1).

(L1/L2).

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.

th th

a) Call Unify with the i argument of L1 and the i argument of L2, putting

result in S.

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

the representation itself.

chaining method.

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)

are always implicitly quantified.

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:

2. Cat(x) :- calico (x)

3. Fish (x): - tuna (x)

4. Tuna (charley)

5. Tuna (herb)

6. Calico (pussy)

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

2. Apples are food

3. Chicken is a food

4. Anything anyone eats and is not killed by his food

5. Bill eats peanuts and is still alive

6. Sue eats everything bill eats

2. food (Apples)

3. foods (Chicken)

4. x : y : eats (x, y) ^ killed (x, y) food(x)

5. a) eats (Bill, Peanuts)

b) killed (bill, peanuts)

6. x : eats (Bill, x) eats (Sue, x)

PROLOG programs:

2. food (Apples)

3. food (Chicken)

4. food(x) :- eats (x, y), killed(x ,y)

5. a) eats (Bill, Peanuts)

b) killed (Bill, peanuts)

6. eats(Sue, x) :- eats (Bill, x)

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.

2. x : cat(x) ^ dog(x) pet(x)

A.Rakesh Babu M.C.A., M.Tech 62

Asst.Prof

Artificial Intelligence

4. poodle (fluffy)

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.

We prefer to move from the smaller set of states to the largest set of states.

ii) In which directions is the branching factor greater?

(Branch Factor: - the average no of nodes that can be reached directly from a single node.)

We refer to proceed in the direction with the lower process to a user.

iii) Will be program be asked to justify its reasoning process to a user?

It is important proceed in the direction that corresponds more closely with the way

the user will think.

iv) What kind of event is going to trigger a problem solving proceeds?

backward reasoning is more natural.

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.

Whenever we apply a rule on the current state. Some properties will be added

and some other properties are deleted and some times the rule will not be applicable.

If no rule will not be applicable to the problem, the RETE process will tell

which rule applicable to the pre-state is not applicable to the current state.

Asst.Prof

Artificial Intelligence

ii) Jaguar(x) mammal(x) ^ sports (x) ^ carnivorous(x)

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.

There may be variable binding conflicts that prevent the rule from firing. For

example, consider the following facts.

Son (john, David)

The individual preconditions of the rule is

x: y : son(x, y) ^ son(y, z)grandparent(y, z).

Where x=John and y=David.

For this first time, x, y has initial values after the completion of first predicate here

x,y are binded variables.

For the second time, if y=bill which is not accepted because ‘y’ has already a value is

given. So, we can not give another value ‘y’. Therefore, ‘y’ is a binding up variable.

The RETE takes the binding up of variables to the problem solving.

Asst.Prof

Artificial Intelligence

An approximate matching is one which used, when the pre conditions

approximately match the current situation.

One of the complex problem, we can take as a speech understanding. It understand

the word and proceedings the matching. If that time it takes appropriate words.

The conversion between ELIZA, an A.I problem and the user. Here ELIZA will try

to match the left side of the rule against the sentence and use the correct right side rule to

generate a response. Let us considering the following ELIZA rules.

(x me y)(X you y)

(I remember x)(Why do remember x just now?)

(My family –member is y)(Who else is your family is y?)

Suppose the use say “I remember Mary”. How ELIZA will try to match the above

response to the left hand side of the given rules. It finds that it matches to the first rule and

now it take the right hand side ask, “Why do remember Mary just now?” This is the why

how the conversion proceeds taking into consideration the approximate matching.

Conflict Resolution:

The conflict resolution is a strategy in which we incorporate the decision making

into the matching process. We have three basic approaches.

Here we consider the rule in the order they are given or we given some priority

to special case rules.

Here we use key words to match into the rules. Consider the example of

ELIZA.

In this case we consider all rules that are waiting, which gives some states.

Here a heuristic function we can decide which state is the best.

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.

Knowledge about which rule to apply in given situation.

Knowledge about the order in which to achieve sub goals

Knowledge about useful sequence of0 rules to apply

A.Rakesh Babu M.C.A., M.Tech 67

Asst.Prof

Artificial Intelligence

knowledge. Two systems which represent control knowledge with rules are SOAR and

PRODIGY.

SOAR CONSIST OF,

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

## Гораздо больше, чем просто документы.

Откройте для себя все, что может предложить Scribd, включая книги и аудиокниги от крупных издательств.

Отменить можно в любой момент.