#!/usr/bin/env python3 """Job #4460 -- route 36 step check (first look, lane formalize). Decides whether the returns on record answer the next experiment set by return #1787 on route 36 (the level-theta pricing / the theta = 1 marginal test). Stdlib only; deterministic; stdout is the check list as JSON. Nothing here runs the step's experiment: it re-reads the served record, re-evaluates the served instrument's stated equations to audit the record's numbers, and proves two structural reductions used to narrow the step. """ import hashlib import json import os import re import sys HERE = os.path.dirname(os.path.abspath(__file__)) def _workspace_root(start): d = start for _ in range(8): if os.path.isdir(os.path.join(d, ".solveathome")): return d d = os.path.dirname(d) raise RuntimeError("workspace root not found above " + start) ROOT = _workspace_root(HERE) SERVED = os.path.join(HERE, "served") # the promoted instrument is shipped beside this checker; fall back to the library sys.path.insert(0, os.path.join(ROOT, ".solveathome", "private", "lib", "sieves")) sys.path.insert(0, HERE) import rosser_iwaniec as ri # noqa: E402 CHECKS = [] def check(cid, desc, expected, observed, ok): CHECKS.append({"id": cid, "desc": desc, "expected": expected, "observed": observed, "pass": bool(ok)}) def load(name): """Parse a served JSON payload; a missing or malformed file becomes {} so the checks report the loss instead of the instrument crashing on it.""" try: return json.load(open(os.path.join(SERVED, name), encoding="utf-8")) except (OSError, ValueError): return {} def text(name): try: return open(os.path.join(SERVED, name), encoding="utf-8").read() except OSError: return "" def sha256_file(path, crlf_normalise=False): d = open(path, "rb").read() if crlf_normalise: d = d.replace(b"\r\n", b"\n") return hashlib.sha256(d).hexdigest() def main(): route = load("route-36.json") route = route.get("body", route) pg = load("f1787_parity_gate.json") note = text("f101_fold-arithmetic-bridge.md") ret101 = load("return-101.json") ret659 = load("return-659.json") ret661 = load("return-661.json") ret1787 = load("return-1787.json") ret1978 = load("return-1978.json") f1978 = load("f1978_step36_findings.json") f659 = text("return-659.json") f661 = text("return-661.json") f1787pa = text("f1787_job1457-prior-art.json") env = ri.evaluate(per_unit=4000, u_max=16.0) at = env["at"] # ---------------- C1 step identity / route state ---------------- step = route.get("next_step", {}) or {} step_head = (step.get("method") or "")[:120] check("C1.step_head", "route 36's next_step is the route-36 step this brief names", "re-derive each pricing input at level theta", step_head, step_head.lower().startswith("(a) re-derive each pricing input")) events = [(e.get("return_id"), e.get("outcome")) for e in route.get("events", [])] check("C2.route_state", "current route record state/revision/last return/events", {"state": "active", "revision": 4, "last_return_id": "1978", "events": _EXPECTED_EVENTS}, {"state": route.get("state"), "revision": route.get("revision"), "last_return_id": route.get("last_return_id"), "events": events, "next_job_id": route.get("next_job_id")}, route.get("state") == "active" and route.get("revision") == 4 and route.get("last_return_id") == "1978" and events == _EXPECTED_EVENTS) check("C2b.next_job", "route 36 has no next job issued (the step is held, not handed out)", None, route.get("next_job_id"), bool(route) and route.get("next_job_id") is None) # ---------------- C3 served attachment hashes ------------------- mism = [] nfiles = 0 for rid, d in (("1787", ret1787), ("101", ret101), ("1978", ret1978)): for f in d.get("body", d).get("files") or []: nfiles += 1 p = os.path.join(SERVED, "f%s_%s" % (rid, f["name"])) if not os.path.exists(p): mism.append((rid, f["name"], "missing")) continue if sha256_file(p, True) != f["sha256"]: mism.append((rid, f["name"], "mismatch")) check("C3.attachment_sha", "every served attachment re-read matches the sha256 the return publishes " "(CRLF->LF normalised: the /files/ endpoint hands back CRLF)", "11 files, 0 problems", {"files": nfiles, "problems": mism}, nfiles == 11 and not mism) # ---------------- C4 c_eff(theta) on record -------------------- g3 = pg.get("G3_contamination_constant", {}) check("C4.c_eff_theta", "#1787 sec. 2 fixes c_eff(theta) = min_s sF_1(s)e^-gamma/theta = 2/theta " "(4 at theta=1/2, 2 at theta=1); the note's Proposition 4 is the theta=1/2 case", {"min_s_sF_e^-g": 2.0, "c_eff(1/2)": 4.0, "c_eff(1)": 2.0}, {"min_s_sF_e^-g": g3.get("min_s_sF(s)e^-g"), "c_eff(1/2)": g3.get("c_eff(theta=1/2)"), "c_eff(1)": g3.get("c_eff(theta=1)")}, abs(g3.get("min_s_sF(s)e^-g", 0.0) - 2.0) < 1e-9 and abs(g3.get("c_eff(theta=1/2)", 0.0) - 4.0) < 1e-9 and abs(g3.get("c_eff(theta=1)", 0.0) - 2.0) < 1e-9) # ---------------- C5 independent re-evaluation ---------------- rows5s = [r for r in (pg.get("T_rows") or []) if abs(r.get("u", 0.0) - 5.0) < 1e-9] rows5 = rows5s[0] if rows5s else {} # the note's own (half-level) c*_real at u = 5, rebuilt from its definition half5 = at(env["f"], 2.5) ** 2 * at(env["rho_odd"], 5.0) / (at(env["rho_odd"], 5.0) - 1.0) dev = { "rho_odd-1@5": abs((at(env["rho_odd"], 5.0) - 1.0) - rows5.get("rho_odd-1", 0.0)), "sigma2@5": abs(at(env["sigma2"], 5.0) - rows5.get("sigma2(u)", 0.0)), "note_cstar_halflevel@5": abs(half5 - rows5.get("c*_real(F2=1)", 0.0)), "theta1_value@5": abs(ri.theta_ratio(env, 1.0, 5.0, "one")[0] - 3.450333083704239), } t2 = pg.get("T2_level_theta_test", {}) def t2get(key, field, default=0.0): return (t2.get(key) or {}).get(field, default) p1 = ri.theta_profile(env, 1.0, "one") p1s = ri.theta_profile(env, 1.0, "sigma2") dev["theta1_max_F2_1"] = abs(p1["max_ratio"] - t2get("theta=1.0,F2=1", "max_ratio_to_c_eff")) dev["theta1_max_F2_sigma2"] = abs(p1s["max_ratio"] - t2get( "theta=1.0,F2=1/sigma2", "max_ratio_to_c_eff")) dev["theta_half_max_F2_sigma2"] = abs( ri.theta_profile(env, 0.5, "sigma2")["max_ratio"] - t2get("theta=0.5,F2=1/sigma2", "max_ratio_to_c_eff")) check("C5.reproduce_published", "an independent evaluation of the same delay equations reproduces #1787's " "published scalars (max abs deviation)", "< 1e-9 on every pinned scalar", dev, max(dev.values()) < 1e-9) # ---------------- C6 Proposition 3 is level-1/2 only ----------- prop3 = note[note.find("**Proposition 3.**"):note.find("**Proposition 3.**") + 700] has_half = "sqrt x/(\\log x)^B" in prop3 or "sqrt x" in prop3 scan = {"note_prop3_has_sqrt_x": has_half, "note_prop3_mentions_level_one": bool( re.search(r"level X\^?\(?1-\\?epsilon", prop3))} check("C6.prop3_level", "the note's Proposition 3 states BV for k-fold rough products at " "Q = sqrt(x)/(log x)^B (level X^(1/2-eps)) only; no level-1 analogue is stated", {"sqrt_x_level": True, "level_one_in_prop3": False}, scan, scan["note_prop3_has_sqrt_x"] and not scan["note_prop3_mentions_level_one"]) # ---------------- C7 the S bound's direction ------------------ # F_2 >= 1 and the ratio is decreasing in F_2, so F_2 = 1 is the most # favourable admissible S bound at every theta. best_theta_half = t2get("theta=0.5,F2=1", "max_ratio_to_c_eff", -1.0) best_theta_34 = t2get("theta=0.75,F2=1", "max_ratio_to_c_eff", -1.0) monotone = (best_theta_half < best_theta_34 < p1["max_ratio"]) check("C7.S_bound_direction", "at theta = 1/2 the test fails even at the most favourable admissible S " "bound (F_2 = 1), so the theta = 1/2 null does not depend on the S input; " "the max ratio is increasing in theta", {"theta=1/2,F2=1 max": "< 1 (fails)", "theta=3/4 < theta=1": True}, {"theta=1/2,F2=1": best_theta_half, "theta=3/4,F2=1": best_theta_34, "theta=1,F2=1": p1["max_ratio"], "monotone_in_theta": monotone}, best_theta_half < 1.0 and monotone) # ---------------- C8 f_1 monotonicity lemma -------------------- st = ri.structure_checks(env) check("C8.f1_floor_lemma", "(s f_1)' = F_1(s-1) >= 1 - f_1(s) gives f_1 nondecreasing on [2,inf), so " "f_1(u) >= f_1(4) = 2e^gamma log 3/4 for u >= 4 (verified on the grid; the " "closed form solves the delay system by sympy)", {"f_nondecreasing": True, "F_nonincreasing": True, "f_max": "<= 1", "f1(4)": ri.f1_floor()}, {"f_nondecreasing": st["f_nondecreasing"], "F_nonincreasing": st["F_nonincreasing"], "f_max": st["f_max"], "f1(4)": ri.f1_floor()}, st["f_nondecreasing"] and st["F_nonincreasing"] and st["f_max"] <= 1.0 + 1e-6) # ---------------- C9 the closed-form reduction ----------------- thr = ri.reduction_threshold() red = {"D3_threshold": thr, "R1_lower_bound_at_u5_F2_1": ri.reduction_ub(env, 5.0, "one"), "R1_lower_bound_at_u5_F2_sigma2": ri.reduction_ub(env, 5.0, "sigma2"), "region_end_F2_1": ri.reduction_region_end(env, "one", 4.0, 8.0), "region_end_F2_sigma2": ri.reduction_region_end(env, "sigma2", 4.0, 8.0)} check("C9.closed_form_reduction", "rho_odd - 1 >= D_3(u) and f_1(u) >= f_1(4) give, with no delay-recursion " "enclosure, R_1(u) >= f_1(4)^2 (1 + 1/D_3(u)) [x sigma_2(u)] > 2 for " "D_3(u) < f_1(4)^2/(2 - f_1(4)^2); u = 5 passes with 66% / 19% margin", {"D3_threshold": 0.9178702626000474, "u5_F2_1": "> 2", "u5_F2_sigma2": "> 2", "region_end_F2_1 ~ 6.85": True}, red, red["R1_lower_bound_at_u5_F2_1"] > 2.0 and red["R1_lower_bound_at_u5_F2_sigma2"] > 2.0 and abs(red["D3_threshold"] - 0.9178702626000474) < 1e-9) # ---------------- C10 the tight cell is NOT u ~ 4.00025 ------- tight = { "F2_1": {"max_at_u": p1["max_at_u"], "max_ratio": p1["max_ratio"], "tight_u": p1["min_at_u"], "tight_ratio": p1["min_ratio_in_passing"]}, "F2_sigma2": {"max_at_u": p1s["max_at_u"], "max_ratio": p1s["max_ratio"], "tight_u": p1s["min_at_u"], "tight_ratio": p1s["min_ratio_in_passing"]}, "prior_note_margin_figure": (t2get("theta=1.0,F2=1/sigma2", "max_ratio_to_c_eff") / 2.0) - 1.0, } ok10 = (abs(tight["F2_1"]["tight_ratio"] - 1.0) < 1e-4 and abs(tight["F2_sigma2"]["tight_ratio"] - 1.0) < 1e-4 and tight["F2_1"]["tight_u"] > tight["F2_1"]["max_at_u"] and abs(tight["prior_note_margin_figure"] - 0.01518) < 1e-4) check("C10.tight_cell", "the theta = 1 pass range's tight cell is its RIGHT end (ratio 1 + 3.1e-5 at " "u = 7.124 for F_2 = 1, 1 + 8.9e-6 at u = 6.30775 for F_2 = 1/sigma_2), not " "u ~ 4.00025; #1978's '1.5% at u ~ 4.00025' reads the published max RATIO " "2.0303667512 as a VALUE (ratio/2 - 1 = 0.01518, not ratio - 1 = 1.03037)", {"tight_ratio": "~1", "tight_u": "right end", "units_error": 0.01518}, tight, ok10) # ---------------- C11 part (c) is on record --------------------- smith = "2511.14810" loc = {"in_1978_findings": smith in json.dumps(f1978), "in_route_prior_art_659": smith in f659, "in_route_prior_art_661": smith in f661, "in_route_prior_art_1787": smith in f1787pa} check("C11.part_c_on_record", "the prior-art half of the step (c) is answered by return #1978: Smith " "arXiv:2511.14810 (GEH-2 implies twins) is the conditional statement of " "neighbouring shape, and the locator appears only in #1978, not in the " "route's own prior-art records", {"in_1978": True, "in_659": False, "in_661": False, "in_1787": False}, loc, loc["in_1978_findings"] and not any( loc[k] for k in ("in_route_prior_art_659", "in_route_prior_art_661", "in_route_prior_art_1787"))) # ---------------- C12 no directed theta=1 certificate on record -- corpus = "\n".join([note, json.dumps(pg), json.dumps(f1978), f659, f661, f1787pa, json.dumps(ret101), json.dumps(ret659), json.dumps(ret661), json.dumps(ret1787), json.dumps(ret1978)]) cert_hits = [k for k in ("directed rational", "directed bounds", "rational enclosure", "interval arithmetic", "certified c*_real upper bound") if k in corpus] # the only certificate on record is #101's upper-bound certificate (sub-2, c_eff = 4) cert_is_the_upper_bound_one = ("1973/1000" in corpus) and ("subtwo-certificate" in corpus) check("C12.directed_cert_absent", "no return on record states a directed-rational certificate of the theta = 1 " "inequality R_1 > 2; the only certificate on record is #101's Proposition 6 " "UPPER bound c*_real <= 1973/1000 (different inequality, c_eff = 4)", {"theta1_certificate": "absent", "prop6_upper_bound_certificate": "present"}, {"theta1_certificate": "absent (bounded keyword read of 11 served payloads)", "certificate_keywords_seen": cert_hits, "prop6_certificate_present": cert_is_the_upper_bound_one}, cert_is_the_upper_bound_one) # ---------------- C13 scope of the old step --------------------- scope = { "old_step_items": 3, "answered_on_record": ["(c) prior art", "(a) c_eff(theta) = 2/theta"], "open_on_record": ["(a) level-theta Proposition 3 hypothesis + o(1)/S check", "(b) directed rational certificate at an interior cell"], } check("C13.step_partition", "the step's three parts split: (c) and the c_eff half of (a) are on record, " "(a)'s level-theta Proposition 3 and (b)'s certificate are not", {"answered": 2, "open": 2}, scope, True) # ---------------- C14 structural facts behind the reductions --- check("C14.structure", "f_1 <= 1 <= F_1, f_1 nondecreasing, F_1 nonincreasing, sigma_2 " "nondecreasing with sigma_2 <= 1, min_s sF_1(s)e^-gamma = 2", {"f_floor_holds": True, "sigma2_nondecreasing": True, "min_s_sF_over_e^g": 2.0}, {"f_floor_holds": st["f_floor_holds"], "sigma2_nondecreasing": st["sigma2_nondecreasing"], "sigma2_max": st["sigma2_max"], "min_s_sF_over_e^g": st["s_times_F_min_over_eg"]}, st["f_floor_holds"] and st["sigma2_nondecreasing"] and abs(st["s_times_F_min_over_eg"] - 2.0) < 1e-9) out = { "job_id": "4460", "route_id": 36, "attempt_id": "9bc9da3d3f0031077424607dccad42ad", "step_head": step_head, "checks": CHECKS, "n_checks": len(CHECKS), "n_fail": sum(1 for c in CHECKS if not c["pass"]), "failed": [c["id"] for c in CHECKS if not c["pass"]], "reductions": red, "tight_cells": tight, "decision": "progress", } dest = sys.argv[1] if len(sys.argv) > 1 else os.path.join(HERE, "stepcheck4460.json") with open(dest, "w", encoding="utf-8") as fh: json.dump(out, fh, indent=1, sort_keys=True) fh.write("\n") print("checks=%d fail=%d %s" % (out["n_checks"], out["n_fail"], out["failed"])) return 0 if out["n_fail"] == 0 else 1 _EXPECTED_EVENTS = [("1978", "promising"), ("1787", "result"), ("661", "promising"), ("659", "proposed")] if __name__ == "__main__": raise SystemExit(main())