# Why doesn't reading the ancilla qubit in Quantum Error Correction kill entanglement?

In Quantum Error Correction we have ancilla qubits (in gray) that will be entangled with the pair of bits we want to check.

Because we don't want to directly measure the "main" qubits (in blue), as this will kill superposition, we then measure the ancilla qubit in order to determine whether the main qubits are the the same or different. According to the algorithm, because we are not measuring the main qubits, this will not kill superposition.

However, isn't the case that, when two qubits are entangled, if I measure one of them, the other one collapses instantaneously? Isn't this the spooky action at a distance phenomena?

In the teleportation circuit we have a similar setup with qubits being entangled. When Alice performs measurement operations on her two qubits (the payload and her half of the entangled pair she shares with Bob), that "destroys" both the qubits.

Why isn't the behaviour the same for the ancilla qubits? If I read the ancilla qubit, the other entangled qubit should collapse as well.

A simplified example: Suppose I have a single qubit $$\alpha|0\rangle+\beta|1\rangle$$ and I encode this into the two-qubit state $$|\psi\rangle = \alpha|00\rangle+\beta|11\rangle$$.

Suppose I also know that the possible errors on my state are very limited and can only leave it in a very specific form:

$$|\psi_\omega\rangle = \sqrt{1-|\omega|^2}(\alpha|00\rangle+\beta|11\rangle) +\omega(\alpha|01\rangle+\beta|10\rangle)$$

(so the case of no errors is represented by $$\omega=0$$)

(Note that this form is very contrived; in particular it isn't equivalent to a single-qubit error, which is what you're usually trying to correct. But it's useful for illustrating the specific point about collapse.)

My error-correction procedure will be as follows: bring in an ancilla $$|0\rangle_A$$, apply a CNOT from the first qubit to the ancilla, then a CNOT from the second qubit to the ancilla, then measure the ancilla in the $$\{0,1\}$$ basis.

Applying the CNOTs does the following:

$$\begin{eqnarray}|\psi_\omega\rangle|0\rangle_A &\to& \sqrt{1-|\omega|^2}(\alpha|00\rangle|0\rangle_A+\beta|11\rangle|0\rangle_A) +\omega(\alpha|01\rangle|1\rangle_A+\beta|10\rangle|1\rangle_A)\\ &=&\sqrt{1-|\omega|^2}|\psi\rangle|0\rangle_A + \omega X_2|\psi\rangle|1\rangle_A \end{eqnarray}$$ where $$X_2$$ is an $$X$$ (bit-flip) operator on the second qubit.

Note that in this state the first 2 qubits are entangled with the ancilla. But when I measure the ancilla, what will the first 2 qubits collapse to? We can see that if I measure a 0, they will collapse to the original state $$|\psi\rangle$$. And if I measure a 1, they will collapse to the original state with an $$X$$ applied to the second qubit, so I can correct it by just applying another $$X$$ to that qubit.

So measuring the ancilla did collapse the original qubits (and destroyed the entanglement between the ancilla and the pair of original qubits, but not between the two original qubits themselves), but to a state where they either have no error or an $$X$$ error on the second qubit (and the measurement outcome tells me which it is). So the collapse didn't, ultimately, damage the original qubit, it actually helped (by reducing the more complex error of $$\psi_\omega$$ to a simple case of a bit-flip or nothing).

(QECCs which can correct arbitrary errors generally work by being able to correct both bit-flip ($$X$$) and phase-flip ($$Z$$) errors; this is sufficient because this kind of collapse process reduces arbitrary errors to a combination of those two kinds.)

The reason this works is that the information the ancilla encodes (if you like, the property of the original state that it is entangled with) is independent of $$\alpha$$ and $$\beta$$ (which define the actual logical qubit) - the ancilla is just recording whether the 2 qubits are in the same state or not. The ancilla tells us about the errors, not the underlying logical state. (In classical terms the ancilla in this example is a "parity check bit" - the quantum difference being we that we have to generate this bit coherently, without revealing/entangling with any further information about the underlying bits.)

Now, all of the above only worked because I required the state with errors to be in the very contrived form $$\psi_\omega$$, but that's because this was a simplified 2-qubit example; you can correct arbitrary errors if you use a full QECC with more qubits, and the underlying principle (measuring the ancilla doesn't damage the logical qubit, it just collapses it into a state of known, correctable errors) is the same. Of course, this is only true because QECCs. their ancillas and the procedures for interacting with them are specifically designed to work this way: in general entangling with an ancilla and then measuring it will damage your state.