Decision Procedures for Presburger Arithmetic Presented by Constantinos Bartzis.

Slides:



Advertisements
Similar presentations
Completeness and Expressiveness
Advertisements

5.1 Real Vector Spaces.
Lecture 24 MAS 714 Hartmut Klauck
Intermediate Code Generation
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Propositional and First Order Reasoning. Terminology Propositional variable: boolean variable (p) Literal: propositional variable or its negation p 
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Disjunctive Normal Form CS 680: Formal Methods Jeremy Johnson.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 1: (Part 2): The Foundations: Logic and Proofs.
Copyright © Cengage Learning. All rights reserved. CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION.
Formal Logic Proof Methods Direct Proof / Natural Deduction Conditional Proof (Implication Introduction) Reductio ad Absurdum Resolution Refutation.
1 Introduction to Computability Theory Lecture3: Regular Expressions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture4: Regular Expressions Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
On the Use of Automata Techniques to Decide Satisfiability Mia Minnes May 3, 2005.
Decision Procedures for Presburger Arithmetic Presented by Constantinos Bartzis.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Normal forms for Context-Free Grammars
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
On Solving Presburger and Linear Arithmetic with SAT Ofer Strichman Carnegie Mellon University.
Flavio Lerda 1 LTL Model Checking Flavio Lerda. 2 LTL Model Checking LTL –Subset of CTL* of the form: A f where f is a path formula LTL model checking.
Ofer Strichman, Technion Deciding Combined Theories.
Solving Systems of Equations Algebraically
College Algebra Fifth Edition
Chapter 1 Equations, Inequalities, and Mathematical Models 1.4 Complex Numbers.
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
Systems of Nonlinear Equations in Two Variables
1 Preliminaries Precalculus Review I Precalculus Review II
Zvi Kohavi and Niraj K. Jha 1 Capabilities, Minimization, and Transformation of Sequential Machines.
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
1 Decision Procedures for Linear Arithmetic Presented By Omer Katz 01/04/14 Based on slides by Ofer Strichman.
Quantified Formulas - Decision Procedure Daniel Kroening, Ofer Strichman Presented by Changki Hong 07 NOV 08.
HAWKES LEARNING SYSTEMS Students Matter. Success Counts. Copyright © 2013 by Hawkes Learning Systems/Quant Systems, Inc. All rights reserved. Section 2.3.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
MATH – High School Common Core Vs Tested Kansas Standards Please note: For informational purposes, all Common Core standards are listed, and the tested.
Review I Rosen , 3.1 Know your definitions!
Prerequisites: Fundamental Concepts of Algebra
Key Concept 1. Example 1 Leading Coefficient Equal to 1 A. List all possible rational zeros of f (x) = x 3 – 3x 2 – 2x + 4. Then determine which, if any,
Advanced Topics in Propositional Logic Chapter 17 Language, Proof and Logic.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
Thinking Mathematically Systems of Linear Equations.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Carnegie Mellon Lecture 14 Loop Optimization and Array Analysis I. Motivation II. Data dependence analysis Chapter , 11.6 Dror E. MaydanCS243:
Copyright © Curt Hill Quantifiers. Copyright © Curt Hill Introduction What we have seen is called propositional logic It includes.
MM150 Unit 3 Seminar Agenda Seminar Topics Order of Operations Linear Equations in One Variable Formulas Applications of Linear Equations.
Disjunctive Normal Form CS 270: Math Foundation of CS Jeremy Johnson.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
© Copyright 2008 STI INNSBRUCK Intelligent Systems Propositional Logic.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Copyright © Cengage Learning. All rights reserved. Fundamental Concepts of Algebra 1.1 Real Numbers.
Fundamentals of Informatics Lecture 13 Reduction Bas Luttik.
The decidability of Presburger Arithmetic By Guillermo Guillen 04/13/05 Dr. Smith COT 6421 FIU Spring 2005.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
Logical Agents Chapter 7. Outline Knowledge-based agents Propositional (Boolean) logic Equivalence, validity, satisfiability Inference rules and theorem.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Real Zeros of Polynomial Functions
1 Section 7.1 First-Order Predicate Calculus Predicate calculus studies the internal structure of sentences where subjects are applied to predicates existentially.
Section 6.2 Solving Linear Equations Math in Our World.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Disjunctive Normal Form
Arithmetic Constraints and Automata
Elementary Metamathematics
Chapter Nine: Advanced Topics in Regular Languages
Computer Security: Art and Science, 2nd Edition
Predicates and Quantifiers
AS-Level Maths: Core 2 for Edexcel
Presentation transcript:

