A Simple Game Semantics Model of Concurrency

2 downloads 0 Views 283KB Size Report
Davide Marchignoli. Technical Report ... Davide Marchignoli. 4. Technical ...... [3] A. Asperti, G. Longo, Categories, Types and Structures, The MIT press, 1992.
A Simple Game Semantics Model of Concurrency

Andrea Asperti

Michele Finelli Gianluca Franco Davide Marchignoli

Technical Report UBLCS-99-17 July 1999

Department of Computer Science University of Bologna Mura Anteo Zamboni 7 40127 Bologna (Italy)

The University of Bologna Department of Computer Science Research Technical Reports are available in gzipped PostScript format via anonymous FTP from the area ftp.cs.unibo.it:/pub/TR/UBLCS or via WWW at URL http://www.cs.unibo.it/. Plain-text abstracts organized by year are available in the directory ABSTRACTS. All local authors can be reached via e-mail at the address [email protected]. Questions and comments should be addressed to [email protected].

Recent Titles from the UBLCS Technical Report Series 97-9 Generalized Semi-Markovian Process Algebra, M. Bravetti, M. Bernardo, R. Gorrieri, October 1997. ¨ Babao˘glu, R. Davoli, A. 98-1 Group Communication in Partitionable Systems: Specification and Algorithms, O. Montresor, April 1998 (Revised May 1999). 98-2 A Catalog of Architectural Styles for Mobility, P. Ciancarini, C. Mascolo, April 1998. 98-3 Comparing Three Semantics for Linda-like Languages, N. Busi, R. Gorrieri, G. Zavattaro, May 1998. 98-4 Design and Experimental Evaluation of an Adaptive Playout Delay Control Mechanism for Packetized Audio for use over the Internet, M. Roccetti, V. Ghini, P. Salomoni, M.E. Bonfigli, G. Pau, May 1998 (Revised November 1998). 98-5 Analysis of MetaRing: a Real-Time Protocol for Metropolitan Area Network, M. Conti, L. Donatiello, M. Furini, May 1998. 98-6 GSMPA: A Core Calculus With Generally Distributed Durations, M. Bravetti, M. Bernardo, R. Gorrieri, June 1998. 98-7 A Communication Architecture for Critical Distributed Multimedia Applications: Design, Implementation, and Evaluation, F. Panzieri, M. Roccetti, June 1998. 98-8 Formal Specification of Performance Measures for Process Algebra Models of Concurrent Systems, M. Bernardo, June 1998. 98-9 Formal Performance Modeling and Evaluation of an Adaptive Mechanism for Packetized Audio over the Internet, M. Bernardo, R. Gorrieri, M. Roccetti, June 1998. 98-10 Value Passing in Stochastically Timed Process Algebras: A Symbolic Approach based on Lookahead, M. Bernardo, June 1998. 98-11 Structuring Sub-Populations in Parallel Genetic Algorithms for MPP, R. Gaioni, R. Davoli, June 1998. 98-12 The Jgroup Reliable Distributed Object Model, A. Montresor, December 1998 (Revised March 1999). 99-1 Deciding and Axiomatizing ST Bisimulation for a Process Algebra with Recursion and Action Refinement, M. Bravetti, R. Gorrieri, February 1999. 99-2 A Theory of Efficiency for Markovian Processes, M. Bernardo, W.R. Cleaveland, February 1999. 99-3 A Reliable Registry for the Jgroup Distributed Object Model, A. Montresor, March 1999. 99-4 Comparing the QoS of Internet Audio Mechanisms via Formal Methods, A. Aldini, M. Bernardo, R. Gorrieri, M. Roccetti, March 1999. ¨ Babao˘glu, April 1999. 99-5 Group-Enhanced Remote Method Invocations, A. Montresor, R. Davoli, O. 99-6 Managing Complex Documents Over the WWW: a Case Study for XML, P. Ciancarini, F. Vitali, C. Mascolo, April 1999. 99-7 Data-Flow Hard Real-Time Programs: Scheduling Processors and Communication Channels in a Distributed Environment, R. Davoli, F. Tamburini, April 1999. 99-8 The MPS Computer System Simulator, M. Morsiani, R. Davoli, April 1999. 99-9 Action Refinement, R. Gorrieri, A. Rensink, April 1999. 99-10 Proceedings of the Workshop on Virtual Documents, Hypertext Functionality and the Web, M. Milosavljevic, F. Vitali, C. Watters, May 1999. 99-11 An Algebraic Model for Evaluating the Performance of an ATM Switch with Explicit Rate Marking, A. Aldini, M. Bernardo, R. Gorrieri, June 1999. 99-12 Simulative and Experimental Analysis of an Adaptive Playout Delay Adjustment Mechanism for packetized Voice across the Internet, M. Roccetti, V. Ghini e G. Pau, June 1999. 99-17 A Simple Game Semantics Model of Concurrency, Asperti A., Finelli M., Franco G., Marchignoli D., July 1999.

A Simple Game Semantics Model of Concurrency Andrea Asperti1 Davide Marchignoli4

Michele Finelli2

Gianluca Franco3

Technical Report UBLCS-99-17 July 1999 Abstract This paper is a full and more detailed presentation of the work of Finelli and Marchignoli [8]. The reason why we started investigating game semantics is whether it is possible to use the game model of Abramsky, Jagadeesan and Malacaria (AJM games, for short), which has been shown suitable to model Classical Linear Logic [6] and a functional language like PCF [1], to model a concurrent language. The answer that we gave in the previous work is that the native AJM game model is not suited to model the message passing paradigm of concurrency, but it is possible to modify their definitions in a conservative way so that it is possible to build a categorical model of a CCS-like process algebra whose games are an extension of AJM games. The main novelty with respect to the existing game categories [1, 6, 14], is the relaxation of the constraint that players should alternate: the constraint we impose is that the players should alternate only in a round of the game, that is, every sequence of an odd and of an even move can not be played by the same player, but we are free to choose if the first should be the Player or the Opponent (the Player / Opponent terminology is standard in game semantics to denote the two players of the game). Next, in our model, each move is associated with two new attributes: its value and its name. The value intuitively captures what it is carried by a channel, where the name is the semantic analogue of the channel: players alternate only with respect to the names of the moves (i.e. you are not allowed to play moves with different names within the same round), this means that the communication between two processes on a given channel is issued by two moves with same name, taken by different players. We proceed as follows. In Section 1 the basic definitions about games are introduced and some basic property is stated. Section 2 introduces the category of games we work with and a particular construction — the exponential game — which is responsible for the modeling of a -calculus like replication operator. The application of the category as a denotational semantics framework for a process algebra is achieved in Section 3 where a simple process algebra is introduced. Conclusions, work in progress and future developments are in Section 4. We wish to thank Vincent Danos for his course on Game Semantics held in Bologna this summer: the first author started investigating game semantics after having attended to the inspired lessons of Vincent Danos.

1. 2. 3. 4.

Dipartimento di Informatica, Universit`a di Bologna, Via Mura Anteo Zamboni, 7, 40127 Bologna, Italy. Dipartimento di Matematica, Universit`a di Siena, Via del Capitano, 15, 53100 Siena, Italy. Dipartimento di Matematica, Universit`a di Udine, Via delle Scienze, 208, 33100 Udine, Italy. Dipartimento di Informatica, Universit`a di Pisa, Corso Italia, 40, 50100 Pisa, Italy.

1

1 The model

1

The model

In the following we assume the knowledge of the usual definitions about languages, such as the Kleene star () , and we will systematically denote uv the concatenation of two words u and v. The empty word is ". Given a word w we will denote with jwj the length of w, and we will usually write it down componentwise as w = w1 ; : : :; wjwj. Given a partial function f :  !  we will call f  the standard (unique) extension of f to words in  . 1.1

Small moves and large games

Definition 1.1 (Moves). Given two countable sets - V of values and N of names - a set of moves is a countable set M with four functions M , M , M and M such that

M M M M

: : : :

M M M M

! fO; P g !V !N ! fQ; Ag

(1)

 the function so defined It is usual to indicate as 

(m) = O =)  (m) = P (m) = P =) (m) = O  = . It is custom to call M O the set of m 2 M such that (m) = O It is easy to check that  P and similarly M the set of m 2 M such that (m) = P . Intuitively the functions  and  give the “interesting part” of a move: what it is played - the  - and where it is played - the  ; the  and the  are a sort of “book-keepers”, in that they indicate who is playing the move - the , that gives the player P or the opponent O - and which is the role of the move - the  , which gives the information about being the move a question Q or an answer A. Our terminology slightly differs from that of [1]: in their notation our  is QA and our  is OP , but the meaning we give to  is very different from theirs, so we preferred to start with a completely different notation. Definition 1.2 (Rounds). Given a set of moves M as above, we define the set of rounds RM , as the following set

RM = fm0 m00 j m0 ; m00 2 M  (m0) =  (m00 ) ^ (m0 ) = (m00 )g a finite string w of even length 2n is round formed if there exist r1 ; : : :; rn 2 RM r1r2 : : :rn.

(2) such that

w=

