Grover'ın algoritması: liste nerede?


15

Grover'ın algoritması, diğer şeylerin yanı sıra, sıralanmamış bir öğe listesinde [ x 0 , x 1 , y öğesini aramak için kullanılır . . . , x n - 1 ] uzunluk n . Burada bu konuyla ilgili birçok soru olmasına rağmen , konuyu hala özlüyorum.[x0,x1,...,xn1]n

Bir listede arama, klasik yol

Normal olarak, bu şekilde bir arama fonksiyonu tasarlamak

search([x0,x1,...,xn1],y)=iNsuch that xi=y
Böylece listeyi ve istenen öğeyi girdi olarak veriyorum ve listedeki öğenin konumunu çıktı olarak alıyorum. I ile ilgili bilgiler anlaşılmalıdır düşünüyorumy Oracle kapısı yoluyla algoritma gömülüdürO eden fonksiyonu olur, böylece
searchy([x1,x2,...,xn])=iNsuch that xi=y
Pratik bir örnek yapalım. Standart bir 52-kart destesinden8 kartlık bir sıra halinde1 nın asını aramayı düşünün:

karıştırılmış güverte

8[x0=J, x1=10, x2=4, x3=Q, x4=3, x5=1, x6=6, x7=6].

The wanted element is x5. I should obtain search(cards)=5. Each card can be encoded with log252=6bits, the list has 8 elements so we need 6×8=48 bits to encode the list. In this case, the oracle O will implement the function:

