Motivation: No Formal Theory Motivation: No Formal Theory Master - - PowerPoint PPT Presentation

motivation no formal theory motivation no formal theory
SMART_READER_LITE
LIVE PREVIEW

Motivation: No Formal Theory Motivation: No Formal Theory Master - - PowerPoint PPT Presentation

On the Nature of Symbolic Execution 1 Frank de Boer (Joint work with Marcello Bonsangue) IFIP WG 2.2, 2019 1 FM 2019 Motivation: No Formal Theory Motivation: No Formal Theory Master course at Leiden University Motivation: No Formal Theory


slide-1
SLIDE 1

On the Nature of Symbolic Execution1

Frank de Boer (Joint work with Marcello Bonsangue) IFIP WG 2.2, 2019

1FM 2019

slide-2
SLIDE 2

Motivation: No Formal Theory

slide-3
SLIDE 3

Motivation: No Formal Theory

Master course at Leiden University

slide-4
SLIDE 4

Motivation: No Formal Theory

Master course at Leiden University Tools

◮ No formal specification (of correctness/completeness)

slide-5
SLIDE 5

Basic Symbolic Execution

slide-6
SLIDE 6

Basic Symbolic Execution

Programming expressions

e := x | op(e1, . . . , en) where x is a simple variable of a basic type.

slide-7
SLIDE 7

Basic Symbolic Execution

Programming expressions

e := x | op(e1, . . . , en) where x is a simple variable of a basic type.

Substitution σ : Var → Expr

xσ = σ(x)

  • p(e1, . . . , en)σ

= op(e1σ, . . . , enσ)

slide-8
SLIDE 8

Basic Symbolic Execution

Programming expressions

e := x | op(e1, . . . , en) where x is a simple variable of a basic type.

Substitution σ : Var → Expr

xσ = σ(x)

  • p(e1, . . . , en)σ

= op(e1σ, . . . , enσ)

Symbolic configuration

S, σ, φ where

◮ S denotes the statement to be executed, ◮ σ denotes the current substitution, ◮ Boolean condition φ denotes the path condition.

slide-9
SLIDE 9

Symbolic Transition System

slide-10
SLIDE 10

Symbolic Transition System

Assignment

x = e; S, σ, φ → S, σ[x = eσ], φ where σ[x = e](y) = σ(y) if x and y are distinct variables, and σ[x = e](x) = e otherwise.

slide-11
SLIDE 11

Symbolic Transition System

Assignment

x = e; S, σ, φ → S, σ[x = eσ], φ where σ[x = e](y) = σ(y) if x and y are distinct variables, and σ[x = e](x) = e otherwise.

Choice

◮ if B {S1}{S2}; S, σ, φ → S1; S, σ, φ ∧ Bσ ◮ if B {S1}{S2}; S, σ, φ → S2; S, σ, φ ∧ ¬Bσ

slide-12
SLIDE 12

Symbolic Transition System

Assignment

x = e; S, σ, φ → S, σ[x = eσ], φ where σ[x = e](y) = σ(y) if x and y are distinct variables, and σ[x = e](x) = e otherwise.

Choice

◮ if B {S1}{S2}; S, σ, φ → S1; S, σ, φ ∧ Bσ ◮ if B {S1}{S2}; S, σ, φ → S2; S, σ, φ ∧ ¬Bσ

Iteration

◮ while B {S}; S′, σ, φ → S; while B {S}; S′, σ, φ ∧ Bσ ◮ while B {S}; S′, σ, φ → S′, σ, φ ∧ ¬Bσ

slide-13
SLIDE 13

Correctness

slide-14
SLIDE 14

Correctness

Concrete transitions

S, V → S′, V ′ where V : Var → Val

slide-15
SLIDE 15

Correctness

Concrete transitions

S, V → S′, V ′ where V : Var → Val

Theorem

If S, id, true →∗ S′, σ, φ and V(φ) = true then S, V →∗ S′, V ◦ σ where V ◦ σ(x) = V(σ(x)).

slide-16
SLIDE 16

Completeness

slide-17
SLIDE 17

