semantic games for synchrony - €¦semantic games for synchrony m. mendler & j. aguado...

21
Semantic Games for Synchrony M. Mendler & J. Aguado Informatics Theory Group University of Bamberg J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 2 What is this talk about? To illustrate how the co-contravariant fixed point problem in synchronous languages can be handled by means of a game theory approach. To show that the Must/Cannot analysis of combinational Esterel corresponds to the computation of winning strategies of a particular game (the maze). Sequencing is modelled by a notion of stratified plays.

Upload: others

Post on 06-Sep-2019

2 views

Category:

Documents


0 download

TRANSCRIPT

Semantic Games for Synchrony

M. Mendler & J. Aguado Informatics Theory GroupUniversity of Bamberg

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 2

What is this talk about?

● To illustrate how the co-contravariant fixed point problem in synchronous languages can be handled by means of a game theory approach.

● To show that the Must/Cannot analysis of combinational Esterel corresponds to the computation of winning strategies of a particular game (the maze).

● Sequencing is modelled by a notion of stratified plays.

Synchronous Configurations: A Declarative View

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 4

Programming Synchronous Reactions

At every instant, signals may be present or absent, emitted or not emitted

(reactive) instant

clock

"if a present and b absent, then emit c and d"

a, ¬b / c, d

trigger / action

positivenegative only positive

Transitions

P, ¬N / A

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 5

Programming Synchronous Reactions

"if a present and b absent, then emit c and d"

a, ¬b / c, d

trigger / action

Positivenegative only positive

Transitions

P, ¬N / A

Declarativea ∧¬b ⊃ c ∧ d

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 6

How do we code configurations ?

Transitions

a / b c / d

Nondeterministic (Statecharts)

a, ¬t2 / b c, ¬t

1 / d

(a ∧ ¬t2 ⊃ b) ∧ (c ∧ ¬t

1 ⊃ d)

Reducible to parallel composition of transitions

t1 t

2

Encoding

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 7

How do we code configurations ?

Transitions

a / b c / d

Deterministic (Esterel, SyncCharts)

a / b c, ¬a / d

(a ⊃ b) ∧ (c ∧ ¬a ⊃ d)

<1> <2>

Priority

Encoding

Reducible to parallel composition of transitions

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 8

How do we execute configurations ?

Transitions

a / b c / d

t2 t

1

Encoding

Nondeterministic:(a ∧ ¬t

2 ⊃ b) ∧ (c ∧ ¬t

1 ⊃ d)

Deterministic(a ⊃ b) ∧ (c ∧ ¬a ⊃ d)(a ∧ ¬c ⊃ b) ∧ (c ⊃ d)

Sequential

Reducible to parallel composition of transitions

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 9

How do we code configurations ?

SequentialTransitions

a / b c / d

t2 t

1

Eager

t2 t

1

t1

t2

Lazy

t2

Reducible to parallel composition of transitions

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 10

How do we code configurations ?

Transitions

a / b c / d

t2 t

1

Sequential (Eager)

a/ b, t1

c, t1/ d

(a ⊃ b ∧ t1) ∧ (c ∧ t

1 ⊃ d)

Encoding

Reducible to parallel composition of transitions

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 11

How do we code configurations ?

Sequential (Lazy)

a / b, t1

(a ⊃ b ∧ t1) ∧ (c ∧ t

1 ⊃ d) ∧ (c ∧ ¬a / d)

Transitions

a / b c / d

t2 t

1

Encoding

c, (t1 ∨ ¬a)

/ d

Reducible to parallel composition of transitions

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 12

How do we code configurations ?

reducible to parallel composition of transitions

environment stimulus(event)

reaction(event)

⇒⇒

Configuration

Choice and priorities can be represented using negations

environment input + configuration ⇒ reaction

t1∥t

2∥ ...∥t

N

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 13

How do we code configurations ?

reducible to parallel composition of transitions

reaction(event)

Configuration

Choice and priorities can be represented using negations

configuration ⇒ reaction

Environment stimulus can be accounted for as part of the configuration

t1∥t

2∥ ...∥t

N∥/a,e

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 14

Configurations

Kernel syntax (for "instantaneous" reactions in the combinational fragment)

C ::= nothing | emit s | present s then C | present s else C | C || C

C ::= true | s | s / C | ¬s / C | C || C

present s then C else D s / C || ¬s / D

Have a break ... play a Maze

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 16

● Players A, B take alternate turns: visible corridor ( ) = turn changes to opponent secret corridor ( ) = player keeps his/her turn

● Winning Rule: “last player loses”

Finite 2-Player Games

Finite game graph (maze)

rooms

visible corridor

secret corridor

dungeon

token

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 17

Finite 2-Player Games

A starts

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 18

Finite 2-Player Games

A

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 19

Finite 2-Player Games

B

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 20

Finite 2-Player Games

A

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 21

Finite 2-Player Games

B

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 22

Finite 2-Player Games

A loses

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 23

Finite 2-Player Games

A

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 24

Finite 2-Player Games

B

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 25

Finite 2-Player Games

