a unifying view on smt-based software verification · 2018-11-29 · predicatecpa predicate cpa p d...

108
A Unifying View on SMT-Based Software Verification Dirk Beyer Joint work with Matthias Dangl and Philipp Wendler LMU Munich, Germany Dirk Beyer LMU Munich, Germany 1 / 63

Upload: others

Post on 27-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

A Unifying Viewon SMT-Based Software Verification

Dirk BeyerJoint work with Matthias Dangl and Philipp Wendler

LMU Munich, Germany

Dirk Beyer LMU Munich, Germany 1 / 63

Page 2: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Based on:Dirk Beyer, Matthias Dangl, Philipp Wendler:A Unifying View on SMT-Based Software Verification

Journal of Automated Reasoning, Volume 60, Issue 3, 2018.https://doi.org/10.1007/s10817-017-9432-6preprint: online on CPAchecker website under“Documentation”

Dirk Beyer LMU Munich, Germany 2 / 63

Page 3: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

SMT-based Software Model Checking

I Predicate Abstraction(Blast, CPAchecker, Slam, ...)

I Impact(CPAchecker, Impact, Wolverine, ...)

I Bounded Model Checking(Cbmc, CPAchecker, Esbmc, ...)

I k-Induction(CPAchecker, Esbmc, 2ls, ...)

Dirk Beyer LMU Munich, Germany 3 / 63

Page 4: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Motivation

I Theoretical comparison difficult:I different conceptual optimizations

(e.g., large-block encoding)I different presentation→ What are their core concepts and key differences?

I Experimental comparison difficult:I implemented in different toolsI different technical optimizations (e.g., data structures)I different front-end and utility codeI different SMT solver→ Where do performance differences actually come from?

Dirk Beyer LMU Munich, Germany 4 / 63

Page 5: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Motivation

I Theoretical comparison difficult:I different conceptual optimizations

(e.g., large-block encoding)I different presentation→ What are their core concepts and key differences?

I Experimental comparison difficult:I implemented in different toolsI different technical optimizations (e.g., data structures)I different front-end and utility codeI different SMT solver→ Where do performance differences actually come from?

Dirk Beyer LMU Munich, Germany 4 / 63

Page 6: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Goals

I Provide a unifying framework for SMT-based algorithmsI Understand differences and key concepts of algorithmsI Determine potential of extensions and combinationsI Provide solid platform for experimental research

Dirk Beyer LMU Munich, Germany 5 / 63

Page 7: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Approach

I Understand, and, if necessary, re-formulate the algorithmsI Design a configurable framework for SMT-based algorithms

(based upon the CPA framework)I Use flexibility of adjustable-block encoding (ABE)I Express existing algorithms using the common frameworkI Implement framework (in CPAchecker)

Dirk Beyer LMU Munich, Germany 6 / 63

Page 8: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Base: Adjustable-Block Encoding

Originally for predicate abstraction:I Abstraction computation is expensiveI Abstraction is not necessary after every transitionI Track precise path formula between abstraction statesI Reset path formula and compute abstraction formula at

abstraction statesI Large-Block Encoding:

abstraction only at loop heads (hard-coded)I Adjustable-Block Encoding:

introduce block operator "blk" to make it configurable

Dirk Beyer LMU Munich, Germany 7 / 63

Page 9: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Base: Configurable Program Analysis

Configurable Program Analysis (CPA):I Beyer, Henzinger, Théoduloz: [CAV’07]I One single unifying algorithm for all algorithms based on

state-space explorationI Configurable components: abstract domain,

abstract-successor computation, path sensitivity, ...

Dirk Beyer LMU Munich, Germany 8 / 63

Page 10: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Using the CPA FrameworkI CPA Algorithm is a configurable reachability analysis

for arbitrary abstract domains

I Provide Predicate CPA for our predicate-based abstract domainI Reuse other CPAsI Built further algorithms on top

that make use of reachability analysis

SourceCode

Spec

ResultsParser &CFA Builder

k-inductionAlgorithm

CEGARAlgorithm

CPAAlgorithm

SpecCPA

LocationCPA

Loop-BoundCPA

PredicateCPA

Dirk Beyer LMU Munich, Germany 9 / 63

Page 11: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Using the CPA FrameworkI CPA Algorithm is a configurable reachability analysis

for arbitrary abstract domainsI Provide Predicate CPA for our predicate-based abstract domain

I Reuse other CPAsI Built further algorithms on top

that make use of reachability analysis

SourceCode

Spec

ResultsParser &CFA Builder

k-inductionAlgorithm

CEGARAlgorithm

CPAAlgorithm

SpecCPA

LocationCPA

Loop-BoundCPA