Decision Procedures for Presburger Arithmetic Presented by Constantinos Bartzis

Presburger formulas numeral ::= 0 | 1 | 2… var ::= x | y | z … relop ::= term ::= numeral | term + term | -term | numeral  term | var formula ::= term relop term | formula  formula | formula  formula |  formula |  var. formula |  var. formula numeral  term isn't really multiplication; it's short-hand for term + term + … + term

Decision Procedures The aim is to produce an algorithm for determining whether or not a Presburger formula is valid with respect to the standard interpretation in arithmetic. Such an algorithm is a decision procedure if it is guaranteed to correctly return “True” or “False” for all closed formulas. Will discuss algorithms for determining truth of formulas of Presburger arithmetic:  Fourier-Motzkin variable elimination (FMVE)  Omega Test  Cooper's algorithm  Automata based

Quantifier Elimination All the methods we'll look at are quantifier elimination procedures. If a formula with no free variables has no quantifiers, then it is easy to determine its truth value, e.g., 10 > 11  3+4 < 5  Quantifier elimination works by taking input P with n quantifiers and turning it into equivalent formula P’ with m quantifiers, and where m < n. So, eventually P  P’  …  Q and Q has no quantifiers. Q will be trivially true or false, and that's the decision

Normalization Methods require input formulas to be normalized  e.g., collect coefficients, use only < and ≤ Methods eliminate innermost existential quantifiers. Universal quantifiers are normalized with (  x. P(x))   (  x.  P(x)) In FMVE, the sub-formula under the innermost existential quantifier must be a conjunction of relations. This means the inner formula must be converted to disjunctive normal form (DNF): (c 11  c 12  …  c 1n 1 ) ...  (c m1  c m2  …  c mn m )

Normalization (cont.) The formula under  is in DNF. Next, the  must be moved inwards First over disjuncts, using (  x. P  Q)  (  x. P)  (  x. Q) Must then ensure every conjunct under the quantifier mentions the bound variable. Use (  x. P(x)  Q)  (  x. P(x))  Q For example: (  x. 3 < x  x +2y ≤ 6  y < 0)  (  x. 3 < x  x +2y ≤ 6)  y < 0

Fourier-Motzkin theorems The following simple facts are the basis for a very simple quantifier elimination procedure. Over R (or Q), with a,b > 0: (  x. c ≤ ax  bx ≤ d)  bc ≤ ad (  x. c < ax  bx ≤ d)  bc < ad (  x. c ≤ ax  bx < d)  bc < ad (  x. c < ax  bx < d)  bc < ad In all four, the right hand side is implied by the left because of transitivity  e.g., (x < y  y ≤ z)  x < z

Fourier-Motzkin theorems (cont.) For the other direction: (bc < ad)  (  x. c < ax  bx ≤ d) take x to be d/b : c < a( d/b ), and b( d/b ) ≤ d. For (bc < ad)  (  x. c < ax  bx < d) take x to be (bc+ad)/2ab : c < a(bc+ad)/2ab  2bc < bc+ad  bc < ad Similarly for the other bound

Extending to a full procedure So far: a quantifier elimination procedure for formulas where the scope of each quantifier is 1 upper bound and 1 lower bound. The method needs to extend to cover cases with multiple constraints. No lower bound, many upper bounds: (  x: b 1 x < d 1  b 2 x < d 2 …  b n x < d n ) True! (take min(d i /b i ) as witness for x) No upper bound, many lower bounds: obviously analogous.

Combining many constraints Example: (  x. c ≤ ax  b 1 x ≤ d 1  b 2 x ≤ d 2 )  b 1 c ≤ ad 1  b 2 c ≤ ad 2 From left to right, result just depends on transitivity. From right to left, take x to be min(d 1 /b 1, d 2 /b 2 ). In general, with many constraints, combine all possible lower-upper bound pairs. Proof that this is possible is by induction on number of constraints.

