#!/usr/bin/env python3 """Job #1028 (leads: new route) -- is the ARRANGEMENT of a certified span free at every level? Question. Return #433 (job #1035) found, at 19# and 43# only, that the matched permutation null of the interior share is degenerate: the class law of #398 pins the interior, so "the arrangement channel" has no freedom. If that holds at EVERY certified level then the record's A_1 value is carried by the gap MULTISET alone and the fixed-multiset permutation statistics of routes 14 and 3 are void at every certified level -- the dichotomy those routes were built to measure. Two distinct things are tested here, and they are not the same test: INTERIOR forcing : every INTERIOR gap (gaps[1:-1]) lies in C_x = {0, +-c(x)} mod 6x. If true the interior slot SET is fixed by the class law (this is what #398 asserts), hence the interior share of #433/route 10 is a function of the multiset. FREE BITS : d(x) = #(all gaps in C_x) - (L-2) = how many eligible gaps are NOT needed in the interior, i.e. how much freedom remains in placing the endpoints. d = 0 means the interior/endpoint placement is forced too, so the permutation ensemble of route 14 has exactly one admissible arrangement. d < 0 is impossible (it would mean fewer eligible gaps than interior slots while every interior gap is eligible -- an inconsistency, asserted against). d > 0 is the only surviving arrangement freedom. Levels <= 23# are enumerated from the definition (EVERY span of the level, not just the recorded one); levels >= 29# decompose the certified least witness of the served LADDER only, so they are a one-witness sample per level and the record multiplicity there is not covered. Every enumerated A_1 is asserted against the served ladder value, and the 19# span-length histogram is asserted against #417's anatomy. Usage: python rigidity.py Output: JSON on stdout, progress on stderr. Stdlib + numpy only. """ import json import sys from math import gcd import numpy as np PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43] # served LADDER: level -> (A_1(x), certified least position) [job1007/splits.py, return #424] LADDER = {11: (42, 899), 13: (66, 731), 17: (108, 701), 19: (150, 659), 23: (204, 76166567), 29: (258, 1205437109), 31: (348, 8813641451), 37: (528, 544899485411), 41: (546, 3784200788231), 43: (618, 830330079152051)} ENUM = [11, 13, 17, 19, 23] ANATOMY19 = {2: 8, 3: 12} # #417: 19# has 20 spans, lengths {2: 8, 3: 12} def primorial(x): r = 1 for p in PRIMES: if p <= x: r *= p return r def class_c(x): return (6 * (2 * pow(6, -1, x) % x)) % (6 * x) def span_from(x, p, g): """The L-1 gaps between the consecutive T_{x-1} slots of [p, p+g]; both ends are asserted slots.""" P = primorial(x - 1) s = [n for n in range(p, p + g + 1) if gcd(n * (n + 2), P) == 1] assert s[0] == p and s[-1] == p + g, "endpoints are not T_{%d} slots" % (x - 1) return [s[i + 1] - s[i] for i in range(len(s) - 1)] def analyse(x, p, gaps, c, mod): L = len(gaps) interior = gaps[1:-1] inclass = [(g % mod) in (0, c, mod - c) for g in gaps] int_class = [f for f, g in zip(inclass[1:-1], interior)] if L >= 2 else [] E = sum(inclass) d = E - len(interior) assert d >= 0, "d<0: fewer eligible gaps than interior slots -- inconsistent" return dict(x=x, least_position=int(p), L=L, gaps=[int(g) for g in gaps], c=int(c), mod=int(mod), in_class=[bool(b) for b in inclass], E=int(E), interior_slots=len(interior), interior_all_in_class=bool(all(int_class)) if interior else True, interior_in_class=int(sum(int_class)), d=int(d)) def main(): out = {"levels": []} for x in ENUM: D = primorial(x) alive = np.ones(D, dtype=bool) for p in (q for q in PRIMES if q <= x): alive[0::p] = False alive[(p - 2) % p::p] = False idx = np.flatnonzero(alive).astype(np.int64) dd = np.diff(idx) seam = int(idx[0] + D - idx[-1]) g = int(max(int(dd.max()), seam)) if seam > g: # the maximal run wraps the primorial seam starts = [int(idx[-1])] else: starts = [int(s) for s in idx[:-1][dd == g]] if seam == g: starts.append(int(idx[-1])) starts = sorted(set(starts)) assert g == LADDER[x][0], "level %d: enumerated A_1 %d != ladder %d" % (x, g, LADDER[x][0]) c, mod = class_c(x), 6 * x rows = [analyse(x, p, span_from(x, p, g), c, mod) for p in starts] forced = sum(1 for r in rows if r["interior_all_in_class"]) free0 = sum(1 for r in rows if r["d"] == 0) Lh = {} for r in rows: Lh[r["L"]] = Lh.get(r["L"], 0) + 1 sys.stderr.write("x=%-3d A1=%-4d spans=%-3d interior-forced=%-3d d=0:%-3d L-hist=%s E-set=%s\n" % (x, g, len(rows), forced, free0, {k: Lh[k] for k in sorted(Lh)}, sorted({r["E"] for r in rows}))) if x == 19: assert {int(k): v for k, v in Lh.items()} == ANATOMY19, "#417 anatomy not reproduced" sys.stderr.write(" 19# span-length histogram reproduces #417 anatomy %s\n" % (Lh,)) out["levels"].append(dict(x=x, A1=g, enumerated=True, n_spans=len(rows), interior_forced_spans=forced, d0_spans=free0, c=c, mod=mod, L_hist={str(k): Lh[k] for k in sorted(Lh)}, E_hist=sorted({r["E"] for r in rows}), rows=rows)) for x in sorted(LADDER): if x in ENUM: continue g, p = LADDER[x] c, mod = class_c(x), 6 * x r = analyse(x, p, span_from(x, p, g), c, mod) sys.stderr.write("x=%-3d A1=%-4d least witness L=%d gaps=%s in-class=%s E=%d of %d interior, d=%d %s\n" % (x, g, r["L"], r["gaps"], r["in_class"], r["E"], r["interior_slots"], r["d"], "RIGID" if r["interior_all_in_class"] and r["d"] == 0 else "FREE")) out["levels"].append(dict(x=x, A1=g, enumerated=False, n_spans=1, least_position=p, interior_forced_spans=1 if r["interior_all_in_class"] else 0, d0_spans=1 if r["d"] == 0 else 0, c=c, mod=mod, rows=[r])) tot = sum(l["n_spans"] for l in out["levels"]) f = sum(l["interior_forced_spans"] for l in out["levels"]) f0 = sum(l["d0_spans"] for l in out["levels"]) out["summary"] = dict(levels=len(out["levels"]), spans=tot, interior_all_in_class=f, d_zero=f0, rigid=(f == tot), rigid_placement=(f0 == tot), note="levels <= 23 enumerate every span; 29..43 use the certified least " "witness only (record multiplicity not covered)") sys.stderr.write("TOTAL spans=%d interior-all-in-class=%d d=0 (placement forced)=%d\n" % (tot, f, f0)) print(json.dumps(out, indent=1)) if __name__ == "__main__": main()