# t29check.py - JOB #642: Q_L(theta) exactly at the fold T_29 -> 31, the fold return #207's # mass bounds are about. Definition, #159 section 0 (and the served producer's tctRHS): # 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}, theta on the 6-grid. import numpy as np from collections import Counter G = np.load("t29-gaps.npy").astype(np.int32) D = len(G) q = 31 assert D == 214708725 print("T_29: D = %d, sum = %d, max gap = %d" % (D, int(G.astype(np.int64).sum()), int(G.max()))) gapq = (G.astype(np.int64) % q) qual = (gapq == 0) | (gapq == 2) | (gapq == q - 2) print("qualifying gaps at q = 31: %d of %d = %.5f" % (int(qual.sum()), D, qual.sum() / D)) print("qualifying gap sizes present:", sorted(set(G[qual].tolist()))[:12], "...", sorted(set(G[qual].tolist()))[-6:]) def cyclic_runs(mask): 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 lens = cyclic_runs(qual) print("loose qualification runs: total %d, spectrum tail %s, max = %d" % (sum(Counter(lens).values()), sorted(Counter(lens).items())[-6:], max(lens))) idx = np.arange(D) run = G.copy() ok = np.ones(D, dtype=np.bool_) print() print(" L sum_theta Q_L windows G>0 max G_{L+1} #207's asserted bound") bounds = {1: None, 2: None, 3: 12992, 4: 4} masses = {} for L in range(1, 13): run = run + np.roll(G, -L) if L >= 2: ok &= qual[(idx + L - 1) % D] good = run[ok] m = int((good.astype(np.int64) // 6).sum()) masses[L] = m b = bounds.get(L) print(" %2d %14d %14d %12d %s" % (L, m, int((good > 0).sum()), int(run.max()), ("asserted <= %d -> %s" % (b, "REFUTED" if m > b else "holds")) if b else "-")) print() print("untruncated vs the producer's LMAX = 8: sum_{L<=8} sum_theta Q_L = %d" % sum(masses[L] for L in range(1, 9))) print("max L with any window at all (loose) = %d = (max loose run length + 1); Q_L = 0 for L >= %d" % (max(L for L in masses if masses[L] > 0), max(L for L in masses if masses[L] > 0) + 1)) print("the producer truncates the L sum at LMAX = 8; the family is already empty above L = 4 here") print() print("return #207 section 2.2 asserts sum_theta Q_4 <= 4 and sum_theta Q_3 <= 12,992 at this fold.") print(" measured sum_theta Q_4 = %d -> factor %d above the asserted bound" % (masses[4], masses[4] // 4)) print(" measured sum_theta Q_3 = %d -> factor %.1f above the asserted bound" % (masses[3], masses[3] / 12992))