Internal ∞-Categorical Models of Dependent Type Theory : Towards 2LTT Eating HoTT

Using dependent type theory to formalise the syntax of dependent type theory is a very active topic of study and goes under the name of "type theory eating itself" or "type theory in type theory." Most approaches are at least loosely based on Dybjer’s categories with families (CwF’s) and come with a type Con of contexts, a type family Ty indexed over it modelling types, and so on. This works well in versions of type theory where the principle of unique identity proofs (UIP) holds. In homotopy type theory (HoTT) however, it is a long-standing and frequently discussed open problem whether the type theory "eats itself" and can serve as its own interpreter. The fundamental underlying difficulty seems to be that categories are not suitable to capture a type theory in the absence of UIP.In this paper, we develop a notion of ∞-categories with families (∞-CwF’s). The approach to higher categories used relies on the previously suggested semi-Segal types, with a new construction of identity substitutions that allow for both univalent and non-univalent variations. The type-theoretic universe as well as the internalised (set-level) syntax are models, although it remains a conjecture that the latter is initial. To circumvent the known unsolved problem of constructing semisimplicial types, the definition is presented in two-level type theory (2LTT).Apart from introducing ∞-CwF’s, the paper explains the shortcomings of 1-categories in type theory without UIP as well as the difficulties of and approaches to internal higher-dimensional categories.


