2026 Volume 35 Issue 9
Article Contents

Hao-Peng Wang, Ji-Ze Cai, Xiong Fang, Ming-Yong Ye, Gong-Wei Lin, Xiu-Min Lin. Unit-probability quantum search for all solutions[J]. Chinese Physics B, 2026, 35(9): 090304. doi: 10.1088/1674-1056/ae1f7e
Citation: Hao-Peng Wang, Ji-Ze Cai, Xiong Fang, Ming-Yong Ye, Gong-Wei Lin, Xiu-Min Lin. Unit-probability quantum search for all solutions[J]. Chinese Physics B, 2026, 35(9): 090304. doi: 10.1088/1674-1056/ae1f7e

Unit-probability quantum search for all solutions

  • Received Date: 15/09/2025
    Accepted Date: 03/11/2025
    Available Online: 01/09/2026
通讯作者: 陈斌, bchen63@163.com
  • 1. 

    沈阳化工大学材料科学与工程学院 沈阳 110142

  1. 本站搜索
  2. 百度学术搜索
  3. 万方数据库搜索
  4. CNKI搜索

Figures(4)  /  Tables(1)

Article Metrics

Article views(77) PDF downloads(0) Cited by(0)

Access History

Unit-probability quantum search for all solutions

Abstract: The objective of Grover’s quantum algorithm is to efficiently identify a single solution within a search space. However, there are search problems that require finding all possible solutions. A direct, repeated application of Grover’s algorithm is unsuitable for these problems, as it lacks an internal mechanism to avoid rediscovering previous solutions. Here we introduce a quantum algorithm that efficiently and deterministically discovers all solutions by preparing special initial states of the index register, a step accomplished by leveraging knowledge from solutions obtained during execution. We experimentally demonstrate our algorithm on a superconducting quantum processor. This work provides quantum examples for search scenarios with some knowledge about solutions.

1.   Introduction
  • Quantum computing represents a novel computational paradigm capable of solving certain problems more efficiently than classical computing. The realization of this advantage depends on progress in both hardware platforms and algorithmic development. Many physical systems have been proposed for implementing quantum computing.[1] Superconducting systems are currently considered one of the most promising platforms, and the optimization of their architectures and hardware remains an ongoing endeavor.[2,3] Quantum algorithms provide sophisticated methods for leveraging quantum hardware.[4–6] Grover’s quantum search algorithm stands as one of the most prominent quantum algorithms.[7] It achieves a quadratic speedup over classical counterparts for unstructured search problems and serves as a critical technique for achieving computational speedups across diverse applications, including solving vehicle routing problems,[8] discovering binary constant weight codes,[9] path-planning for swarm robotics,[10] and neural network training.[11] In addition to Grover’s algorithm, quantum walks can also be used for search problems.[12–14]

    The original Grover’s algorithm is designed to identify a single solution among numerous candidates. Its core component, the Grover operator, consists of an oracle and a diffuser. The algorithm initializes the index register to a uniform superposition state, applies the Grover operator consecutively, and culminates in a measurement. However, the algorithm does not always guarantee success with unit probability. Several modified versions have been proposed to overcome this limitation. For instance, Brassard et al.,[15] Høyer,[16] and Long[17] achieved exact search by tailoring the oracle and diffuser phases. Nevertheless, these methods require modifying the original oracle, which is infeasible in certain practical settings. The D2p scheme circumvented this issue by employing two diffuser phases while keeping the original oracle unchanged,[18] but it needed to solve complex equations. The FXR method improved D2p to arbitrary oracle phases, i.e., the oracle phase can be user-adjustable.[19] One recent approach initializes the quantum register using the information of a known non-solution while preserving the original oracle, thereby achieving unit success probability.[20] This demonstrates that the use of prior knowledge can effectively simplify the quantum search process.

    Different from the previously mentioned investigations, this paper focuses on search scenarios aimed at identifying all solutions with unit probability. Similar to the approach in Ref. [20], our method simplifies the quantum search process by incorporating prior knowledge of known solutions while keeping the original oracle unchanged. Specifically, we begin by testing a randomly selected index y to determine whether it is a solution. If y is not a solution, we apply the method from Ref. [20] to find one solution with unit probability. Conversely, if y is a solution, we instead employ the technique from Section 3 to identify a new solution. Once a set of solutions has been identified, the search for the next new solution proceeds by preparing the initial state of the index register in a specialized form that incorporates information from these known solutions. The key factor in obtaining unit success probability is the use of the knowledge of known solutions to adjust the angle between the initial state and the target state. We note that directly applying Grover’s algorithm to identify all solutions is inadequate, as its oracle cannot exclude known solutions. As a result, the final superposition before measurement still contains all solutions, including those already identified, which prevents guaranteed discovery of a new solution.

    The paper is organized as follows. Section 2 provides a brief review of Grover’s algorithm. Section 3 presents the technique for identifying a new solution when one solution is already known. In Section 4, we introduce the complete algorithm for finding all solutions. Finally, Section 5 presents experimental results of the proposed algorithm on a superconducting quantum processor.

