• Aucun résultat trouvé

Non-idempotent intersection types in logical form

N/A
N/A
Protected

Academic year: 2021

Partager "Non-idempotent intersection types in logical form"

Copied!
20
0
0

Texte intégral

(1)

HAL Id: hal-02346191

https://hal.archives-ouvertes.fr/hal-02346191v2

Submitted on 14 Dec 2020

HAL is a multi-disciplinary open access

archive for the deposit and dissemination of

sci-entific research documents, whether they are

pub-lished or not. The documents may come from

teaching and research institutions in France or

abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est

destinée au dépôt et à la diffusion de documents

scientifiques de niveau recherche, publiés ou non,

émanant des établissements d’enseignement et de

recherche français ou étrangers, des laboratoires

publics ou privés.

Non-idempotent intersection types in logical form

Thomas Ehrhard

To cite this version:

Thomas Ehrhard. Non-idempotent intersection types in logical form. Foundations of Software Science

and Computation Structures - 23rd International Conference, FOSSACS 2020, Held as Part of the

European Joint Conferences on Theory and Practice of Software, ETAPS 2020, Dublin, Ireland,

April 25-30, 2020, Apr 2020, Dublin, Ireland. pp.198-216, �10.1007/978-3-030-45231-5_11�.

�hal-02346191v2�

(2)

form

Thomas Ehrhard [B]

Université de Paris, IRIF, CNRS, F-75013 Paris, France ehrhard@irif.fr

https://www.irif.fr/ ehrhard/

Abstract. Intersection types are an essential tool in the analysis of oper-ational and denotoper-ational properties of lambda-terms and functional pro-grams. Among them, non-idempotent intersection types provide precise quantitative information about the evaluation of terms and programs. However, unlike simple or second-order types, intersection types cannot be considered as a logical system because the application rule (or the intersection rule, depending on the presentation of the system) involves a condition stipulating that the proofs of premises must have the same structure. Using earlier work introducing an indexed version of Linear Logic, we show that non-idempotent typing can be given a logical form in a system where formulas represent hereditarily indexed families of intersection types.

Keywords: Lambda Calculus · Denotational Semantics · Intersection Types · Linear Logic

Introduction

Intersection types, introduced in the work of Coppo and Dezani [4,5] and de-veloped since then by many authors, are still a very active research topic. As quite clearly explained in [13], the Coppo and Dezani intersection type system DΩ can be understood as a syntactic presentation of the denotational interpre-tation of λ-terms in the Engeler’s model, which is a model of the pure λ-calculus in the cartesian closed category of prime-algebraic complete lattices and Scott continuous functions.

Intersection types can be considered as formulas of the propositional calculus with implication ⇒ and conjunction ∧ as connectives. However, as pointed out by Hindley [12], intersection types deduction rules depart drastically from the standard logical rules of intuitionistic logic (and of any standard logical system) by the fact that, in the∧-introduction rule, it is assumed that the proofs of the two premises are typings of the same λ-term, which means that, in some sense made precise by the typing system itself, they have the same structure. Such requirements on proofs premises, and not only on formulas proven in premises,

(3)

are absent from standard (intuitionistic or classical) logical systems where the proofs of premises are completely independent from each other. Many authors have addressed this issue, we refer to [14] for a discussion on several solutions which mainly focus on the design of à la Church presentations of intersection typ-ing systems, thus enrichtyp-ing λ-terms with additional structures. Among the most recent and convincing contributions to this line of research we should certainly mention [15].

In our “new” approach to this problem — not so new actually since it dates back to [3] —, we change formulas instead of changing terms. It is based on a specific model of Linear Logic (and thus of the λ-calculus): the relational model. It is fair to credit Girard for the introduction of this model since it appears at least implicitly in [11]. It was probably known by many people in the Linear Logic community as a piece of folklore since the early 1990’s and is presented formally in [3]. In this quite simple and canonical denotational model, types are interpreted as sets (without any additional structure) and a closed term of type σ is interpreted as a subset of the interpretation of σ. It is quite easy to define, in this semantic framework, analogues of the usual models of the pure λ-calculus such as Scott’s D∞ or Engeler’s model, which in some sense

are simpler than the original ones since the sets interpreting types need not to be pre-ordered. As explained in the work of De Carvalho [6,7], the intersection type counterpart of this semantics is a typing system where “intersection” is non-idempotent (in sharp contrast with the original systems introduced by Coppo and Dezani), sometimes called system R. Notice that the precise connection between the idempotent and non-idempotent approaches is analyzed in [8], in a quite general Linear Logic setting by means of an extensional collapse.

In order to explain our approach, we restrict first to simple types, interpreted as follows in the relational model: a basic type α is interpreted as a given set JαK and the type σ ⇒ τ is interpreted as the set Mfin(JσK) × Jτ K (where Mfin(E) is

the set of finite multisets of elements of E). Remember indeed that intersection types can be considered as a syntactic presentation of denotational semantics, so it makes sense to define intersection types relative to simple types (in the spirit of [10]) as we do in Section3: an intersection type relative to the base type α is an element of JαK and an intersection type relative to σ ⇒ τ is a pair ([ a1, . . . , an], b)

where the ais are intersection types relative to σ and b is an intersection type

relative to τ ; with more usual notations1

([ a1, . . . , an], b) would be written (a1∧

· · · ∧ an) → b. Then, given a type σ, the main idea consists in representing

an indexed family of elements of JσK as a formula of a new logical system. If σ = (ϕ ⇒ ψ) then the family can be written2

([ ak| k ∈ K and u(k) = j ], bj)j∈J

where J and K are indexing sets, u : K → J is a function such that f−1({j}) is

finite for all j ∈ J, (bj)j∈Jis a family of elements of JψK (represented by a formula

B) and (ak)k∈K is a family of elements of JϕK (represented by a formula A): in

that case we introduce the implicative formula (A ⇒uB) to represent the family

1

That we prefer not to use for avoiding confusions between these two levels of typing.

2

We use [ · · · ] for denoting multisets much as one uses {· · · } for denoting sets, the only difference is that multiplicities are taken into account.

(4)

([ ak | k ∈ K and u(k) = j ], bj)j∈J. It is clear that a family of simple types has

generally infinitely many representations as such formulas; this huge redundancy makes it possible to establish a tight link between inhabitation of intersection types with provability of formulas representing them (in an indexed version LJ(I) of intuitionistic logic). Such a correspondence is exhibited in Section 3 in the simply typed setting and the idea is quite simple:

given a type σ, a family (aj)j∈J of elements of JσK, and a closed λ-term

of type σ, it is equivalent to say that ⊢ M : aj holds for all j and to

say that some (and actually any) formula A representing (aj)j∈J has an

LJ(I) proof3

whose underlying λ-term is M .

In Section 4 we extend this approach to the untyped λ-calculus taking as underlying model of the pure λ-calculus our relational version R∞of Scott’s D∞.

We define an adapted version of LJ(I) and establish a similar correspondence, with some slight modifications due to the specificities of R∞.

1

Notations and preliminary definitions

If E is a set, a finite multiset of elements of E is a function m : E → N such that the set{a ∈ E | m(a) 6= 0} (called the domain of m) is finite. The cardinal of such a multiset m is #m =P

a∈Em(a). We use + for the obvious addition

operation on multisets, and if a1, . . . , an are elements of E, we use [ a1, . . . , an]

for the corresponding multiset (taking multiplicities into account); for instance [ 0, 1, 0, 2, 1 ] is the multiset m of elements of N such that m(0) = 2, m(1) = 2, m(2) = 1 and m(i) = 0 for i > 2. If (ai)i∈I is a family of elements of E and if J

is a finite subset of I, we use [ ai| i ∈ J ] for the multiset of elements of E which

