#!/usr/bin/env python3 """ 0016 · REQUIREMENTS AND ACCEPTANCE — the four bars, their thresholds, and the elementary gap-bound bridge. Everything here is a check of arithmetic or of an exact finite identity; there is no new number theory. The script supports the programme's acceptance contract with the following sections: 1. CRITICAL-LEVEL IDENTITY. With x = sqrt(N), the admissible set A_x = { n : gcd(n, x#) = gcd(n+2, x#) = 1 } satisfies A_x & [2, N] = {twin lower members <= N}, so |A_x & [2,N]| = pi_2(N). Checked by building A_x from the primes <= sqrt(N) independently of the twin list. 2. PIGEONHOLE GAP BOUND. If Lambda is the maximal gap between consecutive elements of A_x & [0,N], then pi_2(N) >= (N - Lambda) / (Lambda + 2). Checked against the exact pi_2(N) and the measured Lambda. 3. EXPONENT THRESHOLD. In the normalisation Lambda <= x^beta = N^(beta/2), the pigeonhole gives pi_2(N) >= N^(1 - beta/2) asymptotically, so beta < 2 is the bar. Tabulated at N = 1e6, 1e8 for beta = 1.5, 2, 2.5, 3, 4.26645 (the corpus's record exponent) and compared with the exact pi_2(N). 4. THE MEASURED WINDOW GAP and the (weak) implied lower bound at 1e6, 1e7. 5. CONVENTION TRANSLATION a_k = 1/beta_k (corpus return #121) for the values the corpus records. 6. DISTRIBUTION LEVELS the corpus records as known vs required. Run with the workspace venv: .venv/bin/python3 scripts/requirements.py Output captured in out/requirements.out. """ from math import gcd, log from sympy import primerange, primepi RULE = 78 C2 = 0.6601618158468696 def hr(title): print() print("=" * RULE) print(title) print("=" * RULE) def sieve(limit): s = bytearray([1]) * (limit + 1) s[0] = s[1] = 0 for p in range(2, int(limit ** 0.5) + 1): if s[p]: s[p * p::p] = bytearray(len(s[p * p::p])) return s def primorial(limit): """product of primes <= limit (exact)""" r = 1 for p in primerange(2, limit + 1): r *= p return r def admissible_set(N): """A_x for x = isqrt(N): n with no prime <= x dividing n or n+2. Built from the sieve alone (no primality test of n). Returns (ok, x).""" x = int(N ** 0.5) ok = bytearray([1]) * (N + 3) for p in primerange(2, x + 1): ok[p::p] = bytearray(len(ok[p::p])) # kill n with p | n+2, i.e. n = -2 mod p start = (-2) % p if start == 0: start = p ok[start::p] = bytearray(len(ok[start::p])) ok[0] = ok[1] = 0 return ok, x def twins(N, isp): return [n for n in range(2, N + 1) if isp[n] and n + 2 <= N and isp[n + 2]] def max_gap(xs): if len(xs) < 2: return 0 return max(b - a for a, b in zip(xs, xs[1:])) def main(): hr("0016 · REQUIREMENTS AND ACCEPTANCE — the bars, thresholds and the gap bridge") # ---------------- 1 ---------------- hr("1 · critical-level identity above sqrt(N): A_x & (sqrt N, N] IS the twin set") for N in (10 ** 5, 10 ** 6): isp = sieve(N + 8) ok, x = admissible_set(N) A = [n for n in range(2, N + 1) if ok[n]] T = twins(N, isp) T_hi = [n for n in T if n > x] T_lo = [n for n in T if n <= x] print(" N = %-9d x = %-6d |A_x| = %-7d pi_2(N) = %-7d pi_2(x) = %-4d" % (N, x, len(A), len(T), len(T_lo))) print(" %-9s A_x & (x,N] equals the twins above x: %s (pi_2(N)-pi_2(x) = %d)" % ("", A == T_hi, len(T_hi))) print() print(" Proof: if n > x and n or n+2 were composite, it would have a prime") print(" factor <= sqrt(n+2) <= x, contradicting n in A_x. Conversely a prime") print(" n <= x DIVIDES x# (x# is the product of the primes <= x), so the twin") print(" pairs with n <= x are exactly the elements A_x misses. Hence") print(" |A_x & (x, N]| = pi_2(N) - pi_2(sqrt N) exactly,") print(" which is 0015's identity E_h(N,sqrt N) = pi_h(N) - pi_h(sqrt N).") print(" (The first draft of this programme asserted A_x & [2,N] = twin set;") print(" the check refuted it by pi_2(sqrt N) = 35 at N = 1e6. Corrected here.)") # ---------------- 2/4 ---------------- hr("2 · the pigeonhole gap bound, measured") print(" Lambda(N) = maximal gap between consecutive elements of A_x & (x, N]") print(" bound = pi_2(x) + (N - x) / (Lambda + 1) [pigeonhole]") print() print(" %-10s %-9s %-9s %-12s %-16s %s" % ("N", "pi_2(N)", "pi_2(x)", "Lambda", "pigeonhole bound", "holds?")) for N in (10 ** 5, 10 ** 6, 10 ** 7): isp = sieve(N + 8) ok, x = admissible_set(N) A = [n for n in range(x + 1, N + 1) if ok[n]] T = twins(N, isp) pi2 = len(T) pi2x = len([n for n in T if n <= x]) lam = max_gap(A) bound = pi2x + (N - x) / (lam + 1) print(" %-10d %-9d %-9d %-12d %-16.1f %s" % (N, pi2, pi2x, lam, bound, bound <= pi2)) print() print(" The pigeonhole is true but very weak: it gives pi_2(N) >> N/Lambda,") print(" and the measured Lambda grows only like a prime gap, so the bound is") print(" far below the truth. Its role is to fix the THRESHOLD, not to count.") # ---------------- 3 ---------------- hr("3 · the exponent threshold: Lambda <= N^(beta/2) needs beta < 2") print(" asymptotic pigeonhole: pi_2(N) >= N^(1 - beta/2) (up to constants)") print() hdr = " %-10s" % "beta" Ns = (10 ** 6, 10 ** 8) for N in Ns: hdr += " %-22s" % ("N=%d" % N) print(hdr) print(" %-10s" % "----" + "".join(" %-22s" % "----------------" for _ in Ns)) for beta in (1.5, 2.0, 2.5, 3.0, 4.26645): row = " %-10.5f" % beta for N in Ns: lam = N ** (beta / 2) if lam >= N: cell = "vacuous (Lambda>=N)" else: cell = "N^%.3f = %.3g" % (1 - beta / 2, N ** (1 - beta / 2)) row += " %-22s" % cell print(row) print() for N in Ns: isp = sieve(N + 8) print(" exact pi_2(%d) = %d" % (N, len(twins(N, isp)))) print() print(" beta = 2 is the edge: at beta = 2 the pigeonhole returns a constant.") print(" The corpus's record exponent is beta_2 = 4.26645, i.e. Lambda = N^2.133") print(" at level sqrt(N): larger than the window itself, hence vacuous. The") print(" corpus records the untouched region as the band (2, 4.26645] (#120/#121).") print() print(" CAVEAT (period vs window, corpus W5 / C3): the corpus's G_2(x#) is the") print(" maximal run over the FULL period x#, not over the window [0,N]. The") print(" period is e^x, far larger than N = x^2, so a period bound does not") print(" automatically bound the window gap. The window-to-period transport is") print(" itself one of the corpus's recorded obligations; a programme on this") print(" lane must supply it, and this script uses the window quantity Lambda.") # ---------------- 5 ---------------- hr("5 · convention translation a_k = 1 / beta_k (corpus return #121)") print(" %-28s %-14s %-14s" % ("quantity", "beta_k", "a_k = 1/beta_k")) for label, b in (("DHR dimension-2 record", 4.26645), ("LP floor quoted (#121)", 3.3152), ("quoted 1.8394 floor (#121)", 1.8394), ("threshold for the gap bridge", 2.0)): print(" %-28s %-14.5f %-14.5f" % (label, b, 1 / b)) print() print(" Under a_k = 1/beta_k an upper bound on the sifting limit a_k is a") print(" LOWER bound on beta_k, and conversely. Any programme moving beta_2") print(" must declare the convention and translate borrowed theorems into it;") print(" #121 records that this exact hazard produced a 22% vs 18% discrepancy") print(" in the corpus's own calibration.") # ---------------- 6 ---------------- hr("6 · distribution levels: known vs required (documentation)") rows = [ ("Bombieri-Vinogradov on average", "1/2", "known"), ("well-factorable weights (BFI)", "5/8", "known"), ("two-dimensional BV for the twin form", "all theta < 1", "OPEN (0007 Thm 2.11b)"), ("one-dimensional EH at every theta < 1", "all theta < 1", "insufficient (GPY-Maynard ceiling 12)"), ("the GPY-Maynard ceiling under full EH", "-", "gap 12, not 2"), ("mu-carrier at level 13/25 (route 55)", "13/25 = 0.52", "BLOCKED (parity, CR-11)"), ("obligation D signed Type-II term", "-", "BLOCKED (no published theorem)"), ] print(" %-46s %-18s %s" % ("input", "level", "status")) for a, b, c in rows: print(" %-46s %-18s %s" % (a, b, c)) hr("verdict") print(""" R1 A_x at x = sqrt(N) is the twin set ABOVE x: |A_x & (x,N]| = pi_2(N) - pi_2(sqrt N) exactly (verified at 1e5, 1e6); the pairs with n <= x are missed because n | x#. The count carries no sieve main term. R2 Pigeonhole: pi_2(N) >= (N - Lambda)/(Lambda + 2) with Lambda the maximal window gap; true and measured, but far weaker than the truth. R3 Threshold: Lambda <= N^(beta/2) gives pi_2(N) >= N^(1 - beta/2), so the bar is beta < 2. The record beta_2 = 4.26645 is vacuous at this level; the corpus's band is (2, 4.26645]. R4 The bridge is a RESTATEMENT in gap form, not a source of strength; its content is entirely the uniformity of the gap bound and the period-to- window transport a future programme must supply. R5 Convention hazard a_k = 1/beta_k is recorded (#121); moving beta_2 is meaningless until the convention is declared. R6 Known distribution tops out at 5/8 (well-factorable); the two-dimensional input 0007 needs (all theta < 1) is open, and one-dimensional EH cannot reach it (ceiling 12). Nothing here proves TP or bounds G_2. """.rstrip()) if __name__ == "__main__": main()