propositional logic russell and norvig: chapter 6 chapter 7, sections 7.1—7.4 slides adapted from:...
TRANSCRIPT
Propositional LogicPropositional Logic
Russell and Norvig: Chapter 6Chapter 7, Sections 7.1—7.4Slides adapted from:robotics.stanford.edu/~latombe/cs121/2003/home.htm
Types of KnowledgeTypes of Knowledge
Procedural, e.g.: functions Such knowledge can only be used in one way -- by executing it
Declarative, e.g.: constraints It can be used to perform many different sorts of inferences
LogicLogic
Logic is a declarative language to:
Assert sentences representing facts that hold in a world W (these sentences are given the value true)
Deduce the true/false values to sentences representing other aspects of W
Connection World-Connection World-
RepresentationRepresentation
World W
Conceptualization
Facts about W
hold
hold
Sentences
represent
Facts about W
represent
Sentencesentail
Examples of LogicsExamples of Logics
Propositional calculus A B C First-order predicate calculus ( x)( y) Mother(y,x) Logic of Belief B(John,Father(Zeus,Cronus))
ModelModel
Assignment of a truth value – true or false – to every atomic sentenceExamples: Let A, B, C, and D be the propositional
symbols m = {A=true, B=false, C=false, D=true} is a
model m’ = {A=true, B=false, C=false} is not a
model
With n propositional symbols, one can define 2n models
Model of a KBModel of a KB
Let KB be a set of sentences
A model m is a model of KB iff it is a model of all sentences in KB, that is, all sentences in KB are true in m Given a vocabulary A, B, C and D, how
many models for A^B -> C are there? for A^B -> B?
Satisfiability of a KBSatisfiability of a KB
A KB is satisfiable iff it admits at least one model; otherwise it is unsatisfiable
KB1 = {P, QR} is satisfiable
KB2 = {PP} is satisfiable
KB3 = {P, P} is unsatisfiable
valid sentenceor tautology
Logical EntailmentLogical Entailment
KB : set of sentences : arbitrary sentence KB entails – written KB – iff every model of KB is also a model of Alternatively, KB iff {KB,} is unsatisfiable KB is valid
Inference RuleInference Rule
An inference rule {, } consists of 2 sentence patterns and called the conditions and one sentence pattern called the conclusion If and match two sentences of KB then the corresponding can be inferred according to the rule
InferenceInference
I: Set of inference rules KB: Set of sentences Inference is the process of applying successive inference rules from I to KB, each rule adding its conclusion to KB
Example: Modus PonensExample: Modus Ponens
Battery-OK Bulbs-OK Headlights-WorkBattery-OK Starter-OK Empty-Gas-Tank Engine-StartsEngine-Starts Flat-Tire Car-OKBattery-OK Bulbs-OK
{ , }
{, }
SoundnessSoundness
An inference rule is sound if it generates only entailed sentences All inference rules previously given are sound, e.g.:modus ponens: { , } The following rule: { , } is unsound, which does not mean it is useless
CompletenessCompleteness
A set of inference rules is complete if every entailed sentences can be obtained by applying some finite succession of these rulesModus ponens alone is not complete, e.g.:from A B and B, we cannot get A
ProofProof
The proof of a sentence from a set of sentences KB is the derivation of by applying a series of sound inference rules
ProofProof
The proof of a sentence from a set of sentences KB is the derivation of by applying a series of sound inference rules
1. Battery-OK Bulbs-OK Headlights-Work2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts3. Engine-Starts Flat-Tire Car-OK4. Headlights-Work5. Battery-OK6. Starter-OK 7. Empty-Gas-Tank 8. Car-OK 9. Battery-OK Starter-OK (5+6)10. Battery-OK Starter-OK Empty-Gas-Tank (9+7)11. Engine-Starts (2+10)12. Engine-Starts Flat-Tire (3+8)13. Flat-Tire (11+12)
KB iff {KB,} is unsatisfiable
Deduction vs. Satisfiability Deduction vs. Satisfiability TestTest
Hence:• Deciding whether a set of
sentences entails another sentence, or not
• Testing whether a set of sentences is satisfiable, or not
are closely related problems
Complementary LiteralsComplementary Literals
A literal is a either an atomic sentence or the negated atomic sentence, e.g.: P or P
Two literals are complementary if one is the negation of the other, e.g.: P and P
Unit Resolution RuleUnit Resolution Rule
Given two sentences: L1 … Lp and M where Li,…, Lp and M are all literals, and M and Li are complementary literalsInfer: L1 … Li-1 Li+1 … Lp
ExamplesExamplesFrom:
Engine-Starts Car-OKEngine-Starts
Infer:Car-OK From:
Engine-Starts Car-OKCar-OK
Infer: Engine-Starts
Modus ponens
Modus tolens
Engine-Starts Car-OK
Shortcoming of Unit Shortcoming of Unit ResolutionResolution
From:
Engine-Starts Flat-Tire Car-OK
Engine-Starts Empty-Gas-Tank
we can infer nothing!
Full Resolution RuleFull Resolution Rule
Given two sentences: L1 … Lp and M1 … Mq where L1,…, Lp, M1,…, Mq are all literals, and Li and Mj are complementary literalsInfer: L1 … Li-1Li+1…LkM1 … Mj-1Mj+1…Mk
in which only one copy of each literal is retained (factoring)
ExampleExample
From:
Engine-Starts Flat-Tire Car-OK
Engine-Starts Empty-Gas-Tank
Infer:
Empty-Gas-Tank Flat-Tire Car-OK
Not All Inferences are Not All Inferences are Useful! Useful!
From:
Engine-Starts Flat-Tire Car-OK
Engine-Starts Flat-Tire
Infer:
Flat-Tire Flat-Tire Car-OK
Not All Inferences are Not All Inferences are Useful!Useful!
From:
Engine-Starts Flat-Tire Car-OK
Engine-Starts Flat-Tire
Infer:
Flat-Tire Flat-Tire Car-OK
tautology
Not All Inferences are Not All Inferences are Useful!Useful!
From:
Engine-Starts Flat-Tire Car-OK
Engine-Starts Flat-Tire
Infer:
Flat-Tire Flat-Tire Car-OK True
tautology
Full Resolution RuleFull Resolution Rule
Given two clauses: L1 … Lp and M1 … Mq
Infer the clause: L1 … Li-1Li+1…LkM1 … Mj-1Mj+1…Mk
Sentence Sentence Clause Form Clause FormExample:
(A B) (C D)
1. Eliminate (A B) (C D)2. Reduce scope of (A B) (C D)3. Distribute over
(A (C D)) (B (C D))(A C) (A D) (B C) (B D)
Set of clauses:{A C , A D , B C , B D}
Resolution Refutation Resolution Refutation AlgorithmAlgorithm
RESOLUTION-REFUTATION(KB)clauses set of clauses obtained from KB and new {}Repeat:
For each C, C’ in clauses dores RESOLVE(C,C’)If res contains the empty clause then
return yesnew new U res
If new clauses then return noclauses clauses U new
ExampleExample1. Battery-OK Bulbs-OK Headlights-Work2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts3. Engine-Starts Flat-Tire Car-OK4. Headlights-Work5. Battery-OK6. Starter-OK 7. Empty-Gas-Tank 8. Car-OK 9. Flat-Tire