\documentclass[11pt]{article}

\usepackage{amsmath,amssymb,latexsym}
\usepackage{verbatim}
\usepackage{braket}
\usepackage{fullpage}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}

%% disables automatic indentation
%% sets indent command to allow for manual indentation
\newlength\tindent
\setlength{\tindent}{\parindent}
\setlength{\parindent}{0pt}
\renewcommand{\indent}{\hspace*{\tindent}}

%% User-defined Commands %%

\newcommand{\cop}[2]{% \cop{<state index>}{<spin index>}
	\ensuremath{ \hat{a} _{#1 #2} ^{\dagger} }}

\newcommand{\aop}[2]{% \aop{<state index>}{<spin index>}
	\ensuremath{ \hat{a} _{#1 #2} }}

\newcommand{\pcop}[1]{% \pcop{<state index>}
	\ensuremath{ \cop{#1}{+} \cop{#1}{-} } }

\newcommand{\paop}[1]{% \paop{<state index>}
	\ensuremath{ \aop{#1}{-} \aop{#1}{+} } }

\newcommand{\cpm}[1]{% \cpm{<state index>}
	\ensuremath{\cop{#1}{+} \cop{#1}{-} }}

\newcommand{\amp}[1]{% \apm{<state index>}
	\ensuremath{ \aop{#1}{-} \aop{#1}{+} } }

\newcommand{\sz}[2]{% \sz{<<state index>}{<spin index>>}
	\ensuremath{ \frac{1}{2} \sum_{#1 #2} #2 a _{#1 #2} ^{\dagger} a _{#1 #2} } }

\newcommand{\splus}[1]{% \splus{<state index>}
	\ensuremath{ \sum_{#1}  a _{#1 +} ^{\dagger} a _{#1 -} } }

\newcommand{\sminus}[1]{% \sminus{<state index>}
	\ensuremath{ \sum_{#1}  a _{#1 -} ^{\dagger} a _{#1 +} } }

\newcommand{\hzero}[2]{% \hzero{<state index>}{<spin index>}
	\ensuremath{ \sum_{#1 #2} (#1-1) a _{#1 #2} ^{\dagger} a _{#1 #2} }}

\newcommand{\hfull}[4]{% \hfull{<index 1>}{<index 2>}{<index 3>}{<index 4>}
	\ensuremath{\sum_{#1 #2} (#1 - 1) \cop{#1}{#2} \aop{#1}{#2} - g \sum_{#3 #4} \hat{P} ^+ _{#3} \hat{P} ^- _{#4}  } }

\newcommand{\twobody}[2]{% \twobody{<first index>}{<second index>}
	\ensuremath{ \sum_{#1 #2} (-g) \cop{#1}{+} \cop{#1}{-} \aop{#2}{-} \aop{#2}{+}  } }

\newcommand{\caop}[2]{% \caop{<1st indx>}{<2nd indx>}
	\ensuremath{ \cop{#1}{#2} \aop{#1}{#2} } }

\newcommand{\numop}[2]{% \numop{<state index>}{<spin index>}
	\ensuremath{ \hat{n} _{#1 #2} }}

\newcommand{\nop}[2]{% \nop{<state index>}{<spin index>}
	\ensuremath{ \cop{#1}{#2} \aop{#1}{#2}} }

\newcommand{\sop}[1]{% \sop{<z,+,->}
	\ensuremath{ \hat{S}_{#1} } }

\newcommand{\krondelt}[2]{% \krondelt{<idx 1>}{<idx 2>}
	\ensuremath{ \delta _{#1 #2} }}

\newcommand{\sopz}{
	\ensuremath{ \hat{S} _{z} } }

\newcommand{\sopp}{
	\ensuremath{ \hat{S} _{+} } }

\newcommand{\sopm}{
	\ensuremath{ \hat{S} _{-} } }

\newcommand{\hop}{
	\ensuremath{ \hat{H} _0 }}

\newcommand{\ssop}{
	\ensuremath{ \hat{S} ^2} }

\newcommand{\vop}{
	\ensuremath{ \hat{V} } }

\newcommand{\ppop}[1]{% \ppop{<index>}
	\ensuremath{ \hat{P} _{#1} ^+ } }

\newcommand{\pmop}[1]{% \ppop{<index>}
	\ensuremath{ \hat{P} _{#1} ^- } }

\newcommand{\commutator}[2]{% \commutator{<1st op>}{<2nd op>}}
	\ensuremath{ \left [ #1,#2 \right ] }}

\newcommand{\commutatorexp}[2]{% \commutatorexp{1st op}{<2nd op>}
	\ensuremath{ #1 #2 - #2 #1 } }

\newcommand{\ssqr}{% sum form of S^2
	\ensuremath{ \sopz ^2 + \frac{1}{2} ( \sopp \sopm + \sopm \sopp ) } }

\newcommand{\vacuumb}{
	\ensuremath{ \Bra{0} } }

\newcommand{\vacuumk}{
	\ensuremath{ \Ket{0} } }

\title{Pairing Model}
\author{Xingze Mao \\ Zachary Matheson \\ Thomas Redpath}
%\date{}

\begin{document}

\maketitle

\section*{\hop commutation relations}

Show that the unperturbed Hamiltonian commutes with the spin projection \sop{z}:

\begin{align*}
	\left [ H _0, \sop{z} \right ] &=\\
	&=\left ( \hzero{p}{\sigma} \right ) \left ( \sz{p'}{\sigma'} \right ) -\\
	& \hspace{5mm} \left ( \sz{p''}{\sigma''} \right ) \left ( \hzero{p'''}{\sigma'''} \right )\\
	&= \frac{1}{2} \sum_{p \sigma p' \sigma'} (p-1) \sigma' \numop{p}{\sigma} \numop{p'}{\sigma'} - \frac{1}{2} \sum_{p'' \sigma'' p''' \sigma'''} (p'''-1) \sigma'' \numop{p''}{\sigma''} \numop{p'''}{\sigma'''}
\end{align*}

In this form it is apparent that these two sums are identical and cancel to give $[\hat{H}_0,\sop{z}]=0$.

Show that the unperturbed Hamiltonian commutes with the total spin squared operator $\hat{S}^2$:

\begin{align}
	\left [ \hat{H}_0, \hat{S}^2 \right ] &= \left [ \hop, \sop{z} ^2 \right ] + \frac{1}{2} \left [ \hop,(\sop{+} \sop{-} + \sop{-}\sop{+}) \right ]\\
	&= \commutator{\hop}{\sop{z}} \sop{z} + \sop{z} \commutator{\hop}{\sop{z}} +\frac{1}{2} \commutator{\hop}{(\sop{+}\sop{-} + \sop{-}\sop{+})}\\
	&= \frac{1}{2} \left ( \commutator{\hop}{\sop{+}} \sop{-} + \sop{+} \commutator{\hop}{\sop{-}} + \commutator{\hop}{\sop{-}} \sop{+} + \sop{-} \commutator{\hop}{\sop{+}} \right )
\end{align}

Now consider the commutators \commutator{\hop}{\sop{+}} and \commutator{\hop}{\sop{-}}.

\begin{equation}
	\commutator{\hop}{\sop{+}} = \left ( \hzero{p}{\sigma} \right ) \left ( \splus{p'} \right ) - \left ( \splus{p''} \right ) \left ( \hzero{p'''}{\sigma'''} \right )
	\label{eq:hsplus}
\end{equation}

Using the anti-commutation relations of the creation and annihilation operators, we can show that the first product of sums in eq.~\ref{eq:hsplus} contains the second and therefore, $ \commutator{\hop}{\sop{+}} =0$. Focusing on the first product of sums in eq.~\ref{eq:hsplus}:

\begin{align}
	& \sum_{p \sigma p'} (p-1) \cop{p}{\sigma} \aop{p}{\sigma} \cop{p'}{+} \aop{p'}{-}\\
	&= \sum_{p \sigma p'} (p-1) \cop{p}{\sigma} \left (\krondelt{p}{p'} \krondelt{\sigma}{+} -  \cop{p'}{+} \aop{p}{\sigma} \right ) \aop{p'}{-}\\
	&= \sum_{p \sigma p'} (p-1) \left ( \krondelt{p}{p'} \krondelt{\sigma}{+} \cop{p}{\sigma} \aop{p'}{-} - \cop{p}{\sigma}  \cop{p'}{+} \aop{p}{\sigma} \aop{p'}{-} \right )\\
	&= \sum_{p \sigma p'} (p-1) \left ( \krondelt{p}{p'} \krondelt{\sigma}{+} \cop{p}{\sigma} \aop{p'}{-} - \cop{p'}{+} \cop{p}{\sigma} \aop{p'}{-} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma p'} (p-1) \left ( \krondelt{p}{p'} \krondelt{\sigma}{+} \cop{p}{\sigma} \aop{p'}{-} - \cop{p'}{+} \left ( \krondelt{p}{p'} \krondelt{\sigma}{-} - \aop{p'}{-} \cop{p}{\sigma} \right ) \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma p'} (p-1) \left ( \krondelt{p}{p'} \krondelt{\sigma}{+} \cop{p}{\sigma} \aop{p'}{-} - \krondelt{p}{p'} \krondelt{\sigma}{-} \cop{p'}{+} \aop{p}{\sigma} + \cop{p'}{+} \aop{p'}{-} \cop{p}{\sigma} \aop{p}{\sigma} \right )\\
%	&= \sum_{p}  \left ( (p-1) \cop{p}{+} \aop{p}{-} \right ) + \sum_{p} \left ( (p-1) \cop{p}{+} \aop{p}{-} \right ) + \sum_{p \sigma p'} (p-1) \left ( \cop{p'}{+} \aop{p'}{-} \cop{p}{\sigma} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma p'} (p-1) \left ( \cop{p'}{+} \aop{p'}{-} \cop{p}{\sigma} \aop{p}{\sigma} \right )
\end{align}

Comparing the results of this calculation with the second product of sums in eq.~\ref{eq:hsplus}, which, reordering indicies, we can write as

\begin{align*}
	& \sum_{p'' p''' \sigma} (p''' -1) \left ( \cop{p''}{+} \aop{p''}{-}\cop{p'''}{\sigma'''}\aop{p'''}{\sigma'''} \right )\\
	&= \sum_{p \sigma p' } (p' -1) \left ( \cop{p}{+} \aop{p}{-} \cop{p'}{\sigma'} \aop{p'}{\sigma'} \right )
\end{align*}

\noindent we notice that the two terms cancel leaving $ \commutator{\hop}{\sop{+}} =0$.

Using the same procedure, we can show that $ \commutator{\hop}{\sop{-}} = 0$. With these results, we find that $\commutator{\hop}{\ssop} = 0$.

\section*{\vop commutation relations}

Show that \vop commutes with \sop{z}:

\begin{align}
\begin{split}
	\commutator{\vop}{\sop{z}} &= \left ( \twobody{q}{s} \right ) \left ( \sz{p}{\sigma} \right )\\
	& - \left( \sz{p'}{\sigma'} \right ) \left ( \twobody{q'}{s'} \right )
\end{split}
\label{eq:comvsz}
\end{align}

The first term may be re-written:

\begin{align*}
	& \frac{(-g)}{2} \sum_{qs p \sigma} \sigma \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} \cop{p}{\sigma} \aop{p}{\sigma}\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \sigma \cop{q}{+} \cop{q}{-} \aop{s}{-} \left ( \krondelt{s}{p} \krondelt{+}{\sigma} - \cop{p}{\sigma} \aop{s}{+} \right ) \aop{p}{\sigma}\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \krondelt{s}{p} \krondelt{+}{\sigma} \sigma \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{p}{\sigma} - \sigma \cop{q}{+} \cop{q}{-} \aop{s}{-} \cop{p}{\sigma} \aop{s}{+} \aop{p}{\sigma} \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \krondelt{s}{p} \krondelt{+}{\sigma} \sigma \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{p}{\sigma} - \sigma \cop{q}{+} \cop{q}{-} \left ( \krondelt{s}{p} \krondelt{-}{\sigma} - \cop{p}{\sigma} \aop{s}{-} \right ) \aop{s}{+} \aop{p}{\sigma} \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \krondelt{s}{p} \krondelt{+}{\sigma} \sigma \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{p}{\sigma} - \krondelt{s}{p} \krondelt{-}{\sigma} \sigma \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{p}{\sigma} + \sigma \cop{q}{+} \cop{q}{-} \cop{p}{\sigma} \aop{s}{-} \aop{s}{+} \aop{p}{\sigma}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( (+) \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} -  (-) \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{-} + \sigma \cop{p}{\sigma} \cop{q}{+} \cop{q}{-} \aop{p}{\sigma} \aop{s}{-} \aop{s}{+}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{-} + \sigma \cop{p}{\sigma} \cop{q}{+} \left ( \krondelt{q}{p} \krondelt{-}{\sigma} - \aop{p}{\sigma} \cop{q}{-} \right ) \aop{s}{-} \aop{s}{+}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{-} + \krondelt{q}{p} \krondelt{-}{\sigma} \sigma \cop{p}{\sigma} \cop{q}{+} \aop{s}{-} \aop{s}{+} - \sigma \cop{p}{\sigma} \cop{q}{+} \aop{p}{\sigma} \cop{q}{-} \aop{s}{-} \aop{s}{+}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{-} + (-) \cop{q}{-} \cop{q}{+} \aop{s}{-} \aop{s}{+} - \sigma \cop{p}{\sigma} \cop{q}{+} \aop{p}{\sigma} \cop{q}{-} \aop{s}{-} \aop{s}{+}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{-} - \cop{q}{-} \cop{q}{+} \aop{s}{-} \aop{s}{+} - \sigma \cop{p}{\sigma} \left ( \krondelt{q}{p} \krondelt{+}{\sigma} - \aop{p}{\sigma} \cop{q}{+} \right ) \cop{q}{-} \aop{s}{-} \aop{s}{+}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{-} - \cop{q}{-} \cop{q}{+} \aop{s}{-} \aop{s}{+} - \krondelt{q}{p} \krondelt{+}{\sigma} \sigma \cop{p}{\sigma} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \sigma \cop{p}{\sigma} \aop{p}{\sigma} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{-} - \cop{q}{-} \cop{q}{+} \aop{s}{-} \aop{s}{+} - \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \sigma \cop{p}{\sigma} \aop{p}{\sigma} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}  \right )\\
	& \frac{(-g)}{2} \sum_{qs p \sigma} \left ( \sigma \cop{p}{\sigma} \aop{p}{\sigma} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}  \right )\\
\end{align*}

Comparing this result to the second product of sums in eq.~\ref{eq:comvsz}, which may be re-written:

\begin{equation}
	\frac{+g}{2} \sum_{p \sigma qs} \sigma \cop{p}{\sigma} \aop{p}{\sigma} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} \nonumber
\end{equation}

the terms cancel so that $ \commutator{\vop}{\sop{z}} = 0$.

Show that \vop commutes with \ssop:

\begin{align*}
	\commutator{\vop}{\ssop} &= \commutator{\vop}{\sop{z} ^2} + \frac{1}{2} \left ( \commutator{\vop}{\sop{+} \sop{-}} + \commutator{\vop}{\sop{-} \sop{+}} \right )\\
	&= \sop{z} \commutator{\vop}{\sop{z}} +  \commutator{\vop}{\sop{z}} \sop{z} + \frac{1}{2} \left ( \sop{+} \commutator{\vop}{\sop{-}} + \commutator{\vop}{\sop{+}} \sop{-} + \sop{-} \commutator{\vop}{\sop{+}} + \commutator{\vop}{\sop{-}} \sop{+} \right )\\
	&= \frac{1}{2} \left ( \sop{+} \commutator{\vop}{\sop{-}} + \commutator{\vop}{\sop{+}} \sop{-} + \sop{-} \commutator{\vop}{\sop{+}} + \commutator{\vop}{\sop{-}} \sop{+} \right )
\end{align*}

Writing out \commutator{\vop}{\sop{-}}:

\begin{align}
\begin{split}
	\commutator{\vop}{\sop{-}} &= \left ( \twobody{q}{s} \right ) \left ( \sminus{m} \right )\\
	& - \left ( \sminus{m'} \right ) \left ( \twobody{q'}{s'} \right )
\end{split}
\label{eq:vsminus}
\end{align}

Re-writing the first prduct of sums using the anti-commutation relations and noting that in \ref{eq:vsmmk1} and \ref{eq:vsmmk2} the first terms give zero for the fermionic case since \aop{s}{+} \aop{s}{+} would act to remove a particle from an empty state and \cop{q}{-} \cop{q}{-} would act to add a particle to an occupied state.

\begin{align}
	& (-g) \sum _{q s m} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} \cop{m}{-} \aop{m}{+}\\
	& (-g) \sum _{q s m} \cop{q}{+} \cop{q}{-} \aop{s}{-} \cop{m}{-} \aop{m}{+} \aop{s}{+}\\
	& (-g) \sum _{q s m} \cop{q}{+} \cop{q}{-} \left ( \krondelt{s}{m} - \cop{m}{-} \aop{s}{-} \right ) \aop{m}{+} \aop{s}{+}\\
	& (-g) \sum _{q s m} \krondelt{s}{m} \cop{q}{+} \cop{q}{-} \aop{m}{+} \aop{s}{+} - \cop{q}{+} \cop{q}{-} \cop{m}{-} \aop{s}{-} \aop{m}{+} \aop{s}{+}\\
\label{eq:vsmmk1}	& (-g) \sum _{q s m} \cop{q}{+} \cop{q}{-} \aop{s}{+} \aop{s}{+} - \cop{q}{+} \cop{q}{-} \cop{m}{-} \aop{s}{-} \aop{m}{+} \aop{s}{+}\\
	& (-g) \sum _{q s m} - \cop{m}{-} \cop{q}{+} \aop{m}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
	& (-g) \sum _{q s m} - \cop{m}{-} \left ( \krondelt{q}{m} - \aop{m}{+} \cop{q}{+} \right ) \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
	& (-g) \sum _{q s m} - \krondelt{q}{m}\cop{m}{-} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{m}{-}  \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
\label{eq:vsmmk2}	& (-g) \sum _{q s m} - \cop{q}{-} \cop{q}{-} \aop{s}{-} \aop{s}{+} + \cop{m}{-}  \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
\label{eq:vsmres}	& (-g) \sum _{q s m} \cop{m}{-}  \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}
\end{align}

Comparing the result in \ref{eq:vsmres} to the second product of sums in eq.~\ref{eq:vsminus}, re-written here as

\begin{equation}
	g \sum _{m q s} \cop{m}{-} \cop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} \nonumber
\end{equation}

we see that $ \commutator{\vop}{\sop{-}} = 0$. Using the same procedure, we can show that $ \commutator{\vop}{\sop{+}} = 0$ and conclude that $ \commutator{\vop}{\ssop} = 0$.

\section*{Pair creation and annihilation operators}

We consider the system with total spin $S=0$ (no broken pairs) and define the pair creation and annihilation operators.

\begin{align*}
\begin{split}
	\hat{P} _p ^+ &= \pcop{p}\\
	\hat{P} _p ^- &= \paop{p}
\end{split}
\end{align*}

and the full Hamiltonian

\begin{equation}
	\hat{H} = \hfull{p}{\sigma}{q}{s}
\label{eq:fullham}
\end{equation}

Show that $\hat{H}$ commutes with the product of the pair creation and pair annihilation operators:

%\begin{itemize}
%	\item The indices on the pair creation and annihilation operators must be the same since otherwise, this would imply physically chaning the system.
%\end{itemize}

\begin{align}\label{eq:comhpac}
	\commutator{\hat{H}}{ \ppop{r} \pmop{r}} &= \commutator{\hat{H} _0}{ \ppop{r} \pmop{r}} + \commutator{\vop}{\ppop{r} \pmop{r}}
\end{align}

Taking the first commutator in eq.~\ref{eq:comhpac}:

\begin{align*}
	\commutator{\hop}{ \ppop{r} \pmop{r}} &= \left ( \hzero{p}{\sigma} \right ) \left ( \pcop{r} \paop{r} \right ) - \left ( \pcop{r} \paop{r} \right ) \left ( \hzero{p}{\sigma} \right )
\end{align*}

Re-writing the first product of sums to have the same form as the second product of sums leaves no remaining terms (\ref{eq:comhzpcap}). Thus $ \commutator{\hop}{\ppop{r} \pmop{r}}=0$.

\begin{align}
\begin{split}
	& \left ( \hzero{p}{\sigma} \right ) \left ( \pcop{r} \paop{r} \right )\\
	&= \sum_{p \sigma} (p-1) \cop{p}{\sigma} \aop{p}{\sigma} \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+}\\
	&= \sum_{p \sigma} (p-1) \cop{p}{\sigma} \left ( \krondelt{p}{r} \krondelt{\sigma}{+} - \cop{r}{+} \aop{p}{\sigma} \right ) \cop{r}{-} \aop{r}{-} \aop{r}{+}\\
	&= \sum_{p \sigma} (p-1) \left ( \krondelt{p}{r} \krondelt{\sigma}{+} \cop{p}{\sigma} \cop{r}{-} \aop{r}{-} \aop{r}{+} - \cop{p}{\sigma} \cop{r}{+} \aop{p}{\sigma} \cop{r}{-} \aop{r}{-} \aop{r}{+} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} - \cop{p}{\sigma} \cop{r}{+} \aop{p}{\sigma} \cop{r}{-} \aop{r}{-} \aop{r}{+} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{p}{\sigma} \aop{p}{\sigma} \cop{r}{-} \aop{r}{-} \aop{r}{+} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{p}{\sigma} \left ( \krondelt{p}{r} \krondelt{\sigma}{-} - \cop{r}{-} \aop{p}{\sigma} \right ) \aop{r}{-} \aop{r}{+} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \krondelt{p}{r} \krondelt{\sigma}{-} \cop{r}{+} \cop{p}{\sigma} \aop{r}{-} \aop{r}{+} - \cop{r}{+} \cop{p}{\sigma} \cop{r}{-} \aop{p}{\sigma} \aop{r}{-} \aop{r}{+} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \cop{p}{\sigma} \aop{r}{-} \aop{r}{+} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \left ( \krondelt{p}{r} \krondelt{\sigma}{-} - \aop{r}{-} \cop{p}{\sigma} \right ) \aop{r}{+} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \krondelt{p}{r} \krondelt{\sigma}{-} \cop{r}{+} \cop{r}{-} \aop{r}{+} \aop{p}{\sigma} - \cop{r}{+} \cop{r}{-} \aop{r}{-} \cop{p}{\sigma} \aop{r}{+} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \aop{r}{+} \aop{r}{-} - \cop{r}{+} \cop{r}{-} \aop{r}{-} \cop{p}{\sigma} \aop{r}{+} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} - \cop{r}{+} \cop{r}{-} \aop{r}{-} \cop{p}{\sigma} \aop{r}{+} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} - \cop{r}{+} \cop{r}{-} \aop{r}{-} \left ( \krondelt{p}{r} \krondelt{\sigma}{+} - \aop{r}{+} \cop{p}{\sigma} \right ) \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} -\krondelt{p}{r} \krondelt{\sigma}{+} \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{p}{\sigma} + \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} \cop{p}{\sigma} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} - \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} + \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} \cop{p}{\sigma} \aop{p}{\sigma} \right )\\
	&= \sum_{p \sigma} (p-1) \left ( \cop{r}{+} \cop{r}{-} \aop{r}{-} \aop{r}{+} \cop{p}{\sigma} \aop{p}{\sigma} \right )
\end{split}
\label{eq:comhzpcap}
\end{align}

Working out the second commutator from eq.~\ref{eq:comhpac}:

\begin{align}
\begin{split}
	\commutator{\vop}{\ppop{r} \pmop{t}} &= (-g) \sum _{qs} \commutator{ \ppop{q} \pmop{s} }{ \ppop{r} \pmop{r}}\\
	&= \ppop{q} \commutator{\pmop{s}}{\ppop{r}} \pmop{r} + \ppop{q} \ppop{r} \commutator{\pmop{s}}{\pmop{r}} + \commutator{\ppop{q}}{\ppop{r}} \pmop{s} \pmop{r} +  \ppop{r} \commutator{\ppop{q}}{\pmop{r}} \pmop{s}
%&= \left ( -g \sum_{q s} \hat{P} ^+ _{q} \hat{P} ^- _{s} \right ) \left ( \ppop{r} \pmop{r} \right ) - \left ( \ppop{r} \pmop{r} \right ) \left ( -g \sum_{q s} \hat{P} ^+ _{q} \hat{P} ^- _{s} \right )
\end{split}
\label{eq:ctpcom}
\end{align}

The commutation relations between pair creation and annihilation operators were found to be:

\begin{align*}
	\commutator{\ppop{p}}{\pmop{q}} &= \cop{p}{+} \cop{p}{-} \aop{q}{-} \aop{q}{+} - \aop{q}{-} \aop{q}{+} \cop{p}{+} \cop{p}{-}
\end{align*}

Re-writing the first term

\begin{align*}
	& \cop{p}{+} \cop{p}{-} \aop{q}{-} \aop{q}{+}\\
	& \cop{p}{+} \left ( \krondelt{p}{q} - \aop{q}{-} \cop{p}{-} \right ) \aop{q}{+}\\
	& \cop{p}{+} \aop{p}{+} - \cop{p}{+} \aop{q}{-} \cop{p}{-} \aop{q}{+}\\
	& \cop{p}{+} \aop{p}{+} - \aop{q}{-} \cop{p}{+} \aop{q}{+} \cop{p}{-}\\
	& \cop{p}{+} \aop{p}{+} - \aop{q}{-} \left ( \krondelt{p}{q} - \aop{q}{+} \cop{p}{+} \right ) \cop{p}{-}\\
	& \cop{p}{+} \aop{p}{+} -  \aop{p}{-} \cop{p}{-} + \aop{q}{-} \aop{q}{+} \cop{p}{+} \cop{p}{-}\\
\end{align*}

cancels the second leaving

\begin{equation}
	\commutator{\ppop{p}}{\pmop{q}} = \cop{p}{+} \aop{p}{+} -  \aop{p}{-} \cop{p}{-} \nonumber
\end{equation}

Generalizing the form for the commutation relation between \ppop{p} and \pmop{q}

\begin{align}
\begin{split}
	\commutator{\hat{P} _p ^{\pm} }{\hat{P} _q ^{\mp}} &= \pm ( \cop{p}{+} \aop{p}{+} - \aop{p}{-} \cop{p}{-})\\
	\commutator{\hat{P} _p ^{\pm}}{\hat{P} _q ^{\pm}} &= 0
\end{split}
\label{eq:ppmcom}
\end{align}

These results reduce the four terms in eq.~\ref{eq:ctpcom} to two, which can be expanded taking into account that the pair creation and annihilation operators act to select terms with their specific state index from the sum over all states.

\begin{align*}
	&\ppop{q} \commutator{\pmop{s}}{\ppop{r}} \pmop{r} + \ppop{q} \ppop{r} \commutator{\pmop{s}}{\pmop{r}} + \commutator{\ppop{q}}{\ppop{r}} \pmop{s} \pmop{r} +  \ppop{r} \commutator{\ppop{q}}{\pmop{r}} \pmop{s}\\
	&= \ppop{q} \commutator{\pmop{s}}{\ppop{r}} \pmop{r} +  \ppop{r} \commutator{\ppop{q}}{\pmop{r}} \pmop{s}\\
	&= \pcop{q} \left ( \aop{r}{-} \cop{r}{-} - \cop{r}{+} \aop{r}{+} \right ) \paop{r} + \pcop{r} \left ( \cop{r}{+} \aop{r}{-} - \aop{r}{-} \cop{r}{-} \right ) \paop{s}\\
	&= 0
\end{align*}

since the first term contains two \aop{r}{-} operators, the second term contains two \aop{r}{+} operators, the third contains two \cop{r}{+} operators and the fourth contains two \cop{r}{+} operators, therefore, action of \commutator{\vop}{\ppop{r} \pmop{t}} on any fermionic state produces 0. Combining this result with that of eq.~\ref{eq:comhzpcap} shows that the Hamiltonian commutes with the pair creation and annihilation operators.

\section*{The Hamiltonian Matrix}

Restricting the effective Hilbert space to only the two lowest single-particle states (they are doubly degenerate) and considering only two particles, we can construct a Hamiltonian matrix in the basis of 2-particle Slater determinants (eq.~\ref{eq:2ptclSD}).

\begin{align}
\begin{split}
	\Ket{\Phi _1 ^{\mathrm{SD}}} &= \pcop{1} \ket{0}\\
	\Ket{\Phi _2 ^{\mathrm{SD}}} &= \pcop{2} \ket{0}
\end{split}
	\label{eq:2ptclSD}
\end{align}

 Furthermore, our system is considered to have no broken pairs and total spin $S=0$. The matrix elements of the Hamiltonian can be calculated separately for the one- and two-body parts using Wick's theorem. For example, the one-body part of the first matrix element:

\begin{align*}
	& \Bra{0} \paop{1} \left ( \hzero{p}{\sigma} \right ) \pcop{1} \Ket{0}\\
	&= \Bra{0} \paop{1} \left ( 0 \nop{1}{+} + 0 \nop{1}{-} + 1 \nop{2}{+} + 1 \nop{2}{-} \right ) \pcop{1} \Ket{0}\\
	&= \Bra{0} \paop{1} \left ( 0 \nop{1}{+} + 0 \nop{1}{-} \right ) \pcop{1} \Ket{0}\\
	&= 0
\end{align*}

The two body part of the first matrix element:

\begin{align*}
	& \vacuumb \paop{1} \left ( \twobody{p}{q} \right ) \pcop{1} \vacuumk\\
	&= \vacuumb \paop{1} (-g) \left ( \cpm{1} \amp{1} + \cpm{1} \amp{2} + \cpm{2} \amp{1} + \cpm{2} \amp{2} \right ) \pcop{1} \vacuumk\\
	&= \vacuumb \paop{1} (-g) \left ( \cpm{1} \amp{1} \right ) \pcop{1} \vacuumk\\
	&= -g
\end{align*}

The second matrix element:

\begin{align*}
	& \vacuumb \paop{1} \left ( \hzero{p}{\sigma} \right ) \pcop{2} \vacuumk\\
	&= \vacuumb \paop{1} \left ( 0 \nop{1}{+} + 0 \nop{1}{-} + 1 \nop{2}{+} + 1 \nop{2}{-} \right ) \pcop{2} \vacuumk\\
	&= 0
\end{align*}

\begin{align*}
	& \vacuumb \paop{1} \left ( \twobody{p}{q} \right ) \pcop{2} \vacuumk\\
	&= \vacuumb \paop{1} (-g) \left ( \cpm{1} \amp{1} + \cpm{1} \amp{2} + \cpm{2} \amp{1} + \cpm{2} \amp{2} \right ) \pcop{2} \vacuumk\\
	&= \vacuumb \paop{1} (-g) \left ( \cpm{1} \amp{2} \right ) \pcop{2} \vacuumk\\
	&= -g
\end{align*}

The full $2 \times 2$ matrix where $d$ is the level spacing

\begin{equation}
	H =
	\begin{pmatrix}
		-g & -g\\
		-g & 2d - g
	\end{pmatrix}
	\label{eq:2ptclham}
\end{equation}

This matrix is diagonalized to yield eigenenergies (with $d=1$)

\begin{equation}
	E = 1 - g \pm \sqrt{1 + g^2}
	\label{eq:2ptcleng}
\end{equation}

The ground state energy, $E_0 = 1 - g - \sqrt{1 + g^2}$, as $g$ goes from $-1$ to $1$ goes from $\sim 0.5$ to $\sim -1.5$. This suggests that when the two-body interaction is attractive ($g$ positive), the one pair two level system has at least one bound state. Our shell model code (see Table~\ref{tab:1pr2lvl}) reproduces exactly the analytic result.

When we have four levels and four particles, the number of basis states is $\binom{4}{4/2}=6$, and the 6 Slater determinants are

\begin{align}
\begin{split}
	& \cpm{1} \cpm{2} \vacuumk\\
	& \cpm{1} \cpm{3} \vacuumk\\
	& \cpm{1} \cpm{4} \vacuumk\\
	& \cpm{2} \cpm{3} \vacuumk\\
	& \cpm{2} \cpm{4} \vacuumk\\
	& \cpm{3} \cpm{4} \vacuumk
\end{split}
\end{align}

%$\ket{1\pm2\pm},\ket{1\pm3\pm},\ket{1\pm4\pm},\ket{2\pm3\pm},\ket{2\pm4\pm},\ket{3\pm4\pm}$.

Action of the Hamiltonian on each Slater determinant results in

\begin{align*}
&\hat{H}\ket{1\pm2\pm}=(2-2g)\ket{1\pm2\pm}-g\ket{1\pm3\pm}-g\ket{1\pm4\pm}-g\ket{2\pm3\pm}-g\ket{2\pm4\pm}+0\ket{3\pm4\pm}   \\
&\hat{H}\ket{1\pm3\pm}=g\ket{1\pm2\pm}+(4-2g)\ket{1\pm3\pm}-g\ket{1\pm4\pm}-g\ket{2\pm3\pm}+0\ket{2\pm4\pm}-g\ket{3\pm4\pm}   \\
&\hat{H}\ket{1\pm4\pm}=-g\ket{1\pm2\pm}-g\ket{1\pm3\pm}+(6-2g)\ket{1\pm4\pm}-0\ket{2\pm3\pm}-g\ket{2\pm4\pm}-g\ket{3\pm4\pm}   \\
&\hat{H}\ket{2\pm3\pm}=-g\ket{1\pm2\pm}-g\ket{1\pm3\pm}-g\ket{1\pm4\pm}+(6-2g)\ket{2\pm3\pm}-g\ket{2\pm4\pm}-g\ket{3\pm4\pm}   \\
&\hat{H}\ket{2\pm4\pm}=-g\ket{1\pm2\pm}+0\ket{1\pm3\pm}-g\ket{1\pm4\pm}-g\ket{2\pm3\pm}+(8-2g)\ket{2\pm4\pm}-g\ket{3\pm4\pm}   \\
&\hat{H}\ket{3\pm4\pm}=0\ket{1\pm2\pm}-g\ket{1\pm3\pm}-g\ket{1\pm4\pm}-g\ket{2\pm3\pm}-g\ket{2\pm4\pm}+(10-2g)\ket{3\pm4\pm}
\end{align*}

where a short-hand notation $\ket{p \pm q \pm}$ is employed to represent a Slater determinant with one pair in level $p$ and one in level $q$.

So the Hamiltonian matrix is

\begin{equation}
\begin{bmatrix}
2-2g   &  -g   &   -g   &   -g    &   -g    &    0    \\
  -g   &4-2g   &   -g   &   -g    &    0    &   -g    \\
  -g   &  -g   & 6-2g   &    0    &   -g    &   -g    \\
  -g   &  -g   &   0   & 6-2g    &   -g    &   -g    \\
  -g   &   0   &   -g   &   -g    & 8-2g    &   -g    \\
   0   &  -g   &   -g   &   -g    &   -g    & 10-2g    \\
\end{bmatrix}
\label{eq:ham6mtx}
\end{equation}

We diagonalize this matrix numerically for $g=\{ -1.0, -0.5, 0.0, 0.5, 1.0 \}$ and ensure that our code's output, listed in Table~\ref{tab:2pr4lvl}, matches the results. This test ensures that our code correctly generates the Hamiltonian matrix. Similarly to the one pair two level case, we note that as $g$ becomes negative (as the two-body interaction becomes repulsive), the system becomes unbound (see Figure~\ref{fig:ezerovg}).

\begin{figure}
\center
	\includegraphics[width=0.6\textwidth]{lvl4pr2.png}
	\caption{Ground state energies for five different values of $g$ - calculated by diagonalizing the $6 \times 6$ Hamiltonian matrix of eq.~\ref{eq:ham6mtx}. These results match our code's output given in Table~\ref{tab:2pr4lvl}.}
	\label{fig:ezerovg}
\end{figure}

%Table~\ref{tab:1pr2lvl} lists the results of our shell model calculation with two particles (1 pair) and two levels.

\begin{table}[h]
\begin{center}
\begin{tabular}{|r|r|}
\hline
  g   &  $E_{gs}$ \\ \hline
-1.0  &  0.59 \\
-0.5  &  0.38 \\
 0.0  &  0.0 \\
 0.5  &  -0.62 \\
 1.0  &  -1.41 \\
\hline
\end{tabular}
\end{center}
\caption{Ground state energies as a function of interaction strength $g$ for the case of one pair in 2 single particle levels.}
\label{tab:1pr2lvl}
\end{table}

\begin{table}[h]
\begin{center}
	\begin{tabular}{|r|r|}
\hline
	g   &  $E_{gs}$ \\ \hline
	-1.0  &  3.30 \\
	-0.5  &  2.78 \\
	 0.0  &  2.0 \\
	 0.5  &  -0.64 \\
	 1.0  &  -1.49 \\
\hline
	\end{tabular}
\end{center}
	\caption{Ground state energies as a function of interaction strength $g$ for the case of two pairs in four levels.}
	\label{tab:2pr4lvl}
\end{table}

When we remove the single particle piece of the Hamiltonian and keep only
the two particle interaction, all particles are brought down to the same
degenerate energy level, with degeneracy $\Omega$ and ground state energy
\begin{equation}
	E_0 = - \frac{g}{4} n (\Omega - n +2)
	\label{eq:no1bdy}
\end{equation}

Our code reproduces the analytic result eq.~\ref{eq:no1bdy} for $g>0$ (an attractive two-body interaction). When
$g$ becomes negative, eq.~\ref{eq:no1bdy} gives the highest possible energy level due to the two-body interaction
and the ground state energy becomes 0.

As we then vary the
interaction strength $g$ we observe the following pattern: In the
negative $g$ case, the interaction is repulsive, and so the best the
system can do is break even. In this case, the ground state energy is
zero, regardless of $g$. When $g$ becomes positive, however, the
interaction is attractive, and as $g$ becomes more and more positive,
the interaction becomes increasingly attractive and the system
correspondingly becomes more and more bound. We illustrate this for
several cases in Table \ref{tab:data-nosinglepart}.

%%% Tables
\begin{table}
\begin{center}
%\label{tab:data-nosinglepart}
\begin{tabular}{|c|c|c|c|}
\hline
   g   &  $E_{gs}$(2,2)  &  $E_{gs}$(6,6)  & $ E_{gs}$(8,8) \\ \hline
-1.0  &  0  &  0  &  0   \\
-0.5  &  0  &  0  &  0   \\
  0.0  &  0  &  0  &  0   \\
  0.5  &  -1  & -6  &  -10 \\
  1.0  &  -2  & -12 &  -20 \\
\hline
\end{tabular}
\end{center}
\caption{Ground state energies $E_{gs}(N_l,N_{part})$ for the case with
the single-particle Hamiltonian removed. The energies are shown as a
function of interaction strength $g$ for the case of $N_{part}$
particles in $N_l=\frac{\Omega}{2}$ single particle ``levels.''}
\label{tab:data-nosinglepart}
\end{table}

\clearpage

\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}

\lstset{ %
  backgroundcolor=\color{white},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
  basicstyle=\footnotesize,        % the size of the fonts that are used for the code
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
  breaklines=true,                 % sets automatic line breaking
  captionpos=b,                    % sets the caption-position to bottom
  commentstyle=\color{mygreen},    % comment style
  deletekeywords={...},            % if you want to delete keywords from the given language
  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
  frame=single,	                   % adds a frame around the code
  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
  keywordstyle=\color{blue},       % keyword style
  language=Octave,                 % the language of the code
  otherkeywords={*,...},           % if you want to add more keywords to the set
  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
  numbersep=5pt,                   % how far the line-numbers are from the code
  numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,          % underline spaces within strings only
  showtabs=false,                  % show tabs within strings adding particular underscores
  stepnumber=2,                    % the step between two line-numbers. If it's 1, each line will be numbered
  stringstyle=\color{mymauve},     % string literal style
  tabsize=2,	                   % sets default tabsize to 2 spaces
  title=\lstname                   % show the filename of files included with \lstinputlisting; also try caption instead of title
}

\lstinputlisting{shell_model.py}

%	&= \ppop{q} \left ( \commutatorexp{\pmop{s}}{\ppop{r}} \right ) \pmop{r} + \ppop{r} \left ( \commutatorexp{\ppop{q}}{\pmop{r}} \right ) \pmop{s}\\
%	&= \pcop{q} \left ( \commutatorexp{\paop{s}}{\pcop{r}} \right ) \paop{r} + \pcop{r} \left ( \commutatorexp{\pcop{q}}{\paop{r}} \right ) \paop{s}\\
%	&= \pcop{q} \paop{s} \pcop{r} \paop{r} - \pcop{q} \pcop{r} \paop{s} \paop{r}\\
%	& \hspace{4mm} + \pcop{r} \pcop{q} \paop{r} \paop{s} - \pcop{r} \paop{r} \pcop{q} \paop{s}\\

\begin{comment}

%%% SIDE TRACK - UNNECESSARY %%%

\begin{equation}
	\commutator{\hop}{\sop{-}} = 2 \sum_{p}  \left ( (p-1) \cop{p}{-} \aop{p}{+} \right )
	\label{eq:hsminusres}
\end{equation}

We can now re-write the remaining terms in $ \left [ \hat{H}_0, \hat{S}^2 \right ]$.

\begin{align*}
	\commutator{\hop}{\sop{+}} \sop{-} &= 2 \sum _{pp'} (p-1) \cop{p}{+} \aop{p}{-} \cop{p'}{-} \aop{p'}{+}\\
	\sop{+} \commutator{\hop}{\sop{-}} &= 2 \sum _{pp'} (p'-1) \cop{p}{+} \aop{p}{-} \cop{p'}{-} \aop{p'}{+}\\
	\commutator{\hop}{\sop{-}} \sop{+} &= 2 \sum _{pp'} (p-1) \cop{p}{-} \aop{p}{+} \cop{p'}{+} \aop{p'}{-}\\
	\sop{-} \commutator{\hop}{\sop{+}} &= 2 \sum _{pp'} (p'-1) \cop{p}{-} \aop{p}{+} \cop{p'}{+} \aop{p'}{-}
\end{align*}

Taking \commutator{\hop}{\sop{+}} \sop{-}:

\begin{align*}
	\commutator{\hop}{\sop{+}} \sop{-} &= \sum _{pp'} (p-1) \cop{p}{+} \aop{p}{-} \cop{p'}{-} \aop{p'}{+}\\
	&= \sum _{pp'} (p-1) \cop{p}{+} \left ( \krondelt{p}{p'} -  \cop{p'}{-} \aop{p}{-} \right ) \aop{p'}{+}\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{+} \aop{p'}{+} -  \cop{p}{+} \cop{p'}{-} \aop{p}{-} \aop{p'}{+} \right )\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{+} \aop{p'}{+} -  \cop{p'}{-} \cop{p}{+} \aop{p'}{+} \aop{p}{-} \right )\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{+} \aop{p'}{+} -  \cop{p'}{-} \left ( \krondelt{p}{p'} - \aop{p'}{+} \cop{p}{+} \right ) \aop{p}{-} \right )\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{+} \aop{p'}{+} - \krondelt{p}{p'} \cop{p'}{-} \aop{p}{-} - \cop{p'}{-} \aop{p'}{+} \cop{p}{+} \aop{p}{-} \right )\\
	&= \sum _{p} (p-1) \cop{p}{+} \aop{p}{+} - \sum _{p} (p-1) \cop{p}{-} \aop{p}{-} - \sum _{pp'} (p-1) \cop{p'}{-} \aop{p'}{+} \cop{p}{+} \aop{p}{-}\\
	&= \sum _{p} (p-1) \numop{p}{+} - \sum _{p} (p-1) \numop{p}{-} - \sum _{pp'} (p-1) \cop{p'}{-} \aop{p'}{+} \cop{p}{+} \aop{p}{-}\\
\end{align*}

Taking \commutator{\hop}{\sop{-}} \sop{+}:

\begin{align*}
	\commutator{\hop}{\sop{-}} \sop{+} &= \sum _{pp'} (p-1) \cop{p}{-} \aop{p}{+} \cop{p'}{+} \aop{p'}{-}\\
	&= \sum _{pp'} (p-1) \cop{p}{-} \left ( \krondelt{p}{p'} - \cop{p'}{+} \aop{p}{+} \right ) \aop{p'}{-}\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{-} \aop{p'}{-} - \cop{p}{-} \cop{p'}{+} \aop{p}{+} \aop{p'}{-} \right )\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{-} \aop{p'}{-} -  \cop{p'}{+} \cop{p}{-} \aop{p'}{-} \aop{p}{+} \right )\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{-} \aop{p'}{-} -  \cop{p'}{+} \left ( \krondelt{p}{p'} - \aop{p'}{-} \cop{p}{-} \right ) \aop{p}{+} \right )\\
	&= \sum _{pp'} (p-1) \left ( \krondelt{p}{p'} \cop{p}{-} \aop{p'}{-} - \krondelt{p}{p'} \cop{p'}{+} \aop{p}{+} - \cop{p'}{+} \aop{p'}{-} \cop{p}{-} \aop{p}{+} \right )\\
	&= \sum _{p} (p-1) \cop{p}{-} \aop{p}{-} - \sum _{p} (p-1) \cop{p}{+} \aop{p}{+} - \sum _{pp'} (p-1) \cop{p'}{+} \aop{p'}{-} \cop{p}{-} \aop{p}{+}\\
	&= \sum _{p} (p-1) \numop{p}{-} - \sum _{p} (p-1) \numop{p}{+} - \sum _{pp'} (p-1) \cop{p'}{+} \aop{p'}{-} \cop{p}{-} \aop{p}{+}\\
\end{align*}

Plugging these results in for their respective terms in the the remnant of $ \left [ \hat{H}_0, \hat{S}^2 \right ]$:

\begin{align*}
	& \left [ \hat{H}_0, \hat{S}^2 \right ]\\
	&= \frac{1}{2} \left ( \commutator{\hop}{\sop{+}} \sop{-} + \sop{+} \commutator{\hop}{\sop{-}} + \commutator{\hop}{\sop{-}} \sop{+} + \sop{-} \commutator{\hop}{\sop{+}} \right )\\
	&= \sum _{p} (p-1) \numop{p}{+} - \sum _{p} (p-1) \numop{p}{-} - \sum _{pp'} (p-1) \cop{p'}{-} \aop{p'}{+} \cop{p}{+} \aop{p}{-}\\
	& + \sum _{pp'} (p'-1) \cop{p}{+} \aop{p}{-} \cop{p'}{-} \aop{p'}{+}\\
	& + \sum _{p} (p-1) \numop{p}{-} - \sum _{p} (p-1) \numop{p}{+} - \sum _{pp'} (p-1) \cop{p'}{+} \aop{p'}{-} \cop{p}{-} \aop{p}{+}\\
	& + \sum _{pp'} (p'-1) \cop{p}{-} \aop{p}{+} \cop{p'}{+} \aop{p'}{-}
\end{align*}

%%% ALTERNATIVE FOR [V,SS] = 0 %%%

Writing the term \sop{-} \commutator{\vop}{\sop{+}} explicitly:

\begin{align}
\begin{split}
	\sop{-} \commutator{\vop}{\sop{+}} &= \left ( \sminus{m} \right ) \left ( \twobody{q}{s} \right ) \left ( \splus{p} \right )\\
	& - \left ( \sminus{m'} \right ) \left ( \splus{p'} \right ) \left ( \twobody{q'}{s'} \right )
\end{split}
\label{eq:svs}
\end{align}

The first product of sums may be re-written as follows, noting that in \ref{eq:svsmk1} and \ref{eq:svsmk2} the first terms are dropped since \aop{s}{-} \aop{s}{-} and \cop{q}{+} \cop{q}{+} acting on any state will give 0.

\begin{align}
	& (-g) \sum_{m q s p} \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} \cop{p}{+} \aop{p}{-}\\
	& (-g) \sum_{m q s p} \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \left ( \krondelt{s}{p} -  \cop{p}{+} \aop{s}{+} \right ) \aop{p}{-}\\
	& (-g) \sum_{m q s p} \krondelt{s}{p} \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{p}{-} - \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-}  \cop{p}{+} \aop{s}{+} \aop{p}{-}\\
\label{eq:svsmk1}	& (-g) \sum_{m q s p} \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{-} - \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-}  \cop{p}{+} \aop{s}{+} \aop{p}{-}\\
	& (-g) \sum_{m q s p}  - \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-}  \cop{p}{+} \aop{s}{+} \aop{p}{-}\\
	& (-g) \sum_{m q s p}  \cop{m}{-} \aop{m}{+} \cop{p}{+} \cop{q}{+} \cop{q}{-} \aop{p}{-} \aop{s}{-} \aop{s}{+}\\
	& (-g) \sum_{m q s p}  \cop{m}{-} \aop{m}{+} \cop{p}{+} \cop{q}{+} \left ( \krondelt{q}{p} -  \aop{p}{-} \cop{q}{-} \right ) \aop{s}{-} \aop{s}{+}\\
	& (-g) \sum_{m q s p} \krondelt{q}{p} \cop{m}{-} \aop{m}{+} \cop{p}{+} \cop{q}{+} \aop{s}{-} \aop{s}{+} - \cop{m}{-} \aop{m}{+} \cop{p}{+} \cop{q}{+}  \aop{p}{-} \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
\label{eq:svsmk2}	& (-g) \sum_{m q s p} \cop{m}{-} \aop{m}{+} \cop{q}{+} \cop{q}{+} \aop{s}{-} \aop{s}{+} - \cop{m}{+} \aop{m}{+} \cop{p}{+} \cop{q}{+}  \aop{p}{-} \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
	& (-g) \sum_{m q s p} - \cop{m}{-} \aop{m}{+} \cop{p}{+} \cop{q}{+}  \aop{p}{-} \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
	& (-g) \sum_{m q s p} - \cop{m}{-} \aop{m}{+} \aop{p}{-} \cop{p}{+} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}\\
\label{eq:svsmk3}	& (-g) \sum_{m q s p} \cop{m}{-} \aop{m}{+} \cop{p}{+} \aop{p}{-} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+}
\end{align}

Comparing the result from \ref{eq:svsmk3} to the second product of sums in eq.~\ref{eq:svs} which we re-write here as

\begin{equation}
	g \sum _{m p qs} \cop{m}{-} \aop{m}{+} \cop{p}{+} \aop{p}{-} \cop{q}{+} \cop{q}{-} \aop{s}{-} \aop{s}{+} \nonumber
\end{equation}

we find that $ \sop{-} \commutator{\vop}{\sop{+}} =0$

\end{comment}

\end{document}


\documentclass[11pt]{scrartcl}
\usepackage[sexy]{evan}
\usepackage{braket}
\usepackage{color}   %May be necessary if you want to color links
\usepackage{hyperref}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\usepackage{comment}

\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}

\hypersetup{
	colorlinks=true, %set true if you want colored links
	linktoc=all,     %set to all if you want both sections and subsections linked
	linkcolor=blue,  %choose some color if you want links to stand out
}
\usepackage{geometry}
%\usepackage{showframe} %This line can be used to clearly show the new margins

\newgeometry{vmargin={30mm}, hmargin={20mm,20mm}}   % set the margins
\begin{document}
	\title{Digital Communication Theory} % Beginner
	\date{December 2021}
	\maketitle

	\begin{abstract}
		\sffamily\small
		Here is a collected notes on Digital Communications.
	\end{abstract}

	\vspace{1em}

	\tableofcontents
	\newpage

\section{Resources}
\begin{itemize}
	\item \emph{Thomas Cover, Elements of Information Theory}: Anything entropy, shannon capacity, refer to this.

	\item \emph{Cioffi notes}:   Each chapter covers the equivalent of a small book.  However lots of practical information nowhere else to be found (especially on equalization).
	\item \emph{Bane, Vasic}: Surprisingly good chapters on partial response channel capacity, coding (both RS and LDPC), and timing  recovery.
	\end{itemize}

\section{Foundations}

\subsection{Information Theory}

\textbf{Entropy, facts and definitions}:
\begin{itemize}
	\item Denote the \vocab{entropy} of random variable X with probability distribution $p(x)$ to be:
	\[ H(X) = - \braket{ \log (p(x)) } \]
	\item For a continuous random variable $X$ with density $f(x)$, the \vocab{differential entropy} $h(X)$ is denoted to be:
	\[h(X) = - \int_S f(x) \log f(x) dx \]
	where S is the support of X.
	\item Similarly denote the \vocab{joint entropy} for 2 random variables X, Y with distributions $p(x, y)$ to be:
    \[ H(X, Y) = -\sum_{x, y} p(x, y) \log(p(x, y)) = - \braket{ \log(p(x, y)) } \]
	\item  Denote the \vocab{conditional entropy} of $H(Y | X)$ to be:
	\[ H(Y| X) = \braket{ \log( p(y|x)) } \]
	\[ \sum_{x \in \mathcal{X}} p(x) \sum_{y \in \mathcal{Y}} p(y|x) \log(p(y | x)) \]
	\[ \sum_{x, y} p(x, y) \log(p(y|x)) \]
	\item \vocab{Chain rule}:
	\[H(X, Y) = H(X) + H(Y|X) \]
	\item The \vocab{kullback leibler} distance or \emph{relative entropy} between 2 probability mass distributions p(x) and q(x) is defined as:
	\[D(p || q) = \sum_x p(x) \log {p(x) \over q(x)} = \braket{\log {p(x) \over q(x)}} \]
	It is always non-negative, but it is not symmetric.
	\item  The \vocab{mutual information } I(X, Y) is the relative entropy between the joint and product distribution:
	\[ I(X, Y) = \sum_{x, y} p(x, y) \log {p(x, y) \over p(x) p(y)} \]
	\end{itemize}

\begin{example}
	\begin{itemize}
		\item The differential entropy for uniform $x \in [0, a]$ is:
		\[h(X) - \int_0^a  dx {1 \over a} \log({1 \over a}) = \log(a) \]
		\item The differential entropy for gaussian variable with
		$f(x) = {1 \over \sqrt{2 \pi \sigma^2}} \exp \left( -{x^2 \over 2 \sigma^2}\right)$ is:
		\[h(X) = \frac12 \log (2 \pi e \sigma^2)\]
		\end{itemize}
	\end{example}
\begin{lemma}
	The gaussian distribution between 2 random variable x, y maximizes the differential entropy for any given positive semi-definite autocorrelation $R_{x,y}$:
	\[ p_{x, y} = {1 \over \sqrt{\pi \det(R_{xy})} } \exp \left(- {\mathbf{u}}^T R_{xy}^{-1} \underbrace{\mathbf{u}}_{\equiv (x, y)} \right) \]
	\end{lemma}
\includegraphics{entropy1.png}

\begin{definition}
	A statistic t(X) of some random variable $X$ is \vocab{sufficient} \emph{for underlying parameter $\theta$}  if the conditional probability distribution of the data $X$ given t(X) does not depend on $\theta$.
	It means $I(X, \theta) = I(t(X), \theta)$
\end{definition}

\begin{definition}
	\end{definition}

\begin{theorem}
	Consider a signal $Y(t) = X(t) + N(t)$ where $X \subseteq \mathcal{L}_2$ with an orthonormal basis $ \mathcal{S} \{  \phi_k \}$.  Denote N(t) to be a white gaussian noise process with respect to $\mathcal{S}$.  Then the set of measurements $\braket{ \phi_k | X}$ form a set of sufficient statistics for detection of X(t) from Y(t).
	\end{theorem}

\begin{proof} See 6.451 notes, section 2.4
	\end{proof}

\subsection{Channel Capacity}
cioffic ch. 2

\begin{itemize}
	\item The \vocab{channel capacity} in bits/subsymbol for a channel described by $p(y|x)$ is defined by
	\[  \mathcal{C} = \mathrm{max}_{p(x)} I(x, y) \text{ } bits/subsymbol \]
	\item A slightly more fancy way to describe capacity is to describe the maximum mutual information with respect to a transmit and receive sequence of subsymbols: $\bf{x}^n \equiv (x_1, x_2, ..., x_{n})$ and $\bf{y}^n = (y_1, ..., y_n)$.
	\[ C = \lim_{n \rightarrow \infty} {1 \over n} \mathrm{max}_{p(\bf{x}^n)} I(\bf{x}^n, \bf{y}^n) \]
	The maximization $p(\bf{x}^n)$ is taken over all probability density functions $p(\bf{x}^n)$ which satisfy the symbol energy constraint given by
	\[ \braket{x_k^2} \leq E_s \]
	\item An \vocab{Additive White Gaussian Noise} channel is a channel where
	\[y(t) = x(t) + n(t) \]
	where $n(t)$ is white.
\end{itemize}

\begin{theorem}
	Given a channel with capacity $\mathcal{C}$, then there exists a code with bitrate $b < \mathcal{C}$ such that
	$P_e \leq \delta$ for any $ \delta > 0$.  Furthermore, if $b > \mathcal{C}$, then $P_e  \geq \text{positive constant}$, which is typically large even for b slightly greater than $\mathcal{C}$.
	\end{theorem}

\begin{theorem}
	Given an AWGN channel, the channel capacity is
	\[C = {W \over 2} \log_2 \left(1 + {SNR} \right)\]
	\end{theorem}

It's important to notice a few things about this formula:
\begin{itemize}
	\item  The channel capacity obviously depends on the constraint on the transmit probability distribution.  The probability $p(x)$ distribution that maximizes capacity and gives the formula ${W \over 2}  \log_2 \left(1 + {SNR} \right)$ is gaussian.  The capacity when constrained to be different (PAM-2 symbols etc...) is in general a difficult optimization problem with no closed form solution.
	\end{itemize}

\section{Detection and Estimation}
\newpage
\subsection{Biased SNR}

Consider a signal processing system where we would like to slice an output
\[ y =  \underbrace{\alpha}_{\text{adaptive gain}} (\underbrace{x}_{\text{symbol}} + \underbrace{n}_{\text{uncorrelated noise}})\]

Maximizing the SNR, or minimizing the MSE will lead to a \vocab{biased} gain factor $\alpha$ which is slightly less than 1.  To show this, we just need to minimize the error, defined as:
\[ \text{MSE} = \braket{(y - x)^2} = (\alpha - 1)^2 \epsilon_x + \alpha^2 \epsilon_n \]
\[ \pder{\alpha}{\text{MSE}} = 0 \rightarrow \alpha = {\epsilon_x \over \epsilon_x + \epsilon_n} = {SNR \over 1 + SNR} \]

It is straightforward to make the decisions unbiased by scaling $\alpha$ by ${SNR + 1 \over SNR}$, which leads to a relation between \vocab{biased} and \vocab{unbiased} SNR.
\[ SNR = SNR_{U} + 1 \]
The reason why one would care is that a biased decision rule, while maximizing SNR, may not optimize BER.  We will further make rather trivial comments

\begin{itemize}
\item The distinction between biased and unbiased decreases as the SNR improves.  This is why for SERDES links, people rarely care about the distinction.
\item  While the analysis was done for a simple gain adaptation loop, all the conclusion remains for FFE adaptation.  In that case, if one uses a MMSE algorithm for adaptation, one will end up with a \vocab{biased} decision rule, while if one uses a ZF algorithm, one will end up with a \vocab{unbiased} adaptation.
	\end{itemize}
\section{Math}

\end{document}


\subsection{Original H.530 protocol description}\label{subsec:h5301}
The H.530 protocol tries to address the problem of the Diffie-Hellman communication protocol authentication. As described in \cite[p. 19]{sebmod2018}, without the authentication of half-keys, this protocol could lead to a \textit{man-in-the-middle} attack.
In this exercise, the authentication is based on a third entity \textit{s}, which is trusted by Alice (\textit{A}) and Bob (\textit{B}). Both \textit{A} and \textit{B} share a secret key with the trusted source \textit{s}, so this last entity is in charge of signing \textit{A} and \textit{B} authenticity in order to ensure both parts that the other part is trustworthy.
\begin{figure}[hb]
	\centering
	\input{tex/sequence_diagrams/h530_sequence_diagram}
	\caption{H.530 sequence diagram}
	\label{fig:h530trace}
\end{figure}
\\
As shown in \textit{Figure \ref{fig:h530trace}}, the protocol would be as follows:
\begin{itemize}
	\item First of all, Alice sends a message to Bob with her half-key. The message is signed so that the trustworthy entity can verify the author of that message as Alice.
	\item Bob asks the trustworthy entity about the authenticity of the message. He also includes his half-key and signs the message so that the trustworthy entity can verify the author of this message as Bob.
	\item If both signatures are correct, the trustworthy entity will respond Bob by sending a message in which it states that \textit{A} and \textit{B} are trustworthy. The message will be signed twice in order for both Alice and Bob to be able to verify the third party's verdict.
	\item Finally, when Bob verifies that Alice is trustworthy, he sends her a message with his half-key signed twice, one by the third party entity and the other by Bob himself, using the shared key $g^{XY}$.
	\item If Alice can verify the authenticity of the message, she will be able to send a message to Bob secured by their recently created shared key $g^{XY}$.
\end{itemize}
\subsection{Original H.530 protocol analysis with OFMC and protocol redefinition}\label{subsec:h5302}
As expected, OFMC \cite{sebmod2005} detects an attack, which trace can be found in \textit{Code 1}. This trace describes how a \textit{man-in-the-middle} attack could be done with this protocol:
\begin{itemize}
	\item	Alice shares her half-key, $g^{X_1}$ , with Bob. However, it is intercepted by an intruder.
	\item	The intruder opens the \textbf{first} session with Bob, pretending that he/she is Alice and making up the half-key ($X_2$ is set to 1, so $g^{X_2}=g$) and Alice's signature.
	\item	Bob asks the trustworthy entity to verify the malicious request, attaching to the message his half-key $g^{Y_1}$, but it is also intercepted by the intruder.
	\item	The intruder now reproduces the original message from Alice and sends it to Bob by opening the \textbf{second} session.
	\item	Bob asks again the trustworthy entity to verify this duplicated request, attaching to his message a new half-key, $g^{Y_2}$. The intruder forwards the message to the trustworthy entity and intercepts its response.
	\item	The trustworthy entity confirms that both Alice and Bob can be trusted. However, it does not sign any half-key to be used: Bob does not know that the original key, $g^{X_1}$, is the one that should be trusted.
\end{itemize}
\textit{Figure \ref{fig:h530traceattack}} shows a sequence diagram that illustrates the attack.\\
\begin{figure}[ht!]
	\centering
	\input{tex/sequence_diagrams/h530_attack_sequence_diagram}
	\caption{H.530 attack sequence diagram}
	\label{fig:h530traceattack}
\end{figure}
In \textit{"h530-fix.AnB"}, this issue is solved by making the trustworthy entity to sign not only Alice and Bob's identity but also the half-key $g^{X}$ A have decided to use for this session. With this small change, the security threat disappears: OFMC does not detect any attack.\\
A sequence diagram with the changes made to the protocol is shown in \textit{Figure \ref{fig:h530tracefix}}.
\begin{figure}[ht!]
	\centering
	\input{tex/sequence_diagrams/h530_fix_sequence_diagram}
	\caption{H.530 sequence diagram (fixed)}
	\label{fig:h530tracefix}
\end{figure}
\subsection{Fixed H.530 protocol with untrustworthy third party entity}\label{subsec:h5303}
By doing that, we are saying that the trustworthy entity cannot be trusted anymore: we cannot determine that an identity verification from S is safe.
As expected, once we have changed the entity and examined with OFMC, the simulator detects a potential attack, which steps are shown in \textit{Figure \ref{fig:h530traceS}}.
\begin{figure}[ht!]
	\centering
	\input{tex/sequence_diagrams/h530_fix_sequence_diagram_S}
	\caption{H.530 attack sequence diagram (untrustworthy third party entity)}
	\label{fig:h530traceS}
\end{figure}
\begin{itemize}
	\item	Alice shares her half-key, $g^{X}$, with Bob. However, it is intercepted by an intruder.
	\item	The intruder pretends to be Bob and the third party entity at the same time, sending to Alice a weak half-key $g^{Y=1}=g$. It reuses the signature provided by Alice in the first message and signs the message with their new insecure shared key $g^{XY}=g^X$, which could be simply extracted from Alice's original message. From the point of view of Alice, the message is legit, as it appears to be signed by the trustworthy entity and by Bob with their recently created shared key.
	\item	Alice sends an encrypted message to the intruder, believing that the receiver is Bob. The intruder is able to decrypt the message and reads its content.
\end{itemize}
This attack trace shows that, if the trustworthy server can be substituted by a \textit{man-in-the-middle} attack, it would be possible for an attacker to open a private, secure session with Alice, pretending that it is Bob the one at the other side.


\clearpage
\subsection{Scalar SM3 Acceleration}
\label{sec:scalar:sm3}

\begin{bytefield}[bitwidth={1.05em},endianness={big}]{32}
\bitheader{0-31} \\
\encsmthreepzero
\encsmthreepone
\end{bytefield}

\begin{cryptoisa}
RV32, RV64
    sm3p1 rd, rs1
    sm3p0 rd, rs1
\end{cryptoisa}

These instructions are designed to accelerate the SM3 secure
hash function\cite{ietf:sm3}.
They are based on work done in \cite{MJS:LWSHA:20}, and follow
the same pattern as the scalar SHA2 instructions
(Section \ref{sec:scalar:sha2}).

The instructions implement versions of the $P_0$ and $P_1$
permutations, per the SM3 specification \cite{ietf:sm3}.
RISC-V Sail model code for each instruction is found in figure
\ref{fig:sail:sm3}.

\begin{figure}[h]
\lstinputlisting[language=sail,firstline=98,lastline=106]{../extern/sail-riscv/model/riscv_insts_kext.sail}
\caption{RISC-V Sail model specification for the scalar RV32/RV64 SM3 instructions.}
\label{fig:sail:sm3}
\end{figure}


\documentclass[main_zanardi.tex]{subfiles}

\begin{document}

Zanardi from the University of Southern California.

\section{Distances over quantum state spaces}

\paragraph{What we will talk about}

What is a metric? "Trace norm distance"

Information theore
tical protocol

Battacharya distance; its infinitesimal version: the Fischer metric, the Fubini-Study metric: many body physics, Quantum Phase Transitions.

At zero temperature, we only have the ground state, there is no entropy, so how do transitions work?

The statements preceded by the word "claim" are left as exercises.

\subsection{Quantum theory recap}

We have \emph{states} and \emph{observables}. We call the system $S$, and its associated Hilbert space \(\H\). (No real quantum system is going to be truly isolated).

A state \(\rho\) is a density matrix, an observable is a Hermitian operator over \(\H\).

\begin{equation}
  S(\H) = \qty{\rho |\, \rho \geq 0, \, \Tr \rho = 1}
\end{equation}

Then \(\forall \phi \in \H: \ev{\rho}{\phi} \geq 0\), \(\rho = \rho ^\dag\).

\(\sigma (\rho) = \text{spectrum of } \rho = \qty{p_i}_i\). \(d = \dim (\H)\).

\(p_i \geq 0\), \(\sum_i p_i = 1\).

So quantum theory is just noncommutative probability theory.

\paragraph{Single qubit}.

\(\H \sim \mathbb{C}^2$, $\dim \H = 2$, $\rho = \frac{1}{2} \qty(\mathbb{1} + \vec{\lambda} \cdot \vec{\sigma})\).

\(\vec{\lambda}\) is the Bloch vector, \(\vec{\sigma}\) are the Pauli matrices.
If \(\abs{\vec{\lambda}} = 1\), we have a pure state.

\paragraph{Exercise}
Prove that \(\rho\) being a density matrix is equivalent to \(\abs{\lambda}\leq 1\), and that \(\abs{\lambda} = 1 \iff \rho^2 = \rho \iff \rho = \ketbra{\psi}\).

Creating convex combinations of states should always be allowed,  and we see this in the fact that the space of states is convex.

States are usually decomposable as probabilistic mixtures, which are convex combinations in "Bloch space" (or its generalizations).

\subsection{Telling states apart} We are given two states \(\rho _{1, \, 2}\): what is the measurement which maximizes the probability we will be able to tell one from the other?

Probability vectors: \(\vec{p} = (p_i)\), \(\vec{q} = (q_i)\). We can use the "\(\ell_1\)" metric:

\begin{equation}
  d(p, q) = \sum_i \abs{p_i - q_i}
\end{equation}

Claim: this is a distance.

Can we do the same for quantum states? In general, \([\rho_1,  \rho_2] \neq 0\), we do not have a common eigenbasis. Could we use the Frobenius metric? Eeh, not really.

We have a map from observables to numbers: \(A \rightarrow \Tr \qty(\rho A) = \langle A \rangle_\rho\).

We can do \(\sup{\abs{{\langle A \rangle_{\rho_1} - \langle A \rangle_{\rho_2}}}}\) (Over \(\norm{A} = 1\)).

\begin{equation}
  \norm{A} = \sup_{\psi \neq 0} \frac{\norm{A\psi}}{{\psi}}
\end{equation}

So our distance is

\begin{equation}
  d = \sup_{\norm{A}=1} \abs{\Tr \qty[A(\rho_1 - \rho_2)]}
\end{equation}

We know that

\begin{align}
  \abs{\Tr \qty(AB)} &= \sum_i b_i \ev{A}{i} \\
  &\leq \sum_i \abs{b_i} \ev{A}{i} \\
  &\leq \norm{A} \sum_i \abs{b_i} \\
  &\leq \norm{A} \Tr \abs{B}
\end{align}

Where \(B = \sum_i b_i \ketbra{i}\)),
and we call \(\norm{B}_1 = \Tr \abs{B}\), where the modulus of the operator can be thought of eigenvalue-wise (diagonalizing the operator, and then flipping the sign of all the negative eigenvalues).

So

\begin{equation}
  d \leq \norm{A} \norm{\rho_1 - \rho_2}_1 = \norm{\rho_1 - \rho_2}_1
\end{equation}

Claim: this in an equality (there \emph{always} exists an $A$ to do the job).

Do we get back the classical case if the matrices commute? Claim: yes.

We call \(D(\rho_1, \rho_2) = \frac{1}{2} \norm{\rho_1 - \rho_2}_1\). (since the $d$ we used before is upper-bounded by 2, by the triangular inequality).

"the duals of self-adjoint operators are traceles"?

\paragraph{Measurements}
Von Neumann orthogonal measurement we know about.

Generalized measurement: we have an ancillary system, mearure this system and then trace over it. This is not described by an orthogonal projection:

\paragraph{Positive Operator-Valued Measurement}

We have finitely many \(\qty{E_i}_i\), \(E_i \geq 0\),  \(\sum_i E_i = \mathbb{1}\).

\(\rho \rightarrow p_i = \Tr (\rho E_i)\).

2-element POVM: \(E_{1, \, 2} \geq 0\), we have our states \(\rho_{1, \, 2}\).

Say we get the states with \(50\%\) probability each, and we wish to distinguish them:

\begin{equation}
  P(\text{success}) = \frac{1}{2} \qty[\Tr(E_1 \rho_1) + \Tr(E_2 \rho_2)]
\end{equation}

\begin{equation}
  P(\text{error}) = \frac{1}{2} \qty[\Tr(E_1 \rho_2) + \Tr(E_2 \rho_1)]
\end{equation}

We want to maximize \(P(\text{success})\). We can rewrite it as:

\begin{align}
  P(\text{success}) &= \frac{1}{2} \qty[\Tr(E_1 \rho_1) + \Tr\qty((\mathbb{1} - E_1) \rho_2)] \\
  &= \frac{1}{2}\qty[1 + \Tr \qty(E_1 (\rho_1 - \rho_2))]
\end{align}

to maximize over $E_1$. The optimum (Claim) is

\begin{equation}
  P(\text{success}) = \frac{1}{2}\qty[1 + \frac{1}{2} \norm{\rho_1 + \rho_2}_1]
\end{equation}

Hellstrom optimal measurement?
This is 1 if they are maximally different, $1/2$ if they are indistinguishable.

$E_1$ should be the projection over the positive eigenvalues of the difference between the matrices.

\paragraph{Bhattacharyya distance}

We have two probability vectors \(\vec{p} = \qty(p_i)_i\), \(\vec{q} = \qty(q_i)_i\).
Normalized in the euclidean metric, if we take the square root component by component: \(V_p = \qty(\sqrt{p_i})_i\).

\begin{equation}
  d_B (\vec{p}, \vec{q}) = \cos^{-1} (\vec{V_p}, \vec{V_q})
\end{equation}

Claim: this is a distance.

\begin{equation}
  d_B (\vec{p}, \vec{q}) = \cos^{-1} \qty(\sum_i \sqrt{p_i q_i})
\end{equation}

\paragraph{Quantize it!}

Let us focus on the pure state case:
we have a POVM \(\mathbb{E} = \qty{E_i}\), and two probability distributions \(\rho = \ketbra{\phi}\), \(\sigma = \ketbra{\psi}\)

\begin{equation}
  P_\phi (i) \defeq \Tr (E_i \rho) = \ev{\phi}{E_i}
\end{equation}

and similarly for \(\psi\).

The Bhattacharyya distance is

\begin{equation}
  d_B (\phi, \psi) = \sup _\mathbb{E} d_B\qty(\vec{P_\phi}, \vec{P_\psi})
\end{equation}

Theorem:

\begin{equation}
  d_B (\phi, \psi) = \cos^{-1} \abs{\braket{\phi}{\psi}}
\end{equation}

this is the Fubini-Study metric over a projective Hilbert space.

We can generalize this to differential geometry.

\begin{greenbox}
  In this particular case this can be expressed as
  \(\abs{\braket{\phi}{\psi}} = \sqrt{\Tr \qty(\rho\sigma)}\)
  but the result does not generalize.
\end{greenbox}
\end{document}


% !TEX root=/home/tavant/these/manuscript/src/manuscript.tex

\section{Objectives of the chapter}
\label{sec-ch4objectiv}

In \Cref{sec-sheath_validation}, we have seen that the plasma-wall interaction observed in the \ac{2D} \ac{PIC} simulations are different from the classical sheath models.
We recall here the main observations of \cref{ch-2}.
We have conducted a parametric study on the wall emissivity by varying the crossover energy $\crover$ in the emission probability
\begin{equation*}
  \proba = \sigo + ( 1 - \sigo) \frac{\ek}{\crover},
\end{equation*}
with $\ek$ the electron kinetic energy.
The \ac{SEE} rate (or yield) $\rate$ is the emission probability $\proba$ averaged over the electron flux at the wall.
With a Maxwellian flux of temperature $\Te$, we have
\begin{equation}  \label{eq-rate2}
  \ratemaxw = \sigo + ( 1 - \sigo) \frac{2 \Te}{\crover}.
\end{equation}
The sheath model with \ac{SEE} predicts a potential drop between the sheath-edge and the wall of \citep{goebel2008,hobbs1967}
\begin{equation} \label{eq-dphi2}
  \dphi = \Te \log \lp [1 - \rate] \sqrt{\frac{m_i}{2 \pi m_e}}  \rp.
\end{equation}

In \cref{ch-2}, \cref{fig-seeparamesMaxw} and \cref{fig-Tevsproba}.{\bf a} (reproduced here in \cref{fig-Tevsproba2} to ease the reading of the chapter) show both the plasma potential $\dphi$ and the \ac{SEE} rate $\rate$ measured in the \ac{PIC} simulations and obtained from \Cref{eq-rate2,eq-dphi2}.
We see that the plasma potential is overestimated for low values of $\rate$ by around 30\%.
Moreover, the \ac{SEE} rate is also overestimated.

\begin{figure}[hbt]
  \centering
  \begin{tabular}{@{} cc}
    \includegraphics[width=0.45\textwidth]{phi_drop_6}
    &
    \subfigure{SEE_rates}{{\scriptsize b}}{20,18}
  \end{tabular}
  \caption{({\bf a}) Plasma potential drop to the wall $\dphi$ normalized by the electron bulk temperature $\Te$ as a function of the electron rate (blue) measured in the \acs{PIC} simulations and (orange) calculated with   \cref{eq-dphi2}; ({\bf b})  the \acs{SEE} rate $\rate$ (blue) measured in the PIC simulation, and (orange)  calculated with \cref{eq-rate2}. }
  \label{fig-Tevsproba2}
\end{figure}

The discrepancy is most certainly due to the isothermal hypothesis.
In \cref{ch-3}, we have developed a sheath model without the isothermal hypothesis, but instead the polytropic state law.
The objective of this chapter is to add to the polytropic sheath model of \cref{ch-3} the electron emission from the wall, in order to better predict the plasma-wall interaction.


\section{Introduction}
  Modern online marketplaces can be roughly categorized as centralized and decentralized.
  Two major examples of each category are \href{http://www.ebay.com}{ebay} and \href{https://openbazaar.org/}{OpenBazaar}.
  The common denominator of established online marketplaces is that the reputation of each vendor and client is either
  expressed in the form of stars and user-generated reviews that are viewable by the whole network, or not expressed at
  all inside the marketplace and instead is entirely built on word-of-mouth or other out-of-band means.

  The goal of "Trust Is Risk" is to offer a decentralized marketplace where the trust each user gives to the rest of the users
  is quantifiable, measurable and expressable in monetary terms. The central concept used throughout this paper is that trust
  is equivalent to risk, or the proposition that $Alice$'s \textit{trust} to another user $Bob$ is defined to be the
  \textit{maximum sum of money} that $Alice$ can lose when $Bob$ is free to choose any strategy he wants. To flesh out this
  concept, we will use \textit{lines of credit} as proposed by Washington Sanchez \cite{loc}, not to be confused with the
  synonymous financial product. Joining the network will be done by explicitly entrusting a certain amount of money to another
  user, say $Bob$. If $Bob$ has already entrusted an amount of money to a third user, $Charlie$, then we indirectly trust
  $Charlie$ since if the latter wished to play unfairly, he could have already stolen the money entrusted to him by $Bob$.
  Thus we can engage in economic interaction with $Charlie$. The currency used is Bitcoin \cite{bitcoin}.
  \medskip \ \\
  \subimport{common/figures/}{simpleexample.tikz} \smallskip \ \\
  We thus propose a new kind of wallet where coins are not stored locally, but are placed in 1-of-2 multisigs, a bitcoin
  construction that permits any one of two pre-designated users to spend the coins contained therein \cite{masteringbitcoin}.
  We will use the notation 1/$\{Alice, Bob\}$ to represent a 1-of-2 multisig that can be spent by either $Alice$ or $Bob$.

  Our approach changes the user experience in a subtle but drastic way. A user no more has to base her trust towards a store
  on stars or ratings which are not expressed in financial units. She can simply consult her wallet to decide whether the
  store is trustworthy and, if so, up to what value, denominated in bitcoin. This system works as follows: Initially $Alice$
  migrates her funds from her private bitcoin wallet to 1-of-2 multisig addresses shared with friends she comfortably trusts.
  We call this direct trust. Our system is agnostic to the means players use to determine who is trustworthy for these direct
  1-of-2 deposits. One novelty of our system is that this dubious kind of trust is confined to the direct neighbourhood of
  each player; indirect trust towards unknown users is calculated by a deterministic algorithm.  For comparison, systems with
  global ratings do not distinguish between neighbours and other users, thus offering dubious trust indications for all users.

  Suppose that $Alice$ is viewing the item listings of vendor $Charlie$. Instead of $Charlie$'s stars, $Alice$ will see a
  positive value that is calculated by her wallet and represents the maximum monetary value that $Alice$ can safely use to
  complete a purchase from $Charlie$. We examine exactly how this value, known as indirect trust, is calculated in Trust Flow
  theorem~\ref{trustflow}. It is important to note here that indirect trust to a specific user is not global but subjective;
  each user views a personalized indirect trust based on the network topology. The indirect trust reported by our system
  maintains the following desired security property: If $Alice$ makes a purchase from $Charlie$, then she is exposed to no
  more risk than she was already taking willingly. The existing willing risk is exactly that which $Alice$ was taking by
  sharing her coins with her trusted friends. We prove this result in the Risk Invariance theorem~\ref{riskinv}. Obviously it
  will not be safe for $Alice$ to buy anything from $Charlie$ or any other vendor if she has entrusted no value to any other
  user.

  We see that in Trust Is Risk the money is not invested at the time of the purchase and directly to the vendor, but at an
  earlier point in time and only to parties that are trustworthy for out of band reasons. The fact that this system can
  function in a completely decentralized fashion will become clear in the following sections. We prove this result in the
  Sybil Resilience theorem~\ref{sybil}.

  There are several incentives for a user to join this network. First of all, she can have access to a store that is
  otherwise inaccessible. Moreover, two friends can formalize their mutual trust by entrusting the same amount to each
  other. A large company that casually subcontracts other companies to complete various tasks can express its trust
  towards them using this method. A government can choose to entrust its citizens with money and confront them using a
  corresponding legal arsenal if they make irresponsible use of this trust. A bank can provide loans as outgoing and
  manage savings as incoming trust and thus has a unique opportunity of expressing in a formal and absolute way its
  credence by publishing its incoming and outgoing trust. Last but not least, the network can be viewed as a possible
  field for investment and speculation since it constitutes a completely new area for financial activity.

  It is worth noting that the same physical person can maintain multiple pseudonymous identities in the same trust network
  and that multiple independent trust networks for different purposes can coexist. On the other hand, the same
  pseudonymous identity can be used to establish trust in different contexts.


\chapter{Methodology}
\label{ch:methods}

%This chapter should introduce to the theoretical background of your thesis. Any method you use to obtain the results later should be introduced and explained.
This chapter introduces the methods that are applied in this thesis. The first group of methods comprises the used forecasting methods, the second group involves feature selection techniques and the last group covers methods that are used to evaluate forecasts.\\
%This chapter introduces the methods that are applied in this thesis. First, the used forecasting methods are introduced. After that, the used feature selection techniques are explained and also the methods that were applied for error measuring.\\
%In this chapter, the used forecasting methods are explained and why they were used. After that, other methodological aspects of this thesis will be outlined.\\

%Using weather data from ECMWF Copernicus Climate Change Service (C3S).\\
%Using load data from \url{https://data.open-power-system-data.org/}.\\
%First downloaded whole Datasets from 2006-2019, but as the load for germany is properly available since 2015, now reduced dataset to 2015-2019.\\
%Also checked for non-existing values, only 2 last timestamps values for the load are missing.\\

%\section{Data acquisition}
%\label{sec:dataq}
%
%In order to acquire the needed weather data, \gls{ecmwf}'s Python-API is used for automated data acquisition. The API has been extended by some functionality recently and allows to download the data with different extensions. The chosen extension is .nc, because Python's xarray library allows performant access to these files.\\
%
%The used load data has been downloaded from Open Power System Data\footnote{\url{https://data.open-power-system-data.org/time_series/}}. As the format of the downloaded data is .csv, it has also been converted to .nc to obtain performant and uniform access to all data.\\

\section{Forecasting Methods}
\label{sec:forecastmet}

For time series forecasting, often used methods are \eg \gls{arma} models as mentioned in \tcite{Hyndman2018}. This sections will introduce the methods that are applied in this thesis to forecast the electricity load.\\% Forecasting: Principles and Practice\footnote{\url{https://otexts.com/fpp2}}.%, but  also \gls{nn}, where it is common to reduce the number of input variables in order to speed up computation, which is desirable for the huge amount of grid-based data that grows quadratically with size. There are also some papers that use regression models other than \gls{arma} such as \gls{lr}, \gls{mlr} or \gls{svm}. \tcite{Aguiar2016} applies \gls{nn} to do intra-day solar radiation forecasting with a forecasting horizon of 1-6 hours on Gran Canaria and, as in this thesis, grid-based data from \gls{ecmwf} is used.\\

%\subsection{Linear Regression}
\subsection*{ARMA}

The \gls{arma} model is a combination of \acrfull{ar} and \gls{ma} terms. The formal description is given by\\

\begin{equation}
y_t = c+\sum_{i=1}^{p}\phi_iy_{t-i}+\sum_{j=1}^{q}\rho_j\epsilon_{t-j}+\epsilon_t~,
\label{eq:arma}
\end{equation}

with $c$ as a constant, $\epsilon_t$ as noise term with respect to time $t$, $p$ as size of the \gls{ar} part, $q$ as size of the \gls{ma} part, $\phi$ and $\rho$ for the \gls{ar} and \gls{ma} coefficients respectively and $y_t$ as the response variable.\\

\subsection*{ARMAX}

An extension of \gls{arma} is \gls{armax}, which includes an additional term for exogenous variables. This term can be used to include relations to external factors that do not depend on the endogenous data. It is formally described as\\

\begin{equation}
y_t = c+\sum_{i=1}^{p}\phi_iy_{t-i}+\sum_{j=1}^{q}\rho_j\epsilon_{t-j}+\sum_{k=1}^{n}\eta_kx_k+\epsilon_t~.
\label{eq:armax}
\end{equation}

The only difference between \Cref{eq:armax} and \Cref{eq:arma} is the additional term $\sum_{k=1}^{n}\eta_kx_k$ for the \gls{armax} for $n$ included exogenous variables $x$ with $\eta$ as the respective coefficients.\\
%\Cref{eq:armax} almost equals \Cref{eq:arma} for the \gls{arma} model, but here, there is an additional term $\sum_{k=1}^{n}\eta_kx_k$ for $n$ included exogenous variables $x$ with $\eta$ as the respective coefficients.

%\subsubsection{only calendar variables as exogenous inputs}
%
%\subsubsection{additional weather variables as exogenous inputs}

\section{Feature Selection Techniques}
\label{sec:featsel}

Because the used weather data is grid-based, there are two more dimensions than usual, where only one value per time step exists for a variable. This is why feature selection here is more important in order to obtain a reasonable computation time. In the following, the used methods for feature selection are presented.\\

\subsection*{Naive approach}

First, naive techniques are presented, that are used to reduce the huge amount of grid-based weather data. They are reduced along the two spatial dimensions, longitude and latitude, for each step in time, respectively. These are simple functions such as the maximum or the mean. An exemplary formula for reducing the data along longitude and latitude using the mean is given as\\

\begin{equation}
x_t = \frac{1}{l \times m} \sum_{i=1}^{l}\sum_{j=1}^{m}x_{ij}~,
\end{equation}

where $x_t$ is the calculated mean for time $t$, $l$ and $m$ are the size of the data along the axis of the longitude and latitude and $x_{ij}$ is the value of a weather variable at the grid point with longitude $i$ and latitude $j$.

\subsection*{Using Population Data}

Another method involves population data from Eurostat\footnote{\url{https://ec.europa.eu/eurostat/data/database}}. It contains the population of NUTS 3 level regions. The regions are sorted by population and those with the highest population are used to filter the respective grid points that are then used as exogenous variables.\\

%\subsection{Principal Component Analysis}

\section{Forecast Evaluation}
\label{sec:fceval}

In order to estimate whether the used model performs well, it is important to apply suitable metrics to evaluate the results. In the following, the four used metrics are introduced, where for each metric, $k$ is the number of forecast values, $y$ the actual values and $\hat{y}$ the predicted values.\\

\subsection*{Root Mean Squared Error}

The first metric is the \gls{rmse}, which is an often used, scale-dependent accuracy measure that calculates the root of the squared mean of the differences between the forecast and the actual values. It is described by\\

\begin{equation}
RMSE = \sqrt{\frac{1}{k} \sum_{i=1}^{k} (y_i-\hat{y}_i)^2}~.
\label{eq:rmse}
\end{equation}

\subsection*{Mean Absolute Error}

The second metric is the \gls{mae}, which is another scale-dependent accuracy measure that averages absolute errors. The equation for the \gls{mae} is described by\\

\begin{equation}
MAE = \frac{1}{k} \sum_{i=1}^{k} \left|y_i-\hat{y}_i\right|~.
\end{equation}

\subsection*{Mean Percentage Error}

The third metric is the \gls{mpe}, which is a relative measure of the prediction accuracy. Since it is multiplied by 100 after dividing it by the size of the predictions, it is called a percentage error. The equation is\\
%The \gls{mpe} is the computed average of percentage errors by which forecasts of a model differ from actual values of the quantity being forecast

\begin{equation}
MPE = \frac{100}{k} \sum_{i=1}^{k} \frac{y_i-\hat{y}_i}{y_i}~.
\end{equation}

\subsection*{Mean Absolute Percentage Error}

The fourth metric is the \gls{mape}, which is similar to the \gls{mpe}, but takes the absolute value of each single error instead. The equation for the \gls{mape} is given by\\

\begin{equation}
MAPE = \frac{1}{k}\times 100 \sum_{i=1}^{k} \left|\frac{y_i-\hat{y}_i}{y_i}\right|~.
\label{eq:mape}
\end{equation}

%Maybe use Random Forests for variable selection as in Nicoles paper? \Parencite{Ludwig2015}\\

%This is an example for a simple equation without equation numbering.
%$$
%\sum\limits_{i=1}^{n}{x_i}
%$$

%You can also use equation numbering if you need to refer to an equation later \eg \Cref{eq:ex1}.

%\begin{equation}
%a^2 + b^2 = c^2
%\label{eq:ex1}
%\end{equation}
%
%Additionally, simple equations can be put inline with the text, for example, $x \in X$. Remember to set all variables in math font \ie all $x$, $i$ and so on.
%
%\section{Method 2}
%
%\dots


\chapter{The Second Chapter}
\label{sec:second}

\kant[7-11] % Dummy text

\begin{theorem}[{\cite[95]{AM69}}]
    \label{thm:dedekind}
    Let \( A \) be a Noetherian domain of dimension one. Then the following are equivalent:
    \begin{enumerate}
        \item \( A \) is integrally closed;
        \item Every primary ideal in \( A \) is a prime power;
        \item Every local ring \( A_\mathfrak{p} \) \( (\mathfrak{p} \neq 0) \) is a discrete valuation ring.
    \end{enumerate}
\end{theorem}


\documentclass[12pt]{article}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{parskip}
\usepackage{lipsum}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{setspace}
\usepackage[superscript]{cite}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{ifsym}
\usepackage{tikz}

\begin{document}

	\begin{flushright}
		\today
	\end{flushright}
	{\Large \textbf{Assignment 11}}

	{\large Query Optimization}

	\textsc{Ilaria Battiston - 03723403} \\
	\textsc{Mareva Zenelaj - 03736071}

	\rule{\linewidth}{0.5pt}

	\section{First exercise}

	$m = 3$

	$n = 2$

	$N = m * n = 6$

	$k = 2$

	$p = \frac{\binom{N - k}{k}}{\binom{N}{k}} = \frac{\binom{4}{2}}{\binom{6}{2}} = \frac{6}{15}$

	$\overline{{Yao}}_n^{N,m} (k) = m * {Yao}_n^N (k)$

	since $k \leq N - n$ then ${Yao}_2^6 (2) = 1 - p = 1 - 0.4 = 0.6$

	$\overline{{Yao}}_2^{6,3} (2) = 3 * 0.6 = 1.8$

	\section{Second exercise}

	$m = 3$

	$n = 2$

	$N = m * n = 6$

	$k = 4$

	Since the tuples are not necessarily distinct, we use Cheung's formula.

	$\overline{{Cheung}}_n^{N,m} (k) = m * {Cheung}_n^N (k)$

	where

    ${Cheung}_n^N (k) = [1-\tilde{p}]$

    and $\tilde{p} = \prod_{i=0}^{k-1} \frac{N-n+i}{N+i}$

    $\tilde{p} = \prod_{i=0}^{3} \frac{4+i}{6+i} = \frac{4}{6} * \frac{5}{7} * \frac{6}{8} * \frac{7}{9} = 0.278$

    $\overline{{Cheung}}_2^{6,3} = 3 * (1 - 0.278) = 2.167 $

    \section{Third exercise}

    \begin{center}
    \includegraphics[width=\textwidth]{yao_bernstein_waters.png}
    \end{center}

    Yao and Waters (red and green) results overlap in the graph.

    \section{Fourth exercise}

    \begin{center}
    \includegraphics[width=\textwidth]{cheung_cardenas.png}
    \end{center}

    Below we include all results together:
    \begin{center}
    \includegraphics[width=\textwidth]{all_approx.png}
    \end{center}

\end{document}


\section{Derived proof rules}

\subsection{Base logic}

\ralf{Give the most important derived rules.}

\paragraph{Persistent assertions.}
\begin{defn}
  An assertion $\prop$ is \emph{persistent} if $\prop \proves \always\prop$.
\end{defn}

Of course, $\always\prop$ is persistent for any $\prop$.
Furthermore, by the proof rules given above, $t = t'$ as well as $\ownGGhost{\mcore\melt}$ and $\knowInv\iname\prop$ are persistent.
Persistence is preserved by conjunction, disjunction, separating conjunction as well as universal and existential quantification.

In our proofs, we will implicitly add and remove $\always$ from persistent assertions as necessary, and generally treat them like normal, non-linear assumptions.

\subsection{Program logic}

\ralf{Sync this with Coq.}

Hoare triples and view shifts are syntactic sugar for weakest (liberal) preconditions and primitive view shifts, respectively:
\[
\hoare{\prop}{\expr}{\Ret\val.\propB}[\mask] \eqdef \always{(\prop \Ra \wpre{\expr}{\lambda\Ret\val.\propB}[\mask])}
\qquad\qquad
\begin{aligned}
\prop \vs[\mask_1][\mask_2] \propB &\eqdef \always{(\prop \Ra \pvs[\mask_1][\mask_2] {\propB})} \\
\prop \vsE[\mask_1][\mask_2] \propB &\eqdef \prop \vs[\mask_1][\mask_2] \propB \land \propB \vs[\mask2][\mask_1] \prop
\end{aligned}
\]
We write just one mask for a view shift when $\mask_1 = \mask_2$.
Clearly, all of these assertions are persistent.
The convention for omitted masks is similar to the base logic:
An omitted $\mask$ is $\top$ for Hoare triples and $\emptyset$ for view shifts.

\paragraph{View shifts.}~
The following rules can be derived for view shifts.

\begin{mathparpagebreakable}
\inferH{vs-update}
  {\melt \mupd \meltsB}
  {\ownGGhost{\melt} \vs \exists \meltB \in \meltsB.\; \ownGGhost{\meltB}}
\and
\inferH{vs-trans}
  {\prop \vs[\mask_1][\mask_2] \propB \and \propB \vs[\mask_2][\mask_3] \propC \and \mask_2 \subseteq \mask_1 \cup \mask_3}
  {\prop \vs[\mask_1][\mask_3] \propC}
\and
\inferH{vs-imp}
  {\always{(\prop \Ra \propB)}}
  {\prop \vs[\emptyset] \propB}
\and
\inferH{vs-mask-frame}
  {\prop \vs[\mask_1][\mask_2] \propB}
  {\prop \vs[\mask_1 \uplus \mask'][\mask_2 \uplus \mask'] \propB}
\and
\inferH{vs-frame}
  {\prop \vs[\mask_1][\mask_2] \propB}
  {\prop * \propC \vs[\mask_1][\mask_2] \propB * \propC}
\and
\inferH{vs-timeless}
  {\timeless{\prop}}
  {\later \prop \vs \prop}
\and
\inferH{vs-allocI}
  {\infinite(\mask)}
  {\later{\prop} \vs[\mask] \exists \iname\in\mask.\; \knowInv{\iname}{\prop}}
\and
\axiomH{vs-openI}
  {\knowInv{\iname}{\prop} \proves \TRUE \vs[\{ \iname \} ][\emptyset] \later \prop}
\and
\axiomH{vs-closeI}
  {\knowInv{\iname}{\prop} \proves \later \prop \vs[\emptyset][\{ \iname \} ] \TRUE }

\inferHB{vs-disj}
  {\prop \vs[\mask_1][\mask_2] \propC \and \propB \vs[\mask_1][\mask_2] \propC}
  {\prop \lor \propB \vs[\mask_1][\mask_2] \propC}
\and
\inferHB{vs-exist}
  {\All \var. (\prop \vs[\mask_1][\mask_2] \propB)}
  {(\Exists \var. \prop) \vs[\mask_1][\mask_2] \propB}
\and
\inferHB{vs-box}
  {\always\propB \proves \prop \vs[\mask_1][\mask_2] \propC}
  {\prop \land \always{\propB} \vs[\mask_1][\mask_2] \propC}
 \and
\inferH{vs-false}
  {}
  {\FALSE \vs[\mask_1][\mask_2] \prop }
\end{mathparpagebreakable}

\paragraph{Hoare triples.}
The following rules can be derived for Hoare triples.

\begin{mathparpagebreakable}
\inferH{Ht-ret}
  {}
  {\hoare{\TRUE}{\valB}{\Ret\val. \val = \valB}[\mask]}
\and
\inferH{Ht-bind}
  {\text{$\lctx$ is a context} \and \hoare{\prop}{\expr}{\Ret\val. \propB}[\mask] \\
   \All \val. \hoare{\propB}{\lctx(\val)}{\Ret\valB.\propC}[\mask]}
  {\hoare{\prop}{\lctx(\expr)}{\Ret\valB.\propC}[\mask]}
\and
\inferH{Ht-csq}
  {\prop \vs \prop' \\
    \hoare{\prop'}{\expr}{\Ret\val.\propB'}[\mask] \\
   \All \val. \propB' \vs \propB}
  {\hoare{\prop}{\expr}{\Ret\val.\propB}[\mask]}
\and
\inferH{Ht-mask-weaken}
  {\hoare{\prop}{\expr}{\Ret\val. \propB}[\mask]}
  {\hoare{\prop}{\expr}{\Ret\val. \propB}[\mask \uplus \mask']}
\\\\
\inferH{Ht-frame}
  {\hoare{\prop}{\expr}{\Ret\val. \propB}[\mask]}
  {\hoare{\prop * \propC}{\expr}{\Ret\val. \propB * \propC}[\mask]}
\and
\inferH{Ht-frame-step}
  {\hoare{\prop}{\expr}{\Ret\val. \propB}[\mask] \and \toval(\expr) = \bot}
  {\hoare{\prop * \later\propC}{\expr}{\Ret\val. \propB * \propC}[\mask]}
\and
\inferH{Ht-atomic}
  {\prop \vs[\mask \uplus \mask'][\mask] \prop' \\
    \hoare{\prop'}{\expr}{\Ret\val.\propB'}[\mask] \\
   \All\val. \propB' \vs[\mask][\mask \uplus \mask'] \propB \\
   \physatomic{\expr}
  }
  {\hoare{\prop}{\expr}{\Ret\val.\propB}[\mask \uplus \mask']}
\and
\inferHB{Ht-disj}
  {\hoare{\prop}{\expr}{\Ret\val.\propC}[\mask] \and \hoare{\propB}{\expr}{\Ret\val.\propC}[\mask]}
  {\hoare{\prop \lor \propB}{\expr}{\Ret\val.\propC}[\mask]}
\and
\inferHB{Ht-exist}
  {\All \var. \hoare{\prop}{\expr}{\Ret\val.\propB}[\mask]}
  {\hoare{\Exists \var. \prop}{\expr}{\Ret\val.\propB}[\mask]}
\and
\inferHB{Ht-box}
  {\always\propB \proves \hoare{\prop}{\expr}{\Ret\val.\propC}[\mask]}
  {\hoare{\prop \land \always{\propB}}{\expr}{\Ret\val.\propC}[\mask]}
\and
\inferH{Ht-false}
  {}
  {\hoare{\FALSE}{\expr}{\Ret \val. \prop}[\mask]}
\end{mathparpagebreakable}

\clearpage
\section{Derived constructions}

In this section we describe some derived constructions that are generally useful and language-independent.

\ralf{Describe at least global monoid and invariant namespaces.}
% \subsection{Global monoid}

% Hereinafter we assume the global monoid (served up as a parameter to Iris) is obtained from a family of monoids $(M_i)_{i \in I}$ by first applying the construction for finite partial functions to each~(\Sref{sec:fpfunm}), and then applying the product construction~(\Sref{sec:prodm}):
% \[ M \eqdef \prod_{i \in I} \textdom{GhName} \fpfn M_i \]
% We don't care so much about what concretely $\textdom{GhName}$ is, as long as it is countable and infinite.
% We write $\ownGhost{\gname}{\melt : M_i}$ (or just $\ownGhost{\gname}{\melt}$ if $M_i$ is clear from the context) for $\ownGGhost{[i \mapsto [\gname \mapsto \melt]]}$ when $\melt \in \mcarp {M_i}$, and for $\FALSE$ when $\melt = \mzero_{M_i}$.
% In other words, $\ownGhost{\gname}{\melt : M_i}$ asserts that in the current state of monoid $M_i$, the name $\gname$ is allocated and has at least value $\melt$.

% From~\ruleref{FpUpd} and the multiplications and frame-preserving updates in~\Sref{sec:prodm} and~\Sref{sec:fpfunm}, we have the following derived rules.
% \begin{mathpar}
% 	\axiomH{NewGhost}{
% 		\TRUE \vs \Exists\gname. \ownGhost\gname{\melt : M_i}
% 	}
% 	\and
% 	\inferH{GhostUpd}
%     {\melt \mupd_{M_i} B}
%     {\ownGhost\gname{\melt : M_i} \vs \Exists \meltB\in B. \ownGhost\gname{\meltB : M_i}}
%   \and
%   \axiomH{GhostEq}
%     {\ownGhost\gname{\melt : M_i} * \ownGhost\gname{\meltB : M_i} \Lra \ownGhost\gname{\melt\mtimes\meltB : M_i}}

%   \axiomH{GhostUnit}
%     {\TRUE \Ra \ownGhost{\gname}{\munit : M_i}}

%   \axiomH{GhostZero}
%     {\ownGhost\gname{\mzero : M_i} \Ra \FALSE}

%   \axiomH{GhostTimeless}
%     {\timeless{\ownGhost\gname{\melt : M_i}}}
% \end{mathpar}

% \subsection{STSs with interpretation}\label{sec:stsinterp}

% Building on \Sref{sec:stsmon}, after constructing the monoid $\STSMon{\STSS}$ for a particular STS, we can use an invariant to tie an interpretation, $\pred : \STSS \to \Prop$, to the STS's current state, recovering CaReSL-style reasoning~\cite{caresl}.

% An STS invariant asserts authoritative ownership of an STS's current state and that state's interpretation:
% \begin{align*}
%   \STSInv(\STSS, \pred, \gname) \eqdef{}& \Exists s \in \STSS. \ownGhost{\gname}{(s, \STSS, \emptyset):\STSMon{\STSS}} * \pred(s) \\
%   \STS(\STSS, \pred, \gname, \iname) \eqdef{}& \knowInv{\iname}{\STSInv(\STSS, \pred, \gname)}
% \end{align*}

% We can specialize \ruleref{NewInv}, \ruleref{InvOpen}, and \ruleref{InvClose} to STS invariants:
% \begin{mathpar}
%  \inferH{NewSts}
%   {\infinite(\mask)}
%   {\later\pred(s) \vs[\mask] \Exists \iname \in \mask, \gname.   \STS(\STSS, \pred, \gname, \iname) * \ownGhost{\gname}{(s, \STST \setminus \STSL(s)) : \STSMon{\STSS}}}
%  \and
%  \axiomH{StsOpen}
%   {  \STS(\STSS, \pred, \gname, \iname) \vdash \ownGhost{\gname}{(s_0, T) : \STSMon{\STSS}} \vsE[\{\iname\}][\emptyset] \Exists s\in \upclose(\{s_0\}, T). \later\pred(s) * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T):\STSMon{\STSS}}}
%  \and
%  \axiomH{StsClose}
%   {  \STS(\STSS, \pred, \gname, \iname), (s, T) \ststrans (s', T')  \proves \later\pred(s') * \ownGhost{\gname}{(s, S, T):\STSMon{\STSS}} \vs[\emptyset][\{\iname\}] \ownGhost{\gname}{(s', T') : \STSMon{\STSS}} }
% \end{mathpar}
% \begin{proof}
% \ruleref{NewSts} uses \ruleref{NewGhost} to allocate $\ownGhost{\gname}{(s, \upclose(s, T), T) : \STSMon{\STSS}}$ where $T \eqdef \STST \setminus \STSL(s)$, and \ruleref{NewInv}.

% \ruleref{StsOpen} just uses \ruleref{InvOpen} and \ruleref{InvClose} on $\iname$, and the monoid equality $(s, \upclose(\{s_0\}, T), T) = (s, \STSS, \emptyset) \mtimes (\munit, \upclose(\{s_0\}, T), T)$.

% \ruleref{StsClose} applies \ruleref{StsStep} and \ruleref{InvClose}.
% \end{proof}

% Using these view shifts, we can prove STS variants of the invariant rules \ruleref{Inv} and \ruleref{VSInv}~(compare the former to CaReSL's island update rule~\cite{caresl}):
% \begin{mathpar}
%  \inferH{Sts}
%   {\All s \in \upclose(\{s_0\}, T). \hoare{\later\pred(s) * P}{\expr}{\Ret \val. \Exists s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * Q}[\mask]
%    \and \physatomic{\expr}}
%   {  \STS(\STSS, \pred, \gname, \iname) \vdash \hoare{\ownGhost{\gname}{(s_0, T):\STSMon{\STSS}} * P}{\expr}{\Ret \val. \Exists s', T'. \ownGhost{\gname}{(s', T'):\STSMon{\STSS}} * Q}[\mask \uplus \{\iname\}]}
%  \and
%  \inferH{VSSts}
%   {\forall s \in \upclose(\{s_0\}, T).\; \later\pred(s) * P \vs[\mask_1][\mask_2] \exists s', T'.\; (s, T) \ststrans (s', T') * \later\pred(s') * Q}
%   {  \STS(\STSS, \pred, \gname, \iname) \vdash \ownGhost{\gname}{(s_0, T):\STSMon{\STSS}} * P \vs[\mask_1 \uplus \{\iname\}][\mask_2 \uplus \{\iname\}] \Exists s', T'. \ownGhost{\gname}{(s', T'):\STSMon{\STSS}} * Q}
% \end{mathpar}

% \begin{proof}[Proof of \ruleref{Sts}]\label{pf:sts}
%  We have to show
%  \[\hoare{\ownGhost{\gname}{(s_0, T):\STSMon{\STSS}} * P}{\expr}{\Ret \val. \Exists s', T'. \ownGhost{\gname}{(s', T'):\STSMon{\STSS}} * Q}[\mask \uplus \{\iname\}]\]
%  where $\val$, $s'$, $T'$ are free in $Q$.

%  First, by \ruleref{ACsq} with \ruleref{StsOpen} and \ruleref{StsClose} (after moving $(s, T) \ststrans (s', T')$ into the view shift using \ruleref{VSBoxOut}), it suffices to show
%  \[\hoareV{\Exists s\in \upclose(\{s_0\}, T). \later\pred(s) * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)} * P}{\expr}{\Ret \val. \Exists s, T, S, s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * \ownGhost{\gname}{(s, S, T):\STSMon{\STSS}} * Q(\val, s', T')}[\mask]\]

%  Now, use \ruleref{Exist} to move the $s$ from the precondition into the context and use \ruleref{Csq} to (i)~fix the $s$ and $T$ in the postcondition to be the same as in the precondition, and (ii)~fix $S \eqdef \upclose(\{s_0\}, T)$.
%  It remains to show:
%  \[\hoareV{s\in \upclose(\{s_0\}, T) * \later\pred(s) * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)} * P}{\expr}{\Ret \val. \Exists s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * \ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)} * Q(\val, s', T')}[\mask]\]

%  Finally, use \ruleref{BoxOut} to move $s\in \upclose(\{s_0\}, T)$ into the context, and \ruleref{Frame} on $\ownGhost{\gname}{(s, \upclose(\{s_0\}, T), T)}$:
%  \[s\in \upclose(\{s_0\}, T) \vdash \hoare{\later\pred(s) * P}{\expr}{\Ret \val. \Exists s', T'. (s, T) \ststrans (s', T') * \later\pred(s') * Q(\val, s', T')}[\mask]\]

%  This holds by our premise.
% \end{proof}

% % \begin{proof}[Proof of \ruleref{VSSts}]
% % This is similar to above, so we only give the proof in short notation:

% % \hproof{%
% % 	Context: $\knowInv\iname{\STSInv(\STSS, \pred, \gname)}$ \\
% % 	\pline[\mask_1 \uplus \{\iname\}]{
% % 		\ownGhost\gname{(s_0, T)} * P
% % 	} \\
% % 	\pline[\mask_1]{%
% % 		\Exists s. \later\pred(s) * \ownGhost\gname{(s, S, T)} * P
% % 	} \qquad by \ruleref{StsOpen} \\
% % 	Context: $s \in S \eqdef \upclose(\{s_0\}, T)$ \\
% % 	\pline[\mask_2]{%
% % 		 \Exists s', T'. \later\pred(s') * Q(s', T') * \ownGhost\gname{(s, S, T)}
% % 	} \qquad by premiss \\
% % 	Context: $(s, T) \ststrans (s', T')$ \\
% % 	\pline[\mask_2 \uplus \{\iname\}]{
% % 		\ownGhost\gname{(s', T')} * Q(s', T')
% % 	} \qquad by \ruleref{StsClose}
% % }
% % \end{proof}

% \subsection{Authoritative monoids with interpretation}\label{sec:authinterp}

% Building on \Sref{sec:auth}, after constructing the monoid $\auth{M}$ for a cancellative monoid $M$, we can tie an interpretation, $\pred : \mcarp{M} \to \Prop$, to the authoritative element of $M$, recovering reasoning that is close to the sharing rule in~\cite{krishnaswami+:icfp12}.

% Let $\pred_\bot$ be the extension of $\pred$ to $\mcar{M}$ with $\pred_\bot(\mzero) = \FALSE$.
% Now define
% \begin{align*}
%   \AuthInv(M, \pred, \gname) \eqdef{}& \exists \melt \in \mcar{M}.\; \ownGhost{\gname}{\authfull \melt:\auth{M}} * \pred_\bot(\melt) \\
%   \Auth(M, \pred, \gname, \iname) \eqdef{}& M~\textlog{cancellative} \land \knowInv{\iname}{\AuthInv(M, \pred, \gname)}
% \end{align*}

% The frame-preserving updates for $\auth{M}$ gives rise to the following view shifts:
% \begin{mathpar}
%  \inferH{NewAuth}
%   {\infinite(\mask) \and M~\textlog{cancellative}}
%   {\later\pred_\bot(a) \vs[\mask] \exists \iname \in \mask, \gname.\; \Auth(M, \pred, \gname, \iname) * \ownGhost{\gname}{\authfrag a : \auth{M}}}
%  \and
%  \axiomH{AuthOpen}
%   {\Auth(M, \pred, \gname, \iname) \vdash \ownGhost{\gname}{\authfrag \melt : \auth{M}} \vsE[\{\iname\}][\emptyset] \exists \melt_f.\; \later\pred_\bot(\melt \mtimes \melt_f) * \ownGhost{\gname}{\authfull \melt \mtimes \melt_f, \authfrag a:\auth{M}}}
%  \and
%  \axiomH{AuthClose}
%   {\Auth(M, \pred, \gname, \iname) \vdash \later\pred_\bot(\meltB \mtimes \melt_f) * \ownGhost{\gname}{\authfull a \mtimes \melt_f, \authfrag a:\auth{M}} \vs[\emptyset][\{\iname\}] \ownGhost{\gname}{\authfrag \meltB : \auth{M}} }
% \end{mathpar}

% These view shifts in turn can be used to prove variants of the invariant rules:
% \begin{mathpar}
%  \inferH{Auth}
%   {\forall \melt_f.\; \hoare{\later\pred_\bot(a \mtimes \melt_f) * P}{\expr}{\Ret\val. \exists \meltB.\; \later\pred_\bot(\meltB\mtimes \melt_f) * Q}[\mask]
%    \and \physatomic{\expr}}
%   {\Auth(M, \pred, \gname, \iname) \vdash \hoare{\ownGhost{\gname}{\authfrag a:\auth{M}} * P}{\expr}{\Ret\val. \exists \meltB.\; \ownGhost{\gname}{\authfrag \meltB:\auth{M}} * Q}[\mask \uplus \{\iname\}]}
%  \and
%  \inferH{VSAuth}
%   {\forall \melt_f.\; \later\pred_\bot(a \mtimes \melt_f) * P \vs[\mask_1][\mask_2] \exists \meltB.\; \later\pred_\bot(\meltB \mtimes \melt_f) * Q(\meltB)}
%   {\Auth(M, \pred, \gname, \iname) \vdash
%    \ownGhost{\gname}{\authfrag a:\auth{M}} * P \vs[\mask_1 \uplus \{\iname\}][\mask_2 \uplus \{\iname\}]
%    \exists \meltB.\; \ownGhost{\gname}{\authfrag \meltB:\auth{M}} * Q(\meltB)}
% \end{mathpar}

% \subsection{Ghost heap}
% \label{sec:ghostheap}%

% We define a simple ghost heap with fractional permissions.
% Some modules require a few ghost names per module instance to properly manage ghost state, but would like to expose to clients a single logical name (avoiding clutter).
% In such cases we use these ghost heaps.

% We seek to implement the following interface:
% \newcommand{\GRefspecmaps}{\textsf{GMapsTo}}%
% \begin{align*}
%  \exists& {\fgmapsto[]} : \textsort{Val} \times \mathbb{Q}_{>} \times \textsort{Val} \ra \textsort{Prop}.\;\\
%   & \All x, q, v. x \fgmapsto[q] v \Ra x \fgmapsto[q] v \land q \in (0, 1] \\
%   &\forall x, q_1, q_2, v, w.\; x \fgmapsto[q_1] v * x \fgmapsto[q_2] w \Leftrightarrow x \fgmapsto[q_1 + q_2] v * v = w\\
%   & \forall v.\; \TRUE \vs[\emptyset] \exists x.\; x \fgmapsto[1] v \\
%   & \forall x, v, w.\; x \fgmapsto[1] v \vs[\emptyset] x \fgmapsto[1] w
% \end{align*}
% We write $x \fgmapsto v$ for $\exists q.\; x \fgmapsto[q] v$ and $x \gmapsto v$ for $x \fgmapsto[1] v$.
% Note that $x \fgmapsto v$ is duplicable but cannot be boxed (as it depends on resources); \ie we have $x \fgmapsto v \Lra x \fgmapsto v * x \fgmapsto v$ but not $x \fgmapsto v \Ra \always x \fgmapsto v$.

% To implement this interface, allocate an instance $\gname_G$ of $\FHeap(\textdom{Val})$ and define
% \[
% 	x \fgmapsto[q] v \eqdef
% 	  \begin{cases}
%     	\ownGhost{\gname_G}{x \mapsto (q, v)} & \text{if $q \in (0, 1]$} \\
%     	\FALSE & \text{otherwise}
%     \end{cases}
% \]
% The view shifts in the specification follow immediately from \ruleref{GhostUpd} and the frame-preserving updates in~\Sref{sec:fheapm}.
% The first implication is immediate from the definition.
% The second implication follows by case distinction on $q_1 + q_2 \in (0, 1]$.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "iris"
%%% End: