# Band-limited minorant certificate for route 143 (job 4293). Extends split_majorant2851.py (#1823): same sieve, # grid, DC convention and certificate; adds the Selberg minorant object and the Fejer control asked for by # #1911's step (copied unchanged by #1921). # # Objects on Z/q, q = x#, t = sieve indicator (dim 1: gcd(n,q)=1; dim 2: gcd(n(n+2),q)=1), window h, # S_h(N) = sum_{i= delta, # J-hat(tau) = pi tau (1-|tau|) cot(pi tau) + |tau|. Mass m-hat(0) = h - 1/delta = h/2. # delta = 2/h < 1/2 for h > 4, so the DFT of m on Z/q at r is exactly m-hat(r/q) (Poisson, no aliasing): # M is band-limited by construction (M(r) = 0 for |r|/q >= 2/h). # GATES (per h): (g1) m_q <= 1_[0,h) pointwise on all of Z/q (reported max violation); (g2) m_q agrees with the # spatial Beurling form m(y) = -1/2 [B(delta(a-y)) + B(delta(y-b))], B(z) = (sin pi z/pi)^2 [sum_{n>=0} (z-n)^-2 # - sum_{n<0} (z-n)^-2 + 2/z], summed over |j| <= JP periods, on i in [-2h, 3h) (checked only when q >= 20 h); # (g3) at x = 11, S_m from the FFT route equals a direct O(q^2) correlation. # Certificate at (h,k): C_k = sum_N (|X|/mean)^(2k) < 1, k <= KMAX; then max|X| < mean, so S_m > 0 (m) or # g_F > 0 (F). m <= 1_[0,h) and t >= 0 give S_m <= S_h, so a certified m proves every length-h window is nonempty. # A certified F proves every window of 2h-1 consecutive integers is nonempty (#1911). # PRE-REGISTERED (from the step): success: exp_m within 0.15 of exp_true at x = 17 and 19, dim 2 (<= 1 grid step). # failure: exp_m >= exp_true + 0.3 at x = 19, dim 2 (>= 3 steps), or m certifies nowhere on the grid. # two steps (+0.24) fires neither (#1921 note b). Fejer gate: h_F <= h_true and 2h_F - 1 >= L*. # L* = least window length with no empty window = longest cyclic run of t = 0, plus 1 (exact). # usage: minorant4293.py x dim [kmax] [jmin] [jmax] stdout: one JSON object; progress on stderr import sys, json, math import numpy as np from scipy.special import polygamma x, dim = int(sys.argv[1]), int(sys.argv[2]) KMAX = int(sys.argv[3]) if len(sys.argv) > 3 else 64 JMIN = int(sys.argv[4]) if len(sys.argv) > 4 else -10 JMAX = int(sys.argv[5]) if len(sys.argv) > 5 else 12 P = [p for p in range(2, x + 1) if all(p % r for r in range(2, int(p ** 0.5) + 1))] q = math.prod(P) t = np.ones(q, dtype=np.float64) for p in P: t[0::p] = 0 if dim == 2: t[(p - 2) % p::p] = 0 V = t.sum() / q T = np.fft.rfft(t) c = np.concatenate(([0], np.cumsum(np.concatenate((t, t)), dtype=np.float64))) xi = np.arange(len(T), dtype=np.float64) z = np.flatnonzero(t == 0); nz = np.flatnonzero(t) gaps = np.diff(np.concatenate((nz, [nz[0] + q]))) # distance between consecutive sifted points (cyclic) LSTAR = int(gaps.max()) # longest run of zeros is gaps.max()-1, so least empty-free length is gaps.max() def logC(a, k): la = np.log(a + 1e-300) * (2 * k); mx = la.max() return float(mx + math.log(np.exp(la - mx).sum())) def kcert(a): if a.max() >= 1: return None if logC(a, KMAX) >= 0: return None lo, hi = 1, KMAX if logC(a, 1) < 0: return 1 while hi - lo > 1: mid = (lo + hi) // 2 if logC(a, mid) < 0: hi = mid else: lo = mid return hi def Mhat(h): # DFT of the periodised minorant at r = 0..q//2 (rfft layout) d = 2.0 / h; a, b = -0.5, h - 0.5 tt = xi / q; tau = tt / d M = np.zeros(len(xi), dtype=np.complex128) inb = tau < 1 ti, ta = tt[inb], tau[inb] with np.errstate(divide='ignore', invalid='ignore'): Jh = np.where(ta == 0, 1.0, np.pi * ta * (1 - ta) / np.tan(np.pi * ta) + ta) ea, eb = np.exp(-2j * np.pi * ti * a), np.exp(-2j * np.pi * ti * b) chi = np.where(ti == 0, b - a, (ea - eb) / (2j * np.pi * ti)) M[inb] = Jh * chi - (1.0 / (2 * d)) * (1 - ta) * (ea + eb) return M, int(inb.sum()) def B(zv): # Beurling's function via trigamma: sum_{n>=0}(z-n)^-2 = psi1(-z), sum_{n<0}(z-n)^-2 = psi1(1+z); # reflection psi1(-z) + psi1(1+z) = pi^2/sin^2(pi z) gives pole-free forms on each side zv = np.asarray(zv, dtype=np.float64); out = np.empty_like(zv) s2 = np.sin(np.pi * zv) ** 2 pos = zv > 0; neg = zv < 0 out[pos] = 1 + (2 * s2[pos] / np.pi ** 2) * (1 / zv[pos] - polygamma(1, 1 + zv[pos])) w = -zv[neg] out[neg] = -1 + (2 * s2[neg] / np.pi ** 2) * (polygamma(1, w) - 1 / w) out[zv == 0] = 1.0 return out def m_spatial(h, ys): d = 2.0 / h; a, b = -0.5, h - 0.5 return -0.5 * (B(d * (a - ys)) + B(d * (ys - b))) hs = sorted({int(round(x * x * 2 ** (j / 2))) for j in range(JMIN, JMAX + 1)}) rows = [] for h in hs: if h >= q or h <= 4: continue S = c[h:h + q] - c[:q]; mu = h * V; f = S - mu ang = np.pi * xi / q with np.errstate(divide='ignore', invalid='ignore'): rat = np.where(xi == 0, float(h), np.sin(h * ang) / np.sin(ang)) out = {'h': h, 'mu': round(mu, 4), 'empty': int((S < 0.5).sum())} af = np.abs(f) / mu out['true'] = {'k': kcert(af), 'max': round(float(af.max()), 4), 'logC_KMAX': round(logC(af, KMAX), 3)} # Fejer control spec = T * rat ** 2 / h; spec[0] = 0 aF = np.abs(np.fft.irfft(spec, n=q)) / mu out['F'] = {'k': kcert(aF), 'max': round(float(aF.max()), 4), 'logC_KMAX': round(logC(aF, KMAX), 3)} # Selberg minorant M, nband = Mhat(h) mq = np.fft.irfft(M, n=q) ind = np.zeros(q); ind[:h] = 1 g1 = float((mq - ind).max()) mass = float(M[0].real); mean_m = V * mass gate = {'band_terms': nband, 'mass': round(mass, 9), 'g1_max_m_minus_ind': float('%.3e' % g1), 'm_min': round(float(mq.min()), 6), 'm_max': round(float(mq.max()), 6), 'm_at_0': round(float(mq[0]), 6), 'm_at_h': round(float(mq[h]), 6)} if q >= 20 * h: ii = np.arange(-2 * h, 3 * h); JP = 100 sp = np.zeros(len(ii)) for j in range(-JP, JP + 1): sp += m_spatial(h, (ii + j * q).astype(np.float64)) gate['g2_max_abs_diff'] = float('%.3e' % np.abs(sp - mq[ii % q]).max()) spec = T * np.conj(M); spec[0] = 0 Xm = np.fft.irfft(spec, n=q) if x == 11 and dim == 2 and h in (60, 121, 242): Sd = np.array([np.dot(np.roll(t, -N), mq) for N in range(q)]) gate['g3_direct_vs_fft'] = float('%.3e' % np.abs((Sd - mean_m) - Xm).max()) am = np.abs(Xm) / mean_m out['m'] = {'k': kcert(am), 'max': round(float(am.max()), 4), 'logC_KMAX': round(logC(am, KMAX), 3), 'min_Sm_over_mean': round(float(1 + (Xm / mean_m).min()), 4)} out['m_gate'] = gate rows.append(out) print('x', x, 'dim', dim, 'h', h, 'done', out['true']['k'], out['m']['k'], out['F']['k'], file=sys.stderr, flush=True) def summ(key): cert = [r['h'] for r in rows if r[key]['k'] is not None] hc = min(cert) if cert else None up = None for r in reversed(rows): if r[key]['k'] is None: break up = r['h'] e = lambda v: None if v is None else round(math.log(v) / math.log(x), 3) s = {'h_cert': hc, 'exp': e(hc), 'h_up': up, 'exp_up': e(up), 'k_at_cert': next((r[key]['k'] for r in rows if r['h'] == hc), None), 'uncert_above_first': [r['h'] for r in rows if hc and r['h'] > hc and r[key]['k'] is None]} if key == 'F' and hc: s['certified_length'] = 2 * hc - 1; s['exp_certified_length'] = e(2 * hc - 1) return s summary = {k: summ(k) for k in ('true', 'm', 'F')} e = lambda v: round(math.log(v) / math.log(x), 3) summary['LSTAR'] = LSTAR; summary['exp_LSTAR'] = e(LSTAR) st, sm, sF = summary['true'], summary['m'], summary['F'] summary['m_minus_true'] = None if sm['exp'] is None or st['exp'] is None else round(sm['exp'] - st['exp'], 3) summary['F_gate'] = None if sF['h_cert'] is None else {'hF_le_htrue': sF['h_cert'] <= (st['h_cert'] or 10 ** 18), 'len_ge_LSTAR': 2 * sF['h_cert'] - 1 >= LSTAR} summary['m_cert_ge_LSTAR'] = None if sm['h_cert'] is None else sm['h_cert'] >= LSTAR summary['g1_worst'] = max(r['m_gate']['g1_max_m_minus_ind'] for r in rows) g2 = [r['m_gate']['g2_max_abs_diff'] for r in rows if 'g2_max_abs_diff' in r['m_gate']] summary['g2_worst'] = max(g2) if g2 else None print(json.dumps({'x': x, 'dim': dim, 'q': q, 'V': V, 'KMAX': KMAX, 'grid': 'h=round(x^2 2^(j/2)), j=%d..%d, h>4' % (JMIN, JMAX), 'dc': 'xi=0 term zeroed', 'minorant': 'Selberg minorant of [-1/2, h-1/2], delta=2/h, exact m-hat, periodised to Z/q', 'summary': summary, 'rows': rows}))