SMT Unsat Core Minimization OFER GUTHMANN, OFER STRICHMAN, ANNA TRO STANETSKI FMCAD2016 1 SMT MUCS
Satisfiability Modulo Theories Satisfiability Modulo Theories (SMT): decides satisfiability of formulas over first order theories, by combining β¦ a SAT solver, and β¦ decision procedures for conjunctions of first order literals. 2 SMT MUCS
SMT solvers use Boolean Abstraction Let π be an SMT formula π βs Boolean Abstraction, π π , assigns a Boolean variable to every theory literal in π. Example: π 2 π 1 π 3 π = π¦ = 0 β§ π¦ = 1 β¨ Β¬ π¦ = 2 β¦ β¦ π π = π 1 β§ π 2 β¨ Β¬π 3 β¦ Boolean structure unchanged. Decoding: π π 1 β π¦ = 0 , π π 2 β π¦ = 1 , etc. 3 SMT MUCS
The Minimal Unsat Core Problem (MUC) Let π be an unsat SMT formula (in CNF). Find a minimal (i.e., irreducible) unsat c ore of π β s clauses. π = π β§ Β¬π β¨ π β§ Β¬π β¨ Β¬π β§ π β¨ π π· = π, Β¬π β¨ π , Β¬π β¨ Β¬π π· is a minimal unsat core. Many applications may benefit from finding a MUC: β¦ Abstraction refinement. β¦ Formal equivalence verification. β¦ Decision procedures. β¦ Etc. We know of no SMT MUC extractors in the public domain 4 SMT MUCS
Deletion-based MUC Extraction (propositional case) π« πΊπππππ ππππππππ π πππππ π β π« π»π©πΌ π« ? πππ πΆπ π΅πππ π , πππ π« β π πππ πππ ππ πππ π ππ π« πππ πΆπ π©ππ π ππππππ πΊπππππ π« ππππππ? 5 SMT MUCS
Z3 and Cores Z3 is an open-source competitive SMT solver: β¦ Developed by Microsoft Research. β¦ Emits an unsat core (set of clauses used in proof). β¦ Uses high-level proof rules Unsat Core *Diagram taken from L. Zhang and S. Malik: Validating SAT Solvers Using an Independent Resolution-Based Checker: Practical Implementations and Other Applications . 2003. 6 SMT MUCS
HSmtMuc A Deletion-based SMT MUC Extractor π« πΊπππππ π½πππππππ π πππππ π β π« π»π©πΌ π« ? ππ π« ? πππ πΆπ π΅πππ π , πππ π« β π πππ πππ ππ πππ π ππ π« πππ πΆπ π©ππ π ππππππ πΊπππππ π« ππππππ? 7 SMT MUCS
Optimization: Rotation * A. Belov and J. Marques-Silva. Accelerating MUS extraction with recursive model rotation . 2011. Let π be a marked clause. β¦ π β π is satisfiable. β¦ π½ β¨ π β π . Rotate( c , Ξ±) β¦ Find Ξ± β² β Ξ± and c β² β c , s.t. Ξ±β² β¨ Ο β cβ² β¦ By flipping variables in Ξ± that appear in c . β¦ If such c β² was found: β¦ Mark c β² β¦ Rotate( c β² , Ξ± β² ) 8 SMT MUCS
Now in SMT: Theory Rotation Let π be a marked clause. Recall: π applies Recall: π applies Boolean boolean β¦ π β π is satisfiable. abstraction abstraction β¦ π½ β¨ π π β π . Rotate( c , Ξ±) β¦ Find Ξ± β² β Ξ± and c β² β c , s.t. Ξ±β² β¨ e Ο β c β² : β¦ By flipping variables in Ξ± that appear in c . β¦ If such c β² was found: β¦ Mark c β² β¦ Rotate( c β² , Ξ± β² ) The problem: the new assignment may not be T-consistent 9 SMT MUCS
Theory Rotation β Contradiction Example π = π¦ = 0 β§ Β¬ π¦ = 0 β¨ π¦ = 1 β§ Β¬ π¦ = 0 β¨ π¦ = 2 π π π = π 1 β§ Β¬π 1 β¨ π 2 β§ Β¬π 1 β¨ π 3 π π For a model\interpretation where π¦ βΌ 1 we have: π½ β π 1 , π 3 βΌ πΊ, π 2 βΌ π 10 SMT MUCS
Theory Rotation β Contradiction Example π = π¦ = 0 β§ Β¬ π¦ = 0 β¨ π¦ = 1 β§ Β¬ π¦ = 0 β¨ π¦ = 2 π π π = π 1 β§ Β¬π 1 β¨ π 2 β§ Β¬π 1 β¨ π 3 π π For a model\interpretation where π¦ βΌ 1 we have: π½ β π 1 , π 3 βΌ πΊ, π 2 βΌ π π½ β¨ π π β π Flipping π 1 in π½ results in a Tβcontradiction . β¦ both e 1 β π¦ = 0 and e 2 β (π¦ = 1 ) now hold. 11 SMT MUCS
Theory Rotation - Solution After finding (cβ, π½β²) , check if π½β² is T-consistent. If it is T-consistent use Rotate ( cβ, π½β²) as before. If itβs not... β¦ One possibility is to give up and stop the recursion. β¦ Letβs try and do better. 12 SMT MUCS
Theory Rotation β Fixing a T-Contradiction Try and find more variables to flip in π½ β² . Variables to flip: choose from πππ π π½ β² . β¦ If resulting π½ β²β² still contradictory, recursively flip more vars. β¦ Recursion depth is determined heuristically. π½ β²β² β¨ π β π β²β² and is T-consistent β β¦ mark πβ²β² , and β¦ Rotate (π β²β² , π½ β²β² ) . 13 SMT MUCS
Adaptive Activation of Theory Rotation Failed Theory Rotation can be costly. Determine at runtime whether rotations is be continued: First option: β¦ Fail Bound: stop after π¦ consecutive failures. β¦ Failure: no clauses were marked. Observation: Rotation success-rate declines through time. 14 SMT MUCS
Adaptive Activation of Theory Rotation Another option π’ π β¦ Dynamic Measurement: estimate π’ π‘ππ’ < π π to stop rotation. β¦ Problem: measurement is non-monotonic. Time cost per clause marking Time cost per clause marking 600 600 500 500 400 400 Time (ms) Time (ms) 300 300 200 200 100 100 0 0 0 0 200 200 400 400 600 600 800 800 1000 1000 1200 1200 1400 1400 1600 1600 1800 1800 2000 2000 Iteration Iteration SMT SAT check time Rotation time SMT SAT check time 15 SMT MUCS
Adaptive Activation of Theory Rotation Exponential smoothing: Given a stream of measurements π π π π π’ π‘ππ’ , π’ π ππ’ , π π ππ’ define: π=1 0 0 π π‘ππ’ = π’ π‘ππ’ π π πβ1 , π π‘ππ’ = π½ β π’ π‘ππ’ + 1 β π½ β π π‘ππ’ 0 β€ π½ β€ 1 π π β¦ Do the same for π π ππ’ and π π ππ’ π π π π ππ’ Stop rotation when π π‘ππ’ < holds. π π π ππ’ π½ chosen heuristically. 16 SMT MUCS
Adaptive Activation of Theory Rotation Back to the example, now with exponential smoothing: Time cost per clause marking (Uses exp. smoothing w. alpha = 0.1) 1000 4 900 3.5 800 3 700 2.5 marked clauses 600 Number of Time (ms) 500 2 400 1.5 300 1 200 0.5 100 0 0 1 21 33 44 58 67 76 88 99 107 118 127 136 147 156 165 171 180 189 198 207 216 223 235 245 251 257 264 271 278 284 294 303 309 316 325 333 341 348 354 361 369 Iteration smt call time rotation call time (ratio) #clauses marked in rotation 17 SMT MUCS
Experimental Results β Avg. core size reduction 561 unsat SMT-LIB instances* Avg. core size: β¦ Z3: 820 clauses. β¦ Min:454 clauses. *Same instances seleScted in A. Cimatti, A. Griggio, and R. Sebastiani: Computing small unsatisfiable cores in satisfiability modulo theories . 2011. 18 SMT MUCS
Experimental Results β Theory Rotation Reduces the number of (deletion) iterations. 19 SMT MUCS
Experimental Results β Theory Rotation Translates to a modest run-time improvement (~6%-10%) π·πππππ. Time T-check T-Conflicts (sec.) Time (sec.) Resolved (base) 30.5 0.0 0.0 T-Rotate 29.7 1.4 20.8 T-Rotate b 5 28.9 1.0 10.2 T-Rotate b 7 29.2 1.2 12.3 T-Rotate exp 29.6 1.2 11.2 Can be attributed to time spent on failed rotations, T-contradiction checks and additional var. flipping. Best configuration is for Theory Rotation w. fail bound = 5 20 SMT MUCS
And now... Small Unsatisfiable Core (SUC) [1] suggested an algorithm that finds a small (not necessarily minimal) SMT core β¦ Based on MathSat and the propos. MUC extractor Muser2 We re-implemented [1] based on Z3 + HaifaMuc We also tested a hybrid approach in which we find a small core and then minimize it with HSmtMuc [1] A. Cimatti, A. Griggio, and R. Sebastiani. Computing small unsatisfiable cores in satisfiability modulo theories (2011). 21 HAIFA SMT MUCS
Small Unsatisfiable Core (SUC) Extract MathSat Muser2 π(π πππ’π‘ β² ) Proof π(π πππ’π‘β) SUC π(π πππ’π‘ + ππππππ‘) Our re-implementation with Z3 and HaifaMUC: β¦ Requires proof logging (slows Z3 a lot). β¦ Requires a propositional encoding of Z3βs proof objects. β¦ Produces much larger proofs on avg. comparing to MathSat. β¦ Turned-out to be slower 22 SMT MUCS
We also tried a hybrid approach MathSat-based SUC + minimization with HSmtMuc. β¦ Result is minimal. πππ· π πππ· MathSat + HSmtMuc Muser2 The overall winner. Less time-outs (HSmtMuc alone: 171 vs. Hybrid: 138). β¦ (but higher runtime than HSmtMuc on instances that completed, HSmtMuc: 22.9 sec. vs. Hybrid: 27.9 sec.). 23 SMT MUCS
Summary HSmtMuc is the first SMT-MUC extractor in the public domain. β¦ Based on Z3. Best observed results: MUC: the Hybrid algorithm β¦ MathSat SUC extraction, followed by HSmtMuc. SUC: β¦ MathSat SUC extraction. More information & our implementation is available at http://strichman.net.technion.ac.il/ 24 SMT MUCS
Questions? 25 SMT MUCS
Recommend
More recommend