This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Distributed Grover’s algorithm

Daowen Qiu1,3,∗, Le Luo2,3, Ligang Xiao1,3
1School of Computer Science and Engineering, Sun Yat-sen University, Guangzhou, China
2School of Physics and Astronomy, Sun Yat-sen University, Zhuhai, China
3QUDOOR Technologies Inc., Guangzhou, China
Corresponding author. E-mail address: issqdw@mail.sysu.edu.cn

Abstract

Let Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\longrightarrow\{0,1\} where |{x{0,1}n|f(x)=1}|=a1|\{x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1. To search for an x{0,1}nx\in\{0,1\}^{n} with f(x)=1f(x)=1, by Grover’s algorithm we can get the objective with query times π42na\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n}}{a}}\rfloor. In this paper, we propose a distributed Grover’s algorithm for computing ff with lower query times and smaller number of input bits. More exactly, for any kk with n>k1n>k\geq 1, we can decompose ff into 2k2^{k} subfunctions, each which has nkn-k input bits, and then the objective can be found out by computing these subfunctions with query times at most i=1riπ42nkbi+2nk+2ta+1\sum_{i=1}^{r_{i}}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1 for some 1bia1\leq b_{i}\leq a and ri2ta+1r_{i}\leq 2t_{a}+1, where ta=2πa+11t_{a}=\lceil 2\pi\sqrt{a}+11\rceil. In particular, if a=1a=1, then our distributed Grover’s algorithm only needs π42nk\lfloor\frac{\pi}{4}\sqrt{2^{n-k}}\rfloor queries, versus π42n\lfloor\frac{\pi}{4}\sqrt{2^{n}}\rfloor 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 f:{0,1}n{0,1}f:\{0,1\}^{n}\longrightarrow\{0,1\} 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 2n1+12^{n-1}+1 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 f:{0,1}n{0,1}f:\{0,1\}^{n}\longrightarrow\{0,1\} where |{x{0,1}n|f(x)=1}|=a1|\{x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1. To search for an x{0,1}nx\in\{0,1\}^{n} with f(x)=1f(x)=1, by Grover’s algorithm we can get the objective with π42na\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n}}{a}}\rfloor queries, and the success probability is close to 11. However, any classical algorithm to solve it needs Ω(2n)\Omega(2^{n}) 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 f:{0,1}n{0,1}f:\{0,1\}^{n}\longrightarrow\{0,1\}, and a quantum algorithm 𝒜{\cal A} acting on |0n|0^{n}\rangle, then we hope to get the quantity of information for f(x)=1f(x)=1 from 𝒜|0n{\cal A}|0^{n}\rangle. Actually, the algorithm of quantum amplitude estimation (more exactly, quantum counting) [5] can answer this problem by making 2n\lceil\sqrt{2^{n}}\rceil queries on ff 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 NN with only O(N)O(\sqrt{N}) 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 O(mlogm)O(m\log m) for realizing the oracle (i.e., unitary operator ZfZ_{f}), where Zf|x=(1)f(x)|xZ_{f}|x\rangle=(-1)^{f(x)}|x\rangle, and ff is a Boolean fucntion with conjunctive normal form (CNF) having mm 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 f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} and we assume that f(x)=1f(x)=1 for some x{0,1}nx\in\{0,1\}^{n} (here we consider |{x{0,1}n|f(x)=1}|=a1|\{x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1). The goal is to find out one xx such that f(x)=1f(x)=1. So, the search problem is as follows.

Input: A function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} with |{x{0,1}n|f(x)=1}|=a1|\{x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1

Problem: Find an input x{0,1}nx\in\{0,1\}^{n} such that f(x)=1f(x)=1.

Grover’s algorithm performs the search quadratically faster than any classical algorithm. In fact, any classical algorithm finding a solution with probability at least 23\frac{2}{3} must make Ω(2n)\Omega(2^{n}) queries in the worst case, but Grover’s algorithm takes only O(2n)O(\sqrt{2^{n}}) queries, more exactly π42na\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n}}{a}}\rfloor 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 N=2nN=2^{n}.

Refer to caption
Figure 1: Grover’s algorithm
Input: A function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} with |{x{0,1}n|f(x)=1}|=a1|\{x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1.
Output: the string x{0,1}nx\in\{0,1\}^{n} such that f(x)=1f(x)=1.
1 Hn|0n12nx{0,1}n|xH^{\otimes n}|0\rangle^{\otimes n}\rightarrow\frac{1}{\sqrt{2^{n}}}\sum\limits_{x\in\{0,1\}^{n}}|x\rangle.
2GG is performed with π42na\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n}}{a}}\rfloor times, which G=HnZ0HnZfG=-H^{\otimes n}Z_{0}H^{\otimes n}Z_{f}, Zf|x=(1)f(x)|xZ_{f}|x\rangle=(-1)^{f(x)}|x\rangle, Z0|x={|x,x=0n;|x,x0n.Z_{0}|x\rangle=\left\{\begin{array}[]{rcl}-|x\rangle,&&x=0^{n};\\ |x\rangle,&&x\neq 0^{n}.\end{array}\right.
3Measure the resulting state.
Algorithm 1 Grover’s Algorithm

Next, we recall the analyse of Grover’s algorithm. Denote

A={x{0,1}n|f(x)=1},\displaystyle A=\{x\in\{0,1\}^{n}|f(x)=1\}, (1)
B={x{0,1}n|f(x)=0},\displaystyle B=\{x\in\{0,1\}^{n}|f(x)=0\}, (2)
|A=1axA|x,\displaystyle|A\rangle=\frac{1}{\sqrt{a}}\sum\limits_{x\in A}|x\rangle, (3)
|B=1bxB|x.\displaystyle|B\rangle=\frac{1}{\sqrt{b}}\sum\limits_{x\in B}|x\rangle. (4)

Then after step 1 of algorithm, the quantum state is

Hn|0n=aN|A+bN|B|h,H^{\otimes n}|0\rangle^{\otimes n}=\sqrt{\frac{a}{N}}|A\rangle+\sqrt{\frac{b}{N}}|B\rangle\triangleq|h\rangle, (5)

where a=|A|a=|A|, b=|B|b=|B|, N=2nN=2^{n}.

It is easy to know that Z0=I2|0n0n|Z_{0}=I-2|0^{n}\rangle\langle 0^{n}|, so

HnZ0Hn\displaystyle H^{\otimes n}Z_{0}H^{\otimes n} =Hn(I2|0n0n|)Hn\displaystyle=H^{\otimes n}(I-2|0^{n}\rangle\langle 0^{n}|)H^{\otimes n} (6)
=I2|hh|.\displaystyle=I-2|h\rangle\langle h|. (7)

Let sinθ=aN\sin{\theta}=\sqrt{\frac{a}{N}}, cosθ=bN\cos{\theta}=\sqrt{\frac{b}{N}}. Then we have

Gk|h=cos((2k+1)θ)|B+sin((2k+1)θ)|A.G^{k}|h\rangle=\cos{((2k+1)\theta)}|B\rangle+\sin{((2k+1)\theta)}|A\rangle. (8)

Our goal is to make sin((2k+1)θ)1\sin{((2k+1)\theta)}\approx 1, that is (2k+1)θπ2(2k+1)\theta\approx\frac{\pi}{2}, so kπ4θ12k\approx\frac{\pi}{4\theta}-\frac{1}{2}.

Since θ=sin1aNaN\theta=\sin^{-1}{\sqrt{\dfrac{a}{N}}}\approx\sqrt{\dfrac{a}{N}}, we obtain k=π42nak=\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n}}{a}}\rfloor, and the probability of success is:

