%!TEX root = ../thesis.tex
%*******************************************************************************
%****************************** Second Chapter *********************************
%*******************************************************************************

\chapter{Design and Analysis}

\ifpdf
    \graphicspath{{Chapter2/Figs/Raster/}{Chapter2/Figs/PDF/}{Chapter2/Figs/}}
\else
    \graphicspath{{Chapter2/Figs/Vector/}{Chapter2/Figs/}}
\fi

\section{Preliminaries}

\subsection{Count-Min Sketch}
The Count-Min \cite{cormode2005improved} sketch is a data-stream sketch that is used to approximate frequency counts of items in a data stream.

It consists of a 2D array. In a $h \times w$ sized Count-Min sketch, it consists of $w$ many hash functions that each maps onto $[0,h-1]$.

To store the frequency of an item $x$, it first maps $x$ onto $w$ different values $g_k(x) \in [0,h-1]$ using each hash function $g_k, k \in \{1..w\}$. Then, the entry at the $g_k(x)^{th}$ row, $k^{th}$ column is incremented by the frequency of $x$.

Let the entry of the sketch at the $i^{th}$ row, $j^{th}$ column be denoted by $f(i,j)$. Querying the frequency estimate of an item $x$ is accomplished by finding $min\{f(g_k(x),k)|k \in \{1..w\}\}$.

\subsection{gMatrix Sketch}
The gMatrix \cite{khan} is a sketch that is similar to the Count-Min sketch, except that it consists of a 3D array instead of a 2D one and specializes on graph streams.

In a $h \times h \times w$ sized gMatrix, to store the frequency of an edge $(i,j)$, it first maps $i$ and $j$ onto $w$ different values $g_k(i)$ and $g_k(j)$ using each hash function $g_k, k \in \{1..w\}$. Then, the entry at the $g_k(i)^{th}$ row, $g_k(j)^{th}$ column, and $k^{th}$ layer is incremented by the frequency of the edge $(i,j)$.

Let the entry of the sketch at the $i^{th}$ row, $j^{th}$ column, and $k^{th}$ layer be denoted by $f(i,j,k)$. Querying the frequency estimate of an edge $(i,j)$ is accomplished by finding $min\{f(g_k(i),g_k(j),k)|k \in \{1..w\}\}$.

\subsection{gSketch Partitioning Method}
\begin{algorithm}
\caption{Sketch-Partitioning-On-CountMin \cite{DBLP} (Data Sample: $D$)}\label{cm}
\begin{algorithmic}[1]

\State Create a root node $S$ of the partitioning tree as an
active node;
\State $S.width \gets h$;
\State $S.depth \gets w$;
\State Create an empty list $L$ containing $S$ only;
\While{$L \neq \varnothing$ }
\State Partition active node $S \in L$ based on D into $S_1$, $S_2$ by minimizing E in equation \ref{objective};
\State $S_1.width = S_2.width = \frac{S.width}{2};$
\State $L \gets L \setminus \{ S \};$
\If{$(S_1.width \geq w_0)$ and ($\sum_{m \in S_1} \tilde{d}(m) > C \cdot S_1.width$)}
\State $L \gets L \cup S_1$;
\Else
\State Construct the localized sketch $S_1$;
\EndIf

\If{$(S_2.width \geq w_0)$ and ($\sum_{m \in S_2} \tilde{d}(m) > C \cdot S_2.width$)}
\State $L \gets L \cup S_2$;
\Else
\State Construct the localized sketch $S_2$;
\EndIf

\EndWhile

\end{algorithmic}
\end{algorithm}
The gSketch \cite{DBLP} is a partitioning method performed onto a graph-stream sketch prior to being populated with the stream. The partitioning method is based on the source vertex set of a sample stream. The method, as shown in Algorithm \ref{cm} \cite{DBLP}, is recursive and on each step of the recursion, it first sorts the sample in order of non-decreasing average edge frequency, which is estimated by the ratio of vertex aggregate-frequency to its degree $\frac{\tilde{f_v(m)}}{\tilde{d(m)}}$, and then selects a pivot on which the sorted list is to be partitioned into two by minimizing an objective function,
\begin{equation}
\label{objective}
E = \sum_{m \in S_1} \frac{\tilde{d}(m) \cdot \tilde{F}(S_1)}{\tilde{f}_v(m) / \tilde{d}(m)} + \sum_{m \in S_2} \frac{\tilde{d}(m) \cdot \tilde{F}(S_2)}{\tilde{f}_v(m) / \tilde{d}(m)}
\end{equation}, where $S_1$ and $S_2$ are the two produced partitions based on the selected pivot on the step of the recursion and $\tilde{F}(S_i)$ is its total frequency, and that when minimized, the overall relative error of the whole sketch is minimized as well.

As shown in Algorithm \ref{cm}, there are two conditions in which if any one of the two is met, the recursion is immediately terminated and starts to build the local partition $S$:

\begin{enumerate}
\item $S.width < w_0$ as the sketch is small enough.
\item $\sum_{m\in S}\tilde{d}(m) \leq C \cdot S.width$, where $C$ is a constant, as it implies that the probability for any collisions to occur in any cell of $S$ can be bounded above by $C$.
\end{enumerate}

\section{gSketch Partitioning Method for gMatrix}

The gSketch partitioning\cite{DBLP} is shown to improve Count-Min's\cite{cormode2005improved} accuracy. The partitioning works by grouping edges with similar frequencies in the same partition to improve sketch accuracy and requires an available data sample.

The same partitioning method can also be applied onto the gMatrix, as shown in Algorithm \ref{gmat}, by changing the width $S.width$ of the Count-Min sketch with the number of rows of the gMatrix $S.rows$.

\begin{algorithm}
\caption{Sketch-Partitioning-On-gMatrix (Data Sample: $D$)}\label{gmat}
\begin{algorithmic}[1]

\State Create a root node $S$ of the partitioning tree as an
active node;
\State $S.rows \gets h$;
\State $S.cols \gets h$;
\State $S.depth \gets w$;
\State Create an empty list $L$ containing $S$ only;
\While{$L \neq \varnothing$ }
\State Partition active node $S \in L$ based on D into $S_1$, $S_2$ by minimizing E in equation \ref{objective};
\State $S_1.rows = S_2.rows = \frac{S.rows}{2};$
\State $L \gets L \setminus \{ S \};$
\If{$(S_1.rows \geq w_0)$ and ($\sum_{m \in S_1} \tilde{d}(m) > C \cdot S_1.rows$)}
\State $L \gets L \cup S_1$;
\Else
\State Construct the localized sketch $S_1$;
\EndIf

\If{$(S_2.rows \geq w_0)$ and ($\sum_{m \in S_2} \tilde{d}(m) > C \cdot S_2.rows$)}
\State $L \gets L \cup S_2$;
\Else
\State Construct the localized sketch $S_2$;
\EndIf

\EndWhile

\end{algorithmic}
\end{algorithm}

We provide a proof that the terminating condition $\sum_{m \in S} \tilde{d}(m) \leq C \cdot S.rows$ still guarantees that the probability for any collisions to occur in the sketch partition is bounded above by $C$.

\begin{theorem}
Let $S$ be a gMatrix partition and $0<C<1$ be a constant. Then, the condition $\sum_{m \in S} \tilde{d}(m) \leq C \cdot S.rows$ implies that the probability for any collisions to occur in $S$ is bounded above by C.
\end{theorem}

\begin{proof}
There are two cases of spurious edges that may collide with an edge $(i,j)$ in $S$. The first case of such edges are those for which both end-points are neither $i$ nor $j$, and the probability of collision is $\frac{1}{S.rows \cdot S.cols}$. The second case of such edges are those for which either the source node is $i$ too or the destination node is $j$ too, and the probability of collision is $\frac{1}{S.cols}$ and $\frac{1}{S.rows}$ consecutively. Since the partitioning divides the number of rows into half on each step of the recursion, on an $h \times h \times w$ gMatrix, it always holds that $S.rows \leq S.cols$, and so the probability of collision is at most $\frac{1}{S.rows}$. Since there are $\sum_{m \in S} \tilde{d}(m)$ distinct edges in $S$, the probability for any collisions to occur is at most $\frac{\sum_{m \in S} \tilde{d}(m)}{S.rows}$. Therefore, $\sum_{m \in S} \tilde{d}(m) \leq C \cdot S.rows$ guarantees that the probability for any collisions to occur in the sketch is bounded above by $C$.
\end{proof}

After partitioning, each of the resulting partitions is associated with a set of source vertices. Each source vertex is then only associated with exactly one partition. Edge $(u,v)$ is stored in partition $p$ if and only if $u$ is in the set of source vertices associated with the partition $p$. An outlier partition is then needed to be reserved to store frequencies of edges in the dataset whose source node is not associated with any of the resulting partitions of the sketch partitioning algorithm.

We propose two new optimizations to the partitioning method. The first is that since the partitioning works by grouping edges with similar average frequencies together estimated by the ratio of source-vertex aggregate-frequency to its degree $\frac{\tilde{f}_v(m)}{\tilde{d}(m)}$ and that edges with a common source-node $m$ are assumed to have similar frequencies, we can filter ones for which the assumption does not hold. In particular, we can compute the statistical variances of the frequencies of edges from the data sample with common source nodes and filter edges with source nodes for which the variance of the frequencies is exceeding a certain threshold.

Another observation is that the outlier partition size to be used for the sketch can be estimated by computing the outlier ratio from the data sample. We do so by first splitting the data sample into two, and then after selecting the suitable source nodes from the first split, the ratio of outliers in the second split is computed, which is essentially the ratio of the number of source nodes in the split not found among the previously-selected source nodes to the size of the split.

Next, we observe how gMatrix answers various query types after being partitioned and how partitioning affects gMatrix's accuracy.

\subsection{Edge Frequency Query Estimation}

Since there is only one partition associated with each source vertex, to retrieve the estimated frequency for an arbitrary edge $(i,j)$:

\begin{enumerate}
  \item Find partition $p$ that is responsible for $i$
  \item Find $min\{V_P(g_k(i),g_k(j),k)|\forall k \in \{1..w\}\}$, where $V_P$ is the value of the cell in the partition $p$.
\end{enumerate}

The number of operations taken by the first step depends on implementation. If a hash-table that maps each source-vertex onto its allocated partition is to be built during the sketch partitioning algorithm, the first step takes $\mathcal{O}(1)$ operations in average. For worst-case time complexity analysis, if a balanced binary search tree is to be used instead of the hash-table, the first step takes $\mathcal{O}(lg(|V^{+}|))$ operations, where $V^{+}$ is the set of source verticesnodes from the data sample.

The second step takes $\mathcal{O}(w)$ operations.

Thus, the worst-case time complexity is $\mathcal{O}(lg(|V^{+}|) + w)$.

Since obtaining the frequency estimate of an arbitrary edge only depends on the partition containing the edge, we observe how each partition answers the query.

Let $S$ be a gMatrix of size $h\times h\times w$. Suppose the partitioning step has been performed already. Note that any of the produced partitions will have number of rows equal to $\frac{h}{2^d}$ where $d$ is the depth of the recursion in which the partition is built. Let $p$ be an arbitrary partition. The size of $p$ is $\frac{h}{2^d}\times h\times w$.

\begin{theorem}
\label{thm:efreqguarantee}
Let $p$ be a partition built at depth $d$ of the sketch partitioning algorithm. Let $(i,j)$ be an edge in $p$, $Q(i,j)$ be its actual frequency, and $\overline{Q(i,j)}$ be its estimated frequency according to partition $p$. Let $L_p$ be the total frequency of edges received so far in the arbitrary partition, i.e. total frequency of edges $(u,v)$ such that $u$ is associated with $p$. Let $A_p(j)$ be the sum of the frequencies of edges $(u,v)$ on $p$ such that $v=j$. Let $B_p(i)$ be the sum of the frequencies of edges $(u,v)$ on $p$ such that $u=i$. Let $\epsilon \in (0,1)$ be a very small fraction. Then,

  \[
P(Q(i,j) \leq \overline{Q(i,j)} \leq Q(i,j) + L_p \cdot \epsilon + A_p(j) \cdot h \cdot \epsilon + B_p(i) \cdot h \cdot \epsilon) \geq 1-(\frac{2^{d+1}+1}{h^2\cdot\epsilon})^w
\]

\end{theorem}

\begin{proof}
  Note that $\overline{Q(i,j)}$ is essentially $Q(i,j)$ added with the frequencies of spurious edges mapped into the same cell $(g_k(i),g_k(j),k)$ in the partition, so $P(Q(i,j) \leq \overline{Q(i,j)}) = 1$. We remain to show that

