A Polynomial Time Bounded-error Quantum Algorithm for Boolean Satisfiability
The aim of the paper is to answer a long-standing open problem on the relationship between NP and BQP. The paper shows that BQP contains NP by proposing a BQP quantum algorithm for the MAX-E3-SAT problem which is a fundamental NP-hard problem. Given an E3-CNF Boolean formula, the aim of the MAX-E3-SAT problem is to find the variable assignment that maximizes the number of satisfied clauses. The proposed algorithm runs in for an E3-CNF Boolean formula with clauses and in the worst case runs in for an E3-CNF 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 MAX-E3-SAT problem, the proposed algorithm can also be used to decide if an E3-CNF Boolean formula is satisfiable or not, which is an NP-complete problem, based on the maximum number of satisfied clauses.
Keywords: Quantum Algorithm, MAX-E3-SAT,E3-SAT, Amplitude Amplification, BQP, NP-hard, NP-complete.
A long-standing open problem in quantum computing is the relationship between the classes NP and BQP [2, 4]. Decision problems are in NP if yes-instances have witnesses that can be checked in polynomial time . The class BQP is the quantum computing analogue of the classical class BPP (bounded error probabilistic polynomial) . 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 . 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 ). However, a recent paper by one of the current authors has shown that an NP-hard problem (Graph Bisection) can be efficiently solved, with low failure probability, by a quantum algorithm . This implies that NP is in fact contained within BQP, as any NP problem can be polynomially reduced to an NP-hard 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 truth-value assignments and a probability amplification technique applied to amplify the assignment which maximizes the number of satisfied clauses.
In particular, we will focus on MAX-E3-SAT , 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 MAX-E3-SAT 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 . That MAX-E3-SAT 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  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 non-relativized 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 MAX-E3-SAT 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 E3-CNF Boolean formula with clauses and in the worst case runs in for an E3-CNF 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 E3-CNF 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,
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 NP-complete and is known as -SAT or E-SAT problem. The optimization problem associated with the -SAT problem to find a variable assignment to satisfy a satisfiable -CNF formula is NP-hard. If the -CNF is unsatisfiable, then the problem of finding a variable assignment to maximize the number of satisfied clauses is known as MAX-Ek-SAT problem which is an NP-hard problem . The maximum number of clauses for a -CNF Boolean formula is . Without loss of generality, this paper targets the E3-SAT and MAX-E3-SAT problems where , so the maximum number of clauses for the MAX-3E-SAT is .
2.1 Encoding of a Solution
A candidate solution to the MAX-E3-SAT 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 1-density of so that the 1-density for a satisfiable formula must be equal to . For example, consider the E3-CNF Formula with and ,
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 E3-CNF formula might not be satisfied  where the 1-density 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 1-density of in this case will be 7m/8 which is the worst possible case for the 1-density of . The 3-CNF formula will be unsatisfied for an arbitrary variable assignment .
2.2 Encoding of a Clause
An E3-CNF formula with inputs and clauses will be encoded as an inputs/outputs quantum circuit. Every E3-CNF clause will be encoded using a quantum gate. The ( Generalized Toffli) gate  is the main primitive gate that will be used to encode a clause. The gate is defined as follows:
gate is a reversible gate denoted as,
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,
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,
so that , where , and can be replaced by or such that is the negation of . That is,
For example, consider the following E3-CNF Boolean formula with and ,
Apply the Boolean algebraic identity shown in equation (6) on each clause, then,
then each clause can be encoded using a gate as follows,
To construct a quantum circuit for this E3-CNF 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,
3 The Algorithm
Given an E3-CNF 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 1-density 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,
Variable Assignments Preparation. To prepare a superposition of all variable assignments of qubits, apply on the qubits
where is the Hadamard gate, is the identity matrix of size , , and is the bit-wise 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 E3-CNF 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,
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  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 re-written as,
Let be the 1-density of the state . A solution to the MAX-E3-SAT 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 1-density 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 Pauli-X gate which is the quantum equivalent to the NOT gate. It can be seen as a rotation of the Bloch Sphere around the X-axis by radians as follows,
The partial negation operator is the root of the gate and can be calculated using diagonalization as follows,
where , and applying for times on a qubit is equivalent to the operator,
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 1-density of as follows (as shown in figure 3),
where the gate is a 2-qubit controlled gate with control qubit and target qubit . The gate applies conditionally on if , so, if is the 1-density of then,
and the probabilities of finding the auxiliary qubit in state or when measured is respectively as follows,
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 1-density 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 for-loop is given by,
The probability of finding after Line:4 in the iteration, i.e. is given by,
The probability of finding after Line:4 in the iteration, is given by,
The probability of finding after Line:4 in the iteration, i.e. is given by,
To get the highest probability of success for , the for-loop should be repeated until for small as shown in figure 4. This happens when,
and since the Sine function is a decreasing function then for sufficient large ,
where is the next maximum 1-density 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,
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 over-cooked 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 1-density of , i.e. the ratio .
Consider the case of a complete E3-CNF 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 , so is as follows,
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  and iterating the proposed algorithm will not amplify the amplitudes after arbitrary number of iterations. For an arbitrary E3-CNF formula, the actual probability of success will depend of the 1-density 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 E3-CNF formula, we could interpret the formula for in equation (23) as the expected value of the function,
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,
The probability of finding in the first iteration is bounded as follows,
Since is a concave function on , it follows from Jensen’s inequality that,
For the lower bound we use,
which follows from the Taylor series taken around . Then,
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,
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 for-loop in Algorithm 1,
then the required number of temporary qubits is calculated as follows,
where and . For example, if , then will be in the neighborhood of 99 as shown in figure 5. To conclude, the problem of low 1-density 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 poly-time, i.e. to read for times in a row.
Given an E3-CNF Boolean formula with inputs, the paper showed that BQP contains NP in a non-relativized world by proposing a BQP quantum algorithm to solve the MAX-E3-SAT 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 E3-CNF Boolean formula is satisfiable or not by checking the truth vector of clauses, if the clauses are satisfied then the E3-CNF 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 E-CNF Boolean formula by encoding any E-CNF clause as a GT gate where it can be shown that the algorithm will require iterations.
-  Adleman, L., DeMarrais, J. and Huang, M.-D., Quantum Computability. SIAM Journal on Computing, 26(5):1524–1540, 1997.
-  Bennett, C. H., Bernstein, E., Brassard, G. and Vazirani, U., Strengths and Weaknesses of Quantum Computing. SIAM Journal on Computing, 26(5):1510-1523, 1997.
-  Bernstein, E. and Vazirani, U., Quantum Complexity Theory SIAM Journal on Computing. 26(5): 1411-1473, 1997.
-  Buhrman, H. and Van Dam, W., Quantum Bounded Query Complexity. In Proceedings of the 14 Annual IEEE Conference on Computational Complexity. 149-156, 1999.
-  Dimitriou, T., SAT Distributions with Planted Assignments and Phase Transitions Between Decision and Optimization Problems. Discrete Applied Mathematics 153, pp. 58–72, 2005.
-  Fortnow, L. and Rogers, J., Complexity Limitations on Quantum Computation. Journal of Computer and System Sciences, 59(2):240–252, 1999.
-  Håstad, J., Some Optimal Inapproximability Results. Journal of the ACM, 48(4):798–859, 2001.
-  Moore, C. and Martens, S., The Nature of Computation. Oxford University Press. 2011
-  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/TM-151, MIT Lab for Computer Science (unpublished).
-  Trevisan, L., Gadgets, Approximation, and Linear Programming. In Proceedings of the 37 Annual Symposium on Foundations of Computer Science, pp. 617–626, 1996.
-  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), Wiley-ISTE, 2010.
-  Williamson, D. P. and Shmoys, D. B., The Design of Approximation Algorithms. Cambridge University Press. 2011.
-  Younes, A., A Bounded-error Quantum Polynomial Time Algorithm for Two Graph Bisection Problems. Quantum Information Processing. doi :10.1007/s11128-015-1069-y, 2015.
-  Zhang, W., Phase Transitions and Backbones of 3-SAT and Maximum 3-SAT. T. Walsh (Ed.): CP 2001, LNCS 2239, pp. 153–-167, 2001.