Perturbative Continuous Unitary Transformations (pCUT) map a perturbed quantum many-body Hamiltonian into an effective quasiparticle-conserving Hamiltonian order by order in exact arithmetic. In practice, hand-coded pCUT pipelines break silently when is not equidistant, when a cluster embedding factor is miscounted, or when floating-point rounding corrupts high-order Padé poles.
Weyl makes the entire pipeline—from static spectral preconditions to rational flow recursion, linked-cluster expansion, prime-field reconstruction, dlog-Padé extrapolation, and independent oracle comparison—a single verified compilation target (examples/toric_boundary.weyl).
Equidistant Spectrum Precondition (T-Pcut)
Standard pCUT requires the unperturbed Hamiltonian to have an equidistant spectrum bounded from below, and the perturbation to decompose into finitely many quasiparticle-changing operators :
where has integer eigenvalues and is the unique energy quantum.
In examples/toric_boundary.weyl, the rough–smooth Toric Code cylinder is declared with an integer bulk coupling :
given J : positive integer
given x, κ₁, κ₂ : small parameter
define H₀ ≔ − J Σ_v A_v − J Σ_p B_p − Σ_i P_i
define V ≔ − x Σ_i σˣ_{d_i} − κ₁ Σ_i σᶻ_{d_i} − κ₂ Σ_i σᶻ_{h_i}
define H ≔ H₀ + V
expand H_eff ≔ pCUT of H around H₀
to O(x¹⁵) at κ₁ = κ₂ = 0, to total order 10 in (x, κ₁, κ₂) otherwise
in the sector where every conserved A_v, B_p equals +1At compile time, rule T-Pcut checks three invariants without constructing any Hilbert-space matrix. First, it verifies mutual commutation across by checking every pair of templates with symplectic tests, emitting E0413 on any violation. Second, it establishes a provable common energy quantum: each term squares to with an integer (or statically commensurable rational) weight, fixing and . Third, it derives a finite decomposition directly from the flip masks, which determine the allowed sets: , , and .
Changing J to a continuous symbol immediately fails type checking:
error[E0412]: pCUT requires a provably equidistant unperturbed spectrum
--> toric_boundary.weyl:6:8
| given J : real number
| excitation energies of H₀ are {2 (P_i), 2J (A_v), 2J (B_p)}:
| J is a continuous symbol, so no common energy quantum exists for all J
= help: write `given J : positive integer` (assumption A3), or use epCUT (planned for Phase 2)Flow-Equation Coefficient Recursion in weyl-series
After rescaling to the dimensionless Hamiltonian (so couplings enter as and final order- physical coefficients scale by ), weyl-series integrates the Knetter–Uhrig quasiparticle-conserving flow equation:
where , , (rightmost operator acts first), and the generator uses . Projecting onto each word yields the exact ODE recursion:
with initial condition for and otherwise. The effective Hamiltonian coefficients are , which vanish unless .
Exact Integration & Caching
Each is represented as a finite exact sum with and . Multiplying by the integrating factor maps resonant terms () to with zero rounding error. As a built-in convergence self-check, taking the limit retains only terms, and every surviving term must satisfy ; any signals a non-convergent flow and aborts as an internal compiler error.
Because depends only on the allowed -set and order —never on the lattice—tables are memoized by and cached on disk (~ sequences for TFIM at ). At second order, for example, , which after restoring yields the exact Stage A ground-state energy density .
epCUT Core: Non-Equidistant Spectra over
weyl_series::epcut solves the same flow equation when the excitation energies of have no common quantum. The integers become elements of an exact ordered field : , or with signs taken on a chamber, an open interval of on which every quantity the flow depends on keeps its sign. is split as with , , and each is a finite sum with , integrated in closed form. The coefficients are therefore exact rational functions of , valid on the whole chamber.
use weyl_series::epcut::{effective_hamiltonian, Chamber, FlowField, RatFn};
// H₀ = diag(0, 1, J, 1 + J): two unrelated gaps, 1 and J.
let j = RatFn::symbol();
let one = RatFn::from_i64(1);
let levels = vec![RatFn::from_i64(0), one.clone(), j.clone(), one.add(&j)];
let chamber = Chamber::new(q(1, 1), q(2, 1)).unwrap(); // 1 < J < 2
let h_eff = effective_hamiltonian(&levels, &v, 5, &chamber)?; // h_eff[k − 1] is the x^k coefficient
// e.g. the second-order ground-state shift for V₀₁ = 1, V₀₂ = 2, V₀₃ = 3:
// h_eff[1][0][0] = −1 − 4/J − 9/(1 + J)A sign that is not constant on the chamber is an error that names the wall, not a silent choice:
the chamber crosses a wall: 1 + (-1)*J vanishes at J = 1, inside the chamber (1/2, 3/2)The module is checked three ways: on integer energies every flow function equals the pCUT one term by term (all 1,364 sequences over up to length 5); on the two-gap spectrum above the diagonal entries equal textbook Rayleigh–Schrödinger theory through order 5, computed by a separate recursion; and on a degenerate level the second and third orders equal the Schrieffer–Wolff formulas.
Not yet reachable from source
effective_hamiltonian works on a finite matrix. It is not connected to the cluster expansion or the front end: given J : real number followed by expand … pCUT still stops with E0412.
Schrieffer–Wolff Expansion on Finite Clusters
pCUT needs an equidistant unperturbed spectrum. When the low-energy sector is separated by several incommensurate scales (a Hubbard , a Hund coupling, a crystal field), the same question, "what is the effective Hamiltonian inside a sector of ?", is answered by a Schrieffer–Wolff transformation with . In Weyl it is one expand statement on a fermion model:
model Hubbard dimer: superexchange by a Schrieffer-Wolff expansion
units U = 1
given Λ : open chain of 2 sites
given c↑, c↓ : fermion on vertices(Λ)
given U : energy
given t : small parameter
define H₀ ≔ U Σ_i c↑†_i c↑_i c↓†_i c↓_i
define V ≔ − t Σ_i (c↑†_i c↑_{i+1} + c↑†_{i+1} c↑_i + c↓†_i c↓_{i+1} + c↓†_{i+1} c↓_i)
define H ≔ H₀ + V
claim H : Hermitian
claim [c↑†_i c↑_i c↓†_i c↓_i, c↑†_i c↑_i] = 0
expand H_eff ≔ SW of H around H₀ to O(t⁵)
compare H_eff with exact spectrumThe static premises (rule T-SW) are that the lattice is a finite cluster, that has numeric coefficients after the units declaration (so that every energy denominator is a rational number), that is linear in each small parameter, and that both are Hermitian and of even fermion parity. A symbolic scale or an infinite lattice is rejected with E0412, a non-Hermitian perturbation with E0301.
weyl-series::sw then works on normal-ordered fermion polynomials over . Every perturbation is split into components of definite energy transfer under , using the minimal polynomial of on the Krylov space of the operator, so the spectrum of need not be equidistant and several small parameters are expanded jointly, with the remainder tracked as a monomial ideal. The generator at each order is and the effective Hamiltonian is the part.
$ weylc run examples/hubbard_dimer_sw.weyl
model: Hubbard dimer: superexchange by a Schrieffer-Wolff expansion
sir: 0 term template(s), 3 derive node(s)
fermion cluster: 4 mode(s), perturbation in (t)
H_eff = H₀ + … through total order 4:
t · [−c↑†_1 c↑_2 − c↑†_1 c↓†_1 c↑_1 c↓_2 + …]
t² · [−2 c↑†_1 c↓†_1 c↑_1 c↓_1 − 2 c↑†_1 c↓†_1 c↑_2 c↓_2 + 2 c↑†_1 c↓†_2 c↑_1 c↓_2 − …]
t⁴ · [8 c↑†_1 c↓†_1 c↑_1 c↓_1 + 8 c↑†_1 c↓†_1 c↑_2 c↓_2 − 8 c↑†_1 c↓†_2 c↑_1 c↓_2 + …]
verdict [oracle.sw_spectrum]: Pass(Long brackets are abbreviated here with ….) On the half-filled Néel configuration the second-order coefficient is per configuration, i.e. the superexchange , and the fourth-order one reproduces the expansion of the exact singlet energy.
compare H_eff with exact spectrum is lowered to the pass oracle.sw_spectrum. The oracle shares no code with the expansion: it rebuilds and every coefficient of as matrices on Fock space with its own Jordan–Wigner signs and checks, exactly modulo two 63-bit primes, that each coefficient commutes with and that order by order for in every symmetry block. The trace identities are necessary for isospectrality, not sufficient. Changing one fourth-order coefficient by one, dropping the second-order term, or putting the bare hopping back are each rejected, with first_bad_order 4, 2 and a block-diagonality failure respectively.
Current limits: one-dimensional clusters of at most 16 fermion modes; no bosons in the expanded model; no comparison yet against other Schrieffer–Wolff codes on shared benchmarks.
Linked-Cluster Expansion (LCE) & Prime-Field Reconstruction
Because is cluster-additive, extensive observables are computed on finite connected graphs rather than the thermodynamic lattice:
where is the lattice embedding count per unit cell, is the graph automorphism symmetry factor, and is the reduced cumulant obtained by inclusion–exclusion over proper subclusters .
In this framework, the ground-state energy density subtracts along with subcluster vacuum energies, while one-particle hopping amplitudes subtract the same-cluster vacuum energy before subcluster inclusion–exclusion and then Fourier transform to inside the isolated odd--parity, sector. In toric_boundary.weyl, all stars at and all bulk plaquettes are conserved, causing the linked-cluster expansion to collapse to a quasi-1D problem: even with bulk -creating perturbations (), order requires only boundary chains of length . Coupling monomials are packed directly into the byte prefix of each KIR term, avoiding multivariate polynomial interpolation altogether.
Exact vs. Multi-Prime CRT Reconstruction
Evaluating over millions of cluster paths with arbitrary-precision BigRational arithmetic is memory-bound. weyl-num therefore evaluates KIR term streams simultaneously over independent 63-bit prime fields and reconstructs exact rationals via the Chinese Remainder Theorem (CRT):
| Stage | Direct Arithmetic | + CRT Reconstruction (weyl-num) |
|---|---|---|
| Term accumulation | Variable-size heap BigInt, frequent gcd | Fixed-width [u64; K] (K >= 4, 32 B inline) |
| Denominator handling | Dynamic per-term reduction | Static common denominator from , LCE weights |
| Exactness guarantee | Exact by construction | A priori numerator bound ; chooses primes with |
| Complex phases () | Two BigRational components | Separate real/imag keys in with ; checks |
Why A Priori Bounds Matter
Weyl computes statically before launching the cluster sum by bounding the sum of absolute values over all allowed paths and embeddings. Choosing enough primes to satisfy guarantees mathematically unique CRT recovery—never relying on heuristic "stability under one extra prime."
dlog-Padé Extrapolation & Error Lattice Tracking
Near a continuous quantum phase transition where the one-particle gap closes as , the logarithmic derivative has a simple pole at with residue :
Weyl's estimate (x_c, zν) from Δ by dlog-Padé in x constructs rational approximants (, ) of over using rank-revealing elimination. For each candidate, the solver normalizes the denominator constant term to , cancels before extracting roots, and rejects any approximant whose Taylor expansion fails to match through order . Defective approximants are then filtered out—discarding Froissart doublets (pole–zero pairs within tolerance) and unphysical poles on closer to the origin than the physical singularity—and the surviving diagonal and near-diagonal estimates are aggregated into an ensemble to compute and its spread.
| Approximant | Pole (Stage A, ) | Residue (Stage A) | Typical Stage B Behavior (, ) |
|---|---|---|---|
| (exact) | (exact) | Low-order baseline; sensitive to subleading corrections | |
| (after gcd) | (after gcd) | Near-diagonal primary estimate for | |
| (after gcd) | (after gcd) | Paired with to measure PadeSpread | |
| (after gcd) | (after gcd) | Checked for Froissart doublets before inclusion |
Error Tags (Trunc × EpiKind) and require Checks
Every scalar and series in Weyl carries a static error grade Err = (Trunc, EpiKind) (weyl-types):
pub struct Trunc { pub vars: VarSet, pub generators: Vec<ExponentVector> } // Dickson basis of ideal I
pub struct EpiKind { pub sources: SourceSet, pub method: EpiMethod } // e.g. PadeSpread(dlog-Pade)
pub struct Err { pub trunc: Trunc, pub epi: EpiKind }Here Trunc stores the minimal generating antichain (Dickson basis) of the remainder monomial ideal , such as Box{x: 16} for or Total{(x, κ₁, κ₂): 11} for total order 10. For two truncated series and , addition propagates while multiplication applies the conservative ideal rule
which preserves even when or .
Meanwhile, EpiKind tags dlog-Padé outputs with Epi{PadeSpread(dlog-Padé)}. Even in Stage A, where yields , exact , , and zero spread across all approximants, the Epi tag is never erased—so claim x_c = 1 fails with E0330 unless written claim x_c ≈ 1 within 3σ. When an epistemic uncertainty exceeds a user's threshold, require triggers automated order escalation:
define e₀ ≔ (⟨vac| H_eff |vac⟩ − E_bulk) / L
define ω(k) ≔ one-particle dispersion of H_eff
define Δ ≔ ω(0)
estimate (x_c, zν) from Δ by dlog-Padé in x
require uncertainty of x_c < 10⁻³ otherwise expand to higher orderOracle Verification: Free Fermions & ED Residual Protocol
Weyl never trusts a perturbation kernel on its own. compare invokes independent oracles in weyl-oracle that compile directly from the HIR Hamiltonian without sharing pCUT's syndrome mapping:
compare H_eff with free fermions at κ₁ = κ₂ = 0
compare H_eff through total order 10 with exact diagonalization on L = 12, W = 2
by vacuum sector (k = 0, W_e^top = +1)
and one-particle sector (k, W_e^top = −1)
using double-double arithmetic, residual protocol of section 6.7In Stage A, the free-fermion oracle compares every rational coefficient of and through order 14 against with zero tolerance. In Stage B, the ED oracle evaluates the series along a fixed ray for in double-double precision (~106-bit significand) on a stabilizer-reduced cylinder. It fits the log–log residual slope against the first omitted non-zero order (within tolerance ) and reports first_bad_order on mismatch—while never allowing floating-point ED eigenvalues to upgrade a Trunc or Epi value to Exact.
When an oracle check fails (for instance, during mutation testing or if a cluster embedding is omitted), weyl-oracle emits structured telemetry for deterministic replay (weylc replay):
{
"schema": "weyl.telemetry",
"node": "cluster.eval",
"status": "oracle_failed",
"ir": { "layer": "KIR", "terms_peak": 48211033, "clusters": 13 },
"oracle": {
"kind": "ed",
"verdict": "fail",
"observable": "gap",
"residual_slope": 8.9,
"expected_slope": 13.0,
"precision": "double-double",
"size_L": 16,
"first_bad_order": 8
},
"hints": ["terms at order 8 involve clusters of length 9 for the first time"]
}