The intuitive meaning of a round is that of the “smallest piece of a game” to whom may be given a meaning per se. We think that the game interpretation of a computational structure, be it a functional language as many scholars have done, or an algebra of communicating processes, is finer than other kind of semantics — in the sense that the smallest part of the model (the move) has no counterpart in the term language, it is the round that happens to have this property. This also holds for AJM games, but it is never made explicit. The choice of the property of Definition 2 is of fundamental importance, since it is determined by the intuition of how to model the atomic components of the model: first of all we assume that in a given round the player and the opponent must alternate, with no regard to whom is playing first or second, next we assume that only moves with the same name may be played within a round. A round formed sequence is a sequence of moves that is also a sequence of rounds. Definition 1.3 (Plays). Given a set of moves M and the corresponding set of rounds RM , we say that PM is a play if it is a not empty, prefix closed, subset of finite sequences of rounds. The definition ensures that a play must, at least, have the empty sequence (i.e. " 2 PM ). We extend the functions , ,  and  from moves to sequences of moves (and so to rounds and plays) in the usual way, and we indicate these functions on strings as  ,  ,   and   respectively. A play is the set of “histories” of what has been played (sometimes these histories are also called runs). UBLCS-99-17

2

1 The model

Remark 1.1. With a slight abuse of notation we will almost always talk about a play P built on the moves M , intending the play built on the sequences of rounds whose support is M . Similarly, when it needed to show that a certain prefix closed set of sequences is also a play, it will be proved that the every even length sequence is round formed, and it will be assumed that it is clear form the context if we are talking about a sequence of moves (that also holds odd length sequences — rounds not already completed) or about a sequence of rounds. Now we are almost ready to define games: we need another tool, that is necessary to cope with the problem of having many syntactically different ways to describe essentially the same game. We want a description of the plays and of the strategies of a game that is independent from the syntactical format of the moves m 2 M : we will require that the plays of a game (and so the strategies, which are a particular kind of plays) satisfies an equivalence relation that we call filling relation. Definition 1.4 (Filling relation). Given a play P and an equivalence relation  on P , we say that  is filling if it satisfies  a condition on the projections: for all s1 ; s2 2 P

s1  s2 =)  (s1 ) =  (s2 ) ^  (s1 ) =  (s2 ) ^  (s1 ) =  (s2 ) ^   (s1 ) =   (s2 )

 

2 P and for all m1 ; m2 2 M s1 m1  s2 m2 =) s1  s2

(3)

a prefix-closure condition: for all s1 ; s2

and an extendibility condition: for all s1 ; s2

(4)

2 P and for all m1 2 M

s1  s2 ^ s1 m1 2 P =) 9m2 2 M s1 m1  s2 m2

(5)

It is easy to check that  is a length preserving equivalence relation on P . Given a set of sequences A with a filling relation  and A0  A we define [A0]A = fa 2 A j 0 9a 2 A0 a0  ag and we will say that the set A0 is saturated if A0 = [A0]A. Observe that the saturation []A is done with regard to a fixed superset A of A0 : with a slight abuse of notation we leave off the index A, since the saturation is usually performed on plays, and so the set A is implicitly assumed to be the set of all sequences of moves. Remark 1.2. Clearly the notion of saturation strongly depends on the filling relation  upon which it is built, moreover the concept of saturated plays (and saturated strategies) is important only in the setting of Section 2.1, when we will extend the linear games of this section with nonlinearity. To quote from [6] “ : : : (the equivalence relation) only forgets about the names of the threads in the exponential constructs : : : ” but here we have no nonlinear games (exponential games in the above terminology) and so we will forget about  in the following definitions. The filling relation — as the word suggests — is used to define those plays where there is no hole (i.e. every playable site is filled with a move). The definition is sound, as the following Lemmata show. Lemma 1.1 (Sub-play). Given  a filling relation over P and a saturated play P 0  P ,  \(P 0  P 0) is a filling relation. Proof.The first property (Equation 3) is obvious; the second (Equation 4) holds since P 0 is prefix closed; Equation 5 holds since if s1  s2 and s1 m1 2 P 0 then s1 m1 2 P and so there exists m2 such that s1 m1  s2 m2 and so s2 m2 2 P 0 Lemma 1.2. If P is a play (w.r.t. UBLCS-99-17

M  ), so it is [P ] (w.r.t. M  ).

3

1 The model

Figure 1. The boolean game

On

@@ @R P P

tn

fn

Proof.We have to show that [P ] satisfies the conditions of being a not empty, prefix closed subset of finite sequences of moves M and that each even sequence is round formed:  P  [P ] and P is not empty, so [P ] is not empty,  s 2 [P ] implies that 9t 2 P such that t  s and so jtj = jsj: since t is of finite length so it is s,  sm 2 [P ] =) 9tn 2 P sm  tn so by Equation 4 s  t and since P is prefix closed t 2 P so s 2 [P ],  lastly, since Equation 3, s 2 [P ] has the same image under  and  of a t 2 P , so it is round formed. This ends the proof. Lemma 1.3. For every play P , [P ] = [[P ]]. Proof.By definition. Remark 1.3. Another note on the importance of the filling relation. The reader may wonder if, getting rid of the exponential games, there could be no reason to keep an equivalence on moves, or, put in other terms, if the notation could be simplified. The answer is negative. The fact that there is the need of an equivalence on the moves (and on the plays and on the games) is shown by the observation that may be used syntactically different notations for the same game. The simplest meaningful example is the game of an atomic action (see Figure 2). We may take two different representation of the game of an atomic action a: the game A1 = (fm0 ; m1 g; "; m0; m0m1 ; id) and the game A2 = (fn0; n1g; "; n0; n0n1; id), with m0 6= n0 and m1 6= n1 , but with m0 and n0 having the same projections (namely (m0 ) = O, (m0 ) = ,  (m0 ) = a and  (m0 ) = Q), and similarly for m1 and n1 . Now, A1 and A2 are completely different games, and there is absolutely no way to get a function between them that behaves like the identity, if it were not for the fact that we may declare that m0  n0 and m1  n1 . The problem arises because every game may be assumed to be built from a distinct set of moves. In this way the filling relation is a tool that allows us to work with syntactically different games as if they were a sort of canonical representative of the same abstract game. Definition 1.5 (Games). A game A is a triple (MA ; PMA ; PMA ), where MA is a set of moves, PMA is a play with the moves MA and PMA is a filling relation on PMA . To avoid a cumbersome notation, we will write the game A as (MA ; PA; A ) or (M; P; ), or simply A = (M; P ) if we do not need to specify the filling relation. With a slight abuse of notation, we will set [A] as the game (MA ; [PA]; A). In the following we will write G for the set of all games. Observe that in general, given a set of moves, we have (a possibly infinite number of) many different set of plays, and so many different possible games. The usual examples are the boolean games of Figure 1 and, in our model, the constant game played with moves of various names of Figure 2, corresponding to atomic prefixing in CCS (more on that later in Section 3). 1.1.1 Notation This is the place to describe the notation that we will use. It is often very cumbersome to describe games following the previous definitions (compare with [5] for example, for a completely UBLCS-99-17

4

1 The model

Figure 2. The action games

On

Pn

?

?

Pn

On

different kind of game), so to keep things simple we will denote each move m 2 M as

vnxy where v is (m), n is  (m), x is (m), y is  (m) and the move is put under the sub-game in which it is played. Moreover we convene to use the symbol  for the value of a question move, and that every other move, whose  is not specified, has to be thought as an answer. The plays are displayed as Hasse diagrams [7], since the prefix closure condition allows us a more compact tree notation. Last but not least, when the game is given by the diagram of a play, the underlining set of moves has to be taken as the least set of moves that allows the definition of the play, and the filling relation, when not otherwise specified, is the identity relation. So the example of Figure 1 is a shortcut for the game (M; P; ) where

     

M = fm0 ; m1 ; m2g  Q m0 7 ! O; m0 7 ! ; m0 7 ! n; m0 7 !     m1 7 ! P; m1 7 ! t; m1 7 ! n; m1 7 ! A  A m2 7 ! P; m2 7 ! f; m2 7 ! n; m2 7 ! P = f"; m0; m0 m1 ; m0 m2 g P = f("; "); (m0 ; m0); (m0 m1 ; m0 m1 ); (m0 m2 ; m0m2 )g

When we do not use the graphical notation, we write the set of all the prefixes of all the sequences in A as APC , so the non graphical notation for the game of Figure 1 is

M = fOn ; tPn ; fnP g P = fOn tPn ; On fnP gPC P = f(u; v) j u = vg 1.2 Building games Having defined what are the objects of our study — the games — we will describe some constructions on games  the dual game (or perpendicular game): ()?  the parallel composition of games:   the sequential composition of games: ;  the sum (non deterministic choice) of games: +  the restriction of a game on a set of moves M : ()nM . to define whom we need some operations on the moves (the sum of two sets of moves and the dual notion of parenthood), on the relations (the merge of two relations), on the plays (the projection on a set of moves) and then some properties of sequences and of set of sequences (the notion of balancedness and that of generating set). The first construction is that of sum of set of moves: until Section 2.1 the only way to combine moves will be through their sum (and we will see that the bang construction is nothing more than a denumerable disjoint sum). Definition 1.6 (Sum of moves). Given two sets of moves M1 and M2 we define M = M1 ] M2 as the UBLCS-99-17

5

1 The model

disjoint sum of M1 and M2 . So we have four unique functions M , M , M and M defined as

M M M M

= = = =

