Search an Unsorted Database with Quantum Mechanics
http://www.paper.edu.cn
Front. Comput. Sci. China 2007, 1(3): 247−271 DOI 10.1007/s11704-007-0026-z REVIEW ARTICLE
Search an unsorted database with quantum mechanics
LONG Guilu ( ), LIU Yang
Key Laboratory for Atomic and Molecular Nanosciences of Ministry of Eduation, Department of Physics, Tsinghua University, Beijing 100084, China Tsinghua National Laboratory for Information Science and Technology, Tsinghua University, Beijing 100084, China
© Higher Education Press and Springer-Verlag 2007
Abstract In this article, we review quantum search algo- markably, there is a quantum search algorithm which en- rithms for unsorted database search problem. Unsorted da- ables this search problem to be speeded up substantially, tabase search is a very important problem in science and requiring only ON() operations. Moreover, the quan- technology. In a quantum computer, a marked state can be tum search algorithm is general in the sense that they can found with very high probability using the Grover's algo- be applied far beyond the route-finding example just de- rithm, or exactly with the Long algorithm. We review the scribed to speed up many (though not all) classical algo- Grover algorithm and related generalizations. In particular, rithms that use search heuristics. It plays very important we review the phase matching conditions in quantum roles in the fields of information and computation. For search algorithm. Several issues that may cause confusion example, finding the owner of a phone number, deciphering about the quantum search algorithm are also clarified. DES like code [1], solving the Simon problem [2], quantum counting problem [3]. Spaces can be efficiently searched by Keywords quantum search algorithm, Grover algorithm, a quantum robot using quantum search algorithm [4]. It can Long algorithm, Phase matching, quantum amplitude am- also speed up in a square-root manner difficult problems plification, duality computer such as the hidden shift problem [5], the Hamiltonian cir- cuit problem [6] and NP-complete problem in general [7].
1 Introduction In this review article, we will describe various aspects of quantum search algorithms. In Section 2, we give a brief in- Finding a marked item from an unsorted database (UDB), troduction of the Grover search algorithm. In Section 3, before the so-called unsorted database search (UDS) problem is a going to several important generalizations, we give a clear very common and difficult problem. Many scientific prob- separation of the basic elements in a quantum searching algo- lems can be reduced to UDS problem and the UDS has rithm. We divide the quantum searching problem into two wide applications in science and technology. For instance, basic elements: the search engine and the database. The ob- suppose you are given a map containing many cities, and scurity between a quantum search engine and a quantum da- want to find the shortest route passing through all cities on tabase often misleads people to err. Most impor- the map. A simple algorithm to find this route is to search tantly, the unitary operators U' in ||0ψ0 〉=U' 〉, the database, all possible routes through the cities and keep a record of −1 and U in the search engine G = −UR U Rτ is which route has the shortest length. On a classical computer, 0 not the same in general. However these two are often the same if there are N possible routes, it is obvious that O(N) opera- in many quantum search algorithms. Separating them clears tions are required to determine the shortest route. Re- many misunderstanding. In Section 4 we describe several generalizations of the Grover algorithm, including finding Received July 20, 2007 multiple marked items, replacing the Walsh-Hadamard trans-
E-mail: [email protected] formation with an arbitrary unitary transformation, namely the
转载 中国科技论文在线 http://www.paper.edu.cn
248 quantum amplitude amplification. In Section 5, we concen- trate on one important generalization of replacing the two phase inversions with general phase rotations. Contrary to Excellent work have been done for classical algorithms on anticipation, arbitrary phase rotations are not allowed in a searching problem [8, 9]. Grover algorithm and Shor al- good quantum search algorithm. A good quantum search al- gorithm are the two most successful algorithms in quantum gorithm can find the marked state with high probability. It computing [10, 11]. Grover proposed a quantum mechani- is only when the two phase rotation angles satisfy a phase cal search algorithm [12] which is polynomially faster than matching condition that a good quantum search algorithm classical algorithm. The investigated problem is: there is can be built. It depends both on the quantum search engine an unsorted database containing N items of which only one and on the quantum database. In Section 6, we review an item is to be retrieved. This is the UDS problem. exact quantum search algorithm, the Long algorithm. The The classical algorithm for this problem is to examine standard Grover algorithm finds a marked state with very items one by one. Thus the algorithm needs N/2 iterations high probability in general for very large database. How- in average for finding a desired marked item. Quantum me- ever in some applications, the quantum database size is lim- chanics systems can be in a superposition of the basis states. ited, or the number of marked states is large, then Grover By properly adjusting the various operations, Grover search algorithm runs into difficulty. For instance, Grover algo- algorithm enables√ this method to speed up substantially, re- rithm fails for a database with only two items or half of the quiring only O( N) operations. data is the marked states. The application of the Grover al- Now we examine the Grover algorithm. Let a quantum n gorithm does not increase the finding probability at all. In system have N =2 states which are labelled as |i(i = this case, the Long algorithm is very suited for. It involves 1, 2,...,N), there is a unique marked state |τ that satisfies replacing the two phase inversions with two phase angles a query function C(i)=1, whereas any other state satis- satisfying the phase matching condition and dependent on fies function C(i)=0. The search problem is to identify the size of the database. An analytic expression is explicitly the state τ. To fulfill Grover algorithm, two types of ele- given for the angles. In Section 7, we review the other im- mentary unitary operations are required in the processing: portant generalization of the Grover algorithm, the quantum 1) the Walsh-Hadamard transformation [13], denoted as W ; amplitude amplification (QAA). Standard Grover algorithm 2) selective inversions of the phase of states. The strategy of uses evenly distributed database. In QAA, the items in the the Grover algorithm is to begin with an evenly distributed database may have different coefficients. In Section 8, we state to perform successive above-mentioned operations so briefly review the newly proposed duality computer and the as to increase sufficiently large probability of obtaining the quantum search algorithm in it. A duality computer exploits marked state. both the particle and wave nature of quantum systems. In The W operator performed on single qubit is represented by the matrix addition to quantum parallelism, it also possesses the duality ⎡ ⎤ parallelism. The duality search algorithm provides a way of 1 ⎢ 11⎥ running classical search algorithms in a quantum computer. H = √ ⎣ ⎦ . (1) In Section 9, we give a brief analysis of misunderstanding 2 1 −1 about the quantum search algorithm. This includes: the H transforms a qubit in |0 state to a superposition state relation between speed of search and the initial amplitude 1 1 √ (|0+|1) and |1 state to a superposition state √ (|0− of the marked state in the database, the relation between the 2 2 search speed and the quantum search engine. In Section 10, |1). In a quantum system of n-qubit, H transformation is we give an error tolerance analysis of quantum search algo- performed on each of the n qubit independently to realize rithms. In Section 11, we briefly review a classical parallel the W transformation. Then the total unitary operation is implementation of the quantum search algorithm. By using denoted as classical parallelism, additional speedup can be obtained at W = H⊗n the expense of more qubit resources. In Section 12, a sum- and the elements of matrix are mary and discussion is given about the experimental imple- −n/2 ¯i·¯j mentations of the quantum search algorithm and other re- Wij =2 (−1) , lated issues. where ¯i and ¯j are the binary representations of i and j re- 中国科技论文在线 http://www.paper.edu.cn 249
spectively, ¯i · ¯j denotes the bitwise inner product of the bit gorithm [11, 12] and its later version [22]. In the first version strings ¯i and ¯j. [11, 12], the D operation was implemented by two Walsh- Specifically, the Grover algorithm has the following pro- Hadamard gates with the operation −I0 whose action is to cedures. inverse the signs of all components except the |0 basis state. D Database construction Initialize√ the√ quantum√ register In its later version, the minus sign in was ignored, and it / N, / N, / N,..., I to√ the evenly distributed state (1 1 1 was implemented by two Walsh-Hadamard and the 0 oper- 1/ N). This superposition state requires O(log N) steps. ator whose action is to inverse the sign of |0 component and The initial state can be written as leaves other amplitudes untouched. In this review article, we adopt the later version. The diffusion transform D can be |ψ W | 1 |i β|τ β|c, 0 = 0 = N =sin +cos (2) i expressed as ⎧ where ⎪ 2 ⎨⎪ ,i= j 1 1 N |c = |i,β=arcsin . (3) Dij = . (4) N − 1 N ⎪ i=τ ⎩ 2 − ,i j N 1 = Finding√ the marked item Perform the following it- eration O( N) times. Then measure the resulting state, D can be further represented in the form D = −I +2P , n n there will be a big probability that the measured result is where I is the 2 × 2 identity matrix and P is the projec- the marked item |τ. Each Grover iteration consists of four tion matrix with Pij =1/N for all i, j. It can be easily found 2 steps: that P = P and P transforms any vector v¯ to a new vector 1) inversion of the marked state; whose components are equal to the average of all compo- 2) the Walsh-Hadamard transformation; nents. Consider what happens when D acts on an arbitrary 3) inversion of all states except the |0 ···state; vector v¯. Operator D can be expressed as −I +2P ,sothe 4) another Walsh-Hadamard transformation. following action can be obtained: These four steps consist of one Grover iteration. The number Dv¯ =(−I +2P )¯v = −v¯ +2P v.¯ (5) of queries used in finding the marked state is used to measure the computational complexity of a search algorithm. The Suppose A is the average of all components of the vector v¯, computational complexity of quantum search algorithm and so each component of the vector P v¯ is A. Therefore, the i-th related algorithms have been studied in Refs. [14–17], we do component of the vector Dv¯ is given by (−v i +2A) which is not review this topic in this review article. It is worth noting precisely the inversion about average. So the effect of Steps that there are two phase inversions in a Grover search iter- 2) – 4) is ation. It is the the relation among these two rotation angles D −WI W W | |−I W |ψψ|−I that have led to the result of phase matching [18–21], which = 0 = (2 0 0 ) =2 (6) will be reviewed shortly. where |ψ is the evenly distributed state. Thus the Grover |τ The inversion of the marked state requires the use of search operator G is writtens the query function C(S). Consider the system in any basis state S,ifC(S)=1, rotate the state phase by π radians; If G = −WI0WIτ =(2|ψψ|−I)(I − 2|ττ|). (7) C(S)=0, leave the state unaltered. This inversion of the Grover algorithm has a simple 2-dimensional visualiza- marked state can be expressed as Iτ = I − 2|ττ|. tion. In the Hilbert spaces spanned by |τ and |c, G operator Steps 2) – 4) together make the inversion about the av- can be written as erage operation, or the diffusion transform D. The diffusion ⎡ ⎤ transform D is not a local transform, which means that it can ⎢ cos 2β sin 2β ⎥ G ⎣ ⎦ . not be implemented by operation on each qubit separately, = (8) − sin 2β cos β like the W . It involves the use of entangling operation gate such as the control-not gate. This step can be implemented as One iteration is a rotation through 2β, thus after j succes- a product of three unitary operations D = −WI0W , where sive iterations, the state vector becomes |ψj =cos[(2j + I0 = I − 2|00| is the π phase rotation of the |0 state 1)β]|c + sin[(2j +1)β]|τ. To get the maximum probabil- and W is the n-qubit Walsh-Hadamard operation. There is a ity, the condition sin[(2j +1)β]=1should be satisfied, the minor difference between the first version of the Grover al- optimal number of iterations is obtained 中国科技论文在线 http://www.paper.edu.cn
250 ⎧ ⎨ Efficient quantum search algorithms do exist for database of jm, if jm is an integer; j op = ⎩ the form [25], INT[jm]+1, if jm is not an integer, |ψ θ |τ θ eiδ|c, (9) 0 =sin 0 +cos 0 (11) π 1 where sin θ0 is the amplitude of the marked state in the where jm = − and INT[·] means taking the integer 4β 2 √ database, and δ is the initial phase of the database. Of course, j ≈ π N/ part. It is clear that op 4. one may also write a phase factor δτ in the |τ term to form j P iδ iδ The number op determines max, the maximum proba- the database, sin θ0e τ |τ +cosθ0e c |c. However, we can j β bility of obtaining the marked state. Note that (2 op +1) treat it as a global phase, and subtract it from δc and using π/ may not be exactly 2, the maximum probability is usually δ = δc − δτ in Eq. (11) instead. not 100%. There is also the over-cooking and under-cooking A quantum search engine is a searching operator. In the problem associated with the Grover algorithm. When one standard Grover algorithm, the search engine is given in Eq. j measures at an iteration time greater than op, the probabil- (7) or (8). In a QAA [22–24], the search engine is ity becomes less than Pmax. This is quite similar to the over- G −UI U −1I . cooking in boiling rice. When one measures at an iteration = γ τ (12) number less than jop, the probability of finding the marked In the quantum search algorithm with non-π phases [18, 21, state is also less than Pmax. This is the under-cooking prob- 28], the search engine is lem. −1 G = −UR0U Rτ , (13) where R I − − eiθ | |, |ψ 0 = (1 ) 0 0 It is interesting to note that the initial state is 0 = (14) W | ··· G iφ 0 , and the Grover search operator is = Rτ = I − (1 − e )|ττ|, −WI0WIτ . One important generalization of the Grover are the phase rotations of the |0 state through θ and the |τ algorithm is the quantum amplitude amplification [22–24]. through φ respectively. In QAA the initial state is U|γ and the search operator −1 The query function, or the oracle is the most intriguing as −UIγ U Iτ . Many authors consider wrongly that the part of a quantum search algorithm. It can be understood database and the search operator are related in only such a in two ways. First, like in the theoretical study of quantum way, namely the unitary operation to transform |0 to the search algorithm, the query is treated as a blackbox. Namely initial state and the unitary operation in the search operator someone has already known the marked state, and he/she are the same. This misconception leads to some wrong con- prepared a blackbox containing this information and gave clusions about the search speed with respect to the marked the blackbox to someone else and let him to find the marked state component in the initial state. For this purpose, Long state. Such a contesting game view is both easy to under- et al separated the quantum search algorithm into explicitly stand and good for theoretical study. the search engine and the database [25]. The second way is closer to practical application, and the A quantum database is the initial state where a quantum query function is a computable function. For instance in the search algorithm starts searching. In the standard Grover satisfiability problem in which the existence of solution to a algorithm, it is the evenly distributed superposition state in logic expression is sought, the query function is just the logic Eq. (2). Of course it can be prepared by applying the Walsh- expression. For instance, for a Boolean expression with four Hadamard gate on the |0 state. It should be emphasized variables x1, x2, x3 and x4, one needs to find the solution to that the database is not necessarily this form in general. For the logic expression instance, it can be written as an arbitrary superposition of the basis states in a form, x1x3 + x2x4 =1, (15)
|ψ0 = a0|0 + a1|1 + ···+ ai|i + ···, (10) the query function can be constructed by the quantum cir- where the coefficient of each basis state is arbitrary. It should cuit shown in Fig.1. Qubits 1-4 are the working qubits, be pointed out that searching in such a database is usually not and qubits 5 and 6 hold the values of x1x3 and x2x4 re- very efficient. Biron et al. have studied the search process in spectively. Qubit 7 gives the value of the logic expression such database using the standard Grover search engine [26]. x1x3 + x2x4. Then using qubit 7 as a control, and another 中国科技论文在线 http://www.paper.edu.cn
251