Learning to Solve SMT Formulas Mislav Balunovic, Pavol Bielik , - - PowerPoint PPT Presentation

learning to solve smt formulas
SMART_READER_LITE
LIVE PREVIEW

Learning to Solve SMT Formulas Mislav Balunovic, Pavol Bielik , - - PowerPoint PPT Presentation

Learning to Solve SMT Formulas Mislav Balunovic, 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


slide-1
SLIDE 1

Learning to Solve SMT Formulas

Mislav Balunović, Pavol Bielik, Martin Vechev Department of Computer Science

slide-2
SLIDE 2

SAT SMT

SMT Formula

φ = (b ∨ -x2 ≥ 2.3y ∨ sin(x)3 = cos(log(y) • x)) ∧ (¬b ∨ y < -34.4 ∨ exp(y) > y/x)

where b ∊ {true, false}, x, y ∊ ℝ

Theories Booleans, Reals, Integers, Arrays, BitVectors, Strings, ... Does there exist a valid assignment to b, x, y?

slide-3
SLIDE 3

b = true x = 14.32 y = -37.2

SMT Solvers

φ = (b ∨ -x2 ≥ 2.3y ∨ sin(x)3 = cos(log(y) • x)) ∧ (¬b ∨ y < -34.4 ∨ exp(y) > y/x)

φ

SMT Solver

Find an assignment to all free variables in φ such that φ evaluates to true SAT + model UNSAT + unsat core First-order logic formula

where b ∊ {true, false}, x, y ∊ ℝ

Does there exist a valid assignment to b, x, y?

slide-4
SLIDE 4

SMT Solvers

φ

SMT Solver

Find an assignment to all free variables in φ such that φ evaluates to true

Software & Hardware Verification Neural Networks Verification Type Inference Symbolic Execution Planning Static Program Analysis Scheduling Graph Problems Program Synthesis

Applications SAT + model UNSAT + unsat core First-order logic formula

slide-5
SLIDE 5

Solving SMT Formulas is Hard

φ

SMT Solver

SAT + model UNSAT + unsat core Theory Complexity Quantifier Free Booleans (SAT) NP-Complete O(nk) Linear Real Arithmetic 2-EXPTIME O(22 ) Linear Integer Arithmetic 3-EXPTIME O(22 ) Non-linear Integer Arithmetic undecidable

nk nk

2

First-order logic formula

slide-6
SLIDE 6

Solving SMT Formulas is Hard

φ

Set of Handcrafted Strategies SAT + model UNSAT + unsat core Theory Complexity Quantifier Free Booleans (SAT) NP-Complete O(nk) Linear Real Arithmetic 2-EXPTIME O(22 ) Linear Integer Arithmetic 3-EXPTIME O(22 ) Non-linear Integer Arithmetic undecidable

nk nk

2

First-order logic formula

slide-7
SLIDE 7

Solving SMT Formulas is Hard

φ

Set of Handcrafted Strategies State-of-the-art SMT Solvers ✘ Easily perform badly on new problems ✘ Require expert knowledge to fix SAT + model UNSAT + unsat core First-order logic formula

slide-8
SLIDE 8

Learning to Solve SMT Formulas

φ

Learned Strategies Fast ✔ Learn fast strategies ✔ No prior knowledge Our Work: SAT + model UNSAT + unsat core First-order logic formula State-of-the-art SMT Solvers ✘ Easily perform badly on new problems ✘ Require expert knowledge to fix

slide-9
SLIDE 9

Action Space

SMT Formula Solving

apply transformation (tactic)

Constant Folding x + 0 x Bit Blasting x = 5 x3 = 0 ∧ x2 = 1 ∧ x1 = 0 ∧ x0 = 1

01012

φ φ φ φ

1

Decision Procedure Reals, Integers, BitVectors, ...

2 3

true (SAT) false (UNSAT) t1 t2 t3

Normalize Bounds k ≤ x 0 ≤ x’

x’ = x - k

slide-10
SLIDE 10

Handcrafted strategies determine which path to take

SMT Formula Solving

φ φ φ φ

532 s

φ φ φ φ

TIMEOUT 12 s TIMEOUT TIMEOUT

1 2 2 2 3 3 3 1 2 3 2 3 1

apply transformation (tactic)

slide-11
SLIDE 11

Learning to Solve Formula

SMT Strategy t1; …; tn Model

φ

SAT + model UNSAT + unsat core

Predict Strategy φ

Hard to Learn

slide-12
SLIDE 12

Handcrafted strategies determine which path to take

Learning to Solve Formula

φ φ φ φ

532 s

φ φ φ φ

TIMEOUT 12 s TIMEOUT TIMEOUT

1 2 2 2 3 3 3 1 2 3 2 3 1

apply transformation (tactic)

slide-13
SLIDE 13

Learning to Solve Formula

s s s s s s s s

a1 a1 a2 a3 a2 a1 a3 532 s TIMEOUT 12 s TIMEOUT TIMEOUT

1 2 2 2 3 3 3 1 2 3 2 3 1

Learn path with lowest runtime

slide-14
SLIDE 14

SMT Formula Solving

Model

φ

SMT Strategy t1; …; tn SAT + model UNSAT + unsat core

