\chapter{Vectors}

We have talked a some about forces, but in the calculations that we
have done, we have only talked about the magnitude of a force. It is
equally important to talk about its direction. To do the math on
things with a magnitude and a direction (like forces), we need vectors.\index{vectors}

For example, if you jump out of a plane (hopefully with a parachute),
several forces with different magnitudes and directions will be acting upon
you. Gravity will push you straight down. That force will be proportional to your weight.
If there were a wind from the west, it would push you toward the east. That force
will be proportional to the square of speed of the wind and approximately proportional to
your size. Once you are falling, there will be resistance from the air
that you are pushing through -- that force will point in the opposite direction
from the direction you are moving and will be proportional to the square of your
speed.

To figure out the net force (which will tell us how we will accelerate), we will
need to add these forces together. So we need to learn to do math with vectors.

\section{Adding Vectors}

A vector is typically represented as a list of numbers, with each
number representing a particular dimension. For example, if I am
creating a 3-dimensional vector representing a force, it will have
three numbers representing the amount of force in each of the three
axes. For example, if a force of one newton is in the direction of the
$x$-axis, I might represent the vector as $v = [1, 0, 0]$.
Another vector might be $u = [0.5, 0.9, 0.7]$ \index{vectors!adding}

\tdplotsetmaincoords{80}{130}
\begin{tikzpicture} [scale=4, tdplot_main_coords, axis/.style={->,sdkblue},
vector/.style={-stealth,black,very thick},
vector guide/.style={dashed,sdkblue}]

%standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);

%draw axes
\draw[axis] (0,0,0) -- (1.5,0,0) node[anchor=north east]{$x$};
\draw[axis] (0,0,0) -- (0,0.9,0) node[anchor=north west]{$y$};
\draw[axis] (0,0,0) -- (0,0,0.9) node[anchor=south]{$z$};

%draw a vector from O to P
\draw[vector] (O) -- (1,0,0);
\draw[vector] (O) -- (0.5,0.9,0.7);
\draw (0.2,0.0,0.05) node[left] {v};
\draw (0.2,0.35,0.3) node[right] {u};

\draw[vector guide] (0.5,0,0) -- (0.5,0.9,0);
\draw[vector guide] (0.0,0.9,0) -- (0.5,0.9,0);
\draw[vector guide] (0.5,0.9,0) -- (0.5,0.9,0.7);
\end{tikzpicture}

Thinking visually, when we add to vectors, we put the starting point
second vector at the ending point of the first vector.

\tdplotsetmaincoords{80}{130}
\begin{tikzpicture} [scale=4, tdplot_main_coords, axis/.style={->,sdkblue},
light vector/.style={-stealth,dashed,very thick, black},
vector/.style={-stealth,black,very thick},
vector guide/.style={dashed,sdkblue}]

%standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);

%draw axes
\draw[axis] (0,0,0) -- (1.5,0,0) node[anchor=north east]{$x$};
\draw[axis] (0,0,0) -- (0,0.9,0) node[anchor=north west]{$y$};
\draw[axis] (0,0,0) -- (0,0,0.9) node[anchor=south]{$z$};

%draw a vector from O to P
\draw[light vector] (0,0,0) -- (0.5,0.9,0.7);
\draw[light vector] (0.5, 0.9, 0.7) -- (1.5, 0.9, 0.7);
\draw[vector] (0,0,0) -- (1.5,0.9,0.7) node[left] {u + v};
\draw (0.7,0.9,0.75) node[left] {v};
\draw (0.2,0.35,0.3) node[right] {u};

\draw[vector guide] (0.5,0,0) -- (0.5,0.9,0);
\draw[vector guide] (0.0,0.9,0) -- (0.5,0.9,0);
\draw[vector guide] (0.5,0.9,0) -- (0.5,0.9,0.7);
\draw[vector guide] (0.5,0.9,0) -- (1.5,0.9,0.0);
\draw[vector guide] (1.5,0.9,0.0) -- (1.5,0.9,0.7);
\draw[vector guide] (1.5,0.0,0.0) -- (1.5,0.9,0.0);

\end{tikzpicture}

If you know the vectors, you will just add them element-wise:

$$ u + v = [0.5, 0.9, 0.7] + [1.0, 0.0, 0.0] = [1.5, 0.9. 0.7] $$

These vectors have 3 components, so we say they are \newterm{3-dimensional}.
Vectors can have any number of components. For example, the vector
 $[-12.2, 3, \pi, 10000]$ is 4-dimensional.

 You can only add two vectors if they have the same dimension.

 $$ [12, -4] + [-1, 5] = [11,1] $$

 Addition is commutative: If you have two vectors $a$ and $b$, then
 $a + b$ is the same as $b + a$.

 Addition is also associative: If you have three vectors $a$, $b$, and $c$,
 it doesn't matter which order you add them in.
 That is, $a + (b + c) = (a + b) + c$.

 A 1-dimensional vector is just a number.  We say it is a
 \newterm{scalar}, not a vector.

 \begin{Exercise}[title={Adding vectors}, label=adding_vectors]
Add the following vectors:
\begin{itemize}
    \item $[1, 2, 3] + [4, 5, 6]$
    \item $[-1, -2, -3, -4] + [4, 5, 6, 7]$
    \item $[\pi, 0, 0] + [0, \pi, 0] + [0, 0, \pi]$
\end{itemize}
\end{Exercise}
\begin{Answer}[ref=adding_vectors]
    \begin{itemize}
        \item $[1, 2, 3] + [4, 5, 6] = [5, 7, 9]$
        \item $[-1, -2, -3, -4] + [4, 5, 6, 7] = [3, 3, 3, 3]$
        \item $[\pi, 0, 0] + [0, \pi, 0] + [0, 0, \pi] = [\pi, \pi, \pi]$
    \end{itemize}
\end{Answer}

    \begin{Exercise}[title={Adding Forces}, label=adding_forces]
        You are adrift in space. You are near two different stars.
        The gravity of one star is pulling you towards it with a
        force of $[4.2, 5.6, 9.0]$ newtons.
        The gravity of the other star is pulling you towards it with
        a force of $[-100.2, 30.2, -9.0]$ newtons. What is the net force?
        \end{Exercise}
        \begin{Answer}[ref=adding_forces]
            To get the net force, you add the two forces:

            $$F = [4.2, 5.6, 9.0] + [-100.2, 30.2, -9.0] = [-96, 35.8, 0.0] \text{ newtons}$$

\end{Answer}

\section{Multiplying a vector with a scalar}

It is not uncommon to multiply a vector by a scalar.  For example, a rocket engine
might have a force vector $v$.  If you fire 9 engines in the exact same direction,
the resulting force vector would be $9v$.\index{vectors!multipying by a scalar}

Visually, when we multiply a vector $u$ by a scalar $a$, we get a new vector that
goes in the same direction as $u$ but has a magnitude $a$ times as long as $u$.

\tdplotsetmaincoords{80}{130}
\begin{tikzpicture} [scale=3, tdplot_main_coords, axis/.style={->,sdkblue},
vector/.style={-stealth,black,very thick},
vector guide/.style={dashed,sdkblue}]

%standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);

%draw axes
\draw[axis] (0,0,0) -- (1.6,0,0) node[anchor=north east]{$x$};
\draw[axis] (0,0,0) -- (0,2.8,0) node[anchor=north west]{$y$};
\draw[axis] (0,0,0) -- (0,0,1.9) node[anchor=south]{$z$};

%draw a vector from O to P
\draw[vector] (O) -- (0.5,0.9,0.7);
\draw (0.2,0.35,0.3) node[right] {$u$};

\draw[vector] (O) -- (1.5,2.7,2.1) node[right] {$3u$};

\draw[vector guide] (0.5,0,0) -- (0.5,0.9,0);
\draw[vector guide] (0.0,0.9,0) -- (0.5,0.9,0);
\draw[vector guide] (0.5,0.9,0) -- (0.5,0.9,0.7);

\draw[vector guide] (1.5,0,0) -- (1.5,2.7,0);
\draw[vector guide] (0.0,2.7,0) -- (1.5,2.7,0);
\draw[vector guide] (1.5,2.7,0) -- (1.5,2.7,2.1);
\end{tikzpicture}

When you multiply a vector by a scalar, you just multiply each of the components by the scalar:

$$ 3 \times [0.5, 0.9, 0.7] = [1.5, 2.7, 3.6] $$

\begin{Exercise}[title={Multiplying a vector and a scalar}, label=mult_scalar]
    Simplify the following expressions:
    \begin{itemize}
        \item $2 \times [1, 2, 3]$
        \item $[-1, -2, -3, -4] \times -2$
        \item $\pi[\pi, 2\pi, 3\pi]$
    \end{itemize}
    \end{Exercise}
    \begin{Answer}[ref=mult_scalar]
        \begin{itemize}
            \item $2 \times [1, 2, 3] = [2, 4, 6]$
            \item $[-1, -2, -3, -4] \times -3 = [3, 6, 9, 12]$
            \item $\pi[\pi, 2\pi, 3\pi]  = \pi^2, 2\pi^2, 3\pi^2]$
        \end{itemize}
    \end{Answer}

Note that when you multiply a vector times a negative number, the new vector points
in the opposite direction.

\tdplotsetmaincoords{80}{130}
\begin{tikzpicture} [scale=5, tdplot_main_coords, axis/.style={->,sdkblue},
vector/.style={-stealth,black,very thick},
vector guide/.style={dashed,sdkblue}]

%standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);

%draw axes
\draw[axis] (0,0,0) -- (0.55,0,0) node[anchor=north east]{$x$};
\draw[axis] (0,0,0) -- (0,0.95,0) node[anchor=north west]{$y$};
\draw[axis] (0,0,0) -- (0,0,0.6) node[anchor=south]{$z$};

