5.2 Uniqueness of inductive types

5.2 Uniqueness of inductive types

We have defined “the”

natural numbers

to be a particular type

ℕ

with particular inductive

generators

0

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

•

0

′

:

ℕ

′

•

𝗌𝗎𝖼𝖼

′

:

ℕ

′

→

ℕ

′

.

Then

ℕ

′

will have identical-looking

induction

and

recursion

principles to

ℕ

.
When proving a statement

E

:

ℕ

′

→

𝒰

for all of these “new” natural numbers, it suffices to give the proofs

e

z

:

E

⁢

(

0

′

)

and

e

s

:

∏

(

n

:

ℕ

′

)

∏

(

x

:

E

(

n

)

)

E

⁢

(

𝗌𝗎𝖼𝖼

′

⁢

(

n

)

)

.

And the

function

𝗋𝖾𝖼

ℕ

′

⁢

(

E

,

e

z

,

e

s

)

:

∏

(

n

:

ℕ

′

)

E

⁢

(

n

)

has the following

computation

rules:

•

𝗋𝖾𝖼

ℕ

′

⁢

(

E

,

e

z

,

e

s

,

0

′

)

≡

e

z

,

•

𝗋𝖾𝖼

ℕ

′

⁢

(

E

,

e

z

,

e

s

,

𝗌𝗎𝖼𝖼

′

⁢

(

n

)

)

≡

e

s

⁢

(

n

,

𝗋𝖾𝖼

ℕ

′

⁢

(

E

,

e

z

,

e

s

,

n

)

)

for any

n

:

ℕ

′

.

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:

𝖽𝗈𝗎𝖻𝗅𝖾

′

:

≡

𝗋𝖾𝖼

ℕ

′

(

ℕ

′

,

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

composition

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.

𝖽𝗈𝗎𝖻𝗅𝖾

′

:

≡

λ

n

.

f

(

𝖽𝗈𝗎𝖻𝗅𝖾

(

g

(

n

)

)

)

.

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

f

and

g

.
Consider, for instance, a simple lemma such as

∏

n

:

ℕ

′

𝖽𝗈𝗎𝖻𝗅𝖾

′

⁢

(

𝗌𝗎𝖼𝖼

′

⁢

(

n

)

)

=

𝗌𝗎𝖼𝖼

′

⁢

(

𝗌𝗎𝖼𝖼

′

⁢

(

𝖽𝗈𝗎𝖻𝗅𝖾

′

⁢

(

n

)

)

)

.

Inserting the correct

f

s and

g

s 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

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

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

e

0

:

E

⁢

(

0

′′

)

and

e

s

:

∏

(

ℓ

:

𝖫𝗂𝗌𝗍

(

𝟏

)

)

E

⁢

(

ℓ

)

→

E

⁢

(

𝗌𝗎𝖼𝖼

′′

⁢

(

ℓ

)

)

, we can define

e

𝗇𝗂𝗅

:

≡

e

0

e

𝖼𝗈𝗇𝗌

⁢

(

⋆

,

ℓ

,

x

)

:

≡

e

s

(

ℓ

,

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

f

⁢

(

0

′′

)

≡

f

⁢

(

𝗇𝗂𝗅

)

≡

e

𝗇𝗂𝗅

≡

e

0

f

⁢

(

𝗌𝗎𝖼𝖼

′′

⁢

(

ℓ

)

)

≡

f

⁢

(

𝖼𝗈𝗇𝗌

⁢

(

⋆

,

ℓ

)

)

≡

e

𝖼𝗈𝗇𝗌

⁢

(

⋆

,

ℓ

,

f

⁢

(

ℓ

)

)

≡

e

s

⁢

(

ℓ

,

f

⁢

(

ℓ

)

)

.

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

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/87533

Chapter 1 we saw that the

coproduct

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

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

Generated on Thu Feb 8 19:36:22 2018 by

LaTeXML