abstract object creation in dynamic logici12key/...object_creation_in_dynamic_logi… · abstract...

68
Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt 1 Frank S. de Boer 2 Immo Grabe 3 1 Chalmers University, G¨oteborg, Sweden 2 CWI, Amsterdam, The Netherlands 3 Christian-Albrechts-University Kiel, Germany KeY Symposium Speyer, 2009 Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Upload: others

Post on 27-Sep-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Abstract Object Creation in Dynamic Logicto be or not to be created

Wolfgang Ahrendt1 Frank S. de Boer2 Immo Grabe3

1Chalmers University, Goteborg, Sweden

2CWI, Amsterdam, The Netherlands

3Christian-Albrechts-University Kiel, Germany

KeY Symposium Speyer, 2009

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 2: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Part I

Motivation and Outline

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 3: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Modeling Object Creation in Program Logics

object-oriented programming languages (like Java):

I high-level way of creating objects

I abstract away from memory allocation

I programmer has no access to non-created (pre-)objects

this abstraction not matched by program logics (incl. KeY):

I non-created objects can be referred to in the logic

I additional artifacts (ghost fields) to distinguish created objects

I consistency conditions on reachable states

because of mismatch:

I loose full abstraction property

I additional complexity in formulas and proofs

I symbolic state bloated by createdness information

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 4: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Modeling Object Creation in Program Logics

object-oriented programming languages (like Java):

I high-level way of creating objects

I abstract away from memory allocation

I programmer has no access to non-created (pre-)objects

this abstraction not matched by program logics (incl. KeY):

I non-created objects can be referred to in the logic

I additional artifacts (ghost fields) to distinguish created objects

I consistency conditions on reachable states

because of mismatch:

I loose full abstraction property

I additional complexity in formulas and proofs

I symbolic state bloated by createdness information

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 5: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Modeling Object Creation in Program Logics

object-oriented programming languages (like Java):

I high-level way of creating objects

I abstract away from memory allocation

I programmer has no access to non-created (pre-)objects

this abstraction not matched by program logics (incl. KeY):

I non-created objects can be referred to in the logic

I additional artifacts (ghost fields) to distinguish created objects

I consistency conditions on reachable states

because of mismatch:

I loose full abstraction property

I additional complexity in formulas and proofs

I symbolic state bloated by createdness information

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 6: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Approach Taken

I a logic that can only ‘talk about’ created objects

problem:calculus cannot ‘substitute’ new objects into pre-conditions

I solution:non-standard substitution using meta-knowledge about‘newness’

I carry over to symbolic execution paradigm

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 7: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Approach Taken

I a logic that can only ‘talk about’ created objectsproblem:calculus cannot ‘substitute’ new objects into pre-conditions

I solution:non-standard substitution using meta-knowledge about‘newness’

I carry over to symbolic execution paradigm

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 8: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Approach Taken

I a logic that can only ‘talk about’ created objectsproblem:calculus cannot ‘substitute’ new objects into pre-conditions

I solution:non-standard substitution using meta-knowledge about‘newness’

I carry over to symbolic execution paradigm

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 9: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Approach Taken

I a logic that can only ‘talk about’ created objectsproblem:calculus cannot ‘substitute’ new objects into pre-conditions

I solution:non-standard substitution using meta-knowledge about‘newness’

I carry over to symbolic execution paradigm

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 10: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

In the Following

I simple object-oriented while-language

I dynamic logic for that language

I abstract object creation semantics

I backwards reasoning calculus (wp-style)

I symbolic execution with abstract object creation

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 11: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Relevance

I we examine object creation in simplified setting

I but: keep simplifications orthogonal to object creation issue

I applicable to full languages featuring abstract object creation(including Java)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 12: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Relevance

I we examine object creation in simplified setting

I but: keep simplifications orthogonal to object creation issue

I applicable to full languages featuring abstract object creation(including Java)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 13: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Part II

Syntax and Semantics

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 14: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

A Simple Object-Oriented While Language

I only one class: Object

I 3 types: Object, Integer, Boolean

I no methods

