Download presentation

Presentation is loading. Please wait.

Published byGabriella Fuller Modified over 3 years ago

1
SAT, Interpolants and Software Model Checking Ken McMillan Cadence Berkeley Labs

2
Applications of SAT solvers BMC of programs using SAT (e.g., CBMC) SAT solvers in decision procedures –Eager approach (e.g., UCLID) –Lazy approach (Verifun, ICS, many others) SAT-based image computation –Applied to predicate abstraction (Lahiri, et al)... We will consider instead the lessons learned from solving SAT that can be applied to software verification. SAT solvers have been applied in many ways in software verification

3
Outline SAT solvers –How do they work –What general lessons can we learn from the experience Software model checking survey –How various methods do or do not embody lessons from SAT A modest proposal –An attempt to apply the lessons of SAT to software verification

4
SAT solvers Solvers charactized by –Exhaustive BCP –Conflict-driven learning (resolution) –Deduction-based decision heuristics DPLL DPDLL variable elimination backtrack search SATO, GRASP,CHAFF,etc

5
Lesson #1: Be Lazy DP approach –Eliminate variables by exhaustive resolution –Extremely eager: deduces all facts about remaining variables –Essentially quantifier elimination -- explodes. DPLL approach –Lazy: only resolves clauses when model search fails –Resolution use as a form of failure generalization Learns general facts from model search failure Implications: 1. Make expensive deductions only when their relevance can be justified. 2.Don't do quantifier elimination.

6
Lesson #2: Be Eager In a DPLL solver, we always close deduction under unit resolution (BCP) before making a decision. –Guides decision making model search –Guides resolution steps in failure generalization –BCP updated after decision making and clause learning Implications: 1.Be eager with inexpensive deduction. 2.Deduce all the cheap facts before trying any expensive ones. 3.Let the expensive deduction drive the cheap deduction

7
Lesson #3: Learn from the Past Facts useful in one particular case are likely to be useful in other cases. This principle is embodied in –Clause learning –Deduction-based decision heuristics (e.g., VSIDS) Implication: Deduce facts that have been useful in the past.

8
Static Analysis Compute the least fixed-point of an abstract transformer –This is the strongest invariant the analysis can provide Inexpensive analyses: –value set analysis –affine equalities, etc. These analyses lose information at a merge: x = y x = z T Be eager with inexpensive deductions Be lazy with expensive deductionsX Learn from the pastN/A

9
Predicate abstraction Abstract transformer: –strongest Boolean postcondition over given predicates Advantage: does not lose information at a merge –join is disjunction x = y x = z x=y Ç x=z Disadvantage: –Abstract post is very expensive! –Computes information about predicates with no relevance justification Be eager with inexpensive deductionsX Be lazy with expensive deductionsX Learn from the pastN/A

10
PA with CEGAR loop Model check abstraction T # Choose initial T # Can extend Cex from T # to T? Add predicates to T # true, done Cex yes, Cex no Choose predicates to refute cex's –Generalizes failures –Some relevance justification Still performs expensive deduction without justification –strongest Boolean postcondition Fails to learn from past –Start fresh each iteration –Forgets expensive deductions Be eager with inexpensive deductionsX Be lazy with expensive deductionsX+ Learn from the pastX

11
Boolean Programs Abstract transformer –Weaker than predicate abstraction –Evaluates predicates independently -- loses correlations {T} x=y; {x=0, y=0} Predicate abstraction {T} x=y; {T} Boolean programs Advantages –Computes less expensive information eagerly –Disadvantages –Still computes expensive information without justification –Still uses CEGAR loop Be eager with inexpensive deductionsX Be lazy with expensive deductionsX++ Learn from the pastX

12
Lazy Predicate Abstraction Unwind the program CFG into a tree –Refine paths as needed to refute errors ERR! x=y y=0 Add predicates along path to allow refutation of error Refinement is local to an error path Search continues after refinement –Do not start fresh -- no big CEGAR loop Previously useful predicates applied to new vertices

13
Lazy Predicate Abstraction ERR! x=y y=0 Add predicates along path to allow refutation of error Refinement is local to an error path Search continues after refinement –Do not start fresh -- no big CEGAR loop Previously useful predicates applied to new vertices Be eager with inexpensive deductionsX Be lazy with expensive deductions - Learn from the past