%draw a vector from O to P
\draw[vector] (O) -- (0.5,0.9,0.7);
\draw (0.2,0.36,0.3) node[right] {$u$};

\draw[vector] (O) -- (-0.25,-0.45,-0.35) node[right] {$(-0.5)u$};

\draw[vector guide] (0.5,0,0) -- (0.5,0.9,0);
\draw[vector guide] (0.0,0.9,0) -- (0.5,0.9,0);
\draw[vector guide] (0.5,0.9,0) -- (0.5,0.9,0.7);

\draw[vector guide] (-0.25,0,0) -- (-0.25,-0.45,0);
\draw[vector guide] (0,0,0) -- (-0.25,0,0);
\draw[vector guide] (0.0,-0.45,0) -- (-0.25,-0.45,0);
\draw[vector guide] (0,0,0) -- (0,-0.45,0);

\draw[vector guide] (-.25,-0.45,0) -- (-0.25,-0.45,-0.35);
\end{tikzpicture}

\section{Vector Subtraction}

As you might guess, when you subtract one vector from another,
you just do element-wise subtraction:\index{vectors!subtraction}

$$[4,2,0] - [3,-2, 9] = [1, 4, -9]$$

So, $u - v = u + (-1v)$.

So visually, you reverse the one that is being subtracted:

\tdplotsetmaincoords{80}{130}
\begin{tikzpicture} [scale=5, tdplot_main_coords, axis/.style={->,sdkblue},
light vector/.style={-stealth,dashed,very thick, black},
vector/.style={-stealth,black,very thick},
vector guide/.style={dashed,sdkblue}]

%standard tikz coordinate definition using x, y, z coords
\coordinate (O) at (0,0,0);

%draw axes
\draw[axis] (0,0,0) -- (0.55,0,0) node[anchor=north east]{$x$};
\draw[axis] (0,0,0) -- (0,1.0,0) node[anchor=north west]{$y$};
\draw[axis] (0,0,0) -- (0,0,0.75) node[anchor=south]{$z$};

%draw a vector from O to P
\draw[light vector] (0,0,0) -- (0.5,0.9,0.7);
\draw[light vector] (0.5, 0.9, 0.7) -- (-0.5, 0.9, 0.7);
\draw[vector] (0,0,0) -- (-0.5,0.9,0.7) node[right] {u - v};
\draw (0.1,0.9,0.75) node[left] {-v};
\draw (0.29,0.34,0.32) node[right] {u};

\draw[vector guide] (0.5,0,0) -- (0.5,0.9,0);
\draw[vector guide] (0.0,0.9,0) -- (0.5,0.9,0);
\draw[vector guide] (0.5,0.9,0) -- (0.5,0.9,0.7);
\draw[vector guide] (0.5,0.9,0) -- (-0.5,0.9,0.0);
\draw[vector guide] (-0.5,0.9,0.0) -- (-0.5,0.9,0.7);
\draw[vector guide] (-0.5,0.0,0.0) -- (-0.5,0.9,0.0);
\draw[vector guide] (0,0.0,0.0) -- (-0.5,0.0,0.0);

\end{tikzpicture}

\section{Magnitude of a Vector}

The \newterm{magnitude} of a vector is just its length. We write the
magnitude of a vector $v$ as $|v|$.\index{vectors!magnitude of}

We compute the magnitude using the pythagorean theorem.  If $v = [3,4,5]$,
then

\begin{equation*}
    |v| = \sqrt{3^2 + 4^2 + 5^2} = \sqrt{50} \approx 7.07
\end{equation*}

(You might notice that the notation for the magnitude is exactly like the notation for absolute value.
If you think of a scalar as a 1-dimensional vector, the absolute value and the magnitude are the same.
For example, the absolute value of -5 is 5.  If you take the magnitude of the one-dimenional vector $[-5]$,
you get $\sqrt{25} = 5$.)

Notice that if you scale up a vector, its magnitude scales by the same amount.  For example:

\begin{equation*}
|7[3,4,5]| = 7 \sqrt{50} \approx 7 \times 7.07
\end{equation*}

The rule then is: If you have any vector $v$ and any scalar $a$:
\begin{equation*}
    |a v| = |a| |v|
\end{equation*}

\begin{Exercise}[title={Magnitude of a Vector}, label=vector_mag]
    Find the magnitude of the following vectors:
    \begin{itemize}
        \item $[1, 1, 1]$
        \item $[-5, -5, -5]$ (that is the same as $-5 \times [1, 1, 1]$)
        \item $[3, 4, -4] + [-2, -3, 5]$
    \end{itemize}
    \end{Exercise}
    \begin{Answer}[ref=vector_mag]
        \begin{itemize}
            \item $|[1, 1, 1]| = \sqrt{3} \approx 1.73 $
            \item $|[-5, -5, -5]| = |-5 \times [1,1,1]| = 5 \sqrt{3} \approx 8.66$
            \item $|[3, 4, 5] + [-2, -3, -4]| = | [1,1,1] | = \sqrt{3} \approx 1.73$
        \end{itemize}
    \end{Answer}

\section{Vectors in Python}

numpy is a library that allows you to work with vectors in Python.
You might need to install it on your computer. This is done with \pyfunction{pip}.
\pyfunction{pip3} installs things specifically for Python 3.\index{vectors!in python}

\begin{Verbatim}
pip3 install numpy
\end{Verbatim}

We can think of a vector as a list of numbers.
There are also grids of numbers known as \newterm{matrices}. numpy deals with both the same way,
so it refer to both of them as arrays.\index{numpy}

The study of vectors and matrices is known as \newterm{Linear Algebra}. Some of the functions we need
are in a sublibrary of numpy called \pyfunction{linalg}. \index{linalg}

As a convention, everyone who uses numpy, imports it as \textit{np}. \index{np}

Create a file called \filename{first\_vectors.py}:

\begin{Verbatim}
import numpy as np

# Create two vectors
v = np.array([2,3,4])
u = np.array([-1,-2,3])
print(f"u = {u}, v = {v}")

# Add them
w = v + u
print(f"u + v = {w}")

# Multiply by a scalar
w = v * 3
print(f"v * 3 = {w}")

# Get the magnitude
# Get the magnitude
mv = np.linalg.norm(v)
mu = np.linalg.norm(u)
print(f"|v| = {mv}, |u| = {mu}")
\end{Verbatim}

When you run it, you should see:

\begin{Verbatim}
> python3 first_vectors.py
u = [-1 -2  3], v = [2 3 4]
u + v = [1 1 7]
v * 3 = [ 6  9 12]
|v| = 5.385164807134504, |u| = 3.7416573867739413
\end{Verbatim}

\subsection{Formatting Floats}

The numbesr 5.385164807134504 and 3.7416573867739413 are pretty long.  You probably want it
rounded off after a couple of decimal places.

Numbers with decimal places are called \newterm{floats}. In the placeholder for your float, you
can specify how you want it formatted, including the number of decimal places.

Change the last line to look like this:\index{floats!formatting}
\begin{Verbatim}
    print(f"|v| = {mv:.2f}, |u| = {mu:.2f}")
\end{Verbatim}

When you run the code, it will be neatly rounded off to two decimal places:
\begin{Verbatim}
|v| = 5.39, |u| = 3.74
\end{Verbatim}


% \section{Introduction}\label{sec:introduction}
Refinement types enable specification of complex invariants
by extending the base type system with \emph{refinement predicates}
drawn from decidable logics. For example,
%
\begin{code}
  type Nat = {v:Int | 0 <= v}
  type Pos = {v:Int | 0 < v}
\end{code}
%
are refinements of the basic type @Int@ with a logical predicate
that states the \emph{values} @v@ being described must be
\emph{non-negative} and \emph{postive} respectively.
%
We can specify \emph{contracts} of functions by refining function types.
For example, the contract for @div@
%
\begin{code}
  div :: n:Nat -> d:Pos -> {v:Nat | v <= n}
\end{code}
%
states that @div@ \emph{requires} a non-negative dividend @n@ and a positive
divisor @d@ and \emph{ensures} that the result is less than the dividend.
%
If a program (refinement) type checks, we can be sure that @div@ will never
throw a divide-by-zero exception.

Refinement types \citep{ConstableS87,Rushby98}
have been implemented for several languages like
ML~\cite{pfenningxi98,GordonTOPLAS2011,LiquidPLDI08},
C~\cite{deputy,LiquidPOPL10},
TypeScript~\cite{Vekris16},
Racket~\cite{RefinedRacket} and Scala~\cite{refinedscala}.
%
Here we present \toolname,
a refinement type checker for Haskell.
%
In this chapter we start with an example driven informal and practical overview
of \toolname.
%
In particular, we try to answer the following questions:
%
\begin{enumerate}
  \item What properties can be specified with refinement types?
  \item What inputs are provided and what feedback is received?
  \item What is the process for modularly verifying a library?
  \item What are the limitations of refinement types?
\end{enumerate}

We attempt to investigate these questions, by using the
refinement type checker \toolname, to specify and verify a variety of
properties of over 10,000 lines of Haskell code from popular
libraries, including @containers@, \hbox{@hscolor@,} @bytestring@, @text@,
@vector-algorithms@ and @xmonad@.
%
\begin{itemize}
\item First (\S~\ref{sec:liquidhaskell}),
we present a high-level overview of \toolname, through a tour
of its features.
%

\item Second, we present a qualitative discussion of the kinds of properties
that can be checked -- ranging from generic application independent
criteria like totality (\S~\ref{sec:totality}),
\ie that a function is defined for all inputs (of a given type)
and termination,
(\S~\ref{sec:termination})
\ie that a recursive function cannot diverge,
to application specific concerns like memory safety (\S~\ref{sec:memory-safety})
and functional correctness properties (\S~\ref{sec:structures}).
%
\item Finally (\S~\ref{sec:realworld:evaluation}), we present a quantitative evaluation of the approach, with a view
towards measuring the efficiency and programmer's effort required for
verification,
and we discuss various limitations of the approach which could
provide avenues for further work.
\end{itemize}


