\documentclass{article}
\input{packages}
\input{def}

\lecture{Categories}

\begin{document}
\maketitle

\begin{definition}[(Biased) ($\cat{Set}$-enriched) Category]
A tuple $\langle O, M, \cocomp, \prf{a}, \id, \prf{i} \rangle$ where the components have the following types:
\begin{framed}
\begin{description}
\item[Objects $O$:] $\TYPE{1}$
\item[Morphisms $M$:] $O \times O \to \Type$
\item[Composition $\cocomp$:] $\forall \ob{C}_1, \ob{C}_2, \ob{C}_3 : O.\; M(\ob{C}_1, \ob{C}_2) \times M(\ob{C}_2, \ob{C}_3) \to M(\ob{C}_1, \ob{C}_3)$ (infix --- objects implicit)
\item[Associativity $\prf{a}$:] $\forall \ob{C}_1, \ob{C}_2, \ob{C}_3, \ob{C}_4 : O.\; \forall \mo{m}_1 : M(\ob{C}_1, \ob{C}_2), \mo{m}_2 : M(\ob{C}_2, \ob{C}_3), \mo{m}_3 : M(\ob{C}_3, \ob{C}_4).\; (\mo{m}_1 \cocomp \mo{m}_2) \cocomp \mo{m}_3 = \mo{m}_1 \cocomp (\mo{m}_2 \cocomp \mo{m}_3)$
\item[Identities $\id$:] $\forall \ob{C} : O.\; M(\ob{C}, \ob{C})$ (object implicit)
\item[Identity $\prf{i}$:] $\forall \ob{C}_1, \ob{C}_2 : O, \mo{m} : M(\ob{C}_1, \ob{C}_2).\; \id \cocomp \mo{m} = \mo{m} = \mo{m} \cocomp \id$
\end{description}
\end{framed}
\end{definition}

\begin{notation}
When the category is implicit from context, we use $\ob{C}_1 \mto \ob{C}_2$ to denote the type $M(\ob{C}_1, \ob{C}_2)$, referred to as morphisms from $\ob{C}_1$ to $\ob{C}_2$.
\end{notation}

\begin{notation}
When the category is implicit from context, we use $\ob{C}_1 \xmto{\mo{m}} \ob{C}_2$ to denote $m : \ob{C}_1 \mto \ob{C}_2$.
\end{notation}

\begin{definition}[Domain,Codomain,Source,Target]
Given a morphism $\ob{C}_1 \xmto{\mo{m}} \ob{C}_2$, we refer to~$\ob{C}_1$ as the domain (or source) of~$\mo{m}$, and to~$\ob{C}_2$ as the codomain (or target) of~$\mo{m}$.
\end{definition}

\begin{notation}
We use $\ob{C}_1 \xmto{\mo{m}_1} \ob{C}_2 \xmto{\mo{m}_2} \ob{C}_2$ (and longer chains) to denote $\mo{m}_1 \cocomp \mo{m}_2$.
\end{notation}

\begin{notation}
We use $\mo{m}_2 \circ \mo{m}_1$ to denote $\mo{m}_1 \cocomp \mo{m}_2$.
\end{notation}