I variables (e.g. u, v ,w) distinct from fields (e.g. x , y , z)

statements:s ::= while e do s od | if e1 then s2 else s3 fi | s1; s2 |

u := e | e1.x := e2 | u := newexpressions:e ::= u | e.x | null | e1 = e2 | (e1 ? e2 : e3) | op(e1, ..., en)

to separate issues object creation and aliasing:

I no native statement e.x := new

I can be simulated by u := new; e.x := u (u fresh)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 15: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

A Simple Object-Oriented While Language

I only one class: Object

I 3 types: Object, Integer, Boolean

I no methods

I variables (e.g. u, v ,w) distinct from fields (e.g. x , y , z)

statements:s ::= while e do s od | if e1 then s2 else s3 fi | s1; s2 |

u := e | e1.x := e2 | u := new

expressions:e ::= u | e.x | null | e1 = e2 | (e1 ? e2 : e3) | op(e1, ..., en)

to separate issues object creation and aliasing:

I no native statement e.x := new

I can be simulated by u := new; e.x := u (u fresh)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 16: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

A Simple Object-Oriented While Language

I only one class: Object

I 3 types: Object, Integer, Boolean

I no methods

I variables (e.g. u, v ,w) distinct from fields (e.g. x , y , z)

statements:s ::= while e do s od | if e1 then s2 else s3 fi | s1; s2 |

u := e | e1.x := e2 | u := newexpressions:e ::= u | e.x | null | e1 = e2 | (e1 ? e2 : e3) | op(e1, ..., en)

to separate issues object creation and aliasing:

I no native statement e.x := new

I can be simulated by u := new; e.x := u (u fresh)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 17: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

A Simple Object-Oriented While Language

I only one class: Object

I 3 types: Object, Integer, Boolean

I no methods

I variables (e.g. u, v ,w) distinct from fields (e.g. x , y , z)

statements:s ::= while e do s od | if e1 then s2 else s3 fi | s1; s2 |

u := e | e1.x := e2 | u := newexpressions:e ::= u | e.x | null | e1 = e2 | (e1 ? e2 : e3) | op(e1, ..., en)

to separate issues object creation and aliasing:

I no native statement e.x := new

I can be simulated by u := new; e.x := u (u fresh)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 18: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

A Simple Object-Oriented While Language

I only one class: Object

I 3 types: Object, Integer, Boolean

I no methods

I variables (e.g. u, v ,w) distinct from fields (e.g. x , y , z)

statements:s ::= while e do s od | if e1 then s2 else s3 fi | s1; s2 |

u := e | e1.x := e2 | u := newexpressions:e ::= u | e.x | null | e1 = e2 | (e1 ? e2 : e3) | op(e1, ..., en)

to separate issues object creation and aliasing:

I no native statement e.x := new

I can be simulated by u := new; e.x := u (u fresh)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 19: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

The Logic

I expressions may also contain logical variables (e.g., l)

I boolean expressions are formulas

I true, false are formulas

I logical connectives ∧,∨,→,¬I quantified formulas ∀l .φ, ∃l .φ

I modal formulas (base cases):〈s〉φ, [s]φ, {U}φ,

with s a statement and U (singular) update of form:I u := eI e1.x := e2

I u := new

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 20: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 21: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 22: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 23: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 24: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 25: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l)

true in all states〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 26: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states

〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 27: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states〈u := new〉∀l .¬(u = l)

false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 28: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Semanticsinformal in this talk

I [[u := new]]σ : create new object and assign it to u

terminology:in a state σ: current references = created objects plus null

I [[e]]σ ∈ current references

I [[∀l .φ]]σ : φ holds for all current references l

I [[∃l .φ]]σ : φ holds for some current reference l

e, l of type Object

examples:∀l .〈u := new〉¬(u = l) true in all states〈u := new〉∀l .¬(u = l) false in all states

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 29: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Part III

Calculus

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 30: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Sequent Calculus

rules triggered by top-level formulas only:

I propositional rules, first-order rules, induction

I all these are standard!

I in particular: quantifier rules are standard!

rules triggered also by sub-formulas:

