GAME SEMANTICS FOR INTERFACE MIDDLEWEIGHT JAVA Andrzej S. Murawski - - PowerPoint PPT Presentation

game semantics for interface middleweight java
SMART_READER_LITE
LIVE PREVIEW

GAME SEMANTICS FOR INTERFACE MIDDLEWEIGHT JAVA Andrzej S. Murawski - - PowerPoint PPT Presentation

GAME SEMANTICS FOR INTERFACE MIDDLEWEIGHT JAVA Andrzej S. Murawski Steven J. Ramsay WARWICK OXFORD Nikos Tzevelekos QUEEN MARY LONDON WHAT IS THIS TALK ABOUT? a fully abstract denotational model for a core fragment of Java classification


slide-1
SLIDE 1

Andrzej S. Murawski WARWICK

GAME SEMANTICS FOR INTERFACE MIDDLEWEIGHT JAVA

Nikos Tzevelekos QUEEN MARY LONDON Steven J. Ramsay OXFORD

slide-2
SLIDE 2

WHAT IS THIS TALK ABOUT?

a fully abstract denotational model for a core fragment of Java classification of decidable cases for contextual equivalence

slide-3
SLIDE 3

CAPTURING PROGRAM BEHAVIOUR

?

slide-4
SLIDE 4

FULL ABSTRACTION

M1 = M2 if and only if M1 ∼ = M2

slide-5
SLIDE 5

Game semantics: from PCF to ML