\documentclass{article}
    % General document formatting
    \usepackage[margin=0.7in]{geometry}
    \usepackage[parfill]{parskip}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{tikz}
    \usepackage{fancyhdr}
    \usepackage{multicol}

    \usetikzlibrary{positioning}

\pagestyle{fancy}
\fancyhf{}
\rhead{Edgar Jacob Rivera Rios - A01184125}

\begin{document}
\section*{2.4.1 First-Order Logic.}
Prove the statements:
\begin{itemize}
    \item $\forall x p ( x ) \wedge \forall x q ( x ) \rightarrow \forall x ( p ( x ) \wedge q ( x ) )$
    \begin{align*}
        A &= \forall xp(x) \wedge \forall x q(x)\\
        B &= \forall x( p(x) \wedge q(x))\\
        A &\rightarrow B
    \end{align*}
    \begin{center}
        \begin{tikzpicture}[sibling distance=8em, every node/.style = {align=center}]
            \node {$\neg (A \rightarrow B) \equiv A \wedge \neg B$}
            child { node {$A, \neg B$}
              child { node {$\forall xp(x) \wedge \forall x q(x),\exists x (\neg p(x) \vee \neg q(x))$}
                child { node {$p(a) \wedge q(a), \neg p(a) \vee \neg q(a)$}
                  child { node {$p(a), q(a), \neg p(a) \vee \neg q(a)$}
                    child { node {$p(a), q(a), \neg p(a)$\\$\times$}
                      edge from parent node [left] {$\beta$}}
                    child { node {$p(a), q(a), \neg q(a)$\\$\times$}
                      edge from parent node [right] {$\beta$}}
                    edge from parent [solid] node [right] {$\alpha$}}
                  edge from parent [dashed] node [right] {instantiation}}
                edge from parent [double] node {}}
              edge from parent node [right] {$\alpha$}};
        \end{tikzpicture}
    \end{center}
    By contradiction of the inverse we found out that it's valid

    \item $\forall x ( p ( x ) \rightarrow q ( x ) ) \rightarrow ( \forall x p ( x ) \rightarrow \forall x q ( x ) )$ is a valid formula (but its converse $( \forall x p ( x ) \rightarrow \forall x q ( x ) ) \rightarrow \forall x ( p ( x ) \rightarrow q ( x ) )$ is not).
    \begin{align*}
        A &= \forall x(p(x) \rightarrow q(x))\\
        B &= \forall xp(x) \rightarrow \forall x q(x)\\
        A &\rightarrow B
    \end{align*}
    \begin{center}
        \begin{tikzpicture}[sibling distance=8em, every node/.style = {align=center}]
          \node {$\neg (A \rightarrow B) \equiv A \wedge \neg B$}
            child { node {$A, \neg B$}
              child { node {$\forall x(p(x) \rightarrow q(x)),\forall xp(x) \wedge \exists x \neg q(x)$}
                child { node {$p(a) \rightarrow q(a), p(a) \wedge \neg q(a)$}
                  child { node {$p(a) \rightarrow q(a), p(a), \neg q(a)$}
                    child { node {$\neg p(a) , p(a), \neg q(a)$\\$\times$}
                    edge from parent node [left] {$\beta$}}
                    child { node {$q(a), p(a), \neg q(a)$\\$\times$}
                    edge from parent node [right] {$\beta$}}
                  edge from parent [solid] node [right] {$\alpha$}}
                edge from parent [dashed] node [right] {instantiation}}
              edge from parent [double] node {}}
            edge from parent node [right] {$\alpha$}};
        \end{tikzpicture}
    \end{center}
    By contradiction of the inverse we found out that it's valid
\end{itemize}

\section*{2.4.2 First-Order Logic.}
Prove that the formula $( \forall x p ( x ) \rightarrow \forall x q ( x ) ) \rightarrow \forall x ( p ( x ) \rightarrow q ( x ) )$ is not valid by constructing a semantic tableau for its negation.
\begin{align*}
    A &= \forall xp(x) \rightarrow \forall x q(x) \\
    B &= \forall x(p(x) \rightarrow q(x)) \\
    A &\rightarrow B
\end{align*}
\begin{center}
  \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
    \node {$\neg (A \rightarrow B) \equiv A \wedge \neg B$}
      child { node {$A, \neg B$}
        child { node {$\forall xp(x) \rightarrow \forall x q(x), \neg \forall x(p(x) \rightarrow q(x))$}
          child {node {$\neg \forall x p(x), \neg \forall x(p(x) \rightarrow q(x))$}
            child {node {$\neg p(a), \neg (p(a) \rightarrow q(a))$}
              child { node {$p(a), \neg q(a), \neg p(a)$}
              edge from parent node {$\alpha$}}
            edge from parent node {instantiation}}
          edge from parent node {$\beta$}}
          child {node {$\neg \forall x(p(x) \rightarrow q(x)), \forall x q(x)$}}
        edge from parent [double] node {}}
      edge from parent node [right] {$\alpha$}};
  \end{tikzpicture}
\end{center}
\pagebreak
\section*{2.4.3 First-Order Logic.}
Prove that the following formulas are valid
\begin{itemize}
    \item $\exists x (\mathrm { A } ( x ) \rightarrow \mathrm { B } ( x ) ) \leftrightarrow ( \forall x \mathrm { A } ( x ) \rightarrow \exists x \mathrm { B } ( x ) )$
    \begin{align*}
        F &= \exists x (\mathrm { A } ( x ) \rightarrow \mathrm { B } ( x ) ) \\
        G &= ( \forall x \mathrm { A } ( x ) \rightarrow \exists x \mathrm { B } ( x ) )\\
        F &\rightarrow G, G \rightarrow F
    \end{align*}
    \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
      \node {$\neg (F \rightarrow G) \equiv F \wedge \neg G$}
        child { node {$F, \neg G$}
          child { node {$\exists x(A(x) \rightarrow B(x)), \neg (\forall x A(x) \rightarrow \exists x B(x))$}
            child { node {$\exists x(A(x) \rightarrow B(x)),\forall x A(x), \forall x \neg B(x)$}
              child { node {$A(a) \rightarrow B(a), A(a), \neg B(a)$}
                child { node {$\neg A(a), A(a), \neg B(a)$\\$\times$}
                edge from parent [solid] node [left] {$\beta$}}
                child { node {$B(a), A(a), \neg B(a)$\\$\times$}
                edge from parent [solid] node [right] {$\beta$}}
              edge from parent [dashed] node [right] {instantiation}}
            edge from parent node [right] {$\alpha$}}
          edge from parent [double] node {}}
        edge from parent node [right] {$\alpha$}};
    \end{tikzpicture}
    \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
      \node {$\neg (G \rightarrow F) \equiv G \wedge \neg F$}
        child { node {$\neg F, G$}
          child { node {$ \neg \exists x(A(x) \rightarrow B(x)), (\forall x A(x) \rightarrow \exists x B(x))$}
            child { node {$\neg \exists x(A(x) \rightarrow B(x)), \neg \forall x A(x)$}
              child { node {$\neg (A(a) \rightarrow B(a)), \neg A(a)$}
                child { node {$A(a), \neg B(a), \neg A(a)$\\$\times$}
                edge from parent [solid] node [right] {$\alpha$}}
              edge from parent [dashed] node [right] {instantiation}}
            edge from parent node [left] {$\beta$}}
            child { node {$\neg \exists x(A(x) \rightarrow B(x)), \exists x B(x)$}
              child { node {$\neg (A(a) \rightarrow B(a)), B(a)$}
                child { node {$A(a), \neg B(a), B(a)$\\$\times$}
                edge from parent [solid] node [right] {$\alpha$}}
              edge from parent [dashed] node [right] {instantiation}}
            edge from parent node [right] {$\beta$}}
          edge from parent [double] node {}}
        edge from parent node [right] {$\alpha$}};
    \end{tikzpicture}\\
    It's true by contradiction of the inverse implications
    \item $(\exists x A(x) \rightarrow \forall x B(x)) \rightarrow \forall x(A(x) \rightarrow B(x))$
    \begin{center}
      \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
        \node {$\neg ((\exists x A(x) \rightarrow \forall x B(x)) \rightarrow \forall x(A(x) \rightarrow B(x)))$}
          child {node {$(\exists x A(x) \rightarrow \forall x B(x)), \neg \forall x(A(x) \rightarrow B(x))$}
            child {node {$\neg \exists x A(x),\neg \forall x(A(x) \rightarrow B(x)))$}
              child {node {$\neg A(a), \neg (A(a) \rightarrow B(a))$}
                child {node {$\neg A(a), A(a) , \neg B(a)$\\$\times$}
                edge from parent [solid] node [right] {$\alpha$}}
              edge from parent [dashed] node [right] {instantiation}}
            edge from parent node [left] {$\beta$}}
            child {node {$\forall x B(x),\neg \forall x(A(x) \rightarrow B(x))$}
              child {node {$B(a), \neg (A(a) \rightarrow B(a))$}
                child {node {$B(a), A(a) , \neg B(a)$\\$\times$}
                edge from parent [solid] node [right] {$\alpha$}}
              edge from parent [dashed] node [right] {instantiation}}
            edge from parent node [right] {$\beta$}}
          edge from parent node [right] {$\alpha$}};
      \end{tikzpicture}
    \end{center}
    It's true by contradiction of the inverse
    \pagebreak
    \item $\forall x (A(x) \vee B(x)) \rightarrow (\forall x A(x) \vee \exists x B(x))$
    \begin{center}
      \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
        \node {$\neg(\forall x (A(x) \vee B(x)) \rightarrow (\forall x A(x) \vee \exists x B(x)))$}
          child {node {$\forall x (A(x) \vee B(x)), \neg (\forall x A(x) \vee \exists x B(x))$}
            child {node {$\forall x (A(x) \vee B(x)), \neg \forall x A(x), \neg \exists x B(x)$}
              child {node {$(A(a) \vee B(a)), \neg A(a), \neg B(a)$}
                child {node {$A(a), \neg A(a), \neg B(a)$\\$\times$}
                edge from parent [solid] node [left] {$\beta$}}
                child {node {$B(a), \neg A(a), \neg B(a)$\\$\times$}
                edge from parent [solid] node [right] {$\beta$}}
              edge from parent [dashed] node [right] {instantiation}}
            edge from parent node [right] {$\alpha$}}
          edge from parent node [right] {$\alpha$}};
      \end{tikzpicture}
    \end{center}
    It's true by contradiction of the inverse
    \item $\forall x (A(x) \rightarrow B(x)) \rightarrow (\exists x A(x) \rightarrow \exists x B(x))$
    \begin{center}
      \begin{tikzpicture}[sibling distance=13em, every node/.style = {align=center}]
        \node {$\neg(\forall x (A(x) \rightarrow B(x)) \rightarrow (\exists x A(x) \rightarrow \exists x B(x)))$}
          child {node {$\forall x (A(x) \rightarrow B(x)), \neg (\exists x A(x) \rightarrow \exists x B(x))$}
            child {node {$\forall x (A(x) \rightarrow B(x)), \exists x A(x), \neg \exists x B(x)$}
              child {node {$(A(a) \rightarrow B(a)), A(a), \neg B(a)$}
                child {node {$ \neg A(a), A(a), \neg B(a)$\\$\times$}
                edge from parent [solid] node [left] {$\beta$}}
                child {node {$B(a), A(a), \neg B(a)$\\$\times$}
                edge from parent [solid] node [right] {$\beta$}}
              edge from parent [dashed] node [right] {instantiation}}
            edge from parent node [right] {$\alpha$}}
          edge from parent node [right] {$\alpha$}};
      \end{tikzpicture}
    \end{center}
    It's true by contradiction of the inverse
