# Building a controlled NOT gate which is controlled by the qubit it is acting on

I have a question, which I have thought about for a while now, and can't seem to figure out.

I have a quantum circuit and I would like to construct a unitary gate acting on a qubit $$q$$ that acts as a NOT gate on $$q$$ if $$q = |1\rangle$$, and leaves $$q$$ invariant if $$q = |0\rangle$$. In other words, I would like the NOT gate to act on $$q$$ AND be controlled by $$q$$. I am not sure how to implement this? Is there a sequence of gates that gives this required result?

I tried to to implement it by finding a unitary operator so that $$|0\rangle$$ goes to $$|0\rangle$$ and $$|1\rangle$$ also goes to $$|0\rangle$$ (which is equivalent to the above). I found the matrix that does this, but it is not unitary (and I don't think there is any unitary matrix that does this operation).

I feel like I am missing something obvious here, but can't figure it out. Any help would be appreciated! Thanks!

• What you are looking for seems to be a reset operation. You can do a measurement in the computational basis and apply a NOT operation if your outcome is |1> Aug 11, 2022 at 15:20

The operation you want is impossible, because it is not reversible. It sends both |1> and |0> to |0>, so afterwards if you see |0> you can't tell if it came from |1> or from |0>. So not reversible, therefore not unitary, therefore not possible.

The operation that is closest to what you want is the Reset operation, which effectively discards the qubit's value by swapping in a fresh |0> qubit.

If you can afford an additional auxiliary qubit then it can be done very easily. You initialize the auxiliary qubit to state $$|0⟩$$. Then you peform 2 $$CNOT$$ gates - the first with qubit q as a control and the auxiliary qubit aux as target, and the second one just in the opposite direction. If q was in state $$|1⟩$$ it will flip to $$|0⟩$$. If q was in state $$|0⟩$$ then nothing happens. The simple circuit: • The problem with this solution is that the value of $q$ goes into $aux$. What you've effectively done is swapping the value of $q$ and $|0\rangle$. A more effective way of doing this is simply to rename $q$ to $aux$ and $aux$ to $q$ and carry on with your computation. Aug 11, 2022 at 17:40
• Even though this answer doesn't directly address OP's question, I don't see why it was downvoted. So I upvote it back cause I think it is an interesting educational answer. Aug 11, 2022 at 18:32
• @MonteNero I actually disagree on what you just said, this answer isn’t educational, and on the contrary is quite misleading on the way unitary operations work in quantum computation, not to mention it doesn’t answer the original question.
– Lena
Aug 11, 2022 at 19:40
• @MonteNero: This is misleading since the question is about gate which is not unitary (as pointed by Craig Gidney) but in the answer the gate is unitary. In other words, the answer tells you how to prepare unitary reset which does not make sense. Aug 11, 2022 at 20:55
• @Lena: The answer is educational is the way that shows how easily you can be misled by thinking classically. It seems that the answer is based on assumption that the "copy" in aux qubit is independent of the qubit q. This is not however the case because of non-cloning theorem. Aug 11, 2022 at 20:59