PredicateCPA

Dirk Beyer LMU Munich, Germany 9 / 63

Page 12: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Using the CPA FrameworkI CPA Algorithm is a configurable reachability analysis

for arbitrary abstract domainsI Provide Predicate CPA for our predicate-based abstract domainI Reuse other CPAs

I Built further algorithms on topthat make use of reachability analysis

SourceCode

Spec

ResultsParser &CFA Builder

k-inductionAlgorithm

CEGARAlgorithm

CPAAlgorithm

SpecCPA

LocationCPA

Loop-BoundCPA

PredicateCPA

Dirk Beyer LMU Munich, Germany 9 / 63

Page 13: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Using the CPA FrameworkI CPA Algorithm is a configurable reachability analysis

for arbitrary abstract domainsI Provide Predicate CPA for our predicate-based abstract domainI Reuse other CPAsI Built further algorithms on top

that make use of reachability analysis

SourceCode

Spec

ResultsParser &CFA Builder

k-inductionAlgorithm

CEGARAlgorithm

CPAAlgorithm

SpecCPA

LocationCPA

Loop-BoundCPA

PredicateCPA

Dirk Beyer LMU Munich, Germany 9 / 63

Page 14: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 10 / 63

Page 15: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 10 / 63

Page 16: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPA: Abstract Domain

I Abstract state: (ψ, ϕ)I tuple of abstraction formula ψ and path formula ϕ

(for ABE)I conjunctions represents state spaceI abstraction formula can be a BDD or an SMT formulaI path formula is always SMT formula and concrete

I Precision: set of predicates (per program location)

Dirk Beyer LMU Munich, Germany 11 / 63

Page 17: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPA: Abstract Domain

I Abstract state: (ψ, ϕ)I tuple of abstraction formula ψ and path formula ϕ

(for ABE)I conjunctions represents state spaceI abstraction formula can be a BDD or an SMT formulaI path formula is always SMT formula and concrete

I Precision: set of predicates (per program location)

Dirk Beyer LMU Munich, Germany 11 / 63

Page 18: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 12 / 63

Page 19: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPA: CPA OperatorsI Transfer relation:

I computes strongest postI changes only path formula, new abstract state is (ψ,ϕ′)I purely syntactic, cheapI variety of encodings using different SMT theories possible

(different approximationsfor arithmetic and heap operations)

I Merge operator:

I standard for ABE: create disjunctions inside block

I Stop operator:

I standard for ABE: check coverage only at block ends

I Precision-adjustment operator:

I only active at block ends (as determined by blk)I computes abstraction of current abstract stateI new abstract state is (ψ′, true)

Dirk Beyer LMU Munich, Germany 13 / 63

Page 20: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPA: CPA OperatorsI Transfer relation:

I computes strongest postI changes only path formula, new abstract state is (ψ,ϕ′)I purely syntactic, cheapI variety of encodings using different SMT theories possible

(different approximationsfor arithmetic and heap operations)

I Merge operator:I standard for ABE: create disjunctions inside block

I Stop operator:

I standard for ABE: check coverage only at block ends

I Precision-adjustment operator:

I only active at block ends (as determined by blk)I computes abstraction of current abstract stateI new abstract state is (ψ′, true)

Dirk Beyer LMU Munich, Germany 13 / 63

Page 21: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPA: CPA OperatorsI Transfer relation:

I computes strongest postI changes only path formula, new abstract state is (ψ,ϕ′)I purely syntactic, cheapI variety of encodings using different SMT theories possible

(different approximationsfor arithmetic and heap operations)

I Merge operator:I standard for ABE: create disjunctions inside block

I Stop operator:I standard for ABE: check coverage only at block ends

I Precision-adjustment operator:

I only active at block ends (as determined by blk)I computes abstraction of current abstract stateI new abstract state is (ψ′, true)

Dirk Beyer LMU Munich, Germany 13 / 63

Page 22: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPA: CPA OperatorsI Transfer relation:

I computes strongest postI changes only path formula, new abstract state is (ψ,ϕ′)I purely syntactic, cheapI variety of encodings using different SMT theories possible

(different approximationsfor arithmetic and heap operations)

I Merge operator:I standard for ABE: create disjunctions inside block

I Stop operator:I standard for ABE: check coverage only at block ends

I Precision-adjustment operator:I only active at block ends (as determined by blk)I computes abstraction of current abstract stateI new abstract state is (ψ′, true)

Dirk Beyer LMU Munich, Germany 13 / 63

Page 23: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 14 / 63

Page 24: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPA: Refinement

Four steps:1. Reconstruct ARG path to abstract error state2. Check feasibility of path3. Discover abstract facts, e.g.,

