• Non ci sono risultati.

A Type Assignment System for Game Semantics ?

N/A
N/A
Protected

Academic year: 2021

Condividi "A Type Assignment System for Game Semantics ?"

Copied!
31
0
0

Testo completo

(1)

A Type Assignment System for Game Semantics ?

Pietro Di Gianantonio, Furio Honsell, Marina Lenisa

a

aDipartimento di Matematica e Informatica, Universit`a di Udine via delle Scienze 206, 33100 Udine, Italy.

{digianantonio,honsell,lenisa}@dimi.uniud.it

dedicated to Mariangiola, Mario and Simona, on the occasion of their 60

th

birthdays

Abstract

We present a type assignment system that provides a finitary interpretation of lambda terms in a game semantics model. Traditionally, type assignment systems describe the semantic interpretation of terms in domain theoretic models. Quite surprisingly, the type assignment system presented in this paper is very similar to the traditional ones, the main difference being the omission of the subtyping rules.

Key words: Lambda Calculus, Game Semantics, Type Assignment System

1 Introduction

About twentyfive years ago, Mario Coppo, Mariangiola Dezani, and their group, started to provide logical descriptions of models of λ-calculus, in terms of intersection type assignment systems, [8,10,7,15]. This logical approach was related explicitly to Scott Information Systems in [9], and put on firm categor- ical grounds by Abramsky in [1]. In this paper, we present a logical analysis of game models in the style of intersection types. We feel that it provides new insights both in the semantics of λ-calculus and in the fine structure of game semantics. Thus we show that the idea underpinning intersection types is an outstanding contribution to Theoretical Computer Science, which allows to reap fruitful results in any semantical framework.

? Work partially supported by UE Project IST-CA-510996 Types, and by Italian MIUR Project PRIN 2005015824 ART.

(2)

The intersection type approach can be outlined as follows. The semantics of a programming language can be given in two forms: a term can be interpreted either denotationally by a point in a particular domain, or logically by a set of properties. Stone-duality, as presented in [1], establishes an equivalence be- tween these two alternate descriptions for suitable categories of domains. In this approach, properties of terms are normally called “types”. The logical semantics consists of the set of rules, called “type assignment system”, which allow to derive the properties satisfied by a term. Type assignment systems can be seen to provide concrete, finitary approximations of the semantics of a term.

Differently from the standard case, in type assignment systems for game se- mantics, a type cannot describe simply the input-output behavior of a term, but it needs to describe a more detailed interaction of the term with the envi- ronment. In particular, a type t for a term M describes a set of moves that the Proponent and the Opponent may exchange in some phases of the interaction of the term M with the environment. Quite surprisingly, the syntax for stan- dard intersection types is used to describe sets of moves. The game-theoretic perspective is achieved by removing all structural and congruence rules from standard assignment systems. In our framework, no form of weakening rule is present and the types (t0∧ t1) ∧ t2, t0∧ (t1∧ t2), t0∧ (t2∧ t0) are all distinct.

In this paper, we consider the game semantics framework presented by Abram- sky, Jagadeesan and Malacaria in [4], and known as AJM-games. The strate- gies that game intersection types generate are naturally history-free, the ∧ op- erator is used to model the exponential construction, the lack of associativity and commutativity rules for ∧ is connected to the use of indexes to distin- guish different instances of moves in a exponential type. As for AJM-games, it is necessary to introduce a partial equivalence relation on interpretations to recover subject reduction, due to the arbitrariness in the use of indexes.

In this paper, we focus on simply typed λ-calculus. We define a game λ-model in the standard way in a category of games and history-free strategies, and we introduce an intersection-like type system for describing such a game model.

Our approach to game intersection types is “typed”, i.e. intersection types are built inductively over games. The usual untyped intersection semantics can be recovered as a special case of the typed case. As already mentioned, in our setting, types on a game A represent sets of Opponent and Proponent moves on A. The intended meaning of a judgment in our typing system is that a set of equal number of Opponent and Proponent moves appear in the history-free strategy interpreting the term in the given environment. More- over, the moves in this set may be exchanged during the interaction between that term and that environment. The main point which allows to establish a bridge between the intersection-like types that we introduce and game seman- tics is that history-free strategies induce partial functions from Opponent to

(3)

Proponent moves, in a Geometry of Interaction (GoI) fashion, [13,2,3]. Un- der this perspective, the most informative judgments are those involving step types, where exactly two moves appear, an Opponent move and the Proponent reaction move in the graph of the partial function defining this strategy. The main result of this paper amounts to the fact that the intersection type se- mantics of a given term in context induces a partial function from Opponent to Proponent moves, which defines the strategy interpreting the term in the game model.

Our approach to game intersection types is quite general. In particular, type assignment systems for GoI combinatory algebras in “particle-style” [3] can be easily derived from game type assignment systems, simply by forgetting the distinction between Opponent and Proponent moves.

Type assignment systems like the one presented in this paper are quite useful in the context of game semantics, since they provide a more concrete and intuitive account of the interpretation of terms w.r.t. categorical game models.

In fact, deriving a concrete definition from a categorical one can be a heavy task.

The problem of giving a concrete and finitary description of game models has been also investigated in [11], where a type assignment system describing the game model of the untyped λ-calculus of [12] has been presented. However, the approach of [11] is different and more directly connected to the representation of strategies as sets of plays and to the categorical combinators involved in the game semantics.

Synopsis. In Section 2, we recall basic notions on games and strategies, we present a new alternative definition of the exponential game, and we discuss the representation of history-free strategies as partial functions. In Section 3, we present syntax and game semantics of the simply typed λ-calculus, which we use as target language. In Section 4, we introduce and study a type as- signment system giving a finitary description of the game model of Section 3.

In Section 5, we establish the connection between the type assignment system and the game model for the simply typed λ-calculus of Section 3. Finally, in Section 6, we discuss further developments.

2 Game Categories

In this section, first we recall basic notions and constructions on games and strategies in the style of [4]. Then, in Section 2.1, we present an alternative construction of the exponential game, which will be useful in order to study

(4)

the connections between our typing semantics and the game semantics. To the same purpose, in Section 2.2, we discuss the alternative representation of history-free strategies as partial functions from Opponent to Proponent moves.

The following are the usual definitions of game and strategy in the style of [4]:

Definition 2.1 (Games) A game has two participants: the Proponent 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 → {O, P } × {Q, A} is the labeling function: it tells us if a move is taken by the Opponent or by the Proponent, and if it is a Question or an Answer. We can decompose λA into λOPA : MA → {O, P } and λQAA : MA → {Q, A} and put λA = hλOPA , λQAA i. We denote by the function which exchanges Proponent and Opponent, i.e. O = P and P = O. We also denote with λOPA the function defined by λOPA (a) = λOPA (a). Finally, we denote with λA the function hλOPA , λQAA i.

• PAis a non-empty and prefix-closed subset of the set MA~(written as PAnepref MA~), where MA~ is the set of all sequences of moves which satisfy the fol- lowing conditions:

· s = at ⇒ λA(a) = OQ

· (∀i : 1 ≤ i ≤ |s|)[λOPA (si+1) = λOPA (si)]

· (∀ t v s)[|t  MAA| ≤ |t  MAQ|]

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 denotes the set of positions of the game A.

• ≈A is an equivalence relation on PA which satisfies the following properties:

· s ≈As0 ⇒ |s| = |s0|

· sa ≈As0a0 ⇒ s ≈A s0

· s ≈As0 & sa ∈ PA⇒ (∃a0)[sa ≈As0a0]

In the above s, s0, t and t0 range over sequences of moves, while a, a0, b and b0 range over moves. The empty sequence is written .

In a position, questions and answers match together like open and closed parentheses in an algebraic expression.

Definition 2.2 (History-free Strategies) A strategy for the Proponent in a game A is a non-empty set σ ⊆ PAeven of positions of even length such that σ = σ∪dom(σ) is prefix-closed, where dom(σ) = {t ∈ PAodd | (∃a)[ta ∈ σ]}, and PAodd and PAeven denote the sets of positions of odd and even length respectively.

A strategy σ for a game A is history-free if it satisfies the following properties:

(5)

(1) sab, tac ∈ σ ⇒ b = c

(2) sab, t ∈ σ, ta ∈ PA ⇒ tab ∈ σ

A strategy can be seen as a set of rules which tells the Proponent which move to take after the last move by the Opponent. History-free strategies are strategies which depend only on the last move by the Opponent.

The equivalence relation on positions ≈A can be extended to strategies in the following way.

Definition 2.3 Let σ, τ be strategies, σ ≈ τ if and only if (1) sab ∈ σ, s0a0b0 ∈ τ, sa ≈As0a0 ⇒ sab ≈As0a0b0

(2) s ∈ σ, s0 ∈ τ, sa ≈As0a0 ⇒ (∃b)[sab ∈ σ] iff (∃b0)[s0a0b0 ∈ τ ]

Such an extension is not in general an equivalence relation since it might lack reflexivity. If σ is a strategy for a game A such that σ ≈ σ, we write σ : A.

Game Constructions.

Definition 2.4 (Tensor product) Given games A and B, the tensor prod- uct A ⊗ B is the game defined as follows:

• MA⊗B = MA+ MB

• λA⊗B = [λA, λB]

• PA⊗B ⊆ MA⊗B~ is the set of positions, s, which satisfy the following condi- tions:

(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 matching question.

• s ≈A⊗B s0 ⇐⇒ s  A ≈A s0  A, s  B ≈B s0  B, (∀i)[si ∈ MA⇔ s0i ∈ MA] Here + denotes disjoint union of sets, that is A+B = {(l, a) | a ∈ A}∪{(r, b) | b ∈ B}, and [−, −] is the usual (unique) decomposition of a function defined on disjoint unions.

Definition 2.5 (Linear implication) Given games A and B, the compound game A ( B is defined as follows:

• MA(B = MA+ MB

• λA(B = [λA, λB]

• PA(B ⊆ MA(B~ is the set of positions, s, which satisfy the following condi- tions:

(6)

(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 matching question.

• s ≈A(B s0 ⇐⇒ s  A ≈As0  A, s  B ≈B s0  B, (∀i)[si ∈ MA ⇔ s0i ∈ MA] Definition 2.6 (Exponential) Given a game A, the game !A is defined by:

• M!A = ω × MA=Pi∈ωMA

• λ!A(hi, ai) = λA(a)

• P!A ⊆ M!A~ is the set of positions, s, which satisfy the following conditions:

(1) (∀i ∈ ω)[s  Ai ∈ PAi];

(2) every answer in s is in the same index as the matching question.

• s ≈!A s0 ⇐⇒ ∃ a permutation of indexes α ∈ S(ω) such that:

· π1(s) = α1(s0))

· (∀i ∈ ω)[π2(s  α(i)) ≈ π2(s0  i)]

where π1 and π2 are the projections of ω × MA and s  i is an abbreviation of s  Ai.

The Game Category G. We define a monoidal closed category G.

Objects: games.

Morphisms: a morphism between games A and B is an equivalence class w.r.t. the relation ≈A(B of history-free strategies σ : A ( B. We denote the equivalence class of σ by [σ].

Composition: the 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 defined by

σ||τ = {s ∈ (MA+ MB+ MC) | s  (A, B) ∈ σ & s  (B, C) ∈ τ } τ ◦ σ = {s  (A, C) | s ∈ σ||τ }even

Identity: the identity idA: A ( A is defined by idA = {s ∈ PAeven | s  1 = s  2} .

The game constructions of tensor product and linear implication can be made functorial, in such a way that:

Proposition 2.1 ([4]) The category G is monoidal closed.

(7)

However, as it is well-known, G is not cartesian closed.

The Game Category K!(G). The exponential game construction of Defi- nition 2.6 can be made functorial, by defining, for any strategy σ : A ( B, the strategy !σ :!A (!B by

!σ = {s ∈ P!A(!B | ∀i ∃s0 ∈ σ. (∀s1, s01 prefixes of s, s0 of the same even length.

(s1  (A)i = s01  A & s1  (B)i = s01  B))}.

Moreover, the exponential can be endowed with a comonad structure (!, der , δ) [4], where for each game A the morphisms derA: !A ( A and δA : !A ( !!A are defined as follows:

• derA = [{s ∈ P!A(Aeven | ∀s0 even length prefix of s. (s0  (!A)0 = s0  A & ∀i 6= 0. s0  (!A)i = )}]

• δA = [{s ∈ P!A( !!Aeven | ∀s0 even length prefix of s. (∀i, j. s0  (!A)c(i,j) = s0  (!(!A)i)j & ∀k 6∈ codom(c). s0  (!A)k = )}], where c is a pairing function, i.e. an injective map c : ω × ω → ω.

Let K!(G) be the co-Kleisli category over the comonad (!, der , δ), i.e.:

Objects of K!(G): games.

Morphisms of K!(G): a morphism between games A and B is an equiva- lence class of history-free strategies for the game !A ( B.

Composition on K!(G): given strategies σ : A → B and τ : B → C, the strategy τ ◦ σ : A → C is given by the composition in the category G of the strategies σ:!A (!B and τ :!B ( C, where σ is defined by (!σ) ◦ δA.

The following strategies give a commutative comonoid structure on !A, [4]:

• the empty strategy weakA:!A ( I (weakening), where I = (∅, ∅, {}, {(, )}) is the empty game;

• the contraction strategy conA:!A (!A⊗!A,

conA= [{s ∈ P!A( !A⊗!Aeven | ∀s0 even length prefix of s. ∀i (s0  (!A)d(l,i) = s0  ((!A)l)i & s0  (!A)d(r,i)= s0  ((!A)r)i) & ∀j 6∈ codom(d). (s0  (A)j = )}], where d is a tagging function, i.e. an injective map d : ω + ω → ω.

(8)

Identity on K!(G): the identity idA:!A ( A is derA.

Using the above structure, one can define a cartesian product on K!(G), see [4] for more details:

Proposition 2.2 ([4]) The category K!(G) is cartesian closed.

Finally, we point out that Propositions 2.1 and 2.2 hold also if, in the defini- tion of games, we abandon the machinery of “questions and answers”, i.e. the bracketing condition. Thus, since for our purposes the bracketing condition is not relevant, in the sequel we will simply focus on games with no ques- tions/answers. This corresponds to consider games where all moves are labeled as questions. In this section we have chosen to present the questions/answers machinery, because this is standard, and also in view of possible extensions of the present work.

2.1 An Alternative Construction of the Exponential Game

In this section, we present an exponential game construction alternative to the standard one of Definition 2.6 above. The new exponential will turn out to be naturally isomorphic to the old one. This alternative definition is motivated by the fact that it makes the connection between moves on games and intersection types more direct.

The new exponential game is built using, in place of ω, a set of indexes I defined by:

Definition 2.7 Let I be the set of all indexes represented by (possibly empty) lists of symbols in {0, 1}.

In the sequel, it will be useful to view indexes in I as paths of a binary tree.

We will denote by !IA the new exponential game. The main difference between the standard exponential game and the new one lies in the fact that the set of legal positions over the game !IA is a proper subset of the positions over

!A. Namely, we consider as legal only those positions which use a subset of compatible indexes, in the following sense:

Definition 2.8 (Compatible Subsets of Indexes) Two indexes i, j ∈ I are compatible if neither i is a prefix of j nor j is a prefix of i. A set of indexes J ⊆ I is compatible if, for each i, j ∈ J , i and j are compatible.

Notice that the set of indexes with the compatible relation is a web and the compatible subsets of an index set I form the corresponding coherent space in

(9)

the sense of Girard.

For any pair of indexes i, j ∈ I, we can define the composition operation cI : I × I → I simply as list concatenation. Viewing indexes as paths, the composition operation yields the index corresponding to the path obtained by appending the second path to the first one.

Coherent subsets of indexes have the following relevant property w.r.t. com- position:

Lemma 2.1 For any compatible set J of indexes, and any family of compat- ible sets {Kj}j∈J, the set {cI(j, k) | j ∈ J & k ∈ Kj} is compatible.

The above lemma, together with the definition of the legal positions on the game !IA, will allow us to use the composition operation cI as pairing function for defining the comonad structure on !I. Namely, even if cI is not injective in general, it is injective on compatible sets of indexes. Formally:

Definition 2.9 (Alternative Exponential) Given a game A, the game !IA is defined by:

• M!IA= I × MA=Pi∈IMA

• λ!IA(hi, ai) = λA(a)

• P!IA⊆ M!~IA is the set of positions, s, which satisfy the following conditions:

(1) (∀i ∈ I)[s  Ai ∈ PAi];

(2) (every answer in s is in the same index as the matching question;) (3) the set of indexes appearing in the moves of s is compatible.

• s ≈!IAs0 ⇐⇒ ∃ a permutation of indexes α ∈ S(I) such that:

· π1(s) = α1(s0))

· (∀i ∈ I)[π2(s  α(i)) ≈ π2(s0  i)]

The exponential game construction !I can be naturally lifted to a functor such that:

Proposition 2.3 The exponential functor !I is naturally isomorphic to the standard exponential functor !.

Proof. Let ι : I → ω be any injective function, e.g.

ι(i) =

0 if i = 

2 ∗ ι(i0) + 1 if i = 0i0 2 ∗ ι(i0) + 2 if i = 1i0

Let ι0 : ω → I be any injective function whose codomain is a compatible set of indexes, e.g. ι0(i) = 1 . . . 1

| {z }

i

0.

(10)

Then ι, ι0 induce families of strategies

– σι = {σAι :!IA (!A}A, where σAι = {s ∈ P!IA( !A| ∀s0 even length prefix of s.

s0  (!IA)ι(i)= s0  (!A)i};

– σι0 = {σAι0 :!A (!IA}A, where σAι0 = {s ∈ P!A( !IA| ∀s0 even length prefix of s.

s0  (!A)ι0(i) = s0  (!IA)i}.

One can show that [σι] and [σι0] are well-defined natural isomorphisms; more- over, one is the inverse of the other. 

As a consequence of the above proposition, the exponential functor !I can be endowed with a comonad structure (!I, derI, δI), and, for any game A, the

game !IA can be endowed with a commutative comonoid structure (!IA, conIA, weakIA).

For our purposes, it is useful to give explicit definitions of the morphisms derIA, δAI, conIA, as equivalence classes of special strategies:

• derIA = [{s ∈ P!evenIA(A | ∀s0 even length prefix of s. (s0  (!IA) = s0  A & ∀i 6= . s0  (!IA)i = )}]

• δAI = [{s ∈ P!evenIA( !I!IA | ∀s0 even length prefix of s. (∀i, j. s0  (!IA)cI(i,j) = s0  (!I(!IA)j)i & ∀k 6∈ codom(cI). s0  (!IA)k = )}], where cI : I × I → I is the composition function defined above;

• conIA = [{s ∈ P!evenIA( !IA⊗!IA | ∀s0 even length prefix of s. ∀i. (s0  (!IA)0i = s0  ((!IA)l)i & s0  (!A)1i = s0  ((!IA)r)i & s0  (!IA) = )}].

Notice that δAI is well defined by Lemma 2.1, and the tagging function dI : I + I → I is implicitly defined by dI(l, i) = 0i and dI(r, i) = 1i.

From now on, we will use the symbol ! to refer to the standard or to the new exponential, indifferently. We will state it explicitly, when the new exponential comes into play.

2.2 History-free Strategies as Partial Functions

Following Definition 2.2 of Section 2, strategies are usually represented as trees, where each path corresponds to a position of the strategy. As shown in [4], history-free strategies admit also an alternative presentation as partial functions from Opponent to Proponent moves, which will be quite useful in the sequel. In this section, we study in detail such presentation. The representation of history-free strategies as partial functions will be exploited in the sequel of this paper, where a type assignment system is introduced and its connections with the game semantics are studied.

Following [4]:

Definition 2.10 Let σ be a history-free strategy. We define a partial function

(11)

fσ : MOA* MPA by

fσ(a) = b iff ∃s ∈ PA. sab ∈ σ .

Vice versa, let fσ : MOA * MPA, we define inductively the set traces(f ) as follows:

 ∈ traces(f )

s ∈ traces(f ) & sa ∈ PA & f (a) = b =⇒ sab ∈ traces(f ).

We say that f induces the strategy σf = traces(f ), if traces(f ) ⊆ PA.

Proposition 2.4 If f : MOA * MPA is a partial function inducing a strategy σf on A, then σf is history-free.

Notice that, for any partial function f , we have fσf ⊆ f , while for any strategy τ , we have σfτ = τ . Thus there is always a least partial function on moves canonically inducing a history-free strategy.

Using the representation of strategies as partial functions, the morphisms from A to B on the category G are represented by partial functions f : MAP+MBO * MAO+ MBP. Such functions can be written as matrixes:

f =

f11 f12

f21 f22

where

f11 : MAP * MAO f12 : MBO * MAO f21 : MAP * MBP f22 : MBO * MBP Functions such as f above are amenable of a useful geometrical description in terms of “boxes and wires”, [2,3], as in Fig. 1(i).

The composition on the category G can be equivalently expressed in terms of the representation of strategies as partial functions as follows. Let f : MAP + MBO* MAO+MBP, g : MBP+MCO * MBO+MCP representing strategies, then f, g are composed in such a way that Proponent moves in B under σ get turned into Opponent moves in B for τ , and vice versa. Geometrically, we have the picture in Fig. 1(ii).

Algebraically, the composition of f and g is obtained via a Girard’s Execution Formula, see [4] for more details.

The application morphism appA,B : (A ( B) ⊗ A ( B determined by the monoidal closed structure on G is induced by the isomorphism

((MAO+ MBP) + MAP) + MBO' ((MAP + MBO) + MAO) + MBP .

(12)

? Q

Q Q

?







(i) f11

f12

f22

f21

?

?

MBO

MBP MAP

MAO

? ?

(ii)

? ?

? ?

? ?

 -















 A

A A

A A

A A

A

MBO

MBP

MBP

MBO MAP

MAO

MCO

MCP

Fig. 1. Geometrical description of strategies and strategy composition.

? ?

MBO MAP

fσ

? ?

MBP MAO

MAP fτ

Fig. 2. Geometrical description of application on G.

Geometrically, the application of two strategies σ : A ( B and τ : A, i.e.

appA,B◦ (σ ⊗ τ ) is represented as in Fig. 2.

In view of studying the connections between our type semantics and the game semantics, it is useful to give an explicit description of the application of two strategies, σ :!C ( (!A ( B) and τ :!C ( A, in the category K!(G). The application of σ, τ in K!(G), i.e. ev ◦hσ, τ i, coincides (up-to ≈) with the strategy obtained by the following composition on the category G: appA,B◦(σ⊗τ)◦conC (see [4] for more details).

In Fig. 3 appears the geometrical description of the strategy resulting from the application of strategies σ, τ , represented by partial functions fσ : M!CP + (M!AP + MBO) → M!CO + (M!AO + MBP) and fτ : M!CP + M!AO → M!CO + M!AP. The final box (dash box in figure) represents a two-input/two-output function f : M!CP + MBO → M!CO + MBP. If the input enters through the wire MBO, then it is directly sent to fσ, otherwise, if the input enters through the wire M!CP, then the contraction conC acts where the • appears, by sending the token either to fσ or to fτ, depending on the index of the move. Once the token is sent to fσ or fτ, it can possibly cycle along the wires M!AO and M!AP, and finally it exists either from the box fσ (through the wire M!CO or MBP) or from the box fτ (through the wire M!CO). The contraction merges the outputs coming from the wires M!CO of fσ and fτ where indicated.

(13)

?s

M!CP MBO

MBP

?

? ?

? -

MBO M!AP

M!CP fσ

?

?

?

?

?

MBP M!AO M!CO

M!CP

M!AP M!CO

M!CO fτ

? s ?

Fig. 3. Geometrical description of application on K!(G).

3 The Simply Typed λ-calculus

In this section we recall the syntax of the simply typed λ-calculus with two ground constants, ⊥, >, and we introduce a game model for such calculus. In Section 4, we will introduce a finitary description of this game model, based on a typed assignment system.

Definition 3.1 The class SimType of simple types over a ground type o is defined by:

(SimType 3) A ::= o | A → A .

Raw Terms are defined as follows:

Λ 3 M ::= ⊥ | > | x | λxA.M | M M ,

where ⊥, > ∈ Const are ground constants, x ∈ Var. We denote by Λ0 the set of closed λ-terms.

Well-typed terms. We introduce a proof system for deriving typing judge- ments of the form Γ ` M : A, where Γ is a type environment, i.e. a finite list x1 : A1, . . . , xk : Ak. The rules of the proof system are the following:

