#!/usr/bin/env python3 """Job 990 - the integer-vs-fractional cover frontier, on a ladder of primes (p, 2p]. For a prime p, Q = the primes in (p, 2p], old = the primes <= p. D_N = the first N admissible twin starts s in [a, a+L) (s and s+2 coprime to old); q in Q kills s at phase b iff s = -b or s = -(b+2) (mod q). A cover picks one phase per q. Two frontiers for each support, both monotone thresholds in N (adding a slot only adds constraints, so non-coverability and the existence of a weighted certificate are upward closed): N_int, L_int the first N that is NON-coverable, decided by the independent complete phase search (`tightcert.oracle`) - feasible only where the search fits the node cap. N_w, L_w the first N carrying a verified rational weighted certificate (the LP relaxation, tightcert.certify rule `weighted`) - feasible at every p, which is the point of the route. The gap L_int - L_w is the price of integrality in length units, and (L_int - L_w)/L_w is its size. `uniform` is the Q-only dual baseline sum_{q in Q} 2/q: the value of the uniform per-modulus phase distribution, a lower bound on m* that uses no information about D at all. stdout is the artifact; nothing here is timed, so the output is byte-stable. """ import json import sys import time import tightcert as tc T0 = time.time() CHEAP = dict(iters=600, dual_iters=1500) LADDER = [13, 19, 31, 43, 61, 97] A_OFFSET = 10007 # a deep start, far past p, so no degenerate left edge NODE_CAP = 300_000 def frontier(slots, qs, cap): """(first N non-coverable, first N with a weighted certificate); None past cap.""" n_int = n_w = None errors = [] for N in range(1, len(slots) + 1): D = slots[:N] if n_w is None: cert = tc.certify(D, qs, **CHEAP) ok, _ = tc.verify(cert, D, qs) assert ok, (N, cert.get('rule')) if cert.get('rule') == 'weighted': n_w = N if n_int is None: try: cov, _ = tc.oracle(D, qs, cap=cap) if not cov: n_int = N except RuntimeError: errors.append(N) if n_int is not None and n_w is not None: break return n_int, n_w, errors def main(): p_in = [int(x) for x in sys.argv[1:]] or LADDER print('# Job 990 - integer vs fractional cover frontier, prime-band supports') print('# D_N = first N admissible twin starts s in [a, a+cap); Q = primes in (p, 2p]') print('# integer: first N non-coverable by the independent complete phase search') print('# fractional: first N with a verified rational weighted certificate') print('# uniform = sum_{q in Q} 2/q, the Q-only dual baseline (lower bound on m*)') print('# a = %d for every p; oracle node cap %d; weighted budget iters=600 dual=1500' % (A_OFFSET, NODE_CAP)) print('') print(' p |Q| L_F N_F uniform n_int L_int n_w L_w gap gap/L_w note') rows = [] for p in p_in: a = A_OFFSET _, qs, slots = tc.prime_band(p, a, 65536) if len(slots) < 20: print(' %3d -- (only %d admissible slots at a=%d; widen the cap)' % (p, len(slots), a)) continue # the capacity frontier of this support n_f = l_f = None for N in range(1, len(slots) + 1): f1, _ = tc.budget(slots[:N], qs) if f1 > 0: n_f, l_f = N, slots[N - 1] - a + 1 break n_int, n_w, errors = frontier(slots, qs, NODE_CAP) uniform = sum((tc.Fraction(2, q) for q in qs), tc.Fraction(0)) l_int = slots[n_int - 1] - a + 1 if n_int else None l_w = slots[n_w - 1] - a + 1 if n_w else None gap = (l_int - l_w) if (n_int and n_w) else '' ratio = ('%.4f' % ((l_int - l_w) / l_w)) if (n_int and n_w) else '' note = '' if n_int is None: note = 'oracle capped (N in %s..)' % (errors[0] if errors else '?') if n_w is None: note = (note + ' ' if note else '') + 'no weighted certificate in range' print(' %3d %4d %5d %5d %7.4f %5s %5s %5s %5s %5s %8s %s' % (p, len(qs), l_f or 0, n_f or 0, float(uniform), n_int or '-', l_int or '-', n_w or '-', l_w or '-', gap, ratio, note)) rows.append({'p': p, 'Q': qs, 'a': a, 'N_F': n_f, 'L_F': l_f, 'uniform_2_over_q': [uniform.numerator, uniform.denominator], 'N_int': n_int, 'L_int': l_int, 'N_w': n_w, 'L_w': l_w, 'gap': gap, 'ratio': ratio, 'oracle_capped_from': errors[0] if errors else None, 'D_sha256_N_int': None}) print('') print('## Reading') print(' gap = L_int - L_w is the length cost of the integrality restriction on this') print(' support: how many more slots a fractional (=LP) refutation already rules out') print(' before the first integer-non-coverable prefix. A bounded, slowly growing') print(' ratio is what makes a fractional route to a G2 ceiling worth pursuing; a') print(' ratio that grows without bound refutes it. `note` marks the rows where the') print(' independent integer decision was not reachable inside the node cap, so the') print(' row reports the fractional side alone.') print('') print('Scope: p in the printed ladder, one deep start a = %d per p, window cap 65536.' % A_OFFSET) print('Nothing here mentions H_alpha, TPC, or any infinite family; each row is a') print('statement about one finite support.') json.dump(rows, open('fractgap.json', 'w'), indent=1, sort_keys=True) tc.log('fractgap done in %.1fs' % (time.time() - T0)) if __name__ == '__main__': main()