#!/usr/bin/env python3 """Exact checks and Lean fixture generation for three scoped OMEGA bridges. Python 3.10+, standard library only. Reconstructs the pinned 600-cell, proves finite identities by exhaustive exact checking, and emits its literal vertices for the companion Lean proof. Universal algebraic statements are in that proof. """ from __future__ import annotations import argparse import hashlib import itertools import json from pathlib import Path PIN = '40bc6a1d52efab3d75cf343e65ac06b314f9c9c375fc02bf6d45bf6bb21f9529' ZERO = (0, 0) ONE = (1, 0) PHI = (0, 1) def require(p, message): if not p: raise ArithmeticError(message) def add(p, q): return p[0] + q[0], p[1] + q[1] def mul(p, q): a, b = p c, d = q return a*c + b*d, a*d + b*c + b*d def scale(k, p): return k*p[0], k*p[1] def power(p, n): out = ONE for _ in range(n): out = mul(out, p) return out def total(xs): out = ZERO for x in xs: out = add(out, x) return out def norm(p): a, b = p return a*a + a*b - b*b def step(p): a, b = p return 13*a + 6*b, 6*a + 19*b def graph(): vs = set() for i in range(4): for s in (-1, 1): v = [ZERO]*4 v[i] = (2*s, 0) vs.add(tuple(v)) for ss in itertools.product((-1, 1), repeat=4): vs.add(tuple((s, 0) for s in ss)) even = [p for p in itertools.permutations(range(4)) if sum(p[i] > p[j] for i in range(4) for j in range(i+1, 4)) % 2 == 0] for a, b, c in itertools.product((-1, 1), repeat=3): v = (ZERO, (a, 0), (0, b), (-c, c)) vs.update(tuple(v[i] for i in p) for p in even) vs = sorted(vs) nb = [[] for _ in vs] for i, j in itertools.combinations(range(len(vs)), 2): diff = [(a-c, b-d) for (a, b), (c, d) in zip(vs[i], vs[j])] if total(mul(p, p) for p in diff) == (8, -4): nb[i].append(j) nb[j].append(i) fixture = { 'coordinate_rule': 'vertex coordinate is (a+b*phi)/2 for pair [a,b]', 'neighbors': nb, 'schema': 'OMEGA_600CELL_GRAPH_FIXTURE/1', 'vertex_order': 'Python lexicographic order of tuples of four integer pairs', 'vertices': vs, } raw = (json.dumps(fixture, sort_keys=True, separators=(',', ':'))+'\n').encode() require(hashlib.sha256(raw).hexdigest() == PIN, 'pinned graph identity') require(len(vs) == 120 and all(len(row) == 12 for row in nb), '120 vertices of degree 12') return vs, nb, raw def standard_icosahedron(): out = [] for a, b in itertools.product((-1, 1), repeat=2): out += [(ZERO, scale(a, ONE), scale(b, PHI)), (scale(a, ONE), scale(b, PHI), ZERO), (scale(b, PHI), ZERO, scale(a, ONE))] return sorted(out) def expected_sum(e): if any(t % 2 for t in e): return ZERO d = sum(e) if d == 0: return 12, 0 if d == 2: return 8, 4 if d == 4: return (12, 12) if 4 in e else (4, 4) raise ValueError('outside degree five') def monomial(v, e): return mul(mul(power(v[0], e[0]), power(v[1], e[1])), power(v[2], e[2])) def emit_fixture(vs, path): lines = [ '/- Generated by verify_bridges.py from the pinned graph construction. -/', 'def vertices600 : List (List GP) := [', ] lines += [' [' + ', '.join(f'({a}, {b})' for a, b in v) + ']' + (',' if i+1 < len(vs) else '') for i, v in enumerate(vs)] lines += [']', ''] path.write_text('\n'.join(lines)) def main(): ap = argparse.ArgumentParser() ap.add_argument('--emit', action='store_true', help='Emit exact fixture for Lean') args = ap.parse_args() root = Path(__file__).resolve().parent vs, nb, raw = graph() require(vs[0] == ((-2, 0), ZERO, ZERO, ZERO), 'axis vertex') require(nb[0] == list(range(33, 45)), 'pinned neighbor order') require(all(vs[j][0] == (0, -1) for j in nb[0]), 'affine neighbor slice') # Each physical coordinate is numerator/2. Thus multiplying the last # three coordinates by 2*phi gives these integer golden pairs. direct = [tuple(mul(PHI, p) for p in vs[j][1:]) for j in nb[0]] # The fixed swap aligns the two equally valid coordinate conventions. aligned = [(p[0], p[2], p[1]) for p in direct] require(sorted(aligned) == standard_icosahedron(), 'explicit local-to-sampling map') require(all(total(mul(p, p) for p in v) == (2, 1) for v in aligned), 'icosahedral radius squared') moment_rows = [] for e in itertools.product(range(6), repeat=3): if sum(e) > 5: continue value = total(monomial(v, e) for v in aligned) require(value == expected_sum(e), f'moment {e}') moment_rows.append({'exponents': e, 'sum': value}) require(len(moment_rows) == 56, 'all degree-five monomials') gram = [[total(mul(v[i], v[j]) for v in aligned) for j in range(3)] for i in range(3)] require(gram == [[(8, 4) if i == j else ZERO for j in range(3)] for i in range(3)], '3D tight-frame Gram') require(norm((13, 6)) == 211, 'golden update norm') require(mul((13, 6), (19, -6)) == (211, 0), 'conjugate product') algebra_checks = 0 for a, b in itertools.product(range(-9, 10), repeat=2): p = (a, b) require(step(p) == mul((13, 6), p), 'multiplication intertwiner') require(norm(step(p)) == 211*norm(p), 'norm scaling') pp = step(step(p)) require(pp == add(scale(32, step(p)), scale(-211, p)), 'spectral recurrence') algebra_checks += 1 # Directly connect the golden block to all 120 physical-coordinate rows. for coord in range(4): for i in range(120): a, b = vs[i][coord] ma = 13*a + sum(vs[j][coord][0] for j in nb[i]) mb = 13*b + sum(vs[j][coord][1] for j in nb[i]) require((ma, mb) == (13*a + 6*b, 6*a + 19*b), '600-cell coefficient block') if args.emit: emit_fixture(vs, root/'Vertices600.inc') (root/'graph_fixture.json').write_bytes(raw) report = { 'schema': 'OMEGA_DIMENSION_GOLDEN_BRIDGES/1', 'status': 'PASS', 'graph_sha256': PIN, 'vertices': len(vs), 'local_neighbors': nb[0], 'local_to_sampling': 'swap last two of 2*phi*(p1,p2,p3)', 'aligned_icosahedral_nodes': len(aligned), 'degree_five_monomials': len(moment_rows), 'moments': moment_rows, 'gram_3d': gram, 'universal_algebra_examples': algebra_checks, 'golden_block_entries_checked': 480, 'norm_multiplier': 211, 'spectral_polynomial': [211, -32, 1], 'lean_status': 'Reported separately by the actual Lean compiler run', } print(json.dumps(report, sort_keys=True, indent=2)) if __name__ == '__main__': main()