Changing perspective can be useful Relating alternative logics for automatic software verification

44
Changing perspective can be useful Relating alternative logics for automatic software verification Alex Summers (ETH Zurich) partly based on joint work with Matthew Parkinson and Daniel Jost

description

Changing perspective can be useful Relating alternative logics for automatic software verification. Alex Summers (ETH Zurich) par tly based on joint work with Matthew Parkinson and Daniel Jost. Topic. This talk is concerned with specification logics - PowerPoint PPT Presentation

Transcript of Changing perspective can be useful Relating alternative logics for automatic software verification

Page 1: Changing perspective can be useful Relating alternative logics for automatic software verification

Changing perspective can be useful

Relating alternative logics for automatic software verification

Alex Summers (ETH Zurich) partly based on joint work with Matthew Parkinson and Daniel Jost

Page 2: Changing perspective can be useful Relating alternative logics for automatic software verification

Topic

• This talk is concerned with specification logics– heap-based (usually concurrent) programs – aimed at automatic verification

• There are many alternative logics out there; investigating their relationships can– be helpful for comparing expressiveness/usability– promote understanding between research groups– suggest adapting features from one to another

• I’ll talk about some work relating two logics: separation logic and implicit dynamic frames

Page 3: Changing perspective can be useful Relating alternative logics for automatic software verification

Separation Logic

• Idea: reason in terms of heap fragments• Specialised connectives for describing heaps• e.g., x.f ↦ v (“points-to predicate”)

– The only way for an assertion to dereference x.f– Specifies value v currently stored at the location

v

x.f

Page 4: Changing perspective can be useful Relating alternative logics for automatic software verification

Separation Logic

• Separating conjunction connective *• A*B means A and B hold in disjoint heaps• e.g., x.f ↦ v * y.f ↦ 5

the disjointness guarantees: x and y are not aliasesh A*B iff ⊨ ∃h1,h2.(h=h1 h⊎ 2 and h1 A and h⊨ 2 B)⊨

y.f

v

x.f

5

Page 5: Changing perspective can be useful Relating alternative logics for automatic software verification

Implicit Dynamic Frames

• Extend standard first-order assertions to additionally include “accessibility predicates”:acc(x.f) is an assertion; we have permission to x.f

• Unlike in sep. logic, assertions can also include heap-dependent expressions: e.g., x.f > 3

• Idea: verification based on a total heap– prover “sees” a value for every heap location– but these values are only guaranteed meaningful if

the thread also holds permission to the location

Page 6: Changing perspective can be useful Relating alternative logics for automatic software verification

• For exampleacc(x.f) * x.f = 4 * acc(x.g)

Implicit Dynamic Frames

Page 7: Changing perspective can be useful Relating alternative logics for automatic software verification

• For exampleacc(x.f) * x.f = 4 * acc(x.g)

x.f

Implicit Dynamic Frames

Page 8: Changing perspective can be useful Relating alternative logics for automatic software verification

• For exampleacc(x.f) * x.f = 4 * acc(x.g)

x.f

Implicit Dynamic Frames

Page 9: Changing perspective can be useful Relating alternative logics for automatic software verification

• For exampleacc(x.f) * x.f = 4 * acc(x.g)

4

x.f

Implicit Dynamic Frames

Page 10: Changing perspective can be useful Relating alternative logics for automatic software verification

Implicit Dynamic Frames

• For exampleacc(x.f) * x.f = 4 * acc(x.g)

4

x.f x.g

Page 11: Changing perspective can be useful Relating alternative logics for automatic software verification

Implicit Dynamic Frames

• For exampleacc(x.f) * x.f = 4 * acc(x.g)

• Expressions include heap dereferences

4

x.f x.g

Page 12: Changing perspective can be useful Relating alternative logics for automatic software verification

Implicit Dynamic Frames

• For exampleacc(x.f) * x.f = 4 * acc(x.g)

• Expressions include heap dereferences• Permissions need not match “read footprint”

4

x.f x.g

Page 13: Changing perspective can be useful Relating alternative logics for automatic software verification

Implicit Dynamic Frames

• For exampleacc(x.f) * x.f = 4 * acc(x.g) * y.f = 3

• Expressions include heap dereferences• Permissions need not match “read footprint”

4

x.f x.g

