Asynchronous Games Paul-Andr Mellis Oregon Summer School in - - PowerPoint PPT Presentation

asynchronous games
SMART_READER_LITE
LIVE PREVIEW

Asynchronous Games Paul-Andr Mellis Oregon Summer School in - - PowerPoint PPT Presentation

Programming Languages in String Diagrams [ two ] Asynchronous Games Paul-Andr Mellis Oregon Summer School in Programming Languages June 2011 Starting point: game semantics Every proof of formula A initiates a dialogue where Proponent


slide-1
SLIDE 1

Programming Languages in String Diagrams [ two ]

Asynchronous Games

Paul-André Melliès Oregon Summer School in Programming Languages June 2011

slide-2
SLIDE 2

Starting point: game semantics

Every proof of formula A initiates a dialogue where Proponent tries to convince Opponent Opponent tries to refute Proponent An interactive approach to logic and programming languages

2

slide-3
SLIDE 3

A formal proof of the drinker formula

Axiom A(x0) ⊢ A(x0) Right Weakening A(x0) ⊢ A(x0), ∀x.A(x) Right ⇒ ⊢ A(x0), A(x0) ⇒ ∀x.A(x) Right ∃ ⊢ A(x0), ∃y.{A(y) ⇒ ∀x.A(x)} Right ∀ ⊢ ∀x.A(x), ∃y.{A(y) ⇒ ∀x.A(x)} Left Weakening A(y0) ⊢ ∀x.A(x), ∃y.{A(y) ⇒ ∀x.A(x)} Right ⇒ ⊢ A(y0) ⇒ ∀x.A(x), ∃y.{A(y) ⇒ ∀x.A(x)} Right ∃ ⊢ ∃y.{A(y) ⇒ ∀x.A(x)}, ∃y.{A(y) ⇒ ∀x.A(x)} Contraction ⊢ ∃y.{A(y) ⇒ ∀x.A(x)}

3

slide-4
SLIDE 4

Duality

Proponent Program plays the game A Opponent Environment plays the game ¬ A Negation permutes the rôles of Proponent and Opponent

4

slide-5
SLIDE 5

Duality

Opponent Environment plays the game ¬ A Proponent Program plays the game A Negation permutes the rôles of Opponent and Proponent

5

slide-6
SLIDE 6

Tensor product

Play the two games in parallel

6

slide-7
SLIDE 7

Sum

Proponent selects one component

7

slide-8
SLIDE 8

Exponentials

⊗ ⊗ ⊗ · · ·

Opponent opens as many copies as necessary to beat Proponent

8

slide-9
SLIDE 9

Sequential games

An idea dating back to André Joyal

9

slide-10
SLIDE 10

Traditional game semantics

A proof π alternating sequences of moves A proof π Game semantics: an interleaving semantics of proofs.

10

slide-11
SLIDE 11

Sequential games

A sequential game (M, P, λ) consists of M a set of moves, P ⊆ M∗ a set of plays, λ : M → {−1, +1} a polarity function on moves such that every play is alternating and starts by Opponent. Alternatively, a sequential game is an alternating decision tree.

11

slide-12
SLIDE 12

Sequential games

The boolean game B:

true

  • false
  • question
  • Player in red

Opponent in blue

12

slide-13
SLIDE 13

Deterministic strategies

A strategy σ is a set of alternating plays of even-length s = m1 · · · m2k such that: – σ contains the empty play, – σ is closed by even-length prefix: ∀s, ∀m, n ∈ M, s · m · n ∈ σ =⇒ s ∈ σ – σ is deterministic: ∀s ∈ σ, ∀m, n1, n2 ∈ M, s · m · n1 ∈ σ and s · m · n2 ∈ σ =⇒ n1 = n2.

13

slide-14
SLIDE 14

Three strategies on the boolean game B

true

  • false
  • question
  • Player in red

Opponent in blue

14

slide-15
SLIDE 15

Total strategies

A strategy σ is total when – for every play s of the strategy σ – for every Opponent move m such that s · m is a play there exists a Proponent move n such that s · m · n is a play of σ.

15

slide-16
SLIDE 16

Two total strategies on the boolean game B

true

  • false
  • question
  • Player in red

Opponent in blue

16

slide-17
SLIDE 17

Tensor product

