% Take from PyAudioAnalysis
% short-term, mid-term features

% \chapter{Algorithms}
% \section{Time Analysis}
% \subsection{Convolution}
% A general use of the convolution operation
% is to evaluate the outputs of linear
% time-invariant systems.
% Taking the impulse response of a system, and
% applying the convolution with
% a given input, gives the system's output
% for that specific input.

% For continuous time dependent arguments,
% \(x\) as the input variable, and \(h\) as the
% system's impulse response, the convolution is given by:

% \begin{equation}
%     (x * h)(t) \triangleq \int^{\infty}_{-\infty} x(t)h(t-\tau) d\tau
% \end{equation}

% Due to the commutativity property of the convolution
% operation, the shifting over one of the arguments
% is interchangeable, thus one can write
% the same equation as:

% \begin{equation}
%     (x * h)(t) \triangleq \int^{\infty}_{-\infty} x(t-\tau)h(t) d\tau
% \end{equation}

% Likewise, working with discrete variables,
% the convolution operation can be written as:
% \begin{align}
%     (x * h)[n] \triangleq & \sum^{\infty}_{m=-\infty} x[m]h[n-m] \\
%     (x * h)[n] \triangleq & \sum^{\infty}_{m=-\infty} x[n-m]h[m]
% \end{align}

% \subsection{Cross-Correlation}
% Cross-correlation is an operation that can measure
% how similar two functions are. By ``shifting''
% one function over the other and measuring the amount
% of correlation at each given point, the output graph
% demonstrates at what ``distance''
% the maximum similarity occurs,
% in correspondence
% to the graph's maximum amplitude.

% \begin{align}
%     (x * h)(t) \triangleq & \int^{\infty}_{-\infty} x^{*}(t)h(t+\tau) d\tau \\
%     (x * h)(t) \triangleq & \int^{\infty}_{-\infty} x^{*}(t-\tau)h(t) d\tau
% \end{align}

% \begin{align}
%     (x * h)[n] \triangleq & \sum^{\infty}_{m=-\infty} x^{*}[m]h[n+m] \\
%     (x * h)[n] \triangleq & \sum^{\infty}_{m=-\infty} x^{*}[n-m]h[m]
% \end{align}

% \subsection{Auto-Correlation}
% In a case where the two input functions
% of the cross-correlation are the same input signals,
% the measure is then called ``auto-correlation''.
% In other words, this measure demonstrates
% at what ``distance'' the delayed version of the signal
% most matches the original version of it.

% This kind of measure is very useful in audio
% applications where multi-microphones are spread
% with varying distance from each other and from the
% source. Looking for the maxima point of the
% auto-correlation between the signal received by
% the microphones, one can deduce the lag time
% that best characterizes the microphones' formation.

% Several enhancement and manipulation techniques
% are then become available when the lagging
% time is known.
% For example the delay and sum algorithm beamforming
% algorithm for constructive summation of the different
% channels that translates
% to better SNR (signal-to-noise ratio).

% \subsubsection{Covariance Matrices}
% \begin{equation}
%     \mathbf{R}_{XY} \triangleq \mathbf{E}[XY^{tr}]
% \end{equation}

% \begin{align}
%     \mathbf{R}_{XX} & \triangleq \mathbf{E}[XX^{tr}] \\
%                     & = \frac{1}{T} \sum^{T-1}_{t=0}
%     {X}(t;j\omega){X}^{\mathbf{H}}(t;j\omega)
% \end{align}

% Where the \(\mathbb{H}\) operator
% is the \emph{Hermitian function} which stands for
% the complex conjugate.

% % ESPNet \& Mirco Document
% \subsection{Sinc-Conv}

% % \begin{figure}[ht]
% %     \centering
% %     \includegraphics[width=0.99\textwidth]
% %     {./img/Comparison_convolution_correlation.svg}\label{fig:conv_vs_corr_plot}
% %     \caption{Convolution vs. Cross-Correlation vs. Auto-Correlation plot [Wikipedia]}
% % \end{figure}

% \section{Frequency Analysis}
% \subsection{DTFT}
% \begin{equation}
%     X_{2\pi}(\omega) = \sum_{n=-\infty}^{\infty} x[n] \,e^{-i \omega n}
% \end{equation}

% \subsection{IDTFT}
% \begin{equation}
%     x[n] = \frac{1}{2 \pi}\int_{2\pi} X_{2\pi}(\omega)\cdot e^{i \omega n} d\omega
% \end{equation}

% \subsection{DFT}
% \begin{equation}
%     \label{eq:dft}
%     X_k = \sum_{n=0}^{N-1} x_n \cdot e^{-\frac {i 2\pi}{N}kn}
% \end{equation}

% Taking Euler's identity:
% \begin{equation}
%     e^{ix} = \cos x + j\sin x
% \end{equation}

% Substituting the exponent power in Equation\;\ref{eq:dft} with the Euler identity
% gives:
% \begin{equation}
%     X_k = \sum_{n=0}^{N-1} x_n \cdot \left[\cos\left(\frac{2 \pi}{N}kn\right)
%         - i \cdot \sin\left(\frac{2 \pi}{N}kn\right)\right]
% \end{equation}

% \subsection{IDFT}
% \begin{equation}
%     x[n] = \frac{1}{N} \sum_{k=0}^{N-1} X_k\cdot e^{i \frac{2 \pi}{N} k n}
% \end{equation}

% \subsection{FFT --- Fast Fourier Transform}

% \subsection{Discrete Cosine Transform (DCT)}

% \begin{equation}
%     y[n] = \sum^{}_{}
% \end{equation}

% \section{Time-Frequency Analysis}
% \subsection{STFT - Short Time Fourier Transfer}

% \subsection{Spectrogram}

% \section{Windows}
% \subsection{Overview}

% \subsection{Rect (boxcar)}
% \subsection{Triangle}
% \subsection{Bartlett}
% \subsection{Hamming}
% \subsection{Hann}
% \begin{align}
%     w[n] = 0.5 - 0.5\cos\left( \frac{ 2\pi n }{ M - 1 } \right) & \qquad 0 \leq n \leq M-1
% \end{align}

% % \subsection{Kaiser}
% % \subsection{Analog Filters}

% \subsection{Overlap + Add Reconstruction}
% % \subsection{Wavelets}

% \section{Speech-Enhancement}
% See table
% \begin{figure}[ht]
%     \centering
%     \includegraphics[width=0.99\textwidth]
%     {./img/spc_enhance_tbl}\label{fig:asr_blocks_diagram}
%     \caption{General E2E ASR System Blocks Diagram}
% \end{figure}

% DCT + MFCC Connection
% DST - Discrete Sine Transforms
% Hilbert Transform
% Analytical Signal
% Wavelates
% Convolution / Correlation
% Parseval's Theorm
% PSD
% Median Filter
% ORder Filter
% Wiener Filter
% Hermitian FFTs

\chapter{Features}\label{ch:features}
\section{Introduction}
In data analysis craftsmanship,
prominence importance exists
about how to characterize the data so that
variations in data characteristics would
be noticeable and more
easily discernible during the analysis process.
To that end, the input data being analyzed is reorganized
according to selected features on which
conclusions and distinctive deductions can be made.

Similarly, in a supervised learning
procedure of a machine,
in order to make classification decisions accurately.
The need for such features arises to
aid the learning algorithm in focusing on the
same features that probably were selected manually.
An intelligent choice of the learnable features
\cite{7845025}
can drastically change a given model's outcomes quality.
In a supervised learning, the
feature selection and extraction process withal,
are preparatory steps to the learning or classification
stages coming next.
As a rule of thumb, the more features, the better accuracy
a learning model can yield theoretically\cite{lessIsMore}.
That saying holds true to a great degree
as long as often sudden fluctuations do not characterize the data.
In a case of heavy fluctuating characterizations of the data,
or alternatively, in the case of a
massive number of features,
that some of which have minor contributions
to the classification part of the output,
increase in the number of features may become deteriorative.
In terms of performance,
enlarging the number of features leads to a bigger model,
an increased number of learnable parameters,
longer training times,
and unnecessary extension of processing times.
Also, a possible reduction in the accuracy is
expected due to
False-Negative (FN) or False-Positive (FP)
misdetections resulting from the wrong
classification of signals as noise and
vice versa caused by additional redundant features.

For speech signals, a wide variety of
meaningful feature sets exist.
More or less useful, different speech features
may better fit certain use-cases or fulfill
a particular unerring task.
Features for speech (including audio)
are mainly from the following domains:
\begin{enumerate}
    \item Spectral Features
    \item Cepstral Features
    \item Time domain Features
    \item Spatial Features
\end{enumerate}

Speech features are selected
to give the maximal accuracy in detecting utterances.
That means a precise characterization of a
word, utterance, or the pronunciation of
a single character, making them distinguishable
from other input streams.

\section{Spectral Features}
\subsection{FB --- FilterBanks}
FilterBanks is a very common technique
for spectral mapping of speech signals.
By dividing the audio spectrum into multiple
sub-domains with a defined level of overlap,
the spectrum is
``framed'' according to frequency.
Thus, by a set of band-pass filters,
each frame contains the confined
information of the speech signal
that corresponds to the filter's specific
range of frequencies.

The resolution can then be set as a function of
the number of filters and the overall processed audio bandwidth.
Increasing the number of filters, assuming the
audio bandwidth and the overlap ratio are constant, means
narrower allocated bandwidths for each individual filter
or in other better spectral resolution.

Filterbanks by themselves are not the desired speech feature,
but only the mean for feature extraction.
The most common feature extracted by a Filterbank set
is the total sum of energy bounded by the filter's frequency response.
A set of filters is computed per
frequency bin and remains the same for
the entire signal length over time.
Thus, the total sum of energy computed for
each filter characterizes the
speech over a finite defined duration of time.

The human hearing system is less sensitive to high frequencies
than lower band frequencies, as described in Chapter\;\ref{ch:scaling_methods}.
Therefore, in an attempt to emulate the same natural behavior and
resemble the hearing ``filters'' as much as possible,
the Filterbank set of filters is set with center frequencies
according to the different scaling
methods described in Chapter\;\ref{ch:scaling_methods}.
In that way, narrow-band filters are assigned to
lower frequency ranges.
Similarly, wide-band filters are for
the higher hearable frequency ranges.

\subsubsection{Mel FB}
One way of mapping the audio spectrum is according to the Mel
scale. This scaling method is described in Chapter\;\ref{ch:scaling_methods}.
First, the center frequencies and the bandwidths are received by the transformation
between Herz to Mels. Then a set of Bartlett
filters with those center frequencies are generated
with an overlap of 50\% between adjacent filters.

The amplitude of the filters is bounded to \(1\)
to maintain NOLA compatibility.
An example of a Mel Filterbank constructed by Bartlett filters
is shown in Figure~\ref{fig:sb_mel_fb}.
\begin{figure}[H]
    \centering
    \includegraphics[width=0.75\linewidth]{Features/images/sb_mel_fb}
    \caption{Mel FB}\label{fig:sb_mel_fb}
\end{figure}

\subsubsection{Bark FB}
The Bark Filterbank is very similar to the Mel Filterbank
except that it follows the Bark scale
instead of the Mel Scale.

Different filter shapes are available but,
triangular filter shapes are the most common,
as described in \cite{barkfilt}.

An example of the Bark Filterbank constructed by Bartlett filters
is shown in Figure~\ref{fig:mat_bark_fb}.
\begin{figure}[H]
    \centering
    \includegraphics[width=0.75\linewidth]{Features/images/mat_bark_fb}
    \caption{Bark FB}\label{fig:mat_bark_fb}
\end{figure}

\subsubsection{Gammatone FB}
The Gammatone filter, as described in \cite{gammatonefilt},
has a response function as follows:
\begin{equation}
    g(t) = \alpha t^{n-1}e^{-2\pi bt}\cos \left( 2\pi f_{c} t + \phi\right)
\end{equation}

Where \(\alpha\) denotes the amplitude factor,
\(n\) is the filter order,
\(f_{c}\) is the center frequency,
\(\phi\) is the phase factor,
and \(b\) is the bandwidth parameter
computed according
to the ERB scale mapping of \(1.019\cdot ERB \left( f_{c} \right)\).

An example of a Gammatone Filterbank
is shown in Figure~\ref{fig:sb_fb_gauss}.
\begin{figure}[H]
    \centering
    \includegraphics[width=0.75\linewidth]{Features/images/sb_fb_gauss}
    \caption{Gammatone FB}\label{fig:sb_fb_gauss}
\end{figure}

\section{Cepstral Features}
\subsection{MFCCs --- Mel-Frequency Cepstral Coefficients}

% https://link.springer.com/content/pdf/bbm%3A978-3-319-03116-3/1.pdf
\subsubsection{Pre-emphasis}
Speech signals have a roll-off frequency
resembling a low-pass behavior\cite{237532}.
Due to that physical nature, higher frequencies
decay faster than lower speech frequencies.
Compensation for this phenomenon is attainable with a
pre-emphasis filter that boosts
the higher\cite{7489370} frequencies responses.

\subsubsection{Framing}
Speech signals vary in time.
Although the variation over time is relatively slow,
a speech signal is a non-pure stationary process
but a quasi-stationary.
Therefore, analysis of speech signals
is taken on small portions of the
signal to be less affected by randomness effects.
To that end, a preliminary framing action is applied
to to speech signals in the time domain.
Framing means dividing the signal
into small fragments(frames) with some overlapping in between.
Each time frame is assumed to be stationary,
and thus a measurement can be taken.

The shifting in time between frames is referred
to as the hopping length and is set to contain
a sufficient amount of temporal
context that characterizes the natural
characteristics of speech.