14
SAT-based BMC Inherits all the properties of SAT Deduction limited to propositional logic –Cannot directly infer facts like x · y –Inexpensive deduction limited to BCP Program Loop Unwinding Convert to Bit Level SAT Be eager with inexpensive deductions -- Be lazy with expensive deductions Learn from the past

15
SAT-based with Static Analysis Allows richer class of inexpensive deductions Inexpensive deductions not updated after decisions and clause learning – Coupling could be tighter –Perhaps using lazy decision procedures? Program Loop Unwinding Convert to Bit Level SAT Static Analysis x=y;x=z; x=z decision Be eager with inexpensive deductions - Be lazy with expensive deductions Learn from the past

16
Lazy abstraction and interpolants A way to apply the lessons of SAT to lazy abstraction Keep the advantages of lazy abstraction... –Local refinement (be lazy) –No "big loop" as in CEGAR (learn from the past)...while avoiding the disadvantages of predicate abstraction... –no eager image computation...and propagating inexpensive deductions eagerly –as in static analysis

17
Interpolation Lemma Notation: L ( ) is the set of FO formulas over the symbols of If A B = false, there exists an interpolant A' for (A,B) such that: A A' A' B = false A' 2 L (A) Å L (B) Example: –A = p q, B = q r, A' = q Interpolants from proofs –in certain quantifier-free theories, we can obtain an interpolant for a pair A,B from a refutation in linear time. [McMillan 05] –in particular, we can have linear arithmetic,uninterpreted functions, and restricted use of arrays (Craig,57)

18
Interpolants for sequences Let A 1...A n be a sequence of formulas A sequence A 0...A n is an interpolant for A 1...A n when –A 0 = True –A i -1 Æ A i ) A i, for i = 1..n –A n = False –and finally, A i 2 L (A 1...A i ) Å L (A i+1...A n ) A1A1 A2A2 A3A3 AkAk... A' 1 A' 2 A' 3 A' k-1... TrueFalse )))) In other words, the interpolant is a structured refutation of A 1...A n

19
Interpolants as Floyd-Hoare proofs False x 1 =y 0 True y 1 >x 1 ) ) ) 1. Each formula implies the next 2. Each is over common symbols of prefix and suffix 3. Begins with true, ends with false Path refinement procedure SSA sequence Prover Interpolation Path Refinement proof structured proof x=y; y++; [x=y] x 1 = y 0 y 1 =y 0 +1 x 1 y 1

20
Lazy abstraction -- an example do{ lock(); old = new; if(*){ unlock; new++; } } while (new != old); program fragment L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph

21
1 L=0 T 2 [L!=0] T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 T F L=0 Label error state with false, by refining labels on path

22
6 [L!=0] T 5 [new!=old] T 4 L=0; new++ T 3 L=1; old=new T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 L=0 [L!=0] F L=0 F T Covering: state 5 is subsumed by state 1.

23
T 11 [L!=0] T 10 [new!=old] T 8 T Unwinding the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] control-flow graph 0 12 3 4 5 L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T old=new F F T Another cover. Unwinding is now complete. 9 T

24
Covering step If (x) ) (y)... –add covering arc x B y –remove all z B w for w descendant of y x · y x=y X We restict covers to be descending in a suitable total order on vertices. This prevents covering from diverging.

25
Refinement step Label an error vertex False by refining the path to that vertex with an interpolant for that path. By refining with interpolants, we avoid predicate image computation. T T T T T T T x = 0 [x=y] [x y] y++ [y=0] y=2 x=0 y=0 y 0 F X Refinement may remove covers

26
Forced cover Try to refine a sub-path to force a cover –show that path from nearest common ancestor of x,y proves (x) at y T T T T T T T x = 0 [x=y] [x y] y++ [y=0] y=2 x=0 y=0 y 0 F refine this path y 0 Forced cover allow us to efficiently handle nested control structure

27
T [x=z] [x z] y=1 y=2 y 2 {1,2} [y=1 Æ x z] Incremental static analysis Update static analysis of unwinding incrementally –Static analysis can prevent many interpolant-based refinements –Interpolant-based refinements can refine static analysis T T T T T T T x = 0 [x=y] [x y] y++ [y=0] y=2 x=0 y=0 y 0 F y=2 from value set analysis x=z F refine this path y=2 value set refined