Full Abstraction for PCF (early 90's)

Games for variants of Idealized Algol

  • Non-determinism, exceptions, probability,

concurrency, polymorphism, …

Nominal game semantics (2004-)

  • Use names for dynamic resource generation

→ fragments of ML, CML, C, now Java

slide-6
SLIDE 6

The need for names

References as pairs:

ref int = (unit  int) x (int  unit) ” (1  Z)x(Z  1)

  • Theoretically attractive
  • but: mkvar(R , H), all R , H

(bad variables)

slide-7
SLIDE 7

The need for names

References as pairs: References as names:

ref int = (unit  int) x (int  unit) ” (1  Z)x(Z  1) ref int = base type ”  (reference names)

  • Theoretically attractive
  • but: mkvar(R , H), all R , H

(bad variables)

  • Notion of resource (name):
  • atomic values
  • infinitely many
  • comparable for equality
slide-8
SLIDE 8

GOOD-VARIABLE SOLUTIONS

20 Andrzej S. Murawski, Nikos Tzevelekos: Full Abstraction for Reduced ML. FOSSACS 2009: 32-47 2008 22 Andrzej S. Murawski, Nikos Tzevelekos: Game Semantics for Good General References. LICS 2011: 75-84 37 Andrzej S. Murawski, Nikos Tzevelekos: Game Semantics for Nominal Exceptions. FoSSaCS 2014: 164-179 36 35 Andrzej S. Murawski, Nikos Tzevelekos: Game semantics for interface middleweight

  • Java. POPL 2014: 517-528

i6

ref(int)

ref(ref(θ)) ref(θ1 → θ2)

exceptions

  • bjects
slide-9
SLIDE 9

Interface Middleweight Java (IMJ)

Object calculus based on MJ [Bierman, Parkinson, Pitts]

  • Objects, inheritance, casting, interfaces

Types

θ ::= void | int | 

Interface definitions

Θ ::=  | ( f : θ ), Θ | ( m : θ → θ ), Θ

Interface tables

Δ ::=  | (  : Θ ), Δ | (  : Θ ), Δ

interface ident. field identifiers method identif.

slide-10
SLIDE 10

Interface Middleweight Java (IMJ)

Object calculus based on MJ [Bierman, Parkinson, Pitts]

  • Objects, inheritance, casting, interfaces

Terms

M ::= skip | n | null | x | i | M ⊕ M | if M M M

| let x = M in M | M = M | ()M | new(x : ; M) | M.f | M.f := M | M.m( M ) Method implementations

M ::=  | (m : λx.Μ), M

slide-11
SLIDE 11

IMJ example*

M1 : let u = new( VarEmp

) in

new( M1

)

: Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

* Koutavas & Wand, 2007

slide-12
SLIDE 12

IMJ example*

M1 : let u = new( VarEmp

) in

new( M1

)

: Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

M2 : let b = new( VarInt

) in

let u1 = new( VarEmp

) in

let u2 = new( VarEmp

) in

new( M2

) : Cell

M2 : get : λ(). if b.val

then b.val := 0 ; u1.val else b.val := 1 ; u2.val, set : λy. u1.val := y ;

u2.val := y

* Koutavas & Wand, 2007

slide-13
SLIDE 13

Game Semantics

Computation is modelled as a 2-player game between:

  • Opponent (the environment, O )
  • Proponent (the program, P )

Qualitative games ( ≠ Game Theory) Computations = plays of a specified game Programs = strategies for P Strategy composition → categories of games

slide-14
SLIDE 14

Plays, strategies

call n.set(12) (n  IntCell, val=5), … Plays : sequences of moves-with-store Strategies : sets of plays

  • moves have polarities (O/P ), which alternate
  • P calls methods of O, and viceversa; dually for returns
  • calls and returns obey the object interfaces
  • strategies are closed wrt to O-name subtyping

 M  :  Iinp

  Iout 

arenas strategy

slide-15
SLIDE 15

IMJ example: game semantics

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

M1 : let u = new( VarEmp

) in

new( M1

)

: Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

 M1

 = * n Σ0 ( call n.get() Σ0 ret n.get( nul ) Σ0 )*

call n.set( n1

) Σ1 ret n.set() Σ1

( call n.get() Σ1 ret n.get( n1

) Σ1 )*

call n.set( n2

) Σ2 ret n.set() Σ2 ...

Σi = { n  (Cell, ) }  { nj  (Empty, ), 1  j  i }

O O P P

slide-16
SLIDE 16

IMJ example: game semantics

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

M1 : let u = new( VarEmp

) in

new( M1

)

: Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

 M1

 = * n Σ0 ( call n.get() Σ0 ret n.get( nul ) Σ0 )*

call n.set( n1

) Σ1 ret n.set() Σ1

( call n.get() Σ1 ret n.get( n1

) Σ1 )*

call n.set( n2

) Σ2 ret n.set() Σ2 ...

Σi = { n  (Cell, ) }  { nj  (Empty, ), 1  j  i }

O O P P

slide-17
SLIDE 17

IMJ example: game semantics

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

M1 : let u = new( VarEmp

) in

new( M1

)

: Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

 M1

 = * n Σ0 ( call n.get() Σ0 ret n.get( nul ) Σ0 )*

call n.set( n1

) Σ1 ret n.set() Σ1

( call n.get() Σ1 ret n.get( n1

) Σ1 )*

call n.set( n2

) Σ2 ret n.set() Σ2 ...

Σi = { n  (Cell, ) }  { nj  (Empty, ), 1  j  i }

O O P P

slide-18
SLIDE 18

IMJ example: game semantics

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

M1 : let u = new( VarEmp

) in

new( M1

)

: Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

 M1

 = * n Σ0 ( call n.get() Σ0 ret n.get( nul ) Σ0 )*

call n.set( n1

) Σ1 ret n.set() Σ1

( call n.get() Σ1 ret n.get( n1

) Σ1 )*

call n.set( n2

) Σ2 ret n.set() Σ2 ...

Σi = { n  (Cell, ) }  { nj  (Empty, ), 1  j  i }

O O P P

slide-19
SLIDE 19

IMJ example: game semantics

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

M1 : let u = new( VarEmp

) in

new( M1

)

: Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

 M1

 = * n Σ0 ( call n.get() Σ0 ret n.get( nul ) Σ0 )*

call n.set( n1

) Σ1 ret n.set() Σ1

( call n.get() Σ1 ret n.get( n1

) Σ1 )*

call n.set( n2

) Σ2 ret n.set( ) Σ2 ...

Σi = { n  (Cell, ) }  { nj  (Empty, ), 1  j  i }

O O P P

slide-20
SLIDE 20

IMJ example: game semantics

Δ = Empty: ,

Cell: (get: void → Empty, set: Empty → void), VarEmp: (val: Empty), VarInt: (val: int)

M1 : let u = new( VarEmp

) in

new( Cell; M1

) : Cell

M1 : get : λ(). u.val,

set : λy. u.val := y

 M1

 = * n Σ0 ( call n.get() Σ0 ret n.get( nul ) Σ0 )*

call n.set( n1

) Σ1 ret n.set() Σ1

( call n.get() Σ1 ret n.get( n1

) Σ1 )*

call n.set( n2

) Σ2 ret n.set( ) Σ2 ...

=  M2

Σi = { n  (Cell, ) }  { nj  (Empty, ), 1  j  i }

O O P P

M2 : let b = new( VarInt

) in

let u1 = new( VarEmp

) in

let u2 = new( VarEmp

) in

new( M2

) : Cell

M2 : get : λ(). if b.val

then b.val := 0 ; u1.val else b.val := 1 ; u2.val, set : λy. u1.val := y ;

u2.val := y

slide-21
SLIDE 21

Full abstraction for IMJ

  • Lemma. The game model is sound
  • Lemma. Every finitary strategy is IMJ-definable
  • Theorem. The game model is fully abstract

P  P' ⇔  P    P' 

slide-22
SLIDE 22

TAOOP'94 FSSJava'99

Related work on objects

Domain models

slide-23
SLIDE 23

TAOOP'94 FSSJava'99

Related work on objects

Domain models Environmental bisimulations

FOOL/WOOD'07

slide-24
SLIDE 24

TAOOP'94 FSSJava'99

Related work on objects

Domain models Environmental bisimulations Trace models

FMCO'04 ESOP'03 TCS'05 FOOL/WOOD'07

slide-25
SLIDE 25

VERIFICATION

1 run 2 x.q 3 x.1 4 x.0 5 x.-1 6 x.q 7 x.q 8 x.q 9 x.1 10 x.0 11 x.-1 x.1 12 x.0 13 x.-1 x.1 x.0 14 x.-1 15 x.1write x.0write x.-1write 16 x.0write x.-1write 17 x.-1write 18 x.ok 19 x.ok 20 x.ok 21 x.1write x.0write x.-1write 22 x.ok 23 done

strategy

M1, M2 contextually equivalent ⇐ ⇒ M1 = M2 ⇐ ⇒ AM1 ≈ AM2

slide-26
SLIDE 26

SOURCES OF UNDECIDABILITY

  • arithmetic
  • recursive definitions (datatypes and methods)
  • storage of method-carrying objects in fields
  • “higher-order” types
  • 1 : I1,

· · · , ok : Ik ⊢ M : I

slide-27
SLIDE 27

HIGHER-ORDER TYPES

  • → (• → •)

⊢ ((• → •) → •) → • (• → •) → • ⊢ − − →

G ::= void | int | − − → f : G L ::= void | int | (− − → f : G, − − − − − − − → m : ⃗ G → L) R ::= void | int | (− − → f : G, − − − − − − − → m : ⃗ L → G)

bad good

slide-28
SLIDE 28

AUTOMATA THEORY OVER INFINITE ALPHABETS

  • RA

language equivalence (det) co-NP-complete [LICS’15] bisimilarity PSPACE-complete [LICS’15]

  • PDRA

emptiness EXPTIME-complete [MFCS’14] bisimilarity undecidable [LICS’15] HO emptiness undecidable [MFCS’14]

  • FPDRA

emptiness EXPTIME-complete [ICALP’12, MFCS’14]

n1 # n2 · · · · · · nr

(t, n1) (t′, n2) (t, n1) . . . . . .

slide-29
SLIDE 29

CONEQCT (ATVA’15)

IMJA Compiler Canonical form Converter Automaton Generator Input IMJ* terms IMJA Automata FPDRA Builder IMJ2A Converter FPDRA Converter FPDRA Automaton FPDRA Reachability Checker

  • Fig. 1.

[POPL’14] [ATVA’15]

[MFCS’14] [ATVA’15]

[ICALP’12] [MFCS’14]

42 Andrzej S. Murawski, Steven J. Ramsay, Nikos Tzevelekos: A Contextual Equivalence Checker for IMJ ∗. ATVA 2015: 234-240

slide-30
SLIDE 30

COMPARISON

  • ADR09. A. Ahmed, D. Dreyer, and A. Rossberg. State-dependent representation independence.

In Proceedings of POPL, pages 340–353. ACM, 2009. BL05.

  • N. Benton and B. Leperchey. Relational reasoning in a nominal semantics for storage.

In Proceedings of TLCA, volume 3461 of Lecture Notes in Computer Science, pages 86–101. Springer, 2005.

  • DNB10. D. Dreyer, G. Neis, and L. Birkedal. The impact of higher-order state and control

effects on local relational reasoning. In Proceedings of ICFP, pages 143–156. ACM, 2010. KW06.

  • V. Koutavas and M. Wand. Small bisimulations for reasoning about higher-order im-

perative programs. In Proceedings of POPL, pages 141–152. ACM, 2006. PS98.

  • A. M. Pitts and I. D. B. Stark. Operational reasoning for functions with local state.

In A. D. Gordon and A. M. Pitts, editors, Higher-Order Operational Techniques in Semantics, pages 227–273. Cambridge University Press, 1998.

  • WPH14. Yannick Welsch and Arnd Poetzsch-Heffter. A fully abstract trace-based semantics

for reasoning about backward compatibility of class libraries. Science of Computer Programming, 92, Part B(0):129–161, 2014.

slide-31
SLIDE 31

FUTURE WORK

  • polymorphism
  • soundness and incompleteness