Quotient InductiveInductive Types
 5 Citations
 4.9k Downloads
Abstract
Higher inductive types (HITs) in Homotopy Type Theory allow the definition of datatypes which have constructors for equalities over the defined type. HITs generalise quotient types, and allow to define types with nontrivial higher equality types, such as spheres, suspensions and the torus. However, there are also interesting uses of HITs to define types satisfying uniqueness of equality proofs, such as the Cauchy reals, the partiality monad, and the welltyped syntax of type theory. In each of these examples we define several types that depend on each other mutually, i.e. they are inductiveinductive definitions. We call those HITs quotient inductiveinductive types (QIITs). Although there has been recent progress on a general theory of HITs, there is not yet a theoretical foundation for the combination of equality constructors and inductioninduction, despite many interesting applications. In the present paper we present a first step towards a semantic definition of QIITs. In particular, we give an initialalgebra semantics. We further derive a section induction principle, stating that every algebra morphism into the algebra in question has a section, which is close to the intuitively expected elimination rules.
1 Introduction
This paper is about type theory in the sense of MartinLöf [29], a theory which proof assistants such as Coq [7] and Lean [14] as well as programming languages such as Agda [31] and Idris [8] are based on. Recently, Homotopy type theory (HoTT) [34] has been introduced inspired by homotopy theoretic interpretations of type theory by Awodey and Warren [5] and Voevodsky [25, 36].
A central concept in type theory is the concept of inductive definitions, which allows us to define inductive datatypes like the natural numbers, lists and trees just by presenting constructors with strictly positive occurrences of the inductive type being defined. Using the propositions as types explanation, we can use the same mechanism to inductively define predicates and relations, like an order on the natural numbers, or the derivability predicate for a logic defined by rules. Conceptually, HoTT changes what we mean by an inductive definition, because we view a type not only as given by its elements (points) but also by its equality proofs (paths). Hence an inductive definition may not only feature constructors for elements but also for equalities. This concept of higher inductive types (HITs) has been used to represent the homotopical structure of geometric objects, like circles, spheres and tori, and gives rise to synthetic homotopy theory in HoTT [32].
However, as already noted in the HoTT Book [34], HITs have also more quotidian applications, such as a definition of the Cauchy reals for which the use of the axiom of choice can be avoided when proving e.g. Cauchy completeness. Instead of defining the real numbers as a quotient of sequences of rationals, a HIT is used to define them as the Cauchy completion of the rational numbers, with the quotienting happening simultaneously with the completion definition. Similarly, a definition of the partiality monad, which represents potentially diverging operations over a given type, was given using a HIT [2, 13, 35], again avoiding the axiom of choice when showing e.g. that the construction is a monad [12].
Now, morally, from a family \(A \rightarrow (T_0(A) / R)\), we should be able to construct an element of the quotient \(T_0(A) / R\). This is indeed possible if A is \(\mathbf {2}\) or another finite type, by applying the induction principle of the quotient type A times. However, it seems that, for a general type A, this would require the axiom of choice [34], which unfortunately is not a constructive principle [15]. But using a higher inductive type, we can give an alternative definition for the type of Abranching trees modulo permutation of subtrees.
Example 1
Note that the fact that T(A) is a homotopy set (see preliminaries below) is implicitly included in the statement \(T(A) : \mathsf {hSet}\). The construction we were looking for is now directly given by the constructor \(\mathsf {node}\). This demonstration of the usefulness of higher inductive constructions to increase the strength of quotients was first discussed in Altenkirch and Kaposi [1], where such settruncated HITs are called quotient inductive types (QITs).
Another example of the use of higher inductive types is type theory in type theory [1], where the welltyped syntax of type theory is implemented as a higher inductiveinductive [30] type in type theory itself. A significantly simplified version of this will serve as a running example for us:
Example 2
Despite a lot of work making use of concrete HITs [4, 9, 10, 11, 23, 26, 27], and despite the fact that it is usually — on some intuitive level — clear for the expert how the elimination principle for such a HIT can be derived, giving a general specification and a theoretical foundation for HITs has turned out to be a major difficulty. Several approaches have been proposed [6, 18, 28, 33], and they do indeed give a satisfactory specification of HITs in the sense that they cover all HITs which have been used so far (see related work below). However, to the best of our knowledge, no approach covers higher inductiveinductive definitions such as Example 2. The purpose of the current paper is to remedy this. We restrict ourselves to sets, i.e. to quotient inductiveinductive types (QIITs). This is of course a serious restriction, since it means that we cannot capture many ordinary HITs such as e.g. the circle \(\mathbb {S}^1\). At the same time, all higher inductiveinductive types that we know of are indeed sets — the Cauchy reals, the surreal numbers, the partiality monad, type theory in type theory, permutable trees — and will be instances of our framework, which allows arbitrarily complicated dependency structures. In particular, we allow intermixing of constructors as in Example 2.
Contributions. We give a formal specification of quotient inductiveinductive types with arbitrary dependency structure. This can be viewed as the generalisation of the usual semantics of inductive types as initial algebras of a functor to quotient inductiveinductive types. A QIIT is specified by (i) its sorts, which encode the types and type families that it consists of (Sect. 2), and (ii) by a sequence of constructors, that in turn are specified by argument and target functors (Sect. 3). This is a very general framework, covering in particular point (Sect. 3.2) and path constructors (Sect. 3.4). Each constructor specification gives rise to a category of algebras, and we establish conditions on the target functors that allow us to conclude that these categories of algebras are complete (Sect. 3.5). This is important, because it allows us to prove the equivalence of initiality and a principle that we call section induction (Sect. 4), stating that every algebra morphism into the algebra in question has a section; this principle is close to the intuitively expected elimination rules.
A full version of the paper, including all proofs, is available on the arXiv [3].
Related Work. Sojakova [33] shows the correspondence between initiality and induction (a variant of our Theorem 31) for \(\mathsf {W}\)suspensions, a restricted class of HITs. Basold, Geuvers and van der Weide [6] introduce a syntactic schema for HITs without higher path constructors, and derive their elimination rules. Dybjer and Moeneclaey [18] give a syntactic schema for finitary HITs with at most paths between paths, and give an interpretation in Hofmann and Streicher’s groupoid model [22]. Finally, Lumsdaine and Shulman’s work on the semantics of HITs in model categories [28] is similar to an external version of our approach.
Preliminaries. We work in a standard MartinLöf style type theory and assume function extensionality. We do not assume univalence, but also do not contradict it; in particular, everything we do works in the type theory from the HoTT Book [34]. We write \(\mathcal {U}\) for “the” universe of types, omitting universe indices in the typical ambiguity style [21]. A type is a set if all its equality proofs are equal, and \(\mathsf {hSet}\) is defined as \(\varSigma (A : \mathcal {U}). \mathsf {is}\text{ }\mathsf {set}(A)\); we implicitly treat elements of \(\mathsf {hSet}\) as their first projections — this allows us to view \(\mathsf {hSet}\) as a universe. By a category, we mean a precategory [34, Definition 9.1.1] in the sense of the HoTT Book (all our categories become univalent categories if univalence is assumed). We write \(\mathcal {C}\Rightarrow \mathcal {D}\) for functors and \(X \rightarrow Y\) for functions between types. We denote the obvious category of sets and functions by \(\mathsf {hSet}\) as well; consequently, \(F : A \rightarrow \mathsf {hSet}\) denotes a type family, while \(F : \mathcal {C}\Rightarrow \mathsf {hSet}\) denotes a functor. For such a functor \(F : \mathcal {C}\Rightarrow \mathsf {hSet}\), we write Open image in new window for the category of elements of F, whose objects are pairs (X, x) of an object X in \(\mathcal {C}\) and an element x : FX. For a function \(f : X \rightarrow Y\) and z, w : X, we write \(\mathsf {ap}\;f\; : z = w \rightarrow f(z) = f(w)\) for the usual “action of a function to paths”, \({}^{1} : x = y \rightarrow y = x\) for “path reversal”, and Open image in new window for “path concatenation” [34, Lemmas 2.2.1, 2.1.1, 2.1.2].
2 Sorts
Single inductive (and quotient inductive) sets are simply elements of \(\mathsf {hSet}\). Inductive families [17] indexed over some fixed type A are families \(A \rightarrow \mathsf {hSet}\). For the inductiveinductive definitions we are considering, the situation is more complicated, since we allow very general dependency structures. Our only requirement is that there is no looping dependency, since this is easily seen to lead to contradictions, e.g. we do not allow the definition of a family \(A : B \rightarrow \mathsf {hSet}\) mutually with a family \(B : A \rightarrow \mathsf {hSet}\) (whatever this would mean). Concretely, we will ensure that the collection of type formation rules (the type signatures) is given in a valid order, and we refer to the types used as family indices as the sorts of the definition. Hence our first step towards a specification of general QIITs is to explain what a valid specification of the sorts is.
Sorts do not only determine the formation rules of the inductive definitions, but also the types of the eliminators. To capture this, it is not enough to specify a type of sorts — in order to take the shape of the elimination rules into account, we need to specify a category.
Definition 3