28
Applying the lessons from SAT Be lazy with epensive deductions –All path refinements justified –No eager predicate image computation Be eager with inexpensive deductions –Static anlalysis updated after all changes –Refinement and static analysis interact Learn from the past – Refinements incremental – no big CEGAR loop – Re-use of historically useful facts by forced covering

29
Experiments Windows device driver benchmarks from BLAST benchmark suite –programs flattened to "simple goto programs" Compare performance against BLAST, a lazy predicate abstraction tool No static analysis. namesource LOC SGP LOC BLAST (s) IMPACT (s) BLAST IMPACT kbfiltr12K2.3K26.33.158.3 diskperf14K3.9K10220.05.1 cdaudio44K6.3K31019.116.2 floppy18K8.7K45517.825.6 parclass138K8.8K551126.2210 parport61K13K808437.1224 Almost all BLAST time spent in predicate image operation.

30
The Saga Continues After these results, Ranjit Jhala modified BLAST –vertices inherit predicates from their parents, reducing refinements –fewer refinements allows more predicate localization Impact also made more eager, using value set analysis namesource LOC SGP LOC BLAST (s) IMPACT (s) BLAST IMPACT kbfiltr12K2.3K11.90.3534 diskperf14K3.9K1172.3749 cdaudio44K6.3K2021.51134 floppy18K8.7K1644.0941 parclass138K8.8K4633.84121 parport61K13K3246.4750

31
Conclusions Caveats –Comparing different implementations is dangerous –More and better software model checking benchmarks are needed Tentative conclusions –For control-dominated codes, predicate abstraction is too "eager better to be more lazy about expensive deductions –Propagate inexpensive deductions can produce substantial speedup roughly one order of magnitude for Windows examples –Perhaps by applying the lessons of SAT, we can obtain the same kind of rapid performance improvements obtained in that area Note 2-3 orders of magnitude speedup in lazy model checking in 6 months!

32
Future work Procedure summaries –Many similar subgraphs in unwinding due to procedure expansions –Cannot handle recursion –Can we use interpolants to compute approximate procedure summaries? Quantified interpolants –Can be used to generate program invariants with quantifiers –Works for simple examples, but need to prevent number of quantifiers from increasing without bound Richer theories –In this work, all program variables modeled by integers –Need an interpolating prover for bit vector theory Concurrency...

33
Unwinding the CFG An unwinding is a tree with an embedding in the CFG L=0 L=1; old=new [L!=0] L=0; new++ [new==old] [new!=old] 8 0 12 3 4 L=0 L=1; old=new [L!=0] L=0; new++ MvMv MeMe

34
Expansion Every non-leaf vertex of the unwinding must be fully expanded... L=0 0 1 MvMv MeMe If this is not a leaf......and this exists......then this exists....but we allow unexpanded leaves (i.e., we are building a finite prefix of the infinite unwinding)

35
Labeled unwinding A labeled unwinding is equiped with... –a lableing function : V ! L (S) –a covering relation B µ V £ V 0 12 3 4 5 L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] 6 [L!=0] 7 [new==old] T F L=0 F T T These two nodes are covered. (have a ancestor at the tail of a covering arc)...

36
Well-labeled unwinding An unwinding is well-labeled when... – ( ) = True –every edge is a valid Hoare triple –if x B y then y not covered 0 12 3 4 5 L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] 6 [L!=0] 7 [new==old] T F L=0 F T T

37
Safe and complete An unwinding is –safe if every error vertex is labeled False –complete if every nonterminal leaf is covered T 10 [L!=0] T 9 [new!=old] T 8 T 0 12 3 4 5 L=0 L=1; old=new [L!=0] L=0; new++ [new!=old] F L=0 6 [L!=0] F L=0 7 [new==old] T old=new F F T... Theorem: A CFG with a safe complete unwinding is safe. 9 T

38
Unwinding steps Three basic operations: –Expand a nonterminal leaf –Cover: add a covering arc –Refine: strengthen labels along a path so error vertex labeled False

39
Overall algorithm 1.Do as much covering as possible 2.If a leaf can't be covered, try forced covering 3.If the leaf still can't be covered, expand it 4.Label all error states False by refining with an interpolant 5.Continue until unwinding is safe and complete

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google