Unit 3
Unit 3
Knowledge-Base agent
•A knowledge-based agent can combine general knowledge
with current percepts to infer hidden aspects of the current
state prior to selecting actions.
•The central component of a knowledge-based agent is its
knowledge base, or KB. Informally, a knowledge base is a set
of sentences.
•Each sentence is expressed in a language called a knowledge
representation language and some assertion about the
world.
A knowledge-based agent is composed of:
• 4 X 4 grid of rooms
• Squares adjacent to Wumpus are smelly
• Squares adjacent to pit are breezy
• Glitter iff gold is in the same square
• Shooting kills Wumpus if you are facing it
• Wumpus emits a horrible scream when it is killed
that can be heard anywhere
• Shooting uses up the only arrow
• Grabbing picks up gold if in same square
• Releasing drops the gold in same square
THE WUMPUS WORLD PEAS
Performance measure:
gold +1000, death (eaten or falling in a pit) -1000,
-1 per action taken, -10 for using the arrow.
The games ends either when the agent dies or
comes out of the cave.
Environment:
• 4 X 4 grid of rooms
• Agent starts in square [1,1] facing to the right
• Locations of the gold, and Wumpus are chosen
randomly with a uniform distribution from all
squares except [1,1]
• Each square other than the start can be a pit
with probability of 0.2
THE WUMPUS WORLD PEAS
Actuators:
Left turn, Right turn, Forward, Grab, Release,
Shoot
Sensors:
Stench, Breeze, Glitter, Bump, Scream
Represented as a 5-element list
Example: [Stench, Breeze, None, None, None]
Wumpus World Characterization
Observable? No—only local perception
Discrete? Yes
• The NOR Operator (not or), which has symbol ↓ , written symbolically p ↓ q
Tautology and Contradiction
Definitions:
A compound proposition that is always true for all possible truth values of
the propositions is called a tautology.
A compound proposition that is always false is called a contradiction.
A proposition that is neither a tautology nor contradiction is called a
contingency.
Example: p ∨ ¬p is a tautology.
Tautology and Contradiction
Definitions:
A compound proposition that is always true for all possible truth values of
the propositions is called a tautology.
A compound proposition that is always false is called a contradiction.
A proposition that is neither a tautology nor contradiction is called a
contingency.
Example: p ∧ ¬p is a contradiction.
Logical equivalence
DeMorgan's Laws:
1) ¬( p ∨ q ) <=> ¬p ∧ ¬q
2) ¬( p ∧ q ) <=> ¬p ∨ ¬q
Equivalence
Equivalent statements are important for logical reasoning since they can be
substituted and can help us to:
(1) make a logical argument, and (2) infer new propositions
Example: p q is equivalent to ¬q ¬p (contrapositive)
Important logical equivalences
• Identity • Double negation • Distributive
p ∧ T <=> p ¬(¬p) <=> p P ∨ (q ∧ r) <=> (p ∨ q) ∧ (p
p ∨ F <=> p • Commutative ∨ r)
• Domination p ∨ q <=> q ∨ p p ∧ (q ∨ r) <=> (p ∧ q) ∨ (p
p ∨ T <=> T ∧ r)
p ∧ q <=> q p
p ∧ F <=> F • Other useful equivalences
• Associative
• Idempotent p ∨ ¬p <=> T
(p ∨ q) ∨ r <=> p ∨ (q ∨
p ∨ p <=> p p ∧ ¬p <=> F
r)
p ∧ p <=> p
(p ∧ q) ∧ r <=> p ∧ (q ∧p q <=> (¬p ∨ q)
r)
Show that ¬[p ∨ ¬(¬q ∨ ¬r)] is logically equivalent to (p ∨ q) → ¬(p ∨
r)
Entailment (|=)
• Entailment means that one thing follows from another:
• Knowledge base KB entails sentence α if and only if:
❖ α is true in all interpretations/worlds in which KB is true
❖ if KB is true then α must be true
Write KB |= α for KB entails α, So:
KB |= α iff for every interpretation I, if I |= KB then I |= α.
Or
If M(α) is the set of all models of α, then KB |= α iff M(KB) ⊆ M(α)
Entailment (|=)
Entailment means that one thing follows from another:
Consider:
If it rains John takes an umbrella
If John takes an umbrella he doesn’t get wet
If it doesn’t rain then John doesn’t get wet.
Show:
John doesn’t get wet.
Propositions :
r: It rains
u: John takes an umbrella
w: John gets wet.
Solution:
Inference rules approach
-Start from entries for which KB is True.
-Generate new sentences from the existing ones
Inference rules approach:
Approach:
• Start from KB
• Infer new sentences that are true from existing KB sentences
• Repeat till α is proved (inferred true) or no more sentences can be proved
Rules:
(i) Equivalence rules: Logical equivalence rules
(ii) Inference rules:
Normal forms:
1) Conjunctive normal form (CNF)
Conjunction of clauses (clauses include disjunctions of literals)
2) Disjunctive normal form (DNF)
Disjunction of terms (terms include conjunction of literals)
Normal forms
• A formula is in conjunctive normal form (CNF, clause normal form), if it is a conjunction of
disjunctions of literals (or in other words, a conjunction of clauses).
Example, ∀z(P (z) ∧ Q(x)) ∨ ∃yQ(y). Here all occurrences of z and y are bound,
Only one variable x is free.
Order of quantifiers
The order of nested quantifiers matters if quantifiers are of
different type
• ∃x∀x P(x,y) is not the same as ∀x ∃x P(x,y).
Example:
• Assume P(x,y) denotes “x loves y”
• Then: ∀x ∃x L(x,y)
• Translates to: Everybody loves somebody.
• And: ∃x∀x L(x,y)
• Translates to: There is someone who is loved by everyone.