Grover’s Search Algorithm and Quantum Lower Bounds Lecture Notes for CS 294-6, Quantum Computing Lecturer: Umesh Vazirani Scribe: Jie-Hong Jiang October 6, Fall 2000 Searching an item in an unsorted database with size N costs a classical computer O(N) running time. Can a quantum computer search a needle in a haystack much more efficient than its classical counterpart? Grover, in 1996, affirmatively answered this question by proposing a search algorithm, which consults the database only O( N ) times. In contrast to algorithms based on the quantum Fourier transform, with exponential speedups, the search algorithm only provides a square-root speedup. However, the algorithm is quite important because it has broad applications and the same technique can be used to improve the solution of NP-complete problems. One might think of having better improvements over the search algorithm. Nevertheless, it turns out that Grover’s search algorithm is optimal. At least ( N ) queries are needed to solve the problem. This note details the quantum search algorithm and its lower bound in Section 1 and Section 2 respectively. 1. Grover’s Search Algorithm 1.1 The quantum oracle Let f: {0, 1}n {0, 1}, be a Boolean function. We are given a quantum black box Uf for computing f: Uf : x n y x n y f ( x) . Set y as 0 , we have Uf : x n 0 x n f ( x) . As we have seen before, if we initialize y to ( 0 1 )/ 2 , the oracle acts as 1 Uf : x n 0 1 2 (1) f ( x ) x n 0 1 2 . Now suppose that there is a single value k such that f(k) = 1. If f is specified by a black box, what is the fewest queries we must make to f to determine such k? 1.2 The iterative procedure On searching an N-item database, Grover’s search algorithm uses the operator D defined as 2 2 ( N 1) N 2 2 ( 1) D N N 2 2 N N 2 N 2 N . 2 ( 1) N D has two properties: (1) It is unitary and can be efficiently realized. (2) It can be seen as an “inversion about mean.” Proof: (1) For N = 2n, operator D can be decomposed and rewritten as: 2 0 HN 0 D 1 0 0 1 HN 0 0 0 0 0 0 0 HN I 0 0 0 HN 1 HN 2 0 0 0 0 0 HN I H N 0 0 0 2 2 N 0 0 N 0 0 2 N 0 I 0 2 N 2 N 2 N I 2 N Observe that D be expressed as the product of three unitary matrices (two Hadamard matrices separated by a conditional phase shift matrix). Therefore, D is also unitary. Regarding the implementation, both Hadamard and the conditional phase shift transforms can be efficiently realized within O(n) gates. (2) When D operates on a vector and generates another vector , that is, 2 1 1 D i i , N N the ith amplitude i 2 j i 2 i ( i ) can be considered as an N j “inversion about mean” with respect to i , where is the average amplitude. As shown in Figure 1, the operation of D increases (decreases) amplitudes that are originally below (above) the mean value . i (a) i i (b) i Figure 1: Effects of D operation. (a) States before operation. (b) States after operation. The quantum search algorithm iteratively improves the probability of measuring a solution. In each iteration, this algorithm performs two operations: first consult the oracle Uf and then apply the “inversion about mean” operator D. The quantum state evolves as i1 = DUf i along with iteration i to iteration (i+1). Suppose we are finding one out of N items. In the first step, as shown in Figure 2 (a), we prepare the initial state as a uniform superposition over these N items. In each iteration, Uf marks the only solution k, f(k)=1, with a phase shift as indicated in (b). Then D operation amplifies k, the amplitude of the marked item, and suppresses those of all other items as in (c). Repeating the process before measurement increases the 3 probability of measuring k. For example, after the first iteration, k 3 second iteration, k 5 N ; after the N . More formally, at iteration t, k and l (l = 0, 1, , …, N –1; l k) are (kt ) (1 l(t ) ( Initially, (k0) l( 0) 1 2 (t 1) 2 ) k (2 ) l(t 1) N N 2 (t 1) 2 ) k (1 ) l(t 1) . N N N . After O( N ) steps, k becomes constant. Therefore, in the measurement, the probability of observing k becomes constant. Notice that repeating iterations does not always increase the chance of measuring the right answer. The amplitude of the marked solution goes up and down as a cycle. If we do not stop at the right time, we might not have a good chance to measure the correct item. i (a) i k i (b) k i i (c) k i Figure 2: Finding 1 out of N items. (a) Uniform superposition is prepared initially. Every item has equal amplitude (1 / N ). (b) Oracle Uf recognizes and marks the solution item k. (c) Operator D amplifies the amplitude of the marked item and suppresses amplitudes of other items. 4 1 M k x x f 1 (1) DU f 0 0 2 u 1 N M x x f 1 ( 0 ) U f 0 Figure 3: Geometric interpretation of the iterative procedure. 1.3 The geometric interpretation Suppose to find M solutions from a sample space with N entries. We can cluster these 1 items into two orthogonal bases, say k x (collection of the M solutions) M x f 1 (1) and u 1 N M x (collection of the remaining items). Hence, Figure 3 can x f 1 ( 0 ) visualize iterative steps in a single plane spanned by these two vectors. For original state 0 0 1 N M N N 1 x , it can be rewritten as x 0 1 M N M x 1 N x f (1) 1 N M M N M x 1 N k N u . x f ( 0) In the oracle consultation, Uf shifts the phase in the k component and therefore reflects the acted vector about u . Meanwhile, since D is a reflection about 000 in the Hadamard basis (refer the proof of property (1) of D in page 2), it reflects the acted vector about 0 . The product of these two operators, DUf, performs an equivalent 2 -rotation operation, where sin 1 M N M . After i such iterations, cos 1 N N 5 the state becomes DU i f 0 sin 2 i 1 k cos 2 i 1 u . In the special case of finding 1 out of N items (N » 1), sin 1 N , to maximize the probability of the correct measurement, the needed number of iterations 2 2 4N . Consequently, Grover’s search algorithm makes O( N ) queries. Through this visualization, it can be seen that if the number of iterations is not chosen properly, the final vector might not be rotated to a right angle; a small magnitude is projected onto the k direction, that is, we can only measure the right answer with a small probability. 2. Quantum Lower Bounds In light of previously developed quantum algorithms, one might ask if a quantum computer can solve NP-complete problems in polynomial time. Consider the satisfiability (SAT) problem, the first proven NP-complete problem. It can be formulated as a search problem. That is, given a Boolean formula f(x1, x2, …, xn), search an assignment under which the value of the expression is 1. Ask whether we can devise a quantum algorithm to search within poly(n), or log N (N = 2n), steps. In the following discussion, quantum lower bounds show that such a quantum speedup is unlikely. 2.1 The hybrid argument Consider any quantum algorithm A for solving the search problem. First do a test run of A on function f 0. Define the query magnitude of x to be 2 x ,t , where x,t is the t amplitude with which A queries x at time t. The expectation value of the query magnitudes E x t 2 x ,t 2 T = N . Thus, min x ,t T N . Fix such an x, by x t Cauchy-Schwarz inequality, x,t T N t . Now we modify the query on another function g: g(x) = 1, g(y) = 0 y x. Let 0 , 1 , …, T be the states of Af. Suppose the final state of Ag is T . We will 6 show that T T must be small. Claim: T = T + E0 + E1 + … + ET 1 , where Ei is the error due to Step i. 2.2 The quantum adversary method References [1] [2] [4] [5] A. Ambainis. Quantum lower bounds by quantum arguments. quant-ph/0002066. C. H. Bennett, E. Bernstein, G. Brassard and U. Vazirani. Strengths and weaknesses of quantum computing. SIAM Journal on Computing, Vol. 26, No.5, pp 1510-1523, Oct. 1997. L. K. Grover. A fast quantum mechanical algorithm for database search. Proceedings of the 28th ACM Symposium on Theory of Computing, pp. 212-219, 1996. U. Vazirani. On the power of quantum computation. Philosophical Transactions of the Royal Society of London, Series A: Mathematical and Physical Sciences, 356: 1759-1768, August 1998. 7