Propositional Logic Russell and Norvig Chapter 6 Chapter

  • Slides: 56
Download presentation
Propositional Logic Russell and Norvig: Chapter 6 Chapter 7, Sections 7. 1— 7. 4

Propositional Logic Russell and Norvig: Chapter 6 Chapter 7, Sections 7. 1— 7. 4 CS 121 – Winter 2003 Propositional Logic

Knowledge-Based Agent sensors ? environment agent actuators Knowledge base Propositional Logic 2

Knowledge-Based Agent sensors ? environment agent actuators Knowledge base Propositional Logic 2

Types of Knowledge Procedural, e. g. : functions Such knowledge can only be used

Types 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 Propositional Logic 3

Logic is a declarative language to: Assert sentences representing facts that hold in a

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 Propositional Logic 4

Connection World-Representation Sentences Conceptualization represent entail Sentences represent World W hold Facts about W

Connection World-Representation Sentences Conceptualization represent entail Sentences represent World W hold Facts about W hold Propositional Logic 5

Examples of Logics Propositional calculus A B C First-order predicate calculus ( x)( y)

Examples of Logics Propositional calculus A B C First-order predicate calculus ( x)( y) Mother(y, x) Logic of Belief B(John, Father(Zeus, Cronus)) Propositional Logic 6

Symbols of PL n n n Connectives: , , , Propositional symbols, e. g.

Symbols of PL n n n Connectives: , , , Propositional symbols, e. g. , P, Q, R, … True, False Propositional Logic 7

Syntax of PL sentence atomic sentence | complex sentence atomic sentence Propositional symbol, True,

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

Syntax of PL sentence atomic sentence | complex sentence atomic sentence Propositional symbol, True,

Syntax of PL sentence atomic sentence | complex sentence atomic sentence Propositional symbol, True, False Complex sentence | (sentence sentence) Examples: n n ((P Q) R) (A B) ( C) Propositional Logic 9