sin2((2πN/4a+1)sin1(a/N)),\sin^{2}{((2\lfloor\pi\sqrt{N}/4\sqrt{a}\rfloor+1)\sin^{-1}(\sqrt{a}/\sqrt{N}))}, (9)

where the probability is close to 11.

2.2 Algorithm of quantum amplitude estimation

In this subsection we introduce the algorithm of quantum amplitude estimation [5].

Let f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\}. Suppose we have a quantum algorithm 𝒜\mathcal{A} without measurements such that 𝒜|0n=|Ψ\mathcal{A}|0^{n}\rangle=|\Psi\rangle. Further, there are:

|Ψ=|Ψ1+|Ψ0,|\Psi\rangle=|\Psi_{1}\rangle+|\Psi_{0}\rangle, (10)

where

|Ψ1=x:f(x)=1αx|x,\displaystyle|\Psi_{1}\rangle=\sum\limits_{x:f(x)=1}\alpha_{x}|x\rangle, (11)
|Ψ0=x:f(x)=0αx|x.\displaystyle|\Psi_{0}\rangle=\sum\limits_{x:f(x)=0}\alpha_{x}|x\rangle. (12)

Denote

ag=Ψ1|Ψ1,0<ag<1.a_{g}=\langle\Psi_{1}|\Psi_{1}\rangle,0<a_{g}<1. (13)

Let

Q=𝒜U0𝒜1Uf,\displaystyle Q=\mathcal{A}U_{0}^{\perp}\mathcal{A}^{-1}U_{f},
U0=2|0n0n|I,\displaystyle U_{0}^{\perp}=2|0^{n}\rangle\langle 0^{n}|-I,
Uf|x=(1)f(x)|x.\displaystyle U_{f}|x\rangle=(-1)^{f(x)}|x\rangle.

Define

QFT2m|j=12mk=02m1e2πijk/2m|k,QFT_{2^{m}}|j\rangle=\frac{1}{\sqrt{2^{m}}}\sum\limits_{k=0}^{2^{m}-1}e^{2\pi ijk/2^{m}}|k\rangle, (14)

where 0j<2m10\leq j<2^{m}-1, and it follows that

QFT2m|j=12mk=02m1e2πijk/2m|k,QFT_{2^{m}}^{\dagger}|j\rangle=\frac{1}{\sqrt{2^{m}}}\sum\limits_{k=0}^{2^{m}-1}e^{-2\pi ijk/2^{m}}|k\rangle, (15)

where 0j<2m10\leq j<2^{m}-1. Suppose unitary transformation QQ acts on nn qubits, mm is a positive integer, Λ2m(Q)\Lambda_{2^{m}}(Q) represents a unitary transformation acting on m+nm+n qubits and is defined as:

Λ2m(Q)|j|ψ=|j(Qj|ψ),\Lambda_{2^{m}}(Q)|j\rangle|\psi\rangle=|j\rangle(Q^{j}|\psi\rangle), (16)

where j{0,,2m1}j\in\{0,\cdots,2^{m}-1\}, |ψ|\psi\rangle is the state corresponding to the nn qubit.

When aga_{g} is unknown, we can use quantum amplitude estimation to get an approximation of aga_{g}.

Refer to caption
Figure 2: Algorithm of quantum amplitude estimation
Input: 𝒜\mathcal{A}, ff, 2m2^{m}.
Output: a~=sin2(πy2m)\widetilde{a}=\sin^{2}(\pi\frac{y}{2^{m}}).
1Initialize two registers to the state |0m𝒜|0n|0^{m}\rangle\mathcal{A}|0^{n}\rangle.
2Apply QFT2mQFT_{2^{m}} to the first register, (QFT2mI)|0m𝒜|0n(QFT_{2^{m}}\otimes I)|0^{m}\rangle\mathcal{A}|0^{n}\rangle.
3Apply Λ2m(Q)\Lambda_{2^{m}}(Q) to the state after step 2.
4Apply (QFT2mI)(QFT_{2^{m}}^{\dagger}\otimes I) to the state after step 3.
5Measure the first register and denote the outcome |y|y\rangle.
6Output a~=sin2(πy2m)\widetilde{a}=\sin^{2}(\pi\frac{y}{2^{m}}).
Algorithm 2 Algorithm of quantum amplitude estimation Est_Amp(𝒜,f,2m){\rm Est\_Amp}(\mathcal{A},f,2^{m})

To illustrate the above algorithm, we recall the following theorem [5].

Theorem 1.

[5] For any positive integer kk, the algorithm Est_Amp(𝒜,f,2m){\rm Est\_Amp}(\mathcal{A},f,2^{m}) outputs a~\widetilde{a} (0a~1)(0\leq\widetilde{a}\leq 1) such that

|a~ag|2πkag(1ag)2m+k2π222m,\displaystyle|\widetilde{a}-a_{g}|\leq 2\pi k\frac{\sqrt{a_{g}(1-a_{g})}}{2^{m}}+k^{2}\frac{\pi^{2}}{2^{2m}}, (17)

the probability that this holds is:

(1)(1) When k=1k=1, p8π2p\geq\frac{8}{\pi^{2}};

(2)(2) When k2k\geq 2, p112(k1)p\geq 1-\frac{1}{2(k-1)}.