Page 14: Changing perspective can be useful Relating alternative logics for automatic software verification

Implicit Dynamic Frames

• For exampleacc(x.f) * x.f = 4 * acc(x.g) * y.f = 3

• Expressions include heap dereferences• Permissions need not match “read footprint”

3y.f

x.g

4

x.f

Page 15: Changing perspective can be useful Relating alternative logics for automatic software verification

Self-framing assertionsAn IDF assertion is self-

framing if:For any state in which

the assertion is true,

Page 16: Changing perspective can be useful Relating alternative logics for automatic software verification

Self-framing assertionsIDF total heap

4

3 2

7

4

3 2

7

0 0

An IDF assertion is self-framing if:

For any state in which the assertion is true,

it remains true if we replace the heap with any that agrees on the locations to which it requires permissions

Page 17: Changing perspective can be useful Relating alternative logics for automatic software verification

IDF total heap

4

3 2

7

9

3 2

1

4 1

Self-framing assertionsAn IDF assertion is self-

framing if:For any state in which

the assertion is true,it remains true if we

replace the heap with any that agrees on the locations to which it requires permissions

Page 18: Changing perspective can be useful Relating alternative logics for automatic software verification

Self-framing assertionsIDF total heap

4

3 2

7

8 4

2 1

6 2

5

An IDF assertion is self-framing if:

For any state in which the assertion is true,

it remains true if we replace the heap with any that agrees on the locations to which it requires permissions

Page 19: Changing perspective can be useful Relating alternative logics for automatic software verification

Self-framing assertionsIDF total heap

4

3 2

7

4

3 2

7

0 0

An IDF assertion is self-framing if:

For any state in which the assertion is true,

it remains true if we replace the heap with any that agrees on the locations to which it requires permissions

Page 20: Changing perspective can be useful Relating alternative logics for automatic software verification

Self-framing assertionsSeparation Logic partial heap

4

3 2

7

In Separation Logic, there would be partial heap which canonically represents all of

these total heaps

An IDF assertion is self-framing if:

For any state in which the assertion is true,

it remains true if we replace the heap with any that agrees on the locations to which it requires permissions

Page 21: Changing perspective can be useful Relating alternative logics for automatic software verification

A*B

Separation Logic partial heap

AB

IDF total heap

AB

Page 22: Changing perspective can be useful Relating alternative logics for automatic software verification

A*B

Separation Logic partial heap IDF total heap

AB

AB

Page 23: Changing perspective can be useful Relating alternative logics for automatic software verification

A*B

Separation Logic partial heap IDF total heap

AB

AB

4

3 2

7 4

3 2

7

4

3 2

7

0 0

Idea: x.f ↦ v ⇔ acc(x.f) * x.f = v

Page 24: Changing perspective can be useful Relating alternative logics for automatic software verification

The “Magic Wand”

Separation Logic partial heapAn assertion A ― B means:“If, to the current heap, we add a disjoint heap satisfying A then the resulting heap is guaranteed to satisfy B”

Or: h A ― B iff ⊨h’ h.( h’ A h h’ ∀ ⊥ ⊨ ⇒ ⊎ ⊨

B)

Page 25: Changing perspective can be useful Relating alternative logics for automatic software verification

Separation Logic partial heap

A

The “Magic Wand”

An assertion A ― B means:“If, to the current heap, we add a disjoint heap satisfying A then the resulting heap is guaranteed to satisfy B”

Or: h A ― B iff ⊨h’ h.( h’ A h h’ ∀ ⊥ ⊨ ⇒ ⊎ ⊨

B)

Page 26: Changing perspective can be useful Relating alternative logics for automatic software verification

Separation Logic partial heap

A

The “Magic Wand”

An assertion A ― B means:“If, to the current heap, we add a disjoint heap satisfying A then the resulting heap is guaranteed to satisfy B”

Or: h A ― B iff ⊨h’ h.( h’ A h h’ ∀ ⊥ ⊨ ⇒ ⊎ ⊨

B)

Page 27: Changing perspective can be useful Relating alternative logics for automatic software verification

Separation Logic partial heap

A

B

The “Magic Wand”

An assertion A ― B means:“If, to the current heap, we add a disjoint heap satisfying A then the resulting heap is guaranteed to satisfy B”