2.   A brief review of Grover’s algorithm
  • Consider a search space consisting of N distinct items. Each item is uniquely identified by an index x, where x ∈ {0, 1, 2, …, N – 1}. This search space is unstructured, meaning there is no underlying order or classification that can be exploited to guide the search. The access to the solution criterion is provided by an oracle, which acts as a black-box function f. The objective of a typical search problem is to find a solution with a high probability of success.

    Grover’s quantum algorithm achieves a quadratic reduction in oracle queries compared to classical search. The core of it is the Grover operator G, which consists of two parts: G = WO. Here O is the quantum oracle and W is the diffuser. The oracle O recognizes and marks solutions by phase-shifting them. Assume the search space has dimension N = 2n; the action of an oracle call on computational basis |x〉 is written as[21]

    where |x〉 is the n-qubit index register state, and f is the oracle function that takes index x as input satisfying f(x) = 1 if x is a solution, and f(x) = 0 otherwise. The diffusion operator is defined as

    where |ψ〉=H⊗n|0〉⊗n is the uniform superposition of all computational basis states, and H denotes the Hadamard gate, whose matrix representation is

    Grover’s algorithm begins with |ψ〉 as an initial state of the n-qubit index register. Adopt the convention that ∑x′ indicates a sum over all x which are solutions to the search problem, and ∑x″ indicates a sum over all x which are not solutions to the search problem. Two normalized states are defined as follows:

    where M is the number of solutions. The initial state |ψ〉 can be re-expressed as

    where θ=2arcsin(M/N). In the geometric representation of Grover’s algorithm as shown in Fig. 1, |l〉 and |t〉 are orthogonal vectors, with |ψ〉 represented as a vector between them at an angle θ/2 from |l〉. Each application of G rotates the state by an angle θ away from |l〉. It can be shown that after R iterations the index register will be in the state

    The algorithm concludes with measurement of the register after a proper number of iterations.

    When GR|ψ〉 is close to |t〉 (the solution superposition), measurement of the index register yields a solution with high probability. The optimal number of iterations R is

    where ⎣x⎤ denotes the integer closest to the real number x and we round halves down, e.g., ⎣3.2 ⎤ = 3, ⎣3.5 ⎤ = 3, and ⎣3.6 ⎤ = 4. After Ropt iterations of G, measuring the register will yield a solution with the maximal success probability

    Note that P is generally not unity.

3.   Finding a new solution given one known solution
  • In this section, we address search problems where one solution y is known a priori, leaving M – 1 solutions among N – 1 candidates. The objective is to identify a new solution with unit probability. We will show how to achieve the objective through modifying Grover’s algorithm.

    The following quantum algorithm achieves this objective by leveraging the prior knowledge that index y is a solution. The index register is initialized to the state:

    where the positive ε depends on N and M (its value will be specified later), and |y⊥〉 is a uniform superposition of all index states except |y〉:

    The algorithm employs the oracle Oy = PyO with

    and the diffusion operator

    Given O|y〉 = −|y〉 and Py|y〉 = −|y〉, we have Oy|y〉 = |y〉. Since Oy preserves the phase of |y〉, the state |y〉 is not identified as a solution by the Grover operator Gy = WyOy.

    Similar to Grover’s original algorithm, this algorithm ends with a measurement on the index register after applying the Grover operator Gy many times to the initial state. The initial state |ψy〉 of the index register can be divided into two parts: one is the superposition state of the M – 1 unknown solutions that will be denoted by the normalized state |ty〉, which has the expression

    Given that

    we can express the initial state as

    where

    and |ly〉 is a superposition of the non-solution states and |y〉, making it orthogonal to |ty〉. After applying R iterations of the Grover operator Gy to |ψy〉, the index register state becomes

    The parameter ε in the initial state |ψy〉 controls the value of θy (see Eq. (17)). In the geometric representation of Grover’s algorithm, the angle between the initial state |ψy〉 and the target state |ty〉 is π/2 – θy/2, where a single application of Gy rotates the state by θy toward |ty〉. The parameter ε is chosen such that Ry = (π/2 – θy/2)/θy is an integer, so that after Ry applications of Gy to |ψy〉, the index register state becomes exactly the |ty〉, i.e., GyRy|ψy〉=|ty〉. Therefore, under such an ε and Ry a final measurement will output a solution different from y with unit probability. The smallest ε satisfying that Ry = (π/2 – θy/2)/θy is an integer is

    with

    where ⎡x⎤ denotes the smallest integer greater than or equal to x. We use the above values of ε and Ry in the algorithm, as this Ry is minimal.

    In Fig. 2, we show the growth of success probability for finding a new solution as the number of Grover operator Gy iterations increases. It can be seen that the algorithm achieves unit success probability after Ry applications of Gy. The key to achieving this result lies in preparing an initial state |ψy〉 that forms a specific angle with the target state |ty〉. Such preparation utilizes the prior knowledge that y is a solution.

