Two-Level Type Theory and Applications

We define and develop two-level type theory (2LTT), a version of Martin-L\"of type theory which combines two different type theories. We refer to them as the inner and the outer type theory. In our case of interest, the inner theory is homotopy type theory (HoTT) which may include univalent universes and higher inductive types. The outer theory is a traditional form of type theory validating uniqueness of identity proofs (UIP). One point of view on it is as internalised meta-theory of the inner type theory. There are two motivations for 2LTT. Firstly, there are certain results about HoTT which are of meta-theoretic nature, such as the statement that semisimplicial types up to level $n$ can be constructed in HoTT for any externally fixed natural number $n$. Such results cannot be expressed in HoTT itself, but they can be formalised and proved in 2LTT, where $n$ will be a variable in the outer theory. This point of view is inspired by observations about conservativity of presheaf models. Secondly, 2LTT is a framework which is suitable for formulating additional axioms that one might want to add to HoTT. This idea is heavily inspired by Voevodsky's Homotopy Type System (HTS), which constitutes one specific instance of a 2LTT. HTS has an axiom ensuring that the type of natural numbers behaves like the external natural numbers, which allows the construction of a universe of semisimplicial types. In 2LTT, this axiom can be stated simply be asking the inner and outer natural numbers to be isomorphic. After defining 2LTT, we set up a collection of tools with the goal of making 2LTT a convenient language for future developments. As a first such application, we develop the theory of Reedy fibrant diagrams in the style of Shulman. Continuing this line of thought, we suggest a definition of (infinity,1)-category and give some examples.


Introduction
The literature on homotopy type theory (HoTT), and type theory in general, offers a great variety of results. Some developments are completely internal to a specific type theory, that is, they can be expressed in type-theoretic syntax and mechanised using a proof assistant which itself is an implementation of a sufficiently good approximation of the considered type theory. Examples include most of the material in the homotopy type theory book [Uni13], many theorems of which have been formalised in the proof assistants Coq [BC10], Agda [Nor07], and Lean [dMKA + 15]. A second kind of literature presents results of inherently meta-theoretic nature, for example the development of models of type theory, or proofs that a system is strongly normalising, and so on.
What we are particularly interested in is a third kind of result. Some developments are partially internal to homotopy type theory, and often one would want them to be completely internal and formalisable in a proof assistant, but unfortunately, it is either unknown how this is doable or it is known to be impossible. The most well-known and most frequently discussed example for this situation is the definition of semisimplicial types [LU13]. An informal explanation of the problem is the following. A semisimplicial type of level 1 is the same as a type A 0 in a fixed universe U. A semisimplicial type of level 2 is a pair (A 0 , A 1 ) of a type A 0 ∶ U and a family A 1 ∶ A 0 → A 0 → U. A semisimplicial type of level 3 is a triple (A 0 , A 1 , A 2 ) with A 0 and A 1 as before, and A 2 of the type A 2 ∶ Π(x, y, z ∶ A 0 ).A 1 x y → A 1 y z → A 1 x z → U.
We think of A 0 as a type of points, A 1 x y as a type of lines from x to y, and A 2 x y z f g h as a type of "triangle fillers" for the triangle spanned by f , g, and h. It is tedious but intuitively clear how to extend this definition to levels 4 or 5 (or even 100) in this style. An open problem of HoTT asks: Is it possible to construct a function S ∶ N → U 1 such that, for every n, the type S(n) encodes the type of semisimplicial types of level n? It is known that, for any externally fixed number k (e.g. 4,5,100), we can construct a type S k that encodes semisimplicial types of level k. However, this is not enough to construct an internal function S. Two questions arise naturally: (1) How can we formalise the construction of S k for every external natural number k? (2) How can we extend the type theory such that S itself can be constructed?
In order to answer question 2, Voevodsky suggested a type theory called homotopy type system (HTS) [Voe13]. This theory introduces a type of what they call exact equalities. Exact equality is an internalised version of judgmental (a.k.a. definitional) equality and co-exists with, but is very different from, the usual internal equality type (a.k.a. identity type, identification type, path type). In HTS, exact equality comes with some additional built-in assumptions.
We can think of the type theory of HTS as divided into two levels, each of which is a version of type theory on its own. The first is the actual object of study and close to HoTT; HTS refers to it as the fibrant fragment, and its equality type is the usual path type. In the second type theory, it is possible to reason about, rather than in, HoTT; this is the "full" type theory of HTS with all types including not necessarily fibrant ones, and its equality type is viewed as "internalised judgmental equality". We call a system of this form (and the study of such systems) two-level type theory (2LTT). The two levels are respectively called inner and outer ; for this paper and for HTS, the inner level is a version of HoTT. 1 We strive to keep the assumptions on 2LTT to a minimum. For example, while HTS assumes that types of the inner level are (in some appropriate sense) a "subset" of the outer level, we do not make this assumption. Instead, we only request that there is a conversion function from the inner level to the outer. This is not as drastic of a change as it may sound, and it allows for a larger class of models. Of course, the HTS setup is the special case where the conversion function is simply an inclusion, and a user of 2LTT is free to add this or other such assumptions to the theory they consider, as least as long as these assumptions are justified by a model. We discuss such variations in Subsection 2.4. However, most of the theory in the later part of this paper is developed without such assumptions.
One intuition for the two levels is as follows: from a type in HoTT, we can extract a statement that can be phrased in the meta-theory. From a meta-theoretical statement about HoTT, it is not always possible to construct a type. Thus, we can convert inner types into outer one, but not always vice versa.
The fact that HTS calls inner types fibrant suggests an interpretation in model categories or similar models of abstract homotopy theory. We will adopt a similar terminology, but choose to reserve the term fibrant for a slightly different notion: an outer type is fibrant if it is isomorphic to an inner one. This makes mixing the two levels more convenient when working internally.
While HTS is an answer to question 2, it does not seem suitable as a tool to address question 1: the theory of HTS has not been designed to be conservative over HoTT. Thus, it is unclear what the relation is between statements provable in the inner level of HTS and statements provable in HoTT. The version of 2LTT that we study in this paper does have this conservativity property over HoTT [Cap16] (see Subsection 2.6). That is, given a type in any context in HoTT, if the corresponding type in the inner level of 2LTT is inhabited, we obtain an inhabitant of the original type in HoTT. This can be seen as a canonicity property of the inner level with respect to the full system. It is unknown whether the same is the case for HTS, but we do not expect it (see the discussion in Subsection 2.4). This crucial difference between our version of 2LTT and HTS is however not due to the differences mentioned so far. Instead, the reason is that HTS assumes that many type formers (apart from equality), in particular empty, unit, and natural number type are shared between the two levels. In our setting, this would correspond to the assumption (A1) of Subsection 2.4 that the conversion function from the inner to the outer level preserves these type formers, and such a strong assumption is not covered by the mentioned conservativity result [Cap16]. In summary: the basic version of 2LTT that we work with in this paper is suitable to address question 1, and the framework makes it easy to add additional axioms, also weaker ones such as (A2), which allows it to address question 2.
The idea of semisimplicial types can be developed further as demonstrated by Shulman, who considers diagrams over a larger class of categories [Shu15b]. For clarity of what happens, we switch back to the setting of HoTT rather than 2LTT. Shulman shows that, given externally a category C with a certain property (being inverse), we have a well-behaved notion of type-valued diagrams over C (called Reedy fibrant). For finite C, there will even be a type of such diagrams. Note that C is not a variable that we can quantify over inside the type theory: it is assumed to be given externally. In other words, if we choose a concrete instance for C, we can take a proof assistant, implement the type of these diagrams, and work with them internally. However, if C is an internal variable, this is not possible. 2LTT offers a setting in which this situation can be developed and formalised: C becomes a variable in the outer level, and we will demonstrate in this paper how this can be done (see Section 4). Semisimplicial types restricted to level n are the special case where C is taken to be the initial segment of length n of the semisimplex category.
Without 2LTT, a standard approach to the development of such a theory of diagrams over C is to fix a (possibly arbitrary) model of type theory and work in the corresponding category, using categorical tools. This requires carefully mixing internal notions with external ones, and there may not always be a clean way to achieve that. In the mentioned work by Shulman, the role of the model of HoTT is played by a type-theoretic fibration category (TTFC). Most results of their paper are formulated at that level, that is, as categorical constructions within a particular TTFC. This requires changing style of presentation compared to a more "traditional" type-theoretic exposition, like for example that of the book on HoTT [Uni13]. For instance, one has to work with morphisms rather than terms, fibrations rather than families of types, talk about pullbacks rather than just performing substitutions, and use "diagrammatic" instead of "equational" reasoning techniques. Although these stylistic variations are not necessarily bad in themselves, the fact that one is essentially forced to apply them can lead to difficulties. A testament to that is the fact that, on occasions, the discussed work [Shu15b] falls back to the internal language to formulate certain definitions and properties, as this is much easier than expressing them in a category-theoretic form. 2LTT offers an alternative strategy: Type theory is the only language that is needed, meaning that internal and external reasoning go hand in hand, and the mixing feels very natural.
There are three equally valid ways to think about 2LTT: We can start with the type theory that we want to study (e.g. HoTT), take it as the inner level, and build some of its meta-theory as an additional layer on top of it. Vice versa, we can start with a theory that is suitable as the outer level (e.g. MLTT with function extensionality and unique identity proofs), expose a type family declared as the universe of inner types, and develop the inner level from there. As the middle ground, we can think of the inner and outer theories as coexisting side-by-side, with a shared notion of context, related only by a conversion function from the inner to the outer level. We take this middle ground as our setup, but our point of view, reflected in our choice of terminology, is the second: we consider the outer level as the "default" type theory, and in particular, equality and equality type will always mean the equality type of the outer level. When talking about constructions that happen at the inner level, we will make this clear explicitly, and the equalities of the inner level are referred to as inner equalities or path-equalities. We make this choice for a number of reasons. First, it is reasonable when considering models, since the equality of the outer level is much closer to actual "external equality" than path-equality is (see Subsection 2.5). Second, our choice is also pragmatic since, in practice, one works in the outer theory most of the time as the outer theory is more expressive. For example, in the outer theory, a (small) diagram of types always has a limit that can be calculated in the same way as in the category of sets. In general of course this will not be fibrant, but the ability to talk about it will be useful nevertheless. Finally, our choice also matches the way that 2LTT can be implemented in existing proof assistants such as Coq, Agda, or Lean. We have formalised some of the results in this paper in this style. 2 1.1. Context of this paper and related work. The current paper significantly reworks and extends the idea of 2LTT that Altenkirch and two of the current authors have presented at the CSL'16 conference [ACK16]. As discussed, a main inspiration for the development presented in the current paper is Voevodsky's HTS [Voe13], which itself was suggested as an answer to question 2. The other aspect (question 1) is perhaps a bit closer to the motivation for Maietti's minimalist two-level foundation for constructive mathematics [Mai09] (also cf. the work with Sambin [MS05]). There, the reason for the split of the theory into two levels is that it allows to have minimal type theory as (what we call) the inner level, a type theory that is free of extensionality principles and implements a specific formulation of the proofs-as-programs paradigm, while still having an (in our terminology) outer level with powerful principles. Somewhat similarly, 2LTT has an inner level that can be taken to be free from principles that are not part of HoTT, while such principles can then be added via the outer level. Angiuli, Hou (Favonia), and Harper [AHH18] present cartesian cubical type theory as a two-level system.
2LTT as presented in the current paper (or, rather, a previous draft of it that had been available for a while) has been used by and connected to several other lines of work. One is the book The Univalence Principle by Ahrens, North, Shulman, and Tsementzis [ANST21], using the setting to formulate and prove a very general result stating that equivalent mathematical structures are indistinguishable. 3 Going in a different direction, Kovács uses 2LTT for staging with dependent types [Kov22] and, in particular, shows that staging with stability and soundness corresponds to conservativity over the inner level. Yet another application was given by Barras and Maestracci [BM20], using a two-level type theory in Dedukti [ABC + 16] to encode cubical type theory. Finally, 2LTT provides a framework which may be expressive enough to "eat" (model in a partially synthetic sense) HoTT [Kra21].
Other suggestions to address question 2, i.e. systems that make it possible to develop a theory of semisimplicial types and higher categories, have been made. One is the type theory for synthetic ∞-categories by Riehl and Shulman [RS17], a setting that uses additional context layers to express structure that, in 2LTT, would be expressed via the outer equality type. A setting closer to standard HoTT, but less expressive, was suggested by Finster, Allioux, and Sozeau: By equipping HoTT with a universe of judgmentally associative and unital polynomial monads, they can encode higher coherent algebraic structures including ∞-groupoids.
Our formalisation approach of 2LTT mentioned above uses the type theory of Lean as the outer level, and uses type classes to keep track of and automatically propagate fibrancy constraints. We discuss this further in the conclusions (Section 5). This strategy is similar to the one used by Boulier and Tabareau [BT17] in Coq, although their development proceeds in a direction different from the one pursued in the present paper. They define the fibrant equality type as a private inductive type [Ber13]. Exposing a custom induction principle for such a private inductive type allows one to retain computational behaviour while restricting the user to explicitly provided eliminators. However, private inductive types are not available in all proof assistants. Agda supports a version of 2LTT more directly via a universe of "strict sets" SSet. 4 Agda's approach is somewhat different: instead of starting in the outer level and encoding inner types from there, it treats Agda's types as fibrant by default and adds a new universe to simulate the outer level instead. 2LTT in this setting has been explored by Uskuplu [Usk22].
1.2. Outline. The outline of the paper is as follows. In Section 2, we specify the version of 2LTT that we consider in this paper. We intentionally include as few assumptions on the theory as possible, but we also discuss a number of reasonable additional assumption that one would like to make. The section also discusses the semantics of 2LTT, with some minor differences to the development of [Cap16]. Indeed, we think of 2LTT as being defined via its category of models. We show basic results and introduce the useful notions of fibrancy and cofibrancy in Section 3. This section, we hope, turns 2LTT into a language which can be useful for the study of concepts that are not completely internal to HoTT. A first such application can be found in Section 4, where we develop the theory of Reedy fibrant diagrams over inverse categories. We conclude in Section 5 with a short discussion on formalisations.

