A Polynomial Time Boundederror Quantum Algorithm for Boolean Satisfiability
Abstract
The aim of the paper is to answer a longstanding open problem on the relationship between NP and BQP. The paper shows that BQP contains NP by proposing a BQP quantum algorithm for the MAXE3SAT problem which is a fundamental NPhard problem. Given an E3CNF Boolean formula, the aim of the MAXE3SAT problem is to find the variable assignment that maximizes the number of satisfied clauses. The proposed algorithm runs in for an E3CNF Boolean formula with clauses and in the worst case runs in for an E3CNF Boolean formula with inputs. The proposed algorithm maximizes the set of satisfied clauses using a novel iterative partial negation and partial measurement technique. The algorithm is shown to achieve an arbitrary high probability of success of for small using a polynomial resources. In addition to solving the MAXE3SAT problem, the proposed algorithm can also be used to decide if an E3CNF Boolean formula is satisfiable or not, which is an NPcomplete problem, based on the maximum number of satisfied clauses.
Keywords: Quantum Algorithm, MAXE3SAT,E3SAT, Amplitude Amplification, BQP, NPhard, NPcomplete.
1 Introduction
A longstanding open problem in quantum computing is the relationship between the classes NP and BQP [2, 4]. Decision problems are in NP if yesinstances have witnesses that can be checked in polynomial time [12]. The class BQP is the quantum computing analogue of the classical class BPP (bounded error probabilistic polynomial) [6]. A problem is in BPP if there is a probabilistic classic algorithm (Turing machine with access to random bits) which makes errors (for either yes or no instances) with probability of given a wrong answer at most 1/3. The value 1/3 is arbitrary  all that is required is that the value is bounded away from 1/2. By repeated runs, the probability of failure can be made exponentially small. The problem class BQP replaces the classical algorithm with a quantum algorithm [1]. Thus a decision problem is in BQP if there is a quantum algorithm for it with probability of being wrong less than 1/3.
The common belief concerning the relationship between NP and BQP was that NP is not contained in BQP (e.g see chapter 15 of [8]). However, a recent paper by one of the current authors has shown that an NPhard problem (Graph Bisection) can be efficiently solved, with low failure probability, by a quantum algorithm [13]. This implies that NP is in fact contained within BQP, as any NP problem can be polynomially reduced to an NPhard problem. The Graph Bisection problem is, perhaps, somewhat obscure and much of the presentation of that result involves ensuring the balance of the partition, which detracts from the main features of the approach. Consequently in the current paper, we will directly address the classic Boolean Satisfiability problem (SAT) to show precisely how constraints, expressed as Boolean formula, can be encoded into quantum algorithm. The constraints are entangled with the superposition of all possible truthvalue assignments and a probability amplification technique applied to amplify the assignment which maximizes the number of satisfied clauses.
In particular, we will focus on MAXE3SAT [11], in which each clause contains exactly three literals, and we will show that our quantum algorithm will solve this maximization problem with high probability of success. In particular, it can then be used to solve the decision problem (with high probability). Iterating the process allows the probability of failure to be made exponentially small.
A key fact about the MAXE3SAT problem is that random truth assignments will satisfy, in expectation, 7/8 of the clauses. A consequence of the PCP Theorem is that this cannot be improved upon (more precisely, there is no approximation algorithm for constant ) unless P=NP [7]. That MAXE3SAT can be solved (with high probability) in polynomial time by a quantum computer is therefore all the more remarkable.
The result shown in this paper doesn’t contradict with that shown [2] where it was shown that BQP does not contain NP relative to a random unitary oracle with probability one. This argument does not imply that BQP does not contain NP in a nonrelativized world which is the novel feature in the proposed algorithm, where partial measurement is used in the amplitude amplification process instead of the usual unitary amplitude amplification techniques that use iterative calls to an oracle to amplify the required solution.
The aim of the paper is to propose a quantum algorithm for the MAXE3SAT problem. The algorithm prepares a superposition of all possible variable assignments, then the algorithm evaluates the set of clauses using all the possible variable assignments simultaneously and then amplifies the amplitudes of the state(s) that achieve(s) the maximum satisfaction to the set of clauses using a novel amplitude amplification technique that applies an iterative partial negation and partial measurement. The proposed algorithm runs in for an E3CNF Boolean formula with clauses and in the worst case runs in for an E3CNF Boolean formula with Boolean variables to achieve an arbitrary high probability of success of for small using a polynomial resources.
The paper is organized as follows; Section 2 shows the data structures and the quantum circuit for encoding an E3CNF Boolean formula. Section 3 presents the proposed algorithm with analysis on time and space requirements. Section 4 concludes the paper.
2 Data Structures and Clause Encoding
An inputs CNF Boolean formula,
(1) 
is a conjunction (AND) of clauses, each clause represented by a disjunction (OR) of exactly literals, , such that a literal in clause with and equals to an input variable in its true form or its complemented form . That is, , where can be replaced by or such that is the negation of with . The first aim is to decide whether is satisfiable or not (deciding ). The second aim is to find a variable assignment for and that satisfies if it is satisfiable (solve ) or to find a variable assignment that satisfies the maximum possible number of clauses if is unsatisfiable (maximize ).
The problem of deciding whether a CNF Boolean formula is satisfiable or not is NPcomplete and is known as SAT or ESAT problem. The optimization problem associated with the SAT problem to find a variable assignment to satisfy a satisfiable CNF formula is NPhard. If the CNF is unsatisfiable, then the problem of finding a variable assignment to maximize the number of satisfied clauses is known as MAXEkSAT problem which is an NPhard problem [11]. The maximum number of clauses for a CNF Boolean formula is . Without loss of generality, this paper targets the E3SAT and MAXE3SAT problems where , so the maximum number of clauses for the MAX3ESAT is .
2.1 Encoding of a Solution
A candidate solution to the MAXE3SAT problem is a vector of variable assignment , and each vector is associated with a vector of the truth values of the clauses sorted in order, i.e. . The optimal solution is the solution that contains a vector of variable assignment that maximizes the number of 1’s in the vector of the truth values of the clauses. For short, the number of 1’s in the vector of clauses , i.e. the number of satisfied clauses, will be referred to as the 1density of so that the 1density for a satisfiable formula must be equal to . For example, consider the E3CNF Formula with and ,
(2) 
where,
(3) 
then a solution to this formula will be encoded as , where and . This formula is satisfiable when , or , and an instance of an optimal solution will be with and . For and , the E3CNF formula might not be satisfied [5] where the 1density of the vector will give the maximum number of satisfied clauses and the order of 1’s will show the satisfied clauses using the variable assignment .
For and , we have the problem instance compsrising all possible clauses. The 1density of in this case will be 7m/8 which is the worst possible case for the 1density of . The 3CNF formula will be unsatisfied for an arbitrary variable assignment [14].
2.2 Encoding of a Clause
An E3CNF formula with inputs and clauses will be encoded as an inputs/outputs quantum circuit. Every E3CNF clause will be encoded using a quantum gate. The ( Generalized Toffli) gate [9] is the main primitive gate that will be used to encode a clause. The gate is defined as follows:
Definition 2.1
( gate)
gate is a reversible gate denoted as,
(4) 
where and with . The gate has 4 inputs: , , (known as control qubits) and (known as target qubit). Each control qubit is associated with a condition , such that if then the condition on is satisfied if , i.e. , and if then the condition on is satisfied if . The gate has 4 outputs: , , and . The operation of the gate is defined as follows,
(5) 
where is the XOR logic operation, i.e. the target qubit will be flipped if and only if each control qubits satisfies its associated condition . For example, for the gate if and only if , and .
A gate with its target qubit, , initialized to state can be used to encode a clause using the Boolean algebraic identity,
(6) 
so that , where , and can be replaced by or such that is the negation of . That is,
(7) 
For example, consider the following E3CNF Boolean formula with and ,
(8) 
with
(9) 
Apply the Boolean algebraic identity shown in equation (6) on each clause, then,
(10) 
then each clause can be encoded using a gate as follows,
(11) 
To construct a quantum circuit for this E3CNF formula, prepare a quantum register with 4 qubits to be loaded with the values of , , and , and add 3 extra qubits initialized with the quantum state so that uses the first extra qubit as the target qubit, uses the second extra qubit as the target qubit, and so on, as shown in figure 1. Let be a quantum circuit on 7 qubits defined as , then,
(12) 
3 The Algorithm
Given an E3CNF formula with inputs and clauses. The proposed algorithm is divided into three stages, the first stage prepares a superposition of all possible variable assignments for the variables. The second stage evaluates the clauses for every variable assignment and stores the truth values of the clauses in truth vectors entangled with the corresponding variable assignments in the superposition. The third stage amplifies the truth vector of clauses with maximum number of satisfied clauses using a partial negation and iterative measurement technique. The proposed algorithm uses qubits during the three stages. Each of the first qubits is initialized to state , each of the qubits is initialized to state , and an extra auxiliary qubit, denoted is initialized to state . The qubit is an auxiliary qubit that will be used during the amplitude amplification technique. The amplitude of the state of entangled with every truth vector of clauses will act as an aggregator for the amount of partial negation to be applied on that state based on the 1density of the entangled truth vector of clauses. The probability of finding when measured will depend of the accumulation of all partial negations applied on the states of that qubit.
The system is initially as follows,
(13) 

