propositional logic

56
Propositional Logic Propositional Logic Russell and Norvig: Chapter 6 Chapter 7, Sections 7.1—7.4

Upload: nile

Post on 25-Feb-2016

32 views

Category:

Documents


1 download

DESCRIPTION

Propositional Logic. Russell and Norvig: Chapter 6 Chapter 7, Sections 7.1—7.4. sensors. environment. ?. agent. actuators. Knowledge base. Knowledge-Based Agent. Types of Knowledge. Procedural , e.g.: functions Such knowledge can only be used in one way -- by executing it - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Propositional Logic

Propositional LogicPropositional Logic

Russell and Norvig: Chapter 6Chapter 7, Sections 7.1—7.4

Page 2: Propositional Logic

Propositional Logic 2

Knowledge-Based AgentKnowledge-Based Agent

environmentagent

?

sensors

actuators

Knowledge base

Page 3: Propositional Logic

Propositional Logic 3

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

Page 4: Propositional Logic

Propositional Logic 4

LogicLogicLogic 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

Page 5: Propositional Logic

Propositional Logic 5

Connection World-Connection World-RepresentationRepresentation

World WConceptualization

Facts about Whold

hold

Sentencesrepresent

Facts about W

represent

Sentencesentail

Page 6: Propositional Logic

Propositional Logic 6

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))

Page 7: Propositional Logic

Propositional Logic 7

Symbols of PLSymbols of PL

Connectives: , , , Propositional symbols, e.g., P, Q, R, … True, False

Page 8: Propositional Logic

Propositional Logic 8

Syntax of PLSyntax of PL sentence atomic sentence | complex sentence atomic sentence Propositional symbol, True, False Complex sentence sentence | (sentence sentence) | (sentence sentence) | (sentence sentence)

Page 9: Propositional Logic

Propositional Logic 9

Syntax of PLSyntax of PL sentence atomic sentence | complex sentence atomic sentence Propositional symbol, True, False Complex sentence sentence | (sentence sentence) | (sentence sentence) | (sentence sentence)

Examples: ((P Q) R) (A B) (C)

Page 10: Propositional Logic

Propositional Logic 10

Order of PrecedenceOrder of Precedence

Examples: A B C is equivalent to ((A)B)C A B C is incorrect

Page 11: Propositional Logic

Propositional Logic 11

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

Page 12: Propositional Logic

Propositional Logic 12

What Worlds Does a Model What Worlds Does a Model Represent?Represent?

A model represents any world in which a fact represented by a proposition A having the value True holds and a fact represented by a proposition B having the value False does not hold

A model represents infinitely many worlds

Page 13: Propositional Logic

Propositional Logic 13

Compare!Compare!

BLOCK(A), BLOCK(B), BLOCK(C) ON(A,B), ON(B,C), ONTABLE(C) ON(A,B) ON(B,C) ABOVE(A,C)

ABOVE(A,C)

HUMAN(A), HUMAN(B), HUMAN(C) CHILD(A,B), CHILD(B,C), BLOND(C) CHILD(A,B) CHILD(B,C) GRAND-CHILD(A,C) GRAND-CHILD(A,C)

Page 14: Propositional Logic

Propositional Logic 14

Semantics of PLSemantics of PL It specifies how to determine the truth value of any sentence in a model m The truth value of True is True The truth value of False is False The truth value of each atomic sentence is given by m The truth value of every other sentence is obtained recursively by using truth tables

Page 15: Propositional Logic

Propositional Logic 15

Truth TablesTruth Tables

A B A A B A B A BTrue True False True True True

True False False False True False

False False True False False True

False True True False True True

Page 16: Propositional Logic

Propositional Logic 16

Truth TablesTruth Tables

A B A A B A B A BTrue True False True True True

True False False False True False

False False True False False True

False True True False True True

Page 17: Propositional Logic

Propositional Logic 17

Truth TablesTruth Tables

A B A A B A B A BTrue True False True True True

True False False False True False

False False True False False True

False True True False True True

Page 18: Propositional Logic

Propositional Logic 18

About About

ODD(5) CAPITAL(Japan,Tokyo)EVEN(5) SMART(Sam)Read A B as:“If A IS True, then I claim that B is True, otherwise I make no claim.”

Page 19: Propositional Logic

Propositional Logic 19

ExampleExample

(A B C) D AModel: A=True, B=False, C=False, D=True

FF

TTT

Definition: If a sentence s is true in a model m, then m is said to be a model of s

Page 20: Propositional Logic

Propositional Logic 20

A Small Knowledge BaseA Small Knowledge Base1. Battery-OK Bulbs-OK Headlights-Work2. Battery-OK Starter-OK Empty-Gas-Tank

Engine-Starts3. Engine-Starts Flat-Tire Car-OK4. Headlights-Work5. Car-OK

Sentences 1, 2, and 3 Background knowledgeSentences 4 and 5 Observed knowledge

Page 21: Propositional Logic

Propositional Logic 21

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

Page 22: Propositional Logic

