SMT-based Function Summarization for Software Verification Martin - - PowerPoint PPT Presentation

smt based function summarization for software verification
SMART_READER_LITE
LIVE PREVIEW

SMT-based Function Summarization for Software Verification Martin - - PowerPoint PPT Presentation

SMT-based Function Summarization for Software Verification Martin Blicha Leonardo Alt Sepideh Asadi USI Ethereum USI Grigory Fedyukovich Antti Hyvrinen Natasha Sharygina Princeton USI USI University of Lugano(USI), Switzerland


slide-1
SLIDE 1

SMT-based Function Summarization for Software Verification

University of Lugano(USI), Switzerland

Antti Hyvärinen USI Grigory Fedyukovich Princeton Sepideh Asadi USI

Natasha Sharygina

USI Leonardo Alt Ethereum Martin Blicha USI

slide-2
SLIDE 2

2

Model checking software (HiFrog, FunFrog, eVolCheck, LoopFrog), ANSI-C programs Interpolation-based Bounded Model Checking:

  • Propositional and First-order Interpolation [TACAS’19],[LPAR’13],[FMCAD’17],

[CAV’15]

  • Function summarization [TACAS’17],[ATVA’12]
  • Theory and Summary Refinement [SAT’17], [LPAR’18]

Formal Verification in Lugano, Switzerland

slide-3
SLIDE 3

Boolean and Theory Reasoning (SAT/SMT): Solver, OpenSMT, combines MiniSAT2 SAT-Solver with state-of-the-art decision procedures for QF EUF, LRA, LIA, BV, RDL, IDL Extensible: the SAT-to-theory interface facilitates design and plug-in of new decision procedures Incremental: suitable for incremental verification Open-source: available under MIT license Parallelized: efficient search space partitioning Efficient: competitive open-source SMT Solver according to SMT-Comp.

3

Formal Verification in Lugano, Switzerland

slide-4
SLIDE 4

4

Efficient and adoptable-to-the-task decision procedures as computational engines of verification SMT-based Gas consumption estimation for smart contracts [LPAR’18] Incremental verification, Upgrade checking [STTT’17],[FMCAD’14],[TACAS’13] Integrated dynamic and static analysis [ISSTA’14] Model checking Ethereum smart contracts and mobile programs [ongoing]

4

Formal Verification in Lugano, Switzerland

More info at: www.verify.inf.usi.ch

slide-5
SLIDE 5

The cost of poor software

5

From https://raygun.com/ “11 of the most costly software errors in history”:

Bitcoin Mt. Gox Hack: In 2011, the world’s largest bitcoin exchange, after being hacked, lost

  • ver 800,000 bitcoins – worth around

half a billion dollars!

  • Testing is not sufficient to find the bug (not exhaustive!)
  • The strongest tool to defend against hacks is formal verification.

[Makerdao white paper]

slide-6
SLIDE 6

Program correctness

Can we prove some properties ALWAYS hold in the program?

6
slide-7
SLIDE 7

Program correctness

Can we prove some properties ALWAYS hold in the program?

In general, program verification is undecidable, but … under some conditions/restrictions, it can be turned into a decidable problem!

6
slide-8
SLIDE 8

Automated formal verification: Model Checking [Clarke & Emerson 1981, Queille & Sifakis 1982]

Mathematical and algorithmic way to verify the program Exhaustive search on the state space Fully automatic Can guarantee the absence of bugs

Pros Cons

  • Computationally

expensive

  • State space explosion

problem + + + +

7
slide-9
SLIDE 9

Advances in model checking

  • Well-established

techniques

  • Finite size model
  • Based on bit-precise

encoding

Hardware Software

  • Open Challenges!
  • Large bit-widths
  • Dynamic memory

management

  • Unbounded recursion
  • Domain-specific languages
  • Long development history
8
slide-10
SLIDE 10

Symbolic model checking [McMillan 1993]

SAT-based Model Checking

9

Encoder SAT-solver Not Safe Safe

Program Safety Property

*.c *.h assert (x >0)

Boolean formulas

Formulas represent states

[Biere et al. 1999]
slide-11
SLIDE 11