objects are pairs (X, P), where X is an object in \(\mathcal {C}_i\), and \(P : H_i(X) \rightarrow \mathsf {hSet}\) is a family of sets;

a morphism \((f, g) : (X,P) \rightarrow (Y,Q)\) consists of a morphism \({f : X \rightarrow Y}\) in \(\mathcal {C}_i\), and a dependent function \(g : (x : H_i(X)) \rightarrow P(x) \rightarrow Q(H_i(f)\, x)\) (in \(\mathsf {hSet}\)).
We say that \(\mathcal {C}_n\) is the base category for the sort signature \(H_0, \ldots , H_{n1}\).
The following examples will hopefully make clear the connection between the specification in Definition 3 and common classes of data types.
Example 4
(Permutable trees). For a single inductive type such as the type of trees T(A) in Example 1, the sorts are specified by a single functor \(H_0 : \mathcal {C}_0 \Rightarrow \mathsf {hSet}\) which maps the single object \(\star \) of \(\mathcal {C}_0\) to the unit type \(\mathbf {1}\). Objects in the base category \(\mathcal {C}_1\) are thus pairs \((\star , W)\), where \(W : \mathbf {1}\rightarrow \mathsf {hSet}\), and morphisms are given by \(f : \star \rightarrow \star \) in \(\mathbbm {1}\) (necessarily the identity morphism), together with a dependent function \(g : (x : \mathbf {1}) \rightarrow W(x) \rightarrow V(x)\). It is easy to see that this category \(\mathcal {C}_1\) is equivalent to the category \(\mathsf {hSet}\).
Example 5
(The finite types). Consider the inductive family \(\mathsf {Fin} : \mathbb {N}\rightarrow \mathsf {hSet}\) of finite types. Again, this is a single type family, i.e. we are in the case \(n \equiv 1\). We have Open image in new window , and the base category \(\mathcal {C}_1\) is equivalent to the category of \(\mathbb {N}\)indexed families, where objects are families \(X : \mathbb {N}\rightarrow \mathsf {hSet}\) and morphisms \(\mathcal {C}_1(X,Y)\) are dependent functions \(f : (n : \mathbb {N}) \rightarrow X(n) \rightarrow Y(n)\).
Example 6
(Contexts and types). Let us consider the QIIT \((\mathsf {Con}, \mathsf {Ty})\) from Example 2. Here, we need two functors \(H_0\), \(H_1\), the first corresponding to \(\mathsf {Con}\) and the second to \(\mathsf {Ty}\). The first is given by Open image in new window as in Example 4, since \(\mathsf {Con}\) is a type on its own. Next, we need \(H_1 : \mathcal {C}_1 \Rightarrow \mathsf {hSet}\). Applying the equivalence between \(\mathcal {C}_1\) and \(\mathsf {hSet}\) established in Example 4, we define \(H_1\) to be the identity functor Open image in new window , since then \(\mathsf {Ty}: H_1(\mathsf {Con}) \rightarrow \mathsf {hSet}\). The base category \(\mathcal {C}_2\) is equivalent to the category \(\mathsf {Fam}(\mathsf {hSet})\), whose objects are pairs (A, B) where \(A : \mathsf {hSet}\) and \(B : A \rightarrow \mathsf {hSet}\), and whose morphisms (A, B) to \((A', B')\) consist of functions \(f : A \rightarrow A'\) together with dependent functions \(g : (x:A) \rightarrow B(x) \rightarrow B'(f \, x)\).
Example 7
(the Cauchy reals). Recall that the Cauchy reals in the HoTT book [34] are constructed by simultaneously defining \(\mathbb {R}: \mathsf {hSet}\) and \(\sim : \mathbb {R}\times \mathbb {R}\rightarrow \mathsf {hSet}\) (we ignore the fact that [34] uses \(\mathcal {U}\) instead of \(\mathsf {hSet}\)). This time the sorts \(H_0, H_1\) are given by Open image in new window and Open image in new window , corresponding to the fact that \(\sim \) is a binary relation on \(\mathbb {R}\). The base category has (up to equivalence) pairs (X, Y) with \(Y : X \times X \rightarrow \mathsf {hSet}\) as objects, and morphisms are defined accordingly.
Example 8
Remark 9
Although we work in type theory also in the metatheory, we give the presentation informally in natural language. Formally, the specification of sorts and base categories of Definition 3 can be defined as an inductiverecursive definition [19] of the list \(H_0, \ldots , H_n\) simultaneously with a function that turns such a list into a category. Details can be found in Dijkstra’s thesis [16, Sect. 4.3].
The main result of this section states that base categories of sort signatures are complete, i.e. have all small limits. By a small limit, we mean a limit of a diagram \(D : \mathcal {I}\rightarrow \mathcal {C}\), where the shape category \(\mathcal {I}\) has a set of objects, and the collection of morphisms between any two objects is a set. This result will be needed later to show that categories of QIIT algebras are complete. Recall that \(\mathsf {hSet}\) has all small limits by a standard construction.
Theorem 10
(Base categories are complete). For any sort signature \(H_0,\) \(\ldots ,\) \(H_{n1}\), the corresponding base category \(\mathcal {C}_n\) has all small limits.
Proof
All proofs can be found in the arXiv version of the paper [3]. \(\square \)
3 Algebras
Once the sorts of an inductive definition have been established, the next step is to specify the constructors. In this section, we will give a very general definition of constructor specifications, although we will mainly focus on two specific kinds: point constructors, which can be thought of as the operations of an algebraic signature, and path constructors, which correspond to the axioms.