A very common sampling frequency of audio signals
is \(16KHz\).
As a result, and in order to work with
a round number of sampling points,
the frame lengths
and the hopping lengths
are set to \(25ms\), and
\(6.25ms\) or \(10ms\) for hopping size.
These values translate to a frame length
equals 400 sampling points, and hopping size
equals 100 or 160 sampling points, respectively.
Another advantage of setting the hopping length
as \(6.25ms\) is that it gives
a complete temporal context of 3 adjacent frames
by definition.

\subsubsection{Windowing}
In order to extract each frame only
whilst also minimizing the Gibbs effects as much as possible,
a windowing function is applied.
As a result, the information confined
in a given frame is extracted while the
window's response function tapers
the edges to reduce the adjacent frames' effect.

Usually, a Hamming or a Hann window
is used as the window function due to their
relatively decent trade-off between edge tapering,
implementation simplicity, bandwidth, and spectral leakage,
making them exceptionally suitable for speech signals.

The Hamming and Hann windows are given by
Equations\;\ref{eq:hammwin} and \ref{eq:hannwin}, respectively.
\begin{align}
    \label{eq:hammwin} &W_{_{Hamming}}[n] = 0.54 - 0.46
    \cos\left( \frac{2\pi n}{M-1} \right) &
            0 \leq n \leq M - 1 \\
    \label{eq:hannwin} &W_{_{Hann}}[n] = 0.5 - 0.5
            \cos\left( \frac{2\pi n}{M-1} \right) &
            0 \leq n \leq M - 1
\end{align}

\subsubsection{DFT spectrum}
Each one of the windowed frames is
converted to the frequency domain by applying the
Discrete Fourier Transform (DFT).
The composition of both windowed framing
and the DFT is referred to as the
Short-Time Fourier Transform (STFT).
A technique to visualize the STFT outcome is
called a spectrogram. The STFT outcome contains
multiple frequency bins per time frame,
making it a function of \(f, t\).

The DFT is given by:
\begin{align}
    X_{m}(f) = \sum_{n=-\infty}^{\infty} x[n]g[n-mR]e^{-j2\pi fn}
\end{align}

Where \(X_{m}(f)\) denotes the DFT transformation of
a given time frame windows signal,
\(g[\circ]\) denotes the window function of size \(M\),
and \(R\) represents the hopping size.