I. INTRODUCTION: FORMALISING TYPE THEORY
Dependent type theory in the style of Martin-Löf forms the foundation of various dependently typed programming languages and proof assistants, such as Agda, Coq, Epigram, Idris, and Lean. Numerous variations of type theory have been considered, and models are studied in order to better understand the properties of these theories. Even the study and formalisation of models of type theory in type theory itself is an active field of research, involving various different models such as the setoid model implemented by Palmgren [5] and others, parametric models of type theory (Bernady et al. [6]), or an implementation of the groupoid interpretation (Sozeau and Tabareau [7]) by Hofmann and Streicher [8]. In particular formalisations of the syntax of type theory, i.e. the syntactic model or term model, have received significant attention. Statements of the form "type theory should be able to handle its own meta-theory" are often made (e.g. the very first sentence by Abel et al. [9]), which refers to formalising the (intended) initial model of type theory. 1 Altenkirch and Kaposi [3] call this simply type theory in type theory. To avoid confusion, we refer to the type theory in which these models are implemented as the host theory, and the structure that get implemented as the object theory or simply the model. The expression "type theory eats itself" for this concept was suggested by Chapman [16], inspired by Danielsson [17] and others. Other recent work on the same goal with various techniques includes the studies by Escardó and Xu [18], the PhD thesis by Kaposi [19], the work by Gylterud, Lumsdaine, and Palmgren [20], and the presentation by Buchholtz [21].
The closely related idea to formalise the notion of a model of dependent type theory inside dependent type theory itself goes back at least to Dybjer's internal type theory via categories with families, often just referred to as CwF's [22] (see also formulation by Awodey [23]). Formalisations of various models have since then been pursued many times; a careful comparison of different definitions of models inside type theory has been given by Ahrens et al. [24], [25]. A category with families consists of a category with a terminal object, a presheaf of families on it, and a context extension operation. The objects of the category are usually denoted by Con ("contexts") and the morphisms by Sub ("substitutions" or "context morphisms"). Many presentations further split the presheaf into two functors Ty and Tm, with the idea being that Ty gives the types in a context and Tm the terms of a type. The terminal object represents the empty context.
CwF's, the sorts are contexts, substitutions, types, and terms. Examples for operations are composition of substitutions, identity substitutions, and context extension. The equalities include the associativity law for composition, identity laws, laws expressing that types and terms form functors, and so on. In type theory, sorts can be represented as types and type families. This includes a type Con : U for contexts and families Sub : Con → Con → U as well as Ty : Con → U for substitutions and types. 2 Operations are functions with sorts as codomains. For example, given a type A : Ty ∆ and a substitution σ : Sub Γ ∆, we need an operation (often written as [ ]) which gives us a new type A[σ] : Ty Γ. Equalities are stated using Martin-Löf's identity type, also known as equality type, path type, or identification type, denoted by a = b. 3 As an example, we need an equality of the form A full presentation of type theory in this form, similar to the one developed by Altenkirch and Kaposi [3], is shown in Fig. 1. 4 If one works in a type theory that has quotient inductive-inductive [28] or higher inductive-inductive types [29], then defining a CwF as a GAT automatically gives a formalisation of the initial model (the intended syntax). Besides the initial model, a very important interpretation is the standard model (see e.g. the work by Altenkirch and Kaposi [3] and Coquand et al. [30]), sometimes known as the meta-circular interpretation. It is based on the observation that the category of [small] types can be equipped with the structure of a CwF in a canonical way. In detail, contexts and substitutions in the standard model are [small] types and functions of the host theory, types of the model are dependent types of the host theory, and terms are dependent functions.
We have a morphism of models from the initial model to any other model, and in particular to the standard model. Therefore, anything we do in the syntax (the object theory) can be interpreted as a construction in the host theory. Shulman [31] argues that we should expect this to be possible if type theory is to be seen as a general purpose programming language, as any such language should be able to implement its own interpreter or compiler. This motivates the formulation of the following somewhat vague task: General Problem: In a (given specific version of) dependent type theory, define the notion of model such that both the initial model and the standard model can be constructed, and such that the initial model can reasonably be viewed as syntax.
It seems difficult, but also slightly besides the point, to make the above General Problem completely precise to exclude trivial solutions; a satisfactory solution is something of the category "we know it when we see it". The expectation is that a model should allow at least the constructions listed in Fig. 1, i.e. each component of that figure should be definable. An (algebraic) definition of a model will give rise to the definitions of model morphism and thus initiality in a canonical way. Since we don't want the initial model to be trivial, the notion of model should contain base types; these are omitted in Fig. 1 (and in most parts of the current paper) for simplicity, but easy to add, cf. [3].
The most interesting question is arguable what it means that the initial model can be viewed as syntax. Note that the equality type of the host theory plays the role of definitional/judgmental equality in the (initial) model. Therefore, we expect that the equality of the initial model is proof-irrelevant, i.e. Con, Sub, Ty, Tm are (homotopy) sets in the terminology of homotopy type theory (but see footnote Footnote 6).
If we want to model an intensional type theory (which is the primary case of interest here), it is further desirable that the equality in the initial model is decidable, corresponding to decidable type checking. This means for example that, for Γ : Con, we have If we instead model extensional Martin-Löf type theory, we cannot expect this (cf. Clairambault and Dybjer's work [32]), but the requirement of proof-irrelevance remains.
In intensional dependent type theory with the axiom of unique identity proofs (UIP), i.e. the assumption that all equalities are proof-irrelevant, and quotient inductive-inductive types [28], a solution to the problem has been given by Altenkirch and Kaposi. They construct the initial model with the standard interpretation [3] and show that the initial model has decidable equality [33].
We are interested in settings where UIP is not assumed, which makes the problem much harder. In particular, it is a long-standing open problem whether homotopy type theory (HoTT) [4], which rejects UIP, is able to handle its own meta-theory. The question was first raised by Shulman [31] and has since then been discussed very actively, in particular by Escardó and Xu [18], Gylterud, Lumsdaine, and Palmgren [20], Buchholtz [21], and Altenkirch [34]. Progress in the setting without UIP has also been made by Abel,Öhman, and Vezzosi [9]. The core task, as described by the General Problem above, is still unsolved.
If we define a CwF in homotopy type theory to consist of the components in Fig. 1, maybe with additional base types, universes, or Πand Σ-types as suggested for example by Kaposi, Huber, and Sattler [2], we have to decide how we react to the absence of UIP. If we simply ignore it, the equality types will not be well-behaved and expected properties will not hold, a very common phenomenon in homotopy type theory. In particular, the initial model will not have proofirrelevant (or even decidable) equality, making it unsuitable as "syntax" in any form. Phrased differently, the expected quotiented term model will not be initial. The typical strategy to address this problem is to explicitly include a condition which ensures that all involved types are truncated at a certain level (i.e. that equality has to be irrelevant at some level). As a prominent example, the notion of category considered by Ahrens, Kapulkin, and Shulman [35] requires morphisms to form a set to ensure well-behavedness. Unfortunately, this would not be a satisfactory solution in our situation. Since univalent universes in homotopy type theory are provably not set-truncated [4, Ex. 3.1.9], any such truncatedness assumption would mean that the standard "model" will cease to be a model.
The fundamental underlying issue is that (ordinary) categories are not suitable to talk about non-truncated structures internally in homotopy type theory or other versions of dependent type theory without UIP. The laws of category theory, such as associativity or identity laws, are not appropriately modelled by the internal equality type. In fact, equalities in a theory without UIP are data rather than properties. Thus, an internal equality expressing associativity is much more similar to an isomorphism in a bicategory than a law in a (1-)category. Being even more precise, we should say that an equality behaves like an isomorphism in an (∞, 1)-category (for simplicity called ∞-category; a survey has been given by Bergner [36]), as higher equalities of any levels will be possibly non-trivial data [37].
This motivates the current paper. We define the notion of a model of type theory using ∞-categories rather than ordinary categories. In a nutshell, doing so corresponds to adding all higher coherences which are missing from Fig. 1, turning it into an ∞-category with families. The main difficulty is that ∞-CwF's need an infinite tower of data, and this data needs to be organised appropriately. It is in particular unknown whether this structure can be represented in the version of homotopy type theory developed in the standard reference, the "HoTT book" [4]. To circumvent this problem, we work in a two-level type theory [38], [39] which makes the construction possible. This nevertheless has significant implications for "ordinary" homotopy type theory, where all finite special cases can be expressed. Therefore, our construction automatically gives a definition in HoTT of (2, 1)-CwF's, (3, 1)-CwF's, and more generally (n, 1)-CwF's for any externally fixed natural number n. This already strongly generalises ordinary CwF's, which are merely (1, 1)-CwF's in this scheme.
The specific approach to ∞-categories that we work with is based on the semi-Segal types suggested independently by Capriotti [40] and Schreiber [41], further studied by the current author in joint work with Capriotti [42] as well as with Annenkov, Capriotti, and Sattler [39]. While this approach immediately gives a definition of an ∞-semicategory, adding the identities in a well-behaved manner is trickier than one might expect. All the authors of the work mentioned above use identities which have univalence built-in. This is natural in homotopy type theory, but not necessarily desirable when considering models since we would not expect the syntactic model to be univalent (and even if we do, previous formalisations of the syntax are not univalent and would not be captured by a formulation that requires univalence). We therefore introduce a new definition of identities, namely idempotent equivalences. We prove that our identity structure is unique (i.e. a propositional property rather than data) and therefore automatically fully coherent. A further propositional property expressing univalence can be added optionally on top.
Related work: The original connection between higher categories (in the form of spaces) and type theory, discovered by Awodey and Warren [43] and by Voevodsky (see the presentation by Kapulkin and Lumsdain [44]), marks the beginning of the study of homotopy type theory and univalent foundations. While Voevodsky's model of the univalence axiom uses simplicial structures, the superficial similarity to the work in this paper may be somewhat misleading; in fact, the motivation for the appearance of higher categories is reversed. Voevodsky's simplicial set model uses higher categories in order to model the equality type of the type theory that is modelled, while we are using higher categories because the host theory is unsuitable for working with ordinary categories. While Kapulkin and Lumsdaine [44] define one particular model, the current paper defines a type ("classifier") of models. Similarly, Barras, Coquand, and Huber [45] construct a (concrete) model interpreting types as semisimplicial sets. Boulier [46] and other authors discuss and formalise various models assuming UIP locally or globally. Abel,Öhman, and Vezzosi [9] formalise the syntax in a type theory without UIP, but their induced notion of model includes non-welltyped components which are not present in a type-theoretic universe; thus, the standard interpretation is not a model, and the current author did not manage to use their approach for a solution of the General Problem discussed above. Complete semi-Segal types are a known approach to univalent ∞categories [39], [40], [42], and the current paper uses a variation of those in order to avoid completeness/univalence. Nguyen and Uemura [47] propose the development of ∞type theories, where definitional equalities are replaced by homotopies; although their proposal is not worked out in full at the time of writing, we speculate that our ∞-CwF's are in principle general enough to also be a suitable notion of model for ∞-type theories. Capriotti and Sattler [48] build an interpretation based on Segal types for a specific type theory and prove the equivalence between the initiality and induction principle for higher inductive-inductive types.
Overview of the paper: Section II discusses the formalisation of 1-categorical models, in the form of CwF's, in a type theory with UIP. This approach does not work anymore when UIP is dropped, as several examples break. For our higher-categorical approach, we want to use semisimplicial types to construct semi-Segal types with a new notion of identity, introduced in Section III. The heart of the paper is Section IV, where we develop enough internal ∞-category theory in order to define ∞-CwF's. In Section V, we will see that all the examples that were broken without UIP work when using ∞-CwF's. In Section VI, we discuss open problems and conjectures, and conclude.
Specification of the host type theory: We work in dependent type theory (the "host theory") with Σand Π-types satisfying their respective judgmental η-rule, and with a hierarchy of universes. We always assume function extensionality. In Section II, we assume that the host theory satisfies UIP in order to discuss the standard approaches and why they fail without UIP. From Section III on, we drop this assumption and work in homotopy type theory with all definitions and features introduced in the "HoTT book" [4]. In particular, we use the notions of proposition (−1 -type), set (0 -type) and more generally n-type, as well as the path over notation expressing substitution/transport (a = p b means subst(p, a) = b).
From Section III on, we assume that the host theory is equipped with a second kind of equality type, turning it into a two-level type theory. A very brief introduction is given in Section III-A, but all ideas of the current paper should be understandable without knowledge of two-level type theory as it behaves essentially like "ordinary" Martin-Löf type theory. For details, we refer to [39].
Agda formalisation: The discussed identities via idempotent equivalences, which turn an ∞-semicategory into an ∞category, are a small part of the paper but represent a core idea for the construction of ∞-CwF's. The idea and all proofs can be formulated in a very simple setting that can be formalised without having to refer to 2LTT. An Agda implementation is available on GitHub. 5

A. Motivation and categorical definition
In order to define higher-or ∞-categorical internal models of type theory, we need to find a suitable one-dimensional formulation which can serve as a starting point for generalisations. In the current section, we therefore want to work with types that do not possess non-trivial higher structure. This means that all types in this section are assumed to satisfy the principle of unique identity proofs (UIP), i.e. are (homotopy) sets.
In the introduction we have seen Fig. 1, due to Kaposi and others [1], [2], which presents the components of type theory as a generalised algebraic theory. In detail, a model of type theory according to Fig. 1 consists of four types and type families (Con, Ty, Sub, Tm), together with ten terms that inhabit the four type families in various ways, and together with twelve equations. The original work by Altenkirch and Kaposi [3] (as well as [1], [2]) contains additional components for various type formers. These and the twenty-six components of Fig. 1 are then viewed as signatures and constructors of a quotient inductive-inductive type (QIIT) which defines the initial model (the "syntax"). In the current paper, we are interested in models in general, not only the initial such model. Moreover, the initial model of Fig. 1 is rather uninteresting since we have not added base types, meaning that the initial model has only the empty context and no types.
A more compact description of a model of type theory is given by the categorical formulation of a CwF [22]. Before stating its definition, let us recall the following basic categorical constructions. Let D be a category and F be a functor from D to the category Set of sets and functions. The category of elements is denoted by D F . Its objects are the For d ∈ D 0 , the slice category D/d has as objects those morphisms of D which have d as codomain, while morphisms are those of D which make the evident triangle commute.
. By the Yoneda lemma, this is equivalent to having an element x ∈ F (d) such that (d, x) is initial in D F . We follow standard terminology and call d the representing object and x universal element.
and, for every ∆ ∈ C 0 and A ∈ Ty(∆), an object ∆ A together with a morphism p A : C 1 (∆ A, ∆) which represents the functor Fig. 1 can be seen as a direct implementation of Definition 1 in type theory. The correspondence is made clear by the subheadlines in the figure.

B. Examples
The literature covers many examples for CwF's. For us, the following standard and well-known examples are particularly interesting: Example 2 (syntax/initial model). In a version of type theory with quotient inductive-inductive types (QIITs) [28], [49], we can read Fig. 1 directly as a QIIT signature. There is an implied notion of model morphism, and the QIIT is automatically the initial such model. This is how the construction is presented by Altenkirch and Kaposi [3], and we refer to their construction as the syntax QIIT. The initial CwF without base types consists of only the empty context, but they demonstrate that it is easy to add further components: Unit, Bool, Σand Π-types as well as a "universe" (U, El).
Kaposi and Altenkirch [33] further show that the syntax QIIT has decidable equality. This is important if we want to view the initial model as formalised syntax, and from this point of view, the internal equality type plays the role of the metatheoretic definitional equality, which in most type theories is required to be decidable.
Example 3 (standard model). The standard model is the CwF of types and functions: each expression in Fig. 1 is interpreted by its canonical "semantic counterpart". We need a fixed [small] universe U to define this internally. Then, the standard model is given by: Several authors (see e.g. [3], [18]) have noticed that all equations in this model hold definitionally (i.e. by refl): function composition is definitionally associative (assuming η for Πtypes), and so on. This will play a role later in the current paper.
Example 4 (modelling an axiom). Assume we are given a set-CwF C. This model may have additional types and type formers such as Π-types and universes. We now may want a model where a global assumption is satisfied, i.e. the axiom of function extensionality. Such a model can be created by fixing the context Γ 0 to contain a term which witnesses function extensionality, and constructing the slice C/Γ 0 . As usual, contexts of C/Γ 0 are pairs (∆ : Con, δ : Sub ∆ Γ 0 ), and a morphism between (∆, δ) and (Φ, ϕ) is a pair (f : Sub ∆ Φ, e : δ = ϕ f ). The other components of the new model are those given by C.
The above examples work very well in a type theory where every type satisfies UIP. If we drop this assumption, be it because we want to be more general or other assumptions would be inconsistent with UIP (such as the univalence axiom/principle), we have to choose whether we adapt the definition of a CwF. The first canonical possibility is to keep the previous definition, which leads to what we call a wild CwF: Definition 5 (wild CwF). A wild CwF is a 26-tuple (Con, Sub, . . .) of all the components in Fig. 1.
The other canonical possibility is to simply require that all the involved types satisfy UIP, i.e. are sets; this leads to the definition of a set-CwF: Definition 6 (set-CwF). A set-CwF is a wild CwF together with the following four components: Unfortunately, neither suggestion is satisfactory with the General Problem (cf. the introduction) in mind. Without UIP, the [lowest or higher] universe U is not necessarily a set anymore, and even provably not a set in HoTT. Thus, the standard model Example 3 is not a set-CwF. While the standard model is a wild CwF, the remaining two examples break in the absence of UIP. Altenkirch and Kaposi's syntax QIIT (Example 2) is a wild CwF and remains a valid example, but is not the initial wild CwF. For example, the (higher) equality idl id = idr id holds in the syntax QIIT, but there is no way to prove it from the components in Fig. 1 (assuming the type theory has base types). The situation is even worse for the slice model (Example 4), which cannot even be constructed. Both constructions fail for the same underlying problem, namely coherence data that is missing from the definition of a wild CwF. For the initiality, we have discussed above that at least a datum that gives us idl(id) = idr(id) would be needed, and for the slice construction, "MacLane's pentagon coherence" is missing. Unsurprisingly, naïvely adding these to the definition of a wild CwF creates the need to add even more data, and so on. The approach advocated in this paper, i.e. the use of ∞-categories, amounts to adding all this data.
Section summary. Dybjer's notion of a model of type theory, a category with families (CwF), can be represented as a generalised algebraic theory and implemented in dependent type theory. The most important examples of models are the initial model, which one expects to coincide with an internal representation of the syntax, and the standard model of types and functions, which provides the "obvious semantics". Both models have been studied and work well in a type theory with UIP. Without UIP, neither the unmodified definition of a CwF nor the definition extended with the requirement that all involved types satisfy UIP is satisfactory.

III. INTERNAL ∞-DIMENSIONAL CATEGORIES
Definition 5 defines a wild CwF to be a tuple with 26 components. Even more extreme, Definition 6 defines a set-CwF to consist of 30 components. While this is tedious to write these down in type theory, expressing such a definition is entirely straightforward to simply by listing the components. Formally, a CwF is an element of a nested Σ-type or, if supported by the type theory, a record type (we view records as syntactic sugar for nested Σ-types).
However, what happens if we want to define a structure to consist of not only 30, but infinitely many components? Often, this can be encoded in a finite way. To give a trivial example, an infinite sequence of elements of a type A is simply given as the function type N → A (or as a coinductive type of streams [50]).
A non-trivial example for a structure with infinitely many components are semisimplicial types [51], [52], and these are important for the approach to ∞-categories that we chose in this paper. It is a long-standing open problem whether they can be defined in homotopy type theory. Therefore, we work in two-level type theory (2LTT [38], [39], [53]), an extension of HoTT which allows us to work with semisimplicial types and similar structures.
In order to understand the later ideas of this paper, semisimplicial types are important. Therefore, we first briefly recall what they are. Two-level type theory is more of a technical framework which is required to perform the constructions in full generality, but it is not crucial in order to understand the ideas; a brief explanation is given below and, for details, we refer to [39].

A. Semisimplicial Types
A semisimplicial type of dimension 2 is a tuple (A 0 , A 1 , A 2 ) of types and type families as follows: We think of A 0 as a type of points or vertices, of A 1 x 0 x 1 as lines, of A 2 with three lines as arguments as a type of triangle fillers, and it is (at least on an intuitive level) clear what a semisimplicial type of dimension 3 (extend the above with a family A 3 of tetrahedron fillers) would be, and so on. Meta-theoretically (and in 2LTT), the semisimplicial type (A 0 , A 1 , A 2 ) represents a type-valued presheaf on the index category which is given by The morphism part of this presheaf (i.e. the functions in (51)) are simply projections. It works out such that the usual functor laws hold definitionally thanks to η for Σ-types. This style of presentations of structure as type families described by an index category are known since at least Makkai's FOLDS [54].
A "full" semisimplicial type is a presheaf on the simplex category without degeneracies, ∆ + , of which (50) is an initial segment. 2LTT is a version of type theory where this can be expressed. The main idea of 2LTT that we need to keep in mind for the rest of this paper is that it has a strict layer on top of "normal HoTT". The strict layer contains strict natural numbers N s as well as strict equality (= s ), and more generally contains constructions that would usually only work in the meta-theory; e.g. a number n : N s behaves like an externally fixed natural number (a numeral), and strict equality plays the role of judgmental/definitional equality (at least from the point of view of "normal HoTT"). For clarity, we refer to types in "normal HoTT" as fibrant and types in the strict layer as strict.
Strict equality allows us to talk about strict categories, strict functors, and strict natural transformations. A natural example of a strict category is the universe. The strict category ∆ + has n : N s as objects, and a morphism from m to n is an injective and monotone function Fin m → Fin n . Semisimplicial types are strict functors satisfying the so-called Reedy fibrancy [55] condition which essentially says that the functor can be described by type families as in (51). In a similar fashion, it is possible to define a family of semisimplicial types indexed by another semisimplicial type, which can also be described as a semisimplicial type over a semisimplicial type or a displayed semisimplicial type:

B. Contexts and substitutions, first part: semi-Segal types
Segal spaces (Rezk [56]), also called Rezk spaces, are a model for higher categories. Translating Rezk's Segal condition to type theory is straightforward and has been presented previously by Capriotti [40] and others, but note that the degeneracies are missing. We briefly sketch the definition as presented in [39], [40].
On the strict level, and for n : N s , we have the representable functor ∆[n]. It can be viewed as the n-dimensional tetrahedron. A trivial application of the Yoneda lemma shows that, given a semisimplicial type A, the type of natural transformations ∆[n] → A is strictly isomorphic to the total space of A n (a collection of n + 1 points in A 0 , n+1 2 lines, and so on). Given another number k : N s , the horn Λ k [n] is the semisimplicial set obtained from the representable ∆[n] by removing the identity morphism on Fin n and the monotone injection Fin n−1 → Fin n which does not have k in its image. There is an obvious inclusion Λ k [n] → ∆[n] that is used in the following definition: Definition 8 (Segal condition [39], [56]). A semisimplicial type A satisfies the Segal condition if, for any given n and 0 < k < n, any given η : Λ k [n] → A can uniquely be extended to a natural transformation ∆[n] → A, in the sense that the type of extensions is contractible.
We remark that A is often called local with respect to the inclusion Λ k [n] → ∆[n].
In previous work with Capriotti [42], we unfold the Segal condition explicitly for small n, k (and actually fix k ≡ 1, which is sufficient). Given a semisimplicial type (A 0 , A 1 , A 2 ) of level 2, the Segal condition can be expressed as: We also call this a horn-filling condition or the condition that the horn x 0 x01 − − → x 1 x12 − − → x 2 has a contractible type of fillers. In [42], an explicit translation between horn-filling conditions and the structure one expects of (higher) semicategories is constructed. It not hard to see that having the pair (A 2 , h 2 ) is equivalent to having a composition operator ( • ) : having an element of a type (here A 1 x 0 x 2 ) is equivalent to having a family over the type (here A 2 x 01 x 12 : A 1 x 0 x 2 → U) and a proof that it is inhabited at exactly one point (here h 2 x 01 x 12 ). On the next level, we require that any map Λ 1 [3] → A can uniquely be extended to ∆[3] → A, and this (together with A 3 ) is equivalent to stating that • is associative. The next level corresponds to the pentagon coherence of associativity familiar from the definition of a bicategory [42]. This motivates the following definition: Definition 9 (∞-semicategory [40]). A semisimplicial type A is an ∞-semicategory (also known as a semi-Segal type) if it satisfies the Segal condition.
The generalisation from semisimplicial types to maps between semisimplicial types is canonical: Definition 10 (inner fibration). An inner fibration, or an ∞-semicategory over an ∞0semicategory, is a Reedy fibration η : E A such that, for all n, 0 < k < n, and squares of the form shown on the right, the type of fillers (i.e. the type of the dashed map) is contractible. It is worth noting that, by definition, a semisimplicial type A is an ∞-semicategory exactly if A 1 is an inner fibration.

C. Contexts and substitutions, second part: identities
The natural next question is how the definition of an ∞semicategory can be extended to capture ∞-categories. To do this, we need to add a property which ensures that the ∞semicategory has identities. We want this property to satisfy the following conditions: 1) Of course, the property should give us (i.e. allow us to construct) the "naïve" identities that are shown in Fig. 1: For every object, we want an endomorphism id such that id σ = σ and σ id = σ.
2) The property should be a proposition. In other words, we want an ∞-semicategory to be an ∞-category in at most one way. This is important because we do not only want to talk about a single ∞-category in isolation, but about a type of ∞-categories.
3) From the perspective of HoTT, it is natural to want univalent (or saturated) ∞-categories, meaning that identities/equalities and isomorphisms coincide (analogous to univalent 1-categories [35]). As one might expect, the standard model will indeed turn out to be a univalent ∞-CwF. However, not all examples that we want can possibly be univalent: In a type theory, contexts can be isomorphic in non-trivial ways, meaning that the type Con in a univalent ∞-CwF cannot be a set. This would rule out the "syntax" (Example 2). Phrased differently, the initial model of a non-trivial type theory would not be on the level of sets (and will in particular not have decidable equality for contexts), which contradicts the expectation by Altenkirch [34] and others. 6 Therefore, we want a more general definition of "being an ∞-category" (a.k.a. "having identities") which allows us to study both univalent and non-univalent variants.
The question of adding identities to ∞-semicategories has been studied outside the field of type theory long before HoTT was researched. It is known [57] that a semisimplicial set with (not necessarily unique) fillers for all (not necessarily inner) horns can be extended to a simplicial set. This is however non-constructive and relies on choice. Our situation is closer to semisimplicial spaces with an inner horn filling condition, for which Lurie [58] and Harpaz [59] have suggested a simple condition that expresses the presence of suitable identities. The translation of their idea into type theory leads to the complete semi-Segal types by Capriotti [40] and others. Complete semi-Segal types can be taken as the definition of type-theoretic univalent ∞-categories, but the univalence condition is built into the definition of identities.
A direct replacement of the full simplex category has been suggested by Sattler and the current author [60], which gives rise to (a replacement of) simplicial types and thereby (not necessarily univalent) ∞-categories. Another direct replacement was given by Kock [61]. These approaches both work by adding an infinite tower of data.
The current paper gives a new and different definition of identities in ∞-semicategories. The idea is motivated by [60] and inspired by what is known as dunce's hat in topology [62], which is the simplest example of a space that is contractible but not collapsible (in type-theoretic terms: a space that is contractible but not of the form Σ(a : A).a = a 0 ). Concretely, we define identities to be idempotent equivalences. This is both minimalistic and, as we prove in this section, wellbehaved; it satisfies the three properties listed above. This definition corresponds to a characterisation of identities that was independently suggested by Lai [63], who considered (∞, 1)-categories in a slightly different version of type theory.
This author expects that the definition of identities via idempotent equivalences is equivalent to both of the mentioned "elaborate" definitions [60], [61]. If we add univalence, the equivalence with complete semi-Segal types is obvious.
Our definition of an identity does not need the whole infinite structure of an ∞-semicategory, but only the first four levels (A 0 , A 1 , A 2 , A 3 ). Using the translation explained in Section III-B, we phrase this subsection in the (maybe more familiar) language of a semicategory (Ob, Hom, , assoc), without any requirement of set-truncation. This allows us to present the development in a very elementary way, without the need to allude to infinite structures. Below, we state the precise definitions and theorems; the detailed proofs themselves are reasonably elementary and can be found in the Agda formalisation (see footnote 5 on page 4).
Definition 11 (identities via idempotent equivalences). In a wild semicategory (Ob, Hom, , assoc), a morphism e : Hom(x, y) is an equivalence (neutral morphism in [42]), written iseqv(e), if both composition operations are equivalences of types. A morphism f : Hom(x, x) is ) is a good identity if it is an equivalence and idempotent. The wild semicategory C ≡ (Ob, Hom, , assoc) has a good identity structure if there is an identity for every object, Univalence for ∞-categories is an optional additional property that one can add; it is not discussed further in this paper. From the next subsection on, we will drop the attribute good and simply speak of identities rather than good identities. There is no risk of confusion, especially since Theorem 12 essentially shows that every identity is good.
Section summary. A semisimplicial type is a typevalued presheaf on the category ∆ + , the category of finite (non-empty) sets and strictly increasing functions. Intuitively, a semisimplicial type is an infinite tuple (A 0 , A 1 , A 2 , . . .); this definition can be formulated in 2LTT. A semisimplicial type forms the "raw structure" of a higher category. If we equip it with the Segal condition (which is itself a propositional property), we get an ∞semicategory. Finally, an ∞-semicategory with an idempotent equivalence for every object is a not-necessarily-univalent notion of ∞-category in type theory.

