% !TEX root =  ../main.tex
\section{Essential material on category theory}\label{app:background}
Below are fundamental definitions and examples that are instrumental in providing the necessary background on category theory.
For a comprehensive overview of category theory see resources such as \cite{mac2013categories,perrone2024starting}.

\begin{definition}[Category]\label{def:category}
    A category $\mathsf{C}$ consists of
    \begin{squishlist}
        \item A collection $\mathcal{C}_0$ whose elements are called objects of $\mathsf{C}$;
        \item A collection $\mathcal{C}_1$ whose elements are called morphisms of $\mathsf{C}$;
    \end{squishlist}
    such that:
    \begin{squishlist}
        \item Each morphism $f : X \rightarrow Y$ has assigned two objects of the category called source and target, respectively;
        \item Each object $X$ has a distinguished identity morphism $\catidentity_X: X \rightarrow X$;
        \item Given $f: X\rightarrow Y $ and $g:Y\rightarrow Z$, than it exists $g \circ f = h: X \rightarrow Z$.
    \end{squishlist}
    These structures satisfy the following axioms:
    \begin{squishlist}
        \item (Unitality) $\forall f: X \rightarrow Y, \; f \circ \catidentity_X=f \text{ and } \catidentity_Y \circ f = f$;
        \item (Associativity) Given $f$, $g$, and $h$ such that the compositions are defined, then $h \circ (g \circ f) = (h \circ g) \circ f$.
    \end{squishlist}
\end{definition}

\begin{example}
    The following are some notable examples of categories:
    \begin{squishlist}
        \item Indicate with \Poset a partial order set. \Poset can be viewed as the category whose objects are the elements $p \in \mathcal{P}$ and morphisms are order relations $p \leq p^\prime$. Notice that there is at most one morphism between two objects;
        \item \Vect is the category whose objects are real vector spaces and morphisms are linear maps;
        \item \Hilb is the category whose objects are real complete Hilbert spaces, that is, real vector spaces equipped with an inner product structure and closed under the norm topology.
        Morphisms are bounded linear maps $f: X \rightarrow Y$, that is, $\exists \, b \in \reall^+$ such that $\norm{f(x)} \leq b \norm{x}, \; \forall x \in X$. 
        Every morphism $f: X \rightarrow Y$ between Hilbert spaces admits an \emph{adjoint} $f^\star$ such that, $\forall \, x \in X$ and $y \in Y$, $\Eprod{y}{f(x)}{}=\Eprod{f^\star(y)}{x}{}$.
        We also have $(f^\star)^\star=f$.
    \end{squishlist}
\end{example}

Starting from \Cref{def:category} we can define the notion of \emph{subcategory}.

\begin{definition}\label{def:subcategory}
    Given a category $\mathsf{C}$, a subcategory $\mathsf{S}$ of $\mathsf{C}$ consists of the following data:
    \begin{squishlist}
        \item A subcollection $\mathcal{S}_0$ of $\mathcal{C}_0$ such that $\forall \, S, \, \catidentity_S$ is in $\mathsf{S}$;
        \item A subcollection $\mathcal{S}_1$ of $\mathcal{C}_1$ such that $\forall \, f \text{ and } g$ for which the composition is defined in $\mathsf{C}$, the composite $h = g \circ f$ is in $\mathsf{S}$.
    \end{squishlist}
\end{definition}

\begin{example}[\IPVect]\label{ex:IPVect}
The category of real vector spaces with an inner product \IPVect is a subcategory of \Vect. 
Specifically, objects are real vector spaces equipped with an inner product structure.
Morphisms are bounded linear maps $f: X \rightarrow Y$, that is, $\exists \, b \in \reall^+$ such that $\norm{f(x)} \leq b \norm{x}, \; \forall x \in X$. 
Every morphism $f: X \rightarrow Y$ between inner product vector spaces admits an \emph{adjoint} $f^\star$ such that, $\forall \, x \in X$ and $y \in Y$, $\Eprod{y}{f(x)}{}=\Eprod{f^\star(y)}{x}{}$.
We also have $(f^\star)^\star=f$.
\IPVect is similar to \Hilb, the difference is that in \Hilb the vector spaces are also complete.
\end{example}

\begin{definition}[Functor]\label{def:functor}
    Consider $\mathsf{C}$ and $\mathsf{D}$ categories. 
    A functor $F: \mathsf{C} \rightarrow \mathsf{D}$ consists of the following data:
    \begin{squishlist}
        \item For each object $X \in \mathcal{C}_0$, an object $F(X) \in \mathcal{D}_0$;
        \item For each object morphism $\mathcal{C}_1 \ni f: X \rightarrow Y$, a morphism $\mathcal{D}_1 \ni F(f): F(X) \rightarrow F(Y)$;
    \end{squishlist}
    such that the following axioms hold:
    \begin{squishlist}
        \item (Unitality) $\forall X \in \mathcal{C}_0, \; F(\catidentity_X) \!=\! \catidentity_F(X)$. In other words, the identity in $\mathsf{C}$ is mapped into the identity in $\mathsf{D}$.
        \item (Compositionality) $\forall f \text{ and } g \in \mathcal{C}_1$ such that the composition is defined, then $F(g \circ f) = F(g) \circ F(f)$. In other words, the composition in $\mathsf{C}$ is mapped into the composition in $\mathsf{D}$.
    \end{squishlist}
\end{definition}

To ease the notation, in the sequel, we use $F^\sigma$ and $F^f$ to denote $F(\sigma)$ and $F(f)$, respectively.

\begin{definition}[Natural transformation]\label{def:nat_transf}
Consider two categories $\mathsf{C}$ and $\mathsf{D}$, and two functors between them, namely $F: \mathsf{C} \rightarrow \mathsf{D}$ and $G: \mathsf{C} \rightarrow \mathsf{D}$.
A natural transformation $\alpha: F \rightarrow G$ consists of the following data:
\begin{squishlist}
    \item For each object $X \in \mathcal{C}_0$, a morphism $\alpha_{X}: F^X \rightarrow G^X$ in $\mathcal{D}$ called the component of $\alpha$ at $X$;
    \item For each morphism $f: X \rightarrow X^\prime$ in $\mathcal{C}$, the following diagram commutes:
    \begin{equation}
        \begin{tikzcd}[row sep=1.5cm, column sep=1.5cm]
            F^X \arrow[r, "F^f"] \arrow[d, "\alpha_X"'] & F^{X^\prime} \arrow[d, "\alpha_{X^\prime}"] \\
            G^X \arrow[r, "G^f"'] & G^{X^\prime}
        \end{tikzcd}
    \end{equation}
\end{squishlist}
\end{definition}

A natural transformation can be thought of as a consistent system of arrows between two functors.
The \emph{naturality} of $\alpha$ means that it is invariant with respect to maps between the images of two functors.