\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{Features/images/iscola_stft}
    \caption{STFT demonstration diagram}\label{fig:iscola_stft}
    \source{Adapted from Matlab's STFT documentation}
\end{figure}

\subsubsection{Mel-spectrum}
Once the spectrogram is received,
the frequencies are rescaled in accordance with the Mel Scale.
A comprehensive description of the Mel Scale
is detailed in Chapter\;\ref{ch:scaling_methods}.

Next, the cepstral coefficients are extracted from each frequency bin,
by taking the energies sum of each filter and multiplying it
with the Discrete Cosine Transform (DCT).
\begin{align}\label{eq:mfcc}
    MFCC[n] & = \sqrt{\frac{2}{K}} \sum_{k=1}^{K} \left\{
        e[k] \cdot DCT\left( k \right)
     \right\} \nonumber \\
     & = \sqrt{\frac{2}{K}} \sum_{k=1}^{K} \left\{
        e[k] \cdot \cos \left( \frac{\pi n}{K} (k+0.5) \right)
     \right\}
\end{align}

It is very common to extract the log-Mel energies
and then have Equation\;\ref{eq:mfcc} written as:
\begin{align}\label{eq:logmfcc}
    MFCC[n] & = \sqrt{\frac{2}{K}} \sum_{k=1}^{K} \left\{
        \log \left( e[k] \right) \cdot \cos \left( \frac{\pi n}{K} (k+0.5) \right)
     \right\}
\end{align}

% Take from PyAudioAnalysis
% PyAudioProcessing

\subsection{RFCCs --- Root-Frequency Cepstral Coefficients}
An alternative to the log-Mel
extraction of the cepstral coefficients
has been suggested in \cite{rmfcc1} and \cite{1415167}.
The motivation to put this proposed
technique under test is that the root
function can be less computationally demanding
than the traditional log function..
\begin{align}
    RCC[n] & = \sqrt{\frac{2}{N}} \sum_{k=1}^{K} \left\{
        \left( e[k] \right)^{\gamma} \cdot \cos \left( \frac{\pi n}{K} (k+0.5) \right)
     \right\}
\end{align}

\subsection{GFCCs --- Gammatone-Frequency Cepstral Coefficients}
GFCCs follow the basic steps same as the MFCCs extraction.
But, instead of translating the frequencies to Mels,
the spectrum is translated to the ERB scale.
ERB scale implies a Gammatone Filterbank as described in Chapter \ref{ch:scaling_methods}.

\subsection{BFCCs --- Bark-Frequency Cepstral Coefficients}
Like the Gammatone-FCCs (GFCCs), the BFCCs follow the Bark Scale.

% \subsection{LFCCs --- Linear-Frequency Cepstral Coefficients}
% \subsection{LPC --- Linear Predictive Coefficients}
% \subsection{MSRCC --- Magnitude-based Spectral Root Cepstral Coefficients}
% \subsection{NGCC --- Normalized Gammachirp Cepstral Coefficients}
% \subsection{PNCC --- Mel-Frequency Cepstral Coefficients}
% \subsection{PSRCC --- Mel-Frequency Cepstral Coefficients}
% \subsection{RPLP --- Mel-Frequency Cepstral Coefficients}
% https://spafe.readthedocs.io/en/latest/features/_features.html
% \subsection{articulatory cepstral coefficients}

\section{Time-Domain Features}
\subsection{Dynamic FCC features}
During the framing process, the speech signal
is divided into small fragments of the speech over time.
These time unit fragments are called frames.
Each frame spans over a finite time duration.
The extracted cepstral coefficients are computed statically
for a given frame. However, the original speech
is framed in multiple numbers of frames.
Therefore, coefficients extractions
have to be dynamic for the entire signal, i.e., all frames.

Additional information about the temporal
changes between adjacent coefficients can also be extracted
to include the dynamics and transitions within a frame.

\subsubsection{Deltas}
The first derivate of the cepstral coefficients
,\(\Delta\) (Deltas),
represents the velocity of the MFCCs' dynamics and
is a sub-set of the cepstral coefficients.

Deltas (\(\Delta\)) are extracted by:
\begin{equation}\label{eq:deltaderiv}
    \Delta [n] = \frac{ \sum\limits_{i=-T}^{T} k_{i} c_{m}[n+i]}
    {\sum\limits_{i=-T}^{T} |i|}
\end{equation}

Where \(n\) denotes the frame time index, \(k\) marks the
coefficient weight, \(T\) stands for the number of temporally
adjacent frames used for the calculation, and \(c_{m}\) denotes the
\(m\)th coefficient in the given frame \(n\).

\subsubsection{Delta-Deltas}
Delta-Deltas (\(\Delta\Delta\)) is an extra layer of information
representing the acceleration at which the
MFCCs' dynamics change within a given time frame.
The extraction of the Delta-Deltas follows the same principale
as the first derivatives. Yet, instead of taking the
cepstral coefficients as the input feature, we replace
\(c_{m}\) in Equation\;\ref{eq:deltaderiv}
with the first-order derivatives \(\Delta[n]\).

\subsection{Temporal Context}
Temporal context is an attachment of raw unprocessed
features' data from adjacent
frames together with the currently selected feature.
Whether spectral, cepstral, or spatial features,
the concatenation of past and future
features can infer decisions based on a memory effect.
Furthermore, different languages
introduce contextual constraints such as relative positions
of adjectives or nouns to verbs, plurals, affiliations,
possessions, and other lingual principles.

Usually, the number of adjacent past and future frames
to concatenate is based on the framing and DFT parameters.
It is plain to understand
one would not want to exaggerate and excessively use
redundant frames that do not have any significant impact
on the accuracy of detection.
The downside of overly using temporal context frames is obvious,
orders of magnitude larger amounts of information to process.

% \section{Spatial Features}
% \subsection{VTLN - vocal track length norm}


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{October 27, 2014}
\maketitle
if $G$ is a group, and $A\subseteq G$ and $B\subseteq G$ then $AB=\{ab|a\in A, b\in B\}\subseteq G$.

\section*{proposition}

let $G$ be a group, then $H,K$ subgroups of $G$. Assume that $h^{-1}kh\in K$ for all $h\in H$, $k\in K$ then $HK$ is a subgroup of $G$ that contain s both $H$ and $K$, in fact, $HK$ is the smallest subgroup of $G$ that contains both $H$ and $K$. Assumption only important if we are not dealing with abelian groups.

\subsubsection*{proof}
$a,b\in HK$. Write $a=h_1k_1,b=h_2k_2$ with $h_i\in H,k_i\in K$ then $a\cdot b=h_1k_1h_2k_2=h_1h_2(h_2^{-1}k_1h_2)k_2\in HK$

$a=hk, a^{-1}=(hk)^{-1}=k^{-1}h^{-1}=h^{-1}(hk^{-1}h^{-1})\in HK$

\subsection*{examples}
$S_3, H=\{(1),(12)\}, K=\{(1),(123),(132)\}, (12)(123)=(23)\in HK, (12)(132)=(13)\in HK$ so $HK=G$ and is therefore contained by G

$(\mathbb{Z},+)$, $H=a\mathbb{Z}, k=b\mathbb{Z}$, let $d=(a,b)$

claim: $a\mathbb{Z}+b\mathbb{Z}=d\mathbb{Z}$. clearly $a\mathbb{Z}\subseteq d\mathbb{Z}$, $b\mathbb{Z}\subseteq d\mathbb{Z}$.

$a\mathbb{Z}+b\mathbb{Z}$ is the smallest subgroup that contains both $a\mathbb{Z}$ and $b\mathbb{Z}$. so $a\mathbb{Z}+b\mathbb{Z}\subseteq d\mathbb{Z}$.

$d=\gcd(a,b)$ so we can write $d=ma+nb$. let $\alpha\in d\mathbb{Z}$ and write $\alpha=dt, t\in \mathbb{Z}$ then $\alpha=dt=mat+nbt\in a\mathbb{Z}+b\mathbb{Z}$. so $d\mathbb{Z}\subseteq a\mathbb{Z}+b\mathbb{Z}$
\section*{thm subgroup gen by a subset}
$G$ is a group, if $a\in G$ $<a>=\{a^i|i\in \mathbb{Z}\}$ is the smallest subgroupthat contains $a$.

\subsubsection*{proof}
let $S\subseteq G$, let $<S>=\{\underbrace{a_1a_2\dots a_k}_{\text{word}}|a_i\in S\text{ or }{a_i}^{-1}\in S, k\in \mathbb{N}\}$ then $<S>$ is a subgroup, $<S>=\cap \forall H$ where $S\subseteq H\subseteq G$, and $H$ is a subgroup of $G$, $<S>$ is the smallest subgroup of $G$that contains $S$.

so it is closed under multiplication, identity is in it, and the inverse of all words are in it.

show containment both ways, one is clear because we have words of length 1 that span $S$ and so $S$ is one of the elements of our $H$ intersection.

\section*{example}
$a,b\in G, S=\{a,b\}\subseteq G, <S>=\{a_1a_2\dots a_k|a_i\in\{a,a^{-1},b,b^{-1}\}\}$

if $ab=ba$ then $<S>=\{a^{i}b^{j}|i\in \mathbb{Z}, j\in \mathbb{Z}\}$

\section*{maps}
studied groups, subgroups. now we are going to talk about maps

if we have groups $G_1,G_2$ and $\varphi:G_1\to G_2$ is a group homomorphism provided $x\to\varphi(x), y\to\varphi$ means that $\varphi(x*y)=\varphi(x)*\varphi(y)$ for all $x,y\in G_1$.
\section*{examples}
identity: $x\to x$

$(\mathbb{R},+)=G_1, (\mathbb{R}^+,\cdot)=G_2$. $\varphi(x)=e^x$. ie $\varphi(x+y)=e^{x+y}=e^xe^y=\varphi(x)\varphi(y)$.

\section*{notation}
let $\varphi:G_1\to G_2$ be a group homomorphism, then $\ker\varphi=\{x\in G_1|\varphi(x)=e\}$

homomorphism always takes the identity in $G_1$ to $G_2$.

$\varphi(e_1)\varphi(e_1)^{-1}=\varphi(e_1e_1)\varphi(e_1)^{-1}=\varphi(e_1)\varphi(e_1)\varphi(e_1)^{-1}=e_2=\varphi(e_1)$

prove that $\ker \varphi$ is a subgroup

now we say that $\varphi$ is an isomorphism if $\varphi$ is a group homomorphism and $\varphi$ is bijective.

both of the previous examples are isomorphisms.

so from an algebraic point of view, there is no difference between addition on the reals and multiplication on the positive reals.

\section*{proposition}
let $\varphi$ be an isomorphism. the following are true
\begin{enumerate}
\item
$\varphi^{-1}$ which is the map from $G_2$ to $G_1$ is also an isomorphism.
\item
if $G_1$ is abelian, then $G_2$ is abelian.
\item
if $G_1$ is cyclic then so is $G_2$
\item
if $a\in G_1$ then $\text{ord}(a)=\text{ord}(\varphi(a))$
\end{enumerate}

\begin{enumerate}
\item
need to prove $\varphi^{-1}(\alpha\beta)=\varphi^{-1}(\alpha)\varphi^{-1}(\beta)$ for all $\beta\in G_2$, but $\varphi$ is injective so it is enough to prove that $\varphi(\varphi^{-1}(\alpha\beta))=\varphi(\varphi^{-1}(\alpha)\varphi^{-1}(\beta)=\varphi(\varphi^{-1}(\alpha))\varphi(\varphi^{-1}(\beta))=\alpha\beta$
\item
assume $G_1$ is abelian
\begin{align*}
  \alpha\beta=\varphi(\varphi^{-1}\left(\alpha\right)\varphi^{-1}(\beta))
\end{align*}
\item
hint: assume that $G_1=<a>$ for some $a\in G_1$ and then prove that $G_2=<\varphi(a)$
\item
no hint
\end{enumerate}
\section*{example}
\begin{align*}
  \mathbb{Z}_4\not\equiv\mathbb{Z}_2\times\mathbb{Z}_2
\end{align*}
by contradiction, assume that there exists an isomorphism $\varphi$ from z4 to z2+z2. $[1]\in \mathbb{Z}_4$ and $\text{ord}[1]=4$ so then $\text{ord}\varphi([1])=4$. But all elements of $\mathbb{Z}_2\times\mathbb{Z}_2$ has no elements of order 4, so there is no isomorphisms. however, if $\gcd(m,n)=1$ then $\mathbb{Z}_{mn}\equiv\mathbb{Z}_m\times\mathbb{Z}_n$

\begin{align*}
  \varphi:[x]_{mn}\to[x]_m[x]_n
\end{align*}
\section*{what does well defined mean?}
same input gives same output, ie if $[x]=[y]$ then $\varphi[x]=\varphi[y]$

\section*{3.4 \#13}
$(\mathbb{R}^*,\cdot), C_2=\{\pm1\}\subseteq \mathbb{R}^*$. $C_2$ is a subgroup of $\mathbb{R}^*$. prove that $\mathbb{R}^*\cong \mathbb{R}^+\times C_2$

we construct an isomorphism $\theta:\mathbb{R}^*\to R^{+}\times C_2$.

$x\to(|x|,\frac{x}{|x|})$. prove that $\theta$ is a group homomorphism and bijective.

$\theta(xy)=(|xy|,\frac{xy}{|xy|})=(|x|,\frac{x}{|x|})(|y|,\frac{y}{|y|})=\theta(x)\theta(y)$

bijectivity is exercise, but a number is uniquely identified by sign and magnitude (absolute value)

\section*{example}
prove that $\text{ord}(aba^{-1})=\text{ord}(b)$ for every $a,b\in G$ where $G$ is a group.

$m=\text{ord}(x)$ means $x^m=e$ and $x^k=e$ means that $m|k$.

if given $n=ord(x)$ and $m=ord(y)$ then best way is to show that $m=n$ is $m|n$ and $n|m$. this all works for finit.

this question is trivial if the group is abelian.

so let $m=ord(aba^{-1}), n=ord(b)$

\subsection*{case 1}
$n$ is finite, $b^n=e$. consider $(aba^{-1})^n=aba^{-1}aba^{-1}\dots aba^{-1}=ab^{n}a^{-1}=aea^{-1}=e$ so $ord(aba^{-1})$ is finite, also $m|n$

$b^m=a^{-1}\underbrace{(aba^{-1})(aba^{-1})\dots(aba^{-1})(aba^{-1})}_{m\text{ times}}a=a(aba^{-1})^ma=a^{-1}ea=e$ so $b^m=e$ and $n|m$
\subsection*{case 2}
$n$ is infinite. then we must prove that $m$ is infinite. by contradiction, assume $m<\infty$.

then $b^m=a^{-1}\underbrace{(aba^{-1})(aba^{-1})\dots(aba^{-1})(aba^{-1})}_{m\text{ times}}a=a(aba^{-1})^ma=a^{-1}ea=e$ so $b^m=e$.

and so the order is finite and we have our contradiction. so $m$ must be finite then
\subsection*{consider}
$ord(a^{-1})=ord(a)$ and $ord(ab)=ord(ba)$

by previous part $ord(ba)=(abaa^{-1})=ord(ab)$

\section*{3.2 \# 25 from class}
we note that if $x\in G$ has the required order, then $x^{-1}\in G$ also has the required order. note that the $x\ne x^{-1}$ because the order is greater than $2$.

\section*{!3.3 \#9}

\section*{other things in mind}
lets take a group $G$ and $H,K$ subgroups. then $\left\lvert HK\right\rvert=\frac{|H||K|}{|H\cap K|}$

recall: $HK=\{hk|h\in H, k\in K\}$

\begin{align*}
  g\in HK\\
  g=hk\\
  h\in H\quad |H|=m\\
  k\in K\quad |K|=n\\
\end{align*}
question? how many ways can $g=hk=h'k'$?

\begin{align*}
  hk=h'k'\to(h')^{-1}hk=k'\\
  (h')^{-1}h=k'k^{-1}\in H\cap K
\end{align*}
so $k'=\alpha k, h'=h\alpha^{-1}$

that is to say $hk=(h'\alpha)(\alpha^{-1}k')$
there are $|H\cap K|$ ways to choose alpha

\section*{october 15}
read 3.6.2

\subsubsection*{3.6 \#2}
Write out the addition tables for $\mathbb{Z}_4$ and for $\mathbb{Z}_2\times \mathbb{Z}_2$. Use cycle notation to write out the permutation determined by each row of each of the addition tables as in the discussion preceding Cayley's theorem.

\[
    \begin{array}{c|ccccc}
      +&[0]&[1]&[2]&[3]&(1)\\
      \hline
      [0] & [0] & [1] & [2] & [3]&(1)\\

      [1] & [1] & [2] & [3] & [0]&(1234)\\

      [2] & [2] & [3] & [0] & [1]&(13)(24)\\

      [3] & [3] & [0] & [1] & [2]&(1432)\\
    \end{array}
    \quad\quad
    \begin{array}{c|ccccc}
      + & ([0],[0]) & ([0],[1]) & ([1],[0]) & ([1],[1])&(1)\\
      \hline
      ([0],[0]) & ([0],[0]) & ([0],[1]) & ([1],[0]) & ([1],[1])&(1)\\
      ([0],[1]) & ([0],[1]) & ([0],[0]) & ([1],[1]) & ([1],[0])&(12)(34)\\
      ([1],[0]) & ([1],[0]) & ([1],[1]) & ([0],[0]) & ([0],[1])&(13)(24)\\
      ([1],[1]) & ([1],[1]) & ([1],[0]) & ([0],[1]) & ([0],[0])&(14)(23)\\
    \end{array}
\]

\section*{last time}
$\varphi:G\to \text{Sym}(G)$
\section*{rigid motions of a regular n-gon}
place the first vertex, then the second. we have n options for the first vertex, and 2 options for the second. and the rest are fixed. so we can do $2n$ rigid motions for any n-gon.

observation, rigid motions give us permutations, but for $n>3$ we can't get all the permutations. $2\cdot 4<4!$.

the rigid motions form a group.
\subsection*{goal: describe this group}
$a=$counterclockwise rotation by $\frac{2\pi}{n}$ radians or $\frac{360}{n}^\circ$. order of $a$ is $n$, that is to say, rotating $n$ times gives us our original vertex placement.

$a^i=$rotation by $\frac{2\pi}{n}\cdot i$.

$b=$reflection about line $L$ this will leave one or two vertices unchanged, depending on the parity of $n$.

$b=(2,n)(3,n-1)\dots$.

$b^2=e$.

consider $\{b,ab,a^2b,\dots,a^{n-1}b\}$. remember $a,b$ are functions so $ab=a\circ b$

$a^ib=a^j\Rightarrow a^i=a^j\Rightarrow a^{j-i}=e$ but $a^{j-1}=e$ iff $n|j-i$.

$a^ib=$the flip about the line $L_i$ that makes $\frac{\pi i}{n}$ with $L$, this means that $\text{ord}(a^ib)=2$ because it's just a flip.

now we have $n$ rotations and $n$ flips. note that no flip can be a rotation because a flip changes orientation.

$D_n$ denotes $\{e,a,a^2,\dots,a^{n-1},b,ba,ba^2,\dots,ba^{n-1}\}$ which is the dihedral group with 2n elements. $a^n=e$ and $b^2=e$.

notice that the order of the group reflects the symmetry of the geometric representation. a completely assymetric object with have only the $e$ rigid motions, while a circle will have infinitely many.

what is $ba$? it's $a^{-1}b=a^{n-1}b$

\section*{october 20}
assnmnt: 3.6 \#21,23,25
if odd, has identity, if even, identity and half rotation ($r^{n/2}$)
$a^jb=ba^j\to a^jb=a^{-j}b\to a^j=a^{-j}\to a^{2k}=e\to n|2j$

\subsection*{last time started homomorphisms}
\subsubsection*{definition}
$\varphi:G_1\to G_2$ is group homomorphism then $\text{Im}\varphi=\varphi(G_1)$ is a subgroup of $G_2$ and $\text{Ker}(\varphi)=\{x\in G_1:\varphi(x)=e_2\}=\varphi^{-1}(\{e_2\})$ beause $\{e_2\}\le G_2$ is a normal subgroup, $\text{Ker}(\varphi)\le G_1$ is a normal subgroup

\subsubsection*{equivalence relation defines a group  homomorphism}
on $G_1/\sim$ define the operation $[x][y]=[xy]$. is this well defined?

$[x]=[x']$ and $[y]=[y']$. $\varphi(x)=\varphi(x')$, and $\varphi(y)=\varphi(y')$ and so $\varphi(x)\varphi(y)=\varphi(x')\varphi(y')$ and homomorphism definition gives us $\varphi(xy)=\varphi(x'y')$.

claim , with this operation $G_1/\sim$ is a group. $[e_1]$ is identity. $[x]$ is inverse of $[x^-1]$.

let $\pi(x)=[x]$. claim $\pi$ is a group homomorphism.

$\pi(xy)=[xy]=[x][y]=\pi(x)\pi(y)$.

\subsubsection*{why does $[xy]=[x][y]$}
\subsubsection*{thrm}
Let $\varphi:G_1\to G_2$ be a group homomorphism. then $G_1/\sim\cong\varphi(G_1)$

proof:

$G_1\sim\to\varphi(G_1)$

$[x]\to\varphi(x)$

$\overline\varphi([x])=\varphi(x)$
claim: $\overline\varphi$ is a group homomorphism
$\overline([x][y])=\overline\varphi([xy])=\varphi(xy)=\varphi(x)\varphi(y)=\overline\varphi([x])\overline([y])$

claim: surjectivity is clear
claim: $\overline\varphi$ is injective.
$\overline\varphi([x])=\overline{\varphi}([x])\to \varphi(y)=\varphi(x)\to x\sim y\to [x]=[y]$

\subsubsection*{assignment for next time}
$\varphi:\mathbb{Z}_m\to\mathbb{Z}_n$ where $\varphi$ is group homomorphism. hint: $\varphi(0)=0$ and $\varphi([1])=[k]$ then $\varphi([j])=\varphi([jk])$. take $Z_2\to\mathbb{Z}_4$ then $\varphi([1])\ne[1]$

\section*{october 22}
\subsection*{discussion assnmnt}
\begin{enumerate}
\setcounter{enumi}{13}
\item
call center $C$ with $C=\{c\in G:cg=gc\forall g\in G\}$. then $gcg^{-1}=cgg^{-1}=c\in C$
\item
intesection being a group is pretty straightforward, if a is in both then $a^{-1}$ is in both. if a and b are in both, then $ab$ is in both, and $e$ is in both
\setcounter{enumi}{17}
\item
$\langle a\rangle$ has two subgroups, $\{e\}$ and $\langle a^k\rangle$ where $k|n$. of course $e$ is normal. cyclic groups are abelian, so
\begin{align*}
  b^ja^m(a^k)^ia^{-m}b^j=
\end{align*}
\end{enumerate}
\section*{3.8}
if $G$ is a group and $H$ is a subgroup

\subsubsection*{parallel 1}
on $G$ define the relation $x\sim_ry\Leftrightarrow xy^{-1}\in H$

$\Leftrightarrow x\in Hy$

claim: $\sim_r$ is an equivalence relation
\begin{enumerate}
\item
$x\sim_r x$
\item
$x\sim y\to xy^{-1}\in H\to (xy^{-1})^{-1}\in H\to yx^{-1}\in H\to y\sim x$
\item
transitivity
\end{enumerate}
so $[x]=Hx$
\subsubsection*{observations}
$Hx=Hy\to x\sim_r y$

all the right cosets have the same number of elements
$\theta:H\to xH$ because any $x$ has an image then $\theta$ is surjective, and $\theta(h_1)=\theta(h_2)\to xh_1=xh_2\to h_1=h_2$ and so it is bijective
\subsubsection*{parallel 2}
on $G$ define the relation $x\sim_ly\Leftrightarrow x^{-1}y\in H$

$\Leftrightarrow y\in xH$

claim $\sim_l$ is an equivalence relation
\begin{enumerate}
\item

\end{enumerate}
so $[x]=xH$

there exists a bijection from the set of left cosets to the set of right cosets.

define $\psi(xH)=Hx^{-1}$ (not $Hx$ because this is not well defined.

$xH=yH\to x\sim_l\to xy^{-1}\in H\to yx^{-1}\in H\to y^{-1}(x^{-1})^{-1}\in H\to x^{-1}\sim_r y^{-1}$

claim injectivity:$\psi(xH)=\psi(yH)\to Hx^{-1}=Hy^{-1}\to x^{-1}\sim_ry^{-1}\to x^{-1}(y^{-1})^{-1}\in H\to x^{-1}y\in H\to x\sim_l y\to xH=yH$

notation:  $[G:H]$ is the index of $H$ in $G$ and means the number of left/right cosets of $H$ in G.

corollary: if $G$ is finite and $H$ is a subgroup then the number of elements in $G$ is equal to the number of elements in $H$ times the index. $|G|=|H|\cdot[G:H]$

proof: $|G|$ equals the number of elements in each $[G:H]$ equal partitions of $G$ times the number of partitions.

corollary, if $G$ is finite then $H\subseteq G\to |H|$ divides $G$

\subsubsection*{example}
$G=S_3\cong D_3$

$H=\{e,b\}\le D_3$

left cosets are: $eH=H=bH, aH=\{a,ab\}, a^2H=\{a^2,a^2b\}$ and $[G:H]=3$
$N=\{e,a,a^{2}\}\to [G:N]=2$
\section*{oct 27}
\subsection*{derniere fois}
$G$ group, $N$ is a normal subgroup of $G$. then $G/N=\{aN:a\in G\}$ is a broup with $aN\cdot bN=(ab)N$

$\pi:G\to G/N:a\to aN$

$\pi$ is a surjective group hom with $\text{Ker} \pi=N$.

\subsection*{thrm}
$\varphi:G_1\to G_2$ group homomorphism then $G/\text{Ker}\varphi\cong\varphi(G_1)$
\subsection*{proposition}
there exists a one to one correspondence between $\{\text{subgroups of }G/N\}$ and $\{\text{subgroups of $G$ that contain $N$}\}$.

$\alpha:\{aN:a\in H\}=\pi(H)\leftarrow H\le G, H\supseteq N$

$\beta:K\to\pi^{-1}(K)$

moreover normal subgroups correspond to normal subgroups

\subsubsection*{proof}
note $\pi^{-1}(K)\supseteq\pi^{-1}(\{e\})=\text{Ker}\pi=N$. moreover if $K$ is a normal subgroup of $G/N$ then $\pi^{-1}(K)$ is a normal subgroup of $G$.

similarly if $H\le G$ and $H\supseteq N$ then $\pi(H)$ is a subgroup of $G/N$. moreover if $H$ is a normal subgroup of $G$ then $\pi(H)$ is a normal subgroup of $G/N$ (why?)

\subsubsection*{claim}
$\alpha\circ\beta(K)=\alpha(\beta(K))=\alpha(\pi^{-1}(K))=\pi(\pi^{-1}(K))=\{\pi(y):y\in \pi^{-1}(K)\}=\{\pi(y):\pi(y)\in K\}=K\cap I_m\pi=K\cap\pi(G)=K$ because $\pi$ is surjective

$\beta\circ\alpha(H)=\beta(\alpha(H))=\beta(\pi(H))=\pi^{-1}(\pi(H))\supseteq H$

$h\in H\to \pi(h)\in$

$\pi(x)\in  \pi(H)\to \pi(x)=\pi(h)$ for some $h\in H$ so $xN=hN$ so $xh^{-1}\in N\to xh^{-1}\in H\to x\in H$

so $\alpha$ and $\beta$ are bijections and are inverse.

\subsection*{example}
$G=\mathbb{Z}, N=n\mathbb{Z}$ and so $G/N=\mathbb{Z}/n\mathbb{Z}=\{a+n\mathbb{Z}:a\in \mathbb{Z}\}$

\subsection*{definition}
group $G$ is simple if it's only subgroups are itself and $\{e\}$.

\section*{example}
let $p$ be a prime then $\mathbb{Z}_p$ is simple. because nothing divides $p$ we can't have any subgroups of $\mathbb{Z}_p$ other than itself and the identity.
\end{document}


\section{Commutative algebra}\label{sec:commutative_algebra}

Commutative algebra generalizes desirable properties of \hyperref[def:set_of_integers]{set \( \BbbZ \) of integers} to nontrivial \hyperref[def:semiring/commutative_unital_ring]{commutative unital rings}. As a result, this allows studying polynomials or even arbitrary functions via techniques similar to those for integers.

In this whole section, \( R \) will refer to a nontrivial commutative unital ring. Since \( R \) is commutative, left and right modules over \( R \) are equivalent. We will only refer to either of them as simply \enquote{modules}.


\begin{quote}\textit{
	``I didn't give it a good notation because I didn't like it.''
}\end{quote}
Recall that last time, we defined sheafification, which can be thought of projecting presheaves onto sheaves in a
particularly nice way. This allows us to forget the difference between sheaves and presheaves, so to speak; we'll
use this to understand colimits of sheaves.
\begin{exm}% would be nice to say what x, i_* are...
First, a quick digression, since we got confused last time, on the espace étalé of a skyscraper sheaf. Directly
from the sheaf axioms, one can show that if \(\sF\) is a \(\fC\)-valued sheaf, then \(\sF(\emptyset)\) is the
terminal object (a point for \(\Set\), \(0\) for \(\Ab\), and so on). This follows from abstract nonsense: the
empty product \(\prod_\emptyset S\) is necessarily the terminal object (there's more to think through here). This
is what motivates the definition of the skyscraper sheaf \(i_*S = i_{x,*}S\) in Example~\ref{skys}. For
simplicity, assume \(x\in X\) is a closed point.

Now, let's construct its espace étalé \(\pi:Y_{i_*S}\to X\); for any \(y\in X\), \(\pi^{-1}(y)\) is the stalk of
\((i_*S)\) at \(y\), which is \(S\) if \(y = x\) or the terminal object \(*\) otherwise. Thus, \(Y_{i_*S}\) is as a
set a copy of \(X\), but with \(S\) over the basepoint \(x\) instead of a single point; then, we glue each of these
points of \(S\) to the rest of \(Y_{i_*S}\) as if they were all \(x\). The result is \(X\) with multiple
basepoints, so to speak, and is not at all Hausdorff. However, as topological spaces, we have a pullback diagram
\[\xymatrix{
	(U\setminus\set x)\times S\ar[r]\ar[d] & U\times S\ar[d]\\
	U\setminus\set x\ar[r] & Y_{i_*S}.
}\]
\end{exm}
We can also use the espace étalé to define sheafification: the sheafification \(\sF\sh\) is just the sheaf of
sections of \(Y_\sF\).
\subsection*{Kernels and Cokernels.}
Before discussing limits and colimits more generally, let's focus on kernels and cokernels. Let \(\vp:\sF\to\sG\)
be a morphism of sheaves of abelian groups on a space \(X\), and for every open \(U\subset X\), define
\((\ker\vp)(U) = \ker(\vp|_U)\). It's easy to check that this is a presheaf, and a little more work to check that
it's a sheaf, too. And this is actually the kernel in \(\Ab_X\), in that it satisfies the universal property:
it fits into the diagram
\[\xymatrix{
	\ker\vp\ar[r]\ar[d] & \sF\ar[d]^\vp\\
	0\ar[r] & \sG,
}\]
and any other sheaf \(\mathscr H\) that fits into the same place in the above diagram has a unique map to
\(\ker\vp\).

Likewise, a morphism in \(\Ab_X\) is injective (meaning a monomorphism) exactly when
\(\vp|_U:\sF(U)\to\sG(U)\) is injective for all open \(U\subset X\).

Cokernels are a little more interesting. The sheaf assigning \(U\mapsto\coker(\vp|_U)\) is a presheaf, and is the
cokernel in the category of presheaves, but it is \emph{not} the cokernel in the category of sheaves; it fails to
satisfy the universal property. This is where some of the interesting nuances of sheaf theory pop up.
\begin{exm}
\label{notcoker}
We'll let \(X = \C\), and let \(\sO\) be the sheaf of holomorphic functions and \(\sO^*\) be the sheaf of
``invertible,'' i.e.\ nonvanishing, holomorphic functions (an abelian group under multiplication). The exponential
map \(f(z)\mapsto e^{f(z)}\) sends holomorphic functions to nonvanishing holomorphic functions, and commutes with
restriction, so it's a morphism \(\exp:\sO\to\sO^*\) in \(\Ab_\C\).

If a function maps to \(1\) in \(\sO^*\), then it must be an integer multiple of \(2\pi i\), so it must be locally
constant, Thus, it's constant on each connected component of the given open set. Thus, \(\ker(\exp) = 2\pi
i\underline\Z\): the constant sheaf, not the constant presheaf. This agrees with what we just learned about
kernels.

Then, \(\Im(\exp)(U)\) is the \(f^*\in\sO^*(U)\) such that \(f = e^{2\pi i g}\) for some \(g\in\sO(U)\). That is,
\(\log f\) must have a well-defined branch on \(U\). In particular, if \(U = \C^*\) and \(f = z\), then
\(f\not\in\Im(\exp(U)\). This is a problem: \(\C^*\) can be covered by simply connected open sets on which the
logarithm exists, but the gluing axiom fails.

However, since \(\exp:\sO\to\sO^*\) is surjective on simply connected open sets, then it's surjective on the level
of stalks, even though it's not surjective as a map of sheaves. In other words, we want the sequence
\[\shortexact[j][\exp]{\underline\Z}{\sO}{\sO^*}{}\]
%\[\xymatrix{
%	0\ar[r] &\underline\Z\ar[r]^j &\sO\ar[r]^\exp & \sO^{*}\ar@{-->}[r] & 0
%}\]
to be a short exact sequence of sheaves, but if we naïvely define the cokernel like the kernel, it isn't. This
means that \emph{to define the sheaf cokernel, we sheafify the presheaf cokernel}. In this case, the sheafification
of the presheaf cokernel \(\coker(j)\) stitches together the stalks, but on stalks \(\exp\) is surjective, so since
a sheaf is completely determined by stalks, this is just \(\sO^*\) again, which jives with the idea of
surjectivity. In the same way, we get that \(\coker(\exp) = 0\), as one would expect.
\end{exm}
In other words, a surjective map of sheaves (categorically, an epimorphism), is surjectivity on stalks, but
\emph{not} surjectivity on all open subsets. Injectivity is equivalent to injectivity on stalks and on open
subsets, though.

Since sheafification preserves colimits, this can be generalized: the colimit of a diagram of sheaves is the
sheafification of the presheaf colimit (which is just the colimit on every open set).
\begin{exm}
This next example is in some sense the same example. Let \(X\) be a smooth manifold, \(\sF\) be the sheaf of
smooth maps to \(S^1\), \(C^\infty\) be the smooth maps to \(\R\) (so just the smooth functions), and
\(\underline\Z\) is the constant sheaf (which is also smooth maps to \(\Z\), since \(\Z\) is discrete); each of
these is a sheaf of abelian groups.

We'd like to understand that \(S^1 = \R/\Z\). This comes from the sequence
\[\xymatrix{
	0\ar[r] & \underline\Z\ar[r] & C^\infty\ar[r] & \sF\ar[r] & 0,
}\]
which is short exact. The injectivity of \(\underline\Z\inj C^\infty\) comes from the fact that every map to \(\Z\)
can be lifted to a smooth map to \(\R\), and surjectivity comes from the fact that germs of functions can be
lifted on a small neighborhood, so it's surjective on stalks. However, there are open subsets where functions can't
be lifted: if \(X = S^1\), then the identity map \(S^1\to S^1\) can't be lifted to a map to \(\R\). Thus, this is
surjective, even though it's not so on the level of open sets.
\end{exm}
\begin{exm}
Our next example will be the de Rham complex. Let \(X\) be a smooth manifold. Let \(\underline\R\) denote the
constant sheaf on \(\R\) (locally constant functions) and \(\Omega^1\) denote the sheaf of one-forms on \(X\). The
exterior derivative gives us an exact sequence
\[\xymatrix{
	0\ar[r] & \underline\R\ar[r] & C^\infty\ar[r]^{\d} & \Omega^1\ar[r]^{\d} & \Omega^2\ar[r]^{\d} &\dots
}\]
However, this is not in general short exact; if \(\Omega_{\text{cl}}^1\) denotes the space of closed one-forms,
then the Poincaré lemma just states that the following sequence is short exact.
\[\xymatrix{
	0\ar[r] & \underline\R\ar[r] & C^\infty\ar[r]^{\d} & \Omega_{\text{cl}}^1\ar[r] & 0
}\]
In other words, even considering something very simple about short exact sequences of sheaves gives us cohomology.
This can be used to define sheaf cohomology, though we won't return to that anytime soon.

In fact, Example~\ref{notcoker} is a special case of this, since \(\d z/z\in\Omega^1(\C^*)\) is a closed form
that's not exact.
\end{exm}
\subsection*{Ringed Space.}
Anyways, we were going to talk about schemes, right? These are not just topological spaces, but ringed spaces:
topological spaces with a notion of a ring of functions.
\begin{defn}
A \term{ringed space} is the data \((X,\sO_X)\), where \(X\) is a topological space and \(\sO_X\) is a sheaf of
rings on \(X\).
\end{defn}
The motivating examples are a topological space with continuous functions to \(\R\) (since these form a ring), or a
smooth manifold with the sheaf \(C^\infty\), or an analytic manifold with \(C^\omega\) (analytic functions).  Thus,
there are definitely different notions of ``function'' on a manifold, but the ringed space structure means knowing
what kinds of functions (geometric structure) is.

We'd also like to know how to evaluate functions on a ringed space. For an arbitrary \(x\in U\) and
\(f\in\sO_X(U)\), it's not clear how to define \(f(x)\); we have stalks, but then what? In each of our examples
(continuous functions, smooth functions, analytic functions, holomorphic functions, etc.), the stalks \(\sO_{X,x}\)
aren't just rings, but local rings,\footnote{Recall that a \term{local ring} is a ring with a unique maximal
ideal.} with the maximal ideal \(\m_x\) of functions which vanish at \(x\). \(\m_x\) is unique, because if
\(f\in\sO_{X,x}\setminus\m_x\), then \(f(x)\ne 0\), so it's nonzero on a neighborhood of \(x\), and therefore
invertible in that subset! Thus, \(f\in\sO_{X,x}^\times\), so \(\m_x\) must be unique.

The point is, evaluating at \(x\) is exactly quotienting by \(\m_x\), producing an element of \(\R\). The sheaves
we care about have local rings for stalks, which is what makes this evaluation work. We'll turn this into a
definition of something much more useful than a ringed space.
\begin{defn}
A \term{locally ringed space} is a ringed space \((X,\sO_X)\) such that for every \(x\in X\), the stalk
\(\sO_{X,x}\) is a local ring.
\end{defn}
Thus, all of our basic examples are locally ringed spaces, and in general, given an \(f\in\sO_X(U)\), we can define
\(V(f) = \set{x\in U: f(x) = 0}\), and this will end up being a closed set.

Schemes are particular examples of locally ringed spaces. We'll have to define how to produce a sheaf of functions,
which we'll probably do next time, but we're almost there. One major takeaway is that schemes behave somewhat like
these examples we already have.

We also need to define morphisms. An isomorphism is evident: \((X,\sO_X)\cong (Y,\sO_Y)\) is the data of a
homeomorphism \(f:X\to Y\) that identifies the sheaves, i.e.\ for all open \(U\subset Y\), there's an isomorphism
\(f_*: \sO_Y(U)\to \sO_X(f^{-1}(U))\).

It's less obvious how to define morphisms in general; clearly, we need a continuous \(f:X\to Y\), and we want to
compare \(\sO_X\) and \(\sO_Y\). Functions pull back (because the preimage of an open set is open); in the examples
we had before, we checked that the pullbacks of continuous (smooth, etc.) functions were continuous (smooth, etc.).
More generally, given an open \(U\subset Y\), we have the two rings \(\sO_Y(U)\) and \(\sO_X(f^{-1}(U))\), and we
want the pullback of functions \(f_*:\sO_Y(U)\to\sO_X(f^{-1}(U))\) to be a ring homomorphism. This is exactly how
we defined the pushforward of a sheaf.
\begin{defn}
A \term{morphism of ringed spaces} is a pair \((f,f^\sharp): (X,\sO_X)\to (Y,\sO_Y)\) in which
\begin{itemize}
	\item \(f:X\to Y\) is continuous, and
	\item \(f^\sharp: \sO_Y\to f_*\sO_X\) is a morphism in \(\Ring_Y\).
\end{itemize}
\end{defn}
That is: for every open subset, we can pull functions back into that open subset. But we can say that more
concisely with the sheaf theory we have developed.

It's worth remembering that nilpotents on affine schemes give us functions that aren't determined by their values
(well, we do have to set up the structure of a locally ringed space first, but we'll get there), so a function
isn't quite a bunch of values at points; it's something that we care to pull back.

This is cool, but we care about ringed spaces. What about these maximal ideals? They tell us what it means for a
function to vanish. Back in the world of smooth functions, if \(\vp(y) = 0\) and \(x\in f^{-1}(y)\), then
\((f^*\vp)(x) = \vp(f(x))\) had better be \(0\) too. This is not preserved by morphisms of ringed spaces (since
evaluation isn't defined for germs of functions on ringed spaces), so we need an additional axiom.

If \((f,f^\sharp)\) is a morphism of ringed spaces, passing to colimits induces a map \(\sO_{Y,y}\to\sO_{X,x}\),
whenever \(f(x) = y\) (this is generally true for a map of sheaves, thanks to the property of colimits). Then, we
want this map to send \(\m_y\to\m_x\).
\begin{defn}
A morphism \((f,f^\sharp):(X,\sO_X)\to(Y,\sO_Y)\) is a morphism of locally ringed spaces if for every \(x\in X\),
\(y\in Y\) such that \(f(x) = y\), the induced map \(f^\sharp_x: \sO_{Y,y}\to\sO_{X,x}\) maps \(\m_y\) into
\(\m_x\).
\end{defn}
This is actually all the data that we'll need to define schemes: schemes are a full subcategory of locally ringed
spaces; specifically, they are the ones that are locally isomorphic to \((\Spec R, \sO_{\Spec R})\) (as soon as we
define the locally ringed space structure on \(\Spec R\)), i.e.\ there are actual isomorphisms on an open cover.

Does this look weird? It's actually not unfamiliar: a smooth manifold is a locally ringed space that's locally
isomorphic to \((\R^n,C^\infty)\). This encodes a lot of information; in particular, a continuous map of manifolds
is smooth iff it pulls smooth functions back to smooth functions. In the same way, a topological manifold is a
locally ringed space locally isomorphic to \((\R^n,C)\) (the sheaf of continuous functions). All the structure of
an atlas is encapsulated in this notion of locally ringed spaces.

This notion is extremely general. For example, we can define a complex analytic manifold to be a locally ringed
space locally isomorphic to \((U\subset\C^n, \operatorname{Hol})\) (since small discs in \(\C^n\) aren't
necessarily biholomorphic to all of \(\C^n\)). In all of the cases we've seen, though, \(\sO_X(U)\) is always a
subset of set maps \(U\to\R\) (or \(\C\)), and in particular functions are determined by their values. This is
something that will not be true for schemes.

Next time, we will define \(\Spec R\), as a scheme.


\documentclass[a4paper,10pt]{book}

\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage[top=0.5in, bottom=0.5in, left=0.5in, right=0.5in]{geometry}
\usepackage{setspace}

\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}[theorem]{Lemma}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{xca}[theorem]{Exercise}
\newtheorem{con}[theorem]{}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\numberwithin{section}{chapter}
\numberwithin{equation}{chapter}

\begin{document}

 \chapter{Metric Graphs}
 \section{Graphs: Combinatorical Structure}

 \begin{definition}
  A graph \emph{$\Gamma$} consists of

  \begin{itemize}
   \item A pair of sets $(V,\ E)$ (called the `Vertex' and `Edge' sets respectively)
   \item An involution  $\: \phi \colon E \rightarrow E$
               satisfying $\phi (e) = \bar{e} $ and $\phi\circ\phi = \mathbf{1}_E$ (identity function)
   \item Functions $i,\ \tau: E \rightarrow V$ such that $i(\bar{e}) = \tau (e) $ and $\tau(\bar{e}) = i(e)$
  \end{itemize}

 \end{definition}

 Insert EXAMPLE 'ERE

 \section{A Graph as a Space}

   The following construction associates to a graph $\Gamma$, a space $| \Gamma |$
   \vspace{0.1in} \\ Let $ \xi = E \times [0,1] = \{ (e,t) : e \in E,\ t \in [0,1]\} $.\\
   Let $ \widetilde{\Gamma} =  \xi \cup V $ \\
   Let `\texttildelow' be the equivalence relation on $ \widetilde{\Gamma} $ generated by:
   \begin{itemize}
      \item If $ (e,t) \in \xi $, then $ (e,t) \sim (\bar{e},1-t) $
      \item $ \forall \ e \in E $, $ i(e) \sim (e,0) $ and $ \tau (e) \sim (e,1) $
   \end{itemize}
   $ |\Gamma| $ is the quotient space $ \Gamma / \sim $
   \section{ Metric structure on a Graph}

   \subsection{Distance on the Vertex set V}
   \begin{definition}
      Two vertices $ v_{1}$ and $v_{2} $ are said to be \emph{adjacent} if there exists $ e \in E $ such that $ i(e) = v_1 $ and $ \tau (e) = v_2 $.
   \end{definition}
   Let $ \cal{D} = \{ $ d $: V \times V \rightarrow \mathbf{R} \ : \ $
 d is a metric; d($ v_1,\ v_2 $) $ \leq $ 1 if $ v_1 $, $ v_2 $ are adjacent $ \} $
   \begin{lemma}
      $ \cal{D} $ is not empty
   \end{lemma}
   \begin{definition}
      The \emph{Graph Metric} on V is defined as
      \begin{equation}
	  d_{max}(v_1,v_2)= \sup_{d \in \cal{D} }d(v_1,v_2) \nonumber
      \end{equation}
   \end{definition}
   \begin{lemma}
	$ d_{max} $ is a metric.
    \proof
    \begin{enumerate}
      \item \[\forall \ x \in V,\ d_{max}(x, x)= \sup_{d \in \cal{D}}d(x,x) = \sup\{ 0 \} = 0 \]
      \item \[\forall \ x,\ y \in V,\ d_{max}(x, y)= \sup_{d \in \cal{D} }d(x,y)= \sup_{d \in \cal{D} }d(y,x)  =d _{max}(y, x) \]
      \item \[ d_{max}(x, z)=\sup\{d(x,y): d \in \mathcal{D}\} \leq \sup_{}\{ d(x,y): d \in \mathcal{D}\} {( d \in \cal{D} \text{ is a metric})} \]
    \end{enumerate}
  \end{lemma}
  \begin{definition}
   An \emph{edge path} is a ordered list (may be null, in whuch case it is a single vertex) of edges- denoted by $ \eta=(e_1,e_2,\dots,e_n) $, such that, $ \forall i,\ 1\leq i < n,\ i(e_i)=\tau(e_{i+1})$. $\eta$ is called ``an edge path from $i(e_1)$ to $\tau(e_n)$''.
  \end{definition}
  \begin{definition}
   An edge path is a \emph{loop} if $i(e_1) = \tau(e_n)$
  \end{definition}
  \begin{definition}
   An edge path is said to be \emph{reduced} if $\forall\ i,\ 1\leq i<n,\ e_i \neq \bar{e}_{i+1}$
  \end{definition}
  \begin{definition}
   A graph $\Gamma$ is \emph{connected} if $\forall\ x,y \in V,\ \exists$ an edge path from x to y.
  \end{definition}
  \begin{definition}
   A connected graph is called a \emph{tree} if it has no reduced edge loops.
  \end{definition}
  \begin{theorem}
   Let $\Gamma$ be a connected graph. Then for x, y $\in V$,
   \begin{equation}
    d_{max}(x,y)=min\{n\geq 0 :\ \exists\ \text{an edge path from x to y of cardinality }n\}
   \end{equation}
  \proof
  Let $d_{\Gamma}(x,y)=min\{n\geq 0 :\ \exists\ \text{an edge path from x to y of cardinality }n\}$.\\
  We shall show:
  \begin{enumerate}

   \item $d_\Gamma$ is a metric
   \item $d_\Gamma (i(e),\tau (e))\leq 1$
   \item $d_{max}(x,y) \leq d_\Gamma(x,y)$
  \end{enumerate}
Now, the first and second points establish that $d_\Gamma \in \mathcal{D} $. Then, $d_{max}$ being the supremum value will imply $d_{max}(x,y) \geq d_\Gamma (x,y)$. Together with 3, this will give the desired result.
  \begin{lemma}
   $d_\Gamma$ is a metric
   \proof
   \begin{enumerate}
    \item \[d_\Gamma(x,x) = 0\] because the single vertex `x' is a null list of edges that give the minimal connecting edge path.
    \item \[d_\Gamma(x,y) = d_\Gamma(y,x)\] Now, in an (undirected) graph, $\eta$ is a valid edge path iff $\bar{\eta}$ is also a valid edge path.
    \begin{remark}
     \[ \eta = (e_1,e_2,\dots,e_n) \Rightarrow \bar{\eta}=(\bar{e}_n,\bar{e}_{n-1},\dots,\bar{e}_1)\]
     If $\eta$ is an edge path from x to y, $\bar{\eta}$ is an edge path fom y to x.
    \end{remark}
    Hence, the involution of the minimal edge path connecting x to y will connect y to x. This will also be the minimal edge path connecting y to x since otherwise the involution of the shorter path (from y to x) will connect x to y and be shorter hat the oiginal path, which leads to a contradiction.
    \item If \[
              \eta_1=(e_1,\dots,e_n) \text{ is the minimal path connecting x to y}\] and\[
              \eta_2=(e_{n+1},\dots,e_m) \text{ is the minimal path connecting y to z}
             \]
             \begin{remark}
              Edges in $\eta_1$ and $\eta_2$ need not be distinct.
             \end{remark}
             Then,\[
                   \eta_1 \circ \eta_2 = (e_1,e_2,\dots,e_n,e_{n+1},\dots,e_m) \text{ is an edge path connecting x to z}
                  \]
                  Hence the minimal edge path connecting x to z will have to be, by definition, shorter than or the same length as this path. Which means
                  \[
                   d_{max}(x,z)=|\eta_{min}|\leq |\eta_1 \circ \eta_2| =m+n =d_{max}(x,y)+d_{max}(y,z)
                  \]
                     \end{enumerate}
    This proves that $d_{max}$ is a metric.
  \end{lemma}
  \begin{lemma}
    $d_\Gamma (i(e),\tau (e))\leq 1$
    \proof Since $(e)$ is an edge path connecting $i(e)$ and $\tau(e)$, the minimal edge path will have cardinality less than or equal to this. That is,
    \[
      d_{max}(i(e),\tau(e))\leq |(e)| = 1
    \]
  \end{lemma}
    \begin{lemma}
     $d_{max}(x,y) \leq d_\Gamma(x,y)$
    \proof Let $ d_\Gamma(x,y) = n$.
    This means that there exists an edge path $\eta = (e_1,\dots,e_n) $ connecting x to y. Now,
    \[
     d_{max}(x,y) \leq d_{max}(i(e_1,\tau(e_1)) + \dots + d_{max}(i(e_n),\tau(e_n)) \ \ \ \ \ \ \ \ \ \  \text{[$d_{max}$ is a metric]}
    \]
    \[
     \leq 1 + \dots +1=n \hspace{2in} [d_{max} \in \mathcal{D}]
    \]

  \end{lemma}

  \end{theorem}
\end{document}


\chapter{Quantum states and measurements}
In this chapter we'll explain how to set up quantum states using
linear algebra. This will allow me to talk about quantum \emph{circuits}
in the next chapter, which will set the stage for Shor's algorithm.

I won't do very much physics (read: none at all).
That is, I'll only state what the physical reality is in terms
of linear algebras, and defer the philosophy of why this is true
to your neighborhood ``Philosophy of Quantum Mechanics'' class
(which is a ``social science'' class at MIT!).

\section{Bra-ket notation}
Physicists have their own notation for vectors:
whereas I previously used something like $v$, $e_1$, and so on,
in this chapter you'll see the infamous \vocab{bra-ket} notation:
a vector will be denoted by $\ket\bullet$, where $\bullet$ is some
variable name: unlike in math or Python, this can include
numbers, symbols, Unicode characters, whatever you like.
This is called a ``ket''.
To pay a homage to physicists everywhere,
we'll use this notation for this chapter too.

\begin{abuse}
	[For this part, $\dim H < \infty$]
	In this part on quantum computation,
	we'll use the word ``Hilbert space'' as defined earlier,
	but in fact all our Hilbert spaces will be finite-dimensional.
\end{abuse}

If $\dim H = n$, then its orthonormal basis elements are often denoted
\[ \ket0, \ket1, \dots, \ket{n-1} \]
(instead of $e_i$)
and a generic element of $H$ denoted by
\[ \ket\psi, \ket\phi, \dots \]
and various other Greek letters.

Now for any $\ket\psi \in H$,
we can consider the canonical dual element in $H^\vee$
(since $H$ has an inner form), which we denote by $\bra\psi$ (a ``bra'').
For example, if $\dim H = 2$ then we can write
\[ \ket\psi = \begin{bmatrix} \alpha \\ \beta \end{bmatrix} \]
in an orthonormal basis, in which case
\[ \bra\psi = \begin{bmatrix} \ol\alpha & \ol\beta \end{bmatrix}. \]
We even can write dot products succinctly in this notation:
if $\ket\phi = \begin{bmatrix} \gamma \\ \delta \end{bmatrix}$,
then the dot product of $\ket\phi$ and $\ket\psi$ is given by
\[
	\braket{\psi|\phi}
	= \cvec{\ol\alpha & \ol\beta} \cvec{\gamma \\ \delta}
	= \ol\alpha\gamma + \ol\beta \delta.
\]
So we will use the notation $\braket{\psi|\phi}$
instead of the more mathematical $\left< \ket\psi, \ket\phi \right>$.
In particular, the squared norm of $\ket\psi$ is just $\braket{\psi|\psi}$.
Concretely, for $\dim H = 2$ we have
$\braket{\psi|\psi} = |\alpha|^2 + |\beta|^2$.

\section{The state space}
If you think that's weird, well, it gets worse.

In classical computation, a bit is either $0$ or $1$.
More generally, we can think of a classical space of $n$
possible states $0$, \dots, $n-1$.
Thus in the classical situation, the space of possible states
is just a discrete set with $n$ elements.

In quantum computation, a \vocab{qubit} is instead
any \emph{complex linear combination} of $0$ and $1$.
To be precise, consider the normed complex vector space
\[ H = \CC^{\oplus 2} \]
and denote the orthonormal basis elements by $\ket0$ and $\ket1$.
Then a \emph{qubit} is a nonzero element $\ket\psi \in H$,
so that it can be written in the form
\[ \ket\psi = \alpha \ket 0 + \beta \ket 1 \]
where $\alpha$ and $\beta$ are not both zero.
Typically, we normalize so that $\ket\psi$ has norm $1$:
\[ \braket{\psi|\psi} = 1 \iff |\alpha|^2 + |\beta|^2 = 1. \]
In particular, we can recover the ``classical'' situation
with $\ket 0 \in H$ and $\ket 1 \in H$,
but now we have some ``intermediate'' states,
such as \[ \frac{1}{\sqrt2} \left(\ket 0 + \ket 1 \right). \]
Philosophically, what has happened is that:
\begin{moral}
	Instead of allowing just the states $\ket 0$ and $\ket 1$,
	we allow any complex linear combination of them.
\end{moral}
More generally, if $\dim H = n$,
then the possible states are nonzero elements
\[ c_0\ket0 + c_1\ket1 + \dots + c_{n-1}\ket{n-1} \]
which we usually normalize so that
$|c_0|^2 + |c_1|^2 + \dots + |c_{n-1}|^2 = 1$.

\section{Observations}
\prototype{$\id$ corresponds to not making a measurement
	since all its eigenvalues are equal,
	but any operator with distinct eigenvalues will cause collapse.}
If you think that's weird, well, it gets worse.
First, some linear algebra:
\begin{definition}
	Let $V$ be a finite-dimensional inner product space.
	For a map $T: V \to V$, the following conditions are equivalent:
	\begin{itemize}
		\ii $\left< Tx, y\right> = \left< x, Ty \right>$
		for any $x,y \in V$.
		\ii $T = T^\dagger$.
	\end{itemize}
	A map $T$ satisfying these conditions is called \vocab{Hermitian}.
\end{definition}
\begin{ques}
	Show that $T$ is normal.
\end{ques}
Thus, we know that $T$ is diagonalizable
with respect to the inner form, so for a suitable basis we
can write it in an orthonormal basis as
\[
	T = \begin{bmatrix}
		\lambda_0 & 0 & \dots & 0 \\
		0 & \lambda_1 & \dots & 0 \\
		\vdots & \vdots & \ddots & \vdots \\
		0 & 0 & \dots & \lambda_{n-1}
	\end{bmatrix}.
\]
As we've said, this is fantastic:
not only do we have a basis of eigenvectors,
but the eigenvectors are pairwise orthogonal,
and so they form an orthonormal basis of $V$.
\begin{ques}
	Show that all eigenvalues of $T$ are real.
	($T = T^\dagger$.)
\end{ques}

Back to quantum computation.
Suppose we have a state $\ket\psi \in H$, where $\dim H = 2$;
we haven't distinguished a particular basis yet,
so we just have a nonzero vector.
Then the way observations work (and this is physics, so you'll have to
take my word for it) is as follows:
\begin{moral}
	Pick a Hermitian operator $T : H \to H$;
	then observations of $T$ return eigenvalues of $T$.
\end{moral}
To be precise:
\begin{itemize}
	\ii Pick a Hermitian operator $T : H \to H$,
	which is called the \vocab{observable}.
	\ii Consider its eigenvalues $\lambda_0$, \dots, $\lambda_{n-1}$
	and corresponding eigenvectors $\ket{0}_T$, \dots, $\ket{n-1}_T$.
	Tacitly we may assume that $\ket{0}_T$, \dots, $\ket{n-1}_T$ form
	an orthonormal basis of $H$.
	(The subscript $T$ is here to distinguish the eigenvectors of $T$
	from the basis elements of $H$.)
	\ii Write $\ket\psi$ in the orthonormal basis as
	\[ c_0\ket0_T + c_1\ket1_T + \dots + c_{n-1}\ket{n-1}_T. \]
	\ii Then the probability of observing $\lambda_i$ is
	\[ \frac{|c_i|^2}{|c_0|^2 + \dots + |c_{n-1}|^2}. \]
	This is called making an \vocab{observation along $T$}.
\end{itemize}
Note that in particular, for any nonzero constant $c$,
$\ket\psi$ and $c\ket\psi$ are indistinguishable,
which is why we like to normalize $\ket\psi$.
But the queerest thing of all is what happens to $\ket\psi$:
by measuring it, we actually destroy information.
This behavior is called \vocab{quantum collapse}.
\begin{itemize}
	\ii Suppose for simplicity that we observe $\ket\psi$
	with $T$ and obtain an eigenvalue $\lambda$,
	and that $\ket{i}_T$ is the only eigenvector with this eigenvalue.
	Then, the state $\ket\psi$ \emph{collapses} to just the state
	$c_i \ket{i}_T$: all the other information is destroyed.
	(In fact, we may as well say it collapses to $\ket{i}_T$,
	since again constant factors are not relevant.)

	\ii	More generally, if we observe $\lambda$,
	consider the generalized eigenspace $H_\lambda$
	(i.e.\ the span of eigenvectors with the same eigenvalue).
	Then the physical state $\ket\psi$ has been changed as well:
	it has now been projected onto the eigenspace $H_\lambda$.
	In still other words, after observation, the state collapses to
	\[
		\sum_{\substack{0 \le i \le n \\ \substack{\lambda_i = \lambda}}}
		c_i \ket{i}_T.
	\]
\end{itemize}
In other words,
\begin{moral}
	When we make a measurement,
	the coefficients from different eigenspaces are destroyed.
\end{moral}
Why does this happen? Beats me\dots physics (and hence real life) is weird.
But anyways, an example.
\begin{example}
	[Quantum measurement of a state $\ket\psi$]
	Let $H = \CC^{\oplus 2}$ with orthonormal basis $\ket0$ and $\ket1$
	and consider the state
	\[
		\ket\psi
		= \frac{i}{\sqrt5} \ket 0
		+ \frac{2}{\sqrt5} \ket 1
		= \pair{i/\sqrt5}{2/\sqrt5} \in H.
	\]
	\begin{enumerate}[(a)]
		\ii Let \[ T = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}. \]
		This has eigenvectors $\ket0 = \ket0_T$ and $\ket1 = \ket1_T$,
		with eigenvalues $+1$ and $-1$.  So if we measure $\ket\psi$ to $T$,
		we get $+1$ with probability $1/5$ and $-1$ with probability $4/5$.
		After this measurement, the original state collapses to
		$\ket0$ if we measured $+1$, and $\ket1$ if we measured $-1$.
		So we never learn the original probabilities.

		\ii Now consider $T = \id$, and arbitrarily
		pick two orthonormal eigenvectors $\ket0_T$, $\ket1_T$;
		thus $\psi = c_0\ket0_T + c_1\ket1_T$.
		Since all eigenvalues of $T$ are $+1$,
		our measurement will always be $+1$ no matter what we do.
		But there is also no collapsing,
		because none of the coefficients get destroyed.

		\ii Now consider
		\[ T = \begin{bmatrix} 0 & 7 \\ 7 & 0 \end{bmatrix}. \]
		The two normalized eigenvectors are
		\[ \ket0_T = \frac{1}{\sqrt2}\pair11
		\qquad \ket1_T = \frac{1}{\sqrt2}\pair1{-1} \]
		with eigenvalues $+7$ and $-7$ respectively. In this basis, we have
		\[
			\ket\psi = \frac{2+i}{\sqrt{10}}\ket0_T
			+ \frac{-2+i}{\sqrt{10}}\ket1_T. \]
		So we get $+7$ with probability $\half$ and $-7$
		with probability $\half$, and after the measurement,
		$\ket\psi$ collapses to one of $\ket0_T$ and $\ket1_T$.
	\end{enumerate}
\end{example}
\begin{ques}
	Suppose we measure $\ket\psi$ with $T$ and get $\lambda$.
	What happens if we measure with $T$ again?
\end{ques}

For $H = \CC^{\oplus 2}$ we can come up with more classes of examples using
the so-called \vocab{Pauli matrices}.
These are the three Hermitian matrices
\[
	\sigma_z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}
	\qquad
	\sigma_x = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}
	\qquad
	\sigma_y = \begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}.
\]
These matrices are important because:
\begin{ques}
	Show that these three matrices, plus the identity matrix,
	form a basis for the set of Hermitian $2 \times 2$ matrices.
\end{ques}
So the Pauli matrices are a natural choice of basis.

Their normalized eigenvectors are
\[ \zup = \ket0 = \pair10 \qquad \zdown = \ket1 = \pair01 \]
\[ \xup = \frac{1}{\sqrt2}\pair11
	\qquad \xdown = \frac{1}{\sqrt2}\pair1{-1} \]
\[ \yup = \frac{1}{\sqrt2}\pair1i
	\qquad \ydown = \frac{1}{\sqrt2}\pair1{-i} \]
which we call ``$z$-up'', ``$z$-down'',
``$x$-up'', ``$x$-down'', ``$y$-up'', ``$y$-down''.
(The eigenvalues are $+1$ for ``up'' and $-1$ for ``down''.)
So, given a state $\ket\psi \in \CC^{\oplus 2}$
we can make a measurement with respect to any of these three bases
by using the corresponding Pauli matrix.

In light of this, the previous examples were
(a) measuring along $\sigma_z$,
(b) measuring along $\id$,
and (c) measuring along $7\sigma_x$.

Notice that if we are given a state $\ket\psi$,
and are told in advance that it is either $\xup$ or $\xdown$
(or any other orthogonal states)
then we are in what is more or less a classical situation.
Specifically, if we make a measurement along $\sigma_x$,
then we find out which state that $\ket\psi$ was in (with 100\% certainty),
and the state does not undergo any collapse.
Thus, orthogonal states are reliably distinguishable.

\section{Entanglement}
\prototype{Singlet state: spooky action at a distance.}
If you think that's weird, well, it gets worse.

Qubits don't just act independently:
they can talk to each other by means of a \emph{tensor product}.
Explicitly, consider \[ H = \CC^{\oplus 2} \otimes \CC^{\oplus 2} \]
endowed with the norm described in \Cref{prob:inner_prod_tensor}.
One should think of this as a qubit $A$ in a space $H_A$
along with a second qubit $B$ in a different space $H_B$,
which have been allowed to interact in some way,
and $H = H_A \otimes H_B$ is the set of possible states of \emph{both} qubits.
Thus
\[
	\ket{0}_A \otimes \ket{0}_B, \quad
	\ket{0}_A \otimes \ket{1}_B, \quad
	\ket{1}_A \otimes \ket{0}_B, \quad
	\ket{1}_A \otimes \ket{1}_B
\]
is an orthonormal basis of $H$;
here $\ket{i}_A$ is the basis of the first $\CC^{\oplus 2}$
while $\ket{i}_B$ is the basis of the second $\CC^{\oplus 2}$,
so these vectors should be thought of as ``unrelated''
just as with any tensor product.
The pure tensors mean exactly what you want:
for example $\ket0_A \otimes \ket1_B$ means
``$0$ for qubit $A$ and $1$ for qubit $B$''.

As before, a measurement of a state in $H$ requires
a Hermitian map $H \to H$.
In particular, if we only want to measure the qubit $B$ along $M_B$,
we can use the operator \[ \id_A \otimes M_B. \]
The eigenvalues of this operator coincide with the ones for $M_B$,
and the eigenspace for $\lambda$ will be the $H_A \otimes (H_B)_\lambda$,
so when we take the projection the $A$ qubit will be unaffected.

This does what you would hope for pure tensors in $H$:
\begin{example}[Two non-entangled qubits]
	Suppose we have qubit $A$ in the state
	$\frac{i}{\sqrt5}\ket0_A + \frac{2}{\sqrt5}\ket1_A$
	and qubit $B$ in the state
	$\frac{1}{\sqrt2} \ket0_B + \frac{1}{\sqrt2}\ket1_B$.
	So, the two qubits in tandem are represented by the pure tensor
	\[
		\ket\psi
		=
		\left( \frac{i}{\sqrt5}\ket0_A + \frac{2}{\sqrt5}\ket1_A \right)
		\otimes
		\left( \frac{1}{\sqrt2} \ket0_B + \frac{1}{\sqrt2}\ket1_B \right).
	\]
	Suppose we measure $\ket\psi$ along
	\[ M = \id_A \otimes \sigma_z^B. \]
	The eigenspace decomposition is
	\begin{itemize}
		\ii $+1$ for the span of $\ket0_A \otimes \ket0_B$ and
		$\ket1_A \otimes \ket0_B$, and
		\ii $-1$ for the span of $\ket0_A \otimes \ket1_B$ and
		$\ket1_A \otimes \ket1_B$.
	\end{itemize}
	(We could have used other bases, like $\xup_A \otimes \ket0_B$ and
	$\xdown_A \otimes \ket0_B$ for the first eigenspace, but it doesn't matter.)
	Expanding $\ket\psi$ in the four-element basis, we find that
	we'll get the first eigenspace with probability
	\[ \left|\frac{i}{\sqrt{10}}\right|^2
	+ \left|\frac{2}{\sqrt{10}}\right|^2 = \half. \]
	and the second eigenspace with probability $\half$ as well.
	(Note how the coefficients for $A$ don't do anything!)
	After the measurement, we destroy the coefficients of the other eigenspace;
	thus (after re-normalization) we obtain the collapsed state
	\[ \left( \frac{i}{\sqrt5}\ket0_A + \frac{2}{\sqrt5}\ket1_A \right)
		\otimes \ket0_B
		\qquad\text{or}\qquad
		\left( \frac{i}{\sqrt5}\ket0_A + \frac{2}{\sqrt5}\ket1_A \right)
		\otimes \ket1_B
	\]
	again with 50\% probability each.
\end{example}
So this model lets us more or less work with the two qubits independently:
when we make the measurement, we just make sure to not touch the other qubit
(which corresponds to the identity operator).

\begin{exercise}
	Show that if $\id_A \otimes \sigma_x^B$ is applied to the $\ket\psi$
	in this example, there is no collapse at all.
	What's the result of this measurement?
\end{exercise}

Since the $\otimes$ is getting cumbersome to write, we say:
\begin{abuse}
	From now on $\ket 0_A \otimes \ket 0_B$ will be abbreviated
	to just $\ket{00}$, and similarly for $\ket{01}$, $\ket{10}$, $\ket{11}$.
\end{abuse}

\begin{example}
	[Simultaneously measuring a general $2$-Qubit state]
	\label{ex:simult_measurement}
	Consider a normalized state $\ket\psi$ in
	$H = \CC^{\oplus 2} \otimes \CC^{\oplus 2}$, say
	\[ \ket\psi = \alpha\ket{00} + \beta\ket{01}
		+ \gamma\ket{10} + \delta\ket{11}. \]
	We can make a measurement along the diagonal matrix
	$T : H \to H$ with
	\[ T(\ket{00}) = 0\ket{00}, \quad
	T(\ket{01}) = 1\ket{01}, \quad
	T(\ket{10}) = 2\ket{10}, \quad
	T(\ket{11}) = 3\ket{11}. \]
	Thus we get each of the eigenvalues $0$, $1$, $2$, $3$
	with probability $|\alpha|^2$, $|\beta|^2$, $|\gamma|^2$, $|\delta|^2$.
	So if we like we can make ``simultaneous'' measurements on two qubits
	in the same way that we make measurements on one qubit.
\end{example}

However, some states behave very weirdly.
\begin{example}[The singlet state]
	Consider the state
	\[
		\ket{\Psi_-}
		=
		\frac{1}{\sqrt2} \ket{01}
		- \frac{1}{\sqrt2} \ket{10}
	\]
	which is called the \vocab{singlet state}.
	One can see that $\ket{\Psi_-}$ is not a simple tensor,
	which means that it doesn't just consist of two qubits side by side:
	the qubits in $H_A$ and $H_B$ have become \emph{entangled}.

	Now, what happens if we measure just the qubit $A$?
	This corresponds to making the measurement
	\[ T = \sigma_z^A \otimes \id_B. \]
	The eigenspace decomposition of $T$ can be described as:
	\begin{itemize}
		\ii The span of $\ket{00}$ and $\ket{01}$, with eigenvalue $+1$.
		\ii The span of $\ket{10}$ and $\ket{11}$, with eigenvalue $-1$.
	\end{itemize}
	So one of two things will happen:
	\begin{itemize}
		\ii With probability $\half$, we measure $+1$
		and the collapsed state is $\ket{01}$.
		\ii With probability $\half$, we measure $-1$
		and the collapsed state is $\ket{10}$.
	\end{itemize}
	But now we see that measurement along $A$ has told us what the
	state of the bit $B$ is completely!
\end{example}
By solely looking at measurements on $A$, we learn $B$;
this paradox is called \emph{spooky action at a distance},
or in Einstein's tongue, \vocab{spukhafte Fernwirkung}.
Thus,
\begin{moral}
	In tensor products of Hilbert spaces,
	states which are not pure tensors
	correspond to ``entangled'' states.
\end{moral}

What this really means is that the qubits cannot be described independently;
the state of the system must be given as a whole.
That's what entangled states mean: the qubits somehow depend on each other.

\section\problemhead

\begin{problem}
	We measure $\ket{\Psi_-}$ by $\sigma_x^A \otimes \id_B$,
	and hence obtain either $+1$ or $-1$.
	Determine the state of qubit $B$ from this measurement.
	\begin{hint}
		Rewrite $\ket{\Psi_-} = -\frac{1}{\sqrt2}
		\left( \xup_A\otimes\xdown_B - \xdown_A\xup_B \right)$.
	\end{hint}
	\begin{sol}
		By a straightforward computation,
		we have $\ket{\Psi_-} = -\frac{1}{\sqrt2}
		\left( \xup_A\otimes\xdown_B - \xdown_A\xup_B \right)$.
		Now, $\xup_A \otimes \xup_B$, $\xup_A \otimes \xdown_B$
		span one eigenspace of $\sigma_x^A \otimes \id_B$,
		and $\xdown_A \otimes \xup_B$, $\xdown_A \otimes \xdown_B$
		span the other. So this is the same as before:
		$+1$ gives $\xdown_B$ and $-1$ gives $\xdown_A$.
	\end{sol}
\end{problem}

\begin{problem}
	[Greenberger-Horne-Zeilinger paradox]
	Consider the state in $(\CC^{\oplus2})^{\otimes 3}$
	\[
		\ket{\Psi}_{\text{GHZ}}
		=
		\frac{1}{\sqrt2}
		\left( \ket0_A \ket0_B \ket0_C
		- \ket1_A \ket1_B \ket1_C \right).
	\]
	Find the value of the measurements along each of
	\[ \sigma_y^A \otimes \sigma_y^B \otimes \sigma_x^C , \quad
		\sigma_y^A \otimes \sigma_x^B \otimes \sigma_y^C, \quad
		\sigma_x^A \otimes \sigma_y^B \otimes \sigma_y^C, \quad
		\sigma_x^A \otimes \sigma_x^B \otimes \sigma_x^C.
	\]
	As for the paradox: what happens if you multiply all these measurements together?
	\begin{hint}
		$-1$, $1$, $1$, $1$.
		When we multiply them all together,
		we get that $\id^A \otimes \id^B \otimes \id^C$
		has measurement $-1$, which is the paradox.
		What this means is that the values of the measurements
		are created when we make the observation,
		and not prepared in advance.
	\end{hint}
\end{problem}


\documentclass{subfile}

\begin{document}
	\section{The Buffalo Way}\label{sec:buffalo}
	\index{The buffalo way}\emph{The buffalo way} is a \emph{bashing} method of solving inequality problems. It usually exploits symmetry or cyclic property and involves tedious calculations, so it is not always elegant. Nonetheless it is a useful tool. The idea is to assume something like $a\leq b\leq c$ without losing any generality, specially when there is symmetry. In general, we want to assume that
		\begin{align*}
			a_1
				& \leq a_2\leq\cdots\leq a_n\\
			a_2
				& = a_1+b_1\\
				& \vdots\\
			a_n
				& = a_1+b_n
		\end{align*}
	We can also assume the following.
		\begin{align*}
			a_2
				& = a_1+c_1\\
			a_3
				& = a_2+c_2\\
				& = a_1+c_1+c_2\\
				& \vdots\\
			a_n
				& = a_{n-1}+c_{n-1}\\
				& = a_1+c_1+\ldots+c_{n-1}
		\end{align*}
	where $c_1,\ldots,c_{n-1}\geq0$. Out of these two forms, the latter is actually a consequence of the former one and is usually the more used one. We will see a few problems that implement this technique.
		\begin{problem}
			Prove that for two non-negative reals $x,y$
				\begin{align*}
					x+y
						& \geq2\sqrt{xy}
				\end{align*}
		\end{problem}

		\begin{solution}
			Since the inequality is symmetric on $x$ and $y$, we can assume without loss of generality that $x\leq y$. Let $y=x+k$.
				\begin{align*}
					x+y
						& \geq2\sqrt{xy}\\
					\iff2x+k
						& \geq2\sqrt{x(x+k)}\\
					\iff4x^2+4xk+k^2
						& \geq4x^2+4xk\\
					\iff k^2
						& \geq0
				\end{align*}
			which is evident.
		\end{solution}
	Try proving the case $n=3$ of arithmetic-geometric mean inequality with this technique. You will understand why we said this is often a tedious technique.
		\begin{problem}
			\begin{align*}
				x+y+z
					& \geq3\sqrt[3]{xyz}
			\end{align*}
		\end{problem}
	Let us also prove the following using buffalo way.
		\begin{problem}
			Let $a,b,c>0$ be real numbers. Prove that
				\begin{align*}
					a^2+b^2+c^2
						& \geq ab+bc+ca
				\end{align*}
		\end{problem}

		\begin{solution}
			Assume that $a\leq b\leq c$ and $b=a+x,c=a+x+y$ where $x,y\geq0$.
				\begin{align*}
					a^2+(a+x)^2+(a+x+y)^2
						& \geq a(a+x)+(a+x)(a+x+y)+(a+x+y)a\\
					\iff 3a^2+2x^2+y^2+4ax+2xy+2ay
						& \geq 3a^2+x^2+4ax+2ay+2xy\\
					\iff x^2+y^2
						& \geq0
				\end{align*}
			This is again true.
		\end{solution}

		\begin{problem}
			Let $a,b,c\geq0$ be real numbers such that $a\leq b\leq c$. Prove that
				\begin{align*}
					(a+b)(c+a)^2
						& \geq6abc
				\end{align*}
		\end{problem}

		\begin{solution}
			Since $a\leq b\leq c$, let $b=a+x,c=a+x+y$.
				\begin{align*}
					(2a+x)(2a+x+y)^2
						& \geq6a(a+x)(a+x+y)\\
					\iff(2a+x)(4a^2+x^2+y^2+4ax+4ay+2xy)
						& \geq6a(a^2+2ax+x^2+ay+xy)\\
					\iff8a^3+12a^2x+8a^2y+6ax^2+8axy+2ay^2+x^3+2ax^2+xy^2
						& \geq6a^3+12a^2+6ax^2+6a^2y+6axy\\
					\iff 2a^3+2a^2y+2axy+2ay^2+x^3+2x^2y+xy^2
						& \geq0
				\end{align*}
			This evidently true.
		\end{solution}
	Now, we will prove Nesbitt's inequality using the first form of the buffalo way.
		\begin{proof}[Proof of Nesbitt's inequality by the buffalo way]
			Let $x\leq y\leq z$ and $y=x+a,z=y+b$ with $a\geq0,b\geq0$. We are required to prove that
				\begin{align*}
					\dfrac{x}{y+z}+\dfrac{y}{z+x}+\dfrac{z}{x+y}
						& \geq\dfrac{3}{2}
				\end{align*}
			Let us express each variable as a parameter of a single variable.
				\begin{align*}
					\dfrac{y-a}{2y+b}+\dfrac{y}{2y+b-a}+\dfrac{y+b}{2y-a}
						& \geq\dfrac{3}{2}\\
					\iff\dfrac{y-a}{2y+b}-\dfrac{1}{2}+\dfrac{y}{2y+b-a}-\dfrac{1}{2}+\dfrac{y+b}{2y-a}-\dfrac{1}{2}
						& \geq0\\
					\iff\dfrac{1}{2}\left(\dfrac{2y-2a-2y-b}{2y+b}+\dfrac{2y-2y-b+a}{2y+b-a}+\dfrac{2y+2b-2y+a}{2y-a}\right)
						& \geq0\\
					\iff-\dfrac{2a+b}{2y+b}+\dfrac{a-b}{2y+b-a}+\dfrac{2b+a}{2y-a}
						& \geq0
				\end{align*}
			The last inequality actually holds because of the following:
				\begin{align*}
					\dfrac{2b+a}{2y-a}+\dfrac{a-b}{2y+b-a}-\dfrac{2a+b}{2y+b}
						& \geq\dfrac{2b+a}{2y+b-a}+\dfrac{a-b}{2y+b-a}-\dfrac{2a+b}{2y+b}\\
						& \geq\dfrac{2a+2b}{2y+b-a}-\dfrac{2a+b}{2y+b}\\
						& \geq\dfrac{2a+2b}{2y+b}-\dfrac{2a+b}{2y+b}\\
						& = \dfrac{a}{2y+b}
				\end{align*}
			which is obviously at least $0$. Here, we have used the facts that $\frac{1}{x}\geq\frac{1}{y}$ implies $\frac{1}{x-u}\geq\frac{1}{y}$ and $\frac{1}{x}\geq\frac{1}{y+v}$ for $u,v\geq0$.
		\end{proof}
	The next inequality is a nice application of the buffalo way.
		\begin{problem}
			Let $x,y,z>0$ be real numbers such that no two are equal. Show that,
				\begin{align*}
					\dfrac{1}{(x-y)^2}+\dfrac{1}{(y-z)^2}+\dfrac{1}{(z-x)^2}
						& \geq\dfrac{4}{xy+yz+zx}
				\end{align*}
		\end{problem}

		\begin{solution}
			The expression on the left is symmetric on $x,y,z$. Without loss of generality, assume that $x\leq y\leq z$ and $y=x+a,z=x+a+b$.
				\begin{align*}
					\dfrac{1}{a^2}+\dfrac{1}{b^2}+\dfrac{1}{(a+b)^2}
						& \geq\dfrac{4}{x(x+a)+(x+a)(x+a+b)+(x+a+b)x}\\
						& = \dfrac{4}{x^2+xa+x^2+2ax+a^2+bx+ab+x^2+xa+bx}\\
						& \geq \dfrac{4}{3x^2+4xa+2xb+ab+a^2}
				\end{align*}
			Note that there is no $x$ on the left side of the inequality. So, we can use $x>0$ to get rid of it.
				\begin{align*}
					3x^2+4xa+2xb+ab+a^2
						& > ab+a^2\\
					\dfrac{4}{3x^2+4xa+2xb+ab+a^2}
						& <\dfrac{4}{ab+a^2}
				\end{align*}
			So, we are done if we can prove the following.
				\begin{align*}
					\dfrac{1}{a^2}+\dfrac{1}{b^2}+\dfrac{1}{(a+b)^2}
						& \geq\dfrac{4}{ab+a^2}\\
						& = \dfrac{4}{a(b+a)}
				\end{align*}
			This is not a trivial inequality. We have to show that this actually holds.
				\begin{align*}
					\dfrac{1}{a^2}+\dfrac{1}{b^2}-\dfrac{2}{a(b+a)}+\dfrac{1}{(a+b)^2}
						& \geq\dfrac{2}{a(b+a)}\\
					\iff\dfrac{1}{b^2}+\left(\dfrac{1}{a}-\dfrac{1}{a+b}\right)^2
						& \geq\dfrac{2}{a(a+b)}\\
					\iff\dfrac{1}{b^2}+\left(\dfrac{b}{a(a+b)}\right)^2
						& \geq\dfrac{2}{a(a+b)}\\
					\iff\dfrac{1}{b^2}+\dfrac{b^2}{a^2(a+b)^2}
						& \geq\dfrac{2}{a(a+b)}
				\end{align*}
			The last inequality is true by arithmetic-geometric mean inequality since
				\begin{align*}
					\dfrac{1}{b^2}+\dfrac{b^2}{a^2(a+b)^2}
						& \geq2\sqrt{\dfrac{1}{b^2}\cdot\dfrac{b^2}{a^2(a+b)^2}}\\
						& = \dfrac{2}{a(a+b)}
				\end{align*}
		\end{solution}
	Solve the next problem as an exercise.
		\begin{problem}
			For all real $x,y,z\geq0$, prove that
				\begin{align*}
					\dfrac{x^3+y^3+z^3}{x^2y+y^2z+z^2x}
						& \geq\sum\dfrac{x}{y+z}-1
				\end{align*}
		\end{problem}
\end{document}


\section{Fat Tails}
Roughly speaking, the consequences of ``fat tails" is that rare events tend to play a disproportionally large role in determining the statistical properties of a sample. This is in contrast to ``thin tails", where, as the sample size increases, pretty quickly no single observation modifies the statistical properties of the sample.

For ``thin tails", extreme observations tend to result from the combination of several very unlikely events. For ``fat tails", an extreme observation tend result from a single very unlikely event.

\subparagraph{Thin Tails}
Two people are randomly selected, and their combined height is 4 meters. Most likely this resulted from the selection of two people who are two meters tall, rather than one person that is 10 cm and another that is 3,90 m tall.

\subparagraph{Fat Tails}
Two people are randomly selected, and their combined net worth is \$ 40M. The probability of having selected two people with a net work of \$ 20M is less likely than having selected one person with a net worth of \$ 200k and another person with a net worth of \$ 39,8 M.

Fat tails do not imply that rare events are more frequent, but that they have greater impact when they do happen. In fact, ``fattening" the tails of a Gaussian distribution results in a larger number of observations within one standard deviation.

\begin{figure}
\centering
    \includegraphics[width=\textwidth]{fattails01.png}
    \caption{Probability densities of two independent thin tailed and thick tailed random variables (brazenly copied from Taleb, 2020). Compare to plot of Lp norms. For the thin tailed random variables, the observa- tion of a particular sum is most likely to result from a balanced contribution from both random variables. For the fat tailed random variables, the observation of a particular sum is most likely to result from the contribution of one of the variables.}
    \label{fig:fattails01}
\end{figure}

\subsection{Consequences of Fat Tails}

\begin{figure}
\centering
    \includegraphics[width=\textwidth]{fattailstudentt02.png}
    \caption{Behavior of the sample mean as a function of sample size for standard Student-t distributions with different degrees of freedom.}
    \label{fig:fattails02}
\end{figure}

\begin{figure}
\centering
    \includegraphics[width=\textwidth]{fattailsstudentt01.png}
    \caption{Behavior of the variance of the sample mean as a function of sample size for standard Student-t distributions with different degrees of freedom.}
    \label{fig:fattails03}
\end{figure}

\subparagraph{The Law of Large Numbers works too Slowly}

\subparagraph{The Sample Mean will rarely correspond to the Distribution Mean}
For example, for an 80/20 power law, 92\% of the observations will fall below the distribution mean. The sample mean will tend to underestimate the distribution mean because the distribution mean is heavily biased by rare observations that will tend to be underrepresented in the sample.

\subparagraph{Metrics such as Sample Mean and Sample Variance will be Unusable}

\subparagraph{In finance, metrics like Sharp etc. are unusable}

\subparagraph{Gauss-Markov Theorem fails}
Therefore, linear least squares regressions do not work.

\subparagraph{Maximum Likelihood Methods can still work}
For example in case of a Pareto distribution, it is possible to fit the tail exponent using maximum likelihood methods, and estimating the mean from there. Direct observation of the mean would be misleading. The tail exponent intelligently extrapolates the fat tails of the distribution.

\subparagraph{Absence of Evidence $\neq$ Evidence of Absence}

\subparagraph{PCA is going to cause spurious factors and loads}

\subparagraph{Method of Moments does not work}
Approximating a distribution by matching its moments does not work when higher moments are undefined or cannot be reliably estimated.

\subparagraph{There is no ``typical" large deviation}

\subsection{Maximum to Sum}
The "maximum to sum" or MS plot allows to see the behavior of the relationship between the observed maximum to the sum for a particular moment as the number of observations increases.

\subsection{Maximum Domain of Attraction}

The ``maximum domain of attraciton" is, so to speak, the ``right endpoint of the distribution":

\begin{equation}
x^* = \sup\{x: F(x) < 1 \}
\end{equation}

\subsection{Hidden Tail, Problems in Estimating Moments}
The Glivenko-Cantelli theorem guarantees uniform convergence of the empiral cdf to the true CDF, however, the empirical distribution is necessarily bounded by the values of the minimum and maximum observations. This results in an unobserved contribution to moments $p>0$ that does not necessarily have to be negligible. To illustrate, take $K_n$ to be the maximum observed value.
\begin{equation}
\mathbb{E}(X^p) = \underbrace{\int_{L}^{K_n} x^p \phi(x)\mathrm{d}x}_{observed} + \underbrace{\int_{K_n}^{\infty} x^p \phi(x)\mathrm{d}x}_{unobserved}
\end{equation}


\section{Reorderings and fluctuations}
\label{sec:heap-reordering}

One particular challenge posed by heap algorithms is that
while temporarily causing \emph{small fluctuations} in the number of values
within an array they essentially only \emph{reorder} it,
that is they leave the multiset of its values unchanged.
In this section we will introduce various predicates that will help
us mastering this challenge.

\subsection{Formalizing small fluctuations}

The predicate \MultisetAdd in the following listing
expresses that the number of occurrences of a specific element in an array
has increased by one between two program points~\inl{K} and~\inl{L}.

\input{Listings/MultisetOperations.acsl.tex}

The predicate \MultisetMinus, on the other hand,
expresses that the number of occurrences of a specific element in an array
has decreased by one between two program points~\inl{K} and~\inl{L}.
Note that we have defined \MultisetMinus by calling \MultisetAdd
with the labels reversed.
%
Finally, the predicate \MultisetRetain expresses that a the number
of occurrences of a given value does not change between two program points.
In order to guide the automatic provers, we also provide some
lemmas that formalize conditions under which the respective predicates hold.

Using the predicate \logicref{MultisetReorder} and the logic function \logicref{At}
we also formulate a few simple lemmas that describe when the
predicates from Listing~\logicref{MultisetOperations} hold.

\subsection{Simple properties of fluctuations}

The predicate \logicref{MultisetRetainRest} uses \logicref{MultisetRetain}
in order to express that all values of an array,
except the two given values \inl{u} and \inl{v}, occur as often in program
point \inl{K} and program point \inl{L}.

The lemmas in this listing express conditions under which small
fluctuations---expressed by the predicates \logicref{MultisetAdd}
and \logicref{MultisetMinus}---in the number of occurrences between three
program points even with each other.

\input{Listings/MultisetRetainRest.acsl.tex}

\subsection{Combining fluctuations}

Small fluctuations are so prevalent in the central heap algorithms \implref{pushheap}
and \implref{popheap} that it is worthwhile to introduce another predicate
to concisely capture this feature.
We refer to this predicate as \logicref{MultisetParity} because it describes
the situation where the number of occurrences

\begin{itemize}
\item of the first of two given values increases by one
\item while that of the second value decreases by one
\item and the remaining values retain their respective number of occurrences.
\end{itemize}

With this predicate we can formulate several lemmas that describe useful
combinations of reorderings and fluctuations.
For example, lemma \logicref{MultisetParityMultisetReorder} describes
the situation where two fluctuation cancel each other and consequently
establish a reordering of an array.

\input{Listings/MultisetParity.acsl.tex}

\subsection{How do fluctuations arise?}

The simplest way to creation a small fluctuation is to
update an array element with a different value.
Thus, similar to the predicate \logicref{ArrayUpdate} we introduce
predicate \logicref{MultisetUpdate} which in turn relies on \logicref{MultisetParity}.
Lemma \logicref{ArrayUpdateMultisetUpdate} then formalizes the claim
that updating an array element with a different value creates a small fluctuation.

\input{Listings/MultisetUpdate.acsl.tex}

\clearpage


\section{Conclusions}
\SecLabel{conclusions}

This work started by observing interesting patterns in the LAT modulo 8 of small Feistel Networks. The analysis of the patterns resulted in the definition of High-Degree Indicator Matrix (HDIM). This tool shows a link between the LAT and the highest-degree monomials in the ANF. Furthermore, its properties allow to prove upper bounds on the algebraic degree of cryptographic structures and to prove finer algebraic degeneracies. Though these results do not improve the state of the art, the upper bounds given are expressed in a simple closed formula and there is a room for improvement, e.g. by combining methods. Finally, the most useful application of HDIM is in the cryptanalysis of Feistel Networks masked with secret affine layers. The generalized HDIM-motivated ideas allow to prove lower-degree degeneracies as well, i.e. impossible monomials. I show how they can be used to mount decomposition attacks on Feistel Networks. The results of this chapter together allow to fully decompose affinely-whitened Feistel Networks satisfying the attack conditions. I think it provides many useful tools for S-Box reverse-engineering and white-box analysis toolkit.

The work leaves several open problems:
\begin{enumerate}
    \item Better degree evaluation. Is it possible to improve the HDIM-motivated method? Is it possible to combine it with other methods, e.g. division property?

    \item Proving Conjecture~\Ref{conj:impmono}. Are there always enough impossible monomials to recover the last Feistel function, if the type-II distinguisher applies?

    \item In which cases it is possible to decompose Feistel Networks having at least 1 more round than Feistel Networks satisfying the type-II distinguisher?

    \item A big open problem: lower bounds in Feistel Networks or Substitution-Permutation Networks. How to prove non-trivial lower bounds on the degree of a structure, i.e. that at least one instance of the structure has high enough degree? Strong lower bounds could shed light on how close are current degree evaluation methods to optimal ones.
\end{enumerate}