Abstract
Inductiveinductive types are a joint generalization of mutual inductive types and indexed inductive types. In extensional type theory, inductiveinductive types can be constructed from inductive types, and this construction has been conjectured to work in intensional type theory as well. In this paper, we show that the existing construction requires Uniqueness of Identity Proofs, and present a new construction (which we conjecture generalizes) of one particular inductiveinductive type in cubical type theory, which is compatible with homotopy type theory.
You have full access to this open access chapter, Download conference paper PDF
Similar content being viewed by others
1 Introduction
Inductiveinductive types allow for the mutual inductive definition of a type and a family over that type. As an example, we can simultaneously define contexts and types defined in a context, with dependently typed context extension:
Such definitions have been used for example by Danielsson [9] and Chapman [5] to define intrinsically typed syntax of a dependent type theory, and Agda supports such definitions natively.
These types have been studied extensively in Nordvall Forsberg [15]. There, in §5.3, inductiveinductive types with simple elimination rules (defined in op. cit. §3.2.5) are constructed from indexed inductive types in extensional type theory, and in §5.4 this is conjectured to work in intensional type theory as well.
In this paper, we first show that this construction does not work in intensional type theory without assuming Uniqueness of Identity Proofs (UIP), which is incompatible with the Univalence axiom of Homotopy Type Theory [18]. We then give an alternate construction in cubical type theory [6], which is compatible with Univalence. Specifically, this paper makes the following contributions:^{Footnote 1}

1.
In Sect. 2, we show that, in intensional type theory, if the types constructed by Nordvall Forsberg satisfy the simple elimination rules, then UIP holds (formalized in both Coq and Agda).

