|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""Independent check of PR #4599 (petalas): four binary full-guard events lie below the product of their marginals. |
| 3 | +
|
| 4 | +Setting (#4599): U_1..U_4 pairwise orthogonal rank-one idempotents on F_2^m (normalized U_t = e_t e_t^T), P_t = I - U_t, |
| 5 | +G uniform on GL_m(F_2); E_t: every leading principal minor of G P_t G^-1 of orders 1..m-1 is nonzero. #4599 claims |
| 6 | +Pr(E_1..E_4) < s_m^4 with s_m = 3^n/((2^m - 1) 2^n), n = m - 1, for all m >= 4, via a spectral bound for m >= 85 |
| 7 | +and exact comparisons for 4 <= m <= 84. |
| 8 | +
|
| 9 | +Independent route (no #4275 character law, no #4227 marginal formula, nothing imported from #4599): |
| 10 | + * the order-j minor of G P_t G^-1 = I - g_t h_t^T is 1 - sum_{i<=j} h_t[i] g_t[i] (g_t column t of G, h_t row t |
| 11 | + of G^-1); |
| 12 | + * for k requests, passing headers are counted through the first k columns X and first k rows Y of G^-1: pairs with |
| 13 | + Y X = sum_i y_i x_i^T = I_k whose first m-1 prefix sums have zero diagonal; each such pair extends to exactly |
| 14 | + |GL_{m-k}| headers (the remaining columns are an ordered basis of ker Y); |
| 15 | + * the ordered sequences are counted exactly by a dynamic programme over zero-diagonal k x k matrices, each step |
| 16 | + weighted by the number of factor pairs (y, x) with disjoint supports. |
| 17 | +This gives Pr(E_1) and Pr(E_1..E_4) for every 4 <= m <= 85 as exact fractions. The verifier then |
| 18 | + * checks Pr(E_1) = s_m (independently confirming the marginal law) and Pr(E_1..E_4) < Pr(E_1)^4 for every m; |
| 19 | + * compares the direct joint count with the signed spectrum printed in #4599 PROOF.md (transcribed) at every m; |
| 20 | + * re-checks the integer constants of section 3 of #4599 (m >= 85) from that table; |
| 21 | + * anchors the reformulation by brute force from the leading-minor definition over GL_3 and GL_4. |
| 22 | +Ryanson Jonathan with Claude Code (Claude Opus 5.5) assistance. Apache-2.0. |
| 23 | +""" |
| 24 | +from collections import Counter |
| 25 | +from fractions import Fraction |
| 26 | +from itertools import product |
| 27 | +import json |
| 28 | +import sys |
| 29 | + |
| 30 | +M_MAX = 85 |
| 31 | +# #4599 PROOF.md section 2: z -> signed multiplicity b_z of N_n = sum_z b_z z^n (transcribed, cited). |
| 32 | +SPECTRUM = {81: 1, 63: -12, 57: 24, 55: -8, 51: -24, 49: 18, 47: -48, 45: 118, 43: -68, 41: 85, 39: -180, |
| 33 | + 37: 228, 35: -336, 33: 399, 31: -444, 29: 502, 27: -548, 25: 523, 23: -332, 21: 144, 19: -48, 17: 6} |
| 34 | + |
| 35 | + |
| 36 | +def need(condition, message): |
| 37 | + if not condition: |
| 38 | + raise AssertionError(message) |
| 39 | + |
| 40 | + |
| 41 | +def gl_order(n): |
| 42 | + out = 1 |
| 43 | + for i in range(n): |
| 44 | + out *= 2 ** n - 2 ** i |
| 45 | + return out |
| 46 | + |
| 47 | + |
| 48 | +def outer(y, x, k): |
| 49 | + return sum(1 << (k * a + b) for a in range(k) if y >> a & 1 for b in range(k) if x >> b & 1) |
| 50 | + |
| 51 | + |
| 52 | +def pass_probabilities(k, m_max): |
| 53 | + """{m: Pr(all k events)} for k <= m <= m_max, by the zero-diagonal prefix DP.""" |
| 54 | + zero_diag, anything = Counter(), Counter() |
| 55 | + for y, x in product(range(1 << k), repeat=2): |
| 56 | + r = outer(y, x, k) |
| 57 | + anything[r] += 1 |
| 58 | + if y & x == 0: |
| 59 | + zero_diag[r] += 1 |
| 60 | + ident = sum(1 << (k * a + a) for a in range(k)) |
| 61 | + state, out = Counter({0: 1}), {} |
| 62 | + for m in range(1, m_max + 1): |
| 63 | + if m >= k: |
| 64 | + pairs = sum(w * anything.get(s ^ ident, 0) for s, w in state.items()) |
| 65 | + out[m] = Fraction(pairs * gl_order(m - k), gl_order(m)) |
| 66 | + nxt = Counter() |
| 67 | + for s, ws in state.items(): |
| 68 | + for r, wr in zero_diag.items(): |
| 69 | + nxt[s ^ r] += ws * wr |
| 70 | + state = nxt |
| 71 | + return out |
| 72 | + |
| 73 | + |
| 74 | +def mat_mul(a, b, n): |
| 75 | + return [[sum(a[i][l] & b[l][j] for l in range(n)) & 1 for j in range(n)] for i in range(n)] |
| 76 | + |
| 77 | + |
| 78 | +def inverse(a, n): |
| 79 | + m = [row[:] + [int(i == j) for j in range(n)] for i, row in enumerate(a)] |
| 80 | + for c in range(n): |
| 81 | + p = next((r for r in range(c, n) if m[r][c]), None) |
| 82 | + if p is None: |
| 83 | + return None |
| 84 | + m[c], m[p] = m[p], m[c] |
| 85 | + for r in range(n): |
| 86 | + if r != c and m[r][c]: |
| 87 | + m[r] = [u ^ v for u, v in zip(m[r], m[c])] |
| 88 | + return [row[n:] for row in m] |
| 89 | + |
| 90 | + |
| 91 | +def guards_pass(a, n): |
| 92 | + """Leading principal minors of orders 1..n-1 nonzero, by elimination without pivoting.""" |
| 93 | + m = [row[:] for row in a] |
| 94 | + for c in range(n - 1): |
| 95 | + if not m[c][c]: |
| 96 | + return False |
| 97 | + for r in range(c + 1, n): |
| 98 | + if m[r][c]: |
| 99 | + m[r] = [u ^ v for u, v in zip(m[r], m[c])] |
| 100 | + return True |
| 101 | + |
| 102 | + |
| 103 | +def brute_force(n, k): |
| 104 | + """Exact (Pr(E_1), Pr(E_1..E_k)) over GL_n from the leading-minor definition.""" |
| 105 | + reqs = [[[int(i == j) ^ (i == t and j == t) for j in range(n)] for i in range(n)] for t in range(k)] |
| 106 | + one = joint = total = 0 |
| 107 | + for bits in range(1 << (n * n)): |
| 108 | + g = [[bits >> (n * i + j) & 1 for j in range(n)] for i in range(n)] |
| 109 | + gi = inverse(g, n) |
| 110 | + if gi is None: |
| 111 | + continue |
| 112 | + total += 1 |
| 113 | + ok = [guards_pass(mat_mul(mat_mul(g, p, n), gi, n), n) for p in reqs] |
| 114 | + one += ok[0] |
| 115 | + joint += all(ok) |
| 116 | + return Fraction(one, total), Fraction(joint, total) |
| 117 | + |
| 118 | + |
| 119 | +def spectral_joint(m, spectrum): |
| 120 | + n, x = m - 1, 2 ** m |
| 121 | + s = Fraction(3 ** n, (x - 1) * 2 ** n) |
| 122 | + big_n = sum(b * z ** n for z, b in spectrum.items()) |
| 123 | + h = Fraction((x - 1) ** 3, (x - 2) * (x - 4) * (x - 8)) |
| 124 | + return Fraction(big_n, 81 ** n) * h * s ** 4 |
| 125 | + |
| 126 | + |
| 127 | +def main(): |
| 128 | + marg, joint = pass_probabilities(1, M_MAX), pass_probabilities(4, M_MAX) |
| 129 | + rows = [] |
| 130 | + for m in range(4, M_MAX + 1): |
| 131 | + n = m - 1 |
| 132 | + need(marg[m] == Fraction(3 ** n, (2 ** m - 1) * 2 ** n), "marginal law s_m at m=%d" % m) |
| 133 | + need(joint[m] < marg[m] ** 4, "product inequality at m=%d" % m) |
| 134 | + need(joint[m] == spectral_joint(m, SPECTRUM), "#4599 spectrum table vs direct count at m=%d" % m) |
| 135 | + rows.append((m, joint[m] / marg[m] ** 4)) |
| 136 | + need(joint[4] == 0 and joint[5] == Fraction(1, 208320) and marg[5] == Fraction(81, 496), "m = 4, 5 values") |
| 137 | + deficit = {m: (1 - rho) / Fraction(7, 9) ** (m - 1) for m, rho in rows} |
| 138 | + # 12 - deficit is dominated by the next base: |12 - d_m| <= 4083 (57/63)^n + O(2^-n) correction |
| 139 | + need(all(abs(deficit[m] - 12) < 4100 * Fraction(57, 63) ** (m - 1) + 20 * Fraction(9, 14) ** (m - 1) |
| 140 | + for m in range(40, M_MAX + 1)), "(1 - rho_m)/(7/9)^n approaches 12") |
| 141 | + tail = sum(abs(b) for z, b in SPECTRUM.items() if z < 63) |
| 142 | + need(tail == 4083 and max(z for z in SPECTRUM if z < 63) == 57, "|R_n| <= 4083 * 57^n") |
| 143 | + need(4083 * 57 ** 84 < 63 ** 84 and 9 * 9 ** 84 < 14 ** 84 and 11 * 7 ** 84 < 9 ** 84 and 11 * 512 < 18 * 315, |
| 144 | + "section 3 integer inequalities") |
| 145 | + need(all((x - 1) ** 3 - (x - 2) * (x - 4) * (x - 8) == 11 * x * x - 53 * x + 63 for x in range(1, 200)), |
| 146 | + "H numerator minus denominator") |
| 147 | + for n_, k_ in ((3, 1), (3, 3), (4, 1), (4, 4)): |
| 148 | + p1, pk = brute_force(n_, k_) |
| 149 | + need(p1 == pass_probabilities(1, n_)[n_] and pk == pass_probabilities(k_, n_)[n_], |
| 150 | + "brute force GL_%d, k=%d" % (n_, k_)) |
| 151 | + mutated = dict(SPECTRUM) |
| 152 | + mutated[17] += 1 |
| 153 | + need(any(joint[m] != spectral_joint(m, mutated) for m in range(4, M_MAX + 1)), |
| 154 | + "failure control: a one-unit table change is detected") |
| 155 | + print(json.dumps({"status": "PASS_PR4599_INDEPENDENT_CHECK", |
| 156 | + "dimensions_checked": [4, M_MAX], "marginal_equals_s_m": True, |
| 157 | + "joint_below_product_all_m": True, "spectrum_table_matches_direct_count_all_m": True, |
| 158 | + "m5": {"joint": str(joint[5]), "marginal": str(marg[5])}, |
| 159 | + "rho": {str(m): "%.12f" % float(r) for m, r in rows if m in (5, 6, 8, 12, 20, 40, 85)}, |
| 160 | + "deficit_ratio": {str(m): "%.6f" % float(deficit[m]) for m in (20, 40, 85)}, |
| 161 | + "section3_constants": True, "brute_force_GL3_GL4": True, "new_kappa_claimed": False}, indent=1)) |
| 162 | + |
| 163 | + |
| 164 | +if __name__ == "__main__": |
| 165 | + sys.exit(main()) |
0 commit comments