#!/usr/bin/env python3 """Route 4, job 763: a capacity-tightness certificate of non-coverability. No CNF, no SAT solver, no LRAT. The frozen instance's own counting budget is tight (sum of per-prime capacities equals |D|); in that regime any cover must attain every per-prime maximum simultaneously, and the kill sets must partition D. That reduces coverability to an exact-cover question over the argmax kill sets, which is decided here in milliseconds. stdout is the artifact (byte identical across runs); timing/progress -> stderr. python3 route4-tight-cert.py art/input.json """ import json import sys import time from collections import Counter T0 = time.time() NODE_CAP = 2_000_000 # The stdout artifact must reproduce byte for byte on any platform: force LF so # a Windows run does not emit CRLF. (Caught because an upload of a CRLF capture # hashed differently from the local file.) sys.stdout.reconfigure(newline='\n') def log(*a): print(*a, file=sys.stderr) def is_prime(n): return n >= 2 and all(n % d for d in range(2, n) if d * d <= n) def support(p, a, cap): """Independent rebuild of the admissible old-twin starts (endpoint divisibility).""" old = [n for n in range(2, p + 1) if is_prime(n)] qs = [n for n in range(p + 1, 2 * p + 1) if is_prime(n)] slots = [s for s in range(a, a + cap) if all(s % r and (s + 2) % r for r in old)] return old, qs, slots def kill_set(D, q, b): """Slots of D killed by phase b at prime q: s = -b or s = -b-2 (mod q).""" return frozenset(s for s in D if (s + b) % q == 0 or (s + b + 2) % q == 0) def capacity(D, qs): """cap[q][b] = |kill_set(D,q,b)|; M[q] = max_b; argmax[q] = all maximising b.""" c = {q: Counter() for q in qs} for s in D: for q in qs: c[q].update(((-s) % q, (-s - 2) % q)) M = {q: max(c[q].values(), default=0) for q in qs} am = {q: tuple(b for b in range(q) if c[q][b] == M[q]) for q in qs} return c, M, am def tight_verdict(D, qs, M, am): """Decide coverability in the tight case (sum M == |D|). Returns (verdict, witness). Verdict 'noncoverable' carries either a slot in no argmax kill set or the exhausted-search statement; 'coverable' carries the tiling phases. """ assert sum(M.values()) == len(D) # membership of each slot in the union over all argmax kill sets argmax_union_cover = {s: [] for s in D} for q in qs: for b in am[q]: for s in kill_set(D, q, b): argmax_union_cover[s].append(q) dead = [s for s in D if not argmax_union_cover[s]] if dead: return 'noncoverable', ('slot_in_no_argmax_kill_set', dead[0]) # exact cover: one argmax phase per prime, kill sets pairwise disjoint, union D order = sorted(qs, key=lambda q: (-M[q], q)) sets = {q: [kill_set(D, q, b) for b in am[q]] for q in qs} nodes = [0] def rec(i, used, picked): nodes[0] += 1 if nodes[0] > NODE_CAP: raise RuntimeError('node cap exceeded') if len(used) == len(D): return list(picked) rest = sum(M[order[j]] for j in range(i, len(order))) if len(used) + rest < len(D): return None q = order[i] for b, K in zip(am[q], sets[q]): if K & used: continue r = rec(i + 1, used | K, picked + [(q, b)]) if r is not None: return r return None try: tiling = rec(0, frozenset(), []) except RuntimeError as e: return 'undecided', ('search_cap', str(e)) if tiling is None: return 'noncoverable', ('argmax_disjoint_tiling_absent', nodes[0]) return 'coverable', ('tiling', tiling) def main(): meta = json.load(open(sys.argv[1] if len(sys.argv) > 1 else 'art/input.json')) p, a, capL = meta['p'], meta['a'], meta['cap'] old, qs, slots = support(p, a, capL) assert (p, a, capL) == (97, 9409, 32768) assert qs == meta['Q'] and old == meta['old_primes'] log(f'support rebuilt: {len(slots)} admissible slots in [{a},{a + capL})') # ---- route 4's own capacity scan, reproduced ---- # The scan grows the admissible-slot prefix one slot at a time; the recorded # frontier is the *interval* length at the step where F1 first turns positive. c = {q: Counter() for q in qs} prefix = [] F1_at = {} # keyed by slot count n = len(prefix) for s in slots: prefix.append(s) for q in qs: c[q].update(((-s) % q, (-s - 2) % q)) F1_at[len(prefix)] = len(prefix) - sum(max(c[q].values(), default=0) for q in qs) first_pos = min(n for n, v in F1_at.items() if v > 0) assert first_pos == meta['frontier_N'] == 69, first_pos assert prefix[first_pos - 1] - a + 1 == meta['L_F'] == 4433 assert F1_at[68] == meta['F1'] == 0 assert [s for s in slots if s < a + meta['L']] == meta['slots'], 'frozen D mismatch' def interval_len(n): return prefix[n - 1] - a + 1 out = [] out.append('# Route 4, job 763: tight-capacity non-coverability certificate') out.append(f'# support: p={p} a={a} old_primes_upto={p} Q={qs}') out.append(f'# capacity scan: F1 first turns positive at slot count N={first_pos}, ' f'i.e. interval length L_F={interval_len(first_pos)} (route 4 record)') out.append('') # ---- every prefix where the counting budget is exactly tight ---- tight_lo = [] for n in range(1, first_pos): if F1_at[n] != 0: continue D = prefix[:n] _, M, am = capacity(D, qs) verdict, wit = tight_verdict(D, qs, M, am) tight_lo.append((n, interval_len(n), verdict, wit, sum(M.values()))) log(f' tight N={n} (L={interval_len(n)}): {verdict}') certified = [t for t in tight_lo if t[2] == 'noncoverable'] out.append('## Tight prefixes (F1 = 0) and their verdict') out.append('N L M_sum F1 verdict witness') for n, li, verdict, wit, msum in tight_lo: if verdict == 'noncoverable': w = f'{wit[0]}={wit[1]}' else: w = str(wit[0]) out.append(f'{n:3d} {li:5d} {msum:5d} {F1_at[n]:3d} {verdict:15s} {w}') out.append('') out.append(f'tight prefixes found: {len(tight_lo)}; ' f'certified non-coverable among them: {len(certified)}') if certified: n0, l0, *_ = certified[0] out.append('certified non-coverability frontier: the smallest certified ') out.append(f'non-coverable prefix is N={n0} slots, i.e. interval L={l0}; by ' f'monotonicity of covering in D,') out.append(f'every prefix with L >= {l0} is non-coverable. The record labels the ' f'frozen D by L={meta["L"]} (= L_F - 1);') out.append(f'its capacity frontier L_F={interval_len(69)} is therefore an upper ' 'bound on the true non-coverability frontier, not the frontier itself.') else: out.append('no tight prefix was certified non-coverable: the tight regime is ' 'undecided here') out.append('') # ---- the frozen instance, in full ---- L = meta['L'] D = prefix[:meta['N']] assert D == meta['slots'] and len(D) == 68 cD, M, am = capacity(D, qs) Msum = sum(M.values()) out.append(f'## Frozen instance (record L={L}, L_F-1; N={len(D)} admissible slots, ' f'interval length {interval_len(len(D))})') out.append('q M(q) #argmax argmax phases') for q in qs: out.append(f'{q:4d} {M[q]:4d} {len(am[q]):8d} {list(am[q])}') out.append(f'sum_q M(q) = {Msum}; |D| = {len(D)}; ' f'independent slack F1 = |D| - sum_q M(q) = {len(D) - Msum}') out.append('') # the certificate: the tightness lemma plus one slot dead = [s for s in D if not any(s in kill_set(D, q, b) for q in qs for b in am[q])] out.append('LEMMA (tight-capacity rigidity). If sum_q max_b |K_D(q,b)| = |D| and a') out.append('phase vector covers D, then |K_D(q,b_q)| = max_b |K_D(q,b)| for every q') out.append('and the kill sets K_D(q,b_q) are pairwise disjoint with union D.') out.append('Proof. |D| = |U_q K(q,b_q)| <= sum_q |K(q,b_q)| <= sum_q max_b |K(q,b)| = |D|.') out.append('Equality in both steps gives disjointness and |K(q,b_q)| = max_b.') out.append('') out.append('CERTIFICATE (non-coverability of the frozen instance):') out.append(f' tight: sum_q M(q) = {Msum} = |D| = {len(D)}') out.append(f' slots of D whose kill sets are attained by NO argmax phase: {len(dead)}') for s in dead: out.append(f' s = {s} (in D; (s+2) = {s + 2})') out.append(' Hence every cover would need s in some K_D(q,b) with b argmax, and none') out.append(' exists: the frozen instance is NON-COVERABLE, i.e. its CNF is UNSAT.') out.append('') out.append('Scope: this is an exact statement about one frozen support (p=97, a=9409,') out.append('Q = primes 101..193, prefix L=4432). It does not prove H_alpha, does not') out.append('bound proof length, and says nothing about prefixes with F1 < 0.') out.append(f'# nodes searched in the exact-cover test: see witness column') sys.stdout.write('\n'.join(out) + '\n') log(f'done in {time.time() - T0:.3f}s') if __name__ == '__main__': main()