# How does moving qubits on the surface code not change the logical state

I am reading this paper, and I do not understand how the process of moving a qubit does not change the logical state.

Moving a qubit is done by

1. Extending the logical $$\hat{Z}_L$$ operator to include an adjacent measurement-qubit
2. Extending the hole by not measuring the measurement-qubit
3. Measuring the data qubit that is now not stabilized
4. Turning on the measurement-qubit that was in the original hole
5. Changing the logical operators to match the new structure

I understand why 1 and 2 do not change the logical state held by the surface code (we do not perform any gate or measurement). However it is not clear to me why after measuring the logical qubit and adding it back again to the surface code, the measurement outcomes of the logical operators does not change.

Let's assume that we do the move without any errors.

We denote the state before the move as $$|\psi_L\rangle$$, so that

$$Z_L|\psi_L\rangle=|\psi'_L\rangle \\ X_L|\psi_L\rangle=|\psi''_L\rangle \\$$

What happens during the move? After step (b), we stopped measuring the stabilizer $$Z_6Z_7Z_8Z_9$$ - this didn't change the state, and we also measured $$X_6$$, namely we projected the state to become

$$|\psi^b_L\rangle = \frac{1+(-1)^{x_6} X_6}{2}|\psi_L\rangle.$$ The new logical operators are $$X_L$$ and $$Z_L^e=Z_3Z_4Z_5Z_7Z_8Z_9$$. But they act on $$|\psi^b_L\rangle$$ exactly like the previous operators acted on $$|\psi_L\rangle$$ up to sign, because

$$Z_L^e|\psi^b_L\rangle=\frac{1+(-1)^{x_6} X_6}{2}Z_6Z_7Z_8Z_9Z_L|\psi_L\rangle \\ =(-1)^{z_{6789}}\frac{1+(-1)^{x_6} X_6}{2}|\psi'_L\rangle$$ and $$X_L$$ commutes with $$X_6$$.

Now we do the cycle shown in (c). Here the calculation is similar to above so I just outline it. Qubit 6 is fully stabilized by two X stabilizers and also by the stabilizer $$Z_3Z_4Z_5Z_6$$. The state is thefore projected and becomes an eigenstate of $$Z_3Z_4Z_5Z_6$$ and these 2 X stabilizers. However, if we act on it with the new logical gates $$Z_L'$$ and $$X_L'$$, it will be (up to sign) like acting on them with $$X_L$$ and $$Z_L^e$$, which in turn was the same as acting on them with $$Z_L$$ and $$X_L$$. That's really why it has to be a 2-step process, and also why you need to keep track of the outcomes of the first $$z_{6789}$$ result, $$x_6$$ and the last $$z_{3456}$$.