Download Knowledge Representation and Reasoning Readings: Chapter 6 of

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
22c145-Fall’02: Knowledge Representation and Reasoning
Knowledge Representation and Reasoning
Readings: Chapter 6 of Russell & Norvig.
Hantao Zhang
1
22c145-Fall’02: Knowledge Representation and Reasoning
Reasoning Agents
Remember our goal-based agent.
Sensors
State
What the world
is like now
What my actions do
What it will be like
if I do action A
Goals
What action I
should do now
Agent
Hantao Zhang
Environment
How the world evolves
Effectors
2
22c145-Fall’02: Knowledge Representation and Reasoning
(Knowledge-based) Reasoning Agents
Know about the world
They maintain a collection of facts (sentences) about the world, the
Knowledge Base, expressed in some formal language.
Reason about the world
They are able to derive new facts from those in the KB using some
inference mechanism.
Act upon the world
They map percepts to actions by querying and updating the KB.
Hantao Zhang
3
22c145-Fall’02: Knowledge Representation and Reasoning
Automated Reasoning
Main Assumption (or the “Church Thesis” of AI)
1. Facts about the world can be represented as particular configurations
of symbols 1.
2. Reasoning about the world can be achieved by mere symbol
manipulation.
AI researchers believe that reasoning is symbol manipulation, nothing
else. (After all, the human brain is a physical system itself!)
1
ie physical entities such as marks on a piece of paper, states in a computer’s memory, and so on.
Hantao Zhang
4
22c145-Fall’02: Knowledge Representation and Reasoning
Abstraction Levels
It looks like we can describe every reasoning agent (natural or not) at two different
abstraction levels.
• Knowledge level: what the agent knows and what the agent’s goals are.
• Symbol level: what symbols the agent is manipulating and how.
Agent’s
Knowledge and
Goals
Internal
configuration of
symbols
reasoning
symbol manipulation
Agent’s
Knowledge and
Goals
Internal
configuration of
symbols
Knowledge Level
Symbol Level
At least for artificial agents, we may say that the knowledge level is the metaphor by
which we explain the behavior of the agent, which is really at the symbol level.
Hantao Zhang
5
22c145-Fall’02: Knowledge Representation and Reasoning
A Motivating Example: The Wumpus World!
4
Breeze
Stench
Breeze
3
Stench
PIT
Breeze
PIT
Actions
Gold
2
Breeze
1
Move Forward, Turn Left, Turn Right,
Grab, Shoot, Climb
Breeze
Stench
Breeze
PIT
START
1
Hantao Zhang
2
3
Percepts
Stench Breeze Glitter Bump Scream
y/n
y/n
y/n
y/n
y/n
4
Rewards/Punishments
1,000pts for climbing out with gold
-1pt per action taken
-10,000pts for getting killed
6
22c145-Fall’02: Knowledge Representation and Reasoning
The Wumpus World (cont’t)
Perceipts = ( Stench, Breeze, Glitter, Bump, Screm )
• A stench is perceived in the squares containing or adjacent to the
wumpus.
• A breeze is perceived in the squares adjacent to a pit.
• A glitter is perceived in the square containing the gold.
• A bump is perceived if the agent walks into a wall.
• A scream is perceived anywhere if the wumpus is killed.
Hantao Zhang
7
22c145-Fall’02: Knowledge Representation and Reasoning
1,4
2,4
3,4
4,4
1,3
2,3
3,3
4,3
1,2
2,2
3,2
4,2
A
B
G
OK
P
S
V
W
= Agent
= Breeze
= Glitter, Gold
= Safe square
= Pit
= Stench
= Visited
= Wumpus
1,4
2,4
3,4
4,4
1,3
2,3
3,3
4,3
1,2
2,2
3,2
4,2
OK
OK
1,1
2,1
3,1
4,1
A
OK
P?
1,1
2,1
V
OK
OK
(a)
• What are the safe moves from (1,1)?
A
B
OK
3,1
P?
4,1
(b)
Move to (1,2), (2,1), or stay in (1,1)
• Move to (2,1) then.
• What are the safe moves from (2,1)?
B in (2,1) ⇒ P in (2,2) or (3,1) or (1,1)
• Move to (1,2) then.
Hantao Zhang
8
22c145-Fall’02: Knowledge Representation and Reasoning
1,4
1,3
1,2
W!
A
2,4
3,4
4,4
2,3
3,3
4,3
2,2
3,2
4,2
S
OK
1,1
= Agent
= Breeze
= Glitter, Gold
= Safe square
= Pit
= Stench
= Visited
= Wumpus
1,4
2,4
1,3 W!
1,2
OK
2,1
V
OK
A
B
G
OK
P
S
V
W
B
V
OK
3,1
P!
4,1
S
V
OK
1,1
3,4
4,4
2,3
3,3 P?
4,3
2,2
3,2
4,2
A
S G
B
V
OK
2,1
V
OK
(a)
P?
B
V
OK
3,1
P!
4,1
(b)

 S in (1,2) ⇒ W in (1,1) or (2,2) or (1,3)
