Decision Procedures An Algorithmic Point of View Part I Basic Concepts and Background Basic Concepts and Background D. Kroening O. Strichman ETH/Technion Version 1.1, 2007 Outline Logic in Computer Science 1 What is Logic? Reasoning in AI 2 Deductive Systems Proofs in verification 3 Soundness and Completeness 4 Decidability Queries in Databases 5 Expressiveness . . . many more 6 Background on Propositional Logic D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 3 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 4 / 38 What is Logic? So what is Logic? Defined by Some useful definitions from the web: Syntax (including the Signature Σ of the logic: variables and their domain, ” Science dealing with the principles of valid reasoning and argument ” function and predicate symbols, quantifiers, etc.) ” A formal and powerful method of explaining why the program Semantics: Axioms and Inference rules doesn’t work ” ” The art of being wrong with confidence ” A logic allows us to infer theorems D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 5 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 6 / 38
Example: Propositional Logic A proof by deduction: example Syntax formula : Boolean-var | ¬ formula | formula ∨ formula | Notation: ⊢ H ϕ ’there exists a proof of ϕ in H ’ ( formula ) | T | F Theorem: ⊢ H ( A − → B ) − → (( B − → C ) − → ( A − → C )) Proof: (Syntactic sugar: formula ∧ formula | formula − → formula . . . ) 1. { A − → B, B − → C, A } ⊢ H A Premise Axioms: 2. { A − → B, B − → C, A } ⊢ H A − → B Premise 3. { A − → B, B − → C, A } ⊢ H B M.P. 1,2 ⊢ ( A − → ( B − → A )) 1 4. { A − → B, B − → C, A } ⊢ H B − → C Premise ⊢ (( A − → ( B − → C )) − → 2 A specific (one of many 5. { A − → B, B − → C, A } ⊢ H C M.P. 3,4 (( A − → B ) − → ( A − → C ))) possible) Deductive System 6. { A − → B, B − → C } ⊢ H ( A − → C ) Deduction 5 ⊢ ( ¬ B − → ¬ A ) − → ( A − → B ) 3 for Propositional Logic. 7. { A − → B } ⊢ H (( B − → C ) − → ( A − → C )) Deduction 6 It is known as the (Single) Inference Rule: Modus Ponens (MP) 8. ⊢ H ( A − → B ) − → (( B − → C ) − → ( A − → C )) Deduction 7 Hilbert System H . ⊢ A ⊢ A − → B ⊢ B D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 7 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 8 / 38 More on Semantics Satisfying Interpretations If an assignment α satisfies (according to the truth tables) Can be given via a formula ϕ , we write: α | = φ . axioms and inference rules, or using another (background) logic, or Example: via truth tables: ϕ : ¬ ( x 1 ∧ ¬ ( x 2 ∨ ¬ x 3 )) x 1 x 2 x 1 ∧ x 2 x 1 ∨ x 2 . . . T T T T Assignments for the example: T F F T α 1 : ( x 1 = T , x 2 = F , x 3 = F ) F T F T α 2 : ( x 1 = T , x 2 = F , x 3 = T ) F F F F α 1 | = ϕ , but α 2 �| = ϕ D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 9 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 10 / 38 Satisfiability, Validity, etc. A proof by enumeration: same example ( A − → B ) − → (( B − → C ) − → ( A − → C )) A B C Definition (Satisfiable) T T T T A formula ϕ is satisfiable if ∃ α. α | = ϕ . T T F T T F T T T F F T F T T T Definition (Valid) F T F T A formula ϕ is valid if ∀ α. α | = ϕ . If ϕ is valid, we write | = ϕ . F F T T F F F T | = ( A − → B ) − → (( B − → C ) − → ( A − → C )) Observation: ϕ is valid if and only if ¬ ϕ is unsatisfiable. D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 11 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 12 / 38
Soundness and completeness of a deductive system The decision problem Given a deductive system D , Definition (Decision Problem) D is sound for a logic L , if for every formula f in L , The decision problem for a formula: given ϕ , is ϕ valid? ⊢ D f − → | = f I.e., all formulas proven by the deductive system are valid. Definition (Decision Procedure) A decision procedure for a logic is an algorithm that solves the decision D is complete if for every formula f in L , problem for any formula in this logic. | = f − → ⊢ D f We are naturally interested in a sound and complete decision procedure. I.e., the deductive system can prove all valid formulas. D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 13 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 14 / 38 Soundness and Completeness Soundness and Completeness Soundness: ”when I say that it rains, it rains, and when I say it doesn’t rain, it doesn’t rain” What does it mean that a decision procedure is sound and complete? Completeness: ”When asked, I always reply (in a finite time) whether Soundness: the answer returned by the decision procedure is always it rains” correct (Question: ”correct” according to what?) Completeness: returns with a yes/no answer in finite time. (Question: How does this definition relate to the definition of completeness Definition of a deduction system?) A logic is decidable ⇐ ⇒ there is a sound and complete algorithm that decides if a well-formed expression in this logic is valid. D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 15 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 16 / 38 Soundness and Completeness (cont’d) Soundness and Completeness (cont’d) Algorithm #2 for checking if it rains outside: stand right outside the door and say ’it rains’ Algorithm #1: for checking if it rains outside: if and only if you feel the rain. stand right outside the door and say ’it rains’ It is sound because you say it rains only if it actually rains. It is not sound because you might say it rains when it doesn’t. It is incomplete because you do not say anything if it doesn’t rain (we But it is complete: you always get an answer in a finite time. do not know whether it doesn’t rain, or it takes the person too long to answer . . . ). D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 17 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 18 / 38
Decidability Inference engines We saw that in Propositional Logic we can infer using either a Propositional logic is decidable deductive system (’deduction’) or truth tables (’enumeration’). ⇒ there is a sound and complete algorithm (e.g., truth tables) to decide whether a propositional formula is valid. Which, in the general case, is the better method? Arithmetic over integers is . . . ? . . . undecidable All logics have a deductive definition. (this is G¨ odel’s incompleteness result) NOT all logics can be decided with an enumerative method. D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 19 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 20 / 38 Whenever we can: build an engine to think for us Deduction vs. enumeration Deductive methods Enumerative methods Axioms and inference rules Truth tables Requires thinking... Requires pressing ’Enter’... D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 21 / 38 Expressiveness of a logic Expressiveness of a logic Now consider the Propositional Logic formula Each formula defines a language: ϕ : x 1 ∨ x 2 ∨ x 3 the set of satisfying assignments (’models’) are the words accepted by this language. Q: Can we express this language with 2-CNF? A: No. Consider the logic ’2-CNF’ formula : literal ∨ literal | formula ∧ formula Proof. literal : Boolean-variable | ¬ Boolean-variable The language accepted by ϕ has 7 words: all assignments other than A ’2-CNF’ formula: ( x 1 ∨ ¬ x 2 ) ∧ ( ¬ x 3 ∨ x 2 ) x 1 = x 2 = x 3 = F . The first 2-CNF clause removes 1 4 of the assignments, which leaves us with 6 accepted words. Additional clauses only remove more assignments. D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 23 / 38 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.1, 2007 24 / 38
Recommend
More recommend