0% found this document useful (0 votes)
44 views114 pages

Ai Unit Ii

The document outlines the syllabus and key concepts of Unit II in Artificial Intelligence and Expert Systems, focusing on logical agents, knowledge representation, and inference in first-order logic. It discusses the characteristics and functions of knowledge-based agents, including their ability to perceive, represent knowledge, reason, and act. Additionally, it introduces the Wumpus World as a practical example for understanding intelligent agents and their decision-making processes.

Uploaded by

Sita Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views114 pages

Ai Unit Ii

The document outlines the syllabus and key concepts of Unit II in Artificial Intelligence and Expert Systems, focusing on logical agents, knowledge representation, and inference in first-order logic. It discusses the characteristics and functions of knowledge-based agents, including their ability to perceive, represent knowledge, reason, and act. Additionally, it introduces the Wumpus World as a practical example for understanding intelligent agents and their decision-making processes.

Uploaded by

Sita Ram
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 114

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

ARTIFICIAL INTELLIGENCE AND EXPERT


SYSTEMS
UNIT II

Presentation
Mrs.P.Bhavani, Assistant Professor
Dept of CSE
UNIT II - SYLLABUS

Logical Agents – Predicate Logic – First Order Logic –


Inference in First Order Logic – Forward and chaining –
Knowledge Representation,Classical Planning,
Knowledge Representation
KNOWLEDGE
– Is a fact or more than that?

– May be declarative or procedural.

– Procedural knowledge is compiled knowledge related to the


performance of some task. E.g. Steps used to solve an algebraic
equation

– Declarative knowledge is passive knowledge expressed as


statements of facts about the world. E.g. Personnel data in a database
Intelligent agents should have capacity for:

– Perceiving, that is, acquiring information from environment,

– Knowledge Representation, that is, representing its understanding


of the world,

– Reasoning, that is, inferring the implications of what it knows and of


the choices it has, and

– Acting, that is, choosing what it want to do and carry it out.


LOGICAL-BASED AGENTS
 The central component of a knowledge-based agent is its
knowledge base.
 A knowledge base is a set of sentences.
 Each sentence is expressed in a language called a
knowledge representation language.
 Sometimes we dignify a sentence with the name axiom,
when the sentence is taken as given without being
derived from other sentences.
KNOWLEDGE-BASED AGENTS -
INFERENCE
• Sentences represent some assertions about the world.
There must mechanisms to derive new sentences from
old ones. This process is known as inferencing or
reasoning.
• There must be a way to add new sentences to the
knowledge base and a way to query what is known. The
standard names for these operations are TELL and ASK,
respectively. Both operations may involve inference—that
is, deriving new sentences from old.
Agent Program Process
 Knowledge-Base
 A set of sentences in a formal language
 Sentences are expressed using a knowledge
representation language
 Two generic functions:
 TELL - Knowledge Base what it perceives
 “Tell it what it needs to know”

 ASK – Knowledge Base what action it should


perform
 “Ask what to do next”
KNOWLEDGE-BASED(KB) AGENTS
Two functions
1.Make- Percept sentence
Takes a percept and a time and returns a sentence that the
agent perceived the percept at the given time
2. Make –Action-Query
Takes a time as input and returns a sentence that what
action should be performed at that time
Contd..
• Knowledge level
What agent knows and what its goal are in order to fix its
behaviour
• Implementation Level
Eg.Taxi
• Declarative Level
Adding one by one sentence that represents designers
knowledge of environment
Contd..
• Declarative Approach
Designing the representation language to make it easy to
express knowledge in form of sentence
• Procedural Approach
Efficient system
The Wumpus World!
The Wumpus World!
• The wumpus world is a cave consisting of rooms connected by passageways.
• Looking somewhere in the cave is the wumpus, a beast that eats anyone who
enters its room.
• The wumpus can be shot by an agent, but the agent has only one arrow.
• Some rooms contain bottomless pits that will trap anyone who wanders into
these rooms (except for the wumpus, which is too big to fall in).
• The only mitigating feature of living in this environment is the possibility
of finding a heap of gold
Hunt the wumpus!
PEAS
• Performance measure: +I000 for picking up the gold, -1000 for falling
into a pit or being eaten by the wumpus, -1 for each action taken and -10
for using up the arrow.
• Environment: A 4 x 4 grid of rooms. The agent always starts in the square
labeled [1,1], facing to the right.
• The locations of the gold and the wumpus are chosen randomly,with a
uniform distribution, from the squares other than the start square.
Contd..
Actuators:
• The agent can move forward, turn left by 90°, or turn right by 90".
• The agent dies a miserable death if it enters a square containing a pit or a live
wumpus.
• The action Grab can be used to pick up an object that is in the same square as the
agent.
• The action Shoot can be used to fire an arrow in a straight line in the direction the
agent is facing.
• The arrow continues until it either hits (and hence kills) the wumpus or hits a
wall.
• The agent only has one arrow,so only the first Shoot action has any effect.
Contd..
Sensors: The agent has five sensors, each of which gives a single bit of
information:
1. In the square containing the wumpus and in the directly (not diagonally)
adjacent squares the agent will perceive a stench.
2. In the squares directly adjacent to a pit, the agent will perceive a breeze.
3. In the square where the gold is, the agent will perceive a glitter.
4.When an agent walks into a wall, it will perceive a bump.
5.When the wumpus is killed, it emits a scream that can be perceived
anywhere in the cave
 Performance Measure
Description
 Gold +1000, Death – 1000
 Step -1, Use arrow -10

 Environment
 Square adjacent to the Wumpus are
smelly
 Squares adjacent to the pit are
breezy
 Glitter iff gold is in the same square
 Shooting kills Wumpus if you are
facing it
 Shooting uses up the only arrow
 Grabbing picks up the gold if in
the same square
 Releasing drops the gold in the
same
square

 Actuators
 Left turn, right
turn, forward, grab, release, shoot
Characterization of Wumpus World
 Observable
partial, only local
perception
 Deterministic
Yes, outcomes are
specified
 Episodic

No,
sequential
at the
level of
actions
 Static
An Example
An Example
Logic
• These sentences SYNTAX are expressed according to the syntax of the
representation language, which specifies all the sentences that are well formed.
• The notion of syntax is clear enough in ordinary arithmetic:
• "x + y = 4" is a well-formed sentence
Semantics
• For example, the usual semantics adopted for arithmetic
specifies that the sentence
• "x + y = 4" is true in a world where x is 2 and y is 2, but false
in a world where x is 1 and y is 1.'
Entailment
• In mathematical notation, we write as

• The formal definition of entailment is