Two-level type theory
The basic idea of 2LTT is that it contains two separate levels of types: • the outer level, which is a form of traditional Martin-Löf type theory with intensional equality types and the principle of uniqueness of identity proofs (UIP); • the inner level, which is essentially homotopy type theory, and contains univalent universes and potentially higher inductive types [Uni13].
In this section, we start by suggesting a syntax for 2LTT. We strive to be close to the standard syntax of MLTT and HoTT as used in the book [Uni13]. In a nutshell, we have two copies of each basic type or type former, one outer and one inner. Inner types can be converted to outer types via a separate operation, and contexts are shared between the two levels.
Our suggested syntax should not be understood as a complete specification of 2LTT: such syntactical specifications require many more rules than we give, most of which are obvious and standard but nevertheless important. Instead, we give a precise specification of 2LTT with a semantic approach. We define what a model of 2LTT is (essentially a combination of two categories with families [Dyb95] which share a common category of contexts). From this definition, it is clear that the suggested syntax can be used to perform constructions in any model of 2LTT.
Remark 2.1 (Initiality of the syntax). We can view the syntax as notation which works in any model, and this is how we understand the developments in later sections of the paper. Our category of two-level models will be the category of models of a generalised algebraic theory and thus be locally finitely presentable. As such, there is in particular an initial model for two-level type theory, and of course, all constructions will work in this initial model. If one were to make the syntax precise (cf. [BA21,BAK21]), then one would expect this initial model to coincide with the term model. However, it is known in the community that a complete proof for this sort of statement requires a lot of work. For the calculus of constructions, this was carefully worked out by Streicher [Str93a], and formalisation projects for intensional Martin-Löf type theory were described by de Boer, Brunerie, Lumsdaine, and Mörtberg [BdBLM19, LM18, BL18, BL20]. An Agda formalisation is available as part of the licanciate thesis by de Boer [dB20]. It may be possible to adapt these proofs to two-level type theory, but this is beyond the scope of the paper. While the question is of course important for type theory in general, it is orthogonal to the specific idea of having two levels.
After specifying 2LTT via models, we observe some immediate consequences from the definitions: for example, Π-and Σ-types are preserved up to isomorphism when converting from outer to inner types. Other properties do not follow from the definitions but could be added as assumptions, leading to systems such as HTS, and we discuss these assumptions separately. We also discuss several specific example models (or classes of example models), and prove a conservativity property for 2LTT without further assumptions. Further, we examine the possibility of an inner replacement (or fibrant replacement).
2.1. Syntax. We stay close to the presentation of type theory given in the appendix in the homotopy type theory book [Uni13, App. A.2]. There is however one technical difference that we want to make. The semantics of Russell-style universes (where terms of the universe are types) is less elegant than the one of Tarski-style universes (if A is a term of a universe, then El A is a type), and the former can be seen as a special case of the latter. This is a general observation in type theory which has little to do with the idea of having two levels; see also point (M2) in Subsection 2.4.
We consider the judgments Γ ctx, Γ ⊢ a ∶ A, and Γ ⊢ a ≡ a ′ ∶ A. In addition, we consider the two judgments Here, j is a natural number, the size of A. The first means that A is an outer type, the second that A is an inner type. Similar to the judgment Γ ⊢ a ≡ a ′ ∶ A, we consider equality judgments for types. For the outer level of the theory that we consider, we have the following basic types and type formers: • Π, the type former of dependent functions; • Σ, the type former of dependent pairs; • +, the coproduct type former; • 1, the unit type; • 0, the empty type; • N, the type of natural numbers; • =, the equality type; • a cumulative hierarchy U 0 , U 1 , . . . of universes; • inductive and quotient types (not used in this paper).
The inner level of our 2LTT has the same basic types and type formers. We annotate them to avoid confusion: 5 • Π i , the type former of inner dependent functions; • Σ i , the type former of inner dependent pairs; • + i , the inner coproduct type former; • 1 i , the inner unit type; • 0 i , the inner empty type; • N i , the inner type of natural numbers; • = i , the inner equality (or path-equality) type (in the sense of HoTT); • a cumulative hierarchy U i 0 , U i 1 , . . . of inner universes; • possibly inductive and higher inductive types. The basic rules for Π, +, 1, 0, N, as well as Π i , + i , 1 i , 0 i , N i are the standard ones and match those given in the HoTT book [Uni13, Appendix A.2], modulo the difference between Russell and Tarski universes. For Σ and Σ i , we assume in addition the judgmental η-law x ≡ (π 1 (x), π 2 (x)). 6 Note that all inference rules in the cited appendix are stated in terms of universes, and in our situation, all occurrences of A ∶ U j are replaced by A type j and A ∶ U i j by A type i j ; this keeps the two levels separate. For example, for the formation of coproducts, we have the rules To emphasise, these rules do not allow us to form a coproduct of an inner and an outer type! The outer equality type = and inner equality (path-equality) type = i have the usual rules as well. Since equality is the central aspect of 2LTT, we state the rules for the outer equality type explicitly, although they are completely standard: together with the usual computation rule: The rules of the inner type are the same, with type j replaced by type i j , = by = i , and refl a by refl i a . The El operator is assumed to be an isomorphism between terms 5 In a previous version of this article, inner components were annotated with o (e.g. Σ o ) instead of i (Σ i ). Other authors don't annotate the inner components at all and annotate outer type formers instead, e.g. Σ s (s for strict) [ACK16] or Σ e (e for exo) [ANST21]. 6 Not all authors assume the judgmental η-law for Σ-types, with the possibly most prominent example in the current context being the HoTT book [Uni13]. This law simplifies our theory somewhat: see (2.2) of Lemma 2.11 and the discussion in Remark 2.12. In its absence, we would work with telescopes of inner types as a substitute for inner dependent sums.
of U j (or U i j ) and (inner/outer) types at level i. For the outer equality type, we furthermore assume the principles of UIP and function extensionality: Instead of UIP, we could add the slightly stronger principle called Axiom K [Str93b]. This is a version of (2.1) (with its computation rule) for inducting on loops with a fixed base point. It does not make a difference in our treatment. All inner universes U i j are assumed to be univalent in the sense of homotopy type theory.
Context extension also follows the rules of [Uni13, Appendix A.2], but note that there is only one judgment of the form Γ ⊢ ctx and there are two hierarchies of types. Since context extension works for every type, we have: This means that contexts are shared between the two levels.
Finally, we have a conversion operation c which turns inner types into outer types: Whenever we have Γ ⊢ A type i j , we have a type c(A) such that Γ ⊢ c(A) type j and this operation preserves context extension, in the sense that Γ.A and Γ.c(A) are the same context. This operation is natural in Γ, and the detailed specification is given in the next subsection. Preservation of context extension in particular means that the set of terms of A and c(A) are isomorphic. For the "forwards-direction" we again write c, that is, for Γ ⊢ a ∶ A, we have Γ ⊢ c(a) ∶ c(A).

Semantics.
We define what it means to be a model of two-level type theory. For this, we use the language of categories with families (cwfs) [Dyb95]. We have a choice of how to handle universe hierarchies. In this work, we aim for concreteness and fix a cumulative hierarchy indexed by natural numbers, with no notion of toplevel type.
Given a presheaf F over a category E, we denote by E F its category of elements. Recall the following notion.
In the above, [σ] denotes the action of Ty on the morphism σ. The action of Tm on morphisms is written similarly. These operations are referred to as substitutions of types and terms, respectively.
We treat Definition 2.2 as having algebraic character, immediately giving rise to a category of cwfs. This applies to all the definitions in this subsection. They are to be read as not just introducing a certain concept (algebraic in character), but also the corresponding notion of morphism for it, part of a category structure.
Lemma 2.3. Naturally in the cwf E, Γ ∈ E, and A ∈ Ty(Γ), the set Tm(Γ, A) is isomorphic to the set of sections of p A , with the isomorphism given by terminality of (Γ.A, p A , q A ) and substitution of q A .
In the usual fashion, one has notions of cwfs with type formers and axioms such as Π-types, identity types, and function extensionality. In the following, we abbreviate a generic selection of such type formers and axioms by T and speak of cwfs having type formers T .
Given a cwf E, we also speak of a cwf structure on the category E. We abbreviate such a cwf structure just by its presheaf of types. By restriction, we obtain a category of cwf structures with type formers T on a fixed category E. Note that the action of its morphisms on terms is an isomorphism (this follows from preservation of extension).
Definition 2.4. A cwf hierarchy Ty with type formers T on a category E is a sequential diagram Ty 0 / / Ty 1 / / . . .
of cwf structures with type formers T on E.
We can regard a cwf hierarchy as a multi-sorted cwf indexed over the poset ω. This makes it a cumulative hierarchy. Note that the natural transformation Ty j → Ty j+1 preserve the type formers T . We will omit the subscript index into the hierarchy when it is inferable or we are only interested at a fixed index.
Definition 2.5. A model of Martin-Löf type theory with type formers T on a category E is a cwf hierarchy Ty with type formers T on E together with, for each j, a global section U j of Ty j+1 with an isomorphism El j ∶ Tm j+1 (Γ, U j ) ≃ Ty j (Γ) natural in Γ ∈ E.
We refer to such a model by just its cwf hierarchy Ty. We call U j the j-th universe. If unambiguous, we will omit the universe index j. Note that the above definition models a cumulative hierarchy of universes (closed under type formers), with no top-level notion of type.
We consider two important kinds of models of Martin-Löf type theory.
Definition 2.6. A model of set type theory is a model of Martin-Löf type theory with the following formers: (i) 1 Σ Π-types, all with η-laws (i.e. satisfying universal properties); (ii) identity types, empty types, (binary) coproduct types, and natural number types; (iii) uniqueness of identity proofs and function extensionality.
Definition 2.7. A model of homotopy type theory is a model of Martin-Löf type theory with the type formers (i) and (ii) of Definition 2.6 that is univalent, i.e. (U j , El j ) is univalent in Ty j+1 for each j.
In applications, one can add more type formers to these notions as desired, for example higher inductive types to Definition 2.7 or quotient types to Definition 2.6. All our example models of set type theory are in fact models of extensional type theory, i.e. have equality reflection. For our developments here, the given type formers will suffice.
Definition 2.8. A two-level model (of Martin-Löf type theory) with inner type formers T i and outer type formers T consists of: • a category E (contexts), • the inner level, a model Ty i with type formers T i on E, • the outer level, a model Ty with type formers T on E, • a conversion morphism c∶Ty i → Ty of cwf hierarchies (with no type formers) on E, converting inner types to outer types.
Ignoring type formers, a two-level model can be seen as a multi-sorted cwf indexed over the poset {0 → 1} × ω. With type formers, we have two separate multisorted cwfs (with inner and outer type formers, respectively) indexed over ω. The conversion morphism c can be described as a morphism of multi-sorted cwfs that is the identity on the category of contexts. Consequently, context extension is automatically preserved: if we have Γ ⊢ A type i j , then Γ.A and Γ.c(A) are the same object of E. 7 Note that we assume no interaction between inner and outer type formers under the conversion morphism.
Finally, we can make precise two-level type theory.
Definition 2.9. A model of two-level type theory is a two-level model of Martin-Löf type theory where: • the inner level is a model of homotopy type theory, • the outer level is a model of set type theory.
2.3. Preservation of type formers by conversion. For this subsection, we fix a model E of two-level type theory. We have assumed very little about the conversion morphism c ∶ Ty i → Ty, but in this subsection, we see that it being a morphism of cwf hierarchies allows us to derive important properties. Proof. This follows from Lemma 2.3 since c preserves context extesion.
Further, we can use that many types are characterised by universal properties (the syntactical equivalent of which are elimination rules). The consequences are summarised in the following statement.
Lemma 2.11. Let Γ ∈ E, A ∈ Ty i (Γ), and B ∈ Ty i (Γ.A). We have the following morphisms natural in Γ. All morphisms live in the slice over Γ (and (2.7) lives in the slice over Γ.A.A): Moreover, the three annotated morphisms are natural isomorphisms.
Before constructing the morphisms, let us make some remarks. Via the adjunction with Π, the above morphisms give rise to internal functions at the outer level. This way, isomorphisms become judgmental internal isomorphisms, i.e. the functions in both directions compose judgmentally to the identity. 7 Of course, the notion of a two-level model could be weakened to let c only preserve the universal property of context extension, not the context extension operation itself; i.e. one could require Γ.A ≃ Γ.c(A) instead of an equality. Similarly, one could consider two separated multisorted cwfs with a morphism that induces an equivalence on the categories of contexts. However, all our models in Subsection 2.5 satisfy the rather strict requirements of Definitions 2.8 and 2.9.
It is also worth emphasising the asymmetry that the conversion function c introduces: In general, the rules of the system mean that it is usually easier to eliminate from outer types into inner types than vice versa. While Π, Σ, and 1 at the outer level are "the same" as at the inner level, in the sense made precise in the lemma above, the same is not automatically the case for the remaining types and type formers. For the case of equality types however, this assumption would destroy our motivation for two-level type theory altogether. Although invertibility of (2.4) to (2.6), discussed in Subsection 2.4 under (A1), does hold in some of the intended models, it is not valid with the point of view of the outer level as internalized metatheory of the object theory given by the inner level, made precise by the presheaf model of two-level type theory in Subsection 2.5.3. From that point of view, some of the maps and the absence of their invertibility can be understood as follows: • Coproducts A + B: given a term of A or a term of B in the meta-theory, we get an element of A+ i B, but not vice versa. For example, the context might not allow us to normalise an element of a coproduct type to a coprojection. • Empty type 0: from a contradiction in the meta-theory, one can get a contradiction in the object theory, but not vice versa. • Natural numbers N: we think of an external natural number as a numeral.
From a numeral, one can get an internal natural number, but from an element of the inner natural numbers type, we do not always get a numeral.
• Equality x = y: two meta-theoretically (e.g. syntactically) equal expressions are provably equal via reflexivity, but provably equal expressions might not be equal meta-theoretically (syntactically). The last morphism (2.8) says that inner types are (up to c) outer types, but we would not expect the reverse since not every meta-theoretic statement can be internalised.
Proof of Lemma 2.11. We start with the three isomorphisms. Recall that inner and outer 1 Σ-types come with η-laws. Since c preserves context extensions, it easily follows that c preserves these type formers up to canonical isomorphism. In fact, this is true for cwf morphisms in general, without the requirement that the underlying functor is an identity. In detail, the isomorphism (2.1) is given by Since Π-types in the inner and outer level come with the η-law, their terms are uniquely characterised as terms of the codomain type. We have, naturally in σ ∶∆ → Γ: from which (2.3) follows by Yoneda. The morphism (2.4) is given by the usual properties of outer and inner coproduct. We have Γ.A → Γ.c(A + i B) and Γ.B → Γ.c(A + i B) due to the inner coproduct, and the outer coproduct lets us construct (2.4). The morphism (2.5) comes from the outer empty type 0; no property of the inner empty type is used.
Outer equality implies inner equality in the sense of (2.7) by the J-eliminator of the outer equality and Lemma 2.10. Finally, (2.8) uses the isomorphisms El j and El i j . Remark 2.12. For "positive" type formers such as empty types, coproduct types, natural number types, or identity types, we cannot hope for preservation up to isomorphism by c, even if we add η-laws to both the inner and outer type former. This is because their universal property talks about maps out of the type in question into another type of the same level, rather than an arbitrary object of the slice. For example, for empty types with η-law in both inner and outer level, we have natural isomorphisms E Γ(Γ.0 i , Γ.C) ≃ 1 for C ∈ Ty i (Γ) and E Γ(Γ.0, Γ.C) ≃ 1 for C ∈ Ty(Γ). To be able to conclude that Γ.0 i ≃ Γ.0 over Γ, we would have to apply the universal property of 0 i to an outer type C.
Our proof of the isomorphism (2.2) uses the judgmental η-law for Σ-types, a rule that is not assumed by all authors. If we only assume the induction principle with which the HoTT book [Uni13, Chp 1.6] characterises Σ-types, without a judgmental η-law, then Σ becomes a positive type former, not generally preserved by c.
In some of the models we discuss in Subsection 2.5, the comparison maps (2.4) to (2.8) are indeed not isomorphisms.
2.4. Strengthenings and extensions. In Subsection 2.2, we have defined twolevel type theory in a minimalistic fashion, eschewing properties that one might argue are reasonable to ask for. Indeed, other two-level type theories such as HTS are much more rigid.
We separate possible strengthenings into three groups. The first group has nothing to do with two-level type theory proper, concerning only the basic structure of models of Martin-Löf type theory as per Definition 2.5. In a model of two-level type theory, this applies to both inner and outer levels separately.
(M1) We can ask that the step maps Ty j → Ty j+1 in the cwf hierarchy are mono. In a set-theoretic metatheory, we could go further and demand the step maps are subpresheaf inclusions. (M2) We can ask that the natural isomorphism El ∶ Tm(Γ, U j ) ≃ Ty j (Γ) is an equality on the nose, i.e. that Tm(Γ, U j ) = Ty j (Γ) and El = id. This has the effect of modelling Russell-style universes. Implementing both of these points makes it possible to forgo the distinction between types and terms (with types just being terms of universes), treating the typing relation as going between terms. Together with univalence, this yields a type theory as in the homotopy type theory book [Uni13, App. A.2] (but note that the η-law for Σ-types is not included there).
The second group concerns strictness properties of the conversion morphism c relating the inner to the outer level in a model of two-level type theory as per Definition 2.9.
(T1) We can ask that the conversion morphism c ∶ Ty i → Ty is mono on types, i.e. that c ∶ Ty i (Γ) → Ty(Γ) is injective for Γ ∈ E. In a set-theoretic metatheory, we could demand this is on the nose, i.e. that c is a subpresheaf inclusion on types (and that the action on terms is not just an isomorphism, but an equality). (T2) We can ask that the isomorphisms of Lemma 2.11 witnessing preservation of 1/Σ/Π-types under the conversion morphism c are equalities on the nose. For Π-types, this means the following: If we ask for any other type formers to be preserved by c up to canonical isomorphism (such as in (A1) below), we can similarly ask that these isomorphisms are equalities on the nose. (T3) We can ask that inner types are replete within outer types, i.e. that any outer type with extension isomorphic to that of an inner type is itself the image of an inner type under conversion. In detail, given A ∈ Ty(Γ) and Implementing (T1) and (T2) essentially yields an (outer) type theory with a predicate of "being inner" on types that some type formers are closed under. With inner types named "fibrant", this is the perspective taken in HTS.
The third group concerns more semantical extensions or axioms that will differ depending on what kinds of models one is interested in.
(A1) We can ask that conversion preserves certain "positive" type formers (minus identity types) up to canonical isomorphism, making for example the following canonical comparison maps over Γ ∈ E invertible: We can weaken this by asking for an inverse only up to the outer identity type. Then these properties become axioms internal to two-level type theory. (A2) The following is a weakening of the assertion of (A1) for natural numbers that still allows for the construction of inner types of Reedy fibrant semisimplicial types (see Lemma 4.38 and afterwards). We can ask that countably infinite towers of (trivial) fibrations have (trivially) fibrant limits. The notion of fibration used here will be defined in Subsection 3.2 in terms of inner types. This is an internalization (to the outer level) of the corresponding axiom considered for (co)fibration categories [RB06, Definition 1.6.1] (see also [Shu15b,Lemma 11.8]). (A3) Weakening (A2) further, we can ask that the outer natural number type is cofibrant. The notion of cofibrant type will be defined in Subsection 3.4, essentially meaning that exponentiation with it preserves inner types up to isomorphism. This axiom has been suggested by Shulman. (A4) We can ask that the outer universes are "fibrant", i.e. that there is u ∈ Ty i (Γ) such that Γ.U ≃ Γ.u over Γ (or even U = c(u)), naturally in Γ ∈ E. Again, we can weaken this to an isomorphism up to the outer identity type, making it an axiom internal to two-level type theory concerning universes. (A5) We can ask that the outer level validates the equality reflection rule, i.e. forms a model of extensional type theory. This is the case in all the example models we are interested in.
We phrase this as an extension so that the base systems retains good metatheoretical properties such as decidability of type checking. This is relevant for faithful implementation by current proof assistants (note though that some systems such as Andromeda [BGH + ] model equality reflection).
As a compromise, one may add features to the outer level that are partially extensional while retaining decidability of type checking. An example is the recent addition of universes of strict propositions (with judgmental uniqueness of elements) to Agda and Coq [GCST19]. (A6) We may add more type formers to the inner or outer level as desired. For example, since the inner level is simply a version of homotopy type theory, it is natural to add inner higher inductive types. We can even add higher inductive-inductive types (see e.g. [Uni13] for examples, and [KK19a] for a specification). Similarly, we can add quotient types or quotient inductiveinductive types [ACD + 18, AK16, ADK17] to the outer level (note that the presence of uniqueness of identity proofs makes higher equalities moot). Note that one may identify HTS as two-level type theory in our sense extended with the axioms (A1), (A4), (A5), (T1), and (T2), in their strongest form. In the following subsection, we will discuss which of the above strengthenings and extensions hold in each of several example models. This will provide justification for not including most of the above conditions as blanket assumptions. It will also serve as a guide to the reader on which assumption to include in their two-level type theory when they have a certain class of models in mind.
2.5. Example models. We discuss some key models of two-level type theory. All have in common that the underlying category is presheavesĈ over a category C and that the outer level is given by the standard presheaf model of extensional type theory (in particular, (A5) is validated) where types are (small) presheaves over the category of elements of their context. The only exception to this is in Proposition 2.16, where the outer level is different.
We briefly recall key details of this presheaf model in a set-theoretic metatheory. Fix a sequence of Grothendieck universes M 0 ∈ M 1 ∈ . . . such that C lives in M 0 . Given Γ ∈Ĉ, then Ty j (Γ) consists of presheaves over C Γ valued in M j and Tm j (Γ, A) is the set of global sections of such a presheaf A. Then Ty j is represented by U j ∈Ĉ where U j (X) is the set of presheaves over C X valued in M j , which itself lives in M j+1 . This defines the universe U j ∈ Ty j+1 (1). With types presented in this displayed form, the standard definition of type formers is substitution-stable and preserved under size change.
The above definition of types and universes is essentially that of Hofmann and Streicher [HS97]. Other constructions are possible, for example following Voevodsky [KL18, Subsection 2.1] or Shulman [Shu15a] (the latter construction works equally in the non-univalent setting of classifying all maps, not fibrations), but necessitate further work to split type formers.
2.5.1. Simplicial sets. The first model of homotopy type theory was in simplicial sets [KL18]. As already remarked in that paper, simplicial sets, being a presheaf category, exhibit two separate, but related, structures of models of type theory: the one constructed in the paper itself, and the one that every presheaf category has, modelling extensional type theory. This idea can be expanded by making simplicial sets a model of two-level type theory. We suspect that an observation along these lines motivated Voevodsky's HTS. 8 Letting C = ∆ be the simplex category, the outer level is the presheaf model of simplicial sets as explained above. The inner types over Γ ∈∆ are interpreted as the subset of those outer types whose corresponding "display map" with target Γ is a Kan fibration, making (T1) hold. Kan fibrations are closed under isomorphism, hence (T3) holds (in fact, this can be strengthened to closure under retracts).
The inner identity type is modelled by the cotensor with ∆ 1 . Recall that its elimination operation has a splitting issue. We follow the splitting strategy introduced by [KL18], interpreting the offending operation in the universal context that captures its inputs. For this, one might try to use the representing object U j for i-small types. However, the size change map Ty i j → Ty i j+1 would then not preserve the operation. 9 Instead, as in [KL18], we introduce yet another Grothendieck universe M ω containing M 0 , M 1 , . . ., define a presheaf U ω as above, and use it to build the universal context.
Since generating trivial cofibrations in the form of horn inclusions have representable codomain, the presheaves of inner types are representable, yielding the inner universes. They are fibrant and univalent as in [KL18].
Following the setup of [PO18], a more internal development of the simplicial set model in line of the above choices is described in [CHS19, Appendix D]. It also describes (following a suggestion by Andrew Swan) how the higher inductive types constructed in the cubical setting in [CHM18] interpret in the simplicial model (A6).

