Semantics of type theory
The semantics of type theory involves several closely related types of models, which are constructed and studied in order to justify axioms and new type theories, and to use type theory as an internal language for categories, higher categories and other mathematical structures.
Categories with families
Categories with families, introduced by Dybjer,[1] are a commonly used notion of model which stays relatively close to the syntax of type theory. They form a base substrate consisting of a substitution calculus, onto which extra structure is added for each type former supported by the type theory considered.
Let denote the category of families of sets: an object is a family where each is a set, and a morphism is a function together with, for each , a function . (This category is equivalent to the arrow category of through the functor that sends a function to the family , with the natural action on morphisms.)
A category with families (CwF) consists of the following data:[2][3][4][1]
- A category, whose class of objects is denoted and whose class of morphisms from to is denoted . The objects are called contexts and the morphisms are called substitutions.
- A contravariant functor from the category of contexts to . The image of a context is denoted (we usually drop the subscript in ). The elements of are called types in context , and the elements of are called terms of type (in context ). The image of a substitution is a morphism in . Its component is denoted by , and for each , its component is also denoted . These operations are respectively called substitution in types and substitution in terms. The functoriality means that the following laws hold: , , , .
- A terminal object in the category of contexts, called the empty context and denoted . (Some authors omit this requirement.[5])
- For each context and for each type , a representing object for a certain presheaf on contexts, together with a natural isomorphism witnessing that this object represents it. This presheaf sends a context to the set of pairs of a substitution and a term , and its action on a substitution is given by . The representing context is denoted and called the context extension of by . In one direction, the natural isomorphism sends a substitution and a term to a new substitution called the substitution extension of by . In the other direction, it sends a substitution to a pair of its tail and its head term . The fact that this is a natural isomorphism means that the following laws hold for , , , :
Given a context and a type , we define the weakening substitution by , and the last variable by . Observe that for every substitution , we have
Furthermore, given contexts , a substitution , and a type , we define a lifted substitution by .
To interpret type formers, the following structures are added on top of a CwF.
For the unit type:
- For each context , a type , with the requirement that for every substitution . (This can be replaced with a type in the empty context , although the previous definition does not require the CwF to have a terminal object for the empty context.) This interprets the inference rule for type formation of the unit type in Martin-Löf type theory:
- For each context , a term , with the requirement that for every substitution . This interprets the introduction rule
- For each context , for each type , for each term , and for each term , a term , with the requirement that for every substitution . This interprets the elimination rule
- A requirement that for all context , type and term . This interprets the computation rule
- Optionally, a requirement that for all context and term , if the type theory contains the uniqueness rule (η-rule)
For the empty type:
- For each context , a type , with the requirement that for every substitution . This interprets the type formation rule
- For each context , for each type , for each term , a term , with the requirement that for every substitution . This interprets the elimination rule
For the type of booleans:
- For each context , a type , with the requirement that for every substitution . This interprets the type formation rule
- For each context , terms , with the requirement that and for every substitution . This interprets the introduction rules
- For each context , for each type , for each term and term , and for each term , a term , with the requirement that for all substitution . This interprets the elimination rule
- A requirement that and for all context , type and terms and . This interprets the computation rules
For the type of natural numbers:
- For each context , a type , with the requirement that for every substitution . This interprets the type formation rule
- For each context , a term , with the requirement that for every substitution ; additionally, for each context and term , a term , with the requirement that for all substitution . This interprets the introduction rules
- For each context , for each type , for each term and term , and for each term , a term , with the requirement that for every substitution . This interprets the elimination rule
- A requirement that for all , , , as above, and moreover that when additionally . This interprets the computation rules
For binary product types:
- For each context , for each types , a type , with the requirement that for every substitution . This interprets the type formation rule
- For each context , for each types , for each term and term , a term , with the requirement that for every substitution . This interprets the introduction rule
- For each context , for each types , for each type , for each term where , , , , for each term , a term , with the requirement that for every substitution . This interprets the elimination rule
- A requirement that for all , , , as above and , . This interprets the computation rule
Other kinds of models
Notions of models other than categories with families include comprehension categories, categories with attributes and contextual categories.[5]
Main models
Models of type theory include the standard model (or set model),[2][4], the term model (or syntactic model, or initial model),[2][4], the setoid model,[citation needed] the groupoid model,[6] the simplicial set model,[7] and several models in cubical sets starting with the BCH (Bezem–Coquand–Huber) model.[8]
References
- ↑ 1.0 1.1 Dybjer, Peter (1996). "Internal type theory". TYPES 1995. Springer Berlin Heidelberg. pp. 120–134. doi:10.1007/3-540-61780-9_66. ISBN 9783540707226. https://www.cse.chalmers.se/~peterd/papers/InternalTT.pdf.
- ↑ 2.0 2.1 2.2 Hofmann, Martin (1997). "Syntax and semantics of dependent types". Extensional constructs in intensional type theory. London: Springer. doi:10.1007/978-1-4471-0963-1_2. ISBN 978-1-4471-0963-1.
- ↑ Gratzer, Daniel; Angiuli, Carlo. Principles of dependent type theory. https://www.danielgratzer.com/papers/type-theory-book.pdf. Retrieved 2025-11-21.
- ↑ 4.0 4.1 4.2 Gratzer, Daniel. "Denotational semantics of type theory". https://www.danielgratzer.com/papers/2023-semantics-primer-lecture-notes.pdf.
- ↑ 5.0 5.1 Categorical semantics of dependent type theory in nLab
- ↑ Hofmann, Martin; Streicher, Thomas (1994). "The groupoid model refutes uniqueness of identity proofs". LICS 1994. IEEE Computer Society Press.
- ↑ Kapulkin, Chris; LeFanu Lumsdaine, Peter (2012). "The simplicial model of univalent foundations (after Voevodsky)". Journal of the European Mathematical Society. doi:10.4171/JEMS/1050.
- ↑ Bezem, Marc; Coquand, Thierry; Huber, Simon (2014). "A model of type theory in cubical sets". TYPES 2013. 26. Schloss Daghstuhl — Leibniz Zentrum für Informatik. ISBN 978-3-939897-72-9. https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.TYPES.2013.107.
