Symbolic Shape Analysis Thomas Wies University of Freiburg, Germany - - PowerPoint PPT Presentation

symbolic shape analysis
SMART_READER_LITE
LIVE PREVIEW

Symbolic Shape Analysis Thomas Wies University of Freiburg, Germany - - PowerPoint PPT Presentation

Symbolic Shape Analysis Thomas Wies University of Freiburg, Germany Motivation class SortedList { private static Node f i r s t ; public static specvar content / : : : objset ; vardefs v = n u l l next " content ==


slide-1
SLIDE 1

Symbolic Shape Analysis

Thomas Wies

University of Freiburg, Germany

slide-2
SLIDE 2

Motivation

class SortedList { private static Node f i r s t ; /∗ : public static specvar content : :

  • bjset ;

vardefs " content == { v . v = n u l l ∧ next ∗ f i r s t v } " ; invariant " tree [ next ] " ; invariant "∀ v . v ∈ content ∧ v . next = n u l l − → v . . Node . data ≤ v . next . data " ; ∗/ public static void i n s e r t (Node n ) /∗ : requires "n = n u l l ∧ n / ∈ content " modifies content ensures " content = old content ∪ { n } " ∗/ { Node prev = n u l l ; Node curr = f i r s t ; while ( ( curr ! = n u l l ) && ( curr . data < n . data ) ) { prev = curr ; curr = curr . next ; } n . next = curr ; i f ( prev ! = n u l l ) prev . next = n ; else f i r s t = n ; } }

Thomas Wies Symbolic Shape Analysis 2 / 34

slide-3
SLIDE 3

Motivation

Bohne, Symbolic Shape Analysis Implementation

Properties verified in previous example:

  • correctly inserts the element into the list

(relates pre- and post states of procedure)

  • list remains sorted
  • data structure remains acyclic list
  • no null pointer dereferences

Bohne

  • accepts annotated Java programs as input
  • annotations are user-specied formulae:
  • data structure invariants
  • procedure contracts (pre- and post conditions)
  • automatically computes quantified loop invariants
  • proves desired properties and absence of errors

Thomas Wies Symbolic Shape Analysis 3 / 34

slide-4
SLIDE 4

Motivation

Predicate Abstraction

  • take transition graph (nodes are states)
  • define partitioning of nodes through state predicates
  • abstract transition graph is graph of abstract nodes
  • abstract nodes are equivalence classes of concrete nodes

infinite state space

Thomas Wies Symbolic Shape Analysis 4 / 34

slide-5
SLIDE 5

Motivation

Predicate Abstraction

  • take transition graph (nodes are states)
  • define partitioning of nodes through state predicates
  • abstract transition graph is graph of abstract nodes
  • abstract nodes are equivalence classes of concrete nodes

infinite state space

P1 ∧ ¬P2 ∧ P3

state predicates: P1, P2, P3

Thomas Wies Symbolic Shape Analysis 4 / 34

slide-6
SLIDE 6

Motivation

Shape Analysis à la Sagiv, Reps, and Wilhelm

  • states are graphs
  • define partitioning of nodes through predicates on nodes
  • abstract states are graphs of abstract nodes
  • abstract nodes are equivalence classes of concrete nodes

y

next next next

x

next next next

Thomas Wies Symbolic Shape Analysis 5 / 34

slide-7
SLIDE 7

Motivation

Shape Analysis à la Sagiv, Reps, and Wilhelm

  • states are graphs
  • define partitioning of nodes through predicates on nodes
  • abstract states are graphs of abstract nodes
  • abstract nodes are equivalence classes of concrete nodes

y

next next next

x

next next next

Thomas Wies Symbolic Shape Analysis 5 / 34

slide-8
SLIDE 8

Motivation

shape analysis = 2predicate abstraction

Thomas Wies Symbolic Shape Analysis 6 / 34

slide-9
SLIDE 9

Motivation

Why go symbolic?

Thomas Wies Symbolic Shape Analysis 7 / 34

slide-10
SLIDE 10

Motivation

Apply not only idea, but also techniques of predicate abstraction.

Thomas Wies Symbolic Shape Analysis 8 / 34

slide-11
SLIDE 11

Motivation

Generic Benefits of Predicate Abstraction

  • use formulae to represent infinite sets of states
  • no need to define meaning of abstract values
  • abstract domain ⊆ concrete domain
  • abstraction = entailment

| =

Thomas Wies Symbolic Shape Analysis 9 / 34

slide-12
SLIDE 12

Motivation

Generic Benefits of Predicate Abstraction

  • use formulae to represent infinite sets of states
  • no need to define meaning of abstract values
  • abstract domain ⊆ concrete domain
  • abstraction = entailment

| =

  • use reasoning procedures
  • automation
  • separation of concerns (black-boxing)
  • soundness by construction, loss of precision identifiable
  • get leverage from theorem proving community
  • abstraction = provable entailments

Thomas Wies Symbolic Shape Analysis 9 / 34

slide-13
SLIDE 13

Motivation

Generic Benefits of Predicate Abstraction

  • use formulae to represent infinite sets of states
  • no need to define meaning of abstract values
  • abstract domain ⊆ concrete domain
  • abstraction = entailment

| =

  • use reasoning procedures
  • automation
  • separation of concerns (black-boxing)
  • soundness by construction, loss of precision identifiable
  • get leverage from theorem proving community
  • abstraction = provable entailments

  • abstraction refinement
  • more automation
  • symbolic execution of counterexamples
  • abstract domain ⊂ refined abstract domain

Thomas Wies Symbolic Shape Analysis 9 / 34

slide-14
SLIDE 14

Symbolic Shape Analysis

Outline

1 Boolean heaps (abstract domain) 2 Cartesian post (abstract transformer) 3 Abstraction refinement

Thomas Wies Symbolic Shape Analysis 10 / 34

slide-15
SLIDE 15

Boolean Heaps

Boolean Heaps

Partition heap according to finitely many predicates on heap objects. P1 = { v | v = x } P2 = { v | v = null } P3 = { v | next∗(x, v) } P1 ∧ ¬P2 ∧ P3 ¬P1 ∧ ¬P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x . . . null

next next next next

Describe partitioning as a universally quantified formula ∀ v . P1 ∧ ¬P2 ∧ P3 ∨ ¬P1 ∧ ¬P2 ∧ P3 ∨ ¬P1 ∧ P2 ∧ P3 ➜ Boolean heaps

Thomas Wies Symbolic Shape Analysis 11 / 34

slide-16
SLIDE 16

Boolean Heaps

Abstract domain = {sets of Boolean heaps}

Abstract element

  • i

∀ v .

  • j
  • k

Pi,j,k(v)

  • abstract node
  • Boolean heap
  • set of Boolean heaps

∨ ∨

Boolean heap

  • abstract node
  • set of Boolean heaps

Thomas Wies Symbolic Shape Analysis 12 / 34

slide-17
SLIDE 17

Boolean Heaps

Symbolic shape analysis

  • i

∀ v .

  • j
  • k

Pi,j,k(v)

  • abstract node
  • Boolean heap ∼

= abstract state

  • set of Boolean heaps

➜ sets of sets of bit-vectors (sets of BDDs) Predicate abstraction

  • i
  • j

Pi,j

abstract state

  • sets of abstract states

➜ sets of bit-vectors (BDDs) ➜ Boolean heaps provide extra precision needed for shape analysis.

Thomas Wies Symbolic Shape Analysis 13 / 34

slide-18
SLIDE 18

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

How to compute abstract post on Boolean heaps? post#(H) = ?

Thomas Wies Symbolic Shape Analysis 14 / 34

slide-19
SLIDE 19

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

How to compute abstract post on Boolean heaps? post#(H) = α ◦ post ◦ γ(H) post# is most precise abstract post, but it is also hard to compute.

Thomas Wies Symbolic Shape Analysis 14 / 34

slide-20
SLIDE 20

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

How to compute abstract post on Boolean heaps? post#(H) = α ◦ post ◦ γ(H) post# is most precise abstract post, but it is also hard to compute. Bohne implements an abstraction of post# that can be computed efficiently. Next slides: Cartesian post.

Thomas Wies Symbolic Shape Analysis 14 / 34

slide-21
SLIDE 21

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

P1 = { v | v = x } P2 = { v | next∗(v, null) } P3 = { v | next∗(x, v) } P1 ∧ P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null

next next next

∀ v . P1 ∧ P2 ∧ P3 ∨ ¬P1 ∧ P2 ∧ P3

Thomas Wies Symbolic Shape Analysis 15 / 34

slide-22
SLIDE 22

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

P1 = { v | v = x } P2 = { v | next∗(v, null) } P3 = { v | next∗(x, v) } P1 ∧ P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null

next next next

α ◦ postc ◦ γ(∀ v . P1 ∧ P2 ∧ P3 ∨ ¬P1 ∧ P2 ∧ P3) for command c = (x:=x.next)

Thomas Wies Symbolic Shape Analysis 15 / 34

slide-23
SLIDE 23

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

P1 = { v | v = x } P2 = { v | next∗(v, null) } P3 = { v | next∗(x, v) } P1 ∧ P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null

next next next

α ◦ postc ◦ γ(∀ v . P1 ∧ P2 ∧ P3 ∨ ¬P1 ∧ P2 ∧ P3) for command c = (x:=x.next) x null

next next next

Thomas Wies Symbolic Shape Analysis 15 / 34

slide-24
SLIDE 24

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

P1 = { v | v = x } P2 = { v | next∗(v, null) } P3 = { v | next∗(x, v) } P1 ∧ P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null

next next next

α ◦ postc ◦ γ(∀ v . P1 ∧ P2 ∧ P3 ∨ ¬P1 ∧ P2 ∧ P3) for command c = (x:=x.next) ¬P1 ∧ P2 ∧ ¬P3 P1 ∧ P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null

next next next

∀ v . ¬P1 ∧ P2 ∧ ¬P3 ∨ P1 ∧ P2 ∧ P3 ∨ ¬P1 ∧ P2 ∧ P3

Thomas Wies Symbolic Shape Analysis 15 / 34

slide-25
SLIDE 25

Abstract Transformer Cartesian Post

Abstract Post on Boolean Heaps

P1 = { v | v = x } P2 = { v | next∗(v, null) } P3 = { v | next∗(x, v) } P1 ∧ P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null

next next next

CartesianPostc(∀ v . P1 ∧ P2 ∧ P3 ∨ ¬P1 ∧ P2 ∧ P3) for command c = (x:=x.next) ¬P1 ∧ P2 ∧ ¬P3 P2 ∧ P3 x null

next next next

∀ v . ¬P1 ∧ P2 ∧ ¬P3 ∨ P2 ∧ P3

Thomas Wies Symbolic Shape Analysis 15 / 34

slide-26
SLIDE 26

Abstract Transformer Cartesian Post

Cartesian Post

CartesianPost(∀ v .

  • i

Ci) = ∀ v .

  • i
  • { P | Ci |

= wlp(P) } Cartesian Post Compute effect of heap updates locally

  • for each abstract object Ci
  • and independently for each heap predicate P

Thomas Wies Symbolic Shape Analysis 16 / 34

slide-27
SLIDE 27

Abstract Transformer Cartesian Post

Cartesian Post

CartesianPost(∀ v .

  • i

Ci) = ∀ v .

  • i
  • { P | Ci |

= wlp(P) } In practice: precompute abstract weakest preconditions wlp#(P) =

  • { φ ∈ BoolExp(Pred) | φ |

= wlp(P) } Cartesian Post Compute effect of heap updates locally

  • for each abstract object Ci
  • and independently for each heap predicate P

Thomas Wies Symbolic Shape Analysis 16 / 34

slide-28
SLIDE 28

Abstract Transformer Cartesian Post

Cartesian Post

CartesianPost(∀ v .

  • i

Ci) = ∀ v .

  • i
  • { P | Ci |

= wlp(P) } In practice: precompute abstract weakest preconditions wlp#(P) =

  • { φ ∈ BoolExp(Pred) | φ |

= wlp(P) } Cartesian Post Same advantages as for predicate abstraction: ➜ abstraction reduced to checking verification conditions ➜ requires O(nk) decision procedure calls (in practice) ➜ abstract transformer computed once for the whole analysis ➜ best abstract post computable from Cartesian post.

Thomas Wies Symbolic Shape Analysis 16 / 34

slide-29
SLIDE 29

Abstract Transformer Heap Predicate Transformer

What is wlp(P)?

where P is not an assertion on states, but defined by a formula in a variable v ranging over heap objects, such as next∗(x, v)

Thomas Wies Symbolic Shape Analysis 17 / 34

slide-30
SLIDE 30

Abstract Transformer Heap Predicate Transformer

Heap Predicates

Denotation of formulae with free variables v: [ [next(v) = x] ] = λ s ∈ State . { o ∈ Obj | nexts o = xs }

  • r [

[next(v) = x] ] = λ o ∈ Obj . { s ∈ State | nexts o = xs }

Thomas Wies Symbolic Shape Analysis 18 / 34

slide-31
SLIDE 31

Abstract Transformer Heap Predicate Transformer

Heap Predicates

Denotation of formulae with free variables v: [ [next(v) = x] ] = λ s ∈ State . { o ∈ Obj | nexts o = xs }

  • r [

[next(v) = x] ] = λ o ∈ Obj . { s ∈ State | nexts o = xs } Heap predicates HeapPred

def

= Obj → 2State [ [φ(v)] ]

def

= λ o . { s ∈ State | s, [v → o] | = φ(v) }

Thomas Wies Symbolic Shape Analysis 18 / 34

slide-32
SLIDE 32

Abstract Transformer Heap Predicate Transformer

Heap Predicate Transformers

Remember: HeapPred = Obj → 2State. Lift predicate transformers post and wlp to heap predicates. lift ∈ (2State → 2State) → HeapPred → HeapPred lift τ p = λ o . τ (p o)

Thomas Wies Symbolic Shape Analysis 19 / 34

slide-33
SLIDE 33

Abstract Transformer Heap Predicate Transformer

Heap Predicate Transformers

Remember: HeapPred = Obj → 2State. Lift predicate transformers post and wlp to heap predicates. lift ∈ (2State → 2State) → HeapPred → HeapPred lift τ p = λ o . τ (p o) Definition Heap predicate transformers : hpost, hwlp ∈ Com → HeapPred → HeapPred hpost c

def

= lift (post c) hwlp c

def

= lift (wlp c)

Thomas Wies Symbolic Shape Analysis 19 / 34

slide-34
SLIDE 34

Abstract Transformer On-Demand Abstraction

Destructive Updates and Non-local Properties

z = v x = v y = v next∗(z, v) ¬next∗(x, v) ¬next∗(y, v) z = v x = v y = v next∗(z, v) ¬next∗(x, v) ¬next∗(y, v) z = v x = v y = v next∗(z, v) next∗(x, v) ¬next∗(y, v) z = v x = v y = v ¬next∗(z, v) ¬next∗(x, v) next∗(y, v) z = v x = v y = v next∗(z, v) next∗(x, v) next∗(y, v)

z x y null

next next n e x t next

command c = (x.next:=y)

Thomas Wies Symbolic Shape Analysis 20 / 34

slide-35
SLIDE 35

Abstract Transformer On-Demand Abstraction

Destructive Updates and Non-local Properties

z = v x = v y = v next∗(z, v) ¬next∗(x, v) ¬next∗(y, v) z = v x = v y = v next∗(z, v) ¬next∗(x, v) ¬next∗(y, v) z = v x = v y = v next∗(z, v) next∗(x, v) ¬next∗(y, v) z = v x = v y = v ¬next∗(z, v) ¬next∗(x, v) next∗(y, v) z = v x = v y = v next∗(z, v) next∗(x, v) next∗(y, v)

z x y null

next next n e x t next

command c = (x.next:=y) wlp#

c (next∗(z, v)) = next∗(z, v) ∧ ¬next∗(x, v) ∨

next∗(z, v) ∧ x = v wlp#

c (P) =

  • { φ ∈ BoolExp(Pred) | φ |

= wlpc(P) }

Thomas Wies Symbolic Shape Analysis 20 / 34

slide-36
SLIDE 36

Abstract Transformer On-Demand Abstraction

Destructive Updates and Non-local Properties

z = v x = v y = v next∗(z, v) ¬next∗(x, v) ¬next∗(y, v) z = v x = v y = v next∗(z, v) ¬next∗(x, v) ¬next∗(y, v) z = v x = v y = v next∗(z, v) next∗(x, v) ¬next∗(y, v) z = v x = v y = v ¬next∗(z, v) ¬next∗(x, v) next∗(y, v) z = v x = v y = v next∗(z, v) next∗(x, v) next∗(y, v)

z x y null

next next n e x t next

H

command c = (x.next:=y) wlp#

c (H, next∗(z, v)) = next∗(z, v) ∧ ¬next∗(x, v) ∨

next∗(z, v) ∧ x = v ∨ y = v ∨ next∗(y, v) wlp#

c (H, P) =

  • { φ ∈ BoolExp(Pred) | H ∧ φ |

= wlpc(P) }

Thomas Wies Symbolic Shape Analysis 20 / 34

slide-37
SLIDE 37

Abstract Transformer On-Demand Abstraction

Context-sensitive Cartesian Post

α ◦ postγ ◦ (H) | = CartesianPost(Γ, ∀ v .

  • i

Ci as H) = ∀ v .

  • i
  • { P | Γ ∧ Ci |

= wlp(P) } Context-sensitive Cartesian Post Compute effect of heap updates locally

  • for each abstract object Ci
  • and independently for each heap predicate P
  • but take into account some global information Γ with H |

= Γ

Thomas Wies Symbolic Shape Analysis 21 / 34

slide-38
SLIDE 38

Abstract Transformer On-Demand Abstraction

On-Demand Abstraction

CFG

ℓ0 ℓ1 ℓ2 c1 c4 c2 c3 ℓ0 : ∀ v . φ1 ∨ ∀ v . φ2 ∨ . . . Initial Boolean heaps

Thomas Wies Symbolic Shape Analysis 22 / 34

slide-39
SLIDE 39

Abstract Transformer On-Demand Abstraction

On-Demand Abstraction

CFG

ℓ0 ℓ1 ℓ2 c1 c4 c2 c3 ℓ0 : ∀ v . φ1 ∨ ∀ v . φ2 ∨ . . . ℓ2 : ∀ v . φ3 ∨ ∀ v . φ4

c2

CartesianPost(c2, Γ, (∀ v . φ1) ∨(∀ v . φ2) ∨ . . . )

Thomas Wies Symbolic Shape Analysis 22 / 34

slide-40
SLIDE 40

Abstract Transformer On-Demand Abstraction

On-Demand Abstraction

CFG

ℓ0 ℓ1 ℓ2 c1 c4 c2 c3 ℓ0 : ∀ v . φ1 ∨ ∀ v . φ2 ∨ . . . ℓ2 : ∀ v . φ3 ∨ ∀ v . φ4

c2

ℓ1 : ∀ v . φ5

c1

CartesianPost(c3, Γ, (∀ v . φ1) ∨(∀ v . φ2) ∨ . . . )

Thomas Wies Symbolic Shape Analysis 22 / 34

slide-41
SLIDE 41

Abstract Transformer On-Demand Abstraction

On-Demand Abstraction

CFG

ℓ0 ℓ1 ℓ2 c1 c4 c2 c3 ℓ0 : ∀ v . φ1 ∨ ∀ v . φ2 ∨ . . . ℓ2 : ∀ v . φ3 ∨ ∀ v . φ4

c2

ℓ1 : ∀ v . φ5

c1

ℓ1 : ∀ v . φ6

c3

CartesianPost(c3, Γ, ∀ v . φ5)

Thomas Wies Symbolic Shape Analysis 22 / 34

slide-42
SLIDE 42

Abstract Transformer On-Demand Abstraction

On-Demand Abstraction

CFG

ℓ0 ℓ1 ℓ2 c1 c4 c2 c3 ℓ0 : ∀ v . φ1 ∨ ∀ v . φ2 ∨ . . . ℓ2 : ∀ v . φ3 ∨ ∀ v . φ4

c2

ℓ1 : ∀ v . φ5

c1

ℓ1 : ∀ v . φ6

c3

ℓ1 : ∀ v . φ7

c3

CartesianPost(c3, Γ, ∀ v . φ6)

  • abstraction takes into account

already discovered Boolean heaps at each prog. location.

  • abstract transformers are

precomputed and recomputed

  • n-demand only if Γ changes.
  • decision procedure calls are

cached ’semantically’ to make recomputation fast.

Thomas Wies Symbolic Shape Analysis 22 / 34

slide-43
SLIDE 43

Abstraction Refinement

Outline

1 Boolean heaps (abstract domain) 2 Cartesian post (abstract transformer) 3 Abstraction refinement

Thomas Wies Symbolic Shape Analysis 23 / 34

slide-44
SLIDE 44

Abstraction Refinement

Counterexample Guided Abstraction Refinement

Abstract error trace P0 P1 P2 P3 s0 s1 s2 s3

c0 c1 c2 assert(F) s3 | = F

assertion fails

Thomas Wies Symbolic Shape Analysis 24 / 34

slide-45
SLIDE 45

Abstraction Refinement

Counterexample Guided Abstraction Refinement

Abstract error trace P0 P1 P2 P3 s0 s1 s2 s3

c0 c1 c2 assert(F) s3 | = F s2 | = wlpc2(F)

backwards analyze error trace

Thomas Wies Symbolic Shape Analysis 24 / 34

slide-46
SLIDE 46

Abstraction Refinement

Counterexample Guided Abstraction Refinement

Abstract error trace P0 P1 P2 P3 s0 s1 s2 s3

c0 c1 c2 assert(F) s3 | = F s2 | = wlpc2(F) s1 | = wlpc1;c2(F)

error trace is spurious x

Thomas Wies Symbolic Shape Analysis 24 / 34

slide-47
SLIDE 47

Abstraction Refinement

Counterexample Guided Abstraction Refinement

Abstract error trace P0 P1 P2 P3 s0 s1 s2 s3

c0 c1 c2 assert(F) s3 | = F s2 | = wlpc2(F) s1 | = wlpc1;c2(F)

error trace is spurious x Lazy Abstraction [Henzinger, Jhala, Majumdar POPL 2002] Add new predicates along spurious part of path... Preds′

3 = P3 ∪ atoms(F)

Preds′

2 = P2 ∪ atoms(wlpc2(F))

...and keep safe part of path P0 P1 P′

2

P′

3

s0 s1 s2 s3

c0 c1 c2 assert(F)

Thomas Wies Symbolic Shape Analysis 24 / 34

slide-48
SLIDE 48

Abstraction Refinement Progress

Progress of Abstraction Refinement

Theorem (Progress) If analysis is based on best abstract post post# then refinement step eliminates spurious error trace. Without progress abstraction refinement might run into a deadlock where the same counterexample is produced over and over again, but no new predicates are generated.

Thomas Wies Symbolic Shape Analysis 25 / 34

slide-49
SLIDE 49

Abstraction Refinement Progress

Progress of Abstraction Refinement

Theorem (Progress) If analysis is based on best abstract post post# then refinement step eliminates spurious error trace. Without progress abstraction refinement might run into a deadlock where the same counterexample is produced over and over again, but no new predicates are generated. Does progress property also hold for Cartesian post? Is progress even relevant in practice?

Thomas Wies Symbolic Shape Analysis 25 / 34

slide-50
SLIDE 50

Abstraction Refinement Progress

List Reversal

null first . . .

next next next

method entry first e . . .

next next next

loop entry null first e . . .

next next next

  • 1. loop iter.

null first e . . .

next next next

  • 2. loop iter.

Thomas Wies Symbolic Shape Analysis 26 / 34

slide-51
SLIDE 51

Abstraction Refinement Progress

List Reversal

null first . . .

next next next

method entry first e . . .

next next next

loop entry null first e . . .

next next next

  • 1. loop iter.

null first e . . .

next next next

  • 2. loop iter.

next n e x t n e x t next

Thomas Wies Symbolic Shape Analysis 26 / 34

slide-52
SLIDE 52

Abstraction Refinement Progress

How do we maintain progress property for Cartesian post? Use counterexample to refine not only abstract domain, but also abstract post. P0 P1 P2 P3 s0 s1 s2 s3

c0 c1 c2 assert(F) s3 | = F s2 | = wlpc2(F) s1 | = wlpc1;c2(F)

Thomas Wies Symbolic Shape Analysis 27 / 34

slide-53
SLIDE 53

Abstraction Refinement Progress

How do we maintain progress property for Cartesian post? Use counterexample to refine not only abstract domain, but also abstract post. P0 P1 P2 P3 s0 s1 s2 s3

c0 c1 c2 assert(F) s3 | = F s2 | = wlpc2(F) s1 | = wlpc1;c2(F)

s1 | = wlpc1;c2(F) implies postc1(s1) | = wlpc2(F) implies postc1;c2(s1) | = F Weakest preconditions along spurious part of trace are invariants for that trace.

Thomas Wies Symbolic Shape Analysis 27 / 34

slide-54
SLIDE 54

Abstraction Refinement Progress

Idea Conjoin image of Cartesian post with abstract weakest preconditions P′

2 = P2 ∪ atoms(wlpc2(F))

P′

3 = P3 ∪ atoms(F)

P0 P1 P′

2

P′

3

s0 s1 s′

2

s′

3

c0 c1 c2 assert(F)

s′

2 = CartesianPost(s1) ∧ α[P′ 2](wlpc2(F))

s′

3 = CartesianPost(s′ 2) ∧ α[P′ 3](F)

➜ Progress is guaranteed ➜ Counterexamples guide splitting of abstract objects/states.

Thomas Wies Symbolic Shape Analysis 28 / 34

slide-55
SLIDE 55

Deployment in Jahob

Bohne as Part of Jahob

Jahob system

  • verification of data structure consistency properties
  • Bohne is a component of Jahob
  • Jahob uses Boolean algebra of sets and relations to specify

procedure contracts ➜ fits nicely with Boolean heaps

  • Jahob integrates reasoning procedures for many theories

➜ Bohne can be used beyond shape analysis

Thomas Wies Symbolic Shape Analysis 29 / 34

slide-56
SLIDE 56

Deployment in Jahob

Jahob System Architecture

Thomas Wies Symbolic Shape Analysis 30 / 34

slide-57
SLIDE 57

Conclusion

Conclusion

Bohne - symbolic shape analyzer

  • verifies complex user-specified properties of Java programs
  • procedure contracts
  • data structure invariants
  • infers loop invariants automatically
  • disjunctions of universally quantified Boolean combinations of

predicates on heap objects

  • predicates are inferred automatically

Thomas Wies Symbolic Shape Analysis 31 / 34

slide-58
SLIDE 58

Related Work

Predicate Abstraction

Software model-checker: SLAM, BLAST, ARMC, MAGIC, ACSAR, . . . Successfully applied to control-intensive software, e.g. device drivers. Benefits of predicate abstraction

  • generic framework
  • useful even if predicates are manually supplied
  • combination with abstraction refinement results in fully automated

verification technique Bohne has all this.

Thomas Wies Symbolic Shape Analysis 32 / 34

slide-59
SLIDE 59

Related Work

Quantified Invariants

Example Doubly-linked lists . . . null next next next next prev p r e v p r e v field prev is inverse of field next: ∀ v . next(v) = null → prev(next(v)) = v field next is acyclic: ∀ v . next∗(v, null)

Thomas Wies Symbolic Shape Analysis 33 / 34

slide-60
SLIDE 60

Related Work

Quantified Invariants

Example Doubly-linked lists . . . null next next next next prev p r e v p r e v field prev is inverse of field next: ∀ v . next(v) = null → prev(next(v)) = v field next is acyclic: ∀ v . next∗(v, null) Potential solutions with classical predicate abstraction

  • quantified predicates

➜ decision procedures might not be able to handle quantifiers ➜ finding the right predicates is as hard as finding the invariant

Thomas Wies Symbolic Shape Analysis 33 / 34

slide-61
SLIDE 61

Related Work

Quantified Invariants

Example Doubly-linked lists . . . null next next next next prev p r e v p r e v field prev is inverse of field next: ∀ v . next(v) = null → prev(next(v)) = v field next is acyclic: ∀ v . next∗(v, null) Potential solutions with classical predicate abstraction

  • quantified predicates
  • Skolemization [Flanagan, Qadeer]

➜ does not work well for non-local properties such as reachability

Thomas Wies Symbolic Shape Analysis 33 / 34

slide-62
SLIDE 62

Related Work

Quantified Invariants

Example Doubly-linked lists . . . null next next next next prev p r e v p r e v field prev is inverse of field next: ∀ v . next(v) = null → prev(next(v)) = v field next is acyclic: ∀ v . next∗(v, null) Potential solutions with classical predicate abstraction

  • quantified predicates
  • Skolemization [Flanagan, Qadeer]
  • indexed predicates [Lahiri]

➜ quantified invariants, but no disjunctive completion

Thomas Wies Symbolic Shape Analysis 33 / 34

slide-63
SLIDE 63

Related Work

Three-valued shape analysis [Sagiv, Reps, Wilhelm]

x null . . .

next next next next

Thomas Wies Symbolic Shape Analysis 34 / 34

slide-64
SLIDE 64

Related Work

Three-valued shape analysis [Sagiv, Reps, Wilhelm]

Partition heap according to finitely many predicates on heap objects. P1 = { v | v = x } P2 = { v | v = null } P3 = { v | next∗(x, v) } P1 ∧ ¬P2 ∧ P3 ¬P1 ∧ ¬P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null . . .

next next next next

Thomas Wies Symbolic Shape Analysis 34 / 34

slide-65
SLIDE 65

Related Work

Three-valued shape analysis [Sagiv, Reps, Wilhelm]

Partition heap according to finitely many predicates on heap objects. P1 = { v | v = x } P2 = { v | v = null } P3 = { v | next∗(x, v) } P1 ∧ ¬P2 ∧ P3 ¬P1 ∧ ¬P2 ∧ P3 ¬P1 ∧ P2 ∧ P3 x null

next next next

➜ shape graph Trend is to move to symbolic approaches or combine with symbolic approaches (e.g. lazy shape analysis).

Thomas Wies Symbolic Shape Analysis 34 / 34