I program rules, update application rule

I notation used:bφ′ cbφ c

meaning:premis obtained from conclusion by replacing any φ with φ′

( \find(φ) \replacewith(φ′) )

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 31: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Sequent Calculus

rules triggered by top-level formulas only:

I propositional rules, first-order rules, induction

I all these are standard!

I in particular: quantifier rules are standard!

rules triggered also by sub-formulas:

I program rules, update application rule

I notation used:bφ′ cbφ c

meaning:premis obtained from conclusion by replacing any φ with φ′

( \find(φ) \replacewith(φ′) )

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 32: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Sequent Calculus

rules triggered by top-level formulas only:

I propositional rules, first-order rules, induction

I all these are standard!

I in particular: quantifier rules are standard!

rules triggered also by sub-formulas:

I program rules, update application rule

I notation used:bφ′ cbφ c

meaning:premis obtained from conclusion by replacing any φ with φ′

( \find(φ) \replacewith(φ′) )

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 33: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Sequent Calculus

rules triggered by top-level formulas only:

I propositional rules, first-order rules, induction

I all these are standard!

I in particular: quantifier rules are standard!

rules triggered also by sub-formulas:

I program rules, update application rule

I notation used:bφ′ cbφ c

meaning:premis obtained from conclusion by replacing any φ with φ′

( \find(φ) \replacewith(φ′) )

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 34: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Dynamic Logic Rules

splitb 〈[s1]〉〈[s2]〉φ cb 〈[s1; s2]〉φ c

ifb (e→〈[s1]〉φ) ∧ (¬e→〈[s2]〉φ) cb 〈[if e then s1 else s2 fi]〉φ c

unwindb 〈[if e then s; while e do s od else skip fi]〉φ c

b 〈[while e do s od]〉φ c

assignVarb {u := e}φ cb 〈[u := e]〉φ c

assignFieldb {e1.x := e2}φ cb 〈[e1.x := e2]〉φ c

createObjb {u := new}φ cb 〈[u := new]〉φ c

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 35: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Update Application Rule

for certain formulas {U}φ, the U can be ‘applied’ (resovled)

applyUpdbφ′ cb {U}φ c

if {U}φ φ′

now define relation , resolving updates in a single step

following slides: big-step definition of

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 36: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Update Application Rule

for certain formulas {U}φ, the U can be ‘applied’ (resovled)

applyUpdbφ′ cb {U}φ c

if {U}φ φ′

now define relation , resolving updates in a single step

following slides: big-step definition of

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 37: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Update Application Rule

for certain formulas {U}φ, the U can be ‘applied’ (resovled)

applyUpdbφ′ cb {U}φ c

if {U}φ φ′

now define relation , resolving updates in a single step

following slides: big-step definition of

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 38: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Part IV

Update Application

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 39: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Update Application: Standard Cases I

¬{U}φ φ′

{U}(¬φ) φ′{U}φ1 ∗ {U}φ2 φ′

{U}(φ1 ∗ φ2) φ′

with ∗ ∈ {∧,∨,→}

op({U}e1, ..., {U}en) e ′

{U}op(e1, ..., en) e ′({U}e1 ? {U}e2 : {U}e3) e ′

{U}(e1 ? e2 : e3) e ′

{U}α αwith α ∈ {true, false, null, l}

this slide: U matches all updates

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 40: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Update Application: Standard Cases II

{u := e}u e

{u := α}v v

u 6≡ v α ≡ e | new

({u := e1}e2).x e ′

{u := e1}(e2.x) e ′

( ({e.x := e1}e2) = e ? e1 : ({e.x := e1}e2).x ) e ′

{e.x := e1}(e2.x) e ′

({e.x := e1}e2).y e ′

{e.x := e1}(e2.y) e ′

x 6≡ y

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 41: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Update Application: Restricted Standard Cases

The standard rules for quantifiers and equality are restricted tonon-creating updates Unc of the forms ‘u := e’ , ‘e1.x := e2’ .( ‘u := new’ excluded from these rules.)

∀l . {Unc}φ φ′

