Grover's algorithm, also known as the quantum search algorithm, solves the unstructured search problem while also providing quadratic speedup.
The problem statement is as follows: given , and a function which outputs 0 for all but one input value, find the value for which . A classical computer could solve this problem with a time complexity of , as it needs to evaluate the function times on average. However, as we will see in the following paragraphs, Grover's algorithm provides quadratic speedup, effectively succeeding in finding with a time complexity of .
The quantum circuit that implements Grover's algorithm is shown below.
The quantum circuit is made up of qubits which initially are all in state . Let us define as the state of the quantum system after we apply the gate on each qubit.
We will hereafter denote by the superposition of all bitstrings of length . Let us not introduce . We can rewrite as
where [1].
Next, we apply the oracle. This oracle, also called a subrouting, is defined as . Hence, we obtain
The next step of the algorithm is the application of a diffuser . Using trigonometric identities, we obtain
After applying the successive and instructions, we reach
Let us apply these two gates times. After iterations, we obtain
After iterations, the probability to measure is
Supposing that is considerably larger than 1, the probability can be approximated as . When (i.e., ), the probability approaches 1. Hence, in order to obtain an answer with a high confidence, we must iterate over the and instructions times. This is what actually makes Grover's algorithm have a time complexity of : we evaluate the function approximately times using the oracle.
It has already been proven that Grover's algorithm's quadratic speedup is optimal for the unstructured search problem. This means that we cannot solve the problem in polynomial time or faster, even on a quantum computer. However, the time complexity of Grover's algorithm, which is , is still much better than the exponential time complexity of for a considerably large value of .
The SAT (i.e., boolean satisfiability) problem can be solved using this algorithm. Let us consider the following SAT instance [2], and implement it in KetBy.
By employing ancilla qubits, we can implement Grover's algorithm for as shown in the figure below.
As we can see, we use two ancilla qubits to implement the oracle . The second ancilla qubit is initially in state and we apply a gate on it. We use gates to compute the conjunctions between the literals, effectively mapping to . We also undo the first gate (i.e., uncompute the first ancilla qubit). Finally, we apply the diffuser .
You can find a implementation of this circuit with and iterations here.
According to the previous introduction, is defined as . In our case, , hence . After iterations over the oracle and the diffuser, the probability to measure , where is the bitstring that encodes the solution to the SAT problem, is . When running a simulation of the circuit with iterations of and , we measure (where is the solution to the problem) in of the cases, as shown below.
Let us now perform two iterations over and . In this case, the probability of success is . Again, the results of the simulation correlate with the mathematically expected results, as we measure the state in of the cases.
References
[1]
B. Vermersch, Lecture notes on "Quantum algorithms", Université Grenoble Alpes 2023, URL: https://bvermersch.github.io[2]
B. Siegelwax, Grover's Algorithm, an Intuitive Look, Quantum Zeitgeist 2021, URL: https://quantumzeitgeist.com/grovers-algorithm-an-intuitive-look/© 2024 KetBy.com | All rights reserved.
Contact us at ketby.com@gmail.com