Lecture. Univalent foundations I [01FG]
- August 27, 2025
- Jon Sterling
Truncation levels [01FV]
The most important idea of univalent foundations is the hierarchy of truncation levels due to Vladimir Voevodsky. The beginning of the truncation hierarchy maps directly onto classical notions like “exists uniquely” and “is unique if it exists”. Ascending higher in the hierarchy, we discover new notions that are not accounted directly for by traditional foundations.
Definition Contractible types [01FJ]
We say that a type A is contractible when we have a unique element of that type. To formalise this statement in type theory, we combine sums, products, and identification types:
\mathsf {isContr}(A) :\equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}} {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(y:A)}} x=_A yRemark Revisiting the contractibility of singletons [01FW]
We previously saw the contractibility of singletons in our discussion of the identification elimination rule. Indeed, we can show that for any u:A the singleton type \{u\}_A is contractible in this sense, with the witness \left \langle \left \langle u,\mathsf {refl}_u\right \rangle , h\right \rangle : \mathsf {isContr}(\{u\}_A) where h: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(v:\{u\}_A)}} \left \langle u,\mathsf {refl}_u\right \rangle =_{\{u\}_A}v is defined by the following equation: h~\left \langle u,\mathsf {refl}_u\right \rangle :\equiv \mathsf {refl}_{\left \langle u, \mathsf {refl}_u\right \rangle }
Example The unit type is contractible [01FX]
The uniqueness rule states that every element of the unit type is judgementally equal to (). So we may witness \mathsf {isContr}(\mathsf {unit}) by \left \langle (), \lambda y\mathpunct {.} \mathsf {refl}_{()}\right \rangle .
Definition Propositions [01FK]
A proposition is defined to be a type in which any two elements may be identified. (But it could be empty!) This is formalised in type theory as follows:
\mathsf {isProp}(A) :\equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} x=_A yIn traditional mathematics, one more often uses the phrase “truth value” for what we call a “proposition”. This usage is OK, but will not take it to mean that we assume every truth value is either “true” (the unit type) or “false” (the empty type).
Exercise The empty type is a proposition [01FZ]
Show that \mathsf {empty} is a proposition.
Exercise Contractible types vs. propositions [01G1]
Show that any contractible type is a proposition; give an example of a proposition that is not contractible, with proof.
Definition Sets [01FY]
In univalent foundations, we define a set to be a type whose identification types are all propositions. This is formalised in type theory as follows:
\mathsf {isSet}(A) :\equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isProp}(x=_Ay)Discussion Why are they called “sets”? [01G2]
Why do we call a type whose identification types are all propositions a “set”? In ordinary set-theoretic mathematics, two things being equal is always a proposition in the sense that there is always at most one way for two things to be equal. In type theory, we can call a type a “set” when it behaves like a traditional set in precisely this sense.
Sets in traditional foundations are also associated with the well-ordering of the \in -relation, which isn’t something we can talk about directly for types, and we don’t intend to invoke it when we speak of sets in univalent foundations. Type theorists capture this aspect of set theory by developing theories of trees and ordinals.
Voevodsky saw that contractible types, propositions, and sets form the beginning of a hierarchy that measures how “complicated” a type is (in a certain sense). We can define the rest of that hierarchy by induction, starting (conventionally) at -2.
Definition n-truncated types [01FL]
A type is -2-truncated when it is contractible. A type is k+1-truncated when all of its identification types are k-truncated.
\begin {aligned} \mathsf {isTrunc}_{-2}(A) &:\equiv \mathsf {isContr}(A) \\ \mathsf {isTrunc}_{k+1}(A) &:\equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isTrunc}_k(x=_Ay) \end {aligned}Lemma Propositions are (some) sets [01G4]
Any proposition A is also a set. Assuming h_A: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} x=_A y we must fill in the following hole: \begin {aligned} & \mathsf {propsAreSets}_A : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isProp}(x=_Ay) \\ &\mathsf {propsAreSets}_A~x~y :\equiv \{{?}[x,y]:\mathsf {isProp}(x=_Ay)\} \end {aligned}
Because contractible types are propositions, we can refine the goal further (this is a bit of a leap!):
\begin {aligned} & \mathsf {propsAreSets}_A : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isProp}(x=_Ay) \\ &\mathsf {propsAreSets}_A~x~y :\equiv \mathsf {contrTypesAreProps}~ \{{?}[x,y]:\mathsf {isContr}(x=_Ay)\} \end {aligned}To fill in the hole, we start making an auxiliary definition:
\begin {aligned} & \mathsf {propsAreSetsAux}_A : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isContr}(x=_Ay) \\ &\mathsf {propsAreSetsAux}_A~x~y = \{{?}[x,y]:\mathsf {isContr}(x=_Ay)\} \\\\ & \mathsf {propsAreSets}_A : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isProp}(x=_Ay) \\ &\mathsf {propsAreSets}_A~x~y :\equiv \mathsf {contrTypesAreProps}~(\mathsf {propsAreSetsAux}_A~x~y) \end {aligned}We start refining our auxiliary definition.
\begin {aligned} & \mathsf {propsAreSetsAux}_A : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isContr}(x=_Ay) \\ &\mathsf {propsAreSetsAux}_A~x~y~.1:\equiv \{{?_1}[x,y]:x=_Ay\} \\ &\mathsf {propsAreSetsAux}_A~x~y~.2~p:\equiv \{ {?_2}[x,y,p]: {?_1}[x,y] =_{x=_Ay} p \} \end {aligned}It is at this point where an idea is required, as there are several possibilities for how we might fill in ?_1. If we try defining {?_1}[x,y] :\equiv h_Axy, we will get stuck trying to fill in ?_2[x,y,p]. On the other hand, let's consider how we might eventually fill in the second hole regardless of how the first one gets filled in. It seems natural that we would use identification elimination to get rid of (y,p):
\begin {aligned} & \mathsf {propsAreSetsAux}_A : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isContr}(x=_Ay) \\ &\mathsf {propsAreSetsAux}_A~x~y~.1:\equiv \{{?_1}[x,y]:x=_Ay\} \\ &\mathsf {propsAreSetsAux}_A~x~x~.2~\mathsf {refl}_x:\equiv \{ {?_2}[x]: {?_1}[x,x] =_{x=_Ax} \mathsf {refl}_x \} \end {aligned}This is very interesting. What we know is that howsoever we fill in ?_1[x,y], we need to identify the “diagonal” case ?_1[x,x] with \mathsf {refl}_x. If we filled in {?_1}[x,y] :\equiv h_Axy we would be stuck when we try to fill in {?_2}[x]:h_Axx =_{x=_Ax}\mathsf {refl}_x. What we know is that whatever we do is going to have to involve h_Axy because that is the only way to identify x and y that we have in scope; but we need to do something that will vanish when x\equiv y. In this diagonal case, we will have some expression involving h_Axx and we want the rest of that expression to cancel this out so that we get \mathsf {refl}_x. One way to ensure this would be to find a way to define {?_1}[x,y] such that {?_1}[x,x] \equiv \overline {h_Axx}\cdot h_Axx, since this would cancel out due to the laws of identification flipping (see Exercise [01EN]). Thinking about this, we can come up with two good ideas for instantiating the hole:
- We could set {?_1}[x,y] :\equiv h_Axy\cdot \overline {h_Ayy}.
- Or we could set {?_1}[x,y] :\equiv \overline {h_Axx}\cdot h_Axy.
Both ideas will work, because we shall have h_Axx\cdot \overline {h_Axx} =_{x=_Ax} \mathsf {refl}_x =_{x=_Ax} \overline {h_Axx}\cdot h_Axx! Let’s do the second one:
\begin {aligned} & \mathsf {propsAreSetsAux}_A : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isContr}(x=_Ay) \\ &\mathsf {propsAreSetsAux}_A~x~y~.1:\equiv \overline {h_Axx}\cdot h_Axy \\ &\mathsf {propsAreSetsAux}_A~x~x~.2~\mathsf {refl}_x:\equiv \mathsf {flipPasteFlipLaw}~(h_Axx) \end {aligned}Above, we wrote \mathsf {flipPasteFlipLaw} for the witness constructed in Exercise [01EN].
Lemma Truncation levels for propositions [01G3]
A type is a proposition if and only if it is -1-truncated
We compute out the formal definition of -1-truncation for a type A:
\mathsf {isTrunc}_{-1}(A) \equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isTrunc}_{-2}(x=_Ay) \equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isContr}(x=_Ay)If A is -1-truncated, then it is clearly a proposition, as we have the projection function \mathsf {isContr}(x=_Ay) \to x=_Ay. Conversely, suppose that A is a proposition. Fixing x,y:A we must show that the identification type x=_Ay is contractible by giving an element of the following type:
{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(p:x=_Ay)}} {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(q:x=_Ay)}} p=_{x=_Ay}qFor the first component, we use our assumption that A is a proposition so any two of its elements may be identified. For the second component, it would suffice to show that for any x,y:A and p,q:x=_Ay we may witness p=_{x=_Ay} q. This is the same as showing that A is a set, which follows from the fact that propositions are sets.
Lemma Truncation levels for sets [01GB]
A type is a set if and only if it is 0-truncated.
We compute out the formal definition of 0-truncation for a type A:
\mathsf {isTrunc}_0(A) \equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isTrunc}_{-1}(x=_Ay)By our previous lemma characterising propositions, this is equivalent to being a set. (We haven’t yet formalised the appropriate notion of “equivalence”, but for now it suffices that we can pass from set-hood to 0-truncation and vice versa.)
Lemma Upward closure of n-truncated types [01FM]
For n\geq -2, any n-truncated type is n+1-truncated.
When n\equiv -2, we must check that any contractible type is also -1-truncated; we have seen that propositions are precisely the -1-truncated types, and we have also seen that contractible types are propositions.
In the inductive step, suppose that every n-truncated type is n+1-truncated. We must show that every n+1-truncated type is n+2-truncated. Fixing n+1-truncated A, so that we have h: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isTrunc}_n(x=_Ay) we must construct verify that A is n+2-truncated by constructing a witness of: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isTrunc}_{n+1}(x=_Ay)
Fixing x,y:A, we must find an element of \mathsf {isTrunc}_{n+1}(x=_Ay). Our inductive hypothesis says that all n-truncated types n+1-truncated. Instantiating our assumption, we have hxy:\mathsf {isTrunc}_n(x=_Ay) and so we conclude \mathsf {isTrunc}_{n+1}(x=_Ay) by our induction hypothesis.
Remark External vs. internal induction [01GC]
Our statement of the upward closure of n-truncation should be understood, at this point, to be schematic in truncation levels; and so the induction on truncation levels is external. In the future, once we have a type of natural numbers, we would be able to state and prove this property entirely inside of type theory using the elimination rule of the natural numbers. Note that the induction hypothesis involves a quantification over “all” types, so we would need to use a universe in that case.
(If this remark mystifies you, don’t get hung up on it; it can safely be ignored until we have achieved the needed sensitivity.)
Decidable equality and Hedberg’s theorem [01FN]
A famous result of type theory says that any type whose identification types are decidable (“has decidable equality” for short) is a set. This is not easy to prove directly, and in fact there are a number of proofs that work using different assumptions. We haven’t assumed much yet, so some of those proofs are not yet accessible to us. But there is one proof that we can do based on the idea of a “weakly constant function”. First we define decidable equality formally:
Definition Decidability [01GR]
A type A is said to be decidable when we have either an element of A or a proof that there can be no such element. This is formalised in the following type:
\mathsf {isDec}(A) :\equiv A + (A\to \mathsf {empty})Definition Decidable equality [01GG]
A type A is said to have decidable equality when all of its identification types are decidable:
\mathsf {hasDecEq}(A) :\equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isDec}(A) x=_Ay + (x=_Ay\to \mathsf {empty})Warm-up How shall we proceed? [01GO]
We assume that some type A has decidable equality, so that we have d_A:\mathsf {hasDecEq}(A) in our pocket. Fixing x,y:A and p,q:x=_Ay we need to show that p=_{x=_Ay}q.
We can’t just use identification elimination
First of all, we note that using identification elimination here gets us nowhere: if we contract (y,p) to (x,\mathsf {refl}_x) then we are trying to show that q=_{x=_Ax}\mathsf {refl}_x for all x and q and that is not any easier than what we started with. (The symmetric thing will happen if we instead contract (y,q).)
Idea: a weakly constant identity function
Another idea would be to try to find some further identifications r,s:x=_Ay where it is easy to show that p=_{x=_Ay}r and and r=_{x=_Ay}s and s=_{x=_Ay}q and thus p=_{x=_Ay}q. It doesn’t seem like at first like this would help, but one rule of thumb is that adding extra “flex” into the problem can really help in univalent foundations. If we make just one leap and decide that we shall obtain r from p and s from q respectively by means of some function, then we can get a good idea of what properties that function needs to have:
- In order to make p=r and q=s, our function needs to behave like the identity function.
- In order to make r=s our function needs to give equal outputs regardless of the inputs (i.e., it should be “constant” in a certain sense).
Of course, this is all a little magical and you might not have any reason as-yet to believe that we can carry out the idea above. But it will happen that it is possible and not too difficult. First we must make a few preliminary definitions:
Definition Weakly constant function [01GP]
A function f:A\to B is called weakly constant when any two of its values can be identified. In other words, we have an element of the following type:
\mathsf {isWeaklyConstant}(f) :\equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} fx=_A fyDefinition Identity function [01GQ]
A function f:A\to A is called an identity function when we its value on #x:A can be identified with x; in other words, when we have an element of the following type:
\mathsf {isIdentity}(f) :\equiv {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:A)}} fx=_AxTheorem Hedberg’s theorem [01GM]
Any type A that has decidable equality is a set. Assuming H_A:\mathsf {hasDecEq(A)}, we must check that for all x,y:A and p,q:x=_Ay we have p=_{x=_Ay}q. Putting that aside for now, we first consider that when an individual identification type x=_Ay is decidable, we can “replace” any specific identification p:x=_Ay with the result of the decision procedure.
\begin {aligned} &\mathsf {repl}_{x,y}:\mathsf {isDec}(x=_Ay)\to x=_Ay\to x=_Ay \\ &\mathsf {repl}_{x,y}~(\mathsf {inl}~q)~p :\equiv q \\ &\mathsf {repl}_{x,y}~(\mathsf {inr}~h)~p :\equiv \mathsf {abort}~(hp) \end {aligned}We can show that for each d:\mathsf {isDec}(x=_Ay), the function \mathsf {repl}_{x,y}~d is weakly constant without much difficulty by cases on d:
\begin {aligned} &\mathsf {replIsWeaklyConstant}_{x,y}: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(d:\mathsf {isDec}(x=_Ay))}} \mathsf {isWeaklyConstant}~(\mathsf {repl}_{x,y}~d) \\ &\mathsf {replIsWeaklyConstant}_{x,y}~(\mathsf {inl}~r)~p~q :\equiv \mathsf {refl}_{r} \\ &\mathsf {replIsWeaklyConstant}_{x,y}~(\mathsf {inr}~h)~p~q :\equiv \mathsf {abort}~(hp) \end {aligned}Unfortunately, we cannot seem to show that \mathsf {repl}_{x,y}~d is the identity function. Indeed, to define the case for d\equiv \mathsf {inl}~r we would need to show that any identification p:x=_Ay is equal to r, which is just as hard as our main goal. We can wriggle out of this tough spot using a trick we’ve seen before: we can “pad” \mathsf {repl}_{x,y} with a flipped instance of \mathsf {refl}_{x,x} on either the left-hand or the right-hand side. Then later on, the two will cancel out. Using our witness h_A:\mathsf {hasDecEq}(A), let us define a new function to “clean” an identification:
\begin {aligned} &\mathsf {clean}^{h_A}_{x,y}:x=_Ay\to x=_Ay \\ &\mathsf {clean}^{h_A}_{x,y}~p :\equiv \overline { \mathsf {repl}_{x,x}~(h_Axx)~\mathsf {refl}_x } \cdot \mathsf {repl}_{x,y}~p \end {aligned}First we check that \mathsf {clean}_{x,y} is the identity function:
\begin {aligned} & \mathsf {cleanIsIdentity}_{h_A}: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isIdentity}(\mathsf {clean}^{h_A}_{x,y}) \\ & \mathsf {cleanIsIdentity}_{h_A}~x~y~p :\equiv \bigl \{ ?: \mathsf {clean}^{h_A}_{x,y}~p =_{x=_Ay} p \bigr \} \end {aligned}We proceed by identification elimination on (y,p) and unravel the definition of \mathsf {clean}:
\begin {aligned} & \mathsf {cleanIsIdentity}_{h_A}: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isIdentity}(\mathsf {clean}^{h_A}_{x,y}) \\ & \mathsf {cleanIsIdentity}_{h_Axx}~\mathsf {refl}_x :\equiv \bigl \{ ?: \overline { \mathsf {repl}_{x,x}~(h_Axx)~\mathsf {refl}_x } \cdot \mathsf {repl}_{x,x}~(h_Axx)~\mathsf {refl}_x =_{x=_Ax} \mathsf {refl}_x \bigr \} \end {aligned}But that is just the left unit law for flipping:
\begin {aligned} & \mathsf {cleanIsIdentity}_{h_A}: {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x,y:A)}} \mathsf {isIdentity}(\mathsf {clean}^{h_A}_{x,y}) \\ & \mathsf {cleanIsIdentity}_{h_A}~x~x~\mathsf {refl}_x :\equiv \mathsf {flipLeftUnit}(\mathsf {repl}_{x,x}~(h_Axx)~\mathsf {refl}_{x}) \end {aligned}We still need to check that \mathsf {clean}^{h_A}_{x,y} is weakly constant; luckily, we can reuse our proof that \mathsf {repl}_{x,y} is weakly constant:
\begin {aligned} & \mathsf {cleanIsWeaklyConstant}^{h_A}_{x,y} : \mathsf {isWeaklyConstant}(\mathsf {clean}^{h_A}_{x,y}) \\ & \mathsf {cleanIsWeaklyConstant}^{h_A}_{x,y}~p~q :\equiv \\ &\quad \bigl \{ ?: \overline {\mathsf {repl}_{x,x}~(h_Axx)~\mathsf {refl}_x} \cdot \mathsf {repl}_{x,y}~(h_Axy)~p =_{x=_Ay} \overline {\mathsf {repl}_{x,x}~(h_Axx)~\mathsf {refl}_x} \cdot \mathsf {repl}_{x,y}~(h_Axy)~q \bigr \} \end {aligned}We already know that \mathsf {repl}_{x,y}~(h_Axy)~p=_{x=_Ay}\mathsf {repl}_{x,y}~(h_Axy)~q because we have shown that \mathsf {repl}_{x,y} is weakly constant. So we use the action on identifications:
\begin {aligned} & \mathsf {cleanIsWeaklyConstant}_{x,y} : \mathsf {isWeaklyConstant}(\mathsf {clean}^{h_A}_{x,y}) \\ & \mathsf {cleanIsWeaklyConstant}_{x,y}~p~q :\equiv \mathsf {act}_{\lambda r\mathpunct {.} \overline {\mathsf {repl}_{x,x}~\mathsf {refl}_x}\cdot r} \bigl (\mathsf {replIsWeaklyConstant}_{x,y}~(h_Axy)\bigr ) \end {aligned}Finally we can combine all this to verify Hedberg’s theorem:
\begin {aligned} & \mathsf {hedberg}:\mathsf {hasDecEq}(A)\to \mathsf {isSet}(A) \\ & \mathsf {hedberg}~h_A~x~y~p~q :\equiv \\ &\begin {array}{l} \overline {\mathsf {cleanIsIdentity}_{h_A}~x~y~p} \\ {}\cdot \mathsf {cleanIsWeaklyConstant}^{h_A}_{x,y}~p~q \\ {}\cdot \mathsf {cleanIsIdentity}_{h_A}~x~y~q \end {array} \end {aligned}n-truncated functions and equivalences [01HA]
- September 12, 2025
- Jon Sterling
We recall the definition of fibres:
Definition Fibres [01ES]
By combining function types, dependent pair types, and identification types, we can finally define something useful. Given a function f:A\to B and an element b:B, we define the fibre of f over b to by the type of elements of A whose image in B is identified with b:
\mathsf {fib}_f(b) :\equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}} fx=_B bWe could have defined fibres with an equation in the opposite direction. The two versions are going to be equivalent; but if it matters, we’ll write the following notations:
\begin {aligned} \mathsf {fib}^-_f(b) &:\equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}{fx=_Bb} \\ \mathsf {fib}^+_f(b) &:\equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}{b=_B fx} \end {aligned}In mathematics, a property that is defined for sets (or spaces, algebras, etc.) is often generalised to pertain to functions (or homomorphisms, etc.) by imposing the original property on the fibres of the function; then the original notion is recovered for a given set X by consider the universal map X\to \mathsf {unit}. Generalising the idea of n-truncation from types to functions gives rise to one of the most important concepts in univalent foundations: the equivalence.
Definition n-truncated function [01HB]
- September 12, 2025
- Jon Sterling
A function f:A\to B is said to be n-truncated when all of its fibres \mathsf {fib}_{f}(x) for x:B are n-truncated.
In particular, a function is called contractible (resp. propositional) when all of its fibres are contractible (resp. propositions). The notion of a contractible function will be our first (of many) equivalent formalisations of the concept of “equivalence” between types. Each time we introduce a new notion of equivalence, we will that it is equivalent to the prior notions and thenceforth treat them interchangeably.
Definition Equivalence (I) [01HC]
- September 12, 2025
- Jon Sterling
A function f:A\to B is called an equivalence when it is contractible.
Homotopies, sections, retractions, (bi-)inverses [01FH]
So far we have encountered three possible kinds of sameness for dependent functions f,g:{\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:A)}}{B[x]}:
- They could be judgementally equal in the sense that f\equiv g:{\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:A)}}{B[x]} holds. We have seen that this is equivalent to the values of the function being equal in the sense that x:A\vdash fx\equiv gx:B[x] holds.
- They could be identified by an element p:f=_{{\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:A)}}B[x]}g of the identification type.
- Their values could be identified by a family x:A\vdash h[x]:fx=_{B[x]}gx of identifications, or (equivalent) by a dependent function h:{\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:A)}}fx=_{B[x]}gx assigning identifications to elements of A.
The third notion is above is called a homotopy from f to g. With the foundations that we have set up so far, homotopies are the most correct way to express the mathematical sameness of two functions. Later on, we will see how univalent foundations ensures that identifications of functions (the second notion) are equivalent to homotopies between functions.
Definition Homotopy [01FO]
Let f,g:{\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:A)}}{B[x]} be two dependent functions. A homotopy from f to g is defined to be a dependent function h:{\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(x:A)}}{fx=_{B[x]}gx} sending each element of A to an identification between its respective values in f and g. We will sometimes write f\sim g for the type of homotopies from f to g.
Definition Sections and retractions [01FQ]
A section-retraction pair is defined to be a pair of functions s:B\to A and r:A\to B equipped with a homotopy r\circ s\sim 1_B. In this context, s is called a section of r and r is called a retraction of s. The idea is that r “undoes” or “retracts” whatever s does. B is called a retract of A in the presence of such a section-retraction pair.
Given a function r:A\to B, the type of sections of r can be defined by a sum:
\mathsf {sectionOf}(r) :\equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(s:B\to A)}} r\circ s \sim 1_BLikewise, for a function s:B\to A, the type of retractions of s can be defined similarly:
\mathsf {retractionOf}(s) :\equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(r:A\to B)}} r\circ s\sim 1_BIn both scenarios, such a section-retraction pair is said to witness that B is a retract of A.
Lemma Propositions are closed under retracts [01H5]
Any retract of a proposition is a proposition.
Proof.
Let A be a proposition and let B a retract of A as witnessed by a section-retraction pair as follows:
\begin {aligned} &s:B\to A \\ &r:A\to B \\ &h:r\circ s\sim 1_B \end {aligned}We fix any two elements x,y:B, and we need to witness x=_By. Because A is a proposition, we have some identification p:sx=_Asy\text {,} upon which the action on identifications of the retraction r:A\to B yiels \mathsf {act}_{r}p:rsx=_Brsy\text {.}
Conjugating with the homotopy h:r\circ s\sim 1_B we obtain:
hx \cdot \mathsf {act}_rp \cdot \overline {hy}: x=_ByLemma Contractible types are closed under retracts [01H4]
As propositions are closed under retracts, it suffices to observe that inhabited types are also closed under retracts.
Construction Sums of retracts [01H3]
Fix types A,A'~\mathit {type} and families x:A\vdash B[x]~\mathit {type} and x:A'\vdash B'[x]~\mathit {type}. Suppose that A be a retract of A' as witnessed by \begin {aligned} &s_A:A\to A' \\ &r_A:A'\to A \\ &h_A:r_A\circ s_A\sim 1_{A} \end {aligned} and for each x:A' the component B[r_Ax] is a retract of B'[x] as witnessed by \begin {aligned} &s_B^x: B[r_Ax]\to B'[x] \\ &r_B^x: B'[x]\to B[r_Ax] \\ &h_B^x: r_B^x\circ s_B^x \sim 1_{B[r_Ax]} \text {.} \end {aligned}
Then we may exhibit {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}{B[x]} as a retract of {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A')}}{B'[x]} as follows. We define the retraction first:
\begin {aligned} &r: {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A')}}{B'[x]} \to {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}{B[x]} \\ & (r\left \langle x,y\right \rangle ).1 :\equiv r_Ax \\ & (r\left \langle x,y\right \rangle ).2 :\equiv r_B^{x}y \end {aligned}The section is more difficult. We start as follows:
\begin {aligned} &s:{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x] \to {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A')}}{B'[x]} \\ &(s \left \langle x,y\right \rangle ).1:A' \\ &(s\left \langle x,y\right \rangle ).2: B'[ (s\left \langle x,y\right \rangle ).1 ] \end {aligned}In the first component, we have only one choice: to use section s_A.
\begin {aligned} &s:{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x] \to {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A')}}{B'[x]} \\ & (s \left \langle x,y\right \rangle ).1 :\equiv s_Ax \\ &(s\left \langle x,y\right \rangle ).2: B'[ s_Ax ] \end {aligned}In the second component, we have no choice but to the section s_B^{s_Ax}, which requires as input an element of B[r_A(s_Ax)]. As r_A is a section of s_A, we have an identification h_Ax:r_A(s_Ax)=_Ax, along which we must transport.
\begin {aligned} &s:{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x] \to {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A')}}{B'[x]} \\ & (s \left \langle x,y\right \rangle ).1 :\equiv s_Ax \\ & (s\left \langle x,y\right \rangle ).2 :\equiv s_B^{s_Ax}\left ( \overline {h_Ax}_*^B y \right ) \end {aligned}Next we must construct the homotopy witnessing the section-retraction pair.
x:A, y:B[x] \vdash h\left \langle x,y\right \rangle : r(s\left \langle x,y\right \rangle ) =_{{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x]} \left \langle x,y\right \rangleUnravelling definitions, this is:
x:A, y:B[x] \vdash h\left \langle x,y\right \rangle : \left \langle r_A(s_Ax), r_B^{s_Ax} \left ( s_B^{s_Ax}\left ( \overline {h_Ax}_*^By \right ) \right ) \right \rangle =_{{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x]} \left \langle x,y\right \rangleAt this point, we must “generalise” the goal in order to replace the complicated parts by variables that we can then contract using identification elimination. In this case, we will generalise over the pair \left \langle s_A x, h_Ax\right \rangle : {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x':A')}}{r_Ax'=x} so that our generalised goal becomes \begin {aligned} &x:A, x':A', p:r_Ax'=_Ax, y:B[x] \vdash \\ &\quad h'~\left \langle x,y\right \rangle ~\left \langle x',p\right \rangle : \left \langle r_Ax', r_B^{x'} \left ( s_B^{x'}\left ( \bar {p}_*^By \right ) \right ) \right \rangle =_{{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x]} \left \langle x,y\right \rangle \end {aligned} so that we may define h\left \langle x,y\right \rangle :\equiv h'~\left \langle x,y\right \rangle ~\left \langle s_Ax,h_Ax\right \rangle
To fill in the generalised term h', we proceed by identification elimination on (x,p):
\begin {aligned} & x':A', y:B[r_Ax'] \vdash \\ &\quad h'~\left \langle r_Ax',y\right \rangle ~\left \langle x',\mathsf {refl}_{r_Ax}\right \rangle : \left \langle r_Ax', r_B^{x'} \left ( s_B^{x'}\left ( \overline {\mathsf {refl}_{r_Ax'}}_*^By \right ) \right ) \right \rangle =_{{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x]} \left \langle r_Ax',y\right \rangle \end {aligned}Recalling that flipping and transport are both defined so as to compute definitionally on the reflexivity term, our goal gets simpler:
x':A', y:B[r_Ax'] \vdash h'~\left \langle r_Ax',y\right \rangle ~\left \langle x',\mathsf {refl}_{r_Ax}\right \rangle : \left \langle r_Ax', r_B^{x'} ( s_B^{x'}y ) \right \rangle =_{{\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}B[x]} \left \langle r_Ax',y\right \rangleWe can now use the action on identifications of the pairing function \left \langle r_Ax',-\right \rangle \colon B[r_Ax'] \to {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(x:A)}}{B[x]} on the identification h_B^{x'}y:r_B^{x'}(s_B^{x'}y) =_{B[r_Ax']} y as follows:
x':A', y:B[r_Ax'] \vdash h'~\left \langle r_Ax',y\right \rangle ~\left \langle x',\mathsf {refl}_{r_Ax'}\right \rangle :\equiv \mathsf {act}_{\left \langle r_Ax',-\right \rangle } (h_B^{x'}y)Definition Quasi-inverse [01H7]
A quasi-inverse to a function f:A\to B is given by another function \bar {f}:B\to A that is simultaneously a section and a retraction of f:
\begin {aligned} &\bar {f}:B\to A\\ &\epsilon :f\circ \bar {f} \sim 1_B\\ &\eta :\bar {f}\circ f \sim 1_A\\ \end {aligned}A function is called quasi-invertible when it is equipped with a quasi-inverse.
Definition Bi-inverse [01FI]
A bi-inverse to a function f:A\to B is defined to be a pair of a section and a retraction of f. This amounts to the following data:
- The section s:B\to A with its witnesssing homotopy \sigma :f\circ s\sim 1_B.
- The retraction r:B\to A with its witnessing homotopy \rho :r\circ f\sim 1_A.
A function is called bi-invertible when it is equipped with a bi-inverse.
Remark Why a separate section and retraction? [01FT]
In ordinary mathematics when working with sets, we would define an isomorphism from A to B to be a function f:A\to B together with a function g\colon B\to A that is simultaneously a section and a retraction of f. In set theoretic foundations, the set of isomorphisms from A to B is isomorphic to the set of equivalences (in our sense) from A to B. But in univalent foundations, although we can convert in either direction, the round trips do not line up.
The problem is that in univalent foundations, it is not a mere property of a function that it be simultaneously a section and a retraction of another function. The data of the homotopy matters. We will see later on that a function being bi-invertible is actually a proposition, whereas being quasi-invertible.
Lemma From bi-inverses to quasi-inverses [01HG]
- September 12, 2025
- Jon Sterling
Evidently a quasi-invertible function is bi-invertible, as we can simply take both the section and retraction to have the same underlying map. In the other direction, we can show that the underlying map of the section (resp. retraction) of a bi-inverse is simultaneously a retraction (resp. section). This gives us two ways to construct a quasi-inverse from a bi-inverse: you take either the section or the retraction.
In particular, let f:A\to B be a function with a bi-inverse as follows:
\begin {aligned} &s:B\to A \\ &h_s: f\circ s \sim 1_B \\ & r:B\to A \\ &h_r:r\circ f\sim 1_A \end {aligned}Now we may construct a quasi-inverse, setting \bar {f}:\equiv s. We need to construct the following homotopies:
\begin {aligned} &\epsilon : f\circ \bar {f} \sim 1_B \\ &\eta : \bar {f}\circ f \sim 1_A \end {aligned}We may trivially define \epsilon :\equiv h_s. For the retraction datum, we fix x:A and observe that we have h_s(fx) : f(s(fx)) =_A fx and thus \mathsf {act}_{r}(h_s(fx)) : r(f(s(fx))) =_A r(fx) which we may conjugate by h_r to obtain:
\overline {h_r(s(fx))} \cdot \mathsf {act}_r(h_s(fx)) \cdot h_r x : s(fx) =_A xBe careful! Although we have shown above that we can convert between bi-inverses and quasi-inverses, the two notions are not equivalence in the sense of univalent foundations: indeed, it is not the case that function sending a quasi-inverse to a bi-inverse is contractible.
Lemma Quasi-invertible maps are contractible [01H9]
Let f:A\to B be a map equipped with a quasi-inverse:
\begin {aligned} &\bar {f}:B\to A \\ &\epsilon :f\circ \bar {f}\sim 1_A \\ &\eta :\bar {f}\circ f\sim 1_B \end {aligned}Then f is contractible.
Proof.
We want to show that for each b:B, the fibre \mathsf {fib}_fb \equiv {\mathop {\mathchoice {\textstyle \sum }{\textstyle \sum }{\scriptstyle \sum }{\scriptscriptstyle \sum } }_{(a:A)}}fa=_Bb is contractible. We will show that this type is a retract of the singleton \{b\}_B, recalling that contractible types are closed under retracts.
We recall the construction of sums of retracts; to show that \mathsf {fib}_fb is a retract of \{b\}_B, we can start by exhibiting A as a retract of B. For this, we use the section-retraction pair (f,\bar {f},\eta ). Then we need to show that for each x:B the identification type f (\bar {f}x)=_B b is a retract of x=b. We first define the section component:
\begin {aligned} b,x:B; p:f(\bar {f}x)=_Bb &\vdash s_{b,x}p: x=_B b \end {aligned}We proceed by identification elimination.
\begin {aligned} x:B &\vdash s_{f(\bar {f}x),x}\mathsf {refl}_{f(\bar {f}x)}: x=_B f(\bar {f}x) \\ x:B &\vdash s_{f(\bar {f}x),x}\mathsf {refl}_{f(\bar {f}x)} :\equiv \overline {\epsilon x} \end {aligned}Now we need to define the retraction:
\begin {aligned} x,b:B; p:x=_Bb &\vdash r_{x,b}p: f(\bar {f}x)=_Bb \\ x,b:B; p:x=_Bb &\vdash r_{x,b}p:\equiv \epsilon x \cdot p \end {aligned}Finally, the homotopy witnessing the section-retraction pair:
\begin {aligned} x,b:B; p:f(\bar {f}x)=_Bb &\vdash h_{x,b}p: \epsilon x\cdot s_{x,b} p =_{f(\bar {f}x)=_Bb} p \\ x:B &\vdash h_{x,f(\bar {f}x)}~\mathsf {refl}_{f(\bar {f}x)} : \epsilon x \cdot \overline {\epsilon x} =_{f(\bar {f}x)=_Bf(\bar {f}x)} \mathsf {refl}_{f(\bar {f}x)} \end {aligned}We finish up recalling the laws of flipping.
Lemma Contractible maps are quasi-invertible [01HH]
- September 12, 2025
- Jon Sterling
Any contractible map f:A\to B is quasi-invertible.
Proof.
- September 12, 2025
- Jon Sterling
Let us have the following witness of contractibility:
\gamma : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(b:B)}} \mathsf {isContr}( \mathsf {fib}_fb )This means that for each b:B we have:
\begin {aligned} &\gamma (b).1 : \mathsf {fib}_fb \\ &\gamma (b).2 : {\mathop {\mathchoice {\textstyle \prod }{\textstyle \prod }{\scriptstyle \prod }{\scriptscriptstyle \prod } }_{(u:\mathsf {fib}_f(b))}} \gamma (b).1 =_{\mathsf {fib}_fb} u \end {aligned}Unravelling further, this is \begin {aligned} &\gamma (b).1.1 : A\\ &\gamma (b).1.2 : f(\gamma (b).1.1) =_B b\\ \end {aligned} and for each a:A and p:fa=_Bb we have \begin {aligned} \gamma (b).2\left \langle a,p\right \rangle : \gamma (b).1 =_{\mathsf {fib}_fb} \left \langle a,p\right \rangle \end {aligned} and in particular \mathsf {act}_{-.1}(\gamma (b).2\left \langle a,p\right \rangle ) : \gamma (b).1.1 =_A a \text {.}
We now assign names to some of the above.
\begin {aligned} &\bar {f}:B\to A \\ &\bar {f}b :\equiv \gamma (b).1.1 \\[12pt] &\epsilon : f\circ \bar {f} \sim 1_B \\ &\epsilon b :\equiv \gamma (b).1.2 \\[12pt] &\eta : \bar {f}\circ f\sim 1_A \\ &\eta a :\equiv \mathsf {act}_{-.1}(\gamma (b).2\left \langle a,\mathsf {refl}_{fa}\right \rangle ) \end {aligned}Exercises [01G0]
- August 27, 2025
- Jon Sterling
Exercise. Truncation levels › The empty type is a proposition [01FZ]
Show that \mathsf {empty} is a proposition.
Exercise. Truncation levels › Contractible types vs. propositions [01G1]
Show that any contractible type is a proposition; give an example of a proposition that is not contractible, with proof.