# t23check.py - JOB #642: the two objects return #207 conflates, computed exactly at the # control fold T_23 -> 29. # (a) the kill-run spectrum: maximal runs of consecutive slots whose residues mod q fit in # one 2-set {a, a+2} (a = q-2 is the anchored form {0,-2} that #161's kill graph uses; # all q shifts is the free translate that #161 measures). # (b) the loose per-gap qualification runs and Q_L(theta), exactly as #159 section 0: # Q_L(theta) = #{i : G_{L+1}(i) >= theta and g_{i+1}..g_{i+L-1} all qualify}, # qualifies(g,q) = g mod q in {0, 2, q-2}. import numpy as np from collections import Counter W = 223092870 g = np.load("t23-gaps.npy").astype(np.int64) slots = np.load("t23-slots.npy") D = len(g) q = 29 assert int(g.sum()) == W print("D(T_23) = %d ; gap word cyclic length %d ; every gap a multiple of 6: %s ; sum = W: %s" % (D, D, bool((g % 6 == 0).all()), int(g.sum()) == W)) res = (slots % q).astype(np.int64) gapq = (g % q).astype(np.int64) def cyclic_runs(mask): """maximal cyclic runs of True in a bool array -> list of lengths""" if not mask.any(): return [] m2 = np.concatenate([mask, mask]) prev = np.concatenate([[mask[-1]], mask[:-1]]) starts = np.flatnonzero(mask & ~prev) lens = [] for s in starts: L = 1 while m2[s + L]: L += 1 lens.append(L) return lens # ---------------- (a) kill runs, anchored and free translate specs = {} for a in range(q): mask = (res == a) | (res == ((a + 2) % q)) spec = Counter(cyclic_runs(mask)) specs[a] = spec anch = specs[q - 2] # {q-2, 0} = {0, -2} print("(a) ANCHORED kill-run spectrum (T_23, 29), a = %d:" % (q - 2), dict(sorted(anch.items())), " L_max =", max(anch)) Lmax_free = max(max(s) for s in specs.values()) print("(a') FREE translate: max over all %d anchors of L = %d; anchors with L >= 2: %d" % (q, Lmax_free, sum(1 for s in specs.values() if max(s) >= 2))) print(" #161's reported diagonal value here is L(T_23, 29) = 2 ->", "REPRODUCED" if Lmax_free == 2 else "DIVERGES (got %d)" % Lmax_free) # ---------------- (b) loose qualification runs and Q_L qual = (gapq == 0) | (gapq == 2) | (gapq == q - 2) runsQ = cyclic_runs(qual) specQ = Counter(runsQ) print() print("(b) qualifying gaps (g mod 29 in {0,2,27}): %d of %d = %.4f of the D gaps" % (int(qual.sum()), D, qual.sum() / D)) print(" loose qualification run spectrum, largest 8 lengths:", sorted(specQ.items())[-8:]) print(" max loose run length = %d ; total runs = %d" % (max(specQ), sum(specQ.values()))) S2 = np.concatenate([[0], np.cumsum(g)]) S2 = np.concatenate([S2, S2[-1] + np.cumsum(g)]) idx = np.arange(D) Lcap = max(specQ) + 1 print() print(" L sum_theta Q_L windows G>0 max G_{L+1} violations of 'Q_L = 0'") mass = {} for L in range(1, Lcap + 1): ok = np.ones(D, dtype=np.bool_) for j in range(1, L): ok &= qual[(idx + j) % D] Gl = S2[idx + L + 1] - S2[idx] Gl = np.where(ok, Gl, 0) m = int((Gl // 6).sum()) mass[L] = m if L <= 12: print(" %2d %12d %14d %10d %s" % (L, m, int((Gl > 0).sum()), int(Gl.max()), "YES" if m > 0 else "no")) print() print("The loop was run to L = %d = L_max + 1, the last L that can carry any window" " (the producer truncates at LMAX = 8; #207 asserts a cut at L >= 3)." % Lcap) print("return #207 section 2 at this fold asserts Q_L == 0 for L >= 3:") print(" sum_theta Q_3 = %d sum_theta Q_4 = %d sum_theta Q_5 = %d" % (mass.get(3, 0), mass.get(4, 0), mass.get(5, 0))) last = max(L for L in mass if mass[L] > 0) print(" the last L with any window at all is %d (= L_max + 1 = 2 + 1); Q_L = 0 for L >= %d" % (last, last + 1)) tot = sum(mass.values()) print(" sum_{L>=1} sum_theta Q_L = %d at the control fold (the quantity #207 claims is 4 and 12,992 at 29->31)" % tot)