0% found this document useful (0 votes)
10 views

AI Lecture 9

Uploaded by

mundacharsi447
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

AI Lecture 9

Uploaded by

mundacharsi447
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

Lecture 9 – Knowledge-Based

Agents and Logic

June 29, 2024 1


 Knowledge-based agents
 Wumpus world
 Logic in general - models and entailment
 Propositional (Boolean) logic
 Equivalence, validity, satisfiability
 Inference rules and theorem proving
 Forward chaining
 Backward chaining
 Resolution.

June 29, 2024 2


 Problem-solving agents were very inflexible:
hard code every possible state.

 Search is almost always exponential in the


number of states.

 Problem solving agents cannot infer unobserved


information.

 We want an agent that can reason similarly to


humans.

June 29, 2024 3


 Knowledge,
 reasoning, and
 planning

Knowledge, reasoning, and planning

June 29, 2024 4


 Knowledge base: Set of sentences in a formal language
 Declarative approach for building an agent
 TELL it what it needs to know
 Then it can ASK itself what to do - answers should
follow from the KB
 Agents can be viewed at the knowledge level
 What they know, regardless of implementation
 Or at the implementation level
 Data structures in KB and algorithms that manipulate
them.
June 29, 2024 5
 The agent must be able to:
 Represent states, actions, etc.
 Incorporate new percepts
 Update internal representations of the world
 Deduce hidden properties of the world
 Deduce appropriate actions.
June 29, 2024 6
 Performance measure: Gold +1000,
Death -1000, -1 per step, -10 for
using the arrow
 Environment:
 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
 Shooting uses up the only arrow
 Grabbing picks up gold if in same
square
 Releasing drops the gold in same
square
 Actuators: Left turn, Right turn,
Forward, Grab, Release, Shoot
 Sensors: Breeze, Glitter, Smell.

June 29, 2024 7


 Observable? No - only local perception
 Deterministic? Yes -outcomes exactly specified
 Episodic? No - sequential at the level of actions
 Static? Yes -Wumpus and Pits do not move
 Discrete? Yes
 Single-agent? Yes

June 29, 2024 8


June 29, 2024 9
June 29, 2024 10
June 29, 2024 11
June 29, 2024 12
June 29, 2024 13
June 29, 2024 14
June 29, 2024 15
June 29, 2024 16
 Logics are formal languages for representing
information, such that conclusions can be drawn
 Syntax defines the sentences in the language
 Semantics define the “meaning" of sentences,
i.e., define truth of a sentence in a world
 E.g., the language of arithmetic
 x + 2 ≥ y is a sentence; x2 + y > is not a
sentence
 x + 2 ≥ y is true iff the number x + 2 is no less
than the number y
 x + 2 ≥ y is true in a world where x=7; y =1
 x + 2 ≥ y is false in a world where x=0; y =6
June 29, 2024 17
 Entailment means that one thing follows from
another

 Knowledge base KB entails sentence B iff B is


true in all worlds where KB is true
 E.g., the KB containing “the Giants won" and
“the Reds won” entails “Either the Giants won
or the Reds won“
 E.g., x + y =4 entails 4=x + y
 Entailment is a relationship between sentences
(i.e., syntax) that is based on semantics.

June 29, 2024 18


 Logicians typically think in terms of models,
which are formally structured worlds with
respect to which truth can be evaluated
 We say m is a model of a sentence B if B is true
in m
 M(B) is the set of all models of B
 Then KB |= B if and only if M(KB) M(B)
 E.g. KB = Giants won and Reds won
 B = Giants won

M(B) could be also true for


worlds that are different than
the worlds of KB
June 29, 2024 19
M(B)

June 29, 2024 20


 Situation after detecting
nothing in [1,1], moving
right, breeze in [2,1]
 Consider possible models
for ?s, assuming only pits
 3 Boolean choices, i.e., 8
possible models

June 29, 2024 21


June 29, 2024 22
KB = Wumpus World Rules + Observations
June 29, 2024 23
KB = Wumpus World Rules + Observations
June 29, 2024 Alpha_1 = “(1,2) is safe, KB |= Alpha_1 24
KB = Wumpus World Rules + Observations
June 29, 2024 25
KB = Wumpus World Rules + Observations
June 29, 2024 Alpha_2 = “(2,2) is safe, KB |= Alpha_2 is false 26
 First Order Logic (FOL): Allows complete and
sound inference procedures
 Will answer any question whose answer
follows from what is known by the KB.

June 29, 2024 27


Order of Precedence
June 29, 2024 If and Only If If S1 then S2 28
If S1 is true, then I am claiming that S2 is true

June 29, 2024 29


June 29, 2024 30
June 29, 2024 31
R1

R4

R5

R2

R3

June 29, 2024 32


128 possible rows, only 3 make the KB true P1,2 is false for all 3; hence, no pit in P1,2
Evaluate the entailed sentences in P2,2 is both false and true; hence, no conclusion ca
June 29, 2024 these rows be drawn about the pit being in P2,2 33
June 29, 2024 34
June 29, 2024 35
If KB is true, alpha is
always true. Hence, I can
say that alpha follows from
KB

Suppose that
KB=true. Then, this
will become
unsatisfiable only
when alpha is true.
Hence, I can say that
alpha follows from KB

June 29, 2024 36


 Modus Ponens

Given that P implies Q,


and I know that P is
true, then I can infer Q

 And Rule
Given that P AND Q is
true, I can infer that P is
true, and I can also infer
that Q is true.

June 29, 2024 37


June 29, 2024 38
June 29, 2024 39
June 29, 2024 40
June 29, 2024 41
Add P1,2
Del P1,2 P2,1 Del P2,1
Add P1,2
Add P2,1 already
added
This returns an empty clause.
So, alpha is true.

June 29, 2024 42


June 29, 2024 43

You might also like