# Multi-step quantum algorithm for solving the -bit exact cover problem

###### Abstract

We present a multi-step quantum algorithm for solving the -bit exact cover problem, which is one of the NP-complete problems. Unlike the brute force methods have been tried before, in this algorithm, we showed that by applying the clauses of the Boolean formula sequentially and introducing non-unitary operations, the state that satisfies all of the clauses can be projected out from an equal superposition of all computational basis states step by step, and the search space is reduced exponentially. The runtime of the algorithm is proportional to the number of clauses, therefore scales polynomial to the size of the problem. Our results indicate that quantum computers may be able to outperform classical computers in solving NP-complete problems.

###### pacs:

03.67.Ac^{†}

^{†}thanks: Correspondence to wanghf@mail.xjtu.edu.cn

## I Introduction

The mechanism of nature selection has produced the whole of Life on earth in a surprisingly short time of about three and half billion years. A computational question inspired by this phenomenon is chastain () “what algorithm could possibly achieve all this in such a short time?” Can we develop algorithms using this mechanism? The -bit exact cover problem (EC) is a hard problem in computer science and mathematics. In this problem, one has to find out if there exists an assignment(s) of an -bit string that satisfies a Boolean formula of clauses. The EC problem shares similar property as the evolution of life: lives/assignments have to fit to the changing environments/clauses to survive. Here, we propose a multi-step quantum algorithm for solving this problem.

Quantum computing offers speedup in solving a number of problems shor (); grover (); childs (); nori (); sl (): factorizing large integers, searching unsorted databases, and simulating quantum systems, etc. The question of whether there are polynomial algorithms for NP-complete (NPC) problems is an unsolved problem in mathematics cook (); seife (). The EC problem is a restricted version of the -bit satisfiability problem farhi1 () and is one of the NPC problems. A quantum adiabatic algorithm was proposed for solving the EC problem on a quantum computer farhi1 (); farhi2 (), and it was found later that it cannot solve the EC problem efficiently dam (); znidaric (); farhi3 (); farhi4 (); young1 (). The question of whether NPC problems can be solved in polynomial time on a quantum computer is an open question.

In most of the methods that have been tried, the EC problem is turned to a search problem directly. Classically, the cost for searching an item in a space of items scales as (). Grover’s algorithm provides quadratic speedup over classical algorithms for the search problem on a quantum computer. While the cost can be reduced with the help of some tools. Let’s see an example: there are balls, all of them have equal weights except one that is lighter than the others. How to find out the lighter ball? If we randomly pick up a ball and compare its weight with the others, this will take about trials on average. If we have a balance, then how many times do we have to use the balance to find out the lighter ball? According to information theory, the number of times the balance has to be used is . The procedure is as follows: divide all the balls into groups, each group has , and balls, respectively. Pick up the two groups that both have balls, and use the balance to determine if they have equal weights. If the answer is positive, pick the group with balls and divide it into groups again: ; otherwise, take the group that is lighter and divide it into three new groups, . One can continue this process until the lighter ball is found.

From the above example, we can see that the search space is reduced exponentially by using the balance, therefore the cost of searching the target ball is reduced exponentially. In the algorithm we proposed in this work, by constructing a tool that has similar property as the balance and applying the clauses of the Boolean formula sequentially, the search space of the EC problem is reduced exponentially. The runtime of the algorithm is proportional to the number of clauses, therefore scales polynomial to the size of the problem.

## Ii The algorithm

The EC problem on a quantum computer can be formulated as follows: the -bit instance of satisfiability is a Boolean formula with clauses

(1) |

where each clause is true or false depending on the values of a subset of the bits, and each clause contains three bits. The clause is true if and only if one of the three bits is and the other two are . The task is to determine whether one (or more) of the assignments satisfies all of the clauses, that is, makes formula () true, and find the assignment(s) if it exists. Let , and be the bits associated with clause , for each clause , we define a function

(2) |

The Hamiltonian for clause is defined as

(3) |

where is the -th bit and has value or . If the ground state energy of the Hamiltonian is zero, the ground state is a superposition of , where each bit string satisfies clause . The dimension of computational basis states (CBS) is . A solution to the EC problem is a state which is a superposition of CBS that satisfies all of the clauses, the eigenvalue of the state is zero for every Hamiltonian for all of the clauses.

In this algorithm, we prepare an equal superposition of all CBS of bits as initial state of the problem, and the clauses are applied in steps sequentially. In each step, the state that satisfies the corresponding clause is projected out from the previous state. This procedure is based on resonance phenomenon. The eigenstates of the Hamiltonian for clause have eigenenergies of either or , the energy of the ground state of is if it is an equal superposition of basis states that satisfy the clause . For a probe qubit coupled to a system, the probe qubit exhibits dynamical response when it resonates with a transition in the system. The system can be guided to evolve to its ground state by inducing resonance between the probe qubit and a transition in the system whf1 (). Based on this idea, we can obtain the ground state of with eigenvalue zero. A detailed procedure of the algorithm is as follows.