Variable Assignments Preparation. To prepare a superposition of all variable assignments of qubits, apply on the qubits
(14) where is the Hadamard gate, is the identity matrix of size , , and is the bitwise representation of an integer , for , that represents a variable assignment out of the possible variable assignments.

Preparation of the Truth Vectors of Clauses. For every E3CNF clause , apply a gate taking qubit in the qubits register as the target qubit as shown in Section 2.2. The collection of all gates applied to evaluate the clauses is denoted in figure 2, then the system is transformed to,
(15) where is the truth vector for the clauses associated with variable assignment .

Maximization of the Number of Satisfied Clauses. The aim of this stage is to find the state that contains the maximum number of s. Such a state will be denoted . A modified version of the amplitude amplification algorithm shown in [13] will be used for this purpose. Every is entangled with the corresponding variable assignment . Since the variable assignment will not be involved directly in this stage and the corresponding will not be modified by any operation, then for simplicity the system can be rewritten as,
(16) Let be the 1density of the state . A solution to the MAXE3SAT problem is to find the state with .
The aim is to find when is measured. To find , the algorithm applies partial negation on the state of entangled with based on the 1density of , i.e. more 1’s in gives more negation to the state of entangled with . If the number of 1’s in is , then the entangled state of will be fully negated.
Let be the PauliX gate which is the quantum equivalent to the NOT gate. It can be seen as a rotation of the Bloch Sphere around the Xaxis by radians as follows,
(17) The partial negation operator is the root of the gate and can be calculated using diagonalization as follows,
(18) where , and applying for times on a qubit is equivalent to the operator,
(19) such that if , then . To amplify the amplitude of the state , apply the operator on as will be shown later, where is an operator on qubits register that applies conditionally for times on based on 1density of as follows (as shown in figure 3),
(20) where the gate is a 2qubit controlled gate with control qubit and target qubit . The gate applies conditionally on if , so, if is the 1density of then,
(21) and the probabilities of finding the auxiliary qubit in state or when measured is respectively as follows,
(22) To find the state in , the proposed algorithm is as shown in Algorithm 1 and as shown in figure 3. For simplicity and without loss of generality, assume that a single exists in , although different variable assignments might be associated with truth vectors with maximum 1density with different order of 1’s, but such information is not known in advance.
We require that Algorithm 1 finds for times in a row. The probability of finding after Line:4 in the iteration of the forloop is given by,
(23) The probability of finding after Line:4 in the iteration, i.e. is given by,
(24) The probability of finding after Line:4 in the iteration, is given by,
(25) The probability of finding after Line:4 in the iteration, i.e. is given by,
(26) To get the highest probability of success for , the forloop should be repeated until for small as shown in figure 4. This happens when,
(27) and since the Sine function is a decreasing function then for sufficient large ,
(28) where is the next maximum 1density less than . The values of and are unknown in advance, so let be the number of satisfied clauses, then in the worst case when , and , the required number of iterations for and can be calculated using the formula,
(29) then,
(30) where . When , then the upper bound for the required number of iterations is . Assuming that a single exists in the superposition will increase the required number of iterations, so it is important to notice here that the probability of success will not be overcooked by increasing the required number of iteration similar to the common amplitude amplification techniques.
3.1 Tuning the Probability of Success
During the above analysis, two problems might arise during the implementation of the proposed algorithm. The first one is to finding for times in a row which is a critical issue in the success of the proposed algorithm to terminate in polynomial time. The second problem is that the value of is not known in advance, where the value of shown in equation (23) plays an important role in the success of finding in the next iterations, this value depends heavily on the 1density of , i.e. the ratio .
Consider the case of a complete E3CNF formula where the number of clauses is and all the ’s are equivalent where anyone can be taken as . In this case, each clause will be satisfied by 7 variable assignments out of 8 possible variable assignment, then for any [10], so is as follows,
(31) 
This case is a trivial case for the proposed algorithm by setting in root of to get a probability of success of certainty after a single iteration. Assuming a blind approach where is not known, then this case represents the worst case [14] and iterating the proposed algorithm will not amplify the amplitudes after arbitrary number of iterations. For an arbitrary E3CNF formula, the actual probability of success will depend of the 1density of , i.e. the ratio . In the following, a tuning of will be shown so that we can find after the first iteration with an arbitrary higher probability of success close to certainty without a priori knowledge of .
For an arbitrary E3CNF formula, we could interpret the formula for in equation (23) as the expected value of the function,
(32) 
where is the proportion of clauses satisfied by a random truth assignment, that is, . The bounds for the probability of finding in the first iteration is as shown in the following Lemma,
Lemma 3.1
The probability of finding in the first iteration is bounded as follows,
(33) 