Symbolic model checking [McMillan 1993]

SAT-based Model Checking

9

Encoder SAT-solver Not Safe Safe

Program Safety Property

*.c *.h assert (x >0)

Boolean formulas

Formulas represent states

[Biere et al. 1999]

SAT-based Model Checking

An excellent tool for many problem domains ︎Very efficient SAT-solvers exist Very low-level language —> large formulations Makes search space larger Sometimes even prevent from termination

EXPENSIVE

slide-12
SLIDE 12

Abstraction-based model checking [kurshan1994, Clarke et al.

2000]
  • Problem: High complexity of software model checking
  • Solution:

➡Abstraction : Removes or simplifies details of the

system that are irrelevant to the property under consideration

10
slide-13
SLIDE 13

The paradigm of abstract-check-refine (CEGAR) [Clarke et al. 2000]

11
slide-14
SLIDE 14

The paradigm of abstract-check-refine (CEGAR) [Clarke et al. 2000]

11 If the abstract system is not correct, based on the validity of the counterexample, either Error is returned or the abstraction is refined and the system iterates.

Initial abstraction Verification Analyze the failure Refinement

success, No error! Failure

C program

Error found! Yes No Concretization
slide-15
SLIDE 15

SMT

  • Satisfiability Modulo Theory (SMT)
  • Deciding the satisfiability of a first-order logic over different theories
  • SMT can create verification engines that can reason natively at a

higher level of abstraction

12

Encoder

(translation)

SMT-solver Not Safe Safe

Program Safety Property

*.c *.h assert (x >0)

SMT formulas

The focus of this talk

slide-16
SLIDE 16

SMT vs. SAT encoding

13

More expressive More compact More light-weight Efficient solving procedure

slide-17
SLIDE 17

Hierarchy of different theories

  • Equality Logic & Uninterpreted Functions (EUF)

(f(x, y) 6= f(u, v)) ^ (x = u) ^ (y = v)

  • Example:
14
slide-18
SLIDE 18

Hierarchy of different theories

  • Equality Logic & Uninterpreted Functions (EUF)

(f(x, y) 6= f(u, v)) ^ (x = u) ^ (y = v)

  • Example:
  • Linear Real Arithmetic (LRA)

(x + y ≤ 0) ∧ (x = 0) ∧ (¬a ∨ (x = 1) ∨ (y ≥ 0))

<latexit sha1_base64="Bf2ZlUWvcHjUC79cvXdAOMz0NG8=">ACMHicbVBbS8MwGE29znmb+uhLcAgbwmhF0BdB9EfJ7gprGWk2bcaTNOapNS9pN8afoi4IivorzLqC1wOBk3O+Q/IdP+ZMadt+tiYmp6ZnZktz5fmFxaXlyspqW0WJpNCiEY/khU8UcCagpZnmcBFLIKHP4dy/Ohr5wOQikXiTKcxeCEJBOszSrSRupXjWna7lQ6xy+Ea27iO3RvoBYBrt/v218UVEGC3QHkjlMvaIrdYJSr17uVqt2wc+C/xClIFRVodisPbi+iSQhCU06U6jh2rL2MSM0oh2HZTRTEhF6RADqGChKC8rJ84SHeNEoP9yNpjtA4V78nMhIqlYa+mQyJvlS/vZH4n9dJdH/Py5iIEw2Cjh/qJxzrCI/awz0mgWqeGkKoZOavmF4Sag2HZdNCc7vlf+S9nbDsRvO6U714LCo4TW0QaqIQftogN0gpqohSi6Q4/oBb1a9aT9Wa9j0cnrCKzhn7A+vgEcykt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exit><latexit sha1_base64="Bf2ZlUWvcHjUC79cvXdAOMz0NG8=">ACMHicbVBbS8MwGE29znmb+uhLcAgbwmhF0BdB9EfJ7gprGWk2bcaTNOapNS9pN8afoi4IivorzLqC1wOBk3O+Q/IdP+ZMadt+tiYmp6ZnZktz5fmFxaXlyspqW0WJpNCiEY/khU8UcCagpZnmcBFLIKHP4dy/Ohr5wOQikXiTKcxeCEJBOszSrSRupXjWna7lQ6xy+Ea27iO3RvoBYBrt/v218UVEGC3QHkjlMvaIrdYJSr17uVqt2wc+C/xClIFRVodisPbi+iSQhCU06U6jh2rL2MSM0oh2HZTRTEhF6RADqGChKC8rJ84SHeNEoP9yNpjtA4V78nMhIqlYa+mQyJvlS/vZH4n9dJdH/Py5iIEw2Cjh/qJxzrCI/awz0mgWqeGkKoZOavmF4Sag2HZdNCc7vlf+S9nbDsRvO6U714LCo4TW0QaqIQftogN0gpqohSi6Q4/oBb1a9aT9Wa9j0cnrCKzhn7A+vgEcyktA=</latexit>
  • Example:
