42
Concurrent Strategies Glynn Winskel The notion of deterministic/nondeterministic strategy is potentially as fundamental as the notion of function/relation. The notion needs to be developed in sufficient generality. Two-party concurrent games: Player (a team of players) against Opponent (a team of opponents) subject to constraints of the game. For Player/Opponent read process/environment, proof/refutation, ally/enemy. First: in a general model for concurrency. Later: a recent more geometrical view FOSSACS Tallinn March 2012

Concurrent Strategiescs.ioc.ee/etaps12/invited/winskel-slides.pdf · 2012. 4. 7. · theory (a generalized domain theory) to capture the ways of computing, to near operational and

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

  • Concurrent Strategies

    Glynn Winskel

    The notion of deterministic/nondeterministic strategyis potentially as fundamental as the notion of function/relation.The notion needs to be developed in sufficient generality.

    Two-party concurrent games: Player (a team of players) against Opponent (ateam of opponents) subject to constraints of the game.For Player/Opponent read process/environment, proof/refutation, ally/enemy.

    First: in a general model for concurrency. Later: a recent more geometrical view

    FOSSACS Tallinn March 2012

  • Motivation from semantics and logic

    In Semantics of computation it’s become clear that we need an intensionaltheory (a generalized domain theory) to capture the ways of computing, to nearoperational and algorithmic concerns.

    What are to replace functions?

    A possible answer: strategies, “functions (or relations) extended in time.” [AJ][There are others, e.g. profunctors as maps between presheaf categories.]

    In Logic the well-known Curry-Howard correspondence:Propositions as types, proofs as programsis being recast: Propositions as games, proofs as strategies.

    Traditional definitions of strategies in games are not general enough!Too sequential, too alternating ...

    1

  • From strategies to arrowsTwo important operations on games:parallel composition of games G‖H ;dual of a game G⊥ (reversing the roles of Player and Opponent)

    Joyal after Conway: A strategy σ from a game G to a game H, σ : G + // H, isa strategy in G⊥‖H; strategies compose with identities given by ‘copy-cat.’

    A strategy in H corresponds to a strategy from the empty game ∅ to H. Note

    ∅ + // G + // H composes to give ∅ + // H ,

    so a strategy in G gives rise to a strategy in H when G + // H.Conway’s surreal numbers are strengths of games.

    2

  • Games in a model for concurrency (via Joyal-Conway)

    Lead to

    • Generalised domain theory

    • Operations, including higher-order operations via “function spaces” G⊥‖H,within the model for concurrency

    • Techniques for Logic (via proofs as concurrent strategies) and possiblyverification and algorithmics

    3

  • 1. EVENT STRUCTURES

    Event structures are the analogue of trees in a concurrent setting,where the causal dependence and independence of events is made explicit.

    E.g. just as a transition system unfolds to a tree, a more general model forconcurrency such as a Petri net unfolds to an event structure.

    4

  • Event structures

    An event structure comprises (E,≤,Con), consisting of a set of events E

    - partially ordered by ≤, the causal dependency relation, and

    - a nonempty family Con of finite subsets of E, the consistency relation,

    which satisfy{e′ | e′ ≤ e} is finite for all e ∈ E,{e} ∈ Con for all e ∈ E,Y ⊆ X ∈ Con⇒ Y ∈ Con, andX ∈ Con & e ≤ e′ ∈ X ⇒ X ∪ {e} ∈ Con.

    In games the relation of immediate dependency e _ e′, meaning e and e′ aredistinct with e ≤ e′ and no event in between, will play an important role.

    5

  • Configurations of an event structure

    The configurations, C∞(E), of an event structure E consist of those subsetsx ⊆ E which are

    Consistent: ∀X ⊆fin x. X ∈ Con and

    Down-closed: ∀e, e′. e′ ≤ e ∈ x⇒ e′ ∈ x.

    Often concentrate on the finite configurations C(E).

    6

  • Example: Streams as event structures

    000 /o/o/o 001 010 /o/o/o 011 110 /o/o/o 111

    00

    ccFFFFFFFFF

    OO OO

    /o/o/o/o 01

    OO ;;xxxxxxxxx

    ... /o/o/o/o/o 11

    ;;xxxxxxxxx

    OO

    0

    ccFFFFFFFFFFF

    OO

    /o/o/o/o/o/o 1

    ;;xxxxxxxxxxx

    /o/o/o conflict (inconsistency) // immediate causal dependency

    7

  • Simple parallel composition

    000 /o/o/o 001 010 /o/o/o 011 110 /o/o/o 111

    00

    ccFFFFFFFFF

    OOOO

    /o/o/o/o 01

    OO ;;xxxxxxxxx

    ... /o/o/o/o/o 11

    ;;xxxxxxxxx

    OO

    0

    ccFFFFFFFFFFF

    OO

    /o/o/o/o/o/o 1

    ;;xxxxxxxxxxx

    aaa /o/o/o aab aba /o/o/o abb bba /o/o/o bbb

    aa

    ccFFFFFFFFFF

    OO OO

    /o/o/o/o ab

    OO

  • Other examples

    © ©

    ©

    _LLR_LLR

    ©

    �ZZe @@@@@@@

    _LLR

    /o/o/o ©

    © © ©

    1 2 3

    Con = { ∅, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3} }

    9

  • Maps of event structures

    A (simulation) map of event structures f : E → E′is a partial function on events f : E ⇀ E′ such that for all x ∈ C(E)

    fx ∈ C(E′) andif e1, e2 ∈ x and f(e1) = f(e2), then e1 = e2. (‘event linearity’)

    Idea: the occurrence of an event e in E induces the coincident occurrence ofthe event f(e) in E′ whenever it is defined.

    ;

    • Semantics of synchronising processes [Hoare, Milner] can be expressed in termsof universal constructions on event structures.

    • Relations between models via adjunctions.

    10

  • Process constructions on event structures

    “Partial synchronous” product: A×B with projections Π1 and Π2,cf. synchronized composition where all events of A can synchronize with all eventsof B. (Hard to construct directly, use e.g. coreflection with stable families.)

    Restriction: E �R, the restriction of an event structure E to a subset of eventsR, has events E′ = {e ∈ E | [e] ⊆ R} with causal dependency and consistencyrestricted from E.

    Synchronized compositions: restrictions of products A × B � R, where Rspecifies the allowed synchronized and unsynchronized events.

    Projection: Let E be an event structure. Let V be a subset of ‘visible’ events.The projection of E on V , E↓V , has events V with causal dependency andconsistency restricted from E.

    11

  • Product—an example

    b (b, ∗)2r 1q 0p

    /o .n -m ,l

    (b, ∗) /o/o/o (b, c)

    × =

    a

    _LLR

    c (a, ∗)

    _LLR 5 66?uuuuuuuuuuuuuuuuuuuuuuuuuuuuu

    /o/o/o (a, c)

    _LLR

    /o/o/o (∗, c)

    O�O�O�O�O�O�O�O�O�O�O�

    12

  • Process constructions on event structures

    “Partial synchronous” product: A×B with projections Π1 and Π2,cf. synchronized composition where all events of A can synchronize with all eventsof B. (Hard to construct directly, use e.g. coreflection with stable families.)

    Restriction: E �R, the restriction of an event structure E to a subset of eventsR, has events E′ = {e ∈ E | [e] ⊆ R} with causal dependency and consistencyrestricted from E.

    Synchronized compositions: restrictions of products A × B � R, where Rspecifies the allowed synchronized and unsynchronized events.

    Projection: Let E be an event structure. Let V be a subset of ‘visible’ events.The projection of E on V , E↓V , has events V with causal dependency andconsistency restricted from E.

    13

  • 2. CONCURRENT GAMES

    The paradigm of Joyal-Conway carried out in event structures.

    We define and characterize concurrent strategies, those pre-strategies,i.e. nondeterministic plays, for which copy-cat strategies act as identities.

    14

  • Concurrent games—basics

    Games and strategies are represented by event structures with polarity, whereevents carry a polarity +/− (Player/Opponent), respected by maps.

    (Simple) Parallel composition: A‖B , by juxtaposition.

    Dual, B⊥, of an event structure with polarity B is a copy of the event structureB with a reversal of polarities; b ∈ B⊥ is complement of b ∈ B, and vice versa.

    A (nondeterministic) concurrent pre-strategy in game A is a total map

    σ : S → A

    of event structures with polarity (a nondeterministic play in game A).

    15

  • Pre-strategies as arrows

    A pre-strategy σ : A + // B is a total map of event structures with polarity

    σ : S → A⊥ ‖ B .

    It corresponds to a span of event structures with polarity

    Sσ1

    ~~||||

    |||| σ2

    ��???

    ????

    ?

    A⊥ B

    where σ1, σ2 are partial maps of event structures with polarity; one and only oneof σ1, σ2 is defined on each event of S.

    Pre-strategies are isomorphic if they are isomorphic as spans.

    16

  • Concurrent copy-cat

    Identities on games A are given by copy-cat strategies

    γA : CCA → A⊥ ‖ A

    —strategies for player based on copying the latest moves made by opponent.

    CCA has the same events, consistency and polarity as A⊥ ‖ A but with causaldependency ≤CCA given as the transitive closure of the relation

    ≤A⊥‖A ∪ {(c, c) | c ∈ A⊥ ‖ A & polA⊥‖A(c) = +}

    where c↔ c is the natural correspondence between A⊥ and A.

    The map γA is the identity on the common underlying set of events.

    17

  • Copy-cat—an example

    CCA

    A⊥ A

    a2 � ,,2___________ ⊕ a2

    a1 ⊕

    _LLR

    _LLR

    �llr _ _ _ _ _ _ _ _ _ _ _ a1

    18

  • Composing pre-strategies

    Two pre-strategies σ : A + // B and τ : B + // C as spans:

    Sσ1

    ~~||||

    |||| σ2

    ��???

    ????

    ?

    A⊥ B

    Tτ1

    }}||||

    ||||

    τ2

    AAA

    AAAA

    A

    B⊥ C .

    Their composition

    T�S(τ�σ)1

    {{wwwww

    wwww

    (τ�σ)2

    ""EEE

    EEEE

    EE

    A⊥ C

    where T�S =def (S × T � Syn) ↓ Vis where ...

    19

  • S × TΠ1

    vvmmmmmm

    mmmmmm

    mmmmmm

    m Π2

    ))SSSSS

    SSSSSS

    SSSSSS

    SSSS

    Sσ1

    ~~||||

    |||| σ2

    ��???

    ????

    ?T

    τ1

    }}||||

    |||| τ2

    ��???

    ????

    ?

    A⊥ B B⊥ C

    Their composition: T�S =def (S × T � Syn) ↓ Vis where

    Syn = {p ∈ S × T | σ1Π1(p) is defined & Π2(p) is undefined} ∪

    {p ∈ S × T | σ2Π1(p) = τ1Π2(p) with both defined} ∪{p ∈ S × T | τ2Π2(p) is defined & Π1(p) is undefined} ,

    Vis = {p ∈ S × T � Syn | σ1Π1(p) is defined} ∪{p ∈ S × T � Syn | τ2Π2(p) is defined} .

    20

  • Theorem characterizing concurrent strategies

    Receptivity σ : S → A⊥ ‖ B is receptive when σ(x)−⊂−y implies there is aunique x′ ∈ C(S) such that x−⊂x′ & σ(x′) = y . x −⊂

    _

    ��

    x′_

    ��

    σx −⊂− y

    A strategy should be receptive to all possible moves of opponent.

    Innocence σ : S → A⊥ ‖ B is innocent when it is+-Innocence: If s _ s′ & pol(s) = + then σ(s) _ σ(s′) and−-Innocence: If s _ s′ & pol(s ′) = − then σ(s) _ σ(s′).A strategy should only adjoin immediate causal dependencies _ ⊕.

    Theorem Receptivity and innocence are necessary and sufficient for copy-cat toact as identity w.r.t. composition: γB�σ�γA ∼= σ. [Silvain Rideau, GW]

    21

  • Definition A strategy is a receptive, innocent pre-strategy.

    ; A bicategory, Games, whose

    objects are event structures with polarity—the games,

    maps are strategies σ : A + // B

    2-cells are maps of spans.

    The vertical composition of 2-cells is the usual composition of maps of spans.Horizontal composition is given by the composition of strategies � (which extendsto a functor on 2-cells via the functoriality of synchronized composition).

    ; A sub-category where maps are deterministic strategies andobjects are ‘race-free’ games. [Melliès & Mimram’s receptive ingenuous strategies]

    22

  • Winning strategies

    The paradigm of Joyal-Conway carries through in concurrent games A withwinning conditions W ⊆ C∞(A):

    A strategy σ : S → A in (A,W ) is winning (for Player)

    iff

    any maximal play against a counter-strategy results in a win for Player

    iff

    σx ∈W , for all +-maximal configurations x ∈ C∞(S).

    23

  • A winning strategy from (A,WA) to (B,WB) is a winning strategy in(A,WA)⊥‖(B,WB) where

    (A,WA)⊥ = (A⊥,WA⊥) where WA⊥ is the complement of WA.

    (A,WA)‖(B,WB) = (A‖B,WA‖B) where

    x ∈WA‖B ⇐⇒ xA ∈WA or xB ∈WB .

    To win in G‖H is to win in either game G or H.

    Winning strategies compose ; a bicategory of winning strategies.

    24

  • Extensions

    Determinacy for well-founded race-free concurrent games with winningconditions; concurrent game semantics for PC and a version of Hintikka’s IFLogic [LICS 2012 with Julian Gutierrez and Pierre Clairambault]

    Games with neutral configurations and imperfect information via access levels[Dexter Kozen festschrift]

    Back-tracking? To do so developing games with symmetry to support copyingmonads/comonads. ; fully-fledged generalized domain theory for concurrency

    Concurrent games with pay-off, early stages [with Pierre Clairambault]

    Linear strategies and full completeness for MALL [FOSSACS paper is wrong inclaiming the linear strategies as defined there yield a monoidal closed category!]

    • Games on categories with a factorization system ; a geometrical view •

    25

  • An alternative description of strategies

    A strategy in a game A comprises σ : S → A, a total map of event structureswith polarity, such that(i) whenever σx ⊆− y in C(A) there is a unique x′ ∈ C(S) so thatx ⊆ x′ & σx′ = y , i.e. x

    _

    σ��

    ⊆ x′_

    σ��

    σx ⊆− y ,

    and(ii) whenever y ⊆+ σx in C(A) there is a (necessarily unique) x′ ∈ C(S) so thatx′ ⊆ x & σx′ = y , i.e. x′

    _

    σ��

    ⊆ x_

    σ��

    y ⊆+ σx .

    26

  • Corollary

    Defining a partial order — the Scott order — on configurations of A

    x v y ⇐⇒def x ⊇− x ∩ y ⊆+ y ,

    we obtain a factorization system ((C(A),vA),⊇−,⊆+), i.e.

    y

    ∃!z. xv

    ⊇− z .

    ⊆+

    Theorem Strategies σ : S → A correspond to a discrete fibrations

    σ“ : (C(S),vS)→ (C(A),vA) , i .e.∃!x′. x′

    _

    �

    vS x_

    σ“��y vA σ“(x) ,

    preserving ⊇−, ⊆+ and ∅.

    27

  • From strategies to profunctors

    A strategy σ : A + // B determines a discrete fibration so a presheaf over

    (C(A⊥‖B),vA⊥‖B) ∼= (C(A),vA)op × (C(B),vB)

    i.e. a profunctor σ“ : (C(A),vA) + // (C(B),vB).

    ; a lax pseudo functor ( )“ : Games→ Prof ; have (τ�σ)“⇒ τ“ ◦ σ“.The profunctor composition introduces extra ‘unreachable’ elements.

    Not lax for ‘rigid’ strategies including : simple games; sub-bicategory of “stablespans” with objects A,B, · · · purely +ve.

    28

  • 3. GAMES AS FACTORIZATION SYSTEMS

    A rooted factorization system (C, L,R, 0) comprises a small category C onwhich there is a factorization system (C, L,R),

    so all maps c→ c′ factor uniquely up to iso as c′

    c

    ??��������

    L

    // c′′R

    OO,

    with an object 0 s.t.0←L · →R · · · ←L · →R c

    for all objects c in C.

    Example ( (C(A),vA) , ⊇−, ⊆+, ∅) for a concurrent game A.

    29

  • StrategiesA strategy on a rooted factorization system (A, LA, RA, 0A) is a discrete fibration

    F : (S, LS, RS, 0S)→ (A, LA, RA, 0A) ,

    from another rooted factorization system (S, LS, RS, 0S), which preserves L, Rmaps and 0.Example: The map σ“ : ((C(S),vS),⊇−,⊆+, ∅)→ ((C(A),vA),⊇−,⊆+, ∅)

    induced by a strategy σ : S → A.

    Operations (C, L,R, 0)⊥ =def (Cop, Rop, Lop, 0)

    (B, LB, RB, 0B)‖(C, LC, RC, 0C) =def (B× C, LB × LC, RB ×RC, (0B, 0C))

    Composition: reachable part of profunctor composition.

    ; ‘Venn diagrams’ for games and strategies.

    30

  • 0L

    R

    L

    R

    Example:!the!Euclidean!quarter!plane

    (x,y)

    (x',y')

    (x',y)

    a!typical!map

    a!reverse!

    Opponent!move

    a!Player!

    move

  • 0L

    R

    A!typical!play

    R

    R

    R

    R

    L

    L

    L

  • 0L

    R

    A!typical!play

    R

    R

    R

    R

    L

    L

    L

    an!equivalent!play

  • 0L

    R

    A!typical!deterministic!strategy

  • 0L

    R

    A!typical!deterministic!counter-strategy

  • 0L

    R

    Their!play!against!each!other!

  • 0L

    R

    Their!play!against!each!other!

  • 0L

    R

    Their!play!against!each!other!

    an!equivalent!play

  • 0L

    R

    Winning!strategies

    A!strategy!is!winning!wrt!winning!

    conditions!which!include!its!R-maxl!

    paths

  • A similar example: the game of chase

    Player: the Hunter, velocity vector h; its moves are changes in velocity ∆h

    Opponent: the Prey, velocity vector p; its moves are changes in velocity ∆p

    A strategy for Hunter (observed in people): run (towards Prey) so Prey appearsto be moving in a fixed straight line (direction vector d) from Hunter’s viewpoint,i.e. adjust velocity to maintain the winning condition

    p− h = c.d for some positive real c

    within a game with positions (p,h).

    [BBC Horizon programme “The Unconscious Mind”]

    40

  • THANK YOU!

    41