Automated Reasoning in Propositional Logic Russell and Norvig

  • Slides: 44
Download presentation
Automated Reasoning in Propositional Logic Russell and Norvig: Chapters 6 and 9 Chapter 7,

Automated Reasoning in Propositional Logic Russell and Norvig: Chapters 6 and 9 Chapter 7, Sections 7. 5— 7. 6 CS 121 – Winter 2003 Automated Reasoning in Propositional Logic

Problem Given: n n KB: a set of sentence : a sentence Answer: n

Problem Given: n n KB: a set of sentence : a sentence Answer: n KB ? Automated Reasoning in Propositional Logic 2

Deduction vs. Satisfiability Test KB iff {KB, } is unsatisfiable Hence: • Deciding whether

Deduction vs. Satisfiability Test KB iff {KB, } is unsatisfiable 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 Automated Reasoning in Propositional Logic 3

Computational Approaches Enumeration of models Construction of a proof 1. Battery-OK Bulbs-OK Headlights-Work 2.

Computational Approaches Enumeration of models Construction of a proof 1. Battery-OK Bulbs-OK Headlights-Work 2. Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts 3. Engine-Starts Flat-Tire Car-OK 4. Headlights-Work 5. Battery-OK 6. 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) Automated Reasoning in Propositional Logic 4

Enumeration of Models P: Set of propositional symbols in {KB, } n: Size of

Enumeration of Models P: Set of propositional symbols in {KB, } n: Size of P ENTAILS? (KB, ) For each of the 2 n models on P do If it is a model of {KB, } then return no Return yes Automated Reasoning in Propositional Logic 5

Satisfiability Test as CSP Each propositional symbol is a variable The domain of each

Satisfiability Test as CSP Each propositional symbol is a variable The domain of each variable is {True, False} Each sentence in {KB, } is a constraint on the value(s) taken by one or several variables Recursive backtracking CSP techniques and heuristics are applicable Automated Reasoning in Propositional Logic 6

Construction of a Proof 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

Construction of a Proof 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) Automated Reasoning in Propositional Logic 7

Construction of a Proof 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

Construction of a Proof 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 Headlight-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) What do we need? A complete set of sound inference rules A complete search algorithm to decide which rule to apply next and to which sentences Automated Reasoning in Propositional Logic 8

Complementary Literals A literal is a either an atomic sentence or the negated atomic

Complementary 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 Automated Reasoning in Propositional Logic 9

Unit Resolution Rule Given two sentences: L 1 … Lp and M where Li,

Unit Resolution Rule Given two sentences: L 1 … Lp and M where Li, …, Lp and M are all literals, and M and Li are complementary literals Infer: L 1 … Li-1 Li+1 … Lp Automated Reasoning in Propositional Logic 10

Examples From: Engine-Starts Infer: Car-OK Modus ponens Engine-Starts Car-OK From: Engine-Starts Car-OK Infer: Engine-Starts

Examples From: Engine-Starts Infer: Car-OK Modus ponens Engine-Starts Car-OK From: Engine-Starts Car-OK Infer: Engine-Starts Modus tolens Automated Reasoning in Propositional Logic 11

Another Example 1. Engine-Starts Flat-Tire Car-OK 2. Engine-Starts 3. Flat-Tire 4. Flat-Tire Car-OK 5.

Another Example 1. Engine-Starts Flat-Tire Car-OK 2. Engine-Starts 3. Flat-Tire 4. Flat-Tire Car-OK 5. Car-OK Automated Reasoning in Propositional Logic 12

Detection of Unsatisfiability 1. Car-OK 2. Car-OK 3. False Automated Reasoning in Propositional Logic

Detection of Unsatisfiability 1. Car-OK 2. Car-OK 3. False Automated Reasoning in Propositional Logic 13

Soundness of Unit Resolution Let m be a model of: L 1 … Lp

Soundness of Unit Resolution Let m be a model of: L 1 … Lp and M where M and Li are complementary literals Li must be False in m, hence L 1 … Li-1 Li+1 … Lp must be True Automated Reasoning in Propositional Logic 14

Shortcoming of Unit Resolution From: w Engine-Starts Flat-Tire Car-OK w Engine-Starts Empty-Gas-Tank we can

Shortcoming of Unit Resolution From: w Engine-Starts Flat-Tire Car-OK w Engine-Starts Empty-Gas-Tank we can infer nothing! Automated Reasoning in Propositional Logic 15