We construct a quantum register of qubits, which contains one ancilla qubit and an -qubit quantum register that represents the EC problem of dimension . A probe qubit is coupled to and the Hamiltonian of the entire -qubit system is

(4) |

where and are two- and -dimensional identity operators, respectively, and are the Pauli matrices. The first term in the above equation is the Hamiltonian of the probe qubit, the second term is the Hamiltonian of the register , and the third term describes the interaction between the probe qubit and . Here, is the frequency of the probe qubit (), and is the coupling strength between the probe qubit and , and . The Hamiltonian of is in the form

(5) |

We set the frequency of the probe qubit as , and let where are the CBS of the qubits. The procedure of the algorithm is as follows:

For :

Prepare the probe qubit in its excited state and the register in state , which is the eigenstate of with eigenvalue .

Construct Hamiltonian for clause , and Hamiltonian of the algorithm as shown in Eq. (). Then implement time evolution operator on the -qubit system.

Read out the state of the probe qubit by performing a measurement on the probe qubit in its computational basis.

Repeat steps – until a decay of the probe qubit is observed, and run a purification procedure as described below.

Take the state of the last qubits obtained from step as input state of the problem . Set , repeat steps -, until run over all of the clauses.

The state of the last qubits encodes the solution to the EC problem, that is, all assignments of the bits that satisfy all of the clauses. The quantum circuit for the -th round of the algorithm is shown in Fig. .

In each round of the algorithm, the state in step of the algorithm can be purified to make it closer to the solution state of the round of the algorithm, that is, the eigenstate of the Hamiltonian with eigenvalue , by performing partial measurements on the probe qubit nakazato (). This can be run on the circuit in Fig. . In step of the -th round of the algorithm, when the measurement result on the probe qubit is in state , the state of the last qubits is set as the input state of the problem, and the clause Hamiltonian is unchanged. The entire -qubit system is set in an initial state of , and evolve with Hamiltonian for time , then read out the state of the probe qubit by performing a measurement on the probe qubit. Repeat these steps until a decay of the probe qubit to its ground state is observed. This procedure can be repeated to improve the amplitude of the solution state of the round of the algorithm, while compress the amplitude of non-solution state of the algorithm. In each round of the algorithm, the purification procedure can be repeated for a number of times until a total number of times of the measurements on the probe qubit are in its ground state .

## Iii Efficiency of the algorithm

We now analyze the efficiency of the algorithm. In the first round of the algorithm, the eigenstate obtained from the algorithm is the ground state of the Hamiltonian with eigenvalue , which is an equal superposition of all CBS that satisfy clause . The probability for obtaining the state is , where is the number of CBS that satisfy clause . In this round of the algorithm, the state space of the problem is reduced to .

In the second round of the algorithm, we set the state as input state of the problem, construct Hamiltonian for clause , and run the algorithm. The eigenstate of the Hamiltonian with eigenvalue is projected out from the state that satisfies clause , therefore is an equal superposition of basis states that satisfy clauses . The probability for obtaining state is where is the number of CBS that satisfy clauses . It depends on clause , and can be one of the three values of {}, which corresponds to the cases where clause has zero, one, or two bits same as clause . In the second round, the state space of the problem is reduced to .

In the third round of the algorithm, the state is set as input state of the problem, the Hamiltonian is constructed for clause . The eigenstate of the Hamiltonian with eigenvalue can be projected out from the state . Since the state satisfies clauses , the state is an equal superposition of basis states that satisfy clauses . The probability where is the number of CBS that satisfy clauses . In the following we discuss possible values of .

We define a function , which gives the number of bits in clause that are same as that of in clause set {} and . The function can be , or . We now discuss the possible values of for obtaining the state from state when takes different values. It is obvious that when . For , the smallest value that can be is . In the case of , the smallest value for is , while the next smallest value of . For , the smallest value of , and the next smallest value of . These estimations consider the maximal dimension of the state space that the bits in clause associated with the clauses in the clause set {}.

From the above analysis, we can see that the smallest possible value of is , while the next smallest value of is finite. This means we can conclude whether the probability for obtaining the state is zero or not in finite number of trials in each round of the algorithm.

In the following, we discuss the evolution time required for obtaining the eigenstate of a clause Hamiltonian with eigenvalue in each round of the algorithm. We take the -th round of the algorithm for obtaining state for instance.

In the -th round, the input state of the problem is , in basis of {, , }, where states and are the eigenstates of with eigenvalues and , respectively, are the CBS that satisfy clauses , and are the CBS that satisfy clauses but do not satisfy clause , the Hamiltonian of the algorithm in Eq. () can be written as