[M1 ; M2 ] [M1 ; M2 ] [M1 ; M2 ] [M1 ; M2 ]

(6)

Since the sum of moves allow us to put together two plays, we need a function — the parent function — that gives us the way to recover the sub-play where a move has been played. Definition 1.7 (Parent). Given a set A ] B we define the parent function p : A ] B ! f1; 2g as follows

9a 2 A x = inl (a) =) p(x) = 1 9b 2 B x = inr (b) =) p(x) = 2

and similarly if we have an arbitrarily (countable) disjoint sum, instead of a binary sum, p : !  A we say that p(k; a) 7 ! k. A sequence w satisfies the parent condition if

8i p(w2i+1) 6= p(w2i+2) =)  (w2i+1 ) =  (w2i+2 )

! !, (7)

The intuitive meaning of the parent condition is that in some game (in particular the parallel game) we will not allow a sub-game to answer a move that has not been asked to him (and vice versa). The parent condition means exactly that: if you are allowed to switch in a given round between two sub-games, then you may only copy the request to somebody or copy the answer back to his source. Now we need to define the projection of a game on a set of moves, and this is done defining the notion of projection of a sequence of moves w on a subset of its moves. Definition 1.8 (Projection). Given a word w 2 (M1 ] M2 ) we define wjM1 the projection of w on the set M1 as the unique word x 2 M1 such there exists 0 : : : jxj 2 M2 and

w = inr ( 0)inl (x1 )inr ( 1 )inl (x2) : : :inl (xjxj)inr ( jxj) (8) symmetrically we define wjM2 . Lemma 1.4 (Interleaving). Given x; y 2 PA with MA = M1 ] M2 , then if xjM1 1 yjM1 , xjM2 2 yjM2 and p (x) = p (y) then  (x) =  (y),  (x) =  (y),   (x) =  (y) and   (x) =   (y). Proof.By induction on jxj. So long for moves. Now let us tackle the operations on relations and sequences. Definition 1.9 (Merge). Given two plays P1 on the set of moves M1 , P2 on the set of moves their filling relations 1 and 2 , we define the merge relation 1  2 on P as

M2 and

1  2 = f(u; v) 2 P  P j 8n p(un) = p(vn ) ^ (9) 8i ujMi i vjMi g where p is the parent function on M1 ] M2 and P is a play defined on M1 ] M2 such that PjM1  P1 and PjM2  P2. Proposition 1.5. If 1 and 2 are filling relations for the plays P1 and P2 — respectively defined on the set of moves M1 and M2 — then 1  2 is a filling relation for every play P defined on M1 ] M2 that satisfy the properties PjM1  P1 and PjM2  P2 . Proof.We have to show that Equations 3, 4 and 5 hold. Assume that for all s0 ; s00 2 P we have s0 1  2 s00 , this means that for all indexes n we have p(s0n ) = p(s00n ), s0jM1 1 s00jM1 and s0jM2 2 s00jM2 . Now apply the Interleaving Lemma 1.4 and Equation 3 is proved5 . 5. In general, given two sequences x and y with the same projections over two sequences a and b, we are not allowed to deduct that x = y. But if x and y have the same interleaving pattern they can not be unequal sequences (if it were so,

there would be two different subsequences of a given sequence — xja and yja or xjb and yjb — of the same length, and this is obviously impossible).

UBLCS-99-17

6

1 The model

Equation 4 is proved as follow: assume that s0 ; s00 2 P , m0 ; m00 2 M and s0 m0 1  2 s00m00 , by definition p(m0 ) = p(m00 ) and assume without loss of generality that p(m0 ) = 1. So we get s0jM2 2 s00jM2 and s0 m0jM1 1 s00 m00jM1 . This implies that s0jM1 1 s00jM1 and that is enough to asses that s0 1  2 s00 . Equation 5 is similarly proved, since it holds on each projection of s0 and s00 . To end the proof, note that to have s0jMi i s00jMi we must assume that s0jMi ; s00jMi 2 Pi, and this means that PjMi  Pi. We need two more notions, useful for the construction of the sequential game and of total games (i.e. games which end). Definition 1.10 (Generators). The set Gen(P) of generators of a play P is the set Gen(P ) = fg 2 P

j6 9g0 gg0 2 P g

a play P is generated if P = Gen(P )PC Remark that it could happen that the set Gen(P ) is empty even if P is not an empty play: take the play in which there is each finite sequence of actions

P = fw j w = (On Pn )k 8kg it is clear that it does not exist any finite sequence g 2 P satisfying the above definition, the solution given by the infinite sequence of actions is ruled out because it does not belong to P . In general if the game is finite (and this means that there exist a finite bound on the maximum length of the plays of P ) then the prefix closure of Gen(P ) is equal to P . The set of the generators of a play P is an easy and intuitively clear way to present the set of possible plays in a compact notation, but the reason for the definition is not simply notational, because the set of the generators of a play is necessary to correctly define the sequential game and to deal with recursive games. Definition 1.11 (Balancedness). A string w is balanced if it is of even length, a game A = (MA ; PA) is balanced if and only if every w 2 Gen(PA ) is balanced. We will use the notation Bal(P ), to denote the set of the balanced strings of P . The intuition behind the definition of balanced games is that they are the only games that can be defined as a sequence of rounds. In a certain sense they are the games in which no one is stuck (i.e. the game with only one move for the opponent and no moves for the player is not balanced). The perpendicular game is the game in which the roles of the opponent and of the player are switched. In that sense it is a sort of negation game (the interpretation of the switching between the players as negation is typical of every game model). Definition 1.12 (Perpendicular). Given a game A, we define A? as

MA PA

?

A

?

?

A A A A

? ? ?

?

= = = = = = =

MA PA

A

A A A A

(10)

Proposition 1.6. If A is a game, so it is A? . If A is saturated, so it is A? . Proof.By definition. Some properties of ? are its idempotency (A?? disjoint sum ((M ] N )? = M ? ] N ? ). UBLCS-99-17

= A), and its linearity on the operation of the 7

1 The model

To simplify the notation, let (w) be the proposition saying that w is round formed (Definition 1.2) and satisfies the parent condition (Definition 1.7). In formulas this means that

(w) () jwj = 2n ^ 8i  n  (w2i+1) =  (w2i+2) ^ (w2i+1) =  (w2i+2) ^ p(w2i+1) 6= p(w2i+2 ) =)  (w2i+1) =  (w2i+2 )

(11)

clearly w belongs to a play and so  , , p and  are uniquely determined by the context in which  is placed. Definition 1.13 (Parallel). Given two games A = (MA ; PA; A ) and B = (MB ; PB ; B ) we define the parallel game A  B = (MAB ; PAB ; AB ), as

MAB = MA ] MB PAB = fw 2 MA B j wjMA 2 PA ^ wjMB 2 PB ^ (w)g AB = A  B on PAB

(12)

recall that p is the parent function on MA ] MB , and the functions AB , AB , AB and AB are given as in Definition 1.6 on MAB . Observe that, in general the set of rounds RAB is bigger than the union of the sets RA and RB , but every allowed round in RA ] RB is also in RAB Proposition 1.7. If A and B are games then A  B is a game.

Proof.We have to show that MAB is a set of moves, PAB is a play and AB is a length preserving equivalence relation as in Definition 1.4. The first requirement is satisfied by definition. To show that PAB is a play we need to show that 1. it is a subset of sequences of moves, 2. each sequence w is finite, 3. it is prefix closed, 4. every sequence is round formed. Properties 1), and 4) are also immediate because of the definitions, 2) is also true because w is the interleaving of two finite sequences, and so it is finite. The case that needs care is the third: we will prove it by induction. The empty word is in PAB ; if wm 2 PAB then: a) wm is round formed and w is, too, b) either (w)jMA m 2 PA ^ wjMB 2 PB or wjMA 2 PA ^ (w)jMB m 2 PB , and this implies that

wjMA 2 PA ^ wjMB 2 PB

c) if the “parent condition” is satisfied on wm then it is satisfied on w a fortiori. These three conditions mean that, if wm fulfills the requirements to belong in PAB then w fulfills them too, and so PAB is a prefix closed set. The last requirement — about the filling relation — is satisfied by the definition of AB as A  B , see Theorem 1.5. Proposition 1.8. If A and B are saturated games, so it is A  B Proof.It is enough to show that [A]  [B ] = [A  B ]:

x 2 [A]  [B ] () xjMA 2 [PA] ^ xjMB 2 [PB ] ^ (x) () 9a 2 PA9b 2 PB xjMA A a ^ xjMB B b ^ (x) () 9z 2 MAB p (z ) = p (x) ^ zjMA  xjMA ^ zjMB  xjMB ^ zjMA 2 PA ^ zjMB 2 PB ^ (z ) () 9z 2 PAB z A  B x () x 2 [PAB ] So [A]  [B ] = [A  B ] and A  B is saturated.

UBLCS-99-17

8

2 The category of games

Sometimes we will talk about the sub-games A and B of the game A  B . Definition 1.14 (Sequential). Given two games A = (MA ; PA; A ) and B fine the sequential game A; B as follows

= (MB ; PB ; B ),we de-