2.
In Sect. 3, we give the construction of a particular inductiveinductive type with simple elimination rules in cubical type theory (formalized in cubical Agda).
1.1 Syntax and Conventions
We mostly mimic Agda syntax. The double bar symbol \(=\) is used for definitions directly and by pattern matching, and for equality of terms up to conversion. We write \((a : A) \rightarrow B\) for the dependent product type, and \(A \rightarrow B\) for the nondependent version. Functions are given by pattern matching \(f\; x = y\) or by lambda expressions \(f = \lambda x.y\). Similarly \((a : A) \times B\) is the dependent pair type, and \(A \times B\) the nondependent version. Pairs are (a, b), and projections are p.1 and p.2. The unit type is \(\top \), with unique inhabitant \(\star \). Identity types are \({x}\equiv _{X}{y}\) for the type of identifications of x with y in type X, and we write \(\texttt {refl}\) for a proof of reflexivity. We do not assume that axiom K holds for identity types. We write Type for a universe of types (where Agda uses \(\text {Set}\)). In Sect. 3 we work in cubical type theory, which will be explained there.
1.2 Running Example of an InductiveInductive Definition
For the purposes of this paper, we will focus on one relatively simple inductiveinductive definition (with only 5 clauses), parametrized by a type X, which is given in Fig. 1. We will use this definition to prove that Nordvall Forsberg’s construction implies UIP in Sect. 2 and as a running example to demonstrate our construction in cubical type theory in Sect. 3.
Our example starts with the simplest inductiveinductive sorts, taking \(A :\,\text {Type}\) and \(B : A \rightarrow \,\text {Type}\), and then populates A and B with simple constructors which suffice for our proof of UIP. We have \(\texttt {inj}\), which is supposed to give exactly one element of each \(B\;a\), while \(\texttt {ext}\) lets us mix Bs back into the As (mirroring the type of context extension), and \(\eta \) gives us something to start with: one element of A for each element of X (following the use of \(\eta \) in [15, Example 3.3]). The proof of UIP in Sect. 2 proceeds by considering the type \(B\;(\texttt {ext}\;(\eta \;x)\;(\texttt {inj}\;(\eta \;x))\) for some x : X, and noticing that, while the simple elimination rules tell us that there should only be one element of this type (given by \(\texttt {inj}\)), in Nordvall Forsberg’s construction there are actually as many as there are proofs of \({x}\equiv _{X}{x}\).
Our goal in this paper is to construct \((A,B,\eta ,\texttt {ext},\texttt {inj})\) of the types given in Fig. 1 such that the simple elimination rules hold without using UIP. But first, we will show why Nordvall Forsberg’s approach is not sufficient.
2 Deriving UIP
Uniqueness of Identity proofs (UIP) for a type X is the principle that, for all x : X, y : X, \(p : {x}\equiv _{X}{y}\), \(q : {x}\equiv _{X}{y}\), the type \({p}\equiv _{{x}\equiv _{X}{y}}{q}\) is inhabited. Equivalently, for all x : X, \(p : {x}\equiv _{X}{x}\), the type \({p}\equiv _{{x}\equiv _{X}{x}}{\texttt {refl}}\) is inhabited. It expresses that there is at most one proof of any equality. UIP is independent of standard intensional type theory [13], and is inconsistent with Homotopy Type Theory [18].
Nordvall Forsberg’s construction of inductiveinductive types is described in [15, §5.3]. In this section, we show that if the simple elimination rules hold for this construction of the inductiveinductive type in Fig. 1, then UIP holds for the type X (Theorem 1). This argument has been formalized in both Coq version 8.8.0 [8] (see UIP_from_Forsberg_II.v) and Agda using the –withoutK flag (see UIP_from_Forsberg_II.agda).
To recap, Nordvall Forsberg [15, §5.3] constructs an inductiveinductive type by first defining an approximation (the presyntax) which drops the A index from B leaving a mutual inductive definition. Concretely, we have \({A}_\text {pre}\) and \({B}_\text {pre}\) defined as in Fig. 2. Then a mutual indexed inductive definition is used to define the index relationship between \({A}_\text {pre}\) and \({B}_\text {pre}\); these are the goodness predicates \({A}_\text {good}\) and \({B}_\text {good}\). Finally, the inductive object \((A, B, \eta , \texttt {ext}, \texttt {inj})\) is defined by pairing the presyntax with goodness proofs (see Fig. 3).
In extensional type theory, Nordvall Forsberg proved that \({A}_\text {good}\;a\) is a mere proposition (all inhabitants are equal) [15, Lemma 5.37(ii)]. In intensional type theory as well, if function extensionality and UIP hold then \({A}_\text {good}\) is a mere proposition. This uniqueness of goodness proofs justifies having the definition of B ignore the goodness proof \({a}_\text {good}\), since \({a}_\text {good}\) can have at most one value.
In the next two subsections, we prove that:

1.
If \({A}_\text {good}\;a\) is a mere proposition then UIP holds for the type X (Lemma 2).

2.
If the simple elimination rules from Fig. 1 hold for the \((A, B, \eta , \texttt {inj}, \texttt {ext})\) constructed above then \({A}_\text {good}\;a\) is a mere proposition (Lemma 5).
Combining these results, we conclude that Nordvall Forsberg’s construction satisfies the simple elimination rules in intensional type theory only if UIP holds (Theorem 1).
2.1 Unique Goodness Implies UIP
We define notation \((x == y)\) to mean the term
We first prove that there are at least as many proofs of \({A}_\text {good}\;(x == y)\) as there are of \({x}\equiv _{X}{y}\).
Lemma 1
(\({x}\equiv _{X}{y}\) is a retract of \({\varvec{A}}_\mathbf{good}\)). For all x : X and y : X, there are functions
such that for all \(e : {x}\equiv _{X}{y}\), \({g\;(f\;e)}\equiv {e}\).
Proof
To define f, we let \(f\;\texttt {refl}=\)
To define g, pattern matching on \({a}_\text {good}\) has only one possibility: \({a}_\text {good} = \)
forcing y to be x, and in this case \({x}\equiv _{X}{y}\) holds by reflexivity. Then when \(e = \texttt {refl}\), \(f\;e\) returns a proof in the format matched by g, so \({g\;(f\;\texttt {refl})}\equiv {\texttt {refl}}\), and thus \({g\;(f\;e)}\equiv {e}\).
Lemma 2
(Unique goodness implies UIP). If \({A}_\text {good}\;t\) is a mere proposition for all \(t : {A}_\text {pre}\), then UIP holds for the type X.
Proof
Assume goodness proofs are unique, and take x : X, y : X, with \(p : {x}\equiv {y}\), \(q : {x}\equiv {y}\). We want to show that \({p}\equiv {q}\). Using the f and g from Lemma 1,
2.2 Simple Elimination Rules Imply Unique Goodness
Now we prove that there are at least as many proofs of \(B\;({t}_\text {pre},{t}_\text {good})\) as there are of \({A}_\text {good}\;{t}_\text {pre}\).
Lemma 3
(\({\varvec{A}}_\mathbf{good}\) is a retract of B). For all \({t}_\text {pre} : {A}_\text {pre}\) and \({t}_\text {good} : {A}_\text {good}\;{t}_\text {pre}\), there are functions
such that for all \({a}_\text {good} : {A}_\text {good}\;{t}_\text {pre}\), \({g\;(f\;{a}_\text {good})}\equiv {{a}_\text {good}}\).
Proof
We define \(f\;{a}_\text {good} = {\texttt {inj}}_\text {pre}\;{t}_\text {pre}, {\texttt {inj}}_\text {good}\;{t}_\text {pre}\;{a}_\text {good}\). By induction on \({B}_\text {good}\), we define a function
taking
Then we can define \(g\;({b}_\text {pre},{b}_\text {good}) = g'\;{t}_\text {pre}\;{b}_\text {pre}\;{b}_\text {good}\). Then \({g\;(f\;{a}_\text {good})}\equiv {{a}_\text {good}}\) holds by reflexivity.
Lemma 4
(\(B\;a\) is contractible). Assuming the simple elimination rules from Fig. 1 hold for the \((A, B, \eta , \texttt {inj}, \texttt {ext})\) constructed above, for all a : A and \(b : B\;a\), \({\texttt {inj}\;a}\equiv _{B\;a}{b}\).
Proof
Referring to the simple elimination rules given in Fig. 1, we pattern match on B by giving motives \(( PA , PB )\) and methods \((P\eta , P\texttt {ext}, P\texttt {inj})\), and then using the resulting \( EB \).
We set \( PA \;a = \top \), and take \( PB \;a\;b = {\texttt {inj}\;a}\equiv _{B\;a}{b}\). Then we have \(P\eta \;x = \star \), and \(P\texttt {ext}\;a\;\star \;b\;H = \star \), and we take \(P\texttt {inj}\;a\;\star = \texttt {refl}: {\texttt {inj}\;a}\equiv _{B\;a}{\texttt {inj}\;a}\). The conclusion follows by \( EB : (a : A) \rightarrow (b : B\;a) \rightarrow {\texttt {inj}\;a}\equiv _{B\;a}{b}\).
Lemma 5
(Simple elimination rules imply unique goodness). If the simple eliminators hold for the \((A,B,\eta ,\texttt {inj},\texttt {ext})\) constructed above, then for all \(t : {A}_\text {pre}\), \({A}_\text {good}\;t\) is a mere proposition.
Proof
Assume that the simple elimination rules hold, and take \(t : {A}_\text {pre}\), and \(a_1\) and \(a_2\) in \({A}_\text {good}\;t\). We use the definition of f and g from Lemma 3 with \({t}_\text {pre} = t\) and \({t}_\text {good} = a_1\).
By Lemma 4, we know that
Applying g to both sides, and recognizing that \(g\;(\texttt {inj}\;(t,a_1))\) computes to \(a_1\), while \(g\;(f\;a_2)\) computes to \(a_2\) we find that
2.3 Simple Elimination Rules for Nordvall Forsberg’s Construction only if UIP
Theorem 1
If the simple elimination rules hold for Nordvall Forsberg’s construction, then UIP holds for the type X.
Proof
Compose the results of Lemmas 2 and 5.
Therefore Nordvall Forsberg’s approach to constructing inductiveinductive types requires UIP. Since UIP is inconsistent with the Univalence axiom at the center of Homotopy Type Theory (HoTT) [18], we have an incentive to come up with a different construction which is consistent with HoTT.
3 Constructing an InductiveInductive Type in Cubical Type Theory
Cubical type theory [6] is a recently developed type theory which gives a constructive interpretation of the Univalence axiom of Homotopy Type Theory. It has an implementation as a mode for Agda [19], which we use to formalize the construction given in this section of the running example from Fig. 1.
The most important difference between cubical type theory and standard intensional type theory as implemented by Coq or vanilla Agda is that the identity type \({x}\equiv _{X}{y}\) is represented (loosely speaking) by the type of functions p from an interval type \(\mathbb {I}\) with two endpoints \(i_0\) and \(i_1\) to X such that \(p\;i_0\) reduces to x and \(p\;i_1\) reduces to y. This allows, for example, a simple proof of function extensionality: if we have \(A :\,\text {Type}\), \(B : A\rightarrow \,\text {Type}\), f and g functions of type \((a : A) \rightarrow B\;a\), and \(h : (a : A) \rightarrow {f\;a}\equiv {g\;a}\), then we have \((\lambda i.\lambda a.h\;a\;i) : {f}\equiv {g}\). Taking \(\text {cong}\; f = \lambda p. \lambda i. f\; (p\;i) : {x}\equiv {y} \rightarrow {f\;x}\equiv {f\;y}\) and \(\circ \) for function composition, we also have nice properties such as \((\text {cong}\; f) \circ (\text {cong}\; g) = \text {cong}\; (f \circ g)\).
In this section, we construct the running example from Fig. 1, along with the simple elimination rules, in cubical type theory. Our construction proceeds in several steps:

In Sect. 3.1, we approximate by dropping the indices, leaving a standard mutual inductive definition called the presyntax. This is the same as the presyntax given in Fig. 2.

In Sect. 3.2, we define goodness algebras, collections of predicates over the presyntax which define the index relationship (analogously to \({A}_\text {good}\) and \({B}_\text {good}\) from Sect. 2). We also show that a goodness algebra exists, and call it \(\mathbb {O}\).

In Sect. 3.3, we define a predicate nice on goodness algebras, such that if we have a nice goodness algebra, then we can construct the simple elimination rules. Being nice is similar to having proofs of goodness be unique as in Sect. 2.

In Sect. 3.4, we use pattern matching over the presyntax to define a function S from goodness algebras to goodness algebras.

In Sect. 3.5, we define the limit of the sequence
$$\begin{aligned} \mathbb {O}, S\;\mathbb {O}, S\;(S\;\mathbb {O}), \dots , S^n\;\mathbb {O},\dots \end{aligned}$$and show that it is nice. This is the only section that utilizes the differences between cubical type theory and standard intentional type theory.
Given the nice goodness algebra in Sect. 3.5 we can then construct the simple elimination rules by Sect. 3.3. This construction has been formalized in Agda^{Footnote 2} using the –cubical flag which implies –withoutK (see RunningExample.agda).
The intuition for our construction is that the Nordvall Forsberg’s approach of pairing an approximation with goodness predicates can be repeated, and each time the approximation gets better. Using HoTT terminology, we showed in Sect. 2 that one iteration suffices only if X has homotopy level 0 (is a homotopy set, satisfies UIP). In general, \(n+1\) iterations are sufficient if only if X has homotopy level n. The successor goodness algebra defined in Sect. 3.4 is a slightly simplified version of Nordvall Forsberg’s construction, and taking the limit (in Sect. 3.5) gives a construction which works for arbitrary homotopy levels.
3.1 Presyntax
The presyntax is the same as that used in Sect. 2, defined as a mutually inductive type in Fig. 2. The constructors of the presyntax have the same types as the constructors of the full inductiveinductive definition (given in Fig. 1), except we replace \(B\;a\) with \({B}_\text {pre}\) everywhere, ignoring the dependence of B on A.
Consider this as the closest approximation of the target inductiveinductive type by a standard inductive type; the dependence of B on A is the only new element that inductiveinductive definitions add. Of course, this is only an approximation. We can form elements of the presyntax, such as
for \(x \ne y\) that should be excluded from the inductiveinductive formulation, since \(\texttt {inj}\;(\eta \;y) : B\;(\eta \;y)\) while \(\texttt {ext}\;(\eta \;x) : B\;(\eta \;x) \rightarrow A\).
We will use definitions by induction and by patternmatching on the presyntax in sections Sects. 3.3 and 3.4 respectively.
3.2 Goodness Algebras
As we saw in Sect. 3.1, the presyntax is too lenient, and contains terms we want to exclude from the inductiveinductive object. In this section, we define a notion of subalgebra of the presyntax, which we will call a goodness algebra, and explain how to combine a goodness algebra with the presyntax to get an inductiveinductive object \((A, B, \eta , \texttt {ext}, \texttt {inj})\). We also define a goodness algebra \(\mathbb {O}\).
In Fig. 4, for each clause of the inductiveinductive specification, we define 3 things:

1.
For each sort X a type \(\text {Ix}\,X\) giving the data X depends on, and for each operation F constructing an element of sort X, a family \(\text {Arg}\,F : Y \rightarrow \text {Ix}\,X \rightarrow \,\text {Type}\) where Y collects the arguments of the operation in the presyntax, where \(\text {Arg}\,F\;y\;\phi \) gives the data needed to justify that presyntax constructed by \({F}_\text {pre}\) from y has index \(\phi \). In later sections we will also write \(\text {Ix}\,X\;\delta ^G\) and \(\text {Arg}\,F\;\delta ^G\) to specify which goodness algebra we are working in.

2.
The type of the corresponding component in the goodness algebra. For sorts, this is a predicate relating \(\text {Ix}\) and the presyntax, while for the operations, this is a function witnessing that each element of \(\text {Arg}\) gives a goodness proof relating the index \(\phi \) to the presyntax.

3.
A way to combine the goodness algebra with the presyntax to form an inductiveinductive object. For sorts, we pair the presyntax with a goodness proof, while for operations we apply the operation given by the goodness algebra, mimicking the construction in Fig. 3.
Comparing this definition to the construction in Sect. 2, the mutual inductive definition of \({A}_\text {good}\) and \({B}_\text {good}\) (in Fig. 3) has types equivalent to the result of dropping the dependence of \(\delta ^G.B\) on \(\delta ^G.A\) (defined in Fig. 4), going from
The other difference is that we replace the inductive index (call it s) in the conclusion by a fresh variable \(\phi \), with the condition \(s = \phi \) included in \(\text {Arg}\).
3.3 Niceness
In this section, we identify a property niceness that is sufficient for a goodness algebra to produce an inductiveinductive object \((A, B, \eta , \texttt {ext}, \texttt {inj})\) which satisfies the simple elimination rules, as given in Fig. 1.
To define niceness, we use the concept of equivalence, as defined in Univalent Foundations Program [18] (§4.4 Contractible fibers). Given a function \(f : A \rightarrow B\), we write \(\text {isEquiv}\,f\) (leaving A and B implicit) to denote that f is an equivalence between A and B. We will also write \(A \simeq B\) for the type of pairs of a function f with a proof that f is an equivalence.
We will say that a goodness algebra is nice if we have equivalence proofs \((\delta ^N.\eta , \delta ^N.\texttt {ext}, \delta ^N.\texttt {inj})\), with types
Equivalences between types are very close to equalities between types (the Univalence axiom makes this precise). If we have a nice goodness algebra, the combined data looks similar to a recursive definition:
However, the dependence of \(\delta ^G.B\) on \(\delta ^G.A\) makes this what Nordvall Forsberg calls a “recursiverecursive” definition, and so we cannot use the standard eliminator of the presyntax. In Sect. 3.5, we will expend much effort to construct a solution to this system. Once we have done so, the inductiveinductive object produced by the goodness algebra will satisfy the simple elimination rules, as we show in the following lemma.
Lemma 6
(Nice goodness algebras give simple elimination rules). Given a goodness algebra \(\delta ^G\) with proof of niceness \(\delta ^N\), the inductiveinductive object \((A, B, \eta , \texttt {ext}, \texttt {inj})\) produced from \(\delta ^G\) as specified in Sect. 3.2 satisfies the simple induction rules given in Fig. 1.
Proof
The proof is formalized in RunningExample.agda. The main idea of the proof is to induct on the presyntax, and exploit the equivalences provided by niceness \(\delta ^N\). In the \(\texttt {inj}\) case for example, we have a proof of \(\delta ^G.B\;\phi \;({\texttt {inj}}_\text {pre}\;a)\). But without loss of generality, we can replace that goodness proof with \(\delta ^G.\texttt {inj}\) applied to an element of \(\text {Arg}\,\texttt {inj}\;a\;\phi \), which contains both a proof \({a}_\text {good} : \delta ^G.A\;\star \;a\) and a proof that \({(a, {a}_\text {good})}\equiv {\phi }\). Using J to eliminate that equality leaves a goal to which the provided simple induction step for \(\texttt {inj}\) applies. This proof does not use cubical type theory in any essential way.
3.4 Successor Goodness Algebra
We are trying to create a nice goodness algebra by taking the limit of successive approximations, so we need a step function, which we will call S, that takes a goodness algebra \(\delta ^G\) and returns a new goodness algebra \(S\;\delta ^G\), which is closer in some sense to being nice. We do so by pattern matching on the presyntax to unroll one level of the recurrence equations niceness encodes.
We define by pattern matching
which gives a new property Y which maps back to \(\delta ^G.B\;\phi \;b\) for each b and \(\phi \), and similarly for A.
Then, in Fig. 5, we define the new goodness algebra \((S\;\delta ^G)\) along with projection functions \((\delta ^\pi \;\delta ^G)\) which take \(\text {Ix}\) and \(\text {Arg}\) from \((S\;\delta ^G)\) to \(\delta ^G\).
The projection functions \((\delta ^\pi \;\delta ^G)\) consist of applying the map given by the second component of \((E\;\delta ^G)\) everywhere in sight. The sorts are then defined by the first component of \((E\;\delta ^G)\), while the operations can be defined to be the corresponding projection function itself.
Concretely, for the sort B, we define \((\delta ^\pi \;\delta ^G).B\) to map between \(\text {Ix}\,B\; (S \delta ^G)\) and \(\text {Ix}\,B\;\delta ^G\). This consists of applying the function \(((E\;\delta ^G).A\;{a}_\text {pre}\;\star \;.2)\) which we defined by pattern matching above to \({a}_\text {good}\). Then, since \((S\;\delta ^G).B\) gets an inductive index \(\phi \) in \((S\;\delta ^G)\) but \(((E\;\delta ^G)\;b\;\phi \;.1)\) is expecting an inductive index in \(\delta ^G\), we span the gap with the projection function \((\delta ^\pi \;\delta ^G).B\) just defined. The definition of A follows the same pattern, but \((\delta ^\pi \;\delta ^G).A\) is even simpler because \(\text {Ix}\,A\;\delta ^G = \top \) regardless of what goodness algebra we are working in.
For the operations, consider \(\texttt {inj}\). Like with the sorts, we first define a projection function \((\delta ^\pi \;\delta ^G).\texttt {inj}\;a\;\phi \), which maps from \(\text {Arg}\,\texttt {inj}\;(S\;\delta ^G)\) to \(\text {Arg}\,\texttt {inj}\;\delta ^G\), and we fix up the inductive index \(\phi \) with \((\delta ^\pi \;\delta ^G).B\). For the first component of \(\text {Arg}\), we use the function given by the second component of \((E\;\delta ^G).A\) to fix up \({a}_\text {good}\). For the second component, applying the projection \((\delta ^\pi \;\delta ^G).B\) to the equality proof works out on the left hand side because all these projection functions are doing the same thing: applying the function given by the second component of \((E\;\delta ^G)\) everywhere. Finally, we can define \((S\;\delta ^G).\texttt {inj}= (\delta ^\pi \;\delta ^G).\texttt {inj}\), because \((S\;\delta ^G).\texttt {inj}\;a\;\phi \) is supposed to have codomain
which is defined to be
which reduces on \(({\texttt {inj}}_\text {pre}\;a)\) to
which is exactly the codomain of \((\delta ^\pi \;\delta ^G).\texttt {inj}\;a\;\phi \).
3.5 Limit of Goodness Algebras
We will now construct a nice goodness algebra by taking the limit of the sequence \(S^n\;\mathbb {O}\) and showing that it is nice, where \(S^n\;\mathbb {O}\) is defined by recursion on n with \(S^0\mathbb {O}= \mathbb {O}, S^{1+n}\mathbb {O}= S(S^n\;\mathbb {O})\). But first, we consider the limit of a chain of types.
Limit of Types. This subsection Limit of Types is formalized in Chain.agda.
In order to take the limit of successive goodness algebras, we need to know how to work with chains of types. Specifically, given \((X : \mathbb {N}\rightarrow \mathbb {I}\rightarrow \,\text {Type})\) and \(\pi : (n : \mathbb {N}) \rightarrow X\;(n+1)\;i_0 \rightarrow X\;n\;i_1\), we consider the limit given by the type
If we have \(x : \text {chain.t}\;X\;\pi \), then let x.p denote the second projection.
This definition is designed to work well in cubical type theory, and uses the interval \(\mathbb {I}\) and native heterogeneous equality \({x}\equiv _{X}{y}\) where \(X : \mathbb {I}\rightarrow \,\text {Type}\) (where we can form \(p = \lambda i.w : {x}\equiv _{X}{y}\) when \(p\;i_0 = x\), \(p\;i_1 = y\), and \(p\;i : X\;i\)). In particular, this definition allows for dependent chains without transporting over the base equality, which is problematic in cubical type theory because transport gets stuck on neutral types; instead given
we can form
using \(\text {cong}(B\;n)(a.p\;n)\) which is particularly well behaved in cubical type theory.
This construction commutes with most type formers: dependent function types, dependent pair types, identity types, and constants. We also note a dependent version of the fact that the limit of a chain is equivalent to the limit of a shifted chain to substitute for Ahrens et al. [1, Lemma 12].
Lemma 7
(Dependent chain equivalent to shifted chain). Given
and letting the X arguments to f and g be implicit, we can define the types
Applying f componentwise gives a function from \(t^+\) to t. This function is an equivalence.
We only use Lemma 7 when \(Y_1\;n\;(\pi _X\;n\;x) = Y_0\;(1+n)\;x\), so we may take g to be the identity, leaving \(t^+\) the shifted chain of t up to X arguments.
Limit of Goodness Algebras. Now we use the lemmas about chains to construct a nice goodness algebra, and then conclude by constructing an inductiveinductive object \((A,B,\eta ,\texttt {ext},\texttt {inj})\) that satisfies the simple elimination rules.
Lemma 8
A nice goodness algebra exists.
Proof
The sorts of the limit goodness algebra are defined as a chain, and operations act pointwise on each component of the chain. To prove that the operations are equivalences, we compose a proof that \(\text {Arg}\) commutes with chains (given by combining the lemmas about chains commuting with type formers) with a proof that for each sort, the chain given by the \((E\;(S^n\;\mathbb {O}))\) is equivalent to the chain given by \((S^n\;\mathbb {O})\) (given by Lemma 7). Since \((E\;(S^n\;\mathbb {O}))\) is defined by pattern matching to reduce to \(\text {Arg}\), the right and left sides of these equivalences agree, and we find that the operations are indeed nice. See the formalization for details.
Theorem 2
There exists an inductiveinductive object \((A, B, \eta , \texttt {ext}, \texttt {inj})\) that satisfies the simple elimination rules as defined in Fig. 1.
Proof
A nice goodness algebra exists by Lemma 8, therefore we can construct \((A, B, \eta , \texttt {ext}, \texttt {inj})\) satisfying the simple elimination rules by Lemma 6.
We have therefore succeeded. In cubical type theory, the inductiveinductive definition from Fig. 1 is constructible.
4 Related Work
The principle of simultaneously defining a type and a family over that type has been used many times before. Danielsson [9] used an inductiveinductiverecursive definition to define the syntax of dependent type theory, and Chapman [5] used an inductiveinductive definition for the same purpose. Conway’s surreal numbers [7] are given (up to a defined equivalence relation) by the inductiveinductive definition of number and less than, where less than is a relation indexed by two numbers [15, §7.1]. The HoTT book §11.3 gives a definition of the Cauchy reals as a higher inductiveinductive definition [18].
In his thesis and previous papers [15,16,17], Nordvall Forsberg studies the general theory of inductiveinductive types, axiomatizing a limited class of such definitions, and giving a set theoretic model showing that they are consistent. He also considers various extensions such as allowing a third type indexed by the first two, allowing the second type to be indexed by two elements of the first, or combining inductiveinductive definitions with inductiverecursive definitions from Dybjer and Setzer [10].
There have been several attempts to define a general class of inductiveinductive types larger than that in Nordvall Forsberg’s thesis. Kaposi and Kovács [14] gives an external syntactic description of a class which includes higher inductiveinductive types, and Altenkirch et al. [2] gives a semantic description of a class including quotient inductiveinductive types, but neither gives a type of codes that can be reasoned about internally. Working with UIP, Altenkirch et al. [4] propose a class of quotient inductiveinductive types.
Nordvall Forsberg’s thesis [15] appears to give the best previously known reduction of inductiveinductive types to regular inductive types known. As we have shown, Nordvall Forsberg’s approach can only be applied to intensional type theory if UIP holds. Furthermore, the equations for both Nordvall Forsberg’s approach and our approach only hold propositionally.
Many other structures have been reduced to plain inductive types. Our construction of inductiveinductive types can be seen as an adaptation of the technique in Ahrens et al. [1], where coinductive types are constructed from \(\mathbb {N}\) by taking a limit. Indexed inductive types (which are used in Nordvall Forsberg’s construction) are constructed from plain inductive types in Altenkirch et al. [3], with good computational properties (provided an identity type that satisfies J strictly). And small inductionrecursion is reduced to plain indexed inductive types in Hancock et al. [11].
5 Conclusions and Future Work
In this paper, we have:

1.
Shown that the construction of inductiveinductive types given by Nordvall Forsberg implies UIP.

2.
Given an alternative construction of one particular inductiveinductive type in cubical type theory, which is compatible with Homotopy Type Theory.
We claim that the construction of our specific running example is straightforwardly generalizable to other inductiveinductive types, and have formalized the construction of a number of other examples including types with nonfinitary constructors and indices to support this claim (see the GitHub repository referenced in the introduction).
Going forward, we would like to investigate

An internal definition of inductiveinductive specifications in HoTT. Early experiments suggest that this requires surmounting difficulties related to increasingly complex coherence conditions similar to those encountered when defining semisimplicial sets, c.f. Herbelin [12].

Extending the proof given here to construct the general elimination rules. The general elimination rules were defined in Nordvall Forsberg [15], but that formulation they relies on either strict computation rules or extensional type theory to be well typed. Kaposi and Kovács [14] give equivalent rules which are well typed in intensional type theory.

Identifying what needs to be added for the simple elimination rules to have the expected computational behavior. Given the similar construction method, this hopefully also allows the construction of coinductive types with nice computational behavior, c.f. Ahrens et al. [1].

In the opposite direction from the previous point, rewriting the construction given here in Coq + Function Extensionality. While the elimination rules will have poor computational behavior, this would make using inductiveinductive types in Coq possible without requiring any change to Coq itself, while being compatible with HoTT. In particular, using cubical type theory makes the proofs in Sect. 3.5 simpler, but we speculate that axiomatic function extensionality is sufficient.
Notes
 1.
The formalization can be found at https://github.com/jashug/ConstructingII.
 2.
Agda version 2.6.0 commit bd338484d.
References
Ahrens, B., Capriotti, P., Spadotti, R.: Nonwellfounded trees in homotopy type theory. In: TLCA (2015)
Altenkirch, T., Capriotti, P., Dijkstra, G., Kraus, N., Nordvall Forsberg, F.: Quotient inductiveinductive types. In: Baier, C., Dal Lago, U. (eds.) FoSSaCS 2018. LNCS, vol. 10803, pp. 293–310. Springer, Cham (2018). https://doi.org/10.1007/9783319893662_16
Altenkirch, T., Ghani, N., Hancock, P., McBride, C., Morris, P.: Indexed containers. J. Funct. Program. 25, e5 (2015)
Altenkirch, T., Kaposi, A., Kovács, A.: Constructing quotient inductiveinductive types. Proc. ACM Program. Lang. 3(POPL), 2:1–2:24 (2019). http://doi.acm.org/10.1145/3290315
Chapman, J.: Type theory should eat itself. Electron. Notes Theoret. Comput. Sci. 228, 21–36 (2009). http://www.sciencedirect.com/science/article/pii/S157106610800577X. Proceedings of the International Workshop on Logical Frameworks and Metalanguages: Theory and Practice (LFMTP 2008)
Cohen, C., Coquand, T., Huber, S., Mörtberg, A.: Cubical Type Theory: a constructive interpretation of the univalence axiom. IfCoLog J. Logics Appl. 4(10), 3127–3169 (2017). http://www.collegepublications.co.uk/journals/ifcolog/?00019
Conway, J.: On Numbers and Games. AK Peters Series. Taylor & Francis, Milton Park (2000). https://books.google.com/books?id=tXiVo8qA5PQC
The Coq Development Team: The Coq proof assistant, version 8.8.0, April 2018. https://doi.org/10.5281/zenodo.1219885
Danielsson, N.A.: A formalisation of a dependently typed language as an inductiverecursive family. In: Altenkirch, T., McBride, C. (eds.) TYPES 2006. LNCS, vol. 4502, pp. 93–109. Springer, Heidelberg (2007). https://doi.org/10.1007/9783540744641_7
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_11
Hancock, P., McBride, C., Ghani, N., Malatesta, L., Altenkirch, T.: Small induction recursion. In: Hasegawa, M. (ed.) TLCA 2013. LNCS, vol. 7941, pp. 156–172. Springer, Heidelberg (2013). https://doi.org/10.1007/9783642389467_13
Herbelin, H.: A dependentlytyped construction of semisimplicial types. Math. Struct. Comput. Sci. 25(5), 1116–1131 (2015)
Hofmann, M., Streicher, T.: The groupoid interpretation of type theory. In: TwentyFive Years of Constructive Type Theory (Venice, 1995), Oxford Logic Guides, vol. 36, pp. 83–111. Oxford University Press, New York (1998)
Kaposi, A., Kovács, A.: A syntax for higher inductiveinductive types. In: Kirchner, H. (ed.) 3rd International Conference on Formal Structures for Computation and Deduction, FSCD 2018. Leibniz International Proceedings in Informatics, LIPIcs, vol. 108, pp. 20:1–20:18. Schloss Dagstuhl–LeibnizZentrum fuer Informatik, Dagstuhl, Germany (2018). http://drops.dagstuhl.de/opus/volltexte/2018/9190
Nordvall Forsberg, F.: Inductiveinductive definitions. Ph.D. thesis. Swansea University (2013)
Nordvall Forsberg, F., Setzer, A.: Inductiveinductive definitions. In: Dawar, A., Veith, H. (eds.) CSL 2010. LNCS, vol. 6247, pp. 454–468. Springer, Heidelberg (2010). https://doi.org/10.1007/9783642152054_35
Nordvall Forsberg, F., Setzer, A.: A finite axiomatisation of inductiveinductive definitions. In: Berger, U., Hannes, D., Schuster, P., Seisenberger, M. (eds.) Logic, Construction, Computation, Ontos Mathematical Logic, vol. 3, pp. 259–287. Ontos Verlag (2012)
The Univalent Foundations Program: Homotopy Type Theory: Univalent Foundations of Mathematics, Institute for Advanced Study (2013). https://homotopytypetheory.org/book
Vezzosi, A.: Adding cubes to agda (2017). https://hottuf.github.io/2017/abstracts/cubicalagda.pdf
Acknowledgements
I would like to thank Talia Ringer and Dan Grossman from the UW PLSE lab, for their invaluable feedback throughout the revision process. I also thank Pavel Panchekha, John Leo, Remy Wang, and Fredrik Nordvall Forsberg for their comments.
Some of this work was completed while studying at Tokyo Institute of Technology under Professor Ryo Kashima. I would like to thank Professor Kashima, as well as my fellow lab members and mentors Asami and Maniwa for making my stay both productive and enjoyable.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
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 chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter'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.
Copyright information
© 2019 The Author(s)
About this paper
Cite this paper
Hugunin, J. (2019). Constructing InductiveInductive Types in Cubical Type Theory. In: Bojańczyk, M., Simpson, A. (eds) Foundations of Software Science and Computation Structures. FoSSaCS 2019. Lecture Notes in Computer Science(), vol 11425. Springer, Cham. https://doi.org/10.1007/9783030171278_17
Download citation
DOI: https://doi.org/10.1007/9783030171278_17
Published:
Publisher Name: Springer, Cham
Print ISBN: 9783030171261
Online ISBN: 9783030171278
eBook Packages: Computer ScienceComputer Science (R0)