Semantic Games for Synchrony M. Mendler & J. Aguado Informatics Theory Group University of Bamberg 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. 2 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Synchronous Configurations: A Declarative View Programming Synchronous Reactions (reactive) instant clock At every instant, signals may be present or absent, emitted or not emitted Transitions negative only positive positive a, ¬b / c, d trigger / action P, ¬N / A "if a present and b absent, then emit c and d" 4 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Programming Synchronous Reactions Transitions negative only positive Positive a, ¬b / c, d trigger / action P, ¬N / A "if a present and b absent, then emit c and d" Declarative a ∧¬ b ⊃ c ∧ d 5 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille How do we code configurations ? Reducible to parallel composition of transitions Encoding Nondeterministic (Statecharts) Transitions a, ¬ t 2 / b c, ¬ t 1 / d a / b c / d t 1 t 2 (a ∧ ¬ t 2 ⊃ b) ∧ (c ∧ ¬ t 1 ⊃ d) 6 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
How do we code configurations ? Reducible to parallel composition of transitions Deterministic Encoding (Esterel, SyncCharts) Transitions a / b c, ¬ a / d a / b <1> <2> c / d Priority (a ⊃ b) ∧ (c ∧ ¬ a ⊃ d) 7 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille How do we execute configurations ? Reducible to parallel composition of transitions Nondeterministic: (a ∧ ¬ t 2 ⊃ b) ∧ (c ∧ ¬ t 1 ⊃ d) Transitions Encoding Deterministic c / d a / b (a ⊃ b) ∧ (c ∧ ¬ a ⊃ d) t 2 (a ∧ ¬ c ⊃ b) ∧ (c ⊃ d) t 1 Sequential 8 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
How do we code configurations ? Reducible to parallel composition of transitions Sequential Transitions Eager t 1 t 2 c / d a / b Lazy t 2 t 1 t 2 t 1 t 2 9 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille How do we code configurations ? Reducible to parallel composition of transitions Transitions Sequential (Eager) Encoding c / d a / b a/ b, t 1 c, t 1 / d t 2 t 1 (a ⊃ b ∧ t 1 ) ∧ (c ∧ t 1 ⊃ d) 10 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
How do we code configurations ? Reducible to parallel composition of transitions Transitions Sequential (Lazy) Encoding c, (t 1 ∨ ¬ a) c / d a / b a / b, t 1 / d t 2 t 1 (a ⊃ b ∧ t 1 ) ∧ (c ∧ t 1 ⊃ d) ∧ ( c ∧ ¬ a / d) 11 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille How do we code configurations ? environment input + configuration ⇒ reaction Configuration environment reaction t 1 ∥ t 2 ∥ ... ∥ t N ⇒ stimulus ⇒ (event) (event) reducible to parallel composition of transitions Choice and priorities can be represented using negations 12 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
How do we code configurations ? configuration ⇒ reaction Configuration reaction t 1 ∥ t 2 ∥ ... ∥ t N ∥ /a,e ⇒ (event) reducible to parallel composition of transitions Choice and priorities can be represented using negations Environment stimulus can be accounted for as part of the configuration 13 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Configurations Kernel syntax (for "instantaneous" reactions in the combinational fragment) C ::= nothing C ::= true | emit s | s | present s then C | s / C | present s else C | ¬s / C | C || C | C || C s / C || ¬s / D present s then C else D 14 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Have a break ... play a Maze Finite 2-Player Games Finite game graph (maze) rooms secret corridor visible corridor token dungeon ● Players A , B take alternate turns: visible corridor ( ) = turn changes to opponent secret corridor ( ) = player keeps his/her turn ● Winning Rule: “last player loses” 16 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Finite 2-Player Games A starts 17 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Finite 2-Player Games A 18 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Finite 2-Player Games B 19 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Finite 2-Player Games A 20 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Finite 2-Player Games B 21 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Finite 2-Player Games A loses 22 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Finite 2-Player Games A 23 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Finite 2-Player Games B 24 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Finite 2-Player Games A 25 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Finite 2-Player Games B loses 26 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Strategies visible secret corridors rooms ι τ ι τ γ Let M = (R, , ) be a finite maze and ≔ ∪ . → → → → → 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 a unique 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 β are defined (maximality). 27 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Winning Positions Let length( α , β , r) be the length (possibly ∞ ). Let last( α , β , r) ∈ { A , B, ⊥ } the last player in play( α , β , r). 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 28 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Winning Positions Let length( α , β , r) be the length (possibly ∞ ). Let last( α , β , r) ∈ { A , B, ⊥ } the last player in play( α , β , r). 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 29 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Computing Winning Positions Bounded Winning n ≔ {r ∈ R | r is n-winning } R safe n ≔ {r ∈ R | r is n-safe } R win Iterative Approximation: win ≔ ∅ R -1 R -1 safe ≔ all win ≔ {r ∈ R | ∃ s ∈ R. R n+1 τ ι (r s ∧ s ∈ R n win ) ∨ (r s ∧ s ∉ R n → → safe )} R n+1 safe ≔ {r ∈ R | ∃ s ∈ R. τ ι (r s ∧ s ∈ R n safe ) ∨ (r s ∧ s ∉ R n → → win )} 30 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Computing Winning Positions The iteration constructs approximation sequences ∅ ⊆ R 0 win ⊆ R 1 win ⊆ R 2 win ⊆ ... ⊆ R n win ⊆ ... all ⊇ R 0 safe ⊇ R 1 safe ⊇ R 2 safe ⊇ ... ⊇ R n safe ⊇ ... in which ∅ ⊆ R n+1 win ⊆ R n+1 safe ⊆ all. Theorem (standard result) Let R win ≔ ∪ n R n win and R safe ≔ ∩ n R n safe . Then, ● r ∈ R win iff r winning position ● r ∈ all \ R safe iff r losing position ● r ∈ R safe \ R win iff r draw position. 31 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille So, what is the game in a synchronous reaction ?
Configurations as Mazes if c is winning position Maze G C a c then a is winning position y x d z b if b is losing position then d is winning position Configuration C c/a ║ a/x ║ ¬x/a ║ ¬d/a ║ ¬d/x ║ ¬y/d ║ c/y ║ ¬b/c ║ ¬b/y ║ ¬b/d ║ ¬z/b ● rooms = signals, corridors = transitions ● winning position = signal present ● losing position = signal absent 33 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille Mazes as Configurations Maze G C a c y x d b z Configuration C c/a ║ a/x ║ ¬x/a ║ ¬d/a ║ ¬d/x ║ ¬y/d ║ c/y ║ ¬b/c ║ ¬b/y ║ ¬b/d ║ ¬z/b R -1 win = ∅ R -1 safe = {a, b, c, d, x, y, z } 34 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
The Esterel Game Maze G C a c y x d z b lose Configuration C c/a ║ a/x ║ ¬x/a ║ ¬d/a ║ ¬d/x ║ ¬y/d ║ c/y ║ ¬b/c ║ ¬b/y ║ ¬b/d ║ ¬z/b R 0 win = ∅ present R 0 safe = {a, b, c, d, x, y } z absent 35 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille The Esterel Game Maze G C a c y x d b z lose Configuration C c/a ║ a/x ║ ¬x/a ║ ¬d/a ║ ¬d/x ║ ¬y/d ║ c/y ║ ¬b/c ║ ¬b/y ║ ¬b/d ║ ¬z/b R 1 win = { b } b present R 1 safe = {a, b, c, d, x, y } z absent 36 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
The Esterel Game Maze G C a c y x d z b lose Configuration C c/a ║ a/x ║ ¬x/a ║ ¬d/a ║ ¬d/x ║ ¬y/d ║ c/y ║ ¬b/c ║ ¬b/y ║ ¬b/d ║ ¬z/b R 2 win = { b } b present R 2 safe = {a, b, d, x, y } z,c absent 37 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille The Esterel Game Maze G C a c y x d b z lose Configuration C c/a ║ a/x ║ ¬x/a ║ ¬d/a ║ ¬d/x ║ ¬y/d ║ c/y ║ ¬b/c ║ ¬b/y ║ ¬b/d ║ ¬z/b R 3 win = { b } b present R 3 safe = {a, b, d, x } z,c,y absent 38 J. Aguado, Dec/02/03 SYNCHRON'03 Marseille
Recommend
More recommend