Solution (source code)

= Solution

On the square lattice the PEPO intertwines the local operators as
$$
X_uX_v\longleftrightarrow\widetilde Z_{e=(uv)},
\qquad
Z_v\longleftrightarrow A_v=\prod_{e\ni v}\widetilde X_e.
$$
Its image also obeys the automatic zero-flux constraints $B_p=\prod_{e\in\partial p}\widetilde Z_e=1$. Thus the transverse-field Ising Hamiltonian maps to a $\mathbb Z_2$ lattice-gauge Hamiltonian generated by edge fields and stars in the zero-flux sector.

At the commuting-projector fixed point, promoting the image constraints to energetic terms gives
$$
\boxed{H_{\rm TC}=-\sum_vA_v-\sum_pB_p},
$$
the <toric code> Hamiltonian. Conversely, within a simply connected zero-flux sector one may solve $\widetilde Z_{uv}=X_uX_v$ and recover vertex Ising variables. On a torus, the remaining noncontractible loop eigenvalues correspond to the different Ising boundary twists, which accounts for the toric code's topological ground-state sectors.