\section{Inverse Functions}\label{sec:InverseFunctions}
In mathematics, an \ifont{inverse} is a function that serves to ``undo'' another function.
That is, if $f(x)$ produces $y$, then putting $y$ into the inverse of $f$ produces the output $x$.
A function $f$ that has an inverse is called invertible and the inverse is denoted by $f^{-1}$.
It is best to illustrate inverses using an arrow diagram:
$$\includegraphics[width=3in]{images/inverse1}$$
Notice how $f$ maps $1$ to $a$, and $f^{-1}$ undoes this, that is, $f^{-1}$ maps $a$ back to $1$.
Don't confuse $f^{-1}(x)$ with exponentiation: the inverse $f^{-1}$ is \ifont{different} from $\frac{1}{f(x)}$.

Not every function has an inverse. It is easy to see that if a
function $f(x)$ is going to have an inverse, then $f(x)$
\ifont{never} takes on the same value twice. We give this property a special name.

A function $f(x)$ is called \dfont{one-to-one}  if every element of the range corresponds to \ifont{exactly} one element of the domain.
Similar to the Vertical Line Test (VLT) for functions, we have the Horizontal Line Test (HLT) for the one-to-one property.

\begin{theorem}{The Horizontal Line Test}{HorizontalLineTest}
A function is one-to-one if and only if there is no horizontal line that intersects its graph more than once.
\end{theorem}

\begin{example}{Parabola is Not One-to-one}{ParabolaNotOneOne}
The parabola $f(x)=x^2$ it not one-to-one because it does not satisfy the horizontal line test.
For example, the horizontal line $y=1$ intersects the parabola at two points, when $x=-1$ and $x=1$.
\end{example}

We now formally define the inverse of a function.

\begin{definition}{Inverse of a Function}{InverseOfAFunction}
Let $f(x)$ and $g(x)$ be two \ifont{one-to-one} functions.
If $(f\circ g)(x)=x$ and $(g\circ f)(x)=x$ then we say
that $f(x)$ and $g(x)$ are \deffont{inverses} of each other.
We denote $g(x)$ (the inverse of $f(x)$) by $g(x)=f^{-1}(x)$.
\end{definition}

Thus, if $f$ maps $x$ to $y$, then $f^{-1}$ maps $y$ back to $x$.
This gives rise to the \ifont{cancellation formulas}:
$$f^{-1}(f(x))=x,\mbox{\quad for every $x$ in the domain of $f(x)$},$$
$$f(f^{-1}(x))=x,\mbox{\quad for every $x$ in the domain of $f^{-1}(x)$}.$$

\begin{example}{Finding the Inverse at Specific Values}{FindingInverseSpecificValues}
If $f(x)=x^9+2x^7+x+1$, find $f^{-1}(5)$ and $f^{-1}(1)$.
\end{example}

\begin{solution}
Rather than trying to compute a formula for $f^{-1}$ and then computing $f^{-1}(5)$, we can simply find a number $c$ such that $f$ evaluated at $c$ gives $5$.
Note that subbing in some simple values ($x=-3,-2,1,0,1,2,3$) and evaluating $f(x)$ we eventually find that $f(1)=1^9+2(1^7)+1+1=5$ and $f(0)=1$.
Therefore, $f^{-1}(5)=1$ and $f^{-1}(1)=0$.
\end{solution}

To compute the equation of the inverse of a function we use the following \ifont{guidelines}.

\begin{formulabox}[Guidelines for Computing Inverses]
\begin{enumerate}\itemsep0pt
	\item Write down $y=f(x)$.
	\item Solve for $x$ in terms of $y$.
	\item Switch the $x$'s and $y$'s.
	\item The result is $y=f^{-1}(x)$.
\end{enumerate}
\end{formulabox}

\begin{example}{Finding the Inverse Function}{FindingInverseFunction}
We find the inverse of the function $f(x)=2x^3+1.$
\end{example}

\begin{solution}
Starting with $y=2x^3+1$ we solve for $x$ as follows:
$$y-1=2x^3\qquad\to\qquad \frac{y-1}{2}=x^3\qquad\to\qquad x=\sqrt[3]{\frac{y-1}{2}}.$$
Therefore, $\ds f^{-1}(x)=\sqrt[3]{\frac{x-1}{2}}$.
\end{solution}

This example shows how to find the inverse of a function \ifont{algebraically}.
But what about finding the inverse of a function \ifont{graphically}?
Step $3$ (switching $x$ and $y$) gives us a good graphical technique to find the inverse, namely,
for each point $(a,b)$ where $f(a)=b$, sketch the point $(b,a)$ for the inverse.
More formally, to obtain $f^{-1}(x)$ \ifont{reflect} the graph $f(x)$ about the line $y=x$.

$$\includegraphics[width=2.5in]{images/inverse2}$$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Opensolutionfile{solutions}[ex]
\section*{Exercises for \ref{sec:InverseFunctions}}

\begin{enumialphparenastyle}

%%%%%%%%%%
\begin{ex}
Is the function $f(x)=|x|$ one-to-one?
\end{ex}

%%%%%%%%%%
\begin{ex}
If $h(x)=e^x+x+1$, find $h^{-1}(2)$.
\end{ex}

%%%%%%%%%%
\begin{ex}
Find a formula for the inverse of the function $\ds{f(x)=\frac{x+2}{x-2}}$.
\end{ex}

\end{enumialphparenastyle}


\chapter{Multiscale Entropy applied to Background Fluctuation Analysis}

\section*{The mean entropy vector}

The multiscale entropy has been defined by:
\begin{eqnarray}
H(X) = \sum_{j=1}^{l}  \sum_{k=1}^{N} h(w_j)
\end{eqnarray}
with $h(w_j = \ln ( p(w_j(k))))$.
In order to study the behavior of the information at a given scale, we
prefer to calculate the mean entropy vector $E$ defined by:
\begin{eqnarray}
E(j) = \frac{1}{N}\sum_{k=1}^{N} h(w_j)
\end{eqnarray}
$E(j)$ gives the mean entropy at the scale $j$. From the mean entropy vector,
we have  statistical information on each scale separately.
Having a noise model, we are able to calculate (generally from simulations)
the mean entropy vector $E^{(noise)}(j)$ resulting from a pure noise.
Then we define the normalized mean entropy vector by
\begin{eqnarray}
E_n(j) = \frac{ E(j) }{ E^{(noise)}(j) }
\end{eqnarray}

Figure~\ref{fig_source1} shows the result of a simulation.
Five simulated images were created by adding $n$ sources (i.e., point
sources, or idealized stars) to an 1024
$\times$ 1024 image
containing Gaussian noise of standard deviation equal to 1. The $n$ sources
are identical, with a maximum equal to 1, and standard deviation equal to 2.
Defining the signal to noise ratio (SNR) as the ratio between
the standard deviation in the smallest box which contains at least 90\%
of the flux of the source, and the noise standard deviation, we have a SNR
equal to $0.25$. The sources  are not detectable in the simulated
image, nor in its wavelet transform. Figure~\ref{fig_source2} shows a region
which contains a source at the center. It is clear there is no way to find
this kind of noisy signal. The five images were created using a number
of sources
respectively equal to 0,50,100,200 and 400, and the simulation was
repeated ten times with different noise maps in order to have an error bar on
each entropy measurement. For the image which contains 400
sources, the number of pixels affected by a source is less  than $2.5$\%.

When the number of sources increases, the difference between the multiscale
entropy curves increases. Even if the sources are very faint, the presence
of signal can be clearly detected using the mean entropy vector. But it is
obvious that the positions of these sources remain unknown.

\begin{figure}[htb]
\centerline{
\vbox{
\psfig{figure=fig_source.ps,bbllx=3.5cm,bblly=13cm,bburx=19.5cm,bbury=25.5cm,width=16cm,height=12.5cm}
}}
\caption{Mean entropy versus the scale of 5 simulated images containing undetectable
sources and noise. Each curve corresponds to the multiscale transform
of one image. From
top to bottom, the image contains respectively 400,200,100, 50 and 0 sources.}
\label{fig_source1}
\end{figure}

\begin{figure}[htb]
\centerline{
\vbox{
\psfig{figure=fig_1source.ps,bbllx=1.8cm,bblly=12.9cm,bburx=14.5cm,bbury=25.5cm,width=8cm,height=8cm,clip=}
}}
\caption{Region of a simulated image containing an undetectable source at the
center.}
\label{fig_source2}
\end{figure}


%!TEX root = ../TTK18-Summary.tex
\section{Preliminaries}

% \subsection{KKT conditions}
% Yada yada yada.

\subsection{Lyapunov stability}

\paragraph{Continuous systems}
If there exists a $P > 0$ satisfying
\begin{equation}
  A\tp P + PA < 0,
\end{equation}
then the system $\dot{x} = Ax$ is globally asymptotically stable.

\paragraph{Discrete-time systems}
If there exists a $P > 0$ satisfying
\begin{equation}
  A\tp P A - P < 0,
\end{equation}
then the system $x_{k+1} = Ax_k$ is globally asymptotically stable.

TTK18 Optimaliseringsbasert reguleringsdesign og analyse/tex/sec-preliminaries.tex


\chapter{An algebraic formalism for Multi-instance learning}

\VUname{Multi-instance learning} is a class of machine learning algorithms, first described by \cite{dietterich_solving_1997}, that can be used for both \VUname{supervised} (see \cite{amores_multiple_2013}) as well as \VUname{unsupervised} (see \cite{zhang_multi-instance_2009}, \cite{chen_contextual_2012}) learning. While classical machine learning algorithms typically require a sample to be represented as a vector of numbers, multi-instance learning relaxes this requirement by representing a sample as a \VUname{bag} of an arbitrary number of objects with a singular label for the whole bag. \cite{dedic_hierarchicke_2017} describes a novel approach to the formalization of multi-instance learning, a liberal translation of which constitutes the following chapter.
In order to correctly describe the notion of a bag using mathematical notation, a few theoretical definitions are needed first.

\section{Multisets}

A multiset is a set allowing repeated elements, or alternatively an unordered tuple. \cite{knuth_art_1968} formally defines the concept as follows:

\begin{define}
	Let \( \VUset{A} \) be a set and \( m : \VUset{A} \to \VUfield{N} \setminus \left\{ 0 \right\} \). The tuple \( \left( \VUset{A}, m \right) \) is called a \VUname{multiset} over the set \( \VUset{A} \). For an \( a \in \VUset{A} \), the number \( m \left( a \right) \) is called the \VUname{multiplicity} (i. e. number of occurrences) of \( a \). If \( a \in \VUset{A} \), then \( a \) is called an element of \( \left( \VUset{A}, m \right) \) and denoted as
	\[ a \in \left( \VUset{A}, m \right) \]
\end{define}

Obviously, a multiset is a generalization of a set and as such it is usually written as an enumeration of the elements which are repeated as many times as is their multiplicity.

\begin{example}
	The multiset \( \left( \left\{ a, b, c \right\}, \left\{ \left( a, 4 \right), \left( b, 1 \right), \left( c, 6 \right) \right\} \right) \) may be written as \( \left\{ a, a, a, a, b, c, c, c, c, c, c \right\} \).
\end{example}

\begin{remark}
	A set can be seen as a special case of a multiset where each element has a multiplicity of 1.
\end{remark}