(34) Since is a concave function on , it follows from Jensen’s inequality that,
(35) For the lower bound we use,
(36) which follows from the Taylor series taken around . Then,
(37)
To overcome the problem of low probability of finding in the first iteration, we can add temporary qubits initialized to state to the register as follows,
(38) 
so that the extended number of clauses will be and will be used instead of in the operator, then the density of 1’s will be . To get a probability of success to find after the first iteration of the forloop in Algorithm 1,
(39) 
then the required number of temporary qubits is calculated as follows,
(40) 
where and . For example, if , then will be in the neighborhood of 99 as shown in figure 5. To conclude, the problem of low 1density of can be solved with a polynomial increase in the number of qubits to get the solution in iterations with arbitrary high probability to terminate in polytime, i.e. to read for times in a row.
4 Conclusion
Given an E3CNF Boolean formula with inputs, the paper showed that BQP contains NP in a nonrelativized world by proposing a BQP quantum algorithm to solve the MAXE3SAT problem with clauses. The proposed algorithm encoded every clause as a GT gate where qubits are used. The algorithm is divided into three stages; the first stage prepares a superposition of all possible variable assignments. In the second stage, the algorithm evaluates the set of clauses for all possible variable assignments using a quantum circuit composed of GT gates so that each variables assignment is entangled with a truth vector of clauses evaluated according to that variables assignment. In the third stage, the algorithm amplified the amplitudes of the truth vector of clauses that achieves the maximum satisfaction to the set of clauses using an amplitude amplification technique that applies an iterative partial negation where partial negation is applied to the state of an auxiliary qubit entangled with the truth vector of clauses based on the number of satisfied clauses, i.e. more satisfied clauses implies more negation to entangled state of the auxiliary qubit. A partial measurement on the auxiliary qubit is then used to amplify the set of clauses with more negation. The third stage requires iterations and in the worst case requires iterations. It was shown that the proposed algorithm achieves an arbitrary high probability of success of for small using a polynomial increase in the resources by adding dummy clauses with predefined values to give more negation to the best truth vector of clauses.
In the same manner, the proposed algorithm can also be used decide if a given E3CNF Boolean formula is satisfiable or not by checking the truth vector of clauses, if the clauses are satisfied then the E3CNF Boolean formula is satisfiable, if not, then the proposed algorithm gives the maximum number of satisfied clauses with the corresponding variable assignment.
The proposed algorithm can easily be extended in a trivial way to solve/decide an ECNF Boolean formula by encoding any ECNF clause as a GT gate where it can be shown that the algorithm will require iterations.
References
 [1] Adleman, L., DeMarrais, J. and Huang, M.D., Quantum Computability. SIAM Journal on Computing, 26(5):1524–1540, 1997.
 [2] Bennett, C. H., Bernstein, E., Brassard, G. and Vazirani, U., Strengths and Weaknesses of Quantum Computing. SIAM Journal on Computing, 26(5):15101523, 1997.
 [3] Bernstein, E. and Vazirani, U., Quantum Complexity Theory SIAM Journal on Computing. 26(5): 14111473, 1997.
 [4] Buhrman, H. and Van Dam, W., Quantum Bounded Query Complexity. In Proceedings of the 14 Annual IEEE Conference on Computational Complexity. 149156, 1999.
 [5] Dimitriou, T., SAT Distributions with Planted Assignments and Phase Transitions Between Decision and Optimization Problems. Discrete Applied Mathematics 153, pp. 58–72, 2005.
 [6] Fortnow, L. and Rogers, J., Complexity Limitations on Quantum Computation. Journal of Computer and System Sciences, 59(2):240–252, 1999.
 [7] Håstad, J., Some Optimal Inapproximability Results. Journal of the ACM, 48(4):798–859, 2001.
 [8] Moore, C. and Martens, S., The Nature of Computation. Oxford University Press. 2011
 [9] Toffoli, T., Reversible Computing. In W. de Bakker and J. van Leeuwen, editors, Automata, Languages and Programming, page 632. Springer, New York, 1980. Technical Memo MIT/LCS/TM151, MIT Lab for Computer Science (unpublished).
 [10] Trevisan, L., Gadgets, Approximation, and Linear Programming. In Proceedings of the 37 Annual Symposium on Foundations of Computer Science, pp. 617–626, 1996.
 [11] Trevisan, L., Paradigms of Combinatorial Optimization: Problems and New Approaches. (Chapter 13: Inapproximability of Combinatorial Optimization Problems), vol. 2, p.381, Vangelis Th. Paschos (Editor), WileyISTE, 2010.
 [12] Williamson, D. P. and Shmoys, D. B., The Design of Approximation Algorithms. Cambridge University Press. 2011.
 [13] Younes, A., A Boundederror Quantum Polynomial Time Algorithm for Two Graph Bisection Problems. Quantum Information Processing. doi :10.1007/s111280151069y, 2015.
 [14] Zhang, W., Phase Transitions and Backbones of 3SAT and Maximum 3SAT. T. Walsh (Ed.): CP 2001, LNCS 2239, pp. 153–167, 2001.