14
slide-19
SLIDE 19

Hierarchy of different theories

  • Equality Logic & Uninterpreted Functions (EUF)

(f(x, y) 6= f(u, v)) ^ (x = u) ^ (y = v)

  • Example:
  • Linear Real Arithmetic (LRA)

(x + y ≤ 0) ∧ (x = 0) ∧ (¬a ∨ (x = 1) ∨ (y ≥ 0))

<latexit sha1_base64="Bf2ZlUWvcHjUC79cvXdAOMz0NG8=">ACMHicbVBbS8MwGE29znmb+uhLcAgbwmhF0BdB9EfJ7gprGWk2bcaTNOapNS9pN8afoi4IivorzLqC1wOBk3O+Q/IdP+ZMadt+tiYmp6ZnZktz5fmFxaXlyspqW0WJpNCiEY/khU8UcCagpZnmcBFLIKHP4dy/Ohr5wOQikXiTKcxeCEJBOszSrSRupXjWna7lQ6xy+Ea27iO3RvoBYBrt/v218UVEGC3QHkjlMvaIrdYJSr17uVqt2wc+C/xClIFRVodisPbi+iSQhCU06U6jh2rL2MSM0oh2HZTRTEhF6RADqGChKC8rJ84SHeNEoP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jtA4V78nMhIqlYa+mQyJvlS/vZH4n9dJdH/Py5iIEw2Cjh/qJxzrCI/awz0mgWqeGkKoZOavmF4Sag2HZdNCc7vlf+S9nbDsRvO6U714LCo4TW0QaqIQftogN0gpqohSi6Q4/oBb1a9aT9Wa9j0cnrCKzhn7A+vgEcyktA=</latexit><latexit sha1_base64="Bf2ZlUWvcHjUC79cvXdAOMz0NG8=">ACMHicbVBbS8MwGE29znmb+uhLcAgbwmhF0BdB9EfJ7gprGWk2bcaTNOapNS9pN8afoi4IivorzLqC1wOBk3O+Q/IdP+ZMadt+tiYmp6ZnZktz5fmFxaXlyspqW0WJpNCiEY/khU8UcCagpZnmcBFLIKHP4dy/Ohr5wOQikXiTKcxeCEJBOszSrSRupXjWna7lQ6xy+Ea27iO3RvoBYBrt/v218UVEGC3QHkjlMvaIrdYJSr17uVqt2wc+C/xClIFRVodisPbi+iSQhCU06U6jh2rL2MSM0oh2HZTRTEhF6RADqGChKC8rJ84SHeNEoP9yNpjtA4V78nMhIqlYa+mQyJvlS/vZH4n9dJdH/Py5iIEw2Cjh/qJxzrCI/awz0mgWqeGkKoZOavmF4Sag2HZdNCc7vlf+S9nbDsRvO6U714LCo4TW0QaqIQftogN0gpqohSi6Q4/oBb1a9aT9Wa9j0cnrCKzhn7A+vgEcyktA=</latexit>
  • Example:
  • Theory of Bit-Vectors (BV)
  • Example:

EXPENSIVE

h (a + b) % 2 6= ((a % 2) + (b % 2)) % 2 i

14
slide-20
SLIDE 20

Hierarchy of different theories

  • Equality Logic & Uninterpreted Functions (EUF)

(f(x, y) 6= f(u, v)) ^ (x = u) ^ (y = v)

  • Example:
  • Linear Real Arithmetic (LRA)

