smt unsat core minimization
play

SMT Unsat Core Minimization OFER GUTHMANN, OFER STRICHMAN, ANNA TRO - PowerPoint PPT Presentation

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


  1. SMT Unsat Core Minimization OFER GUTHMANN, OFER STRICHMAN, ANNA TRO STANETSKI FMCAD2016 1 SMT MUCS

  2. 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

  3. 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

  4. 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

  5. Deletion-based MUC Extraction (propositional case) 𝑫 π‘Ίπ’‡π’π’‘π’˜π’‡ 𝒗𝒐𝒏𝒃𝒔𝒍𝒇𝒆 π’…π’Žπ’ƒπ’—π’•π’‡ 𝒅 ∈ 𝑫 𝑻𝑩𝑼 𝑫 ? 𝒁𝒇𝒕 𝑢𝒑 𝑡𝒃𝒔𝒍 𝒅, 𝒃𝒐𝒆 𝑫 ← 𝒅𝒑𝒔𝒇 𝒃𝒆𝒆 𝒋𝒖 𝒄𝒃𝒅𝒍 𝒖𝒑 𝑫 𝒁𝒇𝒕 𝑢𝒑 π‘©π’Žπ’Ž π’…π’Žπ’ƒπ’—π’•π’‡π’• 𝑺𝒇𝒖𝒗𝒔𝒐 𝑫 𝒏𝒃𝒔𝒍𝒇𝒆? 5 SMT MUCS

  6. 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

  7. HSmtMuc A Deletion-based SMT MUC Extractor 𝑫 π‘Ίπ’‡π’π’‘π’˜π’‡ 𝑽𝒐𝒏𝒃𝒔𝒍𝒇𝒆 π’…π’Žπ’ƒπ’—π’•π’‡ 𝒅 ∈ 𝑫 𝑻𝑩𝑼 𝑫 ? π’‚πŸ’ 𝑫 ? 𝒁𝒇𝒕 𝑢𝒑 𝑡𝒃𝒔𝒍 𝒅, 𝒃𝒐𝒆 𝑫 ← 𝒅𝒑𝒔𝒇 𝒃𝒆𝒆 𝒋𝒖 𝒄𝒃𝒅𝒍 𝒖𝒑 𝑫 𝒁𝒇𝒕 𝑢𝒑 π‘©π’Žπ’Ž π’…π’Žπ’ƒπ’—π’•π’‡π’• 𝑺𝒇𝒖𝒗𝒔𝒐 𝑫 𝒏𝒃𝒔𝒍𝒇𝒆? 7 SMT MUCS

  8. 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

  9. 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

  10. 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

  11. 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

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. 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

  18. 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

  19. Experimental Results – Theory Rotation Reduces the number of (deletion) iterations. 19 SMT MUCS

  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

  25. Questions? 25 SMT MUCS

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend