CBMC: Bounded Model Checking for ANSI-C Version 1.0, 2010 Outline - - PowerPoint PPT Presentation

cbmc bounded model checking for ansi c
SMART_READER_LITE
LIVE PREVIEW

CBMC: Bounded Model Checking for ANSI-C Version 1.0, 2010 Outline - - PowerPoint PPT Presentation

CBMC: Bounded Model Checking for ANSI-C Version 1.0, 2010 Outline Preliminaries BMC Basics Completeness Solving the Decision Problem CBMC: Bounded Model Checking for ANSI-C http://www.cprover.org/ 2 Preliminaries We aim at the


slide-1
SLIDE 1

CBMC: Bounded Model Checking for ANSI-C

Version 1.0, 2010

slide-2
SLIDE 2

Outline

Preliminaries BMC Basics Completeness Solving the Decision Problem

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 2

slide-3
SLIDE 3

Preliminaries

◮ We aim at the analysis of programs given in a commodity

programming language such as C, C++, or Java

◮ As the first step, we transform the program into a control

flow graph (CFG)

C/C++ Source parse tree parse frontend CFG

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 3

slide-4
SLIDE 4

Example: SHS

if ( (0 <= t) && (t <= 79) ) switch ( t / 20 ) { case 0: TEMP2 = ( (B AND C) OR (˜B AND D) ); TEMP3 = ( K 1 ); break; case 1: TEMP2 = ( (B XOR C XOR D) ); TEMP3 = ( K 2 ); break; case 2: TEMP2 = ( (B AND C) OR (B AND D) OR (C AND D) ); TEMP3 = ( K 3 ); break; case 3: TEMP2 = ( B XOR C XOR D ); TEMP3 = ( K 4 ); break; default: assert(0); } CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 4

slide-5
SLIDE 5

Example: SHS

if ( (0 <= t) && (t <= 79) ) switch ( t / 20 ) { case 0: TEMP2 = ( (B AND C) OR (˜B AND D) ); TEMP3 = ( K 1 ); break; case 1: TEMP2 = ( (B XOR C XOR D) ); TEMP3 = ( K 2 ); break; case 2: TEMP2 = ( (B AND C) OR (B AND D) OR (C AND D) ); TEMP3 = ( K 3 ); break; case 3: TEMP2 = ( B XOR C XOR D ); TEMP3 = ( K 4 ); break; default: assert(0); }

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 4

slide-6
SLIDE 6

Bounded Program Analysis

Goal: check properties of the form AGp, say assertions. Idea: follow paths through the CFG to an assertion, and build a formula that corresponds to the path

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 5

slide-7
SLIDE 7

Example

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 6

slide-8
SLIDE 8

Example

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 6

slide-9
SLIDE 9

Example

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

0 ≤ t ≤ 79 ∧ t/20 = 0 ∧ t/20 = 1 ∧ TEMP2 = B ⊕ C ⊕ D ∧ TEMP3 = K 2

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 6

slide-10
SLIDE 10

Example

We pass 0 ≤ t ≤ 79 ∧ t/20 = 0 ∧ t/20 = 1 ∧ TEMP2 = B ⊕ C ⊕ D ∧ TEMP3 = K 2 to a decision procedure, and obtain a satisfying assignment, say: t → 21, B → 0, C → 0, D → 0, K 2 → 10, TEMP2 → 0, TEMP3 → 10 ✔ It provides the values of any inputs on the path.

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 7

slide-11
SLIDE 11

Which Decision Procedures?

◮ We need a decision procedure for an appropriate logic

◮ Bit-vector logic (incl. non-linear arithmetic) ◮ Arrays ◮ Higher-level programming languages also feature

lists, sets, and maps

◮ Examples

◮ Z3 (Microsoft) ◮ Yices (SRI) ◮ Boolector CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 8

slide-12
SLIDE 12

Enabling Technology: SAT

1960 1970 1980 1990 2000 2010 1,000,000 100,000 10,000 1,000 100 10

number of variables of a typical, practical SAT instance that can be solved by the best solvers in that decade

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 9

slide-13
SLIDE 13

Enabling Technology: SAT

◮ propositional SAT solvers have made enourmous progress

in the last 10 years

◮ Further scalability improvements in recent years because

  • f efficient word-level reasoning and array decision

procedures

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 10

slide-14
SLIDE 14

Let’s Look at Another Path

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 11

slide-15
SLIDE 15

Let’s Look at Another Path

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 11

slide-16
SLIDE 16

Let’s Look at Another Path

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

0 ≤ t ≤ 79 ∧ t/20 = 0 ∧ t/20 = 1 ∧ t/20 = 2 ∧ t/20 = 3

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 11

slide-17
SLIDE 17

Let’s Look at Another Path

if switch case0 case1 case2 case3 default 0 ≤ t ≤ 79 t/20 = 0 t/20 = 1 t/20 = 2 t/20 = 3

0 ≤ t ≤ 79 ∧ t/20 = 0 ∧ t/20 = 1 ∧ t/20 = 2 ∧ t/20 = 3 That is UNSAT, so the assertion is unreachable.

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 11

slide-18
SLIDE 18

What If a Variable is Assigned Twice?

x=0; if(y>=0) x++; Rename appropriately: x = 0 ∧ y ≥ 0 ∧ x = x + 1

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 12

slide-19
SLIDE 19

What If a Variable is Assigned Twice?

x=0; if(y>=0) x++; Rename appropriately: x1 = 0 ∧ y0 ≥ 0 ∧ x1 = x0 + 1 This is a special case of SSA (static single assignment)

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 12

slide-20
SLIDE 20

Pointers

How do we handle dereferencing in the program?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 13

slide-21
SLIDE 21

Pointers

How do we handle dereferencing in the program? int ∗p; p=malloc(sizeof(int)∗5); ... p[1]=100; p1 = &DO1 ∧ DO1 1 = (λi. i = 1?100 : DO1 0[i]) Track a ‘may-point-to’ abstract state while simulating!

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 13

slide-22
SLIDE 22

Scalability of Path Search

Let’s consider the following CFG:

L1 L2 L3 L4

This is a loop with an if inside.

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 14

slide-23
SLIDE 23

Scalability of Path Search

Let’s consider the following CFG:

L1 L2 L3 L4

This is a loop with an if inside. Q: how many paths for n iterations?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 14

slide-24
SLIDE 24

Bounded Model Checking

◮ Bounded Model Checking (BMC) is the most successful

formal validation technique in the hardware industry

◮ Advantages:

✔ Fully automatic ✔ Robust ✔ Lots of subtle bugs found

◮ Idea: only look for bugs up to specific depth ◮ Good for many applications, e.g., embedded systems

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 15

slide-25
SLIDE 25

Transition Systems

Definition: A transition system is a triple (S, S0, T) with

◮ set of states S, ◮ a set of initial states S0 ⊂ S, and ◮ a transition relation T ⊂ (S × S).

The set S0 and the relation T can be written as their characteristic functions.

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 16

slide-26
SLIDE 26

Unwinding a Transition System

Q: How do we avoid the exponential path explosion? We just ”concatenate” the transition relation T:

t S0

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 17

slide-27
SLIDE 27

Unwinding a Transition System

Q: How do we avoid the exponential path explosion? We just ”concatenate” the transition relation T:

t S0 ✲ ∧ T t

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 17

slide-28
SLIDE 28

Unwinding a Transition System

Q: How do we avoid the exponential path explosion? We just ”concatenate” the transition relation T:

t S0 ✲ ∧ T t ∧ T ✲ t

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 17

slide-29
SLIDE 29

Unwinding a Transition System

Q: How do we avoid the exponential path explosion? We just ”concatenate” the transition relation T:

t S0 ✲ ∧ T t ∧ T ✲ t . . . ∧ t ✲ T ∧ t

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 17

slide-30
SLIDE 30

Unwinding a Transition System

Q: How do we avoid the exponential path explosion? We just ”concatenate” the transition relation T:

t S0 ✲ ∧ T t ∧ T ✲ t . . . ∧ t ✲ T ∧ t s0 s1 s2 sk−1 sk

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 17

slide-31
SLIDE 31

Unwinding a Transition System

As formula: S0(s0) ∧

k−1

  • i=0

T(si, si+1) Satisfying assignments for this formula are traces through the transition system

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 18

slide-32
SLIDE 32

Example

T ⊆ N0 × N0 T(s, s′) ⇐ ⇒ s′.x = s.x + 1 . . . and let S0(s) ⇐ ⇒ s.x = 0 ∨ s.x = 1

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 19

slide-33
SLIDE 33

Example

T ⊆ N0 × N0 T(s, s′) ⇐ ⇒ s′.x = s.x + 1 . . . and let S0(s) ⇐ ⇒ s.x = 0 ∨ s.x = 1 An unwinding for depth 4: (s0.x = 0 ∨ s0.x = 1) ∧ s1.x = s0.x + 1 ∧ s2.x = s1.x + 1 ∧ s3.x = s2.x + 1 ∧ s4.x = s3.x + 1

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 19

slide-34
SLIDE 34

Checking Reachability Properties

Suppose we want to check a property of the form AGp.

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 20

slide-35
SLIDE 35

Checking Reachability Properties

Suppose we want to check a property of the form AGp. We then want at least one state si to satisfy ¬p: S0(s0) ∧

k−1

  • i=0

T(si, si+1) ∧

k

  • i=0

¬p(si) Satisfying assignments are counterexamples for the AGp property

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 20

slide-36
SLIDE 36

Unwinding Software

We can do exactly that for our transition relation for software. E.g., for a program with 5 locations, 6 unwindings:

L1 L2 L3 L4 L5 #6 L1 L2 L3 L4 L5 #5 L1 L2 L3 L4 L5 #4 L1 L2 L3 L4 L5 #3 L1 L2 L3 L4 L5 #2 L1 L2 L3 L4 L5 #1 L1 L2 L3 L4 L5 #0

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 21

slide-37
SLIDE 37

Unwinding Software

Problem: obviously, most of the formula is never ’used’, as only few sequences of PCs correspond to a path.

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 22

slide-38
SLIDE 38

Unwinding Software

Example:

L1 L2 L3 L4 L5

CFG

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 23

slide-39
SLIDE 39

Unwinding Software

Example:

L1 L2 L3 L4 L5

L1 L2 L3 L4 L5 #6 L1 L2 L3 L4 L5 #5 L1 L2 L3 L4 L5 #4 L1 L2 L3 L4 L5 #3 L1 L2 L3 L4 L5 #2 L1 L2 L3 L4 L5 #1 L1 L2 L3 L4 L5 #0

CFG unrolling

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 23

slide-40
SLIDE 40

Unwinding Software

Optimization: don’t generate the parts of the formula that are not ’reachable’

L1 L2 L3 L4 L5

CFG

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 24

slide-41
SLIDE 41

Unwinding Software

Optimization: don’t generate the parts of the formula that are not ’reachable’

L1 L2 L3 L4 L5

L1 L2 L3 L4 L5 #6 L1 L2 L3 L4 L5 #5 L1 L2 L3 L4 L5 #4 L1 L2 L3 L4 L5 #3 L1 L2 L3 L4 L5 #2 L1 L2 L3 L4 L5 #1 L1 L2 L3 L4 L5 #0 L1 L2 L4 L3 L5 L2 L4 L3 L5 L2 L4 L3 L5

CFG unrolling

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 24

slide-42
SLIDE 42

Unwinding Software

Problem:

L1 L2 L3 L4 L5

L1 L2 L3 L4 L5 #6 L1 L2 L3 L4 L5 #5 L1 L2 L3 L4 L5 #4 L1 L2 L3 L4 L5 #3 L1 L2 L3 L4 L5 #2 L1 L2 L3 L4 L5 #1 L1 L2 L3 L4 L5 #0 L1 L2 L3 L4 L5 L2 L3 L4 L5 L2 L3 L4 L5 L2 L3 L4 L2 L3 L2

CFG unrolling

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 25

slide-43
SLIDE 43

Unwinding Software

◮ Unwinding T with bound k results in a formula of size

|T| · k

◮ If we assume a k that is only linear in |T|,

we get get a formula with size O(|T|2)

◮ Can we do better?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 26

slide-44
SLIDE 44

Unrolling Loops