IV. INTERNAL ∞-CWF'S
A. The empty context: a terminal object Modelling the empty context as a terminal object is standard.
Definition 15 (terminal object). Given an ∞-category (A 0 , A 1 , A 2 , . . .), an object x : A 0 is terminal if, for all y : A 0 , the type A 1 y x is contractible.

B. Types: a presheaf
Following Definition 1, types should be a presheaf on the category of contexts. This author is aware of two differently looking (but of course in a suitable sense equivalent) ways to define what an ∞-presheaf (or prestack) is in this setting. The first possibility is to: 1) define the opposite category A op ; 2) define the ∞-category T of types and functions; 3) and define what an ∞-functor between ∞-categories is. The second possibility, suggested and studied by Christian Sattler in unpublished work, is to consider right fibrations over the category of contexts. We will discuss this second approach and its advantages below in Remark 20. For now, we concentrate on the first possibility which is closer to the 1-categorical formulation discussed in Section II.
Let us start with the last point (3). A morphism in a (strict) functor category is a (strict) natural transformation, and ∞categories are certain (strict) functors equipped with structure. Manually unfolded to type theory, a natural transformation between semisimplicial types of level 2, from Being a strict map between the underlying semisimplicial types already ensures that F preserves the compositionality structure. We can make this transparent on level 2 via the translation explained in Section III-B, under which the last component F 2 translates to: ∞-categories come with a proof that the underlying functors are Reedy fibrant, but the strict natural transformation takes care of this automatically. Thus, the only task that is left is to ensure that the functor F preserves identities, i.e. if i : A 1 x x is an idempotent equivalence, then F 1 i has to be an idempotent equivalence as well. Stating it in this way would not give a well-behaved notion of ∞-functor, since "being idempotent" is not a propositional property. Fortunately, idempotence is already preserved automatically by F 2 , and "being an equivalence" is a propositional property.
Definition 16 (∞-functor). An ∞-functor between ∞categories is a strict natural transformation which maps identities to equivalences.

