cs510 software engineering
play

CS510 Software Engineering Propositional Logic Asst. Prof. Mathias - PowerPoint PPT Presentation

CS510 Software Engineering Propositional Logic Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-CS510-SE Spring 2015 Additional


  1. CS510 Software Engineering Propositional Logic Asst. Prof. Mathias Payer Department of Computer Science Purdue University TA: Scott A. Carr Slides inspired by Xiangyu Zhang http://nebelwelt.net/teaching/15-CS510-SE Spring 2015 Additional slides credit: Michael Reniers, Julia Lawall, and Neil Jones.

  2. Motivation Many static analysis techniques rely on proofing that some set of conditions hold. We need to come up with a way to express these conditions and reason about them. SAT solving allows to test the satisfiablity of propositional formulas in the domain of Boolean values. SAT solving is used for, e.g., formal equivalence checking, model checking, formal verification, automatic test pattern generation, scheduling problems, and symbolic execution. We need to understand propositional logic and SAT solving to follow the techniques listed above. Mathias Payer (Purdue University) CS510 Software Engineering 2015 2 / 60

  3. History of Logic Philosophical Logic (500BC to 19th century) Symbolic Logic (mid to late 19th century) Mathematical Logic (late 19th century to mid 20th century) Logic in Computer Science (now) Mathias Payer (Purdue University) CS510 Software Engineering 2015 3 / 60

  4. Syntax of propositional logic Table of Contents Syntax of propositional logic 1 Semantics of propositional logic 2 Semantic entailment 3 Natural deduction of proof system Soundness and completeness Validity and Satisfiability 4 Conjunctive normal forms SAT Solver 5 Mathias Payer (Purdue University) CS510 Software Engineering 2015 4 / 60

  5. Syntax of propositional logic Syntax F :== ( P ) | ( ¬ F ) | ( F ∨ F ) | ( F ∧ F ) | ( F → F ) P :== p | q | r | ... Propositional atoms ( p , q , r , ...) are used to describe declarative sentences like “1037 is a prime number”, “Every even number > 2 is the sum of two prime numbers”, or “All Martians like pepperoni on their pizza” (i.e., they can be evaluated to true or false). Connective Symbol Alternative Symbols negation (not) � = disjunction (or) ∨ | conjunction (and) ∧ & mplication (implies) → ⇒ , ⊃ , ⊆ Mathias Payer (Purdue University) CS510 Software Engineering 2015 5 / 60

  6. Syntax of propositional logic Syntax for propositional logic Binding priorities: ¬ , ∨ , ∧ , → , ↔ (These help reduce the amount of brackets needed. Also, outermost brackets are often omitted.) Mathias Payer (Purdue University) CS510 Software Engineering 2015 6 / 60

  7. Semantics of propositional logic Table of Contents Syntax of propositional logic 1 Semantics of propositional logic 2 Semantic entailment 3 Natural deduction of proof system Soundness and completeness Validity and Satisfiability 4 Conjunctive normal forms SAT Solver 5 Mathias Payer (Purdue University) CS510 Software Engineering 2015 7 / 60

  8. Semantics of propositional logic Semantics for Propositional Logic The meaning of a formula depends on: The meaning of the propositional atoms (occurring in the formula) The meaning of the connectives (occurring in the formula) Mathias Payer (Purdue University) CS510 Software Engineering 2015 8 / 60

  9. Semantics of propositional logic Semantics: Propositional Atoms The meaning of the propositional atoms (occurring in the formula): A declarative sentence is either true or false Captured as an assignment of truth values ( B = { T , F } ) to the propositional atoms a valuation v : P → B Mathias Payer (Purdue University) CS510 Software Engineering 2015 9 / 60

  10. Semantics of propositional logic Semantics: Connectives The meaning of an n -ary connective ⊕ is captured by a function f ⊕ : B n → B Usually, such functions are specified by a truth table. A B ¬ A A ∧ B A ∨ B A → B T T F T T T T F F F T F F T T F T T F F T F F T Mathias Payer (Purdue University) CS510 Software Engineering 2015 10 / 60

  11. Semantics of propositional logic Example: Formula Evaluation Evaluate the following formula: (p → q) ∧ (q → r) → (p → r) p q r p → q q → r . . . ∧ . . . p → r A ∧ B → C T T T T T T T T T T F T F F F T T F T F T F T T T F F F T F F T F T T T T T T T F T F T F F T T F F T T T T T T F F F T T T T T Mathias Payer (Purdue University) CS510 Software Engineering 2015 11 / 60

  12. Semantic entailment Table of Contents Syntax of propositional logic 1 Semantics of propositional logic 2 Semantic entailment 3 Natural deduction of proof system Soundness and completeness Validity and Satisfiability 4 Conjunctive normal forms SAT Solver 5 Mathias Payer (Purdue University) CS510 Software Engineering 2015 12 / 60

  13. Semantic entailment Areas of Interest Semantic entailment. Many logical arguments are of the form: from the assumptions φ 1 , φ 2 , . . . φ n we know ψ . This is formalised by the semantic entailment relation | =. E.g., M | = A describes that a situation M satisfies a formula A . Formally, φ 1 , φ 2 , . . . φ n | = ψ iff for all valuations v such that � φ i � ( v ) = T for all 1 ≤ i ≤ n we have � ψ � ( v ) = T Validity: a formula φ is valid if | = φ holds. Satisfiability: a formula φ is sat if there exists a valuation v so that � φ � ( v ) = T . Mathias Payer (Purdue University) CS510 Software Engineering 2015 13 / 60

  14. Semantic entailment Semantic Entailment How do we establish semantic entailment φ 1 , φ 2 , . . . φ n | = ψ ? Option 1: Construct a truth table. If formulas contain m propositional atoms, the truth table contains 2 m lines! Option 2: Give a proof. Suppose that ( p → q ) ∧ ( q → r ). Suppose that p . Then, as p → q follows from ( p → q ) ∧ ( q → r ), we have q . Finally, as q → r follows from ( p → q ) ∧ ( q → r ), we have r . Thus the formula holds (i.e., there is no contradiction). Mathias Payer (Purdue University) CS510 Software Engineering 2015 14 / 60

  15. Semantic entailment Semantic Entailment Proof rules for inferring a conclusion ψ from a list of premises φ 1 , φ 2 , . . . φ n ( x ⊢ y means that y is provable from x ): φ 1 , φ 2 , . . . φ n ⊢ ψ ( sequent ) What is a proof of a sequent φ 1 , φ 2 , . . . φ n ⊢ ψ ? Proof rules may be instantiated: consistent replacement of variables with formulas. Constructing the proof is filling the gap between the premises and the conclusion by applying a suitable sequence of proof rules. Mathias Payer (Purdue University) CS510 Software Engineering 2015 15 / 60

  16. Semantic entailment Natural deduction of proof system Natural Deduction: Conjunction Proof rules for conjunction : proofs of ψ ∧ φ are a concatenation of proofs for ψ and proofs of φ . ψ φ ∧ introduction: ψ ∧ φ ∧ i ψ ∧ φ ψ ∧ φ ∧ elimination: ∧ e 1 ∧ e 2 ψ φ Mathias Payer (Purdue University) CS510 Software Engineering 2015 16 / 60

  17. Semantic entailment Natural deduction of proof system Conjunction: Exercise Prove ( p ∧ q ) ∧ r , s ∧ t ⊢ q ∧ s . Given that we have ( p ∧ q ) ∧ r and s ∧ t we can prove q ∧ s . Linear representation: 1 ( p ∧ q ) ∧ r premise 2 s ∧ t premise 3 p ∧ q ∧ e 1 1 4 q ∧ e 2 3 5 s ∧ e 1 2 6 q ∧ s ∧ i 4,5 Mathias Payer (Purdue University) CS510 Software Engineering 2015 17 / 60

  18. Semantic entailment Natural deduction of proof system Conjunction: Exercise (2) Prove ( p ∧ q ) ∧ r , s ∧ t ⊢ q ∧ s . Given that we have ( p ∧ q ) ∧ r and s ∧ t we can prove q ∧ s . Tree representation: ( p ∧ q ) ∧ r ∧ e 1 s ∧ t p ∧ q ∧ e 2 ∧ e 1 q s ∧ i q ∧ s Mathias Payer (Purdue University) CS510 Software Engineering 2015 18 / 60

  19. Semantic entailment Natural deduction of proof system Natural Deduction: Disjunction Proof rules for disjunction : ψ φ ∨ introduction: ψ ∨ φ ∨ i 1 ψ ∨ φ ∨ i 2 φ ψ . . . . φ ∨ ψ . . χ χ ∨ elminiation: ∨ e χ Mathias Payer (Purdue University) CS510 Software Engineering 2015 19 / 60

  20. Semantic entailment Natural deduction of proof system Disjunction: Exercise Prove ( p ∧ q ) ∨ ( p ∧ r ) ⊢ p ∧ ( q ∨ r ): 1 ( p ∧ q ) ∨ ( p ∧ r ) premise 2 p ∧ q assumption (1) 3 p ∧ e 1 2 4 q ∧ e 2 2 5 q ∨ r ∨ i 1 4 6 p ∧ ( q ∨ r ) ∧ i 3, 5 7 p ∧ r assumption (2) 8 p ∧ e 1 7 9 r ∧ e 2 7 10 q ∨ r ∨ i 2 9 11 p ∧ ( q ∨ r ) ∧ i 8,10 12 p ∧ ( q ∨ r ) ∨ e 1, 2-6, 7-11 Mathias Payer (Purdue University) CS510 Software Engineering 2015 20 / 60

  21. Semantic entailment Natural deduction of proof system Natural Deduction: Implication Proof rules for implication : φ . . . ψ → introduction φ → ψ → i φ → ψ φ → elminiation → e ψ Mathias Payer (Purdue University) CS510 Software Engineering 2015 21 / 60

  22. Semantic entailment Natural deduction of proof system Implication: Exercise Prove p → q , q → r ⊢ p → r : 1 p → q premise 2 q → r premise 3 p assumption 4 q → e 1, 3 5 r → e 2, 4 6 p → r → i 3-5 Mathias Payer (Purdue University) CS510 Software Engineering 2015 22 / 60

  23. Semantic entailment Natural deduction of proof system Natural Deduction: Negation Proof rules for negation : φ . . . ⊥ ¬ introduction ¬ φ ¬ i ¬ φ φ ¬ elimination: ¬ q ⊥ Mathias Payer (Purdue University) CS510 Software Engineering 2015 23 / 60

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend