5.2 Uniqueness of inductive types

We have defined β€œthe” natural numbersMathworldPlanetmath to be a particular type β„• with particular inductive generatorsPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath 0 and π—Œπ—Žπ–Όπ–Ό. However, by the general principle of inductive definitions in type theoryPlanetmathPlanetmath described in the previous sectionPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath, there is nothing preventing us from defining another type in an identical way. That is, suppose we let β„•β€² be the inductive type generated by the constructors

  • β€’


  • β€’


Then β„•β€² will have identical-looking inductionMathworldPlanetmath and recursion principles to β„•. When proving a statement E:ℕ′→𝒰 for all of these β€œnew” natural numbers, it suffices to give the proofs ez:E⁒(0β€²) and es:∏(n:β„•β€²)∏(x:E(n))E⁒(π—Œπ—Žπ–Όπ–Όβ€²β’(n)). And the function 𝗋𝖾𝖼ℕ′⁒(E,ez,es):∏(n:β„•β€²)E⁒(n) has the following computation rules:

  • β€’


  • β€’

    𝗋𝖾𝖼ℕ′⁒(E,ez,es,π—Œπ—Žπ–Όπ–Όβ€²β’(n))≑es⁒(n,𝗋𝖾𝖼ℕ′⁒(E,ez,es,n)) for any n:β„•β€².

But what is the relationMathworldPlanetmathPlanetmath between β„• and β„•β€²?

This is not just an academic question, since structuresMathworldPlanetmath that β€œlook like” the natural numbers can be found in many other places. For instance, we may identify natural numbers with lists over the type with one element (this is arguably the oldest appearance, found on walls of caves), with the non-negative integers, with subsets of the rationals and the reals, and so on. And from a programming point of view, the β€œunary” representation of our natural numbers is very inefficient, so we might prefer sometimes to use a binary one instead. We would like to be able to identify all of these versions of β€œthe natural numbers” with each other, in order to transfer constructions and results from one to another.