Cubical sets.
A similar class of models of two-level type theory is given by cubical sets for various choices of a cubical site and notion of fibrations [BCH14,CCHM17]. In contrast to [KL18], these models of homotopy type theory have been developed from the start with Hofmann-Streicher universes in mind and all type formers split by construction. Thus, they immediately fit our setup and we can simply declare them to form the inner level.
The development of cubical models of [PO18,LOPS18] can be interpreted as defining the inner level internally to the outer level. Note that this requires extending the outer level to crisp type theory [LOPS18,Shu18].
A major difference to the simplicial model is that cubical Kan lifts are part of the structure of inner types. That is, an inner type is not just an outer type satisfying a lifting property, but has an additional datum in its Kan composition operation. This invalidates (T1). Other strengthenings (T2) and (T3) and (A1) to (A6) hold in the same manner as discussed above for simplicial sets.
The reason that simplicial and cubical sets model validate (A1) is, in both cases, that fibrant objects (in slices) are closed under small coproducts. We will first establish some preliminaries. A weak morphism F ∶ C → D of cwfs is a functor between underlying categories with natural transformations on types and terms that preserves the global context and extension only up to canonical isomorphism. Given interpretations of type formers T in C and D, it still makes sense to ask that F preserves the operations of T , transporting along these preservation isomorphisms when required. Indeed, by expressing the type formers T in a cwf E as operations internal to its presheaf categoryÊ, one may completely avoid the dependency of T on extension as an algebraic operation [Cap16,Uem19]. Thus we obtain a notion of weak morphism of cwfs with type formers T .
There is an evident notion of 2-morphism between weak cwf morphisms F, G∶C → D, a natural transformation u∶F → G such that for Γ ∈ C and A ∈ Ty C . This extends to a notion of 2-morphism for cwfs with type formers T by requiring that substitution along the components of u preserves the operations of T . With this, we obtain a (strict) 2-category of cwfs (with type formers T ) and weak morphisms. It has the 1-category of cwfs (with type formers T ) as a wide sub-2-category. Importantly, the initial object C of the 1-category of cwfs (with type formers T ) becomes biinitial in the 2-category of cwfs (with type formers T ) and weak morphisms. That is, given an object D with a weak morphism H ∶ C → D, there is an isomorphism H ≅ F between weak morphisms where F ∶ C → D is the unique morphism. This may be derived from making the strict pseudolimit of H (seen as a diagram indexed by the walking arrow) into a cwf E (with type formers T ): • objects are triples (X, X ′ , f ) where X ∈ C, X ′ ∈ D, and f ∶ H(X) ≃ X ′ , • types over such an object are pairs (A, A ′ ) with A ∈ Ty C (X) and A ′ ∈ Ty D (X ′ ) such that H(A) and A ′ correspond over f , • terms of such a type are pairs (t, t ′ ) with t ∈ Tm C (X, A) and t ′ ∈ Tm D (X ′ , A ′ ) such that H(t) and t ′ correspond over f . Note that A ′ and t ′ in the above description are redundant. We have projection morphisms p C ∶ E → C and p D ∶ E → D. By initiality of C, Everything we have said above extends analogously to cwf hierarchies (with type formers T ), models of Martin-Löf type theory (with type formers T ), models of homotopy type theory, and models of two-level type theory.
Recall from [Hof97] that for any category C, the categoryĈ of presheaves over C forms a model of extensional type theory. Here, the types and terms are defined as follows. Given a presheaf P , which we think of as a context, we define Ty(P ) to consists of (small) presheaves over the category C P of elements of P (specifically, for Ty j (P ), we require these presheaves to be valued in the Grothendieck universe M j ). Given such a type A ∈ Ty i (P ) over P , the set Tm(A) of terms is the set of global sections of the corresponding presheaf over C P .
In the special case where C is itself a cwf, we can define an additional, inner cwf structure Ty i on presheavesĈ with a morphism c ∶ Ty i → Ty to the presheaf cwf structure Ty. This works as follows. We can single out a special context (in other words, a type in the empty context), namely Ty C itself. This context can play the role of a universe in the presheaf cwfĈ. In fact, we have a type Tm C ∈ Ty(Ty C ), acting as the universal family of this universe. The cwf structure induced by this universe forms the inner cwf structure Ty i ofĈ. In detail, we define Ty i = y(Ty C ), i.e. Ty i (P ) =Ĉ(P, Ty C ), and let c send A ∈ Ty i (P ) to the restriction of Tm C along the functor C P → C Ty C induced by A, i.e. to c(A) ∈ C P sending (Γ, x) to Tm C (Γ, A(x)). We are then forced to define Tm i (P, A) as the set of global sections of c(A).
The Yoneda embedding y C ∶ C →Ĉ becomes a weak morphism of cwfs (2.9) whose actions on types and terms are bijective by construction of Ty i . Let C now support a selection of type formers T . We can lift the rules in T to corresponding operations and laws on the "universe" Ty C in (Ĉ, Ty), and thereby to interpretations of the type formers T in the inner cwf (Ĉ, Ty i ). Furthermore, the weak morphism (2.9) preserves these, i.e. y C becomes a weak morphism of cwfs with type formers T . This process and its properties are explained in [Hof97] for a specific set of type formers, and in [Cap16] for a generic notion of type former.
We illustrate the above process for the formation operation for dependent products. We desire the following judgment in the presheaf cwf: (2.10) Naturally in Γ ∈ C, we are given: , and have to produce an element Π(A, B) ∈ Ty C (Γ). By the universal property of context extension in C, data in (2) is uniquely induced by just the element B p A ∈ Ty(Γ.A). Thus, our obligation precisely corresponds to the formation rule for Π in C. Furthermore, after lifting to the cwf (Ĉ, Ty i ), we can check that the weak morphism (2.9) preserves the formation rule.
The above example makes it reasonable to expect that every type former can be lifted, rule by rule, from C, producing judgements that replicate each rule internally in the theory ofĈ when expressed using the "universe" Ty C , and that hence one can interpret each rule in the inner presheaf cwf.
The above construction is functorial in the cwf structure Ty C (with type formers T ) on C and 2-functorial in C as an object of the 2-category of cwfs (with type formers T ) and weak morphisms. From this, we obtain the following.
Proposition 2.13. Let C be a model of Martin-Löf type theory with type formers T . Assume that (Tm C ) j is valued in the Grothendieck universe M j for every i. ThenĈ forms a two-level model of Martin-Löf type theory with inner type formers T and outer types formers from extensional type theory. The Yoneda embedding extends to a weak morphism y ∶ C → (Ĉ, Ty i ) of models of Martin-Löf type theory that acts bijectively on types and terms.
Furthermore, this operation is 2-functorial in C as an object of the 2-category of models of Martin-Löf type theory with type formers T and weak morphisms. The action on a weak morphism F ∶C → D is as follows. The left Kan extension F ! ∶Ĉ →D extends to a weak morphism of two-level models as above. The natural isomorphism F ! ○y C ≃ y D ○F of functors lifts to the 2-category of models of Martin-Löf type theory with type formers T and weak morphisms.
Proof. Applying the above discussion to the sequence of cwf structures (Ty C ) j with type formers T on C, we obtain a corresponding sequence of cwf structures with type formers T onĈ. Yoneda preserves terminal objects, so sends the global section U j of (Ty C ) j+1 to a global section U i j of Ty i j+1 . Naturally in Γ ∈ C, we have using that the action of (2.9) on types and terms is bijective. By cocontinuous extension, we thus have Tm i (X, U i j ) ≃ Ty i j (X) naturally in X ∈Ĉ. By the smallness assumption, the map Ty i j → Ty restricts to Ty i j → Ty j .
Seeing univalence as just another type former, the universes U i j in the above model are univalent if the original universes U j in C are.
Corollary 2.14. Let C be a model of homotopy type theory. Assume that (Tm C ) j is valued in the Grothendieck universe M j for every i. ThenĈ forms a model of two-level type theory. The Yoneda embedding extends to a weak morphism y ∶ C → (Ĉ, Ty i ) of models of homotopy type theory that acts bijectively on types and terms. Furthermore, this operation is 2-functorial in C as in Proposition 2.13.
We call this the presheaf modelĈ of two-level type theory over the given model C of homotopy type theory. It will be key for proving conservativity of two-level type theory over homotopy type theory in Subsection 2.6.
Let us discuss strictness properties of conversion satisfies by the presheaf model. Depending on the specifics of the implementation of the outer types, c may or may not have a chance to be mono. With our choice of presheaves over categories of elements, (T1) holds as long as the action of the presheaf Tm C on objects is injective. Note that this can always be achieved by passing through the Grothendieck construction. None of the other strictness properties (T2) and (T3) are satisfied.
Remark 2.15. Concerning (T2), some effort is expended in [Cap16, Chapter 3.2] to achieve strict preservation of 1 Σ Π-types under what we here call conversion from the inner to outer level. This is achieved by defining the inner types more cleverly as certain free expressions involving the types of C and formal 1 Σ Π-type forming operations. Unfortunately, this only works for "top-level" 1 Σ Π-types and breaks whenever the kind of type in question has a classifier that is itself a type (of higher size). Thus, this technique is not applicable here.
The presheaf model does not preserve (up to isomorphism) "positive" type formers as in (A1). Note that the interpretation of empty types, coproducts, and natural numbers in the outer level is levelwise. Were (A1) to hold, then in an arbitrary context Γ in C, there would be no terms of empty type, every term of coproduct type would be a constructor application, and every natural number term would be a canonical numeral. Even the weaker versions (A2) and (A3) do not hold in general. Note that (A2) holds if C supports dependent sums of "arity" ω (also known as record types with countably infinitely many fields). Axiom (A4) is also generally not satisfied.
As for the other example models, the outer level models extensional type theory, i.e. (A5) holds. Extension (A6) holds as far as permitted by the given model C of homotopy type theory.
We end this subsection by giving a modified version of the presheaf model where (T1) and (T2) hold. This is achieved by modifying the interpretation of the outer level. The technique is inspired by Shulman's modification [Shu19, Appendix A] of the local universe splitting technique in the presence of universes (recall though that we do not make use of the local universe splitting technique). Furthermore, this operation is 2-functorial in C in the same sense as Corollary 2.14.
Proof. The following is to be understood as happening for every size index i, which we omit. By a small set, we mean an element of the Grothendieck universe M j .
Let U ∈Ĉ denote the representing object of Ty, with universal element El ∈ Ty(U). Define Ty ′ as the presheaf represented by Ty C +U. We have a map [c, id U ]∶Ty C +U → U. Applying Yoneda, this induces the map r ∶ Ty ′ → Ty. The cwf structure of Ty ′ is inherited from Ty via r. Applying Yoneda to the coprojections inl ∶ Ty C → Ty C + U and inr ∶ U → Ty C + U, we obtain respective cwf structure morphisms c ′ ∶ Ty i → Ty ′ and s ∶ Ty → Ty ′ . These fit into a commuting diagram as follows: nfolding the definition, we find that, given X ∈Ĉ, an element of Ty ′ (X) consists of a partition X = X 0 ⊔ X 1 of X into subpresheaves X 0 and X 1 together with A 0 ∈ Ty i (X 0 ), i.e. A 0 ∶ X 0 → Ty C , and A 1 ∈ Ty(X 1 ), i.e. a small presheaf A 1 over C X 1 .
The interpretation of type formers in Ty ′ other than 1 Σ Π-types is as for Ty and is defined such that it is preserved by r. For the type forming operations, we first transport the given types in Ty ′ to Ty via r, use the corresponding type forming operation there, and apply s to the result. Since r ○ s = id, this makes r preserve the type forming operation, meaning the remainder of the operations dealing with terms can be copied from Ty to Ty ′ .
It remains to interpret 1 Σ Π-types in Ty ′ . Since the terms of these type formers are characterised by universal properties, it will suffice to define their type forming operations such that r preserves 1 Σ Π-types up to isomorphism. The remainder of their operations dealing with terms is then uniquely induced. In order to ensure that c ′ preserves 1 Σ Π-types, we only have to check that c ′ preserves the type forming operations and that the isomorphisms used in the penultimate sentence are the ones of Lemma 2.11 whenever the input types come from Ty i via c ′ .
The case of 1-types is trivial: given X ∈Ĉ, we imply take 1 ′ = inl(1 i ) ∈ Ty ′ (X) using 1 i ∈ Ty i . Since it has no inputs, there is nothing to show. The type forming operations for Σ-types and Π-types are of the same form. To save space, we only show the case of Π-types.
Recall how the Π-type forming operation of Ty i was inherited from the one of Ty C via the operation (2.10). The cwf structure of Ty ′ is induced by El[c, id U ] ∈ Ty(Ty C + U) rather than Tm C ∈ Ty(Ty C ) as for (2.10). Here, we have to interpret the analogous operation in the same context. To define the action at level Γ ∈ C, we take of presheaves over C Γ. We perform a case distinction on A.
using the type forming operation of Ty, and let (2.12) be the identity.
). Since C has extension, this presheaf is representable (represented by Γ.A). In particular, mapping out of it as in (2.11) preserves coproducts. We can thus make a further case distinction on B.
again using the type forming operation of Ty, and let (2.12) be the identity.
using the type forming operation of Ty i , and let (2.12) be the isomorphism given by Lemma 2.11. One checks that this definition is natural in Γ. Recalling that c ′ is given by the action of Yoneda on inl ∶ Ty C → Ty C + U, we find that c ′ preserves Π-type formation by construction (case (ii.b)) with the required coherence isomorphism.
This finishes the verification that Ty ′ forms a cwf hierarchy with the type formers of the outer level of a model of two-level type theory. Note that uniqueness of identity proofs and function extensionality are inherited from Ty (this is immediate for the former; for the latter, use that the outer identity type respects the isomorphism relating Π ′ and Π).
To obtain the universes in Ty ′ , we must encode the representing object (Ty C ) j + (U) j as El(r(U ′ j )) (under the isomorphismĈ ≃ C 1) for some U ′ j ∈ Ty ′ (1). We have V j ∈ Ty j+1 (1) such that (Ty C ) j + (U) j is El(V j ) (under the isomorphismĈ ≃ C 1). So we simply take U ′ j = s(V j ). 2-Functoriality in C is a straightforward calculation.
Note that the cwf hierarchy morphism s in the above proof preserves almost all type formers: the only one not preserved is the unit type. Note also that the technique of Proposition 2.16 is constructive only for finitary type formers: were we to add product types of infinite arity or dependent sums of "arity" ω (ω op -Reedy limits) to homotopy type theory, then to make c ′ preserve these using the above approach, we would have to perform an infinite number of case distinctions before deciding on the result of the corresponding type forming operation in Ty ′ on given inputs, which requires classical logic.
In Subsection 2.6, we will use this modified presheaf model to strengthen conservativity of two-level type theory over homotopy type theory to additionally include conservativity of (T1) and (T2).
None of the other properties (A1) and (T3) to (A6) are generally impacted by the model construction of Proposition 2.16.
2.6. Conservativity. Two-level type theory is an extension of homotopy type theory, which forms its inner level. As such, it makes sense to ask if two-level type theory is conservative over homotopy type theory.
Here, we take the perspective regarding homotopy type theory and two-level type theory simply as the initial models in their respective categories of models, which are the primary notion. Syntax is treated as notation, that is, merely as a device for working within such models. Expressions of our syntax denoting types and terms are just stand-ins denoting certain derivations. We do not analyse them as raw syntactic objects independently from the associated derivation, although such considerations are of course important for the implementation of proof assistants.
What does conservativity mean under this perspective? We have a forgetful functor (−) i from the category of models of two-level type theory to the category of models of homotopy type theory. Letting 0 HoTT and 0 2LTT denote their respective initial objects, we have a unique morphism 0 HoTT → 0 2LTT i . This expresses that any derivation in homotopy type theory can also be performed in two-level type theory. For conservativity, we wish to know reversely that any construction of a type or term, or equality of such, in 0 2LTT i , with given context (and type, in the case of constructions for terms) coming from 0 HoTT , can be lifted to 0 HoTT .
We will employ the following definition of conservativity for a cwf morphism F ∶ C → D, which is, in some sense, the weakest possible. It essentially states that F reflects inhabitation of terms. This formalises the idea that we can use the language of D to prove statements in C.
Definition 2.17. A cwf morphism F ∶C → D is called conservative if for all contexts Γ ∈ C and types A ∈ Ty C (Γ) with an element of Tm D (F Γ, F A), we have an element of Tm C (Γ, A).
Note that is definition is unrelated to the underlying functor F being conservative, i.e. reflecting isomorphisms. Stronger definitions are of course possible, for example requiring that F acts (split) surjectively or bijectively on terms and types, perhaps up to internal notions of equality in D.
Proposition 2.18. Two-level type theory is conservative over homotopy type theory. That is, the morphism !∶0 HoTT → (0 2LTT ) i is conservative. This stays true when the outer level is extended with any type former validated by the standard presheaf model, such as equality reflection (A5).
Proof. We apply the construction of Corollary 2.14 to 0 HoTT and 0 2LTT i , obtaining a diagram 0 HoTT commuting up to isomorphism in the 2-category of models of homotopy type theory and weak morphisms. Conservativity of the vertical map now follows immediately from the fact that the Yoneda embedding acts bijectively on terms.
Using Proposition 2.16, we may strengthen the above statement to two-level type theory with injective conversion morphisms that strictly preserve 1 Σ Π-types.
Proposition 2.19. Two-level type theory with (T1) and (T2) is conservative over homotopy type theory. This stays true when the outer level is extended with any type former validated by the outer level of the modified presheaf model, such as equality reflection (A5).
Proof. This is a copy of the proof of Proposition 2.18, with the presheaf model of Corollary 2.14 replaced by the modified presheaf model of Proposition 2.16.
We conjecture a stronger conservativity result: if equality reflection (A5) holds in the outer level, then the actions of the cwf morphism ! ∶ 0 HoTT → (0 2LTT ) i on types and terms are bijective (and hence the underlying functor is fully faithful). We believe this result can be obtained using the technique of categorical glueing.
A concrete argument has been given by Kovács [Kov22, Corollary 5.5], seen there as "soundness and stability of staging".

