#!/usr/bin/env python3 """Job #1464 (Leads: new statistic, lane infinitude): the DENSITY-NORMALIZED MAXIMUM GAP. = QUESTION, PRE-REGISTERED BEFORE ANY RUN ====================================================== Does the level-x tile's maximum gap need the twin *arithmetic* to explain it, or is it a pure density effect? Object. T_x = { r mod W : gcd(r, W) = gcd(r+2, W) = 1 }, W = x# (the corpus's tile: killrun.js `slots = [11, 17, 29]` expanded by `r % p !== 0 && (r+2) % p !== 0`; determine.tile). D = |T_x| = prod_{p<=x} (p-2). Gaps are the D cyclic differences; G(x) = max gap. This is the PERIOD object (the corpus's maxgap census: 66 at T_13, 108 at T_17, 150 at T_19, 204 at T_23, per job #1402's gap-census), NOT the integer record ladder A144311, which is a different object at a different variable. The two are not to be conflated (that confusion is exactly what return #663 adjudicated). Statistic. Normalise G(x) by the maximum gap of the MATCHED-DENSITY null: D points placed independently and uniformly in the cycle [0, W). Let mu(x), sd(x) be the mean and sd of that null's maximum gap over 2000 seeded draws, and define R2(x) = G2(x) / mu2(x) (two-class tile, the twin object) R1(x) = G1(x) / mu1(x) (one-class tile {r : gcd(r,W)=1}, D1 = phi(W), its own null) The one-class tile is the MATCHED CONTROL the repo's style asks for: same construction, same sieve, one dimension lower. R2/R1 therefore measures whether the two-class (twin) comb's maximum gap is special relative to the one-class comb at the same level, with both densities removed. Decision it informs. If R2 = 1 the level-x maximum is a density effect, and a density-only bound would reach the exponent question -- a route absent from the 72-route DEAD list. If R2 is systematically far from 1, the arithmetic arrangement carries the maximum and item 0c's "information absent from the failed growth laws" has a calibrated size at reachable scale. FALSIFIER, written before the run. F1 (density explains): |R2(x) - 1| < 2 sd-of-the-null at EVERY reachable level x <= 19. Then the arithmetic regularity is not detectable in the maximum at reachable scale and any claim that the twin comb's maximum is arrangement-driven is unsupported there. F2 (one-class equals two-class): |R2/R1 - 1| < 0.05 at every level. Then the dimension of the sieve does not change the normalised maximum, and the two-class object carries no regularity structure of its own at this scale. F3 (density-only route viable): R2(x) approaches 1 monotonically as x grows. Then a density-only bound becomes plausible in the limit and the exponent question might be reachable without the failing growth laws. A verdict of F1/F2/F3 ACCEPTED means the design's own premise (that arrangement matters) is dead at reachable scale; the honest outcome is then a NEGATIVE finding, which is a result about the route family, not a bound. Registered guard. No number from this file may be read as a statement about A144311 or about the integer twin record; the object is the period. No asymptotic claim: x <= 19 only, and the reachable range is stated with every number. """ import importlib.util import json import math import pathlib import sys import time import numpy as np HERE = pathlib.Path(__file__).resolve().parent LC = pathlib.Path("D:/AI/TwinPrimeProject/.solveathome/twin-primes/runs/lc-63a9a60e07335b40") T0 = time.time() def log(m): sys.stderr.write("[%7.2fs] %s\n" % (time.time() - T0, m)) sys.stderr.flush() spec = importlib.util.spec_from_file_location( "det", str(LC / "work" / "readings" / "determine.py")) det = importlib.util.module_from_spec(spec) spec.loader.exec_module(det) LEVELS = [5, 7, 11, 13, 17, 19] DRAWS = 2000 SEED = 1464 def one_class_tile(level): """{r coprime to W}: the one-class control tile, built by the same plain sieve style.""" W = det.primorial(level) return np.flatnonzero(np.array([math.gcd(r, W) == 1 for r in range(W)], dtype=bool)), W def max_cyclic_gap(pos, W): if pos.size <= 1: return W g = np.diff(np.concatenate([pos, [pos[0] + W]])) return int(g.max()) def gaps(pos, W): return np.diff(np.concatenate([pos, [pos[0] + W]])) def thinned_null(W, D, draws, rng): """Matched-density independent placement: D iid uniform points in [0, W), max cyclic gap.""" out = np.empty(draws, dtype=np.int64) idx = np.arange(W) for i in range(draws): p = np.sort(rng.choice(idx, size=D, replace=False)) out[i] = int(np.diff(np.concatenate([p, [p[0] + W]])).max()) return out def main(): rng = np.random.default_rng(SEED) rep = {"tool": "job1464/density-normalized-maxgap", "seed": SEED, "draws": DRAWS, "levels": [], "prereg": {"F1": "|R2-1| < 2 null sd at every level", "F2": "|R2/R1-1| < 0.05 at every level", "F3": "R2 -> 1 monotonically in x"}, "object": "period object T_x (killed-run/tile), NOT A144311 (integer record)"} for level in LEVELS: W = det.primorial(level) two, _ = det.tile(level) two = np.asarray(two, dtype=np.int64) one, _ = one_class_tile(level) one = np.asarray(one, dtype=np.int64) D2, D1 = int(two.size), int(one.size) G2, G1 = max_cyclic_gap(two, W), max_cyclic_gap(one, W) n2 = thinned_null(W, D2, DRAWS, rng) n1 = thinned_null(W, D1, DRAWS, rng) mu2, sd2 = float(n2.mean()), float(n2.std(ddof=1)) mu1, sd1 = float(n1.mean()), float(n1.std(ddof=1)) rec = {"level": level, "W": W, "D_two": D2, "D_one": D1, "G_two": G2, "G_one": G1, "null_two_mean": round(mu2, 3), "null_two_sd": round(sd2, 3), "null_one_mean": round(mu1, 3), "null_one_sd": round(sd1, 3), "R2": round(G2 / mu2, 4), "R1": round(G1 / mu1, 4), "R2_over_R1": round((G2 / mu2) / (G1 / mu1), 4), "z_two": round((G2 - mu2) / sd2, 2), "z_one": round((G1 - mu1) / sd1, 2), "null_two_p_ge": round(float((n2 >= G2).mean()), 5), "null_two_p_le": round(float((n2 <= G2).mean()), 5), "distinct_gap_values": int(np.unique(gaps(two, W)).size), "gap_values": [int(v) for v in np.unique(gaps(two, W))]} rep["levels"].append(rec) log("x=%-3d W=%-12d D2=%-9d G2=%-5d null %.1f+-%.1f R2=%.3f (z %+.1f) | " "D1=%-9d G1=%-5d R1=%.3f R2/R1=%.3f | distinct gaps %d" % (level, W, D2, G2, mu2, sd2, rec["R2"], rec["z_two"], D1, G1, rec["R1"], rec["R2_over_R1"], rec["distinct_gap_values"])) # verdicts, computed from the table and nothing else R2 = [r["R2"] for r in rep["levels"]] R2R1 = [r["R2_over_R1"] for r in rep["levels"]] f1 = all(abs(r["z_two"]) < 2 for r in rep["levels"]) f2 = all(abs(v - 1) < 0.05 for v in R2R1) f3 = all(R2[i] < R2[i + 1] for i in range(len(R2) - 1)) and abs(R2[-1] - 1) < abs(R2[0] - 1) rep["verdicts"] = {"F1_density_explains": bool(f1), "F2_one_equals_two": bool(f2), "F3_trend_toward_1": bool(f3), "R2_sequence": R2, "R2_over_R1_sequence": R2R1} rep["seconds"] = round(time.time() - T0, 2) (HERE / "density-normalized-maxgap.json").write_text( json.dumps(rep, indent=1, sort_keys=True), encoding="utf-8", newline="\n") log("verdicts: F1=%s F2=%s F3=%s" % (f1, f2, f3)) print(json.dumps(rep["verdicts"], indent=1, sort_keys=True)) return 0 if __name__ == "__main__": sys.exit(main())