Leveraging Linear and Mixed Integer Programming for SMT Tim King 1 Clark Barrett 1 Cesare Tinelli 2 1 New York University 2 The University of Iowa July 18, 2014
Big Ideas ◮ Call a floating point LP/MIP solver (GLPK) from CVC4 ◮ Focus on hard problems ◮ Technique 1: Reseed a Simplex solver ◮ Technique 2: Replay an MIP proof ◮ Great on some families and not so great on others
Table of Contents Background Reseeding Simplex States Replaying MIP Proofs Empirical Results Conclusion
Decision Procedure for QF LRA Quantifier Free Linear Real Arithmetic Is there a satisfying assignment, a : X → R , that makes, x + y ≥ 1 x − y ≥ 0 − ≤ 4 x y 2 evaluate to true?
Decision Procedure for QF LRA Quantifier Free Linear Real Arithmetic Is there a satisfying assignment, a : X → R , that makes, x + y ≥ 1 x − y ≥ 0 − ≤ 4 x y 2 evaluate to true? 1 a x 2 = 1 a y 2
Visually y x + y ≥ 1 x − y ≥ 0 4 x − y ≤ 2 1 a x a = 2 1 (0,0) a y x 2
Preprocessing ◮ Introduce a fresh s i for each � T i , j · x j ◮ Literals are of the form: � � � s i = ∧ T i , j · x j l i ≤ x i ≤ u i x j and s i appears in exactly 1 equality. ◮ Collect into: T � � l ≤ � X = 0 X ≤ � u
Preprocessing ◮ Introduce a fresh s i for each � T i , j · x j ◮ Literals are of the form: � � � s i = ∧ T i , j · x j l i ≤ x i ≤ u i x j and s i appears in exactly 1 equality. ◮ Collect into: T � � l ≤ � X = 0 X ≤ � u
Preprocessing ◮ Introduce a fresh s i for each � T i , j · x j ◮ Literals are of the form: � � � s i = ∧ T i , j · x j l i ≤ x i ≤ u i x j and s i appears in exactly 1 equality. ◮ Collect into: T � � l ≤ � X = 0 X ≤ � u
Basic, Nonbasic, & Tableau ◮ Every row in T is solved for a variable x i � x i = T i , j x j x j ∈N ◮ Not solved for variables are nonbasic ( x j ∈ N ) ◮ Set of solved for variables are basic ( x i ∈ B )
Pivoting the Tableau & Updating the Assignment ◮ Pivoting x i for x j solve x i ’s row for x j and “substitute” out x j from the other rows � � T i , k 1 x i = T i , j x j + T i , k x k = ⇒ x j = x i + x k T i , j T i , j x k ∈N x k ∈N ◮ Invariant: T � a = 0 ◮ Update the assignment of nonbasic x j to α if we also update assignment of the dependent basic variables
Tableau Example x + y ≥ 1 − ≥ x y 0 4 x − y ≤ 2
Tableau Example s 1 = x + y T � X = 0 is equivalent to s 2 = x − y s 3 = 4 x + y s 1 ≥ 1 ∧ s 2 ≥ 0 ∧ s 3 ≤ 2 B = { s 1 , s 2 , s 3 } , N = { x , y }
Result of applying Simplex 1. Starting from a x = a y = 0. 2. Pivot s 1 with y . Update a s 1 to 1 3. Pivot s 2 with x . Update a s 2 to 0 1 a x 2 = 1 1 1 y 2 s 1 − 2 s 2 a y 2 = 1 1 = x 2 s 1 + 2 s 2 a s 1 1 = 3 5 s 3 2 s 1 + 2 s 2 a s 2 0 3 a s 3 2
Simplex for DPLL(T) [DdM06] procedure SimplexDPLL while x i ∈ B s.t. a i > u i or . . . do select some x i = � T i , j · x j s.t. a i > u i if � T i , j · x j is at a minimum under a then return a row conflict else select some x j in � T i , j · x j Pivot x i with x j Update assignment of x i to u i
Simplex for DPLL(T) [DdM06] procedure SimplexDPLL while x i ∈ B s.t. a i > u i or . . . do select some x i = � T i , j · x j s.t. a i > u i if � T i , j · x j is at a minimum under a then return a row conflict else select some x j in � T i , j · x j Pivot x i with x j ⊲ O ( | T | ) Update assignment of x i to u i
Simplex for DPLL(T) : Key Observations ◮ Assuming a i > u i , if ∀ T i , j > 0 . a j = l j ∀ T i , j < 0 . a j = u j and then the bounds on the variables on the row are in conflict { x j ≥ l j | T i , j > 0 } ∪ { x j ≥ u i | T i , j < 0 } ∪ { x i ≤ u i } ◮ Simplex “likes” assignments that are against bounds ◮ Pivoting is expensive ◮ 90% of checks need 0 or 1 pivots [KBD13]
Table of Contents Background Reseeding Simplex States Replaying MIP Proofs Empirical Results Conclusion
General Approach ◮ Call an external off-the-shelf untrusted Simplex LP solver ◮ Reseed the state of the exact precision solver ◮ Only when it is likely to help ◮ Implemented with GLPK
Reseeding the Simplex State If the real relaxation is hard, try the following: 1. Construct an approximate problem from exact X = 0 ,� � � X ≤ � T � X = 0 ,� l ≤ � T � l ≤ � X ≤ � u = ⇒ � u 2. Call untrusted floating point Simplex solver on � T , � l , � u a and � 3. Get back an approximate � B a into a massage ( X → Q ) 4. Convert floating point � 5. Reseed ( a massage , � B ) to get a new a and T 6. Call exact precision Simplex
Massaging Assignments ◮ Suppose we directly attempted to use � a . ◮ Each row must satisfy: � a i = T i , j a j ◮ Many variables have assignments near the bounds ◮ Many slack variables are entailed to be 0 (in practice) ◮ Get in a Simplex “friendly” state
Massaging Assignments Floats to Rationals r ← DioApprox ( � a i , D ) if | r − a i | ≤ ǫ then r ← a i if x ∈ X Z and | r − ⌊ r ⌉| ≤ ǫ then r ← ⌊ r ⌉ if r > u i or | r − u i | ≤ ǫ then r ← u i else if r < l i or | r − l i | ≤ ǫ then r ← l i a massage ← r i
Reseeding Simplex ( a massage , � B ) 1. Update a j to a massage for all x j ∈ N j 2. B ′ ← N ∩ � B 3. If T has a row conflict, return Unsat 4. If all variables satisfy their bounds, return ( Sat ) � � ∃ i k . x k ∈ B ′ ∧ x i �∈ � 5. If ¬ B ∧ T i , k � = 0 , return Unknown � B is not valid basis 6. Otherwise, Pivot x i with x j , and update a i to a massage i 7. If B ′ � = ∅ , goto (3) 8. Otherwise, Unknown (call Simplex)
Reseeding Simplex Related work ◮ More robust with Sum-of-Infeasibilities Simplex [KBD13] ◮ ForcedPivot procedure via Simplex [CBdOM12, Mon09] ◮ Check each conflict used in resolution at the end [FNORC08]
Table of Contents Background Reseeding Simplex States Replaying MIP Proofs Empirical Results Conclusion
From QF LRA to QF LIRA ◮ Partition variables X into X R ∪ X Z ◮ a is integer-compatible if ∀ x i ∈ X Z , then a i ∈ Z
Branches and Cuts ◮ Branch: x i ≤ ⌊ α ⌋ ∨ x i ≥ ⌈ α ⌉ if x i ∈ X Z ◮ Cut: � c i x j ≥ d such that � c j x j ≥ d ◮ { l i } | = RZ � c j x j ≥ d ◮ { l i } �| = R = � c j x j ≥ d (*) ◮ { x j = a j } �|
Branches and Cuts Visually Branch: y ≥ 1 ∨ y ≤ 0 Cut: {· · · } | = RZ x ≥ 1 y y a a (0,0) (0,0) x x
Branch-and-cut Solvers Most SMT solvers and many MIP solvers 1. Treat all of X as if they were X R 2. Solve this R - relaxation 3. If unsat, return R -conflict[s] 4. If R -relaxation is ( Sat a ) and a is Z -compatible, return a 5. [Heuristically] try to derive a cut. If successful, add the cut � c j x j ≥ d , and goto (1) 6. Branch on some x i ∈ X Z with a i �∈ Z
Branch-and-cut Solvers Most SMT solvers and many MIP solvers 1. Treat all of X as if they were X R 2. Solve this R - relaxation 3. If unsat, return R -conflict[s] 4. If R -relaxation is ( Sat a ) and a is Z -compatible, return a 5. [Heuristically] try to derive a cut. If successful, add the cut � c j x j ≥ d , and goto (1) 6. Branch on some x i ∈ X Z with a i �∈ Z Splitting-on-Demand in SMT
Answers for QF LIA and QF LIRA ◮ R -infeasible ◮ R -feasible and Z -feasible ◮ R -feasible and Z -infeasible
Answers for QF LIA and QF LIRA ◮ R -infeasible ◮ R -feasible and Z -feasible Same reseeding trick as R -feasible ◮ R -feasible and Z -infeasible
Answers for QF LIA and QF LIRA ◮ R -infeasible ◮ R -feasible and Z -feasible Same reseeding trick as R -feasible ◮ R -feasible and Z -infeasible
Infeasible Branch-and-Cut Executions ◮ Leaves are conflicts ◮ Internal nodes are branches A x = 0, l < x < u x i ≤ ⌊ α ⌋∨ x i ≥ ⌈ α ⌉ if x i ∈ X Z Cut: ... |= x + y >= 3 ◮ Nodes have cuts Cut: ... |= x + 2z <= 7 � { l i } | = RZ c j x j ≥ d x >=4 x <= 3 Conflict: C or ~(x>=4) Conflict: C or ~(x<=3)
Replaying the MIP Execution ◮ Minimizes changes to the MIP solver’s search
Replaying the MIP Execution ◮ Minimizes changes to the MIP solver’s search ◮ Instrument GLPK to print hints about: branch, unsat leaves, and derivations of cutting planes
Replaying the MIP Execution ◮ Minimizes changes to the MIP solver’s search ◮ Instrument GLPK to print hints about: branch, unsat leaves, and derivations of cutting planes ◮ Repeat “the big steps” in the SMT solver
Replaying the MIP Execution ◮ Minimizes changes to the MIP solver’s search ◮ Instrument GLPK to print hints about: branch, unsat leaves, and derivations of cutting planes ◮ Repeat “the big steps” in the SMT solver ◮ Reconstruct the Resolution+Cutting Planes proof ◮ Resolution removes branching literals
Recommend
More recommend