Remark 17.
A strict natural transformation between ∞categories does not automatically preserve equivalences or even identities. Let be the terminal ∞-category, which is the unit type Unit on every level. Let A be the ∞-category defined by A 0 :≡ Unit, A 1 :≡ (2 → 2), A 2 f g h :≡ (g • f = h), and A k+3 being constantly Unit. There are three maps → A, each of them even an inner fibration, but only a single of them preserves identities.
Given an ∞-category A ≡ (A 0 , A 1 , A 2 , . . .), we need to define the opposite category A op ≡ (A op 0 , A op 1 , A op 2 , . . .). There is really only one possible construction: of course we want A op 0 :≡ A 0 and A op 1 x y :≡ A y x, and after this, everything is determined; e.g. we have A op 2 f g h :≡ A 2 g f h, since nothing else would type-check. The concrete combinatorial description for the representation as functors is identical to the one for simplicial sets given by Lurie [64, Sec 1.2.1].
Finally, we need the ∞-category T of types and functions, starting with T 0 ≡ U, T 1 X Y :≡ (X → Y ), and T 2 f g h ≡ (g • f = h). We briefly sketch the complete construction given in [39]. Given any strict category C, one can define a strict functor N + (C) : ∆ op + s = ⇒ U via the usual nerve construction which defines N + (C) n to be (fibrant) type of sequences X 0 → X 1 → . . . → X n . This strict functor is not Reedy fibrant, but via a general Reedy fibrant replacement construction [39,Sec. 4], one can find a levelwise equivalent and Reedy fibrant functor R(N + (C)). The identity structure is obvious and simply comes from X id − → X.
Definition 18 (∞-category of small types). The ∞-category T is given as R(N + (U)), where U is the strict category of types and functions.