Given two sequential games A and B, define A ⊗ B as the sequential game M A⊗B = MA + MB λ A⊗B = [ λA , λB ] P A⊗B = PA ⊗ PB where PA ⊗ PB denotes the set of alternating plays in M ∗

A⊗B

  • btained by interleaving a play s ∈ PA and a play t ∈ PB.

17

slide-18
SLIDE 18

Linear implication

Given two sequential games A and B, define A ⊸ B as the sequential game M A⊸B = MA + MB λ A⊸B = [ −λA , λB ] P A⊸B = PA ⊸ PB where PA ⊸ PB denotes the set of alternating plays in M ∗

A⊸B

  • btained by interleaving a play s ∈ PA and a play t ∈ PB.

18

slide-19
SLIDE 19

A category of sequential games

The category Games has – the sequential games as objects – the strategies of the sequential game σ ∈ A ⊸ B as maps σ : A −→ B

19

slide-20
SLIDE 20

The copycat strategy

The identity map idA : A −→ A is the copycat strategy idA : A ⊸ A defined as idA = { s ∈ PA⊸A | s = m1 · m1 · m2 · m2 · · · mk · mk }

20

slide-21
SLIDE 21

The copycat strategy

A

id

−→ A m1 m1 m2 m2 m3 m3 . . . . . . mk mk

21

slide-22
SLIDE 22

Composition

Given two strategies A

σ

−→ B

τ

−→ C the composite strategy A

σ ; τ

−→ C is defined as σ ; τ =      u ∈ PA⊸C

  • ∃ s ∈ σ , ∃ t ∈ τ

u↾A = s↾A s↾B = t↾B u↾C = t↾C      The definition of composition is associative.

22

slide-23
SLIDE 23

Illustration

1

true

−→ B

id

−→ B question question true true

23

slide-24
SLIDE 24

Illustration

1

false

−→ B

id

−→ B question question false false

24

slide-25
SLIDE 25

Illustration

1

true

−→ B

negation

−→ B question question true false

25

slide-26
SLIDE 26

An important isomorphism

The sequential game ( A ⊗ B ) ⊸ C is isomorphic to the sequential game A ⊸ ( B ⊸ C ) for all sequential games A, B, C. Here, isomorphism means tree isomorphism.

26

slide-27
SLIDE 27

The category of sequential games

Theorem. The category Games is symmetric monoidal closed. As such, it defines a model of linear λ-calculus.

27

slide-28
SLIDE 28

Illustration

( B ⊸ B ) ⊗ B

eval

−→ B question question bool bool f : B ⊸ B , x : B ⊢ f ( x ) : B

28

slide-29
SLIDE 29

Illustration

( B ⊸ B ) ⊗ B

eval

−→ B question question question question bool bool f ( bool ) f ( bool ) f : B ⊸ B , x : B ⊢ f ( x ) : B

29

slide-30
SLIDE 30

Illustration

( B ⊸ B )

id

−→ B ⊸ B question question question question bool bool f ( bool ) f ( bool ) f : B ⊸ B ⊢ λx . f ( x ) : B ⊸ B

30

slide-31
SLIDE 31

Currification

More generally, the transformation of the term Γ , x : A ⊢ f : B into the term Γ ⊢ λ x . f : A ⊸ B does not alter the associated strategy, simply reorganizes it.

31

slide-32
SLIDE 32

Cartesian product

Given two sequential games A and B, define A & B as the sequential game M A&B = MA + MB λ A&B = λA + λB P A&B = PA ⊕ PB where PA ⊕ PB is the coalesced sum of the pointed sets PA and PB. This means that every nonempty play in A&B is either in A or in B.

32

slide-33
SLIDE 33

The cartesian product

For every sequential game X, there exists an isomorphism X ⊸ A&B

  • (X ⊸ A)

& (X ⊸ B) This means that the game A&B is the cartesian product of A and B.

33

slide-34
SLIDE 34

The cartesian product

For every game X, there exists a bijection between the strategies X −→ A&B and the pair of strategies X −→ A X −→ B.

34

slide-35
SLIDE 35

The cartesian product

The cartesian product A&B of two objects A and B is an object equipped with two maps π1 : A&B −→ A π2 : A&B −→ B such that for all diagrams A X

f

  • g
  • A&B

π1

  • π2
  • B

