Quantum Algorithm for Solving Tautology and Satisfiability Problems ()
1. Introduction
Let’s say we are given a Boolean formula with
number of Boolean variables—
. Each of these
variables can take two possible values: TRUE or FALSE. Therefore,
variables can take
different values in total. If the Boolean formula is a tautology, then the Boolean formula will always evaluate to TRUE, regardless of the values of the variables.
The tautology problem is co-NP-complete [1]. As we know, a problem is in co-NP if its complement is in NP. For example, the complement of the tautology problem asks whether the Boolean formula evaluates to TRUE for at least one combination of values of the Boolean variables. Please note that this is the same problem as the satisfiability problem.
The satisfiability problem is in NP. If the variables of the Boolean formula are assigned Boolean values, we can verify in polynomial time whether the Boolean formula evaluates to TRUE.
Moreover, the satisfiability problem is known to be NP-complete. As the satisfiability problem is the complement of the tautology problem, the tautology problem is a co-NP-complete problem.
A qubit does not always take the values 0 or 1. It can take any values of the form
, where
and
are two complex numbers and
. We can leverage this to solve the tautology and the satisfiability problem using a quantum algorithm.
2. The Proposed Quantum Algorithm
Let’s say
is a Boolean formula consisting of
input variables. The input variables are Boolean and can take the values TRUE or FALSE. Depending on these
Boolean variables,
can evaluate to any value, TRUE or FALSE.
Let’s also assume that
is a function. The
input Boolean variables of the function
represent the
Boolean variables of
. And the output of
represents the output of the Boolean formula
.
In other words, let’s say
are the
input variables of
.
represents the value that the Boolean formula
evaluates for the same set of values of its Boolean variables. Let’s also assume that the function
can be implemented as an oracle.
Therefore, if
is a tautology, then
always evaluates to 1. If
is not satisfiable, then
always evaluates to 0. In all other cases, if
evaluates to 1 for at least one set of values of the input variables, then
is satisfiable.
For our purpose, we can use the quantum circuit as shown in Figure 1. The first
qubits are initialized to
, and the last qubit is initialized to
.
We can apply the Hadamard gate on the first
qubits. As a result, after applying the Hadamard gate, we will obtain the following state:
(1)
Now, we can apply the oracle [2]
that implements the function
. Therefore, if we query the oracle, we obtain the following state:
(2)
Figure 1. Quantum circuit implementing the proposed quantum algorithm.
For example, if
, we will get the following state:
(3)
At this point, if
is a tautology, we will get the following state:
(4)
If
is not satisfiable, we will get the following state:
(5)
However, if
is satisfiable, it can be in any other state, like the following, for example:
(6)
The
qubits of the quantum state
now passes through the quantum gate G. We will use the unitary matrix M to implement G. The construction of the
unitary matrix M is explained in Section 3.
The output of G is
qubit. The measurements of the output qubits specify whether
is satisfiable, unsatisfiable, or a tautology.
3. Construction of the Unitary Matrix M
The quantum gate G is implemented using the unitary matrix M.
is the number of Boolean variables of
and
.
Let’s consider the quantum state
.
(7)
Please note that
for
has
qubits.
and
cannot be non-zero simultaneously, as the output of
for a specific
cannot be both 0 and 1. For example, if
and
, then the coefficient
for
is
and the coefficient
for
is 0.
Let’s say the output of the quantum gate G is the following:
(8)
Therefore, we can write the following:
(9)
In our case,
is a
unitary matrix. Let’s say
is the following block matrix:
(10)
As
is a unitary and real matrix, we can write the following:
or,
or,
(11)
We will consider the following initial value for A:
(12)
We observe that
(13)
We can now put the value of
and construct
as follows:
(14)
We can now set
and calculate
as
.
Similarly, we can continue to construct the
matrix
where
. We will discuss the time complexity of constructing matrix
in Section 5.
4. Some Properties of the Matrix M
Property 1: The first and second rows of
will always contain 0 and
alternately.
We can use mathematical induction to prove this.
(15)
contains 0 and
alternately in the first and second rows. Therefore, the property holds for
. Let’s say the property holds for all
for
. We will prove that the property holds for
.
(16)
(17)
As per our assumption, the property holds for
. As the number of rows of
for
is more than 2, the first and second rows of
will contain
and 0 alternately. Hence, the property holds for all
.
Property 2: Each row
of
, for
, contains
and
alternately as non-zero elements.
We can use mathematical induction to prove this.
(18)
Each row
for
contains
and
alternately as non-zero elements. Therefore, the property holds for
.
Let’s say the property holds for all
for
. We will prove that the property also holds for
.
(19)
(20)
As the property holds for
, it will hold for
. And the non-zero elements of
will be
and
alternately. Therefore, the property holds for
. Hence, the property holds for all
.
Property 3: The matrix M is unitary.
M is constructed recursively from
. Therefore, the following holds:
(21)
We can use mathematical induction to prove that
is an involutory [3] matrix for
.
(22)
As
is a symmetric matrix,
. Therefore,
(23)
Therefore,
is an involutory matrix for
. Let’s assume that
is an involutory matrix for all
where
.
(24)
As per our assumption,
is involutory.
(25)
Therefore,
is an involutory matrix for all
where
.
As
, we can write the following:
(26)
Hence,
is a unitary matrix.
5. Output of the Quantum Gate G
As discussed in Section 3,
(27)
And the output of the quantum gate G is the following:
(28)
Therefore, we can write the following:
(29)
As discussed in Section 4, the first two rows of M alternate between 0 and 1. Therefore, we can write the following:
(30)
The input of the quantum gate G is the following:
(31)
The first
qubits of
for
and
specify the input of the given Boolean function and the
th qubit of
is the output of the Boolean function. Therefore,
and
cannot be 1 together for
.
If the given Boolean function is a tautology, the
th qubit of
for
and
is always 1. Therefore, in that case,
are zeros and
are all ones.
(32)
Please note that
for
as per Property 2. Therefore, the output of the quantum gate G, in that case, will be the following:
Similarly, if the given Boolean function is not satisfiable, the
th qubit of
for
and
is always 0. Therefore, in that case,
are all ones and
are all zeros. Therefore, in that case,
(33)
(34)
(35)
Therefore, the output of the quantum gate G, in that case, will be the following:
In all other cases, the output of the quantum gate G will be different from
or
. The Boolean function, in that case, is satisfiable. We can detect that by measuring the
output qubits.
If we repeat the experiment, the
output qubits, in that case, will collapse to different values each time. The
output qubits, in that case, will not be
or
.
6. Time Complexity for Constructing M
M is constructed recursively from
.
(36)
In the
iteration, we compute
. Therefore, we need
iterations to compute
, where
is the number of variables of the Boolean function
.
7. Discussion on a Specific Corner Case
Let’s consider a scenario where the Boolean function has
variables. And it evaluates to 1 in only one specific assignment of Boolean values to the set of
variables.
(37)
As discussed earlier, if the given Boolean function is not satisfiable,
are all ones and
are all zeros. Therefore, in that case,
(38)
Therefore, the probability of incorrectly getting
instead of
is significantly high.
To address this problem, we can use Unambiguous State Discrimination [4] [5].
Let’s say the Boolean formula evaluates to 1 for
cases and to 0 in one case. Let’s also assume that
is a state that indicates a tautology and
is the state that we derive. We need to unambiguously distinguish between these two non-orthogonal states.
Let’s assume that
,
, and
be three operators such that if we get the outcome
, we will be certain that the state was
. If we get the outcome
, we will be certain that the state was
. The outcome
means that the result is inconclusive.
In other words,
must never trigger for
.
must never trigger for
. And, the following holds:
(39)
Let
and
be the states orthogonal to
and
, respectively. Therefore, we can construct
and
in the following way:
(40)
We choose
and
in such a way that
is minimized. We choose the following value for
and
:
(41)
Let’s look at an example. Let’s say the Boolean formula has two variables. It evaluates to 1 for 3 cases and to 0 in one case. The output state we obtain in this case is the following:
(42)
If the Boolean formula was a tautology, we would have obtained the following state:
(43)
Therefore,
and
, in our case, will be:
(44)
Therefore, the probability of getting
will be the following:
(45)
Table 1 shows the probability of failures for different numbers of Boolean variables.
Table 1. Probability of failures.
Number of Boolean variables |
Probability of failure |
Minimum number of times the experiment should be repeated
(k = a positive constant) |
2 |
0.75 |
100 |
3 |
0.875 |
100 |
4 |
0.9375 |
100 |
5 |
0.96875 |
100 |
6 |
0.9843 |
100 × k |
7 |
0.9921 |
100 × k |
8 |
0.9960 |
100 × k |
9 |
0.9980 |
100 × k |
10 |
0.9990 |
1000 × k |
11 |
0.99951 |
1000 × k |
12 |
0.99975 |
1000 × k |
13 |
0.999877 |
1000 × k |
Therefore, we will get an inconclusive result 75% of the time, in which case we need to repeat the experiment. If the number of Boolean variables is 10, then the probability of getting an inconclusive result becomes 0.9990. In that case, if we repeat the experiment, for example, 1000 or 2000 times, in the worst case, we can correctly determine whether the Boolean formula is a tautology, satisfiable, or unsatisfiable.
Hence, if we repeat the experiment the required number of times, the proposed quantum algorithm can correctly predict whether the Boolean formula is a tautology, satisfiable, or unsatisfiable.
8. Time Complexity of The Proposed Quantum Algorithm
The value of
is constant for a given value of
where
is the number of Boolean variables in
. Therefore, once M is constructed for a specific
, we can use the same value of M for all Boolean functions with
variables.
The proposed quantum algorithm must be run a constant number of times to test whether the corresponding qubits are consistently
or
. If no, then the Boolean formula is satisfiable. If yes, then we need to repeat this experiment as described in Section 7.
Therefore, once we construct
, we can correctly determine whether the given Boolean function is a tautology, satisfiable, or non-satisfiable. And, construction
takes
time where
is the number of Boolean variables in the given Boolean function.
9. Conclusion
This paper proposes a quantum algorithm to solve the tautology and the satisfiability problems. In a classical computer, we may need to evaluate all
assignments on
Boolean variables in the worst case. As a result, these problems can take
time for
Boolean variables. However, the proposed quantum algorithm shows significant improvement, as the stated problem can be solved in
time, in most cases, once M is constructed. Only when we get the result
or
, we need to repeat the experiment as mentioned in the paper. Constructing M takes
time, where
is the number of Boolean variables of the given Boolean function.