Γ ` C : o Γ, x : A, Γ0 ` x : A

(14)

Γ, x : A ` M : B Γ ` λxA.M : A → B

Γ ` M : A → B Γ ` N : A Γ ` M N : B

where C ∈ {⊥, >}.

β-conversion. β-conversion between well-typed terms is the least relation gen- erated by the following rule and the rules for congruence closure (which we omit):

Γ ` (λxA.M )N = M [N/x] : B, where Γ, x : A ` M : B, and Γ ` N : A.

3.1 A Game Model

We define a game model for the λ-calculus of Definition 3.1 in the cartesian closed category K!(G). Simple types are interpreted by the hierarchy of games over the following Sierpinski Game (without questions/answers):

Definition 3.2 (Sierpinski Game) The game O is defined as follows:

• MO = {∗, a}

• λO(∗) = O λO(a) = P

• PO = {, ∗, ∗a}

• ≈O= idPO

The only two strategies on the Sierpinski Game are the empty strategy, which we denote by ⊥O, and the strategy >Oinduced by the partial function f>O(∗) = a. More in general, we denote by ⊥!A1⊗...⊗!Ak(O the empty strategy on !A1⊗ . . . ⊗!Ak ( O, and by >!A1⊗...⊗!Ak(Othe strategy induced by f>!A1⊗...⊗!Ak(O(hr, ∗i) = hr, ai.

Types are interpreted by games over the hierarchy on the Sierpinski game.

Terms in contexts are interpreted as strategies in the usual way, i.e. x1 : A1, . . . , xk : Ak ` M : A is interpreted as a strategy on the game ![[A1]]G ⊗ . . . ⊗![[Ak]]G ( [[A]]G using standard categorical combinators as follows:

Definition 3.3 (Term Interpretation)

• [[x1 : A1, . . . , xk : Ak` ⊥ : o]]G = ⊥

![[A1]]G⊗...⊗![[Ak]]G([[A]]G

• [[x1 : A1, . . . , xk : Ak` > : o]]G = >

![[A1]]G⊗...⊗![[Ak]]G([[A]]G

• [[x1 : A1, . . . , xk : Ak` xi : Ai]]G = πi :![[A1]]G⊗ . . . ⊗![[Ak]]G ( [[A]]G

(15)

• [[Γ ` λxA.M : A → B]]G = Λ([[Γ, x : A ` M : B]]G)

• [[Γ ` M N : B]]G = ev ◦ h[[Γ ` M : A → B]]G, [[Γ ` N : A]]Gi where πi denotes the i-th projection.

Notice that, by abuse of notation, we have used the same symbols A, B, . . . to denote simple types and the games interpreting them.

4 The Type Assignment System

In this section, we introduce and study a type assignment system, which gives a finitary description of the game model of Section 3.1. The types involved are essentially the standard intersection types, where the intuitionistic arrow is substituted by the linear arrow type constructor, and the structural rules are missing. Our approach to intersection types is “typed”, i.e. intersection types are built inductively over games. The usual untyped intersection semantics can be recovered as a special case of the typed case (see Section 6 below for more details). In our setting, types on a game A represent sets of Opponent and Proponent moves on A. The judgments derivable in our typing system are of the shape x1 : t!A1, . . . , xk : t!Ak ` M : t!A, whose intended meaning is to represent a set of equal number of Opponent and Proponent moves.

We will show that, for each Opponent move in such a set, there will be a corresponding Proponent answer such that the pair of moves belongs to the graph of the strategy interpreting the term.

4.1 Types and Environments

For each game A, we define the set of corresponding intersection types. At this stage, a type on A simply represents a set of moves on the game A. The intersection type constructor is used to represent sets of moves on exponential games, i.e. the moves appearing in each ∧-component correspond to moves in different components of the exponential game. This is why the ∧ constructor is not commutative neither associative nor idempotent. In Section 5, the exact correspondence between types and games is established.

Definition 4.1 (Types) We define a family of intesection type sets IntTypeA, by induction on the structure of the game A via the following abstract syntax:

• Types on Sierpinski game:

tO ::= cO | cO{∗} | cO{a} | cO{∗,a}

(16)

• Types on linear arrow games:

tA(B ::= tA ( tB

• Types on exponential games:

t!A ::= tA | t!A∧ t!A

In what follows, we use the symbols tA, uA, vAto denote elements in IntTypeA, and we simply write t in place of tA, when the game is irrelevant.

We use the symbols cA(B and c!A to denote, respectively, the types cA ( cB

and cA (which, in particular, is a type on !A). Moreover, we endow the set of types with the equivalence relation induced by cA = cA ∧ cA.

When related to game semantics, types represent sets of moves, in the sense presented by the following definitions. First, we define a subclass of types representing a single move. Informally, a single-move type is a type whose term structure contains a single instance of one of the two constant cO{a}, cO{∗}, while all the other instances of basic constants are in the form cA. We mark single-move types as Proponent or Opponent types, mimicking the usual game semantic definitions.

Definition 4.2 (Single-move Types) We distinguish between types where the only move is a Proponent move (pA) and types where the only move is an Opponent move (oA). The definition of the family of sets SingleTypeA, single-move types on A, is by induction on the game A:

pO ::= cO{a}

oO ::= cO{∗}

pA(B ::= cA ( pB | oA( cB

oA(B ::= cA ( oB | pA ( cB

p!A ::= pA | p!A∧ cA | cA ∧ p!A o!A::= oA | o!A∧ cA | cA ∧ o!A

In what follows, we will use the symbol mA to denote a single-move type pA or oA, indifferently.

Any intersection type can be seen as the union of single-move types by the following definition:

(17)

Definition 4.3 The family of functions SA: IntTypeA → ℘(SingleTypeA) are defined, with some abuse of notation, by induction as follows:

SA(cA) = ∅

SA(tA) = {tA} if tA∈ SingleTypeA SO(cO{∗,a}) = {cO{∗}, cO{a}}

SA(B(tA ( uB) = (cA ( SB(uB)) ∪ (SA(tA) ( cB) S!A(tA) = SA(tA)

S!A(t!A∧ u!A) = (cA ∧ S!A(u!A)) ∪ (S(t!A) ∧ cA)

where the symbols ( and ∧ on the righthand side of the equations denote the pointwise application of the corresponding constructors to a set.

As a curiosity, notice that, for any game A, the set {S(tA)|tA ∈ IntTypeA} is the set of finite elements of a coherent space built on a web having SingleTypeA as set of elements. The coherence relation on single-move types is related and similar to the compatible relation on indexes presented in Definition 2.8.

Loosely speaking, two single-move types are coherent if the corresponding expression trees are not included one into the other.

Given the above correspondence between types and sets of moves, it is natural, and for our purpose useful, to introduce on types some of the basic notions on sets.

Definition 4.4

• We say that a type tA contains the single-move type uA if uA∈ SA(tA).

• We define the cardinality of a type tA as the cardinality of the set SA(tA).

• We say that two types tAand uAare disjoint, if the sets SA(tA) and SA(uA) are disjoint.

• We define a family of partial union operations on types, {]A}A, ]A: IntTypeA→ IntTypeA, as follows:

tA1 ] tA2 =

uA if SA(tA1) ∪ SA(tA2) = SA(uA) undefined if there is no such a uA

If t ] u is defined, we say that t and u are compatible.

(18)

Notice that the union operations ]A are well-defined, since it is easy to check that, if the union of two single-move types correspond to an intersection type uA, then uA is unique. Alternatively, the partial union operations can be more explicitly characterized as follows:

Lemma 4.1 The operations ]A : IntTypeA→ IntTypeAare the least partially defined functions satisfying:

cOX ]OcOY = cOX∪Y

(tA1 ( tB2) ]A(B (uA1 ( uB2) = tA1 ]AuA1 ( tB2 ]BuB2 (t!A1 ∧ t!A2 ) ]!A(u!A1 ∧ u!A2 ) = (t!A1 ]!Au!A1 ) ∧ (t!A2 ]!Au!A2 ) Notice that, for any A, cA ] tA= tA.

To recover the history-free strategy corresponding to a term, it is useful to introduce a subclass of types consisting of exactly two moves, an Opponent move and a Proponent one. Namely, such types will represent pairs in the graph of a partial function describing a history-free strategy.

Definition 4.5 The Step types on the game A (StepTypeA) are the types that can be obtained as union of a Proponent and an Opponent single-move type:

sA::= pA] oA .

Lemma 4.2 Step types can be characterized by induction on games as follows:

sO ::= cO{∗,a}

sA(B ::= pA( pB | oA( oB | cA ( sB | sA( cB

s!A ::= sA | s!A∧ cA | cA∧ s!A | p!A∧ o!A | o!A∧ p!A

Definition 4.6 (Environments) • Let xA1, xA2, . . . be a list of variables with domains A1, A2, . . ., ranging over simple types.

Environments are lists defined by:

Γ, ∆ ::=  | xA: t!A, Γ1

where xA does not appear in Γ1 and, by abuse of notation, xA : t!A is used in place of xA: t![[A]]G.

We will simply write x in place of xA, when the game is irrelevant.

• Let dom(Γ) denote the list of variables in the domain of Γ, i.e., if Γ = [xA1 : t!A1, . . . , xAk : t!Ak], then dom(Γ) = [xA1, . . . , xAk].

(19)

• Let Γ denote a generic environment, where all types are c.

• Let Γ, Γ0 be contexts such that dom(Γ) = dom(Γ0). We define the disjoint union context Γ ] Γ0 (the intersection context Γ ∧ Γ0) as the pointwise ap- plication of the ] (∧) operation to the types in the contexts.

4.2 The Typing System

We introduce a typing system for deriving judgments of the shape x1 : t!A1, . . . , xk : t!Ak ` M : t!A, whose intended meaning is to represent a set of equal number of Opponent and Proponent moves. If the main connective of t!A is not ∧, then, for each Opponent move in such a set, there is a corresponding Proponent answer such that the pair of moves belongs to the graph of the strategy interpreting the term. The most informative judgments are those involving step types, where exactly two moves appear, an Opponent move and the Proponent answer. When the type contains more than two moves, we lose the exact matching between Opponent and Proponent moves. In principle, step types would be sufficient to recover the strategy interpreting the term in the game model, however, it is useful to consider general types in the type assignment system, because this simplifies the presentation of the rule for application.

Definition 4.7 (Typing System) The typing rules for deriving judgments xA1 : t!A1, . . . , xAk : t!Ak ` M : t!A are almost the standard ones, i.e.:

Γ ` C : cO (∅)

Γ ` > : cO{∗,a} (>)

Γ, xA: tA, ∆ ` xA: tA (var) Γ ` M : tA1 ∆ ` M : tA2

Γ ∧ ∆ ` M : tA1 ∧ tA2 (intersection) Γ, xA: u!A, ∆ ` M : tB tB not a ∧-type

Γ, ∆ ` λxA.M : u!A ( tB (abs) Γ ` M : uA( tB ∆ ` N : uA

Γ ∧ ∆ ` M N : tB (app)

where C ∈ {⊥, >} and a ∧-type is a type whose main constructor is ∧.

(20)

In what follows, we will simply drop game tags from variables and types in the judgments, when the game is not relevant.

In the rest of this section, we study basic properties of the typing system.

The following definition will be useful:

Definition 4.8

• The type associated to a judgement xA1 : t!A1, . . . , xAk : t!Ak ` M : t is the type of its curryfication i.e. the type t!A1 ( (. . . ( (t!Ak ( t) . . .)

• The cardinality of a judgment is the cardinality of the associated type.

• A step judgment is a judgment whose associated type is a step type.

• A ∧-judgment is a judgment Γ ` M : tA where A is a ∧-type, i.e. the main constructor of tA is ∧.

• A non-∧ judgment is a judgment that is not a ∧-judgment.

• Two judgments Γ ` M : t and Γ0 ` M : u are compatible ( disjoint) if their associated types are compatible (disjoint).

• We say that a judgment contains a single-move type tA if the associated type contains tA.

The single move types contained in the conclusion of a typing rule are inherited from the single-move types contained in the premises. However, when moving from a premise to the conclusion, a single-move type partly changes its term structure. For example, when applying the (app) rule to premises x : cC ` N : uA and x : tC ` M : uA( tB, where the latter contains the single-move type mC ( cA(B , we obtain a conclusion containing the single-move type mC ∧ cC ( cB. In the sequel of this paper, to avoid irrelevant details, we will be a little sloppy in the notation, and we denote with the same symbols single-move types appearing in premises and the corresponding single-move types in the conclusions.

Lemma 4.3 All judgments derivable in the typing system have even cardinal- ity. All derivable judgments contain equal number of Proponent and Opponent single-move types.

Proof. Straightforward, by induction on derivations. 

The following lemma collects a number of technical properties of the typing system. In particular, items (ii) and (iii) will be useful to prove Proposition 4.1 below, which expresses the fact that all derivable judgments can be “decom- posed” in step judgments. The most technical part of Lemma 4.4 below is item (v), which amounts to the counterpart in the typing system of the application between strategies as described in Section 2.2, Fig. 3.

(21)

Lemma 4.4

(i) If xA1 : t!A1 1, . . . , xAk : t!A1 k ` M : t1 and xA1 : t!A2 1, . . . , xAk : t!A2 k ` M : t2 are derivable non-∧ step judgments, containing the single-move types m1, m01 and m2, m02, respectively, then

• m1 = m2 iff m01 = m02.

• m1 is compatible with m2 if and only if m01 is compatible with m02.

(ii) For any set {Γi ` M : ti|i ∈ I} of pairwise compatible non-∧ step judg- ments, the judgment Ui∈IΓi ` M :Ui∈Iti is derivable.

(iii) For any derivable non-∧ judgment Γ ` M : t, there exist decompositions of t and Γ in types t1, . . . tn and environments Γ1, . . . , Γn such that t =Uiti, Γ =UiΓi, and Γi ` M : ti are derivable step judgments, for all i = 1, . . . , n.

(iv) Items (i)–(iii) hold also for ∧-judgments.

(v) Given any pair of judgments Γ ` M : u ( t and ∆ ` N : u, and any single-move type m contained in the judgment Γ ∧ ∆ ` M N : t, there exist a single-move type m0 contained in Γ ∧ ∆ ` M N : t and a chain of single-move types hujij∈J contained in u such that

• J is an interval of integers.

• If the chain is empty, then there exists a judgement either in the form Γ ` M : c ( t, or ∆ ` N : c, containing the single-move types m and m0.

• If the chain is non-empty, then

· either there exists a step judgment Γ1 ` M : u1 ( t1 containing m, and the first element in J is 1 or there exists a step judgement ∆0 ` N : u0 containing m, and the first element in J is 0.

· Γ ` M : (u2k ( c) ] (u2k+1 ( c), for all 2k, 2k + 1 ∈ J , k ≥ 0.

· ∆ ` N : u2k+1] u2k+2, for all 2k + 1, 2k + 2 ∈ J , k ≥ 0.

· Either there exists a step judgment Γ2k ` M : u2k ( t02k containing m0 and the last element in J is 2k or there exists a step judgement ∆2k+1 ` N : u2k+1 containing m0 and the last element in J is 2k + 1.

Proof. First we define the complexity of a term M as the number of con- structors appearing in it. The proof of items (i)–(v) is by induction on the complexity of the terms M and N .

Basic cases: M and N have complexity 1.

• The term M is a constant: items (i)–(iii) and (v) are trivial, since the only rules usable in the derivations are the rules (∅) and (>).

Riferimenti

Documenti correlati

This article proves a case of the p-adic Birch and Swinnerton–Dyer conjecture for Garrett p-adic L-functions of (Bertolini et al. in On p-adic analogues of the Birch and

Di Gianantonio, Lenisa (Udine) Innocent Game Semantics via ITAS CSL’13, Torino 21

trovare un tipo A tale che Gamma |- M : A sia valido l’analisi semantica risolve problemi di type inference:. nel codice definito il tipo

On one hand, we shall discuss the existence of hyperelliptic curves lying on the Jacobian variety - and a fortiori on the second symmetric product - of a generic curve by extending

Usually, this fact is proved by non-constructive techniques, althought a constructive proof, depending on the Principle of Uniform Boundedness can be found in [8]... This argument

Nella seconda parte sono state trattate le tecnologie emergenti per alcuni dei combustibili citati, riportando le tecniche per la riduzione degli inquinanti

One compound can have a higher affinity for the stationary phase with a particular mobile phase and will present a higher retention time than another metabolite with a lower

In fact, for the purpose of this study, I was given direct access to the workings of the Paoletti, Baroni & Baldi law firm in Pisa.. My thesis is divided into