# What's the relation between the sign of error correction code and commute of operators?

For example, the 5-qubit QECC.

If $$X_i, Y_i, Z_i$$ commutes with $$M_i$$, the eigenvalue will be +1. Otherwise, the eigenvalue will be -1. What's the relation between the commute and the sign of the eigenvalue? Moreover, since the control qubit is the ancilla qubit and the target qubit is $$\psi$$, how comes that a change in the target qubit could influence the measurement of the control qubit? For example, if $$X_0$$ appears, why is the measurement result of ancilla qubit be 0100?  What you are describing is called indirect measurement, and it forms the backbone of the stabilizer formalism. To understand it, we can just work with a general element of the Pauli group, which in the below diagram is the gate labeled $$P$$. Also, the $$|\phi\rangle$$ wire is generally a bundle of $$n$$ wires, and the gate $$P$$ acts on all of them (in your example, it is a five-qubit state, and each single-qubit Pauli is $$X$$, $$Z$$, or $$I$$), but for this example let's just assume it's a single qubit.

Any element of the Pauli group has an eigenspace such that half of the eigenvectors have eigenvalue +1, and the other half has eigenvalue -1. In the case of a single-qubit Pauli $$P$$, we can call these two eigenvectors $$|\phi_+\rangle$$ and $$|\phi_-\rangle$$, and write the input state in this basis $$|\phi\rangle = \alpha |\phi_+\rangle + \beta |\phi_-\rangle$$. Working out the action of the circuit, we get

$$|0\rangle|\phi\rangle \rightarrow \frac{1}{\sqrt{2}}(|0\rangle + |1\rangle) |\phi\rangle \rightarrow \frac{1}{\sqrt{2}}(|0\rangle |\phi\rangle + |1\rangle P |\phi\rangle ) \rightarrow \frac{1}{2} (|0\rangle(I + P)|\phi\rangle + |1\rangle(I - P)|\phi\rangle)$$

This means that the outcome we obtain when measuring the ancilla determines which operator we apply to the data qubit(s). Working out just the first term, as if we measured the ancilla and collapsed it to $$|0\rangle$$:

$$\frac{1}{2}(I+P) |\phi\rangle = \frac{1}{2} (I+P) (\alpha|\phi_+\rangle + \beta|\phi_-\rangle) = \frac{1}{2} (\alpha|\phi_+\rangle + \beta|\phi_-\rangle + \alpha|\phi_+\rangle - \beta|\phi_-\rangle) = \alpha |\phi_+\rangle$$

So the action of the operator is to project onto its positive eigenspace, conditioned on the ancilla outcome (and you can check that the other outcome projects onto the negative eigenspace). Since we only project onto a subspace, instead of collapsing to an individual state, this is called indirect measurement. To be clear, in this example $$|\phi_+\rangle$$ is just a ray in Hilbert space, but you can imagine other projectors like $$ZZ$$ which define even/odd subspaces, not rays.

If we intentionally prepare $$|\phi\rangle = |\phi_+\rangle$$, then the ancilla can only ever give 0, because no part of the data state lies in the negative eigen(sub)space ($$\alpha=1, \beta=0$$).

Now, what happens if some error $$U$$ occurs, somewhere before the gate $$P$$? Since the error is also assumed to be some Pauli, it also has some positive and negative eigenspaces. Furthermore, note that any two elements of the Pauli group must either commute or anticommute. Assume that $$U$$ commutes with $$P$$: $$UP = PU \rightarrow PU|\phi_+\rangle = U|\phi_+\rangle$$ so the new error state $$U|\phi_+\rangle$$ still has eigenvalue +1 under $$P$$. Meauring the ancilla can still only ever give $$|0\rangle$$ (i.e $$m_Z = +1$$).

Now assume that $$U$$ anti-commutes with $$P$$: $$UP = -PU \rightarrow PU|\phi_+\rangle = -U|\phi_+\rangle$$ Now the state that was supposed to be in the positive eigenspace has eigenvalue -1 under $$P$$ due to the error, so the spaces have flipped! This means the ancilla can only ever give $$|1\rangle$$ upon measurement (i.e. $$m_Z = -1$$).

In this way, errors ($$U$$) that commute with the stabilizers ($$P$$) are undetectable, because they do not flip the sign of the corresponding ancillas. But any errors that anticommute with at least one stabilizer will flip at least one ancilla, and we can detect the error. Then, the only thing left is to make sure that different errors trigger unique sets of ancillas, which are called syndromes, so that the errors are uniquely decodable.

(image credit to TU Delft Fundamentals of Quantum Information course notes)

• Thanks! It's very clear. One point that I don't understand. How to prepare the input state to be $|\phi_+\rangle$ ? When an error occurs, why do we only consider $|\phi_+\rangle$ instead of a superposition state of $|\phi_+\rangle$ and $|\phi_-\rangle$? Aug 18, 2020 at 8:33
• If your encoding initialized a superposition between $|\phi_+\rangle$ and $|\phi_-\rangle$, then the error correction would only succeed with whatever probability you have to collapse to $|\phi_+\rangle$, because only in that case do all the stabilizers give +1, which is indistinguishable from the error-less case. Otherwise, you would not be able to tell whether you collapsed to $|\phi_-\rangle$ and had no errors, or if you started with $|\phi_+\rangle$, but then had some errors that triggered all the stabilizers to -1. Aug 18, 2020 at 11:02
• To prepare $|\phi_+\rangle$, you would need to figure out some circuit that could prepare a state such that $P |\phi_+\rangle = +1 |\phi_+\rangle$ holds for all $P$ you intend to measure, which is no simple task. Aug 18, 2020 at 11:03
• Thanks! I see! For example, we can prepare the input state to be $|0\rangle$ and the stablizer P to be $Z$. So that $Z|0\rangle = +1|0\rangle$. Am I correct? Aug 18, 2020 at 11:53
• That is correct, the operator $Z$ stabilizes the state $|0\rangle$, though in practice, of course, we need a larger code space to enable useful, fault tolerant quantum logic. Aug 18, 2020 at 14:46