Intersection types, introduced in the work of Coppo and Dezani [CD80, CDV81] and developed since then by many authors, are still a very active research topic. As quite clearly explained in [Kri93], the Coppo and Dezani intersection type system can be understood as a syntactic presentation of the denotational interpretation 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 implication with and conjunction as connectives. However, as pointed out by Hindley [Hin84], 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 typing 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 of premises, and not only on formulas proven in premises, 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 [LR07] for a discussion on several solutions which mainly focus on the design of à la Church presentations of intersection typing systems, thus enriching -terms with additional structures. Among the most recent and convincing contributions to this line of research we should certainly mention [LS19].
In our “new”111Not so new since it dates back to
our [BE01]. approach to this problem, we
change formulas instead of changing terms. It is based on a specific
model of Linear Logic (and thus of the -calculus): the
relational model222It is fair to credit Girard for the
introduction of this model since it appears at least implicitly
in [Gir88] . This model was probably known by many people in
the Linear Logic community as a piece of folklore since the early
1990’s. It is presented formally
. This model was probably known by many people in the Linear Logic community as a piece of folklore since the early 1990’s. It is presented formally in[BE01].. In this quite simple333As one can guess, there is a price to pay for this apparent simplicity: it is the relative complexity of the definition of morphism composition and of duplication, which take carefully multiplicities into account, see Section 2. 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 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 [dC09, dC18], 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 . Notice that the precise connection between the idempotent and non-idempotent approaches is analyzed in [Ehr11], in a quite general Linear Logic setting by means of an extensional collapse444This shows that, when one wants to “forget multiplicities” in the relational model, one needs to equip the sets interpreting types with a preorder relation..
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 and the type is interpreted as the set (where is the set of finite multisets of elements of ). 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 [FP91]) as we do in Section 3: an intersection type relative to the base type is an element of and an intersection type relative to is a pair where the s are intersection types relative to and is an intersection type relative to ; with more usual notations555That we prefer not to use for avoiding confusions between these two levels of typing. would be written . Then, given a type , the main idea consists in representing an indexed family of elements of as a formula of a new logical system. If then the family can be written666We use for denoting multisets much as one uses for denoting sets, the only difference is that multiplicities are taken into account. where and are indexing sets, is a function such that is finite for all , is a family of elements of (represented by a formula ) and is a family of elements of (represented by a formula ): in that case we introduce the implicative formula to represent the family . 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 (in an indexed version of intuitionistic logic) of formulas representing them. Such a correspondence is exhibited in Section 3 in the simply typed setting and the idea is quite simple:
given a type , a family of elements of , and a closed -term of type , it is equivalent to say that holds for all and to say that some (and actually any) formula representing has an proof777Any such proof can be stripped from its indexing data giving rise to a proof of in intuitionistic logic. whose underlying -term is .
In Section 4 we extend this approach to the untyped -calculus taking as underlying model of the pure -calculus the aforementioned relational version of Scott’s that we denote as : it is the least set which contains all -indexed sequences of finite multisets of elements such that is the empty multiset for almost all . We define an adapted version of and establish a similar correspondence, with some slight modifications due to the specificities of .
1 Notations and preliminary definitions
If is a set, a finite multiset of elements of is a function such that the set (called the domain of ) is finite. The cardinal of such a multiset is . We use for the obvious addition operation on multisets, and if are elements of , we use for the corresponding multiset (taking multiplicities into account); for instance is the multiset of elements of such that , , and for . If is a family of elements of and if is a finite subset of , we use for the multiset of elements of which maps to the number of elements such that (which is finite since is). We use for the set of finite multisets of elements of .
We use to denote set union when we we want to stress the fact that the invloved sets are disjoint. A function is almost injective if is finite for each (so the inverse image of any finite subset of under is finite). If is a sequence of elements of and , we use for the sequence . Given sets and , we use for the set of function from to . The elements of are sometimes considered as functions (with a functional notation for application) and sometimes as indexed families (with index notations for application) especially when is countable. The choice between these options should be clear from the context.
If and , we define as follows: if and if .
2 The relational model of the -calculus
Let the category whose objects are sets888We can restrict to countable sets. and with and composition of and given by
It is easily checked that this composition law is associative and that is neutral for composition999This results from the fact that arises as the Kleisli category of the LL model of sets and relations, see [BE01] for instance.. This category has all countable products: let be a countable family of sets, their product is and projections given by and if is a family of morphisms then their tupling is .
The category is cartesian closed with object of morphisms from to the set and evaluation morphism is given by . The transpose (or curryfication) of is given by .
Let be the least set such that as soon as are finite multisets of elements of which are almost all equal to . Notice in particular that and satisfies . By construction we have , that is and hence is a model of the pure -calculus in which also satisfies the -rule. See [BMR18] 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 ; types and terms are given as usual by and .
With any type atom we associate a set . This interpretation is extended to all types by . The relational semantics of this -calculus can be described as a non-idempotent intersection type system, with judgments of shape where the ’s are pairwise distinct variables, is a term, and for each . Here are the typing rules:
where , for and .
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 (where non-idempotent intersection types and are considered as logical formulas, the ordinary types playing the role of “kinds”) because, in the application rule above, it is required that all the proofs of the right hand side premises have the same shape given by the -term . We propose now a “logical system” derived from [BE01] 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.
We define now the syntax of indexed formulas. Assume to be given an infinite countable set of indices (one can take , but we use no specific properties or structures on natural numbers). Then we define indexed types ; with each such type we associate an underlying type , and a family . These formulas are given by the following inductive definition:
if and is a function then is a formula with , and
and if and are formulas and is almost injective then is a formula with , and, for , .
Let be a type, be a subset of and . There is a formula such that , and (actually, there are infinitely many such ’s as soon as is not an atom and ).
The proof is by induction on . If is an atom then we take . Assume that so that with and . Since each is finite and is infinite, we can find a family of pairwise disjoint finite subsets of such that . Let , there is a function such that for each (choose first an enumeration of for each and then define where is the unique element of such that ). Let be the unique function such that for all ; since each is finite, this function is almost injective. By inductive hypothesis there is a formula such that , and , and there is a formula such that , and . Then the formula is well formed (since is an almost injective function ) and satisfies , and as contended.
As a consequence, for any type and any element of (so is a non-idempotent intersection type of kind ), one can find a formula such that , (where is an arbitrary element of ) and . 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 “heriditary -equivalence”, this representation is unique).
For any formula and , we define a formula such that , and . The definition is by induction on .
where and .
Let be a bijection, we define a formula such that , and . The definition is by induction on :
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 intuitionistic logic. This logical system allows to derive sequents which are of shape
where for each , the function is almost injective. Notice that the expressions are not formulas; this construction is part of the syntax of sequents, just as the “” separating these pseudo-formulas. Given a formula and almost injective, it is nevertheless convenient to define by . In particular, when is a bijection, .
The crucial point here is that such a sequent (1) involves no -term.
The main difference between the original system of [BE01] and the present system is the way axioms are dealt with. In 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
and is a bijection
so that for , the function is empty. A special case is
and is the identity function
which may look more familiar, but the general axiom rule, allowing to “delocalize” the proven formula by an arbitrary bijection , is required as we shall see. The introduction rule is quite simple
Last the elimination rule is more complicated (from a Linear Logic point of view, this is due to the fact that it combines LL logical rules: elimination, contraction and promotion). We have the deduction
under the following conditions, to be satisfied by the involved formulas and functions: for each one has , , , , , and .
Let be a deduction tree of the sequent in this system. By dropping all index information we obtain a derivation tree of , and, upon choosing a sequence of pairwise distinct variables, we can associate with this derivation tree a simply typed -term which satisfies .
3.3 Basic properties of
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 is provable by a proof and let
be a formula such that . Then
is provable by a proof , where is obtained by
inserting at any place in
(where is obtained from by inserting a dummy
variable at the same place).
by inserting a dummy variable at the same place).
The proof is an easy induction on the proof of .
Lemma 2 (Relocation)
Let be a proof of let be a bijection, there is a proof of such that .
The proof is a straightforward induction on .
Lemma 3 (Restriction)
Let be a proof of and let . For , let and . Then the sequent has a proof such that .
By induction on . Assume that consists of an axiom with if , and a bijection. With the notations of the lemma, for and is a bijection . Moreover so that is obtained by an axiom with .
Assume that ends with a -introduction rule:
with , and we have . With the notations of the lemma we have . By inductive hypothesis there is a proof of such that and hence we have a proof of with as contended.
Assume last that ends with a -elimination rule:
with , and , and for , and of course . Let . Let and for (we also set , and ). By inductive hypothesis, we have a proof of such that and a proof of such that . Now, setting , observe that
since and , hence , and also .
It follows that , and, setting , we have and . Hence we have a proof of such that as contended.
Though substitution lemmas are usually trivial, the substitution lemma requires some care in its statement and proof101010We use notations introduced in Section 1..
Lemma 4 (Substitution)
Assume that with a proof and that, for some , with a proof . Then there is a proof of such that as soon as for each , for each with:
By induction on the proof .
Assume that is an axiom, so that there is a such that , is a bijection and for all . In that case we have . There are two subcases to consider. Assume first that . By Lemma 2 there is a proof of such that . We have and for , so that is a proof of , so we take and equation holds since . Assume next that , then and hence (and ) for . Therefore and for . So our target sequent can also be written and is provable by a proof such that as contended.
Assume now that is a -intro, that is and is