1. Introduction and Preliminaries
Quantum computing promises to offer a different paradigm for solving long standing complex problems. Shor’s algorithm [
1] is a clear example of the success of the application of quantum computation to a difficult problem, the factoring of integers. Other algorithms like Deutsch-Josza’s [
2] or Grover’s [
3] give strong hints that the intrinsic parallelism of quantum computation could be used in order to efficiently solve computationally complex problems. In particular, Grover’s algorithm uses the concept of an oracle
which, given a configuration
x of the problem at hand, computes whether or not
x is a solution of the problem. In other words, if
x is a configuration that solves an instance of a combinatorial problem then the oracle returns
otherwise the oracle outputs
. By using this oracle, Grover’s algorithm is capable of speeding up the time to search for a solution of many, very complex, combinatorial problems. In Grover’s algorithm the Grover iteration amplifies the amplitude of the configuration states corresponding to solutions of the problem (i.e., those states
x for which
) by a factor less than
(in the worst case in which there is only one configuration which is the solution of the problem), where
is the number of possible configurations. In this way, after approximately
iterations, the amplitudes of the states corresponding to the solutions of the problem approach 1.
We exploit the parallelism of quantum computation, therefore devising a quantum algorithm that is capable of doubling the amplitude of the states corresponding to the solution of a problem. In this paper, we will focus on the subset sum problem, a well known NP-complete problem. The subset sum problem is very important both at a theoretical level in complexity theory, and at a practical level in applications such as cryptography. The problem can be stated in the following way in which we denote by
, the set of non-zero natural numbers. Let
E be a finite set of elements,
a function and
a target number. The subset sum problem wonders whether there exists a subset
such that
. Usually this problem can also be reformulated as follows. There exists a subset
such that
? In this later formulation it is called the partition problem (PP) [
4]. From now on we do not lose any generality in considering the set
E equals the set of the first
natural numbers; that is, we always consider
. Furthermore, we note that if PP has a solution
then
is also a solution of the PP.
The literature is abundant in the study of this problem, for which the dynamic programming solving strategy is the most commonly applied. More recently, it has also been approached from the point of view of quantum computing, among these references we can mention [
5] where an instance of the subset sum problem can be implemented by a quantum algorithm using the nuclear magnetic resonance (NMR) technique. In that paper, even at a very early stage and with a low number of qubits, they limit themselves to showing that the problem can be approached from this new perspective.
In [
6], the authors studied the problem through both an asymptotic heuristic and a new data structure for using quantum gates. There, the possibility of obtaining an improvement over classical algorithms is shown, specifically the Howgrave–Graham–Joux [
7], which of course is fully coherent with the NP ⊆ BQP conjecture, obtaining a bound time
.
More recently, in 2018, Helm and May [
8] proposed a quantum algorithm that reduces the heuristic time to
. A couple of years later, Li and Li [
9] reduced this time beyond that, i.e., to
.
In this work we will get rid of the heuristics of these studies to better go for the modest approach of [
5]. In this sense, we propose a piece of quantum code using a quantum circuit to model the problem, consequently we devise a transformation that will allow us to increase the amplitudes of those corresponding to the solution by
, leaving the line of how and how many times this process could be iterated, as the key issue to be dealt with. In fact, we think that we could find the same limitations as those from Grover’s algorithm. Anyway, we believe that this line of research deserves to be addressed.
Let , then we say that is a computational state, the binary representation of which is with being the most significant bit of the binary representation of .
The
S gate for a single qubit is represented by the following matrix:
Other usual gates are Pauli X gate, also known as NOT gates, and
gates.
The Hadamard gate for a single qubit is
While the same gate for
n qubits is represented by the following matrix
As stated before, we are interested in amplifying amplitudes for the search problem. In order to do this we make use of sequences of quantum gates in the way of Hadamard-S-Hadamard. Let us start by describing graphically the effect of such quantum gates and so resorting to the positions of the state vector represented in the Bloch sphere.
The effect of applying an H q-gate over a qubit represented on the Bloch Sphere can be seen as “first rotating an angle of
radians around the
Z axis and then rotating an angle of
radians around the Y axis” (fully equivalent to “first rotating an angle of
radians around the Y axis and then rotating an angle of
radians around the X axis”, which are the movements made by H in
Figure 1). Hadamard q-gate application changes a qubit from a computational basis to a Hadamard basis. To better understand the effects of the sequence H-S-H we start, as usual, from a qubit initialized to
, i.e., located at the north pole of the Bloch s. which, moved through a Hadamard gate, gets located at the equator of the Bloch s., specifically on the X axis, in the position usually known as a
, which corresponds to the qubit
After this gate, we apply an S gate, the effect of which is a rotation of the state vector through an angle of
radians around the Z axis. This places the qubit at position
.
Finally, the effect of the second application of gate H is to reset the computational base, and then the vector from position
moves to the opposite point on the Y axis, that is, to the position
In general, we have the following result
That is, an HSH gate is equivalent to a
radians clockwise rotation around the X axis as
Figure 1 shows over a single qubit initialized to
.
Let us go for the general case of a qubit register initialized, as usual, to .
2. The Effect of Applying Hadamard-S-Hadamard Gates to
First of all we will introduce a notation which will be heavily used in the rest of the paper. Let , and be its binary representation. The Hamming weight of x will be denoted as . Let , , . The term denotes . Furthermore, , , we denote by a natural number obtained from z by considering only the least significant bits, that is, the binary representation of is . In other words is the bitwise AND between z and .
In this section we want to determine the effect of applying Hadamard first, then S and finally Hadamard gates on quantum state
, that is, we want to determine a formula for
such that
and we show that in the out-coming computational state
the amplitude
of a single state
depends just on
.
It is well known, see [
3], that given any computational state
where
Now we start with the following Lemma
Proof. Induction on
n is the base case with
straightforward. So suppose that the statement holds for
. Then
□
Now by Lemma 1 and Equation (
2), we have that
and applying the Hadamard to
, by (
2), we have that
and reordering the term of the sum we have that
So in order to compute the amplitudes of
we need to compute the sum
for every
. We will do this in the following two theorems. First of all we need the next Lemma which will be heavily used in the rest of the paper.
Lemma 2. Let and and let and be the binary representation, respectively, of z and x. We have that Proof. We note that, on the left hand of Equation (
4), for every element of the sum, we have that
. Therefore
. Based on this we have that
Furthermore for the same reason above, if
and if
then we have that
and this proves Equation (
4). □
Theorem 1. Let , . If is even we have that Proof. We prove Equation (
5) on induction on
m being the base case with
being easily verifiable for all
. So suppose the statement holds for all
and for all
. Then, for any
we have
Now, by Equation (
4) and by induction hypothesis, we have that (
7) is equal to
Likewise, in the term (
8), for each,
x is the sum, the bit
is always set to 1, so we have that (
8) is, by Equation (
4), equal to
Now by repeatedly applying Equation (
4) and the induction hypothesis we have that the sum in the right hand of Equation (
10) is
So if we replace (
12) in (
10) and if we sum together (
6), (
9) and (
10) we obtain
Now if we denote by
we have that (
13) is
and it is now easy to verify that
for every
, and this proves the induction step. □
Theorem 2. Let be an odd natural, and let , . Then Proof. First of all we note that Equation (
14) holds if
and
. So in the following we suppose that
. We have that
and, by Theorem 1, and by Equation (
4), we have
Let
be the binary representation of
z. Suppose first that
. Then Equation (
15) become
and the Theorem is therefore proved. So suppose that
. Then Equation (
15) become
but observing that
we have that also in this case the theorem is satisfied. □
As an example we have computed the amplitudes
(disregarding the normalization factor) for
and we report them on
Figure 2.
3. Doubling the Amplitudes of the Solution States of the PP
In this section we consider a quantum circuit for doubling the amplitude of the solution’s states of the partition problem.
We describe an application of the gates described in the previous section in a quantum circuit to deal with PP (see
Figure 3). While the following results apply specifically to the PP, they can be applied to any other search problem.
Let us denote by . Notice that S belonging to is a requirement for PP to have a solution. We use the two’s complement representation of , so requiring for it qubits. Then for each , we use qubits to encode . These qubits will remain constant in every phase of the circuit and therefore we will not consider them in the rest of the discussion. As usual, we use n qubits to encode a subset of E, i.e., if is the state of those n qubits, then an element e, , is included in the set if and only if . We will use m qubits, denoted in the following by , to store the sum for the elements selected in . In this way for a solution of the PP. Qubit is used for control purposes.
For a top-down description we can distinguish four groups of bits: , , and the sets of qubits used to represent the constants for each element of E. Note that the number of qubits of the circuit, , is polynomial in the size of a concise specification of the PP.
At the beginning of the circuit we have the superposition:
where
is set to the two’s complement of
and
is set to
. Then, we apply the Hadamard q-gate to the first
n qubits, so obtaining
Next, we use each qubit
to conditionally sum the element
to
. If there exists a solution to the PP then, in the final superposition of
, the amplitude of the state
will not be 0. The states
for which
is zero will be referred to as the solutions states of the PP. The control qubit
will be set to zero exactly for those states for which
. At this point we apply an uncomputational step in order to set
. Now if we apply the
S gate to the first
n qubits we obtain, by Lemma 1
Afterwards Hadamard gate is applied to the first
n qubits controlled by the control qubit
such that it only affects non-solution states (see
Figure 3). For the sake of simplicity we suppose that PP has only two solutions whose numeric representation is
y and its bitwise complement
. By Equation (
3), we obtain
Now we want to quantify the amplitude of the state
and
of Equation (
19). We consider only the state
since the same arguments can be applied to state
. The amplitude
of the state
(in the following we disregard the normalization factor
) is given by the following formula
We may write the above sum as
Then, recalling that when x is even and when x is odd, we have two cases:
For simplicity of notation in the following we denote
as simply
. We have that if
is even then, by Theorem 1,
is
while if
is odd, by Theorem 2,
is
It is immediate to check that in Equations (
25) and (
26) the term
becomes negligible, with respect to the other term in the equation, as
m becomes bigger. We conclude that the amplitude of the state
is almost the same as the amplitude of state
, thus effectively duplicating the chances of state
at the end of the circuit.
Figure 3 captures on the Quirk simulator the instance of the PP where elements in
are
and
depicted in rows 1–2, 3–4 and 5–6, bottom-up referring to the number of the rows as well as the significance of the qubits. The 7
th row is used for the control qubit. Rows 8–11 encode
which in two’s complement is represented with four bits
(bootom-up). The last three qubits are used to be set on the superposition as usual.
Since
and
, we have that
, thus the probability of getting
is, by (
19),
which is exactly the output of Quirk simulator as it can be checked in [
10].
As can be easily seen, this circuit resembles Grover’s algorithm. Both have an initial superposition in the states where the solution will be encoded, afterwards the function to be solved (also called oracle) is computed in order to identify the solution state that should be marked in some way. Finally, a sort of transformation (Z axis turns, Hadamards) before measuring is required. However, they have important differences in some of these generic steps that can generate on the one hand why our proposal amplifies the probability of the solution state more than Grover’s but on the other hand Grover’s one can be iterated; meanwhile, ours cannot.
The main difference relies on how the algorithms mark the solution state. In our proposal the X axis is used for that; i.e., formerly the control qubit is set to which means “no solution”; meanwhile, as soon as equals 0 (solution condition) it is set to . In Grover’s algorithm, the solution state is marked on the Z axis; that is, by means of a negative sign in the solution state. This last fact allows the calculations to be carried without any entanglement with the solution state.
Finally, the amplitude amplification part is also different but follows somehow the same fashion. In our proposal, we perform the amplification of the probability amplitude by means of turns in the Z axis and Hadamard transformations, which is very similar to the inversion on the mean of Grover’s algorithm nevertheless, we apply Hadamard gates controlled by a qubit in which the solution has been marked. This fact generates an entanglement with the result of the function, which probably disables the interference required to iterate the corresponding piece of code.
4. Conclusions and Future Work
We have presented a quantum algorithm for doubling the amplitude of the state which corresponds to the solution of the partition problem. We further studied in detail the effects of applying first Hadamard, then S and finally Hadamard gates to the state .
Since the proposed method doubles the amplitude of the states corresponding to a solution of the referred problem, one can infer that the reiteration of the method could lead us to a quantum polynomial algorithm that could solve the problem P = NP. Of course, we emphasize, that this is not our intention. Due to the way in which we mark the solution state pointed out at the end of the previous section, our piece of quantum code cannot directly be iterated as it can in the case of Grover’s algorithm, therefore our proposal is simply to research to what extent this circuit could be either iterated/modified to be iterable, or, used as a shortcut to finish sooner some algorithms like Grover´s one.
The algorithm presented makes use of an oracle, and the approach is similar to the black box model as described in [
11]; the idea of iterating this algorithm will suffer inevitably from the same limitation described there, and then the maximum speed-up should be limited to the polynomial, as it occurs with Grover’s algorithm. It is our belief that together with any transformation aimed to make iterable the proposed code, it would come as drawback that its computational cost will compensate such an advantage.
Another idea related to our proposal is the possibility of application to the hidden subgroup problem. It is described in Section 5.4.3 of [
3] and it has a known quantum solution by a variant of Shor’s algorithm for the specific case of finite Abelian groups. However, the general problem remains open, with important consequences, for example for the graph isomorphism problem. This problem is discussed in Section 16.3 of [
12] by using Boolean functions and their parity. This discussion is very similar to our
Figure 2; thus, we think that it is worth investigating the possible relationship between them and, moreover, we also think that the problem of the hidden subgroup on Lie groups of general nature, such as SU(2) groups representing the quantum states of a single qubit, SU(4) for two qubits, and so on deserves to be studied. This could also offer an interesting research line for future works.