# How does the surface code satisfy constraints of relativity?

Consider a surface code in the shape of a rectangle that has very very long horizontal edges and very short vertical edges. I initialize the surface code into the logical state $$\vert 0\rangle$$.

Let's say the boundaries are chosen such that the logical $$X$$ operator involves $$X$$ operations on physical qubits from top to bottom (along the short edge). Can one perform the logical $$X$$ measurement also only involving operations on a line of physical qubits from top to bottom?

If the answer to the measurement question is yes, how does this square with relativity? What if I perform a logical $$X$$ operation using qubits on the right edge of my surface code and then measure the logical state using qubits on the left edge?

If the answer to the measurement question is no, how many qubits of the surface code do I need to measure to know its logical state?

• Not an answer but I'm not sure it is possible to know the answer to your paragraph before the last one with the usual formalism of the surface code as it is based on non relativistic quantum mechanics. Commented May 14 at 19:56
• This is like an encoded version of the EPR paradox with a similar resolution. Commented May 15 at 0:19

TL;DR: Yes, you can apply logical $$X$$ gate by applying physical $$X$$ gate on qubits along one boundary, e.g. on the left, and you can measure logical $$X$$ by measuring physical $$X$$ on qubits along another boundary, e.g. on the right$$^1$$. This does not enable superluminal communication, because applying the $$X$$ gate has no effect on measuring the $$X$$ observable. For example, measuring $$X$$ on $$|0\rangle$$ yields the two outcomes $$\pm 1$$ with fifty-fifty probability. Measuring $$X$$ on $$|1\rangle$$ has the same output distribution.

## Quantum mechanics satisfies locality

Quantum mechanics satisfies the principle of locality$$^2$$, i.e. it does not allow superluminal communication. This can be understood as a consequence of two facts. First, if two operators $$U$$, describing a quantum gate, and $$O$$, describing a quantum observable, commute, then $$U$$ does not affect observations made using $$O$$. Second, if two operators act on spatially disjoint regions, then they commute$$^3$$.

## Communication requires non-commuting operators

Suppose that $$[U,O]=UO-OU=0$$ for some linear operators $$U$$ and $$O$$. Then for any quantum state $$\rho$$, we have \begin{align} \mathrm{tr}(OU\rho U^\dagger)=\mathrm{tr}(UO\rho U^\dagger)=\mathrm{tr}(O\rho U^\dagger U)=\mathrm{tr}(O\rho).\tag1 \end{align} This equation says that applying $$U$$ to $$\rho$$ doesn't affect measurements of $$O$$ on $$\rho$$. This implies that applying the $$X$$ gate has no effect on measuring the $$X$$ observable, because every operator commutes with itself.

## Operators with disjoint supports commute

Can we find two other logical operators that do not commute and can be applied on disjoint sets of qubits, like $$X$$ along the left boundary and $$X$$ along the right boundary? The answer is no. Consider two disjoint sets of qubits $$A$$ and $$B$$ and two operators $$U:=U_A\otimes I_B$$ and $$O:=I_A\otimes O_B$$. We have \begin{align} [U,O]=[U_A\otimes I_B,I_A\otimes O_B]=U_A\otimes O_B-U_A\otimes O_B=0.\tag2 \end{align} Clearly, we need the operators to act non-trivially on at least one qubit in common. For example, in the surface code, we could apply logical $$X$$ along the short boundary on the left and measure logical $$Z$$ along the long boundary at the top. The fact that they have to meet in the top left corner means there is no superluminal communication and no contradiction with locality or special relativity.

$$^1$$ Measuring only those qubits reduces the code distance, so it isn't the wise approach to realizing logical measurement. Nevertheless, it yields the correct logical measurement outcome in the absence of noise.
$$^2$$ If quantum mechanics is a manifestation of a deeper classical theory, then that deeper classical theory does not satisfy locality. This property of quantum mechanics is sometimes misleadingly called "quantum non-locality".
$$^3$$ In quantum field theories, this is usually postulated directly. In standard quantum mechanics it is a consequence of the tensor product structure of the Hilbert space (in turn postulated by the axiom about composite systems).

• Thanks, great answer! Just a quick question about footnote 1, is the idea of the surface code to do multiple vertical measurements and treat them as independent noisy measurements to determine the actual measurement outcome? Commented May 15 at 18:18
• I assume that "vertical" refers to repeated measurements of the same measure qubits at subsequent times. The answer to the question is no. This approach to decoding would discard valuable information. Instead, measurements are viewed as occurring in a 3D volume formed from the 2D qubit lattice and the time dimension and decoding is performed in this 3D volume. Commented May 15 at 22:21