I interpolantsI weakest preconditionI heuristics

4. Refine abstract modelI add predicates to precision, cut ARGorI conjoin interpolants to abstract states,

recheck coverage relation

Dirk Beyer LMU Munich, Germany 15 / 63

Page 25: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 16 / 63

Page 26: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction

I Predicate AbstractionI [CAV’97, POPL’02, J. ACM’03, POPL’04]I Abstract-interpretation techniqueI Abstract domain constructed from a set of predicates πI Use CEGAR to add predicates to π (refinement)I Derive new predicates using Craig interpolationI Abstraction formula as BDD

Dirk Beyer LMU Munich, Germany 17 / 63

Page 27: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Expressing Predicate Abstraction

I Abstraction Formulas: BDDsI Block Size (blk): e.g. blkSBE or blkl or blklf

I Refinement Strategy: add predicates to precision, cut ARGUse CEGAR Algorithm:1: while true do2: run CPA Algorithm3: if target state found then4: call refine5: if target state reachable then6: return false7: else8: return true

Dirk Beyer LMU Munich, Germany 18 / 63

Page 28: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 19 / 63

Page 29: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Example Program

1 i n t main ( ) {2 unsigned in t x = 0 ;3 unsigned in t y = 0 ;4 while ( x < 2) {5 x++;6 y++;7 i f ( x != y ) {8 ERROR: return 1 ;9 }

10 }11 return 0 ;12 }

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

Dirk Beyer LMU Munich, Germany 20 / 63

Page 30: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 21 / 63

Page 31: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 32: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (true, x0 = 0 ∧ y0 = 0))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 33: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 34: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 35: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 36: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬¬(x1 = y1)))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 37: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 38: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 39: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(x1 = y1)))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 40: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 41: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate Abstraction: Examplewith blkl, π(l4) = {x = y} and π(l8) = {false}

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (x = y,¬(x0 < 2)))

e4: (l12, (x = y,¬(x0 < 2)))

e5: (l5, (x = y, x0 < 2))