\[
P(\overline{Q(i,j)} \leq Q(i,j) + L_p \cdot \epsilon + A_p(j) \cdot h \cdot \epsilon + B_p(i) \cdot h \cdot \epsilon) \geq 1-(\frac{2^{d+1}+1}{h^2\cdot\epsilon})^w
\]

  There are three possible cases for the spurious edges.

The first possible case of spurious edges $(u,v)$ are those for which $u \neq i$ and $v \neq j$. Any of such edges are equally likely to be mapped into any cell in $p$, and the probability to be mapped into any particular cell is $\frac{1}{h \cdot \frac{h}{2^d}} = \frac{2^d}{h^2}$. Let $X_k$ be a random variable that represents the number of such spurious edges that are mapped into $(g_k(i),g_k(j),k)$. Therefore, $E[X_k] = \frac{2^dL_p}{h^2}$. Then, by Markov's inequality,

\begin{equation} \label{efreq1}
P(X_k \geq L_p \cdot \epsilon) \leq \frac{E[X_k]}{L_p \cdot \epsilon} = \frac{2^d}{h^2\epsilon}
\end{equation}

The second possible case of spurious edges $(u,v)$ are those for which $u \neq i$ but $v=j$. The probability for any of such edges to be mapped into $(g_k(i),g_k(j),k)$ in $p$ is $\frac{1}{\frac{h}{2^d}} = \frac{2^d}{h}$. Let $Y_k$ be a random variable representing the number of such spurious edges. Therefore, $E[Y_k] = \frac{2^dA_p(j)}{h}$. By Markov's inequality,

\begin{equation} \label{efreq2}
P(Y_k \geq h A_p(j) \cdot \epsilon) \leq \frac{E[Y_k]}{h A_p(j) \cdot \epsilon} = \frac{2^d}{h^2\epsilon}
\end{equation}

The third possible case of spurious edges $(u,v)$ are those for which $u=i$ but $v \neq j$. The probability for any of such edges to be mapped into $(g_k(i),g_k(j),k)$ in $p$ is $\frac{1}{h}$. Let $Z_k$ be a random variable representing the number of such spurious edges. Therefore, $E[Z_k] = \frac{B_p(i)}{h}$. By Markov's inequality,

\begin{equation} \label{efreq3}
P(Z_k \geq h B_p(i) \cdot \epsilon) \leq \frac{E[Z_k]}{h B_p(i) \cdot \epsilon} = \frac{1}{h^2\epsilon}
\end{equation}

Combining inequations \ref{efreq1}, \ref{efreq2}, \ref{efreq3},
\begin{equation} \label{efreq4}
  P(X_k + Y_k + Z_k \geq L_p \cdot \epsilon + A_p(j) \cdot h \cdot \epsilon + B_p(i) \cdot h \cdot \epsilon) \leq \frac{2^{d+1}+1}{h^2\cdot\epsilon}
\end{equation}

Therefore,
\begin{align}
\begin{split}
&  P(\overline{Q(i,j)} \leq Q(i,j) + L_p \cdot \epsilon + A_p(i) \cdot h \cdot \epsilon + B_p(i) \cdot h \cdot \epsilon)
\\  &= 1 - \prod _{k=1}^{w}P(X_k + Y_k + Z_k \geq L_p \cdot \epsilon + A_p(j) \cdot h \cdot \epsilon + B_p(i) \cdot h \cdot \epsilon)
\\  &\geq 1-(\frac{2^{d+1}+1}{h^2\cdot\epsilon})^w
\end{split}
\end{align}

\end{proof}

\begin{remarks}
  The probability of the guarantee gets lower as the depth $d$ of the recursion in which a partition is built gets deeper, but in ideal partitioning, the guarantee of the estimate of the partition itself gets better as $L_p$, $A_p(i)$, and $B_p(i)$ are reduced.
\end{remarks}

\subsection{Heavy-hitter Edge Query Estimation}
The query asks for retrieving the set of edges in the graph stream with frequencies at least $F$. The query is accomplished by the following steps:

\begin{enumerate}
\item obtain the set of edges with frequencies at least $F$ from each partition in the gMatrix, which can be accomplished as described in \cite{khan}
\item compute the union of each of the obtained sets.
\end{enumerate}

Without partitioning, we only need to perform step 1 once, but with partitioning, we need to perform it $n$ times, where $n$ is the number of partitions, so it is already at least $n$ times slower than without partitioning in the worst case. Thus, the first step takes $\mathcal{O}(nh^2w + 2 n \left \lfloor{P/h} \right \rfloor log P \prod_{k=1}^wc_k)$ operations \cite{khan}, where $c_k$ is the number of cells in the $k^{th}$ layer whose entries are at least $F$, and $P$ is a gMatrix parameter for generating hash functions and is a prime number larger than the maximum number of nodes in the graph stream.

For the second step, if the partitioning algorithm produces only one partition, there are no union operations performed. Otherwise, the second step takes $\Omega(|H|)$ operations, where $H$ denotes the set of true heavy-hitter edges in the graph stream.

As in \cite{khan}, the resulting set of heavy-hitter edges may consist of edges that are not actually heavy-hitter edges, but the set of all true heavy-hitter edges is always a subset, i.e. there are no missing true heavy-hitter edges in the resulting set.

We observe the probability that an edge $(i,j)$ is correctly classified as a heavy-hitter edge in each partition.

\begin{theorem}
Let $p$ be a partition built at depth $d$ of the sketch partitioning algorithm. Let $(i,j)$ be an edge in $p$. Let $Q(i,j)$ be its actual frequency, and $\overline{Q(i,j)}$ be its estimated frequency according to partition $p$. Let $L_p$ be the total frequency of edges received so far in the arbitrary partition, i.e. total frequency of edges $(u,v)$ such that $u$ is associated with $p$. Let $A_p(j)$ be the sum of the frequencies of edges $(u,v)$ on $p$ such that $v=j$. Let $B_p(i)$ be the sum of the frequencies of edges $(u,v)$ on $p$ such that $u=i$. Let $\epsilon \in (0,1)$ be a very small fraction. Then,
\[
P(Q(i,j) \geq F) \geq 1-(\frac{3\cdot2^d(L_p+h\cdot A_p(j)) + 3\cdot h\cdot B_p(i)}{h^2\cdot (\overline{Q(i,j)}-F)})^w
\]
\end{theorem}

\begin{proof}
Note that if the number of spurious edges is at most $(\overline{Q(i,j)} - F)$, the true frequency $Q(i,j)$ is at least $F$, so by obtaining a lower bound for the probability of the former, we obtain a lower bound for the probability of the latter as well.

To obtain a lower bound for the probability that the number of spurious edges is at most $(\overline{Q(i,j)} - F)$, we consider all possible cases of spurious edges.

The first possible case of spurious edges $(u,v)$ are those for which $u \neq i$ and $v \neq j$. Any of such edges are equally likely to be mapped into any cell in $p$, and the probability to be mapped into any particular cell is $\frac{1}{h \cdot \frac{h}{2^d}} = \frac{2^d}{h^2}$. Let $X_k$ be a random variable that represents the number of such spurious edges that are mapped into $(g_k(i),g_k(j),k)$. Therefore, $E[X_k] = \frac{2^dL_p}{h^2}$. Then, by Markov's inequality,

\begin{equation} \label{hh1}
P(X_k \geq \frac{\overline{Q(i,j)}-F}{3}) \leq \frac{E[X_k]}{\frac{\overline{Q(i,j)}-F}{3}} = \frac{3\cdot2^dL_p}{h^2(\overline{Q(i,j)}-F)}
\end{equation}

The second possible case of spurious edges $(u,v)$ are those for which $u \neq i$ but $v=j$. The probability for any of such edges to be mapped into $(g_k(i),g_k(j),k)$ in $p$ is $\frac{1}{\frac{h}{2^d}} = \frac{2^d}{h}$. Let $Y_k$ be a random variable representing the number of such spurious edges. Therefore, $E[Y_k] = \frac{2^dA_p(j)}{h}$. By Markov's inequality,

\begin{equation} \label{hh2}
P(Y_k \geq \frac{\overline{Q(i,j)}-F}{3}) \leq \frac{E[Y_k]}{\frac{\overline{Q(i,j)}-F}{3}} = \frac{3\cdot2^dA_p(j)}{h(\overline{Q(i,j)}-F)}
\end{equation}

The third possible case of spurious edges $(u,v)$ are those for which $u=i$ but $v \neq j$. The probability for any of such edges to be mapped into $(g_k(i),g_k(j),k)$ in $p$ is $\frac{1}{h}$. Let $Z_k$ be a random variable representing the number of such spurious edges. Therefore, $E[Z_k] = \frac{B_p(i)}{h}$. By Markov's inequality,

\begin{equation} \label{hh3}
P(Z_k \geq \frac{\overline{Q(i,j)}-F}{3}) \leq \frac{E[Z_k]}{\frac{\overline{Q(i,j)}-F}{3}} = \frac{3\cdot B_p(i)}{h(\overline{Q(i,j)}-F)}
\end{equation}

Combining inequations \ref{hh1}, \ref{hh2}, \ref{hh3},
\begin{equation}
  P(X_k + Y_k + Z_k \geq \overline{Q(i,j)}-F) \leq \frac{3\cdot2^d(L_p+h\cdot A_p(j)) + 3\cdot h\cdot B_p(i)}{h^2\cdot (\overline{Q(i,j)}-F)}
\end{equation}

Therefore,
\begin{align}
\begin{split}
&  P(Q(i,j) \geq F)
\\  &= 1 - \prod _{k=1}^{w}P(X_k + Y_k + Z_k \geq \overline{Q(i,j)}-F)
\\  &\geq 1-(\frac{3\cdot2^d(L_p+h\cdot A_p(j)) + 3\cdot h\cdot B_p(i)}{h^2\cdot (\overline{Q(i,j)}-F)})^w
\end{split}
\end{align}

\end{proof}

\subsection{Node Aggregate-Frequency Query Estimation}

The queries ask for the sum of frequencies of all edges incoming to / outgoing from a node $i$. Due to partitioning based on source nodes, source-node aggregate-frequency queries and destination-node aggregate-frequency queries are answered differently.

\subsubsection{Source-Node Aggregate-Frequency Query Estimation}

The task of finding the aggregate frequency of a source node $i$ is broken down to the following steps:

\begin{enumerate}
\item Finding the associated partition $p$ of $i$.
\item Finding the aggregate frequency of the source node $i$ at the partition $p$, which can be accomplished as described in \cite{khan}.
\end{enumerate}

The number of operations taken by the first step depends on implementation. If a hash-table that maps each source-vertex onto its allocated partition is to be built during the sketch partitioning algorithm, the first step takes $\mathcal{O}(1)$ operations in average. For worst-case time complexity analysis, if a balanced binary search tree is to be used instead of the hash-table, the first step takes $\mathcal{O}(lg(|V^{+}|))$ operations, where $V^{+}$ is the set of source verticesnodes from the data sample.

The second one takes $\mathcal{O}(hw)$ operations, so the query can be answered in $\mathcal{O}(hw)$ operations.

Thus, the overall time complexity is $\mathcal{O}(lg(|V^{+}|) + hw)$.

Next, we observe how partitioning affects the probabilistic accuracy guarantee.

\begin{theorem}
\label{thm:agg1}
Let $p$ be a partition built at depth $d$ of the sketch partitioning algorithm. Let $(i,j)$ be an edge in $p$. Let $Q_{agg}^{+}(i)$ be the true aggregate-frequency of source-node $i$, and $\overline{Q_{agg}^{+}(i)}$ be its estimated aggregate-frequency. Let $L_p$ be the total frequency of edges received so far on $p$. Let $\epsilon \in (0,1)$ be a very small fraction. Then,
\[
P(Q_{agg}^{+}(i) \leq \overline{Q_{agg}^{+}(i)} \leq Q_{agg}^{+}(i) + L_p \cdot \epsilon) \geq 1-(\frac{2^d}{h\cdot\epsilon})^w
\]
\end{theorem}

\begin{proof}
We note that $P(Q_{agg}^{+}(i) \leq \overline{Q_{agg}^{+}(i)}) = 1$ since $\overline{Q_{agg}^{+}(i)}$ is always an overestimate. We remain to show that
\[
P(\overline{Q_{agg}^{+}(i)} \leq Q_{agg}^{+}(i) + L_p \cdot \epsilon) \geq 1-(\frac{2^d}{h\cdot\epsilon})^w
\]
In any arbitrary partition $p$, the probability for a spurious edge $(u,v)$, where $u \neq i$ and $u$ is associated with $p$, to be mapped onto any of the columns at the $g_k(i)^{th}$ row, $k^{th}$ layer of $p$ is $\frac{1}{\frac{h}{2^d}} = \frac{2^d}{h}$, so the expected number of spurious edges is $\frac{2^dL_p}{h}$. Let $R_k$ be the random variable that represents the number of such spurious edges for the $k^{th}$ hash function. By Markov's inequality,

