#!/usr/bin/env python3 # job1861-checks.py — run_20260918_132625_7-aiew, job #1861 (triage of route 71) # Bounded, exact, word-domain computation of route 71's own next_step (a)-(c): # does the Holt-Rudd fold factor through a rotation-invariant summary S_k # (the summed k-deck, k = 1,2,3) of the oriented gap word? # No network. Definitions only, no timing in the output (byte-reproducible). import itertools, json, math from collections import defaultdict 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 # ---------- the true tile: admissible residues r with r, r+2 coprime to x# ---------- 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) word = [r[i + 1] - r[i] for i in range(D - 1)] + [P + r[0] - r[-1]] return {"x": x, "P": P, "D": D, "residues": r, "word": word} # ---------- the reviewer's word-fold (review #71 of return #23, as re-implemented by #982) ---------- def fold(word, q): """q lifts of each old class, delete the classes 0 and -2 mod q, retain the gap word.""" P = sum(word) pos, x = [], 0 for g in word: pos.append(x) x += g assert x == P 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 # ---------- rotation-invariant summaries ---------- 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): """the word's class under rotations and reversal -- S_k is invariant on this whole class""" return rot_reps(w) | rot_reps(list(reversed(w))) def S(w, k): """summed k-deck: multiset of sums of k consecutive cyclic gaps""" n = len(w) return tuple(sorted(sum(w[(i + j) % n] for j in range(k)) for i in range(n))) def is_rotation(a, b): return canon(a) in (canon(b), canon(list(reversed(b)))) # ---------- ledger ---------- CHECKS = [] def check(name, ok, detail=""): CHECKS.append({"check": name, "pass": bool(ok), "detail": str(detail)[:400]}) print(("PASS " if ok else "FAIL ") + name + ((" | " + str(detail)[:200]) if detail else "")) print("== 1. the true tile and its word ==") T = {x: tile(x) for x in (3, 5, 7, 11, 13)} for x, t in T.items(): want = 1 for q in primes_upto(x): if q >= 3: # the q=2 factor is 0 by construction; T_x = prod_{3<=q<=x}(q-2) want *= (q - 2) check(f"D(T_{x}) = prod(q-2) = {want}", t["D"] == want, f"P={t['P']} D={t['D']}") check(f"sum(word T_{x}) = P", sum(t["word"]) == t["P"], t["word"] if t["D"] <= 15 else "") print("T_5 word:", T[5]["word"], " T_7 word:", T[7]["word"]) print("== 2. CONTROL: the word-fold on true words (does it reproduce the next true word up to rotation?) ==") for x, x2 in ((3, 5), (5, 7), (7, 11), (11, 13)): f = fold(T[x]["word"], x2) ok = is_rotation(f, T[x2]["word"]) check(f"fold(T_{x}) == rot/refl T_{x2} (D {len(f)} vs {T[x2]['D']})", ok, "gap multisets equal" if sorted(f) == sorted(T[x2]["word"]) else f"multiset differs: {sorted(f)} vs {sorted(T[x2]['word'])}") print("== 3. S_k is invariant under the dihedral class (rotations AND reversal) ==") for x in (5, 7, 11): w = T[x]["word"] rev = list(reversed(w)) for k in (1, 2, 3, min(len(w) - 1, 7)): check(f"S_{k} invariant under reversal at T_{x}", S(w, k) == S(rev, k)) # a rotation at a non-trivial offset r = w[3:] + w[:3] check(f"S_k invariant under rotation at T_{x}", all(S(w, k) == S(r, k) for k in (1, 2, 3))) print("== 4. ambiguity search inside the fold's own domain ==") # Domain: the words the reviewer's word-fold can be applied to at level 7 -- length D, # positive even gaps from the tile's OWN observed alphabets, total exactly P_7 = 210. A = sorted(set(T[7]["word"]) | set(T[11]["word"])) P7 = T[7]["P"] print("observed alphabet:", A, " P7:", P7) # all gaps are even here, so count in units of 6: sum 210 = 35 units UNITS = sorted({g // 6 for g in A}) TARGET = P7 // 6 assert all(g % 6 == 0 for g in A) and TARGET * 6 == P7 def compositions(D, alphabet, target, prefix=()): if D == 1: if target in alphabet: yield prefix + (target,) return for v in alphabet: if v * D <= target <= v * D + (D - 1) * (max(alphabet) - v) or True: rest = target - v if rest >= sum(sorted(alphabet)[:D - 1]) and rest <= (D - 1) * max(alphabet): yield from compositions(D - 1, alphabet, rest, prefix + (v,)) found = [] for D in range(2, 9): buckets = defaultdict(list) seen = set() for comp in compositions(D, UNITS, TARGET): c = canon([u * 6 for u in comp]) if c in seen: continue seen.add(c) key = (S(c, 1), S(c, 2), S(c, 3)) buckets[key].append(c) n_words = len(seen) amb = 0 for key, ws in buckets.items(): if len(ws) < 2: continue classes = [] for w in ws: if not any(w in dihedral(u) for u in classes): classes.append(w) if len(classes) >= 2: amb += 1 for w in classes: found.append((D, key, w, classes)) check(f"D={D}: {n_words} distinct cyclic words over the tile's alphabet summing to {P7}; " f"{amb} buckets with >=2 non-dihedral members", True) print("== 5. do S_1,S_2,S_3 determine the FOLDED summary? (test every non-dihedral ambiguity pair) ==") tested = 0 refuted = [] for D, key, w, classes in found: others = [u for u in classes if u != w] if not others: continue u = min(others) fw, fu = fold(list(w), 11), fold(list(u), 11) tested += 1 same1 = S(fw, 1) == S(fu, 1) same2 = S(fw, 2) == S(fu, 2) if not (same1 and same2): refuted.append({"D": D, "w": list(w), "u": list(u), "k1_equal": same1, "k2_equal": same2, "S1_fold_w": list(S(fw, 1)), "S1_fold_u": list(S(fu, 1))}) check("ambiguity pairs found and folded at q=11", tested > 0, f"tested={tested}") check("closure REFUTED at k<=2 by at least one pair (S_k equal, folded S_k unequal)", len(refuted) > 0, json.dumps(refuted[:2])[:400]) print("== 6. literal in-class scope of the route's step (a) ==") # The class at a given level = ALL cyclic arrangements of the true word's own gap multiplicities. for x in (5, 7, 11): w = T[x]["word"] m = defaultdict(int) for g in w: m[g] += 1 mult = math.factorial(len(w)) for v in m.values(): mult //= math.factorial(v) check(f"T_{x}: D={len(w)}, {len(m)} distinct gaps, arrangements of the class = {mult // len(w)} " f"(cyclic), D_<=9 levels: {[y for y in (3,5,7,11,13) if T[y]['D'] <= 9]}", True) print("== 7. the T_3 word class is a single word (the only class with D <= 9) ==") w3 = T[3]["word"] arr = set(itertools.permutations(w3)) check("T_3 class has exactly one cyclic word", len(arr) == 1, f"{w3}") print("== 8. LITERAL in-class test: every cyclic arrangement of T_7's own gap multiplicities ==") # This is route 71's step (a)/(b) with the class taken as the route defines it -- the words # carrying the tile's own gap histogram -- at the smallest level where the class has >1 element. w7 = T[7]["word"] from collections import Counter as _C cnt = _C(w7) items = sorted(cnt) n = len(w7) 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 = set() for p in distinct_perms(dict(cnt), items, n): classes.add(canon(list(p))) check(f"T_7 multiplicity class: {len(classes)} distinct cyclic words (all share S_1 by construction)", True) for kk in (2, 3, 4): buckets = defaultdict(list) for w in classes: buckets[S(list(w), kk)].append(w) multi = [b for b in buckets.values() if len(b) > 1] # non-dihedral members inside a bucket amb = [] for b in multi: cls = [] for w in b: if not any(w in dihedral(u) for u in cls): cls.append(w) if len(cls) > 1: amb.append(cls) check(f"T_7 class, k={kk}: {len(buckets)} S_{kk}-buckets, {len(multi)} with >1 member, " f"{len(amb)} with >=2 non-dihedral classes", True) if amb: ref = 0 for cls in amb[:60]: fw, fu = fold(list(cls[0]), 11), fold(list(cls[1]), 11) if S(fw, kk) != S(fu, kk): ref += 1 check(f"T_7 class, k={kk}: folding the ambiguous pairs -> {ref}/{min(len(amb), 60)} " f"differ in S_{kk} of the folded word", True) 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("ambiguity pairs folded:", tested, " refutations:", len(refuted)) json.dump({"checks": CHECKS, "passed": npass, "total": len(CHECKS), "all_pass": npass == len(CHECKS), "ambiguity_pairs_folded": tested, "refutations": refuted[:5], "tiles": {str(x): {"P": t["P"], "D": t["D"], "word": t["word"]} for x, t in T.items()}}, open("job1861-checks.json", "w"), indent=1)