maps a ∈ E to the number of elements i ∈ J such that ai = a (which is finite

since J is). We use Mfin(E) for the set of finite multisets of elements of E.

We use + to denote set union when we we want to stress the fact that the involved sets are disjoint. A function u : J → K is almost injective if #u−1{k}

is finite for each k ∈ K (equivalently, the inverse image of any finite subset of K under u is finite). If s = (a1, . . . , an) is a sequence of elements of E and

i ∈ {1, . . . , n}, we use (s) \ i for the sequence (a1, . . . , ai−1, ai+1, . . . , an). Given

sets E and F , we use FE for the set of function from E to F . The elements of

FEare sometimes considered as functions u (with a functional notation u(e) for

application) and sometimes as indexed families a (with index notations ae for

application) especially when E is countable.

If i ∈ {1, . . . , n} and j ∈ {1, . . . , n − 1}, we define s(j, i) ∈ {1, . . . , n} as follows: s(j, i) = j if j < i and s(j, i) = j + 1 if j ≥ i.

3

Any such proof can be stripped from its indexing data giving rise to a proof of σ in intuitionistic logic.

(5)

2

The relational model of the λ-calculus

Let Rel!the category whose objects are sets4and Rel!(X, Y ) = P(Mfin(X) × Y )

with IdX = {([ a ], a) | a ∈ X} and composition of s ∈ Rel!(X, Y ) and t ∈

Rel!(Y, Z) given by

t ◦ s = {(m1+ · · · + mk, c) |

∃b1, . . . , bk ∈ Y ([ b1, . . . , bk], c) ∈ t and ∀j (mj, bj) ∈ s} .

It is easily checked that this composition law is associative and that Id is neutral for composition5

. This category has all countable products: let (Xj)j∈J be a

countable family of sets, their product is X = &j∈JXj = Sj∈J{j} × Xj and

projections (prj)j∈J given by prj = {([ (j, a) ], a) | a ∈ Xj} ∈ Rel!(X, Xj) and if

(sj)j∈J is a family of morphisms sj ∈ Rel!(Y, Xj) then their tupling is hsjij∈J =

{([ a ], (j, b))) | j ∈ J and ([ a ], b) ∈ sj} ∈ Rel!(Y, X).

The category Rel!is cartesian closed with object of morphisms from X to Y

the set (X ⇒ Y ) = Mfin(X)×Y and evaluation morphism Ev ∈ Rel!((X ⇒ Y ) &

X, Y ) is given by Ev = {([ (1, [ a1, . . . , ak], b), (2, a1), . . . , (2, ak) ], b) | a1, . . . , ak ∈

X and b ∈ Y }. The transpose (or curryfication) of s ∈ Rel!(Z & X, Y ) is

Cur(s) ∈ Rel!(Z, X ⇒ Y ) given by Cur(s) = {([ c1, . . . , cn], ([ a1, . . . , ak], b)) |

([ (1, c1), . . . , (1, cn), (2, a1), . . . , (2, ak) ], c) ∈ s}.

Relational D∞. Let R∞be the least set such that (m0, m1, . . . ) ∈ R∞ as soon

as m0, m1. . . are finite multisets of elements of R∞ which are almost all equal

to [ ]. Notice in particular that e = ([ ], [ ], . . . ) ∈ R∞ and satisfies e = ([ ], e).

By construction we have R∞ = Mfin(R∞) × R∞, that is R∞ = (R∞ ⇒ R∞)

and hence R∞is a model of the pure λ-calculus in Rel! which also satisfies the

η-rule. See [1] for general facts on this kind of model.

3

The simply typed case

We assume to be given a set of type atoms α, β, . . . and of variables x, y, . . . ; types and terms are given as usual by σ, τ, . . . := α | σ ⇒ τ and M, N, . . . := x | (M ) N | λxσN .

With any type atom we associate a set JαK. This interpretation is extended to all types by Jσ ⇒ τ K = JσK ⇒ Jτ K = Mfin(JσK) × Jτ K. The relational semantics of

this λ-calculus can be described as a non-idempotent intersection type system, with judgments of shape x1: m1: σ1, . . . , xn: mn: σn⊢ M : a : σ where the xi’s

are pairwise distinct variables, M is a term, a ∈ JσK and mi ∈ Mfin(JσiK) for

each i. Here are the typing rules: j 6= i ⇒ mj= [ ] and mi= [ a ]

(xi: mi : σi)ni=1⊢ xi: a : σ

Φ, x : m : σ ⊢ M : b : τ Φ ⊢ λxσM : (m, b) : σ ⇒ τ

4

We can restrict to countable sets.

5

This results from the fact that Rel!arises as the Kleisli category of the LL model of

(6)

Φ ⊢ M : ([ a1, . . . , ak], b) : σ ⇒ τ (Φl⊢ N : al: σ)kl=1

Ψ ⊢ (M ) N : b : τ

where Φ = (xi : mi : σi)ni=1, Φl = (xi : mli : σi)ni=1 for l = 1, . . . , k and

Ψ = (xi: mi+Pkl=1mli: σi)ni=1.

3.1 Why do we need another system?

The trouble with this deduction system is that it cannot be considered as the term decorated version of an underlying “logical system for intersection types” allowing to prove sequents of shape m1 : σ1, . . . , mn : σn ⊢ a : σ (where

non-idempotent intersection types mi and a are considered as logical formulas, the

ordinary types σi playing the role of “kinds”) because, in the application rule

above, it is required that all the proofs of the k right hand side premises have the same shape given by the λ-term N . We propose now a “logical system” derived from [3] which, in some sense, solves this issue. The main idea is quite simple and relies on three principles: (1) replace hereditarily multisets with indexed families in intersection types, (2) instead of proving single types, prove indexed families of hereditarily indexed types and (3) represent syntactically such families (of hereditarily indexed types) as formulas of a new system of indexed logic. 3.2 Minimal LJ(I)

We define now the syntax of indexed formulas. Assume to be given an infinite countable set I of indices. Then we define indexed types A; with each such type we associate an underlying type A, a set d(A) and a family hAi ∈ JAKd(A)

. These formulas are given by the following inductive definition:

– if J ⊆ I and f : J → JαK is a function then α[f ] is a formula with α[f ] = α, d(α[f ]) = J and hα[f ]i = f

– and if A and B are formulas and u : d(A) → d(B) is almost injective then A ⇒u B is a formula with A ⇒uB = A ⇒ B, d(A ⇒uB) = d(B) and, for

k ∈ d(B), hA ⇒uBik= ([ hAij | j ∈ d(A) and u(j) = k ], hBik).

Proposition 1. Let σ be a type, J be a subset of I and f ∈ JσKJ. There is a

formula A such that A = σ, d(A) = J and hAi = f (actually, there are infinitely many such A’s as soon as σ is not an atom and J 6= ∅).

Proof. The proof is by induction on σ. If σ is an atom α then we take A = α[f ]. Assume that σ = (ρ ⇒ τ ) so that f (j) = (mj, bj) with mj ∈ Mfin(JρK) and

bj∈ Jτ K. Since each mj is finite and I is infinite, we can find a family (Kj)j∈J of

pairwise disjoint finite subsets of I such that #Kj = #mj. Let K = Sj∈JKj,

there is a function g : K → JρK such that mj = [ g(k) | k ∈ Kj] for each j ∈ J

(choose first an enumeration gj : Kj → JρK of mj for each j and then define

g(k) = gj(k) where j is the unique element of J such that k ∈ Kj). Let u : K → J

(7)

this function u is almost injective. By inductive hypothesis there is a formula A such that A = ρ, d(A) = K and hAi = g, and there is a formula B such that B = τ , d(B) = J and hBi = (bj)j∈J. Then the formula A ⇒u B is well formed

