\documentclass[%handout,
	sans,
	12pt,
	%slidescentered,% center text on slide
	%draft,			% compile as draft version
	%notes,			% include notes in slides
	%compress		% compress navigation bar
]{beamer}

\beamertemplatenavigationsymbolsempty

\usetheme{default}
\usecolortheme{orchid}
\setbeamertemplate{frametitle}
{
    \vspace*{1.5em}\insertframetitle\vspace*{-1.5em}
}
\setbeamertemplate{footline}[frame number]

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}

\usepackage{mathpazo}
\usepackage[british]{babel}
\usepackage{csquotes}

\newcommand{\high}[1]{{\usebeamercolor[fg]{structure} #1}}
\newcommand{\bad}[1]{\textcolor{red}{#1}}
\newcommand{\gray}[1]{\textcolor{darkgray}{#1}}
\newcommand{\black}[1]{\textcolor{black}{#1}}

\usepackage{amsmath,amssymb}
\usepackage{upgreek}
\usepackage{booktabs}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{colortbl}
\usepackage{url}
\usepackage{setspace}
\usepackage{wrapfig}
\usepackage{tabularx}
\usepackage{xspace}
\usepackage{mathpartir}

\usepackage{tikz}
\usetikzlibrary{trees, positioning}
\usetikzlibrary{shapes.geometric}

\usepackage{isabelle,isabellesym}
\isabellestyle{it}
\def\isacartoucheopen{}%
\def\isacartoucheclose{}%

\newcommand{\NN}{\mathbb{N}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\CC}{\mathbb{C}}
\renewcommand{\epsilon}{\varepsilon}
\renewcommand{\phi}{\varphi}
\def\braces#1{[#1]}
\newcommand{\wrt}{w.\,r.\,t.\xspace}
\newcommand{\eg}{e.\,g.\xspace}
\newcommand{\ie}{i.\,e.\xspace}
\DeclareMathOperator\caret{\char`\^}

\newcommand{\hastype}{\,:\,}
\newcommand{\cons}{::}
\newcommand{\corrto}{\overset{\scriptscriptstyle\wedge}{=}}
\newcommand{\listapp}{\mathbin{@}}
\newcommand{\listnil}{[\hskip0.3mm]}
\newcommand{\listnth}{\mathbin{!}}
\newcommand{\expectation}{\text{\upshape E}}

\usepackage{manfnt}
\newenvironment{danger}{\medbreak\noindent\hangindent=2pc\hangafter=-2%
  \clubpenalty=10000%
  \hbox to0pt{\hskip-\hangindent\hskip0.25em\raisebox{-0.25em}[0pt][0pt]{\dbend}\hfill}\small\ignorespaces}%
  {\medbreak\par}
  %\raisebox{-1.05em}[0pt][0pt]{\Huge\hskip.15em \stixdanger}

\newcommand{\etAl}{\textit{et al.}\xspace}

%\definecolor{mybg}{rgb}{0.9,0.9,0.9}
\definecolor{mybg}{rgb}{1,1,1}
\setbeamercolor{background canvas}{bg=mybg}

\title{Verification of an Approximation Algorithm for the Metric Travelling Salesperson Problem}
\author{\normalsize Fabian Hellauer}
\institute[]{\footnotesize Technische Universität München}
\date{\footnotesize16 October 2019}

\begin{document}

\maketitle

\begin{frame}
\begin{center}
\includegraphics[width=5cm]{isabelle.pdf}
\end{center}
\end{frame}

\newcommand{\pivot}[1]{{\color{red}#1}}
\newcommand{\ltpiv}[1]{{\color{blue}#1}}
\newcommand{\gtpiv}[1]{{\color{olive}#1}}

\section{Verification of Algorithms}
\begin{frame}{Verification of Algorithms}%<very fast>
Reasons:
\begin{itemize}
	\item a basis for reliable software\pause
	\item find mistakes in algorithm explanations\pause
	\item prove that verification of executable programs
	is feasible\ % when using a modern tool like
	\pause when using \includegraphics[height=1em]{isabelle.pdf}Isabelle\pause
\end{itemize}
Mathematical results might be a requirement.
%In this case here, from graph theory.
\end{frame}

\section{Metric TSP}
\begin{frame}
	TSP is the problem of finding a tour of minimal cost within a graph.\\\pause
	We consider the special case where the nodes form a \textit{metric space} with their weights.\\\pause
	In particular,\pause
	\begin{itemize}
		\item \textit{weight} is total
		% All TSP cities are connected by an edge, in other words we require the graph to be complete.
		\item $\textit{weight}\ v_1\ v_3\ \leq\ \textit{weight}\ v_1\ v_2\ +\ \textit{weight}\ v_2\ v_3$
		\item $0\ \leq\ \textit{weight}\ v_1\ v_2$\pause
	\end{itemize}
	In such a graph, the cost of a \textit{minimum spanning tree} is a lower bound on the optimal tour cost.
\end{frame}

\section{Approximation Algorithms}
\begin{frame}{Approximation Algorithms}
	What are Approximation Algorithms?\pause%based on (metric) TSP
	\vspace{1em}
	\includegraphics[width=\linewidth]{OPT_line}
	%OPT is the performance of an *actual* algorithm, namely the brute-force algorithm that tries all exponentially many node sequences.
	\vspace{1em}\pause %Since we consider undirected graphs, the reverse of a TSP tour is also a TSP tour (I omitted these duplicates in the graphic)

	\high{Good solutions for NP-complete problems in polynomial time!}
\end{frame}

\section{Algorithm Explanation}
\begin{frame}
\begin{center}
	\huge\high{Algorithm Explanation}
\end{center}
\end{frame}

\subsection{Algorithm Overview}
\begin{frame}{Algorithm Overview}
Consider a complete undirected graph$G = (V, E)$ and its minimum spanning tree $T$.\pause%or rather: let one of its minimum spanning trees be $T$

We are going to
\begin{enumerate}
	\item find such a $T$\pause
	\item generate a TSP tour using $T$'s edges
\end{enumerate}% and we are going to argue that T has cost less than an optimal TSP tour
\end{frame}

\subsection{MST vs.\ TSP tour}
\begin{frame}{MST vs.\ TSP tour}
\begin{center}
	\includegraphics[height=2cm]{complete0.png}
\end{center}
\end{frame}

\subsection{MST vs.\ TSP tour}
\begin{frame}{MST vs.\ TSP tour}
\begin{center}
	\includegraphics[height=2cm]{complete1.png}
\end{center}
\end{frame}

\subsection{MST vs.\ TSP tour}
\begin{frame}{MST vs.\ TSP tour}
\begin{center}
	\includegraphics[height=2cm]{complete2.png}
\end{center}
\end{frame}

\subsection{MST vs.\ TSP tour}
\begin{frame}{MST vs.\ TSP tour}
\begin{center}
	\includegraphics[height=2cm]{complete2.png}
\end{center}
\begin{isabelle}
\isacommand{lemma}\isamarkupfalse%
\ minimum{\isacharunderscore}spanning{\isacharunderscore}tree{\isacharunderscore}le{\isacharunderscore}OPTWEIGHT{\isacharcolon}\isanewline
\ \ \isakeyword{assumes}\ {\isacartoucheopen}minimum{\isacharunderscore}spanning{\isacharunderscore}tree\ T{\isacharprime}\ {\isacharparenleft}symhull\ E{\isacharparenright}{\isacartoucheclose}\isanewline
\ \ \isakeyword{assumes}\ {\isacartoucheopen}{\isadigit{2}}\ {\isasymle}\ card\ V{\isacartoucheclose}\isanewline
\ \ \isakeyword{shows}\ {\isacartoucheopen}set{\isacharunderscore}cost\ T{\isacharprime}\ {\isasymle}\ OPTWEIGHT{\isacartoucheclose}
\end{isabelle}
\end{frame}

\subsection{Tour Search}
\begin{frame}{Tour Search}
Find an edge sequence which\pause
\begin{itemize}
	\item uses exactly the MST's edges, each of which twice\pause
	\item visits every node\pause
	\item starts and ends at the same node\pause
\end{itemize}
This sequence is then called a \textit{pretour}.\pause

Its cost is twice the cost of the MST's edges.
%And the MST's edges are, as mentioned, less than the cost of an optimal tour.
\end{frame}

\subsection{Duplicate Removal}
\begin{frame}{Duplicate Removal}
Transform the pretour into a TSP tour:
%typically we require TSP tours to visits each node exactly once. Our sequence doesn't do that yet.
\begin{itemize}
	\item remove duplicate visits, replace them by shortcuts.\pause
	%That means that when the sequence goes to an already visited node, we instead jump to the next one

	\high{This can be done at one go.}
\end{itemize}
These shortcuts always exist and do not increase the cost. %That is why we require a complete metric graph
\end{frame}

\subsection{Time Complexity}%not verified
\begin{frame}{Time Complexity}\pause
\begin{itemize}
	\item MST generation: $\mathcal{O}(|E| \log |E|) = \mathcal{O}(n^2 \log (n^2)) = \mathcal{O}(2(n^2 \log n)) = \mathcal{O}(n^2 \log n)$%We use Kruskal's, which sorts edges by comparisons
	\pause
	\item Tour: $\mathcal{O}(n)$ %This is the number of edges in the MST. We discuss later how we can arrange the edges in time linear to this, to-do: Is this actually covered?
	\pause
\end{itemize}
overall: $\mathcal{O}(n^2 \log n)$
\end{frame}

\section{Results}
%What I did in the setting of this algorithm
\begin{frame}
\begin{center}
	\huge\high{Results}
\end{center}
\end{frame}

\subsection{Algorithm Sketch}
\begin{frame}{Algorithm Sketch} %and its Specification?
%We have a fixed graph here, OPT depends on it
\begin{isabelle}
	\isacommand{definition}\isamarkupfalse%
	\ two{\isacharunderscore}approx\ \isakeyword{where}\isanewline
	\ \ {\isacartoucheopen}two{\isacharunderscore}approx\ {\isacharequal}\ SPEC\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ is{\isacharunderscore}tour\ T\ {\isasymand}\ cost\ T\ {\isasymle}\ OPT\ {\isacharplus}\ OPT{\isacharparenright}{\isacartoucheclose}%explain lack of multiplication
	\vspace{1mm}\pause\\
	\isacommand{definition}\isamarkupfalse%
	\ algorithm{\isacharunderscore}sketch\ \isakeyword{where}\ {\isacartoucheopen}algorithm{\isacharunderscore}sketch\ {\isacharequal}\isanewline
	do\ {\isacharbraceleft}\isanewline
	\ \ MST\ {\isasymleftarrow}\ SPEC\ {\isacharparenleft}{\isasymlambda}E{\isacharprime}{\isachardot}\ minimum{\isacharunderscore}spanning{\isacharunderscore}tree\ {\isacharparenleft}ind\ E{\isacharprime}{\isacharparenright}\ G{\isacharparenright}{\isacharsemicolon}\isanewline
	\ \ pretour\ {\isasymleftarrow}\ SPEC\ {\isacharparenleft}{\isasymlambda}pT{\isachardot}\ int{\isacharunderscore}vertices\ pT\ {\isacharequal}\ nodes\ G\\ \ \ \ \ {\isasymand}\ cost\ pT\ {\isasymle}\ set{\isacharunderscore}cost\ MST\ {\isacharplus}\ set{\isacharunderscore}cost\ MST{\isacharparenright}{\isacharsemicolon}\isanewline
	\ \ tour\ {\isasymleftarrow}\ SPEC\ {\isacharparenleft}{\isasymlambda}T{\isachardot}\ is{\isacharunderscore}tour\ T\ {\isasymand}\ cost\ T\ {\isasymle}\ cost\ pretour{\isacharparenright}{\isacharsemicolon}\isanewline
	\ \ RETURN\ tour\isanewline
	{\isacharbraceright}{\isacartoucheclose}
\end{isabelle}\pause
\vspace{-4mm}
\begin{theorem}
	\hspace{2.6cm}$\textit{algorithm{\isacharunderscore}sketch} \le \textit{two{\isacharunderscore}approx}$\\
\upshape if $G$ is a complete finite metric graph.
\end{theorem}
\end{frame}

\subsection{Phase I}%MST generation
%It was already in a library, but had to be adjusted
\begin{frame}{Phase I}

\begin{isabelle}
	\isacommand{locale}\isamarkupfalse%
	\ finite{\isacharunderscore}weighted{\isacharunderscore}connected{\isacharunderscore}graph\ {\isacharequal}\ finite{\isacharunderscore}weighted{\isacharunderscore}graph\ {\isacharplus}\ connected{\isacharunderscore}graph\isanewline
	\isakeyword{begin}\isanewline
	\isanewline
	\ \ \isacommand{lemma}\isamarkupfalse%
	\ kruskal{\isadigit{0}}{\isacharunderscore}MST{\isacharcolon}\ {\isacartoucheopen}s{\isachardot}kruskal{\isadigit{0}}\ {\isasymle}\ SPEC\ {\isacharparenleft}{\isasymlambda}E{\isacharprime}{\isachardot}\ minimum{\isacharunderscore}spanning{\isacharunderscore}tree\ {\isacharparenleft}ind\ E{\isacharprime}{\isacharparenright}\ G{\isacharparenright}{\isacartoucheclose}
	\isanewline
	\isanewline
	\isacommand{end}\isamarkupfalse%
\end{isabelle}\pause%This also includes that the forest is a tree (simple) and that it still is minimal in the symhull (quite a bit of work...)

\begin{isabelle}
	\isacommand{sublocale}\isamarkupfalse%
	\ complete{\isacharunderscore}finite{\isacharunderscore}weighted{\isacharunderscore}graph\ {\isasymsubseteq}\\ \ \ finite{\isacharunderscore}weighted{\isacharunderscore}connected{\isacharunderscore}graph
	\end{isabelle}\pause
This required a reorganisation in the \textit{Kruskal} AFP entry.
\end{frame}

\subsection{Library Connections}
\begin{frame}{Library Connections}\pause
\vspace{3mm}
\begin{enumerate}
	\item \textit{Kruskal}: edges with weight field, undirected/directed\pause
	%to-do: vielleicht unterringeln?
	% I improved this library: I had to reorganise this one to get what I want without unnecessary assumptions.
	\item \textit{DFS\_Framework}: edges are node relations, directed\pause
	\item \textit{Koenigsberg\_Friendship}: edges have a label, undirected\pause
	%Even worse, there are different notions of "undirected"
	%So we really have the worst case in terms of compatibility.
	%Koenigsberg-Friendship also forbids loops, for technical reasons
	%It also reinterprets..., Kruskal also has a definition "is_path_undir".
	%to-do: add Noschinski, a third notion of "undirected".
	%"There are even more graph libraries out there: The somewhat new work by Noschinski starts anew,
	% with the reasonable modeling of undirected edges as two-element-sets (It sounds reasonable, and is well argued for).
	%Sadly, the fresh start did not really establish a new standard."
\end{enumerate}
%Example Conversion:\pause
\begin{isabelle}
\isacommand{lemma}\isamarkupfalse%
\ ex{\isadigit{1}}{\isacharunderscore}the{\isacharunderscore}path{\isacharcolon}\isanewline
\ \ \isakeyword{assumes}\ {\isacartoucheopen}is{\isacharunderscore}path{\isacharunderscore}undir\ G\ v\ ps\ v{\isacharprime}{\isacartoucheclose}\isanewline
\ \ \isakeyword{shows}\ {\isacartoucheopen}{\isasymexists}{\isacharbang}ps{\isacharprime}{\isachardot}\ map\ fst\ ps{\isacharprime}\ {\isacharequal}\ map\ fst\ ps\ {\isasymand}\ is{\isacharunderscore}path{\isacharunderscore}undir\ G\ v\ ps{\isacharprime}\ v{\isacharprime}{\isacartoucheclose}
\isanewline \pause
\isanewline
	\isacommand{definition}\isamarkupfalse%
	\ the{\isacharunderscore}path\ \isakeyword{where}\isanewline
	\ \ {\isacartoucheopen}the{\isacharunderscore}path\ nodelist\ lst\ {\isacharequal}\ {\isacharparenleft}case\ nodelist\ of\isanewline
	\ \ \ \ {\isacharbrackleft}{\isacharbrackright}\ {\isasymRightarrow}\ {\isacharbrackleft}{\isacharbrackright}\ {\isacharbar}\isanewline
	\ \ \ \ n\ {\isacharhash}\ ns\ {\isasymRightarrow}\ THE\ ps{\isachardot}\ map\ fst\ ps\ {\isacharequal}\ nodelist\\\ \ \ \ \ \ {\isasymand}\ is{\isacharunderscore}path{\isacharunderscore}undir\ G\ n\ ps\ lst{\isacharparenright}{\isacartoucheclose}
\end{isabelle}

\end{frame}

\subsection{Library Connections -- Example}
\begin{frame}{Library Connections -- Example}\pause
\begin{isabelle}
	\isacommand{lemma}\isamarkupfalse%
	\ spanning{\isacharunderscore}forest{\isacharunderscore}symhull{\isacharcolon}\isanewline
	\ \ {\isacartoucheopen}spanning{\isacharunderscore}forest\ F\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\ edges\ {\isacharequal}\ E{\isasymrparr}\ \\\ \ \ \ {\isasymLongrightarrow}\ spanning{\isacharunderscore}forest\ F\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\ edges\ {\isacharequal}\ symhull\ E{\isasymrparr}{\isacartoucheclose}
\end{isabelle}\pause
\begin{isabelle}
	\isacommand{lemma}\isamarkupfalse%
	\ {\isacharparenleft}\isakeyword{in}\ finite{\isacharunderscore}weighted{\isacharunderscore}graph{\isacharparenright}\\\ \ spanning{\isacharunderscore}forest{\isacharunderscore}symhull{\isacharunderscore}preimage{\isacharcolon}\isanewline
	\ \ \isakeyword{assumes}\ {\isacartoucheopen}spanning{\isacharunderscore}forest\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\ edges{\isacharequal}F{\isasymrparr}\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\\\ \ \ \  edges{\isacharequal}symhull\ E{\isasymrparr}{\isacartoucheclose}\isanewline
	\ \ \isakeyword{shows}\ {\isacartoucheopen}{\isasymexists}F{\isacharprime}{\isachardot}\\\ \ \ \ spanning{\isacharunderscore}forest\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\ edges{\isacharequal}F{\isacharprime}{\isasymrparr}\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\ edges{\isacharequal}E{\isasymrparr}\isanewline
	\ \ \ \ {\isasymand}\ edge{\isacharunderscore}weight\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\ edges{\isacharequal}F{\isacharprime}{\isasymrparr}\ \\\ \ \ \ \ \  {\isacharequal}\ edge{\isacharunderscore}weight\ {\isasymlparr}nodes{\isacharequal}V{\isacharcomma}\ edges{\isacharequal}F{\isasymrparr}{\isacartoucheclose}
\end{isabelle}
\end{frame}

\subsection{Phase II}
\begin{frame}{Phase II}
\begin{center}
\includegraphics[height=7cm]{Sorted_binary_tree_preorder}
\end{center}
%to-do: attribute "By Sorted_binary_tree.svg: Milesderivative work: Pluke (talk) - Sorted_binary_tree.svg, Public Domain, https://commons.wikimedia.org/w/index.php?curid=10616003"
\end{frame}

\subsection{Phase II -- Parametrisation} %to-do: replace according to e-mail
\begin{frame}{Phase II -- Parametrisation}
\vspace{8mm}
We use the \textit{DFS-Framework}. This is the parametrisation:
\vspace{-2mm}
\begin{isabelle}
	\isacommand{definition}\isamarkupfalse%
	\ fp{\isadigit{0}}{\isacharunderscore}params\ {\isacharcolon}{\isacharcolon}\ {\isachardoublequoteopen}{\isacharprime}v\ fp{\isadigit{0}}{\isacharunderscore}param{\isachardoublequoteclose}\ \isakeyword{where}\isanewline
	{\isachardoublequoteopen}fp{\isadigit{0}}{\isacharunderscore}params\ {\isasymequiv}\ dflt{\isacharunderscore}parametrization\ state{\isachardot}more\isanewline
	\ \ {\isacharparenleft}RETURN\ {\isasymlparr}\ tour{\isacharunderscore}list\ {\isacharequal}\ {\isacharbrackleft}{\isacharbrackright}\ {\isasymrparr}{\isacharparenright}\isanewline
	\ \ {\isasymlparr}on{\isacharunderscore}discover\ {\isacharcolon}{\isacharequal}\ {\isasymlambda}{\isacharunderscore}\ n\ s{\isachardot}\ RETURN\ {\isasymlparr}tour{\isacharunderscore}list\ {\isacharequal}\ tour{\isacharunderscore}list\ s\ {\isacharat}\ {\isacharbrackleft}n{\isacharbrackright}{\isasymrparr}\ {\isasymrparr}{\isachardoublequoteclose}
\end{isabelle}\pause
\vspace{-5mm}
\begin{isabelle}
	\isacommand{locale}\isamarkupfalse%
	\ node{\isacharunderscore}and{\isacharunderscore}MST{\isacharunderscore}in{\isacharunderscore}graph\ {\isacharequal}\isanewline
	\ \ complete{\isacharunderscore}finite{\isacharunderscore}metric{\isacharunderscore}graph\ G\ {\isacharplus}\isanewline
	\ \ T{\isacharcolon}\ tree\ T\isanewline
	\ \ \isakeyword{for}\ G{\isacharcolon}{\isacharcolon}{\isacartoucheopen}{\isacharparenleft}{\isacharprime}v{\isacharcolon}{\isacharcolon}metric{\isacharunderscore}space{\isacharcomma}real{\isacharparenright}\ graph{\isacartoucheclose}\isanewline
	\ \ \isakeyword{and}\ T{\isacharcolon}{\isacharcolon}{\isacartoucheopen}{\isacharparenleft}{\isacharprime}v{\isacharcomma}real{\isacharparenright}\ graph{\isacartoucheclose}\ {\isacharplus}\isanewline
	\ \ \isakeyword{fixes}\ v\isactrlsub {\isadigit{0}}{\isacharcolon}{\isacharcolon}{\isacartoucheopen}{\isacharprime}v{\isacartoucheclose}\isanewline
	\ \ \isakeyword{assumes}\ v{\isacharunderscore}in{\isacharunderscore}V{\isacharcolon}\ {\isacartoucheopen}v\isactrlsub {\isadigit{0}}\ {\isasymin}\ V{\isacartoucheclose}\isanewline
	\ \ \isakeyword{and}\ mst{\isacharcolon}\ {\isacartoucheopen}minimum{\isacharunderscore}spanning{\isacharunderscore}tree\ T\ G{\isacartoucheclose}
\end{isabelle}
\end{frame}

%to-do: simplification of Phase II? not really my work, but something which slowed me down...

\section{Plans}
\begin{frame}
\begin{center}
	\huge\high{Plans}%time ran out sadly...
\end{center}
\end{frame}

\subsection{Input Generation}% We need a script that generates the edge weights for us.
\begin{frame}{Input Generation}
Consider a Euclidean space like $\RR^2$, $\RR^3$,\dots
	\begin{itemize}
		\item A popular metric is the \textit{Euclidean} metric.\pause

		\bad{It is often irrational, and thus difficult to store and compare with infinite precision.}\pause
		\item In contrast, the \textit{maximum metric} and the \textit{Manhattan metric} return natural numbers. %When the coordinates are natural numbers.
		%to-do: definition? small drawing?
	\end{itemize}
	%application drilling robot
\end{frame}

\subsection{DFS Invariant}
\begin{frame}{DFS Invariant}\pause
	finish this proof\pause
	\vspace{-2mm}
	\begin{isabelle}
		\isacommand{lemma}\isamarkupfalse%
		\ {\isacartoucheopen}dfs{\isachardot}is{\isacharunderscore}invar\ {\isacharparenleft}{\isasymlambda}s{\isachardot}\ valid{\isacharunderscore}graph{\isachardot}tour\ {\isacharparenleft}ind{\isacharprime}\ {\isacharparenleft}dom\ {\isacharparenleft}discovered\ s{\isacharparenright}{\isacharparenright}{\isacharparenright}\ {\isacharparenleft}tour{\isacharunderscore}list\ s{\isacharparenright}{\isacharparenright}{\isacartoucheclose}
	\end{isabelle}\pause
	Advancing this proof has already led to generally useful statements for the \textit{DFS-Framework}, e.g.\ \pause
	\begin{isabelle}
		\isacommand{lemma}\isamarkupfalse%
		\ i{\isacharunderscore}snd{\isacharunderscore}pending{\isacharunderscore}sane{\isacharcolon}\ {\isacartoucheopen}dfs{\isachardot}is{\isacharunderscore}invar\ {\isacharparenleft}{\isasymlambda}s{\isachardot}\ snd\ {\isacharbackquote}\ {\isacharparenleft}pending\ s{\isacharparenright}\ {\isasymsubseteq}\ V{\isacharparenright}{\isacartoucheclose}
	\end{isabelle}\pause
	\begin{isabelle}
		\isacommand{lemma}\isamarkupfalse%
		\ i{\isacharunderscore}stack{\isacharunderscore}sane{\isacharcolon}\ {\isacartoucheopen}dfs{\isachardot}is{\isacharunderscore}invar\ {\isacharparenleft}{\isasymlambda}s{\isachardot}\ set\ {\isacharparenleft}stack\ s{\isacharparenright}\ {\isasymsubseteq}\ V{\isacharparenright}{\isacartoucheclose}
	\end{isabelle}\pause
	\begin{isabelle}
		\isacommand{lemma}\isamarkupfalse%
		\ i{\isacharunderscore}discovered{\isacharunderscore}sane{\isacharcolon}\ {\isacartoucheopen}dfs{\isachardot}is{\isacharunderscore}invar\ {\isacharparenleft}{\isasymlambda}s{\isachardot}\ dom\ {\isacharparenleft}discovered\ s{\isacharparenright}\ {\isasymsubseteq}\ V{\isacharparenright}{\isacartoucheclose}
	\end{isabelle}
\end{frame}

\section{Conclusion}
\begin{frame}{Conclusion}
Even with parts already verified, formal verification can require a lot of work:
\begin{itemize}
	\item Differing graph formalisations\pause!\pause
	%in particular connecting Digraph.graph_rec to my own finite_complete_weighted...graph
	\item For this particular algorithm, a lot of assumptions have to be collected and formulated.\pause %complete_finite_weighted is actually complete_finite_weighted_simple_loopfree_metric_graph

	%"Not really part of a conclusion, but I want to mention it here since I had to leave out much context earlier for brevity."
	\item Definitions have many dependencies. %They e.g. have to fix a graph, a subtree and an arbitrary node at the same time.
\end{itemize}
\end{frame}

\section{Questions}
\begin{frame}
\begin{center}
	\huge\high{Questions}
\end{center}
\end{frame}

%to-do: Problems?

\end{document}

%to-do: compare to the plan from the meeting:
%25+5min

%explain in the presentation:

%Bibliotheken vorstellen, Wahl begründen
%--> Graphformalisierungen: directed vs. undirected edges in both phases. Welche gibt es alle?
%edge labels, i.e. a third field besides start node and end node 5min
%MST lemma zeigen, wieso nicht Graph_Theory? 5min
%was ist der projektstatus? 5min
%maybe a slide about the commit count?
%add dfs-sublocale statement to plans. "This is already proven. However, the set membership must be implemented..."


\documentclass{fancyArticle}
\usepackage{lipsum}

\title{A Sample Document}
\author{Gary Baker}
\date{\today}

\begin{document}
\maketitle

\begin{abstract}
  \lipsum[1]
\end{abstract}
\pagebreak

\section{A first section}

This\footnote{\lipsum[1][3]} demonstrates the footnote
style. \lipsum[4] Here's another footnote\footnote{\lipsum[30][1]}
followed by a numbered equation.

\begin{equation}
  \label{eq:1}
  e^{i\pi}+1 = 0
\end{equation}

\lipsum[5]

\subsection{A subsection}

\lipsum[6]

\begin{equation*}
  V(l) = \max_{\beta\geq 0}\left\{ -c(\beta) * \Delta + e^{-r\Delta}
    \left[ \int \frac{1}{2} (\tanh(l/2)+1) V(l+\hat{s}) f_\beta(s) ds \right]\right\}
\end{equation*}

\lipsum[7]

\section{A section with some citations}

\cite{Nash1950} and \cite{Rubinstein1982} say some things about
bargaining. Those citations are also clickable links to their
respective entries in the bibliography.

\lipsum [20-21]

\pagebreak
\bibliography{sampleBib.bib}

\end{document}


\documentclass{article}

\usepackage[british]{babel}
\usepackage[useregional]{datetime2}
\DTMlangsetup[en-GB]{showdayofmonth=false}

\usepackage[utf8]{inputenc}

\usepackage{amsmath}
\usepackage{float}
\usepackage{graphicx}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    filecolor=magenta,
    urlcolor=blue,
}

\title{Machine Learning}
\author{Josh Myers-Dean \and Robin Cosbey}
\date{\today}

\begin{document}

\maketitle
\newpage
\tableofcontents
\newpage

\section{Introduction}
The term ``machine learning'' was defined in 1959 as \textit{a field of study that gives computers the ability to learn without being explicitly programmed.} This means that rather than giving a computer a list of instructions to follow, we take advantage of the computer's representational abilities. The computer \textit{learns} patterns in data. Machine learning is essentially a math problem: $y = h(x)$ where $x$ is the input, $y$ is the output and $h$ represents the function (mathematical model) applied. In simple terms we are learning a mapping from $x$ to $y$. The goal of this workshop is to dive into the topics presented in \ref{fig:flow}, show how the process of each step and provide some resources.

\begin{figure}[H]
    \centering
    \includegraphics[width=3in]{flowchart.jpeg}
    \caption{General machine learning workflow. \href{https://www.freecodecamp.org/news/every-single-machine-learning-course-on-the-internet-ranked-by-your-reviews-3c4a7b8026c0/}{Link}}
    \label{fig:flow}
\end{figure}

\subsection{Unsupervised and Supervised Learning}
We primarily see \textit{unsupervised} and \textit{supervised} learning algorithms. Both are given a set of examples to learn from, known as \textit{training data}. In the case of supervised learning, we have ground truth output associated with the input data unlike unsupervised learning in which the computer is only given the input and ``clusters'' the examples based on similarity rather than learning from the mappings provided. Most of this workshop will focus on supervised learning.
\begin{figure}[H]
    \centering
    \includegraphics[width=3.1in]{supervision.png}
    \caption{Unsupervised consists of clustering whereas supervised (in this case binary classification) consists of finding a boundary between data points. \href{https://chatbotsmagazine.com/lets-know-supervised-and-unsupervised-in-an-easy-way-9168363e06ab}{Link}}
\end{figure}

\newpage
\subsection{Tasks}

The two general types of problems that can be solved with supervised machine learning techniques are \textbf{classification} and \textbf{regression}. The main difference between the two is the output: classification has a categorical (discrete) output whereas regression has a numerical (continuous) output.

\begin{figure}[H]
    \centering
    \includegraphics[width=3.5in]{tasks.png}
    \caption{Basic distinction between the two types of tasks. \href{https://medium.com/datadriveninvestor/supervised-vs-unsupervised-machine-learning-5200ffa7301a}{Link}}
    \label{fig:tasks}
\end{figure}

\subsubsection{Classification}
Classification algorithms are used when the outputs are restricted to a limited set of values. The basic form is \textit{binary classification} as shown in \ref{fig:tasks} in which the model assigns each input to one of two outputs. For example, if we have a model that identifies if an image contains a dog, the output would be the prediction of either `dog' or `not dog' (true or false).

\begin{figure}[H]
    \centering
    \includegraphics[width=3.5in]{dogs.jpg}
    \caption{Can you tell which photos contain a dog? Can a computer? \href{https://www.npr.org/sections/thesalt/2016/03/11/470084215/canine-or-cuisine-this-photo-meme-is-fetching}{Link}}
\end{figure}

\newpage
\subsubsection{Regression}
Regression involves continuous values such as temperature, length and price. You typically see regression models used for finding relationships between variables and for forecasting. How do age, gender and diet impact height? This is an example of input variables (age, gender and diet), referred to as \textit{predictor variables}, and their relationship to a single output (height) known as the \textit{outcome variable}. Unlike classification, we determine a trend from the training data fed into the model.

\begin{figure}[H]
    \centering
    \includegraphics[width=3.5in]{regression.png}
    \caption{Regression line showing the relationship between hours studied and exam score. \href{https://stackabuse.com/linear-regression-in-python-with-scikit-learn/}{Link}}
\end{figure}

\newpage
\section{Data}
So what does data look like in machine learning?
Aside from numerical data, anything that can be encoded as a numerical value or set of numerical values, such as images, words, or audio.
With images, we can encode each pixel into their RGB numerical value.
Audio data can be represented numerically based on features or by way of images with what are called spectograms.
Words can be encoded as numbers, or word frequencies throughout an entire document might be used.
We also use categorical data, a number that represents a group i.e. dogs, cats, or birds used primarily in classification tasks.
Typically, this data is put into a matrix, let's examine some famous data sets where you can see real examples of data used in machine learning.

\subsection{Data Sets}
Let's examine some data sets that are commonly used by those exploring machine learning. Probably the most famous among these data sets, is the MNIST data set; a collection of handwritten numbers. We can use this data set to classify each picture as the number it is meant to represent. The MNIST data set is quite large and machine learning models are able to get up to 99\% accuracy classifying these images.

\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{mnist.png}
    \caption{MNIST Data set \href{http://yann.lecun.com/exdb/mnist/}{dataset linked here}.}
\end{figure}

\newpage

Another smaller data set is the Iris data set. In this case, we are not dealing with image data, we are given attributes. There are three kinds of iris represented in this data set and we are given four attributes of each flower: the sepal length and width, and the petal length and width.

\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{iris.png}
    \caption{Iris Data set \href{https://archive.ics.uci.edu/ml/datasets/iris}{dataset linked here}.}
\end{figure}

This is a great data set for beginners because there are only 150 iris samples, making it easy to test and debug. Take a look at the links included to get a feel for what data looks like in machine learning.

\subsection{Bias in Data}
As you begin a machine learning project, one of the first steps is to find the dataset you will be working with. As you are forming the initial questions that you hope to answer with your efforts make sure to also ask the data some questions. Before you start building a model to work with the data, you should have a firm understanding of the distribution and makeup of the data itself. Many news stories have surfaced over the years indicating the explicit, inherent biases in many publicly released face and object recognition systems and it is not hard to believe that similar stories can be found in other domains.

This analysis of your data is especially important when considering problems directly related to society. As the systems we build gain trust from the public, we, as computer scientists, can have great implications unknowingly on the world we live in. Throughout this analysis be on the lookout for an uneven distribution of data. Additionally, keep in mind that the biases present throughout history can be found implicitly in the datasets produced in those times and by using that data to train a model you are propagating those biases forward through time. Sometimes you may need to evaluate the types of problems you are looking to solve and ensure the value of this pursuit for the community.

\newpage
\subsection{Data Preparation}
The above datasets, MNIST and Iris, are \textit{clean}. There are no missing values, or random Unicode characters that are going to trip you up when trying to parse the data. Often, data needs to be cleaned and made consistent. This process of making sure that data is clean can take up a lot of time. If an entire chunk of data is missing should it be averaged with its neighbors or be given the value of the previous data point? These are considerations a machine learning engineer will encounter. There is also the consideration of how to store input and output data as you will often train and re-train a model many times with different parameters that can be tuned called hyperparameters or maybe parse the data in a different way to see if that leads to any performance gains. Since you will want to run your model many times, you don't want to have to re-parse your cleaned data each time you want to run it as that takes a lot of time, so you will want to store your cleaned data somehow. You may also want to save various configurations of your trained model, so you will need an efficient and organized way to store trained models. You can also create data based off of your current data set, this is called data augmentation and may be something as simple as when building an image classifier reflecting some of your images horizontally or vertically to make you model more robust to image orientation. So, data preparation is a complex beast. There are many techniques that can be explored and many components to consider when preparing data.

After our data has been cleaned we typically want to split our data into train, development (sometimes called ``validation''), and test. You'll understand more in depth as to how these data sets are used after reading the \textit{Training} section. For now, understand that in order to train a model we will need data it can see (train), new data it can see to check its progress while training (development), and more data to see if it learned a pattern that can be applied to unseen data (test). We generally want to reserve 70\% for our training set, 10\% for our development set, and 20\% for our test set. You are not limited to splitting your data in this way and can try out different configurations as well.

\subsection{Training}
Once we have an understanding of the data we are working with, have preprocessed the data appropriately and split the data into a train, development and test set, now it is time to design your model. More on the types of the basic machine learning and deep learning models in future sections. The training phase allows the the model to learn from the examples provided and understand the presents in the data. The development, or validation, phase is when we tune hyperparameters -- \textit{hyperparameters} are typically related to the model architecture. Slight changes to the hyperparameters will produce different results with the model. This process repeats for a predefined amount of time. Only once we have completed training and hyperparameter tuning do we turn to the test data. The test set is used to independently assess the accuracy of the model on held out data that has not been seen previously.

\newpage
\section{Machine Learning \& Deep Learning}
There are many differences between deep learning and machine learning algorithms. Features are pieces of information that are intended to be relevant to performing a task. For example, if we were to build an animal classifier using a machine learning algorithm a feature we may want to include is the type of coat an animal has: fur, scales, or feathers. We would want to include as many of these distinctive features as possible for each animal and then give those pieces of information to our machine learning algorithm and this would create a model that can classify animals. But with deep learning we wouldn't need to manually identify distinctive characteristics of animals, we can just give our deep learning algorithm thousands of pictures of animals. Deep learning algorithms are capable of finding which pieces of information about a picture for example, are important without human assistance. This is one benefit of deep learning algorithms.

Another difference between machine learning and deep learning algorithms is their expressiveness. Machine learning algorithms generally revolve around optimizing linear functions to fit our data. However, not all patterns found in data can be expressed by linear functions.

\begin{figure}[H]
    \centering
    \includegraphics[width=5.0in]{linearvsnonlinear.png}
    \caption{Non-linear models are able to model more complex patterns.}
\end{figure}

Deep learning algorithms can consist of one or more linear or non-linear transformations. Because of this, deep learning models are able to model both linear and non-linear patterns in data. This is very powerful, and is the \textit{secret sauce} of deep learning models. Because deep learning algorithms are able to model much more complex and nuanced patterns in data, they require a lot more data than traditional machine learning algorithms which are trying to model simpler patterns. While a machine learning model may require thousands of data points to do well, a deep learning model may require millions making deep learning much more computationally expensive.

\newpage
\subsection{Decision Trees}
Decision trees are tree-like structures that can represent probability, decisions, and much more.

\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{decisiontree.png}
    \caption{Decision Tree}
\end{figure}

\subsubsection{Random Forest}
Random Forest is a supervised machine learning algorithm that can be used for both classification and regression tasks that consists of a collection of decision trees, hence the name. Here is the general algorithm:

\begin{enumerate}
    \item Split data into $n$ random sets selecting $m$ random features from each sample.
    \item Create a decision tree using each subset of data.
    \item Given new sample, each of these independent trees makes a prediction.
    \item The prediction with the most "votes" from our trees is our overall prediction.
\end{enumerate}

For a regression task, we would average the predictions made by all of the decision trees. This idea of averaging decisions of multiple models is called bootstrap aggregating or bagging and can reduce variance and overfitting.

Essentially, every decision tree will make a prediction and the most common prediction in among all of the decision trees will be the outcome. When using the random forest algorithm for regression, we will average the output of each decision tree.

\newpage
\subsection{Support Vector Machines (SVMs)}
Support vector machines are a simple model that do not require a large amount of data and separate classes represented in data. SVMs are simple discriminative classifiers that output an optimal decision boundary between the datapoints provided. When new datapoints are fed through the SVM, they are classified based on where they fall in relation to the decision boundary. This boundary is often referred to as a ``hyperplane.''  The margin is the distance from the boundary to the nearest datapoint. We want to find a decision boundary that allows points to be in their respective classes without crossing the boundary into other classes and a good margin is one where this separation is large for all classes represented. scikit-learn offers a SVM tool that is easy to download to test with given data. More information about SVMs and the toolkit can be found \href{https://scikit-learn.org/stable/modules/svm.html}{here}.

\begin{figure}[H]
    \centering
    \includegraphics[width=3.5in]{svm.jpeg}
    \caption{Decision boundary (yellow dashed line) separating the red from blue. \href{https://medium.com/deep-math-machine-learning-ai/chapter-3-support-vector-machine-with-math-47d6193c82be}{Link}}
\end{figure}

\newpage
\subsection{KNN}
K-Nearest Neighbors is an supervised machine learning algorithm that can be used for classification and regression tasks. Let's focus on classification. In this case we won't do any training using our training data, we will using the position of our training data in space to classify unseen data points.

\begin{figure}[H]
    \centering
    \includegraphics[width=4.0in]{knn.png}
    \caption{KNN Algorithm.}
\end{figure}

\begin{enumerate}
    \item Select number of neighbors to examine $k$.
    \item Given an unseen data point, find $k$ nearest data points.
    \item The class that appears the most of those $k$ nearest data points is the class of our unseen data point.
\end{enumerate}

You can experiment with different distance metrics like Euclidean distance, Manhattan distance, or Cosine similarity. Because there is no training time involved, this can be a good option when time is limited and is relatively easy to setup. K-Nearest Neighbors may not be a good idea if you have very high dimensional or feature-rich data. This is because of something called the Curse of Dimensionality; as we go into higher and higher dimensional space distance as we know it becomes more skewed and two things that are very different may seem to be "close" to each other in high dimensional space. For more on the Curse of Dimensionality and how higher dimensionality can affect your models read \href{https://towardsdatascience.com/curse-of-dimensionality-2092410f3d27}{this article}.

\newpage
\subsection{Deep Neural Networks (DNNs)}
DNNs are commonly used within problem spaces with a lot of available data. Once the data is preprocessed, we provide the data as input to the DNN. The data undergoes a series of non-linear transformations. This is what separates deep neural networks from one-layer, shallow, linear neural networks. These transformations are followed by a linear transformation which produces the output or result.
\begin{figure}[H]
    \centering
    \includegraphics[width=3.5in]{nn.jpg}
    \caption{Simple DNN with two hidden non-linear layers. \href{https://www.digitaltrends.com/cool-tech/what-is-an-artificial-neural-network/}{Link}}
\end{figure}

\href{https://playground.tensorflow.org}{Tutorial here.}

\newpage
\subsection{Convolutional Neural Networks (CNNs)}

Convolutional Neural Networks are mostly used with image data to perform image classification and other image related tasks.

\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{cnn.jpeg}
    \caption{Unrolling an RNN. Each input is fed through to produce an output at the given timestep. We also pass context forward through time. \href{https://towardsdatascience.com/a-comprehensive-guide-to-convolutional-neural-networks-the-eli5-way-3bd2b1164a53}{Link}}
\end{figure}

\subsection{Recurrent Neural Networks (RNNs)}

Recurrent Neural Networks strength lies in finding patterns in sequential data, whether that be sentences, audio, or protein sequences. They have special cells which allow them to keep important information seen from past samples or from future samples. There are many different variations of RNNs, here is a link to some RNN tutorials written in PyTorch \href{https://github.com/yunjey/pytorch-tutorial/tree/master/tutorials/02-intermediate}{here}.

\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{rnn.png}
    \caption{Unrolling an RNN. Each input is fed through to produce an output at the given timestep. We also pass context forward through time. \href{https://medium.com/@jianqiangma/all-about-recurrent-neural-networks-9e5ae2936f6e}{Link}}
\end{figure}

\newpage
\section{Further Topics}

\subsection{Reinforcement Learning}
\href{https://deepmind.com/research/publications/playing-atari-deep-reinforcement-learning/}{Paper}
\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{rl.jpg}
    \caption{In recent years deep learning has been introduced to reinforcement learning algorithms to improve performance. The agent chooses an action and receives updated information of the environment in order to choose a new action. Deep approaches have been used to augment the agent. \href{https://www.kdnuggets.com/2018/03/5-things-reinforcement-learning.html}{Link}}
\end{figure}

\subsection{Generative Adversarial Networks}
\href{https://arxiv.org/abs/1406.2661}{Paper}
\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{gans.png}
    \caption{We have been able to achieve incredible results using this model to generate things. This is done by training a generator and discriminator model. The generator tries to generate a realistic sample from the training set and the discriminator does its best to tell if the sample given to it is from the training set or a generated "fake" sample. By doing this we are able to train a generator that can create extremely good "fakes" or generated samples. Things it may try to "fake" and generate are images, audio, or video. \href{https://skymind.ai/wiki/generative-adversarial-network-gan}{Link}}
\end{figure}

\newpage
\subsection{Few Shot Learning}
\href{https://openreview.net/forum?id=HkxLXnAcFQ}{Paper}
\begin{figure}[H]
    \centering
    \includegraphics[width=4.5in]{fewshot.png}
    \caption{Few shot learning works to train a model on very few examples of given classes. Many training episodes are used to understand the distinctions between the classes provided.  \href{https://medium.com/sap-machine-learning-research/deep-few-shot-learning-a1caa289f18}{Link}}
\end{figure}
\newpage

\end{document}