If ag=0a_{g}=0 then a~=0\widetilde{a}=0 with certainty, and if ag=1a_{g}=1 then a~=1\widetilde{a}=1 with certainty.

We recall the first stage of quantum phase estimation procedure (Figure 3) that can implement Λ2m(Q)\Lambda_{2^{m}}(Q), where we replace UU by QQ in Figure 3. Each QQ contains one UfU_{f}, so the total number of queries on UfU_{f} is i=0m12i=2m1\sum_{i=0}^{m-1}2^{i}=2^{m}-1.

Refer to caption
Figure 3: The first stage of quantum phase estimation procedure

A straightforward application of this algorithm is to approximately count the number of solutions tt to f(x)=1f(x)=1 where f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\}. We then have ag=Ψ1|Ψ1=t2na_{g}=\langle\Psi_{1}|\Psi_{1}\rangle=\frac{t}{2^{n}}. 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 𝒜\mathcal{A} be Hadamard transformation HnH^{\otimes n}.

Input: 𝒜\mathcal{A}, ff, 2m2^{m}.
Output: t=2n×sin2(πy2m)t^{\prime}=2^{n}\times\sin^{2}(\pi\frac{y}{2^{m}}).
1Initialize two registers to the state |0m𝒜|0n|0^{m}\rangle\mathcal{A}|0^{n}\rangle.
2Apply QFT2m{\rm{QFT}}_{2^{m}} to the first register, (QFT2mI)|0m𝒜|0n({\rm{QFT}}_{2^{m}}\otimes I)|0^{m}\rangle\mathcal{A}|0^{n}\rangle.
3Apply Λ2m(Q)\Lambda_{2^{m}}(Q) to the state after step 2.
4Apply (QFT2mI)({\rm{QFT}}_{2^{m}}^{\dagger}\otimes I) to the state after step 3.
5Measure the first register and denote the outcome |y|y\rangle.
Output t=2n×sin2(πy2m)t^{\prime}=2^{n}\times\sin^{2}(\pi\frac{y}{2^{m}}).
Algorithm 3 Quantum counting algorithm Count(𝒜,f,2m){\rm\textbf{Count}}(\mathcal{A},f,2^{m})

By Theorem 1, we obtain the following theorem by taking 𝒜\mathcal{A} to be the Hadamard transformation HnH^{\otimes n}.

Theorem 2.

For any positive integer kk, and any Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\}, the algorithm Count(Hn,f,2m){\rm\textbf{Count}}(H^{\otimes n},f,2^{m}) outputs an estimate tt^{\prime} to t=|f1(1)|t=|f^{-1}(1)| such that

|tt|2πkt(2nt)2m+k2π22n22m,\displaystyle|t^{\prime}-t|\leq 2\pi k\frac{\sqrt{t(2^{n}-t)}}{2^{m}}+k^{2}\frac{\pi^{2}2^{n}}{2^{2m}}, (18)

the probability that this holds is:

(1)(1) When k=1k=1 , p8π2p\geq\frac{8}{\pi^{2}};

(2)(2) When k2k\geq 2 , p112(k1)p\geq 1-\frac{1}{2(k-1)}.

If t=0t=0 then t=0t^{\prime}=0 with certainty, and if t=2nt=2^{n} then t=2nt^{\prime}=2^{n} with certainty.

In particular, if we want to estimate tt within a few deviations, we can apply algorithm Count(𝒜,f,2m){\rm\textbf{Count}}(\mathcal{A},f,2^{m}) with 2m=2n2^{m}=\lceil\sqrt{2^{n}}\rceil. This is the following corollary further presented in [5].

Corollary 1.

[5] Given a Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} with t=|{x{0,1}n|f(x)=1}|1t=|\{x\in\{0,1\}^{n}|f(x)=1\}|\geq 1, there is an algorithm of quantum counting Count(Hn,f,2n){\rm\textbf{Count}}(H^{\otimes n},f,\lceil\sqrt{2^{n}}\rceil) requiring exactly 2n\lceil\sqrt{2^{n}}\rceil queries of ff and outputting integer number tt^{\prime} such that

|tt|2πt(2nt)2n+11\displaystyle|t^{\prime}-t|\leq 2\pi\sqrt{\frac{t(2^{n}-t)}{2^{n}}}+11 (19)

with probability at least 8π2\frac{8}{\pi^{2}}. In particular, if t=0t=0 then t=0t^{\prime}=0 is determined with certainty, and if t=2nt=2^{n} then t=2nt^{\prime}=2^{n} is determined with certainty.

3 Distributed Grover’s algorithm

