\chapter{The object classifier}\label{chap:univalent}

In this chapter we establish notation, and we highlight the basic results concerning fiberwise transformations and fiberwise equivalences, which we will use for the descent theorems \cref{thm:descent,thm:rcoeq_cartesian}. Of particular importance are the following theorems:
\begin{enumerate}
\item The Fundamental Theorem of Identity Types (\cref{thm:id_fundamental}), which establishes that a type family $B$ over $A$ with $b:B(a)$ for a given $a:A$ is fiberwise equivalent to the identity type $a=x$ if and only if its total space is contractible. This result appears in \cite{hottbook} as Theorem 5.8.2, which contains other equivalent conditions as well.
\item \cref{thm:pb_fibequiv}, in which we establish that for any fiberwise map
\begin{equation*}
g:\prd{x:A}P(x)\to Q(f(x)),
\end{equation*}
the commuting square
\begin{equation*}
\begin{tikzcd}[column sep=large]
\sm{x:A}P(x) \arrow[r,"{\total[f]{g}}"] \arrow[d,swap,"\proj 1"] & \sm{y:B}Q(y) \arrow[d,"\proj 1"] \\
A \arrow[r,swap,"f"] & B,
\end{tikzcd}
\end{equation*}
where $\total[f]{g}$ is defined as $\lam{(x,p)}(f(x),g(x,y))$, is a pullback square if and only if $g$ is a fiberwise equivalence\index{fiberwise equivalence}. As a consequence, we obtain that a commuting square
\begin{equation*}
\begin{tikzcd}
A \arrow[d,swap,"f"] \arrow[r] & B \arrow[d,"g"] \\
X \arrow[r,swap,"h"] & Y
\end{tikzcd}
\end{equation*}
is a pullback square if and only if the induced fiberwise transformation
\begin{equation*}
\prd{x:X} \fib{f}{x}\to\fib{g}{h(x)}
\end{equation*}
is a fiberwise equivalence. Our main reference \cite{hottbook} does not present many results of homotopy pullbacks, although the material we present about homotopy pullbacks is surely well-known. The connection between pullbacks and fiberwise equivalences has an important role in the descent theorem\index{descent} in \cref{chap:descent}, which is why we devote a section to this result.
\item \cref{thm:classifier}, in which we establish that the universe is an object classifier. This result appears in \cite{RijkeSpitters} as Theorem 2.31, and in \cite{hottbook} as Theorem 4.8.4
\end{enumerate}

\section{Notation and preliminary results}

We work in Martin-L\"of dependent type theory with $\Pi$-types, $\Sigma$-types and cartesian products, coproducts $A+B$ equipped with $\inl:A\to A+B$ and $\inr:B\to A+B$ for any two types $A$ and $B$, an empty type $\emptyt$, a unit type $\unit$ equipped with $\ttt:\unit$, a type $\bool$ of booleans equipped with $\btrue,\bfalse:\bool$, a type $\N$ of natural numbers equipped with $0:\N$ and $\suc:\N\to\N$, and identity types.

\begin{rmk}
As usual, we write $\idfunc[A]:A\to A$ for the \define{identity function} $\lam{x}x$ on $A$, and we write $g\circ f:A\to C$ for the \define{composite function} $\lam{x}g(f(x))$ of $f:A\to B$ and $g:B\to C$. For any two types $A$ and $B$, and any $b:B$, we write
\begin{equation*}
\const_b : A\to B
\end{equation*}
for the \define{constant function} $\lam{x}b$. Sometimes we also write $\lam{\nameless}b$ for the constant function.

In the case of $\Sigma$-types, the empty type $\emptyt$, and the unit type, we use the following notation to define functions by pattern-matching:
\begin{align*}
\lam{(x,y)}f(x,y) & : \prd{t:\sm{x:A}B(x)} P(t) \\
\lam{\ttt}y & : \prd{t:\unit}P(t).
\end{align*}
For instance, the first and second projection maps
\begin{align*}
\proj 1 & : (\sm{x:A}B(x))\to A \\
\proj 2 & : \prd{p:\sm{x:A}B(x)}B(\proj 1)
\end{align*}
are defined as $\proj 1\defeq \lam{(x,y)}x$ and $\proj 2\defeq\lam{(x,y)}y$.
We use similar notation for definitions by iterated pattern-matching. For instance, given a dependent function $f:\prd{x:A}{y:B(x)}{z:C(x,y)} P((x,y),z)$ we obtain the function
\begin{equation*}
\lam{((x,y),z)} f(x,y,z): \prd{t:\sm{s:\sm{x:A}B(x)}C(s)}P(t).
\end{equation*}
\end{rmk}

Given a type $A$ in context $\Gamma$, the \define{identity type} of $A$ at $a:A$ is the inductive type family
\begin{equation*}
\Gamma,x:A\vdash a =_A x~\mathrm{type}
\end{equation*}
with constructor
\begin{equation*}
\Gamma \vdash \refl{a} : a=_A a.
\end{equation*}
The induction principle for the identity type of $A$ at $a$ asserts that for any type family
\begin{equation*}
\Gamma,x:A,\alpha: a=_A x\vdash P(x,\alpha)~\mathrm{type}
\end{equation*}
there is a term
\begin{equation*}
\ind{a=} : P(a,\refl{a})\to \prd{x:A}{\alpha:a=_A x}P(x,\alpha)
\end{equation*}
in context $\Gamma$, satisfying the computation rule
\begin{equation*}
\ind{a=}(p,a,\refl{a})\jdeq p.
\end{equation*}

A term of type $a=_A x$ is also called an \define{identification} of $a$ with $x$, or a \define{path} from $a$ to $x$.
The induction principle for identity types is sometimes called \define{identification elimination} or \define{path induction}. Occasionally, we also write $\idtypevar{A}$ for the identity type on $A$.

Moreover, we assume that there is a universe $\UU$ with a universal family $\mathrm{El}$ over $\UU$, that is closed under the type forming operations. For example, there is a map
\begin{equation*}
\check{\idtypevar{}}:\prd{A:\UU}\mathrm{El}(A)\to\mathrm{El}(A)\to\UU
\end{equation*}
satisfying
\begin{equation*}
\mathrm{El}(\check{\idtypevar{}}(A,x,y))\jdeq (x=_{\mathrm{El}(A)} y),
\end{equation*}
establishing that the universe is closed under identity types.

Given a type $A$ the \define{concatenation} operation
\begin{equation*}
\concat : \prd{x,y,z:A} (\id{x}{y})\to(\id{y}{z})\to (\id{x}{z})
\end{equation*}
is defined by $\concat(\refl{x},q)\defeq q$. We will usually write $\ct{p}{q}$ for $\concat(p,q)$.
The concatenation operation satisfies the unit laws
\begin{align*}
\leftunit(p) & : \ct{\refl{x}}{p}=p \\
\rightunit(p) & : \ct{p}{\refl{y}}=p.
\end{align*}

The \define{inverse operation}
\begin{equation*}
\invfunc:\prd{x,y:A} (x=y)\to (y=x)
\end{equation*}
is defined by $\invfunc(\refl{x})\defeq\refl{x}$. We will usually write $p^{-1}$ for $\invfunc(p)$.
The inverse operation satisfies the inverse laws
\begin{align*}
\leftinv(p) & : \ct{p^{-1}}{p} = \refl{y} \\
\rightinv(p) & : \ct{p}{p^{-1}} = \refl{x}.
\end{align*}

The \define{associativity operation}, which assigns to each $p:x=y$, $q:y=z$, and $r:z=w$ the \define{associator}
\begin{equation*}
\assoc(p,q,r) : \ct{(\ct{p}{q})}{r}=\ct{p}{(\ct{q}{r})}
\end{equation*}
is defined by $\assoc(\refl{x},q,r)\defeq \refl{\ct{q}{r}}$.

Given a map $f:A\to B$, the \define{action on paths} of $f$ is an operation
\begin{equation*}
\apfunc{f} : \prd{x,y:A} (\id{x}{y})\to(\id{f(x)}{f(y)})
\end{equation*}
defined by $\ap{f}{\refl{x}}\defeq\refl{f(x)}$.
Moreover, there are operations
\begin{align*}
\apid_A & : \prd{x,y:A}{p:\id{x}{y}} \id{p}{\ap{\idfunc[A]}{p}} \\
\apcomp(f,g) & : \prd{x,y:A}{p:\id{x}{y}} \id{\ap{g}{\ap{f}{p}}}{\ap{g\circ f}{p}}
\end{align*}
defined by $\apid_A(\refl{x})\defeq \refl{\refl{x}}$ and $\apcomp(f,g,\refl{x})\jdeq \refl{\refl{g(f(x))}}$, respectively.
It can be shown easily that the action on paths of a map preserves the groupoid operations, and that the groupoid laws are also preserved.

\begin{defn}
Let $A$ be a type, and let $B$ be a type family over $A$. The \define{transport} operation
\begin{equation*}
\tr_B:\prd{x,y:A} (\id{x}{y})\to (B(x)\to B(y))
\end{equation*}
is defined by $\tr_B(\refl{x}) \defeq \idfunc[B(x)]$.
\end{defn}

\begin{defn}\label{defn:apd}
Given a dependent function $f:\prd{a:A}B(a)$ and a path $p:\id{x}{y}$ in $A$, the \define{dependent action on paths}
\begin{equation*}
\apdfunc{f} : \prd{x,y:A}{p:x=y}\id{\tr_B(p,f(x))}{f(y)}
\end{equation*}
is defined by $\apd{f}{\refl{x}}\defeq \refl{f(x)}$.
\end{defn}

\begin{defn}
Let $f,g:\prd{x:A}P(x)$ be two dependent functions. The type $f\htpy g$ of \define{homotopies}\index{homotopy|textbf} from $f$ to $g$ is defined as
\begin{equation*}
f\htpy g \defeq \prd{x:A} f(x)=g(x).
\end{equation*}
\end{defn}