Idea: do exactly one location in each timeframe:

L1 L2 L3 L4 L5

CFG

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 27

slide-45
SLIDE 45

Unrolling Loops

Idea: do exactly one location in each timeframe:

L1 L2 L3 L4 L5

#6 #5 #4 #3 #2 #1 #0 L1 L2 L3 L2 L3 L4 L5

CFG unrolling

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 27

slide-46
SLIDE 46

Unrolling Loops

✔ More effective use of the formula size ✔ Graph has fewer merge nodes, the formula is easier for the solvers ✘ Not all paths of length k are encoded → the bound needs to be larger

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 28

slide-47
SLIDE 47

Unrolling Loops

This essentially amounts to unwinding loops: while(cond) Body;

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 29

slide-48
SLIDE 48

Unrolling Loops

This essentially amounts to unwinding loops: if(cond) { Body; while(cond) Body; }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 29

slide-49
SLIDE 49

Unrolling Loops

This essentially amounts to unwinding loops: if(cond) { Body; if(cond) { Body; while(cond) Body; } }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 29

slide-50
SLIDE 50

Unrolling Loops

This essentially amounts to unwinding loops: if(cond) { Body; if(cond) { Body; if(cond) { Body; while(cond) Body; } } }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 29

slide-51
SLIDE 51

Unrolling Loops

This essentially amounts to unwinding loops: if(cond) { Body; if(cond) { Body; if(cond) { Body; assume(!cond); } } }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 29

slide-52
SLIDE 52

Completeness

BMC, as discussed so far, is incomplete. It only refutes, and does not prove. How can we fix this?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 30

slide-53
SLIDE 53

Unwinding Assertions

Let’s revisit the loop unwinding idea: while(cond) Body;

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 31

slide-54
SLIDE 54

Unwinding Assertions

Let’s revisit the loop unwinding idea: if(cond) { Body; while(cond) Body; }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 31

slide-55
SLIDE 55

Unwinding Assertions

Let’s revisit the loop unwinding idea: if(cond) { Body; if(cond) { Body; while(cond) Body; } }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 31

slide-56
SLIDE 56

Unwinding Assertions

Let’s revisit the loop unwinding idea: if(cond) { Body; if(cond) { Body; if(cond) { Body; while(cond) Body; } } }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 31

slide-57
SLIDE 57

Unwinding Assertions

Let’s revisit the loop unwinding idea: if(cond) { Body; if(cond) { Body; if(cond) { Body; assert(!cond); } } }

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 31

slide-58
SLIDE 58

Unwinding Assertions

◮ We replace the assumption we have used earlier to cut off

paths by an assertion ✔ This allows us to prove that we have done enough unwinding

◮ This is a proof of a high-level worst-case execution time

(WCET)

◮ Very appropriate for embedded software

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 32

slide-59
SLIDE 59

CBMC Toolflow: Summary

  • 1. Parse, build CFG
  • 2. Unwind CFG, form formula
  • 3. Formula is solved by SAT/SMT

wind Source parse formula flattening CNF AUFBV C/C++ parse SMT frontend CFG un- tree

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 33

slide-60
SLIDE 60

Solving the Decision Problem

Suppose we have used some unwinding, and have built the formula. For bit-vector arithmetic, the standard way of deciding satisfiability of the formula is flattening, followed by a call to a propositional SAT solver. In the SMT context: SMT-BV

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 34

slide-61
SLIDE 61

Bit-vector Flattening

◮ This is easy for the bit-wise operators. ◮ Denote the Boolean variable for bit i of term t by µ(t)i. ◮ Example for a |[l] b: l−1

  • i=0

(µ(t)i = (ai ∨ bi)) (read x = y over bits as x ⇐ ⇒ y)

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 35

slide-62
SLIDE 62

Bit-vector Flattening

◮ This is easy for the bit-wise operators. ◮ Denote the Boolean variable for bit i of term t by µ(t)i. ◮ Example for a |[l] b: l−1

  • i=0

(µ(t)i = (ai ∨ bi)) (read x = y over bits as x ⇐ ⇒ y)

◮ We can transform this into CNF using Tseitin’s method.

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 35

