Jun 24, 2014 - the phone number x in the phone book, then the phone book is used as an .... gate) allowing us to run Grover's algorithm to search either for a ...
Two Notes on Grover’s Search: Programming and Discriminating Daniel Reitzner1,2 and M´ario Ziman1,3 1
Institute of Physics, Slovak Academy of Sciences, D´ ubravsk´ a cesta 9, 845 11 Bratislava, Slovakia 2 Department of Physics, Hunter College of CUNY, 695 Park Avenue, New York, New York 10021, USA 3 Faculty of Informatics, Masaryk University, Botanick´ a 68a, 60210 Brno, Czech Republic
In this work we address two questions concerning Grover’s algorithm. In the first we give an answer to the question how to employ Grover’s algorithm for actual search over database. We introduce a quantum model of an unordered phone book (quantum database) with programmable queries to search in the phone book either for a number, or for a name. In the second part we investigate how successful the algorithm can be if the number of elements of the database is not known precisely. This question reduces to analysis of the distinguishability of states occurring during Grover’s algorithm. We found that using unambiguous discrimination scheme even a seemingly good guess, that is close to the optimal one can result in a rather small success rate.
arXiv:1406.6391v1 [quant-ph] 24 Jun 2014
I.
INTRODUCTION
Grover’s algorithm [1] is a typical example demonstrating the power of quantum computation. It is designed to search within an unstructured database of alternatives. Although it is used in many different applications and algorithms of quantum information theory (see e.g. [2]), we have yet to succeed to find any explicit example how to use it to search over an actual (quantum) database. In the first part of the paper we will discuss how to design a (quantum) phone book and employ Grover’s algorithm to search within either for a name, or for a number. In the second part we will investigate how successful the algorithm can be if the number of elements of the database is not known (precisely). This question is posed as the analysis of the distinguishability of states occurring during Grover’s algorithm. Grover’s algorithm proves to be quadratically faster than any (classical) algorithm performing the task and it was proven to be optimal [3] — there is no quantum (and no classical) algorithm that would do the task faster. The speedup in the algorithm is in the number of oracle calls, i.e. evaluations of functions ( 1, if y matches x, fx (y) = (1) 0 otherwise. This function evaluates, whether element x has property y (a specific example is Kronecker’s delta which evaluates whether x = y). A set of these indexed functions {fx }x can be represented by the set of paired elements (x, y) which define the database D of N = |D| elements. In this setting the database search is conveniently posed as a discrimination among the oracles implementing the functions fx . For its simplicity we will switch now to the phone book analogy. If we are given the task of finding the owner y of the phone number x in the phone book, then the phone book is used as an oracle in the following sense fx (y) = Compare{x, Phonebook(y)} ,
(2)
where the function Phonebook(y) returns the phone number of owner y and the function Compare(x, x0 ) ≡ fx (x0 ) compares the phone numbers x and x0 , returning 1 if and only if they match. The database search then consists of the identification of the oracle’s input y returning the value 1. For the unstructured database (which we can interpret as a search for the owner of a given phone number in the phone book) each y is equally likely the correct one, i.e. the probability of (x, y) ∈ D has the same probability for all y’s — if this would not be the case, this prior information would help us search faster in the database. Therefore, in the classical case the optimal average number of oracle queries identifying the particular oracle function is N/2. At this point the phone book is (typically) alphabetically ordered, thus, the Eq. (2) represents an efficient implementation of the oracle function. However, the efficiency of the oracle design is not of interest in the query complexity framework. It is assumed to be “expensive” in a sense that it requires a lot of resources — either energy, or time to return result that is independent of implementation. This being constant justifies the necessity to count only the number of the times the oracle is used and the complexity of the algorithm is calculated in the number of oracle calls. The quantum √ algorithm discovered by Grover identifies the oracle in O( N ) calls, hence, the ability to discriminate quantum implementations of different oracle functions requires quadratically smaller number of queries than in the classical case. Without loss of generality we may assume that both x and y are indexed from 0 to N − 1, and choose D = {(x, x) : x = 0, . . . , N − 1}. The quantum oracle is a quantum analogue of the function (1). In the quantum gate formalism it is implemented as a gate Rx = I − 2|xihx|,
(3)
with states |xi forming an orthonormal computational basis of the N -dimensional Hilbert space HN . This quantum oracle is a special case of a standardly used oracle Vx |yi ⊗ |ki = |yi ⊗ |k ⊕ fx (y)i,
2 where k = 0, 1, thus Vx acts on the Hilbert space HN ⊗ H2 . Initializing the qubit register in the state |−i = √ (|0i−|1i)/ 2 ∈ H2 we obtain Vx |yi⊗|−i = (Rx |yi)⊗|−i. From the construction of Rx in Eq. (3) follows, that for |yi being an element of the chosen computational basis the states |yi ⊗ |−i are eigenvectors of Vx with eigenvalue either one or minus one (if y is the searched for element). Each call of the oracle from Eq. (3) is in the algorithm followed by a unitary operation G called inversion about average which acts as
of all the names (persons) in database and D2 the set of all the numbers. Let us stress that both the names and the numbers can be repeated and only pairs of them are unique. Let us denote by Kn the subset of people having the same phone number n and by KA the subset of phone numbers belonging to the person A. Then X RKn = I − 2 |AihA| ; A∈Kn
RKA = I − 2
G = 2|yihy| − I,
X
|nihn| ,
n∈KA
P where |yi = √1N y |yi denotes the equal superposition of all computational basis states. After m repetitive calls of the unitary evolution Ux = DRx the initial query state |ψ0 i = |yi evolves into (2m + 1)ω (2m + 1)ω |xi + cos |y x i, (4) 2 2 P where cos ω = (N −2)/N and |y x i = √N1−1 y6=x |yi. We shall call the states |ψm i Grover’s states. Clearly, if the condition (2m + 1)ω = π is met, then |ψm i = |xi, hence, the search algorithm succeeds — we will mark this (in general non-integer) “number of steps” with m0 . Strictly speaking, this is possible only for N = 4, when a single step is needed. In all other cases the condition can never be exactly reached (for an integer), however, for large N this does not cause any problems, as the probability |ψm i = sin
PG = sin2 (2m + 1)
ω 2
will still be sufficiently close to √the unity. The optimal number of steps scales as O( N ) and it was shown [3] that Grover’s algorithm is optimal in sense, that it reaches the boundary on the number of steps needed to find targeted element x. For more details on Grover’s algorithm we refer to any quantum computation textbook, for instance [4]. This paper contains two results on Grover’s oracles. In Sec. II we look closer at the implementation of the oracle and uncover a symmetry within the “quantum database”. In Sec. III we evaluate the quantum search algorithm with unknown size of the database, which reduces to the discrimination of quantum states appearing during the Grover search algorithm. II.
PROGRAMMABLE SEARCH QUANTUM DATABASE
Let us again switch back to the phone book analogy where Grover’s algorithm searches over now completely unstructured phone book. Not only the numbers of owners are disordered, but now, for the sake of the argument, let also the owners be stored randomly in the phone book. Such database D consists of N pairs (n, A); n will represent phone number and A its owner, D1 will be the set
are Grover’s oracles for searching over the names and the numbers, respectively. We now make the key observation for the rest of this section. It is straightforward to verify that the following identity holds X X RKA ⊗ |AihA| ≡ R . (5) |nihn| ⊗ RKn = n∈D1
A∈D2
Therefore, the unitary gate X R=I ⊗I −2
|nihn| ⊗ |AihA| ,
(n,A)∈D
can be understood as the quantum database (oracle) encoding the unstructured phone book. Now we will show how Grover’s algorithm can be employed to search over such unstructured phone book. We introduce a programmable quantum query gate (PQQ gate) allowing us to run Grover’s algorithm to search either for a name, or for a phone number in a programmable fashion, i.e. the query is represented by the choice of the input state of the device and is completely independent of the PQQ gate containing the information stored in quantum database R. The PQQ gate is illustrated in Fig. 1 and is defined by the following equation PQQ = S0 ⊗ (I ⊗ Gname )R + S1 ⊗ (Gnum ⊗ I)R ,
(6)
where Gname = 2|AihA| − I, Gnum = 2|nihn| − I are the inversions over the respective averages, and Sj = |jihj| is a classical (can be made also quantum) switch determining whether the name, or the number is going to be searched for, respectively. Neither the switch, nor the quantum database R depend on the particular value of the database query. The quantum query (program) |1i ⊗ |ni ⊗ |Ai programs PQQ gate to run Grover’s search algorithm to identify the phone number matching the name A. Similarly, the query |0i ⊗ |ni ⊗ |Ai implements Grover’s search algorithm to identify the name matching the phone number n. In this way we showed, that the programmable oracle, due to the symmetry (5) provides not only a way how to search for the owner of a phone number, but also the other direction — how to search for the phone number of some owner. Both these searches can be made in time
3 √ O( N ) and, recalling that the database R is unstructured in both items, it provides a quadratic speedup in both cases. Moreover, the construction can be expanded by an additional type of information, e.g. mailing address or email, but the overall structure remains the same. Suppose we have k possible query tasks. The database D consists of N distinct k-tuples x := (x0 , x1 , . . . , xk−1 ), the oracle (storing the database) is given as X R = I ⊗k − |xihx|,
a)
x∈D
where |xi = |x0 i ⊗ |x1 i ⊗ · · · ⊗ |xk−1 i. The PQQ gate is then integer-parametrized X PQQ = Sj ⊗ (I ⊗(j−1) ⊗ Gj ⊗ I ⊗(k−j) )R (7) j
b)
when performing task j (knowing all other information but j th ); Gj is the corresponding inversion about average on register j, Gj = 2|¯ yj ih¯ yj | − I. Higher degree of free parameters allows also a wider variety of problems than the one mentioned above which just serves to fill in the information j while the rest is known. In general we can be given a smaller subset of parameters characterizing the element we want to find in the database (e.g. knowing the phone number and email, we might want to find the name and address of the owner). This general case does not differ much from the previously discussed cases. The initial state is prepared as the equal superposition over the basis states of all unknown subspaces and as a given choice on the subspaces where the information about the searched element is known. The PQQ is then similar to Eq. (7) with j indexing the possible types of searches we might want to perform — the corresponding term in Eq. (7) for given j will be then Sj tensored with operator having identity operator I on all the positions the information is known and respective G on all the positions the information is unknown to us. Using the oracle point of view the construction and/or performance of the quantum database R is not an issue, however, from application point of view this question (especially the performance) is of high relevance. Here we have addresed only one implementation problem: the actual design of quantum database. The questions related to writing, or deleteing entries from database we left untouched. III.
GROVER’S SEARCH WITH UNKNOWN SIZE OF THE DATABASE.
The size of the Hilbert space we search for might be unknown, or not known precisely. It is generally a difficult problem to decide what the size of the Hilbert space is, especially when it might be rather large [5, 6]. Having Grover’s states as resources and being able to choose only
FIG. 1: The programmable quantum query gate performing one step of the Grover’s algorithm over the phone book, when searching a) for the name belonging to the number |ni or b) for the number belonging to the name |Ai. Operation R is independent on the type of query and can be considered to be quantum database, while operation S is controlled inversion about average depending on the task performed — 0 triggers inversion on the name space, while 1 triggers inversion on the number space.
the number of steps m after which Grover’s algorithm stops we might therefore not know how close we are to the optimal number of steps and we want to know how reliable our results will be. This question can be recast as a discrimination of quantum states produced by Grover’s oracles after m uses, hence, the question is how distinguishable the states from Eq. (4) are. We will investigate two extreme variations of the problem: the minimumerror discrimination optimizing the average success rate of our conclusions and the unambiguous discrimination allowing for error-free conclusions while tolerating inconclusive outcomes. Our goal is to find a final measurement optimizing the associated success rates while keeping the rest of Grover’s algorithm unchanged. Let us stress this problem is different from discrimination of Grover’s oracles, where one is allowed to design also the test state and to employ ancillary systems and devices in order to optimize the success rates. In Ref. [7] some results on unambiguous discrimination of Grover oracles are given, stating that the unambiguous discrimination of Grover’s oracles is always possible. The exact protocols achieving perfect (errorfree) discrimination of Grover’s oracles were investigated in [8], where it was shown that in order to√achieve such goal the number of queries scales as N − N with the size of the database. It achieves better scaling than any classical algorithm requiring at least N − 1 oracle calls. However, the quadratic speed-up is in this case lost. As
4 far as we know, the oracle discrimination problem is still open. Grover’s algorithm provides [9] an asymptotic solution to minimum-error case quantifying the number of queries needed for vanishingly small error. A.
Symmetry of Grover’s oracles
Before we proceed let us note that Grover’s oracles Uxm respect the following symmetry m T Ux−1 T†
=
Uxm
,
where T =
X
|(x + 1)modN ihx|
(8)
P Let us denoty by |γi = √1N a |γa i = |0i and by P |γ 0 i = √N1−1 a6=0 |γa i. Then a single step of Grover’s algorithm can be expressed as 4 U0 = 2|γ0 ihγ0 | + 2|γihγ| − I − √ |γihγ| N √ 2 2 N −1 = (I0 − I) + (1 − )I0 − i Y0 , (10) N N where I0 , Y0 are Pauli operators defined on twodimensional subspace H0 spanned by the vectors |γ0 i, |γ 0 i, thus, I0 = |γ0 ihγ0 | + |γ 0 ihγ 0 |, Y0 = −i|γ0 ihγ 0 | + i|γ 0 ihγ0 |, and I − I0 is the projector onto the orthogonal subspace H0⊥ . As in the original Grover’s algorithm we define the angle ω via the identity cos ω = 1−2/N . Then
x
is the shift operator with T N = I. The eigenvalues of T are λa = exp(i2πa/N ) for a = 0, . . . , N − 1 and corresponding eigenvectors are N −1 1 X −i 2πay |γa i = √ e N |yi. N y=0
This symmetry feature has a favorable mathematical consequence. If we take the initial state of equal superposition |ψ0 i, which is invariant under the action of T , i.e. T |ψ0 i = |ψ0 i, then the output states |ψx (m)i = Uxm |ψ0 i will respect the same symmetry as the unitary matrices Uxm . In this way, for each step m the Grover states |ψx (m)i = Uxm |ψ0 i form a family of symmetric states satisfying the relation |ψx (m)i = T x |ψ0 (m)i, m where |ψ0 (m)i = Ux=0 |ψ0 i. This reduces our discrimination problems to discrimination of symmetric states {|ψx (m)i}x being the set of potential output states after m steps of Grover’s algorithm. B.
Unambiguous discrimination
Let us start with the case of unambiguous discrimination [10]. In this case, the conclusions made are certain, hence, the algorithm is exact although it requires an inconclusive result. In Ref. [11] a theory of unambiguous discrimination of (pure) symmetric states is described. In particular, if we are given a set of N pure symmetric states |φx i = T x |φ0 i for some unitary operator T (such that T N = I), then using the result of Ref. [11] we can evaluate the upper bound on probability of success in unambiguous discrimination as Psuc ≤ N min |hγa |φ0 i|2 , a
(9)
where |φ0 i is the test state and |γa i are the eigenvectors of T . In our case T is given by Eq. (8) and we are to discriminate the states {T x |ψ0 (m)i}x given |φ0 (m)i = U0m |γ0 i. We find Psuc (m) ≤ N min |hγa |U0m |γ0 i|2 ≡ Γ0 (m) . a
U0m = (I0 − I) + e−imωY0 . Using the above form of U0m we find | sin ωm| Γ0 (m) = min | cos ωm|, √ . N −1
(11)
The minimized elements of this function (which is the upper bound on the success probability for unambiguous discrimination) is plotted in Fig. 2 (upper plot). Since | cos mω| and | sin mω| have exactly opposite monotonicity, it follows that the maximal value (with respect to m) is achieved √ when they coincide, i.e. when | cos mω| = | sin mω|/ N − 1. This condition gives us two solutions m0 and m0 +1 when the perfect discrimination is possible as the Grover’s states become orthogonal. Also it is not surprising that (in the limit of N → ∞) the success probability approaches 1 for the number of calls coinciding with the number of calls needed in Grover’s search. Indeed, at this point different oracles lead to mutually orthogonal quantum states. Relating to the question we answer in this paper, knowing the length of the database (the size of the Hilbert space) only approximately, an interesting observation is at hand. If our chosen number of steps m will be the closest integer larger than the optimal number m0 (we recall, that m0 is integer only for N = 4) but smaller than m0 + 1 the unambiguous discrimination scheme can fail as the minimal term in Eq. (11) will be the cosine term going to zero. If ωm is close to π/2 — this happens when m = m0 + 1/2 — by Eq. (11) the success probability will be bounded from above by 0 and the search will be unsuccessful as Grover’s states in this case are linearly dependent. This can however exactly happen only for N = 2 but one can get very close to this point for large N as well and the success probability can be very small, as after m0 it drops fast towards zero — see the lower plot of Fig. 2. C.
Minimum-error discrimination
In the case of minimum-error discrimination the results from Ref. [12] provide necessary and sufficient con-
5 would be orthogonal and the minimum-error discrimination coincides with the unambiguous discrimination. For choice of m smaller than m0 +1/2 the success probability copies that of the usual Grover’s search, and for m larger it becomes slightly advantageous. If the choice of m falls in the region [m0 , m0 + 1], in contrast to the unambiguous discrimination scheme where the probability drops towards zero, we do not have any considerable drop in probability showing that minimum-error discrimination is in this sense superior to the unambiguous discrimination scheme. Furthermore, considering only integer m, none of the discrimination schemes can be perfect.
IV.
FIG. 2: Illustration (with exaggerated differences — small size of database with N = 100) of the bound on success probability for discrimination of Grover’s oracles. The upper plot depicts the terms in Γ0 over which we minimize, while the lower plot shows the success probabilities for the different discrimination schemes — unambiguous discrimination (dashed line) has a dip between optimal number of steps m0 and m0 +1 that can lead to unsuccessful discrimination. The minimumerror discrimination (solid line) does not suffer this problem and up to the point m0 copies the usual Grover’s success probability.
ditions for discriminating states, while in Ref. [13] specific results on the discrimination of states are provided. Minimum-error discrimination of pure symmetric states was addressed in Ref. [14], where the optimal success probability PM was shown to be PM = |hψ0 (m)|Ω−1/2 |ψ0 (m)i|2
(12)
with Ω=
X
|ψx (m)ihψx (m)|
x∈[N ]
= N cos2 mω|yihy| +
N sin2 mω(I − |yihy|). N −1
Since |hψ0 (m)|yi|2 = cos2 mω, from Eq. (12) we find 2 r 1 N −1 PM = √ cos mω + sin mω . N N From this equation we obtain (see also Fig. 2) ( sin2 (2m + 1)ω/2, for m ≤ m0 + 1/2, PM = sin2 (2m − 1)ω/2, for m ≥ m0 + 1/2. Again we may notice perfect discrimination (PM = 1) not only at m = m0 but also at m = m0 + 1 when the states
CONCLUSION
We have introduced the concept of programmable search database (see Fig. 1) employing (in a programmable way) Grover’s oracles to search over an unstructured databases (like phone book). It enables us to choose query (either name, or phone number) and search for its complement (phone number, or name, respectively) from the unstructured database. Because of the symmetry of the programmable search database for any query the complexity is the same as for Grover’s algorithm but offers a lot of flexibility. Moreover, this construction works also for higher degree of searchable items (like mailing address, email, etc.). We believe this note clarifies how the Grover algorithm might actually be used for searching a quantum database, especially with more degrees of freedom within which one might want to search. Although we have not addressed the question of how the database would be physically constructed, this note provides an outlook on what one should consider — the symmetry of the oracle, if implemented, would make the search more universal. In the second note we have discussed the performance of Grover’s search algorithm when the size of the database is unknown, but the resources (probe state and oracles) are available at user’s disposal. We have found that the measurement point has to be chosen carefully (even if the guess is almost precise), as in a small range between the points of perfect discrimination, the success probability can drop significantly (see Fig. 2). This feature holds for unambiguous approach and therefore minimum error might be favored more if the size of the database is not known exactly. Minimum-error discrimination seems to be more practicable as it not only overcomes the pit near m0 + 1/2 but it also works in the presence of small errors. Moreover, it might be applied more easily, as the bound for unambiguous discrimination can be hard to reach. Finally, as for the number of steps smaller than m0 it copies the usual success probability for Grover’s search we see, that the measurement in the computational basis performs the minimum error discrimination. The unambiguous discrimination, although very interesting from the theoretical point of view, is to large extent impractical.
6 The two presented notes cover only a small set of directions of interest where only partial results are known. For example we still do not know what an actual realization might look like — quite possibly it will be a subroutine in a larger algorithmic application [2]. Other interesting directions to pursue are geometric analysis of Grover’s search [15] or quantum searches under decoherence [16, 17].
[1] L.K. Grover, Quantum mechanics helps in searching for a needle in a haystack, Phys. Rev. Lett. 79, 325 (1997). [2] A. Ambainis, Quantum walk algorithm for element distinctness, SIAM Journal on Computing 37, 210–239 (2007). [3] C.H. Bennett, E. Bernstein, C. Brassard, and U. Vazirani, Strength and weakness of quantum computing, SIAM J. Comput. 26, 1510 (1997). [4] M.A. Nielsen and I.L. Chuang, Quantum Computation and Quantum Information, (Cambridge University Press, 2000). [5] N. Brunner, S. Pironio, A. Acin, N. Gisin, A.A. M´ethot, and V. Scarani, Testing the Dimension of Hilbert Spaces, Phys. Rev. Lett. 100, 210503 (2008). [6] M.M. Wolf and D. Perez-Garcia, Assessing Quantum Dimensionality from Observable Dynamics, Phys. Rev. Lett. 102, 190504 (2009). [7] A. Chefles, A. Kitagawa, M. Takeoka, M. Sasaki, and J. Twamley, Unambiguous discrimination among oracle operators, J. Phys. A 40, 10183 (2007). [8] X. Wu and R. Duan, Exact quantum search by parallel unitary discrimination schemes, Phys. Rev. A 78, 012303 (2008). [9] C. Zalka, Grovers quantum searching algorithm is optimal, Phys. Rev. A 60, 2746 (1999).
Acknowledgment
This work was supported by projects APVV-080812 (QIMABOS) and COST Action MP1006. M.Z. acˇ project knowledges the support of RAQUEL and GACR P202/12/1142. D.R. acknowledges the support of Fulbright Visiting Scholar Program.
[10] M. Sedl´ ak, Quantum theory of unambiguous measurements, Acta Physica Slovaca 59, 653 (2009). [11] A. Chefles and S.M. Barnett, Optimum unambiguous discrimination between linearly independent symmetric states, Phys. Lett. A 250, 223 (1998). [12] A.S. Holevo, Statistical decision theory for quantum systems, Journal of Multivariate Analysis 3, 337 (1973). [13] S.M. Barnett and S. Croke, On the conditions for discrimination between quantum states with minimum error, J. Phys. A 42, 062001 (2009). [14] M. Ban, K. Kurokawa, R. Momose, and O. Hirota, Optimum measurements for discrimination among symmetric quantum states and parameter estimation, International Journal of Theoretical Physics 36, 1269 (1997). [15] C. Cafaro and S. Mancini, On Grovers search algorithm from a quantum information geometry viewpoint, Physica A 391, 1610–1625 (2012). [16] N. Shenvi, K.R. Brown, K.B. Whaley, Effects of a random noisy oracle on search algorithm complexity, Phys. Rev. A 68, 052313 (2003). [17] O. Regev, L. Schiff, Impossibility of a Quantum SpeedUp with a Faulty Oracle, Proc. of the 35th International colloquium on Automata, Languages and Programming 1, 773 (2008).