there exists a unique map h : X −→ A × B making the diagram A X

h

  • f
  • g
  • A&B

π1

  • π2
  • B

commute.

35

slide-36
SLIDE 36

The exponential game

Given a sequential game A, define ! A as the game M ! A = N × MA λ ! A : (i, m) → λA(m) P ! A = ! PA where ! PA is the set of alternating plays in M ! A such that for all i ∈ N 1. the restriction s↾i of s to the i -th component is a play of A 2. for every prefix u

  • f

s : u↾i = ε ⇒ u↾ i + 1 = ε.

36

slide-37
SLIDE 37

Two important isomorphisms

Define A ⇒ B = ! A ⊸ B Observe the isomorphism ! ( A & B )

  • ! A ⊗ ! B

and the isomorphism ( A & B ) ⇒ C = ! ( A & B ) ⊸ C

  • ( ! A ⊗ ! B ) ⊸ C
  • ! A ⊸ ( ! B ⊸ C )

= A ⇒ ( B ⇒ C )

37

slide-38
SLIDE 38

A model of the simply-typed λ-calculus

Fact. Every simply-typed λ-term x1 : A1 , · · · , xk : Ak ⊢ M : B may be interpreted as a strategy in the game ! A1 ⊗ · · · ⊗ ! Ak −→ B Here, the modality ! enables to backtrack in the sequential games

38

slide-39
SLIDE 39

Illustration

! ( N ⊸ N ) ⊗ N

M

−→ N question question1 question1 question2 question2 question n n f(n) f(n) f f (n) f f (n)

f : ! ( N ⊸ N ) , x : N ⊢ f f ( x ) : N

39

slide-40
SLIDE 40

Asynchronous games

An asynchronous reconstruction of the λ-calculus

40

slide-41
SLIDE 41

Geometry of rewriting

M (λy.M)N (λy.M)Q (λx.(λy.x))MQ (λx.(λy.x))MN c b v u a

Can we do the same thing for open systems ?

41

slide-42
SLIDE 42

The traditional interleaving semantics

The boolean game B:

true

  • false
  • question
  • Player in red

Opponent in blue

42

slide-43
SLIDE 43

The traditional interleaving semantics

The tensor product of two boolean games B1 et B2:

false2

  • true1
  • question2
  • question1
  • true1
  • false2
  • question1
  • question2
  • 43
slide-44
SLIDE 44

A step towards true concurrency: bend the branches!

false2

  • true1
  • question2
  • question1
  • true1
  • false2
  • question1
  • question2
  • 44
slide-45
SLIDE 45

True concurrency: tile the diagram!

V ⊗ F V ⊗ q

false2

q ⊗ F

true1

  • V ⊗ ∗

q2

q ⊗ q

true1

  • false2

∗ ⊗ F

q1

  • q ⊗ ∗

true1

  • q2

∗ ⊗ q

q1

  • false2
  • ∗ ⊗ ∗

q1

  • q2
  • 45
slide-46
SLIDE 46

Asynchronous game semantics

A proof π trajectories in an asynchronous graph A proof π The phenomenon refined: a truly concurrent semantics of proofs.

46

slide-47
SLIDE 47

Event structures

