Manuscript En02-B@1 · En02-B-v1.tex · section · ca28dee4
Exact finite checks and a schedule explorer
Exact finite checks and a schedule explorer · lines 1910–2036
Copy the following standard-library Python source to
02_b_checks.py and run:
python en02_b_checks.py
The code uses Gaussian integers, represented by pairs of integers. Hadamards are applied without their factors, and those factors are accounted for explicitly in the checked norms. There is no floating-point state simulation.
The checks cover the supplied code projector, all physical Pauli operators of weight at most two, the batch and streaming branch factorizations, and a finite two-level schedule class. The tree channel theorem itself follows by composition in the main text; no dense twenty-five-qubit simulation is needed or claimed.
"""En02-B: exact finite checks, not a universal proof certificate.
Standard library only. Gaussian integers are pairs (real, imag). No execution log is supplied by the manuscript. """
from itertools import combinations, product from functools import lru_cache from dataclasses import dataclass
class CheckFailure(Exception): pass
def need(condition, message): if not condition: raise CheckFailure(message)
ZERO = (0, 0) ONE = (1, 0) II = (0, 1)
def add(a, b): return (a[0] + b[0], a[1] + b[1])
def neg(a): return (-a[0], -a[1])
def mul(a, b): return (a[0] * b[0] - a[1] * b[1], a[0] * b[1] + a[1] * b[0])
def conj(a): return (a[0], -a[1])
def norm_sq(a): return a[0] * a[0] + a[1] * a[1]
def inner(v, w): out = ZERO for a, b in zip(v, w): out = add(out, mul(conj(a), b)) return out
def vadd(v, w): return [add(a, b) for a, b in zip(v, w)]
def bits(index, n): return tuple((index >> (n - 1 - j)) & 1 for j in range(n))
def index_of(bs): out = 0 for b in bs: out = 2 * out + b return out
def nqubits(v): size = len(v) need(size >= 1 and (size & (size - 1)) == 0, "state size is not a power of two") return size.bit_length() - 1
def pauli_action(v, word, phase=0): """Apply i**phase times a Pauli word exactly.""" n = nqubits(v) need(len(word) == n, "wrong Pauli arity") units = (ONE, II, (-1, 0), (0, -1)) out = [ZERO] * len(v) for k, amp in enumerate(v): bs = list(bits(k, n)) factor = units[phase for j, letter in enumerate(word): b = bs[j] if letter == "X": bs[j] ^= 1 elif letter == "Z": if b: factor = neg(factor) elif letter == "Y": factor = mul(factor, II if b == 0 else (0, -1)) bs[j] ^= 1 elif letter != "I": raise CheckFailure("invalid Pauli letter") target = index_of(bs) out[target] = add(out[target], mul(factor, amp)) return out
LOCAL_PRODUCT = ("X", "Y"): (1, "Z"), ("Y", "Z"): (1, "X"), ("Z", "X"): (1, "Y"), ("Y", "X"): (3, "Z"), ("Z", "Y"): (3, "X"), ("X", "Z"): (3, "Y"),