1 Introduction
Intersection type theories were first introduced as a form of ad hoc polymorphism in (pure) calculi à la Curry. The paper by Barendregt, Coppo, and Dezani [4] is a classic reference, while [5] is a definitive reference.
Intersection type assignment systems have been wellknown in the literature for almost 40 years for many reasons: among them, characterization of strongly normalizing terms [5], models [1], automatic type inference [26], type inhabitation [43, 37], type unification [17]. As intersection had its classical development for type assignment systems, many papers tried to find an explicitly typed calculus à la Church corresponding to the original intersection type assignment systems à la Curry. The programming language Forsythe, by Reynolds [38]
, is probably the first reference, while Pierce’s Ph.D. thesis
[33] combines also unions, intersections and bounded polymorphism. In [45] intersection types were used as a foundation for typed intermediate languages for optimizing compilers for higherorder polymorphic programming languages; implementations of typed programming language featuring intersection (and union) types can be found in SMLCIDRE [14] and in StardustML [18, 19].Annotating pure terms with intersection types is not simple: a classical example is the difficulty to decorate the bound variable of the explicitly typed polymorphic identity such that the type of the identity is : previous attempts showed that the full power of the intersection type discipline can be easily lost.
In this paper, we define and prove the main properties of the calculus, a generic intersection typed system for an explicitly typed calculus à la Church enriched with strong pairs, denoted by , projections, denoted by , and type coercions, denoted by .
A strong pair is a special kind of cartesian product such that the two parts of a pair satisfies a given property on their “essence”, that is .
An essence of a term is a pure term obtained by erasing type decorations, projections and choosing one of the two elements inside a strong pair. As examples,
and so on. Therefore, the essence of a term is its untyped skeleton: a strong pair can be typechecked if and only if is verified, otherwise the strong pair will be illtyped. The essence also gives the exact mapping between a term and its typing à la Church and its corresponding term and type assignment à la Curry. Changing the parameters and results in defining a totally different intersection typed system. For the purpose of this paper, we study the four wellknown intersection type theories , namely CoppoDezani [11], CoppoDezaniSallé [12], CoppoDezaniVenneri [13] and BarendregtCoppoDezani [4]. We will inspect the above type theories using three equivalence relations on pure terms, namely and .
The combination of the above and allows to define ten meaningful typed systems for the calculus that can be pictorially displayed in a “chair” (see Definition 2.2). Following the same style as in the Barendrengt et al. book [5], the edges in the chair represent an inclusion relation over the set of derivable judgments.
A type coercion is a term of type whose typedecoration denotes an application of a subsumption rule to the term of type such that : if we omit type coercions, then we lose the uniqueness of type property.
Section 3 shows a number of typable examples in the systems presented in the chair: each example is provided with a corresponding type assignment derivation of its essence. Some historical examples of Pottinger [36], Hindley [23] and BenYelles [6] are essentially redecorated and inhabited (when possible) in the calculus. The aims of this section is both to make the reader comfortable with the different intersection typed systems, and to give a first intuition of the correspondence between Churchstyle and Currystyle calculi.
Section 4 proves the metatheory for all the systems in the chair: ChurchRosser, unicity of type, subject reduction, strong normalization, decidability of type checking and type reconstruction and studies the relations between intersection type assignment systems à la Curry and the corresponding intersection typed systems à la Church. Notions of soundness, completeness and isomorphism will relate type assignment and typed systems. We also show how to get rid of type coercions defining a translation function, denoted by , inspired by the one of Tannen et al. [42]: the intuition of the translation is that if has type and , then is a term of type , has type and is the identity .
1.1 calculi with intersection types à la Church
Several calculi à la Church appeared in the literature: they capture the power of intersection types; we briefly review them.
The Forsythe programming language by Reynolds [38] annotates a abstraction with types as in . However, we cannot type a typed term, whose type erasure is the combinator , with the type .
Pierce [34] improves Forsythe by using a for
construct to build ad hoc polymorphic typing, as in
. However, we cannot type a typed term, whose type
erasure is ,
with the type
Freeman and Pfenning [20] introduced refinement types, that is types that allow ad hoc
polymorphism for ML constructors. Intuitively, refinement types can be seen as subtypes of a standard type: the user first defines a type and then the refinement types of this type. The main motivation for these refinement types is to allow nonexhaustive pattern matching, which becomes exhaustive for a given refinement of the type of the argument. As an example, we can define a type
boolexp
for boolean expressions, with
constructors True
, And
,
Not
and Var
, and a refinement type
ground
for boolean expressions without variables, with
the same constructors except Var
: then, the constructor
True
has type , the constructor And
has type and so
on. However, intersection is meaningful only when using constructors.
Wells et al. [45] introduced , a typed intermediate calculus for optimizing compilers for higherorder programming languages. The calculus features intersection, union and flow types, the latter being useful to optimize data representation. can faithfully encode an intersection type assignment derivation by introducing the concept of virtual tuple, i.e. a special kind of pair whose type erasure leads to exactly the same untyped term. A parallel context and parallel substitution, similar to the notion of [27, 28], is defined to reduce expressions in parallel inside a virtual tuple. Subtyping is defined only on flow types and not on intersection types: this system can encode the type assignment system.
Wells and Haak [46] introduced , a more compact typed calculus encoding of : in fact, by comparing Fig. 1 and Fig. 2 of [46] we can see that the set of typable terms with intersection types of and are the same. In that paper, virtual tuples are removed by introducing branching terms, typable with branching types, the latter representing intersection type schemes. Two operations on types and terms are defined, namely expand, expanding the branching shape of type annotations when a term is substituted into a new context, and select, to choose the correct branch in terms and types. As there are no virtual tuples, reductions do not need to be done in parallel. As in [45], the type assignment system can be encoded.
Frisch et al. [21] designed a typed system with intersection, union, negation and recursive types. The authors inherit the usual problem of having a domain space that contains all the terms and, at the same time, all the functions from to . They prevent this by having an auxiliary domain space which is the disjoint union of and . The authors interpret types as sets in a wellsuited model where the setinspired type constructs are interpreted as the corresponding to settheoretical constructs. Moreover, the model manages higherorder functions in an elegant way. The subtyping relation is defined as a relation on the settheoretical interpretation of the types. For instance, the problem will be interpreted as , where becomes the set intersection operator, and the decision program actually decides whether is the empty set.
Bono et al. [7] introduced a relevant and strict parallel term constructor to build inhabitants of intersections and a simple callbyvalue parallel reduction strategy. An infinite number of constants is applied to typed variables such that is upcasted to type . It also uses a local renaming typing rule, which changes type decoration in abstractions, as well as coercions. Term synchronicity in the tuples is guaranteed by the typing rules. The calculus uses van Bakel’s strict version [2] of the intersection type theory.
1.2 Logics for intersection types
Prooffunctional (or strong) logical connectives, introduced by Pottinger [36], take into account the shape of logical proofs, thus allowing for polymorphic features of proofs to be made explicit in formulæ. This differs from classical or intuitionistic connectives where the meaning of a compound formula is only dependent on the truth value or the provability of its subformulæ.
Pottinger was the first to consider the intersection as a prooffunctional connective. He contrasted it to the intuitionistic connective as follows: “The intuitive meaning of can be explained by saying that to assert is to assert that one has a reason for asserting which is also a reason for asserting , while to assert is to assert that one has a pair of reasons, the first of which is a reason for asserting and the second of which is a reason for asserting ”.
A simple example of a logical theorem involving intuitionistic conjunction which does not hold for prooffunctional conjunction is . Otherwise there would exist a term which behaves both as and as . Later, LopezEscobar [30] and Mints [31] investigated extensively logics featuring both prooffunctional and intuitionistic connectives especially in the context of realizability interpretations.
It is not immediate to extend the judgmentsastypes CurryHoward paradigm to logics supporting prooffunctional connectives. These connectives need to compare the shapes of derivations and do not just take into account their provability, i.e. the inhabitation of the corresponding type.
1.3 Raising the calculus to a framework.
Our goal is to build a prototype of a theorem prover based on the calculus and prooffunctional logic. Recently [25], we have extended a subset of the generic calculus with other prooffunctional operators like union types, relevant arrow types, together with dependent types as in the Edinburgh Logical Framework [22]: a preliminary implementation of a type checker appeared in [40] by the authors. In a nutshell:
Strong disjunction is a prooffunctional connective that can be interpreted as the union type [15, 40]: it contrasts with the intuitionistic connective . As Pottinger did for intersection, we could say that asserting is to assert that one has a reason for , which is also a reason to assert and . A simple example of a logical theorem involving intuitionistic disjunction which does not hold for strong disjunction is . Otherwise there would exist a term which behaves both as and as .
Strong (relevant) implication is yet another prooffunctional connective that was interpreted in [3] as a relevant arrow type . As explained in [3], it can be viewed as a special case of implication whose related function space is the simplest one, namely the one containing only the identity function. Because the operators and differ, is not derivable.
Dependent types, as introduced in the Edinburgh Logical Framework [22] by Harper et al., allows considering proofs as firstclass citizens albeit differently with respect to prooffunctional logics. The interaction of both dependent and prooffunctional operators is intriguing: the former mentions proofs explicitly, while the latter mentions proofs implicitly. Their combination therefore opens up new possibilities of formal reasoning on prooftheoretic semantics.
2 Syntax, Reduction and Types
[Type atoms, type syntax, type theories and type assignment systems] We briefly review some basic definition from Subsection 13.1 of [5], in order to define type assignment systems. The set of atoms, intersection types, intersection type theories and intersection type assignment systems are defined as follows:

