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}