% !TEX root =  ../main.tex
\section{Examples}\label{app:examples}

This appendix is devoted to provide practical examples about the formalism introduced in \Cref{sec:cat_scm_ck}.
Consider $\myexogenous=\{Z_1, Z_2, Z_3\}$ and $\myendogenous=\{X_1, X_2, X_3\}$ as exogenous and endogenous variables of the following linear SCM with additive noise $\mathsf{M}$:
\begin{equation}\label{eq:linSCM_noni}
\begin{cases}
    X_1 = Z_1 = m_1(Z_1)\, ,\\
    X_2 = c_{21}X_1 + Z_2 = c_{21}Z_1 + Z_2 = m_2(Z_1,Z_2)\, ,\\
    X_3 = c_{32} X_2 + Z_3 = c_{32}c_{21}Z_1 + c_{32}Z_2 +Z_3 = m_3(Z_1,Z_2,Z_3)\,;
\end{cases}    
\end{equation}
where $Z_i \sim N(0,1)$ and $Z_i \perp Z_j$, $i, j \in [3]$ and $i \neq j$.
Additionally, let the probability space associated with the exogenous to be $(\reall^n, \mathcal{B}(\reall^n), N(\zeros_3, \identity_3) )$, where $\mathcal{B}(\reall^n)$ is the Borel $\sigma$-algebra of $\reall^n$.
We can equivalently express $\mathsf{M}$ as $\X=\mixing\Z$, where
\begin{equation}
    \mixing = \begin{bmatrix}
    1 & 0 & 0\\
    c_{21} & 1 & 0\\
    c_{32}c_{21} & c_{32} & 1
    \end{bmatrix}\,.    
\end{equation}
We call the matrix $\mixing$ the mixing matrix.
See Lemma E.1 in \citet{d'acunto2023learning} for a proof of the existence of $\mixing$.

At this point, according to \Cref{def:SCM_meas}, the components of the measure-theoretic \scm{} are:
\emph{(i)} $(\reall^n, \mathcal{B}(\reall^n), N(\zeros_3, \identity_3) )$ for the exogenous;
\emph{(ii)} $\mixing$ as mixing;
and \emph{(iii)} $(\reall^n, \mathcal{B}(\reall^n), N(\zeros, \mixing\mixing^\top))$ for the endogenous.
In detail, the endogenous measure is the pushforward of $N(\zeros, \identity_3)$ given \mixing. 
Using the notation in the paper for pushforward measures, each $X_i$ follows $m_i(\mu(Z_i \cup \myexogenous^{\ancestors_i}))=m_i(N(\zeros,\identity_{|\ancestors_i|+1}))=N(0, [\mixing]_{i,:}[\mixing]_{i,:}^\top)$.

Starting from the measure-theoretic SCM, according to \Cref{def:scm_fun}, the category-theoretic representation of \scm{} is the functor mapping $I$ to $(\reall^n, \mathcal{B}(\reall^n), N(\zeros_3, \identity_3) )$, $I^\prime$ to $(\reall^n, \mathcal{B}(\reall^n), N(\zeros, \mixing\mixing^\top))$, and the arrow between $I$ and $I^\prime$ to \mixing.

At this point, let us consider hard and soft interventions.
Starting with the former, we consider the hard intervention $\mathrm{do}(X_2=c)$.
Accordingly, \Cref{eq:linSCM_noni} becomes
\begin{equation}\label{eq:linSCM_hi}
    \begin{cases}
        X_1 = Z_1 = m_1^\hard(Z_1) \sim N(0,1)\, ,\\
        X_2 = c \quad \text{(constant),} \\
        X_3 = c_{32} c + Z_3 = d + Z_3 = m^\hard_3(Z_3) \sim N(d,1)\,.
    \end{cases}  
\end{equation}
Starting from \Cref{eq:linSCM_hi}, the hard-intervened SCM \scm{\hard} in \SCMcat is the functor mapping $I$ to $(\reall^n, \mathcal{B}(\reall^n), N(\zeros_3, \identity_3) )$, $I^\prime$ to $(\reall^n, \mathcal{B}(\reall^n), N(0, 1) \times \delta_c \times N(d,1))$, and the arrow between $I$ and $I^\prime$ to $\mymixing_\hard=\{m_1^\hard, c ,m_3^\hard\}$. 

Consider now a soft intervention on $X_2$ which modifies $c_{21} \to c_{21}^\soft$.
Recall that we do not consider soft interventions that modify the parent set of the intervened variable.
Accordingly, \Cref{eq:linSCM_noni} becomes
\begin{equation}\label{eq:linSCM_si}
    \begin{cases}
        X_1 = Z_1 = m^\soft_1(Z_1)\, ,\\
        X_2 = c_{21}^\soft X_1 + Z_2 = c_{21}^\soft Z_1 + Z_2 = m^\soft_2(Z_1,Z_2)\, ,\\
        X_3 = c_{32} X_2 + Z_3 = c_{32}c_{21}^\soft Z_1 + c_{32}Z_2 +Z_3 = m^\soft_3(Z_1,Z_2,Z_3)\,;
    \end{cases}
\end{equation}
For convenience, represent $\mymixing_\soft$ as
\begin{equation}
    \mixing_\soft = \begin{bmatrix}
    1 & 0 & 0\\
    c_{21}^\soft & 1 & 0\\
    c_{32}c_{21}^\soft & c_{32} & 1
    \end{bmatrix}\,.    
\end{equation}
At this point, the soft-intervened SCM \scm{\soft} in \SCMcat is the functor mapping $I$ to $(\reall^n, \mathcal{B}(\reall^n), N(\zeros_3, \identity_3) )$, $I^\prime$ to $(\reall^n, \mathcal{B}(\reall^n), N(\zeros, \mixing_\soft \mixing_\soft^\top) )$, and the arrow between $I$ and $I^\prime$ to $\mixing_\soft$.

Finally, we exemplify the category-theoretic representation of the above interventions in \SCMcat.
The inverse $\mymixing^{-1}$ exists by definition of the mixing matrix \mixing itself.
Specifically, it is equal to $\identity_3 - \mathbf{C}$, where $\mathbf{C}$ is the matrix of causal coefficients corresponding to \Cref{eq:linSCM_noni}.
Using \Cref{lem:intervention_prob}, 
in \SCMcat \emph{(i)} the hard intervention corresponds to the natural transformation $\eta^\hard=\langle \catidentity_{(\reall^n, \mathcal{B}(\reall^n), N(\zeros_3, \identity_3) )}, \hard = \mymixing_\hard \circ \mymixing^{-1}\rangle$;
and \emph{(ii)} the soft intervention corresponds to the natural transformation $\eta^\soft=\langle \catidentity_{(\reall^n, \mathcal{B}(\reall^n), N(\zeros_3, \identity_3))}, \soft = \mymixing_\soft \circ \mymixing^{-1}\rangle$.


