\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{25: Needle in a Haystack: Grover Search}{V. Arvind}{V. Arvind}{Ramprasad Saptharishi}

\section{Overview}

In this lecture, we shall look at another problem where quantum
algorithms do better than classical algorithms. This, unlike the DJ
problem, is deep and is truly one where the quantum model beats the
classical model.

\section{Grover's Search}

The problem is the following. You are given a function
$f:\inbrace{0,1}\longrightarrow \inbrace{0,1}$ as an oracle with the
promise $f(x)=1$ for precisely one $x$ say $x_0.$ The problem is to
find the $x_0.$ We want to do this with as few queries as possible. 

This is equivalent to searching in an unordered list; the value $x_0$
is hidden in the list and you want to find it. 

\subsection{Lower bounds on classical models}

It is clear that a deterministic algorithm will take $O(2^n)$
queries. 

It is easy to show that even for randomized algorithms, it would need
$O(2^n)$ queries to make the error probability bounded by a
constant. We shall leave the proof to the interested reader. 

\subsection{The Quantum Model}

Grover presented a quantum algorithms that makes
$O\inparen{2^{n/2}poly(n)}$ queries and finds $x_0$ with error
probability bounded by a constant. 

\section{The Algorithm}

The basic idea is the following property:

Let $M_1$ and $M_2$ are two lines through the origin in the plane, and the angle
separating them being $\alpha$ and let $P$ is any point on the
plane. If you reflect $P$ about $M_1$ and then that reflection about
$M_2$, the resultant point is at an angle $2\alpha$ from $P$ in the
direction $M_1M_2.$ \\

Our setting is going to be like this. We will be working in $\C^{2^n}$
and there is one special coordinate axis labelled by $x_0$ that we
want to find. Using the function provided as oracle, we can get the
unitary transform of the rotation about $x_0$ eventhough we do not
know what $x_0$ is. The idea is to take another vector whose angle
with $x_0$ is known and use this rotation technique to get closer to
$x_0.$ Since we know the angles, we know precisely how many rotations
need to be done and that will give us a vector with a very high
probability amplitude on the $x_0$ coordinate at which point we can
make a measurement. 

\subsection{The Reflection Maps}

Consider the uniform superposition $\q{\psi} = \frac{1}{N}\sum_x \q{x}.$ We know
that it makes an angle of $\cos^{-1}(2^{-n/2})$ with each coordinate
axis. 

The unitary map given to us works as we have assumed always. And we
have also seen that $\q{x}\inparen{\frac{\q{0} - \q{1}}{\sqrt{2}}}$
goes to $(-1)^{f(x)}\q{x}\inparen{\frac{\q{0}-\q{1}}{\sqrt{2}}}.$ By
just dropping the second coordinate, we can think of this as a map
$$
I_{x_0}:\q{x}\mapsto (-1)^{f(x)}\q{x}
$$
This is just the identity matrix with a $-1$ on the $(x_0,x_0)$
entry. This can be compactly written as $I_{x_0} = I -
2\outerprod{x_0}{x_0}.$ This is just reflection about the plan
perpendicular to $x_0.$

\begin{observation}
  If $U$ is any unitary operator, then $I_{U\q{0^n}} = UI_{0^n}U^{-1}.$
\end{observation}
\begin{proof}
It follows from the observation that $I_x = I - 2\outerprod{x}{x}.$
\end{proof}

\begin{observation}
  For any states $\q{\phi}$ and $\q{\psi}$, $I_\psi$ preserves the
  span of $\q{\phi},\q{\psi}.$ 
\end{observation}

In particular, $I_{U\q{0^n}}$ and $I_{x_0}$ preserve the span $S$ of $x_0$
and $U\q{0^n}.$ 

\begin{observation}
  Let $\q{e_1} = U\q{0^n}$ and let $e_2$ be anything in $S$ that is
  perpendicular to $e_1.$ We can pull out the $e^{i\theta}$ factor out
  of $e_i$ so that $\inangle{e_i,x_0}$ is real. Hence we now have 
  $$
  S = \setdef{a\q{e_1} + b\q{e_2}}{a,b\in\R}
  $$
\end{observation}

\begin{observation}
  Let $v\in S$  and let $v^\perp$ be another in $S$ that is orthogonal
  to $v$ in $S.$ Then $I_v = - I_{v^\perp}.$
\end{observation}

Thus, we need not know what $x_0$ is but by just using $I_{x_0}$ we
can achieve the reflection about $x_0.$ And let $U$ be the hadamard
transform and $U\q{0^n}$ will now be the uniform superposition $\q{\psi}.$

\subsection{The Double Reflection}

We know that $U0^n$ make an angle of $\cos^{-1}(2^{-n/2})$ with each
coordinate axis, and this is almost a right angle. Thus instead of
$U\q{0^n}$, we shall look at the orthogonal vector $U\q{0^n}^\perp$ in
the span $S$ and the reflection. The angle that $x_0$ makes with this
$\sin^{-1}(2^{-n/2})$ which is very small. Now, the unitary transform
that achieves the rotation about $x_0$ and then about $U\q{0^n}^\perp$
is just $-UI_{0^n}UI_{x_0}.$

Now look at the uniform superposition $\q{\psi} = \frac{1}{N}\sum_x
\q{x}$. This is in the plane and the double rotation will rotate it
by an angle of $2\sin^{-1}(2^{-n/2}).$ Thus with just
$\frac{\pi}{4}\sqrt{2^n}$ such double rotations we would get very
close to $x_0.$

At this point, we can safely make a measurement and obtain $x_0$ with
high probability. 


\section{Implications on $\SAT$}

The problem can be transformed to a decision problem. We are given a
function $f$ as an oracle and we need to determine if $f$ is $1$ at
atleast one $x.$ This is certainly easier than determining the $x_0$
as we have seen. 

A result of Valiant and Vazirani shows that any $\SAT$ instance $\phi$
can be reduced to another instance $\phi'$ in randomized polynomail time such
that $\phi$ is satisfiable implies $\phi'$ has exactly one satisfiable
instance, and $\phi$ is unsatisfiable implies $\phi'$ is also
unsatisfiable. 

Grover's algorithm shows that $\SAT$ can be solved in $O(\sqrt{2}^n)$
time using a quantum algorithm. 

\section{A glimpse into the finale}

In the next class, we shall show that Grover's algorithm is infact
tight, any quantum algorithm that has error probability bounded by a
constant must take $O(2^{n/2})$ queries. 

We shall prove this using two beautiful lower bound techniques in the
oracle setting. 



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


\end{document}
