Presentation is loading. Please wait.

Presentation is loading. Please wait.

Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.

Similar presentations


Presentation on theme: "Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background."— Presentation transcript:

1 Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background

2 Decision Procedures An algorithmic point of view2 Outline What is Logic Proofs by deduction Proofs by enumeration Decidability, soundness and completeness Some notes on Propositional Logic

3 Decision Procedures An algorithmic point of view3 What is Logic? Some useful definitions on the web:  “science dealing with the principles of valid reasoning and argument”  “A formal and powerful method of explaining why the program doesn't work”  “The art of being wrong with confidence”

4 Decision Procedures An algorithmic point of view4 So what is Logic? Defined by  Syntax (including the Signature of the logic  : variables and their domain, function and predicate symbols, quantifiers, etc)  Axioms and Inference rules. A logic allows us to infer theorems.

5 Decision Procedures An algorithmic point of view5 Example: Propositional Logic Syntax formula: Boolean-var | : formula | formula Ç formula | ( formula ) | T | F (Can also use: formula Æ formula | formula ! formula…) Axioms: 1. ` (A ! (B ! A)) 2. ` ((A ! (B ! C)) ! ((A ! B) ! (A ! C))) 3. ` ( : B ! : A) ! (A ! B) Inference Rule: Modus Ponens (MP) ` A ` A ! B ` B A specific (one of many possible) Deductive System for Propositional Logic. It is known as the Hilbert System H.

6 Decision Procedures An algorithmic point of view6 A proof by deduction: example Notation: ` H  ‘there exists a proof of  in H ’ Theorem: ` H (A ! B) ! ((B ! C) ! (A ! C)) 1. {A ! B, B ! C, A} ` H APremise 2. {A ! B, B ! C, A} ` H A ! BPremise 3. {A ! B, B ! C, A} ` H BM.P. 1,2 4. {A ! B, B ! C, A} ` H B ! CPremise 5. {A ! B, B ! C, A} ` H CM.P. 3,4 6. {A ! B, B ! C} ` H (A ! C)Deduction 5 7. {A ! B} ` H ((B ! C) ! (A ! C))Deduction 6 8. ` H (A ! B) ! ((B ! C) ! (A ! C))Deduction 7

7 Decision Procedures An algorithmic point of view7 Semantics Can be given via axioms and inference rules, or Can be given via truth tables x1x1 x2x2 x1 Æ x2x1 Æ x2 x1 Ç x2x1 Ç x2... TTTT TFFT FTFT FFFF

8 Decision Procedures An algorithmic point of view8 Satisfying interpretations If an assignment  satisfies (according to the truth tables) a formula , we write:  ² . Example:  : : ( x 1 Æ : ( x 2 Ç : x 3 ))    : ( x 1 = T, x 2 = F, x 3 = F)   ²     : ( x 1 = T, x 2 = F, x 3 = T)  2 2 

9 Decision Procedures An algorithmic point of view9 Satisfiability, Validity, etc. Definition (Satisfiability): A formula  is satisfiable if 9  ²  Definition (Validity): A formula  is valid if 8   ² . If  is valid, we write ² . Observation:  is valid if and only if :  is unsatisfiable.

10 Decision Procedures An algorithmic point of view10 A proof by enumeration: same example ABC(A ! B) ! ((B ! C) ! (A ! C)) TTTT TTFT TFTT TFFT FTTT FTFT FFTT FFFT ²

11 Decision Procedures An algorithmic point of view11 Soundness and completeness of a deductive system Given a deductive system D,  D is sound for a logic L, if for every formula f in L, ` D f ! ² f  D is complete if for every formula f in L, ² f ! ` D f

12 Decision Procedures An algorithmic point of view12 The decision problem Definition (the decision problem): The decision problem for a formula: given , is  valid? Definition (decision Procedure for a logic): A decision procedure for a logic is an algorithm that solves the decision problem for any formula in this logic. We are naturally interested in a sound and complete decision procedure.