MA;B = MA ] MB PA;B = fuv 2 MA ;B j ujMA 2 Bal(Gen(PA)) ^ vjMB 2 PB g [ fu 2 MA ;B j ujMA 2 PA ^ ujMB = "g A;B = A  B on PA;B Observe that in general A; B 6= B ; A. Definition 1.15 (Sum (choice)). Given two games define the sum game A + B as follows

(13)

A = (MA ; PA; A) and B = (MB ; PB ; B ), we

MA+B = MA ] MB PA+B = fu 2 MA +B j (ujMA 2 PA ^ ujMB = ") _ (ujMA = " ^ ujMB 2 PB )g A+B = A  B on PA+B

(14)

Observe that both A;B and A+B are defined as A  B . Proposition 1.9. If A and B are games, so are A; B and A + B . Proof.Easy, following the pattern of Theorem 1.7. Proposition 1.10. If A and B are saturated games, so are A; B and A + B . Proof.Following Theorem 1.8 and the Interleaving Lemma 1.1. The restriction game depends heavily on the encoding of the process algebra and so its definition will be postponed until Section 3, where various kinds of restriction are given.

2

The category of games

In this section, we will define a notion of morphism between games, so to get a category of games in which the objects of the category are the games previously defined, and every operator will be easily extended to an endofunctor of the category. The key definition is that of strategy, which determines how the first and the second player of a round may answer each other (i.e. you should intuitively think to a strategy as a way to specify how should a run of a game be played, but a major difference with [1] is that in AJM-games you define how the Opponent answers to Player’s moves — or simmetrically, if the game is started by the Opponent — in our games, instead, we are not able to determine who moves first, so we must specify, in any given round, how the second palyer answers to the first, be him the Player or the Opponent). Definition 2.1 (Strategy). A strategy  on a game A = (MA ; PA; A ) is a not empty prefix closed subset of PA with the property that for all s 2 

jsj = 2k + 1 =) (9m 2 MA sm 2 PA =) 9m0 2 MA sm0 2 )

(15)

Observe that  PA is round formed by definition, so it is any of its subsets, and that means that  is round formed, too,  the empty play f"g is a strategy for each game. Intuitively a strategy is a particular kind of play in which, when you may continue to play — i.e. when you may end a round — you must do so. Thinking to the rounds as the atomic steps of a run of a game, this exactly capture the intuition of strategy as a way of never getting stuck, or equivalently, to always be able to answer to the first player’s last move. Observe that the definition has not yet addressed the issue of winning the game, that is another topic of its own: it says only UBLCS-99-17

9

2 The category of games

that, before winning the game, you must be able to finish it. The complementary notion is that of totality, which means, in this context, that not only the second player may always reply to the first, but also that a player must always start a new round if it can. Definition 2.2 (Totality). A strategy  on a game A = (MA ; PA; A ) is total if, for all s 2 

8m 2 MA (sm 2 PA ^ jsj = 2k) =) sm 2 

(16)

A total strategy is a play in which you play every possible move: the totality condition binds the first player to start every possible round and the definition of strategy says that there is always the way to close them. If we are interested in modeling functional programming then the notion of totality roughly correspond to that of winning, since a never ending strategy would mean that the underlying algorithm never ends — never returns a value. But in the study of reactive systems, in which the value of the computation does not exist at all, the meaning of the computational structure is given by other “observabilia” and the notion of totality is not good enough to capture the result of the computation. Observe that a total strategy is defined by a k logical formula since the quantification over the moves has the pattern 8 9 8 : : : while a strategy that is not total is not so — by the way we should remark that the empty play f"g is a total strategy only for games whose set of plays is empty. Definition 2.3 (Determinism). A strategy  is deterministic if

8sm 2  (jsj = 2k ^ smn0 2  ^ smn00 2 ) =) n0 = n00 A deterministic strategy is a strategy in which there is only one possible move n (equal to n0 and n00 in the above terminology) that closes the round opened by the move m (the existential quantification of Equation 2.1 is satisfied by an unique value). A further refinement of deterministic strategies is given by the notion of memoryless, that binds the second player to choose its future move only as a function of the previously played one. Definition 2.4 (Memoryless). A strategy  is memoryless if there exist a function f : (M ) ! M such that

8smn 2  (jsj = 2k =) n = f ((m)) A memoryless strategy is necessarily deterministic, and the choice of n may be done only looking at the value of the last move played m. Lastly, recall the definition of saturation given in the previous section, which was given to get saturated strategies (as in [6]). Definition 2.5 (Saturation). Given a game A = (MA ; PA; A) and a strategy  on A, we define [], the saturation of  as the set [] = fs 2 PA j 9s0 2  s0 A sg we will say that  is saturated if  = []. Obviously, we must prove that the operation of saturating a strategy is harmless. Lemma 2.1. The saturation of a strategy is a strategy. Proof.We already know that the saturation of a play is again a play, so [] is a play. Next, take s 2 [] and suppose that jsj = 2n + 1 (otherwise we are finished), we must show that if there exists m 2 M such that sm 2 P then there exists m0 2 M such that sm0 2 []. If, for every m 2 M , sm is not in P , there is nothing to prove, otherwise let m  be a move such that sm 2 P . Because of s 2 [] there is t 2  such that s  t and since sm  2 P , by Equation 5 of Definition 1.4, there must be n  2 M such that sm  tn , and so tn 2 P . Now, since the equivalence of s and t, we have t 2 , jtj = 2n + 1 and we have just proved that there exists a move n 2 P such that tn 2 P (take n = n ). Since we assume that  is a strategy there exists n0 such that tn0 2  and also tn0 2 P . Now, applying again Equation 5, we have that t  s and tn0 2 P implies that there is m0 such that sm0  tn0. So, in the hypothesis that there exists m such that sm 2 P , there exists also m0 such that sm0  tn0 where tn0 2  and this implies that sm0 2 []. UBLCS-99-17

10

2 The category of games

This theorem explains (at last !) the meaning of the properties asked for  :  the condition on the projections is required to identify, modulo  , the moves,  the prefix closure condition is needed for Theorem 1.2, (i.e. saturation brings plays to plays),  the extendibility condition is needed for the previous theorem (i.e. saturation brings strategies to strategies). Remark 2.1. Perhaps it is better to stress that a strategy is always (albeit implicitly) defined upon a game, so over a well known set of moves, plays and a well defined filling relation. For this reason a strategy inherits the filling relation of the set of plays of whom it is a subset. This is important when we will talk about saturated strategies because the saturation is always defined with reference to a relation: it has to be taken as the relation of the game upon which the strategy is defined. We will show that there are many ways to define the morphisms between games. This should not be surprising, as the “usual” way to get a model of games (a.e. see [1], [15]) is to build a linear category and then get a full model via the co-Kleisli construction on it (a trick that we will use, too). There are three kinds of morphisms: sequential, (concurrent) linear and co-Kleisli construction on the linear category.

(G; B ;B )  (G; IB )  (G; B ) The index f in f is the identity function of the category (B is the dereliction on B , IB copy-cat map and B ? ; B is nothing more than that game). ?

is the

Now we are ready to define the arrows of the category. Definition 2.6 (Morphisms). The morphisms of the categories are defined as particular strategies on games. Now we will define the (linear) parallel and the sequential morphisms: a parallel morphism  : A ! B is a saturated strategy  on the game A?  B , a sequential morphism  : A ! B is a saturated strategy  on the game A? ; B . The definitions of totality, determinism and memoryless on morphisms are the obvious extensions of the definition on strategies. Note that it is easy to prove that, if  is a total strategy, so it is [], while, in general, that does not hold for the properties of being deterministic and memoryless. Remark 2.2. To simplify a bit the notation, we will write A for both the game A and the full strategy PA . Note also that this strategy is always saturated. It will be clear from the context if we are talking about games or about strategies between games. Besides, when we talk about (linear) parallel morphisms (i.e. saturated strategies over the game A?  A) we will denote their type as a linear implication A A, because it is the canonical linear logic terminology (and we will use these game also as a model of Linear Logic [10]). So, when we want to stress that a morphism f : A ! B is a linear one, we will write f : A B Definition 2.7 (Identities). Given a game A the parallel identity morphism IA : A ! A is given by the copy-cat strategy:

M = MA A IA = fw 2 M  j wjMA 2 PA ^ wjMA 2 PA ^ p(w2i+1) = 6 p(w2i+2) ^ wjMA A (wjMA )? g IA = A A ?

?

?

(17)

?

?

while the sequential identity morphism is simply the full set of plays of the game A? ; A. The following theorems guarantee that the identities are sound. Lemma 2.2. IA is a strategy on A?  A.

Proof.Check that IA is a play: since IA contains the empty sequence, it is a not empty subset of A?  A; every sequence w 2 IA is got by two finite sequences in PA and PA? hence it is finite; lastly it is prefix closed. Indeed, given wm 2 IA if the condition wmjMA 2 PA , wmjMA? 2 PA? , p(wm2i+1) 6= p(wm2i+2) and wm2i+1 IA wm?2i+2 is satisfied by every i then wjMA 2 PA , wjMA? 2 PA? , p(w2i+1) 6= p(w2i+2) and w2i+1 IA w2?i+2 is also satisfied by every i and so w 2 IA . UBLCS-99-17

11

2 The category of games

