Game semantics for untyped -calculus - Semantic Scholar

12 downloads 4220 Views 293KB Size Report
head lazy reduction or call-by-value reduction, the class of -theories is, in e ect, unfathomly rich, see ... now have a \fully abstract" syntax-free model, i.e. a model which induces pre- ..... Let D be the class of -models D = hD; fi where D is the ..... In Proceedings of the Italian Conference of Theoretical Computer Science,. 1998.
Game semantics for untyped  -calculus Pietro Di Gianantonio, Gianluca Franco, and Furio Honsell Dipartimento di Matematica e Informatica Universita di Udine, Italy.

email:fdigianantonio,gfranco,[email protected]

Abstract. We study extensional models of the untyped lambda calculus

in the setting of game semantics. In particular, we show that, somewhat unexpectedly and contrary to what happens in ordinary categories of domains, all re exive objects in the category of games G , introduced by Abramsky, Jagadeesan and Malacaria, induce the same -theory. This is H , the maximal theory induced already by the classical CPO model D1 , introduced by Scott in 1969. This results indicates that the current notion of game carries a very speci c bias towards head reduction.

Introduction -theories are congruences over -terms, which extend pure -conversion. Their interest lies in the fact that they correspond to the possible operational (observational) semantics of -calculus. Although researchers have mainly focused on only three such operational semantics, namely those given by head reduction, head lazy reduction or call-by-value reduction, the class of -theories is, in e ect, unfathomly rich, see e.g. [6,14,13,9] for interesting examples of this complexity. Brute force, purely syntactical techniques are usually extremely dicult to use in the study of -theories. Therefore, since the seminal work of Dana Scott on D1 in 1969 [18], semantical tools have been extensively investigated. A large number of mathematical models for -calculus, arising from syntaxfree constructions, have been introduced, since then, in various categories of domains (see e.g. [19,7,10,6,12,14,5,9]). And a rich host of di erent -theories now have a \fully abstract" syntax-free model, i.e. a model which induces precisely those identities which hold in the given theory. However, the denotational semantics supported by these models do not match all the possible operational semantics of -calculus. For example, in most existing categories of domains, -models have too many functions, and hence many interesting -theories, such as those arising from observing termination under some natural sequential reduction strategy (see e.g. [13]), do not have fully abstract denotational models [14,5,8]. An example of such a strategy is the one which tries non-deterministically to reduce a term to a closed term. In the case of CPOs, the sequentiality embedded in these strategies clashes with the necessary existence of Scott-continuous \parallel" functions. On the other hand, in the case of coherent spaces, and stable functions, the presence

of so called \parasitic" functions, prevents other kinds of identities deriving from monotonicity. In this paper we explore the methodology for giving denotational semantics based on games, recently introduced by Abramsky, Jagadeesan, Malacaria, and Hyland, Ong (see [3,16]). This methodology has been extremely successful in modeling sequential languages [3,17]. It should be reasonable to expect, therefore, that one could obtain fully abstract game models, at least for those -theories mentioned above, which escape domain models. Of course, the very fact that game semantics faithfully captures sequentiality, should suggest also that even game semantics is not rich enough to provide fully abstract models for all -theories. It is possible to show, in fact, that there are -theories where, say, the behavior of an unsolvable term, i.e. a term with no head normal form, is that of a \parallel function", which checks if at least one of its arguments evaluates to a xed term. Somewhat surprisingly, however, it turns out that all re exive objects, i.e. extensional -models, in the standard category of games of [3], determine models which have the same theory. This is the well known maximal -theory H [6], already induced by Scott's D1 . We recall that, if M; N are closed terms (i.e. M; N 2  ), and HNF denotes the set of -terms which have a head normal form, then M =H N if and only if 0

8C [ ] : C [M ]; C [N ] 2  =) (C [M ] 2 HNF () C [N ] 2 HNF) 0

Alternatively, this is the theory where two terms are equal if we cannot observe that head reduction terminates when one is placed in a given context, but does not terminate when the other is. More speci cally, in this paper we show that all re exive objects in the Cartesian closed category of games K (G ) [3] determine -models which are isomorphic to models which can be constructed as special non-initial colimits in a category G e of games and \embeddings", which mimics the traditional Scott's construction in CPOs and embedding-projection pairs. By extending the methodology of approximants originally introduced in [20,15,14] for the continuous case, to the setting of the game semantics, we study the ne structure of these models. The paper [11] is a companion to the present one. Finitary logical descriptions of game models, in the spirit of [10,1], are introduced. The case of one of the models introduced in this paper is discussed in detail. One can elaborate in various ways on the main result of this paper. In any case, we think that it provides a very clear indication that existing game semantics is more rigid than CPO semantics, which can model a very rich collection of -theories. Since the current notion of game appears to carry a very strong bias towards head reduction, a new notion of game seems to be necessary to model -theories di erent from H . This appears to be rather problematic, since we feel that \head reduction" is intrinsic to games for which we can observe only interactions with the environment. The present paper is organized as follows. In section 1, we introduce the categories of games that we shall utilize, namely G and K (G ). In Section 2 we !

!

2

discuss initial and non-initial solutions of recursive game equations. In Section 3 we introduce the special class of extensional -models D , and we prove that all re exive objects in K (G ) determine models belonging to D . In Section 4 we study the ne structure of the models in D and prove that such models induce the theory H . In Section 5 we give some concrete examples of extensional game -models, including the model arising from applying Scott's trick [19] to the game setting. Final remarks and directions for future work appear in section 6. We assume the reader familiar with the basic notions and de nitions of -calculus, see e.g. [6]. For the bene t of a reader coming from the -calculus community, this paper is self-contained as far as the theory of games, however the reader can refer to [2{4,16] for more details on this topic. The authors are grateful to Fabio Alessi, Samson Abramsky, and Marina Lenisa for useful discussions. !

