EVE-AEQIRION / research /code /verify_legacy.py
PureOne's picture
Release AËQIRION v3.0: manuscript, proofs, code and verification data
8e19377 verified
Raw History Blame Contribute Delete
46.4 kB
#!/usr/bin/env python3
"""AËQIRION II: standalone verification; Python >=3.10, standard library only.
Embedded source modules are also provided separately in the complete package.
Finite checks support explicit mathematical proofs; they do not establish
worldwide novelty, image performance, or peer-reviewed breakthrough status.
"""
import argparse
import contextlib
import hashlib
import io
import json
from pathlib import Path
import re
import sys
import types
SOURCES = {'original': '#!/usr/bin/env python3\n"""EVE-AEQIRION: reproducible verification of finite-dimensional statements.\n\nRequires only Python 3 standard library. Proofs of the all-n and\nperfectoid statements are mathematical; numerical checks do not prove\noriginality or performance on real images.\n"""\n\nfrom itertools import combinations, product\nfrom math import exp, log\nfrom random import Random\n\n\ndef eye(n):\n return [[int(i == j) for j in range(n)] for i in range(n)]\n\n\ndef mul(a, b):\n n = len(a)\n return [[sum(a[i][k] * b[k][j] for k in range(n))\n for j in range(n)] for i in range(n)]\n\n\ndef inv_unipotent(a):\n """(I+N)^-1 = I-N+N^2-... for strictly upper triangular N."""\n n = len(a)\n identity = eye(n)\n neg_n = [[identity[i][j] - a[i][j] for j in range(n)]\n for i in range(n)]\n out = eye(n)\n power = eye(n)\n for _ in range(1, n):\n power = mul(power, neg_n)\n out = [[out[i][j] + power[i][j] for j in range(n)]\n for i in range(n)]\n return out\n\n\ndef comm(a, b):\n return mul(mul(mul(a, b), inv_unipotent(a)), inv_unipotent(b))\n\n\ndef brunnian(n, weights):\n d = n + 1\n matrices = []\n for j, weight in enumerate(weights):\n g = eye(d)\n g[j][j + 1] = weight\n matrices.append(g)\n output = matrices[0]\n for g in matrices[1:]:\n output = comm(output, g)\n return output\n\n\ndef parity_value(bits, parity, delta):\n return 0.0 if (sum(bits) & 1) == parity else -delta\n\n\ndef tropical_marginal(n, subset, kept_values, parity, delta, tau):\n missing = [j for j in range(n) if j not in subset]\n x = [0] * n\n for j, v in zip(subset, kept_values):\n x[j] = v\n vals = []\n for y in product((0, 1), repeat=len(missing)):\n for j, v in zip(missing, y):\n x[j] = v\n vals.append(parity_value(x, parity, delta))\n maximum = max(vals)\n thermal = tau * log(sum(exp(v / tau) for v in vals) / len(vals))\n return maximum, thermal\n\n\ndef tropical_check():\n total = 0\n delta = 3.0\n for n in range(3, 8):\n for k in range(n): # Every proper subset, including the empty one\n for subset in combinations(range(n), k):\n for kept in product((0, 1), repeat=k):\n for tau in (0.25, 1.0):\n m0 = tropical_marginal(n, subset, kept, 0, delta, tau)\n m1 = tropical_marginal(n, subset, kept, 1, delta, tau)\n assert all(abs(a - b) < 1e-12 for a, b in zip(m0, m1))\n analytic = tau * log((1 + exp(-delta / tau)) / 2)\n assert abs(m0[0]) < 1e-12\n assert abs(m0[1] - analytic) < 1e-12\n total += 1\n return total\n\n\ndef v_p(x, p):\n if x == 0:\n return float(\'inf\')\n v = 0\n while x % p == 0:\n x //= p\n v += 1\n return v\n\n\ndef graph_test():\n # [[a,b],c] = a b a^-1 b^-1 c b a b^-1 a^-1 c^-1\n word = \'abABcbaBAC\'\n assert len(word) == 10\n rng = Random(5)\n options = [[(round(rng.uniform(-0.3, 0.8), 3),\n tuple(round(rng.uniform(-1.0, 1.0), 3) for _ in range(3)))\n for _ in range(3)] for _ in word]\n lam = 8.0\n\n def features(path):\n return tuple(sum(options[k][path[k]][1][j] for k in range(len(word)))\n for j in range(3))\n\n def score(path):\n f = features(path)\n return (sum(options[k][path[k]][0] for k in range(len(word)))\n + sum(x * x for x in f) / (2.0 * lam))\n\n path = tuple(max(range(3), key=lambda j: options[i][j][0])\n for i in range(len(word)))\n scores = [score(path)]\n for _ in range(50):\n theta = [x / lam for x in features(path)]\n next_path = tuple(\n max(range(3), key=lambda j:\n options[i][j][0] + sum(theta[k] * options[i][j][1][k]\n for k in range(3)))\n for i in range(len(word)))\n if next_path == path:\n break\n assert score(next_path) > score(path) - 1e-12\n path = next_path\n scores.append(score(path))\n else:\n raise AssertionError(\'Optimizer did not terminate\')\n\n global_best_score = -float(\'inf\')\n for candidate in product(range(3), repeat=len(word)):\n global_best_score = max(global_best_score, score(candidate))\n assert scores[-1] <= global_best_score + 1e-10\n return word, scores, global_best_score\n\n\ndef main():\n print(\'EVE-AEQIRION exact and exhaustive checks\')\n for n in range(3, 8):\n weights = list(range(2, n + 2))\n expected = eye(n + 1)\n value = 1\n for w in weights:\n value *= w\n expected[0][n] = value\n assert brunnian(n, weights) == expected\n for j in range(n):\n deleted = weights.copy()\n deleted[j] = 0\n assert brunnian(n, deleted) == eye(n + 1)\n print(f\'UT({n+1}) triple-and-higher holonomy: PASS, coefficient={value}\')\n\n total = tropical_check()\n print(f\'Proper-subset finite-temperature tropical scans: PASS, {total} comparisons\')\n\n # If v_p(error)>v_p(h), ultrametric cancellation cannot destroy h.\n h, error = 3 * 9 * 2, 3**5\n assert v_p(h, 3) == v_p(h + error, 3) == 3\n print(\'3-adic witness stability: PASS, v3(h)=v3(h+error)=3\')\n\n word, scores, maximum = graph_test()\n print(\'Fixed 10-letter Brunnian scan word:\', word)\n print(\'Monotone finite alternation scores:\', \', \'.join(f\'{s:.5f}\' for s in scores))\n print(\'Exhaustive 3^10-path global optimum:\', f\'{maximum:.5f}\')\n print(\'All checks PASS\')\n\n\nif __name__ == \'__main__\':\n main()\n', 'tomography': '#!/usr/bin/env python3\n"""Independent exact checks of the two-temperature binary reconstruction theorem.\n\nOnly standard-library integers and Fractions are used. S and Q are the\nunnormalized exponential moments corresponding to temperatures tau and tau/2;\nthe logarithms themselves are deliberately not approximated.\n"""\nfrom fractions import Fraction\nfrom itertools import product\nfrom collections import defaultdict, deque\nimport json\nimport random\n\n\ndef parity(x):\n return 1 if x.bit_count() % 2 == 0 else -1\n\n\ndef cube_edges(n):\n return [(x, x ^ (1 << i)) for x in range(1 << n)\n for i in range(n) if x < (x ^ (1 << i))]\n\n\ndef moments(z, edges):\n return ([z[u] + z[v] for u, v in edges],\n [z[u] * z[u] + z[v] * z[v] for u, v in edges])\n\n\ndef canonical_from_sums(n, edges, sums):\n """Tree propagation followed by removal of the parity component."""\n nv = 1 << n\n adj = [[] for _ in range(nv)]\n for k, (u, v) in enumerate(edges):\n adj[u].append((v, k))\n adj[v].append((u, k))\n z0 = [None] * nv\n z0[0] = Fraction(0)\n queue = deque([0])\n while queue:\n u = queue.popleft()\n for v, k in adj[u]:\n value = sums[k] - z0[u]\n if z0[v] is None:\n z0[v] = value\n queue.append(v)\n else:\n assert z0[v] == value, "inconsistent first moments"\n assert all(v is not None for v in z0), "disconnected observation graph"\n coefficient = sum(parity(x) * z0[x] for x in range(nv)) / nv\n return [z0[x] - coefficient * parity(x) for x in range(nv)]\n\n\ndef recover(n, edges, sums, squares):\n z0 = canonical_from_sums(n, edges, sums)\n d = [parity(u) * (z0[u] - z0[v]) for u, v in edges]\n low = min(range(len(edges)), key=lambda i: d[i])\n high = max(range(len(edges)), key=lambda i: d[i])\n gap = d[high] - d[low]\n if gap == 0:\n return None, gap, (low, high), z0\n q0 = [z0[u] ** 2 + z0[v] ** 2 for u, v in edges]\n t = ((squares[high] - squares[low]) -\n (q0[high] - q0[low])) / (2 * gap)\n reconstructed = [z0[x] + t * parity(x) for x in range(1 << n)]\n return reconstructed, gap, (low, high), z0\n\n\ndef is_parity_swap(a, b):\n even = {a[x] for x in range(len(a)) if parity(x) == 1}\n odd = {a[x] for x in range(len(a)) if parity(x) == -1}\n if len(even) != 1 or len(odd) != 1:\n return False\n av, bv = next(iter(even)), next(iter(odd))\n return all(b[x] == (bv if parity(x) == 1 else av)\n for x in range(len(a)))\n\n\ndef check_exhaustive(n, alphabet):\n edges = cube_edges(n)\n groups = defaultdict(list)\n single_groups = defaultdict(list)\n total = 0\n for z in product(alphabet, repeat=1 << n):\n s, q = moments(z, edges)\n groups[(tuple(s), tuple(q))].append(z)\n single_groups[tuple(s)].append(z)\n rec, gap, _, _ = recover(n, edges, list(map(Fraction, s)),\n list(map(Fraction, q)))\n if gap:\n assert rec == list(z)\n else:\n assert len({z[x] for x in range(len(z)) if parity(x) == 1}) == 1\n assert len({z[x] for x in range(len(z)) if parity(x) == -1}) == 1\n total += 1\n ambiguous_groups = 0\n for fiber in groups.values():\n assert len(fiber) <= 2\n if len(fiber) == 2:\n assert is_parity_swap(*fiber)\n ambiguous_groups += 1\n for fiber in single_groups.values():\n a = fiber[0]\n for b in fiber[1:]:\n t = b[0] - a[0]\n assert all(b[x] - a[x] == t * parity(x) for x in range(len(a)))\n return {"dimension": n, "arrays": total, "two_temperature_fibers": len(groups),\n "ambiguous_fibers": ambiguous_groups}\n\n\ndef check_rational_recovery():\n rng = random.Random(24062026)\n cases = noise_cases = two_probe_cases = full_noise_cases = 0\n for n in range(2, 8):\n edges = cube_edges(n)\n for _ in range(12):\n z = [Fraction(rng.randrange(1, 70), rng.randrange(1, 13))\n for _ in range(1 << n)]\n s, q = moments(z, edges)\n rec, gap, (low, high), _ = recover(n, edges, s, q)\n assert gap and rec == z\n cases += 1\n # Adversarial errors attain the claimed epsilon/gap bound exactly.\n epsilon = min(z) * gap / 20\n noisy = list(q)\n noisy[high] += epsilon\n noisy[low] -= epsilon\n perturbed, _, _, _ = recover(n, edges, s, noisy)\n expected = epsilon / gap\n assert max(abs(a - b) for a, b in zip(perturbed, z)) == expected\n assert all(perturbed[x] - z[x] == expected * parity(x)\n for x in range(1 << n))\n assert min(perturbed) > 0\n noise_cases += 1\n # Only the selected two second moments enter the reconstruction.\n sparse_q = [Fraction(-10**9)] * len(q)\n sparse_q[high], sparse_q[low] = q[high], q[low]\n sparse_rec, _, _, _ = recover(n, edges, s, sparse_q)\n assert sparse_rec == z\n two_probe_cases += 1\n # Fully noisy certificate. Build a known canonical perturbation r\n # perpendicular to parity; its compatible sum noise is A r.\n z0 = canonical_from_sums(n, edges, s)\n r = [Fraction(rng.randrange(-3, 4), 1000) for _ in z]\n rmean = sum(parity(x) * r[x] for x in range(len(z))) / len(z)\n r = [r[x] - rmean * parity(x) for x in range(len(z))]\n alpha = max(map(abs, r))\n shat = [s[k] + r[u] + r[v] for k, (u, v) in enumerate(edges)]\n eps = Fraction(1, 10000)\n qhat = [qk + Fraction(rng.randrange(-10, 11), 10) * eps for qk in q]\n noisy_rec, noisy_gap, _, z0hat = recover(n, edges, shat, qhat)\n assert z0hat == [v + dr for v, dr in zip(z0, r)]\n assert noisy_gap > 0\n khat = max(map(abs, z0hat))\n upper = max(z)\n scalar_error_bound = (eps + 4 * khat * alpha + 2 * alpha ** 2\n + 4 * upper * alpha) / noisy_gap\n assert max(abs(a - b) for a, b in zip(noisy_rec, z)) <= (\n alpha + scalar_error_bound)\n assert noisy_gap >= gap - 4 * alpha\n full_noise_cases += 1\n return {"exact_rational_cases": cases, "sharp_noise_bound_cases": noise_cases,\n "two_second_moment_probe_cases": two_probe_cases,\n "fully_noisy_certificate_cases": full_noise_cases}\n\n\ndef check_all_temperature_obstruction():\n checks = 0\n for n in range(2, 7):\n z = [Fraction(2 if parity(x) == 1 else 5) for x in range(1 << n)]\n w = [Fraction(5 if parity(x) == 1 else 2) for x in range(1 << n)]\n for mask in range((1 << n) - 1): # all proper coordinate subsets\n for values in range(1 << n):\n if values & ~mask:\n continue\n selected = [x for x in range(1 << n) if (x & mask) == values]\n for power in range(1, 7):\n assert sum(z[x] ** power for x in selected) == sum(\n w[x] ** power for x in selected)\n checks += 1\n assert z[0] != w[0] # a single labeled point resolves the ambiguity\n return {"exact_power_projection_checks": checks,\n "note": "Finite exact checks illustrate the analytic all-temperature proof."}\n\n\ndef check_graph_cases():\n # Odd cycle: three first moments alone recover all three labels.\n a, b, c = Fraction(2, 3), Fraction(7, 4), Fraction(5, 6)\n s01, s12, s20 = a + b, b + c, c + a\n assert (s01 + s20 - s12) / 2 == a\n assert (s01 + s12 - s20) / 2 == b\n assert (s12 + s20 - s01) / 2 == c\n # Bipartite square: first moments have the alternating null direction.\n square = [(0, 1), (1, 2), (2, 3), (3, 0)]\n z = [Fraction(2), Fraction(3), Fraction(5), Fraction(7)]\n signs = [1, -1, 1, -1]\n t = Fraction(1, 2)\n w = [z[x] + t * signs[x] for x in range(4)]\n s, q = moments(z, square)\n sw, qw = moments(w, square)\n assert s == sw and q != qw\n # An extra same-part chord closes an odd cycle and measures 2t.\n assert (w[0] + w[2]) - (z[0] + z[2]) == 2 * t\n recovered_t = ((w[0] + w[2]) - (z[0] + z[2])) / 2\n assert recovered_t == t\n # Exceptional square: two part-constant values can be swapped.\n za, zb = [2, 5, 2, 5], [5, 2, 5, 2]\n assert moments(za, square) == moments(zb, square)\n return {"triangle_one_temperature": True, "square_null_direction": True,\n "same_part_chord_recovers_hidden_scalar": True,\n "part_constant_swap": True}\n\n\ndef check_tree_adaptation():\n rng = random.Random(882071)\n count = 0\n for n in range(2, 8):\n # Each nonroot vertex connects to the result of deleting its top bit.\n tree = [(x, x ^ (1 << (x.bit_length() - 1)))\n for x in range(1, 1 << n)]\n assert len(tree) == (1 << n) - 1\n for _ in range(12):\n z = [Fraction(rng.randrange(1, 80), rng.randrange(1, 15))\n for _ in range(1 << n)]\n s, q = moments(z, tree)\n rec, gap, (low, high), _ = recover(n, tree, s, q)\n assert gap and rec == z\n # The same two-probe method applies to this N-1-edge first stage.\n sparse_q = [Fraction(-10**9)] * len(tree)\n sparse_q[low], sparse_q[high] = q[low], q[high]\n rec, _, _, _ = recover(n, tree, s, sparse_q)\n assert rec == z\n count += 1\n return {"spanning_tree_plus_two_square_probe_cases": count}\n\n\ndef check_qary_counterexamples():\n checks = 0\n for n in range(2, 5):\n vertices = list(product(range(3), repeat=n))\n # Three distinct cyclic ternary tensors. Every nonempty set of omitted\n # coordinates has exactly equal numbers of all residue completions.\n fields = [[Fraction(2 if sum(x) % 3 == sector else 5) for x in vertices]\n for sector in range(3)]\n assert all(fields[i] != fields[j] for i in range(3) for j in range(i))\n for mask in range((1 << n) - 1):\n retained = [i for i in range(n) if mask & (1 << i)]\n for assignment in product(range(3), repeat=len(retained)):\n selected = [k for k, x in enumerate(vertices)\n if all(x[i] == a for i, a in zip(retained, assignment))]\n for power in range(1, 5):\n sums = [sum(field[k] ** power for k in selected)\n for field in fields]\n assert sums[0] == sums[1] == sums[2]\n checks += 1\n return {"ternary_counterexample_power_projection_checks": checks,\n "dimensions": [2, 3, 4], "distinct_indistinguishable_fields": 3}\n\n\ndef main():\n result = {"status": "passed", "arithmetic": "exact integer/Fraction",\n "exhaustive": [check_exhaustive(2, range(1, 4)),\n check_exhaustive(3, range(1, 3))],\n "reconstruction": check_rational_recovery(),\n "parity_obstruction": check_all_temperature_obstruction(),\n "general_graphs": check_graph_cases(),\n "tree_adaptation": check_tree_adaptation(),\n "qary_counterexamples": check_qary_counterexamples()}\n return result\n\n\nif __name__ == "__main__":\n print(json.dumps(main(), indent=2))\n', 'algebra': '#!/usr/bin/env python3\n"""Exact algebra and calibrated residue tests for AEQIRION v2.\n\nUses only the Python standard library. Numerical checks illustrate statements;\nthe research note supplies proofs. No perfectoid field is numerically emulated:\nthe residue tests take place in Q using exact p-adic valuations.\n"""\nfrom fractions import Fraction as F\nfrom math import inf\nimport json\nimport random\n\n\ndef eye(n):\n return [[F(i == j) for j in range(n)] for i in range(n)]\n\n\ndef elementary(n, i, j, a):\n a0 = eye(n)\n a0[i][j] += F(a)\n return a0\n\n\ndef add(a, b):\n return [[x + y for x, y in zip(ar, br)] for ar, br in zip(a, b)]\n\n\ndef sub(a, b):\n return [[x - y for x, y in zip(ar, br)] for ar, br in zip(a, b)]\n\n\ndef mul(a, b):\n n = len(a)\n return [[sum((a[i][k] * b[k][j] for k in range(n)), F(0))\n for j in range(n)] for i in range(n)]\n\n\ndef inverse_unipotent(a):\n n = len(a)\n neg_n = sub(eye(n), a)\n out = eye(n)\n term = eye(n)\n for _ in range(1, n):\n term = mul(term, neg_n)\n out = add(out, term)\n assert mul(a, out) == eye(n)\n return out\n\n\ndef commutator(a, b):\n return mul(mul(mul(a, b), inverse_unipotent(a)), inverse_unipotent(b))\n\n\ndef product(factors, n):\n out = eye(n)\n for g in factors:\n out = mul(out, g)\n return out\n\n\ndef vp(x, p):\n x = F(x)\n if not x:\n return inf\n num, den = abs(x.numerator), x.denominator\n out = 0\n while num % p == 0:\n num //= p\n out += 1\n while den % p == 0:\n den //= p\n out -= 1\n return out\n\n\ndef matrix_vp(a, p):\n return min(vp(x, p) for row in a for x in row)\n\n\ndef residue_unit(x, p):\n x = F(x)\n assert vp(x, p) == 0\n return x.numerator * pow(x.denominator, -1, p) % p\n\n\ndef power(p, exponent):\n return F(p ** exponent) if exponent >= 0 else F(1, p ** (-exponent))\n\n\ndef run_tests():\n counts = {}\n\n # Exact n-sector identities, all single-sector deletions, and sign loss.\n identity_cases = deletion_cases = valuation_blindness_cases = 0\n for n in range(2, 9):\n for offset in range(5):\n amplitudes = [F((-1) ** (i + offset) * (i + offset + 1), 5)\n for i in range(n)]\n matrices = [elementary(n + 1, i, i + 1, a)\n for i, a in enumerate(amplitudes)]\n out = commutator(matrices[0], matrices[1])\n for g in matrices[2:]:\n out = commutator(out, g)\n coefficient = F(1)\n for a in amplitudes:\n coefficient *= a\n expected = elementary(n + 1, 0, n, coefficient)\n assert out == expected\n identity_cases += 1\n for deleted in range(n):\n modified = list(matrices)\n modified[deleted] = eye(n + 1)\n check = commutator(modified[0], modified[1])\n for g in modified[2:]:\n check = commutator(check, g)\n assert check == eye(n + 1)\n deletion_cases += 1\n negative = elementary(n + 1, 0, n, -coefficient)\n for p in (2, 3, 5, 7):\n assert [[vp(x, p) for x in row] for row in out] == [\n [vp(x, p) for x in row] for row in negative]\n assert out != negative\n valuation_blindness_cases += 1\n counts[\'nested_commutator_identities\'] = identity_cases\n counts[\'single_sector_deletions\'] = deletion_cases\n counts[\'orientation_lost_by_entrywise_valuation\'] = valuation_blindness_cases\n\n # Deleting a sector from the nested word is not the same as all pair loops\n # being trivial. Both adjacent pair commutators survive here.\n a = elementary(4, 0, 1, 2)\n b = elementary(4, 1, 2, 3)\n c = elementary(4, 2, 3, 5)\n assert commutator(a, b) == elementary(4, 0, 2, 6)\n assert commutator(b, c) == elementary(4, 1, 3, 15)\n counts[\'nontrivial_pairwise_commutator_counterexamples\'] = 2\n\n # Calibration and measurement errors strictly smaller than the signal.\n residue_cases = 0\n for p in (3, 5, 7):\n for exponent in range(-4, 5):\n u = power(p, exponent) * F(p + 1, 2 * p + 1)\n for mu in (-1, 1):\n for depth in range(1, 5):\n for noise_unit in range(-3, 4):\n for calibration_unit in (-2, 0, 2):\n e = u * power(p, depth) * noise_unit\n d = u * power(p, depth + 1) * calibration_unit\n y, uhat = mu * u + e, u + d\n assert vp(e, p) > vp(u, p)\n assert vp(d, p) > vp(u, p)\n assert vp(y, p) == vp(uhat, p) == vp(u, p)\n assert residue_unit(y / uhat, p) == mu % p\n residue_cases += 1\n counts[\'calibrated_residue_recovery\'] = residue_cases\n\n # At the boundary, zero is compatible with either sign.\n sharp_boundary_cases = 0\n for p in (3, 5, 7):\n for mu in (-1, 1):\n u = F(9, 25)\n e = -mu * u\n assert mu * u + e == 0 and vp(e, p) == vp(u, p)\n sharp_boundary_cases += 1\n counts[\'strict_threshold_boundary_counterexamples\'] = sharp_boundary_cases\n\n # In residue characteristic 2 the first residue cannot encode +/-1.\n u = F(3, 8)\n y = u\n e_minus = 2 * u\n assert -u + e_minus == y and vp(e_minus, 2) > vp(u, 2)\n assert residue_unit(1, 2) == residue_unit(-1, 2) == 1\n # Extra precision still distinguishes their exact Q2 values.\n assert (1 % 4) != (-1 % 4)\n counts[\'characteristic_two_failure_and_extra_precision\'] = 1\n\n # Exact output cannot identify mu if u itself has an uncalibrated sign.\n assert F(1) * F(6, 25) == F(-1) * F(-6, 25)\n counts[\'uncalibrated_amplitude_gauge_counterexamples\'] = 1\n\n # Ultrametric matrix product errors do not grow with word length when all\n # exact and perturbed factors have max-entry norm <= 1.\n rng = random.Random(3102026)\n product_stability_cases = 0\n for p in (2, 3, 5, 7):\n for length in (1, 2, 10, 31, 128):\n for depth in (1, 2, 4):\n factors, noisy = [], []\n for k in range(length):\n g = elementary(4, k % 3, k % 3 + 1,\n rng.randrange(-5, 6))\n error = [[F(p ** depth * rng.randrange(-2, 3))\n for _ in range(4)] for _ in range(4)]\n gt = add(g, error)\n assert matrix_vp(g, p) >= 0 and matrix_vp(gt, p) >= 0\n assert matrix_vp(sub(gt, g), p) >= depth\n factors.append(g)\n noisy.append(gt)\n error_out = sub(product(noisy, 4), product(factors, 4))\n assert matrix_vp(error_out, p) >= depth\n product_stability_cases += 1\n counts[\'integral_matrix_product_stability\'] = product_stability_cases\n\n # End-to-end: noisy factors of the actual ten-letter sensor word, then\n # central-entry extraction and normalized residue decoding. The sign is\n # placed in a fixed label representation; amplitudes stay calibrated.\n end_to_end_cases = 0\n for p in (3, 5, 7):\n a0, b0, c0 = p, p + 1, 2\n u = F(a0 * b0 * c0)\n for mu in (-1, 1):\n ga = elementary(4, 0, 1, mu * a0)\n gb = elementary(4, 1, 2, b0)\n gc = elementary(4, 2, 3, c0)\n gai, gbi, gci = map(inverse_unipotent, (ga, gb, gc))\n factors = [ga, gb, gai, gbi, gc, gb, ga, gbi, gai, gci]\n assert product(factors, 4) == elementary(4, 0, 3, mu * u)\n for depth in (1, 2, 4):\n precision = int(vp(u, p)) + depth\n for repeat in range(4):\n noisy = [add(g, [[F(p ** precision * rng.randrange(-2, 3))\n for _ in range(4)] for _ in range(4)])\n for g in factors]\n measured = product(noisy, 4)[0][3]\n calibration_error = u * p ** depth * (repeat - 2)\n calibrated = u + calibration_error\n assert vp(measured - mu * u, p) >= precision > vp(u, p)\n assert vp(calibration_error, p) > vp(u, p)\n assert residue_unit(measured / calibrated, p) == mu % p\n end_to_end_cases += 1\n counts[\'end_to_end_noisy_sensor_word_residue_decoding\'] = end_to_end_cases\n\n # A ring with zero divisors permits all ai != 0 but product ai == 0.\n # The polynomial commutator identity remains valid modulo 6.\n amps = (2, 3, 5)\n assert all(x % 6 != 0 for x in amps)\n out = commutator(commutator(elementary(4, 0, 1, amps[0]),\n elementary(4, 1, 2, amps[1])),\n elementary(4, 2, 3, amps[2]))\n reduced = [[int(x) % 6 for x in row] for row in out]\n assert reduced == [[int(x) % 6 for x in row] for row in eye(4)]\n counts[\'nonzero_factors_zero_product_mod6\'] = 1\n\n # A fixed symbolic word preserves the output only for a fixed label map.\n # If inverse occurrences do not use inverse matrices, even B=C=I can\n # leave a first-order coefficient.\n factors = [elementary(4, 0, 1, 2), eye(4),\n elementary(4, 0, 1, -1), eye(4), eye(4), eye(4),\n elementary(4, 0, 1, 1), eye(4),\n elementary(4, 0, 1, -1), eye(4)]\n assert product(factors, 4) == elementary(4, 0, 1, 1)\n counts[\'varying_letter_amplitude_counterexamples\'] = 1\n\n # Exponential literal length of the particular left-nested construction.\n word = (\'a\', \'b\', \'A\', \'B\')\n def inverse_word(w):\n return tuple(s.swapcase() for s in reversed(w))\n for n in range(2, 10):\n assert len(word) == 3 * 2 ** (n - 1) - 2\n if n < 9:\n letter = chr(ord(\'a\') + n)\n word = word + (letter,) + inverse_word(word) + (letter.upper(),)\n counts[\'literal_left_nested_word_lengths\'] = 8\n\n # Balanced commutators are an established construction (Gartside and\n # Greenwood, Brunnian links, Fund. Math. 193 (2007), 259-276). They are\n # included as an efficiency correction, not as a novelty claim.\n def balanced_word(lo, hi):\n if hi - lo == 1:\n return (lo + 1,)\n mid = (lo + hi) // 2\n wl, wr = balanced_word(lo, mid), balanced_word(mid, hi)\n return wl + wr + tuple(-j for j in reversed(wl)) + tuple(\n -j for j in reversed(wr))\n\n def balanced_matrix(gs, lo, hi):\n if hi - lo == 1:\n return gs[lo]\n mid = (lo + hi) // 2\n return commutator(balanced_matrix(gs, lo, mid),\n balanced_matrix(gs, mid, hi))\n\n balanced_identity_cases = balanced_deletion_cases = 0\n balanced_literal_evaluations = balanced_lengths = 0\n for n in range(2, 17):\n bw = balanced_word(0, n)\n k = n.bit_length() - 1\n assert len(bw) == 3 * 2 ** k * n - 2 ** (2 * k + 1)\n if n & (n - 1) == 0:\n assert len(bw) == n * n\n balanced_lengths += 1\n if n <= 9:\n amps = [F((-1) ** i * (i + 2), 5) for i in range(n)]\n gs = [elementary(n + 1, i, i + 1, x)\n for i, x in enumerate(amps)]\n coefficient = F(1)\n for x in amps:\n coefficient *= x\n expected = elementary(n + 1, 0, n, coefficient)\n assert balanced_matrix(gs, 0, n) == expected\n balanced_identity_cases += 1\n literal_factors = [elementary(n + 1, abs(j) - 1, abs(j),\n amps[abs(j) - 1] * (1 if j > 0 else -1))\n for j in bw]\n assert product(literal_factors, n + 1) == expected\n balanced_literal_evaluations += 1\n for deleted in range(n):\n modified = list(gs)\n modified[deleted] = eye(n + 1)\n assert balanced_matrix(modified, 0, n) == eye(n + 1)\n balanced_deletion_cases += 1\n counts[\'balanced_commutator_monomial_identities\'] = balanced_identity_cases\n counts[\'balanced_commutator_sector_deletions\'] = balanced_deletion_cases\n counts[\'balanced_literal_word_matrix_evaluations\'] = balanced_literal_evaluations\n counts[\'balanced_literal_word_lengths\'] = balanced_lengths\n\n return {\n \'status\': \'PASS\',\n \'arithmetic\': \'exact integers and fractions; no numerical perfectoid simulation\',\n \'counts\': counts,\n \'total_cases\': sum(counts.values()),\n \'limitations\': [\n \'Finite examples support the supplied proofs; they are not proofs of novelty.\',\n \'Residue tests use Qp-valuations on rational numbers, not a Cp implementation.\',\n \'The product stability theorem assumes integral matrix factors.\',\n \'Orientation recovery requires a calibrated nonzero monomial amplitude.\'\n ]\n }\n\n\nif __name__ == \'__main__\':\n print(json.dumps(run_tests(), indent=2, sort_keys=True))\n', 'paths': '#!/usr/bin/env python3\n"""Exact finite checks for the AEQIRION continuous-feature path certificate.\n\nRun with Python >=3.10; standard library only. All optimization and bound\ncomparisons use Fraction, including the real-feature examples (rational inputs).\nThis verifies finite cases, not the general theorem\'s proof or empirical utility.\n"""\nfrom __future__ import annotations\n\nfrom dataclasses import dataclass\nfrom fractions import Fraction as F\nfrom itertools import product\nimport json\nimport random\n\n\nWORD = ("a", "b", "A", "B", "c", "b", "a", "B", "A", "C")\n\n\n@dataclass(frozen=True)\nclass Edge:\n source: int\n target: int\n label: str\n base: F\n feature: tuple[F, ...]\n\n\n@dataclass(frozen=True)\nclass Path:\n edges: tuple[int, ...]\n base: F\n feature: tuple[F, ...]\n\n\ndef dot(x, y):\n return sum((a * b for a, b in zip(x, y)), F(0))\n\n\ndef objective(path, lam, bonus):\n return path.base + bonus + dot(path.feature, path.feature) / (2 * lam)\n\n\ndef make_graph(seed, rational=False):\n """Ten-layer multigraph: every accepting path has exactly WORD as spelling.\n\n Geometric route choices change base/features; generator matrices are fixed\n per label, which is the assumption required for preserved word holonomy.\n """\n rng = random.Random(seed)\n edges = []\n for k, label in enumerate(WORD):\n for _ in range(2):\n base = F(rng.randint(-10, 12), 7)\n feature = tuple(F(rng.randint(-3, 3), 3 if rational else 1)\n for _ in range(2))\n edges.append(Edge(k, k + 1, label, base, feature))\n return edges\n\n\ndef extend(path, edge_id, edge):\n return Path(path.edges + (edge_id,), path.base + edge.base,\n tuple(a + b for a, b in zip(path.feature, edge.feature)))\n\n\ndef additive_oracle(edges, word, theta, base_weight=F(1), bonus=F(0)):\n """Product-graph DP. State (vertex, DFA state), finite length <=len(word).\n\n The DFA recognizes the literal word, not all group-equivalent spellings.\n The terminal bonus is constant on this accepting class. General class\n rewards require the class to be included in the automaton state.\n """\n d = len(theta)\n states = {(0, 0): (F(0), Path((), F(0), (F(0),) * d))}\n for _ in range(len(word)):\n following = {}\n for (vertex, q), (value, path) in states.items():\n for edge_id, edge in enumerate(edges):\n if edge.source != vertex or q == len(word) or edge.label != word[q]:\n continue\n new_path = extend(path, edge_id, edge)\n score = value + base_weight * edge.base + dot(theta, edge.feature)\n key = (edge.target, q + 1)\n if key not in following or score > following[key][0]:\n following[key] = (score, new_path)\n states = following\n accepted = [(score + bonus, path) for (v, q), (score, path) in states.items()\n if v == len(word) and q == len(word)]\n assert accepted, "No admissible accepting path"\n return max(accepted, key=lambda item: item[0])\n\n\ndef exhaustive_paths(edges, word):\n """Independent enumeration for this layered test family."""\n stages = [[i for i, e in enumerate(edges)\n if e.source == k and e.target == k + 1 and e.label == word[k]]\n for k in range(len(word))]\n d = len(edges[0].feature)\n out = []\n for ids in product(*stages):\n base = sum((edges[i].base for i in ids), F(0))\n phi = tuple(sum((edges[i].feature[j] for i in ids), F(0)) for j in range(d))\n out.append(Path(ids, base, phi))\n return out\n\n\ndef augmented_exact_dp(edges, word, lam, bonus):\n """Retain best base at each exact feature sum: original integer-state DP.\n\n Our integer tests have the original pseudo-polynomial grid interpretation.\n The same dictionary code remains exact on rational tests, but that does not\n imply the original integer-grid running-time bound for arbitrary reals.\n """\n d = len(edges[0].feature)\n zero = (F(0),) * d\n states = {(0, 0, zero): Path((), F(0), zero)}\n for _ in range(len(word)):\n following = {}\n for (vertex, q, _), path in states.items():\n for i, edge in enumerate(edges):\n if edge.source != vertex or q == len(word) or edge.label != word[q]:\n continue\n new_path = extend(path, i, edge)\n key = (edge.target, q + 1, new_path.feature)\n if key not in following or new_path.base > following[key].base:\n following[key] = new_path\n states = following\n candidates = [path for (v, q, _), path in states.items()\n if v == len(word) and q == len(word)]\n return max(candidates, key=lambda p: objective(p, lam, bonus))\n\n\ndef feature_bound(edges, word):\n """Compute H=max_{P,j}|Phi_j(P)| by 2d ordinary additive DP calls."""\n d = len(edges[0].feature)\n extrema = []\n for j in range(d):\n for sign in (-1, 1):\n theta = tuple(F(sign if i == j else 0) for i in range(d))\n score, _ = additive_oracle(edges, word, theta, base_weight=F(0))\n extrema.append(score)\n return max(extrema)\n\n\ndef certified_grid(edges, word, lam, bonus, cells_per_axis):\n """A finite cover of all Phi(P)/lambda gives an exact rational certificate.\n\n For each cube center c, query p_c=max_P J(P,c). If its cell has Euclidean\n squared radius r^2, every path with Phi(P)/lambda in that cell satisfies\n R(P)<=J(p_c,c)+lambda*r^2/2. Values J include the quadratic weight penalty.\n """\n d = len(edges[0].feature)\n h = feature_bound(edges, word)\n if h == 0:\n _, path = additive_oracle(edges, word, (F(0),) * d, bonus=bonus)\n value = objective(path, lam, bonus)\n return value, value, F(0), 1\n k = cells_per_axis\n radius_squared = d * (h / (lam * k)) ** 2\n error_bound = lam * radius_squared / 2\n centers = [h * F(2 * i + 1 - k, k) / lam for i in range(k)]\n lower = None\n upper = None\n for center in product(centers, repeat=d):\n linear_value, path = additive_oracle(edges, word, center, bonus=bonus)\n j_value = linear_value - lam * dot(center, center) / 2\n value = objective(path, lam, bonus)\n upper_cell = j_value + error_bound\n lower = value if lower is None else max(lower, value)\n upper = upper_cell if upper is None else max(upper, upper_cell)\n assert lower <= upper\n assert upper - lower <= error_bound\n return lower, upper, error_bound, k ** d\n\n\ndef alternating(edges, word, lam, bonus):\n """Strict-improvement alternating method with deterministic oracle ties."""\n _, current = additive_oracle(edges, word, (F(0),) * len(edges[0].feature), bonus=bonus)\n history = [objective(current, lam, bonus)]\n visited = {current.edges}\n while True:\n theta = tuple(x / lam for x in current.feature)\n score, proposed = additive_oracle(edges, word, theta, bonus=bonus)\n old_score = current.base + bonus + dot(theta, current.feature)\n if score <= old_score:\n break\n current = proposed\n value = objective(current, lam, bonus)\n assert value > history[-1]\n assert current.edges not in visited\n visited.add(current.edges)\n history.append(value)\n return current, history\n\n\ndef run():\n lam, bonus = F(3, 2), F(2, 5)\n report = {"arithmetic": "exact fractions; no floating-point comparisons", "cases": []}\n for seed in range(4):\n rational = bool(seed % 2)\n edges = make_graph(seed, rational)\n paths = exhaustive_paths(edges, WORD)\n optimum = max(objective(path, lam, bonus) for path in paths)\n for theta in ((F(0), F(0)), (F(1, 3), F(-2, 7)), (F(-5), F(4))):\n got, _ = additive_oracle(edges, WORD, theta, bonus=bonus)\n expected = max(p.base + bonus + dot(theta, p.feature) for p in paths)\n assert got == expected\n augmented = augmented_exact_dp(edges, WORD, lam, bonus)\n assert objective(augmented, lam, bonus) == optimum\n assert feature_bound(edges, WORD) == max(abs(x) for p in paths for x in p.feature)\n _, history = alternating(edges, WORD, lam, bonus)\n certificates = []\n for cells in (1, 2, 4, 8):\n lo, hi, bound, calls = certified_grid(edges, WORD, lam, bonus, cells)\n assert lo <= optimum <= hi\n assert optimum - lo <= bound\n certificates.append({"cells_per_axis": cells, "oracle_queries": calls,\n "lower": str(lo), "upper": str(hi),\n "actual_optimality_gap": str(optimum - lo),\n "certified_gap": str(hi - lo),\n "uniform_error_bound": str(bound)})\n report["cases"].append({"seed": seed, "rational_features": rational,\n "enumerated_paths": len(paths),\n "global_optimum": str(optimum),\n "augmented_dp_exact_match": True,\n "alternating_scores": [str(x) for x in history],\n "certificates": certificates})\n # An arbitrarily bad stationary path, even in d=1 with nonnegative bases.\n trap_edges = [Edge(0, 1, "a", F(1), (F(0),)),\n Edge(0, 1, "a", F(0), (F(10),))]\n trap_path, trap_history = alternating(trap_edges, ("a",), F(1), F(0))\n trap_optimum = max(objective(p, F(1), F(0))\n for p in exhaustive_paths(trap_edges, ("a",)))\n assert trap_history == [F(1)] and trap_optimum == 50\n report["arbitrarily_bad_local_trap"] = {\n "parameter_T": 10, "alternating_value": "1", "global_value": "50",\n "general_ratio": "2/T^2 for T>sqrt(2)",\n "strict_updates_terminate": True}\n # Verify the Max-Cut embedding on small instances. The proof of NP-hardness\n # is the general incidence-matrix reduction, not these finite checks.\n report["maxcut_embedding"] = []\n for n, pairs in ((3, [(0, 1), (1, 2), (0, 2)]),\n (4, [(0, 1), (1, 2), (2, 3), (3, 0), (0, 2)])):\n reduced_edges = []\n for vertex in range(n):\n row = tuple(F((1 if vertex == u else 0) - (1 if vertex == v else 0))\n for u, v in pairs)\n for sign in (-1, 1):\n reduced_edges.append(Edge(vertex, vertex + 1, "a", F(0),\n tuple(sign * x for x in row)))\n reduced_paths = exhaustive_paths(reduced_edges, ("a",) * n)\n for path in reduced_paths:\n signs = [(-1, 1)[i % 2] for i in path.edges]\n cut = sum(signs[u] != signs[v] for u, v in pairs)\n assert objective(path, F(2), F(0)) == cut\n best_cut = max(objective(p, F(2), F(0)) for p in reduced_paths)\n report["maxcut_embedding"].append({"vertices": n, "edges": len(pairs),\n "all_cuts_checked": 2 ** n,\n "maximum_cut": str(best_cut)})\n report["status"] = "PASS"\n return report\n\n\nif __name__ == "__main__":\n print(json.dumps(run(), indent=2))\n'}
def evaluate(key, entry):
source = SOURCES[key]
name = '_aeqirion_embedded_' + key
module = types.ModuleType(name)
module.__file__ = '<embedded:' + key + '>'
sys.modules[name] = module
captured = io.StringIO()
with contextlib.redirect_stdout(captured):
exec(compile(source, module.__file__, 'exec'), module.__dict__)
result = getattr(module, entry)()
return result, captured.getvalue()
def main():
if sys.version_info < (3, 10):
raise SystemExit('Python 3.10 or newer is required.')
if not __debug__:
raise SystemExit('Assertions must be enabled: do not use Python -O.')
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--report', type=Path,
default=Path(__file__).resolve().with_name('verification_report.json'))
args = parser.parse_args()
_, original_stdout = evaluate('original', 'main')
original_count = int(re.search(r'(\d+) comparisons', original_stdout).group(1))
assert 'All checks PASS' in original_stdout
tomography, _ = evaluate('tomography', 'main')
algebra, _ = evaluate('algebra', 'run_tests')
paths, _ = evaluate('paths', 'run')
for result in (tomography, algebra, paths):
assert result['status'].lower() in ('pass', 'passed')
report = {
'project': 'EVE-AEQIRION II',
'version': '2.0',
'audit_date': '2026-10-20',
'status': 'PASS',
'python': sys.version.split()[0],
'embedded_source_sha256': {
name: hashlib.sha256(source.encode()).hexdigest()
for name, source in SOURCES.items()
},
'original_reproduction': {
'status': 'PASS', 'projection_comparisons': original_count,
'stdout': original_stdout,
'arithmetic': 'integer matrices and floating-point projection/graph examples'
},
'two_temperature': tomography,
'algebra_and_residue': algebra,
'certified_paths': paths,
'scope': {
'finite_checks': 'passed',
'general_theorems': 'proofs in research note; not established by finite enumeration',
'perfectoid_simulation': False,
'image_or_AI_benchmark': False,
'priority_established': False,
'external_peer_review': False
}
}
args.report.parent.mkdir(parents=True, exist_ok=True)
args.report.write_text(json.dumps(report, indent=2, sort_keys=True) + '\n')
tensors = sum(case['arrays'] for case in tomography['exhaustive'])
path_count = sum(case['enumerated_paths'] for case in paths['cases'])
intervals = sum(len(case['certificates']) for case in paths['cases'])
print('AËQIRION II verification: PASS')
print(f'Original projections reproduced: {original_count:,}')
print(f'Exhaustive binary tensors: {tensors:,}')
print(f'Exact algebra/residue cases: {algebra["total_cases"]:,}')
print(f'Exhaustive graph paths: {path_count:,}; certified intervals: {intervals}')
print(f'Report: {args.report}')
print('Finite verification does not establish novelty or real-image performance.')
if __name__ == '__main__':
main()