#!/usr/bin/env python3 """Independent check of the T_37 twin-tile census and its fold against the pruned closed form. Route 52, seventh rung. Run from the directory holding the three served inputs: python3 check-t37.py -> exit 0 and a final line "RESULT: ALL CHECKS PASS" Inputs (same directory): tc31.json T_31 census (byte-identical to the values served with return #1816) tc37.json T_37 census, instrument tcensus.c (served: see the return's manifest) rho37.json T_37 closed form, instrument rhoie.c, classes g = 6 .. 432 completed Nothing here reuses the C instruments' code: cop_x(g) = prod_{q<=x} (q - #distinct (-o) mod q), o in {0,2,g,g+2}, is recomputed in Python with its own primality test. Exact integer arithmetic throughout; no floating point enters a pass/fail. Self-inflicted error disclosed: an earlier draft compared N_6 - N_12 instead of D - N_6 when forming D(12), which yields C_6 - C_12 = 1,575,551,250; the corrected form is checked below. """ import json import os import sys sys.stdout.reconfigure(newline="\n", encoding="utf-8", errors="replace") HERE = os.path.dirname(os.path.abspath(__file__)) PREREG = {"D": 217929355875, "G2": 528, "N6": 15597957375, "D12": 945330750} FOLDS = [(29, 31, "tc29.json", "tc31.json"), (31, 37, "tc31.json", "tc37.json")] fails = [] def primes_upto(x): out = [] for n in range(2, x + 1): if all(n % d for d in range(2, int(n ** 0.5) + 1)): out.append(n) return out def cop_product(x, g): v = 1 for q in primes_upto(x): v *= q - len({(-o) % q for o in (0, 2, g, g + 2)}) return v def chk(name, ok, detail=""): print((" PASS " if ok else " FAIL ") + name + (" " + str(detail) if detail else "")) if not ok: fails.append(name) def load(name): return json.load(open(os.path.join(HERE, name), encoding="utf-8")) def census(d): return {int(k): v for k, v in d["census"].items()} def main() -> int: t31, t37 = load("tc31.json"), load("tc37.json") N31, N37 = census(t31), census(t37) cm37 = {int(k): v for k, v in t37["cop_measured"].items()} blank = load("rho37.json") cl = {int(k): v for k, v in blank["classes"].items()} print("== Q1 totals at T_37 ==") chk("D(T_37) = 35 * D(T_31) = pre-registered", t37["D"] == PREREG["D"] == 35 * t31["D"], f"{t37['D']}") chk("G2(T_37) = 528 = A144311(12)+1", t37["G2"] == PREREG["G2"], t37["G2"]) chk("sum_g N_g = D", sum(N37.values()) == t37["D"], sum(N37.values())) chk("N_6(T_37) = 33 * N_6(T_31) = prod_{5<=q<=37}(q-4)", N37[6] == PREREG["N6"] == 33 * N31[6], f"{N37[6]}") d12 = (t37["D"] - N37[6]) - 35 * (t31["D"] - N31[6]) c6 = N37[6] - 35 * N31[6] chk("D(12) = 2 N_6(T_31) = -C_6 = pre-registered", d12 == PREREG["D12"] == -c6, f"{d12} = -C_6 = {-c6}") chk("no class above G2 carries a gap", all(N37.get(g, 0) == 0 for g in range(t37["G2"] + 6, t37["GMAX"] + 1, 6)), f"g = {t37['G2'] + 6}..{t37['GMAX']}") print("== Q2 product structure (Python CRT product, independent of the C instruments) ==") cmp_g = [g for g in sorted(cm37) if g <= t37["G2"]] bad = [g for g in cmp_g if cm37[g] != cop_product(37, g)] chk("cop_measured(g) = product for every class g <= G2", not bad, f"{len(cmp_g)} classes compared, mismatches {len(bad)} {bad[:5]}") print("== Q3 closure N_g = cop(g) - rho_ie(g) ==") comp = sorted(g for g, v in cl.items() if v.get("rho_ie") is not None) bad = [(g, cop_product(37, g) - cl[g]["rho_ie"], N37.get(g, 0)) for g in comp if cop_product(37, g) - cl[g]["rho_ie"] != N37.get(g, 0)] chk("closure holds wherever rho_ie was evaluated", not bad, f"{len(comp)} classes, g = {comp[0]}..{comp[-1]}, mismatches {len(bad)} {bad[:4]}") cover = [g for g in range(6, t37["G2"] + 1, 6) if g not in comp] print(" INFO covered to g = %d of G2 = %d; not evaluated: %s" % (max(comp), t37["G2"], cover)) print("== Q4 the fold: C_g = N_g(T_37) - 35 N_g(T_31) ==") classes = list(range(6, t37["GMAX"] + 1, 6)) C = {g: N37.get(g, 0) - 35 * N31.get(g, 0) for g in classes} neg = [g for g in classes if C[g] < 0] chk("negative classes are exactly {6,12,18,24,30,36}; K = 6", neg == [6, 12, 18, 24, 30, 36], neg) chk("C_6 = -2 N_6(T_31)", C[6] == -2 * N31[6], f"{C[6]}") chk("first positive class is 42", next((g for g in classes if C[g] > 0), None) == 42, C[42]) chk("sum_g C_g = 0", sum(C.values()) == 0, sum(C.values())) print("== Q6 non-existent classes below G2, and the K series ==") nonex = [g for g in classes if g <= t37["G2"] and N37.get(g, 0) == 0] print(" T_37:", nonex) chk("T_31 has exactly the recorded non-existent classes {324, 336, 342}", [g for g in classes if g <= t31["G2"] and N31.get(g, 0) == 0] == [324, 336, 342]) for p, q, fp, fq in FOLDS: Np, Nq = census(load(fp)), census(load(fq)) nn = [g for g in classes if Nq.get(g, 0) - (q - 2) * Np.get(g, 0) < 0] chk(f"T_{p} -> T_{q}: negative classes {{6..36}}, K = 6", nn == [6, 12, 18, 24, 30, 36], f"K = {len(nn)}") print() print("RESULT:", "ALL CHECKS PASS" if not fails else "FAILURES: %s" % fails) return 1 if fails else 0 if __name__ == "__main__": raise SystemExit(main())