(since u is an almost injective function d(A) = K → d(B) = J) and satisfies A ⇒uB = σ, d(A ⇒uB) = J and hA ⇒uBi = f as contended. ✷

As a consequence, for any type σ and any element a of JσK (so a is a non-idempotent intersection type of kind σ), one can find a formula A such that A = σ, d(A) = {j} (where j is an arbitrary element of I) and hAij= a. In other

word, any intersection type can be represented as a formula (in infinitely many different ways in general of course, but up to renaming of indices, that is, up to “hereditary α-equivalence”, this representation is unique).

For any formula A and J ⊆ I, we define a formula A↾J such that A↾J= A,

d(A↾J) = d(A) ∩ J and hA↾Ji = hAi ↾J. The definition is by induction on A.

– α[f ]↾J= α[f ↾J]

– (A ⇒uB)↾J= (A↾K ⇒vB↾J) where K = u−1(d(B) ∩ J) and v = u ↾K.

Let u : d(A) → J be a bijection (so that u(d(A)) = J), we define a formula u∗(A) such that u∗(A) = A, d(u∗(A)) = u(d(A)) and hu∗(A)ij = hAiu−1(j). The

definition is by induction on A: – u∗(α[f ]) = α[f ◦ u−1]

– u∗(A ⇒vB) = (A ⇒u◦v u∗(B)).

Using these two auxiliary notions, we can give a set of three deduction rules for a minimal natural deduction allowing to prove formulas in this indexed intu-itionistic logic. This logical system allows to derive sequents which are of shape

Au1

1 , . . . , Aunn⊢ B (1)

where for each i = 1, . . . , n, the function ui: d(Ai) → d(B) is almost injective (it

is not required that d(B) =Sn

i=1ui(d(Ai))). Notice that the expressions Auii are

not formulas; this construction Auis part of the syntax of sequents, just as the “,”

separating these pseudo-formulas. Given a formula A and u : d(A) → J almost injective, it is nevertheless convenient to definehAui ∈ M

fin(JAK)J byhAuij =

[ hAik | u(k) = j ]. In particular, when u is a bijection, hAuij = [ hAiu−1(j)].

The crucial point here is that such a sequent (1) involves no λ-term. The main difference between the original system LL(I) of [3] and the present system is the way axioms are dealt with. In LL(I) there is no explicit identity axiom and only “atomic axioms” restricted to the basic constants of LL; indeed it is well-known that in LL all identity axioms can be η-expanded, leading to proofs using only such atomic axioms. In the λ-calculus, and especially in the untyped λ-calculus we want to deal with in next sections, such η-expansions are hard to handle so we prefer to use explicit identity axioms.

The axiom is

j 6= i ⇒ d(Aj) = ∅ and ui is a bijection

Au1

(8)

so that for j 6= i, the function uj is empty. A special case is

j 6= i ⇒ d(Aj) = ∅ and ui is the identity function

Au1

1 , . . . , Aunn⊢ Ai

which may look more familiar, but the general axiom rule, allowing to “delocalize” the proven formula Ai by an arbitrary bijection ui, is required as we shall see.

The⇒ introduction rule is quite simple Au1

1 , . . . , Aunn, Au⊢ B

Au1

1 , . . . , Aunn⊢ A ⇒uB

Last the⇒ elimination rule is more complicated (from a Linear Logic point of view, this is due to the fact that it combines 3 LL logical rules: ⊸ elimination, contraction and promotion). We have the deduction

Cu1

1 , . . . , Cnun ⊢ A ⇒uB D1v1, . . . , Dvnn⊢ A

Ew1

1 , . . . , Ewnn⊢ B

under the following conditions, to be satisfied by the involved formulas and functions: for each i = 1, . . . , n one has d(Ci)∩d(Di) = ∅, d(Ei) = d(Ci)+ d(Di),

Ci= Ei↾d(Ci), Di= Ei↾d(Di), wi↾d(Ci)= ui, and wi ↾d(Di)= u ◦ vi.

Let π be a deduction tree of the sequent Au1

1 , . . . , Aunn ⊢ B in this system.

By dropping all index information we obtain a derivation tree π of A1, . . . , An ⊢

B, and, upon choosing a sequence −→x of n pairwise distinct variables, we can associate with this derivation tree a simply typed λ-term π→−x which satisfies

x1: A1, . . . , xn : An ⊢ π−→x : B.

3.3 Basic properties of LJ(I)

We prove some basic properties of this logical system. This is also the opportunity to get some acquaintance with it. Notice that in many places we drop the type annotations of variables in λ-terms, first because they are easy to recover, and second because the very same results and proofs are also valid in the untyped setting of Section 4.

Lemma 1 (Weakening). Assume that Φ ⊢ A is provable by a proof π and let B be a formula such that d(B) = ∅. Then Φ′ ⊢ A is provable by a proof π, where

Φ′ is obtained by inserting B0d(A) at any place in Φ. Moreover π

x = π′−→x′ (where

− →

x′ is obtained from −x by inserting a dummy variable at the same place).

The proof is an easy induction on the proof of Φ ⊢ A. Lemma 2 (Relocation). Let π be a proof of (Aui

i )ni=1⊢ A let u : d(A) → J be

a bijection, there is a proof π′ of (Au◦ui

i )ni=1⊢ u∗(A) such that π′−→x = π→−x.

The proof is a straightforward induction on π. Lemma 3 (Restriction). Let π be a proof of (Aui

i )ni=1 ⊢ A and let J ⊆ d(A).

For i = 1, . . . , n, let Ki= ui−1(J) ⊆ d(Ai) and ui′ = ui↾Ki : Ki → J. Then the

sequent ((Ai↾Ki)

u′ i)n

(9)

Proof. By induction on π. Assume that π consists of an axiom (Auj

j )nj=1⊢ ui∗(Ai)

with d(Aj) = ∅ if j 6= i, and ui a bijection. With the notations of the lemma,

Kj= ∅ for j 6= i and u′i is a bijection Ki→ J. Moreover u′i∗(Ai↾Ki) = ui∗(Ai)↾J

so that ((Ai↾Ki)

u′i)n

i=1⊢ A↾J is obtained by an axiom π′ with π′−→x = xi= π−→x.

Assume that π ends with a ⇒-introduction rule: ρ (Aui i ) n+1 i=1 ⊢ B (Aui i )ni=1⊢ An+1⇒un+1 B

with A = (An+1 ⇒un+1 B), and we have π→−x = λxn+1ρ−→x ,x

n+1. With the

no-tations of the lemma we have A↾J = (An+1↾Kn+1 ⇒u′n+1 B↾J). By inductive

hypothesis there is a proof ρ′of (A i↾u

′ i

Ki)

n+1

i=1 ⊢ B↾J such that ρ′→−x ,xn+1= ρ−→x ,xn+1

and hence we have a proof π′ of (A i↾u

′ i

Ki)

n

i=1⊢ A↾Jwith π′−→x = λxn+1ρ′−→x ,xn+1=

π−→x as contended.

Assume last that π ends with a ⇒-elimination rule: µ (Bvi i )ni=1⊢ B ⇒vA ρ (Cwi i )ni=1 ⊢ B (Aui i )ni=1⊢ A

with d(Ai) = d(Bi) + d(Ci), Bi = Ai↾d(Bi) and Ci = Ai↾d(Ci), ui↾d(Bi) = vi

and ui↾d(Ci) = v ◦ wi for i = 1, . . . , n, and of course π→−x =

 µ−→x



ρ−→x. Let

L = v−1(J) ⊆ d(B). Let L

i = vi−1(J) and Ri = wi−1(L) for i = 1, . . . , n (we

also set v′

i = vi↾Li, w

i= wi↾Ri and v

= v↾

L). By inductive hypothesis, we have

a proof µ′ of (B i↾v ′ i Li) n