Commutativity of diagrams is stated using homotopies. For instance, a triangle
\begin{equation*}
\begin{tikzcd}[column sep=tiny]
A \arrow[dr,swap,"f"] \arrow[rr,"h"] & & B \arrow[dl,"g"] \\
& X
\end{tikzcd}
\end{equation*}
is said to commute if it comes equipped with a homotopy $H:f\htpy g\circ h$, and a square
\begin{equation*}
\begin{tikzcd}
A \arrow[d,"i"'] \arrow[r,"g"] & X \arrow[d,"f"] \\
B \arrow[r,swap,"h"] & Y
\end{tikzcd}
\end{equation*}
is said to commute if it comes equipped with a homotopy $H:h\circ i\htpy f\circ g$.

The reflexivity, inverse, and concatenation operations on homotopies are defined pointwise.
We will write $H^{-1}$ for $\lam{x}H(x)^{-1}$, and $\ct{H}{K}$ for $\lam{x}\ct{H(x)}{K(x)}$.
These operations satisfy the groupoid laws (phrased appropriately as homotopies). Apart from the groupoid operations and their laws, we will occasionally need \emph{whiskering} operations and the naturality of homotopies.

\begin{defn}\label{defn:htpy_whisering}
We define the following \define{whiskering}\index{homotopy!whiskering operations|textbf}\index{whiskering operations!of homotopies|textbf} operations on homotopies:
\begin{enumerate}
\item Suppose $H:f\htpy g$ for two functions $f,g:A\to B$, and let $h:B\to C$. We define
\begin{equation*}
h\cdot H\defeq \lam{x}\ap{h}{H(x)}:h\circ f\htpy h\circ g.
\end{equation*}
\item Suppose $f:A\to B$ and $H:g\htpy h$ for two functions $g,h:B\to C$. We define
\begin{equation*}
H\cdot f\defeq\lam{x}H(f(x)):h\circ f\htpy g\circ f.
\end{equation*}
\end{enumerate}
\end{defn}

We will frequently make use of commuting cubes. The commutativity of a cube is stated using the whiskering operations on homotopies.

\begin{defn}\label{defn:cube}
A \define{commuting cube}\index{commuting cube|textbf}
\begin{equation*}
\begin{tikzcd}
& A_{111} \arrow[dl] \arrow[dr] \arrow[d] \\
A_{110} \arrow[d] & A_{101} \arrow[dl] \arrow[dr] & A_{011} \arrow[dl,crossing over] \arrow[d] \\
A_{100} \arrow[dr] & A_{010} \arrow[d] \arrow[from=ul,crossing over] & A_{001} \arrow[dl] \\
& A_{000},
\end{tikzcd}
\end{equation*}
consists of
\begin{enumerate}
\item types
\begin{equation*}
A_{111},A_{110},A_{101},A_{011},A_{100},A_{010},A_{001},A_{000},
\end{equation*}
\item \begin{samepage}%
maps
\begin{align*}
f_{11\check{1}} & : A_{111}\to A_{110} & f_{\check{1}01} & : A_{101}\to A_{001} \\
f_{1\check{1}1} & : A_{111}\to A_{101} & f_{01\check{1}} & : A_{011}\to A_{010} \\
f_{\check{1}11} & : A_{111}\to A_{011} & f_{0\check{1}1} & : A_{011}\to A_{001} \\
f_{1\check{1}0} & : A_{110}\to A_{100} & f_{\check{1}00} & : A_{100}\to A_{000} \\
f_{\check{1}10} & : A_{110}\to A_{010} & f_{0\check{1}0} & : A_{010}\to A_{000} \\
f_{10\check{1}} & : A_{101}\to A_{100} & f_{00\check{1}} & : A_{001}\to A_{000},
\end{align*}
\end{samepage}%
\item homotopies
\begin{align*}
H_{1\check{1}\check{1}} & : f_{1\check{1}0}\circ f_{11\check{1}} \htpy f_{10\check{1}}\circ f_{1\check{1}1} & H_{0\check{1}\check{1}} & : f_{0\check{1}0}\circ f_{01\check{1}} \htpy f_{00\check{1}}\circ f_{0\check{1}1} \\
H_{\check{1}1\check{1}} & : f_{\check{1}10}\circ f_{11\check{1}} \htpy f_{01\check{1}}\circ f_{\check{1}11} & H_{\check{1}0\check{1}} & : f_{\check{1}00}\circ f_{10\check{1}} \htpy f_{00\check{1}}\circ f_{\check{1}01} \\
H_{\check{1}\check{1}1} & : f_{\check{1}01}\circ f_{1\check{1}1} \htpy f_{0\check{1}1}\circ f_{\check{1}11} & H_{\check{1}\check{1}0} & : f_{\check{1}00}\circ f_{1\check{1}0} \htpy f_{0\check{1}0}\circ f_{\check{1}10},
\end{align*}
\item and a homotopy
\begin{align*}
C & : \ct{(f_{\check{1}00}\cdot H_{1\check{1}\check{1}})}{(\ct{(H_{\check{1}0\check{1}}\cdot f_{1\check{1}1})}{(f_{00\check{1}}\cdot H_{\check{1}\check{1}1})})} \\
& \qquad \htpy \ct{(H_{\check{1}\check{1}0}\cdot f_{11\check{1}})}{(\ct{(f_{0\check{1}0}\cdot H_{\check{1}1\check{1}})}{(H_{0\check{1}\check{1}}\cdot f_{\check{1}11})})}
\end{align*}
filling the cube.
\end{enumerate}
\end{defn}

\begin{defn}
Let $f:A\to B$ be a function. We say that $f$ has a \define{section}\index{section!of a map|textbf} if there is a term of type\index{sec(f)@{$\sections(f)$}|textbf}
\begin{equation*}
\sections(f) \defeq \sm{g:B\to A} f\circ g\htpy \idfunc[B].
\end{equation*}
Dually, we say that $f$ has a \define{retraction}\index{retraction} if there is a term of type\index{retr(f)@{$\retractions(f)$}|textbf}
\begin{equation*}
\retractions(f) \defeq \sm{h:B\to A} h\circ f\htpy \idfunc[A].
\end{equation*}
If $f$ has a retraction, we also say that $A$ is a \define{retract}\index{retract!of a type} of $B$.
\end{defn}

\begin{defn}
We say that a function $f:A\to B$ is an \define{equivalence}\index{equivalence|textbf}\index{bi-invertible map|see {equivalence}} if it has both a section and a retraction, i.e.~if it comes equipped with a term of type\index{is_equiv@{$\isequiv$}|textbf}
\begin{equation*}
\isequiv(f)\defeq\sections(f)\times\retractions(f).
\end{equation*}
We will write $\eqv{A}{B}$\index{equiv@{$\eqv{A}{B}$}|textbf} for the type $\sm{f:A\to B}\isequiv(f)$.
\end{defn}

Clearly, if $f$ is \define{invertible}\index{invertible map} in the sense that it comes equipped with a function $g:B\to A$ such that $f\circ g\htpy\idfunc[B]$ and $g\circ f\htpy\idfunc[A]$, then $f$ is an equivalence. We write\index{has_inverse@{$\hasinverse$}|textbf}
\begin{equation*}
\hasinverse(f)\defeq\sm{g:B\to A} (f\circ g\htpy \idfunc[B])\times (g\circ f\htpy\idfunc[A]).
\end{equation*}
The section of an equivalence is also a retraction (and vice versa), so we define the \define{inverse} of an equivalence to be its section. It follows immediately that the inverse of any equivalence is again an equivalence.\index{equivalence!invertibility of} The identity function $\idfunc[A]$ on a type $A$ is an equivalence since it is its own section and its own retraction.

It is straightforward to show that for any two functions $f,g:A\to B$, we have
\begin{equation*}
(f\htpy g)\to (\isequiv(f)\leftrightarrow\isequiv(g)).
\end{equation*}
Given a commuting triangle
\begin{equation*}
\begin{tikzcd}[column sep=tiny]
A \arrow[rr,"h"] \arrow[dr,swap,"f"] & & B \arrow[dl,"g"] \\
& X.
\end{tikzcd}
\end{equation*}
with $H:f\htpy g\circ h$, we have:
\begin{enumerate}
\item If the map $h$ has a section, then $f$ has a section if and only if $g$ has a section.
\item If the map $g$ has a retraction, then $f$ has a retraction if and only if $h$ has a retraction.
\item (The \define{3-for-2 property} for equivalences.) If any two of the functions
\begin{equation*}
f,\qquad g,\qquad h
\end{equation*}
are equivalences, then so is the third.
\end{enumerate}

In the following theorem we characterize the identity type of a $\Sigma$-type as a $\Sigma$-type of identity types.

\begin{prp}[Theorem 2.7.2 of \cite{hottbook}]\label{thm:eq_sigma}
Let $B$ be a type family over $A$, let $s:\sm{x:A}B(x)$, and consider the dependent function\index{pair_eq@{$\paireq$}|textbf}
\begin{equation*}
\paireq_s:\prd{t:\sm{x:A}B(x)} (s=t)\to \sm{\alpha:\proj 1(s)=\proj 1(t)} \tr_B(\alpha,\proj 2(s))=\proj 2(t)
\end{equation*}
defined by $\paireq_s(\refl{s}) \defeq (\refl{\proj 1(s)},\refl{\proj 2(s)})$. Then $\paireq_{s,t}$ is an equivalence for every $t:\sm{x:A}B(x)$.\index{Sigma type@{$\Sigma$-type}!identity types of|textit}\index{identity type!of a Sigma-type@{of a $\Sigma$-type}|textit}
\end{prp}

We include the proof mainly to introduce some more notation.

\begin{proof}
The maps in the converse direction\index{eq_pair@{$\eqpair$}}
\begin{equation*}
\eqpair_{s,t} : \Big(\sm{p:\proj 1(s)=\proj 1(t)}\id{\tr_B(p,\proj 2(s))}{\proj 2(t)}\Big)\to(\id{s}{t})
\end{equation*}
is defined by
\begin{equation*}
\eqpair_{(x,y),(x',y')}(\refl{x},\refl{y})\defeq \refl{(x,y)}.
\end{equation*}
The proofs that the function $\eqpair_{s,t}$ is indeed an inverse of $\paireq_{s,t}$ are also by induction.
\end{proof}

\begin{defn}
We say that a type $A$ is \define{contractible}\index{contractible!type|textbf} if there is a term of type
\begin{equation*}
\iscontr(A) \defeq \sm{c:A}\prd{x:A}c=x.
\end{equation*}
Given a term $(c,C):\iscontr(A)$, we call $c:A$ the \define{center of contraction}\index{center of contraction|textbf} of $A$, and we call $C:\prd{x:A}a=x$ the \define{contraction}\index{contraction} of $A$.
\end{defn}

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
\begin{equation*}
\const_c\htpy\idfunc[A].
\end{equation*}
In other words, the contraction $C$ is a \emph{homotopy} from the constant function to the identity function.

\begin{defn}
Consider a type $A$ with a base point $a:A$. We say that $A$ satisfies \define{singleton induction}\index{singleton induction|textbf} if for every type family $B$ over $A$, the map
\begin{equation*}
\evpt:\Big(\prd{x:A}B(x)\Big)\to B(a)
\end{equation*}
given by $f\mapsto f(a)$ has a section.
\end{defn}

\begin{prp}\label{thm:contractible}
A type $A$ is contractible if and only if it satisfies singleton induction.
\end{prp}

\begin{eg}
By definition the unit type\index{unit type!contractibility} $\unit$ satisfies singleton induction, so it is contractible.
\end{eg}

\begin{rmk}
For any family $P:\Big(\sm{x:A}B(x)\Big)\to\UU$ there is a map
\begin{equation*}
\evpair : \Big(\prd{t:\sm{x:A}B(x)}P(t)\Big)\to \prd{x:A}{y:B(x)}P(x,y)
\end{equation*}
that evaluates $f:\prd{t:\sm{x:A}B(x)}P(t)$ at pairs $(x,y)$. In other words, $\evpair$ is defined by $\lam{f}{x}{y}f(x,y)$. By the induction principle for $\Sigma$-types, this map has a section. It is easy to show that $\evpair$ is in fact an equivalence.

Similarly, there is a map
\begin{equation*}
\evrefl : \Big(\prd{x:A}{p:a=x}B(x,p)\Big)\to B(a,\refl{a})
\end{equation*}
given by $\lam{f}f(a,\refl{a})$, for any type family $B:\prd{x:A} (a=x)\to\UU$. By path induction, this map has a section, and again it is easy to show that this map is in fact an equivalence.
\end{rmk}

\begin{prp}[Lemma 3.11.8 in \cite{hottbook}]\label{thm:total_path}
For any $x:A$, the type
\begin{equation*}
\sm{y:A}x=y
\end{equation*}
is contractible.\index{identity type!contractibility of total space|textit}
\end{prp}

\begin{proof}
We have the term $(x,\refl{x}):\sm{y:A}x=y$, and both maps in the composite
\begin{equation*}
\begin{tikzcd}[column sep=large]
\prd{t:\sm{y:A}x=y}B(t) \arrow[r,"\evpair"] & \prd{y:A}{p:x=y}B((y,p)) \arrow[r,"\evrefl"] & B((x,\refl{x}))
\end{tikzcd}
\end{equation*}
have sections, so the composite has a section. The composite is $\evpt$, so we see that the asserted type satisfies singleton induction.
\end{proof}

\begin{defn}
Let $f:A\to B$ be a function, and let $b:B$. The \define{fiber}\index{fiber|textbf}\index{homotopy fiber|see {fiber}} of $f$ at $b$ is defined to be the type
\begin{equation*}
\fib{f}{b}\defeq\sm{a:A}f(a)=b.
\end{equation*}
\end{defn}

\begin{eg}[Lemma 4.8.1 of \cite{hottbook}]\label{eg:fib_proj}
Consider a type family $B$ over $A$. Then the map
\begin{equation*}
B(a)\to \fib{\proj 1}{a}
\end{equation*}
given by $b\mapsto ((a,b),\refl{a})$ is an equivalence. In other words, the fibers of the projection function $\proj 1 : \big(\sm{x:A}B(x)\big)\to A$ are just the fibers of the family $B$.
\end{eg}

\begin{defn}
We say that a function $f:A\to B$ is \define{contractible}\index{contractible!map|textbf} if there is a term of type
\begin{equation*}
\iscontr(f)\defeq\prd{b:B}\iscontr(\fib{f}{b}).
\end{equation*}
\end{defn}

We cite Chapter 4 of \cite{hottbook} for the following result, although it is well-known that it can be proven directly and without the use of function extensionality.

\begin{prp}[Chapter 4 in \cite{hottbook}]\label{thm:contr_equiv}
A function is an equivalence if and only if it is contractible.\index{contractible!map!is an equivalence|textit}
\end{prp}

\section{The Fundamental Theorem of Identity Types}
Consider a family
\begin{equation*}
f : \prd{x:A}B(x)\to C(x)
\end{equation*}
of maps. Such $f$ is also called a \define{fiberwise map} or \define{fiberwise transformation}.

\begin{defn}[Definition 4.7.5 of \cite{hottbook}]
We define the map
\begin{equation*}
\total{f}:\sm{x:A}B(x)\to\sm{x:A}C(x).
\end{equation*}
by $\lam{(x,y)}(x,f(x,y))$.
\end{defn}

\begin{lem}[Theorem 4.7.6 of \cite{hottbook}]\label{lem:fib_total}
For any fiberwise transformation $f:\prd{x:A}B(x)\to C(x)$, and any $a:A$ and $c:C(a)$, there is an equivalence
\begin{equation*}
\eqv{\fib{f(a)}{c}}{\fib{\total{f}}{\pairr{a,c}}}.
\end{equation*}
\end{lem}

\begin{eg}
There are equivalences
\begin{equation*}
\eqv{\fib{(\apfunc{f})_{x,y}}{q}}{\fib{\delta_f}{(x,y,q)}}
\end{equation*}
for any $q:f(x)=f(y)$, because the triangle
\begin{equation*}
\begin{tikzcd}[column sep=-1em]
A \arrow[rr,"{\lam{x}(x,x,\refl{x})}"] \arrow[dr,swap,"\delta_f"] & & \sm{x,y:A}x=y \arrow[dl,"\total{\total{\apfunc{f}}}"] \\
\phantom{\sm{x,y:A}x=y} & \sm{x,y:A}f(x)=f(y)
\end{tikzcd}
\end{equation*}
commutes, and the top map is an equivalence.
\end{eg}

\begin{prp}[Theorem 4.7.7 of \cite{hottbook}]\label{thm:fib_equiv}
Let $f:\prd{x:A}B(x)\to C(x)$ be a fiberwise transformation. The following are logically equivalent:
\begin{enumerate}
\item For each $x:A$, the map $f_x:B(x)\to C(x)$ is an equivalence. In this case we say that $f$ is a \define{fiberwise equivalence}.
\item The map $\total{f}:\sm{x:A}B(x)\to\sm{x:A}C(x)$ is an equivalence.
\end{enumerate}
\end{prp}

The following theorem is the key to many results about identity types, which we will use instead of the \emph{encode-decode method}\index{encode-decode method} of \cite{LicataShulman}. We refer to it as the \define{Fundamental Theorem of Identity Types}.

\begin{thm}[Theorem 5.8.2 of \cite{hottbook}]\label{thm:id_fundamental}
Let $A$ be a type with $a:A$, and let $B$ be a type family over $A$ with $b:B(a)$.
Then  the following are logically equivalent:
\begin{enumerate}
\item The canonical family of maps
\begin{equation*}
\ind{a{=}}(b):\prd{x:A} (a=x)\to B(x)
\end{equation*}
is a fiberwise equivalence.
\item The total space
\begin{equation*}
\sm{x:A}B(x)
\end{equation*}
is contractible.
\end{enumerate}
\end{thm}

\begin{proof}
By \autoref{thm:fib_equiv} it follows that the fiberwise transformation $\ind{a{=}}(b)$ is a fiberwise equivalence if and only if it induces an equivalence
\begin{equation*}
\eqv{\Big(\sm{x:A}a=x\Big)}{\Big(\sm{x:A}B(x)\Big)}
\end{equation*}
on total spaces. We have that $\sm{x:A}a=x$ is contractible. Now it follows by the 3-for-2 property of equivalences, applied in the case
\begin{equation*}
\begin{tikzcd}
\sm{x:A}a=x \arrow[rr,"\total{\ind{a{=}}(b)}"] \arrow[dr,swap,"\eqvsym"] & & \sm{x:A}B(x) \arrow[dl] \\
& \unit & \phantom{\sm{x:A}a=x}
\end{tikzcd}
\end{equation*}
that $\total{\ind{a{=}}(b)}$ is an equivalence if and only if $\sm{x:A}B(x)$ is contractible.
\end{proof}

Observe that in the proof of \cref{thm:id_fundamental} we haven't used the actual definition of the fiberwise transformation. Indeed, for any fiberwise transformation
\begin{equation*}
f:\prd{x:A}(a=x)\to B(x)
\end{equation*}
we have that $f$ is a fiberwise equivalence if and only if the total space of $B$ is contractible.

Since retracts of contractible types are again contractible, it follows that the only retract of the identity type is the identity type itself:

\begin{cor}\label{cor:id_fundamental_retr}
Let $a:A$, and let $B$ be a type family over $A$. If each $B(x)$ is a retract of $\id{a}{x}$, then $B(x)$ is equivalent to $\id{a}{x}$ for every $x:A$.
\end{cor}

As a first application of the fundamental theorem we give a quick new proof that equivalences are embeddings. The proof of the corresponding theorem in \cite{hottbook} is more involved.

\begin{defn}
An \define{embedding}\index{embedding|textbf} is a map $f:A\to B$ satisfying the property that
\begin{equation*}
\apfunc{f}:(\id{x}{y})\to(\id{f(x)}{f(y)})
\end{equation*}
is an equivalence for every $x,y:A$. We write $\isemb(f)$ for the type of witnesses that $f$ is an embedding.
\end{defn}

\begin{prp}[Theorem 2.11.1 in \cite{hottbook}]
\label{cor:emb_equiv}
Any equivalence is an embedding.\index{embedding!equivalences are embeddings|textit}\index{equivalence!is an embedding|textit}
\end{prp}

\begin{proof}
Let $e:\eqv{A}{B}$ be an equivalence, and let $x:A$. By \autoref{thm:id_fundamental} it follows that
\begin{equation*}
\apfunc{e} : (\id{x}{y})\to (\id{e(x)}{e(y)})
\end{equation*}
is an equivalence for every $y:A$ if and only if the total space
\begin{equation*}
\sm{y:A}e(x)=e(y)
\end{equation*}
is contractible for every $y:A$. Now observe that $\sm{y:A}e(x)=e(y)$ is equivalent to the fiber $\fib{e}{e(x)}$, which is contractible by \cref{thm:contr_equiv}.
\end{proof}

\begin{defn}
A type $A$ is said to be a \define{proposition} if there is a term of type
\begin{equation*}
\isprop(A)\defeq\prd{x,y:A}\iscontr(x=y).
\end{equation*}
Furthermore, we write $\prop\defeq\sm{X:\UU}\isprop(X)$ for the type of all small propositions.
\end{defn}

We will often use either of the following characterizations of propositions.

\begin{lem}[Lemma 3.11.10 and Exercise 3.5 of \cite{hottbook}]\label{lem:prop_char}
For any type $A$ the following are equivalent:
\begin{enumerate}
\item $A$ is a proposition.
\item $A$ is \define{proof irrelevant} in the sense that $\prd{x,y:A}x=y$.
\item $A\to\iscontr(A)$.
\end{enumerate}
\end{lem}

\begin{eg}\label{eg:prop_contr}
Any contractible type is a proposition. The empty type is a proposition by a direct application of the induction principle of the empty type. Furthermore, any retract of a proposition is again a proposition. In particular, propositions are closed under equivalences.
\end{eg}

\begin{lem}\label{lem:id_fib}
Consider a function $f:A\to B$, and let $(a,p),(a',p'):\fib{f}{b}$ for some $b:B$. Then the canonical map
\begin{equation*}
((a,p)=(a',p'))\to \fib{\apfunc{f}}{\ct{p}{p'^{-1}}}
\end{equation*}
is an equivalence.
\end{lem}

\begin{proof}
By \cref{thm:fib_equiv} it suffices to show that the type
\begin{equation*}
\sm{y:A}{q:f(y)=b}{p:\proj 1(s)=y} \ap{f}{p}=\ct{\proj 2(s)}{q^{-1}}
\end{equation*}
is contractible, which is immediate by two applications of \cref{thm:total_path}.
\end{proof}

\begin{prp}[Lemma 7.6.2 of \cite{hottbook}]\label{thm:prop_emb}
A map is an embedding if and only if its fibers are propositions.
\end{prp}

\begin{proof}
If $f$ is an embedding, then the fibers of $\apfunc{f}$ are contractible by \cref{thm:contr_equiv}. Thus it follows by \cref{lem:id_fib} that the fibers of $f$ are propositions.

Conversely, if the fibers of $f$ are propositions, then we have by \cref{lem:id_fib} an equivalence
\begin{equation*}
\eqv{((x,p)=(y,\refl{f(y)}))}{\fib{\apfunc{f}}{p}}
\end{equation*}
for any $p:f(x)=f(y)$, which shows that the fibers of $\apfunc{f}$ are contractible. Thus $f$ is an embedding by \cref{thm:contr_equiv}.
\end{proof}

\begin{defn}
A type family $B$ over $A$ is said to be a \define{subtype} of $A$ if for each $x:A$ the type $B(x)$ is a proposition.
\end{defn}

\begin{cor}\label{thm:subtype}
A type family $B$ over $A$ is a subtype if and only if the projection map
\begin{equation*}
\proj 1 : \Big(\sm{x:A}B(x)\Big)\to A
\end{equation*}
is an embedding.
\end{cor}

\begin{proof}
Immediate by \cref{eg:fib_proj,thm:prop_emb}.
\end{proof}

\section{Function extensionality}
\begin{prp}[Theorem 4.9.5 of \cite{hottbook}]\label{thm:funext_wkfunext}
The following are equivalent:
\begin{enumerate}
\item The \define{function extensionality principle}\index{function extensionality}: For every type family $B$ over $A$, and any two dependent functions $f,g:\prd{x:A}B(x)$, the canonical map\index{htpy_eq@{$\htpyeq$}|textbf}
\begin{equation*}
\htpyeq(f,g) : (\id{f}{g})\to (f\htpy g)
\end{equation*}
by path induction (sending $\refl{f}$ to $\lam{x}\refl{f(x)}$) is an equivalence. We will write $\eqhtpy$\index{eq_htpy@{$\eqhtpy$}} for its inverse.
\item The \define{weak function extensionality principle}\index{weak function extensionality} holds: For every type family $B$ over $A$ one has\index{contractible!weak function extensionality}
\begin{equation*}
\Big(\prd{x:A}\iscontr(B(x))\Big)\to\iscontr\Big(\prd{x:A}B(x)\Big).
\end{equation*}
\end{enumerate}
\end{prp}

From now on we will assume that function extensionality holds.

\begin{cor}[Theorem 7.1.9 of \cite{hottbook}]\label{thm:prop_pi}
For any type family $B$ over $A$ one has
\begin{equation*}
\Big(\prd{x:A}\isprop(B(x))\Big)\to \isprop\Big(\prd{x:A}B(x)\Big).
\end{equation*}
In particular, if $B$ is a proposition, then $A\to B$ is a proposition for any type $A$.
\end{cor}

We show in this section that a map $f:A\to B$ is an equivalence if and only if for any type family $P$ over $B$, the precomposition map
\begin{equation*}
\blank\circ f: \Big(\prd{y:B}P(y)\Big)\to\Big(\prd{x:A}P(f(x))\Big)
\end{equation*}
is an equivalence.
In the proof we use the notion of \emph{path-split} maps, which was introduced in \cite{RijkeShulmanSpitters}.

\begin{defn}
We say that a map $f:A\to B$ is \define{path-split}\index{path-split|textbf} if $f$ has a section, and for each $x,y:A$ the map
\begin{equation*}
\apfunc{f}(x,y):(x=y)\to (f(x)=f(y))
\end{equation*}
also has a section. We write $\pathsplit(f)$\index{path_split(f)@{$\pathsplit(f)$}|textbf} for the type
\begin{equation*}
\sections(f)\times\prd{x,y:A}\sections(\apfunc{f}(x,y)).
\end{equation*}
\end{defn}

We will also use the notion of \emph{half-adjoint equivalences}, which were introduced in \cite{hottbook}.

\begin{defn}[Definition 4.2.1 of \cite{hottbook}]
We say that a map $f:A\to B$ is a \define{half-adjoint equivalence}\index{half-adjoint equivalence|textbf}, in the sense that there are
\begin{align*}
g & : B \to A\\
G & : f\circ g \htpy \idfunc[B] \\
H & : g\circ f \htpy \idfunc[A] \\
K & : G\cdot f \htpy f\cdot H.
\end{align*}
We write $\halfadj(f)$\index{half_adj(f)@{$\halfadj(f)$}|textbf} for the type of such quadruples $(g,G,H,K)$.
\end{defn}

Furthermore, we will need `type theoretic choice'.

\begin{prp}[Theorem 2.15.7 of \cite{hottbook}]\label{thm:choice}
Let $C(x,y)$ be a type in context $\Gamma,x:A,y:B(x)$. Then the map
\begin{equation*}
\varphi:\Big(\prd{x:A}\sm{y:B(x)}C(x,y)\Big)\to \Big(\sm{f:\prd{x:A}B(x)}\prd{x:A}C(x,f(x))\Big)
\end{equation*}
given by $\lam{h}(\lam{x}\proj 1(h(x)),\lam{x}\proj 2(h(x)))$ is an equivalence.
\end{prp}

\begin{cor}
For type $A$ and any type family $C$ over $B$, the map
\begin{equation*}
\Big(\sm{f:A\to B} \prd{x:A}C(f(x))\Big)\to\Big(A\to\sm{y:B}C(x)\Big)
\end{equation*}
given by $\lam{(f,g)}{x}(f(x),g(x))$ is an equivalence.
\end{cor}

\begin{prp}\label{prp:equiv_precomp}
For any map $f:A\to B$, the following are equivalent:
\begin{enumerate}
\item $f$ is an equivalence.
\item $f$ is path-split.
\item $f$ is a half-adjoint equivalence.
\item For any type family $P$ over $B$ the map
\begin{equation*}
\Big(\prd{y:B}P(y)\Big)\to\Big(\prd{x:A}P(f(x))\Big)
\end{equation*}
given by $s\mapsto s\circ f$ is an equivalence.
\item For any type $X$ the map
\begin{equation*}
(B\to X)\to (A\to X)
\end{equation*}
given by $g\mapsto g\circ f$ is an equivalence.
\end{enumerate}
\end{prp}

\begin{proof}
To see that (i) implies (ii) we note that any equivalence has a section, and its action on paths is an equivalence by \cref{cor:emb_equiv} so again it has a section.

To show that (ii) implies (iii), assume that $f$ is path-split. Thus we have $(g,G):\sections(f)$, and the assumption that $\apfunc{f}:(x=y)\to (f(x)=f(y))$ has a section for every $x,y:A$ gives us a term of type
\begin{equation*}
\prd{x:A}\fib{\apfunc{f}}{G(f(x))}.
\end{equation*}
By \cref{thm:choice} this type is equivalent to
\begin{equation*}
\sm{H:\prd{x:A}g(f(x))=x}\prd{x:A}G(f(x))=\ap{f}{H(x)},
\end{equation*}
so we obtain $H:g\circ f\htpy \idfunc[A]$ and $K:G\cdot f\htpy f\cdot H$, showing that $f$ is a half-adjoint equivalence.

To show that (iii) implies (iv), suppose that $f$ comes equipped with $(g,G,H,K)$ witnessing that $f$ is a half-adjoint equivalence. Then we define the inverse of $\blank\circ f$ to be the map
\begin{equation*}
\varphi:\Big(\prd{x:A}P(f(x))\Big)\to\Big(\prd{y:B}P(y)\Big)
\end{equation*}
given by $s\mapsto \lam{y}\tr_P(G(y),sg(y))$.

To see that $\varphi$ is a section of $\blank\circ f$, let $s:\prd{x:A}P(f(x))$. By function extensionality it suffices to construct a homotopy $\varphi(s)\circ f\htpy s$. In other words, we have to show that
\begin{equation*}
\tr_P(G(f(x)),s(g(f(x)))=s(x)
\end{equation*}
for any $x:A$. Now we use the additional homotopy $K$ from our assumption that $f$ is a half-adjoint equivalence. Since we have $K(x):G(f(x))=\ap{f}{H(x)}$ it suffices to show that
\begin{equation*}
\tr_P(\ap{f}{H(x)},sgf(x))=s(x).
\end{equation*}
A simple path-induction argument yields that
\begin{equation*}
\tr_P(\ap{f}{p})\htpy \tr_{P\circ f}(p)
\end{equation*}
for any path $p:x=y$ in $A$, so it suffices to construct an identification
\begin{equation*}
\tr_{P\circ f}(H(x),sgf(x))=s(x).
\end{equation*}
We have such an identification by $\apd{H(x)}{s}$.

To see that $\varphi$ is a retraction of $\blank\circ f$, let $s:\prd{y:B}P(y)$. By function extensionality it suffices to construct a homotopy $\varphi(s\circ f)\htpy s$. In other words, we have to show that
\begin{equation*}
\tr_P(G(y),sfg(y))=s(y)
\end{equation*}
for any $y:B$. We have such an identification by $\apd{G(y)}{s}$. This completes the proof that (iii) implies (iv).

Note that (v) is an immediate consequence of (iv), since we can just choose $P$ to be the constant family $X$.

It remains to show that (v) implies (i). Suppose that
\begin{equation*}
\blank\circ f:(B\to X)\to (A\to X)
\end{equation*}
is an equivalence for every type $X$. Then its fibers are contractible by \cref{thm:contr_equiv}. In particular, choosing $X\jdeq A$ we see that the fiber
\begin{equation*}
\fib{\blank\circ f}{\idfunc[A]}\jdeq \sm{h:B\to A}h\circ f=\idfunc[A]
\end{equation*}
is contractible. Thus we obtain a function $h:B\to A$ and a homotopy $H:h\circ f\htpy\idfunc[A]$ showing that $h$ is a retraction of $f$. We will show that $h$ is also a section of $f$. To see this, we use that the fiber
\begin{equation*}
\fib{\blank\circ f}{f}\jdeq \sm{i:B\to B} i\circ f=f
\end{equation*}
is contractible (choosing $X\jdeq B$).
Of course we have $(\idfunc[B],\refl{f})$ in this fiber. However we claim that there also is an identification $p:(f\circ h)\circ f=f$, showing that $(f\circ h,p)$ is in this fiber, because
\begin{align*}
(f\circ h)\circ f & \jdeq f\circ (h\circ f) \\
& = f\circ \idfunc[A] \\
& \jdeq f
\end{align*}
Now we conclude by the contractibility of the fiber that there is an identification $(\idfunc[B],\refl{f})=(f\circ h,p)$. In particular we obtain that $\idfunc[B]=f\circ h$, showing that $h$ is a section of $f$.
\end{proof}

\section{Homotopy pullbacks}
\subsection{Cartesian squares}

Recall that a square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"g"] & X
\end{tikzcd}
\end{equation*}
is said to \define{commute}\index{commuting square|textbf} if there is a homotopy $H:f\circ p\htpy g\circ q$.

\begin{defn}\label{defn:cospan}
A \define{cospan}\index{cospan|textbf} consists of three types $A$, $X$, and $B$, and maps $f:A\to X$ and $g:B\to X$. Given a type $C$, a \define{cone}\index{cone!on a cospan|textbf} on the cospan $A \stackrel{f}{\rightarrow} X \stackrel{g}{\leftarrow} B$ with \define{vertex} $C$\index{vertex!of a cone|textbf} consists of maps $p:C\to A$, $q:C\to B$ and a homotopy $H:f\circ p\htpy g\circ q$ witnessing that the square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
commutes. We write\index{cone(C)@{$\cone(\blank)$}|textbf}
\begin{equation*}
\cone(C)\defeq \sm{p:C\to A}{q:C\to B}f\circ p\htpy g\circ q
\end{equation*}
for the type of cones with vertex $C$.
\end{defn}

Given a cone with vertex $C$ on a span $A\stackrel{f}{\rightarrow} X \stackrel{g}{\leftarrow} B$ and a map $h:C'\to C$, we construct a new cone with vertex $C'$ in the following definition.

\begin{defn}
For any cone $(p,q,H)$ with vertex $C$ and any type $C'$, we define a map\index{cone map@{$\conemap$}|textbf}
\begin{equation*}
\conemap(p,q,H):(C'\to C)\to\cone(C')
\end{equation*}
by $h\mapsto (p\circ h,q\circ h,H\cdot h)$.
\end{defn}

\begin{defn}
We say that a commuting square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with $H:f\circ p\htpy g\circ q$ is a \define{pullback square}\index{pullback square|textbf}, or that it is \define{cartesian}\index{cartesian square|textbf}, if it satisfies the \define{universal property} of pullbacks\index{universal property!of pullbacks}, which asserts that the map
\begin{equation*}
\conemap(p,q,H):(C'\to C)\to\cone(C')
\end{equation*}
is an equivalence for every type $C'$.
\end{defn}

We often indicate the universal property with a diagram as follows:
\begin{equation*}
\begin{tikzcd}
C' \arrow[drr,bend left=15,"{q'}"] \arrow[dr,densely dotted,"h"] \arrow[ddr,bend right=15,swap,"{p'}"] \\
& C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
& A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
since the universal property states that for every cone $(p',q',H')$ with vertex $C'$, the type of pairs $(h,\alpha)$ consisting of $h:C'\to C$ equipped with $\alpha:\conemap((p,q,H),h)=(p',q',H')$ is contractible by \cref{thm:contr_equiv}.

\begin{prp}\label{thm:pullback_up}
Consider a commuting square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with $H:f\circ p\htpy g\circ q$
Then the following are equivalent:\index{universal property!of pullbacks (characterization)|textit}
\begin{enumerate}
\item The square is a pullback square.
\item For every type $C'$ and every cone $(p',q',H')$ with vertex $C'$, the type of quadruples $(h,K,L,M)$ consisting of
\begin{align*}
h & : C'\to C \\
K & : p\circ h \htpy p' \\
L & : q\circ h \htpy q' \\
M & : \ct{(H\cdot h)}{(g\cdot L)} \htpy \ct{(f\cdot K)}{H'}
\end{align*}
is contractible.
\end{enumerate}
\end{prp}

\begin{rmk}
The homotopy $M$ in \cref{thm:pullback_up} witnesses that the square
\begin{equation*}
\begin{tikzcd}
f\circ p\circ h \arrow[r,"f\cdot K"] \arrow[d,swap,"H\cdot h"] & f\circ p' \arrow[d,"{H'}"] \\
g\circ q\circ h \arrow[r,swap,"g\cdot L"] & g\circ q'
\end{tikzcd}
\end{equation*}
of homotopies commutes.
\end{rmk}

\subsection{The unique existence of pullbacks}

\begin{defn}
Let $f:A\to X$ and $B\to X$ be maps. Then we define
\begin{align*}
A\times_X B & \defeq \sm{x:A}{y:B}f(x)=g(y) \\
\pi_1 & \defeq \proj 1 & & : A\times_X B\to A \\
\pi_2 & \defeq \proj 1\circ\proj 2 & & : A\times_X B\to B\\
\pi_3 & \defeq \proj 2\circ\proj 2 & & : f\circ \pi_1 \htpy g\circ\pi_2.
\end{align*}
The type $A\times_X B$ is called the \define{canonical pullback}\index{canonical pullback|textbf} of $f$ and $g$.
\end{defn}

Note that $A\times_X B$ depends on $f$ and $g$, although this dependency is not visible in the notation.

\begin{prp}[Exercise 2.11 of \cite{hottbook}]
Given maps $f:A\to X$ and $g:B\to X$, the commuting square\index{canonical pullback|textit}
\begin{equation*}
\begin{tikzcd}
A\times_X B \arrow[r,"\pi_2"] \arrow[d,swap,"\pi_1"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X,
\end{tikzcd}
\end{equation*}
is a pullback square.
\end{prp}

In the following lemma we establish the uniqueness of pullbacks up to equivalence via a \emph{3-for-2 property} for pullbacks.

\begin{lem}\label{lem:pb_3for2}\index{pullback!3-for-2 property|textit}\index{3-for-2 property!of pullbacks|textit}%
Consider the squares
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] & {C'} \arrow[r,"{q'}"] \arrow[d,swap,"{p'}"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X & A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with homotopies $H:f\circ p \htpy g\circ q$ and $H':f\circ p'\htpy g\circ q'$.
Furthermore, suppose we have a map $h:C'\to C$ equipped with
\begin{align*}
K & : p\circ h \htpy p' \\
L & : q\circ h \htpy q' \\
M & : \ct{(H\cdot h)}{(g\cdot L)} \htpy \ct{(f\cdot K)}{H'}.
\end{align*}
If any two of the following three properties hold, so does the third:
\begin{samepage}%
\begin{enumerate}
\item $C$ is a pullback.
\item $C'$ is a pullback.
\item $h$ is an equivalence.
\end{enumerate}%
\end{samepage}%
\end{lem}

\begin{proof}
The type of triples $(K,L,M)$ is equivalent to the type of identifications
\begin{equation*}
\conemap((p,q,H),h)=(p',q',H').
\end{equation*}
Let $D$ be a type, and let $k:D\to C'$ be a map. We observe that
\begin{align*}
\conemap((p,q,H),(h\circ k)) & \jdeq (p\circ (h\circ k),q\circ (h\circ k),H\circ (h\circ k)) \\
& \jdeq ((p\circ h)\circ k,(q\circ h)\circ k, (H\circ h)\circ k) \\
& \jdeq \conemap(\conemap((p,q,H),h),k) \\
& = \conemap((p',q',H'),k).
\end{align*}
Thus we see that the triangle
\begin{equation*}
\begin{tikzcd}[column sep=-1em]
(D\to C') \arrow[rr,"{h\circ \blank}"] \arrow[dr,swap,"{\conemap(p',q',H')}"] & & (D\to C) \arrow[dl,"{\conemap(p,q,H)}"] \\
& \cone(D) & \phantom{(D\to C')}
\end{tikzcd}
\end{equation*}
commutes. Therefore it follows from the 3-for-2 property of equivalences that if any two of the following properties hold, then so does the third:
\begin{enumerate}
\item The map $\conemap(p,q,H):(D\to C)\to \cone(D)$ is an equivalence,
\item The map $\conemap(p',q',H'):(D\to C')\to \cone(D)$ is an equivalence,
\item The map $h\circ\blank : (D\to C')\to (D\to C)$ is an equivalence.
\end{enumerate}
Thus the 3-for-2 property for pullbacks follows from the fact that $h$ is an equivalence if and only if $h\circ\blank : (D\to C')\to (D\to C)$ is an equivalence for any type $D$.
\end{proof}

\begin{defn}
Given a commuting square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with $H:f\circ p \htpy g \circ q$, we define the \define{gap map}\index{gap map|textbf}\index{pullback!gap map|textbf}
\begin{equation*}
\gap(p,q,H):C \to A\times_X B
\end{equation*}
by $\lam{z}(p(z),q(z),H(z))$. Furthermore, we will write\index{is_pullback@{$\ispullback$}|textbf}
\begin{equation*}
\ispullback(f,g,H)\defeq \isequiv(\gap(p,q,H)).
\end{equation*}
\end{defn}

\begin{prp}\label{thm:is_pullback}
Consider a commuting square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with $H:f\circ p \htpy g \circ q$. The following are equivalent:
\begin{enumerate}
\item The square is a pullback square
\item There is a term of type
\begin{equation*}
\ispullback(p,q,H)\defeq \isequiv(\gap(p,q,H)).
\end{equation*}
\end{enumerate}
\end{prp}

\begin{proof}
Note that there are homotopies
\begin{align*}
K & : \pi_1\circ \gap(p,q,H) \htpy p \\
L & : \pi_2\circ \gap(p,q,H) \htpy q \\
M & : \ct{(\pi_3\cdot \gap(p,q,H))}{(g\cdot L)} \htpy \ct{(f\cdot K)}{H}.
\end{align*}
given by
\begin{align*}
K & \defeq \lam{z}\refl{p(z)} \\
L & \defeq \lam{z}\refl{q(z)} \\
M & \defeq \lam{z}\ct{\rightunit(H(z))}{\leftunit(H(z))^{-1}}.
\end{align*}
Therefore the claim follows by \cref{lem:pb_3for2}.
\end{proof}

\subsection{Fiberwise equivalences}

\begin{prp}\label{thm:pb_fibequiv}
Let $f:A\to B$, and let $g:\prd{a:A}P(a)\to Q(f(a))$ be a fiberwise transformation\index{fiberwise transformation|textit}. The following are equivalent:
\begin{enumerate}
\item The commuting square
\begin{equation*}
\begin{tikzcd}[column sep=large]
\sm{a:A}P(a) \arrow[r,"{\total[f]{g}}"] \arrow[d,swap,"\proj 1"] & \sm{b:B}Q(b) \arrow[d,"\proj 1"] \\
A \arrow[r,swap,"f"] & B
\end{tikzcd}
\end{equation*}
is a pullback square.
\item $g$ is a fiberwise equivalence.\index{fiberwise equivalence|textit}
\end{enumerate}
\end{prp}

\begin{proof}
The gap map factors as follows
\begin{equation*}
\begin{tikzcd}[column sep=-2em]
\sm{x:A}P(x) \arrow[dr,swap,"\total{g}"] \arrow[rr,"\gap"] & & A \times_B \Big(\sm{y:B}Q(y)\Big) \\
\phantom{A \times_B \Big(\sm{y:B}Q(y)\Big)} & \sm{x:A}Q(f(x)) \arrow[ur,swap,"{\gap'\,\defeq\,\lam{(x,q)}(x,(f(x),q),\refl{f(x)})}"]
\end{tikzcd}
\end{equation*}
Since $\gap'$ is an equivalence, it follows by \cref{thm:fib_equiv} that the gap map is an equivalence if and only if $g$ is a fiberwise equivalence.
\end{proof}

\begin{lem}
Consider a commuting square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with $H:f\circ p\htpy g\circ q$, and consider the fiberwise transformation
\begin{equation*}
\fibf{(f,q,H)} : \prd{a:A} \fib{p}{a}\to \fib{g}{f(a)}
\end{equation*}
given by $\lam{a}{(c,u)}(q(c),\ct{H(c)^{-1}}{\ap{f}{u}})$. Then there is an equivalence
\begin{equation*}
\eqv{\fib{\gap(p,q,H)}{(a,b,\alpha)}}{\fib{\fibf{(f,q,H)}(a)}{(b,\alpha^{-1})}}
\end{equation*}
\end{lem}

\begin{proof}
To obtain an equivalence of the desired type we simply concatenate known equivalences:
\begin{align*}
\fib{h}{(a,b,\alpha)} & \jdeq \sm{z:C} (p(z),q(z),H(z))=(a,b,\alpha) \\
& \eqvsym \sm{z:C}{u:p(z)=a}{v:q(z)=b}\ct{H(z)}{\ap{g}{v}}=\ct{\ap{f}{u}}{\alpha} \\
& \eqvsym \sm{(z,u):\fib{p}{a}}{v:q(z)=b} \ct{H(z)^{-1}}{\ap{f}{u}}=\ct{\ap{g}{v}}{\alpha^{-1}} \\
& \eqvsym \fib{\varphi(a)}{(b,\alpha^{-1})}\qedhere
\end{align*}
\end{proof}

\begin{cor}\label{cor:pb_fibequiv}
Consider a commuting square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with $H:f\circ p\htpy g\circ q$. The following are equivalent:
\begin{enumerate}
\item The square is a pullback square.\index{pullback square!characterized by fiberwise equivalence|textit}
\item The induced map on fibers
\begin{equation*}
\fibf{(p,q,H)}:\prd{x:A}\fib{p}{x}\to \fib{g}{f(x)}
\end{equation*}
is a fiberwise equivalence.
\end{enumerate}
\end{cor}

\begin{cor}\label{cor:pb_equiv}
Consider a commuting square
\begin{equation*}
\begin{tikzcd}
C \arrow[r,"q"] \arrow[d,swap,"p"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X.
\end{tikzcd}
\end{equation*}
and suppose that $g$ is an equivalence. Then the following are equivalent:
\begin{enumerate}
\item The square is a pullback square.
\item The map $p:C\to A$ is an equivalence.\index{equivalence!pullback of|textit}
\end{enumerate}
\end{cor}

\begin{proof}
If the square is a pullback square, then by \cref{thm:pb_fibequiv} the fibers of $p$ are equivalent to the fibers of $g$, which are contractible by \cref{thm:contr_equiv}. Thus it follows that $p$ is a contractible map, and hence that $p$ is an equivalence.

If $p$ is an equivalence, then by \cref{thm:contr_equiv} both $\fib{p}{x}$ and $\fib{g}{f(x)}$ are contractible for any $x:X$. It follows that the induced map $\fib{p}{x}\to\fib{g}{f(x)}$ is an equivalence. Thus we apply \cref{cor:pb_fibequiv} to conclude that the square is a pullback.
\end{proof}

\section{The univalence axiom}

The univalence axiom characterizes the identity type of the universe. It is considered to be an \emph{extensionality principle}\index{extensionality principle!types} for types. In the following theorem we introduce the univalence axiom and give two more equivalent ways of stating this.

\begin{prp}\label{thm:univalence}
The following are equivalent:
\begin{enumerate}
\item The \define{univalence axiom}\index{univalence axiom|textbf}: for any $A:\UU$ the map\index{equiv_eq@{$\equiveq$}|textbf}
\begin{equation*}
\equiveq\defeq \ind{A=}(\idfunc[A]) : \prd{B:\UU} (\id{A}{B})\to(\eqv{A}{B}).
\end{equation*}
is a fiberwise equivalence.\index{identity type!universe} If this is the case, we write
$\eqequiv$\index{eq equiv@{$\eqequiv$}|textbf}
for the inverse of $\equiveq$.
\item The type
\begin{equation*}
\sm{B:\UU}\eqv{A}{B}
\end{equation*}
is contractible for each $A:\UU$.
\item The principle of \define{equivalence induction}\index{equivalence induction}\index{induction principle!for equivalences}: for every $A:\UU$ and for every type family
\begin{equation*}
P:\prd{B:\UU} (\eqv{A}{B})\to \type,
\end{equation*}
the map
\begin{equation*}
\Big(\prd{B:\UU}{e:\eqv{A}{B}}P(B,e)\Big)\to P(A,\idfunc[A])
\end{equation*}
given by $f\mapsto f(A,\idfunc[A])$ has a section.\qedhere
\end{enumerate}
\end{prp}

It is a trivial observation, but nevertheless of fundamental importance, that by the univalence axiom the identity types of $\UU$ are equivalent to types in $\UU$, because it provides an equivalence $\eqv{(A=B)}{(\eqv{A}{B})}$, and the type $\eqv{A}{B}$ is in $\UU$ for any $A,B:\UU$. Since the identity types of $\UU$ are equivalent to types in $\UU$, we also say that the universe is \emph{locally small}.

\begin{defn}\label{defn:ess_small}
\begin{enumerate}
\item A type $A$ is said to be \define{essentially small}\index{essentially small!type|textbf} if there is a type $X:\UU$ and an equivalence $\eqv{A}{X}$. We write\index{ess_small(A)@{$\esssmall(A)$}|textbf}
\begin{equation*}
\esssmall(A)\defeq\sm{X:\UU}\eqv{A}{X}.
\end{equation*}
\item A map $f:A\to B$ is said to be \define{essentially small}\index{essentially small!map|textbf} if for each $b:B$ the fiber $\fib{f}{b}$ is essentially small.
We write\index{ess_small(f)@{$\esssmall(f)$}|textbf}
\begin{equation*}
\esssmall(f)\defeq\prd{b:B}\esssmall(\fib{f}{b}).
\end{equation*}
\item A type $A$ is said to be \define{locally small}\index{locally small!type} if for every $x,y:A$ the identity type $x=y$ is essentially small.
We write\index{loc_small(A)@{$\locsmall(A)$}|textbf}
\begin{equation*}
\locsmall(A)\defeq \prd{x,y:A}\esssmall(x=y).
\end{equation*}
\item Similarly, a map $f:A\to X$ is said to be \define{locally small} if $\delta_f:A\to A\times_X A$ is essentially small.
\end{enumerate}
\end{defn}

\begin{lem}\label{lem:isprop_ess_small}
The type $\esssmall(X)$ is a proposition for any type $X$.\index{essentially small!is a proposition|textit}
\end{lem}

\begin{proof}
Let $X$ be a type. Our goal is to show that the type
\begin{equation*}
\sm{Y:\UU}\eqv{X}{Y}
\end{equation*}
is a proposition. Suppose there is a type $X':\UU$ and an equivalence $e:\eqv{X}{X'}$, then the map
\begin{equation*}
(\eqv{X}{Y})\to (\eqv{X'}{Y})
\end{equation*}
given by precomposing with $e^{-1}$ is an equivalence. This induces an equivalence on total spaces
\begin{equation*}
\eqv{\Big(\sm{Y:\UU}\eqv{X}{Y}\Big)}{\Big(\sm{Y:\UU}\eqv{X'}{Y}\Big)}
\end{equation*}
However, the codomain of this equivalence is contractible by \cref{thm:univalence}. Thus it follows that the asserted type is a proposition.
\end{proof}

\begin{cor}
For each function $f:A\to B$, the type $\esssmall(f)$ is a proposition, and for each type $X$ the type $\locsmall(X)$ is a proposition.
\end{cor}

\begin{proof}
This follows from the fact that propositions are closed under dependent products, established in \cref{thm:prop_pi}.
\end{proof}

\begin{rmk}
The property of essentially smallness is preserved by $\Pi$, $\Sigma$, and $\mathsf{Id}$. Of course, any contractible type is essentially small, and so is any small type. The property of essentially smallness is preserved by $\Sigma$ and $\mathsf{Id}$, and the exponent $X^A$ of a locally small type $X$ by an essentially small type $A$ is again locally small. Furthermore, any proposition is locally small, and any universe is locally small with respect to itself.
\end{rmk}

\begin{defn}
Consider two functions $f:A\to X$ and $g:B\to X$. We define the type
\begin{equation*}
\hom_X(f,g)\defeq \sm{h:A\to B} f\htpy g\circ h.
\end{equation*}
\end{defn}

In other words, the type $\hom_X(f,g)$ is the type of functions $h:A\to B$ equipped with a homotopy witnessing that the triangle
\begin{equation*}
\begin{tikzcd}[column sep=tiny]
A \arrow[dr,swap,"f"] \arrow[rr,"h"] & & B \arrow[dl,"g"] \\
& X
\end{tikzcd}
\end{equation*}

\begin{lem}
Let $P$ and $Q$ be two type families over $X$, and write $\proj 1^P$ and $\proj 1^Q$ for their first projections, respectively. Then the map
\begin{equation*}
\tottriangle:\Big(\prd{x:X} P(x)\to Q(x)\Big)\to \hom_X(\proj 1^P,\proj 1^Q)
\end{equation*}
given by $\tottriangle(f)\defeq (\total{f},\lam{(x,y)}\refl{x})$, is an equivalence.
\end{lem}

\begin{cor}\label{cor:fib_triangle}
For any two maps $f:A\to X$ and $g:B\to X$, the map
\begin{equation*}
\fibtriangle : \hom_X(f,g) \to \prd{x:X}\fib{f}{x}\to \fib{g}{x}
\end{equation*}
given by $\lam{(h,H)}{x}{(a,p)}(h(a),\ct{H(a)^{-1}}{p})$ is an equivalence.
\end{cor}

\begin{thm}\label{thm:fam_proj}
For any small type $A:\UU$ there is an equivalence
\begin{equation*}
\eqv{(A\to \UU)}{\Big(\sm{X:\UU} X\to A\Big)}.
\end{equation*}
\end{thm}

\begin{proof}
Note that we have the function
\begin{equation*}
\varphi :\lam{B} \Big(\sm{x:A}B(x),\proj 1\Big) : (A\to \UU)\to \Big(\sm{X:\UU}X\to A\Big).
\end{equation*}
The fiber of this map at $(X,f)$ is by univalence and function extensionality equivalent to the type
\begin{equation*}
\sm{B:A\to \UU}{e:\eqv{(\sm{x:A}B(x))}{X}} \proj 1\htpy f\circ e.
\end{equation*}
By \cref{cor:fib_triangle} this type is equivalent to the type
\begin{equation*}
\sm{B:A\to \UU}\prd{a:A} \eqv{B(a)}{\fib{f}{a}},
\end{equation*}
and by `type theoretic choice', which was established in \cref{thm:choice}, this type is equivalent to
\begin{equation*}
\prd{a:A}\sm{X:\UU}\eqv{X}{\fib{f}{a}}.
\end{equation*}
We conclude that the fiber of $\varphi$ at $(X,f)$ is equivalent to the type $\esssmall(f)$. However, since $f:X\to A$ is a map between small types it is essentially small. Moreover, since being essentially small is a proposition by \cref{lem:isprop_ess_small}, it follows that $\fib{\varphi}{(X,f)}$ is contractible for every $f:X\to A$. In other words, $\varphi$ is a contractible map, and therefore it is an equivalence.
\end{proof}

\begin{rmk}
The inverse of the map
\begin{equation*}
\varphi : (A\to \UU)\to \Big(\sm{X:\UU}X\to A\Big).
\end{equation*}
constructed in \cref{thm:fam_proj} is the map $(X,f)\mapsto \fibf{f}$.
\end{rmk}

\section{The object classifier}

\begin{defn}
Let $p:E\to B$ and $p':E'\to B'$ be maps. A morphism from $p'$ to $p$ is a triple $(f,g,H)$ consisting of maps $f:B'\to B$ and $g:E'\to E$ and a homotophy $H:f\circ p'\htpy p\circ g$ witnessing that the square
\begin{equation}\label{eq:morphism_arrow}
\begin{tikzcd}
E' \arrow[r,"g"] \arrow[d,swap,"p'"] & E \arrow[d,"p"] \\
B' \arrow[r,"f"] & B
\end{tikzcd}
\end{equation}
commutes. We write $\mathsf{hom}(p',p)$ for the type of such triples $(f,g,H)$, and sometimes we write $\mathsf{hom}_f(p',p)$ for the type of pairs $(g,H)$. A morphism $(f,g,H)$ is said to be \define{cartesian} if the square in \cref{eq:morphism_arrow} is cartesian. We write $\mathsf{cart}(p',p)$ for the type of cartesian morphisms from $p'$ to $p$, and we write $\mathsf{cart}_f(p',p)$ for the type of triples $(g,H,t)$ for the type of triples, where $t:\ispullback(p',g,H)$.
\end{defn}

\begin{defn}\label{defn:object_classifier}
A morphism $p:E\to B$ is said to be an \define{object classifier} if the type $\mathsf{cart}(p',p)$ is a proposition for each $p':E'\to B'$. If $p:E\to B$ is an object classifier, we also write
\begin{equation*}
\mathsf{is\usc{}classified}(p')\defeq \mathsf{hom}(p',p).
\end{equation*}
\end{defn}

Our goal in this section is to show that a univalent universe is an object classifier.

\begin{prp}\label{thm:pb_fibequiv_complete}
Let $\alpha:I\to J$ be a map, and let $A:I\to\UU$ and $B:J\to\UU$ be type families.
Then the map
\begin{equation*}
\Big(\prd{i:I}A_i\to B_{\alpha(i)}\Big) \to \mathsf{hom}_\alpha(\proj 1^A,\proj 1^B)
\end{equation*}
given by $\lam{f}(\total[\alpha]{f},\lam{(x,y)}\refl{x})$ is an equivalence. Furthermore, the map
\begin{equation*}
\Big(\prd{i:I}A_i\eqvsym B_{\alpha(i)}\Big) \to \mathsf{cart}_\alpha(\proj 1^A,\proj 1^B)
\end{equation*}
given by $\lam{e}(\total[\alpha]{e},\lam{(x,y)}\refl{x},t)$ where $t$ is the term constructed in \cref{thm:pb_fibequiv}, is an equivalence.
\end{prp}

\begin{proof}
We have the equivalences
\begin{align*}
\prd{i:I}A_i\to B_{\alpha(i)} & \eqvsym \prd{i:I}{a:A_i}\sm{j:J}{\gamma : \alpha(i)=j} B_j \\
& \eqvsym \prd{i:I}{a:A_i}\sm{j:J}{b:B_j}\alpha(i)=j \\
& \eqvsym \prd{(i,a):\sm{i:I}A_i}\sm{(j,b):\sm{j:J}B_j}\alpha(i)=j \\
& \eqvsym \sm{f:\big(\sm{i:I}A_i\big)\to\big(\sm{j:J}B_j\big)}\alpha\circ \proj 1^A\htpy \proj 1^B\circ f \\
& \jdeq \mathsf{hom}_\alpha(\proj 1^A,\proj 1^B).
\end{align*}
It is easy to check that this composite is the asserted map. The second claim follows from \cref{thm:pb_fibequiv}.
\end{proof}

\begin{cor}\label{cor:sq_fib}
Consider a diagram of the form
\begin{equation*}
\begin{tikzcd}
A \arrow[d,swap,"f"] & B \arrow[d,"g"] \\
I \arrow[r,swap,"\alpha"] & J.
\end{tikzcd}
\end{equation*}
Then the map
\begin{equation*}
\mathsf{hom}_\alpha(f,g)\to \Big(\prd{i:I}\fib{f}{i}\to\fib{g}{\alpha(i)}\Big)
\end{equation*}
given by $\lam{(h,H)}{i}{(a,p)}(h(a),\ct{H(a)^{-1}}{\ap{\alpha}{p}})$ is an equivalence.
\end{cor}

\begin{thm}\label{thm:classifier}
Let $f:A\to B$ be a map, and let $\UU$ be a univalent universe with universal family $\mathrm{El}$ over $\UU$. Then there is an equivalence
\begin{equation*}
\eqv{\esssmall(f)}{\mathsf{cart}(f,\proj 1^{\mathrm{El}})}.
\end{equation*}
In particular, the type $\mathsf{cart}(f,\proj 1^{\mathrm{El}})$ is a proposition for each map $f$, so the universe is an object classifier in the sense of \cref{defn:object_classifier}.
\end{thm}

\begin{proof}
From \cref{cor:sq_fib} we obtain that the type of pairs $(\tilde{F},H)$ is equivalent to the type of fiberwise transformations
\begin{equation*}
\prd{b:B}\fib{f}{b}\to F(b).
\end{equation*}
By \cref{cor:pb_fibequiv} the square is a pullback square if and only if the induced map
\begin{equation*}
\prd{b:B}\fib{f}{b}\to F(b)
\end{equation*}
is a fiberwise equivalence. Thus the data $(F,\tilde{F},H,pb)$ is equivalent to the type of pairs $(F,e)$ where $e$ is a fiberwise equivalence from $\fibf{f}$ to $F$. By \cref{thm:choice} the type of pairs $(F,e)$ is equivalent to the type $\esssmall(f)$.
\end{proof}

\begin{rmk}
For any type $A$ (not necessarily small), and any $B:A\to \UU$, the square\index{Sigma-type@{$\Sigma$-type}!as pullback of universal family|textit}
\begin{equation*}
\begin{tikzcd}[column sep=6em]
\sm{x:A}B(x) \arrow[d,swap,"\proj 1"] \arrow[r,"{\lam{(x,y)}(B(x),y)}"] & \sm{X:\UU}X \arrow[d,"\proj 1"] \\
A \arrow[r,swap,"B"] & \UU
\end{tikzcd}
\end{equation*}
is a pullback square. Therefore it follows that for any family $B:A\to\UU$ of small types, the projection map $\proj 1:\sm{x:A}B(x)\to A$ is an essentially small map.
To see that the claim is a direct consequence of \cref{thm:pb_fibequiv} we write the asserted square in its rudimentary form:
\begin{equation*}
\begin{tikzcd}[column sep=6em]
\sm{x:A}\mathrm{El}(B(x)) \arrow[d,swap,"\proj 1"] \arrow[r,"{\lam{(x,y)}(B(x),y)}"] & \sm{X:\UU}\mathrm{El}(X) \arrow[d,"\proj 1"] \\
A \arrow[r,swap,"B"] & \UU.
\end{tikzcd}
\end{equation*}
\end{rmk}

In the following theorem we show that a type is locally small if and only if its diagonal is classified by $\UU$.

\begin{thm}
Let $A$ be a type. The following are equivalent:
\begin{enumerate}
\item $A$ is locally small.\index{locally small|textit}
\item The diagonal $\delta_A : A\to A\times A$ is classified by $\UU$.\index{diagonal!of a type|textit}
\end{enumerate}
\end{thm}

\begin{proof}
The identity type $x=y$ is the fiber of $\delta_A$ at $(x,y):A\times A$. Therefore it follows that $A$ is locally small if and only if the diagonal $\delta_A$ is essentially small.
Now the result follows from \cref{thm:classifier}.
\end{proof}


\section{Protocol Parameters}
\label{sec:protocol-parameters}

\subsection{Updatable Protocol Parameters}
\label{sec:updatable-protocol-parameters}

The Shelley protocol parameters are listed in Figure~\ref{fig:defs:protocol-parameters}.
Some of the Shelley protocol parameters are common to the Byron era,
specifically, the common ones are $\var{a}$, $\var{b}$, $\var{maxTxSize}$, and
$\var{maxHeaderSize}$ (see the document~\cite{byron_ledger_spec}).

The type $\Ppm$ represents the names of the protocol parameters,
and $\mathsf{T_{ppm}}$ is the type of the protocol parameter $\var{ppm}$.
The type $\PParams$ is a finite map containing all the Shelley parameters,
indexed by their names.
We will explain the significance of each parameter as it comes up in
the calculations used in transition rules.
The type $\PParamsUpdate$ is similar to $\PParams$, but is
a partial mapping of the protocol parameters. It is used in the update
system explained in Section~\ref{sec:update}.

The type $\Coin$ is defined as an alias for the integers.
Negative values will not be allowed in UTxO outputs or reward accounts,
and $\Z$ is only chosen over $\N$ for its additive inverses.

Some helper functions are defined in Figure~\ref{fig:defs:protocol-parameters-helpers}.
The $\fun{minfee}$ function calculates the minimum fee that must be paid by a transaction.
This value depends on the protocol parameters and the size of the transaction.

Two time related types are introduced, $\Epoch$ and $\type{Duration}$.
A $\type{Duration}$ is the difference between two slots, as given by $\slotminus{}{}$.

Lastly, there are two functions, $\fun{epoch}$ and $\fun{firstSlot}$ for converting
between epochs and slots and one function $\fun{kesPeriod}$ for getting the cycle of a slot.
Note that $\Slot$ is an abstract type, while the constants are integers.
We use multiplication and division symbols on these distinct types
without being explicit about the types and conversion.

\begin{figure*}[htb]
  \emph{Abstract types}
  %
  \begin{equation*}
    \begin{array}{r@{~\in~}lr}
      \var{p} & \Ppm & \text{protocol parameter}\\
      \var{dur} & \Duration & \text{difference between slots}\\
      \var{epoch} & \Epoch & \text{epoch} \\
      \var{kesPeriod} & \KESPeriod & \text{KES period} \\
    \end{array}
  \end{equation*}
  %
  \emph{Derived types}
  %
  \begin{equation*}
    \begin{array}{r@{~\in~}l@{\qquad=\qquad}lr}
      \var{pp}
      & \PParams
      & \Ppm \to \mathsf{T_{ppm}}
      & \text{protocol parameters}
      \\
      \var{ppup}
      & \PParamsUpdate
      & \Ppm \mapsto \mathsf{T_{ppm}}
      & \text{protocol parameter update}
      \\
      \var{coin}
      & \Coin
      & \Z
      & \text{unit of value}
      \\
      \var{pv}
      & \ProtVer
      & \N\times\N
      & \text{protocol version}
    \end{array}
  \end{equation*}
  %
  \emph{Protocol Parameters}
  %
  \begin{equation*}
      \begin{array}{r@{~\in~}lr}
        \var{a} \mapsto \Z & \PParams & \text{min fee factor}\\
        \var{b} \mapsto \Z & \PParams & \text{min fee constant}\\
        \var{maxBlockSize} \mapsto \N & \PParams & \text{max block body size}\\
        \var{maxTxSize} \mapsto \N & \PParams & \text{max transaction size}\\
        \var{maxHeaderSize} \mapsto \N & \PParams & \text{max block header size}\\
        \var{keyDecayRate} \mapsto \nonnegReals & \PParams & \text{stake credential decay rate}\\
        \var{poolDeposit} \mapsto \Coin & \PParams & \text{stake pool deposit}\\
        \var{E_{max}} \mapsto \Epoch & \PParams & \text{epoch bound on pool retirement}\\
        \var{n_{opt}} \mapsto \Npos & \PParams & \text{desired number of pools}\\
        \var{a_0} \mapsto \posReals & \PParams & \text{pool influence}\\
        \tau \mapsto \unitInterval & \PParams & \text{treasury expansion}\\
        \rho \mapsto \unitInterval & \PParams & \text{monetary expansion}\\
        \var{d} \mapsto \{0,~0.1,~0.2,~\ldots,~1\} & \PParams & \text{decentralization parameter}\\
        \var{extraEntropy} \mapsto \Seed & \PParams & \text{extra entropy}\\
        \var{pv} \mapsto \ProtVer & \PParams & \text{protocol version}\\
        \var{minUTxOValue} \mapsto \Coin & \PParams & \text{minimum allowed value of a new \TxOut}\\
        \var{minPoolCost} \mapsto \Coin & \PParams & \text{minimum allowed stake pool cost}\\
      \end{array}
  \end{equation*}
  %
  \emph{Accessor Functions}
  %
  \begin{center}
    \fun{a},
    \fun{b},
    \fun{maxBlockSize},
    \fun{maxTxSize},
    \fun{maxHeaderSize},
    \fun{keyDeposit},
    \fun{poolDeposit},
    \fun{emax},
    \fun{nopt},
    \fun{influence},
    \fun{tau},
    \fun{rho},
    \fun{d},
    \fun{extraEntropy},
    \fun{pv},
    \fun{minUTxOValue},
    \fun{minPoolCost}
  \end{center}
  %
  \emph{Abstract Functions}
  %
  \begin{equation*}
    \begin{array}{r@{~\in~}lr}
      (\slotminus{}{}) & \Slot \to \Slot \to \Duration
                       & \text{duration between slots}
    \end{array}
  \end{equation*}
  %
  \caption{Definitions Used in Protocol Parameters}
  \label{fig:defs:protocol-parameters}
\end{figure*}

\subsection{Global Constants}
\label{sec:global-constants}

In additon to the updatable protocol parameters defined in
Section~\ref{sec:updatable-protocol-parameters},
there are ten parameters which cannot be changed by the update
system in Section~\ref{sec:update}.
We call these the global constants, as changing these values can only
be done by updating the software, i.e. a soft or a hard fork.
For the software update mechanism, see Section~\ref{sec:software-updates}.

The constants $\SlotsPerEpoch$ and $\SlotsPerKESPeriod$
represent the number of slots in an epoch/KES period (for a brief explanation
of a KES period, see Section \ref{sec:crypto-primitives-shelley}).
The constants $\StabilityWindow$ and $\RandomnessStabilisationWindow$ concern the chain stability.
The maximum number of time a KES key can be evolved before a pool operator
must create a new operational certificate is given by $\MaxKESEvo$.
\textbf{Note that if } $\MaxKESEvo$
\textbf{is changed, the KES signature format may have to change as well.}

The constant $\Quorum$ determines the quorum amount needed for votes on the
protocol parameter updates and the application version updates.

The constant $\MaxMajorPV$ provides a mechanism for halting outdated nodes.
Once the major component of the protocol version in the protocol parameters
exceeds this value, every subsequent block is invalid.
See Figures~\ref{fig:funcs:chain-helper} and~\ref{fig:rules:chain}.

The constant $\MaxLovelaceSupply$ gives the total number of lovelace in the system,
which is used in the reward calculation.
It is always equal to the sum of the values in the UTxO, plus the sum of the
values in the reward accounts, plus the deposit pot, plus the fee pot,
plus the treasury and the reserves.

The constant $\ActiveSlotCoeff$ is the value $f$ from the
Praos paper \cite{ouroboros_praos}.

Lastly, $\NetworkId$ determines what network, either mainnet or testnet, is expected.
This value will also appear inside every address, and transactions
containing addresses with an unexpected network ID are rejected.

\begin{figure*}[htb]
  \emph{Global Constants}
  %
  \begin{equation*}
    \begin{array}{r@{~\in~}lr}
      \SlotsPerEpoch & \N & \text{- slots per epoch} \\
      \SlotsPerKESPeriod & \N & \text{- slots per KES period} \\
      \StabilityWindow & \Duration &
      \begin{array}{r}
        \text{- window size for chain growth} \\
        \text{guarantees, see}\text{ in \cite{ouroboros_praos}}
      \end{array} \\
      \RandomnessStabilisationWindow & \Duration &
      \begin{array}{r}
        \text{- duration needed for epoch}\\
        \text{nonce stabilization}\\
      \end{array} \\
      \MaxKESEvo & \N & \text{- maximum KES key evolutions}\\
      \Quorum & \N & \text{- quorum for update system votes}\\
      \MaxMajorPV & \N & \text{- all blocks are invalid after this value}\\
      \MaxLovelaceSupply & \Coin & \text{- total lovelace in the system}\\
      \ActiveSlotCoeff & (0, 1] & \text{ - }f\text{ in \cite{ouroboros_praos}}\\
      \NetworkId & \Network & \text{- the network, mainnet or testnet}\\
    \end{array}
  \end{equation*}
  %
  \caption{Global Constants}
  \label{fig:defs:global-constants}
\end{figure*}

\begin{figure*}[htb]
  \emph{Helper Functions}
  %
  \begin{align*}
    \fun{minfee} & \in \PParams \to \Tx \to \Coin & \text{minimum fee}\\
    \fun{minfee} & ~\var{pp}~\var{tx} =
    (\fun{a}~\var{pp}) \cdot \fun{txSize}~\var{tx} + (\fun{b}~\var{pp})
    \\
    \\
    \fun{epoch} & \in ~ \Slot \to \Epoch & \text{epoch of a slot}
    \\
    \fun{epoch} & ~\var{slot} = \var{slot}~/~\SlotsPerEpoch
    \\
    \\
    \fun{firstSlot} & \in ~ \Epoch \to \Slot
               & \text{first slot of an epoch}
    \\
    \fun{firstSlot} & ~\var{e} = \var{e}~\cdot~\SlotsPerEpoch
    \\
    \\
    \fun{kesPeriod} & \in ~ \Slot \to \KESPeriod & \text{KES period of a slot}
    \\
    \fun{kesPeriod} & ~\var{slot} = \var{slot}~/~\SlotsPerKESPeriod
  \end{align*}
  %
  \caption{Helper functions for the Protocol Parameters}
  \label{fig:defs:protocol-parameters-helpers}
\end{figure*}

\clearpage


\section{Power Reactor Terminology}
\begin{labeling}
    \item [\underline{Coolant}:] Material used to remove heat from core, to
        heat water, to push a turbine, etc.
    \item [\underline{Steam or Coolant Loops}:] Number of heat transfer mechanisms.
        Must be at least 1.
    \item [\underline{Moderator}:] Material that slows down neutrons. Not all
        reactors are moderated. Sometimes this is the same as the coolant. Typically
        low-Z materials.
    \item [\underline{Neutron Energies}:]
        \begin{labeling}
            \item [\underline{Fast}:] At or near fission neutron birth energies $> 1$ MeV
            \item [\underline{Epithermal}:] Neutrons in the process of slowing down
                $[10^{-5}, 1)$ MeV.
            \item [\underline{Thermal}:] Neutrons in thermal equilibrium with the moderator,
                $< 10^{-5}$ MeV. Maxwellian distribution
                % FIXME Add image of maxwell distribution for linaer and log.
        \end{labeling}
    \item [\underline{Fuel Production}:]
        \begin{labeling}
            \item [\underline{Burner}:] If destroies more atomes of fuel at discharge.
            \item [\underline{Breeder}:] If creates more atoms of fuel at discharge
        \end{labeling}
\end{labeling}

% FIXME Add single loop core image
% FIXME Add two loop core image

\section{Neutron Multiplication}
Reactors are controlled by how many neutron are in teh core at any given time.
This is because neutrons cause fission, which releases energy and more neutrons.

\section{Prompt Neutron Multiplication}
``Prompt'' means that neutrons born in a given generation are destroyed or lost before the
next generation, i.e. instantly.

Change in \# neutrons = Sources - Losses

Symbolically,
\[ \frac{dN}{dt} = \nu \Sigma_f\phi - \Sigma_a\phi -DB^2\phi \]

Let's go through this term-by-term.

Note: The book uses $\Phi$ for $\phi$

\section{Difussion Theory Terms}
\begin{labeling}
    \item [$N$:] Neutron density [n/cm$^3$]
    \item [$t$:] Time [sec]
    \item [$\nu$:] Number of neutrons born per fission, 2 - 5 typically [unitless]
    \item [$\Sigma_f$:] macroscopic fission cross section, [1/cm]
    \item [$\phi$:] neutron flux, [n/cm$^2$ s]
    \item [$\Sigma_a$:] Macroscopic absorption cross-section
    \item [$D$:] Diffission coefficient, [cm], related to neutron mean free path
        $\lambda_{\mathrm{tr}}$ by
        \[ D = \frac{\lambda_{\mathrm{tr}}}{3} = \frac{1}{3\Sigma_{\mathrm{tr}}} = \frac{1}{3\Sigma_s(1 -\frac{2}{3A})} \]
    \item [$B$:] Buckling [1/cm]
        \begin{itemize}
            \item \mathbf{Geometric Buckling} $B_g$ depends on the shape of the core, see table 4-2.
            \item \mathbf{Material Buckling} $B_m$'s is derived from the criticality constraint
                such that $B_m^2 = \frac{\nu\Sigma_f - \Sigma_a}{D}$ for critical systems.
        \end{itemize}
\end{labeling}

So, $\frac{dN}{dt}$ is the growth rate.

$\nu\Sigma_f\phi$ is the rate of neutron birth.

$\Sigma_a\phi$ is the rate at which neutrons are destroyed.

$DB^2\phi$ is the \textit{Leakage}, or the rate at which neutrons leave the system entirely.

\underline{On the board:}  Units for each term. Ensure that they are the same.