From b42e665721e76e69d05f24a19bdabee0e0f77c04 Mon Sep 17 00:00:00 2001 From: apoursh <8867770+apoursh@users.noreply.github.com> Date: Thu, 19 Nov 2026 12:04:23 -0500 Subject: [PATCH] Prove the five-qubit Clifford tensor threshold is fifteen --- .../clifford-five-qubit-threshold/MOMENTS.md | 44 ++ .../PROJECTION.json | 525 ++++++++++++++++++ .../clifford-five-qubit-threshold/PROOF.md | 59 ++ .../clifford-five-qubit-threshold/README.md | 43 ++ .../SOURCES.json | 76 +++ .../clifford-five-qubit-threshold/TASK.json | 99 ++++ .../clifford-five-qubit-threshold/VERIFY.json | 90 +++ .../check_archive_modular.py | 155 ++++++ .../check_gates.py | 168 ++++++ .../check_moments.py | 148 +++++ .../clifford-five-qubit-threshold/extract.py | 193 +++++++ .../clifford-five-qubit-threshold/verify.py | 86 +++ 12 files changed, 1686 insertions(+) create mode 100644 research/clifford-five-qubit-threshold/MOMENTS.md create mode 100644 research/clifford-five-qubit-threshold/PROJECTION.json create mode 100644 research/clifford-five-qubit-threshold/PROOF.md create mode 100644 research/clifford-five-qubit-threshold/README.md create mode 100644 research/clifford-five-qubit-threshold/SOURCES.json create mode 100644 research/clifford-five-qubit-threshold/TASK.json create mode 100644 research/clifford-five-qubit-threshold/VERIFY.json create mode 100644 research/clifford-five-qubit-threshold/check_archive_modular.py create mode 100644 research/clifford-five-qubit-threshold/check_gates.py create mode 100644 research/clifford-five-qubit-threshold/check_moments.py create mode 100644 research/clifford-five-qubit-threshold/extract.py create mode 100644 research/clifford-five-qubit-threshold/verify.py diff --git a/research/clifford-five-qubit-threshold/MOMENTS.md b/research/clifford-five-qubit-threshold/MOMENTS.md new file mode 100644 index 0000000000..4c3ebdc6fa --- /dev/null +++ b/research/clifford-five-qubit-threshold/MOMENTS.md @@ -0,0 +1,44 @@ +# Independent fixed-space census and Gram trace checks + +The width-14 and width-15 rank calculations depend on character projections. As a check on their class assignments, group orders and normalization, `check_moments.py` computes the fixed-space histograms for the three groups directly from subspace orbits. It then checks the first two trace moments of each full Gram matrix, counting zero modes with their regular multiplicities. Only the block side of these comparisons reads the supplied projections. + +## Counting fixed spaces from embeddings + +Let $G$ be the symplectic group on a binary space of dimension $2n$, or the isometry group of a nonsingular quadratic refinement of sign $\epsilon$. Write $I(k,r)=\prod_{j=0}^{r-1}(2^k-2^j)$ for the number of ordered independent $r$-tuples in a $k$-space. If $C_k$ counts group elements fixing a space of dimension exactly $k$, Burnside's lemma gives + +$$ +\sum_{k=r}^{2n} C_k I(k,r)=|G|\,a_r . +$$ + +Here $a_r$ is the number of orbits on ordered independent $r$-tuples. The system is triangular from $r=2n$ down to zero. Witt's extension lemma identifies an orbit with its pullback form on a fixed, labelled $r$-dimensional domain. Thus $a_r$ counts the forms that embed into the specified ambient space. + +For a polar form of rank $2h$, let $t=r-2h$ and $m=n-h$. There are $\binom{r}{t}_2 |\mathrm{GL}(2h,2)|/|\mathrm{Sp}(2h,2)|$ such forms: choose the radical and then a nonsingular alternating form on the quotient. In the symplectic case each embeds exactly when $t\le m$. + +For the orthogonal groups, fix a vector-space complement to the radical in the domain and refine its polar form to a quadratic form. There are $2^{h-1}(2^h+\delta)$ refinements of sign $\delta$ on this complement for $h>0$; the zero-dimensional complement has positive sign. The restriction on the radical is a linear functional. When $t\le m$, count the possibilities as follows. + +- A nonzero restriction contributes $(2^t-1)4^h$. After embedding the nonsingular $2h$-space, choose a nonsingular vector in its orthogonal complement, extend its line to a polar-isotropic $t$-plane, and choose an isomorphism matching the two nonzero linear restrictions. This case necessarily has $t>0$ and $m>0$. +- A zero restriction requires a totally singular $t$-plane in the complementary quadratic space of dimension $2m$ and sign $\epsilon\delta$. If $t= 2 and all(n % k for k in range(2, isqrt(n) + 1)), "Composite trial factor") + return + generator, factors = CERTIFICATES[n] + need(prod(factors) == n - 1 and pow(generator, n-1, n) == 1, "Primality factorization") + for q in set(factors): + certify_prime(q) + need(pow(generator, (n-1)//q, n) != 1, "Generator order is too small") + # An element of exact order n-1 in (Z/n)^* forces n prime. + + +def first_list(text): + start = text.index("[") + depth = 0 + for j in range(start, len(text)): + depth += int(text[j] == "[") - int(text[j] == "]") + if depth == 0: + return text[start:j+1], text[j+1:] + raise ValueError("Unterminated GAP list") + + +def evaluate_table(source, name, root): + data = source.split('MOT("' + name + '",', 1)[1] + _, data = first_list(data) + centralizers, data = first_list(data) + centralizers = json.loads(centralizers) + _, data = first_list(data) + values, _ = first_list(data) + values = "".join(values[1:-1].split()) + descriptions = [] + while values: + row, values = first_list(values) + values = values.removeprefix(",") + ref = re.fullmatch(r"\[(TENSOR|GALOIS),\[(\d+),(\d+)\]\]", row) + descriptions.append(ref.groups() if ref else (None, row[1:-1].split(","), None)) + + @cache + def value(token, power): + total = 0 + terms = STEP.findall(token) + need("".join(terms) == token, "Unsupported cyclotomic expression") + for term in terms: + if "E(" not in term: + total += int(term) + continue + sign, scale, order, exponent = ROOT_TERM.fullmatch(term).groups() + n = int(order) + need(CONDUCTOR % n == 0, "Unsupported root order") + k = (CONDUCTOR//n) * power * int(exponent or 1) % CONDUCTOR + total += (-1 if sign == "-" else 1) * int(scale or 1) * pow(root, k, PRIME) + return total % PRIME + + @cache + def row(index, power): + op, a, b = descriptions[index] + if op == "GALOIS": + return row(int(a)-1, power * int(b) % CONDUCTOR) + if op == "TENSOR": + return [(x*y) % PRIME for x, y in zip(row(int(a)-1, power), row(int(b)-1, power), strict=True)] + need(len(a) == len(centralizers), "Class count") + return [value(entry, power) for entry in a] + + need(len(descriptions) == len(centralizers), "Non-square table") + return centralizers, [row(j, 1) for j in range(len(descriptions))] + + +def check_blocks(centralizers, characters, dimensions, projection, t, width): + order = centralizers[0] + need(projection["order"] == order and order % PRIME, "Group order") + class_sizes = [order//c for c in centralizers] + need(sum(class_sizes) == order, "Class-size sum") + weights = [size * t**d % PRIME for size, d in zip(class_sizes, dimensions, strict=True)] + for char, (degree, *bins) in zip(characters, projection["rows"], strict=True): + need(char[0] == degree and len(bins) == 11, "Degree or fixed-space bins") + direct = sum(c*w for c, w in zip(char, weights, strict=True)) * pow(order, -1, PRIME) % PRIME + integer, rem = divmod(sum(b*t**j for j, b in enumerate(bins)), order) + need(rem == 0 and 0 <= integer <= 32**width and integer == direct, + "Direct cyclic-root calculation disagrees with the projection") + return len(characters) + + +def main(): + parser = ArgumentParser(description=__doc__) + parser.add_argument("archive", type=Path) + path = parser.parse_args().archive + need(sha256(path.read_bytes()).hexdigest() == ARCHIVE_SHA, "Wrong CTblLib archive") + certify_prime(PRIME) + need(PRIME > 32**15 and (PRIME-1) % CONDUCTOR == 0, "Insufficient field") + root = pow(2, (PRIME-1)//CONDUCTOR, PRIME) + need(pow(root, CONDUCTOR, PRIME) == 1 and + all(pow(root, CONDUCTOR//q, PRIME) != 1 for q in (3, 11, 17, 31)), "Root order") + tables = json.loads(Path(__file__).with_name("PROJECTION.json").read_text(encoding="utf-8")) + with tarfile.open(path, "r:gz") as archive: + def source(name): + with archive.extractfile("ctbllib-1.3.11/data/" + name) as f: + return f.read().decode("latin-1") + + name = "S10(2)" + cents, rows = evaluate_table(source("ctosymp1.tbl"), name, root) + a, b = [v for v in rows if v[0] in (495, 527)] + dims = [] + for x, y in zip(a, b, strict=True): + count = (2+x+y) % PRIME + need(count > 0 and count & (count-1) == 0, "Binary fixed-space count") + dims.append(count.bit_length()-1) + checked = sum(check_blocks(cents, rows, dims, tables[name], t, f) + for t, f in ((-64, 13), (128, 15))) + orthogonal = source("ctoorth3.tbl") + for name in ("O10+(2).2", "O10-(2).2"): + cents, rows = evaluate_table(orthogonal, name, root) + data = orthogonal.split('ALF("' + name + '","S10(2)",', 1)[1] + fusion = json.loads(first_list(data)[0]) + need(len(fusion) == len(cents) and all(1 <= j <= len(dims) for j in fusion), "Class fusion") + checked += check_blocks(cents, rows, [dims[j-1] for j in fusion], tables[name], -64, 14) + need(checked == 715, "Incomplete width-specific check") + print(f"PASS_DIRECT_MODULAR_ARCHIVE prime={PRIME} root_order={CONDUCTOR} " + f"width_specific_multiplicities={checked}") + + +if __name__ == "__main__": + main() diff --git a/research/clifford-five-qubit-threshold/check_gates.py b/research/clifford-five-qubit-threshold/check_gates.py new file mode 100644 index 0000000000..fde854787d --- /dev/null +++ b/research/clifford-five-qubit-threshold/check_gates.py @@ -0,0 +1,168 @@ +"""Test trace phases and quadratic Bell-label transport on literal five-qubit gates. +The sparse columns have Gaussian integer entries with a shared power-of-two denominator. +apoursh with substantial OpenAI Codex assistance. Apache-2.0. +""" +from itertools import product + +N = 5 +D = 1 << N +MASK = D - 1 + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def mul(v, w): + a,b = v + c,d = w + return a*c-b*d, a*d+b*c + + +def power(v, n): + out = (1,0) + for _ in range(n): + out = mul(out,v) + return out + + +def accumulate(values, key, delta): + a,b = values.get(key,(0,0)) + values[key] = a+delta[0], b+delta[1] + + +def sign(mask): + return 1 - 2*(mask.bit_count() & 1) + + +def gate_matrix(program): + columns = [{j:(1,0)} for j in range(D)] + denominator = 1 + for gate, a, b in program: + active = 1 << a + if gate == "H": + # Multiply the usual Hadamard lift by its eighth-root phase, + # obtaining (1+i)[[1,1],[1,-1]]/2 in the Gaussian-dyadic ring. + denominator *= 2 + for j,col in enumerate(columns): + new = {} + for y, (v,w) in col.items(): + if gate == "H": + lo, hi = y & ~active, y | active + accumulate(new,lo,(v-w,v+w)) + factor = sign(y & active) + accumulate(new,hi,(factor*(v-w),factor*(v+w))) + elif gate == "S": + new[y] = (-w,v) if y & active else (v,w) + elif gate == "X": + new[y ^ active] = (v,w) + elif gate == "Z": + factor = sign(y & active) + new[y] = v*factor,w*factor + elif gate == "CNOT": + new[y ^ ((1 << b) if y & active else 0)] = (v,w) + else: + raise ValueError(gate) + columns[j] = {r:c for r,c in new.items() if c != (0,0)} + return columns, denominator + + +def symplectic(program, label): + x, z = label & MASK, label >> N + for gate,a,b in program: + bit = 1 << a + if gate == "H" and bool(x & bit) != bool(z & bit): + x ^= bit + z ^= bit + if gate == "S" and x & bit: + z ^= bit + if gate == "CNOT": + x ^= ((x >> a) & 1) << b + z ^= ((z >> b) & 1) << a + return (z << N) | x + + +def translate_trace(columns, x, z): + real = imag = 0 + for j,col in enumerate(columns): + y = x ^ j + a,b = col.get(y,(0,0)) + factor = sign(z & y) + real += a*factor + imag += b*factor + return real,imag + + +def refinement(u, p): + ux, uz = u & MASK, u >> N + px, pz = p & MASK, p >> N + return ((px & pz) ^ (ux & pz) ^ (uz & px)).bit_count() & 1 + + +def bell_target(program, u): + basis = [1 << i for i in range(2*N)] + guesses = [v for v in range(D*D) + if all(refinement(v,symplectic(program,e)) == refinement(u,e) + for e in basis)] + require(len(guesses) == 1, "Bell-label transport must be unique") + return guesses[0] + + +def check_bell(program, columns, den, u): + x,z = u & MASK, u >> N + output = {} + for j,col in enumerate(columns): + factor = sign(z & j) + for r,v in columns[j ^ x].items(): + for c,w in col.items(): + a,b = mul(v,w) + accumulate(output,(r,c),(a*factor,b*factor)) + output = {p:v for p,v in output.items() if v != (0,0)} + target = bell_target(program,u) + xnext,znext = target & MASK, target >> N + phase = output.get((xnext,0),(0,0)) + require(sum(v*v for v in phase) == den**4, "Bell amplitude") + expected = {(xnext ^ c,c): (phase[0]*sign(znext & c),phase[1]*sign(znext & c)) + for c in range(D)} + require(output == expected,"literal congruence and quadratic refinement disagree") + require(refinement(0,u) == refinement(0,target),"changed Arf orbit") + + +def main(): + h,s,cx = "H","S","CNOT" + programs = [ + (), ((s,0,0),), ((h,2,0),), ((cx,0,4),), + ((h,0,0),(s,0,0),(cx,0,1),(h,1,0),("Z",3,0)), + ((h,1,0),(cx,1,4),(s,2,0),(h,4,0),("X",0,0),(cx,2,0)), + ] + translated = bell_cases = detected = 0 + seen = set() + for program in programs: + cols, den = gate_matrix(program) + count = sum(symplectic(program,u) == u for u in range(D*D)) + d = count.bit_length()-1 + require(2**d == count,"fixed-space count") + seen.add(d) + nonzero = 0 + for x,z in product(range(D),repeat=2): + a,b = translate_trace(cols,x,z) + translated += 1 + if (a,b) == (0,0): + continue + nonzero += 1 + require(a*a+b*b == den**2 * count,"Pauli trace norm") + require(power((a,b),12) == (((-64)**d)*den**12,0),"width-13 trace phase") + require(power((a,b),16) == ((128**d)*count*den**16,0),"width-15 trace phase") + detected += int(d % 2 == 1) + require(nonzero * count == D*D,"trace support") + for u in [0, 1, 32, 33, 22, 61, 210, 411, 700, 1023]: + check_bell(program,cols,den,u) + bell_cases += 1 + require(detected and len(seen)>=3,"controls exercise changing trace sign and rank") + print(f"PASS literal five-qubit gates={len(programs)} Pauli-translates={translated} " + f"Bell-congruences={bell_cases} fixed-dimensions={sorted(seen)}") + + +if __name__ == "__main__": + main() diff --git a/research/clifford-five-qubit-threshold/check_moments.py b/research/clifford-five-qubit-threshold/check_moments.py new file mode 100644 index 0000000000..f38fdc239c --- /dev/null +++ b/research/clifford-five-qubit-threshold/check_moments.py @@ -0,0 +1,148 @@ +"""Independent fixed-space census and first two full Gram moments. + +Orbit counts use subspace embeddings in finite symplectic and quadratic spaces. +No character table is used to compute the expected counts or trace moments. +Prepared by apoursh with substantial OpenAI Codex assistance. Apache-2.0. +""" +from collections import Counter +from fractions import Fraction +from math import prod +import json +from pathlib import Path + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def injections(ambient, rank): + """Number of ordered independent rank-tuples in a binary vector space.""" + return prod(2**ambient - 2**i for i in range(rank)) + + +def sp_order(n): + return 2**(n*n) * prod(4**j - 1 for j in range(1, n+1)) + + +def refinements(n, sign): + if n == 0: + return int(sign == 1) + return 2**(n-1) * (2**n + sign) + + +def group_order(n, sign): + return sp_order(n) if sign == 0 else sp_order(n) // refinements(n, sign) + + +def orbit_count(n, r, sign): + """Orbits on ordered independent r-tuples, classified by pullback form.""" + total = 0 + for h in range(r//2 + 1): + t, m = r - 2*h, n - h + if t > m: + continue + # Choose the radical, then choose a nonsingular alternating form on + # the 2h-dimensional quotient. Only the radical dimension matters. + choose_radical = injections(r, t) // injections(t, t) + alternating = choose_radical * (injections(2*h, 2*h) // sp_order(h)) + if sign == 0: + total += alternating + continue + # For a nonzero restriction to the radical, any polar-isotropic + # t-plane containing a nonsingular vector realizes a nonzero linear + # restriction. For the zero restriction, the complement must have + # Witt index at least t. At t=m this forces the complement to be plus. + nonzero = (2**t - 1) * 4**h + zero = sum(refinements(h, delta) for delta in (-1, 1) + if t < m or delta == sign) + total += alternating * (zero + nonzero) + return total + + +def census(n, sign): + order = group_order(n, sign) + counts = [0] * (2*n + 1) + for r in reversed(range(2*n + 1)): + known = sum(counts[k] * injections(k, r) for k in range(r+1, 2*n+1)) + counts[r], rem = divmod(order*orbit_count(n, r, sign) - known, injections(r, r)) + require(rem == 0 and counts[r] >= 0, "nonintegral or negative fixed-space count") + require(sum(counts) == order and counts[-1] == 1, "identity or group order") + return counts + + +def small_calibration(n): + d = 2**n + labels = range(d*d) + def polar(x, y): + return (((x//d) & y).bit_count() + ((y//d) & x).bit_count()) % 2 + def form(x, sign): + q = ((x//d) & x).bit_count() % 2 + return q if sign == 1 else q ^ polar(1+d, x) + transvections = [tuple(x ^ (v if polar(x, v) else 0) for x in labels) + for v in range(1, d*d)] + identity = tuple(labels) + seen, pending = {identity}, [identity] + counts = {s: Counter() for s in (-1, 0, 1)} + while pending: + g = pending.pop() + fixed = sum(x == y for x, y in enumerate(g)) + require(fixed & (fixed-1) == 0, "fixed vectors form a binary subspace") + k = fixed.bit_length()-1 + for sign in counts: + if sign == 0 or all(form(x, sign) == form(y, sign) for x, y in enumerate(g)): + counts[sign][k] += 1 + for t in transvections: + product = tuple(t[y] for y in g) + if product not in seen: + seen.add(product) + pending.append(product) + for sign, histogram in counts.items(): + require([histogram[k] for k in range(2*n+1)] == census(n, sign), + "literal small group disagrees with the embedding census") + + +def gram_checks(data): + n, d = 5, 32 + full = sp_order(n) * d**2 + keys = {0: "S10(2)", 1: "O10+(2).2", -1: "O10-(2).2"} + counts = {s: census(n, s) for s in keys} + for s, key in keys.items(): + block = data[key] + require(block["order"] == sum(counts[s]), "group order from embedding census") + trivial, = [row for row in block["rows"] if row[0] == 1 and row[1:] == counts[s]] + require(trivial[0] == 1, "trivial character projection") + expected_nullity = {13: 6466626860503040, 14: 6954742423552, 15: 0} + for width in (13, 14, 15): + power = (width - 1) // 2 + twist = -1 if width in (13, 14) else 1 + mass = nullity = 0 + first = second = Fraction(0) + for sector in ((1, -1) if width == 14 else (0,)): + inertia = d if sector == 0 else refinements(n, sector) + for degree, *projection in data[keys[sector]]["rows"]: + character_sum = sum(c*(twist*2**power)**k for k,c in enumerate(projection)) + mult, rem = divmod(character_sum, group_order(n, sector)) + require(rem == 0 and mult >= 0, "bad multiplicity in tensor representation") + irrep = inertia * degree + weight = irrep**2 + eigenvalue = Fraction(full*mult, d**width * irrep) + mass += weight + first += weight*eigenvalue + second += weight*eigenvalue**2 + if mult == 0: + nullity += weight + # Direct Frobenius norm from trace magnitudes of individual Pauli + # lifts: 2^(2n-k) lifts with squared trace 2^k above each S. + direct = Fraction(full, d**(2*width)) * sum( + size * 2**(2*n-k) * 2**(k*width) for k, size in enumerate(counts[0])) + require(mass == first == full and second == direct, "Gram moment mismatch") + require(nullity == expected_nullity[width], "rank classification mismatch") + print(f"PASS width {width}: rank {full-nullity}, nullity {nullity}, trace and squared trace") + + +if __name__ == "__main__": + for qubits in (1, 2): + small_calibration(qubits) + print("PASS literal small symplectic and both orthogonal censuses") + gram_checks(json.loads((Path(__file__).parent / "PROJECTION.json").read_text())) diff --git a/research/clifford-five-qubit-threshold/extract.py b/research/clifford-five-qubit-threshold/extract.py new file mode 100644 index 0000000000..dfc9db7f27 --- /dev/null +++ b/research/clifford-five-qubit-threshold/extract.py @@ -0,0 +1,193 @@ +"""Regenerate the fixed-space projections from the official CTblLib 1.3.11 archive. + +The three tables use integer entries, sums of roots of unity, Galois row +references, and tensor products by a rational sign row. No GAP expressions +are executed. The default mode compares the rebuilt numerical data. +apoursh with substantial OpenAI Codex assistance. Apache-2.0. +""" +import argparse +from fractions import Fraction +from functools import cache +from hashlib import sha256 +import json +from math import gcd +from pathlib import Path +import re +import tarfile + +ROOT = Path(__file__).resolve().parent +ARCHIVE = "f201e9da571c681a7bbfb1e4683bdb2c80a23b005099ed0453521f59cb443434" +MEMBERS = { + "ctosymp1.tbl": "461519e33cb31b2bc46f554b09f283f0afb7125fd805840d79bfc614fce75b6f", + "ctoorth3.tbl": "736b8f34211dd8a20c51312015fa72c1bb0a4931db19b317ea436ac0e9644626", +} +GROUP = "S10(2)" +SUBGROUPS = ("O10+(2).2", "O10-(2).2") + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def integer(value): + value = Fraction(value) + require(value.denominator == 1, "Nonintegral projected character sum") + return value.numerator + + +def take_list(text): + start = text.index("[") + depth = 0 + for pos in range(start, len(text)): + if text[pos] == "[": + depth += 1 + elif text[pos] == "]": + depth -= 1 + if depth == 0: + return text[start:pos+1], text[pos+1:] + raise ValueError("Unterminated table list") + + +@cache +def root_trace(n, k): + """Normalized field trace of a root of unity of exact order m.""" + m = n // gcd(n, k) + reduced, mu = m, 1 + for p in range(2, m+1): + if reduced % p == 0: + reduced //= p + if reduced % p == 0: + return Fraction(0) + mu = -mu + return Fraction(mu, sum(gcd(j, m) == 1 for j in range(m))) + + +@cache +def rational_trace(word): + if "E(" not in word: + return int(word) + terms = re.findall(r"([+-]?)(?:(\d+)\*)?E\((\d+)\)(?:\^(\d+))?|([+-]?\d+)", word) + rebuilt = "".join(const or sign + (coeff+"*" if coeff else "") + "E(" + n + ")" + ("^" + k if k else "") + for sign, coeff, n, k, const in terms) + require(rebuilt == word, "Unrecognized cyclotomic table entry: "+word) + return sum(int(const) if const else + (-1 if sign == "-" else 1) * int(coeff or 1) * root_trace(int(n), int(k or 1)) + for sign, coeff, n, k, const in terms) + + +def character_data(source, name): + rest = source.split(f'MOT("{name}",', 1)[1] + _, rest = take_list(rest) + centralizers, rest = take_list(rest) + centralizers = json.loads(centralizers) + _, rest = take_list(rest) + raw, _ = take_list(rest) + raw = "".join(raw[1:-1].split()) + rows = [] + while raw: + record, raw = take_list(raw) + raw = raw.removeprefix(",") + reference = re.fullmatch(r"\[(GALOIS|TENSOR),\[(\d+),(\d+)\]\]", record) + if reference: + operation, index, exponent = reference.groups() + row = rows[int(index)-1] + if operation == "TENSOR": + sign = rows[int(exponent)-1] + require(all(v in (-1, 1) for v in sign), "Non-sign tensor factor") + row = [a*b for a,b in zip(row, sign, strict=True)] + rows.append(row) + else: + row = [rational_trace(word) for word in record[1:-1].split(",")] + require(len(row) == len(centralizers), "Wrong class count") + rows.append(row) + require(len(rows) == len(centralizers), "Table is not square") + return centralizers, rows + + +def fixed_dimensions(rows): + summands = [row for row in rows if row[0] in (495, 527)] + require(len(summands) == 2 and sum(row[0] for row in summands) == 1022, + "Natural rank-three character constituents") + counts = [integer(2 + a + b) for a,b in zip(*summands, strict=True)] + require(all(x > 0 and x & (x-1) == 0 for x in counts), "Not a binary space size") + return [x.bit_length()-1 for x in counts] + + +def projection(order, centralizers, rows, fixed): + sizes = [order // c for c in centralizers] + require(sum(sizes) == order and all(order % c == 0 for c in centralizers), + "Class sizes do not partition the group") + projected = [] + for row in rows: + sums = [0] * 11 + for d, size, val in zip(fixed, sizes, row, strict=True): + sums[d] += size*val + projected.append([integer(row[0]), *map(integer, sums)]) + return {"order": order, "rows": projected} + + +def check_seven_pair_seed(centralizers, rows, fixed): + # A nonzero alternating 4-by-4 shear has rank two (35 choices) or + # four (28 choices). Class size and natural fixed dimension identify + # the two columns uniquely in the full ordinary table. + columns = [] + for size, dim in ((86955, 8), (21912660, 6)): + hits = [i for i, (c, k) in enumerate(zip(centralizers, fixed, strict=True)) + if k == dim and centralizers[0] // c == size] + require(len(hits) == 1, "Ambiguous alternating shear class") + columns.append(hits[0]) + a, b = columns + ranks = [integer(Fraction(row[0]+35*row[a]+28*row[b], 64)) for row in rows] + require(len(ranks) == 198 and min(ranks) == ranks.count(1) == 1, + "Seven-pair subgroup fixed spaces") + print("PASS seven-pair seed: positive fixed space in all 198 ordinary irreducibles") + + +def extract(path): + require(sha256(path.read_bytes()).hexdigest() == ARCHIVE, "Wrong CTblLib release") + source = {} + with tarfile.open(path, "r:gz") as t: + for name, digest in MEMBERS.items(): + with t.extractfile("ctbllib-1.3.11/data/"+name) as f: + data = f.read() + require(sha256(data).hexdigest() == digest, "Original table file hash") + source[name] = data.decode("latin-1") + c, rows = character_data(source["ctosymp1.tbl"], GROUP) + fixed = fixed_dimensions(rows) + check_seven_pair_seed(c, rows, fixed) + result = {GROUP: projection(c[0], c, rows, fixed)} + text = source["ctoorth3.tbl"] + for name in SUBGROUPS: + c, rows = character_data(text, name) + tail = text.split(f'ALF("{name}","{GROUP}",', 1)[1] + fusion = json.loads(take_list(tail)[0]) + require(len(fusion) == len(c) and all(1 <= f <= len(fixed) for f in fusion), + "Malformed class fusion") + result[name] = projection(c[0], c, rows, [fixed[f-1] for f in fusion]) + return result + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("archive", type=Path) + parser.add_argument("--output", type=Path, help="Write the projection to this new file") + args = parser.parse_args() + result = extract(args.archive) + if args.output: + with args.output.open("x", encoding="utf-8") as output: + output.write("{\n") + for i, (name, group) in enumerate(result.items()): + lines = ",\n".join(" "+json.dumps(row, separators=(",", ":")) + for row in group["rows"]) + output.write(f' {json.dumps(name)}: {{"order": {group["order"]}, "rows": [\n') + output.write(lines+"\n ]}"+("," if i+1 != len(result) else "")+"\n") + output.write("}\n") + else: + saved = json.loads((ROOT/"PROJECTION.json").read_text(encoding="utf-8")) + require(result == saved, "Projected data differ") + print("PASS_CTBLLIB_PROJECTION groups=3 rows=517 dimensions=11") + + +if __name__ == "__main__": + main() diff --git a/research/clifford-five-qubit-threshold/verify.py b/research/clifford-five-qubit-threshold/verify.py new file mode 100644 index 0000000000..e1abe60476 --- /dev/null +++ b/research/clifford-five-qubit-threshold/verify.py @@ -0,0 +1,86 @@ +"""Check all spectral blocks for five qubits at widths 13, 14 and 15. +apoursh with substantial OpenAI Codex assistance. Apache-2.0. +""" +from fractions import Fraction +from hashlib import sha256 +import json +from pathlib import Path + +ROOT = Path(__file__).resolve().parent +SOURCE = "d7a8465e81f7e20cb87f6bc7b0d7fb7a059e88691fd06df2ec502ee65be62f54" +ORDER = 24815256521932800 +NUM_COLUMNS = 1024 * ORDER + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def block_spectrum(group, t, width, orbit): + order = group["order"] + degrees = [] + records = [] + for i, (degree, *sums) in enumerate(group["rows"], start=1): + require(len(sums) == 11 and sums[-1] == degree, "identity fixed space") + require(sum(sums) == (order if i == 1 else 0), "row orthogonality to trivial") + inner = sum(c * t**d for d, c in enumerate(sums)) + multiplicity, remainder = divmod(inner, order) + require(remainder == 0 and multiplicity >= 0, "integral nonnegative multiplicity") + dim = degree * orbit + eigen = Fraction(NUM_COLUMNS * multiplicity, 32**width * dim) + degrees.append(degree) + records.append((i, degree, dim, multiplicity, eigen)) + require(sum(d*d for d in degrees) == order, "degree census") + return records + + +def census(records, width): + require(sum(d*d for _,_,d,_,_ in records) == NUM_COLUMNS, "all projective blocks") + require(sum(d*m for _,_,d,m,_ in records) == 32**width, "full natural tensor dimension") + require(sum(d*d*v for _,_,d,_,v in records) == NUM_COLUMNS, "normalized Gram trace") + missing = [(i, degree) for i,degree,_,m,_ in records if m == 0] + nullity = sum(d*d for _,_,d,m,_ in records if m == 0) + return missing, nullity + + +def main(): + data = (ROOT / "PROJECTION.json").read_bytes() + require(sha256(data).hexdigest() == SOURCE, "projection bytes") + tables = json.loads(data) + g = tables["S10(2)"] + require(g["order"] == ORDER and len(g["rows"]) == 198, "Sp10") + r13 = block_spectrum(g, -64, 13, 32) + missing, nullity = census(r13, 13) + require(missing == [(10,11935), (26,81158), (31,202895), (38,365211), + (41,405790), (73,1623160), (77,1826055)] and + nullity == 6466626860503040, "width 13 missing blocks") + results = [] + for name, orbit, count, index, degree in (("O10+(2).2",528,155,9,868), + ("O10-(2).2",496,164,16,5236)): + table = tables[name] + require(table["order"] * orbit == ORDER and len(table["rows"]) == count, + "Bell orbit and stabilizer order") + group_rows = block_spectrum(table, -64, 14, orbit) + require([(j,d) for j,d,_,m,_ in group_rows if m == 0] == [(index,degree)], + "Bell missing row") + # Dropping the phase in the trace would give positive multiplicity + # for this missing block, invalidating the rank result. + y = table["rows"][index-1][1:] + require(sum(c * 64**d for d,c in enumerate(y)) > 0, "phase control") + results.extend(group_rows) + _, null14 = census(results, 14) + require(null14 == 6954742423552, "width 14 exact nullity") + r15 = block_spectrum(g, 128, 15, 32) + require(census(r15, 15) == ([],0), "width 15 full rank") + vals = [v for _,_,_,_,v in r15] + lower = Fraction(394477183485, 2**43) + upper = Fraction(7279231852517625, 2**45) + require(min(vals) == lower and max(vals) == upper, "threshold endpoints") + print(f"PASS f13 missing=7 nullity={nullity}") + print(f"PASS f14 missing=2 nullity={null14} rank={NUM_COLUMNS-null14}") + print(f"PASS f15 rank={NUM_COLUMNS} endpoints=[{lower},{upper}] T(5)=15") + + +if __name__ == "__main__": + main()