4.   Algorithm for finding all solutions
  • Here we consider the search problem of finding all M solutions among N candidates with unit probability. We assume M ≤ N/2 for simplicity. The algorithm’s first step is to classically test an arbitrary index y to determine whether f(y) = 1. The subsequent step depends on whether y is a solution to the search problem.

  • If index y is a solution (i.e., f(y) = 1), M – 1 solutions remain to be found. We will find these unknown solutions one by one. Suppose we have found m solutions (1 ≤ m < M, including y), and we aim to find a new solution. We use a modified version of the previous section’s technique. The index register is first prepared in the initial state

    where |fm〉 is a normalized equal superposition of all index states excluding the m found solutions. The oracle used is Oa = PyO, identical to that in the previous section. The diffusion operator is

    Since oracle Oa does not mark y as a solution, we decompose |ψa〉 into two parts: the superposition of (M – m) unknown solutions (denoted by normalized state |ta〉) and the orthogonal component. Explicitly:

    where

    and |la〉 is a superposition of non-solution states and |y〉. Similar to the previous section’s algorithm, the minimum number of Grover operator Ga = WaOa applications required to output a new solution with unit probability is

    with the specific parameter choice

    In other words, there is GaRm|ψa〉=|ta〉 and a final measurement will output a new solution. All solutions will be found by repeating the procedure.

    Thus, when y is a solution, the total oracle calls Na to find all M – 1 remaining solutions is

    which quantifies the algorithm’s resource requirements. We analyze the computational complexity of the total oracle calls Na. Since sin(x) < x for x ∈ (0, π/2), we can show that Rm is in the class of O(N/(M−m)). There is

    which implies Na is in the class of O(NM). This means there exists a constant c (independent of N and M) such that Na<cMN.

  • If index y is not a solution (i.e., f(y) = 0), all M solutions remain to be found. We will repeat the following procedure to find all solutions one by one. Assume m solutions have been found (0 ≤ m < M), a new solution is located as follows. The index register is first prepared in the initial state

    where |fm〉 is a normalized equal superposition of all index states excluding the m found solutions and y. The oracle Ob = O is the same as the original Grover’s scheme, while the diffusion operator is

    We decompose |ψb〉 into two components: the superposition of (M – m) unknown solutions (denoted by normalized state |tb〉) and an orthogonal complement. This yields

    where

    and |lb〉 consists of |y〉 and the (N – M – 1) non-solution states in |fm〉. As in the previous case, the minimum number of Grover operator Gb = WbOb applications required for unit success probability is

    with the specific parameter

    Thus, when y is not a solution, the total oracle calls to find all M solutions is

    which is also in the complexity class of O(NM).

    In a real search scenario, y is most likely not a solution to the search problem. Figure 3 demonstrates Nb as a function of M for N = 64.

  • Our described algorithm represents a specific method of finding all M solutions with unit probability, which utilizes the information of known solutions to prepare initial states for identifying new ones. It is worth noting that this is one of various possible methods.

    We can modify any unit-probability Grover-based algorithm[15–19] (initialized with a uniform superposition) to find all solutions with unit probability. In such algorithms, the oracle Os applies a phase shift of eiθ to solution states, where θ is not necessarily π since the oracle is usually modified. To find all solutions with unit probability, we can replace the oracle Os by MkOs for the k-th solution search, where Mk applies a phase shift of e−iθ to all k – 1 known solution states, thus ensuring that MkOs identifies only the yet undiscovered solutions. To analyze the complexity, suppose m solutions have already been found (0 ≤ m < M). The minimal number of oracle calls R∼m required to find the next solution in this modified setting is given by

    The total number of oracle calls to identify all M solutions is then

    A comparison between N∼b and the quantity Nb in Eq. (34) is given in Fig. 3. It reveals a key insight: although N∼b shares the same computational complexity of O(NM) as Nb, it holds that there is N∼b≥Nb as demonstrated in Fig. 3. This is because each term R∼m in Eq. (35) is greater than or equal to its counterpart Rm in Eq. (32).

