"""Job #1902 (pursue route 75 rev 2). Regenerate the finite two-class covering certificate of the xlnx-lower-bound packet (return #32) under the theorem's OWN revised choices, with the old choices kept as labelled controls. OBJECT. A two-class cover of [1, y]: a set of classes (q, a), q prime, that covers every n in [1, y] with n = a or a - 2 (mod q). Stage 1: every prime p <= z with a = 0 (kills n = 0, -2 mod p); survivors V = {n <= y : gcd(n(n+2), P(z)) = 1}. Mop-up, two rules: INJECT (the theorem's choice, review #15 / route 75): one distinct fresh prime per survivor, survivors in ascending order, primes ascending above z, a_q = r mod q; hence x = p_{pi(z) + |V|} (#1007's identity). GREEDY (return #32's section 5 variant): the same, but a survivor already covered by an earlier mop-up class is skipped. Cutoffs: REVISED z = floor(sqrt(y) / ln y) (the theorem's); OLD z = floor(sqrt y); BASELINE z = 13 (#32's first row). Verification from scratch after each construction: an integer array of cover counts over [1, y]; uncovered = 0 required. Stdout carries only stable numbers (no timing) so two runs must be byte-identical (sha256 printed by the caller). PRE-REGISTERED (from #1004/#1007's tables at y = 2*10^5): (old, greedy) 2137 survivors / 1220 mop-up / largest 10711 / ratio 2.0123224; (old, inject) 2137 / 2137 / 19597 / 1.0326326; (revised, greedy) 6210 / 1331 / 11071 / 1.9399755; (revised, inject) 6210 / 6210 / 61871 / 0.2929927; (z = 13, greedy) largest 10301 with 1257 mop-up primes, 9889 survivors (#32's row). At y = 2*10^6: (revised, inject) z = 97, |V| = 38523, x = 461183, ratio 0.333 (#1007's counting); coverage verified here for the first time. FALSIFIER: any uncovered n at either scale under the revised injective rule.""" import math, sys, json import numpy as np def primes_upto(n): s = np.ones(n + 1, dtype=bool); s[:2] = False for i in range(2, int(n ** 0.5) + 1): if s[i]: s[i * i::i] = False return np.flatnonzero(s) def survivors(y, z, primes): alive = np.ones(y + 1, dtype=bool); alive[0] = False for p in primes[primes <= z]: alive[0::p] = False; alive[(-2) % p::p] = False return np.flatnonzero(alive) # n in [1, y] with n != 0, -2 mod every p <= z def cover_counts(y, classes): cnt = np.zeros(y + 1, dtype=np.int32) for q, a in classes: for c in {a % q, (a - 2) % q}: cnt[c::q] += 1 cnt[0] = 1 return cnt def build(y, z, rule, primes): V = survivors(y, z, primes) stage1 = [(int(p), 0) for p in primes[primes <= z]] pool = primes[primes > z] classes = list(stage1); k = 0 if rule == 'inject': for r in V: q = int(pool[k]); k += 1; classes.append((q, int(r) % q)) else: # greedy: skip survivors already covered by an earlier mop-up class covered = np.zeros(y + 1, dtype=bool) for r in V: r = int(r) if covered[r]: continue q = int(pool[k]); k += 1; a = r % q; classes.append((q, a)) for c in {a % q, (a - 2) % q}: covered[c::q] = True cnt = cover_counts(y, classes) uncovered = int(np.count_nonzero(cnt[1:] == 0)) x = max(q for q, _ in classes) return {'y': y, 'z': int(z), 'rule': rule, 'pi_z': int(np.count_nonzero(primes <= z)), 'survivors': int(len(V)), 'mopup_primes': k, 'largest_prime': int(x), 'classes': len(classes), 'ratio_y_over_xlnx': round(y / (x * math.log(x)), 7), 'uncovered': uncovered, 'x_equals_p_pi_z_plus_S': bool(rule != 'inject' or x == int(primes[int(np.count_nonzero(primes <= z)) + len(V) - 1]))} def main(): out = [] for y in (200000, 2000000): primes = primes_upto(max(700000, 40 * int(y ** 0.5))) # enough primes for the injective pool at both scales for name, z in (('revised', int(math.isqrt(y) / math.log(y)) if False else int(math.floor(math.sqrt(y) / math.log(y)))), ('old', int(math.floor(math.sqrt(y)))), ('baseline13', 13)): for rule in ('inject', 'greedy'): if name == 'baseline13' and rule == 'inject' and y == 2000000: continue # 98k survivors, pool would need ~1.3M primes; not a labelled control r = build(y, z, rule, primes); r['cutoff'] = name; out.append(r) print(json.dumps(r, sort_keys=True)) json.dump(out, open('cert1902.json', 'w'), indent=1) ok = all(r['uncovered'] == 0 for r in out) print('ALL_COVERED', ok) if __name__ == '__main__': main()