Learning to Solve SMT Formulas Mislav Balunović, Pavol Bielik , Martin Vechev Department of Computer Science
SMT Formula Does there exist a valid assignment to b, x, y? φ = (b ∨ -x 2 ≥ 2.3y ∨ sin(x) 3 = cos(log(y) • x)) ∧ (¬b ∨ y < -34.4 ∨ exp(y) > y/x) where b ∊ {true, false}, x, y ∊ ℝ SMT Theories Booleans , Reals , Integers, Arrays, BitVectors, Strings, ... SAT
SMT Solvers Does there exist a valid assignment to b, x, y? φ = (b ∨ -x 2 ≥ 2.3y ∨ sin(x) 3 = cos(log(y) • x)) ∧ (¬b ∨ y < -34.4 ∨ exp(y) > y/x) where b ∊ {true, false}, x, y ∊ ℝ b = true Find an assignment to all free variables x = 14.32 in φ such that φ evaluates to true y = -37.2 SAT + model First-order φ SMT Solver logic formula UNSAT + unsat core
SMT Solvers Applications Planning Software & Hardware Verification Type Inference Scheduling Neural Networks Verification Symbolic Execution Graph Problems Program Synthesis Static Program Analysis Find an assignment to all free variables in φ such that φ evaluates to true SAT + model First-order φ SMT Solver logic formula UNSAT + unsat core
Solving SMT Formulas is Hard Theory Complexity Quantifier Free Booleans (SAT) NP-Complete O (n k ) n k Linear Real Arithmetic 2-EXPTIME O (2 2 ) n k 2 Linear Integer Arithmetic 3-EXPTIME O (2 2 ) Non-linear Integer Arithmetic undecidable SAT + model First-order φ SMT Solver logic formula UNSAT + unsat core
Solving SMT Formulas is Hard Theory Complexity Quantifier Free Booleans (SAT) NP-Complete O (n k ) n k Linear Real Arithmetic 2-EXPTIME O (2 2 ) n k 2 Linear Integer Arithmetic 3-EXPTIME O (2 2 ) Non-linear Integer Arithmetic undecidable SAT + model First-order φ Set of Handcrafted logic formula Strategies UNSAT + unsat core
Solving SMT Formulas is Hard State-of-the-art SMT Solvers ✘ Easily perform badly on new problems ✘ Require expert knowledge to fix SAT + model First-order φ Set of Handcrafted logic formula Strategies UNSAT + unsat core
Learning to Solve SMT Formulas State-of-the-art SMT Solvers Our Work: ✘ Easily perform badly on new problems ✔ Learn fast strategies ✘ Require expert knowledge to fix ✔ No prior knowledge Fast SAT + model First-order φ Learned Strategies logic formula UNSAT + unsat core
SMT Formula Solving apply transformation (tactic) t 1 t 2 t 3 true (SAT) φ φ φ φ 1 2 3 false (UNSAT) Constant Folding Bit Blasting x 3 = 0 ∧ x 2 = 1 ∧ x + 0 x x = 5 Action x 1 = 0 ∧ x 0 = 1 0101 2 Space Normalize Bounds Decision Procedure x ’ = x - k Reals, Integers, BitVectors, ... k ≤ x 0 ≤ x ’
SMT Formula Solving φ 1 532 s 2 apply transformation φ 1 TIMEOUT (tactic) 3 φ φ φ φ 2 2 12 s 1 2 3 φ 3 TIMEOUT 3 φ 3 TIMEOUT 2 Handcrafted strategies determine which path to take
Learning to Solve Formula Predict Strategy φ SAT + model Hard to Learn SMT UNSAT + unsat core Strategy φ Model t 1 ; … ; t n
Learning to Solve Formula φ 1 532 s 2 apply transformation φ 1 TIMEOUT (tactic) 3 φ φ φ φ 2 2 12 s 1 2 3 φ 3 TIMEOUT 3 φ 3 TIMEOUT 2 Handcrafted strategies determine which path to take
Learning to Solve Formula s 1 532 s 2 a 1 s 1 TIMEOUT a 1 3 a 1 a 2 a 2 s s s s 2 2 12 s 1 2 3 a 3 s 3 TIMEOUT a 3 3 s 3 TIMEOUT 2 Learn path with lowest runtime
SMT Formula Solving Predict Strategy φ SAT + model Hard to Learn SMT UNSAT + unsat core Strategy φ Model t 1 ; … ; t n Predict Single Transformations Easier to Learn SAT φ φ 1 Policy SMT Policy SMT t 1 t 2 ... UNSAT Runtime Overhead Internal SMT State Lost Model Not Available Bit Blasting x 3 = 0 ∧ x 2 = 1 ∧ x = 5 x 1 = 0 ∧ x 0 = 1 0101 2
Learning to Solve SMT Formulas Learning Policy Dataset of Formulas Policy Tactic no SAT SMT solved? φ yes UNSAT Learn a policy to select next tactic
Learning to Solve SMT Formulas Learning Policy Policy Extraction Dataset of Program with Formulas Branches Policy SAT + model φ + SMT Tactic no UNSAT + unsat core SAT SMT solved? φ yes UNSAT ✔ No runtime overhead ✔ Integration with existing SMT Solvers Learn a policy to Use the learned policy to select next tactic synthesize a Strategy program
Neural Network Policy Prior Actions Embedding [simplify, bit_blast, … ] eval on φ Formula Measures [1733, 0, … ] [num_consts, is_pb, … ] eval on φ Formula Representation Embedding BOW | Skip-Gram | AST
Neural Network Policy Probability distribution over tactics Prior Actions Embedding Tactics [simplify, bit_blast, … ] SoftMax 0.70: pb2bv ReLU 0.15: smt eval on φ ... Formula Measures ReLU [1733, 0, … ] [num_consts, is_pb, … ] Parameters Sigmoid 0.20: flat ReLU eval on φ 0.75: som Formula Representation Embedding 95: factor BOW | Skip-Gram | AST ... Regression to predict each parameter
Training = { φ , ψ, …, χ } Dataset of Formulas
Training Policy no = { φ , ψ, …, χ } Tactic SAT SMT solved? φ yes UNSAT Dataset of Formulas Sample Policy
Training Policy no = { φ , ψ, …, χ } Tactic SAT SMT solved? φ yes UNSAT Dataset of Formulas Sample Policy Training Dataset
Training Policy no = { φ , ψ, …, χ } Tactic SAT SMT solved? φ yes UNSAT Dataset of Formulas Sample Policy Retrain Policy Training Dataset tactic weighted average of cross-entropy loss = + mean-square-error parameters
Training Policy no = { φ , ψ, …, χ } Tactic SAT SMT solved? φ yes UNSAT Evaluate Sample Policy Retrain Policy Training Dataset tactic weighted average of cross-entropy loss = + mean-square-error parameters
Learning 𝜌 (a | s) a 1 a 2 φ a 3 a 5 a 4 ψ a 1 a 5 a 4 χ a 1 Sequential Strategies
Learning Policy Extraction 𝜌 (a | s) a 1 a 2 φ if expr then a 2 else a 4 a 3 a 5 a 5 a 4 a 4 a 1 ψ a 1 a 2 a 3 a 5 a 4 χ a 1 { φ , ψ , …, χ } Strategy with Branches Sequential Strategies
Evaluation state-of-the-art SMT Solver Z3 Academic Benchmarks Industrial Benchmarks leipzig core hycomp AProVE Sage2 Learning Learning Learning Learning Learning + + + + + Policy Extraction Policy Extraction Policy Extraction Policy Extraction Policy Extraction
Speed-up over Z3 Speed-up log scale 1000 100 10 faster Z3 handcrafted 1 strategy slower 0.1 0 20 40 60 80 100 Formulas
Speed-up over Z3 Speed-up log scale 1000 100 Synthesized Sage2 10x Strategy 10 faster Z3 handcrafted 1 strategy slower 0.1 0 20 40 60 80 100 Formulas
Speed-up over Z3 Speed-up log scale 1000x 1000 AProVE 100x 100 Synthesized Sage2 10x Strategy 10 faster Z3 handcrafted 1 strategy slower 0.1 0 20 40 60 80 100 Formulas
Speed-up over Z3 Speed-up log scale 1000x 1000 AProVE 100x 100 Synthesized Sage2 10x Strategy 10 leipzig hycomp faster core Z3 handcrafted 1 strategy slower 0.1 0 20 40 60 80 100 Formulas
Learning to Solve SMT Formulas http://fastsmt.ethz.ch/ Learning Policy Policy Extraction Dataset of Program with Formulas Branches Policy SAT + model φ + SMT Tactic no UNSAT + unsat core SAT SMT solved? φ yes UNSAT ✔ No runtime overhead ✔ Integration with existing SMT Solvers Learn a policy to Use the learned policy to select next tactic synthesize a Strategy program
Recommend
More recommend