C. Terms: diagrams over a category of elements
Recall from Definition 1 that terms are in 1-CwF's modelled by a functor Tm : C op Ty → Set. Our treatment of types has already covered several of the components that are needed in order to translate this to the ∞-categorical setting. The remaining missing part is the construction of the category of elements, which is what we explain in this subsection.
Let A be an ∞-category and F : A → T be an ∞functor. As one may expect, A F can be viewed as an ∞category over A: Given an n-simplex in A consisting of vertices x 0 , x 1 , . . ., lines x 01 , . . ., and so on, we can build an n-simplex in A F if we have something in F 0 x 0 , in F 0 x 1 , in F 1 x 01 , and so on, where all the new data has to "match". Our goal is to define A F on all levels.
We first solve the problem for the case that A is a strict category and F : A → U a strict functor with the following adhoc construction that has been (partially) discussed in [39]. We For the terminal ("universal") case, where A is U and F the identity functor, we denote the constructed Reedy fibration by T • T . We call T • the ∞-category of pointed types. For the first few levels, its "over T " representation is the following, where we annotate arguments with their types for readability and happly is the function given in [4, Eq. 2.9.2]: We can now come back to the general case of an ∞-category A and an ∞-functor F : A → T . Recall (from [39]) that Reedy fibrations are closed under pullback.
Definition 19 (∞-category of elements). For an ∞-category A and a functor F : A → T , the ∞-category of elements of F , written A F , is defined to be the strict pullback of F along the Reedy fibration T • T , as shown on the right.
It is standard that pullbacks are closed under fibrations (given a lifting problem for A F A, we extend it to a lifting problem for T • T and use the pullback property). Therefore, A F is an ∞-category.
Remark 20 (left and right fibrations). Let η : E A be a Reedy fibration between semisimplicial types. η is a left fibration if it fulfils the condition of Definition 10 for 0 ≤ k < n (that means that all left fibrations are inner fibrations, but only some inner fibration are left fibrations). Analogously, η is a right fibration if the condition of Definition 10 holds for for 0 < k ≤ n.
One can show that the map η : N • + (A, F ) → N + (A) constructed above, and in particular T • T , is a left fibration. One can further show that T • T is a homotopical left fibration classifier: For any left fibration E A, the type of tuples (g, h, q) with g : A → T , h : E → T • , and q witnessing that the resulting square commutes up to homotopy and is a homotopy pullback, is contractible.
This implies that left fibrations over A are in a suitable sense equivalent to ∞-functors A → T . Thus, ∞-presheaves on A correspond to right fibrations over A. If C is the ∞category of contexts, we can define types to be given as a right fibration Ty C. Since Ty already is (the opposite of) the ∞-category of elements, terms are then simply given by a second right fibration Tm Ty. This formulation is due to Christian Sattler.
Note that the strict pullback (64) is also a homotopy pullback since the vertical maps are Reedy fibrations.