{Unc}(∀l . φ) φ′

∃l . {Unc}φ φ′

{Unc}(∃l . φ) φ′

{Unc}e1 = {Unc}e2 e ′

{Unc}(e1 = e2) e ′

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 42: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: the Issue

recall:

I ‘{U}φ’ is the (explicit) weakest precondition wp(U , φ)

I applying U to φ (via ) computes weakest precondition

problem:

I result of {u := new}φ, i.e., wp({u := new}, φ), cannot talkabout new object because it does not exist in pre-state

I in particular: {u := new}u ?

basic approach:

I totally avoid ‘{u := new}u’I observation: the only operations on objects are

I de-referencing fieldsI test for equalityI quantification

I in all cases, wp computation can employ meta knowledge

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 43: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: the Issue

recall:

I ‘{U}φ’ is the (explicit) weakest precondition wp(U , φ)

I applying U to φ (via ) computes weakest precondition

problem:

I result of {u := new}φ, i.e., wp({u := new}, φ), cannot talkabout new object because it does not exist in pre-state

I in particular: {u := new}u ?

basic approach:

I totally avoid ‘{u := new}u’I observation: the only operations on objects are

I de-referencing fieldsI test for equalityI quantification

I in all cases, wp computation can employ meta knowledge

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 44: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: the Issue

recall:

I ‘{U}φ’ is the (explicit) weakest precondition wp(U , φ)

I applying U to φ (via ) computes weakest precondition

problem:

I result of {u := new}φ, i.e., wp({u := new}, φ), cannot talkabout new object because it does not exist in pre-state

I in particular: {u := new}u ?

basic approach:

I totally avoid ‘{u := new}u’

I observation: the only operations on objects areI de-referencing fieldsI test for equalityI quantification

I in all cases, wp computation can employ meta knowledge

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 45: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: the Issue

recall:

I ‘{U}φ’ is the (explicit) weakest precondition wp(U , φ)

I applying U to φ (via ) computes weakest precondition

problem:

I result of {u := new}φ, i.e., wp({u := new}, φ), cannot talkabout new object because it does not exist in pre-state

I in particular: {u := new}u ?

basic approach:

I totally avoid ‘{u := new}u’I observation: the only operations on objects are

I de-referencing fieldsI test for equality

I quantification

I in all cases, wp computation can employ meta knowledge

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 46: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: the Issue

recall:

I ‘{U}φ’ is the (explicit) weakest precondition wp(U , φ)

I applying U to φ (via ) computes weakest precondition

problem:

I result of {u := new}φ, i.e., wp({u := new}, φ), cannot talkabout new object because it does not exist in pre-state

I in particular: {u := new}u ?

basic approach:

I totally avoid ‘{u := new}u’I observation: the only operations on objects are

I de-referencing fieldsI test for equalityI quantification

I in all cases, wp computation can employ meta knowledge

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 47: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: the Issue

recall:

I ‘{U}φ’ is the (explicit) weakest precondition wp(U , φ)

I applying U to φ (via ) computes weakest precondition

problem:

I result of {u := new}φ, i.e., wp({u := new}, φ), cannot talkabout new object because it does not exist in pre-state

I in particular: {u := new}u ?

basic approach:

I totally avoid ‘{u := new}u’I observation: the only operations on objects are

I de-referencing fieldsI test for equalityI quantification

I in all cases, wp computation can employ meta knowledge

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 48: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: Field Access

({u := new}e).x e ′

{u := new}(e.x) e ′

e neither u nor conditional

{u := new}u.x initT (x)

initT (x) ≡ null | 0 | false

({u := new}b ? {u := new}(e1.x) : {u := new}(e2.x)) e ′

{u := new}((b ? e1 : e2).x) e ′

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 49: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: Equality

({u := new}e1) = ({u := new}e2) e ′

{u := new}(e1 = e2) e ′

e1, e2 neither u nor conditional

{u := new}(u = e) false

e neither u nor conditional{u := new}(u = u) true

({u := new}b ? {u := new}(e1 = e3) : {u := new}(e2 = e3)) e ′