An event structure ( M , ≤ , # ) consists of: — a partially ordered set ( M , ≤ ) where m ↓ = { n ∈ M | n ≤ m } is finite for every event m ∈ M, — a binary symmetric irreflexive relation # satisfying ∀m, n, p ∈ M, m # n ≤ p ⇒ m # p.

47

slide-48
SLIDE 48

The asynchronous graph

A position is a compatible downward-closed subset of M. The asynchronous graph has: — the finite positions as vertices — the triples (x, m, y) such that y = x ⊎ {m} as edges x −→ y. The asynchronous graph is pointed with the empty position ∗ as root.

48

slide-49
SLIDE 49

Event structures

E L2

  • R2
  • L1

R1 B

  • E
  • R2

L2

  • R1

L1

  • L2
  • R2
  • L1
  • R1
  • B
  • B · L1
  • · L2
  • · R1
  • · R2
  • · E
  • 49
slide-50
SLIDE 50

Event structures

E L2

  • R2
  • L1

R1 B

  • E
  • R2

L2

  • R1

L1

  • L2
  • R2
  • L1
  • R1
  • B
  • B · L1
  • · R1
  • · L2
  • · R2
  • · E
  • 50
slide-51
SLIDE 51

Asynchronous games

An asynchronous game is an event structure ( M , ≤ , # ) equipped with a polarity function λ : M −→ { −1 , +1 } indicating whether a move is Player (+1) or Opponent (−1).

51

slide-52
SLIDE 52

Legal plays

A legal play is a path ∗

m1

−→ x1

m2

−→ x2

m3

−→ · · · xk−1

mk

−→ xk starting from the empty position ∗ and satisfying: ∀i ∈ [1, ..., k] λ ( mi ) = ( −1 ) i So, a legal play is alternating and starts by an Opponent move.

52

slide-53
SLIDE 53

Strategies

A strategy is a set of legal plays of even length, such that: — σ contains the empty play, — σ is closed under even-length prefix s · m · n ∈ σ ⇒ s ∈ σ, — σ is deterministic s · m · n1 ∈ σ and s · m · n2 ∈ σ ⇒ n1 = n2. A strategy plays according to the current play.

53

slide-54
SLIDE 54

Innocence: strategies with partial information

Full definability result [Hyland, Ong, Nickau 1994] Innocence characterizes the interactive behavior of λ-terms. An innocent strategy plays according to the current view.

54

slide-55
SLIDE 55

A positionality theorem for innocent strategies

Starting from a local criterion of innocence

55

slide-56
SLIDE 56

Backward innocence

σ ∋

s2

  • P
  • O
  • P
  • O
  • O
  • s1

s2

  • P

P

  • O

O

  • P
  • P
  • O
  • O
  • s1
  • ∈ σ

56

slide-57
SLIDE 57

Forward innocence

σ ∋

O

  • P
  • P
  • O
  • O
  • s1
  • ∈ σ

=⇒ σ ∋

P

P

  • O

O

  • P
  • P
  • O
  • O
  • s1
  • ∈ σ

57

slide-58
SLIDE 58

Innocent strategies are positional

  • Definition. A strategy σ is positional when for every two plays s1 and

s2 with same target x: s1 ∈ σ and s2 ∈ σ and s1 · t ∈ σ ⇒ s2 · t ∈ σ Theorem (by an easy diagrammatic proof) Every innocent strategy σ is positional More: An innocent strategy is characterized by the positions it reaches.

58

slide-59
SLIDE 59

An illustration: the strategy (true ⊗ false)

59

slide-60
SLIDE 60

Hence, the schism between games and linear logic

strategy

halting positions

  • proo f
  • cliques

Imagine that a discussion is defined by the set of its final states

60

slide-61
SLIDE 61

Tensorial logic

A primitive logic of tensor and negation

61

slide-62
SLIDE 62

Five primitive components of logic

[1] the negation ¬ [2] the linear conjunction ⊗ [3] the repetition modality ! [4] the existential quantification ∃ [5] the least fixpoint µ Logic = Data Structure + Duality

62

slide-63
SLIDE 63

Tensorial logic

axiom A ⊢ A Γ ⊢ A A , ∆ ⊢ B cut Γ , ∆ ⊢ B Γ ⊢ A left ¬ Γ , ¬ A ⊢ Γ , A ⊢ right ¬ Γ ⊢ ¬ A Γ , A , B ⊢ C left ⊗ Γ , A ⊗ B ⊢ C Γ ⊢ A ∆ ⊢ B right ⊗ Γ , ∆ ⊢ A ⊗ B Γ ⊢ A left true Γ , true ⊢ A right true ⊢ true

63

slide-64
SLIDE 64

Tensorial logic

Γ ⊢ B weakening Γ , ! A ⊢ B Γ , ! A , ! A ⊢ B contraction Γ , ! A ⊢ B Γ , A ⊢ B dereliction Γ , ! A ⊢ B ! Γ ⊢ A promotion ! Γ ⊢ ! A Γ , A(x) ⊢ B left ∃ Γ , ∃x.A ⊢ B Γ ⊢ A(t) right ∃ Γ ⊢ ∃x.A

64

slide-65
SLIDE 65

Tensorial logic

The boolean in linear logic: B := ( 1 ⊕ 1 ) The boolean in tensorial logic: B := ¬ ¬ ( 1 ⊕ 1 ) The classical boolean in tensorial logic: C := ¬ ! ¬ ( 1 ⊕ 1 )

65

slide-66
SLIDE 66

The left-to-right implementation of conjunction

B ⊗ B −→ B question question answer1 question answer2 answer1 ∧ answer2

66

slide-67
SLIDE 67

The right-to-left implementation of conjuction

B ⊗ B −→ B question question answer2 question answer1 answer1 ∧ answer2

67

slide-68
SLIDE 68

A formal proof of the drinker formula

Axiom A(x0) ⊢ A(x0) Right Weakening A(x0) ⊢ A(x0), ∀x.A(x) Right ⇒ ⊢ A(x0), A(x0) ⇒ ∀x.A(x) Right ∃ ⊢ A(x0), ∃y.{A(y) ⇒ ∀x.A(x)} Right ∀ ⊢ ∀x.A(x), ∃y.{A(y) ⇒ ∀x.A(x)} Left Weakening A(y0) ⊢ ∀x.A(x), ∃y.{A(y) ⇒ ∀x.A(x)} Right ⇒ ⊢ A(y0) ⇒ ∀x.A(x), ∃y.{A(y) ⇒ ∀x.A(x)} Right ∃ ⊢ ∃y.{A(y) ⇒ ∀x.A(x)}, ∃y.{A(y) ⇒ ∀x.A(x)} Contraction ⊢ ∃y.{A(y) ⇒ ∀x.A(x)}

68

slide-69
SLIDE 69

The drinker formula in tensorial logic

∃y ⇒

  • A(y)

∀x A(x) → ¬ ! ¬ ∃y ¬ ⊗

  • !w

!w A(y) ∃x ¬ A(x)

69

slide-70
SLIDE 70

A proof of the drinker formula in tensorial logic

Axiom A(x0) ⊢ A(x0) Negation ¬ A(x0) , A(x0) ⊢ Dereliction ¬ A(x0) , !w A(x0) ⊢ Weakening ¬ A(x0) , !w A(x0) , !w ∃x ¬ A(x) ⊢ Negation ¬ A(x0) ⊢ ¬ { !w A(x0) ⊗ !w ∃x ¬ A(x) } Right ∃ ¬ A(x0) ⊢ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x)} Negation ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ¬ A(x0) ⊢ Left ∃ ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ∃x ¬ A(x) ⊢ Dereliction ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , !w ∃x ¬ A(x) ⊢ Weakening ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , !w A(y0) , !w ∃x.¬ A(x) ⊢ Negation ¬ ∃y.¬ { !w A(y) ⊗ !w ∃x.¬ A(x) } ⊢ ¬ { !w A(y0) ⊗ !w ∃x ¬ A(x) } Right ∃ ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ ∃y.¬ { !w A(y) ⊗ !w ∃x.¬ A(x) } Negation ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ Dereliction ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ Contraction ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ Negation ⊢ ¬ ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) }