D. Context extension
When generalising from CwF's to ∞-CwF's, context extension greatly benefits from the formulation of representabiliy via initiality in a category of elements (see Section II). Even for ∞-categories, representability can be stated referring only to the lowest levels of the category, i.e. using finitely many components. However, the presentation of Fig. 1 relies on UIP and does not work out of the box; instead, we define: Definition 21. Let F : A → T be an ∞-functor. A representation for F is a tuple (x, u, r) where x : A 0 , u : F 0 x, and r : Applying this definition to our case of interest and unfolding leads us to: Definition 22 (context extension structure). Let an ∞category C be given together with ∞-functors Ty : C op → T and Tm : C op Ty → T . A context extension structure consists, for all Γ : C 0 and A : Ty 0 Γ, of the following data: 1) an object Γ A : C 0 , 2) a morphism p A : C 1 (Γ A) Γ, 3) and a term q A : Tm 0 ((Γ A), (Ty 1 p A A)). Whenever, in addition to Γ and A, we have Θ : C 0 and σ : C 1 Θ Γ and t : Tm 0 (Θ, (Ty 1 σ A)), then we also have the following data: 4) a morphism (σ, t) : C 1 Θ (Γ A), 5) a triangle filler β A,σ,t 1 : C 2 (σ, t) p A σ 6) an equality β A,σ,t 2 : Tm 1 ((σ, t), refl) q A = t over the equality we get from Ty 2 β A,σ,t 1 . 7) for any 3-tuple (τ, f, e) of the same type as ((σ, t), β A,σ,t 1 , β A,σ,t 2 ), the two tuples are equal.
Section summary. An ∞-CwF has the following components: 1) An ∞-category C, cf. Definition 14. This is a semisimplicial type (C 0 , C 1 , C 2 , . . .) such that every inner horn has a contractible type of fillers and, for every object, we have an idempotent equivalence. 2) C has a terminal object, cf. Definition 15. An object x is terminal if every C 1 y x is contractible. 3) An ∞-functor Ty : C op → T . Here, T (cf. Definition 18) is the semisimplicial type of (small) types and functions, with T 0 ≡ U and T 1 X Y :≡ (X → Y ). An ∞-functor (cf. Definition 16) is a strict natural transformation between semisimplicial types which maps identities to equivalences. 4) A second ∞-functor Ty : C op Ty → T . The ∞category of elements (cf. Definition 19) is defined by first constructing the ∞-category of pointed types. 5) A context extension structure, cf. Definition 22.
Context extension can be represented in a finite way even without referring to the strict layer of 2LTT. Christian Sattler has suggested an alternative, where the above functors Ty and Tm are replace by a sequence of right fibrations, Tm Ty C. Context extension can then be described as a right adjoint of the first fibration, in line with Awodey's presentation [23].