13 Decision Procedures An algorithmic point of view13 Soundness and Completeness What does it mean that a decision procedure is sound and complete?  Soundness: the answer returned by the decision procedure is always 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 of a deduction system?)

14 Decision Procedures An algorithmic point of view14 Soundness and Completeness Soundness: “when I say that it rains, it rains, and when I say it doesn’t rain, it doesn’t rain” Completeness: “If asked, I always reply (in a finite time…) whether it rains” A logic is decidable  there is a sound and complete algorithm that decides if a well-formed expression in this logic is valid.

15 Decision Procedures An algorithmic point of view15 Soundness and Completeness (cont’d) Algorithm #1: for checking if it rains outside: “stand right outside the door and say ‘it rains’” It is not sound because you might say it rains when it doesn’t. But it is complete: you always get an answer in a finite time.

16 Decision Procedures An algorithmic point of view16 Soundness and Completeness (cont’d) Algorithm #2 for checking if it rains outside: “stand right outside the door and say ‘it rains’ if and only if you feel the rain” It is sound because you say it rains only if it actually rains. It is incomplete because you do not say anything if it doesn’t rain (we do not know whether it doesn’t rain, or it takes the person too long to answer…).

17 Decision Procedures An algorithmic point of view17 Decidability Propositional logic is decidable  there is a sound and complete algorithm (e.g., truth tables) to decide whether a propositional formula is valid. Arithmetic over integers is undecidable (this is Gödel's incompleteness result)

18 Decision Procedures An algorithmic point of view18 Inference engines We saw that in Propositional Logic we can infer with both a deductive system (“deduction”) and truth tables (“enumeration”). Which, in the general case, is the better method? All logics have a deductive definition. NOT all logics can be decided with an enumerative method.

19 Decision Procedures An algorithmic point of view19 Deductive methods Axioms and Inference rules Enumerative methods “Truths tables” Or Requires thinking… Requires pressing ‘Enter’… Whenever we can: build an engine to think for us

20 Decision Procedures An algorithmic point of view20 Expressiveness of a logic Each formula defines a language: the set of satisfying assignments (‘models’) are the words accepted by this language. Consider the logic ‘2-CNF’ formula : ( literal Ç literal ) | formula Æ formula literal: Boolean-variable | : Boolean-variable ( x 1 Ç : x 2 ) Æ ( : x 3 Ç x 2 )

21 Decision Procedures An algorithmic point of view21 Expressiveness of a logic Now consider a Propositional Logic formula  ( x 1 Ç x 2 Ç x 3 ). Q: Can we express this language with 2-CNF? A: No. Proof:  The language accepted by  has 7 words: all assignments other than x 1 = x 2 = x 3 = F.  The first 2-CNF clause removes ¼ of the assignments, which leaves us with 6 accepted words. Additional clauses only remove more assignments.

22 Decision Procedures An algorithmic point of view22 Expressiveness of a logic Claim: 2-CNF Á Propositional Logic Generally there is only a partial order between logics. Languages defined by L 2 Languages defined by L 1 L 2 is more expressive than L 1. Denote: L 1 Á L 2

23 Decision Procedures An algorithmic point of view23 Tradeoff: expressiveness/computational hardness. Assume we are given logics L 1 Á … Á L n More expressive Easier to decide UndecidableDecidable Intractable (exponential) Tractable (polynomial) Computational Challenge! LnLn L1L1 Our course

24 Decision Procedures An algorithmic point of view24 When is a specific logic useful? 1. Expressible enough to state something interesting. 2. Decidable (or semi-decidable) and more efficiently solvable than richer logics. 3. More expressible, or more natural for expressing some models in comparison to ‘leaner’ logics.

25 Decision Procedures An algorithmic point of view25 Example: First Order Peano Arithmetic constants: 0,1 Function symbols: ‘+’, ‘*’, Predicate symbol: ‘=’ Domain: Natural numbers Axioms (“semantics”): 1. 8 x : (0  x + 1) 2. 8 x : 8 y : (x  y) ! (x + 1  y + 1) 3. Induction 4. 8 x : x + 0 = x 5. 8 x : 8 y : (x + y) + 1 = x + (y + 1) 6. 8 x : x * 0 = 0 7. 8 x 8 y : x * (y + 1) = x * y + x + * Undecidable! These axioms define the semantics of ‘+’

26 Decision Procedures An algorithmic point of view26 Example: Presburger Arithmetic constants: 0,1 Function symbols: ‘+’, ‘*’, Predicate symbol: ‘=’ Domain: Natural numbers Axioms (“semantics”): 1. 8 x : (0  x + 1) 2. 8 x : 8 y : (x  y) ! (x + 1  y + 1) 3. Induction 4. 8 x : x + 0 = x 5. 8 x : 8 y : (x + y) + 1 = x + (y + 1) 6. 8 x : x * 0 = 0 7. 8 x 8 y : x * (y + 1) = x * y + x + * Decidable!

27 Decision Procedures An algorithmic point of view27 Logic in Computer Science Reasoning in AI Proofs in verification Queries in Databases … many more

28 Decision Procedures An algorithmic point of view28 Some notes on Propositional Logic The simplest of them all NP-complete Exceptionally efficient solvers (SAT engines, BDDs) Formulas with 10 5 variables are being solved regularly All the logics that we will consider can be reduced directly to this logic

29 Decision Procedures An algorithmic point of view29 Some notes on Propositional Logic A literal: v : v positive literal negative literal Also known as ‘the phase’, or ‘the polarity’ of the literal. The “logical phase” of a literal can be computed by counting the number of negations that nest it:  v is logically negative in: : v, : ( : ( : v )), v ! u, : ( u ! v )  v is logically positive in: v, : ( v ! u )

30 Decision Procedures An algorithmic point of view30 Some notes on Propositional Logic Normal forms:  Conjunctive Normal Form (CNF)  Disjunctive Normal Form (DNF) (for which satisfiability is in P)  Negation Normal Form (NNF) (all negations are over literals, not sub formulas) CNF and DNF are special cases of NNF

31 Decision Procedures An algorithmic point of view31 Some notes on Propositional Logic Checking Satisfiability of a Boolean formula  :  Convert  to a CNF: with additional variables, in P time.  Convert  to DNF: Exp time and space  Convert  to NNF: P time

32 Decision Procedures An algorithmic point of view32 The ‘Pure literal rule’  : ( x Ç y ) Æ ( : x Ç z ) Æ ( x Ç y Ç : z ) y is ‘pure’: it only appears in one phase Idea: when trying to satisfy , first assign y = true. Why? If there is a satisfying assignment to , there is a satisfying assignment in which y = true. Generalization: assign all pure literals according to their phase.

33 Decision Procedures An algorithmic point of view33 Pure literals in NNF CNF is a special case of NNF A pure literal is defined in the same way: a literal that only appears in one phase. We can always start satisfiability checking by assigning these pure literals true or false according to their phase. We will rely on a similar principle also when considering other Logics.

34 Decision Procedures An algorithmic point of view34 Monotonicity of NNF Thm: NNF formulas are monotonically satisfied (in CNF this is simply the pure literal rule)  ’’ Satisfied literals  ²  !  ’ ²   : 0 0 1 1 0  ’: 1 1  : ( x 1 Æ : x 2 ) Ç ( x 2 Ç ( x 3 Æ x 1 ))

35 Decision Procedures An algorithmic point of view35 Monotonicity of NNF (example)  : ( : x Æ y ) Ç z  : ( x, y, z ) = (0,1,0)  ²  S ={ : x, y }  ’: ( x, y, z ) = (0,1,1)  ’ ²  S ’={ : x, y, z }

36 Decision Procedures An algorithmic point of view36 Some notes… Why is monotonicity relevant to our decision procedures ? We will use the fact that if we make unsatisfied predicates satisfied, we do not make the formula unsatisfied. We will rely heavily on this fact later: it simplifies decision procedures.


Download ppt "Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background."

Similar presentations


Ads by Google