Full Resolution Rule Given two sentences: L 1 … Lp and M 1 …

Full Resolution Rule Given two sentences: L 1 … Lp and M 1 … Mq where L 1, …, Lp, M 1, …, Mq are all literals, and Li and Mj are complementary literals Infer: L 1 … Li-1 Li+1 … Lk M 1 … Mj-1 Mj+1 … Mk in which only one copy of each literal is retained (factoring) Automated Reasoning in Propositional Logic 16

Example From: Flat-Tire Car-OK Engine-Starts Empty-Gas-Tank Engine-Starts Infer: Empty-Gas-Tank Flat-Tire Car-OK Automated Reasoning in

Example From: Flat-Tire Car-OK Engine-Starts Empty-Gas-Tank Engine-Starts Infer: Empty-Gas-Tank Flat-Tire Car-OK Automated Reasoning in Propositional Logic 17

Example From: Q Q R P ( P Q) ( Q R) Infer: P

Example From: Q Q R P ( P Q) ( Q R) Infer: P R ( P R) Automated Reasoning in Propositional Logic 18

Not All Inferences are Useful! From: Flat-Tire Car-OK Engine-Starts Flat-Tire Engine-Starts Infer: Flat-Tire Car-OK

Not All Inferences are Useful! From: Flat-Tire Car-OK Engine-Starts Flat-Tire Engine-Starts Infer: Flat-Tire Car-OK Automated Reasoning in Propositional Logic 19

Not All Inferences are Useful! From: Flat-Tire Car-OK Engine-Starts Flat-Tire Engine-Starts Infer: Flat-Tire Car-OK

Not All Inferences are Useful! From: Flat-Tire Car-OK Engine-Starts Flat-Tire Engine-Starts Infer: Flat-Tire Car-OK tautology Automated Reasoning in Propositional Logic 20

Not All Inferences are Useful! From: Flat-Tire Car-OK Engine-Starts Flat-Tire Engine-Starts Infer: Flat-Tire Car-OK

Not All Inferences are Useful! From: Flat-Tire Car-OK Engine-Starts Flat-Tire Engine-Starts Infer: Flat-Tire Car-OK True tautology Automated Reasoning in Propositional Logic 21

Soundness of Full Resolution Left as an exercise Automated Reasoning in Propositional Logic 22

Soundness of Full Resolution Left as an exercise Automated Reasoning in Propositional Logic 22

Full Resolution Rule Given two sentences: L 1 … Lp and M 1 …

Full Resolution Rule Given two sentences: L 1 … Lp and M 1 … Mq Infer: L 1 … Li-1 Li+1 … Lk M 1 … Mj-1 Mj+1 … Mk Automated Reasoning in Propositional Logic clauses 23

Sentence Clause Form Example: (A B) (C D) Automated Reasoning in Propositional Logic 24

Sentence Clause Form Example: (A B) (C D) Automated Reasoning in Propositional Logic 24

Sentence Clause Form Example: (A B) (C D) 1. Eliminate (A B) (C D)

Sentence Clause Form Example: (A B) (C D) 1. Eliminate (A B) (C D) Automated Reasoning in Propositional Logic 25

Sentence Clause Form Example: (A B) (C D) 1. Eliminate (A B) (C D)

Sentence Clause Form Example: (A B) (C D) 1. Eliminate (A B) (C D) 2. Reduce scope of ( A B) (C D) Automated Reasoning in Propositional Logic 26

Sentence Clause Form Example: (A B) (C D) 1. Eliminate (A B) (C D)

Sentence Clause Form Example: (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) Automated Reasoning in Propositional Logic 27

Sentence Clause Form Example: (A B) (C D) 1. Eliminate (A B) (C D)

Sentence Clause Form Example: (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} Automated Reasoning in Propositional Logic 28

Resolution Refutation Algorithm RESOLUTION-REFUTATION(KB, a) clauses set of clauses obtained from KB and a

Resolution Refutation Algorithm RESOLUTION-REFUTATION(KB, a) clauses set of clauses obtained from KB and a new {} Repeat: For each C, C’ in clauses do res RESOLVE(C, C’) If res contains the empty clause then return yes new U res If new clauses then return no clauses U new Automated Reasoning in Propositional Logic 29

Completeness of Resolution Refutation Left as an exercise Automated Reasoning in Propositional Logic 30