(6) |

where . Let , the Schrödinger equation with the above Hamiltonian can be solved exactly and

(7) |

where are eigenvalues of the Hamiltonian matrix in Eq. ().

When a decay of the probe qubit occurred, the state can be evolved to state with probability close to one at time , as long as is finite. As we have discussed above, is finite when . In Fig. , by setting and , we show the variation of and with respect to evolution time . The variation of with respect to evolution time is shown in Fig. . We can see that is very small and in most of the evolution time . By running the algorithm for different evolution time to obtain the decay dynamics of the probe qubit whf2 (), one can locate the optimal evolution time in which the decay probability of the probe qubit reaches its maximal value and is close to one. Consider the degeneracy of the eigenstates of the clause Hamiltonian with eigenvalues of and , the probabilities of the system being in state and are and , respectively. By running the purification procedure, the amplitude of the state can be greatly improved while the amplitude of the state can be compressed to be very small and close to zero in polynomial number of trials. This is analyzed in detail in the next section.

In the case of , the Hamiltonian in basis of can be written as . With the initial state being set as , the decay probability of the probe qubit is . It is very small for and oscillates between and . The dynamics of the probe qubit in this case can be well distinguished from that of the probe qubit in the resonance case whf2 ().

In the algorithm, the total number of trials for executing the algorithm is proportional to the number of clauses as . And since is finite when , the amplitudes of the eigenstates that contain the solution to the problem can be amplified to close to unity in finite time by setting to be small but finite. The maximum number of clauses for an -bit string is , in each round of the algorithm, the evolution time of the algorithm is finite when , and the case when can be determined in finite number of trials. Therefore the runtime of the algorithm scales polynomial with the number of bits of the EC problem.

The time evolution operator in the algorithm can be implemented efficiently through the Trotter formula nc () on a quantum computer.

The cost of the algorithm will be different if we apply the clauses in different order. We use an -bit EC problem as an example. The -bit sets of the clauses are applied in the order of {}, {}, {}, {}, {}, and {}. In this case, the corresponding probabilities of are {}, respectively. The solution to the EC problem is . If we set the order of the clauses as {}, {}, {}, {}, {}, and {}, the corresponding probabilities of are {}. The cost of the algorithm is less in the second case.

## Iv Error analysis

Suppose in the -th round of the algorithm, the probability of the system being in state is , and in state is , then the success probability of the algorithm is . This shows that the success probability of the algorithm can be very small when is large. Fortunately, by running the purification procedure in each round of the algorithm, the state of the system can be purified to be very close to the solution state of the round of the algorithm, the error can be compressed to be very small such that the algorithm can still have high success probability. We now analyze the effect of the purification procedure in detail.

We define a measurement as “successful measurement” only if the measurement result on the probe qubit is in its ground state . In step of the -th round of the algorithm, after a successful measurement on the probe qubit at evolution time , the entire system is collapsed to state , where . We take the state of the last qubits of the system as input state of the problem and run the purification procedure, the probability of the system being evolved to state , which is the solution state of the round of the algorithm, can be further improved.

From Fig. and Fig. , we can see that and is close to one. Therefore in the purification procedure, we perform a measurement on the probe qubit after the system being evolved for time . This guarantees that both the decay probability of the probe qubit and the probability of the system being evolved to the solution state of the round of the algorithm is close to one. If the measurement result on the probe qubit is in state , the state of the register remain unchanged. When a successful measurement is performed, the operation acts on the register is , this operator in general is a non-unitary operator. In step () of the algorithm, we can repeat the purification procedure until successful measurements on the probe qubit are achieved, then the register is evolved to state . In basis of {, }, is a two dimensional matrix whose eigenvalues and are discrete and non-degenerate and . In this process, when is large, the state of the register converges to the eigenstate of with corresponding eigenvalue nakazato ().

We now estimate the effect of the operator acting on the register . In step () of the algorithm, when the first successful measurement on the probe qubit is achieved, the probability of the system being in state is and , while the probability of the system being in state is and . Then in the purification procedure, the input state of the algorithm is .

In basis of {, , }, the Hamiltonian of the algorithm is in the form

(8) |

This purification procedure can be iterated for a number of times until successful measurements on the probe qubit are obtained. With the same initial state and evolution time , as the parameter becomes larger, the probability of the system being evolved to state is larger whf1 (). Therefore we have the following relation: , and , the converge speed to the state of the system is accelerated in the purification process. The first iteration provides the lowest transformation speed to state . From Fig. and Fig. , we can see that , where . Based on this, we can conclude that after successful measurements on the probe qubit, the upper bound for the error (the probability of the system being in state ) in a round of the algorithm is . The probability for the system being in state is . And unlike the approach in Ref. nakazato (), we do not require continuous successful measurements of the probe qubit in the purification process of this algorithm. The state that is to be purified is updated in each iteration of the purification procedure. Therefore successful measurements on the probe qubit can be achieved in polynomial number of trials.

