\documentclass{article}
\usepackage{amsmath,mathtools,amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{blkarray}
\usepackage{gensymb}
\usepackage{verbatim}
\usepackage{mathrsfs}
\usepackage{bbm}
\usepackage{braket}
\usepackage{hyperref}
\usepackage{verbatim}
\usepackage{cancel}
\usepackage[margin=1.0in]{geometry}
\newcommand{\ol}{\overline}
\newcommand{\lp}{\left(}
\newcommand{\rp}{\right)}
\newcommand{\eps}{\varepsilon}
\newcommand{\lam}{\lambda}
\newcommand{\h}{\circ}
\newcommand{\p}{\bullet}

\newcommand{\Ezero}{E^{(0)}}
\newcommand{\Rz}{\mathcal{R}_{0}}

\newcommand{\Phizero}{\Phi^{(0)}}
\newcommand{\Eone}{E^{(1)}}
\newcommand{\En}{E^{(n)}}
\newcommand{\Phione}{\Phi^{(1)}}
\newcommand{\Phin}{\Phi^{(n)}}

\newcommand{\Ecorr}{E_{\mathrm{corr}}}
\newcommand{\Hc}{H_{\mathrm{c}}}
\newcommand{\dg}{\ensuremath{^\dagger} }
\def\*#1{\mathbf{#1}}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\title{Lecture 5: Perturbation Theory II}
\date{April 6, 2020}
\begin{document}
\maketitle
\noindent

In perturbation theory, we split our Hamiltonian into parts $H = H_0 + V$, and our ground
state wavefunction $\ket{\Psi_0}$ and energy $E_0$ are expressed as an infinite series, where the first term is the unperturbed
quantity of some simpler model system described by $H_0$, and the rest of the terms
are corrections at various ``orders'' $n$:
\[\ket{\Psi_0} = \ket{\Phi_0} + \sum_{n=1}^{\infty} \ket{\Phin_0} \]
\[E_0 = \Ezero_0 + \sum_{n=1}^{\infty} \En_0\]

As we saw in the previous set of notes, the expression for each wavefunction and energy correction
    needs to be derived from a system of equations.
This way of doing things is very inefficient at high orders, so in this set of notes
    we will use a new scheme, which was primarily popularized and championed by Per-Olav L{\"o}wdin
    in his highly influential series of papers \textit{Studies in Perturbation Theory} in the 1960s.
The majority of the content in these notes can be found in the 9th (IX) paper in the series.
This new methodology will allow you to derive each order of PT using the same exact procedure.
Though the higher order wavefunctions and energy expressions get more and more complex,
the procedure for deriving them does not change at higher orders.
This methodology also beautifully translates into clean diagrams, which we will see later on.

%\section{L{\"o}wdin and his Resolvents}
\section{The Wave Operator}
Suppose there was some magical operator $\Omega$ which
acts on the unperturbed state $\ket{\Phi_0}$ (an eigenstate of $H_0$)
and transforms it into the exact state $\ket{\Psi_0}$ described by $H_0 + V$
\[\ket{\Psi_0} = \Omega \ket{\Phi_0} \]
We will call $\Omega$ the \textit{wave operator}.
For now, we have no idea what it is, but we do know what it does.
Suppose further that we are using an intermediate normalized $\Psi_0$ and normalized $\Phi_0$ such that
\[ \braket{\Phi_0|\Phi_0} = 1 \]
\[ \braket{\Phi_0 | \Psi_0} = \braket{\Phi_0 | \Omega | \Phi_0} = 1 \]
Under the above conditions, we will now see what happens to the Schr{\"o}dinger equation,
\[(H_0 + V) \ket{\Psi_0} = E_0 \ket{\Psi_0} \]
Projecting both sides of this equation by $\bra{\Phi_0}$ gives
\[\braket{\Phi_0 | H_0 | \Psi_0} + \braket{\Phi_0 | V | \Psi_0} = E_0 \braket{\Phi_0|\Psi_0} \]
The first term reduces to $\Ezero_0$ by acting $H_0$ to the left. The second term
can be re-expressed in terms of $\Omega$, and we obtain an expression for the
perturbed eigenvalue $E_0$ in terms of a \textit{shift} from the unperturbed eigenvalue $\Ezero_0$.
\[ E_0 = \Ezero_0 + \braket{\Phi_0 | V \Omega | \Phi_0}  \]
If we were to know what $\Omega$ is, at this point the eigenstates and eigenvalues would be completely
determined.
L{\"o}wdin derived that such an $\Omega$ can be constructed from an operator called a \textit{resolvent},
and under this definition, $\Omega$ yields the same perturbation expansion for $E_0$ and $\ket{\Psi_0}$.

\section{Resolvents}
A resolvent is a mathematical structure which is used to study the eigenspectrum
of operators, among other things.
The concept of a \textit{reduced resolvent} arises when one considers an eigenvalue problem \[A \phi = a \phi \]

Suppose the eigenfunctions $\phi$ can be expanded in an orthonormal basis ($f_1$, $f_2$, $f_3$,...) such that $\sum_i c_i f_i $
and let $\mathbf{A}_{ij} = \braket{f_i | A | f_j}$ be the matrix representation of the operator $A$ in this basis.
Suppose we divide the basis $f$ into two partitions $p$ and $q$.
If the $p$ partition is just a single basis function ($p: {f_1}$) (which we will just denote by the number 1) and the $q$ partition
    is all other basis functions ($q: {f_2, f_3,...}$),
    one finds with some manipulation that the eigenvalues are defined by the relation
\[ a =  A_{11} + \mathbf{A}_{1q}( a \cdot \mathbf{1}_{qq} - \mathbf{A}_{qq})^{-1} \mathbf{A}_{q1} \]
The above is the ``reduced'' characteristic equation, and it can be used for finding the eigenvalues.
It arises in the particular case of our partitioning of our basis in this manner.
The above equation can be thought of as an alternative to the standard characteristic equation $\mathrm{det}(\mathbf{A} - a\mathbf{1}) = 0$.

If we replace the eigenvalues $a$ in the expression above with some continuous, variable parameter $\kappa$, we obtain the following:
\[f(\kappa) =  A_{11} + \mathbf{A}_{1q}( \kappa \cdot \mathbf{1}_{qq} - \mathbf{A}_{qq})^{-1} \mathbf{A}_{q1} \]

Now, whenever this function is such that $f(\kappa) = \kappa $, we have found an eigenvalue $a = \kappa$.
If we vary this $\kappa$ until $f(\kappa) - \kappa = 0$, we pull out a discrete eigenvalue which is a solution to the eigenvalue problem.

The key quantity above
\[\mathcal{R}_{\kappa}(A) = ( \kappa \cdot \mathbf{1}_{qq} - \mathbf{A}_{qq})^{-1}\]
is the \textbf{reduced resolvent} operator of $\mathbf{A}$ for a particular $\kappa$.
\footnote{Here, $\mathbf{1}_{qq}$ is the identity matrix of size $q \times q$ and $\mathbf{A}_{qq}$ is
 the matrix representation of the operator in just the $q$-space, (over just $q$ basis functions)}
In words, the reduced resolvent is an operator that is assigned to another operator $\mathbf{A}$.
It is only defined in $q$-space part of the operator, and different values of $\kappa$ give different reduced resolvents.
As abstract as that is, it is tremendously useful, as we will see later.

Notice how the resolvent is dependent on just the matrix elements of the operator $\mathbf{A}$
which correspond to the $q$ partition; it lives in the $q$-space partition of our basis.
Expressed pictorially as a matrix representation divided into $pp$, $pq$, $qp$, $qq$ blocks,
\[\mathcal{R}_{\kappa}(A) =
\left( \begin{array}{c|c}
   0 & \mathbf{0} \\
   \midrule
   \mathbf{0} & (\kappa \mathbf{1}_{qq} - A_{qq})^{-1} \\
\end{array}\right)
  \]

\section{L{\"o}wdin's big idea: using reduced resolvents to define perturbation theory and solve the Schr{\"o}dinger equation}
Back to the world of quantum chemistry and the Schr{\"o}dinger equation,
we can define two projection operators $P$ and $Q$ which partition our $n$-electron Hilbert space into two parts (note: if that sounds like gobbledygook to you, see the Appendix for details).
It is this partitioning which birthed the idea of a reduced resolvent above.

$P$ is the ``model space projection operator'', which can act on a state
    and project it onto some reference determinant $\Phi_0$.
\[P = \ket{\Phi_0}\bra{\Phi_0}  \]
$Q$ is the \textit{orthogonal complement} of $P$, which projects out every determinant other than the reference $\Phi_0$
\[Q = 1 - P = \sum_{n \neq 0}  \ket{\Phi_n}\bra{\Phi_n}\]
$P$ and $Q$ basically just split our basis into two parts, and the sum of $P$ and $Q$ yield the resolution of the identity, $P + Q = 1$.
In terms of operators, the definition of the reduced resolvent for some operator $H$ is
\[\mathcal{R}_{\kappa} = (\kappa - H)^{-1} Q  \]
This is the operator analogue of the matrix representation form of $\mathcal{R}_{\kappa}(A)$
we defined earlier. Instead of only explicitly including matrix elements in the $q$ space,
we use our newly defined operator $Q$ to project the negative inverse of $H$ into the $Q$ space.
%TODO

L{\"o}wdin's idea, in short, was to generalize the Schr{\"o}dinger equation
to a continous spectrum in $\kappa$, and use the $\kappa$-dependent reduced resolvent in the definition of
a trial wavefunction to solve for the eigenvalues. Read that last sentence a few more times.
Hopefully, it will soon become clear what I mean by this.
Starting from the re-arranged Schr{\"o}dinger equation,
\[(E_0 - H) \ket{\Psi_0} = 0 \]
suppose we choose a form for the wavefunction which has a continuous dependence on some parameter
$\kappa$:
\[(\kappa - H) \ket{\Psi_{\kappa}} = ... \]
The above equation \textit{becomes} the Schrodinger equation whenever the right side is 0.
If this is the case, $\kappa$ happens to be equal to a true eigenvalue $E_0$.
For this reason, we refer to it as a \textit{generalization} of the Schr{\"o}dinger equation.

L{\"o}wdin derived that a \textbf{trial wavefunction} $\ket{\Psi_{\kappa}}$
    which is of the form $\ket{\Psi_\kappa} = \Omega_\kappa \ket{\Phi_0}$
    can be expressed in terms of the reduced resolvent.
\[\ket{\Psi_\kappa} = \Omega_\kappa \ket{\Phi_0}\]
\[\Omega_{\kappa} = P + \mathcal{R}_{\kappa} H P \]
\[\ket{\Psi_{\kappa}} = \ket{\Phi_0} + \mathcal{R}_{\kappa} H \ket{\Phi_0} \]

What happens when we apply $(\kappa - H)$ to our trial wavefunction $\ket{\Psi_{\kappa}}$?
as in the above expression $(\kappa - H) \ket{\Psi_{\kappa}} = ... $?
Applying the resolution of the identity $P + Q = 1$, we find
\[ (\kappa - H) \ket{\Psi_{\kappa}} =  P (\kappa - H) \ket{\Psi_{\kappa}} + Q (\kappa - H) \ket{\Psi_{\kappa}}  \]
Looking at just the $Q$ term, we find that
\begin{align*}
Q (\kappa - H) \ket{\Psi_{\kappa}} &= Q (\kappa - H) \ket{\Phi_0} + Q (\kappa - H) \mathcal{R}_{\kappa} H \ket{\Phi_0}  \\
&= \kappa Q \ket{\Phi_0} - Q H \ket{\Phi_0} + Q H \ket{\Phi_0}  \\
&= \kappa Q \ket{\Phi_0}  \\
&= 0
\end{align*}
Above we have used the fact that $ Q (\kappa - H) \mathcal{R}_{\kappa}  = Q$ , which follows
clearly from the definition of the reduced resolvent, and that $Q$ acting on $\ket{\Phi_0}$ is 0, since
$\ket{\Phi_0}$ lives in the $P$ space.
We conclude the $Q$ term is 0, so we are left with:
\[ (\kappa - H) \ket{\Psi_{\kappa}} =  P (\kappa - H) \ket{\Psi_{\kappa}} \]
Using the definition of $P = \ket{\Phi_0}\bra{\Phi_0}$, and noting that we can always ensure $\ket{\Psi_\kappa}$ is intermediately normalized, we obtain
\begin{align*}
 (\kappa - H) \ket{\Psi_{\kappa}} &=  \ket{\Phi_0}\bra{\Phi_0} (\kappa - H) \ket{\Psi_{\kappa}} \\
 &=  \kappa \ket{\Phi_0} \braket{\Phi_0|\Psi_\kappa} - \ket{\Phi_0} \braket{\Phi_0| H | \Psi_\kappa} \\
 &= (\kappa - \braket{\Phi_0 | H | \Psi_\kappa}) \ket{\Phi_0} \\
 &= (\kappa - \braket{\Phi_0 | H \Omega_\kappa | \Phi_0}) \ket{\Phi_0} \\
 &= (\kappa - \braket{\Phi_0 | H + H \mathcal{R}_\kappa H  | \Phi_0} ) \ket{\Phi_0} \\
 &= (\kappa - f(\kappa)) \ket{\Phi_0}
\end{align*}

where we have defined the function of $\kappa$, denoted  $f(\kappa)$ as
\[ f(\kappa) =  \braket{\Phi_0 | H | \Psi_\kappa} = \braket{\Phi_0 | H + H \mathcal{R}_\kappa H  | \Phi_0}\]
L{\"o}wdin calls this the \textit{bracketing function}, since it enables one to obtain both lower and upper bounds to true eigenvalues.
Restating the above in one compact expression, we have
\[ (\kappa - H) \ket{\Psi_{\kappa}} = (\kappa - f(\kappa)) \ket{\Phi_0} \]
\[ (\kappa - H) \Omega_\kappa \ket{\Phi_0} = (\kappa - f(\kappa)) \ket{\Phi_0} \]
This is a monumental result.
\textbf{When $\kappa$ is equal to $f(\kappa)$, the right side above goes to zero. If this occurs,
we conclude that our trial function $\ket{\Psi_{\kappa}}$
is a solution to the Schr{\"o}dinger equation, and the eigenvalue $\kappa$ is the corresponding
energy eigenvalue.}
Thus, our chosen trial function (derived by L{\"o}wdin) gives us access to the solutions of
the Schrodinger equation, by looking for zeros of $F(\kappa) = f(\kappa) - \kappa$.

\textbf{
To summarize, our discrete eigenvalue problem (the Schr{\"o}dinger equation)
was modified into a continuous form, which was enabled by the $\kappa$ dependence of the
reduced resolvent $\mathcal{R}_\kappa$, which Lowdin realized can be used to construct our magical wave operator $\Omega_\kappa$, which
transforms our reference determinant into some function $\Psi_\kappa$ by $ \ket{\Psi_\kappa} = \Omega_\kappa \ket{\Phi_0}$.
When $\kappa$ happens to be equal to an eigenvalue of the Schr{\"o}dinger equation,
we will know it, since $\kappa - f(\kappa) = 0$, and we will have found an eigenstate and eigenvalue (solved the Schr{\"o}dinger equation).
}

\subsection{L{\"o}wdin's Rayleigh-Schr{\"o}dinger Perturbation Theory}
We can now take our generalized Schr{\"o}dinger equation from above
\[ (\kappa - H) \Omega_\kappa \ket{\Phi_0} = (\kappa - f(\kappa)) \ket{\Phi_0} \]
and consider how it behaves when our Hamiltonian is split into two parts $H = H_0 + V$.

\paragraph{\textbf{The Wave Operator}}
Our wave operator becomes
\[\Omega_\kappa = P + \mathcal{R}_{\kappa} H_0 P + \mathcal{R}_{\kappa} V P \]
\[\Omega_\kappa = P + \mathcal{R}_{\kappa} H_0 \ket{\Phi_0}\bra{\Phi_0} + \mathcal{R}_{\kappa} V P \]
\[\Omega_\kappa = P + E_0 \mathcal{R}_{\kappa} P + \mathcal{R}_{\kappa} V P \]
\[\Omega_\kappa = P + \mathcal{R}_{\kappa} V P \]
where the reduced resolvent acting on $P$ is zero, since the resolvent entirely resides in the $Q$ space, which is orthogonal to $P$.

\paragraph{\textbf{The Bracketing Function}}
After a few manipulations which are left as an exercise,
the bracketing function $f(\kappa) = \braket{\Phi_0 | H \Omega_\kappa | \Phi_0}$ becomes
\[f(\kappa) = \Ezero_0 + \braket{\Phi_0 | V \Omega_\kappa | \Phi_0 } \]

\paragraph{\textbf{The Reduced Resolvent}}
We have one last quantity to fully define: the reduced resolvent.
How does the resolvent behave for our Hamiltonian $H = H_0 + V$?
\[\mathcal{R}_{\kappa} = (\kappa - H)^{-1}Q \]
We are about to do a lot of tricky manipulations, but in doing so,
we will arrive at perhaps the most important result in this set of notes.
Let's do it.
First we will expand $H$ and add $0 = \Ezero_0 - \Ezero_0$
\[\mathcal{R}_{\kappa} = (\kappa - \Ezero_0 + \Ezero_0 - H_0 - V)^{-1}Q \]
Rearranging and letting $V' = V - (\kappa - \Ezero_0)$:
\[\mathcal{R}_{\kappa} = (\Ezero_0 - H_0 - V')^{-1}Q \]
To move further, we use of the following identity for two operators $A$ and $B$,
\[ (A- B)^{-1} = A^{-1} + A^{-1} B (A - B)^{-1} \]
If we let  $A = (\Ezero_0 - H_0)$ and $B = V'$, we have
\[\mathcal{R}_{\kappa} = \left[ (\Ezero_0 - H_0)^{-1} +  (\Ezero_0 - H_0)^{-1} V' (\Ezero_0 - H_0 - V')^{-1} \right] Q\]
\[\mathcal{R}_{\kappa} = (\Ezero_0 - H_0)^{-1}Q +  (\Ezero_0 - H_0)^{-1} V' (\Ezero_0 - H_0 - V')^{-1}Q\]
Since $Q^2 = Q$ and Q is Hermitian we can insert a $Q$ in the second term:
\[\mathcal{R}_{\kappa} = (\Ezero_0 - H_0)^{-1}Q +  (\Ezero_0 - H_0)^{-1}Q V' (\Ezero_0 - H_0 - V')^{-1}Q\]
Expanding the definition of $V'$ in the parentheses we obtain
\[\mathcal{R}_{\kappa} = (\Ezero_0 - H_0)^{-1}Q +  (\Ezero_0 - H_0)^{-1}Q V' (\kappa - H)^{-1}Q\]
Now, we define the quantity $\Rz =  (\Ezero_0 - H_0)^{-1} Q$, the \textbf{unperturbed reduced resolvent},
which is the resolvent defined for $\kappa = \Ezero_0 $ and unperturbed Hamiltonian $H_0$.
\[\mathcal{R}_{\kappa} = \Rz +  \Rz V' (\kappa - H)^{-1}Q\]
Noting the last part of the second term is just our original reduced resolvent $\mathcal{R}_{\kappa} = (\kappa - H)^{-1}Q $,
we finally arrive at our result:
\[\mathcal{R}_{\kappa} = \Rz +  \Rz V' \mathcal{R}_{\kappa} \]
\textbf{The resolvent is dependent on itself.
Because of this, we can iteratively construct an expansion of the resolvent.
This will ultimately be the source of our perturbation expansion.}
In an exercise, you will explicitly iterate the resolvent, and show that it generalizes to the following
\[\mathcal{R}_{\kappa} = \sum_{n=0}^{\infty} (\Rz V')^n \Rz \]

Up to this point, we have defined everything with the subscript $\kappa$.
From here on, we will focus on just finding solutions for which $\kappa$ is our ground
state energy $\kappa = E_0$, so we will drop the $\kappa$ subscripts.
Since the only part of the resolvent above which depends on $\kappa$ is
$V' = V - (\kappa - \Ezero_0)$, we will now have
\[V' = V - (E_0 - \Ezero_0)\]
\[\mathcal{R} = \sum_{n=0}^{\infty} (\Rz V')^n \Rz \]
We will likewise drop the $\kappa$ from our definition of the wave operator
and the wave function
\[\Omega = P + \sum_{n=0}^{\infty} (\Rz V')^n \Rz V P \]
\[\ket{\Psi_0} = \Omega \ket{\Phi_0}\]
\[\ket{\Psi_0} =  \ket{\Phi_0} + \sum_{n=0}^{\infty} (\Rz V')^n \Rz V \ket{\Phi_0} \]
\textbf{This is our perturbation expansion for the wavefunction.}
From section 1, ``The Wave Operator'', we derived our energy expression to be,
\[ E_0 = \Ezero_0 + \braket{\Phi_0 | V \Omega | \Phi_0}  \]
Our energy expansion is therefore,
\[E_0 = \Ezero_0 + \braket{\Phi_0|V|\Phi_0} + \sum_{n=0}^{\infty} \braket{\Phi_0|V (\Rz V')^n \Rz V | \Phi_0}\]
\textbf{This is our perturbation expansion for the energy.}

The operator $V'$ introduces some complexity that is worth discussing.
It contains $E_0$, which is the exact energy,
    so it involves a sum over all orders of energy corrections.
\[V' = V - (E_0 - \Ezero_0) \]
\[V' = V - \sum_{m=1} E_0^{(m)} \]
\[V' = V - E_0^{(1)} - E_0^{(2)} - E_0^{(3)} - \cdots \]

To conclude, we have obtained expressions for the $n^{th}$ order wavefunction
and energy corrections in perturbation theory.
Looking at the expression for $\ket{\Psi_0}$, each order wavefunction correction
at higher orders is just a string of operators $(\Rz, V, V')$ acting on our reference determinant.
Each energy is just an expectation value of a string of operators $(\Rz, V, V')$.
Using these expansions in practice can be a bit tricky, as we will see in the next section.

\section{Deriving Perturbation Theory Orders}
Before we get started, we need to know how to identify the ``order'' of a term in our
wavefunction expansion. The reason is that if we want the
$m$th order wavefunction correction, we need to pull out all $m$th order
terms in $\ket{\Psi_0} =  \ket{\Phi_0} + \sum_{n=0}^{\infty} (\Rz V')^n \Rz V \ket{\Phi_0}$.

\paragraph{\textbf{How to identify the order of a term?}}
Some tips for finding the order of a given term:
\begin{itemize}
\item Each $V$ contributes an order of 1
\item Each $E_0^{(m)}$ contributes an order of $m$
\item Instead of counting orders from $V$ and $E_0^{(m)}$, you can instead count
the number of resolvents $\Rz$. Before doing so, you must convert all $E_0^{(m)}$ to the
corresponding analytic expression.
\end{itemize}
As an example of the above rules, when determining the order of the term
\[ \Rz E_0^{(2)} \Rz V \ket{\Phi_0} \]
which appears in the third-order wavefunction,
we could reason that $V$ and $E_0^{(2)}$ is $1 + 2 = 3 \implies$ third order.
Alternatively, we could recognize that $E_0^{(2)} = \braket{\Phi_0 |V \Rz V|\Phi_0}$ (for now,
just accept that this is true, we will derive it later),
so therefore our expression is
\[ \Rz \braket{\Phi_0 |V \Rz V|\Phi_0} \Rz V \ket{\Phi_0} \]
The above expression has 3 resolvents, so we conclude it is third order.
OR, we could count that the above expression has 3 $V$'s, and conclude it is third order.
Everything checks out.
Let's derive some perturbation theory orders.

\paragraph{\textbf{Zero order}}
The 0th order wavefunction correction is just the first term of the respective pertubation expansion
fro above, which is of course just our reference determinant $\ket{\Phi_0}$.
The 0th order energy is just $\Ezero_0$.

\paragraph{\textbf{First order}}
\[ \ket{\Phi_0^{(1)}} = \Rz V \ket{\Phi_0}\]
\[ E_0^{(1)} = \braket{ \Phi_0 | V | \Phi_0} \]

\paragraph{\textbf{Second order}}
We read off from the expansion for $n=1$,
\[ \ket{\Phi_0^{(2)}} = \Rz V' \Rz V \ket{\Phi_0}\]
Here is the only tricky thing with this formalism: $V'$ contains
higher order contributions to the energy
\[V' = V - E_0^{(1)} - E_0^{(2)} - E_0^{(3)} - \cdots\]
\textbf{Since we are building the second order wavefunction, it must be composed of only
second order pieces. The prefactor $\Rz V' \Rz V$ above should therefore only be second order.
The V is first order, so multiplying by V' should only increase the order by 1.
This means only terms in the V' expansion which are first order contribute
to the second order wavefunction.}
This means our $V'$ in this case is truncated to just $V + E_0^{(1)}$,
so we have,
\[\ket{\Phi_0^{(2)}} = \Rz (V - \Eone_0) \Rz V \ket{\Phi_0}\]
\[\ket{\Phi_0^{(2)}} = \Rz V \Rz V \ket{\Phi_0} - \Rz \Eone_0 \Rz V \ket{\Phi_0}\]
That's it!
The energy correction is,
\[ E_0^{(2)} = \braket{ \Phi_0 | V \Rz V | \Phi_0} \]

\paragraph{\textbf{Third order}}
Here we have track of the orders of various terms
more carefully.
To remind you, our wavefunction perturbation expansion is
\[\ket{\Psi_0} =  \ket{\Phi_0} + \sum_{n=0}^{\infty} (\Rz V')^n \Rz V \ket{\Phi_0} \]
At $n=2$, we have a $V$ and two $V'$ in our term.
To make the term third order overall (this is our target for constructing $\ket{\Phi_0^{(3)}}$),
we require that each $V'$ is 1st order, so we only take out the first order
energy and $V$ in our $V'$ expansion $V' = V - E_0^{(1)}$.
Let's now write this $n=2$ term down before moving on,
\[\ket{\Phi_0^{(3)}} = (\Rz (V - \Eone_0))^2 \Rz V \ket{\Phi_0} + (... \mathrm{more})\]

There is also a third-order term which appears when $n=1$,
$(\Rz V')^1 \Rz V \ket{\Phi_0}$. That $V'$ has a second order contribution from $E_0^{(2)}$,
therefore we set $V' = -E_0^{(2)}$ and
pick up an additional term $ \Rz E_0^{(2)} \Rz V \ket{\Phi_0}$ for $\ket{\Phi_0^{(3)}}$
\[\ket{\Phi_0^{(3)}} = (\Rz (V - \Eone_0))^2 \Rz V \ket{\Phi_0} - \Rz E_0^{(2)} \Rz V \ket{\Phi_0} \]
Expanding this and simplifying yields
\[\ket{\Phi_0^{(3)}} = \Rz V \Rz V \Rz V \ket{\Phi_0} - \Rz \Eone_0 \Rz V \Rz V \ket{\Phi_0}
  - \Rz V \Rz \Eone_0 \Rz V \ket{\Phi_0} + \Rz E_0^{(1)} \Rz E_0^{(1)} \Rz V \ket{\Phi_0}
 - \Rz E_0^{(2)} \Rz V \ket{\Phi_0} \]

Our energy expansion is
\[E_0 = \Ezero_0 + \braket{\Phi_0|V|\Phi_0} + \sum_{n=0}^{\infty} \braket{\Phi_0|V (\Rz V')^n \Rz V | \Phi_0}\]

The third order contribution to the energy expression occurs for $n=1$ and is
\[ E_0^{(3)} = \braket{\Phi_0 | V ( \Rz (V - E_0^{(1)})) \Rz V | \Phi_0} \]
Alternatively, we could have also found the above by noting that generally the $(m+1)$ order energy is found
by the $m$th order wavefunction,
\[ E_0^{(m+1)} = \braket{\Phi_0 | V | \Phi_0^{(m)}} \]
\[ E_0^{(3)} = \braket{\Phi_0 | V | \Phi_0^{(2)}} \]
and just plug in our derived $\ket{\Phi_0^{(2)}}$.

\section{The Energy Substitution Theorem}
There is a pattern for finding equations for $\Phi_0^{(m)}$, so you don't have to
go through the tedious process of analyzing where to get terms of a certain order for different
values of $n$ in the expansion, or plucking out the proper terms from $V'$
(but you should know how to do this anyway).

\paragraph{\textbf{Energy Substitution Theorem}}
 $\ket{\Phi_0^{(m)}}$ is equal to the sum of a ``principal term''
 $(\Rz V)^m \ket{\Phi_0} $ plus all unique substitutions of
adjacent factors $(\Rz V)^r$ with $(\Rz E_0^{(r)})$. Each term
in the sum is waited by a sign factor $(-1)^k$ where $k$ is the number of substitutions.
The pair of operators $\Rz V$ closest to the ket $\ket{\Phi_0}$ is not considered for substitutions. \\

We will not prove this, but hopefully by looking at the expressions for  $\ket{\Phi_0^{(2)}}$ and $\ket{\Phi_0^{(3)}}$ that we just derived will convince you:

\[\ket{\Phi_0^{(2)}} = \Rz V \Rz V \ket{\Phi_0} - \Rz \Eone_0 \Rz V \ket{\Phi_0}\]

\[\ket{\Phi_0^{(3)}} = \Rz V \Rz V \Rz V \ket{\Phi_0} - \Rz \Eone_0 \Rz V \Rz V \ket{\Phi_0}
  - \Rz V \Rz \Eone_0 \Rz V \ket{\Phi_0} + \Rz E_0^{(1)} \Rz E_0^{(1)} \Rz V \ket{\Phi_0}
 - \Rz E_0^{(2)} \Rz V \ket{\Phi_0} \]

Now we barely even need to think when we write down our perturbative wavefunction corrections.
Keeping in mind the energy corrections follow form
\[ E^{(m+1)} = \braket{\Phi_0 | V | \Phi_0^{(m)}} \]
our wavefunction correction expressions determine our energy expression corrections.

\section{Concluding Remarks}
I should note that we have not actually translated the energy corrections into
programmable expressions.
To do this, we would have to actually evaluate the expectation values, and it would
be a lot of work.
Later on in the course, after learning diagrams, we will revisit PT and learn
how to diagrammatically derive programmable expressions for the various energy orders.
When we do this, we will cleverly choose $H_0$ and $V$ such that $E_0^{(0)} = E_0^{(1)} = 0$,
which simplifies things a good bit, and also makes it so that each energy
correction is purely a correlation energy contribution.
For a sneak peak, you can look at handout 6 from the 2017 edition of this course.

That was a long and arduous mathematical climb. But we have finally reached the summit,
and now hopefully you can see that all of perturbation theory is obtainable by just
smacking your reference state $\ket{\Phi_0}$ with operator strings consisting
of resolvents $\Rz$ and the perturbed part of the Hamiltonian $V$.
Compare this to how we derived MP2 in the previous set of notes; we had to do a bunch of
algebraic manipulations to get to the end result.
As you can imagine, deriving MP3 and MP4 under that framework only gets worse.
In L{\"o}wdin's resolvent formalism, we can just read off the result,
    and then evaluate it to an algebraic expression using diagrams.

\section{Appendix}
\subsection{Hilbert Space}
Recall that many of the objects we have been talking about (spin orbitals, Slater determinants, wavefunctions)
``live'' in some Hilbert space. This means many things, but for our purposes, we just need to know
there is some ``space'' of \textit{abstract vectors} which have a defined inner product with a certain set of properties.
Every abstract vector in the space can be described in terms of the orthonormal basis which makes up the space.

\begin{itemize}
\item The set of all spin orbitals form a basis for what you might call the one-electron Hilbert space $\mathcal{H}$
\item $n$ tensor products of $\mathcal{H}$ with itself forms an $n$-electron Hilbert space $\mathcal{H}^n$.
        A member of the basis of such a space is a product of spin orbitals (Hartree products)
\item Denote the \textit{antisymmetric subspace} of $\mathcal{H}^n$ as $\mathscr{H}^n$. The basis of this space
    is the set of $n$-electron Slater determinants. All possible Slater determinants for an $n$-electron system live in $\mathscr{H}^n$
    The full CI wavefunction for an $n$-electron system can be constructed from a linear combination of basis vectors in $\mathscr{H}^n$
\end{itemize}

\subsection{Partitioning}
Consider the following \textit{partition} of this $n$-electron antisymmetric Hilbert space $\mathscr{H}^n$ into
a ``$P$'' space and a ``$Q$'' space.
\[ \mathscr{H}^n = \mathscr{H}^n_P \oplus  \mathscr{H}^n_Q \]
where $P$ is the \textit{projection operator} onto some reference determinant
\[P = \ket{\Phi_0}\bra{\Phi_0}  \]
and $Q$ is the \textit{orthogonal complement} of $P$, which projects onto every determinant other than the reference $\Phi_0$
\[Q = 1 - P = \sum_{n \neq 0}  \ket{\Phi_n}\bra{\Phi_n} \]
You can think of this as just dividing your Slater determinant basis into two parts, $P$ and $Q$.
The sum $P + Q$ is equal to unity. This can be most easily seen by thinking of $P$ and $Q$ as two distinct chunks of the resolution of the identity.

\end{document}


\documentclass{memoir}
\usepackage{notestemplate}

%\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}
%\institute{Rice University}
%\faculty{Faculty of Whatever Sciences}
%\department{Department of Mathematics}
%\title{Class Notes}
%\subtitle{Based on MATH xxx}
%\author{\textit{Author}\\Gabriel \textsc{Gress}}
%\supervisor{Linus \textsc{Torvalds}}
%\context{Well, I was bored...}
%\date{\today}

\begin{document}

% \maketitle

% Notes taken on ??

\section{Character Theory}
\label{sec:character_theory}

Character theory will serve as a very convenient bookkeeping tool for representations of \(G\) when \(G\) is finite. We still keep \(K = \C\).

\begin{defn}
	Let \((V,\rho)\) be a \(\C\)-representation of \(G\) of finite degree \(n\). Choose any basis of \(V\) and express \(\rho_g\) as a matrix in \(GL_n(\C)\), for all \(g \in G\). The \textbf{character of \((V,\rho)\)}, denoted \(X_V\) is the function
	\begin{align*}
		X_V:G\to \C\\
		g\mapsto \textrm{Tr}(\rho g)
	\end{align*}
	We say that \(X_V\) is \textbf{irreducible} if \((V,\rho)\) is irreducible.
\end{defn}
It turns out that characters detect irreducibility. Let \(X_V,\psi_W\) be given. We define a scalar by
\begin{align*}
	\langle X_V,\psi_W \rangle := \frac{1}{\left| G \right| }\sum_{g \in G} \overline{X_V(g)}\psi_W(g).
\end{align*}
\begin{prop}
	Let \(V\) be a representation of \(G\). Then
	\begin{align*}
		V \text{ is irreducible }\iff\langle X_V,X_V \rangle =1.
	\end{align*}
\end{prop}

Of course, we need to be sure that our construction of characters is well-defined. It turns out that they capture the properties of our representation well and are unique.

\begin{prop}
	\begin{enumerate}
		\item The definition of \(X_V\) is independent of choice of basis of \(V\)
		\item If \(V \cong W\), then \(X_V = X_W\)
		\item If \(g,h \in G\) are conjugate, then \(X_V(g) = X_V(h)\)
	\end{enumerate}
\end{prop}

\begin{defn}
	The \textbf{character table} of \(G\) is defined as
	\begin{align*}
		\begin{bmatrix} X_{V_1}(g_1) & X_{V_1}(g_2) & \ldots & X_{V_1}(g_k)\\
		\vdots & & & \vdots \\
	X_{V_\ell}(g_1) & X_{V_\ell}(g_2) & \ldots & X_{V_\ell}(g_k)\end{bmatrix}
	\end{align*}
\end{defn}
The number of irreducible characters of \(G\) is the same as the number of conjugacy classes of elements of \(G\). Furthermore, the character table is a square matrix with entries in \(\C\) when the rows are indexed by irreducible representations of \(G\) and the columns are indexed by conjugacy classes representations of elements of \(G\).\\

In this case, \((X_{V_i}(g_j))\) is an invertible matrix.

% Examples

\begin{prop}
	Let \((V,\rho )\) be a representation of \(G\), and take \(g \in G\). Then
	\begin{enumerate}
		\item \(X_V(e) = \textrm{dim}(V)\)
		\item \(X_V(g)\) is a sum of roots of unity
		\item \(X_{V\oplus W}(g) = X_{V}(g) + X_{W}(g)\)
		\item \(X_V(g^{-1}) = \overline{X_V(g)}\)
		\item \(\overline{X_V}\) is a character of \(G\)
	\end{enumerate}
\end{prop}

Let \(X_1,\ldots,X_r\) be irreducible characters of a finite group \(G\). Define
\begin{align*}
	\langle X_i, X_j \rangle := \frac{1}{\left| G \right| } \sum_{g \in G} \overline{X_i(g)}X_j(g)
\end{align*}

\begin{thm}
	\begin{enumerate}
		\item \(\langle X_i, X_j \rangle = \delta _{ij}\)
		\item
			\begin{align*}
				\sum_{i=1}^{r} \overline{X_i(x)}X_i(y) = \begin{cases}
					\left| C_G(x) \right| & x,y \text{ conjugate in }G\\
					0 & \text{otherwise}
				\end{cases}
			\end{align*}
	\end{enumerate}
\end{thm}
			Here, \(C_G(x)\) is the centralizer of \(x \in G\), that is, \(C_G(x) = \textrm{Stab}_x(G) = \left\{g \in G \mid g x g^{-1} = x \right\} \).

% Example

\begin{thm}
	If \(V,W\) are irreducible representations of \(G\), then
	\begin{align*}
		\langle X_V,X_V \rangle = 1\\
		\langle X_V,X_W \rangle = 0 \text{ when }V\not\cong W
	\end{align*}
\end{thm}
This shows us that characters completely determine representations, and forthermore characters completely determine irreducibility.
\end{document}

Abstract Algebra - Introductory/Algebra II/Notes/source/Lecture13 - CharacterThry.tex


\section{PolyPasswordHasher: A New Technique for Password Verification}
\label{SEC:design}

The goal of PolyPasswordHasher is to make cracking individual passwords
infeasible.  It provides a way of preventing an attacker from validating a
password hash.  At its core, PolyPasswordHasher aims to protect password hashes
by combining a share (derived using a threshold cryptosystem) with a salted
password hash and then storing this combined value in the password database.
Neither the share nor the password hash is stored on disk and, as we discuss in
more detail below, an attacker cannot recover either piece with only the
password database.  Cracking a password that is stored by PolyPasswordHasher
requires that the attacker know a threshold of passwords; this effectively
makes the passwords in a database interdependent.  Our goal is to ensure that
so long as an attacker does not know a threshold of passwords, no password in a
database can be cracked.

To make passwords interrelate, \PPH functions differently from a salted hash.  A
typical salted hash database stores a Username, Salt, and a Salted Hash.  A \PPH
database, rather than storing a salted hash, stores the secure hash XORed with
the share (\sxh).  The resulting \PPH database also holds an extra field called the
share number.  This field indicates which share was XORed with which salted
hash.

\begin{figure}
    \includegraphics[width=1\linewidth]{./images/Verify_account.pdf}
    \caption{Account verification. }
    \label{FIGURE:account-verification}
\end{figure}

When prompted to validate a password, the server XORs the salted hash with the
stored data and determines whether the result is a valid share of the threshold
%cryptosystem.  For example, in Figure~\ref{FIGURE:basic-pph-algorithm}, Bob
cryptosystem.  For example, in Figure~\ref{FIGURE:account-verification}, Alice
has provided her password (`fsh\$t!kz') and the username `Alice'.
The server and computes the salted hash of her password (`4298f44d...') and
reconstructs Alice's share (`3e773b6f...') using her share number
(2).  The server XORs the share and Alice's salted password hash together
and compares them to the value stored in the \sxh field in the password
database (`7cefcf22...').  If they match, then the password
provided was correct.

Account creation involves creating a share and XORing it with
the salted hash of the password before storing it on disk
For example, in Figure~\ref{FIGURE:basic-pph-algorithm}, Bob registers an
account with his password (`Tr4mP0l1ne') and username (`Bob').  The
server computes a salt (`0x5a17') and the salted hash of Bob's
password (`4153f0aa...').  The server knows the secret and knows Bob's
share number, 4. It computes Bob's share (`66ef2279...') and this value is XORed
with Bob's password’s salted hash; that value is compared to the value
stored in the database (`27bcd2d3...'). If these match, then the password
provided was correct.
%cryptosystem.  For example, in Figure~\ref{FIGURE:basic-pph-algorithm}, Bob

\begin{figure}
    \includegraphics[width=1\linewidth]{./images/basic-pph-algorithm.pdf}
    \caption{The basic PolyPasswordHasher algorithm showing how an entry is created}
    \label{FIGURE:basic-pph-algorithm}
\end{figure}

In PolyPasswordHasher, each share protects a salted hash and each salted hash
protects a share, unless a threshold of shares is known (as is shown in
Figure~\ref{FIGURE:pph-interdependency-2}).  Suppose that an attacker has
obtained the password database and knows some set of account passwords (x,y,z).
For each known password, (illustrated in Figure~\ref{FIGURE:pph-interdependency-new})
the hacker can compute the salted hash and XOR this with the database entry to
obtain the corresponding share.  If the attacker does not have a threshold of shares,
the attacker cannot generate a share for another account (e.g., `share a').  As a
result, the attacker cannot access share a's password's salted hash and cannot crack
a's password.  Or, suppose that a server has a threshold of correct passwords.
The server now has enough information to validate a threshold of shares and can use those to
recover the secret. The server could then reconstruct any share and thus,
recover the salted hash for any account's password -- an important step in
validating passwords.  Because shares protect passwords, an attacker who does
not have an adequate number of correct passwords (and thus shares) cannot
feasibly crack passwords individually.

\begin{figure}
    \includegraphics[width=1\linewidth]{./images/pph-interdependency-2.pdf}
    \caption{An attacker: (1) Cannot obtain salted hashes (needed to crack
    passwords) without a threshold  of shares AND (2) Cannot obtain a share without
    knowing the salted hash (password) for a \thresholdaccount.}
    \label{FIGURE:pph-interdependency-2}
\end{figure}

\begin{figure*}
    \includegraphics[width=1\linewidth]{./images/pph-interdependency-new.pdf}
    \caption{If an attacker knows some number of shares he can get the
    corresponding salted hashes; if he knows the salted hashes, he can get the
    corresponding shares; and, if he has a threshold of these, he can get the
    secret.}
    \label{FIGURE:pph-interdependency-new}
\end{figure*}

The basic scheme, as outlined so far, covers PolyPasswordHasher’s core
functions.  In the remaining subsections we address how \PPH checks passwords
without having a threshold of correct passwords (such as after a restart) and
how it ensures that all
accounts, even those that could be created by an attacker, are protected.  To
more fully describe the full \PPH algorithm, we begin, in
Section~\ref{SUBSEC:normal-operation}, with how PolyPasswordHasher functions in
situations where the server has already validated a threshold of correct
passwords and how, after reaching this threshold, the server proceeds to login
normal users, in a phase we call normal operation.  Following this,
Section~\ref{SUBSEC:bootstrapping} discusses how \PPH performs differently when
a threshold of correct passwords have not yet been provided and needs to
acquire that threshold (e.g. after a reboot).
Section~\ref{SUBSEC:bootstrap-transitioning} discusses how the system
transitions between bootstrapping and normal operation and in
Section~\ref{SUBSEC:handling-rare-events}, we describe how unlikely situations,
such as the loss of a large number of account passwords, are handled.

\subsection{Normal operation of PolyPasswordHasher}
\label{SUBSEC:normal-operation}

Given that a server with a threshold of shares can effectively recover any
salted hash, if every account protected a share, every password would play an
important role in protecting the security of the database.  However, not all
accounts should necessarily be trusted to protect shares.  For example, a forum
may allow any user to register an account and any party, including an attacker,
to register any number of user accounts.  If these accounts each protected a
share, an attacker could easily crack the password database.

PolyPasswordHasher enables one group of passwords, which we call protector
accounts, to protect the remaining passwords in the password database; these we
call \thresholdlessaccounts.  Bob's account (who we started following in the
previous example) is an example of a \thresholdaccount
(Figure~\ref{FIGURE:protected-protector}).  An administrator will define a
threshold value of \thresholdaccounts so that if an attacker does not know a
threshold of protector passwords, Bob's salted hash cannot be recovered.  Bob's
password hash protects his share and in turn, Bob's share helps to protect the
other shares (such as shares 1,2), which in turn protect their corresponding
password hashes (for root and Alice). These shares serves to protect the full
password database, including \thresholdlessaccounts (Trudy and Luke).

\begin{figure}
    \includegraphics[width=1\linewidth]{./images/pph-store.pdf}
    \caption{A PolyPasswordHasher store with protector and \thresholdlessaccounts. \Thresholdlessaccounts are displayed with a share number of SH. }
    \label{FIGURE:protected-protector}
\end{figure}

Since a \thresholdlessaccount  does not protect a share, it is not XORed with one.
Nonetheless, these accounts are still protected by shares, or more precisely,
the secret.  \PPH uses the secret as an encryption key and with it, encrypts the
password's salted hash.  For these accounts, the resulting value (but not the
secret or salted hash) is stored in the password database.  For example, in
Figure~\ref{FIGURE:protected-protector}, Trudy's password hash (a9e32543...) is
encrypted using the secret (9d380eb6...); the result (8198a5fd...) is stored in the
database.  There are two important points to note.  First, if an attacker knows
another \thresholdlessaccount's password (e.g., Luke's), this does not
substantially help with cracking Trudy's password.  The attacker would need to
break the symmetric encryption algorithm.  Also, knowing Luke's
password would not substantially help the attacker crack the secret or other
shares in the password.  Once again, the attacker would need to break the
symmetric encryption algorithm.  Thus, \thresholdlessaccounts cannot be
effectively cracked unless an attacker knows a threshold of \thresholdaccount
passwords.

\subsubsection{PolyPasswordHasher's algorithm}
\label{SUBSUBSEC:pph-algorithm}

Algorithm~\ref{ALG:acc-creation} details the processes of creating a user
accounts.  The relevant operations for normal operation (lines 2-13)
are discussed in this section.  Bootstrapping operations (lines 14-23) are
deferred to the next section.

\begin{algorithm}
\footnotesize
\begin{algorithmic}[1]\Function{createAccount}{username, salt, saltedPasswordHash, isProtectorAccount}
    \vspace{.1cm}
    \State \codecomment{\footnotesize// check whether we are under normal operation}

    \If{normalOperation} \codecomment{\footnotesize// Section \ref{SEC:design} and
    \ref{SUBSEC:normal-operation}}

        \If{isProtectorAccount}

            \State \codecomment{\footnotesize// Obtain a share from the share cryptosystem}
            \State shareNumber, share = SecretShares.getShare()

            \State \codecomment{\footnotesize// Combine the share with the hash}
            \State passwordEntry = share $\oplus$ saltedHash
            \State shareID = shareNumber

        \vspace{.11cm}
        \Else~\codecomment{\footnotesize// Shielded Account
        (Section~\ref{SUBSEC:normal-operation})}
            \State Key = SecretShares.getSecret()
            \State passwordEntry = AES.encrypt(saltedPasswordHash, Key)
            \State shareID = \THRESHOLDLESS
        \EndIf

    \vspace{.1cm}
    \Else~\codecomment{\footnotesize// Bootstrapping (Section~\ref{SUBSEC:bootstrapping})}

        \If{isProtectorAccount}
            \State raise AccountCreationError
        \Else
            \State shareID = BOOTSTRAP
        \EndIf
        \State passwordEntry = saltedPasswordHash
    \EndIf

    \State \codecomment{\footnotesize// Isolated Validation (Section~\ref{SUBSEC:bootstrapping})}
    \State isolatedCheckBits = saltedPasswordHash.getSuffix(IC\_BITS)
    \State passwordEntry += isolatedCheckBits

    \State store (username, salt, shareID, passwordEntry)
    \EndFunction

\end{algorithmic}
\caption{\small Account creation pseudocode.
\label{ALG:acc-creation}}
\end{algorithm}

{\bf Creating Accounts}.  Adding an account works as is shown in
Algorithm~\ref{ALG:acc-creation}.  As the algorithm describes, the username,
salt, the password’s salted hash, and a boolean are used to indicate whether or
not the account should be a \thresholdaccount. If the account is a
\thresholdaccount, an unused share is found (line 6) and the salted hash is
XORed with it (line 8) before the share number and resulting value are stored
(line 23).

Since a \thresholdlessaccount does not protect a share, those accounts are
instead encrypted with the secret (lines 11-12).  The share field is set to a
special value that indicates a \thresholdlessaccount (line 13).  As before,
this information is then stored in the database (line 23).

It is important to prevent users, particularly \thresholdaccounts, from using bad
passwords.  Similar to many deployed systems, PolyPasswordHasher employs simple
techniques to weed out extremely bad passwords.  When creating an account,
users input a password they want to use, but \PPH checks this password to ensure
that it is not too weak (e.g., ``letmein'' or ``password'').  This is done by
checking the requested password against a list of commonly used passwords (the
64K most popular). The proposed password will be rejected if it is on
that list.  PolyPasswordHasher also enforces constraints on the password length
and composition (number of lowercase and uppercase letters, numbers, and
symbols).  The purpose is not to ensure that passwords are immensely strong,
but to prevent the use of \thresholdaccount  passwords that are trivial to
guess.  These constraints are already common in many systems, such as those
that aim to prevent passwords from being cracked by brute force over the
network.

{\bf Process for Verifying Passwords}. Assuming that the server holds the
right number of valid passwords (and thus shares), it will be able to recover
the remaining shares, as shown in Algorithm~\ref{ALG:acc-verification}.
To verify a \thresholdaccount  (lines 4-5), the server first computes the salted
hash of the user’s password and XORs it with the passwordEntry. If the
passwordEntry XORed with the salted hash is the share, then the password is
correct.

For a \thresholdlessaccount, password verification differs because the salted hash
is encrypted instead of being XORed with a share.  Lines 8-10 of
Algorithm~\ref{ALG:acc-verification} describe how to compare the provided password
hash.  The password hash is encrypted with the secret and, if the encrypted
value matches the \sxh field, the correct password was provided.

\begin{algorithm}
\footnotesize
\begin{algorithmic}[1]\Function{verifyAccount}{username, saltedPasswordHash, shareID, passwordEntry}

    \If{normalOperation}
        \If{isProtector(shareID)}\codecomment{\footnotesize // Section~\ref{SEC:design}}
            \State share = passwordHash $\oplus$ passwordEntry
            \State return SecretShares.computeShare(shareID) == share
        \Else \codecomment{\footnotesize// \thresholdlessaccount ,
    Section~\ref{SUBSEC:normal-operation}}

            \State \codecomment{\footnotesize// Encrypt the obtained hash and compare}
            \State Key = SecretShares.getSecret()
            \State encryptedHash = AES.encrypt(passwordHash, Key)
            \State return passwordEntry == encryptedHash

        \EndIf
        \vspace{.1cm}

    \Else \codecomment{\footnotesize// Bootstrapping, Section~\ref{SUBSEC:bootstrapping}}

        \State \codecomment{\footnotesize// verify account created during bootstrap}
        \If{shareID == BOOTSTRAP}
            \State return passwordHash == passwordEntry
        \EndIf

        \If{not passwordHash.endsWith(isolatedCheckBits)}
            \State return False
        \EndIf
        \If{isProtector(shareID)}
            \State share = passwordHash $\oplus$ passwordEntry
            \State SecretShares.cacheShare(share)
        \EndIf
        \State return True

    \EndIf

    \EndFunction
\end{algorithmic}
\caption{\small Account verification pseudocode.\label{ALG:acc-verification}}
\end{algorithm}

{\bf Changing a user's password / password recovery} Changing a password
is a similar process to that used in a salted hash system, for both \thresholdaccounts
and \thresholdlessaccounts. Similar to existing systems, the procedure for
changing a password may require validating the existing password before
allowing a replacement to be generated. Changing the password involves creating
a new entry with the same username and share number. (This is nearly identical
to account creation.)  A new salt is generated and hashed along with the new
password.  Since the hash has changed, the fourth field will also change. Once
the new password entry is computed, it replaces the original stored data.  The
user may then log in normally with their new account.

\subsection{Bootstrapping After a Reboot}
\label{SUBSEC:bootstrapping}

When a system restarts, \PPH cannot validate or create accounts as it normally
would, because a threshold of valid accounts has not been reached. Because \PPH
stores shares in memory, not on disk, these are lost during reboot.  This means
that a server does not know the secret and cannot compute arbitrary shares.  As
a result, when bootstrapping, neither \thresholdaccount nor \thresholdlessaccounts
may be verified or created using the methods described above; account creation and verification
procedures are different when the system is bootstrapping.

%\begin{figure}
%    \includegraphics[width=1\linewidth]{./images/bootstrap}
%    \caption{Bootstrapping is similar to verifying an account except that we
%    use the obtained shares to restore the secret and interpolate the rest of the
%    shares.}
%    \label{FIGURE:bootstrap}
%\end{figure}

\subsubsection{Bootstrap account creation}
\label{SUBSUBSEC:bootstrap-account}

New accounts may also be created during bootstrapping. To do this, the new
account is added to the database along with the salted hash.  While the system
is bootstrapping, the new account is available to use.  In the interim, these
passwords will be created (line 19 of Algorithm~\ref{ALG:acc-creation}) and
validated (lines 18-19 of Algorithm~\ref{ALG:acc-verification}) in the same
manner as passwords stored in a system that uses salted hashes.

Although it would be easy to support \thresholdaccount creation during
bootstrap, PolyPasswordHasher does not do so (line 16 of
Algorithm~\ref{ALG:acc-creation}).  The reason is that an attacker who can
read the password database would also be able to read the salted password hash.
If the attacker can later read the password database during normal operation,
the attacker could use that salted password hash to recover the share.

\subsubsection{Isolated Validation}
\label{SUBSUBSEC:isolated-validation}

When started, a \PPH system does not have enough protector passwords (and thus,
shares) to recover the secret.  At this point it is not possible to validate
accounts following the same process as \PPH's normal operation
(\ref{SUBSEC:normal-operation}).  Here we describe how \partialverification  can
be used to check logins even without the secret.  \Partialverification is a
process that leaks a configurable number of bits of the salted hash by using a
slow hash algorithm.  It implements a mechanism wherein it is possible, but
extremely unlikely, that an attacker could access an account using an incorrect
password.  In the next section we discuss the \partialverification mechanism,
but defer discussion of its algorithm until
Section~\ref{SUBSEC:security-properties}.

As it bootstraps, \PPH collects shares from protector logins. The number of
logins required to recover the secret will have been configured by the system
administrator, with the threshold normally set to a low number (e.g., three).
Once the threshold has been reached, \PPH will finish bootstrapping
(Section~\ref{SUBSEC:bootstrapping}). Meanwhile, before this threshold is
reached, \partialverification makes use of an isolated-check bits field to authenticate
user passwords.

In this scheme, illustrated in the upper right corner of
Figure~\ref{FIGURE:isolated-verification}, the password database contains
isolated-check bits.  These bits are used to verify logins before a threshold
is reached and the same process is used for both protector and shielded
accounts.  The user's password is hashed using the \partialverification hash
function.  This function returns a small number of bits of the hash (such as 24
bits of a SHA256 hash) and typically involves many iterations of a secure hash
function.  If the isolated-check bits field of the password database match the
\partialverification  hash function’s output (line 12 of
Algorithm~\ref{ALG:acc-verification}), the user is allowed to log in.

\begin{figure}
    \includegraphics[width=1\linewidth]{./images/pph-with-partial-bytes.pdf}
    \caption{This figure shows validation using \partialverification. The
    isolated-check bits are stored on disk. This allows verification of accounts
    before a threshold of correct passwords is provided.  }
    \label{FIGURE:isolated-verification}
\end{figure}

\begin{figure}
    \includegraphics[width=1\linewidth]{./images/bootstrap.pdf}
    \caption{Wilson's account was created during bootstrap, so a regular
    salted hash is stored instead.}
        \label{FIGURE:bootstrap-verification}
\end{figure}

For example, Figure~\ref{FIGURE:bootstrap-verification} illustrates
verification while the system is bootstrapping.  Bootstrap accounts, such
as Wilson's account are validated in an identical way to a salted hash
system.  Wilson's password is salted and hashed and this is compared
with the value stored in the database.  If it matches, Wilson is logged in.

\Thresholdaccounts and \thresholdlessaccounts, like those of Trudy or Alice may
also log in while the system is bootstrapping
(Figure~\ref{FIGURE:bootstrap-verification}) using \partialverification.  The
\partialverification hash function is computed over the provided password and
the \partialbytes field is checked.  If these values match, the user is allowed
to log in. Bootstrap accounts, such as Wilson's account are validated in an
identical way to a salted hash system.  Wilson's password is salted and hashed
and this is compared with the value stored in the database.  If it matches,
Wilson is logged in.

\Partialverification represents a tradeoff for administrators.  Using
\partialverification makes the system available immediately after a reboot.
However, when using a small number of \partialbytes, there is the potential
for an incorrect authentication during the bootstrapping phase.  Alternatively
a large number of \partialbytes impacts the confidentiality of the password
database in the event of a theft, by making the passwords easier to crack.
Thus in some scenarios different settings are appropriate, possibly
even for \thresholdaccounts and \thresholdlessaccounts in the same database.
We explore this tradeoff more in Section~\ref{SUBSEC:security-properties}

\subsection{Transitioning From Bootstraping to Normal Operation}
\label{SUBSEC:bootstrap-transitioning}

As the system bootstraps, the server batches shares from \thresholdaccounts
(line 14 of Algorithm~\ref{ALG:acc-verification}).   After the system has a
threshold of shares, it is possible to recover the secret. The server performs
Lagrange interpolation, which allows the server to not only recover the secret
but also, to generate arbitrary shares (both are needed to check \thresholdlessaccounts).

Recall that accounts created during the bootstrap phase contain BOOTSTRAP for
their share number and have a salted hash stored in the database.  When the
system recovers the secret and transitions to normal operation, these accounts
will have their password hashes encrypted with the secret and their share
number field set to \THRESHOLDLESS.  This transforms these accounts to the same
state as \thresholdlessaccounts that are created in normal operation.

Also, all account logins that were processed during bootstrapping are now
checked to be certain that the correct passwords were provided.  This step is
needed because it is possible that an attacker could find a password that is
invalid and yet, matches the \partialbytes.  (We examine the feasibility and
computational cost of this in Section~\ref{SEC:evaluation})  The salted
password hash for \thresholdlessaccount logins are cached in memory and the
passwords are verified once a threshold is reached.

For a \thresholdaccount , if a provided password hash matches the \partialbytes,
but the password is not correct, the recovered share is not invalid.  The
incorrect share will be detected when a threshold of shares are obtained
because the integrity check on the secret will fail.  If this integrity check
fails, the administrator is notified.  The system can still enter normal
operation once a threshold of valid shares are obtained.

\subsection{Handling Rare Events}
\label{SUBSEC:handling-rare-events}

At an administrator's behest, accounts may be switched between shielded
and protector without user intervention. To do this, the server must be in
normal operation.  The server can then recover the salted secure hash. This
salted secure hash can then be re-encoded (using a share for an account that
becomes a \thresholdaccount; or encrypted, for an account that becomes
shielded) and the new entry can be stored. This transitions the account
from a protector to shielded (or vice versa).

{\bf Recovering data if all \thresholdaccounts are lost}.  If not enough
known threshold users can be verified, the salted hashes are lost forever and
accounts cannot be validated using the technique we described in
Section~\ref{SUBSUBSEC:isolated-validation}.  However, this does not mean that
the system is unusable because \partialverification allows users to log in.
Furthermore, mechanisms like root password recovery that are done through the console
will still work, and will allow any data on the system to be accessed.

{\bf Trusting a \thresholdaccount with multiple shares}.  A single
account may optionally provide access to multiple shares.
To do this, a single user can have multiple rows in the table.  Each
row will have a different \sxh entry and thus protect a different share.
Each entry must also have a different salt to ensure that a different
hash value is XORed with each share.  When the user provides their password,
the value can be used to recover the share in each row by XORing the salted
password hash with each share.

{\bf Detecting an \partialbytes match of an incorrect password}.  If the
system is in normal operation, it will detect that the password does not match.
However, PolyPasswordHasher will always check the \partialbytes for an entered
password (for clarity, not depicted in Algorithm~\ref{ALG:acc-verification}).
If the password is incorrect, but the \partialbytes match, this indicates that
an attacker has almost certainly stolen the password database but has not (yet)
cracked the password.  This generates an alert to the administrator to notify
her of the likely breach.


\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{xcolor}

\author{Salvador Castagnino \\ scastagnino@itba.edu.ar}
\date{}
\title{Chapter 4 - Elementary Hilbert Space Theory}

\begin{document}

\maketitle

\section*{Exercise Solutions}

\begin{exercise}\textbf{Exercise 4.4.}
    We start by assuming that $\{u_n\}_{n \in \mathbb{N}}$ is a countable maximal orthonormal system in $H$, we want to see that $H$ is separable. Observe that it sufices to find a countable set $A$ such that $P \subset \overline{A}$, with $P$ the set of all finite linear combinations of elements in $\{u_n\}_{n \in \mathbb{N}}$. Define the set $A$ to be,
    \[
        A = \Bigg\{ \sum_{n=1}^{N} \left( q_n + i p_n \right)  u_n : q_n,p_n \in \mathbb{Q},\ N \ge 1\Bigg\}
    \]
    which is clearly countable. Take $x \in P$, we have $x = \sum_{n=1}^{N} c_n u_n $ for some $c_n$ complex numbers and some $N \ge 1$ . Observe that for every $1 \le n \le N$ there exist $\{q_{nk}\}_{k \in \mathbb{N}}$ and $\{p_{nk}\}_{k \in \mathbb{N}}$ sequences of rational numbers such that $ \left( q_{nk} + i p_{nk} \right) \rightarrow c_n$ as $k$ goes to infinity. Then let $\epsilon > 0$ we can ask for a $k$ large enough such that $|\left( q_{nk} + i p_{nk} \right) - c_n| < \frac{\epsilon}{N}$ for all $1 \le n \le N$, we in turn have
    \[
        \|\sum_{n=1}^{N} \left( q_{nk} + i p_{nk} \right)u_n - \sum_{n=1}^{N} c_n u_n \| \le \sum_{n=1}^{N} |\left( q_{nk} + i p_{nk} \right) - c_n| < \sum_{n=1}^{N} \frac{\epsilon}{N} < \epsilon
    \]
    Given that every element in $P$ can be aproximated by elements in $A$ we have that, $P \subset \overline{A}$, which concludes the proof.

\bigbreak

Now suppose that $\{x_n\}_{n \in \mathbb{N}}$ is countable and dense in $H$, we are going to build a countable maximal orthonormal system. Let $A$ be the set such that
\[
   \begin{cases}
      x_1 \in A \\
      x_{n+1} \in A \text{ iff } x_{n+1} \notin [ x_1, ..., x_n ]
   \end{cases}
\]
where $[x_1, ..., x_n]$ denotes the span of $\{x_1, ..., x_n\}$, let's see that $A$ is linearly independent. Suppose that for some $v_1, ..., v_{m+1}$ in $A$ and $\alpha_1, ..., \alpha_m$ nonzero complex numbers we have that
\[
    \sum_{j=1}^{m} \alpha_j v_j = v_{m+1}
\]
Every $v_j$ can be expressed as $x_{n_j}$, so let $v_k$ be such that $n_k$ is the greates index between all $n_j$, we then have
\[
    v_k = \frac{v_{m+1}}{\alpha_k} - \sum_{1 \le n \neq k \le m} \frac{\alpha_n v_n}{\alpha_k}
\]
which clashes with the construction of A, thus A is linearly independent. By \textbf{Ex4.3} we can build from A a countable orthnormal set $\{u_n\}$ such that $[v_1, ..., v_n] = [u_1, ..., u_n]$ for all $n \ge 1$. Given that every $x_n$ can be expressed as a linear combination of elements in $A$, one can see that every $x_n$ will be in $[u_1, ..., u_m]$ for some $m$. Then we can see that every $x_n$ is an element of $\overline{P}$, with P the set of finite linear combinations of elements in $\{u_n\}$, which in turn imples that $P$ is dense in $H$ and concludes the proof.
\end{exercise}

\bigbreak

\begin{exercise}\textbf{Exercise 4.6.}
    Let $U = \{u_n\}_{n \in \mathbb{N}}$ be an orthonormal set in $H$, let's prove the assertion \textbf{(a)}. Boundedness of $U$ is more than clear and closedness and non-compacntess can be easily derived from that fact that $\|u_n - u_m\| = \sqrt{2}$ for all $1 \le  n < m$.

\bigbreak

To prove assertion \textbf{(b)} (we go directly with the general case), we start by supposing that $\sum_{n=1}^{\infty} \delta_n^2 < \infty$ and proving that $S$ is compact. In ordert to do this, let $\{x_n\}_{n \in \mathbb{N}}$ be a sequence in $S$, we will construct a convergent subsequence.
\begin{itemize}
    \item Let $y_{n1} = \hat{x}_n \left( 1 \right)$, notation as in the book. Given that the closed disk $\overline{B} \left( 0,\delta_1 \right)$ is compact and $y_{n1} \in \overline{B} \left( 0, \delta_1 \right) $, we can find $y_{n_k1}$ a convergent subsequence of $y_{n1}$ which converges to a $y_1$ in that disk. We replace our original sequence $x_n$ for the new subsequence $x_{n_k}$, define $z_1 = x_{n_1}$  and proceed be repeating what we just did but for the second terms (we also rename the new sequence $x_{n_k}$ as $x_n$ for the sake of simplicity).
    \item Notation as above we can find a convergent subsequence $y_{n_k2}$ of the sequence of second terms which converges in $\overline{B} \left( 0,\delta_2 \right) $ to a $y_2$ in that disk. We again define $z_2 = x_{n_1}$ and replace $x_n$ by it's subsequence $x_{n_k}$. Observe that the sequence of first terms still converges as it's a subsequence of a convergent sequence.
\end{itemize}
Repeating this process an arbirary number of times we build a sequence $z_n$ in S and a sequence of numbers $y_n$ in $\overline{B} \left( 0,\delta_n \right) $ for each $n$. Given that $0 \le |y_n| \le \delta_n$ for all $n \ge 1$ we have that $\sum_{n=1}^{\infty} |y_n|^2 < \infty $ and thus there exists a $y \in S$ such that $\hat{y} \left( n \right) = y_n$ for all $n \ge 1$. By the definition of the sequences $z_n$ and $y_n$, given $\epsilon > 0$ we can find $N, M \in \mathbb{N}$ large enough such that,
\begin{equation}
    \sum_{n=N}^{\infty} |\hat{z}_m \left( n \right)  - y_n|^2 \le \sum_{n=N}^{\infty} 4\delta_n^2   < \frac{\epsilon}{2}
\end{equation}
\begin{equation}
    |\hat{z}_m \left( n \right)  - y_n|^2 < \frac{\epsilon}{2^{n+1}} \quad \forall\ 1 \le n < N
\end{equation}
for all $m \ge M$. With this in mind we can see that $\sum_{n=1}^{\infty} |\hat{z}_m \left( n \right) - y_n|^2 =  \|z_m-y\|^2 < \epsilon$ for all $m \ge M$ which shows that $z_n$ converges to $y$ in $S$ and concludes the proof.

\bigbreak

Now suppose that $S$ is compact and that $\sum_{n=1}^{\infty} \delta_n^2 = \infty $, we will get to a contradiction. Define $x_k = \sum_{n=1}^{\infty} c_{kn}u_n $ with
\[
    c_{kn} =
    \begin{cases}
        \delta_n & \text{if } n \le k \\
        0 & \text{else}
    \end{cases}
\]
Clearly $x_k \in S$ for all $k \ge 1$  and $\|x_k\|^2 \rightarrow \sum_{n=1}^{\infty} \delta_n^2 = \infty$ but given that $\|x_k\| \le \|x_k-x\| + \|x\|$ for every $x \in S$ no subsequence of $x_k$ can converge in $S$ which implies that $S$ is not compact, contradicting our assumption and concluding the proof.

\bigbreak

Finally to prove assertion \textbf{(c)} we observe that $\frac{r}{2}u_n \in B \left( 0,r \right)$ for all $r > 0$ and all $n \ge 1$. With this in mind, and the fact that $\|u_n\|$ has no covergent subsequence, the sequences $\|\frac{r}{2}u_n\| $ have no convergent subsequence in $\overline{B} \left( 0,r \right) $ which in turn shows that $0$ has no neighbourhood with compact closure in $H$ which concludes the proof.
\end{exercise}

\bigbreak

\begin{exercise}\textbf{Exercise 11.}
We claim that the set $ E = \{ f_n \}_{n \in \mathbb{N}}$  with $f_n \left( x \right) = \sin \left( nx \right) I_{[0, \pi+\frac{\pi}{n}]}$ (where $I_A$ stands for the indicator function of $A$) is closed in $L^2 \left( T \right) $ and has no element of smallest norm. It can be easily verified that $E$ is a subset of $L^2 \left( T \right) $, we proceed to prove the other assertions.

\bigbreak

We start by proving that E is closed, to do this we will prove that the sequence $\{f_n\}_{n \in \mathbb{N}}$ has no convergent subsequence in $L^2 \left( T \right) $ and thus $E$ equals it's closure. Before starting the proof, observe that most properties of $L^2 \left( \mu \right) $ spaces hold for $L^2 \left( T \right) $ as their norms are just a scalar multiplication appart, we won't give the proofs for them here. Suppose that there exists a subsequence $\{f_{n_j}\}_{j \in \mathbb{N}}$ convergent in $L^2 \left( T \right) $, by \textcolor{blue}{Th3.12} this subsequence has a subsequence $\{f_{n_k}\}_{ k \in \mathbb{N}$ which converges pointwise a.e in $[0, 2\pi]$. Given that $f_n \left( x \right) = \sin \left( nx \right) $ for all $x \in [0,\pi]$, this conclusion contradicts the result obtained in Ex4.10 saying that the set in which $\sin \left( n_k x \right) $ converges has null measure and proves our assertion.

\bigbreak

Now, to prove that $E$ has no element of smallest norm let's prove that $\inf_{n \ge 1}\|f_n\|_2 = \frac{1}{2}$ and that this infimum is not attained in $E$. To do this we start by observing that
\begin{equation}
    \bigg\{ \frac{1}{2\pi} \int_0^\pi \sin^2 \left( nx \right) \: dx \bigg\}^\frac{1}{2} = \frac{1}{2}
\end{equation}
for all $n \in \mathbb{N}$ and that $f_n \left( x \right) = \sin \left( nx \right) I_{[0,\pi]} + \sin \left( nx \right) I_{(\pi, \pi + \frac{\pi}{n}]}$. Now using (3) we can write
\[
    \|f_n\|_2 = \bigg\{ \frac{1}{2\pi} \int_0^\pi \sin^2 \left( nx \right) \: dx + \frac{1}{2\pi} \int_\pi^{\pi + \frac{\pi}{n}} \sin^2 \left( nx \right) \: dx \bigg\}^\frac{1}{2} > \frac{1}{2}
\]
which shows that $\frac{1}{2}$ is smaller than the norm of every element in $E$. With this in mind and the fact that $\sin \left( x \right) $ is a bounded function using Minkowski's inequality we get,
\[
    0 < \|f_n\|_2 - \frac{1}{2}\le  \|\sin \left( nx \right) I_{(\pi, \pi + \frac{\pi}{n}]}\|_2 \rightarrow 0
\]
This final assertion shows that $E$ has no element of smallest norm which concludes the proof.

\end{exercise}

\section*{Useful Properties}

\end{document}


\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{latexsym,amsfonts,amssymb,amsthm,amsmath}
\usepackage[makeroom]{cancel}
\usepackage {tikz}
\usetikzlibrary {positioning}

\setlength{\parindent}{0in}
\setlength{\oddsidemargin}{0in}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{8.8in}
\setlength{\topmargin}{0in}
\setlength{\headheight}{18pt}

\title{Complexity Theory - Assignment 1}
\author{Kishlaya Jaiswal, Satya Prakash Nayak}

\begin{document}

\maketitle

\vspace{0.5in}

\subsection*{Exercise 1}
\begin{proof}
We shall prove the contrapositive that $P = NP \implies EXP = NEXP$. So assume $P=NP$ then it suffices to show $NEXP \subseteq EXP$.

Let $L \in NEXP$, then there exist a non-deterministic turing machine $M$ with running time $T(x) = O(2^{|x|^c})$ that decides $L$.
Define $L_p = \{x10^{T(x)} \mid x \in L\}$.\\

We claim that $L_p \in NP$. For any $y \in L_p$, we have $|y| = |x| + T(x) + 1$. Define NTM $M'$ that does the following: on input $y$ it throws out the last $10^{T(x)}$ parts and run $M$ on $x$ (remaining part) and does whatever $M$ does. Since $M$ runs in $T(x)$ time, $M'$ is a NP machine. Therefore, $L_p \in NP \implies L_p \in P$, so there exists a deterministic poly-time machine $D$ which decides $L_p$. Now we can construct a deterministic machine $D'$ which on input $x$, will pad it with $10^{T(x)}$ and check whether $x10^{T(x)} \in L_p$ using the machine $D$ on input $x$. Hence, $L \in EXP$.
\end{proof}

\subsection*{Exercise 2}
\begin{proof}
We shall show $SAT \leq_p HALT$.

Let $N$ be the poly-time $NTM$ that decides $SAT$. Consider the modified $NTM$ $M$ which on input $x$, accepts if $N$ accepts $x$ and otherwise if $N$ rejects then $M$ goes into a loop, and hence never halts. Let $\alpha$ be the encoding for this machine $M$.

Given a SAT-instance $\phi$ encoded as $x$, consider the string $(\alpha, x)$ as an instance of $HALT$ problem. (Note that: $M_\alpha = M$)

Suppose $\phi \in SAT$, then there exists a satisfying assignment and so $N$ accepts $x$ $\implies$ $M = M_\alpha$ halts and accepts $x$ and therefore $(\alpha, x) \in HALT$. Conversely, $\phi \not \in SAT$, then $N$ rejects $x$ $\implies$ $M = M_\alpha$ doesn't halt on $x$ and therefore $(\alpha, x) \not \in HALT$.

Thus, $HALT$ is $NP$-hard.
\newline

Furthermore, $HALT \not \in NP$ because otherwise, if there exists a $NTM$ which decides $HALT$, then given a machine $M_\alpha$ and an input $x$, we could decide if $M_\alpha$ halts on input $x$, hence solving the HALTING problem. So $HALT$ is not $NP$-complete.
\end{proof}

\subsection*{Exercise 3}
\begin{proof}
$L_1 \in NP \implies \exists$ a polynomial $p_1$ and a poly-time predicate $B_1$ such that $x \in L_1 \iff \exists w, |w| \leq p_1(|x|) \wedge B_1(w,x) = 1$

$L_2 \in NP \implies \exists$ a polynomial $p_2$ and a poly-time predicate $B_2$ such that $x \in L_2 \iff \exists w, |w| \leq p_2(|x|) \wedge B_2(w,x) = 1$
\newline

To show $L_1 \cup L_2 \in NP$, consider the polynomial $p = p_1 + p_2$ and the poly-time predicate $B = B_1 \vee B_2$, then: $x \in L_1 \cup L_2 \iff (x \in L_1) \vee (x \in L_2) \iff (\exists w, |w| \leq p_1(|x|) \wedge B_1(w,x) = 1) \vee (\exists w, |w| \leq p_2(|x|) \wedge B_2(w,x) = 1) \iff \exists w, |w| \leq p(|x|) \wedge B(w,x) = 1$
\newline

To show $L_1 \cap L_2 \in NP$, consider the polynomial $p = p_1 + p_2$ and the poly-time predicate $B(w_1 \# w_2) = B_1(w_1) \wedge B_2(w_2)$, then: $x \in L_1 \cap L_2 \iff (x \in L_1) \wedge (x \in L_2) \iff (\exists w_1, |w_1| \leq p_1(|x|) \wedge B_1(w_1,x) = 1) \wedge (\exists w_2, |w_2| \leq p_2(|x|) \wedge B_2(w_2,x) = 1) \iff \exists w, w = w_1 \# w_2, |w| \leq p(|x|) \wedge B(w,x) = 1$
\end{proof}

\subsection*{Exercise 4}
\begin{proof}.
It is clear that $TAUT \in coNP$ because given any NO instance $\phi(x)$ of $TAUT$, a short certificate for verification is an assignment of variables $x$ such that $\phi(x) = 0$. Clearly such an assignment can be expressed in $O(n\lg n)$ size (where $n$ = number of variables).

To show that $TAUT$ is $coNP-complete$, we note that, for any two $NP$ languages $A$ and $B$, $A \leq_p B \iff \overline{A} \leq_p \overline{B}$.

Thus, if $L$ is $NP-complete$, then $\overline{L}$ is $coNP-complete$ because firstly, $\overline{L} \in coNP$ by definition and for any $L' \in coNP$, $\overline{L'} \leq_p L \implies L' \leq_p \overline{L}$. So, we conclude that $\overline{3SAT}$ is $coNP-complete$.

To show that $TAUT$ is $coNP-complete$, we show that $\overline{3SAT} \leq_p TAUT$. Given any formula $\varphi$, consider the formula $\overline{\varphi}$. This formula can be constructed in $O(|\varphi|)$ time. Now, $\varphi$ doesn't have a satisfying assignment iff $\overline{\varphi}$ is a tautology.
\newline

Suppose $NP=coNP$. Since $3SAT$ is $NP-complete$, for every $NP$ language $L$, $L \leq_p 3SAT$. But $TAUT \in coNP = NP \implies TAUT \leq_p 3SAT$. Similarly, since $TAUT$ is $coNP-complete$, for every $coNP$ language $L$, $L \leq_p TAUT$. But $3SAT \in NP = coNP \implies 3SAT \leq_p TAUT$.

Conversely, let $L \in NP$, then $L \leq_p 3SAT \leq_p TAUT$. So given a NO instance of the problem $L$, we reduce it to a NO instance of $TAUT$ problem and hence we have a short certificate for the NO instances of $L$ as well implying that $L \in coNP$. Similarly, let $L \in coNP$, then $L \leq_p TAUT \leq_p 3SAT$. So given a YES instance of the problem $L$, we reduce it to a YES instance of $3SAT$ problem and hence we have a short certificate for the YES instances of $L$ as well implying that $L \in NP$. Thus, $NP=coNP$.
\end{proof}

\subsection*{Exercise 5}
\begin{proof}
Suppose unary $NP \subseteq P$.

Let $L \in NEXP$, then there exist a non-deterministic turing machine $M$ with running time $T(x) = 2^{|x|^c}$ that decides $L$.

Define $L_u = \{Unary(x) \mid x \in L\}$.\\

Observe that if $x \in L$, then $x$ is a binary string of length $|x|$ and so the unary representation of $x$ will have size atmost $2^{|x|}$.

We claim that $L_u \in NP$. For that we construct a machine $M'$ which on input $1^y$, converts $y$ into it's binary $x$ and then simulate $M$ on $x$. $M'$ accepts $1^y$ iff $M$ accepts $x$. Since $|1^y| = y < 2^{|x|}$, $M$ requires $2^{|x|} + 2^{|x|^c} = O(2^{|x|^c}) = O(y^c)$ time and hence $L(M') = L_u \in NP$.

Therefore, $L_u \in P$, so there exists a deterministic poly-time machine $D$ which decides $L_u$. Now we can construct a deterministic machine $D'$ which on input $x$, will construct $Unary(x)$ and check if it is in $L_u$ using the machine $D$. Hence, $L \in EXP$.
\end{proof}

\subsection*{Exercise 6}
\begin{proof}
Since $P=NP$, we claim that $P = coNP$: $L \in coNP \implies \overline{L} \in NP \implies \overline{L} \in P \implies L \in coP = P$.

Thus $TAUT \in P$ and so there exists a poly-time algorithm $A$ such that $A(\varphi(y)) = 1$ iff $\varphi(y)$ is a tautology.

We shall show that $\Sigma_2 SAT \in NP$. Consider a YES instance of $\Sigma_2 SAT$, that is a formula $\psi = \exists x \forall y (\phi(x,y) = 1)$ which admits a $x_0$ such that $\phi(x_0,y)$ is a tautology.

Then a short certificate for $\psi \in \Sigma_2 SAT$ is $x_0$; because clearly $|x_0| \leq |\psi|$ and in poly-time we can check if $\phi(x_0,y)$ is a tautology by calling $A(\phi(x_0, y))$.

In other words, $\psi \in \Sigma_2 SAT \iff \exists x_0$ such that $|x_0| \leq |\psi|$ and $A(\phi(x_0,y))=1$.

Hence $\Sigma_2 SAT \in P$.
\end{proof}

\vspace{2in} %Leave more space for comments!

\end{document}


\documentclass[a4paper,11pt]{article}
\usepackage{geometry}
 \geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }

 \usepackage{amsmath}
 \usepackage{siunitx}
 \usepackage{multirow}
\usepackage{colortbl}
 \usepackage{hhline}

 \usepackage{lipsum}  %%% Lorem ipsum

\setlength{\headheight}{30.0pt}
\setlength{\footskip}{20pt}

\usepackage{hyperref}
\hypersetup{
    colorlinks=True,
    linkcolor={blue!20!black},
    filecolor=magenta,
    urlcolor=cyan,
}

 \usepackage[export]{adjustbox}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{multicol}

\pagestyle{fancy}
\fancyhf{}
\rhead{\textit{Pul074BEX004}}
\lhead{\textit{Amrit Prasad Phuyal}}
\rfoot{\thepage}

\usepackage{mathpazo} % Palatino font
\usepackage{graphicx}
\usepackage{float}

\input{./CoverPage.tex} %%% cover page
\input{./Matlab.tex} %%% Matlab code

\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}

%%%%%%%%%%%%%%%%%%%%%for matlab observation #1 fig name #2 Caption
\newcommand{\mobs}[2]{
    \begin{figure}[H]
        \centering
        \includegraphics[width=1.07\linewidth]{./FIG/#1.eps}
        \caption{#2}
    \end{figure}

}

\begin{document}

%%%%  COver page
\CP{Digital Signal Processing}{Lab \#2}{Familiarization with basic CT/DT functions}
{Anila  Kansakar}
%%%%%%%%%%%%%%%%%%%%

\pagenumbering{gobble}
\renewcommand{\contentsname}{Table of Contents}
\tableofcontents

\pagebreak
%\listoffigures
% \pagebreak
% \vspace{5em}
\lstlistoflistings
\vspace{10em}
% \pagebreak
\listoffigures
\pagebreak
\pagenumbering{arabic}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Title} {\large Familiarization with basic CT/DT functions }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Objective}
Familiarization with basic CT/DT functions

%%%%%%%%%%%%%%%%%%%%%

%Theory
\section{Theory}

\begin{verbatim}
    who         >> List variables in workspace
    whos        >> List variables in workspace, with sizes and types
    input()     >> Read input from user
    disp()      >> Display value of variable
    subplot()   >> Plot multiple graphs in one figure
    figure()    >> Create new figure window
    clear all   >> Clear all variables from workspace, freeing up system memory
    close all   >> Close all figures
    home        >> Send cursor to home position
    hold on     >> Retain plot data for multiple plots in one figure
    grid on     >> Turn on grid lines
    grid off    >> Turn off grid lines
    grid        >> Turn on and off grid lines and set grid spacing
    demo        >> Access product examples in Help browser
    ver         >> Display version of Matlab and operating system information
    lookfor     >> Search for keyword in all help files
    length()    >> Length of largest dimension of array
    pause       >> Stop MATLAB execution temporarily
    plot()      >> 2-D line  plotting
    stem()      >> Plot discrete data as stems
    real()      >> Return real part of complex number
    imag()      >> Return imaginary part of complex number
    zeros()     >> Create array of all zeros
    ones()      >> Create array of  all ones
    exp()       >> Return exponential of complex number
    for         >> Loop to repeat specified numbers of times
    end         >> End  For loop
    if-else     >> If-else statement execute if statement is true
\end{verbatim}

\section {Lab Problems}
%%%%%%%%%%%%Problem 1

\subsection{Problem 1}
\subsection*{Plot the basic signal using Matlab}

%%%%%%%%%%%%% Problem 1aaaaaaaaaaaaaa
\subsubsection{Impulse response}
Codes:
\MAT{./CODES/p1a.m}{Matlab code for plotting Impulse function }
\mobs{impulse}{Plot for Impulse function }

%%%%%%%%%%%%% Problem 1bbbbbbbbbbbb
\subsubsection{Unit step response}
\MAT{./CODES/p1b.m}{Matlab code for plotting Unit Step function }
\mobs{unit}{Plot for Unit Step function }

%%%%%%%%%%%%% Problem 1ccccccccccccccc
\subsubsection{Ramp response}
\MAT{./CODES/p1c.m}{Matlab code for plotting Ramp function }
\mobs{ramp}{Plot for Ramp function}

%%%%%%%%%%%% Problem 1dddddddddddddd
\subsubsection{ Rectangular pulse response}
\MAT{./CODES/p1d.m}{Matlab code for plotting  Rectangular pulse function }
\mobs{rect}{Plot for Rectangular pulse function}

%%%%%%%%%%%%Problem 2
\subsection{Problem 2}
\subsection*{Plot the following continuous-time signals}

%%%%%%%%%%%%% Problem 2aaaa
\subsubsection*{$x(t)=Ce^{at}$ where $C$ and $a$ are real numbers and choose $C$ and $a$ both positive and negative.}
\MAT{./CODES/p2a.m}{Matlab code for C and a  Both real }
\mobs{ca_real}{Plot for for C and a  Both real}

%%%%%%%%%%%%% Problem 2bbbbbb
\subsubsection*{Plot the same signal taking $a$ as pure imaginary number}
\MAT{./CODES/p2b.m}{Matlab code for C real a Imaginary }
\mobs{a_imag}{Plot for C real a Imaginary}

%%%%%%%%%%%%% Problem 2ccccc
\subsubsection*{Consider complex exponential signal as specified in b) where $C$ is expressed in polar form i.e., $C=|C|e^{j\theta}$ and $a$ in rectangular form i.e., $a=r+j\omega_o$. Then function $x(t)$, on simplification, becomes $$ x(t)= |C|e^{rt}[\cos(\omega_o t+\theta)+j\sin(\omega_o t+\theta)]$$
Now, plot the signal for different values of r and comment on the results.\\
i. r=0 \quad \quad ii. r$<$ 0 \quad \quad iii. r$>$0}
\MAT{./CODES/p2c.m}{Matlab code for different value of r}

\subsubsection{For r=0}
\mobs{r0}{Plot for r=0}

\subsubsection{For r$<$0}
\mobs{rm1}{Plot for r$<$0}

\subsubsection{For r$>$0}
\mobs{r1}{Plot for r$>$0}

%%%%%%%%%%%%Problem 3
\subsection{Problem 3}
\subsection*{Plot the DT exponential function $x[n]=a^n$, $a=|a|e^{j\theta}$. Choose the suitable value of $|a|$ and $\theta$.}

\MAT{./CODES/p3.m}{Matlab code for calculation and plot DT exponential function}

\mobs{dt}{Plot for DT exponential function}

% %%%%%%%%%%%%Problem 4

\subsection{Problem 4}
\subsection*{Synthesize the signal from the FS coefficients as $C_0=1$, $C_1=C_{-1}=\ddfrac{1}{4}$, $C_2=C_{-2}=\ddfrac{1}{2}$, $C_3=C_{-3}=\ddfrac{1}{3}$.}
\MAT{./CODES/p4.m}{Matlab code for synthesizing and plotting signal}
\mobs{syn}{Plot for synthesized signal}

% %%%%%%%%%%%%Problem 5

\subsection{Problem 5}
\subsection*{Plot fundamental sinusoidal signal, its higher harmonics up to 5\textsuperscript{th} harmonics and add all of them to see the result. Comment on the result.}
\MAT{./CODES/p5.m}{Matlab code for calculation and plot of Sinusoidal harmonics and thier sum}
\mobs{harmonics}{Plot for Sinusoidal harmonics and thier sum}

%%Discussion and Conclusion
\section{Discussion and Conclusion}
In this Lab we familiarize ourself with Matlab Programming with basic of Continous time and Discrete time signals. We also learn about their basic operations in Matlab including  plotting and analyzing the signals. We learn to use online help for different commands and use them to calculate different DT and CT functions and plot them.

\end{document}

DSP LABs/LAB 2/DSP LAB 2 Amrit Prasad Phuyal.tex


\iffalse
It's unfair to say that mathematicians aren't real doctors, we perform surgeries all the time. In this class we'll introduce the notion of a topological manifold via simplicial (delta) complexes. Spend a day or two doing examples and go over several notions like orientation, cobordism and of course surgery.

Keywords: simplicial complex, manifold, orientation, cobordism, surgery

Type: Lecture
Homework: Recommended
Prereqs: None
\fi

\input{../preamble}
\rhead{\scshape Mathcamp 2017 : All things Manifoldy}
\begin{document}
\title{Mapping class groups}
\author{Apurva Nakade}
\thispagestyle{fancy}
\maketitle

\section{Automorphisms}

\begin{definition}
	An \textbf{automorphism} or a \textbf{self-homeomorphism} of a manifold $X$ is a map $f:X \rightarrow X$ which is a homeomorphism. The set of automorphisms forms a group under composition, denoted ${\mathrm{Homeo}(X)}$.
\end{definition}

This group is usually too big to get a good handle on, so instead we study automorphisms up to deformations i.e. we consider two automorphisms to be the same if one automorphism can be continuously deformed into another.

\begin{definition}
	The group $\mathrm{Homeo}(X)/{deformations}$ is called the \textbf{mapping class group}, denoted $\mathrm{MCG}(X)$.
\end{definition}

\begin{example}\label{thm:MCG}
	Every automorphism of $\R^1$ is a strictly increasing or a strictly decreasing function $f:\R^1 \rightarrow \R^1$. It is possible to deform a strictly increasing function $f_1$ to another strictly increasing function $f_2$ via the path of maps $t.f_1 + (1-t).f_2$ for $t\in[0,1]$, similarly for decreasing functions. And composition of two decreasing functions is an increasing function. Together these imply that $\mathrm{MCG}(\R^1) \cong \Z/2$.
\end{example}

The main object of interest for us is the mapping class group of the torus $\mathrm{MCG}(T)$ i.e. automorphisms of the torus \emph{up to deformations}. Let us fix two non-parallel circles on the torus and call these the \textbf{principal circles}. While there are various choices for these all of which work we'll pick the simples ones and call them the \textbf{red} and the \textbf{blue} circles. See \textbf{Fig.1}.
%
% The first important observation to make is that \emph{up to deformations} an automorphism of a torus is completely determined by where the two principal circles are mapped.
%
%
% \begin{ques}
% 	Are there automorphisms of the torus which map the red lines as in \textbf{Fig.2}?
% \end{ques}

\section{Dehn Twists}
One way to construct non-trivial automorphisms of the torus is via Dehn twists.
\begin{definition}
	A \textbf{Dehn twist}, denoted $D$, is a special automorphism of the cylinder which twists the cylinder as in \textbf{Fig.2}.
\end{definition}

% The direction of the rotation is very important. If the cylinder is placed upright then we think of $D$ as fixing the bottom circle and twisting the cylinder by rotating the top circle counterclockwise. To avoid confusion we'll always indicate which way is \textbf{`up'} in the cylinder.

Dehn twist has the nice property that the two boundary circles are unchanged. We can use Dehn twists to create  non-trivial automorphisms of the torus by cutting out a cylinder, performing a Dehn twist, and glueing it back. This is an example of surgery on the torus! Dehn twists look even more interesting on gluing diagrams. See \textbf{Fig.3}.

We can perform Dehn twists on other cylinders sitting inside a torus which allows us to create more automorphisms of the torus. A theorem of Dehn-Lickorish  says that for genus $g$ surfaces the mapping class group is generated by a small set of Dehn twists. Dehn twists on punctured discs give rise to Braid groups establishing further connections between topology and group theory.

\section{Exercises}
\begin{exercise}
	Use the following exercises to show that the mapping class group of $S^1 = \{ (x,y): x^2 + y^2 = 1\}$ is $\Z/2$.
	\begin{enumerate}
		\item Show that every automorphism can be continuously deformed to one that fixes the point $(1,0)$.
		\item Find two automorphisms of $S^1$ which fix $(1,0)$ which cannot be deformed into each other via automorphisms.
		\item Show that $\mathrm{MCG}(S^1) \cong \Z/2$.
	\end{enumerate}
\end{exercise}

\begin{exercise}
	Find $\mathrm{MCG}(X)$ when $X$ is one of the following spaces
	\begin{enumerate}
		\item Two parallel lines in $\R^2$
		\item Two intersecting lines in $\R^2$
		\item Union of two intersecting circles
		\item The 2 dimensional unit disk $D^2 = \{ (x,y) \in \R^2 : x^2 + y^2 \le 1\}$ \\ This one is non-trivial. Read the wikipedia page on Alexander's trick.
	\end{enumerate}
\end{exercise}

\begin{exercise}
	Based on the above exercise what is the relationship between $\mathrm{MCG}(X \sqcup X)$ and $\mathrm{MCG}(X)$, where $X \sqcup X$ denotes the disjoint union of two copies of $X$.
\end{exercise}

\begin{exercise}
	Describe the homeomorphisms which are inverses of $D_R$ and $D_B$ in the mapping class group of the torus.
\end{exercise}

\begin{exercise}
	Perform a Dehn twist on the cylinder around the equator on $S^2$. What is the corresponding element in $\mathrm{MCG}(S^2)$?
\end{exercise}

\begin{exercise}
	\begin{enumerate}
		\item Verify that $D_B D_R D_B$ and $D_R D_B D_R$ are equal in $\mathrm{MCG}(T)$ by checking what they do to the principal circles.
		\item Consider the $2 \times 2$ matrices $M_B = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}$ and $M_R = \begin{bmatrix} 1 & 0 \\ -1 & 1 \end{bmatrix}$. Verify that $M_B M_R M_B = M_R M_B M_R$.
		\item Assuming that $\mathrm{MCG}(T)$ is generated by $D_R$ and $D_B$ show that this defines a homomorphism from $\mathrm{MCG}(T)$ to the group $SL_2(\Z)$ of $2 \times 2$ matrices with integer coefficients and determinant 1.
		\item Describe the action of the matrices $M_R$ and $M_B$ on the plane and relate it to the Dehn twists $D_R$ and $D_B$.
	\end{enumerate}
\end{exercise}

\begin{exercise}
	$D_B D_R D_B$ is NOT a reflection! In \textbf{Fig. 4} describe what Dehn twists do to the shaded regions and figure out what $D_B D_R D_B$ really is.
\end{exercise}

\end{document}

01 All things manifoldy/04 - Dehn Twists.tex