we start with \(\mathsf {hSet}\) as our base category (only one trivial sort, as in Example 4);

we add a point constructor for the constant corresponding to 0; the category of algebras at this stage is the category of pointed sets;

we add a second point constructor for the operation corresponding to \(\mathsf {suc}\); the category of algebras at this stage is the category of sets equipped with a point and a unary operation;

the set of natural numbers, together with its usual structure, can now be regarded as an initial object in the category of algebras just constructed.
3.1 Relative Continuity and Constructor Specifications
Roughly speaking, constructors at each stage are given by pairs of \(\mathsf {hSet}\)valued functors F and G on \(\mathcal {C}\), where G is continuous (i.e. preserves all small limits). The intuition is that F specifies the arguments of the constructor, while G determines its target. For instance, in the example of the natural numbers when specifying the constructor \(\mathsf {suc} : \mathbb {N}\rightarrow \mathbb {N}\), \(\mathcal {C}\) is the category of pointed sets, and both F and G are the forgetful functor to \(\mathsf {hSet}\). The continuity condition on G is needed for the corresponding category of algebras to be complete. Intuitively, this expresses that a constructor should only “construct” elements of one of the sorts, or equalities thereof.^{1} In particular, a constant functor is usually not a valid choice for G.
Unfortunately, this simple description falls short of capturing many of the examples of QIITs mentioned in Sect. 1. The problem is that we want G to be able to depend on the elements of F. However, since F is assumed to be an arbitrary functor, its category of elements is not necessarily complete, and so we need to refine the notion of G being continuous to this case.
Definition 11
(Relative continuity). Let \(\mathcal {C}\) be a category, \(\mathcal {C}_0\) a complete category, and \(U : \mathcal {C}\Rightarrow \mathcal {C}_0\) a functor. If I is a small category, and \(X : I \rightarrow \mathcal {C}\) is a diagram, we say that a cone \(A \rightarrow X\) in \(\mathcal {C}\) is a Ulimit cone, or limit cone relative to U, if the induced cone \(UA \rightarrow UX\) is a limit cone in \(\mathcal {C}_0\). A functor \(\mathcal {C}\Rightarrow \mathsf {hSet}\) is continuous relative to U if it maps Ulimit cones to limit cones in \(\mathsf {hSet}\).
In the special case \(\mathcal {C}_0 \equiv \mathsf {hSet}\), the functor U in Definition 11 is continuous relative to itself. Also note that if \(\mathcal {C}\) is complete and U creates limits, then relative continuity with respect to U reduces to ordinary continuity. If \(\mathcal {C}\) is a complete category, and \(F : \mathcal {C}\Rightarrow \mathsf {hSet}\) is an arbitrary functor, the category Open image in new window of elements of F is equipped with a forgetful functor into \(\mathcal {C}\). We will implicitly consider relative limit cones and relative continuity with respect to this forgetful functor, unless specified otherwise. Note that if \(\mathcal {C}\) is complete and F is continuous, then Open image in new window is also complete, and relative continuity of functors on Open image in new window is the same as continuity, as observed above.
We can now give a precise definition of what is needed to specify a constructor:
Definition 12