i=1 ⊢ B↾L ⇒v′ A↾J such that µ′

x = µ−→x and a proof ρ ′ of (Ci↾w ′ i Ri) n

i=1⊢ B↾L such that ρ′−→x = ρ−→x. Now, setting Ki = ui−1(K), observe

that

– d(Bi) ∩ Ki= Li= d(Bi↾Li) and ui↾Li = v

i since ui↾d(Bi)= vi

– d(Ci) ∩ Ki= Ri= d(Ci) ∩ wi−1(L) since ui↾d(Ci)= v ◦ wi and L = v−1(J),

hence d(Ci) ∩ Ki = d(Ci↾Ri), and also ui↾Li = v

◦ w′ i.

It follows that d(Ai↾Ki) = Li+ Ri, and, setting u

′ i= ui↾Ki, we have u ′ i↾Li = v ′ i and u′ i↾Ri = v ′ ◦ w

i. Hence we have a proof π′ of (Ai↾u

′ i

Ki)

n

i=1 ⊢ A↾J such that

π′−→x =µ′−→x  ρ′→−x =  µ−→x  ρ−→x = π−→x as contended. ✷

Though substitution lemmas are usually trivial, the LJ(I) substitution lemma requires some care in its statement and proof6

. Lemma 4 (Substitution). Assume that (Auj

j )nj=1 ⊢ A with a proof µ and

that, for some i ∈ {1, . . . , n}, (Bvj

j )n−1j=1 ⊢ Ai with a proof ρ. Then there is a

proof π of (Cwj

j )n−1j=1 ⊢ A such that π(−→x)\i= µ−→x

h

ρ(−x)\i/xi

i

as soon as for each j = 1, . . . , n − 1, d(Cj) = d(As(j,i)) + d(Bj) for each j = 1, . . . , n − 1 (remember

that this requires also that d(As(j,i)) ∩ d(Bj) = ∅) with:

6

(10)

– Cj↾d(As(j,i))= As(j,i) and wj↾d(As(j,i))= us(j,i)

– Cj↾d(Bj)= Bj and wj↾d(Bj)= ui◦ vj.

Proof. By induction on the proof µ. Assume that µ is an axiom, so that there is a k ∈ {1, . . . , n} such that A = uk∗(Ak), uk is a bijection and d(Aj) = ∅ for all

j 6= k. In that case we have µ−→x = xk. There are two subcases to consider. Assume

first that k = i. By Lemma2 there is a proof ρ′ of (Bui◦vj

j )n−1j=1 ⊢ ui∗(Ai) such

that ρ′(−x)\i = ρ(−x)\i. We have Cj = Bj and wj = ui ◦ vj for j = 1, . . . , n − 1,

so that ρ′ is a proof of (Cwj

j )n−1j=1 ⊢ A, so we take π = ρ′ and equation π(−→x)\i=

µ−→x

h

ρ(−x)\i/xi

i

holds since µ−→x = xi. Assume next that k 6= i, then d(Ai) = ∅

and hence d(Bj) = ∅ (and vj = 0∅) for j = 1, . . . , n − 1. Therefore Cj = As(j,i)

and wj = vs(j,i) for j = 1, . . . , n − 1. So our target sequent (Cjwj)n−1j=1 ⊢ A can

also be written (Aus(j,i)

s(j,i)) n−1

j=1 ⊢ uk∗(Ak) and is provable by a proof π such that

π(−→x)\i= xk as contended.

Assume now that µ is a ⇒-intro, that is A = (An+1⇒un+1A

) and µ is θ (Auj j ) n+1 j=1 ⊢ A′ (Auj j )nj=1⊢ A

We set Bn = An+1↾∅ and of course vn+1 = 0d(A). Then we have a proof ρ′ of

(Bvj

j )nj=1⊢ Ai such that ρ′(−x)\i,xn+1 = ρ(−x)\i by Lemma 1. We set Cn= An+1

and wn = un+1. Then by inductive hypothesis applied to θ we have a proof

π0 of (Cwj

j )nj=1 ⊢ A′ which satisfies π0(−→x)\i,xn+1 = θ−→x ,xn+1

h

ρ(−x)\i/xi

i and applying a ⇒-introduction rule we get a proof π of (Cwj

j )n−1j=1 ⊢ A such that π(−→x)\i= λxn+1(θ→−x ,xn+1 h ρ(−x)\i/xi i ) = µ→−x h ρ(−x)\i/xi i as expected. Assume last that the proof µ ends with

ϕ (Esj j )nj=1⊢ E ⇒sA ψ (Ftj j )nj=1⊢ E (Auj j )nj=1⊢ A

with d(Aj) = d(Ej) + d(Fj), Aj↾d(Ej) = Ej, Aj↾d(Fj) = Fj, uj↾d(Ej) = sj

and uj↾d(Fj) = s ◦ tj, for j = 1, . . . , n. And we have µ−→x =

 ϕ−→x



ψ−→x. The

idea is to “share” the substituting proof ρ of (Bvj

j )nj=1 ⊢ Ai among ϕ and ψ

according to what they need, as specified by the formulas Eiand Fi. So we write

d(Bj) = Lj+Rjwhere Lj= vj−1(d(Ei)) and Rj= vj−1(d(Fi)) and by Lemma3

we have two proofs ρL of (B j↾ vL j Lj) n−1 j=1 ⊢ Ei and (Bj↾ vR j Rj) n−1 j=1 ⊢ Fi where we set vL j = vj↾Lj and v R

j = vj↾Rj, obtained from ρ by restriction. These proofs satisfy

ρL

(−→x)\i= ρ R

(11)

Now we want to apply the inductive hypothesis to ϕ and ρL, in order to get

a proof of the sequent (Gw

L j

j )n−1j=1 ⊢ E ⇒sA where Gj= Cj↾d(Es(j,i))+Lj (observe

indeed that d(Es(j,i)) ⊆ d(As(j,i)) and Lj ⊆ d(Bj) and hence are disjoint by our

assumption that d(Cj) = d(As(j,i)) + d(Bj)) and wjL = wj↾d(Es(j,i))+Lj. With

these definitions, and by our assumptions about Cj and wj, we have for all

j = 1, . . . , n − 1

Gj↾d(Es(j,i))= Cj↾d(As(j,i))↾d(Es(j,i))= As(j,i)↾d(Es(j,i))= Es(j,i)

wL

j↾d(Es(j,i))= wj↾d(As(j,i))↾d(Es(j,i))= us(j,i)↾d(Es(j,i))= ss(j,i)

Gj↾Lj = Cj↾d(Bj)↾Lj = Bj↾Lj

wL

j↾Lj = wj↾d(Bj)↾Lj = (ui ◦ vj)↾Lj = ui↾d(Ei)◦ v

L

j = si◦ vLj .

Therefore the inductive hypothesis applies yielding a proof ϕ′ of (GwLj

j )n−1j=1 ⊢

E ⇒sA such that ϕ′(−x)\i= ϕ−→x

h ρL (−→x)\i/xi i = ϕ−→x h ρ(−x)\i/xi i .

Next we want to apply the inductive hypothesis to ψ and ρR, in order to

get a proof of the sequent (Hrj

j )n−1j=1 ⊢ E where, for j = 1, . . . , n − 1, Hj =

Cj↾d(Fs(j,i))+Rj (again d(Fs(j,i)) ⊆ d(As(j,i)) and Rj ⊆ d(Bj) are disjoint by our

assumption that d(Cj) = d(As(j,i)) + d(Bj)) and rj is defined by rj↾d(Fs(j,i)) =

ts(j,i) and rj↾Rj = ti ◦ v

R

j. Remember indeed that vRj : Rj → d(Fi) and ti :

d(Fi) → d(E). We have