2.7.
On the possibility of a fibrant replacement. In homotopical models of two-level type theory, outer types in context Γ correspond to arbitrary maps into Γ, whereas inner types correspond to fibrations with base Γ. From this viewpoint, it is natural to ask whether we could extend our theory with a fibrant replacement operation, allowing us to replace any outer type by its "closest" inner approximation. A syntactic presentation of rules for such a fibrant replacement type former might look as follows: Phrased internally, given an outer type A, we get an inner type RA together with a function r ∶ A → c(RA) with the universal property that, for any inner type X, to define a function RA → X is to give a function A → c(X). Note the similarity of the above rules to those of the propositional truncation modality; the only difference is, of course, that R makes types fibrant rather than propositional. A type former along these lines is considered in [BT17], where the authors construct a model structure on a universe of outer types using fibrant replacement.
Unfortunately, the fibrant replacement operation cannot actually be internalised in the above form while still retaining interesting homotopical models. This is shown by the following theorem.
Theorem 2.20. Assume a fibrant replacement type former R as defined by the rules form-R to comp-R. Then the inner level satisfies uniqueness of identity proofs.
Proof. For an inner type A with u, v ∶ A, the internalisation of (2.7) gives us a canonical map We claim the following: (2.13) By inner path induction, we can assume p ≡ refl i u . Using intro-R it remains to show that, for h ∶ c(u) = c(u), we have (2.14) Because of UIP, we can replace h by refl c(u) , and by observing that i maps the trivial outer equality to the trivial inner equality we get (2.14).
Our goal is to show that A satisfies UIP. Assume now u ∶ A and p ∶ u = i u. It suffices to show p = i refl i u . This follows from (2.13), choosing h to be refl c(u) .
While homotopical models do have fibrant replacement operations coming from weak factorisation systems, they are usually not stable under base change. This prevents internalisation of this operation in the form of the above rules. That is, we may replace an inner type by an outer type, but this operation is not natural in the context. If one still wishes to expose this operation, one option is to make two-level type theory into a modal type theory extended with a notion of crisp types as in [LOPS18]. Then one can state the above replacement operation crisply.
2.8. Notational conventions. The rest of the paper does not concern the metaproperties of 2LTT. Instead, we develop some theory internally to 2LTT. As described above, we use the syntax suggested in Subsection 2.1. For notational convenience, we omit applications of El and pretend that we work with Russell-style universes. As it is fairly standard, we also omit universe indices in the style of typical ambiguity. Similarly, we will keep the conversion operation c between inner and outer types implicit.
Note that we did not assume a built-in universe of propositions in either level (but cf. (A5)). Instead, we define Prop ∶≡ Σ (X ∶ U) . Π x,y∶X (x = y). (2.16) Most of the time, we work with the outer level, which is why we treat that level as the default; note how the inner type formers are annotated with the symbol i , while the outer do not carry annotations. This also means that, when when we say that a diagram commutes, it commutes up to the outer equality type.
For outer types A and B, we can form the type of isomorphisms, written A ≃ B. Note that, because of UIP, asking for maps in both directions such that both compositions are pointwise equal to the identity is well-behaved. For inner types A and B, the inner type A ≃ i B is the usual type of equivalences.

Basic tools: categories, fibrations, and cofibrations
Before we can start working inside two-level type theory, it is helpful to develop some basic theory. As the outer level of the theory is simply a version of MLTT with UIP, we have access to a vast pool of results that are already known. In particular, finite types and the basics of category theory work in the expected way. We will summarise some of that here.
Later on, we will need several notions more specific to two-level type theory. Namely, we are going to define what it means for a function to be a fibration or a cofibration, and for types to be fibrant or cofibrant. These notions will allow us to use the outer level to obtain results that are really about the inner one, without having to explicitly coerce from inner types to outer.
3.1. Preliminaries. Although somewhat trivial, the importance of finite types for our development justifies that we introduce them explicitly. Recall that, in usual type-theoretic terminology, Fin n is the finite type with n elements. In our development, we will use this notation exclusively to refer to finite types in the outer level. One explicit definition is as the type of natural numbers smaller than n, where the order on natural numbers is defined as usual.
We will say that a type X is finite if it is isomorphic to Fin n , for some n, i.e. if we have Σ (n ∶ N) . X ≅ Fin n . The type Fin n is not to be confused with its inner counterpart Fin i n , which exists for n ∶ N i . Of course, we have a canonical function Fin n → Fin i n , where the application of the function N → N i is kept implicit. In a two-level theory satisfying (A1), this would be an isomorphism, but in general, we do not even assume a function in the other direction.
In the following, will make heavy use of category-theoretic notions. Categories are defined in the usual way, within the outer level of the theory.
Definition 3.1 (category). A category C is given by • a type C ∶ U of objects; • for all pairs x, y ∶ C , a type C(x, y) ∶ U of arrows or morphisms; • an identity arrow id ∶ C(x, x) for every object x; • and a composition function ○ ∶ C(y, z) → C(x, y) → C(x, z) for all objects x, y, z; • such that the usual categorical laws holds, that is, we have Given objects x and y of a category C, we also write f ∶ x → y for a morphism from x to y, that is, an element of the type C(x, y). It will always be clear from the context if x and y are types or objects of a category, so that there is no confusion with the function type former. (In the case of a category of types, the two notions agree.) Readers familiar with the chapter on category theory in the HoTT book [Uni13] (and [AKS15]) will note that our definition is exactly the same as that of precategories there. Of course, since our outer theory validates UIP, and therefore every type is a set, we do not need to explicitly add a truncation condition on homsets.
A canonical example of a category is the category of types, whose objects are the types in a given universe U, and whose morphisms are functions. By a slight abuse of notation, we will simply write U to denote this category. Analogously, if C is a category, we allow ourselves to denote the type of objects by C itself.
The usual theory of categories can be reproduced in the context of our categories (as long as we stay constructive). We write [C, D] for the functor category of categories C and D, with the type of natural transformations from a functor F to a functor G also written Nat(C, D). Functors and natural transformations form the objects and morphisms of a (larger) category of categories. We have the usual concepts such as limits and adjunctions and can prove all their usual properties, for example that limits (if they exist) are unique up to isomorphism.
Remark 3.2. We will not indulge in the exercise of replicating the whole of category theory in our outer level, and simply assume, on the empirical evidence provided by several existing developments in the major implementations of type theory, like the aforementioned Agda, Coq and Lean, that doing so is simply a matter of diligence and patience, and it ultimately should present no mathematical difficulties.
Remark 3.3. Despite the above remark, it is perhaps appropriate to add a small explanation of how one might reasonably deal with "size" issues in a formal development of category theory within the outer theory.
When translating category-theoretical statements originally formulated in the metalanguage of set theory, one is posed with the question of what precise typetheoretic meaning to give to the term "small".
As most incarnations of type theory, including our outer level, provide the user with an infinite tower of universes, it feels unnecessarily restrictive to constrain a general term like "small" to a predetermined choice of a universe level.
For this reason, we will not make such a choice, and simply continue the tradition of writing "small" for a type that resides in a universe which is one step below a "default" unspecified universe level. This makes it clear that the absolute level that certain constructions happen to end in is not particularly important, rather what we have to pay attention to are the differences in relative size.
Note that the universe U i of inner types also forms a category, although it is not as well behaved as U. For example, it does not have pullbacks (but see part (i) of Lemma 3.10).

Fibrant types.
Definition 3.4 ((trivially) fibrant type). A type A ∶ U is fibrant if it is isomorphic to an inner type A ′ ∶ U i . It is trivially fibrant if the inner type A ′ is furthermore contractible.
Note that fibrancy (and similarly trivial fibrancy) is a proof-relevant notion, in that being fibrant is not a proposition (in the sense of having at most one element). A fibrant type A carries with it a choice of an inner type A ′ and an isomorphism f ∶ A ≅ A ′ relating its coercion to a type to the original type A (and a trivially fibrant type furthermore carries an element witnessing inner contractibility of A ′ ). This should be kept in mind in our use of language when we use being fibrant as an adjective. For example, when we say that A is fibrant exactly if B is fibrant, what we mean is functions back and forth between the types witnessing fibrancy of A and B.
Generally speaking, our use of informal language in the outer level follows the mantra of "propositions as types". Thus, similar conventions as established in the previous paragraph apply to notions such as fibrations and cofibrations defined below (and their Reedy variants considered later).
We write U fib for the type of fibrant types in U. Note that it is itself not generally fibrant (although it is in some of the intended models such as simplicial sets). We let U fib inherit the category structure of U. Note that the functor U fib → U is the replacement of the coercion functor U i → U by an isofibration. In particular, fibrant types are closed under isomorphism. We allow ourselves to implicitly coerce from U fib to U. Proof. Recall from Lemma 2.11 that the coercion map U i → U preserves unit type, dependent sums, and dependent products up to canonical isomorphism. We do the case of dependent products in detail. Note that we can internalise the inner dependent product as an operation Π i ∶ (Σ A ∶ U i . (A → U i )) → U i and that given A ∶ U i and B ∶ A → U i , we have a comparison isomorphism Π i (A, B) ≅ Π a∶A B(a). This shows that the (outer) dependent product of A ∶ U i and B ∶ A → U i is fibrant. Isomorphic families have isomorphic dependent product, generalising the statement to B ∶ A → U fib . Finally, reindexing a family along an isomorphism gives isomorphic dependent product, generalising the statement to A ∶ U fib .
Definition 3.6 (equivalence). A function f ∶ A → B between fibrant types with underlying inner types A ′ and B ′ is an equivalence if the corresponding inner function A ′ → i B ′ is an equivalence (in the sense of homotopy type theory and using the inner identity type).
Note that the notion of f being an equivalence in the above definition formally depends on the witnesses of fibrancy of A and B. Different witnesses yield nonisomorphic types of f being an equivalence. However, they will still be logically equivalent (in the sense of maps back and forth) and are in fact propositionally fibrant (meaning that their underlying inner type is a proposition in the sense of homotopy type theory). As per our convention, we can thus say that the notion of equivalence is invariant under isomorphism.
Properties of equivalences are directly lifted from the inner level. For example, equivalences satisfy 2-out-of-6.

Fibrations.
Recall that the fibre p −1 (x) of a function p ∶ Y → X over x ∶ X is given by the type Σ (y ∶ Y ) . p(e) = b. This is not to be confused with the notion of homotopy fibre, which is only available for inner types (using the inner identity type). More generally, we say that a type A is the fibre of p over x if A arises as a pullback of p along 1 → X, in which case it is isomorphic to p −1 (x).

Definition 3.7 ((trivial) fibration). A function p ∶ Y → X is a (trivial) fibration if its fibres are (trivially) fibrant.
In the running text and diagrams, a fibration Y → X is denoted Y ↠ X.
(i) Note that A → 1 is a (trivial) fibration exactly if A is (trivially) fibrant. This matches the terminology in abstract homotopy theory, where the notion of fibration is taken as primitive and fibrant objects are the special case of maps into the terminal object. Note also that every trivial fibration is a fibration. (ii) In the models of simplicial sets and cubical sets, our fibration coincide with the fibrations in the sense of the model. The reader should be aware that our internal pointwise definition of fibration, talking just about the fibres of a map, does not correspond to an external pointwise or fibrewise property. For example, a map Y → X in simplicial sets is not necessarily a Kan fibration if the fibre Y x of every point x ∈ X 0 is a Kan complex. Rather, the internal quantification over elements of the base type X externally becomes a quantification over [n] ∶ ∆ with x ∈ X n . The witness of fibrancy is given by a family of elements σ([n], x) ∈ U n , natural in [n], where U is the universe of Kan fibrations.
Since isomorphic maps have isomorphic fibres and the notion of (trivial) fibrancy is invariant under isomorphism, the notion of (trivial) fibration is invariant under isomorphism as well. From this, the following lemma is an immediate consequence of the definitions.
Lemma 3.9. The following are equivalent for a function p ∶ Y → X: (i) p is a fibration, and if X is fibrant with underlying inner type X ′ ∶ U i : (iv) p is isomorphic to the map Σ i X ′ Y ′ → X ′ corresponding to the inner dependent projection Σ i X ′ Y ′ → i X ′ for some Y ′ ∶ X ′ → U i . We have analogous equivalences for trivial fibrations with U i replaced by the type of inner contractible types and U fib replaced by the type of trivially fibrant types.
Fibrations and trivial fibrations enjoy a number of closure properties. We start with the following easy collection. Part (iii) is a consequence of (i) and (ii).
Lemma 3.11. Every trivial fibration has a section.
Proof. By Lemma 3.9, we can assume that the given trivial fibration is of the form Σ (b ∶ B) . X(b) → B for a type B and a family X ∶ B → U i of contractible fibrant types over B. We obtain a section Π b∶B X(b) by extracting the centre of contraction from the contractibility proof of X(b).
Lemma 3.12. Let p ∶ E → B be a map between fibrant types. Then p is a trivial fibration if and only if it is both a fibration and an equivalence.
Proof. Let p be a fibration. By invariance under isomorphism and Lemma 3.9, we can assume that p is of the form Σ (b ∶ B) . X(b) → B for an inner type B ∶ U i and a family X ∶ B → U i of inner types over B, with identity isomorphisms witnessing fibrancy of B and E. Then p is a trivial fibration exactly if X(b) is contractible for all b ∶ B. Note that dependent projection Σ (b ∶ B) . X(b) → B corresponds to the inner dependent projection Σ i (b ∶ B) . X(b) → i B under the isomorphisms relating inner and outer dependent sums and function types. Thus, p is an equivalence exactly if this inner dependent projection is an equivalence in the inner level, which from homotopy type theory we know to be equivalent to its fibres X(b) being contractible for all b ∶ B.