(Atoms). Let denote a set of symbols which we will call type atoms, and let be a special type atom denoting the universal type. In particular, we will use with being different from and .

(Syntax). The syntax of intersection types, parametrized by , is: .

(Intersection type theories ). An intersection type theory is a set of sentences of the form satisfying at least the axioms and rules of the minimal type theory defined in Figure 1. The type theories , and are the smallest type theories over satisfying the axioms and rules given in Figure 3. We write if, for all such that , we have that . In particular and . We will sometime note, for instance, instead of .

(Intersection type assignment systems ). We define in Figure 2^{4}^{4}4Although rules are derivable with , we add them for clarity. an infinite collection of type assignment systems parametrized by a set of atoms and a type theory . We name four particular type assignment systems in the table below, which is an excerpt from Figure 13.4 of [5]. denotes a derivable type assignment judgment in the type assignment system . Type checking is not decidable for , , , and .
Figure 3: Type theories , , , and . The ref. column refers to the original article these theories come from.
2.1 The calculi
Intersection type assignment systems and calculi have in common their type syntax and intersection type theories. The generic syntax of the calculus is defined as follows. [Generic calculus syntax]
denotes an infinite set of constants, indexed with a particular untyped term. denotes an explicit coercion of to type . The expression denotes a pair that, following the LopezEscobar jargon [30], we call “strong pair” with respective projections and . The essence function is an erasing function mapping typed terms into pure terms. It is defined as follows.
[Essence function]
One could argue that the choice of is arbitrary and could have been replaced with . However, the typing rules will ensure that, if is typable, then, for some suitable equivalence relation , we have that . Thus, strong pairs can be viewed as constrained cartesian products. The generic reduction semantics reduces terms of the calculus as follows. [Generic reduction semantics] Syntactical equality is denoted by .

