For integer L >= 2, take an L-by-L square fundamental domain and identify opposite sides. Put one qubit on each horizontal and vertical edge, an X check at each vertex, and a Z check on each face boundary. The result has n=2L², k=2, and d=L [Kitaev 1997; Kitaev 2003; Dennis et al. 2002]. The proof below is for this square cellulation, not an arbitrary torus mesh.
Let C2, C1, and C0 be the binary spaces generated by faces, edges, and vertices. Define
C2 --d2--> C1 --d1--> C0 .
Each column of d2 marks the four boundary edges of one face. Each column of d1 marks the two endpoints of one edge. At a corner of a face, exactly two of its boundary edges touch that vertex. Therefore every entry of d1 d2 is zero modulo two. The constructor checks this matrix identity directly.
Set HX=d1 and HZ=d2^T. Then
HX HZ^T = d1 d2 = 0,
so every X star commutes with every Z plaquette. In Pauli language a neighboring pair overlaps on two qubits, producing two anticommutation signs; a non-neighboring pair overlaps on none.
The periodic domain has L² vertices and L² faces. Choose at every vertex the horizontal edge leaving it and the vertical edge leaving it. This counts each edge exactly once, so there are 2L² edge qubits.
Every column of d1 has two ones. Hence the sum of all vertex rows is zero. To see that no further dependency exists, select a spanning tree of the connected periodic graph. Its vertex-edge incidence matrix has rank L²-1: starting at a leaf, its unique incident tree edge forces that leaf coefficient to vanish in any row dependency; removing leaves iteratively leaves only the global all-vertex relation. Thus rank(HX)=L²-1.
Apply the same argument to the connected dual graph. Faces are dual vertices and primal edges are dual edges, so rank(HZ)=L²-1. The total stabilizer rank is 2L²-2, and
k = n - rank(HX) - rank(HZ)
= 2L² - (L²-1) - (L²-1)
= 2.
This also identifies the two global dependencies: the product of every star and the product of every plaquette are each identity because every qubit appears twice.
A Z string is a binary edge chain. It commutes with all stars exactly when its boundary is zero, so closed Z strings lie in ker(d1). A product of plaquettes is a face boundary in im(d2). Therefore distinct Z logical classes are
H1(torus; GF(2)) = ker(d1) / im(d2).
There are two generators: one winds horizontally and one vertically. The dual cellulation gives two X cycles. Choose each dual cycle to cross its conjugate primal cycle once and the other primal cycle zero times. Odd intersection is the symplectic product, so each selected X/Z pair anticommutes and the cross-pairs commute.
The constructor exports exactly these four supports and refuses them if they fail stabilizer commutation, fall inside the stabilizer row space, or have the wrong four-by-four symplectic product matrix.
A straight row of L horizontal edges winds once around the torus and is a nontrivial Z cycle. A straight column of L vertical edges gives the other Z class. Corresponding straight dual loops supply X logicals. Each has weight L, so d <= L.
Take a primal cycle with nonzero horizontal winding. Draw the L parallel vertical dual cuts, one between each neighboring pair of vertex columns. A horizontal-winding cycle has odd intersection with every cut. Each primal edge can cross at most one such cut, so the cycle contains at least L edges. A vertical-winding cycle obeys the rotated argument.
If a cycle has zero winding in both directions, it is a face boundary and is not logical. Thus every nontrivial primal logical has weight at least L. Repeating the cut argument on the dual lattice gives the same lower bound for X logicals. Combining bounds yields d=L.
The L=2 cellulation is small but still satisfies the argument: opposite directions join the same two coordinate layers, yet the constructor keeps four distinct incident edge qubits at every check and exact enumeration returns distance two.
reproduce.py checks L=2,3,4 cell counts, ranks, row weights, global dependencies, logical intersections, and periodic scene data. It invokes exact distance enumeration for the two committed instances. The claims in instances.yaml carry {kind: verified} and are independently recomputed by make verify-entry.
Primary sources: kitaev1997imperfect, kitaev1997quantum, kitaev2003fault, and dennis2002topological.