# Moving pauli product rotations past measurements

I'm trying to understand how the clifford + T compiler works in "A Game of Surface codes".

How do I move a pauli product rotation block past a pauli product measurement block? More specifically, how do I get from a) to b).

a)

b)

Would appreciate any help. Thank you!

Let $$\sigma$$ and $$\tau$$ be two tensor products of Paulis. Imagine you have a gate sequence $$e^{i\theta\tau}\sqrt{\sigma},$$ then you can always rewrite this as $$e^{i\theta\tau}=\sqrt{\sigma}e^{i\theta\sqrt{\sigma}^\dagger\tau\sqrt{\sigma}}\sqrt{\sigma}^\dagger$$ such that $$e^{i\theta\tau}\sqrt{\sigma}=\sqrt{\sigma}e^{i\theta\sqrt{\sigma}^\dagger\tau\sqrt{\sigma}}.$$ In other words, we have moved the $$\sqrt{\sigma}$$ the other term, but the other term has updated from $$\tau$$ to $$\sqrt{\sigma}^\dagger\tau\sqrt{\sigma}$$. If $$\tau$$ and $$\sigma$$ commute, this just leaves $$\tau$$. But if they anti-commute, you get $$\tau\sigma$$ (up to an $$i$$ phase that I'm not being very careful about.
This manipulation doesn't care if it's a unitary that $$\tau$$ is doing, or a measurement, where $$\theta$$ might as well be $$\pi/2$$.