\begin{example}
\begin{description}
\setlength{\itemsep}{0pt}
\item[$\cat{Set} =$] $\langle \Type, \lambda \langle \tau_1, \tau_2 \rangle.\; \tau_1 \to \tau_2, \lambda \langle \tau_1, \tau_2, \tau_3 \rangle.\; \lambda \langle f, g \rangle.\; \lambda x.\; g(f(x)), \noprf, \lambda \tau. \; \lambda x.\; x, \noprf \rangle$
\item[$\cat{n} =$] $\langle \mathbb{n}, \leq, \prf{transitivity}, \prf{proof\text{-}irrelevance}, \prf{reflexivity}, \prf{proof\text{-}irrelevance} \rangle$ where $\mathbb{n}$ is $\{1, \dots, n\}$
\item[$\mathbb{\omega} =$] $\langle \N, \leq, \prf{transitivity}, \prf{proof\text{-}irrelevance}, \prf{reflexivity}, \prf{proof\text{-}irrelevance} \rangle$
\item[$\cat{Rel} =$] $\langle \Type, \lambda \langle \tau_1, \tau_2 \rangle.\; \tau_1 \times \tau_2 \to \Prop, \lambda \langle \tau_1, \tau_2, \tau_3 \rangle.\; \lambda \langle \phi_1, \phi_2 \rangle.\; \lambda \langle t_1, t_3 \rangle.\; \exists t_2.\; \phi_1(t_1, t_2) \wedge \phi_2(t_2, t_3), \noprf, \lambda \langle t, t' \rangle.\; t = t', \noprf \rangle$
\item[$\cat{Prost}$] $\displaystyle \left\langle\begin{array}{l} \sum_{\tau : \Type} \sum_{R : \tau \times \tau \to \Prop} (\forall t : \tau.\; R(t,t)) \wedge (\forall t_1, t_2, t_3 : \tau.\; R(t_1, t_2) \times R(t_2, t_3) \to R(t_1, t_3)), \\ \lambda \langle \langle \tau_1, R_1, \noprf \rangle, \langle \tau_2, R_2, \noprf \rangle \rangle.\; \sum_{f : \tau_1 \to \tau_2} \forall t_1, t_2 : \tau_1.\; R_1(t_1, t_2) \to R_2(f(t_1), f(t_2)), \\ \lambda \langle \alg{R}_1, \alg{R}_2, \alg{R}_3 \rangle.\; \lambda \langle \langle f_1, \noprf \rangle, \langle f_2, \noprf \rangle \rangle.\; \langle \lambda x.\; f_2(f_1(x)), \noprf \rangle, \noprf, \lambda \langle \tau, R, \noprf \rangle.\; \langle \lambda x.\;x, \noprf \rangle, \noprf \end{array}\right\rangle$
\item[$\cat{Mat} =$] $\langle \N, \lambda \langle n_1, n_2 \rangle.\; \R^{n_2 \times n_1}, \lambda \langle n_1, n_2, n_3 \rangle.\; \lambda \langle M_1, M_2 \rangle.\; M_2 \cdot M_1, \noprf, \lambda n.\; \delta^n_n, \noprf \rangle$
\item[$\mathbb{\Delta}_n =$] $\langle \mathbb{n}, \lambda \langle n_1, n_2 \rangle.\; \{ \sigma : \mathbb{n}_1 \to \mathbb{n}_2 \mid \forall n_1, n_2 : \mathbb{n}_1.\; n_1 \leq n_2 \imply \sigma n_1 \leq \sigma n_2 \}, \lambda \langle n_1, n_2, n_3 \rangle.\; \lambda \langle \sigma_1, \sigma_2 \rangle.\; \sigma_1 \cocomp \sigma_2, \noprf, \lambda n.\; \lambda x.\; x, \noprf \rangle$
\item[$\mathbb{\Delta} =$] $\langle \N, \lambda \langle n_1, n_2 \rangle.\; \{ \sigma : \mathbb{n}_1 \to \mathbb{n}_2 \mid \forall n_1, n_2 : \mathbb{n}_1.\; n_1 \leq n_2 \imply \sigma n_1 \leq \sigma n_2 \}, \lambda \langle n_1, n_2, n_3 \rangle.\; \lambda \langle \sigma_1, \sigma_2 \rangle.\; \sigma_1 \cocomp \sigma_2, \noprf, \lambda n.\; \lambda x.\; x, \noprf \rangle$
\item[$\cat{Sig} =$] $\displaystyle \left\langle \begin{array}{l} \sum_{O : \Type} O \to \Type, \\ \lambda \langle \langle O_1, N_1 \rangle, \langle O_2, N_2 \rangle \rangle.\; \sum_{f : O_1 \to O_2} \prod_{o : O_1} N_2(f(o)) \to N_1(o), \\ \lambda \langle \langle O_1, N_1 \rangle, \langle O_2, N_2 \rangle, \langle O_3, N_3 \rangle \rangle.\; \lambda \langle \langle f_1, n_1 \rangle, \langle f_2, n_2 \rangle \rangle.\; \langle \lambda o.\; f_2(f_1(o)), \lambda o.\; \lambda n.\; n_1(o)(n_2(f_1(o))(n)) \rangle, \noprf, \\ \lambda \langle O, N \rangle.\; \langle \lambda o.\; o, \lambda o.\; \lambda n.\; n \rangle, \noprf \end{array} \right\rangle$
\item[$\cat{Alg}(\Omega : \cat{Sig}) =$] $\left\langle \begin{array}{l} \sum_{A : \Type} \prod_{\mathit{op} \mapsto N \in \Omega} (N \to A) \to A, \\ \lambda \langle \langle A, a \rangle, \langle B, b \rangle \rangle.\; \sum_{f : A \to B} \forall \mathit{op} \mapsto N \in \Omega.\; \forall i : N \to A.\; b_{\mathit{op}}(\lambda n.\; f(i(n))) = f(a_{\mathit{op}}(i)), \\ \lambda \langle \alg{A}_1, \alg{A}_2, \alg{A}_3 \rangle.\; \lambda \langle \langle f_1, \noprf \rangle, \langle f_2, \noprf \rangle \rangle.\; \langle \lambda x.\; f_2(f_1(x)), \noprf \rangle, \noprf, \lambda \langle A, a \rangle.\; \langle \lambda x.\;x, \noprf \rangle, \noprf \end{array}\right\rangle$
\item[$\cat{Rel}(\Phi : \cat{Sig}) =$] $\left\langle \begin{array}{l} \sum_{A : \Type} \prod_{\mathit{rel} \mapsto N \in \Phi} (N \to A) \to \Prop, \\ \lambda \langle \langle R, \phi \rangle, \langle S, \psi \rangle \rangle.\; \sum_{f : R \to S} \forall \mathit{rel} \mapsto N \in \Phi.\; \forall i : N \to A.\; \phi_{\mathit{rel}}(i) \implies \psi_{\mathit{rel}}(\lambda n.\; f(i(n))), \\ \lambda \langle \alg{R}_1, \alg{R}_2, \alg{R}_3 \rangle.\; \lambda \langle \langle f_1, \noprf \rangle, \langle f_2, \noprf \rangle \rangle.\; \langle \lambda x.\; f_2(f_1(x)), \noprf \rangle, \noprf, \lambda \langle A, a \rangle.\; \langle \lambda x.\;x, \noprf \rangle, \noprf \end{array}\right\rangle$
\end{description}
\end{example}

\begin{exercise}
Define a category~$\cat{Mon}_b$ with biased monoids as its objects and biased monoid homomorphisms as its morphisms.
\end{exercise}

\begin{exercise}
Define a category~$\cat{Mon}_u$ with unbiased monoids as its objects and unbiased monoid homomorphisms as its morphisms.
\end{exercise}

\end{document}