A

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 26

Finite 2-Player Games

B loses

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 27

Strategies

Let M = (R, , ) be a finite maze and ≔ ∪ . →ι →τ

rooms visible secret corridors

→γ →ι →τ

A strategy is a partial mapping α : R → R such that∀r. if α(r) is defined then r α(r). →γ

A pair of strategies (α, β) and a start room r determines aunique play in M, denoted play(α, β, r), where

player A uses function αplayer B uses function β

to determine his/her next move, as long as α and β aredefined (maximality).

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 28

Winning Positions

A room r ∈ R is called a winning position (for the starting player A)

if ∃α.∀β. last(α, β, r) = B losing position (for the starting player A)

if ∀α.∃β. last(α, β, r) = A

Let length(α, β, r) be the length (possibly ∞). Let last(α, β, r) ∈ {A, B, ⊥} the last player in play(α, β, r).

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 29

Winning Positions

A room r ∈ R is called an n-winning position (for the starting player A)

if ∃α.∀β. length(α, β, r) ≤ n & last(α, β, r) = B n-losing position (for the starting player A)

if ∀α.∃β. length(α, β, r) ≤ n & last(α, β, r) = A n-safe position (for the starting player A)

if ∃α.∀β. length(α, β, r) > n ∨ last(α, β, r) = B

Let length(α, β, r) be the length (possibly ∞). Let last(α, β, r) ∈ {A, B, ⊥} the last player in play(α, β, r).

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 30

Computing Winning Positions

Rwin

n ≔ {r∈R | r is n-winning } Rsafe

n ≔ {r∈R | r is n-safe }

Bounded Winning

Iterative Approximation:

R-1

win ≔ ∅

R-1safe

≔ all

Rn+1

win ≔ {r∈R | ∃s∈R.

(r s ∧ s∈Rn

win) ∨ (r s ∧ s∉Rn

safe)}

Rn+1

safe ≔ {r∈R | ∃s∈R.

(r s ∧ s∈Rn

safe) ∨ (r s ∧ s∉Rn

win)}

→τ →ι

→ι→τ

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 31

Computing Winning Positions

The iteration constructs approximation sequences

∅ ⊆ R0

win ⊆ R1

win ⊆ R2

win ⊆ ... ⊆ Rn

win ⊆ ...

all ⊇ R0

safe ⊇ R1

safe ⊇ R2

safe ⊇ ... ⊇ Rn

safe ⊇ ...

in which ∅ ⊆ Rn+1

win ⊆ Rn+1

safe ⊆ all.

Theorem (standard result)

Let Rwin

≔ ∪n Rn

win and R

safe ≔

n Rn

safe. Then,

● r ∈ Rwin

iff r winning position

● r ∈ all \ Rsafe

iff r losing position

● r ∈ Rsafe

\ Rwin

iff r draw position.

So, what is the game in a synchronous reaction ?

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 33

Configurations as Mazes

a

b

c

d

● rooms = signals, corridors = transitions● winning position = signal present● losing position = signal absent

z

x y

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

Maze GC

Configuration C

if c is winning position then a is winning position

if b is losing position then d is winning position

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 34

Mazes as Configurations

a

b

c

d z

x y

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

Maze GC

Configuration C

R-1

win = ∅

R-1

safe = {a, b, c, d, x, y, z }

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 35

The Esterel Game

a

b

c

d z

x y

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

Maze GC

Configuration C

R0

win = ∅

R0

safe = {a, b, c, d, x, y }

lose

present z absent

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 36

The Esterel Game

a

b

c

d z

x y

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

Maze GC

Configuration C

R1

win = { b }

R1

safe = {a, b, c, d, x, y }

b present z absent

lose

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 37

The Esterel Game

a

b

c

d z

x y

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

Maze GC

Configuration C

R2

win = { b }

R2

safe = {a, b, d, x, y }

lose

b present z,c absent

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 38

The Esterel Game

a

b

c

d z

x y

Maze GC

Configuration C

R3

win = { b }

R3

safe = {a, b, d, x }

lose

b present z,c,y absent

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 39

The Esterel Game

a

b

c

d z

x y

Maze GC

Configuration C

R4

win = { b, d }

R4

safe = {a, b, d, x }

lose

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

b,d present z,c,y absent

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 40

The Esterel Game

a

b

c

d z

x y

Maze GC

Configuration C

R5

win = { b, d } = R4

win

R5

safe = {a, b, d, x } = R4

safe

lose

Fixed point reached b,d present z,c,y absent

c/a║a/x║¬x/a║¬d/a║¬d/x║¬y/d║c/y║¬b/c║¬b/y║¬b/d║¬z/b

J. Aguado, Dec/02/03 SYNCHRON'03 Marseille 41

Coincidence Theorem

Theorem

Let C be a configuration and GC be the game associated

with C. Then, for all signals a ∈ Sigs:

a is present in the Esterel reaction of C iff a is a winning position in G

C

a is absent in the Esterel reaction of C iff a is a losing position in G

C

a is non-constructive in the Esterel reaction of C

iff a is a draw position