φ

Policy SMT t1

φ1

Policy SMT t2 SAT UNSAT ...

Predict Strategy φ Predict Single Transformations

Hard to Learn Internal SMT State Lost Model Not Available Runtime Overhead Easier to Learn Bit Blasting x = 5 x3 = 0 ∧ x2 = 1 ∧ x1 = 0 ∧ x0 = 1

01012

slide-15
SLIDE 15

Learning to Solve SMT Formulas

Learning Policy Dataset of Formulas Learn a policy to select next tactic Policy SMT

solved? Tactic

φ

no yes SAT UNSAT

slide-16
SLIDE 16

Learning to Solve SMT Formulas

Learning Policy Extraction Policy Dataset of Formulas Learn a policy to select next tactic Use the learned policy to synthesize a Strategy program Policy SMT

solved? Tactic

φ

no yes SAT UNSAT

SMT

+

✔ No runtime overhead ✔ Integration with existing SMT Solvers

φ

SAT + model UNSAT + unsat core Program with Branches

slide-17
SLIDE 17

Neural Network Policy

Prior Actions [simplify, bit_blast, …] Formula Measures [num_consts, is_pb, …] Formula Representation BOW | Skip-Gram | AST Embedding Embedding [1733, 0, …]

eval on φ eval on φ

slide-18
SLIDE 18

Neural Network Policy

Embedding Embedding [1733, 0, …] ReLU ReLU ReLU SoftMax Sigmoid Tactics 0.70: pb2bv 0.15: smt ... Parameters 0.20: flat 0.75: som 95: factor ... Probability distribution

  • ver tactics

Regression to predict each parameter

eval on φ eval on φ

Prior Actions [simplify, bit_blast, …] Formula Measures [num_consts, is_pb, …] Formula Representation BOW | Skip-Gram | AST

slide-19
SLIDE 19

Training

Dataset of Formulas = {φ, ψ, …, χ}

slide-20
SLIDE 20

Training

Sample Policy

Policy SMT

solved? Tactic

φ

no yes SAT UNSAT

Dataset of Formulas = {φ, ψ, …, χ}

slide-21
SLIDE 21

Training

Training Dataset Sample Policy

Policy SMT

solved? Tactic

φ

no yes SAT UNSAT

Dataset of Formulas = {φ, ψ, …, χ}

slide-22
SLIDE 22

Training

Training Dataset Retrain Policy

tactic weighted average of cross-entropy loss + mean-square-error parameters

= Sample Policy

Policy SMT

solved? Tactic

φ

no yes SAT UNSAT

Dataset of Formulas = {φ, ψ, …, χ}

slide-23
SLIDE 23

Training

Training Dataset Retrain Policy

tactic weighted average of cross-entropy loss + mean-square-error parameters

= Sample Policy

Policy SMT

solved? Tactic

φ

no yes SAT UNSAT

= {φ, ψ, …, χ} Evaluate

slide-24
SLIDE 24

Learning

Sequential Strategies 𝜌(a | s)

φ

a1 a2 a3 a1 a4 a5 a1 a4 a5

ψ χ

slide-25
SLIDE 25

Learning Policy Extraction

φ ψ χ

𝜌(a | s) a1 a4 a5 a1 a2 a3 a1 a4 a5 Strategy with Branches if expr then a2 else a4 a1 a4 a5 a3 a2

{φ, ψ, …, χ}

Sequential Strategies

slide-26
SLIDE 26

Evaluation

state-of-the-art SMT Solver

Z3

Industrial Benchmarks

AProVE Sage2

Academic Benchmarks

leipzig core hycomp

Learning Policy Extraction

+

Learning Policy Extraction

+

Learning Policy Extraction

+

Learning Policy Extraction

+

Learning Policy Extraction

+

slide-27
SLIDE 27

Speed-up over Z3

Z3 handcrafted strategy

Speed-up

log scale 0.1 1 10 100 1000 20 40 60 80 100

faster slower Formulas

slide-28
SLIDE 28

Speed-up over Z3

Z3 handcrafted strategy

Speed-up

log scale 0.1 1 10 100 1000 20 40 60 80 100

faster slower

Synthesized Strategy

10x

Sage2

Formulas

slide-29
SLIDE 29

Speed-up over Z3

Z3 handcrafted strategy

Speed-up

log scale 0.1 1 10 100 1000 20 40 60 80 100

faster slower

Synthesized Strategy

10x 100x 1000x

Sage2 AProVE

Formulas

slide-30
SLIDE 30

Speed-up over Z3

Z3 handcrafted strategy

Formulas Speed-up

log scale 0.1 1 10 100 1000 20 40 60 80 100

faster slower

Synthesized Strategy

10x 100x 1000x

Sage2 AProVE leipzig core hycomp

slide-31
SLIDE 31

Learning to Solve SMT Formulas

http://fastsmt.ethz.ch/

Learning Policy Extraction Policy Dataset of Formulas Learn a policy to select next tactic Use the learned policy to synthesize a Strategy program SMT

+

✔ No runtime overhead ✔ Integration with existing SMT Solvers Policy SMT

solved? Tactic

φ

no yes SAT UNSAT

φ

SAT + model UNSAT + unsat core Program with Branches