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

\begin{document}

% =================================================================================================
% create checkpoint file

\bgroup
\CdbSetup{action=hide}
\begin{cadabra}
   import cdblib
   checkpoint_file = 'tests/semantic/output/connection.json'
   cdblib.create (checkpoint_file)
   checkpoint = []
\end{cadabra}
\egroup

% =================================================================================================
\section*{The connection}

Here we use the output from {\tt metric.tex} and {\tt metric-inv.tex} to compute the metric connection
$\Gamma^{d}_{ab}$. We use the standard metric compatible connection
\begin{align}
   \label{eqn:Gamma}
   \Gamma^{d}_{ab} = \frac{1}{2} g^{dc}\left( g_{cb,a} + g_{ac,b} - g_{ab,c} \right)
\end{align}

Since {\tt metric.tex} and {\tt metric-inv.tex} generate truncated expressions for $g_{ab}$ and
$g^{ab}$ a similar truncation must be applied to this computation of $\Gamma^{d}_{ab}$. The naive
choice is to truncate $\Gamma^{d}_{ab}$ \emph{after} it has been fully evaluated on the truncated
expersions for $g_{ab}$ and $g^{ab}$. This will work but it wastes time and memory (big time).

A better approach is to truncate $\Gamma^{d}_{ab}$ during its construction. That is, we take
careful note of how the terms in the finite series for $g_{ab}$ and $g^{ab}$ combine to produce
the terms of a particular order in the expansion of $\Gamma^{d}_{ab}$.

Suppose $g_{ab}$ and $g^{ab}$ are known to say fourth order. We can write each of these as follows
\begin{align}
   g_{ab} &= \ngab{0}_{ab} + \ngab{1}_{ab} + \ngab{2}_{ab} + \ngab{3}_{ab} + \ngab{4}_{ab}\\
   g^{ab} &= \ngab{0}^{ab} + \ngab{1}^{ab} + \ngab{2}^{ab} + \ngab{3}^{ab} + \ngab{4}^{ab}
\end{align}
where $\ngab{n}$ denotes a term of order $\BigO{\eps^n}$. A similar expansion applies for $\Gamma^{d}_{ab}$, that is
\begin{align}
   \Gamma^{d}_{ab} = \nGamma{0}^{d}_{ab}
                   + \nGamma{1}^{d}_{ab}
                   + \nGamma{2}^{d}_{ab}
                   + \nGamma{3}^{d}_{ab}
                   + \nGamma{4}^{d}_{ab}
\end{align}
After substituting these formal expansions into the equation \eqref{eqn:Gamma} and then matching
corresponing terms we obtain
\begin{align}
   \nGamma{n}^{d}_{ab}
   =
   \frac{1}{2} \sum_{i=0}^{i=n} \ngab{i}^{dc}\left( \ngab{n-i}_{cb,a} + \ngab{n-i}_{ac,b} - \ngab{n-i}_{ab,c} \right)
\end{align}

We use this equation to compute the successive terms in $\Gamma^{d}_{ab}$.

\clearpage