A. The Syntax as a QIIT
Every set-CwF in the sense of Definition 6 and Fig. 1 can be presented as an ∞-CwF. Therefore, the syntax QIIT by Altenkirch and Kaposi [3], discussed in Example 2, is an ∞-CwF. The concrete construction of the ∞-CwF C from Fig. 1 can be described as follows. One starts by defining C 0 to be Con and by setting C 1 Γ ∆ to be Sub Γ ∆. The next level is given by C 2 f g h :≡ (g f = h), and all higher components of C are contractible: C 3+n ( ) :≡ Unit. The other parts are constructed analogously. Summarised, the construction of an ∞-CwF from a set-CwF is easy because almost all components of the ∞-CwF become trivial.
Although we do not explain it in this paper, we can define what a morphism between ∞-CwF's is, which in turn lets us speak about the property of being the initial ∞-CwF (again, note that this only makes sense if we consider base types). We conjecture that the syntax is the initial ∞-CwF, but this seems to be highly non-trivial.

B. The Initial Model as a HIIT
The definition of an ∞-CwF is fully algebraic in the sense of Cartmell [27], although with infinitely many sorts, operations, and equations, and this is still true if we add components such as base types or Π-types. Clearly, semisimplicial types themselves are an (infinite) generalised algebraic theory, as seen from the presentation (47)(48)(49). For the Segal condition, this might be slightly harder to see; however, the specific formulation of the Segal condition via horn filling that we have chosen in Section III-B makes it doable: for every horn, we can generate a filler (with two operations), and that filler is equal to every other filler parallel to it (using two equations). This construction makes it possible to build the free ∞-category of a semisimplicial type if the type theory has an "infinite" version of higher inductive-inductive types as specified by Kaposi and Kovács [29], i.e. a HIIT where constructors are indexed over strict natural numbers. The other components of an ∞-CwF can be written as a GAT as well, giving us the initial ∞-CwF.
We do not know under which conditions this HIIT turns out to have decidable equality, but if it does, then it is in particular based on sets. If this is the case, it is also initial among the set-CwF's and thus equivalent to the syntax QIIT.