(x + y ≤ 0) ∧ (x = 0) ∧ (¬a ∨ (x = 1) ∨ (y ≥ 0))

<latexit sha1_base64="Bf2ZlUWvcHjUC79cvXdAOMz0NG8=">ACMHicbVBbS8MwGE29znmb+uhLcAgbwmhF0BdB9EfJ7gprGWk2bcaTNOapNS9pN8afoi4IivorzLq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Bk3O+Q/IdP+ZMadt+tiYmp6ZnZktz5fmFxaXlyspqW0WJpNCiEY/khU8UcCagpZnmcBFLIKHP4dy/Ohr5wOQikXiTKcxeCEJBOszSrSRupXjWna7lQ6xy+Ea27iO3RvoBYBrt/v218UVEGC3QHkjlMvaIrdYJSr17uVqt2wc+C/xClIFRVodisPbi+iSQhCU06U6jh2rL2MSM0oh2HZTRTEhF6RADqGChKC8rJ84SHeNEoP9yNpjtA4V78nMhIqlYa+mQyJvlS/vZH4n9dJdH/Py5iIEw2Cjh/qJxzrCI/awz0mgWqeGkKoZOavmF4Sag2HZdNCc7vlf+S9nbDsRvO6U714LCo4TW0QaqIQftogN0gpqohSi6Q4/oBb1a9aT9Wa9j0cnrCKzhn7A+vgEcyktA=</latexit><latexit sha1_base64="Bf2ZlUWvcHjUC79cvXdAOMz0NG8=">ACMHicbVBbS8MwGE29znmb+uhLcAgbwmhF0BdB9EfJ7gprGWk2bcaTNOapNS9pN8afoi4IivorzLqC1wOBk3O+Q/IdP+ZMadt+tiYmp6ZnZktz5fmFxaXlyspqW0WJpNCiEY/khU8UcCagpZnmcBFLIKHP4dy/Ohr5wOQikXiTKcxeCEJBOszSrSRupXjWna7lQ6xy+Ea27iO3RvoBYBrt/v218UVEGC3QHkjlMvaIrdYJSr17uVqt2wc+C/xClIFRVodisPbi+iSQhCU06U6jh2rL2MSM0oh2HZTRTEhF6RADqGChKC8rJ84SHeNEoP9yNpjtA4V78nMhIqlYa+mQyJvlS/vZH4n9dJdH/Py5iIEw2Cjh/qJxzrCI/awz0mgWqeGkKoZOavmF4Sag2HZdNCc7vlf+S9nbDsRvO6U714LCo4TW0QaqIQftogN0gpqohSi6Q4/oBb1a9aT9Wa9j0cnrCKzhn7A+vgEcyktA=</latexit>
  • Example:
  • Theory of Bit-Vectors (BV)
  • Example:

EXPENSIVE

h (a + b) % 2 6= ((a % 2) + (b % 2)) % 2 i

14
slide-21
SLIDE 21

15

Efficient and adoptable to the task decision procedures as computational engines of verification Gas consumption estimation for smart contracts Incremental verification Integrated dynamic and static analysis Model checking mobile programs

Formal Verification in Lugano, Switzerland

slide-22
SLIDE 22
  • Need for incremental analysis
  • To avoid repetition of same tasks while checking multiple

properties of the same code

  • Incremental verification
  • Reuse information from one verification run to another
  • Speed-up in consecutive verification runs

Motivation

16

slide-23
SLIDE 23

HiFrog [TACAS’17]

17

slide-24
SLIDE 24

HiFrog [TACAS’17]

A bounded model checker

  • Uses function summaries based on interpolation

17

slide-25
SLIDE 25

HiFrog [TACAS’17]

A bounded model checker

  • Uses function summaries based on interpolation
  • With different theory reasoning (SMT-based)

17

slide-26
SLIDE 26

HiFrog [TACAS’17]

A bounded model checker

  • SMT interpolation system w.r.t different first order theories
  • Compact and readable summaries
  • Uses function summaries based on interpolation
  • With different theory reasoning (SMT-based)

17

slide-27
SLIDE 27

