Current task: —

← Session 35 — ii′-6-R: Lagarias 6.1 right-tail re-proof (E-032/D-073)

#2070 assistant 2026-08-26 02:21:02.985 UTC · 3957→5828 tok open ⤢
thinking (2839 chars)
§§3–6 written. Now E-033 script. Design (from my analysis): Checks: - V1: |ζ′/ζ(2)| = Z₀ certified: partial Dirichlet sum + tail bound ⊂ [0.5699, 0.5700]; cross-check mpmath. - V2: q(c) table: q(1) > 1 (bug), q(c) < 1 for c ≥ 1.25; boundary c* = 1/√log2 ∈ [1.2011, 1.2013]. - V3: R(c) vs E-032 measured |I_right| (read from E-032 CSV): R(1.5) ≥ max measured at c=1.5 (1.12/1.14/1.00); R(2) ≥ measured (0.62/0.31/0.35). - V4: kernel charge: max over σ-grid on [−3,3] of |k_n(σ+iT)| ≤ e^{4/c²}+1 at n = 10⁵, T = c√n, c ∈ {1.5, 2}. - V5: fold fit: NI(T) + 5.5(10.5 log(T+2)+48) ≤ 7·Ĥ(T) on grid, T = c√n+1, c ∈ {1.5, 2}; report max ratio. - V6: margin(n; c) = sInftyLower(n) − Bn_c(n) + 1 > 0 on dense log grid [8e4, N₁(c)], c ∈ {1.5, 2}; report margin at base points (8e4, 1e5) and at N₁(c). - V7: full fold honest_assembly_c(n) ≤ Bn_c(n) on the grid (identical pieces except horizontal — implied by V5, but verify the bookkeeping). Bn_c(n) := 4FAlt(T) + 4T[(2/3)Z2(T) + 10.5 log(T+2) + 48] + 40·1.3352 + 2(e^{4/c²}+1)(7Ĥ(T) + R(c)) + IIMaj_c(n) + 1, T = c√n+1. honest_c(n) := 4FAlt(T) + 4T[...] + 40·1.3352 + 2(e^{4/c²}+1)(NI + 5.5(10.5 log(T+2)+48) + R(c)) + IIMaj_c(n) + 1. IIMaj_c(n) := 2(c√n+1)(e^{√n/2}+1)·0.57·2^{−(2√n−2)}. NI(T) := Z2(T)·2·log(16.5·9·C0hat(c√n+2)) [c_clear = 1/(9·C0hat(a+2)), a = c√n; log(16.5/c_clear) = log(16.5·9·C0hat(a+2))]. Hhat(T) := 3·C0hat(T)² + 10.5·log(T+2) + 48. sInftyLower(n) := 0.5 n log n − 1.41894 n − 4. FAlt, Z2, C0hat as in E-030. N₁(c) = ((3e12 − 1)/c)². Grid: base points [8e4, 1e5] + log grid 1e5 → N₁(c) with 30 points per c. Also tabulate for D-073 §5: R(c), kernel, margin at N₁, max fold ratio for c ∈ {1.25, 1.3, 1.5, 1.75, 2}. For V1 certification: partial sum S_K = Σ_{k=2}^{K} Λ(k)/k² + tail bound: Σ_{k>K} Λ(k)/k² ≤ (log(K−1)+1)/(K−1)·... — use the same certified form: Σ_{k>K} Λ(k)k^{−2} ≤ ∫_{K−1}^∞ log x/x² dx = (log(K−1)+1)/(K−1). At K = 25000: (10.13+1)/24999 ≈ 4.45e-4. So Z₀ ∈ [S_K, S_K + 4.5e-4]. Check S_K ∈ [0.5695, 0.5700]. Good enough (we need Z₀ to ~1e-3 for R(c); R is charged with Z₀ upper bound + tail: use Z₀_hi = S_K + tail_hi in R). For the script: compute Z0_lo = S_K, Z0_hi = S_K + (log(K−1)+1)/(K−1); use Z0_hi in R(c) for honesty; report Z0 and mpmath cross-check. Reuse the sieve from E-032 (copy the code). Kernel charge V4: max over σ ∈ [−3, 3] grid (step 0.05) of |(1+1/(σ+iT))ⁿ − 1| — at n=10⁵, T = c√10⁵: values near σ=3: |1+1/(3+iT)|ⁿ ~ (1 + 4/(9+T²))ⁿ ~ e^{4n/T²}·... plus the −1: |k_n| ≤ |(1+1/s)ⁿ|+1 — the check: max|k_n| ≤ e^{4/c²}+1. Direct evaluation. The fold-fit V5 ratio: (NI + 5.5(10.5 log+48))/(7Ĥ) — should be < 1 (E-030 got 0.40 at c=1). At c=2, T doubles: NI grows ~ loglog-ish, 7Ĥ grows ~ (log T)² — ratio should stay < 1 comfortably. Verify. Runtime: trivial (all closed forms). Foreground run, < 1 min. Write the script.
§§3–6 written. Now the E-033 cross-validation script.
tool: Write
input
{
  "file_path": "D:\\Python\\Quantum\\research\\numerics\\scripts\\E-033-repaired-stepping-validation.py",
  "content": "#!/usr/bin/env python3\n\"\"\"E-033 \u2014 F-D side thread ii\u2032-6-R, sub-stage 6-R-1 (deliverable D2-v):\ncross-validation of ALL constants in the repaired horizontal proof\n(D-073 \u00a7\u00a74\u20136): the corrected stepping lemma at T = c.sqrt(n),\nc > 1/sqrt(log 2), with the explicit right-tail bound\n\n    R(c) := Z0 . [ e^{4/c^2} / (4(1-q) log 2) + 1/(2 log 2) ],\n    q := e^{1/c^2}/2,  Z0 := |zeta'/zeta(2)|.\n\nChecks:\n  V1: Z0 certified: partial Dirichlet sum + certified tail bound\n      bracketing |zeta'/zeta(2)| (mpmath cross-check).\n  V2: the q-table: q(1) > 1 (the F-D bug), q(c) < 1 for c in\n      {1.25, 1.3, 1.5, 1.75, 2}; boundary c* = 1/sqrt(log 2) in\n      [1.2011, 1.2013].\n  V3: R(c) covers the E-032 MEASURED |I_right| at c = 1.5, 2\n      (reads the committed E-032 CSV; n = 1e3, 1e4, 1e5).\n  V4: kernel charge: max_{sigma in [-3,3]} |k_n(sigma+iT)| <= e^{4/c^2}+1\n      at n = 1e5, T = c.sqrt(n), c in {1.5, 2} (direct evaluation,\n      0.02 grid).\n  V5: horizontal fold fit at T = c.sqrt(n)+1:\n      NI(T) + 5.5(10.5 log(T+2)+48) <= 7.Hhat(T) on the grid,\n      c in {1.5, 2} (the E-030 V3 analogue at the repaired height).\n  V6: margin(n; c) = sInftyLower(n) - Bn_c(n) + 1 > 0 on a dense log\n      grid over [8e4, N1(c)], N1(c) = ((3e12-1)/c)^2, c in {1.5, 2}.\n  V7: full fold honest_c(n) <= Bn_c(n) on the grid (E-030 V4 analogue).\n\nAll numerics dps 50, deterministic; reads E-032 CSV (committed data).\n\"\"\"\nimport csv as csvmod\nimport json\nimport sys\nfrom pathlib import Path\n\nimport mpmath as mp\n\nmp.mp.dps = 50\n\nDATA = Path(__file__).resolve().parent.parent / \"data\"\nCSV = DATA / \"E-033-repaired-stepping-validation.csv\"\nJSON = DATA / \"E-033-repaired-stepping-validation.json\"\nE032CSV = DATA / \"E-032-horizontal-true-integral.csv\"\n\npi, e = mp.pi, mp.e\nLOG2 = mp.log(2)\n\nSIEVE_MAX = 25000\n_spf = list(range(SIEVE_MAX + 1))\nfor _i in range(2, int(SIEVE_MAX ** 0.5) + 1):\n    if _spf[_i] == _i:\n        for _j in range(_i * _i, SIEVE_MAX + 1, _i):\n            if _spf[_j] == _j:\n                _spf[_j] = _i\nLAM = [mp.mpf(0)] * (SIEVE_MAX + 1)\nLOGK = [mp.mpf(0)] * (SIEVE_MAX + 1)\nfor _k in range(2, SIEVE_MAX + 1):\n    LOGK[_k] = mp.log(_k)\n    _p = _spf[_k]\n    _m = _k\n    while _m % _p == 0:\n        _m //= _p\n    if _m == 1:\n        LAM[_k] = LOGK[_p]\n\n\ndef Z0_bracket(K=25000):\n    \"\"\"|zeta'/zeta(2)| = sum Lambda(k)/k^2, certified tail\n    <= integral_{K-1}^inf log x / x^2 dx = (log(K-1)+1)/(K-1).\"\"\"\n    s = mp.mpf(0)\n    for k in range(2, K + 1):\n        if LAM[k]:\n            s += LAM[k] / (mp.mpf(k) ** 2)\n    tail = (mp.log(K - 1) + 1) / (K - 1)\n    return s, s + tail\n\n\ndef qc(c):\n    return e ** (1 / mp.mpf(c) ** 2) / 2\n\n\ndef Rc(c, Z0hi):\n    c = mp.mpf(c)\n    q = qc(c)\n    return Z0hi * (e ** (4 / c ** 2) / (4 * (1 - q) * LOG2) + 1 / (2 * LOG2))\n\n\ndef kernel_charge(c):\n    return e ** (4 / mp.mpf(c) ** 2) + 1\n\n\ndef C0hat(t):\n    return mp.mpf(\"0.433\") * mp.log(t + 2) + mp.mpf(\"0.886\") * mp.log(mp.log(t + 2)) + mp.mpf(\"2.9\")\n\n\ndef Z2(t):\n    return mp.mpf(\"0.6\") * mp.log(t + 2) + mp.mpf(\"0.886\") * mp.log(mp.log(t + 2)) + mp.mpf(\"2.7\")\n\n\ndef FAlt(T):\n    return ((1 / (2 * pi)) * (T * mp.log(T)) + mp.mpf(\"0.137\") * mp.log(T)\n            + mp.mpf(\"0.443\") * mp.log(mp.log(T)) + (mp.mpf(7) / 8 + mp.mpf(\"1.588\")))\n\n\ndef Hhat(T):\n    return 3 * C0hat(T) ** 2 + mp.mpf(\"10.5\") * mp.log(T + 2) + 48\n\n\ndef NI(T, a):\n    \"\"\"Near-sum integral on the horizontal at height T, pigeonhole\n    window [a, a+1], clearance 1/(9.C0hat(a+2)).\"\"\"\n    c_clear = 1 / (9 * C0hat(a + 2))\n    return Z2(T) * 2 * mp.log(mp.mpf(\"16.5\") / c_clear)\n\n\ndef IIMaj_c(n, c):\n    return 2 * (c * mp.sqrt(n) + 1) * (mp.e ** (mp.sqrt(n) / 2) + 1) * mp.mpf(\"0.57\") * 2 ** (-(2 * mp.sqrt(n) - 2))\n\n\ndef Bn_c(n, c, Z0hi):\n    T = c * mp.sqrt(n) + 1\n    return (4 * FAlt(T) + 4 * T * ((mp.mpf(2) / 3) * Z2(T) + mp.mpf(\"10.5\") * mp.log(T + 2) + 48)\n            + 40 * mp.mpf(\"1.3352\")\n            + 2 * kernel_charge(c) * (7 * Hhat(T) + Rc(c, Z0hi))\n            + IIMaj_c(n, c) + 1)\n\n\ndef honest_c(n, c, Z0hi):\n    T = c * mp.sqrt(n) + 1\n    a = c * mp.sqrt(n)\n    horiz = 2 * kernel_charge(c) * (NI(T, a) + mp.mpf(\"5.5\") * (mp.mpf(\"10.5\") * mp.log(T + 2) + 48)\n                                    + Rc(c, Z0hi))\n    return (4 * FAlt(T) + 4 * T * ((mp.mpf(2) / 3) * Z2(T) + mp.mpf(\"10.5\") * mp.log(T + 2) + 48)\n            + 40 * mp.mpf(\"1.3352\") + horiz + IIMaj_c(n, c) + 1)\n\n\ndef sInftyLower(n):\n    return mp.mpf(\"0.5\") * n * mp.log(n) + (mp.mpf(\"-1.41894\")) * n - 4\n\n\ndef N1(c):\n    return ((mp.mpf(\"3e12\") - 1) / c) ** 2\n\n\ndef main() -> int:\n    if JSON.exists() and \"--force\" not in sys.argv:\n        print(f\"cached: {JSON} (use --force to recompute)\")\n        return 0\n\n    rows = []\n\n    # V1: Z0 certified\n    zlo, zhi = Z0_bracket()\n    zmp = -mp.zeta(2, derivative=1) / mp.zeta(2)\n    v1 = zlo <= zmp <= zhi and mp.mpf(\"0.5699\") < zlo and zhi < mp.mpf(\"0.5700\")\n    rows.append({\"check\": \"V1_Z0_certified\", \"c\": \"\", \"n\": \"\",\n                 \"value_lo\": mp.nstr(zlo, 12), \"value_hi\": mp.nstr(zhi, 12),\n                 \"mpmath\": mp.nstr(zmp, 12), \"pass\": str(bool(v1))})\n\n    # V2: q-table + boundary\n    cs = [\"1\", \"1.25\", \"1.3\", \"1.5\", \"1.75\", \"2\"]\n    qtab = {c: qc(mp.mpf(c)) for c in cs}\n    cstar = 1 / mp.sqrt(LOG2)\n    v2 = qtab[\"1\"] > 1 and all(qtab[c] < 1 for c in cs[1:]) \\\n        and mp.mpf(\"1.2011\") < cstar < mp.mpf(\"1.2013\")\n    for c in cs:\n        rows.append({\"check\": \"V2_q_table\", \"c\": c, \"n\": \"\",\n                     \"value_lo\": mp.nstr(qtab[c], 6),\n                     \"value_hi\": mp.nstr(Rc(mp.mpf(c), zhi), 6),\n                     \"mpmath\": mp.nstr(kernel_charge(mp.mpf(c)), 6) if c != \"1\" else \"\",\n                     \"pass\": str(bool(qtab[c] < 1))})\n    rows.append({\"check\": \"V2_c_boundary\", \"c\": \"c*\", \"n\": \"\",\n                 \"value_lo\": mp.nstr(cstar, 8), \"value_hi\": \"1/sqrt(log2)\",\n                 \"mpmath\": \"\", \"pass\": str(bool(mp.mpf(\"1.2011\") < cstar < mp.mpf(\"1.2013\")))})\n\n    # V3: R(c) covers the E-032 measured |I_right|\n    measured = {}\n    with E032CSV.open() as f:\n        for r in csvmod.DictReader(f):\n            if r[\"check\"] == \"right_part\" and r[\"c\"] in (\"1.5\", \"2.0\"):\n                measured[(int(r[\"n\"]), mp.mpf(r[\"c\"]))] = mp.mpf(r[\"abs_I_right\"])\n    v3 = True\n    for (n, c), val in sorted(measured.items()):\n        ok = Rc(c, zhi) >= val\n        v3 = v3 and ok\n        rows.append({\"check\": \"V3_R_covers_measured\", \"c\": mp.nstr(c, 3), \"n\": str(n),\n                     \"value_lo\": mp.nstr(val, 6), \"value_hi\": mp.nstr(Rc(c, zhi), 6),\n                     \"mpmath\": \"\", \"pass\": str(bool(ok))})\n\n    # V4: kernel charge on [-3,3]\n    n = 10 ** 5\n    v4 = True\n    for c in [mp.mpf(\"1.5\"), mp.mpf(\"2\")]:\n        T = c * mp.sqrt(n)\n        mx = mp.mpf(0)\n        sig = mp.mpf(-3)\n        while sig <= 3:\n            v = abs((1 + 1 / mp.mpc(sig, T)) ** n - 1)\n            if v > mx:\n                mx = v\n            sig += mp.mpf(\"0.02\")\n        ok = mx <= kernel_charge(c)\n        v4 = v4 and ok\n        rows.append({\"check\": \"V4_kernel_charge\", \"c\": mp.nstr(c, 3), \"n\": str(n),\n                     \"value_lo\": mp.nstr(mx, 6), \"value_hi\": mp.nstr(kernel_charge(c), 6),\n                     \"mpmath\": \"\", \"pass\": str(bool(ok))})\n\n    # grids\n    def loggrid(lo, hi, pts):\n        llo, lhi = mp.log(lo), mp.log(hi)\n        return [mp.e ** (llo + (lhi - llo) * i / (pts - 1)) for i in range(pts)]\n\n    # V5/V6/V7 per c\n    v5, v6, v7 = True, True, True\n    for c in [mp.mpf(\"1.5\"), mp.mpf(\"2\")]:\n        grid = [mp.mpf(\"8e4\"), mp.mpf(\"1e5\")] + loggrid(mp.mpf(\"1e5\"), N1(c), 30)\n        maxfit = mp.mpf(0)\n        minmargin = None\n        for nn in grid:\n            T = c * mp.sqrt(nn) + 1\n            a = c * mp.sqrt(nn)\n            fit = (NI(T, a) + mp.mpf(\"5.5\") * (mp.mpf(\"10.5\") * mp.log(T + 2) + 48)) / (7 * Hhat(T))\n            if fit > maxfit:\n                maxfit = fit\n            v5 = v5 and (fit < 1)\n            marg = sInftyLower(nn) - Bn_c(nn, c, zhi) + 1\n            if minmargin is None or marg < minmargin:\n                minmargin = marg\n            v6 = v6 and (marg > 0)\n            v7 = v7 and (honest_c(nn, c, zhi) <= Bn_c(nn, c, zhi))\n        rows.append({\"check\": \"V5_fold_fit_max_ratio\", \"c\": mp.nstr(c, 3), \"n\": \"grid\",\n                     \"value_lo\": mp.nstr(maxfit, 4), \"value_hi\": \"< 1\",\n                     \"mpmath\": \"\", \"pass\": str(bool(maxfit < 1))})\n        rows.append({\"check\": \"V6_margin_min_on_grid\", \"c\": mp.nstr(c, 3), \"n\": \"grid\",\n                     \"value_lo\": mp.nstr(minmargin, 6), \"value_hi\": \"> 0\",\n                     \"mpmath\": \"\", \"pass\": str(bool(minmargin > 0))})\n        for nn in [mp.mpf(\"8e4\"), mp.mpf(\"1e5\"), N1(c)]:\n            marg = sInftyLower(nn) - Bn_c(nn, c, zhi) + 1\n            rows.append({\"check\": \"V6_margin_value\", \"c\": mp.nstr(c, 3), \"n\": mp.nstr(nn, 8),\n                         \"value_lo\": mp.nstr(marg, 8), \"value_hi\": \"> 0\",\n                         \"mpmath\": \"\", \"pass\": str(bool(marg > 0))})\n        rows.append({\"check\": \"V7_full_fold\", \"c\": mp.nstr(c, 3), \"n\": \"grid\",\n                     \"value_lo\": \"honest<=Bn\", \"value_hi\": \"\",\n                     \"mpmath\": \"\", \"pass\": \"see above\"})\n\n    # recompute v7 cleanly (the row above is a placeholder)\n    v7 = all(honest_c(nn, c, zhi) <= Bn_c(nn, c, zhi)\n             for c in [mp.mpf(\"1.5\"), mp.mpf(\"2\")]\n             for nn in [mp.mpf(\"8e4\"), mp.mpf(\"1e5\")] + loggrid(mp.mpf(\"1e5\"), N1(c), 30))\n\n    allpass = v1 and v2 and v3 and v4 and v5 and v6 and v7\n\n    DATA.mkdir(exist_ok=True)\n    with CSV.open(\"w\") as f:\n        f.write(\",\".join(rows[0].keys()) + \"\\n\")\n        for r in rows:\n            f.write(\",\".join(r.values()) + \"\\n\")\n    sidecar = {\n        \"experiment\": \"E-033\",\n        \"title\": \"F-D side thread 6-R-1: cross-validation of the repaired-stepping \"\n                 \"constants (D-073 secs.4-6): Z0 certified, q-table, R(c) vs E-032 \"\n                 \"measured, kernel charge, fold fit, margins at c = 1.5 and 2\",\n        \"session\": \"039\",\n        \"thread\": \"ii-prime-6-R\",\n        \"design_doc\": \"D-073\",\n        \"checks\": {\"V1_Z0_certified\": bool(v1), \"V2_q_table_and_boundary\": bool(v2),\n                   \"V3_R_covers_E032_measured\": bool(v3), \"V4_kernel_charge\": bool(v4),\n                   \"V5_fold_fit\": bool(v5), \"V6_margin_positive\": bool(v6),\n                   \"V7_full_fold\": bool(v7)},\n        \"all_checks_pass\": bool(allpass),\n        \"dps\": 50,\n        \"constants\": {\"Z0_lo\": mp.nstr(zlo, 12), \"Z0_hi\": mp.nstr(zhi, 12),\n                      \"q_1.5\": mp.nstr(qc(mp.mpf(\"1.5\")), 8),\n                      \"q_2\": mp.nstr(qc(mp.mpf(\"2\")), 8),\n                      \"R_1.5\": mp.nstr(Rc(mp.mpf(\"1.5\"), zhi), 8),\n                      \"R_2\": mp.nstr(Rc(mp.mpf(\"2\"), zhi), 8),\n                      \"kernel_1.5\": mp.nstr(kernel_charge(mp.mpf(\"1.5\")), 8),\n                      \"kernel_2\": mp.nstr(kernel_charge(mp.mpf(\"2\")), 8),\n                      \"N1_1.5\": mp.nstr(N1(mp.mpf(\"1.5\")), 6),\n                      \"N1_2\": mp.nstr(N1(mp.mpf(\"2\")), 6)},\n        \"notes\": \"Recommendation (D-073 sec.5): c = 2 for the main line \"\n                 \"(R = 1.97 < 3.3 broken charge, kernel 3.72 < 55.6, N1 = 2.25e24); \"\n                 \"c = 1.5 the range option (N1 = 4e24, R = 5.94, kernel 6.92).\",\n    }\n    with JSON.open(\"w\") as f:\n        json.dump(sidecar, f, indent=2)\n    print(f\"V1 {bool(v1)} V2 {bool(v2)} V3 {bool(v3)} V4 {bool(v4)} \"\n          f\"V5 {bool(v5)} V6 {bool(v6)} V7 {bool(v7)}\")\n    print(f\"wrote {CSV} + {JSON}\")\n    return 0 if sidecar[\"all_checks_pass\"] else 1\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n"
}
raw content_json (database row)
[{"type":"thinking","thinking":"§§3–6 written. Now E-033 script. Design (from my analysis):\n\nChecks:\n- V1: |ζ′/ζ(2)| = Z₀ certified: partial Dirichlet sum + tail bound ⊂ [0.5699, 0.5700]; cross-check mpmath.\n- V2: q(c) table: q(1) > 1 (bug), q(c) < 1 for c ≥ 1.25; boundary c* = 1/√log2 ∈ [1.2011, 1.2013].\n- V3: R(c) vs E-032 measured |I_right| (read from E-032 CSV): R(1.5) ≥ max measured at c=1.5 (1.12/1.14/1.00); R(2) ≥ measured (0.62/0.31/0.35).\n- V4: kernel charge: max over σ-grid on [−3,3] of |k_n(σ+iT)| ≤ e^{4/c²}+1 at n = 10⁵, T = c√n, c ∈ {1.5, 2}.\n- V5: fold fit: NI(T) + 5.5(10.5 log(T+2)+48) ≤ 7·Ĥ(T) on grid, T = c√n+1, c ∈ {1.5, 2}; report max ratio.\n- V6: margin(n; c) = sInftyLower(n) − Bn_c(n) + 1 > 0 on dense log grid [8e4, N₁(c)], c ∈ {1.5, 2}; report margin at base points (8e4, 1e5) and at N₁(c).\n- V7: full fold honest_assembly_c(n) ≤ Bn_c(n) on the grid (identical pieces except horizontal — implied by V5, but verify the bookkeeping).\n\nBn_c(n) := 4FAlt(T) + 4T[(2/3)Z2(T) + 10.5 log(T+2) + 48] + 40·1.3352 + 2(e^{4/c²}+1)(7Ĥ(T) + R(c)) + IIMaj_c(n) + 1, T = c√n+1.\nhonest_c(n) := 4FAlt(T) + 4T[...] + 40·1.3352 + 2(e^{4/c²}+1)(NI + 5.5(10.5 log(T+2)+48) + R(c)) + IIMaj_c(n) + 1.\nIIMaj_c(n) := 2(c√n+1)(e^{√n/2}+1)·0.57·2^{−(2√n−2)}.\nNI(T) := Z2(T)·2·log(16.5·9·C0hat(c√n+2)) [c_clear = 1/(9·C0hat(a+2)), a = c√n; log(16.5/c_clear) = log(16.5·9·C0hat(a+2))].\nHhat(T) := 3·C0hat(T)² + 10.5·log(T+2) + 48.\nsInftyLower(n) := 0.5 n log n − 1.41894 n − 4.\nFAlt, Z2, C0hat as in E-030.\n\nN₁(c) = ((3e12 − 1)/c)².\n\nGrid: base points [8e4, 1e5] + log grid 1e5 → N₁(c) with 30 points per c.\n\nAlso tabulate for D-073 §5: R(c), kernel, margin at N₁, max fold ratio for c ∈ {1.25, 1.3, 1.5, 1.75, 2}.\n\nFor V1 certification: partial sum S_K = Σ_{k=2}^{K} Λ(k)/k² + tail bound: Σ_{k>K} Λ(k)/k² ≤ (log(K−1)+1)/(K−1)·... — use the same certified form: Σ_{k>K} Λ(k)k^{−2} ≤ ∫_{K−1}^∞ log x/x² dx = (log(K−1)+1)/(K−1). At K = 25000: (10.13+1)/24999 ≈ 4.45e-4. So Z₀ ∈ [S_K, S_K + 4.5e-4]. Check S_K ∈ [0.5695, 0.5700]. Good enough (we need Z₀ to ~1e-3 for R(c); R is charged with Z₀ upper bound + tail: use Z₀_hi = S_K + tail_hi in R). For the script: compute Z0_lo = S_K, Z0_hi = S_K + (log(K−1)+1)/(K−1); use Z0_hi in R(c) for honesty; report Z0 and mpmath cross-check.\n\nReuse the sieve from E-032 (copy the code).\n\nKernel charge V4: max over σ ∈ [−3, 3] grid (step 0.05) of |(1+1/(σ+iT))ⁿ − 1| — at n=10⁵, T = c√10⁵: values near σ=3: |1+1/(3+iT)|ⁿ ~ (1 + 4/(9+T²))ⁿ ~ e^{4n/T²}·... plus the −1: |k_n| ≤ |(1+1/s)ⁿ|+1 — the check: max|k_n| ≤ e^{4/c²}+1. Direct evaluation.\n\nThe fold-fit V5 ratio: (NI + 5.5(10.5 log+48))/(7Ĥ) — should be < 1 (E-030 got 0.40 at c=1). At c=2, T doubles: NI grows ~ loglog-ish, 7Ĥ grows ~ (log T)² — ratio should stay < 1 comfortably. Verify.\n\nRuntime: trivial (all closed forms). Foreground run, < 1 min. \n\nWrite the script.","signature":""},{"type":"text","text":"§§3–6 written. Now the E-033 cross-validation script."},{"type":"tool_use","id":"Write_35","name":"Write","input":{"file_path":"D:\\Python\\Quantum\\research\\numerics\\scripts\\E-033-repaired-stepping-validation.py","content":"#!/usr/bin/env python3\n\"\"\"E-033 — F-D side thread ii′-6-R, sub-stage 6-R-1 (deliverable D2-v):\ncross-validation of ALL constants in the repaired horizontal proof\n(D-073 §§4–6): the corrected stepping lemma at T = c.sqrt(n),\nc > 1/sqrt(log 2), with the explicit right-tail bound\n\n    R(c) := Z0 . [ e^{4/c^2} / (4(1-q) log 2) + 1/(2 log 2) ],\n    q := e^{1/c^2}/2,  Z0 := |zeta'/zeta(2)|.\n\nChecks:\n  V1: Z0 certified: partial Dirichlet sum + certified tail bound\n      bracketing |zeta'/zeta(2)| (mpmath cross-check).\n  V2: the q-table: q(1) > 1 (the F-D bug), q(c) < 1 for c in\n      {1.25, 1.3, 1.5, 1.75, 2}; boundary c* = 1/sqrt(log 2) in\n      [1.2011, 1.2013].\n  V3: R(c) covers the E-032 MEASURED |I_right| at c = 1.5, 2\n      (reads the committed E-032 CSV; n = 1e3, 1e4, 1e5).\n  V4: kernel charge: max_{sigma in [-3,3]} |k_n(sigma+iT)| <= e^{4/c^2}+1\n      at n = 1e5, T = c.sqrt(n), c in {1.5, 2} (direct evaluation,\n      0.02 grid).\n  V5: horizontal fold fit at T = c.sqrt(n)+1:\n      NI(T) + 5.5(10.5 log(T+2)+48) <= 7.Hhat(T) on the grid,\n      c in {1.5, 2} (the E-030 V3 analogue at the repaired height).\n  V6: margin(n; c) = sInftyLower(n) - Bn_c(n) + 1 > 0 on a dense log\n      grid over [8e4, N1(c)], N1(c) = ((3e12-1)/c)^2, c in {1.5, 2}.\n  V7: full fold honest_c(n) <= Bn_c(n) on the grid (E-030 V4 analogue).\n\nAll numerics dps 50, deterministic; reads E-032 CSV (committed data).\n\"\"\"\nimport csv as csvmod\nimport json\nimport sys\nfrom pathlib import Path\n\nimport mpmath as mp\n\nmp.mp.dps = 50\n\nDATA = Path(__file__).resolve().parent.parent / \"data\"\nCSV = DATA / \"E-033-repaired-stepping-validation.csv\"\nJSON = DATA / \"E-033-repaired-stepping-validation.json\"\nE032CSV = DATA / \"E-032-horizontal-true-integral.csv\"\n\npi, e = mp.pi, mp.e\nLOG2 = mp.log(2)\n\nSIEVE_MAX = 25000\n_spf = list(range(SIEVE_MAX + 1))\nfor _i in range(2, int(SIEVE_MAX ** 0.5) + 1):\n    if _spf[_i] == _i:\n        for _j in range(_i * _i, SIEVE_MAX + 1, _i):\n            if _spf[_j] == _j:\n                _spf[_j] = _i\nLAM = [mp.mpf(0)] * (SIEVE_MAX + 1)\nLOGK = [mp.mpf(0)] * (SIEVE_MAX + 1)\nfor _k in range(2, SIEVE_MAX + 1):\n    LOGK[_k] = mp.log(_k)\n    _p = _spf[_k]\n    _m = _k\n    while _m % _p == 0:\n        _m //= _p\n    if _m == 1:\n        LAM[_k] = LOGK[_p]\n\n\ndef Z0_bracket(K=25000):\n    \"\"\"|zeta'/zeta(2)| = sum Lambda(k)/k^2, certified tail\n    <= integral_{K-1}^inf log x / x^2 dx = (log(K-1)+1)/(K-1).\"\"\"\n    s = mp.mpf(0)\n    for k in range(2, K + 1):\n        if LAM[k]:\n            s += LAM[k] / (mp.mpf(k) ** 2)\n    tail = (mp.log(K - 1) + 1) / (K - 1)\n    return s, s + tail\n\n\ndef qc(c):\n    return e ** (1 / mp.mpf(c) ** 2) / 2\n\n\ndef Rc(c, Z0hi):\n    c = mp.mpf(c)\n    q = qc(c)\n    return Z0hi * (e ** (4 / c ** 2) / (4 * (1 - q) * LOG2) + 1 / (2 * LOG2))\n\n\ndef kernel_charge(c):\n    return e ** (4 / mp.mpf(c) ** 2) + 1\n\n\ndef C0hat(t):\n    return mp.mpf(\"0.433\") * mp.log(t + 2) + mp.mpf(\"0.886\") * mp.log(mp.log(t + 2)) + mp.mpf(\"2.9\")\n\n\ndef Z2(t):\n    return mp.mpf(\"0.6\") * mp.log(t + 2) + mp.mpf(\"0.886\") * mp.log(mp.log(t + 2)) + mp.mpf(\"2.7\")\n\n\ndef FAlt(T):\n    return ((1 / (2 * pi)) * (T * mp.log(T)) + mp.mpf(\"0.137\") * mp.log(T)\n            + mp.mpf(\"0.443\") * mp.log(mp.log(T)) + (mp.mpf(7) / 8 + mp.mpf(\"1.588\")))\n\n\ndef Hhat(T):\n    return 3 * C0hat(T) ** 2 + mp.mpf(\"10.5\") * mp.log(T + 2) + 48\n\n\ndef NI(T, a):\n    \"\"\"Near-sum integral on the horizontal at height T, pigeonhole\n    window [a, a+1], clearance 1/(9.C0hat(a+2)).\"\"\"\n    c_clear = 1 / (9 * C0hat(a + 2))\n    return Z2(T) * 2 * mp.log(mp.mpf(\"16.5\") / c_clear)\n\n\ndef IIMaj_c(n, c):\n    return 2 * (c * mp.sqrt(n) + 1) * (mp.e ** (mp.sqrt(n) / 2) + 1) * mp.mpf(\"0.57\") * 2 ** (-(2 * mp.sqrt(n) - 2))\n\n\ndef Bn_c(n, c, Z0hi):\n    T = c * mp.sqrt(n) + 1\n    return (4 * FAlt(T) + 4 * T * ((mp.mpf(2) / 3) * Z2(T) + mp.mpf(\"10.5\") * mp.log(T + 2) + 48)\n            + 40 * mp.mpf(\"1.3352\")\n            + 2 * kernel_charge(c) * (7 * Hhat(T) + Rc(c, Z0hi))\n            + IIMaj_c(n, c) + 1)\n\n\ndef honest_c(n, c, Z0hi):\n    T = c * mp.sqrt(n) + 1\n    a = c * mp.sqrt(n)\n    horiz = 2 * kernel_charge(c) * (NI(T, a) + mp.mpf(\"5.5\") * (mp.mpf(\"10.5\") * mp.log(T + 2) + 48)\n                                    + Rc(c, Z0hi))\n    return (4 * FAlt(T) + 4 * T * ((mp.mpf(2) / 3) * Z2(T) + mp.mpf(\"10.5\") * mp.log(T + 2) + 48)\n            + 40 * mp.mpf(\"1.3352\") + horiz + IIMaj_c(n, c) + 1)\n\n\ndef sInftyLower(n):\n    return mp.mpf(\"0.5\") * n * mp.log(n) + (mp.mpf(\"-1.41894\")) * n - 4\n\n\ndef N1(c):\n    return ((mp.mpf(\"3e12\") - 1) / c) ** 2\n\n\ndef main() -> int:\n    if JSON.exists() and \"--force\" not in sys.argv:\n        print(f\"cached: {JSON} (use --force to recompute)\")\n        return 0\n\n    rows = []\n\n    # V1: Z0 certified\n    zlo, zhi = Z0_bracket()\n    zmp = -mp.zeta(2, derivative=1) / mp.zeta(2)\n    v1 = zlo <= zmp <= zhi and mp.mpf(\"0.5699\") < zlo and zhi < mp.mpf(\"0.5700\")\n    rows.append({\"check\": \"V1_Z0_certified\", \"c\": \"\", \"n\": \"\",\n                 \"value_lo\": mp.nstr(zlo, 12), \"value_hi\": mp.nstr(zhi, 12),\n                 \"mpmath\": mp.nstr(zmp, 12), \"pass\": str(bool(v1))})\n\n    # V2: q-table + boundary\n    cs = [\"1\", \"1.25\", \"1.3\", \"1.5\", \"1.75\", \"2\"]\n    qtab = {c: qc(mp.mpf(c)) for c in cs}\n    cstar = 1 / mp.sqrt(LOG2)\n    v2 = qtab[\"1\"] > 1 and all(qtab[c] < 1 for c in cs[1:]) \\\n        and mp.mpf(\"1.2011\") < cstar < mp.mpf(\"1.2013\")\n    for c in cs:\n        rows.append({\"check\": \"V2_q_table\", \"c\": c, \"n\": \"\",\n                     \"value_lo\": mp.nstr(qtab[c], 6),\n                     \"value_hi\": mp.nstr(Rc(mp.mpf(c), zhi), 6),\n                     \"mpmath\": mp.nstr(kernel_charge(mp.mpf(c)), 6) if c != \"1\" else \"\",\n                     \"pass\": str(bool(qtab[c] < 1))})\n    rows.append({\"check\": \"V2_c_boundary\", \"c\": \"c*\", \"n\": \"\",\n                 \"value_lo\": mp.nstr(cstar, 8), \"value_hi\": \"1/sqrt(log2)\",\n                 \"mpmath\": \"\", \"pass\": str(bool(mp.mpf(\"1.2011\") < cstar < mp.mpf(\"1.2013\")))})\n\n    # V3: R(c) covers the E-032 measured |I_right|\n    measured = {}\n    with E032CSV.open() as f:\n        for r in csvmod.DictReader(f):\n            if r[\"check\"] == \"right_part\" and r[\"c\"] in (\"1.5\", \"2.0\"):\n                measured[(int(r[\"n\"]), mp.mpf(r[\"c\"]))] = mp.mpf(r[\"abs_I_right\"])\n    v3 = True\n    for (n, c), val in sorted(measured.items()):\n        ok = Rc(c, zhi) >= val\n        v3 = v3 and ok\n        rows.append({\"check\": \"V3_R_covers_measured\", \"c\": mp.nstr(c, 3), \"n\": str(n),\n                     \"value_lo\": mp.nstr(val, 6), \"value_hi\": mp.nstr(Rc(c, zhi), 6),\n                     \"mpmath\": \"\", \"pass\": str(bool(ok))})\n\n    # V4: kernel charge on [-3,3]\n    n = 10 ** 5\n    v4 = True\n    for c in [mp.mpf(\"1.5\"), mp.mpf(\"2\")]:\n        T = c * mp.sqrt(n)\n        mx = mp.mpf(0)\n        sig = mp.mpf(-3)\n        while sig <= 3:\n            v = abs((1 + 1 / mp.mpc(sig, T)) ** n - 1)\n            if v > mx:\n                mx = v\n            sig += mp.mpf(\"0.02\")\n        ok = mx <= kernel_charge(c)\n        v4 = v4 and ok\n        rows.append({\"check\": \"V4_kernel_charge\", \"c\": mp.nstr(c, 3), \"n\": str(n),\n                     \"value_lo\": mp.nstr(mx, 6), \"value_hi\": mp.nstr(kernel_charge(c), 6),\n                     \"mpmath\": \"\", \"pass\": str(bool(ok))})\n\n    # grids\n    def loggrid(lo, hi, pts):\n        llo, lhi = mp.log(lo), mp.log(hi)\n        return [mp.e ** (llo + (lhi - llo) * i / (pts - 1)) for i in range(pts)]\n\n    # V5/V6/V7 per c\n    v5, v6, v7 = True, True, True\n    for c in [mp.mpf(\"1.5\"), mp.mpf(\"2\")]:\n        grid = [mp.mpf(\"8e4\"), mp.mpf(\"1e5\")] + loggrid(mp.mpf(\"1e5\"), N1(c), 30)\n        maxfit = mp.mpf(0)\n        minmargin = None\n        for nn in grid:\n            T = c * mp.sqrt(nn) + 1\n            a = c * mp.sqrt(nn)\n            fit = (NI(T, a) + mp.mpf(\"5.5\") * (mp.mpf(\"10.5\") * mp.log(T + 2) + 48)) / (7 * Hhat(T))\n            if fit > maxfit:\n                maxfit = fit\n            v5 = v5 and (fit < 1)\n            marg = sInftyLower(nn) - Bn_c(nn, c, zhi) + 1\n            if minmargin is None or marg < minmargin:\n                minmargin = marg\n            v6 = v6 and (marg > 0)\n            v7 = v7 and (honest_c(nn, c, zhi) <= Bn_c(nn, c, zhi))\n        rows.append({\"check\": \"V5_fold_fit_max_ratio\", \"c\": mp.nstr(c, 3), \"n\": \"grid\",\n                     \"value_lo\": mp.nstr(maxfit, 4), \"value_hi\": \"< 1\",\n                     \"mpmath\": \"\", \"pass\": str(bool(maxfit < 1))})\n        rows.append({\"check\": \"V6_margin_min_on_grid\", \"c\": mp.nstr(c, 3), \"n\": \"grid\",\n                     \"value_lo\": mp.nstr(minmargin, 6), \"value_hi\": \"> 0\",\n                     \"mpmath\": \"\", \"pass\": str(bool(minmargin > 0))})\n        for nn in [mp.mpf(\"8e4\"), mp.mpf(\"1e5\"), N1(c)]:\n            marg = sInftyLower(nn) - Bn_c(nn, c, zhi) + 1\n            rows.append({\"check\": \"V6_margin_value\", \"c\": mp.nstr(c, 3), \"n\": mp.nstr(nn, 8),\n                         \"value_lo\": mp.nstr(marg, 8), \"value_hi\": \"> 0\",\n                         \"mpmath\": \"\", \"pass\": str(bool(marg > 0))})\n        rows.append({\"check\": \"V7_full_fold\", \"c\": mp.nstr(c, 3), \"n\": \"grid\",\n                     \"value_lo\": \"honest<=Bn\", \"value_hi\": \"\",\n                     \"mpmath\": \"\", \"pass\": \"see above\"})\n\n    # recompute v7 cleanly (the row above is a placeholder)\n    v7 = all(honest_c(nn, c, zhi) <= Bn_c(nn, c, zhi)\n             for c in [mp.mpf(\"1.5\"), mp.mpf(\"2\")]\n             for nn in [mp.mpf(\"8e4\"), mp.mpf(\"1e5\")] + loggrid(mp.mpf(\"1e5\"), N1(c), 30))\n\n    allpass = v1 and v2 and v3 and v4 and v5 and v6 and v7\n\n    DATA.mkdir(exist_ok=True)\n    with CSV.open(\"w\") as f:\n        f.write(\",\".join(rows[0].keys()) + \"\\n\")\n        for r in rows:\n            f.write(\",\".join(r.values()) + \"\\n\")\n    sidecar = {\n        \"experiment\": \"E-033\",\n        \"title\": \"F-D side thread 6-R-1: cross-validation of the repaired-stepping \"\n                 \"constants (D-073 secs.4-6): Z0 certified, q-table, R(c) vs E-032 \"\n                 \"measured, kernel charge, fold fit, margins at c = 1.5 and 2\",\n        \"session\": \"039\",\n        \"thread\": \"ii-prime-6-R\",\n        \"design_doc\": \"D-073\",\n        \"checks\": {\"V1_Z0_certified\": bool(v1), \"V2_q_table_and_boundary\": bool(v2),\n                   \"V3_R_covers_E032_measured\": bool(v3), \"V4_kernel_charge\": bool(v4),\n                   \"V5_fold_fit\": bool(v5), \"V6_margin_positive\": bool(v6),\n                   \"V7_full_fold\": bool(v7)},\n        \"all_checks_pass\": bool(allpass),\n        \"dps\": 50,\n        \"constants\": {\"Z0_lo\": mp.nstr(zlo, 12), \"Z0_hi\": mp.nstr(zhi, 12),\n                      \"q_1.5\": mp.nstr(qc(mp.mpf(\"1.5\")), 8),\n                      \"q_2\": mp.nstr(qc(mp.mpf(\"2\")), 8),\n                      \"R_1.5\": mp.nstr(Rc(mp.mpf(\"1.5\"), zhi), 8),\n                      \"R_2\": mp.nstr(Rc(mp.mpf(\"2\"), zhi), 8),\n                      \"kernel_1.5\": mp.nstr(kernel_charge(mp.mpf(\"1.5\")), 8),\n                      \"kernel_2\": mp.nstr(kernel_charge(mp.mpf(\"2\")), 8),\n                      \"N1_1.5\": mp.nstr(N1(mp.mpf(\"1.5\")), 6),\n                      \"N1_2\": mp.nstr(N1(mp.mpf(\"2\")), 6)},\n        \"notes\": \"Recommendation (D-073 sec.5): c = 2 for the main line \"\n                 \"(R = 1.97 < 3.3 broken charge, kernel 3.72 < 55.6, N1 = 2.25e24); \"\n                 \"c = 1.5 the range option (N1 = 4e24, R = 5.94, kernel 6.92).\",\n    }\n    with JSON.open(\"w\") as f:\n        json.dump(sidecar, f, indent=2)\n    print(f\"V1 {bool(v1)} V2 {bool(v2)} V3 {bool(v3)} V4 {bool(v4)} \"\n          f\"V5 {bool(v5)} V6 {bool(v6)} V7 {bool(v7)}\")\n    print(f\"wrote {CSV} + {JSON}\")\n    return 0 if sidecar[\"all_checks_pass\"] else 1\n\n\nif __name__ == \"__main__\":\n    sys.exit(main())\n"},"extra_content":null}]