Order of Precedence Examples: n n A B C is equivalent to (( A)

Order of Precedence Examples: n n A B C is equivalent to (( A) B) C A B C is incorrect Propositional Logic 10

Model Assignment of a truth value – true or false – to every atomic

Model Assignment of a truth value – true or false – to every atomic sentence Examples: n n n 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 2 n models Propositional Logic 11

What Worlds Does a Model Represent? A model represents any world in which a

What Worlds Does a Model 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 Propositional Logic 12

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

Compare! BLOCK(A), BLOCK(B), BLOCK(C) ON(A, B), ON(B, C), ONTABLE(C) ON(A, B) ON(B, 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) Propositional Logic 13

Semantics of PL It specifies how to determine the truth value of any sentence

Semantics 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 Propositional Logic 14

Truth Tables A B A A B A B True False True False False

Truth Tables A B A A B A B True False True False False True False True Propositional Logic 15

Truth Tables A B A A B A B True False True False False

Truth Tables A B A A B A B True False True False False True False True Propositional Logic 16

Truth Tables A B A A B A B True False True False False

Truth Tables A B A A B A B True False True False False True False True Propositional Logic 17

About ODD(5) CAPITAL(Japan, Tokyo) EVEN(5) SMART(Sam) Read A B as: “If A IS True,

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. ” Propositional Logic 18

Example Model: A=True, B=False, C=False, D=True ( A B C) D A F F

Example Model: A=True, B=False, C=False, D=True ( A B C) D A F F T T T Definition: If a sentence s is true in a model m, then m is said to be a model of s Propositional Logic 19

A Small Knowledge Base 1. Battery-OK Bulbs-OK Headlights-Work 2. Battery-OK Starter-OK Empty-Gas-Tank 3. 4.

A Small Knowledge Base 1. Battery-OK Bulbs-OK Headlights-Work 2. Battery-OK Starter-OK Empty-Gas-Tank 3. 4. 5. Engine-Starts Flat-Tire Car-OK Headlights-Work Car-OK Sentences 1, 2, and 3 Background knowledge Sentences 4 and 5 Observed knowledge Propositional Logic 20

Model of a KB Let KB be a set of sentences A model m

Model 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 Propositional Logic 21

Satisfiability of a KB A KB is satisfiable iff it admits at least one

Satisfiability of a KB A KB is satisfiable iff it admits at least one model; otherwise it is unsatisfiable KB 1 = {P, Q R} is satisfiable KB 2 = { P P} is satisfiable KB 3 = {P, P} is unsatisfiable Propositional Logic valid sentence or tautology 22

3 -SAT Problem n propositional symbols P 1, …, Pn KB consists of p

3 -SAT Problem n propositional symbols P 1, …, Pn KB consists of p sentences of the form Qi Qj Qk where: n n i j k are indices in {1, …, n} Qi = Pi or Pi 3 -SAT: Is KB satisfiable? 3 -SAT is NP-complete Propositional Logic 23

Logical Entailment KB : set of sentences : arbitrary sentence KB entails – written

Logical Entailment KB : set of sentences : arbitrary sentence KB entails – written KB – iff every model of KB is also a model of Propositional Logic 24

Logical Entailment KB : set of sentences : arbitrary sentence KB entails – written

Logical Entailment KB : set of sentences : arbitrary sentence KB entails – written KB – iff every model of KB is also a model of Alternatively, KB iff n n {KB, } is unsatisfiable KB is valid Propositional Logic 25

Logical Equivalence Two sentences and are logically equivalent – written -- iff they have

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

Logical Equivalence Two sentences and are logically equivalent – written -- iff they have

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

Logical Equivalence Two sentences and are logically equivalent – written -- iff they have

Logical Equivalence Two sentences and are logically equivalent – written -- iff they have the same models, i. e. : iff and Examples: n n ( ) ( ) One can always replace a sentence by an equivalent one in a KB Propositional Logic 28

Inference Rule An inference rule { , } consists of 2 sentence patterns and

Inference Rule An inference rule { , } consists of 2 sentence patterns and called the conditions and one sentence pattern called the conclusion Propositional Logic 29

Inference Rule An inference rule { , } consists of 2 sentence patterns and

Inference 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 Propositional Logic 30

Example: Modus Ponens { , } Propositional Logic 31

Example: Modus Ponens { , } Propositional Logic 31

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Battery-OK Bulbs-OK Propositional Logic 32

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Battery-OK Bulbs-OK Propositional Logic 33

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Battery-OK Bulbs-OK Propositional Logic 34

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire

Example: Modus Ponens { , } Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Battery-OK Bulbs-OK Headlights-Work Propositional Logic 35

Example: Modus Tolens { , } Engine-Starts Flat-Tire Car-OK Propositional Logic 36

Example: Modus Tolens { , } Engine-Starts Flat-Tire Car-OK Propositional Logic 36

Example: Modus Tolens { , } Engine-Starts Flat-Tire Car-OK (Engine-Starts Flat-Tire) Propositional Logic 37

Example: Modus Tolens { , } Engine-Starts Flat-Tire Car-OK (Engine-Starts Flat-Tire) Propositional Logic 37

Example: Modus Tolens { , } Engine-Starts Flat-Tire Car-OK (Engine-Starts Flat-Tire) Engine-Starts Flat-Tire Propositional

Example: Modus Tolens { , } Engine-Starts Flat-Tire Car-OK (Engine-Starts Flat-Tire) Engine-Starts Flat-Tire Propositional Logic 38

Other Examples { , } { , . } Etc … Propositional Logic 39

Other Examples { , } { , . } Etc … Propositional Logic 39

Inference I: Set of inference rules KB: Set of sentences Inference is the process

Inference 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 Propositional Logic 40

Example 1. Battery-OK Bulbs-OK Headlights-Work 2. Battery-OK Starter-OK Empty-Gas-Tank Engine 3. 4. 5. 6.

Example 1. Battery-OK Bulbs-OK Headlights-Work 2. Battery-OK Starter-OK Empty-Gas-Tank Engine 3. 4. 5. 6. 7. 8. Starts Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Propositional Logic 41

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. Battery-OK Bulbs-OK Headlights-Work Battery-OK

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Propositional Logic 42

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Battery-OK Bulbs-OK Headlights-Work

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Battery-OK Starter-OK Empty-Gas-Tank (9+7) Propositional Logic 43

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Battery-OK Bulbs-OK

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Battery-OK Starter-OK Empty-Gas-Tank (9+7) Engine-Starts (2+10) Propositional Logic 44

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Battery-OK

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Battery-OK Starter-OK Empty-Gas-Tank (9+7) Engine-Starts (2+10) Engine-Starts Flat-Tire (3+8) Propositional Logic 45

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Battery-OK

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Battery-OK Starter-OK Empty-Gas-Tank (9+7) Engine-Starts (2+10) Engine-Starts Flat-Tire (3+8) Engine-Starts Flat-Tire Propositional Logic 46

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Battery-OK

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Battery-OK Starter-OK Empty-Gas-Tank (9+7) Engine-Starts (2+10) Engine-Starts Flat-Tire (3+8) Propositional Logic 47

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13.

Example 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Battery-OK Starter-OK Empty-Gas-Tank (9+7) Engine-Starts (2+10) Engine-Starts Flat-Tire (3+8) Flat-Tire (11+12) Propositional Logic 48

Soundness An inference rule is sound if it generates only entailed sentences Propositional Logic

Soundness An inference rule is sound if it generates only entailed sentences Propositional Logic 49

Soundness An inference rule is sound if it generates only entailed sentences All inference

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

 Connective symbol (implication) Logical entailment KB iff KB is valid Inference Propositional Logic

Connective symbol (implication) Logical entailment KB iff KB is valid Inference Propositional Logic 51

Soundness An inference rule is sound if it generates only entailed sentences All inference

Soundness 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 Propositional Logic 52

Completeness A set of inference rules is complete if every entailed sentences can be

Completeness A set of inference rules is complete if every entailed sentences can be obtained by applying some finite succession of these rules Modus ponens alone is not complete, e. g. : from A B and B, we cannot get A Propositional Logic 53

Proof The proof of a sentence from a set of sentences KB is the

Proof The proof of a sentence from a set of sentences KB is the derivation of by applying a series of sound inference rules Propositional Logic 54

Proof The proof of a sentence from a set of sentences KB is the

Proof The proof of a sentence from a set of sentences KB is the derivation of by applying a series of sound inference rules 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Battery-OK Starter-OK (5+6) Battery-OK Starter-OK Empty-Gas-Tank (9+7) Engine-Starts (2+10) Engine-Starts Flat-Tire (3+8) Flat-Tire (11+12) Propositional Logic 55

Summary Knowledge representation Propositional Logic Truth tables Model of a KB Satisfiability of a

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