1 Categories of games In this section, we introduce two categories of games. Both are introduced by Abramsky, Jadgadeesan and Malacaria in 1993, [3]. Notice however that for our purposes the machinery of \questions and answers" i.e. the bracketing condition, seems unnecessary. One can safely, and more simply, focus only on the full and faithful sub-category of this category consisting of all those games all whose moves are labeled as questions. We begin by giving the basic de nitions. De nition 1 (Games). A game has two participants: the Player and the Opponent. A game A is a quadruple (MA ; A ; PA ; A) where { MA is the set of moves of the game. { A : MA ! fO; P g  fQ; Ag is the labeling function: it tells us if a move is taken by the Opponent or by the Player, and if it is a Question or an Answer. We can decompose A into OP : MA ! fO; P g and QA A A : MA ! fQ; Ag QA i. We denote by ? the function which exchanges and put A = hOP ;  A A Player and Opponent, i.e. O = P and P = O. We also denote with OP A OP (a). Finally, we denote with A the the function de ned by OP ( a ) =  A A QA function hOP A ; A i. { PA is a non-empty and pre x-closed subset of the set MA~ (written as ~ nepref PA  MA ), where MA~ is the set of all sequences of moves which satisfy the following conditions:  s = at ) A (a) = OQ OP  (8i : 1  i  jsj)[OP A (si )Q= A (si )] A  (8 t v s)[jt  MA j  jt  MA j] where MAA and MAQ denote the subsets of game moves labeled respectively as Answers and as Questions, s  M denotes the set of moves of M which appear in s and v is the substring relation. PA is called the set of positions of the game A. +1

3

{ A is an equivalence relation on PA which satis es the following properties:  s A s0 ) jsj = js0 j  sa A s0 a0 ) s A s0  s A s0 ^ sa 2 PA ) (9a0 )[sa A s0 a0 ] In the above s, s0 , t and t0 range over sequences of moves, while a, a0 , b and 0 b range over moves. The empty sequence is written .

De nition 2 (Strategies). A strategy for the Player in a game A is a nonempty set   PAeven of positions of even length such that  =  [ dom() is pre x-closed, where dom() = ft 2 PAodd j (9a)[ta 2 ]g, and PAodd and PAeven denote the sets of positions of odd and even length respectively. A strategy can be seen as a set of rules which tells the Player which move to take after the last move by the Opponent.

In this paper we shall consider only history-free strategies, i.e. strategies which depend only on the last move by the Opponent.

De nition 3 (History-free strategies). A strategy  for a game A is historyfree if it satis es the following properties: 1. sab; tac 2  ) b = c 2. sab; t 2 ; ta 2 PA ) tab 2  The equivalence relation on positions A can be extended to strategies in the following way.

De nition 4. Let ;  be strategies,    if and only if 1. sab 2 ; s0 a0 b0 2 ; sa A s0 a0 ) sab A s0 a0 b0 2. s 2 ; s0 2 ; sa A s0 a0 ) (9b)[sab 2 ] i (9b0 )[s0 a0 b0 2  ] Such an extension is not in general an equivalence relation since it might lack re exivity. If  is a strategy for a game A such that   , we write  : A.

