Distributed Grover’s algorithm
Abstract
Let Boolean function where . To search for an with , by Grover’s algorithm we can get the objective with query times . In this paper, we propose a distributed Grover’s algorithm for computing with lower query times and smaller number of input bits. More exactly, for any with , we can decompose into subfunctions, each which has input bits, and then the objective can be found out by computing these subfunctions with query times at most for some and , where . In particular, if , then our distributed Grover’s algorithm only needs queries, versus queries of Grover’s algorithm. Finally, we propose an efficient algorithm of constructing quantum circuits for realizing the oracle corresponding to any Boolean function with conjunctive normal form (CNF).
Keywords: Distributed quantum computing; Grover’s algorithm; Quantum amplitude estimation
1 Introduction
Quantum computers were first considered by Benioff [2], and then suggested by Feynman [12] in 1982. By formalizing Benioff and Feynman’s ideas, Deutsch [9] in 1985 proved the existence of universal quantum Turing machines (QTMs) and proposed the quantum Church-Turing Thesis. Subsequently, Deutsch [10] considered quantum network models. In 1993, Yao [24] elaborated on the simulation of QTMs by quantum circuits (recently simulation has been further improved [17]). Universal QTMs simulating other QTMs with polynomial time was proved by Bernstein and Vazirani [6].
The Deutsch-Jozsa algorithm was proposed by Deutsch and Jozsa in 1992 [11] and improved by Cleve, Ekert, Macchiavello, and Mosca in 1998 [7]. For determining whether a function is constant or balanced, the Deutsch-Jozsa algorithm [11, 7] solves exactly the Deutsch-Jozsa problem with exact quantum 1-query, but the classical algorithm requires queries to compute it deterministically. It presents a basic procedure of quantum algorithms, and in a way provides inspiration for Simon’s algorithm, Shor’s algorithm, and Grover’s algorithm [14, 18].
Deutsch-Jozsa problem and Simon problem have been further studied. In fact, it was proved that all symmetric partial Boolean functions with exact quantum 1-query complexity can be computed by the Deutsch-Jozsa algorithm [21], and further generalization of Deutsch-Jozsa problem was studied in [20]. An optimal separation between exact quantum query complexity and classical deterministic query complexity for Simon problem was obtained in [8].
Grover’s algorithm can find out one target element in an unordered database if the sum of all target elements is known. More formally, let a Boolean function where . To search for an with , by Grover’s algorithm we can get the objective with queries, and the success probability is close to . However, any classical algorithm to solve it needs queries. Grover’s algorithm with zero theoretical failure rate was considered by Long [15]. The problem of operator coherence in Grover’s algorithm was considered in [19].
After Grover’s algorithm, the algorithms of quantum amplitude amplification and estimation [5] were proposed and developed. The algorithm of quantum amplitude amplification is a generalization of Grover’s algorithm. We describe the algorithm of quantum amplitude estimation [5] roughly. Given a Boolean function , and a quantum algorithm acting on , then we hope to get the quantity of information for from . Actually, the algorithm of quantum amplitude estimation (more exactly, quantum counting) [5] can answer this problem by making queries on with high success probability. Therefore, if the sum of all target elements in an unordered database is not known, then we can employ the algorithm of quantum counting [5] to estimate it with high success probability (see Corollary 1).
The exponential speed-up of Shor’s quantum algorithm for factoring integers in polynomial time [22] and afterwards Grover’s algorithm of searching in database of size with only accesses [13] have already shown great advantages of quantum computing over classical computing, but nowadays it is still difficult to build large-scale universal quantum computers due to noise and depth of quantum circuits. So, in the NISQ (Noisy Intermediate-scale Quantum) era, developing new quantum algorithms and models with better physical realizability is an intriguing and promising research field, and distributed quantum computing is such a feasible and useful subject.
Distributed quantum computing has been studied from different methods and points of view (for example, [1, 4, 16, 23, 25]). As we are aware, there are three methods for distributed quantum computing in general. One way is directly to divide the quantum circuit for computing a problem into multiple quantum sub-circuits, but quantum communications (such as quantum teleportation) are needed among quantum sub-circuits, for example, a distributed Shor’s algorithm in [25]. However, the price of this method is more teleportations to be paid; the second method is to get multiple local solutions by using similar quantum algorithms to the original one and then conclude the final solution of problem, for example, distributed quantum phase estimation in [16]; the third method proposed recently is decomposing a Boolean function to be computed into multiple subfunctions [1], and then computing these (all or partial) subfunctions to get the solution of original problem (for example [23]). In fact, we have proposed a distributed algorithm for solving Simon’s problem, where there exist actually entanglement among those oracles for querying subfunctions.
In this paper, we use the third method to design a distributed Grover’s algorithm, but these oracles for querying all subfunctions can work separately in our algorithm, that is, without entnaglement between these oracles. In addition, we propose an efficient algorithm with time complexity for realizing the oracle (i.e., unitary operator ), where , and is a Boolean fucntion with conjunctive normal form (CNF) having clauses.
The remainder of the paper is organized as follows. In Section 2, we recall the Grover’s algorithm and the algorithms of quantum amplitude estimation and quantum counting that we will use in this paper. Then, in Section 3, we give two distributed Grover’s algorithms, where one is serial and another is parallel. In our distributed algorithms, many oracles are required, so in Section 4, we propose an efficient algorithm for realizing the oracle corresponding to any Boolea function with conjunctive normal form (CNF). Finally, in Section 5 we summarize the results obtained and mention related problems for further study.
2 Preliminaries
In the interest of readability, in this section, we briefly review the Grover’s algorithm [13] and the algorithms of quantum amplitude estimation and quantum counting [5]. First we recall Grover’s algorithm.
2.1 Grover’s algorithm
Grover’s algorithm aims to search for a goal (solution) to a very wide range of problems. We formally describe this problem as follows. Define a function and we assume that for some (here we consider ). The goal is to find out one such that . So, the search problem is as follows.
Input: A function with
Problem: Find an input such that .
Grover’s algorithm performs the search quadratically faster than any classical algorithm. In fact, any classical algorithm finding a solution with probability at least must make queries in the worst case, but Grover’s algorithm takes only queries, more exactly queries.
Although this is not the exponential quantum advantage achieved as Shor’s algorithm for factoring, the wide applicability of searching problems makes Grover’s algorithm interesting and important. We describe the Grover’s algorithm in the following Figure 1, where .