• this: a I= if and only if, in every model in which a is true, is
also true.
Contd..
• we are happy with
• The idea that the sentence x + y = 4
entails the sentence 4 = x + y.
Contd..
Contd..
Contd..
• Now let us consider two possible conclusions:
• a1 = "There is no pit in [1,2] ."
• a2 = "There is no pit in [2,2].
Contd..
• Logical inference
• Model checking
• Sound
Propositional Logic
• Syntax
• The syntax of propositional logic defines the allowable
sentences.
• The atomic sentences-
The indivisible syntactic elements-consist of a single
proposition symbol.G1,3
Contd..
• use uppercase names for symbols: P, Q, R, and so on.
• Names are arbitary
Example for complex Connectives
• P,Q
• John can play tennis –P
• John cannot play tennis – 7P
• John can play tennis and badminton(^)
• John can play tennis or badminton(v)
• If john can play tennis then he can play badminton(P->Q)
• John can play tennis if and only if he can play badminton
• (PQ)
BNF
Contd..
(1.)7 P V Q ^ R => S
is equivalent to the sentence
((7P v (Q ^R)) => S
2.A^B^C read as ((A^B^C) or(A^(B^C))
3.A^B^C,AVBVC AND A BC is allowed
A=>B=>C is not allowed
Truth Table
Example
• {P1,2=false,P2,2=false,P3,1=True}
• 7P1,2^(P2,2VP3,1)
• True^(False V True)
Contd..
• B1,1 (P1,2 V P2,1)
• P1,1
• 7P1,1
• B2,1 (P1,1 V P2,2 VP3,1)
Truth Table for KB
SEMANTICS
• Rules for determining the truth of a sentence
• Meaning
Inference rules
• Modus Ponens
• Modus Tollens
• Hypothetical Syllogism
• Disjunctive Syllogism
• Addition
• Simplification
• Resolution
Inferences
• Modus Ponens
If P ->Q P=True
Then Q=True
Example: If you have a current password, then you
can log onto the network
P:You have a current password
Q:You can log on to the network
Modus Tollens
• If P->Q True & 7Q =True then 7P=True
• Example: If you have a current password,
then you can log onto the network
• P:you have a current password
• 7Q:you cannot log on to the network
• 7P:you don't have a password
Hypothetical Syllogism

• If P ->Q =True & Q ->R =True then P ->R =True


• P : It rains
• Q:The ground is wet
• R: The ground is slippery
• P ->Q = If it rains then the ground is wet
• Q ->R = If the ground is wet then the ground is slippery
• P ->R = If it rains then the ground is slippery
Disjunctive Syllogism

• If P V Q=True & 7P=True then Q= True


• P:Today is Sunday
• Q:Today is Monday
• P V Q : Today is sunday or Monday
• 7P:Today is not Sunday
• Q :Today is Monday
Addition
• If P=True then P V Q=True
• P: I Drink coffee
• Q:I Drink Tea
• P V Q : I drink coffee or tea
Simplification
• If P ^ Q=True Then Q V P= True
• P:It is freezing now
• Q:It is raining now
Resolution
• If P V Q &7P^R=True the Q V R=True
• P:It is raining
• Q:It is cloudy
• R:It is windy
• P V Q : It is raining or cloudy
• 7P^R :it is not raining and windy
• Q V R: it is cloudy or windy
First Order Logic or Predicate Logic
• FOL ,a representation language knowledge which is powerful
than propositional logic (i.e)Boolean logic
• FOL is an expressive ,declarative ,compositional language
First Order Logic or Predicate Logic
Like Natural Language has well defined Syntax and Semantics
• Objects: people, houses, numbers, theories, Ronald
McDonald, colors, baseball games, wars, centuries ...
• Relations: brother of, bigger than, inside, part of, has color,
occurred after, owns ...
• Properties: red, round, bogus, prime, multistoried...
Functions: father of, best friend, third inning of, one more
than ...
Representation Revisited
S.No Programming languages Propositional logic
1. It follows procedural approach It follows declarative approach

2. Dependent Independent
3. It lack to handle Partial It details with Partial information
information
4. No compositionality Good compositionality
5. Difficult to think Easy to think
EXAMPLE
• "Evil King John ruled England in 1200."
• Objects: John, England, 1200;
• Relation: ruled;
• Properties: evil, king.
ONTOLOGICAL COMMITMENT
• Nature of reality
• Special purpose logic makes faster ontological
commitment
TEMPORAL LOGIC
• It assumes that facts hold particular times and
that those times(interval) are ordered
(arranged)
• High order logic
• More expressive than FOL.It allows one to
make assertions about all relations
Epistemological commitments
Syntax and Semantics of FOL
• Syntax – Procedures
• Semantics – Meaning
Model of FOL
Model in propositional logic are just of truth
values i.e 0’s and 1’s
Relations
• Relation is the related set of tuples of objects
Tuple
A tuple is a collection of objects arranged in a
fixed order and written within angle brackets
Model
Contd..
• 5 objects
• 2 binary relations
• 3 unary relations
• 1 unary functions
5 objects

• Richard
• John
• Left leg of Richard
• Left leg of John
• crown
Contd..
2 binary relations
“Brothers” and “on head”
3 Unary relations
Person
King john
crown
Contd..
• 1 unary function
• <richard the lionheart> richard left leg
• <king john> john left leg
• <Richard,john>
Symbols and interpretations
• 3 types of symbols
• Constant symbol – object (john , Richard)
• Predicate symbol – relation(Brother, on
head ,Person,king,crown)
• Function symbol – left leg
Interpretations
• Object
• Relation
• Functions
Other interpretations
Detailed explanation of elements
Terms
A term is a logical expression that refers to an
object.
Atomic Sentences
William is the brother of Richard
Function(object)
Brother(William,richard)
Contd..
• Richard’s Father is married to William's mother
• Married(Father(Richard),Mother(william)
• Complex Sentence
• 7
• ^
• V
• =>
• 
Contd..
• Either Richard is king or john is king
• King(Richard) V King(john)
• Richard is not king,so it implies john is king
• 7King(Richard)=>king(john)
Contd..
• X is an integer
Integer(x)
• Caesar was ruler
Ruler(caesar)
• Ravi and Rama are brothers
brothers(Ravi,rama)
• Marcus tried to assassinate caesar
Try to Assassinate (marcus,caesar)
Quantifiers
• Universal quantification ∀
• Existential quantification
• Nested
Contd..
• All man drink coffee
x fn
∀x man(x) ->drink(x,coffee)
Every man respects his parents
∀x man(x)->respects(x,Parents)
Contd..
• Some boys play cricket
∃x boys(x)->play(x, cricket)
• Not all students like both Mathematics and
science
• 7∀xstudent(x)->like(x,mathematics) ^ like(x,science)
Contd..
• Everyone is loyal to someone
∀x ∃y loyal(x,y)
• Everyone loves Everyone
∀X ∀Y loves(X,Y)
• Everyone likes icecream There is none who dislikes
icecream
Equality
7(x,y) x y
Forward chaining
• The Generalized Modus Ponens rule can be used in two ways.
• We can start with the sentences in the knowledge base and
generate new conclusions that in turn can allow more
inferences to be made.
• This is called forward chaining.
• Forward chaining is usually used when a new fact is added to
the database and we want to generate its consequences.
Contd..
• Known facts
• Applying inference rules
• To reach the goal
Contd..
• Given Data
• Tomy barks
• Tomy eats bone
• To prove :Tomy is black
Contd..
• Rules:
• If D barks and D eats bone then D is dog ->1
• If V is cold and V is sweet ,then V is ice cream ->2
• If D is a dog then D is black ->3
• If V is icecream ,then it is vannila ->4
Example 2
• As per the law ,it is crime for an American to
sell weapons to hostile nations vizar,an enemy
of American has some missile and all the
missiles were sold to it by robin,who is an
American.
• Prove “Robin is criminal”
Contd..
1.It is a crime for an American to sell weapon to
hostile weapons
American(x) ^ weapon(y)^sells(x,y,z)^hostile(z) ->criminal(x)
2.Vizar has some missiles
own(A,M)
Missile(M)
Contd..
3.All of the missiles were sold to country vizar by
robin
Missile(M)^owns(A,M) ->sells(Robin,M,A)
4.Enemy of America is known as hostile
Enemy(A,America) ->hostile(A)
Contd..
5.Missiles are weapons
Missile(M) ->weapons(W)
6.Country vizar is an enemy of America
Enemy(A,America)
7.Robin is American
American(Robin)
Forward chaining
criminal(x)

sells(Robin,M,A) weapons(W) hostile(A)

American(Robin) own(A,M) Missile(M) Enemy(A,America)


Efficient of Forward chaining
• The inner loop of an algorithm involves finding all
the possible unifiers in the KB.This. is called pattern
matching and can be very expensive
• Algorithm rechecks every rule onevery iteraion to see
whether it premises satisfied ,even if few additions
are made to the KB on each iterations
• Algorithm may generate many irrelevant facts to goal
Contd..
• Most rules in real world KB are small and
simple .Data complexity is polynomial
• We can consider subclasses of rules for which
matching is efficient
• We can work hard to eliminate redundant rule
matching attempts
Contd..
• Irrelevant facts
• FOL- FC – ASK generate irrelevant conclusions
• By using Backward chaining we avoid irrelevant
conclusions
• Restrict forward chaining to a selected subset of rules
• To rewrite rule set using information goal ,relevant
variables are called as magic set
Backward chaining
• It is a form of reasoning
• It starts with goal and work backward chaining
rules to find known facts support the goal
• Top down approach
Contd..
• Based on Modus Ponens
• Goal is broken into sub goal
• Used in game theory, Inference engines and
various AI Applications
• Mostly used in DFS
Contd..
• Cognitive Architecture
It is a model of human reasoning .In such systems the working
memory of the system are short term memory and productions
are part of long term memory
Example for Backward Chaining
• It is a crime for an American to sell weapons to hostile nations.Linda,an
enemy of America, has some missiles and all the missiles were sold it by
Robert, who is an American
• Prove: Robert is criminal
BACKWARD CHAINING
1.It is a crime for an American to sell weapons to hostile nation.
American(P) ^Weapon(q)^sells(P,q,r)^hostile(r) ->Criminal(p)
2.Linda has some missiles
missiles(T)
Owns(L,T)
Contd..
3.Missiles are weapons
missile(T) ->Weapon(q)
4.Enemy of America is known as hostile
Enemy(E,America)->hostile(r)
Contd..
5.Linda is an enemy of America
enemy(L, America)
6.Robert is an American
American(Robert)
7.All the missiles were sold to country Linda by Robert
Missiles(T)^owns(L,T) ->Sells(Robert ,T, L)
Backward chaining
Criminal(Robert)

American(Robert) Sells(p,q,r) Hostile(r )


Weapon(q)

Missiles(T) Owns (L,T) Enemy(e,America)


Logic programming
• I t is a technology
• Declarative ideal
• Algorithm = Logic +control
Difference between Forward and backward chaining
Contd..
knowledge representation

• Humans are best at understanding, reasoning, and interpreting knowledge. Human knows things, which
is knowledge and as per their knowledge they perform various actions in the real world. But how
machines do all these things comes under knowledge representation and reasoning. Hence we can
describe Knowledge representation as following:
• Knowledge representation and reasoning (KR, KRR) is the part of Artificial intelligence which
concerned with AI agents thinking and how thinking contributes to intelligent behavior of agents.
• It is responsible for representing information about the real world so that a computer can understand
and can utilize this knowledge to solve the complex real world problems such as diagnosis a medical
condition or communicating with humans in natural language.
• It is also a way which describes how we can represent knowledge in artificial intelligence. Knowledge
representation is not just storing data into some database, but it also enables an intelligent machine to
learn from that knowledge and experiences so that it can behave intelligently like a human.
CONTD..
• Following are the kind of knowledge which needs to be represented in AI
systems:
• Object: All the facts about objects in our world domain. E.g., Guitars
contains strings, trumpets are brass instruments.
• Events: Events are the actions which occur in our world.
• Performance: It describe behavior which involves knowledge about how
to do things.
• Meta-knowledge: It is knowledge about what we know.
• Facts: Facts are the truths about the real world and what we represent.
• Knowledge-Base: The central component of the knowledge-based agents
is the knowledge base. It is represented as KB.
1.Declarative Knowledge:

• Declarative knowledge is to know about something.


• It includes concepts, facts, and objects.
• It is also called descriptive knowledge and expressed in
declarative sentences.
• It is simpler than procedural language.
2.Procedural Knowledge

• It is also known as imperative knowledge.


• Procedural knowledge is a type of knowledge which is responsible for
knowing how to do something.
• It can be directly applied to any task.
• It includes rules, strategies, procedures, agendas, etc.
• Procedural knowledge depends on the task on which it can be applied.
CONTD
3. Meta-knowledge:
Knowledge about the other types of knowledge is called Meta-knowledge.
4. Heuristic knowledge:
• Heuristic knowledge is representing knowledge of some experts in a filed
or subject.
• Heuristic knowledge is rules of thumb based on previous experiences,
awareness of approaches, and which are good to work but not guaranteed.
Structural knowledge:
• Structural knowledge is basic knowledge to problem-solving.
• It describes relationships between various concepts such as kind of, part of,
and grouping of something.
• It describes the relationship that exists between concepts or objects.
Approaches to knowledge representation:

There are mainly four approaches to knowledge representation, which are


given below:
1. Simple relational knowledge:
• It is the simplest way of storing facts which uses the relational method,
and each fact about a set of the object is set out systematically in
columns.
• This approach of knowledge representation is famous in database
systems where the relationship between different entities is represented.
• This approach has little opportunity for inference.
Inheritable knowledge:

• In the inheritable knowledge approach, all data must be stored into a


hierarchy of classes.
• All classes should be arranged in a generalized form or a hierarchal
manner.
• In this approach, we apply inheritance property.
• Elements inherit values from other members of a class.
Inferential knowledge:

• Inferential knowledge approach represents knowledge in the


form of formal logics.
• This approach can be used to derive more facts.
• It guaranteed correctness.
Procedural knowledge:

• Procedural knowledge approach uses small programs and codes which


describes how to do specific things, and how to proceed.
• In this approach, one important rule is used which is If-Then rule.
• In this knowledge, we can use various coding languages such as LISP
language and Prolog language.
CLASSICAL PLANNING
• AI Classical planning is a key area in Artificial Intelligence to
find a sequence of actions that will fulfil a specific goal from
an exact beginning point.
• This process creates methods and algorithms that allow smart
systems to explore systematically various actions and their
outcomes which eventually lead to the desired result
occasionally from the starting place.
CONTD
• There are many different areas in which classical planning
methods are used such as: robotics or other industries related
to manufacturing, transportation services like supply chain
management or project management.
• Planning based on logical reasoning forms the basis for all
current methodologies that deal with automated decision
making as well as enhancing efficiency for resource
allocation.
Importance of Classical Planning
in AI
• The reason why classical planning is so important is first of all
its wide range of features that can be applied to solving
problems in different domains.
• Secondly - its an allowance for handling complex situations in
a logically coherent manner. Through the replication of the
problem area, stipulation of initial and final states, and
specifying how these states may be reached, classical planning
algorithms may search for a viable solution by systematically
going through the space of possible solutions.
Domain-Independent Planning

• The essential feature of classical reasoning is


domain independence. The classical algorithms of
the planning and technique are designed to apply
to different problems without having to learn
domain knowledge or heuristics. Such domain-
independent planning enables the creation of
general-purpose planners that can solve problems
and machines for different domains increasing the
power and versatility of classical planning.
CONTD..
• The main objective of domain-independent or multi-
domain planning is to develop planning algorithms
and systems that can reason about and solve
problems in many different domains, without having
to make several adjustments or change parameters.
This is done by concentrating on the elementary
fundamentals of planning that are: state
representations, action models and a strategy of
search, and not the domain-specific rules or the
heuristics.
CONTD..
• The feature of independence concerning domains in the field of classical
planning can be elaborated by the use of domain-independent modelling
languages like PDDL (Planning Domain Definition
Language) and STRIPS (Stanford Research Institute Problem Solver).
THANK YOU!!!!

You might also like