Intersection type discipline

From testwiki
Revision as of 10:55, 20 August 2024 by imported>Ngeiswei (Create hyperlink for subtyping)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Short description

In mathematical logic, the intersection type discipline is a branch of type theory encompassing type systems that use the intersection type constructor () to assign multiple types to a single term.[1] In particular, if a term M can be assigned both the type φ1 and the type φ2, then M can be assigned the intersection type φ1φ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 λx.(xx) can be assigned the type ((αβ)α)β in most intersection type systems, assuming for the term variable x both the function type αβ and the corresponding argument type α.

Prominent intersection type systems include the Coppo–Dezani type assignment system,[2] the Barendregt-Coppo–Dezani type assignment system,[3] and the essential intersection type assignment system.[4] 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[5] and Scala,[6] 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.[2][7][8] The underlying motivation was to study semantic properties (such as normalization) of the λ-calculus by means of type theory.[9] While the initial work by Coppo and Dezani established a type theoretic characterization of strong normalization for the λI-calculus,[2] Pottinger extended this characterization to the λK-calculus.[7] In addition, Sallé contributed the notion of the universal type ω that can be assigned to any λ-term, thereby corresponding to the empty intersection.[8] Using the universal type ω allowed for a fine-grained analysis of head normalization, normalization, and strong normalization.[10] 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.[11] Later, this result was refined showing exponential space completeness of rank 2 intersection type inhabitation and undecidability of rank 3 intersection type inhabitation.[12] Remarkably, principal type inhabitation is decidable in polynomial time.[13]

Coppo–Dezani type assignment system

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

Term language

The term language of (CD) is given by λ-terms (or, lambda expressions):

M,N::=x(λx.M)(MN) where x ranges over term variables

Type language

The type language of (CD) is inductively defined by the following grammar:

φ::=ασφ where α ranges over type variablesσ::=φ1φn where n1

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

Typing rules

The typing rules (I), (E), (I), and (E) of (CD) are:

Γ,x:σCDM:φΓCDλx.M:σφ(I)ΓCDM:σφΓCDN:σΓCDMN:φ(E)ΓCDM:φ1ΓCDM:φnΓCDM:φ1φn(I)(1in)Γ,x:φ1φnCDx:φi(E)

Properties

Typability and normalization are closely related in (CD) by the following properties:[2]

If the type language is extended to contain the empty intersection, i.e. σ=φ1φn where n=0, then (CD) is closed under β-equality and is sound and complete for inference semantics.[14]

Barendregt–Coppo–Dezani type assignment system

The Barendregt–Coppo–Dezani type assignment system (BCD) extends the Coppo–Dezani type assignment system in the following three aspects:[3]

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

Term language

The term language of (BCD) is given by λ-terms (or, lambda expressions):

M,N::=x(λx.M)(MN) where x ranges over term variables

Type language

The type language of (BCD) is inductively defined by the following grammar:

σ,τ::=αωστστ where α ranges over type variables

Intersection type subtyping

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

σω,ωωω,στσ,σττ,(στ1)(στ2)στ1τ2,if στ1 and στ2, then στ1τ2,if σ2σ1 and τ1τ2, then σ1τ1σ2τ2

Intersection type subtyping is decidable in quadratic time.[15]

Typing rules

The typing rules (I), (E), (I), (), (A), and (ω) of (BCD) are:

Γ,x:σBCDM:τΓBCDλx.M:στ(I)ΓBCDM:στΓBCDN:σΓBCDMN:τ(E)ΓBCDM:σΓBCDM:τΓBCDM:στ(I)ΓBCDM:σ(στ)ΓBCDM:τ()Γ,x:σBCDx:σ(A)ΓBCDM:ω(ω)

Properties

  • Semantics: (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.[3]
  • Subject reduction: If ΓBCDM:σ and MβN, then ΓBCDN:σ.[3]
  • Subject expansion: If ΓBCDN:σ and MβN, then ΓBCDM:σ.[3]
  • Characterization of strong normalization: M is strongly normalizing wrt. β-reduction, if and only if ΓBCDM:σ is derivable without rule (ω) for some Γ and σ.[16]
  • Principal pairs: If M is strongly normalizing, then there exists a principal pair (Γ,σ) such that for any typing ΓBCDM:σ the pair (Γ,σ) can be obtained from the principal pair (Γ,σ) by means of type expansions, liftings, and substitutions.[17]

References

Template:Reflist

  1. Cite error: Invalid <ref> tag; no text was provided for refs named BDS13
  2. 2.0 2.1 2.2 2.3 2.4 Cite error: Invalid <ref> tag; no text was provided for refs named CD80
  3. 3.0 3.1 3.2 3.3 3.4 Cite error: Invalid <ref> tag; no text was provided for refs named BCD83
  4. Cite error: Invalid <ref> tag; no text was provided for refs named B11
  5. Template:Cite web
  6. Template:Cite web
  7. 7.0 7.1 Cite error: Invalid <ref> tag; no text was provided for refs named P80
  8. 8.0 8.1 Cite error: Invalid <ref> tag; no text was provided for refs named CDS79
  9. Cite error: Invalid <ref> tag; no text was provided for refs named CD78
  10. Cite error: Invalid <ref> tag; no text was provided for refs named CDV81
  11. Cite error: Invalid <ref> tag; no text was provided for refs named U99
  12. Cite error: Invalid <ref> tag; no text was provided for refs named U09
  13. Cite error: Invalid <ref> tag; no text was provided for refs named DR19
  14. Cite error: Invalid <ref> tag; no text was provided for refs named VB92
  15. Cite error: Invalid <ref> tag; no text was provided for refs named DMR17
  16. Cite error: Invalid <ref> tag; no text was provided for refs named G96
  17. Cite error: Invalid <ref> tag; no text was provided for refs named RDRV83