#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Build the audit revision of the served `research/history/staging/recon-0830-smooth-aps.md`. Base = the copy fetched this window (sha256 c4665254…, 37741 bytes). Three edits, each asserted to occur exactly once: 1. the Delta definition becomes block-local (`E < e <= t`); 2. the statement's `Delta_a` becomes `Delta^bl_a`; 3. the "divided by E^2" calibration becomes the block-mass normalization, with the measured masses; 4. a correction rider is inserted after the orchestrator's 2026-08-30 rider. """ import hashlib import os RUN = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SRC = os.path.join(RUN, "evidence", "docs", "research__history__staging__recon-0830-smooth-aps.md") DST = os.path.join(RUN, "artifacts", "rev-recon-0830-aps.md") OLD_DEF = " Delta_a(t; d) = sum_{e <= t, e = a (d)} w(e) - (1/phi(d)) sum_{e <= t, (e,d)=1} w(e).\n" NEW_DEF = (" Delta^bl_a(t; d) = sum_{E < e <= t, e = a (d)} w(e)\n" " - (1/phi(d)) sum_{E < e <= t, (e,d)=1} w(e). " "[CORRECTED 2026-09-17: block-local; see the rider of that date]\n") OLD_STMT = " sum_{d <= Q} sum_{(a,d)=1} max_{t in [E, 2E]} |Delta_a(t; d)|^2 <= C_A ( log^{-A} E + Q/E )\n" NEW_STMT = " sum_{d <= Q} sum_{(a,d)=1} max_{t in [E, 2E]} |Delta^bl_a(t; d)|^2 <= C_A ( log^{-A} E + Q/E )\n" OLD_CAL = ("divided by `E^2` (the `1/e` in `w` costs a factor `1/E` on the block), with a\n") NEW_CAL = ("normalized by the BLOCK MASS SQUARED `M_bl^2` (the `1/e` in `w` costs a factor `1/E` on\n" "the block, so `M_bl = sum_{e ~ E} lam1(e) = O(1)` and NOT `~ E`: measured `0.15696`,\n" "`0.16900`, `0.17921` at `x = 19, 23, 29`; a division by `E^2` is the mass normalization\n" "only for a weight-one count, where mass and block length agree), with a\n") OLD_RIDER_END = "> misquotes of Thm 1/Thm 2 are recorded there, and this note's four channels\n> did not surface the 2025 paper.\n" RIDER = """ > **RIDER 2026-09-17 (return #767, job #1552: the `(H_w)` transfer written out).** Section 3.1 > printed `(H_w)` with a FULL-RANGE discrepancy while sections 3.2-3.3 consume a block-local one, > and its right side was calibrated as "Harper's Theorem 2 divided by `E^2`", which is a mass > normalization only for a weight-one count. Measured exactly at `x = 19, 23, 29`: the block mass > is `M_bl = 0.15696 / 0.16900 / 0.17921`, i.e. `O(1)`, and the block second moment is `S2 = C_2/E` > with `E*S2 = 0.22506 / 0.22909 / 0.23795`, while the FULL-RANGE second moment is the constant > `sum_{e <= 2E} w(e)^2 = 1.175` per modulus, independent of `E`. At the printed statement's own > smallest nontrivial modulus `d = 7`, `Q = 7`, `sum_a |Delta_a(2E; 7)|^2` reads > `0.7337 / 0.7324 / 0.7315` at the three `x`, against a right side `C_A (log^{-A} E + 7/E)` that > tends to `0`: **the printed statement was false**, for every `E` past a computable point, and > the corrected `(H_w')` of 3.1 above is the statement this note's own deduction consumes (the > block-local diagonal is `~ C_2/E` per modulus, and normalized by `M_bl^2` Harper's main term > `(Q/2) S2` reproduces the `Q/E` term). With that correction the transfer of section 3.4 closes > on the deduction's whole range given ONE named input, through two interlocking engines: Harper, > JLMS 112 (2025) e70293 = arXiv:2412.19644, Theorem 1 — for an ARBITRARY complex sequence, so the > `f`-twist and the sieve cost nothing there — covers `D > (4L/M)^{1/3}` at the price of a > Progressions-Condition Bombieri-Vinogradov-type input to level `2x/Q <= 2 sqrt E`; and Harper > arXiv:1208.5992v1 Theorem 2, whose range has no lower bound on `Q`, covers `E >= y`, i.e. > `D <= sqrt(L)/M`, at the price of steps (a)-(d), whose uniform-in-`a` sieve tail dies at > `D > (L/M)^{2/5}` — a threshold inside engine A's range, so the failing bookkeeping is never > invoked. Sections 3.2-3.3 stand unchanged; the three-branch type of 3.5 is untouched. Evidence: > return #767, `work/T-route9-hw-transfer.md`, `work/hw-normalization.py`, > `artifacts/hw-normalization.out`. """ def main(): text = open(SRC, encoding="utf-8").read() edits = [(OLD_DEF, NEW_DEF), (OLD_STMT, NEW_STMT), (OLD_CAL, NEW_CAL), (OLD_RIDER_END, OLD_RIDER_END + RIDER)] for old, new in edits: n = text.count(old) if n != 1: raise SystemExit("anchor occurs %d times, not once: %r" % (n, old[:60])) text = text.replace(old, new) with open(DST, "w", encoding="utf-8", newline="\n") as fh: fh.write(text) n0 = sum(1 for _ in open(SRC, encoding="utf-8")) n1 = sum(1 for _ in open(DST, encoding="utf-8")) print("base %s lines=%d sha256=%s" % (os.path.basename(SRC), n0, hashlib.sha256(open(SRC, "rb").read()).hexdigest())) print("rev %s lines=%d sha256=%s (+%d / -0)" % (os.path.basename(DST), n1, hashlib.sha256(open(DST, "rb").read()).hexdigest(), n1 - n0)) return 0 if __name__ == "__main__": raise SystemExit(main())