\begin{equation} \label{agg21}
  P(R_k \geq L_p \epsilon) \leq \frac{E[R_k]}{L_p \epsilon} = \frac{2^d}{h\epsilon}
\end{equation}

Therefore,
\begin{align}
\begin{split}
&  P(\overline{Q_{agg}^{+}(i)} \leq Q_{agg}^{+}(i) + L_p \cdot \epsilon)
\\  &= 1 - \prod _{k=1}^{w}P(R_k \geq L_p \cdot \epsilon)
\\  &\geq 1-(\frac{2^d}{h\cdot\epsilon})^w
\end{split}
\end{align}

\end{proof}

\begin{remarks}
As the depth $d$ of the recursion in which the partition is built increases, the probability of the accuracy guarantee decreases, but in ideal partitioning, the accuracy guarantee itself gets better as $L_p$ gets reduced.
\end{remarks}

\subsubsection{Destination-Node Aggregate-Frequency Query Estimation}

The task of finding the aggregate-frequency of a destination node $j$ is broken down to:

\begin{enumerate}
\item Computing the aggregate-frequency of the destination-node $j$ in each partition $p$, which can be accomplished as described in \cite{khan}.
\item Computing the sum of all of the computed destination-node aggregate-frequencies together
\end{enumerate}

The first step implies that the time complexity for answering the query is at least $n$ times slower in the worst case than it is without partitioning, where $n$ is the number of partitions after performing the sketch partitioning algorithm. The second step only takes $\mathcal{O}(n)$ operations. Thus, the worst-case time complexity to answer the query is $\mathcal{O}(nhw)$.

Next, we observe how partitioning affects the probabilistic accuracy guarantee.
\begin{theorem}
\label{thm:agg2}
Let $Q_{agg}^{-}(j)$ be the true aggregate-frequency of destination-node $j$, and $\overline{Q_{agg}^{-}(j)}$ be the estimated aggregate-frequency. Let $L$ be the total frequency of edges received so far. Let $\epsilon \in (0,1)$ be a very small fraction. Then,

  \[
P(Q_{agg}^{-}(j) \leq \overline{Q_{agg}^{-}(j)} \leq Q_{agg}^{-}(j) + L \cdot \epsilon) \geq 1-(\frac{n}{h\cdot\epsilon})^w
\]

\end{theorem}

\begin{proof}
We note that $P(Q_{agg}^{-}(j) \leq \overline{Q_{agg}^{-}(j)}) = 1$ since $\overline{Q_{agg}^{-}(j)}$ is always an overestimate. We remain to show that
\[
P(\overline{Q_{agg}^{-}(j)} \leq Q_{agg}^{-}(j) + L \cdot \epsilon) \geq 1-(\frac{n}{h\cdot\epsilon})^w
\]
Let $\{p_1,..,p_n\}$ be the set of all partitions in the gMatrix and $L_i$ be the total frequency of edges in $p_i$. In any partition $p_i$, the probability for a spurious edge $(u,v)$, $v \neq j$ to be mapped onto any of the rows at the $g_k(j)^{th}$ column, $k^{th}$ layer is $\frac{1}{h}$, so the expected number of spurious edges is $\frac{L_i}{h}$. Let $R_k^i$ be the random variable that represents the number of spurious edges in $p_i$ for the $k^{th}$ hash function. By Markov's inequality,

\begin{equation} \label{agg21}
  P(R_k^i \geq L_i \epsilon) \leq \frac{E[R_k^i]}{L_i \epsilon} = \frac{1}{h\epsilon}
\end{equation}

Let $R_k = \sum_{i=1}^{n} R_k^i$ be the total number of spurious edges in all of the $n$ partitions. Combining inequation \ref{agg21} for all $i \in \{1..n\}$,

\begin{equation} \label{agg22}
 P(R_k \geq L\epsilon) \leq \frac{n}{h\epsilon}
\end{equation}

Therefore,
\begin{align}
\begin{split}
&  P(\overline{Q_{agg}^{-}(j)} \leq Q_{agg}^{-}(j) + L \cdot \epsilon)
\\  &= 1 - \prod _{k=1}^{w}P(R_k \geq L \cdot \epsilon)
\\  &\geq 1-(\frac{n}{h\cdot\epsilon})^w
\end{split}
\end{align}

\end{proof}

\begin{remarks}
The probability of the guarantee gets lower as the number of partitions increases, and the guarantee itself never gets any better with partitioning. In other words, partitioning will never improve the accuracy of gMatrix for answering destination-node aggregate-frequency queries.
\end{remarks}


\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array, tikz,tkz-berge, calrsfs}
\usepackage{tkz-graph}

\title{Matroids And their Graphs}
\author{o.mcdonnell4@nuigalway.ie }
\date{19 January 2018}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem*{cor}{Corollary}

\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\newtheorem{conj}{Conjecture}[section]
\newtheorem{exmp}{Example}[section]

\theoremstyle{remark}
\newtheorem*{rem}{Remark}
\newtheorem*{note}{Note}

\newenvironment{rcases}
  {\left.\begin{aligned}}
  {\end{aligned}\right\rbrace}

\newcounter{excercise}
\newcounter{solution}
\newcounter{Question}

\newcommand\Excercise{%
  \textbf{Excercise:}~%
  \setcounter{solution}{0}%
}

\newcommand\TheSolution{%
  \textbf{Solution:}\\%
}

\newcommand\Question{%
    \textbf{Question:}~%
    \setcounter{Question}{0}%
}
\newcommand\Notation{%
  \textbf{Notation:}~%
}

\newcommand\Proof{%
    \textbf{Proof:}~%
}

\setlength{\droptitle}{-10em}

\begin{document}
\maketitle

 \section{Matroids imply Circuits: Alternative C3}
 \begin{defn} By using (I1)–(I3) , it is not difficult to show that the collection $\mathcal{C}$ of circuits of a matroid M has the following three properties:\\
(C1) The empty set is not in $\mathcal{C}$\\
(C2) No member of $\mathcal{C}$ is a proper subset of another member of $\mathcal{C}$\\
(C3) if $ C_1 $ and $ C_2 $ are distinct members of $ C $ and
$ e \in C_1 \cap C_2 $, then $ (C_1 \cup C_2 ) \setminus \{e\} $ contains a member of $\mathcal{C}$ .
 \end{defn}

 \vspace{5mm}

 \begin{thm}
 A matroid M $\implies$ all circuits in $\mathcal{C}$ satisfy (C1-C3).
 \end{thm}

 \noindent\Proof Let $A,b \in \mathcal{C}$, $A \neq B$
 \\
 \noindent Let $e \in A \cap B$
 \\
 \noindent Suppose(seeking a contradiction) that $(A \cap B) \setminus \{e\}$ is independent.
 \\
 \noindent Let $x \in A \setminus B$, noting that $x \neq e$
 \\
 \noindent $\implies A \setminus \{x\} \in \mathcal{I}$ i.e independent.
 \\
 \noindent We can add elements of $(A \cup B) \setminus \{e\}$ to $A \setminus \{x\}$ retaining independence until we have $|A \cup B| - 1$ elements.
 \\
 \noindent But now our new set $(A \cup B) \setminus \{x\}$ contains all of $B$ and $B \in \mathcal{C}$. Therefore, we have a contradiction, $(A \cup B) \setminus \{e\}$ cannot be independent
 \\
 \qed
 \end{document}


\section{Triggers}

The triggers are likely the most difficult part of this tutorial.
VCC tries to infer appropriate triggers automatically, so
trigger annotations were not needed for the examples in the tutorial.
However, you may need them to deal with more complex VCC verification
tasks.

This appendix gives some background on the usage of triggers in the
SMT solvers, the underlying VCC theorem proving technology.

SMT solvers
prove that the program is correct by looking for possible counterexamples,
or \Def{models}, where your program goes wrong (\eg by violating an assertion).
Once the solver goes through \emph{all} possible counterexamples, and finds them
all to be inconsistent (\ie impossible),
it considers the program to be correct.
Normally, it would take virtually forever, for there is very large number of
possible counterexamples, one per every input to the function (values stored in
the heap also count as input).
To workaround this problem, the SMT solver considers
\Def{partial models}, \ie
sets of statements about the state of the program.
For example, the model description may say \vcc{x == 7}, \vcc{y > x}
and \vcc{*p == 12}, which describes all the concrete models, where
these statements hold. There is great many such models,
for example one for each different value of \vcc{y} and other program variables,
not even mentioned in the model.

It is thus useful to think of the SMT solver as sitting there with
a possible model, and trying to find out whether the model is consistent or not.
For example, if the description of the model says that \vcc{x > 7} and
\vcc{x < 3}, then the solver can apply rules of arithmetic, conclude this is
impossible, and move on to a next model.
The SMT solvers are usually very good in finding inconsistencies in models
where the statements describing them do not involve universal quantifiers.
With quantifiers things tend to get a bit tricky.

For example, let's say the model description states that the two
following facts are true:
\begin{VCC}
\forall unsigned i; i < 10 ==> a[i] > 7
a[4] == 3
\end{VCC}
The meaning of the universal quantifier is that it should hold
not matter what we substitute for \vcc{i}, for example
the universal quantifier above implies the following facts (which
are called \Def{instances} of the quantifier):
\begin{VCC}
 4 < 10 ==>  a[4] > 7  // for i == 4
\end{VCC}
which happens to be the one needed to refute our model,
\begin{VCC}
11 < 10 ==> a[11] > 7  // for i == 11
\end{VCC}
which is trivially true, because false implies everything, and
\begin{VCC}
 k < 10 ==>  a[k] > 7  // for i == k
\end{VCC}
where \vcc{k} is some program variable of type \vcc{unsigned}.

However, there is potentially infinitely many such instances, and certainly too many
to enumerate them all.
Still, to prove that our model candidate is indeed contradictory
we only need the first one, not the other two.
Once the solver adds it to the model description,
it will simplify \vcc{4 < 10} to true,
and then see that \vcc{a[4] > 7} and \vcc{a[4] == 3} cannot hold
at the same time.

The question remains: how does the SMT solver decide that the first
instance is useful, and the other two are not?
This is done through so called \Def{triggers}.
Triggers are either specified by the user or inferred automatically
by the SMT solver or the verification tool.
In all the examples before we relied on the automatic trigger
inference, but as we go to more complex examples, we'll need to consider
explicit trigger specification.

A trigger for a quantified formula is usually some subexpression
of that formula, which contains all the variables that the formula
quantifies over.
For example, in the following formula:
\begin{VCC}
\forall int i; int p[int]; is_pos(p, i) ==> f(i, p[i]) && g(i)
\end{VCC}
possible triggers include the following expressions
\vcc|is_pos(p, i)|, \vcc|p[i]|, and also \vcc|f(i, p[i])|,
whereas \vcc|g(i)| would not be a valid trigger, because
it does not contain \vcc|p|.

Let's assume that \vcc|is_pos(p, i)| is the trigger.
The basic idea is that when the SMT solvers considers a model,
which mentions \vcc|is_pos(q, 7)| (where \vcc|q| is, \eg a local variable), then the formula
should be instantiated with \vcc|q| and \vcc|7| substituted
for \vcc|p| and \vcc|i| respectively.

Note that the trigger \vcc|f(i, p[i])| is \Def{more restrictive} than
\vcc|p[i]|: if the model contains \vcc|f(k, q[k])| it also contains \vcc|q[k]|.
Thus, a ``bigger'' trigger will cause the formula to be instantiated less often,
generally leading to better proof performance (because the solver has
less formulas to work on), but also possibly preventing
the proof altogether (when the solver does not get the instantiation needed for the proof).

Triggers cannot contain boolean operators or the equality operator.
As of the current release, arithmetic operators are allowed, but cause warnings
and work unreliably, so you should avoid them.

A formula can have more than one trigger.
It is enough for one trigger to match in order for the formula
to be instantiated.

\begin{note}
\textbf{Multi-triggers}:
Consider the following formula:
\begin{VCC}
\forall int a, b, c; P(a, b) && Q(b, c) ==> R(a, c)
\end{VCC}
There is no subexpression here, which would contain all the variables
and not contain boolean operators.
In such case we need to use a \Def{multi-trigger}, which
is a set of expressions which together cover all variables.
An example trigger here would be \vcc|{P(a, b), Q(b, c)}|.
It means that for any model, which has both \vcc|P(a, b)|
and \vcc|Q(b, c)| (for the same \vcc|b|!), the quantifier
will be instantiated.
In case a formula has multiple multi-triggers, \emph{all}
expressions in at least \emph{one} of multi-triggers
must match for the formula to be instantiated.