(Substitution) Substitution on terms is defined as usual, with the additional rules:

(Onestep reduction). We define three notions of reduction:
Observe that is not a redex, because the abstraction is coerced. The contextual closure is defined as usual except for reductions inside the index of that are forbidden (even though substitutions are propagated). We write for the contextual closure of the and notions of reduction, for the contextual closure of . We also define a synchronous contextual closure, which is like the usual contextual closure except for the strong pairs, as defined in point . Synchronous contextual closure of the notions of reduction generates the reduction relations and .

(Synchronous closure of ). Synchronous closure is defined on the strong pairs with the following constraint:
Note that we reduce in the two components of the strong pair; 
(Multistep reduction). We write (resp. ) as the reflexive and transitive closure of (resp. );

(Congruence). We write as the symmetric, reflexive, transitive closure of .
We mostly consider reductions, thus to ease the notation we omit the subscript in reductions.
The next definition introduces a notion of synchronization inside strong pairs. [Synchronization] A term is synchronous if and only if, for all its subterms of the shape , we have that .
It is easy to verify that preserves synchronization, while it is not the case for . The next definition introduces a generic intersection typed system for the calculus that is parametrizable by suitable equivalence relations on pure terms and type theories as follows.
[Generic intersection typed system] The generic intersection typed system is defined in Figure 4. We denote by a particular typed system with the type theory and under an equivalence relation and by a corresponding typing judgment. The typing rules are intuitive for a calculus à la Church except rules , and .
The typing rule for a strong pair is similar to the typing rule for a cartesian product, except for the sidecondition , forcing the two parts of the strong pair to have essences compatible under , thus making a strong pair a special case of a cartesian pair. For instance, is not typable in ; is not typable in but it is in ; is not typable in nor but it is in . In the typing rule , the subscript in is not necessarily typable so can easily be any arbitrary term. The typing rule allows to change the type of a term from to if : the term in the conclusion must record this change with an explicit type coercion , producing the new term : explicit type coercions are important to keep the unicity of typing derivations.
The next definition introduces a partial order over equivalence relations on pure terms and an inclusion over typed systems as follows.
[ and ]

Let . if, for all pure terms such that , we have that ;