Next, IA satisfies Definition 2.1: if jsj = 2k + 1 then s must be in the form t inl (m) with m 2 MA or t inr (m) with m 2 MA? . Suppose that the s = t inl (m) holds: m 2 MA implies that m? 2 MA and p(m) 6= p(m? ), so m? IA m and by construction of IA then s inr (m? ) 2 IA — symmetrically if s = t inr (m) — so Equation 15 is satisfied. The same reasoning shows that IA is ?

also total.

Lemma 2.3.

IA is saturated.

Proof.Since the definition of IA :

s 2 IA ^ t IA s =) s2i+1 IA s?2i+2 ^ 8k tk IA sk =) t2i+1 IA s2i+1 IA s?2i+2 IA t?2i+2 =) t2i+1 IA t?2i+2 =) t 2 IA the last equation implies that t 2 [IA ] so IA = [IA ]. Proposition 2.4. IA is a morphism of type A ! A Proof.By the previous theorems, IA is saturated strategy on the game A?  A. Definition 2.8. For each game A, we may define the empty arrow "A : A ! A as the strategy M = MA A "A = f"g "A = A A ?

(18)

?

To prove that we get a category of games we have to define an operation of composition between strategies, and we have to show that the categorical laws of associativity of the composition and of the existence of the identity morphisms hold [3]. In our model the composition between morphisms is the interaction between two strategies, that play one against the other. To lighten the burden of the notation we need two auxiliary functions, that we call HT (the head-tail function) and MB (the middle-body function). Definition 2.9 (Dismembering functions). The function

HT A;B;C : ((MA ] MB ) ] (MB ] MC )) ! (MA ] MC ) ?

?

?

is the extension to the sequences of the function

htA;B;C : (MA ] MB ) ] (MB ] MC ) ! MA ] MC so defined, 8m 2 (MA ] MB ) ] (MB ] MC ) 9a 2 MA m = inl (inl (a)) =) ht(m) = inl (a) 9c 2 MC m = inr (inr (c)) =) ht(m) = inr (c) ?

?

?

?

?

?

the function

MBA;B;C : ((MA ] MB ) ] (MB ] MC )) ! (MB ] MB ) ?

?

?

is the extension to the sequences of the function

mbA;B;C : (MA ] MB ) ] (MB ] MC ) ! MB ] MB so defined, 8m 2 (MA ] MB ) ] (MB ] MC ) 9b 2 MB m = inr (inl (b)) =) mb(m) = inl (b) 9b 2 MB m = inl (inr (b)) =) mb(m) = inr (b) ?

?

?

?

?

?

UBLCS-99-17

12

2 The category of games

Definition 2.10 (Composition). Given two strategies    : A ! C as follows:

:A !B

and

 : B ! C , we define

   = fHT A;B;C (w) j w 2    ^ MBA;B;C (w) 2 IB g

(19)

Lemma 2.5. The composition of two plays is again a parallel play. Proof.This lemma guarantees that plays are closed under . To prove the lemma we must simply show that    contains those sequences w that are the interleaving of two sequences in  and  and that (w) holds. This is shown in two steps, first of all we show that every even length sequence in w 2    is  (w2i+2); round formed: for all i  b(jwj=2)c we have that  (w2i+1) =  (w2i+2) and (w2i+1) =  next that w satisfies the parent condition: for all i  b(jwj=2)c we have that p(w2i+1) 6= p(w2i+2) implies  (w2i+1) =  (w2i+2). Take a sequence x 2   , this means that there exists a sequence w 2    such that x = HT A;B;C (w) and MBA;B;C (w) 2 IB . Now, if every round in x is played either in  or in  , there is nothing to prove, else we may assume without loss of generality that there is a subsequence rj ; : : :; rk+1 of rounds in x such that rj 2 , rk+1 2  and rj +1 : : :; rk 2 IB and rj is played in the two subcomponents of  and rk+1 is played in the two subcomponents of  . For every such a subsequence it is immediate to observe that:  the two moves in rj have the same name and are played in alternation, by construction  the second move in rj and the first move in rj +1 have the same name and are played in alternation, since this sequence is a valid round of IB and this is again true for every round rj +1 : : :rk that belongs to IB ,  the two moves in rk+1 have the same name and are played in alternation , again by construction, so the sequence w2j +1w2k+4 is a round. The same observation shows every round in IB is played on the two subcomponents of B ?  B and this happens also for the moves in rj and rk+1, so the  is constant all over the subsequence rj ; : : :; rk+1.

Remember that the filling relation of    is automatically defined as the merge relation A  B on PA B as every strategy, being defined over a specific game, automatically inherits ?

?

its filling relation. We may define two kind of compositions for morphism defined as sequential strategies: in either case we get a category, as the following theorems demonstrate. Theorem 2.6 (Well foundedness). Given  : A ! B and  : B ! C morphisms, their compositions    : A ! C is again a morphism.

Proof.We will carry on the proof only for morphisms defined as strategies on the game A?  B : the case A? ; B is similar. We must proof that    is a strategy (a play with additional properties) and that it is saturated. First of all we will show that    is a play: it contains the empty string (it follows from the definition), it is a set of finite sequences (since every sequence s in it is shorter that a string s0 such that s = HT A;B;C (s0 ) and s0 is finite because it belongs to    ) and it is a prefix closed set of round formed sequences. This last property will be shown by induction, as for Theorem 1.7. Assume that sm belongs to   , this means that there exists s0 such that sm = HT A;B;C (s0 ) and that there exists a subsequence s00 of s0 such that s = HT A;B;C (s00 ). Now, since ,  and IB are strategies, they are prefix closed, too, and this means that s00jM ? ]MB 2 , s00jM ? ]MC 2  and A B MBA;B;C (s00) 2 IB , and so s is in   . The round formed condition is automatically fulfilled by the definition of composition, since we are taking round formed subsequences of sequences that belong to a parallel game. Let us recall the definition of strategy:    is a strategy if for every s of odd length 9m 2 M sm 2 P =) 9m0 2 M sm0 2   . Now, suppose that we have an odd length sequence s in   , this means that there exists an odd length sequence w in    such that s = HT A;B;C (w); that w is of odd length is shown observing that the run of w in IB could always be made of even UBLCS-99-17

13

2 The category of games

length — since the definition of identity — and so, since the length of s is the sum of the length of the projection of w on MA? and MC , this means that either wjMA? or wjMC is odd. Assume that it is wjMA? and call it w . Now, either  and  are strategies and this means that, if s could be extended with a move, so must w , and moreover the move can not always be played in the sub component of B , because in that case it may immediately be matched by its dual move in B ? , since the definition of identity. So – sooner or later, since IB contains only finite sequences — there must be a move in MA? . We are concluded, because the projection of this new sequence is in   . Last, we must show that    is saturated. Assume that w 2    and v  w, we will show that v belongs to   , too. To do so we will build a sequence v0 with the following properties: v0  w0 , v = HT A;B;C (v0 ), w = HT A;B;C (w0 ), MB A;B;C (v0 ) 2 IB and MB A;B;C (w0) 2 IB . Note that if the above properties are fulfilled, since  and  are saturated by the hypothesis, we will have that v belongs to   . We build v0 in steps with the following algorithm: for every k in f1; : : :; jw0jg, look at the parent p(p(w0)), if it is a move in MA? or in MC , then set vk0 := vl , where vl  wl and wl = htA;B;C (wk0 ) — this may always be done because, by assumption, we are assuming that v  w — else, if p(p(w0)) is a move in MB or MB? , simply set vk0 := wk0 . It is immediate that v0 satisfies the needed properties. So    is a morphism. Theorem 2.7 ( of the Ornithorhynchus). The following are categories:  (G; IB ),  (G; B? ;B ). Proof.We will carry on the proof in full detail only to show the first statement, the same pattern is easily applied to the case of the sequential category of games. First of all we will show that there exist the identities: given  : A ! B we check   IA =  and similarly IB   = . Next we will show that, given  : A ! B ,  : B ! C and  : C ! D, the operation of composition is associative:   (  ) = (   )  . Take a sequence x 2   IA , this means that there exists a sequence w 2 (A?  A)   with the property that every move in the first component of A?  A is matched by an equivalent dual move in the second component and then that it is matched by (another) dual move — since the definition of composition — in the first component of : but this means, since every strategy is saturated, that every move of x that is played in the first component is also present in the first component of . This is enough to prove that   IA  , since it is given by construction that any move in the second component of x is present in the second component of . Now we repeat the same reasoning, starting with a sequence x 2  and we get that     IA . This ends the proof. Obviously the same holds for the right identity IB   = . Take  : A ! B ,  : B ! C and  : C ! D, we must show that   (  ) = (   )  . Take x 2   (  ): this means that there exists a sequence w0 2 (  )   such that x = HT A;C;D (w0) and MB A;C;D (w0) 2 IC , and by the same reason there exists w00 2    such that wj0M ? MC = A HT A;B;C (w00 ) and MBA;B;C (w00 ) 2 IB . We may so build a sequence z 2 (((MA? ] MB ) ] (MB? ] MC )) ] (MC ? ] MD )) such that

(zj(MA ]MB )](MB ]MC ) )jMA ]MB = wj00MA ]MB ?

?

?

?

(zj(MA ]MB )](MB ]MC ) )jMB ]MC = wj00MB ]MC ?

?

?

?

zjMC ]MD = wj0MC ]MD ?

?

and moreover

