In this post I will argue that, improving on previous work of Awodey-Frey-Speight, (higher) inductive types can be defined using impredicative encodings with their full dependent induction principles — in particular, eliminating into all type families without any truncation hypotheses — in ordinary (impredicative) Book HoTT without any further bells or whistles. But before explaining that and what it means, let me review the state of the art.
Categorically, a (higher) inductive type is an initial object in some category. For instance, the coproduct of and is the initial object of the category of types equipped with maps and ; and the circle is the initial object of the category of types equipped with a point and an equality . A (H)IT is therefore a kind of “colimity” thing, while an “impredicative encoding” of it is a way to construct it (or an approximation thereof) using limits instead — specifically, large limits, which requires a universe closed under impredicative quantification (i.e. -types whose domain is not necessarily an element of the universe).
The most basic such encodings (usually associated with System F) approximate the initial object of a category by the product of all objects of that category. For instance, the System F coproduct is the product of all types equipped with maps and , which in type-theoretic syntax becomes
Such impredicative encodings of ordinary inductive types are well-known in type theory, and back when we were first discovering HITs I blogged here about the fact that they can also be encoded impredicatively. However, these basic encodings have the problem that they don’t satisfy the “uniqueness principle” or -conversion, and (equivalently) they don’t support a “dependent eliminator” or “induction principle”, only the non-dependent “recursion principle”. In categorical language, the product of all objects of a category, even if it exists, is only a weak initial object.
Last year, Sam Speight blogged here about a way to fix this problem (paper here with Awodey and Frey), by defining a (higher) inductive type to be the limit of the identity functor of the category in question, and appealing to this theorem. Such a limit, if constructed out of products and equalizers, appears as a subobject of the product of all objects; and if we “compile out” this definition in type theory, it adds additional assertions that System F encoding data is natural. For instance, the coproduct becomes
This approach is very nice, but unfortunately it only works for h-sets, i.e. 0-types. That is, given two sets , it produces a coproduct set , which has a dependent induction principle that can only eliminate into other sets. Categorically, the point is that the construction of limits out of products and equalizers works in a 1-category, but not in a higher category. We can boost up the dimension one at a time by adding additional coherence conditions — the paper ends with an example of constructed as a 1-type with a dependent induction principle that can eliminate into other 1-types (but not higher types) — but this approach offers no hope of an induction principle into types that are not -truncated for any . If we could solve the “problem of infinite objects” (perhaps by working in a context like two-level type theory) maybe we could add “all the coherence conditions at once”, although the path algebra would probably get quite hairy.
Surprisingly (to me), it turns out that there is a different solution, which works in (impredicative) Book HoTT without any bells or whistles. Recall that theorem about initial objects as limits of identity functors, and note that it’s proven using this lemma, which says that if is an object of a category equipped with a natural transformation from the constant functor to the identity functor, i.e. a cone consisting of maps for all objects such that for all morphisms , and moreover is the identity morphism, then is initial. Can we use this lemma directly?
You might think this is no better, since even obtaining a fully-coherent -natural transformation already involves infinitely many coherence conditions. However, inspecting the proof of this lemma, we see that it will work in HoTT even for an “incoherent” natural transformation, essentially because the definition of contractibility is a propositions-as-types translation of being a singleton set. That is, to show that is initial in , we want to show that is contractible. We take its center to be , and then we must show that any is equal to . But by incoherent naturality, we have , which is equal to since .
This is great, because the 0-type version of the Awodey-Frey-Speight construction, if written down with the full universe in place of , already comes with an incoherent cone over the identity functor. So “all” we need to do is ensure . (Note that this is a version of for an inductive type.)
Here’s the trick. Note that the proof of the lemma shows is initial by applying the naturality property in a case where one of the objects is itself. Let’s try to prove is the identity by applying that same naturality property in the case where the morphism is itself. This gives us . In other words, although may not (yet) be the identity, it’s already the next best thing: an idempotent. And in the words of Robinson and Rosolini,
No category theorist can see an idempotent without feeling the urge to split it.
This is especially true when we were hoping that that idempotent would turn out to be an identity, since splitting it is a way to “make” it an identity. And in fact it’s not hard to show with categorical algebra that if and are a splitting of (so that and ), where is a cone over the identity functor, then is initial. For we have another cone , whose -component is . And we have , using naturality and the splitting equations, so , so the lemma applies. Note that this argument also uses no higher coherence, and so should work just fine for an incoherent natural transformation.
What’s left is to split the idempotent in type theory. Fortunately, I wrote a paper a few years ago (original blog posts here and here) about precisely this problem, inspired by analogous results of Lurie in higher category theory. It turns out that an arbitrary “incoherent idempotent” (a map equipped with an equality ) may not be splittable, but as soon as the “witness of idempotency” satisfies one additional coherence condition (not the infinite tower of such one might expect), the map can be split. And in our situation, we can obtain this one additional coherence condition for the naturality triangle by using the 1-type version of the Awodey-Frey-Speight construction. (Actually, we can even omit their unit condition; all we need is the composition coherence for pseudonaturality.)
I’ve verified in Coq that this works for coproducts, using type-in-type for impredicativity. (I don’t think Coq’s built-in impredicative-set option is compatible with the HoTT library, which has tried to excise Coq’s built-in smallest universe Set as much as possible.) Most of the proof is quite easy; the longest part (40 lines of path algebra) is deducing the idempotence coherence condition from the naturality coherence condition. As expected, we only get typal computation rules for the induction principle — although we do have definitional computation rules for the recursion principle (i.e. the non-dependent eliminator). More precisely, there is a non-dependent eliminator (a special one, not just the dependent eliminator specialized to a non-dependent motive) that satisfies a definitional computation rule.
I’m working on coding it up for higher inductive types as well, but the path algebra gets quite annoying. Further bulletins as events warrant.
To conclude, let me point out that I find this a very satisfying answer to the question with which I ended my second idempotents post:
… [For equivalences] we also have a “fully coherent” notion … that is a retract of a type of “partially coherent” objects…. Are there any other structures that behave like this? Are there any other “fully coherent” gadgets that we can obtain by splitting an idempotent on a type of partially-coherent ones?
The answer is yes: a fully-coherent impredicative encoding can be obtained by splitting an idempotent on a partially-coherent one.