Next, we recall the analyse of Grover’s algorithm. Denote
(1) | |||
(2) | |||
(3) | |||
(4) |
Then after step 1 of algorithm, the quantum state is
(5) |
where , , .
It is easy to know that , so
(6) | ||||
(7) |
Let , . Then we have
(8) |
Our goal is to make , that is , so .
Since , we obtain , and the probability of success is:
(9) |
where the probability is close to .
2.2 Algorithm of quantum amplitude estimation
In this subsection we introduce the algorithm of quantum amplitude estimation [5].
Let . Suppose we have a quantum algorithm without measurements such that . Further, there are:
(10) |
where
(11) | |||
(12) |
Denote
(13) |
Let
Define
(14) |
where , and it follows that
(15) |
where . Suppose unitary transformation acts on qubits, is a positive integer, represents a unitary transformation acting on qubits and is defined as:
(16) |
where , is the state corresponding to the qubit.
When is unknown, we can use quantum amplitude estimation to get an approximation of .

To illustrate the above algorithm, we recall the following theorem [5].
Theorem 1.
[5] For any positive integer , the algorithm outputs such that
(17) |
the probability that this holds is:
When , ;
When , .
If then with certainty, and if then with certainty.
We recall the first stage of quantum phase estimation procedure (Figure 3) that can implement , where we replace by in Figure 3. Each contains one , so the total number of queries on is .