\end{itemize}
\end{document}


\documentclass{article}

\usepackage{amsmath}
\usepackage{numprint}

\author{Daniel Fernandes Martins (danielfmt)}
\title{Question \#8 Solution}

\begin{document}

\maketitle

\textbf{Disclaimer.} This is the reasoning I used to solve the problem; it
may be wrong though. This is intended just as food for thought.

\section{Backpropagation Computation}

This question gives a hypothetical neural network and asks about how many
of the given operations are performed in a single iteration of backpropagation
(using Stochastic Gradient Descent in one data point).

The network has $L=2$, $d^{(0)}=5$, $d^{(1)}=3$, $d^{(2)}=1$, and only products
of the form $w_{ij}^{(l)}x_i^{(l-1)}$, $w_{ij}^{(l)}\delta_j^{(l)}$, and
$x_i^{(l-1)}\delta_j^{(l)}$ count as operations.

My answer was 47 operations.

\subsection{Feedforward Step}

From the input layer to the first hidden layer there are 18 operations, and from
the first hidden layer to the output layer there are 4 operations, resulting in
a total of 22 operations.

\subsection{Backpropagation Step}

The computation of delta for the output layer $\delta_j^{(L)}$ do not count as
an operation, since no such products are required. However, the computation of
each delta in the hidden layer does count, resulting in a total of 3 operations.

\subsection{Weight Update Step}

Finally, we have to update all weights after computing the deltas, resulting
in a total of 22 operations.

\end{document}


\documentclass[12pt]{cdblatex}
\usepackage{exercises}
\usepackage{fancyhdr}
\usepackage{footer}

\begin{document}

% --------------------------------------------------------------------------------------------
\section*{Exercise 6.4 Scalar curavture of a 2-sphere}

\begin{cadabra}
   {\theta, \varphi}::Coordinate.
   {a,b,c,d,e,f,g,h#}::Indices(values={\theta, \varphi}, position=independent).

   \partial{#}::PartialDerivative.

   g^{a b}::InverseMetric.  # essential when using complete (gab, $g^{a b}$)

   Gamma := \Gamma^{a}_{b c} -> 1/2 g^{a d} (   \partial_{b}{g_{d c}}
                                              + \partial_{c}{g_{b d}}
                                              - \partial_{d}{g_{b c}}).

   Rabcd := R^{a}_{b c d} ->   \partial_{c}{\Gamma^{a}_{b d}}
                             - \partial_{d}{\Gamma^{a}_{b c}}
                             + \Gamma^{e}_{b d} \Gamma^{a}_{c e}
                             - \Gamma^{e}_{b c} \Gamma^{a}_{d e}.

   Rab := R_{a b} -> R^{c}_{a c b}.

   R := R -> R_{a b} g^{a b}.

   gab := { g_{\theta\theta}   = r**2,
            g_{\varphi\varphi} = r**2 \sin(\theta)**2 }.      # cdb(ex-0604.101,gab)

   complete   (gab, $g^{a b}$)                                # cdb(ex-0604.102,gab)

   substitute (Rabcd, Gamma)
   substitute (Rab, Rabcd)
   substitute (R, Rab)

   evaluate   (Gamma, gab, rhsonly=True)                      # cdb(ex-0604.103,Gamma)
   evaluate   (Rabcd, gab, rhsonly=True)                      # cdb(ex-0604.104,Rabcd)
   evaluate   (Rab,   gab, rhsonly=True)                      # cdb(ex-0604.105,Rab)
   evaluate   (R,     gab, rhsonly=True)                      # cdb(ex-0604.106,R)
\end{cadabra}

\clearpage

\begin{align*}
   &\Cdb{ex-0604.101}\\[10pt]
   &\Cdb{ex-0604.102}\\[10pt]
   &\Cdb{ex-0604.103}\\[10pt]
   &\Cdb{ex-0604.104}\\[10pt]
   &\Cdb{ex-0604.105}\\[10pt]
   &\Cdb{ex-0604.106}
\end{align*}

\end{document}


\section{Problem Statement}
\label{sec:ProblemStatement}

Simply put: fit a smooth function through a sequence of data points,
\textit{e.g.} Figure \ref{fig:DataFittingExampleFigure}. \\
More precisely:
\begin{itemize}
  \setlength\itemsep{0em}
  \item \textbf{Given:} a time-stamped set of points in space.
  \item \textbf{Find:} a smooth vector function.
  \item \textbf{Minimize:} integral of curvature-rate-squared and sum or squared-error.
  \item \textbf{Subject to:} value, slope, and curvature at the boundaries.
\end{itemize}

\par
We will use $\bm{x}(t)$ to represent value as a function of time.
The data set is $\{t_i, \bar{\bm{x}}_i\}$, which gives measured value at each time stamp.
The time-domain of the data set is $[0, T]$.

\subsection{Objective Function}

The objective function is a weighted combination of two terms.
The first is the sum of the squared-error between the candidate vector function and the points in the data set.
The second is a smoothing-term, minimizing the integral of the third derivative of the function.

\begin{equation}
  \bm{J}\big(\bm{x}(t)\big) \; =   \;
    \frac{T}{N}  \sum_{i=0}^N \big( \bm{x}(t_i) - \bar{\bm{x}}_i \big)^2
     \; +   \; \alpha \! \int_0^T \! \dddot{\bm{x}}^2(t) \, dt
  \label{eqn:continuousObjectiveFunction}
\end{equation}

\subsection{Constraints}

The vector function $\bm{x}(t)$ must be smooth: continuous value, slope, and curvature.
\begin{equation}
  \bm{x}(t) \in \mathcal{C}^2
\end{equation}

We also require that the value, slope, and curvature be prescribed at the initial and final times.
In practice these boundary constraints can be dropped if not required by the end-user.

\begin{align}
  \bm{x}(0) = \bm{x}_0  & \quad &  \bm{x}(T) = \bm{x}_T \\
  \dot{\bm{x}}(0) = \dot{\bm{x}}_0  & \quad & \dot{\bm{x}}(T) = \dot{\bm{x}}_T \\
  \ddot{\bm{x}}(0) = \ddot{\bm{x}}_0  & \quad & \ddot{\bm{x}}(T) = \ddot{\bm{x}}_T
\end{align}


\subsection{System Identification using P. Hudzovic's method}

An extensive report on the details of P. Hudzovic's method and the accompanied
MATLAB simulations can be found here\cite{ref:comet}.

The method proposed by P. Hudzovic\cite{ref:hudzovic} is based on a model that
approximates a plant with a series of  PT1  elements  multiplied together with
varying time constants $T_k$ to form a PTn element, $G_n(s)$.

\begin{equation}
    G_n(s,r) = K_s\prod_{k=1}^{n}\frac{1}{1+s\cdot T_k(r)}
    \label{eq:pt1_series}
\end{equation}

The neat trick P. Hudzovic proposed was rather than having to find individual,
independent time constants for each PT1 element -- the effort of which greatly
increases with higher orders of $n$  --  one  should  instead  have a function
$T_k(r)$  which  spaces the time constants in a meaningful  way.  He  defines:

\begin{equation}
    T_k(r) = \frac{T}{1-(k-1)r}
    \label{eq:hudzovic}
\end{equation}

where  the  parameter  $r$  must  be confined to  the  interval  $0  \le  r  <
\frac{1}{n-1}$.

With  this  approach  the  problem  has  effectively been reduced  to  finding
appropriate values for $n$,  $T$,  and  $r$  such  that  the  step response of
$G_n(s,r)$  approximates the measured step response as  closely  as  possible.

It is not possible to \textit{directly} calculate these values, however, it is
possible construct a lookup-table from the  equations  \ref{eq:pt1_series} and
\ref{eq:hudzovic} by calculating  a  (theoretically)  infinite  number of step
responses  for  all  values  of  $n$,  $T$,  and $r$, characterising each step
response (i.e. determine $T_u$ and $T_g$),  and performing a reverse lookup on
those  results  to  find  the  parameters  $n$  and  $r$.   This   method   of
reverse-lookup   works   because   the   lookup   curves   are   monotonically
increasing/decreasing (see figure \ref{fig:hudzovic}).

In practice, it is sufficient to calculate about 50 step  response  curves for
each order  $n$  and  interpolate  between  those  points  when performing the
lookup.

Using MATLAB, the lookup table is constructed and the parameters $n$, $r$, and
$T$ are calculated based on  the  previously  determined  parameters $T_u$ and
$T_g$. The  transfer  function  $G_2(s)$  is  calculated  and turns out to be:

\begin{equation}
    G_2(s) = \frac{24.68}{1.159 s^2 + 5.365 s + 1}
\end{equation}

Figure  \ref{fig:hudzovic_step}  shows  the  step response of  the  calculated
transfer  function  $G_2(s)$  and  compares it to the measured step  response.
$G_2(s)$ seems to be a much better approximation  than  the  transfer function
$G_1(s)$ obtained in section \ref{sec:ident_Tt_PT1}.

By looking  at  the Bode-Diagram of the transfer function $G_2(s)$ (see figure
\ref{fig:hudzovic_bode}), we see one potential issue: This system  is a second
order system, which means  the  phase never exceeds \SI{180}{\degree} and thus
the parameter $K_{p,crit}$ cannot be  determined  for  any finite value of the
P-controller's gain! As a result, it will not be possible to use the method of
Ziegler-Nichols for determining controller parameters.

\begin{figure}
    \centering
    \includegraphics[width=\imagewidth]{images/hudzovic_curves_tu_tg.pdf}
    \caption{Lookup curves generated with P. Hudzovic's equations. By measuring $T_u$ and $T_g$ it is possible to look up the parameters $n$, $r$ and $T$ which can be used together with equation \ref{eq:pt1_series} to construct an accurate transfer function of the measured system.}
    \label{fig:hudzovic}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[width=\linewidth]{images/hudzovic}
    \caption{Comparison of the calculated step response function $G_2(s)$ (using P. Hudzovic's method) and the measured step response of the motor.}
    \label{fig:hudzovic_step}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[width=\linewidth]{images/hudzovic_bode}
    \caption{Bode-Diagram of the transfer function $G_2(s)$, acquired using P. Hudzovic's method}
    \label{fig:hudzovic_bode}
\end{figure}

\clearpage


\documentclass{mrl}

\title{Discrete logarithm equality across groups}
\authors{Sarang Noether\footnote{\texttt{sarang.noether@protonmail.com}}}
\affiliations{Monero Research Lab}
\date{\today}

\newcommand{\hg}{\operatorname{H}_\mathbb{G}}
\newcommand{\hh}{\operatorname{H}_\mathbb{H}}
\newcommand{\zp}{\mathbb{Z}_p}
\newcommand{\zq}{\mathbb{Z}_q}

\type{TECHNICAL NOTE}
\ident{MRL-0010}

\begin{document}

\begin{abstract}
This technical note describes an algorithm used to prove knowledge of the same discrete logarithm across different groups. The scheme expresses the common value as a scalar representation of bits, and uses a set of ring signatures to prove each bit is a valid value that is the same (up to an equivalence) across both scalar groups.
\end{abstract}

\section{Notation}
We use the shorthand notation $\mathbb{Z}_n$ to mean the group $\mathbb{Z}/n\mathbb{Z}$. Let $\mathbb{G}$ and $\mathbb{H}$ be prime-order groups where the discrete logarithm problem is assumed to be hard: for example, \texttt{secp256k1} or the $l$-subgroup of \texttt{curve25519}. Let $G,G' \in \mathbb{G}$ and $H,H' \in \mathbb{H}$ be generators of their respective groups. Suppose $|G| = p$ and $|H| = q$. Let $\hg: \{0,1\}^* \to \zp$ and $\hh: \{0,1\}^* \to \zq$ be cryptographic hash functions.

Without loss of generality, assume $p \leq q$. Choose $x \in \mathbb{Z}$ such that $0 \leq x < p$. By considering the natural projections $\mathbb{Z} \to \zp$ and $\mathbb{Z} \to \zq$ with this domain restriction, there is a bijection between elements of $\zp$ and the restriction of $\zq$. Given this, we wish to prove that, given only the values $xG'$ and $xH'$ (and other proof elements as needed), the discrete logarithm of each is a representation of the same integer. In particular, we do not wish to reveal $x$ to the verifier.

Since there is no meaningful map assumed between the two groups, our approach is to decompose $x$ into bits, treating each bit as a scalar in both $\zp$ and $\zq$ using our equivalence, and generate commitments to each bit in both groups. For each bit, we will construct a Schnorr-type ring signature showing that the bit commitment is valid and the same value in each group.

This method was originally proposed publicly by Andrew Poelstra.
\section{Algorithm}
\subsection{Prover}
Given an integer $0 \leq x < p$, express in bits: $$x = \sum_{i=0}^{n-1} b_i2^i$$ Note that because of the equivalence discussed above, each $b_i$ may be considered as an element of either $\zp$ or $\zq$ as needed, leading to a representation of $x$ in each group.
For each $i \in [0,n-2]$, generate random blinders $r_i \in \zp$ and $s_i \in \zq$. For $i = n-1$, set blinders $$r_{n-1} = (2^{n-1})^{-1}\sum_{i=0}^{n-2} r_i2^i \in \zp$$ and $$s_{n-1} = (2^{n-1})^{-1}\sum_{i=0}^{n-2} s_i2^i \in \zq$$ to ensure that $\sum_{i=0}^{n-1} r_i2^i = \sum_{i=1}^{n-1} s_i2^i = 0$.

For each $i \in [0,n-1]$, use the blinders to compute two Pedersen commitments:
\begin{eqnarray*}
C_i^G &:=& b_iG' + r_iG \in \mathbb{G} \\
C_i^H &:=& b_iH' + s_iH \in \mathbb{H}
\end{eqnarray*}
Because of this construction, the weighted commitment sums are $\sum_{i=0}^{n-1} 2^iC_i^G = xG'$ and $\sum_{i=0}^{n-1} 2^iC_i^H = xH'$ in their respective groups.

We next construct a ring signature on each bit to show it is either $0$ or $1$, and that the value is the same (up to our equivalence) in both groups. Specifically, for each $i \in [0,n-1]$, we consider two cases:

\textbf{Case:} $b_i = 0$. Choose random $j_i \in \zp$ and $k_i \in \zq$. Set
\begin{eqnarray*}
e_{1,i}^G &:=& \hg\left( C_i^G, C_i^H, j_iG, k_iH \right) \in \zp \\
e_{1,i}^H &:=& \hh\left( C_i^G, C_i^H, j_iG, k_iH \right) \in \zq
\end{eqnarray*}
and choose random $a_{0,i} \in \zp$ and $b_{0,i} \in \zq$. Set
\begin{eqnarray*}
e_{0,i}^G &:=& \hg\left( C_i^G, C_i^H, a_{0,i}G - e_{1,i}^G(C_i^G-G'), b_{0,i}H - e_{1,i}^H(C_i^H-H') \right) \in \zp \\
e_{0,i}^H &:=& \hh\left( C_i^G, C_i^H, a_{0,i}G - e_{1,i}^G(C_i^G-G'), b_{0,i}H - e_{1,i}^H(C_i^H-H') \right) \in \zq
\end{eqnarray*}
and then define:
\begin{eqnarray*}
a_{1,i} &:=& j_i + e_{0,i}^Gr_i \in \zp \\
b_{1,i} &:=& k_i + e_{0,i}^Hs_i \in \zq
\end{eqnarray*}

\textbf{Case:} $b_i = 1$. Choose random $j_i \in \zp$ and $k_i \in \zq$. Set
\begin{eqnarray*}
e_{0,i}^G &:=& \hg\left( C_i^G, C_i^H, j_iG, k_iH \right) \in \zp \\
e_{0,i}^H &:=& \hh\left( C_i^G, C_i^H, j_iG, k_iH \right) \in \zq
\end{eqnarray*}
and choose random $a_{1,i} \in \zp$ and $b_{1,i} \in \zq$. Set
\begin{eqnarray*}
e_{1,i}^G &:=& \hg\left( C_i^G, C_i^H, a_{1,i}G - e_{0,i}^GC_i^G, b_{1,i}H - e_{0,i}^HC_i^H \right) \in \zp \\
e_{1,i}^H &:=& \hh\left( C_i^G, C_i^H, a_{1,i}G - e_{0,i}^GC_i^G, b_{1,i}H - e_{0,i}^HC_i^H \right) \in \zq
\end{eqnarray*}
and then define:
\begin{eqnarray*}
a_{0,i} &:=& j_i + e_{1,i}^Gr_i \in \zp \\
b_{0,i} &:=& k_i + e_{1,i}^Hs_i \in \zq
\end{eqnarray*}

The proof is the tuple $\left( xG',xH',\{C_i^G\},\{C_i^H\}, \{e_{0,i}^G\}, \{e_{0,i}^H\}, \{a_{0,i}\}, \{a_{1,i}\}, \{b_{0,i}\}, \{b_{1,i}\} \right)$.

\subsection{Verifier}
Given a proof tuple, we first ensure the bit commitments faithfully represent the discrete logarithm commitments by checking that the following equations hold:
\begin{eqnarray*}
\sum_{i=0}^{n-1} 2^iC_i^G &=& xG' \in \mathbb{G} \\
\sum_{i=0}^{n-1} 2^iC_i^H &=& xH' \in \mathbb{H}
\end{eqnarray*}

For each $i \in [0,n-1]$, compute the following:
\begin{eqnarray*}
e_{1,i}^G &:=& \hg\left( C_i^G, C_i^H, a_{1,i}G - e_{0,i}^GC_i^G, b_{1,i}H - e_{0,i}^HC_i^H \right) \in \zp \\
e_{1,i}^H &:=& \hh\left( C_i^G, C_i^H, a_{1,i}G - e_{0,i}^GC_i^G, b_{1,i}H - e_{0,i}^HC_i^H \right) \in \zq \\
(e_{0,i}^G)' &:=& \hg\left( C_i^G, C_i^H, a_{0,i}G - e_{1,i}^G(C_i^G-G'), b_{0,i}H - e_{1,i}^H(C_i^H-H') \right) \in \zp \\
(e_{0,i}^H)' &:=& \hh\left( C_i^G, C_i^H, a_{0,i}G - e_{1,i}^G(C_i^G-G'), b_{0,i}H - e_{1,i}^H(C_i^H-H') \right) \in \zq
\end{eqnarray*}
Check that $(e_{0,i}^G)' = e_{0,i}^G$ and $(e_{0,i}^H)' = e_{0,i}^H$ from the proof tuple.

If all of these checks are successful, the verifier accepts the proof. Otherwise, it rejects the proof. The verifier is assumed to have also checked each proof tuple element to ensure it belongs to the expected group, to account for a malicious prover.
\end{document}


\chapter{Simple Induction}
\label{chapter:simple-induction}
\section{Proofs by Induction}
\marginurl{%
  The Induction Principle:\\\noindent
  Introduction to Mathematical Reasoning \#4
}{youtu.be/jOnZTWGpX_I}

Let us consider a simple problem: what is bigger $2^n$ or $n$? In this chapter,
we are going to study the simplest way to prove that $2^n > n$ for all positive
integers $n$. First, let us check that it is true for small positive integers
$n$.
\begin{center}
  \begin{tabular}{l l l  l  l  l  l  l  l}
    \toprule
          & 1 & 2 & 3 & 4  & 5  & 6  & 7   & 8   \\
    \midrule
    $n$   & 1 & 2 & 3 & 4  & 5  & 6  & 7   & 8   \\
    $2^n$ & 2 & 4 & 8 & 16 & 32 & 64 & 128 & 256 \\
    \bottomrule
  \end{tabular}
\end{center}
We may also note that $2^n$ is growing faster than $n$, so we expect that if
$2^n > n$ for small positive integers $n$, then it is true for all positive
integers $n$.

Consider the following argument that uses proof by contradiction. Assume the
statement is not true; i.e., there is a positive integer $n_0$ such that
$2^{n_0} \le n_0$. Consider the minimal such $n_0$ and call it $n^*$; i.e.,
consider $n^*$ such that $2^{n^*} \le n^*$, but $2^{n* - 1} > n* - 1$.
Note that $2^{n* - 1} + 2^{n* - 1} > n^* - 1 + n^* - 1 = 2n^* - 2 \ge n*$;
hence, we get a contradiction. Therefore our assumption is false and $2^n > n$
for any positive integer $n$.

This argument looks simple, but it has a fatal flaw: we assume that the minimal
$n$ exists, and it is not clear why it is true.

To overcome this problem and make this proof formal we use the following
principle.
\begin{principle}[The Induction Principle]
  Let $P(n)$ be some statement about a positive integer $n$.
  Hence, $P(n)$ is true for every positive integer $n$ iff
  \begin{description}
    \item [(the base case)] $P(1)$ is true and
    \item [(the induction step)] $P(k - 1) \implies P(k)$ is true
      for all integers $k > 1$.
  \end{description}
\end{principle}

Let us prove now the statement using this principle.
We define $P(n)$ be the statement that ``$2^n > n$''.
$P(1)$ is true since $2^1 > 1$. Let us assume now that $2^{n - 1} > n - 1$. Note
that $2^n = 2 \cdot 2^{n - 1} > 2n \ge n - 2 \ge n$. Hence, we proved the
induction step.

\begin{template}
  \textbf{Template for proving a statement using simple induction.} \\

  We use induction by $n$. Base case for $n = 1$: \emph{present some argument
  that proves the statement with $n$ replaced by $1$}.

  Now we need to prove the induction step from $k - 1$ to $k$. Let us assume now
  that the statement is true for $n = k - 1$ for some $k$. \emph{Present some
  argument of the statement with $n$ replaced by $k$ assuming the statement is
  true if we replace $n$ by $k - 1$}. Hence, the statement is true for all $n$
  by the induction principle.
\end{template}

\begin{exercise}
  Prove that $(1 + x)^n \ge 1 + nx$ for all positive integers $n$ and real
  numbers $x \ge -1$.
\end{exercise}
\begin{solution}
  We are going to prove that using induction by $n$.

  The base case is clear. We prove now the induction step. Assume the
  induction hypothesis: $(1 + x)^n \ge 1 + nx$. Note that  $(1 + x)^{n + 1} \ge
  (1 + nx) \cdot (1 + x) = 1 + nx + x + nx^2 \ge 1 + (n + 1)x$. Which proves the
  induction step.
\end{solution}

\section{Changing the Base Case}
Let us consider the functions $n^2$ and $2^n$.

\begin{center}
    \begin{tabular}{l  l  l  l  l  l  l  l  l}
        \toprule
              & 1 & 2 & 3 & 4  & 5  & 6  & 7   & 8   \\
        \midrule
        $n^2$ & 1 & 4 & 9 & 16 & 25 & 36 & 49  & 64  \\
        $2^n$ & 2 & 4 & 8 & 16 & 32 & 64 & 128 & 256 \\
        \bottomrule
    \end{tabular}
\end{center}
Note that $2^n$ is greater than $n^2$ starting from $5$. But without some trick
we cannot prove this using induction since for $n \le 4$ it is not true!

The trick is to use the statement $P(n)$ stating that $(n + 4)^2 < 2^{n + 4}$.
The base case when $n = 1$ is true.
Let us now prove the induction step. Assume that $P(k)$ is true; i.e.,
$(k + 4)^2 < 2^{k + 4}$. Note that $2(k + 4)^2 < 2^{k + 1 + 4}$ but
$(k + 5)^2 = k^2 + 10k + 25 \le 2k^2 + 16k + 32 = 2(k + 4)^2$.
Which implies that
$2^{k + 1 + 4} > (k + 5)^2$. So $P(k + 1)$ is also true.

In order to avoid this strange $+ 4$ we may change the base
case and use the following argument.

\begin{theorem}
\label{theorem:induction-shifted-base}
    Let $P(n)$ be some statement about an integer $n$.
    Then $P(n)$ is true for every integer $n > n_0$ iff
    \begin{description}
        \item [(the base case)] $P(n_0 + 1)$ is true and
        \item [(the induction step)] $P(k - 1) \implies P(k)$ is true for all
            integers $k > n_0 + 1$.
    \end{description}
\end{theorem}

Using this generalized induction principle we may prove that $2^n \ge n^2$ for
$n \ge 4$. The base case for $n = 4$ is true. The induction step is also true;
indeed let $P(k)$ be true i.e. $(k + 4)^2 < 2^{k + 4}$. Hence,
$2(k + 4)^2 < 2^{k + 1 + 4}$ but
$(k + 5)^2 = k^2 + 10k + 25 \le 2k^2 + 16k + 32 = 2(k + 4)^2$.

Let us now prove the theorem. Note that the proof is based on an idea similar
to the trick with $+ 4$, we just used.
\begin{proof}[Proof of Theorem~\ref{theorem:induction-shifted-base}]
    \begin{description}
        \item[$\Rightarrow$] If $P(n)$ is true for any $n > n_0$ it is also true
            for $n = n_0 + 1$ which implies the base case. Additionally, it true for
            $n = k$ so the induction step is also true.
        \item[$\Leftarrow$] In this direction the proof is a bit harder. Let us
            consider a statement $Q(n)$ saying that $P(n + n_0)$ is true. Note that
            by the base case for $P$, $Q(1)$ is true; by the induction step for $P$
            we know that $Q(k - 1)$ implies $Q(k)$ since $P(k + n_0 - 1)$
            implies $P(k + n_0)$. As a result, by the induction
            principle $Q(n)$ is true for all positive integers $n$. Which implies
            that $P(n)$ is true for all integers $n > n_0$.
    \end{description}
\end{proof}

\section{Inductive Definitions}

We may also define objects inductively. Consider the sum
$1 + 2 + \dots + n$ a line of dots indicating ``and so on'' which indicates the
definition by induction. In this case, a more precise notation is
$\sum_{i = 1}^n i$.

\begin{definition}
    Let $a(1)$, \dots, $a(n)$, \dots be a sequence of integers. Then
    $\sum_{i = 1}^n a(i)$ is defined inductively by the following
    statements:
    \begin{itemize}
        \item $\sum_{i = 1}^1 a(i) = a(1)$, and
        \item $\sum_{i = 1}^{k + 1} a(i) =
            \sum_{i = 1}^k a(i) + a(k + 1)$.
    \end{itemize}
\end{definition}
\nomenclature[C]{$\sum_{i = 1}^k \alpha_i$}{denotes $\alpha_1 + \dots +
\alpha_k$}

Let us prove that $\sum_{i = 1}^n i = \frac{n (n + 1)}{2}$.
Note that by definition $\sum_{i = 1}^1 i = 1$ and
$\frac{1 (1 + 1)}{2} = 1$; hence, the base case holds. Assume that
$\sum_{i = 1}^n i = \frac{n (n + 1)}{2}$. Note that
$\sum_{i = 1}^{n + 1} i = \sum_{i = 1}^n i + (n + 1)$ and by the
induction hypothesis $\sum_{i = 1}^n i = \frac{n (n + 1)}{2}$.
Hence, $\sum_{i = 1}^{n + 1} i = \frac{n (n + 1)}{2} + (n + 1) =
\frac{(n + 1)(n + 2)}{2}$.

\begin{exercise}
    Prove that $\sum_{i = 1}^n 2^i = 2^{n + 1} - 2$.
\end{exercise}

\section{Analysis of Algorithms with Cycles}

Induction is very useful for analysing algorithms using cycles. Let us extend
the example we considered in Section~\ref{section:simple-algorithm}.

Let us consider the following algorithm.
\begin{algorithm}
  \begin{algorithmic}[1]
    \Function{Max}{$a_1$, \dots, $a_n$}
      \State{$r \gets a_1$}
      \For{$i$ from $2$ to $n$}
        \If{$a_i > r$}
          \State{$r \gets a_i$}
        \EndIf
      \EndFor
      \State\Return{r}
    \EndFunction
  \end{algorithmic}
  \caption{The algorithm that finds the maximum element of $a_1$, \dots, $a_n$.}
\end{algorithm}
We prove that it is working correctly. First, we need to define $r_1$,
\dots, $r_n$ the value of $r$ during the execution of the algorithm.
It is easy to see that $r_1 = a_1$ and
\[
    r_{i + 1} =
    \begin{cases}
        r_i & \text{if } r_i > a_{i + 1} \\
        a_{i + 1} & \text{otherwise}
    \end{cases}.
\]
Secondly, we prove by induction that $r_i$ is the maximum of $a_1$, \dots,
$a_i$. It is clear that the base case for $i = 1$ is true. Let us prove the
induction step from $k$ to $k + 1$. By the induction hypothesis, $r_k$
is the maximum of $a_1$, \dots, $a_k$. We may consider two following cases.
\begin{itemize}
    \item If $r_k > a_{k + 1}$, then $r_{k + 1} = r_{k}$ is the maximum of $a_1$,
        \dots, $a_{k + 1}$ since $r_k$ is the maximum of $a_1$, \dots, $a_k$.
    \item Otherwise, $a_{k + 1}$ is greater than or equal to $a_1$, \dots, $a_k$,
        hence, $r_{k + 1} = a_{k + 1}$.
\end{itemize}

\begin{chapterendexercises}
  \exercise Show that there does not exist the largest integer.
  \exercise[recommended] Show that for any positive integer $n$, $n^2 + n$ is even.
  \exercise Show that for any positive integer $n$, $3$ divides $n^3 + 2n$.
  \exercise Show that for any integer $n \ge 10$, $n^3 \le 2^n$.
  \exercise Show that for any positive integer $n$,
    $\sum_{i = 0}^n x^i = \frac{1 - x^{n + 1}}{1 - x}$.
  \exercise[recommended] Show that $\sum_{i = 1}^n i^2 =
    \frac{n (n + 1)(2n + 1)}{6}$ for all integers $n \ge 1$.
    \begin{solution}
      We prove the statement using induction by $n$. The base case for $n = 1$
      is clear. Let us prove the induction step now. The induction hypothesis is
      $1^2 + 2^2 + 3^2 + \dots + n^2 = \frac{n (n + 1)(2n + 1)}{6}$.
      Note that
      \begin{multline*}
        1^2 + 2^2 + 3^2 + \dots + n^2 + (n + 1)^2 = \frac{n (n + 1)(2n + 1)}{6} +
        (n + 1)^2 = \\
        (n + 1)\frac{2n^2 + n + 6n + 6}{6} = (n + 1)\frac{(n + 2)(2n + 3)}{6}.
      \end{multline*}
      Hence, $1^2 + 2^2 + 3^2 + \dots + n^2 + (n + 1)^2 =
      \frac{(n + 1)(n + 2)(2n + 3)}{6}$.
    \end{solution}
  \exercise Show that $\sum_{i = 1}^n \frac{1}{i (i + 1)} =
    \frac{n}{n + 1}$ for all integers $n \ge 1$.
  \exercise Show that $\sum_{i = 1}^n \frac{1}{i^2} \le 2$ for all integers
    $n \ge 1$.
    \begin{solution}
      Let us prove a stronger statement:
      \[
        1 + \frac{1}{2^2} + \dots + \frac{1}{n^2} \le 2 - \frac{1}{n}.
      \]

      The base case is clear. We prove now the induction step. By the induction
      hypothesis the following inequality holds
      \[
        1 + \frac{1}{2^2} + \dots + \frac{1}{(n - 1)^2} \le 2 - \frac{1}{n - 1}.
      \]
      Hence,
      \[
        1 + \frac{1}{2^2} + \dots + \frac{1}{n^2} \le 2 - \frac{1}{n - 1} + \frac{1}{n^2} = 2
      \]
      but $\frac{1}{n - 1} - \frac{1}{n^2} \ge \frac{1}{n}$. Indeed,
      $\frac{1}{n - 1} \ge \frac{n + 1}{n^2}$ is equivalent to
      $\frac{1}{(n - 1)^2} \ge \frac{1}{n^2}$ which is true. As a result we proved
      the induction step.
    \end{solution}
  \exercise Show that $\sum_{i = 1}^n (2i - 1) = n^2$ for any positive integer $n$.
  \exercise Prove that $\sum_{i = 1}^n \frac{1}{i (i + 1)} = \frac{n}{n + 1}$
    for any positive integer $n$.
  \exercise Prove that $\sum_{i = 1}^n (i + 1) 2^i = n 2^{n + 1}$ for all
    integers $n > 2$.
    \begin{solution}
      First we prove the base case for $n = 1$. Note that
      $\sum\limits_{i = 1}^1 (i + 1) 2^i = 2 \cdot 2 = 2^2$; hence, the base
      case is true. Let us check the induction step from $k$ to $k + 1$. By
      the induction hypothesis
      $\sum\limits_{i = 1}^k (i + 1) 2^i = k 2^{k + 1}$.
      It is clear that
      \begin{multline*}
        \sum_{i = 1}^{k + 1} (i + 1) 2^i =
        \sum_{i = 1}^k (i + 1) 2^i + (k + 2) 2^{k + 1} = \\
          k 2^{k + 1} + (k + 2) 2^{k + 1} =
          2 (k + 1) 2^{k + 1} = (k + 1) 2^{k + 2}.
        \end{multline*}
      \end{solution}
  \exercise Let $a_1$, \dots, $a_n$ be a sequence of real numbers. We define
    inductively
    $\prod_{i = k}^n a_i$ as follows:
    \begin{itemize}
      \item $\prod_{i = 1}^1 a_i = a_1$ and
      \item $\prod_{i = 1}^{k + 1} a_i =
        \left( \prod_{i = 1}^k a_i \right) \cdot a_{k + 1}$.
    \end{itemize}
    \nomenclature[C]{$\prod_{i = 1}^k \alpha_i$}{denotes $\alpha_1 \cdot
      \ldots \cdot \alpha_k$}

    Prove that
    $\prod_{i = 1}^{n - 1} \left(1 - \frac{1}{(i + 1)^2} \right) =
      \frac{n + 1}{2n}$ for all integers $n > 1$.
  \exercise Let us define $n!$ as follows: $1! = 1$ and
    $n! = (n - 1)! \cdot n$. Show that $n! \ge 2^n$ for any $n \ge 4$.
    \nomenclature[C]{$\factorial{n}$}{denotes $n \cdot (n - 1) \cdot (n - 2) \cdot \ldots
      \cdot 1$}
  \exercise[open] Find all the natural numbers $n$ such that $n! = m^2$ for some
    integer $m$.
  \exercise Show that $\int\limits_0^{+\infty} x^n e^{- x} ~ \mathrm{d}x = n!$
    for all $n \ge 0$.
    \begin{solution}
      We prove the statement using induction by $n$. The base case is for $n =
      0$. It is easy to see that $\int\limits_0^{+\infty} e^{-x} ~ \mathrm{d}x
      = (-e^{-x})\big\rvert_0^\infty = 1$.

      Let us prove the induction step from $k$ to $k + 1$. By the induction
      hypothesis, $\int\limits_0^{+\infty} x^k e^{- x} ~ \mathrm{d}x = k!$.
      Note that
      \begin{multline*}
        \int_0^{+\infty} x^{k + 1} e^{- x} ~ \mathrm{d}x =
        -x^{k + 1} e^{- x}\big\rvert_0^\infty +
          \int_0^{+\infty} (k + 1) x^k e^{- x} ~ \mathrm{d}x = \\
        \int_0^{+\infty} (k + 1) x^k e^{- x} ~ \mathrm{d}x = (k + 1)!.
      \end{multline*}
    \end{solution}
  \exercise Show that $\sum_{k = 1}^n k \cdot k! = (n + 1)! - 1$.
  \exercise Show that \Cref{algorithm:selection-sort} executes line~6 exactly
    $\frac{n (n + 1)}{2}$ times.
    \begin{algorithm}
      \begin{algorithmic}[1]
        \Function{SelectionSort}{$a_1$, \dots, $a_n$}
          \For{$i$ from $1$ to $n$}
            \State{$r \gets a_i$}
            \State{$\ell \gets i$}
            \For{$j$ from $i$ to $n$}
              \If{$a_j > r$}
                \State $r \gets a_j$
                \State $\ell \gets j$
              \EndIf
            \EndFor
          \State{Swap $a_i$ and $a_\ell$.}
          \EndFor
        \EndFunction
      \end{algorithmic}
      \caption{The algorithm is selection sort, it sorts $a_1$, \dots, $a_n$.}
      \label{algorithm:selection-sort}
    \end{algorithm}
  \exercise Show that \Cref{algorithm:selection-sort} sorts the array.
\end{chapterendexercises}


\section{Problem Formulation}
\label{text:approach/formulation}
In this work, we are interested in finding the optimal trajectory for a robot navigating among pedestrians on the two-dimensional plane. Let $\x_t = (x_t, y_t) \in \mathbb{R}^2$ and $\dx_t = (\dot{x}_t, \dot{y}_t) \in \mathbb{R}^2 $ be the position and velocity of the robot, also referred to as $ego$, at time $t$ and $(\x, \dx)_{0:N}$, a trajectory over multiple position-velocity-pairs $((\x, \dx)_0, (\x, \dx)_1, (\x, \dx)_2, \hdots, (\x, \dx)_N)$. Within this work, the robot is assumed to have double integrator dynamics. With control input $\u_t = (u_{x, t}, u_{y, t}) \in \mathbb{R}^2$, we have:

\begin{equation}
\ddx_t = \u_t
\label{eq:robot_dynamics}
\end{equation}

For further simplification, the robot's dynamics are assumed to be deterministic.
The pedestrians (also referred to as $ados$) follow single integrator dynamics. As pointed out in \cite{Ivanovic2018}, this is a natural choice "as a person's movements are all position-changing, e.g., walking increases position along a direction, running does so faster." Other standard models for pedestrian dynamics such as Social Forces \cite{Helbing1995}, however, regard the pedestrian to be a double integrator, not a single integrator, and describe the forces acting on it introduced by other pedestrians and obstacles. Having a reasonable fast reaction time and a large maximal acceleration in comparison to the robot, both of these descriptions converge so that the single integrator model is the right choice nonetheless. \footnote{As discussed in Chapter \ref{text:experiments} the modular implementation allows us to use different pedestrian dynamics. When testing against other prediction environments non-single integrator dynamics are used, but most analysis described in this report relates to the single integrator model.}

\begin{align}
\dxped[k]_t = \uped[k]_t
\label{eq:pedestrian_dynamics}
\end{align}

Each pedestrian's future trajectory is predicted as a probabilistic and multimodal using some model $\distmodel[]$. Thereby, let $\xped[k]_t \sim \dist[k]_t$ be the distribution of the pedestrian $k$s velocity at time $t$, with mean $\muped[k]_t$, variance $\sigmaped[k]_t$, and mode-weights vector $\piped[k]_t$. The prediction is based on the past states of the robot $\x_{0:t}$ and of every pedestrian in the scene $\xped[j]_{0:t}$, including pedestrian $k$. Moreover, the function $\distmodel[]$ is generally not shared across all pedestrians but individually for each one.

\begin{align}
\xped[k]_t &\sim \distmodel[k]_t(\muped[k]_t, \sigmaped[k]_t, \piped[k]_t) \\
\dist[k]_t &= \distmodel[k] (\x_{0:t}, \xped[0]_{0:t}, \hdots, \xped[K]_{0:t})
\end{align}

Like the robot, the pedestrians are modeled as single point masses, both underlying speed bounds defined by the $L_2$ norm of their velocities. Furthermore, both the robot and the pedestrians underly constraints for their minimal and maximal control effort. Thus, the sets of feasible control inputs $
\uset$ and $\upedset$ respectively, are defined using the $L_1$-norm and the $L_2$-norm respectively:

\begin{align}
\uset &= \{\u | \u \in \mathbb{R}^2, ||\u||_1 \leq u_{max}\} \\
\upedset &= \{\uped[] | \uped[] \in \mathbb{R}^2, ||\uped[]||_2 \leq \tilde{u}_{max}\}
\label{eq:controls_bounds}
\end{align}

All actions are assumed to take place in a free-space, two-dimensional environment.
\newline
Within project \project, we want to find a robot trajectory $\x_{0:T}$ over some discrete-time horizon $N$ that makes trade-offs between minimizing the travel time from its current state to some goal state in $\xset_f = \{\boldsymbol{g} | \boldsymbol{g} \in \xset \}$ on the one side and the interference with the pedestrians in the scene, concerning its dynamic as well as safety boundaries, on the other side. For further simplification, perfect knowledge about the current and all past states of surrounding agents $\xped[k]_{0:t} \forall k \in [0, K]$ is assumed.
\newline\newline
For brevity of notation, in the following, the temporal index $t$ and the pedestrian index $k$ will be omitted when not necessary.


This section presents future approaches to optimally reduce the spread of the disease with minimal societal intervention.

\subsection{Edge Cutting}
All non pharmaceutical interventions (NPI) could be understood as some kind of edge removal in our graph-based approach:
\begin{itemize}
	\item Isolation of an infected individual removes all of its edges with very high probability.
	\item Quarantine of a contact person removes all of its edges with high probability.
	\item Social distancing removes some edges of of many individuals.
	\item Cancellation of large events remove many edges of many individuals.
\end{itemize}
These interventions can be modelled in our SIR model by modifying the diffusion rate of the agents.
Thus its effects can be evaluate qualitatively and quantitatively.

Based on our graph-based approach, one could also try to compute the minimal set of interventions, which still contains the disease.
A good proxy for this containment is to analyse the effect of these measures on $R_0$, which models how many people are infected by a single infected person.
It is crucial to constrain $R_0$ below one to avoid exponential growth of the number of infected individuals.

In our approach $R_0$ can be derived from the ratio of infected people of $H^{(t+1)}$ and of $H^{(t)}$:
\begin{equation}
	R_0 = \frac{\norm{H^{(t+1)}\mid_{m=1}}_{0}}{\norm{H^{(t)}\mid_{m=1}}_{0}} %#TODO betrag
\end{equation}

The square matrix $C$ with dimensions $N \times N$ models desirable edge cancellations.
Note, that this matrix does not have to know the edges of a future time step, it only expresses which edges must not exist.
It is multiplied element-wise onto the adjacency matrix $A$, thus $\bar{A} = A \odot C$ describes a adjacency matrix with applied cancellations.

To optimally limit the spread of the disease, we seek to minimize the number of cancellations $\norm{C}_0$, given that $R_0$ is below one:
\begin{equation}
	\max_{C} \norm{C}_0\text{, s.t. }R_0 < 1
\end{equation}
Alternatively

\begin{equation}
	\max_{C} \norm{C}_0\text{, s.t. } \norm{H^{(t+1)}\mid_{m=1}}_{0} <= KapaLimit
\end{equation}

% Future Work: This would be more powerful, if there would be some different kinds of edges (social, work, education, large events, etc.)\\
% Future Work: This only takes the current time step into account but it would be desirable to look even further into the future.

\subsection{Test Prioritization}
When tests are limited, they should be used to discover as much as possible about the health state of the overall population.
This in turn allows to reduce the $R_0$ value in further time steps as edge cutting becomes more efficient.

Lets assume there are $t_{\text{max}}$ tests per time step.
A test reveals the true health state of an individual (ignoring false negatives and false positives)
\begin{equation}
	h_{{v}_i}^{(t)} \xrightarrow{\text{test}} h_{{v}_i}^{(t+1)} \in \{\vec{e}_0, \vec{e}_1, \vec{e}_2 \}
\end{equation}

The test assignment $T$ with dimension $N$ is a binary variable describing which individuals should be tested.


\section{The Square Root of 2}

\begin{frame}
  \begin{columns}
    \begin{column}{0.3\textwidth}
      \centering
      \begin{tikzpicture}
        \draw[draw=gmitblue] (0,0) --node [midway, left, black] {$1$} (0,3) -- (3,3) -- (3,0) --node [midway, below, black] {$1$} (0,0);
        \draw[gmitred] (3,0) -- (0,3) node [midway, above right, black] {$\sqrt{2}$};
      \end{tikzpicture}
    \end{column}
    {\color{gmitgrey!30}\vrule{}} \hspace{0.1\textwidth}
    \begin{column}{0.5\textwidth}
      $\sqrt{2} \times \sqrt{2} = 2$ \\[16mm]
      $d^2 = l^2 + w^2$ \\[4mm]
      $d^2 = 1^2 + 1^2$ \\[4mm]
      $d = \sqrt{2}$ \\[8mm]
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \begin{column}{0.3\textwidth}
      \color{gmitblue} \fontsize{30}{10}
      \[\frac{a}{b}\]
    \end{column}
    {\color{gmitgrey!30}\vrule{}} \hspace{0.1\textwidth}
    \begin{column}{0.5\textwidth}
      $\sqrt{2} = \dfrac{a}{b}$ \\[8mm]
      $\Rightarrow 2 = \dfrac{a^2}{b^2}$ \\[8mm]
      $\Rightarrow 2b^2 = a^2$ \\[8mm]
      $\Rightarrow 2 \mid a^2$ \\[8mm]
      $\Rightarrow 2 \mid a$
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}
  \begin{columns}
    \begin{column}{0.3\textwidth}
      \color{gmitblue} \fontsize{30}{10}
      \[2 \mid a\]
    \end{column}
    {\color{gmitgrey!30}\vrule{}} \hspace{0.1\textwidth}
    \begin{column}{0.5\textwidth}
      $2 \mid a$ \\[8mm]
      $\Rightarrow 4 \mid a^2$ \\[8mm]
      $\Rightarrow 4 \mid 2b^2$ \\[8mm]
      $\Rightarrow 2 \mid b^2$ \\[8mm]
      $\Rightarrow 2 \mid b$
    \end{column}
  \end{columns}
\end{frame}

\begin{frame}[standout]

\begin{quote}
  A number is rational if and only if its decimal expansion becomes periodic.
\end{quote}

\end{frame}