#!/usr/bin/env python3 """Triage of route 89 (job #2059): does the cutoff family's transfer pad stay bounded? Extends job2050's measurement to x = 2^21, 2^22 (and 2^23 if the clock allows) on a DYADIC chain D = {1,2,4,8,16,32} at V = 32 and its midpoint refinement, and reports the two numbers the consumer's allowance 2x/25 = 0.08x actually needs: Vx = sum|increments|/x and Mx = max|member|/x. Falsifiers: job2059/PREREG-2059.md, written before this run. The family(), the controls and the window identity come from job2050/window_increments.py, unchanged. """ import json import math import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) RUN = os.path.join(HERE, "..") sys.path.insert(0, os.path.join(RUN, "job2050")) from window_increments import family # noqa: E402 D = [1, 2, 4, 8, 16, 32] D_REF = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32] V = 32 LADDER = [21, 22, 23] ALLOWANCE = 0.08 def ols(xs, ys): n = len(xs) mx = sum(xs) / n my = sum(ys) / n sxx = sum((x - mx) ** 2 for x in xs) sxy = sum((x - mx) * (y - my) for x, y in zip(xs, ys)) slope = sxy / sxx resid = [y - (my + slope * (x - mx)) for x, y in zip(xs, ys)] sse = sum(r * r for r in resid) se = math.sqrt(sse / (n - 2) / sxx) if n > 2 else float("nan") return slope, se def main(): prev = json.load(open(os.path.join(RUN, "job2050", "window-increments.json"))) pts = [(r["j"], r["G_sum_abs_inc_over_max_member"]) for r in prev["rows"]] vx_pts = [(r["j"], sum(abs(v) for v in r["increments_over_x"])) for r in prev["rows"]] rows = [] for j in LADDER: x = 2 ** j r = family(x, D, V) r2 = family(x, D_REF, V) inc = r["increments_over_x"] Vx = sum(abs(v) for v in inc) row = { "j": j, "V": V, "chain": D, "refined_chain": D_REF, "G": r["G_sum_abs_inc_over_max_member"], "G_ref": r2["G_sum_abs_inc_over_max_member"], "G_refine_ratio": (r2["G_sum_abs_inc_over_max_member"] / r["G_sum_abs_inc_over_max_member"] if r["G_sum_abs_inc_over_max_member"] else None), "Vx_sum_abs_increments_over_x": Vx, "Vx_ref": sum(abs(v) for v in r2["increments_over_x"]), "Mx_max_member_over_x": r["max_member_over_x"], "Vx_over_Mx": Vx / r["max_member_over_x"] if r["max_member_over_x"] else None, "Vx_over_allowance": Vx / ALLOWANCE, "members_over_x": r["members_over_x"], "increments_over_x": inc, "signed_sum_over_x": sum(inc), "signed_over_abs": (abs(sum(inc)) / Vx if Vx else None), "sign_changes": r["sign_changes"], "invariant_spread_over_x": r["invariant_spread_over_x"], "invariant_matches_free_side": r["invariant_matches_free_side"], "mu_identity_violations": r["mu_identity_violations"], "window_identity_resid_rel": r["window_identity_resid_rel"], "surviving_pairs": r["surviving_pairs"], } rows.append(row) pts.append((j, row["G"])) vx_pts.append((j, Vx)) print(json.dumps({k: row[k] for k in ("j", "G", "G_ref", "G_refine_ratio", "Vx_sum_abs_increments_over_x", "Vx_over_allowance", "Mx_max_member_over_x", "sign_changes", "invariant_matches_free_side", "mu_identity_violations", "window_identity_resid_rel", "surviving_pairs")}), flush=True) # H1: trend of ln G on ln x over all twelve points (nine from #1097 plus these) slope_G, se_G = ols([math.log(j) for j, _ in pts], [math.log(g) for _, g in pts]) slope_V, se_V = ols([math.log(j) for j, _ in vx_pts], [math.log(v) for _, v in vx_pts]) out = { "rows": rows, "prev_points": pts[:len(prev["rows"])], "slope_lnG_on_lnx": slope_G, "se_slope_lnG": se_G, "slope_lnVx_on_lnx": slope_V, "se_slope_lnVx": se_V, "H1_refuted_slope_ge_0.5": slope_G >= 0.5, "H1_supports_slope_lt_0.2": slope_G < 0.2, "H2_variation_exceeds_allowance_and_does_not_shrink": ( all(r["Vx_sum_abs_increments_over_x"] >= ALLOWANCE for r in rows) and slope_V >= 0), "allowance_2x_over_25": ALLOWANCE, } with open(os.path.join(HERE, "ladder-ext.json"), "w") as fh: json.dump(out, fh, indent=1) print(json.dumps({k: out[k] for k in ("slope_lnG_on_lnx", "se_slope_lnG", "slope_lnVx_on_lnx", "se_slope_lnVx", "H1_refuted_slope_ge_0.5", "H1_supports_slope_lt_0.2", "H2_variation_exceeds_allowance_and_does_not_shrink")}, indent=1)) if __name__ == "__main__": main()