#!/usr/bin/env python3 """Generate the complete coverage-repair evidence file (outputs/coverage_repair.json). Reproduces the s=34 (K*(34)=29) and s=36 (K*(36)=33) coverage-repair result with an INDEPENDENT covering implementation (pure Python, gcd + division only), records every verdict, the witness phase vectors and slot lists, and the reconciled manifests. """ import json from math import gcd def primes_le(n): ps = [] for k in range(2, n + 1): if all(k % d for d in range(2, int(k ** 0.5) + 1)): ps.append(k) return ps def is_slot(r, prim): for p in prim: if r % p == 0 or (r + 2) % p == 0: return False return True def coverable(positions, Q): """Exact phase-assignment cover search; returns (ok, phases, bound, nodes).""" m = len(positions) nq = len(Q) res = [[p % q for q in Q] for p in positions] FULL = (1 << m) - 1 kill = [] for j, q in enumerate(Q): km = {} for a in range(q): a2 = (a - 2) % q mask = 0 for i in range(m): if res[i][j] == a or res[i][j] == a2: mask |= (1 << i) km[a] = mask kill.append(km) uc = [[bin(kill[j][a]).count("1") for a in range(Q[j])] for j in range(nq)] nodes = [0] best = [None] * nq def dfs(cov, used): nodes[0] += 1 if cov == FULL: return True i = 0 while (cov >> i) & 1: i += 1 rem = m - bin(cov).count("1") cap = sum(max(uc[j]) for j in range(nq) if not (used >> j) & 1) if cap < rem: return False for j in range(nq): if (used >> j) & 1: continue c = res[i][j] for a in (c, (c + 2) % Q[j]): km_a = kill[j][a] m2 = cov | km_a if m2 == cov: continue S = m2 ^ cov for j2 in range(nq): for s in range(m): if (S >> s) & 1: r = res[s][j2] uc[j2][r] -= 1 uc[j2][(r + 2) % Q[j2]] -= 1 ok = dfs(m2, used | (1 << j)) for j2 in range(nq): for s in range(m): if (S >> s) & 1: r = res[s][j2] uc[j2][r] += 1 uc[j2][(r + 2) % Q[j2]] += 1 if ok: best[j] = a return True return False ok = dfs(0, 0) root_bound = sum(max(uc[j]) for j in range(nq)) return ok, best, root_bound, nodes[0] def collect_window(start, L, prim): win = [start] cur = start while len(win) < L: cur += 1 if is_slot(cur, prim): win.append(cur) assert all(is_slot(w, prim) for w in win) return win def witness_block(start, L, prim, Q): win = collect_window(start, L, prim) ok, best, bound, nodes = coverable(win, Q) phases = {q: best[j] for j, q in enumerate(Q)} # verify every slot is killed by at least one assigned phase killed = [] for p in win: who = [q for j, q in enumerate(Q) if p % q == best[j] or p % q == (best[j] - 2) % q] killed.append(who) assert ok and all(killed), "witness verification failed" return {"start": start, "L": L, "span": win[-1] - win[0], "slots": win, "phases": phases, "cover_by_slot": killed, "nodes": nodes} def high_component(s, L): prim = primes_le(s) P = 1 for p in prim: P *= p N = 1 for p in prim: if p >= 3: N *= (p - 2) Q = [q for q in primes_le(2 * s) if q > s] n_high = (L + 1) // 2 n_low = (N - L + 1) // 2 top_desc = [] k = 1 while len(top_desc) < L: if is_slot(P - k, prim): top_desc.append(P - k) k += 1 top_asc = list(reversed(top_desc)) first = [] r = 1 while len(first) < n_high - 1: if is_slot(r, prim): first.append(r) r += 1 verdicts = [] ncov = 0 for t in range(n_high): win = top_asc[t:] + [P + s0 for s0 in first[:t]] ok, best, bound, nodes = coverable(win, Q) idx = N - L + t verdicts.append({"start_index": idx, "first_position": win[0], "slots": win, "covering": ok, "root_bound": bound, "nodes": nodes}) if ok: ncov += 1 return {"s": s, "L": L, "P_hash": P, "N": N, "Q": Q, "n_low": n_low, "n_high": n_high, "covering": ncov, "negative": n_high - ncov, "verdicts": verdicts} out = { "claim": "K*(34) = 29 and K*(36) = 33, exact, with complete-domain coverage restored after return #933's defect report.", "method": "independent pure-Python covering implementation (gcd + division only); cross-checked against the served kstar engine (identical node counts).", "s34": { "K_star": 29, "witness": witness_block(24531881117, 29, primes_le(34), [q for q in primes_le(68) if q > 34]), "L30_scan": high_component(34, 30), "manifest": {"low_from_segments": 3113276498, "high_this_run": 15, "total": 3113276513}, "msc34": {"num": 1590, "den": 348, "exact": "265/58", "value": 4.568965517241379}, }, "s36": { "K_star": 33, "witness": witness_block(20283513461, 33, primes_le(36), [q for q in primes_le(72) if q > 36]), "L34_scan": high_component(36, 34), "manifest": {"low_from_segments": 3113276496, "high_this_run": 17, "total": 3113276513}, "msc36": {"note": "msc(36) = maxsum_34(T_31)/348 > 1590/348 = 4.569 > 4 (maxsum_34 exceeds #588's m=30 table value)"}, }, "cross_check": { "c_engine_s34_L30_high": "windows=15 filter_pass=0 found=0", "c_engine_s34_L29_witness": "found=1 nodes=240 (python nodes=240)", "c_engine_s36_L34_high": "windows=17 filter_pass=0 found=0", "c_engine_s36_L33_witness": "found=1 nodes=104 (python nodes=104)", }, } with open("outputs/coverage_repair.json", "w") as f: json.dump(out, f, indent=2) print(json.dumps({"claim": out["claim"], "s34_K": out["s34"]["K_star"], "s34_high_covering": out["s34"]["L30_scan"]["covering"], "s36_K": out["s36"]["K_star"], "s36_high_covering": out["s36"]["L34_scan"]["covering"]}, indent=2)) print("wrote outputs/coverage_repair.json")