Presentation on theme: "Satisfiability modulo the Theory of Bit Vectors"— Presentation transcript:
1 Satisfiability modulo the Theory of Bit Vectors Alessandro CimattiIRST, Trento, ItalyJoint work with R. Bruttomesso, A. Franzen, A. Griggio, R. SebastianiWe gratefully acknowledge support from the Academic Research Program of Intel
2 Index of the talk Satisfiability Modulo Theory The theory of Bit VectorsSatisfiability Modulo BVBit blastingEager encoding into Linear Integer ArithmeticA lazy approachConclusions( A preview of QF_UFBV32 at SMT-COMP )
3 SMT in a nutshell Satisfiability Modulo Theory or: beyond boolean SATDecide the satisfiability of a first order formula with respect to a background theoryExamples of relevant theoriesuninterpreted functions: x=y & f(x) != f(y)difference logic: x – y < 7linear arithmetic: 3x + 2y < 12arrays: read(write(M, a0, v0) a1)their combinationsbit vectors
4 Why SMT From SAT-based to SMT-based verification Representation of interesting problemstimed automatahybrid automatapipelinessoftwareEfficient solvingleverage availability of structural informationhopefully retaining efficiency of boolean SAT
5 Satisfiability Modulo Theory is there a truth-assignment to boolean variablesand a valuation to individual variablessuch that formula evaluates to true?Standard semantics for FOLAssignment to individual variablesInduces truth values to atomsTruth assignment to boolean atomsInduced value to whole formula
6 Propositional structure + -++ --+ -++ --TATATATAP P Px y z w xx y z w x
7 Two Main Approaches to SMT the eager approachthe lazy approachtheory independent viewtheory specific view
8 Eager Approach to SMT Main idea: compilation to SAT STEP1: Theory part compiled to equisatisfiable pure SAT problemSTEP2: run propositional SAT solver
9 Propositional structure TAP P Px y z w xx y z w x
10 Propositional structure Lifted theoryPropositional structureTA TA TA TAP P P
11 The Lazy approach Ingredients a boolean SAT solvera theory solverThe boolean solver is modified to enumerate boolean (partial) modelsThe theory solver is used to Check for theory consistency
12 Propositional structure TATA TA TA TATAP P PTATAx y z w xx y z w x
13 MathSAT: intuitionsTwo ingredients: boolean search and theory reasoningfind boolean modeltheory atoms treated as boolean atomstruth values to boolean and theory atomsmodel propositionally satisfies the formulacheck consistency wrt theoryset of constraints induced by truth values to theory atomsexistence of values to theory variablesExample: (P v (x = 3)) & (Q v (x – y < 1)) & (y < 2) & (P xor Q)Boolean model!P, (x = 3), Q, (x – y < 1), (y < 2)Check (x = 3), (x – y < 1), (y < 2)Theory contradiction!Another boolean modelP , !(x = 3) , !Q, (x – y < 1), (y < 2)Check !(x = 3), (x – y < 1), (y < 2)Consistent: e.g. x := 0, y := 0
14 Boolean SAT: search space QQRSSTSTRRTSAT!The DPLL procedureIncremental construction of satisfying assignmentBacktrack/backjump on conflictLearn reason for conflictSplitting heuristics
15 MathSAT: approach DPLL-based enumeration of boolean models Retain all propositional optimizationsConflict-directed backjumping, learningNo overhead if no theory reasoningTight integration betweenboolean reasoning andtheory reasoning
16 MathSAT: search space Many boolean models are not theory consistent! P QQRSSTSTRRBool Bool TMath Bool TMath Bool Bool TMath TSAT!Bool Many boolean models are not theory consistent!
17 Early pruning Check theory consistency of partial assignments P Q S T EP:Math EP:Math TQEP:Math TSPruned awayin the EP stepEP:Math TTEP:Math TRBool Bool TMath TSAT!
20 Fixed Width Bit Vectors Constants0b , 0xFFFF, …Variablesvalued over BitVectors of corresponding widthimplicit restriction to finite domainFunction symbolsselection: x[15:0]concatenation: y :: zbitwise operators: x && y, z || w, …arithmetic operators: x + y, z * w, …shifting: x << 2, y >> 3Predicate symbolscomparators: =, ≠ , > , < , ≥ , ≤
21 Fragments of BV theory Core Bitwise operators Arithmetic operators selectionconcatenationBitwise operatorsx && y, x || y, x ^ yArithmetic operatorsx +y, x – y, c * xCore + Bitwise + ArithmeticComplexity of equality between BV termsCore is in PCore + B + A in NPVariable width bit vectors: not covered herecore is in NPsmall additions yield undecidability
22 Decision procedures for BV Many approachesCyrluk, Moeller, RuessMoeller, RuessBjørner, PichoraBarrett, Dill, LevittFocus on deciding conjunctions of literalsEmphasis on proof obligations in ITPsome emphasis on variable width, generic wrt NShostak-style integrationcanonizationsolving
24 Satisfiability modulo Bit Vectors Applications of interestRTL hardware descriptions essentially bit vectorsassembly-level programssoftware with finite precision arithmeticKey featurecombination of control flow and data flowIn principle, boolean logic can be encoded into BVcontrol (boolean logic) encoded into width 1 BVs.Likely inefficient in comparison to SATMore natural to keep them separate at modelingstructural info can be exploited for verification
25 Approaches to SMT(BV) Bit blasting Eager Encoding into LA Lazy approach
29 Scalability with respect to N??? Bit Blasting Wordsa,b,c,d,…blasted to [a1,…aN], [b1,…bN], [c1,…cN], [d1,…dN], …LTmp6 != RTmp6(LOut.1 != ROut.1) or … or (LOut.N != ROut.N)LTmp1 = 2 * bformula in 2N vars, conjunction of N iffsLTmp2 = LTmp0 + LTmp1formula relating 3N varspossibly additional vars required (e.g. carries)N = 16 bits?13 secsN = 32 bits?170 secs“But obviously N = 64 bits!”stopped after 2h CPU timeScalability with respect to N???
30 Bit-Blasting: Pros and Conses Bottlenecksdependency on word width“wrong” level of abstractionboolean synthesis of arithmetic circuitsassignments are pervasiveconflicts are very fine grainede.g. discover x < yAdvantageslet the SAT solver do all the workand nowadays SAT solvers are tough nuts to crackamalgamation of the decision processno distinction between control and dataconflicts can be as fine grained as possiblebuilt-in capability to generate “new atoms”
31 Enhancements to BitBlasting Tuning SAT solver on structural informatione.g. splitting heuristic for addersPreprocessing + SAT [GBD05]rewrite and normalize bit vector termsbit blasting to SAT
33 From BV to LIARTL-Datapath Verification using Integer Linear Programming [BD01]BV constants as integers0b32_1111 as 15BV variables as integer valued variables, with range constraintsreg x [31:0] as x in range [0, 2^32)Assignments treated as equality, e.g. x = yArithmetic, e.g. z = x + yLinear arithmetic? not quite! BV Arithmetic is modulo 2^Nz = x + y - 2^N s, with z in [0, 2^N)Concatenation: x :: y as 2^n x + ySelection: relational encoding (based on integrity)x[23:16] as xm, wherex = 2^24 xh + 2^16 xm + xl, xl in [0, 2^16), xm in [0, 2^8), xl in [0, 2^8)Bitwise operatorsbased on selection of individual bitsSOLVERthe omega test
34 From SMT(BV) into SMT(LIA) Generalizes [BD01] to deal with boolean structureEager encoding into SMT(LIA)Unfortunately, not very efficientMore precisely, a failure
35 Retrospective Analysis Crazy approach?ArithmeticLinear arithmetic? not quite! BV Arithmetic is modulo 2^NSelection and Concatenationan easy problem becomes expensive!Bitwise operatorsHARD!!!Available solvers not adequateintegers with infinite precisionreasoning with integers may be hard (e.g. BnB within real relaxation)Functional dependencies are lost!A clear culprit: static encodingdepending on control flow, same signal is split in different partsz = if P then x[7:0] :: y[3:0] else x[5:2] :: y[10:3]x, y and also z are split more than neededthe notion of “maximal chunk” depends on P !!!
37 A lazy approach Based on standard MathSAT schema DPLL-based model enumeationDedicated Solver for Bit vectorsThe encoding leverages information resulting from decisionsGiven values to control variables, the data path is easier to deal with (e.g. maximal chunks are bigger)Layering in the theory solverequality reasoninglimited simplification rulesfull blown bit vector solver only at the end
39 Rewriting rules evaluation of constant terms rules for equality 0b8_ [4:2] becomes 0b3_101rules for equalityx = y and Phi(x) becomes Phi(y)based on congruence closuresplitting concatenations(x :: y) = z becomes x = z[h_n] && y == z[l_n]
41 BV rewriter Rules are applied until fix point reachedcontradiction foundImplementation based on EUF reasonerrules as merges between eq classesOpen issuesincrementality/backtrackabilityselective rule activationconflic set reconstructionWhen it fails …
42 LIA encoding (the last hope) idenfication of maximal slices“purification”: separating out arithmetic and BW by introduction of additional variablesNB: on resulting problemsLIA encoding always superior to bit blasting!!!cfr [DB01]
43 Status of Implementation Implementation still in prototypical state“Does a lot of stupid things”conflict minimization by deletion filteringchecking that conflict are in fact minimalunnecessary calls to LA for SAT clusterscalling LA solver implemented as dump on file, and run external MathSAThuge conflict sets
45 Competitors Run against MiniSAT 1.14 KEY REMARK: ~ winner of SAT competition in 2005KEY REMARK:boolean methods are very matureA good reason for giving up?
46 Test benches 74 benchmarks from industrial partner Unfortunately would have been ideal for SMT-COMPQF_UFBV32Unfortunatelycan not be disclosed“will have to be destroyed after the collaboration”hopefully our lives will be spared
49 Conclusions A “market need” for SMT(BV) solvers Bit Blasting: tough competitorsAfter a failure, …Preliminary results are encouragingFuture challengesoptimize BV solverbetter conflict setstackle some RTL verification casesextension to memories
51 QF_UFBV at SMT-COMPthe MathSAT you will see there IS NOT the one I describedWe currently have no results for QF_UFBVEasy benchmarks:QF_UFBV not particularly “SMT”the boolean component is nearly missingthe BV part is “easily” solvable by bit blastingWe entered SMT-COMP QF_UFBV32MathSAT based on BIT BLASTING to SATNuSMV based on bit blasting to BDDs
52 QF_UFBV: Bit Blasting to SAT Preprocessing based onAckerman’s elimination of function symbolsrewriting simplificationbit blastingCore: call SAT solver underlying MathSATevery SAT problem in < 0.3 secsmost UNSAT within secondsa handful of hard ones between 300 and 500 secs
53 BDDs (???) on SMT-COMP tests Even NuSMV entered SMT-COMPAckerman’s elimination of functional symbolsRewriting preprocessorCore solverbased on BDDsconjunctively partitioned problemstructural BDD-based ordering (bit interleaving)(almost) no dynamic reorderingaffinity-based clustering, threshold 100 nodesearly quantificationSeems to work well both on SAT and UNSAT instances
54 RESULTS first STP then YICES then NuSMV then CVC3 (but no results on two samples)then MathSAT BITBLASTING3rd on SATlast on UNSAT
Your consent to our cookies if you continue to use this website.