slide-63
SLIDE 63

Flattening Bit-Vector Arithmetic

How to flatten a + b?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 36

slide-64
SLIDE 64

Flattening Bit-Vector Arithmetic

How to flatten a + b? − → we can build a circuit that adds them!

FA

i b a s

  • Full Adder

s ≡ (a + b + i ) mod 2 ≡ a ⊕ b ⊕ i

(a + b + i ) div 2 ≡ a · b + a · i + b · i The full adder in CNF: (a ∨ b ∨ ¬o) ∧ (a ∨ ¬b ∨ i ∨ ¬o) ∧ (a ∨ ¬b ∨ ¬i ∨ o)∧ (¬a ∨ b ∨ i ∨ ¬o) ∧ (¬a ∨ b ∨ ¬i ∨ o) ∧ (¬a ∨ ¬b ∨ o)

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 36

slide-65
SLIDE 65

Flattening Bit-Vector Arithmetic

Ok, this is good for one bit! How about more?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 37

slide-66
SLIDE 66

Flattening Bit-Vector Arithmetic

Ok, this is good for one bit! How about more?

8-Bit ripple carry adder (RCA)

i

FA FA FA FA FA FA FA FA

a7b7 a6b6 a5b5 a4b4 a3b3 a2b2 a1b1 a0b0

  • s7

s6 s5 s4 s3 s2 s1 s0

◮ Also called carry chain adder ◮ Adds l variables ◮ Adds 6 · l clauses

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 37

slide-67
SLIDE 67

Multipliers

◮ Multipliers result in very hard formulas ◮ Example:

a · b = c ∧ b · a = c ∧ x < y ∧ x > y CNF: About 11000 variables, unsolvable for current SAT solvers

◮ Similar problems with division, modulo ◮ Q: Why is this hard?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 38

slide-68
SLIDE 68

Multipliers

◮ Multipliers result in very hard formulas ◮ Example:

a · b = c ∧ b · a = c ∧ x < y ∧ x > y CNF: About 11000 variables, unsolvable for current SAT solvers

◮ Similar problems with division, modulo ◮ Q: Why is this hard? ◮ Q: How do we fix this?

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 38

slide-69
SLIDE 69

Incremental Flattening

ϕf := ϕsk, F := ∅ ϕsk: Boolean part of ϕ F: set of terms that are in the encoding

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 39

slide-70
SLIDE 70

Incremental Flattening

ϕf := ϕsk, F := ∅

Is ϕf SAT? ϕsk: Boolean part of ϕ F: set of terms that are in the encoding

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 39

slide-71
SLIDE 71

Incremental Flattening

ϕf := ϕsk, F := ∅

Is ϕf SAT?

No! UNSAT ϕsk: Boolean part of ϕ F: set of terms that are in the encoding

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 39

slide-72
SLIDE 72

Incremental Flattening

ϕf := ϕsk, F := ∅

Is ϕf SAT?

No! UNSAT

Yes! compute I ϕsk: Boolean part of ϕ F: set of terms that are in the encoding I: set of terms that are inconsistent with the current assignment

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 39

slide-73
SLIDE 73

Incremental Flattening

ϕf := ϕsk, F := ∅

Is ϕf SAT?

No! UNSAT

Yes! compute I

I = ∅ SAT ϕsk: Boolean part of ϕ F: set of terms that are in the encoding I: set of terms that are inconsistent with the current assignment

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 39

slide-74
SLIDE 74

Incremental Flattening

ϕf := ϕsk, F := ∅

Is ϕf SAT?

No! UNSAT

Yes! compute I

I = ∅ SAT

I = ∅ Pick F ′ ⊆ (I \ F) F := F ∪ F ′ ϕf := ϕf ∧ CONSTRAINT(F)

ϕsk: Boolean part of ϕ F: set of terms that are in the encoding I: set of terms that are inconsistent with the current assignment

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 39

slide-75
SLIDE 75

Incremental Flattening

◮ Idea: add ’easy’ parts of the formula first ◮ Only add hard parts when needed ◮ ϕf only gets stronger – use an incremental SAT solver

CBMC: Bounded Model Checking for ANSI-C – http://www.cprover.org/ 40