Skip to content

Commit dd1b382

Browse files
authored
Merge pull request #960 from langston-barrett/exercises
solutions to several exercises
2 parents 79e6d60 + a02f510 commit dd1b382

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

exercise_solutions.tex

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,147 @@ \subsection*{Solution to \cref{ex:pr-to-ind}}
239239
%
240240
Now for $\Sigma$-types the exact same expressions work as well, except that the types change.
241241

242+
\section*{Exercises from \cref{cha:basics}}
243+
244+
\subsection*{Solution to \cref{ex:npaths}}
245+
246+
In general, when defining an ``$n$-foo'', one should ensure that a ``$1$-foo''
247+
is just a ``foo'' (e.g.\ a 1-category is just a category). In this case, a
248+
$1$-path in some type $A$ should just be a path, that is, an equality $\id[A]
249+
xy$ between some elements $x,y:A$. Then a 0-path should probably be an
250+
element of $A$. We also know that a $2$-path, or homotopy, is a pair of
251+
$1$-paths and an equality between them. Our definition should extrapolate from
252+
this pattern.
253+
254+
Define $C\defeq \lam{n}\type\to\type$. By the induction principle for $\nat$, it
255+
suffices to give terms
256+
\begin{gather*}
257+
c_0 : \type\to\type \\
258+
c_s : \prd{n:\nat}\prd{f:\type\to\type}\type\to\type
259+
\end{gather*}
260+
Define these by
261+
\begin{align*}
262+
c_0 &\defeq \idfunc[\type] \\
263+
c_s(n,f,A) &\defeq \sm{x,y:f(A)}\id[]xy
264+
\end{align*}
265+
That is to say, an $(n+1)$-dimensional path should be a pair of $n$-dimensional
266+
paths, together with a path between them. More concisely:
267+
\begin{gather*}
268+
\operatorname{npath} : \nat\to\type\to\type \\
269+
\operatorname{npath} \defeq \ind{\nat}\Parens{\lam{n}\type\to\type, \idfunc[\type], \lam{n}\lam{f}\lam{A}\Parens{\sm{x,y:f(A)}\id[]xy}}
270+
\end{gather*}
271+
272+
What should the boundary of an $n$-path be? The boundary of a $1$-path is
273+
a pair of points. The boundary of a $2$-path (that is, a homotopy) is a pair of
274+
$1$-paths. Perhaps the boundary of an $(n+1)$-path should be a pair of
275+
$n$-paths. We can get these by using the appropriate projections:
276+
\begin{gather*}
277+
\operatorname{nboundary} :
278+
\prd{n:\nat}\prd{A:\type}\operatorname{npath}(\suc(n),A)\to
279+
\operatorname{npath}(n,A)\times \operatorname{npath}(n,A) \\
280+
\operatorname{nboundary}(p)\defeq (\proj{1}(p),\proj{1}(\proj{2}(p)))
281+
\end{gather*}
282+
242283
\section*{Exercises from \cref{cha:logic}}
243284