\begin{define}
	Let \( \VUset{A} \) be a set. A multiset \( \left( \VUset{B}, m \right) \) is called a \VUname{submultiset} of \( \VUset{A} \) if \( \VUset{B} \subset \VUset{A} \). This is denoted as
	\[ \left( \VUset{B}, m \right) \subset \VUset{A} \]
\end{define}

The previous definition allows for a generalization of the concept of a power set, which is usually denoted as \( \mathcal{P} \left( \VUset{A} \right) \) or \( 2^{\VUset{A}} \).

\begin{define}
	Let \( \VUset{A} \) be a set. A \VUname{power multiset} of \( \VUset{A} \) is the set
	\[ \mathcal{P}^M \left( \VUset{A} \right) = \left\{ \left( \VUset{B}, m \right) \middle| \left( \VUset{B}, m \right) \text{is a multiset} \wedge \left( \VUset{B}, m \right) \subset \VUset{A} \right\} \]
\end{define}

\begin{remark}
	A power set of \( \VUset{A} \) may be seen as a set of all function from \( \VUset{A} \) to \( \left\{ 0, 1 \right\} \), sometimes written as \( \left\{ 0, 1 \right\}^{\VUset{A}} \). \( \left\{ 0, 1 \right\} \) coincides with the von Neumann ordinal 2, therefore the power set is often denoted \( 2^{\VUset{A}} \). Similarly, the power multiset may be seen as a set of all functions from \( \VUset{A} \) to \( \VUfield{N} \) (where \( 0 \in \VUfield{N} \)). It is therefore possible to use an analogous notation \( \mathcal{P}^M \left( \VUset{A} \right) = \VUfield{N}^\VUset{A} \). This analogy extends to the size of the sets in question where
	\[ \left\lvert 2^{\VUset{A}} \right\rvert = 2^{\left\lvert \VUset{A} \right\rvert} \qquad \text{and} \qquad \left\lvert \VUfield{N}^\VUset{A} \right\rvert = + \infty \]
	for all \( \VUset{A} \neq \emptyset \).
\end{remark}

\begin{define}
	Let \( \VUset{B} = \left( \VUset{A}, m \right) \) be a multiset where \( \VUset{A} \) is finite. The cardinality of the multiset \( \VUset{B} \) is
	\[ \left\lvert \VUset{B} \right\rvert = \sum_{a \in \VUset{A}} m \left( a \right) \]
\end{define}

\section{Multi-instance learning}
Multi-instance learning (see \cite{dietterich_solving_1997}) is an approach to solving problems where there is an input space \( \VUspace{X} \) and an output space \( \VUspace{Y} \) (whose elements are often called labels or classes) and the goal is to find a mapping of input objects to output objects. Unlike classical supervised learning, there is no known solution consisting of pairs of input and output objects. Instead, the input objects are grouped together into so called bags, which are defined as follows:

\begin{define}
	Let \( \VUspace{X} \) be a set of input objects. Then the \VUname{bag space} is a multiset \( \VUspace{B} \) with the properties
	\begin{enumerate}
		\item \( \VUspace{B} \subset \mathcal{P}^M \left( \VUspace{X} \right) \)
		\item \( \left( \forall x \in \VUspace{X} \right) \left( \exists b \in \VUspace{B} \right) \left( x \in b \right) \)
	\end{enumerate}
	Elements of the bag space are called \VUname{bags}.
\end{define}

Multi-instance learning uses a dataset consisting of pairs of bags and labels to learn a mapping between them. \cite{dietterich_solving_1997} provides the following example of a multi-instance problem:

\begin{example}
	Suppose there is a keyed lock on the door to the supply room in an office. Each staff member has a key chain containing several keys. One key on each key chain can open the supply room door. For some staff members, their supply room key opens only the supply room door; while for other staff members, their supply room key may open one or more other doors (e.g., their office door, the mail room door, the conference room door).

	Suppose you are a lock smith and you are attempting to infer the most general required shape that a key must have in order to open the supply room door. If you knew this required shape, you could predict, by examining any key, whether that key could unlock the door. What makes your lock smith job difficult is that the staff members are uncooperative. Instead of showing you which key on their key chains opens the supply room door, they just hand you their entire key chain and ask you to figure it out for yourself! Furthermore, you are not given access to the supply room door, so you can’t try out the individual keys. Instead, you must examine the shapes of all of the keys on the key rings and infer the answer.
\end{example}

In this example, the keys (or, more precisely their description by a feature vector) are the input objects from \( \VUspace{X} \). The key chains are bags. Even though it makes sense to ask for each key whether it unlocks the supply room, this information is not provided. Instead only a key-chain-level information is available. On the other hand, it may be stated that a key chain opens the supply room door if and only if it contains a key which opens the door. This naturally leads to the following definition:

\begin{define}\label{baglabel}
	Let \( \VUspace{X} \) be an input space and \( \VUspace{Y} \) a label space such that
	\[ \left( \forall x \in \VUspace{X} \right) \left( \exists_1 y_x \in \VUspace{Y} \right) \]
	Let \( \VUspace{B} \) be a bag space. Let maximum be well-defined in \( \VUspace{Y} \). Then the label of the bag \( b \in \VUspace{B} \) is
	\[ y_b = \max_{x \in b} \left( y_x \right) \in \VUspace{Y} \]
\end{define}

As will later be shown in sections \ref{bag-space-paradigm} and \ref{embedded-space-paradigm}, this isn't the only interpretation of multi-instance learning. There are problems where the instance-level labels are not only no known, but even not well-defined as the bag isn't seen as a mere collection of objects but as a distinct object of its own.

\section{Approaches to solving multi-instance problems}
In this section, there are described the three major approaches to solving multi-instance problems. The section is sourced primarily from \cite{pevny_using_2017} and \cite{pevny_discriminative_2016}.

\subsection{Instance-space paradigm}
Instance-space paradigm is the original approach proposed by \cite{dietterich_solving_1997}. The existence of labels for all instances is presumed, even though such labels aren't known. The goal of this approach is to find the instance-level labelling \( f : \VUspace{X} \to \VUspace{Y} \) and use it to model the bag-level label analogically to definition \ref{baglabel}, that is
\[ y_b = \max_{x \in \VUspace{X} } \left( f \left( x \right) \right) \]

There are many applications of instance-space paradigm, the most important of which are described next. (Also see \cite{andrews_support_2003} \cite{zhang_multiple_2006})

\VUname{BP-MIP}, proposed by \cite{zhou_neural_2002}, is an application of multi-instance learning to binary classification, i. e. \( \VUspace{Y} = \left\{ -1, +1 \right\} \). A feedforward neural network is used, its output for the \( j \)-th instance of the \( i \)-th bag denoted \( o_{ij} \). An instance-level error function is defined as
\[ E_{ij} = \begin{cases}
		0 &\text{for} \quad y_{b_i} = -1 \wedge o_{ij} < 0.5 \\
		0 &\text{for} \quad y_{b_i} = +1 \wedge o_{ij} \geq 0.5 \\
		\frac{1}{2} \left( o_{ij} - 0.5 \right)^2 &\text{otherwise}
	\end{cases} \]
This instance-level error function is then used to define a bag-level error function as \footnote{The original article erroneously states the upper bound as \( \left\lvert b_j \right\rvert \)}
\[ E_i = \begin{cases}
		\max_{1 \leq j \leq \left\lvert b_i \right\rvert} E_{ij} &\text{for} \quad y_{b_i} = -1 \\
		\min_{1 \leq j \leq \left\lvert b_i \right\rvert} E_{ij} &\text{for} \quad y_{b_i} = +1
	\end{cases} \]
And this is in turn used to define the global loss function
\[ E = \sum_{i = 1}^{\left\lvert \VUspace{B} \right\rvert} E_i \]
With such a well-defined global loss function, the back-propagation algorithm can be used with a slight modification described in the original article.

