Math 2.0

Computer science Definition

Subtyping

Builds on Simply typed lambda calculusType systemPreorder

Definition

Consider a type system with a typing relation Γ⊢t:T\Gamma \vdash t : T, such as the simply typed lambda calculus extended with record types {l1:T1,…,ln:Tn}\set{l_1 : T_1, \dots, l_n : T_n} with distinct labels lil_i. A subtyping relation is a relation S<:TS <: T on types that is closed under these rules.

  1. Reflexivity: T<:TT <: T.
  2. Transitivity: if S<:US <: U and U<:TU <: T, then S<:TS <: T.
  3. Functions: if T1<:S1T_1 <: S_1 and S2<:T2S_2 <: T_2, then S1→S2<:T1→T2S_1 \to S_2 <: T_1 \to T_2.
  4. Records: {l1:S1,…,ln:Sn}<:{k1:T1,…,km:Tm}\set{l_1 : S_1, \dots, l_n : S_n} <: \set{k_1 : T_1, \dots, k_m : T_m} if each label kjk_j equals some label lil_i, and Si<:TjS_i <: T_j for that ii.

The type system is linked to <:<: by the subsumption rule: if Γ⊢t:S\Gamma \vdash t : S and S<:TS <: T, then Γ⊢t:T\Gamma \vdash t : T. The relation <:<: is usually taken to be the least relation closed under the rules, together with chosen relations between base types, such as 𝖨𝗇𝗍<:𝖱𝖾𝖺𝗅\mathsf{Int} <: \mathsf{Real}.

Remarks

Example: {x:𝖨𝗇𝗍,y:𝖨𝗇𝗍}<:{x:𝖨𝗇𝗍}\set{x : \mathsf{Int}, y : \mathsf{Int}} <: \set{x : \mathsf{Int}} by rule 4, since the label xx occurs on the left and 𝖨𝗇𝗍<:𝖨𝗇𝗍\mathsf{Int} <: \mathsf{Int} by rule 1. So a function of type {x:𝖨𝗇𝗍}→𝖨𝗇𝗍\set{x : \mathsf{Int}} \to \mathsf{Int} may be applied to a point with two coordinates.

Non-example: with 𝖨𝗇𝗍<:𝖱𝖾𝖺𝗅\mathsf{Int} <: \mathsf{Real}, one does not get 𝖨𝗇𝗍→𝖨𝗇𝗍<:𝖱𝖾𝖺𝗅→𝖨𝗇𝗍\mathsf{Int} \to \mathsf{Int} <: \mathsf{Real} \to \mathsf{Int}. Rule 3 would need 𝖱𝖾𝖺𝗅<:𝖨𝗇𝗍\mathsf{Real} <: \mathsf{Int}, which fails; and indeed a function defined only on integers cannot accept every real. The opposite inclusion 𝖱𝖾𝖺𝗅→𝖨𝗇𝗍<:𝖨𝗇𝗍→𝖨𝗇𝗍\mathsf{Real} \to \mathsf{Int} <: \mathsf{Int} \to \mathsf{Int} does hold.

By rules 1 and 2, subtyping is a preorder on types. Rule 3 says that the arrow is contravariant in its argument and covariant in its result.

Reading path

To understand this page from the ground up, read these 26 pages in order. The foundations come first.

Show the path as a graph
Element, definition, no evidence levelElementdefinitionIntuitionistic logic, concept, no evidence levelIntuitionistic logicconceptLambda calculus, concept, no evidence levelLambda calculusconceptPreorder, concept, no evidence levelPreorderconceptProposition, concept, no evidence levelPropositionconceptSet, concept, no evidence levelSetconceptType system, concept, no evidence levelType systemconceptSet, definition, no evidence levelSetdefinitionConjunction, definition, no evidence levelConjunctiondefinitionDisjunction, definition, no evidence levelDisjunctiondefinitionImplication, definition, no evidence levelImplicationdefinitionNegation, definition, no evidence levelNegationdefinitionBiconditional, definition, no evidence levelBiconditionaldefinitionTruth table, concept, no evidence levelTruth tableconceptModus ponens, concept, no evidence levelModus ponensconceptMathematical proof, concept, no evidence levelMathematical proofconceptPropositional logic, concept, no evidence levelPropositional logicconceptTautology, definition, no evidence levelTautologydefinitionLogical equivalence, definition, no evidence levelLogical equivalencedefinitionDouble negation law, statement, no evidence levelDouble negation lawstatementProof by contradiction, concept, no evidence levelProof by contradictionconceptRussell's paradox, statement, no evidence levelRussell's paradoxstatementType theory, concept, no evidence levelType theoryconceptCurry–Howard correspondence, concept, no evidence levelCurry–Howard correspo…conceptSimply typed lambda calculus, concept, no evidence levelSimply typed lambda c…conceptSubtyping, definition, no evidence levelSubtypingdefinition
Each page uses the pages above it. The colour of the bar on a box shows how strong the evidence is, and the box also gives it as text. The list has the same pages.
  • no evidence level
  1. Element definition
  2. Intuitionistic logic concept
  3. Lambda calculus concept
  4. Preorder concept
  5. Proposition concept
  6. Set concept
  7. Type system concept
  8. Set definition
  9. Conjunction definition
  10. Disjunction definition
  11. Implication definition
  12. Negation definition
  13. Biconditional definition
  14. Truth table concept
  15. Modus ponens concept
  16. Mathematical proof concept
  17. Propositional logic concept
  18. Tautology definition
  19. Logical equivalence definition
  20. Double negation law statement
  21. Proof by contradiction concept
  22. Russell's paradox statement
  23. Type theory concept
  24. Curry–Howard correspondence concept
  25. Simply typed lambda calculus concept
  26. Subtyping definition

Further reading

  1. Web https://en.wikipedia.org/wiki/Subtyping
About this page
TagHSP09EW4V3
URIm2://HSP09EW4V3
Kinddefinition
WritingW0 stub
MSC68N15, 03B40
DefinesSubtyping
UsesSimply typed lambda calculus, Type system, Preorder
Changed3 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)
  • a source with a locator (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.