285+
\subsection*{Solution to \cref{ex:equiv-functor-set}}
286+
287+
% Prove that if $\eqv A B$ and $A$ is a set, then so is $B$.
288+
289+
Generally, we can use univalence to transform equivalences to equalities
290+
(paths), and use the principle indiscernability of identicals (transport) to
291+
show that any statement (family) that holds for one type holds for any type it
292+
is equivalent to.
293+
294+
Let $A,B:\type$, $s:\isset(A)$, and $\eqv A B$. By univalence, there is
295+
a path $p:A=_{\type}B$. We can transport $s$ across this path to obtain the
296+
desired result:
297+
\begin{equation*}
298+
\transfib{X\mapsto \isset(X)}{p}{s} : \isset(B)
299+
\end{equation*}
300+
301+
\subsection*{Solution to \cref{ex:isset-coprod}}
302+
303+
Let $A,B:\type$, and assume that $A$ and $B$ are sets. To show $\isset(A+B)$, we
304+
must show that there is at most one path between elements of $A+B$, up to
305+
homotopy. Let $x,y:A+B$. We proceed by case analysis on $x$ and $y$.
306+
307+
Consider the cases where $x\jdeq \inl(a)$ and $y\jdeq \inr(b)$ or
308+
$x\jdeq \inr(b)$ and $y\jdeq \inl(a)$ for some $a:A$ and $b:B$. By the
309+
characterization of paths in coproduct types (\cref{sec:compute-coprod}), these
310+
can't be equal. In particular, by \eqref{eq:inlrdj}, given $p:x=y$, we can
311+
conclude anything we like.
312+
313+
Now suppose that $x\jdeq \inl(a_1)$ and $y\jdeq \inl(a_2)$ for $a_1,a_2:A$. Then
314+
by \eqref{eq:inlinj},
315+
\begin{equation*}
316+
(x=y)\jdeq {(\inl(a_1)=\inl(a_2))}\eqvsym {(a_1=a_2)}.
317+
\end{equation*}
318+
Since $A$ is a set, $a_1=a_2$ is a mere proposition. It follows that
319+
$x=y$ is a mere proposition (one can use univalence and
320+
transport, as in the previous exercise). A symmetric proof shows that
321+
in the case that $x\jdeq \inr(b_1)$ and $y\jdeq \inr(b_2)$ for $b_1,b_2:B$,
322+
$x=y$ is also a mere proposition. Therefore, $A+B$ is a set.
323+
324+
\subsection*{Solution to \cref{ex:prop-endocontr}}
325+
326+
($\Rightarrow$) Let $A:\type$ and $P:\isprop(A)$. To show that
327+
$A\to A$ is contractible, we must give a center of contraction and show that
328+
every other function $A\to A$ is equal to the center. Define our center to be
329+
$\idfunc[A]$, and let $f:A\to A$. Define a homotopy $\idfunc[A]\htpy f$ by
330+
\begin{gather*}
331+
\alpha:\prd{x:A}\id[]{\idfunc[A](x)}{f(x)} \\
332+
\alpha(x)\defeq P(\idfunc[A](x),f(x))
333+
\end{gather*}
334+
Then by function extensionality, $\idfunc[A]=f$.
335+
336+
($\Leftarrow$) Assume $A\to A$ is contractible with center of contraction $c$,
337+
and let $x,y:A$. We want to show that $x=y$. Define $f:A\to A$ by $f(z)\defeq
338+
y$. By contractability of $A\to A$, $\idfunc[A]=c=f$. Using $\happly$ on the
339+
equality between $\idfunc[A]$ and $f$, we obtain that
340+
$x\jdeq \idfunc[A](x)=f(x)\jdeq y$, so $\id[]xy$. We have shown that any
341+
two elements of $A$ are equal, that is, $A$ is a mere proposition.
342+
343+
\subsection*{Solution to \cref{ex:lem-mereprop}}
344+
345+
Assume $A$ is a proposition, and let $x,y:A+(\neg A)$. We want to show that
346+
$x=y$. We proceed by cases using the induction principle for coproducts.
347+
\begin{enumerate}
348+
\item Assume $x\jdeq \inl(a)$ and $y\jdeq \inr(n)$. Then
349+
$n(a):\emptyt$ gives us a contradiction.
350+
\item Assume $x\jdeq \inr(n)$ and $y\jdeq \inl(a)$. Then
351+
$n(a):\emptyt$ gives us a contradiction.
352+
\item Assume $x\jdeq \inl(a_1)$ and $y\jdeq \inl(a_2)$. By the
353+
characterization of paths in coproduct types (\cref{sec:compute-coprod}), we
354+
know $\eqv{(\id[]xy)}{(\id[]{a_1}{a_2})}$, and we have $\id[]{a_1}{a_2}$
355+
since $A$ is a proposition.
356+
\item Finally, assume $x\jdeq \inr(n_1)$ and $y\jdeq \inr(n_2)$.
357+
Again by the characterization of paths in coproduct types, we know
358+
$\eqv{(\id[]xy)}{(\id[]{n_1}{n_2})}$, so it suffices to show $\id[]{n_1}{n_2}$.
359+
Since $\neg A\jdeq A\to \emptyt$ and $\emptyt$ is a mere proposition, we
360+
have by \cref{thm:isprop-forall} that $\neg A$ is a mere proposition.
361+
Therefore, any two elements of $\neg A$ are equal, and in particular,
362+
$\id[]{n_1}{n_2}$.
363+
\end{enumerate}
364+
365+
\subsection*{Solution to \cref{ex:disjoint-or}}
366+
367+
Assume $h:\neg(A\times B)$, and let $x,y:A+B$. We want to show that
368+
$x=y$. We proceed by cases using the induction principle for coproducts.
369+
\begin{enumerate}
370+
\item Assume $x\jdeq \inl(a)$ and $y\jdeq \inr(b)$ for $a:A$ and $b:B$.
371+
Then $h(a,b):\emptyt$, and we can use the destructor for $\emptyt$ to
372+
conclude anything we wish.
373+
\item Assume $x\jdeq \inr(b)$ and $y\jdeq \inl(a)$. Then $h(a,b):\emptyt$, and
374+
we're done.
375+
\item Assume $x\jdeq \inl(a_1)$ and $y\jdeq \inl(a_2)$. By the
376+
characterization of paths in coproduct types (\cref{sec:compute-coprod}), we
377+
know $\eqv{(\id[]xy)}{(\id[]{a_1}{a_2})}$, and we have $\id[]{a_1}{a_2}$
378+
since $A$ is a proposition.
379+
\item Assume $x\jdeq \inr(b_1)$ and $y\jdeq \inr(b_2)$. Just as above,
380+
we have $\eqv{(\id[]xy)}{(\id[]{b_1}{b_2})}$, and $\id[]{b_1}{b_2}$.
381+
\end{enumerate}
382+
244383
\subsection*{Solution to \cref{ex:decidable-choice}}
245384

246385
The hypotheses imply that

0 commit comments

Comments
 (0)