#!/usr/bin/env python3 # Job #1437 (explore, triage of route 32) - the smallest experiment on the route's uncovered step. # # THE ROUTE'S CENTRAL UNCERTAINTY, restated exactly: is the fixed-translate surcharge a # polylog at all, or is the measured exponent 1.886 a finite-size drift of the 17 matched # levels? Route 32's own declared falsifier: if the top-end slope exceeds about 2.5 while # the bottom-end slope sits below 2, the polylog shape is refuted and the surcharge lemma is # dead. This script runs exactly that split, plus the non-overlapping variant, plus the same # split for the translate price, and it must reproduce return #647's full-range numbers or it # reports a control failure rather than a result. # # Inputs are published OEIS terms already cited in return #647: A144311 (fixed, the record's # own object; 22 terms, recorded as PROVEN maximal), A048670 (one-class g; 58 terms), # A288815 (free paired h2; 21 terms). No published count is regenerated here. # # Invocation: python check-1437.py --out check-1437.out.json import argparse import json import math import sys FIXED = [1, 5, 11, 29, 41, 65, 107, 149, 203, 257, 347, 527, 545, 617, 707, 869, 965, 1079, 1283, 1397, 1529, 1709] FREE = [2, 6, 18, 30, 66, 150, 192, 258, 366, 450, 570, 708, 894, 1044, 1284, 1422, 1656, 1902, 2190, 2460, 2622] ONE = [2, 4, 6, 10, 14, 22, 26, 34, 40, 46, 58, 66, 74, 90, 100, 106, 118, 132, 152, 174, 190, 200, 216, 234, 258, 264, 282, 300, 312, 330, 354, 378, 388, 414, 432, 450, 476, 492, 510, 538, 550, 574, 600, 616, 642, 660, 686, 718, 742, 762, 798, 810, 834, 858, 876, 908, 926, 954] def primes_upto(n): s = bytearray([1]) * (n + 1) s[0:2] = b"\x00\x00" for i in range(2, int(n ** 0.5) + 1): if s[i]: s[i * i::i] = bytearray(len(range(i * i, n + 1, i))) return [i for i in range(n + 1) if s[i]] def ols(xs, ys): n = len(xs) mx, my = sum(xs) / n, sum(ys) / n sxx = sum((x - mx) ** 2 for x in xs) if sxx == 0: return None b = sum((x - mx) * (y - my) for x, y in zip(xs, ys)) / sxx a = my - b * mx s2 = sum((y - (a + b * x)) ** 2 for x, y in zip(xs, ys)) / (n - 2) return {"factor": round(math.exp(a), 4), "slope": round(b, 4), "slope_se": round((s2 / sxx) ** 0.5, 4), "n": n} def fit(rows, fn): xs = [math.log(math.log(r[1])) for r in rows] ys = [math.log(fn(r)) for r in rows] f = ols(xs, ys) if f: f["two_sigma_band"] = [round(f["slope"] - 2 * f["slope_se"], 4), round(f["slope"] + 2 * f["slope_se"], 4)] return f def two_point(rows, fn): n0, p0 = rows[0][0], rows[0][1] n1, p1 = rows[-1][0], rows[-1][1] return {"from_n": n0, "to_n": n1, "slope": round((math.log(fn(rows[-1])) - math.log(fn(rows[0]))) / (math.log(math.log(p1)) - math.log(math.log(p0))), 4)} def main(): ap = argparse.ArgumentParser() ap.add_argument("--out", required=True) a = ap.parse_args() P = primes_upto(600) out = {"checks": [], "failures": []} def check(name, ok, observed, expected=None, note=None): rec = {"check": name, "ok": bool(ok), "observed": observed} if expected is not None: rec["expected"] = expected if note: rec["note"] = note out["checks"].append(rec) if not ok: out["failures"].append(name) matched = [(i + 1, P[i], FIXED[i] + 1, ONE[i], FREE[i]) for i in range(4, 21)] # n = 5..21 L7 = lambda r: r[2] / r[3] # G2 / g PRICE = lambda r: r[4] / r[2] # h2 / G2 # ---- controls: the frame and the full-range fit must reproduce return #647 exactly c_free = {P[i]: FREE[i] / (P[i] * math.log(P[i]) ** 2) for i in range(len(FREE))} check("A frame control: h2/(p ln^2 p) = 1.04 at x=11 and 1.95 at x=73 (as in #647)", round(c_free[11], 2) == 1.04 and round(c_free[73], 2) == 1.95, [round(c_free[11], 4), round(c_free[73], 4)], [1.04, 1.95]) full = fit(matched, L7) check("B regression control: the full-range fit reproduces #647's 1.8861 +/- 0.1091", abs(full["slope"] - 1.8861) < 5e-4 and abs(full["slope_se"] - 0.1091) < 5e-4, full, {"slope": 1.8861, "slope_se": 0.1091}) full_price = fit(matched, PRICE) check("C regression control: the full-range price fit reproduces #647's -0.1358 +/- 0.1391", abs(full_price["slope"] + 0.1358) < 5e-4 and abs(full_price["slope_se"] - 0.1391) < 5e-4, full_price, {"slope": -0.1358, "slope_se": 0.1391}) # ---- the experiment: end-restricted refits of the L7 surcharge bottom9 = matched[:9] # n = 5..13 top9 = matched[-9:] # n = 13..21 (overlapping, as route 32 specified) bottom8 = matched[:8] # n = 5..12 top8 = matched[-8:] # n = 14..21 (non-overlapping) out["l7_splits"] = { "bottom9_n5_13": fit(bottom9, L7), "top9_n13_21": fit(top9, L7), "bottom8_n5_12": fit(bottom8, L7), "top8_n14_21": fit(top8, L7), "full": full, "two_point_ends": two_point(matched, L7), "ratio_endpoints": [round(L7(matched[0]), 4), round(L7(matched[-1]), 4)], } out["price_splits"] = { "bottom9_n5_13": fit(bottom9, PRICE), "top9_n13_21": fit(top9, PRICE), "bottom8_n5_12": fit(bottom8, PRICE), "top8_n14_21": fit(top8, PRICE), "full": full_price, "two_point_ends": two_point(matched, PRICE), } s = out["l7_splits"] b, t = s["bottom9_n5_13"], s["top9_n13_21"] b8, t8 = s["bottom8_n5_12"], s["top8_n14_21"] disjoint = lambda u, v: (u["two_sigma_band"][1] < v["two_sigma_band"][0] or v["two_sigma_band"][1] < u["two_sigma_band"][0]) straddle = lambda u, v: u["slope"] > 2 > v["slope"] out["verdict_inputs"] = { "declared_falsifier": "top-end slope > 2.5 while bottom-end slope < 2", "top_slope": t["slope"], "bottom_slope": b["slope"], "top_band": t["two_sigma_band"], "bottom_band": b["two_sigma_band"], "bands_overlap": not disjoint(b, t), "falsifier_fires": bool(t["slope"] > 2.5 and b["slope"] < 2), "observed_direction": "bottom (small p) steeper than top (large p)", "single_power_law_rejected_overlapping_split": disjoint(b, t), "split_robust": bool(straddle(b8, t8)), "rejection_robust_to_split": bool(disjoint(b, t) and disjoint(b8, t8)), } check("D the declared falsifier does NOT fire (top slope not > 2.5 with bottom < 2)", not out["verdict_inputs"]["falsifier_fires"], out["verdict_inputs"], "no fire") # E was drafted as "both end-restricted fits are below 2" and FAILED on its own output: # the bottom-end slope is 2.266, above 2. That draft asserted the author's expectation, # not the data. The claim the data supports is directional, and it is the OPPOSITE of # the falsifier's shape: the small-p end is the steep one. check("E the two end-restricted slopes straddle 2 in the direction OPPOSITE the " "falsifier's shape: bottom (small p) > 2 > top (large p)", straddle(b, t), {"bottom": b["slope"], "top": t["slope"], "bottom_band_lower_edge": b["two_sigma_band"][0]}, "bottom > 2 > top") check("F the split choice does not create the result: the non-overlapping variant " "(n=5..12 vs n=14..21) straddles 2 the same way", straddle(b8, t8), {"bottom8": b8["slope"], "top8": t8["slope"]}, "bottom > 2 > top") check("G the overlapping split's two end 2-sigma bands are DISJOINT, so in that split a " "single power law does not fit the matched range", disjoint(b, t), {"bottom9": b["two_sigma_band"], "top9": t["two_sigma_band"]}, "disjoint") check("H the non-overlapping (8 vs 8) split's bands OVERLAP slightly -- recorded as the " "margin: the model-adequacy rejection is NOT robust to the split, even though the " "direction is, so G is reported as split-dependent and not as a settled rejection", disjoint(b8, t8) == False, # noqa: E712 - the observation, stated as a check {"bottom8": b8["two_sigma_band"], "top8": t8["two_sigma_band"], "overlap_width": round(min(b8["two_sigma_band"][1], t8["two_sigma_band"][1]) - max(b8["two_sigma_band"][0], t8["two_sigma_band"][0]), 4)}, "overlapping") check("I the full-range slope lies strictly between the two end slopes (consistency of " "the reported decomposition, recorded either way)", t["slope"] < s["full"]["slope"] < b["slope"], {"top": t["slope"], "full": s["full"]["slope"], "bottom": b["slope"]}, "top < full < bottom") pb, pt = out["price_splits"]["bottom9_n5_13"], out["price_splits"]["top9_n13_21"] pb8, pt8 = out["price_splits"]["bottom8_n5_12"], out["price_splits"]["top8_n14_21"] zero_in = lambda r: r["two_sigma_band"][0] <= 0 <= r["two_sigma_band"][1] check("J the price's constant reading survives end-restriction in BOTH split variants: " "all four end bands contain slope 0", all(zero_in(r) for r in (pb, pt, pb8, pt8)), {"bottom9": pb["two_sigma_band"], "top9": pt["two_sigma_band"], "bottom8": pb8["two_sigma_band"], "top8": pt8["two_sigma_band"]}, "all four contain 0") out["summary"] = {"checks": len(out["checks"]), "failures": len(out["failures"]), "ok": not out["failures"]} with open(a.out, "w", encoding="utf-8", newline="\n") as fh: fh.write(json.dumps(out, indent=1, sort_keys=True)) print("check-1437: %d checks, %d failures -> %s" % (out["summary"]["checks"], out["summary"]["failures"], a.out)) return 0 if not out["failures"] else 1 if __name__ == "__main__": sys.exit(main())