HiFrog [TACAS’17]

A bounded model checker

  • SMT interpolation system w.r.t different first order theories
  • Compact and readable summaries
  • Controllable interpolation system for SMT-theories
  • flexible in Size & Strength
  • Uses function summaries based on interpolation
  • With different theory reasoning (SMT-based)

17

slide-28
SLIDE 28

HiFrog [TACAS’17]

A bounded model checker

  • SMT interpolation system w.r.t different first order theories
  • Compact and readable summaries
  • Controllable interpolation system for SMT-theories
  • flexible in Size & Strength
  • Uses function summaries based on interpolation
  • Additional features:
  • User-defined summaries and Assertion optimization
  • With different theory reasoning (SMT-based)

17

slide-29
SLIDE 29

Bounded model checking [Biere et al. 1999] Task: Satisfiability check by a SAT/SMT procedure

SAT : Error found!

  • Satisfying assignment identifies an error trace

UNSAT : Program is safe

Foundations

– The BMC formula is then checked by using a SAT/SMT procedure

18

  • only look for bugs up to specific depth
slide-30
SLIDE 30

Function summarization

  • Contains only relevant information to prove properties
  • Expressed using function’s in/out parameters

Function summarization: A technique to create and use

  • ver-approximation of the function behavior

19

Usage

  • Same code, different properties
  • To approximate the corresponding functions
slide-31
SLIDE 31

Example of summaries in a C program with assertions

void main() { int y = 1; int x = nondet(); if (x > 0) y = f(x); assert(y >= 0); assert(y >= 1); } int f(int a) { if (a < 10) return a; return a – 10; }

20

slide-32
SLIDE 32

Summary

Example of summaries in a C program with assertions

(a > 0) -> (f_return >= 0)

=> Over-approximates real behavior!

void main() { int y = 1; int x = nondet(); if (x > 0) y = f(x); assert(y >= 0); assert(y >= 1); } int f(int a) { if (a < 10) return a; return a – 10; }

20

slide-33
SLIDE 33

void main() { int y = 1; int x = nondet(); if (x > 0){ assume(y >= 0); } assert(y >= 0); assert(y >= 1); }

=>

Example of summaries in a C program with assertions

Use of Summary

void main() { int y = 1; int x = nondet(); if (x > 0) y = f(x); assert(y >= 0); assert(y >= 1); } int f(int a) { if (a < 10) return a; return a – 10; } (a > 0) -> (f_return >= 0)

=>

21

slide-34
SLIDE 34

I'' I'

I'

I