e6: (l6, (x = y, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (x = y, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l4, (x = y, true))

e9: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 22 / 63

Page 42: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact

I ImpactI "Lazy Abstraction with Interpolants" [CAV’06]I Abstraction is derived dynamically/lazilyI Solution to avoiding expensive abstraction computationsI Compute fixed point over three operations

I ExpandI RefineI Cover

I Abstraction formula as SMT formulaI Optimization: forced covering

Dirk Beyer LMU Munich, Germany 23 / 63

Page 43: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Expressing Impact

I Abstraction Formulas: SMT-basedI Block Size (blk): blkSBE or other (new!)I Refinement Strategy:

conjoin interpolants to abstract states,recheck coverage relation

Furthermore:I Use CEGAR AlgorithmI Precision stays empty→ predicate abstraction never computed

Dirk Beyer LMU Munich, Germany 24 / 63

Page 44: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 25 / 63

Page 45: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 26 / 63

Page 46: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (true, x0 = 0 ∧ y0 = 0))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (true, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 47: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (true, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (true, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 48: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (true, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (true, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 49: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (true, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (true, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 50: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (true, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(x1 = y1)))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 51: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (true, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (true, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 52: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (false, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 53: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (false, true))

e9: (l4, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬¬(x1 = y1)))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 54: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (false, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 55: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (false, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1 ∧ ¬(x2 = y2)))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 56: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (false, true))

e9: (l4, (true, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (true, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 57: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (false, true))

e9: (l4, (x = y, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 58: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Impact: Examplewith blkl

l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true))

e1: (l3, (true, x0 = 0))

e2: (l4, (x = y, true))

e3: (l11, (true,¬(x0 < 2)))

e4: (l12, (true,¬(x0 < 2)))

e5: (l5, (true, x0 < 2))

e6: (l6, (true, x0 < 2 ∧ x1 = x0 + 1))

e7: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1))

e8: (l8, (false, true))

e9: (l4, (x = y, true))

e10: (l5, (true, x1 < 2))

e11: (l6, (true, x1 < 2 ∧ x2 = x1 + 1))

e12: (l7, (true, x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1))

e13: (l8, (false, true))

covered by

Dirk Beyer LMU Munich, Germany 27 / 63

Page 59: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Bounded Model Checking

I Bounded Model Checking:I Biere, Cimatti, Clarke, Zhu: [TACAS’99]I No abstractionI Unroll loops up to a loop bound kI Check that P holds in the first k iterations:

k∧i=1P (i)

Dirk Beyer LMU Munich, Germany 28 / 63

Page 60: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Expressing BMC

I Block Size (blk): blknever

Furthermore:I Add CPA for bounding state space (e.g., loop bounds)I Choices for abstraction formulas and refinement irrelevant

because block end never encounteredI Use Algorithm for iterative BMC:

1: k = 12: while !finished do3: run CPA Algorithm4: check feasibility of each abstract error state5: k++

Dirk Beyer LMU Munich, Germany 29 / 63

Page 61: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Predicate CPAPredicate CPA P

DP =(C, EP, [[·]]P) ΠP P mergeP stopP precP

StrongestPostcondition

SMT Theory

ABVFP

. . .

QF_UFLIRA

Abstraction-FormulaRepresentation

BDD

SMT-based

PredicateAbstraction

Cartesian

Boolean

blk

blkSBE

blkl

blklf

blknever

fcoverP

fcoverid

fcoverImpact

refineP

AbstractFacts

Interpolants

PathInvariants

Unsat Cores

WeakestPreconditions

HeuristicPredicates

RefinementStrategy

Predicate

Impact

Dirk Beyer LMU Munich, Germany 30 / 63

Page 62: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Bounded Model Checking: Example with k = 1l2start

l3

l4

l5

l6

l7

l8

l11

l12

unsigned int x = 0;

unsigned int y = 0;

[x < 2]

[!(x < 2)]

x++;

y++;

[x != y]

ERROR: return 1;return 0;

[!(x != y)]

e0: (l2, (true, true), {l4 7→ −1})

e1: (l3, (true, x0 = 0), {l4 7→ −1})

e2: (l4, (true, x0 = 0 ∧ y0 = 0), {l4 7→ 0})

e3: (l11, (true, x0 = 0 ∧ y0 = 0 ∧ ¬(x0 < 2)), {l4 7→ 0})

e4: (l12, (true, x0 = 0 ∧ y0 = 0 ∧ ¬(x0 < 2)), {l4 7→ 0})

e5: (l5, (true, x0 = 0 ∧ y0 = 0 ∧ x0 < 2), {l4 7→ 0})

e6: (l6, (true, x0 = 0 ∧ y0 = 0 ∧ x0 < 2 ∧ x1 = x0 + 1), {l4 7→ 0})

e7: (l7, (true, x0 = 0 ∧ y0 = 0 ∧ x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1), {l4 7→ 0})

e8: (l8, (true, x0 = 0 ∧ y0 = 0 ∧ x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(x1 = y1)), {l4 7→ 0})

e9: (l12, (true, x0 = 0 ∧ y0 = 0 ∧ x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(x1 = y1)), {l4 7→ 0})

e10: (l4, (true, x0 = 0 ∧ y0 = 0 ∧ x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1))), {l4 7→ 1})

Dirk Beyer LMU Munich, Germany 31 / 63

Page 63: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

1-Induction

I 1-Induction:I Base case: Check that the safety property holds in the

first loop iteration:P (1)

→ Equivalent to BMC with loop bound 1I Step case: Check that the safety property is 1-inductive:

∀n : (P (n)⇒ P (n+ 1))

Dirk Beyer LMU Munich, Germany 32 / 63

Page 64: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

k-Induction

I k-Induction generalizes the induction principle:I No abstractionI Base case: Check that P holds in the first k iterations:→ Equivalent to BMC with loop bound k

I Step case: Check that the safety property is k-inductive:

∀n :((

k∧i=1P (n+ i− 1)

)⇒ P (n+ k)

)

I Stronger hypothesis is more likely to succeedI Add auxiliary invariantsI Kahsai, Tinelli: [PDMC’11]

Dirk Beyer LMU Munich, Germany 33 / 63

Page 65: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

k-Induction with Auxiliary Invariants

Induction:1: k = 12: while !finished do3: BMC(k)4: Induction(k, invariants)5: k++

Invariant generation:1: prec = <weak>2: invariants = ∅3: while !finished do4: invariants = GenInv(prec)5: prec = RefinePrec(prec)

Dirk Beyer LMU Munich, Germany 34 / 63

Page 66: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

k-Induction: Examplee0: (l4, (true, true), {l4 7→ 0})

e1: (l11, (true,¬(x0 < 2)), {l4 7→ 0})

e2: (l12, (true,¬(x0 < 2)), {l4 7→ 0})

e3: (l5, (true, x0 < 2), {l4 7→ 0})

e4: (l6, (true, x0 < 2 ∧ x1 = x0 + 1), {l4 7→ 0})

e5: (l7, (true,∧x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1), {l4 7→ 0})

e6: (l8, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(x1 = y1)), {l4 7→ 0})

e7: (l12, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(x1 = y1)), {l4 7→ 0})

e8: (l4, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1))), {l4 7→ 1})

e9: (l11, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ ¬(x1 < 2)), {l4 7→ 1})

