Leonardo de Moura (Microsoft Research) and Grant Passmore - - PowerPoint PPT Presentation

leonardo de moura microsoft research and grant passmore
SMART_READER_LITE
LIVE PREVIEW

Leonardo de Moura (Microsoft Research) and Grant Passmore - - PowerPoint PPT Presentation

Leonardo de Moura (Microsoft Research) and Grant Passmore (University of Cambridge) A Satisfiability Checker with built-in support for useful theories b + 2 = c and f(read(write(a,b,3), c- 2) f(c -b+1) b + 2 = c and f(read(write(a,b,3),


slide-1
SLIDE 1

Leonardo de Moura (Microsoft Research) and Grant Passmore (University of Cambridge)

slide-2
SLIDE 2

A Satisfiability Checker with built-in support for useful theories

slide-3
SLIDE 3

b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

slide-4
SLIDE 4

Arithmetic

b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

slide-5
SLIDE 5

Arithmetic Array Theory

b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

slide-6
SLIDE 6

Arithmetic Array Theory Uninterpreted Functions

b + 2 = c and f(read(write(a,b,3), c-2) ≠ f(c-b+1)

slide-7
SLIDE 7

Solvers:

AProve, Barcelogic, Boolector, CVC3, CVC4, MathSAT5, OpenSMT, SMTInterpol, SOLONAR, STP2, veriT, Yices, Z3

SMT-LIB: library of benchmarks (> 100k problems)

http://www.smtlib.org

SMT-COMP: annual competition

http://www.smtcomp.org

slide-8
SLIDE 8

Test case generation Verifying Compilers Predicate Abstraction Invariant Generation Type Checking Model Based Testing Scheduling & Planning …

slide-9
SLIDE 9

VCC

Hyper-V

Terminator T-2 NModel

HAVOC F7 SAGE Vigilante

SpecExplorer

slide-10
SLIDE 10

“Big” and hard formulas Thousands of “small” and easy formulas Short timeout (< 5secs)

slide-11
SLIDE 11

“Big” and hard formulas Thousands of “small” and easy formulas Short timeout (< 5secs)

VCC HAVOC SAGE

slide-12
SLIDE 12
slide-13
SLIDE 13

Z3 is a solver developed at Microsoft Research. Development/Research driven by internal customers. Free for non-commercial use. Interfaces: http://research.microsoft.com/projects/z3

Z3

Text C/C++ .NET OCaml

slide-14
SLIDE 14

rise4fun.com/z3

slide-15
SLIDE 15

Verification/Analysis tools need some form of Symbolic Reasoning

slide-16
SLIDE 16

Logic is “The Calculus of Computer Science” (Z. Manna). High computational complexity

slide-17
SLIDE 17
slide-18
SLIDE 18

We can try to solve the problems we find in real applications

slide-19
SLIDE 19

Scalability (huge formulas) Complexity Undecidability Quantified formulas

slide-20
SLIDE 20

A Sample

slide-21
SLIDE 21

Execution Path Run Test and Monitor Path Condition Solve seed New input Test Inputs Constraint System Known Paths

slide-22
SLIDE 22

unsigned GCD(x, y) { requires(y > 0); while (true) { unsigned m = x % y; if (m == 0) return y; x = y; y = m; } }

We want a trace where the loop is executed twice.

(y0 > 0) and (m0 = x0 % y0) and not (m0 = 0) and (x1 = y0) and (y1 = m0) and (m1 = x1 % y1) and (m1 = 0)

model

x0 = 2 y0 = 4 m0 = 2 x1 = 4 y1 = 2 m1 = 0

SSA

Assignment

slide-23
SLIDE 23
slide-24
SLIDE 24
slide-25
SLIDE 25
slide-26
SLIDE 26
slide-27
SLIDE 27

Apply DART to large applications (not units). Start with well-formed input (not random). Combine with generational search (not DFS).

Negate 1-by-1 each constraint in a path constraint. Generate many children for each parent run.

parent generation 1

slide-28
SLIDE 28

Starting with 100 zero bytes … SAGE generates a crashing test for Media1 parser

SMT@Microsoft

00000000h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000010h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000020h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000030h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000040h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000050h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000060h: 00 00 00 00 ; ....

Generation 0 – seed file

slide-29
SLIDE 29

Starting with 100 zero bytes … SAGE generates a crashing test for Media1 parser

SMT@Microsoft

00000000h: 52 49 46 46 00 00 00 00 00 00 00 00 00 00 00 00 ; RIFF............ 00000010h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000020h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000030h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000040h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000050h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000060h: 00 00 00 00 ; ....

Generation 1

slide-30
SLIDE 30

Starting with 100 zero bytes … SAGE generates a crashing test for Media1 parser

SMT@Microsoft

00000000h: 52 49 46 46 3D 00 00 00 ** ** ** 20 00 00 00 00 ; RIFF=...*** .... 00000010h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000020h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................ 00000030h: 00 00 00 00 73 74 72 68 00 00 00 00 76 69 64 73 ; ....strh....vids 00000040h: 00 00 00 00 73 74 72 66 B2 75 76 3A 28 00 00 00 ; ....strf²uv:(... 00000050h: 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 ; ................ 00000060h: 00 00 00 00 ; ....

Generation 10 – CRASH

slide-31
SLIDE 31

Formulas are usually big conjunctions. SAGE uses only the bitvector and array theories. Pre-processing step has a huge performance impact.

Eliminate variables. Simplify formulas.

Early unsat detection.

slide-32
SLIDE 32

Static program verifier (Boogie)

MSIL Z3 V.C. generator Verification condition “correct” or list of errors Spec# compiler Spec# C Bytecode translator C Boogie VCC HAVOC

slide-33
SLIDE 33

V C C

VCC translates an annotated C program into a Boogie PL program. A C-ish memory model

Abstract heaps Bit-level precision

Microsoft Hypervisor: verification grand challenge.

slide-34
SLIDE 34

Meta OS: small layer of software between hardware and OS Mini: 60K lines of non-trivial concurrent systems C code Critical: must provide functional resource abstraction Trusted: a verification grand challenge

Hardware Hypervisor

slide-35
SLIDE 35

VCs have several Mb Thousands of non ground clauses Developers are willing to wait at most 5 min per VC

slide-36
SLIDE 36

Model programs (M. Veanes – MSRR) Termination (B. Cook – MSRC) Security protocols (A. Gordon and C. Fournet - MSRC) Business Application Modeling (E. Jackson - MSRR) Cryptography (R. Venki – MSRR) Verifying Garbage Collectors (C. Hawblitzel – MSRR) Model Based Testing (L. Bruck – SQL) Semantic type checking for D models (G. Bierman – MSRC) More coming soon…

slide-37
SLIDE 37

Pex, Spec#, VCC and many other tools are available online.

slide-38
SLIDE 38
slide-39
SLIDE 39

Current SMT solvers provide a combination

  • f different engines
slide-40
SLIDE 40

DPLL Simplex Grobner Basis - elimination Superposition Simplification Congruence Closure KB Completion

SMT

slide-41
SLIDE 41

Theorem Prover/ Satisfiability Checker

F

Satisfiable (model) Unsatisfiable (proof) Config

Z3 has approx. 300

  • ptions
slide-42
SLIDE 42

Actual feedback provided by Z3 users:

“Could you send me your CNF converter?” “I want to implement my own search strategy.” “I want to include these rewriting rules in Z3.” “I want to apply a substitution to term t.” “I want to compute the set of implied equalities.”

slide-43
SLIDE 43

To build theoretical and practical tools allowing users to exert strategic control

  • ver core heuristic aspects of high

performance SMT solvers.

slide-44
SLIDE 44

Theorem proving as an exercise of combinatorial search Strategies are adaptations of general search mechanisms which reduce the search space by tailoring its exploration to a particular class of formulas.

slide-45
SLIDE 45

Different Strategies for Different Domains.

slide-46
SLIDE 46

Different Strategies for Different Domains.

From timeout to 0.05 secs…

slide-47
SLIDE 47

Hardware Fixpoint Checks. Given: and Ranking function synthesis.

Join work with C. Wintersteiger and Y. Hamadi FMCAD 2010

QBVF = Quantifiers + Bit-vectors + uninterpreted functions

slide-48
SLIDE 48
slide-49
SLIDE 49
slide-50
SLIDE 50

Z3 is using different engines: rewriting, simplification, model checking, SAT, … Z3 is using a customized strategy. We could do it because we have access to the source code.

slide-51
SLIDE 51

SMT solvers are collections of little engines. They should provide access to these engines. Users should be able to define their own strategies.

slide-52
SLIDE 52

Tactic goal subgoals Proof builder

slide-53
SLIDE 53

Proofs for subgoals Proof builder Proof for goal

Tactic

goal

subgoals

Proof builder

slide-54
SLIDE 54

Tactic

goal

Tactic Tactic

Proof builder Proof builder Proof builder

slide-55
SLIDE 55

Proof Builder

proof

Proof Builder Proof Builder

slide-56
SLIDE 56

Proof Builder

proof

Proof Builder Proof Builder

thm in LCF terminology proof in LCF terminology

slide-57
SLIDE 57

then( , ) =

Tactic Tactic Tactic

  • relse( , ) =

Tactic Tactic Tactic

repeat( ) =

Tactic Tactic

slide-58
SLIDE 58

Tactic goal subgoals Proof builder Model builder

slide-59
SLIDE 59
slide-60
SLIDE 60

end-game tactics: never return unknown(sb, mc, pc)

slide-61
SLIDE 61

non-branching tactics: sb is a sigleton in unknown(sb, mc, pc)

slide-62
SLIDE 62

Empty goal [ ] is trivially satisfiable False goal * …, false, …+ is trivially unsatisfiable basic : tactic

slide-63
SLIDE 63

Tactic: elim-vars Proof builder Model builder

slide-64
SLIDE 64

Tactic: elim-vars Proof builder Model builder M M, M(a) = M(b) + 1

slide-65
SLIDE 65

Tactic: split-or Proof builder Model builder

slide-66
SLIDE 66

simplify nnf cnf tseitin lift-if bitblast gb vts propagate-bounds propagate-values split-ineqs split-eqs rewrite p-cad sat solve-eqs

slide-67
SLIDE 67
slide-68
SLIDE 68
slide-69
SLIDE 69
slide-70
SLIDE 70

Probing structural features of formulas.

slide-71
SLIDE 71

diff logic? atom/dim < k no yes no yes simplex simplex floyd warshall

slide-72
SLIDE 72

Fail if condition is not satisfied. Otherwise, do nothing.

slide-73
SLIDE 73
slide-74
SLIDE 74
slide-75
SLIDE 75

Under-approximation unsat answers cannot be trusted Over-approximation sat answers cannot be trusted

slide-76
SLIDE 76

Under-approximation model finders Over-approximation proof finders

slide-77
SLIDE 77

Under-approximation S  S  S’ Over-approximation S  S \ S’

slide-78
SLIDE 78

Under-approximation Example: QF_NIA model finders add bounds to unbounded variables (and blast) Over-approximation Example: Boolean abstraction

slide-79
SLIDE 79

Combining under and over is bad! sat and unsat answers cannot be trusted.

slide-80
SLIDE 80

In principle, proof and model converters can check if the resultant models and proofs are valid.

slide-81
SLIDE 81

In principle, proof and model converters can check if the resultant models and proofs are valid. Problem: if it fails what do we do?

slide-82
SLIDE 82

In principle, proof and model converters can check if the resultant models and proofs are valid. Problem: if it fails what do we do? We want to write tactics that can check whether a goal is the result of an abstraction or not.

slide-83
SLIDE 83

Solution Associate an precision attribute to each goal.

slide-84
SLIDE 84

Store extra logical information Examples: precision markers goal depth polynomial factorizations

slide-85
SLIDE 85

Basic Idea

x  0, y = x + 1, (y > 2  y < 1) p1, p2, (p3  p4) Abstract (aka “naming” atoms) p1  (x  0), p2  (y = x + 1), p3  (y > 2), p4  (y < 1)

slide-86
SLIDE 86

Basic Idea

x  0, y = x + 1, (y > 2  y < 1) p1, p2, (p3  p4) Abstract (aka “naming” atoms) p1  (x  0), p2  (y = x + 1), p3  (y > 2), p4  (y < 1) SAT Solver

slide-87
SLIDE 87

Basic Idea

x  0, y = x + 1, (y > 2  y < 1) p1, p2, (p3  p4) Abstract (aka “naming” atoms) p1  (x  0), p2  (y = x + 1), p3  (y > 2), p4  (y < 1) SAT Solver Assignment p1, p2, p3, p4

slide-88
SLIDE 88

Basic Idea

x  0, y = x + 1, (y > 2  y < 1) p1, p2, (p3  p4) Abstract (aka “naming” atoms) p1  (x  0), p2  (y = x + 1), p3  (y > 2), p4  (y < 1) SAT Solver Assignment p1, p2, p3, p4 x  0, y = x + 1,

  • (y > 2), y < 1
slide-89
SLIDE 89

Basic Idea

x  0, y = x + 1, (y > 2  y < 1) p1, p2, (p3  p4) Abstract (aka “naming” atoms) p1  (x  0), p2  (y = x + 1), p3  (y > 2), p4  (y < 1) SAT Solver Assignment p1, p2, p3, p4 x  0, y = x + 1,

  • (y > 2), y < 1

Theory Solver Unsatisfiable x  0, y = x + 1, y < 1

slide-90
SLIDE 90

Basic Idea

x  0, y = x + 1, (y > 2  y < 1) p1, p2, (p3  p4) Abstract (aka “naming” atoms) p1  (x  0), p2  (y = x + 1), p3  (y > 2), p4  (y < 1) SAT Solver Assignment p1, p2, p3, p4 x  0, y = x + 1,

  • (y > 2), y < 1

Theory Solver Unsatisfiable x  0, y = x + 1, y < 1 New Lemma

  • p1p2p4
slide-91
SLIDE 91

Theory Solver Unsatisfiable x  0, y = x + 1, y < 1 New Lemma

  • p1p2p4

AKA Theory conflict

slide-92
SLIDE 92

Apply “cheap” propagation/pruning steps; and then apply complete “expensive” procedure

slide-93
SLIDE 93

AP-CAD ( tactic ) = tactic

slide-94
SLIDE 94
slide-95
SLIDE 95
slide-96
SLIDE 96

Simplification Constant propagation Interval propagation Contextual simplification If-then-else elimination Gaussian elimination Unconstrained terms

slide-97
SLIDE 97

proof procedure as a transition system Abstract DPLL, DPLL(T), Abstract GB, cutsat, …

slide-98
SLIDE 98

proof procedure as a transition system Abstract DPLL, DPLL(T), Abstract GB, cutsat, …

Challenge: Efficient strategic control

slide-99
SLIDE 99

Different domains need different strategies. We must expose the little engines in SMT solvers. Interaction between different engines is a must. Tactic and Tacticals: big step approach. More transparency.