De nition 5 (Tensor product). Given games A and B the tensor product A B is the game de ned as follows: { MA B = MA + MB { A B = [A~; B ] { PA B  MA B is the set of positions, s, which satisfy the following conditions: 1. the projections on each component (written as s  A or s  B ) are positions for the games A and B respectively; 2. every answer in s must be in the same component game as the corresponding question. { s A B s0 () s  A A s  A0 ; s  B B s  B0; (8i)[si 2 MA , s0i 2 MA] 4

Here + denotes disjoint union of sets, that is A + B = finl (a) j a 2 Ag [ finr (b) j b 2 B g, and [?; ?] is the usual (unique) decomposition of a function

de ned on disjoint unions. It is easy to see that in such a game only the Opponent can switch component. De nition 6 (Unit). The unit element for the tensor product is given by the empty game I = (?; ?; fg; f(; )g). De nition 7 (Linear implication). Given games A and B the compound game A ( B is de ned as follows: { MA(B = MA + MB { A(B = [A ; B ] { PA B  MA~ B is the set of positions, s, which satisfy the following conditions: 1. the projections on each component are positions for the games A and B respectively; 2. every answer in s must be in the same component game as the corresponding question. { s A(B s0 () s  A A s  A0 ; s  B B s  B0 ; (8i)[si 2 MA , s0i 2 MA] It is easy to see that in such a game only the Player can switch component. De nition 8 (Exponential). Given a game A the game !A is de ned by: { M A = !  MA = Pi2! MA {  A(hi; ai) = A (a) { P A  M ~A is the set of positions, s, which satisfy the following conditions: 1. (8i 2 !)[s  Ai 2 PA ]; 2. every answer in s is in the same index as the corresponding question. { s  As0 () 9 a permutation of indexes 2 S (!) such that:   (s) = ( (s0 ))  (8i 2 !)[ (s  (i))   (s  i)] where  and  are the projections of !  MA and s  i is an abbreviation of s  Ai . One can easily see that the following de nition is well posed and that the objects introduced in De nitions 5, 6 provide indeed a categorical tensor product and its unit. De nition 9 (The category of games G ). The category G has as objects games and as morphisms, between games A and B , the equivalence classes, for the relation A(B , of history-free strategies  : A ( B . We denote the equivalence class of  by []. The identity for each game A is given by the (equivalence class) of the copycat strategy idA = fs 2 PA0 (A00 j s  A0 = s  A00 g where the superscripts are introduced to distinguish between the two di erent occurrences of the game A. !

!

!

!

i

!

1

1

2

1

2

2

5

Composition is given by the extension on equivalence classes of the following composition of strategies. Given strategies  : A ( B and  : B ( C ,    : A ( C is de ned by    = fs  (A; C ) j s 2 (MA + MB + MC ) ^ s  (A; B ) 2 ; s  (B; C ) 2  geven Throughout this paper, without loss of generality, we shall restrict ourselves to \irredundant" games, i.e. to games such that every move appears in at least one position. Any redundant game is in fact categorically isomorphic to an irredundant one. One can easily see that the constructions introduced in De nitions 5, 7 and 8 can be made to be functorial. The category G is a monoidal closed category [3] but it is not Cartesian closed. De nition 10 (A Cartesian closed category of games). The category K (G ) is the category obtained by taking the co-Kleisli category over G over the comonad (!;der; ) [3], where for each game A the strategies derA : !A ( A and A : !A ( !!A are de ned as follows: { derA = [fs 2 P A(A j s  (!A) = s  Ag] { A = [fs 2 P A( A j s  (!A)p i;j = s  (!(!A)i )j g] where p : N  N ! N is a pairing function The category K (G ) has as objects games and as morphisms between games A and B the equivalence class of history-free strategies for the game !A ( B . Moreover it is Cartesian closed. De nition 11 (Cartesian product). Given games A and B the Cartesian product A ^ B is the game de ned as follows: { MA ^ B = MA + M B { A ^ B = [A; B ] { PA ^ B = P A + P B { A ^ B = A + B !

!

!

0

!!

(

)

!

1.1 Order-enrichment

Following [3] we can enrich each homset of G with a partial order structure, as follows De nition 12. Given strategies  and  we write  .  i (8s; s0; a; b; a0)[sab 2  ^ s0 2  ^ sa  s0 a0 =) 9b0 :(s0 a0 b0 2  ^ sab  s0 a0 b0 )] De nition 13. Given a game A and strategies  : A and  : A we de ne [] vA [ ] ()  .  6

Given a game A let A^ be the set of equivalence classes of history-free strategies for A. vA is a partial order over A^. The least element in this partial order is [fg]. We now prove that this partial order is not complete. This answers a question raised in [3] page 21. De nition 14 (Game N). The game N is de ned as follows: { MN = fq; !g [ fn; n j n 2 Ng { N(q) = N(n) = OQ N (!) = N (n) = PQ { PN = fqn(n ? 1)(n ? 1)(n ? 2) : : : 00q!q!q! : : : j n 2 Ngnepref { s N t , jsj = jtj Theorem 15. (N^ ; vN) is not a complete partial order. Proof. Consider the following strategies indexed by n  1: n = fqn(n ? 1)(n ? 1)(n ? 2) : : : 1gnepref It is easy to check that n . m for n  m. The chain [ ]; [ ]; : : : ; [n ]; : : : has no lub, since there is no in nite history-free strategy in N. ut Since N^ ' G (I; N) we have that Corollary 16. The categories G and K (G ) are not cpo-enriched categories under the order relation on morphisms of De nition 13. 0

1

!

2 Solution of recursive games equations The categories of games G and K (G ) allow for the existence of recursive objects, i.e. objects that are xed points of particular functors. In this section we analyze and elaborate the method proposed by Abramsky and McCusker in [4], for de ning recursive games. In a simple-minded, well-founded setting, this method allows to de ne only initial xed points of functors. However in order to model non-trivially  -calculus, it is well known that we need to de ne models which arise from non-initial xed points of a suitable functor. To this end we have to change the functor altogether and use some form of encoding or, equivalently, generalize the method of [4] and consider games \up to" isomorphisms, or consider non-well-founded sets. In this section we shall explore the rst two alternatives. !

2.1 Initial xed points

We start by discussing brie y the method of Abramsky and McCusker [4] in a well-founded setting. This method follows the pattern used for building initial xed points in the context of information systems. First a complete partial order E on games is introduced. 7

De nition 17. Let A; B be games, A is a sub-game of B (A E B) i { MA  M B ; { A = B  MA~; { PA = P B \ M A ; { s A s0 i s B s0 and s 2 PA. One can easily see that the sub-game relation de nes a complete partial order on games. Hence a functor F which Fis continuous with respect to E has a (minimal) xed point D = F (D) given by E F n (I ). Notice that we have indeed an identity between D and F (D). In domain theory, non-initial xed points for a functor F are usually obtained by carrying out the above construction starting from some object A, di erent from the initial one (i.e. I in this case), such that A E F (A). However one can prove that for functors F obtained from constant functors by composition of the basic functors &, , (, ( )? , and !, and for every game A, whose moves are well-founded sets, if A E F (A) then 9n 2 N s.t. A E F n (I ). Hence, eventually, only initial xed points can be obtained using this technique in well-founded Set Theory. As remarked earlier, even if no non-trivial model of  -calculus can be obtained applying this technique directly to the functor !D ( D, nevertheless using Scott's trick (see [19]) we can still de ne models of  . What we need is a non-trivial game which satis es the equivalence D ' D&D. To see this consider the initial xed point, E , of the functor F (X ) = X ! D. This is clearly non trivial. One can easily see that the following chain of equivalences holds E = E ! D = (E ! D) ! D ' (E ! (DD)) ! D ' ((E ! D)(E ! D)) ! D = ((E ! D)  E ) ! D ' (E ! D) ! (E ! D) = E ! E: We shall present this model in Section 5.

2.2 Non-initial xed points In order to obtain a non-initial xed point of a functor, without having to deal with the subtleties of non-well-founded sets, or with indirect encodings, we present a generalization of the method proposed in [4], \up to isomorphism". The basic idea is to obtain a xed point of a functor F as a limit of a chain of approximations D ; D ; D ; : : : where, not necessarily Dn E Dn , but only a weaker relation between Dn and Dn holds. We simply ask that each Dn is isomorphic to a sub-game B of Dn . In order to formalize our construction we need to introduce a new category G e . A similar category was introduced also in [2] for other purposes. 0

1

2

+1

+1

+1

De nition 18. Given games A and B an embedding f : A injective function f : MA ! MB such that: { A =  B  f { f (PA ) = PB \ (f (MA))~ { s A s0 i f (s) B f (s0 ) 8

 B is a total

In the above we have used the notation f  to denote the natural extension of f both to sequences and sets of sequences. De nition 19. The category of games G e has as objects games and as morphisms embeddings. Proposition 20. The category G e is !-cocomplete. Each embedding f : A  B in G e induces two morphisms f : A ( B and f? : B ( A in G de ned as follows. De nition 21. Given an embedding f : A  B, put f = ft 2 PA(B j t 2 sf g f? = ft0 2 PB(A j t0 2 sf g where sf is the least set satisfying: sf = ft a f (a) j t 2 sf ; a 2 MA g [ ft0 f (a) a j t0 2 sf ; a 2 MA g [ fg: One can easily see that (g  f ) = g  f and (g  f )? = f?  g? . The category G e is indeed isomorphic to a sub-category of G and to a sub-category of G op . Now, using the well-known machinery, we can obtain xed points of any continuous functor F in G e . Theorem 22. Given a game D and an embedding f : D  F (D), let hD1 ; nin2! be the colimit of the chain h(F )n (D); (F )n (f )in2! . Then, the game D1 is the xed point of the functor F . The isomorphic F embeddings ' : D1  FF(D1 ) and : F (D1 )  D1 are given by ' = n2! F (n )  ?n and = n2! n  F (n )? respectively, where the lubs are taken in the category of partial embeddings. The following Proposition will be useful in the sequel. Proposition 23. Given a game D and an embedding f : D  F (D) let hD1; nin2! be the xed point of the functor F . For each n 2 N let pn : D1 ( D1 = (n )  (n )? . Then we have: 1. for each game A and for each strategy  : A ( D1 the following equality holds: pn   = fs j s 2 ( \ (inl (MA ) [ inr (n (MF D )))~ )g 2. for each n 2 N (a) pFn v pn (b) n2! pn = id (c) pn  pm = pminfm;ng : Using the above machinery, given an endofunctor F in G (either variant or covariant), one can obtain a xed point of F provided there exists a covariant continuous functor F e in G e , which coincides with F on objects. One can easily see that this is the case for constant functors, the functors &,

, (, !, ( )? and their compositions. +

+

+

+

+

1

1

+

n(

+1

9

)

3 Extensional -models in K (G ) !

As it is well known, a model for  -calculus is a pair D = hD; f i, where D is an extensional re exive object in a Cartesian closed category, i.e. an object D such that D isomorphic to D ! D, and f : D ! [D ! D] is an isomorphism. Two models D = hD; f i, D0 = hD0 ; f 0 i are isomorphic if there exists an isomorphism g : D ! D0 such that f 0  g = [g? ! g]  f . This implies that the two \applicative structures" are the same, i.e. for each ;  : A ! D we have that g  ev  hf  ;  i = ev  hf 0  (g  ); g   i. In this section, using the techniques outlined in Section 2, we de ne a subclass, D , of extensional models in K (G ), and prove the crucial result, namely, that each extensional model in K (G ) is isomorphic to a model in D . In Section 4 we will prove that all models in D induce the -theory H . The endofunctor Fun on the category G e is de ned as follows: { Fun(D) = [D ! D] = (!D ( D); { f : A  B, then: Fun(f ) = [!f; f ] where !f (hi; ai) = hi; f (a)i. One can easily see that Fun is continuous. De nition 24. Let D be the class of -models D = hD; f i where D is the limit of a chain generated by iterating the functor Fun on an initial game D , using an initial embedding f  : D  Fun(D ), such that for each m 2 MD0 , f  (m) = inr (m0 ) for some m0 2 MD0 . And where the isomorphism f : D ! Fun(D) in G is '  derD , where ' is the isomorphic embedding given by the colimit construction. Isomorphisms in K (G ) can be reduced to isomorphisms in G e . In fact we have: Proposition 25. { For each isomorphism  : A ! B in K (G ), there exists an isomorphic strategy 0 : A ( B such that  = 0  derA . { For each isomorphic strategy  : A ( B, there exists an isomorphic embedding f : A  B such that  = (f ) . Proof. The proof of the rst part of the lemma is straightforward. As shown in [3], a history-free strategy  : A ( B can be described as a map g from Opponent's moves to Player's moves in the game A ( B . If  is an isomorphism, with inverse ? then g maps each Player's move of A in a Player's move of B , and each Opponent's move in B to a Opponent's move in A. In fact, suppose by contradiction, that an Opponent's move b 2 MB is such that g (b) = b0 is a Player's move in B , then g?1  (b) = b0 and therefore ?   is not the copy-cat strategy. By a similar argument one can prove that g and g?1 are one the inverse of the other. The function f is then de ned as  OP O f (a) = gg?a1 (a) ifif BOP ((aa)) = = P  A 1

!

!

0

0

0

+

!

!

+

1

1

( )

10

By an analysis similar to the one above, and using the bracketing condition it is possible to prove that f preserves the labeling and that f (PA ) = PB . In order to establish the main result of this section, we need a new de nition, and prove a technical lemma.

De nition 26. Given a game A and a move a 2 MA, the rank of a, r(a), is the smallest integer n such that there exists a sequence of moves a ; : : : ; an such that a ; : : : ; an ; a 2 PA . Lemma 27. For each game A, for each embedding f : A  Fun(A) and for each move a 2 MA, if f (a) = inl (hn; a0 i) then r(a0 ) < r(a); if f (a) = inr (a0 ) then r(a0 )  r(a). 1

1

Proof. Let sa be a minimal position with end point a. The projection of f  (sa ) on the left component must still be a position in P A . Its length is strictly smaller than that of sa , since the initial move of sa has to be mapped onto a move on the right component. ut !

Theorem 28. Each extensional model in K (G ) is isomorphic to a model in D . Proof. Let hD; i be an extensional model in K (G ). Then, by Proposition 25 there exists an isomorphic embedding f : D  Fun(D), such that  = f derA . Let MD0 be the largest subset of MD such that 8d 2 MD0 9d0 2 MD0 such that f (d) = inr (d0 ). Alternatively, with a slight abuse of notation, we can de ne MD0 = fd 2 D j 8n 2 N : (inr ?  f )n (d) is de nedg. It is immediate to verify that the quadruple D = (MD0 ; D  MD0 ; PD \ MD~0 ; D \(MD0  MD0 ) ) is indeed a sub-game of D. By the construction of D , it follows that f = f j 0 is an embedding from D to Fun(D ). Let D be the limit of the !-chain hFunn (D ); Funn (f )in2N, and let f  : !

!

+

1

0

0

0

0

D

0

D  Fun(D ) be the isomorphic embedding induced by the limit construction. We will prove that there exists an isomorphic embedding f 0 : D  D such that f  f 0 = Fun(f 0 )  f  . The isomorphism f 0 is de ned as follows: given d 2 Funn (D ) f 0 ([d] ) = ? f ;n (d), where f ;n : D  Funn (D) is the isomorphism Funn? (f )  : : : Fun(f )  f . Since, for each n 2 N , MFun D0  MFun D , f 0 is a well de ned function from MD to MD . Moreover it is not dicult to verify that f 0 is an embedding. We need to prove that f 0 is surjective. This can be done by induction on the rank of the moves in D. Formally, we will prove that for each move d 2 MD there exists a move d0 in MD such that d = f 0 (d0 ). 0

0

0

1

0

1

0

n

(

n

)

(

)

{ Basic step. this follows form the fact that all initial moves (i.e. moves of rank 0) are in MD0 . { Induction step. Let d 2 MD be a move of rank n + 1, two possible cases arise. Either d 2 D , and therefore d = f 0 ([d] ), or there exist p; i 2 N and d0 2 MD such that 8m  p; (inr ? f )m(d) is de ned and f ((inr ? f )p (d)) = inl(hi; d0 i). By Lemma 27 the rank of d0 is less than n + 1 and, hence, by 0

1

1

11

induction hypothesis, there exists k 2 N and d00 2 Funk (D ) such that d0 = f 0 ([d00 ] ). Let d000 = inr p  inl (hi; d00 i) 2 Funk p (D ), it is not dicult to verify that d = f 0 ([d000 ] ). 0

+

0

Moreover, it is straightforward to verify that f  f 0 = Fun(f 0 )  f  , and from the fact that: [(f  derD )? ! (f  derD )] = Fun(f )  derD!D , the theorem follows straightforwardly. ut +

1

+

+

4 The ne structure of models in D In order to analyze the equational theories induced by the models in D , we establish an Approximation Theorem, in the style of [20,14]. Using this result we will be able to characterize the meaning of a term in the model as the lub of the set of the meanings of the syntactical approximants of the term. To our knowledge this is the rst time such a theorem is proved for models in \non-concrete" categories such as game models. As usual it is convenient to consider ( ), an extension of -calculus with a constant to denote divergence, and its indexed version ( )N .

De nition 29. 1. The set of  -terms, ( )(3 M ) is de ned from a set of variables V ar(3 x) as follows: M ::= x j MM j x:M j : 2. The set of (possibly) indexed terms ( )N(3 M ) is the superset of ( ) de ned as follows:

M ::= x j MM j x:M j j M n : 3. A term is truly indexed if it is of the shape M n . A term is completely indexed if all its subterms of the shape constant, variable, abstraction, and application are immediate subterms of truly indexed terms. The intended meaning of an indexed term M n is the n-th projection of the interpretation of the term M . Hence the interpretation of -terms in K (G ) is de ned as follows. De nition 30. Let D = hD; 'i be a model in D. The interpretation of a term M 2 ( )N (whose free variables are among the list  = fx ; : : : ; xn g) in the jj }| { z model is the strategy [ M ] D  : !(D & : : : & D) ( D de ned inductively as follows:  [ xi ] D  = i ; D D [ MN ]  = ev  h('  [ M ] D  ) ; [ N ]  i; D [ x:M ] D  =  ( [ M ] ;x ); D [ M n] D  = pn  [ M ]  ; !

1

12

[ ] D  =  ; where i are the canonical projection morphisms, ev and  denote \evaluation" and \abstraction" in the Cartesian closed category K (G ),  = [fg], = '? and the pn are the strategies de ned in Proposition 23. Given strategies ;  with codomain D, we use the abbreviation    to denote the strategy ev  h('  );  i, and we will denote with (D)n the game !

1

z }|n { D & : : : & D.

The main result of this section is Theorem 43. In order to establish it we need several preliminary results.

Lemma 31. For each model D = hD; 'i in D , for each game A and pair of strategies ;  : !A ( D , we have:

1. (p  )   = (p  )   = p  (   ) 2. (pn  )   v pn  (  (pn   )) 8n 2 N 0

0

+1

0

+1

Notice that in the statement of Lemma 31.2, we have not taken equality but only inequality. This is done in order to be able to deal simultaneously not only with models in D , but also, in Section 5, with models obtained using the trick of Scott outlined in Section 2. The following Lemmata and De nitions follow closely the pattern of [20,14], and they amount essentially to the game theoretic version of the corresponding \continuous result".

De nition 32. The erasing function R : ( )N ! ( ) is inductively de ned as follows:

R(x) = x; R( ) =

R(PQ) = R(P )R(Q) R(x:P ) = x:R(P ) R(M n ) = R(M ) Lemma 33. For each model D = hD ; 'i in D , for each term M 2 ( ) whose free variables are in , given a nite strategy  : !(D )jj ( D s.t.  v [ M ] D  there exists a natural number n s.t.  v [ M n ] D .   Lemma 34. For each model D = hD ; 'i in D , for each term M 2 ( ) whose free variables are in , given a nite strategy  : !(D )jj ( D s.t.  v [ M ] D  there exists a completely indexed term Q 2 ( )N such that R(Q) = M and  v 1. 2. 3. 4.

[ Q] D .

Lemma 35. Let A be a game and  : A a strategy.  = Ff : A j  nite and  v g. From the above Lemmata it follows that 13

Proposition 36. For each model D = hD; 'i in D, for each term M 2 , F D [ M ]  = f[ Q] D  j Q is a completely indexed term s.t. R(Q) = M g. De nition 37. 1. The following reduction rules are de nable on ( ): ( ) x: !

( ) M !

1

2

2. The following reduction rules are de nable on completely indexed terms of ( )N: ( n ) x: n !

0

1

( n ) n M !

0

2

( I ) ((x:P n )m Qp )h ! (P [x=Qa ])b where b = minfn; m + 1; hg; a = minfm; pg +1

( ) ((x:P ) Q)h ! (P [x= ]) 0

0

0

( i;j ) (M i )j ! M minfi;jg Notice again that the above de nition of the ( I ) indexed reduction rule and the statement of the following Theorem are not formulated as in [20], but are relaxed so as to take care of the model DN (see Section 5).

Theorem 38 (Validity of indexed reduction). For each model D = hD; 'i in D , the rules ( n ); ( n ); ( I ); ( ) and ( i;j ) are valid in the following sense: let P; Q 2 ( )N then D (P  1 2 0 Q) =) [ P ] D  v [ Q]  . Lemma 39. Let Q 2 ( )N be a completely indexed term. Then Q is n n I i;j 1

0

2

n

n

I

i;j

1

normalizing.

2

0

From the above lemma it is immediate to state the following.

Lemma For each model D = hD ; 'i in D , for each term M 2 , [ M ] D = Ff[ N ] D 40.  j 9Q completely indexed term such that R(Q) = M and N is the

n n I i;j -normal form of Qg. De nition 41. The direct approximant of a -term M 2  is a normal form A 2 ( ) obtained from M by replacing each redex in M by , and performing 1

2

0

all the n n -reductions. 1

2

14

De nition 42. The set of approximants of M is the set A(M ) = fA j 9M 0; M   M 0 and A is the direct approximant of M 0 g. Theorem 43 (Approximation theorem). For each model D = hD ; 'i in F D , for each term M 2 , [ M ] D = f[ A] D j A 2 A(M )g. Theorem 44. For each model D = hD ; 'i in D, Th(D) = H. Proof. Using Theorem 38 and standard techniques (see e.g. [6] Section 19.2), one can prove that the structure of the approximants in Theorem 43 as well as the partial order induced by the semantics over them coincide precisely with those of the approximants of Scott's D1 model as in the continuous case. In particular their corresponding Bohm trees satisfy the 1 -equivalence. Hence the argument for the continuous case goes through even in the game setting, and we have that the theory of D, just as in the continuous case, is H . ut

5 Some examples of concrete game models for   -calculus In this Section, by way of example, we introduce four extensional -models in K (G ). The rst two belong to D , the third does not, while the fourth one is the model obtained by carrying the analogous of Scott's trick as outlined in Section 2. We start by introducing three initial embeddings for the functor Fun: De nition 45. 1. Let D = (fg; () = OQ; f; g; id) and de ne f : D  (!D ( D ) by f () = inr (); 2. let D = (f; g; (() = OQ; () = PQ); f; ; g; id) and de ne f : D  (!D ( D ) by f() = inr () and f () = inr (); 3. let D = (f; g; (() = OQ; () = PQ); f; ; g; id) and de ne f : D ! (!D ( D ) by f () = inr () and f () = inl(h0; i). Finally, using Theorem 22 we give the following de nition: De nition 46. The models D1 ; D1; D1 are determined by the limits of the chains generated by iterating the functor Fun on the embeddings f ; f ; f, and by the corresponding injection ' respectively. The last -model we introduce, de ned using Scott's trick, is DN. De nition 47. Let AN = (N; n:OQ; fg [ N; id): The model DN is the one naturally induced by the least xed point of the functor F (D) = !D ( AN where the following chain holds for every n 2 N: DnN ' !DnN ( AN ' !DnN ( (AN & AN ) ' (!DnN ( AN ) & (!DnN ( AN) ' DnN & DnN . Hence we have DnN ' !DnN ( AN ' !(DnN & DnN) ( AN ' !DnN ( (!DnN ( AN) ' !DnN ( DnN . One can easily see that DN is a -model since any bijection p : N + N ! N , induces an isomorphism between AN and AN & AN . !

0

0

0

0

0

0

0

0

0

0

0

0

+1

+1

+1

+1

15

+1

6 Conclusions and Final Remarks In this paper we have shown that all extensional -models in the category K (G ) of [3] induce the same -theory, this is the well-known theory H . It is natural to conjecture, therefore, that also there is only one non-extensional sensible theory which can be modeled using games. We recall that a sensible -theory is a theory where all unsolvable terms are equated. This would be the theory B of Bohm trees, and would be the theory of any re exive object in K (G ), hD; f i, for which f maps the unde ned strategy on !D ( D on the unde ned strategy on D, but it is not an isomorphism. Our results clearly indicate that game models are even more rigid than continuous models. But is this really a \surprise", or a \bad surprise"? De nitely there must be some intrinsic feature of games, as they are currently de ned, that is intimately related with head reduction. It is dicult to imagine at this stage what this is. Probably it is not the fact that we have considered only \historyfree" strategies, more likely it has to do with the \strict" protocol of alternation of moves between Opponent and Player. We feel however that when the appropriate constraint will be relaxed, the perspicuous analytic power of games will become applicable also to other reduction strategies, besides head reduction. We end this paper with two more technical notes. It is worth noticing that in our models of untyped -calculus it is not necessary to take at the very end an extensional quotient, as is done for typed -calculus [3] or the lazy -calculus [4]. The essential ingredient in the proof of Theorem 44 is Lemma 31. This has a bearing also on models in the category of CPOs. Namely H is the theory of all inverse limits obtained starting from an initial injection where all points are mapped onto constant functions, as well as that of the \Scott's trick model" presented in [19]. !

!

References 1. S. Abramsky. Domain theory in logical form. In Annals of Pure and Applied Logic, volume 51, pages 1{77, 1991. 2. S. Abramsky and R. Jagadeesan. Games and full completeness for multiplicative linear logic. Journal of Symbolic Logic, 59(2):543{574, June 1994. 3. S. Abramsky, R. Jagadeesan, and P. Malacaria. Full abstraction for PCF. Ftpavailable at http://www.dcs.ed.ac.uk/home/samson, 1994. 4. S. Abramsky and G. McCusker. Games for recursive types. In I. C. Mackie C. L. Hankin and R. Nagarajan, editors, Theory and Formal Methods of Computing 1994: Proceedings of the Second Imperial College Department of Computing Workshop on Theory and Formal Methods. Imperial College Press, October 1995. 5. S. Abramsky and C.H.L. Ong. Full abstraction in the lazy -calculus. Information and Computation, 105:159{267, 1993. 6. H. Barendregt. The Lambda Calculus: Its Syntax and Semantics. North-Holland, Amsterdam, 1984. revised edition. 7. H. Barendregt, M. Coppo, and M. Dezani-Ciancaglini. A lter model and the completeness of type assignment. Journal of Symbolic Logic, 48(4):931{940, 1983.

16

8. O. Bastonero and X. Gouy. Strong stability and the incompleteness of strong models for -calculus. To appear on Annals of Pure and Applied logic. 9. C. Berline. From Computation to Foundations via Functions and Application: the -calculus and its Webbed Models. To appear. 10. M. Coppo, M. Dezani-Ciancaglini, F. Honsell, and G.Longo. Extended type structures and lter -models. In G.Lolli G.Longo and A.Marcja, editors, Logic Colloquium '82. Elsevier Science Publishers, 1984. 11. P. Di Gianantonio and G. Franco. A type assignment system for the game semantics. In Proceedings of the Italian Conference of Theoretical Computer Science, 1998. 12. J.Y. Girard. The system F of variable types, fteen years later. Theoretical Computer Science, 45:159{192, 1986. 13. F. Honsell and M. Lenisa. Final semantics for untyped -calculus. In LNCS, volume 902, pages 249{265. Springer-Verlag, 1995. 14. F. Honsell and S. Ronchi Della Rocca. An Approximation Theorem for Topological Lambda Models and the Topological Incompleteness of Lambda Calculus. Journal of Computer and System Sciences, 45:49{75, 1992. 15. J.M.E. Hyland. A syntatic characterization of the equality in some models of the -calculus. Journal of London Mathematical Society, 12(2):361{370, 1976. 16. 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. 17. G. A. McCusker. Games and full abstraction for a functional language with recursive types. PhD thesis, Imperial College, 1996. 18. D. Scott. Continuous lattices. In Toposes, Algebraic Geometry and Logic - Lecture Notes in Mathematics, volume 274. Springer-Verlag, Berlin, New York, 1972. 19. D. Scott and C. Gunter. Semantic domains. In Handbook of Theorical Computer Science. North Holland, 1990. 20. C. P. Wadsworth. The Relation between computational and Denotational Properties for scott's D1 -models of the lambda-calculus. SIAM Journal of Computing, 5(3):488{521, September 1976.

A Proofs Proof of Proposition 20 Given an !-chain hDn ; fni with fn : Dn

 Dn its colimit is hD1; ni where D1 is the game: { MD1 = (Sn2! MD )= where  is the least equivalence relation such that 8n 2 N 8a 2 Dn 8b 2 Dn : fn (a) = b ) a  b: { D1 ([a]) = D (a) if a 2 Dn, { PD1 = SSn2! f[a ][a ] : : : [ap ] j a 0a : : :0 ap 2 PD0 g { D1 = n2! f([a ][a ] : : : [ap ]; [a ][a ] : : : [ap]) j (a a : : : ap ; a0 a0 : : : a0p ) 2 D g The colimit functions n : Dn  D1 are de ned by n (a) = [a] . ut +1

n

+1

n

1

2

1

1

1

2

2

1

1

2

n

2

n

2

Proof of Lemma 31

17

1. From Proposition 23 we have p   = fs 2  j s 2  ^ s 2 (inl (M A) [ inr ( (MD0 )))g. Let '0 : D ( (!D ( D) the strategy such that ' = '0  derD . It follows that '0  p   : !A ( (!D ( D ) = fs 2  j s 2  ^ s 2 (inl (M A ) [ inr (inr ( (MD0 ))))g. Hence the strategy '0  (p  ) never interacts with its second input. We have then (p  )   = ev  h('  (p  ));  i = (p  )   . In the same way we get p  (   ) = (p  )   . 2. From Proposition 23, and Theorem 22 we have '0  (pn  ) : !A ( (!D ( D ) = fs 2  j s 2  ^ s 2 (inl (M A ) [ inr (inl (n (MFun D0 ))) [ inr (inr (n (MFun D0 ))))g. Hence the strategy '0  (pn  ) considers only the moves in n (MFun D0 ) of its second component and returns only moves in n (MFun D0 ) as output. It follows that (pn  )   = pn  (  (pn   )), and from this (pn  )   v pn (  (pn   )). 0

!

0

0

!

0

0

0

0

0

0

0

+1

n(

!

n(

)

)

+1

(

(

)

)

+1

+1

ut

+1

Proof of Lemma 33   Since  v [ M ] D  : !(D ) ( D then each position of  has a corresponding

position in [ M ] D  ; but  is nite, hence there exist an n such that  involves only moves \in Dn ". ut

Proof of Lemma 34

Induction on M . 1. M  x. Follows from lemma 33. ? D 2. M  x:P . Given a nite  s.t.  v [ x:P ] D  then  ('   ) v [ P ] ;x . Since  preserves niteness of strategies and since ' is an isomorphism, by induction hypothesis, there exists an indexed term P n s.t. ? ('  ) v nD [ P n] D ;x . Hence we get  v [ x:P ]  by de nition of interpretation of terms and hence  v [ (x:P n )m ] D  by Lemma 33. D D 3. M  PQ. If  v [ PQ]  then  = ev  h'  [ P ] D  ; [ Q]  i. Since ev is conD tinuous there are nite strategies  ;  s.t.  v '  [ P ] D  ,  v [ Q]  and   v [ P ] D since preserve niteness of strategies. Hence, by induction hypothesis, there exist completely indexed terms P n and Qm s.t.   v mD [ P n] D  and  v [ Q ]  . By Lemma 33 we can then conclude that there exists an h s.t.  v [ (P n Qm)h ] D . 1

1

1

2

1

2

1

1

2

ut

Proof of Proposition 36

Since the projection functions are smaller that the F identity we have: [ Q] D v D D [ M ]  . From 35 and 34 we have [ M ]  = f j  nite and  v Ff[ Lemma D j Q is an indexed term and R(Q) = M g = [ M ] D g v Q ] [M]D  since  v   D D ut [ Q]  v [ M ]  . 18

Proof of Theorem 38 1. Rules ( n ) and ( n ). Since the interpretation of n is always  , the empty strategy, the validity of the rules follows easily. 2. Rule ( I ). [ ((x:P n )m Qp )h ] D  = ph  [ (x:P n )m Qp ] D  pD = ph  ([[(x:P n )m ] D  [Q ]) D = ph  ((pm  [ x:P n ] D  )  (pq  [ Q]  )) n D v ph  pm  ([[x:P ]   (pm  pq  [ Q] D )) (by lemma 31) D = pminfh;m g  ([[x:P n ] D   (pminfm;qg  [ Q]  )) minfm;qg ] D ) = pminfh;m g  ([[x:P n ] D  [Q  n min f m;q g ]]]D = pminfh;m g  [ P [x=Q  = pminfh;m g  pn  [ P [x=Qminfm;qg ]]]D  = pb  [ P [x=Qa ] D  3. Rule ( ). [ ((x:P ) Q)h ] D  D = ph  ((p  [ x:P ] D  ) [ Q]  ) = ph  (p  ([[x:P ] D    )) (by lemma 31) D = ph  (p  ([[x:P ] D   [ ]  )) = p  ([[P [x= ]]]D ) 4. Rule ( i;j ) follows immediately from Proposition 23.2.c. 1

2

+1

+1

+1

+1

+1

+1

+1

+1

+1

0

0

0

0

0

0

Proof of Theorem 43 D Since [ A] D  v [ M ]  Ffor each approximant A and A(M ) is a strongly directed set of strategies we get f[ A] j A 2 A(M )g v [ M ] D  . Since erasing the indexes from an indexed normal term Q we get an approximant of M , see [20], by lemma 40 we get the equality. ut

19