Or: h A ― B iff ⊨h’ h.( h’ A h h’ ∀ ⊥ ⊨ ⇒ ⊎ ⊨

B)

Page 28: Changing perspective can be useful Relating alternative logics for automatic software verification

Separation Logic partial heap IDF total heap

A

B

The “Magic Wand”

Page 29: Changing perspective can be useful Relating alternative logics for automatic software verification

Separation Logic partial heap IDF total heap

A ?

B

A

The “Magic Wand”

Page 30: Changing perspective can be useful Relating alternative logics for automatic software verification

IDF total heap

A ?

How to model heap extension?

Page 31: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 1:

Just add extra permissions to the original state

Problem:We attach significance to the values that were previously stored in the heap, at the new locations

IDF total heap

A ?

How to model heap extension?

Page 32: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

A ?

How to model heap extension?

Page 33: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

A ?

How to model heap extension?

Page 34: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

A ?

How to model heap extension?

Page 35: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

A ?

How to model heap extension?

Page 36: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

A ?

How to model heap extension?

Page 37: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

A ?

How to model heap extension?

Page 38: Changing perspective can be useful Relating alternative logics for automatic software verification

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

A ?

How to model heap extension?

Page 39: Changing perspective can be useful Relating alternative logics for automatic software verification

For example,acc(x.f) * (x.f ≠ null ― acc(x.f.g))

The intention is that the meaning of x.f is fixed by the permission “elsewhere”

When we judge the magic wand, if we consider assigning arbitrary values to x.f, then we lose the meaning

Idea 2:

Assign new (arbitrary) values to unreadable heap locations, and then add new permissions

Problem:In IDF, A may involve heap-dependent expressions

IDF total heap

How to model heap extension?

Page 40: Changing perspective can be useful Relating alternative logics for automatic software verification

Minimal State Extensions

• Idea: only consider “extending” the state by the smallest amount possible

We modify the original semantics:h A ― B iff ⊨

∀ h’ h. (h’ A h h’ B) ⊥ ⊨ ⇒ ⊎ ⊨ h h’ B)⇒ ⊎ ⊨

A kind of “optimised” semantics for Separation Logic (but still equivalent, for SL assertions)

For IDF, we can analogously take new values for exactly the new permissions required by A

Page 41: Changing perspective can be useful Relating alternative logics for automatic software verification

Minimal State Extensions

• Idea: only consider “extending” the state by the smallest amount possible

We modify the original semantics to be:h A ― B iff ⊨

∀ h’ h. (h’ A ⊥ ⊨ ∧ h’’(h’’ h’ h’’ A)∀ ⊂ ⇒ ⊨ h h’ B)⇒ ⊎ ⊨

A kind of “optimised” semantics for Separation Logic (but still equivalent, for SL assertions)

For IDF, we can analogously take new values for exactly the new permissions required by A

/

Page 42: Changing perspective can be useful Relating alternative logics for automatic software verification

Where did this get us?

• well, we wrote some papers– joint with Matthew Parkinson: ESOP’11,LMCS’12

• Gave formal assertion semantics to IDF logic – new connectives “migrated” from SL (e.g., A ― B)

• We gave translation from SL assertions to IDF– formally relates the semantics of each

• We gave a total heaps semantics for Sep. Logic– suggests new implementation strategies

Page 43: Changing perspective can be useful Relating alternative logics for automatic software verification

But, it gets (even) better..

• Making the comparison practical, required a story for recursive predicates/functions

• In joint work with Daniel Jost, we translate VeriFast examples to Chalice (VSTTE’13) – we can encode SL verification for Z3 SMT solver– required static analysis for recursive definitions

• Pulling ideas from both sides is productive– Kassios/Kritikos: [ESOP’13] add backpointers to SL– “magic wand” handling might be implementable..– other fun ideas in infancy (stay tuned)

Page 44: Changing perspective can be useful Relating alternative logics for automatic software verification

Ways of investigating relationships

• Formalising and proving relationships between semantics of specification logics (e.g., described)– joint work with Matthew Parkinson: ESOP’11,LMCS’12

• Providing encodings/translations between languages of different implemented verifiers– Joint work with Daniel Jost: VSTTE’13 (this weekend!)

• Specifying and verifying challenging examples using multiple different approaches/tools• e.g., verification competitions for VSTTE and FM events• interesting to try out variety of methodologies by hand