# How to apply control on a register if that register is equal to a specific n-bit string c*?

Say we want to apply CNOT, and the control register "c" is a n-bit string. Given a specific c*, is it possible to change all bits of the register into 1, if and only if the initial c equals to c*?

I checked "Classical Concepts in Quantum Programming" in order to get an idea of how to implement something similar to if-else in quantum computing, but it made things more complicated. What is the right direction to figure something like this out?

Currently, I do not know of any quantum processor allowing to condition a quantum operation on results in a classical register. On IBM Q, it is possible to do so in simulator only.

However, if you are dealing with quantum circuits like quantum teleportation or superdense coding, where you use such conditioning, you can simply use controlled quantum gates where control qubits are those you would measure and store the results in classical register. See this thread for more information.

Let me consider this example: if we have $$|01\rangle$$ then the circuit should give us at the output $$|11\rangle$$. Here I will try to show why I think this is impossible (by assuming that we don't do any measurements). Let's assume that we have the desired gate and we want to apply it to this state $$\frac{1}{\sqrt{3}}(|00\rangle +|01\rangle - |11\rangle)$$:

$$U \frac{1}{\sqrt{3}}(|00\rangle +|01\rangle - |11\rangle) = \frac{1}{\sqrt{3}}(|00\rangle +|11\rangle - |11\rangle) = \frac{1}{\sqrt{3}}|00\rangle$$

$$U$$ must be unitary and that means it should keep the length of the vector, but in this example, the length didn't preserve (was $$1$$, became $$\frac{1}{3}$$). This means that we can't construct this kind of circuit at least for this example. Note that I assumed from the beginning that we don't have any kind of measurements in the circuit. Also, I assume that we don't have an ancillary qubit, but I guess (I might be wrong) an ancillary qubit will not help here. Nevertheless, for the mentioned assumptions, this answer shows a prove why this will not work (at least) for the given example.

If we assume that there is no superposition of bitstrings by considering qubits as bits, and we allow measurement operations then this can be done easily: measure the qubits and if the qubits will be measured in $$|01\rangle$$ state then apply $$X$$ gate on the first qubit in order to obtain $$|11\rangle$$, otherwise do nothing. One caveat, depending on the Quantum hardware the gates after the measurement on the same qubit theoretically might not work. Or this can be done without measurement, but with ancillary qubit (still assuming no superposition of bitstrings): The first part can be understood from this answer, the second part uses ancillary qubit $$q_2$$ that will be in $$|1\rangle$$ if only the first two qubits are in $$|01 \rangle$$ state. In the second part, a CNOT gate is applied to make sure that the first two qubits will be in $$|11\rangle$$ state at the end.

Did I understand the question right?