#!/usr/bin/env python3 """Sympy check of the route-157 base-cutoff arithmetic (research/0025). Claim under test (proven): for the H1 <= 216 candidate parameters A = 2583/10000, eps_s = 3/400, delta = 3/250, the source's Appendix-B premise `u - d < ell` fails, because u - delta - ell = 2 eps_s - delta = 3/1000 > 0, while for the source's own k = 48 parameters u = 2605/10000, ell = 2455/10000, d = 182/10000 it holds with u - d - ell = -32/10000 < 0. """ from __future__ import annotations import sympy as sp A = sp.Rational(2583, 10000) eps_s = sp.Rational(3, 400) delta = sp.Rational(3, 250) u = A + eps_s ell = A - eps_s U_SRC = sp.Rational(2605, 10000) ELL_SRC = sp.Rational(2455, 10000) D_SRC = sp.Rational(182, 10000) def main(): ok = True def check(name, cond): nonlocal ok ok &= bool(cond) print(f" {name}: {cond}") print("candidate (k = 46, H1 <= 216)") check("u = 1329/5000", sp.simplify(u - sp.Rational(1329, 5000)) == 0) check("ell = 627/2500", sp.simplify(ell - sp.Rational(627, 2500)) == 0) check("u - delta - ell = 3/1000", sp.simplify(u - delta - ell - sp.Rational(3, 1000)) == 0) check("2 eps_s - delta = 3/1000", sp.simplify(2 * eps_s - delta - sp.Rational(3, 1000)) == 0) check("u - delta > ell", sp.simplify((u - delta) - ell) > 0) print("source (eprint 2026/1893 Appendix B)") check("u - d - ell = -32/10000", sp.simplify(U_SRC - D_SRC - ELL_SRC + sp.Rational(32, 10000)) == 0) check("u - d < ell", sp.simplify((U_SRC - D_SRC) - ELL_SRC) < 0) print("cap constants in the engine normalisation u = t/A") check("delta/A = 40/861", sp.simplify(delta / A - sp.Rational(40, 861)) == 0) check("(3/20)/A = 500/861", sp.simplify(sp.Rational(3, 20) / A - sp.Rational(500, 861)) == 0) check("(4/25)/A = 1600/2583", sp.simplify(sp.Rational(4, 25) / A - sp.Rational(1600, 2583)) == 0) check("2 eps_s/A = 50/861", sp.simplify(2 * eps_s / A - sp.Rational(50, 861)) == 0) check("1/A = 10000/2583", sp.simplify(1 / A - sp.Rational(10000, 2583)) == 0) print("ALL PASS" if ok else "FAILURES PRESENT") return 0 if ok else 1 if __name__ == "__main__": raise SystemExit(main())