PropositionalLogic1 6pp
PropositionalLogic1 6pp
1 2
3 4
5 6
1
The Knowledge Base (KB) The Knowledge Base (KB)
TELL
• A knowledge base is a set • Need to add new
of “sentences” sentences to the
• Each sentence is knowledge base (this task
Knowledge Base:
expressed in a knowledge Knowledge Base: is called TELL)
Sentence 1 Sentence 1
Sentence 2 representation language Sentence 2 • Need to query what is
: :
Sentence N and represents some Sentence N known (this task is called
assertion about the world ASK)
ASK
7 8
Knowledge Knowledge
Base Base
11 12
2
A Generic Knowledge-based Agent The Wumpus World
Input: Percept
• Wumpus eats anyone
that enters its room
1. TELL the KB what it • Wumpus can be shot
perceives by an agent, but agent
Knowledge 2. ASK the KB what action has one arrow
Base it should perform • Pits trap the agent (but
3. TELL the KB that the not the wumpus)
action was executed
• Agent’s goal is to pick
up the gold
Output: Action
13 14
17 18
3
The Wumpus World Environment
Wumpus World Example
Properties
• Fully or Partially observable?
• Deterministic or stochastic?
• Episodic or sequential?
• Static or dynamic?
• Discrete or continuous?
• Single agent or multiagent?
19 20
21 22
23 24
4
Wumpus World Example Logic
We’ll skip the agent’s state of knowledge
at [2,2] and assume it goes to [2,3].
Logic must define:
Agent detects a glitter in [2,3] so it grabs
1. Syntax of the representation language
the gold and ends the game • Symbols, rules, legal configurations
2. Semantics of the representation language
Note: In each case where the agent • Loosely speaking, this is the “meaning” of the
draws a conclusion from the sentence
available information, that conclusion • Defines the truth of each sentence with
is guaranteed to be correct if the
respect to each possible world
available information is correct
• Everything is either true or false, no in
between
25 26
Models Entailment
• We will use the word model instead of “possible α |= β means α entails β i.e. β follows
world”
logically from α, where α and β are
• “m is a model of α” means that sentence α is true
in model m sentences
• Models are mathematical abstractions which fix
the truth or falsehood of every relevant sentence Mathematically, α |= β if and only if in every
• Think of it as the possible assignments of values model in which α is true, β is also true.
to the variables
– E.g. the possible models for x + y = 4 are all possible
assignments of numbers to x and y such that they add
up to 4 Another way: if α is true, then β must also be
true.
27 28
29 30
5
Entailment Applied to the Wumpus Entailment applied to the Wumpus
World World Now let us consider the
Let us consider the models that models that support the
support the conclusion α1 = conclusion α2 = “There
“There is no pit in [1,2].” We is no pit in [2,2].” We
draw a line marked with α1 draw a line marked
around these models with α2 around these
models
In every model in which
KB is true, α1 is also true.
In some models in
Therefore KB |= α1
which KB is true, α2 is
false. Therefore KB
|≠ α2 and the agent
cannot conclude that
there is no pit in [2,2]
31 32
33 34
6
Completeness In Summary
• An inference algorithm is complete if it can • Soundness: i is sound if whenever KB |- i α,
derive any sentence that is entailed it is also true that KB |= α
• For some KBs, the number of sentences can • Completeness: i is complete if whenever KB
be infinite |= α, it is also true that KB |-i α
• Can’t exhaustively check all of them, need
to rely on proving completeness
37 38
39 40
41 42
7
Precedence of Connectives Semantics (Are sentences true?)
• In order of precedence, from highest to • Defines the rules for determining if a sentence is
lowest: ¬, , , , true with respect to a particular model
• E.g. ¬P Q R S is equivalent to • For example, suppose we have the following
((¬P) (Q R)) S model: P=true, Q=false, R=true
• You can rely on the precedence of the • Is (P Q R) true?
connectives or use parentheses to make the I want the
order explicit truth!
• Parentheses are necessary if the meaning is
ambiguous
43 44
45 46
47 48
8
The Wumpus World KB Inference
• How do we decide if KB |= ?
3. We add the percepts for the first two • Enumerate the models, check that is true in every model
in which KB is true
squares ([1,1] and [2,1]) visited in the
Wumpus World example: B1,1 B2,1 P1,1 P1,2 P2,1 P2,2 P3,1 R1 R2 R3 R4 R5 KB
false false false false false false false true true true true false false
R4: B1,1 false false false false false false true true true false true false false
R5: B2,1 : : : : : : : : : : : : :
false true false false false false false true true false true true false
false true false false false false true true true true true true true
The KB is now a conjunction of sentences R1 false true false false false true false true true true true true true
R2 R3 R4 R5 because all of these false true false false false true true true true true true true true
sentences are asserted to be true. false true false false true false false true false false true true false
: : : : : : : : : : : : :
true true true true true true true false true true false true false
49