Let Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\}, and suppose |{x{0,1}n|f(x)=1}|=a1|\{x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1. For any n>k1n>k\geq 1, we divide ff into 2k2^{k} subfunctions as follows.

For any i[0,2k1]i\in[0,2^{k}-1], we identify yi{0,1}ky_{i}\in\{0,1\}^{k} with the binary representation of ii, and then define Boolean function fi:{0,1}nk{0,1}f_{i}:\{0,1\}^{n-k}\rightarrow\{0,1\} as follows: For any x{0,1}nkx\in\{0,1\}^{n-k},

fi(x)=f(xyi).f_{i}(x)=f(xy_{i}). (20)

If we can find out some x{0,1}nkx\in\{0,1\}^{n-k} such that fi(x)=1f_{i}(x)=1, then the solution has been discovered. However, if function fi(x)=0f_{i}(x)=0 for any x{0,1}nkx\in\{0,1\}^{n-k}, 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 11. If the subfunction is constant to 0, then the algorithm of quantum counting can determine this subfunction is constant to 0 exactly without error; if the subfunction is not constant to 0, then the algorithm of quantum counting can determine the number of “good” elements of subfunction with success probability at least 8π2\frac{8}{\pi^{2}}.

After that, for a subfunction having function value 11, 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 |{x{0,1}n|f(x)=1}|=a1|\{x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1 as above.

Lemma 1.

Let Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\}. Given n>k1n>k\geq 1, for any integer i[0,2k1]i\in[0,2^{k}-1], denote ai=|{x{0,1}nk|fi(x)=1}|a_{i}=|\{x\in\{0,1\}^{n-k}|f_{i}(x)=1\}| and ta=2πa+11t_{a}=\lceil 2\pi\sqrt{a}+11\rceil. Then the algorithm of quantum counting Count(H(nk),fi,2nk){\rm\textbf{Count}}(H^{\otimes(n-k)},f_{i},\lceil\sqrt{2^{n-k}}\rceil) can outputs an integer number aia_{i}^{\prime} such that ai{aita,aita+1,,ai+ta}a_{i}\in\{a_{i}^{\prime}-t_{a},a_{i}^{\prime}-t_{a}+1,\ldots,a_{i}^{\prime}+t_{a}\} with 2nk\lceil\sqrt{2^{n-k}}\rceil queries to fif_{i}, and the success probability is at least 8π2\frac{8}{\pi^{2}}. In particular, if ai=0a_{i}=0 then ai=0a_{i}^{\prime}=0 is determined with certainty, and if ai=2nka_{i}=2^{n-k} then ai=2nka_{i}^{\prime}=2^{n-k} is determined with certainty.

Proof.

It follows from Corollary 1 by taking fif_{i} there. More specifically, for inputting function fif_{i}, by virtue of the algorithm of quantum counting Count(H(nk),fi,2nk){\rm\textbf{Count}}(H^{\otimes(n-k)},f_{i},\lceil\sqrt{2^{n-k}}\rceil), an integer number aia_{i}^{\prime} is outputted and satisfies

|aiai|\displaystyle|a_{i}^{\prime}-a_{i}| 2πai(2nkai)2nk+11\displaystyle\leq 2\pi\sqrt{\frac{a_{i}(2^{n-k}-a_{i})}{2^{n-k}}}+11 (21)
2πa+11\displaystyle\leq 2\pi\sqrt{a}+11 (22)
=ta,\displaystyle=t_{a}, (23)

where aiaa_{i}\leq a is used. Therefore, we have ai{aita,aita+1,,ai+ta}a_{i}\in\{a_{i}^{\prime}-t_{a},a_{i}^{\prime}-t_{a}+1,\ldots,a_{i}^{\prime}+t_{a}\}. ∎

Remark 1.

From Lemma 1 we know that aia_{i} has at most 2ta+12t_{a}+1 possible values.

After fif_{i} is determined not constant to zero, we use Grover’s algorithm to search for a solution x{0,1}nkx\in\{0,1\}^{n-k} such that fi(xyi)=1f_{i}(xy_{i})=1. Then xyixy_{i} is exactly the solution of the original problem.

For subfunctions fif_{i} (i=0,1,2,,2k1)(i=0,1,2,\ldots,2^{k}-1), we can use 2k2^{k} machines in parallel to deal with fif_{i} independently, or we use one machine only to do it in sequence. Next we analyze their query complexity respectively.

If we use 2k2^{k} machines in parallel to compute, then once fif_{i} 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 i=12ta+1π42nkbi+2nk+2ta+1\sum_{i=1}^{2t_{a}+1}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1 times for some 1bia1\leq b_{i}\leq a (i=1,2,,2ta+1i=1,2,\ldots,2t_{a}+1), where we use 2nk\lceil\sqrt{2^{n-k}}\rceil queries in the algorithm of quantum counting, and 2ta+12t_{a}+1 means the times to check the results for using Grover’s algorithm regarding each possible number of goals bib_{i} of fif_{i}.

If we use only one machine to do it with serial method, and suppose fif_{i} has no goals (i.e., ai=0a_{i}=0) for 0iT2k20\leq i\leq T\leq 2^{k}-2, but fTf_{T} does, then we need to query i=12ta+1π42nkbi+T2nk+2ta+1\sum_{i=1}^{2t_{a}+1}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+T\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1 times at most (of course, if we are failure to get a solution from fTf_{T}, we can continue to search from fT+1f_{T+1}, but we do not consider this case here).

Next we give a distributed Grover’s algorithm in serial method.

Input: A function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} with f(x)=1f(x)=1 for some x{0,1}nx\in\{0,1\}^{n}.
Output: the string x{0,1}nx\in\{0,1\}^{n} such that f(x)=1f(x)=1.
1
2Given k[1,n)k\in[1,n), decompose ff into fif_{i} (i=0,1,2,,2k1)(i=0,1,2,\ldots,2^{k}-1) as Equation (20).
3Take i=0i=0.
4Use the algorithm of quantum counting Count(H(nk),fi,2nk){\rm\textbf{Count}}(H^{\otimes(n-k)},f_{i},\lceil\sqrt{2^{n-k}}\rceil) to determine a range of ai=|{x{0,1}nk|fi(x)=1}|a_{i}=|\{x\in\{0,1\}^{n-k}|f_{i}(x)=1\}| with at most 2ta+12t_{a}+1 possible values, say {b1,b2,,b2ta+1}\{b_{1},b_{2},\ldots,b_{2t_{a}+1}\} where bj0b_{j}\neq 0 otherwise it is removed. If ai=0a_{i}=0 and i<2k2i<2^{k}-2, return to Step 2 by taking i=i+1i=i+1, otherwise go to next step by taking j=1j=1.
5H(nk)|0(nk)12nkx{0,1}nk|xH^{\otimes(n-k)}|0\rangle^{\otimes(n-k)}\rightarrow\frac{1}{\sqrt{2^{n-k}}}\sum\limits_{x\in\{0,1\}^{n-k}}|x\rangle.
6GiG_{i} is performed with π42nkbi\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor times, where Gi=H(nk)Z0H(nk)ZfiG_{i}=-H^{\otimes(n-k)}Z_{0}H^{\otimes(n-k)}Z_{f_{i}}, Zfi|x=(1)fi(x)|xZ_{f_{i}}|x\rangle=(-1)^{f_{i}(x)}|x\rangle, Z0|x={|x,x=0nk;|x,x0nk.Z_{0}|x\rangle=\left\{\begin{array}[]{rcl}-|x\rangle,&&x=0^{n-k};\\ |x\rangle,&&x\neq 0^{n-k}.\end{array}\right.
7Measure the resulting state, and check whether it is a solution of fif_{i}. If it is, then end the algorithm, otherwise take j=j+1j=j+1 and return to Step 4.
Algorithm 4 Distributed Grover’s Algorithm (I)
Remark 2.

In above algorithm, we have not considered the case of being failure to get a solution from fTf_{T} and then continuing to search from next subfunction.

We can describe the above algorithm with the following theorem.

Theorem 3.

Given n>k1n>k\geq 1, let Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} with |x{0,1}n|f(x)=1}|=a1|x\in\{0,1\}^{n}|f(x)=1\}|=a\geq 1. Then Algorithm 4 can find out the string x{0,1}nx\in\{0,1\}^{n} such that f(x)=1f(x)=1 with query times at most π42nk+(2k1)(42nk1)\lfloor\frac{\pi}{4}\sqrt{2^{n-k}}\rfloor+(2^{k}-1)(4\sqrt{2^{n-k}}-1) and the success probability is at least

