University of Nottingham, United Kingdomthorsten.altenkirch@nottingham.ac.uk
University of Nottingham, United Kingdomjacob.neumann@nottingham.ac.ukhttps://orcid.org/0009-0003-5858-466X
\CopyrightThorsten Altenkirch and Jacob Neumann {CCSXML}
<ccs2012>
<concept>
<concept_id>10003752.10003790.10011740</concept_id>
<concept_desc>Theory of computation Type theory</concept_desc>
<concept_significance>500</concept_significance>
</concept>
</ccs2012>
\ccsdesc[500]Theory of computation Type theory
\hideLIPIcs\EventEditorsJohn Q. Open and Joan R. Access
\EventNoEds2
\EventLongTitle42nd Conference on Very Important Topics (CVIT 2016)
\EventShortTitleCVIT 2016
\EventAcronymCVIT
\EventYear2016
\EventDateDecember 24–27, 2016
\EventLocationLittle Whinging, United Kingdom
\EventLogo\SeriesVolume42
\ArticleNo23
Synthetic 1-Categories in Directed Type Theory
Thorsten Altenkirch
Jacob Neumann
Abstract
The field of directed type theory seeks to design type theories capable of reasoning synthetically about (higher) categories, by generalizing the symmetric identity types of Martin-Löf Type Theory to asymmetric hom-types.
We articulate the directed type theory of the category model, with appropriate modalities for keeping track of variances and a powerful directed-J rule capable of proving results about arbitrary terms of hom-types; we put this rule to use in making several constructions in synthetic 1-category theory.
Because this theory is expressed entirely in terms of generalized algebraic theories, we know automatically that this directed type theory admits a syntax model and is the first step towards directed higher observational type theory.
keywords:
semantics, directed type theory, homotopy type theory, category theory,generalized algebraic theories
keywords:
Categories with Families (CwFs)
keywords:
polarized category with families (PCwF)
keywords:
sub-PCwF
keywords:
neutral-polarized category with families (NPCwF)
keywords:
directed CwF (DCwF)
keywords:
-truncated DCwF
keywords:
polarized -types
1 Introduction
One exciting aspect of the emergent field of homotopy type theory (HoTT) [28] is the observation that types are -groupoids [29]. Homotopy type theory can be understood as a synthetic theory of -groupoids: all the higher structure is generated by the simple rules for manipulating identity types in Martin-Löf Type Theory [21, 22], permitting efficient reasoning with these complex structures.
Not long after homotopy type theory was established, the search for directed homotopy type theory—a synthetic theory of (higher) categories—began. In a directed type theory, the identity types of ordinary Martin-Löf Type Theory (which are provably symmetric in the theory, i.e. a witness can be turned into ) are replaced by asymmetric hom-types. However, building a type theory to effectively work with these hom-types is beset by difficulties, in particular the need to carefully track the variances of terms. A common feature of many approaches to directed type theory (e.g. [20, 24, 23]) is to track these variances by adopting some kind of modal typing discipline. However, no consensus ever emerged for exactly how to do this. More recent approaches to directed type theory (such as the work of Riehl and Shulman [25]) avoid these issues by adopting a more indirect approach inspired by simplicial spaces, at the cost of a more elaborate, multi-layered theory.
A possible new approach to directed type theory seems to be on the horizon, drawing from the recent development of higher observational type theory [5, 4]. Higher observational type theory, or H.O.T.T., seeks to strike a balance between the properties of “Book HoTT” (as originally articulated in [28]) and cubical type theory [10], particularly with regards to the central axiom of HoTT, Voevodsky’s univalence axiom. In Book HoTT, identity types are defined inductively, which results in the univalence axiom being impossible to compute with—complicating a key attribute of HoTT, its amenability to computer formalization. Cubical type theory rectifies this situation by instead defining identity types in terms of a special interval type, and adding enough machinery to make univalence computable as a theorem rather than an axiom (though at the expense of Book HoTT’s intuitive simplicity). Higher observational type theory seeks to build homotopy type theory around observational identities, in particular turning univalence into a definition, preserving both the computational and intuitive character of homotopy type theory. H.O.T.T.’s definitional univalence suggests a clear directed analogue, making directed higher observational type theory an appealing prospect. Though H.O.T.T. remains to be fully worked out, it’s clear that second-order generalized algebraic theories (SOGATs) [27, 26, 7, 17] provide the appropriate setting for formulating this theory, as the language of SOGATs provide a higher-order abstract syntax ideal for handling formal languages with variable binders.
Ordinary (first-order) generalized algebraic theories (GATs) [8] have played a prominent role in the semantics of type theory: Dybjer’s categories with families (CwFs) [11] are a GAT articulating the basic mechanics of type theory, and provide a highly flexible and modular approach to interpreting type theories. Articulating the semantics of type theory as a GAT comes with numerous advantages: the universal algebraic features of GATs—such as homomorphisms, displayed models, products and coproducts of models, free and cofree models—are well-understood [18]. In particular, every GAT has an initial model, the syntax model, which can be constructed as a quotient inductive-inductive type [16]. Finally, GATs have the advantage of being (relatively) straightforward to formalize, as they make all the relevant operations and equations explicit.
Anticipating SOGAT and higher observational treatments of directed type theory, we begin by articulating directed type theory as a generalized algebraic theory.
1.1 Related Work
The present work draws most closely from Hofmann and Streicher’s work on the groupoid model [15]; in particular, we develop a directed analogue of the groupoid model—the category model—and adapt the groupoid models main constructs (dependent types and identity types) to the directed setting. We also closely follow the kind of metatheoretic arguments made there, and develop a directed analogue of their universe extensionality, an early articulation of univalence. We also draw from the closely-related setoid model of [13, 2].
Among directed type theories, the present work draws some constructs from the theory of Licata and Harper [20], particularly their treatment of the opposite category construction as a modality on contexts and context extension, as well as their treatment of -types in the directed setting. Our directed J-rule for eliminating hom-types is similar to one of the eliminators given by North [23], though with the critical difference mentioned below. Our theory, like North’s, is “1-dimensional” in the sense of Licata-Harper in that we maintain judgmental equality as a symmetric notion, as opposed to “2-dimensional” theories [20, 24, 1] which introduce a theory of directed reductions. All these theories adopt a modal typing discipline for handling variances, as do we, unlike the theories of [25, 19, 31] and [30], which adopt approaches akin to simplicial and cubical type theories, respectively.
The commonality between the setoid, groupoid, preorder, and category model described in Section 2 is made much more general [18, 16], where it is shown that any GAT gives rise to a CwF of algebras, algebra morphisms, displayed algebras, and sections. The modal features of the present work are most likely instances of the modal type theory of [12].
1.2 Contribution and Organization
We articulate a directed type theory satisfying the following constraints.
(1)
It is presented as a generalized algebraic theory.
(2)
It is 1-dimensional in the sense of Licata-Harper: there are no ‘directed reductions’ introduced judgmentally.
(3)
It is deeply-polarized: there is a modal typing discipline to keep track of variances, which operates not just on types but on contexts, substitutions, and context extension.
(4)
The directed J-rule (directed path induction) permits reasoning about arbitrary terms of hom-types.
(5)
Hom-types can be iterated,111In contrast to e.g. [20], where homs-between-homs and homs-between-homs-between-homs is not possible to express. expressing synthetic higher categorical structure (though in the present work we only consider 1-category theoretic structure).
To our knowledge, there is no existing type theory satisfying all these criteria.
Starting with Section 2, we adopt a semantics-driven approach by investigating a particular model, the category model and abstracting its key features into a series of abstract notions of model (Section 3). These notions are all GATs (indeed, CwFs with additional structure), and therefore each give rise to a syntax model. Our main notion is that of a Directed CwF (DCwF), a generalized algebraic theory of directed types with adequate polarity structure to properly track variances.
Achieving (4) while maintaining a modal typing discipline requires a novel approach. In the typing rules of existing directed type theories (including ours), the endpoint terms and of a hom-type are assigned opposite variances: negative and positive. However, this poses a difficulty for typing the identity morphism since must assume both variances. North [23] solves this by restricting to be a term of a core type (interpreted semantically by groupoids), but the consequent J-rule only operates on hom-terms with a core endpoint, not arbitrary ones. Our solution instead uses groupoid contexts rather than groupoid types.
In Section 4, we show that this is a viable framework for conducting synthetic category theory. In this section, we adopt an informal style reminiscent of [28], showing how this theory can be operated and how the groupoid context can be carefully maintained by a simple syntactic rule. We use our directed J-rule to give several basic constructions in synthetic (1-)category theory.
Finally, we consider the directed universe of sets in the category model, which serves as the category of sets. The existence of a directed universe allows us to make the metatheoretic argument that the syntax of DCwFs cannot prove the symmetry of hom-types (i.e. this is a genuinely directed type theory) or the uniqueness of homs (analogous to Hofmann and Streicher’s proof that the groupoid model refutes the uniqueness of identity proofs). We conclude by sketching several possible routes for further study.
1.3 Metatheory and Notation
Throughout, we work in an informal type-theoretic metatheory, using pseudo-Agda notation to specify GATs, make category-theoretic constructions, and define terms in the syntax of Directed CwFs. We use the notations
for the dependent function and dependent sum types, respectively. When defining dependent functions, we’ll enclose arguments in curly brackets to indicate that they’re implicit. Any variables appearing free are also assumed to be implicitly universally quantified. We sometimes use underscores to indicate where the arguments to a function are written. When defining an instance of a construct given as a record type, we’ll often omit the names of specific components, referring to all of them as just (matching the category-theoretic convention of referring to both the object- and morphism-parts of a functor by just ).
We use to mean definitional or judgmental equality in our metatheory, whereas means propositional equality (though there’s no reason they couldn’t coincide, i.e. in an extensional metatheory). We tacitly make use of appropriate extensionality principles (particularly function extensionality) for both notions of equality, and the uniqueness of identity proofs for . We write for the type of h-propositions in our metatheory, i.e. those such that for all .
We assume basic familiarity with category theory. The set of objects of a category is denoted , the set of -morphisms from to is denoted , and identities are written as . The discrete groupoid/category on a set is the category whose objects are elements of and whose morphisms from to are inhabitants of the identity type . The opposite category construction is understood to be definitionally involutive, i.e. is defined to be and is defined to be , and thus
2 The Category Interpretation of Type Theory
As mentioned, generalized algebraic theories (GATs) are a desirable formalism for expressing models of type theory, particularly when modelling numerous extensions to a ‘basic’ type theory. When a theory is given as a GAT, all operations and equations are made clear and explicit, making it easier to compare and contrast similar theories. The theory of (originally defined by Dybjer [11]) present the fundamental operations of type theory—contexts, variables, terms, types, and substitutions—encoded as a GAT; upon this basic framework, an endless variety of different type theories can be studied.
The main components of a CwF are given in Fig. 1: a category of contexts, whose morphisms are called substitutions; a presheaf on and a dependent presheaf over ; and a context extension operation guaranteeing that is locally representable (in the sense of [7]).
The last line says that there is an isomorphism (natural in ) between the type of pairs with and and the type of substitutions from to . The left-to-right direction of this isomorphism is denoted and the opposite direction as , so
for any as above and .
Two paradigm examples of CwFs are the setoid model of [13, 2] and the groupoid model of [15]. In the former, the contexts are setoids (i.e. sets equipped with equivalence relations), the types are families of setoids (functorially) indexed over their context setoid, and terms are given by the appropriate notion of section of their type (see the Coq formalization of [3] for a precise definition). The groupoid model is quite similar: contexts are groupoids, types are families of groupoids functorially indexed over their context groupoid, and terms are the appropriate notion of section. Indeed, we can view the groupoid model as generalizing the setoid model: a setoid can be viewed as a groupoid whose hom-sets are subsingletons (or propositions, in the terminology of [28]), sets with at most one element. In other words, the groupoid model is what results when the assumption of proof-irrelevance is dropped from the setoid model.
Both these models provide interpretations for numerous type formers, in particular the dependent types, identity types, and universes characteristic of Martin-Löf Type Theory [21, 22]. The difference in these models is reflected in the type theories they interpret: while both models permit arbitrary iteration of the identity type former (expressing identities between identities, and identities between identities between identities, and so on), these iterated identity types become trivial more quickly in the setoid model. More precisely, the setoid model validates the uniqueness of identity proofs principle, meaning that any two terms of an identity type, are themselves identical, . The groupoid model famously violates this principle: in the type theory of the groupoid model, there are types (in particular, the universe of sets) which are not h-sets, i.e. they possess terms which are proved identical by multiple, distinct identity proofs.
This provides a roadmap for how we might develop a model of directed type theory. Since directed type theory can be described as “dependent type theory, but with asymmetric identity types”, this leads us to suspect that models of directed type theory will result if we simply drop the assumption of symmetry from the setoid and groupoid models. A setoid without symmetry is a preorder, and a groupoid without symmetry is a category. A close inspection of the definition of the groupoid model reveals that nothing in its interpretation of just the CwF structure requires symmetry (i.e. that morphisms are invertible), and thus we can define the preorder model of type theory and the category model of type theory. The category model is given by Fig. 2, minus the definition of context extension (which will be discussed more below). This is just a generalization of the groupoid model, obtained by dropping symmetry: contexts are categories (and substitutions are functors), types are families of categories, and terms are sections.
We wont focus on the preorder model here, but leave it to future work to develop the directed analogue of setoid-model-specific considerations. Instead, we’ll highlight those features of the category model which are relevant for modelling directed type theory, before abstracting those features into the notion of a directed CwF in the next section.
Figure 2: The CwF structure of the category model, excluding context extension.
While the basic CwF structure of the groupoid model doesn’t require symmetry (i.e. that all morphisms are invertible), its interpretations of further type formers certainly do. After all, our hope is that by passing from the groupoid model to the category model, the symmetric identity types of the former will become asymmetric hom-types in the latter. Consider the semantics of the identity type former in the groupoid model. Here, and henceforth, we define a type (in this case ) by giving its object- and morphism-parts, which are denoted obj and map in Fig. 2, but here are both written as just .
Here, the fact that is a groupoid is used in an essential way (we must take the inverse of ), and hence this definition doesn’t work in the category model. But notice the following: the term is in the “negative” position (the domain) and the term is in the “positive” position. Fittingly, we only use the inverse of —never itself—and only use but not its inverse. This observation will provide the key to adapting this definition for the category model.
What is needed is for to be a contravariant term of type , while keeping as covariant. This difference can be articulated in the category model, using a fundamental construct from category theory: opposite categories. A type in the category model consists of a family of categories for each object and a functor for each morphism . Given such a family of categories , we can form a new family , where is defined as the opposite category of . This extends to the morphism part as well, because any functor can be viewed as a functor on their opposites, . Alternatively, we could view as a functor , and define to be the composition of with the endofunctor . We can state generally that the category model validates the following rule:
If , this means that the object part of will still send objects to objects of , since and have the same objects. But observe the type of its morphism part:
This is precisely what we need to articulate the definition of hom-types in the category model: see Fig. 3. This definition is almost exactly the same as the semantics of in the groupoid model, but with changed to be a term of , thus eliminating the need for the categories to be groupoids. Here’s the hom-type formation, expressed as a rule:
The type annotation of as a “negative” term and the implicit annotation of as “positive” serve as a kind of modal typing discipline for keeping track of the variances of terms.
Figure 3: Semantics of the -type former in the category model
For now, we just state the formation rule for hom-types; introducing and eliminating terms of hom-types will require more machinery. To see what kind of machinery, let’s instead consider dependent function types. Like with the formation of hom-types, -types involve positive and negative “variance”: a function is contravariant in its argument and covariant in its result. Therefore, as we might expect, the interpretation of -types in the groupoid model ([15, Section 4.6]) makes essential use of the invertability of morphisms in a groupoid. Again, it only comes into play when defining the morphism part of the interpretation: the object part (reproduced in Fig. 5) defines for each an auxiliary type in context , and then specifies the category with terms as objects. This works fine in the category model. However, defining the morphism part of requires a kind of negative variance deeper than the shallow contravariance of : in the type it was a term that occurred negatively (), in the type it’s a type that occurs negatively.
To make sense of this, we must consider the opposite category operation, not just as acting on each in a family of categories over a context , but as acting on the contexts themselves. In the category model, we have the following rules.
That is, we can negate contexts and substitutions as well as types: is interpreted as , and this operation is (covariantly) lifted onto functors as before. Now consider the difference in the morphism parts of terms with these different kinds of variance.
This is why we referred to this as “shallow” and “deep” negation: the difference between the first two is that we’ve flipped around each , whereas in the third term, the dependence of on has itself been flipped around ( is now contravariant, so takes objects of to objects of ). It is this latter kind of contravariance that describes ’s position in .
We need another ingredient to state the -type formation rule: negative context extension. In the type , appears negatively, i.e. we want to depend negatively on , i.e. ; but appears positively—we want to depend covariantly on , plus a variable of type . In the theory of CwFs, a type “depending on a variable” of another type is encoded by context extension. In the category model, we in fact have two context extension operations (see Fig. 4), corresponding to the two ways a type can depend on a context. The positive context extension operator, , obeys the usual isomorphism discussed above. For the negative extension, the isomorphism becomes:
(1)
for any . We’ll write for the left-to-right direction of this isomorphism, and write and for the data obtained from applying the right-to-left direction to the identity morphism on .
With this, we have everything needed to give the semantics of the -type former; this is done in Fig. 5. As expected for -types, we have an isomorphism between and , the application and lambda-abstraction rules. This is omitted here for reasons of space, but included in the appendix with accompanying calculations; see Fig. 13.
Figure 5: Semantics of the -type former in the category model
Let’s now return to the key feature of directed type theory, hom-types. Above, we gave just the formation rule for hom-types, but said nothing of how to introduce or eliminate terms of this type. Stating the introduction rule, the term refl inhabiting for each term proves rather subtle. The difficulty stems from the mixed-variance problem mentioned in the introduction: since our formation rule demands the domain term be of type and the codomain term to be of type , it’s not immediately clear how to make well-formed. There is, in general, no way to coerce terms of type into terms of type or vice versa, and we have no rule permitting us to use a term in both variances.
As mentioned in the introduction, the solution to this problem presented in [23] is to use core types. This solution consists of asserting a new type for each , equipped with coercions and . Then, for a term , it makes sense to write , as can be coerced to both the positive and negative modality, in order to fit the formation rule. From there, a directed J-rule can be stated for eliminating hom terms. The issue with this solution is that it forces homs to have core endpoints: the directed J-rule can only be used to prove claims about homs anchored at a core term, and it’s not clear that proofs about arbitrary homs can be made. For the synthetic category-theoretic claims we study below, this will prove to be an unacceptable restriction.
A solution which avoids this shortcoming is revealed by considering hom-types in the empty context. In the empty context, a type is the same thing as a category, and a term of type is the same thing as an object of type (we silently coerce between and ). So then there’s no difference between terms of type and terms of type , since a category and its opposite have the same objects. Therefore, in the empty context, there is no mixed-variance problem, and we can state the introduction rule for simply by coercing to be positive and negative as needed.
This doesn’t extend to arbitrary contexts: as we saw above, terms and have different morphism parts. But here’s the key observation: if is a groupoid, then we can still coerce between and : given , we can obtain , and vice-versa. The definition is given in Fig. 6; there (and henceforth), we use to indicate that is a groupoid, and therefore can invert -morphisms as needed. So, rather than introduce a new type whose terms can be either positive or negative, we have instead have identified those contexts—neutral contexts—where terms of the familiar types and can be inter-converted. Given this, we can introduce refl:
We only need to assert for of type , because the analogous rule for of type can be derived: given , we observe that , so .
Figure 6: Semantics of neutral-context coercion in the category model
Let’s conclude this section by giving an eliminator for our hom-type, known as the directed J-rule or directed path induction. Following [15, Section 4.10], we study directed path induction in the empty context first, which can then be extended to an arbitrary neutral context. Given and and some , our goal is to be able to prove for arbitrary and , just by supplying a term of . Translated into the category model semantics: is a category, and are objects of , is a functor from the coslice category into , is an -morphism from to , and is an object of the category . The key observation is that is then also a morphism in the coslice category from to .
Therefore,
and so the object part of this functor turns objects of into objects of , that is, it turns terms into terms
And, since is the identity functor, we have the law, saying that . The general law replaces with an arbitrary neutral context:
(2)
but the category model interpretation—see Fig. 7—essentially follows this same idea. If doesn’t need to depend on the term of type , then we can instead use the simpler rule
(3)
Note that the dependence on is preserved in the conclusion, even if ignores it. In Section 4 we put this rule to use in synthetic category theory constructions and proofs.
Figure 7: Semantics of directed path induction in the category model
3 Directed Categories with Families
The aim of the present work is not just to establish the category model as a suitable interpretation of directed type theory, but to abstract the category model to a general, abstract notion of ‘model’ of directed type theory. Specifically, we wish to present this model notion as a generalized algebraic theory, that is, as a CwF with further structure.
We do so in several stages, progressively capturing more of the structure described in the previous section. In addition to making the complex and multifaceted notion of ‘directed CwF’ more digestible, this approach will also give us several intermediate notions, each of which is worthy of further study in its own right. First, we encapsulate the ‘negation’ structure.
Definition 3.1(Polarized CwF).
A consists of a CwF equipped with the following operations.
•
An endofunctor such that and for all and
•
A natural transformation such that for all .
So a PCwF is just a CwF equipped with context-, substitution-, and type-negation involutions. The fact that the type-negation operation is a natural transformation just says that it is stable under substitution, i.e. . Now, notably absent from this definition is the negative context extension operation ; by this definition, a PCwF only has the positive one. This is because the negative operation is, in fact, definable: in the category model, the following equation holds for any and any :
(4)
Here we use the fact that ,222In the category model, this holds as a definitional equality, though in Definition 3.1 we only asserted it propositionally, since we’re defining a GAT. and hence , making the right-hand side well-formed. Consequently, we can turn this equation around to define negative context extension: for , let be . The isomorphism characterizing (Equation 1) can then be proved as a consequence of the one for .
Also absent from Definition 3.1 is any mechanism connecting the context/substitution negation endofunctor to the type-negation operation. It’s unclear if this ought to be rectified, or if their connection is just a peculiarity of the category model. Not every CwF fits the same mold of “contexts are structures, types are families of structures”, so it’s not possible to require in general that the type-negation operation is just post-composition with the context-negation functor. There are suitably abstract ways of connecting the two—for instance, we can note that the category model is democratic in the sense of [9, Defn. 3] : there is an isomorphism between contexts and closed types; this isomorphism is compatible with both negation operations, in that . However, we don’t need need such strong assumptions for the results of Section 4, so we omit them from the general definition of PCwFs.
Of course, the category model and the preorder model are both examples of PCwFs, where the negation is the ‘opposite’ construction. But so are the groupoid and setoid models. Indeed, the groupoid model is a sub-PCwF of the category model: a groupoid is a category, and so it makes perfect sense to take the opposite category of , obtaining , which is also a groupoid. What makes the groupoid model a peculiar instance of a PCwF is that for every , and for every . It is what we’ll call a symmetric PCwF. The setoid model is also a symmetric PCwF, but strictly so: there, . The situation exemplified by the groupoid/category and setoid/preorder models—a symmetric sub-PCwF of another PCwF—is what we capture in our next notion.
Definition 3.2(Neutral-Polarized CwF).
A of a PCwF consists of predicates and such that
•
;
•
if , then ;
•
if , then ;
•
if is such that , then for any ; and
•
if and , then .
We indicate a sub-PCwF by to indicate that is the subcategory of -contexts, and is the subpresheaf of -types.
A consists of a PCwF and a sub-PCwF such that
•
is symmetric: every comes equipped with an such that is an inverse of ; moreover, this isomorphism is natural in the sense that, for and , we have ;
•
if either and or and , there are coercion operations and such that for all ;
•
for every and , there is an isomorphism
such that
–
–
for every , , and every ,333 Note that , so , hence why the right-hand side of the following equation is well-formed. The need for and the need to negate is why must be neutral here.
In the third bullet point, note that is not assumed to be in ; if it were, then and then we could use the isomorphism for and the coercion operators to construct this. With being an arbitrary type, this is a genuine addition to the theory. The requirements of this point are somewhat ad-hoc: these were just the principles needed in Section 4 to be able to operate effectively with neutral contexts (and all are provable in the category model). Perhaps a more mature version of this theory will place more requirements on NPCwFs, but this is all the neutral-polar structure needed here.
Let us also note that a common feature in directed type theories (e.g. [24, 23]) is to include core types, i.e. an operation of the form . In the category model, this is interpreted as applying the core groupoid construction to each category , producing a family of groupoids indexed over . We might as well have a deep version too, operating on contexts . We won’t need these features for the present work (and therefore don’t endeavor to axiomatize them), but, once again, it’s quite possible that it would be fruitful to add them in the future.
Recall that CwFs are not a single notion of model for a single type theory, but rather that CwFs encode the basic structural operations of type theory, upon which innumerable different type theories can be specified by defining the desired term- and type-formers. We have arrived at the same point in our development of a semantics for directed type theory: the notion of NPCwF consists solely of structural components, but nothing that actually allows for the construction of interesting types and terms. So let’s rectify this by giving the directed analogue of the standard core of undirected type theory: identity types, dependent types, and universes.
We start with the directed analogue of identity types, hom-types.
Definition 3.3(Directed CwF).
A is a NPCwF equipped with the following structure:
•
a type former
which is stable under substitution:
•
in any , a term for each term , also stable under substitution by for ; and
•
a term former as given in Equation 2, also appropriately stable under substitution.
For any and , write for .
The naming of versus is suggestive: the types in a DCwF are supposed to function like synthetic categories (with encoding their morphisms), and the neutral types are synthetic groupoids, whose homs are symmetric like an identity type. This point is best illustrated by the following claim.
This proof relies on the neutrality of in a very subtle, but critical way: in the definition of the type family , the variable term is negated, so that it is of type and therefore able to stand as the first argument to . But this is only possible if because term-negation is only defined in neutral contexts. This reasoning will prove important for the style of reasoning we employ in Section 4, so we isolate it as a principle.
Principle(Var Neg).
For , the variable term
can only be negated (i.e. forming ) if (and likewise for ).
In Section 5, we’ll argue that there’s no way to construct this symmetry term (for arbitrary DCwFs444with some nontrivial amount of structure.) if is not assumed to be neutral.
Before proceeding, it’s worth explaining what is “the DCwF syntax” mentioned in the proof above. This is where it becomes relevant that DCwFs are presented as generalized algebraic theories: as mentioned in the
introduction, [16] proves that any GAT has an initial syntax model. Therefore, any construction done in the syntax model (such as the construction of above) can be interpreted into any DCwF. This is why a syntactic construction was adequate to prove a claim about all DCwFs in the foregoing proof. In the next section, our proofs will all be syntactic, and thereby apply to arbitrary DCwFs.
Let us make an important observation about the syntax of DCwFs. An important criterion for our theory is that hom-types can be iterated, that is, our syntax allows for the formation of homs between homs, and homs between homs between homs, and so on. The iteration of identity types is, after all, how homotopy type theory is able to serve as a synthetic language for higher groupoids; and since hom types are iterable in the DCwF syntax, it is a synthetic language for higher categories. However, a given model may be truncated, in that the higher structure may become trivial after a certain point. This is the case with the groupoid model: while its types do not all obey the uniqueness of identity proofs (UIP) principle and are therefore not mere h-sets, they do obey “UIP, one level up”: in the groupoid model, identity proofs of identity proofs are unique.
The same happens in the category model: in general, there may be terms and but no term of type . But if there is such a term, there is exactly one. So the (1-)category model, unsurprisingly, can only model 1-categories. But there’s another sense in which the category model structure trivializes “one level up”: all the hom-types are interpreted as discrete categories, which are necessarily groupoids. So, while is still a synthetic category, it’s actually a synthetic setoid. This is appropriate for doing synthetic 1-category theory: it makes sense that the hom-types are trivial as categories: to do 1-category theoretic arguments, we wish to speak of identities between parallel morphisms, not further category-theoretic structure.
We encapsulate DCwFs like this into a definition for further study.
Definition 3.6.
A is a DCwF such that
•
is a neutral type for any terms ; and
•
UIP holds for identities of hom-terms:
The numbering follows the well-known indexing of -categories (see e.g. [6, Defn. 8]) to refer to -categories where all parallel -morphisms are equal when and all -morphisms are invertible for . We could define -truncated DCwFs for arbitrary and (for instance, the preorder model would be -truncated, the groupoid model -truncated, etc.), but that would take us too far afield. For the present work, we will work with -truncated DCwFs, and develop the theory of synthetic 1-category theory (i.e. synthetic -category theory) in that language. The practical consequence of working in the syntax of -truncated DCwFs is that we only have one “layer” of homs, and the type itself is neutral, i.e. its homs are symmetric identity types.
To conclude this section, we state the -type former in PCwFs. This is just the appropriately-polarized analogue of [14, Defn. 3.15], and is approximately the same rule for -types in [20].
Definition 3.7.
A PCwF supports if it comes equipped with a type former
which is stable under substitution, along with a natural isomorphism
The -law is that and the -law the other way around. The differences between polarized -types and the familiar -types of undirected type theory are pretty minimal when operating in neutral contexts: for instance, when instantiating to non-dependent functions , the application operator defined by has type
If , then we can take terms from , and and use the negation operator and the substitution to get into for the purposes of applying functions. In the next section, we push this bureaucracy into the background and proceed informally.
4 Synthetic Category Theory
In this section, we work in an arbitrary -truncated DCwF with polarized -types by only working in the syntax. In the main body of the text, we’ll adopt an informal type theoretic style (inspired by [28]).
We assume that we’re working in some neutral context , though we don’t explicitly reference . We’ll write to indicate . In what follows, we’ll use the letters to name terms (of various types) in , whereas the letters will be the names of variables obtained by extending . We’ll have to be careful to abide by the variable negation rule:
Principle(Var Neg).
An expression can only be negated if all the variables occurring in it are of neutral types.
We suppress the distinction between and , since we can substitute back and forth with behind the scenes, as needed. Negative context extension will just behave like positive extension by a negative type: recall that
i.e.
so, if we’re suppressing the distinction between and , then this is just a variable of . Accordingly, we’ll apply functions like this:
and form them like this:
Finally, here’s our principle of directed path induction:
Principle(Directed Path Induction).
For every , if is a type family depending on and , then, for each
we get an
for all .
So, for instance, the construction of symmetry above (the proof of Proposition 3.4) would be expressed informally as follows: given a neutral type and a term , define a type family over by
We have not violated ((Var Neg).) because and is neutral. We have a term of type , i.e. , namely . So therefore we get for arbitrary . If we have a particular and , we can put
Again, we emphasize that it is ((Var Neg).) which prevents this argument from working for non-neutral types, as desired. Below, we are more casual with our application of directed path induction (e.g. not defining the type family explicitly) in cases where ((Var Neg).) is not a concern.
With that, we can proceed to the informal constructions. Along the way, the explicit constructions in the DCwF syntax are carried out in the accompanying figures.
As mentioned, a type in directed type theory is supposed to be a synthetic category. The terms represent objects, and the terms represent morphisms. For this to truly be category theory, however, we must be able to compose morphisms. We’ll write composition in diagrammatic order: given and , we should be able to compose with to get . We do this by directed path induction on , by putting
The terms serve as the identity morphisms of the category: by the above, we know that , and thus . As for the other unit law, we must again use directed path induction: since
we have that , and, by induction we get a term
for each .
Finally, we get that the composition operation is associative. Given and as well as , , and , we construct
by directed path induction on . If , then and . Thus, we have
and then the induction carries through, and we get as desired.
If types are synthetic categories, it should come as no surprise that terms are synthetic functors. The object part is given by the usual function application, but the variances are somewhat mixed: if , then we can say . However, we can still apply to a term , we just have to put a minus on , i.e. .
Unlike usual (“analytic”) category theory, we don’t have to explicitly define the morphism part of a functor; any term of type we can write down will come with a morphism part for free. To obtain this morphism part, again we use directed path induction: given an and some , we can define a -morphism
for every and by putting
By definition, this operation preserves identities (sending to ), and respects composition: if we have and , then, since and and , we have
By induction, we get an identity between and for arbitrary .
Let us also note that functors are also composable: given and , we get the usual
Of course, we can prove equal to by directed path induction, using the following observations:
As the previous section showed, the syntax of 1-truncated Directed CwFs provides a nice setting for some very basic constructions in synthetic category theory. However, further expansion of the DCwF syntax is needed to be able to capture the full range of constructions in category theory. In this section, we’ll observe some constructions that can be made (and some equivalences that hold) in the category model, which require further study to be internalized into the DCwF syntax.
Probably the most significant omission from the synthetic category theory of the previous section is natural transformations. There are some natural transformations expressible in the theory as written, because natural transformations are, as we might hope and expect, homs between functors. That is, the type is a synthetic category: given and , we can form the type . In the category model, these are interpreted as natural transformations from to , but all dependent over the context . Both and sends objects to functors from to ; if , then sends to a natural transformation . On morphisms , is a witness to the fact that
Presently, the only such natural transformations expressible in the DCwF syntax are identities (e.g ). There is not a way to work with the actual components of a natural transformation, or to define a natural transformation by its components. What we would like to be able to do is write terms of type
and then prove that they are automatically natural by directed path induction, since . The issue is that this type violates ((Var Neg).): we’re not allowed to write for a variable without knowing that is neutral. If is neutral, then we’re only capturing natural transformations between functors whose domain is a groupoid, which is a significant restriction. Thus, we have two important open questions: how to make natural transformations definable component-wise in the syntax (ideally using -types), and how to express in the syntax that the type of such transformations is equivalent to the hom-type between the two functors.
Another important feature we add are universes. The category model comes equipped with several type universes, most significantly the universe of sets. More precisely, we can regard the category as a closed type in the category model. The operation takes a set and views it as a discrete category. We can then define
by directed path induction: should be the identity function . We can use this to state the following principle.
Principle(External Directed Univalence).
Hom-to-func is a bijection.
Really, Hom-to-func is the identity function, since terms of hom-types in the empty context are just the morphisms of the category, the morphisms of are functions, and a functor between discrete categories is just a function between their objects. Spelling out the category model semantics, we see that every function is sent to itself. Sufficiently internalized, this principle of Directed Univalence serves as the directed analogue of Hofmann and Streicher’s universe extensionality axiom [15, Section 5.4]. Further work is required to better develop the theory of isomorphisms in the synthetic category theory, and to compare this principle of directed univalence to existing ones (e.g. [19]).
Let us conclude by observing that the existence of a universe allows for metatheoretic reasoning as well, specifically negative proofs about what cannot be done in the syntax. We can view the directed universe as a source of nontrivial directedness: if we affirm Section 5, then cannot possibly be a neutral type. We show that, in DCwFs equipped with a directed univalent universe , hom-types must be asymmetric in general. That is, we cannot construct a term like in Proposition 3.4 for non-neutral types in the syntax DCwF+ (the initial model of the GAT of DCwFs with a universe ). We do so the same way Hofmann and Streicher [15] proved that ordinary Martin-Löf Type Theory couldn’t prove the Uniqueness of Identity Proofs: by countermodel. Hofmann and Streicher’s countermodel was the groupoid model, and, of course, ours is the category model.
Proposition 5.1.
There cannot be an operation
definable in the syntax of DCwFs+.
Proof 5.2.
If the syntax model of DCwF+ had such an operation , then, by initiality, so too would every DCwF with , in particular the category model. But then for any and and , we would obtain . But this is absurd, because the function is a term of type in the category model, and, by Section 5, corresponds to a term of type , but there cannot be any terms of , because the set of terms of this type is in bijection with the set of functors to , of which there are none.
Basically the same argument will show the uniqueness of homs principle—that for any hom terms and , there is a witness of —is violated in the category model (a counterexample being -homs from the two-element set to itself), and therefore not provable in the syntax of DCwFs+. So we can conclude that the difference between -truncated DCwFs, -truncated DCwFs, and -truncated CwFs is reflected internally in the syntax.
6 Conclusion and Future Work
We have laid the laid the foundation for a generalized algebraic theory of directed types, and began to conduct synthetic category theory in that setting. Our semantics-forward approach was to study the category model first, and extract its key features into a series of abstract definitions—the GATs of polarized CwFs, neutral-polar CwFs, directed CwFs, -truncated directed CwFs, and directed CwFs with features like polarized dependent types and a directed univalent set universe. Working within the directed type theory of these models, we found that it was possible to work informally with the powerful directed path induction principle to make basic constructions in category theory, with our careful discipline about variable negation preventing the directed type theory from collapsing into undirected type theory.
Much remains to be done. The category theory of Section 4 serves as a proof-of-concept, but needs to be fleshed out into a full theory. As mentioned, work is needed to articulate natural transformations in the theory; our current investigations concern possible generalization of -types to di-variant end types which address some of the above-mentioned variance issues with natural transformations. For reasons of space, we omitted dependent sum types from the theory. But with them added, much of basic category theory should be expressible in this language, such as isomorphisms, (co)slice categories, (co)limits, exponentials, and perhaps some basic topos theory. Better development of the category of sets should put representability and some properties of presheaf categories into reach, though internal statement and proof of the Yoneda Lemma will likely rely on the resolution of the above-mentioned dilemma regarding natural transformations. We also leave it to future work to study whether this theory can capture higher category theory by weakening or dropping the assumption of 1-truncation, and, if so, how it compares to existing synthetic higher category frameworks, such as [25].
There are further avenues for developing the type theory of DCwFs. Two important metatheoretic results about the syntax of DCwFs currently being pursued are canonicity and normalization. Moreover, we would like to verify the correctness of these results by formalizing them in a computer proof assistant. A further goal would be to implement the syntax of DCwFs as a computer proof language itself, hopefully with syntax nearly as convenient as the constructions of Section 4, and formalize larger swaths of category theory in it.
As mentioned in the introduction, a motivation for the present work’s focus on generalized algebraic theories is the possibility of expressing it in a second-order generalized algebraic theory, following [7, 27, 26, 4, 17]. Since our notions of PCwFs and NPCwFs include explicit operations on contexts (as seen in the substructural character of the ((Var Neg).) rule), it’s clear that either an extension to the SOGAT signature language of [17], and/or a partial internalization of the first-order theory into the second-order theory—à la [4]—will be necessary. A related question is whether the operation (or a neutralization operation interpreted in the category model by core groupoids) on types and contexts can be viewed as a modality in the sense of [12]. Also, as mentioned, this work is oriented towards higher observational type theory, and further study of the observational equivalences of this theory (e.g. a characterization of the -types of -types) is needed.
Finally, the present framework provides a setting for studying directed higher-inductive types—inductively-defined types with both term constructors and hom constructors. Some simple examples would be the directed interval (as is studied in [30, 25]) and a directed analogue of the circle type [28, Section 6.2]. These examples are modelled by the category model, and can therefore be soundly added to the present theory. Higher examples (such as directed versions of higher tori and spheres) would require more careful metatheoretic work to justify, but could perhaps lead to a number of interesting considerations.
References
[1]
Benedikt Ahrens, Paige Randall North, and Niels van der Weide.
Bicategorical type theory: semantics and syntax.
Mathematical Structures in Computer Science, 33(10), 2023.
[2]
Thorsten Altenkirch.
Extensional equality in intensional type theory.
In Proceedings. 14th Symposium on Logic in Computer Science
(Cat. No. PR00158), pages 412–420. IEEE, 1999.
[3]
Thorsten Altenkirch, Simon Boulier, Ambrus Kaposi, Christian Sattler, and
Filippo Sestini.
Constructing a universe for the setoid model.
In FoSSaCS, pages 1–21, 2021.
[4]
Thorsten Altenkirch, Yorgo Chamoun, Ambrus Kaposi, and Michael Shulman.
Internal parametricity, without an interval.
Proceedings of the ACM on Programming Languages,
8(POPL):2340–2369, 2024.
[5]
Thorsten Altenkirch, Ambrus Kaposi, and Michael Shulman.
Towards higher observational type theory, 2022.
28th International Conference on Types for Proofs and Programs (TYPES
2022).
[8]
John Cartmell.
Generalised algebraic theories and contextual categories.
Annals of pure and applied logic, 32:209–243, 1986.
[9]
Simon Castellan, Pierre Clairambault, and Peter Dybjer.
Categories with families: Unityped, simply typed, and dependently
typed.
Joachim Lambek: The Interplay of Mathematics, Logic, and
Linguistics, pages 135–180, 2021.
[10]
Cyril Cohen, Thierry Coquand, Simon Huber, and Anders Mörtberg.
Cubical type theory: A constructive interpretation of the univalence
axiom.
In 21st International Conference on Types for Proofs and
Programs, 2018.
[11]
Peter Dybjer.
Internal type theory.
In International Workshop on Types for Proofs and Programs,
pages 120–134. Springer, 1995.
[12]
Daniel Gratzer, GA Kavvos, Andreas Nuyts, and Lars Birkedal.
Multimodal dependent type theory.
In Proceedings of the 35th Annual ACM/IEEE Symposium on Logic in
Computer Science, pages 492–506, 2020.
[13]
Martin Hofmann.
A simple model for quotient types.
In International Conference on Typed Lambda Calculi and
Applications, pages 216–234. Springer, 1995.
[14]
Martin Hofmann.
Syntax and semantics of dependent types.
In Extensional Constructs in Intensional Type Theory, pages
13–54. Springer, 1997.
[15]
Martin Hofmann and Thomas Streicher.
The groupoid interpretation of type theory.
Twenty-five years of constructive type theory (Venice, 1995),
36:83–111, 1995.
[16]
Ambrus Kaposi, András Kovács, and Thorsten Altenkirch.
Constructing quotient inductive-inductive types.
Proc. ACM Program. Lang., 3(POPL), jan 2019.
doi:10.1145/3290315.
[17]
Ambrus Kaposi and Szumi Xie.
Second-order generalised algebraic theories: Signatures and
first-order semantics.
In 9th International Conference on Formal Structures for
Computation and Deduction (FSCD 2024). Schloss Dagstuhl–Leibniz-Zentrum
für Informatik, 2024.
[18]
András Kovács.
Type-Theoretic Signatures for Algebraic Theories and Inductive
Types.
PhD thesis, Eötvös Loránd University, 2022.
[19]
Nikolai Kudasov, Emily Riehl, and Jonathan Weinberger.
Formalizing the -categorical yoneda lemma, 2023.
arXiv:2309.08340.
[20]
Daniel R Licata and Robert Harper.
2-dimensional directed dependent type theory.
2011.
[21]
Per Martin-Löf.
An intuitionistic theory of types: Predicative part.
In H.E. Rose and J.C. Shepherdson, editors, Logic Colloquium
’73, volume 80 of Studies in Logic and the Foundations of Mathematics,
pages 73–118. Elsevier, 1975.
[22]
Per Martin-Löf.
Constructive mathematics and computer programming.
In L. Jonathan Cohen, Jerzy Łoś, Helmut Pfeiffer, and Klaus-Peter
Podewski, editors, Logic, Methodology and Philosophy of Science VI,
volume 104 of Studies in Logic and the Foundations of Mathematics,
pages 153–175. Elsevier, 1982.
[23]
Paige Randall North.
Towards a directed homotopy type theory.
Electronic Notes in Theoretical Computer Science, 347:223–239,
2019.
[24]
Andreas Nuyts.
Towards a directed homotopy type theory based on 4 kinds of variance.
Mém. de mast. Katholieke Universiteit Leuven, 2015.
[25]
Emily Riehl and Michael Shulman.
A type theory for synthetic -categories.
arXiv preprint arXiv:1705.07442, 2017.
[26]
Taichi Uemura.
Abstract and concrete type theories.
PhD thesis, University of Amsterdam, 2021.
[28]
The Univalent Foundations Program.
Homotopy Type Theory: Univalent Foundations of Mathematics.
Institute for Advanced Study, 2013.
URL: https://homotopytypetheory.org/book.
[29]
Benno Van Den Berg and Richard Garner.
Types are weak -groupoids.
Proceedings of the london mathematical society,
102(2):370–394, 2011.
[30]
Matthew Z. Weaver and Daniel R. Licata.
A constructive model of directed univalence in bicubical sets.
In Proceedings of the 35th Annual ACM/IEEE Symposium on Logic in
Computer Science, LICS ’20, page 915–928, New York, NY, USA, 2020.
Association for Computing Machinery.
doi:10.1145/3373718.3394794.
[31]
Jonathan Weinberger and Ulrik Buchholtz.
Type-theoretic modalities for synthetic -categories,
2019.
International Conference on Homotopy Type Theory (HoTT 2019).
Appendix A Additional Calculations
The definition of the -type former given in Fig. 5 is repeated in Fig. 13, plus the definitions for lambda abstraction and application.
These definitions rely on the following calculations.
•
A naturality calculation for the morphism part of lamt’:
(5)
The first and the last equations are the functoriality conditions of . The middle equations are the category laws for , , and , as well as the functoriality of .
•
To see that the morphism part of appf is well-typed, observe that
(6)
i.e.
and therefore,
and also that
(7)
and therefore
and thus we can conclude that can be composed with , giving a term of the appropriate type.