Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Intersection type discipline

From Wikipedia, the free encyclopedia
(Redirected fromIntersection type system)
Branch of type theory

Inmathematical logic, theintersection type discipline is a branch oftype theory encompassingtype systems that use theintersection type constructor(){\displaystyle (\cap )} to assign multiple types to a single term.[1]In particular, if a termM{\displaystyle M} can be assignedboth the typeφ1{\displaystyle \varphi _{1}} and the typeφ2{\displaystyle \varphi _{2}}, thenM{\displaystyle M} can be assigned theintersection typeφ1φ2{\displaystyle \varphi _{1}\cap \varphi _{2}} (and vice versa).Therefore, the intersection type constructor can be used to express finite heterogeneousad hoc polymorphism (as opposed toparametric polymorphism).For example, theλ-termλx.(xx){\displaystyle \lambda x.\!(x\;x)} can be assigned the type((αβ)α)β{\displaystyle ((\alpha \to \beta )\cap \alpha )\to \beta } in most intersection type systems, assuming for the term variablex{\displaystyle x} both the function typeαβ{\displaystyle \alpha \to \beta } and the corresponding argument typeα{\displaystyle \alpha }.

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 expressad hoc polymorphism.

History

[edit]

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 asnormalization) of theλ-calculus by means oftype 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ω{\displaystyle \omega } that can be assigned to any λ-term, thereby corresponding to the empty intersection.[8]Using the universal typeω{\displaystyle \omega } allowed for a fine-grained analysis of head normalization, normalization, and strong normalization.[10]In collaboration withHenk 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 infinite intersection type systems isundecidable. However restricting intersection types to finite rank makes their typeability decidable for any finite rank, which is in contrast withsystem F, where (quatifier) restrictions to finite ranks above 3 still have undecidable typeability.[11] On the other hand, ifrecursive types are added to a system with rank-2 or higher intersection types, typability becomes undecidable, in general.[12]

Complementarily,undecidability of the dual problem oftype inhabitation in prominent intersection type systems was proven by Paweł Urzyczyn.[13]Later, this result was refined showingexponential space completeness of rank 2 intersection type inhabitation andundecidability of rank 3 intersection type inhabitation.[14]Remarkably,principal type inhabitation is decidable inpolynomial time.[15]

To deal with the difficulties in applying theCurry-Howard correspondence to intersection types, Kamareddine and Wells have replaced the intersection constructor in the deduction system with finite-set declarations (FSD) for the domain of each variable in a lambda abstraction, turning them intoΠ types. And they extended thelambda cube to what they call the f-cube, which has with FSD-encoded intersection types at all vertices.Urzyczyn’s term U, which is untypable in the λ-cube, is typable in the f-cube.[16]

Coppo–Dezani type assignment system

[edit]

TheCoppo–Dezani type assignment system(CD){\displaystyle (\vdash _{\text{CD}})} extends thesimply typed λ-calculus by allowing multiple types to be assumed for a term variable.[2]

Term language

[edit]

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

M,N::=x(λx.M)(MN) where x ranges over term variables{\displaystyle {\begin{aligned}M,N&::=x\mid (\lambda x.\!M)\mid (M\;N)&&{\text{ where }}x{\text{ ranges over term variables}}\\\end{aligned}}}

Type language

[edit]

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

φ::=ασφ where α ranges over type variablesσ::=φ1φn where n1{\displaystyle {\begin{aligned}\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{aligned}}}

The intersection type constructor ({\displaystyle \cap }) is taken modulo associativity, commutativity andidempotence.

Typing rules

[edit]