8π2PGi,\frac{8}{\pi^{2}}P_{G_{i}}, (24)

where PGi=sin2((2π2(nk)4ai+1)sin1(ai2(nk)))P_{G_{i}}=\sin^{2}{((2\lfloor\frac{\pi\sqrt{2^{(n-k)}}}{4\sqrt{a_{i}}}\rfloor+1)\sin^{-1}(\frac{a_{i}}{\sqrt{2^{(n-k)}}}))} is the success probability of Grover’s algorithm for computing the first fif_{i} with fif_{i} being not constant to zero.

Proof.

Suppose fTf_{T} is not a constant function, but fj0f_{j}\equiv 0 for j=0,1,2,,T1j=0,1,2,\ldots,T-1. Then the algorithm of quantum counting can exactly determine fjf_{j} is constant to zero for j=0,1,2,,T1j=0,1,2,\ldots,T-1. For fif_{i}, the algorithm of quantum counting outputs a range of aTa_{T} with success probability at least 8π2\frac{8}{\pi^{2}}, say {b1,b2,,b2ta+1}\{b_{1},b_{2},\ldots,b_{2t_{a}+1}\} where bi0b_{i}\neq 0 otherwise it is removed (recall aT=|{x{0,1}nk|fT(x)=1}|a_{T}=|\{x\in\{0,1\}^{n-k}|f_{T}(x)=1\}|).

After that, we use Grover’s algorithm to compute fTf_{T} for each possible number bjb_{j} of goals and get the solution with success probability PGTP_{G_{T}}, where

PGT=sin2((2π2(nk)4aT+1)sin1(aT2(nk))).P_{G_{T}}=\sin^{2}{((2\lfloor\frac{\pi\sqrt{2^{(n-k)}}}{4\sqrt{a_{T}}}\rfloor+1)\sin^{-1}(\frac{a_{T}}{\sqrt{2^{(n-k)}}}))}.

So, in this case, the number of queries is i=12ta+1π42nkbi+T2nk+2ta+1\sum_{i=1}^{2t_{a}+1}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+T\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1, where we use T2nkT\lceil\sqrt{2^{n-k}}\rceil queries in the algorithm of quantum counting, and 2ta+12t_{a}+1 means the times to check the results for using Grover’s algorithm regarding each possible number of goals bib_{i} of fTf_{T}. It is clear that

i=12ta+1π42nkbi+T2nk+2ta+1\displaystyle\sum_{i=1}^{2t_{a}+1}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+T\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1 (25)
(2ta+1)π42nk+2k2nk+2ta+1.\displaystyle\leq(2t_{a}+1)\lfloor\frac{\pi}{4}\sqrt{2^{n-k}}\rfloor+2^{k}\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1. (26)

Therefore, the success probability is at least 8π2PGi.\frac{8}{\pi^{2}}P_{G_{i}}. Since both 8π2\frac{8}{\pi^{2}} and PGiP_{G_{i}} approximate 11, the success probability is still high.

Next we give a distributed Grover’s algorithm in parallel.

Input: A function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} with f(x)=1f(x)=1 for some x{0,1}nx\in\{0,1\}^{n}.
Output: the string x{0,1}nx\in\{0,1\}^{n} such that f(x)=1f(x)=1.
1
2Given k[1,n)k\in[1,n), decompose ff into fif_{i} (i=0,1,2,,2k1)(i=0,1,2,\ldots,2^{k}-1) as Equation (20).
32k2^{k} machines (say Mi,i=0,1,2,,2k1M_{i},i=0,1,2,\ldots,2^{k}-1) separately perform the algorithm of quantum counting Count(H(nk),fi,2nk){\rm\textbf{Count}}(H^{\otimes(n-k)},f_{i},\lceil\sqrt{2^{n-k}}\rceil) to determine a range Ri={b1(i),b2(i),,bri(i)}R_{i}=\{b_{1}^{(i)},b_{2}^{(i)},\ldots,b_{r_{i}}^{(i)}\} of ai=|{x{0,1}nk|fi(x)=1}|a_{i}=|\{x\in\{0,1\}^{n-k}|f_{i}(x)=1\}|, with |ri|2ta+1|r_{i}|\leq 2t_{a}+1. If ai=0a_{i}=0, then MiM_{i} stops, otherwise the rest MiM_{i} continue next step in parallel.
4Take j=1j=1.
5H(nk)|0(nk)12nkx{0,1}nk|xH^{\otimes(n-k)}|0\rangle^{\otimes(n-k)}\rightarrow\frac{1}{\sqrt{2^{n-k}}}\sum\limits_{x\in\{0,1\}^{n-k}}|x\rangle.
6GiG_{i} is performed with π42nkbj\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{j}}}\rfloor times, which Gi=H(nk)Z0H(nk)ZfiG_{i}=-H^{\otimes(n-k)}Z_{0}H^{\otimes(n-k)}Z_{f_{i}}, Zfi|x=(1)fi(x)|xZ_{f_{i}}|x\rangle=(-1)^{f_{i}(x)}|x\rangle, Z0|x={|x,x=0nk;|x,x0nk.Z_{0}|x\rangle=\left\{\begin{array}[]{rcl}-|x\rangle,&&x=0^{n-k};\\ |x\rangle,&&x\neq 0^{n-k}.\end{array}\right.
7Measure the resulting state, and check whether it is a solution of fif_{i}. If it is, then end the algorithm, otherwise take j=j+1j=j+1 and return to Step 4.
Algorithm 5 Distributed Grover’s Algorithm (II)

In order to explain the above algorithm, we use the following theorem.

Theorem 4.

Given n>k1n>k\geq 1, let Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} with 1a=|x{0,1}n|f(x)=1}|1\leq a=|x\in\{0,1\}^{n}|f(x)=1\}|. Then for any ai=|{x{0,1}nk|fi(x)=1}|a_{i}=|\{x\in\{0,1\}^{n-k}|f_{i}(x)=1\}| with ai1a_{i}\geq 1, Algorithm 5 can find out the string x{0,1}nx\in\{0,1\}^{n} such that f(x)=1f(x)=1 with query times i=1riπ42nkbi+2nk+2ta+1\sum_{i=1}^{r_{i}}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1 for some 1bia1\leq b_{i}\leq a and ri2ta+1r_{i}\leq 2t_{a}+1, and the success probability is at least