{u := new}((b ? e1 : e2) = e3) e ′

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 50: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: Quantifiers

({u := new}φ[l/u]) ∧ ∀l .({u := new}φ) φ′

{u := new}∀l .φ φ′

({u := new}φ[l/u]) ∨ ∃l .({u := new}φ) φ′

{u := new}∃l .φ φ′

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 51: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Creating Update Application: Quantifiers

({u := new}φ[l/u]) ∧ ∀l .({u := new}φ) φ′

{u := new}∀l .φ φ′

({u := new}φ[l/u]) ∨ ∃l .({u := new}φ) φ′

{u := new}∃l .φ φ′

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 52: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Example Proof 1

∗closeFalse

false =⇒notRight=⇒ ¬ falseapplyUpd

=⇒ {u := new}¬(u = c)assignVar

=⇒ 〈u := new〉¬(u = c)allRight

=⇒ ∀l .(〈u := new〉¬(u = l))

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 53: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Example Proof 2

∗closeTrue ∀l .¬false =⇒ truenotLeft ¬(true),∀l .¬false =⇒

andLeft ¬(true) ∧ ∀l .¬false =⇒applyUpd

{u := new}∀l .¬(u = l) =⇒assignVar

〈u := new〉∀l .¬(u = l)) =⇒notRight

=⇒ ¬〈u := new〉∀l .¬(u = l)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 54: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

(applyUpd step in Example Proof 2)

{u := new}(u = u) true

{u := new}¬(u = u) ¬(true)

{u := new}(u = l) false

{u := new}¬(u = l) ¬false

∀l .{u := new}¬(u = l) ∀l .¬false

{u := new}¬(u = u) ∧ ∀l .{u := new}¬(u = l) ¬(true) ∧ ∀l .¬false

{u := new}∀l .¬(u = l) ¬(true) ∧ ∀l .¬false

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 55: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Part V

Abstract Object Creation in Symbolic Execution

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 56: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

KeY-style Symbolic Execution

up to here, backwards reasoning only

KeYapproach:forward symbolic execution using update parallelisation

*close u < v =⇒ u < v

applyUpdu < v =⇒ {w := u | u := v | v := u}v < u

mergeUpdu < v =⇒ {w := u | u := v}{v := w}v < u

assignVaru < v =⇒ {w := u | u := v}〈v := w〉v < u

mergeUpd,assignVaru < v =⇒ {w := u}{u := v}〈v := w〉v < u

split,assignVaru < v =⇒ {w := u}〈u := v ; v := w〉v < u

split,assignVaru < v =⇒ 〈w := u; u := v ; v := w〉v < u

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 57: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

KeY-style Symbolic Execution

up to here, backwards reasoning only

KeYapproach:forward symbolic execution using update parallelisation

*close u < v =⇒ u < v

applyUpdu < v =⇒ {w := u | u := v | v := u}v < u

mergeUpdu < v =⇒ {w := u | u := v}{v := w}v < u

assignVaru < v =⇒ {w := u | u := v}〈v := w〉v < u

mergeUpd,assignVaru < v =⇒ {w := u}{u := v}〈v := w〉v < u

split,assignVaru < v =⇒ {w := u}〈u := v ; v := w〉v < u

split,assignVaru < v =⇒ 〈w := u; u := v ; v := w〉v < u

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 58: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Problem: Parallelising Object Creating Updates

no natural way of merging {u := new} with other updates

consider the two formulas (one true, one false):

〈u := new; v := u〉(u = v) 〈u := new; v := new〉(u = v)

symbolic execution generates:

{u := new}{v := u}(u = v) {u := new}{v := new}(u = v)

merging updates, both result in:

{u := new | v := new}(u = v)

cannot be true and false

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 59: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Solution

I not merge object creation with other updates

I split {u := new} into creation and (mergable) assignment to u

new object creation rule:

createObjb {a := new}{u := a}φ cb 〈u := new〉φ c

a a fresh program variable

facilitate merging of all non-creating updates by shifting creation

shiftCreationb {u := new}{Unc}φ cb {Unc}{u := new}φ c