if and , then .

and ;

if and .
2.2 The chair
The next definition classifies ten typed systems for the
calculus: some of them already appeared (sometime with a different notation) in the literature by the present authors.[chair]
Ten typed systems can be drawn pictorially in a
chair, where the arrows represent an inclusion relation.
corresponds roughly to [27, 28] (in the expression
, is the essence of ) and in its intersection
part to [40]; corresponds roughly in its
intersection part to [16],
corresponds in its intersection part to [29],
corresponds in its intersection part to
[15]. The other typed systems are basically new.
The main properties of these systems are:
All the systems enjoys the synchronous subject
reduction property, the other systems also enjoy ordinary subject
reduction (Th. 4.1);
All the systems strongly normalize (Th. 4.2);
All the systems correspond to the to original type assignment systems
except , , and (Th. 5);
Type checking and type reconstruction are decidable for all the
systems, except , , and
(Th. 5).
3 Examples
This section shows examples of typed derivations and highlights the corresponding type assignment judgment in they correspond to, in the sense that we have a derivation and another derivation . The correspondence between intersection typed systems and intersection type assignment will be defined in Subsection 5.1.
[Polymorphic identity] In all of the intersection type assignment systems we can derive A corresponding term is: that can be typed in all of the typed systems of the chair as follows
[Auto application] In all of the intersection type assignment systems we can derive A corresponding term is: that can be typed in all of the typed systems of the chair as follows
[Some examples in ] In we can derive , and using this type assignment, we can derive . A corresponding term is: that can be typed in as follows
As another example, we can also derive . A corresponding term is: that can be typed in as follows
[An example in ] In we can prove the commutativity of intersection, i.e. A corresponding term is: that can be typed in as follows
where is .
[Another polymorphic identity in ] In all the you can type this term: The typing derivation is thus
[Two examples in and ] In we can can type any term, including the nonterminating term More precisely, we have: A corresponding term whose essence is is: that can be typed in as follows
where is
In we can type A corresponding term whose essence is is: that can be typed in as follows
Note that the condition has an interesting loophole, as it is wellknown that does not enjoy conversion property. Theorem B.1(1) will show that we can construct a term which does not correspond to any derivation.
[Pottinger] The following examples can be typed in all the type theories of the chair (we also display in square brackets the corresponding pure terms typable in ). These are encodings from the examples à la Curry given by Pottinger in [36].
In the same paper, Pottinger lists some types that cannot be inhabited by any intersection type assignment () in an empty context, namely: . It is not difficult to verify that the above types cannot be inhabited by any of the type systems of the chair because of the failure of the essence condition in the strong pair type rule.
[Intersection is not the conjunction operator] This counterexample is from the corresponding counterexample à la Curry given by Hindley [24] and BenYelles [6]. The intersection type where the left part of the intersection corresponds to the type for the combinator I and the right part for the combinator S cannot be assigned to a pure term. Analogously, the same intersection type cannot be assigned to any term.
3.1 On synchronization and subject reduction
For the typed systems , strong pairs have an
intrinsic notion of synchronization: some redexes need to be reduced
in a synchronous fashion unless we want to create meaningless
terms that cannot be typed. Consider the term
. If we use
the reduction relation, then the following reduction
paths are legal
More precisely, the first and second redexes are rewritten
asynchronously, thus they cannot be typed in any typed system
, because we fail to check the left and the right
part of the strong pair to be the same: the
reduction relation prevents this loophole
and allows to type all redexes. In summary,
can be thought of as the natural
reduction relation for the typed systems .
4 Metatheory of
4.1 General properties
Unless specified, all properties applies to the intersection typed systems . For lack of space all proofs are omitted: the interested reader can found more technical details in the Appendix. The ChurchRosser property is proved using the technique of Takahashi [41]. The parallel reduction semantics extends Definition 2.1 and it is inductively defined as follows. [Parallel reduction semantics]
Intuitively, means that is obtained from by simultaneous contraction of some redexes possibly overlapping each other. ChurchRosser can be achieved by proving a stronger statement, namely where is a term determined by and independent from . The statement (1) is satisfied by the term which is obtained from by contracting all the redexes existing in simultaneously.
[The map ]
Now we have to prove the ChurchRosser property for the parallel reduction. [Confluence property for ] If , then .
The ChurchRosser property follows. [Confluence] If and , then there exists such that and .
The next lemma says that all type derivations for have an unique type. [Unicity of typing] If , then is unique. The next theorem states that all the typed systems preserve synchronous reduction, and all the and typed systems preserve
Comments
There are no comments yet.