e10: (l12, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ ¬(x1 < 2)), {l4 7→ 1})

e11: (l5, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ x1 < 2), {l4 7→ 1})

e12: (l6, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ x1 < 2 ∧ x2 = x1 + 1), {l4 7→ 1})

e13: (l7, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ x1 < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1), {l4 7→ 1})

e14: (l8, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ x < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1 ∧ ¬(x2 = y2)), {l4 7→ 1})

e15: (l12, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ x < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1 ∧ ¬(x2 = y2)), {l4 7→ 1})

e16: (l4, (true, x0 < 2 ∧ x1 = x0 + 1 ∧ y1 = y0 + 1 ∧ ¬(¬(x1 = y1)) ∧ x < 2 ∧ x2 = x1 + 1 ∧ y2 = y1 + 1 ∧ ¬(¬(x2 = y2))), {l4 7→ 2})

Dirk Beyer LMU Munich, Germany 35 / 63

Page 67: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Insights

I BMC naturally follows by increasing block sizeto whole (bounded) program

I Difference between predicate abstraction and Impact:

I BDDs vs. SMT-based formulas:costly abstractions vs. costly coverage checks

I Recompute ARG vs. rechecking coverageI We know that only these differences are relevant!I Predicate abstraction pays for creating more general

abstract modelI Impact is lazier but this can lead to many refinements→ forced covering or large blocks help

Dirk Beyer LMU Munich, Germany 36 / 63

Page 68: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Insights

I BMC naturally follows by increasing block sizeto whole (bounded) program

I Difference between predicate abstraction and Impact:I BDDs vs. SMT-based formulas:

costly abstractions vs. costly coverage checksI Recompute ARG vs. rechecking coverageI We know that only these differences are relevant!I Predicate abstraction pays for creating more general

abstract modelI Impact is lazier but this can lead to many refinements→ forced covering or large blocks help

Dirk Beyer LMU Munich, Germany 36 / 63

Page 69: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Evaluation: Usefulness of Framework

I 4 existing approaches successfully integratedI Ongoing projects for integration of further approachesI Interesting insights learned about these approachesI High configurability allows new combinations and hybrid

approachesI Already used as base for other successful research projects

Dirk Beyer LMU Munich, Germany 37 / 63

Page 70: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Evaluation: Usefulness of Implementation

I Used in other research projects

I Used as part of manySV-COMP submissions,48 medals

I Also competitive stand-alone

I Awarded Gödel medalby Kurt Gödel Society

Dirk Beyer LMU Munich, Germany 38 / 63

Page 71: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Comparison with SV-COMP’17 Verifiers

I 5 594 verification tasks from SV-COMP’17(only reachability, without recursion and concurrency)

I 15 min time limit per task (CPU time)I 15 GB memory limitI Measured with BenchExecI Comparison of

I 4 configurations of CPAchecker with Predicate CPA:BMC, k-induction, Impact, predicate abstraction

I 16 participants of SV-COMP’17

Dirk Beyer LMU Munich, Germany 39 / 63

Page 72: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Comparison with SV-COMP’17 Verifiers: Results

Number of correctly solved tasks:I Each configuration of Predicate CPA

beats other tools with same approachI Only 3 tools beat Predicate CPA with k-induction:

I Smack: guesses resultsI CPA-BAM-BnB, CPA-Seq:

based on Predicate CPA as well

Number of wrong results:I Comparable with other toolsI No wrong proofs (sound)

Dirk Beyer LMU Munich, Germany 40 / 63

Page 73: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Comparison with SV-COMP’17 Verifiers: Results

Number of correctly solved tasks:I Each configuration of Predicate CPA

beats other tools with same approachI Only 3 tools beat Predicate CPA with k-induction:

I Smack: guesses resultsI CPA-BAM-BnB, CPA-Seq:

based on Predicate CPA as well

Number of wrong results:I Comparable with other toolsI No wrong proofs (sound)

Dirk Beyer LMU Munich, Germany 40 / 63

Page 74: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Comparison with SV-COMP’17 Verifiers

1

10

100

1 000

CP

Uti

me

(s)

SV-COMP’17CPA-BAM-BnBCPA-KIndCPA-SeqCbmcDepthKEsbmcEsbmc-KIndSmackUltimate Automizer

Predicate CPA(MathSAT5 QF_UFBVFP)BMCk -InductionImpact

Predicate Abstraction

0 500 1 000 1 500 2 000 2 500 3 000 3 5000

n-th fastest correct result

Dirk Beyer LMU Munich, Germany 41 / 63

Page 75: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Evaluation: Enabling Experimental Studies