Combining many constraints The core elimination formula is With n constraints initially, evenly divided between upper and lower bounds, this formula generates n 2 /4 new constraints.

FMVE example  x. 20+x ≤ 0   y. 3y +x ≤ 10  20 ≤ y - x (re-arrange)   x. 20+x ≤ 0   y. 20+x ≤ y  3y ≤ 10 - x (eliminate y)   x. 20+x ≤ 0  60+3x ≤ 10 - x (re-arrange)   x. 20+x ≤ 0  4x +50 ≤ 0 (normalize universal)   x. 20+x ≤ 0  0 < 4x +50 (re-arrange)   x. -50 < 4x  x ≤ -20 (eliminate x)   (-50 < -80)  T

Complexity As before, when eliminating an existential over n constraints we may introduce n 2 /4 new constraints. With k quantiers to eliminate, we might end with n 2 k /4 k constraints. If dealing with alternating quantifiers, repeated conversions to DNF may really hurt.

Integers

Expressivity over Integers Can do divisibility by specific numerals: 2|e   x. 2x = e for example:  x. 0 < x < 30   (2|x  3|x  5|x) Can do integer division and modulus, as long as divisor is constant. Use one of the following results (similar for division) P(x mod d)   q,r. (x = qd +r )  (0 ≤ r < d  d < r ≤ 0)  P(r ) P(x mod d)   q,r. (x = qd +r )  (0 ≤ r < d  d < r ≤ 0)  P(r ) Any formula involving modulus or integer division by a constant can be translated to one without.

Expressivity over Integers Any procedure for Z trivially extends to be one for N (or any mixture of N and Z) too: add extra constraints stating that variables are  0 Relations < and ≤ can be converted into one another: x ≤ y  x < y +1 x < y  x +1 ≤ y Decision procedures normalize to one of these relations.

Fourier-Motzkin for Integers? Central theorem is false. E.g., (  x  Z. 3 ≤ 2x  2x ≤ 3)  6 ≤ 6 But one direction still works (thanks to transitivity): (  x. c ≤ ax  bx ≤ d)  bc ≤ ad We can compute consequences of existentially quantified formulas /

Fourier-Motzkin for Integers? We know (  x. c ≤ ax  bx ≤ d)  bc ≤ ad Thus an incomplete procedure for universal formulas over Z: Compute negation: (  x. P(x))   (  x.  P(x)) Compute consequences: if (  x.  P(x))   then (  x.  P(x))   and (  x. P(x))  T Repeat for all quantified variables. This is Phase 1 of the Omega Test

Omega Phase 1 - Example  x,y  Z. 0 < x  y < x  y +1 < 2x (normalize)   x,y. 1 ≤ x  y +1 ≤ x  2x ≤ y +1  x,y. 1 ≤ x  y +1 ≤ x  2x ≤ y +1 (eliminate y)   x. 1 ≤ x  2x ≤ x (normalize)   x. 1 ≤ x  x ≤ 0 (eliminate x)  1 ≤ 0  

Omega Phase 1 and the Interactive Theorem Provers The Omega Test's Phase 1 is used by systems like Coq, HOL4, HOL Light and Isabelle to decide arithmetic problems. Against:  it's incomplete  conversion to DNF  quadratic increase in numbers of constraints For:  it's easy to implement  it's easy to adapt the procedures to create proofs that can be checked by other tools

Some Shadows Given  x. (  i c i ≤ a i x)  (  j b j x ≤ d j ) The formula  i,j b j c i ≤ a i d j is known as the real shadow. If all of the a i or all of the b j are equal to 1, then the real shadow is exact. If the shadow is exact, then the formula can be used as an equivalence.

Exact Shadows When a = 1 or b = 1, the core theorem (  x. c ≤ ax  bx ≤ d)  bc ≤ ad is valid because   transitivity still holds   take x = d if b = 1 or x = c if a = 1 Omega Test's inventor, Bill Pugh, claims many problems in his domain (compiler optimization) have exact shadows. Experience suggests the same is true in other domains too, such as interactive theorem-proving. When shadows are exact, can pretend problem is over R rather than Z and life is easy.

