\documentclass[11pt]{article}

\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{hyperref}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{complexity}
\usepackage{graphicx}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
    \framebox[\textwidth]{
      \vbox{
        \hbox to \textwidth { {\bf Algebra and Computation } \hfill Course Instructor: #2 }
        \vspace{4mm}
        \hbox to \textwidth { {\Large \hfill #5  \hfill} }
        \vspace{2mm}
        \hbox to \textwidth { {\em #3 \hfill #4} }
      }
    }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[4]{\handout{#1}{#2}{Lecturer: #3}{Scribe: #4}{Lecture #1}}

\newtheorem{theorem}{Theorem}
\newtheorem{theorem*}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{fact}[]{Fact}
\newtheorem{subclaim}[theorem]{Subclaim}

% my custom commands
\newcommand{\inparen}[1]{\left(#1\right)}             %\inparen{x+y}  is (x+y)
\newcommand{\inbrace}[1]{\left\{#1\right\}}           %\inbrace{x+y}  is {x+y}
\newcommand{\insquar}[1]{\left[#1\right]}             %\insquar{x+y}  is [x+y]
\newcommand{\inangle}[1]{\left\langle#1\right\rangle} %\inangle{A}    is <A>
\newcommand{\abs}[1]{\left|#1\right|}                 %\abs{x}        is |x|
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}        %\norm{x}       is ||x||
\newcommand{\union}{\cup}
\newcommand{\Union}{\bigcup}
\newcommand{\intersection}{\cap}
\newcommand{\super}[2]{#1^{\inparen{#2}}}             %\super{G}{i-1} is G^{(i-1)}
\newcommand{\setdef}[2]{\inbrace{{#1}\ : \ {#2}}}
\newcommand{\inv}[1]{#1^{-1}}
\newcommand{\inrpdt}[2]{\left\langle{#1},{#2}\right\rangle}%\inrpdt{x}{y} is <x,y>.
\newcommand{\pderiv}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\zo}{\inbrace{0,1}}
\newcommand{\oneton}[1]{\inbrace{1,2,\cdots, #1}}

% Commands specific to this file
% TODO: Find the right way to typeset group index
\DeclareMathOperator{\Sym}{Sym}
\newcommand{\gpidx}[2]{\insquar{#1 : #2}}             %\gpidx{H}{K}   is [H : K]
\newcommand{\gpigs}[2]{\gpidx{\super{G}{#1}}{\super{G}{#2}}} %Group index of g super ...
\newcommand{\llhd}{\!\!\lhd\!\!\lhd}
\newcommand{\roundoff}[1]{\left\lfloor #1 \right\rceil}


% \newcommand{\ceil}[1]{\lceil #1 \rceil}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\F}{\mathbb{F}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\Z}{\mathbb{Z}}
\renewcommand{\C}{\mathbb{C}}

%for algorithms
\renewcommand{\algorithmicrequire}{\textbf{Input:}}

% Problems we look at
\newcommand{\GIso}{\lang{Graph\text{-}Iso}} %Without \text, ugly minus instead of hyphen.
\newcommand{\GAut}{\lang{Graph\text{-}Aut}}
\newcommand{\SStab}{\lang{Set\text{-}Stab}}

%for Quantum computing
\newcommand{\q}[1]{\left|#1\right\rangle}
\newcommand{\qip}[2]{\left\langle#1|#2\right\rangle}
\newcommand{\outerprod}[2]{\left|#1\right\rangle\left\langle#2\right|}


\begin{document}

\lecture{21: Quantum simulation of Boolean circuits and more}{V. Arvind}{V.  Arvind}{Vipul Naik}

\section{Postulates of quantum mechanics}

\subsection{The state space postulate}

The state space of an isolated physical system is a $\C$-vector space
(equipped with inner product) and the possible outcomes form an
orthonormal basis for this space.

Note that we require the physical system to be {\em isolated}. In
fact, one of the concrete problems with implementing quantum computers
in reality is the inability to sufficiently isolate the quantum
computer from the outside world.

\subsection{The evolution postulate}

The state space of an isolated physical system evolves under the
action of a unitary operator.

In other words, if $\q{\psi}$ is the state at time $t_1$ and
$\q{\psi'}$ is the state at time $t_2$, then there exists a unitary
operator $U_{t_1,t_2}$ that maps $\q{\psi}$ to $\q{\psi'}$.

The unitary operator can thus be viewed as acting in discrete time, according
to a ``clock'' whose clock pulse is $t_2 - t_1$.

Continuous-time evolution, if we are interested in that, is governed
by a Hermitian operator, called the Hamiltonian of the system. That is:

$$ih \frac{d}{dt} \q{\psi} = H\q{\psi}$$

This is obtained by differentiating the unitary operator with respect to time.

When we only assume the physical system to be closed and do {\em not}
assume it to be isolated, then we get a time-varying Hamiltonian, and hence
the evolution is not given by a unitary operator.

\subsection{The measurement postulate}

\begin{definition}
  A \em{measurement} is a collection of linear operators $M_m$
  such that:

  $$\sum_m M_m^* M_m = I$$

  The measurement is said to be \em{measurement}(projective)
  if it measures components with respect to an orthogonal direct
  sum decomposition.
\end{definition}

The measurements we have talked of so far are projective measurements
where we look at a {\em complete} orthogonal direct sum decomposition,
that is, a decomposition as a sum of pairwise orthogonal
one-dimensional subspaces.

\section{The Deutsch-Josza problem}

\subsection{Statement of the problem}

The Deutsch-Josza problem is a somewhat artificial problem that
illustrates that in the query model, deterministic quantum computation
can be far faster than deterministic classical computation. By query
model, we mean a model where the complexity is measured by the number
of queries that need to be made to an oracle, to answer a question
about something hidden within that oracle.

Here is the precise statement:

\noindent{\bf Problem:}

  $f:\zo^n \to \zo$ is a Boolean function with the ``promise'' that
  $f$ is either constant (that is, $f(x) = f(y)$ for all $x,y \in
  \zo^n$) or balanced (that is, $\abs{f^{-1}(0)} =
  \abs{f^{-1}(1)}$). We have a query oracle for $f$, that can take in
  $x \in \zo^n$ and output $f(x)$. We need to use this query oracle
  to find where $f$ is constant or balanced. The complexity of our procedure
  is determined by the number of queries (calls) made to the oracle.


\subsection{Classical deterministic and randomized complexities}

The deterministic complexity of the Deutsch-Josza problem is
$2^{n-1}+1$.  This is because if the function is actually constant,
then we need to know its value at at least that many points to be sure
that it is constant.

The randomized complexity of the Deutsch-Josza problem is constant, in
the sense that we can, given any $\epsilon$, make a constant number of
queries dependent only on $\epsilon$ such that the probability of
error is bounded above by $\epsilon$ (note that in this case the error
is one-sided).

\subsection{Rules for the quantum algorithm}

In the quantum algorithm, what we want to do is to use the fact that
there are an equal number of $0$s and $1$s, to get the $0$s and $1$s
to {\em cancel} one another. First, however, we need to be clear as to
what exactly is {\em given} in the quantum algorithm. The quantum
algorithm does not oracle-query $f$, rather it oracle-queries $U_f$,
the unitary operator associated to $f$.

Further, the ``input'' that we send to $U_f$ need not be a ``pure''
outcome, it could be a state with any mix of amplitudes of the various
outcomes.

\subsection{The Hadamard gate}

Consider a qubit (state space is $\C^2$). The Hadamard gate takes this
as input and outputs another qubit, and its action on the basis $\q{0}, \q{1}$
is defined as follows:

\begin{eqnarray*}
  \q{0} \mapsto \frac{\q{0} + \q{1}}{\sqrt{2}}\\
  \q{1} \mapsto \frac{\q{0} - \q{1}}{\sqrt{2}}
\end{eqnarray*}

The Hadamard gate (called $H$) can be thought of as a particular instance of what
we will later see as a {\em rotation gate} -- it rotates the basis by an angle
of $\pi/4$.

The Hadamard gate acts on each qubit. Hence, if the state space has
$n$ qubits, we can consider the $n^{th}$ tensor power of the Hadamard
gate.  This is a unitary operator that does the Hadamard on {\em each}
gate. This tensor power is often denoted as $H^{\otimes n}$.

Let's see what happens if we apply $H^{\otimes n}$ to $\q{0}^{\otimes n}$.
We'll get:

\begin{eqnarray*}
  H^{\otimes n}(\q{0}^{\otimes n}) & = & \left(\frac{\q{0} + \q{1}}{\sqrt{2}}\right)^{\otimes n}\\
  \implies  H^{\otimes n}(\q{0}^{\otimes n}) & = & \frac{1}{2^{n/2}}\sum_{x \in \zo^n} \q{x}
\end{eqnarray*}

Note that applying the inverse of the Hadamard gate again retrieves for us
the origina $\q{0}^{\otimes n}$.
\subsection{The solution}

The idea is to use the Hadamard gate to {\em cancel} the effect of the $0$s
and the $1$s.

\begin{enumerate}

\item Start with a state where all qubits are $\q{0}$

\item Apply the Hadamard transform $H^{\otimes n}$ to get a state
  where all qubits are $\frac{\q{0} + \q{1}}{\sqrt{2}}$. By the
  calculation done above, the new state is $1/2^{n/2}$ times the sum
  of all possible outcomes (classical states) of the state space.

\item Tensor with the state $\frac{\q{0} - \q{1}}{\sqrt{2}}$.

\item Now apply the operator $U_f$. Note that $U_f$ applied to a pure
  outcome $x$ is:

  $$x \otimes \frac{\q{f(x)} - \q{1+f(x)}}{2^{(n+1)/2}}$$

  which simplifies to:

  $$x \otimes (-1)^{f(x)} \frac{\q{0} - \q{1}}{\sqrt{2}}$$

  Hence the effect of $U_f$ on the current state is:

  $$\sum_{x\in\zo^n} x \otimes (-1)^{f(x)}\frac{\q{0} - \q{1}}{2^{(n+1)/2}}$$

\end{enumerate}

\subsection{For a constant function}

In the case that $f$ is constant, the second term in the tensor product
becomes constant, and pulling the $(-1)^{f(x)}$ out (which after all only
controls the phase), we'll get:

$$(\sum_x \in \zo^n x) \otimes \frac{\q{0} - \q{1}}{\sqrt{2}}$$

Now, applying the inverse Hadamard transform to the first $n$ qubits,
we retrieve $\q{0}^{\otimes n} \otimes \frac{\q{0} -
  \q{1}}{2^{(n+1)/2}}$.  Thus, performing a measurement on the first
$n$ coordinates yields $\q{0}^{\otimes n}$ with certainty.

\subsection{For a balanced function}

In the case that $f$ is balanced, we get exactly half the $x$'s added
with a positive sign, and half the $x$'s added with a negative
sign. Now, when we apply the inverse Hadamard transform to this
state, we will get a quantum state that will have nonzero coefficients for all
the places where the function takes the value $1$.

\subsection{The upshot}

The upshot is as follows:

\begin{itemize}

\item We use the Hadamard transform to obtain a uniform superposition of all
  the possible input states, and then apply the unitary operator to this,
  tensored with $\frac{\q{0} - \q{1}}{\sqrt{2}}$

\item We then again apply the inverse Hadamard transform to the output qubit
  and obtain the ``aggregate'' value of the function, hence any measurement
  gives us the answer.

\end{itemize}


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


\end{document}