f(x)={1,x=10,otherwise

However, the input of Grover's algorithm is not a state of 48qubits.

(NB: Image of shuffled deck is taken from here)

Grover and its oracle

Several sources (eg. here - graphically explained) say that the input of the algorithm is different: the input is a state taken from the search space S={0,1,2,...,N}={0,1,2,...,7} where N is the number of elements of the list. Each number corresponds to the position of an element in the list.

The input of search() is now a log28=3qubit vector |ψ, which must be a superposition of all the items in the search space S.

We know

  • |03qubits=|000 corresponds to J;
  • |13qubits=|001 corresponds to 10;
  • |23qubits=|010 corresponds to 4;
  • |53qubits=|101 corresponds to 1 which is the wanted element;
  • and so on...

In this case we have

search(|ψ)=|53qubits
But in this case, our oracle would have to implement the function
f(|ψ)={1,|ψ=|53qubits0,otherwise

Building the oracle requires us to know that is at position 5. What's the point to execute the algorithm if we have already searched for the element in order to build the oracle?


I also have difficulty understanding the advantage of Grover’s algorithm. Suppose that I have N items in the list. At each call to the Oracle, did it evaluate all N possibilities? Even if the evaluation is very fast but if we still need to iterate over all configurations, then the complexity of Oracle evaluation is O(N). So the Grover’s algorithm doesn’t seem to be faster than dumb search. Is this correct?
Sanparith Marukatat

@SanparithMarukatat It's not correct. The items of your list are the terms of the superposition of the state involved in the search. When the Oracle operates on this state, it counts as a single operation. The ability of the Oracle to mark the searched-for term of your superposition is a fundamental part of Grover's insight. To understand Grover's algorithm, I recommend you first understand how this marking off of the desired state happens. Afterwards, make sure to understand the role of the state | in the Oracle.
R. Chopin

If you understand that, then you should study the operator that is able to increase the amplitude of the desired term in the superposition while at the same time decreasing the amplitude of the undesired terms of the superposition. To me the easiest way to approach Grover's is to look at the inverse-about-mean operator. (Some people take the geometric view, but I don't find it as clear.)
R. Chopin

Yanıtlar:


10

If you have 8 items in the list (like in your card's example), then the input of the oracle is 3 (qu)bits. Number of cards in the deck (52) is irrelevant, you need 3 bits only to encode 8 cards.

You can think that 3 bits encode the position in the list of the card you are searching; then you don't know the position, but the oracle knows. So if you are searching the ace of spades, then the oracle knows that the ace of spades is the 6th card (or 5th counting from zero) and implements the function

f(x)={1,if x = 5, or binary '101'0,otherwise

PS: It is better to think about the Grover's algorithm differently: you have an oracle implementing a boolean function which outputs 1 for a single combination of input bits, otherwise outputs zero, and your task is to find the combination. The problem has the same complexity as searching in an unsorted list or database, that is why the Grover's algorithm is usually described as searching in an unsorted database. But applying the algorithm to a real-world database search indeed raises questions that are beyond the algorithm itself. Grover's algorithm is just searching for what the oracle knows.


Yes sorry, that 6 was from a previous edit
incud

2
Thank you for your answer. I fixed the miswriting. What's the point of executing the algorithm if in order to build the oracle I need to know the position of the searched element?
incud

1
@incud Indeed it does not make sense. I've updated the answer.
kludg

"Grover's algorithm is just searching for what the oracle knows": not necessarily. The oracle may be checking for only some specific property of the input, so that the result one gets at the end contains more information than that encoded in the oracle itsef. A typical example is searching in a phone book. The oracle "asks" for a record attached to a specific name, but once the correct record is found, one also gains the additional information of the phone number attached to that record, which was not encoded at all in the oracle
glS

4

While it is perhaps easiest for us to think about the function of the oracle as already having computed all these values, that's not what it's doing. In the case you described, the oracle has 8 possible inputs (i.e. encoded in 3 (qu)bits), and the oracle does all the computation that you need on the fly. So, the moment you try to evaluate the oracle for some value x, the oracle looks up (in this instance) the card that the value of x corresponds to, and then checks if that card is the marked card. The idea being that each time you call the oracle, it goes through that process once. Overall, you evaluate the function a number of times that's equal to the number of times you call the oracle. The aim of any search algorithm is to call that oracle as few times as possible.

In case this sounds a little circular (given an input x, find which card that corresponds to), remember that your look-up table for what x corresponds to what card can be ordered which is a different, simpler, much faster search question.

The key differences in your example compared to a more realistic usage scenario are:

  • The search space is usually massive. There's no realistic prospect of precomputing all values. Indeed, that is exactly what we're trying to avoid.

  • Usually, we don't actually say 'find the ace of spades'. Instead, there's an f(x) that is non-trivial to evaluate to test if x is the 'marked' item or not. The fact that the oracle can take quite a long time to evaluate, even for a single entry, is what makes the oracle the costly part to implement (and all other gates are given for free) and why you need to minimise the number of calls.

So, really, the way a classical search would work on your problem is: pick an x at random. Evaluate y=f(x). If y=1, return x, otherwise repeat. While the net effect of f(x) is 'is the input x0, the marked entry?', that is not the actual calculation that it does.


2

The question is ultimately: "What's the point to execute the algorithm if we have already searched for the element in order to build the oracle?"

Whilst somebody prebuilt the oracle, it may not have been the person using the oracle.

Grover's algorithm requires the oracle be queried no more times than size of list. Naturally we cannot hope respective database lookups, as proposed earlier against which I cannot comment for lack of reputation, on say 5 million keys will return the content we want if our content is not addressed by any of those 5 million keys, but by saying the 9 millionth key, which happens not to be in our sample. How does Grover's algorithm do it then?

We ask the oracle: what is the answer it already has for the question it already has? Even Mateus and Omar would ask the "oracle-for-a-particular-alphabet-symbol" during runtime, what are the position(s) of its symbol in the string that it has already compiled? The oracle will give the answer to our query after only one consultation, but in this story, it cannot for example simply write out the answer as a binary string and send it to us over a classical communication channel. It will hide its answer in a superposition for us to draw it out.

I let fancy or metaphor run away in this next bit: we don't quite hear the answer the first time, and we have to ask the oracle to repeat the same answer over and over again until we are sure what the oracle has said, except we start to hallucinate from misinformation in the diffusion process if we ask too many times.


2

Given the oracle you have provided, the search is indeed pointless. However, that oracle misses the point of Grover's algorithm because searching for a card in a deck of cards is not an unstructured search because, as you stated, you already know the order. Ergo, your search is structured. The reason this oracle is used is that it demonstrates how Grover's may be applied without having to discuss an oracle that would make Grover's useful because such an oracle would be more complicated than valuable. Therefore, a better oracle to demonstrate the usefulness of Grover's might be something like:

f(x)={1,x[0,,3]+x[4,,7]=10100,otherwise

What this oracle implies is that you have an 8-qubit search where you take the first four qubits and add them to the second four qubits and flip M if the addition makes 10 (1010 in binary). The difference between this oracle and the one you provided is that this oracle tests a pattern (do the operands add to 10) whereas yours tests equality (is this index 5). This oracle is much more difficult to build but it leverages the true power of Grover's, which is, in essence, a brute-force search where your oracle defines the search space.

Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.