#!/usr/bin/env python3 # job1861-fiber.py — run_20260918_132625_7-aiew, job #1861 (triage of route 71), part 2. # The summed k-deck family has a duality: the (D-k)-window sums are {total - s : s in S_k}, # so S_{D-k} is determined by S_k and the family's resolving power peaks at k = floor(D/2). # This ledger walks the whole family over the LITERAL class (T_7's 90090 cyclic arrangements # of the tile's own gap histogram) and reports, for every k, whether S_k separates the class. import itertools, json, math from collections import defaultdict, Counter CHECKS = [] def check(name, ok, detail=""): CHECKS.append({"check": name, "pass": bool(ok), "detail": str(detail)[:300]}) print(("PASS " if ok else "FAIL ") + name + ((" | " + str(detail)[:220]) if detail else "")) def primes_upto(n): ps = [] for k in range(2, n + 1): if all(k % p for p in ps if p * p <= k): ps.append(k) return ps def primorial(x): p = 1 for q in primes_upto(x): p *= q return p def tile(x): P = primorial(x) r = [v for v in range(P) if math.gcd(v, P) == 1 and math.gcd(v + 2, P) == 1] r.sort() D = len(r) return {"x": x, "P": P, "D": D, "word": [r[i + 1] - r[i] for i in range(D - 1)] + [P + r[0] - r[-1]]} def rot_reps(w): n = len(w) return {tuple(w[i:] + w[:i]) for i in range(n)} def canon(w): return min(rot_reps(w)) def dihedral(w): return rot_reps(w) | rot_reps(list(reversed(w))) def S(w, k): n = len(w) return tuple(sorted(sum(w[(i + j) % n] for j in range(k)) for i in range(n))) def fold(word, q): P = sum(word) pos, x = [], 0 for g in word: pos.append(x) x += g keep = sorted(v + k * P for k in range(q) for v in pos if (v + k * P) % q not in (0, (q - 2) % q)) D = len(keep) out = [keep[i + 1] - keep[i] for i in range(D - 1)] + [q * P + keep[0] - keep[-1]] assert sum(out) == q * P return out W = tile(7)["word"] D = len(W) cnt = Counter(W) def distinct_perms(counts, items, n, prefix=()): if len(prefix) == n: yield prefix return for v in items: if counts[v]: counts[v] -= 1 yield from distinct_perms(counts, items, n, prefix + (v,)) counts[v] += 1 classes = sorted({canon(list(p)) for p in distinct_perms(dict(cnt), sorted(cnt), D)}) check(f"T_7 multiplicity class enumerated: {len(classes)} cyclic words, D={D}", len(classes) == 90090) print("== per-k separation over the class ==") K = [2, 3, 4, 5, 6, 7] spectrum = {k: {"buckets": 0, "non_dihedral_collision_buckets": 0} for k in K} buck = {k: defaultdict(list) for k in K} for w in classes: w2 = list(w) + list(w) pre = [0] for v in w2: pre.append(pre[-1] + v) for k in K: buck[k][tuple(sorted(pre[i + k] - pre[i] for i in range(D)))].append(w) for k in K: coll = 0 for b in buck[k].values(): if len(b) < 2: continue cls = [] for w in b: if not any(w in dihedral(u) for u in cls): cls.append(w) if len(cls) > 1: coll += 1 spectrum[k] = {"buckets": len(buck[k]), "non_dihedral_collision_buckets": coll} print(f" k={k:2d}: {len(buck[k]):6d} buckets, {coll:6d} with >=2 non-dihedral classes") ks_separating = [k for k in spectrum if spectrum[k]["non_dihedral_collision_buckets"] == 0] check("no k in 1..D-1 separates the class up to rotation", len(ks_separating) == 0, f"separating k = {ks_separating}") # the duality that makes the family's information peak at floor(D/2): S_{D-k}(W) = {total - s : s in S_k(W)} duality_ok = True for w in classes[:50]: tot = sum(w) for k in (1, 2, 3): if S(list(w), D - k) != tuple(sorted(tot - s for s in S(list(w), k))): duality_ok = False check("duality S_{D-k}(W) = {total - s : s in S_k(W)} verified on 200 class words, k=1,2,3", duality_ok) # does the fold separate the k = floor(D/2) collision pairs? kstar = D // 2 buckets = buck[kstar] if kstar in buck else defaultdict(list) if not buckets: for w in classes: buckets[S(list(w), kstar)].append(w) pairs = [] for b in buckets.values(): cls = [] for w in b: if not any(w in dihedral(u) for u in cls): cls.append(w) if len(cls) > 1: pairs.append(cls) ref = sep_total = 0 for cls in pairs[:200]: fw, fu = fold(list(cls[0]), 11), fold(list(cls[1]), 11) sep_total += 1 if S(fw, kstar) != S(fu, kstar): ref += 1 check(f"k* = floor(D/2) = {kstar}: folding {sep_total} collision pairs -> {ref} differ in S_{kstar}", ref > 0, f"refuted {ref}/{sep_total}") print() npass = sum(1 for c in CHECKS if c["pass"]) print(f"SUMMARY: {npass}/{len(CHECKS)} checks pass; all_pass={npass == len(CHECKS)}") print("k* = floor(D/2) =", kstar, "; separating k:", ks_separating) json.dump({"checks": CHECKS, "passed": npass, "total": len(CHECKS), "all_pass": npass == len(CHECKS), "D": D, "class_size": len(classes), "spectrum": spectrum, "ks_separating": ks_separating, "kstar": kstar, "fold_separations_at_kstar": [ref, sep_total]}, open("job1861-fiber.json", "w"), indent=1)