•
Survived in (1,1) and no S in (2,1) ⇒ W in (1,3)

No B in (1,2) ⇒ P in (3,1)
• Move to (2,2), then to (2,3).
• G in (2,3).
• Grab G and come home ...
Hantao Zhang
9
22c145-Fall’02: Knowledge Representation and Reasoning
Knowledge Representation
An (artificial) agent represents knowledge as a collection of sentences in
some formal language, the knowledge representation language.
A knowledge representation language is defined by its
• syntax, which describes all the possible symbol configurations that
constitute a sentence,
• semantics, which maps each sentence of the language to a fact about
the world.
Ex: Arithmetic
• x + y > 3 is a sentence; x+ > y is not.
• the semantics of x + y > 3 is either the fact “true” or the fact “false”.
• x + y > 3 is “true” iff the number x + y is greater than the number three.
Hantao Zhang
10
22c145-Fall’02: Knowledge Representation and Reasoning
Knowledge Representation and Reasoning
At the semantical level, reasoning is the process of deriving new facts
from previous ones.
At the syntactical level, this process is mirrored by that of producing new
sentences from previous ones.
The production of sentences from previous ones should not be arbitray.
Only entailed sentences should be derivable.
Hantao Zhang
11
22c145-Fall’02: Knowledge Representation and Reasoning
Entailment
Informally,
a sentence ϕ is entailed by a set of sentences Γ
iff
the fact denoted by ϕ follows from the facts denoted by Γ.
Sentences
Facts
Hantao Zhang
Semantics
World
Semantics
Representation
Sentence
Entails
Follows
Fact
12
22c145-Fall’02: Knowledge Representation and Reasoning
Entailment
Notation
Γ |= ϕ if the set of sentences Γ entail the sentence ϕ.
Intuitive reading of Γ |= ϕ:
Whenever Γ is true in the world, ϕ is also true.
Examples
Let Γ consist of the axioms of arithmetic.
{x = y, y = z}
|= x = z
Γ ∪ {x + y ≥ 0}
|= x ≥ −y
Γ ∪ {x + y = 3, x − y = 1} |= x = 2
Γ ∪ {x + y = 3}
Hantao Zhang
6|= x = 2
13
22c145-Fall’02: Knowledge Representation and Reasoning
Inference Systems
At the knowledge representation level, reasoning is achieved by an
inference system I, a computational device able to derive new
sentences from previous ones.
Notation
Γ `I ϕ if I can derive the sentence ϕ from the set Γ.
To be useful at all, an inference system must be sound:
if Γ `I ϕ then Γ |= ϕ holds as well.
An ideal inference system is also complete:
if Γ |= ϕ then Γ `I ϕ holds as well.
Hantao Zhang
14
22c145-Fall’02: Knowledge Representation and Reasoning
Inference Rules
An inference system is typically described as a set of inference (or
derivation) rules.
Each derivation rule has the form:
P1, . . . , Pn ←− premises
←− conclusion
C
Hantao Zhang
15
22c145-Fall’02: Knowledge Representation and Reasoning
Derivation Rules and Soundness
A derivation rule is sound if it derives true conclusions from true
premises.
All men are mortal
Aristotle is a man
Aristotle is mortal
All men are mortal
Aristotle is mortal 2
All men are Aristotle
2
Sound Inference
Unsound Inference!
Woody Allen in Love and Death, 1975.
Hantao Zhang
16
22c145-Fall’02: Knowledge Representation and Reasoning
Knowledge Representation Languages
Why don’t we use natural language (eg, English) to represent knowledge?
• Natural language is certainly expressive enough!
• But it is also too ambiguous for automated reasoning.
Ex: I saw the boy on the hill with the telescope.
Why don’t we use programming languages?
• They are certainly well-defined and unambiguous.
• But they are not expressive enough.
Hantao Zhang
17
22c145-Fall’02: Knowledge Representation and Reasoning
Knowledge Representation and Logic
The field of Mathematical Logic provides powerful, formal knowledge
representation languages and inference systems to build reasoning agents.
Inference and Logic
Soundness
Indispensable but easily achievable: an inference system is sound if all of
its rules are sound.
Completeness
Generally hard or even impossible to achieve. But most of the times we
can live without it . . .
Hantao Zhang
18
22c145-Fall’02: Knowledge Representation and Reasoning
Logics
A logic is a triple hL, S, Ri where
• L, the logic’s language, is a class of sentences described by a formal
grammar.
• S, the logic’s semantics is a formal specification of how to assign
meaning in the “real world” to the elements of L.
• R, the logic’s inference system, is a set of formal derivation rules
over L.
There are several logics: propositional, first-order, higher-order, modal,
temporal, intuitionistic, linear, equational, non-monotonic, fuzzy, . . .
We will concentrate on propositional logic and first-order logic.
Hantao Zhang
19
22c145-Fall’02: Knowledge Representation and Reasoning
Propositional Logic
Each sentence is made of
• propositional variables (A, B, . . . , P, Q, . . . )
• logical constants (True, False).
• logical connectives (∧, ∨, ⇒, . . . ).
Every propositional variable stands for a basic fact.
Ex: I’m hungry, Apples are red, Bill and Hillary are married.
Hantao Zhang
20
22c145-Fall’02: Knowledge Representation and Reasoning
Propositional Logic
The Language
• Each propositional variable (A, B, . . . , P, Q, . . . ) is a sentence.
• Each logical constant (True, False) is a sentence.
• If ϕ and ψ are sentences, all of the following are also sentences.
(ϕ)
¬ϕ
ϕ∧ψ
ϕ∨ψ
ϕ⇒ψ
ϕ⇔ψ
• Nothing else is a sentence.
Hantao Zhang
21
22c145-Fall’02: Knowledge Representation and Reasoning
The Language of Propositional Logic
Formally, it is the language generated by the following grammar.
• Symbols:
– Propositional variables: A, B, . . . , P, Q, . . .
– Logical constants:
True (true)
False (false)
∧ (and)
∨ (or)
⇒ (implies)
⇔ (equivalent)
¬ (not)
• Grammar Rules:
Sentence
AtomicS
ComplexS
Connective
Hantao Zhang
::=
::=
::=
::=
AtomicS | ComplexS
True | False | A | B | . . . | P | Q | . . .
(Sentence) | Sentence Connective Sentence | ¬Sentence
∧| ∨ | ⇒ | ⇔
22
22c145-Fall’02: Knowledge Representation and Reasoning
Propositional Logic
Ontological Commitments
Propositional Logic is about facts in the world that are either true or
false, nothing else.
Semantics of Propositional Logic
Since each propositional variable stands for a fact about the world, its
meaning ranges over the Boolean values {True, False}.
Note: Do note confuse, as the textbook does, True, False, which are values (ie
semantical entities) with True, False which are logical constants (ie symbols).
Hantao Zhang
23
22c145-Fall’02: Knowledge Representation and Reasoning
Semantics of Propositional Logic
• The meaning (value) of True is always True. The meaning of False is always False.
• The meaning of the other sentences depends on the meaning of the propositional
variables.
– Base cases: Truth Tables
True
True
False
False
Q
False
False
False
True
P
Q
False
True
True
True
P
Q
True
True
False
True
P
False
True
False
True
P
False
False
True
True
P
Q
P
Q
True
False
False
True
– Non-base Cases: Given by reduction to the base cases.
Ex: the meaning of (P ∨ Q) ∧ R is the same as the meaning of A ∧ R where
A has the same meaning as P ∨ Q.
Hantao Zhang
24
22c145-Fall’02: Knowledge Representation and Reasoning
The Meaning of Logical Connectives: A Warning
Disjunction
• A ∨ B is true when A or B or or both are true (inclusive or).
• A ⊕ B is sometimes used to mean “either A or B but not both” (exclusive or).
Implication
• A ⇒ B does not require a causal connection between A and B.
Ex: Sky-is-blue ⇒ Snow-is-white
• When A is false, A ⇒ B is always true regardless of the value of B.
Ex: Two-equals-four ⇒ Apples-are-red
• Beware of negations in implications.
Ex: (¬Has-blue-seal) ⇒ (¬Chiquita)
Hantao Zhang
25
22c145-Fall’02: Knowledge Representation and Reasoning
Semantics of Propositional Logic
• An assignment of Boolean values to the propositional variables of a
sentence is an interpretation of the sentence.
H)
False
False
True
False
H
((P
H)
H)
False
True
True
True
(P
False
True
False
True
H
False
False
True
True
P
H
P
P
True
True
True
True
• The semantics of Propositional logic is compositional:
– The meaning of a sentence is given recursively in terms of the
meaning of the sentence’s components (all the way down to its
propositional variables).
Hantao Zhang
26
22c145-Fall’02: Knowledge Representation and Reasoning
Semantics of Propositional Logic
The meaning of a sentence in general depends on its interpretation.
Some sentences, however, have always the same meaning.
H)
H
False
False
True
False
((P
H)
H)
False
True
True
True
(P
False
True
False
True
H
False
False
True
True
P
H
P
P
True
True
True
True
A sentence is
• satisfiable if it is true in some interpretation,
• valid if it is true in every possible interpretation.
Hantao Zhang
27
22c145-Fall’02: Knowledge Representation and Reasoning
Entailment in Propositional Logic
Given a set Γ of sentences and a sentence ϕ, we write
Γ |= ϕ
iff every interpretation that makes all sentences in Γ true makes ϕ also
true.
Γ |= ϕ is read as “Γ entails ϕ” or “ϕ logically follows from Γ.”
Hantao Zhang
28
22c145-Fall’02: Knowledge Representation and Reasoning
Entailment in Propositional Logic: Examples
{A, A ⇒ B}
{A}
{A, B}
{}
{A}
{A ∨ ¬A}
1.
2.
3.
4.
Hantao Zhang
A
False
False
True
True
B A⇒B
False True
True True
False False
True True
|=
|=
|=
|=
6|=
6|=
B
A∨B
A∧B
A ∨ ¬A
A∧B
A
A∨B
False
True
True
True
A ∧ B A ∨ ¬A
False True
False True
False True
True True
29
22c145-Fall’02: Knowledge Representation and Reasoning
Entailment in Propositional Logic
Note:
• Γ |= ϕ, for all ϕ ∈ Γ (inclusion property of PL)
• if Γ |= ϕ, then Γ0 |= ϕ for all Γ0 ⊇ Γ (monotonicity of PL)
• ϕ is valid iff True |= ϕ (also written as |= ϕ)
• ϕ is unsatisfiable iff ϕ |= False
• Γ |= ϕ iff the set Γ ∪ {¬ϕ} is unsatisfiable
Hantao Zhang
30
22c145-Fall’02: Knowledge Representation and Reasoning
Logical Equivalence
Two sentences ϕ1 and ϕ2 are logically equivalent
ϕ1 ≡ ϕ2
if ϕ1 |= ϕ2 and ϕ2 |= ϕ1.
Note:
• If ϕ1 ≡ ϕ2, every interpretation of their propositional variables will assign the same
Boolean value to ϕ1 and ϕ2.
• Implication and equivalence (⇒, ⇔), which are syntactical entities, are intimately
related to entailment and logical equivalence (|=, ≡), which are semantical notions:
ϕ1 |= ϕ2 iff |= ϕ1 ⇒ ϕ2
ϕ1 ≡ ϕ2 iff |= ϕ1 ⇔ ϕ2
Hantao Zhang
31