\chapter{Theory}
\label{chap:theory}

The approach of using graph theory to model networks is abundant in many areas of sciences, ranging from engineering to biology \cite{network_science_chap1}. From the perspective of machine learning, there exist many graph related tasks, with two common ones being \textit{graph classification} and \textit{node classification} \cite{quadratic_graph_classification, active_learning_node_classification}. In graph classification, the task is to classify a graph as belonging to one of several classes, whilst in node classification the task is to classify each node in the graph individually. These two problems can be generalised to graph and node regression, with the aim of predicting a continuous variable instead of a class. Graph and node classification/regression can be referred to as graph and node prediction.
% From the perspective of machine learning, there exists many applications, with two common ones being \textit{graph classification} and \textit{node classification}
%% TODO TIKZ
% \begin{center}
%     \resizebox {\textwidth} {!} {
%         \input{chapters/images_theory/node_classification.tikz}
%     }
% \end{center}

\begin{figure}[!htbp]
    \centering
        \begin{subfigure}{.5\textwidth}
            \centering
            \includegraphics[width=0.95\linewidth]{chapters/images_theory/graph_classification_v2.png}
            \caption{Graph prediction}
            \label{fig:subject_prediction}
        \end{subfigure}%
        \begin{subfigure}{.5\textwidth}
            \centering
            \includegraphics[width=0.95\linewidth]{chapters/images_theory/population_node_classification.png}
            \caption{Node prediction}
            \label{fig:population_prediction}
        \end{subfigure}
    \caption{Schematic representations of graph and node prediction.}
    \label{fig:graph_and_node_class}
\end{figure}

In the context of neuroscience, graph and node prediction may correspond to predicting some property of a subject, for instance sex or age. Graph prediction is relevant when each subject is associated with a graph, which in this thesis will correspond to functional networks in a subject's brain. A schematic visualisation of graph prediction can be seen in \cref{fig:subject_prediction}. Node prediction is relevant in, for instance, \textit{population graphs}, where each node represents a single subject. See \cref{fig:population_prediction} for a representation of node prediction in population graphs.

% In this chapter, the foundations of graph theory, graph convolutional neural networks and explainability methods will be presented. The chapter begins with a primer on general graph theory, followed by the description of two specific types of graphs, population and multiplex graphs. Next, graph convolutional neural networks will be presented, followed by a black-box analysis methods known as Zorro. The chapter will be concluded with a brief overview of related works regarding GCNs and explainability of AI.

% The remainder of the chapter will present a theoretical background for graphs, graph convolutional neural networks and explaiability for AI. Specifically,

% Graph prediction is relevant when each subject is associated with a graph, and can be schematically visualised in figure \ref{fig:subject_prediction}. An example of such a graph could be the functional networks in a subjects brain.

% In this chapter, the necessary theory of graphs, graph convolutional neural networks and explaiability for AI will be presented.

% The following of this chpter will aim to present necceccary theory for performing maching leaning on graphs, both

% In this thesis, two kinds of graphs will be considered: subject-specific graphs for graph prediction, and population graphs for node prediction. The subject-specific graphs will represent the functional brain networks for each subject, and will be formulated as a specific kind of graph known as a multiplex graph.

\section{General graph theory}
\label{sec:general_graph_theory}

Let $\mathcal{G}$ be a graph, associated with a set of nodes $V$ and a set of edges $E$. The edges form the connections between nodes, and for a pair of nodes $(i,j)$ the corresponding edge may be denoted $e_{ij}$. The neighbours $N(v)$ to a certain node $v \in V$ are defined as the nodes $u \in V$ that are connected to $v$, i.e., $e_{vu} \in E$. Each node $v$ may also be associated with \textit{node features} $x_v$. $x_v$ may represent some state or information about node $v$, which in practice can take the form of a vector of numbers \cite{active_learning_node_classification}.
% in applications typically takes the form of a number, a vector of numbers, or a piece of text etc

A graph $\mathcal{G}$ is considered to be \textit{undirected} if all edges in the graph are undirected, $e_{ij} \equiv e_{ji}$, and \textit{directed} if all edges are directed, $e_{ij} \not\equiv e_{ji}$. The edges in $\mathcal{G}$ may be succinctly summarised in an \textit{adjacency matrix} $A$, defined as
\begin{equation}
    A_{ij} = \begin{cases} \mbox{1,} & \mbox{if } e_{ij} \in E \\ \mbox{0,} & \mbox{otherwise.} \end{cases}
    \label{eq:adjacencydefinition}
\end{equation}
From definition \eqref{eq:adjacencydefinition} it follows that undirected graphs have a symmetric adjacency matrix, $A_{ij} = A_{ji}$. From the adjacency matrix, the degree matrix $D$ is defined as
\begin{equation}
    D_{ij} = \begin{cases} \sum_k A_{ik}, & \mbox{if } i = j \\ \mbox{0,} & \mbox{otherwise,} \end{cases}
    \label{eq:degreematrixdefinition}
\end{equation}
which describes each node's \textit{degree}, i.e., the number of edges connected to each node.

Moreover, each edge in $\mathcal{G}$ may be associated with a weight $w_{ij}$, and $\mathcal{G}$ is then denoted as a \textit{weighted} graph. The adjacency matrix becomes $A_{ij} = w_{ij}$, and the degree matrix now describes the \textit{strength} of each node, which is defined as the sum of the weights of all edges connected to the node. Weights in a weighted graph may be interpreted differently depending on the application \cite{adventures_in_graph_theory_chap1}. They can be seen as the connection strength between devices in a cellular network, the cost of a ticket along a route in a train network, the flow of goods in a logistics setting etc. All graphs referenced in the remainder of this thesis will be weighted and undirected unless otherwise specified.

\section{Population graphs and multiplex graphs}
\label{sec:similarity_measure}

In a population graph, each node corresponds to an individual, and the edges relate all individuals to each other. One way of calculating the weights in a population graph is by using a similarity measure. The similarity measure greatly shapes the resulting population graph, and should be chosen with the specific application in mind. One common approach is to define a similarity measure $\sigma$ as a distance measure $D$ inverted by a kernel $K$. The similarity measure between two data points $x_1$ and $x_2$ may then be written as
\begin{equation}
    \sigma(x_1,x_2) = K \left(D\left(x_1, x_2\right) \right).
    \label{eq:similarity_measure}
\end{equation}

\begin{figure}[!htbp]
    \centering
    \includegraphics[width=0.5\textwidth]{chapters/images_theory/multiplex_graph.png}
    \caption{An example of a two-layered multiplex graph, with the same nodes in each layer but different edges.}
    \label{fig:multiplex_graph}
\end{figure}
Another type of graph, relevant for this thesis, is a multiplex graph. A multiplex graph is a layered graph where each layer can represent a different type of interaction between nodes \cite{multiplex_book_chap2}. One example of a multiplex graph with the same nodes in all layers is a graph with cities as nodes and different means of transportation as edges. Edges representing highways and railways make up two different graphs, but they might be combined into a multiplex graph since they share the same nodes, i.e., the cities. See \cref{fig:multiplex_graph} for a visual representation of a two-layered multiplex graph, in which the nodes are fixed, but the edges are different in each layer.

\section{Graph Convolutional Networks}
\label{sec:gcn}

\acrlong{gcn}s (\acrshort{gcn}) are a class of neural networks that generalise the notion of convolutions from grid data to graph structured data \cite{wu_review}. Regular convolutional operations operate on structured grids of data, for instance the pixels in an image, where each grid point is only connected to its adjacent neighbours. This may not be the case for graph structured data, where any pair of nodes can be connected. Generalising the convolutional operator to the graph domain enables a \acrshort{gcn} to utilise information about the graph structure, in the same way a \acrshort{cnn} can utilise information about structures in e.g. an image \cite{wu_review}.

The theoretical foundations for \acrshort{gcn}s will be explained in three parts. First, the concept of convolutions in the graph domain, and how they are implemented in a computationally efficient manner. Then, a layer-wise propagation rule for a graph convolutional layer based on the implementation of convolutions, and finally a heuristic interpretation known as \textit{message passing}.

\subsection{Efficient convolutions in the graph domain}

Let $\mathcal{G}$ be an undirected graph, with $N$ nodes and adjacency matrix $A$. The graph Laplacian $L$ is defined as $L=D-A$, and may be normalized according to
\begin{equation}
    L_\text{norm} = D^{-1/2} L D^{-1/2} =  I_N - D^{-1/2} A D^{-1/2},
    \label{eq:normalized_graph_laplacian}
\end{equation}
where $I_N$ is the $N \times N$ identity matrix. With $L = L_{\text{norm}}$, the convolution of a signal $x \in R^N$ defined on the nodes of $\mathcal{G}$ with a filter $g_\theta = \text{diag}(\theta)$ parametrized by $\theta \in R^N$, can in the Fourier domain be written as
\begin{equation}
    g_\theta * x = U g_\theta U^T x,
    \label{eq:graph_convolution}