5.   Experimental demonstration
  • We present experimental results for the algorithm designed to identify all solutions, as implemented on OriginQ’s “Wukong” superconducting quantum processor (we conducted the experiments on the OriginQ Cloud platform using the graphical programming tool, with the OriginQ Wukong 102 superconducting quantum processor). In our setup, the dimension of the search space is N = 4 and there are M = 2 solutions, so the index register consists of 2 qubits, which are denoted by qubit q0 and q1 (see Fig. 4). As a demonstration we set the index ‘10’ and ‘11’ as solutions. So the quantum oracle is O = Z0, which is Pauli-Z gate on the qubit q0. According to the algorithm in Section 4 we begin by testing a randomly selected index y to determine whether it is a solution.

  • Assume we select y = ‘11’ as the testing index. Fortunately it is a solution, and there is one solution to be found. According to the algorithm in Section 4, the oracle used in this case is

    where CZ01 is the controlled Z gate with q0 being the controlling qubit and q1 being the target qubit. According to Eqs. (24) and (25) with m = 1, there are

    So according to Eq. (21) the initial state in our demonstration is an equal superposition of all index states, i.e.,

    The diffusion operator Wa = 2|ψa〉〈ψa| – I used in the algorithm is

    In Fig. 4(a), we show the experimental circuit, where the first two H gates are used to prepare the index register in the initial state |ψa〉. After preparing the index register in the state |ψa〉, the Grover operator Ga = WaOa is applied for R1 = 1 times (actually what we applied is eiπGa but the global phase eiπ does not matter), then the circuit ends with a measurement on the two register qubits.

    If there were no error in the quantum processor, the final measurement would output the index ‘10’ perfectly. In our experiment, we repeat the computation for 1000 times and the results are presented in the row denoted ‘Case A’ of Table 1. The experiment only outputs the index ‘10’ with probability 0.985, which is due to the imperfection of the quantum processor.

  • Assume, unfortunately, that we select y = ‘00’ as the testing index and it turns out not to be a solution. According to the algorithm described in Section 4, the oracle used in this case is the original oracle O and there are two solutions to be found.

    To find the first solution, based on Eqs. (32) and (33) with m = 0, simple calculation shows that

    thus the initial state |ψb〉 is

    This initial state can be prepared by applying a gate UP to |00〉, i.e., |ψb0〉=UP|00〉, and the circuit for UP is shown in Fig. 4(c).[22] The diffusion operator Wb0=2|ψb0〉〈ψb0|−I used in the experiment is

    The total circuit for finding the first solution is shown in Fig. 4(b) where UP is in Fig. 4(c). Theoretically, the state prior to the final measurement is an equal superposition of |10〉 and |11〉. Consequently, the measurement will project the state into either |10〉 or |11〉 with equal probability. We repeat the computation for 1000 times and the result is shown in Table 1 ‘Case B0’ line.

    Without loss of generality, we assume the first solution found is ‘11’. To locate the second solution, we now proceed as follows. Based on Eqs. (32) and (33) with m = 1, there is

    and the required initial state is

    which can be prepared by applying a gate UP shown in Fig. 4(d) to |00〉. The diffusion operator Wb1=2|ψb1〉〈ψb1|−I in the experiment is

    The total circuit for finding the second solution is shown in Fig. 4(b) where UP is in Fig. 4(d). The ideal measurement is to output ‘10’ certainly. The number of experimental repetitions remained 1000 and the result is shown in Table 1 ‘Case B1’ line. Despite minor experimental uncertainties, the results are in good agreement with theoretical expectations.

6.   Conclusion
  • Grover’s algorithm provides a powerful quantum approach for identifying a single solution from numerous candidates with a high probability of success. This work extends its capability by introducing an algorithm that deterministically finds all solutions with unit probability. Key to our method is the iterative use of information from previously identified solutions to prepare specialized initial states for subsequent searches. Rather than modifying the oracle’s phase, our approach adjusts the angles between the initial states and the equal superposition of remaining target states, ensuring deterministic identification of new solutions. The algorithm has been successfully executed on OriginQ’s “Wukong” superconducting quantum processor, confirming its validity. Our results advance quantum search techniques for scenarios where partial information about solution spaces is available.

Figure (4)  Table (1) Reference (22)

Catalog

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return