Decision Procedures An Algorithmic Point of View Part V Linear Arithmetic Linear Arithmetic D. Kroening O. Strichman ETH/Technion Version 1.0, 2007 Fourier-Motzkin Variable Elimination Fourier-Motzkin Variable Elimination Outline 1 Goal: decide satisfiability of conjunction of linear constraints over reals ^ X ai,j xj ≤ bi History 1≤i≤m 1≤j≤n 2 Linear Arithmetic over the Reals 3 Partitioning and Bounds Discovered in 1826 by Fourier, re-discovered by Motzkin in 1936 4 Complexity Basic idea of variable elimination: Earliest method for solving linear inequalities Pick one variable and eliminate it Continue until all variables but one are eliminated D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.0, 2007 3 / 11 Linear Arithmetic over the Reals D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.0, 2007 4 / 11 Removing unbounded variables Iteratively remove variables that are not bounded in both ways (and all the constraints that use them) Input: A system of conjoined linear inequalities Ax ≤ b The new problem has a solution iff the old problem has one! m constraints a11 a12 · · · . a22 . . ··· a21 .. .. . . am1 a22 · · · · · · n variables D. Kroening, O. Strichman (ETH/Technion) Decision Procedures a1n .. . .. . amn x1 .. . .. . xn ≤ b1 .. . .. . bn Version 1.0, 2007 5 / 11 8x x y z 20 ≥ ≥ ≥ ≥ ≥ 7y 3 z 10 z D. Kroening, O. Strichman (ETH/Technion) −→ y ≥ z z ≥ 10 20 ≥ z Decision Procedures −→ z ≥ 10 20 ≥ z Version 1.0, 2007 6 / 11 Partitioning the Constraints Example for Upper and Lower Bounds 1. When eliminating xn , partition the constraints according to the coefficient ain : ai,n > 0: upper bound βi ai,n < 0: lower bound βi n X Category? (1) (2) (3) (4) ai,j · xj ≤ bi j=1 ⇒ ⇒ ai,n · xn ≤ bi − xn ≤ bi − ai,n n−1 X ai,j · xj j=1 n−1 X ai,j j=1 D. Kroening, O. Strichman (ETH/Technion) x1 − x2 ≤ 0 x1 − x3 ≤ 0 −x1 + x2 + 2x3 ≤ 0 −x3 ≤ −1 ai,n · xj Upper bound Upper bound Lower bound Assume we eliminate x1 . =: βi Decision Procedures Version 1.0, 2007 7 / 11 Adding the constraints D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.0, 2007 8 / 11 Fourier-Motzkin: Example Category? 2. For each pair of a lower bound al,n < 0 and upper bound au,n > 0, we have βl ≤ xn ≤ βu (1) (2) (3) (4) x1 − x2 ≤ 0 x1 − x3 ≤ 0 −x1 + x2 + 2x3 ≤ 0 −x3 ≤ −1 (5) (6) 2x3 ≤ 0 x2 + x3 ≤ 0 (from 1,3) (from 2,3) (7) 0 ≤ −1 (from 4,5) Upper bound Upper bound Lower bound Lower bound we eliminate x1 3. For each such pair, add the constraint Upper bound Upper bound we eliminate x3 βl ≤ βu → Contradiction (the system is UNSAT) D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.0, 2007 9 / 11 Complexity Worst-case complexity: m → m2 → (m2 )2 → . . . → m2 n Heavy! So why is it so popular in verification? The bottleneck: case-splitting D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.0, 2007 11 / 11 D. Kroening, O. Strichman (ETH/Technion) Decision Procedures Version 1.0, 2007 10 / 11