Exact commuting-projector Hamiltonians—from the 2D Toric Code and general CSS quantum error-correcting codes to 3D fracton models like X-cube—share an algebraic backbone: every local check operator is a Pauli (or generalized qudit Weyl–Heisenberg) string. Instead of building exponentially large dense matrices, Weyl compiles stabilizer models directly in symplectic vector spaces over (and for qudits), reducing both static type verification and finite-size exact diagonalization to bit-level linear algebra.
Symplectic Representation over and
For qubits, every Pauli string is represented in weyl-canonical by a phase and a binary symplectic vector . Multiplication merges sparse sorted u32 site words (site << 2) | code in time, and commutation reduces to the symplectic inner product:
For -level qudits (Qudit<d>, prime or prime-power ), generalized Pauli operators and () satisfy . Strings map to vectors with commutation factor
A stabilizer group is an isotropic subspace ( for all ) that excludes . For a CSS code with separate -type and -type parity-check matrices and , mutual commutation is the matrix orthogonality condition
where is the number of encoded logical qubits (ground-state degeneracy ).
Stabilizer Coordinate Transformations (weyl-topo + weyl-canonical)
When compiling an unperturbed stabilizer Hamiltonian , some checks may satisfy global product relations (e.g. on a torus). weyl-topo extracts a maximal independent stabilizer subset , records all dependent product relations, and runs symplectic Gram–Schmidt to complete a canonical Clifford basis consisting of destabilizers satisfying , , and , together with logical symplectic pairs that commute with all and obey .
Fixing a canonical product ordering uniquely decomposes any Pauli operator and gives its bit-level action on syndrome-logical basis states (, ):
Why SIR Never Expands Projectors
A naive perturbative lowering of a Pauli perturbation into operators would expand syndrome projectors onto fixed sectors. Instead, Weyl's SIR stores only the flip mask and phase mask ; KIR evaluates the exact energy jump dynamically on each active syndrome state :
When all terms are independent with weights , this simplifies to ; when product relations exist (like ), KIR evaluates from the full energy table.
In weyl-canonical and weyl-topo, the compiled operator action is stored in compact bit-packed Rust structs:
/// Canonical sparse Pauli word: each u32 packs `(site << 2) | pauli_code` (X=1, Y=2, Z=3)
pub struct PauliWord {
pub phase: u8, // i^phase, phase in {0, 1, 2, 3}
pub ops: Vec<u32>, // strictly ascending by site; big-endian memcmp = lex order
}
/// Stabilizer-basis action on syndrome-logical states |s, l>
pub struct StabilizerAction {
pub flip_syndrome: BitVec, // a: bitmask of destabilizers D_j flipped
pub phase_syndrome: BitVec, // b: bitmask of stabilizers S_j contributing (-1)^{b·s}
pub flip_logical: u64, // u: logical X_r mask
pub phase_logical: u64, // v: logical Z_r mask
pub phase: u8, // overall i^phi
}Logical Operators as Wilson & 't Hooft Loops
The centralizer of the stabilizer group is generated by non-contractible Wilson loops (-strings carrying electric flux) and 't Hooft loops (-strings carrying magnetic flux). Their algebra encodes the topology of :
| Geometry | Boundary Types | Independent Logical Pairs | Non-Contractible Loop Generators |
|---|---|---|---|
| Torus | Periodic Periodic | () | and |
| Cylinder | Rough () – Rough () | () | Horizontal , vertical open -string |
| Cylinder | Smooth () – Smooth () | () | Horizontal , vertical open -string |
| Cylinder | Rough () – Smooth () | () | None (unique vacuum; labels parity) |
Cross-Sector One-Particle States on the Rough–Smooth Cylinder
On the rough–smooth cylinder of examples/toric_boundary.weyl ( qubits), define the bottom and top horizontal electric Wilson loops:
Two exact operator identities hold on the lattice:
In the conserved bulk sector where every , the boundary -anyon parity is locked to the top Wilson loop: . Consequently, the vacuum () lies in , while the single boundary -particle state () lies in . The one-particle dispersion must therefore be extracted across Wilson sectors:
Common Pitfall: Same-Sector Excitations
Taking the first excited state within the sector yields a two-particle continuum state (), not the single-particle gap . Weyl's compare clause explicitly binds both sectors so the ED oracle never conflates them.
CSS Codes & 3D Fracton Stabilizer Models (X-Cube) Draft
Weyl's template-based symplectic engine generalizes seamlessly beyond 2D surface codes to 3D type-I fracton CSS models such as the X-cube model on a 3D cubic lattice :
model X-cube fracton stabilizer code on a 3-torus
given Λ : cubic lattice on a 3-torus (Lx, Ly, Lz)
given σ : qubit on edges(Λ)
define A_c ≔ ∏_{l ∈ cube(c)} σˣ_l for c ∈ cubes(Λ)
define B_v^xy ≔ ∏_{l ∋ v, l ⊥ z} σᶻ_l for v ∈ vertices(Λ)
define B_v^yz ≔ ∏_{l ∋ v, l ⊥ x} σᶻ_l for v ∈ vertices(Λ)
define B_v^zx ≔ ∏_{l ∋ v, l ⊥ y} σᶻ_l for v ∈ vertices(Λ)
define H_xcube ≔ − Σ_c A_c − Σ_v (B_v^xy + B_v^yz + B_v^zx)
claim H_xcube : Hermitian, local
claim [A_c, B_v^xy] = 0 and [B_v^xy, B_v^yz] = 0
claim B_v^xy · B_v^yz · B_v^zx = 1Because every cube shares either or edges with each planar cross , T-Comm proves mutual commutation in time independent of . The planar product relations give sub-extensive topological degeneracy , while syndrome analysis immediately shows that a single flips four adjacent cubes (creating immobile fractons at membrane corners) whereas flips two crosses along an axis (creating 1D lineons).
Static Commutation, Gauge Invariance & weylc Diagnostics
Every operator expression synthesizes an internal 5-tuple type Op<Space, Charge, Herm, Grade, Support> (weyl-types). For the rough–smooth Toric Code benchmark, the type checker synthesizes exact symplectic charges on unit-cell representatives without instantiating :
| Operator Template | Symplectic Overlap | Synthesized Charge | Effect on |
|---|---|---|---|
| Even overlap () with all | (vacuum) | Retained in | |
| ( term) | with | (net ) | Breaks ; preserves all |
| ( term) | with | (net ) | Removes stars from |
| ( term) | with only | (absorbed by rough ) | Removes stars; anticommutes with |
For any Hamiltonian , the type checker computes the maximal conserved stabilizer set and checks locality (support diameter ), Hermiticity, and explicit conservation claims (H conserves C).
When a perturbation violates locality, Hermiticity, or gauge invariance, weylc check reports exact symplectic witnesses before any numerical solver runs:
error[E0301]: `H` is claimed Hermitian but is not
--> toric_boundary.weyl:17:22
| define V ≔ − x Σ_i σˣ_{d_i} σᶻ_{d_i} − κ₁ Σ_i σᶻ_{d_i} − κ₂ Σ_i σᶻ_{h_i}
| σˣ_{d_i} and σᶻ_{d_i} anticommute (ε = −1), so their product is anti-Hermitian (T-Mul)
= help: use σʸ_{d_i}, or multiply by i
error[E0320]: term violates declared gauge symmetry `A_v`
--> bad_gauge.weyl:14:18
| define V ≔ − h Σ_{l ∈ bulk} σᶻ_l
| σᶻ_l anticommutes with bulk stars A_{v₁}, A_{v₂} (ω = 1 on edge l),
| violating `claim H conserves A_v for v ∈ bulk`
= help: dress σᶻ_l with matter charges, or restrict the sum to boundary dangling edges d_i
error[E0201]: operator support exceeds locality bound or crosses open boundary
--> bad_local.weyl:11:25
| define W ≔ ∏_{i=0}^{L-1} σᶻ_{h_{i,0}}
| support diameter grows with symbolic size L (exceeds R_max = 4 unit cells)
= help: global Wilson loops cannot enter local `H`; bind W as a sector observable insteadCylinder Reduction & External ED Export
For the rough–smooth cylinder ( qubits, where a single dense f64 state vector would require ), weyl-oracle independently constructs a Clifford stabilizer basis, fixes the conserved deep stars and bulk plaquettes , and blocks the remaining effective qubits by lattice translation momentum and .
To audit the reduced Hamiltonian externally with NumPy/SciPy, weylc export-ed emits a self-contained JSON specification and standalone solver script:
$ weylc export-ed examples/toric_boundary.weyl \
--size-l 8 --height-w 2 \
--at J=1,x=1/10,κ₁=1/20,κ₂=-1/20 \
--out ./ed_out
wrote ./ed_out/ed_model.json (N=48 qubits -> 16 active qubits after 32 conserved stabilizers)
wrote ./ed_out/solve_ed.py (sectors: k=0 W_e^top=+1, k=0 W_e^top=-1)The exported ed_model.json records the reduced active-qubit Hamiltonian terms, exact E_bulk constant, and Wilson-sector projector masks so external Lanczos runs reproduce weyl-oracle to full double-double or f64 precision:
{
"schema": "weyl.ed-model",
"geometry": { "L": 8, "W": 2, "total_qubits": 48, "active_qubits": 16 },
"fixed_stabilizers": 32,
"e_bulk": -40.0,
"couplings": { "J": 1, "x": "1/10", "kappa_1": "1/20", "kappa_2": "-1/20" },
"sectors": [
{ "name": "vacuum", "momentum_k": 0, "wilson_top": 1 },
{ "name": "one_particle", "momentum_k": 0, "wilson_top": -1 }
],
"terms": [
{ "coeff": "-1", "pauli": "Z0 Z1", "label": "P_0" },
{ "coeff": "-1/10", "pauli": "X0", "label": "x*X(d_0)" }
]
}Symplectic Gram–Schmidt Independence
To prevent shared bugs between weyl-series and weyl-oracle, weyl-oracle builds its Clifford basis independently from the HIR microscopic Hamiltonian: it selects pivots among , finds a single-qubit or minimal-weight anticommuting partner , clears overlaps with all previously fixed pairs via , and extracts the remaining -dimensional symplectic complement as .