Hj↾d(Fs(j,i))= Cj↾d(As(j,i))↾d(Fs(j,i))= As(j,i)↾d(Fs(j,i))= Fs(j,i)

Hj↾Rj = Cj↾d(Bj)↾Rj = Bj↾Rj

and hence by inductive hypothesis there is a proof ψ′ of (Hrj

j )n−1j=1 ⊢ E such that ψ′ (−→x)\i= ψ−→x h ρR (−→x)\i/xi i = ψ−→x h ρ(−x)\i/xi i .

To end the proof of the lemma, it will be sufficient to prove that we can apply a ⇒-elimination rule to the sequents (Gw

L j

j )n−1j=1 ⊢ E ⇒s A and (Hjrj)n−1j=1 ⊢ E

in order to get a proof π of the sequent (Cwj

j )n−1j=1 ⊢ A. Indeed, the proof π

obtained in that way will satisfy π(−→x)\i =

 ϕ′(−x)\i  ψ′(−x)\i = µ−→x h ρ(−x)\i/xi i . Let j ∈ {1, . . . , n−1}. We have Cj↾d(Gj)= Gjand Cj↾d(Hj)= Hjsimply because

Gj and Hj are defined by restricting Cj. Moreover d(Gj) = d(Es(j,i)) + Lj and

d(Hj) = d(Fs(j,i)) + Rj. Therefore d(Gj) ∩ d(Hj) = ∅ and

d(Cj) = d(As(j,i)) + d(Bj) = d(Es(j,i)) + d(Fs(j,i)) + Lj+ Rj= d(Gj) + d(Hj) .

We have wj↾d(Gj)= w

L

j by definition of wLj as wj↾d(Es(j,i))+Lj. We have

wj↾d(Hj)↾d(Fs(j,i))= wj↾d(As(j,i))↾d(Fs(j,i))= us(j,i)↾d(Fs(j,i))

= s ◦ ts(j,i)= (s ◦ rj)↾d(Fs(j,i))

wj↾d(Hj)↾Rj = wj↾d(Bj)↾Rj = (ui◦ vj)↾Rj

(12)

and therefore wj↾d(Hj)= s ◦ rj as required. ✷

We shall often use the two following consequences of the Substitution Lemma. Lemma 5. Given a proof µ of (Auj

j )nj=1 ⊢ A and a proof ρ of Bv ⊢ Ai (for

some i ∈ {1, . . . , n}), there is a proof π of (Auj

j )i−1j=1, Bui◦v, (A uj j )nj=i+1 ⊢ A such that π−→x = µ x h ρ xi/xi i

Proof. By weakening we have a proof µ′ of (Auj

j )ij=1, B↾ 0d(A) ∅ , (A uj j )nj=i+1 ⊢ A such that µ′ −

x = µ(−x)\i+1 (where −→x is a list of pairwise distinct variables of

length n+1), as well as a proof ρ′of (A j↾ 0d(Ai) ∅ )ij=1, Bv, (Aj↾ 0d(Ai) ∅ )nj=i+1 ⊢ Aisuch that ρ′ − →x = ρx

i+1. By Lemma4, we have a proof π

of (Auj j )i−1j=1, Bui◦v, (A uj j )nj=i+1⊢ A which satisfies π′ (−→x)\i = µ′→−x h ρ′ (−→x)\i/xi i = µ−→x h ρ xi/xi i . ✷

Lemma 6. Given a proof µ of Av ⊢ B and a proof ρ of (Auj

j )nj=1 ⊢ A, there is a proof π of (Av◦uj j )nj=1⊢ B such that π−→x = µx h ρ→−x/x i . The proof is similar to the previous one.

If A and B are formulas such that A = B, d(A) = d(B) and hAi = hBi, we say that A and B are similar and we write A ∼ B. One fundamental property of our deduction system is that two formulas which represent the same family of intersection types are logically equivalent.

Theorem 1. If A ∼ B then AId

⊢ B with a proof π such that πx∼ηx.

Proof. Assume that A = α[f ], then we have B = A and AId

⊢ B is an axiom. Assume that A = (C ⇒u D) and B = (E ⇒v F ). We have D ∼ F and

hence DId

⊢ F with a proof ρ such that ρ

x ∼η x. And there is a bijection

w : d(E) → d(C) such that w∗(E) ∼ C and u ◦ w = v. By inductive hypothesis

we have a proof µ of w∗(E)Id⊢ C such that µy∼ηy, and hence using the axiom

Ew⊢ w

∗(E) and Lemma5we have a proof µ′ of Ew⊢ C such that µ′x= µx.

There is a proof π1 of (C ⇒ uD)

Id

, Cu⊢ D such that π1

x,y = (x) y (consider

the two axioms (C ⇒u D) Id , C↾0d(D) ∅ ⊢ C ⇒u D and (C ⇒u D)↾ 0d(C) ∅ , C Id ⊢ C and use a ⇒-elimination rule). So by Lemma 5 there is a proof π2 of (C ⇒

u D)Id , Eu◦w ⊢ D, that is of (C ⇒u D) Id , Ev ⊢ D, such that π2 x,y = (x) µy.

Applying Lemma6 we get a proof π3 of (C ⇒

uD)Id, Ev ⊢ F such that π3x,y=

ρzh(x) µy/zi. We get the expected proof π by a ⇒-introduction rule so that πx= λy ρ z h (x) µ y/z i . By inductive hypothesis πx∼η x. ✷

(13)

3.4 Relation between intersection types and LJ(I)

Now we explain the precise connection between non-idempotent intersection types and our logical system LJ(I). This connection consists of two statements: – the first one means that any proof of LJ(I) can be seen as a typing derivation

in non-idempotent intersection types (soundness)

– and the second one means that any non-idempotent intersection typing can be seen as a derivation in LJ(I) (completeness).

Theorem 2 (Soundness). Let π be a deduction tree of the sequent (Aui

i )ni=1⊢

B and −→x a sequence of n pairwise distinct variables. Then the λ-term π−→x

sat-isfies (xi: hAuiiij: Ai)ni=1 ⊢ π−→x : hBij : B in the intersection type system, for

each j ∈ d(B).

Proof. We prove the first part by induction on π (in the course of this induction, we recall the precise definition of π−→x). If π is the proof

q 6= i ⇒ d(Aq) = ∅ and ui is a bijection

(Auq

q )nq=1⊢ ui∗(Ai)

(so that B = ui∗(Ai)) then π−→x = xi. We have hA uq

q ij = [ ] if q 6= i, hAuiiij =

[ hAiiui−1(j)] and hui∗(Ai)ij= hAiiui−1(j). It follows that (xq : hA

uq

q ij : Aq)nq=1⊢

xi: hBij: B is a valid axiom in the intersection type system.

Assume that π is the proof

π0

Au1

1 , . . . , Aunn, Au⊢ B

Au1

1 , . . . , Aunn⊢ A ⇒uB

where π0is the proof of the premise of the last rule of π. By inductive hypothesis

the λ-term π0−→x ,x satisfies (xi : hAuiiij : Ai)ni=1, x : hAuij : A ⊢ π0−→x ,x: hBij : B

from which we deduce (xi: hAuiiij: Ai)ni=1⊢ λxAπ0−→x ,x: (hAuij, hBij) : A⇒ B

which is the required judgment since π→−x = λxAπ0−

x ,x and (hAuiiij, hBij) =

hA ⇒uBij as easily checked.

Assume last that π ends with π1 Cu1 1 , . . . , Cnun ⊢ A ⇒uB π2 Dv1 1 , . . . , Dvnn⊢ A Ew1 1 , . . . , Ewnn⊢ B

with: for each i = 1, . . . , n there are two disjoint sets Li and Ri such that

d(Ei) = Li+ Ri, Ci= Ei↾Li, Di= Ei↾Ri, wi↾Li= ui, and wi↾Ri= u ◦ vi.

