% This is the exercise solution document for the homotopy type theory book. % This file supports two book sizes: % - Letter size (8.5" x 11") % - US Trade size (6" x 9") % % To activate one or the other, uncomment the appropriate font size in % the documentclass below, and then one of the two page geometry incantations % % NOTE: The 6" x 9" format is only experimental. It will break the % title page, for example. \PassOptionsToPackage{table}{xcolor} % DOCUMENT CLASS \documentclass[ % %10pt % for US Trade 6" x 9" book % 11pt % for Letter size book ]{article} \usepackage{etex} % We're running out of registers and dimensions, or some such \newcounter{chapter} % So that macros.tex doesn't choke % PAGE GEOMETRY % % Uncomment one of these % We make the page 40pt taller than the standard LaTeX book. % OPTION 1: Letter \usepackage[papersize={8.5in,11in}, twoside, includehead, top=1in, bottom=1in, inner=0.75in, outer=1.0in, bindingoffset=0.35in]{geometry} % OPTION 2: US Trade % \usepackage[papersize={6in,9in}, % twoside, % includehead, % top=0.75in, % bottom=0.75in, % inner=0.5in, % outer=0.75in, % bindingoffset=0.35in]{geometry} % HYPERLINKING AND PDF METADATA \usepackage[pagebackref, colorlinks, citecolor=darkgreen, linkcolor=darkgreen, unicode, pdfauthor={Univalent Foundations Program}, pdftitle={Homotopy Type Theory: Univalent Foundations of Mathematics}, pdfsubject={Mathematics}, pdfkeywords={type theory, homotopy theory, univalence axiom}]{hyperref} % OTHER PACKAGES % Use this package and stick \layout somewhere in the text to see % page margins, text size and width etc. Useful for debugging page format. %\usepackage{layout} %%% Because Germans have umlauts and Slavs have even stranger ways of mangling letters \usepackage[utf8]{inputenc} %%% For table {tab:theorems} \usepackage{pifont} %%% Multi-Columns for long lists of names \usepackage{multicol} %%% Set the fonts \usepackage{mathpazo} \usepackage[scaled=0.95]{helvet} \usepackage{courier} \linespread{1.05} % Palatino looks better with this \usepackage{graphicx} \DeclareGraphicsExtensions{.png} \input{bmpsize-hack} % for bounding boxes in dvi mode \usepackage{comment} \usepackage{wallpaper} % For the background image on the cover page \usepackage{fancyhdr} % To set headers and footers \usepackage{nextpage} % So we can jump to odd-numbered pages \usepackage{amssymb,amsmath,amsthm,stmaryrd,mathrsfs,wasysym} \usepackage{enumitem,mathtools,xspace} \usepackage{xcolor} % For colored cells in tables we need \cellcolor \usepackage{booktabs} % For nice tables \usepackage{array} % For nice tables \usepackage{supertabular} % For index of symbols \definecolor{darkgreen}{rgb}{0,0.45,0} \usepackage{aliascnt} \usepackage[capitalize]{cleveref} \usepackage[all,2cell]{xy} \UseAllTwocells \usepackage{braket} % used for \setof{ ... } macro \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing} \usepackage{etoolbox} % hacking commands for TOC \usepackage{mathpartir} % for formal.tex appendix, section 3 \usepackage[numbered]{bookmark} % add chapter/section numbers to the toc in the pdf metadata \input{macros} %%%% Indexing \usepackage{makeidx} \makeindex %%%% Header and footers \pagestyle{fancyplain} \setlength{\headheight}{15pt} \renewcommand{\sectionmark}[1]{\markright{\textsc{\thesection\ #1}}} \newcommand{\transfun}[3]{\mathcal{I}_{#1}(#2, #3)} \newcommand{\nathom}[2]{\mathsf{nat}_{#1}(#2)} \newcommand{\Tgh}[2]{\mathcal{T}_1(#1,#2)} \newcommand{\T}[2]{\mathcal{T}_2(#1,#2)} \newcommand{\TT}[2]{\mathcal{T}_3(#1,#2)} \newcommand{\I}{\mathcal{I}_1} \newcommand{\II}{\mathcal{I}_2} \newcommand{\hapfuneq}{\mathsf{happly}\mbox{-}\mathsf{funext}\mbox{-}\mathsf{inv}} \lhead[\fancyplain{}{{\thepage}}]% {\fancyplain{}{\nouppercase{\rightmark}}} \rhead[\fancyplain{}{\nouppercase{\leftmark}}]% {\fancyplain{}{\thepage}} \cfoot{\textsc{\scriptsize \textcolor{gray}{[Draft of \today]}}} \lfoot[]{} \rfoot[]{} %%%% Chapter & part style \usepackage{titlesec} \titleformat{\part}[display]{\fontsize{40}{40}\fontseries{m}\fontshape{sc}\selectfont}{\hfil\partname\ \Roman{part}}{20pt}{\fontsize{60}{60}\fontseries{b}\fontshape{sc}\selectfont\hfil} \titleformat{\chapter}[display]{\fontsize{23}{25}\fontseries{m}\fontshape{it}\selectfont}{\chaptertitlename\ \thechapter}{20pt}{\fontsize{35}{35}\fontseries{b}\fontshape{n}\selectfont} \input{main.labels} \title{Solutions to selected exercises} \begin{document} \maketitle \section*{Exercises from \cref{cha:typetheory}} \subsection*{Solution to \cref{ex:composition}} We of course know what composition of functions $f : A \to B$ and $g : B \to C$ should be, but let us see how we might derive it by considering available forms of construction. We want a term \[ g \circ f \defeq (\Box : A \to C), \] where $\Box : A \to C$ indicates that in place of $\Box$ we would like to put something of type $A \to C$. Since we are defining a function whose domain is $A$, we expect it to be of the form \[ g \circ f \defeq \lam{x:A} (\Box : C), \] so now we are looking for something of type $C$, with $x$, $f$ and $g$ available. Of these $g$ looks most promising as it lands in $C$: \[ g \circ f \defeq \lam{x:A} g (\Box : B). \] Now we repeat the same trick with $f$ to get \[ g \circ f \defeq \lam{x:A} g(f(\Box : A)). \] Inside the abstraction $x$ is available and has the type we need, so we define \begin{equation} \label{eq:composdef} g \circ f \defeq \lam{x:A} g(f(x)) : C \end{equation} % This baby example demonstrates how one often works with a proof assistant: look at what you need and what is available, and try to make some progress. Now, suppose given also $h : C \to D$. We have, according to \cref{eq:composdef}, % \begin{align*} h \circ (g \circ f) &\jdeq \lamu{x:A} h ((\lam{y:A} g(f(y))) x)\\ &\jdeq \lamu{x:A} h(g(f(x))), \end{align*} % and % \begin{align*} (h \circ g) \circ f & \jdeq \lamu{x:A} (\lam{y:A} h(g(y))) (f(x))\\ & \jdeq \lamu{x:A} h(g(f(x))). \end{align*} % They are equal, which establishes associativity of composition. \subsection*{Solution to \cref{ex:pr-to-rec}} If we suppose given only $\fst : A \times B \to A$ and $\snd : A \times B \to B$ satisfying $\fst(\tup{a}{b}) \jdeq a$ and $\snd(\tup{a}{b})\jdeq b$, we can define $\rec{A\times B}'$ by \[ \rec{A\times B}'(C,g,x) \defeq g (\fst x) (\snd x). \] We can now verify, given $C:\UU$, $g:A\to B \to C$ and $(a,b):A\times B$, \begin{align*} \rec{A\times B}'(C,g,(a,b)) &\jdeq g (\fst (a,b)) (\snd (a,b))\\ &\jdeq g (a) (b). \end{align*} % For $\Sigma$-types we replace $A \times B$ above with $\sm{a:A} B(a)$, but otherwise everything else stays the same: \[ \rec{\sm{x:A} B(x)}'(C,g,x) \defeq g (\fst x) (\snd x). \] \subsection*{Solution to \cref{ex:pr-to-ind}} Quite naturally, we form \[ \ind{A\times B}''(C,g,x) \defeq g (\fst x) (\snd x),\] of type \[ \prd{C:A\times B \to \UU}\Parens{\prd{y:A}\prd{z:B} C(\tup yz)} \to \prd{x : A \times B} C (\tup{\fst x}{\snd x}). \] This is not quite what we need because $\ind{A\times B}$ has the type \[ \prd{C:A\times B \to \UU}\Parens{\prd{y:A}\prd{z:B} C(\tup{y}{z})} \to \prd{x : A \times B} C (x). \] % Recall that we have the propositional uniqueness principle % \[ \uniq{A\times B}: \prd{x : A \times B} (\id[A\times B]{\tup{\fst x}{\snd x}}{x}), \] % satisfying $\id{\uniq{A\times B}(\tup{a}{b})}{\refl{(a,b)}}$. We can transport along $\uniq{A\times B}(x)$ to get from $C(\tup{\fst x}{\snd x})$ to $C(x)$: % \[ \ind{A\times B}'(C,g,x) \defeq \transfib{C}{\uniq{A\times B}(x)}{\ind{A \times B}''(C, g, x)}. \] % It remains to verify that $\ind{A \times B}'(C, g, x)$ behaves as expected: % \begin{align*} \ind{A \times B}'(C,g,(a,b)) &\jdeq \transfib{C}{\uniq{A\times B}(\tup{a}{b})}{g(\fst \tup{a}{b})(\snd\tup{a}{b})} \\ &\jdeq \transfib{C}{\uniq{A\times B}(\tup{a}{b})}{g(a)(b)} \\ &\jdeq \transfib{C}{\refl{\tup ab}}{g(a)(b)} \\ &\jdeq g(a)(b). \end{align*} % Now for $\Sigma$-types the exact same expressions work as well, except that the types change. \section*{Exercises from \cref{cha:logic}} \subsection*{Solution to \cref{ex:decidable-choice}} The hypotheses imply that \[ \Parens{\sm{n:\nat}P(n)} \to \sm{n:\nat}\Parens{P(n) \times \prd{m:\nat} \big((m] (N0) -- node[above]{\footnotesize $i_n$} (N1); \draw[->] (N0) -- node[left]{\footnotesize $j_n$} (N2); \draw[->] (N1) -- node[right]{\footnotesize $j_{n+1}$} (N2); \draw[double, double equal sign distance] (N3) -- node[left,above]{\footnotesize $glue_n$} (N4); \end{tikzpicture} \end{center} we get a path $x \defeq j_n(y) = j_{n+1} (i_n(y))$. But, as we will show, the inclusion $i_n$ of $\Sn^n$ in $\Sn^{n+1}$ is nullhomotopic, every point in the image is equal to $\north_{n+1}$. Thus, we are able to show that $j_{n+1}(i_n(y)) = j_{n+1}(\north_{n+1})$. Composing the proof of the first step with the proof of the second step we conclude the exercise. To construct a $D_{\blank} : \prd{n:\nat} j_n(\north_n) = j_0(\north_0)$ we proceed by induction on $n$. For the base case we can use $\refl{j_0(\north_0)}$. For the inductive case, we have by inductive hypothesis $j_n(\north_n) = j_0(\north_0)$. By our definition of $i_{\blank}$, we have that $\north_{n+1} \equiv i_n(\north_n)$. So $j_{n+1} (\north_{n+1})$ equals $j_{n+1}(i_n(\north_n))$. By concatenation with $\glue_n(\north_n)$, we reduce our goal to the inductive hypothesis. Let's now show that the inclusion of $\Sn^n$ in $\Sn^{n+1}$ can be continuously retracted to $\north_{n+1}$. That is, let's construct a homotopy: \[ H_{\blank} : \prd{n:\nat}{x:\Sn^n} i_n(x) = \north_{n+1} \] For the case $n\equiv 0$ we know that $i_0(\btrue) \equiv \north_1$ and $i_0(\bfalse) \equiv \south_1$. This is because we constructed the inclusion that way. So we can prove the equalities using $\refl{\north_1}$ and $\merid_1(\btrue) : \north_1 = \south_1$. For the inductive case we defined, previously, $i_n(\north_n) \equiv \north_{n+1}$ and $i_n(\south_{n}) \equiv \south_{n+1}$. So we can prove the equalities using $\refl{\north_{n+1}}$ and $(\merid_{n+1}(\north_n))^{-1}$. Then we have to prove that the function respects $\merid_n$: \[ \prd{x:\Sn^{n-1}} \dpath {x\mapsto (i_n(x) = \north_{n+1})} {\merid_n(x)} {\refl{\north_{n+1}}} {(\merid_{n+1}(\north_n))^{-1}} \] By \cref{thm:transport-path} (and some straightforward computation) this reduces to: \[ i_n(\merid_n(x)) = \merid_{n+1}(\north_{n}) \] But, by our definition of $i_{\blank}$, and the computation rule of the suspension induction $i_n(\merid_n(x))$ equals $\merid_{n+1} (i_{n-1}(x))$. And, by inductive hypothesis, $i_{n-1}(x) = \north_n$, which gives us the desired result. Composing the two proofs we just gave we get a function: \[ J_n(x) \defeq \glue_n(x)\ct \apfunc{j_{n+1}}{H_n(x)}\ct D_{n+1} : \prd{n:\nat}{x:\Sn^n} j_n(x) = j_0(\north_0). \] We use this function and induction on $\Sn^{\infty}$ to derive the contractibility of the space. Now it remains to show that our function respects the gluing: \[ \prd{n:\nat}{x:\Sn^n} \dpath {x\mapsto (x = j_0(\north_0))} {\glue_n(x)} {J_n(x)} {J_{n+1}(i_n (x))} \] By definition this is: \[ \prd{n:\nat}{x:\Sn^n} \transfib{x\mapsto (x = j_0(\north_0))}{\glue_n(x)}{J_n(x)} = {J_{n+1}(i_n (x))} \] The LHS is equal to $\glue_{n}(x)^{-1}\ct J_n(x)$, which, by definition of $J_n(x)$, is: \[ \glue_n(x)^{-1}\ct\glue_n(x)\ct\apfunc{j_{n+1}}{H_n(x)}\ct D_{n+1} \] Cancelling we get: \[ \apfunc{j_{n+1}}{H_n(x)}\ct D_{n+1} \] We also use the definition of $J_{\blank}$ in the RHS, and then the computation rule of $D_{\blank}$, giving us the equalities: \begin{align*} & J_{n+1}(i_n(x))\\ &= \glue_{n+1}(i_n(x))\ct\apfunc{j_{n+2}}{H_{n+1}(i_n(x))}\ct D_{n+2}\\ &= \glue_{n+1}(i_n(x))\ct\apfunc{j_{n+2}}{H_{n+1}(i_n(x))}\ct \glue_{n+1}(\north_{n+1})^{-1}\ct D_{n+1}. \end{align*} So it suffices to show: \[ \apfunc{j_{n+1}}{H_n(x)} = \glue_{n+1}(i_n(x))\ct\apfunc{j_{n+2}}{H_{n+1}(i_n(x))} \ct\glue_{n+1}(\north_{n+1})^{-1} \] Or equivalently: \[ \apfunc{j_{n+1}}{H_n(x)} \ct\glue_{n+1}(\north_{n+1}) = \glue_{n+1}(i_n(x))\ct\apfunc{j_{n+2}}{H_{n+1}(i_n(x))} \] But we remember that we have the homotopy $\glue_{n+1} : j_{n+1} = j_{n+2}\circ i_{n+1}$, so, by a simple application of \cref{lem:htpy-natural} and the functoriality of $\apfunc{}{}$, we get a proof of the equality: \[ \apfunc{j_{n+1}}{H_n(x)} \ct\glue_{n+1}(\north_{n+1}) = \glue_{n+1}(i_n(x))\ct\apfunc{j_{n+2}}{\apfunc{i_{n+1}}{H_n(x)}} \] So we reduced the goal to showing: \[ \apfunc{i_{n+1}}{H_n(x)} = H_{n+1}(i_n(x)) \] This can be done easily by induction in $\Sn^n$ using the definition of $H_{\blank}$. \subsection*{Solution to \cref{ex:contr-infinity-sphere-susp}} First we write down the type of the induction principle explicitly: \[ \ind{\Sn^\infty} : \prd{C:\Sn^\infty \to \UU}{n:C(\north)}{s:C(\south)} \Parens{\prd{x:\Sn^\infty} C(x) \to \dpath C {\merid(x)} {n}{s}} \to \prd{x:\Sn^\infty} C(x) . \] We take $\north$ as center of contraction. So we have to prove $\prd{x:\Sn^\infty} \north = x$. For this we use induction on $\Sn^\infty$ taking: \[C \defeq (\lambda x. \north = x) : \Sn^\infty \to \UU .\] When $x$ is $\north$ we just use $\refl{\north} : \north = \north$. When $x$ is $\south$ we use $\merid(\north) : \north = \south$. When $x$ varies along $\merid$ we have to give a function of type: \[\prd{x:\Sn^\infty} \Parens{\north = x} \to \Parens{\dpath C {\merid(x)} {\refl{\north}}{\merid(\north)}}. \] So, given $x : \Sn^\infty$ and $p : \north = x$, we have to prove: \[\transfib{x \mapsto (\north = x)}{\merid(x)}{\refl{\north}} = \merid(\north).\] By \cref{cor:transport-path-prepost} it suffices to show $\refl{\north}\ct \merid(x) = \merid(\north)$. Canceling $\refl{\north}$ and applying $\merid$ to $p$ gets us the desired result. \subsection*{Solution to \cref{ex:unique-fiber}} We know that every two points $y_1,y_2 : Y$ are merely equal, because $Y$ is is connected. That is, we have a function $c : \prd{y_1,y_2:Y}\trunc {} {y_1 = y_2}$. To prove this we can use the remark after \cref{thm:connected-pointed}. If we want to show that any pair of points $y_1,y_2 : Y$ are merely equal we can use the first point $y_1$ to get a pointed space $(Y,y_1)$, and then use the remark. We note that it suffices to show that for any $y_1,y_2:Y$ we have $\trunc {} {\hfib{f}{y_1} = \hfib{f}{y_2}}$ because $\hfib{f}{y_1} = \hfib{f}{y_2}$ implies (using $\idtoeqv$) $\hfib{f}{y_1}\simeq \hfib{f}{y_2}$ and thus, by recursion on the truncation of $\hfib{f}{y_1} = \hfib{f}{y_2}$, we get that $\trunc {} {\hfib{f}{y_1} = \hfib{f}{y_2}}$ implies $\trunc {} {\hfib{f}{y_1} \simeq \hfib{f}{y_2}}$. The type of $c(y_1,y_2)$ is a truncation, so we can use its recursion to prove the desired result. By recursion we can assume that $y_1 = y_2$, and in that case we obviously have $\trunc {} {\hfib{f}{y_1} = \hfib{f}{y_2}}$. We also have to show that the proposition we want to prove is $-1$-truncated, but that is straightforward because it is a $-1$-truncation. \section*{Exercises from \cref{cha:category-theory}} \subsection*{Solution to \cref{ex:stack}} Define $K$ to be the precategory with $K_0 \defeq Y$ and $\hom_K(y_1,y_2) \defeq (p(y_1)=p(y_2))$. Then $\mathrm{Desc}(A,p)\defeq A^K$ is a good definition. Moreover, the obvious functor $K\to X$ (where $X$ denotes the discrete category on itself) is a weak equivalence, so \cref{ct:esofull-precomp-ff,ct:cat-weq-eq} yield the second and third parts. Finally, $K$ is a strict category, so if it is a stack, then $p$ has a section, while conversely if $p$ has a section then $K\to X$ is a (strong) equivalence. \section*{Exercises from \cref{cha:set-math}} \subsection*{Solution to \cref{ex:prop-ord}} Define $A