\VUname{EM-DD}, proposed by \cite{zhang_em-dd:_2002}, combines the \VUname{expectation-maximization} algorithm (see \cite{dempster_maximum_1977}) with the \VUname{diverse density} algorithm (see \cite{maron_framework_1998}). The EM-DD algorithm starts with a target hypothesis \( h \in \VUspace{Y} \), which is then refined with the EM algorithm. In the E-step, the instance thought to be most responsible for the label of each bag is picked. In the M-step, the gradient ascent algorithm is used to find a new hypothesis \( h' \) which maximizes \( \mathrm{DD} \left( h \right) \). \( \mathrm{DD} \left( h \right) \) corresponds to the likelihood that \( h \) is the actual target. These steps are then repeated, refining the hypothesis.

\subsection{Bag-space paradigm}\label{bag-space-paradigm}
The bag-space paradigm is a formalism in which the notion of instance-level labels is abandoned and only bag-level labels are assumed to exist. The definition \ref{baglabel} is no longer used, so some other way of working with bags must be devised. In order to do this, a bag distance function or a bag kernel function is defined, having the form
\[ k : \VUspace{B} \times \VUspace{B} \to \VUfield{R}_0^+ \]
Because the notion of an instance-level label is no longer used, the sought classification function is of the form \( f : \VUspace{B} \to \VUspace{Y} \).

\VUname{Citation-kNN}, proposed by \cite{wang_solving_2000}, defines a modified Hausdorff distance for bags \( b_1, b_2 \in \VUspace{B} \) as
\[ H \left( b_1, b_2 \right) = \min_{x \in b_1} \min_{y \in b_2} \left\lVert x - y \right\rVert \]
The \( k \)-nearest neighbour algorithm (see \cite{dasarathy_nearest_1991}) is modified for this application by adding a system of \VUname{citations} and \VUname{references}. The \( r \)-nearest references are the nearest neighbours from the vanilla kNN algorithm and the \( c \)-nearest citers are defined as
\[ \mathrm{Citers} \left( x, c \right) = \left\{ x_i \middle| \mathrm{Rank} \left( x_i, x \right) \leq c \wedge x_i \in b \right\} \]
For each bag, the \( r \)-nearest references and the \( c \)-nearest citers are found using the modified Hausdorff distance. If among those there are more positive bags then there are negative ones, the bag is labelled as positive. Otherwise the bag is labelled as negative.

For more applications using the bag-space paradigm, see \cite{wang_solving_2000}, \cite{kwok_marginalized_2007}, \cite{gartner_multi-instance_2002}, \cite{haussler_convolution_1999}, \cite{zhou_multi-instance_2009} and \cite{muandet_learning_2012}.

\subsection{Embedded-space paradigm}\label{embedded-space-paradigm}
In the embedded space paradigm, labels are only defined on the level of bags, same as in the bag-space paradigm. In order for these bag labels to be learned, an embedding function of the form \( \phi : \VUspace{B} \to \bar{\VUspace{X}} \) must be defined, where \( \bar{\VUspace{X}} \) is a new input space, which may or may not be identical to \( \VUspace{X} \). Using this function, each bag can be represented by an input object \( \phi \left( b \right) \in \bar{\VUspace{X}} \), which makes it possible to use any off-the-shelf supervised learning algorithm. Amongst the simplest embedding functions are e. g. element-wise minimum, maximum and mean. A more complicated embedding function may for example apply a neural network to each instance of the bag and subsequently pool the instances using one of the aforementioned functions.

\VUname{MILES}, proposed by \cite{chen_miles:_2006}, uses an instance dictionary \( \VUspace{D} \) to define an embedding function representing the degree of similarity between the bag and the dictionary, that is
\[ \phi : \VUspace{B} \to \VUfield{R}^{\left\lvert \VUspace{D} \right\rvert} \]
which is defined element-wise as
\[ \phi_i \left( b \right) = \sum_{x \in b} k \left( x, d_i \right) \quad \text{where} \quad d_i \in \VUspace{D} \]
where
\[ k \left( x, d \right) = \begin{cases}
		e^{- \frac{1}{\sigma^2} \left\lVert x - d \right\rVert^2} &\text{if } d \text{ is the nearest neighbour of } x \text{ in } \VUspace{D} \\
		0 &\text{otherwise}
	\end{cases} \]
The dictionary is populated by a 1-class support vector machine (see \cite{zhu_1-norm_2004}), which, however, has a high computational complexity.

For more applications using the embedded-space paradigm, see \cite{cheplygina_multiple_2015}, \cite{chen_image_2004} \cite{foulds_learning_2008}, \cite{zhang_multi-instance_2009} and \cite{dedic_hierarchicke_2017}.


\subsection{True and False}

We start off with two statements:

\begin{itemize}
\item True - \(T\) or \(\top \)
\item False - \(F\) or \(\bot \)
\end{itemize}


%*******************************************************************************
%********************************* Appendix B **********************************
%*******************************************************************************
\chapter{Graph Theory}
\chaptermark{Graph Theory}
\label{AppendixB}

\section{Introduction}

Multiple real life situations can be modelled by a set of vertices connected together by edges, this representation is called a graph. Graph theory is a field of discrete mathematics that has been developed in order to provide the tools to analyse and solve problems involving graphs, subsequently providing answers to the real life situations they represent \citep{Diestel2000,Bondy2008}. Graphs can be undirected, directed, and even weighted based on the type of situation that is modelled. A given graph $\mathcal{G}$ is defined by an ordered pair of elements, including a set of vertices $V$ and a set of edges $E$ such that,

\begin{equation} \label{eqnB.1}
\mathcal{G} = (V,E).
\end{equation}

The set of edges $E$ is composed of pairs of vertices taken from the set $V$ that can be directed and even weighted in some cases. Graphs can also be defined by their incidence or adjacency matrices. The incidence matrix of an undirected graph is a rectangle matrix whose rows represent the vertices and whose columns represent the edges, its entries are positive integers representing the number of times a vertex and an edge are incident. The adjacency matrix is a square matrix with rows and columns labelled after the vertices and composed of binaries. When an entry is equal to $1$, it indicates the presence of an edge between the vertices corresponding to the row and column indexes, whereas a $0$ entry  means that there is no direct link between these two particular vertices. A graph is said to be disconnected if its vertices can be partitioned into two distinct subsets that do not share any edges, otherwise a graph is said to be connected.

\section{Undirected Graphs}

An undirected graph also called simple graph is a graph where the edges are not oriented, therefore, the edge $\{1,2\}$ is the same as the edge $\{2,1\}$. A direct consequence of this is that for an undirected graph with $n$ vertices the maximum number of edges is $\frac{n(n-1)}{2}$ if loops are not considered and $\frac{n(n+1)}{2}$ with loops. Two vertices linked by an edge are said to be adjacent, and a vertex is said to be incident with an edge and vice versa. Subsequently, a graph can be defined by its incidence matrix or adjacency matrix. The adjacency matrix of a simple graph is a symmetric binary matrix, the Figure \ref{figB.1} represents a simple undirected graph with $10$ vertices.

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=4,
	vertex/.style={draw,circle,minimum size=0.75cm,inner sep=0pt},
	arc/.style={draw=blue!#10,thick,->},
	arc label/.style={fill=white,circle,font=\tiny,inner sep=1pt},
	loop arc/.style={min distance=2mm,looseness=8}]
	\foreach [count=\i] \coord in
							{(1.000,0.000),
							 (0.809,0.588),
							 (0.309,0.951),
							 (-0.309,0.951),
							 (-0.809,0.588),
							 (-1.000,0.000),
							 (-0.809,-0.588),
							 (-0.309,-0.951),
							 (0.309,-0.951),
							 (0.809,-0.588)}
							 {
				\node[vertex] (p\i) at \coord {\i};
		}
		\graphfromadj[bend left=0]{p}{{0,0,0,0,10,0,0,0,0,10},
										{10,0,0,0,0,10,0,0,0,0},
										{0,10,0,0,0,0,10,0,0,0},
										{0,0,10,0,0,0,0,10,0,0},
										{0,0,0,10,0,0,0,0,10,0},
										{0,0,0,0,10,0,0,0,0,10},
										{10,0,0,0,0,10,0,0,0,0},
										{0,10,0,0,0,0,10,0,0,0},
										{0,0,10,0,0,0,0,10,0,0},
										{0,0,0,10,0,0,0,0,10,0}}{36}{30}{1}
\end{tikzpicture}
\caption{Example of an undirected graph.}
\label{figB.1}
\end{figure}

The adjacency matrix representation is not unique and any permutations of a row and a column with equal indexes will yield the same graph by changing the vertex labels. A possible adjacency matrix $\mathcal{A}$ for the graph presented in Figure \ref{figB.1} is as follows,

\begin{equation} \label{eqnB.2}
\mathcal{A}=
\begin{bmatrix}
0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 \\
1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 \\
0 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 \\
0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 \\
1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 0 \\
0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 \\
1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 \\
0 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 \\
0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 \\
1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & 0
\end{bmatrix}
\end{equation}

Similarly, a graph can be defined by its incidence matrix $\mathcal{I}$. This kind of matrix links each edge to the two vertices it connects. The incidence matrix of the graph \ref{eqnB.1} is presented in equation \eqref{eqnB.3}. It can be noted that the adjacency matrix does not have to be symmetric or even square since the number of edges can be different from the number of vertices. In the same way as for the adjacency matrix, any permutations of the rows and the columns will represent the same graph after changing the labels of the vertices and of the edges respectively. Very often graphs have a lot more edges than vertices, subsequently in most cases the adjacency matrix constitutes a more compact way to store a graph than the incidence matrix. Hence, it is the preferred representation in most cases.

\begin{equation} \label{eqnB.3}
\mathcal{I}^{\top}=
\begin{bmatrix}
1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1
\end{bmatrix}
\end{equation}

Graphs are mathematical objects used to represent a given topology and consequently, the relative position of the vertices as well as the shape of the edges does not change the topological properties of a given graph. However, only plotting the undirected edges between a set of vertices can be insufficient sometimes, and in some cases associating an edge with a specific direction can carry some useful meaning. This property is achieved for the directed graphs and presented within the next section.

\section{Directed Graphs}

Each edge of a simple graph can be oriented from a vertex towards another in order to define a directed graph. An edge is called a loop if it connects a vertex to itself. A directed graph also called a digraph does not usually include any loops or parallel edges (multiple edges from and to the same vertex). The graph presented in Figure \ref{figB.2} corresponds to the oriented adjacency matrix $\mathcal{A}$ given equation \eqref{eqnB.4}. In this case the adjacency matrix is still square and composed of binaries entries but does not have to be symmetric any more. Indeed, the adjacency matrix of a digraph contains the information related to the incidence of the edges as well as their orientation. Any element of $\mathcal{A}$ indicates the number of edges starting from the vertex indexed by the row index and going to the vertex indexed by the column index. Directed graphs do not only inform on the topology but also on the direction of the edges between the vertices, therefore, they can be used to represent a succession of states or flows between vertices. In the example presented Figure \ref{eqnB.2}, each vertex is the initial vertex of two edges and the terminal vertex of two other edges.

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=4,
		vertex/.style={draw,circle,minimum size=0.75cm,inner sep=0pt},
		arc/.style={draw=blue!#10,thick,->},
		arc label/.style={fill=white,circle,font=\tiny,inner sep=1pt},
		loop arc/.style={min distance=2mm,looseness=8}
		]
		\foreach [count=\i] \coord in
							{(1.000,0.000),
							 (0.809,0.588),
							 (0.309,0.951),
							 (-0.309,0.951),
							 (-0.809,0.588),
							 (-1.000,0.000),
							 (-0.809,-0.588),
							 (-0.309,-0.951),
							 (0.309,-0.951),
							 (0.809,-0.588)}
							 {
				\node[vertex] (p\i) at \coord {\i};
		}
		\directedgraphfromadj[bend left=5]{p}{{0,0,0,0,0,0,10,0,0,10},
											{10,0,0,0,0,0,0,10,0,0},
											{0,10,0,0,0,0,0,0,10,0},
											{0,0,10,0,0,0,0,0,0,10},
											{10,0,0,10,0,0,0,0,0,0},
											{0,10,0,0,10,0,0,0,0,0},
											{0,0,10,0,0,10,0,0,0,0},
											{0,0,0,10,0,0,10,0,0,0},
											{0,0,0,0,10,0,0,10,0,0},
											{0,0,0,0,0,10,0,0,10,0}}{36}{30}{1}
\end{tikzpicture}
\caption{Example of a directed graph.}
\label{figB.2}
\end{figure}

Consequently, in this specific case the binary entries of the adjacency matrix $\mathcal{A}$ are positioned in such a way that each row and each column sum to two. A row sums to two for two edges leaving a vertex and a column sums to two for two edges going to a vertex.

\begin{equation} \label{eqnB.4}
\mathcal{A}=
\begin{bmatrix}
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\
1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0
\end{bmatrix}
\end{equation}

The representation of a directed graph by its incidence matrix is done by adding signs to the matrix entries. An entry is set to $-1$ if an edge leaves a vertex and to $1$ if an edge points towards a vertex, it is set to $0$ otherwise.

\section{Weighted Graphs}

In some cases it is important to associate each oriented edge of a directed graph to a weight. Weighted graphs are used to define a certain distance closeness between two given vertices and are therefore essential to analyse the flow between vertices. In the same way as for the simple graphs and the directed graphs, weighted graphs could be defined by their incidence or adjacency matrix.

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=4,
		vertex/.style={draw,circle,minimum size=0.75cm,inner sep=0pt},
		arc/.style={draw=blue!#10,thick,->},
		arc label/.style={fill=white,circle,font=\tiny,inner sep=1pt},
		loop arc/.style={min distance=2mm}
		]
		\foreach [count=\i] \coord in
							{(1.000,0.000),
							 (0.809,0.588),
							 (0.309,0.951),
							 (-0.309,0.951),
							 (-0.809,0.588),
							 (-1.000,0.000),
							 (-0.809,-0.588),
							 (-0.309,-0.951),
							 (0.309,-0.951),
							 (0.809,-0.588)}
							 {
				\node[vertex] (p\i) at \coord {\i};
		}
		\weigthedgraphfromadj[bend left=10]{p}{{0,0,0,0,0,0,5,0,0,9},
												 {2,0,0,0,0,0,0,2,0,0},
												 {0,5,0,0,0,0,0,0,5,0},
												 {0,0,7,0,0,0,0,0,0,10},
												 {7,0,0,9,0,0,0,0,0,0},
												 {0,6,0,0,2,0,0,0,0,0},
												 {0,0,5,0,0,1,0,0,0,0},
												 {0,0,0,5,0,0,2,0,0,0},
												 {0,0,0,0,8,0,0,5,0,0},
												 {0,0,0,0,0,3,0,0,8,0}}{36}{30}{1}
\end{tikzpicture}
\caption{Example of a weighted graph.}
\label{figB.3}
\end{figure}

The adjacency matrix of a weighted graph has to contain the necessary information about the weights and the orientations of all the edges. A weight is located on the entry at the intersection of the row and the column, whose indexes are the index of the initial vertex and of the terminal vertex respectively. The entries of the incidence matrix are the weights of the edges with positive and negative signs, positive for an edge that is directed from a vertex and negative for an edge directed towards a vertex.

\section{Multi-graphs}

Finally, multi-graphs allow to have multiple weighted edges between two given vertices, also a given vertex can be connected to itself by a loop. Therefore, multi-graphs subsume the oriented and weighted graphs into one single type of graph. In the same way as before they can be represented by an adjacency matrix $\mathcal{A}$ as presented equation \eqref{eqnB.5} or by an incidence matrix. The multi-graph linked to the adjacency matrix $\mathcal{A}$ is shown in Figure \ref{figB.4}. The adjacency matrix contains the orientation of each edge as well as their respective weights, subsequently it is a square matrix linking the vertices with weights. The edges connect the vertices indexed by the row indexes to the ones indexed by the column indexes with the weight provided by the value of the matrix entry. The incidence matrix has the same definition as the incidence matrix for the weighted graphs, possibly including many parallel edges as well as loops.

\begin{equation} \label{eqnB.5}
\mathcal{A}=
\begin{bmatrix}
1 & 5 & 0 & 0 & 1 & 0 & 5 & 0 & 0 & 5 \\
2 & 2 & 1 & 0 & 0 & 5 & 0 & 2 & 0 & 0 \\
0 & 5 & 3 & 2 & 0 & 0 & 2 & 0 & 5 & 0 \\
0 & 0 & 7 & 4 & 5 & 0 & 0 & 2 & 0 & 5 \\
7 & 0 & 0 & 7 & 5 & 5 & 0 & 0 & 1 & 0 \\
0 & 5 & 0 & 0 & 2 & 6 & 5 & 0 & 0 & 1 \\
2 & 0 & 5 & 0 & 0 & 1 & 7 & 5 & 0 & 0 \\
0 & 7 & 0 & 5 & 0 & 0 & 2 & 8 & 1 & 0 \\
0 & 0 & 5 & 0 & 7 & 0 & 0 & 5 & 9 & 1 \\
5 & 0 & 0 & 5 & 0 & 1 & 0 & 0 & 1 & 10
\end{bmatrix}
\end{equation}

\begin{figure}[!htbp]
\centering
\begin{tikzpicture}[scale=4,
		vertex/.style={draw,circle,minimum size=0.75cm,inner sep=0pt},
		arc/.style={draw=blue!#10,thick,->},
		arc label/.style={fill=white,circle,font=\tiny,inner sep=1pt},
		loop arc/.style={loop,min distance=2mm}
		]
		\foreach [count=\i] \coord in
							{(1.000,0.000),
							 (0.809,0.588),
							 (0.309,0.951),
							 (-0.309,0.951),
							 (-0.809,0.588),
							 (-1.000,0.000),
							 (-0.809,-0.588),
							 (-0.309,-0.951),
							 (0.309,-0.951),
							 (0.809,-0.588)}
							 {
				\node[vertex] (p\i) at \coord {\i};
		}
		\weigthedgraphfromadj[bend left=10]{p}{{1,5,0,0,1,0,5,0,0,5},
											 {2,2,1,0,0,5,0,2,0,0},
											 {0,5,3,2,0,0,2,0,5,0},
											 {0,0,7,4,5,0,0,2,0,5},
											 {7,0,0,7,5,5,0,0,1,0},
											 {0,5,0,0,2,6,5,0,0,1},
											 {2,0,5,0,0,1,7,5,0,0},
											 {0,7,0,5,0,0,2,8,1,0},
											 {0,0,5,0,7,0,0,5,9,1},
											 {5,0,0,5,0,1,0,0,1,10}}{36}{30}{1}
\end{tikzpicture}
\caption{Example of a weighted multi-graph.}
\label{figB.4}
\end{figure}


\chapter{Canonical Transformation}
For each problem there may be one particular choice for which all coordinates $q_i$ are cyclic. Then the conjugate momenta $p_i$ are all constant:
$$p_i=\alpha_i$$
Consider a situation in which Hamiltonian is a constant of motion,
then
$$H=H(\alpha_1,.......\alpha_n)$$
so the Hamiltonian equations for $\dot{q}_i$ are
$$\dot{q}_i=\frac{\partial H}{\partial \alpha_i}=\omega_i$$
Where $\omega_i$'s are functions of $\omega_i$'s only
$\therefore $ solutions are
$$ q_i=\omega_i t+\beta_i$$
where $\beta_i$'s are constants of integration.\\
\par Since the obivious generalized coordinates suggested by the problem will
not normally be cyclic, we must have a specific proceedure for transforming from one set of variables to some other set that may be more suitable.\\
\par In the Hameltonian formulation the momenta are also independent variable on the same level as the generalized coordinates. The similtaneous transformation of the independent coordinates and momenta $q_i,p_i$ to a new se t  $Q_i,P_i$ with (invertible) equation of transformation:
$$Q_i=Q_i (q,p,t)$$
$$P_i=P_i (q,p,t)$$
Which define a point transformation in phase space.
\section{Jacobian}
If $u$ and $v$ are two function of two independent variables $x$ and $y$ then the determinant $J=\left|\begin{array}{ll}\frac{\partial u}{\partial x} & \frac{\partial u}{\partial y} \\ \frac{\partial v}{\partial x} & \frac{\partial v}{\partial y}\end{array}\right|$ is called the Jacobian of $u$ and $v$ with respect to of $x$ and $y$ which is written as $\frac{\partial(u, v)}{\partial(x, y)}$ or $J\left(\frac{u, v}{x, y}\right)$\\
If $u, v$ and $w$ are three functions of three independent variables $x, y$ and $z$ then the determinant\\
$J=\left|\begin{array}{lll}\frac{\partial u}{\partial x} & \frac{\partial u}{\partial y} & \frac{\partial u}{\partial z} \\ \frac{\partial v}{\partial x} & \frac{\partial v}{\partial y} & \frac{\partial v}{\partial z} \\ \frac{\partial w}{\partial x} & \frac{\partial w}{\partial y} & \frac{\partial w}{\partial z}\end{array}\right|$
is called the Jacobian of $u, v$ and $w$ with respect to of $x, y$ and $z$
which is written as $\frac{\partial(u, v, w)}{\partial(x, y, z)}$ or $J\left(\frac{u, v, w}{x, y, z}\right)$
\subsection{Properties of Jacobian}
\begin{itemize}
	\item  If $J=\frac{\partial(u, v, w)}{\partial(x, y, z)}$ and $J^{\prime}=\frac{\partial(x, y, z)}{\partial(u, v, w)}$ then $J J^{\prime}=1$
	\item Chain rule for Jacobian if $u, v$ are functions of $r, s$ and $r, s$ functions of $x, y$ then $\frac{\partial(u, v)}{\partial(x, y)}=\frac{\partial(u, v)}{\partial(r, s)} \cdot \frac{\partial(r, s)}{\partial(x, y)}$
	\item If $u_{1}, u_{2}, u_{3}$ instead of being given explicitly in terms $x_{1}, x_{2}, x_{3}$ be connected with them with equations such as
	$$
	f_{1}\left(u_{1}, u_{2}, u_{3}, x_{1}, x_{2}, x_{3}\right)=0 f_{2}\left(u_{1}, u_{2}, u_{3}, x_{1}, x_{2}, x_{3}\right)=0 f_{3}\left(u_{1}, u_{2}, u_{3}, x_{1}, x_{2}, x_{3}\right)=0
	$$
	then $\frac{\partial\left(u_{1}, u_{2}, u_{3}\right)}{\partial\left(x_{1}, x_{2}, x_{3}\right)}=(-1)^{3} \frac{\partial\left(f_{1}, f_{2}, f_{3}\right)}{\partial\left(x_{1}, x_{2}, x_{3}\right)} / \frac{\partial\left(f_{1}, f_{2}, f_{3}\right)}{\partial\left(u_{1}, u_{2}, u_{3}\right)}$
	\\\\$\left((-1)^{3}\right.$ is for three variable system $)$
	\item  If $u_{1}, u_{2}, u_{3}$ be functions of $x_{1}, x_{2}, x_{3}$ then the necessary and sufficient condition for existence of a functional relationship of the form $f_{1}\left(u_{1}, u_{2}, u_{3}\right)=0$ is $J\left[\frac{\partial\left(u_{1}, u_{2}, u_{3}\right)}{\partial\left(x_{1}, x_{2}, x_{3}\right)}\right]=0$
\end{itemize}
\section{Canonical Transformation}
	 In Hamiltonian mechanics the transformation should be such that $Q$ and $P$ are canonical coordinates
	We would like to change variables from the set $(a,p)$ to a new set $(Q,P )$ such that:
	\begin{enumerate}
		\item  Determinent of Jacobian matrix of transformation, $\left| \frac{\partial(Q,P)}{\partial(q,p)}\right|=+1 $
		(This ensures that it is volume and orientation are preserved during transformation)
		\item  Ensures structure of Hamilton's equation is not changed, so the exist a function $K=K(Q,P,t)$
		such that the equation of motion of new set are
		$$\dot{Q_i}-\frac{\partial K}{\partial P_i}\quad,\quad\dot{P_i}=\frac{\partial K}{\partial Q_i}$$
		$K$ plays role of Hamiltonian in new coordinate set and known as 'kamiltonian'
	\end{enumerate}
\begin{note}
	The transformation considered be problem independent that is to say $(Q,P)$ must be canonical coordinates not onlu for some specific mechanical systems, but for all systems of the same number of degrees of freedom.
\end{note}
\textbf{Hamilton's Priciple of Transformed Coordinates}\vspace{0.1cm}\\
 As $Q_i$ and $P_i$ are canonical variable they must satisfy Hamiltonians principle
\begin{equation}
\delta\int\limits_{t_1}^{t_2}(P_i\dot{Q_i}-K(Q,P,t))dt=0
\end{equation}
as of old canonical variables
\begin{equation}
\delta\int\limits_{t_1}^{t_2}(p_i\dot{q_i}-H(Q,P,t))dt=0
\end{equation}
$\therefore$ we can say
$$\lambda (p_i\dot{q_i}-H)=P_i\dot{Q_i}-K+\frac{\partial F}{\partial t}$$
$F$ is a function of phase space coordinates with continuous second derivatives \\
$\lambda$ is a constant independent of canonical coordinates and the time and it is related to scale transformation. \\\\
For $\lambda=1$ we have
$$p_i\dot{q_i}-H=P_i\dot{Q_i}-K+\frac{dF}{dt}$$
Which is simply called canonical transformation
\begin{note}
	A transformation of canonical coordinates for which is called extended canonical transformation
\end{note}
Canonical Transformation have following four properties
\begin{enumerate}
	\item The identity transformation is canonical.
	\item If a transformation is canonical, so is its inverse.
	\item Two successive canonical transformations (the group "product" operation) define a transformation that is also canonical.
	\item The product operation is associative.
\end{enumerate}
\section{Generating Function}
\begin{itemize}
	\item The term $\frac{df}{dt}$ in canonical transformation contributes to the variation of action integral only at the end points, and will vanish if $F$ is a function of $(q,p t)$ or $(Q,P,t)$or any mixture of the phase space coordinates since these have zero variation at the end points.
	\item Through equations of transformation and their inverses $F$ can be expressed partly in terms of the old set of variables and partly of the new.
	\item $F$ acts as a bridge between the two sets of canonical variables and is called the generating function of transformation.
\end{itemize}
There are four types of generating function:
\begin{enumerate}
	\item  $F=F_{1}\left(q_{i}, Q_{i}, t\right)$ known as $F_{1}\left(q_{i}, Q_{i}, t\right)$ is $F_{1}$ type Generating function.
	$$
	\begin{aligned}
	\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\frac{d F}{d t} \Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\frac{d F_{1}}{d t} \\
	\Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\sum_{i} \frac{\partial F_{1}}{\partial q_{i}} \dot{q}_{i}+\sum_{i} \frac{\partial F_{1}}{\partial Q_{i}} \dot{Q}_{i}+\frac{\partial F}{\partial t}\\
	\text{	Comparing both the }&\text{coefficient of $\dot{q}_{i}$ and $\dot{Q}_{i}$}\\
	\frac{\partial F_{1}}{\partial q_{i}}=p_{i} \quad \frac{\partial F_{1}}{\partial Q_{i}}&=-P_{i}\text{ and }K=H+\frac{\partial F_{1}}{\partial t}
	\end{aligned}
	$$
	\item $F=F_{2}\left(q_{i}, P_{i}, t\right)-Q_{i} P_{i}$ known as $F_{2}\left(q_{i}, P_{i}, t\right)$ is $F_{2}$ type Generating function.\\
	$$
	\begin{aligned}
	\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\frac{d F}{d t} \\
	\Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)-\sum_{i} \dot{Q}_{i} P_{i}-\sum_{i} Q_{i} \dot{P}_{i}-\frac{d F_{2}}{d t} \\
	\Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\sum_{i} \frac{\partial F_{2}}{\partial q_{i}} \dot{q}_{i}+\sum_{i} \frac{\partial F_{2}}{\partial P_{i}} \dot{P}_{i}+\frac{\partial F_{2}}{\partial t}-\sum_{i} \dot{Q}_{i} P_{i}-\sum_{i} Q_{i} \dot{P}_{i}\\
	\text{Comparing both the }&\text{coefficient of $\dot{q}_{i}$ and $\dot{P}_{i}$}\\
	\frac{\partial F_{2}}{\partial q_{i}}=p_{i}, \ \frac{\partial F_{2}}{\partial P_{i}}&=Q_{i}\text{ and }K=H+\frac{\partial F_{2}}{\partial t}
	\end{aligned}
	$$
	\item  $F=F_{3}\left(Q_{i}, p_{i}, t\right)+q_{i} p_{i}$ known as $F_{3}\left(Q_{i}, p_{i}, t\right)$ is $F_{3}$ type Generating function.
	$$
	\begin{aligned}
	\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\frac{d F}{d t} \\
	\Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\frac{d F_{3}}{d t}+\sum_{i} \dot{q}_{i} p_{i}+\sum_{i} q_{i} \dot{p}_{i} \\
	\Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\sum_{i} \frac{\partial F_{3}}{\partial Q_{i}} \dot{Q}_{i}+\sum_{i} \frac{\partial F_{3}}{\partial p_{i}} \dot{p}_{i}+\frac{\partial F_{3}}{\partial t}+\sum_{i} \dot{q}_{i} p_{i}+\sum_{i} q_{i} \dot{p}_{i}\\
	\text{	Comparing both the }&\text{coefficient of $\dot{q}_{i}$ and $\dot{P}_{i}$}\\
	\frac{\partial F_{3}}{\partial Q_{i}}=-P_{i},\  \frac{\partial F_{3}}{\partial p_{i}}&=-q_{i}\text{ and }K=H+\frac{\partial F_{3}}{\partial t}
	\end{aligned}
	$$
	\item  $F=F_{4}\left(p_{i}, P_{i}, t\right)+q_{i} p_{i}-Q_{i} P_{i}$ known as $F_{3}\left(P_{i}, p_{i}, t\right)$ is $F_{3}$ type Generating function.
	$$
	\begin{aligned}
	\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\frac{d F}{d t} \\
	\Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\frac{d F_{4}}{d t}+\sum_{i} \dot{q}_{i} p_{i}+\sum_{i} q_{i} \dot{p}_{i}-\sum_{i} \dot{Q}_{i} P_{i}-\sum_{i} Q_{i} \dot{P}_{i}\\
	\Rightarrow\left(\sum_{i} p_{i} \dot{q}_{i}-H\right)&=\left(\sum_{i} P_{i} \dot{Q}_{i}-K\right)+\sum_{i} \frac{\partial F_{4}}{\partial P_{i}} \dot{P}_{i}+\sum_{i} \frac{\partial F_{4}}{\partial p_{i}} \dot{p}_{i}+\frac{\partial F_{4}}{\partial t}+\sum_{i} \dot{q}_ip_i+q_i\dot{p}_i-\sum_{i} \dot{Q}_iP_i-\sum_{i} Q_i\dot{P}_i\\
	\text{Comparing both }&\text{the coefficient of $\dot{p}_{i}$ and $\dot{P}_{i}$}\\
	\frac{\partial F_{4}}{\partial p_{i}}=-q_{i},\  \frac{\partial F_{4}}{\partial P_{i}}&=Q_{i} \text { and } K=H+\frac{\partial F_{4}}{\partial t}
	\end{aligned}
	$$
\end{enumerate}
	\begin{table}[H]
	\centering
	\renewcommand*{\arraystretch}{1.8}
	\begin{tabular}{|p{4.5cm}|p{5cm}|p{5.5cm}|}
	\hline Generating Function&Generating Function Derivatives&Trivial Special Case\\
	\hline $F=F_{1}(q, Q, t)$&$p_{i}=\frac{\partial F_{1}}{\partial q_{i}} \quad P_{i}=-\frac{\partial F_{1}}{\partial Q_{i}}$&$F_{1}=q_{i} Q_{i}, \quad Q_{i}=p_{i}, \quad P_{i}=-q_{i}$\\
	\hline $F=F_{2}(q, P, t)-Q_{i} P_{i}$&$p_{i}=\frac{\partial F_{2}}{\partial q_{i}} \quad Q_{i}=\frac{\partial F_{2}}{\partial P_{i}}$&$F_{2}=q_{i} P_{i}, \quad Q_{i}=q_{i}, \quad P_{i}=p_{i}$\\
	\hline $F=F_{3}(p, Q, t)+q_{i} p_{i}$&$q_{i}=-\frac{\partial F_{3}}{\partial p_{i}} \quad P_{i}=-\frac{\partial F_{3}}{\partial Q_{i}}$&$F_{3}=p_{i} Q_{i}, \quad Q_{i}=-q_{i}, \quad P_{i}=-p_{i}$\\
	\hline $F=F_{4}(p, P, t)+q_{i} p_{i}-Q_{i} P_{i}$&$q_{i}=-\frac{\partial F_{4}}{\partial p_{i}} \quad Q_{i}=\frac{\partial F_{4}}{\partial P_{i}}$&$F_{4}=p_{i} P_{i}, \quad Q_{i}=p_{i}, \quad P_{i}=-q_{i}$\\\hline
	\end{tabular}
\end{table}

Classical Mechanics  -CSIR/chapter/Canonical Transformation.tex


\chapter{Elementary Properties of Groups}
\label{ch:elementary-properties-of-groups}
%% FIXME: \cite{Pinter2016}*{Chapter 4}

\begin{enumerate}[label={\Alph*.},font={\bfseries}]
\item {\bf Solving Equations in Groups}
  \begin{enumerate}[label={\arabic*},font={\bfseries}]
  \item
    \begin{align*}
      axb &= c \\
      ax &= cb^{-1} \\
      x &= a^{-1}cb^{-1}
    \end{align*}
  \item
    \begin{align*}
      x^2b &= xa^{-1}c \\
      xb &= a^{-1}c \\
      x &= a^{-1}cb^{-1}
    \end{align*}
  \item
    \begin{align*}
      acx &= xac \\
      xacx &= x^2ac
      \\
      x^2a &= bxc^{-1} \\
      x^2ac &= bx \\
      \\
      xacx &= bx \\
      xac &= b \\
      x &= b(ac)^{-1}
    \end{align*}
  \item
    \begin{align*}
      x^3 &= e \\
      \\
      ax^2 &= b \\
      a &= bx \\
      x &= b^{-1}a
    \end{align*}
  \item
    \begin{align*}
      x^5 &= e \\
      x^4 &= x^{-1} \\
      \\
      x^2 &= a^2 \\
      x^4 &= a^2x^2 \\
      x^{-1} &= a^2x^2 \\
      e &= a^4x \\
      \left(a^4\right)^{-1} &= x
    \end{align*}
  \item
    \begin{align*}
      x^2a &= (xa)^{-1} \\
      \\
      (xax)^3 &= bx \\
      xa(x^2a)(x^2a)x &= bx \\
      xa(xa)^{-1}(xa)^{-1}x &= bx \\
      (xa)^{-1}x &= bx \\
      a^{-1}x^{-1}x &= bx \\
      b^{-1}a^{-1} &= x
    \end{align*}
  \end{enumerate}
\item {\bf Rules of Algebra in Groups} \\
  $$G = \Group{\Set{I,A,B,C,D,K}, \cdot}$$ \\
  \begin{alignat*}{4}
    & \mathbf{I} &&=
    \begin{pmatrix}
      \phantom{-}1 & \phantom{-}0 \\
      \phantom{-}0 & \phantom{-}1
    \end{pmatrix}
    \qquad
    \mathbf{A} &&=
    \begin{pmatrix}
      \phantom{-}0 & \phantom{-}1 \\
      \phantom{-}1 & \phantom{-}0
    \end{pmatrix}
    \qquad
    \mathbf{B} &&=
    \begin{pmatrix}
      \phantom{-}0 & \phantom{-}1 \\
      -1 & -1
    \end{pmatrix} \\
    & \mathbf{C} &&=
    \begin{pmatrix}
      -1 & -1 \\
      \phantom{-}0 & \phantom{-}1
    \end{pmatrix}
    \qquad
    \mathbf{D} &&=
    \begin{pmatrix}
      -1 & -1 \\
      \phantom{-}1 & \phantom{-}0
    \end{pmatrix}
    \qquad
    \mathbf{K} &&=
    \begin{pmatrix}
      \phantom{-}1 & \phantom{-}0 \\
      -1 & -1
    \end{pmatrix}
  \end{alignat*}
  \begin{enumerate}[label={\arabic*},font={\bfseries}]
  \item
    \(
      \mathbf{A}^2 =
      \begin{pmatrix}
        0 & 1 \\
        1 & 0
      \end{pmatrix}
      \begin{pmatrix}
        0 & 1 \\
        1 & 0
      \end{pmatrix}
      =
      \begin{pmatrix}
        1 & 0 \\
        0 & 1
      \end{pmatrix}
      = e
    \)
    ... but $\mathbf{A} \ne e$, so $x^2 = e \centernot\implies x = e$.\qed
  \item $\mathbf{A}^2 = \mathbf{I}^2$, but $\mathbf{A} \ne \mathbf{I}$, so $x^2 = a^2 \centernot\implies x = a$.\qed
  \item $(\mathbf{A}\mathbf{B})^2 = \mathbf{K}^2 = \mathbf{I}$, and $\mathbf{A}^2\mathbf{B}^2 = \mathbf{I}\mathbf{D} = \mathbf{D}$, but $\mathbf{I} \ne \mathbf{D}$, so $(ab)^2 = a^2b^2$ is not true in every group $G$.\footnote{$(ab)^2 = a^2b^2$ is only true in abelian groups.}\qed
  \item $x^2 = x \implies x = e$
    \begin{align*}
      x^2 &= x \\
      xx &= x \\
      xxx^{-1} &= xx^{-1} \\
      xe &= e \\
      x &= e
    \end{align*}
    \qed
  \item
    \captionof{table}{$\Group{\Set{I,A,B,C,D,K}, \cdot}$}
    \begin{tabular}{ c | c c c c c c}
      $\cdot$ & $\mathbf{I}$ & $\mathbf{A}$ & $\mathbf{B}$ & $\mathbf{C}$ & $\mathbf{D}$ & $\mathbf{K}$ \\
      \hline
      $\mathbf{I}$ & $\mathbf{I}$ \\
      $\mathbf{A}$ & & $\mathbf{I}$ \\
      $\mathbf{B}$ & & & $\mathbf{D}$ \\
      $\mathbf{C}$ & & & & $\mathbf{I}$ \\
      $\mathbf{D}$ & & & & & $\mathbf{B}$ \\
      $\mathbf{K}$ & & & & & & $\mathbf{I}$
    \end{tabular}

    As shown in the table, there does not exist an $x \in G$ such that $x = y^2$ for $y \in \Set{\mathbf{A}, \mathbf{C}, \mathbf{K}}$. \\
    Therefore $\neg\left(\forall x \in G,\ \exists y \in G\left( x = y^2 \right)\right)$.\qed
  \item
    \begin{align*}
      y &= xz \\
      x^{-1}y &= x^{-1}xz \\
      z &= x^{-1}y
    \end{align*}
    Therefore, for all $x,y \in G$, there exists a $z \in G$ such that $y = xz$.\qed
  \end{enumerate}
\newpage
\item {\bf Elements That Commute}
  \begin{enumerate}[label={\arabic*},font={\bfseries}]
  \item $a^{-1}b^{-1} = (ba)^{-1} = (ab)^{-1} = b^{-1}a^{-1}$
  \item Since $a = b^{-1}ba = b^{-1}ab$, $ab^{-1} = (b^{-1}ab)b^{-1} = b^{-1}a$.
  \item $a(ab) = a(ba) = (ab)a$
  \item $(xax^{-1})(xbx^{-1}) = xa(x^{-1}x)bx^{-1} = x(ab)x^{-1} = x(ba)x^{-1} = xb(x^{-1}x)ax^{-1} = (xbx^{-1})(xax^{-1})$
  \item $ab = ba \iff aba^{-1} = b$
    \begin{proof}
      First, assume $ab = ba$.
      Multiplying by $a^{-1}$ on the right shows $ab = ba \implies aba^{-1} = b$.
      %%
      Next, assume $aba^{-1} = b$.
      Multiplying by $a$ on the right shows $aba^{-1} = b \implies ab = ba$.
    \end{proof}
  \item $ab = ba \iff aba^{-1}b^{-1} = e$
    \begin{proof}
      First, assume $ab = ba$.
      Multiplying by $a^{-1}$ on the right yields $aba^{-1} = b$.
      Then multiplying by $b^{-1}$ on the right yields $aba^{-1}b^{-1} = e$.
      Thus $ab = ba \implies x$.
      %%
      Next, assume $aba^{-1}b^{-1} = e$.
      Multiplying by $b$ on the right yields $aba^{-1} = b$.
      Then multiplying by $a^{-1}$ on the right yields $ab = ba$.
      Thus $aba^{-1}b^{-1} = e \implies ab = ba$ and $ab = ba \iff aba^{-1}b^{-1} = e$.
    \end{proof}
  \end{enumerate}
\item {\bf Group Elements and Their Inverses}
  \begin{enumerate}[label={\arabic*},font={\bfseries}]
  \item $ab = e \implies ba = e$
    \begin{proof}
      If $ab = e$, then $ab = aa^{-1}$, so by the cancellation law, $b = a^{-1}$ and $a = b^{-1}$. \\
      Thus, $bb^{-1} = e \implies ba = e$, as desired.
    \end{proof}
  \item $abc = e \implies cab = e$ and $bca = e$.
    \begin{proof}
      If $(ab)c = e$, then $(ab)c = (ab)(ab)^{-1}$, so by the cancellation law, $c = (ab)^{-1} = b^{-1}a^{-1}$ \\
      Thus, $(ab)^{-1}(ab) = e \implies c(ab) = e$, and $b(b^{-1}a^{-1})a = e \implies cba = e$.
    \end{proof}
  \item ...
  \item Let $G$ be a group such that $xay = a^{-1}$ for all $a,x,y \in G$.
    Prove that $yax = a^{-1}$ as well.
    \begin{proof}
      If $xay = a^{-1}$, then $(xay)a = a^{-1}a$, so by the definition of inversion, $(xay)a = e$.
      Thus $x^{-1}(xay)ax = x^{-1}ex$, so by associativity and the definition of the identity element, $(x^{-1}x)a(yax) = e \iff ea(yax) = e \iff a(yax) = e$.
      Multiply by $a^{-1}$ on the left to obtain $a^{-1}a(yax) = a^{-1}e$, so by the definition of inversion, $yax = a^{-1}$.
    \end{proof}
  \item Let $a = a^{-1}$, $b = b^{-1}$, and $c = c^{-1}$. If $ab = c$ show that $bc = a$ and $ca = b$ as well.
    \begin{align*}
      ab &= c \\
      abb^{-1} &= cb^{-1} = cb \\
      a &= cb \\
      a^{-1} &= b^{-1}c^{-1} = bc \\
      bc &= a \\
      \\
      ab &= c \\
      b^{-1}a^{-1} &= c^{-1} \\
      ba^{-1} &= c \\
      ba^{-1}a &= ca \\
      ca &= b
    \end{align*}
  \item Let $abc = (abc)^{-1}$, show that $bca = (bca)^{-1}$ and $cab = (cab)^{-1}$.
    \begin{align*}
      abc &= (abc)^{-1} \\
      bca &= a^{-1}(abc)^{-1}a \\
      &= a^{-1}(bc)^{-1} \\
      &= (bca)^{-1} \\
      \\
      bca &= (bca)^{-1} \\
      cab &= b^{-1}(bca)^{-1}b \\
      &= b^{-1}(ca)^{-1} \\
      &= (cab)^{-1}
    \end{align*}
  \item Let $a = a^{-1}$ and $b = b^{-1}$, show that $(ab)^{-1} = ba$.
    \begin{proof}
      Replace $a$ and $b$ with their inverses on the right-hand side of
      $(ab)^{-1} = b^{-1}a^{-1}$ to obtain $(ab)^{-1} = ba$.
    \end{proof}
  \item $a = a^{-1} \iff a^2 = e$
    \begin{proof}
      If $a = a^{-1}$, then $a^2 = e$ by multiplying by $a$ on the right.
      If $a^2 = e$, then $a = a^{-1}$ by multiplying by $a^{-1}$ on the right.
    \end{proof}
  \item Let $c = c^{-1}$. Prove $ab = c \iff abc = e$.
    \begin{proof}
      If $ab = c$, then $ab = c^{-1}$, since $c = c^{-1}$.
      Multiply by $c$ on the right to obtain $abc = e$.
      %%
      If $abc = e$, then $abc^{-1} = e$ since $c = c^{-1}$.
      Multiply by $c$ on the right to obtain $ab = c$.
    \end{proof}
  \end{enumerate}
\item {\bf Counting Elements and Their Inverses}
  \begin{enumerate}[label={\arabic*},font={\bfseries}]
  \item Prove that in any finite group $G$, $2 \mid \left|\Set{x \in G : x \ne x\inverse}\right|$.
    \begin{proof}
      By definition, $G = \Set{x \in G : x = x\inverse} \cup \Set{x \in G : x \ne x\inverse}$.

      Therefore, $\forall x \in G\left(x = x\inverse \lor \left(x \ne x\inverse \land \exists y \in G\left(y \ne x \land y = x\inverse\right)\right)\right)$.

      So, $\left|\Set{x \in G : x \ne x\inverse}\right| = \left|\Set{x_0,x_0\inverse,x_1,x_1\inverse,x_2,x_2\inverse,x_3,x_3\inverse...}\right| = 2k$.
    \end{proof}
  \item Prove $\left|\Set{x \in G : x = x\inverse}\right|$ has the same parity as $|G|$.
    \begin{proof}
      Since $|G| = \left|\Set{x \in G : x = x\inverse}\right| + \left|\Set{x \in G : x \ne x\inverse}\right|$, \\
      and $\left|\Set{x \in G : x \ne x\inverse}\right|$ is even, $\left|\Set{x \in G : x = x\inverse}\right|$ has the same parity as $|G|$.
    \end{proof}
  \item Prove $2 \mid |G| \implies \exists x \in G\left(x \ne e \land x = x\inverse \right)$.
    \begin{proof}
      If $2 \mid |G|$ then $2 \mid \left|\Set{x \in G : x = x\inverse}\right|$. Since $e = e\inverse$, $2 \nmid \left|\Set{x \in G : x \ne e \land x = x\inverse}\right|$ and thus $\exists x \in G\left(x \ne e \land x = x\inverse\right)$.
    \end{proof}
  \item Given a finite abelian group $G = \Set{e,a_1,a_2,...a_n}$, prove $(a_1a_2...a_n)^2 = e$.
    \begin{align*}
      (a_1a_2...a_n)^2 &= (a_1a_2...a_n)(a_1^{-1}a_2^{-1}...a_n^{-1}) \\
      &= a_1a_1^{-1}a_2a_2^{-1}...a_na_n^{-1} \\
      &= ee...e \\
      &= e
    \end{align*}
    \qed
  \item Prove $\forall x \in G\left(x \ne e \implies x \ne x\inv\right) \implies a_1a_2...a_n = e$.
    \begin{proof}
      Assume $\forall x \in G\left(x \ne e \implies x \ne x\inv\right)$.
      Then $\forall x \in a_1a_2...a_n\left(\exists y \in a_1a_2...a_n\left(x \ne y \land y = x\inv\right)\right)$.
      So $a_1a_2...a_n$ can be rewritten $a_1a_1^{-1}a_2a_2^{-}...a_{n/2}a_{n/2}^{-1}$, which reduces to $e$.
    \end{proof}
  \item Prove that if there is exactly one $x \ne e$ in $G$ such that $x = x\inv$ then $a_1a_2...a_n = x$.
    \begin{proof}
      $a_1a_2...a_n$ can be rewritten $xa_1a_1^{-1}a_2a_2^{-1}...a_{n/2}a_{n/2}^{-1}$, which is equivalent to $xe$.
    \end{proof}
  \end{enumerate}
\item {\bf Constructing Small Groups}
  \begin{enumerate}[label={\arabic*},font={\bfseries}]
  \item $a,b \in G$
    \begin{enumerate}[label={(\alph*)},font={\bfseries}]
    \item Prove $a^2 = a \implies a = e$.
      \begin{proof}
        Assume $a^2 = a$. Divide by $a$ to get $a = e$.
      \end{proof}
    \item Prove $ab = a \implies b = e$.
      \begin{proof}
        Assume $ab = a$.
        Multiply by $a\inv$ on the left to get ${a\inv}ab = {a\inv}a \equiv b = e$.
      \end{proof}
    \item Prove $ab = b \implies a = e$.
      \begin{proof}
        Assume $ab = b$.
        Multiply by $b\inv$ on the right to get $ab{b\inv} = b\inv \equiv a = e$.
      \end{proof}
    \end{enumerate}
  \item ...\todo[inline]{Explain why elements of each row in a Cayley table must be distinct.}
  \item There is exactly oneo group with three distinct elements.
    \captionof{table}{\href{https://nathancarter.github.io/group-explorer/Multtable.html?groupURL=https://nathancarter.github.io/group-explorer/groups/Z_3.group}{Multiplication Table for $\mathbb{Z}_3$}}
    \begin{tabular}{ c | c c c }
      $\cdot$ & $\mathbf{e}$ & $\mathbf{a}$ & $\mathbf{b}$ \\
      \hline
      $\mathbf{e}$ & $e$ & $a$ & $b$ \\
      $\mathbf{a}$ & $a$ & $b$ & $e$ \\
      $\mathbf{b}$ & $b$ & $e$ & $a$
    \end{tabular}
    \newpage
  \item There is exactly one group $G$ with four elements, such that $\forall x \in G (xx = e)$.
    \captionof{table}{\href{https://nathancarter.github.io/group-explorer/Multtable.html?groupURL=https://nathancarter.github.io/group-explorer/groups/V_4.group}{Multiplication Table for $v_4$}}
    \begin{tabular}{ c | c c c c }
      $\cdot$ & $\mathbf{e}$ & $\mathbf{a}$ & $\mathbf{b}$ & $\mathbf{c}$  \\
      \hline
      $\mathbf{e}$ & $e$ & $a$ & $b$ & $c$ \\
      $\mathbf{a}$ & $a$ & $e$ & $c$ & $b$ \\
      $\mathbf{b}$ & $b$ & $c$ & $e$ & $a$ \\
      $\mathbf{c}$ & $c$ & $b$ & $a$ & $e$
    \end{tabular}
  \item There is exactly one group $G$ with four elements, such that $\exists x \in G (x \ne e \land xx = e)$ and
    $\exists y \in G (yy \ne e)$.
    \captionof{table}{\href{https://nathancarter.github.io/group-explorer/Multtable.html?groupURL=https://nathancarter.github.io/group-explorer/groups/V_4.group}{Multiplication Table for $v_4$}}
    \begin{tabular}{ c | c c c c }
      $\cdot$ & $\mathbf{e}$ & $\mathbf{a}$ & $\mathbf{b}$ & $\mathbf{c}$  \\
      \hline
      $\mathbf{e}$ & $e$ & $a$ & $b$ & $c$ \\
      $\mathbf{a}$ & $a$ & $e$ & $c$ & $b$ \\
      $\mathbf{b}$ & $b$ & $c$ & $e$ & $a$ \\
      $\mathbf{c}$ & $c$ & $b$ & $a$ & $e$
    \end{tabular}
    \item ...\todo[inline]{Explain why $\mathbb{Z}_3$ and $V_4$ are the only possible groups of order 4.}
  \end{enumerate}
\item {\bf Direct Products of Groups}
  \begin{enumerate}[label={\arabic*},font={\bfseries}]
  \item Prove that $G \times H$ is a group.
    \begin{proof}
      \ \\
      \begin{enumerate}[label={(G\arabic*)}]
      \item
        \begin{align*}
          (x_1,y_1)\left[(x_2,y_2)(x_3,y_3)\right] &= (x_1,y_1)(x_2x_3,y_2y_3) \\
          &= (x_1x_2x_3,y_1y_2y_3) \\
          &= (x_1x_2,y_1y_2)(x_3,y_3) \\
          &= \left[(x_1,y_1)(x_2,y_2)\right](x_3,y_3)
        \end{align*}
      \item Let $e_G$ be the identity element of $G$, and $e_H$ the identity element of $H$.
        The identity element of $G \times H$ is $(e_G,e_H)$.
        \begin{alignat*}{3}
          &(x,y)(e_G,e_H) &&= (xe_G,ye_H) &&= (x,y) \\
          \\
          &(e_G,e_H)(x,y) &&= (e_Gx,e_Hy) &&= (x,y)
        \end{alignat*}
      \item $\forall (a,b) \in G \times H \left( (a,b)\inv = (a\inv,b\inv) \right)$
        \begin{alignat*}{4}
          &(a,b)(a\inv,b\inv) &&= (aa\inv,bb\inv) &&= (e_G,e_H) &&= e_{G \times H}\\
          \\
          &(a\inv,b\inv)(a,b) &&= ({a\inv}a,{b\inv}b) &&= (e_G,e_H) &&= e_{G \times H}
        \end{alignat*}
      \end{enumerate}
    \end{proof}
  \end{enumerate}
\end{enumerate}


\subsection{Partial Fractions}
\noindent
If we have a function of two polynomials $f(x) = \frac{P(x)}{Q(x)}$, it's often easier to break this quotient into a sum of parts where the denominator is a linear or quadratic factor and the numerator is always a smaller degree than the denominator.

\begin{example}
	\begin{equation*}
		\frac{2x-1}{x^3-6x^2+11x-6} = \frac{1/2}{x-1}+\frac{-3}{x-2}+\frac{5/2}{x-3}.
	\end{equation*}
\end{example}

\noindent
One natural way to find these small denominators comes from the linear factors of the denominator where we keep quadratics with complex roots.
This way, when making a common denominator, we get back the original big denominator.
However, there are a few special cases we have to take care of.

\input{../common/algebraPreCalc/linearFactors.tex}
\input{../common/algebraPreCalc/repeatedLinearFactors.tex}
\input{../common/algebraPreCalc/quadraticFactors.tex}
\input{../common/algebraPreCalc/repeatedQuadraticFactors.tex}
\input{../common/algebraPreCalc/improperFractions.tex}


\chapter{Feature Reel}

\section{Maths}

\LaTeX{} shines when it comes to typesetting maths. This should work as expected when using this template, see \Cref{eq:gauss-integral}.
\begin{equation}\label{eq:gauss-integral}
	\int_{-\infty}^{\infty} \mathrm{e}^{-x^2} \enspace \mathrm{d}x = \sqrt{\pi}
\end{equation}

\section{Floating-Environments}
% Figures, Tables, TikZ

Figures and tables should be put in floating environments.
\Cref{fig:example-fig} shows an example of a floating figure.
\Cref{tab:example-table} shows an example of a floating table.

\begin{table}[ht]
	\centering
	\begin{tabular}{ccc}
		\toprule
		a & b & c \\
		\midrule
		a & b & c \\
		d & e & f \\
		g & h & i \\
		\bottomrule
	\end{tabular}
	\caption{This is an example of a table with an extraordinarily long caption that requires multiple lines to demonstrate that this is, in principle, possible and still appealing.}
	\label{tab:example-table}
\end{table}

\begin{figure}[ht]
	\centering
	\includegraphics{example-image-a}
	\caption{This is an example figure}
	\label{fig:example-fig}
\end{figure}

\section{Algorithms}
%
Algorithms should be in floating environments.
\Cref{alg:swap} shows a levelwise graph mining algorithm taken from \cite{theoremofbenda}.
You can reference individual lines in the algorithm, for example \Cref{algline:swap:return}.

\begin{algorithm}
\begin{tabbing}
output \= : \= \kill
input \> : \> A set of people $P$ who have been mindswapped, plus two helpers $a,b$ \\
\>\>who have never been mindswapped \\
output \> : \> $P \cup \{a,b\}$ with the right minds in the right bodies \\
\end{tabbing}

\begin{algorithmic}[1]

\State Have everybody who's messed up arrange themselves in circles of "conga lines", i.e. everyone's front facing someone's back, each facing the body their mind should land in (e.g., if Fry's mind is in Zoidberg's body, then Zoidberg's body should face the back of Fry's body).

\ForAll{Circle}

	\State Start each time with Helper $a$ and Helper $b$'s minds in either their own or each other's bodies

	\State Pick any circle of messed-up people you like and unwrap it into a line with whoever you like at the front

	\State Swap the mind at the front of the line into Helper $a$'s body

	\State From back to front, have everybody in the line swap minds with Helper $b$'s body in turn. (This moves each mind in the line, apart from the front one, forward into the right body. The last switch puts Helper $a$'s mind into Helper $b$'s body.)

	\State Swap the mind in Helper $a$'s body back where it belongs, into the body at the back of the line. This puts Helper $b$'s mind in Helper $a$'s body. Now the circle/line has been completely fixed. The one side effect is that for each time a circle is fixed, the Helpers' minds will switch places, but that's OK, see below\label{algline:swap:return}
\EndFor

\State At the very end, after all the circles have been fixed, mind-swap the two Helpers if necessary (i.e., in case there was originally an odd number of messed-up circles)

\end{algorithmic}
\vspace{1em}
\caption{Mind Swapping Algorithm \cite{theoremofbenda}}
\label{alg:swap}
\end{algorithm}

\section{Theorem-like Environments} \label{sec:theorem-like-environments}
% list the predefined environments

The \texttt{mlai-thesis} class provides the following set of theorem-like environments with an appropriate numbering scheme using the \texttt{ntheorem} package:
\begin{description}[font=\normalfont\ttfamily]
	\item[defn] Technical notions, such as abstract structures, complexity measures, data structures, etc., that are central for your thesis should be emphasized by properly \emph{defining} them in a \emph{definition} environment.
	\item[thm] A \emph{theorem} is an important and central theoretical result of your thesis and should be presented as such.
	\item[proof] \emph{Proofs} are necessary for every of your own theoretical results and most of the time come directly after a theorem, lemma, or proposition. Note that you can usually cite theorems by other authors without proof. When in doubt consult your supervisor.
	\item[prop] A \emph{proposition} is a self-contained mathematical result. Usually, a theoretical result that is interesting but not central for the research problem of your thesis can be presented as a proposition.
	\item[lem] A \emph{lemma} is a minor statement or an auxiliary statement that is used in the proof of another proposition or theorem. It is sensible to structure complicated proofs into logical units to improve the
	\item[cor] A \emph{corollary} is an immediate and obvious consequence of a theorem or proposition and as such does not require a comprehensive proof.
	\item[rmk] Observations, ideas, motivations that you want to emphasize as such but are not really mathematical statements can be set as a \emph{remark}.
	\item[rmks] Used for multiple \emph{remarks}.
	\item[exa] It is always a good idea to provide an \emph{example} that illustrates a notion, idea, or a result in an easy-to-understand way.
	\item[exas] Used for multiple \emph{examples}.
	\item[prblm] A (research) \emph{problem} you want to study or present and that is relevant for your thesis
	\item[prblms] Used for multiple \emph{problems}.
	\item[quest] If you study a certain \emph{question} and want to refer to it at other points in the thesis, it might be worth it to typeset it in a theorem-like environment.
	\item[quests] Used for multiple \emph{questions}.
\end{description}

The advantage of using theorem-like environments is not only that they are more prominent in the text emphasizing central notions and results but also that they can be labeled and referenced. The usage of theorem-like environments and how to reference them is demonstrated below. For instance,~\Cref{prblm:mind-switching-problem} was produced by the following \LaTeX{} code:
\begin{Verbatim}
\begin{prblm}[Mind-Switching Problem]
	\label{prblm:mind-switching-problem}
	...
\end{prblm}
\end{Verbatim}

\begin{prblm}[Mind-Switching Problem]
    \label{prblm:mind-switching-problem}
    \textcolor{red}{todo} %TODO:
\end{prblm}

\begin{defn}
	\textcolor{red}{todo} %TODO:
\end{defn}

\begin{thm}[Keeler's Theorem]
	\textcolor{red}{todo} %TODO:
\end{thm}

For more information on the \texttt{ntheorem} package, refer to its documentation. %TODO: cite the documentation

\section{List Environments}
% itemize, enumerate, description

You can use the following nestable list environments
\begin{description}[font=\normalfont\ttfamily]
	\item[itemize] used for bullet lists without numbering
	\item[enumerate] used for numbered lists
	\item[description] used for item description lists (such as this one)
\end{description}

This is an example for nested bullet lists:
\begin{enumerate}
	\item Philip J. Fry
	\begin{itemize}
		\item was cryogenically frozen
		\item delivery boy at Planet Express
		\item former pizza delivery boy
	\end{itemize}
	\item Turanga Leela
	\begin{itemize}
		\item one-eyed mutant
		\item purple hair
		\item spaceship captain of \enquote{Old Bessie}
	\end{itemize}
	\item Bender Bending Rodr\'{i}guez
	\begin{itemize}
		\item Bending Unit 22
		\item Unit no. 1729
		\item Serial no. 2716057
	\end{itemize}
\end{enumerate}

\section{Citations}

You can use the bibliography package of your liking. If you choose to stick with the default, i.e., \texttt{biblatex} with \texttt{biber} as a backend, you can cite sources by using the following commands:
\begin{description}[font=\normalfont\ttfamily]
	\item[\textbackslash{}cite] a bare citation without parentheses; example: \cite{adams1979}
	\item[\textbackslash{}parencite] a citation enclosed in parentheses; example: \parencite{adams1979}
	\item[\textbackslash{}textcite] a citation that is part of the text; example: \textcite{adams1979}
\end{description}
The \texttt{biblatex} package provides a rich tool set for citations and the bibliography. For further information, refer to the \texttt{biblatex} documentation. %TODO: cite the biblatex documentation
In addition, the MLAI student's guide contains a section on what and how to cite your references properly according to scientific style. %TODO: cite the MLAI student's guide


\subsection{Implementing a Model-Checker}

\begin{frame}
  \frametitle{Implementing a Model-Checker}

  In order to implement model-checker we need:
  \begin{enumerate}
    \item representing large sets of states
    \item computing $T(S^{(i)})$
    \item check if bad states are in $S^{(i)}$
    \item check if $S^{(i)} \equiv S^{(i+1)}$
  \end{enumerate}
  \vfill\pause
  The naive way would be to represent states {\bf explicitly}
  (e.g., with a C {\tt struct} containing values for state variables)
  \vfill
  Very few model-checkers adopt this method (e.g., SPIN)
  \vfill\pause
  A more powerful approach represents
  states {\bf symbolically},
  by means of SAT/SMT-formul\ae: each set of
  states $S$ is represented by a formula $\phi$ such
  that $S$ corresponds to the models of $\phi$

\end{frame}

\begin{frame}
  \frametitle{Symbolic Model-Checking - Representing States}

  \scriptsize

  Examples:
  \medskip\\
  \begin{tabular}{ccc}

    \begin{minipage}{.4\textwidth}
      \input{symb_1}
    \end{minipage}
    &~ &
    door\_open $\wedge$ engine\_on $\wedge$ $\neg$ tray\_full \\
    \pause
    \\

    \begin{minipage}{.4\textwidth}
      \input{symb_2}
    \end{minipage}
    &~ &
    $\neg$ door\_open $\wedge$ engine\_on $\wedge$ $\neg$ tray\_full \\
    \pause
    \\

    \begin{minipage}{.4\textwidth}
      \input{symb_3}
    \end{minipage}
    &~ &
    engine\_on $\wedge$ $\neg$ tray\_full \\

  \end{tabular}
  \vfill\pause
  Also, it is easy to see that:
  \medskip\\
  \begin{tabular}{ccc}
    $S_1 \cup S_2$ & & $\phi_1 \vee \phi_2$ \\
    $S_1 \cap S_2$ & & $\phi_1 \wedge \phi_2$ \\
    $S_1 \subseteq S_2$ & & $\phi_1 \rightarrow \phi_2$
  \end{tabular}

\end{frame}

\begin{frame}
  \frametitle{Symbolic Model-Checking - Representing Transitions}

  \scriptsize

  Transitions are also represented as formul\ae\xspace between state
  variables and their primed versions
  \vfill
  \begin{tabular}{llllcl}
    \multirow{2}{*}{if} & door=closed & \multirow{2}{*}{then} & tray'=empty & & \multirow{2}{*}{[start\_washing]} \\
                        & engine=off  &                       & engine'=on  & &                                   \\
  \end{tabular}
  \vfill
  $$
    \neg \mbox{door\_open} \wedge \neg \mbox{engine\_on} \wedge \neg \mbox{door\_open'} \wedge \mbox{engine\_on'} \wedge \neg \mbox{tray\_full'}
  $$
  \vfill\pause
  This formula says that the following pair of states are related
  $$
  \begin{array}{rcl}
    \neg \mbox{door\_open} \wedge \neg \mbox{engine\_on} \wedge \neg \mbox{tray\_full}
    & ~~~ & \neg \mbox{door\_open'} \wedge \mbox{engine\_on'} \wedge \neg \mbox{tray\_full'} \\
    \\
    \neg \mbox{door\_open} \wedge \neg \mbox{engine\_on} \wedge \mbox{tray\_full}
    & ~~~ & \neg \mbox{door\_open'} \wedge \mbox{engine\_on'} \wedge \neg \mbox{tray\_full'}
  \end{array}
  $$

\end{frame}

\begin{frame}
  \frametitle{Symbolic Model-Checking - Computing Next State}

  \scriptsize

  From a set of states $S^{(i)}$, represented symbolically by a formula $\phi( \vec{s} )$,
  and a transition $t_j$, represented symbolically by a formula $\psi( \vec{s}, \vec{s'} )$,
  the next states $t_j(S^{(i)})$ can be expressed as
  $$
  \exists \vec{s}.\ \phi( \vec{s} ) \wedge \psi( \vec{s}, \vec{s'} )
  $$
  By means of an operation called {\bf quantifier elimination}, we can remove $\vec{s}$.
  If then we rename $\vec{s'}$ as $\vec{s}$ we obtain the symbolic representation of $t_j(S^{(i)})$
  \vfill\pause
  Example:
  $$
  \begin{array}{l}
    \phi \equiv \neg \mbox{door\_open} \wedge \neg \mbox{engine\_on} \\
    \psi \equiv \neg \mbox{door\_open} \wedge \neg \mbox{engine\_on} \wedge
                \neg \mbox{door\_open'} \wedge \mbox{engine\_on'} \wedge \neg \mbox{tray\_full'} \\
  \end{array}
  $$
  Quantifier elimination of $\exists \mbox{ door\_open}, \mbox{engine\_on}.\ \phi \wedge \psi$ is
  $$
    \neg \mbox{door\_open'} \wedge \mbox{engine\_on'} \wedge \neg \mbox{tray\_full'}
  $$
  and therefore
  $$
    \neg \mbox{door\_open} \wedge \mbox{engine\_on} \wedge \neg \mbox{tray\_full}
  $$
  is $t_j(S^{(i)})$. The whole set of next states $T(S^{(i)})$ is
  $\bigvee_j t_j( S^{(i)} )$

\end{frame}

\begin{frame}
  \frametitle{Symbolic Model-Checking - Bad states in $S^{(i)}$}

  Suppose that $\phi$ is the symbolic representation of $S^{(i)}$,
  and that $\beta$ is the symbolic representation of the {\bf bad states}
  \vfill
  checking if some bad state is in $S^{(i)}$ can be simply done with\pause
  $$
    \phi \wedge \beta \mbox{ is satisfiable ?}
  $$

\end{frame}

\begin{frame}
  \frametitle{Symbolic Model-Checking - Fix point test}

  Suppose that $\phi_i$ is the symbolic representation of $S^{(i)}$
  and that $\phi_{i+1}$ is the symbolic representation of $S^{(i+1)}$
  how do I that $S^{(i)} \equiv S^{(i+1)}$ ?
  \vfill\pause
  First of all, notice that $S^{(i)} \equiv S^{(i+1)}$ if and only if
  $$
    S^{(i)} \subseteq S^{(i+1)} \mbox{ and } S^{(i+1)} \subseteq S^{(i)}
  $$
  \vfill\pause
  $S^{(i)} \subseteq S^{(i+1)}$ always holds (explored states grow monotonically)
  \vfill\pause
  $S^{(i+1)} \subseteq S^{(i)}$ can be perfomed with the following check
  $$
  \begin{array}{l}
    \phi_{i+1} \rightarrow \phi_i \mbox{ is a tautology ? or equivalently} \\
    \phi_{i+1} \wedge \neg \phi_i \mbox{ is unsafisfiable ? }
  \end{array}
  $$

\end{frame}

\begin{frame}
  \frametitle{Symbolic Model-Checking - Summary}

  Model-Checking can be implemented by representing
  states and transitions symbolically with SAT/SMT-formul\ae
  \vfill
  Next states $T(S^{(i)})$ can be computed using quantifier elimination
  \vfill
  Presence of bad states can be computed with a satisfiability call of
  the form $\phi \wedge \beta$
  \vfill
  Fix-point check can be computed with a satisfiability call of the
  form $\phi_{i+1} \wedge \neg \phi_i$

\end{frame}

\begin{frame}
  \frametitle{Symbolic Model-Checking - Termination}

  \begin{boxedminipage}{\textwidth}
  \begin{center}
  Forward-Reachability
  \begin{tabular}{rcl}
     \\
       {\bf Safety Check} & ~~ & If $\phi_i \wedge \beta$ is satisfiable, return {\bf unsafe} \\
        {\bf Next States} & ~~ & Compute $\phi_{i+1}$ with quantifier elimination \\
    {\bf Fix-Point Check} & ~~ & If $\phi_{i+1} \wedge \neg \phi_i$ is unsatisfiable, return {\bf safe}
  \end{tabular}
  \end{center}
  \end{boxedminipage}
  \vfill
  Model-Checking always terminates if the satisfiability
  tests above terminates
  \begin{itemize}

    \item If the system under inspection
	  is a {\bf finite state machine}, everything can be encoded
	  into Booleans, and so they always terminate (SAT-solver is enough)

    \item If the system has {\bf infinite states} (e.g., $0 \leq x \wedge y \geq 2$),
	  it terminates if everyting can be encoded into a decidable SMT theory
	  (e.g., \Lia) (SMT-Solver necessary)

    \item If quantifiers are needed to express states, then Forward-Reachability
          might not terminate (SMT-Solver plus clever way of handling quantifiers)

  \end{itemize}

\end{frame}