Thetyping rules(I){\displaystyle (\to \!\!{\text{I}})},(E){\displaystyle (\to \!\!{\text{E}})},(I){\displaystyle (\cap {\text{I}})}, and(E){\displaystyle (\cap {\text{E}})} of(CD){\displaystyle (\vdash _{\text{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){\displaystyle {\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

[edit]

Typability and normalization are closely related in(CD){\displaystyle (\vdash _{\text{CD}})} by the following properties:[2]

If the type language is extended to contain the empty intersection, i.e.σ=φ1φn where n=0{\displaystyle \sigma =\varphi _{1}\cap \cdots \cap \varphi _{n}{\text{ where }}n=0}, then(CD){\displaystyle (\vdash _{\text{CD}})} is closed under β-equality and is sound and complete for inference semantics.[17]

Barendregt–Coppo–Dezani type assignment system

[edit]

TheBarendregt–Coppo–Dezani type assignment system(BCD){\displaystyle (\vdash _{\text{BCD}})} extends the Coppo–Dezani type assignment system in the following three aspects:[3]

Term language

[edit]

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

M,N::=x(λx.M)(MN) where x ranges over term variables{\displaystyle {\begin{aligned}M,N&::=x\mid (\lambda x.\!M)\mid (M\;N)&&{\text{ where }}x{\text{ ranges over term variables}}\\\end{aligned}}}

Type language

[edit]

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

σ,τ::=αωστστ where α ranges over type variables{\displaystyle {\begin{aligned}\sigma ,\tau &::=\alpha \mid \omega \mid \sigma \to \tau \mid \sigma \cap \tau &&{\text{ where }}\alpha {\text{ ranges over type variables}}\end{aligned}}}

Intersection type subtyping

[edit]

Intersection typesubtyping(){\displaystyle (\leq )} is defined as the smallestpreorder (reflexive andtransitive 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{\displaystyle {\begin{aligned}&\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{aligned}}}

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

Typing rules

[edit]

Thetyping rules(I){\displaystyle (\to \!\!{\text{I}})},(E){\displaystyle (\to \!\!{\text{E}})},(I){\displaystyle (\cap {\text{I}})},(){\displaystyle (\leq )},(A){\displaystyle ({\text{A}})}, and(ω){\displaystyle (\omega )} of(BCD){\displaystyle (\vdash _{\text{BCD}})} are:

Γ,x:σBCDM:τΓBCDλx.M:στ(I)ΓBCDM:στΓBCDN:σΓBCDMN:τ(E)ΓBCDM:σΓBCDM:τΓBCDM:στ(I)ΓBCDM:σ(στ)ΓBCDM:τ()Γ,x:σBCDx:σ(A)ΓBCDM:ω(ω){\displaystyle {\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

[edit]

References

[edit]
  1. ^Henk Barendregt; Wil Dekkers; Richard Statman (20 June 2013).Lambda Calculus with Types. Cambridge University Press. pp. 1–.ISBN 978-0-521-76614-2.
  2. ^abcdeCoppo, Mario; Dezani-Ciancaglini, Mariangiola (1980)."An extension of the basic functionality theory for the λ-calculus".Notre Dame Journal of Formal Logic.21 (4):685–693.doi:10.1305/ndjfl/1093883253.S2CID 29748788.
  3. ^abcdeBarendregt, Henk; Coppo, Mario; Dezani-Ciancaglini, Mariangiola (1983). "A filter lambda model and the completeness of type assignment".Journal of Symbolic Logic.48 (4):931–940.doi:10.2307/2273659.JSTOR 2273659.S2CID 45660117.
  4. ^van Bakel, Steffen (2011). "Strict intersection types for the Lambda calculus".ACM Computing Surveys.43 (3): 20:1–20:49.CiteSeerX 10.1.1.310.2166.doi:10.1145/1922649.1922657.S2CID 5537689.
  5. ^"Intersection Types in TypeScript". Retrieved2019-08-01.
  6. ^"Compound Types in Scala". Retrieved2019-08-01.
  7. ^abPottinger, G. (1980). A type assignment for the strongly normalizable λ-terms. To HB Curry: essays on combinatory logic, lambda calculus and formalism, 561-577.
  8. ^abCoppo, Mario; Dezani-Ciancaglini, Mariangiola; Sallé, Patrick (1979). "Functional Characterization of Some Semantic Equalities inside Lambda-Calculus". In Hermann A. Maurer (ed.).Automata, Languages and Programming, 6th Colloquium, Graz, Austria, July 16-20, 1979, Proceedings. Vol. 71. Springer. pp. 133–146.doi:10.1007/3-540-09510-1_11.ISBN 3-540-09510-1.
  9. ^Coppo, Mario; Dezani-Ciancaglini, Mariangiola (1978). "A new type assignment for λ-terms".Archiv für mathematische Logik und Grundlagenforschung.19 (1):139–156.doi:10.1007/BF02011875.S2CID 206809924.
  10. ^Coppo, Mario; Dezani-Ciancaglini, Mariangiola; Venneri, Betti (1981). "Functional characters of solvable terms".Mathematical Logic Quarterly.27 (2–6):45–58.doi:10.1002/malq.19810270205.
  11. ^Kfoury, A.J.; Wells, J.B. (January 2004). "Principality and type inference for intersection types using expansion variables".Theoretical Computer Science:1–70.
  12. ^Terauchi, T., Aiken, A.: On typability for rank-2 intersection types with polymorphic recursion. In: LICS, IEEE Computer Society (2006) pp. 111–122
  13. ^Urzyczyn, Paweł (1999). "The emptiness problem for intersection types".Journal of Symbolic Logic.64 (3):1195–1215.doi:10.2307/2586625.JSTOR 2586625.S2CID 36979036.
  14. ^Urzyczyn, Paweł (2009). "Inhabitation of low-rank intersection types".International Conference on Typed Lambda Calculi and Applications. TLCA 2009. Vol. 5608. Springer. pp. 356–370.doi:10.1007/978-3-642-02273-9_26.ISBN 978-3-642-02272-2.
  15. ^Dudenhefner, Andrej; Rehof, Jakob (2019). "Principality and approximation under dimensional bound".Proceedings of the ACM on Programming Languages. POPL 2019. Vol. 3. ACM. pp. 8:1–8:29.doi:10.1145/3290321.ISSN 2475-1421.
  16. ^Fairouz Dib Kamareddine, Joe Wells "Intersection Types via Finite-Set declarations"https://arxiv.org/pdf/2405.00440 WoLLIC 2024
  17. ^Van Bakel, Steffen (1992). "Complete restrictions of the intersection type discipline".Theoretical Computer Science.102 (1):135–163.CiteSeerX 10.1.1.310.903.doi:10.1016/0304-3975(92)90297-S.
  18. ^Dudenhefner, Andrej; Martens, Moritz; Rehof, Jakob (2017). "The algebraic intersection type unification problem".Logical Methods in Computer Science.13 (3).arXiv:1611.05672.doi:10.23638/LMCS-13(3:9)2017.S2CID 31640337.
  19. ^Ghilezan, Silvia (1996)."Strong normalization and typability with intersection types".Notre Dame Journal of Formal Logic.37 (1):44–52.doi:10.1305/ndjfl/1040067315.
  20. ^Wells, J.B. (2003). "The Essence of Principal Typings".ICALP '02: Proceedings of the 29th International Colloquium on Automata, Languages and Programming. pp. 913–925.
  21. ^Ronchi Della Rocca, Simona; Venneri, Betti (1983)."Principal type schemes for an extended type theory".Theoretical Computer Science.28 ((1-2)):151–169.doi:10.1016/0304-3975(83)90069-5.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Intersection_type_discipline&oldid=1320905029"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp