motivation
play

Motivation SMT Theories of Interest History of SMT Eager approach - PowerPoint PPT Presentation

SMT Theory and DPLL( T ) Albert Oliveras Technical University of Catalonia (BarcelonaTech) Third International SAT/SMT Solver Summer School 2013 Aalto University, Finland July 4th, 2013 SMT Theory and DPLL( T ) p. 1 Overview of the talk


  1. Lazy approach Methodology: Example: consider EUF and the CNF g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 SAT solver returns model [ 1, 2, 4 ] SMT Theory and DPLL( T ) – p. 18

  2. Lazy approach Methodology: Example: consider EUF and the CNF g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 SAT solver returns model [ 1, 2, 4 ] Theory solver says T -inconsistent SMT Theory and DPLL( T ) – p. 18

  3. Lazy approach Methodology: Example: consider EUF and the CNF g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 SAT solver returns model [ 1, 2, 4 ] Theory solver says T -inconsistent Send { 1, 2 ∨ 3, 4, 1 ∨ 2 ∨ 4 } to SAT solver SMT Theory and DPLL( T ) – p. 18

  4. Lazy approach Methodology: Example: consider EUF and the CNF g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 SAT solver returns model [ 1, 2, 4 ] Theory solver says T -inconsistent Send { 1, 2 ∨ 3, 4, 1 ∨ 2 ∨ 4 } to SAT solver SAT solver returns model [ 1, 2, 3, 4 ] SMT Theory and DPLL( T ) – p. 18

  5. Lazy approach Methodology: Example: consider EUF and the CNF g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 SAT solver returns model [ 1, 2, 4 ] Theory solver says T -inconsistent Send { 1, 2 ∨ 3, 4, 1 ∨ 2 ∨ 4 } to SAT solver SAT solver returns model [ 1, 2, 3, 4 ] Theory solver says T -inconsistent SMT Theory and DPLL( T ) – p. 18

  6. Lazy approach Methodology: Example: consider EUF and the CNF g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 SAT solver returns model [ 1, 2, 4 ] Theory solver says T -inconsistent Send { 1, 2 ∨ 3, 4, 1 ∨ 2 ∨ 4 } to SAT solver SAT solver returns model [ 1, 2, 3, 4 ] Theory solver says T -inconsistent SAT solver detects { 1, 2 ∨ 3, 4, 1 ∨ 2 ∨ 4, 1 ∨ 2 ∨ 3 ∨ 4 } UNSATISFIABLE SMT Theory and DPLL( T ) – p. 18

  7. Lazy approach (2) Why “lazy”? Theory information used lazily when checking T -consistency of propositional models Characteristics: + Modular and flexible - Theory information does not guide the search Tools: Alt-Ergo, ArgoLib, Ario, Barcelogic, CVC, DTP, ICS, MathSAT, OpenSMT, Sateen, SVC, Simplify, tSAT, veriT, Yices, Z3, etc... SMT Theory and DPLL( T ) – p. 19

  8. Overview of the talk Motivation SMT Theories of Interest Eager approach Lazy approach Optimizations Theory propagation Conflict analysis in DPLL( T ) Combining Theory Solvers Eager vs Lazy Theory solver example SMT Theory and DPLL( T ) – p. 19

  9. Lazy approach - Optimizations Several optimizations for enhancing efficiency: Check T -consistency only of full propositional models SMT Theory and DPLL( T ) – p. 20

  10. Lazy approach - Optimizations Several optimizations for enhancing efficiency: Check T -consistency only of full propositional models Check T -consistency of partial assignment while being built SMT Theory and DPLL( T ) – p. 20

  11. Lazy approach - Optimizations Several optimizations for enhancing efficiency: Check T -consistency only of full propositional models Check T -consistency of partial assignment while being built Given a T -inconsistent assignment M , add ¬ M as a clause SMT Theory and DPLL( T ) – p. 20

  12. Lazy approach - Optimizations Several optimizations for enhancing efficiency: Check T -consistency only of full propositional models Check T -consistency of partial assignment while being built Given a T -inconsistent assignment M , add ¬ M as a clause Given a T -inconsistent assignment M , identify a T -inconsistent subset M 0 ⊆ M and add ¬ M 0 as a clause SMT Theory and DPLL( T ) – p. 20

  13. Lazy approach - Optimizations Several optimizations for enhancing efficiency: Check T -consistency only of full propositional models Check T -consistency of partial assignment while being built Given a T -inconsistent assignment M , add ¬ M as a clause Given a T -inconsistent assignment M , identify a T -inconsistent subset M 0 ⊆ M and add ¬ M 0 as a clause Upon a T -inconsistency, add clause and restart SMT Theory and DPLL( T ) – p. 20

  14. Lazy approach - Optimizations Several optimizations for enhancing efficiency: Check T -consistency only of full propositional models Check T -consistency of partial assignment while being built Given a T -inconsistent assignment M , add ¬ M as a clause Given a T -inconsistent assignment M , identify a T -inconsistent subset M 0 ⊆ M and add ¬ M 0 as a clause Upon a T -inconsistency, add clause and restart Upon a T -inconsistency, bactrack to some point where the assignment was still T -consistent SMT Theory and DPLL( T ) – p. 20

  15. Lazy approach - Important points Important and benefitial aspects of the lazy approach: (even with the optimizations) Everyone does what he/she is good at: SAT solver takes care of Boolean information Theory solver takes care of theory information Theory solver only receives conjunctions of literals Modular approach: SAT solver and T -solver communicate via a simple API SMT for a new theory only requires new T -solver SAT solver can be embedded in a lazy SMT system with very few new lines of code SMT Theory and DPLL( T ) – p. 21

  16. Overview of the talk Motivation SMT Theories of Interest Eager approach Lazy approach Optimizations Theory propagation Conflict analysis in DPLL( T ) Combining Theory Solvers Eager vs Lazy Theory solver example SMT Theory and DPLL( T ) – p. 21

  17. Lazy approach - T -propagation As pointed out the lazy approach has one drawback: Theory information does not guide the search (too lazy) How can we improve that? T-Propagate : � = T l M | if M || F ⇒ M l || F l or ¬ l occurs in F and not in M Search guided by T -Solver by finding T-consequences, instead of only validating it as in basic lazy approach. Naive implementation:: Add ¬ l . If T -inconsistent then infer l [ACG00] But for efficient Theory Propagation we need: - T -Solvers specialized and fast in it. -fully exploited in conflict analysis This approach has been named DPLL( T ) [NOT06] SMT Theory and DPLL( T ) – p. 22

  18. DPLL( T ) In a nutshell: DPLL( T ) = DPLL( X ) + T -Solver DPLL( X ): Very similar to a SAT solver, enumerates Boolean models Not allowed: pure literal, blocked literal detection, ... Required: incremental addition of clauses Desirable: partial model detection T -Solver: Checks consistency of conjunctions of literals Computes theory propagations Produces explanations of inconsistency/ T -propagation Should be incremental and backtrackable SMT Theory and DPLL( T ) – p. 23

  19. DPLL( T ) - Example Consider again EUF and the formula: g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 / 0 || ( UnitPropagate ) 1, 2 ∨ 3, 4 ⇒ SMT Theory and DPLL( T ) – p. 24

  20. DPLL( T ) - Example Consider again EUF and the formula: g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 / 0 || ( UnitPropagate ) 1, 2 ∨ 3, 4 ⇒ ( UnitPropagate ) 1 || 1, 2 ∨ 3, 4 ⇒ SMT Theory and DPLL( T ) – p. 24

  21. DPLL( T ) - Example Consider again EUF and the formula: g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 / 0 || ( UnitPropagate ) 1, 2 ∨ 3, 4 ⇒ ( UnitPropagate ) 1 || 1, 2 ∨ 3, 4 ⇒ ( T-Propagate ) 1 4 || 1, 2 ∨ 3, 4 ⇒ SMT Theory and DPLL( T ) – p. 24

  22. DPLL( T ) - Example Consider again EUF and the formula: g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 / 0 || ( UnitPropagate ) 1, 2 ∨ 3, 4 ⇒ ( UnitPropagate ) 1 || 1, 2 ∨ 3, 4 ⇒ ( T-Propagate ) 1 4 || 1, 2 ∨ 3, 4 ⇒ ( T-Propagate ) 1 4 2 || 1, 2 ∨ 3, 4 ⇒ SMT Theory and DPLL( T ) – p. 24

  23. DPLL( T ) - Example Consider again EUF and the formula: g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 / 0 || ( UnitPropagate ) 1, 2 ∨ 3, 4 ⇒ ( UnitPropagate ) 1 || 1, 2 ∨ 3, 4 ⇒ ( T-Propagate ) 1 4 || 1, 2 ∨ 3, 4 ⇒ ( T-Propagate ) 1 4 2 || 1, 2 ∨ 3, 4 ⇒ ( Fail ) 1 4 2 3 || 1, 2 ∨ 3, 4 ⇒ SMT Theory and DPLL( T ) – p. 24

  24. DPLL( T ) - Example Consider again EUF and the formula: g ( a )= c ∧ ( f ( g ( a )) � = f ( c ) ∨ g ( a )= d ) c � = d ∧ ���� � �� � � �� � � �� � 1 3 4 2 / 0 || ( UnitPropagate ) 1, 2 ∨ 3, 4 ⇒ ( UnitPropagate ) 1 || 1, 2 ∨ 3, 4 ⇒ ( T-Propagate ) 1 4 || 1, 2 ∨ 3, 4 ⇒ ( T-Propagate ) 1 4 2 || 1, 2 ∨ 3, 4 ⇒ ( Fail ) 1 4 2 3 || 1, 2 ∨ 3, 4 ⇒ UNSAT SMT Theory and DPLL( T ) – p. 24

  25. DPLL( T ) - Overall algorithm High-levew view gives the same algorithm as a CDCL SAT solver: while(true){ while (propagate_gives_conflict()){ if (decision_level==0) return UNSAT; else analyze_conflict(); } restart_if_applicable(); remove_lemmas_if_applicable(); if (!decide()) returns SAT; // All vars assigned } Differences are in: propagate_gives_conflict analyze_conflict SMT Theory and DPLL( T ) – p. 25

  26. DPLL( T ) - Propagation propagate_gives_conflict( ) returns Bool do { // unit propagate if ( unit_prop_gives_conflict() ) then return true // check T-consistency of the model if ( solver.is_model_inconsistent() ) then return true // theory propagate solver.theory_propagate() } while (someTheoryPropagation) return false SMT Theory and DPLL( T ) – p. 26

  27. DPLL( T ) - Propagation (2) Three operations: Unit propagation (SAT solver) Consistency checks ( T -solver) Theory propagation ( T -solver) Cheap operations are computed first If theory is expensive, calls to T -solver are sometimes skipped For completeness, only necessary to call T -solver at the leaves (i.e. when we have a full propositional model) Theory propagation is not necessary for completeness SMT Theory and DPLL( T ) – p. 27

  28. Case Reasoning in Theory Solvers For certain theories, consistency checking requires case reasoning. Example: consider the theory of arrays and the set of literals read ( write ( A , i , x ) , j ) � = x read ( write ( A , i , x ) , j ) � = read ( A , j ) SMT Theory and DPLL( T ) – p. 28

  29. Case Reasoning in Theory Solvers For certain theories, consistency checking requires case reasoning. Example: consider the theory of arrays and the set of literals read ( write ( A , i , x ) , j ) � = x read ( write ( A , i , x ) , j ) � = read ( A , j ) Two cases: i = j . LHS rewrites into x � = x !!! SMT Theory and DPLL( T ) – p. 28

  30. Case Reasoning in Theory Solvers For certain theories, consistency checking requires case reasoning. Example: consider the theory of arrays and the set of literals read ( write ( A , i , x ) , j ) � = x read ( write ( A , i , x ) , j ) � = read ( A , j ) Two cases: i = j . LHS rewrites into x � = x !!! i � = j . RHS rewrites into read ( A , j ) � = read ( A , j ) !!! SMT Theory and DPLL( T ) – p. 28

  31. Case Reasoning in Theory Solvers For certain theories, consistency checking requires case reasoning. Example: consider the theory of arrays and the set of literals read ( write ( A , i , x ) , j ) � = x read ( write ( A , i , x ) , j ) � = read ( A , j ) Two cases: i = j . LHS rewrites into x � = x !!! i � = j . RHS rewrites into read ( A , j ) � = read ( A , j ) !!! CONCLUSION : T -inconsistent SMT Theory and DPLL( T ) – p. 28

  32. Case Reasoning in Theory Solvers (2) A complete T-solver might need to reason by cases via internal case splitting and backtracking mechanisms. An alternative is to lift case splitting and backtracking from the T -Solver to the SAT engine. Basic idea: encode case splits as sets of clauses and send them as needed to the SAT engine for it to split on them. Possible benefits: All case-splitting is coordinated by the SAT engine Only have to implement case-splitting infrastructure in one place Can learn a wider class of lemmas (more details later) SMT Theory and DPLL( T ) – p. 29

  33. Case Reasoning in Theory Solvers (3) Basic idea: encode case splits as a set of clauses and send them as needed to the SAT engine Example: s = read ( write ( A , i , t ) , j ) Assume model contains literal � �� � s ′ DPLL( X ) asks: “is it T -satisfiable”? T -solver says: “I do not know yet , but it will be helpful that you consider these theory lemmas:” s = s ′ ∧ i = j − → s = t s = s ′ ∧ i � = j − → s = read ( A , j ) We need certain completeness conditions (e.g. once all lits from a certain subset L has been decided, the T -solver should answer YES/NO) SMT Theory and DPLL( T ) – p. 30

  34. Overview of the talk Motivation SMT Theories of Interest Eager approach Lazy approach Optimizations Theory propagation Conflict analysis in DPLL( T ) Combining Theory Solvers Eager vs Lazy Theory solver example SMT Theory and DPLL( T ) – p. 30

  35. DPLL( T ) - Conflict Analysis Remember conflict analysis in SAT solvers: C := conflicting clause while C contains more than one lit of last DL l :=last literal assigned in C C :=Resolution( C ,reason( l )) end while // let C = C’ v l where l is UIP backjump(maxDL(C’)) add l to the model with reason C learn(C) SMT Theory and DPLL( T ) – p. 31

  36. DPLL( T ) - Conflict Analysis (2) Conflict analysis in DPLL( T ): if boolean conflict then C := conflicting clause else C := ¬ ( solver.explain_inconsistency() ) while C contains more than one lit of last DL l :=last literal assigned in C C :=Resolution( C ,reason( l )) end while // let C = C’ v l where l is UIP backjump(maxDL(C’)) add l to the model with reason C learn(C) SMT Theory and DPLL( T ) – p. 32

  37. DPLL( T ) - Conflict Analysis (3) What does explain_inconsistency return? A (small) conjuntion of literals l 1 ∧ ... ∧ l n such that: They were in the model when T -inconsistency was found It is T -inconsistent What is now reason ( l ) ? If l was unit propagated, reason is the clause that propagated it If l was T -propagated? T -solver has to provide an explanation for l , i.e. a (small) set of literals l 1 , ... , l n such that: They were in the model when l was T -propagated l 1 ∧ ... ∧ l n | = T l Then reason ( l ) is ¬ l 1 ∨ ... ∨¬ l n ∨ l SMT Theory and DPLL( T ) – p. 33

  38. DPLL( T ) - Conflict Analysis (4) Let M be of the form ... , c = b , ... and let F contain h ( a )= h ( c ) ∨ p a = b ∨ ¬ p ∨ a = d a � = d ∨ a = b Take the following sequence: 1. Decide h ( a ) � = h ( c ) 2. UnitPropagate p (due to clause h ( a )= h ( c ) ∨ p ) 3. T-Propagate a � = b (since h ( a ) � = h ( c ) and c = b ) 4. UnitPropagate a = d (due to clause a = b ∨ ¬ p ∨ a = d ) 5. Conflicting clause a � = d ∨ a = b Explain( a � = b ) is { h ( a ) � = h ( c ) , c = b } a = b ∨¬ p ∨ a = d a � = d ∨ a = b ❄ h ( a )= h ( c ) ∨ c � = b ∨ a � = b a = b ∨¬ p h ( a )= h ( c ) ∨ p h ( a )= h ( c ) ∨ c � = b ∨¬ p h ( a )= h ( c ) ∨ c � = b SMT Theory and DPLL( T ) – p. 34

  39. Overview of the talk Motivation SMT Theories of Interest Eager approach Lazy approach Optimizations Theory propagation Conflict analysis in DPLL( T ) Combining Theory Solvers Eager vs Lazy Theory solver example SMT Theory and DPLL( T ) – p. 34

  40. Need for combination In software verification, formulas like the following one arise: a = b + 2 ∧ A = write ( B , a + 1,4 ) ∧ ( read ( A , b + 3 )= 2 ∨ f ( a − 1 ) � = f ( b + 1 )) Here reasoning is needed over The theory of linear arithmetic ( T LA ) The theory of arrays ( T A ) The theory of uninterpreted functions ( T EUF ) Remember that T -solvers only deal with conjunctions of lits. Given T -solvers for the three individual theories, can we combine them to obtain one for ( T LA ∪ T A ∪ T EUF )? Under certain conditions the Nelson-Oppen combination method gives a positive answer SMT Theory and DPLL( T ) – p. 35

  41. Motivating example - Convex case Consider the following set of literals: f ( f ( x ) − f ( y )) = a f ( 0 ) = a + 2 = x y There are two theories involved: T LA ( R ) and T EUF FIRST STEP: purify each literal so that it belongs to a single theory f ( f ( x ) − f ( y )) = a = ⇒ f ( e 1 ) = a = ⇒ f ( e 1 ) = a e 1 = f ( x ) − f ( y ) e 1 = e 2 − e 3 e 2 = f ( x ) e 3 = f ( y ) SMT Theory and DPLL( T ) – p. 36

  42. Motivating example - Convex case Consider the following set of literals: f ( f ( x ) − f ( y )) = a f ( 0 ) = a + 2 = x y There are two theories involved: T LA ( R ) and T EUF FIRST STEP: purify each literal so that it belongs to a single theory f ( 0 ) = a + 2 = ⇒ f ( e 4 ) = a + 2 = ⇒ f ( e 4 ) = e 5 e 4 = 0 e 4 = 0 e 5 = a + 2 SMT Theory and DPLL( T ) – p. 36

  43. Motivating example - Convex case (2) SECOND STEP: check satisfiability and exchange entailed equalities EUF Arithmetic f ( e 1 ) = e 2 − e 3 = a e 1 f ( x ) = = 0 e 2 e 4 f ( y ) = = a + 2 e 3 e 5 f ( e 4 ) = e 5 = x y The two solvers only share constants: e 1 , e 2 , e 3 , e 4 , e 5 , a To merge the two models into a single one, the solvers have to agree on equalities between shared constants (interface equalities) This can be done by exchanging entailed interface equalities SMT Theory and DPLL( T ) – p. 37

  44. Motivating example - Convex case (2) SECOND STEP: check satisfiability and exchange entailed equalities EUF Arithmetic f ( e 1 ) = e 2 − e 3 = a e 1 f ( x ) = = 0 e 2 e 4 f ( y ) = = a + 2 e 3 e 5 f ( e 4 ) = = e 5 e 2 e 3 = x y The two solvers only share constants: e 1 , e 2 , e 3 , e 4 , e 5 , a EUF -Solver says SAT Ari -Solver says SAT = e 2 = e 3 EUF | SMT Theory and DPLL( T ) – p. 38

  45. Motivating example - Convex case (2) SECOND STEP: check satisfiability and exchange entailed equalities EUF Arithmetic f ( e 1 ) = e 2 − e 3 = a e 1 f ( x ) = = 0 e 2 e 4 f ( y ) = = a + 2 e 3 e 5 f ( e 4 ) = = e 5 e 2 e 3 = x y = e 1 e 4 The two solvers only share constants: e 1 , e 2 , e 3 , e 4 , e 5 , a EUF -Solver says SAT Ari -Solver says SAT = e 1 = e 4 Ari | SMT Theory and DPLL( T ) – p. 39

  46. Motivating example - Convex case (2) SECOND STEP: check satisfiability and exchange entailed equalities EUF Arithmetic f ( e 1 ) = e 2 − e 3 = a e 1 f ( x ) = = 0 e 2 e 4 f ( y ) = = a + 2 e 3 e 5 f ( e 4 ) = = e 5 e 2 e 3 = = x y a e 5 = e 1 e 4 The two solvers only share constants: e 1 , e 2 , e 3 , e 4 , e 5 , a EUF -Solver says SAT Ari -Solver says SAT = a = e 5 EUF | SMT Theory and DPLL( T ) – p. 40

  47. Motivating example - Convex case (2) SECOND STEP: check satisfiability and exchange entailed equalities EUF Arithmetic f ( e 1 ) = e 2 − e 3 = a e 1 f ( x ) = = 0 e 2 e 4 f ( y ) = = a + 2 e 3 e 5 f ( e 4 ) = = e 5 e 2 e 3 = = x y a e 5 = e 1 e 4 The two solvers only share constants: e 1 , e 2 , e 3 , e 4 , e 5 , a EUF -Solver says SAT Ari -Solver says UNSAT Hence the original set of lits was UNSAT SMT Theory and DPLL( T ) – p. 41

  48. Nelson-Oppen – The convex case A theory T is stably-infinite iff every T -satisfiable quantifier-free formula has an infinite model A theory T is convex iff = T a 1 = b 1 ∨ ... ∨ a n = b n = = a i = b i for some i S | ⇒ S | Deterministic Nelson-Oppen: [NO79, TH96, MZ02] Given two signature-disjoint, stably-infinite and convex theories T 1 and T 2 Given a set of literals S over the signature of T 1 ∪ T 2 The ( T 1 ∪ T 2 )-satisfiability of S can be checked with the following algorithm: SMT Theory and DPLL( T ) – p. 42

  49. Nelson-Oppen – The convex case (2) Deterministic Nelson-Oppen 1. Purify S and split it into S 1 ∪ S 2 . Let E the set of interface equalities between S 1 and S 2 2. If S 1 is T 1 -unsatisfiable then UNSAT 3. If S 2 is T 2 -unsatisfiable then UNSAT = T 1 x = y with x = y ∈ E \ S 2 then 4. If S 1 | S 2 : = S 2 ∪{ x = y } and goto 3 = T 2 x = y with x = y ∈ E \ S 1 then 5. If S 2 | S 1 : = S 1 ∪{ x = y } and goto 2 6. Report SAT SMT Theory and DPLL( T ) – p. 43

  50. Motivating example – Non-convex case Consider the following UNSATISFIABLE set of literals: 1 ≤ ≤ 2 x f ( 1 ) = a f ( x ) = b = b + 2 a f ( 2 ) = f ( 1 ) + 3 There are two theories involved: T LA ( Z ) and T EUF FIRST STEP: purify each literal so that it belongs to a single theory f ( 1 ) = = f ( e 1 ) = ⇒ a a e 1 = 1 SMT Theory and DPLL( T ) – p. 44

  51. Motivating example – Non-convex case Consider the following UNSATISFIABLE set of literals: 1 ≤ ≤ 2 x f ( 1 ) = a f ( x ) = b = b + 2 a f ( 2 ) = f ( 1 ) + 3 There are two theories involved: T LA ( Z ) and T EUF FIRST STEP: purify each literal so that it belongs to a single theory f ( 2 ) = f ( 1 ) + 3 = e 2 = ⇒ 2 f ( e 2 ) = e 3 f ( e 1 ) = e 4 e 3 = e 4 + 3 SMT Theory and DPLL( T ) – p. 44

  52. Motivating example – Non-convex case(2) SECOND STEP: check satisfiability and exchange entailed equalities Arithmetic EUF ≤ f ( e 1 ) = 1 x a f ( x ) = ≤ 2 x b = f ( e 2 ) = e 1 1 e 3 = b + 2 f ( e 1 ) = a e 4 = e 2 2 = e 4 + 3 e 3 = a e 4 The two solvers only share constants: x , e 1 , a , b , e 2 , e 3 , e 4 Ari -Solver says SAT EUF -Solver says SAT = a = e 4 EUF | SMT Theory and DPLL( T ) – p. 45

  53. Motivating example – Non-convex case(2) SECOND STEP: check satisfiability and exchange entailed equalities Arithmetic EUF ≤ f ( e 1 ) = 1 x a f ( x ) = ≤ 2 x b = f ( e 2 ) = e 1 1 e 3 = b + 2 f ( e 1 ) = a e 4 = e 2 2 = e 4 + 3 e 3 = a e 4 The two solvers only share constants: x , e 1 , a , b , e 2 , e 3 , e 4 Ari -Solver says SAT EUF -Solver says SAT No theory entails any other interface equality, but... SMT Theory and DPLL( T ) – p. 46

  54. Motivating example – Non-convex case(2) SECOND STEP: check satisfiability and exchange entailed equalities Arithmetic EUF ≤ f ( e 1 ) = 1 x a f ( x ) = ≤ 2 x b = f ( e 2 ) = e 1 1 e 3 = b + 2 f ( e 1 ) = a e 4 = e 2 2 = e 4 + 3 e 3 = a e 4 The two solvers only share constants: x , e 1 , a , b , e 2 , e 3 , e 4 Ari -Solver says SAT EUF -Solver says SAT = T x = e 1 ∨ x = e 2 . Let’s consider both cases. Ari | SMT Theory and DPLL( T ) – p. 47

  55. Motivating example – Non-convex case(2) SECOND STEP: check satisfiability and exchange entailed equalities Arithmetic EUF ≤ f ( e 1 ) = 1 x a f ( x ) = ≤ 2 x b = f ( e 2 ) = e 1 1 e 3 = b + 2 f ( e 1 ) = a e 4 = = e 2 2 x e 1 = e 4 + 3 e 3 = a e 4 = x e 1 Ari -Solver says SAT EUF -Solver says SAT = T a = b , that when sent to Ari makes it UNSAT EUF | SMT Theory and DPLL( T ) – p. 48

  56. Motivating example – Non-convex case(2) SECOND STEP: check satisfiability and exchange entailed equalities Arithmetic EUF ≤ f ( e 1 ) = 1 x a f ( x ) = ≤ 2 x b = f ( e 2 ) = e 1 1 e 3 = b + 2 f ( e 1 ) = a e 4 = e 2 2 = e 4 + 3 e 3 = a e 4 Let’s try now with x = e 2 SMT Theory and DPLL( T ) – p. 49

  57. Motivating example – Non-convex case(2) SECOND STEP: check satisfiability and exchange entailed equalities Arithmetic EUF ≤ f ( e 1 ) = 1 x a f ( x ) = ≤ 2 x b = f ( e 2 ) = e 1 1 e 3 = b + 2 f ( e 1 ) = a e 4 = = e 2 2 x e 2 = e 4 + 3 e 3 = a e 4 = x e 2 Ari -Solver says SAT EUF -Solver says SAT = T b = e 3 , that when sent to Ari makes it UNSAT EUF | SMT Theory and DPLL( T ) – p. 50

  58. Motivating example – Non-convex case(2) SECOND STEP: check satisfiability and exchange entailed equalities Arithmetic EUF ≤ f ( e 1 ) = 1 x a f ( x ) = ≤ 2 x b = f ( e 2 ) = e 1 1 e 3 = b + 2 f ( e 1 ) = a e 4 = = e 2 2 x e 2 = e 4 + 3 e 3 = a e 4 = x e 2 Since both x = e 1 and x = e 2 are UNSAT , the set of literals is UNSAT SMT Theory and DPLL( T ) – p. 51

  59. Nelson-Oppen - The non-convex case In the previous example Deterministic NO does not work This was because T LA ( Z ) is not convex: = T LA ( Z ) x = e 1 ∨ x = e 2 , but S LA ( Z ) | = T LA ( Z ) x = e 1 and S LA ( Z ) �| S LA ( Z ) �| = T LA ( Z ) x = e 2 However, there is a version of NO for non-convex theories Given a set constants C , an arrangement A over C is: A set of equalities and disequalites between constants in C For each x , y ∈ C either x = y ∈ A or x � = y ∈ A SMT Theory and DPLL( T ) – p. 52

  60. Nelson-Oppen – The non-convex case (2) Non-deterministic Nelson-Oppen: [NO79, TH96, MZ02] Given two signature-disjoint, stably-infinite theories T 1 and T 2 Given a set of literals S over the signature of T 1 ∪ T 2 The ( T 1 ∪ T 2 ) -satisfiability of S can be checked via: 1. Purify S and split it into S 1 ∪ S 2 Let C be the set of shared constants 2. For every arrangement A over C do If ( S 1 ∪ A ) is T 1 -satisfiable and ( S 2 ∪ A ) is T 2 -satisfiable report SAT 3. Report UNSAT This is another example of Case Reasoning inside a T -Solver SMT Theory and DPLL( T ) – p. 53

  61. Overview of the talk Motivation SMT Theories of Interest Eager approach Lazy approach Optimizations Theory propagation Conflict analysis in DPLL( T ) Combining Theory Solvers Eager vs Lazy Theory solver example SMT Theory and DPLL( T ) – p. 53

  62. Eager vs Lazy Approach REMEMBER.... Important and benefitial aspects of the lazy approach: (even with the optimizations) Everyone does what he/she is good at: SAT solver takes care of Boolean information Theory solver takes care of theory information Theory solver only receives conjunctions of literals Modular approach: SAT solver and T -solver communicate via a simple API SMT for a new theory only requires new T -solver SAT solver can be embedded in a lazy SMT system with very few new lines of code SMT Theory and DPLL( T ) – p. 54

  63. Eager vs Lazy Approach (2) The Lazy Approach idea ( SAT Solver + Theory Reasoner ) has been applied to other extensions of SAT ( x i ’s are Boolean): Cardinality constraints (e.g. x 1 + x 2 + ... + x 7 ≤ 4 ) Pseudo-Boolean constraints (e.g. 7 x 1 + 4 x 2 + 3 x 3 + 5 x 4 ≤ 10 ) ... Also sophisticated encodings exist for these constraints (Eager Approach) Lazy approach extremely simple to implement, but is it always competitive w.r.t. an encoding? SMT Theory and DPLL( T ) – p. 55

  64. Eager vs Lazy Approach (3) Consider the problem with no SAT clauses and two constraints: x 1 + ... + x n ≤ n / 2 x 1 + ... + x n > n / 2 Let us see how a (very) Lazy Approach would behave: Problem is obviously unsatisfiable Inconsistency explanations are of the form: SMT Theory and DPLL( T ) – p. 56

  65. Eager vs Lazy Approach (3) Consider the problem with no SAT clauses and two constraints: x 1 + ... + x n ≤ n / 2 x 1 + ... + x n > n / 2 Let us see how a (very) Lazy Approach would behave: Problem is obviously unsatisfiable Inconsistency explanations are of the form: ¬ x i 1 ∨ ... ∨¬ x i n / 2 + 1 x i 1 ∨ ... ∨ x i n / 2 SMT Theory and DPLL( T ) – p. 56

  66. Eager vs Lazy Approach (3) Consider the problem with no SAT clauses and two constraints: x 1 + ... + x n ≤ n / 2 x 1 + ... + x n > n / 2 Let us see how a (very) Lazy Approach would behave: Problem is obviously unsatisfiable Inconsistency explanations are of the form: ¬ x i 1 ∨ ... ∨¬ x i n / 2 + 1 x i 1 ∨ ... ∨ x i n / 2 All ( n 2 + 1 ) + ( n n / 2 ) explanations are needed to produce an n unsatisfiable subset of clauses SMT Theory and DPLL( T ) – p. 56

  67. Eager vs Lazy Approach (3) Consider the problem with no SAT clauses and two constraints: x 1 + ... + x n ≤ n / 2 x 1 + ... + x n > n / 2 Let us see how a (very) Lazy Approach would behave: Problem is obviously unsatisfiable Inconsistency explanations are of the form: ¬ x i 1 ∨ ... ∨¬ x i n / 2 + 1 x i 1 ∨ ... ∨ x i n / 2 All ( n 2 + 1 ) + ( n n / 2 ) explanations are needed to produce an n unsatisfiable subset of clauses Hence, runtime is exponential in n . SMT Theory and DPLL( T ) – p. 56

  68. Eager vs Lazy approach (4) What has happened? Lazy approach = lazily encoding (parts of) the theory into SAT Sometimes, only parts of the theory need to be encoded But in this example the whole constraint is encoded into SAT... ...and the encoding used is a very naive one SMT Theory and DPLL( T ) – p. 57

  69. Eager vs Lazy approach (4) What has happened? Lazy approach = lazily encoding (parts of) the theory into SAT Sometimes, only parts of the theory need to be encoded But in this example the whole constraint is encoded into SAT... ...and the encoding used is a very naive one Best here is a good SAT encoding with auxiliary variables 1e+07 SAT Encoding SMT 1e+06 Number of conflicts 100000 10000 1000 100 16 18 20 22 24 26 SMT Theory and DPLL( T ) – p. 57 Size (n)

  70. Overview of the talk Motivation SMT Theories of Interest Eager approach Lazy approach Optimizations Theory propagation Conflict analysis in DPLL( T ) Combining Theory Solvers Eager vs Lazy Theory solver example SMT Theory and DPLL( T ) – p. 57

  71. Difference logic Literals in Difference Logic are of the form a − b ⊲ ⊳ k , where ⊳ ∈ {≤ , ≥ , < , > , = , � = } ⊲ a and b are integer/real variables k is an integer/real At the formula level, a = b is replaced by p and p ↔ a ≤ b ∧ b ≤ a is added If domain is Z then a − b < k is replaced by a − b ≤ k − 1 If domain is R then a − b < k is replaced by a − b ≤ k − δ δ is a sufficiently small real δ is not computed but used symbolically (i.e. numbers are pairs ( k , δ ) Hence we can assume all literals are a − b ≤ k SMT Theory and DPLL( T ) – p. 58

  72. Difference Logic - Remarks Note that any solution to a set of DL literals can be shifted (i.e. if σ is a solution then σ ′ ( x ) = σ ( x ) + k also is a solution) This allows one to process bounds x ≤ k Introduce fresh variable zero Convert all bounds x ≤ k into x − zero ≤ k Given a solution σ , shift it so that σ ( zero ) = 0 If we allow (dis)equalities as literals, then: If domain is R consistency check is polynomial If domain is Z consistency check is NP-hard ( k -colorability) 1 ≤ c i ≤ k with i = 1 ... # verts encodes k colors available c i � = c j if i and j adjacents encode proper assignment SMT Theory and DPLL( T ) – p. 59

  73. Difference Logic as a Graph Problem Given M = { a − b ≤ 2, b − c ≤ 3, c − a ≤ − 7 } , construct weighted graph G ( M ) 2 a b − 7 3 c Theorem: M is T -inconsistent iff G ( M ) has a negative cycle SMT Theory and DPLL( T ) – p. 60

  74. Difference Logic as a Graph Problem (2) Theorem: M is T -inconsistent iff G ( M ) has a negative cycle ⇐ ) k 1 k 2 k n Any negative cycle a 1 − → a 2 − → a 3 − → ... − → a n − → a 1 corresponds to a set of literals: a 1 − a 2 ≤ k 1 a 2 − a 3 ≤ k 2 ... a n − a 1 ≤ k n If we add them all, we get 0 ≤ k 1 + k 2 + ... + k n , which is inconsistent since neg. cycle implies k 1 + k 2 + ... + k n < 0 SMT Theory and DPLL( T ) – p. 61

  75. Difference Logic as a Graph Problem (3) Theorem: M is T -inconsistent iff G ( M ) has a negative cycle ⇒ ) Let us assume that there is no negative cycle. 0 1. Consider additional vertex o with edges o − → v for all verts. v 2. For each variable x , let σ ( x ) = − dist ( o , x ) 3. σ is a model of M If σ �| = x − y ≤ k then − dist ( o , x ) + dist ( o , y ) > k Hence, dist ( o , y ) > dist ( o , x ) + k But k = weight ( x − → y ) !!! SMT Theory and DPLL( T ) – p. 62

  76. Difference Logic as a Graph Problem (3) Theorem: M is T -inconsistent iff G ( M ) has a negative cycle ⇒ ) Let us assume that there is no negative cycle. 0 1. Consider additional vertex o with edges o − → v for all verts. v 2. For each variable x , let σ ( x ) = − dist ( o , x ) 3. σ is a model of M If σ �| = x − y ≤ k then − dist ( o , x ) + dist ( o , y ) > k Hence, dist ( o , y ) > dist ( o , x ) + k But k = weight ( x − → y ) !!! Where am I using there is no negative cycle? SMT Theory and DPLL( T ) – p. 62

  77. Difference Logic as a Graph Problem (3) Theorem: M is T -inconsistent iff G ( M ) has a negative cycle ⇒ ) Let us assume that there is no negative cycle. 0 1. Consider additional vertex o with edges o − → v for all verts. v 2. For each variable x , let σ ( x ) = − dist ( o , x ) [exists because there is no negative cycle] 3. σ is a model of M If σ �| = x − y ≤ k then − dist ( o , x ) + dist ( o , y ) > k Hence, dist ( o , y ) > dist ( o , x ) + k But k = weight ( x − → y ) !!! Where am I using there is no negative cycle? SMT Theory and DPLL( T ) – p. 62

Recommend


More recommend