29.04.2014 Views

Presburger Arithmetic and Its Use in Verification

Presburger Arithmetic and Its Use in Verification

Presburger Arithmetic and Its Use in Verification

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.2. DECISION PROCEDURES FOR PRESBURGER ARITHMETIC<br />

In general, every quantifier can be elim<strong>in</strong>ated from a <strong>Presburger</strong> formula <strong>in</strong> PNF:<br />

Q 1 x 1 .Q 2 x 2 ....Q n x n . ∨ ∧<br />

L ij<br />

i j<br />

where Q k ∈{∃, ∀} <strong>and</strong> L ij are literals <strong>in</strong> a form of weak <strong>in</strong>equalities.<br />

Quantifiers are removed <strong>in</strong> a bottom-up manner. The formula ∨ ∧<br />

i j L ij is <strong>in</strong><br />

disjunctive normal form (DNF). If Q n = ∃ we have the follow<strong>in</strong>g equivalence:<br />

∃x n . ∨ ∧<br />

L ij ≡ ∨ ∃x n . ∧ L ij<br />

i j i j<br />

Now we can use elements of the Omega Test on the conjunction of literals. On<br />

the other h<strong>and</strong>, any universal quantifier is removed by us<strong>in</strong>g the dual relation<br />

∀x.φ(x) ≡¬∃x.¬φ(x) <strong>and</strong>convert<strong>in</strong>g¬φ(x) <strong>in</strong>toDNF.<br />

The procedure is done recursively until no quantifier is left.<br />

The Omega Test has some advantages <strong>and</strong> disadvantages compared to Cooper’s<br />

algorithm:<br />

•ElementsoftheOmegaTestcannotdealwithdivisibilityconstra<strong>in</strong>ts.Tobe<br />

able to use the Omega Test for an arbitrary formula, one has to elim<strong>in</strong>ate<br />

divisibility constra<strong>in</strong>ts first, which is quite costly if they occur often <strong>in</strong> the<br />

formula. Divisibility constra<strong>in</strong>t elim<strong>in</strong>ation is beyond the scope of this paper.<br />

•TheOmegaTestrequiresthe<strong>in</strong>nerformulatobe<strong>in</strong>DNFwhichcancausethe<br />

formula to grow very fast compared to NNF of Cooper’s algorithm. Moreover,<br />

once the Gray shadow has to be checked, it generates a disjunction of constra<strong>in</strong>ts<br />

<strong>and</strong> the result<strong>in</strong>g formula is not <strong>in</strong> DNF anymore. Therefore, even <strong>in</strong><br />

ablockofquantifiers,eachquantifierelim<strong>in</strong>ationrequirestotranslatethe<strong>in</strong>put<br />

formula <strong>in</strong>to DNF, which is prohibitively expensive. In contrast, Cooper’s<br />

algorithm h<strong>and</strong>les blocks of quantifiers quite well, <strong>and</strong> a formula is normalized<br />

<strong>in</strong>to NNF once for each block.<br />

•TheOmegaTestdoesnothavetheproblemofhugecoefficientsasCooper’s<br />

algorithm because each shadow only <strong>in</strong>volves <strong>in</strong> pairs of <strong>in</strong>equalities.<br />

Cooper’s algorithm <strong>and</strong> the Omega Test have good characteristics to make them<br />

competitive with each other. Both algorithms have been implemented <strong>in</strong> HOL<br />

theorem-prov<strong>in</strong>g system [22]. The results show that while the Omega Test is a little<br />

faster, there are problems where Cooper’s algorithm outperforms its competitor. It<br />

is also easy to construct formulas more favorable for either one of these procedures.<br />

Thus, us<strong>in</strong>g both the Omega Test <strong>and</strong> Cooper’s algorithm <strong>in</strong> a complete procedure<br />

might be a good idea. One possible solution is execut<strong>in</strong>g two algorithms <strong>in</strong> a parallel<br />

manner [22], <strong>and</strong> another solution is comb<strong>in</strong><strong>in</strong>g elements of the Omega Test <strong>and</strong><br />

Cooper’s procedure <strong>in</strong> a clever way. For example, the Omega Test is employed for<br />

resolv<strong>in</strong>g <strong>in</strong>equalities so coefficients of <strong>in</strong>equalities do not contribute to lcm <strong>and</strong><br />

result<strong>in</strong>g small disjuncts are resolved by Cooper’s algorithm. This comb<strong>in</strong>ation is<br />

<strong>in</strong>corporated <strong>in</strong>to the SMT-solver Z3, <strong>and</strong> Z3 has capability to solve PA formulas<br />

quite efficiently [1].<br />

33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!