a functor \(F : \mathcal {C}\Rightarrow \mathsf {hSet}\), called the argument functor of the specification;

a relatively continuous functor Open image in new window , called the target functor.
Given a constructor specification, we can define the corresponding category of algebras. In Theorem 25, we will see that the assumptions of Definition 12 guarantee that this category is complete.
Definition 13

objects are pairs \((X, \theta )\), where X is an object of \(\mathcal {C}\), and \(\theta : (x : F X) \rightarrow G(X, x)\) is a dependent function (in \(\mathsf {hSet}\));
 morphisms \((X, \theta ) \rightarrow (Y, \psi )\) are given by morphisms \(f : X \rightarrow Y\) in \(\mathcal {C}\), with the property that for all x : FX,where \(\overline{f} : (X, x) \rightarrow (Y, F(f)\,x)\) is the morphism in Open image in new window determined by f.$$\begin{aligned} \psi (F(f)\,x) = G(\overline{f}) (\theta \,x), \end{aligned}$$
We think of \(\mathcal {C}.(F,G)\) as a category of “dependent dialgebras” [20]. Note that there is an obvious forgetful functor \(\mathcal {C}.(F,G) \rightarrow \mathcal {C}\).
Similarly to how we defined sort specifications (Definition 3), we now have all the necessary notions in place to be able to give the full definition of a QIIT.
Definition 14

