10

I am interesting in finding a circuit to implement the operation $f(x) > y$ for an arbitrary value of $y$. Below is the circuit I would like to build:

enter image description here

I use the first three qubits to encode $|x\rangle $, use the other three qubits to encode $|f(x) = x\rangle $, and finally I want to filter out all of the solutions for which $f(x) \leq y$.

So, if we set $y = 5$, the states would be: \begin{align*} \Psi_{0} &= |0\rangle \otimes|0\rangle \\ \Psi_{1} &= \frac{1}{\sqrt{8}}\sum_{i=0}^{7} (|i\rangle \otimes|0\rangle ) \\ \Psi_{2} &= \frac{1}{\sqrt{8}}\sum_{i=0}^{7} (|i\rangle \otimes|i\rangle ) \\ \Psi_{3} &= \frac{1}{\sqrt{2}}(|6\rangle \otimes|6\rangle + |7\rangle \otimes|7\rangle ) \end{align*} Is there a general method to come up with such filter, or is this non-trivial?

Frederik vom Ende
  • 4,163
  • 3
  • 12
  • 49
Max
  • 203
  • 1
  • 5

2 Answers2

5

What you are looking for I think is to use a quantum circuit for doing comparison. Those are made from adder circuits with a slight modification to have comparators.

For adders, you have for example one from Cuccaro et al. (this one give the modification to adapt for comparison) and another from Himanshu et al.

cnada
  • 4,802
  • 1
  • 9
  • 22
1

Let $U$ be the circuit you stated that takes $| 0 \rangle^{\otimes (2n)}$ to $\psi=\frac{1}{2^{n/2}}\sum_{i=0}^{2^n-1} | i \rangle \otimes | f(i) \rangle $.

$S_\psi = I - 2 | \psi \rangle \langle \psi | = U ( S_{| 0 \rangle^{\otimes (2n)}} ) U^\dagger$

$S_P$ needs to be the unitary that sends $| i \rangle \otimes | j \rangle$ to $(-1)^{j>y} (| i \rangle \otimes | j \rangle)$. For example if $y$ is $2^{n-1}-1$, then this would be done with a $Z$ gate on the most significant index. Generally for $y$ 1 less than a power of $2$ this should be easy by combining information from all more significant indices.

Those are the requisite ingredients for amplitude amplification for $f(x) \geq 2^k$ for some $k$. The number of times you need to apply $Q$ is dependent on the overlap which is dependent on how many solutions $x$ there are to $f(k) \geq 2^k$. If $f$ is reversible so just giving a permutation of $2^n$, then you have the overlap in terms of $n-k$ without bothering with any details of $f$.

You won't get exactly the result you asked for because that was projecting to a subspace/not unitary, but this will get you close to that desired state given your starting setup. There is also the trouble of setting $y$ arbitrarily, but at least you can amplify the condition $f(x) \geq 2^k$ as a step along the way to amplifying $f(x) \geq y$ for $y \geq 2^k$.

I may have misunderstood the question. You might have wanted something that works more generally, but given your small example this approach is okay. You don't have to worry about the fact that $\frac{\pi}{4\theta}$ will get really big as $n$ grows you, if you don't let $n$ grow. Did you want to input $y$ as a quantum state as well?

I wasn't careful about checking $\geq$ vs $\gt$ so you should check that.

AHusain
  • 3,723
  • 2
  • 11
  • 18