Cofibrations.
Cofibrations and cofibrant types are further technical concepts which help us to study the actual objects of interest, i.e. fibrant types. We will see their usefulness later in this article, but let us in addition try to give some motivation here. If B is a fibrant type, then so are B × B and B × B × B. More generally, if we work in HoTT and fix any natural number n in the meta-theory, we can consider the n-fold product of B. In our setting, this corresponds to the function type Fin n → B. It is important to note that, while (Fin 2 → B) is isomorphic to B × B, this and analogous isomorphisms do in general not hold if we use the inner version Fin i 2 instead; we will only get the weaker notion of an inner equivalence. While Fin n → B is fibrant, this is not directly given by the rules of 2LTT and instead requires a proof (see Lemma 3.25). This, we hope, makes it plausible that it is useful to have a notion of cofibrant types, which we want to be those that exponentiation with preserves fibrancy; and it is not too far-fetched that we also want an analogous notion for functions. In fact, one might expect that any setting which allows to reason about HoTT externally in such a way benefits from a notion of cofibration.
For example, it is worth comparing the characterisation in Remark 3.14(i) with the extension types by Riehl and Shulman [RS17].
To define and reason about cofibrations (as well as Reedy cofibrations later on), we make use of the theory of Leibniz constructions established in [RV14]. Given a bifunctor F ∶ C × D → E, the Leibniz actionF (f, g) of F on maps f ∶ A → B in C and g ∶ C → D in D is the induced map from the pushout corner in the square i.e. the map assuming that this pushout exists. If E has all pushouts, this gives rise to a bifunctor F ∶ C → × D → → E → , the Leibniz construction of F . In a category C with finite products, the Leibniz action of the product functor (−) × (−) ∶ C × C → C in a category C is called the pushout product. For C Cartesian closed, the Leibniz action of the exponential functor exp op ∶ C × C op → C op is called the pullback exponential. Note the dualised functor signature we have given exp here (as opposed to exp ∶ C op × C → C). This causes the pushout (in C op ) of the Leibniz construction to become a pullback in C, explaining the naming.
The category U of types is Cartesian closed and has pullbacks, thus we have the pullback exponential bifunctor exp We thank Mike Shulman for pointing out that we were missing the condition on trivial fibrations for cofibration in an earlier version of this definition.
(i) Unfolding the above definition, we obtain the following phrasing. A function f ∶ A → B is a cofibration exactly if for all fibrations p ∶ Y ↠ X and commuting squares the type of diagonal fillers (indicated by the dotted arrow) is fibrant, and trivially fibrant whenever p is a trivial fibration. (ii) Analogously to (i), f is a trivial cofibration exactly if, for all fibrations p as above, the type of diagonal fillers is trivially fibrant. Remark 3.15. The conditions for (trivial) cofibrations given by Definition 3.13 are reminiscent of the pushout product axiom of Cartesian closed model categories. In fact, they correspond exactly to the dual phrasing of this axiom in terms of pullback exponentials. This is the intuition behind our naming scheme.
In the simplicial set model, our notion of (trivial) cofibration (interpreted in the empty context) coincides with the (trivial) cofibrations of the Kan model structure. This can be seen as follows. The Kan model structure is Cartesian closed, hence a (trivial) cofibration of the model structure is a (trivial) cofibration in our sense.
Reversely, let f ∶ A → B be a cofibration in our sense. In particular, Leibniz exponential with f preserves trivial fibrations. Then f lifts against trivial fibrations by Lemma 3.11, i.e. is a cofibration of the model structure. A similar argument applies to trivial cofibrations, and our reasoning is not specific to simplicial sets but applies to any cartesian closed model structure.
One can ask for a local version of this correspondence. Given a simplicial set Γ, the above argument in the slice over Γ shows that the (trivial) cofibrations of the model structure over Γ include all of our (trivial) cofibrations in context Γ. However, the reverse inclusions fails as the slices of the Kan model structure are not Cartesian closed. For example, taking Γ = ∆ 1 , the map {0} → ∆ 1 (sitting over ∆ 1 via the identity) is an example of a trivial cofibration of the model structure that is not even a cofibration in context Γ in our sense. For if it were, pullback exponentials over ∆ 1 with {0} → ∆ 1 would preserve fibrations, which, by the adjunction between product and exponential, would imply that pushout product over ∆ 1 with {0} → ∆ 1 preserves trivial cofibrations. However, the pushout product over ∆ 1 of {0} → ∆ 1 and {1} → ∆ 1 is simply their union ∂∆ 1 → ∆ 1 , which is not a trivial cofibration.
Remark 3.16. Our notions of (trivial) cofibrations and (trivial) fibrations do not form weak factorisation systems. One may be tempted to consider the collection of maps with the left lifting property with respect to (trivial) fibrations. This notion does not capture the intuition described at the beginning of Subsection 3.4, and we instead call such maps anodyne (cf. Definition 4.11).
Within fibrant types, trivial cofibrations can be characterised as cofibrations that are equivalences. Proof. By part (iv) of Remark 3.14, we can assume that f is a cofibration and prove that it is a trivial cofibration if and only if it is an equivalence.
If f is a trivial cofibration, then, for all fibrant types X, the restriction map (B → X) → (A → X) is an equivalence. A Yoneda-like argument implies that f is an equivalence in this case. In detail, the characterisation (ii) of Remark 3.14 implies that the type of dotted diagonal fillers is trivially fibrant in each of the following two diagrams: As indicated, we call g the unique morphism B → A that makes the left triangle commute. In the right triangle, observe that f ○ g and id both make the triangle commute, and the desired result follows by uniqueness. Conversely, let p ∶ Y → X be a fibration. Then the corresponding pullbackexponential fibration is an equivalence by preservation of equivalences under exponentiation with a fixed base and 2-out-of-3, hence a trivial fibration by Lemma 3.12. Thus, f is a trivial cofibration.
The following key lemma helps us characterise cofibrations.
Lemma 3.18. For any function f ∶ A → B: (i) f is a cofibration exactly if for any family Y ′ ∶ B → U fib of (trivially) fibrant types, the induced map is a (trivial) fibration. (ii) f is a trivial cofibration exactly if for any family Y ′ ∶ B → U fib of fibrant types, the induced map is a trivial fibration.
Before giving its proof, let us recall the following characterisation of dependent functions in terms of non-dependent functions into a type of pairs where the first component is fixed.
Lemma 3.19. For a function f ∶ A → B and a family X ∶ B → U, the following diagram is a pullback: Proof. By direct calculation, the pullback is Σ (g ∶ A → Σ B X) . (π 1 ○ g = f ), which is indeed isomorphic to Π A (X ○ f ).
Proof of Lemma 3.18. Let p ∶ Y → X be a fibration. It is isomorphic to Σ X Y ′ → X for some family Y ′ ∶ X → U fib of fibrant types. Given v ∶ B → X, we have the following diagram: The right bottom square is a pullback by construction. The composite bottom square and the composite left square are pullbacks by Lemma 3.19. By pullback pasting, the top left square is a pullback.
Note that a map over a type Z is a (trivial) fibration exactly if all its pullbacks along maps 1 → Z are (trivial) fibrations. It follows that exp(f, p) is a (trivial) This shows the desired equivalences: going forward, we put X = B and v = id B ; going backward, we use the given condition for the family Y ′ ○ v for all v.
By setting A = 0 in Lemma 3.18, we obtain the following important special case.
Corollary 3.20. For any type B: (i) B is cofibrant exactly if for any family Y ′ ∶ B → U fib of (trivially) fibrant types, the type Π B Y ′ is (trivially) fibrant, (ii) B is trivially cofibrant exactly if for any family Y ′ ∶ B → U fib of fibrant types, the type Π B Y ′ is trivially fibrant.
In the following, we make use of standard properties of the Leibniz calculus (most of which are established at a general level in [RV14]). They allow us to infer closure properties of (trivial) cofibrations from corresponding closure properties of (trivial) fibrations established in Lemma 3.10. (i) pushouts (whenever they exist), (ii) finite compositions, (iii) finite coproducts.
Recall that U does not possess pushouts in general. Part (i) does not establish the existence of pushouts, but merely asserts that any pushout of a (trivial) cofibration is also one.
Proof of Lemma 3.21. For part (i), recall from [RV14] that the functorial action of the pullback exponential in its first argument sends morphisms of arrows that are pushouts to morphisms of arrows that are pullbacks. Thus, the claim follows from part (i) of Lemma 3.10.
In detail, consider a pushout Assuming that f is a cofibration, we wish to show that g is a cofibration (the case of trivial cofibrations is analogous). Let Y ↠ X be a (trivial) fibration. From the universal property of the pushout and pullback pasting, we get that the square is a pullback. Since f ∶ A → B is a cofibration, the right vertical map is a (trivial) fibration, hence so is the left vertical map by part (i) of Lemma 3.10. This makes g a cofibration. An alternative argument uses Lemma 3.18 and the dependent version of the universal property of pushouts. For part (ii), recall from [RV14] that the pullback exponential of a map p with a finite composition is a finite composition of pullbacks of pullback exponentials of p with the individual factors. Thus, the claim follows from parts (i) and (ii) of Lemma 3.10.
For an alternative proof, we can make use of the characterisation of (trivial) cofibrations given by Lemma 3.18. Let us only deal with the case of a binary composition of cofibrations. Given a family X ∶ C → U fib of (trivially) fibrant types, we have to show that Π C X → Π A (X ○g○f ) is a (trivial) fibration. This writes as the composite whose factors are (trivial) fibrations by assumption. The statements then follows from closure of fibrations under composition, i.e. part (ii) of Lemma 3.10. For part (iii), recall that the exponential bifunctor sends colimits in its exponent to limits. By [RV14], this property transfers to the pullback exponential bifunctor. In particular, for a fixed function p, the operation exp(−, p) sends coproducts (in U → ) to products. The claim then reduces to part (iii) of Lemma 3.10. Alternatively, it is a consequence of (i) and (ii) in the same fashion as for Lemma 3.10.
Corollary 3.22. For any type A and cofibrant type B, the inclusion A → A + B is a cofibration.
Proof. Since U has binary coproducts, it has pushouts along 0 → A. Instantiating part (i) of Lemma 3.21 to the pushout of the cofibration 0 → B along 0 → A, we obtain the claim.
Alternatively, we could instantiate part (iii) of Lemma 3.21 to the cofibrations id A (using the nullary case of part (ii) of Lemma 3.21) and 0 → B.
Note that the map 0 → 1 is the unit for the pushout product. Thus, the pullback exponential with 0 → 1 is equivalent to the identity functor. Thus, 1 is the simplest example a cofibrant type. This can be seen as the nullary version of the following statement.
Lemma 3.23. Any pushout product f×g (if it exists) of a cofibration f with a cofibration g is again a cofibration. Furthermore, f×g is a trivial cofibration if one of f and g is a trivial cofibration.
Proof. Recall that binary product and exponential form a two-variable adjunction. As explained in [RV14], this lifts to Leibniz constructions. In particular, given a function p, we have isomorphisms exp(f×g, p) ≅ exp(g, exp(f, p)) ≅ exp(f, exp(g, p)).
With this, the claim reduces to the definition of (trivial) cofibrations. We are now able to characterise a large class of cofibrant types. Part (ii) is an instance of part (iii) of Lemma 3.21. Part (iii) is a corollary of (ii) and cofibrancy of 1.
For part (iv), we work with the characterisation of cofibrancy given by Corollary 3.20. Let X ∶ (Σ A B) → U fib be a (trivially) fibrant family. We have to show that Π ΣAB X is (trivially) fibrant. This type is strictly isomorphic to Π a∶A Π b∶B(a) X(a, b) and (trivially) fibrant by two applications of Corollary 3.20.
For part (v), the nullary case is given by cofibrancy of 1. With this, the general situation reduces to the case of binary products. This is the non-dependent instance of (iv). Alternatively, it is the instance of Lemma 3.23 for maps 0 → A and 0 → B (whose pushout product is 0 → A × B).
We note that part (iv) of Lemma 3.25 has a relative generalization: given cofibrant A and a family f a ∶ C a → D a of cofibrations indexed over a ∶ A, the functorial action Σ A C → Σ A D of Σ A on f is a cofibration. This is proved using Lemma 3.19 instead of Lemma 3.18. In principle, one could generalize further to a "Leibniz dependent sum" of a cofibration A → B with a family of cofibrations indexed over B, but we have no need for that here.
The type of functors F ∶ (∆ <3 + ) op → U is defined in the usual way, and is isomorphic to the type of 9-tuples (X 0 , X 1 , X 2 , f s , f t , f u , f v , f w , e 0 , e 1 , e 2 ) where: While this type of 9-tuples is unfortunately not fibrant, we can identify a class of diagrams -the Reedy fibrant ones (Definition 4.6) -whose type will turn out to be fibrant, and such that every functor is equivalent a Reedy fibrant one for a suitably weak notion of equivalence. We will illustrate the idea using (∆ <3 + ) op . We will regard this category as a presentation of a dependency structure of types and type families. That is, instead of asking for source and target map from the type of edges to the type of vertices, we let the type of edges be indexed twice over the type of vertices, and similarly for triangles over edges. This leads to a type of triples (A 0 , A 1 , A 2 ) with the following components: The type of triples (A 0 , A 1 , A 2 ) encodes the so-called Reedy fibrant functors from (∆ <3 + ) op to U and can be formulated in homotopy type theory without the notion of strict equality, or in other words, it can be formulated in our inner theory without using equality from the outer theory.
Every triple (A 0 , A 1 , A 2 ) determines a functor, but, unfortunately, it is not the case that the latter type of triples is isomorphic (as a type) to the former type of tuples that used strict equality. Instead, we will show later that for every functor there exists a Reedy fibrant one that is equivalent to it in a weaker sense (Corollary 4.27) -its Reedy fibrant replacement.
Before this, we introduce the basic required categorical infrastructure within the language of 2LTT. This is a first demonstration of results which can be expressed in full in 2LTT although they would require meta-theoretic reasoning in more traditional approaches. We define the notion of Reedy fibration, and show that Reedy fibrant diagrams C → U have limits in U for a finite inverse category C. This is an internalised version of Shulman's results which can be found in [Shu15b]. In the second half of this section, we describe how to construct Reedy fibrant replacements, discuss classifiers for Reedy fibrations (a special case of which would be the type of semisimplicial types restricted to level n), and finally, we develop the theory of exponentials of diagrams. 4.2. Inverse categories. In the following, when considering categories of diagrams, we will mostly focus on diagrams over inverse categories. In contrast with the setup leading, for instance, to the Reedy model structure on simplicial presheaves over a Reedy category, in our setting it is necessary to impose the further restriction on the index category to be "one-way". We can either express this in terms of direct categories and contravariant functors, or inverse categories and covariant functors. We have arbitrarily picked the second representation. For readers familiar with Reedy categories, inverse categories are simply the special case of those obtained by requiring that there be no non-trivial positive arrows. For the sake of illustrating how to encode the details of the definition in two-level type theory, however, we choose to give an explicit definition.
Consider the category ω. Its objects are the natural numbers N and its morphisms are given by ω(n, m) ∶≡ m ≤ n, with ≤ ∶ N → N → Prop defined in the usual way. This category is in fact a poset. In general, Reedy categories can be defined in terms of arbitrary ordinals, but ω is enough for our purposes. This lets us evade the question of how to encode more general ordinals in the theory.
Definition 4.1 (inverse category). We say that a category C is inverse if there is a functor ϕ ∶ C op → ω reflecting identities; i.e. given f ∶ x → y with ϕ(x) = ϕ(y), then f is an identity, i.e. (x, y, f ) = (x, x, id x ) as elements of the type of arrows of C. We call ϕ the rank functor, and say x ∶ C has rank ϕ(x). We write C <n for the full subcategory of C consisting of objects of rank less than n.
Given category C and a functor F ∶ C → U, the category of elements F , denoted F C in analogy with the notation for coslices, is defined as usual via the Grothendieck construction. In particular, objects are pairs (a, x) where a ∶ C and x ∶ F (a) and morphisms from (a, x) to (b, y) are maps f ∶ a → b such that F f (x) = y. We have a forgetful functor F C → C that is discrete Grothendieck opfibration. This is a cosieve exactly if F is valued in propositions.
Let C now be an inverse category. Then the forgetful functor F C → C induces a rank functor also on F C. This makes F C into an inverse category.
Given a category C, recall that the coslice x C over an object x ∶ C has as objects pairs (y, f ) of y ∶ C and a map f ∶ x → y. Morphisms between (y, f ) and (y ′ , f ′ ) are given maps h ∶ y → y ′ with h ○ f = f ′ in C. The evident forgetful functor x C is a discrete Grothendieck opfibration.
The formulation of Reedy fibrancy for diagrams over inverse categories makes use of the notion of matching object. The following definition can be used (see Definition 4.4) to give a formulation of matching objects in terms of limits.
Definition 4.2 (reduced coslice). Given a category C and an object x ∶ C, the reduced coslice x C is the full subcategory of the coslice x C on objects (y, f ) that are not equal to (x, id x ), i.e. come with a proof p ∶ (y, f ) ≠ (x, id x ) in the type of objects of x C (equivalently, (x, y, f ) ≠ (x, x, id x ) in the type of morphisms of C). We write such an object as a triple (y, f, p).
By definition, we have a fully faithful forgetful functor x C → x C. Composing it with the forgetful functor to C, we obtain forget ∶ x C → C, sending an object (y, f, p) to y.
Definition 4.2 may seem slightly unnatural from a category-theory point of view. There is, however, a different perspective that can perhaps help to shed some light on the above definition, motivated by thinking of inverse categories as generalisations of ∆ op + . For a given inverse C with an object x ∶ C, we have the representable diagram C[x] defined by C[x] y ∶≡ C(y, x) (with evident functorial action). Note that the coslice x C is the category of elements of C[x]. Now, the representable diagram C[x] has a maximal non-trivial subfunctor consisting of all the elements of C[x] except the identity arrow id x ∶ x → x. We detail its construction below.
Recall that subfunctors of representable functors correspond to cosieves, i.e. families of propositions: such that, for maps f ∶ x → y and g ∶ y → z, we have The functor Φ ∶ C → U corresponding to such a cosieve ϕ is then given by  4.3. Reedy fibrations. Part (i) of Lemma 3.10 makes it possible to construct fibrant limits of certain "well-behaved" functors from inverse categories. We follow Shulman [Shu15b], but our setup allows a slightly more general development. We will give a short analysis after the proof of Theorem 4.8. In the following, we always assume that C is an inverse category.
Definition 4.4 (matching object; see [Shu15b, Chapter. 11]). Let X ∶ C → U be a functor. For any z ∶ C, we define the matching object M X z to be the limit of the composition z C forget → C X → U.
Using the universal property of the limit defining the matching object, we obtain a map X z → M X z . Abstracting over X, this gives a natural transformation (−) z → M z between functors from [C, U] to U.
Alternatively, we can formulate matching objects in terms of abstract boundaries: Lemma 4.5. Given a diagram X over C, and an object z ∶ C, the matching object M X z is isomorphic to Nat(∂C[z], X), naturally in X. Under this and the Yoneda isomorphism X z ≅ Nat(C[z], X), the map X z → M X z corresponds to Nat(i z , X). Proof. This is straightforward to verify directly. Alternatively, one can observe that weighted limits of X with weight W can be implemented by taking the limit over the restriction of X to category of elements of W , and this is natural in W .
Definition 4.6 (Reedy (trivial) fibration; see [Shu15b,Def. 11.3]). Let X, Y ∶C → U be two diagrams. Further, let p ∶ Y → X be a natural transformation. We say that p is a Reedy (trivial) fibration if, for all z ∶ C, the canonical map induced by the universal property of the pullback, is a (trivial) fibration.
A diagram X is said to be Reedy (trivially) fibrant if the canonical map X → 1 is a Reedy (trivial) fibration, where here 1 denotes the diagram that is constantly the unit type.
In terms of the natural transformation (−) z → M z , we can express that p is a Reedy fibration by saying that the pullback application of (−) z → M z to p is a fibration for all z ∶ C. Here, we have applied the Leibniz calculus to the bifunctor We can use abstract boundaries to improve on this. The pullback hom Nat in the category of diagrams on C is the Leibniz construction of the natural transformation bifunctor Nat. Concretely, given natural transformations f ∶ A → B and p ∶ Y → X between diagram on C, their pullback hom is the induced map With this, we can give an alternative characterisation of Definition 4.6 that is occasionally useful. Proof. Immediate consequence of Lemma 4.5.
Using Definition 4.6, we can make precise the claim that we can construct fibrant limits of certain well-behaved diagrams.
Theorem 4.8 (see [Shu15b,Lemma 11.8]). Assume that C is an inverse category with a finite type of objects C and that X ∶ C → U is a Reedy (trivially) fibrant diagram. Then, X has a (trivially) fibrant limit.
Proof. By induction on the cardinality of C . In the case C ≅ Fin 0 , the limit is the unit type.
Otherwise, we have C ≅ Fin n+1 . Let us consider the rank functor Choose an object z ∶ C such that ϕ(z) is maximal; this is possible (constructively) due to the finiteness of C . Let us call C ′ the category that we get if we remove z from C; that is, we set C ′ ∶≡ Σ (x ∶ C ) . x ≠ z. Clearly, C ′ is still inverse, and we have C ′ ≅ Fin n . Denote by 1 the terminal diagram on C, and by 1 ′ the left Kan extension of the terminal diagram on C ′ to C. So 1 ′ has value 1 on all objects except z, where it has value 0. Similarly, let X ′ be the restriction of X on C ′ .
The following square of diagrams on C is a pushout, as one can easily check levelwise, using the fact that equality on objects in C is decidable, since C is finite. By applying the bifunctor Nat with X on the right, we get that the square is a pullback. The right vertical map is a fibration by Reedy fibrancy of X, hence the left vertical map is a fibration by part (i) of Lemma 3.10. Now lim X ′ is fibrant by induction hypothesis, hence lim X is fibrant.
In Shulman's work [Shu15b], the notion of an outer type does not exist, and every type that occurs is inner. This means that every diagram is valued in inner types, and consequently, matching objects do not necessarily exist, so the definition of a Reedy fibration has to include the condition that all the matching objects involved are available.
If we wanted to precisely reproduce Shulman's definition of a Reedy fibration, we would have to modify Definition 4.6: first, that all occurring diagrams are valued in fibrant types; and second, that all occurring matching objects, obtained by coercing to outer types then taking a limit, happen to be fibrant.
In our setting, it is more natural to work with outer types from the beginning. We recover Shulman's notion in the special case where the outer types that occur are coercions of inner types. Although diagrams of fibrant types (C → U i ) are what we are ultimately interested in, we can at no cost enlarge the class of diagrams that we talk about to those that are built out of outer types, possibly not even isomorphic to inner ones. The ability to make this choice is an important feature of two-level type theory as a meta-theoretic reasoning framework, and it can help to obtain some slightly more general results compared to a traditional approach.
Similarly to the notation C <n (see Definition 4.1), we will denote by X n the restriction of a diagram X ∶ C → U to C <n .
The following lemma generalises Lemma 3.10 to Reedy fibrations. Proof. As before, part (iii) is a consequence of (i) and (ii). For part (i), we first give an abstract argument. Recall from [RV14] that the functorial action of the pullback hom in its second argument preserves morphisms between arrows that are pullbacks. It follows that Nat(i z , p * f ) is a pullback of Nat(i z , f ) for any z ∶ C. This reduces the claim to part (i) to Lemma 3.10.
For the benefit of the reader, we also include a more direct proof, which is obtained by unfolding the abstract argument. Suppose we have a pullback square: where p is a Reedy fibration. We want to show that q is a Reedy fibration. Now fix an object n ∶ C , and consider the cube: ; ; The front and back faces are pullbacks by construction, and the right face is a pullback because it is the limit of a pullback square. By a pullback pasting argument, the square determined by the front left and the back right vertical arrow is a pullback. By a second pullback pasting argument, the left face is a pullback. Now consider the diagram: We have proved that the lower square is a pullback, and the outermost square is a pullback because limits in categories of diagrams are pointwise. It follows that the upper square is a pullback for all n ∶ C, which shows that the map Y → A is a Reedy fibration.  The goal of the current section is to show that any functor X from an admissible inverse category C to U fib has a Reedy fibrant replacement; that is, we can construct a Reedy fibrant diagram which is equivalent to X in a suitable sense. More generally, given any map of pointwise fibrant diagrams, we can always factor it into a (pointwise) equivalence followed by a fibration.
We emphasise that we are talking about diagrams that are valued in fibrant types. An obvious reason why this is necessary is that the only notion of equivalence for general diagrams that we could use would be (strict) isomorphism, which clearly would be too strong. But even if we came up with a weak notion of equivalence of general diagrams, we could not expect it to be possible to start with any diagram C → U and derive a Reedy fibrant one from it which is in some sense equivalent. Already in the special case that C is the discrete category with exactly one object, this would correspond to finding a fibrant replacement of an outer type. By Theorem 2.20 such a fibrant replacement cannot be defined internally.
Our construction is an internalisation of the known analogous construction in traditional mathematics (see e.g. [Shu15b,Lemma 11.10] or [RV14]).
Definition 4.11. We say that a map i ∶ A → B is anodyne if it has the left lifting property with respect to fibrations. More precisely, for all fibrations p ∶ Y → X, the pullback exponential (B → Y ) → (B → X) × A→X (A → Y ) has a section.
The following characterisations of anodyne maps are straightforward to establish.
Lemma 4.12. A function i ∶ A → B is anodyne if and only if for all families X ∶ B → U fib of fibrant types over B, and all terms t ∶ Π a∶A X(i(a)), we can find a term t ′ ∶ Π b∶B X(b) such that t ′ (i(a)) = t(a) for all a ∶ A.
Lemma 4.13. Assume we are given a commutative triangle where the map i is fibrewise anodyne, i.e. for all x ∶ X, the induced map p −1 (x) → q −1 (x) between the fibres is anodyne. Then, i is anodyne.
Since anodyne maps are defined by a left lifting property, they exhibit familiar closure properties, of which we recall the following: Lemma 4.14. Anodyne maps are closed under retracts.
When focusing on fibrant types, we can say more about anodyne maps.
Lemma 4.15. If i ∶ A → B is an anodyne map between fibrant types, then i is an equivalence.
Proof. Since A is fibrant, we get a map r ∶ B → A such that r ○ i = id, in particular r ○ i = i id. To show that i ○ r = i id, it is enough, by Lemma 4.12, to show that i ○ r ○ i = i i, which follows from the first part.
Trivial cofibrations are in particular anodyne maps, as the following lemma shows.
Lemma 4.16. If i ∶ A → B is a trivial cofibration, then it is anodyne.
Proof. For any fibration p, the pullback exponential exp(i, p) is a trivial fibration, so it has a section by Lemma 3.11.
The following lemma provides an important example of anodyne map which is not necessarily a trivial cofibration.
Lemma 4.17. Let A be a fibrant type, and a 0 ∶ A a term. Then the map i ∶ 1 → Σ (a ∶ A) . a = i a 0 which selects the pair (a 0 , refl a0 ) is anodyne.
Proof. Immediate consequence of the elimination rule for the fibrant identity type and its computation rule. We will refer to the type N constructed in the proof of Corollary 4.18 as the mapping cocylinder of f . Definition 4.19. Let C be an inverse category. We say that C is admissible if, for all a ∶ C, Reedy (trivially) fibrant diagrams over the reduced coslice a C have a (trivially) fibrant limit.
Let C be an inverse category with a functor F ∶ C → U. Since the category of elements F C → C is a discrete Grothendieck opfibration, the induced functor (a, x) F C → a C is an isomorphism for any (a, x) ∶ F C, and similarly for the (non-reduced) coslices. It follows that admissibility of C implies admissibility of F C.
Lemma 4.20. Let C an admissible inverse category, and let X ∶ C → U be a Reedy fibrant diagram. Then X is pointwise fibrant, and all the matching objects of X are fibrant.
Proof. First observe that if X is a Reedy fibrant diagram on C, and z ∶ C is any object, then j * X is a Reedy fibrant diagram on z C, where j ∶ z C → C is the forgetful functor. This follows from the above observation that j induces an isomorphism between (reduced) coslices of z C and (reduced) coslices of C.
Therefore, if C is admissible, the matching object M X z of X is fibrant for all z ∶ C. Since furthermore the map X z → M X z is a fibration by the assumption that X is Reedy fibrant, we get that X z is fibrant as well.
The main example of an admissible inverse category is ∆ op + , the opposite of the simplex category restricted to strictly monotone maps. We can define it concretely as follows: That ∆ op + is admissible follows from Theorem 4.8 and the fact that all the reduced coslices of ∆ op + are finite. The notion of anodyne can be extended to diagrams in a pointwise fashion.
Definition 4.22. Let C be a category, and X, Y be diagrams on C. A natural transformation f ∶ X → Y is said to be anodyne if it is so pointwise, i.e. for all n ∶ C, the function f n ∶ X n → Y n is anodyne.
Similarly, we have a notion of equivalence of diagrams, defined pointwise.
Definition 4.23. For a category C, let X, Y ∶ C → U be pointwise fibrant diagrams.
A natural transformation f ∶ X → Y is said to be an equivalence if, for all n ∶ C, the function f n ∶ X n → Y n is a ("homotopy") equivalence.
Lemma 4.24. An anodyne natural transformation between pointwise fibrant diagrams is an equivalence.
Proof. Immediate consequence of Lemma 4.15.
Lemma 4.25. Let p ∶ X → Y be a (trivial) Reedy fibration of diagrams over an inverse category C. Suppose that Reedy (trivially) fibrant diagrams over C have (trivially) fibrant limits. Then the limit lim p ∶ lim X → lim Y is a (trivial) fibration.
Proof. We only do the case of fibrations.
Let y ∶ lim Y be an arbitrary element of the limit. We can think of y as a natural transformation y ∶ 1 → Y . Consider the following pullback of diagrams: By part (i) of Lemma 4.9, X[y] is a Reedy fibrant diagram, hence its limit is fibrant by the assumption on C. Since limits commute with pullbacks, we get a pullback diagram: lim showing that the fibre of lim p over y is fibrant.
Lemma 4.26. Let f ∶ X → Z be a natural transformation of pointwise fibrant diagrams over an admissible inverse category C. Then f can be factored as: where i is anodyne, and p is a Reedy fibration.
Proof. We will construct, by induction on the natural number n, a diagram Y (n) over C <n , and a factorisation of f : where i (n) is anodyne and p (n) is a Reedy fibration. For n = 0 there is nothing to construct, so assume the existence of Y (n) , and fix any object x ∶ C of rank n + 1. The forgetful functor j x ∶ x C → C factors through C <n , hence we can consider the composition Y (n) ○j x and take its limit L. Note that L is not necessarily fibrant, but the map L → M Z x induced by p (n) is a fibration by Lemma 4.25 and the admissibility of C. By part (i) of Lemma 3.10, we get a to be the mapping cocylinder of this map. For any object y of rank n or less, define Y (n+1) y as Y (n) y , and for any morphism f ∶ x → y in C, the corresponding function Y is given by the projection from the mapping cocylinder, followed by a map of the universal cone of the limit L. The action of Y (n) on morphisms between objects of ranks n or less is defined to be the same as that of Y (n) .
It is easy to see that those definitions make Y (n+1) into a diagram that extends Y (n) to objects of rank n + 1. We can also extend i (n) by defining i (n+1) x to be the embedding of X x into the mapping cocylinder Y (n+1) x , which is anodyne by Corollary 4.18.
Similarly, we define p (n+1) x to be the composition of the projection from the mapping cocylinder with the map L × M Z x Z x → Z x defined above. The fact that p (n+1) is a Reedy fibration follows immediately from the construction, since L is exactly the matching object of Y (n+1) at x.
To conclude the proof, we glue together all the Y (n) , i (n) and p (n) into a single diagram Y and natural transformations i, p. Clearly, p is a Reedy fibration, and i is an equivalence.  Proof. First suppose that i ∶ A → B is anodyne, and let p ∶ Y → X be any fibration. Consider a commutative square For all natural numbers n, we will construct a lift w for the square of the restrictions of all the diagrams involved to C <n . The base of the induction is trivial, so suppose we have constructed such a lift for n, and let x ∈ C be an object of degree n + 1. Consider the square: where the bottom map is obtained from the inductively constructed lift w, together with the bottom natural transformation v of the original square. The right map is a fibration by the assumption that p is a Reedy fibration, which lets us construct a diagonal lift w x for the square. This gives an extension of the lift w to all objects x of degree n, and naturality of w follows immediately from the commutativity of the bottom right triangle. Note that we have not used the assumption that A and B are pointwise fibrant for this direction.
Conversely, suppose that i ∶ A → B has the stated lifting property. Since A and B are pointwise fibrant, we can factor i as A j → N p → B, where j is anodyne and p is a Reedy fibration, thanks to Lemma 4.26. At this point, a standard retract argument shows that i must be anodyne. More explicitly, first consider the square and use the lifting property of i to get a natural transformation r ∶ B → M . It then follows that i is a retract of j, so in particular i x is a retract of j x for all objects x ∶ C. The conclusion now follows from Lemma 4.14.
4.5. Classifiers for Reedy fibrations. Let C be an admissible category. The goal of this section is to construct a type that classifies, in the appropriate sense, Reedy fibrant diagrams over C. In certain cases, this type will itself be fibrant, giving a construction of a classifier for diagrams which is completely internal to the inner level.
The construction of this classifier makes use of a stricter notion of fibration than the one we have used so far.
Definition 4.29. Let X be a type. A strict fibration on X is simply a family of inner types indexed over X.
Any strict fibration A over X determines a map Y → X, where Y ∶≡ Σ X A. We will sometimes abuse language and refer to a map p ∶ Y → X itself as a strict fibration, with the convention that strict fibrations are always assumed to be equipped with a corresponding choice of a family A, which we will refer to as a strict fibration structure on p. Fibrations can then be characterised as those maps Y → X that are isomorphic over X to some strict fibration. In particular, strict fibrations are fibrations.
To show that this is a morphism of strict Reedy fibrations, observe that in the induced diagram is Cartesian, and therefore in the diagram are Cartesian. It is then easy to verify that our choice of strict Reedy fibration structure on the extension of Y to objects of rank n makes the colimit injections X i → Y into morphisms of strict Reedy fibrations.
As for uniqueness, let Y ′ → B be a strict Reedy fibration, together with morphisms forming a cocone for the diagram X. Universality of colimits, applied to the identity map colim i A i → B, yields that Y ′ → B is a colimit of the X i → A i , and therefore Y and Y ′ are isomorphic over B. From the fact that the colimit injections into Y ′ are morphisms of strict Reedy fibrations, and the choice of strict Reedy fibration structure on Y , it then follows easily that the isomorphism Y ≅ Y ′ can be chosen to be a morphism of strict Reedy fibrations over the identity of B. Since strict Reedy fibrations form a discrete Grothendieck fibration over [C, U] by Lemma 4.33, we get that Y = Y ′ on the nose, as required. The next step is defining a universe of strictly Reedy fibrant types in the category of diagrams on C. We use the basic idea for the construction of a universe in presheaves [HS97], but we specialise it to strict Reedy fibrations rather than arbitrary natural transformations.
Definition 4.35. Let V be the diagram on C defined by: with the obvious action on morphisms. 4.6. Exponents of diagrams. In this section, we want to address Reedy fibrancy of exponentials, and fibrancy of types of natural transformations. As before, we fix an inverse category C, and work with diagrams on C. We begin by defining a notion of Reedy (trivial) cofibrations, analogous to that of Definition 3.13.  Proof. Pushouts are constructed levelwise. For t ∶ C, we have to construct a pushout If z and t have different degrees, then ∂C[z] t → C[z] t is an isomorphism, and we take P t ∶≡ C[z] t × B t . If z and t have the same degree, then ∂C[z] t is empty. In that case, the top map is an isomorphism, and we take P t ∶≡ C[z] t × A t .
We say that a natural transformation f ∶A → B is a pointwise (trivial) cofibration, if for all objects z ∶ C, we have that f z ∶ A z → B z is a (trivial) cofibration. The following theorem implies that, under a mild assumption on the index category C, pointwise cofibrations are in particular Reedy cofibrations.
Theorem 4.42. Let f ∶ A → B be a pointwise cofibration of diagrams over C. Then f is a Reedy cofibration, i.e. given a Reedy (trivial) fibration p, the pullback exponential of p with f is a Reedy (trivial) fibration.
Proof. Let z ∶ C be any object. The forgetful functor F ∶ z C → C is a discrete Grothendieck fibration. The induced restriction functor F * ∶ [C, U] → [z C, U] has a left adjoint, left Kan extension along F , sending a diagram X over z C to the diagram F ! X over C defined by (F ! X) t ∶≡ Σ (f ∶ C(z, t)) . X (t,f ) . We have naturally in X ∶ [z C, U] and Y ∶ [C, U]. Abstractly, this is a consequence of F * preserving exponentiation. Explicitly, it unfolds at level t to the natural isomorphism Since F ! preserves colimits, the isomorphism (4.4) lifts to an isomorphism naturally in u a map in [z C, U] and v a map in [C, U] whenever the involved pushout products exist.
Let now p ∶ Y → X be a Reedy fibration. We will argue that exp(f, p) is again a Reedy fibration. The case of Reedy trivial fibrations is analogous. Using Lemma 4.7, we have to show that Nat(i z , exp(f, p)) is a fibration. Recall from the proof of Lemma 4.10 that under F ! . We calculate using (4.5) in the second step. We denote T the functor 1 → z C selecting the initial object (z, id z ). Restriction T * ∶ [z C, U] → U has left adjoint T ! the constant functor. Note that the unit Id → T * T ! of the adjunction T ! ⊣ T * is invertible, i.e. the T ! is a coreflective embedding. Its counit induces a map of arrows. We claim that it is cocartesian, i.e. forms a pushout square. This we check at each level (t, f ) of z C. If t has degree less than z, then (i (z,idz) ) (t,f ) is an isomorphism. Isomorphisms are absorbing for the pushout product, so both source and target of (4.6) at stage (t, f ) are isomorphisms, making the square a pushout. Otherwise, we have (t, f ) = (z, id z ). Evaluation at (z, id z ) is given by T * , and T ! T * F * f → F * f becomes invertible upon application of T * . Thus, the map (4.6) at stage (t, f ) is an isomorphism, in particular cocartesian. The functorial action of the pullback hom in its first argument takes cocartesian maps in its first argument to cartesian maps, i.e. sends pushout squares to pullback squares. Thus, the map Nat(i (z,idz)× F * f, F * p) is a pullback of Nat(i (z,idz)× T ! T * F * f, F * p). Using part (i) of Lemma 3.10, it thus suffices to show that this map is a fibration. We calculate ≅ exp(f z , Nat(i (z,idz) , F * p)) ≅ exp(f z , Nat(i z , p)) using exponential transposition, the adjunction T ! ⊣ T * , the adjunction F ! ⊣ F * .
By assumption, f z is a cofibration. It thus remains to show that Nat(i z , p) is a fibration. This holds by Lemma 4.7. of p with f is a fibration.
Proof. By the assumption on f , the pullback exponential exp(f, p) is a Reedy fibration. Normally, Segal spaces are employed to reason about higher categorical structures such as (∞, 1)-categories in a homotopy-invariant fashion. In other words, Segal spaces are a model of (∞, 1)-categories that can be constructed purely in terms of existing models of spaces (∞-groupoids) and their homotopy theory.
By contrast, a model such as the one based on quasicategories [BV73, Joy02] works by encoding higher categories in terms of their simplicial nerves. The difference is that the homotopy-theoretic features of complete Segal spaces are inherited from the environment in which they are defined (i.e. spaces), whereas for quasicategories, they have to be imposed by an ad hoc construction (the Joyal model structure on simplicial sets).
In the setting of type theory, only the first kind of approach is possible, if we are aiming for a formulation of higher category theory that can talk about higher categorical structures within the theory. In this subsection, we will see how to import the ideas of the framework of complete Segal spaces into two-level type theory.
Complete Segal spaces [Rez01] are first of all simplicial objects. Unfortunately, the fact that our development of Reedy fibrancy is restricted to inverse categories, rather than more general Reedy categories, implies that we have to limit ourselves to the semisimplicial case.
It has been shown by Harpaz [Har15], that semisimplicial spaces satisfying a Segal condition and a version of the completeness condition form a model of (∞, 1)categories, by constructing a Quillen equivalence between the appropriate Bousfield localisations of marked semisimplicial spaces and simplicial spaces.
Inspired by Harpaz's construction, we give the following definitions in two-level type theory: Definition 4.45. Let τ ∶ F → G be a Reedy cofibration between semisimplicial types (i.e. diagrams over the semisimplicial category ∆ op + ), and X a Reedy fibrant semisimplicial type. Assume that G is bounded, in the sense that it is the left Kan extension of a diagram over (∆ op + ) <n for some n. We say that X is local with respect to τ if the induced map Nat(G, X) → Nat(F, X) (4.7) is a trivial fibration.
Note that the assumptions on τ and G imply that the map (4.7) is already a fibration.
Definition 4.46. A semi-Segal type is a Reedy fibrant semisimplicial type X that is local with respect to all inner horn inclusions Λ k [n] → ∆[n], with 0 < k < n.
Equivalently (and perhaps more elegantly), we can define the semi-Segal condition as locality with respect to the pushout corner map in the image under Yoneda  for all a, b ≥ 0, that is: Here, we can equivalently restrict to a = 1. However, semi-Segal types do not constitute the correct notion of (∞, 1)-category that we are after, for essentially two reasons. Firstly, they are not complete, meaning that their type of vertices X 0 carries extra (non-categorical) information, i.e., they are not univalent; and secondly, they do not necessarily have identity arrows. They model (∞, 1)-pre-semicategories.
It turns out, however, that one can define a notion of equivalence in a semi-Segal type, and using equivalences one can solve both problems at the same time.
For a semi-Segal type X, let X(x, y) be the type of edges that have vertices x, y ∶ X 0 as endpoints. This is fibrant by the Reedy fibrancy condition. Thanks to locality with respect to the horn inclusion Λ 1 [2] → ∆[2], we get a composition map: − ○ − ∶ X(y, z) × X(x, y) → X(x, z).
Definition 4.47. Let X be a semi-Segal type. An equivalence in X is an edge f ∶ X(x, y) such that for all vertices z, the functions f ○ − ∶ X(z, x) → X(z, y) and − ○ f ∶ X(y, z) → X(x, z) are equivalences (of fibrant types).
Since being an equivalence is a fibrant proposition, we get that equivalences in a semisimplicial type X form a fibrant type E, which we can think of as a subtype of X 1 . We are now ready for the main definition.
Definition 4.48. A univalent (∞, 1)-category is a semi-Segal type such that the source map E → X 0 is an equivalence.
By source map in Definition 4.48 we mean the function mapping every equivalence f ∶ X(x, y) to the source vertex x. The condition of Definition 4.48 is sometimes referred to as the completeness condition. One way to think of it is as a formulation of univalence internal to X. Since Definition 4.48 gives the only notion of (∞, 1)-category that we consider here, we drop the attribute univalent for simplicity.
Note that Definitions 4.46 to 4.48 are all invariant under (levelwise) equivalence of Reedy fibrant semisimplicial types.
Two of the current authors have checked in detail that this definition is wellbehaved, and equivalent to the manual definition that one might expect, for the truncated special cases of univalent ordinary categories and (2,1)-categories [CK17]. It is out of the scope of this paper to develop the theory of (∞, 1)-category in twolevel type theory. Therefore, we limit ourselves to sketching some basic examples of (∞, 1)-categories, to give a taste of how our definition can be employed in practice.
For a given category C, let N + (C) be the semisimplicial nerve of C, i.e. the semisimplicial type whose n-simplices are given by functors [n] → C, where [n] denotes the ordinal with n + 1 elements, regarded as a category. Observe that the square (4.8) is a pushout in categories. It follows that N + (C) sends it to a pullback (4.10) This is a strict version of the semi-Segal condition. We shall see below that under sufficient fibrancy conditions, it also forms a homotopy pullback, hence makes the Reedy fibrant replacement of N + (C) a semi-Segal type. . This is a fibration by assumption: its fiber over x ∶ C is isomorphic to C x . The claim follows since fibrations are closed under pullback.
Corollary 4.50. Let C be a category such that C and all its slices have fibrant types of objects. Then N + (C) ∶ ∆ op + → U is valued in fibrant types. From a pointwise fibrant semisimplicial type, we obtain a Reedy fibrant semisimplicial type (levelwise) equivalent to it using Lemma 4.26.
Lemma 4.51. Let C be a category such that C and all its slices have fibrant types of objects. Let j ∶ N + (C) → X be a Reedy fibrant replacement. Then X is a semi-Segal type.
By Yoneda, the left map is equivalently the pullback corner map in (4.10), hence is invertible. The top left object is fibrant by Corollary 4.50, hence so is the bottom left object. Note that j evaluates to an equivalence at all of Thus, the top map is an equivalence. The bottom map is the induced map between the pullbacks of two cospans of fibrant objects with one leg a fibration (by Lemma 4.49). The induced morphism between these cospans is (levelwise) an equivalence. By an argument analogous to the gluing lemma for fibration categories [RB06, Lemma 1.4.1, part (2)], the induced map between the two pullbacks is also an equivalence. Finally, since all other maps in the square are equivalences, so is Nat(c a,b , X).
Let C be a category with fibrant types of objects and morphisms (between any two given objects). As a consequence of Lemma 4.51, any Reedy fibrant replacement X of N + (C) is a semi-Segal type. We may start the construction of such a Reedy fibrant replacement with X 0 ∶≡ C and X 1 (x, y) ∶≡ C(x, y). It is then easy to check that the composition map for X defined before Definition 4.47 agrees with the composition of C. In particular, an edge in X is an equivalence exactly if the corresponding morphism in C is a homotopy equivalence (invertible up to inner equality). It follows that X is univalent exactly if C is wildly univalent, that is, the canonical map from C to the type of equivalences of C is an equivalence.
As an important special case of this construction, we can take for C the category of fibrant types. The resulting (∞, 1)-category TYPE (large, but locally small) can be regarded as a classifier for families of types over (∞, 1)-categories.
One way to construct a universal fibration TYPE • over TYPE is as follows. Let U • denote the category of fibrant types with an element (note that morphisms preserve the element strictly). We have a forgetful functor U • → U that is Reedy fibrant on underlying graphs. Taking a relative Reedy fibrant replacement, we obtain the following square: By a relative version of Lemma 4.51 for homotopy left fibrations, the fibration TYPE • ↠ TYPE is a left fibration. One may go on to show that it is a classifier for left fibrations with small fibers. This gives one way to adapt the Grothendieck construction for presheaves of (∞, 1)-categories to our settings. (An alternative is to directly define the universe of left fibrations and check the semi-Segal condition and univalence).

