#!/usr/bin/env python3 """job2456-linear — linear (non-wrapping) version of the loose run, against the record's L values. The main ledger's R(q) is the longest CYCLIC run of consecutive qualifying gaps. The served kill-graph edge rule is `sigma' - sigma = g_i (mod p)` on the OLD gap word O(D) with no fold (#1644/#856, quoted in job1645's own artifact: "L(T_x,p) >= 2 iff some gap g satisfies g = 0, +2 or -2 (mod p)"), so a run of r consecutive qualifying gaps is a path of r edges, i.e. r+1 nodes, in the LINEAR word. Prediction therefore: L(T_x, q) >= R_linear(q) + 1 (a run of r qualifying gaps is an (r+1)-node path) with equality expected unless other edges/isolated-node conventions intervene, and R_linear <= R_cyclic (a run may wrap the seam). Test at T23, where the record has three measured L values (#1840 / #159): L(T23,29) = 2, L(T23,31) = 3, L(T23,37) = 2. If R_linear = 1, 2, 1 there, the prediction L = R_linear + 1 reproduces all three exactly and explains why the cyclic values (2, 2, 2) looked inconsistent with the recorded 2 -- the difference is the seam. Deterministic JSON on stdout, timing on stderr. """ import importlib.util import json import os import sys import time import numpy as np _HERE = os.path.dirname(os.path.abspath(__file__)) _spec = importlib.util.spec_from_file_location( "job2456_checks", os.path.join(_HERE, "job2456-checks.py")) _jc = importlib.util.module_from_spec(_spec) _spec.loader.exec_module(_jc) P23, SMALL23 = _jc.P23, _jc.SMALL23 sieve_chunk = _jc.sieve_chunk def word_linear(P, small): """Gap word of one period WITHOUT the cyclic seam gap: the O(D) linear word.""" idx = np.flatnonzero(sieve_chunk(0, P, small)).astype(np.int64) return np.diff(idx).astype(np.uint16), int(idx.size) def R_linear(word, p): mod = np.mod(word, np.uint16(p)) qual = (mod == np.uint16(0)) | (mod == np.uint16(2)) | (mod == np.uint16(p - 2)) idx = np.flatnonzero(qual) if idx.size == 0: return 0 d = np.diff(idx) brk = np.flatnonzero(d != 1) if brk.size == 0: return int(idx.size) lens = np.diff(np.concatenate(([-1], brk, [int(idx.size) - 1]))) return int(lens.max()) def main(): t0 = time.time() w23, n23 = word_linear(P23, SMALL23) w23c = np.concatenate([w23, np.array([42], dtype=np.uint16)]) # seam gap value taken from job1645 recorded = {29: 2, 31: 3, 37: 2} rows = {} for p in (29, 31, 37, 107, 127): rl = R_linear(w23, p) rc = _jc.R_of(w23c, p) rows[str(p)] = {"R_linear": rl, "R_cyclic": rc, "predicted_L_ge": rl + 1, "recorded_L_T23": recorded.get(p), "matches_record": (recorded[p] == rl + 1) if p in recorded else None} checks = [ {"name": "T23 linear-word residue count = 7952175", "ok": n23 == 7952175, "detail": n23}, {"name": "T23 R_linear(31) + 1 = recorded L(T23,31) = 3", "ok": rows["31"]["R_linear"] + 1 == 3, "detail": rows["31"]}, {"name": "T23 R_linear(37) + 1 = recorded L(T23,37) = 2", "ok": rows["37"]["R_linear"] + 1 == 2, "detail": rows["37"]}, {"name": "T23 R_linear <= R_cyclic at every measured prime (seam can only add)", "ok": all(v["R_linear"] <= v["R_cyclic"] for v in rows.values()), "detail": {k: (v["R_linear"], v["R_cyclic"]) for k, v in rows.items()}}, {"name": "T23 R_linear(107) = R_linear(127) = 0 (the served uniform threshold 127 is at the " "linear ladder's top too)", "ok": rows["107"]["R_linear"] == 0 and rows["127"]["R_linear"] == 0, "detail": {k: rows[k]["R_linear"] for k in ("107", "127")}}, ] out = { "job": 2456, "artifact": "linear vs cyclic loose run at T23, against the record's measured L values", "D_T23": n23, "rows": rows, "T29_prediction": { "measured_cyclic": {"R_cyclic(29)": 3, "R_cyclic(31)": 3, "R_cyclic(37)": 2}, "recorded_quoted_L": {"L(T29,31)": 4}, "prediction": "L(T_x,q) = R_linear(q) + 1; at T29 that predicts L(T29,31) = 4 when the " "longest cyclic run does not wrap (consistent with the quoted 4) and " "L(T29,29) in {3,4}, a value the record does not have", "falsifier": "a T29 kill-graph component census at q=29,31 (exact, ~214M slots, " "union-find over the corrected tile) returning L(T29,29) < 3 or " "L(T29,31) != 4", }, "checks": checks, "all_pass": all(c["ok"] for c in checks), "wall_s_excluded": True, } print(json.dumps(out, indent=1, sort_keys=True)) print("[stderr] %d checks, all_pass=%s, elapsed %.1fs" % (len(checks), all(c["ok"] for c in checks), time.time() - t0), file=sys.stderr) if __name__ == "__main__": main()