Of course, if two versions of the natural numbers satisfy identical induction principles, then they have identical induced structure. For instance, recall the example of the function π–½π—ˆπ—Žπ–»π—…π–Ύ defined in Β§1.9 (http://planetmath.org/19thenaturalnumbers). A similar function for our new natural numbers is readily defined by duplication and adding primes:

π–½π—ˆπ—Žπ–»π—…π–Ύβ€²:≑𝗋𝖾𝖼ℕ′(β„•β€², 0β€²,Ξ»n.Ξ»m.π—Œπ—Žπ–Όπ–Όβ€²(π—Œπ—Žπ–Όπ–Όβ€²(m))).

Simple as this may seem, it has the obvious drawback of leading to a proliferation of duplicates. Not only functions have to be duplicated, but also all lemmas and their proofs. For example, an easy result such as ∏(n:β„•)π–½π—ˆπ—Žπ–»π—…π–Ύβ’(π—Œπ—Žπ–Όπ–Όβ’(n))=π—Œπ—Žπ–Όπ–Όβ’(π—Œπ—Žπ–Όπ–Όβ’(π–½π—ˆπ—Žπ–»π—…π–Ύβ’(n))), as well as its proof by induction, also has to be β€œprimed”.

In traditional mathematics, one just proclaims that β„• and β„•β€² are obviously β€œthe same”, and can be substituted for each other whenever the need arises. This is usually unproblematic, but it sweeps a fair amount under the rug, widening the gap between informal mathematics and its precise description. In homotopy type theory, we can do better.

First observe that we have the following definable maps:

  • β€’

    f:≑𝗋𝖾𝖼ℕ(β„•, 0β€²,Ξ»n.π—Œπ—Žπ–Όπ–Όβ€²):β„•β†’β„•β€²,

  • β€’

    g:≑𝗋𝖾𝖼ℕ′(β„•β€², 0,Ξ»n.,π—Œπ—Žπ–Όπ–Ό):β„•β€²β†’β„•.

Since the compositionMathworldPlanetmath of g and f satisfies the same recurrences as the identity function on β„•, Theorem 5.1.1 (http://planetmath.org/51introductiontoinductivetypes#Thmprethm1) gives that ∏(n:β„•)g⁒(f⁒(n))=n, and the β€œprimed” version of the same theorem gives ∏(n:β„•β€²)f⁒(g⁒(n))=n. Thus, f and g are quasi-inverses, so that ℕ≃ℕ′. We can now transfer functions on β„• directly to functions on β„•β€² (and vice versa) along this equivalence, e.g.


It is an easy exercise to show that this version of π–½π—ˆπ—Žπ–»π—…π–Ύβ€² is equal to the earlier one.

Of course, there is nothing surprising about this; such an isomorphismMathworldPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmathPlanetmath is exactly how a mathematician will envision β€œidentifying” β„• with β„•β€². However, the mechanism of β€œtransfer” across an isomorphism depends on the thing being transferred; it is not always as simple as pre- and post-composing a single function with f and g. Consider, for instance, a simple lemma such as


Inserting the correct fs and gs is only a little easier than re-proving it by induction on n:β„•β€² directly.

Here is where the univalence axiom steps in: since ℕ≃ℕ′, we also have β„•=𝒰ℕ′, i.e.Β β„• and β„•β€² are equal as types. Now the induction principle for identityPlanetmathPlanetmathPlanetmathPlanetmath guarantees that any construction or proof relating to β„• can automatically be transferred to β„•β€² in the same way. We simply consider the type of the function or theorem as a type-indexed family of types P:𝒰→𝒰, with the given object being an element of P⁒(β„•), and transport along the path β„•=β„•β€². This involves considerably less overhead.

For simplicity, we have described this method in the case of two types β„• and β„•β€² with identical-looking definitions. However, a more common situation in practice is when the definitions are not literally identical, but nevertheless one induction principle implies the other. Consider, for instance, the type of lists from a one-element type, π–«π—‚π—Œπ—β’(𝟏), which is generated by

  • β€’

    an element 𝗇𝗂𝗅:π–«π—‚π—Œπ—β’(𝟏), and

  • β€’

    a function π–Όπ—ˆπ—‡π—Œ:πŸΓ—π–«π—‚π—Œπ—β’(𝟏)β†’π–«π—‚π—Œπ—β’(𝟏).

This is not identical to the definition of β„•, and it does not give rise to an identical induction principle. The induction principle of π–«π—‚π—Œπ—β’(𝟏) says that for any E:π–«π—‚π—Œπ—β’(𝟏)→𝒰 together with recurrence data e𝗇𝗂𝗅:E⁒(𝗇𝗂𝗅) and eπ–Όπ—ˆπ—‡π—Œ:∏(u:𝟏)∏(β„“:π–«π—‚π—Œπ—(𝟏))E⁒(β„“)β†’E⁒(π–Όπ—ˆπ—‡π—Œβ’(u,β„“)), there exists f:∏(β„“:π–«π—‚π—Œπ—(𝟏))E⁒(β„“) such that f⁒(𝗇𝗂𝗅)≑e𝗇𝗂𝗅 and f⁒(π–Όπ—ˆπ—‡π—Œβ’(u,β„“))≑eπ–Όπ—ˆπ—‡π—Œβ’(u,β„“,f⁒(β„“)). (We will see how to derive the induction principle of an inductive definition in Β§5.6 (http://planetmath.org/56thegeneralsyntaxofinductivedefinitions).)

Now suppose we define 0β€²β€²:≑𝗇𝗂𝗅:π–«π—‚π—Œπ—(𝟏), and π—Œπ—Žπ–Όπ–Όβ€²β€²:π–«π—‚π—Œπ—β’(𝟏)β†’π–«π—‚π—Œπ—β’(𝟏) by π—Œπ—Žπ–Όπ–Όβ€²β€²(β„“):β‰‘π–Όπ—ˆπ—‡π—Œ(⋆,β„“). Then for any E:π–«π—‚π—Œπ—β’(𝟏)→𝒰 together with e0:E⁒(0β€²β€²) and es:∏(β„“:π–«π—‚π—Œπ—(𝟏))E⁒(β„“)β†’E⁒(π—Œπ—Žπ–Όπ–Όβ€²β€²β’(β„“)), we can define

e𝗇𝗂𝗅 :≑e0
eπ–Όπ—ˆπ—‡π—Œβ’(⋆,β„“,x) :≑es(β„“,x).

(In the definition of eπ–Όπ—ˆπ—‡π—Œ we use the induction principle of 𝟏 to assume that u is ⋆.) Now we can apply the induction principle of π–«π—‚π—Œπ—β’(𝟏), obtaining f:∏(β„“:π–«π—‚π—Œπ—(𝟏))E⁒(β„“) such that


Thus, π–«π—‚π—Œπ—β’(𝟏) satisfies the same induction principle as β„•, and hence (by the same arguments above) is equal to it.

Finally, these conclusionsMathworldPlanetmath are not confined to the natural numbers: they apply to any inductive type. If we have an inductively defined type W, say, and some other type Wβ€² which satisfies the same induction principle as W, then it follows that W≃Wβ€², and hence W=Wβ€². We use the derived recursion principles for W and Wβ€² to construct maps Wβ†’Wβ€² and Wβ€²β†’W, respectively, and then the induction principles for each to prove that both composites are equal to identities. For instance, in http://planetmath.org/node/87533Chapter 1 we saw that the coproductMathworldPlanetmath A+B could also have been defined as βˆ‘(x:𝟐)π—‹π–Ύπ–ΌπŸβ’(𝒰,A,B,x). The latter type satisfies the same induction principle as the former; hence they are canonically equivalentMathworldPlanetmathPlanetmathPlanetmath.

This is, of course, very similar to the familiar fact in category theoryMathworldPlanetmathPlanetmathPlanetmathPlanetmath that if two objects have the same universal propertyMathworldPlanetmath, then they are equivalent. In Β§5.4 (http://planetmath.org/54inductivetypesareinitialalgebras) we will see that inductive types actually do have a universal property, so that this is a manifestation of that general principle.

Title 5.2 Uniqueness of inductive types