8π2PGi,\frac{8}{\pi^{2}}P_{G_{i}}, (27)

where PGi=sin2((2π2(nk)4ai+1)sin1(ai2(nk)))P_{G_{i}}=\sin^{2}{((2\lfloor\frac{\pi\sqrt{2^{(n-k)}}}{4\sqrt{a_{i}}}\rfloor+1)\sin^{-1}(\frac{a_{i}}{\sqrt{2^{(n-k)}}}))} is the success probability of Grover’s algorithm for computing fif_{i}.

Proof.

For any ai=|{x{0,1}nk|fi(x)=1}|a_{i}=|\{x\in\{0,1\}^{n-k}|f_{i}(x)=1\}| with ai1a_{i}\geq 1, the algorithm of quantum counting takes 2(nk)\sqrt{2^{(n-k)}} queries to determine a range Ri={b1(i),b2(i),,bri(i)}R_{i}=\{b_{1}^{(i)},b_{2}^{(i)},\ldots,b_{r_{i}}^{(i)}\} of ai=|{x{0,1}nk|fi(x)=1}|a_{i}=|\{x\in\{0,1\}^{n-k}|f_{i}(x)=1\}|, with |ri|2ta+1|r_{i}|\leq 2t_{a}+1. The success probability is at least 8π2\frac{8}{\pi^{2}}. Then we use Grover’s algorithm to search for a solution of fif_{i} according to the possible values of goals in RiR_{i} in sequence, and after each measuring, we check whether the result is the solution of fif_{i}. So, it takes at most i=1riπ42nkbi+2nk+2ta+1\sum_{i=1}^{r_{i}}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1 queries for some 1bia1\leq b_{i}\leq a and ri2ta+1r_{i}\leq 2t_{a}+1. Since aiRia_{i}\in R_{i}, the success probability of Grover’s algorithm for computing fif_{i} is PGiP_{G_{i}}. Consequently, the success probability is at least 8π2PGi\frac{8}{\pi^{2}}P_{G_{i}}.

Remark 3.

Finally, we consider a special case, that is |x{0,1}n|f(x)=1}|=a=1|x\in\{0,1\}^{n}|f(x)=1\}|=a=1. In this case, aia_{i} is 0 or 11 where ai=|{x{0,1}nk|fi(x)=1}|a_{i}=|\{x\in\{0,1\}^{n-k}|f_{i}(x)=1\}|. So, we can use Grover’s algorithm directly by just taking ai=1a_{i}=1 instead of using the algorithm of quantum counting, and then check whether the measuring result is the solution of fif_{i}. Therefore, the number of queries in the above distributed Grover’s algorithm in parallel is

π42nk.\lfloor\frac{\pi}{4}\sqrt{2^{n-k}}\rfloor. (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 f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\}, its oracle ZfZ_{f} is defined as Zf|x=(1)f(x)|xZ_{f}|x\rangle=(-1)^{f(x)}|x\rangle, and the unitary operator GG is constructed from ZfZ_{f} 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 x1,x2,,xnx_{1},x_{2},\cdots,x_{n} is of the form

C1C2Cm,C_{1}\land C_{2}\land\cdots\land C_{m}, (29)

where CiC_{i} (called clause) is in the form v1v2vkiv_{1}\lor v_{2}\lor\cdots\lor v_{k_{i}} (i=1,2,,mi=1,2,\cdots,m) and vjv_{j} (called literal) is a variable or negation of a variable in {x1,x2,,xn}\{x_{1},x_{2},\cdots,x_{n}\} (j=1,2,,kij=1,2,\cdots,k_{i}). For example, (x1¬x2)(¬x1x4¬x3)(x_{1}\lor\neg x_{2})\land(\neg x_{1}\lor x_{4}\lor\neg x_{3}) is a CNF with 22 clauses that relies on variables x1,x2,x3,x4x_{1},x_{2},x_{3},x_{4}, where k1=2k_{1}=2 and k2=3k_{2}=3. In the interest of simplification, we consider functions that are 3CNF, where 3CNF is a CNF with ki3,i=1,2,,mk_{i}\leq 3,i=1,2,\cdots,m. 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 nn qubits to represent nn Boolean variables, and use log(m+1)\lceil\log(m+1)\rceil 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 |0log(m+1)|0\rangle^{\otimes\lceil\log(m+1)\rceil}. In addition, we flip the phase if the ancillary qubits is |0log(m+1)|0\rangle^{\otimes\lceil\log(m+1)\rceil}, 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 UkU_{k} and UkU_{k}^{\prime} depending on clause CkC_{k} in a CNF as above Eq. (29) (k=1,2,,mk=1,2,\ldots,m), where UkU_{k} and UkU_{k}^{\prime} act on the Hilbert space spanned by {|i1,i2,,in|j1,j2,,jM:i1,i2,,in,j1,j2,,jM{0,1},M=log(m+1)}\{|i_{1},i_{2},\ldots,i_{n}\rangle|j_{1},j_{2},\ldots,j_{M}\rangle:i_{1},i_{2},\ldots,i_{n},j_{1},j_{2},\ldots,j_{M}\in\{0,1\},M=\lceil\log(m+1)\rceil\}.

Definition 1.

For each k=1,,mk=1,\cdots,m, unitary operator UkU_{k} is defined as: for any |y1,,yn{|i1,i2,,in:i1,i2,,in{0,1}}|y_{1},\cdots,y_{n}\rangle\in\{|i_{1},i_{2},\ldots,i_{n}\rangle:i_{1},i_{2},\ldots,i_{n}\in\{0,1\}\} and for any c{0,1,,m}c\in\{0,1,\cdots,m\},