A straightforward application of this algorithm is to approximately count the number of solutions to where . We then have . Actually, by means of the above theorem, Brassard et al [5] further presented an algorithm of quantum counting and obtained the following theorem. Here let be Hadamard transformation .
By Theorem 1, we obtain the following theorem by taking to be the Hadamard transformation .
Theorem 2.
For any positive integer , and any Boolean function , the algorithm outputs an estimate to such that
(18) |
the probability that this holds is:
When , ;
When , .
If then with certainty, and if then with certainty.
In particular, if we want to estimate within a few deviations, we can apply algorithm with . This is the following corollary further presented in [5].
Corollary 1.
[5] Given a Boolean function with , there is an algorithm of quantum counting requiring exactly queries of and outputting integer number such that
(19) |
with probability at least . In particular, if then is determined with certainty, and if then is determined with certainty.
3 Distributed Grover’s algorithm
Let Boolean function , and suppose . For any , we divide into subfunctions as follows.
For any , we identify with the binary representation of , and then define Boolean function as follows: For any ,
(20) |
If we can find out some such that , then the solution has been discovered. However, if function for any , then we cannot get any useful solution from it. We employ the algorithm of quantum counting [5] to determine the number of “good” elements for each subfunction, where a “good” element means an input string mapping to function value . If the subfunction is constant to , then the algorithm of quantum counting can determine this subfunction is constant to exactly without error; if the subfunction is not constant to , then the algorithm of quantum counting can determine the number of “good” elements of subfunction with success probability at least .
After that, for a subfunction having function value , we use Grover’s algorithm to find out a solution that is the goal of the original problem as well.
So, before we perform the Grover’s algorithm for a subfunction, we use the algorithm of quantum counting [5] to determine the number of “good” elements of subfunctions.
First we present a lemma. Here we denote as above.
Lemma 1.
Let Boolean function . Given , for any integer , denote and . Then the algorithm of quantum counting can outputs an integer number such that with queries to , and the success probability is at least . In particular, if then is determined with certainty, and if then is determined with certainty.
Proof.
It follows from Corollary 1 by taking there. More specifically, for inputting function , by virtue of the algorithm of quantum counting , an integer number is outputted and satisfies
(21) | ||||
(22) | ||||
(23) |
where is used. Therefore, we have . ∎
Remark 1.
From Lemma 1 we know that has at most possible values.
After is determined not constant to zero, we use Grover’s algorithm to search for a solution such that . Then is exactly the solution of the original problem.
For subfunctions , we can use machines in parallel to deal with independently, or we use one machine only to do it in sequence. Next we analyze their query complexity respectively.
If we use machines in parallel to compute, then once is determined as non-constant to zero by the algorithm of quantum counting, we further use Grover’s algorithm to search for a solution. So, in this case, we need to query at most times for some (), where we use queries in the algorithm of quantum counting, and means the times to check the results for using Grover’s algorithm regarding each possible number of goals of .
If we use only one machine to do it with serial method, and suppose has no goals (i.e., ) for , but does, then we need to query times at most (of course, if we are failure to get a solution from , we can continue to search from , but we do not consider this case here).
Next we give a distributed Grover’s algorithm in serial method.
Remark 2.
In above algorithm, we have not considered the case of being failure to get a solution from and then continuing to search from next subfunction.
We can describe the above algorithm with the following theorem.
Theorem 3.
Given , let Boolean function with . Then Algorithm 4 can find out the string such that with query times at most and the success probability is at least
(24) |
where is the success probability of Grover’s algorithm for computing the first with being not constant to zero.
Proof.
Suppose is not a constant function, but for . Then the algorithm of quantum counting can exactly determine is constant to zero for . For , the algorithm of quantum counting outputs a range of with success probability at least , say where otherwise it is removed (recall ).
After that, we use Grover’s algorithm to compute for each possible number of goals and get the solution with success probability , where
So, in this case, the number of queries is , where we use queries in the algorithm of quantum counting, and means the times to check the results for using Grover’s algorithm regarding each possible number of goals of . It is clear that
(25) | |||
(26) |
Therefore, the success probability is at least Since both and approximate , the success probability is still high.
∎
Next we give a distributed Grover’s algorithm in parallel.
In order to explain the above algorithm, we use the following theorem.
Theorem 4.
Given , let Boolean function with . Then for any with , Algorithm 5 can find out the string such that with query times for some and , and the success probability is at least
(27) |
where is the success probability of Grover’s algorithm for computing .
Proof.
For any with , the algorithm of quantum counting takes queries to determine a range of , with . The success probability is at least . Then we use Grover’s algorithm to search for a solution of according to the possible values of goals in in sequence, and after each measuring, we check whether the result is the solution of . So, it takes at most queries for some and . Since , the success probability of Grover’s algorithm for computing is . Consequently, the success probability is at least .
∎
Remark 3.
Finally, we consider a special case, that is . In this case, is or where . So, we can use Grover’s algorithm directly by just taking instead of using the algorithm of quantum counting, and then check whether the measuring result is the solution of . Therefore, the number of queries in the above distributed Grover’s algorithm in parallel is
(28) |
4 Realization of Oracles with Quantum Circuits
Constructing quantum circuit to realize an oracle is important in Grover’s algorithm, since it is a key step from practical problems to applications. As above, more oracles are required in the distributed Grover’s algorithms, so how to construct quantum circuits to realize oracles physically is useful in practice. In this section, the goal is to design an algorithm for realizing oracles and provide a corresponding quantum circuit.
More specifically, given any Boolean function , its oracle is defined as , and the unitary operator is constructed from in Algorithm 1. Recently, there was a method to construct a quantum circuit for realizing oracles related to Boolean functions in the form of disjunctive normal form (DNF) proposed in [1]. However, their method relies on the truth table of functions to be computed, which means that it is difficult to apply in practice, since the truth table of a Boolean function is likely not known in general. Therefore, in this section, we give a method to construct the oracle for any given Boolean function which is a conjunctive normal form (CNF), without knowing its truth table. As is known, 3SAT problem is a special case of conjunctive normal forms.
A CNF that relies on Boolean variables is of the form
(29) |
where (called clause) is in the form () and (called literal) is a variable or negation of a variable in (). For example, is a CNF with clauses that relies on variables , where and . In the interest of simplification, we consider functions that are 3CNF, where 3CNF is a CNF with . 3CNF is vital, since the famous 3SAT problem (the first proven NPC problem) is to determine whether any given 3CNF has a solution. Of course, our method can be used similarly for realizing the oracles corresponding to general conjunctive normal forms.
How can we construct a quantum circuit for realizing the oracle related to a 3CNF? The idea is as follows. We consider such a circuit. We use qubits to represent Boolean variables, and use ancillary qubits to store the number of clauses that are false. Thus, we can know the value of the function under the current assignment of variables is true if and only if the ancillary qubits is in state . In addition, we flip the phase if the ancillary qubits is , and finally restore the ancillary qubits. This idea can be formalized by means of Algorithm 6, and the corresponding circuit of Algorithm 6 is shown in Figure 4.
For describing Algorithm 6 clearly, we first define two unitary operators and depending on clause in a CNF as above Eq. (29) (), where and act on the Hilbert space spanned by .
Definition 1.
For each , unitary operator is defined as: for any and for any ,
(30) | ||||
(33) |
Definition 2.
For each , unitary operator is defined as: for any and for any ,
(34) | ||||
(37) |