I Comparison of algorithmsacross different program categories[VSTTE’16, JAR]

I SMT solvers for various theories and algorithms

Dirk Beyer LMU Munich, Germany 42 / 63

Page 76: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Experimental Comparison of Algorithms

I 5 287 verification tasks from SV-COMP’17I 15 min time limit per task (CPU time)I 15 GB memory limitI Measured with BenchExec

Dirk Beyer LMU Munich, Germany 43 / 63

Page 77: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

All 3 913 bug-free tasks

0 500 1 000 1 500 2 0001

10

100

1 000

Number of correctly solved tasks

CPU

time(s)

BMC

k-Induction

PredicateAbstraction

Impact

Dirk Beyer LMU Munich, Germany 44 / 63

Page 78: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

All 1 374 tasks with known bugs

0 100 200 300 4001

10

100

1 000

Number of correctly solved tasks

CPU

time(s)

BMC

k-Induction

PredicateAbstraction

Impact

Dirk Beyer LMU Munich, Germany 45 / 63

Page 79: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Device Drivers

I Several thousands LOC per taskI Complex structuresI Pointer arithmetics

Dirk Beyer LMU Munich, Germany 46 / 63

Page 80: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Device Drivers: 2 440 bug-free tasks

0 200 400 600 800 1 000 1 200 1 4001

10

100

1 000

Number of correctly solved tasks

CPU

time(s)

BMC

k-Induction

PredicateAbstraction

Impact

Dirk Beyer LMU Munich, Germany 47 / 63

Page 81: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Device Drivers: 355 tasks with known bugs

0 5 10 15 20 25 30 351

10

100

1 000

Number of correctly solved tasks

CPU

time(s)

BMC

k-Induction

PredicateAbstraction

Impact

Dirk Beyer LMU Munich, Germany 48 / 63

Page 82: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Event Condition Action Systems (ECA)I Several thousand LOC per taskI Auto-generatedI Only integer variablesI Linear and non-linear arithmeticsI Complex and dense control structure

if (((a24==3) && (((a18==10) && ((input == 6)&& ((115 < a3) && (306 >= a3))))&& (a15==4)))) {

a3 = (((a3 ∗ 5) + −583604) ∗ 1);a24 = 0;a18 = 8;return −1;

}

Dirk Beyer LMU Munich, Germany 49 / 63

Page 83: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Event Condition Action Systems (ECA)I Several thousand LOC per taskI Auto-generatedI Only integer variablesI Linear and non-linear arithmeticsI Complex and dense control structure

if (((a24==3) && (((a18==10) && ((input == 6)&& ((115 < a3) && (306 >= a3))))&& (a15==4)))) {

a3 = (((a3 ∗ 5) + −583604) ∗ 1);a24 = 0;a18 = 8;return −1;

}

Dirk Beyer LMU Munich, Germany 49 / 63

Page 84: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category ECA: 738 bug-free tasks

0 100 200 300 4001

10

100

1 000

Number of correctly solved tasks

CPU

time(s)

BMC

k-Induction

PredicateAbstraction

Impact

Dirk Beyer LMU Munich, Germany 50 / 63

Page 85: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category ECA: 411 tasks with known bugs

I Only BMC and k-Induction solve 1 task(the same one for both)

I Impact and Predicate Abstraction solve none

Dirk Beyer LMU Munich, Germany 51 / 63

Page 86: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Product Lines

I Several hundred LOCI Mostly integer variables, some structsI Mostly simple linear arithmeticsI Lots of property-independent code

Dirk Beyer LMU Munich, Germany 52 / 63

Page 87: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Product Lines: 332 bug-free tasks

0 50 100 150 200 250 300 3501

10

100

1 000

Number of correctly solved tasks

CPU

time(s)

BMC

k-Induction

PredicateAbstraction

Impact

Dirk Beyer LMU Munich, Germany 53 / 63

Page 88: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Category Product Lines: 265 tasks with known bugs

0 20 40 60 80 100 120 1401

10

100

1 000

Number of correctly solved tasks

CPU

time(s)

BMC

k-Induction

PredicateAbstraction

Impact

Dirk Beyer LMU Munich, Germany 54 / 63

Page 89: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Experimental Comparison of Algorithms: Summary

We reconfirm thatI BMC is a good bug hunterI k-Induction is a heavy-weight proof technique:

effective, but costlyI CEGAR makes abstraction techniques

(Predicate Abstraction, Impact) scalableI Impact is lazy:

explores the state space and finds bugs quickerI Predicate Abstraction is eager:

prunes irrelevant parts and finds proofs quicker

Dirk Beyer LMU Munich, Germany 55 / 63

Page 90: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

SMT Study: Motivation

