ZX-CALCULUS · CODE DISTANCE · REWRITE RULES

Where does distance break — and by how much?

Given a famous quantum error-correcting code, we enumerate (sample) its ZX rewrite space, compute the ZX distance at every point, and chart where distance breaks, by how much, and in which structural neighborhoods — as a re-runnable, content-hashed atlas.

Baseline semantics: Rodatz–Poór–Kissinger, arXiv:2410.17240 v4 (the sole authority). Engine: PyZX + a dual-implementation ZX-distance module, cross-checked against Prop 3.3 as a free oracle.

Choose a city

PIPELINE T0–T2 IN PROGRESS

Surface Code

d = 3, 5, 7 · The first city. Full T0–T5 pipeline is validated here before anywhere else; depth-limited BFS rewrite graph, sampled — not enumerated.

anchor test set below; engine gates green 2026-10-03; M0 distance semantics validated 2026-10-08.

QUEUED AFTER CITY 1

Color Code

d = 3, 5, 7 · Rule report cards get their cross-city comparison here: the same rewrite can preserve distance in one city and shatter it in another.

QUEUED AFTER CITY 1

Floquet Color Code

d = 3, 5, 7 · The moving city. Floquetification (RPK24 §Floquet) is exactly where measurement-outcome-postselection semantics matter most.

📐 Honesty boundary. Every atlas dataset ships as rewrite-space sample under depth-N BFS with full sampling metadata (depth cap, node cap, rule order, seed) and a content hash. We do not claim the full rewrite space; we publish the map and the trail we walked.

Pipeline & hard gates

T0 · NormalizeCanonical ZX graph + hash. Gate: determinism + code-space invariance. GREEN 2026-10-04 — canonical-label hash iso deferred (reported).
T1 · InstancesAll applicable rule instances on the graph. Gate: count & dedup self-check. GREEN 2026-10-04 — sp/lc enumerated, pivot count 0 on all anchors (observed, reported).
T2 · DistanceZX distance per instance, dual-impl. Gate: anchors + Prop 3.3 oracle all green. GREEN 2026-10-03
T3 · GraphBFS / sampled rewrite graph. Gate: sampling metadata mandatory. PARTIAL GREEN 2026-10-04 — first datasets on all four anchors (content-hash identical local/server). M0 semantics pinning GREEN 2026-10-08: Def 2.16 restricted distance validated against published d on all four anchors (input_data hypothesis; dual classification + state-vector cross-check; local == server). Δd coloring of the rewrite graph: GREEN 2026-10-14 — d=1 for every scanned node on all four anchors (4q 296/296, 5q 1010/1010, Steane 1021/1021 full; Shor 60/60 frozen deterministic sample of 1013), Δd flat (all 0 relative to d_root=1); local == server, 0 d/witness mismatches on all common nodes (Shor overlap 52).
T4 · RenderStatic SVG map slices. Gate: ≥20 nodes spot-checked vs raw. PENDING
T5 · ReportRule distance profiles. Gate: zero theorem implication. PENDING

Anchor test set (engine self-check, every run)

CodeParamsZX distanceRoleGate status
[[4,2,2]]4 qubits, k=2d = 2Smallest anchor PASS 2026-10-03
[[5,1,3]]5 qubits, k=1d = 3Perfect code PASS 2026-10-03
[[7,1,3]] Steane7 qubits, k=1d = 3Color-code parent PASS 2026-10-03
[[9,1,3]] Shor9 qubits, k=1d = 3Repetition-based anchor PASS 2026-10-03

Prop 3.3 oracle: for any stabilizer code, the ZX distance of its establishment-measurement circuit equals d. If the engine cannot recover d on the raw circuit — with zero rewriting applied — the run is declared wrong and nothing enters the database.

