Semantics of type theory

The semantics of type theory involves several closely related kinds 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.

There are several ways to package the structure of a model of type theory, including categories with families, comprehension categories, categories with attributes and contextual categories.[1] In all cases, a model is a base substrate, together with extra structure and requirements for each rule of the type theory under consideration.

Categories with families

Categories with families, introduced by Dybjer,[2] are a commonly used notion of model which stays relatively close to the syntax of type theory.

Introduction

The CwF structure is designed to closely parallel the syntax of type theory.

  • To each derivable syntactic judgment of the form “ is a context”, the semantics in a CwF associates an element of a set of contexts denoted .
  • To each derivable judgment “ is a type in context ” is associated an element of a set of types in context denoted . (Here depends on and not merely on although this dependency is dropped in the notation.)
  • To each derivable judgment “ is a term of type in context ” (usually denoted ) is associated an element of a set of terms of type in context , denoted .

The semantic interpretation of definitional equality is always actual equality in the model, so whenever a judgment “ and are definitionally equal types in context ” is derivable, the interpretation in the model must ensure , and whenever “ and are definitionally equal terms of type in context ” is derivable, the interpretation ensures .

A CwF contains operations to interpret contexts: a special element to model the empty context, and a context extension operation to model the addition of a new variable to a context.

The remaining data of CwFs serves to interpret the substitution operation necessitated by dependent types: if has the dependent function type where is a term involving the variable , the application of to a term has the type . CwFs use parallel substitutions, namely substitutions between entire contexts. If there were a judgment in the syntax which was directly interpreted by a substitution from to in the CwF, it would be “ is a list of terms in context , one for each type in , having this type with the previous variables from substituted by the previous terms in the list” (e.g., a parallel substitution from to in the syntax would be a term of type in context and a term of type in context ).

Definition

Let denote the category of families of sets.[a] An object of is a family where is a set and each is a set. A morphism in is a function together with, for each , a function . (This category is equivalent to the arrow category of , through the correspondence between a function and the family of sets .)

A category with families (CwF) consists of the following data:[3][4][5][2]

  • A category.

    The class of objects is denoted and the objects are called contexts. The class of morphisms from a context to a context is denoted and these morphisms are called substitutions from to .

  • A contravariant functor from this category to .

    The image of a context is a family of sets 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.

    Alternatively, this data can be packaged as a presheaf of types on the category of contexts, and a dependent presheaf of terms on the category of contexts over the presheaf of types.

  • A terminal object in the category of contexts.

    It is denoted and called the empty context.

  • For each context and for each type , consider the presheaf on the category of contexts which sends a context to the set of pairs of a substitution and a term . The functorial action of the presheaf on a substitution is given by . The last part of the CwF data is a representing object for this presheaf, together with a natural isomorphism witnessing the representation.

    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 .

    Explicitly, the fact that this is a natural isomorphism means that the following laws hold:

Defined operations

Let be a context and a type in . The head and tail of the identity substitution from to itself are respectively a substitution called weakening, and a term called the head variable. Informally, the weakening adds an unused variable to the context, and the head variable is the term given by the variable last declared in the context.

Observe that weakening and the head variable allow to recover the tail and head of any substitution by and

Furthermore, given a substitution , and a type , we define a lifted substitution by .

Extra structure for type formers

For each rule of a particular type theory, there is added structure and/or requirements on a CwF for it to model the type theory.

  • A rule which introduces a type or term former is interpreted by an operation returning a type or term of the CwF, which is required to commute with substitution. The latter requirement is necessary since substitution is defined recursively in the syntax, e.g., is .
  • A rule adding definitional equalities is interpreted by a requirement that the operations on the CwF satisfy a corresponding equation.

To illustrate this, consider the case of dependent pair types (Σ-types). The type formation rule is

The corresponding operation on a CwF is: for each , for each , and for each , a type . This operation is required to satisfy the substitution rule: for all substitution and types , we must have .

The term formation rules for the pairing operation is:

The corresponding operation on a CwF is: for each , , , and ), a term . This must satisfy the substitution rule:

This equation is meaningful because of the CwF laws and the substitution rule for . The left hand side is an element of , which by the substitution rule for is equal to . To see that the right hand side is in this set, one has to check that is in . This holds because is in and

while

Finally, the remaining rules for dependent pair types are the computation rules (or β-rules)

and the uniqueness rule (or η-rule)

These are interpreted by requiring the following equations on the previous operations:

  • and (for , , , , ),
  • (for , , , ).

Democracy

The basic intuition stemming from the syntax is that a context is a list of types , which is essentially equivalent to an iterated Σ-type . This is not true in all models, but it can be a useful property to consider.

A CwF is democratic when every context is isomorphic (in the category of contexts) to for some closed type (i.e., a type in the empty context ).[6]: 6 

The set model

The set model[4]: §3.5 [2]: 2 [3]: 24 [5]: §5 , or standard model, is the simplest model of type theory. Every construct is simply interpreted by its metatheoretic counterpart: a term of a function type is a function, a term of a product type is a pair, etc. (This is akin to the usual Tarskian semantics of first-order logic, and if one views type theory as a programming language, it is a metacircular interpreter.)

The CwF is defined as follows:

  • A context is a set and a substitution is a function (so the category of contexts and substitutions is the category of sets).
  • A type in is a family of sets , and a term of this type is a choice of an element for each . The action of a substitution on a type gives , and on a term , it gives .
  • The empty context is a fixed singleton set.
  • The extension of a context by a type is the type of pairs of an and an element of . The tail and head of a substitution are given by and .