70

slide-71
SLIDE 71

A proof of the drinker formula in tensorial logic

Axiom A(x0) ⊢ A(x0) Negation ¬ A(x0) , A(x0) ⊢ Dereliction ¬ A(x0) , !w A(x0) ⊢ Weakening ¬ A(x0) , !w A(x0) , !w ∃x ¬ A(x) ⊢ Negation 2 ¬ A(x0) ⊢ ¬ { !w A(x0) ⊗ !w ∃x ¬ A(x) } Right ∃ ¬ A(x0) ⊢ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x)} Negation 1 ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ¬ A(x0) ⊢ Left ∃ ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ∃x ¬ A(x) ⊢ Dereliction ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , !w ∃x ¬ A(x) ⊢ Weakening ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , !w A(y0) , !w ∃x.¬ A(x) ⊢ Negation 2 ¬ ∃y.¬ { !w A(y) ⊗ !w ∃x.¬ A(x) } ⊢ ¬ { !w A(y0) ⊗ !w ∃x ¬ A(x) } Right ∃ ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ ∃y.¬ { !w A(y) ⊗ !w ∃x.¬ A(x) } Negation 1 ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ Dereliction ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } , ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ Contraction ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) } ⊢ Negation 0 ⊢ ¬ ! ¬ ∃y ¬ { !w A(y) ⊗ !w ∃x ¬ A(x) }

71