#!/usr/bin/env python3 """ Completely Independent, Minimal-TCB, Pure-Python Verifier for the Global Proof of Minc Conjecture 5 / Ryser's Conjecture on (13, 9, 6): For EVERY B in Lambda_13^9, per(B) >= 64,803,969, with equality IF AND ONLY IF B is isomorphic to J_13 - PG(2, 3). Trusted Computing Base (TCB): - Python 3 standard library ONLY (math, decimal, fractions, gzip, os, sys, multiprocessing). - ZERO LP solver, ZERO external libraries, ZERO heuristic search code. - Exact rational Fraction arithmetic for polynomial identities, Laguerre orthogonality, Rayleigh-coupled p_6 bounds, and exact Intermediate Value Theorem root bracketing. - Outward-rounded 55-digit Decimal interval arithmetic (ROUND_FLOOR / ROUND_CEILING) for Gauss-Laguerre quadrature weights, rounded outward to IEEE-754 float intervals. - Correctly rounded Decimal logarithm/exponential enclosures from round3_strict_bounds.py, with exact outward conversion to binary64 intervals. - Exact IEEE-754 outward-rounded interval arithmetic via math.nextafter(). - Exact IEEE-754 hexadecimal float interchange (float.fromhex) -> zero parsing loss. Two verification stages: Stage A: Exact symbolic/rational combinatorial & spectral identities (P_0..P_5, Laguerre orthogonality, exact Fraction Rayleigh/Cauchy/triangle p_6 bounds for C_4=8..13, 61 real matrices m_0..m_6 / 6 C_6 / p_1..p_6, and the (13, 4, 1) zero-root Stieltjes Hankel barrier). Stage B: Complete continuous proof-tree & outward-rounded interval certificate verification for ALL 110 integer values C_4 in {8, 9, ..., 117}. This verifies the high-four-cycle part of Theorem 6. """ import argparse import decimal import gzip import lzma import math import multiprocessing as mp import os import re import sys import time from decimal import Decimal from fractions import Fraction try: from .round3_strict_bounds import ( derivative_coefficient_bounds, exp_bounds, log_bounds, ) except ImportError: from round3_strict_bounds import ( derivative_coefficient_bounds, exp_bounds, log_bounds, ) TARGET = 64803969.0 INF = float("inf") NINF = float("-inf") POLY_SPECS = [ (0.0, 0.0, 0.0, 0.0, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0)), (2.0, 0.0, 2.0, 2.0, (0.0, 0.0, 16.0, -32.0, 24.0, -8.0, 1.0)), (2.5, 0.0, 2.5, 2.5, (0.0, 0.0, 39.0625, -62.5, 37.5, -10.0, 1.0)), (4.0, 0.0, 2.0, 4.0, (0.0, 0.0, 64.0, -96.0, 52.0, -12.0, 1.0)), (5.0, 1.0, 3.0, 5.0, (225.0, -690.0, 799.0, -444.0, 127.0, -18.0, 1.0)), (8.0, 1.0, 4.0, 8.0, (1024.0, -2816.0, 2768.0, -1208.0, 257.0, -26.0, 1.0)), ] nextafter = math.nextafter fabs = math.fabs isfinite = math.isfinite class CertificateError(ValueError): """A malformed or mathematically invalid certificate record.""" def require(condition, message="certificate verification failed"): """Runtime check that remains active under ``python -O``.""" if not condition: raise CertificateError(str(message)) def parse_hex_float(token: str) -> float: match = _HEX_FLOAT_TOKEN.fullmatch(token) require(match is not None and len(token) <= 64, f"invalid hexadecimal float token {token!r}") whole = match.group("whole") or "0" fraction = match.group("fraction") or "" exponent = int(match.group("exp"), 10) require(bool(whole + fraction) and len(whole) <= 1 and len(fraction) <= 13, f"hexadecimal float is outside the binary64 interchange grammar: {token!r}") require(-4096 <= exponent <= 4096, f"hexadecimal exponent out of range in {token!r}") significand = int(whole + fraction, 16) exact = Fraction(significand, 16 ** len(fraction)) if exponent >= 0: exact *= 1 << exponent else: exact /= 1 << -exponent if match.group("sign") == "-": exact = -exact try: value = float.fromhex(token) except (TypeError, ValueError, OverflowError) as exc: raise CertificateError(f"invalid hexadecimal float {token!r}") from exc require(isfinite(value), f"non-finite hexadecimal float {token!r}") require(abs(value) <= 2**100, f"out-of-range numerical certificate field {token!r}") require(Fraction.from_float(value) == exact, f"hexadecimal float is not represented exactly by binary64: {token!r}") return value _INT_TOKEN = re.compile(r"(?:0|[1-9][0-9]*|-[1-9][0-9]*)\Z") _HEX_FLOAT_TOKEN = re.compile( r"(?P[+-]?)0[xX](?P[0-9a-fA-F]?)(?:\.(?P[0-9a-fA-F]*))?[pP](?P[+-]?[0-9]+)\Z" ) def parse_int(token: str) -> int: require(_INT_TOKEN.fullmatch(token) is not None, f"invalid canonical integer {token!r}") return int(token, 10) def expect_arity(tokens, length: int, context: str): require(len(tokens) == length, f"{context}: expected {length} tokens, found {len(tokens)}") TREE_ARITY = { "DESCEND_R0": 3, "SPLIT_ROOT": 3, "LEAF_POLY": 2, "LEAF_TRIV": 4, "LEAF_FARKAS": 11, "LEAF_INTGAP": 19, "LEAF_GL8": 6, "LEAF_INTSPLIT": 6, } TREE_TAGS = frozenset(TREE_ARITY) | {"HOLE_OR_HIT"} RECORD_ARITY = TREE_ARITY | { "GAP_PAR": 17, "SKIP_TOP": 1, "POS": 9, "NEG": 9, "M_FARKAS": 10, "M_GL8": 2, } def check_record(tokens): tag = tokens[0] if tag == "HOLE_OR_HIT": require(len(tokens) >= 7, "Short hole branch record") shell_count = parse_int(tokens[6]) require(shell_count >= 1, "Nonpositive shell count") expect_arity(tokens, 7 + 2 * shell_count, tag) elif tag == "SKIP_GAP": require(len(tokens) in (1, 2), "Wrong SKIP_GAP arity") else: require(tag in RECORD_ARITY, f"Unknown record tag {tag}") expect_arity(tokens, RECORD_ARITY[tag], tag) def next_record(iterator, context: str): try: line = next(iterator) except StopIteration as exc: raise CertificateError(f"unexpected end of certificate while reading {context}") from exc tokens = line.split() require(bool(tokens), f"empty record while reading {context}") check_record(tokens) return tokens def shell_intersections(segments, shell, source_hole): """Return closed shell/support intersections, including allowed singleton touches.""" ua, ub = shell ha, hb = source_hole intersections = [] for sa, sb in segments: ia, ib = max(sa, ua), min(sb, ub) if ib > ia or (ia == ib and ia > 0.0 and ha < ia < hb and ua <= ia <= ub): intersections.append((ia, ib)) return intersections # 50-digit outward-rounded Decimal contexts for exact Gauss-Laguerre weight enclosures CTX_DN = decimal.Context(prec=55, rounding=decimal.ROUND_FLOOR) CTX_UP = decimal.Context(prec=55, rounding=decimal.ROUND_CEILING) # ========================================================================= # Exact outward-rounded IEEE-754 interval arithmetic (pure Python stdlib) # ========================================================================= def dn(x: float) -> float: return nextafter(x, NINF) def up(x: float) -> float: return nextafter(x, INF) def iv_pow_nn(a0: float, a1: float, k: int): if k == 0: return (1.0, 1.0) require((a0 >= 0.0), 'a0 >= 0.0') lo, hi = 1.0, 1.0 for _ in range(k): lo = max(0.0, nextafter(lo * a0, NINF)) hi = nextafter(hi * a1, INF) return (lo, hi) def iv_div(a0: float, a1: float, b0: float, b1: float): if b0 <= 0.0 <= b1: raise ZeroDivisionError("Interval division by interval containing 0") r1, r2, r3, r4 = a0 / b0, a0 / b1, a1 / b0, a1 / b1 return (nextafter(min(r1, r2, r3, r4), NINF), nextafter(max(r1, r2, r3, r4), INF)) def iv_mul(a0: float, a1: float, b0: float, b1: float): p1, p2, p3, p4 = a0 * b0, a0 * b1, a1 * b0, a1 * b1 return (nextafter(min(p1, p2, p3, p4), NINF), nextafter(max(p1, p2, p3, p4), INF)) def get_p_exact(c4: int): p0, p1, p2, p3 = 13.0, 52.0, 364.0, 3016.0 p4 = float(27196 - 4 * c4) p5 = float(258232 - 120 * c4) base = 2538172 - 2340 * c4 if c4 == 8: p6 = float(base + 102) elif c4 == 9: p6 = float(base + 156) elif c4 == 10: p6 = float(base + 264) elif c4 == 11: p6 = float(base + 270) elif c4 == 12: p6 = float(base + 324) elif c4 == 13: p6 = float(base + 330) else: num = 108 * c4 - 4 * c4 * c4 q = num // 54 p6 = float(base + 6 * q + 48 * ((2 * c4) // 3)) return (p0, p1, p2, p3, p4, p5, p6) # ========================================================================= # Rigorous Exact-Fraction + 55-digit Outward-Rounded Gauss-Laguerre Rules # ========================================================================= def laguerre_frac(n: int): return [Fraction((-1) ** k * math.comb(n, k), math.factorial(k)) for k in range(n + 1)] L6_F = laguerre_frac(6) + [Fraction(0), Fraction(0)] L7_F = laguerre_frac(7) + [Fraction(0)] L8_F = laguerre_frac(8) FACT_D = [Decimal(math.factorial(k)) for k in range(9)] def frac_to_dec_iv(fr: Fraction): num = Decimal(fr.numerator) den = Decimal(fr.denominator) return (CTX_DN.divide(num, den), CTX_UP.divide(num, den)) def dec_iv_add(a, b): return (CTX_DN.add(a[0], b[0]), CTX_UP.add(a[1], b[1])) def dec_iv_mul(a, b): ps = ( CTX_DN.multiply(a[0], b[0]), CTX_DN.multiply(a[0], b[1]), CTX_DN.multiply(a[1], b[0]), CTX_DN.multiply(a[1], b[1]), ) qs = ( CTX_UP.multiply(a[0], b[0]), CTX_UP.multiply(a[0], b[1]), CTX_UP.multiply(a[1], b[0]), CTX_UP.multiply(a[1], b[1]), ) return (min(ps), max(qs)) def dec_iv_div(a, b): require((b[0] > 0 or b[1] < 0), 'b[0] > 0 or b[1] < 0') ds = ( CTX_DN.divide(a[0], b[0]), CTX_DN.divide(a[0], b[1]), CTX_DN.divide(a[1], b[0]), CTX_DN.divide(a[1], b[1]), ) us = ( CTX_UP.divide(a[0], b[0]), CTX_UP.divide(a[0], b[1]), CTX_UP.divide(a[1], b[0]), CTX_UP.divide(a[1], b[1]), ) return (min(ds), max(us)) def dec_to_float_lo(d: Decimal) -> float: f = float(d) if Decimal(f) > d: f = dn(f) require(d.is_finite() and isfinite(f) and Decimal(f) <= d, "Invalid lower endpoint conversion") return f def dec_to_float_hi(d: Decimal) -> float: f = float(d) if Decimal(f) < d: f = up(f) require(d.is_finite() and isfinite(f) and Decimal(f) >= d, "Invalid upper endpoint conversion") return f def eval_frac_poly(Q, x: Fraction) -> Fraction: v = Fraction(0) for c in reversed(Q): v = v * x + c return v def compute_rigorous_rule8(c1: float, c2: float): """ Given exact IEEE-754 doubles (c1, c2), rigorously prove Q(x) = L_8(x) + c1 L_7(x) + c2 L_6(x) has 8 distinct real roots xi_0 > ... > xi_7 >= 0 and compute outward-rounded IEEE-754 enclosures x_iv[i], w_iv[i] guaranteed to contain the EXACT roots and EXACT positive weights! """ require((isfinite(c1) and isfinite(c2)), 'isfinite(c1) and isfinite(c2)') f1, f2 = Fraction(c1), Fraction(c2) Q = [L8_F[k] + f1 * L7_F[k] + f2 * L6_F[k] for k in range(9)] require((Q[8] == Fraction(1, math.factorial(8))), 'Q[8] == Fraction(1, math.factorial(8))') # Approximate root locations in float for fast bracketing Qf = [float(c) for c in Q] def ev_f(x): v = 0.0 for c in reversed(Qf): v = v * x + c return v def dev_f(x): v = 0.0 for k in range(8, 0, -1): v = v * x + k * Qf[k] return v approx = [] x = 0.0 dx = 0.01 prev = ev_f(0.0) if abs(prev) < 1e-13: approx.append(0.0) x = 1e-5 prev = ev_f(x) while len(approx) < 8 and x < 120.0: x2 = x + dx cur = ev_f(x2) if prev * cur <= 0.0: r = 0.5 * (x + x2) for _ in range(25): df = dev_f(r) if df == 0.0: break r -= ev_f(r) / df if not approx or r > approx[-1] + 1e-5: approx.append(r) x, prev = x2, cur require((len(approx) == 8), f"Expected 8 roots for ({c1}, {c2}), found {len(approx)}") approx.reverse() # Exact-Fraction IVT bracketing + refinement to width <= 2^{-62} (~2e-19)! Q_dec = [frac_to_dec_iv(c) for c in Q] dQ_dec = [frac_to_dec_iv(k * Q[k]) for k in range(1, 9)] x_ivs = [] w_ivs = [] prev_lo = None for r_app in approx: # Start with a small dyadic rational bracket around r_app rad = Fraction(1, 1 << 40) center = Fraction(r_app) lo = max(Fraction(0), center - rad) hi = center + rad flo = eval_frac_poly(Q, lo) fhi = eval_frac_poly(Q, hi) # Expand if needed while flo * fhi > 0: rad *= 4 require((rad < Fraction(1, 100)), f"Root bracket failed near {r_app}") lo = max(Fraction(0), center - rad) hi = center + rad flo = eval_frac_poly(Q, lo) fhi = eval_frac_poly(Q, hi) # Refine by exact Fraction secant/bisection until hi - lo <= 2^-62 if flo == 0: hi = lo elif fhi == 0: lo = hi else: for _ in range(100): if hi - lo <= Fraction(1, 1 << 62): break mid = (lo + hi) / 2 fmid = eval_frac_poly(Q, mid) if fmid == 0: lo = hi = mid break if (flo < 0) == (fmid < 0): lo, flo = mid, fmid else: hi, fhi = mid, fmid require((lo == hi or (flo < 0 < fhi) or (fhi < 0 < flo)), '(flo == 0 and fhi == 0) or (flo < 0 < fhi) or (fhi < 0 < flo)') require(0 <= lo <= hi and hi-lo <= Fraction(1, 1 << 62), "invalid root bracket") # Verify strict disjointness of all 8 exact roots! if prev_lo is not None: require((hi < prev_lo), "Overlapping root brackets!") prev_lo = lo # Convert exact rational bracket [lo, hi] to 55-digit Decimal interval xi_d = (frac_to_dec_iv(lo)[0], frac_to_dec_iv(hi)[1]) # Rigorous 55-digit outward-rounded synthetic division for b_k of Q(x)/(x - xi): # b_7 = Q_8, b_k = Q_{k+1} + xi * b_{k+1} b_iv = [None] * 8 b_iv[7] = Q_dec[8] for k in range(6, -1, -1): b_iv[k] = dec_iv_add(Q_dec[k + 1], dec_iv_mul(xi_d, b_iv[k + 1])) # Numerator = sum_{k=0}^7 k! * b_k num_iv = (Decimal(0), Decimal(0)) for k in range(8): num_iv = dec_iv_add(num_iv, dec_iv_mul(b_iv[k], (FACT_D[k], FACT_D[k]))) # Denominator = Q'(xi) via outward-rounded Horner den_iv = dQ_dec[7] for k in range(6, -1, -1): den_iv = dec_iv_add(dec_iv_mul(den_iv, xi_d), dQ_dec[k]) require((den_iv[0] > 0 or den_iv[1] < 0), "Zero derivative in root bracket!") w_d = dec_iv_div(num_iv, den_iv) require((w_d[0] > 0), f"Non-positive weight enclosure {w_d} for ({c1}, {c2})") x_ivs.append((dec_to_float_lo(xi_d[0]), dec_to_float_hi(xi_d[1]))) w_ivs.append((dec_to_float_lo(w_d[0]), dec_to_float_hi(w_d[1]))) require((w_ivs[-1][0] > 0.0), 'w_ivs[-1][0] > 0.0') return (tuple(x_ivs), tuple(w_ivs)) # Per-worker rule cache _RULE_CACHE = {} def get_rigorous_rule8(c1: float, c2: float): key = (c1, c2) r = _RULE_CACHE.get(key) if r is None: r = compute_rigorous_rule8(c1, c2) if len(_RULE_CACHE) >= 1024: _RULE_CACHE.clear() _RULE_CACHE[key] = r return r # ========================================================================= # Support & Lrem Verification # ========================================================================= def all_holes_of(roots, anchors, holes, _L: float = 0.0): require(len(roots) == len(anchors), "root/anchor state mismatch") result = list(holes) for (a, b), selection in zip(roots, anchors): if selection is None: continue xi, ha, hb = selection # The two directed operations match the generator's conservative # inner endpoints. The open intersection preserves ties and endpoints. if b < xi: lo, hi = max(b, ha), min(dn(dn(2.0 * xi) - b), hb) elif a > xi: lo, hi = max(ha, up(up(2.0 * xi) - a)), min(a, hb) else: continue if lo < hi: result.append((lo, hi)) return result def get_support(L: float, holes): """ Exact set difference (0, L] \\ union(open holes (ha, hb)). Note: 0 is never a root of r(A, x) since r(A, 0) = -per(A) <= -1 < 0 (Hall/Schrijver). Any isolated point p in (0, L] created by touching open holes is explicitly preserved as a closed singleton (p, p) so NO point of (0, L] outside the open holes is ever dropped! """ segs = [(0.0, L)] if L > 0.0 else [] for ha, hb in holes: if hb <= ha: continue nsegs = [] for sa, sb in segs: if hb <= sa or ha >= sb: nsegs.append((sa, sb)) else: if sa < ha or (sa == ha and sa > 0.0): nsegs.append((sa, ha)) if hb <= sb: nsegs.append((hb, sb)) segs = nsegs return segs def squared_factors_lower(x, roots): value = 1.0 for root in roots: value = max(0.0, dn(value * max(0.0, dn(x - root)))) return max(0.0, dn(value * value)) def eval_poly_rem_ub(c4: int, roots, poly_idx: int) -> float: t0, r1, r2, r3, coefs = POLY_SPECS[poly_idx] p = get_p_exact(c4) rem = 0.0 for k in range(7): rem = up(rem + up(coefs[k] * p[k])) for ra, _rb in roots: if ra >= t0: rem = up(rem - squared_factors_lower(ra, (r1, r2, r3))) return rem def verify_Lrem(c4: int, roots, anchors, holes, L: float, reason_idx: int) -> bool: """ Verify mathematically that EVERY remaining root lies in [0, L]. First verify raw upper bound R_raw from reason_idx (or roots[0][1]), then verify that any trimming from R_raw down to L is strictly covered by open holes in all_holes! """ require((isfinite(L) and L >= 0.0), 'isfinite(L) and L >= 0.0') def open_hole_reach_up(start: float, ah) -> float: # Step 1: an open hole (ha, hb) with ha <= start < hb excludes (start, hb) cur = start for ha, hb in ah: if ha <= start < hb and hb > cur: cur = hb if cur == start: return start # Subsequent steps: require STRICT overlap ha < cur < hb so endpoint cur is also excluded! chg = True while chg: chg = False for ha, hb in ah: if ha < cur < hb: cur = hb chg = True return cur if reason_idx == -1: require((len(roots) > 0), 'len(roots) > 0') R_base = roots[0][1] if L >= R_base: return True ah = all_holes_of(roots, anchors, holes) # Need (L, R_base] strictly covered => reach_up(L) > R_base strictly! return open_hole_reach_up(L, ah) > R_base require((0 <= reason_idx < len(POLY_SPECS)), '0 <= reason_idx < len(POLY_SPECS)') t0, r1, r2, r3, _ = POLY_SPECS[reason_idx] rem = eval_poly_rem_ub(c4, roots, reason_idx) if rem < 0.0: return True if L >= t0: if squared_factors_lower(L, (r1, r2, r3)) > rem: return True # Check if (L, reach) is covered by overlapping open holes and every remaining root < reach ah = all_holes_of(roots, anchors, holes) reach = open_hole_reach_up(L, ah) if reach <= L: return False # If P(reach) > rem (with reach >= t0), then P(r) <= rem < P(reach) => r < reach strictly! if reach >= t0: if squared_factors_lower(reach, (r1, r2, r3)) > rem: return True # Or if r <= roots[0][1] < reach strictly, then (L, roots[0][1]] is inside (L, reach)! return len(roots) > 0 and reach > roots[0][1] # ========================================================================= # Fast Outward-Rounded Polynomial Certification on Support S & Root Boxes # ========================================================================= def min_gap_on_piece(c, shift: float, mode: int, xi0: float, xi1: float, L: float, sa: float, sb: float, n_sub: int) -> float: if len(c) != 7 or not all(isfinite(x) for x in (*c, shift, xi0, xi1, L, sa, sb)): raise CertificateError("min-gap input contains a non-finite or malformed bound") if not (0 <= mode <= 3 and L > 0.0 and sa <= sb and n_sub > 0): raise CertificateError("min-gap input has an invalid mode, scale, interval, or subdivision count") worst = INF c0, c1, c2, c3, c4, c5, c6 = c d_bounds = derivative_coefficient_bounds(c) h = (sb - sa) / n_sub _na = nextafter _ninf = NINF _inf = INF for i in range(n_sub): a = sa if i == 0 else min(sb, sa + i * h) b = sb if i + 1 == n_sub else min(sb, sa + (i + 1) * h) m = 0.5 * (a + b) rad = _na(max(m - a, b - m), _inf) # Outward-rounded Horner for P(m) + shift pm0 = pm1 = c6 for ck in (c5, c4, c3, c2, c1, c0): p1, p2 = pm0 * m, pm1 * m if p1 <= p2: pm0 = _na(_na(p1, _ninf) + ck, _ninf) pm1 = _na(_na(p2, _inf) + ck, _inf) else: pm0 = _na(_na(p2, _ninf) + ck, _ninf) pm1 = _na(_na(p1, _inf) + ck, _inf) if shift != 0.0: pm0 = _na(pm0 + shift, _ninf) # Outward-rounded Horner for P'([a, b]) dp0, dp1 = d_bounds[5] for dk_lo, dk_hi in reversed(d_bounds[:5]): q1, q2, q3, q4 = dp0 * a, dp0 * b, dp1 * a, dp1 * b dp0 = _na(_na(min(q1, q2, q3, q4), _ninf) + dk_lo, _ninf) dp1 = _na(_na(max(q1, q2, q3, q4), _inf) + dk_hi, _inf) piv0 = _na(pm0 - _na(rad * max(fabs(dp0), fabs(dp1)), _inf), _ninf) require(all(map(isfinite, (pm0, pm1, dp0, dp1, piv0))), "Nonfinite Horner interval") if mode == 0: if piv0 < worst: worst = piv0 continue if mode == 1: div0 = _na(xi0 - _na(L * b, _inf), _ninf) if div0 <= 0.0: raise CertificateError("nonpositive logarithm argument on root box") div1 = _na(xi0 - _na(L * a, _ninf), _inf) dm0 = _na(xi0 - _na(L * m, _inf), _ninf) if dm0 <= 0.0: raise CertificateError("nonpositive logarithm argument on root box") v_z = _na(piv0 + log_bounds(div0)[0], _ninf) lg0 = log_bounds(dm0)[0] gm0 = _na(pm0 + lg0, _ninf) df0 = _na(L / div1, _ninf) df1 = _na(L / div0, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _ninf) mdg = max(fabs(dg0), fabs(dg1)) v_t = _na(gm0 - _na(rad * mdg, _inf), _ninf) val = v_z if v_z > v_t else v_t elif mode == 2: div0 = _na(xi1 - _na(L * b, _inf), _ninf) if div0 <= 0.0: raise CertificateError("nonpositive logarithm argument on root box") div1 = _na(xi1 - _na(L * a, _ninf), _inf) dm1 = _na(xi1 - _na(L * m, _inf), _inf) v_z = _na(piv0 - log_bounds(div1)[1], _ninf) fm1 = log_bounds(dm1)[1] gm0 = _na(pm0 - fm1, _ninf) df0 = _na(-L / div0, _ninf) df1 = _na(-L / div1, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _inf) mdg = max(fabs(dg0), fabs(dg1)) v_t = _na(gm0 - _na(rad * mdg, _inf), _ninf) val = v_z if v_z > v_t else v_t else: la0, la1 = _na(L * a, _ninf), _na(L * a, _inf) lb0, lb1 = _na(L * b, _ninf), _na(L * b, _inf) dmax = max( fabs(_na(la0 - xi1, _ninf)), fabs(_na(la1 - xi0, _inf)), fabs(_na(lb0 - xi1, _ninf)), fabs(_na(lb1 - xi0, _inf)), ) v_z = _na(piv0 - log_bounds(dmax)[1], _ninf) if dmax > 0.0 else 1e300 v_t = -1e300 if lb1 < xi0: div0 = _na(xi1 - lb1, _ninf) if div0 > 0.0: div1 = _na(xi1 - la0, _inf) dm1 = _na(xi1 - _na(L * m, _ninf), _inf) fm1 = log_bounds(dm1)[1] gm0 = _na(pm0 - fm1, _ninf) df0 = _na(-L / div0, _ninf) df1 = _na(-L / div1, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _inf) mdg = max(fabs(dg0), fabs(dg1)) v_t = _na(gm0 - _na(rad * mdg, _inf), _ninf) elif la0 > xi1: div0 = _na(la0 - xi0, _ninf) if div0 > 0.0: div1 = _na(lb1 - xi0, _inf) dm1 = _na(_na(L * m, _inf) - xi0, _inf) fm1 = log_bounds(dm1)[1] gm0 = _na(pm0 - fm1, _ninf) df0 = _na(L / div1, _ninf) df1 = _na(L / div0, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _inf) mdg = max(fabs(dg0), fabs(dg1)) v_t = _na(gm0 - _na(rad * mdg, _inf), _ninf) val = v_z if v_z > v_t else v_t if not isfinite(val): raise CertificateError("non-finite interval lower bound in min-gap calculation") if val < worst: worst = val if not isfinite(worst): raise CertificateError("non-finite min-gap result") return worst def verify_poly_on_support(c, segs, mode: int, xi_iv, L: float, cut_left: float = -1.0, shift_left: float = 0.0) -> bool: if (len(c) != 7 or len(xi_iv) != 2 or not all(isfinite(x) for x in (*c, *xi_iv, L, cut_left, shift_left)) or not 0 <= mode <= 3 or L < 2**-40): return False c0, c1, c2, c3, c4, c5, c6 = c if c6 < 0.0: return False d_bounds = derivative_coefficient_bounds(c) xi0, xi1 = xi_iv _na = nextafter _ninf = NINF _inf = INF _fabs = fabs stk = [] for sa, sb in segs: sh = shift_left if (cut_left >= 0.0 and sb <= cut_left) else 0.0 ua = 0.0 if sa == 0.0 else max(0.0, _na(sa / L, _ninf)) ub = _na(sb / L, _inf) n0 = max(4, int(math.ceil(10.0 * (ub - ua)))) inv_n0 = (ub - ua) / n0 for i in range(n0): a = ua if i == 0 else min(ub, ua + i * inv_n0) b = ub if i + 1 == n0 else min(ub, ua + (i + 1) * inv_n0) stk.append((a, b, sh, 0)) evals = 0 while stk: a, b, sh, d = stk.pop() evals += 1 m = 0.5 * (a + b) rad = _na(b - m if b - m > m - a else m - a, _inf) # Outward-rounded Horner for P(m) + sh (unrolled for speed, bit-identical!) pm0 = pm1 = c6 for ck in (c5, c4, c3, c2, c1, c0): p1 = pm0 * m p2 = pm1 * m if p1 <= p2: pm0 = _na(_na(p1, _ninf) + ck, _ninf) pm1 = _na(_na(p2, _inf) + ck, _inf) else: pm0 = _na(_na(p2, _ninf) + ck, _ninf) pm1 = _na(_na(p1, _inf) + ck, _inf) if sh != 0.0: pm0 = _na(pm0 + sh, _ninf) # Outward-rounded Horner for P'([a, b]) dp0, dp1 = d_bounds[5] for dk_lo, dk_hi in reversed(d_bounds[:5]): q1 = dp0 * a q2 = dp0 * b q3 = dp1 * a q4 = dp1 * b mn = q1 if q1 < q2 else q2 if q3 < mn: mn = q3 if q4 < mn: mn = q4 mx = q1 if q1 > q2 else q2 if q3 > mx: mx = q3 if q4 > mx: mx = q4 dp0 = _na(_na(mn, _ninf) + dk_lo, _ninf) dp1 = _na(_na(mx, _inf) + dk_hi, _inf) adp = _fabs(dp0) adp1 = _fabs(dp1) if adp1 > adp: adp = adp1 piv0 = _na(pm0 - _na(rad * adp, _inf), _ninf) require(all(map(isfinite, (pm0, pm1, dp0, dp1, piv0))), "Nonfinite Horner interval") if mode == 0: if piv0 >= 0.0: continue elif mode == 1: div0 = _na(xi0 - _na(L * b, _inf), _ninf) if div0 > 0.0: lv = log_bounds(div0)[0] if _na(piv0 + lv, _ninf) >= 0.0: continue dm0 = _na(xi0 - _na(L * m, _inf), _ninf) if dm0 > 0.0: div1 = _na(xi0 - _na(L * a, _ninf), _inf) lvm = log_bounds(dm0)[0] gm0 = _na(pm0 + lvm, _ninf) df0 = _na(L / div1, _ninf) df1 = _na(L / div0, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _ninf) mdg = _fabs(dg0) if _fabs(dg1) > mdg: mdg = _fabs(dg1) if _na(gm0 - _na(rad * mdg, _inf), _ninf) >= 0.0: continue elif mode == 2: div0 = _na(xi1 - _na(L * b, _inf), _ninf) if div0 > 0.0: div1 = _na(xi1 - _na(L * a, _ninf), _inf) lv = log_bounds(div1)[1] if _na(piv0 - lv, _ninf) >= 0.0: continue dm1 = _na(xi1 - _na(L * m, _ninf), _inf) lvm = log_bounds(dm1)[1] gm0 = _na(pm0 - lvm, _ninf) df0 = _na(-L / div0, _ninf) df1 = _na(-L / div1, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _ninf) mdg = _fabs(dg0) if _fabs(dg1) > mdg: mdg = _fabs(dg1) if _na(gm0 - _na(rad * mdg, _inf), _ninf) >= 0.0: continue else: la0, la1 = _na(L * a, _ninf), _na(L * a, _inf) lb0, lb1 = _na(L * b, _ninf), _na(L * b, _inf) dmax = _fabs(_na(la0 - xi1, _ninf)) t = _fabs(_na(la1 - xi0, _inf)) if t > dmax: dmax = t t = _fabs(_na(lb0 - xi1, _ninf)) if t > dmax: dmax = t t = _fabs(_na(lb1 - xi0, _inf)) if t > dmax: dmax = t if dmax == 0.0: continue lv = log_bounds(dmax)[1] if _na(piv0 - lv, _ninf) >= 0.0: continue if lb1 < xi0: div0 = _na(xi1 - lb1, _ninf) if div0 > 0.0: div1 = _na(xi1 - la0, _inf) dm1 = _na(xi1 - _na(L * m, _ninf), _inf) lvm = log_bounds(dm1)[1] gm0 = _na(pm0 - lvm, _ninf) df0 = _na(-L / div0, _ninf) df1 = _na(-L / div1, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _ninf) mdg = _fabs(dg0) if _fabs(dg1) > mdg: mdg = _fabs(dg1) if _na(gm0 - _na(rad * mdg, _inf), _ninf) >= 0.0: continue elif la0 > xi1: div0 = _na(la0 - xi0, _ninf) if div0 > 0.0: div1 = _na(lb1 - xi0, _inf) dm1 = _na(_na(L * m, _inf) - xi0, _inf) lvm = log_bounds(dm1)[1] gm0 = _na(pm0 - lvm, _ninf) df0 = _na(L / div1, _ninf) df1 = _na(L / div0, _inf) dg0 = _na(dp0 - df1, _ninf) dg1 = _na(dp1 - df0, _ninf) mdg = _fabs(dg0) if _fabs(dg1) > mdg: mdg = _fabs(dg1) if _na(gm0 - _na(rad * mdg, _inf), _ninf) >= 0.0: continue if d >= 20 or evals > 40000: return False stk.append((a, m, sh, d + 1)) stk.append((m, b, sh, d + 1)) return True def eval_c_dot_p_ub(c, L: float, p) -> float: require(c[6] >= 0.0, "Negative sixth-moment coefficient") s = up(c[0] * p[0]) for k in range(1, 7): Lk0, Lk1 = iv_pow_nn(L, L, k) uk0, uk1 = iv_div(c[k], c[k], Lk0, Lk1) _p0, p1 = iv_mul(uk0, uk1, p[k], p[k]) s = up(s + p1) return s def eval_c_dot_q_ub(c, roots, L: float, p) -> float: K = len(roots) m_cnt = float(13 - K) s = up(c[0] * m_cnt) for k in range(1, 7): slo, shi = 0.0, 0.0 for ra, rb in roots: p0, p1 = iv_pow_nn(ra, rb, k) slo = dn(slo + p0) shi = up(shi + p1) ql = 0.0 if k == 6 else dn(p[k] - shi) qh = up(p[k] - slo) Lk0, Lk1 = iv_pow_nn(L, L, k) qlo = dn(ql / Lk1) if ql >= 0.0 else dn(ql / Lk0) qhi = up(qh / Lk0) if qh >= 0.0 else up(qh / Lk1) if k == 6: require((c[6] >= 0.0), 'c[6] >= 0.0') s = up(s + up(c[6] * qhi)) else: s = up(s + (up(c[k] * qhi) if c[k] >= 0.0 else up(c[k] * qlo))) return s def coupled_ub(c, mode: int, xi_iv, L: float, p, roots, j_out, j_in, alpha_left: float = 0.0, m_left: int = 0) -> float: xi0, xi1 = xi_iv ub = eval_c_dot_p_ub(c, L, p) if m_left != 0 and alpha_left != 0.0: ub = up(ub + up(alpha_left * float(m_left))) for j in j_out: ra, rb = roots[j] sa, sb = dn(ra / L), up(rb / L) ns = max(12, min(96, int(math.ceil((sb - sa) * 300.0)))) mg = min_gap_on_piece(c, 0.0, mode, xi0, xi1, L, sa, sb, ns) require((mg > -1e200 and isfinite(mg)), 'mg > -1e200 and isfinite(mg)') ub = up(ub - mg) for j in j_in: ra, rb = roots[j] sa, sb = dn(ra / L), up(rb / L) ns = max(12, min(96, int(math.ceil((sb - sa) * 300.0)))) mg = min_gap_on_piece(c, 0.0, 0, 0.0, 0.0, L, sa, sb, ns) require((mg > -1e200 and isfinite(mg)), 'mg > -1e200 and isfinite(mg)') ub = up(ub - mg) return ub # ========================================================================= # Stage A: Exact Symbolic / Rational Combinatorial & Spectral Identities # ========================================================================= def verify_stage_a(): print("[Stage A] Verifying exact combinatorial, algebraic & spectral identities...") # [A1] Factored nonnegative polynomials P_0..P_5 for idx, (t0, r1, r2, r3, coefs) in enumerate(POLY_SPECS): q = [Fraction(1)] for r in (Fraction(r1), Fraction(r2), Fraction(r3)): nq = [Fraction(0)] * (len(q) + 1) for i, v in enumerate(q): nq[i] -= v * r nq[i + 1] += v q = nq sq = [Fraction(0)] * 7 for i in range(4): for j in range(4): sq[i + j] += q[i] * q[j] for k in range(7): require((sq[k] == Fraction(coefs[k])), f"P_{idx} coeff mismatch at k={k}") require((t0 >= max(r1, r2, r3)), 't0 >= max(r1, r2, r3)') print(f" [A1] All {len(POLY_SPECS)} factored nonnegative polynomials P_0..P_5 verified symbolically -> OK") # [A2] Exact Laguerre orthogonality: int_0^inf e^{-x} x^m L_d(x) dx = 0 for m <= 5, d in {6,7,8} # => Q_{c1,c2} = L_8 + c1 L_7 + c2 L_6 gives EXACT 8-pt quadrature for all degree <= 13 polynomials! for d in (6, 7, 8): Ld = laguerre_frac(d) for m in range(6): integral = sum(Ld[k] * Fraction(math.factorial(k + m)) for k in range(d + 1)) require((integral == 0), f"Laguerre orthogonality failed for d={d}, m={m}: {integral}") print(" [A2] Exact Fraction Laguerre orthogonality int e^-x x^m L_d(x) dx = 0 (m<=5, d=6..8) -> OK") # [A3] Exact Fraction verification of Rayleigh-coupled + Cauchy-interlacing + triangle p_6 bounds (C_4=8..13) def h_a(a, x): return -(x ** 3) - (3 - 2 * a) * (x ** 2) + (6 * a - a ** 2) * x def hp_a(a, x): return -3 * (x ** 2) - 2 * (3 - 2 * a) * x + (6 * a - a ** 2) def check_1eig(S, L1, a, target_lt): require((3 - 2 * a >= 0 and hp_a(a, L1) < 0), '3 - 2 * a >= 0 and hp_a(a, L1) < 0') val = 33 * (a ** 2) + (3 - 2 * a) * S + h_a(a, L1) require((val < target_lt), f"1-eig bound {float(val)} >= {target_lt}") # C_4 = 8 Case 2b exact rational factorization at alpha = 2/5: a25 = Fraction(2, 5) for xtest in (Fraction(0), Fraction(2, 5), Fraction(1), Fraction(3)): require((hp_a(a25, xtest) == -3 * (xtest - Fraction(2, 5)) * (xtest + Fraction(28, 15))), 'hp_a(a25, xtest) == -3 * (xtest - Fraction(2, 5)) * (xtest + Fraction(28, 15))') for s in range(-4, 4): a1 = Fraction(2) - Fraction(s, 2) a2 = Fraction(26, 9) + Fraction(13 * s, 18) m1, m2 = max(max(a1, a2), a25), max(min(a1, a2), a25) val = 30 * (a25 ** 2) + (3 - 2 * a25) * Fraction(32) + h_a(a25, m1) + h_a(a25, m2) require((val < 36), 'val < 36') check_1eig(Fraction(32), Fraction(130, 43), Fraction(1, 2), 36) # C4=8 Case 2a: <= 30 + 72 = 102 check_1eig(Fraction(32), Fraction(26, 11), Fraction(3, 5), 54) # C4=8 Case 1: <= 48 + 48 = 96 # C_4 = 9..13 exact certificates: check_1eig(Fraction(36), Fraction(26, 11), Fraction(7, 10), 66) # C4=9 P2: <= 60 + 96 = 156 check_1eig(Fraction(36), Fraction(26, 5), Fraction(1, 5), 0) # C4=9 K33: < 0 + 144 = 144 check_1eig(Fraction(36), Fraction(39, 11), Fraction(1, 2), 24) # C4=9 P3: <= 18 + 120 = 138 for c4, a2, t2, a3, t3, k2, k3, tot in ( (10, Fraction(7, 10), 72, Fraction(1, 2), 30, 3, 5, 264), (11, Fraction(4, 5), 78, Fraction(3, 5), 36, 3, 5, 270), (12, Fraction(9, 10), 84, Fraction(7, 10), 42, 4, 6, 324), (13, Fraction(9, 10), 84, Fraction(4, 5), 48, 4, 6, 330), ): check_1eig(Fraction(4 * c4), Fraction(26, 11), a2, t2) check_1eig(Fraction(4 * c4), Fraction(39, 11), a3, t3) require((max((t2 - 6) + 48 * k2, (t3 - 6) + 48 * k3) == tot), 'max((t2 - 6) + 48 * k2, (t3 - 6) + 48 * k3) == tot') # Pointwise K_{2,3} inequalities for general C_4 >= 14 for d in (-1, 0, 1, 2, 3): c = 1 + d require((Fraction(c * (c - 1) * (c - 2) // 6) <= Fraction(1, 3) * (d * d + d)), 'Fraction(c * (c - 1) * (c - 2) // 6) <= Fraction(1, 3) * (d * d + d)') print(" [A3] Exact Fraction Rayleigh-coupled / Cauchy-interlacing / triangle p_6 bounds (C_4=8..13) -> OK") # [A4] Verify m_0..m_6, 6 C_6 = 1404 - 36 C_4 + tr(D^3), Newton p_1..p_6, and p_6 upper bound on 61 matrices base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) le7_path = os.path.join(base_dir, "data", "global_c4_le7.txt") test_mats = [] if os.path.exists(le7_path): with open(le7_path) as f: for line in f: line = line.strip() if not line or line.startswith("#") or "," not in line: continue hex_part = next((tok for tok in line.split() if tok.count(",") == 12), None) if hex_part: test_mats.append([int(h, 16) for h in hex_part.split(",")]) for hx_s in ( "1980,1a40,06a0,0710,1038,1026,00d4,014a,0161,020d,0c0c,0c03,0093", # B8 (C4=8) "06c0,1860,1890,01a8,0432,100e,0425,0059,1608,0b04,0a03,0154,0183", # B9 (C4=9) ): test_mats.append([int(h, 16) for h in hx_s.split(",")]) for diffset in ([0, 1, 2, 6], [0, 1, 3, 11], [0, 1, 2, 3]): rows = [] for i in range(13): m = 0 for d in diffset: m |= 1 << ((i + d) % 13) rows.append(m) test_mats.append(rows) test_mats.append([ 0x000F, 0x000F, 0x000F, 0x000F, 0x00F0, 0x00F0, 0x00F0, 0x00F0, 0x1E00, 0x1D00, 0x1B00, 0x1700, 0x0F00, ]) def rook_poly_m0_to_m6(rows): dp = {0: 1} for rmask in rows: ndp = dict(dp) cols = [c for c in range(13) if (rmask >> c) & 1] for mask, cnt in dp.items(): if mask.bit_count() >= 6: continue for c in cols: bit = 1 << c if not (mask & bit): nmask = mask | bit ndp[nmask] = ndp.get(nmask, 0) + cnt dp = ndp m = [0] * 7 for mask, cnt in dp.items(): k = mask.bit_count() if k <= 6: m[k] += cnt return m max_c4_seen = 0 for rows in test_mats: A = [[(rows[i] >> j) & 1 for j in range(13)] for i in range(13)] require((all(sum(r) == 4 for r in A)), 'all(sum(r) == 4 for r in A)') require((all(sum(A[i][j] for i in range(13)) == 4 for j in range(13))), 'all(sum(A[i][j] for i in range(13)) == 4 for j in range(13))') G = [[sum(A[i][c] * A[j][c] for c in range(13)) for j in range(13)] for i in range(13)] Gp = [[sum(A[r][i] * A[r][j] for r in range(13)) for j in range(13)] for i in range(13)] D = [[G[i][j] - (4 if i == j else 1) for j in range(13)] for i in range(13)] c4 = sum(G[i][j] * (G[i][j] - 1) // 2 for i in range(13) for j in range(i + 1, 13)) max_c4_seen = max(max_c4_seen, c4) k23_r = sum(G[i][j] * (G[i][j] - 1) * (G[i][j] - 2) // 6 for i in range(13) for j in range(i + 1, 13)) k23_c = sum(Gp[i][j] * (Gp[i][j] - 1) * (Gp[i][j] - 2) // 6 for i in range(13) for j in range(i + 1, 13)) tr3 = sum(D[i][j] * D[j][l] * D[l][i] for i in range(13) for j in range(13) for l in range(13)) require((tr3 % 6 == 0), 'tr3 % 6 == 0') c6 = 0 for r0 in range(13): for r1 in range(r0 + 1, 13): for r2 in range(r0 + 1, 13): if r2 == r1: continue m01, m12, m20 = rows[r0] & rows[r1], rows[r1] & rows[r2], rows[r2] & rows[r0] if not (m01 and m12 and m20): continue for c0 in range(13): if not ((m01 >> c0) & 1): continue for c1 in range(13): if c1 == c0 or not ((m12 >> c1) & 1): continue c6 += (m20 & ~((1 << c0) | (1 << c1))).bit_count() require((c6 % 2 == 0), 'c6 % 2 == 0') c6 //= 2 require((6 * c6 == 1404 - 36 * c4 + tr3), '6 * c6 == 1404 - 36 * c4 + tr3') m = rook_poly_m0_to_m6(rows) require((m[:4] == [1, 52, 1170, 14976]), 'm[:4] == [1, 52, 1170, 14976]') require((m[4] == 120627 + c4 and m[5] == 638820 + 28 * c4), 'm[4] == 120627 + c4 and m[5] == 638820 + 28 * c4') require((m[6] == 2258100 + 318 * c4 + (c6 - 234) - 4 * (k23_r + k23_c)), 'm[6] == 2258100 + 318 * c4 + (c6 - 234) - 4 * (k23_r + k23_c)') p = [13] for k in range(1, 7): pk = ((-1) ** (k - 1)) * k * m[k] for j in range(1, k): pk += ((-1) ** (j - 1)) * m[j] * p[k - j] p.append(pk) require((p[4] == 27196 - 4 * c4 and p[5] == 258232 - 120 * c4), 'p[4] == 27196 - 4 * c4 and p[5] == 258232 - 120 * c4') require((p[6] == 2538172 - 2340 * c4 - tr3 + 24 * (k23_r + k23_c)), 'p[6] == 2538172 - 2340 * c4 - tr3 + 24 * (k23_r + k23_c)') if c4 >= 8: require((p[6] <= get_p_exact(c4)[6]), 'p[6] <= get_p_exact(c4)[6]') print(f" [A4] All {len(test_mats)} matrices (C_4 in [0, {max_c4_seen}]) satisfy exact m_0..m_6, 6 C_6, p_1..p_6, and sharpened p_6 UB -> OK") # [A5] (13, 4, 1) zero-root Stieltjes Hankel positivity barrier q = [12, 52, 364, 3016, 27196, 258232, 2538172] def det_exact(M): n = len(M) A = [[Fraction(x) for x in row] for row in M] d = Fraction(1) for col in range(n): piv = next(r for r in range(col, n) if A[r][col] != 0) if piv != col: A[col], A[piv] = A[piv], A[col] d = -d d *= A[col][col] for r in range(col + 1, n): fac = A[r][col] / A[col][col] for j in range(col, n): A[r][j] -= fac * A[col][j] return d for k in range(1, 5): require((det_exact([[q[i + j] for j in range(k)] for i in range(k)]) > 0), 'det_exact([[q[i + j] for j in range(k)] for i in range(k)]) > 0') for k in range(1, 4): require((det_exact([[q[i + j + 1] for j in range(k)] for i in range(k)]) > 0), 'det_exact([[q[i + j + 1] for j in range(k)] for i in range(k)]) > 0') print(" [A5] (13, 4, 1) zero-root Stieltjes Hankel barrier (all 7 leading minors > 0) -> OK") # ========================================================================= # Stage B: Complete Zero-LP-Solver Proof-Tree Interval Verifier # ========================================================================= def verify_subtree_task(task): c4, init_roots, init_anchors, init_holes, sub_lines = task it = iter(sub_lines) p = get_p_exact(c4) stats = {"nodes": 0, "farkas": 0, "poly": 0, "triv": 0, "intgap": 0, "gl8": 0, "intsplit": 0, "min_gap": INF} def parse_node(roots, anchors, holes): K = len(roots) toks = next_record(it, "tree node") tag = toks[0] stats["nodes"] += 1 if tag == "DESCEND_R0": require(K == 0 and not holes, "Largest-root descent must start from an empty state") L0 = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) require((verify_Lrem(c4, [], [], [], L0, r_idx)), f"C4={c4}: invalid DESCEND_R0 L0={L0}") require((L0 >= 4.0), 'L0 >= 4.0') parse_node([(4.0, L0)], [None], []) elif tag == "SPLIT_ROOT": j = parse_int(toks[1]) mid = parse_hex_float(toks[2]) require((0 <= j < K and roots[j][0] < mid < roots[j][1]), '0 <= j < K and roots[j][0] < mid < roots[j][1]') r1 = list(roots); r1[j] = (roots[j][0], mid) r2 = list(roots); r2[j] = (mid, roots[j][1]) parse_node(r1, anchors, holes) parse_node(r2, anchors, holes) elif tag == "HOLE_OR_HIT": L = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) xi = parse_hex_float(toks[3]) ha = parse_hex_float(toks[4]) hb = parse_hex_float(toks[5]) n_sh = parse_int(toks[6]) require((verify_Lrem(c4, roots, anchors, holes, L, r_idx)), 'verify_Lrem(c4, roots, anchors, holes, L, r_idx)') require(1 <= K < 13 and anchors[0] is None and L > 0.0 and xi >= 0.0 and 0.0 <= ha < hb and n_sh >= 1, "Invalid hole branch") shells = [] for s_i in range(n_sh): ua = parse_hex_float(toks[7 + 2 * s_i]) ub = parse_hex_float(toks[8 + 2 * s_i]) require((ha <= ua < ub <= hb), 'ua < ub') shells.append((ua, ub)) # Verify shells cover [ha, hb] with ZERO gaps! shells_s = sorted(shells) require((shells_s[0][0] <= ha and shells_s[-1][1] >= hb), 'shells_s[0][0] <= ha and shells_s[-1][1] >= hb') cov = shells_s[0][1] for ua, ub in shells_s[1:]: require((ua <= cov), f"C4={c4}: shell coverage gap {cov} < {ua}") if ub > cov: cov = ub require((cov >= hb), 'cov >= hb') ah = all_holes_of(roots, anchors, holes, L) segs = get_support(L, ah) # Child 0: HOLE (ha, hb) parse_node(roots, anchors, holes + [(ha, hb)]) # Children 1+: HIT in each shell intersect S (closest-root anchor = xi) for ua, ub in shells: for ia, ib in shell_intersections(segs, (ua, ub), (ha, hb)): parse_node(roots + [(ia, ib)], anchors + [(xi, ha, hb)], holes) elif tag == "LEAF_POLY": poly_idx = parse_int(toks[1]) require((0 <= poly_idx < len(POLY_SPECS) and eval_poly_rem_ub(c4, roots, poly_idx) < 0.0), 'eval_poly_rem_ub(c4, roots, poly_idx) < 0.0') stats["poly"] += 1 elif tag == "LEAF_TRIV": L = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) k = parse_int(toks[3]) require((verify_Lrem(c4, roots, anchors, holes, L, r_idx)), 'verify_Lrem(c4, roots, anchors, holes, L, r_idx)') if k == 0: require((K < 13 and len(get_support(L, all_holes_of(roots, anchors, holes, L))) == 0), 'K < 13 and len(get_support(L, all_holes_of(roots, anchors, holes, L))) == 0') else: require((1 <= k <= 5), '1 <= k <= 5') slo, shi = 0.0, 0.0 for ra, rb in roots: p0, p1 = iv_pow_nn(ra, rb, k) slo = dn(slo + p0) shi = up(shi + p1) ql = dn(p[k] - shi) qh = up(p[k] - slo) Lk_hi = iv_pow_nn(L, L, k)[1] require((qh < 0.0 or ql > up(float(13 - K) * Lk_hi)), 'qh < 0.0 or ql > up(float(13 - K) * Lk_hi)') stats["triv"] += 1 elif tag == "LEAF_FARKAS": L = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) kind = toks[3] w = tuple(parse_hex_float(toks[4 + k]) for k in range(7)) require((verify_Lrem(c4, roots, anchors, holes, L, r_idx)), 'verify_Lrem(c4, roots, anchors, holes, L, r_idx)') segs = get_support(L, all_holes_of(roots, anchors, holes, L)) require((verify_poly_on_support(w, segs, 0, (0.0, 0.0), L)), 'verify_poly_on_support(w, segs, 0, (0.0, 0.0), L)') if kind == "C": ub = coupled_ub(w, 0, (0.0, 0.0), L, p, roots, (), tuple(range(K))) elif kind == "D": ub = eval_c_dot_q_ub(w, roots, L, p) else: raise ValueError(kind) require((isfinite(ub) and ub < 0.0), f"C4={c4}: Farkas ub={ub} >= 0") stats["farkas"] += 1 elif tag == "LEAF_INTGAP": L = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) ga = parse_hex_float(toks[3]) k_int = parse_int(toks[4]) c_hi = tuple(parse_hex_float(toks[5 + k]) for k in range(7)) c_lo = tuple(parse_hex_float(toks[12 + k]) for k in range(7)) require((verify_Lrem(c4, roots, anchors, holes, L, r_idx)), 'verify_Lrem(c4, roots, anchors, holes, L, r_idx)') segs = get_support(L, all_holes_of(roots, anchors, holes, L)) require((any(r + 1 < len(segs) and segs[r][1] == ga for r in range(len(segs)))), 'any(r + 1 < len(segs) and segs[r][1] == ga for r in range(len(segs)))') all_j = tuple(range(K)) require((verify_poly_on_support(c_hi, segs, 0, (0.0, 0.0), L, ga, -1.0)), 'verify_poly_on_support(c_hi, segs, 0, (0.0, 0.0), L, ga, -1.0)') u_hi = coupled_ub(c_hi, 0, (0.0, 0.0), L, p, roots, (), all_j) require((verify_poly_on_support(c_lo, segs, 0, (0.0, 0.0), L, ga, +1.0)), 'verify_poly_on_support(c_lo, segs, 0, (0.0, 0.0), L, ga, +1.0)') neg_lo = coupled_ub(c_lo, 0, (0.0, 0.0), L, p, roots, (), all_j) require((neg_lo < -float(k_int) and u_hi < float(k_int + 1)), f"C4={c4}: INTGAP failed: neg_lo={neg_lo}, u_hi={u_hi}, k={k_int}") stats["intgap"] += 1 elif tag == "LEAF_GL8": L = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) c1 = parse_hex_float(toks[3]) c2 = parse_hex_float(toks[4]) n_pg = parse_int(toks[5]) require(0 <= n_pg <= 8, "gap parity count out of range") require((verify_Lrem(c4, roots, anchors, holes, L, r_idx)), 'verify_Lrem(c4, roots, anchors, holes, L, r_idx)') segs = get_support(L, all_holes_of(roots, anchors, holes, L)) x_ivs, w_ivs = get_rigorous_rule8(c1, c2) all_j = tuple(range(K)) pos_gaps = [] for _ in range(n_pg): gt = next_record(it, "gap parity") require((gt[0] == "GAP_PAR"), 'gt[0] == "GAP_PAR"') ga = parse_hex_float(gt[1]) m_u = parse_int(gt[2]) c_hi = tuple(parse_hex_float(gt[3 + k]) for k in range(7)) c_lo = tuple(parse_hex_float(gt[10 + k]) for k in range(7)) r_match = next(r for r in range(len(segs) - 1) if segs[r][1] == ga) gb = segs[r_match + 1][0] require((verify_poly_on_support(c_hi, segs, 0, (0.0, 0.0), L, ga, -1.0)), 'verify_poly_on_support(c_hi, segs, 0, (0.0, 0.0), L, ga, -1.0)') u_hi = coupled_ub(c_hi, 0, (0.0, 0.0), L, p, roots, (), all_j) require((verify_poly_on_support(c_lo, segs, 0, (0.0, 0.0), L, ga, +1.0)), 'verify_poly_on_support(c_lo, segs, 0, (0.0, 0.0), L, ga, +1.0)') neg_lo = coupled_ub(c_lo, 0, (0.0, 0.0), L, p, roots, (), all_j) require((0 <= m_u <= 13 - K and u_hi < float(m_u + 1) and neg_lo < -float(m_u - 1)), '0 <= m_u <= 13 - K and u_hi < float(m_u + 1) and neg_lo < -float(m_u - 1)') fix_above = 0 for ra, rb in roots: if ra >= gb: fix_above += 1 else: require((rb <= ga), "Fixed root straddles parity gap!") require(((fix_above + (13 - K - m_u)) % 2 == 0), "Gap parity is not even!") pos_gaps.append((ga, gb)) total_lo = 0.0 for idx in range(8): nt = next_record(it, "quadrature node") ntag = nt[0] xi_iv = x_ivs[idx] wi_iv = w_ivs[idx] require((wi_iv[0] > 0.0), 'wi_iv[0] > 0.0') if ntag == "SKIP_TOP": require((K >= 1 and xi_iv[0] >= roots[0][1] and xi_iv[0] >= L), 'K >= 1 and xi_iv[0] >= roots[0][1] and xi_iv[0] >= L') elif ntag == "SKIP_GAP": expect_arity(nt, 2, ntag) g_id = parse_int(nt[1]) require(0 <= g_id < len(pos_gaps), "gap index out of range") ga, gb = pos_gaps[g_id] require((xi_iv[0] >= ga and xi_iv[1] <= gb), 'xi_iv[0] >= ga and xi_iv[1] <= gb') elif ntag == "POS": kind = nt[1] c = tuple(parse_hex_float(nt[2 + k]) for k in range(7)) require((xi_iv[0] > L and all(rb < xi_iv[0] for _ra, rb in roots)), 'xi_iv[0] > L and all(rb < xi_iv[0] for _ra, rb in roots)') require((verify_poly_on_support(c, segs, 1, xi_iv, L)), 'verify_poly_on_support(c, segs, 1, xi_iv, L)') if kind == "C": ub = coupled_ub(c, 1, xi_iv, L, p, roots, all_j, ()) elif kind == "D": ub = eval_c_dot_q_ub(c, roots, L, p) for _ra, rb in roots: dmin = dn(xi_iv[0] - rb) require((dmin > 0.0), 'dmin > 0.0') ub = up(ub - log_bounds(dmin)[0]) else: raise ValueError(kind) require((isfinite(ub)), 'isfinite(ub)') total_lo = dn(total_lo + dn(wi_iv[0] * exp_bounds(-ub)[0])) elif ntag == "NEG": kind = nt[1] c = tuple(parse_hex_float(nt[2 + k]) for k in range(7)) rem_pos = xi_iv[0] > L mode = 2 if rem_pos else 3 require((verify_poly_on_support(c, segs, mode, xi_iv, L)), 'verify_poly_on_support(c, segs, mode, xi_iv, L)') j_out, j_in = [], [] pf_in_hi, pf_all_hi = 1.0, 1.0 for j, (ra, rb) in enumerate(roots): dm = max( fabs(dn(ra - xi_iv[1])), fabs(up(ra - xi_iv[0])), fabs(dn(rb - xi_iv[1])), fabs(up(rb - xi_iv[0])), ) pf_all_hi = up(pf_all_hi * dm) if xi_iv[1] < ra or xi_iv[0] > rb: j_out.append(j) else: j_in.append(j) pf_in_hi = up(pf_in_hi * dm) if kind == "C": ub = coupled_ub(c, mode, xi_iv, L, p, roots, j_out, j_in) loss = up(up(wi_iv[1] * pf_in_hi) * exp_bounds(ub)[1]) elif kind == "D": ub = eval_c_dot_q_ub(c, roots, L, p) loss = up(up(wi_iv[1] * pf_all_hi) * exp_bounds(ub)[1]) else: raise ValueError(kind) require((isfinite(loss)), 'isfinite(loss)') total_lo = dn(total_lo - loss) else: raise ValueError(f"Unknown node tag: {ntag}") require((isfinite(total_lo) and total_lo > TARGET), f"C4={c4}: LEAF_GL8 failed: total_lo={total_lo} <= {TARGET}") stats["gl8"] += 1 gap = dn(total_lo - TARGET) if gap < stats["min_gap"]: stats["min_gap"] = gap elif tag == "LEAF_INTSPLIT": L = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) c1 = parse_hex_float(toks[3]) c2 = parse_hex_float(toks[4]) ga = parse_hex_float(toks[5]) require((verify_Lrem(c4, roots, anchors, holes, L, r_idx)), 'verify_Lrem(c4, roots, anchors, holes, L, r_idx)') segs = get_support(L, all_holes_of(roots, anchors, holes, L)) r_match = next(r for r in range(len(segs) - 1) if segs[r][1] == ga) gb = segs[r_match + 1][0] x_ivs, w_ivs = get_rigorous_rule8(c1, c2) all_j = tuple(range(K)) clean = True fix_above = 0 for ra, rb in roots: if ra >= gb: fix_above += 1 elif rb <= ga: pass else: clean = False n_rem = 13 - K for m_exp in range(n_rem + 1): mt = next_record(it, "integer case") mtag = mt[0] m_val = parse_int(mt[1]) require((m_val == m_exp), f"C4={c4}: INTSPLIT expected m={m_exp}, got {m_val}") if mtag == "M_FARKAS": alp = parse_hex_float(mt[2]) w = tuple(parse_hex_float(mt[3 + k]) for k in range(7)) require((isfinite(alp) and verify_poly_on_support(w, segs, 0, (0.0, 0.0), L, ga, alp)), 'isfinite(alp) and verify_poly_on_support(w, segs, 0, (0.0, 0.0), L, ga, alp)') ub = coupled_ub(w, 0, (0.0, 0.0), L, p, roots, (), all_j, alp, m_val) require((isfinite(ub) and ub < 0.0), f"C4={c4}: M_FARKAS m={m_val} ub={ub} >= 0") elif mtag == "M_GL8": gap_pos = clean and ((fix_above + n_rem - m_val) % 2 == 0) total_lo = 0.0 for idx in range(8): nt = next_record(it, "quadrature node") ntag = nt[0] xi_iv, wi_iv = x_ivs[idx], w_ivs[idx] require((wi_iv[0] > 0.0), 'wi_iv[0] > 0.0') if ntag == "SKIP_TOP": require((K >= 1 and xi_iv[0] >= roots[0][1] and xi_iv[0] >= L), 'K >= 1 and xi_iv[0] >= roots[0][1] and xi_iv[0] >= L') elif ntag == "SKIP_GAP": expect_arity(nt, 1, ntag) require((gap_pos and xi_iv[0] >= ga and xi_iv[1] <= gb), 'gap_pos and xi_iv[0] >= ga and xi_iv[1] <= gb') elif ntag == "POS": alp = parse_hex_float(nt[1]) c = tuple(parse_hex_float(nt[2 + k]) for k in range(7)) require((isfinite(alp) and xi_iv[0] > L and all(rb < xi_iv[0] for _ra, rb in roots)), 'isfinite(alp) and xi_iv[0] > L and all(rb < xi_iv[0] for _ra, rb in roots)') require((verify_poly_on_support(c, segs, 1, xi_iv, L, ga, alp)), 'verify_poly_on_support(c, segs, 1, xi_iv, L, ga, alp)') ub = coupled_ub(c, 1, xi_iv, L, p, roots, all_j, (), alp, m_val) require((isfinite(ub)), 'isfinite(ub)') total_lo = dn(total_lo + dn(wi_iv[0] * exp_bounds(-ub)[0])) elif ntag == "NEG": alp = parse_hex_float(nt[1]) c = tuple(parse_hex_float(nt[2 + k]) for k in range(7)) rem_pos = xi_iv[0] > L mode = 2 if rem_pos else 3 require((isfinite(alp) and verify_poly_on_support(c, segs, mode, xi_iv, L, ga, alp)), 'isfinite(alp) and verify_poly_on_support(c, segs, mode, xi_iv, L, ga, alp)') j_out, j_in = [], [] pf_in_hi = 1.0 for j, (ra, rb) in enumerate(roots): if xi_iv[1] < ra or xi_iv[0] > rb: j_out.append(j) else: j_in.append(j) dm = max( fabs(dn(ra - xi_iv[1])), fabs(up(ra - xi_iv[0])), fabs(dn(rb - xi_iv[1])), fabs(up(rb - xi_iv[0])), ) pf_in_hi = up(pf_in_hi * dm) ub = coupled_ub(c, mode, xi_iv, L, p, roots, j_out, j_in, alp, m_val) loss = up(up(wi_iv[1] * pf_in_hi) * exp_bounds(ub)[1]) require((isfinite(loss)), 'isfinite(loss)') total_lo = dn(total_lo - loss) else: raise ValueError(f"Unknown M_GL8 tag: {ntag}") require((isfinite(total_lo) and total_lo > TARGET), f"C4={c4}: M_GL8 m={m_val} total_lo={total_lo} <= {TARGET}") gap = dn(total_lo - TARGET) if gap < stats["min_gap"]: stats["min_gap"] = gap else: raise ValueError(f"Unknown INTSPLIT tag: {mtag}") stats["intsplit"] += 1 else: raise ValueError(f"Unknown proof-tree tag: {tag}") parse_node(init_roots, init_anchors, init_holes) # Ensure NO trailing unconsumed lines in this subtree! rem_lines = list(it) require((len(rem_lines) == 0), f"C4={c4}: {len(rem_lines)} unconsumed trailing lines!") return c4, stats def verify_single_c4_block(block_lines): hdr = block_lines[0].split() expect_arity(hdr, 2, "C4") require((hdr[0] == "C4"), 'hdr[0] == "C4"') c4 = parse_int(hdr[1]) return verify_subtree_task((c4, [], [], [], block_lines[1:])) def _skip_subtree(lines, pos: int, roots, anchors, holes) -> int: toks = lines[pos].split() tag = toks[0] if tag == "DESCEND_R0": L0 = parse_hex_float(toks[1]) return _skip_subtree(lines, pos + 1, [(4.0, L0)], [None], []) if tag == "SPLIT_ROOT": j = parse_int(toks[1]) mid = parse_hex_float(toks[2]) r1 = list(roots); r1[j] = (roots[j][0], mid) r2 = list(roots); r2[j] = (mid, roots[j][1]) pos = _skip_subtree(lines, pos + 1, r1, anchors, holes) return _skip_subtree(lines, pos, r2, anchors, holes) if tag == "HOLE_OR_HIT": L = parse_hex_float(toks[1]) xi = parse_hex_float(toks[3]) ha = parse_hex_float(toks[4]) hb = parse_hex_float(toks[5]) n_sh = parse_int(toks[6]) shells = [(parse_hex_float(toks[7 + 2 * i]), parse_hex_float(toks[8 + 2 * i])) for i in range(n_sh)] segs = get_support(L, all_holes_of(roots, anchors, holes, L)) pos = _skip_subtree(lines, pos + 1, roots, anchors, holes + [(ha, hb)]) for ua, ub in shells: for ia, ib in shell_intersections(segs, (ua, ub), (ha, hb)): pos = _skip_subtree(lines, pos, roots + [(ia, ib)], anchors + [(xi, ha, hb)], holes) return pos if tag in ("LEAF_POLY", "LEAF_TRIV", "LEAF_FARKAS", "LEAF_INTGAP"): return pos + 1 if tag == "LEAF_GL8": n_gaps = parse_int(toks[5]) require(0 <= n_gaps <= 8, "Invalid parity gap count while partitioning") return pos + 1 + n_gaps + 8 if tag == "LEAF_INTSPLIT": p = pos + 1 for _ in range(13 - len(roots) + 1): mtag = lines[p].split()[0] if mtag == "M_FARKAS": p += 1 elif mtag == "M_GL8": p += 9 else: raise ValueError(f"Unexpected INTSPLIT tag while partitioning: {mtag}") return p raise ValueError(f"Unknown tag while partitioning: {tag}") def partition_block_into_tasks(block_lines, max_split_depth: int = 7): hdr = block_lines[0].split() require((hdr[0] == "C4"), 'hdr[0] == "C4"') c4 = parse_int(hdr[1]) lines = block_lines[1:] if len(lines) <= 40000: return c4, [(c4, [], [], [], lines)] tasks = [] def walk(pos: int, roots, anchors, holes, depth: int) -> int: toks = lines[pos].split() tag = toks[0] if tag == "DESCEND_R0" and depth < max_split_depth: require((len(roots) == 0), 'len(roots) == 0') L0 = parse_hex_float(toks[1]) r_idx = parse_int(toks[2]) require((verify_Lrem(c4, [], [], [], L0, r_idx)), f"C4={c4}: invalid DESCEND_R0 L0={L0}") require((L0 >= 4.0), 'L0 >= 4.0') return walk(pos + 1, [(4.0, L0)], [None], [], depth + 1) if tag == "SPLIT_ROOT" and depth < max_split_depth: j = parse_int(toks[1]) mid = parse_hex_float(toks[2]) require((0 <= j < len(roots) and roots[j][0] < mid < roots[j][1]), '0 <= j < len(roots) and roots[j][0] < mid < roots[j][1]') r1 = list(roots); r1[j] = (roots[j][0], mid) r2 = list(roots); r2[j] = (mid, roots[j][1]) pos = walk(pos + 1, r1, anchors, holes, depth + 1) return walk(pos, r2, anchors, holes, depth + 1) end = _skip_subtree(lines, pos, roots, anchors, holes) tasks.append((c4, roots, anchors, holes, lines[pos:end])) return end final_pos = walk(0, [], [], [], 0) require((final_pos == len(lines)), f"C4={c4}: partition left {len(lines) - final_pos} trailing lines!") return c4, tasks def read_blocks(cert_path, expected): if cert_path.endswith(".xz"): opener = lzma.open elif cert_path.endswith(".gz"): opener = gzip.open else: opener = open blocks = {} current = None with opener(cert_path, "rt", encoding="ascii") as stream: for raw in stream: line = raw.strip() if not line or line.startswith("#"): continue words = line.split() if words[0] == "C4": expect_arity(words, 2, "C4") c4 = parse_int(words[1]) require(c4 in expected, f"Unexpected C4={c4}") require(c4 not in blocks, f"Duplicate C4={c4}") current = blocks[c4] = [line] else: require(current is not None, "Data precedes the first C4 header") check_record(words) current.append(line) require(set(blocks) == expected, f"Missing C4 values: {sorted(expected - set(blocks))}") require(all(len(block) > 1 for block in blocks.values()), "Empty C4 proof tree") return blocks FULL_C4 = frozenset(range(8, 118)) COUNTERS = ("nodes", "farkas", "poly", "triv", "intgap", "gl8", "intsplit") def verify_blocks(blocks, workers): indexed = [(partition_block_into_tasks(block), c4) for c4, block in blocks.items()] all_tasks = [task for (_, tasks), _ in indexed for task in tasks] all_tasks.sort(key=lambda task: len(task[4]), reverse=True) pending = {c4: len(tasks) for (_, tasks), c4 in indexed} totals = {c4: dict.fromkeys(COUNTERS, 0) | {"min_gap": INF} for c4 in blocks} for (_, tasks), c4 in indexed: totals[c4]["nodes"] = sum( record.split()[0] in TREE_TAGS for record in blocks[c4][1:] ) - sum( record.split()[0] in TREE_TAGS for task in tasks for record in task[4] ) print(f"Loaded {len(blocks)} trees, {len(all_tasks)} verification tasks, {workers} workers.", flush=True) with mp.Pool(processes=workers) as pool: for c4, stats in pool.imap_unordered(verify_subtree_task, all_tasks): total = totals[c4] for key in COUNTERS: total[key] += stats[key] total["min_gap"] = min(total["min_gap"], stats["min_gap"]) pending[c4] -= 1 if pending[c4] == 0: gap = total["min_gap"] margin = gap.hex() if isfinite(gap) else "infeasible" leaves = sum(total[key] for key in COUNTERS if key != "nodes") detail = " ".join(f"{key}={total[key]}" for key in COUNTERS[1:]) print(f"C4={c4:3} nodes={total['nodes']} leaves={leaves} {detail} margin={margin}", flush=True) require(not any(pending.values()), "Unfinished verification tasks") return totals def verify_stage_b(cert_path, workers): t0 = time.monotonic() totals = verify_blocks(read_blocks(cert_path, FULL_C4), workers) c4, margin = min(((c4, row["min_gap"]) for c4, row in totals.items()), key=lambda pair: pair[1]) require(isfinite(margin) and margin > 0, "No finite positive global minimum margin") print(f"STRICT CERTIFICATION {len(totals)}/110 trees in {time.monotonic() - t0:.2f}s") print("Certified tree records: " + " ".join( f"{field}={sum(row[field] for row in totals.values())}" for field in COUNTERS)) print(f"Minimum strict margin {margin.hex()} (exact binary64 {margin!r}), at C4={c4}") def main(): parser = argparse.ArgumentParser(description="Strict 110-tree certificate verifier") base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) parser.add_argument("certificate", nargs="?", default=os.path.join(base, "data", "k9_round4_certificate.txt.gz")) parser.add_argument("--workers", type=int, default=min(os.cpu_count() or 1, 32)) args = parser.parse_args() if not 1 <= args.workers <= 32: parser.error("--workers must be between 1 and 32") require(sys.float_info.radix == 2 and sys.float_info.mant_dig == 53 and sys.float_info.max_exp == 1024 and sys.float_info.rounds == 1 and math.ulp(0.0) == float.fromhex("0x0.0000000000001p-1022") and math.ulp(0.0) * 2 != 0.0, "Verifier requires round-to-nearest binary64 with subnormals") verify_stage_a() verify_stage_b(args.certificate, args.workers) if __name__ == "__main__": try: main() except (ValueError, ArithmeticError, OSError, StopIteration, IndexError, RecursionError) as problem: sys.exit(f"REJECTED: {problem}")