HT A;B;C (zj(MA ]MB )](MB ]MC ) ) = wj0MA ]MC ?

UBLCS-99-17

?

?

14

2 The category of games

MB A;B;C (zj(MA ]MB )](MB ]MC ) ) 2 IB ?

?

MBA;C;D (HT A;B;C (zj(MA ]MB )](MB ]MC ) ) ] zjMC ]MD ) 2 IC ?

?

?

HT A;C;D (HT A;B;C (zj(MA ]MB )](MB ]MC ) ) ] zjMC ]MD ) = x But S = (((MA ] MB ) ] (MB ] MC )) ] (MC ] MD )) is isomorphic to T = ((MA ] MB ) ] ((MB ] MC ) ] (MC ] MD ))) , so we may scramble z 2 S and rebuild it as z 0 2 T . It is immediate that, since the definition of z , z 0 belongs to (   )  . So we have shown that for every x 2   (  ) there exists exactly one sequence z from whom x is got, and that to each z there correspond exactly a z 0 such that its projection is again x and also x 2 (   )  . This shows that   (  )  (   )  . The same construction holds if we start with a sequence x 2 (   )   so also (   )      (  ) and this ends the proof: (G; IB ) is a category. The reader may check that the same constructions allow us to show that also (G; B ;B ) is a category. (In fact it is simply a matter of searching every  in the above proof and replacing it ?

?

?

?

?

?

?

?

?

?

with the sequential constructor — something that is better done by a word processor).

An important properties of the arrows is that, if f : A ! B is a morphism, so it is f ? : ? A ! B ? . This is immediate to prove, since the definition of ()? , and amounts to say that ()? is a covariant functor. This is not quite usual, since the behavior of the negation is that of

a contravariant endofunctor, as it happens in every other known game model. We will recover a contravariant operation when we will restrict ourself over those sub-games in which the alternation between the players is fixed before the game starts (i.e. it is fixed in advance whether it is the opponent or the player that starts moving). Lastly we state the usual definition of isomorphism: Definition 2.11 (Isomorphisms). Two games A and B are isomorphic if there exists two arrows f : A ! B and g : B ! A such that g  f = IA and f  g = IB . If two games A and B are isomorphic, we will indicate it as A  = B. 2.1 Exponential games We will enrich the category of games with the comonoidal structure necessary to get the full expressiveness of PCF and CCS with recursion. The common feature is the introduction of a bang game !A. Definition 2.12 (Bang). Given a game A = (MA ; PA; A ) we define the game !A as

M!A = !  MA P!A = fw 2 M!A j 8n 2 ! wj(n;MA) 2 (n  PA) ^ (w)g !A = f(u; v) 2 P!A  P!A j 9 : ! ! ! permutation on ! 8i  juj 1(ui ) = (2 (vi )) ^ 8n 2 ! 2 (uj(n;MA) ) A 2(vj((n);MA) )g where the projection 1 and 2 are defined on !  MA , and !A (k; m) = A (m), !A (k; m) = A (m), !A (k; m) = A (m) and !A (k; m) = A (m). Theorem 2.8. !A is a game. Proof.Following the pattern of theorem 1.7. The same argument shows that P!A is a play, and since the definition, it is also immediate to observe that, if A is a saturated game, so is !A. Observe that the linear negation ()? travels inside ! : (!A)? =!A? . The operation of expo-

nentiation (so called because this operation models the exponentials of Linear Logic) is more then another operation on games: it is a functor. To show that, we extend the bang construction from objects to arrows. Since  : A ! B is also a game, we define ! as the bang game of the game . The definition is sound since we have the following theorem. Theorem 2.9. ! is an endofunctor of G . UBLCS-99-17

15

2 The category of games

Proof.We have to show that I!A =!IA and that for all  and  (of the right types) !! =!(   ). First of all, observe that in the play of a game !A there are not only sequences in whom the first component of a move is always the same (i.e. sequences like (n; m1); : : :; (n; mk )), but also sequences like (n1 ; m1); : : :; (nk ; mk ) where the markers n1, : : : , nk , of the threads on whom the game is played are different. This immediately shows that in the game !A?!B there are exactly and only the sequences that belongs also to !(A?  B ). This implies that, since in set theory we have !  (A ] B )  = (! ] A)  (! ] B ), also !IA is isomorphic to I!A . The same observation also shows that !! is isomorphic to !(   ). 2.2 Miscellanea Sequential strategies An interesting subclass of games is given by those plays that are strategies on the game A? ; B . In general,  is not a strategy on PAB (i.e. it is not a morphism !), because the play can never start in B if it has not ended in A, but they have some interesting properties. First of all they are closed by composition: if  is a strategy on A? ; B an  is a strategy on B ? ; C then    is a strategy on A? ; C . In the second place, there is a strategy, given by the full strategy of the game A? ; A, that act as the identity on sequential strategies.

G = Gop

The category is self dual. This means that for every property P that is true in the category the coproperty P op is also a true property of the category. The fact simplifies the proof of the following theorem Theorem 2.10. The category G has neither initial objects nor terminal objects. Proof.By duality it is enough to show that the category does not admit initial objects. Given a game A, the empty play is always a strategy on 1 ! A and the same holds true for the strategy given by the full play PA . Since the definition of initial [3] there should be a unique morphism, but this is possible only if PA itself is empty. Remark that there are not initial (nor terminal) objects, even if we restrict to the full sub-category of total arrows, as the following total strategies on the game A  A? show:

0 = fw 2 PAA j p(w2i+1) 6= p(w2i+2)g 00 = fw 2 PAA j p(w2i+1) = p(w2i+2)g ?

?

Corollary 2.11. The category has neither products nor co-products.

Proof.If it were so assume that there is a product or a sum , since A  = A 1 or A  = A1 implies that the category has terminal — respectively initial — objects, if we had products or sums, it could happen only for an operator ? such that A 6 = A ? 1; but for every ? 2 f+; ; ; g we . A ? 1 have A  = I think we already met somewhere : : :

The game model G has an important link with Linear Logic, as it was promised in the introduction: Abramsky, Jagadeesan and Malacaria’s games are a special sub-case of our games. Precisely, once : : :  you have decided that every round should start with the move of the same player that first started the game,  strategies are O-strategies if they are strategies for the Opponent (this amounts to say that the strategy is closed by moves of the Player) - and symmetrically for P-strategies,  you split the connective  in two (guess their names ?) depending on whom may switch between two sub-plays of a play and define A B as that sub-game of A  B where only the opponent may switch - and symmetrically A O B as that sub-game of A  B where only the player may switch, UBLCS-99-17

16

3

Games in action



you define !A with a similar condition (only the Opponent may switch between sub-plays) - and symmetrically ?A,  you define the arrows as saturated strategies on !A? O B ,  you restrict yourself to games whose  functions are constant (say to a dummy name ) and define with ,  and  the base boolean and natural types in the usual way : : : you have got AJM games, as they where given in [6], and so are their game models for PCF and Classical Linear Logic. Note that the act of specializing games preserve the covariance of every operator but yields a contravariant negation, as it should be. What is the meaning of all that ? First of all, having a common semantical framework where a functional language as PCF and a process algebra with a structure that allow a form of recursion (the replication of our elementary process algebra), could help to understand the links between concurrency, functional languages and logic. This work is a first step toward this (ambitious) goal since it establishes that AJM games are (more or less) a “good” semantics for concurrency, in the sense that there is a super category of AJM games — that detailed in this paper is only an example — that models a CCS-like process algebra plus replication. Proposition 2.12. Everything I told you was true. Proof.Read paper [9].

3

Games in action

Now we are ready to use our semantic domains of games to study a very simple but powerful process algebra. Our first study will be on a kind of finite CCS [16] with replication [17]. The process algebra of CCS does not have a sequential operator ; but supplies with (the less expressive) family of action prefixing a: operators, one for each a 2 Act. Moreover we do not have an explicit constant in the syntax of terms to deal with deadlocked processes: in the intuitive semantics of CCS, a deadlocked process is undistinguishable from the process 0 (pronunced nil). We suppose an infinite set Act of names a and co-names a , with a special a 2 Act, and that L  Act, our algebra is defined by the following name  62 Act. Assume that a;  grammar:

Q ::= 0 j :Q j QkQ j Q + Q j QnL j!Q