\begin{cadabra}
   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).

   D{#}::Derivative.
   \nabla{#}::Derivative.
   \partial{#}::PartialDerivative.

   g_{a b}::Metric.
   g^{a b}::InverseMetric.
   g_{a}^{b}::KroneckerDelta.
   g^{a}_{b}::KroneckerDelta.
   \delta^{a}_{b}::KroneckerDelta.
   \delta_{a}^{b}::KroneckerDelta.

   R_{a b c d}::RiemannTensor.
   R^{a}_{b c d}::RiemannTensor.

   x^{a}::Depends(D{#}).

   R_{a b c d}::Depends(\nabla{#}).
   R^{a}_{b c d}::Depends(\nabla{#}).

   import cdblib

   gab = cdblib.get ('g_ab','metric.json')      # cdb(gab.000,gab)
   iab = cdblib.get ('g^ab','metric-inv.json')  # cdb(iab.000,iab)

   defgab := g_{a b} -> @(gab).
   defiab := g^{a b} -> @(iab).

   dgab := D_{a}{g_{c b}} + D_{b}{g_{a c}} - D_{c}{g_{a b}}.  # cdb(dgab.001,dgab)

   substitute   (dgab,defgab)

   distribute   (dgab)              # cdb(dgab.002,dgab)
   unwrap       (dgab)              # cdb(dgab.003,dgab)
   product_rule (dgab)              # cdb(dgab.004,dgab)
   distribute   (dgab)              # cdb(dgab.005,dgab)
   substitute   (dgab,$D_{a}{x^{b}}->\delta^{b}_{a}$,repeat=True)  # cdb(dgab.006,dgab)
   eliminate_kronecker (dgab)       # cdb(dgab.007,dgab)
   sort_product   (dgab)            # cdb(dgab.008,dgab)
   rename_dummies (dgab)            # cdb(dgab.009,dgab)
   canonicalise   (dgab)            # cdb(dgab.010,dgab)

\end{cadabra}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{gab.000} \end{dmath*}
\end{dgroup*}

\begin{dgroup*}
   \begin{dmath*} \cdb*{dgab.001} \end{dmath*}
   \begin{dmath*} \cdb*{dgab.002} \end{dmath*}
   % \begin{dmath*} \cdb*{dgab.003} \end{dmath*} % too big for pdfLaTeX
   % \begin{dmath*} \cdb*{dgab.004} \end{dmath*}
   % \begin{dmath*} \cdb*{dgab.005} \end{dmath*}
   % \begin{dmath*} \cdb*{dgab.006} \end{dmath*}
   % \begin{dmath*} \cdb*{dgab.007} \end{dmath*}
   % \begin{dmath*} \cdb*{dgab.008} \end{dmath*}
   % \begin{dmath*} \cdb*{dgab.009} \end{dmath*}
   \begin{dmath*} \cdb*{dgab.010} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{cadabra}
   # Note:
   # Computing Gamma directly by (1/2) iab dgab and *then* truncating to lower order
   # is not optimal. We only want the leading oder terms (to 4th order in x). But the direct
   # calculation would compute *all* terms before the truncation. This does work but it
   # is slower than the following code.
   #
   # The better approach (as adopted in this code) is to extract all of the terms of iab
   # and dgab then construct the leading order terms of Gamma (to fifth order) term by term.

   def get_Rterm (obj,n):

   # I would like to assign different weights to \nabla_{a}, \nabla_{a b}, \nabla_{a b c} etc. but no matter
   # what I do it appears that Cadabra assigns the same weight to all of these regardless of the number of subscripts.
   # It seems that the weight is assigned to the symbol \nabla alone. So I'm forced to use the following substitution trick.

       Q_{a b c d}::Weight(label=numR,value=2).
       Q_{a b c d e}::Weight(label=numR,value=3).
       Q_{a b c d e f}::Weight(label=numR,value=4).
       Q_{a b c d e f g}::Weight(label=numR,value=5).

       tmp := @(obj).

       distribute (tmp)

       substitute (tmp, $\nabla_{e f g}{R_{a b c d}} -> Q_{a b c d e f g}$)
       substitute (tmp, $\nabla_{e f}{R_{a b c d}} -> Q_{a b c d e f}$)
       substitute (tmp, $\nabla_{e}{R_{a b c d}} -> Q_{a b c d e}$)
       substitute (tmp, $R_{a b c d} -> Q_{a b c d}$)

       foo := @(tmp).
       bah = Ex("numR = " + str(n))
       keep_weight (foo, bah)

       substitute (foo, $Q_{a b c d e f g} -> \nabla_{e f g}{R_{a b c d}}$)
       substitute (foo, $Q_{a b c d e f} -> \nabla_{e f}{R_{a b c d}}$)
       substitute (foo, $Q_{a b c d e} -> \nabla_{e}{R_{a b c d}}$)
       substitute (foo, $Q_{a b c d} -> R_{a b c d}$)

       return foo

   # terms of the curvature expansion of dg_{ab}

   dgab00 = get_Rterm (dgab,0)   # cdb(dgab00.105,dgab00)  # zero
   dgab01 = get_Rterm (dgab,1)   # cdb(dgab01.105,dgab01)  # zero
   dgab02 = get_Rterm (dgab,2)   # cdb(dgab02.105,dgab02)
   dgab03 = get_Rterm (dgab,3)   # cdb(dgab03.105,dgab03)
   dgab04 = get_Rterm (dgab,4)   # cdb(dgab04.105,dgab04)
   dgab05 = get_Rterm (dgab,5)   # cdb(dgab05.105,dgab05)

   # Convert free indices on iab from ^{a b} to ^{d c}
   # This ensures we can later build products like @(iab) @(dgab) knowing that the indices are correctly ordered.
   # Without this step we would be using free indices ^{a b} and _{a b c}. Thus the product @(iab) @(dgab) would
   # have just one free index _{c}. This is clearly wrong.

   tmp := @(iab) \delta_{a}^{d} \delta_{b}^{c}.

   distribute     (tmp)
   eliminate_kronecker (tmp)
   sort_product   (tmp)
   rename_dummies (tmp)
   canonicalise   (tmp)

   idc := @(tmp).

   # terms of the curvature expansion of g^{ab}

   idc00 = get_Rterm (idc,0)   # cdb(idc00.105,idc00)
   idc01 = get_Rterm (idc,1)   # cdb(idc01.105,idc01)  # zero
   idc02 = get_Rterm (idc,2)   # cdb(idc02.105,idc02)
   idc03 = get_Rterm (idc,3)   # cdb(idc03.105,idc03)
   idc04 = get_Rterm (idc,4)   # cdb(idc04.105,idc04)
   idc05 = get_Rterm (idc,5)   # cdb(idc05.105,idc05)

\end{cadabra}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{dgab00.105} \end{dmath*}
   \begin{dmath*} \cdb*{dgab01.105} \end{dmath*}
   \begin{dmath*} \cdb*{dgab02.105} \end{dmath*}
   \begin{dmath*} \cdb*{dgab03.105} \end{dmath*}
   \begin{dmath*} \cdb*{dgab04.105} \end{dmath*}
   \begin{dmath*} \cdb*{dgab05.105} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{idc00.105} \end{dmath*}
   \begin{dmath*} \cdb*{idc01.105} \end{dmath*}
   \begin{dmath*} \cdb*{idc02.105} \end{dmath*}
   \begin{dmath*} \cdb*{idc03.105} \end{dmath*}
   \begin{dmath*} \cdb*{idc04.105} \end{dmath*}
   \begin{dmath*} \cdb*{idc05.105} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{cadabra}
   # idc  = g^{d c}
   # dgab = D_{a}{g_{c b}} + D_{b}{g_{a c}} - D_{c}{g_{a b}}

   # terms of the curvature expansion of \Gamma^{d}_{a b}

   # term0 := (1/2)  @(idc00) @(dgab00).
   # term1 := (1/2) (@(idc01) @(dgab00) + @(idc00) @(dgab01)).
   # term2 := (1/2) (@(idc02) @(dgab00) + @(idc01) @(dgab01) + @(idc00) @(dgab02)).
   # term3 := (1/2) (@(idc03) @(dgab00) + @(idc02) @(dgab01) + @(idc01) @(dgab02) + @(idc00) @(dgab03)).
   # term4 := (1/2) (@(idc04) @(dgab00) + @(idc03) @(dgab01) + @(idc02) @(dgab02) + @(idc01) @(dgab03) + @(idc00) @(dgab04)).
   # term5 := (1/2) (@(idc05) @(dgab00) + @(idc04) @(dgab01) + @(idc03) @(dgab02) + @(idc02) @(dgab03) + @(idc01) @(dgab04) + @(idc00) @(dgab05)).

   # simplidied version of the above after noting dgab00 = dgab01 = 0

   term0 := 0.
   term1 := 0.
   term2 := (1/2) (@(idc00) @(dgab02)).
   term3 := (1/2) (@(idc01) @(dgab02) + @(idc00) @(dgab03)).
   term4 := (1/2) (@(idc02) @(dgab02) + @(idc01) @(dgab03) + @(idc00) @(dgab04)).
   term5 := (1/2) (@(idc03) @(dgab02) + @(idc02) @(dgab03) + @(idc01) @(dgab04) + @(idc00) @(dgab05)).

   def tidy_terms (obj):
       substitute     (obj,$x^{a}->AA^{a}$,repeat=True)  # will force AA to the left of all terms
       distribute     (obj)
       sort_product   (obj)
       rename_dummies (obj)
       canonicalise   (obj)
       substitute     (obj,$AA^{a}->x^{a}$,repeat=True)  # replace AA with x
       factor_out     (obj,$x^{a?}$)

       return obj

   term0 = tidy_terms (term0)   # cdb(term0.201,term0)  # zero
   term1 = tidy_terms (term1)   # cdb(term1.201,term1)  # zero
   term2 = tidy_terms (term2)   # cdb(term2.201,term2)
   term3 = tidy_terms (term3)   # cdb(term3.201,term3)
   term4 = tidy_terms (term4)   # cdb(term4.201,term4)
   term5 = tidy_terms (term5)   # cdb(term5.201,term5)

   Gamma := @(term0) + @(term1) + @(term2) + @(term3) + @(term4) + @(term5). # cdb(Gamma.200,Gamma)

\end{cadabra}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{term0.201} \end{dmath*}
   \begin{dmath*} \cdb*{term1.201} \end{dmath*}
   \begin{dmath*} \cdb*{term2.201} \end{dmath*}
   \begin{dmath*} \cdb*{term3.201} \end{dmath*}
   \begin{dmath*} \cdb*{term4.201} \end{dmath*}
   \begin{dmath*} \cdb*{term5.201} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{dgroup*}
   \begin{dmath*} \cdb*{Gamma.200} \end{dmath*}
\end{dgroup*}

\clearpage

\begin{cadabra}
   cdblib.create ('connection.json')

   cdblib.put ('Gamma',Gamma,'connection.json')

   cdblib.put ('GammaRterm0',term0,'connection.json')
   cdblib.put ('GammaRterm1',term1,'connection.json')
   cdblib.put ('GammaRterm2',term2,'connection.json')
   cdblib.put ('GammaRterm3',term3,'connection.json')
   cdblib.put ('GammaRterm4',term4,'connection.json')
   cdblib.put ('GammaRterm5',term5,'connection.json')

   checkpoint.append (term0)
   checkpoint.append (term1)
   checkpoint.append (term2)
   checkpoint.append (term3)
   checkpoint.append (term4)
   checkpoint.append (term5)

\end{cadabra}

% =================================================================================================
% the remaining code is just for pretty printing

\clearpage

\begin{cadabra}
   # note: keeping numbering as is (out of order) to ensure R appears before \nabla R etc.
   def product_sort (obj):
       substitute (obj,$ A^{a}                            -> A001^{a}               $)
       substitute (obj,$ x^{a}                            -> A002^{a}               $)
       substitute (obj,$ g^{a b}                          -> A003^{a b}             $)
       substitute (obj,$ \nabla_{e f g h}{R_{a b c d}}    -> A008_{a b c d e f g h} $)
       substitute (obj,$ \nabla_{e f g}{R_{a b c d}}      -> A007_{a b c d e f g}   $)
       substitute (obj,$ \nabla_{e f}{R_{a b c d}}        -> A006_{a b c d e f}     $)
       substitute (obj,$ \nabla_{e}{R_{a b c d}}          -> A005_{a b c d e}       $)
       substitute (obj,$ R_{a b c d}                      -> A004_{a b c d}         $)
       sort_product   (obj)
       rename_dummies (obj)
       substitute (obj,$ A001^{a}                  -> A^{a}                         $)
       substitute (obj,$ A002^{a}                  -> x^{a}                         $)
       substitute (obj,$ A003^{a b}                -> g^{a b}                       $)
       substitute (obj,$ A008_{a b c d e f g h}    -> \nabla_{e f g h}{R_{a b c d}} $)
       substitute (obj,$ A007_{a b c d e f g}      -> \nabla_{e f g}{R_{a b c d}}   $)
       substitute (obj,$ A006_{a b c d e f}        -> \nabla_{e f}{R_{a b c d}}     $)
       substitute (obj,$ A005_{a b c d e}          -> \nabla_{e}{R_{a b c d}}       $)
       substitute (obj,$ A004_{a b c d}            -> R_{a b c d}                   $)

       return obj

   def reformat (obj,scale):
      foo  = Ex(str(scale))
      bah := @(foo) @(obj).
      distribute     (bah)
      bah = product_sort (bah)
      rename_dummies (bah)
      canonicalise   (bah)
      factor_out     (bah,$A^{a?},x^{b?}$)
      ans := @(bah) / @(foo).
      return ans

   def rescale (obj,scale):
      foo  = Ex(str(scale))
      bah := @(foo) @(obj).
      distribute  (bah)
      factor_out  (bah,$A^{a?},x^{b?}$)
      return bah

   Rterm2 := @(term2) A^{a} A^{b}.
   Rterm3 := @(term3) A^{a} A^{b}.
   Rterm4 := @(term4) A^{a} A^{b}.
   Rterm5 := @(term5) A^{a} A^{b}.

   Rterm2 = reformat (Rterm2,  3)    # cdb(Rterm2.301,Rterm2)
   Rterm3 = reformat (Rterm3, 12)    # cdb(Rterm3.301,Rterm3)
   Rterm4 = reformat (Rterm4,360)    # cdb(Rterm4.301,Rterm4)
   Rterm5 = reformat (Rterm5,180)    # cdb(Rterm5.301,Rterm5)

   Gamma  := @(Rterm2) + @(Rterm3) + @(Rterm4) + @(Rterm5).  # cdb (Gamma.301,Gamma)
   Scaled := 360 @(Gamma).                                   # cdb (Scaled.301,Scaled)

   scaled2 = rescale (Rterm2,   3)   # cdb (scaled2.301,scaled2)
   scaled3 = rescale (Rterm3,  12)   # cdb (scaled3.301,scaled3)
   scaled4 = rescale (Rterm4, 360)   # cdb (scaled4.301,scaled4)
   scaled5 = rescale (Rterm5, 180)   # cdb (scaled5.301,scaled5)
\end{cadabra}

\clearpage

% =================================================================================================
\section*{The connection in Riemann normal coordinates}

\begin{dgroup*}
   \begin{dmath*} A^a A^b \Gamma^{d}_{a b} = \cdb{Gamma.301} \end{dmath*}
\end{dgroup*}

\begin{dgroup*}
   \begin{dmath*} 360 A^a A^b \Gamma^{d}_{a b} = \cdb{Scaled.301} \end{dmath*}
\end{dgroup*}

\clearpage

% =================================================================================================
\section*{Curvature expansion of the connection}

\begin{align*}
     A^a A^b \Gamma^{d}_{a b} =
     A^a A^b \nGamma{2}^{d}{}_{a b}
   + A^a A^b \nGamma{3}^{d}{}_{a b}
   + A^a A^b \nGamma{4}^{d}{}_{a b}
   + A^a A^b \nGamma{5}^{d}{}_{a b}+\BigO{\eps^6}
\end{align*}
\begin{dgroup*}
   \begin{dmath*}   3 A^a A^b \nGamma{2}^{d}_{a b} = \cdb{scaled2.301} \end{dmath*}
   \begin{dmath*}  12 A^a A^b \nGamma{3}^{d}_{a b} = \cdb{scaled3.301} \end{dmath*}
   \begin{dmath*} 360 A^a A^b \nGamma{4}^{d}_{a b} = \cdb{scaled4.301} \end{dmath*}
   \begin{dmath*} 180 A^a A^b \nGamma{5}^{d}_{a b} = \cdb{scaled5.301} \end{dmath*}
\end{dgroup*}

% =================================================================================================
% export checkpoints in json format

\bgroup
\CdbSetup{action=hide}
\begin{cadabra}
   for i in range( len(checkpoint) ):
      cdblib.put ('check{:03d}'.format(i),checkpoint[i],checkpoint_file)
\end{cadabra}
\egroup

\end{document}


\setlength{\parindent}{0pt}

\clearpage
\section{Liveness Analysis}
(Prepared by Jai Arora)
\vspace{0.3cm}

Previously, we saw a type of Global Optimisation called Global Constant Propagation, which required the knowledge of the whole program.
After all the constants have been propagated globally, there can be a scope for eliminating dead code.

\begin{figure}[H]
    \centering
    \includegraphics[height=6cm]{images/Module81_1.png}
    \caption{Motivation for Liveness Analysis}
\end{figure}

Consider a statement $x := ...$\\
Questions to ask: Is $x$ live or dead just after the statement? What does liveness mean?\\
Ans: A variable $x$ is live after a statement if it can be used in the downflow logic\\

Consider the following example:
\begin{figure}[H]
    \centering
    \includegraphics[height=6cm]{images/Module81_2.png}
    %\caption{Converting to SSA Example}
\end{figure}

\vspace{0.3cm}
The above intuition can be formalized as follows. A variable $x$ is live at a statement $s$ if:
\begin{itemize}
    \item There exists a statement $s'$ that uses $x$

    Eg:- $s':$ $y := f(...,x,...)$
    \item There is a path from $s$ to $s'$ (directed)
    \item The path has \underline{no intervening assignments} to $x$
\end{itemize}

Once we have figured out if a variable $x$ live or dead at all statements, then we can easily identify dead code.\\
A statement $x := ...$ is dead code if $x$ is dead immediately after the assignment.
In this case, as the variable is not being used in the downflow logic, which means that we can simply remove the assignment.

\subsection{Liveness Analysis as a DFA}
In this analysis, the property that we want to know at a particular program point is the liveness of a particular variable. In the example above, we found the liveness value at one point using the other values.
This gives us an intuition for a $\textbf{Transfer Function}$, and hence we use a DFA for this problem as follows:
\begin{itemize}
    \item Express liveness at a program point based on the liveness of the successor program point (Backward Dataflow)
    \item The Liveness property for a variable $x$ would take a boolean value

    \hspace*{0.1 in}${\tt true} \rightarrow$ The variable may be live (This is a conservative value)\\
    \hspace*{0.1 in}${\tt false} \rightarrow$ The variable is definitely dead (not live)
\end{itemize}

\subsection{Ordering of Liveness Values}
As seen previously, it really helps to construct a partial ordering because it makes the rules concise. So we do would the same here. Define the ordering as:

\begin{center}
    ${\tt true} \leqslant {\tt false}$
\end{center}
\begin{figure}[H]
    \centering
    \includegraphics[height=2cm]{images/Module81_3.png}
    \caption{The Semilattice of Liveness Values}
\end{figure}

Once this ordering has been established, it can be easily seen that the greatest lower bound of any $2$ values $x, y$ would be the boolean OR of those values.
$$glb(x,y) = x \vee y$$
$$glb(x_1,x_2,...,x_n) = x_1 \vee x_2 \vee ... \vee x_n$$


% TITLE: Lipsum text with two figures and math
% AUTHOR: Adrian Schrader
% Created on: 31/7/15

\section{Section One}
\lipsum[1-2]

\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{img/plot}
  \caption{Plot of of f(t) in maple}
  \label{img:function}
\end{figure}

\lipsum[3-4]

\subsection{Subsection One.One}
\lipsum[5]

\begin{figure*}[ht]
  \centering
  \includegraphics[width=\linewidth]{img/example2}
  \caption{Another Random cat picture from Google \protect\url{https://static.pexels.com/photos/4067/animal-pet-cute-cat.jpg}}
  \label{img:cat2}
\end{figure*}

\subsection{Subsection One.Two}
\lipsum[6]
\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{img/spectrum}
  \caption{Plot of the spectrum of f(t) in maple}
  \label{img:spectrum}
\end{figure}

\begin{align}
    f(t) &= s_0 \cdot e^{-\frac{t}{\tau}} \cdot cos(\omega_s t) \cdot \Theta(t) \nonumber \\
    &= s_0 \cdot e^{-\frac{t}{\tau}} \cdot \frac{1}{2} \Big( e^{i \omega_s t} + e^{-i \omega_s t} \Big) \cdot \Theta(t)\\
    \tilde{f}(\omega) &= \mathcal{F}(f)(\omega) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} f(t) \cdot e^{-i \omega t} dt \nonumber\\
    &= \frac{s_0}{\sqrt{2\pi}} \frac{\frac{1}{\tau} + i \omega}{(\frac{1}{\tau} + i \omega)^2 + \omega_s^2}
\end{align}

\section{Section Two}
\lipsum[9-12]

\subsection{Subsection Two.One}
\lipsum[13-14]


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Master Thesis in Mathematics
% "Immersions and Stiefel-Whitney classes of Manifolds"
% -- Chapter 4: Outlook --
%
% Author: Gesina Schwalbe
% Supervisor: Georgios Raptis
% University of Regensburg 2018
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter
{An Outline of the Proof of the Immersion Conjecture}
\label{chap:outlook}
% Requirements:
% (Optional) Give an outline of the work of Brown-Peterson and Cohen for
% the proof of the Immersion Conjecture.

This chapter gives an overview of the main steps towards a proof
of the immersion conjecture.
In the course of this it becomes clear how the key theorems discussed
in this thesis---Theorem~\ref{thm:massey} by Massey and
Theorem~\ref{thm:brown} by R.~L.~Brown---contributed to the
development in this area.
The proof discussed will be the one based on the work of
E.~H.~Brown~Jr., F.~P.~Peterson \cite{brownpeterson}, which was
finalized by R.~L.~Cohen in his dissertation \cite{cohen}. The
outlines here are geared to Cohen's highly recommendable lecture notes
\cite{immersionconj} on this topic.

Proofs of the following statements are either sketched or omitted. For
details the reader is advised to consult the latter reference if no
other is given. Even though the proof of the immersion conjecture
itself requires profound knowledge of the theory of spectra, basic
knowledge should suffice to follow the outlines below. See
\cite[p.~77ff]{immersionconj} for a very brief introduction, or
\cite{switzer} for a more complete picture.

\begin{Not*}
  Normal Bundles will be considered to arise from immersions of
  manifolds into Euclidean space, and
  vector bundles will be identified with their classifying maps.
  For a vector bundle $\xi\colon X\to\BO$ denote its Thom spectrum by
  $\Tspec{\xi}$,
  and for a map of spaces $f\colon Y\to X$ denote the induced map of
  Thom spaces resp. spectra by
  $\thommap{f}\colon\Tspec{(\pb f\xi)}\to\Tspec{\xi}$.
  Denote by $\EMspec$ the Eilenberg-MacLane spectrum for $\Zmod2$.
  For $k\in\Nat$ let
  \begin{compactitemize}
  \item $\univbdl{k}$ be the universal bundle of $\Orth(k)$,
  \item $\MO(k)\cong\Thomspace{\univbdl{}}$ the corresponding Thom space,
  \item $\MOspec(k)$ the corresponding Thom spectrum,
  \item $\MOspec\coloneqq\{\MO(k)\mid k\in\Nat\}$ be the universal Thom
    spectrum, and
  \item $\Spherespec{k}$ be the $k$th suspension of the sphere spectrum.
  \end{compactitemize}
  For a sequence $I=(i_1,\dotsc,i_l)$ of positive integers, denote by
  $\Deg{I}\coloneqq\deg(\sigma^I)$ the degree of the monomial
  $\sigma^{i_1}\dotsm\sigma^{i_l}$ in variables $\sigma_i$ with
  $\deg(\sigma_i)=i$.
  Lastly, fix some $n\in\Nat$ throughout this chapter.
\end{Not*}

Recall from \autoref{chap:reformulation} that the statement in
question is:
\begin{Thm*}
  Every closed smooth $n$\nbd{}manifold immerses into
  $\R^{2n-\alpha(n)}$.
\end{Thm*}
Furthermore, it was shown that this is equivalent to:
\begin{Thm*}
  For any closed smooth $n$\nbd{}manifold,
  the classifying map $\N M\colon M\to\BO$ factors over the
  inclusion $\BO(n-\alpha(n))\to\BO$.
\end{Thm*}
This theorem essentially says that the universal
$\Orth(n-\alpha(n))$\nbd{}vector bundle is a better choice for
classifying normal bundles of $n$\nbd{}manifolds than
$\BO$.
% This is not astonishing, as $\BO$ is a
% universal space of \emph{all} vector bundles up to stable
% equivalence over \emph{all} (sufficiently nice) spaces.
% Due to Whitney's immersion theorem, a first improvement of $\BO$ is
% the universal bundle over $\BO(n-1)$.
The idea for the proof of the immersion conjecture is to
find a vector bundle $\BOmodI n\to\BO$ which
\begin{enumerate}[1.]
\item
  acts as universal bundle for normal bundles of $n$\nbd{}manifolds, in
  the sense that all normal bundle maps factor over it, and which
\item
  is even better than $\BO(n-\alpha(n))$ in classifying normal
  bundles, \idest it lifts to $\BO(n-\alpha(n))$.
\end{enumerate}
In other words, we are looking for a space later called $\BOmodI n$
and a map
\begin{gather*}
  \rho_n\colon \BOmodI n\longto\BO(n-\alpha(n))\longto\BO
\end{gather*}
over which all classifying maps of stable normal bundles factor.
More precisely, for a fixed $n\in\Nat$ the proof
encompasses the following main steps:
\begin{steps}
\item
  Get an idea of the statement on cohomology, and determine up to a
  Thom isomorphism the ideal $\I n\subset\H^*(\BO)$ of characteristic
  classes that vanish on all normal bundles of $n$\nbd{}manifolds.
  This turns out to be a generalization of Massey's theorem on
  characteristic classes of normal bundles (Theorem~\ref{thm:massey}).
\item
  Find a spectrum $\MOmodI n$ with a map
  $\bm{\rho}_n\colon \MOmodI n\to\MOspec$ which acts as a universal
  spectrum for Thom spectra of normal bundles of $n$\nbd{}manifolds,
  \idest all maps $\Tspec{\N{M^n}}\to \MOspec$ of a Thom spectrum of a
  normal bundle factor over the above map.
  Furthermore, $\bm{\rho}_n$ should factor
  over $\MOspec(n-\alpha(n))\to\MOspec$.
\item
  Find a sufficient criterion when a map of a spectrum into the Thom
  spectrum of a bundle \emph{de-Thom-ifies}, \idest sort of
  comes from a map of Thom spectra which is induced by a map
  of vector bundles.
\item
  Construct a de-Thom-ification bundle $\BOmodI n\to\BO$ of $\MOmodI
  n\to\MOspec$ by de-Thom-ifying a suitable resolution,
  and show that this acts as a universal space for normal
  bundles of manifolds.
\item
  Show that there is a space $X^n$ and a map
  $X^n\to\BOmodI n\to\BO$, which factors over $\BO(n-\alpha(n))$, and
  admits some nice splitting and  commutativity properties on the Thom
  spectra corresponding to the classifying maps.
\item
  Show that the latter implies that the map $\BOmodI n\to\BO$ factors
  over the universal bundle $\BO(n-\alpha(n))\to\BO$.
\end{steps}
In the end, one has a space $\BOmodI n$ which admits for
any $n$\nbd{}manifold a commutative diagram
\begin{center}
  \begin{tikzcd}[column sep=small]
    M \ar[r]
    \ar[drr, "\N M", bend right=15]
    &\BOmodI n
    \ar[r]
    &\BO(n-\alpha(n))
    \ar[d, "\incl"]\\
    &&\BO
  \end{tikzcd}
\end{center}
as was to be shown for the immersion conjecture.

The last two steps turn out to be quite tricky and are the topic of
Cohen's dissertation \cite{cohen}. This is also the point where
R.~L.~Brown's theorem from \autoref{chap:brown} comes into play.
It is needed for some choices in the construction of $X^n$.
The other results are due to E.~H.~Brown~Jr. and F.~P.~Peterson.

In the following a couple of aspects of the above steps are filled
with more details.

\section*{A Generalization of Massey's Theorem}
In search of properties of such a universal bundle
$\rho_n\colon X_n\to\BO$ for stable normal bundles of $n$\nbd{}manifolds,
one idea is that the \enquote{best} such one should fulfill
\begin{gather*}
  \ker(\pb\rho_n)
  = \bigcap_{\text{$M$ mfd.}}
  \ker\left(\pb{\N M}\colon\H^*(\BO)\to \H^*(M)\right)
  \eqqcolon \I n
  \;,
\end{gather*}
\idest all characteristic classes from $\H^*(\BO)$ that vanish for
normal bundles, already vanish for the bundle $\rho_n$.
Note that by Massey's theorem the ideal
$\left(\ws{i}\middlemid i>n-\alpha(n)\right)$ lies within $\I n$.

\begin{Rem*}
Recall that the Thom isomorphism extends to an isomorphism
\begin{gather*}
  \thomiso\colon \H^*(\BO) \to \H^*(\MOspec)
\end{gather*}
(see \forexample \cite{milnor}).
Furthermore, note that $\H^*(\MOspec)$ is known to be a free module
over the Steenrod algebra $\A$ of the form
\begin{gather*}
  \H^*(\MOspec)
  = (\sigma_i\mid i\neq 2^s-1)_{\A}
  \cong \A\otimes \Zmod2[\sigma_i\mid i\neq 2^s-1]
  \cong \bigoplus_{\mathclap{\Deg{I}\neq 2^s-1}}
  \A_{(*+\Deg{I})}\sigma^I
\end{gather*}
where the $\sigma_i$ are algebraically independent elements,
$\deg(\sigma_i)=i$.
Furthermore, the last isomorphism is one of $\A$\nbd{}modules, and the sum
is over arbitrary sequences $I$ of positive integers
(see \forexample \cite[p.~82]{immersionconj} or
\cite[Chap.~20]{switzer}).
\end{Rem*}

Brown and Peterson investigated the image of $\I n$ under the Thom
isomorphism, which is characterized by the property that for any
$n$\nbd{}manifold $M$, $\thomiso(\I n)=\ker(\pb{\thommap{\N M}})$.
Their result was the following.
\begin{Thm*}[{\cite[Theorem~2.3]{immersionconj}}]
  One has the following equality of left-ideals of $\A$:
  \begin{gather*}
    \J r
    \coloneqq \bigcap_{\text{$M^n$ mfd.}}
    \left\{ a\in\A \middlemid a(\u{\N M}) = 0 \right\}
    = \A \cdot \left\{\antipode(\Sq i) \middlemid 2i>r\right\}
    \subset \A
    \;.
  \end{gather*}
  Furthermore, with notation as above,
  \begin{align*}
    \H^*(\MOspec)/\thomiso(\I n)
    &\cong \bigoplus_{\mathrlap{n\geq\Deg{I}\neq 2^s-1}}
      \left( \A / \J{n-\Deg{I}} \right)_{*+\Deg{I}}
      \;,\qquad\text{thus}\\
    \thomiso(\I n)
    &= \H^{*>n}(\MOspec)
    + \A\cdot \left\{
      \antipode(\Sq i)(\sigma^I) \middlemid 2i>n-\deg(\sigma^I)
    \right\}
      \;.
  \end{align*}
\end{Thm*}

Note that Massey's theorem~\ref{thm:massey} can be obtained
from the above statement as follows:
\begin{Rem*}
  Note that the projection of
  \begin{gather*}
    \left\{
      \antipode(\Sq I) \middlemid
      I=(i_1,\dotsc,i_l) \text{ admissible, } 2i_1\leq r
    \right\}
  \end{gather*}
  is a $\Zmod2$\nbd{}vector space basis of $\A/\J r$.
  Taking a closer look at these elements, one notes that the
  largest dimension occurring is $r-\alpha(r)$.
  Therefore, for $i>r-\alpha(r)$, $\Sq i$ is sent to zero under the
  projection of $\A/\J r$, respectively lies in $\J r$.
  Thus, $\Sq i$ lies in $\thomiso(\I n)$ for
  $i>n-\alpha(n)=\max_k\{(n-k)-\alpha(n-k)\}$.
  This yields the statement of Massey's theorem, since for an
  $n$\nbd{}manifold $M$ one gets
  \begin{gather*}
    \thomiso(\w{i}{\N M})
    \cequalsby{\ref{thm:altdefswclasses}} \Sq i(\u{\N M})
    \in \Sq i(\Im\pb{(\T{\N M})})
    = \pb{(\T{\N M})} (\Sq i\cdot \H^*(\MOspec))
    = 0
    \;.
  \end{gather*}
  See also \cite[p.~93]{immersionconj}.
\end{Rem*}

\section*{The Construction of $\MOmodI n$}
The summands in $\H^*(\MOspec)/\thomiso(\I n)$ are isomorphic to the
cohomology rings of the Brown-Gitler spectra.
Thus, the form of $\H^*(\MOspec)/\thomiso(\I n)$ gives a good hint on how
to proceed in the search of some universal spectrum for Thom spaces of
normal bundles.

\begin{Rem*}
  Recall that Thom calculated
  \begin{gather*}
    \MOspec
    \cong \bigvee_{\mathclap{\Deg{I}\neq 2^s-1}}
    \Spherespec{\Deg{I}} \smashprod \EMspec
  \end{gather*}
  (see \cite[p.~81f]{immersionconj} for a good summary of the arguments).
\end{Rem*}

\begin{Def*}
  In the following denote by $\BrownGitler k$ the $k$th
  Brown-Gitler spectrum, thus especially
  $\H^*(\BrownGitler k)\cong\A/\J k$
  (see \cite{browngitler} or \cite[p.~101]{immersionconj} for
  definition and a construction).
  For $k\in\Nat$ let $y_k$ be the generator of
  $\H^*(\BrownGitler k)\cong \A/\J k$ as $\A$\nbd{}module,
  \idest $\H^*(\BrownGitler k)=\A\cdot y_k$.
  Define
  \begin{gather*}
    \SwapAboveDisplaySkip
    \bm{\rho}_n\colon
    \MOmodI n
    \coloneqq \bigvee_{\mathrlap{n\geq\Deg{I}\neq 2^s-1}}
    \Spherespec{\Deg{I}} \smashprod \BrownGitler{n-\Deg{I}}
    \longto
    \bigvee_{\mathrlap{\Deg{I}\neq 2^s-1}}
    \Spherespec{\Deg{I}} \smashprod \EMspec
    \cong \MOspec
  \end{gather*}
  where the map is the wedge product given by the cohomology elements
  \begin{gather*}
    y_k\colon\BrownGitler k \to \EMspec
    \;.
  \end{gather*}
\end{Def*}

\begin{Thm*}
  $\bm{\rho}_n\colon\MOmodI n\to\MOspec$ fulfills
  \begin{enumerate}
  \item\label{item:momodinprop:1}
    $\pb{\bm{\rho}}_n=\proj\colon
    \H^*(\MOspec)
    \to \H^*(\MOspec)/\thomiso(\I n)\cong\H^*(\MOmodI n)$
  \item\label{item:momodinprop:2}
    $\MOmodI n$ together with $\bm{\rho}_n$ is a universal Thom spectrum
    for Thom spectra of normal bundles of $n$\nbd{}manifolds.
    \Idest for every $n$\nbd{}manifold there exists a lift $\bm{f}_M$ of
    $\thommap{\N M}$
    such that the following diagram commutes up to homotopy
    \begin{center}
      \begin{tikzcd}
        \Tspec{\N M} \ar[r, "\bm{f}_M"]
        \ar[dr, bend right=20, "\thommap{\N M}"{below}]
        &\MOmodI n
        \ar[d, "\bm{\rho}_n"]\\
        &\MOspec
      \end{tikzcd}
    \end{center}
  \item\label{item:momodinprop:3}
    $\bm{\rho}_n$ factors up to homotopy over
    $\MOspec(n-\alpha(n))\to\MOspec$.
  \end{enumerate}
  \begin{proof}[Outline of the proof]
    For a proof see \cite[Lemma~2.28, Theorem~2.29]{immersionconj}.
    Statement \ref{item:momodinprop:1} requires mainly the
    considerations from above, thus follows rather directly from the
    definition.
    For \ref{item:momodinprop:2}, one piece-wise constructs a lift on
    the wedge-product factors, \idest for any
    sequence $I$ with $n\geq d=\Deg{I}\neq2^s-1$, find a map
    $\proj\circ\bm{f}_M$ making the following diagram commute:
    \begin{center}
      \begin{tikzcd}
        &&\susp^{d}\BrownGitler{n-d}
        \ar[d, "\susp^{d}y_k"]
        \\
        \ar[urr, bend left=20, dashed, "\proj\circ f_M"]
        \Tspec{\N M}
        \ar[r, "\thommap{\N M}"{below}]
        &\MOspec
        \ar[r, "\proj"]
        &\susp^{d}\EMspec
      \end{tikzcd}
    \end{center}
    Lastly, \ref{item:momodinprop:3} uses that $\BrownGitler k$ has
    modulo 2 the homotopy type of a CW complex of dimension $k-\alpha(k)$,
    which makes it possible to apply an obstruction argument to find
    the required lift.
  \end{proof}
\end{Thm*}

This gives the desired intermediate result.

\section*{The Construction of $\BOmodI n$}
Now that a nice universal spectrum for Thom spaces of normal bundles
of $n$\nbd{}manifolds is found, one has to somehow \emph{de-Thom-ify} this
result to a universal space of normal bundles with the desired
properties.
Let us first specify the meaning of de-Thom-ification.
\begin{Def*}
  For a classifying map $\xi\colon X\to\BO$, a map of spectra
  $\bm{\tau}\colon\spectrum{Z}\to\Tspec{\xi}$ is said to
  \emph{de-Thom-ify} through dimension $k$ if there is
  \begin{compactitemize}
  \item a map of spaces $g\colon Y\to X$, and
  \item a $k$\nbd{}connected map of spectra
    $\bm{\kappa}\colon\Tspec{(\pb g\xi)}\to\spectrum{Z}$,
  \end{compactitemize}
  such that the following diagram homotopy commutes
  \begin{center}
    \begin{tikzcd}
      \spectrum{Z} \ar[r, "\bm{\tau}"]
      \ar[d, "\bm{\kappa}"]
      &\Tspec{\xi}\\
      \ar[ur, bend right=30, "~\thommap{g}"{right}]
      \Tspec{(\pb g\xi)}
    \end{tikzcd}
    .
  \end{center}
\end{Def*}

On the way a sufficient criterion for de-Thom-ification it
is necessary to observe what additional structure a
map of Thom spectra has if it is induced by a map on vector bundles.
Indeed, such maps are linear with respect to an additional module structure
(see \cite[p.~107ff]{immersionconj}).
\begin{Def*}
  On the tensor product $\A\otimes\H^*(\BO)$ define the multiplication
    \begin{gather*}
      (a\otimes x) \cdot (b\otimes y)
      \coloneqq \sum_{i\in A}
      \left(a\circ b_i'\right) \otimes \left(\antipode(b_i'')(x)\cdot y\right)
    \end{gather*}
    where $b_i', b_i''$ is such that $\sum_{i\in A}b_i'\otimes b_i''$ is
    the image of $b$ under the diagonal map of $\A$
    (see Definition~\ref{def:steenrodalgebra}).
\end{Def*}

\begin{Lem*}
  Note that the multiplication defined above turns
  $\A\otimes\H^*(\BO)$ into a ring. Then:
  \begin{enumerate}
  \item For any classifying map $\xi\colon X\to\BO$, the
    corresponding $\H^*(\BO)$\nbd{}module structure on $\H^*(X)$
    induces the $(\A\otimes\H^*(\BO))$\nbd{}structure on $\H^*(\Tspec{\xi})$
    \begin{gather*}
      (a\otimes x)\cdot \thomiso(y) = a\left( \thomiso(\pb\xi x\cup y \right)
    \end{gather*}
    via the Thom isomorphism.
  \item For any map of vector bundles, the induced map on Thom spaces
    is $(\A\otimes\H^*(\BO))$\nbd{}linear on cohomology.
  \end{enumerate}
\end{Lem*}

In the spirit of the above observation, one gets even more additional
structure around Thom maps induced by pullbacks of vector bundles.
An essential result is the following de-Thom-ification criterion:
\begin{Thm*}
  Let $k\in\Nat$ and $\xi\colon X\to\BO$ be $k$\nbd{}connected.
  Assume there is a map of spectra
  $\bm{\tau}\colon\spectrum{Z}\to\Tspec{\xi}$.
  Then $\bm{\tau}$ de-Thom-ifies through dimension $2k$ if and only if
  in dimensions lower or equals $2k$ the cohomology ring
  $\H^*(\spectrum{C}_{\bm{\tau}})$ of the mapping cone of $\bm{\tau}$ is
  a free module over $\A\otimes\H^*(\BO)$.
  \begin{proof}[Outline of the proof]
    See \cite[Theorem~3.5]{immersionconj}.
    For the necessity one should observe that a pullback $g\colon Y\to X$ of
    vector bundles can be modified to a certain 2-stage Postnikov tower
    \begin{gather*}
      \SwapAboveDisplaySkip
      Y'\longto X\overset{\xi}\longto\BO
    \end{gather*}
    without changing the homotopy type of $\Tspec{(\pb g\xi)}$ up to
    dimension $2k$.
    Then one can use a theorem by Brown and Peterson, which yields the
    needed result for the cohomology of the modified Thom mapping cone
    (see \cite[Theorem~3.3]{immersionconj}).
    For the other direction, a construction that rebuilds a system as
    the above one using the Thom isomorphism can be applied.
  \end{proof}
\end{Thm*}

Brown and Peterson found a nice Adams resolution of spectra
\begin{gather*}
  \MOmodI n \to\dotsc \to \spectrum{Z}_1 \to \spectrum{Z}_0 = \MOspec
\end{gather*}
which in each stage de-Thom-ifies through dimension $n$ according to
the above criterion.
This finally gives:
\begin{Def}
  Let
  \begin{gather*}
    \SwapAboveDisplaySkip
    \dotsc \to Y_1 \to Y_0 = \BO
 \end{gather*}
  be the result of the de-Thom-ification of the above resolution.
  Define $\BOmodI n$ as the $n$\nbd{}skeleton of the inverse limit of the
  $Y_i$, and the map $\rho_n\colon\BOmodI n\to\BO$ by
  \begin{gather*}
    \rho_n\colon\BOmodI n\to\dotsc\to Y_1\to Y_0=\BO
    \;.
  \end{gather*}
\end{Def}

\begin{Thm*}
  The special choice of the resolution equips
  $\rho_n\colon\BOmodI n\to\BO$ with the following properties:
  \begin{enumerate}
  \item\label{item:bomodinprop:1}
    $\thommap{\rho_n} = \bm{\rho}_n\colon \Tspec{\rho_n}\simeq\MOmodI n\to\MOspec$.
  \item\label{item:bomodinprop:2}
    $\pb\rho_n=\proj\colon
    \H^*(\BOmodI n) \to \H^*(\BO)/\I n\cong\H^*(\BOmodI n)$.
  \item\label{item:bomodinprop:3}
    $\rho_n$ acts as universal bundle for stable normal bundles of
    $n$\nbd{}manifolds.
    \Idest for every $n$\nbd{}manifold there exists a lift $f_M$ of
    $\N M$
    such that the following diagram commutes up to homotopy
    \begin{center}
      \begin{tikzcd}
        M \ar[r, "f_M"]
        \ar[dr, bend right=30, "\N M"{left}]
        &\BOmodI n
        \ar[d, "\rho_n"]\\
        &\BO
      \end{tikzcd}
    \end{center}
  \end{enumerate}
  \begin{proof}[Outline of the proof]
    Statements \ref{item:bomodinprop:1} and \ref{item:bomodinprop:2}
    follow from the choice of $\BOmodI n$ as de-Thom-ification of
    $\bm{\rho}_n\colon\MOmodI n\to\MOspec$, and application of the Thom
    isomorphism.
    For \ref{item:bomodinprop:3}, consider the classifying map $\N M$
    of a stable normal bundle of an $n$\nbd{}manifold. This can inductively
    be lifted to the spaces $Y_i$, again
    using obstruction theory,
    which in this case only needs to be checked on the Thom spectrum
    level. However, for the latter a nice property of the chosen
    resolution is applicable.
  \end{proof}
\end{Thm*}

This is already very close to the desired final result.
However, note that Brown and Peterson could not directly conclude the
needed factorization over $\BO(n-\alpha(n))$ from the definition
(compare \cite{brownpeterson}).
This still required quite a lot of work done by Cohen.

\section*{The Construction of the Lift $\BOmodI n\to\BO(n-\alpha(n))$}
Cohen's approach to finding the factorization of
$\rho_n\colon\BOmodI n\to\BO$ over $\BO(n-\alpha(n))$ is split into two
main parts:
\begin{compactitemize}
\item Show an indirect version of the statement using a carefully
  constructed helper space $X_n$ (\cite[Lemma~B]{cohen}), and
\item prove that this already implies the factorization.
\end{compactitemize}

\begin{Def*}
  Let $P_n\coloneqq \BOmodI n \times_{\BO}\BO(n-\alpha(n))$
  be the usual homotopy pullback of
  \begin{center}
    \begin{tikzcd}
      \BOmodI n
      \ar[r, "{\rho_n}"]
      &\BO
      &\ar[l, "{\incl}"{above}]
      \BO(n-\alpha(n))
    \end{tikzcd}
    ,
  \end{center}
  \idest defined by
  \begin{gather*}
    P_n
    \coloneqq \left\{
      (x, y, \gamma)
      \in \BOmodI n\times \BO(n-\alpha(n))\times \BO^I
      \middlemid
      \gamma(0) = \rho_n(x), \gamma(1) = \incl(y)
    \right\}
    \;.
  \end{gather*}
\end{Def*}
Cohen's Lemma~B is as follows.
\begin{Thm*}
  There exists a space and a map $p_n\colon X_n\to P_n$
  respectively maps $f_n$, $g_n$ fitting into the resulting
  homotopy commutative diagram
  \begin{center}
    \begin{tikzcd}[column sep=small, row sep=small]
      X_n \ar[dr, "p_n"]
      \ar[drr, bend left=20,  "f_n"]
      \ar[ddr, bend right=20, "g_n"{left}]\\
      &P_n \ar[r]\ar[d]
      &\BO(n-\alpha(n)) \ar[d, "\incl"{right}]\\
      &\BOmodI n \ar[r, "\rho_n"]
      &\BO
    \end{tikzcd}
  \end{center}
  satisfying the following properties.
  Let $\xi_n\coloneqq \rho_n\circ g_n=\incl\circ f_n$ be the vector bundle on
  $X$ defined by the map into $\BO$.
  \begin{enumerate}
  \item\label{item:bomodinfactorisation:1}
    There is a map $\bm{s}_n\colon \MOmodI n\to\Tspec{\xi_n}$ of
    spectra, such that
    \begin{center}
      \begin{tikzcd}
        \MOmodI n
        \ar[r, "\bm{s}_n"]
        &\Tspec{\xi_n}
        \ar[r, "\thommap{g_n}"]
        &\MOmodI n
      \end{tikzcd}
    \end{center}
    is homotopic to the identity, \idest defines a split.
  \item\label{item:bomodinfactorisation:2}
    Furthermore, $\bm{s}_n\circ \thommap{g_n}$ is close to the
    identity in the sense that the following diagram of spectra
    commutes up to homotopy
    \begin{center}
      \begin{tikzcd}[column sep=huge, row sep=small]
        \Tspec{\xi_n}
        \ar[r, "\thommap{p_n}"]
        \ar[d, "{\scriptstyle\thommap{g_n}}"{left, near start}]
        & \Tspec{\xi_n} \\
        \MOmodI n
        \ar[d, "{\scriptstyle\bm{s}_n}"{left, near start}] \\
        \Tspec{\xi_n}
        \ar[uur, bend right=15, "~\thommap{p_n}"{right}]
      \end{tikzcd}
    \end{center}
  \end{enumerate}
\end{Thm*}
Cohen showed that Lemma~B implies the existence of a lift of $\rho_n$
to $\BO(n-\alpha(n))$ along $\incl$. This was done by inductively
constructing lifts along a slightly modified Postnikov tower of
the map $\incl\colon\BO(n-\alpha(n))\to\BO$.
The induction step uses that the obstruction to such a lift is
a map from a Thom spectrum to a spectrum which again admits a
free $(\A\otimes\H^*(\BO))$\nbd{}module structure in lower dimensions.
The latter is then used to get rid of the obstruction
(compare \cite[p.~118f]{immersionconj}).

\begin{proof}[Outline of the proof of Lemma~B]
  For more details see \cite[Chap.~III, §2]{immersionconj}.
  We sketch the construction of $X_n$ below.
  The idea is to dissect the map $\MOmodI n\to\MO$ into its
  wedge summands in order to see that this actually factors over a
  wedge of Thom maps of vector bundles.
  $\xi_n\colon X_n\to\BO$ can be constructed from these vector bundles
  as disjoint sum of products in the correct dimension.
  Thus, first observe that
  \begin{gather*}
    \MOmodI n
    \coloneqq
    % \bigvee_{\mathrlap{n\geq\Deg{I}\neq 2^s-1}}
    % \susp^{\Deg{I}} \BrownGitler{n-\deg{I}}
    \bigvee_{\mathrlap{n\geq\Deg{I}\neq 2^s-1}}
    \Spherespec{\Deg{I}} \smashprod \BrownGitler{n-\deg{I}}
    \longto
    \bigvee_{\mathrlap{\Deg{I}\neq 2^s-1}}
    \Spherespec{\Deg{I}} \smashprod  \EMspec
    \cong
    \MOspec
  \end{gather*}
  on each wedge factor looks like
  \begin{center}
    \begin{tikzcd}[column sep=large]
      \Spherespec{\Deg{I}} \smashprod \BrownGitler{n-\deg{I}}
      \ar[r, "M_{\Deg{I}}\smashprod y_k"]
      &\MOspec \smashprod \MOspec
      \ar[r]
      &\MOspec
    \end{tikzcd}
  \end{center}
  where the second map is the multiplication of the ring spectrum
  $\MO$.
  Now, both $M_{\Deg{I}}$ as well as $y_k$ originate
  from classifying maps of vector bundles, which furthermore factor
  over $\BO(n-\alpha(n))$:
  \begin{description}
  \item[$y_k$:]
    Using a specific construction shows that
    the $k$th Brown-Gitler spectrum is in fact the Thom spectrum of a
    vector bundle $\tilde y_k\colon\BraidSpace k\to\BO$ over the
    Eilenberg-MacLane space $\BraidSpace k\coloneqq K(\Braid{k},1)$,
    where $\Braid k$ is the $k$th braid group
    (see \cite[Chap.~II, §2]{immersionconj}).
    The homotopy type of $\BraidSpace{k}$ shows that $\tilde y_k$
    factors over $\BO(k-\alpha(k))$ by obstruction theory.
  \item[$M_{\Deg{I}}$:]
    The stable homotopy group $\pi_k^s(\MOspec)$ is isomorphic
    to the $k$th cobordism group $\c_k$
    via the Thom-Pontryagin isomorphism (see \cite[Chap.~II]{stong}).
    The latter also says that a map $\Spherespec{k}\to\MOspec$
    represented by a manifold $M^k$ representing under the above
    isomorphism factors up to homotopy as
    \begin{center}
      \begin{tikzcd}
        \Spherespec{k} \ar[r, "\spectrum{c}"]
        &\Tspec{\N M} \ar[r, "\thommap{\N M}"]
        &\MOspec
      \end{tikzcd}
    \end{center}
    where $\bm{c}$ is the stable version of a collapse map.
    Furthermore, due to Theorem~\ref{thm:brown}, one can always choose
    a representative $M^k$ for which
    $\N M\colon M\to\BO$ factors over $\BO(n-\alpha(n))$.
  \end{description}
  The map $\xi_n\colon X_n\to\BO$ will look like
  \begin{gather*}
    \SwapAboveDisplaySkip
    \coprod_{\mathclap{n\geq\Deg{I}\neq 2^s-1}}
    M_{\Deg{I}} \times \BraidSpace{n-\Deg{I}}
    \xrightarrow{\coprod \N{M_{\Deg{I}}} \times \tilde y_{n-\Deg{I}}}
    \BO
  \end{gather*}
  where $M_{\Deg{I}}$ is a manifold representing the map
  $M_{\Deg{I}}$, chosen such that it fulfills the immersion
  property.
  A choice like this will factor over
  $\incl\colon\BO(n-\alpha(n))\to\BO$ as explained above.
  And a factorization over $\rho_n\colon\BOmodI n\to\BO$ is directly
  given if one observes that
  \begin{compactitemize}
  \item $\rho_i\times\rho_j\colon\BOmodI i\times\BOmodI j\to\BO$ factors
    over $\rho_{i+j}$,
  \item $\tilde y_k$ factors over $\rho_k$, and that
  \item all stable normal bundles of $k$\nbd{}manifolds factor over
    $\rho_k$ by its universality property.
  \end{compactitemize}
  So, bundles of the form described above are candidates
  for $\xi_n$.
  They can also be shown to fulfill the splitting
  property \ref{item:bomodinfactorisation:1} using the well-known
  formula
  \begin{gather*}
    \Tspec{(\N{M_i} \times \tilde y_j)}
    = \Tspec{\N{M_i}} \smashprod \Tspec{\tilde y_j}
    \;.
  \end{gather*}
  However, if one wants to obtain a vector bundle satisfying
  condition~\ref{item:bomodinfactorisation:2} using the above
  construction, one has to be careful when choosing the
  set of representatives
  \begin{gather*}
    \left\{ M_{\Deg{I}}\mid n\geq\Deg{I}\neq 2^s-1 \right\}
    \;.
  \end{gather*}
  Cohen's approach here is an induction on $n$:
  For $\Deg{I}=n$,
  \begin{itemize}
  \item the decomposable classes are represented as product
    manifold of the lower dimensional representatives, and
  \item the (unique) indecomposable class $\Spherespec{n}\to\MO$ of degree
    $n$ is shown to originate from a split
    \begin{gather*}
      \SwapAboveDisplaySkip
      \bm{j}\colon
      \Tspec{(\rho_n|_{\subcxBOmodI n})} \vee \Spherespec{n}
      \overset{\cong}\longrightarrow \MOmodI n
    \end{gather*}
    where $\subcxBOmodI n$ is a nice subcomplex of $\BOmodI n$.
  \end{itemize}
  The neat properties of $\subcxBOmodI n$ and the induction assumption
  then imply \ref{item:bomodinfactorisation:2} for this choice of
  $\xi_n$.
\end{proof}

With this Cohen finalized the proof of the immersion conjecture.

%\optcite[Theorem~3.34]{The Topology of Fiber Bundles Lecture Notes, Cohen}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "thesis"
%%% ispell-local-dictionary: "en_US"
%%% End:


%!TEX root = ../notes.tex
\section{March 25, 2022}
\subsection{Quantum Computation}
\emph{Warm-up:} Deutch's Algorithm

\ul{Setup}: We have a function $f : \{0, 1\}\to \{0, 1\}$. We note there are 4 possibilities for functions $f$. Let's say we have a black box that takes $x$ and computes $f(x)$, taking an hour to run.

Our question is ``is $f$ constant''? Does $f(0) = f(1)$?

Classically, the fastest algorithm takes $2$ hours. We pass in $0$ and then pass in $1$ and check if they are equal.

At the end, we know $f(0) \overset{?}{=} f(1)$. But we know more! We know exactly what $f(0)$ and $f(1)$ are.

\ul{Quantum Reformulation}: we can \emph{manipulte quantum states}. We consider the simplest system, an electron $e^-$. An electron has a property called \emph{spin}: which can be in one of two states:
\[\Ket{\uparrow}, \quad \Ket{\downarrow}\]
which we notate $0$ and $1$.

\begin{remark*}
    The state of the system is \textbf{not a ``probabilistic classical state''.}. It's \textbf{not} represented as
    \[a\cdot \Ket{\uparrow} + b\cdot \Ket{\downarrow}\]
    where $a, b$ are positive reals with $a + b = 1$.
\end{remark*}

The \emph{actual state} of our machine is
\[a\cdot \Ket{\uparrow} + b\cdot \Ket{\downarrow}\]
where $a, b\in\CC$ where $|a|^2 + |b|^2 = 1$. The probability of measuring $\Ket{\uparrow}$ is $|a|^2$ and $\Ket{\downarrow}$ is $|b|^2$.

\begin{example}
    The typical experiment for this is the light passing through two slits:
    \begin{center}
        \includegraphics[width=0.5\textwidth]{images/slit-experiment.png}
    \end{center}
\end{example}

We'll run black box again with quantum mechanics - except we only run it once and don't require the knowledge of what $f(0)$ and $f(1)$ \emph{actually are}.

The laws of quantum mechanics are time symmetric. Thus,
\[f : \begin{cases}
        0\mapsto 0 \\
        1\mapsto 0
    \end{cases}\]
\emph{cannot} exist in a quantum computer since it's not invertible. How do we encapsulate our function to be run in a quantum computer?

We define a new function
\[F(x, y) = (x, f(x) + y \text{ mod } 2)\]
$F$ and $f$ encode exactly the same information. But $F$ is defined in a way such that it fits on a quantum computer since it's an invertible function. Classically, it makes no difference having a box that computes $F$ or a box that computes $f$. Computing one gives us the other.

\subsubsection{Deutch's Problem}
Given a \emph{quantum} black box for $F$. Can we determine whether $f(0) = f(1)$?

The idea is that we feed in $x$ and $y$ as superpositions between $0$ and $1$ and exploit cancellation. We evaluate
\begin{align*}
     & \phantom{=} F\left( \frac{1}{\sqrt{2}}\Ket{0}+\frac{1}{\sqrt{2}}\Ket{1}, \frac{1}{\sqrt{2}}\Ket{0} - \frac{1}{\sqrt{2}}\Ket{1} \right)                                \\
     & = \frac{1}{2} \Ket{0}\otimes \Ket{f(0)} - \frac{1}{2}\Ket{0}\otimes \Ket{f(0) + 1} + \frac{1}{2}\Ket{1}\otimes \Ket{f(1)} - \frac{1}{2}\Ket{1} \otimes \Ket{f(1) + 1} \\
     & = \frac{1}{2}\boxed{\left( (-1)^{f(0)}\Ket{0} + (-1)^{f(1)}\Ket{1} \right)}\otimes \left( \Ket{0} - \Ket{1} \right)
\end{align*}

What if I measure the first register? We get $50\%$ chance of $\Ket{0}$ and $50\%$ chance of $\Ket{1}$ and we gain no information.

Graphing this, we have $4$ states $(1,1)$, $(-1, -1)$, $(1, -1)$, and $(-1, 1)$. Applying a rotation matrix
\[\begin{pmatrix}
        \frac{1}{\sqrt{2}}  & \frac{1}{\sqrt{2}} \\
        -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}
    \end{pmatrix}\]
we get states on the axes. So we get $\Ket{1}$ if $f(0) = f(1)$ and $\Ket{0}$ if $f(0) \neq f(1)$.


\subsection{Candidate set verification} \label{sec:verification} The pruning
methods based on the \khop and the \ncl labels start with a \CR and prune some
of the candidate vertices based on the conditions described in theorems
\ref{thm:khop} and \ref{thm:ncl}.  The verification step reduces \CR to \RS by
retaining only those vertices $v$ for which there exists an isomorphism $\phi$ in
which $\phi(u) = v$.  Informally, it does this by checking if the pattern $P$ can be
embedded at $v$ such that total cost of label mismatch is at most $\alpha$.

A vertex $v \in R(u)$ iff for any walk $w_p = (u_0=u), u_1,\ldots,u_m$ that covers all
the edges in pattern $P$ there exists atleast one walk $w_d = (v_0=v), v_1,\ldots,
v_m$ in the database $G$ and satisfying the following three conditions: i)
$u_i = u_j \implies v_i = v_j$ ii) $(v_i, v_{i+1}) \in \eg$
iii) $\sum\matij{C}{L(u_i)}{L(v_i)} \leq \alpha$.
Unlike the \ncl label condition, the above conditions are necessary and
sufficient and can be verified by following the definition of isomorphism.

Now, to check whether $v \in R(u)$, we first map $u$ to $v$ and subtract the cost of
$\matij{C}{L(u)}{L(v)}$ from the threshold $\alpha$. We then try to map the
remaining vertices in $P$ by following $w_p$ one edge at a time. In any step
$(u_i, u_{i+1})$, if $u_i$ and $u_{i+1}$ are mapped to $x$ and $y$ respectively
then we ensure that $(x, y) \in \eg$
(condition ii). If on the other hand, $u_{i+1}$ is not mapped then we map it
to some vertex in $y \in R'(u_{i+1})$ and subtract the cost
$\matij{C}{L(u_{i+1})}{L(y)}$ from the remaining $\alpha$ threshold. We back
track if the remaining threshold is less than $0$. The vertex $v \in R(u)$, if we
can complete the walk $w_p$ satisfying the above three conditions.

Consider checking whether the vertex $30 \in R(1)$
in the pattern in the figure~\ref{subfig:ex_sub} and let $\alpha = 0.5$. The
sequence $w_p = 1, 2, 4, 3, 1$ is a walk in the pattern that covers all the edges.
In general, finding a walk that covers all the edges in a graph is a special
case of Chinese postman problem \cite{chinesepostman}. We first map $1$ to $30$
an subtract the cost $\matij{C}{L(1)}{L(30)} = 0.2$ from $0.5$. In the first
step $(1,2)$, since $2$ is not mapped we map it some vertex, say $20$. The cost
of the mapping is $0.2$ and the remaining threshold is $0.3 -0.2 = 0.1$. It can
be verified that these mappings cannot complete the walk $w_p$. So we backtrack
and map $2$ to another vertex say $10$. The walk can be completed with the
mappings as in $\phi_1$ in Table~\ref{subfig:ex_occur} and the remaining cost is
$0.1$. The mappings of the pattern vertices not only implies that $30 \in R(1)$,
it also tells us that $10, 60, 40$ represent vertices $2, 3, 4$ respectively.
The above procedure can be easily extended to enumerate all the isomorphims of the
pattern.


\chapter{The structure and kinematics of the Milky Way}
In this chapter we describe how SALSA can be used to measure the structure
and kinematics of the Milky Way. First we explain how to measure the rotation curve,
i.e. the rotational speed of the gas at different distances from the galactic center.
Then we build on these results to make a map of the spiral arms.

\section{The rotation curve of the Milky Way}
A rotation curve is function which describes the rotational speed of the galaxy
at different distances from the center, usually denoted $V(R)$.
To construct a rotation curve we first need to understand how the velocity we
measure (through Doppler shift) is related to the movement of gas clouds in the
Milky Way. Let us imagine that we point our radio telescope towards a gas cloud
in the Galaxy, i.e. we observe along the green line in Fig. \ref{fig:galgeom}.
\begin{figure}[ht]
\begin{center}
\includegraphics[width=8cm]{../figures/galgeom.pdf}
\end{center}
\caption{Geometry of the Galaxy. {\bf C} is the location of the Galactic center,
{\bf S} that of the Sun, {\bf M} that of a gas cloud that we want to observe.
The SM line is the line-of-sight. The arrow on an arc indicates the direction
of rotation of the Galaxy. The arrows on line segments indicate the
velocity of the Sun ($V_0$) and the gas cloud ($V$).}
\label{fig:galgeom}
\end{figure}
For future reference we list some variables used in this figure:
\begin{displaymath}
	\boxed{
\begin{array}{ll}
	V_0 	&\hbox{Sun's velocity around the Galactic center, i.e. 220 km/s}					\\
    R_0	&\hbox{Distance of the Sun to the Galactic center, i.e. 8.5 kpc}) 					\\
l	&\hbox{Galactic longitude of observation}				\\
V	&\hbox{Velocity of a cloud of gas}			\\
R	&\hbox{Cloud's distance to the Galactic center}		\\
\end{array}
}
\end{displaymath}

There may be many clouds in this direction, but for the purpose of this
derivation we only care about a single cloud located at position $M$ in Fig.
\ref{fig:galgeom}. Since both the Sun and the cloud are moving, we do not measure
the cloud velocity directly. Instead, we measure the relative velocity, $V_r$,
between the us and the cloud, projected on the line-of-sight.  Using the angles
in Fig. \ref{fig:galgeom} we can write this down as
\begin{equation}
V_r = V \cos\alpha - V_0 \sin c .
\label{eqn:vrel1}
\end{equation}
For this expression to be useful we need to relate the angles to the galactic
coordinates we discussed in Sect. \ref{sect:galcoords}.  We know that
the sum of angles in the upper right triangle must be 180$^\circ$, which means that
we can relate the angle $c$ to galactic longitude $l$ as
\begin{equation}
(90-l)+90+c=180 \quad \Rightarrow \quad c=l.
\label{eqn:c}
\end{equation}
We now want to relate also the angle $\alpha$ to the longitude $l$.
We note that the angle between $V$ and $R$ is 90$^\circ$ and can be written
as the sum of $a$ och $\alpha$, i.e. $90^\circ = b + \alpha$.
From the triangle {\bf CMT} we also note that $b = 90^\circ - a$.
Put together we get
\begin{equation}
    90 = 90-a+\alpha \quad \Rightarrow \quad a = \alpha
\label{eqn:a}
\end{equation}
Looking at the triangles {\bf CST} and {\bf CMT} we find that the distance
between the Galactic Center ({\bf C}) and the tangential point ({\bf T}) can be
expressed in two different ways:
\begin{equation}
	{\rm\bf CT} = R_0\sin l = R \cos a \quad \Rightarrow \quad \cos a = \frac{R_0\sin l}{R}
\label{eqn:cosalpha}
\end{equation}
Using eqns. \ref{eqn:c}, \ref{eqn:a}, and \ref{eqn:cosalpha} we can now
re-write eqn. \ref{eqn:vrel1} as
\begin{equation}
\boxed{V_r = V \frac{R_0}{R}\sin l - V_0 \sin l .}
\label{eqn:vrel2}
\end{equation}
This equation is valid for all longitudes $l$. However, measuring $V_r$ alone for any given $l$
is not enough to solve this equation to derive both $V$ and $R$. A solution is to restrict
the range of possible $l$ to the first quadrant, and using only the maximum velocity detected
in our calculations. We now explain how this simplifies the problem.

In any given direction we may observe emission from multiple clouds at once. Since the clouds
move with different relative velocities, we measure multiple components in the spectrum, as illustrated
in Fig. \ref{fig:vmax}.
\begin{figure}[ht]
\begin{center}
\includegraphics[width=10cm]{../figures/vmax.pdf}
\end{center}
\caption{There can be multiple velocity components in the observed spectrum, each peak corresponds
to a cloud with some relative velocity.}
\label{fig:vmax}
\end{figure}
We now assume that clouds at larger distances from the center move with equal
or lower speed than clouds closer to the center, as expected from standard
Keplarian motion (see Appendix. \ref{sect:kepler}).  In this case, the {\bf
largest velocity component}, $V_{\rm r,max}$, comes from the cloud {\bf at the
tangential point} ({\bf T}), since the maximum possible projected velocity
happens when the projection angle is 0.  For a cloud at the tangent point we
see from Fig. \ref{fig:galgeom} that the cloud location is given by
\begin{equation}
	R = R_0 \sin l.
	\label{eqn:rotR}
\end{equation}

This simplifies equation \ref{eqn:vrel2} so that, at the tangential point, we
have:
\begin{equation}
V = V_{r,max} + V_0 \sin l .
\label{eqn:rotV}
\end{equation}

We may now use SALSA to measure $V_{\rm r,max}$ at different $l$ in the first
quadrant.  Using equations \ref{eqn:rotR} and \ref{eqn:rotV} we may then
calculate the rotation curve $V(R)$. It is reasonable to assume the measured
rotation curve to be valid also in the other three quadrants.

\subsection{Measure the rotation curve with SALSA}
\label{sect:SALSArot}
After reading the previous section you should have an idea about how to measure
the rotation curve of the Milky Way using SALSA. Instructions for how to
operate the telescope are given in another document called the \emph{SALSA
users manual}, available at the SALSA website.
Once you have obtained spectra
at a few selected longitudes, extract the maximum velocity of each spectrum and
plot the rotation curve.
The simplest way is to use the cursor to inspect the spectrum directly in the
control program, but you can also use more advanced tools such as
Matlab. Instructions for how to extract velocity information from the spectra
can also be found in the \emph{SALSA users manual}.
To make the final plot of the rotation curve you may use your favourite
plotting program.  A simple free solution is to use the \emph{Excel-like}
program \emph{LibreOffice Calc}, where you can put your calculated
values of V and R in a spreadsheet and then use the {\tt xy-chart}
to plot the data. Your final plot should look similar to Fig. \ref{fig:rotfinal}.
Note that the rotation curve is almost flat! This is an indirect evidence
for dark matter in our galaxy. You may also want to compare with the results in
Appendix \ref{app:rotcurves}.

\begin{figure}[t]
\begin{center}
\includegraphics[width=0.7\textwidth]{../figures/SALSA_rotcurve.pdf}
\caption{Example of a rotation curve measured with SALSA.}
\label{fig:rotfinal}
\end{center}
\end{figure}

\section{Mapping the Milky Way}
\label{sect:map}
Now we would like to find out {\em where} is the HI gas that we have detected.
Let us therefore return to eqn. \ref{eqn:vrel2}.  When finding the rotation
curve, we used only the maximum velocity component in the spectrum, and assumed
that it came from gas at the tangential point.  This assumption made it
possible to solve eqn. \ref{eqn:vrel2} in the first quadrant.  Now, we shall
use  {\em all the velocity components} that we see in our spectra, and we want
to be able to map in all observable directions, not only in the first quadrant.
We can now use our knowledge about the rotation curve obtained in the Sect. \ref{sect:SALSArot}.
Motivated by the shape our measured rotation curve we now assume that the gas in our Milky Way
obeys {\em differential rotation}, i.e. the rotational speed is
constant with radius and is the same as the rotational speed of the Sun, i.e.
\begin{equation}
	V(R) = {\rm constant} = V_0.
\end{equation}
With this assumption, eqn. \ref{eqn:vrel2} simplifies to
\begin{equation}
V_r = V_0\sin l \left( \frac{R_0}{R} -1 \right).
\end{equation}
This equation can be re-written as an expression for the cloud distance $R$ as
a function of known (or observable in the case of $V_r$) quantities as
\begin{equation}
\boxed{
R = \frac{R_0 V_0 \sin l}{V_0 \sin l + V_r}.
}
\label{eqn:Rmap}
\end{equation}

Now we would like to make a map of the Milky Way and place the
position of the cloud that we have detected.  From our measurement of
the radial velocity $V_r$ we have just calculated the distance of the
cloud to the Galactic center, $R$, and we know in which direction we
have observed (the Galactic longitude $l$).

Please note that if you observe in Quadrants II or III, then the position of
the emitting gas clouds can be determined uniquely. But, if observing in
Quadrants I or IV, there may be {\em two possible locations} corresponding to
given values of $l$ and $R$: closer to us than the tangential point $T$ (the
actual point {\bf M} on the figure), or farther away, at the intersection of
the {\bf ST} line and the inner circle (see Fig. \ref{fig:galgeom}).
{\bf You may want to make a drawing to convince yourself that
this is true.}

This distance ambiguity can also be shown mathematically. Let $r$ denote the
distance from the Sun to the cloud, i.e. the distance between the points {\bf
S} and {\bf M} in  Fig.  \ref{fig:galgeom}. Using the law of cosines on the triangle
{\bf CSM} we obtain the following relation:
\begin{equation}
R^2 = R_0^2 + r^2 - 2 R_0 r \cos l.
\end{equation}
This is a second-order equation in $r$, which has two possible solutions. If we
denote these solutions $r=r_{+}$ and $r=r_{-}$, we can write the solutions as
\begin{equation}
\boxed{
r_\pm = \pm \sqrt{R^2 - R_0^2 \sin^2 l} + R_0\cos l .
}
\label{eqn:rpm}
\end{equation}

We note a couple things regarding the above equation. For some data points one
finds one postitive and one negative solution for $r$. The negative solution is
not meaningful (it would mean on the other side of the sun) and should be
discarded.  In Quadrants II or III, $R$ is always larger than $R_0$ and $\cos l
<0$, meaning there is one and only one positive solution, $r_+$.  In Quadrants
I or IV, there may be two positive, and therefore possible, solutions. In cases
with two possible solutions it is not possible to determine which one is the
correct one without additional observations.  To resolve this ambiguity, one
can observe again towards the same galactic longitude but towards a small (a
few degrees) non-zero galactic latitude.  If the ambigous cloud is far away, it
should no longer be seen. If the cloud is close, it should still appear even if
observing slightly out of the plane.  Some experimenting may be necessary here
to find out the appropriate galactic latitude.

\subsection{Converting from $r$ and $l$ to Carteesian coordinates}
For plotting it may be inconvenient to use the coordinates $r$ (distance to
cloud from the Sun) and $l$ (galactic longitude) to describe the cloud
positions. Instead it is usually more convenient to transform to a Carteesian
system of perpendicular coordinates $x$ and $y$.  To convert to $x-y$
coordinates we need to relate them to $r$ and $l$.

You are probably familiar with \emph{polar coordinates}, usually defined as
\begin{equation}
\left\{
\begin{array}{l}
x=r \cos \theta \\
y=r \sin \theta \\
\end{array}
\right.
\label{eqn:polar}
\end{equation}
where $r$ is the distance from the origin and $\theta$ is the rotation angle, and
$x$ and $y$ are Carteesian coordinates.

It is clear that polar coordinates are very similar to our $r$, $l$-system,
as is also evident when plotting both together in Fig. \ref{fig:polar}.
\begin{figure}[ht]
\begin{center}
\includegraphics[width=0.5\textwidth]{../figures/coordinate.pdf}
\caption{Illustration of polar ($r$,$\theta$) versus Galactic
  ($r$,$l$) coordinates.}
\label{fig:polar}
\end{center}
\end{figure}
We find that $\theta=270^\circ +l$, or $\theta=l-90^\circ$. This means that we can convert our positions given as $r$,
$l$ to Carteesian $x-y$ coordinates by:
\begin{equation}
	\boxed{
\left\{
\begin{array}{l}
	x=r \cos (l-90^\circ) \\
	y=r \sin (l-90^\circ) \\
\end{array}
\right.}
\label{eqn:rpmtocart}
\end{equation}
This format is usually the most convenient to plot the positions. Note that this will show the map
with Earth in the center, at position (0,0). If you instead want the Galactic center to be awt (0,0),
add $R_0$ to the y-coordinate of each point.

\subsection{Make a map with SALSA}
\label{sect:SALSAmap}
After reading the previous section you should have an idea about how to
construct a map from measured velocities. The measurements are done in the same
way as you did in Sect. \ref{sect:SALSArot}, but now you do not have to measure
in the first quadrant. Also, you should extract all velocity components in your
spectra, not only the maximum one.  Again, instructions for how to operate the
telescope are given in another document called the \emph{SALSA users manual},
available at the SALSA website.  The simplest way to obtain velocities from a
spectrum is to use the cursor to inspect the spectrum directly in the control
program, but you can also use more advanced tools such as Matlab. Instructions
for how to extract velocity information from the spectra can also be found in
the \emph{SALSA users manual}.

Once you have a list of measured velocities for multiple longitides you
can use eqn. \ref{eqn:rpm} to find the position of the clouds. Note that
observations in Quadrants I or IV may need additional observations
to resolve possible distance ambiguities, as discussed in the previous section.

To make the final map you may use your favourite plotting program.  Again, a
simple free solution is to use the \emph{Excel-like} program \emph{LibreOffice
Calc}, where you can put your calculated positions (x,y) in a spreadsheet and
then use the {\tt xy-chart} to plot the data.  Your final map may look similar
to Fig. \ref{fig:rotfinal}, although it will depend on in which directions you
have been observing.  You may also want to compare with the map on the cover
page of this document.

\begin{figure}[t]
\begin{center}
\includegraphics[width=0.6\textwidth]{../figures/galaxopenoffice1.pdf}
\caption{Snapshot of the $xy$-chart in OpenOffice.  You can clearly
  see the spiral arms in the Galaxy.  The blue circle represents the
  area of the Galaxy, which has diameter of 50~kpc.}
\label{fig:mapfinal}
\end{center}
\end{figure}


\documentclass[12]{article}
\usepackage{amssymb}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{xspace}
\usepackage{amsmath}
\usepackage[english]{babel}
\makeatletter

\def\BState{\State\hskip-\ALG@thistlm}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{bytefield}
\usepackage{graphicx}
\usepackage{graphicx,wrapfig,lipsum}
\newcommand{\species}[1]{\textit{#1} sp.}
\usetikzlibrary{arrows,shapes}

\title{Department of Computer Science | University of Wisconsin-Whitewater \\
Cryptography and Cloud Security Midterm Exam}
\author{ Dr. Jiazhen Zhou \\ \\
Abdoul-Nourou Yigo
}

\date{March 2019}

\begin{document}
% Declare layers
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\maketitle

\section{ Congruential Algorithm}

$X_{n+1} = 7X_n \mod 13$

\begin{enumerate}

	\item Assume that $X_0 = 1$, write out the sequence till a number is repeated in the sequence. Does this generate a full period?

	$X_0  = 1$ \\
	$X_1  = 7 \times      \mod 13  = 7$ \\
	$X_2  = 7 \times 7    \mod 13  = 10$\\
	$X_3  = 7 \times 10   \mod 13  = 5$ \\
	$X_4  = 7 \times 5    \mod 13  = 9$ \\
	$X_5  = 7 \times 9    \mod 13  = 11$ \\
	$X_6  = 7 \times 11   \mod 13  = 12$ \\
	$X_7  = 7 \times 12   \mod 13  = 6$ \\
	$X_8  = 7 \times 6    \mod 13  = 3$ \\
	$X_9  = 7 \times 3    \mod 13  = 8$ \\
	$X_{10} = 7 \times 8  \mod 13  = 4$ \\
	$X_{11} = 7 \times 4  \mod 13  = 2$ \\
	$X_{12} = 7 \times 2  \mod 13  = 1$ \\

	With the above result we can see the sequence repeats at $X_{12}$; therefore, it generates a full period.

	\item  Does this sequence look random to you? Hint: if you can find some relationship among neighboring ( could be evenly spaced numbers ) numbers in the sequence, likely it means that it is not random. \\

	Let's an observation to analyse the number patterns: \\

	$X_1 - X_0 = 6$ \\
	$X_2 - X_1 = 3$ \\
	$X_3 - X_2 = 5$ \\
	$X_4 - X_3 = 4$ \\
	$X_5 - X_4 = 2$ \\
	$X_6 - X_5 = 1$ \\
	$X_7 - X_6 = 6$ \\
	$X_7 - X_8 = 3$ \\
	$X_9 - X_8 = 5$ \\
	$X_9 - X_{10} = 4$ \\
	$X_{11} - X_{10} = 2$ \\
	$X_{11} - X_{12} = 1$

	When  we do a substrations between the  values ( predecessor and successor ) or vice versa we can see that the subtraction results repeat twice in the sequence. Each value repeat at index $i + 6$ position for instance. From this observation, we can clearly see a pattern between the numbers generation. We can conclude that this process is not random.

	\item Using the keystream generated above ( each key is $4$ bits ) for a stream cipher to encrypt the the plaintext "ab e4 25 69 3c 2f 8d 21", what is the ciphertext?

	\textbf{Plaintext: ab e4 25 69 3c 2f 8d 21 } \\
	\textbf{Keystream: 1 7 10 5 9 11 12 6 3 8 4 2 }\\

	Let's effectuate the encryption:
	\begin{tiny}

	1010 1011 1110 0100 0010 0101 0110 1001 0011 1100 0010 1111 1000 1101 0010 0001 \\
	0001 0111 1010 0101 1001 1011 1100 0110 0011 1000 0100 0010 0001 0111 1010 0101 \\
	1011 1100 0100 0001 1011 1110 1010 1111 0000 0100 0110 1101 1001 1010 1000 0100 \\
	b		c    4    1    b    e    a    f    0    4    6    d    9    a    8    4
	\end{tiny}

	\textbf{CipherText:	bc 41 be af 04 6d 9a 84 }

	\item If the recieved stream cipher is "45 6c 26 3e 47 5c", please decrypt the stream. Note that the receiver is using the same pseudo number generator as the sender and  knows the same seed ( 1 in this case).

	$X_1  = 7$ \\
	$X_2  = 7 \times 7    \mod 13  = 10$\\
	$X_3  = 7 \times 10   \mod 13  = 5$ \\
	$X_4  = 7 \times 5    \mod 13  = 9$ \\
	$X_5  = 7 \times 9    \mod 13  = 11$ \\
	$X_6  = 7 \times 11   \mod 13  = 12$ \\
	$X_7  = 7 \times 12   \mod 13  = 6$ \\
	$X_8  = 7 \times 6    \mod 13  = 3$ \\
	$X_9  = 7 \times 3    \mod 13  = 8$ \\
	$X_{10} = 7 \times 8  \mod 13  = 4$ \\
	$X_{11} = 7 \times 4  \mod 13  = 2$ \\
	$X_{12} = 7 \times 2  \mod 13  = 1$ \\
	$X_{13} = 7 \times 1  \mod 13 = 7$

	\textbf{CipherText: 45 6c 26 3e 47 5c }

	\textbf{Keystream: 7 10 5 9 11 12 6 3 8 4 2 1 }

	\begin{tiny}

		0100 0101 0110 1100 0010 0110 0011 1110 0100 0111 0101 1100

		0111 1010 0101 1001 1011 1100 0110 0011 1000 0100 0010 0001

		0011 1111 0011 0101 1001 1010 0101 1101 1100 0011 0111 1101

		3	  f     3    5   9    a     5    d   c     3    7   d

	\end{tiny}

	\textbf{Plaintext: 3f 35 9a 5d c3 7d }

\end{enumerate}

\section{ Modular Arithmetic Operations}

	Find the results of the following modular arithmetic operations. Use related theorem ( e.g Euler's theoreme ) as appropriate.

	\begin{enumerate}
		\item $10^{482} \mod 33$

		 $a = 10$ \\
		 $n = 33$ \\

		 $\phi(33) = ( 3 - 1 ) \times ( 11 - 1 ) = 20$ \\
		 $10^{20} \mod 33 = 1 $ \\
		 $10^{20 \times 24 + 2} \mod 33 = ( 10^{20})^{24} \times 10^2 \mod 33 = 1$

		 \item $8^{602} \mod 39$

		  $a = 8$ \\
		  $n = 39$ \\
		  $\phi(39) = ( 3 - 1 ) \times  ( 13 - 1 ) =  24$ \\
		  $8^{24} \mod  39 = 1 $ \\
		  $8^{ 24 \times 25 + 2 } \mod 39 = (8^{24} )^{25} \times 8^2 \mod 39$ \\
		  $8^2 \mod 39 =  25$

		  \item $6^{163} \mod 17 $

		  We have  $a = 6$, $p = 17$ such that $6^{16} \mod 17 = 1$

		  Dividing the exponent by $p - 1$ we have:

		  $163 =  16 \times 10 + 3$ \\
		  $6^{163} \mod 17 = 6^{16 \times 10 + 3} \mod 17$\\
		  $= 6^{16 \times 10}  \times \mod 17 \times 6^3 \mod 17$\\
  		  $= 1^{10} \times 6^3 \mod 17 =  12$ \\

		  \item $ 33^{162}\mod 11$

		  We have $a = 33$,  $p = 11$ such that $33^{10} \mod 11 = 1$

		  Diving  the exponent by $p - 1$ we have:

		  $162 = 10 \times 16 + 2$ \\
		  $33^{162} \mod 11 =  33^{10 \times 16 +2 } \mod  11$ \\
		  $=  1 \times 33^{2} \mod 11 = 0$

	\end{enumerate}

\section{ RSA Algorithm }

For RSA algorithm, find the private key for each of the following case and show your encryption and decryption results with given  M

\begin{enumerate}
	\item $p = 7$, $q = 13$, $e = 29$, $M = 81$

	 	\begin{itemize}
	 		\item   Calculation of $n$

			$n = pq = 7 \times  13 = 91$ \\

			\item Calculation of $\phi(n)$

			$\phi(n) = ( p - 1)( q - 1 ) = ( 7 - 1)( 13 - 1 ) = 72$

			\item Calculation of the private key $d$

			$ed = \phi(n) \times k + 1$ \\
			$29d = 72 \times k + 1 $ \\
			$k = 2$\\
			$d =  \frac{145}{29}$ \\
			$d = 5$

			\item Encryption procedures

			$C = M^e \mod n$ \\
			$C = 81^{29} \mod 91$ \\
			$C = ( 81^3)^8 \mod 91 \times 81^4 \mod 91 \times  81 \mod 91$ \\
			$(81^3)^8 \mod 91 = 1$\\
			$(81^4 \times 81) \mod 91 =  9$ \\
			$C = 9$

			\item Procedures for descryption

			$M = C^d \mod 91$ \\
			$M = 9^5 \mod 91$ \\
			$M = 59049 \mod 91$ \\
			$M = 81$

	 	\end{itemize}

		\item $p = 5$, $q = 17$, $e = 3$, $M = 31$

		\begin{itemize}
			\item   Calculation of $n$

			$n = pq = 5 \times 17 = 85$

			\item Calculation of $\phi(n)$

			$ \phi(n) = ( p - 1)(q - 1) = ( 5 - 1 )( 17 - 1 ) = 64$ \\

			\item Calculation of the private key d

			$ed = \phi(n)  \times k + 1$ \\
			$3d =  64 \times k + 1 $	\\
			$k = 2$ \\
			$d =  \frac{129}{3}$ \\
			$d = 43$

			\item  Encryption procedures

			$C = M^e \mod  n$ \\
			$C = 31^3 \mod 85$\\
			$C = 29791 \mod 85$ \\
			$C = 41$

			\item Decrytion procedures

			$M = 41^{43} \mod 85$ \\
			$M = ( 41^6)^7 \mod \times 41 \mod 85$ \\
			$M = ( 26^7 \times 41 ) \mod  85$ \\
			$M =  31$

		\end{itemize}

			\item $p = 3$, $q = 19$, $ M = 65$

				\begin{itemize}

					\item Calculation of $n$

					$n = pq =  3 \times 19  = 57$ \\

					\item Calculation of $\phi(n)$

					$\phi(n) = ( p - 1)( q - 1 ) = ( 3 - 1 )( 19 - 1 ) = 36$

					\item We could observe that there is a basic requirement that is not met because $M > n$. Therefore, we could conclude that the Encryption and decryption procedures could not be done.

				\end{itemize}

\end{enumerate}

\section{ Block Cipher Operations }

Suppose that one has designed a block cipher operation mode as \\

$C_i = E_k(P_{i - 1 }) \oplus P_i$ \\
$P_0 = IV$

\begin{enumerate}
	 \item  Write the formula for decrypting in the receiver side

		$P_i =  C_i \oplus D_k( P_{ i - 1 })$

		\begin{figure}

				\includegraphics[scale=.5]{1.jpg}
				\caption{ Encryption Procedures }
				\label{Figure1:Encryption}

		\end{figure}

		\begin{figure}

				\includegraphics[scale=.5]{2.jpg}
				\caption{ Illustration of Error Propagation from $C_2$ }
				\label{Figure1:Encryption}

		\end{figure}

		\begin{figure}

				\includegraphics[scale=.5]{3.jpg}
				\caption{ Illustration of the Error Propagation from $P_1$}
				\label{Figure1:Encryption}

		\end{figure}

	\item  Is it possible to execute encryption in parallel? How about decryption? Justify your answer.

	Observing the  blocks chaining from $Figure1$, we could see that the
	encryption can be done in parallel. It can be done as such because we do not relate on the result of the prodecessor to encrypt the successor ciphertext.

	On the other hand, the decryption cannot be done in parallel because each procedecessor block output is needed to decrypt the next one.

	\item If an error happened to  $C_2$ during  the transmission ( all other blocks are transmitted correctly ), which blocks of plaintext could not recovered at the receiver? Please explain.

	 Observing $Figure2$ if $C_2$ is corrupted, the error would get progated accross  the successor block chains because the outputs of the predecessors that were corrupted would are used the successors blocks. As a result, the error would keep propagation accross the chains.

	 \item If an error happened to $P_1$ before encryption, through how many blocks are of ciphertext is the error propagated? Which blocks of plaitext could not be recovered at the receiver? Please explain.

	 With the observation of the block chaining structure in $Figure3$, we could see that only $C_1$ and $C_2$ would be affected by the error.

	  Let perform a demonstration to understand the block that could be recovered:

	  $P_i = C_i  \oplus D_k(P_{ i - 1 })$ \\
	  $P_i = E_k(P_{i - 1}) \oplus P_i  \oplus D_k(P_{ i - 1 }) $ \\
	  $P'_1 = E_k(P_0)  \oplus P'_1 \oplus D_k(P_0)$ \\
	  $P'_1 = P'_1$

	  Now We could try to apply the same logic to another block. Let use $P'_2$:

	  $P_i = C_i  \oplus D_k(P_{ i - 1 })$ \\
	  $P_i = E_k(P_{i - 1}) \oplus P_i  \oplus D_k(P_{ i - 1 }) $ \\
	  $P'_2 = E_k(P'_1)  \oplus P_2 \oplus D_k(P'_1)$
	  \\
	  $P'_2 =  P_2$ \\

	  We could see that  $P_2$ could be recovered and $P_1$ is not going to be recovered.

	 \item  Is this a good block cipher operation mode in your opinion? Justify your answer.

	  This design could be usable because the error propagation can be reduced to certain
number of blocks. For instance, we have seen that an error from a encryption block can
only affect the block itself and its successor in chain instead of propagating in the entire
chain. Also, we have seen that with a set of corrupted plaintext. Some of the
plaintext could be recovered according the formula we have used. Therefore, this
chaining could be used data transmission because in case an error happened during
the transmission, the likelihood of recovering the original information could be possible
because of the features we have previously described.

\end{enumerate}

\section{ RSA Algorithm Analysis }

\begin{enumerate}
	\item Explain how does the decryption operation recover the plaintext?

	First, the RSA alogrithm is practical because of the  Eurler's Theorem:

	We have for any integer ( message ) relatively prime to n,

	$M^{\phi(n)} = 1 ( \mod n )$ \\

	We know that $\phi(n)$ is the Euler totient function: \\
	$\phi(n) =  \phi(p).\phi(q)$\\
	$= (p - 1)(q - 1)$\\
	$= n - ( p + q ) + 1$

	Since the private key $d$ is relatively prime to $\phi(n)$, it would have a multiplicative  inverse public key $e$ of the modulo of $\phi(n)$: \\

	$e.d = 1 ( \mod \phi(n))$ \\

	If $e$ and $d$ are correctly choosen we could have the following equation: \\
	$D(E(M)) \equiv (E(M))^d \equiv (M^e)^d ( \mod n )  = M^{e.d} ( \mod n )$

	and also

	$M^{e.d} \equiv M^{k.\phi(n) + 1 } \mod n $ \\

	From the above equation we could write the following equation:

	$( M^{\phi(n)} \mod n )^k . M \mod n$ \\

	We know that  $( M^{\phi(n)} )^k = 1 $ according to the Euler theorem. Therefore we could write: \\

	$M \mod n = M $  for all $M$, $ 0 \leq M  < n$ . \\

	 Why value of the plaintext $M$ must be less $n$?

	 The value of $M$ must be less than $n$ because of the following reason: \\

	 Let suppose that one of the primes, for instance $q$ divides $M$. Therefore,	$M \equiv 0 (  \mod q ) $ and we have $ 0 \equiv M^{1 + k\phi(n)} \equiv m ( \mod q )$. \\
	 As a result, $q$ could divide $M$, but $p$ cannot divide $M$ since $n = pq$ so that we could have  $gcd(M, p) = 1$. As a result, $M < n$ to maintain these properties.

	\item Suppose that A is quite longer than n ( for example, n is about $400$ digits long, but M is  $5,000$  digit long). Please propose a scheme to encrypt $M$ so that $B$ could recover M using B's private key.

	Let $e_B$ and $d_B$ be B's public and private keys respectively. We would use the following illustration for the encryption and decryption of  $M$ \\
	$M^{e_B} \mod n = C $ \\

	To decrypt $C$, we would have to discover the private of $B$ with the following equation. \\

	$e_B.d_B = \phi(n)k + 1$  \\
	$d_B = \frac{\phi(n)k + 1 }{ e_B }$ \\
	$M = C^{\frac{\phi(n)k + 1 }{e_B}}  \mod n $ \\
	$M = C^{d_B} \mod  n$

	Since in this case, $M > n$  it could be infeasible to recover $M$.

\end{enumerate}

\section{ Short answer questions }

	\begin{enumerate}
		\item Please  list the main causes of cloud security problems.
			\begin{enumerate}
				The following are the causes of cloud security problems.

				\item Loss of control
				\item Lack of trust ( mechanisms )
				\item Multi-tenancy
			\end{enumerate}

			\item If $A$ is to send a confidential message to $B$ using public cryptography, what kind of key $A$ use?

			In this situation, $A$ should use the public of $B$.

			\item If $A$ is to send a piece of message to $B$ so that $B$ can autenticate that this  message is  from $A$, what kind of key should $A$ use? \\

			In this situation, the private key $A$ would be used.

			\item What is avalanche effect in a cipher? Is this a good property or not? Please explain your answer. \\

			The avalanche effect is desirable property of encryption algorithm where a change of $one$ input or key bit results in changing $half$ output bits.
			We believe that it is good property because it would a change made in the plaintext or ciphertext cannot  deduce by the cryptanalyst because the ouput would be extremely different.

			\item Why are modern ciphers designed as product ciphers instead of pure substitution ciphers?

			Modern ciphers are designed as product ciphers to be more resistant to exhaustive-search attack because it is the combinaison of different components such as diffusion and confusion. Also, modern ciphers are made of different combinations such as transposition units ( P-boxes ) and substitution units ( S-boxes ) to give more security. For instance, the S-box is designed to be  resistant to known cryptanalytic attack because the Rijndael developers sought a design that has a low correlation between input bits and outputs bits, and the  property that the output cannot be described as a simple mathematical function of the input

	\end{enumerate}

\section{Reference}

Ronald L. Rivest, Adi Shamir, and Leonard M. Adleman, A method for obtaining digital signatures and public key signatures, Communications of the ACM, Vol. 21, No. 2, Feb. 1978; or reprinted in Secure Communications and Assymmetric Cryptosystems, AAAS Selected Synposium 69, Westview Press, Boulder, CO, 1982

\end{document}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{ifsym}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{cleveref}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\usetikzlibrary{trees}
\title{Query Optimization Exercise 8}

\usepackage{amssymb}
\def\roj{\mathbin{\bowtie\mkern-5.8mu\ojoin}}
\usepackage[bottom]{footmisc}

\date{January 2021}

\begin{document}

\maketitle

\section{Exercise 1}
We begin by listing the possible options for ordering with descending ordering Benefit (omitting any orderings with benefit smaller than 1).
\begin{center}
\begin{tabular}{c|c}
Relation & ordering Benefit \\ \hline
$(R_3 \bowtie R_0, R_3 \bowtie R_2)$ & 2 \\
$(R_1 \bowtie R_4, R_1 \bowtie R_0)$ & $\frac{500}{251} \approx 1.992$ \\
$(R_1 \bowtie R_2, R_1 \bowtie R_0)$ & $\frac{5}{3} \approx 1.667$ \\
$(R_0 \bowtie R_3, R_0 \bowtie R_1)$ & $\frac{150}{101} \approx 1.485$ \\
$(R_2 \bowtie R_3, R_2 \bowtie R_1)$ & $\frac{5}{4} = 1.25$ \\
$(R_1 \bowtie R_4, R_1 \bowtie R_2)$ & $\frac{300}{251} \approx 1.195$
\end{tabular}
\end{center}

\begin{tikzpicture}
    \node (L0) {$R_0$};
    \node (L1) [right=of L0] {$R_1$};
    \node (L4) [right=of L1] {$R_4$};
    \node (L3) [below=of L0] {$R_3$};
    \node (L2) [below=of L1] {$R_2$};
    \draw
        (L0) edge (L1)
        (L1) edge (L4)
        (L0) edge (L3)
        (L2) edge (L3)
        (L1) edge (L2);
\end{tikzpicture}

\subsection{Step 1}
\begin{center}

\begin{tikzpicture}
    \node (L0) {$R_0$};
    \node (L1) [right=of L0] {$R_1$};
    \node (L4) [right=of L1] {$R_4$};
    \node (L3) [below=of L0] {$R_3$};
    \node (L2) [below=of L1] {$R_2$};
    \draw
        ($(L0)!0.5!(L3)$) edge (L2) edge (L3) edge (L0)
        (L1) edge (L4)
        (L2) edge (L3)
        (L0) edge (L1)
        (L1) edge (L2);
\end{tikzpicture}
\end{center}
Update of ordering Benefit:
\begin{center}
\begin{tabular}{c|c}
Relation & ordering Benefit \\ \hline
$((R_3 \bowtie R_2) \bowtie R_0, R_0 \bowtie R_1 )$ & $\frac{25}{11}\approx 2.27$ \\
$(R_1 \bowtie R_4, R_1 \bowtie R_0)$ & $\frac{500}{251} \approx 1.992$ \\
$(R_1 \bowtie R_2, R_1 \bowtie R_0)$ & $\frac{5}{3} \approx 1.667$ \\
$(R_0 \bowtie R_3, R_0 \bowtie R_1)$ & $\frac{150}{101} \approx 1.485$ \\
$(R_2 \bowtie R_3, R_2 \bowtie R_1)$ & $\frac{5}{4} = 1.25$ \\
$(R_1 \bowtie R_4, R_1 \bowtie R_2)$ & $\frac{300}{251} \approx 1.195$
\end{tabular}
\end{center}
\subsection{Step 2}

\begin{center}

\begin{tikzpicture}
    \node (L0) {$R_0$};
    \node (L1) [right=of L0] {$R_1$};
    \node (L4) [right=of L1] {$R_4$};
    \node (L3) [below=of L0] {$R_3$};
    \node (L2) [below=of L1] {$R_2$};
    \draw
        % ($(L0)!0.5!(L3)$) edge (L2) edge (L3) edge (L0)
        ($(L0)!0.6!(L3)$) edge (L0) edge (L2) edge (L3) edge (L1)
        (L3) edge (L0)
        (L1) edge (L4)
        (L0) edge (L3)
        (L0) edge (L1)
        (L1) edge (L2)
        (L3) edge (L2);

\end{tikzpicture}
\end{center}
\section{Exercise 2}
We assume for this exercise that the right outer join has the same properties regarding associativity as the left outer join.

\begin{center}
\begin{tikzpicture}[level distance=1.5cm,
  level 1/.style={sibling distance=3cm},
  level 2/.style={sibling distance=3cm},
  level 3/.style={sibling distance=3cm},
  level 4/.style={sibling distance=1.5cm}]
  node {$\bowtie_{A.x=B.y}$}
    child {node {$A$}}
    child {node {$\bowtie_{B.x=C.y}$} %first right
      child {node {$B$}} %second left
      child {node {$\bowtie_{-}^{\_\_C.x=E.y}$} %second right
        child{ node{$\bowtie_{C.y=D.x}$} %third left
          child{node {$C$}}%forth left
          child{node {$D$}}%forth right
        }
        child{ node{ {$\bowtie_{E.x = F.y}$}} %third right
          child{node {$E$}}%forth left
          child{node {$F$}}%forth right
            }
      }
    }
\end{tikzpicture}
\end{center}
\begin{center}
\begin{tabular}{c|c}
SES & TES \\ \hline
$\{A,B\}$ & $\{A,B\}$\\
$\{B,C\}$ & $\{B,C,D,E\}$\\
$\{C,E\}$ & $\{C,D,E\}$\\
$\{C,D\}, \{E,F\}$ & $\{C,D\}, \{E,F\}$\\
\end{tabular}
\end{center}

\begin{center}

\begin{tikzpicture}
    \node (LC) {$C$};
    \node (LE) [right=of LC] {$E$};
    \node (LF) [right=of LE] {$F$};
    \node (LD) [below=of LC] {$D$};
    \node (LB) [below=of LE] {$B$};
    \node (LA) [right=of LB] {$A$};
    \draw
        % ($(L2)!0.5!(L3)$) edge (L2) edge (L3) edge (L0)
        ($(L0)!0.6!(L2)$) edge[gray] (L0) edge[gray] (L2) edge[gray] (L3) edge[gray] (L1)
        ($(LC)!0.6!(LE)$) edge (LC) edge (LE) edge (LD)
        (L3) edge (L0)
        (L1) edge (L4)
        (L0) edge (L3)
        (L0) edge (L1)
        % (L3) edge (L2)
        (LB) edge (LA);
\end{tikzpicture}
\end{center}

\end{document}


%!TEX root = ../notes.tex
\section{March 7, 2022}
\subsection{Pollard's \texorpdfstring{$p-1$}{p-1} Method}
\recall the Pollard's $p-1$ method from last time. Let
\[N = p\cdot q\]
\[\begin{array}{c}
        p-1\mid n! \\
        q-1\nmid n!
    \end{array}\rightarrow \gcd(N, a^{n!}-1) = p\]

\begin{lstlisting}[language=Python]
from pollard import *

def factor(N):
    # Naive, brute force factoring algorithm.
    i = 2
    while N % i != 0:
        i += 1
    return i

def factor(N, a=2):
    # Pollard's method
    i = 1
    while gcd(a - 1, N) == 1:
        i += 1
        a = pow_mod(a, i, N)
    return gcd(a - 1, N)
\end{lstlisting}

This algorithm is \emph{significantly} faster than random guesses. By how much? We can formalize this intuition of size of prime factors:
\begin{definition}
    We say $n$ is \ul{$B$-smooth} if all prime factors are $\leq B$. We define
    \[\Psi(X, B) = \text{\# of $B$-smooth $n\leq X$}.\]
\end{definition}
\begin{theorem}
    Let $X, B$ increase together. Suppose \[(\log X)^\varepsilon \leq \log B \leq (\log X)^{1-\varepsilon}\]
    Then
    \[\frac{\Psi(X, B)}{X} = u^{-u\cdot (1+o(1))}\quad\text{where }u = \frac{\log X}{\log B}.\]
\end{theorem}
\ul{What is $o(1)$?}
\begin{definition}
    Say $f(x) = o(g(x))$ if
    \[\lim_{x\to\infty}\frac{f(x)}{g(x)} = 0\]
\end{definition}
So ``$o(1)$'' is to mean something whose limit is $0$. This is in contrast to $O(1)$ which means something whose limit is finite.

For our purposes, we say that the probability $X$ is $B$-smooth is $\approx u^{-u}$ where $u = \frac{\log X}{\log B}$.

What if we do Pollard $p-1$ for $e^{\sqrt{\log p}}$ steps? The probability of success is then \[\sqrt{\log p}^{-\sqrt{\log p}}\approx e^{-\frac{1}{2}\log\log p\cdot \sqrt{\log p}} \gg p^{-\varepsilon}\]

By brute force, doing $p^\varepsilon$ steps gives a probability of success $\approx p^{\varepsilon - 1}$.

\subsection{Quadratic Sieve}
\textbf{Goal:} find $a, b$ with $a^2\equiv b^2\pmod{N = pq}$, hence $(a-b)(a+b)\equiv 0\mod N$. $\gcd(a+b, N)$ will allow us to recover $p$ or $q$ with decent probability.

\begin{example}\label{example:quadratic-sieve}
    For example, if
    \begin{align*}
        (\lfloor\sqrt{N}\rfloor + 1)^2 & \equiv (\lfloor\sqrt{N}\rfloor + 1)^2 - N
        = 2^1\cdot 3^1                                                             \\
        (\lfloor\sqrt{N}\rfloor + 2)^2 & \equiv (\lfloor\sqrt{N}\rfloor + 2)^2 - N
        = (\text{not smooth})                                                      \\
        (\lfloor\sqrt{N}\rfloor + 3)^2 & \equiv (\lfloor\sqrt{N}\rfloor + 3)^2 - N
        = 2^2\cdot 3^1                                                             \\
        (\lfloor\sqrt{N}\rfloor + 4)^2 & \equiv (\lfloor\sqrt{N}\rfloor + 4)^2 - N
        = 2^1\cdot 3^2                                                             \\
                                       & \vdots
    \end{align*}
    then we have
    \[\left[(\lfloor\sqrt{N}\rfloor + 1)^3\right]^2 \equiv \left[(\lfloor\sqrt{N}\rfloor + 3) (\lfloor\sqrt{N}\rfloor + 4)\right]^2\]
    Which comes from the fact that the exponent vectors
    \[\begin{bmatrix}1\\1\end{bmatrix}, \begin{bmatrix}2\\1\end{bmatrix}, \begin{bmatrix}1\\2\end{bmatrix}\]
    are linearly dependent. We can take these mod $2$ (the parity) since we square. We can also rewrite this as\footnote{Using the definition of linear dependence}
    \[\left[(\lfloor\sqrt{N}\rfloor + 1)(\lfloor\sqrt{N}\rfloor + 3) (\lfloor\sqrt{N}\rfloor + 4)\right]^2\equiv \left(2^2\cdot 3^2\right)^2\]
\end{example}
So we can do the following steps:
\begin{enumerate}
    \item Pick smoothness bound $B$.
    \item Find integers
          \[(\lfloor \sqrt{N}\rfloor + i)^2 - N\]
          that are $B$ smooth.
    \item Find linear relationship between exponent vectors. Then we get a congruence $a^2\equiv b^2\pmod N$ after which we can try to find factors of $N$.
\end{enumerate}


\documentclass{article}
\usepackage{fancyvrb}
\usepackage{amsmath}
\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
\usepackage{tikz}

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

% https://stackoverflow.com/questions/3175105/inserting-code-in-this-latex-document-with-indentation

\usepackage{listings}
\usepackage{color}
\definecolor{lightgray}{rgb}{.9,.9,.9}
\definecolor{darkgray}{rgb}{.4,.4,.4}
\definecolor{purple}{rgb}{0.65, 0.12, 0.82}

\lstdefinelanguage{JavaScript}{
  keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break},
  keywordstyle=\color{blue}\bfseries,
  ndkeywords={class, export, boolean, throw, implements, import, this},
  ndkeywordstyle=\color{darkgray}\bfseries,
  identifierstyle=\color{black},
  sensitive=false,
  comment=[l]{//},
  morecomment=[s]{/*}{*/},
  commentstyle=\color{purple}\ttfamily,
  stringstyle=\color{red}\ttfamily,
  morestring=[b]',
  morestring=[b]"
}

\lstset{
   frame=tb,
   aboveskip=3mm,
   belowskip=3mm,
   language=JavaScript,
   extendedchars=true,
   basicstyle=\footnotesize\ttfamily,
   showstringspaces=false,
   showspaces=false,
   numberstyle=\footnotesize,
   numbersep=9pt,
   tabsize=2,
   breaklines=true,
   showtabs=false,
   captionpos=b
}

\title{Sorting Olympics Running Time}
\date{2020\\ November}
\author{Jared Dyreson\\ California State University, Fullerton
\and Mason Godfrey, California State University, Fullerton
\and Brian Lucero, California State University, Fullerton}

\begin{document}
\maketitle
\tableofcontents
\newpage

\section{Big-O Analysis}

\subsection{Initial Setup}
This program starts off by randomly selecting an input from a list that was provided in the project description.
The input is then given to four separate instances of a specific sorting algorithm, which will process it.
There is then a main loop in which all the algorithms are allowed to do a pass and will signal if completed.

\subsubsection{Pore's Gold Sort}

This algorithm is similar to Bubble sort as is follows the same behavior where the biggest element "bubbles" to the end.
Pore's key distinction however, is that even and odd pairs are swapped if they satisfy the swapping condition.
Thus the Big-O running time is $O(n^2)$.

\subsubsection{Insertion Sort}

The basis of insertion is that once it encounters a swap candidate, it has to back track from right to left until it finds the final resting place of that element.
That being said, the most amount of movements until the swap would be the length of the container.
Here we can say that the Big-O running time is $O(n^2)$.

\subsubsection{Merge Sort}

Merge works by breaking up the container into multiple sub-containers and then sorting them recursively.
At the end, each of the sub-containers are stitched together, making one complete container.
This style of approach is called divide and conquer, and generally runs in $O(n * log(n))$.

\subsubsection{Quick Sort}

Lastly, quick sort is also in the same family of algorithms as merge sort.
A defining characteristic of this algorithm is it's use of pivot values and moving values less than itself to the left.
This creates inherit order and structure to each pass it does.
It too creates sub-containers but only through the use of ranges and does not allocate any extra memory for this.
Thus the running time for quick sort is $O(n * log(n))$.

\end{document}


\section{Guarded Command Language}

\begin{itemize}

	\item $ \Skip $ -- Empty Command

	\begin{itemize}

		\item $ wp(\Skip, Q) \equiv Q $

		\item Hence $ \hoare{Q}{\Skip}{Q} \equiv \true $ for any $ Q $

		\item $ \hoare{P}{\Skip}{Q} $ is false if and only if $ P $ is strictly weaker than $ Q $

	\end{itemize}

	\item $ \Abort $ -- Chaotic Command

	\begin{itemize}

		\item $ wp(\Abort, Q) \equiv \false $

		\item No precondition can guarantee a postcondition

		\item Represents `chaotic/undefined behaviour'

	\end{itemize}

	\item $ := $ -- Assignment

	\begin{itemize}

		\item $ wp(x := E, Q) \equiv Q[x \backslash E] $

		\item So $ \hoare{Q[x \backslash E]}{x := E}{Q} $ is $ \true $

		\item Generalises to multiple assignment: $ wp((x,y := E, F), Q) \equiv Q[x,y \backslash E,F] $

	\end{itemize}

	\item $ ; $ -- Composition/Concatenation

	\begin{itemize}

		\item $ wp(S_1; S_2, Q) \equiv wp(S_1, wp(S_2, Q)) $

		\item There exists some `middle' predicate true after $ S_1 $ and before $ S_2 $

		\item If $ \hoare{P}{S_1}{M} \land \hoare{M}{S_2}{Q} $ then $ \hoare{P}{S_1; S_2}{Q} $

	\end{itemize}

	\item $ \If $ -- Selection

	\begin{itemize}

		\item
		$ \If ~ G_1 \rightarrow S_1  $\\
		$ \Choice ~ G_2 \rightarrow S_2 $\\
		$ \dots $\\
		$ \Choice ~ G_n \rightarrow S_n $\\
		$ \Fi $

		\item Evaluate all guards $ G_1 \dots G_n$, choose a $ \true $ guard $ G_i $ nondeterministically, and execute $ S_i $

		\item if all guards evaluate to $ \false $ then $ \Abort $ is executed

		\item $ wp(\If, Q) \equiv \bigvee_{i=1}^{n} G_i \land \bigwedge_{i=1}^{n} (G_i \implies wp(S_i), Q)  $
		\item The disjunction of the guards \textit{must} be true

	\end{itemize}

	\item $ \Do $ -- Repetition

	\begin{itemize}

		\item
		$ \Do ~ G_1 \rightarrow S_1  $\\
		$ \Choice ~ G_2 \rightarrow S_2 $\\
		$ \dots $\\
		$ \Choice ~ G_n \rightarrow S_n $\\
		$ \Od $

		\item Evaluate all guards, choose a $ \true $ guard nondeterministically, execute $ S_i $ and repeat

		\item If all $ G_i $ are false, the loop ends and the program continues

		\item Weakest precondition rule is complex, so \textit{loop invariants} are used instead

		\item Predicate $ I $ is a loop invariant if $\hoare{I \land G_i}{S_i}{I} $ for all $ 1 \le i \le n $

		\item There are usually many possible invariants for a loop

	\end{itemize}

\end{itemize}