Intersection type discipline

{{short description|Branch of type theory}}

In mathematical logic, the intersection type discipline is a branch of type theory encompassing type systems that use the intersection type constructor (\cap) to assign multiple types to a single term.

In particular, if a term M can be assigned both the type \varphi_1 and the type \varphi_2, then M can be assigned the intersection type \varphi_1 \cap \varphi_2 (and vice versa).

Therefore, the intersection type constructor can be used to express finite heterogeneous ad hoc polymorphism (as opposed to parametric polymorphism).

For example, the λ-term \lambda x.\!(x\;x) can be assigned the type ((\alpha \to \beta) \cap \alpha) \to \beta in most intersection type systems, assuming for the term variable x both the function type \alpha \to \beta and the corresponding argument type \alpha.

Prominent intersection type systems include the Coppo–Dezani type assignment system, the Barendregt-Coppo–Dezani type assignment system, and the essential intersection type assignment system.

Most strikingly, intersection type systems are closely related to (and often exactly characterize) normalization properties of λ-terms under β-reduction.

In programming languages, such as TypeScript{{cite web |url=https://www.typescriptlang.org/docs/handbook/advanced-types.html#intersection-types |title=Intersection Types in TypeScript |accessdate=2019-08-01}} and Scala,{{cite web |url=https://www.scala-lang.org/files/archive/spec/2.12/03-types.html#compound-types |title=Compound Types in Scala |accessdate=2019-08-01}} intersection types are used to express ad hoc polymorphism.

History

The intersection type discipline was pioneered by Mario Coppo, Mariangiola Dezani-Ciancaglini, Patrick Sallé, and Garrel Pottinger.

The underlying motivation was to study semantic properties (such as normalization) of the λ-calculus by means of type theory.

While the initial work by Coppo and Dezani established a type theoretic characterization of strong normalization for the λI-calculus, Pottinger extended this characterization to the λK-calculus.

In addition, Sallé contributed the notion of the universal type \omega that can be assigned to any λ-term, thereby corresponding to the empty intersection.

Using the universal type \omega allowed for a fine-grained analysis of head normalization, normalization, and strong normalization.

In collaboration with Henk Barendregt, a filter λ-model for an intersection type system was given, tying intersection types ever more closely to λ-calculus semantics.

Due to the correspondence with normalization, typability in prominent intersection type systems (excluding the universal type) is undecidable.

Complementarily, undecidability of the dual problem of type inhabitation in prominent intersection type systems was proven by Paweł Urzyczyn.

Later, this result was refined showing exponential space completeness of rank 2 intersection type inhabitation and undecidability of rank 3 intersection type inhabitation.

Remarkably, principal type inhabitation is decidable in polynomial time.

Coppo–Dezani type assignment system

The Coppo–Dezani type assignment system (\vdash_{\text{CD}}) extends the simply typed λ-calculus by allowing multiple types to be assumed for a term variable.

= Term language =

The term language of (\vdash_\text{CD}) is given by λ-terms (or, lambda expressions):

:

\begin{align}

M, N & ::= x \mid (\lambda x.\!M) \mid (M\;N) && \text{ where } x \text{ ranges over term variables}\\

\end{align}

= Type language =

The type language of (\vdash_\text{CD}) is inductively defined by the following grammar:

:

\begin{align}

\varphi & ::= \alpha \mid \sigma \to \varphi && \text{ where } \alpha \text{ ranges over type variables}\\

\sigma & ::= \varphi_1 \cap \cdots \cap \varphi_n && \text{ where } n \geq 1

\end{align}

The intersection type constructor (\cap) is taken modulo associativity, commutativity and idempotence.

= Typing rules =

The typing rules (\to\!\!\text{I}), (\to\!\!\text{E}), (\cap\text{I}), and (\cap\text{E}) of (\vdash_\text{CD}) are:

:

\begin{array}{cc}

\dfrac{\Gamma, x : \sigma \vdash_\text{CD} M : \varphi}{\Gamma \vdash_\text{CD} \lambda x.\!M : \sigma \to \varphi}(\to\!\!\text{I})

&\dfrac{\Gamma \vdash_\text{CD} M : \sigma \to \varphi \quad \Gamma \vdash_\text{CD} N : \sigma}{\Gamma \vdash_\text{CD} M\;N : \varphi}(\to\!\!\text{E})\\\\

\dfrac{\Gamma \vdash_\text{CD} M : \varphi_1 \quad \ldots \quad \Gamma \vdash_\text{CD} M : \varphi_n}{\Gamma \vdash_\text{CD} M : \varphi_1 \cap \cdots \cap \varphi_n}(\cap\text{I})

&\dfrac{(1 \leq i \leq n)}{\Gamma, x : \varphi_1 \cap \cdots \cap \varphi_n \vdash_\text{CD} x : \varphi_i}(\cap\text{E})

\end{array}

= Properties =

Typability and normalization are closely related in (\vdash_{\text{CD}}) by the following properties:

  • Subject reduction: If \Gamma \vdash_{\text{CD}} M : \sigma and M \to_\beta N, then \Gamma \vdash_{\text{CD}} N : \sigma.
  • Normalization: If \Gamma \vdash_{\text{CD}} M : \sigma, then M has a β-normal form.
  • Typability of strongly normalizing λ-terms: If M is strongly normalizing, then \Gamma \vdash_{\text{CD}} M : \sigma for some \Gamma and \sigma.
  • Characterization of λI-normalization: M has a normal form in the λI-calculus, if and only if \Gamma \vdash_{\text{CD}} M : \sigma for some \Gamma and \sigma.

If the type language is extended to contain the empty intersection, i.e. \sigma = \varphi_1 \cap \cdots \cap \varphi_n \text{ where } n = 0,

then (\vdash_{\text{CD}}) is closed under β-equality and is sound and complete for inference semantics.

Barendregt–Coppo–Dezani type assignment system

The Barendregt–Coppo–Dezani type assignment system (\vdash_{\text{BCD}}) extends the Coppo–Dezani type assignment system in the following three aspects:

  • (\vdash_\text{BCD}) introduces the universal type constant \omega (akin to the empty intersection) that can be assigned to any λ-term.
  • (\vdash_{\text{BCD}}) allows the intersection type constructor (\cap) to appear on the right-hand side of the arrow type constructor (\to).
  • (\vdash_\text{BCD}) introduces the intersection type subtyping (\leq) partial order on types together with a corresponding typing rule.

= Term language =

The term language of (\vdash_{\text{BCD}}) is given by λ-terms (or, lambda expressions):

:

\begin{align}

M, N & ::= x \mid (\lambda x.\!M) \mid (M\;N) && \text{ where } x \text{ ranges over term variables}\\

\end{align}

= Type language =

The type language of (\vdash_{\text{BCD}}) is inductively defined by the following grammar:

:

\begin{align}

\sigma, \tau & ::= \alpha \mid \omega \mid \sigma \to \tau \mid \sigma \cap \tau && \text{ where } \alpha \text{ ranges over type variables}

\end{align}

= Intersection type subtyping =

Intersection type subtyping (\leq) is defined as the smallest preorder (reflexive and transitive relation) over intersection types satisfying the following properties:

:

\begin{align}

&\sigma \leq \omega, \quad \omega \leq \omega\to\omega, \quad \sigma \cap \tau \leq \sigma, \quad \sigma \cap \tau \leq \tau, \\

& (\sigma\to\tau_1) \cap (\sigma\to\tau_2) \leq \sigma \to \tau_1 \cap \tau_2,\\

&\text{if }\sigma \leq \tau_1 \text{ and } \sigma\leq \tau_2 \text{, then } \sigma \leq \tau_1 \cap \tau_2, \\

&\text{if } \sigma_2 \leq \sigma_1 \text{ and } \tau_1 \leq \tau_2 \text{, then } \sigma_1\to\tau_1 \leq \sigma_2\to\tau_2

\end{align}

Intersection type subtyping is decidable in quadratic time.

= Typing rules =

The typing rules (\to\!\!\text{I}), (\to\!\!\text{E}), (\cap\text{I}), (\leq), (\text{A}), and (\omega) of (\vdash_{\text{BCD}}) are:

:

\begin{array}{cc}

\dfrac{\Gamma, x : \sigma \vdash_{\text{BCD}} M : \tau}{\Gamma \vdash_{\text{BCD}} \lambda x.\!M : \sigma \to \tau}(\to\!\!\text{I})

&\dfrac{\Gamma \vdash_{\text{BCD}} M : \sigma \to \tau \quad \Gamma \vdash_{\text{BCD}} N : \sigma}{\Gamma \vdash_{\text{BCD}} M\;N : \tau}(\to\!\!\text{E})\\\\

\dfrac{\Gamma \vdash_{\text{BCD}} M : \sigma \quad \Gamma \vdash_{\text{BCD}} M : \tau}{\Gamma \vdash_{\text{BCD}} M : \sigma \cap \tau}(\cap\text{I})

&\dfrac{\Gamma \vdash_{\text{BCD}} M : \sigma \quad (\sigma \leq \tau)}{\Gamma \vdash_{\text{BCD}} M : \tau}(\leq)\\\\

\dfrac{}{\Gamma, x : \sigma \vdash_{\text{BCD}} x : \sigma}(\text{A})

&\dfrac{}{\Gamma \vdash_{\text{BCD}} M : \omega}(\omega)

\end{array}

= Properties =

  • Semantics: (\vdash_{\text{BCD}}) is sound and complete wrt. a filter λ-model, in which the interpretation of a λ-term coincides with the set of types that can be assigned to it.
  • Subject reduction: If \Gamma \vdash_{\text{BCD}} M : \sigma and M \to_{\beta} N, then \Gamma \vdash_{\text{BCD}} N : \sigma.
  • Subject expansion: If \Gamma \vdash_{\text{BCD}} N : \sigma and M \to_{\beta} N, then \Gamma \vdash_{\text{BCD}} M : \sigma.
  • Characterization of strong normalization: M is strongly normalizing wrt. β-reduction, if and only if \Gamma \vdash_{\text{BCD}} M : \sigma is derivable without rule (\omega) for some \Gamma and \sigma.
  • Principal pairs: If M is strongly normalizing, then there exists a principal pair (\Gamma, \sigma) such that for any typing \Gamma' \vdash_{\text{BCD}} M : \sigma' the pair (\Gamma', \sigma') can be obtained from the principal pair (\Gamma, \sigma) by means of type expansions, liftings, and substitutions.

References

{{Reflist|refs=

{{cite journal |doi=10.1007/BF02011875 |title=A new type assignment for λ-terms |journal=Archiv für mathematische Logik und Grundlagenforschung |volume=19 |issue=1 |pages=139–156 |year=1978 |last1=Coppo |first1=Mario |last2=Dezani-Ciancaglini |first2=Mariangiola |s2cid=206809924 }}

{{cite conference |title=Functional Characterization of Some Semantic Equalities inside Lambda-Calculus |last1=Coppo |first1=Mario |last2=Dezani-Ciancaglini |first2=Mariangiola |last3=Sallé |first3=Patrick |year=1979 |editor=Hermann A. Maurer |volume=71 |book-title=Automata, Languages and Programming, 6th Colloquium, Graz, Austria, July 16-20, 1979, Proceedings |publisher=Springer |pages=133–146 |isbn=3-540-09510-1 |doi=10.1007/3-540-09510-1_11 }}

{{cite journal |doi=10.1305/ndjfl/1093883253 |title=An extension of the basic functionality theory for the λ-calculus |journal=Notre Dame Journal of Formal Logic |volume=21 |issue=4 |pages=685–693 |year=1980 |last1=Coppo |first1=Mario |last2=Dezani-Ciancaglini |first2=Mariangiola |s2cid=29748788 |doi-access=free }}

Pottinger, G. (1980). A type assignment for the strongly normalizable λ-terms. To HB Curry: essays on combinatory logic, lambda calculus and formalism, 561-577.

{{cite journal |doi=10.1002/malq.19810270205 |title=Functional characters of solvable terms |journal=Mathematical Logic Quarterly |volume=27 |issue=2–6 |pages=45–58 |year=1981 |last1=Coppo |first1=Mario |last2=Dezani-Ciancaglini |first2=Mariangiola |last3=Venneri |first3=Betti }}

{{cite journal |doi=10.2307/2273659 |jstor=2273659 |title=A filter lambda model and the completeness of type assignment |journal=Journal of Symbolic Logic |volume=48 |issue=4 |pages=931–940 |year=1983 |last1=Barendregt |first1=Henk |last2=Coppo |first2=Mario |last3=Dezani-Ciancaglini |first3=Mariangiola |s2cid=45660117 }}

{{cite journal |doi=10.1016/0304-3975(83)90069-5 |title=Principal type schemes for an extended type theory |journal=Theoretical Computer Science |volume=28 |issue=(1-2) |pages=151–169 |year=1983 |last1=Ronchi Della Rocca |first1=Simona |last2=Venneri |first2=Betti |doi-access=free }}

{{cite journal |doi=10.1016/0304-3975(92)90297-S |title=Complete restrictions of the intersection type discipline |journal=Theoretical Computer Science |volume=102 |issue=1 |pages=135–163 |year=1992 |last1=Van Bakel |first1=Steffen |citeseerx=10.1.1.310.903 }}

{{cite journal |doi=10.1305/ndjfl/1040067315 |title=Strong normalization and typability with intersection types |journal=Notre Dame Journal of Formal Logic |volume=37 |issue=1 |pages=44–52 |year=1996 |last1=Ghilezan |first1=Silvia |doi-access=free }}

{{cite journal |doi=10.2307/2586625 |title=The emptiness problem for intersection types |journal=Journal of Symbolic Logic |volume=64 |issue=3 |pages=1195–1215 |year=1999 |last1=Urzyczyn |first1=Paweł |jstor=2586625 |s2cid=36979036 }}

{{cite conference |title=Inhabitation of low-rank intersection types |last1=Urzyczyn |first1=Paweł |year=2009 |volume=5608 |book-title=International Conference on Typed Lambda Calculi and Applications |conference=TLCA 2009 |publisher=Springer |pages=356–370 |isbn=978-3-642-02272-2 |doi=10.1007/978-3-642-02273-9_26 }}

{{cite journal |doi=10.1145/1922649.1922657 |title=Strict intersection types for the Lambda calculus |journal=ACM Computing Surveys |volume=43 |issue=3 |pages=20:1–20:49 |year=2011 |last1=van Bakel |first1=Steffen |s2cid=5537689 |citeseerx=10.1.1.310.2166 }}

{{cite book |author1=Henk Barendregt |author2=Wil Dekkers |author3=Richard Statman |title=Lambda Calculus with Types |url=https://books.google.com/books?id=2UVasvrhXl8C&pg=PR1 |date=20 June 2013 |publisher=Cambridge University Press |isbn=978-0-521-76614-2 |pages=1–}}

{{cite journal |doi=10.23638/LMCS-13(3:9)2017 |title=The algebraic intersection type unification problem |journal=Logical Methods in Computer Science |volume=13 |issue=3 |year=2017 |last1=Dudenhefner |first1=Andrej |last2=Martens |first2=Moritz |last3=Rehof |first3=Jakob |s2cid=31640337 |arxiv=1611.05672 }}

{{cite conference |title=Principality and approximation under dimensional bound |last1=Dudenhefner |first1=Andrej |last2=Rehof |first2=Jakob |year=2019 |volume=3 |book-title=Proceedings of the ACM on Programming Languages |conference=POPL 2019 |publisher=ACM |pages=8:1–8:29 |issn=2475-1421 |doi=10.1145/3290321 |doi-access=free }}

}}

Category:Type theory

Category:Type systems

Category:Lambda calculus

Category:Theory of computation

Category:Polymorphism (computer science)