Introduction to Homotopy Type Theory
Introduction to Homotopy Type Theory
E GBERT R IJKE
L ECTURE N OTES
FOR THE
A UGUST 2019
The author gratefully acknowledges the support of the Air Force Office of Scientific
Research through MURI grant FA9550-15-1-0053.
Contents i
i
ii CONTENTS
14 The circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
14.1 The induction principle of the circle . . . . . . . . . . . . . . . . . 96
14.2 The (dependent) universal property of the circle . . . . . . . . . . 97
14.3 Multiplication on the circle . . . . . . . . . . . . . . . . . . . . . . 100
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
15 The fundamental cover of the circle . . . . . . . . . . . . . . . . . . . . . 104
15.1 Families over the circle . . . . . . . . . . . . . . . . . . . . . . . . . 104
15.2 The fundamental cover of the circle . . . . . . . . . . . . . . . . . 105
15.3 Contractibility of general total spaces . . . . . . . . . . . . . . . . 106
15.4 The dependent universal property of the integers . . . . . . . . . 108
15.5 The identity type of the circle . . . . . . . . . . . . . . . . . . . . . 110
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Bibliography 113
Index 115
Chapter I
H1 H2 ... Hn
C
containing above the horizontal line a finite list H1 , H2 , . . . , Hn of judgments for the
hypotheses, and below the horizontal line a single judgment C for the conclusion. A
very simple example that we will encounter in §2 when we introduce function types, is
the inference rule
Γ`a:A Γ` f :A→B
Γ ` f ( a) : B
This rule asserts that in any context Γ we may use a term a : A and a function f : A → B
to obtain a term f ( a) : B. Each of the expressions
Γ`a:A
Γ` f :A→B
Γ ` f ( a) : B
are examples of judgments. There are four kinds of judgments in type theory:
1
2 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
(i) A is a (well-formed) type in context Γ. The symbolic expression for this judgment is
Γ ` A type
(ii) A and B are judgmentally equal types in context Γ. The symbolic expression for this
judgment is
Γ ` A ≡ B type
(iii) a is a (well-formed) term of type A in context Γ. The symbolic expression for this
judgment is
Γ`a:A
(iv) a and b are judgmentally equal terms of type A in context Γ. The symbolic expression
for this judgment is
Γ`a≡b:A
Thus we see that any judgment is of the form Γ ` J , consisting of a context Γ and an
expression J asserting that A is a type, that A and B are equal types, that a is a term of
type A, or that a and b are equal terms of type A. The role of a context is to declare what
hypothetical terms are assumed, along with their types. More formally, a context is an
expression of the form
x 1 : A 1 , x 2 : A 2 ( x 1 ), . . . , x n : A n ( x 1 , . . . , x n −1 ) (1.1)
satisfying the condition that for each 1 ≤ k ≤ n we can derive, using the inference rules
of type theory, that
In other words, to check that an expression of the form Eq. (1.1) is a context, one starts
on the left and works their way to the right verifying that each hypothetical term xk is
assigned a well-formed type. Hypothetical terms are commonly called variables, and we
say that a context as in Eq. (1.1) declares the variables x1 , . . . , xn . We may use variable
names other than x1 , . . . , xn , as long as no variable is declared more than once.
The condition in Eq. (1.2) that each of the hypothetical terms is assigned a well-formed
type, is checked recursively. Note that the context of length 0 satisfies the requirement in
Eq. (1.2) vacuously. This context is called the empty context. An expression of the form
x1 : A1 is a context if and only if A1 is a well-formed type in the empty context. Such
types are called closed types. We will soon encounter the type N of natural numbers,
which is an example of a closed type. There is also the notion of closed term, which
is simply a term in the empty context. The next case is that an expression of the form
x1 : A1 , x2 : A2 ( x1 ) is a context if and only if A1 is a well-formed type in the empty
context, and A2 ( x1 ) is a well-formed type, given a hypothetical term x1 : A1 . This
process repeats itself for longer contexts.
It is a feature of dependent type theory that all judgments are context-dependent, and
indeed that even the types of the variables may depend on any previously declared
variables. For example, when we introduce the identity type in §5, we make full use of
the machinery of type dependency, as is clear from how they are introduced:
1. DEPENDENT TYPE THEORY 3
Γ ` A type
Γ, x : A, y : A ` x = y type
This rule asserts that given a type A in context Γ, we may form a type x = y in context
Γ, x : A, y : A. Note that in order to know that the expression Γ, x : A, y : A is indeed a
well-formed context, we need to know that A is a well-formed type in context Γ, x : A.
This is an instance of weakening, which we will describe shortly.
In the situation where we have
Γ, x : A ` B( x ) type,
we say that B is a family of types over A in context Γ. Alternatively, we say that B( x ) is
a type indexed by x : A, in context Γ. Similarly, in the situation where we have
Γ, x : A ` b( x ) : B( x ),
we say that b is a section of the family B over A in context Γ. Alternatively, we say
that b( x ) is a term of type B( x ), indexed by x : A in context Γ. Note that in the above
situations A, B, and b also depend on the variables declared in the context Γ, even though
we have not explicitly mentioned them. It is common practice to not mention every
variable in the context Γ in such situations.
Judgmental equality
In this set of inference rules we ensure that judgmental equality (both on types and on
terms) are equivalence relations, and we make sure that in any context Γ, we can change
the type of any variable to a judgmentally equal type.
The rules postulating that judgmental equality on types and on terms is an equiva-
lence relation are as follows:
Γ ` A type Γ ` A ≡ A0 type Γ ` A ≡ A0 type Γ ` A0 ≡ A00 type
Γ ` A ≡ A type Γ ` A0 ≡ A type Γ ` A ≡ A00 type
Γ`a:A Γ ` a ≡ a0 : A Γ ` a ≡ a0 : A Γ ` a0 ≡ a00 : A
Γ`a≡a:A Γ ` a0 ≡ a : A Γ ` a ≡ a00 : A
Apart from the rules postulating that judgmental equality is an equivalence relation,
there are also variable conversion rules. Informally, these are rules stating that if A and
4 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
A0 are judgmentally equal types in context Γ, then any valid judgment in context Γ, x : A
is also a valid judgment in context Γ, x : A0 . In other words: we can convert the type of a
variable to a judgmentally equal type.
The first variable conversion rule states that
Γ ` A ≡ A0 type Γ, x : A, ∆ ` B( x ) type
Γ, x : A , ∆ ` B( x ) type
0
In this conversion rule, the context of the form Γ, x : A, ∆ is just any extension of the
context Γ, x : A.
Similarly, there are variable conversion rules for judgmental equality of types, for
terms, and for judgmental equality of terms. To avoid having to state essentially the
same rule four times, we state all four variable conversion rules at once using a generic
judgment J , which can be any of the four kinds of judgments.
Γ ` A ≡ A0 type Γ, x : A, ∆ ` J
Γ, x : A , ∆ ` J
0
An analogous term conversion rule, stated in Exercise 1.1, converting the type of a term to
a judgmentally equal type, is derivable using the rules for substitution and weakening,
and the variable rule.
Substitution
If we are given a term a : A in context Γ, then for any type B in context Γ, x : A, ∆ we can
form the type B[ a/x ] in context Γ, ∆[ a/x ], where B[ a/x ] is an abbreviation for
B ( x 1 , . . . , x n −1 , a ( x 1 , . . . , x n −1 ), x n +1 , . . . , x n + m −1 ).
Γ`a:A Γ, x : A, ∆ ` J
Sa
Γ, ∆[ a/x ] ` J [ a/x ]
Furthermore, we postulate that substitution by judgmentally equal terms results in
judgmentally equal types
Γ ` a ≡ a0 : A Γ, x : A, ∆ ` B type
Γ, ∆[ a/x ] ` B[ a/x ] ≡ B[ a0 /x ] type
and it also results in judgmentally equal terms
Γ ` a ≡ a0 : A Γ, x : A, ∆ ` b : B
Γ, ∆[ a/x ] ` b[ a/x ] ≡ b[ a0 /x ] : B[ a/x ]
When B is a family of types over A and a : A, we also say that B[ a/x ] is the fiber of B at
a. We will usually write B( a) for B[ a/x ].
1. DEPENDENT TYPE THEORY 5
Weakening
If we are given a type A in context Γ, then any judgment made in a longer context Γ, ∆
can also be made in the context Γ, x : A, ∆, for a fresh variable x. The weakening rule
asserts that weakening by a type A in context preserves well-formedness and judgmental
equality of types and terms.
Γ ` A type Γ, ∆ ` J
WA
Γ, x : A, ∆ ` J
This process of expanding the context by a fresh variable of type A is called weakening
(by A).
In the simplest situation where weakening applies, we have two types A and B in
context Γ. Then we can weaken B by A as follows
Γ ` A type Γ ` B type
WA
Γ, x : A ` B type
in order to form the type B in context Γ, x : A. The type B in context Γ, x : A is called the
constant family B, or the trivial family B.
Γ ` A type
δ
Γ, x : A ` x : A A
One of the reasons for including the variable rule is that it provides an identity function
on the type A in context Γ.
1.3 Derivations
A derivation in type theory is a tree in which each node is a valid rule of inference. We
give two examples of derivations: a derivation showing that any variable can be changed
to a fresh one, and a derivation showing that any two variables that do not depend on
one another can be swapped in order.
Thus, we will see some examples of new inference rules that can be derived using
the rules of type theory. Such inference rules are called admissible. Since derivations
tend to get long and unwieldy, we declare that admissible inference rules are also valid
to be used in derivations.
6 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
Changing variables
Variables can always be changed to fresh variables. We show that this is the case by
showing that the inference rule
Γ, x : A, ∆ ` J
x 0 /x
Γ, x 0 : A, ∆[ x 0 /x ] ` J [ x 0 /x ]
Γ ` A type Γ ` A type Γ, x : A, ∆ ` J
δA WA
Γ, x : A ` x : A
0 0 Γ, x : A, x : A, ∆ ` J
0
Sx 0
Γ, x 0 : A, ∆[ x 0 /x ] ` J [ x 0 /x ]
In this derivation it is the application of the weakening rule where we have to check that
x 0 does not occur in the context Γ, x : A, ∆.
Interchanging variables
The interchange rule states that if we have two types A and B in context Γ, and we
make a judgment in context Γ, x : A, y : B, ∆, then we can make that same judgment in
context Γ, y : B, x : A, ∆ where the order of x : A and y : B is swapped. More formally,
the interchange rule is the following inference rule
Γ ` B type Γ, x : A, y : B, ∆ ` J
Γ, y : B, x : A, ∆ ` J
Just as the rule for changing variables, we claim that the interchange rule is an admissible
rule.
The idea of the derivation for the interchange rule is as follows: If we have a judgment
Γ, x : A, y : B, ∆ ` J ,
then we can change the variable y to a fresh variable y0 and weaken the judgment to
obtain the judgment
Γ ` B type Γ, x : A, y : B, ∆ ` J
δB y0 /y
Γ, y : B ` y : B Γ, x : A, y0 : B, ∆[y0 /y] ` J [y0 /y]
WWB ( A) WB
Γ, y : B, x : A ` y : B Γ, y : B, x : A, y0 : B, ∆[y0 /y] ` J [y0 /y]
SWA (y)
Γ, y : B, x : A, ∆ ` J
1. EXERCISES 7
Exercises
1.1 Give a derivation for the following term conversion rule:
Γ ` A ≡ A0 type Γ`a:A
Γ`a:A 0
∆, Γ ` Ba type
for every context ∆, and every term ∆, Γ ` a : A, subject to the condition that
one can derive
∆`d:D ∆, y : D, Γ ` a : A
∆, Γ ` Ba [d/y] ≡ Ba[d/y] type
Define a bijection between the set of types in context Γ, x : A modulo judg-
mental equality, and the set of uniform families over A modulo judgmental
equality.
(b) Consider a type Γ, x : A ` B. We define a uniform term of B over A to consist
of a type
∆, Γ ` ba : B[ a/x ] type
for every context ∆, and every term ∆, Γ ` a : A, subject to the condition that
one can derive
∆`d:D ∆, y : D, Γ ` a : A
∆, Γ ` ba [d/y] ≡ ba[d/y] : B[ a/x ][d/y]
Define a bijection between the set of terms of B in context Γ, x : A mod-
ulo judgmental equality, and the set of uniform terms of B over A modulo
judgmental equality.
∏ (x:A) B( x )
in context Γ, consisting of all the dependent functions of which the output at x : A has
type B( x ). There are four principal rules for Π-types:
(i) The formation rule, which tells us how we may form dependent function types.
(ii) The introduction rule, which tells us how to introduce new terms of dependent
function types.
(iii) The elimination rule, which tells us how to use arbitrary terms of dependent
function types.
(iv) The computation rules, which tell us how the introduction and elimination rules
interact. These computation rules guarantee that every term of a dependent
function type behaves as expected: as a dependent function.
In the cases of the formation rule, the introduction rule, and the elimination rule, we will
also provide conversion rules that ensure that all the constructions respect judgmental
equality.
Γ, x : A ` B( x ) type
Π.
Γ ` ∏ (x:A) B( x ) type
With the following conversion rule we postulate that formation of dependent function
types respects judgmental equality of types:
Γ ` A ≡ A0 type Γ, x : A ` B( x ) ≡ B0 ( x ) type
Π-eq.
Γ ` ∏ (x:A) B( x ) ≡ ∏ (x:A0 ) B0 ( x ) type
Furthermore, when x 0 is a fresh variable, i.e., which does not occur in the context Γ, x : A,
we also postulate that
Γ, x : A ` B( x ) type
Π-x 0 /x.
Γ ` ∏ (x:A) B( x ) ≡ ∏ (x0 :A) B( x 0 ) type
2. DEPENDENT FUNCTION TYPES 9
Γ, x : A ` b( x ) : B( x )
λ
Γ ` λx. b( x ) : ∏ (x:A) B( x )
Γ, x : A ` b( x ) ≡ b0 ( x ) : B( x )
λ-eq.
Γ ` λx. b( x ) ≡ λx. b0 ( x ) : ∏ (x:A) B( x )
Γ ` f : ∏ (x:A) B( x )
ev
Γ, x : A ` f ( x ) : B( x )
Γ ` f ≡ f 0 : ∏ (x:A) B( x )
Γ, x : A ` f ( x ) ≡ f 0 ( x ) : B( x )
Γ, x : A ` b( x ) : B( x )
β.
Γ, x : A ` (λy.b(y))( x ) ≡ b( x ) : B( x )
Γ ` f : ∏ (x:A) B( x )
η.
Γ ` λx. f ( x ) ≡ f : ∏ (x:A) B( x )
Γ ` A type Γ ` B type
Γ, x : A ` B type
Γ ` ∏ (x:A) B type
The result is the type of functions that take an argument of type A, and return a term of
type B. In other words, terms of the type ∏ (x:A) B are ordinary functions from A to B. We
write A → B for the type of functions from A to B. Sometimes we will also write B A for
the type A → B.
We give a brief summary of the rules specifying ordinary function types, omitting
the conversion rules. All of these rules can be derived easily from the corresponding
rules for Π-types.
Γ ` A type Γ ` B type
→
Γ ` A → B type
Γ ` B type Γ, x : A ` b( x ) : B Γ` f :A→B
λ ev
Γ ` λx. b( x ) : A → B Γ, x : A ` f ( x ) : B
Γ ` B type Γ, x : A ` b( x ) : B Γ` f :A→B
β η
Γ, x : A ` (λy. b(y))( x ) ≡ b( x ) : B Γ ` λx. f ( x ) ≡ f : A → B
Γ ` A type
Γ, x : A ` x : A
Γ ` id A :≡ λx. x : A → A
Note that we have used the symbol ≡ in the conclusion to define the identity function.
A judgment of the form Γ ` a :≡ b : A should be read as "b is a well-defined term of type
A in context Γ, and we will refer to it as a".
Definition 2.3.2. For any three types A, B, and C in context Γ, there is a composition
operation
comp : ( B → C ) → (( A → B) → ( A → C )),
i.e., we can derive
Construction. The idea of the definition is to define comp( g, f ) to be the function λx. g( f ( x )).
The derivation we use to construct comp is as follows:
Γ ` B type Γ ` C type
Γ ` A type Γ ` B type Γ, g : CB, y : B ` g(y) : C
Γ, f : BA, x : A ` f (x) : B Γ, g : CB, f : BA, y : B ` g(y) : C
Γ, g : CB, f : BA, x : A ` f (x) : B Γ, g : CB, f : BA, x : A, y : B ` g(y) : C
Γ, g : C B , f : B A , x : A ` g( f ( x )) : C
Γ, g : C B , f : B A ` λx. g( f ( x )) : C A
Γ, g : B → C ` λ f . λx. g( f ( x )) : B A → C A
Γ ` comp :≡ λg. λ f . λx. g( f ( x )) : C B → ( B A → C A )
The rules of function types can be used to derive the laws of a category for functions,
i.e., we can derive that function composition is associative and that the identity function
satisfies the unit laws. In the remainder of this section we will give these derivations.
Γ`g:B→C
Γ` f :A→B Γ, y : B ` g(y) : C Γ`h:C→D
Γ, x : A ` f ( x ) : B Γ, x : A, y : B ` g(y) : C Γ, z : C ` h(z) : D
Γ, x : A ` g( f ( x )) : C Γ, x : A, z : C ` h(z) : D
Γ, x : A ` h( g( f ( x ))) : D
Γ, x : A ` h( g( f ( x ))) ≡ h( g( f ( x ))) : D
Γ, x : A ` (h ◦ g)( f ( x )) ≡ h(( g ◦ f )( x )) : D
Γ, x : A ` ((h ◦ g) ◦ f )( x ) ≡ (h ◦ ( g ◦ f ))( x ) : D
Γ ` (h ◦ g) ◦ f ≡ h ◦ ( g ◦ f ) : A → D.
Lemma 2.3.4. Composition of functions satisfies the left and right unit laws, i.e., we can derive
Γ` f :A→B
Γ ` idB ◦ f ≡ f : A → B
and
Γ` f :A→B
Γ ` f ◦ id A ≡ f : A → B
12 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
Γ ` B type
Γ` f :A→B Γ, y : B ` idB (y) ≡ y : B
Γ, x : A ` f ( x ) : B Γ, x : A, y : B ` idB (y) ≡ y : B
Γ, x : A ` idB ( f ( x )) ≡ f ( x ) : B
Γ, x : A ` (idB ◦ f )( x ) ≡ f ( x ) : B
Γ ` idB ◦ f ≡ f : A → B
The right unit law is left as Exercise 2.1.
Exercises
2.1 Give a derivation for the right unit law of Lemma 2.3.4.
2.2 Show that the rule
Γ, x : A ` b( x ) : B( x )
λ-x 0 /x
Γ ` λx. b( x ) ≡ λx 0 . b( x 0 ) : ∏ (x:A) B( x )
is admissible for any variable x 0 that does not occur in the context Γ, x : A.
2.3 (a) Construct the constant function
Γ ` A type
Γ, y : B ` consty : A → B
(b) Show that
Γ` f :A→B
Γ, z : C ` constz ◦ f ≡ constz : A → C
(c) Show that
Γ ` A type Γ`g:B→C
Γ, y : B ` g ◦ consty ≡ constg(y) : A → C
2.4 In this exercise we generalize the composition operation of non-dependent function
types:
(a) Define a composition operation for dependent function types
Γ ` f : ∏ (x:A) B( x ) Γ ` g : ∏ (x:A) ∏ (y:B(x)) C ( x, y)
Γ` g ◦0 f : ∏ (x:A) C ( x, f ( x ))
and show that this operation agrees with ordinary composition when it is
specialized to non-dependent function types.
(b) Show that composition of dependent functions agrees with ordinary compo-
sition of functions:
Γ` f :A→B Γ`g:B→C
Γ ` (λx. g) ◦ f ≡ g ◦ f : A → C
0
Γ ` f : ∏ (x:A) B( x )
Γ ` (λx. f ) ◦0 id A ≡ f : ∏ (x:A) B( x )
(e) Show that composition of dependent functions satisfies the left unit law:
Γ ` f : ∏ (x:A) B( x )
Γ ` (λx. idB(x) ) ◦0 f ≡ f : ∏ (x:A) B( x )
2.5 (a) Given two types A and B in context Γ, and a type C in context Γ, x : A, y : B,
define the swap function
Γ ` σ : ∏ (x:A) ∏ (y:B) C ( x, y) → ∏ (y:B) ∏ (x:A) C ( x, y)
“The primary concern of mathematics is number, and this means the positive
integers. We feel about number the way Kant felt about space. The positive
integers and their arithmetic are presupposed by the very nature of our
intelligence and, we are tempted to believe, by the very nature of intelligence
in general. The development of the theory of the positive integers from
the primitive concept of the unit, the concept of adjoining a unit, and the
process of mathematical induction carries complete conviction. In the words
of Kronecker, the positive integers were created by God. Kronecker would
have expressed it even better if he had said that the positive integers were
created by God for the benefit of man (and other finite beings). Mathematics
belongs to man, not to God. We are not interested in properties of the
positive integers that have no descriptive meaning for finite man. When a
man proves a positive integer to exist, he should show how to find it. If God
has mathematics of his own that needs to be done, let him do it himself.”
“Building on the positive integers, weaving a web of ever more sets and
ever more functions, we get the basic structures of mathematics: the ra-
tional number system, the real number system, the euclidean spaces, the
complex number system, the algebraic number fields, Hilbert space, the
classical groups, and so forth. Within the framework of these structures, most
mathematics is done. Everything attaches itself to number, and every math-
ematical statement ultimately expresses the fact that if we perform certain
computations within the set of positive integers, we shall get certain results.”
14 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
` 0N : N ` succN : N → N
Remark 3.1.1. We annotate the terms 0N and succN of type N with their type in the
subscript, as a reminder that 0N and succN are declared to be terms of type N, and not
of any other type. In the next chapter we will introduce the type Z of the integers, on
which we can also define a zero term 0Z , and a successor function succZ . These should
be distinguished from the terms 0N and succN . In general, we will make sure that every
term is given a unique name. In libraries of mathematics formalized in a computer proof
assistant it is also the case that every type must be given a unique name.
Needless to say, we want an induction principle to hold for the natural numbers in type
theory and we also want it to be possible to construct operations on the natural numbers
by recursion.
In dependent type theory we may think of a type family P over N as a predicate over
N. Especially after we introduce a few more type-forming operations, such as Σ-types
and identity types, it will become clear that the language of dependent type theory
expressive enough to find definitions of all of the standard concepts and operations
of elementary number theory in type theory. Many of those definitions, the ordering
relations ≤ and < for example, will make use of type dependency. Then, to prove that
P(n) ‘holds’ for all n we just have to construct a dependent function
∏ (n:N) P(n).
The induction principle for the natural numbers in type theory exactly states what
one has to do in order to construct such a dependent function, via the following inference
rule:
Γ, n : N ` P(n) type
Γ ` p 0 : P ( 0N )
Γ ` pS : ∏ (n:N) P(n) → P(succN (n))
N-ind
Γ ` indN ( p0 , pS ) : ∏ (n:N) P(n)
Just like for the usual induction principle of the natural numbers, there are two things
to be constructed given a type family P over N: in the base case we need to construct
a term p0 : P(0N ), and for the inductive step we need to construct a function of type
P(n) → P(succN (n)) for all n : N. And this comes at one immediate advantage:
induction and recursion in type theory are one and the same thing!
Remark 3.1.2. We might alternatively present the induction principle of N as the following
inference rule
Γ, n : N ` P(n) type
Γ ` indN : P(0N ) → ∏ (n:N) P(n) → P(succN (n)) → ∏ (n:N) P(n)
In other words, for any type family P over N there is a function indN that takes two
arguments, one for the base case and one for the inductive step, and returns a section
of P. Now it is justified to wonder: is this slightly different presentation of induction
equivalent to the previous presentation?
To see that indeed we get such a function from the induction principle (rule N-ind
above), we note that the induction principle is stated to hold in an arbitrary context Γ. So
let us wield the power of type dependency: by weakening and the variable rule we have
the following well-formed terms:
in context Γ. Therefore we see that it does not really matter whether we present the
induction principle of N in a more verbose way as an inference rule with the base case
and the inductive step as hypotheses, or as a function taking variables for the base case
and the inductive step as arguments.
Γ, n : N ` P(n) type
Γ ` p 0 : P ( 0N )
Γ ` pS : ∏ (n:N) P(n) → P(succN (n))
Γ ` indN ( p0 , pS , 0N ) ≡ p0 : P(0N )
Similarly, with the same hypotheses as for the computation rule for the base case, the
computation rule for the inductive step is
···
Γ, n : N ` indN ( p0 , pS , succN (n)) ≡ pS (n, indN ( p0 , pS , n)) : P(succN (n))
This completes the formal specification of N.
addN : N → (N → N)
satisfying addN (0N , n) ≡ n and addN (succN (m), n) ≡ succN (addN (m, n)). Usually we
will write n + m for addN (n, m).
add-succN (n, f ) : N → N,
The function add-0N : N → N is of course taken to be idN , since the result of adding
0 to n should be n.
Given n : N and a function f : N → N we define add-succN (n, f ) :≡ succN ◦ f . The
idea is that if f represents adding m, then add-succN (n, f ) should be adding one more
than f did.
Formal derivation. The derivation for the construction of add-succN looks as follows:
succN : NN g : N → N ` comp( g) : NN → NN
` comp(succN ) : NN → NN
n : N ` comp(succN ) : NN → NN
` add-succN :≡ λn. comp(succN ) : N → (NN → NN )
We combine this derivation with the induction principle of N to complete the construc-
tion of addition:
.. .. ..
. . .
n : N ` NN type ` add-0N :≡ idN : NN ` add-succN : N → (NN → NN )
` addN ≡ indN (add-0N , add-succN ) : N → NN
The asserted judgmental equalities then hold by the computation rules for N.
Remark 3.2.2. When we define a function f : ∏ (n:N) P(n), we will often do so just by
indicating its definition on 0N and its definition on succN (n), by writing
f (0N ) :≡ p0
f (succN (n)) :≡ pS (n, f (n)).
For example, the definition of addition on the natural numbers could be given as
addN (0N , n) :≡ n
addN (succN (m), n) :≡ succN (addN (m, n)).
This way of defining a function is called pattern matching. A more formal inductive
argument can be obtained from a definition by pattern matching if it is possible to obtain
from the expression pS (n, f (n)) a general dependent function
pS : ∏ (n:N) P(n) → P(succN (n)).
In practice this is usually the case. Computer proof assistants such as Agda have
sophisticated algorithms to allow for definitions by pattern matching.
Remark 3.2.3. By the computation rules for N it follows that
0N + n ≡ n, and succN (m) + n ≡ succN (m + n).
However, the rules that we provided so far are not sufficient to also conclude that n +
0N ≡ n and n + succN (m) ≡ succN (n + m). Nevertheless, once we have introduced the
identity type in §5 we will nevertheless be able to identify n + 0N with n, and n + succN (m)
with succN (n + m). See Exercise 5.5.
18 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
Exercises
3.1 Define the binary min and max functions
mulN : N → (N → N).
(i) The constructors tell what structure the inductive type comes equipped with.
There may any finite number of constructors, even no constructors at all, in the
specification of an inductive type.
(ii) The induction principle specifies the data that should be provided in order to
construct a section of an arbitrary type family over the inductive type.
(iii) The computation rules assert that the inductively defined section agrees on the
constructors with the data that was used to define the section. Thus, there is a
computation rule for every constructor.
The induction principle and computation rules can be generated automatically once the
constructors are specified, but it goes beyond the scope of our course to describe general
inductive types.
Definition 4.2.1. We define the unit type to be a closed type 1 equipped with a closed
term
? : 1,
satisfying the induction principle that for any type family of types P( x ) indexed by x : 1,
there is a term
ind1 : P(?) → ∏ (x:1) P( x )
for which the computation rule
ind1 ( p, ?) ≡ p
holds. Sometimes we write λ ? . p for ind1 ( p).
The induction principle can also be used to define ordinary functions out of the unit
type. Indeed, given a type A we can first weaken it to obtain the constant family over 1,
with value A. Then the induction principle of the unit type provides a function
ind1 : A → (1 → A).
In other words, by the induction principle for the unit type we obtain for every x : A a
function ptx :≡ ind1 ( x ) : 1 → A.
Definition 4.3.1. We define the empty type to be a type ∅ satisfying the induction
principle that for any family of types P( x ) indexed by x :, there is a term
ind∅ : ∏ (x:∅) P( x ).
The induction principle for the empty type can also be used to construct a function
∅→A
for any type A. Indeed, to obtain this function one first weakens A to obtain the constant
family over ∅ with value A, and then the induction principle gives the desired function.
Thus we see that from the empty type anything follows. Therefore, we we see that
anything follows from A, if we have a function from A to the empty type. This motivates
the following definition.
¬ A :≡ A → ∅.
02 : 2
12 : 2
satisfying the induction principle that for any family of types P( x ) indexed by x : 2,
there is a term
ind2 : P(02 ) → P(12 ) → ∏ (x:2) P( x )
ind2 ( p0 , p1 , 02 ) ≡ p0
ind2 ( p0 , p1 , 12 ) ≡ p1
hold.
Just as in the cases for the unit type and the empty type, the induction principle for
the booleans can also be used to construct an ordinary function 2 → A, provided that we
can construct two terms of type A. Indeed, by the induction principle for the booleans
there is a function
ind2 : A → ( A → A2 )
for any type A.
Example 4.4.2. Using the induction principle of 2 we can define all the operations of
Boolean algebra. For example, the boolean negation operation neg2 : 2 → 2 is defined
by
12 ∧ 12 : ≡ 12 02 ∧ 12 : ≡ 02
12 ∧ 02 : ≡ 02 02 ∧ 02 : ≡ 02 .
12 ∨ 12 : ≡ 12 02 ∨ 12 : ≡ 12
12 ∨ 02 : ≡ 12 02 ∨ 02 : ≡ 02 .
We leave the definitions of some of the other boolean operations as Exercise 4.3. Note
that the method of defining the boolean operations by the induction principle of 2 is not
that different from defining them by truth tables.
Boolean logic is important, but it won’t be very prominent in this course. The reason
is simple: in type theory it is more natural to use the ‘logic’ of types that is provided by
the inference rules.
4. MORE INDUCTIVE TYPES 21
inl : A → A + B
inr : B → A + B
satisfying the induction principle that for any family of types P( x ) indexed by x : A + B,
there is a term
ind+ : ∏ (x:A) P(inl( x )) → ∏ (y:B) P(inr(y)) → ∏ (z:A+ B) P(z)
ind+ ( f , g, inl( x )) ≡ f ( x )
inr+( f , g, inr(y)) ≡ g(y)
( P → Q) → ( P0 → Q) → ( P ∨ P0 → Q) .
Indeed, we can think of propositions as types and of terms as their constructive proofs.
Under this interpretation of type theory the coproduct is indeed the disjunction.
An important example of a type that can be defined using coproducts is the type Z
of integers.
Definition 4.5.2. We define the integers to be the type Z :≡ N + (1 + N). The type of
integers comes equipped with inclusion functions of the positive and negative integers
−1Z :≡ in-neg(0)
0Z :≡ inr(inl(?))
1Z :≡ in-pos(0).
In the following lemma we derive an induction principle for Z, which can be used in
many familiar constructions on Z, such as in the definitions of addition and multiplica-
tion.
22 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
p−1 : P(−1Z )
p−S : ∏ (n:N) P(in-neg(n)) → P(in-neg(succN (n)))
p 0 : P ( 0Z )
P1 : P(1Z )
PS : ∏ (n:N) P(in-pos(n)) → P(in-pos(succN (n))),
then we can construct a dependent function f : ∏ (k:Z) P(k ) for which the following judgmental
equalities hold:
f (−1Z ) ≡ p−1
f (in-neg(succN (n))) ≡ p−S (n, f (in-neg(n)))
f ( 0Z ) ≡ p 0
f (1Z ) ≡ p1
f (in-pos(succN (n))) ≡ pS (n, f (in-pos(n))).
Note that in-neg ≡ inl and −1Z ≡ in-neg(0N ). In order to define pinl we use induction
on the natural numbers, so it suffices to define
p−1 : P(−1)
p−S : ∏ (n:N) P(in-neg(n)) → P(in-neg(succN (n))).
Definition 4.5.4. We define the successor function on the integers succZ : Z → Z using
the induction principle of Lemma 4.5.3, taking
succZ (−1Z ) :≡ 0N
succZ (in-neg(succN (n))) :≡ in-neg(n)
succZ (0Z ) :≡ 1N
succZ (1Z ) :≡ in-pos(1N )
succZ (in-pos(succN (n))) :≡ in-pos(succN (succN (n))).
4. MORE INDUCTIVE TYPES 23
The induction principle for ∑(x:A) B( x ) asserts that for any family of types P( p) indexed
by p : ∑(x:A) B( x ), there is a function
indΣ : ∏ (x:A) ∏ (y:B(x)) P( x, y) → ∏ ( p:∑(x:A) B(x)) P( p) .
is defined by induction as
pr1 :≡ λ( x, y). x.
The second projection map is a dependent function
pr2 : ∏ ( p:∑(x:A) B(x)) B(pr1 ( p))
defined by induction as
pr2 :≡ λ( x, y). y.
By the computation rule we have
pr1 ( x, y) ≡ x
pr2 ( x, y) ≡ y.
Definition 4.7.1. Consider two types A and B. The (cartesian) product of A and B is
defined as the inductive type A × B with constructor
( –, – ) : A → ( B → A × B).
The induction principle for A × B asserts that for any type family P over A × B, one has
ind× : ∏ (x:A) ∏ (y:B) P( a, b) → ∏ ( p:A× B) P( p)
The projection maps are defined similarly to the projection maps of Σ-types. When
one thinks of types as propositions, then A × B is interpreted as the conjunction of A
and B.
Exercises
4.1 Write the rules for 1, ∅, 2, A + B, ∑(x:A) B( x ), and A × B. As usual, present the
rules in four sets:
(i) A formation rule.
(ii) Introduction rules.
(iii) An elimination rule.
(iv) Computation rules.
4.2 Let A be a type.
(a) Show that ( A + ¬ A) → (¬¬ A → A).
(b) Show that ¬¬¬ A → ¬ A.
4.3 Define the following operations of Boolean algebra:
addZ : Z → (Z → Z)
negZ : Z → Z,
mulZ : Z → (Z → Z).
4. EXERCISES 25
4.6 Construct a function F : Z → Z that extends the Fibonacci sequence to the negative
integers
. . . , 5, −3, 2, −1, 1, 0, 1, 1, 2, 3, 5, 8, 13, . . .
in the expected way.
4.7 Show that 1 + 1 satisfies the same induction principle as 2, i.e., define
t0 : 1 + 1
t1 : 1 + 1,
and show that for any type family P over 1 + 1 there is a function
ind1+1 : P(t0 ) → P(t1 ) → ∏ (t:1+1) P(t)
satisfying
ind1+1 ( p0 , p1 , t0 ) ≡ p0
ind1+1 ( p0 , p1 , t1 ) ≡ p1 .
In other words, type theory cannot distinguish between the types 2 and 1 + 1.
4.8 For any type A we can define the type list( A) of lists elements of A as the inductive
type with constructors
nil : list( A)
cons : A → (list( A) → list( A)).
(a) Write down the induction principle and the computation rules for list( A).
(b) Let A and B be types, suppose that b : B, and consider a binary operation
µ : A → ( B → B). Define a function
fold-list(µ) : list( A) → B
5 Identity types
From the perspective of types as proof-relevant propositions, how should we think of
equality in type theory? Given a type A, and two terms x, y : A, the equality x = y should
again be a type. Indeed, we want to use type theory to prove equalities. Dependent
type theory provides us with a convenient setting for this: the equality type x = y is
dependent on x, y : A.
Then, if x = y is to be a type, how should we think of the terms of x = y. A term
p : x = y witnesses that x and y are equal terms of type A. In other words p : x = y is an
identification of x and y. In a proof-relevant world, there might be many terms of type
x = y. I.e., there might be many identifications of x and y. And, since x = y is itself a
type, we can form the type p = q for any two identifications p, q : x = y. That is, since
x = y is a type, we may also use the type theory to prove things about identifications (for
instance, that two given such identifications can themselves be identified), and we may
use the type theory to perform constructions with them. As we will see shortly, we can
give every type a groupoidal structure.
Clearly, the equality type should not just be any type dependent on x, y : A. Then
how do we form the equality type, and what ways are there to use identifications in
constructions in type theory? The answer to both these questions is that we will form
the identity type as an inductive type, generated by just a reflexivity term providing
an identification of x to itself. The induction principle then provides us with a way of
performing constructions with identifications, such as concatenating them, inverting
them, and so on. Thus, the identity type is equipped with a reflexivity term, and further
possesses the structure that are generated by its induction principle and by the type
theory. This inductive construction of the identity type is elegant, beautifully simple, but
far from trivial!
The situation where two terms can be identified in possibly more than one way
is analogous to the situation in homotopy theory, where two points of a space can be
connected by possibly more than one path. Indeed, for any two points x, y in a space,
there is a space of paths from x to y. Moreover, between any two paths from x to y there is
a space of homotopies between them, and so on. This leads to the homotopy interpretation
of type theory, outlined in Table I.1. The connection between homotopy theory and type
theory been made precise by the construction of homotopical models of type theory, and
it has led to the fruitful research area of synthetic homotopy theory, the subfield of homotopy
type theory that is the topic of this course.
5. IDENTITY TYPES 27
refla : a = A a.
The induction principle of the identity type postulates that for any family of types P( x, p)
indexed by x : A and p : a = A x, there is a function
Remark 5.1.2. We see that the identity type is not just an inductive type, like the inductive
types N, ∅, and 1 for example, but it is and inductive family of types. Even though we
have a type a = A x for any x : A, the constructor only provides a term refla : a = A a,
identifying a with itself. The induction principle then asserts that in order to prove
something about all identifications of a with some x : A, it suffices to prove this assertion
about refla only. We will see in the next sections that this induction principle is strong
enough to derive many familiar facts about equality, namely that it is a symmetric and
transitive relation, and that all functions preserve equality.
Remark 5.1.3. Since the identity types require getting used to, we provide the formal
rules for identity types. The identity type is formed by the formation rule:
Γ`a:A
Γ, x : A ` a = A x type
The constructor of the identity type is then given by the introduction rule:
Γ`a:A
Γ ` refla : a = A a
The induction principle is now given by the elimination rule:
Γ`a:A Γ, x : A, p : a = A x ` P( x, p) type
Γ ` path-inda : P( a, refla ) → ∏ (x:A) ∏ ( p:a= A x) P( x, p)
Γ`a:A Γ, x : A, p : a = A x ` P( x, p) type
Γ ` path-inda ( p, a, refla ) ≡ p : P( a, refla )
28 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
Remark 5.1.4. One might wonder whether it is also possible to form the identity type at a
variable of type A, rather than at a term. This is certainly possible: since we can form the
identity type in any context, we can form the identity type at a variable x : A as follows:
Γ, x : A ` x : A
Γ, x : A, y : A ` x = A y type
In this way we obtain the ‘binary’ identity type. Its constructor is then also indexed by
x : A. We have the following introduction rule
Γ, x : A ` x : A
Γ, x : A ` reflx : x = A x
To obtain a term of the asserted type we need to swap the order of the arguments
p : x = y and z : A, using Exercise 2.5.
inv : ∏ (x,y:A) ( x = y) → (y = x ).
The next question is whether the concatenation and inverting operations on paths
behave as expected. More concretely, is path concatenation associative, does it satisfy
the unit laws, and is the inverse of a path indeed a two-sided inverse?
For example, in the case of associativity we are asking to compare the paths
( p q) r and p (q r )
for any p : x = y, q : y = z, and r : z = w in a type A. The computation rules of path
induction are not strong enough to conclude that ( p q) r and p (q r ) are judgmentally
equal. However, both ( p q) r and p (q r ) are terms of the same type: they are
identifications of type x = w. Since the identity type is a type like any other, we can ask
whether there is an identification
( p q ) r = p ( q r ).
This is a very useful idea: while it is often impossible to show that two terms of the same
type are judgmentally equal, it may be the case that those two terms can be identified.
Indeed, we identify two terms by constructing a term of the identity type, and we can use
all the type theory at our disposal in order to construct such a term. In this way we can
show, for example, that addition on the natural numbers or on the integers is associative
and satisfies the unit laws. And indeed, here we will show that path concatenation is
associative and satisfies the unit laws.
Definition 5.2.3. Let A be a type and consider three consecutive paths
p q r
x y z w
5.4 Transport
Dependent types also come with an action on paths: the transport functions. Given an
identification p : x = y in the base type A, we can transport any term b : B( x ) to the
fiber B(y). The transport functions have many applications, which we will encounter
throughout this course.
Definition 5.4.1. Let A be a type, and let B be a type family over A. We will construct a
transport operation
tr B : ∏ (x,y:A) ( x = y) → ( B( x ) → B(y)).
tr B (reflx ) :≡ idB(x) .
32 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
Thus we see that type theory cannot distinguish between identified terms x and y,
because for any type family B over A one gets a term of B(y) as soon as B( x ) has a term.
As an application of the transport function we construct the dependent action on paths
of a dependent function f : ∏ (x:A) B( x ). Note that for such a dependent function f ,
and an identification p : x = A y, it does not make sense to directly compare f ( x ) and
f (y), since the type of f ( x ) is B( x ) whereas the type of f (y) is B(y), which might not be
exactly the same type. However, we can first transport f ( x ) along p, so that we obtain
the term tr B ( p, f ( x )) which is of type B(y). Now we can ask whether it is the case that
tr B ( p, f ( x )) = f (y). The dependent action on paths of f establishes this identification.
Exercises
5.1 (a) State Goldbach’s Conjecture in type theory.
(b) State the Twin Prime Conjecture in type theory.
5.2 Show that the operation inverting paths distributes over the concatenation opera-
tion, i.e., construct an identification
inv-con( p, q, r ) : ( p q = r ) → (q = p−1 r )
con-inv( p, q, r ) : ( p q = r ) → ( p = r q−1 ).
5.4 Let B be a type family over A, and consider a path p : x = x 0 in A. Construct for
any y : B( x ) a path
liftB ( p, y) : ( x, y) = ( x 0 , tr B ( p, y)).
In other words, a path in the base type A lifts to a path in the total space ∑(x:A) B( x )
for every term over the domain, analogous to the path lifting property for fibrations
in homotopy theory.
5.5 Show that the operations of addition and multiplication on the natural numbers
satisfy the laws of a commutative semi-ring:
m + (n + k) = (m + n) + k m · (n · k) = (m · n) · k
m+0 = m m·1 = m
0+m = m 1·m = m
6. TYPE THEORETIC UNIVERSES 33
in a type A. In this exercise we will show that the Mac Lane pentagon for identifi-
cations commutes.
(a) Construct the five identifications α1 , . . . , α5 in the pentagon
α4
(( p q) r ) s ( p q ) (r s )
α1 α5
( p (q r )) s p (q (r s)),
α2 α3
p ((q r ) s)
x : 2 ` T ( P( x )) type
every m, n : N, unlike judgmental equality. Therefore we can use type theory to reason
about observational equality on N. Indeed, in the exercises we show that some very
elementary mathematics can already be done at this early stage in our development of
type theory.
A second reason to introduce universes is that it allows us to define many types
of types equipped with structure. One of the most important examples is the type of
groups, which is the type of types equipped with the group operations satisfying the
group laws, and for which the underlying type is a set. We won’t discuss the condition
for a type to be a set until §10, so the definition of groups in type theory will be given
much later. Therefore we illustrate this use of the universe by giving simpler examples:
pointed types, graphs, and reflexive graphs.
One of the aspects that make universes useful is that they are postulated to be closed
under all the type constructors. For example, if we are given X : U and P : T ( X ) → U ,
then the universe is equipped with a term
Σ̌( X, P) : U
satisfying the judgmental equality T (Σ̌( X, P) ≡ ∑(x:T (X )) T ( P( x )). We will similarly
assume that any universe is closed under Π-types and the other ways of forming types.
However, there is an important restriction: it would be inconsistent to assume that the
universe is contained in itself. One way of thinking about this is that universes are types
of small types, and it cannot be the case that the universe is small with respect to itself.
We address this problem by assuming that there are many universes: enough universes
so that any type family can be obtained by substituting into the universal type family of
some universe.
(iii) U is closed under identity types, in the sense that it comes equipped with a function
Ǐ : ∏ (X:U ) T ( X ) → (T ( X ) → U )
(iv) U is closed under coproducts, in the sense that it comes equipped with a function
+̌ : U → (U → U )
that satisfies T X +̌Y ≡ T ( X ) + T (Y ).
ˇ 1̌, Ň : U that satisfy the judgmental equalities
(v) U contains terms ∅,
T ∅ ˇ ≡∅
T 1̌ ≡ 1
T (Ň) ≡ N.
holds. If A is small with respect to U , we usually write simply A for Ǎ and also A for
T ( Ǎ). In other words, by A : U we mean that A is a small type.
Remark 6.1.2. Since ordinary function types are defined as a special case of dependent
function types, we don’t have to assume that universes are closed under ordinary
function types. Similarly, it follows from the assumption that universes are closed under
dependent pair types that universes are closed under cartesian product types.
R := { x ∈ S | x ∈
/ x }.
a universe that contains a term Ǔ : U such that T Ǔ ≡ U . In order to avoid such
paradoxes, Russell and Whitehead formulated the ramified theory of types in their book
Principia Mathematica. The ramified theory of types is a precursor of Martin Löf’s type
theory that we are studying in this course.
Even though the universe is not a term of itself, it is still convenient if every type,
including any universe, is small with respect to some universe. Therefore we will assume
that there are sufficiently many universes: we will assume that for every finite list of
types
Γ1 ` A1 type
..
.
Γn ` An type,
there is a universe U that contains each Ai in the sense that U comes equipped with a
term
Γi ` Ǎi : U
holds. With this assumption it will rarely be necessary to work with more than one
universe at the same time.
Remark 6.2.1. Using the assumption that for any finite list of types in context there is a
universe that contains those types, we obtain many specific universes:
(i) There is a base universe U0 that we obtain using the empty list of types in context.
This is a universe, but it isn’t specified to contain any further types.
Γ1 ` A1 type
..
.
Γn ` An type,
` U type
X : U ` T ( X ) type.
Note that since the universe U + contains all the types in U , it also contains the
types A1 , . . . , An . To see this, we derive that there is a code for Ai in U + .
6. TYPE THEORETIC UNIVERSES 37
X : U ` Ť ( X ) : U +
Γi ` Ǎi : U Γi , X : U ` Ť ( X ) : U +
Γi ` Ť ( Ǎi ) : U +
T + (Ť ( Ǎi )) ≡ Ai .
Γ1 ` A1 type ∆1 ` B1 type
.. ..
. .
Γn ` An type ∆m ` Bm type
X : U ` TU ( X ) type
Y : V ` TV (Y ) type.
Since we don’t postulate any relations between the universes, there are indeed very few
of them. For example, the base universe U0 might contain many more types than it is
postulated to contain. Nevertheless, there are some relations between the universes. For
instance, there is a function U → U + , since we can simply derive
X : U ` Ť ( X ) : U +
` λX. Ť ( X ) : U → U +
Similarly, there are functions U → U t V and V → U t V for any two universes U and
V.
U∗ :≡ ∑(X:U ) X.
38 CHAPTER I. MARTIN-LÖF’S DEPENDENT TYPE THEORY
Definition 6.3.2. Consider two pointed types ( A, a) and ( B, b). A pointed map from
( A, a) to ( B, b) is a pair ( f , p) consisting of a function f : A → B and an identification
p : f ( a) = b. We write
A →∗ B :≡ ∑( f :A→ B) f ( a) = b
for the type of all pointed maps from ( A, a) to ( B, b), leaving the base point implicit.
Since we have a type U∗ of all pointed types in a universe U , we can start defining
operations on U∗ . An important example of such an operation is to take the loop space
of a pointed type.
Ω( A, a) :≡ ( a = a), refla .
We can even go further and define the iterated loop space of a pointed type. Note that
this definition could not be given in type theory if we didn’t have universes.
Definition 6.3.4. Given a pointed type ( A, a) and a natural number n, we define the n-th
loop space Ωn ( A, a) by induction on n : N, taking
Ω0 ( A, a) :≡ ( A, a)
Ωn+1 ( A, a) :≡ Ω(Ωn ( A, a)).
Definition 6.4.1. We define the type family Fin : N → U of finite types by induction on
N, taking
Fin(0N ) :≡ ∅
Fin(succN (n)) :≡ Fin(n) + 1
Similarly, we can define many relations on the natural numbers using a universe. We
give here the example of observational equality on N. This inductively defined equivalence
relation is very important, as it can be used to show that equality on the natural numbers
is decidable, i.e., there is a program that decides for any two natural numbers m and n
whether they are equal or not.
E0 : N → U
ES : N → (N → U ) → (N → U )
We define E0 by induction, taking E00 :≡ 1 and E0S (n, X, m) :≡ ∅. The resulting family
E0 satisfies
E0 (0N ) ≡ 1
E0 (succN (n)) ≡ ∅.
We define ES by induction, taking ES0 :≡ ∅ and ES0 (n, X, m) :≡ X (m). The resulting
family ES satisfies
ES (n, X, 0N ) ≡ ∅
ES (n, X, succN (m)) ≡ X (m)
Therefore we have by the computation rule for the first induction that the judgmental
equality
We can also define observational equality for many other kinds of types, such as 2 or
Z. In each of these cases, what sets the observational equality apart from other relations
is that it is the least reflexive relation.
Exercises
6.1 Show that observational equality on N is an equivalence relation, i.e., construct
terms of the following types:
(b) Show that N satisfies ordinal induction, i.e., construct for any type family P
over N a function of type
∏ (k:N) ∏ (m:N) (m < k ) → P(m) → P(k ) → ∏ (n:N) P(n).
Chapter II
7 Equivalences
7.1 Homotopies
In homotopy type theory, a homotopy is just a pointwise equality between two functions
f and g. We view the type of homotopies as the observational equality for Π-types.
Definition 7.1.1. Let f , g : ∏ (x:A) P( x ) be two dependent functions. The type of homo-
topies from f to g is defined as
f ∼ g :≡ ∏ (x:A) f ( x ) = g( x ).
∏ (x:A) H ( x ) = K ( x ).
Definition 7.1.2. For any type family B over A there are operations
htpy-assoc( H, K, L) : ( H K ) L ∼ H (K L)
htpy-left-unit( H ) : htpy-refl f H ∼ H
41
42 CHAPTER II. BASIC CONCEPTS OF TYPE THEORY
htpy-right-unit( H ) : H htpy-reflg ∼ H
htpy-left-inv( H ) : H −1 H ∼ htpy-reflg
htpy-right-inv( H ) : H H −1 ∼ htpy-refl f
for any H : f ∼ g, K : g ∼ h and L : h ∼ i, where f , g, h, i : ∏ (x:A) B( x ).
Construction. We define
htpy-refl( f ) :≡ λx. refl f (x)
htpy-inv( H ) :≡ λx. H ( x )−1
htpy-concat( H, K ) :≡ λx. H ( x ) K ( x ),
where H : f ∼ g and K : g ∼ h are homotopies. Furthermore, we define
f g
X
commutes if it comes equipped with a homotopy H : f ∼ g ◦ h, and we say that a square
g
A A0
f f0
B B0
h
retr( f ) :≡ ∑(h:B→ A) h ◦ f ∼ id A .
g:B→A h:B→A
G : f ◦ g ∼ idB H : h ◦ f ∼ id A .
Clearly, if f has an inverse in the sense that it comes equipped with a function g : B → A
such that f ◦ g ∼ idB and g ◦ f ∼ id A , then f is an equivalence. We write
Lemma 7.2.3. Any equivalence e : A ' B can be given the structure of an invertible map. We
define e−1 to be the section g : B → A of e.
Proof. First we construct for any equivalence f with right inverse g and left inverse h a
homotopy K : g ∼ h. For any y : B, we have
K ( f ( x )) H (x)
g f (x) h f (x) x.
Remark 7.2.5. For any type A, the identity function id A is an equivalence, since it is its
own section and its own retraction
Example 7.2.6. For any type C ( x, y) indexed by x : A and y : B, the swap function
σ : ∏ (x:A) ∏ (y:B) C ( x, y) → ∏ (y:B) ∏ (x:A) C ( x, y)
that swaps the order of the arguments x and y is an equivalence by Exercise 2.5.
(ii) Then we will show that this binary relation is reflexive, by constructing a term of
type
∏ (x:A) R( x, x )
(iii) Using the reflexivity we will show that there is a canonical map
( x = y) → R( x, y)
for every x, y : A. This map is just constructed by path induction, using the
reflexivity of R.
( x = y) → R( x, y)
The last step is usually the most difficult, and we will refine our methods for this step in
§9, where we establish the fundamental theorem of identity types.
In this section we consider a type family B over A. Given two pairs
( x, y), ( x 0 , y0 ) : ∑(x:A) B( x ),
tr B (α, y) = y0 .
by defining
EqΣ (s, t) :≡ ∑(α:pr1 (s)=pr1 (t)) tr B (α, pr2 (s)) = pr2 (t).
Definition 7.3.3. Consider a type family B over A. Then for any s, t : ∑(x:A) B( x ) we
define a map
pair-eq : (s = t) → EqΣ (s, t)
by path induction, taking pair-eq(refls ) :≡ reflexive-EqΣ (s).
A map of this type is again defined by Σ-induction. Thus it suffices to define a dependent
function of type
∏ ( p:x= x0 ) (tr B ( p, y) = y0 ) → (( x, y) = ( x 0 , y0 )).
Such a dependent function is defined by double path induction by sending (reflx , refly )
to refl(x,y) . This completes the definition of the function eq-pair.
Next, we must show that eq-pair is a section of pair-eq. In other words, we must
construct an identification
By the definition of eq-pair we have eq-pair(reflx , refly ) ≡ refl(x,y) , and by the definition
of pair-eq we have pair-eq(refl(x,y) ) ≡ (reflx , refly ). Thus we may take refl(reflx ,refly ) to
complete the construction of the homotopy pair-eq ◦ eq-pair ∼ id.
To complete the proof, we must show that eq-pair is a retraction of pair-eq. In other
words, we must construct an identification
eq-pair(pair-eq( p)) = p
Exercises
7.1 Show that the functions
inv : ( x = y) → (y = x )
concat( p) : (y = z) → ( x = z)
concat0 (q) : ( x = y) → ( x = z)
tr B ( p) : B( x ) → B(y)
inl : X → X + ∅ pr1 : ∅ × X → ∅
inr : X → ∅ + X pr2 : X × ∅ → ∅
are equivalences.
7.3 (a) Consider two functions f , g : A → B and a homotopy H : f ∼ g. Then
(b) Show that for any two homotopic equivalences e, e0 : A ' B, their inverses
are also homotopic.
7. EXERCISES 47
f g
X.
with H : f ∼ g ◦ h.
(a) Suppose that the map h has a section s : B → A. Show that the triangle
s
B A
g f
X.
commutes, and that f has a section if and only if g has a section.
(b) Suppose that the map g has a retraction r : X → B. Show that the triangle
f
A X
h r
B.
commutes, and that f has a retraction if and only if h has a retraction.
(c) (The 3-for-2 property for equivalences.) Show that if any two of the functions
f, g, h
are equivalences, then so is the third.
7.5 (a) Show that the negation function on the booleans neg2 : 2 → 2 defined in
Example 4.4.2 is an equivalence.
(b) Use the observational equality on the booleans, defined in Exercise 6.5, to
show that 02 6= 12 .
(c) Show that for any b : 2, the constant function constb is not an equivalence.
7.6 Show that the successor function on the integers is an equivalence.
7.7 Construct a equivalences A + B ' B + A and A × B ' B × A.
7.8 Consider a section-retraction pair
i r
A B A,
7.11 In this exercise we will show that the laws for abelian groups hold for addition
on the integers. Note: these are obvious facts, but the proof terms that show how
the group laws hold are nevertheless fairly involved. This exercise is perfect for a
formalization project.
(a) Show that addition satisfies the left and right unit laws, i.e., construct terms
left-unit-law-add-Z : ∏ (x:Z) 0 + x = x
right-unit-law-add-Z : ∏ (x:Z) x + 0 = x.
(b) Show that addition respects predecessors and successor on both sides, i.e.,
construct terms
assoc-add-Z : ∏ (x,y,z:Z) ( x + y) + z = x + (y + z)
comm-add-Z : ∏ (x,y:Z) x + y = y + x.
left-inverse-law-add-Z : ∏ (x:Z) (− x ) + x = 0
right-inverse-law-add-Z : ∏ (x:Z) x + (− x ) = 0.
f + g : A + B → A0 + B0 .
H + K : ( f + g ) ∼ ( f 0 + g 0 ).
8. CONTRACTIBLE TYPES AND CONTRACTIBLE MAPS 49
( f 0 ◦ f ) + ( g 0 ◦ g ) ∼ ( f 0 + g 0 ) ◦ ( f ◦ g ).
(e) Show that if f and g are equivalences, then so is f + g. (The converse of this
statement also holds, see Exercise 9.5.)
7.13 Construct equivalences
Remark 8.1.2. Suppose A is a contractible type with center of contraction c and contraction
C. Then the type of C is (judgmentally) equal to the type
constc ∼ id A .
In other words, the contraction C is a homotopy from the constant function to the identity
function.
Example 8.1.3. The unit type is easily seen to be contractible. For the center of contraction
we take ? : 1. Then we define a contraction ∏ (x:1) ? = x by the induction principle of 1.
Applying the induction principle, it suffices to construct a term of type ? = ?, for which
we just take refl? .
Definition 8.1.4. Suppose A comes equipped with a term a : A. Then we say that A
satisfies singleton induction if for every type family B over A, the map
ev-pt : ∏ (x:A) B( x ) → B( a)
sing-inda : B( a) → ∏ (x:A) B( x )
sing-compa : ev-pt ◦ sing-inda ∼ id
Example 8.1.5. Note that the singleton induction principle is almost the same as the
induction principle for the unit type, the difference being that the "computation rule" in
the singleton induction for A is stated using an identification rather than as a judgmental
equality. The unit type 1 comes equipped with a function
for every type family B over 1, satisfying the judgmental equality ind1 (b, ?) ≡ b for every
b : B(?) by the computation rule. Thus we easily obtain the homotopy
(ii) The type A comes equipped with a term a : A, and satisfies singleton induction.
sing-inda (b) :≡ tr B (C ( x ), b) : B( x ).
apλω. tr
B (ω,b)
( p) reflb
tr B (C (c), b) tr B (reflc , b) b.
sing-inda : a = a → ∏ (x:A) a = x.
∑(x:A) a = x
is contractible.
Proof. We will prove the statement by showing that ∑(y:A) x = y satisfies singleton
induction, and then use Theorem 8.1.6 to conclude that ∑(x:A) a = x is contractible. We
will use the term ( a, refla ) : ∑(x:A) a = x as the center of contraction.
Now let P be a type family over ∑(x:A) a = x. Note that we have a commuting
triangle
ev-pair
∏ (t:∑(x:A) a= x) P(t) ∏ (x:A) ∏ ( p:a= x) P( x, p)
ev-pt ev-refl
P( a, refla )
f 7→ λx. λp. f ( x, p)
52 CHAPTER II. BASIC CONCEPTS OF TYPE THEORY
g 7→ g( a, refla ),
respectively. By the induction principle for Σ-types it follows that ev-pair has a section,
and by path induction it follows that ev-refl has a section. Therefore it follows from
Exercise 7.4 that the composite ev-pt has a section.
In other words, the fiber of f at b is the type of a : A that get mapped by f to b. One
may think of the fiber as a type theoretic version of the pre-image of a point.
It will be useful to have a characterization of the identity type of a fiber, so we will
make such a characterization immediately.
Definition 8.2.2. Let f : A → B be a map, and let ( x, p), ( x 0 , p0 ) : fib f (y) for some y : B.
Then we define
The relation Eq-fib f : fib f (y) → fib f (y) → U is a reflexive relation, since we have
(( x, p) = ( x 0 , p0 )) → Eq-fib f (( x, p), ( x 0 , p0 ))
induced by the reflexivity of Eq-fib f is an equivalence for any ( x, p), ( x 0 , p0 ) : fib f (y).
Eq-fib f (( x, p), ( x 0 , p0 )) → (( x, p) = ( x 0 , p0 ))
is easily defined by Σ-induction, and then path induction twice. The homotopies witness-
ing that this converse map is indeed a right inverse as well as a left inverse is similarly
constructed by induction.
Then we observe that both G · f and f · H are homotopies of the same type
f ◦ g ◦ f ∼ f.
A coherently invertible map is an invertible map for which there is a further homotopy
G · f ∼ f · H.
g:B→A
G : f ◦ g ∼ id
H : g ◦ f ∼ id
K : G · f ∼ f · H.
Although we will encounter the notion of coherently invertible map on some further
occasions, the following lemma is our main motivation for considering it.
g:B→A
G : f ◦ g ∼ id
H : g ◦ f ∼ id
K : G · f ∼ f · H,
and let y : B. Our goal is to show that fib f (y) is contractible. For the center of contraction
we take ( g(y), G (y)). In order to construct a contraction, it suffices to construct a term of
type
∏ (x:A) ∏ ( p: f (x)=y) Eq-fib f (( g(y), G (y)), ( x, p)).
By path induction on p : f ( x ) = y it suffices to construct a term of type
∏ (x:A) Eq-fib f (( g( f ( x )), G ( f ( x ))), ( x, refl f (x) )).
By definition of Eq-fib f , we have to construct a term of type
∏ (x:A) ∑(α:g( f (x))=x) G ( f ( x )) = ap f (α) refl f (x) .
Such a term is constructed as λx. ( H ( x ), K 0 ( x )), where the homotopy H : g ◦ f ∼ id is
given by assumption, and the homotopy
f (y) g(y)
H (y)
commutes. This square is also called the naturality square of the homotopy H at p.
8. CONTRACTIBLE TYPES AND MAPS 55
since ap f (reflx ) ≡ refl f (x) and apg (reflx ) ≡ reflg(x) , and since refl f (x) H ( x ) ≡ H ( x ), we
see that the path right-unit( H ( x ))−1 is of the asserted type.
H ( f ( x ))
f f (x) f (x)
ap f ( H ( x )) H (x)
f (x) x
H (x)
K : G 0 · f ∼ f · H.
G ( f g f ( x ))
f g f g f (x) f g f (x)
ap f ( H ( g f ( x ))) ap f ( H ( x ))
f g f (x) f (x)
G ( f ( x ))
G ( f g f ( x ))
f g f g f (x) f g f (x)
ap f g f ( H ( x )) ap f ( H ( x ))
f g f (x) f (x)
G ( f ( x ))
commutes. Now we observe that this is just a naturality square the homotopy G f :
f g f ∼ f , which commutes by Definition 8.3.3.
56 CHAPTER II. BASIC CONCEPTS OF TYPE THEORY
Now we put the pieces together to conclude that any equivalence has contractible
fibers.
Theorem 8.3.6. Any equivalence is a contractible map.
Proof. We have seen in Lemma 8.3.2 that any coherently invertible map is a contractible
map. Moreover, any equivalence has the structure of an invertible map by Lemma 7.2.3,
and any invertible map is coherently invertible by Lemma 8.3.5.
Corollary 8.3.7. Let A be a type, and let a : A. Then the type
∑(x:A) x = a
is contractible.
Proof. By Remark 7.2.5, the identity function is an equivalence. Therefore, the fibers of
the identity function are contractible by Theorem 8.3.6. Note that ∑(x:A) x = a is exactly
the fiber of id A at a : A.
Exercises
8.1 Show that if A is contractible, then for any x, y : A the identity type x = y is also
contractible.
8.2 Suppose that A is a retract of B. Show that
is-contr( B) → is-contr( A).
8.3 (a) Show that for any type A, the map const? : A → 1 is an equivalence if and
only if A is contractible.
(b) Apply Exercise 7.4 to show that for any map f : A → B, if any two of the
three assertions
(i) A is contractible
(ii) B is contractible
(iii) f is an equivalence
hold, then so does the third.
8.4 Show that for any two types A and B, the following are equivalent:
(i) Both A and B are contractible.
(ii) The type A × B is contractible.
8.5 Let A be a contractible type with center of contraction a : A. Furthermore, let B
be a type family over A. Show that the map y 7→ ( a, y) : B( a) → ∑(x:A) B( x ) is an
equivalence.
8.6 Let B be a family of types over A, and consider the projection map
pr1 : ∑(x:A) B( x ) → A.
8.7 Construct for any map f : A → B an equivalence e : A ' ∑(y:B) fib f (y) and a
homotopy H : f ∼ pr1 ◦ e witnessing that the triangle
e
A ∑(y:B) fib f (y)
f pr1
B
commutes. The projection pr1 : (∑(y:B) fib f (y)) → B is sometimes also called
the fibrant replacement of f , because first projection maps are fibrations in the
homotopy interpretation of type theory.
f : ∏ (x:A) B( x ) → C ( x ).
Lemma 9.1.2. For any family of maps f : ∏ (x:A) B( x ) → C ( x ) and any t : ∑(x:A) C ( x ), there
is an equivalence
fibtot ( f ) (t) ' fib f (pr1 (t)) (pr2 (t)).
58 CHAPTER II. BASIC CONCEPTS OF TYPE THEORY
Proof. For any p : fibtot ( f ) (t) we define ϕ(t, p) : fibpr1 (t) (pr2 (t)) by Σ-induction on p.
Therefore it suffices to define ϕ(t, (s, α)) : fibpr1 (t) (pr2 (t)) for any s : ∑(x:A) B( x ) and
α : tot ( f )(s) = t. Now we proceed by path induction on α, so it suffices to define
ϕ(tot ( f )(s), (s, refl )) : fib f (pr1 (tot ( f )(s))) (pr2 (tot ( f )(s))). Finally, we use Σ-induction on s
once more, so it suffices to define
equipped with homotopies G (t) : ϕ(t) ◦ ψ(t) ∼ id and H (t) : ψ(t) ◦ ϕ(t) ∼ id. In each
of these definitions we use Σ-induction and path induction all the way through, until
an obvious choice of definition becomes apparent. We define ψ(t), G (t), and H (t) as
follows:
Theorem 9.1.3. Let f : ∏ (x:A) B( x ) → C ( x ) be a family of maps. The following are equivalent:
(i) For each x : A, the map f ( x ) is an equivalence. In this case we say that f is a family of
equivalences.
Proof. By Theorems 8.2.5 and 8.3.6 it suffices to show that f ( x ) is a contractible map
for each x : A, if and only if tot ( f ) is a contractible map. Thus, we will show that
fib f (x) (c) is contractible if and only if fibtot ( f ) ( x, c) is contractible, for each x : A and
c : C ( x ). However, by Lemma 9.1.2 these types are equivalent, so the result follows by
Exercise 8.3.
Now consider the situation where we have a map f : A → B, and a family C over B.
Then we have the map
Lemma 9.1.4. Consider an equivalence e : A ' B, and let C be a type family over B. Then the
map
σ f (C ) :≡ λ( x, z). ( f ( x ), z) : ∑(x:A) C ( f ( x )) → ∑(y:B) C (y)
is an equivalence.
The construction of these functions and homotopies is by using Σ-induction and path
induction all the way through, just as in the proof of Lemma 9.1.2. We list the definitions
Now the claim follows, since we see that ϕ is a contractible map if and only if f is a
contractible map.
g : ∏ (x:A) C ( x ) → D ( f ( x )),
where C is a type family over A, and D is a type family over B. In this situation we also
say that g is a family of maps over f . Then we define
Theorem 9.1.6. Suppose that g is a family of maps over f , and suppose that f is an equivalence.
Then the following are equivalent:
tot f ( g)
∑(x:A) C ( x ) ∑(y:B) D (y)
Definition 9.2.1. Let A be a type equipped with a term a : A. A (unary) identity system
on A at a consists of a type family B over A equipped with b : B( a), such that for any
family of types P( x, y) indexed by x : A and y : B( x ), the function
h 7→ h( a, b) : ∏ (x:A) ∏ (y:B(x)) P( x, y) → P( a, b)
has a section.
The most important implication in the fundamental theorem is that (ii) implies
(i). Occasionally we will also use the third equivalent statement. We note that the
fundamental theorem also appears as Theorem 5.8.4 in [2].
Theorem 9.2.2. Let A be a type with a : A, and let B be be a type family over A with b : B( a).
Then the following are logically equivalent for any family of maps
f : ∏ (x:A) ( a = x ) → B( x ).
Proof. First we show that (i) and (ii) are equivalent. By Theorem 9.1.3 it follows that the
family of maps f is a family of equivalences if and only if it induces an equivalence
∑(x:A) a = x ' ∑(x:A) B( x )
on total spaces. We have that ∑(x:A) a = x is contractible. Now it follows by Exercise 8.3,
applied in the case
tot ( f )
∑(x:A) a = x ∑(x:A) B( x )
'
1
ev-pair
∏ (t:∑(x:A) B(x)) P(t) ∏ (x:A) ∏ (y:B(x)) P( x, y)
In this diagram the top map has a section. Therefore it follows by Exercise 7.4 that the
left map has a section if and only if the right map has a section. Notice that the left map
has a section for all P if and only if ∑(x:A) B( x ) satisfies singleton induction, which is by
Theorem 8.1.6 equivalent to ∑(x:A) B( x ) being contractible.
9.3 Embeddings
As an application of the fundamental theorem we show that equivalences are embed-
dings. The notion of embedding is the homotopical analogue of the set theoretic notion
of injective map.
62 CHAPTER II. BASIC CONCEPTS OF TYPE THEORY
ap f : ( x = y) → ( f ( x ) = f (y))
is an equivalence for every x, y : A. We write is-emb( f ) for the type of witnesses that f is
an embedding.
Another way of phrasing the following statement is that equivalent types have
equivalent identity types.
Proof. Let e : A ' B be an equivalence, and let x : A. Our goal is to show that
∑(y:A) e( x ) = e(y)
is an equivalence by Exercise 7.1. The fiber fibe (e( x )) is contractible by Theorem 8.3.6, so
it follows by Exercise 8.3 that the type ∑(y:A) e( x ) = e(y) is indeed contractible.
In order to prove Theorem 9.4.1, we first define a binary relation Eq-coprod A,B on the
coproduct A + B.
9. THE FUNDAMENTAL THEOREM 63
Eq-coprod A,B : ( A + B) → ( A + B) → U
The relation Eq-coprod A,B is also called the observational equality of coproducts.
Lemma 9.4.3. The observational equality relation Eq-coprod A,B on A + B is reflexive, and
therefore there is a map
∑(x:A) ∅ ' ∅
A + ∅ ' A.
is contractible.
Proof. We will do the proof by induction on s. The two cases are similar, so we only
show that the total space
Exercises
9.1 (a) Show that the map ∅ → A is an embedding for every type A.
(b) Show that inl : A → A + B and inr : B → A + B are embeddings for any two
types A and B.
9.2 Consider an equivalence e : A ' B. Construct an equivalence
(e( x ) = y) ' ( x = e−1 (y))
for every x : A and y : B.
9.3 Show that
( f ∼ g) → (is-emb( f ) ↔ is-emb( g))
for any f , g : A → B.
9.4 Consider a commuting triangle
h
A B
f g
X
with H : f ∼ g ◦ h.
(a) Suppose that g is an embedding. Show that f is an embedding if and only if h
is an embedding.
(b) Suppose that h is an equivalence. Show that f is an embedding if and only if
g is an embedding.
9.5 Consider two maps f : A → A0 and g : B → B0 .
(a) Show that if the map
f + g : ( A + B) → ( A0 + B0 )
is an equivalence, then so are both f and g (this is the converse of Exer-
cise 7.12.e).
9. EXERCISES 65
(b) Show that f + g is an embedding if and only if both f and g are embeddings.
9.6 (a) Let f , g : ∏ (x:A) B( x ) → C ( x ) be two families of maps. Show that
∏ (x:A) f ( x ) ∼ g( x ) → tot ( f ) ∼ tot ( g) .
f : ∏ (x:A) ( a = x ) → B( x ),
ap f : ( x = y) → ( f ( x ) = f (y))
f g
X
tot (fib-triangle(h,H ))
∑(x:X ) fib f ( x ) ∑(x:X ) fibg ( x )
A B
h
Given a universe U , we define PropU to be the type of all small propositions, i.e.,
Example 10.1.2. Any contractible type is a proposition by Exercise 8.1. However, proposi-
tions do not need to be inhabited: the empty type is also a proposition, since
∏ (x,y:∅) is-contr( x = y)
(ii) Any two terms of type A can be identified, i.e., there is a dependent function
is-prop0 ( A) :≡ ∏ (x,y:A) x = y.
A → is-contr( A).
10. HOMOTOPICAL COMPLEXITY 67
In the following lemma we show that propositions are closed under equivalences.
Lemma 10.1.4. Let A and B be types, and let e : A ' B. Then we have
is-prop( A) ↔ is-prop( B).
Proof. We will show that is-prop( B) implies is-prop( A). This suffices, because the con-
verse follows from the fact that e−1 : B → A is also an equivalence.
Since e is assumed to be an equivalence, it follows by Theorem 9.3.2 that
ape : ( x = y) → (e( x ) = e(y))
is an equivalence for any x, y : A. If B is a proposition, then in particular the type
e( x ) = e(y) is contractible for any x, y : A, so the claim follows from Theorem 8.3.6.
In set theory, a set y is said to be a subset of a set x, if any element of y is an element
of x, i.e., if the condition
∀z (z ∈ y) → (z ∈ x )
holds. We have already noted that type theory is different from set theory in that terms in
type theory come equipped with a unique type. Moreover, in set theory the proposition
x ∈ y is well-formed for any two sets x and y, whereas in type theory the judgment a : A
is only well-formed if it is derived using the postulated inference rules. Because of these
differences we must find a different way to talk about subtypes.
Note that in set theory there is a correspondence between the subsets of a set x,
and the predicates on x. A predicate on x is just a proposition P(z) that varies over the
elements z ∈ x. Indeed, if y is a subset of x, then the corresponding predicate is the
proposition z ∈ y. Conversely, if P is a predicate on x, then we obtain the subset
{z ∈ x | P(z)}
of x. Now we have the right idea of subtypes in type theory: they are families of
propositions.
68 CHAPTER II. BASIC CONCEPTS OF TYPE THEORY
10.2 Sets
Definition 10.2.1. A type A is said to be a set if it comes equipped with a term of type
Lemma 10.2.2. A type A is a set if and only if it satisfies axiom K, i.e., if and only if it comes
equipped with a term of type
Proof. If A is a set, then x = x is a proposition, so any two of its elements are equal. This
implies axiom K.
For the converse, if A satisfies axiom K, then for any p, q : x = y we have p q−1 = reflx ,
and hence p = q. This shows that x = y is a proposition, and hence that A is a set.
Proof. Let f : A → B be an injective map between sets. Now consider the relation
R( x, y) :≡ ( f ( x ) = f (y)).
R( x, y) → ( x = y)
for any x, y : A. Therefore we are in the situation of Theorem 10.2.3, so it follows that the
map ap f : ( x = y) → ( f ( x ) = f (y)) is an equivalence.
Proof. We will apply Theorem 10.2.3. Note that the observational equality EqN : N →
(N → U ) on N (Definition 6.4.2) is a reflexive relation by Exercise 6.1, and moreover
that EqN (n, m) is a proposition for every n, m : N (proof by double induction). Therefore
it suffices to show that
∏ (m,n:N) EqN (m, n) → (m = n).
This follows from the fact that observational equality is the least reflexive relation, which
was shown in Exercise 6.2.
is-trunc−2 ( A) :≡ is-contr( A)
is-trunck+1 ( A) :≡ ∏ (x,y:A) is-trunck ( x = y).
For any type A, we say that A is k-truncated, or a k-type, if there is a term of type
is-trunck ( A). We say that a map f : A → B is k-truncated if its fibers are k-truncated.
Proof. We have seen in Example 10.1.2 that contractible types are propositions. This
proves the base case. For the inductive step, note that if any k-type is also a (k + 1)-type,
then any (k + 1)-type is a (k + 2)-type, since its identity types are k-types and therefore
(k + 1)-types.
Proof. We have seen in Exercise 8.3 that if B is contractible and e : A ' B is an equiva-
lence, then A is also contractible. This proves the base case.
For the inductive step, assume that the k-types are stable under equivalences, and
consider e : A ' B where B is a (k + 1)-type. In Theorem 9.3.2 we have seen that
ap f : ( x = y) → ( f ( x ) = f (y))
Theorem 10.3.5. Let B be a type family over A. Then the following are equivalent:
(i) For each x : A the type B( x ) is k-truncated. In this case we say that the family B is
k-truncated.
is k-truncated.
fibpr1 ( x ) ' B( x )
ap f : ( x = y) → ( f ( x ) = f (y))
is k-truncated.
Proof. First we show that for any s, t : fib f (b) there is an equivalence
≡ ∑(α:x=y) p = ap f (α) q
' ∑(α:x=y) ap f (α) q = p
' ∑(α:x=y) ap f (α) = p q−1
≡ fibap f ( p q−1 ).
By these equivalences, it follows that if ap f is k-truncated, then for each s, t : fib f (b)
the identity type s = t is equivalent to a k-truncated type, and therefore we obtain by
Theorem 10.3.3 that f is (k + 1)-truncated.
For the converse, note that we have equivalences
It follows that if f is (k + 1)-truncated, then the identity type ( x, p) = (y, refl f (y) ) in
fib f ( f (y)) is k-truncated for any p : f ( x ) = f (y). We conclude by Theorem 10.3.3 that
the fiber fibap f ( p) is k-truncated.
Corollary 10.3.7. A map is an embedding if and only if its fibers are propositions.
Corollary 10.3.8. A type family B over A is a subtype if and only if the projection map
pr1 : ∑(x:A) B( x ) → A
is an embedding.
Theorem 10.3.9. Let f : ∏ (x:A) B( x ) → C ( x ) be a family of maps. Then the following are
equivalent:
is k-truncated.
Proof. This follows directly from Lemma 9.1.2 and Theorem 10.3.3.
Exercises
10.1 (a) Show that succN : N → N is an embedding.
(b) Show that n 7→ m + n is an embedding, for each m : N. Moreover, conclude
that there is an equivalence
(c) Show that n 7→ mn is an embedding, for each m > 0 in N. Conclude that the
divisibility relation
d|n
is a proposition for each d, n : N such that d > 0.
72 CHAPTER II. BASIC CONCEPTS OF TYPE THEORY
10.2 Let A be a type, and let the diagonal of A be the map δA : A → A × A given by
λx. ( x, x ).
(a) Show that
is-equiv(δA ) ↔ is-prop( A).
(b) Construct an equivalence fibδA (( x, y)) ' ( x = y) for any x, y : A.
(c) Show that A is (k + 1)-truncated if and only if δA : A → A × A is k-truncated.
10.3 (a) Let B be a type family over A. Show that if A is a k-type, and B( x ) is a k-type
for each x : A, then so is ∑(x:A) B( x ). Conclude that for any two k-types A and
B, the type A × B is also a k-type. Hint: for the base case, use Exercises 8.3
and 8.5.
(b) Show that for any k-type A, the identity types of A are also k-types.
(c) Show that any maps f : A → B between k-types A and B is a k-truncated
map.
(d) Use Exercise 8.6 to show that for any type family B : A → U , if A and
∑(x:A) B( x ) are k-types, then so is B( x ) for each x : A.
10.4 Show that 2 is a set by applying Theorem 10.2.3 with the observational equality on
2 defined in Exercise 6.5.
10.5 Show that for any two (k + 2)-types A and B, the disjoint sum A + B is again a
(k + 2)-type. Conclude that Z is a set.
10.6 Use Exercises 8.2 and 7.8 to show that if A is a retract of a k-type B, then A is also a
k-type.
10.7 Show that a type A is a (k + 1)-type if and only if the map constx : 1 → A is
k-truncated for every x : A.
10.8 Consider a commuting triangle
h
A B
f g
X
Univalent mathematics
11 Function extensionality
11.1 Equivalent forms of function extensionality
Definition 11.1.1. The axiom of function extensionality asserts that for any type family
B over A, and any two dependent functions f , g : ∏ (x:A) B( x ), the canonical map
htpy-eq : ( f = g) → ( f ∼ g)
that sends refl f to htpy-refl f is an equivalence. We will write eq-htpy for its inverse, if it is
assumed to exist.
In other words, the axiom of function extensionality asserts that for any two depen-
dent functions f , g : ∏ (x:A) B( x ), the type of identifications f = g is equivalent to the
type of homotopies f ∼ g from f to g. By the fundamental theorem of identity types
(Theorem 9.2.2) there are three equivalent ways of asserting function extensionality. In
the following theorem we state one further equivalent condition.
(ii) For any type family B over A and any dependent function f : ∏ (x:A) B( x ), the total space
is contractible.
(iii) The principle of homotopy induction: for any type family B over A, any dependent
function f : ∏ (x:A) B( x ), and any family of types P( g, H ) indexed by g : ∏ (x:A) B( x )
and H : f ∼ g, the evaluation function
∏ ( g:∏ (x:A) B(x)) ∏ ( H: f ∼ g) P( g, H ) → P( f , htpy-refl f )
73
74 CHAPTER III. UNIVALENT MATHEMATICS
(iv) The weak function extensionality principle holds: For every type family B over A one
has
∏ (x:A) is-contr( B( x )) → is-contr ∏ (x:A) B( x ) .
Proof. The fact that function extensionality is equivalent to (ii) and (iii) follows directly
from Theorem 9.2.2.
To show that function extensionality implies weak function extensionality, sup-
pose that each B( a) is contractible with center of contraction c( a) and contraction
Ca : ∏ (y:B(a)) c( a) = y. Then we take c :≡ λa. c( a) to be the center of contraction of
∏ (x:A) B( x ). To construct the contraction we have to define a term of type
∏ ( f :∏ (x:A) B(x)) c = f .
i :≡ λ( g, H ). λx. ( g( x ), H ( x ))
r :≡ λp. (λx. pr1 ( p( x )), λx. pr2 ( p( x ))).
Their composite is homotopic to the identity function by the computation rule for Σ-types
and the η-rule for Π-types:
r (i ( g, H )) ≡ r (λx. ( g( x ), H ( x )))
≡ (λx. g( x ), λx. H ( x ))
≡ ( g, H ).
Now we observe that the type ∏ (x:A) ∑(b:B(x)) f ( x ) = b is a product of contractible types,
so it is contractible by our assumption of the weak function extensionality principle. The
claim therefore follows, since retracts of contractible types are contractible by Exercise 8.2.
For the remainder of this chapter we will assume that the function extensionality ax-
iom holds. In Theorem 12.2.2 we will derive function extensionality from the univalence
axiom.
As a first application of the function extensionality axiom we generalize the weak
function extensionality axiom to k-types.
11. FUNCTION EXTENSIONALITY 75
Theorem 11.1.3. Assume function extensionality. Then for any type family B over A one has
∏ (x:A) is-trunck ( B( x )) → is-trunck ∏ (x:A) B( x ) .
Proof. The theorem is proven by induction on k ≥ −2. The base case is just the weak func-
tion extensionality principle, which was shown to follow from function extensionality in
Theorem 11.1.2.
For the inductive hypothesis, assume that the k-types are closed under dependent
function types. Assume that B is a family of (k + 1)-types. By function extensionality,
the type f = g is equivalent to f ∼ g for any two dependent functions f , g : ∏ (x:A) B( x ).
Now observe that f ∼ g is a dependent product of k-types, and therefore it is an k-type
by our inductive hypotheses. Therefore, it follows by Theorem 10.3.3 that f = g is an
k-type, and hence that ∏ (x:A) B( x ) is an (k + 1)-type.
Corollary 11.1.4. Suppose B is a k-type. Then A → B is also a k-type, for any type A.
given by λh. (pr1 (h( x )), pr2 (h( x ))), is an equivalence. In order to see this as a principle of
choice, one can view the left hand side as the type of functions h that pick for every x : A
a term y : B( x ) equipped with a term of type C ( x, y). The function choice then constructs
a dependent function f : ∏ (x:A) B( x ) equipped with a term of type ∏ (x:A) C ( x, f ( x )). In
this section we show that the map choice is an equivalence, and we use this to characterize
the identity of any dependent function type ∏ (x:A) B( x ) in terms of any characterization
of the identity types of the individual types B( x ).
choice(choice−1 ( f , g)) = ( f , g)
76 CHAPTER III. UNIVALENT MATHEMATICS
for any f : ∏ (x:A) B( x ) and any g : ∏ (x:A) C ( x, f ( x )). We compute the left-hand side as
follows:
By the η-rule it follows that f ≡ λx. f ( x ) and g ≡ λx. g( x ). Therefore we have the
identification
refl( f ,g) : choice(choice−1 ( f , g)) = ( f , g).
This completes the construction of the first homotopy.
For the second homotopy we have to construct an identification
choice−1 (choice(h)) = h
for any h : ∏ (x:A) ∑(y:B(x)) C ( x, y). We compute the left-hand side as follows:
choice−1 (choice(h)) ≡ choice−1 (λx. pr1 (h( x )), (λx. pr2 (h( x ))))
≡ λx. (pr1 (h( x )), pr2 (h( x )))
However, it is not the case that (pr1 (h( x )), pr2 (h( x ))) ≡ h( x ) for any h : ∏ (x:A) ∑(y:B(x)) C ( x, y).
Nevertheless, we have the identification
Corollary 11.2.2. For type A and any type family C over B, the map
∑( f :A→ B) ∏ (x:A) C ( f ( x )) → A → ∑(y:B) C ( x )
Remark 11.2.3. The type theoretic choice principle can be used to derive the binomial
theorem. We give an informal argument of how this goes. Recall that the binomial
theorem asserts that
k
k l k−l
(n + m) = ∑
k
nm
l =0
l
for any three natural numbers k, m, n.
Consider the types A :≡ Fin(k ), B :≡ Fin(n) and C :≡ Fin(m). Then we can define
the type family P : 2 → U given by
P (12 ) : ≡ B
P(02 ) :≡ C.
11. FUNCTION EXTENSIONALITY 77
Now we note that, because there are (kl) ways to choose a subset of l elements of A, there
are
k
k
∑ l nl mk−l
l =0
Theorem 11.3.1. Let B be a type family over A, and let X be a type. Then the map
ev-pair : ∑(x:A) B( x ) → X → ∏ (x:A) ( B( x ) → X )
To show that indΣ ◦ ev-pair ∼ id we will also apply function extensionality. Thus, it
suffices to show that indΣ (λx. λy. f (( x, y))) = f . We apply function extensionality again,
so it suffices to show that
ev-pair : ( A × B → X ) → ( A → ( B → X ))
The universal property of identity types is sometimes called the type theoretical Yoneda
lemma: families of maps out of the identity type are uniquely determined by their action
on the reflexivity identification.
Theorem 11.3.3. Let B be a type family over A, and let a : A. Then the map
ev-refl : ∏ (x:A) ( a = x ) → B( x ) → B( a)
– ◦ f : (B → X) → ( A → X)
is an equivalence. Moreover, we will show in Theorem 11.4.1 that the ‘dependent version’
of this statement also holds: a map f : A → B is an equivalence if and only if for any
type family P over B, the precomposition map
– ◦ f : ∏ (y:B) P(y) → ∏ (x:A) P( f ( x ))
is an equivalence.
(i) f is an equivalence.
given by h 7→ h ◦ f is an equivalence.
11. FUNCTION EXTENSIONALITY 79
Proof. To show that (i) implies (ii), we first recall from Lemma 8.3.5 that any equivalence
is also coherently invertible. Therefore f comes equipped with
g:B→A
G : f ◦ g ∼ idB
H : g ◦ f ∼ id A
K : G · f ∼ f · H.
tr P ( G ( f ( x )), h( g( f ( x ))) = h( x )
for any x : A. Now we use the additional homotopy K from our assumption that f is
coherently invertible. Since we have K ( x ) : G ( f ( x )) = ap f ( H ( x )) it suffices to show that
tr P (ap f ( H ( x )), hg f ( x )) = h( x ).
tr P (ap f ( p)) ∼ tr P◦ f ( p)
tr P◦ f ( H ( x ), hg f ( x )) = h( x ).
for any y : B. We have such an identification by apdh ( G (y)). This completes the proof
that (i) implies (ii).
Note that (iii) is an immediate consequence of (ii), since we can just choose P to be
the constant family X.
It remains to show that (iii) implies (i). Suppose that
– ◦ f : (B → X) → ( A → X)
80 CHAPTER III. UNIVALENT MATHEMATICS
is an equivalence for every type X. Then its fibers are contractible by Theorem 8.3.6. In
particular, choosing X ≡ A we see that the fiber
( f ◦ h) ◦ f ≡ f ◦ (h ◦ f )
= f ◦ id A
≡ f
Now we conclude by the contractibility of the fiber that (idB , refl f ) = ( f ◦ h, p). In
particular we obtain that idB = f ◦ h, showing that h is a section of f .
Exercises
11.1 Show that the functions
htpy-inv : ( f ∼ g) → ( g ∼ f )
htpy-concat( H ) : ( g ∼ h) → ( f ∼ h)
htpy-concat0 (K ) : ( f ∼ g) → ( f ∼ h)
( P ↔ Q ) ' ( P ' Q ).
(b) Show that P is a proposition if and only if P → P is contractible.
11.6 Show that path-split( f ) and is-coh-invertible( f ) are propositions for any map f :
A → B. Conclude that we have equivalences
Note: We will use this fact in Exercise 15.6 to show that there are types for which
is-invertible(id A ) 6' is-equiv(id A ).
11.8 (a) Show that the type
∏ (t:∅) P(t)
is contractible for any P : ∅ → U .
(b) Show that for any type X the following are equivalent:
(i) the unique map ∅ → X is an equivalence.
(ii) The type Y X is contractible for any type Y.
11.9 Consider two types A and B.
(a) Show that the map
ev-inl-inr : ∏ (t:A+ B) P(t) → ∏ (x:A) P(inl( x )) × ∏ (y:B) P(inr(y))
λ f . ( f ◦ i, f ◦ j) : ( X → Y ) → ( A → Y ) × ( B → Y )
is an equivalence.
11.10 (a) Show that the map
∏ (t:1) P(t) → P(?)
given by λ f . f (?) is an equivalence.
(b) Consider a type X equipped with a point x : X. Show that the following are
equivalent:
(i) The map ind1 ( x ) : 1 → X is an equivalence (i.e., X is contractible).
(ii) For any type Y the map
λ f . f (x) : (X → Y) → Y
is an equivalence.
82 CHAPTER III. UNIVALENT MATHEMATICS
f g
X
with H : f ∼ g ◦ h.
(a) Show that if h has a section, then sec( g) is a retract of sec( f ).
(b) Show that if g has a retraction, then retr(h) is a retract of sec( f ).
11.12 Let ei : Ai ' Bi be an equivalence for every i : I. Show that the map
λ f . λi. ei ◦ f : ∏ (i:I ) Ai → ∏ (i:I ) Bi
is an equivalence.
11.13 Consider a diagram of the form
A B
f g
X
(a) Show that the type ∑(h:A→ B) f ∼ g ◦ h is equivalent to the type of families of
maps
∏ (x:X ) fib f ( x ) → fibg ( x ).
(b) Show that the type ∑(h:A' B) f ∼ g ◦ h is equivalent to the type of families of
equivalences
∏ (x:X ) fib f ( x ) ' fibg ( x ).
11.14 Consider a diagram of the form
A B
f g
X Y.
h
f :A→B
g:B→A
H : f ◦ g = idB
K : g ◦ f = id A .
12. THE UNIVALENCE AXIOM 83
pr1 : ∑(x:A) B( x ) → A
A
pr1 ◦ – : ∑(x:A) B( x ) → AA.
Construct equivalences
∏ (x:A) B ( x ) ' sec(pr1 ) ' fibpr1 ◦ – (id A ).
11.17 Suppose that A : I → U is a type family over a set I with decidable equality. Show
that
∏ (i:I ) is-contr ( A i ) ↔ is-contr ∏ (i:I ) i .
A
Definition 12.1.1. The univalence axiom on a universe U is the statement that for any
A : U the family of maps
The following theorem is a special case of the fundamental theorem of identity types
(Theorem 9.2.2). Subsequently we will assume that any type is contained in a univalent
universe.
(iii) The principle of equivalence induction holds: for every A : U and for every type family
P : ∏ ( B:U ) ( A ' B) → U ,
the map
∏ ( B:U ) ∏ (e:A' B) P( B, e) → P( A, id A )
Lemma 12.2.1. For any equivalence e : X ' Y in a univalent universe U , and any type A, the
post-composition map
e ◦ – : ( A → X) → ( A → Y)
is an equivalence.
Proof. The statement is obvious for the identity equivalence id : X ' X. Therefore the
claim follows by equivalence induction, which is by Theorem 12.1.2 one of the equivalent
forms of the univalence axiom.
Theorem 12.2.2. For any universe U , the univalence axiom on U implies function extensionality
on U .
Proof. Note that by Theorem 11.1.2 it suffices to show that univalence implies weak
function extensionality, where we note that Theorem 11.1.2 also holds when it is restricted
to small types.
Suppose that B : A → U is a family of contractible types. Our goal is to show that the
product ∏ (x:A) B( x ) is contractible. Since each B( x ) is contractible, the projection map
pr1 : ∑(x:A) B( x ) → A is an equivalence by Exercise 8.6.
iff-eq : ( P = Q) → ( P ↔ Q)
that sends reflP to (id, id ) is an equivalence. It follows that the type Prop of propositions in U is
a set.
Note that for any P : Prop, we usually also write P for the underlying type of the
proposition P. If we would be more formal about it we would have to write pr1 ( P) for the
underlying type, since Prop is the Σ-type ∑(X:U ) is-prop( X ). In the following proof it is
clearer if we use the more formal notation pr1 ( P) for the underlying type of a proposition
P.
Proof. We note that the identity type P = Q is an identity type in Prop. However, since
is-prop( X ) is a proposition for any type X, it follows that the map
( P = Q) ( P ↔ Q)
appr1 '
Since the left, bottom, and right map are equivalences, it follows that the top map is an
equivalence.
86 CHAPTER III. UNIVALENT MATHEMATICS
Definition 12.3.2. A partially ordered set (poset) is a set P equipped with a relation
– ≤ – : P → ( P → Prop)
that is reflexive (for every x : P we have x ≤ x), transitive (for every x, y, z : P such that
x ≤ y and y ≤ z we have x ≤ z), and anti-symmetric (for every x, y : P such that x ≤ y
and y ≤ x we have x = y).
Remark 12.3.3. The condition that X is a set can be omitted from the definition of a poset.
Indeed, if X is any type that comes equipped with a Prop-valued ordering relation ≤
that is reflexive and anti-symmetric, then X is a set by Theorem 10.2.3.
Example 12.3.4. The type Prop is a poset, where the ordering relation is given by im-
plication: P is less than Q if P → Q. The fact that P → Q is a proposition is a special
case of Corollary 11.1.4. The relation P → Q is reflexive by the identity function, and
transitive by function composition. Moreover, the relation P → Q is anti-symmetric by
Theorem 12.3.1.
Example 12.3.5. The type of natural numbers comes equipped with at least two important
poset structures. The first is given by the usual ordering relation ≤, and the second is
given by the relation d | n that d divides n.
Theorem 12.3.6. For any poset P and any type X, the set P X is a poset. In particular the type
of subtypes of any type is a poset.
Proof. Let P be a poset with ordering ≤, and let X be a type. Then P X is a set by
Corollary 11.1.4. For any f , g : X → P we define
( f ≤ g) :≡ ∏ (x:X ) f ( x ) ≤ g( x ).
Reflexivity and transitivity follow immediately from reflexivity and transitivity of the
original relation. Moreover, by the anti-symmetry of the original relation it follows that
( f ≤ g ) × ( g ≤ f ) → ( f ∼ g ).
Exercises
12.1 (a) Use the univalence axiom to show that the type ∑( A:U ) is-contr( A) of all con-
tractible types in U is contractible.
(b) Use Corollaries 10.3.4 and 11.1.4 and Exercise 11.4 to show that if A and B are
(k + 1)-types, then the type A ' B is also a (k + 1)-type.
(c) Use univalence to show that the universe of k-types
U ≤k :≡ ∑(X:U ) is-trunck ( X )
(e) Show that (2 ' 2) ' 2, and conclude by the univalence axiom that the
universe of sets U ≤0 is not a set.
12.2 Use the univalence axiom to show that the type ∑( P:Prop) P is contractible.
12.3 Let A and B be small types.
(a) Construct an equivalence
( A → ( B → U )) ' ∑(S:U ) (S → A) × (S → B)
12.6 Show that any subuniverse is closed under equivalences, i.e., show that there is a
map
( X ' Y ) → ( P( X ) → P(Y ))
for any subuniverse P : U → Prop, and any X, Y : U .
88 CHAPTER III. UNIVALENT MATHEMATICS
and a homotopy
We write is-unital( G ) for the type of such triples (eG , left-unitG , right-unitG ). Unital semi-
groups are also called monoids.
groupoids. We will briefly introduce categories in §13.5. For more about categories we recommend Chapter 9
of [2].
13. GROUPS IN UNIVALENT MATHEMATICS 89
Proof. Let G be a semi-group. Note that since G is a set, it follows that the types of the
left and right unit laws are propositions. Therefore it suffices to show that any two terms
e, e0 : G satisfying the left and right unit laws can be identified. This is easy:
e = µG (e, e0 ) = e0 .
Definition 13.1.4. Let G be a unital semi-group. We say that G has inverses if it comes
equipped with an operation x 7→ x −1 of type G → G, satisfying the left and right inverse
laws
left-inv G : ∏ (x:G) µG ( x −1 , x ) = eG
right-inv G : ∏ (x:G) µG ( x, x −1 ) = eG .
We write is-group0 ( G, e) for the type of such triples (( – )−1 , left-inv G , right-inv G ), and we
write
is-group( G ) :≡ ∑(e:is-unital(G)) is-group0 ( G, e)
A group is a unital semi-group with inverses. We write Group for the type of all groups
in U .
Lemma 13.1.5. For any semi-group G the type is-group( G ) is a proposition.
Proof. We have already seen that the type is-unital( G ) is a proposition. Therefore it
suffices to show that the type is-group0 ( G, e) is a proposition for any e : is-unital( G ).
Since a semi-group G is assumed to be a set, we note that the types of the inverse
laws are propositions. Therefore it suffices to show that any two inverse operations
satisfying the inverse laws are homotopic.
Let x 7→ x −1 and x 7→ x̄ −1 be two inverse operations on a unital semi-group G, both
satisfying the inverse laws. Then we have the following identifications
x −1 = µ G ( e G , x −1 )
= µG (µG ( x̄ −1 , x ), x −1 )
= µG ( x̄ −1 , µG ( x, x −1 ))
= µG ( x̄ −1 , eG )
= x̄ −1
for any x : G. Thus the two inverses of x are the same, so the claim follows.
Example 13.1.6. An important class of examples consists of loop spaces x = x of a 1-type
X, for any x : X. We will write Ω ( X, x ) for the loop space of X at x. Since X is assumed
to be a 1-type, it follows that the type Ω ( X, x ) is a set. Then we have
reflx : Ω ( X, x )
inv : Ω ( X, x ) → Ω ( X, x )
concat : Ω ( X, x ) → (Ω ( X, x ) → Ω ( X, x )),
and these operations satisfy the group laws, since the group laws are just a special case
of the groupoid laws for identity types, constructed in §5.2.
90 CHAPTER III. UNIVALENT MATHEMATICS
Example 13.1.7. The type Z of integers can be given the structure of a group, with the
group operation being addition. The fact that Z is a set follows from Theorem 10.2.6
and Exercise 10.5. The group laws were shown in Exercise 7.11.
Example 13.1.8. Our last class of examples consists of the automorphism groups on sets.
Given a set X, we define
Aut( X ) :≡ ( X ' X ).
The group operation of Aut( X ) is just composition of equivalences, and the unit of
the group is the identity function. Note however, that although function composition
is strictly associative and satisfies the unit laws strictly, composition of equivalences
only satisfies the group laws up to identification because the proof that composites are
equivalences is carried along.
Important special cases of the automorphism groups are the symmetric groups
Sn :≡ Aut(Fin(n)).
id : G → G
λx. λy. reflxy : ∏ (x,y:G) xy = xy.
Let f : G → H and g : H → K be semi-group homomorphisms. Then the compos-
ite function g ◦ f : G → K is also a semi-group homomorphism, since we have the
identifications
g( f ( xy)) g( f ( x ) f (y)) g( f ( x )) g( f (y)).
id ◦ f = f
13. GROUPS IN UNIVALENT MATHEMATICS 91
g ◦ id = g
(h ◦ g) ◦ f = h ◦ ( g ◦ f )
for any composable semi-group homomorphisms f , g, and h. Note, however that these
equalities are not expected to hold judgmentally, since preservation of the semi-group
operation is part of the data of a semi-group homomorphism.
G∼
= H :≡ ∑(h:hom(G,H )) ∑(k:hom( H,G)) (k ◦ h = idG ) × (h ◦ k = id H ).
is-iso(h)
Proof. Let k and k0 be two inverses of h. In Remark 13.2.2 we have observed that the
type of semi-group homomorphisms between any two semi-groups is a set. Therefore it
follows that the types h ◦ k = id and k ◦ h = id are propositions, so it suffices to check
that k = k0 . In Remark 13.2.2 we also observed that the equality type k = k0 is equivalent
to the type of homotopies k ∼ k0 between their underlying functions. We construct a
homotopy k ∼ k0 by the usual argument:
is contractible, a useful strategy is to first show that the type ∑( x:A) C ( x ) is contractible. Once this is
established, say with center of contraction ( x0 , z0 ), it suffices to show that the type ∑(y:B( x0 )) D ( x0 , y, z0 ) is
contractible.
13. GROUPS IN UNIVALENT MATHEMATICS 93
iso-eq : ( G = H ) → ( G ∼
= H)
by path induction, taking reflG to the identity isomorphism id : G ∼
= G.
Theorem 13.4.2. For any two groups G and H, the map
iso-eq : ( G = H ) → ( G ∼
= H)
is an equivalence.
Proof. Let G and H be groups, and write UG and UH for their underlying semi-groups,
respectively. Then we have a commuting triangle
appr1
(G = H ) (UG = UH )
iso-eq iso-eq
(G ∼
= H)
Since being a group is a property of semi-groups it follows that the projection map
Group → Semi-Group forgetting the unit and inverses, is an embedding. Thus the top
map in this triangle is an equivalence. The map on the right is an equivalence by
Theorem 13.3.5, so the claim follows by the 3-for-2 property.
Corollary 13.4.3. The type of groups is a 1-type.
hom( x, y)
of morphisms from x to y.
94 CHAPTER III. UNIVALENT MATHEMATICS
(iv) For every two morphisms f : hom( x, y) and g : hom(y, z), a morphism
g ◦ f : hom( x, z)
called the composition of f and g.
(v) the following terms
left-unitC : id ◦ f = f
right-unitC : g ◦ id = g
assocC : (h ◦ g) ◦ f = h ◦ ( g ◦ f )
witnessing that the category laws are satisfied.
Example 13.5.2. Since the type X → Y of functions between sets is again a set, we have a
pre-category of sets.
Example 13.5.3. By Remarks 13.2.3 and 13.2.5 we have pre-categories of semi-groups and
of groups.
Example 13.5.4. A pre-category satisfying the condition that every hom-set is a proposi-
tion is a preorder.
Definition 13.5.5. Given a pre-category C , a morphism f : hom( x, y) is said to be an
isomorphism if there exists a morphism g : hom(y, x ) such that
g ◦ f = id
f ◦ gid.
We will write iso( x, y) for the type of all isomorphisms in C from x to y.
Remark 13.5.6. Just as in the case for semi-groups and groups, the condition that f :
hom( x, y) is an isomorphism is a property of f .
Definition 13.5.7. A pre-category C is said to be Rezk-complete if the canonical map
( x = y) → iso( x, y)
is an equivalence for any two objects x and y of C . Rezk-complete pre-categories are also
called categories.
Example 13.5.8. The pre-category of sets is Rezk complete by the univalence axiom, so it
is a category.
Example 13.5.9. The pre-categories of semi-groups and groups are Rezk-complete. There-
fore they form categories.
Example 13.5.10. A pre-order is Rezk-complete if and only if it is anti-symmetric. In other
words, a poset is precisely a category for which all the hom-sets are propositions. Thus,
we see that the anti-symmetry axiom can be seen as a univalence axiom for pre-orders.
13. EXERCISES 95
Exercises
13.1 Let X be a set. Show that the map
equiv-eq : ( X = X ) → ( X ' X )
is a group isomorphism.
13.2 (a) Consider a group G. Show that the function
µG : G → (G ' G)
is an embedding.
13.3 Let f : hom( G, H ) be a group homomorphism. Show that f preserves units and
inverses, i.e., show that
f (eG ) = e H
f ( x −1 ) = f ( x ) −1 .
13.4 Give a direct proof and a proof using the univalence axiom of the fact that all semi-
group isomorphisms between unital semi-groups preserve the unit. Conclude that
isomorphic monoids are equal.
13.5 Consider a monoid M with multiplication µ : M → ( M → M) and unit e. Write
µ̄ :≡ fold-list(e, µ) : list( M ) → M
for the iterated multiplication operation (see Exercise 4.8). Show that the square
flatten-list( M )
list(list( M)) list( M )
list(µ̄) µ̄
list( M) µ̄
M
commutes.
13.6 Construct the category of posets.
14 The circle
We have seen inductive types, in which we describe a type by its constructors and an
induction principle that allows us to construct sections of dependent types. Inductive
types are freely generated by their constructors, which describe how we can construct
their terms.
However, many familiar constructions in algebra involve the construction of algebras
by generators and relations. For example, the free abelian group with two generators is
described as the group with generators x and y, and the relation xy = yx.
96 CHAPTER III. UNIVALENT MATHEMATICS
In this chapter we introduce higher inductive types, where we follow a similar idea:
to allow in the specification of inductive types not only point constructors, but also path
constructors that give us relations between the point constructors. The ideas behind the
definition of higher inductive types are introduced by studying the simplest non-trivial
example: the circle.
base : S1
loop : base = base.
Just like for ordinary inductive types, the induction principle for higher inductive types
provides us with a way of constructing sections of dependent types. However, we need
to take the path constructor loop into account in the induction principle.
By applying a section f : ∏ (x:S1 ) P( x ) to the base point of the circle, we obtain a term
f (base) : P(base). Moreover, using the dependent action on paths of f of Definition 5.4.2
we also obtain for any dependent function f : ∏ (x:S1 ) P( x ) a path
Definition 14.1.1. Let P be a type family over the circle. The dependent action on
generators is the map
dgenS1 : ∏ (x:S1 ) P( x ) → ∑(y:P(base)) tr P (loop, y) = y (14.1)
base : S1
loop : base = base,
and satisfies the induction principle of the circle, which provides for each type family
P over S1 a map
indS1 : ∑(y:P(base)) tr P (loop, y) = y → ∏ (x:S1 ) P( x ) ,
∑(y:P(base)) tr P (loop, y) = y
aptr
P (loop)
(α)
tr P (loop, y) tr P (loop, y0 )
p p0
y α y0
commutes. Therefore it follows from the induction principle of the circle that for
any (y, p) : ∑(y:P(base)) tr P (loop, y) = y, there is a dependent function f : ∏ (x:S1 ) P( x )
equipped with an identification
α : f (base) = y,
aptr
P (loop)
(α)
tr P (loop, f (base)) tr P (loop, y)
apd f (loop) p
f (base) α y
commutes.
Theorem 14.2.1. For any type family P over the circle, the map
∏ (x:S1 ) P( x ) → ∑(y:P(base)) tr P (loop, y) = y
Proof. By the induction principle of the circle we know that the map has a section, i.e.,
we have
indS1 : ∑(y:P(base)) tr P (loop, y) = y → ∏ (x:S1 ) P( x )
indS1 (dgenS1 ( f )) = f .
We proceed by the induction principle of the circle using the family of types Eg, f ( x ) :≡
g( x ) = f ( x ) indexed by x : S1 , where g is the function
α : g(base) = f (base)
β : tr Eg, f (loop, α) = α.
aptr
P (loop)
(α)
tr P (loop, g(base)) tr P (loop, f (base))
apdg (loop) apd f (loop)
g(base) α f (base)”
commutes. Notice that we get exactly such a pair (α, β) from the computation rule of the
circle, by Remark 14.1.3.
Corollary 14.2.2. Consider a type family P over the circle, and let
y : P(base)
p : tr P (loop, y) = y.
α : f (base) = y
aptr
P (loop)
(α)
tr P (loop, f (base)) tr P (loop, y)
apd f (loop) p
f (base) α y
commutes, is contractible.
Now we use the dependent universal property to derive the ordinary universal
property of the circle. It would be tempting to say that it is a direct corollary, but we
need to address the transport that occurs in the dependent universal property.
( S1 → X )
genS1 dgenS1
∑(x:X ) x = x ' ∑(x:X ) trconstX (loop, x ) = x
in which the bottom map is an equivalence. Indeed, once we have such a triangle, we
use the fact from Theorem 14.2.1 that dgenS1 is an equivalence to conclude that genS1 is
an equivalence.
To construct the bottom map, we first observe that for any constant type family constB
over a type A, any p : a = a0 in A, and any b : B, there is an identification
tr-constB ( p, b) = b.
l 7→ tr-constX (loop, x ) l,
100 CHAPTER III. UNIVALENT MATHEMATICS
commutes. This again follows from general considerations: for any f : A → B and any
p : a = a0 in A, the triangle
tr-constB ( p, f ( a))
trconstB ( p, f ( a)) f ( a)
apd f ( p) ap f ( p)
f ( a0 )
Corollary 14.2.4. For any loop l : x = x in a type X, the type of maps f : S1 → X equipped
with an identification
α : f (base) = x
α
f (base) x
ap f (loop) l
f (base) α x
commutes, is contractible.
mulS1 : S1 → (S1 → S1 ).
14. THE CIRCLE 101
Construction. Using the universal property of the circle, we define mulS1 as the unique
map S1 → (S1 → S1 ) equipped with an identification
base-mulS1
mulS1 (base) id
apmul (loop) eq-htpy( H )
S1
mulS1 (base) id
base-mulS1
commutes. Note that in this square we have a homotopy H : id ∼ id, which is not yet
defined. We use the dependent universal property of the circle with respect to the family
Eid,id given by
Eid,id ( x ) :≡ ( x = x ),
α : H (base) = loop
aptr
Eid,id (loop)
(α)
tr Eid,id (loop, H (base)) tr Eid,id (loop, loop)
apd H (loop) γ
H (base) α loop
commutes. Now it remains to define the path γ : tr Eid,id (loop, loop) = loop in the above
square. To proceed, we first observe that a simple path induction argument yields a
function
p r = q p → tr Eid,id ( p, q) = r ,
Now we apply this function to reflloop loop to obtain the desired identification
The left unit law mulS1 (base, x ) = x holds by the computation rule of the universal
property. More precisely, we define
left-unitS1 :≡ htpy-eq(base-mulS1 ).
For the right unit law, however, we need to give a separate argument that is surprisingly
involved, because all the aspects of the definition of mulS1 will come out and play their
part.
Theorem 14.3.3. The multiplication operation on the circle satisfies the right unit law, i.e., we
have
mulS1 ( x, base) = x
for any x : S1 .
Proof. The proof is by induction on the circle. In the base case we use the left unit law
P( x ) :≡ mulS1 ( x, base) = x.
for any
p : base = x
q : mulS1 (base, base) = base
r : mulS1 ( x, base) = x.
left-unitS1 (base)
mulS1 (base, base) base
htpy-eq(apmul (loop))(base) loop
S1
htpy-eq(base-mulS1 )(base)
mulS1 (base, base) base
htpy-eq(apmul (loop))(base) H (base)
S1
commutes. The commutativity of this square easily follows from the identification
loop-mulS1 constructed in Definition 14.3.1.
Exercises
14.1 Let P : S1 → Prop be a family of propositions over the circle. Show that
P(base) → ∏ (x:S1 ) P( x ).
indS1 ( x, reflx ) : S1 → X
are equivalences.
(b) Show that the function
mulS1 : S1 → (S1 → S1 )
is an equivalence.
(b) Show that a type X is a set if and only if the map
λ f . f (base) : (S1 → X ) → X
is an equivalence.
104 CHAPTER III. UNIVALENT MATHEMATICS
Definition 15.1.1. Consider a type X and every equivalence e : X ' X. We will construct
a dependent type D( X, e) : S1 → U with an equivalence x 7→ xD : X ' D( X, e, base) for
which the square
'
X D( X, e, base)
e trD(X,e) (loop)
X ' D( X, e, base)
commutes. We also write d 7→ d X for the inverse of this equivalence, so that the relations
hold.
The type ∑(X:U ) X ' X is also called the type of descent data for the circle.
( S1 → U )
genS1 descS1
commutes, where the map descS1 is given by P 7→ ( P(base), tr P (loop)) and the bottom
map is an equivalence by the univalence axiom and Theorem 9.1.3. Now it follows
by the 3-for-2 property that descS1 is an equivalence, since genS1 is an equivalence by
15. THE FUNDAMENTAL COVER OF THE CIRCLE 105
Theorem 14.2.3. This means that for every type X and every e : X ' X there is a type
family D( X, e) : S1 → U such that
D( X, e, base) X
equiv-eq( p)
commutes.
Z e ES1 (base)
commutes.
For convenience, we write k E for the term e(k ) : ES1 (base), for any k : Z.
The picture of the fundamental cover is that of a helix over the circle. This picture
emerges from the path liftings of loop in the total space. The segments of the helix
connecting k to k + 1 in the total space of the helix, are constructed in the following
lemma.
Lemma 15.2.3. For any k : Z, there is an identification
We just take α :≡ loop. Then we have trE (α, k E ) = succ(k )E by the commuting square
provided in the definition of E .
More generally, if we are given an equivalence e : F ' P( x ) for some x : X, then we have
an equivalence
∏ (y:P(x)) c = ( x, y) → ∏ (y:F) c = ( x, e(y)) (15.1)
e
F P( x )
f tr P ( p)
e0
F0 P( x0 )
with H : e0 ◦ f tr P ( p) ◦ e, where e, e0 , and f are all equivalences. Then there is for any
y : F an identification
e
F P( x )
f tr P ( p)
e0
F0 P( x0 )
h : ∏ (y:F) c = ( x, e(y))
h0 : ∏ (y0 :F0 ) c = ( x 0 , e0 (y0 )).
– ◦e
∏ (y:B(x)) c = ( x, y) ∏ (y:F) c = ( x, e(y))
trC ( p) ψ
where ψ(h0 ) = λy. h0 ( f (y)) segment-tot(y)−1 . All the maps in this square are equiva-
lences. In particular, the inverses of the top and bottom maps are ϕ and ϕ0 , respectively.
The claim follows from this observation, but we will spell out the details.
Since any equivalence is an embedding, we see immediately that the type trC ( p)( ϕ(h)) =
ϕ (h0 ) is equivalent to the type
0
By the commutativity of the square, the left hand side is h. The right hand side is ψ(h0 ).
Therefore it follows that
trC ( p)( ϕ(h)) = ϕ0 (h0 ) ' h = λy. h0 ( f (y)) segment-tot(y)−1
' h0 ◦ f ∼ (λy. h(y) segment-tot(y) .
Applying these observations to the fundamental cover of the circle, we obtain the
following lemma that we will use to prove that the total space of E is contractible.
Corollary 15.3.3. In order to show that the total space of E is contractible, it suffices to construct
a function
h : ∏ (k:Z) (base, 0E ) = (base, k E )
equipped with a homotopy
In the next section we establish the dependent universal property of the integers,
which we will use with Corollary 15.3.3 to show that the total space of the fundamental
cover is contractible.
for each k : Z. Then there is a dependent function f : ∏ (k:Z) B(k ) equipped with identifications
f (0) = b0 and
f (succ(k )) = ek ( f (k ))
for any k : Z.
Proof. The map is defined using the induction principle for the integers, stated in
Lemma 4.5.3. First we take
Z A
f
One way of phrasing the following corollary, is that Z is the ‘initial type equipped
with a point and an automorphism’.
Corollary 15.4.4. For any type X equipped with a base point x0 : X and an automorphism
e : X ' X, the type
is contractible.
We obtain h and H by the elimination principle of Lemma 15.4.1. Indeed, the family P
over the integers given by P(k ) :≡ (base, 0E ) = (base, k E ) comes equipped with a term
refl(base,0E ) : P(0), and a family of equivalences
given by k, p 7→ p segment-helix(k ).
sending reflbase to 0E is a family of equivalences. In particular, the loop space of the circle is
equivalent to Z.
Proof. To see that the circle is a 1-type we have to show that s = t is a 0-type for
every s, t : S1 . By Exercise 14.1 it suffices to show that the loop space of the circle is
a 0-type. This is indeed the case, because Z is a 0-type, and we have an equivalence
(base = base) ' Z.
Furthermore, since Z is a 0-type and not a (−1)-type, it follows that the circle is a
1-type and not a 0-type.
15. EXERCISES 111
Exercises
15.1 Show that the map
Z → Ω ( S1 )
is a group homomorphism. Conclude that the loop space Ω (S1 ) as a group is
isomorphic to Z.
15.2 Use the fundamental cover of the circle to show that
¬ ∏ (t:S1 ) base = t .
15.4 The (twisted) double cover of the circle is defined as the type family T :≡
D(2, neg) : S1 → U , where neg : 2 ' 2 is the negation equivalence of Exercise 7.5.
(a) Show that ¬(∏ (t:S1 ) T (t)).
(b) Construct an equivalence e : S1 ' ∑(t:S1 ) T (t) for which the triangle
e
S1 ∑(t:S1 ) T (t)
deg(2) pr1
S1
commutes.
15.5 Show that (S1 ' S1 ) ' S1 + S1 . Conclude that a univalent universe containing a
circle is not a 1-type.
15.6 (a) Construct a family of equivalences
∏ (t:S1 ) (t = t) ' Z .
[1] Erret Bishop. Foundations of constructive analysis. New York: McGraw-Hill Book Co.,
1967, pp. xiii+370.
[2] The Univalent Foundations Program. Homotopy Type Theory: Univalent Foundations
of Mathematics. Institute for Advanced Study: [Link]
book, 2013.
113
Index
( –, – ), 23 anti-symmetric
−1Z , 21 poset, 86
∅, see empty type ap f , see action on paths
02 , 20 ap-comp, 30
02 6= 12 , 47 ap-concat, 31
0N , 14 ap-id, 30
0Z , 21 ap-inv, 31
1, see unit type ap-refl, 31
12 , 20 apd f , 32
1Z , 21 associativity
2, see booleans of addition on N, 32
3-for-2 property of addition on Z, 48
of contractible types, 56 of dependent function composition,
of equivalences, 47 12
of function composition, 11
A + B, see coproduct of multiplication on N, 32
a = x, see identity type of path concatenation, 29
A → B, see function type of Σ-types, 47
A ' B, see equivalence Aut, 90
as relation, 87 automorphism group, 90
truncatedness, 86 axiom
A × B, see cartesian product function extensionality, 74
action on generators univalence, 83
for the circle, 99 axiom K, 68
action on paths, 30–31
ap-comp, 30 B A , see function type
ap-concat, 31 base, 96
ap-id, 30 base case, 15
ap-inv, 31 β-rule
ap-refl, 31 for Π-types, 9
addN , 16 bi-implication, 81, 85
addN (m) is an embedding, 71 bi-invertible map, see equivalence
addZ , 24 binomial coefficient, 18, 77
addition on N, 16–17 binomial theorem, 76
annihilation laws Bishop on the positive integers, 13
cartesian product, 46 boolean algebra, 20, 24
anti-reflexive, 40 boolean logic, 20
115
116 INDEX
ind∅ , 19 family, 3
induction principle, 19 constant family, 5
is a proposition, 66 fiber of, 4
rules, 24 fibers of projection map, 56
universal property, 81 of finite types, 38
encoding of a type in a universe, 33 transport, 31
enough universes, 35–37 trivial family, 5
Eq2 , 40 universal family, 34
Eq-fib, 52 family of equivalences, 57–60
EqN , 38 fib f (b), 52
EqΣ , 45 fiber, 52
eq-equiv, 83 characterization of identity type, 52
eq-htpy, 73 Eq-fib, 52
eq-pair, 45 of a family, 4
equiv-eq, 83 of tot ( f ), 57
is a group isomorphism, 95 Fibonacci sequence, 14, 18, 25
equivalence, 41–49 fibrant replacement, 57
3-for-2 property, 47 Fin, 76
closed under homotopies, 46 Fin, 38
composition, 47 finite types, 38
has an inverse, 43 first projection map, 23
inverse, 43 flatten-list, 25
is a contractible map, 56 fold-list, 25
is an embedding, 62 function
pointed equivalence, 87 action on paths, 30
postcomposition, 80 addition on N, 16–17
precomposition, 78 binomial coefficient, 18
equivalence induction, 84 const, 12
equivalence relation constant function, 12
observational equality on N, 40 exponentiation on N, 18
η-rule, 85 factorial operation, 18
for Π-types, 9 has a retraction, 43
ev-inl-inr, 81 has a section, 43
ev-pair, 77, 78 has an inverse, 43
ev-pt, 50, 81 is an equivalence, 43
ev-refl, 78 maxN , 18
evaluation, 9 minN , 18
exponentiation function on N, 18 mulN , 18
extensionality principle pr1 , 23
for functions, 73 pr2 , 23
for propositions, 85 predZ , 24
for types, 83 succN , 14
succZ , 22
f + g, see functorial action, of coproducts swap, 13
f ∼ g, see homotopy is an equivalence, 44
factorial operation, 18 function extensionality, 73
INDEX 119
inv, 28 htpy-eq, 73
is an equivalence, 46 htpy-inv, 80
inv-con, 32 identity function, 44
inverse inv, 46
of an equivalence, 43 inverse of an equivalence, 43
is an equivalence, 43 neg2 , 47
inverse law operations pair-eq, 45
for identifications, 30 pr1 of contractible family, 56
inverse laws succZ , 47
for a group, 89 swap function, 44
for addition on Z, 48 tot ( f ) of family of equivalences, 58
for semi-group isomorphisms, 91 tr B ( p), 46
inverse operation is contractible
for identifications, 28 factor of contractible cartesian prod-
is a contractible map, 52 uct, 56
equivalence, 56 fiber of an equivalence, 56
is a proposition identity type of contractible type, 56
contractible type, 66 iff singleton induction, 50
d | n for d > 0, 71 is a property, 80
empty type, 66 total space of an identity system, 61
is a set, 68 total space of identity type, 51
natural numbers, 69 total space of opposite identity type,
is an embedding, 62 56
(−1)-truncated map, 71 unit type, 50
∅ → A, 64 is family of equivalences
addN (m), 71 iff tot ( f ) is an equivalence, 58
composite of embeddings, 64 is-coh-invertible( f ), 53
equivalence, 62 is-contr( A), see contractible type
if the action on paths have sections, is a proposition, 80
65 is-contr( f ), see contractible map
injective map into a set, 69 is-decidable
inl (for coproducts), 64 is a proposition, 87
inr (for coproducts), 64 is-emb( f ), 62
left factor of embedding if right fac- is-equiv( f ), 43
tor is an equivalence, 64 is a proposition, 80
mulN (m) for m > 0, 71 is-equiv( f ) ' is-coh-invertible( f ), 81
right factor of embedding if left fac- is-equiv( f ) ' is-contr( f ), 80
tor is an embedding, 64 is-equiv( f ) ' path-split( f ), 81
succN , 71 is-function( R), 87
is an equivalence, 43 is-group, 89
action on paths of an embedding, 62 is a proposition, 89
concat0 (q), 46 is-group0 , 89
concat( p), 46 is a proposition, 89
contractible map, 52 is-iso for semi-groups, 91
htpy-concat0 (K ), 80 is a proposition, 91
htpy-concat( H ), 80 is-prop0 ( A), 66
122 INDEX
property, 68 formation, 14
proposition, 66–68 induction principle, 15
closed under equivalences, 67 introduction rules, 14
propositional extensionality, 85, 86 for type dependency
propositions as types change of variables, 6
conjunction, 24 interchange, 6
ptx , 19 rules for judgmental equality, 3–4
rules for substitution, 4
refl, 27 rules for weakening, 5
reflexive term conversion, 7
poset, 86 variable conversion, 3
reflexive relation, 40 variable rule, 5
relation for unit type, 24
anti-reflexive, 40 identity type, 27
functional, 87
opposite relation, 87 S1 , 96, see circle
order, 40 sec( f ), 43
reflexive, 40 second projection map, 23
retr( f ), 43 section
retract of a map, 43
identity type, 47 section of a family, 3
of a type, 43 Semi-Group, 88
retraction, 43 identity type, 92
reverse-list, 25 is a 1-type, 92
Rezk-complete, 94 is a category, 94
right-inv, 30 semi-group, 88
right-unit, 29 has inverses, 89
right unit law, see unit laws homomorphism, 90
rules is a pre-category, 94
for booleans, 24 unital, 88
for cartesian product, 24 semi-ring laws
for coproduct, 24 for N, 32
for dependent function types set, 34, 68–69
β-rule, 9 isomorphism, 82
change of bound variable, 8 set-level structure, 88
conversion, 8 sets
η-rule, 9 form a category, 94
evaluation, 9 Σ-type, see dependent pair type
formation, 8 associativity of, 47
λ-abstraction, 9 universal property, 77
λ-conversion, 9 sing-comp, 50
for dependent pair type, 24 sing-ind, 50
for empty type, 24 singleton induction, 50
for function types, 10 iff contractible, 50
for N small type, 35
computation rules, 16 Sn , 90
INDEX 125
identity type, 78
of the circle, 97
Σ-types, 77
unit type, 81
universe, 33–40
enough universes, 35–37
of contractible types, 86
of k-types, 86
of propositions, 86
of sets, 87
small types, 35
U∗ , 37, 87
identity type, 87
variable, 2
variable conversion rules, 3
variable declaration, 2
variable rule, 5
Z, see integers
fundamental cover of S1 , 105
is a group, 90