Intersection Type System
   HOME

TheInfoList



OR:

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 and Scala, 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 Normalization or normalisation refers to a process that makes something more normal or regular. Most commonly it refers to: * Normalization (sociology) or social normalization, the process through which ideas and behaviors that may fall outside of ...
) 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 type theory, a branch of mathematical logic, in a given typed calculus, the type inhabitation problem for this calculus is the following problem: given a type \tau and a typing environment \Gamma, does there exist a \lambda-term M such that \Ga ...
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 In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by ...
.


Coppo–Dezani type assignment system

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


Term language

The term language of (\vdash_\text) is given by λ-terms (or, lambda expressions): : \begin M, N & ::= x \mid (\lambda x.\!M) \mid (M\;N) && \text x \text\\ \end


Type language

The type language of (\vdash_\text) is inductively defined by the following grammar: : \begin \varphi & ::= \alpha \mid \sigma \to \varphi && \text \alpha \text\\ \sigma & ::= \varphi_1 \cap \cdots \cap \varphi_n && \text n \geq 1 \end The intersection type constructor (\cap) is taken modulo associativity, commutativity and idempotence.


Typing rules

The typing rules (\to\!\!\text), (\to\!\!\text), (\cap\text), and (\cap\text) of (\vdash_\text) are: : \begin \dfrac(\to\!\!\text) &\dfrac(\to\!\!\text)\\\\ \dfrac(\cap\text) &\dfrac(\cap\text) \end


Properties

Typability and normalization are closely related in (\vdash_) by the following properties: * Subject reduction: If \Gamma \vdash_ M : \sigma and M \to_\beta N, then \Gamma \vdash_ N : \sigma. *
Normalization Normalization or normalisation refers to a process that makes something more normal or regular. Most commonly it refers to: * Normalization (sociology) or social normalization, the process through which ideas and behaviors that may fall outside of ...
: If \Gamma \vdash_ M : \sigma, then M has a β-normal form. * Typability of
strongly normalizing In abstract rewriting, an object is in normal form if it cannot be rewritten any further, i.e. it is irreducible. Depending on the rewriting system, an object may rewrite to several normal forms or none at all. Many properties of rewriting systems ...
λ-terms: If M is
strongly normalizing In abstract rewriting, an object is in normal form if it cannot be rewritten any further, i.e. it is irreducible. Depending on the rewriting system, an object may rewrite to several normal forms or none at all. Many properties of rewriting systems ...
, then \Gamma \vdash_ 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_ 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 n = 0, then (\vdash_) 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_) extends the Coppo–Dezani type assignment system in the following three aspects: * (\vdash_\text) introduces the universal type constant \omega (akin to the empty intersection) that can be assigned to any λ-term. * (\vdash_) allows the intersection type constructor (\cap) to appear on the right-hand side of the arrow type constructor (\to). * (\vdash_\text) introduces the intersection type subtyping (\leq) partial order on types together with a corresponding typing rule.


Term language

The term language of (\vdash_) is given by λ-terms (or, lambda expressions): : \begin M, N & ::= x \mid (\lambda x.\!M) \mid (M\;N) && \text x \text\\ \end


Type language

The type language of (\vdash_) is inductively defined by the following grammar: : \begin \sigma, \tau & ::= \alpha \mid \omega \mid \sigma \to \tau \mid \sigma \cap \tau && \text \alpha \text \end


Intersection type subtyping

Intersection type subtyping (\leq) is defined as the smallest
preorder In mathematics, especially in order theory, a preorder or quasiorder is a binary relation that is reflexive and transitive. Preorders are more general than equivalence relations and (non-strict) partial orders, both of which are special c ...
( reflexive and transitive relation) over intersection types satisfying the following properties: : \begin &\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\sigma \leq \tau_1 \text \sigma\leq \tau_2 \text \sigma \leq \tau_1 \cap \tau_2, \\ &\text \sigma_2 \leq \sigma_1 \text \tau_1 \leq \tau_2 \text \sigma_1\to\tau_1 \leq \sigma_2\to\tau_2 \end Intersection type subtyping is decidable in quadratic time.


Typing rules

The typing rules (\to\!\!\text), (\to\!\!\text), (\cap\text), (\leq), (\text), and (\omega) of (\vdash_) are: : \begin \dfrac(\to\!\!\text) &\dfrac(\to\!\!\text)\\\\ \dfrac(\cap\text) &\dfrac(\leq)\\\\ \dfrac(\text) &\dfrac(\omega) \end


Properties

* Semantics: (\vdash_) 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_ M : \sigma and M \to_ N, then \Gamma \vdash_ N : \sigma. * Subject expansion: If \Gamma \vdash_ N : \sigma and M \to_ N, then \Gamma \vdash_ M : \sigma. * Characterization of strong normalization: M is strongly normalizing wrt. β-reduction, if and only if \Gamma \vdash_ 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_ 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 {{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 Type theory Type systems Lambda calculus Theory of computation Polymorphism (computer science)