Propositional Logic 22

Satisfiability of a KBSatisfiability of a KBA 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 unsatisfiablevalid sentenceor tautology

Page 23: Propositional Logic

Propositional Logic 23

3-SAT Problem3-SAT Problem n propositional symbols P1,…,Pn KB consists of p sentences of the form

Qi Qj Qkwhere: i j k are indices in {1,…,n} Qi = Pi or Pi 3-SAT: Is KB satisfiable? 3-SAT is NP-complete

Page 24: Propositional Logic

Propositional Logic 24

KB : set of sentences : arbitrary sentence KB entails – written KB – iff every model of KB is also a model of

Logical EntailmentLogical Entailment

Page 25: Propositional Logic

Propositional Logic 25

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

Page 26: Propositional Logic

Propositional Logic 26

Logical EquivalenceLogical Equivalence Two sentences and are logically equivalent – written -- iff they have the same models, i.e.: iff and

Page 27: Propositional Logic

Propositional Logic 27

Logical EquivalenceLogical Equivalence Two sentences and are logically equivalent – written -- iff they have the same models, i.e.: iff and Examples: ( ) ( ) ( ) ( )

Page 28: Propositional Logic

Propositional Logic 28

Logical EquivalenceLogical Equivalence Two sentences and are logically equivalent – written -- iff they have the same models, i.e.: iff and Examples: ( ) ( ) ( ) ( )

One can always replace a sentence by an equivalent one in a KB

Page 29: Propositional Logic

Propositional Logic 29

Inference RuleInference Rule

An inference rule {, } consists of 2 sentence patterns and called the conditions and one sentence pattern called the conclusion

Page 30: Propositional Logic

Propositional Logic 30

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

Page 31: Propositional Logic

Propositional Logic 31

Example: Modus PonensExample: Modus Ponens

{ , }

{, }

Page 32: Propositional Logic

Propositional Logic 32

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

{ , }

{, }

Page 33: Propositional Logic

Propositional Logic 33

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

{ , }

{, }

Page 34: Propositional Logic

Propositional Logic 34

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

{ , }

{, }

Page 35: Propositional Logic

Propositional Logic 35

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-OKHeadlights-Work

{ , }

{, }

Page 36: Propositional Logic

Propositional Logic 36

Example: Modus TolensExample: Modus Tolens

Engine-Starts Flat-Tire Car-OKCar-OK

{ , }

Page 37: Propositional Logic

Propositional Logic 37

Example: Modus TolensExample: Modus Tolens

Engine-Starts Flat-Tire Car-OKCar-OK (Engine-Starts Flat-Tire)

{ , }

Page 38: Propositional Logic

Propositional Logic 38

Example: Modus TolensExample: Modus Tolens

Engine-Starts Flat-Tire Car-OKCar-OK (Engine-Starts Flat-Tire) Engine-Starts Flat-Tire

{ , }

Page 39: Propositional Logic

Propositional Logic 39

Other ExamplesOther Examples

{,} {,.} {,.} Etc …

Page 40: Propositional Logic

Propositional Logic 40

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

Page 41: Propositional Logic

Propositional Logic 41

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

Page 42: Propositional Logic

Propositional Logic 42

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. Battery-OK Starter-OK (5+6)

Page 43: Propositional Logic

Propositional Logic 43

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. Battery-OK Starter-OK (5+6)10. Battery-OK Starter-OK Empty-Gas-Tank (9+7)

Page 44: Propositional Logic

Propositional Logic 44

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. Battery-OK Starter-OK (5+6)10. Battery-OK Starter-OK Empty-Gas-Tank (9+7)11. Engine-Starts (2+10)

Page 45: Propositional Logic

Propositional Logic 45

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. 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)

Page 46: Propositional Logic

Propositional Logic 46

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. 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) Engine-Starts Flat-Tire

Page 47: Propositional Logic

Propositional Logic 47

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. 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)

Page 48: Propositional Logic

Propositional Logic 48

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. 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)

Page 49: Propositional Logic

Propositional Logic 49

SoundnessSoundness An inference rule is sound if it generates only entailed sentences

Page 50: Propositional Logic

Propositional Logic 50

SoundnessSoundness An inference rule is sound if it generates only entailed sentences All inference rules previously given are sound, e.g.:modus ponens: { , }

Page 51: Propositional Logic

Propositional Logic 51

Connective symbol (implication)

Logical entailment

Inference

KB iff KB is valid

Page 52: Propositional Logic

Propositional Logic 52

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

Page 53: Propositional Logic

Propositional Logic 53

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

Page 54: Propositional Logic

Propositional Logic 54

ProofProofThe proof of a sentence from a set of sentences KB is the derivation of by applying a series of sound inference rules

Page 55: Propositional Logic

Propositional Logic 55

ProofProofThe 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-Work

2. 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)

Page 56: Propositional Logic

Propositional Logic 56

SummarySummary

Knowledge representation Propositional Logic Truth tables Model of a KB Satisfiability of a KB Logical entailment Inference rules Proof