Conclusions
We believe that two-level type theory is a suitable framework for expressing and proving results which, in conventional homotopy type theory, require externally fixed data that one wishes to keep as variable as possible. We have demonstrated that this approach can be used effectively to express Shulman's results on diagrams over inverse categories [Shu15b]. Starting from there, we have suggested the very beginning of an internal development of a theory of (∞, 1)-categories. We expect that such a theory is helpful for other constructions which make use of the fact that types and universes are, naturally, higher categories; a short discussion is available in [Kra18].
Examples for existing results which can be expressed in and benefit from our framework of higher categories can be found in our previous work [Kra15b,Kra15a,KS17]. These results use semisimplicial types to express large or even infinite towers of coherences, and it is unknown how to express such towers in standard settings of homotopy type theory. If we do these constructions in our suggested setting, it is important which precise version of two-level type theory we use. If we only use "basic" two-level type theory without any of the strengthenings discussed in Subsection 2.4, then the conservativity result means that we immediately get the corresponding result in homotopy type theory. For the results cited above, this is the case if the size of required coherence towers is bounded, with a bound given as an outer natural number; then, the construction works in homotopy type theory, with the bound fixed externally. An example for this situation is [Kra15b, Theorem 8.9.6]. Other results however need one or more of the strengthenings of Subsection 2.4, and for those, it is in general unknown whether they can be expressed in usual settings of homotopy type theory. In case of the mentioned work, an assumption made for some results is that limits of Reedy-fibrant towers are fibrant (A2), but we expect that this assumption can alternatively be substituted by the axiom (A3) that the outer natural numbers are cofibrant or even fibrant (A1). To give an example, [Kra15b,Theorem 8.8.5] depends on such an assumption. Possible future directions include developing a richer theory of (∞, 1)-categories that includes standard concepts such as limits and colimits, and potentially based on that, a treatment of the internal semantics of higher inductive types as for example specified by [KK19b].
As a proof of concept, we have implemented some parts of our paper (with the main result being Theorem 4.8) in the proof assistant Lean. 10 Since Lean does not support two-level type theory directly, we have used type classes to keep track of and automatically propagate fibrancy constraints. An overall idea of the implementation is suitable for most existing proof assistants: we work in a type theory with universes of outer types (i.e. where uip holds), outer types correspond to the ordinary types of the proof assistant, while fibrant types are represented as types "tagged" with the extra structure of being fibrant. The role of the outer equality is played by the ordinary propositional equality of the proof assistant (which, thanks to UIP, is indeed propositional in the sense of HoTT). We postulate the fibrant equality type, its elimination rule J and fibrancy preservation rules for Π and Σ resulting from the rules in Subsection 2.1. The usual computation (or β-) rule for J is defined using outer equality -the propositional equality of the proof assistant -and not judgemental equality. This means that this computation does a priori not happen automatically, and explicit rewrites along the propositional β-rules are needed in proof implementations when working in the inner level. In our development, besides the general two-level framework, we have implemented machinery required to define Reedy fibrant diagrams and have fully formalised a proof of Theorem 4.8. We did not find the lack of a definitional β-rule for J in the inner fragment to affect the internalisation of results on the theory of Reedy fibrant diagrams we have developed. For other formalisation approaches to 2LTT, we refer to Subsection 1.1 above.