Craig interpolation [Craig '57]

Definition:

  • Given mutually unsatisfiable formulas A and B, an

Interpolant is a formula I such that

  • A → I
  • I ∧ B is unsatisfiable
  • I is defined over common symbols of both A and B

A B

22

slide-35
SLIDE 35

I'' I'

I'

I

Craig interpolation [Craig '57]

Definition:

  • Given mutually unsatisfiable formulas A and B, an

Interpolant is a formula I such that

  • A → I
  • I ∧ B is unsatisfiable
  • I is defined over common symbols of both A and B

A B

I is over-approximation of A, still unsatisfiable with B

22

slide-36
SLIDE 36

Apply Craig interpolation after SMT-solver returns UNSAT

  • Iterative procedure over the set of function calls

Interpolation-based function summarization

How to use interpolation for extracting function summarization

partitioned bounded model checking (PBMC)

unwound

program

Interpolation-Based Function Summaries in Bounded Model Checking [Sery, Fedyukovich, Sharygina:HVC'11]23

slide-37
SLIDE 37

f1 f3 f2 f4 f6 f5

main

Formula construction

BMC formula created in a partitioned way: each partition represents the body

  • f a function

Partitioning BMC

24

slide-38
SLIDE 38

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

Formula construction

BMC formula created in a partitioned way: each partition represents the body

  • f a function

Partitioning BMC

24

slide-39
SLIDE 39

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

Formula construction

BMC formula created in a partitioned way: each partition represents the body

  • f a function

Partitioning BMC

24

slide-40
SLIDE 40

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

Formula construction

BMC formula created in a partitioned way: each partition represents the body

  • f a function

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Partitioning BMC

24

slide-41
SLIDE 41

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

Formula construction

BMC formula created in a partitioned way: each partition represents the body

  • f a function

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Partitioning BMC

24

slide-42
SLIDE 42

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Partitioning BMC

25

slide-43
SLIDE 43

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-44
SLIDE 44

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-45
SLIDE 45

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

A

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-46
SLIDE 46

φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

A

B φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-47
SLIDE 47

I1 φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

A

B φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-48
SLIDE 48

I1 φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-49
SLIDE 49

I1 I2 Imain I3 I4 I6 I5 φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-50
SLIDE 50

I1 I2 Imain I3 I4 I6 I5 φmain φ2 φ5 φ1 φ3 φ4 φ6 f1 f3 f2 f4 f6 f5

main

UNSAT

φ1 ˄ φ2 ˄ φ3 ˄ φmain ˄ φ4 ˄ φ5 ˄ φ6 ˄ errormain

Generation of summaries

Partitioning BMC

25

slide-51
SLIDE 51

Underlying technology

  • HiFrog - model checker for C
  • https://scm.ti-edu.ch/projects/hifrog
  • Uses CProver framework for symbolic encoding of C

programs

  • http://cprover.org [Kroening et al.]
  • Employs our open-source SMT-solver OpenSMT2
  • For SMT checks & interpolation

http://verify.inf.usi.ch/opensmt

26

slide-52
SLIDE 52

HiFrog Architecture

27

summary refiner

symbolic execution SSA slicing

SMT encoder

QF_BOOL QF_LRA QF_UF

parser storage for summaries sources + assertions assertion holds assertion violated

& error trace

SAT UNSAT

assertions

traversal

QF BOOL QF LRA QF UF

interpolation- based summaries

assertions

  • ptimizer

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

theory refiner

slide-53
SLIDE 53

HiFrog Architecture

If successful, HiFrog updates function summaries for next checks If unsuccessful, after refinement HiFrog reports violation + an error trace

27

summary refiner

symbolic execution SSA slicing

SMT encoder

QF_BOOL QF_LRA QF_UF

parser storage for summaries sources + assertions assertion holds assertion violated

& error trace

SAT UNSAT

assertions

traversal

QF BOOL QF LRA QF UF

interpolation- based summaries

assertions

  • ptimizer

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

theory refiner

slide-54
SLIDE 54 symbolic execution SSA slicing

SMT encoder

QF_LRA QF_BOOL QF_UF

HiFrog Architecture

28

summary refiner

symbolic execution SSA slicing

SMT encoder

QF_BOOL QF_LRA QF_UF

parser storage for summaries sources + assertions assertion holds assertion violated

& error trace

SAT UNSAT

assertions

traversal

QF BOOL QF LRA QF UF

interpolation- based summaries

assertions

  • ptimizer

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

theory refiner

If the SMT formula is SAT — Maybe the reachable error is spurious due to over-approximation of summaries Solution: Refine the abstraction!

  • By Error trace analysis identify summaries that appears along the error

trace

  • Replace summaries by precise representation
slide-55
SLIDE 55 symbolic execution SSA slicing

SMT encoder

QF_LRA QF_BOOL QF_UF

HiFrog Architecture

28

summary refiner

symbolic execution SSA slicing

SMT encoder

QF_BOOL QF_LRA QF_UF

parser storage for summaries sources + assertions assertion holds assertion violated

& error trace

SAT UNSAT

assertions

traversal

QF BOOL QF LRA QF UF

interpolation- based summaries

assertions

  • ptimizer

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

theory refiner

slide-56
SLIDE 56 symbolic execution SSA slicing

SMT encoder

QF_LRA QF_BOOL QF_UF

Different encoding precisions through SMT theories

29

slide-57
SLIDE 57 symbolic execution SSA slicing

SMT encoder

QF_LRA QF_BOOL QF_UF

Propositional logic (QF_BOOL) Linear Real Arithmetics(QF_LRA) Uninterpreted Functions (QF_UF)

Different encoding precisions through SMT theories

29

slide-58
SLIDE 58 symbolic execution SSA slicing

SMT encoder

QF_LRA QF_BOOL QF_UF

Propositional logic (QF_BOOL) Linear Real Arithmetics(QF_LRA) Uninterpreted Functions (QF_UF)

Different encoding precisions through SMT theories Trade off between level of abstraction and precision! A key factor for success is to find a level of abstraction that is sufficiently precise but not too expensive to reason

  • n

Abstraction level Precision

29

slide-59
SLIDE 59 symbolic execution SSA slicing

SMT encoder

QF_LRA QF_BOOL QF_UF

HiFrog Architecture

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

30

summary refiner

symbolic execution SSA slicing

SMT encoder

QF_BOOL QF_LRA QF_UF

parser storage for summaries sources + assertions assertion holds assertion violated

& error trace

SAT UNSAT

assertions

traversal

QF BOOL QF LRA QF UF

interpolation- based summaries

assertions

  • ptimizer

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

theory refiner

slide-60
SLIDE 60

Interpolation for various theories

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

Each theory has its own interpolation procedure

31

slide-61
SLIDE 61

Interpolation for QF_BOOL Interpolation for QF_LRA Interpolation for QF_UF

Interpolation for various theories

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

Each theory has its own interpolation procedure

31

slide-62
SLIDE 62

Interpolation for QF_BOOL Interpolation for QF_LRA Interpolation for QF_UF

Interpolation for various theories

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

Each theory has its own interpolation procedure

more compact encoding

31

slide-63
SLIDE 63

Interpolation for QF_BOOL Interpolation for QF_LRA Interpolation for QF_UF

Interpolation for various theories

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

Each theory has its own interpolation procedure

more compact encoding Readability

31

slide-64
SLIDE 64

Interpolation for QF_BOOL Interpolation for QF_LRA Interpolation for QF_UF

Interpolation for various theories

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

Each theory has its own interpolation procedure

more compact encoding Readability precision

31

slide-65
SLIDE 65

Interpolation for QF_BOOL Interpolation for QF_LRA Interpolation for QF_UF

Interpolation for various theories

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

Generated interpolants are controllable w.r.t Size and Strength

Each theory has its own interpolation procedure

more compact encoding Readability precision

31

slide-66
SLIDE 66

UF and LRA interpolation system

  • Flexibility in generating interpolants control expressiveness of summaries
  • Labeling functions can be partially ordered with respect to strength
  • Proof reduction: process the resolution proof to obtain smaller interplants
  • itps [McMillan '05]
  • Custom

[Alt PhD Thesis '17]

Different algorithms of Interpolation

  • itps [Alt et al. ’17]

[Fuchs et al. ’09]

  • itpw [Alt PhD Thesis]
  • itpr [Alt et al. '17]

QF_UF Alg.

QF_Bool Alg.

  • Ms [McMillan ,05]
  • P [Pudlák ‘97]
  • Mw [D’Silva et al. '10]
  • PS [Alt et al. '15]
  • PSw [Alt et al. '15]
  • PSs [Alt et al. '15]
  • Dmin [D’Silva et al. '10]

QF_LRA Alg.

32

slide-67
SLIDE 67

User-Provided Summaries

33

slide-68
SLIDE 68

User-Provided Summaries

33

slide-69
SLIDE 69

User-Provided Summaries

(nonlin_return = 1) Summary of function:

33

slide-70
SLIDE 70

User-Provided Summaries

(nonlin_return = 1) Summary of function:

33

slide-71
SLIDE 71

User-Provided Summaries

(nonlin_return = 1) Summary of function:

33

slide-72
SLIDE 72

User-Provided Summaries

(nonlin_return = 1) Summary of function:

33

➢ We can inject any summary

we want for functions !

slide-73
SLIDE 73

34

a pre-compiled Linux-binary available at the Virtual Machine at http://verify.inf.usi.ch/hifrog/binary

slide-74
SLIDE 74

34

Demo

a pre-compiled Linux-binary available at the Virtual Machine at http://verify.inf.usi.ch/hifrog/binary

slide-75
SLIDE 75

HiFrog evaluation

C Benchmarks #assertion QF_UF QF_LRA QF_Bool token.c 54 34 34 34 s3.c 131 18 21 26 mem.c 149 96 96 96 disk.c 79 6 6 23 ddv.c 152 47 47 142 café.c 115 15 20 30 tcas_asrt.c 162 16 29 29 p2p.c 244 8 20 94 floppy1.c 18 15 16 18 floppy2.c 21 15 16 21 floppy4.c 22 11 13 22 floppy3.c 19 13 14 19 diskperf1.c 14 9 10 14 diskperf2.c 4 2 2 4 kbfilter1.c 10 10 10 10 kbfilter2.c 13 13 13 13 kbfilter3.c 14 11 11 14 Percentage of success 50.65% 58% 100% 35

slide-76
SLIDE 76

Experimental Results

Running time by QF_BOOL against QF_UF and QF_LRA.

36

slide-77
SLIDE 77

Recent Related Work

  • FunFrog: old generation of HiFrog [Sery, Fedyukovich, Sharygina:

ATVA’12]

  • eVolCheck: Incremental upgrade checker for C [Fedyukovich et. al 2013]
  • CBMC [Kroening et. al 2004]
  • A BMC for C with incremental capabilities of a SAT solver (limited)
  • ESBMC [Cordeiro 2016]
  • SMT-based tool based on CProver infrastructure, no incrementality
  • Viper [Muller et al. 2016]
  • A deductive verification tool based on modular verification
  • Dafny [Leino et al. 2015]
  • A deductive verification tool cashing the intermediate verification results

37

slide-78
SLIDE 78

Future and On-going Work

  • Automatic theory Refinement
  • Support for other SMT-theories: LIA, Bit-Vector,…
  • Parallel verification of several assertions
  • Extend to loop summaries (invariants)

38

slide-79
SLIDE 79

Conclusion

  • HiFrog function-summarization-based BMC
  • Supports SMT as the modelling and summarization language
  • QF_UF, QF_LRA, QF_LIA and propositional logic

Other features of HiFrog

  • User-Provided Summaries
  • Removal of redundant assertions
  • Counter-example guided summary and theory refinement
  • Generating multitude of different interpolants and giving

more control to the model checker over them w.r.t Size and Strength

39

slide-80
SLIDE 80

Conclusion

  • HiFrog function-summarization-based BMC
  • Supports SMT as the modelling and summarization language
  • QF_UF, QF_LRA, QF_LIA and propositional logic

Other features of HiFrog

  • User-Provided Summaries
  • Removal of redundant assertions
  • Counter-example guided summary and theory refinement
  • Generating multitude of different interpolants and giving

more control to the model checker over them w.r.t Size and Strength

39

Questions?

slide-81
SLIDE 81

Thank you!

P .S. We are seeking motivated PhD students

www.verify.inf.usi.ch

Contact: natasha.sharygina@usi.ch

slide-82
SLIDE 82

summary refiner

symbolic execution SSA slicing

SMT encoder

QF_BOOL QF_LRA QF_UF

parser summaries sources + assertions assertion holds assertion violated

& error trace SAT UNSAT

assertions

traversal

QF BOOL QF LRA QF UF user-defined summaries interpolation- based summaries

assertions

  • ptimizer

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

theory refiner

selection of precision and size s e l e c t i
  • n
  • f
t h e
  • r
y

settings

a pre-compiled Linux-binary available at the Virtual Machine at http://verify.inf.usi.ch/hifrog/binary

41

slide-83
SLIDE 83

summary refiner

symbolic execution SSA slicing

SMT encoder

QF_BOOL QF_LRA QF_UF

parser summaries sources + assertions assertion holds assertion violated

& error trace SAT UNSAT

assertions

traversal

QF BOOL QF LRA QF UF user-defined summaries interpolation- based summaries

assertions

  • ptimizer

Interpolating SMT solver

theory solvers proof compressor itp for QF_UF itp for QF_BOOL itp for QF_LRA proof

theory refiner

selection of precision and size s e l e c t i
  • n
  • f
t h e
  • r
y

settings

Questions?

a pre-compiled Linux-binary available at the Virtual Machine at http://verify.inf.usi.ch/hifrog/binary

41