natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory
In the relation between type theory and category theory, dependent types (in dependent type theory) have categorical semantics given by morphisms which are the bundles whose fibers are the families indexed by the base (see also at dependent type – Relation to families of elements).
More concretely: if a type interprets as an object in some category , then an -dependent type
interprets as a morphism in (hence as an object in the slice category ). We may think of this morphism as a bundle or fibration, whose fiber over is the type . We can then say that type forming operations such as dependent sum type and dependent product type correspond to category-theoretic operations of dependent sum and dependent product.
However, this correspondence is not quite precise; in the case of dependent types there are extra coherence issues. Substitution in type theory should correspond to pullback in category theory (but see at substitution – Categorical semantics for more); that is, given a term
corresponding to a morphism , the substituted dependent type
should correspond to the pullback of along . However, substitution in type theory is strictly associative. That is, given also , the dependent type
is syntactically the same regardless of whether we obtain it by substituting into , or into . In category theory, however, pullback is not generally strictly associative, so there is a mismatch. Similarly, every type-forming operation must also be strictly preserved by substitition/pullback.
The way this is generally dealt with is to introduce a category-theoretic structure which does have a “substitution” operation which is strictly associative, hence does correspond directly to type theory, and then show that any category can be “strictified” into such a stricter structure. Unfortunately, there are many different such structures which have been used, differing only slightly. On this page we define and compare them all.
One of these structures is called “contextual categories” (definition below).
This and other kinds of categories-with-extra-structure may hence be thought of as stand-ins for the syntax of a type theory:
Rather than constructing an interpretation of the syntax directly, we may work via the intermediary notion of contextual categories, a class of algebraic objects abstracting the key structure carried by the syntax. The plain definition of a contextual category corresponds to the structural core of the syntax; further syntactic rules (logical constructors, etc.) correspond to extra algebraic structure that contextual categories may carry. Essentially, contextual categories provide a completely equivalent alternative to the syntactic presentation of type theory.
Why is this duplication of notions desirable? The trouble with the syntax is that it is mathematically tricky to handle. Any full presentation must account for (among other things) variable binding, capture-free substitution, and the possibility of multiple derivations of a judgement; and so a direct interpretation must deal with all of these, at the same time as tackling the details of the particular model in question. By passing to contextual categories, one deals with these subtleties and bureaucracy once and for all, and obtains a clear framework for subsequently constructing models. Conversely, why not work only with contextual categories, dispensing with syntax entirely?
The trouble on this side is that working with higher-order logical structure in contextual categories quickly becomes unreadable. The reader preferring to take contextual categories as primary may regard the syntax as essentially a notation for working within them: a powerful, flexible, and intuitive notation, but one whose validity requires non-trivial work to establish. (The situation is comparable to that of string diagrams, as used in monoidal and more elaborately structured categories.)
(from Kapulkin-Lumsdaine 12)
In all the definitions, will be a category. Generally, we will regard the objects of as contexts in a type theory.
So far, we do not assume anything about as a category. Usually, one at least wants to have a terminal object, representing the empty context, although this is not always included in the definitions. The additional structures we impose on below will imply in particular that certain pullbacks exist in .
Sometimes, we want to consider as a strict category, that is, we consider its objects up to equality rather than isomorphism. However, for most of the definitions below (until we get to contextual categories), it is still sensible to treat in an ordinary category-theoretic way, with the strictness living in the additional structure.
All of this could be made more precise by assembling the structures considered below into categories, 2-categories, and/or strict 2-categories.
A comprehension category consists of a strictly commutative triangle of functors
where is the arrow category of and denotes the codomain projection (which is a fibration if has pullbacks), and such that
is a Grothendieck fibration,
takes cartesian morphisms in to cartesian morphisms in (i.e. to pullback squares in ).
In def we do not ask that be a fibration (that would require to have all pullbacks), only that the particular morphisms in the image of are cartesian.
A comprehension category (def. ) is called
full if is a fully faithful functor.
split if is a split fibration.
In the latter case, we must consider at least to be a strict category (that is, we consider its objects up to equality rather than isomorphism) for the notion to make sense.
The interpretation of def. is as follows:
In a comprehension category, we may regard the objects of as contexts, and the fiber of over an object as the category of dependent types in context . If the comprehension category is split (def. ), then such dependent types have strictly associative substitution.
The functor assigns to each “type in context ” a new context which we think of as extended by a fresh variable of type , and write as . This new context comes with a projection (which forgets the fresh variable), and all substitutions in are realized as pullbacks in .
A display map category consists of a category together with a class of morphisms in , called display maps, such that all pullbacks of display maps exist and are themselves display maps.
If is a display map category, then by defining to be the full subcategory of whose objects are display maps, we obtain a full comprehension category (def. ). Thus, we have:
Display map categories (def. ) may be identified with those comprehension categories, def. , for which the functor is the inclusion of a full subcategory.
Working up to equivalence of categories, as is usual in category theory, it is natural to consider display map categories to also be equivalent to full comprehension categories, def. , (those where is merely fully faithful).
However, this breaks down when we are interested in split comprehension categories, def. , for modeling substitution with strict associativity, since then at least must be regarded as a strict category and considered up to isomorphism rather than equivalence. Thus, display map categories may be said to be equivalent to non-split full comprehension categories, but “split display map categories” are not equivalent to split full comprehension categories. (In fact, split display map categories are not very useful; usually in order to make pullbacks strictly associative we have to introduce extra “names” for the same objects.)
A category with attributes is a comprehension category, def. , for which is a discrete fibration.
That is, in a category with attributes (def. ) we demand only that each context comes with a set of dependent types in that context, rather than a category of such. The intent is that the morphisms between two types in context should be determined by the morphisms in between the extended contexts over .
Another way to convey this same intent with a comprehension category would be to ask that it be full, def. , i.e. that the functor be fully faithful.
In fact, any category with attributes gives rise to a full comprehension category by factoring the functor into a bijective on objects functor followed by a fully faithful functor. In this way, we obtain:
The category of categories with attributes (def. ) is equivalent to the category of full split comprehension categories (def. ).
(These are, however, quite different as subcategories of .)
A category with attributes specifies for each “context” only a set of “types” in that context. A comprehension category, by contrast, specifies a whole category of “types” in each context. If , then we may think of a morphism in as a term
in type theory.
A category with families specifies instead, for each context and each type in that context, a set of “terms belonging to that type”. These should be thought of as terms
in type theory.
A term of the form (1) can equivalently be regarded as a term of the form (2) by replacing by the extended context , and by its substitution along the projection .
The additional insight in the following definition is that if we expect all of these terms to be determined by the morphisms in , as in a category with attributes or a full comprehension category, then instead of specifying the functor and then asking either that it be fully faithful or that be discrete (removing the information about extra morphisms in ), if we specify the terms of the form (2), then the functor is determined by a universal property.
Let denote the category of families of sets. Its objects are set-indexed families , and its morphisms consist of a function and functions . We can equivalently, of course, regard this as the arrow category of Set, where corresponds to the arrow .
A category with families is a category together with
A functor , written .
For each and , a representing object for the functor
Intuitively, is the set of terms in the context indexed by their type, and the representing object for the map is the projection from context to context .
We can then prove:
Given a category with families, let be the Grothendieck construction of the functor , and let take each to the above representing object. This is a category with attributes.
Conversely, given a category with attributes, let be the functor corresponding to the discrete fibration , and for let be the set of sections of the morphism in that is the image of in . These constructions are inverses up to isomorphism.
Awodey 2016 presented the following “natural model” of type theory as an alternative to categories with families.
If we modify Def. by requiring only that the functors be representable (rather than equipped with representing objects), then it is equivalent to giving
The category models the category of contexts and substitutions, and the morphism models the bundle of (context-dependent) terms over (context-dependent) types. The representability models the extension of a context with a new typed variable.
The condition that is a representable morphism in presheaves can be reformulated in terms of adjoints as follows: is representable just if the associated functor has a right adjoint. Thus a natural model can be equivalently described as a category equipped with a natural transformation of presheaves for which has a right adjoint.
This specification can be related to that of a , by reformulating the representability of the morphism in terms of representable profunctors as follows. A natural model is equivalently described as:
Writing the profunctor as P, it is equivalent to the following definition:
then the universal property of the context extension is that there is a natural isomorphism
Taichi Uemura introduced categories with representable maps? as a functorial semantics approach to type theory generalizing the notion of a Category with Families/Natural Model. A category with representable maps (CwR) is a category with finite limits with a specified class of “representable” arrows that are pullback-stable and exponentiable. The motivating examples are presheaf categories where the representable arrows are the representable morphisms in the usual sense. Then any CwR can be considered to be a type theory: for instance, the free CwR with a representable map has as models precisely the natural models, and so can be thought of as the embodiment of the judgments of Martin-Lof Type Theory (with no connectives).
Recall that
If is a comprehension category (def. ), is a “context” and is a “type” in context , then we denote by the “extended context” in (remark ).
A contextual category (Cartmell 86, Streicher 91) or C-system (Voevodsky 15) is a category with attributes (def. ) together with a length function such that
Since def. refers to equality of objects, a contextual category must be a strict category.
The idea which distinguishes a contextual category is that “every context must be built out of types” in a unique way.
This makes for the closest match with type theory; in fact we have:
The category of contextual categories, def. , and (strictly) structure-preserving functors is equivalent to the category of dependent type theories and interpretations?.
Since contextual categories are strict categories, the category of such is really a 1-category, or perhaps a strict 2-category.
Given any category with attributes , def. , possessing a terminal object, there is a canonical way to build a contextual category , def. , from it.
Choose a terminal object (the resulting contextual category does not depend on this choice, up to isomorphism).
The objects of are the finite lists
such that and for all .
The morphisms in are the morphisms in .
All the rest of the structure on is induced in an evident way from . This construction is in fact right adjoint to the inclusion of contextual categories in categories with attributes; see Kapulkin-Lumsdaine, Proposition 4.4.
Comprehension categories and display map categories are easy to come by “in nature”, but it is more difficult to find examples of the “split” versions of the above structure (which are what is needed for modeling type theory). Here we summarize some basic known constructions.
However, first we should mention the examples that come from type theory itself.
The syntactic category of any dependent type theory has all of the above structures. Its objects are contexts in the theory, and the types in context form the set or category . The strict associativity of substitution in type theory makes this fibration automatically split.
There are standard constructions which can replace any Grothendieck fibration by an equivalent split fibration. Therefore,
Of course, comprehension categories are easy to come by; perhaps they arise most commonly as display map categories. For instance, if has all pullbacks, then we can take all maps to be display maps. If is a category of fibrant objects, we can take the fibrations to be the display maps.
So, for the record, we have in particular:
For a locally cartesian closed category , it becomes a model for dependent type theory by regarding its codomain fibration as a comprehension category, def. , and then strictifying that as in example .
It turns out that for modeling additional type-forming operations, however, not all splitting constructions are created equal.
Given , one construction due to Benabou (called the “right adjoint splitting”), defines , where the objects of over are functors over which map every morphism of to a cartesian arrow. Type-theoretically, we can think of such an object as a type together with specified compatible substitutions along any possible morphism. That type-formers may be extended in this case was proven by Martin Hofmann for dependent sums and dependent products and the identity types of extensional type theory. But this is not generally possible for the identity types of intensional type theory (particularly not their eliminator), which do not have a 1-categorical universal property and hence are not stable under pullback up to isomorphism.
A different construction (due to John Power, called the “left adjoint splitting”) defines an object of over to consist of a morphism in along with an object of over . Type-theoretically, we can regard as a type with a “delayed substitution” . This produces a split fibration (the chosen cartesian arrows are given by composition of morphisms in ), and it was proven by Lumsdaine & Warren (2015) that essentially all type formers can be extended to it from .
Suppose given a particular morphism in . We can then define a category with attributes, def. , as follows: the discrete fibration corresponds to the representable presheaf , and the functor is defined by pullback of . We are thus treating as a “universe” of types. We may then of course pass to a contextual category, via example .
Type-forming operations may be extended strictly in this case by performing them once in the “universal” case, then acting by composition. This construction is due to Voevodsky. It also meshes quite well with type theories that contain internal universes – a type of types– , and in particular for modeling the univalence axiom.
Particular important universes include:
Any Grothendieck universe in Set, or more generally a universe in a topos. The resulting display maps are those with “-small fibers”.
In the category Gpd, the groupoid of small groupoids. The resulting display maps are the split opfibrations with small fibers. Similarly, we can consider the groupoid of small sets, whose display maps are the discrete opfibrations with small fibers.
In the category sSet of simplicial sets, there is a universal Kan fibration which classifies all Kan fibrations with small fibers.
Let be any category with finite products, and define to be the discrete fibration corresponding to the presheaf which is constant at . Thus, the objects of are pairs of objects of , with the only morphisms being of the form induced by a morphism in .
Define the functor to take to the projection . It is straightforward to check that this defines a category with attributes. The corresponding (split) full comprehension category is called the simple fibration of .
The dependent type theory which results from this structure “has no nontrivial dependency”. That is, whenever we have a dependent type , it is already the case that is a type in the empty context (that is, we have ), and so it cannot depend nontrivially on . In effect, it is not really a dependent type theory, but a simple (non-dependent) type theory — hence the name “simple fibration”.
Ignoring coherence issues, the CwF induced by a locally cartesian closed (lcc) category (example ) is given explicitly by the “Explicit” column of the following table:
In : Explicit | In terms of slices of | Big model | |
---|---|---|---|
Contexts | Objects | Slice categories | Lcc categories |
Context Morphisms | Morphisms | Lcc functors over | Lcc functors |
Types | Morphisms | Objects | Objects |
Terms | Sections | Morphisms in | Morphisms in , where is a terminal object. |
Substitution | Pullback along | Application of | Application of |
The next column describes the same CwF in the terminology of slice categories: Every object of corresponds to a slice category over , and is also lcc. Every morphism in induces a pullback functor . preserves the finite limits and dependent products of (i.e. it is an lcc functor), and the diagram
commutes (up to unique isomorphism). Conversely, every lcc functor under is uniquely isomorphic to the pullback functor along some morphism .
The last column describes the big model of type theory in the opposite category of lcc categories and lcc functors. Since the contexts of this model are itself models of type theory, it can be understood as a “model of models”. The definition of the big model can be arrived at by removing all reference to the fixed lcc category in the previous column. Instead of just the slice categories of , now all lcc categories are allowed as contexts. Context morphisms are generalized to general lcc functors instead of just the pullback functors of . The identity morphism on an object of is a terminal object in the slice category and is thus generalized to a terminal object in any lcc category.
The usual model in a fixed lcc category can be recovered from the big model by slicing: The contextual core (example ) of the slice of the big model over is equivalent to .
However, the naive definition of the big model above suffers from the same coherence issues as the standard models in individual lcc categories: Lcc functors preserve lcc structure (i.e. type formers) up to isomorphism, but not necessarily up to equality. These coherence problems can be resolved by working with a suitable model categorical presentation of the -category of lcc categories, lcc functors and natural isomorphisms. Note that the model category presenting a higher category is unique up to zig-zag of Quillen equivalences, but that the underlying 1-categories of these model categories can vary non-trivially. Because coherence issues are ultimately about equations in the underlying 1-category, we can thus hope that some model categories presenting the category of lcc categories will be better behaved than others for our purpose.
One possible way to construct such a well-behaved model category is as follows (see (Bidlingmaier 2020) for details):
First one defines a model category of lcc sketches. An lcc sketch is a category with some diagrams marked as finite limits cones and evalution maps of dependent products. These marked diagrams do not need to satisfy the corresponding universal property, however. The model category structure is set up such that every object is cofibrant, and the fibrant objects are precisely the lcc categories with diagrams marked if and only if they satisfy the corresponding universal property. Thus the subcategory of fibrant objects of corresponds to the usual category of lcc categories. Note however, that lcc categories in the sense of fibrant lcc sketches “have” finite limits and dependent products in the sense that these universal objects merely exist; there are no distinguished/assigned choices of universal objects. Thus preservation of universal objects by functors up to equality (i.e. strictness of substitution) cannot even be stated in .
The model category of strict lcc categories is defined as the category of algebraically fibrant objects of ; it is Quillen equivalent to . Assigned lifts against the trivial cofibrations of correspond to distinguished choices of universal objects, and these choices are preserved by the morphisms of , the strict lcc functors. Thus supports substitutions that preserve type formers up to equality.
However, it does not support some dependent type formers in any obvious way, notably not and types. The problem is that the context extension of some by a type (i.e. object) of is given by freely (in the 1-categorical sense) adjoining a morphism to . To interpret and types, one has to relate with the slice category in some way, and it appears that this is not generally possible. Note that has the universal property of a context extension in the higher/bicategorical sense, but that is defined purely 1-categorically.
To reconcile context extensions with slice categories , one can work with the algebraically cofibrant objects of . An algebraically cofibrant object of is a coalgebra for a fixed cofibrant replacement comonad. The category of such coalgebras has model category structure, and this model category is again Quillen equivalent to .
A cofibrant object of has the property that every non-strict lcc functor (i.e. morphism of underlying lcc sketches) out of is isomorphic to a strict lcc functor. This property turns out to be sufficient to construct a weak equivalence in . For algebraically cofibrant , this weak equivalence is structure and hence preserved by coalgebra morphisms up to equality. This turns out to be sufficient to endow the category of algebraically cofibrant objects of with CwF structure that supports finite limit, and type constructors.
The general idea of categorical semantics of dependent types goes back at least to Seely 1984, a first formalization via categories with display maps (“clans”) is due to:
Paul Taylor, §4.3.2 in: Recursive Domains, Indexed Category Theory and Polymorphism, Cambridge (1983-7) [pdf]
Paul Taylor, Section 8.3 in: Practical Foundations of Mathematics, Cambridge University Press (1999) [webpage]
General overview:
which originates as
Texbook accounts:
Comprehension categories are defined in
A 2-categorical treatment of variant kinds of comprehension category is given in
A correspondence with orthogonal factorization systems is discussed in
Categories with attributes are discussed in
John Cartmell, Generalised algebraic theories and contextual categories, Ph.D. thesis, Oxford (1978), Ann. Pure Appl. Logic 32 3 (1986) 209–243 [doi:10.1016/0168-0072(86)90053-9MR865990]
Eugenio Moggi, A category-theoretic account of program modules, Math. Structures Comput. Sci. 1 1 (1991) 103-139 [MR1108806, doi:10.1017/S0960129500000074]
Andrew M. Pitts, Categorical logic, in Handbook of Logic in Computer Science 5 Oxford Univ. Press (2000) 39-128 [doi:10.1093/oso/9780198537816.003.0002, pdf, MR1859470]
Categories with families are defined in
and shown to be equivalent to categories with attributes in Hofmann (1997)
The formulation in terms of representable natural transformations (natural models of homotopy type theory) is due to:
See also
A proof of initiality for dependent type theory is claimed in
This was formalized inside type theory with set quotients of higher inductive types in:
Contextual categories were defined in
John Cartmell, Generalised algebraic theories and contextual categories, Annals of Pure and Applied Logic Volume 32, 1986, Pages 209-243 (doi:10.1016/0168-0072(86)90053-9)
Thomas Streicher, Semantics of type theory – Correctness, completeness and independence results, Progress in Theoretical Computer Science, Birkhäuser (1991) [ISBN:0-8176-3594-7, doi:10.1007/978-1-4612-0433-6, MR1134134]
Review:
Contextual categories as models for homotopy type theory are discussed in
Chris Kapulkin, Peter LeFanu Lumsdaine, The homotopy theory of type theories, Advances in Mathematics 337 (2018) 1-38 [arXiv:1610.00037, doi:10.1016/j.aim.2018.08.003]
André Joyal, Notes on Clans and Tribes [arXiv:1710.10238]
Further discussion of contextual categories is in
Vladimir Voevodsky, A C-system defined by a universe category, Theory Appl. Categ. 30 (2015), No. 37, 1181–1215, arXiv:1409.7925 (arXiv:1409.7925)
Vladimir Voevodsky, Martin-Löf identity types in the C-systems defined by a universe category (arXiv:1505.06446)
Vladimir Voevodsky, Products of families of types in the C-systems defined by a universe category (arXiv:1503.07072)
Vladimir Voevodsky, Subsystems and regular quotients of C-systems (arXiv:1406.7413)
Discussion of B-systems, another essentially algebraic model, is in
The model of dependent type theory with dependent product types/dependent function types in locally cartesian closed categories was first made explicit in
The problem with strict substitution compared to weak pullback in this argument was discussed and fixed in
Pierre-Louis Curien, Substitution up to isomorphism, Fundamenta Informaticae, 19 1-2 (1993) 51-86 [doi:10.5555/175469.175471] and: Diagrammes 23 (1990) 43-66 [numdam:DIA_1990__23__43_0]
Martin Hofmann, On the interpretation of type theory in locally cartesian closed categories, in Computer Science Logic. CSL 1994, Lecture Notes in Computer Science 933 (1994) 427–441 [doi:10.1007/BFb0022273]
but in the process the equivalence of categories was lost. This was finally all rectified in
and
See also:
Peter LeFanu Lumsdaine, Michael Warren, The local universes model: An overlooked coherence construction for dependent type theory, ACM Trans. Comput. Log., 16 3 no 23 (2015) 1-31 [arXiv:1411.1736, doi:10.1145/2754931]
Comparisons of various models can be found in
Benedikt Ahrens, Peter LeFanu Lumsdaine, Vladimir Voevodsky, Categorical structures for type theory in univalent foundations [arxiv:1705.04310]
Chris Kapulkin, Peter LeFanu Lumsdaine, The homotopy theory of type theories[arXiv:1610.00037]
Daniel Gratzer, Jonathan Sterling, Syntactic categories for dependent type theory: sketching and adequacy [arXiv:2012.10783]
Recent work on abstract definitions of (models of) type theory include:
Valery Isaev, Algebraic Presentations of Dependent Type Theories (arXiv:1602.08504)
Taichi Uemura, A General Framework for the Semantics of Type Theory (arXiv:1904.04097)
A category with families structure is constructed on the -category of all locally cartesian closed categories, which since locally presentable may be treated via model categories, in:
Martin Bidlingmaier, An interpretation of dependent type theory in a model category of locally cartesian closed categories, (arXiv:2007.02900)
Michael Ching, Emily Riehl, Coalgebraic models for combinatorial model categories arXiv:1403.5303
Valery Isaev, Model category of marked objects arXiv:1610.08459
An equivalence between contextual categories and B-systems is in:
Last revised on June 6, 2024 at 18:38:13. See the history of this page for a list of all contributions to it.