Let j ∈ d(B). By inductive hypothesis, the judgment (xi: hCiuiij: Ci)ni=1 ⊢

π1−→x : hA ⇒uBij: A ⇒ B is derivable in the intersection type system. Let Kj=

(14)

each k ∈ Kj we have (xi : hDiuiik: Di)ni=1 ⊢ π2−→x : hAik : A . Now observe that

hA ⇒uBij = ([ hAik | k ∈ Kj], hBij) so that

(xi: hCiuiij+

X

k∈Kj

hDui

i ik: Ei)ni=1⊢ π1−→x π2−→x : hBij: B

is derivable in intersection types (remember that Ci = Di = Ei). Since π−→x =

π1−→x π2−→x it will be sufficient to prove that hEwi i ij= hCiuiij+ X k∈Kj hDvi i ik. (2)

For this, sincehEwi

i ij = [ hEiil| wi(l) = j ], consider an element l of d(Ei) such

that wi(l) = j. There are two possibilities: (1) either l ∈ Li and in that case we

know thathEiil= hCiilsince Ei↾Li= Ciand moreover we have ui(l) = wi(l) = j

(2) or l ∈ Ri. In that case we have hEiil = hDiil since Ei↾Ri = Di. Moreover

u(vi(l)) = wi(l) = j and hence vi(l) ∈ Kj. Therefore

[ hEiil| l ∈ Li and wi(l) = j ] = [ hCiil| ui(l) = j ] = hCiuiij [ hEiil| l ∈ Ri and wi(l) = j ] = [ hDiil| vi(l) ∈ Kj] = X k∈Kj hDvi i ik and (2) follows. ✷

Theorem 3 (Completeness). Let J ⊆ I. Let M be a λ-term and x1, . . . , xn

be pairwise distinct variables, such that (xi: mji : σi)ni=1 ⊢ M : bj: τ in the

intersection type system for all j ∈ J. Let A1, . . . , An and B be formulas and

let u1, . . . , un be almost injective functions such that ui : d(Ai) → J = d(B).

Assume also that Ai = σi for each i = 1, . . . , n and that B = τ . Last assume

that, for all j ∈ J, one has hBij = bj andhAuiiij = mji for i = 1, . . . , n. Then

the judgment (Aui

i )ni=1 ⊢ B has a proof π such that π→−x ∼ηM .

Proof. By induction on M . Assume first that M = xi for some i ∈ {1, . . . , n}.

Then we must have τ = σi, mjq = [ ] for q 6= i and m j

i = [ bj] for all j ∈ J.

Therefore d(Aq) = ∅ and uq is the empty function for q 6= i, ui is a bijection

d(Ai) → J and ∀k ∈ d(Ai) hAiik = bui(k), in other words ui∗(Ai) ∼ B. By

Theorem1we know that the judgment (ui∗(Ai)) Id

⊢ B is provable in LJ(I) with a proof ρ such that ρx ∼η x. We have a proof θ of (Auii)ni=1 ⊢ ui∗(Ai) which

consists of an axiom so that θ−→x = xi and hence by Lemma6we have a proof π

of (Aui

i )ni=1⊢ B such that π−→x = ρx[θ−→x/x] ∼η xi.

Assume that M = λxσN , that τ = (σ ⇒ ϕ) and that we have a

fam-ily of deductions (for j ∈ J) of (xi: mji : σi)ni=1 ⊢ M : (mj, cj) : σ ⇒ ϕ with

bj = (mj, cj) and the premise of this conclusion in each of these deductions is

(xi : mji : σi)ni=1, x : mj: σ ⊢ N : cj : ϕ. We must have B = (C ⇒u D) with

(15)

[ hCik | k ∈ d(C) and u(k) = j ] = mj, that is hCuij = mj, for each j ∈ J.

By inductive hypothesis we have a proof ρ of (Aui

i )ni=1, Cu ⊢ D such that

ρ−→x ,x ∼η N from which we obtain a proof π of (Auii)ni=1 ⊢ C ⇒u D such that

π−→x = λxσρ

x ,x∼ηM as expected.

Assume last that M = (N ) P and that we have a J-indexed family of deduc-tions (xi: mji : σi)ni=1 ⊢ M : bj: τ . Let A1, . . . , An, u1, . . . , un and B be LJ(I)

formulas and almost injective functions as in the statement of the theorem. Let j ∈ J. There is a finite set Lj ⊆ I and multisets mj,0i , (m

j,l

i )l∈Lj such

that we have deductions7

of (xi: mj,0i : σi)ni=1 ⊢ N : ([ a j

l | l ∈ Lj], bj) : σ ⇒ τ

and, for each l ∈ Lj, of (xi: mj,li : σi)ni=1⊢ P : a j

l : σ with

mji = mj,0i +X

l∈Lj

mj,li . (3)

We assume the finite sets Lj to be pairwise disjoint (this is possible because I

is infinite) and we use L for their union. Let u : L → J be the function which maps l ∈ L to the unique j such that l ∈ Lj, this function is almost injective.

Let A be an LL(J) formula such that A = σ, d(A) = L and hAil= a u(l) l ; such a

formula exists by Proposition1.

Let i ∈ {1, . . . , n}. For each j ∈ J we know that [ hAiir| r ∈ d(Ai) and ui(r) = j ] = mji = m j,0 i + X l∈Lj mj,li

and hence we can split the set d(Ai) ∩ ui−1({j}) into disjoint subsets Rj,0i and

(Rj,li )l∈Lj in such a way that

[ hAiir| r ∈ Rj,0i ] = m j,0 i and ∀l ∈ Lj [ hAiir| r ∈ Rj,li ] = m j,l i . We set R0 i = S j∈JR j,0

i ; observe that this is a disjoint union because R j,0 i ⊆ ui−1({j}). Similarly we define Ri1 = S l∈LR u(l),l

i which is a disjoint union for

the following reason: if l, l′ ∈ L satisfy u(l) = u(l′) = j then Rj,l i and R

j,l′ i

have been chosen disjoint and if u(l) = j and u(l′) = j′ with j 6= j′ we have Rij,l⊆ ui−1{j} and Rj

,l′

i ⊆ ui−1({j′}). Let vi : R1i → L be defined by: vi(r) is

the unique l ∈ L such that r ∈ Ru(l),li . Since each Rj,li is finite the function vi is

almost injective. Moreover u ◦ vi= ui↾R1 i.

We use u′

i for the restriction of ui to R0i so that u′i : R0i → J. By

induc-tive hypothesis we have ((Ai↾R0 i)

u′i)n

i=1 ⊢ A ⇒u B with a proof µ such that

µ−→x ∼η N . Indeed [ hAi↾R0 iir| r ∈ R 0 i and u′i(r) = j ] = m j,0 i and hA ⇒u Bij =

([ ajl | u(l) = j ], bj) for each j ∈ J. For the same reason we have ((Ai↾R1 i)

vi)n

i=1⊢

A with a proof ρ such that ρ−→x ∼η P . Indeed for each l ∈ L = d(A) we have

7

Notice that our λ-calculus is in Church style and hence the type σ is uniquely determined by the sub-term N of M .

(16)

[ hAi↾R1

iir| vi(r) = l ] = m

j,l

i and hAil = ajl where j = u(l). By an application

rule we get a proof π of (Aui

i )ni=1⊢ B such that π−→x =

 µ−→x



ρ−→x ∼η(N ) P = M

as contended. ✷

4

The untyped Scott case

Since intersection types usually apply to the pure λ-calculus, we move now to this setting by choosing in Rel!the set R∞as model of the pure λ-calculus. The

Rintersection typing system has the elements of R∞ as types, and the typing

rules involve sequents of shape (xi: mi)ni=1 ⊢ M : a where mi∈ Mfin(R∞) and

a ∈ R∞.

We use Λ for the set of terms of the pure λ-calculus, and ΛΩ as the pure

λ-calculus extended with a constant Ω subject to the two following ❀ωreduction

rules: λx Ω ❀ωΩ and (Ω) M ❀ωΩ. We use ∼ηωfor the least congruence on ΛΩ

which contains ❀ηand ❀ωand similarly for∼βηω. We define a family (H(x))x∈V

of subsets of ΛΩminimal such that, for any sequence −→x = (x1, . . . , xn) and −→y =

(y1, . . . , yk) such that −→x , −→y is repetition-free, and for any terms Mi∈ H(xi) (for

i = 1, . . . , n), one has λ−→x λ−→y (x) M1· · · MnO1· · · Ol ∈ H(x) where Oj ∼ω Ω

for j = 1, . . . , l. Notice that x ∈ H(x). The typing rules of R∞ are

x1: [ ], . . . , xi: [ a ], . . . , xn : [ ] ⊢ xi : a Φ, x : m ⊢ M : a Φ ⊢ λx M : (m, a) Φ ⊢ M : ([ a1, . . . , ak], b) (Φj ⊢ N : aj)kj=1 Φ +Pk j=1Φj ⊢ (M ) N : b

where we use the following convention: when we write Φ + Ψ it is assumed that Φ is of shape (xi : mi)ni=1 and Ψ is of shape (xi : pi)ni=1, and then Φ + Ψ is

(xi : mi+ pi)ni=1. This typing system is just a “proof-theoretic” rephrasing of the

denotational semantics of the terms of ΛΩ in R∞.

Proposition 2. Let M, M′∈ Λ

Ωand −→x = (x1, . . . , xn) be a list of pairwise

dis-tinct variables containing all the free variables of M and M′. Let m

i∈ Mfin(R∞)

for i = 1, . . . , n and b ∈ R∞. If M ∼βηω M′ then (xi: mi)ni=1 ⊢ M : b iff

(xi : mi)ni=1⊢ M′: b.

4.1 Formulas

We define the associated formulas as follows, each formula A being given together with d(A) ⊆ I and hAi ∈ Rd∞(A).

– If J ⊆ I then εJ is a formula with d(εJ) = J and hεJij= e for j ∈ J

– and if A and B are formulas and u : d(A) → d(B) is almost injective then A ⇒u B is a formula with d(A ⇒u B) = d(B) and hA ⇒u Bij =

(17)

We can consider that there is a type o of pure λ-terms interpreted as R∞ in

Rel!, such that (o ⇒ o) = o, and then for any formula A we have A = o.

Operations of restriction and relocation of formulas are the same as in Sec-tion 3 (setting εJ↾K = εJ∩K) and satisfy the same properties, for instance

hA↾Ki = hAi↾K and one sets u∗(εJ) = εK if u : J → K is a bijection.

The deduction rules are exactly the same as those of Section3, plus the axiom ⊢ ε∅. With any deduction π of (Auii)ni=1 ⊢ B and sequence −→x = (x1, . . . , xn) of

pairwise distinct variables, we can associate a pure π−→x ∈ ΛΩ defined exactly as

in Section3(just drop the types associated with variables in abstractions). If π consists of an instance of the additional axiom, we set π−→x = Ω.

Lemma 7. Let A, A1, . . . , An be a formula such that d(A) = d(Ai) = ∅. Then

(A0∅

i )ni=1⊢ A is provable by a proof π which satisfies πx1,...,xk∼ωΩ.

The proof is a straightforward induction on A using the additional axiom, Lemma1 and the observations that if d(B ⇒uC) = ∅ then u = 0∅.

One can easily define a size function sz : R∞ → N such that sz(e) = 0 and

sz([ a1, . . . , ak], a) = sz(a) +Pki=1(1 + sz(ai)). First we have to prove an adapted

version of Proposition1; here it will be restricted to finite sets. Proposition 3. Let J be a finite subset of I and f ∈ RJ

∞. There is a formula

A such that d(A) = J and hAi = f .

Proof. Observe that, since J is finite, there is an N ∈ N such that ∀j ∈ J ∀q ∈ N q ≥ N ⇒ f (j)q = [ ] (remember that f (j) ∈ Mfin(R)N

). Let N (f ) be the least such N . We set sz(f ) = P

j∈Jsz(f (j)) and the proof is by induction on

(sz(f ), N (f )) lexicographically.

If sz(f ) = 0 this means that f (j) = e for all j ∈ J and hence we can take A = εJ. Assume that sz(f ) > 0, one can write8 f (j) = (mj, aj) with

mj ∈ Mfin(R∞) and aj∈ R∞for each j ∈ J. Just as in the proof of Proposition1

we choose a set K, a function g : K → R∞ and an almost injective function

u : K → J such that mj = [ g(k) | u(k) = j ]. The set K is finite since J is

and we have sz(g) < sz(f ) because sz(f ) > 0. Therefore by inductive hypothesis there is a formula B such that d(B) = K and hBi = g. Let f′: J → R

∞defined

by f′(j) = a

j, we have sz(f′) ≤ sz(f ) and N (f′) < N (f ) and hence by inductive

hypothesis there is a formula C such that hCi = f . We set A = (B ⇒uC) which

satisfieshAi = f as required.

Theorem1 still holds up to some mild adaptation. First notice that A ∼ B simply means now that d(A) = d(B) and hAi = hBi.

Theorem 4. If A and B are such that A ∼ B then AId

⊢ B with a proof π which satisfies πx∈ H(x).

8

(18)

Proof. By induction on the sum of the sizes of A and B. Assume that A = εJ

so that d(B) = J and ∀j ∈ J hBij = e. There are two cases as to B. In the

first case B is of shape εK but then we must have K = J and we can take for

π an axiom so that πx = x ∈ H(x). Otherwise we have B = (C ⇒u D) with

d(D) = J, ∀j ∈ J hDij = e and d(C) = ∅, so that u = 0J. We have A ∼ D and

hence by inductive hypothesis we have a proof ρ of AId

⊢ D such that ρx∈ H(x). By weakening and ⇒-introduction we get a proof π of AId

⊢ B which satisfies πx= λy ρx∈ H(x).

Assume that A = (C ⇒uD). If B = εJthen we must have d(C) = ∅, u = 0J

and D ∼ B and hence by inductive hypothesis we have a proof ρ of DId

⊢ B such that ρx∈ H(x). By Lemma7 there is a proof θ of ⊢ C such that θ ∼ω Ω.

Hence there is a proof π of AId

⊢ B such that πx= ρ

y[(x) θ/y] ∈ H(x).

Assume last that B = (E ⇒vF ), then we must have D ∼ F and there must

be a bijection w : d(E) → d(C) such that u ◦ w = v and w∗(E) ∼ C. We reason

as in the proof of Lemma1: by inductive hypothesis we have a proof ρ of DId

⊢ F and a proof µ of w∗(E)Id ⊢ C from which we build a proof π of AId ⊢ B such

that πx= λy ρzh(x) µy/zi∈ H(x) by inductive hypothesis. ✷ Theorem 5 (Soundness). Let π be a deduction tree of Au1

1 , . . . , Aunn ⊢ B and

x a sequence of n pairwise distinct variables. Then the λ-term π

x ∈ ΛΩsatisfies

(xi : hAuiiij)i=1n ⊢ π→−x : hBij in the R∞ intersection type system, for each j ∈

d(B).

The proof is exactly the same as that of Theorem2, dropping all simple types. For all λ-term M ∈ Λ, we define HΩ(M ) as the least subset of element of

ΛΩ such that:

– if O ∈ ΛΩ and O ∼ωΩ then O ∈ HΩ(M ) for all M ∈ Λ

– if M = x then H(x) ⊆ HΩ(M )