If it is impossible to select any single-triggers in the formula,
and none are specified explicitly, Z3 will select \emph{some}
multi-trigger, which is usually not something that you want.
\end{note}

\subsection{Matching loops}

Consider a model description
\begin{VCC}
\forall struct Node *n; {\mine(n)} \mine(n) ==> \mine(n->next)
\mine(a)
\end{VCC}
Let's assume the SMT solver will instantiate the quantifier with \vcc{a}, yielding:
\begin{VCC}
\mine(a) ==> \mine(a->next)
\end{VCC}
It will now add \vcc{\mine(a->next)} to the set of facts
describing the model.
This however will lead to instantiating the quantifier again,
this time with \vcc{a->next}, and in turn again with
\vcc{a->next->next} and so forth.
Such situation is called a \Def{matching loop}.
The SMT solver would usually cut such loop at a certain depth,
but it might make the solver run out of time, memory, or both.

Matching loops can involve more than one quantified formula.
For example consider the following, where \vcc{f} is a user-defined function.
\begin{VCC}
\forall struct Node *n; {\mine(n)} \mine(n) ==> f(n)
\forall struct Node *n; {f(n)} f(n) ==> \mine(n->next)
\mine(a)
\end{VCC}

\subsection{Trigger selection}
\label{sect:trigger-inference}

The explicit triggers are listed in \vcc|{...}|, after the quantified variables.
They don't have to be subexpressions of the formula.
We'll see some examples of that later.
When there are no triggers specified explicitly, VCC selects the triggers for you.
These are always subexpressions of the quantified formula body.
To select default triggers VCC first considers all subexpressions which contain all the quantified variables,
and then it splits them into four categories:
\begin{itemize}
\item level 0 triggers, which are mostly ownership-related.
These are \vcc{\mine(E)}, \vcc{E1 \in \owns(E2)}, and also \vcc{E1 \in0 E2} (which, except for triggering, is the same as \vcc{E1 \in E2}).
\item level 1 triggers: set membership and maps, that is expressions of
the form \vcc{E1 \in E2} and \vcc{E1[E2]}.
\item level 2 triggers: default, \ie everything not mentioned elsewhere.
It is mostly heap dereferences, like \vcc{*p}, \vcc{&a[i]} or \vcc{a[i]}, as well as bitwise arithmetic operators.
\item level 3 triggers: certain ``bad triggers'', which use internal VCC encoding functions.
\item level 4 triggers: which use interpreted arithmetic operations (\vcc{+}, \vcc{-}, and \vcc{*} on integers).
\end{itemize}

Expressions, which contain \vcc{<=}, \vcc{>=}, \vcc{<}, \vcc{>}, \vcc{==},
\vcc{!=}, \vcc{||}, \vcc{&&}, \vcc{==>}, \vcc{<==>}, and \vcc{!} are not
allowed in triggers.

Each of these expressions is then tested for immediate matching loop,
that is VCC checks if instantiating the formula with that trigger
will create a bigger instance of that very trigger.
Such looping triggers are removed from their respective categories.
This protects against matching loops consisting of a single
quantified formula, but matching loops with multiple formulas
are still possible.

To select the triggers, VCC iterates over levels, starting with 0.
If there are some triggers at the current level, these triggers are selected
and iteration stops.
This means that, \eg if there are set-membership triggers then heap dereference
triggers will not be selected.

If there are no triggers in levels lower than 4, VCC tries to select a multi-trigger.
It will only select one, with possibly low level, and some overlap between variables
of the subexpressions of the trigger.
Only if no multi-trigger can be found, VCC will try to use level 4 trigger.
Finally, if no triggers can be inferred VCC will print a warning.

As a post-processing step, VCC looks at the set of selected triggers, and if
any there are two triggers X and Y, such that X is a subexpression of Y, then Y
is removed, as it would be completely redundant.

You can place a \vcc@{:level N}@ annotation in place of a trigger.
It causes VCC to use all triggers from levels 0 to N inclusive.
If this results in empty trigger set, the annotation is silently ignored.

The flag \texttt{/dumptriggers:K} (or \texttt{/dt:K}) can be used to display inferred
triggers.
\texttt{/dt:1} prints the inferred triggers,
\texttt{/dt:2} prints what triggers would be inferred if \vcc@{:level ...}@ annotation
was supplied.
\texttt{/dt:3} prints the inferred triggers even when there are explicit triggers
specified.
It does not override the explicit triggers, it just print what would happen if you
removed the explicit trigger.

Let's consider an example:
\begin{VCC}
int *buf;
unsigned perm[unsigned];
\forall unsigned i; i < len ==> perm[i] == i ==> buf[i] < 0
\end{VCC}
The default algorithm will infer \vcc@{perm[i]}@, and with \vcc@{:level 1}@
it will additionally select \vcc@{&buf[i]}@.
Note the ampersand.
This is because in C \vcc{buf[i]} is equivalent to \vcc{*(&buf[i])}, and thus
the one with ampersand is simpler.
You can also equivalently write it as \vcc@{buf + i}@.
Note that the plus is not integer arithmetic addition, and can thus be safely used
in triggers.

Another example would be:
\begin{VCC}
\forall struct Node *n; n \in q->\owns ==> perm[n->idx] == 0
\end{VCC}
By default we get level 0 \vcc@{n \in q->\owns}@, with level 1 we also get
\vcc@{perm[n->idx]}@ and with level 2 additionally \vcc@{&n->idx}@.

\subsection{Hints}
\label{sect:trigger-hints}

Consider a quantified formula \vcc|\forall T x; {:hint H} E|.
Intuitively the hint annotation states that the expression \vcc{H} (which can
refer to \vcc{x}) might have something to do with proving \vcc{E}.
A typical example, where you might need it is the following:
\begin{VCC}
\forall struct Node *n; \mine(n) ==> \mine(n->next) && n->next->prev == n
\end{VCC}
The default trigger selection will pick \vcc@{\mine(n->next)}@, which is also
the ``proper'' trigger here.
However, when proving admissibility, to know that \vcc{n->next->prev} did not
change in the legal action, we need to know \vcc{\mine(n->next)}.
This is all good, it's stated just before, but the SMT solver
might try to prove \vcc{n->next->prev == n} first,
and thus miss the fact that \vcc{\mine(n->next)}.
Therefore, we will need to add \vcc@{:hint \mine(n->next)}@.
For inferred level 0 triggers, these are added automatically.

%\subsection{Typical triggers}
%
%\itodo{maybe we want a section like that?}
%
%\begin{VCC}
%\forall unsigned i; {a[i]} i < 100 ==> a[i] > 0
%\forall unsigned i, j; {f(i, j)} f(i, j) == i + j * 2
%\end{VCC}
%


\problemname{Assigning Workstations}