a sort specification \(H_0, \ldots , H_{n1}\);

a list of constructor specifications \((F_0, G_0), \ldots , (F_{n1}, G_{n1})\) on \(\mathcal {B}_0, \ldots , \mathcal {B}_{n1}\) respectively, where \(\mathcal {B}_0\) is the base category of the given sort specification, and \(\mathcal {B}_{i+1}\) is the category of algebras of \((F_i, G_i)\).
For Definition 14 to make sense, the categories \(\mathcal {B}_i\) need to be complete, since constructor specifications are only defined on complete categories. This will follow from Theorem 25.
Example 15
The corresponding category of algebras for this constructor specification \((F_1, G_1)\) for \(\mathsf {node}\) is equivalent to the category whose objects are triples (X, l, n) where \(X : \mathsf {hSet}\), l : A, and \(n : (A \rightarrow X) \rightarrow X\). After specifying also the \(\mathsf {mix}\)constructor, the new category of algebras further contains a dependent function \(p : (f : A \rightarrow X) \rightarrow (e : X \cong X) \rightarrow n(f) = n(f \circ e)\).
Example 16
3.2 Point Constructors
If \(\mathcal {C}\) is the base category for a sort signature as in Definition 3, we can define specific target functors \(\mathcal {C}\Rightarrow \mathsf {hSet}\) which are guaranteed to be relatively continuous. Constructors having those as targets are referred to as point constructors. Intuitively, a point constructor is an operation that returns an element (point) of one of the sorts. The corresponding target functor is the forgetful functor that projects out the chosen sort. However, sorts can be dependent, so such a projection needs to be defined on a category of elements.
Example 17
(Permutable trees). In Example 15, the functor Open image in new window specifying the target of \(\mathsf {leaf}\) is the composition of the forgetful Open image in new window with the base target functor for the only sort, in this case the identity \(\mathsf {id}: \mathsf {hSet}\Rightarrow \mathsf {hSet}\).
Note that \(U_H = \mathsf {id}\) in Example 17 is relatively continuous, as required by Definition 12. In the rest of this section, we will show that this is true in general. Given a category \(\mathcal {C}\) and a functor \(F : \mathcal {C}\Rightarrow \mathsf {hSet}\), it is well known that the slice category over F of the functor category \(\mathcal {C}\Rightarrow \mathsf {hSet}\) is equivalent to the functor category Open image in new window (see for example [24, Proposition 1.1.7]). Given a functor \(G : \mathcal {C}\Rightarrow \mathsf {hSet}\) and a natural transformation \(\alpha : G \rightarrow F\), we will refer to the functor Open image in new window corresponding to \(\alpha \) as the functor of fibres of \(\alpha \). Concretely, \(\overline{G}\) maps an object (X, x), where x : FX, to the fibre of \(\alpha _X\) over x. The following theorem is proved by noting that \(U_H\) is a functor of fibres.
Theorem 18
(Base target functors are relatively continuous). Let \(\mathcal {C}\) be a complete category, \(H : \mathcal {C}\Rightarrow \mathsf {hSet}\) any functor, and \(\mathcal {C}'\) the extended base category corresponding to H. Then the base target functor \(U_H\) is relatively continuous. \(\square \)
3.3 Reindexing Target Functors
Lemma 19
(Preservation of relative limit cones). Suppose given is a commutative diagram of categories and functors as shown on the right, where \(\mathcal {C}_0\) and \(\mathcal {D}_0\) are complete, and G maps Ulimit cones to Vlimit cones. Then F maps \((U \circ U')\)limit cones to \((V \circ V')\)limit cones. In particular, if \(\mathcal {C}\) and \(\mathcal {D}\) are complete and G is continuous, then F preserves relative limit cones. \(\square \)
Example 20
Starting from the situation in (1) we can form the diagram shown on the left, where \(V : \mathcal {C}\Rightarrow \mathsf {Fam}(\mathsf {hSet})\) is the forgetful functor and hence continuous. It follows from the second statement of Lemma 19 that S preserves relative limit cones, hence \(G = U_H \circ S\) is relatively continuous by Theorem 18.
3.4 Path Constructors
Definition 21
Let Open image in new window be the functor defined on objects by Open image in new window and on morphisms by Open image in new window .
It is not hard to see that \(\mathsf {Eq}\) is a functor. Furthermore, \(\mathsf {Eq}\) is the functor of fibres of the obvious diagonal natural transformation \(\varDelta : \mathsf {id}\rightarrow \mathsf {id}\times \mathsf {id}\).
Lemma 22
The standard equality functor \(\mathsf {Eq}\) is relatively continuous. \(\square \)
The lemma we have just given is central to the observation that a large class of equality functors are suitable targets for constructors:
Theorem 23
Example 24
(Permutable trees). The target of the \(\mathsf {mix}\) constructor from Example 1 can be obtained as an equality functor in this sense. We take G to be the underlying sort, which is relatively continuous by the results of the previous section. The global elements l and r are defined by Open image in new window and Open image in new window . Their naturality can easily be verified directly.
Iterating equality functors, one can also express higher path constructors, but in our limited setting of inductively defined sets, there is little reason to go beyond one level of path constructors — higher ones will have no effect on the resulting inductive type. However, we believe that the ease with which Theorem 23 can be applied iteratively will be an important feature when generalising our technique to general higher inductive types. We discuss this further in Sect. 5.
3.5 Categories of Algebras are Complete
Recall from Definition 13 that the category of algebras \(\mathcal {C}.(F,G)\) for a constructor specification (F, G) on a complete category \(\mathcal {C}\) has “dependent (F, G)dialgebras” as objects, and maps that commute with the dialgebra structure as morphisms. In this section, we will show that \(\mathcal {C}.(F,G)\) is complete, and that its forgetful functor is continuous. The significance of this result is twofold: First of all, it enables the use of limits when reasoning about algebras; in particular, we will show in Sect. 4 how, using products and equalisers, one can extend the classical equivalence between initiality and induction for ordinary inductive types to our setting. Secondly, it goes a long way towards establishing existence of initial algebras; since a category of algebras over \(n + 1\) constructors is complete, and the forgetful functor to the category of algebras over the first n preserves limits, the adjoint functor theorem says that this functor has a left adjoint if and only if it satisfies the solution set condition. Applying this argument at every stage, we get a left adjoint for the forgetful functor down to \(\mathsf {hSet}\), and in particular an initial object. There is no reason to expect the solution set condition to hold at this generality, but we expect it to follow from appropriate “accessibility” conditions on the argument functors. This is discussed further in Sect. 5.
Theorem 25
(Categories of algebras are complete). Let (F, G) be a constructor specification on a complete category \(\mathcal {C}\). Then \(\mathcal {C}.(F,G)\) is complete. \(\square \)
4 Elimination Principles
So far, we have given rules for specifying a QIIT by giving a sort signature and a list of constructors. As typetheoretical rules, these correspond to the formation and introduction rules for the QIIT. In this section, we introduce the corresponding elimination rules, stating that a QIIT is the smallest type closed under its constructors. We show that a categorical formulation of the elimination rules is equivalent to the universal property of initiality.
4.1 The Section Induction Principle
The elimination principle for an algebra \(X\) states that every fibred algebra over \(X\) has a section, where a fibred algebra over \(X\) is an algebra family “\(Q : X \rightarrow \mathsf {hSet}\)”, and a section of it a dependent algebra morphism “\((x : X) \rightarrow Q(x)\)”.^{2} The usual correspondence between type families and fibrations extends to algebras, and so we formulate the elimination rule for \(X\) as \(X\) being section inductive in the category of algebras in the following sense:
Definition 26
(Section inductive). An object X of a category \(\mathcal {C}\) is section inductive if for every object Y of \(\mathcal {C}\) and morphism \(p : Y \rightarrow X\), there exists \(s : X \rightarrow Y\) such that \(p \circ s = \mathsf {id}_X\).
For an algebra \(X\), the existence of the underlying function(s) \(X \rightarrow Y\) corresponds to the elimination rules, while the fact that they are algebra morphisms corresponds to the computation rules.
Example 27
Example 28
A general account of the equivalence between the usual formulation of the elimination rules and the section induction principle is in Dijkstra [16, Sect. 5.4].
4.2 Initiality, and its Relation to the Section Induction Principle
The section induction principle for an algebra \(X\) matches our intuitive understanding of the elimination rules for \(X\) quite well, but it is perhaps a priori not so clear that e.g. satisfying it defines an algebra uniquely up to equivalence. In this section, we show that this is the case by proving that the section induction principle is equivalent to the categorical property of initiality. Recall that a type is contractible if it is equivalent to the unit type [34, Definition 3.11.1].
Definition 29
(Initiality). An object X of a category \(\mathcal {C}\) is (homotopy) initial if for every object Y of \(\mathcal {C}\), the set of morphisms \(X \rightarrow Y\) is contractible.
It is easy to see that initiality implies section induction, while the converse requires additional structure on \(\mathcal {C}\):
Lemma 30
If an object X in a category \(\mathcal {C}\) is initial, then it is section inductive. If \(\mathcal {C}\) has finite limits and X is section inductive, then X is initial. \(\square \)
From here, we can show the main theorem of the current section. The proof uses the fact that both statements involved are mere propositions, i.e. they have at most one proof.
Theorem 31
(Initiality \(\cong \) section induction). An object X in a in a category of algebras \(\mathcal {C}.(F,G)\) being initial is equivalent to it being section inductive. \(\square \)
As an application, we can now reason about QIITs using their categories of algebras. For instance, we get a short proof of the following fact:
Corollary 32
The interval is equivalent to the unit type.
Proof
By Theorem 31, the interval is the initial object in the category with objects \(\varSigma (X : \mathsf {hSet}).\varSigma (x : X).\varSigma (y : X).x =_{X} y\), while the unit type is the initial object in the category with objects \(\varSigma (X : \mathsf {hSet}).X\). By contractibility of singleton types [34, Lemma 3.11.8], the former is equivalent to the latter, and since initiality is a universal property, the two initial objects coincide up to equivalence. \(\square \)
5 Conclusions and Further Work
We have developed a semantic framework for QIITs: A QIIT description gives rise to a category of algebras, and the initial object of this category represent the types and constructors of the QIIT. This generalises the usual functorial semantics of inductive types to a more general setting. So far we have verified the appropriateness of this setting by means of examples. In future work, we would like to explicitly relate the syntax of QIITs to the corresponding semantics.
Our categories of algebras are complete. This is helpful for the metatheory of QIITs, as demonstrated by the proof of initiality being equivalent to section induction (Theorem 31), justifying elimination principles. Of course, completeness is not by itself sufficient to derive the existence of initial algebras, but it suggests that it should be possible to restrict the argument functors to guarantee this, possibly by reducing QIITs to a basic type former playing an analogous role to that of Wtypes for inductive types. We believe that completeness of the categories of algebras allows an existence proof using the adjoint functor theorem.
We have restricted our attention to QIITs, but we believe that our construction is applicable to general HITs (and even HIITs). While at first glance such an extension of our framework seems to require an internal theory of \((\infty ,1)\)categories, we believe that it is enough to keep track of only a very limited number of coherence conditions, making this extension possible even without solving the wellknown problem of specifying an infinite tower of coherences in HoTT.
Other possible future directions include the combination of QIITs and inductionrecursion, and the possibility of generalising coinductive types along similar lines. These generalisations should be driven by examples, similar to how the examples discussed in the current paper have motivated the need for a theory of QIITs.
Footnotes
 1.
More concretely, elements of a sort correspond to representable functors for algebras over a single generator for that sort, while equalities correspond to algebras with no generators and the given equality as the only relation. Clearly, representable functors are continuous, and the converse holds for reasonable functors (e.g. accessible ones). However, we do not attempt to make this construction precise here, and the following results do not depend on it.
 2.
See Dijkstra’s thesis [16, Sect. 5.4] for the general definition of fibred algebras and their morphisms — here we restrict ourselves to examples only for space reasons.
Notes
Acknowledgements
We thank Ambrus Kaposi and Jakob von Raumer for many interesting discussions, and the anonymous referees for their valuable comments. This research was supported by EPSRC grants EP/M016994/1 and EP/K023837/1, as well as AFOSR award FA95501610029.
References
 1.Altenkirch, T., Kaposi, A.: Type theory in type theory using quotient inductive types. In: Principles of Programming Languages, pp. 18–29. ACM (2016)Google Scholar
 2.Altenkirch, T., Danielsson, N.A., Kraus, N.: Partiality, revisited. In: Esparza, J., Murawski, A.S. (eds.) FoSSaCS 2017. LNCS, vol. 10203, pp. 534–549. Springer, Heidelberg (2017). https://doi.org/10.1007/9783662544587_31CrossRefGoogle Scholar
 3.Altenkirch, T., Capriotti, P., Dijkstra, G., Kraus, N., Nordvall Forsberg, F.: Quotient inductiveinductive types (2018). arXiv:1612.02346
 4.Angiuli, C., Morehouse, E., Licata, D.R., Harper, R.: Homotopical patch theory. In: International Conference on Functional Programming, pp. 243–256 (2014)Google Scholar
 5.Awodey, S., Warren, M.A.: Homotopy theoretic models of identity types. Math. Proc. Camb. Philos. Soc. 146(1), 45–55 (2009)MathSciNetCrossRefGoogle Scholar
 6.Basold, H., Geuvers, H., van der Weide, N.: Higher inductive types in programming. J. Univ. Comput. Sci. 23(1), 63–88 (2016)MathSciNetGoogle Scholar
 7.Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. Springer, Heidelberg (2004). https://doi.org/10.1007/9783662079645
 8.Brady, E.: Idris, a generalpurpose dependently typed programming language: design and implementation. J. Funct. Program. 23(9), pp. 552–593 (2013)MathSciNetCrossRefGoogle Scholar
 9.Brunerie, G.: On the homotopy groups of spheres in homotopy type theory. Ph.D. thesis, Université de Nice (2016)Google Scholar
 10.Buchholtz, U., Rijke, E.: The real projective spaces in homotopy type theory. In: Logic in Computer Science, pp. 1–8 (2017)Google Scholar
 11.Cavallo, E.: Synthetic cohomology in Homotopy Type Theory. Master’s thesis, CarnegieMellon University (2015)Google Scholar
 12.Chapman, J., Uustalu, T., Veltri, N.: Quotienting the delay monad by weak bisimilarity. In: Leucker, M., Rueda, C., Valencia, F.D. (eds.) ICTAC 2015. LNCS, vol. 9399, pp. 110–125. Springer, Cham (2015). https://doi.org/10.1007/9783319251509_8CrossRefGoogle Scholar
 13.Chapman, J., Uustalu, T., Veltri, N.: Quotienting the delay monad by weak bisimilarity. Math. Struct. Comput. Sci. 1–26 (2017)Google Scholar
 14.de Moura, L., Kong, S., Avigad, J., van Doorn, F., von Raumer, J.: The Lean theorem prover. In: Conference on Automated Deduction (2015)Google Scholar
 15.Diaconescu, R.: Axiom of choice and complementation. Proc. Am. Math. Soc. 51(1), 176–178 (1975)MathSciNetCrossRefGoogle Scholar
 16.Dijkstra, G.: Quotient inductiveinductive types. Ph.D. thesis, University of Nottingham (2017)Google Scholar
 17.Dybjer, P.: Inductive families. Formal Aspects Comput. 6(4), 440–465 (1994)CrossRefGoogle Scholar
 18.Dybjer, P., Moeneclaey, H.: Finitary higher inductive types in the groupoid model. In: Silva, A. (ed.) Mathematical Foundations of Programming Semantics (2017)Google Scholar
 19.Dybjer, P., Setzer, A.: A finite axiomatization of inductiverecursive definitions. In: Girard, J.Y. (ed.) TLCA 1999. LNCS, vol. 1581, pp. 129–146. Springer, Heidelberg (1999). https://doi.org/10.1007/3540489592_11CrossRefGoogle Scholar
 20.Hagino, T.: A categorical programming language. Ph.D. thesis, University of Edinburgh (1987)Google Scholar
 21.Harper, R., Pollack, R.: Type checking with universes. Theor. Comput. Sci. 89(1), 107–136 (1991)MathSciNetCrossRefGoogle Scholar
 22.Hofmann, M., Streicher, T.: The groupoid interpretation of type theory. In: TwentyFive Years of Constructive Type Theory of Oxford Logic Guides, vol. 36. Oxford University Press, New York, pp. 83–111 (1998)Google Scholar
 23.Hou (Favonia), K.B., Finster, E., Licata, D.R., Lumsdaine, P.L.: A mechanization of the BlakersMassey connectivity theorem in homotopy type theory. In: Logic in Computer Science (2016)Google Scholar
 24.Johnstone, P.: Sketches of an Elephant: A Topos Theory Compendium. Oxford University Press, New York (2002)zbMATHGoogle Scholar
 25.Kapulkin, C., Lumsdaine, P.L.: The simplicial model of univalent foundations (after Voevodsky) (2016). arXiv:1211.2851
 26.Licata, D.R., Finster, E.: EilenbergMaclane spaces in homotopy type theory. In: Logic in Computer Science, pp. 66:1–66:9 (2014)Google Scholar
 27.Licata, D.R., Shulman, M.: Calculating the fundamental group of the circle in homotopy type theory. In: Logic in Computer Science, pp. 223–232 (2013)Google Scholar
 28.Lumsdaine, P.L., Shulman, M.: Semantics of higher inductive types (2017). arXiv:1705.07088
 29.MartinLöf, P.: An intuitionistic theory of types. Published in TwentyFive Years of Constructive Type Theory (1972)Google Scholar
 30.Nordvall Forsberg, F.: Inductiveinductive definitions. Ph.D. thesis, Swansea University (2013)Google Scholar
 31.Norell, U.: Towards a practical programming language based on dependent type theory. Ph.D. thesis, Chalmers University of Technology (2007)Google Scholar
 32.Shulman, M.: Homotopy type theory: the logic of space. In: New Spaces for Mathematics and Physics (2017, to appear). arXiv:1703.03007
 33.Sojakova, K.: Higher inductive types as homotopyinitial algebras. In: Principles of Programming Languages, pp. 31–42. ACM (2015)Google Scholar
 34.The Univalent Foundations Program. Homotopy Type Theory: Univalent Foundations of Mathematics, Institute for Advanced Study (2013). https://homotopytypetheory.org/book
 35.Veltri, N.: A typetheoretical study of nontermination. Ph.D. thesis, Tallinn University of Technology (2017)Google Scholar
 36.Voevodsky, V.: The equivalence axiom and univalent models of type theory (talk at CMU on February 4, 2010). arXiv:1402.5556
Copyright information
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made. The images or other third party material in this book are included in the book's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the book's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.