– if M = λy N and N′∈ H

Ω(N ) then λy N′∈ HΩ(M )

– if M = (N ) P , N′ ∈ H

Ω(N ) and P′∈ HΩ(P ) then (N′) P′ ∈ HΩ(M ).

The elements ofHΩ(M ) can probably be seen as approximates of M .

Theorem 6 (Completeness). Let J ⊆ I be finite. Let M ∈ ΛΩ and x1, . . . , xn

be pairwise distinct variables, such that (xi: mji)ni=1 ⊢ M : bj in the R∞

inter-section type system for all j ∈ J. Let A1, . . . , An and B be formulas and let

u1, . . . , un be almost injective functions such that ui : d(Ai) → J = d(B).

As-sume also that, for all j ∈ J, one has hBij= bj andhAuiiij= mji for i = 1, . . . , n.

Then the judgment Au1

1 , . . . , Aunn⊢ B has a proof π such that π−→x ∈ HΩ(M ).

The proof is very similar to that of Theorem3.

5

Concluding remarks and acknowledgments

The results presented in this paper show that, at least in non-idempotent inter-section types, the problem of knowing whether all elements of a given family of

(19)

intersection types (aj)j∈J are inhabited by a common λ-term can be

reformu-lated logically: is it true that one (or equivalently, any) of the indexed formulas A such that d(A) = J and ∀j ∈ hAij = aj is provable in LJ(I)? Such a strong

con-nection between intersection and Indexed Linear Logic was already mentioned in the introduction of [2], but we never made it more explicit until now.

To conclude we propose a typed λ-calculus à la Church to denote proofs of the LJ(I) system of Section 4. The syntax of pre-terms is given by s, t . . . := x[J] | λx : Aus | (s) t where in x[J], x is a variable and J ⊆ I and, in λx : Aus,

u is an almost injective function from d(A) to a set J ⊆ I. Given a pre-term s and a variable x, the domain of x in s is the subset dom(x, s) of I given by dom(x, x[J]) = J, dom(x, y[J]) = ∅ if y 6= x, dom(x, λy : Aus) = dom(x, s)

(assuming of course y 6= x) and dom(x, (s) t) = dom(x, s) ∪ dom(x, t). Then a pre-term s is a term if any subterm of t which is of shape (s1) s2 satisfies

dom(x, s1)∩dom(x, s2) = ∅ for all variable x. A typing judgment is an expression

(xi : Auii)ni=1 ⊢ s : B where the xi’s are pairwise distinct variables, s is a term

and each uiis an almost injective function d(Ai) → d(B). The following typing

rules exactly mimic the logical rules of LJ(I): d(A) = ∅ ((xi: A0i∅)ni=1) ⊢ Ω : A

q 6= i ⇒ d(Ai) = ∅ and ui bijection

(xq : Auqq)nq=1⊢ xi[d(Ai)] : ui∗(Ai)

(xi: Auii)ni=1, x : Au⊢ s : B

(xi: Auii)ni=1⊢ λx : Aus : A ⇒uB

(xi: Ai↾vdomi (xi,s))ni=1 ⊢ s : A ⇒uB (xi: Ai↾wdomi (xi,t))ni=1⊢ t : A

(xi: Avii+(u◦wi))ni=1⊢ (s) t : B

The properties of this calculus, and more specifically of its β-reduction, and its connections with the resource calculus of [9] will be explored in further work.

Another major objective will be to better understand the meaning of LJ(I) formulas, using ideas developed in [3] where a phase semantics is introduced and related to (non-uniform) coherence space semantics. In the intuitionistic present setting, it is tempting to look for Kripke-like interpretations with the hope of generalizing indexed logic beyond the (perhaps too) specific relational setting we started from.

Last, we would like to thank Luigi Liquori and Claude Stolze for many helpful discussions on intersection types and the referees for their careful reading and insightful comments and suggestions.

References

1. F. Breuvart, G. Manzonetto, and D. Ruoppolo. Relational graph models at work. Logical Methods in Computer Science, 14(3), 2018.

2. A. Bucciarelli and T. Ehrhard. On phase semantics and denotational semantics in multiplicative-additive linear logic. Annals of Pure and Applied Logic, 102(3):247– 282, 2000.

(20)

3. A. Bucciarelli and T. Ehrhard. On phase semantics and denotational semantics: the exponentials. Annals of Pure and Applied Logic, 109(3):205–241, 2001. 4. M. Coppo and M. Dezani-Ciancaglini. An extension of the basic functionality

theory for the λ-calculus. Notre Dame Journal of Formal Logic, 21(4):685–693, 1980.

5. M. Coppo, M. Dezani-Ciancaglini, and B. Venneri. Functional characters of solv-able terms. Mathematical Logic Quarterly, 27(2-6):45–58, 1981.

6. D. de Carvalho. Execution time of lambda-terms via denotational semantics and intersection types. CoRR, abs/0905.4251, 2009.

7. D. de Carvalho. Execution time of λ-terms via denotational semantics and inter-section types. MSCS, 28(7):1169–1203, 2018.

8. T. Ehrhard. The Scott model of linear logic is the extensional collapse of its relational model. Theoretical Computer Science, 424:20–45, 2012.

9. T. Ehrhard and L. Regnier. Uniformity and the Taylor expansion of ordinary lambda-terms. Theoretical Computer Science, 403(2-3):347–372, 2008.

10. T. S. Freeman and F. Pfenning. Refinement Types for ML. In D. S. Wise, editor, Proceedings of the ACM SIGPLAN’91 Conference on Programming Language De-sign and Implementation (PLDI), Toronto, Ontario, Canada, June 26-28, 1991, pages 268–277. ACM, 1991.

11. J.-Y. Girard. Normal functors, power series and the λ-calculus. Annals of Pure and Applied Logic, 37:129–177, 1988.

12. J. R. Hindley. Coppo-dezani types do not correspond to propositional logic. The-oretical Computer Science, 28:235–236, 1984.

13. J.-L. Krivine. Lambda-Calculus, Types and Models. Ellis Horwood Series in Com-puters and Their Applications. Ellis Horwood, 1993. Translation by René Cori from French 1990 edition (Masson).

14. L. Liquori and S. R. D. Rocca. Intersection-types à la Church. Information and Computation, 205(9):1371–1386, 2007.

15. L. Liquori and C. Stolze. The Delta-calculus: Syntax and Types. In H. Geu-vers, editor, 4th International Conference on Formal Structures for Computation and Deduction, FSCD 2019, June 24-30, 2019, Dortmund, Germany., volume 131 of LIPIcs, pages 28:1–28:20. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2019.

Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.

The images or other third party material in this chapter are included in the chapter’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.

Références

Documents relatifs

In this paper, we have proposed a new approach to prove Lyapunov stability of a non-linear discrete- time system in a given neighbourhood [x 0 ], regardless of the

We note that a generalization of Theorem 2.2 is essentially stated in The- orem 2.6. In [8] the authors investigated idempotent uninorms, which are as- sociative, commutative,

In this example we adapt for counts-as conditionals and institutional constraints a proposal of Jones and Sergot, and for obligations and permissions we adapt the input/output

Following [7], Chomsky assumes that the analysis of a sentence is driven by the verb which goes by two specific states: the phases VP and cP.. Note that neither tP nor the

Course 4: Resource Calculi inspired from MELL PN Course 5: Non-Idempotent Intersection Types Exam: 15 December 2021. or

The inhabitation problem for intersection types has been proved to be undecidable, but breaking the idempotency of intersection types makes

showing how filters of intersection types can be used to produce models of various source typing systems; [CS07] provides a modular proof that λ-terms that are typable in

We present a typing system with non-idempotent intersection types, typing a term syntax covering three different calculi: the pure λ-calculus, the calculus with explicit