Completeness of Resolution Refutation Left as an exercise Automated Reasoning in Propositional Logic 30

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. 14. 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 Flat-Tire Starter-OK Empty-Gas-Tank Engine-Starts Battery-OK Starter-OK Engine-Starts Flat-Tire Engine-Starts Car-OK Automated Reasoning in Propositional Logic 31

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. 14. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlight-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire Starter-OK Empty-Gas-Tank Engine-Starts Battery-OK Starter-OK Engine-Starts Flat-Tire Engine-Starts Car-OK Automated Reasoning in Propositional Logic 32

Example … Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire … Battery-OK Starter-OK Engine-Starts Flat-Tire … Automated

Example … Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire … Battery-OK Starter-OK Engine-Starts Flat-Tire … Automated Reasoning in Propositional Logic 33

Example … Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire … Battery-OK Starter-OK Engine-Starts Flat-Tire … Battery-OK

Example … Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire … Battery-OK Starter-OK Engine-Starts Flat-Tire … Battery-OK Starter-OK Flat-Tire … False (empty clause) Automated Reasoning in Propositional Logic 34

Resolution Heuristics Set-of-support heuristics: At least one ancestor of every inferred clause comes from

Resolution Heuristics Set-of-support heuristics: At least one ancestor of every inferred clause comes from a Shortest-clause heuristics: Generate a clause with the fewest literals first Simplifications heuristics: n Remove any clause containing two complementary literals (tautology) n Remove any clause C that contains all the literals of another clause C’ n If a symbol always appears with the same “sign”, remove all the clauses that contain it (pure symbol) Automated Reasoning in Propositional Logic 35

Example (Set-of-Support) 1. 2. 3. 4. 5. 6. 7. 8. 9. Battery-OK Bulbs-OK Headlights-Work

Example (Set-of-Support) 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 Headlight-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire Automated Reasoning in Propositional Logic 36

Example (Set-of-Support) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.

Example (Set-of-Support) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlight-Work Battery-OK Starter-OK Note the goal-directed Empty-Gas-Tank flavor Car-OK Flat-Tire Engine-Starts Car-OK Engine-Starts Battery-OK Starter-OK Empty-Gas-Tank False Automated Reasoning in Propositional Logic 37

Resolution Heuristics Set-of-support heuristics: At least one ancestor of every inferred clause comes from

Resolution Heuristics Set-of-support heuristics: At least one ancestor of every inferred clause comes from a Shortest-clause heuristics: Generate a clause with the fewest literals first Simplifications heuristics: n Remove any clause containing two complementary literals (tautology) n Remove any clause C that contains all the literals of another clause C’ n If a symbol always appears with the same “sign”, remove all the clauses that contain it (pure symbol) Automated Reasoning in Propositional Logic 38

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

Example (Shortest-Clause) 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 Headlight-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire Automated Reasoning in Propositional Logic 39

Example (Shortest-Clause) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.

Example (Shortest-Clause) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. Battery-OK Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank Engine-Starts Flat-Tire Car-OK Headlight-Work Battery-OK Starter-OK Empty-Gas-Tank Car-OK Flat-Tire Engine-Starts Car-OK Engine-Starts Bulbs-OK Headlights-Work Battery-OK Starter-OK Empty-Gas-Tank False Automated Reasoning in Propositional Logic 40

Resolution Heuristics Set-of-support heuristics: At least one ancestor of every inferred clause comes from

Resolution Heuristics Set-of-support heuristics: At least one ancestor of every inferred clause comes from a Shortest-clause heuristics: Generate a clause with the fewest literals first Simplifications heuristics: n Remove any clause containing two complementary literals (tautology) n Remove any clause C that contains all the literals of another clause C’ n If a symbol always appears with the same “sign”, remove all the clauses that contain it (pure symbol) Automated Reasoning in Propositional Logic 41

Example (Pure Literal) 1. 2. 3. 4. 5. 6. 7. 8. 9. Battery-OK Bulbs-OK

Example (Pure Literal) 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 Flat-Tire Automated Reasoning in Propositional Logic 42

When to Use Logic? When the knowledge base is large and can be made

When to Use Logic? When the knowledge base is large and can be made explicit When formulating a problem as a CSP problem would yield complex constraints When the agent’s environment is conveniently described by true or false sentences Automated Reasoning in Propositional Logic 43

Summary Entailment problem Resolution rule Clause form of a set of sentences Resolution refutation

Summary Entailment problem Resolution rule Clause form of a set of sentences Resolution refutation algorithm Resolution heuristics Automated Reasoning in Propositional Logic 44