C. Higher Models from Strict Models and the Standard Interpretation
A strict CwF is a (1-categorical) CwF where most equations hold up to strict equality. As remarked in Example 3, this is in particular the case for the standard model. We show that, from a strict CwF, we get an ∞-CwF. Let us begin with a precise definition: Definition 23 (strict CwF). In 2LTT, a strict category with families (sCwF) is a CwF as in Fig. 1 such that Con, Sub, Ty and Tm are all fibrant types, while all the stated equalities for contexts, substitutions, types, and terms hold up to strict equality (= s ). For context extension, we need the contractibility condition of Definition 21 stated using the usual fibrant equality type (=), i.e. it suffices to have the conditions 5,6,7 in Definition 22 as fibrant equalities.
Proof sketch. The first part of the proof is given by the construction of semi-Segal types from strict categories, as described in [39] and sketched in Section IV-B. To construct the remaining components, we first generate strict semisimplicial diagrams by taking nerves N + and N • + as in Section IV-C. The Reedy fibrant replacement operation R constructed in [39] has the property that, from a strict natural transformation τ : X → Y between strict diagrams over ∆ op + , we get a strict natural transformation R(τ ) : R(X) → R(Y ) between the respective Reedy fibrant replacements, i.e. semisimplicial types. This follows from [39,Cor 4.28], applied on the diagram on the right.
Simply fibrantly replacing everything does not fully work for the ∞-functor Tm since the fibrant replacement does not commute with the required strict pullback, but switching to right fibrations and back (as discussed in Remark 20) resolves the issue. Context extension can be checked manually, since it only concerns the lowest levels.
Applying Lemma 24 on the 1-categorical standard model (which is a strict CwF, see Example 3) shows that the standard model is also an ∞-CwF.
D. Slicing in ∞-CwF's As a final example, let us show that the slice construction analogous to Example 4 works for ∞-CwF's. Slicing of ∞categories in type theory works in essentially the same way as slicing in simplical sets [64].
Given an ∞-category C with an object Γ : C 0 , we want to construct the slice ∞-category (C/Γ). Recall that elements of C n can, by Yoneda, be seen as n-simplices ∆[n] s = ⇒ C. We define (C/Γ) n to be the type of (n+1)-simplices where the last vertex strictly equals Γ; in other words, (C/Γ) n is defined to be C n+1 with a condition involving a strict equality. This type is fibrant nevertheless: (C/Γ) n is (strictly isomorphic to) a nested Σ-type of (n + 2) vertices including the last vertex x n+1 : C 0 , lines, triangle fillers, . . . , and the strict equality e : x n+1 = Γ. But the type of pairs (x n+1 , e) is strictly isomorphic to the unit type and therefore fibrant.
The morphism part of (C/Γ) is given as those morphisms in C n+1 which do not touch the last vertex. Thinking of C n+1 as simplices and face maps as projections as in (51), face maps are those projections which do not remove the last vertex x n+1 .
One can check that (C/Γ) is a semi-Segal type. Further, if i is an identity on Θ in C and f : C 1 Θ Γ an object of (C/Γ), then the identity on this object is given by the cell in C 2 f i f of Theorem 12. Thus, (C/Γ) is an ∞-category. As in the 1categorical case, the functors Ty and Tm as well as context extension are not affected by the slicing operation.
Section summary. In Section II, we have discussed that several 1-categorical CwF constructions break in the absence of UIP. In the current section, we have seen that the examples work (again) in the ∞-categorical setting.

VI. OPEN PROBLEMS AND FUTURE DIRECTIONS
We have demonstrated that higher-dimensional categories lead to a notion of model of type theory that is very wellbehaved and works in situations where 1-categorical models are unsuitable. Our work inspires numerous new questions. First of all, it seems natural to equip the definition of an ∞-CwF with additional components such as Π-types, Σ-types, universes, or simple base types. Developing a notion of ∞natural transformation, it is easy to define what a morphism between ∞-categories is; but the natural expectation would be that [small] ∞-CwF's form a [large] (∞, 2)-category, and it is much less clear how this can be formulated. The intermediate goal would be to show that ∞-CwF's form a large ∞-CwF.
A very important question is whether the Altenkirch-Kaposi syntax QIIT is initial as an ∞-CwF (after adding base types and other type formers). Phrased differently, we can ask whether the initial ∞-CwF has decidable equality. This is very closely related to the open problem whether HoTT can "eat" itself (Shulman [31]). Our conjecture is that HoTT cannot eat itself, but that 2LTT can eat itself. Of course, the intermediate goal that this paper is working towards is the statement that 2LTT can eat HoTT. Even a much weaker question, namely whether the initial ∞-CwF has trivial fundamental group, would be very interesting; but already this seemingly much simpler problem appears to be highly non-trivial, and similar results for seemingly simpler situations [65]- [67] suggest that a solution will require new techniques.
If it turns out that the syntax QIIT is indeed the initial ∞-CwF, we still have to face the problem of defining semisimplicial types before we can hope for a solution to the General Problem of whether "HoTT eats itself". The other direction seems in reach: If HoTT can eat itself, then we can define semisimplicial types. This has already been conjectured by Shulman [31] but not yet been made precise.
It also would be interesting to formulate and study higher categories with attributes (which one would expect to be equivalent to ∞-CwF's), the more general higher comprehension categories, and other internal ∞-categorical formulations of models that have been considered in 1-category theory.
The connection to directed type theory [68]- [72] is intriguing. Future directed type theories may allow us to develop ∞-category theory in a synthetic way, and the relationship to the semi-synthetic approach of this paper will be interesting to see.