\illustration{0.48}{workstation-scaled}{Picture by NASA via \href{https://upload.wikimedia.org/wikipedia/commons/1/19/STS-128_ISS-20_Destiny_Canadarm2.jpg}{WikiMedia Commons}}%
\noindent
Penelope is part of the admin team of the newly built supercomputer. Her job is
to assign workstations to the researchers who come here to run their
computations at the supercomputer.

Penelope is very lazy and hates unlocking machines for the arriving
researchers. She can unlock the machines remotely from her desk, but does not
feel that this menial task matches her qualifications. Should she decide to
ignore the security guidelines she could simply ask the researchers not to lock
their workstations when they leave, and then assign new researchers to
workstations that are not used any more but that are still unlocked. That way,
she only needs to unlock each workstation for the first researcher using it,
which would be a huge improvement for Penelope.

Unfortunately, unused workstations lock themselves automatically if they are
unused for more than $m$ minutes. After a workstation has locked itself,
Penelope has to unlock it again for the next researcher using it. Given the
exact schedule of arriving and leaving researchers, can you tell Penelope how
many unlockings she may save by asking the researchers not to lock their
workstations when they leave and assigning arriving researchers to workstations
in an optimal way? You may assume that there are always enough workstations
available.

\section*{Input}

The input consists of:
\begin{itemize}
  \item one line with two integers $n$ ($1 \leq n \leq 300\,000$), the number
        of researchers, and $m$ ($1 \leq m \leq 10^8$), the number of minutes
        of inactivity after which a workstation locks itself;
  \item $n$ lines each with two integers $a$ and $s$ ($1 \leq a, s \leq 10^8$),
        representing a researcher that arrives after $a$ minutes and stays for
        exactly $s$ minutes.
\end{itemize}

\section*{Output}

Output the maximum number of unlockings Penelope may save herself.


%!TEX root = ./ERL Industrial Robots.tex

%--------------------------------------------------------------------
%--------------------------------------------------------------------
\subsection{Control Functionality}
\label{ssec:Control}
%--------------------------------------------------------------------
\subsubsection{Functionality Description}
\label{sssec:ControlDescription}
This functionality benchmark assesses the robot's capability to control the manipulator's (and the mobile platform's) motion in a continuous manner. This functionality is essential for precise placement of objects (see TBM2 in Section \ref{ssec:TaskPlateDrilling}) or following a given line in common industrial applications like welding or gluing.
A marker set is attached to the robot's manipulator. With the tip of this marker set, the robot has to follow a given path in Cartesian space. The external ground truth system measures the deviation between the given path and the path executed by the robot using this marker.
Only for visualization purposes, the path is displayed on the table (see Figures \ref{fig:FBM3_line_example} and \ref{fig:FBM3_sine_example}).

%--------------------------------------------------------------------
\subsubsection{Feature Variation}
\label{sssec:ControlVariation}

The path is a segment of either a straight line or a sine function.
In future competitions the path can be given as a trajectory including velocities and accelerations.
The path can be limited to the workspace for a manipulator or of a size that forces the mobile platform to move as well (future competitions).

%--------------------------------------------------------------------
\subsubsection{Input Provided}
\label{sssec:ControlInput}

\paragraph{Marker set}
An image of the marker set is depicted in Figure~\ref{fig:MarkerSetEndEffector}. The rod of this marker set is attached either directly to the end-effector or to the tool on the robot's manipulator. The tip of the marker set is defined as the center of the spherical cap nut at the end of the rod. This tip is indicated by the coordinate frame in Figure \ref{fig:MarkerSetEndEffector}. Note that in this FBM only the origin of the coordinate frame is important, while the orientation is irrelevant!
\begin{figure}[!htbp]
	\begin{center}
		\subfigure[]{
			\includegraphics[width=0.45\textwidth]{fig/marker_set/marker_set_with_frame}
			\label{fig:MarkerSetEndEffectorWithFrame}
		}
		\subfigure[]{
			\includegraphics[width=0.45\textwidth]{fig/marker_set/marker_set_side}
			\label{fig:MarkerSetEndEffectorSide}
		}
		\caption{The marker set used in FBM3. The rod is marked by the yellow brace. The tip of the marker set is marked by the origin of the coordinate frame (the orientation of the coordinate frame is irrelevant here).}
		\label{fig:MarkerSetEndEffector}
	\end{center}
\end{figure}

\paragraph{Path specification}
The path to be executed by the robot is specified by:
\begin{itemize}
\item a mathematical description of a line in 2D space (see Figure~\ref{fig:FBM3_line_example} for an example):
    \begin{displaymath}
    f(x) = m \cdot x
    \end{displaymath}
    where
    \begin{itemize}
    \item $x$ is a distance in metres [$m$] along the x-axis of the robot-selected coordinate system
    \item $f(x)$ is a distance specified in metres [$m$] along the y-axis of the robot-selected coordinate system
    \item $m$ is the slope specified as a dimensionless scalar
    \end{itemize}
\item a mathematical description of a sine in 2D space (see Figure~\ref{fig:FBM3_sine_example} for an example):
    \begin{displaymath}
    f(x) = a \cdot \sin(c \cdot x)
    \end{displaymath}
    where
    \begin{itemize}
    \item $x$ is a distance in metres [$m$] along the x-axis of the robot-selected coordinate system
    \item $f(x)$ is a distance specified in metres [$m$] along the y-axis of the robot-selected coordinate system
    \item $a$ is the amplitude specified in metres [$m$]
    \item $c$ is a conversion from a distance to an angle specified in radians per metre [$\frac{rad}{m}$].
    \end{itemize}
\item distance between the calibration point and starting point specified in metres [$m$].
\item start of the path, specified in the domain of the mathematical description.
\item end of the path, specified in the domain of the mathematical description.
\item the concrete selection of the parameters for each benchmark will be announced before the competition.
\end{itemize}
\noindent
To exemplify the definition of start and end of the path assume a sine with $a = 0.1\;m$ and $c = 12.5\cdot\pi\;\frac{rad}{m}$. Let the start of the path be given as $start = 0\;m$ and the end of the path be given as $end = 0.2\;m$. Then the start point is $f(start = 0\;m) = 0\;m$ and the end point is $f(end = 0.2\;m) = 0.1 \;m$.

\begin{figure}[!htbp]
	\begin{center}
		\frame{\includegraphics[scale=0.5,angle=0]{fig/FBM/atwork/fbm3/fbm3_line_example.pdf}}
		\caption{Example of a path on a straight line.}
		\label{fig:FBM3_line_example}
	\end{center}
\end{figure}

\begin{figure}[!htbp]
	\begin{center}
		\frame{\includegraphics[scale=0.4,angle=0]{fig/FBM/atwork/fbm3/fbm3_sine_example.pdf}}
		\caption{Example of a path on a sine.}
		\label{fig:FBM3_sine_example}
	\end{center}
\end{figure}

\begin{figure}[!htbp]
	\begin{center}
		\frame{\includegraphics[scale=0.4,angle=0]{fig/FBM/atwork/fbm3/fbm3_rotation_example.pdf}}
		\caption{Example of two different starting points, $s1$ and $s2$. Note that the orientation of the path depends on the starting point.}
		\label{fig:FBM3_rotation_example}
	\end{center}
\end{figure}

%--------------------------------------------------------------------
\subsubsection{Expected Robot Behaviour or Output}
\label{sssec:ControlOutput}

The robot is placed in front of the test area (a planar surface). The robot is required to execute the provided path in a plane above the test area that is parallel to the ground, where the height above the ground is selected by the robot. Because the robot is free to select the reference frame w.r.t. which the path is executed, it must synchronize its internal reference frame with the benchmarking system's reference frame. This is achieved by a two-step calibration procedure as described below.

Each benchmark run consists of three different phases, namely \emph{calibration}, \emph{preparation} and \emph{execution}. In the calibration phase the robot moves the tip of the marker set to an arbitrary point on top of the test area which will be used as the \emph{calibration point}. Afterwards, in the preparation phase, the robot must move the tip of the marker set by the predefined \emph{calibration distance} (see Figure \ref{fig:FBM3_line_example} and Figure \ref{fig:FBM3_sine_example}) in a self-selected direction. The position reached after that motion is defined as the \emph{starting point} of the path. Finally, in the execution phase, the robot follows the path until the end point is reached or the time runs out. After each phase, the robot notifies the CFH that it has completed the phase.

The robot-selected coordinate system is derived based on the calibration procedure in the following way:
\begin{enumerate}
	\item The \emph{x-axis} is defined as the vector from the calibration point to the starting point.
	\item The \emph{z-axis} points upwards from the test area.
	\item The \emph{y-axis} complements the right-handed coordinate system.
\end{enumerate}
Figure~\ref{fig:FBM3_rotation_example} depicts two examples of such robot-selected coordinate systems.

Notice: this task is NOT executed with a feedback from any vision sensor from the team, but only testing a pre-planned path and the online continuous path control ability of the robot!

%--------------------------------------------------------------------
\subsubsection{Procedures and Rules}
\label{sssec:ControlProcedures}

Maximum time allowed for one functionality run is 4 minutes (60 seconds for calibration, 60 seconds for preparation and 120 seconds for execution). A run consists of (1) a calibration phase where the robot moves the tip of the marker set to the calibration point; (2) a preparation phase in which the tip of the marker set travels the calibration distance and (3) an execution phase where the robot follows the path.

Note: The tip of the marker set must maintain the height of the calibration point throughout a complete run. Only the position of the marker set's tip is considered, but not the orientation of the marker set.

\begin{description}
\item[Step 1] The robot is provided with the selection of the specific path and calibration distance in advance.
\item[Step 2] The CFH tells the robot to start the calibration phase.
\item[Step 3] The robot moves the tip of the marker set to its preferred calibration point. The robot reports to the CFH that it has finished the calibration phase.
\item[Step 4] The referee manually adjusts a sheet of paper such that the calibration point on the sheet coincides with the projection of the marker set to the test area.
\item[Step 5] The CFH tells the robot to start the preparation phase.
\item[Step 6] The robot moves the tip of the marker set until the calibration distance has been traveled. The robot reports to the CFH that it has finished the preparation phase.
\item[Step 7] The referee rotates the sheet of paper (with the calibration point acting as the pivot) such that the starting point coincides with the projection of the marker set to the test area.
\item[Step 8] The CFH tells the robot to start the execution phase.
\item[Step 9] The robot follows the path with the tip of the marker set and stops at the end point of the path. The robot reports the termination of the execution phase to the CFH.
\end{description}

%--------------------------------------------------------------------
\subsubsection{Communication with CFH}
\label{sssec:CommCFHControl}

For this task benchmark the robot does not have to control any networked device in the environment. Only the communication as described below is necessary:

\begin{description}
\item[Step 1] The robot sends a \textbf{BeaconSignal} message at least every second.
\item[Step 2] The robot waits for a \textbf{BenchmarkState} message. It starts the calibration procedure when the \emph{phase} field is equal to CALIBRATION and the \emph{state} field is equal to RUNNING.
\item[Step 3] As soon as the robot reaches the calibration position, it sends a message of type \textbf{BenchmarkFeedback} to the CFH with the \emph{phase\_to\_terminate} field set to CALIBRATION. The robot should do this until the \textbf{BenchmarkState}'s \emph{phase} and \emph{state} fields have changed.
\item[Step 4] The robot waits for a \textbf{BenchmarkState} message. It starts the preparation procedure when the \emph{phase} field is equal to PREPARATION and the \emph{state} field is equal to RUNNING.
\item[Step 5] As soon as the robot reaches the preparation position, it sends a message of type \textbf{BenchmarkFeedback} to the CFH with the \emph{phase\_to\_terminate} field set to PREPARATION. The robot should do this until the \textbf{BenchmarkState}'s \emph{phase} and \emph{state} fields have changed.
\item[Step 6] The robot waits for a \textbf{BenchmarkState} message. It starts the benchmark execution when the \emph{phase} field is equal to EXECUTION and the \emph{state} field is equal to RUNNING.
\item[Step 7] As soon as the robot reaches the goal position, it sends a message of type \textbf{BenchmarkFeedback} to the CFH with the \emph{phase\_to\_terminate} field set to EXECUTION. The robot should do this until the \textbf{BenchmarkState}'s \emph{phase} and \emph{state} fields have changed.
\item[Step 8] The robot continues with Step 2.
\item[Step 9] The functionality benchmark ends when the \textbf{BenchmarkState}'s \emph{phase} field is equal to EXECUTION  and the \emph{state} field is equal to FINISHED.
\end{description}
\noindent
The messages to be sent and to be received can be seen on the Github repository located at \cite{rockin:CFHMessages}.

%--------------------------------------------------------------------
\subsubsection{Acquisition of Benchmarking Data}
\label{sssec:ControlData}

General information on the acquisition of benchmarking data is described in Section \ref{sec:TbmAcquisitionOfData}. There the \textbf{offline} part of the benchmarking data can be found.

\paragraph{Online Data} No online benchmarking data has to be sent to the CFH during this task benchmark.

\paragraph{Offline data}
The additional information described in the following table has to be logged:
\\
\begin{table}[h]
	\centering
	\begin{footnotesize}
		\begin{tabular}{|l|l|l|l|}
			\hline
			Topic				 					&	Type		&	Frame Id		&	Notes \\ \hline\hline
			/rockin/reference\_pose\tablefootnote{Pose of the gripper at the reference point.} & geometry\_msgs/PoseStamped & /base\_link & -- \\ \hline
			/rockin/starting\_pose\tablefootnote{Pose of the gripper at the starting point.} 	& geometry\_msgs/PoseStamped & /base\_link & When starting \\ \hline
			/rockin/ending\_pose\tablefootnote{Pose of the gripper at the end of the trajectory.} 	& geometry\_msgs/PoseStamped & /base\_link & When ending \\ \hline
			/rockin/gripper\_pose\tablefootnote{Pose of the gripper during the whole trajectory.} & geometry\_msgs/PoseStamped & /base\_link & 10 Hz \\ \hline
			/rockin/arm\_joints\tablefootnote{Joints data}	& geometry\_msgs/JointState & /base\_link & 10 Hz \\ \hline
		\end{tabular}
	\end{footnotesize}
\end{table}

%--------------------------------------------------------------------
\subsubsection{Scoring and Ranking}
\label{sssec:ControlScoring}

Evaluation of the performance of a robot according to this functionality benchmark is based on:

\begin{enumerate}
	\item Accuracy of following the given path with the tip of the marker
	\item Number of completely executed path movements (maximum 5);
	\item Execution time (if less than the maximum allowed for the benchmark).
\end{enumerate}

The accuracy is evaluated as follows. Given the recorded marker path executed by the robot $r(l)$, the actual ground truth path $t(l)$ and $l$ as a parameter in $[0:1]$ with
\begin{itemize}
	\item $r(l) = ( x_{r(l)}, y_{r(l)} )$ the parametric representation of the robot path
	\item $t(l) = ( x_{t(l)}, y_{t(l)} )$ the parametric representation of the target path
\end{itemize}

\noindent the accuracy is computed by

\begin{equation}
\frac{1}{N} * \sum\nolimits_{l \in L_{sampled}} d(r(l), t(l))
\end{equation}

\noindent where $L_{sampled}$ is a subset of $L_{gt}$ and $L_{gt}$ are the values of $l$ to which corresponds a measure of the robot's path from the ground truth system, $N = |L_{sampled}|$ and $d()$ is the Euclidean distance. A more detailed analysis of this measure is available in the \roaw Wiki \cite{rockin:wiki:2015}.\\

The scoring of teams is based on the accuracy with which the robot follows the given path. In case of ties the overall execution time will be taken into account.

%--------------------------------------------------------------------
% EOF
%--------------------------------------------------------------------


\newpage
\section{Unsorted Problems}

\prob{}{}{}{In $\triangle ABC$, $I$ is the incenter, $D$ is the touch point of the incenter with $BC$. $AD\cap\odot ABC\equiv X$. The tangents line from $X$ to $\odot I$ meet $\odot ABC$ at $Y,Z$. Prove that $YZ,BC$ and the tangent at $A$ to $\odot ABC$ concur.}

\prob{https://artofproblemsolving.com/community/c6h1423007p8003905}{IRAN TST 2017 Day 1, P3}{M}{	In triangle $ABC$ let $I_a$ be the $A$-excenter. Let $\omega$ be an arbitrary circle that passes through $A, I_a$ and intersects the extensions of sides $AB, AC$ (extended from $B,C$) at $X,Y$ respectively. Let $S,T$ be points on segments $I_aB, I_aC$ respectively such that $\angle AXI_a=\angle BTI_a$ and $\angle AYI_a=\angle CSI_a$. Lines $BT, CS$ intersect at $K$. Lines $KI_a, TS$ intersect at $Z$.
Prove that $X, Y, Z$ are collinear.}

\prob{https://artofproblemsolving.com/community/c182907_2015_iran_team_selection_test}{IRAN TST 2015 Day 3, P2}{}{In triangle $ABC$(with incenter $I$) let the line parallel to $BC$ from $A$ intersect circumcircle of $\triangle ABC$ at $A_1$ let $AI\cap BC=D$ and $E$ is tangency point of incircle with $BC$ let $ EA_1\cap \odot (\triangle ADE)=T$ prove that $AI=TI$.}

\fig{1}{ITST2015D3P2}{IRAN TST 2015 Day 3, P2}

\prob{http://artofproblemsolving.com/community/c6h1423742p8012916}{Generalization of Iran TST 2017 P5}{}{Let $ABC$ be triangle and the points $P, Q$ lies on the side $BC$ s.t $B, C, P, Q$ are all different. The circumcircles of triangles $ABP$ and $ACQ$ intersect again at $G$. $AG$ intersects $BC$ at $M$. The circumcircle of triangle $APQ$ intersects $AB, AC$ again at $E, F$ , respectively. $EP$ and $FQ$ intersect at $T$. The lines through $M$ and parallel to $AB, AC$, intersect $EP, FQ$ at $X, Y$, respectively. Prove that the circumcircles of triangle $TXY$ and $APQ$ are tangent to each other.}

\prob{https://artofproblemsolving.com/community/c6h535325p3070851}{ARMO 2013 Grade 11 Day 2 P4}{}{Let  $ \omega $ be the incircle of the triangle $ABC$ and with center $I$. Let $\Gamma $ be the circumcircle of the triangle $AIB$. Circles $ \omega $ and $ \Gamma $ intersect at the point $X$ and $Y$. Let $Z$ be the intersection of the common tangents of the circles $\omega$ and $\Gamma$. Show that the circumcircle of the triangle $XYZ$ is tangent to the circumcircle of the triangle $ABC$.}

\prob{https://artofproblemsolving.com/community/c6h1490457p8788075}{AoPS}{}{Let $ABC$ be a triangle with incircle $(I)$ and $A$-excircle $(I_a)$. $(I), (I_a)$ are tangent to $BC$ at $D,P$, respectively. Let $(I_1), (I_2)$ be the incircle of triangles $APC,APB$, respectively, $(J_1), (J_2)$ be the reflections of $(I_1), (I_2)$ wrt midpoints of $AC,AB$. Prove that $AD$ is the radical axis of $(J_1)$ and $(J_2)$.}

\prob{https://artofproblemsolving.com/community/c6h1491448p8781804}{AoPS}{}{Let $ABC$ be a $A-$right-angled triangle and $MNPQ$ a square inscribed into it, with $M,N$ onto $BC$ in order $B-M-N-C$, and $P,Q$ onto $CA, AB$ respectively. Let $R=BP\cap QM, S=CQ\cap PN$. Prove that $AR=AS$ and $RS$ is perpendicular to the $A-$inner angle bisector of $\triangle ABC$.}

\prob{https://artofproblemsolving.com/community/c6h282732}{AoPS}{}{$P$ is an arbitrary point on the plane of $\triangle ABC$ and let $\triangle A'B'C'$ be the cevian triangle of $P$ WRT $\triangle ABC.$ The circles $\odot (ABB')$ and $\odot (ACC')$ meet at $A,X.$ Similarly, define the points $Y$ and $Z$ WRT $B$ and $C.$ Prove that the lines $ AX,BY,CZ$ concur at the isogonal conjugate of the complement of $P$ WRT $ \triangle ABC.$}

\prob{https://artofproblemsolving.com/community/c6h108111p8724592}{AoPS}{}{Given are $\triangle ABC, L$ is Lemoine point,$L_{a},L_{b},L_{c}$ are three Lemoine point of triangles $LBC,LCA,LAB$ prove that $AL_{a},BL_{b},CL_{a}$ are concurrent!

A question: What is the locus of point $P$ such that $AL_{a},BL_{b},CL_{a}$ are concurrent with $L_{a},L_{b},L_{c}$ are three `Lemoine points' of triangles $PBC, PCA, PAB$?}

\prob{https://artofproblemsolving.com/community/c6h1432386p8088082}{AoPS}{}{Let $ABC$ be a triangle inscribed circle $(O)$. Let $(O')$ be the circle wich is tangent to the circle $(O)$ and the sides $CA, AB$ at $D$ and $E, F$, respectively. The line $BC$ intersects the tangent line at $A$ of $(O)$, $EF$ and $AO'$ at $T, S$ and $L$, respectively. The circle $(O)$ intersects $AS$ again at $K$. Prove that the circumcenter of triangle $AKL$ lies on the circumcircle of triangle $ADT$.}

\prob{}{}{}{Let $P$ and $Q$ be isogonal conjugates of each other. Let $\triangle XYZ, \triangle KLM$ be the pedal triangles of $P$ and $Q$ wrt $\triangle ABC$. ($X,K$ lie on $BC$; $Y,L$ lie on $CA$; $Z,M$ lie on $AB$) Prove that $YM,ZL,PQ$ are concurrent.}

\prob{}{2nd Olympiad of Metropolises}{}{Let $ABCDEF$ be a convex hexagon which has an inscribed circle and a circumscribed circle. Denote by $\omega_A,\ \omega_B,\ \omega_C,\  \omega_D,\ \omega_E$, and $\omega_F$ the inscribed circles of the triangles $FAB,ABC,BCD,CDE,DEF$,and $EFA$,respectively. Let $l_{AB}$ be the external common tangent of $\omega_A$ and $\omega_B$ other than the line $AB$; lines $l_{BC},l_{CD},l_{DE},l_{EF}$, and $l_{FA}$ are analogously defined. Let $A_1$ be the intersection point of the lines $l_{FA}$ and $l_{AB}$; $B_1$ be the intersection point of the lines $l_{AB}$ and $l_{BC}$; points $C_1,D_1,E_1$, and $F1$ are analogously defined. Suppose that $A_1 B_1 C_1 D_1 E_1 F_1$ is a convex hexagon. Show that its diagonals $A_1 D_1, B_1 E_1$, and $C_1 F_1$ meet at a single point.}

\prob{https://artofproblemsolving.com/community/c6h1480719p8639316}{ISL 2016 G6}{}{Let $ABCD$ be a convex quadrilateral with $\angle ABC = \angle ADC < 90^{\circ}$. The internal angle bisectors of $\angle ABC$ and $\angle ADC$ meet $AC$ at $E$ and $F$ respectively, and meet each other at point $P$. Let $M$ be the midpoint of $AC$ and let $\omega$ be the circumcircle of triangle $BPD$. Segments $BM$ and $DM$ intersect $\omega$ again at $X$ and $Y$ respectively. Denote by $Q$ the intersection point of lines $XE$ and $YF$. Prove that $PQ \perp AC$.}


\documentclass[a4paper]{article}

\def\ntitle{Galois Theory}

\input{header}

\begin{document}

\maketitle

\tableofcontents

\section{Basic Definitions}

\begin{definition}
    $\aut(K/F) := \{\sigma \in \aut(K): \sigma|_F = \id \}$
\end{definition}

$\sigma \in \aut(K)$ always fixes its \emph{prime subfield} so e.g. $\aut(\mathbb{R}) = \aut(\mathbb{R}/\mathbb{Q})$

\begin{proposition}
  \label{prop:permutation}
    Given $K/F$, $\alpha \in K$ algebraic over $F$, $\forall\sigma \in \aut(K/F)$, $\sigma\alpha$ is also a root of the minimal polynomial, i.e. $\sigma$ permutates the roots of the minimal polynomial.
\end{proposition}

$\sigma \in \aut(K/F)$ is completely determined by what it does to the generators of $K$. If $K/F$ is finite then $\aut(K/F)$ is finite.

\begin{proposition}
    Given $H \leq \aut(K)$, the \emph{fixed field of $H$} $F := \{\alpha \in K:\forall\sigma \in H, \sigma\alpha = \alpha\}$ is a subfield of $K$.
\end{proposition}

Actually, given any $S \subseteq \aut(K), F_S = F_{\langle S \rangle} \leq K$.

\begin{proposition}
    The association of the group to fields and fields to group is inclusion reversing, namely

    \begin{enumerate}
        \item if $F_1 \leq F_2 \leq K$ are two subfields of $K$ then $\aut(K/F_2) \leq \aut(K/F_1)$, and
        \item if $H_1 \leq H_2 \leq \aut(K)$ are two subgroups of automorphisms with associated subfield $F_1$ and $F_2$ then $F_2 \leq F_1$
    \end{enumerate}

\end{proposition}

Let $F$ be a field and $E$ be the splitting field over $F$ of $f(x) \in F[x]$. Given any isomorphism $\phi: F \rightarrow F'$, it can be extended to an isomorphism $\sigma: E \rightarrow E'$ where $E'$ is the splitting field for $f'(x) = \phi(f(x)) \in F'[x]$.

We now show by induction on $[E : F]$ that the number of such extensions is at most $[E : F]$, with equality if $f(x)$ is separable over $F$.

If $[E : F] = 1$ then $E = F, E' = F', \sigma = \phi$ and the number of extensions is $1$. If $[E : F] > 1$ then $f(x)$ has at least one irreducible factor $p(x)$ of degree larger than $1$ with corresponding irreducible factor $p'(x)$ of $f'(x)$. Let $\alpha$ be a fixed root of $p(x)$. If $\sigma$ is any extension of $\phi$ to $E$, then $\sigma|_{F(\alpha)}$ is an isomorphism $\tau$ of $F(\alpha)$ with some subfields of $E'$. The isomorphism $\tau$ is completely determined by its action on $\alpha$, i.e. $\tau\alpha$. Thus we have the diagram
\[
  \begin{tikzcd}
    F \arrow{r}{\sim}[swap]{\phi} \arrow[hook]{d} & F' \arrow[hook]{d}\\
    F(\alpha) \arrow{r}{\sim}[swap]{\tau} \arrow[hook]{d} & F(\beta) \arrow[hook]{d}\\
    E \arrow{r}{\sim}[swap]{\sigma} & E'
  \end{tikzcd}
\]

Conversely, for any $\beta$ a root of $p'(x)$ there are extensions $\tau$ and $\sigma$ giving such a diagram. Hence to count the number of extensions $\sigma$ we need only count the possible number of these diagrams.

The number of extensions of $\phi$ to $\tau$ is equal to the number of distinct roots of $\beta$ of $p'(x)$. Since the degree of $p(x)$ and $p'(x)$ are both equal to $[F(\alpha) : F]$, we see that the number of extensions of $\phi$ to a $\tau$ is at most $[F(\alpha) : F]$, with equality if the roots of $p(x)$ are distinct.

Since $E$ is also the splitting field of $f(x)$ over $F(\alpha)$, $E'$ is the splitting field of $f'(x)$ over $F(\beta)$, and $[E : F(\alpha)] < [E : F]$, we may apply our induction hypothesis to these field extensions. By induction, the number of extensions of $\tau$ to $\sigma$ is at most $[E : F(\alpha)]$, with equality if $f(x)$ has distinct roots.

From $[E : F] = [E: F(\alpha)] [F(\alpha) : F]$ it follows that the number of extensions of $\phi$ to $\sigma$ is at most $[E : F]$, equality if $p(x)$ and $f(x)$ have distinct roots. Since $p(x)$ is a factor of $f(x)$, it is equaivalent to $f(x)$ having distinct roots.

In the particular case when $F = F'$ and $\phi$ is identity we have:

\begin{proposition}
    Let $E$ be a splitting field over $F$ of the polynomial $f(x) \in F[x]$, then
    \[
        |\aut(E/F)| \leq [E : F]
    \]

    with equality if $f(x)$ is separable over $F$.
\end{proposition}

\begin{definition}
    Let $K/F$ be a finite extension. Then $K$ is said to be \emph{Galois} over $F$ and $K/F$ is a \emph{Galois extension} if $|\aut(K/F)| = [K : F]$. If $K/F$ is Galois the group $\aut(K/F)$ is called the \emph{Galois group} of $K/F$, denoted $\gal(K/F)$.
\end{definition}

\begin{corollary}
    If $K$ is a splitting field over $F$ of a separable polynomial $f(x)$ then $K/F$ is Galois.
\end{corollary}

Note that the corollary implies that \emph{the splitting field of any polynomial $f(x)$ over a perfect field is Galois}, since the splitting field of $f(x)$ is the same as the splitting field of the product of the irreducible factors of $f(x)$ (i.e. the ``square free'' part), which is separable.

\begin{definition}
    If $f(x)$ is a separable polynomial over $F$, then the \emph{Galois group of $f(x)$ over $F$} is the Galois group of the splitting field of $f(x)$ over $F$.
\end{definition}

\begin{eg}
    \begin{enumerate}
        \item $\gal(\mathbb{Q}(\sqrt 2)/\mathbb{Q}) = \langle \sigma \rangle \cong C_2$ where $\sigma: a + b \sqrt 2 \mapsto a - b \sqrt 2$.
        \item More generally, any quadratic $K$ of any field $F$ of characteristic different from $2$ is Galois.
        \item $\mathbb{Q}(\sqrt[3] 2)/\mathbb{Q}$ is not Galois since its group of automorphism is trivial.
        \item $\mathbb{Q}(\sqrt 2, \sqrt 3)/\mathbb{Q}$ is Galois since it is the splitting field of $(x^2 - 2)(x^2 - 3)$. Any automorphism $\sigma$ is completely determined by its action on the generators $\sqrt 2$ and $\sqrt 3$, which must be mapped to $\pm 2$ and $\pm 3$ respectively. We can find $\gal(\mathbb{Q}(\sqrt 2, \sqrt 3)/\mathbb{Q}) = \langle \sigma, \tau \rangle \cong C_2^2$ where $\sigma:\sqrt 2 \mapsto \sqrt 2, \sqrt 3 \mapsto -\sqrt 3$ and $\tau: \sqrt 2 \mapsto -\sqrt 2, \sqrt 3 \mapsto \sqrt 3$.
        \item The splitting field of $x^3 - 2$ over $\mathbb{Q}$ $\mathbb{Q}(\sqrt[3] 2, \zeta_3 \sqrt[3] 2) \cong \mathbb{Q}(\sqrt[3] 2, \zeta_3)$ is Galois over $\mathbb{Q}$ with $\gal(\mathbb{Q}(\sqrt[3] 2, \zeta_3)/\mathbb{Q}) \cong S_3$.
        \item Galois extension is not transitive. Consider
        \[
            \overbrace{\underbrace{\mathbb{Q} \leq \mathbb{Q}}_2\underbrace{(\sqrt 2) \leq \mathbb{Q}(\sqrt[4] 2)}_2}^4,
        \]
        both quadratic extensions are Galois but $\mathbb{Q}(\sqrt[4] 2)$ is not Galois over $\mathbb{Q}$ since only two of $\{\pm \sqrt[4] 2, \pm i \sqrt[4] 2\}$ are elements of the field.
        \item $\mathbb F_{p^n}/\mathbb F_p$ is Galois since it is the splitting field of $x^{p^n} - x$. $\sigma_p: \mathbb F_{p^n} \rightarrow F_{p^n}, \alpha \mapsto \alpha^p$ is call the \emph{Frobenius automorphism} of the finite field. Since $\forall\alpha,\: \sigma_p^i(\alpha) = \alpha^{p^i}$, $\alpha^{p^n} = \alpha$, so $\sigma_p^n = 1$. No lower power can be the identity, since this would imply $\alpha^{p^i} = \alpha$ for all $\alpha \in \mathbb F_{p^n}$ for some $i < n$, which is impossible since the equation has at most $p^i$ roots. Thus $\gal(\mathbb F_{p^n}/\mathbb F_p) = \langle \sigma_p \rangle \cong C_n$.
        \item The inseparable extension $\mathbb F_2(x)/\mathbb F_2(t)$ where $x^2 - t = 0$ is not Galois.
    \end{enumerate}
\end{eg}

\section{The Fundamental Theorem of Galois Theory}
There is a correspondence between the lattice of subgroups of a Galois group and subfields of the extension field. The Fundamental Theorem of Galois Theory states that the relations are not conincidental and hold for any Galois extension. We first introduce \emph{group characters}:

\begin{definition}
    A \emph{character} $\chi$ of a group $G$ with values in a field $L$ is a homomorphism from $G$ to the multiplicative group of $L$:
    \[
        \chi: G \rightarrow L^\times
    \]
\end{definition}

\begin{definition}
    The characters $\chi_1, \chi_2, \ldots \chi_n$ of $G$ are said to be \emph{linearly independent} over $L$ is they are linearly independent as functions on $G$, i.e. if there is no nontrivial relation
    \[
        a_1 \chi_1 + a_2 \chi_2 + \cdots a_n \chi_n = 0
    \]
\end{definition}

\begin{theorem}[Linear Independence of Characters]
    If $\chi_1, \chi_2, \ldots \chi_n$ are distinct characters of $G$ with values in $L$ then they are linearly independent over $L$.
\end{theorem}

\begin{proof}
    Suppose there is a counterexample with minimal number $m$ of nonzero coefficients $a_i$. Wlog suppose
    \[
        \sum_{i=1}^m a_i \chi_i = 0
    \]
    Then for any $g \in G$ we have
    \[
        \sum_{i=1}^m a_i \chi_i(g) = 0
    \]
    Let $g_0$ be an element s.t. $\chi_1(g_0) ≠ \chi_m(g_0)$ (since $\chi_1$ and $\chi_m$ are distinct). Then
    \[
        \sum_{i=1}^m a_i \chi_i(g_0 g) = \sum_{i=1}^m a_i \chi_i(g_0) \chi_i(g) = 0
    \]
    Multiply and subtract the first equation to get
    \[
        \sum_{i=1}^{m-1} (\chi_m(g_0) - \chi_i(g_0))a_i \chi_i(g) = 0
    \]
    Since the first coefficient if nonzero this is a relation with fewer than $m$ nonzero coefficients. Contradiction.
\end{proof}

An injective homomorphism of a field $K$ into a field $L$ is called an \emph{embedding} of $K$ into $L$.

\begin{corollary}
  If $\sigma_1, \sigma_2, \ldots \sigma_n$ are distinct embeddings of a field $K$ into a field $L$, then they are linearly independent as funcrions on $K$. In particular distinct automorphisms of a field $K$ are linearly independent.
\end{corollary}

\begin{theorem}\label{thm:degree of fixed field}
  Let $G = \{\sigma_1=1, \sigma_2,\ldots, \sigma_n\}$ be a subgroup of automorphisms of a field $K$ and let $F$ be its fixed field. Then
  \[ [K:F] = n = |G| \]
\end{theorem}

\begin{proof}
  \texttt{to be filled in}
\end{proof}

\begin{corollary}
  \label{cor:upper bound of order of aut group}
  Let $K/F$ be a finite extension. Then
  \[ |\aut(K/F)| \leq [K:F] \]
  with equality iff $F$ is the fixed field of $\aut(K/F)$. In other words, $K/F$ is Galois iff $F$ is the fixed field of $\aut(K/F)$.
\end{corollary}

\begin{proof}
  Let $F_1$ be the fixed field of $\aut(K/F)$, so that
  \[ F \subseteq F_1 \subseteq K. \]
  By Theorem \ref{thm:degree of fixed field}, $[K:F] = [K:F_1][F_1:F] = |\aut(K/F)| [F_1:F]$.
\end{proof}

\begin{corollary}\label{cor:galois group cor}
  Let $G \leq \aut(K)$ be finite and let $F$ be its fixed subfield. Then $\aut(K/F) = G$, so $K/F$ is Galois with Galois group $G$.
\end{corollary}

\begin{proof}
  Since $G \leq \aut(K/F)$, $|G| \leq |\aut(K/F)|$. From Theorem \ref{thm:degree of fixed field} $|G| = [K:F]$ and from Corollary \ref{cor:galois group cor} $|\aut(K/F)| \leq [K:F]$ so
  \[ [K:F] = |G| \leq |\aut(K/F)| \leq [K:F] \]

  and it follows that we have equalities throughout.
\end{proof}

\begin{corollary}
  \label{cor:unique fixed field}
  If $G_1 \neq G_2$ are two distinct finite subgroups of $\aut(K)$ then their fxed fixed fields are also distinct.
\end{corollary}

\begin{proof}
  Let $F_1$ and $F_2$ be their fixed fields respectively. If $F_1 = F_2$ then $F_1$ is fixed by $G_2$. Thus By the previous corollary $G_2 \leq G_1$. Same argrument shows $G_1 \leq G_2$.
\end{proof}

\begin{theorem}
  \label{thm:characterisation of galois extension}
  The extension $K/F$ is Galois iff $K$ is the splitting field of some separable polynomial over $F$. In this case every irreducible polynomial with coefficients in $F$ which has a root in $K$ is separable and has all its roots in $K$ (so in particular $K/F$ is a separable extension).
\end{theorem}

\begin{proof}
  We first show that if $K/F$ is Galois then every irreducible polynomial $p(x) \in F[x]$ having a root in $K$ splits completely in $K[x]$. Let $G = \gal(K/F) = \{1, \sigma_2,\ldots,\sigma_n\}$. Let $\alpha \in K$ be a root of $p(x)$ and consider the elements
  \[ \alpha, \sigma_2(\alpha),\ldots, \sigma_n(\alpha) \]
  Let $\alpha, \alpha_2,\ldots,\alpha_r$ be \emph{distinct} elements. Give $\tau \in G$, since $G$ is a group the elements $\{\tau, \tau\sigma_2,\ldots,\tau\sigma_n\}$ are the same as $\{1,\sigma_2,\ldots,\sigma_n\}$. Thus applying $\tau$ to the elements simply permutes them. The polynomial
  \[ f(x) = (x-\alpha) (x-\alpha_2)\cdots (x-\alpha_r) \]
  therefore has coefficients whihc are fixed by all elements of $G$. Thus the coefficients lie in $F$, the fixed field of $G$. Since $p(x)$ is irreducible and has $\alpha$ as a root it is the minimal polynomial for $\alpha$ so $p(x)$ divides $f(x)$ in $F[x]$. On the other hand by Propsition \ref{prop:permutation} $f(x)$ divides $p(x)$ in $K[x]$ so $p(x) = f(x)$. In particular $p(x)$ is separable and all its roots lies in $K$.

  To show the first part, suppose $K/F$ is Galois and let $\{\omega_i\}_{i=1}^n$ be a basis for $K/F$. Let $p_i(x)$ be the minimal polynomial for $\omega_i$ over $F$, which is separable and has all its roots in $K$. Let $g(x)$ be the ``square free'' part of their products. Then the splitting field of the two polynomials is the same, which is $K$ (shown by demonstrating inclusion both ways). Thus $K$ is the splitting field of the separable polynomial $g(x)$.
\end{proof}

\begin{definition}
  Let $K/F$ be a Galois extension. If $\alpha \in F$ then the elements $\sigma\alpha$ for $\sigma \in \gal(K/F)$ are called the \emph{(Galois) conjugates} of $\alpha$ over $F$. If $F \subseteq E \subseteq K$ is a subfield then $\sigma(E)$ is the \emph{conjugate field} of $E$ over $F$.
\end{definition}

\begin{theorem}[Fundamental Theorem of Galois Theory]
  Let $K/F$ be a Galois extension and $G := \gal(K/F)$. Then there is a bijection
  \[
    \left\{
      \begin{array}[h]{c}
        \text{subfields } \\
        E\: \text{of } K \\
        \text{containing } F
      \end{array}
      \begin{array}[h]{c}
        K \\
        | \\
        E \\
        | \\
        F
      \end{array}
    \right\}
    \longleftrightarrow
    \left\{
      \begin{array}[h]{c}
        \text{subgroups } \\
        H \: \text{of } G
      \end{array}
      \begin{array}[h]{c}
        1 \\
        | \\
        H \\
        | \\
        G
      \end{array}
      \right\}
  \]

  given by
  \begin{align*}
    E & \mapsto \{\sigma \in G: \sigma \: \text{fixes } E\} \\
    \{\text{fixed field of } H\} & \mapsfrom H
  \end{align*}
  which are inverses to each other, with the following properties:
  \begin{enumerate}
  \item order reversing,
  \item $[K:E] = |H|$ and $[E:F] = |G/H|$, the index of $H$ in $G$,
  \item $K/E$ is Galois with $\gal(K/E) \cong H$,
  \item $E$ is Galois over $F$ iff $H \trianglelefteq G$. In this case $\gal(E/F) \cong G/H$. More generally, even if $H$ is not necessarily normal in $G$, the isomorphisms of $E$ (into a fixed algebraic closure of $F$ containing $K$) which fix $F$ are in bijection with $G/H$, the set of cosets of $H$ in $G$.
  \item the lattice of subfields is dual to the lattice of subgroups: if $E_1, E_2$ correspond to $H_1, H_2$ respectively, then the intersection $E_1 \cap E_2$ corresponds to the group $\langle H_1, H_2 \rangle$ generated by $H_1$ and $H_2$ and the composite field $E_1E_2$ corresponds to the intersection $H_1 \cap H_2$.
  \end{enumerate}
\end{theorem}

\begin{proof}
  Given any $H \leq G$ there is a unique fixed field by Corollary \ref{cor:unique fixed field} so the map is injective from right to left.

  If $K$ is the splitting field of a separable polynomial $f(x) \in F[x]$ then $K$ is also the splitting field of $f(x) \in E[x]$ so $K/E$ is Galois. By Corollary \ref{cor:upper bound of order of aut group}, $E$ is the fixed field of $\aut(K/E) \leq G$, showing that the map is surjective from right to left. By Corollary \ref{cor:upper bound of order of aut group} the maps are inverses to each other.

  By Theorem \ref{thm:degree of fixed field} $[K:E] = H$ and taking quotients gives $[E:F] = |G/H|$.

  Now we prove that $\emb(E/F)$, the set of embeddings of E into $\bar F$, the algebraic closure of $F$, which fixed $F$ is precisely $\{ \sigma|_E: \sigma \in G \}$. One direction of inclusion is clear. To prove the other inclusion, suppose $\tau : E \rightarrow \tau(E) \subseteq \bar F$ fixes $F$. We show $\tau(E) \subseteq K$: given $\alpha \in E$ with minimal polynomial $m_\alpha(x)$ over $F$, $\tau(\alpha)$ is another root of $m_\alpha(x)$ and $K$ contains all these roots by Theorem \ref{thm:characterisation of galois extension}. Since as above $K$ is the splitting field of $f(x)$ over $E$, it is also the splitting field of $\tau f(x)$. Thus we have the extension
  \[
    \begin{tikzcd}
      E \arrow{r}{\sim}[swap]{\tau} \arrow[hook]{d} & \tau(E) \arrow[hook]{d} \\
      K \arrow{r}{\sim}[swap]{\sigma} & K
    \end{tikzcd}
  \]
  and moreover $\sigma|_F = \tau|_F = \id$ so $\sigma \in G$. Thus every embedding of $E$ is of the form $\sigma|_E$ for some $\sigma \in G$.

  $\sigma, \sigma' \in G$ restrict to the same embedding of $E$ iff $\sigma^{-1} \sigma' |_E = \id$, so $\sigma^{-1} \sigma' \in H$. Thus there is a bijection between the embeddings and the cosets
  \[ \emb(E/F) \longleftrightarrow G/H. \]
  Note that $\aut(E/F) \subseteq \emb(E/F)$.

  The extension $E/F$ is Galois iff $|\aut(E/F)| = [E:F] = |\emb(E/F)|$, i.e. for every $\sigma \in G$, $\sigma(E) = E$. Now use the fact from group theory that conjugacy of stabiliser is the stabiliser of orbit, the subgroup fixing $\sigma(E)$ is precisely $\sigma H \sigma^{-1}$. Thus $\sigma(E) = E$ for all $\sigma \in G$ iff $\sigma H \sigma^{-1} = H$, i.e. $H \trianglelefteq G$. In this case the identification of the group structure of the cosets translates to the Galois group $\gal(E/F)$.

  Finally noting that elements in the composite field $E_1E_2$ are algebraic combinations of the elements of $E_1$ and $E_2$, the last part is easy to see.
\end{proof}

\begin{eg}[Splitting field of $x^8 - 2$]
  The splitting field of $x^8 - 2$ over $\mathbb{Q}$ is generated by $\theta = \sqrt[8] 2$ and a primitive $8$th root of unity $\zeta = \zeta_8$. Since $\mathbb{Q}(\zeta_8) = \mathbb{Q}(i, \sqrt 2)$ and $\theta^4 = \sqrt 2$ the splitting field is generated by $\theta$ and $i$. From
  \[ \mathbb{Q} \subseteq \mathbb{Q}(\theta) \subseteq \mathbb{Q}(\theta, i) = \mathbb{Q}(\theta, \zeta_8) \]
  we see the extension is of degree $16$. The Galois group is determined by its action on the generators $\theta$ and $i$ which gives the possibilities
  \[
    \begin{cases}
      \theta \mapsto \zeta^m \theta & m = 0, 1, \ldots, 7 \\
      i \mapsto \pm i
    \end{cases}
  \]
  Since the degree of the extionsion is $16$ and there are only $16$ such maps, it follows that each of the mpas above is an element of $\gal(\mathbb{Q}(\theta, i)/\mathbb{Q})$.

  Define two elements
  \[
    \sigma:
    \begin{cases}
      \theta \mapsto \zeta\theta \\
      i \mapsto i
    \end{cases}
    \qquad
    \tau:
    \begin{cases}
      \theta \mapsto \theta \\
      i \mapsto -i
    \end{cases}
  \]

  To facilitate computation we write
  \[ \zeta = \zeta_8 = \frac{1}{2}(1+i) \sqrt 2 = \frac{1}{2}(1+i) \theta^4 \]
  and from which we compute the following automorphisms:
  \begin{center}
    \begin{tabular}[h]{c c c c||c c c c}
       & $\theta$ & $i$ & $\zeta$ & & $\theta$ & $i$ & $\zeta$ \\
      \hline
      1 & $\theta$ & $i$ & $\zeta$ & $\tau$ & $\theta$ & $-i$ & $\zeta^7$ \\
      \hline
      $\sigma$ & $\zeta\theta$ & $i$ & $\zeta^5$ & $\tau\sigma$ & $\zeta^7 \theta$ & $-i$ & $\zeta^3$ \\
      \hline
      $\sigma^2$ & $\zeta^6\theta$ & $i$ & $\zeta$ & $\tau\sigma^2$ & $\zeta^2\sigma$ & $-i$ & $\theta^7$ \\
      \hline
      $\sigma^3$ & $\zeta^7\theta$ & $i$ & $-\zeta$ & $\tau\sigma^3$ & $\zeta\theta$ & $-i$ & $\zeta^3$ \\
      \hline
      $\sigma^4$ & $-\theta$ & $i$ & $\zeta$ & $\tau\sigma^4$ & $-\theta$ & $-i$ & $\zeta^7$ \\
      \hline
      $\sigma^5$ & $\zeta^5\theta$ & $i$ & $-\zeta$ & $\tau\sigma^5$ & $\zeta^3\theta$ & $-i$ & $\zeta^3$ \\
      \hline
      $\sigma^6$ & $\zeta^2\theta$ & $i$ & $\zeta$ & $\tau\sigma^6$ & $\zeta^6\theta$ & $-i$ & $\zeta^7$ \\
      \hline
      $\sigma^7$ & $\zeta^3\theta$ & $i$ & $-\zeta$ & $\tau\sigma^7$ & $\zeta^5\theta$ & $-i$ & $\zeta^3$ \\
      \hline
    \end{tabular}
  \end{center}

  By counting argument $\sigma$ and $\tau$ generate the Galois gropu. To determine the relation, first note that
  \[ \sigma^8 = \tau^2 = 1.\]
  Also we have
  \[ \sigma\tau = \tau\sigma^3.\]

  We can deduce that these relations define the group completely so
  \[ \gal(\mathbb{Q}(\sqrt[8] 2,i)/\mathbb{Q}) = \langle \sigma, \tau | \sigma^8 = \tau^2 = 1, \sigma\tau = \tau\sigma^3 \rangle\]
  which is a \emph{quasidihedral group} which is a subgroup of $S_8$.
\end{eg}

\begin{remark}
  The example illustrates that one must take care in determining Galois groups from the actions on generators. Had we proceeded directly from the original generators $\theta = \sqrt[8] 2$ and $\zeta = \zeta_8$ we might have incorrectly concluded that there were a total of $32$ elements in the Galois group. The problem is that these choices are not independent, due to the relation
  \[ \theta^4 = \sqrt 2 = \zeta + \zeta^7 \]
  which shows that one cannot specify the images of $\theta$ and $\zeta$ independently.

  It is thus necessary to provide justification that maps are automorphisms. This can be accomplished, for example, by using the extension theorems or by using degree considerations as we did here.
\end{remark}

\section{Finite Fields}

The field $\mathbb F_{p^n}$ is Glaois over $\mathbb F_p$, with cyclic Galois group of order $n$:
\[
  \gal(\mathbb F_{p^n} / \mathbb F_p) = \langle\sigma_p\rangle \cong \mathbb{Z}/n\mathbb{Z}
\]
where
\begin{align*}
  \sigma_p : \mathbb F_{p^n} & \rightarrow \mathbb F_{p^n} \\
  \alpha & \mapsto \alpha^p
\end{align*}

Since the Galois group is abelian, every subgroup is normal, so each of the subfields $\mathbb F_{p^d}$ where $d|n$ is Galois over $\mathbb F_p$.

\begin{proposition}
  Any finite field is isomorphic to $\mathbb F_{p^n}$ for some prime $p$ and some integrer $n \geq 1$. The field $\mathbb F_{p^n}$ is the splitting field over $\mathbb F_p$ of the polynomial $x^{p^n}-x$, with cyclic Galois group of order $n$ generated by the Frobenius automorphism $\sigma_p$. The subfields of $\mathbb F_{p^n}$ are all Galois over $\mathbb F_p$ and are in bijection with the divisors $d$ of $n$. They are the fields of $\mathbb F_{p^d}$, the fixed fields of $\sigma^d_p$.
\end{proposition}

\begin{corollary}
  The irreducible polynomial $x^4+1 \in \mathbb{Z}[x]$ is reducible modulo every prime $p$.
\end{corollary}

\begin{proof}
  Consider the polynomial $x^4+1 \in \mathbb F_p[x]$ for prime $p$. If $p = 2$ then $x^4 + 1 = (x+1)^4$ so reducible. Assume now that $p$ is odd. Then $p^2-1 \equiv 0 \mod 8$. Thus
  \[
    x^4+1 | x^8-1 | x^{p^2-1}-1 | x^{p^2}-x
  \]
  which shows that all the roots of $x^4+1$ are roots of $x^{p^2}-x$. Thus the extension generated by any root of $x^4+1$ is at most of degree $2$ over $\mathbb F_p$, so $x^4+1$ cannot be irreducible.
\end{proof}

The multiplicative group $\mathbb F_{p^n}^\times$ is finite so cyclic. Let $\theta$ be any generator, then $\mathbb F_{p^n} = \mathbb F_p(\theta)$. Thus

\begin{proposition}
  $\mathbb F_{p^n}$ is simple. In particular, there exists an irreducivle polynomial of degree $n$ over $\mathbb F_p$ for every $n \geq 1$.
\end{proposition}

Thus $\mathbb F_{p^n}$ can both be seen as the splitting field of $x^{p^n}-x$ over $\mathbb F_p$ and the quotient of $\mathbb F_p$ by the minimal polynomial of $\theta$. As $\theta$ is a root of $x^{p^n}-x$, the minimal polynomial is a divisor of $x^{p^n}-x$ of degree $n$.

Conversely, let $p(x)$ be irreducible of degree $d$ and divide $x^{p^n}-x$. If $\alpha$ is a root of $p(x)$ then $\mathbb F(\alpha)$ is a subfield of $\mathbb F_{p^n}$ of degree $d$. Thus $d|n$ and the extension if Galois by the previous proposition so all the roots of $p(x)$ are contained in $\mathbb F_p(\alpha)$. Thus if we gather all factors of $x^{p^n}-x$ in $\mathbb F_{p^n}$ according to the degree $d$ of their minimal polynomails ofver $\mathbb F_p$, then

\begin{proposition}
  The polynomial $x^{p^n}-x$ is precisely the product of all the distinct irreducible polynomials in $\mathbb F_p[x]$ of degree $d$ where $d|n$.
\end{proposition}

\begin{eg}
  The finite field $\mathbb F_{p^n}$ is unique up to isomorphism. If $f_1(x)$ and $f_2(x)$ are irreducible of degree $n$, then $f_2(x)$ splits completely in the field $\mathbb F_{p^n} \cong \mathbb F_p[x]/(f_1(x))$. If we denote a root of $f_2(x)$ by $\alpha(x)$, the isomorphism is given by
  \begin{align*}
    \mathbb F_p[x]/(f_2(x)) & \cong \mathbb F_p[x]/(f_1(x)) \\
    x & \mapsto \alpha(x)
  \end{align*}

  For example, if $f_1(x) = x^4+x^3+1, f_2(x) = x^4+x+1$ are two irreducible over $\mathbb F_2$ then $x \mapsto \alpha(x) = x^3+x^2$ gives an isomorphism.
\end{eg}

We can give a formula for the number of irreducible polynomials of degree $n$ using result from elementary number theory.

\begin{definition}
  The \emph{M\"obius $\mu$-function} is definded by
  \[
    \mu (n) =
  \begin{cases}
    1 & \text{for } n = 1 \\
    0 & \text{if $n$ has a square factor} \\
    (-1)^r & \text{if $n$ has $r$ distinct prime factors}
  \end{cases}
  \]
\end{definition}

Given $f(n)$ a function defined for all nonnegative integers $n$ and
\[
  F(n) := \sum_{d|n} f(d)
\]

then the \emph{M\"obius inversion formula} states that
\[
  f(n) = \sum_{d|n} \mu(d) F(\frac{n}{d}).
\]

Now define $\psi(n)$ to be the number of irreducible polynomials of degree $n$ in $\mathbb F_p[x]$, we have
\[
  p^n = \sum_{d|n} d\psi(d)
\]

Apply the inversion formula we get
\[
  n \psi(n) = \sum_{d|n} \mu(d) p^{n/d}
\]
so
\[
  \psi(n) = \frac{1}{n} \sum_{d|n} \mu(d) p^{n/d}.
\]

Given two finite fields $\mathbb F_{p^{n_1}}, \mathbb F_{p^{n_2}}$, $\mathbb F_{p^{n_1n_2}}$ contains both of them. This gives a partial ordering on these fields and take the union of all these finite extensions we get the algebraic closure of $\mathbb F_p$
\[
  \cl{\mathbb F_p} = \bigcup_{n\geq 1} \mathbb F_{p^n}.
\]

\iffalse
\appendix

\section{From Dexter Chua Notes}

\begin{lemma}
  Given $L/K$, $f(t) \in K[t]$ irreducible, there is a bijection between
  \[ \{ \text{roots of } f \: \text{in } L \} \longleftrightarrow \Hom_K(K[t]/(f(t)), L) \]
\end{lemma}
\fi
\end{document}