Now, which do you think is better, i.e., solves more tasks?

(A)

k-Induction

solves 29 % more tasks

Z3with bitprecise arithmetic

(B)

Predicate Abstraction

solves 3 % more tasks

MathSAT5with linear arithmetic

Depending on configuration, either (A) or (B) can be true!

Technical details (e.g., choice of SMT theory)influence evaluation of algorithms

Dirk Beyer LMU Munich, Germany 56 / 63

Page 91: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

SMT Study: Motivation

Now, which do you think is better, i.e., solves more tasks?

(A)k-Induction

solves 29 % more tasks

Z3with bitprecise arithmetic

(B)Predicate Abstractionsolves 3 % more tasks

MathSAT5with linear arithmetic

Depending on configuration, either (A) or (B) can be true!

Technical details (e.g., choice of SMT theory)influence evaluation of algorithms

Dirk Beyer LMU Munich, Germany 56 / 63

Page 92: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

SMT Study: Motivation

Now, which do you think is better, i.e., solves more tasks?

(A)k-Induction

solves 29 % more tasks

Z3with bitprecise arithmetic

(B)Predicate Abstractionsolves 3 % more tasks

MathSAT5with linear arithmetic

Depending on configuration, either (A) or (B) can be true!

Technical details (e.g., choice of SMT theory)influence evaluation of algorithms

Dirk Beyer LMU Munich, Germany 56 / 63

Page 93: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Comparison of SMT Solvers and Theories

I Which SMT solver should we use in a verifier?I Which formula encoding?I Which of these should we use for benchmarks in papers?

I Large study made possible by our frameworkI Produced some interesting insightsI Resulted in change of default configuration of CPAchecker

I Comparison using CPAchecker and Predicate CPAI 5 594 verification tasks from SV-COMP’17I 15 min time limit (CPU time), 15 GB memory limitI Measured with BenchExec

Dirk Beyer LMU Munich, Germany 57 / 63

Page 94: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Comparison of SMT Solvers and Theories

I Which SMT solver should we use in a verifier?I Which formula encoding?I Which of these should we use for benchmarks in papers?

I Large study made possible by our frameworkI Produced some interesting insightsI Resulted in change of default configuration of CPAchecker

I Comparison using CPAchecker and Predicate CPAI 5 594 verification tasks from SV-COMP’17I 15 min time limit (CPU time), 15 GB memory limitI Measured with BenchExec

Dirk Beyer LMU Munich, Germany 57 / 63

Page 95: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Comparison of SMT Solvers and Theories

I Which SMT solver should we use in a verifier?I Which formula encoding?I Which of these should we use for benchmarks in papers?

I Large study made possible by our frameworkI Produced some interesting insightsI Resulted in change of default configuration of CPAchecker

I Comparison using CPAchecker and Predicate CPAI 5 594 verification tasks from SV-COMP’17I 15 min time limit (CPU time), 15 GB memory limitI Measured with BenchExec

Dirk Beyer LMU Munich, Germany 57 / 63

Page 96: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

SMT Study: 120 Configurations

BMC k-Induction Impact Pred. AbsŚ

MathSAT5 Princess SMTInterpol Z3Ś

Bitprecise Linear Linear unsoundŚ

with Quantifiers Quantifier-freeŚ

Arrays UFs

Dirk Beyer LMU Munich, Germany 58 / 63

Page 97: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: SMT Solvers

I Princess is never competitiveI Interpolation in Z3 is unmaintained since 2015I Bitvector interpolation in Z3 produces up to 24 % crashesI MathSAT5 has known interpolation problem for bitvectors,

but problem occurs rarely

Dirk Beyer LMU Munich, Germany 59 / 63

Page 98: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Theories and Encodings

I Unsound linear encoding always the easiest (as expected)

I Correctness as expected:BV > sound LIRA > unsound LIRA

I Effectivity for Z3 as expected:BV < sound LIRA < unsound LIRA

I Effectivity for MathSAT5:sound LIRA < BV ≈ unsound LIRA(but BV needs more CPU time)

I Effectivity for SMTInterpol:sound LIRA � unsound LIRA

⇒ MathSAT5 is really good with bitvectors.⇒ Sound LIRA encoding rarely makes sense.

Dirk Beyer LMU Munich, Germany 60 / 63

Page 99: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Theories and Encodings

I Unsound linear encoding always the easiest (as expected)I Correctness as expected:

BV > sound LIRA > unsound LIRA

I Effectivity for Z3 as expected:BV < sound LIRA < unsound LIRA

I Effectivity for MathSAT5:sound LIRA < BV ≈ unsound LIRA(but BV needs more CPU time)

I Effectivity for SMTInterpol:sound LIRA � unsound LIRA

