5.2 Uniqueness of inductive types
We have defined βtheβ natural numbers to be a particular type with particular inductive generators and . However, by the general principle of inductive definitions in type theory described in the previous section, 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 induction and recursion principles to . When proving a statement for all of these βnewβ natural numbers, it suffices to give the proofs and And the function has the following computation rules:
-
β’
,
-
β’
for any .
But what is the relation between and ?
This is not just an academic question, since structures 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:
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 , 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:
-
β’
,
-
β’
.
Since the composition of and satisfies the same recurrences as the identity function on , Theorem 5.1.1 (http://planetmath.org/51introductiontoinductivetypes#Thmprethm1) gives that , and the βprimedβ version of the same theorem gives . Thus, and 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 isomorphism 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 and . Consider, for instance, a simple lemma such as
Inserting the correct s and s is only a little easier than re-proving it by induction on 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 identity 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 , with the given object being an element of , 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 together with recurrence data and , there exists such that and . (We will see how to derive the induction principle of an inductive definition in Β§5.6 (http://planetmath.org/56thegeneralsyntaxofinductivedefinitions).)
Now suppose we define , and by . Then for any together with and , we can define
(In the definition of we use the induction principle of to assume that is .) Now we can apply the induction principle of , obtaining such that
Thus, satisfies the same induction principle as , and hence (by the same arguments above) is equal to it.
Finally, these conclusions are not confined to the natural numbers: they apply to any inductive type. If we have an inductively defined type , say, and some other type which satisfies the same induction principle as , then it follows that , and hence . We use the derived recursion principles for and to construct maps and , 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 coproduct could also have been defined as . The latter type satisfies the same induction principle as the former; hence they are canonically equivalent.
This is, of course, very similar to the familiar fact in category theory that if two objects have the same universal property, 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 |
---|---|
\metatable |