where 2 f g [ Act. Let us call Q the set of all the process terms. 3.1

The operational semantics

The operational semantics of the language is given in the usual structured format: action rules

a a! 0

a a! 0

prefixing rules

x:R x! R summation rules

Q x! Q0 Q + R x! Q0

R x! R0 Q + R x! R0

parallel / communication rules

Q QkR restriction rule

UBLCS-99-17

x! Q0 x! Q0 kR

R QkR

x! R0 x! QkR0

 R x! R0 Q x! Q0 QkR ! Q0kR0

x 2= L Q x! Q0 QnL x! Q0 nL 17

3

Games in action

We work with terms up to the structural equivalence induced by the law !P take as the definition of the behavior of the replication operator !.

!P kP , that we

3.2

The game semantics model

Now we will use the games introduced to model a simple process algebra. The basic analogy is among actions and moves. An atomic action is regarded as a round in our games: in a round the process acts as the player and the environment is taken in account as the opponent; the round takes place on a name corresponding to the channel on which the action is performed. The complementary action is naturally modeled by the dual round, in which the roles of player and opponent (process/environment) are exchanged. So we define:

PA OA G (a) = (Ma ; fOQ G (a) = (Ma ; fPQ a a g) a ; a g) PQ OA PA PQ OQ PA QA PC G ( ) = (M ; fOQ     ;     g ) In the following we will omit the equivalence relation on games intending the maximal relation satisfying the definition of filling relation. Before giving the translation from terms to games, we need some other game constructors: the prefix game (it is in fact a family of constructors, corresponding to the family of action prefixing operators : ) the restriction game and the par game. The prefix game is very easy, indeed we shall use the sequential game that we defined in the first Section. The restriction game, too is very intuitive: only the parallel game is more troublesome. Definition 3.1 (Restriction). Let A = (MA ; PA) be a game and L  Act a set of actions, we define the restricted game AnA L as follows

MAnL = MA PAnL = fw 2 PA j 8i  (wi) 2= Lg We already pointed out that the communication arise as the mutual interplaying of the two rounds, an example of which are the two leftmost sequences of Figure 3. A first difference we observe between process algebras and our games is that interaction is not atomic, i.e. in our setting we can describe an interaction that starts in a round and lasts for several rounds before being completed: O a Pa : : : Pa Oa . In order to restrict ourself to plays arising from atomic interactions, we need to define a transformation on plays that discards those subsequences in which the communication spans over more than two consecutive rounds. So, we define normal sequences as those sequences in which interaction among the (outermost) sub-games is resolved within one round. Definition 3.2. Given games A; B we define:  the parity of a round m1 m2 2 RAB as:

8 > 1 :1



if p(m1 ) = p(m2 ) if p(m1 ) 6= p(m2 ) ^   (m1 m2 ) = QQ if p(m1 ) 6= p(m2 ) ^   (m1 m2 ) = AA

Pbjwj=2c

the parity of a sequence w 2 PAB as par(w) = i=0 par(w2i+1w2i+2) We will say that w 2 PAB is a normal sequence (and write NS(w)) whenever

w = um1m2 v, with jwj = 2n =) par(u) = 0 _ par(um1 m2 ) = 0

Next, another restriction we have to introduce is motivated by the fact that in process algebras we are not able to observe the channel over which the communication takes place. The parallel operator  of Definition 1.13 is not suited to model the operator k of the process algebra, since Q terms like AkB may emit  action, that are not in general present in the definition of a parallel game G (A)  G (B ). Whence we are forced to rename the channels of actions involved in communication (think to the terms (aka )na and (bkb)nb, if we do not rename the moves then we could never get the same thing — namely the game of the action  ). UBLCS-99-17

18

3

Games in action

a Figure 3. The maximal sequences in the play of the parallel game ak

PQ a

?    + OQ

OA a

a

?

PA a

OQ a

PQ OQ  

  + OQ

QQ QQs PQ

?   QQ QQs PQ ?PA ? a  OA  QQ   Q  s Q  + ? OA OA PA

PA a

a

n

n

Definition 3.3. Given games A; B we define a partial map

  

Hide : PAB ! PAB ; w 7! w0 iff

w is a normal sequence;  (w) =  (w0 ); ( (w) =   (w0 ); (w) =  (w0 );  (w20 i+1w20 i+2 ) =  (w2i+1w2i+2) if par(w2i+1w2i+2) = 0  otherwise Observe that we implicitly assume  is in the set of names of plays A and B . Definition 3.4 (Par). Let A = (MA ; PA; A) and B = (MB ; PB ; B ) be games, we define AkB = (MAB ; Hide(PAB ); AB ) Proposition 3.1. The constructors : , n and k brings games to games. Proof.For all the proofs of the theorems of this Section, we suggest the interested reader to read the Appendix of [8]. Figure 3 shows the maximal sequences of the parallel game between an action a and its coaction a . It is clear that the sequences in which we observe actions correspond to round played in the same sub-game, where the  moves correspond to communication rounds (i.e. rounds where the moves are played in two different sub-games). Moreover, note that in that case the moves have their name function  set to  . The full translation G from process terms to games is defined as follows. Note that the dual a  of an action a is simply modeled by the dual game. Definition 3.5. We inductively define the map G : Q ! G as

G (0) G (a:P ) G (P1 + P2) G (P1kP2) G (!P ) G (P nL)

= = = = = =

(;; fg) G (a); G (P ) for all a 2 Act [ f g G (P1) + G (P2 ) G (P1) k G (P2) !G (P ) k !G (P ) G (P )nL

The main result of this paper is that the strong bisimulation relation is completely captured by the following notion of mimic strategies. Definition 3.6. A total strategy  : A ! B is mimic if, for every w 2  and for all i  bjwj=2c, p(w2i+1) 6= p(w2i+2 ). It is intended that p is the parent function on A and B . We will usually write A  B for 9 : A ! B mimic. UBLCS-99-17

19

3

Games in action

Figure 4. The games a:(b + c) and a:b + a:c

a : (b

+

c)

a

:

+

b

OQ a

OQ a

? QPQPPPP QQ s OQPPqP OQ c b

PA a

?

PA b

? QQ QQs OQ 

?

:

c

OQ a

PA a

PA c

a

b

? QQ QQs OQ 

PA a

c

?

?

PA b

PA c

 is mimic then for every w 2 , (w2i+1 ) = (w2i+2 ), (w2i+1) = (w2i+2),  (w2i+1) =  (w2i+2) and  (w2i+1 ) =  (w2i+2 ). Proposition 3.2. If

The proposition explains that a mimic strategy is such because in a given round there are two moves which, apart from the switching between the opponent and the player, are “the same” moves (in the sense that they have the same projections). Observe that the identity function is indeed mimic, as it is any isomorphism (Proposition 3.11). Figure 4 shows the games of two typical processes which are not strongly bisimilar: a:(b + c) and a:b + a:c. Looking at the games, it is obvious that there could be no way to build a total mimic strategy between them, because there is no way, after having decided a branch of the right game, to match every possible sequence in the left game (that delays the choice of two possible subsequences after having played the two moves corresponding to the action a). This is folklore in concurrency theory, but we think that it is worth displaying, in the framework of game semantics, what bisimulation means in term of strategies. Now, to state the theorems, we need some preliminary definitions and lemmata. Definition 3.7. Given a game A define:

 Init(A) = fw 2 PA j NS(w) ^ 8u 6= :w = um1 m2 =) :NS (u)g  Res(A; w) = fv 2 MA j wv 2 PA g

Lemma 3.3. The composition of mimic strategies is a mimic strategy. Proof.Easy, it follows from the definition of mimic. Lemma 3.4. For any process P we have G (!P ) = G (P k!P )

Proof.A very simple categorical proof follows from the fact that in the category G the ! is both a monad/comonad. For a sketch of a direct proof, simply observe that it is possible to make the first thread of !P play with P and the k + 1-th thread with the k-th copy of (the other) !P . This mapping is an isomorphism between N and N ] fg, so follows the thesis. Lemma 3.5. Given processes P; Q and their encodings A = G (P ); B

= G (Q)

P ! Q () 9w 2 PA:w 2 G ( ) ^ (MA ; Res(A; w))  B Proof.We prove the two implications separately. =)) The proof proceeds inductively on the structure on the derivation P UBLCS-99-17

! Q. 20

3

Games in action

axiom easily by construction of game G (a:P ); sum apply inductive hypothesis then by construction of game G (P + Q); par apply inductive hypothesis then observe that A  B =) A  C  B  C =) Hide(A  C )  Hide(B  C ); comm apply twice the induction hypothesis then observe A  A0 ^ B  B 0 =) A  B  A0  B 0 =) Hide(A  B )  Hide(A0  B 0 ); restriction easily applying inductive hypothesis. (=) By induction on the structure of P we prove 9w 2 PA :w 2 G ( ) =) (MA ; Res(A; w)) = B , the full statement will be proved when we will show that G (Q0 )  B =) Q0  Q. prefix easily by construction; sum by induction hypothesis; par consider any w 2 Init(PA ), it can be either a round from one of the two sub-games or an interaction among the two sub-games. In the first case apply induction hypothesis then observe that A  B =) A  C  B  C =) Hide(A  C )  Hide(B  C ). In the second case apply again induction hypothesis to both sub-games and observe A  A0 ^ B  B 0 =) A  B  A0  B 0 =) Hide(A  B )  Hide(A0  B 0 ); replication consider any w 2 Init(PA ), it can be either a round from one of the two subgames or an interaction among the two sub-games. In the first case apply induction hypothesis and observe Res(w; G (!P )) = Res(w; G (!P kP )). In the second case apply induction hypothesis to the term P kP and observe that Res(w; G (!P )) is equal to Res(w; G (!P k(P kP ))); restriction obvious by construction and induction hypothesis. Lemma two of games (Ai )i2I ; (Bi )i2I and the mimic strategies i P  3.6. P Given Pfamilies : A ! B is a mimic strategy. i i i i2I i2I i2I

P

P

: Ai ! Bi then

P

Proof.Let  = i2I i ; A = i2I Ai ; B = i2I Bi and consider any w 2 . Then, by construction, w 2 i for some i and hence w is a mimic sequence. Moreover  is total, since 8w 2 ; wa 2 PA? B with jwj = 2n we have w 2 i for some i and, by totality of i , wa 2 i  . Lemma 3.7. For each process P we have