Uk|y1,,yn|cC\displaystyle U_{k}|y_{1},\cdots,y_{n}\rangle|c\rangle_{C} (30)
=\displaystyle= {|y1,,yn|cC,Ck is true under the assignment y1,,yn;|y1,,yn|(c+1)mod(m+1)C,Ck is false under the assignment y1,,yn.\displaystyle\left\{\begin{array}[]{lcl}|y_{1},\cdots,y_{n}\rangle|c\rangle_{C},&&C_{k}\text{ is true under the assignment $y_{1},\cdots,y_{n}$};\\ |y_{1},\cdots,y_{n}\rangle|(c+1)\bmod(m+1)\rangle_{C},&&C_{k}\text{ is false under the assignment $y_{1},\cdots,y_{n}$}.\end{array}\right. (33)
Definition 2.

For each k=1,,mk=1,\cdots,m, unitary operator UkU_{k}^{\prime} is defined as: for any |y1,,yn{|i1,i2,,in:i1,i2,,in{0,1}}|y_{1},\cdots,y_{n}\rangle\in\{|i_{1},i_{2},\ldots,i_{n}\rangle:i_{1},i_{2},\ldots,i_{n}\in\{0,1\}\} and for any c{0,1,,m}c\in\{0,1,\cdots,m\},

Uk|y1,,yn|cC\displaystyle U_{k}^{\prime}|y_{1},\cdots,y_{n}\rangle|c\rangle_{C} (34)
=\displaystyle= {|y1,,yn|cC,Ck is true under the assignment y1,,yn;|y1,,yn|(c1)mod(m+1)C,Ck is false under the assignment y1,,yn.\displaystyle\left\{\begin{array}[]{lcl}|y_{1},\cdots,y_{n}\rangle|c\rangle_{C},&&C_{k}\text{ is true under the assignment $y_{1},\cdots,y_{n}$};\\ |y_{1},\cdots,y_{n}\rangle|(c-1)\bmod(m+1)\rangle_{C},&&C_{k}\text{ is false under the assignment $y_{1},\cdots,y_{n}$}.\end{array}\right. (37)
Input: A Boolean function ff that is a 3CNF with representation C1C2CmC_{1}\land C_{2}\land\cdots\land C_{m}.
An assignment (denoted as y1,,yny_{1},\cdots,y_{n}) of its variables x1,,xnx_{1},\cdots,x_{n}.
Output: (1)f(y1,,yn)|y1yn(-1)^{f(y_{1},\cdots,y_{n})}|y_{1}\cdots y_{n}\rangle
1Initialize state |y1yn|0C|y_{1}\cdots y_{n}\rangle|0\rangle_{C}, where register CC is log(m+1){\lceil\log(m+1)\rceil}-qubit.
2Apply U1,,UmU_{1},\cdots,U_{m} in sequence.                       
3Apply Z0Z_{0} to register CC, where Z0|xC={|xC,x=0;|xC,x0.Z_{0}|x\rangle_{C}=\left\{\begin{array}[]{rcl}-|x\rangle_{C},&&x=0;\\ |x\rangle_{C},&&x\neq 0.\end{array}\right.
4Apply Um,,U1U_{m}^{\prime},\cdots,U_{1}^{\prime} in sequence.                       
Algorithm 6 Compute 3CNF
Refer to caption
Figure 4: Circuit of Algorithm 6

Next, we give the proof of correctness of Algorithm 6.

Theorem 5.

The final state of Algorithm 6 is (1)f(y1,,yn)|y1,,yn|0log(m+1)(-1)^{f(y_{1},\cdots,y_{n})}|y_{1},\cdots,y_{n}\rangle|0\rangle^{\otimes\lceil\log(m+1)\rceil}.

Proof.

Denote y=(y1,,yn)y=(y_{1},\cdots,y_{n}), and let α1(y),,αm(y)\alpha_{1}(y),\cdots,\alpha_{m}(y) be defined as:

αk(y)={1,Ck is false under the assignment y1,,yn;0,Ck is true under the assignment y1,,yn,\alpha_{k}(y)=\left\{\begin{array}[]{rcl}1,&&C_{k}\text{ is false under the assignment $y_{1},\cdots,y_{n}$};\\ 0,&&C_{k}\text{ is true under the assignment $y_{1},\cdots,y_{n}$},\end{array}\right.

for k=1,,mk=1,\cdots,m. According to the definition of each UkU_{k}, we have

Uk|y1yn|cC=|y1yn|c+αk(y)C,U_{k}|y_{1}\cdots y_{n}\rangle|c\rangle_{C}=|y_{1}\cdots y_{n}\rangle|c+\alpha_{k}(y)\rangle_{C}, (38)

for k=1,,mk=1,\cdots,m and c=0,1,,m1c=0,1,\cdots,m-1. Therefore we have

UkU1|y1yn|0C=|y1yn|j=1kαj(y)C,U_{k}\cdots U_{1}|y_{1}\cdots y_{n}\rangle|0\rangle_{C}=|y_{1}\cdots y_{n}\rangle|\sum_{j=1}^{k}\alpha_{j}(y)\rangle_{C}, (39)

for k=1,,mk=1,\cdots,m. Hence, after step 2, the quantum state is

UmU1|y1yn|0C=|y1yn|j=1mαj(y)C,U_{m}\cdots U_{1}|y_{1}\cdots y_{n}\rangle|0\rangle_{C}=|y_{1}\cdots y_{n}\rangle|\sum_{j=1}^{m}\alpha_{j}(y)\rangle_{C}, (40)

where j=1mαj(y)m\sum_{j=1}^{m}\alpha_{j}(y)\leq m. Since f(y1,,yn)=1f(y_{1},\cdots,y_{n})=1 if and only if j=1mαj(y)=0\sum_{j=1}^{m}\alpha_{j}(y)=0, we in step 3 obtain

Z0|j=1mαj(y)C=(1)f(y1,,yn)|j=1mαj(y)C.Z_{0}|\sum_{j=1}^{m}\alpha_{j}(y)\rangle_{C}=(-1)^{f(y_{1},\cdots,y_{n})}|\sum_{j=1}^{m}\alpha_{j}(y)\rangle_{C}. (41)

Similarly, in step 4, we can see that

UkUm(1)f(y1,,yn)|y1yn|j=1mαj(y)C=(1)f(y1,,yn)|y1yn|j=1k1αj(y)C,U_{k}^{\prime}\cdots U_{m}^{\prime}(-1)^{f(y_{1},\cdots,y_{n})}|y_{1}\cdots y_{n}\rangle|\sum_{j=1}^{m}\alpha_{j}(y)\rangle_{C}=(-1)^{f(y_{1},\cdots,y_{n})}|y_{1}\cdots y_{n}\rangle|\sum_{j=1}^{k-1}\alpha_{j}(y)\rangle_{C}, (42)

for k=2,,mk=2,\cdots,m. When k=1k=1, we get

U1Um(1)f(y1,,yn)|y1yn|j=1mαj(y)C=(1)f(y1,,yn)|y1yn|0C.U_{1}^{\prime}\cdots U_{m}^{\prime}(-1)^{f(y_{1},\cdots,y_{n})}|y_{1}\cdots y_{n}\rangle|\sum_{j=1}^{m}\alpha_{j}(y)\rangle_{C}=(-1)^{f(y_{1},\cdots,y_{n})}|y_{1}\cdots y_{n}\rangle|0\rangle_{C}. (43)

Consequently, we have completed the proof. ∎

Remark 4.

We use log(m+1){\lceil\log(m+1)\rceil} ancillary qubits to implement the transformation from |y1,,yn|y_{1},\cdots,y_{n}\rangle to (1)f(y1,,yn)|y1,,yn(-1)^{f(y_{1},\cdots,y_{n})}|y_{1},\cdots,y_{n}\rangle. Moreover, the construction of operators Uk,UkU_{k},U_{k}^{\prime} (k=1,,m)(k=1,\cdots,m) only depends on CkC_{k}. For example, suppose Ck=(x1¬x3¬x4)C_{k}=(x_{1}\lor\neg x_{3}\lor\neg x_{4}) for some kk, since CkC_{k} is false if and only if x1=0,x3=1x_{1}=0,x_{3}=1 and x4=1x_{4}=1, we know UkU_{k} and UkU_{k}^{\prime} can be construted as Figure 5, where the operators ADDADD and SUBSUB act as follows:

ADD|cC=|(c+1)mod(m+1)C,ADD|c\rangle_{C}=|(c+1)\bmod(m+1)\rangle_{C}, (44)
SUB|cC=|(c1)mod(m+1)CSUB|c\rangle_{C}=|(c-1)\bmod(m+1)\rangle_{C} (45)

for any c{0,1,,m}c\in\{0,1,\cdots,m\}. The operators ADDADD and SUBSUB can be constructed by means of using O(log(m+1))O(\lceil\log(m+1)\rceil) elementary gates with O(log(m+1))O(\lceil\log(m+1)\rceil) ancillary qubits [25]. According to the similar method, the construction of each UkU_{k} and UkU_{k}^{\prime} can be generalized to general case of CkC_{k} with number of variable more than 3.

Refer to caption
Figure 5: Constructions for UkU_{k} and UkU_{k}^{\prime}.

Due to Algorithm 6, we have the following theorem.

Theorem 6.

Let Boolean function f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} be a 3CNF with mm clauses. Then the oracle Zf|x=(1)f(x)|xZ_{f}|x\rangle=(-1)^{f(x)}|x\rangle can be realized by using O(mlogm)O(m\log m) elementary gates with O(logm)O(\log m) ancillary qubits.

Proof.

By means of Algorithm 6, the oracle Zf|x=(1)f(x)|xZ_{f}|x\rangle=(-1)^{f(x)}|x\rangle can be realized by operators U1,U2,,Um,Z0U_{1},U_{2},\cdots,U_{m},Z_{0},U1,U2,,UmU_{1}^{\prime},U_{2}^{\prime},\cdots,U_{m}^{\prime}.

The operator ADDADD or SUBSUB can be constructed in terms of using O(log(m+1))O(\lceil\log(m+1)\rceil) elementary gates with O(log(m+1))O(\lceil\log(m+1)\rceil) ancillary qubits [25]. Hence, each UkU_{k} or UkU_{k}^{\prime} can be constructed by using O(log(m+1))O(\lceil\log(m+1)\rceil) elementary gates with O(log(m+1))O(\lceil\log(m+1)\rceil) ancillary qubits. Z0Z_{0} is a muti-qubit controlled gate and can be constructed by using O(log(m+1))O(\lceil\log(m+1)\rceil) 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 fi(x)=f(xyi)f_{i}(x)=f(xy_{i}) (i=1,2,,2t1i=1,2,\ldots,2^{t}-1) are needed, where f:{0,1}n{0,1}f:\{0,1\}^{n}\rightarrow\{0,1\} is given, yi{0,1}ty_{i}\in\{0,1\}^{t} is the binary representation of ii and x{0,1}ntx\in\{0,1\}^{n-t}. If ff is a 3CNF, then fif_{i} is also a 3CNF and usually can be simplified with classical method based on the known variables yiy_{i} to the 3CNF of ff. Since fif_{i} is a 3CNF, by Theorem 6, we can realize its oracle with O(milogmi)O(m_{i}\log m_{i}) elementary gates and O(logmi)O(\log m_{i}) ancillary qubits, where mim_{i} is the number of clauses in the 3CNF of fif_{i}. Therefore, for any positive integer tt, the time complexity of realizing the oracles for f0,f1,,f2t1f_{0},f_{1},\cdots,f_{2^{t}-1} in parallel is O(maxi{0,1,,2t1}milogmi)O(\max_{i\in\{0,1,\cdots,2^{t}-1\}}m_{i}\log m_{i}).

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 2k2^{k} 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 i=1riπ42nkbi+2nk+2ta+1\sum_{i=1}^{r_{i}}\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n-k}}{b_{i}}}\rfloor+\lceil\sqrt{2^{n-k}}\rceil+2t_{a}+1 for some 1bia1\leq b_{i}\leq a, where ri2ta+1r_{i}\leq 2t_{a}+1 and ta=2πa+11t_{a}=\lceil 2\pi\sqrt{a}+11\rceil, versus π42na\lfloor\frac{\pi}{4}\sqrt{\frac{2^{n}}{a}}\rfloor of Grover’s algorithm, where nn is the number of input bits of problem, but the number of input bits for subfunctions is nkn-k.

In particular, if |x{0,1}n|f(x)=1}|=a=1|x\in\{0,1\}^{n}|f(x)=1\}|=a=1, then our distributed Grover’s algorithm in parallel only needs π42nk\lfloor\frac{\pi}{4}\sqrt{2^{n-k}}\rfloor queries, versus π42n\lfloor\frac{\pi}{4}\sqrt{2^{n}}\rfloor queries of Grover’s algorithm.

For any Boolean function ff with CNF having mm clauses, we have proposed an efficient algorithm of constructing quantum circuit for realizing the oracle Zf|x=(1)f(x)|xZ_{f}|x\rangle=(-1)^{f(x)}|x\rangle corresponding to ff. The algorithm’s time complexity is O(mlogm)O(m\log m). According to Remark 5, the time complexity of realizing the oracles in our distributed Grover’s algorithm in parallel is at most O(mlogm)O(m\log m), where mm 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.