u not appearing in (non-creating) Unc

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 60: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Solution

I not merge object creation with other updates

I split {u := new} into creation and (mergable) assignment to u

new object creation rule:

createObjb {a := new}{u := a}φ cb 〈u := new〉φ c

a a fresh program variable

facilitate merging of all non-creating updates by shifting creation

shiftCreationb {u := new}{Unc}φ cb {Unc}{u := new}φ c

u not appearing in (non-creating) Unc

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 61: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Solution

I not merge object creation with other updates

I split {u := new} into creation and (mergable) assignment to u

new object creation rule:

createObjb {a := new}{u := a}φ cb 〈u := new〉φ c

a a fresh program variable

facilitate merging of all non-creating updates by shifting creation

shiftCreationb {u := new}{Unc}φ cb {Unc}{u := new}φ c

u not appearing in (non-creating) Unc

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 62: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Solution

I not merge object creation with other updates

I split {u := new} into creation and (mergable) assignment to u

new object creation rule:

createObjb {a := new}{u := a}φ cb 〈u := new〉φ c

a a fresh program variable

facilitate merging of all non-creating updates by shifting creation

shiftCreationb {u := new}{Unc}φ cb {Unc}{u := new}φ c

u not appearing in (non-creating) Unc

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 63: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Symbolic Execuion Proof

*notRight, closeFalse=⇒ ¬falseapplyUpd

=⇒ {a := new}¬(v = a)applyUpd

=⇒ {a := new}{u := v | v := a |w := u}¬(w = v)assignVar,mergeUpd

=⇒ {a := new}{u := v | v := a}〈w := u〉¬(w = v)mergeUpd

=⇒ {a := new}{u := v}{v := a}〈w := u〉¬(w = v)shiftCreation

=⇒ {u := v}{a := new}{v := a}〈w := u〉¬(w = v)createObj

=⇒ {u := v}〈v := new〉〈w := u〉¬(w = v)split,assignVar,split

=⇒ 〈u := v ; v := new; w := u〉¬(w = v)

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 64: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Part VI

Object Creation vs. Object Activation

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 65: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Abstract Object Creation Proof

reconsider proof from above

∗closeFalse

false =⇒notRight=⇒ ¬ falseapplyUpd

=⇒ {u := new}¬(u = c)assignVar

=⇒ 〈u := new〉¬(u = c)allRight

=⇒ ∀l .(〈u := new〉¬(u = l))

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 66: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Object Activation Proof

∗close

c .cre, obj(next)=c =⇒ c.creequality

c .cre, obj(next)=c =⇒ obj(next).crenotLeft ¬obj(next).cre, c .cre, obj(next)=c =⇒

(≈2 rules)(obj(next).cre↔ next < next), c .cre, obj(next)=c =⇒

allLeft ∀n.(obj(n).cre↔ n < next), c.cre, obj(next)=c =⇒inReachableState

c .cre, obj(next)=c =⇒notRight

c .cre =⇒ ¬(obj(next)=c)applyUpd

c.cre =⇒ {u :=obj(next); u.cre :=true; next :=next+1}¬(u =c)createObj

c .cre =⇒ 〈u :=new〉¬(u =c)impRight

=⇒ c .cre→〈u :=new〉¬(u =c)allRight

=⇒ ∀l . (l .cre→〈u :=new〉¬(u = l))

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 67: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Part VII

Reflections

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic

Page 68: Abstract Object Creation in Dynamic Logici12key/...Object_Creation_in_Dynamic_Logi… · Abstract Object Creation in Dynamic Logic to be or not to be created Wolfgang Ahrendt1 Frank

Reflections

I abstraction level of logic matches programming languageI changes to standard treatment very local

I additional update type,not mergable with others, but shiftable to the front

I update application differs only in few cases

I formulas and proofs are simplerI symbolic state representation:

I not diluted by createdness bookkeepingI separates out

1. newly created objects (shifted forward)2. symbolic value of fields and variables

Wolfgang Ahrendt, Frank S. de Boer, Immo Grabe Abstract Object Creation in Dynamic Logic