⇒ MathSAT5 is really good with bitvectors.⇒ Sound LIRA encoding rarely makes sense.

Dirk Beyer LMU Munich, Germany 60 / 63

Page 100: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Theories and Encodings

I Unsound linear encoding always the easiest (as expected)I Correctness as expected:

BV > sound LIRA > unsound LIRAI Effectivity for Z3 as expected:

BV < sound LIRA < unsound LIRA

I Effectivity for MathSAT5:sound LIRA < BV ≈ unsound LIRA(but BV needs more CPU time)

I Effectivity for SMTInterpol:sound LIRA � unsound LIRA

⇒ MathSAT5 is really good with bitvectors.⇒ Sound LIRA encoding rarely makes sense.

Dirk Beyer LMU Munich, Germany 60 / 63

Page 101: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Theories and Encodings

I Unsound linear encoding always the easiest (as expected)I Correctness as expected:

BV > sound LIRA > unsound LIRAI Effectivity for Z3 as expected:

BV < sound LIRA < unsound LIRAI Effectivity for MathSAT5:

sound LIRA < BV ≈ unsound LIRA(but BV needs more CPU time)

I Effectivity for SMTInterpol:sound LIRA � unsound LIRA

⇒ MathSAT5 is really good with bitvectors.

⇒ Sound LIRA encoding rarely makes sense.

Dirk Beyer LMU Munich, Germany 60 / 63

Page 102: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Theories and Encodings

I Unsound linear encoding always the easiest (as expected)I Correctness as expected:

BV > sound LIRA > unsound LIRAI Effectivity for Z3 as expected:

BV < sound LIRA < unsound LIRAI Effectivity for MathSAT5:

sound LIRA < BV ≈ unsound LIRA(but BV needs more CPU time)

I Effectivity for SMTInterpol:sound LIRA � unsound LIRA

⇒ MathSAT5 is really good with bitvectors.

⇒ Sound LIRA encoding rarely makes sense.

Dirk Beyer LMU Munich, Germany 60 / 63

Page 103: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Theories and Encodings

I Unsound linear encoding always the easiest (as expected)I Correctness as expected:

BV > sound LIRA > unsound LIRAI Effectivity for Z3 as expected:

BV < sound LIRA < unsound LIRAI Effectivity for MathSAT5:

sound LIRA < BV ≈ unsound LIRA(but BV needs more CPU time)

I Effectivity for SMTInterpol:sound LIRA � unsound LIRA

⇒ MathSAT5 is really good with bitvectors.⇒ Sound LIRA encoding rarely makes sense.

Dirk Beyer LMU Munich, Germany 60 / 63

Page 104: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Algorithms

I Mostly, the best configurations of MathSAT5,SMTInterpol, and Z3 are close for each algorithmI Gives confidence for valid comparison of algorithmI But outlier exists:

Z3 is worse than others for predicate abstraction

I Predicate abstraction and Impact suffer most fromdisjunctions of sound LIRA encoding.

Dirk Beyer LMU Munich, Germany 61 / 63

Page 105: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Algorithms

I Mostly, the best configurations of MathSAT5,SMTInterpol, and Z3 are close for each algorithmI Gives confidence for valid comparison of algorithmI But outlier exists:

Z3 is worse than others for predicate abstractionI Predicate abstraction and Impact suffer most from

disjunctions of sound LIRA encoding.

Dirk Beyer LMU Munich, Germany 61 / 63

Page 106: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Arrays and Quantifiers

I Little difference with/without arrays/quantifiers⇒ Arrays don’t hurt

(though this might changeonce more complex array predicates are used)

I But quantifiers restrict solver choice(Princess and Z3)

Dirk Beyer LMU Munich, Germany 62 / 63

Page 107: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

Point of View: Arrays and Quantifiers

I Little difference with/without arrays/quantifiers⇒ Arrays don’t hurt

(though this might changeonce more complex array predicates are used)

I But quantifiers restrict solver choice(Princess and Z3)

Dirk Beyer LMU Munich, Germany 62 / 63

Page 108: A Unifying View on SMT-Based Software Verification · 2018-11-29 · PredicateCPA Predicate CPA P D P = (C,EP,[[·]] P) Π P Pmerge stop P prec Strongest Postcondition SMTTheory ABVFP

SMT Study: Final Conclusions

I Choice of theories, solver, and encoding details affectscomparisons of algorithms!

I For now:use MathSAT5 with bitvectors and arrays if possibleI Possible problems for users: license, native binaryI Next-best choice:

SMTInterpol with unsound linear arithmeticI No improvement of situation in sight

Dirk Beyer LMU Munich, Germany 63 / 63