All type formers are defined “pointwise”. For example, the product is defined as , the pairing of terms and is , etc. This model supports essentially any type former supported by the metatheory (with the exception of universes: the metatheory needs a stronger universe than the object theory contains, namely a universe large enough to contain all universes from the object theory, as is expected from Gödel's second incompleteness theorem). It can model the equality reflection rule of extensional type theory, but not univalence.

The syntactic model

The syntactic model (or term model) is given by the contexts, parallel substitutions, types and terms in the syntax of the type theory under consideration, with the operations induced by all type and term constructors of the type theory.

For “reasonable” type theories, the syntactic model is also the initial model, which means that it has a unique morphism into every other model. The notion of morphism between models is usually defined by presenting the definition of a model as a generalized algebraic theory (GAT) (which is like an algebraic theory but allowing dependent functions), and applying the standard definition of morphism between algebras of a GAT. The initiality means that the syntax can indeed be interpreted in every model as expected. Actually establishing this turns out to be very tedious. While Cartmell and Hofmann proved it for some standard type theories, initiality became a contentious point in the research community around 2015 when some researchers, notably Voevodsky, opined that it was not justified to treat it as established for different type theories without carefully adapting the proofs. Most researchers consider the issue to have been satisfactorily solved by Uemura's introduction of the logical framework of second-order generalized algebraic theories (SOGATs), which encompasses practically all existing type theories (the main exception being substructural type theories), and his proof of initiality of the syntactic model for any SOGAT.[7]

Meanwhile, it has also become common to eschew the traditional syntactic presentation of type theory entirely and define the syntax as the initial model (which exists for any GAT). This approach is called intrinsic syntax. At this level of abstraction, it is possible to construct and study models and to use type theory as an internal language for them (treating the traditional terms merely as a notation for elements of the model). It is not possible to study properties of the concrete, extrinsic syntax such as subject reduction and confluence. However, remarkably, the two main syntactic properties of some type theories, canonicity and normalization, can be stated and proved entirely at this level.[8][9][10]

Presheaf models

Let be a category. The presheaf category is equipped with a canonical CwF structure as follows.[3]: 45 

A type in context is a dependent presheaf on over . This means the following data:

  • For each object , and for each element , a set ,
  • For each morphism in , and for each element , a function .

This data is subject to a functoriality requirement: and .

Alternatively, can be viewed as a presheaf on the category of elements of .

For a natural transformation , the substituted type is defined by precomposition: it maps an object and an element to , and it maps a morphism in and an element to the function .

A term of type in context consists of, for each object and for each element , an element , such that these choices are natural: for in and , we should have .

Other models

Other models of type theory include the setoid model,[citation needed] the groupoid model,[11] the simplicial set model,[12] the assemblies model,[citation needed] and several models in cubical sets starting with the BCH (Bezem–Coquand–Huber) model.[13]

Relationship to categorical logic

Traditional categorical logic involves correspondences between logics and kinds of categories which serve as their models. For example, elementary toposes are models of a form of intuitionistic higher-order logic, and regular categories are models of regular logic. The correspondence is used in both ways: a notion of model is fundamental to study a logic, e.g., to prove that a statement is unprovable by finding a model where it fails, and conversely, a category can be studied by reasoning in a logic of which it is a model, which is often called an internal language for the category.

For simple type theory, such correspondences can be found. For example, Cartesian closed categories model the simply typed λ-calculus with function, top and product types, and bicartesian closed categories model its extension with bottom and sum types. On the other hand, the situation is significantly more complicated for dependent type theory.

In the aforementioned semantics of simple type theory, a type is interpreted by an object of the category. In dependent type theory, a type depends on the value of the context in which it is defined, so one cannot simply use an object. Instead, a natural idea is to interpret a type in context by an object equipped with a morphism to the interpretation of . The idea is to mimic the category of sets, where a family of sets can be represented categorically as the morphism , where is the disjoint union of all the , which sends elements of each to their index . The family can be recovered by .

This idea was used by Seely in a 1984 paper claiming that Martin–Löf type theory with Π types, Σ types and extensional identity types can be modelled in a locally Cartesian closed category (i.e., a category such that all the slice categories are Cartesian closed).[14] However, it was later observed that Seely's proof is wrong. Substitution in types is modelled by pullback. For the interpretation of substitution to be sound, this operation must be strictly functorial way: pullback along must be exactly the same as pullback along followed by pullback along . However, pullback involves an arbitrary choice and there is no reason for all these choices to be globally coherent: these pullbacks are always isomorphic, but have no reason to be the same. (Taking a skeleton of does not help, since a pullback is not merely a choice of object but also a choice of morphisms.)

For example, call the successor constructor of natural numbers, and consider the trivial proof that for a predicate , if holds, holds, and holds for all (call this hypothesis ), then for all . This is done by two inductions: the first reduces to proving where is a fresh variable, and the second reduces this to proving where is fresh. By applying the hypothesis to (noting that ), one obtains an element of . This only works because in the syntax of type theory, the substituted types and are the same, namely . On the other hand, using the interpretation of substitution as pullback, the interpretations of these two types would only be isomorphic and it would not be semantically justified to use elements of one as elements of the other.

The same problem arises with the interpretation of type formers, which must commute with substitution, whereas this fails in Seely's purported model. For example, given a dependent function , the application has type . Without an actual equality between this type and , it is not semantically justified to apply the first projection to to obtain an element of .

For this reason, type theory is not modelled directly in categories with properties, but rather in categories enriched with structure, such as CwFs, which include a set of types for each context and a substitution operation on types required to be functorial. The usual way to define a model is to start from a category with good enough properties and define this structure analogously to categorical constructions, but taking care to preserve coherence. This process is sometimes referred to as strictification.

There are several strictification constructions for doing this in general. A construction due to Bénabou was used by Hofmann to interpret MLTT in any locally Cartesian closed category, thus repairing Seely's result (with a different semantic interpretation).[15][6] More recently, Lumsdaine and Warren proposed the local universes construction, which delays computing pullbacks by modelling a type in as two objects and with a pair of morphisms , so that applying a substitution can be simply performed by composition of with , which is functorial.[16][4]: §6.5.5 

However, in most concrete cases, the strictification can be done by hand, and the result is simpler to work with than the output of such general constructions. For example, in the set model, types in context are defined as the actual families of sets rather than a functions so that the application of a substitution can simply be the family . This definition of substitution is strictly functorial, unlike pullback in the category of sets. The presheaf model is another typical example: substitution is made functorial by replacing presheaves with a natural transformation to by dependent presheaves over .

Footnotes

  1. ^ This is an abuse of language since most CwFs such as the set model use collections too large to be sets as “objects” of this category. Formally, this article should be read as assuming a sequence of Grothendieck universes and taking each occurrence of the word “set” to mean a set in an appropriate universe.

References

  1. ^ Categorical semantics of dependent type theory at the nLab
  2. ^ a b c Dybjer, Peter (1996). "Internal type theory" (PDF). Types for Proofs and Programs. TYPES 1995. Springer Berlin Heidelberg. pp. 120–134. doi:10.1007/3-540-61780-9_66. ISBN 9783540707226. ISSN 1611-3349.
  3. ^ a b c Hofmann, Martin (1997). "Syntax and semantics of dependent types". Extensional constructs in intensional type theory. London: Springer. pp. 13–54. doi:10.1007/978-1-4471-0963-1_2. ISBN 978-1-4471-0963-1.
  4. ^ a b c Gratzer, Daniel; Angiuli, Carlo. Principles of dependent type theory (PDF). Retrieved 2025-11-21.
  5. ^ a b Gratzer, Daniel. "Denotational semantics of type theory" (PDF).
  6. ^ a b Clairambault, Pierre; Dybjer, Peter (2014). "The biequivalence of locally Cartesian closed categories and Martin-Löf type theories". Mathematical Structures in Computer Science. 24 (6). arXiv:1112.3456. doi:10.1017/S0960129513000881.
  7. ^ Initiality conjecture at the nLab
  8. ^ Coquand, Thierry (2019). "Canonicity and normalization for dependent type theory". Theoretical Computer Science. 777: 184–191. arXiv:1810.09367. doi:10.1016/j.tcs.2019.01.015.
  9. ^ Kaposi, Ambrus (2017). Type theory in a type theory with quotient inductive types (PDF) (PhD thesis). University of Nottingham.
  10. ^ Sterling, Jonathan (2021). First steps in synthetic Tait computability: the objective metatheory of type theory (PhD thesis). Carnegie Mellon University. doi:10.5281/zenodo.6990769.
  11. ^ Hofmann, Martin; Streicher, Thomas (1994). "The groupoid model refutes uniqueness of identity proofs". Proceedings of the Ninth Annual IEEE Symposium on Logic in Computer Science (LICS 1994). LICS 1994. IEEE Computer Society Press. pp. 208–212.
  12. ^ Kapulkin, Chris; LeFanu Lumsdaine, Peter (2012). "The simplicial model of univalent foundations (after Voevodsky)". Journal of the European Mathematical Society. arXiv:1211.2851. doi:10.4171/JEMS/1050.
  13. ^ Bezem, Marc; Coquand, Thierry; Huber, Simon (2014). "A model of type theory in cubical sets". In Matthes, Ralph; Schubert, Aleksy (eds.). 19th International Conference on Types for Proofs and Programs (TYPES 2013). TYPES 2013. Leibniz International Proceedings in Informatics (LIPIcs). Vol. 26. Schloss Daghstuhl — Leibniz Zentrum für Informatik. pp. 107–128. ISBN 978-3-939897-72-9. ISSN 1868-8969.
  14. ^ Seely, Robert A. G. (1984). "Locally cartesian closed categories and type theory". Mathematical Proceedings of the Cambridge Philosophical Society. 95 (1): 33–48. doi:10.1017/S0305004100061284.
  15. ^ Hofmann, Martin (1995). On the interpretation of type theory in locally Cartesian closed categories. CSL 1994. doi:10.1007/BFb0022273.
  16. ^ LeFanu Lumsdaine, Peter; Warren, Michael A. (2015). "The local universes model: an overlooked coherence construction for dependent type theories". ACM Transactions on Computational Logic. 16 (3): 1–31. arXiv:1411.1736. doi:10.1145/275493.

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.