✅ Gate log, 2026-10-14 (M1 — rewrite-graph Δd coloring). Weight-1 Pauli-flip restricted distance measured graph-side over the gated T3 rewrite space: [[4,2,2]] 296/296, [[5,1,3]] 1010/1010, [[7,1,3]] Steane 1021/1021 (full); [[9,1,3]] Shor 60/60 frozen deterministic sample (root + even hash stride). Every scanned node has d=1 (undetectable non-trivial single-edge flip exists), so Δd = 0 across the entire rewrite space — the distance is flat under all applicable rewrites. psi± superposition certification (two-image zero <=> per-basis zero) equivalence-verified against per-basis enumeration; simple-edge scan only, H-edge flips excluded by the pinned semantics (HXH=Z, non-Pauli). Server re-run cross-check: 0 d mismatches, 0 witness mismatches on every common node (4q/5q full, Steane 700 overlap, Shor 52 overlap). Checkpoint: m06_deltad_2026-10-14.json. 技术报告 PDF(中文).
✅ Gate log, 2026-10-08 (M0 — RPK24 v4 distance semantics pinned & validated). Three implementation bugs found and fixed on the way (postselection spider is a phase-0 X-spider = √2⟨0|; a phase-0 Z-spider is ⟨+| — graph-vs-circuit bit-order bridge; edge subdivision must inherit the H-edge type), plus one upstream defect in PyZX's naive contractor worked around and documented (edge-subdivided graphs with H-edges gain spurious tensor support). Error classification uses exact Pauli propagation through the Clifford check circuit — provably equivalent for Pauli edge flips — cross-validated against independent direct state-vector simulation: 0 disagreements (350 / 485 / 625 / 645 checks per anchor). Def 2.16 restricted distance reproduces published d on all four anchors under the fault-tolerant-preparation input_data hypothesis (G1 PASS), corrupted-generator negative control flips (G2 PASS), dense-tensor G0 on the two small anchors, identical output locally and on the build server. Reported findings (semantics, not bugs): bare single-round measurement circuits have restricted distance 1 under wider segment hypotheses — post-interaction and output-segment errors are invisible to that round; and ancilla-preparation X faults can cancel data-error syndromes (observed on [[5,1,3]]) — both are exactly what the Def 2.16 fault-tolerant preparation remark excludes. Records: data/m05_semantics_2026-10-08.json, engine/m05_semantics.py, docs/m0_semantics.md (appendix).
🗺️ Gate log, 2026-10-04 (T3 — first rewrite graphs). Depth-3 BFS over applicable rule instances on the raw check graphs of all four anchors; sampling metadata and content hashes ship in data/t04_2026-10-04.json. Sizes: [[4,2,2]] 296 nodes / 878 edges (canonical labels 169/296, node cap not hit); [[5,1,3]] 1010/1948 (cap hit); Steane 1021/1884 (cap hit, canonical 43/1021); Shor 1013/1918 (cap hit, canonical 6/1013). Where canonical labels are sparse the node count is an upper bound (iso-deferred dedup). Determinism gate: two full runs per anchor, identical content hash, locally and on the build server. Nodes carry structural statistics only; distance coloring awaits RPK25 gadget-orbit fault semantics (see layer-2 log below). Engine: engine/t04_bfs_graph.py.
📋 Gate log, 2026-10-04 (engine layer 2 — rule profiles). Full rule-applicability census on the anchor set, identical locally and on the build server: sp applicable 14 / 26 / 42 / 31; lc 0 everywhere (structurally absent — π/2-phase precondition vs 0/π-only bare check circuits); pivot candidates 4 / 13 / 17 / 24, applicable 0 (PyZX preconditions). Circuit-level fault distance on bare check circuits: 1 / 2 / 2 / 1 vs published 2 / 3 / 3 / 3 — expected bare-syndrome-extraction physics, C0 invariance gate PASS. Δd measurement is blocked: circuit extraction proved non-faithful where tensor-verifiable, and verification exceeds memory on the largest anchor. One real gate bug was found and fixed the same day ("inconclusive" was silently counted as verified); after the fix, local and server agree. Δd's only sound path is graph-side fault semantics (RPK25 gadget orbit) — scheduled next. Records: data/t03_2026-10-04.json, engine engine/t03_profiles.py.
✅ Gate log, 2026-10-03. Both T2 gates PASS on the anchor set, locally and on the build server (identical output): dual implementation (brute-force Pauli enumeration vs. binary-symplectic normalizer algebra) agrees on every anchor and reproduces published d; the Prop 3.3 oracle (exact code-space evaluation, zero rewriting) independently reproduces every d. Note: the oracle's current implementation is an exact state-space evaluation of the established code space; the ZX-diagram-level oracle (synthesized establishment circuit through PyZX) lands with T0/T1. The previously listed "[[13,1,3]] surface" anchor had no standard literature referent and was corrected to Shor [[9,1,3]]. Every number above is a computational verification, not a proof. Records: data/t02_anchors_*.json, data/t02_oracle_*.json in the project repository.