We make a numerical estimation on the success probability of the algorithm. From Fig. and Fig. , we can see that , then . After successful measurements on the probe qubit, the error in each round of the algorithm can be controlled to be smaller than . The success probability of the algorithm . Fig. shows the variation of the success probability of the algorithm vs. . From the figure we can see that the success probability of the algorithm converges quickly to one even after a few purification iterations.

In practice, the state in each round of the algorithm can be purified in a few iterations such that the state is very close to the solution state of the round of the algorithm, as in the example above, by setting , and , the errors are {}, for , respectively. From the expression , we can see that the algorithm can still have a high success probability as long as the error is compressed to a certain degree in each round of the algorithm, since the error decreased exponentially with the number of successful measurements. For example, the success probability of the algorithm can be , if the error in each round of the algorithm is controlled smaller than . In real implementation of the algorithm, a polynomial large success probability of the algorithm can be achieved by performing only a few iterations of the purification procedure in each round of the algorithm, e.g., by performing only one successful measurement on the probe qubit, the error can be controlled to a degree that guarantees the success probability of the algorithm for clauses.

## V Discussion

For an -bit EC problem, classically the probability for obtaining a solution to the problem is , where is the number of the assignments that satisfy all of the clauses according to the algorithm. In the algorithm, the probability is decomposed into steps , and each is finite. By applying the clauses sequentially, and using a non-unitary operator through introducing partial measurement, the state that satisfies all of the clauses is projected out step by step. The dimension of the search space of the problem is reduced exponentially in each round of the algorithm. This makes the run time of the algorithm scales linearly with the number of clauses, thus scales polynomial with the number of bits of the problem.

In each round of the algorithm, a state that satisfies the current clause and all of the clauses in previous rounds of the algorithm can be obtained with finite success probability. We introduce a purification procedure which is based on resonance and partial measurement to purify the solution state of each round of the algorithm, the error in each round of the algorithm decreases exponentially with the number successful measurements on the probe qubit. Therefore the success probability of the algorithm can be polynomial large by compressing the error through the purification procedure, which can be can be achieved in finite number of trials.

###### Acknowledgements.

We thank Dr. Song Liu for helpful discussions. This work was supported by the National Natural Science Foundation of China (Grant No. 11275145).## References

- (1) E. Chastain, A. Livnat, C. Papadimitriou and U. Vazirani, Proc. Natl. Acad. Sci. 111, 10620 (2014).
- (2) P. Shor, Proc. 35th Ann. Symp. on Found. of Comp. Sci., 124–134 (IEEE Comp. Soc. Press, Los Alamitos, CA, 1994).
- (3) L. K. Grover, Phys. Rev. Lett. 79, 325-328 (1997).
- (4) A. M. Childs and W. van Dam, Rev. Mod. Phys. 82(1), 1-52 (2010).
- (5) I. Buluta and F. Nori, Science, 326, 108 (2009).
- (6) S. Lloyd, Science 273, 1073 (1996).
- (7) S. A. Cook, Millennium Problems (Clay Mathematics Institute, 2000), http://www.claymath.org/millennium.
- (8) C. Seife, Science 309, 96 (2005).
- (9) E. Farhi, J. Goldstone, and S. Gutmann, e-print: quant-ph/0007071v1 (2000)
- (10) E. Farhi, J. Goldstone, S. Gutmann, J. Lapan, A. Lundgren, D. Preda, Science 292, 472-475 (2001).
- (11) W. van Dam, M. Mosca, and U. Vazirani, in Proceedings of the th IEEE Symposium on Foundations of Computer Science (FOCS 2001) (IEEE Computer Society, Washington, DC, 2001), p. 279-287.
- (12) M. Žnidarič, and M. Horvat, Phys. Rev. A 73, 022329 (2006).
- (13) E. Farhi, J. Goldstone, and S. Gutmann, e-print: quant-ph/0208135 (2002).
- (14) E. Farhi, et al., Int. J. Quantum. Inform. 6, 503-516 (2008).
- (15) I. Hen, A. P. Young, Phys. Rev. E 84, 061152 (2011).
- (16) H. Wang, e-print arXiv: 1510.00820v1 (2015).
- (17) H. Nakazato, T. Takazawa and K. Yuasa, Phys. Rev. Lett. 90, 060401 (2003).
- (18) H. Wang, Phys. Rev. A 93, 032301 (2016).
- (19) M. A. Nielsen and I. L. Chuang, Quantum computation and quantum information. (Cambridge Univ. Press, Cambridge, England, 2000).