Next, we give the proof of correctness of Algorithm 6.
Theorem 5.
The final state of Algorithm 6 is .
Proof.
Denote , and let be defined as:
for . According to the definition of each , we have
(38) |
for and . Therefore we have
(39) |
for . Hence, after step 2, the quantum state is
(40) |
where . Since if and only if , we in step 3 obtain
(41) |
Similarly, in step 4, we can see that
(42) |
for . When , we get
(43) |
Consequently, we have completed the proof. ∎
Remark 4.
We use ancillary qubits to implement the transformation from to . Moreover, the construction of operators only depends on . For example, suppose for some , since is false if and only if and , we know and can be construted as Figure 5, where the operators and act as follows:
(44) |
(45) |
for any . The operators and can be constructed by means of using elementary gates with ancillary qubits [25]. According to the similar method, the construction of each and can be generalized to general case of with number of variable more than 3.

Due to Algorithm 6, we have the following theorem.
Theorem 6.
Let Boolean function be a 3CNF with clauses. Then the oracle can be realized by using elementary gates with ancillary qubits.
Proof.
By means of Algorithm 6, the oracle can be realized by operators ,.
The operator or can be constructed in terms of using elementary gates with ancillary qubits [25]. Hence, each or can be constructed by using elementary gates with ancillary qubits. is a muti-qubit controlled gate and can be constructed by using elementary gates with fixed number of ancillary qubits [1, 3]. So, the theorem holds. ∎
Remark 5.
In the distributed Grover’s algorithm we have designed, the oracles related to all Boolean subfunction () are needed, where is given, is the binary representation of and . If is a 3CNF, then is also a 3CNF and usually can be simplified with classical method based on the known variables to the 3CNF of . Since is a 3CNF, by Theorem 6, we can realize its oracle with elementary gates and ancillary qubits, where is the number of clauses in the 3CNF of . Therefore, for any positive integer , the time complexity of realizing the oracles for in parallel is .
5 Concluding remarks
It is still difficult to design large-scale universal quantum computers nowadays due to significant depth of quantum circuits and noise impact. Therefore, quantum models and algorithms with smaller number of input bits and shallower circuits have better physical realizability. Distributed quantum algorithms usually require smaller size of input bits and better time complexity as well as shallower depth of quantum circuits, so it is intriguing to design distributed quantum algorithms for important quantum algorithms such as Shor’s algorithm and Grover’s algorithm.
In this paper, we have given a distributed Grover’s algorithm. We can divide a function to be computed into subfunctions and then compute one of useful subfunctions to obtain the solution of the original function. For dealing with these subfunctions, we have considered two methods, i.e., serial method and parallel method. The success probabilities of two methods are same and approximate to that of Grover’s algorithm. As for query times (depth of quantum circuits) in the worst case, parallel method needs at most for some , where and , versus of Grover’s algorithm, where is the number of input bits of problem, but the number of input bits for subfunctions is .
In particular, if , then our distributed Grover’s algorithm in parallel only needs queries, versus queries of Grover’s algorithm.
For any Boolean function with CNF having clauses, we have proposed an efficient algorithm of constructing quantum circuit for realizing the oracle corresponding to . The algorithm’s time complexity is . According to Remark 5, the time complexity of realizing the oracles in our distributed Grover’s algorithm in parallel is at most , where is the number of clauses in the Boolean function to be computed.
Other problems worthy of further consideration are how to design distributed quantum algorithms for Deutsch-Jozsa problem, Hidden subgroup problem, and decomposition of large number. We would like to consider it in sequent study. In particular, we would like to realize these distributed quantum algorithms with ion trap quantum computers experimentally in near future.
Acknowledgements
We thank Dr. Markus Grassl for pointing out a problem of query times in Theorem 1. This work is supported in part by the National Natural Science Foundation of China (Nos. 61876195, 61572532) and the Natural Science Foundation of Guangdong Province of China (No. 2017B030311011).
References
- [1] J. Avron, O. Casper, and I. Rozen, Quantum advantage and noise reduction in distribute quantum computing, Physical Review A 104 (2021) 052404.
- [2] P. Benioff, The computer as a physical system: a microscopic quantum mechanical Hamiltonian model of computers as represented by Turing machines, Journal of Statistic Physics 22 (1980) 563-591.
- [3] A. Barenco, C. H. Bennett, R. Cleve, et al. Elementary gates for quantum computation. Physical Review A 52 (5) (1995) 3457.
- [4] R. Beals, S. Brierley, O. Gray, et al., Efficient distributed quantum computing, Proceedings of the Royal Society A 469 (2013) 20120686.
- [5] G. Brassard, P. Hoyer, M. Mosca, and A. Tapp, Quantum amplitude amplification and estimation, Contemp. Math. 305 (2002) 53-74.
- [6] E. Bernstein, U. Vazirani, Quantum complexity theory, SIAM Journal on Computing 26 (5) (1997) 1411-1473.
- [7] R. Cleve, A. Eckert, C. Macchiavello, and M. Mosca, Quantum algorithms revisited, Proceedings of the Royal Society of London 454A (1998) 339–354.
- [8] G. Cai, D.W. Qiu, Optimal separation in exact query complexities for Simon problem, Journal of Computer and System Sciences 97 (2018) 83-93.
- [9] D. Deutsh, Quantum theory, the Church-Turing principle and the universal quantum computer, Proceedings of the Royal Society of London Series A 400 (1985) 97-117.
- [10] D. Deutsh, Quantum computational networks, Proceedings of the Royal Society of London Series A 400 (1985) 73-90.
- [11] D. Deutsch and R. Jozsa, Rapid solution of problems by quantum computation, Proceedings of the Royal Society of London 439A (1992) 553–558.
- [12] R.P. Feynman, Simulating physics with computers, International Journal of Theoretical Physics 21 (1982) 467-488.
- [13] L.K. Grover, A fast quantum mechanical algorithm for database search, in: Proceedings of the 28th Annual ACM Symposium on Theory of Computing, Philadelphia, Pennsylvania, USA, 1996, pp. 212-219.
- [14] P. R. Kaye, R. Laflamme, and M. Mosca, An Introduction to Quantum Computing, Oxford University Press, New York, 2007.
- [15] G. L. Long, Grover algorithm with zero theoretical failure rat, Physical Review A 64 (2001) 022307.
- [16] K. Li, D.W. Qiu, et al., Application of distributed semi-quantum computing model in phase estimation, Information Processing Letters 120 (2017) 23-29.
- [17] A. Molina, J. Watrous, Revisiting the simulation of quantum Turing machines by quantum circuits, Proceedings of the Royal Society of London Series A 475 (2019) 20180767.
- [18] M. Nielsen, I. Chuang, Quantum Computation and Quantum Information, Cambridge University Press, Cambridge, 2000.
- [19] M. Pan, D.W. Qiu, Operator coherence dynamics in Grover’s quantum search algorithm, Physical Review A 100(1) (2019) 1-10.
- [20] D.W. Qiu, S. Zheng, Generalized Deutsch-Jozsa problem and the optimal quantum algorithm, Physical Review A 97 (2018) 062331.
- [21] D.W. Qiu, S. Zheng, Revisiting Deutsch-Jozsa Algorithm, Information and Computation, 2020,275: 1-12.
- [22] P.W. Shor, Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer, SIAM Journal on Computing 26 (5) (1997) 1484-1509.
- [23] J. Tan, L. Xiao, D.W. Qiu, L. Luo, and P. Mateus, Distributed quantum algorithm for Simon’s problem, Physical Review A 106 (2022) 032417.
- [24] A.C. Yao, Quantum circuit complexity, in: Proceedings of the 34th IEEE Symposium on Foundations of Computer science, 1993, pp. 352-361.
- [25] A. Yimsiriwattana, S.J. Lomonaco, Distributed quantum computing: A distributed Shor algorithm, Quantum Information and Computation II 5436 (2004) 360-372.