#!/usr/bin/env python3 """job1524-checks.py -- offline checks for job #1524 (rescue investigation: return #9). Run from the department root: the evidence paths below are repo-relative so this script runs as shipped on any copy of the folder. Reads only this run's own saved replies: .solveathome/runs/run_20260916_174657_y42ODA/work/job1524/two-moire-argument.md.txt .solveathome/runs/run_20260916_174657_y42ODA/work/job1524/moire-primes.md.txt .solveathome/runs/run_20260916_174657_y42ODA/work/job1524/exponent-control.js.txt Each is the server's reply, unwrapped from its {"raw": ...} envelope by the fetch step (see report.md "Evidence custody"). """ import hashlib import json import math import sys from functools import reduce BASE = ".solveathome/runs/run_20260916_174657_y42ODA/work/job1524/" RESULTS = [] def check(name, ok, detail): RESULTS.append({"check": name, "ok": bool(ok), "detail": detail}) print(("PASS " if ok else "FAIL ") + name + " :: " + str(detail)) def load(name): return open(BASE + name, encoding="utf-8").read() def primes_upto(n): s = [True] * (n + 1) s[0] = s[1] = False for i in range(2, int(n ** 0.5) + 1): if s[i]: for j in range(i * i, n + 1, i): s[j] = False return [i for i, v in enumerate(s) if v] def primorial(p): return reduce(lambda a, b: a * b, primes_upto(p), 1) moire = load("moire-primes.md.txt") twom = load("two-moire-argument.md.txt") expo = load("exponent-control.js.txt") flat = " ".join(moire.split()) # ---------------------------------------------------------------- 1. the cutoff item4 = [ln for ln in twom.splitlines() if "Only primes in" in ln] check("served two-moire note states the Scour alphabet as (x, sqrt(|Tx|)]", len(item4) == 1 and "\u221a|T\u2093|]" in item4[0] and "181" not in twom, item4[0].strip()[:120] if item4 else "item 4 not found") check("served two-moire note never mentions a 181 cutoff", "181" not in twom, "occurrences of '181' in the served note: %d" % twom.count("181")) # ------------------------------------------------- 2. the exact numbers at x=13 W = 30030 # 13# = |T_13| sq = math.sqrt(W) last = max(p for p in primes_upto(int(sq)) ) log173 = math.log10(primorial(173)) log181 = math.log10(primorial(181)) frac173 = math.log10(W / primorial(173)) frac181 = math.log10(W / primorial(181)) check("floor(sqrt(13#)) is the largest allowed scour prime 173", int(sq) == 173 and last == 173, "sqrt(30030)=%.6f -> last allowed prime %d" % (sq, last)) check("log10(173#) matches the review's 68.221648677", abs(log173 - 68.221648677) < 1e-9, "%.9f" % log173) check("log10(30030/173#) matches the review's -63.744093345", abs(frac173 + 63.744093345) < 1e-9, "%.9f" % frac173) check("log10(181#) and 30030/181# reproduce the note's stale 10^73 / 10^-69", abs(log181 - 72.732180283) < 1e-9 and abs(frac181 + 68.254624951) < 1e-9, "log10(181#)=%.9f log10(30030/181#)=%.9f (note prints ~10^73 and ~10^-69)" % (log181, frac181)) check("note's stale magnitudes are ~5 orders off its own stated cutoff", abs(log181 - log173) > 4 and abs(frac181 - frac173) > 4, "10^73 vs 10^%.4f ; 10^-69 vs 10^%.4f" % (log173, frac173)) check("joint period under the note's own item-4 cutoff is exactly 173#", W * reduce(lambda a, b: a * b, [p for p in primes_upto(173) if p > 13], 1) == primorial(173), "30030 * prod(13= 1 and "1.539+-0.094" in s7[0], s7[0].strip()[:140] if s7 else "no line with both 1.801 and +-0.074") # ---------------------------------------------------- 6. the review's falsifier rev = json.load(open(BASE + "return9.json", encoding="utf-8"))["reviews"][0]["notes_md"] check("review 18's own falsifier is satisfied by the actual source", "withdrawn if" in rev and "181 cutoff" in rev and "181" not in twom, "review: the principal rejection would be withdrawn if the source used an 181 cutoff; the source does not") check("return 9's rejected revision hash is the one the review reproduced", json.load(open(BASE + "return9.json", encoding="utf-8"))["revision_sha"] == "2ea88cd3692ac44b928f3cd04e5dad761e3d5a68231445190011471a5546efb7", "revision_sha 2ea88cd3... (reproduced by the review, not recomputed here)") passed = sum(1 for r in RESULTS if r["ok"]) summary = { "job_id": 1524, "checks": RESULTS, "passed": passed, "total": len(RESULTS), "all_pass": passed == len(RESULTS), "evidence_sha256": { "two-moire-argument.md.txt": hashlib.sha256(twom.encode()).hexdigest(), "moire-primes.md.txt": hashlib.sha256(moire.encode()).hexdigest(), "exponent-control.js.txt": hashlib.sha256(expo.encode()).hexdigest(), }, "note": ("Finite exact arithmetic and source-location checks only; no primorial census, " "no hedge of the paper's asymptotics, no rerun of the review's 1018081 sieve."), } open(BASE + "checks.json", "w", encoding="utf-8").write(json.dumps(summary, indent=1)) print("\n%d/%d passed" % (passed, len(RESULTS))) sys.exit(0 if summary["all_pass"] else 1)