Completeness

Relating symbolic and concrete configurations

S, V ≃ S, σ, φ if V = V0 ◦ σ and V0(φ) = true, for some valuation V0.

slide-18
SLIDE 18

Completeness

Relating symbolic and concrete configurations

S, V ≃ S, σ, φ if V = V0 ◦ σ and V0(φ) = true, for some valuation V0.

Theorem (simulation)

S, V ≃ S, σ, φ and S, V → S′, V ′ implies the existence of a corresponding symbolic transition S, σ, φ → S′, σ′, φ′ such that S′, V ′ ≃ S′, σ′, φ′.

slide-19
SLIDE 19

OO

slide-20
SLIDE 20

OO

Variables

◮ Global variables (main statement) ◮ Local variables (formal parameters of methods) ◮ Instance variables (class definitions)

slide-21
SLIDE 21

OO

Variables

◮ Global variables (main statement) ◮ Local variables (formal parameters of methods) ◮ Instance variables (class definitions)

Programming expressions

e := x | op(e1, . . . , en) (In the main statement only global variables are used).

slide-22
SLIDE 22

OO

Variables

◮ Global variables (main statement) ◮ Local variables (formal parameters of methods) ◮ Instance variables (class definitions)

Programming expressions

e := x | op(e1, . . . , en) (In the main statement only global variables are used).

Syntax of heap variables H and heap expressions E

H := x | H.y E := H | op(E1, . . . , En) , where x is a global variable.

slide-23
SLIDE 23

Symbolic Heap Representation

slide-24
SLIDE 24

Symbolic Heap Representation

Symbolic heap σ

σ denotes a substitution which assigns to each heap variable H a heap expression E.

slide-25
SLIDE 25

Symbolic Heap Representation

Symbolic heap σ

σ denotes a substitution which assigns to each heap variable H a heap expression E.

Local environment τ

τ denotes a substitution which assigns to each formal parameter x a heap expression E.

slide-26
SLIDE 26

Symbolic Heap Representation

Symbolic heap σ

σ denotes a substitution which assigns to each heap variable H a heap expression E.

Local environment τ

τ denotes a substitution which assigns to each formal parameter x a heap expression E.

Application substitution θ = τ ∪ σ

xθ = σ(x) global variable xθ = τ(x) local variable xθ = σ(τ(this).x) instance variable

  • p(E1, . . . , En)θ

= op(E1θ, . . . , Enθ)

slide-27
SLIDE 27

Symbolic Heap Update

slide-28
SLIDE 28

Symbolic Heap Update

Update global variable

◮ σ[x = E](x) = E ◮ σ[x = E](H) = σ(H), for any other heap variable H

slide-29
SLIDE 29

Symbolic Heap Update

Update global variable

◮ σ[x = E](x) = E ◮ σ[x = E](H) = σ(H), for any other heap variable H

Update instance variable

◮ σ[H.x = E](H′.x) = if σ(H′) = σ(H) then E else σ(H′.x) fi ◮ σ[H.x = E](H′) = σ(H′), for any other heap variable H′

slide-30
SLIDE 30

Symbolic Transition System

slide-31
SLIDE 31

Symbolic Transition System

Assignment global variable

(⊥, x = e; S), σ, φ → (⊥, S), σ[x = eσ], φ

slide-32
SLIDE 32

Symbolic Transition System

Assignment global variable

(⊥, x = e; S), σ, φ → (⊥, S), σ[x = eσ], φ

Assignment instance variable

(τ, x = e; S) · Σ, σ, φ → (τ, S) · Σ, σ[τ(this).x = eθ], φ where θ = τ ∪ σ.

slide-33
SLIDE 33

Symbolic Transition System

Assignment global variable

(⊥, x = e; S), σ, φ → (⊥, S), σ[x = eσ], φ

Assignment instance variable

(τ, x = e; S) · Σ, σ, φ → (τ, S) · Σ, σ[τ(this).x = eθ], φ where θ = τ ∪ σ.

Object creation

(τ, x = new C; S) · Σ, σ, φ → (τ[x = y], S) · Σ, σ′, φ where σ′(y.z) = nil.

slide-34
SLIDE 34

Symbolic Transition System (Cont’d)

slide-35
SLIDE 35

Symbolic Transition System (Cont’d)

Method call

Given a method declaration m(¯ u){S}, we have (τ, y = e0.m(¯ e); S′) · Σ, σ, φ → (τ ′.S) · (τ, y =?; S′) · Σ, σ, φ′ where

◮ τ ′(¯

u) = ¯ e(τ ∪ σ)

◮ τ ′(this) = e0(τ ∪ σ)

slide-36
SLIDE 36

Symbolic Transition System (Cont’d)

Method call

Given a method declaration m(¯ u){S}, we have (τ, y = e0.m(¯ e); S′) · Σ, σ, φ → (τ ′.S) · (τ, y =?; S′) · Σ, σ, φ′ where

◮ τ ′(¯

u) = ¯ e(τ ∪ σ)

◮ τ ′(this) = e0(τ ∪ σ)

Method return

(τ, return e) · (τ ′, x =?; S) · Σ, σ, φ → (τ ′[x = eθ], S) · Σ, σ, φ where θ = (τ ∪ σ).

slide-37
SLIDE 37

Concrete Transition System

slide-38
SLIDE 38

Concrete Transition System

Valuation

◮ V(H) = V(H′) implies V(H.x) = V(H′.x), ◮ V(x) = V(x′),

for any two distinct global variables x and x′ which do not appear in the main statement (unique name assumption).

slide-39
SLIDE 39

Concrete Transition System

Valuation

◮ V(H) = V(H′) implies V(H.x) = V(H′.x), ◮ V(x) = V(x′),

for any two distinct global variables x and x′ which do not appear in the main statement (unique name assumption).

Heap update

◮ V[H.x = v](H′.x) =

v if V(H′) = V(H) V(H′.x)

  • therwise

◮ V[H.x = v](H′) = V(H′), for any other heap variable H′.

slide-40
SLIDE 40

Concrete Transition System

Valuation

◮ V(H) = V(H′) implies V(H.x) = V(H′.x), ◮ V(x) = V(x′),

for any two distinct global variables x and x′ which do not appear in the main statement (unique name assumption).

Heap update

◮ V[H.x = v](H′.x) =

v if V(H′) = V(H) V(H′.x)

  • therwise

◮ V[H.x = v](H′) = V(H′), for any other heap variable H′.

Assignment instance variable

(L, x = e; S) · Σ, V → (L, S) · Σ, V[H.x = v] where V(H) = L(this) and v = (L ∪ V)(e).

slide-41
SLIDE 41

Correctness

slide-42
SLIDE 42

Correctness

Theorem

If (⊥, S), id, true →∗ (τ, S′) · Σ, σ, φ and V(φ) = true, where V is an initial valuation, then (⊥, S), V →∗ (V ◦ τ, S′) · V ◦ Σ, V ◦ σ where

◮ (V ◦ τ)(x) = V(τ(x)) ◮ (V ◦ σ)(H) = V(σ(H))

slide-43
SLIDE 43

Conclusion

slide-44
SLIDE 44

Conclusion

Extensions

◮ Arrays ◮ Multithreading (Java) ◮ Concurrent objects ◮ Concolic execution ◮ Backward symbolic execution

slide-45
SLIDE 45

Conclusion

Extensions

◮ Arrays ◮ Multithreading (Java) ◮ Concurrent objects ◮ Concolic execution ◮ Backward symbolic execution

Implementation

◮ Finite representation ◮ Optimization aliasing

slide-46
SLIDE 46

Conclusion

Extensions

◮ Arrays ◮ Multithreading (Java) ◮ Concurrent objects ◮ Concolic execution ◮ Backward symbolic execution

Implementation

◮ Finite representation ◮ Optimization aliasing

Related work

A generic framework for symbolic execution: A coinductive approach. By D. Lucanu, V. Rusu, and A. Arusoaie. In Journal of Symbolic Computation 80(1):125–163, Elsevier,