Dark Shadows The formula  i,j (a i -1)(b j -1) ≤ a i d j - b j c i is known as the dark shadow. If all a i or all b j are one, then this is the same as the real shadow (or exact). The real shadow provides a test for unsatisfiability. The dark shadow tests for satisfiability, because (a-1)(b-1) ≤ ad - bc  (  x. c ≤ ax  bx ≤ d) This is the Phase 2 of the Omega Test

Omega Test Phases 1 & 2 Problem is  x. P(x) If input is exact for one elements of x, then eliminate them  x. P(x)   x’. P’(x’) Otherwise, calculate real shadow R:  x. P(x)  R so, if R  , then input formula is . Otherwise, calculate dark shadow D: D   x. P(x) so, if D = T, then input formula is T.

Omega Phase 2 - Example (a-1)(b-1) ≤ ad - bc  (  x. c ≤ ax  bx ≤ d)  x,y. 3x +2y ≤ 18  3y ≤ 4x  3x ≤ 2y +1 3y ≤ 4x  3x ≤ 2y +1 3y ≤ 4x  3x ≤ y 6 ≤ 8y y 6 ≤ y - 9y y ≤ -2 17y ≤ 66 y ≤ 3 This gives a suitable value for y, and by back- substitution, finds x = -1, y = -2 as a possible solution.

Splinters Purely existential formulas are often proved false by their real shadow; or proved true by their dark shadow But in “rare” cases, the main theorem is needed. Let m be the maximum of all the d j s. Then dark shadow splinter

Splinters A splinter does represent a smaller problem than the original because the extra equality allows x to be eliminated immediately. When quantifiers alternate, and there is no exact shadow, the main theorem is used as an equivalence, and splinters can't be avoided. Splinters must also be checked if neither real nor dark shadows decide an input formula.

Eliminating Equalities In an expression  x. …  cx = e  … the existential can be eliminated. First, multiply all terms involving x so that they have a common coefficient. Formula becomes  x. …c’x …  c’x = e’  …c’x… This is equivalent to …e’…  c’|e’  …e’…

Eliminating Divisibilities  x. …  c | dx + e  … Note: d < c (otherwise, replace d with d mod c). Introduce temporary new existential variable:  x,y. …  cy = dx + e  … Rearrange:  x,y. …  dx = cy -e  … Use equality elimination to derive  y. …  d | cy -e  … Because d < c, this process must terminate with elimination of divisibility term.

Implementation - Normalization Omega Test's big disadvantage is that it requires the formula under quantifier to be in DNF Consider  x. (x  10  x  11  9 < x ≤ 12)  x = 12 Negate, remove , <:  x. (x ≤ 9  11 ≤ x)  (x ≤ 10  12 ≤ x)  10 ≤ x  x ≤ 12  (x ≤ 11  13 ≤ x) Evaluate 8 (= 2 3 ) DNF terms. Clever preparation of input formulas can make orders of magnitude difference

Implementation - Normalization The propositional tautology (p  (q  q’))  (p  q  p  q’) justifies the following procedure: If P is an atomic formula, then when processing P  Q, assume P is true while processing Q:  If a sub-formula Q 0 of Q is such that P  Q 0, then replace Q 0 in Q by T.  If a sub-formula Q 0 of Q is such that P   Q 0, then replace Q 0 in Q by . Similarly, (  p  (q  q’))  (p  q  p  q’) for disjunctions.

Contextual Rewriting example Over  : 0 ≤ x + y + 4  (0 ≤ x + y + 6  0 ≤ 2x + 3y + 6) is equivalent to 0 ≤ x + y + 4 Whereas 0 ≤ x + y + 4  0 ≤ -x -y -6  0 ≤ 2x + 3y + 6 is equivalent to  Over  : 0 ≤ x + y + 4  0 ≤ x + y + 1  0 ≤ 2x + 3y + 6 is equivalent to 0 ≤ x + y + 4  0 ≤ 2x + 3y + 6

Cooper’s Algorithm

