I need to implement a quantum comparator that, given a quantum register $a$ and a real number $b$ known at generation time (i.e. when the quantum circuit is generated), set a qubit $r$ to the boolean value $(a < b)$.

I successfully implemented a comparator using 2 quantum registers as input by following A new quantum ripple-carry addition circuit (Steven A. Cuccaro and Thomas G. Draper and Samuel A. Kutin and David Petrie Moulton, 2004). This means that given two quantum registers $a$ and $b$, the circuit set a qubit $r$ to the boolean value $(a < b)$.

I could use an ancilla quantum register that will be initialised to the constant value $b$ I am interested in and then use the implementation I already have, but this sounds quite inefficient.

The only gate that use the quantum register $b$ (the one fixed at generation time) is the following:

MAJ gate as described by Cuccaro's paper

When this gate is used, the qubits of $b$ are given as the second input (i.e. the middle line in the circuit representation above) and the value of each of the qubit of $b$ is known at circuit generation.

My questions:

  1. Is there a way to remove completely the quantum register $b$ by encoding the constants values of each $b_i$ in the quantum circuit generated?
  2. Can the fact of knowing the value of the second entry of the gate at generation time be used to optimise the number of gates used (or their complexity)?

I already have a partial answer for question n°2: the Toffoli gate may be simplified to one CX gate when $b_i = 1$ and to the identity (i.e. no gate) when $b_i = 0$. There is still a problem with the first CX gate that prevent this optimisation, but this may be a track to follow?


Let's answer my own question: it is not possible.

After some research I ended up computing the "truth table" for the two possible cases:

  1. $b = 0$:
    • $\vert 00 \rangle\rightarrow\vert 00 \rangle$
    • $\vert 01 \rangle\rightarrow\vert 10 \rangle$
    • $\vert 10 \rangle\rightarrow\vert 10 \rangle$
    • $\vert 11 \rangle\rightarrow\vert 01 \rangle$
  2. $b = 1$:
    • $\vert 00 \rangle\rightarrow\vert 00 \rangle$
    • $\vert 01 \rangle\rightarrow\vert 11 \rangle$
    • $\vert 10 \rangle\rightarrow\vert 11 \rangle$
    • $\vert 11 \rangle\rightarrow\vert 01 \rangle$

It is clearly visible in the above truth tables that the operation I want to produce is not reversible (two different input give the same output) and so not unitary.

I will have to find another algorithm to do what I am searching for. I am still open to suggestions on interesting algorithms.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.