\end{equation}
where $U$ is an orthogonal matrix containing the eigenvectors of $L$ \cite{kipf_semi_supervised}. Performing convolutions using Equation \eqref{eq:graph_convolution} may, however, be computationally intractable in practice, partly because multiplication with $U$ is $\mathcal{O}(N^2)$, and partly because calculating $U$ requires the eigendecomposition of $L$, which may be very computationally expensive for large graphs \cite{kipf_semi_supervised}. Kipf et al. \cite{kipf_semi_supervised} proposes a solution to this problem, in which the convolution is approximated with an expansion in Chebyshev polynomials $T_k(x)$, as,
\begin{equation}
    g_{\theta'} * x \approx \sum_{k=0}^K \theta'_k T_k(\tilde{L})x,
    \label{eq:convolution_approximation}
\end{equation}
where $\tilde{L} =  \frac{2}{\lambda_{\text{max}}}L - I_N$, and $\lambda_{\text{max}}$ is the largest eigenvalue of $L$. $\theta'_k$ is here a vector of Chebyshev coefficients, which in the context of machine learning corresponds to trainable parameters. The interpretation of Equation \eqref{eq:convolution_approximation} is that the convolution is $K^{\text{th}}$ order local, i.e. that a convolution considers each node and its $K^{\text{th}}$ order neighbors, the neighbours that are at most $K$ steps away in the graph.

\subsection{Layer-wise propagation rule}
By setting $K = 1$ and a single trainable parameter $\theta = \theta_0' = -\theta_1'$, the convolution in Equation \eqref{eq:convolution_approximation} can be further simplified as
\begin{equation}
    g_{\theta'} * x \approx \theta \left(I_N + D^{-1/2}AD^{-1/2} \right)x,
    \label{eq:k1_approximation_step3}
\end{equation}
\cite{kipf_semi_supervised}. Setting $K=1$ limits the convolution to only consider a node ($k=0$) and its closest neighbours ($k=1$). Implementing convolutions as in Equation \eqref{eq:k1_approximation_step3} may, however, lead to exploding or vanishing gradients, since the eigenvalues of $I_N + D^{-1/2}AD^{-1/2}$ lies in the range $[0, 2]$. This problem can be avoided using a \textit{renormalization trick}:
\begin{equation}
    I_N + D^{-1/2}AD^{-1/2} \rightarrow \tilde{D}^{-1/2} \tilde{A} \tilde{D}^{-1/2},
    \label{eq:renormalization_trick}
\end{equation}
where $\tilde{A} = A + I_N$ and $\tilde{D} = \sum_j \tilde{A}_{ij}$.

The convolutional operation may now be generalized to a signal $X \in \mathbb{R}^{N \times C}$, defined on the $N$ nodes of the graph and with a $C$-dimensional feature vector for each node. The signal $X$ thus has $C$ input channels. Furthermore, let the convolution apply $F$ filters to the $C$ input channels. The application of such a convolution can then be written
\begin{equation}
    Z = \tilde{D}^{-1/2} \tilde{A} \tilde{D}^{-1/2} X \Theta,
    \label{eq:propagation_rule}
\end{equation}
with $\Theta \in \mathbb{R}^{C\times F}$ being a matrix of filter parameters and $Z \in \mathbb{R}^{N\times F}$ being the convolved signal. This propagation rule in Equation \eqref{eq:propagation_rule}, when paired with an activation function $\sigma$ such that $H = \sigma\left(Z \right)$, defines a graph convolutional layer.

Recall that, in order to arrive at Equation \eqref{eq:propagation_rule}, the Chebyshev polynomial expansion in Equation \eqref{eq:convolution_approximation} was truncated at $K=1$. By truncating the Chebyshev polynomial, the convolution operator only considers each node and its closest neighbours, and becomes a linear function in $L$. These two points may seem to be limitations in the representational strength of the graph convolutional layer, however, this is not necessarily the case \cite{kipf_semi_supervised}. Firstly, larger neighbourhoods can be convolved over by stacking multiple layers, with the first layer considering a node and its neghbours, the second layer considering the neighbours' neighbours and so on. Secondly, keeping the convolutional operator linear in $L$ actually makes it more flexible, since it is not dependant on the explicit parametrization given by the Chebyshev polynomials \cite{kipf_semi_supervised}. Combined, a deep \acrshort{gcn} consisting of several stacked graph convolutional layers, paired with possibly non-linear activation functions $\sigma$, can still model a rich class of convolutional filter functions, whilst keeping the computational costs low.

\subsection{Message passing interpretation of GCNs}
\label{subsec:message_passing}

\begin{figure}[!htbp]
    \centering
    \includegraphics[width=0.5\linewidth]{chapters/images_theory/message_passing_v2.png}
    \caption{A schematic representation of the message passing interpretation of a graph convolutional layer. The messages $h_{ij}$ are sent from node $j$ to node $i$.}
    \label{fig:message_passing}
\end{figure}

Heuristically, a graph convolutional layer can be seen to perform a sort of \textit{message passing}, in that each node receives messages (aggregates features) from all of its closest neighbours. This can be seen by studying the propagation rule in Equation \eqref{eq:propagation_rule} for a single node $i$, a single feature channel $C=1$ and a single filter channel $F=1$, and explicitly rewriting it as a sum:
\begin{equation}
\begin{split}
    z_i &= \theta \left(\left(\tilde{D}^{-1/2} \tilde{A} \tilde{D}^{-1/2}\right)_{ii} x_{i} + \sum_{j \neq i} \left(\tilde{D}^{-1/2} \tilde{A} \tilde{D}^{-1/2}\right)_{ij} x_{j} \right) \\
    &=
    \theta \left(h_{ii} + \sum_{j \neq i} h_{ij} \right).
\end{split}
\end{equation}
$z_i$ and $x_i$ corresponds to the activation and feature for node $i$, respectively. $h_{ij}$ can be interpreted as a normalised message, communicating the state $x_j$ weighted by the normalised connection between node $j$ and $i$. The activation $z_i$ can then be seen as an aggregation of normalised messages from all neighbouring nodes, $h_{ij}$, and itself, $h_{ii}$. See \cref{fig:message_passing} for a visual representation of how the messages are passed to node $i$ from it's neighbours. In this manner information can flow through the graph, and by stacking multiple graph convolutional layers the information can spread over successively larger neighbourhoods. With the message passing interpretation, a deep \acrshort{gcn} can be seen to draw upon the informational flow patterns in the graph. This enables it to learn from the graph structure, similarly to how a deep \acrshort{cnn} can extract information from structures in an image.

\section{Zorro -- an algorithm for saliency mappings in GCNs}
\label{sec:zorro}
% To describe the Zorro algorithm

Zorro is an algorithm for determining which nodes and features are important for a trained \acrshort{gcn} model performing node classification on a graph with adjacency matrix $A$ and feature matrix $X$ \cite{zorro}. The model is denoted $\Phi_n(X,A)$ and takes $A$ and $X$ as input, and gives a prediction for a node $n$ in the graph. The general idea is to replace the feature matrix $X$ by noise and then reintroduce nodes and features to successively make the model prediction similar to the original. The reintroduced nodes $V$ and features $F$ are referred to as an explanation $\mathcal{S} = \{V, F\}$. The noisy signal $Y_{\mathcal{S}}$ is obtained by applying noise to $X$ through element-wise multiplication with a masking matrix $S$, representing $\mathcal{S}$, and a matrix of random noise $Z$, according to
\begin{equation}
    Y_\mathcal{S} = X \odot S + Z \odot (1 - S), \quad Z \sim \mathcal{N}.
\end{equation}
$1$ is a matrix of ones, $\odot$ represents element-wise multiplication and the noise distribution $\mathcal{N}$ is chosen to match the distribution of features over the nodes, i.e, the distribution of $X$. The prediction of the model $\Phi$ on the masked data is then $\Phi_n(Y_{\mathcal{S}}, A)$. To evaluate an explanation $\mathcal{S}$, i.e., if the unmasked nodes and features are important for the prediction of a specific node, the fidelity of the explanation is calculated as
\begin{equation}
    \mathcal{F}(\mathcal{S}) = \mathbb{E}_{Y_{\mathcal{S}}|Z\sim\mathcal{N}}\left[\mathbbm{1}_{\Phi_n(X,A) = \Phi_n(Y_{\mathcal{S}},A)}\right].
    \label{eq:Ys}
\end{equation}
The fidelity of an explanation is a measure of how likely it is for a model with a noisy signal $Y_{\mathcal{S}}$ to give the same prediction as a model with the original signal $X$.

For each node $n$, the algorithm begins with an empty explanation $S_n = \{\emptyset, \emptyset\}$, and thus a completely random input signal according to Equation \eqref{eq:Ys}. Then, the node or feature that increases the fidelity of the explanation the most is added to the explanation. Nodes and features are iteratively added in this manner until the fidelity of the explanation exceeds a hyperparameter $\tau$. The resulting explanation indicates which nodes and features were important to make the prediction for node $n$, yielding a saliency map detailing the importance of each node. The algorithm can then be repeated for all the nodes in the graph.

\section{Similar works: the intersection of GCNs and neuroscience}

% Ta upp relaterade arbeten och knyt ihop med introduction inför metoden. E.g. Jansson sandström, stankeviciute.

There have been numerous papers published in the last few years applying graph neural networks in neuroscience, with similar aims as that of this thesis; to develop accurate classifiers for brain age and sex prediction, and analyse them using saliency mapping techniques. For age prediction, notable works include Stankevičiūtė et al. \cite{stankeviciute} and Amoroso et al. \cite{amoroso_multiplex_age}, which both utilise structural \acrshort{mri} data. Stankevičiūtė et al. apply \acrshort{gcn}s to a population graph of subjects, and Amoroso et al. use an \acrshort{ann} with graph measures as input features to predict age. The problem of sex prediction is approached in Arslan et al. \cite{arslan}, who use \acrshort{gcn}s, and in the work by Kim and Ye \cite{understanding_gnn}, who use a variant of \acrshort{gnn} known as \acrshort{gin}s. Both of these studies apply their models to \acrshort{rs-fmri} data. Furthermore, \cite{arslan} and \cite{understanding_gnn} also analyse the gradients within the models, with the goal of identifying which functional brain networks are related to biological sex.

There are three main differences that sets this thesis apart from the work in \cite{stankeviciute, amoroso_multiplex_age, arslan, understanding_gnn}. Firstly, resting-state \acrshort{fmri} data is used for age prediction. Secondly, relevant functional brain networks for age prediction are investigated. Finally, saliency maps of the relevant functional brain networks are obtained using methods that only considers the input-output behaviour of the models.


\documentclass{article}
\usepackage{amsmath,amsthm,amssymb}
\title{Uniform estimates for fourier restriction to complex polynomial curves in $\mathbb{R^d}$}
\author{Jaume de Dios Pont}
\newtheorem{thm}{Theorem}
\newtheorem{defi}{Definition}

\begin{document}
	\maketitle

	\abstract{
		This is the first instance of a uniform optimal estimate (not including the endpoint) for families of surfaces of dimension>1. On the other hand, they are still on the specific $d|cod$, which seems to be easier.
	}
	\section{Introduction}
	\begin{thm}
		For each $N,d$ and $(p,q)$ satisfying:

		\begin{equation}
			p' = \frac{d(d+1)}{2} q, \;\; q> \frac{d^2+d+2}{d^2+d}
		\end{equation}

		there is a constant $C_{N,d,p}$ such that for all polynomials $\gamma: \mathbb C \to \mathbb C^d$ of degree up to $N$ we have:

		\begin{equation}
			\|\hat f\|_{L^q(d\lambda_\gamma)} \le C_{N,d,p} \|f\|_{L^q(dx)}
		\end{equation}
		for all Schwartz functions $f$.
	\end{thm}

	We will instead prove the dual problem, showing boundedness of the adjoint (extension) operator $\mathcal E_\gamma$.

\section{Uniform Local restriction}

\begin{defi}
	For a polynomial $\gamma: \mathbb C \to \mathbb C^d$ we define $$L_\gamma(z) := \det(\gamma'(z), \gamma^{(2)}(z), \dots,\gamma^{d}(z))$$ $$J_\gamma(z_1, \dots , z_d) = \det(\gamma'(z_1), \dots, \gamma'(z_d))$$
\end{defi}

In this section we will prove the following result:

\begin{thm}
	Fix $d>2$, $N$, and a feasible $(p,q)$ pair. For every triangular set $S\subset \mathbb C^d$ and every degree $N$ polynomial $\gamma: \mathbb C \to \mathbb C^d$ satisfying:

	\begin{equation}
		0 < C_1 \le \Re \, L_\gamma(z)
	\end{equation}

	\begin{equation}
		|L_\gamma(z)| \le C_2 < \infty
	\end{equation}
	in S we have the extension estimate:

	\begin{equation}
		\|\mathcal E_\gamma \|_{L^q} \le C_{d,N, \frac {C_1}{C_2}}\|f\|_{L^p(d\lambda_\gamma)}
	\end{equation}
\end{thm}

Without loss of generality, we can split in a controlled number of triangles, and assume $C_1 = \frac 1 2$, $C_2=2$.

\section{$\epsilon-$aligned sets, $\epsilon-$aligned functions} % (fold)
\label{sec:section_name}

The main idea of the paper is to uniformly partition

\begin{defi}[$\epsilon-$aligned set] We say that a list $S = (z_1, .. z_n)$ is $\epsilon-$aligned in a direction $s \in C\setminus 0$ if $\arg{(s^{-1}(z_i-z_j))} \in [-\pi +\epsilon,\pi -\epsilon]$ whenever\footnote{we use the convention $\arg(0) = 0$} $i<j$. (or, equivalently, whenever $j=i+1$). Given a list $s$ let $A_\epsilon(S)$ be the set of $s$ such that $S$ is $\epsilon$-aligned with respect to $s$
\end{defi}

\begin{defi} ()
	Given two lists $S = (z_1, \dots z_n)$, $T=(w_1, \dots w_{n+1})$ we say $T> S$ if $w_i$ is a real convex combination of $z_i,z_i+1$. We extend the relationship by transitivity to arbitrary tuples.
\end{defi}

Now, it is an easy to see that that $S>T$ implies that $A_\epsilon(S) \subseteq A_\epsilon(T)$.\\

\textbf{Decomposition procedure D1'}

There exists a decomposition of a rational function $m(z)$onto $O_{\epsilon, N}(1)$ convex sets $C_i$, such that there exists $w_i, c_i \in \mathbb C$, $n_i \in \mathbb N$, such that on each $c_i$:

\begin{equation}
	\frac{p(z)}{w_i(z-c_i)^n} \in B(1,\epsilon)
\end{equation}

Using this lemma, \\

\textbf{Partition for injectivity:}

Let $P(x) = (x-x_i)^k_i$. Do $\epsilon$ partitions for the jacobian and all the involved polynomials and their derivatives. Assume you are in one of the $\epsilon-$regions where the Jacobian does not vanish first. You can write

\section{Uncoordinated polynomials} % (fold)
\label{sec:uncoordinated_polynomials}

In this section we will study functions that $\epsilon-$look like polynomials (in the sense above), and whose derivatives also $\epsilon-$look like polynomials.

Note that $P =_\epsilon Q$ in $D$ does not imply $P'=_\epsilon Q$ in $D$

Want to solve: $\sigma_M(\vec x) = \sum M(x_i) = 0$

$$d\Sigma_M = \frac 1 {K!} V(x_i)$$

$p(z) = z^p$

$z' = - p z^{p-1} p(z) = -p z$

% section uncoordinated_polynomials (end)

% section section_name (end)
\end{document}


\documentclass{beamer}
%
% Choose how your presentation looks.
%
% For more themes, color themes and font themes, see:
% http://deic.uab.es/~iblanes/beamer_gallery/index_by_theme.html
%
\mode<presentation>
{
  \usetheme{default}      % or try Darmstadt, Madrid, Warsaw, ...
  \usecolortheme{default} % or try albatross, beaver, crane, ...
  \usefonttheme{default}  % or try serif, structurebold, ...
  \setbeamertemplate{navigation symbols}{}
  \setbeamertemplate{caption}[numbered]
  \setbeamertemplate{footline}[frame number]
  \setbeamertemplate{itemize items}[circle]
  \setbeamertemplate{theorems}[numbered]
  \setbeamercolor*{structure}{bg=white,fg=blue}
  \setbeamerfont{block title}{size=\normalsize}
}

% \newtheorem{proposition}[theorem]{Proposition}
% \theoremstyle{definition}
% \newtheorem{algorithm}[theorem]{Algorithm}
% \newtheorem{idea}[theorem]{Idea}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{aligned-overset}
\usepackage{alltt}
\usepackage{amsmath}
\usepackage{csquotes}
% \usepackage{multicol}
% \usepackage{stmaryrd}
\usepackage{tabularx}

% \renewcommand\tabularxcolumn[1]{m{#1}}
% \newcolumntype{R}{>{\raggedleft\arraybackslash}X}=

\newcommand\logeq{\mathrel{\vcentcolon\Leftrightarrow}}
\def\code#1{\texttt{\frenchspacing#1}}
\def\padding{\vspace{0.5cm}}
\def\spadding{\vspace{0.25cm}}
\def\b{\textcolor{blue}}
\def\r{\textcolor{red}}
\def\g#1{{\usebeamercolor[fg]{block title example}{#1}}}

% fix for \pause in align
\makeatletter
\let\save@measuring@true\measuring@true
\def\measuring@true{%
  \save@measuring@true
  \def\beamer@sortzero##1{\beamer@ifnextcharospec{\beamer@sortzeroread{##1}}{}}%
  \def\beamer@sortzeroread##1<##2>{}%
  \def\beamer@finalnospec{}%
}
\makeatother

\title[Theoretical Computer Science]{Theoretical Computer Science \\ Languages and Grammars}
\author{Jonas Hübotter}
\date{}

\begin{document}

\begin{frame}
  \titlepage
\end{frame}

\begin{frame}{Outline}
 \tableofcontents[subsectionstyle=hide, subsubsectionstyle=hide]
\end{frame}
% \AtBeginSection[]
%   {
%      \begin{frame}[allowframebreaks]{Plan}
%      \tableofcontents[currentsection, sectionstyle=show/hide, hideothersubsections]
%      \end{frame}
%   }

\section{Formal Languages}

\begin{frame}{Formal Languages}
    \begin{definition}
        \begin{itemize}
            \item The \b{alphabet} $\Sigma$ is a finite set of symbols.\pause
            \item A finite sequence of symbols is called a \b{word}.\pause
            \item $\epsilon$ is the \b{empty word}.\pause
            \item $\Sigma^*$ is the set of all words over an alphabet $\Sigma$.\pause
            \item $L \subseteq \Sigma^*$ is called a \b{(formal) language}.
        \end{itemize}.
    \end{definition}\pause
    \begin{definition}[Operations on words]
        \begin{itemize}
            \item $|w|$ is the \b{length} of word $w$.\pause
            \item $uv$ is the \b{concatenation} of two words $u, v$.\pause
            \item $w^0 = \epsilon, w^{n+1} = ww^n$ defines \b{repetition} of a word $w$.
        \end{itemize}
    \end{definition}
\end{frame}

\begin{frame}{Operations on Formal Languages}
    \begin{definition}
        Let $A$ and $B$ be formal languages.
        \begin{itemize}
            \item $AB = \{uv \mid u \in A, v \in B\}$ (\b{concatenation}).\pause
            \item $A^0 = \{\epsilon\}, A^{n+1} = AA^n$ (\b{repetition}).\pause
            \item $A^* = \bigcup_{n \in \mathbb{N}_0} A^n$ (\b{reflexive transitive closure}).\pause
            \item $A^+ = AA^* = \bigcup_{n \in \mathbb{N}} A^n$ (\b{transitive closure}).
        \end{itemize}.
    \end{definition}
\end{frame}

\section{Grammars}

\begin{frame}{Grammars}
    \begin{definition}
        A \b{grammar} is a 4-tuple $G = (V, \Sigma, P, S)$\pause where
        \begin{itemize}
            \item $V$ is a finite set of \b{non-terminals} (or \b{variables})\pause;
            \item $\Sigma$ is an alphabet whose symbols are called \b{terminals}\pause;
            \item $P \subseteq (V \cup \Sigma)^* \times (V \cup \Sigma)^*$ is a set of \b{productions}\pause; and
            \item $S \in V$ is the \b{initial variable}.
        \end{itemize}
    \end{definition}
\end{frame}

\begin{frame}{Grammars}
    \begin{definition}[Derivation]
        A grammar induces a \b{derivation relation} $\rightarrow_G$ on words over $V \cup \Sigma$:\pause
        \begin{align*}
            &\forall \alpha, \alpha' \in (V \cup \Sigma)^*.\ \alpha \rightarrow_G \alpha' \logeq \exists \beta \to \beta' \in P.\\
            &\alpha = \alpha_1\beta\alpha_2 \text{ and } \alpha' = \alpha_1\beta'\alpha_2.
        \end{align*}\pause
        A \b{derivation} of $\alpha_n$ from $\alpha_1$ is denoted by $\alpha_1 \rightarrow_G \dots \rightarrow_G \alpha_n$.
    \end{definition}\pause
    \begin{definition}[Language of a Grammar]
        Given the derivation of $\alpha_n$ from $\alpha_1$, $G$ \b{produces} $\alpha_n$ if $\alpha_1 = S$ and $\alpha_n \in \Sigma^*$.\pause\par
        The \b{language} of $G$ $L(G)$ is the set of all words produced by $G$.
    \end{definition}
\end{frame}

\section{Chomsky-Hierarchy}

\begin{frame}{Chomsky-Hierarchy}
    \begin{definition}
        A grammar $G$ is of\pause
        \begin{itemize}
            \item \b{Type 0} always;\pause
            \item \b{Type 1 (context-sensitive)} $\forall \alpha \to \beta \in P\setminus\{S \to \epsilon\}.\ |\alpha| \leq |\beta|$;\pause
            \item \b{Type 2 (context-free)} if of type 1 and $\forall \alpha \to \beta \in P.\ \alpha \in V$;\pause
            \item \b{Type 3 (right-linear)} if of type 2 and $\forall \alpha \to \beta \in P\setminus\{S \to \epsilon\}.\ \beta \in \Sigma \cup \Sigma V$.
        \end{itemize}
    \end{definition}
\end{frame}

\section{Word problem}

\begin{frame}{Word problem}
    \begin{block}{Word Problem}
        given: a grammar $G$, a word $w \in \Sigma^*$\par
        problem: $w \in L(G)$?
    \end{block}\pause\padding
    Automata are used to solve the word problem. Depending on the type of the grammar different automata are used.\par
    For example, (Non-)Deterministic Finite Automata are used for right-linear grammars (regular languages) while Pushdown Automata are used for context-free grammars.
\end{frame}

\end{document}


\documentclass[italian, 12pt, reqno]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

% Stylistic points.
\usepackage{geometry}
\geometry{
  a4paper,
  right=2.5cm,
  left=2.5cm,
  top=2.5cm,
  bottom=2.5cm,
  %showframe,
}

\usepackage{mathpazo} % Math Palatino font.

% Links and references.
\usepackage{xcolor}
\definecolor{Myblue}{rgb}{0,0,0.6}
\usepackage[a4paper,colorlinks,citecolor=Myblue,linkcolor=Myblue,urlcolor=Myblue,pdfpagemode=None]{hyperref}

% Necessities for math.
\usepackage{amsmath, amscd, amssymb, mathrsfs, accents, amsfonts, amsthm}

\newtheoremstyle{myteo}{\topsep}{\topsep}
	{}
	{}
	{\bfseries}
        {.}
	{2pt}
	{\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
\theoremstyle{myteo}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{notation}[theorem]{Notation}

\numberwithin{equation}{section}

\usepackage{tikz}
\usetikzlibrary{cd}
\usetikzlibrary{fadings}

% Figures stuff.
\usepackage{caption}
\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}

% Lists stuff.
\usepackage{enumitem}
\setenumerate{label=(\arabic*)}

% Commands.
\newcommand{\cat}[1]{\mathscr{#1}}
\newcommand{\dual}[1]{#1^{\text{op}}}
\newcommand{\aut}{\text{Aut}}
\newcommand{\gset}{\text{\textbf{GSet}}}
\newcommand{\set}{\text{\textbf{Set}}}
\newcommand{\tgset}{\text{\textbf{GSet}}^t}
\newcommand{\fix}[1]{\text{Fix}(#1)}
\newcommand{\homs}[2]{[#1, #2]}
\newcommand{\fun}[3]{#1\colon#2\to #3}
\newcommand{\nonamefundef}[4]{\begin{align*}
                             \begin{tikzcd}[sep=large]#1\end{tikzcd} &\longrightarrow \begin{tikzcd}[sep=large]#2\end{tikzcd}\\
                             \begin{tikzcd}[sep=large]#3\end{tikzcd} &\longmapsto \begin{tikzcd}[sep=large]#4\end{tikzcd}
                           \end{align*}}
\newcommand{\fundef}[5]{\begin{align*}
                             #1\colon\begin{tikzcd}[sep=large]#2\end{tikzcd} &\longrightarrow \begin{tikzcd}[sep=large]#3\end{tikzcd}\\
                             \begin{tikzcd}[sep=large]#4\end{tikzcd} &\longmapsto \begin{tikzcd}[sep=large]#5\end{tikzcd}
\end{align*}}

% Operators
\DeclareMathOperator{\im}{im}

\begin{document}
\title{Grothendieck's Galois Theory}
\author{Gabriele Rastello}
\maketitle

\tableofcontents

\section{Introduction}
\label{sec:introduction}
The Fundamental Theorem of Galois Theory is an old and profound result of field theory.
In modern terms it establishes a one-to-one correspondence between the subextensions of a finite Galois extension of a field and the subgroups of the Galois group of that extension.
A statement and a "classical" proof of this theorem can be found in \cite{lang}.

Another similar result, this time in algebraic topology, is the Fundamental Theorem of Covering Theory.
This theorems states the existence of a one-to-one correspondence between subgroups of the fundamental group and path-connected covering spaces of a path-connected topological space.

The two statements, at least on an intuitive level, have something in common.
Intrigued by this curious fact and moved by a belief that this is no coincidence Grothen\-dieck was able to prove a theorem (here Theorem \ref{theo:galois}) that has both of them as consequences; thus unifying the matter\footnote{It is noteworthy to say that Grothendieck went even further than that and was able to prove an even more general theorem that, even for the classical case of fields, yields results that weren't previously known. However, we will stick to the base case here; the interested reader can check \cite{edo} section IV and V.}.
In this pages we will explore Grothendieck's approach following closely section III of \cite{edo}, but with some added details (mostly confined in the appendix).

The reader is assumed to have a basic knowledge of category theory (categories, functors, natural transformations, adjoint functors, some (co)limits) and of group actions (mostly about transitive actions).
We use the notation \(H\leq G\) to indicate that \(H\) is a subgroup of \(G\) and \([-,-]\) for the hom-set \(\cat{C}(-, -)\).

\section{Group actions and adjunctions}
\label{sec:1}

\begin{definition}
  \label{def:strit_epi}
  In a category \(\cat{C}\) an arrow \(\fun{f}{X}{Y}\) is a \textbf{strict epimorphism} if it is the joint coequalizer of all the pairs of arrows it coequalizes.
  This means that any arrow \(\fun{g}{X}{Z}\) such that \(g\circ x = g\circ y\) for all \(\fun{x,y}{C}{X}\) such that \(f\circ x = f\circ y\) there exists a unique arrow \(\fun{h}{Y}{Z}\) such that \(h\circ f = g\).
  Refer to Figure \ref{diagram:strict_epi}.
\end{definition}

\begin{figure}[h]
  \begin{center}
    \begin{tikzcd}[sep=huge]
      C \ar[r, shift right=1, "x"'] \ar[r, shift left=1, "y"] & X \ar[r, "f"] \ar[dr, "g"] & Y \ar[d, dashed, "h"]\\
      & & Z
    \end{tikzcd}
  \end{center}
  \caption{}
  \label{diagram:strict_epi}
\end{figure}

\begin{remark}
  \label{rem:strict_epi}
  Strict epimorphisms are epimorphisms, as the name implies.
\end{remark}

\begin{remark}
  \label{rem:strict_epi_plus_mono}
  If an arrow is both a strict epimorphism and a monomorphism then it is an isomorphism.
\end{remark}

\begin{definition}
  \label{def:action}
  Let \(H\) be a group, \(A\) an object of \(\cat{C}\) and \(G = \aut(A)\) the group of automorphisms of \(A\) in \(\cat{C}\) i.e. the group whose underlying set is the set of isomorphisms of type \(A\to A\) of \(\cat{C}\) and whose operation is composition in \(\cat{C}\).
  An \textbf{action} of \(H\) on \(A\) is a group homomorphism \(H \to G\).
\end{definition}

\begin{notation}
  \label{not:action}
	Given an action of a group \(H\) on an object \(A\) of \(\cat{C}\) we denote, with a slight abuse of notation, the automorphism of \(A\) associated to \(h\in H\) with \(h\) as well.
\end{notation}

\begin{definition}
  \label{def:quotient}
  If \(H\) acts on \(A\) as defined in \ref{def:action} we define the quotient of \(A\) by \(H\) in \(\cat{C}\) to be an element \(A/H\) of \(\cat{C}\) equipped with an arrow \(\fun{q}{A}{A/H}\) such that:
  \begin{enumerate}
  \item for all \(h\in H\) we have \(q\circ h = q\),
  \item for any \(\fun{x}{A}{X}\) such that \(x\circ h = x\) for all \(h\in H\) there exists a unique arrow \(\fun{\varphi}{A/H}{X}\) such that \(x = \varphi\circ q\).
  \end{enumerate}
  See also Figure \ref{diagram:quotient}.
\end{definition}

\begin{remark}
  \label{rem:uniqueness_of_quotient}
  Quotients are defined by a universal property, thus are unique up to unique isomorphism and we can speak of ``the'' quotient of \(A\) by \(H\) instead of ``a'' quotient of \(A\) by \(H\).
\end{remark}

\begin{notation}
  \label{not:quotient}
  Sometimes we use the sentence ``the quotient of \(A\) by \(H\)'' to refer to the object \(A/H\), some others to the arrow \(\fun{q}{A}{A/H}\); the context should be enough to differentiate between the two.
\end{notation}

\begin{figure}[h]
  \begin{center}
    \begin{tikzcd}[sep=huge]
      A \ar[loop left, "h"] \ar[r, "q"] \ar[rd, "x"] & A/H \ar[d, "\varphi"]\\
      & X
    \end{tikzcd}
  \end{center}
  \caption{}
  \label{diagram:quotient}
\end{figure}

\begin{remark}
  \label{rem:quotient_are_strict_epi}
  Consider a quotient \(\fun{q}{A}{A/H}\); by condition (1) above \(q\circ h = q = q\circ 1_A\) so \(q\) coequalizes all the pairs \((h, 1_A)\), for \(h\in H\).
  If another arrow \(\fun{x}{A}{X}\) coequalizes all the pairs that \(q\) does then this arrow is such that \(x\circ h = x\circ 1_A = x\) for all \(h\in H\) and thus, by condition (2), we have a unique factorization \(x = \varphi\circ q\).
  This proves that all quotients are strict epimorphisms.
\end{remark}

\begin{notation}
  Let \(G\) be a group, then with \(\gset\) we denote the category of \(G\)-sets and \(G\)-invariant maps.
\end{notation}

\begin{remark}
  \label{rem:transitive_actions}
  Consider \(\gset\).
  The underlying set of \(G\) (that we also denote with \(G\)) is a G-set with the action given by left multiplication; we call this the \textbf{canonical action} of \(G\) on itself.
  Let \(\fun{\varphi}{G}{E}\) be a G-invariant map; it is easy to see that such a \(\varphi\), by virtue of being G-invariant, is determined uniquely by the value \(\varphi(e)\), where \(e\) is the neutral element of \(G\).

  Let now \(E\) be a transitive G-set i.e. such that \(E/G = \{*\}\) in \(\set\)\footnote{This states that the set of orbits of \(E\) is a singleton that is of course the case if and only if \(E\) is transitive.}.
  Fix an \(x\in E\) and let \(\varphi\) be the G-invariant map defined by \(\varphi(e) = x\); we argue that \(\fun{\varphi}{G}{E}\) makes \(E\) into a quotient of \(G\) by the subgroup
  \[H = \fix{x} = \{g\in G\colon g\cdot x = x\}.\]
  Indeed by using the definition of \(H\) and the fact that \(\varphi\) is G-invariant we have
  \[(\varphi\circ h)(e) = \varphi(h\cdot e) = h\cdot\varphi(e) = h\cdot x = x.\]
  for all \(h\in H\).
  Moreover let \(\fun{g}{G}{F}\) satisfy (1) of Definition \ref{def:quotient}; as we discussed above \(g\) is entirely determined by the image of \(e\) so we obtain (2) defining an arrow \(\fun{f}{E}{F}\) by \(f(x) = g(e)\).
  The situation is depicted in Figure \ref{diagram:transitive_actions}.

  Finally: \(G\) is a transitive G-set and so is every \(G/H\) with \(H\leq G\) and the action defined again by left multiplication (on cosets) so an object \(E\in\gset\) is transitive if and only if it is isomorphic to some \(G/H\).
\end{remark}

\begin{figure}
  \begin{center}
    \begin{tikzcd}[sep=huge]
      G \ar[loop left, "h"] \ar[dr, "g"] \ar[r, "\varphi"] & E \cong G/H \ar[d, dashed, "f"]\\
      & F
    \end{tikzcd}
  \end{center}
  \caption{}
  \label{diagram:transitive_actions}
\end{figure}

For the rest of the section fix a category \(\cat{C}\), an object \(A\in\cat{C}\) and let \(G = \aut(A)\).

\begin{remark}
  \label{prop:action_hom_set}
  Consider a subgroup \(H\leq G\) and an object \(X\in\cat{C}\). \(H\) acts on the hom-set \([A, X]\) as follows\footnote{Since an action as of Definition \ref{def:action} is a map that sends elements of a group to arrows it is, in this case, equivalent to give the definition of an action by uncurrying.}:
  \nonamefundef{H\times [A, X]}{[A, X]}{(h, x)}{h\cdot x = x \circ h.}
\end{remark}

\begin{remark}
  \label{rem:hom_functor}
  Assume that the action \(G\times [A, X] \to [A, X]\) is transitive and let \(\tgset\) be the category of transitive \(G\)-sets (a subcategory of \(Gset\)).
  Then we have a functor
  \fundef{[A, -]_G}{\cat{C}}{\tgset}{X \ar[d, "f"] \\ Y}{\homs{A}{X}_G \ar[d, "f_*"] \\ \homs{A}{Y}_G}
  where we indicate with \(\homs{A}{X}_G\) the hom-set \([A, X]\) upon which \(G\) acts as described in Proposition \ref{prop:action_hom_set} and \(f_*\) is post-composition with \(f\).
  It is easy to check that \(f_*\) is indeed \(G\)-invariant.
\end{remark}

\begin{remark}
  \label{rem:adjoints}
  Consider an object \(E\in\tgset\), pick an element \(x_0\in E\) and let \(H = \fix{x_0}\leq G\) (the choice of \(x_0\) is irrelevant as \(E\) is transitive).
  Moreover assume that \(\cat{C}\) has quotients of \(A\) by any subgroup of \(G\).

  By what we observed in Remark \ref{rem:transitive_actions} we have a bijection between elements of \(E\) and arrows of type \(G\to E\).
  Consider then \(f\in\homs{A}{X}_G\) and its corresponding arrow \(\fun{\varphi}{G}{\homs{A}{X}_G}\); we claim that \(f\) factors through \(A/H\) if and only if \(\varphi\) factors through \(E \cong G/H\) (see Figure \ref{diagram:bijection}).
  Indeed \(f\) factors if and only if \(f\circ h = f\) for all \(h\in H\), by using the fact that \(\varphi\) is \(G\)-invariant we obtain
  \[\varphi(h\cdot e) = h\cdot\varphi(e) = h\cdot f = f\circ h = f\]
  and, since \(\varphi\) is uniquely determined by \(\varphi(e)\),  \(\varphi\circ h =\varphi\) for all \(h\in H\); this happens if and only if \(\varphi\) factors through \(E\cong G/H\).

  This gives us, for each \(X\in\cat{C}\) and \(E\in\tgset\), a bijection
  \[[A/H, X] \cong \tgset(E, [A, X]_G)\tag{\(*\)}\]
  natural in \(X\) in \(E\) (see Section \ref{sec:appendixes}).

	Provided that \(\cat{C}\) has quotients of \(A\) by subgroups of \(G\) we can define a functor \(A\times_G -\) from \(\tgset\) to \(\cat{C}\) by setting \(A\times_G E = A/H\) for \(H=\text{Fix}(x_0)\) and \(x_0\in E\) as above.
	The behaviour of \(A\times_G-\) on arrows is defined as follows.
	Let \(\fun{f}{E\cong G/H}{F\cong G/H'}\) be an arrow in \(\tgset\) with \(H=\text{Fix}(x_0), H'=\text{Fix}(f(x_0))\) and \(x_0\in E\).
	Notice that for all \(h\in H\) we have \(f(h\cdot x_0) = f(x_0)\) by definition of \(H\) and \(f(h\cdot x_0) = h\cdot f(x_0)\) by \(G\)-invariance of \(f\); thus \(H\leq H'\).
	This means that if \(\fun{q}{A}{A/H}\) and \(\fun{q'}{A}{A/H'}\) are the quotients in \(\cat{C}\) there is a unique arrow \(\fun{\tilde{f}}{A/H}{A/H'}\) such that \(q' = \tilde{f}\circ q\); we set \(A\times_G f = \tilde{f}\).

	Finally the naturality of the bijection \((*)\) now indicates that we have an adjunction
  \[A\times_G - \dashv \homs{A}{-}_G.\]
\end{remark}

\begin{figure}[h]
  \begin{center}
    \begin{tikzcd}[sep=huge]
      A \ar[loop left, "h"] \ar[r, ""] \ar[dr, "f"] & A/H \ar[d, dashed, ""]\\
      & X
    \end{tikzcd}\hspace{2cm}
    \begin{tikzcd}[sep=huge]
      G \ar[loop left, "h"] \ar[r, ""] \ar[dr, "\varphi"] & E\cong G/H \ar[d, dashed, ""]\\
      & \homs{A}{X}_G
    \end{tikzcd}
  \end{center}
  \caption{}
  \label{diagram:bijection}
\end{figure}

Our main problem will be that of finding conditions on \(\cat{C}\) that make this adjunction into an equivalence of categories.

\section{Categorial axiomatization of Galois Theory}
\label{sec:axioms}

Through this section fix a category \(\cat{C}\) and an object \(A\in\cat{C}\).

\begin{definition}
  \label{def:axioms}
  We define the following axioms.
  \begin{enumerate}
  \item For every \(X\in\cat{C}\) there is at least a map of type \(A\to X\) and all maps \(A\to X\) are strict epimorphisms.
  \item For any subgroup \(H\leq \aut(A)\) the quotient \(\fun{q}{A}{A/H}\) exists and is preserved by \(\fun{\homs{A}{-}}{\cat{C}}{\gset}\).
  \item Every endomorphism of \(A\) is an isomorphism i.e. \(\homs{A}{A} = \aut(A)\).
  \end{enumerate}
\end{definition}

\begin{remark}
  \label{rem:all_strict_epi}
  It is known that if \(f\circ g\) is a strict epimorphism then so is \(f\).
  Thus it follows from Axiom (1) that every arrow \(X\to Y\) in \(\cat{C}\) is a strict epimorphism.
\end{remark}

\begin{proposition}
  \label{prop:hom_is_faithful}
  Axiom (1) implies that \(\homs{A}{-}\) is faithful, reflects monomorphisms and isomorphisms.
\end{proposition}

\begin{proof}
  Consider arrows \(\fun{f,g}{X}{Y}\in\cat{C}\) such that \(\homs{A}{f} = \homs{A}{g}\); that is \(f_* = g_*\).
  By Axiom (1) let \(\fun{h}{A}{X}\) be a third arrow of \(\cat{C}\) then we have \(f_*(h) = g_*(h)\) i.e. \(f\circ h = g\circ h\).
  Again by Axiom (1) \(h\) is an epimorphism (really, a strong one) and thus we obtain \(f = g\); that is: \(\homs{A}{-}\) is faithful.

  It is well known that every faithful functor reflects monomorphisms.
  Because of this if \(f\in\gset\) is an isomorphism and \(g\in\cat{C}\) is such that \(\homs{A}{g} = f\) then \(g\) is a monomorphism too; but, as an arrow of \(\cat{C}\), \(g\) is also a strict epimorphism and thus an isomorphism.
\end{proof}

\begin{remark}
  \label{rem:axiom1}
  Consider \(H\leq G\) and the quotient \(\fun{q}{A}{A/H}\) in \(\cat{C}\), then \(\fun{q_*}{\homs{A}{A}}{\homs{A}{A/H}}\) in \(\gset\) is a quotient too because quotients are preserved by \(\homs{A}{-}\) (Axiom (2)).
	Thus we have \(\homs{A}{A}/H \cong \homs{A}{A/H}\), and the diagram in Figure \ref{diagram:eta} commutes (where \(\rho\) is a quotient arrow and \(\eta\) the isomorphism).

  \begin{figure}
    \begin{center}
      \begin{tikzcd}[sep=huge]
        \homs{A}{A} \ar[r, "\rho"] \ar[rr, bend left, "q_*"] & \homs{A}{A}/H \ar[r, "\eta"] & \homs{A}{A/H}
      \end{tikzcd}
    \end{center}
    \caption{}
    \label{diagram:eta}
  \end{figure}

	Isomorphisms in \(\gset\) are bijections so:
  \begin{enumerate}
  \item[(i)] for \(f, g\in \homs{A}{A}\) if \(q\circ f = q\circ g\) then there is some \(h\in H\) such that \(f = h\circ g\),
  \item[(ii)] for all \(\fun{x}{A}{A/H}\) there is an arrow \(f\in\homs{A}{A}\) such that \(q\circ f = x\).
  \end{enumerate}
  Moreover, under Axiom (3), (i) implies the following:
  \begin{enumerate}
  \item[(iii)] \(q\circ f = q\) implies \(f\in H\).
  \end{enumerate}
  Indeed by taking \(g = 1_A\) in (i) we obtain that \(f = h\) for some \(h\in H\).
\end{remark}

\begin{remark}
  \label{rem:axiom2}
	Consider an arrow \(\fun{x}{A}{X}\) and the epi-mono factorization \(x_* = \psi\circ \rho\)\footnote{We recall that \(\gset\) is a topos and, as such, has epi-mono factorization. The interested reader can find evidence of both facts in \cite{topi}.}.
  With reference to the diagram below Axiom (3) implies that \(I = \homs{A}{A}/H\) with \(H = \fix{x}\leq G\).

  \begin{center}
    \begin{tikzcd}[sep=huge]
      \homs{A}{A} \ar[rr, bend left, "x_*"] \ar[r, "\rho"] & I \ar[r, "\psi"] & \homs{A}{X}
    \end{tikzcd}
  \end{center}

	Indeed by Axiom (3) \(\homs{A}{A} = G\) so an arrow from \(\homs{A}{A}\) is determined by its behaviour on \(1_A\).
	Now
	\[(\psi\circ\rho\circ h)(1_A) = x_*(1_A\circ h) = x\circ h = x = x_*(1_A) = (\psi\circ\rho)(1_A)\]
  that is \(\psi\circ\rho\circ h = \psi\circ\rho\) which, by monicness of \(\psi\), implies \(\rho\circ h = \rho\).
	This makes \(\rho\) into a quotient.
\end{remark}

\begin{proposition}
  \label{prop:epsilon_iso}
  Any arrow \(\fun{x}{A}{X}\) of \(\cat{C}\) is a quotient of \(A\) by \(H = \fix{x}\leq G\) (with respect to the action on \(\homs{A}{X}\) described in Remark \ref{prop:action_hom_set}) i.e. \(X = A/H\).
\end{proposition}

\begin{proof}
	By choosing \(H = \fix{x}\) we get \(x\circ h = x\) for all \(h\in H\) and thus there is a unique arrow \(\fun{\varepsilon}{A/H}{X}\) of \(\cat{C}\) such that \(x = \varepsilon\circ q\), where \(\fun{q}{A}{A/H}\) is the quotient of \(A\) by \(H\) (see Figure \ref{diagram:varepsilon}).
  \begin{figure}
    \begin{center}
      \begin{tikzcd}[sep=huge]
        A \ar[rr, bend left, "x"] \ar[r, "q"] & A/H \ar[r, "\varepsilon"] & X
      \end{tikzcd}.
    \end{center}
    \caption{}
    \label{diagram:varepsilon}
  \end{figure}
	\begin{figure}
    \begin{center}
      \begin{tikzcd}[sep=huge]
        \homs{A}{A} \ar[rr, bend left, "x_*"] \ar[r, "q_*"] \ar[dr, bend right, "\rho"] & \homs{A}{A/H} \ar[r, "\varepsilon_*"] & \homs{A}{X}\\
        & \homs{A}{A}/H \ar[u, "\eta"] \ar[ru, bend right, "\psi"] &
      \end{tikzcd}
    \end{center}
    \caption{}
    \label{diagram:big_diagram}
  \end{figure}

	By applying \(\homs{A}{-}\) we obtain Figure \ref{diagram:big_diagram} where \(\rho, \psi\) and \(\eta\) are as discussed before.
  We have
  \[\varepsilon_*\circ \eta\circ\rho = \varepsilon_*\circ q_* = x_* = \psi\circ \rho\]
  that by epicness of \(\rho\) implies \(\varepsilon_*\circ \eta = \psi\).
  Now \(\varepsilon_*\) must be monic since \(\psi\) and \(\eta\) are; but this, by Proposition \ref{prop:hom_is_faithful}, implies that \(\varepsilon\in\cat{C}\) is monic too.
  Being an arrow of \(\cat{C}\), by Axiom (i), \(\varepsilon\) is also a strict epimorphism and thus an isomorphism.
\end{proof}

\begin{proposition}
  \label{prop:transitive_action}
  The action of \(\text{Aut}(A)\) on \(\homs{A}{X}\) is transitive for all \(X\in\cat{C}\).
\end{proposition}

\begin{proof}
  Consider again Figure \ref{diagram:big_diagram}.
  We proved that \(\varepsilon\) is an isomorphism and thus \(\varepsilon_*\) must be one too.
  Moreover from Remark \ref{rem:axiom1} we know \(\eta\) is iso too and so we have \(\homs{A}{X}\cong \homs{A}{A}/H\), but by Axiom (3) \(\homs{A}{A} = \text{Aut}(A)\) and so we have that \(\homs{A}{X}\) is transitive.
  %% From Proposition \ref{prop:epsilon_iso} given \(\fun{x}{A}{X}\in\cat{C}\) we have \(X\cong A/H\) with \(H = \text{Fix}(x) \leq \text{Aut}(A)\).
  %% By Axiom (2) \(\homs{A}{A/H} \cong \homs{A}{A}/H\) and finally, via Axiom (3), \(\homs{A}{X} \cong \text{Aut}(A)/H\), a transitive \(\text{Aut}(A)\)-set.
\end{proof}

\begin{theorem}
  \label{theo:galois}
  Given a category \(\cat{C}\) and an object \(A\in\cat{C}\) such that Axioms (1), (2) and (3) hold there exists an adjunction
  \[A\times_G- \dashv \homs{A}{-}_G\]
  where \(G = \text{Aut}(A)\) such that the maps
  \[\fun{\eta}{E\cong \homs{A}{A}/H}{\homs{A}{A/H}}\]
  \[\fun{\varepsilon}{A/H}{X}\]
  are isomorphisms.
  This establishes an equivalence of categories between \(\cat{C}\) and \(\tgset\).
\end{theorem}

\begin{proof}
  The existence of the adjunction follows from the discussion in Section \ref{sec:1}, the fact that \(\eta\) and \(\varepsilon\) are (the components of) the unit and counit of the adjunction is a calculation that has been moved to the appendix and the fact that they are isomorphisms follows respectively from Remark \ref{rem:axiom1} and Proposition \ref{prop:epsilon_iso}.
\end{proof}

\section{Conclusion}
\label{sec:conclusion}
Let \(k\) be a field and \(E\) a finite Galois extension of \(k\).
Let \(\cat{C}\) be the opposite category of the category of subextensions of \(E\) (with arrows restricted to the field homomorphisms that fix the base field \(k\)) then it is possible to prove that \(\cat{C}\) satisfies Axioms (1), (2) and (3) with \(A=E\).
Indeed:
\begin{itemize}
	\item Axiom (3) is trivially satisfied and \(G = \text{Aut}(A, A)\) is the Galois group of \(E\),
	\item Axiom (2) is satisfied as one can check that, for each \(H\leq G\) the fixed field
		\[E^H = \{x\in E\colon \forall h\in H\ h(x) = x\}\]
		is the quotient of \(E\) by \(H\) in \(\cat{C}\)\footnote{If we prefer to work in the original category of subextensions (not in the dual) this means that \(E^H\) is the coquotient of \(E\) by \(H\).},
	\item Axiom (1) is satisfied because in the category of subextensions of \(E\) every object has an arrow to \(E\) and every such arrow is a strict monomorphism.
\end{itemize}
We can then apply Theorem \ref{theo:galois} to obtain that \(\cat{C}\) and \(\tgset\) are equivalent.
The correspondence of Galois can then be retrieved by associating to each \(F\in\cat{C}\) the subgroup \(H\leq G\) such that the transitive \(G\)-set \(G/H\) is precisely the \(G\)-set associated to \(F\) by the equivalence above.

Theorem \ref{theo:galois} can also be used to give alternative proofs of other well-known results (such as the correspondence between subgroups of the fundamental group and path-connected covering spaces of a path-connected topological space) that intuitively share some similarities with the case of Galois Theory.
Indeed the most beautiful part about this theorem is that, through its very abstract nature, is able to clearly identify, capture and unify these "intuitive similarities" that different pieces of mathematics posses\footnote{Arguably this is the goal of category theory as a whole, making this particular theorem into a quintessential example.}.

\section{Appendix}
\label{sec:appendixes}

\subsection{Naturality of \(\homs{A/H}{X} \cong \tgset(E, \homs{A}{X}_G)\)}
Fix a category \(\cat{C}\), an element \(A\in\cat{C}\) and let \(G = \aut(A)\).
Let's indicate with \(\psi_{EX}\) the bijection between \(\homs{A/H}{X}\) and \(\tgset(E, \homs{A}{X}_G)\) described in Remark \ref{rem:adjoints}; we shall prove that it is natural in both \(X\in\cat{C}\) and \(E\in\tgset\).

\begin{proof}[Naturality in \(X\)]
  \label{proof:naturality_in_X}
  Given an arrow \(\fun{f}{X}{Y}\) of \(\cat{C}\) we want to prove that the \(\psi_{EX}\) are the components of a natural transformation \(\homs{A/H}{-}\Rightarrow \tgset(E, \homs{A}{-}_G)\) i.e that the following diagram commutes.
  \begin{center}
    \begin{tikzcd}[sep=huge]
      \homs{A/H}{X} \ar[r, "\psi_{EX}"] \ar[d, "f_*"] & \tgset(E, \homs{A}{X}_G) \ar[d, "(f_*)_*"] \\
      \homs{A/H}{Y} \ar[r, "\psi_{EY}"] & \tgset(E, \homs{A}{Y}_G)
    \end{tikzcd}
  \end{center}
  Recall that here \(H = \fix{x_0}\) for \(x_0\in E\).
  Pick any \(x\in \homs{A/H}{X}\) and let \(\fun{q}{A}{A/H}\) be the quotient arrow (the quotient exists because \(\cat{C}\) is assumed to have all quotients by subgroups of \(G\)); then chasing \(x\) through the diagram down the two possible ways yields two arrows in \(\tgset\) of type \(E\to\homs{A}{Y}_G\).
  Since \(E\) is transitive arrows out of \(E\) are determined uniquely by the image of \(x_0\); keeping this in mind the following computations show that the square commutes.
  \[((f_*)_*\circ \psi_{EX})(x)(x_0) = (f_*\circ \psi_{EX}(x))(x_0) = f_*(\psi_{EX}(x)(x_0)) = f_*(x\circ q) = f\circ x\circ q\]
  \[(\psi_{EY}\circ f_*)(x)(x_0) = \psi_{EX}(f\circ x)(x_0) = f\circ x\circ q\]
\end{proof}

\begin{proof}[Naturality in \(E\)]
  \label{proof:naturality_in_E}
  We want to prove that the \(\psi_{EX}\) are the components of a natural transformation \(\homs{A/-}{X}\Rightarrow\tgset(-, \homs{A}{X}_G)\).
	Given \(\fun{f}{E\cong G/H}{F\cong G/H'}\) with \(H=\text{Fix}(x_0), H'=\text{Fix}(f(x_0)), x_0\in E\), using the notation \(\tilde{f} = A\times_G f\) (see Remark \ref{rem:adjoints}), we show the naturality of the following square.
  \begin{center}
    \begin{tikzcd}[sep=huge]
      \homs{A/H}{X} \ar[r, "\psi_{EX}"] & \tgset(E, \homs{A}{X}_G) \\
      \homs{A/H'}{X} \ar[r, "\psi_{FX}"] \ar[u, "\widetilde{f}^*"] & \gset(F, \homs{A}{X}_G) \ar[u, "f^*"]
    \end{tikzcd}
  \end{center}
  As before we chase an \(x\in\homs{A/H'}{X}\) down the two possible paths to get two arrows of type \(E\to\homs{A}{X}_G\) and prove that they are the same by evaluating them on \(x_0\in E\):
  \[(\psi_{EX}\circ \widetilde{f}^*)(x)(x_0) = \psi_{EX}(x\circ \widetilde{f})(x_0) = x\circ \widetilde{f}\circ q = x\circ q',\]
  \[(f^*\circ \psi_{FX})(x)(x_0) = (\psi_{FX}(x)\circ f)(x_0) = \psi_{FX}(x)(f(x_0)) = x\circ q'.\]
\end{proof}

\subsection{\(\eta\) and \(\varepsilon\) are the unit and counit of \(A\times_G- \dashv \homs{A}{-}_G\)}

\begin{proof}[\(\eta\) is the unit]
  Our adjunction is given by the bijection
  \[\psi\colon\cat{C}(A\times_G E, X)\cong\tgset(E, \homs{A}{X}_G)\]
  natural in \(X\in\cat{C}\) and \(E\in\tgset\).
  To obtain the unit we set \(X = A\times_G E\):
  \[\cat{C}(A\times_G E, A\times_G E)\cong\tgset(E, \homs{A}{A\times_G E}_G)\]
  and so
  \[\cat{C}(A/H, A/H)\cong\tgset(E, \homs{A}{A/H}_G)\]
  where \(H = \text{Fix}(x)\leq G\) (\(x\in E\)) by definition of \(A\times_G E\).
  Now (the component at \(E\) of) the unit is given by the image of \(1_{A/H}\) under this bijection.
  By the discussion in Section \ref{sec:1} if \(\fun{q}{A}{A/H}\) is the quotient arrow in \(\cat{C}\) then \(\psi(1_{A/H})\) is the map \(E\cong\homs{A}{A}_G/H \to \homs{A}{A/H}_G\) of \(\tgset\) that factors the map \(G\to E\) that sends \(e\) to \(q\).
  But this last map is \(q^*\) as in Figure \ref{diagram:eta}.
\end{proof}

\begin{proof}[\(\varepsilon\) is the counit]
  Keeping the proof above in mind we set \(E = \homs{A}{X}\) and obtain
  \[\psi\colon \cat{C}(A\times_G\homs{A}{X}, X) \cong \tgset(\homs{A}{X}_G, \homs{A}{X}_G)\]
  that becomes
  \[\cat{C}(A/H, X) \cong \tgset(\homs{A}{X}_G, \homs{A}{X}_G)\]
  with \(H = \text{Fix}(x)\) for some \(x\in\homs{A}{X}\).
  Notice that since \(\homs{A}{X}\cong G/H\) by Proposition \ref{prop:transitive_action} we can consider \(1_{\homs{A}{X}}\) as a map of type \(G/H \to \homs{A}{X}\) such that \(1_{\homs{A}{X}}(e) = x\) (this can be obtained by chasing \(1_A\) around Figure \ref{diagram:big_diagram}) there is iso).
  Now we have that \(\psi^{-1}(1_{\homs{A}{X}})\) is the arrow \(A/H\to X\) of \(\cat{C}\) that factorizes \(x\) i.e. \(\psi^{-1}(1_{\homs{A}{X}}) = \varepsilon\) as in Figure \ref{diagram:varepsilon}.
\end{proof}

\begin{thebibliography}{1}
\bibitem{edo}
	E.J. Dubuc, C. Sanchez de la Vega,
  \textit{On the Galois Theory of Grothendieck},
  \href{https://arxiv.org/abs/math/0009145}{arXiv:math/0009145},
  2007.
\bibitem{catwork}
  Saunders Mac Lane,
  \textit{Categories for the Working Mathematician},
  Springer,
  second edition,
  1997.
\bibitem{lang}
  Serge Lang,
  \textit{Algebra},
  Springer - Graduate Texts in Mathematics,
  revised third edition,
  2005.
\bibitem{topi}
  Robert Goldblatt,
  \textit{Topoi - the categorical analysis of logic},
  Dover,
  revised edition,
  2006.
\end{thebibliography}
\end{document}


\documentclass[12.5pt]{scrartcl}
\usepackage[sexy]{evan}
\usepackage{fullpage}
\usepackage{amsmath, amsfonts}
\usepackage{biblatex}

\addbibresource{refs.bib}

\author{Gaurav Arya}
\title{Functional Queues}

\usepackage{url}

\DeclareMathOperator{\INS}{\mathtt{INS}}
\DeclareMathOperator{\POP}{\mathtt{POP}}
\DeclareMathOperator{\HEAD}{\mathtt{HEAD}}
\DeclareMathOperator{\opsleft}{\mathtt{ops\_left}}
\DeclareMathOperator{\n}{\mathtt{n}}
\DeclareMathOperator{\dd}{\mathtt{d}}
\DeclareMathOperator{\Q}{\mathtt{Q}}

\begin{document}

\maketitle

\section{Functional data structures}

A functional data structure can never be modified. Instead, when performing an operation, a new copy of the data structure is returned. This implies a property called \emph{full persistence}: previous versions of the data structure remain accessible forever, and we can perform operations on any version we choose.

\section{Functional stacks}

A functional stack is probably the simplest example of a functional data structure. It consists solely of a pointer to the head of a one-way linked list, which contains the stack’s elements from top to bottom. To push, we add a new element to the one-way linked list, and return the pointer to this new element. To pop, we return a pointer to the second element of the linked list.

\section{What about a functional queue?}

Functional queues are a natural next step. Ideally, we would like to implement them with a constant number of changes per enqueue/dequeue. This turns out to be much harder than for stacks! But there is a solution: using our functional stacks as a black box, we can simulate each queue operation using a constant number of operations on a set of six stacks. The primary goal of our visualizer is to show these operations in action, and how they come together to make a functional queue.

\section{Outline of functional queue implementation}

\subsection{Overview}

We will represent our functional queue $\Q$ by a tuple $(\INS, \POP, \POP_{rev}, \POP_2, \INS_2,\HEAD, \n, \opsleft)$. Here, $\INS$, $\POP$, $\POP_{rev}$, $\POP_2$, $\INS_2$ and $\HEAD$ are functional stacks, and $\n$ and $\opsleft$ are integers. When $\Q$ is created, all stacks are empty.

Broadly speaking, our queue $\Q$ works by maintaing a stack $\INS$ that contains the most recently added elements of $\Q$, and a stack $\POP$ that contains the remaining elements. $\INS$ keeps more recently added elements higher, whereas $\POP$ keeps less recently added elements higher. Thus, $\INS$ will allow for easy insertions into our queue, while $\POP$ will allow for easy pops from our queue.

At any moment, $\Q$ is either in ``normal mode" or ``transfer mode". In normal mode, $\Q$ maintains the invariants above, and does not worry about the other stacks: inserted elements are placed into $\INS$\footnote{as a special case, however, when an element is inserted into an empty queue we place it directly into $\POP$.}, and deletions pop from $\POP$. In normal mode, operations are clearly $O(1)$, and as long as $\POP$ is non-empty these operations will be valid.

However, if the size $\n$ of $\INS$ becomes equal to the size of $\POP$, $\Q$ will switch into transfer mode for the next $2\n - \dd$ operations, where $\dd \geq 0$ is the number of deletions that occur during the transfer mode. At the end of transfer mode, all elements of $\INS$ will be moved into $\POP$. We now describe how this happens.

\subsection{Transfer Mode}

\subsubsection{Initializing} To begin, $\HEAD$ points to the top of the $\POP$ stack, and $\POP_{rev}$, $\POP_2$, and $\INS_2$ are empty. We set $\opsleft$ to $2\n$, which will keep track of how many operations are left in transfer mode.

\subsubsection{Passive operations} The following happens independent of the operation type. We always reduce $\opsleft$ by 1. For the first $n$ operations of transfer mode, we will:
\begin{itemize}
	\item Pop an element from $\POP$ and add it into $\POP_{rev}$.
	\item Pop an element from $\INS$ and add it into $\POP_2$.
\end{itemize}
For the next $\n - \dd$ operations of transfer mode, we will pop an element from $\POP_{rev}$ and add it into $\POP_2$. We are able to tell when transfer mode ends by checking when $\opsleft$ is 0. Note that since we stop after $\n-\dd$ operations, we do not copy elements of $\POP_{rev}$ into $\POP_2$ if they have been deleted.

\subsubsection{Insertion} We simply place the element into $\INS_2$.

\subsubsection{Deletion} First, we reduce $\opsleft$ by 1. Then, we move the $\HEAD$ pointer down by one (apply the tail operation to the stack it points to), and return the value it points to. Note that there can be at most $\n$ deletions before termination of transfer mode, and hence that we can always apply the tail operation.

\subsubsection{Cleanup} At the end of transfer mode, $\POP_2$ has become the amalgation of the original $\INS$ and $\POP$, with elements in decreasing order of recency, as desired. Meanwhile, $\INS_2$ has collected all the elements that have been inserted during transfer mode. So we simply assign $\POP$ to $\POP_2$ and $\INS$ to $\INS_2$, and return to normal mode. Note that transfer mode lasts for $2\n - \dd$ operations, and when it ends $\POP$ has size $2\n - \dd$. Thus, after transfer mode ends, the size of $\INS$ cannot exceed the size of $\POP$. This justifies our assumption that during normal mode $\INS$ has size at most the size of $\POP$, and that transfer mode is triggered when $\INS$ grows in size to become equal in size to $\POP$.

\nocite{hood}

\printbibliography

\end{document}


\subsection{Innovative task: Minimum Spanning Tree}
\subsubsection{Proof of Correctness}
In order to verify the correctness of our implementation, we first run our algorithm on tiny synthetic graph with 10 nodes and 17 edges. We verified the result is correct. Then we compare our implementation against MATLAB's implementation of Minimum Spanning Tree and we get identical result for output of both implementation.

\subsubsection{Experiment on Large datasets}
Since MST algorithm require that graph is fully connected, weighted, and undirected. We can barely find such graph in Konect and SNAP project. Therefore, we generate synthetic graph of different size. We plot the runtime against graph size (number of nodes) in Figure \ref{mst:fig}. We find the run time grows near-quadratically as the number of nodes in graph. This is identical to the time complexity of Prim's Algorithm, which is $O(N^2)$.

\begin{figure}[!htbf]
\begin{center}
     \includegraphics[width=0.8\textwidth]{FIG/mst.png}
\caption{MST runtime plot}
\label{mst:fig}
\end{center}
\end{figure}


\begin{landscape}
\chapter{Checking of Guarded Recursion: Proofs}
\label{app:check-guard-recurs}
\newcommand{\inCE}[1]{$CE \vdash$ #1}

\begin{figure}[h]
\begin{prooftree}
\AxiomC{(1)}
\AxiomC{}
\UnaryInfC{\inCE{$Nat : Type$}}
\RightLabel{App}
\BinaryInfC{\inCE{$ (_g::) Nat : Nat \to \later^\kappa_1 \onk{Stream}\ Nat \to
    \onk{Stream}\ Nat$}}
\AxiomC{}
\RightLabel{Var}
\UnaryInfC{\inCE{$ Z : Nat$}}
\RightLabel{App}
\BinaryInfC{\inCE{$ (_g::)\,Nat\,Z \  : \later ^\kappa_1  \onk{Stream}\,Nat \to \onk{Stream}\,Nat$}}
\AxiomC{}
\RightLabel{Var}
\UnaryInfC{\inCE{$_gzeros : \forall \kappa . \onk{Stream}\ Nat$}}
\RightLabel{$Ref_{\causal}$}
\UnaryInfC{\inCE{$\onk{Next}\,
  _gzeros[\kappa] : \later ^\kappa_1  \onk{Stream}\,Nat$}}
\RightLabel{App}
\BinaryInfC{\inCE{$  \,(_g::)\,Nat\,Z\,(\onk{Next}\,
  _gzeros[\kappa]) : Stream^\kappa \,Nat$}}
\end{prooftree}

\begin{prooftree}
\AxiomC{}
\LeftLabel{(1)}
\RightLabel{Var$_{1_\open}$}
\UnaryInfC{\inCE{$(_g::) : (a : Type) \to a \to \later \kappa_1 \onk{Stream}\ a \to
    \onk{Stream}\ a$}}
\end{prooftree}

$CE = _gzeros;\ \causal;\ \open; \ \Gamma,Z : Nat,\ _gzeros
: \forallk{Stream} Nat,\ (_g::) : (a : Type) \to a \to \later \kappa_1 \onk{Stream}\ a \to
    \onk{Stream}\ a$

  \caption{Checking of zeros.}
  \label{fig:check_zeros}
\end{figure}

\newpage

\begin{figure}[h]
  \begin{prooftree}
\AxiomC{}

\RightLabel{Var$_{1_\open}$}
\UnaryInfC{\inCE{$(_g::) : (a : Type) \to a \to \later \kappa_1 \onk{Stream}\ a \to
    \onk{Stream}\ a$}}
\AxiomC{}
\UnaryInfC{\inCE{$Nat : Type$}}
\RightLabel{App}
\BinaryInfC{\inCE{$ (_g::) Nat : Nat \to \later \kappa_1 \onk{Stream}\ Nat \to
    \onk{Stream}\ Nat$}}
\AxiomC{}
\RightLabel{Var}
\UnaryInfC{\inCE{$ Z : Nat$}}
\RightLabel{App}
\BinaryInfC{\inCE{$ (_g::)\,Nat\,Z \  : \later ^\kappa_1  \onk{Stream}\,Nat \to \onk{Stream}\,Nat$}}
\AxiomC{(1)}
\RightLabel{App}
\BinaryInfC{\inCE{$(_g::)\,Nat\,Z\,(\onk{Next} ((\, _gmap[\kappa])\ Nat \ Nat\,S) \tensor^\kappa_1
  \,(\onk{Next}(\, _gnats[\kappa]))) : \onk{Stream}\ Nat$}}
  \end{prooftree}

  \begin{prooftree}
    \AxiomC{(2)}
    \AxiomC{}
\RightLabel{Var}
\UnaryInfC{\inCE{$S : Nat \to Nat$}}
\RightLabel{App}
\BinaryInfC{\inCE{$(\, _gmap[\kappa])\ Nat\ Nat\ S : \onk{Stream}\ Nat \to
    \onk{Stream}\ Nat$}}
\RightLabel{$I_{\onk{Next}}$}
\UnaryInfC{\inCE{$\onk{Next} ((\, _gmap[\kappa])\ Nat\ Nat\ S) : \later^\kappa_1 (\onk{Stream}\ Nat \to \onk{Stream}\ Nat)$}}
\AxiomC{}
\RightLabel{Var}
\UnaryInfC{\inCE{$_gnats : \forall \kappa . \onk{Stream}\ Nat$}}
\RightLabel{$Rec_{\causal}$}
\UnaryInfC{\inCE{$(\onk{Next}(\, _gnats[\kappa])) : \onk{Stream}\ Nat$}}
\LeftLabel{(1)}
\RightLabel{$I_{\tensorkappan}$}
\BinaryInfC{\inCE{$    \,\onk{Next} ((\, _gmap[\kappa])\ Nat \ Nat\,S) \tensor^\kappa_1 \,(\onk{Next}(\, _gnats[\kappa])) :
    \later^\kappa_1 Stream^\kappa \,Nat$}}
  \end{prooftree}

  \begin{prooftree}
\AxiomC{(3)}
\AxiomC{}
\UnaryInfC{\inCE{$Nat : Type$}}
\RightLabel{App}
    \BinaryInfC{\inCE{$(\, _gmap[\kappa])\ Nat : (b : Type) \to (Nat \to b) \to
        \onk{Stream}\ Nat \to \onk{Stream}\ b$}}
\AxiomC{}
\UnaryInfC{\inCE{$Nat : Type$}}
\RightLabel{App}
\LeftLabel{(2)}
    \BinaryInfC{\inCE{$(\, _gmap[\kappa])\ Nat\ Nat : (Nat \to Nat) \to \onk{Stream}\ Nat \to \onk{Stream}\ Nat$}}
  \end{prooftree}

  \begin{prooftree}
\AxiomC{}
\RightLabel{Var}
    \UnaryInfC{\inCE{$\ _gmap : \forall \kappa.((a : Type) \to (b : Type) \to
        (a \to b) \to \onk{Stream}\ a \to \onk{Stream}\ b)$}}
\RightLabel{$I_{[\kappa]}$}
\LeftLabel{(3)}
    \UnaryInfC{\inCE{$\, _gmap[\kappa] : (a : Type) \to (b : Type) \to (a \to b) \to \onk{Stream}\ a \to \onk{Stream}\ b$}}
  \end{prooftree}

$CE =\ _gnats;\ \causal;\ \open; \ \Gamma,Z : Nat,\ _gnats :
\forallk{Stream} Nat, \ _gmap : \forall \kappa.((a : Type) \to (b : Type) \to
        (a \to b) \to \onk{Stream}\ a \to \onk{Stream}\ b),\ (_g::) : (a : Type) \to a \to \later \kappa_1 \onk{Stream}\ a \to
    \onk{Stream}\ a$

  \caption{Checking of nats.}
  \label{fig:check_nat}
\end{figure}
\end{landscape}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../../copatterns-thesis"
%%% End:


\chapter{Utility}

\section{EigenHelper}
\subsection{slice\_by\_set - indexing a matrix by integer set}
Giving a matrix \cd{mat} and a integer set \cd{is}, dimension indicator \cd{dim}. Return a matrix so that each column or row comes from \cd{mat} indicated by \cd{is}.

\cd{dim=0} for select rows. \cd{dim=1} for select columns.

\noindent Definition:
\begin{lstlisting}
template<typename SV, typename IDXT>
SV slice_by_set(SV mat, IDXT is, int dim=0);
\end{lstlisting}

\cd{IDXT} is the type of set. It can be \cd{set<int>} or \cd{vector<int>}. It's very useful when you want to manipulate a subset of rows or columns.

\noindent Example:
\begin{lstlisting}
set<int> s;
s.emplace(1);
s.emplace(2);
s.emplace(0);

MatrixXd m(5, 4);
m.setRandom();

cout << slice_by_set(m,s) << endl;
cout << slice_by_set(m, vector<int>{ 0,1,2 }) << endl;
\end{lstlisting}

\section{FunctionCollection}
\subsection{print\_stl - print values in a STL container}

\noindent Definition:
\begin{lstlisting}
template<typename T>
void print_stl(T& v);
\end{lstlisting}

\subsection{which - get indices of a value in a container}
\noindent Definition:
\begin{lstlisting}
template<typename V, typename S>
vector<int> which(const V& v, const S& val);
\end{lstlisting}

\subsection{set2vec - convert a set to vector}
\noindent Definition:
\begin{lstlisting}
template<typename T>
vector<T> set2vec(const set<T>& s);
\end{lstlisting}


\section{Viromancer}\label{perk:viromancer}
\textbf{Cost:} 250CP\\
\textbf{Requirements:}~\nameref{rune:life} I\\
\textbf{Passive, Repeatable, Source(250 Gold)}\\
You have become able to heal more effectively.\\
Whenever a rune or spell allows you to heal damage, you add one to every healing die that you roll.\\
\\
Level Progression:\\
\\
\rowcolors{2}{lightgray}{white}
\begin{tabular}{l | l | l | l | l}
    Level & CP Cost & Gold Cost &  Effect\\
    II & 750 & 750 & +2 to every die\\
    III & 2,500 & 900 & +3 to every die\\
    IV & 5,000 & 1,500 & +4 to every die\\
\end{tabular}


\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fontspec}
%\XeTeXlinebreaklocale "zh"
%\XeTeXlinebreakskip = 0pt plus 1pt
%\setmainfont[Mapping=tex-text]{DejaVu Serif} % rm
\usepackage{graphicx}
\usepackage[a4paper]{geometry}
%\setlength{\textwidth}{5in}
%\setlength{\hoffset}{0.6in}
%header
\usepackage{fancyhdr}
%math package
\usepackage[fleqn]{amsmath}
%\usepackage{amsmath,amssymb}
%code package
%\usepackage{minted}
\usepackage{listings}
\usepackage{minted}
\usepackage[lined,boxed]{algorithm2e}
\usepackage{subcaption}

\newcommand{\horrule}[1]{\rule{\linewidth}{#1}}
\title{
\normalfont \normalsize \vspace{-13em} % Your university, school and/or department name(s)
\horrule{1pt} \\[0.5cm] % Thick bottom horizontal rule
\huge Neural Network
\\ % The assignment title
\vspace{1em}
\large Assignment 4
\horrule{2pt} \\[0.5cm] % Thick bottom horizontal rule
}
\author{Zhao Shenjian 5110309748}
\date{}
\pagestyle{fancy}
\rhead{Self Organizing Map}

\begin{document}
\maketitle
\thispagestyle{empty}
\setcounter{page}{1}
\section*{Part I: Self-organizing maps}
  \paragraph{}A self-organizing map is a type of artificial neural network (ANN) that is trained using unsupervised learning to produce a low-dimensional,
  discretized representation of the input space of the training samples, called a map.
  Self-organizing maps are different from other artificial neural networks in the sense that they use a neighborhood function to preserve the
  topological properties of the input space.
  \paragraph{} In this homework, we are mapping two gaussian distributions to $ 5*5 $ neural network.

 \section*{Part II: Matlab implementation}
 \paragraph{} According to the algorithm, we can easily implement it in Matlab. But there are some parameters to tweak such as the learning rate and the
 gaussian neighborhood function.

 \section*{Part III: Test results}
\paragraph{} I run this implementation with different parameters, and the results is shown in the following figures.
With larger learning rate the results will converge slower, but smaller learning rate and $\sigma$ will produce
incorrect results.

\begin{figure}[h!]
\begin{center}
%\framebox[4.0in]{$\;$}

\begin{subfigure}{.33\textwidth}
  \centering
  \includegraphics[width=.8\linewidth]{p1000}
      \caption{learning rate 1000, $ \sigma = 4 $}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
  \centering
  \includegraphics[width=.8\linewidth]{p500}
      \caption{learning rate 500, $ \sigma = 4 $}
\end{subfigure}%
\begin{subfigure}{.33\textwidth}
  \centering
  \includegraphics[width=.8\linewidth]{rho1}
      \caption{learning rate 500, $ \sigma = 1 $}
\end{subfigure}%
\end{center}
      \caption{Comparison of different parameters}
      \end{figure}

\end{document}


\subsection{Simulation with simulink}

A simulation was done using Simulink to compare the tracking behaviour between
simulation and experiment. Unfortunately  the  time  in the laboratory was not
enough  to finish the exercise. So we didn't have  the  time  to  analyse  the
tracking behaviour of the electrical motor  in  the  laboratory.  However,  in
Simulink  the  tracking  behaviour was analysed and it can be seen  in  figure
\ref{fig:tracking}. The best value for  the  $PT_{1}$-element we determined to
be $5.962$, so our $PT_{1}$-element is of the form:

\begin{equation}
    G(s) = \frac{1}{5.962s+1}
\end{equation}

For  the   dead   time   element   we  took  the  value  $0.1655$.  In  figure
\ref{fig:simulink} there are 5  different  Block  diagram. the first 3 diagram
represent  the  simulation  model  of  the  plant. The last two Block  diagram
represent an implemented PID controller with and without a tracking behaviour.

The best PID controller we obtained  during  the  experiment  have  the values
(Proportional $P$, Integral $I$ and Derivative $D$) :

\begin{align*}
    P &= 0.330 \\
    I &= 0.660 \\
    D &= 0.330
\end{align*}

\begin{figure}[t]
    \centering
    \includegraphics[width=\imagewidth]{images/simulink.png}
    \caption{Block diagram of the Simulink simulation}
    \label{fig:simulink}
\end{figure}

The smallest tracking behaviour we obtained with the values:

\begin{align*}
    P &= 0.330 \\
    I &= 0.660 \\
    D &= 0.330
\end{align*}

which  are  the  same  as  for  the  normal   PID   controller.   In   picture
\ref{fig:tracking}  one  can  see  that the tracking behaviour have a change of
$180$  degree.  That means that the electrical  motor  change  his  direction.

\begin{figure}[t]
    \centering
    \includegraphics[width=\imagewidth]{images/slope.png}
    \caption{The system without tracking.}
    \label{fig:WithoutTracking}
\end{figure}

\begin{figure}[t]
    \centering
    \includegraphics[width=\imagewidth]{images/slope_tracking.png}
    \caption{Tracking behaviour of the system.}
    \label{fig:tracking}
\end{figure}

\clearpage


\section{Application to field data}

We have applied our method to interpret airborne magnetic data provided by
Geological Survey of Brazil (CPRM) over the Anit{\'a}polis complex \citep{melo-2020},
in southern Brazil.
The airborne survey was flown with north-south and east-west lines spaced by $500$ m and $10\,000$ m from each other, respectively.
The total-field anomaly data (Fig. \ref{fig:real_data}a) were corrected from diurnal correction and the main geomagnetic field using the IGRF.
The inclination, declination, and intensity of the main geomagnetic field at the study area,
for the period of the survey, are $-37.05^{\circ}$, $-18.17^{\circ}$ and
$\approx 22 \, 768 $ nT, respectively.
Fig. \ref{fig:real_data}(b) shows a regional field obtained by fitting, in the least-squares sense, a first-order polynomial to the original data (Fig. \ref{fig:real_data}a).
Figs \ref{fig:real_data}(c) and \ref{fig:real_data}(d) show the geometric height.
We have subtracted 800 m from their values and, after the inversion, the estimated model is corrected.

After removing a first-order polynomial (Fig. \ref{fig:real_data}b) from the original data
(Fig. \ref{fig:real_data}a) using a least-squares polynomial fitting, we obtain the residual total-field anomaly shown in Fig. \ref{fig:anitapolis_rtp}(a).
The Anit{\'a}polis alkaline-carbonatitic complex forms a circular concentric body
($\approx 6$ km$^{2}$ in area) containing magnetite as part of its mineralogical
composition.
It intruded into the Late Proterozoic leucogranites of the Dom Feliciano
mobile belt in the Early Cretaceous ($132$ Ma), apparently concomitant with the
voluminous flood tholeiitic basalts of the Serra Geral Formation ($133$-$130$ Ma)
at the southern side of the Paran{\'a} Basin \citep{gibson-1999, scheibe-etal2005}.
As pointed out by \citet{GOMES2018}, there is still some debate about the emplacement
of the Anit{\'a}polis alkaline-carbonatitic complex.
\citet{melcher-coutinho1966} pointed out the influence of N-S-trending faults.
\citet{horbach-marimon1980} affirmed that the Anit{\'a}polis complex is controlled by
a large N30W lineament.
\citet{scheibe-etal2005} considered that it is roughly emplaced along the E-W Rio
Uruguay Lineament.
According to \citet{riccomini-etal2005}, the Anit{\'a}polis
complex does not show a clear structural control.

By using the methodology of \cite{reis-etal2020}, we set the total-magnetization direction of the interpretation model with inclination $ I=-21^\circ $ and declination $ D=-11^\circ $. These values were estimated by \cite{reis-seg-2019}.
We have accepted this estimated magnetization direction because the calculated RTP anomaly
(Fig. \ref{fig:anitapolis_rtp}b) of the residual total-field anomaly
(Fig. \ref{fig:anitapolis_rtp}a) is predominantly positive and decays to zero toward
the borders of the study area \citep{reis-etal2020, reis-seg-2019}.

This total-magnetization direction indicates the presence of remanent magnetization.
Laboratory measurements on rock samples obtained at the Jacupiranga complex,
another alkaline complex located northward of the study area,
with the same age as the Anit{\'a}polis complex,
show total-magnetization intensities values varying from approximately
$0.01$ to $29.90$ A/m \citep[][ tb. 1]{valdivia-2009}.
We used these values as a priori information to set the range of possible values
for the total-magnetization intensity $m_{0}$ in the Anit{\'a}polis complex.

We used an interpretation model formed by $L = 6$ prisms, each one with
$V = 20$ vertices defining their horizontal cross-sections.
We inverted the residual total-field anomaly (Fig. \ref{fig:anitapolis_rtp}a) for each
pair of $m_0$ and $z_0$ shown in Fig. \ref{fig:anitapolis_rtp}(c), resulting in $100$ estimated
models.
For all models, we set the same initial approximation $\hat{\mathbf{p}}_{(0)}$
(red prisms in Figs \ref{fig:real_result2}b and \ref{fig:real_result}b)
with origin at $(x_0^k, y_0^k) = (6\,921, 688)$ km, constant radii $r_j^k = 700$ m for
all vertices forming all prisms and the same constant thickness $dz = 900$ m.
We also set the same weights which were used in the synthetic tests, i.e.,
$\tilde{\alpha}_1 = 10^{-4}$,
$\tilde{\alpha}_2 = 10^{-3}$,
$\tilde{\alpha}_3 = 10^{-4}$,
$\tilde{\alpha}_4 = 0$,
$\tilde{\alpha}_5 = 0$,
$\tilde{\alpha}_6 = 10^{-8}$, and
$\tilde{\alpha}_7 = 10^{-5}$ (Eq. \ref{eq:alphas}).
Fig. \ref{fig:anitapolis_rtp}(c) shows that there is a region (blue region) containing
candidate solutions producing small values of the goal function
$\Gamma (\hat{\mathbf{p}}_{(f)}, m_{0}, z_{0})$ (Eq. \ref{eq:gamma}), with different values of $m_0$ and $z_0$.
Two estimates produced the smallest values for $\Gamma (\hat{\mathbf{p}}_{(f)}, m_{0}, z_{0})$ (Eq. \ref{eq:gamma}).
The magenta diamond in Fig. \ref{fig:anitapolis_rtp}(c) represents the
non-outcropping estimated model shown in Fig. \ref{fig:real_result2}.
This model produces a reasonable data fit (Fig. \ref{fig:real_result2}a).
It has a volume $ 6.94 $ km$ ^3 $, total thickness of $ 3\,045.69 $ m
($ dz = 510.95 $), depth-to-the-top $z_0 = 20$ m and total-magnetization intensity
$m_0 = 16.0$ A/m.
The white diamond in Fig. \ref{fig:anitapolis_rtp}(c) represents the outcropping estimated
model shown in Fig. \ref{fig:real_result}. This model is similar to that shown in
Fig. \ref{fig:real_result2}. It has a volume $ 7.24 $ km$ ^3 $, total thickness
$ 3\,032.65 $ m ($ dz = 505.44 $), depth-to-the-top $z_0 = 0$ m and
total-magnetization intensity $m_0 = 15$ A/m.
In comparison with the non-outcropping model shown in Fig. \ref{fig:real_result2}, the
alternative model shown in Fig. \ref{fig:real_result} has very similar geometry,
but it outcrops.

Finally, we stress that both total-magnetization intensities $m_0 = 16$  A/m and  $m_0 = 15$ A/m
are within the range found by  \citet{valdivia-2009} for intrusions located at the Jacupiranga complex.
Both estimated models show a nearly N30W elongated body with high dip
along depth (Figs \ref{fig:real_result2} and \ref{fig:real_result}),
which coincides with the topographic low observed in Fig \ref{fig:real_data}(c).
Hence, these estimates agree with the interpretation proposed by
\citet{horbach-marimon1980}, that considered the presence of N30W-trending fault
controlling the Anit{\'a}polis complex.


\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{amsmath}
\usepackage{graphicx}
\graphicspath{ {./} }

\usepackage[hmargin=3cm,vmargin=6.0cm]{geometry}
%\topmargin=0cm
\topmargin=-2cm
\addtolength{\textheight}{6.5cm}
\addtolength{\textwidth}{2.0cm}
%\setlength{\leftmargin}{-5cm}
\setlength{\oddsidemargin}{0.0cm}
\setlength{\evensidemargin}{0.0cm}

\newcommand{\HRule}{\rule{\linewidth}{1mm}}

%misc libraries goes here
\usepackage{tikz}
\usetikzlibrary{automata,positioning}

\begin{document}

\noindent
\HRule \\[3mm]
\begin{flushright}

                                         \LARGE \textbf{IE407}  \\[4mm]
                                         \Large Fundamentals of Operational Research\\[4mm]
                                        \normalsize      Fall '2019-2020 \\
                                           \Large   Term Project \\
\end{flushright}
\HRule

\section*{Group Information}
Group Number : 17 \\\\
Full Name : Yavuz Selim Yesilyurt \\
Id Number : 2259166 \\
Full Name : Alper Kocaman \\
Id Number : 2169589 \\
Full Name : Erce Eren \\
Id Number : 2099000 \\

\section*{Our Model and Related Information}
\subsection*{All employees with their types}

1- Senior Manager \\
2- Project Manager \\
3- Project Manager \\
4- Professional \\
5- Professional \\
6- Professional \\
7- Sales Person \\
8- Sales Person \\
9- Technician \\
10- Technician \\
11- Technician \\
12- Administrative Assistant \\
13- Administrative Assistant

\subsection*{Decision Variables}
  \begin{equation}
    X_{ep}=
    \begin{cases}
      1, & \text{if Employee}\ e \text{ is assigned to Program}\ p \\
      0, & \text{otherwise}
    \end{cases}
  \end{equation}

\subsection*{Objective Function}

\begin{align*}
    Min \sum_{p = 1}^{15} \sum_{e = 1}^{13} X_{ep} \times C_p
\end{align*}
Where $C_p$ is the cost of taking program $p$.

\subsection*{Constraints}
\begin{itemize}
\item Day(Time) Constraint
\begin{align*}
    \sum_{p = 1}^{15} X_{ep} \times D_p \leq 17 \ \ \ \text{For each } e \in \{1,2, ...,13\}
\end{align*}
Where $D_p$ is the day spent while taking program $p$.
\item Conflicting Programs Constraints
\begin{align*}
X_{e1} + X_{e3} &\leq 1 \ \ \ \text{For each } e \in \{1,2,...,13\}\\
X_{e9} + X_{e15} &\leq 1 \ \ \ \text{For each } e \in \{1,2,...,13\}\\
X_{e11} + X_{e12} &\leq 1 \ \ \ \text{For each } e \in \{1,2,...,13\}
\end{align*}
\item Being present on the Office Constraints
\begin{itemize}
\item For Professionals
\begin{align*}
&\sum_{i = 4}^{6} X_{i1} + \sum_{i = 4}^{6} X_{i3} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i9} + \sum_{i = 4}^{6} X_{i15} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i11} + \sum_{i = 4}^{6} X_{i12} \leq 2 \text{,} \\
&\sum_{i = 4}^{6} X_{i2} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i4} \leq 2  \text{,} \ \
\sum_{i = 4}^{6} X_{i5} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i6} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i7} \leq 2 \text{,} \\
&\sum_{i = 4}^{6} X_{i8} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i10} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i13} \leq 2 \text{,} \ \
\sum_{i = 4}^{6} X_{i14} \leq 2
\end{align*}
\item For Technicians
\begin{align*}
&\sum_{i = 9}^{11} X_{i1} + \sum_{i = 9}^{11} X_{i3} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i9} + \sum_{i = 9}^{11} X_{i15} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i11} + \sum_{i = 9}^{11} X_{i12} \leq 2 \text{,} \\
&\sum_{i = 9}^{11} X_{i2} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i4} \leq 2  \text{,} \ \
\sum_{i = 9}^{11} X_{i5} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i6} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i7} \leq 2 \text{,} \\
&\sum_{i = 9}^{11} X_{i8} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i10} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i13} \leq 2 \text{,} \ \
\sum_{i = 9}^{11} X_{i14} \leq 2
\end{align*}
\end{itemize}
\item Employees' Skill Coverage Constraint (The programs that employee $e$ take, needs to cover all the skills $s$ that employee needs to have)
\begin{align*}
    \sum_{p = 1}^{15} \sum_{e = 1}^{13} X_{ep} \times Y_{ps} \geq \sum_{e = 1}^{13} Z_{es} \ \ \text{For each skill } s \in \{1, ..., 41\}
\end{align*}
Where $Y_{ps}$ indicates whether Program $p$ covers skill $s$ or not; and $Z_{es}$ indicates whether Employee $e$ needs to have skill $s$ or not.

\end{itemize}

\end{document}