G (P )  G (

X

P !P

:P 0) 0

Proof.Follows easily by the two previous lemmata.

G (P )  G (Q) =) P  Q Proof.To prove the implication, we prove G (P )  G (Q) and P ! P 0 implies 9Q0:Q ! Q0 and G (P 0)  G (Q0 ). Consider such and P 0 , from a previous lemma we have w 2 Init(G (P )):w = G ( ) and Res(w; G (P ))  G (P 0). Consider now a mimic strategy  : G (P ) ! G (Q), by definition of mimic we have u 2  such that ujG (P ) = w? and ujG (Q) = v with w?  v. Then applying again the lemma we obtain Q ! Q0 with G ( ) = v and G (Q0 )  Res(v; G (Q)). Now define a new strategy  = Res(w1 v1 w2v2 ; ), it is easily verified that  : Res(w; G (P )) ! Res(v; G (Q)) is a mimic strategy, hence P 0  Q0. Proposition 3.9. P  Q =) G (P )  G (Q) Proof.Given a bisimulation among P and Q we directly build a strategy among G (P ) and G (Q) and then we prove that it is a mimic strategy. Using previous lemma we can extend relation  to ::: sequences, more precisely, let A = G (P ); B = G (Q) and define  PA  PB :u  v () P 1 !n !n Q0; Q  Q0 and u = G ( 1 ) : : : G ( n), v = G ( 1) : : : G ( n ), Res(u; A)  G (P 0), P 0; Q 1::: Res(v; B )  G (Q0 ). Finally define  = fw 2 A?  B j wjA  wjB ; p(w2i+1) 6= p(w2i+2)gPC Proposition 3.8.

?

?

UBLCS-99-17

21

4 Conclusions and Future Work

That  is a mimic strategy directly follows by construction. Theorem 3.10.

P  Q () G (P )  G (Q)

Proof.By the previous propositions. Proposition 3.11. Any isomorphism is mimic. Proof.It is easy to show that, if there is a sequence in f that is not mimic, than the composition of f with f ? contains more sequences than the identity function. Note that the converse does not holds: take the two games G (a) and G (a + a). It is easy to show that there is only one mimic strategy (corresponding to the strong bisimulation relation), but that it is not an isomorphism, since there is no way to recover (only) the identity function on G (a + a), after having composed f : G (a + a) ! G (a) with f ? : all you get is a function that is both the identity function and the switch function between the two subcomponents of G (a + a). Corollary 3.12. If G (P )  = G (Q) then P  Q. Proof.By the above theorems.

4

Conclusions and Future Work

There are many topics of interest. Currently we are investigating some issues. 1. We are trying to extend the game model to more expressive process algebras, like the  calculus, looking for the correspondence between various kinds of bisimulation relations and the mapping induced on the category. 2. The category comes with an operation, that of composition, that has not yet a direct analogue on the operational semantics. If we take a process algebra with value-passing, composition should allow us to model exactly the operation of receiving a value over a channel and binding it to the free variable upon which the value was transmitted. 3. Exploit the links between concurrency theory and Linear Logic: we are currently working to a game model of Classical Linear Logic that takes account directly of the additives - not via some encoding - and of the constants; moreover we would like to extend the game paradigm towards those fragments (LLL [13] and LAL [2]) whose modalities (a.e. the x) have not a clear interpretation. In the following there are some ideas that we think are worth some further investigation: the name games for -calculi game semantics models and the direct definition of recursive games (instead of the encoding with the replication operator). 4.1 Name games for the -calculus In this section we will define the name games and the bind games to model value passing CCS and the -calculus. Definition 4.1 (Name game). Given a name a 2 N , we define the game

G (a) = (fPa ; nOa g; fPa nOa gPC 8n 2 N ; f(u; v) j u = vg)

(20)

Definition 4.2 (Binder game). Given two names and we define the binder game b ; on and as the strategy b ;

b

= fw 2 P ; j w = uv; ujM 2 P ; vjM 2 P ;   (u) =   (v) ^  (u) =  (v)g = P ;

(21)

where P ; is the set of plays of the sequential game ; (= : ). UBLCS-99-17

22

4 Conclusions and Future Work

Figure 5. The game a(x)

Pa

P@@RPPPP   PPq ) 

(n1 )Oa

(n2)Oa

:::

(nj )Oa

Px

Px

:::

Px

(n1 )Ox

(n2)Ox

:::

(nj )Ox

? ?

? ?

? ?

Figure 6. The game bx

O

x P    @@RPPPPPPq   ) 

(n1 )Px

(n2)Px

:::

(nj )Px

Ob

Ob

:::

Ob

(n1 )Pb

(n2)Pb

:::

(nj )Pb

? ?

UBLCS-99-17

? ?

? ?

23

REFERENCES

Observe that b ; is a strategy upon the game ; , and the equivalence relation is coherently defined, even if for the name games of Definition 4.1 it collapses into the identity. Using this definition, the games corresponding to the atomic action of value passing CCS may be uniformly given in terms of the binder as follows (X is a variable symbol , a and v are name symbols) action games G (a(X )) = ba;x G (aX ) = bx;a

G (av) = bv;a G (av) = bv;a

Figures 5 and 6 should clarify the meaning of the binder construction. Note that the two games are not exactly one the perpendicular game of the other, because the order in which the game of the channel and the game of the variable appear is swapped. The composition of name games should model the -calculus construction of binding a variable in the body of a term upon the reception of a name over a channel. The idea behind the definition of composition is exactly in that: model communication of values. Without values (as in pure CCS) the act of communicating may be seen simply as a form of handshaking: it is enough to encode value passing CCS, but at the cost of introducing infinitary sums [16]. 4.2

Recursive games

Another interesting topic is whether it is possible to define directly recursive games, following the canonical Scott construction on domains: first of all we would like to define recursively the closed processes P k :

P0 = 1 P k+1 = P [X := P k ]

and then the sequence fG (P k )gk2N . The recursive game corresponding to the recursive term recXP (X ) is then simply given by the limit

G (recXP (X )) =

1 [

k=0

G (P k )

To proof that the above construction is indeed a game, we have to find that it can be expressed as a tuple (M; P; ) of moves and plays on those moves. Next we would have to show that the recursive game construction yields a game G (recXP (X )) that is isomorphic to the game corresponding to the process

(!(x:P (x))jx)nfxg where x is a distinguished action not in the actions of P (X ) and P (x) is the process obtained from P (X ) substituting x for the variable X . The problem is that the encoding is not completely correct, because of the presence of some  moves that have to be absorbed. We think (well, the first author : : : ) that the trick, more or less, should work, but he needs much more work to prove that it is indeed so. Enjoy.

References [1] S. Abramsky, R. Jagadeesan, P. Malacaria, Full abstraction for PCF, Information and computation, to appear, 1998. [2] A. Asperti, Light Affine Logic Proc. of Logic in Computer Science, IEEE 1998. [3] A. Asperti, G. Longo, Categories, Types and Structures, The MIT press, 1992. [4] J. Bergstra, J. Klop, Algebra of Communication Processes with Abstraction, Theoretical Computer Science, 37, vol.1, 77–121, 1985. [5] J.H. Conway, On Number and Games, Academic Press, 1976. UBLCS-99-17

24

REFERENCES

[6] V. Danos, P. Baillot, T. Ehrhard, L. Regnier, Believe it or not, AJM’s games model is a model of classical linear logic, Proc. of Logic in Computer Science, IEEE 1997. [7] B. Davey, H. Priestley, Lattices and Order, Cambridge University Press, 1992. [8] M. Finelli and D. Marchignoli, A Game Semantics Model for a Simple Process Algebra, submitted, 1999. [9] M. Finelli and D. Marchignoli, Believe it or not, AJM games are (almost) a model of concurrent processes, forthcoming Technical Report, University of Bologna, 1999. [10] J.-Y. Girard, Linear Logic, Theoretical Computer Science, 50, 1–102, 1985. [11] J.-Y. Girard, Linear Logic: its syntax and semantics, Advances in Linear Logic, (ed. J.-Y. Girard, Y. Lafont and L. Regnier). London Math. Soc. Lecture Note Series 222 1–42, 1995. [12] J.-Y. Girard, Geometry of interaction III, Advances in Linear Logic, (ed. J.-Y. Girard, Y. Lafont and L. Regnier). London Math. Soc. Lecture Note Series 222 329-89, 1995. [13] J.-Y. Girard, Light Linear Logic Information and Computation, 143, 175–204, 1998. [14] J.M.H. Hyland and C.H.L. Ong. On full abstraction for PCF:I, II, III, ftp-available at theory.doc.ic.ac.uk in directory papers/Ong. [15] G. McCusker, Game and full Abstraction for a Functional Metalanguage with Recursive Types, Ph.D. Thesis, Department of Computing, Imperial College, University of London, 1996. [16] R. Milner, Communication and Concurrency, Prentice-Hall, 1989. [17] R. Milner, J. Parrow, D. Walker A Calculus of Mobile Processes (Parts I and II), Information and Computation, 100, 1–77 1992. [18] P. Wadler, An Angry Half Dozen, ACM-SIGPLAN, vol. 33, 25–30, 1998.

UBLCS-99-17

25

Suggest Documents