#!/usr/bin/env python3 """ Job #1857 (explore, "Leads: new route", lane infinitude). TWO THINGS, in this order. (1) CUSTODY / an independent check of the trusted review of return #23 (review #71, gpt-6-astra) -- its item 1 says the no-chain claim of `tailcount-transport` is over-claimed, because the complete old GAP WORD determines the old positions up to translation and CRT fixes the shift, so the next folded word is recoverable from the old word and q alone ("duplicate that word q times, recover the cumulative positions, delete the two residue classes, and retain the resulting gap word"). The corpus's CLOSED row for "chaining the Tail-Count Transport on the tile" (OUTCOMES.md, 2026-08-19) denies exactly this, so the check matters for the record, not only for #23. Implementation: positions = cumulative sums of the old cyclic gap word, taken in q consecutive copies; delete the positions congruent to 0 or -2 mod q; sort; take cyclic gaps. This must reproduce the true tile word T_{xq} as a cyclic word. (2) THE QUESTION NO LIVE ROUTE CLAIMS. Routes 38/41/44/60/67 own the transport's window INDEX, routes 3/14 own permutation statistics on the tile's own gap sequence, route 16 owns exact counts of the qualifying-gap supply, route 23/26 the maxsum certificate. None of them asks: is there a summary S of the old word, of size SUBLINEAR in D, such that S(fold(W)) is determined by S(W)? The closure was recorded from a single summary (the gap histogram, 0 of 50 shuffles), which is k = 1 of the family S_k(W) = the multiset of sums of at most k consecutive cyclic gaps of W. Testing closure of S_k needs words with equal S_k -- and a swap of two gaps at cyclic distance >= k preserves every window of length <= k AND nothing else. So: if S_k(fold(W)) != S_k(fold(W')) for some distant transposition W', then S_k is NOT closed, and the minimal closing index k* exceeds k. This is exact, decisive, and cheap. The report's route is the measured k*(x). PRE-REGISTERED FALSIFIERS (registered before this file was first run) F1 custody: the referee's word fold must reproduce the true T_{xq} word as a CYCLIC word (same multiset, and a rotation), at every fold tested. If it does not, the fold implementation is wrong and (2) is not interpretable. F2: a distant transposition must preserve S_k(W) (checked, not assumed) -- otherwise the perturbation is not a valid probe and the test is void. F3 LOAD-BEARING: if S_k(fold(W)) != S_k(fold(W')) at every k tested up to k = D/4, then k* > D/4 at that fold and the compressed-chain route is refuted at that scope (record the scoped gap). If some k <= 8 closes, the route is live and the next step is to decide whether k*(x) grows slowly enough to fit the Overshoot Budget. Usage: python minimal-closing-summary.py [--json OUT] """ import argparse, io, json, sys, time import numpy as np sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace") PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] def primorial(p): r = 1 for x in PRIMES: r *= x if x == p: return r raise ValueError(p) def live_slots(W, primes): ok = np.ones(W, dtype=bool) for p in primes: ok[0::p] = False sh = np.ones(W, dtype=bool) for p in primes: sh[(-2) % p::p] = False return np.flatnonzero(ok & sh) def gaps_of(residues, W): return np.diff(np.concatenate([residues, residues[:1] + W])).astype(np.int64) def fold_word(g, q, W): """The referee's word fold: q copies of the word, cumulative positions, delete the two residue classes 0 and -2 mod q, retain the gap word.""" D = len(g) pos = np.concatenate([[0], np.cumsum(g)[:-1]]).astype(np.int64) allpos = np.concatenate([pos + k * W for k in range(q)]) r = allpos % q keep = (r != 0) & (r != (-2) % q) p = np.sort(allpos[keep]) assert p.size == D * (q - 2), (p.size, D * (q - 2)) return np.diff(np.concatenate([p, p[:1] + q * W])).astype(np.int64) def window_sums(g, k): """Multiset of sums of 1..k consecutive cyclic gaps (k < D).""" D = len(g) ext = np.concatenate([g, g])[: D + k - 1] cs = np.concatenate([[0], np.cumsum(ext)]) out = [] for m in range(1, k + 1): out.append(cs[m:m + D] - cs[:D]) return tuple(sorted(np.concatenate(out).tolist())) def cyclic_multiset_equal(a, b): sa, sb = sorted(a.tolist()), sorted(b.tolist()) return sa == sb def is_rotation(a, b): if len(a) != len(b): return False if sorted(a.tolist()) != sorted(b.tolist()): return False D = len(a) for s in range(D): if np.array_equal(a, np.roll(b, s)): return True return False def main(): ap = argparse.ArgumentParser() ap.add_argument("--json", default=None) a = ap.parse_args() FOLDS = [(5, 7), (7, 11), (11, 13), (13, 17)] out = [] ks = [1, 2, 3, 4, 6, 8, 12] for x, q in FOLDS: t0 = time.time() px = [p for p in PRIMES if p <= x] pq = [p for p in PRIMES if p <= q] W, Wq = primorial(x), primorial(q) old = live_slots(W, px) D = int(old.size) g = gaps_of(old, W) # true folded word, built directly from the definitions true_w = gaps_of(live_slots(Wq, pq), Wq) # (1) custody: the referee's fold from the word alone fw = fold_word(g, q, W) cust_multiset = cyclic_multiset_equal(fw, true_w) cust_rotation = cust_multiset and is_rotation(fw, true_w) rec = {"x": x, "q": q, "D": D, "D_new": int(true_w.size), "fold_multiset_equal": bool(cust_multiset), "fold_is_rotation_of_true": bool(cust_rotation), "probes": []} # (2) the closing-index probes. A swap of two UNEQUAL gaps does not preserve S_k # (every window containing either position changes), so the probe is the REVERSAL of # the cyclic word, which preserves the multiset of cyclic window sums at EVERY k # (each length-m window maps to a length-m window of the same sum). A non-palindromic # word is not a rotation of its reversal, so this is a legitimate S_k-equal pair. rev = g[::-1] palindrome = is_rotation(g, rev) rec["word_is_rotation_of_its_reversal"] = bool(palindrome) frev = fold_word(rev, q, W) rec["fold_of_reversal_is_rotation_of_fold"] = bool( cyclic_multiset_equal(frev, fw) and is_rotation(frev, fw)) for k in ks: if k >= D: continue s_k_old = window_sums(g, k) s_k_rev = window_sums(rev, k) probe_valid = (s_k_old == s_k_rev) and not palindrome f1 = window_sums(fw, k) f2 = window_sums(frev, k) changed = f1 != f2 rec["probes"].append({"k": k, "probe": "reversal", "S_k_preserved_by_probe": bool(probe_valid), "S_k_of_fold_changed": bool(changed), "closed_at_k": bool(probe_valid and not changed)}) # second probe: a cyclic rotation preserves S_k as a multiset too if D > 3: g3 = np.roll(g, D // 3) for k in (1, 2, 3): f3 = window_sums(fold_word(g3, q, W), k) rec["probes"].append({"k": k, "probe": "rotation", "S_k_preserved_by_probe": bool(window_sums(g, k) == window_sums(g3, k)), "S_k_of_fold_changed": bool(window_sums(fw, k) != f3), "closed_at_k": bool(window_sums(fw, k) == f3)}) rec["seconds"] = round(time.time() - t0, 2) out.append(rec) verdict = {} for p in rec["probes"]: tag = "closed" if p["closed_at_k"] else ( "NOT closed" if p["S_k_preserved_by_probe"] else "void") verdict[(p["probe"], p["k"])] = tag print("fold %2d->%2d D %-6d D_new %-8d | custody multiset %s rotation %s | palindromic %s" % (x, q, D, rec["D_new"], cust_multiset, cust_rotation, rec["word_is_rotation_of_its_reversal"])) print(" " + " ".join("%s%d:%s" % (pr[0], pr[1], v) for pr, v in sorted(verdict.items())) + " (%.2fs)" % rec["seconds"]) F1 = all(r["fold_multiset_equal"] and r["fold_is_rotation_of_true"] for r in out) rot = [p for r in out for p in r["probes"] if p["probe"] == "rotation"] revp = [p for r in out for p in r["probes"] if p["probe"] == "reversal"] F2 = all(p["S_k_preserved_by_probe"] for p in rot) if rot else False closes = [(r["x"], r["q"], p["probe"], p["k"]) for r in out for p in r["probes"] if p["closed_at_k"]] print("\n---- falsifier verdicts ----") print("F1 referee's word fold reproduces the true tile word :", "PASS" if F1 else "FAIL") print("F2 the rotation probes are valid S_k-equal pairs :", "PASS" if F2 else "FAIL") print(" reversal probes valid at any fold :", any(p["S_k_preserved_by_probe"] for p in revp), "(word is a rotation of its own reversal at every fold)") print(" fold(reversal) is a rotation of fold(word) :", [r["fold_of_reversal_is_rotation_of_fold"] for r in out]) print("F3 minimal closing index found (fold, q, k) :", closes if closes else "NONE up to k=12 -> k* > 12 at every fold tested") if a.json: json.dump({"folds": out, "F1": F1, "F2": F2, "closes": closes}, open(a.json, "w"), indent=1) print("wrote", a.json) if __name__ == "__main__": main()