Professional Documents
Culture Documents
A Fast Quantum Mechanical Algorithm For Database Search - Lov K Grover IIT-D
A Fast Quantum Mechanical Algorithm For Database Search - Lov K Grover IIT-D
Lov K. Grover
3C-404A, AT&T Bell Labs
600 Mountain Avenue
Murray Hill NJ 07974
lkg@mhcnet.att.com
1. Introduction
that this @gorithm will need to look at an average of\
1.0 Background Quantum mechanical computers
items before finding the desired one.
were proposed in the early 1980’s [Benioff80] and
shown to be at least as powerful as classical computers -
1.1 Search Problems in Computer Science
an important but not surprising result, since classical
Even in theoretical computer science, the typical prob-
computers, at the deepest level, ultimately follow the
lem can be looked at as that of examining a number of
laws of quantum mechanics. The description of quan-
different possibilities to see which, if any, of them sat-
tum mechanical computers was formalized in the late
isfy a given condition. This is analogous to the search
80’s and early 90’s [Deutsch85][BB92] [BV93] [Yao93] problem stated in the summary above, except that usu-
and they were shown to be more powerful than classical ally there exists some structure to the problem, i.e some
computers on various specialized problems. In early sorting does exist on the database. Most interesting
1994, [Shor94] demonstrated that a quantum mechani- problems are concerned with the effect of this structure
cal computer could efficiently solve a well-known prob- on the speed of the algorithm. For example the SAT
lem for which there was no known efficient algorithm problem of NP-completeness asks whether it is possible
using classical computers. This is the problem of integer to find any combination of n binary variables that satis-
factorization, i.e. testing whether or not a given integer, fies a certain set of clauses C, in time polynomial in n. In
N, is prime, in a time which is a finite power of this case there are N=2’ possible combinations which
o (logN) . have to be searched for any that satisfy the specified
property and the question is whether we can do that in a
-------------------- ------------------------ ----
time which is a finite power of O (logN) , i.e. O (nk) .
Permission to make digitelihard copies of all or part of tMs material for Thus if it were possible to reduce the number of steps to
personal or ctasamom use is granted without fee provided that the copies
are not made or dktributed for profit or commercial advantage, the copy- a finite power of O (logIV) (instead of O ( ~N) as in
right notice, the titte of the publication and its date appear, and notice is
given that copyright is by permission of the ACM, Inc. To copy otherwise, this paper), it would yield a polynomial time algorithm
to repubtish, to poet on servers or to redktribute to tints, requires specific for NP-complete problems.
permission and/or fee.
STOC’96, Philadelphia PA, USA
In view of the fundamental nature of the search
Q 1996 ACM 0-89791-785-5/96/05. .$3.50 problem in both theoretical and applied computer sci-
ence, it is natural to ask - how fast can the basic identifi-
212
cation problem be solved without assuming anything tem is equal; the second is the Fourier transformation
about the structure of the problem? It is generally operation and the third the selective rotation of different
assumed that this limit is O (N) since there are N items states.
to be examined and a classical algorithm will clearly A basic operation in quantum computing is that
of a “fair coin flip” performed on a single bit whose
take O (N) steps. However, quantum mechanical sys-
states are O and 1 [Simon93]. This operation is repre-
tems can sometimes be counter-intuitive [BV93]
[1
~_l
into a superposition
.Abit
in the
the desired item can be identified. [BBBV94] show in
their paper that in order to identify the desired element, two states: $+ . Similarly a bit in the state 1 is
()
without any information about the structure of the data-
base, a quantum mechanical system will need at least
‘Msfomedkto(;+ioeof iemagni’tideofthe
Cl ( ~~ steps. Since the number of steps required by
the algorithm of this paper is O ( fi) , it is within a amplitude in each state is ~ but the phase of the
&
constant factor of the fastest possible quantum mechani-
cal algorithm. amplitude in the state 1 is inverted. The phase does not
have an analog in classical probabilistic algorithms. It
1.2 Quantum mechanical algorithms A good
comes about in quantum mechanics since the ampli-
starting point to think of quantum mechanical algo-
tudes are in general complex. As mentioned previously,
rithms is probabilistic algorithms [BV93] (e.g. simu-
the probabilities are determined by the square of the
lated annealing), In these algorithms, instead of having
absolute value of the amplitude in each state; hence the
the system in a specified state, it is in a disrnbution over
probabilities of the two states in both cases (i.e. when the
various states with a certain probability of being in each
state. At each step, there is a certain probability of mak- amplitudes are $,$ and when they are
ing a transition from one state to another. The evolution ()
of the system is obtained by premultiplying this proba-
) are equal. And yet the distributions have
bility vector (that describes the distribution of probabili- ($”$)
ties over various states) by a state transition matrix.
very different properties. For example, applying M to
Knowing the initial distribution and the state transition
matrix, it is possible in principle to calculate the distri- the disrnbution results in the configuration
bution at any instant in time. ~ () +’ i
Just like classical probabilistic algorithms, being in the state O; applying M to the distribution
quantum mechanical algorithms work with a probability 11, ——
results in the system being in the state 1.
distribution over various states. However, unlike classi- (3 d)
cat systems, the probability vector does not completely
Two distributions that had the same probability distribu-
describe the system. In order to completely describe the
tions over all states, now have orthogonal distributions!
system we need the amplitude in each state which is a
This illustrates the point that, in quantum mechanics, the
complex number. The evolution of the system is
complete description of the system requires the ampli-
obtained by Premultiplying this amplitude vector (that
tudes over all states, just the probabilities is not enough.
describes the distribution of amplitudes over various
In a system in which the states are described by
states) by a transition matrix, the entries of which are
n bits (it has 2n possible states) we can perform the
complex in general. The probabilities in any state are
transformation M on each bit independently in sequence
given by the square of the absolute values of the ampli-
thus changing the state of the system. The state transi-
tude in that state. It can be shown that in order to con-
tion matrix representing this operation will be of dimen-
serve probabilities, the state transition matrix has to be
unitary [BV93]. sion 2n X 2n. In case the initial configuration was the
The machinery of quantum mechanical algo- configuration with all n bits in the lirst state, the resuR-
rithms is illustrated by discussing the three operations ant configuration will have an identical amplitude of
that are needed in the algorithm of this paper. The tirst is -. n
the creation of a configuration in which the amplitude of 22 in each of the 2n states. This is a way of creating a
the system being in any of the 2“ basic states of the sys-
distribution with the same amplitude in all 2“ states.
213
Next consider the case when the sting state 3. Algorithm
is another one of the 2“ states, i.e. a state described by (i) Initialize the system to the distribution
an n bit binary string with some 0s and some 1s. The 1111
result of performing the transformation
will be a superposition
M on each bit
of states described by all possi-
( ~~~...~
)
, i.e. there is the same amplitude
uct of % and y , i.e. (–1) z” Y. This transformation is This diffusion transform, D, can be
referred to as the Fourier transformation [DJ92]. This implemented as D = FRF, where F the
operation is one of the things that makes quantum Fourier Tkmsform Matrix and R the rotation
mechanical algorithms more powerful than classical matrix are defined as follows:
algorithms and forms the basis for most significant Rij=Oifi#j;
quantum mechanical algorithms.
Rii= 1 ifi= O; R.. =–lifi#O.
The third transformation that we will need is tl
the selective rotation of the phase of the amplitude in As discussed in section 1.2, the
certain states. The transfomnation describing this for a 4 Fourier transformation matrix F is
defined as:
Oe
I
‘o’ o. .
0 where
Fij = 2-n/2 (–1) i “J, where ~ is the
Note that, unlike the Fourier transformation and other with a probability of at least ~.
state transition matrices, the probability in each state 2
stays the same since the square of the absolute value of
the amplitude in each state stays the same.
4. Outline of rest of paper
The following sections prove that the system discussed
2. The Abstracted Problem Let a system in section 3 is indeed a valid quantum mechanical sys-
have N = 2n states which are labelted S1 ,S2,...SN These tem and that it converges to the desired state with a
probability O(l). The proofs are divided into two parts,
2n states are represented as n bit strings. Let there be a First, it is proved that the system is a valid quantum
unique state, say Sv, that satisfies the condition C(SV) = mechanical system (theorems 1 & 2) and, second, that it
1, whereas for all other states S, C(S) = 0 (assume that converges to the desired state (theorems 3, 4 & 5) . In
for any state S, the condition C(S) can be evaluated in order to prove that it is a valid quantum mechanical sys-
unit time), The problem is to identify the state SV. tem we need to prove that it is unitary and that it can be
implemented as a product of local transition matrices.
214
The diffusion transform D is defined by the matrix D as lar case of the diffusion transformation by using theo-
foffow.x rem 3.
Corollary 3.2- Let the state vector be as follows -
(4.0) Dij=; ,ifi#j&Dii = -1+;.
for the state that satisfies C(S) = 1, the amplitude is k,
Theorem 1- The matix D is unitary. for each of the remaining (N-1) states the amplitude is 1.
Then if after applying the diffusion transformation D,
The way D is presented above, it is not a local tmnsition the new amplitudes are respectively kl and 11 iis derived
matrix since there are transitions from each state to all N in theorem 3, then
states. Using the Fourier transformation matrix as
k:+ (N-1)1; = k2+ (N-1)12
defined in section 3, it can be implemented as a product
of three unitary transformations as D = FRF, each of
k & 1vary with each iteration of the algorithm in section
F & R is a local transition matrix. R as defined in theo-
3. Therefore if we are given k at any step of the algo-
rem 2 is a phase rotation matrix and is clearly local. F
rithm, by using the conservation result of corollary 3.2
when implemented as in section 1.2 is a local transition
matrix on each bit. we can immediately obtain 111, the sign of 1 can be
deduced by corollary 3.1 -it is thus enough to keep track
Theorem 2 - D can be expressed as D = FRF,
of one variable k or 1, not both. Using this we prove -
where F, the Fourier Transform Matrix and R, the rota-
tion matrix are defined as follows
Theorem 4- Let the state vector before step (a) of the
algorithm be as follows - for the one state that satisfies
Rij=Oifi#j,
c (s) = 1, the amplitude is k, for each of the remain-
Rii=lif i= O, Rii=–lifi#O. ing (N-l) states the amplitude is 1 such that
11 =$k+~l. 1
state when k is ~, is k2 = ~. Therefore if the system
J2
is now sampled, it will be in the desired state with a
Using this we prove a simple relation between the
amplitudes k & 1. probability of ~. Finally it is proved that once we can
Corollary 3.1- Let the state vector be as follows -
design an experiment with a finite success probability of
for any one state the amplitude is k, for each of the
remaining
real numbers
(N-1) states the amplitude
(in general the amplitudes
is 1. Let k and 1 be
can be com-
E,
()
in O ~ repetitions
to have a probability
of the experiment it is possible
~ < ~N. Then after applying the diffusion transform Theorem 5- Let the probability of a particular out-
both k and 1are positive numbers. come in an experiment be &. Then if the experiment be
215
Section 6 quotes the argument fkom [BBBV94] that it is
not possible to identify the desired record in less than
don: D2, ad = XFabR2, bCFCd. Uskg
bc
the definition
Q ( J7i7isteps.
of R2 and the fact N = 2n, it follows that
5. Proofs
As mentioned before (4.0), the diffusion transform D is
all elements of the matrix Dz equal ~, the sum of the
defined by the matrix D as follows:
two matrices D1 and D2 gives D.
(5.0) Dij=~, ifi#j&Dii= -1+~.
Theorem 1- The matrix D is unitary. Theorem 3- Let the state vector be as follows - for
Proof - For a marnx to be unitary it is necessary and any one state the amplitude is kl, for each of the remain-
sufficient to prove that the columns are orthonormal. ing (N-1) states the amplitude is ll. Then after applying
The magnitude of each column vector is the diffusion transform D, the amplitude in the one state
n
E
i=l
D?. j = 1, 2...n.
ZJy
Substituting from (5.0), it fol-
isk2
each
=
of
()
2
~– 1 k1+2(
the
N-1
N
remaining
) 11 and the amplitude
(N-1) states
in
is
to 1. The dot product of two distinct column vectors is Proof -Using the definition of the diffusion transform
n (5.0) (at the beginning of this section), it follows that
x
i=l
DikDij. This is N~
N2
–:
N
= O,
k2 =
()
;-1 k1+2~11
2(N-2)11
12 = ;- ll+~k+N
lN1
()
Theorem 2 - D can be expressed as D = FRF, l%erefortz
where F, the Fourier Transform Matrix and R, the rota-
tion matrix, are defined as follows
Rij = O ifi#j,
R1
= –1, 1 is the identity matrix and R2 ~ = 2,
kl =
() ~-l k+2~l. Assuming N>2, it fol-
proved that FF=I and hence D ~ = FRIF = –I. We tive and 2(N;
—1 1) is positive and hence kl >0.
next evaluate D2 = FR2F. B y standard matrix multiplica- Similarly it follows that since by theorem 3,
216
~ c ~ is satisfied, then 11>0. If ~ < ~N,
‘hce(o<k<*) it follows from corollary 3.2 that
andll>O.
is positive, it follows that 1> — . Therefore by (5.1),
~N
Corollary 3.2- Let the state vector be as follows -
assuming non-trivial N, it follows that Ak >.~.
for the state that satisfies C(S) = 1, the amplitude is k, ;?~N
for each of the remaining (N-1) states the amplitude is 1.
In order to prove 12>0, observe that after the phase
Then if after applying the diffusion transformation D,
the new amplitudes are respectively kl and 11as derived inversion (step (a)), kl <0 & 11>0. Furthermore it fol-
in theorem 3, then
_4(N-2) (iV-l)kl
N2 In order to prove theorem 5, we tist prove a simple
lemma
Similarly
4 (N- l)2kz
Lemma 5- (1 -y) ’17 c e-” provided K y >0.
(N-1)1? = N2
Proof - Observe that (1 -y) < efl, if ‘y> O. Now
Adding the previous two equations the corollary fol- Theorem 5- Let the probability of a particular out-
lows. come of an experiment be e. Then if the experiment be
(o<k<$) and 1>0. The change in k (Ak) after lemma 5 this is less than or equal to e-”.
217
eracy of the solution being in the range
to N queries will take a running time of T = L2 ( ~N) .
(k, k + 1, . . . 2k) for various k. Then within log N repe-
To see this, assume that C(S) = O for all states and the
titions of this procedure, one can ascertain whether or
algorithm returns the right result. Then, by [BBBV94] if
not there exists at least one state out of the N states that
T< C?( rN) the answer to at least one of the queries satisfies the condition.
about C(S) for some S can be flipped without affecting (ii) The other possibility is to slightly perturb the prob-
the result, thus giving an incorrect result this time, lem in a random fashion as discussed in [MVV87] so
that with a high probability the degeneracy is removed.
There is also a scheme discussed in [VV86] by which it
7. Other observations
is possible to modify any algorithm that solves an NP-
1. As mentioned in the introduction, the algorithm
search problem with a unique solution and use it to
of this paper does not use any Imowledge about the
solve an NP-search problem in general.
problem. There exist fast quantum mechanical algo-
rithms that make use of the structure of the problem at
hand. For example Shor’s primality testing algorithm T. Acknowledgments The author gratefully
[Shor94] for a number N can be viewed as a search of acknowledges Peter Shor’s and Ethan Bernstein’s help
the (N-l) numbers smaller than N to see if any of them is in going through this paper in detail and making several
a factor of N. This algorithm, by cleverly making use of extremely constructive suggestions.
some features of the structure of the problem, is the only
known algorithm that solves the problem in O (logIV)
steps. It might be possible to combine the search scheme
8. References
of this paper with [Shor94] and other quantum mechani- BBBV94] C.H. Bennett, E. Bernstein, G. Brassard
cal algorithms to design even faster algorithms. Altern- and U.Vazirani, Strengths and weak-
atively, it might be possible to combine it with efficient nesses of quantum computing, preprint,
database search algorithms that make use of specific 1994.
properties of the database. ~B92] A. Berthiaume and G. Brassard, The
Associative memories were one of the first appli- quantum challenge to structural com-
cations of synthetic neural networks. There, the motiva- plexity theory, Proceedings 7th IEEE
tion was to use as much information as possible about Conference on Structure in Complexity
the problem so as to encode and retrieve it most effi- Theory, 1992, pp. 132-137.
ciently. It is interesting to speculate about computational lBenioff80] P. Benioff, The computer as a physical
properties and limits of quantum mechanical neural sys- system: A microscopic quantum
tems that might achieve both efficient encoding as well mechanical Ha~”ltonian model of com-
as efficient search. [Penrose89] [Penrose94] mention puters as represented by Turing
that certain neural sensing systems in the retina and machines, Journal of Statistical Physics,
brain operate in a quantum mechanical framework. 22, pp. 563-591.
Quantum mechanical computation is discussed as one lllv93] E. Bernstein and U. Vazirani, Quantum
possible aspect distinguishing a brain from a traditional Complexity Theory, Proceedings 25th
computer. Noise is a factor which limits quantum ACM Symposium on Theory of Com-
mechanical computation in the brain and elsewhere. puting, 1993, pp. 11-20.
Very recent results [Shor95] have shown the existence meutsch85] D. Deutsch, Quantum Theory, the
of quantum mechanical error corr~ting cod~ which Church-Turing principle and the univer-
enable transmission of data even in the presence of sal quantum computer, Proceedings
noise; design of error free quantum mechanical gates Royal Society London Ser. A, 400, pp.
still remains an unsolved problem. 96-117.
~J92] D. Deutsch and R. Jozsa, Rapid solution
2. The algorithm as discussed here assumes a unique of problems by quantum computation,
state that satisfies the desired condition. It can be easily Proceedings Royal Society of London,
modified to take care of the case when there are multiple A400, pp. 73-90.
states satisfying the condition C(S) = 1 and it is required ~V87] K. Mulmuley, U. Vazirani and V. Vazi-
to return one of these. Two ways of achieving this are: rani, Matching is as easy as matrix
(i) The first possibility would be to repeat the experi- inversion, Combinatorics, 7 (1987), pp.
ment so that it checks for a range of degeneracy, i.e. 105-131.
redesign the experiment so that it checks for the degen-
218
[Pemose89] R. Penrose, The Emperor’s New Mind,
Concerning Computers, Minds and the
Laws of Physics. Oxford University
Press, 1989, pp. 400-402.
[Penrose94] R. Penrose, Shadows of the mind,.
Oxford University Press, 1994, pp. 348-
388.
[Shor94] P. W. Shor, Algorithms for quantum
computation: discrete logarithms and
factoring, Proceedings, 35th Annual
Symposium on Fundamentals of Com-
puter Science (FOCS), 1994, pp. 124-
134.
[Shor95] P. W. Shor, Scheme for reducing deco-
herence in quantum computer memory,
Phys. Rev. A, Vol. 52, October 1995, pp.
2493-2496.
[Simon94] D. Simon, On the power of quantum
computation, Proceedings, 35th Annual
Symposium on Fundamentals of Com-
puter Science (FOCS), 1994, pp.l16-
123.
[VV86] L. G. Valiant and V. Vazirani, NP is as
easy as detecting unique solutions, The-
oretical Computer Science 47, 1986, pp.
85-93.
[Yao93J A. Yao, Quantum circuit complexip,
Proceedings 34th Annual Symposium
on Foundations of Computer Science
(FOCS), 1993, pp. 352-361.
219