Cooper's Algorithm Cooper's algorithm is a decision procedure for Presburger arithmetic. A non-Fourier-Motzkin alternative It is also a quantifier elimination procedure, which also works from the inside out, eliminating existentials. Its big advantage is that it doesn't need to normalize input formulas to DNF. Description is of simplest possible implementation; many tweaks are possible.

Preprocessing To eliminate the quantifier in  x. P(x): 1. Normalize so that only operators are <, and divisibility (c|e), and negations only occur around divisibility leaves. 2. Compute least common multiple c of all coefficients of x, and multiply all terms by appropriate numbers so that in every term the coefficient of x is c. 3. Now apply (  x. P(cx))  (  x. P(x)  c|x).

Preprocessing Example  x,y  Z. 0 < y  x < y  x +1 < 2y (normalize)   x,y. 0 < y  x < y  2y < x +2 (transform y to 2y everywhere)   x,y. 0 < 2y  2x < 2y  2y < x +2 (give y unit coefficient)   x,y. 0 < y  2x < y  y < x +2  2|y

Two cases How might  x. P(x) be true? Either:  there is a least x making P true; or  there is no least x: however small you go, there will be a smaller x that still makes P true Construct two formulas corresponding to both cases.

Case 1: Infinitely many small solutions Look at the atomic formulas in P, and think about their values when x has been made arbitrarily small:  x < e: if x goes as small as we like, this will be T  e < x: if x goes small, this will be   c | x+e: unchanged This constructs P - , a formula where x only occurs in divisibility terms. Say  is the l.c.m. of the constants involved in divisibility terms. Need just test P -  on 1,…, .

P -  example For  y. 0 < y  2x < y  y < x +2  2|y  0 < y will become  as y gets small  2x < y also becomes  as y gets small  y < x +2 will be T as y gets small  2|y doesn't change (it tests if y is even or not) So in this case, P -  (y)  (     T  2|y)  

Case 2: Least solution The case when there is a least x satisfying P. For there to be a least x satisfying P, it must be the case that one of the terms e < x is T, and that if x was any smaller the formula would become . Let B = {b | b < x is a term of P} Need just consider P(b+j), where b  B and 1 ≤ j ≤ . Final elimination formula is:

Example continued For  y. 0 < y  2x < y  y < x +2  2|y least solutions, if they exist, will be at y = 1, y = 2, y = 2x +1, or y = 2x +2 The divisibility constraint eliminates two of these. Original formula is equivalent to: (2x < 2  0 < x)  (0 < 2x +2  x < 0) Which is unsatisfiable.

Automata based

Symbolic Representation We use finite automata to represent the integer solutions (in binary) of atomic linear constraints ,0, ,1, Example: The constraint x 1  x 2  0 has solutions: (0,0), (1,0), (1,1), (2,0), (2,1), (2,2), (3,0), … The corresponding automaton

FA Construction Based on the basic state machine (BSM) A finite state transducer for computing linear integer expressions / /101/1 1 / / / 1 11/011/0 00/100/1 Example BSM for x + 2y  /001/0 1 0 / 0

Equality With 0 Construct the BSM All transitions writing 1 go to a sink state State labeled 0 is the only accepting state For disequations, state labeled 0 is the only rejecting state Size

Inequality (<0) Construct the BSM States with negative carries are accepting No sink state All other types of inequalities can be derived from this Size

Non-zero Constant Term c Same as before but now -c is the initial state If there is no such state, create one (and possibly some intermediate states) Size Alternatively, we can stack log 2 c BSMs that compare with 0 or 1, depending on the corresponding bit of c

Boolean Connectives For  compute the intersection For  compute the union For  compute the complement

Conjunction example ,1, , ,1,1 Automaton for x-y< , , ,0,1 1 0, Automaton for 2x-y> , , , , , Automaton for x-y 0 -1,-1 0,-1 -2,-1 -1,0 -2,0-2,1

Existential Quantification Project the quantified variables away The resulting FA is non-deterministic Determinization results in exponential blowup of the FA size Rarely occurs in practice For universal quantification use negation

Constraints on All Integers Use 2’s complement arithmetic The BSM remains the same Create two clones for each state of the BSM one accepting and one rejecting For =0, accepting states contain loops that write 0 For <0, accepting states contain loops that write 1 Size