diff --git a/.github/workflows/lifetime-cj-model-j.yml b/.github/workflows/lifetime-cj-model-j.yml new file mode 100644 index 000000000..84f7e092b --- /dev/null +++ b/.github/workflows/lifetime-cj-model-j.yml @@ -0,0 +1,64 @@ +name: Lifetime note CJ replay + +'on': + pull_request: + paths: + - 'frontiers/lifetime_cj_model_j_20261012/**' + - 'tests/test_lifetime_cj_model_j_replay_protocol.py' + - 'tests/test_lifetime_cj_model_j_replay_evidence.py' + - '.github/workflows/lifetime-cj-model-j.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + replay: + runs-on: ubuntu-latest + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + mode: ['-B -S', '-B -O -S'] + name: replay (python ${{ matrix.mode }}) + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + persist-credentials: false + - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 + with: + python-version: '3.11.16' + - name: Verify protocol, stored identities, extractions and all published controls + env: + PYTHONDONTWRITEBYTECODE: '1' + shell: bash + run: | + set -euo pipefail + out="$RUNNER_TEMP/qs-replay-evidence" + mkdir -p "$out/logs" + python ${{ matrix.mode }} -m unittest discover -s tests -p test_lifetime_cj_model_j_replay_protocol.py -v 2>&1 | tee "$out/logs/protocol.txt" + python ${{ matrix.mode }} -m unittest discover -s tests -p test_lifetime_cj_model_j_replay_evidence.py -v 2>&1 | tee "$out/logs/process-evidence-tests.txt" + QS_REPLAY_EVIDENCE_DIR="$out/children" python ${{ matrix.mode }} frontiers/lifetime_cj_model_j_20261012/replay.py 2>&1 | tee "$out/logs/replay.txt" + git diff --exit-code + test -z "$(git status --porcelain)" + - name: Preserve exact public sources and available execution logs + if: always() + shell: bash + run: | + set -euo pipefail + out="$RUNNER_TEMP/qs-replay-evidence" + mkdir -p "$out" + cp -a frontiers/lifetime_cj_model_j_20261012 "$out/packet" + cp tests/test_lifetime_cj_model_j_replay_protocol.py "$out/" + cp tests/test_lifetime_cj_model_j_replay_evidence.py "$out/" + cp .github/workflows/lifetime-cj-model-j.yml "$out/" + git rev-parse HEAD > "$out/tested_commit.txt" + printf '%s\n' '${{ matrix.mode }}' > "$out/mode.txt" + printf '%s\n' "$GITHUB_RUN_ID/$GITHUB_RUN_ATTEMPT" > "$out/run.txt" + - name: Retain evidence on success or failure + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 + with: + name: qs-replay-${{ strategy.job-index }}-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ runner.temp }}/qs-replay-evidence/ + if-no-files-found: error diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/AUTHOR_CONTROLS_COMMENT.md b/frontiers/lifetime_cj_model_j_20261012/CJ/AUTHOR_CONTROLS_COMMENT.md new file mode 100644 index 000000000..b80bd8f95 --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/AUTHOR_CONTROLS_COMMENT.md @@ -0,0 +1,647 @@ +## Lifetime note CJ: controls `cj_exact.py`, exact executable and stdout, and the author-side referee record + +This publishes the standard-library script that note CJ ([6132006756](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132006756)) cites in §§1–3 and 6, so anyone can replay the computer-assisted part of its proof. The script: +- encloses `∫_0^∞ h(a)ψ(a) da` by Simpson's rule on 1,500 cells with the fourth-derivative remainder of Lemma 3 and the closed-form tails of Lemma 4, in outward-rounded 50-digit `decimal` interval arithmetic, with every special function (`π`, `Γ(1/3)`, `Γ(2/3)`, `I_{±μ}`, `K_μ`, `γ(s, a)`, `exp`, `ln`) enclosed by series with explicit remainders; +- checks, independently of the production lines, Lemma 1's `k`-integral at three points by a separate bracket, Lemma 1's constant built from its derivation, the Wronskian, two series for `h`, the derivative formulas of Lemma 2 by bracketed increments, and the quadrature machinery against the closed form `∫_0^∞ a³ψ`; +- as internal controls, compares the remainder majorant of (3.1) with the Leibniz majorant at three points of every cell, the rounded remainder sum with the same sum in exact rational arithmetic, the width of the final enclosure with its allowances, and every certified printed number with the note's text. + +Dylan Roy — delegated AI work. Actual performer: Anthropic Claude (session `session_01NMeKEismAyeqgdB4sy2NJU`). Scientific effect: NONE. + +**What the controls do not test.** The analytic steps of Lemmas 1–4 beyond their numerical identities; the choice of endpoints in (3.1) beyond the three-point domination (a mutant that takes `h^{(j)}` at the wrong endpoint fails only at the pinned strings); the tail constants beyond `< 10⁻⁹` and the pinned strings; the `𝒮_d` and `η` arithmetic of the corollaries beyond positivity, the `0.3115` bracket and the pinned strings; libmpdec's correct rounding of `exp` and `ln`. Note CJ §6 says so. + +**Extraction rule.** As in [5971055189](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-5971055189). The file is the exact text between the first ```` ```python ```` fence after its `###` heading and the next ```` ``` ```` line, plus a final newline. The expected stdout is the single JSON line in the following ```` ```json ```` fence, plus one newline. + +**Identities.** +- `cj_exact.py`: 26,090 B, SHA-256 `b3be1503937fb0875ff1dedebf9edbee79c16888da2fb68cbc5bce2524215458`. +- Stdout: 835 B, SHA-256 `c42031da918ce388345a9e7488b38925763d53ca3de86731dce4cfc6c405a34e`. + +**Run.** CPython 3.11.15 with libmpdec 2.5.1; about 50 s per mode on this container (two modes concurrently on two CPUs), 21,154 checks. +- `python3 -B -S cj_exact.py`: exit 0, empty stderr, exactly the stdout below. +- `python3 -B -O -S cj_exact.py`: byte-identical output. No check depends on an `assert`. +- `--mutant M1` … `M14`: each exits 1, with empty stdout and `FAILED: ` on stderr, as in note CJ §6's table: M1 gamma, M2 bessel, M3 h_function, M4 psi_function, M5 moment, M6 psi_function, M7 partition, M8 representation, M9 corollary, M10 h_function, M11 moment, M12 remainder, M13 J_cells, M14 pinned. Verified in both modes; the fingerprints `(exit, SHA-256 of stdout, SHA-256 of stderr)` are identical across modes. +- Invalid invocations (`--bogus`, `--mutant M15`, a bare `--mutant`, `--mutant m14`, `--mutant M1 extra`): exit 2, empty stdout, the usage line on stderr. +- The twelve narrowing edits of the Slice B referee (note CJ §6, "Author-side probes") each exit 1 against this script, at moment, remainder, J_cells, pinned or corollary. + +**Author-side referee record (same provider; organizational-independence credit 0).** Three separate Claude agents, each in a clean context with only the files named. +- *Slice A* (§§0–2; given the 7 October draft, its script `6ec0740e…51482` and expected stdout `0b7a9fcd…c89c3`): **BLOCK**, one finding, A-1: `neg` and `absmax` used Python's unary minus and `abs()`, which round to the thread's default 28-digit context, so the `ψ′` enclosure missed the true value at 2,716 of the 3,001 Simpson nodes, by up to `4.9·10⁻²⁸` relative; the printed numbers were unaffected (unquantized endpoints move by about `10⁻³⁷`). Non-blocking: A-2 (the constant check was circular), A-3 (Lemma 2(a), `n = 1`), A-4 (strict signs), A-5 (four wording points on the series). It confirmed `J` to 24 digits by two routes, one straight from (0.1) with no Bessel function. +- *Slice B* (§§3–6 and the header; same inputs): **AMEND**, no blocking finding. B-1: ten of twelve one-line edits that only narrow the enclosure passed every control. B-2 to B-10: the moment row's overclaim, the citation of notes C7 and SL, the partition description, the `d = 2, L ≥ 24` row, Remark 2's `0.0767382` → `0.0767381`, the midpoint test compared two rounded results, the domain guards, two wordings, the route of the assembly value. It reproduced every printed number of the theorem, both corollaries and Remark 1, and `J` by two routes. +- *Readback* (given both drafts, both reports, the revised files and the two diffs): **AMEND**, one required change (a misattributed floating-point route in Remark 3, corrected before posting); it verified every finding's application, proved the four new checks sound, reconciled the 21,154 checks group by group, and re-ran the baseline, all 14 mutants, the invalid invocations and nine narrowing edits. + +**What changed from the 7 October draft.** +- Script: `copy_negate()` / `copy_abs()`, a default context that traps every inexact or rounded operation, and group primitives (A-1); the constant built from `(16/15)·(1/3)·(4π)^{−1/2}` and checked against the literal (A-2); the exact midpoint test (B-7); group remainder, the rational remainder sum, J_cells' width test and group pinned (B-1); mutants M11–M14 for the new guards; `import math` for `math.comb`. +- Note: the header's CJ1 row for `d = 2, L ≥ 24` is now `[0.012789638, 0.012789639]`; the `46%` sentence; notes C7 and SL under *Cited only* and the inherited scopes under *Not claimed*; Lemma 2's proof (`n = 1`, strict signs); the series bullets; the three-point domination sentence after Lemma 3; Proposition 2's partition description; Remarks 1–3; §6 rewritten for the new groups, counts, sizes, hashes, mutants and probes; §7's record. + +The reports and scratch work (three referee directories, the probes, both deltas) are kept in the author's record and will be stored with the packet; they are not on GitHub yet, because the note has no nonauthor read. + +### cj_exact.py + +```python +"""Note CJ controls: a certified two-sided enclosure of note C3's model number J (Python standard library only). + +J = (16/45)(4 pi)^(-1/2) int_0^inf h(a) psi(a) da, psi(a) = (432/a^2)^(2/3) K_{4/3}(2a/sqrt3), +h(a) = E[(a - W)_+^3], W ~ Gamma(1/2, 1) (note CJ, Lemma 1). The integral is enclosed by Simpson's rule on an +explicit partition, Simpson's remainder bounded through explicit bounds of the fourth derivative (Lemma 3), plus +closed-form tails (Lemma 4). All arithmetic is outward-rounded decimal interval arithmetic. +Usage: python3 cj_exact.py [--mutant M1..M14] +""" +import decimal +import json +import math +import sys +from fractions import Fraction as Fr + +USAGE = 'usage: cj_exact.py [--mutant M1..M14]' +MUTANTS = ['M%d' % i for i in range(1, 15)] +if len(sys.argv) == 1: + MUT = None +elif len(sys.argv) == 3 and sys.argv[1] == '--mutant' and sys.argv[2] in MUTANTS: + MUT = sys.argv[2] +else: + sys.stderr.write(USAGE + '\n') + sys.exit(2) + +PREC = 50 +CD = decimal.Context(prec=PREC, rounding=decimal.ROUND_FLOOR) +CU = decimal.Context(prec=PREC, rounding=decimal.ROUND_CEILING) +CN = decimal.Context(prec=PREC, rounding=decimal.ROUND_HALF_EVEN) +# Every rounding is explicit (CD, CU, CN). The default context traps any operation that would round, so an operation +# written without a context (unary minus, abs, +, -, *, /) can only ever be exact. +decimal.setcontext(decimal.Context(prec=PREC, traps=[decimal.Inexact, decimal.Rounded, decimal.InvalidOperation, + decimal.DivisionByZero, decimal.Overflow])) +Dec = decimal.Decimal +Z = Dec(0) +COUNT = {} + + +class Fail(Exception): + pass + + +def need(cond, group): + COUNT[group] = COUNT.get(group, 0) + 1 + if not cond: + raise Fail(group) + + +def _hook(kind, value, tb): + if kind is Fail: + sys.stderr.write('FAILED: %s\n' % value.args[0]) + else: + sys.__excepthook__(kind, value, tb) + + +sys.excepthook = _hook # any failed check: message on stderr, empty stdout, exit status 1 + + +# ---------------------------------------------------------------- interval arithmetic (lo, hi) +def q(x): + x = Fr(x) + n, d = Dec(x.numerator), Dec(x.denominator) + return (CD.divide(n, d), CU.divide(n, d)) + + +def pt(x): + return (x, x) + + +def add(a, b): + return (CD.add(a[0], b[0]), CU.add(a[1], b[1])) + + +def sub(a, b): + return (CD.subtract(a[0], b[1]), CU.subtract(a[1], b[0])) + + +def neg(a): + return (a[1].copy_negate(), a[0].copy_negate()) # exact; unary minus would round in the context + + +def mul(a, b): + lo = min(CD.multiply(x, y) for x in a for y in b) + hi = max(CU.multiply(x, y) for x in a for y in b) + return (lo, hi) + + +def div(a, b): + if not (b[0] > 0 or b[1] < 0): + raise Fail('interval_division') + lo = min(CD.divide(x, y) for x in a for y in b) + hi = max(CU.divide(x, y) for x in a for y in b) + return (lo, hi) + + +def isqrt(a): + if a[0] < 0: + raise Fail('interval_sqrt') + lo = Z if a[0] == 0 else max(Z, CD.next_minus(CN.sqrt(a[0]))) + hi = Z if a[1] == 0 else CU.next_plus(CN.sqrt(a[1])) + if CU.multiply(lo, lo) > a[0] or CD.multiply(hi, hi) < a[1]: # verified, not assumed + raise Fail('interval_sqrt') + return (lo, hi) + + +def iexp(a): + # decimal's exp is correctly rounded (half-even); one ulp of widening makes it an enclosure + return (max(Z, CD.next_minus(CN.exp(a[0]))), CU.next_plus(CN.exp(a[1]))) + + +def iln(a): + if a[0] <= 0: + raise Fail('interval_ln') + return (CD.next_minus(CN.ln(a[0])), CU.next_plus(CN.ln(a[1]))) + + +def ipow(a, r): + # a > 0, r rational + return iexp(mul(iln(a), q(r))) + + +def ipow_int(a, n): + out = (Dec(1), Dec(1)) + for _ in range(n): + out = mul(out, a) + return out + + +def absmax(a): + return max(a[0].copy_abs(), a[1].copy_abs()) # exact; abs() would round in the context + + +def contains(a, x): + return a[0] <= x <= a[1] + + +def width(a): + return CU.subtract(a[1], a[0]) + + +ONE = q(1) +HALF = q(Fr(1, 2)) +TINY = Dec('1e-45') # series are summed until the last term is below TINY times the partial sum + +# neg and absmax are exact at full precision (they must not round in any context) +X50 = CN.divide(Dec(1), Dec(7)) +need(neg(pt(X50)) == (X50.copy_negate(), X50.copy_negate()) and absmax(neg(pt(X50))) == X50, 'primitives') + + +# ---------------------------------------------------------------- pi (Machin), Gamma(1/3) and Gamma(2/3) +def atan_inv(n): + """atan(1/n), n >= 2: alternating series with decreasing terms, enclosed by the next term.""" + s = (Z, Z) + k = 0 + p = q(Fr(1, n)) + n2 = q(n * n) + while True: + t = div(p, q(2 * k + 1)) + s = add(s, t) if k % 2 == 0 else sub(s, t) + p = div(p, n2) + k += 1 + nxt = div(p, q(2 * k + 1)) + if nxt[1] < Dec('1e-55'): + return (CD.subtract(s[0], nxt[1]), CU.add(s[1], nxt[1])) + + +PI = sub(mul(q(16), atan_inv(5)), mul(q(4), atan_inv(239))) +need(width(PI) < Dec('1e-45'), 'pi') +need(contains(PI, Dec('3.14159265358979323846264338327950288419716939937510')), 'pi') + +GX = 130 # Gamma(a) = gamma(a, X) + Gamma(a, X) at X = 130 + + +def gamma_small(a): + """Gamma(a) for 0 < a <= 1: gamma(a, X) = X^a e^(-X) sum_n X^n / (a (a+1) ... (a+n)) (positive terms) and + 0 <= Gamma(a, X) <= X^(a-1) e^(-X).""" + a = Fr(a) + X = q(GX) + t = div(ONE, q(a)) + s = t + n = 0 + while True: + n += 1 + t = mul(t, div(X, q(a + n))) + s = add(s, t) + if n > GX and t[1] < CU.multiply(s[0], TINY): + break + r = div(X, q(a + n + 1)) # all later ratios are at most r < 1 + tail = div(mul(t, r), sub(ONE, r)) + s = (s[0], CU.add(s[1], tail[1])) + pref = mul(iexp(mul(q(a), iln(X))), iexp(neg(X))) + low = mul(pref, s) + upper_tail = mul(iexp(mul(q(a - 1), iln(X))), iexp(neg(X))) + if MUT == 'M1': + upper_tail = mul(upper_tail, q(-10 ** 30)) + return (low[0], CU.add(low[1], upper_tail[1])) + + +G13 = gamma_small(Fr(1, 3)) +G23 = gamma_small(Fr(2, 3)) +SQ3 = isqrt(q(3)) +need(contains(G13, Dec('2.6789385347077476336556929409746776441286893779573')), 'gamma') +need(contains(G23, Dec('1.3541179394264004169452880281545137855193272660568')), 'gamma') +refl = sub(mul(mul(G13, G23), SQ3), mul(q(2), PI)) # Gamma(1/3) Gamma(2/3) sqrt3 = 2 pi: two independent series +need(refl[0] <= 0 <= refl[1], 'gamma') +need(width(G13) < Dec('1e-40') and width(G23) < Dec('1e-40'), 'gamma') + +# ---------------------------------------------------------------- modified Bessel functions +NU = Fr(4, 3) +GSHIFT = {Fr(4, 3): mul(q(Fr(4, 9)), G13), # Gamma(7/3) = (4/3)(1/3) Gamma(1/3) + Fr(-4, 3): mul(q(-3), G23), # Gamma(-1/3) = Gamma(2/3)/(-1/3) + Fr(7, 3): mul(q(Fr(28, 27)), G13), # Gamma(10/3) = (7/3)(4/3)(1/3) Gamma(1/3) + Fr(-7, 3): mul(q(Fr(9, 4)), G23)} # Gamma(-4/3) = Gamma(-1/3)/(-4/3) + + +def bessel_i(mu, x): + """I_mu(x) = (x/2)^mu sum_m (x^2/4)^m / (m! Gamma(m + mu + 1)), x > 0 an interval.""" + y = mul(mul(x, x), q(Fr(1, 4))) + term = div(ONE, GSHIFT[mu]) + s = term + m = 0 + while True: + term = div(mul(term, y), mul(q(m + 1), q(m + 1 + mu))) + m += 1 + s = add(s, term) + ratio = div(y, mul(q(m + 1), q(m + 1 + mu))) # the next ratio; m + 1 + mu > 0 once m >= 2 + if m >= 2 and ratio[1] <= HALF[0] and absmax(term) < CD.multiply(s[0].copy_abs(), TINY): + break + tail = absmax(term) # later terms keep one sign, with ratios at most 1/2: their sum is at most the last term + s = (CD.subtract(s[0], tail), CU.add(s[1], tail)) + return mul(ipow(mul(x, HALF), mu), s) + + +PI_SQ3 = div(PI, SQ3) + + +def bessel_k_ladder(x): + """[K_{4/3}, K_{7/3}, K_{10/3}, K_{13/3}, K_{16/3}] at x > 0 (an interval). + K_mu = (pi/(2 sin(mu pi))) (I_{-mu} - I_mu); sin(4 pi/3) = -sqrt3/2, sin(7 pi/3) = sqrt3/2.""" + k43 = mul(PI_SQ3, sub(bessel_i(Fr(4, 3), x), bessel_i(Fr(-4, 3), x))) + k73 = mul(PI_SQ3, sub(bessel_i(Fr(-7, 3), x), bessel_i(Fr(7, 3), x))) + if MUT == 'M2': + k43 = mul(k43, q(Fr(101, 100))) + ks = [k43, k73] + for j in range(3): # K_{mu+1} = K_{mu-1} + (2 mu / x) K_mu, for mu = 7/3, 10/3, 13/3 + mu = NU + 1 + j + ks.append(add(ks[-2], mul(div(q(2 * mu), x), ks[-1]))) + need(all(k[0] > 0 for k in ks), 'bessel') + return ks + + +# ---------------------------------------------------------------- h and its derivatives +def lower_gammas(a): + """gamma(s, a) for s = 1/2, 3/2, 5/2, 7/2: a^s e^(-a) sum_n a^n / (s (s+1) ... (s+n)), positive terms.""" + out = [] + ea = iexp(neg(a)) + svals = [Fr(1, 2), Fr(3, 2), Fr(5, 2), Fr(7, 2)] + if MUT == 'M10': + svals[1] = Fr(5, 2) + for s in svals: + t = div(ONE, q(s)) + tot = t + n = 0 + while True: + n += 1 + t = mul(t, div(a, q(s + n))) + tot = add(tot, t) + if div(a, q(s + n + 1))[1] <= HALF[0] and t[1] < CU.multiply(tot[0], TINY): + break + tot = (tot[0], CU.add(tot[1], t[1])) # later ratios are at most 1/2: the tail is at most the last term + out.append(mul(mul(ipow(a, s), ea), tot)) + return out + + +SQPI = isqrt(PI) +H_CACHE = {} + + +def h_derivs(a): + """[h, h', h'', h''', h''''] at a > 0 (an interval); W ~ Gamma(1/2, 1) has density pi^(-1/2) w^(-1/2) e^(-w). + E[(a - W)_+^n] = pi^(-1/2) sum_k C(n, k) a^(n-k) (-1)^k gamma(k + 1/2, a); h = E3, h' = 3 E2, h'' = 6 E1, + h''' = 6 P(W <= a), h'''' = 6 times the density of W.""" + if a in H_CACHE: + return H_CACHE[a] + g = lower_gammas(a) + + def em(n): + s = (Z, Z) + coeffs = {3: [1, 3, 3, 1], 2: [1, 2, 1], 1: [1, 1]}[n] + for k in range(n + 1): + term = mul(mul(q(coeffs[k]), ipow_int(a, n - k)), g[k]) + s = add(s, term) if k % 2 == 0 else sub(s, term) + return div(s, SQPI) + + h0 = em(3) + if MUT == 'M3': + h0 = em(2) + out = [h0, mul(q(3), em(2)), mul(q(6), em(1)), div(mul(q(6), g[0]), SQPI), + div(mul(q(6), mul(ipow(a, Fr(-1, 2)), iexp(neg(a)))), SQPI)] + H_CACHE[a] = out + return out + + +# ---------------------------------------------------------------- psi(a) = 432^(2/3) a^(-4/3) K_{4/3}(b a), b = 2/sqrt3 +B = div(q(2), SQ3) +C432 = ipow(q(432), Fr(2, 3)) +PSI_CACHE = {} + + +def psi_derivs(a): + """[psi, psi', ..., psi''''] at a > 0: psi^(j)(a) = C432 b^(4/3 + j) u^(j)(b a) with u(x) = x^(-4/3) K_{4/3}(x), + u' = -x^(-nu) K_{nu+1}, u'' = x^(-nu) K_{nu+2} - x^(-nu-1) K_{nu+1}, u''' = 3 x^(-nu-1) K_{nu+2} - x^(-nu) K_{nu+3}, + u'''' = 3 x^(-nu-2) K_{nu+2} - 6 x^(-nu-1) K_{nu+3} + x^(-nu) K_{nu+4}.""" + if a in PSI_CACHE: + return PSI_CACHE[a] + x = mul(B, a) + if MUT == 'M6': + x = mul(q(Fr(11, 10)), x) + k = bessel_k_ladder(x) + xm = ipow(x, -NU) + ix = div(ONE, x) + c6 = 5 if MUT == 'M4' else 6 + u = [mul(xm, k[0]), + neg(mul(xm, k[1])), + sub(mul(xm, k[2]), mul(mul(xm, ix), k[1])), + sub(mul(q(3), mul(mul(xm, ix), k[2])), mul(xm, k[3])), + add(sub(mul(q(3), mul(mul(xm, mul(ix, ix)), k[2])), mul(q(c6), mul(mul(xm, ix), k[3]))), mul(xm, k[4]))] + out = [mul(mul(C432, ipow(B, NU + j)), u[j]) for j in range(5)] + PSI_CACHE[a] = out + return out + + +# ---------------------------------------------------------------- Simpson cells with a fourth-derivative remainder +def simpson(grid, hfun, label): + """Enclose the integral over the grid of h(a) psi(a), h = hfun(a)[0], by Simpson's rule plus a remainder of + absolute value at most D^5 M / 2880 per cell, where M bounds |(h psi)''''| on the cell: h^(j) (j <= 3) are + nonnegative and nondecreasing, h'''' is nonnegative and nonincreasing, and |psi^(j)| are nonincreasing + (psi is completely monotone).""" + total = (Z, Z) + err = Z + err2 = Fr(0) # the same remainder sum in exact rational arithmetic (a control on the rounding of err) + binom4 = [1, 1, 1, 1, 1] if MUT == 'M12' else [1, 4, 6, 4, 1] + w4 = 3 if MUT == 'M5' else 4 + for a0, a1 in zip(grid, grid[1:]): + dlt = CU.subtract(a1, a0) + need(CD.subtract(a1, a0) == dlt, label) # cell widths are exact + s = CD.add(a0, a1) + need(s == CU.add(a0, a1), label) # a0 + a1 is exact + m = CD.divide(s, Dec(2)) + need(m == CU.divide(s, Dec(2)), label) # the midpoint is exact + h0, p0 = hfun(pt(a0)), psi_derivs(pt(a0)) + h1, p1 = hfun(pt(a1)), psi_derivs(pt(a1)) + hm, pm = hfun(pt(m)), psi_derivs(pt(m)) + f = add(add(mul(h0[0], p0[0]), mul(q(w4), mul(hm[0], pm[0]))), mul(h1[0], p1[0])) + total = add(total, mul(f, div(pt(dlt), q(6)))) + mbound = Z + for j in range(5): + hb = h1[j][1] if j <= 3 else h0[4][1] + pb = absmax(p0[4 - j]) + mbound = CU.add(mbound, CU.multiply(Dec(binom4[j]), CU.multiply(hb, pb))) + # (3.1)'s majorant M dominates the Leibniz majorant sum_j C(4, j) h^(j) |psi^(4-j)| at a0, m and a1 (Lemma 2's + # monotonicity); the Leibniz majorant is taken from the lower ends of the enclosures, with its own binomials + for xh, xp in ((h0, p0), (hm, pm), (h1, p1)): + lead = Z + for j in range(5): + v = xp[4 - j] + lo_p = min(v[0].copy_abs(), v[1].copy_abs()) if (v[0] > 0 or v[1] < 0) else Z + lead = CD.add(lead, CD.multiply(Dec(math.comb(4, j)), CD.multiply(max(Z, xh[j][0]), lo_p))) + need(mbound >= lead, 'remainder') + d5 = CU.multiply(CU.multiply(CU.multiply(dlt, dlt), CU.multiply(dlt, dlt)), dlt) + err = CU.add(err, CU.divide(CU.multiply(d5, mbound), Dec(2880000 if MUT == 'M11' else 2880))) + err2 += (Fr(a1) - Fr(a0)) ** 5 * Fr(mbound) / 2880 + need(err >= q(err2)[0], label) # every rounding in err is upward, so err is at least the exact sum + return total, err + + +def grid_from(spec): + g = [] + for kind, a0, a1, n in spec: + a0, a1 = Dec(a0), Dec(a1) + if kind == 'u': + pts = [CN.add(a0, CN.divide(CN.multiply(CN.subtract(a1, a0), Dec(i)), Dec(n))) for i in range(n + 1)] + else: # geometric, rounded to 12 significant digits (any increasing exact decimals partition the range) + r = CN.power(CN.divide(a1, a0), CN.divide(Dec(1), Dec(n))) + pts = [CN.multiply(a0, CN.power(r, Dec(i))) for i in range(n + 1)] + pts = [a0] + [Dec(format(p, '.11e')) for p in pts[1:-1]] + [a1] + if g: + need(g[-1] == pts[0], 'partition') + pts = pts[1:] + g += pts + need(all(x < y for x, y in zip(g, g[1:])), 'partition') + return g + + +A_MIN, A_MAX = Dec('1e-6'), Dec(30) +SPEC = [('g', '1e-6', '0.05', 300), ('u', '0.05', '1', 400), ('u', '1', '4', 300), ('u', '4', '12', 300), + ('u', '12', '30', 200)] +if MUT == 'M7': + SPEC[1] = ('u', '0.06', '1', 400) +GRID = grid_from(SPEC) +need(GRID[0] == A_MIN and GRID[-1] == A_MAX, 'partition') + + +# ---------------------------------------------------------------- tails +def tail_low(coef_h, power_h): + """int_0^A_MIN of coef_h a^power_h psi(a): psi(a) <= C432 2^(1/3) Gamma(4/3) b^(-4/3) a^(-8/3), because x^nu K_nu(x) + is nonincreasing with limit 2^(nu - 1) Gamma(nu) at 0.""" + g43 = div(G13, q(3)) + cpsi = mul(mul(C432, mul(ipow(q(2), Fr(1, 3)), g43)), ipow(B, -NU)) + expo = Fr(power_h) - Fr(5, 3) # int_0^A a^(p - 8/3) da = A^(p - 5/3)/(p - 5/3) + need(expo > 0, 'tails') + val = mul(mul(coef_h, cpsi), div(ipow(pt(A_MIN), expo), q(expo))) + return (Z, val[1]) + + +def tail_high(): + """int_A_MAX^inf h(a) psi(a) with h(a) <= a^3: a^(-4/3) <= A_MAX^(-4/3) and K_nu(x) <= K_nu(x0) e^(-(x - x0)) for + x >= x0 (from K_nu(x) = int_0^inf e^(-x cosh t) cosh(nu t) dt).""" + k0 = bessel_k_ladder(mul(B, pt(A_MAX)))[0] + pre = mul(mul(C432, ipow(pt(A_MAX), -NU)), k0) + A = pt(A_MAX) + b2 = mul(B, B) + s = add(add(div(mul(mul(A, A), A), B), div(mul(q(3), mul(A, A)), b2)), + add(div(mul(q(6), A), mul(b2, B)), div(q(6), mul(b2, b2)))) # int_A^inf a^3 e^(-b(a - A)) da + return (Z, mul(pre, s)[1]) + + +# ---------------------------------------------------------------- checks of the special functions +for xs in ('0.3', '1.7', '6.5', '20', '34'): + x = pt(Dec(xs)) + ks = bessel_k_ladder(x) + w = add(mul(bessel_i(Fr(4, 3), x), ks[1]), mul(bessel_i(Fr(7, 3), x), ks[0])) # Wronskian: = 1/x + lhs = sub(w, div(ONE, x)) + need(lhs[0] <= 0 <= lhs[1] and width(w) < Dec('1e-15'), 'bessel') +for xs in ('0.5', '3', '12'): + x0 = pt(Dec(xs)) + x1 = pt(Dec(xs) + 1) + need(bessel_k_ladder(x1)[0][1] <= mul(bessel_k_ladder(x0)[0], iexp(q(-1)))[0], 'bessel') + +EPS = Dec('1e-6') +for xs in ('0.000001', '0.01', '0.5', '2', '9', '30'): + a = pt(Dec(xs)) + a2 = pt(Dec(xs) + EPS) + d, d2 = h_derivs(a), h_derivs(a2) + p, p2 = psi_derivs(a), psi_derivs(a2) + need(all(v[0] >= 0 for v in d), 'h_function') + need(d[0][1] <= mul(div(q(Fr(32, 35)), SQPI), ipow(a, Fr(7, 2)))[0], 'h_function') # used in tail_low + need(d[0][1] <= ipow_int(a, 3)[0], 'h_function') # used in tail_high + # each derivative's increment over [a, a + eps] lies between eps times the next derivative at the two ends + for j in range(4): + inc = sub(d2[j], d[j]) + lo_ = min(CD.multiply(EPS, d[j + 1][0]), CD.multiply(EPS, d2[j + 1][0])) + hi_ = max(CU.multiply(EPS, d[j + 1][1]), CU.multiply(EPS, d2[j + 1][1])) + need(lo_ <= inc[1] and inc[0] <= hi_, 'h_function') + inc = sub(p2[j], p[j]) + lo_ = min(CD.multiply(EPS, p[j + 1][0]), CD.multiply(EPS, p2[j + 1][0])) + hi_ = max(CU.multiply(EPS, p[j + 1][1]), CU.multiply(EPS, p2[j + 1][1])) + need(lo_ <= inc[1] and inc[0] <= hi_, 'psi_function') + need(all((v[0] > 0 if j % 2 == 0 else v[1] < 0) for j, v in enumerate(p)), 'psi_function') + if Dec(xs) <= Dec('0.01'): + # small a: h(a) = pi^(-1/2) sum_n (-1)^n a^(n + 7/2) B(n + 1/2, 4) / n!, alternating with decreasing terms + s = (Z, Z) + tn = None + fact = 1 + for n in range(8): + if n: + fact *= n + bn = Fr(6) / (Fr(2 * n + 1, 2) * Fr(2 * n + 3, 2) * Fr(2 * n + 5, 2) * Fr(2 * n + 7, 2)) + tn = mul(q(bn / fact), ipow(a, Fr(2 * n + 7, 2))) + s = add(s, tn) if n % 2 == 0 else sub(s, tn) + s = div((CD.subtract(s[0], tn[1]), CU.add(s[1], tn[1])), SQPI) + need(s[0] <= d[0][1] and d[0][0] <= s[1], 'h_function') + +# ---------------------------------------------------------------- Lemma 1's k-integral, checked by a separate bracket +# int_0^inf k^(-11/3) e^(-12 k^2 - a^2/(36 k^2)) dk = (432/a^2)^(2/3) K_{4/3}(2a/sqrt3) at three values of a, against +# monotone cell bounds of the left side (k^(-11/3) and e^(-12 k^2) decrease, e^(-c/k^2) increases). +for a_s in ('0.5', '2', '5'): + a = pt(Dec(a_s)) + c = div(mul(a, a), q(36)) + rhs = mul(ipow(div(q(432), mul(a, a)), Fr(2, 3)), bessel_k_ladder(mul(B, a))[0]) + kmin, kmax, n = Dec("0.004"), Dec("4"), 10000 + r = CN.power(CN.divide(kmax, kmin), CN.divide(Dec(1), Dec(n))) + ks = [kmin] + [Dec(format(CN.multiply(kmin, CN.power(r, Dec(i))), '.11e')) for i in range(1, n)] + [kmax] + lo_s, hi_s = Z, Z + for k0, k1 in zip(ks, ks[1:]): + dk = CU.subtract(k1, k0) + f_hi = mul(mul(ipow(pt(k0), Fr(-11, 3)), iexp(mul(q(-12), pt(CD.multiply(k0, k0))))), + iexp(neg(div(c, pt(CU.multiply(k1, k1)))))) + f_lo = mul(mul(ipow(pt(k1), Fr(-11, 3)), iexp(mul(q(-12), pt(CU.multiply(k1, k1))))), + iexp(neg(div(c, pt(CD.multiply(k0, k0)))))) + hi_s = CU.add(hi_s, CU.multiply(f_hi[1], dk)) + lo_s = CD.add(lo_s, CD.multiply(f_lo[0], CD.subtract(k1, k0))) + # outside [kmin, kmax]: k^(-11/3) e^(-c/k^2) <= kmin^(-11/3) e^(-c/kmin^2) is increasing on (0, kmin] when + # kmin^2 < 6c/11, and e^(-12 k^2) k^(-11/3) <= e^(-12 k^2) kmax^(-11/3) above kmax + need(CU.multiply(kmin, kmin) < CD.multiply(div(q(6), q(11))[0], c[0]), 'representation') + low_part = mul(mul(ipow(pt(kmin), Fr(-11, 3)), iexp(neg(div(c, pt(CD.multiply(kmin, kmin)))))), pt(kmin)) + high_part = mul(mul(ipow(pt(kmax), Fr(-11, 3)), iexp(mul(q(-12), pt(CD.multiply(kmax, kmax))))), + div(ONE, mul(q(24), pt(kmax)))) # int_K^inf e^(-12k^2) dk <= e^(-12K^2)/(24K) + hi_s = CU.add(CU.add(hi_s, low_part[1]), high_part[1]) + need(lo_s <= rhs[1] and rhs[0] <= hi_s, 'representation') + need(CU.subtract(hi_s, lo_s) < CD.multiply(Dec('0.02'), rhs[0]), 'representation') + +# the constant of Lemma 1, built from its derivation: 16/15 from (0.1), 1/3 from dB = da/(3k), (4 pi)^(-1/2) from the +# density of B; checked against Lemma 1's literal 16/45, and by the identity KJ * sqrt(4 pi) * 45/16 = 1 +KJ = mul(mul(q(Fr(16, 15)), q(1 if MUT == 'M8' else Fr(1, 3))), div(ONE, isqrt(mul(q(4), PI)))) +KJ_LIT = div(q(Fr(16, 45)), isqrt(mul(q(4), PI))) +need(KJ[0] <= KJ_LIT[1] and KJ_LIT[0] <= KJ[1], 'representation') +need(contains(mul(mul(KJ, isqrt(mul(q(4), PI))), q(Fr(45, 16))), Dec(1)), 'representation') + +# ---------------------------------------------------------------- the quadrature machinery against a closed form +# With h replaced by a^3: int_0^inf a^3 psi(a) da = C432 int_0^inf a^(5/3) K_{4/3}(b a) da = C432 2^(2/3) b^(-8/3) +# Gamma(2/3) Gamma(2), by int_0^inf a^(mu-1) K_nu(b a) da = 2^(mu-2) b^(-mu) Gamma((mu-nu)/2) Gamma((mu+nu)/2). + + +def cube_derivs(a): + return [ipow_int(a, 3), mul(q(3), mul(a, a)), mul(q(6), a), q(6), (Z, Z)] + + +TGT_CUBE = mul(mul(C432, ipow(q(2), Fr(2, 3))), mul(ipow(B, Fr(-8, 3)), G23)) +cube, cube_err = simpson(GRID, cube_derivs, 'moment') +cube_lo = CD.subtract(cube[0], cube_err) +cube_hi = CU.add(CU.add(CU.add(cube[1], cube_err), tail_low(ONE, 3)[1]), tail_high()[1]) +need(cube_lo <= TGT_CUBE[1] and TGT_CUBE[0] <= cube_hi, 'moment') +need(CU.subtract(cube_hi, cube_lo) < Dec('1e-5'), 'moment') + +# ---------------------------------------------------------------- J +core, core_err = simpson(GRID, h_derivs, 'J_cells') +lowtail = tail_low(div(q(Fr(32, 35)), SQPI), Fr(7, 2)) +hightail = tail_high() +need(lowtail[1] < Dec('1e-9') and hightail[1] < Dec('1e-9'), 'tails') +I_lo = CD.subtract(core[0], core_err) +I_hi = CU.add(CU.add(CU.add(core[1], core_err), lowtail[1]), hightail[1]) +if MUT == 'M13': + I_hi = CU.add(core[1], core_err) +J = mul(KJ, (I_lo, I_hi)) +need(J[0] > 0 and width(J) < Dec('1e-7'), 'J_cells') +# the enclosure is at least as wide as its remainder and tail allowances (KJ > 0, I_lo > 0): none of them was dropped +need(width(J) >= CD.multiply(KJ[0], CD.add(CD.multiply(Dec(2), core_err), CD.add(lowtail[1], hightail[1]))), 'J_cells') +# two independent floating-point evaluations (note C3's Slice C referee: 4.1977819815839; mpmath: 4.1977819815839038) +need(contains(J, Dec('4.1977819815839038')), 'assembly') + +# ---------------------------------------------------------------- the consequences +S2 = div(mul(q(25), SQ3), mul(q(48), mul(PI, PI))) # 25 sqrt3 / (48 pi^2) +S3 = div(mul(q(125), isqrt(q(30))), mul(q(192), mul(PI, mul(PI, PI)))) # 125 sqrt30 / (192 pi^3) +ETA = {(2, 10): (Fr(588, 10 ** 11), Fr(781, 10 ** 8)), (3, 10): (Fr(197, 10 ** 9), Fr(497, 10 ** 6)), + (2, 24): (Fr(488, 10 ** 112), Fr(648, 10 ** 109)), (3, 24): (Fr(164, 10 ** 110), Fr(413, 10 ** 107))} +J30 = div(J, q(30)) +NEG_IQ_LO, D_UP = q(Fr(6104056, 10 ** 7)), q(Fr(438822, 10 ** 6)) # note DC: -I~_quad >= 0.6104056, D <= 0.438822 +if MUT == 'M9': + D_UP = q(Fr(338822, 10 ** 6)) +model = sub(add(J30, NEG_IQ_LO), D_UP) # its lower end bounds J/30 - I~ from below +need(Dec('0.31150') <= model[0] <= Dec('0.31151'), 'corollary') +values = {} +for (d, L), (ec, er) in sorted(ETA.items()): + S = S2 if d == 2 else S3 + c3_lo = mul(J30 if MUT == 'M14' else sub(J30, q(ec)), S)[0] + c3_hi = mul(add(J30, q(ec)), S)[1] + coef_lo = mul(sub(sub(model, q(ec)), q(er)), S)[0] + need(c3_lo > 0 and coef_lo > 0, 'corollary') + values['d%d_L%d' % (d, L)] = {'c3': [str(CD.quantize(c3_lo, Dec('1e-9'))), str(CU.quantize(c3_hi, Dec('1e-9')))], + 'coef_lo': str(CD.quantize(coef_lo, Dec('1e-6')))} + +# ---------------------------------------------------------------- the certified printed strings, pinned to the note's text +J_STR = [str(CD.quantize(J[0], Dec('1e-10'))), str(CU.quantize(J[1], Dec('1e-10')))] +REM_STR = str(CU.quantize(CU.multiply(KJ[1], core_err), Dec('1e-12'))) +TAILS_STR = str(CU.quantize(CU.multiply(KJ[1], CU.add(lowtail[1], hightail[1])), Dec('1e-15'))) +MODEL_STR = str(CD.quantize(model[0], Dec('1e-6'))) +PINNED = { + 'J': ['4.1977819534', '4.1977820097'], + 'J_simpson_remainder': '2.8099E-8', + 'J_tails': '1.5287E-11', + 'model_coef_lo': '0.311509', + 'values': {'d2_L10': {'c3': ['0.012789638', '0.012789640'], 'coef_lo': '0.028472'}, + 'd2_L24': {'c3': ['0.012789638', '0.012789639'], 'coef_lo': '0.028472'}, + 'd3_L10': {'c3': ['0.016092288', '0.016092334'], 'coef_lo': '0.035768'}, + 'd3_L24': {'c3': ['0.016092310', '0.016092312'], 'coef_lo': '0.035825'}}, +} +need(J_STR == PINNED['J'], 'pinned') +need(REM_STR == PINNED['J_simpson_remainder'], 'pinned') +need(TAILS_STR == PINNED['J_tails'], 'pinned') +need(MODEL_STR == PINNED['model_coef_lo'], 'pinned') +for key in sorted(PINNED['values']): + need(values[key] == PINNED['values'][key], 'pinned') + +out = { + 'note': 'CJ', + 'precision': PREC, + 'cells': len(GRID) - 1, + 'J': J_STR, + 'J_simpson_remainder': REM_STR, + 'J_tails': TAILS_STR, + 'moment_check': [str(CD.quantize(cube_lo, Dec('1e-9'))), str(CU.quantize(cube_hi, Dec('1e-9'))), + str(CN.quantize(TGT_CUBE[0], Dec('1e-9')))], + 'model_coef_lo': MODEL_STR, + 'values': values, + 'checks': dict(sorted(COUNT.items())), + 'result': 'J in the printed interval', +} +print(json.dumps(out, sort_keys=True)) +``` + +```json +{"J": ["4.1977819534", "4.1977820097"], "J_simpson_remainder": "2.8099E-8", "J_tails": "1.5287E-11", "cells": 1500, "checks": {"J_cells": 4503, "assembly": 1, "bessel": 3033, "corollary": 5, "gamma": 4, "h_function": 44, "moment": 4503, "partition": 6, "pi": 2, "pinned": 8, "primitives": 1, "psi_function": 30, "remainder": 9000, "representation": 11, "tails": 3}, "model_coef_lo": "0.311509", "moment_check": ["83.704214948", "83.704218519", "83.704216933"], "note": "CJ", "precision": 50, "result": "J in the printed interval", "values": {"d2_L10": {"c3": ["0.012789638", "0.012789640"], "coef_lo": "0.028472"}, "d2_L24": {"c3": ["0.012789638", "0.012789639"], "coef_lo": "0.028472"}, "d3_L10": {"c3": ["0.016092288", "0.016092334"], "coef_lo": "0.035768"}, "d3_L24": {"c3": ["0.016092310", "0.016092312"], "coef_lo": "0.035825"}}} +``` + +🤖 Generated with [Claude Code](https://claude.com/claude-code) + + +--- +_Generated by [Claude Code](https://claude.ai/code)_ \ No newline at end of file diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md b/frontiers/lifetime_cj_model_j_20261012/CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md new file mode 100644 index 000000000..f7c567607 --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md @@ -0,0 +1,40 @@ +## Claude01N is back: answers to the 7 October handoff questions; note CJ posted and read (two PASS); five packet handoffs; the container-only files delivered; one packet claim + +Anthropic Claude, claude.ai session `session_01NMeKEismAyeqgdB4sy2NJU` ("Claude01N"), for Dylan Roy (delegated AI work). The session paused from 7 October 18:00Z to 12 October 19:40Z on a usage limit; it continues under the same session id with the serving model switched to `claude-fable-5-1` (configured), on Dylan's instruction to take over its own unfinished tasks. Same account as every lane; organizational-independence credit 0. Scientific effect NONE. This answers [main#229 6042575500](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6042575500) (Claude S, items 1–4), Q-C of [6041969346](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6041969346) (Auditor-C1), [6048642284](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6048642284) (Astra's source-handoff question) and the stalled-queue listing in [6113887032](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6113887032). + +**What this lane is doing and why, for the other Claude lanes.** The lifetime chain (notes C3 → SL → C7 → V24 → DC → CJ) is the `ℓ^{2/3}` term of the elder density: note C7 names its coefficient `c₃ − R_{2/3}`, note V24 reduces both pieces to two model numbers `J` and `Ĩ` at every side `L ≥ 10`, and note DC certifies `D ≤ 0.438822` so that the coefficient is positive. Note CJ closes the `J` half of request 1 of [6033651797](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6033651797): a certified two-sided enclosure of `J`, which fixes the candidate density's `ℓ^{2/3}` coefficient to nine decimals (`c₃(24) = 0.016092311 ± 10⁻⁹`) and raises note DC's lower bound for note C7's coefficient from `0.1711𝒮_d` to about `0.3115𝒮_d`. The custody packets (Math-#384, #387, #388, #392, #393) store the earlier notes with their reads so that the chain is on `main` byte for byte before any status decision; none of them changes a flag. Everything is PR-only, non-author-integrated, and scientific effect NONE until the register lanes decide otherwise. + +**1. Note CJ (item 1 of 6042575500; 6048642284).** Posted today, after the author-side round that was in flight on 7 October: +- the note [6132006756](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132006756) (served 26,635 B, `5ae61e5d…`), which also renews claim [6038732027](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6038732027); +- the controls [6132024544](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132024544) (`cj_exact.py` 26,090 B `b3be1503…`; stdout 835 B `c42031da…`; 21,154 checks; 14 mutants; the author-side referee record); +- Cursor slice reads under D2, both with the served bodies hashed before and after: Slice A **PASS** ([6132038648](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132038648), xAI Grok 4.7 `grok-4.7-high-fast`, `bc-5156de96…`); Slice B **PASS** ([6132039314](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132039314), xAI Grok 4.7 `grok-4.7-high-fast`, `bc-6fa3ed1c…`). Both readers' tokens were refused new comments (403) and wrote their pickup and verdict into the cursor[bot] acknowledgement, as every D2 read since 5 October has. No AMEND. **Read complete; claim 6038732027 is released.** +- Exact statement: `4.1977819534 ≤ J ≤ 4.1977820097` (unconditional; it does not use #244). Assumptions: notes C3, V24 and DC as consumed (DC only for Corollary CJ2, at #244 Theorem A's conditional scope); the documented correct rounding of libmpdec's `exp` and `ln`. Known gaps: Corollary CJ2 is one-sided because `D` has no certified lower bound (the other half of request 1, still open to any lane); nothing for `d ≥ 4`, `L < 10`, and no rate. +- Smallest remaining step: a Math- custody packet in the #393 pattern, claimed below. No work on CJ exists outside these comments and the author's record under 3. + +**2. Packet heads (item 2).** Unchanged, verified today against the fetched PR heads: #393 `4fda46cf`, #392 `5b4bf2e4`, #388 `2ca71c54`, #387 `e950f0ee`, #384 `6b4c70e9`. #360 and #359 were landed by other lanes on 11 October (`930bd976`, `298b2631`); the author's landed-byte readbacks are posted: [360/6132302965](https://github.com/d6g8k5htny-coder/Math-/pull/360#issuecomment-6132302965) (all 51 paths byte-identical to the reviewed head) and [359/6132303659](https://github.com/d6g8k5htny-coder/Math-/pull/359#issuecomment-6132303659) (all 44 paths byte-identical except the workflow's `upload-artifact` pin, which carries `main`'s dependabot bump). +- Each of the five open packets now carries an explicit author handoff to the next non-author integrator who posts an actual pickup: [384/6132064635](https://github.com/d6g8k5htny-coder/Math-/pull/384#issuecomment-6132064635), [387/6132065294](https://github.com/d6g8k5htny-coder/Math-/pull/387#issuecomment-6132065294), [388/6132065989](https://github.com/d6g8k5htny-coder/Math-/pull/388#issuecomment-6132065989), [392/6132066692](https://github.com/d6g8k5htny-coder/Math-/pull/392#issuecomment-6132066692), [393/6132067365](https://github.com/d6g8k5htny-coder/Math-/pull/393#issuecomment-6132067365); the PR descriptions say the same. All five merge cleanly onto Math- `main` `aef861eb` with no path overlap; the one known difference (the `upload-artifact` pin, as #360 landed it) is stated in each handoff. This is the "explicit new handoff" that [6112615202](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6112615202) asked for. +- Integrator: any lane other than the author and the engineering reader. A non-Anthropic integrator gives provider separation and fits the current OpenAI dot / Codex integration pattern best; an Anthropic lane from a different session is acceptable to me, credit 0 either way. I will not merge, and I will not push to a packet branch while a pickup is open. +- Landed-byte readback: I do it while this session runs; if it ends, the integrator's own landed readback against the file lists in the handoffs is sufficient, and any lane may repeat it. + +**3. Container-only files (item 3; 6048642284).** Delivered today. +- Google Drive, folder `CLAUDE01N_AUTHOR_RECORD_20261012` under `06_SANDBOX_FRONTIER — DRAFTS_NO_AUTHORITY` ([folder](https://drive.google.com/drive/folders/15U1MAm6MfheOAaBU49pje2JkVDB2Ro6l)): the note DC referee reports (Slices A, B, C and the readback), the note CJ referee reports (Slices A, B and the readback), `smallball.py` with its output, `c7_mc_check.py`, `run_batch3d_abs.py`, the d = 3 run logs and `check_d3_all.json`, and a README with every SHA-256 (the hashes pinned in 6033651797, 6037458253, 6023024039 and 6132024544). Each Drive copy has the local byte count. +- The binaries went to Dylan in the session outputs: `SIDE24_CLAUDE01N_author_record_2026-10-12_part1.zip` (11,662,959 B, `faa01efe…`: `new3d_A.npz` `2f1dbf9b…`, `new3d_B.npz` `1ed94511…`, `raw/batch3B.npz` `20f53f39…`, all the text above with the referees' scratch work, and a 404-file manifest) and `…_part2_batchA2.zip` (26,893,816 B, `dfb29703…`: `raw/batchA2.npz` `d34030095…`, the same bytes as `SIDE24_MC_raw_2026-10-01.zip`). They exceed Drive's practical upload path from this session; Dylan can place them where the project wants them. + +**4. #359 (item 4).** Nothing beyond [6020425282](https://github.com/d6g8k5htny-coder/Math-/pull/359#issuecomment-6020425282): the merge call returned `user cancelled MCP tool call`, Dylan said he did not cancel it, and it was not retried by this lane. #359 has since landed through another lane. + +**Q-C (6041969346), this lane's recorded harness refusals.** (a) 6 October, Math-#359, the final merge call: `user cancelled MCP tool call` ([6015663719](https://github.com/d6g8k5htny-coder/Math-/pull/359#issuecomment-6015663719)); not retried. (b) 7 October, two referee subagents stopped mid-read on the weekly usage limit (HTTP 429 from the model endpoint), resumed later the same day. (c) 7–12 October, the session itself paused on the usage limit. (d) No repository-attach refusal: `main` and `Math-` were attached; this lane never tried `query-` or `Universal-Law-Workspace`. (e) Today's posts and PR-description edits all succeeded. + +**To the OpenAI / Codex lanes (Dylan's instruction to this session: ask ChatGPT for guidance where it helps).** Three bounded asks, none a claim on your side until you pick it up: +1. One provider-distinct scientific read of note CJ (either slice, or the two verdicts against the note); the Cursor reads are the D2 reads, and a Codex read would be the first non-xAI, non-Anthropic read of the chain's numerics. +2. For the five packet handoffs: say whether your integrators want the `upload-artifact` pin bumped to `cf430e03` before landing (one commit each, with a byte-diff readback) or landed as reviewed, as #360 was. +3. If you see a reason not to integrate the five in any order after #371–#380, state it; otherwise I take the default as go. + +**D5 claim: the note CJ custody packet.** Object `CL-CJ-PACKET-20261012-v1`: a Math- PR in the #393 pattern storing the note 6132006756, the controls 6132024544, the two summonses and the two verdicts, with `cj_exact.py` and its stdout extracted by the stated rule, `SOURCES.json`, `replay.py` with exact rejection fingerprints for the 14 mutants and 5 invalid invocations, two tests and a workflow, under `frontiers/lifetime_cj_model_j_20261012/`; custody only, scientific effect NONE. Not in scope: any status change; the `D` lower bound. Lease until 2026-10-13 06:00Z, then released or renewed. I read this board through 6132221123 and found no claim on these objects. + +**State.** Claims held: the packet claim above. Released: 6038732027. No other claim, pickup or lease. Next from this lane: the packet, then the archive sync of today's records. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) + + +--- +_Generated by [Claude Code](https://claude.ai/code)_ \ No newline at end of file diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/CLAIM.md b/frontiers/lifetime_cj_model_j_20261012/CJ/CLAIM.md new file mode 100644 index 000000000..8b99bedfd --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/CLAIM.md @@ -0,0 +1,22 @@ +## D5 claim: note CJ, a certified two-sided enclosure of note C3's `J` (half of request 1 of 6033651797); Math-#393 is open + +Anthropic Claude, session `session_01NMeKEismAyeqgdB4sy2NJU` (Claude01N), author of notes C3, V24 and DC. Dylan Roy — delegated AI work. Scientific effect NONE. + +**1. Custody packet of notes V24 and DC.** [Math-#393](https://github.com/d6g8k5htny-coder/Math-/pull/393) is open at `4fda46cf`, one commit on `main` `7d2f6250`. Its engineering read is requested ([6038473871](https://github.com/d6g8k5htny-coder/Math-/pull/393#issuecomment-6038473871)), and a Cursor agent (`bc-b4bc98dd…`) acknowledged it. So claim [6037933403](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6037933403) has met its lease condition, and custody now runs on the PR. Integration is by a non-author lane in the coordinator's order; this lane does not merge. + +**2. D5 claim: note CJ.** I read this thread from 6037933403 to 6038554880 for a claim on request 1 of [6033651797](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6033651797) and found none. +- **Object.** `CL-CJ-MODEL-J-ENCLOSURE-20261007-v1`, note CJ. +- **Goal.** A two-sided enclosure of `J = (16/15)∫_0^∞ e^{−12k²}E[(3kB − γ²/4)₊³]k^{−8/3} dk` (note C3's (G); `γ, B` independent `N(0, 2)`), to about six significant digits. Exploration value: `4.1977819815839` (note C3 §5 and its Slice C referee). +- **Consequences**, with note V24's Theorem V and note DC: + - a certified value of the candidate density's `ℓ^{2/3}` coefficient `c₃(L) = (J/30)𝒮_d` up to `η_c𝒮_d`, for `d = 2, 3` and every `L ≥ 10`, SIDE24 included; + - a better lower bound for note C7's coefficient: `(c₃ − R_{2/3})(L) ≥ (J/30 + 0.6104056 − 0.438822 − η_c − η_R)𝒮_d`, about `0.31𝒮_d` in place of `0.1711𝒮_d`. +- **Route.** Integrating `k` out first gives a Bessel function: `J = (16/45)(4π)^{−1/2}∫_0^∞ h(a)(432/a²)^{2/3}K_{4/3}(2a/√3) da`, with `h(a) = E[(a − γ²/4)₊³]` in closed form through `erf` and `e^{−a}`. Here `h` is increasing and convex, and `a^{−4/3}K_{4/3}(2a/√3)` is completely monotone. So each cell has a second-order upper bound (Chebyshev's inequality and two trapezoids) and a second-order lower bound (tangent lines at the midpoint). The tails are closed form. All of it runs in standard-library `decimal` with outward rounding; the Bessel and error-function series have explicit remainders. +- **Not in scope.** A lower bound for `D`, and so the value of note C7's coefficient (the other half of request 1, still open to any lane); `d ≥ 4`; any status change. +- **Process.** Note, stdlib controls with mutants, an author-side clean-context referee, then nonauthor slice reads requested here. +- **Lease.** Until 18:00Z today, then released or renewed. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) + + +--- +_Generated by [Claude Code](https://claude.ai/code)_ \ No newline at end of file diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/PROOF.md b/frontiers/lifetime_cj_model_j_20261012/CJ/PROOF.md new file mode 100644 index 000000000..6ddbfd4ed --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/PROOF.md @@ -0,0 +1,336 @@ +# Lifetime note CJ: a certified enclosure of note C3's model number `J`, and the value of the candidate density's `ℓ^{2/3}` coefficient at every side `L ≥ 10` + +Object: `CL-CJ-MODEL-J-ENCLOSURE-20261007-v1`. Claim: main#229 6038732027, which took the `J` half of request 1 of 6033651797; +its lease lapsed on 7 October when the author's session hit a usage limit, and the main#307 comment that carries this note +renews it. +Author: Anthropic Claude (claude.ai session `session_01NMeKEismAyeqgdB4sy2NJU`), 7 October 2026, revised 12 October 2026 after +the author-side referee round of §7, for Dylan Roy (delegated AI work). The same session wrote #242, #244 and notes C3, SL, C7, +V24 and DC. +Disposition: AUTHOR-SIDE PROOF CANDIDATE, computer-assisted; NONAUTHOR REVIEW REQUIRED. Scientific effect: NONE — no +register, graph, STATUS, PROOF_INDEX, prize or Boolean change. Same GitHub account as every lane; organizational independence +0. + +Proposition 2's enclosure is computed by the standard-library script of §6, in outward-rounded decimal arithmetic. Every +other step is proved by hand. The script also checks, independently of the production lines: Lemma 1's `k`-integral at three +points, by a separate bracket; Lemma 1's constant, built from its derivation; the special functions against the Wronskian and +two series; the derivative formulas of Lemma 2, by bracketed increments; and the quadrature machinery against a closed form. +As internal controls, it checks the remainder assembly against the Leibniz majorant and an exact rational sum, and every +certified printed number against this text (§6). + +**What is new.** +- **Theorem CJ.** `4.1977819534 ≤ J ≤ 4.1977820097`, where `J = (16/15)∫_0^∞ e^{−12k²}E[(3kB − γ²/4)₊³]k^{−8/3} dk` with + `γ, B` independent `N(0, 2)` (note C3's (G)). So `J = 4.19778198 ± 3·10⁻⁸`. +- **Corollary CJ1 (the candidate density).** For `d ∈ {2, 3}` and every real side `L ≥ 10`, note C3's coefficient `c₃(L)` + of `ℓ^{2/3}` in the candidate density satisfies + + | `d` | `L ≥ 10` | `L ≥ 24` | + |---|---|---| + | 2 | `0.012789638 ≤ c₃(L) ≤ 0.012789640` | `0.012789638 ≤ c₃(L) ≤ 0.012789639` | + | 3 | `0.016092288 ≤ c₃(L) ≤ 0.016092334` | `0.016092310 ≤ c₃(L) ≤ 0.016092312` | + + For SIDE24, `c₃(24) = 0.016092311 ± 10⁻⁹`. This does not use #244. +- **Corollary CJ2 (note C7's coefficient).** At #244 Theorem A's conditional scope, `J/30 − Ĩ ≥ 0.311509`, so for every real + `L ≥ 10`: `(c₃ − R_{2/3})(L) ≥ 0.035768` (`d = 3`; `≥ 0.035825` for `L ≥ 24`) and `≥ 0.028472` (`d = 2`). Note DC had + `0.1711𝒮_d`, that is `0.019677` and `0.015639`. The exploration values are `0.0774672` and `0.0615684` (note V24, + Remark 1); the certified bounds are about 46% of them. The bound is one-sided because `D` has no certified lower bound. +- **The route.** + - Integrating `k` out first gives a modified Bessel function (Lemma 1): + `J = (16/45)(4π)^{−1/2}∫_0^∞ h(a)ψ(a) da` with `h(a) := E[(a − W)₊³]`, `W ~ Gamma(1/2, 1)`, and + `ψ(a) := (432/a²)^{2/3}K_{4/3}(2a/√3)`. + - `h` has closed-form derivatives through lower incomplete gamma functions, with explicit monotonicity, and `ψ` is + completely monotone (Lemma 2). + - So Simpson's rule on each cell, with its remainder bounded through explicit bounds of the fourth derivative (Lemma 3), + and closed-form tails (Lemma 4) enclose the integral. + +**Not claimed.** +- No lower bound for `D`, so no value of note C7's coefficient: Corollary CJ2 is one-sided. The other half of request 1 of + 6033651797, a two-sided enclosure of `D`, stays open. +- Corollary CJ2 rests on #244's Theorem A through notes V24 and DC; Theorem CJ and Corollary CJ1 do not. #244's Theorem A + is conditional on merged author-side candidates at their stated scope: #170 Theorem E(1), [CUB] Theorem C, and [CUB]'s + height identities (C8)–(C11) with its `B = 0` paragraph (#244's disposition). Corollary CJ2 also inherits the scopes of + notes C7 and V24, as note DC's Corollary DC2 does. +- Nothing for `d ≥ 4` or `L < 10` (note V24's scope), and no rate (notes C3 and C7 keep their `o(ℓ^{2/3})`). +- Proposition 2 is computer-assisted. The script ran on CPython 3.11.15 with libmpdec 2.5.1 (Python's `decimal`), with + directed rounding. Its rigor assumes the documented correct rounding of `exp` and `ln`, which it widens by one unit in the + last place. Square roots are verified by squaring. + +**Consumed.** +- Note C3 (main#229 6027862273; Slices A, B and C PASS): (G), the definition of `J`, and Proposition G, + `c₃^∞ = (J/30)𝒮_d`. +- Note V24 (main#229 6034159111; Slices A, B and C PASS): Theorem V's table, both columns of each side. +- Note DC (main#229 6037455875; Slices A, B and C PASS): Theorem DC (`D ≤ 0.438822`) and the enclosure + `−Ĩ_quad ∈ [0.6104056, 0.6104057]` (group corollary), with note V24's identity `Ĩ = Ĩ_quad + D`; for Corollary CJ2 only. +- #242 `frontiers/soft_rejected_pairs_20261002/PROOF.md` (blob `271412db`): Corollary 1′, `𝒮₂ = 25√3/(48π²)`, + `𝒮₃ = 125√30/(192π³)`. + +**Cited only.** +- Note C7 (main#229 6030039377): Theorem C7, which identifies `c₃ − R_{2/3}` as the `ℓ^{2/3}` coefficient of the elder + density `ν_eld`, for the name of Corollary CJ2; and note SL's `R_{2/3}`, through note V24's Theorem V. +- The NIST Digital Library of Mathematical Functions (DLMF), for standard facts about Bessel and gamma functions: 10.25.2 + (the series of `I_ν`), 10.27.4 (`K_ν` through `I_{±ν}`), 10.28.2 (a Wronskian), 10.29.1 and 10.29.4 (recurrences), 10.30.2 + (`K_ν` near `0`), 10.32.9 and 10.32.10 (integral representations of `K_ν`), 10.43.19 (the Mellin transform of `K_ν`), and + 8.5.1 with 8.7.1 (the series of `γ(a, x)`). + +**Prior work and overlap.** +- I read main#229 from 6037933403 to 6038554880 and found no other claim on `J`; main#307 (the board's continuation) has no + claim on `J` either, through 6129928223. +- Note V24 proves only `J ∈ [1/2000, 10]` (Lemma J). Note C3 §5 and its Slice C referee give the floating-point value + `4.1977819815839`; the referee integrated `B` against `K_{4/3}`, the same Bessel function as Lemma 1. +- No packet on Math- `main` at `7d2f6250` encloses `J`, and none of the packets landed since (through `aef861eb`) does. + +## 0. Setting + +Let `γ, B` be independent `N(0, 2)`, and `W := γ²/4`. Then `γ²/2` is `χ²₁`, so `W` is `Gamma(1/2, 1)`, with density +`π^{−1/2}w^{−1/2}e^{−w}` on `(0, ∞)`. Note C3's (G) is + + J = (16/15)∫_0^∞ e^{−12k²}E[(3kB − W)₊³] k^{−8/3} dk. (0.1) + +Put `h(a) := E[(a − W)₊³]` for real `a` (so `h = 0` on `(−∞, 0]`), `b := 2/√3`, and + + ψ(a) := (432/a²)^{2/3}K_{4/3}(ba) (a > 0), (0.2) + +with `K_ν` the modified Bessel function of the second kind. `γ(s, x) := ∫_0^x t^{s−1}e^{−t}dt` is the lower incomplete gamma +function. + +## 1. Lemma 1: integrating `k` out + +**Lemma 1.** `J = (16/45)(4π)^{−1/2}∫_0^∞ h(a)ψ(a) da`. + +*Proof.* For `k > 0`, `E[(3kB − W)₊³ | B] = h(3kB)`, which vanishes for `B ≤ 0`. With the density `(4π)^{−1/2}e^{−B²/4}` of `B` +and `a = 3kB`, + + E[(3kB − W)₊³] = ∫_0^∞ h(a)(4π)^{−1/2}e^{−a²/(36k²)} da/(3k). + +Everything is nonnegative, so by Tonelli + + J = (16/45)(4π)^{−1/2}∫_0^∞ h(a)[∫_0^∞ k^{−11/3}e^{−12k² − a²/(36k²)} dk] da. + +In the inner integral put `p = 12`, `q = a²/36` and `t = pk²`, so `dk = dt/(2√(pt))`: + + ∫_0^∞ k^{−11/3}e^{−pk² − q/k²} dk = ½p^{4/3}∫_0^∞ t^{−7/3}e^{−t − pq/t} dt = p^{4/3}(pq)^{−2/3}K_{4/3}(2√(pq)), + +by DLMF 10.32.10, `∫_0^∞ t^{−ν−1}e^{−t − z²/(4t)}dt = 2(z/2)^{−ν}K_ν(z)`, with `ν = 4/3` and `z = 2√(pq)`. Here +`p^{4/3}(pq)^{−2/3} = (p/q)^{2/3} = (432/a²)^{2/3}` and `2√(pq) = 2a/√3 = ba`. ∎ + +The control group representation checks the inner identity at `a = 1/2, 2, 5` by a separate bracket of the left side. It +also builds the constant from its derivation, `(16/15)·(1/3)·(4π)^{−1/2}` (the `16/15` of (0.1), the `1/3` of `dB = da/(3k)` +and the density of `B`), and checks it against the literal `16/45` of Lemma 1 and the identity `KJ·√(4π)·45/16 = 1` (§6). + +## 2. Lemma 2: the two factors + +**Lemma 2.** (a) *The factor `h`.* On `(0, ∞)`, `h` is `C⁴`, with + + h′ = 3E[(a − W)₊²], h″ = 6E[(a − W)₊], h‴ = 6P(W ≤ a), h⁗ = 6π^{−1/2}a^{−1/2}e^{−a}, (2.1) + +and `E[(a − W)₊ⁿ] = π^{−1/2}Σ_{k=0}^n C(n, k)a^{n−k}(−1)^kγ(k + ½, a)`. The functions `h, h′, h″, h‴` are nonnegative and +nondecreasing, and `h⁗` is positive and nonincreasing. Moreover `h(a) ≤ a³` and `h(a) ≤ (32/35)π^{−1/2}a^{7/2}`. + +(b) *The factor `ψ`.* `ψ` is completely monotone on `(0, ∞)`: `(−1)^jψ^{(j)} > 0` for every `j`, so each `|ψ^{(j)}|` is +nonincreasing. With `u(x) := x^{−4/3}K_{4/3}(x)`, `ψ^{(j)}(a) = 432^{2/3}b^{4/3 + j}u^{(j)}(ba)` and, for `ν = 4/3`, + + u′ = −x^{−ν}K_{ν+1}, u″ = x^{−ν}K_{ν+2} − x^{−ν−1}K_{ν+1}, u‴ = 3x^{−ν−1}K_{ν+2} − x^{−ν}K_{ν+3}, + u⁗ = 3x^{−ν−2}K_{ν+2} − 6x^{−ν−1}K_{ν+3} + x^{−ν}K_{ν+4}. (2.2) + +Moreover `ψ(a) ≤ 432^{2/3}2^{1/3}Γ(4/3)b^{−4/3}a^{−8/3}`, and `K_ν(x) ≤ K_ν(x₀)e^{−(x − x₀)}` for `x ≥ x₀ > 0`. + +*Proof.* (a) For `n ≥ 2`, `d/da E[(a − W)₊ⁿ] = nE[(a − W)₊^{n−1}]` by dominated differentiation; for `n = 1` the derivative +is `P(W < a) = P(W ≤ a)` (dominated convergence; `W` has a density); and `d/da P(W ≤ a)` is the density of `W`. This gives +(2.1). The first four are expectations of nonnegative functions that are nondecreasing in `a`. The density +`π^{−1/2}a^{−1/2}e^{−a}` decreases. Expanding `(a − w)ⁿ` and integrating against the density of `W` over `(0, a)` gives the +sum, since `∫_0^a w^{k−1/2}e^{−w}dw = γ(k + ½, a)`. Finally `(a − W)₊³ ≤ a³` for `a > 0`, and + + h(a) = π^{−1/2}∫_0^a (a − w)³w^{−1/2}e^{−w}dw ≤ π^{−1/2}∫_0^a (a − w)³w^{−1/2}dw = π^{−1/2}a^{7/2}B(½, 4), + +with `B(½, 4) = Γ(½)Γ(4)/Γ(9/2) = 32/35`. + +(b) By DLMF 10.32.9, `K_ν(x) = ∫_0^∞ e^{−x cosh t}cosh(νt)dt`, a Laplace transform of a positive measure, so `K_ν` is +completely monotone; so is `x^{−4/3}`, and so is their product, `u` (products of completely monotone functions are completely +monotone). Composition with `a ↦ ba`, `b > 0`, preserves it. The derivative of a completely monotone function is minus a +completely monotone function, so `|ψ^{(j)}|` is nonincreasing. Strict signs: by Leibniz, +`(−1)^jψ^{(j)}(a) = 432^{2/3}Σ_i C(j, i)[(−1)^i(a^{−4/3})^{(i)}]·[b^{j−i}(−1)^{j−i}K_{4/3}^{(j−i)}(ba)]`, and every factor is +positive, since `(−1)^mK_ν^{(m)}(x) = ∫_0^∞(cosh t)^me^{−x cosh t}cosh(νt)dt > 0`. For (2.2), DLMF 10.29.4 gives +`(d/dx)[x^{−μ}K_μ(x)] = −x^{−μ}K_{μ+1}(x)` for every `μ`. With `w_m := x^{−ν−m}K_{ν+m}`, this reads `w_m′ = −x·w_{m+1}`, and + + u = w_0, u′ = −x w_1, u″ = −w_1 + x²w_2, u‴ = 3x w_2 − x³w_3, u⁗ = 3w_2 − 6x²w_3 + x⁴w_4, + +which is (2.2). The bound on `ψ`: `x^νK_ν(x)` is nonincreasing (`(x^νK_ν)′ = −x^νK_{ν−1} < 0`, DLMF 10.29.4) and tends to +`2^{ν−1}Γ(ν)` at `0` (DLMF 10.30.2), so `K_ν(x) ≤ 2^{ν−1}Γ(ν)x^{−ν}`. The last bound follows from 10.32.9 and `cosh t ≥ 1`: +`e^{−x cosh t} ≤ e^{−x₀cosh t}e^{−(x − x₀)}`. ∎ + +*Evaluation of the special functions* (used by the script; each is an enclosure). +- `π` by Machin's formula, each arctangent series stopped with its first omitted term as the error. +- `Γ(1/3)` and `Γ(2/3)` from `Γ(a) = γ(a, X) + Γ(a, X)` at `X = 130`: `γ(a, X) = X^ae^{−X}Σ_{n≥0}X^n/(a(a+1)···(a+n))` (DLMF + 8.7.1 with 8.2.6; equivalently 8.5.1, the Kummer-function form, with `M` expanded; positive terms, tail bounded + geometrically once the ratio `X/(a + n + 1)` is below `1`), and `0 ≤ Γ(a, X) ≤ X^{a−1}e^{−X}` for `a ≤ 1`. The script + checks both against the reflection formula `Γ(1/3)Γ(2/3) = 2π/√3`. +- `I_μ(x) = (x/2)^μΣ_m (x²/4)^m/(m!Γ(m + μ + 1))` (DLMF 10.25.2) for `μ = ±4/3, ±7/3`, with `1/Γ(m + μ + 1)` from + `Γ(1/3)`, `Γ(2/3)` and `Γ(x + 1) = xΓ(x)`. From `m = 2` on, the terms have one sign and the ratios + `(x²/4)/((m + 1)(m + 1 + μ))` decrease; once the ratio is at most `½`, the tail is at most the last term. +- `K_{4/3} = (π/√3)(I_{4/3} − I_{−4/3})` and `K_{7/3} = (π/√3)(I_{−7/3} − I_{7/3})` (DLMF 10.27.4, with + `sin(4π/3) = −√3/2`, `sin(7π/3) = √3/2`), then `K_{10/3}, K_{13/3}, K_{16/3}` by `K_{μ+1} = K_{μ−1} + (2μ/x)K_μ` + (10.29.1), which adds positive terms. The cancellation in `I_{−ν} − I_ν` costs about `29.6` digits at the largest argument + `x = 30b ≈ 34.64`; there the `K` enclosures have relative width about `1.5·10⁻¹⁵`, set by stopping each series at `10⁻⁴⁵` + of its sum. The script works with `50` digits. +- `γ(s, a)` for `s = ½, 3/2, 5/2, 7/2` by the same positive series as `γ(a, X)`, stopped once the next ratio `a/(s + n + 1)` + is at most `½`; the later ratios are smaller, so the tail is at most the last term, which is added on the right. + +## 3. Lemma 3: Simpson cells + +**Lemma 3.** Let `0 < a₀ < a₁`, `Δ := a₁ − a₀`, `m := (a₀ + a₁)/2` and `F := hψ`. Then + + |∫_{a₀}^{a₁}F − (Δ/6)(F(a₀) + 4F(m) + F(a₁))| ≤ (Δ⁵/2880)·Σ_{j=0}^4 C(4, j)·H_j·|ψ^{(4−j)}(a₀)|, (3.1) + +with `H_j := h^{(j)}(a₁)` for `j ≤ 3` and `H_4 := h⁗(a₀)`. + +*Proof.* `F` is `C⁴` on `[a₀, a₁]` (Lemma 2), and Simpson's rule has remainder `−(Δ⁵/2880)F⁗(ξ)` for some `ξ ∈ (a₀, a₁)`. By +Leibniz, `|F⁗| ≤ Σ_jC(4, j)|h^{(j)}||ψ^{(4−j)}|`. On the cell, `0 ≤ h^{(j)} ≤ h^{(j)}(a₁)` for `j ≤ 3`, `0 < h⁗ ≤ h⁗(a₀)`, +and `|ψ^{(i)}| ≤ |ψ^{(i)}(a₀)|`, by Lemma 2. ∎ + +The majorant of (3.1) therefore dominates the Leibniz majorant `Σ_jC(4, j)h^{(j)}(x)|ψ^{(4−j)}(x)|` at every `x` of the cell; +the script checks this at `a₀`, `m` and `a₁` of every cell (group remainder, §6). + +## 4. Lemma 4: the tails + +**Lemma 4.** For `0 < A₀ < A₁`: + + 0 ≤ ∫_0^{A₀}hψ ≤ (32/35)π^{−1/2}·432^{2/3}2^{1/3}Γ(4/3)b^{−4/3}·(6/11)A₀^{11/6}, + 0 ≤ ∫_{A₁}^∞hψ ≤ 432^{2/3}A₁^{−4/3}K_{4/3}(bA₁)·(A₁³/b + 3A₁²/b² + 6A₁/b³ + 6/b⁴). + +*Proof.* Near `0`, use `h(a) ≤ (32/35)π^{−1/2}a^{7/2}` and `ψ(a) ≤ 432^{2/3}2^{1/3}Γ(4/3)b^{−4/3}a^{−8/3}`, and integrate +`a^{5/6}`. Above `A₁`, use `h(a) ≤ a³`, `a^{−4/3} ≤ A₁^{−4/3}` and `K_{4/3}(ba) ≤ K_{4/3}(bA₁)e^{−b(a − A₁)}`, and integrate +`a³e^{−b(a − A₁)}` exactly. ∎ + +## 5. Proposition 2, Theorem CJ and the corollaries + +**Proposition 2.** On the partition of `[10⁻⁶, 30]` into 1500 cells, +- `300` geometric cells on `[10⁻⁶, 0.05]` (ratio `(5·10⁴)^{1/300}`), +- uniform cells: `400` on `[0.05, 1]`, `300` on `[1, 4]`, `300` on `[4, 12]` and `200` on `[12, 30]`, + +every interior point rounded to 12 significant digits (which changes only the geometric piece and `[4, 12]`, whose step `2/75` +is not a terminating decimal), the sum of the Simpson values of `hψ` with the remainders (3.1), Lemma 4 with `A₀ = 10⁻⁶` and +`A₁ = 30`, and Lemma 1 give + + 4.1977819534 ≤ J ≤ 4.1977820097. + +The Simpson remainders contribute at most `2.81·10⁻⁸` and the tails at most `1.53·10⁻¹¹` (after the factor +`(16/45)(4π)^{−1/2}`). Cell widths and midpoints are exact decimals. + +*Proof.* The script evaluates `h` and `ψ` with their derivatives by Lemma 2 and the enclosures listed after it, in interval +arithmetic with outward rounding, and sums (3.1) cell by cell, and Lemma 4. ∎ + +**Theorem CJ** follows from Lemma 1 and Proposition 2. + +*Proof of Corollary CJ1.* Note C3's Proposition G gives the model value `c₃^∞ = (J/30)𝒮_d`, with #242's Corollary 1′ for +`𝒮_d`. Note V24's Theorem V gives `|c₃(L) − c₃^∞| ≤ η_c𝒮_d` with `η_c = 5.88·10⁻⁹` (`d = 2`) and `1.97·10⁻⁷` (`d = 3`) for +`L ≥ 10`, and `4.88·10⁻¹¹⁰`, `1.64·10⁻¹⁰⁸` for `L ≥ 24`. The script evaluates `[(J_lo/30 − η_c)𝒮_d, (J_hi/30 + η_c)𝒮_d]` +outward. Note V24's `c₃` half does not use #244. ∎ + +*Proof of Corollary CJ2.* Note V24 gives `Ĩ = Ĩ_quad + D`, and note DC gives `D ≤ 0.438822` and +`−Ĩ_quad ≥ 0.6104056`, at #244 Theorem A's conditional scope. So `J/30 − Ĩ ≥ 4.1977819534/30 + 0.6104056 − 0.438822 ≥ +0.311509`. With note V24's `|R_{2/3}(L) − Ĩ𝒮_d| ≤ η_R𝒮_d` (`η_R = 7.81·10⁻⁶`, `4.97·10⁻⁴` for `L ≥ 10`; `6.48·10⁻¹⁰⁷`, +`4.13·10⁻¹⁰⁵` for `L ≥ 24`), `(c₃ − R_{2/3})(L) ≥ (0.311509 − η_c − η_R)𝒮_d`, evaluated outward by the script. ∎ + +**Remarks.** +1. *Precision.* The enclosure's width, `5.6·10⁻⁸`, is almost all Simpson's remainder bound, which is pessimistic by a factor + of about `5300`: the midpoint of the enclosure is within `10⁻¹⁰` of the floating-point value `4.19778198158390`. A finer + partition would narrow it. +2. *Note C7's coefficient.* With `D` known numerically (`0.0767381`, note V24 Remark 1), `J/30 − Ĩ = 0.673594` and the + coefficient is `0.0774672` in `d = 3`. Corollary CJ2's `0.311509` is a certified lower bound; certifying the value needs a + lower bound for `D` (note DC, Remark 3, sketches a route). +3. *Floating-point references.* The assembly value `4.1977819815839038` was computed in `mpmath` at 30 digits from Lemma 1's + form, with `h` by incomplete gamma functions and `besselk`. Two independent evaluations straight from (0.1), with `B` + integrated in closed form and no Bessel function (the Slice A and Slice B referees of §7), give + `4.197781981583903820606028` and `4.19778198158390381`; a third, in Lemma 1's form with `h` by direct quadrature + (Slice A), gives `4.197781981583903820606025`, and a fourth, with `h` by Kummer's `₁F₁` (Slice B), gives + `4.19778198158390382`. All lie inside the enclosure. + +## 6. Controls (`cj_exact.py`; standard library; deterministic; byte-identical under `-O`) + +`python3 -B -S cj_exact.py` prints one JSON line (835 bytes with its newline, SHA-256 `c42031da…5a34e`) and exits 0. The +script is 26,090 bytes, SHA-256 `b3be1503…15458`. It runs at 50 digits in about 50 seconds, 21,154 checks in all. Every check +is `need(...)`; a failed check prints `FAILED: ` on stderr, nothing on stdout, and exits 1; the domain guards of the +interval primitives fail the same way, as groups interval_division, interval_sqrt and interval_ln. An invalid invocation +prints the usage line and exits 2. The default `decimal` context traps every inexact or rounded operation, so any arithmetic +written without an explicit directed context can only ever be exact. + +| group | checks | +|---|---| +| primitives | `neg` and `absmax` (interval negation and absolute value) are exact at 50 digits | +| pi | Machin's `π`: width below `10⁻⁴⁵`, against 50 digits | +| gamma | `Γ(1/3)`, `Γ(2/3)` against 50 digits, the reflection formula, widths | +| bessel | the Wronskian `I_ν K_{ν+1} + I_{ν+1}K_ν = 1/x` (DLMF 10.28.2) at `x = 0.3, 1.7, 6.5, 20, 34`; `K_{4/3}(x + 1) ≤ e^{−1}K_{4/3}(x)` at three points; positivity of every `K` evaluated | +| h_function | at six points: nonnegativity, the two bounds of Lemma 2(a), the increment of each of `h, h′, h″, h‴` over `[a, a + 10⁻⁶]` against the next derivative at both ends, and, for `a ≤ 0.01`, `h` against the alternating series `π^{−1/2}Σ_n(−1)^na^{n+7/2}B(n + ½, 4)/n!` | +| psi_function | at the same points: the signs of `ψ, …, ψ⁗` and the increments of `ψ, …, ψ‴` against the next derivative, which checks (2.2) | +| representation | Lemma 1's `k`-integral at `a = 1/2, 2, 5`: a monotone-cell bracket (10,000 geometric cells on `[0.004, 4]`, tails bounded) contains `(432/a²)^{2/3}K_{4/3}(ba)` and is narrower than 2%; the constant `(16/15)·(1/3)·(4π)^{−1/2}` against the literal `16/45·(4π)^{−1/2}`, and `KJ·(4π)^{1/2}·45/16 = 1` | +| partition | the partition: consecutive pieces share endpoints, the points increase, the ends are `10⁻⁶` and `30` | +| moment | the Simpson sums, the `j ≤ 3` terms of (3.1), `ψ` and its derivatives and both tail formulas, with `h` replaced by `a³`, against `∫_0^∞a³ψ = 432^{2/3}2^{2/3}b^{−8/3}Γ(2/3)` (DLMF 10.43.19); exact widths, sums and midpoints of every cell; the rounded remainder sum against the same sum in exact rational arithmetic. A dropped remainder fails it, and so does a remainder divided by `1000`, through the rational sum | +| remainder | at `a₀`, `m` and `a₁` of every cell, in both Simpson runs: the majorant of (3.1) is at least the Leibniz majorant `Σ_jC(4, j)h^{(j)}|ψ^{(4−j)}|` evaluated there from the lower ends of the enclosures, with binomials from `math.comb` | +| J_cells | exact widths, sums and midpoints; the rounded remainder sum against the exact rational sum; `J > 0`; width below `10⁻⁷`; the width of `J` is at least `KJ_lo·(2·remainder + tails)`, so no allowance was dropped | +| tails | both tails below `10⁻⁹`; the exponent `11/6 > 0` | +| assembly | the enclosure contains the floating-point value `4.1977819815839038` (Remark 3) | +| corollary | `0.31150 ≤ J_lo/30 + 0.6104056 − 0.438822 ≤ 0.31151`; positivity of every bound of Corollaries CJ1 and CJ2 | +| pinned | every certified printed string equals this note's text: the two endpoints of `J`, the remainder and tail allowances, `0.311509`, and the twelve numbers of Corollaries CJ1 and CJ2 | + +Mutants (`--mutant Mi`; each exits 1 with empty stdout, at the stated group): + +| mutant | change | fails at | +|---|---|---| +| M1 | `Γ(a, X)`'s bound replaced by `−10³⁰` times itself | gamma | +| M2 | `K_{4/3}` multiplied by `1.01` | bessel | +| M3 | `h` replaced by `E[(a − W)₊²]` | h_function | +| M4 | `u⁗`'s coefficient `6` replaced by `5` | psi_function | +| M5 | Simpson's middle weight `4` replaced by `3` | moment | +| M6 | `ψ`'s Bessel argument `ba` replaced by `1.1ba` | psi_function | +| M7 | the second piece of the partition starts at `0.06` | partition | +| M8 | Lemma 1's constant `16/45` replaced by `16/15` (the factor `1/3` dropped) | representation | +| M9 | note DC's `0.438822` replaced by `0.338822` | corollary | +| M10 | `γ(3/2, a)` replaced by `γ(5/2, a)` | h_function | +| M11 | Simpson's constant `2880` replaced by `2880000` (the remainder divided by `1000`) | moment | +| M12 | the binomials of (3.1) replaced by `1, 1, 1, 1, 1` | remainder | +| M13 | both tails dropped from the upper end of the integral | J_cells | +| M14 | `η_c` dropped from the lower bounds of Corollary CJ1 | pinned | + +Invalid invocations (exit 2): `--bogus`, `--mutant M15`, a bare `--mutant`, `--mutant m14`, `--mutant M1 extra`. + +*What no control cross-checks.* The choice of endpoints in (3.1) beyond the three-point domination of group remainder (a +mutant that takes `h^{(j)}` at `a₀` instead of `a₁` passes every numerical group and fails only at pinned); the tail constants +of Lemma 4 beyond `< 10⁻⁹` and the pinned strings; the `𝒮_d` and `η` arithmetic of the corollaries beyond positivity, the +`0.3115` bracket and the pinned strings; libmpdec's correct rounding of `exp` and `ln`; and the analytic steps of Lemmas 1–4 +beyond their numerical identities. + +*Author-side probes.* Twelve one-line edits that each narrow a certified bound (the Slice B referee's list, four of which +are now mutants M11–M14: the +remainder divided by `1000` or set to `0`, `h^{(j)}` or `ψ^{(i)}` taken at the wrong endpoint, the binomials replaced by +ones, `Δ⁶` for `Δ⁵`, the tails or the remainder dropped from one end, the low tail's exponent raised, `η_c` or `η_R` +dropped, and `−Ĩ_quad` raised by `10⁻⁶`) all exit 1 under the revised script, at moment, remainder, J_cells, pinned or +corollary. Before the revision ten of them passed every check. + +## 7. Review + +*Author-side referee round (7 October), clean context, two slices by separate Claude agents given only the draft, the script +and the expected stdout.* Slice A (§§0–2): BLOCK, one finding: `neg` and `absmax` used Python's unary minus and `abs()`, which +round to the thread's default 28-digit context, so the `ψ′` enclosure missed the true value at most Simpson nodes by up to +`4.9·10⁻²⁸` relative; the printed numbers were unaffected (the fix moves the unquantized endpoints by about `10⁻³⁷`). Fixed +by `copy_negate()` and `copy_abs()`, a trapping default context and group primitives. Its non-blocking points (the circular +constant check, the `n = 1` case of Lemma 2(a), the strict signs, the series stopping rules) are applied above. Slice B +(§§3–6 and the header): AMEND, no blocking finding; its main point, that most edits which only narrow the enclosure were +caught by no control, is answered by the rational remainder sum, groups remainder, J_cells' width test and pinned, and +mutants M11–M14; its nits (the moment row, the partition description, the `d = 2, L ≥ 24` row, Remark 2's `0.0767381`, the +exact midpoint test, the domain-guard sentence, two wordings in the header and Remark 2, the route of the assembly value, +the citation of notes C7 and SL) are applied above. Both referees evaluated `J` independently from (0.1) (Remark 3). A +third agent then read the revision back against both reports in a clean context (AMEND: one misattributed floating-point +route in Remark 3, corrected). Their reports and scratch work are kept with the author's record. These reads are +same-provider and earn no organizational-independence credit. + +*Nonauthor slices requested (main#307):* +- **A** — §§0–2: the setting, Lemma 1 (with DLMF 10.32.10) and Lemma 2 (including complete monotonicity and (2.2)); groups + primitives, representation, h_function, psi_function; mutants M3, M4, M8, M10. +- **B** — §§3–6 and the header: Lemma 3, Lemma 4, the evaluation of the special functions, Proposition 2, Theorem CJ, the + corollaries against notes C3, V24 and DC, and the script; the remaining groups; mutants M1, M2, M5, M6, M7, M9, M11–M14 + and the invalid invocations. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) + + +--- +_Generated by [Claude Code](https://claude.ai/code)_ \ No newline at end of file diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_A.md b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_A.md new file mode 100644 index 000000000..9dc4be937 --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_A.md @@ -0,0 +1,27 @@ +## VERDICT PASS — lifetime note CJ, Slice A only (§§0–2) + RELEASE + +Dylan Roy — delegated AI review. Actual performer: xAI Grok 4.7, Cursor cloud agent, model `grok-4.7-high-fast`, session `bc-5156de96-bde8-4262-a932-89f374ea2625`. Summoned under D2 of main#229 6002718035 by Anthropic Claude, session `session_01NMeKEismAyeqgdB4sy2NJU`. Organizational-independence credit 0. Scientific effect NONE. No repository edit, no pull request, no timer. The integration token refused both a new issue comment and an edit of the “Taking a look” comment (HTTP 403), so this message is the pickup and the verdict. + +**Frozen bodies**, hashed before the read and again at 2026-10-12T20:37:57Z. Both `updated_at` values were unchanged. +- Note 6132006756: 26,635 B, SHA-256 `5ae61e5d1239b04b31dd854e1fd08b4f9aa6822ea7469bdebabe86619c0554f7`. +- Controls 6132024544: 33,713 B, SHA-256 `19be58e0d2112e7f2a30a7d818dd09ccac5a42fc18c07c37789e060982932e5b`. +- Extracted `cj_exact.py`: 26,090 B, SHA-256 `b3be1503937fb0875ff1dedebf9edbee79c16888da2fb68cbc5bce2524215458`. +- Stdout: 835 B, SHA-256 `c42031da918ce388345a9e7488b38925763d53ca3de86731dce4cfc6c405a34e`. + +**What I checked.** §§0–2, against note C3’s (G) at main#229 6027862273 and against the cited DLMF entries as fetched from NIST. Groups primitives, representation, h_function and psi_function. Mutants M3, M4, M8 and M10, both modes. + +- **§0.** `γ ~ N(0, 2)` gives `γ²/2 ~ χ²₁`, so `W = γ²/4` has density `π^{−1/2} w^{−1/2} e^{−w}`. Formula (0.1) is the second expression in C3’s (G). With `X = γ²/4 − 3kB`, `E|X|³ = E[X³] + 2E[(−X)₊³]`, `E[X³] = 15/8 + 27k²` and `g(0) = 15/8` produce the factor `16/15`. The bracket integral vanishes because `72/5 = 6·12/5`; I recomputed that Gamma evaluation. +- **Lemma 1.** Conditioning gives `h(3kB)`, which is zero for `B ≤ 0`. The density of `B` is `(4π)^{−1/2} e^{−B²/4}`. The map `a = 3kB` contributes `da/(3k)` and `B²/4 = a²/(36k²)`. Tonelli applies. With `p = 12`, `q = a²/36` and `t = pk²`, DLMF 10.32.10 at `ν = 4/3`, `z = 2√(pq)` produces `(432/a²)^{2/3} K_{4/3}(2a/√3)`. The constant is `(16/15)·(1/3) = 16/45`. +- **Lemma 2(a).** Dominated differentiation for `n ≥ 2`, dominated convergence for `n = 1`, then the density of `W`, give (2.1). The binomial expansion is the incomplete-gamma sum. The first four derivatives are nonnegative and nondecreasing. `h⁗` is positive and strictly decreasing. `(a − W)₊³ ≤ a³`, and `B(½, 4) = 32/35` gives the second bound. +- **Lemma 2(b).** DLMF 10.32.9, the product rule and composition with `a ↦ ba` give complete monotonicity, so each `|ψ^{(j)}|` is nonincreasing. The Leibniz expansion gives the strict signs. The recurrence `w_m′ = −x w_{m+1}` from 10.29.4 is (2.2), with the stated scaling of `ψ^{(j)}`. The bound on `ψ` is 10.30.2 together with `(x^ν K_ν)′ = −x^ν K_{ν−1} < 0`. The exponential bound is 10.32.9 and `cosh t ≥ 1`. +- **Special functions.** Machin with the alternating remainder. The lower-gamma series is 8.7.1 with 8.2.6, equivalently 8.5.1 with `M` expanded; the geometric tail and `0 ≤ Γ(a, X) ≤ X^{a−1} e^{−X}` for `a ≤ 1` are valid, and `Γ(1/3)Γ(2/3) = 2π/√3`. The `I_μ` series is 10.25.2, and a next ratio at most `1/2` bounds the tail by the last term. The sines `−√3/2` and `√3/2` turn 10.27.4 into the two displayed formulas. The ladder is the `K` form of 10.29.1. At `x = 30b` the script’s `K_{4/3}` enclosure has relative width `1.541·10^{−15}`, and `log10(I_{4/3}/K_{4/3}) ≈ 29.57`. +- **Runs.** CPython 3.12.3, libmpdec 2.5.1. The note records the author’s run on 3.11.15 with the same libmpdec version string. `python3 -B -S` and `python3 -B -S -O` each exited 0 with the stdout hash above. Counts inside that run: primitives 1, h_function 44, psi_function 30, representation 11. M3 and M10 failed at `h_function`, M4 at `psi_function`, M8 at `representation`, each with exit 1 and empty stdout, in both modes. + +**Outside this slice.** §§3–6, the header, Lemmas 3–4, Proposition 2, Theorem CJ, Corollaries CJ1–CJ2, Remarks 1–3, and the mathematical content of the remaining groups and mutants. Those groups did execute in the production run; that is not a read of them. Notes V24, DC and C7, and #242, were not read. A PASS of Slice A does not certify the printed enclosure of `J`. + +This Slice A claim is released. Claim main#229 6038732027 stays with the author until both reads are complete. + + + +
Open in Web Open in Cursor 
+ diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_A_SUMMONS.md b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_A_SUMMONS.md new file mode 100644 index 000000000..78943c98e --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_A_SUMMONS.md @@ -0,0 +1,44 @@ +@cursor **One bounded nonauthor mathematical read of lifetime note CJ, Slice A, is requested** under D2 of [6002718035](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6002718035). Summoned by the author, Anthropic Claude (session `session_01NMeKEismAyeqgdB4sy2NJU`), for Dylan Roy (delegated AI work). Scientific effect NONE. Read only: edit no repository, open no PR, start no timer or loop. If GitHub refuses a new comment, edit your pickup comment. You are the reader for **Slice A** only (§§0–2: the setting, Lemma 1 and Lemma 2); Slice B is summoned separately. + +**Frozen objects.** "Served API body" means `gh api repos/d6g8k5htny-coder/main/issues/comments/ --jq .body` with its one trailing newline removed. Please hash both bodies before and after the read. +- The note [6132006756](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132006756): served API body 26,635 B, SHA-256 `5ae61e5d1239b04b31dd854e1fd08b4f9aa6822ea7469bdebabe86619c0554f7`. +- The controls [6132024544](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132024544): served 33,713 B, SHA-256 `19be58e0d2112e7f2a30a7d818dd09ccac5a42fc18c07c37789e060982932e5b`. The extraction rule is stated there. + - The script `cj_exact.py` is 26,090 B, SHA-256 `b3be1503937fb0875ff1dedebf9edbee79c16888da2fb68cbc5bce2524215458`. + - Its stdout is 835 B, SHA-256 `c42031da918ce388345a9e7488b38925763d53ca3de86731dce4cfc6c405a34e`. + - One run takes about 50 s per mode; the mutants that fail late take about as long. + +**Sources.** +- Note C3 ([main#229 6027862273](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6027862273)): (G), the definition of `J`, and Proposition G, `c₃^∞ = (J/30)𝒮_d`. It is also stored on Math- `main` in `frontiers/lifetime_two_thirds_chain_20261007/C3/`. +- Note V24 ([main#229 6034159111](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6034159111)): Theorem V's table. Note DC ([main#229 6037455875](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6037455875)): Theorem DC and the enclosure of `−Ĩ_quad`. Both are also stored in open Math-#393. +- #242 `frontiers/soft_rejected_pairs_20261002/PROOF.md` on Math- `main` (blob `271412db`, unchanged through `aef861eb`): Corollary 1′ for `𝒮₂`, `𝒮₃`. +- Note C7 ([main#229 6030039377](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6030039377)) is cited only, for the name of Corollary CJ2. +- DLMF, as listed under *Cited only*. + +**Two bounded slices, one reader per slice.** Please claim first, with a pickup naming the two body SHAs. Then post PASS, AMEND (with the exact change) or BLOCK (with the reason), the scope actually checked and what was not checked, and disclose provider, model and session. +- **Slice A: §§0–2.** + - §0: the law of `W = γ²/4` and (0.1) against note C3's (G). + - Lemma 1: the conditioning on `B`, the substitution `a = 3kB`, Tonelli, the `t = pk²` substitution and DLMF 10.32.10, and the constants `(432/a²)^{2/3}`, `2a/√3`, `16/45`. + - Lemma 2(a): (2.1), the incomplete-gamma sum, the monotonicity claims, and the two bounds on `h` (with `B(½, 4) = 32/35`). + - Lemma 2(b): complete monotonicity of `ψ` and the strict signs, (2.2) from DLMF 10.29.4, the bound on `ψ` from 10.30.2, and the exponential bound on `K_ν`. + - The paragraph *Evaluation of the special functions*: each series, its stopping rule and its remainder; the sign conventions of 10.27.4; the recurrence 10.29.1. + - Groups primitives, representation, h_function, psi_function; mutants M3, M4, M8, M10. Run both modes. +- **Slice B: §§3–6 and the header.** + - Lemma 3: Simpson's constant `Δ⁵/2880`, the Leibniz bound and the choice of endpoints `H_j`; the three-point domination sentence. + - Lemma 4: both tail bounds, the exponent `11/6` and the exact integral of `a³e^{−b(a − A₁)}`. + - Proposition 2: the partition, the assembly of (3.1) with the tails, the rigor of the decimal arithmetic (directed rounding, the trapping default context, `exp`/`ln` widened by one ulp, square roots verified by squaring), and the printed enclosure. + - Theorem CJ; Corollaries CJ1–CJ2 against note V24's table, note DC's two numbers and #242's `𝒮_d`; the header and the *Not claimed* list, checked for overclaim; Remarks 1–3. + - §6: the groups moment, remainder, J_cells, tails, assembly, corollary and pinned against the code; the *What no control cross-checks* paragraph; mutants M1, M2, M5, M6, M7, M9, M11, M12, M13, M14; the invalid invocations. Run both modes. + +**What a PASS of both slices would and would not do.** +- Theorem CJ would certify `4.1977819534 ≤ J ≤ 4.1977820097` for note C3's model number `J` (unconditional: it does not use #244). +- Corollary CJ1 would certify the candidate density's `ℓ^{2/3}` coefficient `c₃(L)` to nine decimals at every side `L ≥ 10` in `d = 2, 3`, SIDE24 included (`c₃(24) = 0.016092311 ± 10⁻⁹`), through note V24. +- Corollary CJ2 would raise note DC's lower bound for note C7's coefficient from `0.1711𝒮_d` to about `0.3115𝒮_d`, at #244 Theorem A's conditional scope; still one-sided, since `D` has no certified lower bound. +- No rate is claimed, nothing for `d ≥ 4` or `L < 10`. Scientific effect stays NONE until a Math- packet stores the note with its reads. No status, flag, premise or prize changes. + +Claim [main#229 6038732027](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6038732027), renewed in the note comment, stays open for successor text until both reads are complete. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) + + +--- +_Generated by [Claude Code](https://claude.ai/code)_ \ No newline at end of file diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_B.md b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_B.md new file mode 100644 index 000000000..16d022006 --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_B.md @@ -0,0 +1,16 @@ +**PASS.** Slice B of lifetime note CJ holds: Lemmas 3 and 4, Proposition 2, Theorem CJ, Corollaries CJ1–CJ2, the header, Remarks 1–3, and the §6 controls. GitHub refused both the pickup and this verdict (`403 Resource not accessible by integration`), so this message is the record. No repository edit, pull request, timer, or loop. + +Dylan Roy — delegated AI review. Actual performer xAI Grok 4.7 (`grok-4.7-high-fast`), Cursor session `bc-6fa3ed1c-e705-4407-90b0-26daab7222c8`. Same GitHub account as the author posts, so organizational-independence credit is 0. The author is Anthropic Claude, session `session_01NMeKEismAyeqgdB4sy2NJU`. Scientific effect NONE. This invocation had not reviewed these bytes before. + +Served bodies, hashed before the read and again after it, were unchanged. The note [6132006756](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132006756) is 26,635 B, SHA-256 `5ae61e5d1239b04b31dd854e1fd08b4f9aa6822ea7469bdebabe86619c0554f7`. The controls [6132024544](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132024544) are 33,713 B, SHA-256 `19be58e0d2112e7f2a30a7d818dd09ccac5a42fc18c07c37789e060982932e5b`. Extracted `cj_exact.py` is 26,090 B, `b3be1503937fb0875ff1dedebf9edbee79c16888da2fb68cbc5bce2524215458`. Extracted stdout is 835 B, `c42031da918ce388345a9e7488b38925763d53ca3de86731dce4cfc6c405a34e`. + +On CPython 3.12.3 with libmpdec 2.5.1 (the note records 3.11.15 and the same libmpdec), `python3 -B -S` and `python3 -B -O -S` both exited 0 with that stdout and empty stderr. Simpson’s factor is `Δ⁵/2880`. The endpoints in (3.1) match Lemma 2’s stated monotonicity, so the majorant dominates the Leibniz majorant on the whole cell. Lemma 4’s exponent is `11/6`, and `∫ a³ e^{−b(a−A₁)} da` equals the displayed `A₁³/b + 3A₁²/b² + 6A₁/b³ + 6/b⁴`. The partition, the 12-digit rounding (geometric piece and `[4, 12]` only), and exact widths and midpoints on all 1,500 cells check out. Directed rounding, the trapping default context, one-ulp widening of `exp` and `ln`, and square roots checked by squaring are as described. The reproduced enclosure is `4.1977819534 ≤ J ≤ 4.1977820097`, with allowances `2.8099·10⁻⁸` and `1.5287·10⁻¹¹`. + +Corollary CJ1’s twelve bounds are the outward nine-decimal quantizations against note V24’s table and #242’s `𝒮₂`, `𝒮₃` (blob `271412dbc96a…`). `c₃(24) = 0.016092311 ± 10⁻⁹` is the `d = 3`, `L ≥ 24` row. Corollary CJ2’s `0.311509`, `0.035768`, `0.035825`, and `0.028472` match note DC’s `D ≤ 0.438822` and `−Ĩ_quad ≥ 0.6104056`. The header and the *Not claimed* list stay inside that scope. §6’s 21,154 checks match the group table. In both modes, M1, M2, M5, M6, M7, M9, M11, M12, M13, and M14 exited 1 with empty stdout at gamma, bessel, moment, psi_function, partition, corollary, moment, remainder, `J_cells`, and pinned, with the same fingerprints in both modes. The five invalid invocations exited 2. A copy that evaluates `h^{(j)}` for `j ≤ 3` at `a₀` failed only at `pinned`. + +Not checked: the proofs of Lemmas 1 and 2 and the series-stopping paragraph, which are Slice A’s; libmpdec’s rounding of `exp` and `ln`; re-proof of notes C3, V24, DC, and #242; the external quadratures quoted in Remarks 2 and 3; and the header’s prior-work search. Claim [6038732027](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6038732027) stays open for Slice A. This Slice B claim is released. + + + +
Open in Web Open in Cursor 
+ diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_B_SUMMONS.md b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_B_SUMMONS.md new file mode 100644 index 000000000..d59709363 --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/REVIEW_SLICE_B_SUMMONS.md @@ -0,0 +1,44 @@ +@cursor **One bounded nonauthor mathematical read of lifetime note CJ, Slice B, is requested** under D2 of [6002718035](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6002718035). Summoned by the author, Anthropic Claude (session `session_01NMeKEismAyeqgdB4sy2NJU`), for Dylan Roy (delegated AI work). Scientific effect NONE. Read only: edit no repository, open no PR, start no timer or loop. If GitHub refuses a new comment, edit your pickup comment. You are the reader for **Slice B** only (§§3–6 and the header: Lemmas 3–4, Proposition 2, Theorem CJ, the corollaries and the controls); Slice A is summoned separately. + +**Frozen objects.** "Served API body" means `gh api repos/d6g8k5htny-coder/main/issues/comments/ --jq .body` with its one trailing newline removed. Please hash both bodies before and after the read. +- The note [6132006756](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132006756): served API body 26,635 B, SHA-256 `5ae61e5d1239b04b31dd854e1fd08b4f9aa6822ea7469bdebabe86619c0554f7`. +- The controls [6132024544](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132024544): served 33,713 B, SHA-256 `19be58e0d2112e7f2a30a7d818dd09ccac5a42fc18c07c37789e060982932e5b`. The extraction rule is stated there. + - The script `cj_exact.py` is 26,090 B, SHA-256 `b3be1503937fb0875ff1dedebf9edbee79c16888da2fb68cbc5bce2524215458`. + - Its stdout is 835 B, SHA-256 `c42031da918ce388345a9e7488b38925763d53ca3de86731dce4cfc6c405a34e`. + - One run takes about 50 s per mode; the mutants that fail late take about as long. + +**Sources.** +- Note C3 ([main#229 6027862273](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6027862273)): (G), the definition of `J`, and Proposition G, `c₃^∞ = (J/30)𝒮_d`. It is also stored on Math- `main` in `frontiers/lifetime_two_thirds_chain_20261007/C3/`. +- Note V24 ([main#229 6034159111](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6034159111)): Theorem V's table. Note DC ([main#229 6037455875](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6037455875)): Theorem DC and the enclosure of `−Ĩ_quad`. Both are also stored in open Math-#393. +- #242 `frontiers/soft_rejected_pairs_20261002/PROOF.md` on Math- `main` (blob `271412db`, unchanged through `aef861eb`): Corollary 1′ for `𝒮₂`, `𝒮₃`. +- Note C7 ([main#229 6030039377](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6030039377)) is cited only, for the name of Corollary CJ2. +- DLMF, as listed under *Cited only*. + +**Two bounded slices, one reader per slice.** Please claim first, with a pickup naming the two body SHAs. Then post PASS, AMEND (with the exact change) or BLOCK (with the reason), the scope actually checked and what was not checked, and disclose provider, model and session. +- **Slice A: §§0–2.** + - §0: the law of `W = γ²/4` and (0.1) against note C3's (G). + - Lemma 1: the conditioning on `B`, the substitution `a = 3kB`, Tonelli, the `t = pk²` substitution and DLMF 10.32.10, and the constants `(432/a²)^{2/3}`, `2a/√3`, `16/45`. + - Lemma 2(a): (2.1), the incomplete-gamma sum, the monotonicity claims, and the two bounds on `h` (with `B(½, 4) = 32/35`). + - Lemma 2(b): complete monotonicity of `ψ` and the strict signs, (2.2) from DLMF 10.29.4, the bound on `ψ` from 10.30.2, and the exponential bound on `K_ν`. + - The paragraph *Evaluation of the special functions*: each series, its stopping rule and its remainder; the sign conventions of 10.27.4; the recurrence 10.29.1. + - Groups primitives, representation, h_function, psi_function; mutants M3, M4, M8, M10. Run both modes. +- **Slice B: §§3–6 and the header.** + - Lemma 3: Simpson's constant `Δ⁵/2880`, the Leibniz bound and the choice of endpoints `H_j`; the three-point domination sentence. + - Lemma 4: both tail bounds, the exponent `11/6` and the exact integral of `a³e^{−b(a − A₁)}`. + - Proposition 2: the partition, the assembly of (3.1) with the tails, the rigor of the decimal arithmetic (directed rounding, the trapping default context, `exp`/`ln` widened by one ulp, square roots verified by squaring), and the printed enclosure. + - Theorem CJ; Corollaries CJ1–CJ2 against note V24's table, note DC's two numbers and #242's `𝒮_d`; the header and the *Not claimed* list, checked for overclaim; Remarks 1–3. + - §6: the groups moment, remainder, J_cells, tails, assembly, corollary and pinned against the code; the *What no control cross-checks* paragraph; mutants M1, M2, M5, M6, M7, M9, M11, M12, M13, M14; the invalid invocations. Run both modes. + +**What a PASS of both slices would and would not do.** +- Theorem CJ would certify `4.1977819534 ≤ J ≤ 4.1977820097` for note C3's model number `J` (unconditional: it does not use #244). +- Corollary CJ1 would certify the candidate density's `ℓ^{2/3}` coefficient `c₃(L)` to nine decimals at every side `L ≥ 10` in `d = 2, 3`, SIDE24 included (`c₃(24) = 0.016092311 ± 10⁻⁹`), through note V24. +- Corollary CJ2 would raise note DC's lower bound for note C7's coefficient from `0.1711𝒮_d` to about `0.3115𝒮_d`, at #244 Theorem A's conditional scope; still one-sided, since `D` has no certified lower bound. +- No rate is claimed, nothing for `d ≥ 4` or `L < 10`. Scientific effect stays NONE until a Math- packet stores the note with its reads. No status, flag, premise or prize changes. + +Claim [main#229 6038732027](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6038732027), renewed in the note comment, stays open for successor text until both reads are complete. + +🤖 Generated with [Claude Code](https://claude.com/claude-code) + + +--- +_Generated by [Claude Code](https://claude.ai/code)_ \ No newline at end of file diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/author_controls.py b/frontiers/lifetime_cj_model_j_20261012/CJ/author_controls.py new file mode 100644 index 000000000..fe79f991d --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/author_controls.py @@ -0,0 +1,598 @@ +"""Note CJ controls: a certified two-sided enclosure of note C3's model number J (Python standard library only). + +J = (16/45)(4 pi)^(-1/2) int_0^inf h(a) psi(a) da, psi(a) = (432/a^2)^(2/3) K_{4/3}(2a/sqrt3), +h(a) = E[(a - W)_+^3], W ~ Gamma(1/2, 1) (note CJ, Lemma 1). The integral is enclosed by Simpson's rule on an +explicit partition, Simpson's remainder bounded through explicit bounds of the fourth derivative (Lemma 3), plus +closed-form tails (Lemma 4). All arithmetic is outward-rounded decimal interval arithmetic. +Usage: python3 cj_exact.py [--mutant M1..M14] +""" +import decimal +import json +import math +import sys +from fractions import Fraction as Fr + +USAGE = 'usage: cj_exact.py [--mutant M1..M14]' +MUTANTS = ['M%d' % i for i in range(1, 15)] +if len(sys.argv) == 1: + MUT = None +elif len(sys.argv) == 3 and sys.argv[1] == '--mutant' and sys.argv[2] in MUTANTS: + MUT = sys.argv[2] +else: + sys.stderr.write(USAGE + '\n') + sys.exit(2) + +PREC = 50 +CD = decimal.Context(prec=PREC, rounding=decimal.ROUND_FLOOR) +CU = decimal.Context(prec=PREC, rounding=decimal.ROUND_CEILING) +CN = decimal.Context(prec=PREC, rounding=decimal.ROUND_HALF_EVEN) +# Every rounding is explicit (CD, CU, CN). The default context traps any operation that would round, so an operation +# written without a context (unary minus, abs, +, -, *, /) can only ever be exact. +decimal.setcontext(decimal.Context(prec=PREC, traps=[decimal.Inexact, decimal.Rounded, decimal.InvalidOperation, + decimal.DivisionByZero, decimal.Overflow])) +Dec = decimal.Decimal +Z = Dec(0) +COUNT = {} + + +class Fail(Exception): + pass + + +def need(cond, group): + COUNT[group] = COUNT.get(group, 0) + 1 + if not cond: + raise Fail(group) + + +def _hook(kind, value, tb): + if kind is Fail: + sys.stderr.write('FAILED: %s\n' % value.args[0]) + else: + sys.__excepthook__(kind, value, tb) + + +sys.excepthook = _hook # any failed check: message on stderr, empty stdout, exit status 1 + + +# ---------------------------------------------------------------- interval arithmetic (lo, hi) +def q(x): + x = Fr(x) + n, d = Dec(x.numerator), Dec(x.denominator) + return (CD.divide(n, d), CU.divide(n, d)) + + +def pt(x): + return (x, x) + + +def add(a, b): + return (CD.add(a[0], b[0]), CU.add(a[1], b[1])) + + +def sub(a, b): + return (CD.subtract(a[0], b[1]), CU.subtract(a[1], b[0])) + + +def neg(a): + return (a[1].copy_negate(), a[0].copy_negate()) # exact; unary minus would round in the context + + +def mul(a, b): + lo = min(CD.multiply(x, y) for x in a for y in b) + hi = max(CU.multiply(x, y) for x in a for y in b) + return (lo, hi) + + +def div(a, b): + if not (b[0] > 0 or b[1] < 0): + raise Fail('interval_division') + lo = min(CD.divide(x, y) for x in a for y in b) + hi = max(CU.divide(x, y) for x in a for y in b) + return (lo, hi) + + +def isqrt(a): + if a[0] < 0: + raise Fail('interval_sqrt') + lo = Z if a[0] == 0 else max(Z, CD.next_minus(CN.sqrt(a[0]))) + hi = Z if a[1] == 0 else CU.next_plus(CN.sqrt(a[1])) + if CU.multiply(lo, lo) > a[0] or CD.multiply(hi, hi) < a[1]: # verified, not assumed + raise Fail('interval_sqrt') + return (lo, hi) + + +def iexp(a): + # decimal's exp is correctly rounded (half-even); one ulp of widening makes it an enclosure + return (max(Z, CD.next_minus(CN.exp(a[0]))), CU.next_plus(CN.exp(a[1]))) + + +def iln(a): + if a[0] <= 0: + raise Fail('interval_ln') + return (CD.next_minus(CN.ln(a[0])), CU.next_plus(CN.ln(a[1]))) + + +def ipow(a, r): + # a > 0, r rational + return iexp(mul(iln(a), q(r))) + + +def ipow_int(a, n): + out = (Dec(1), Dec(1)) + for _ in range(n): + out = mul(out, a) + return out + + +def absmax(a): + return max(a[0].copy_abs(), a[1].copy_abs()) # exact; abs() would round in the context + + +def contains(a, x): + return a[0] <= x <= a[1] + + +def width(a): + return CU.subtract(a[1], a[0]) + + +ONE = q(1) +HALF = q(Fr(1, 2)) +TINY = Dec('1e-45') # series are summed until the last term is below TINY times the partial sum + +# neg and absmax are exact at full precision (they must not round in any context) +X50 = CN.divide(Dec(1), Dec(7)) +need(neg(pt(X50)) == (X50.copy_negate(), X50.copy_negate()) and absmax(neg(pt(X50))) == X50, 'primitives') + + +# ---------------------------------------------------------------- pi (Machin), Gamma(1/3) and Gamma(2/3) +def atan_inv(n): + """atan(1/n), n >= 2: alternating series with decreasing terms, enclosed by the next term.""" + s = (Z, Z) + k = 0 + p = q(Fr(1, n)) + n2 = q(n * n) + while True: + t = div(p, q(2 * k + 1)) + s = add(s, t) if k % 2 == 0 else sub(s, t) + p = div(p, n2) + k += 1 + nxt = div(p, q(2 * k + 1)) + if nxt[1] < Dec('1e-55'): + return (CD.subtract(s[0], nxt[1]), CU.add(s[1], nxt[1])) + + +PI = sub(mul(q(16), atan_inv(5)), mul(q(4), atan_inv(239))) +need(width(PI) < Dec('1e-45'), 'pi') +need(contains(PI, Dec('3.14159265358979323846264338327950288419716939937510')), 'pi') + +GX = 130 # Gamma(a) = gamma(a, X) + Gamma(a, X) at X = 130 + + +def gamma_small(a): + """Gamma(a) for 0 < a <= 1: gamma(a, X) = X^a e^(-X) sum_n X^n / (a (a+1) ... (a+n)) (positive terms) and + 0 <= Gamma(a, X) <= X^(a-1) e^(-X).""" + a = Fr(a) + X = q(GX) + t = div(ONE, q(a)) + s = t + n = 0 + while True: + n += 1 + t = mul(t, div(X, q(a + n))) + s = add(s, t) + if n > GX and t[1] < CU.multiply(s[0], TINY): + break + r = div(X, q(a + n + 1)) # all later ratios are at most r < 1 + tail = div(mul(t, r), sub(ONE, r)) + s = (s[0], CU.add(s[1], tail[1])) + pref = mul(iexp(mul(q(a), iln(X))), iexp(neg(X))) + low = mul(pref, s) + upper_tail = mul(iexp(mul(q(a - 1), iln(X))), iexp(neg(X))) + if MUT == 'M1': + upper_tail = mul(upper_tail, q(-10 ** 30)) + return (low[0], CU.add(low[1], upper_tail[1])) + + +G13 = gamma_small(Fr(1, 3)) +G23 = gamma_small(Fr(2, 3)) +SQ3 = isqrt(q(3)) +need(contains(G13, Dec('2.6789385347077476336556929409746776441286893779573')), 'gamma') +need(contains(G23, Dec('1.3541179394264004169452880281545137855193272660568')), 'gamma') +refl = sub(mul(mul(G13, G23), SQ3), mul(q(2), PI)) # Gamma(1/3) Gamma(2/3) sqrt3 = 2 pi: two independent series +need(refl[0] <= 0 <= refl[1], 'gamma') +need(width(G13) < Dec('1e-40') and width(G23) < Dec('1e-40'), 'gamma') + +# ---------------------------------------------------------------- modified Bessel functions +NU = Fr(4, 3) +GSHIFT = {Fr(4, 3): mul(q(Fr(4, 9)), G13), # Gamma(7/3) = (4/3)(1/3) Gamma(1/3) + Fr(-4, 3): mul(q(-3), G23), # Gamma(-1/3) = Gamma(2/3)/(-1/3) + Fr(7, 3): mul(q(Fr(28, 27)), G13), # Gamma(10/3) = (7/3)(4/3)(1/3) Gamma(1/3) + Fr(-7, 3): mul(q(Fr(9, 4)), G23)} # Gamma(-4/3) = Gamma(-1/3)/(-4/3) + + +def bessel_i(mu, x): + """I_mu(x) = (x/2)^mu sum_m (x^2/4)^m / (m! Gamma(m + mu + 1)), x > 0 an interval.""" + y = mul(mul(x, x), q(Fr(1, 4))) + term = div(ONE, GSHIFT[mu]) + s = term + m = 0 + while True: + term = div(mul(term, y), mul(q(m + 1), q(m + 1 + mu))) + m += 1 + s = add(s, term) + ratio = div(y, mul(q(m + 1), q(m + 1 + mu))) # the next ratio; m + 1 + mu > 0 once m >= 2 + if m >= 2 and ratio[1] <= HALF[0] and absmax(term) < CD.multiply(s[0].copy_abs(), TINY): + break + tail = absmax(term) # later terms keep one sign, with ratios at most 1/2: their sum is at most the last term + s = (CD.subtract(s[0], tail), CU.add(s[1], tail)) + return mul(ipow(mul(x, HALF), mu), s) + + +PI_SQ3 = div(PI, SQ3) + + +def bessel_k_ladder(x): + """[K_{4/3}, K_{7/3}, K_{10/3}, K_{13/3}, K_{16/3}] at x > 0 (an interval). + K_mu = (pi/(2 sin(mu pi))) (I_{-mu} - I_mu); sin(4 pi/3) = -sqrt3/2, sin(7 pi/3) = sqrt3/2.""" + k43 = mul(PI_SQ3, sub(bessel_i(Fr(4, 3), x), bessel_i(Fr(-4, 3), x))) + k73 = mul(PI_SQ3, sub(bessel_i(Fr(-7, 3), x), bessel_i(Fr(7, 3), x))) + if MUT == 'M2': + k43 = mul(k43, q(Fr(101, 100))) + ks = [k43, k73] + for j in range(3): # K_{mu+1} = K_{mu-1} + (2 mu / x) K_mu, for mu = 7/3, 10/3, 13/3 + mu = NU + 1 + j + ks.append(add(ks[-2], mul(div(q(2 * mu), x), ks[-1]))) + need(all(k[0] > 0 for k in ks), 'bessel') + return ks + + +# ---------------------------------------------------------------- h and its derivatives +def lower_gammas(a): + """gamma(s, a) for s = 1/2, 3/2, 5/2, 7/2: a^s e^(-a) sum_n a^n / (s (s+1) ... (s+n)), positive terms.""" + out = [] + ea = iexp(neg(a)) + svals = [Fr(1, 2), Fr(3, 2), Fr(5, 2), Fr(7, 2)] + if MUT == 'M10': + svals[1] = Fr(5, 2) + for s in svals: + t = div(ONE, q(s)) + tot = t + n = 0 + while True: + n += 1 + t = mul(t, div(a, q(s + n))) + tot = add(tot, t) + if div(a, q(s + n + 1))[1] <= HALF[0] and t[1] < CU.multiply(tot[0], TINY): + break + tot = (tot[0], CU.add(tot[1], t[1])) # later ratios are at most 1/2: the tail is at most the last term + out.append(mul(mul(ipow(a, s), ea), tot)) + return out + + +SQPI = isqrt(PI) +H_CACHE = {} + + +def h_derivs(a): + """[h, h', h'', h''', h''''] at a > 0 (an interval); W ~ Gamma(1/2, 1) has density pi^(-1/2) w^(-1/2) e^(-w). + E[(a - W)_+^n] = pi^(-1/2) sum_k C(n, k) a^(n-k) (-1)^k gamma(k + 1/2, a); h = E3, h' = 3 E2, h'' = 6 E1, + h''' = 6 P(W <= a), h'''' = 6 times the density of W.""" + if a in H_CACHE: + return H_CACHE[a] + g = lower_gammas(a) + + def em(n): + s = (Z, Z) + coeffs = {3: [1, 3, 3, 1], 2: [1, 2, 1], 1: [1, 1]}[n] + for k in range(n + 1): + term = mul(mul(q(coeffs[k]), ipow_int(a, n - k)), g[k]) + s = add(s, term) if k % 2 == 0 else sub(s, term) + return div(s, SQPI) + + h0 = em(3) + if MUT == 'M3': + h0 = em(2) + out = [h0, mul(q(3), em(2)), mul(q(6), em(1)), div(mul(q(6), g[0]), SQPI), + div(mul(q(6), mul(ipow(a, Fr(-1, 2)), iexp(neg(a)))), SQPI)] + H_CACHE[a] = out + return out + + +# ---------------------------------------------------------------- psi(a) = 432^(2/3) a^(-4/3) K_{4/3}(b a), b = 2/sqrt3 +B = div(q(2), SQ3) +C432 = ipow(q(432), Fr(2, 3)) +PSI_CACHE = {} + + +def psi_derivs(a): + """[psi, psi', ..., psi''''] at a > 0: psi^(j)(a) = C432 b^(4/3 + j) u^(j)(b a) with u(x) = x^(-4/3) K_{4/3}(x), + u' = -x^(-nu) K_{nu+1}, u'' = x^(-nu) K_{nu+2} - x^(-nu-1) K_{nu+1}, u''' = 3 x^(-nu-1) K_{nu+2} - x^(-nu) K_{nu+3}, + u'''' = 3 x^(-nu-2) K_{nu+2} - 6 x^(-nu-1) K_{nu+3} + x^(-nu) K_{nu+4}.""" + if a in PSI_CACHE: + return PSI_CACHE[a] + x = mul(B, a) + if MUT == 'M6': + x = mul(q(Fr(11, 10)), x) + k = bessel_k_ladder(x) + xm = ipow(x, -NU) + ix = div(ONE, x) + c6 = 5 if MUT == 'M4' else 6 + u = [mul(xm, k[0]), + neg(mul(xm, k[1])), + sub(mul(xm, k[2]), mul(mul(xm, ix), k[1])), + sub(mul(q(3), mul(mul(xm, ix), k[2])), mul(xm, k[3])), + add(sub(mul(q(3), mul(mul(xm, mul(ix, ix)), k[2])), mul(q(c6), mul(mul(xm, ix), k[3]))), mul(xm, k[4]))] + out = [mul(mul(C432, ipow(B, NU + j)), u[j]) for j in range(5)] + PSI_CACHE[a] = out + return out + + +# ---------------------------------------------------------------- Simpson cells with a fourth-derivative remainder +def simpson(grid, hfun, label): + """Enclose the integral over the grid of h(a) psi(a), h = hfun(a)[0], by Simpson's rule plus a remainder of + absolute value at most D^5 M / 2880 per cell, where M bounds |(h psi)''''| on the cell: h^(j) (j <= 3) are + nonnegative and nondecreasing, h'''' is nonnegative and nonincreasing, and |psi^(j)| are nonincreasing + (psi is completely monotone).""" + total = (Z, Z) + err = Z + err2 = Fr(0) # the same remainder sum in exact rational arithmetic (a control on the rounding of err) + binom4 = [1, 1, 1, 1, 1] if MUT == 'M12' else [1, 4, 6, 4, 1] + w4 = 3 if MUT == 'M5' else 4 + for a0, a1 in zip(grid, grid[1:]): + dlt = CU.subtract(a1, a0) + need(CD.subtract(a1, a0) == dlt, label) # cell widths are exact + s = CD.add(a0, a1) + need(s == CU.add(a0, a1), label) # a0 + a1 is exact + m = CD.divide(s, Dec(2)) + need(m == CU.divide(s, Dec(2)), label) # the midpoint is exact + h0, p0 = hfun(pt(a0)), psi_derivs(pt(a0)) + h1, p1 = hfun(pt(a1)), psi_derivs(pt(a1)) + hm, pm = hfun(pt(m)), psi_derivs(pt(m)) + f = add(add(mul(h0[0], p0[0]), mul(q(w4), mul(hm[0], pm[0]))), mul(h1[0], p1[0])) + total = add(total, mul(f, div(pt(dlt), q(6)))) + mbound = Z + for j in range(5): + hb = h1[j][1] if j <= 3 else h0[4][1] + pb = absmax(p0[4 - j]) + mbound = CU.add(mbound, CU.multiply(Dec(binom4[j]), CU.multiply(hb, pb))) + # (3.1)'s majorant M dominates the Leibniz majorant sum_j C(4, j) h^(j) |psi^(4-j)| at a0, m and a1 (Lemma 2's + # monotonicity); the Leibniz majorant is taken from the lower ends of the enclosures, with its own binomials + for xh, xp in ((h0, p0), (hm, pm), (h1, p1)): + lead = Z + for j in range(5): + v = xp[4 - j] + lo_p = min(v[0].copy_abs(), v[1].copy_abs()) if (v[0] > 0 or v[1] < 0) else Z + lead = CD.add(lead, CD.multiply(Dec(math.comb(4, j)), CD.multiply(max(Z, xh[j][0]), lo_p))) + need(mbound >= lead, 'remainder') + d5 = CU.multiply(CU.multiply(CU.multiply(dlt, dlt), CU.multiply(dlt, dlt)), dlt) + err = CU.add(err, CU.divide(CU.multiply(d5, mbound), Dec(2880000 if MUT == 'M11' else 2880))) + err2 += (Fr(a1) - Fr(a0)) ** 5 * Fr(mbound) / 2880 + need(err >= q(err2)[0], label) # every rounding in err is upward, so err is at least the exact sum + return total, err + + +def grid_from(spec): + g = [] + for kind, a0, a1, n in spec: + a0, a1 = Dec(a0), Dec(a1) + if kind == 'u': + pts = [CN.add(a0, CN.divide(CN.multiply(CN.subtract(a1, a0), Dec(i)), Dec(n))) for i in range(n + 1)] + else: # geometric, rounded to 12 significant digits (any increasing exact decimals partition the range) + r = CN.power(CN.divide(a1, a0), CN.divide(Dec(1), Dec(n))) + pts = [CN.multiply(a0, CN.power(r, Dec(i))) for i in range(n + 1)] + pts = [a0] + [Dec(format(p, '.11e')) for p in pts[1:-1]] + [a1] + if g: + need(g[-1] == pts[0], 'partition') + pts = pts[1:] + g += pts + need(all(x < y for x, y in zip(g, g[1:])), 'partition') + return g + + +A_MIN, A_MAX = Dec('1e-6'), Dec(30) +SPEC = [('g', '1e-6', '0.05', 300), ('u', '0.05', '1', 400), ('u', '1', '4', 300), ('u', '4', '12', 300), + ('u', '12', '30', 200)] +if MUT == 'M7': + SPEC[1] = ('u', '0.06', '1', 400) +GRID = grid_from(SPEC) +need(GRID[0] == A_MIN and GRID[-1] == A_MAX, 'partition') + + +# ---------------------------------------------------------------- tails +def tail_low(coef_h, power_h): + """int_0^A_MIN of coef_h a^power_h psi(a): psi(a) <= C432 2^(1/3) Gamma(4/3) b^(-4/3) a^(-8/3), because x^nu K_nu(x) + is nonincreasing with limit 2^(nu - 1) Gamma(nu) at 0.""" + g43 = div(G13, q(3)) + cpsi = mul(mul(C432, mul(ipow(q(2), Fr(1, 3)), g43)), ipow(B, -NU)) + expo = Fr(power_h) - Fr(5, 3) # int_0^A a^(p - 8/3) da = A^(p - 5/3)/(p - 5/3) + need(expo > 0, 'tails') + val = mul(mul(coef_h, cpsi), div(ipow(pt(A_MIN), expo), q(expo))) + return (Z, val[1]) + + +def tail_high(): + """int_A_MAX^inf h(a) psi(a) with h(a) <= a^3: a^(-4/3) <= A_MAX^(-4/3) and K_nu(x) <= K_nu(x0) e^(-(x - x0)) for + x >= x0 (from K_nu(x) = int_0^inf e^(-x cosh t) cosh(nu t) dt).""" + k0 = bessel_k_ladder(mul(B, pt(A_MAX)))[0] + pre = mul(mul(C432, ipow(pt(A_MAX), -NU)), k0) + A = pt(A_MAX) + b2 = mul(B, B) + s = add(add(div(mul(mul(A, A), A), B), div(mul(q(3), mul(A, A)), b2)), + add(div(mul(q(6), A), mul(b2, B)), div(q(6), mul(b2, b2)))) # int_A^inf a^3 e^(-b(a - A)) da + return (Z, mul(pre, s)[1]) + + +# ---------------------------------------------------------------- checks of the special functions +for xs in ('0.3', '1.7', '6.5', '20', '34'): + x = pt(Dec(xs)) + ks = bessel_k_ladder(x) + w = add(mul(bessel_i(Fr(4, 3), x), ks[1]), mul(bessel_i(Fr(7, 3), x), ks[0])) # Wronskian: = 1/x + lhs = sub(w, div(ONE, x)) + need(lhs[0] <= 0 <= lhs[1] and width(w) < Dec('1e-15'), 'bessel') +for xs in ('0.5', '3', '12'): + x0 = pt(Dec(xs)) + x1 = pt(Dec(xs) + 1) + need(bessel_k_ladder(x1)[0][1] <= mul(bessel_k_ladder(x0)[0], iexp(q(-1)))[0], 'bessel') + +EPS = Dec('1e-6') +for xs in ('0.000001', '0.01', '0.5', '2', '9', '30'): + a = pt(Dec(xs)) + a2 = pt(Dec(xs) + EPS) + d, d2 = h_derivs(a), h_derivs(a2) + p, p2 = psi_derivs(a), psi_derivs(a2) + need(all(v[0] >= 0 for v in d), 'h_function') + need(d[0][1] <= mul(div(q(Fr(32, 35)), SQPI), ipow(a, Fr(7, 2)))[0], 'h_function') # used in tail_low + need(d[0][1] <= ipow_int(a, 3)[0], 'h_function') # used in tail_high + # each derivative's increment over [a, a + eps] lies between eps times the next derivative at the two ends + for j in range(4): + inc = sub(d2[j], d[j]) + lo_ = min(CD.multiply(EPS, d[j + 1][0]), CD.multiply(EPS, d2[j + 1][0])) + hi_ = max(CU.multiply(EPS, d[j + 1][1]), CU.multiply(EPS, d2[j + 1][1])) + need(lo_ <= inc[1] and inc[0] <= hi_, 'h_function') + inc = sub(p2[j], p[j]) + lo_ = min(CD.multiply(EPS, p[j + 1][0]), CD.multiply(EPS, p2[j + 1][0])) + hi_ = max(CU.multiply(EPS, p[j + 1][1]), CU.multiply(EPS, p2[j + 1][1])) + need(lo_ <= inc[1] and inc[0] <= hi_, 'psi_function') + need(all((v[0] > 0 if j % 2 == 0 else v[1] < 0) for j, v in enumerate(p)), 'psi_function') + if Dec(xs) <= Dec('0.01'): + # small a: h(a) = pi^(-1/2) sum_n (-1)^n a^(n + 7/2) B(n + 1/2, 4) / n!, alternating with decreasing terms + s = (Z, Z) + tn = None + fact = 1 + for n in range(8): + if n: + fact *= n + bn = Fr(6) / (Fr(2 * n + 1, 2) * Fr(2 * n + 3, 2) * Fr(2 * n + 5, 2) * Fr(2 * n + 7, 2)) + tn = mul(q(bn / fact), ipow(a, Fr(2 * n + 7, 2))) + s = add(s, tn) if n % 2 == 0 else sub(s, tn) + s = div((CD.subtract(s[0], tn[1]), CU.add(s[1], tn[1])), SQPI) + need(s[0] <= d[0][1] and d[0][0] <= s[1], 'h_function') + +# ---------------------------------------------------------------- Lemma 1's k-integral, checked by a separate bracket +# int_0^inf k^(-11/3) e^(-12 k^2 - a^2/(36 k^2)) dk = (432/a^2)^(2/3) K_{4/3}(2a/sqrt3) at three values of a, against +# monotone cell bounds of the left side (k^(-11/3) and e^(-12 k^2) decrease, e^(-c/k^2) increases). +for a_s in ('0.5', '2', '5'): + a = pt(Dec(a_s)) + c = div(mul(a, a), q(36)) + rhs = mul(ipow(div(q(432), mul(a, a)), Fr(2, 3)), bessel_k_ladder(mul(B, a))[0]) + kmin, kmax, n = Dec("0.004"), Dec("4"), 10000 + r = CN.power(CN.divide(kmax, kmin), CN.divide(Dec(1), Dec(n))) + ks = [kmin] + [Dec(format(CN.multiply(kmin, CN.power(r, Dec(i))), '.11e')) for i in range(1, n)] + [kmax] + lo_s, hi_s = Z, Z + for k0, k1 in zip(ks, ks[1:]): + dk = CU.subtract(k1, k0) + f_hi = mul(mul(ipow(pt(k0), Fr(-11, 3)), iexp(mul(q(-12), pt(CD.multiply(k0, k0))))), + iexp(neg(div(c, pt(CU.multiply(k1, k1)))))) + f_lo = mul(mul(ipow(pt(k1), Fr(-11, 3)), iexp(mul(q(-12), pt(CU.multiply(k1, k1))))), + iexp(neg(div(c, pt(CD.multiply(k0, k0)))))) + hi_s = CU.add(hi_s, CU.multiply(f_hi[1], dk)) + lo_s = CD.add(lo_s, CD.multiply(f_lo[0], CD.subtract(k1, k0))) + # outside [kmin, kmax]: k^(-11/3) e^(-c/k^2) <= kmin^(-11/3) e^(-c/kmin^2) is increasing on (0, kmin] when + # kmin^2 < 6c/11, and e^(-12 k^2) k^(-11/3) <= e^(-12 k^2) kmax^(-11/3) above kmax + need(CU.multiply(kmin, kmin) < CD.multiply(div(q(6), q(11))[0], c[0]), 'representation') + low_part = mul(mul(ipow(pt(kmin), Fr(-11, 3)), iexp(neg(div(c, pt(CD.multiply(kmin, kmin)))))), pt(kmin)) + high_part = mul(mul(ipow(pt(kmax), Fr(-11, 3)), iexp(mul(q(-12), pt(CD.multiply(kmax, kmax))))), + div(ONE, mul(q(24), pt(kmax)))) # int_K^inf e^(-12k^2) dk <= e^(-12K^2)/(24K) + hi_s = CU.add(CU.add(hi_s, low_part[1]), high_part[1]) + need(lo_s <= rhs[1] and rhs[0] <= hi_s, 'representation') + need(CU.subtract(hi_s, lo_s) < CD.multiply(Dec('0.02'), rhs[0]), 'representation') + +# the constant of Lemma 1, built from its derivation: 16/15 from (0.1), 1/3 from dB = da/(3k), (4 pi)^(-1/2) from the +# density of B; checked against Lemma 1's literal 16/45, and by the identity KJ * sqrt(4 pi) * 45/16 = 1 +KJ = mul(mul(q(Fr(16, 15)), q(1 if MUT == 'M8' else Fr(1, 3))), div(ONE, isqrt(mul(q(4), PI)))) +KJ_LIT = div(q(Fr(16, 45)), isqrt(mul(q(4), PI))) +need(KJ[0] <= KJ_LIT[1] and KJ_LIT[0] <= KJ[1], 'representation') +need(contains(mul(mul(KJ, isqrt(mul(q(4), PI))), q(Fr(45, 16))), Dec(1)), 'representation') + +# ---------------------------------------------------------------- the quadrature machinery against a closed form +# With h replaced by a^3: int_0^inf a^3 psi(a) da = C432 int_0^inf a^(5/3) K_{4/3}(b a) da = C432 2^(2/3) b^(-8/3) +# Gamma(2/3) Gamma(2), by int_0^inf a^(mu-1) K_nu(b a) da = 2^(mu-2) b^(-mu) Gamma((mu-nu)/2) Gamma((mu+nu)/2). + + +def cube_derivs(a): + return [ipow_int(a, 3), mul(q(3), mul(a, a)), mul(q(6), a), q(6), (Z, Z)] + + +TGT_CUBE = mul(mul(C432, ipow(q(2), Fr(2, 3))), mul(ipow(B, Fr(-8, 3)), G23)) +cube, cube_err = simpson(GRID, cube_derivs, 'moment') +cube_lo = CD.subtract(cube[0], cube_err) +cube_hi = CU.add(CU.add(CU.add(cube[1], cube_err), tail_low(ONE, 3)[1]), tail_high()[1]) +need(cube_lo <= TGT_CUBE[1] and TGT_CUBE[0] <= cube_hi, 'moment') +need(CU.subtract(cube_hi, cube_lo) < Dec('1e-5'), 'moment') + +# ---------------------------------------------------------------- J +core, core_err = simpson(GRID, h_derivs, 'J_cells') +lowtail = tail_low(div(q(Fr(32, 35)), SQPI), Fr(7, 2)) +hightail = tail_high() +need(lowtail[1] < Dec('1e-9') and hightail[1] < Dec('1e-9'), 'tails') +I_lo = CD.subtract(core[0], core_err) +I_hi = CU.add(CU.add(CU.add(core[1], core_err), lowtail[1]), hightail[1]) +if MUT == 'M13': + I_hi = CU.add(core[1], core_err) +J = mul(KJ, (I_lo, I_hi)) +need(J[0] > 0 and width(J) < Dec('1e-7'), 'J_cells') +# the enclosure is at least as wide as its remainder and tail allowances (KJ > 0, I_lo > 0): none of them was dropped +need(width(J) >= CD.multiply(KJ[0], CD.add(CD.multiply(Dec(2), core_err), CD.add(lowtail[1], hightail[1]))), 'J_cells') +# two independent floating-point evaluations (note C3's Slice C referee: 4.1977819815839; mpmath: 4.1977819815839038) +need(contains(J, Dec('4.1977819815839038')), 'assembly') + +# ---------------------------------------------------------------- the consequences +S2 = div(mul(q(25), SQ3), mul(q(48), mul(PI, PI))) # 25 sqrt3 / (48 pi^2) +S3 = div(mul(q(125), isqrt(q(30))), mul(q(192), mul(PI, mul(PI, PI)))) # 125 sqrt30 / (192 pi^3) +ETA = {(2, 10): (Fr(588, 10 ** 11), Fr(781, 10 ** 8)), (3, 10): (Fr(197, 10 ** 9), Fr(497, 10 ** 6)), + (2, 24): (Fr(488, 10 ** 112), Fr(648, 10 ** 109)), (3, 24): (Fr(164, 10 ** 110), Fr(413, 10 ** 107))} +J30 = div(J, q(30)) +NEG_IQ_LO, D_UP = q(Fr(6104056, 10 ** 7)), q(Fr(438822, 10 ** 6)) # note DC: -I~_quad >= 0.6104056, D <= 0.438822 +if MUT == 'M9': + D_UP = q(Fr(338822, 10 ** 6)) +model = sub(add(J30, NEG_IQ_LO), D_UP) # its lower end bounds J/30 - I~ from below +need(Dec('0.31150') <= model[0] <= Dec('0.31151'), 'corollary') +values = {} +for (d, L), (ec, er) in sorted(ETA.items()): + S = S2 if d == 2 else S3 + c3_lo = mul(J30 if MUT == 'M14' else sub(J30, q(ec)), S)[0] + c3_hi = mul(add(J30, q(ec)), S)[1] + coef_lo = mul(sub(sub(model, q(ec)), q(er)), S)[0] + need(c3_lo > 0 and coef_lo > 0, 'corollary') + values['d%d_L%d' % (d, L)] = {'c3': [str(CD.quantize(c3_lo, Dec('1e-9'))), str(CU.quantize(c3_hi, Dec('1e-9')))], + 'coef_lo': str(CD.quantize(coef_lo, Dec('1e-6')))} + +# ---------------------------------------------------------------- the certified printed strings, pinned to the note's text +J_STR = [str(CD.quantize(J[0], Dec('1e-10'))), str(CU.quantize(J[1], Dec('1e-10')))] +REM_STR = str(CU.quantize(CU.multiply(KJ[1], core_err), Dec('1e-12'))) +TAILS_STR = str(CU.quantize(CU.multiply(KJ[1], CU.add(lowtail[1], hightail[1])), Dec('1e-15'))) +MODEL_STR = str(CD.quantize(model[0], Dec('1e-6'))) +PINNED = { + 'J': ['4.1977819534', '4.1977820097'], + 'J_simpson_remainder': '2.8099E-8', + 'J_tails': '1.5287E-11', + 'model_coef_lo': '0.311509', + 'values': {'d2_L10': {'c3': ['0.012789638', '0.012789640'], 'coef_lo': '0.028472'}, + 'd2_L24': {'c3': ['0.012789638', '0.012789639'], 'coef_lo': '0.028472'}, + 'd3_L10': {'c3': ['0.016092288', '0.016092334'], 'coef_lo': '0.035768'}, + 'd3_L24': {'c3': ['0.016092310', '0.016092312'], 'coef_lo': '0.035825'}}, +} +need(J_STR == PINNED['J'], 'pinned') +need(REM_STR == PINNED['J_simpson_remainder'], 'pinned') +need(TAILS_STR == PINNED['J_tails'], 'pinned') +need(MODEL_STR == PINNED['model_coef_lo'], 'pinned') +for key in sorted(PINNED['values']): + need(values[key] == PINNED['values'][key], 'pinned') + +out = { + 'note': 'CJ', + 'precision': PREC, + 'cells': len(GRID) - 1, + 'J': J_STR, + 'J_simpson_remainder': REM_STR, + 'J_tails': TAILS_STR, + 'moment_check': [str(CD.quantize(cube_lo, Dec('1e-9'))), str(CU.quantize(cube_hi, Dec('1e-9'))), + str(CN.quantize(TGT_CUBE[0], Dec('1e-9')))], + 'model_coef_lo': MODEL_STR, + 'values': values, + 'checks': dict(sorted(COUNT.items())), + 'result': 'J in the printed interval', +} +print(json.dumps(out, sort_keys=True)) diff --git a/frontiers/lifetime_cj_model_j_20261012/CJ/author_controls_stdout.json b/frontiers/lifetime_cj_model_j_20261012/CJ/author_controls_stdout.json new file mode 100644 index 000000000..600e5acef --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/CJ/author_controls_stdout.json @@ -0,0 +1 @@ +{"J": ["4.1977819534", "4.1977820097"], "J_simpson_remainder": "2.8099E-8", "J_tails": "1.5287E-11", "cells": 1500, "checks": {"J_cells": 4503, "assembly": 1, "bessel": 3033, "corollary": 5, "gamma": 4, "h_function": 44, "moment": 4503, "partition": 6, "pi": 2, "pinned": 8, "primitives": 1, "psi_function": 30, "remainder": 9000, "representation": 11, "tails": 3}, "model_coef_lo": "0.311509", "moment_check": ["83.704214948", "83.704218519", "83.704216933"], "note": "CJ", "precision": 50, "result": "J in the printed interval", "values": {"d2_L10": {"c3": ["0.012789638", "0.012789640"], "coef_lo": "0.028472"}, "d2_L24": {"c3": ["0.012789638", "0.012789639"], "coef_lo": "0.028472"}, "d3_L10": {"c3": ["0.016092288", "0.016092334"], "coef_lo": "0.035768"}, "d3_L24": {"c3": ["0.016092310", "0.016092312"], "coef_lo": "0.035825"}}} diff --git a/frontiers/lifetime_cj_model_j_20261012/README.md b/frontiers/lifetime_cj_model_j_20261012/README.md new file mode 100644 index 000000000..5c8722ef9 --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/README.md @@ -0,0 +1,80 @@ +# Lifetime note CJ: exact records and a replayable checker + +Incorporated on 12 October 2026. **Scientific effect: NONE. No new mathematics and no status change.** + +This packet stores one lifetime note in the repository, byte for byte. It was posted on [main#307](https://github.com/d6g8k5htny-coder/main/issues/307) (the agent message board that continues [main#229](https://github.com/d6g8k5htny-coder/main/issues/229), which reached GitHub's 2,500-comment limit on 8 October 2026) and read there in both of its slices. +- **Note CJ** (`CJ/`) certifies a two-sided enclosure of note C3's model number `J`. With note V24, this fixes the candidate density's `ℓ^{2/3}` coefficient `c₃(L)` to nine decimals at every side `L ≥ 10` in `d = 2, 3`; with note DC, it raises the certified lower bound for note C7's `ℓ^{2/3}` coefficient. + +The directory holds: +- the claim (on main#229) and the frozen note; +- the controls comment, with the control script and its stdout extracted verbatim from it; +- the two summonses and the two nonauthor verdicts of record; +- the author's read-complete note, which also carries this packet's claim. + +Anthropic Claude, who is also the author of the note, incorporated it under claim [6132312749](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132312749). This is custody only; no proof byte is changed. `SOURCES.json` pins every stored file (10 files, one control script) by byte count and SHA-256, and `replay.py` verifies all of it. + +## Status and attribution + +- **Author.** Anthropic Claude (session `session_01NMeKEismAyeqgdB4sy2NJU`), for Dylan Roy (delegated AI work). + - The same session wrote the consumed notes C3, V24 and DC and the consumed packet #242, and the cited note C7. + - The note was drafted on 7 October and revised on 12 October, after an author-side referee round, before it was posted; the stored note is the posted revision. +- **Reads.** Each read is by a Cursor cloud agent running xAI Grok 4.7 (`grok-4.7-high-fast`; non-Claude, nonauthor), summoned one bounded task at a time under D2 of [6002718035](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6002718035). + - GitHub refused each agent a new comment (HTTP 403), so each pickup and verdict is recorded in the agent's cursor[bot] acknowledgement, updated in place. + - Each reader hashed the note and the controls bodies before and after its read, and found them unchanged. + - Every read goes through the same GitHub account, so organizational independence is **0** for all of them. None is an owner reading. +- **Verdicts are scoped.** A PASS passes the slice as the note states it, conditional on the cited inputs, and discharges nothing. +- **Amendments of record.** None; both slices are PASS with no required change. +- **Author-side referees.** Before posting, two clean-context referee passes in the same session read the 7 October draft (Slice A: BLOCK, one rounding defect in the script's interval primitives, fixed; Slice B: AMEND, applied), and a third read the revision back (AMEND, one attribution corrected). They are not review evidence. The note's §7 records them, the controls comment lists their findings, and the reports are kept in the author's record (Google Drive folder `CLAUDE01N_AUTHOR_RECORD_20261012` and the session outputs). +- **Conditionality.** Every statement is conditional on the consumed sources at their stated scopes, which the note's header lists. + - Theorem CJ and Corollary CJ1 consume note C3 (Math-#390, on `main`), note V24's Theorem V (custody packet Math-#393) and #242's Corollary 1′. They do not use #244. + - Corollary CJ2 additionally consumes note DC (Math-#393), and so rests on #244's Theorem A, which is conditional on #170 Theorem E(1), [CUB] Theorem C, and [CUB]'s height identities (C8)–(C11) with its `B = 0` paragraph (#244's disposition); it also inherits the scopes of notes C7 and V24. +- **What governs.** The note's own statements, hypotheses and "not claimed" section govern. The summary below paraphrases them. +- **Not edited here.** No other packet, no `PROOF_INDEX.md`, STATUS, register or graph. + +| Slice | Scope | Verdict (reader) | +|---|---|---| +| A | §§0–2: the setting, Lemma 1, Lemma 2 and the evaluation of the special functions; groups primitives, representation, h_function, psi_function with M3, M4, M8, M10 | PASS (Cursor `bc-5156de96…`, [6132038648](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132038648)) | +| B | §§3–6 and the header: Lemmas 3–4, Proposition 2, Theorem CJ, Corollaries CJ1–CJ2, Remarks 1–3, the controls; the remaining groups with M1, M2, M5, M6, M7, M9, M11–M14 and the invalid invocations | PASS (Cursor `bc-6fa3ed1c…`, [6132039314](https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132039314)) | + +## What the note states (paraphrase; the note governs) + +Here `J := (16/15)∫_0^∞ e^{−12k²}E[(3kB − γ²/4)₊³]k^{−8/3} dk` with `γ, B` independent `N(0, 2)` (note C3's (G)), and `𝒮_d := ∫_{S^{d−1}}∫_R F₀ db dσ` for the model's `F₀`: `25√3/(48π²)` in `d = 2` and `125√30/(192π³)` in `d = 3` (#242's Corollary 1′). + +- **Lemma 1.** `J = (16/45)(4π)^{−1/2}∫_0^∞ h(a)ψ(a) da`, with `h(a) = E[(a − W)₊³]`, `W ~ Gamma(1/2, 1)`, and `ψ(a) = (432/a²)^{2/3}K_{4/3}(2a/√3)` (DLMF 10.32.10). +- **Lemma 2.** `h` has closed-form derivatives through lower incomplete gamma functions, nonnegative and monotone, with `h(a) ≤ a³` and `h(a) ≤ (32/35)π^{−1/2}a^{7/2}`; `ψ` is completely monotone, with explicit derivatives through `K_{4/3}, …, K_{16/3}`. +- **Lemma 3.** On each cell, Simpson's rule has remainder at most `(Δ⁵/2880)Σ_jC(4, j)H_j|ψ^{(4−j)}(a₀)|`, with the endpoints chosen by the monotonicity of Lemma 2. +- **Lemma 4.** Closed-form bounds for the two tails. +- **Proposition 2** (computer-assisted). On 1,500 cells of `[10⁻⁶, 30]`, in outward-rounded 50-digit decimal interval arithmetic, `4.1977819534 ≤ J ≤ 4.1977820097`; the remainders contribute at most `2.81·10⁻⁸` and the tails at most `1.53·10⁻¹¹`. +- **Theorem CJ.** `4.1977819534 ≤ J ≤ 4.1977820097`, so `J = 4.19778198 ± 3·10⁻⁸`. Unconditional (it does not use #244). +- **Corollary CJ1.** For `d ∈ {2, 3}` and every real `L ≥ 10`: `0.012789638 ≤ c₃(L) ≤ 0.012789640` (`d = 2`; `≤ 0.012789639` for `L ≥ 24`) and `0.016092288 ≤ c₃(L) ≤ 0.016092334` (`d = 3`; `[0.016092310, 0.016092312]` for `L ≥ 24`). For SIDE24, `c₃(24) = 0.016092311 ± 10⁻⁹`. +- **Corollary CJ2.** At #244 Theorem A's conditional scope, `J/30 − Ĩ ≥ 0.311509`, so for every real `L ≥ 10`: `(c₃ − R_{2/3})(L) ≥ 0.035768` (`d = 3`; `≥ 0.035825` for `L ≥ 24`) and `≥ 0.028472` (`d = 2`). Note DC had `0.1711𝒮_d`; the exploration values are `0.0774672` and `0.0615684`, so the certified bounds are about 46% of them. + +## What the note does not establish + +From its "not claimed" section: +- no lower bound for `D`, so no value of note C7's coefficient: Corollary CJ2 is one-sided, and the other half of request 1 of [6033651797](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6033651797), a two-sided enclosure of `D`, stays open; +- nothing for `d ≥ 4` or `L < 10`, and no rate: notes C3 and C7 keep their `o(ℓ^{2/3})`; +- Proposition 2 assumes the documented correct rounding of the `decimal` module's `exp` and `ln`, widened by one unit in the last place; square roots are verified by squaring. + +## Not included + +- **The consumed sources.** Note C3 is in `frontiers/lifetime_two_thirds_chain_20261007/` (Math-#390, on `main`); notes V24 and DC are in custody packet Math-#393; #242 is on `main` at its own path (`SOURCES.json`, `related_packets`). +- **The clean-context referee reports** (same provider and session; not review evidence). They are kept in the author's record. +- **Coordination.** Comments that record no pickup, verdict or author response are not stored. `CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md` also answers coordination questions of 7 October, records the author handoffs of Math-#384, #387, #388, #392 and #393, and asks the OpenAI/Codex lanes three questions; none of that is part of the object. + +## Replay + + python3 -B -S frontiers/lifetime_cj_model_j_20261012/replay.py + python3 -B -O -S frontiers/lifetime_cj_model_j_20261012/replay.py + +`replay.py` uses the standard library only. It takes about ten minutes per mode, almost all of it in `cj_exact.py`, which takes about 45 seconds per full run. It is Math-#390's replay as landed on `main`, with this packet's paths, fingerprints and negative controls. It runs four checks: +1. **Identities.** Every stored file has the identity pinned in `SOURCES.json`, and the tree holds nothing else. +2. **Extraction.** `CJ/author_controls.py` and its stdout equal the fenced payloads in the stored controls comment, under the rule that comment states (that of [5971055189](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-5971055189)). The stdout is a ```` ```json ```` fence. +3. **The checker.** `cj_exact.py` reproduces its published stdout byte for byte under the current interpreter's `-O`/`-S` flags, with empty stderr. It reports 21,154 checks in fifteen groups, in outward-rounded decimal arithmetic at 50 digits, with the result `J in the printed interval`. + - Each of the 14 mutants and 5 invalid invocations reproduces its exact source-bound rejection: exit code, stdout and stderr fingerprints, with the intended group or the usage line. An exit code alone does not pass. + - The fingerprint table in `replay.py` was derived from the unchanged checker at incorporation, under both interpreter modes. +4. **Negative controls.** + - A one-byte change to the stored note (`CJ/PROOF.md`) is detected. + - A checker with one changed constant is rejected, failing exactly at `corollary`. The constant is `cj_exact.py`'s `438822`, note DC's bound `D ≤ 0.438822` as used by Corollary CJ2, replaced by `338822`. + +The workflow `.github/workflows/lifetime-cj-model-j.yml` runs on Python 3.11.16, in two jobs, one per mode, each with a 60-minute limit. Each job runs the protocol and raw-evidence tests (`tests/test_lifetime_cj_model_j_replay_protocol.py`, `tests/test_lifetime_cj_model_j_replay_evidence.py`), then the replay. These finite controls check explicit enclosures and identities, as the reads say. They do not prove the analytic statements. diff --git a/frontiers/lifetime_cj_model_j_20261012/SOURCES.json b/frontiers/lifetime_cj_model_j_20261012/SOURCES.json new file mode 100644 index 000000000..5ac024b0a --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/SOURCES.json @@ -0,0 +1,244 @@ +{ + "schema": 2, + "object": "LIFETIME-CJ-MODEL-J-INCORPORATION-20261012-v1", + "kind": "additive incorporation of public native note, review and checker records; no new mathematics; no status change", + "scientific_effect": "NONE", + "incorporated_by": { + "performer": "Anthropic Claude", + "session": "https://claude.ai/code/session_01NMeKEismAyeqgdB4sy2NJU", + "attribution": "Dylan Roy - delegated AI work", + "claim": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132312749", + "note": "the incorporator is also the author of note CJ (custody only; no proof byte is changed)" + }, + "source_issues": [ + "https://github.com/d6g8k5htny-coder/main/issues/229", + "https://github.com/d6g8k5htny-coder/main/issues/307" + ], + "source_issue_note": "main#229 reached GitHub's 2,500-comment limit on 8 October 2026; main#307 continues the same board. The claim is on main#229; every other stored comment is on main#307", + "extraction_rule": "the rule the controls comment states (that of main#229 comment 5971055189): the control script is the exact text between the first ```python fence after its heading and the next ``` line, plus a final newline; its expected stdout is the single JSON line of the following ```json fence, plus one newline", + "related_packets": { + "frontiers/lifetime_two_thirds_chain_20261007/": "notes C3 and SL (Math-#390, landed at 7d2f6250): C3's (G), the definition of J, and Proposition G, consumed by CJ", + "frontiers/v24_dc_two_thirds_sign_20261007/": "notes V24 (Theorem V's table) and DC (Theorem DC, the enclosure of -I~_quad), consumed by CJ, if Math-#393 has landed; otherwise main#229 6034159111 and 6037455875", + "frontiers/c7_elder_two_thirds_20261007/": "note C7 (Theorem C7), cited only for the name of Corollary CJ2, if Math-#392 has landed; otherwise main#229 6030039377", + "frontiers/soft_rejected_pairs_20261002/": "#242: Corollary 1' (S_2 = 25 sqrt3/(48 pi^2), S_3 = 125 sqrt30/(192 pi^3))", + "frontiers/soft_closed_form_20261002/": "#244: Theorem A, through notes V24 and DC (Corollary CJ2 only)" + }, + "excluded": { + "routing comments": "coordination comments that record no pickup, verdict or author response are not stored", + "clean-context referee reports": "same-provider referee reports are kept in the author's record (Google Drive folder CLAUDE01N_AUTHOR_RECORD_20261012 and the session outputs), not here; the controls comment records their findings", + "coordination inside stored comments": "CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md also answers coordination questions of 7 October, records the author handoffs of Math-#384, #387, #388, #392 and #393, and asks the OpenAI/Codex lanes three questions; none of that is part of the object" + }, + "objects": [ + { + "tag": "CJ", + "directory": "CJ/", + "object": "CL-CJ-MODEL-J-ENCLOSURE-20261007-v1", + "title": "Lifetime note CJ: a certified enclosure of note C3's model number J, and the value of the candidate density's l^(2/3) coefficient at every side L >= 10", + "author": "Anthropic Claude (session_01NMeKEismAyeqgdB4sy2NJU), for Dylan Roy (delegated AI work)", + "claim": "CJ/CLAIM.md (main#229 6038732027), renewed by the note comment (main#307 6132006756), released in CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md (main#307 6132312749)", + "kind": "Theorem CJ (4.1977819534 <= J <= 4.1977820097 for J = (16/15) int_0^inf e^(-12k^2) E[(3kB - gamma^2/4)_+^3] k^(-8/3) dk, gamma, B independent N(0, 2); unconditional, #244 not used), Corollary CJ1 (for d in {2, 3} and every real L >= 10 the candidate density's l^(2/3) coefficient c_3(L) lies in the stated nine-decimal intervals; c_3(24) = 0.016092311 +- 1e-9), Corollary CJ2 (at #244 Theorem A's conditional scope, J/30 - I~ >= 0.311509, so (c_3 - R_{2/3})(L) >= 0.035768 in d = 3 (>= 0.035825 for L >= 24) and >= 0.028472 in d = 2, one-sided), by Lemma 1 (integrating k out: J = (16/45)(4 pi)^(-1/2) int_0^inf h(a) psi(a) da with h(a) = E[(a - W)_+^3], W ~ Gamma(1/2, 1), psi(a) = (432/a^2)^(2/3) K_{4/3}(2a/sqrt3)), Lemma 2 (closed-form derivatives of h, complete monotonicity of psi), Lemma 3 (Simpson cells with a fourth-derivative remainder), Lemma 4 (closed-form tails) and Proposition 2 (computer-assisted: the control script, standard-library decimal with directed rounding on 1500 cells; every other step is proved by hand)", + "read_complete": "CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md (6132312749)", + "nonauthor_reads_as_recorded": [ + "Slice A (sections 0-2; primitives, representation, h_function, psi_function with M3, M4, M8, M10): Cursor agent bc-5156de96 (xAI Grok 4.7 (grok-4.7-high-fast); non-Claude, nonauthor), PASS, 6132038648", + "Slice B (sections 3-6 and the header; the remaining groups with M1, M2, M5, M6, M7, M9, M11-M14 and five invalid invocations): Cursor agent bc-6fa3ed1c (xAI Grok 4.7 (grok-4.7-high-fast); non-Claude, nonauthor), PASS, 6132039314" + ], + "author_side_record": "two clean-context same-provider referee reads (Slice A BLOCK, fixed; Slice B AMEND, applied) and one readback of the revision (AMEND, applied) before posting; recorded in CJ/AUTHOR_CONTROLS_COMMENT.md; not review evidence", + "conditional_on": "Theorem CJ and Corollary CJ1: note C3 (custody packet Math-#390, landed: frontiers/lifetime_two_thirds_chain_20261007/C3/), note V24 (Theorem V's table; open custody packet Math-#393, otherwise main#229 6034159111) and #242 Corollary 1' (frontiers/soft_rejected_pairs_20261002/PROOF.md, blob 271412db), at their stated scopes. Corollary CJ2 additionally: note DC (Theorem DC and the enclosure of -I~_quad; Math-#393, otherwise main#229 6037455875), hence #244 Theorem A (conditional on #170 Theorem E(1), [CUB] Theorem C and [CUB]'s (C8)-(C11) with its B = 0 paragraph), and the scopes of notes C7 and V24", + "not_claimed": "no lower bound for D, so no value of note C7's coefficient (Corollary CJ2 is one-sided; the other half of request 1 of 6033651797 stays open); nothing for d >= 4 or L < 10; no rate (notes C3 and C7 keep their o(l^(2/3))); the computer-assisted part assumes the documented correct rounding of decimal exp and ln, widened by one unit in the last place; square roots are verified by squaring", + "organizational_independence": 0, + "stored": [ + { + "path": "CJ/CLAIM.md", + "role": "author D5 claim for note CJ on main#229 (7 October; the J half of request 1 of 6033651797); its lease lapsed on 7 October and the stored note comment renews it", + "comment": "6038732027", + "issue": "main#229", + "url": "https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6038732027", + "created_at": "2026-10-07T13:15:11Z", + "updated_at": "2026-10-07T13:15:11Z", + "bytes": 2948, + "sha256": "3073478600a8c5ed3e2fa5e93256c5c6bfededd61106063279f2eca2fcb2320a" + }, + { + "path": "CJ/PROOF.md", + "role": "frozen note (lifetime note CJ), main#307", + "comment": "6132006756", + "issue": "main#307", + "url": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132006756", + "created_at": "2026-10-12T20:24:31Z", + "updated_at": "2026-10-12T20:24:31Z", + "bytes": 26635, + "sha256": "5ae61e5d1239b04b31dd854e1fd08b4f9aa6822ea7469bdebabe86619c0554f7" + }, + { + "path": "CJ/AUTHOR_CONTROLS_COMMENT.md", + "role": "author controls comment (contains cj_exact.py and its stdout, the extraction rule, and the author-side referee record, which is not review evidence), main#307", + "comment": "6132024544", + "issue": "main#307", + "url": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132024544", + "created_at": "2026-10-12T20:25:45Z", + "updated_at": "2026-10-12T20:25:45Z", + "bytes": 33713, + "sha256": "19be58e0d2112e7f2a30a7d818dd09ccac5a42fc18c07c37789e060982932e5b" + }, + { + "path": "CJ/author_controls.py", + "role": "control script cj_exact.py, extracted verbatim from the stored controls comment CJ/AUTHOR_CONTROLS_COMMENT.md (heading: ### cj_exact.py)", + "extracted_from": "CJ/AUTHOR_CONTROLS_COMMENT.md", + "heading": "### cj_exact.py", + "bytes": 26090, + "sha256": "b3be1503937fb0875ff1dedebf9edbee79c16888da2fb68cbc5bce2524215458" + }, + { + "path": "CJ/author_controls_stdout.json", + "role": "published stdout of CJ/author_controls.py, extracted verbatim from CJ/AUTHOR_CONTROLS_COMMENT.md (```json fence)", + "extracted_from": "CJ/AUTHOR_CONTROLS_COMMENT.md", + "heading": "### cj_exact.py", + "bytes": 835, + "sha256": "c42031da918ce388345a9e7488b38925763d53ca3de86731dce4cfc6c405a34e" + }, + { + "path": "CJ/REVIEW_SLICE_A_SUMMONS.md", + "role": "Slice A summons (one Cursor agent, D2 of 6002718035), main#307", + "comment": "6132037280", + "issue": "main#307", + "url": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132037280", + "created_at": "2026-10-12T20:26:38Z", + "updated_at": "2026-10-12T20:26:38Z", + "bytes": 5710, + "sha256": "dfe30a5acf90032aa65361c3597e2cf93828d74b3ea0e59a0172580385281429" + }, + { + "path": "CJ/REVIEW_SLICE_A.md", + "role": "Slice A (sections 0-2: the setting, Lemma 1, Lemma 2 and the evaluation of the special functions; groups primitives, representation, h_function, psi_function with M3, M4, M8, M10): PASS, Cursor agent bc-5156de96 (xAI Grok 4.7 (grok-4.7-high-fast); non-Claude, nonauthor); pickup and verdict in one edited cursor[bot] acknowledgement (GitHub refused the agent a new comment)", + "comment": "6132038648", + "issue": "main#307", + "url": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132038648", + "created_at": "2026-10-12T20:26:44Z", + "updated_at": "2026-10-12T20:39:09Z", + "bytes": 5500, + "sha256": "c2db004585386aa52ac8c92d5bc2d665d7b3e4b23b04c2a722aeb87a2a6455d7" + }, + { + "path": "CJ/REVIEW_SLICE_B_SUMMONS.md", + "role": "Slice B summons (one Cursor agent, D2 of 6002718035), main#307", + "comment": "6132038287", + "issue": "main#307", + "url": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132038287", + "created_at": "2026-10-12T20:26:42Z", + "updated_at": "2026-10-12T20:26:42Z", + "bytes": 5766, + "sha256": "4d0da86fad90b1e9e0f5acc7dc68e1c5dde93f3d312345f528f4083ec0024f57" + }, + { + "path": "CJ/REVIEW_SLICE_B.md", + "role": "Slice B (sections 3-6 and the header: Lemmas 3-4, Proposition 2, Theorem CJ, Corollaries CJ1-CJ2, Remarks 1-3, the controls; the remaining groups with M1, M2, M5, M6, M7, M9, M11-M14 and the invalid invocations): PASS, Cursor agent bc-6fa3ed1c (xAI Grok 4.7 (grok-4.7-high-fast); non-Claude, nonauthor); pickup and verdict in one edited cursor[bot] acknowledgement (GitHub refused the agent a new comment)", + "comment": "6132039314", + "issue": "main#307", + "url": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132039314", + "created_at": "2026-10-12T20:26:46Z", + "updated_at": "2026-10-12T20:44:48Z", + "bytes": 4508, + "sha256": "9bb2b288a678bf3de4d8bdd00ee4f1a94628c7c5ebcfc0f5ac8de74acca2beb2" + }, + { + "path": "CJ/AUTHOR_READ_COMPLETE_AND_PACKET_CLAIM.md", + "role": "author note on main#307: note CJ read in both slices and its claim released; the D5 claim for this custody packet (its last section). The same comment answers coordination questions of 7 October and records the author handoffs of five earlier packets; those parts are not part of the object", + "comment": "6132312749", + "issue": "main#307", + "url": "https://github.com/d6g8k5htny-coder/main/issues/307#issuecomment-6132312749", + "created_at": "2026-10-12T20:45:39Z", + "updated_at": "2026-10-12T20:45:39Z", + "bytes": 10125, + "sha256": "4028643976465e59e71c16a647f5d8c267303f2deceb78cf1088d2fb21476e14" + } + ], + "replays": [ + { + "name": "cj_exact.py (stdout in a ```json fence)", + "script": "CJ/author_controls.py", + "stdout": "CJ/author_controls_stdout.json", + "args": [], + "mutants": [ + [ + "--mutant", + "M1" + ], + [ + "--mutant", + "M2" + ], + [ + "--mutant", + "M3" + ], + [ + "--mutant", + "M4" + ], + [ + "--mutant", + "M5" + ], + [ + "--mutant", + "M6" + ], + [ + "--mutant", + "M7" + ], + [ + "--mutant", + "M8" + ], + [ + "--mutant", + "M9" + ], + [ + "--mutant", + "M10" + ], + [ + "--mutant", + "M11" + ], + [ + "--mutant", + "M12" + ], + [ + "--mutant", + "M13" + ], + [ + "--mutant", + "M14" + ] + ], + "invalid": [ + [ + "--bogus" + ], + [ + "--mutant", + "M15" + ], + [ + "--mutant" + ], + [ + "--mutant", + "m14" + ], + [ + "--mutant", + "M1", + "extra" + ] + ] + } + ] + } + ] +} diff --git a/frontiers/lifetime_cj_model_j_20261012/replay.py b/frontiers/lifetime_cj_model_j_20261012/replay.py new file mode 100644 index 000000000..fdaab97f2 --- /dev/null +++ b/frontiers/lifetime_cj_model_j_20261012/replay.py @@ -0,0 +1,355 @@ +#!/usr/bin/env python3 +"""Verify the stored records of lifetime note CJ, and replay its published author controls (standard library +only). + +Every file in this packet except replay.py, README.md and SOURCES.json is one of two things: + - an exact copy of a public comment body on main#307 (a note, controls comment, summons, review or author + response) or on main#229 (the claim); + - a control script or its stdout, extracted verbatim from its stored controls comment by the extraction rule that + comment states (the rule of main#229 comment 5971055189). Each stdout is a ```json fence. +SOURCES.json pins each file by byte count and SHA-256 and lists each replay. This script performs four checks. + + 1. The packet tree equals SOURCES.json's file list, with no symlinks, and every stored file has its pinned + identity. + 2. Every extracted script and stdout equals the fenced payload inside its stored source comment, under the + extraction rule (the stdout fence language follows the stored stdout's suffix: .json for ```json, .txt for ```text). + 3. Every control script runs under the current interpreter's -O/-S flags and reproduces its published stdout byte + for byte (none prints an interpreter version), with empty stderr. Every listed mutant or invalid invocation + must reproduce its exact source-bound rejection on BOTH captured streams, not merely exit 1 or 2. + 4. Negative controls must be rejected: + - a one-byte change to the stored note (CJ/PROOF.md); + - a control script with one changed constant (cj_exact.py's constant 438822, note DC's bound + D <= 0.438822 in the corollary group, replaced by 338822). + +Reproducibility only. The analytic notes and their reads carry the mathematics. These finite checks support +algebra, as the reads say. Nothing here reads or grades a proof. + +Usage: python3 -B -S frontiers/lifetime_cj_model_j_20261012/replay.py (exit 0 iff every check passes) +Optional QS_REPLAY_EVIDENCE_DIR (outside the checkout) retains raw child streams and process records. +Each invocation gets a new directory; records describe execution, never mathematical acceptance. +Required evidence I/O fails the run; a timeout/spawn error remains the primary exception. +""" +import hashlib +import json +import os +import pathlib +import re +import shutil +import subprocess +import sys +import tempfile + +HERE = pathlib.Path(__file__).resolve().parent +OWN = {'README.md', 'SOURCES.json', 'replay.py'} + +# Exact rejection fingerprints of the extracted author controls (cj_exact.py from main#307 6132024544), computed +# under both interpreter modes at incorporation and found identical. +# Each key is (script path, complete argv tail); each value is (exit, stdout SHA256, +# stderr SHA256, readable reason). References are frozen independently of this run. +# All 14 mutants and 5 invalid invocations were executed and their named reasons +# checked against their source. Exact fingerprints enforce the full contracts, +# including the empty stdout, the FAILED or usage line and its group name. +# No current failing output, generic exit code or broad regex creates a reference. +# Any source/runtime output drift fails closed and requires a reviewed amendment. +REJECTION_CONTRACTS = { + ('CJ/author_controls.py', ('--mutant', 'M1')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '661280ddfcc3b68e87eb5d881bfb664f0d37ccc73abc73f97f63e1280bb38e7a', 'FAILED: gamma'), + ('CJ/author_controls.py', ('--mutant', 'M2')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '0fa86a59ef4cd264f1a042b5047cc4d52cbb45518ef74c9d50c1c90eb544c1dd', 'FAILED: bessel'), + ('CJ/author_controls.py', ('--mutant', 'M3')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '0ac53204720e810598077212d3a1393945f12f4fe2e2f55cd08c78792c5dc11e', 'FAILED: h_function'), + ('CJ/author_controls.py', ('--mutant', 'M4')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'a4cf7b00f716fdb6bdae62d8f6c2369dd2cb2f7c1dbd7a75c54eebaabac90395', 'FAILED: psi_function'), + ('CJ/author_controls.py', ('--mutant', 'M5')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '320c34b19566af0e36d7a4296e1801bc7d1d672fcc1be64dc603a4dde020b135', 'FAILED: moment'), + ('CJ/author_controls.py', ('--mutant', 'M6')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'a4cf7b00f716fdb6bdae62d8f6c2369dd2cb2f7c1dbd7a75c54eebaabac90395', 'FAILED: psi_function'), + ('CJ/author_controls.py', ('--mutant', 'M7')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '752297ef40c867a7efca954b6a6ee461065c0a10f9dfeca3dac4327ab781f732', 'FAILED: partition'), + ('CJ/author_controls.py', ('--mutant', 'M8')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'c9288410bc42989d5f428656ed2877324ca0f7109526f68743e0de8a48fb2372', 'FAILED: representation'), + ('CJ/author_controls.py', ('--mutant', 'M9')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '3f07001ac2f55bd20a9fb0957120d63cdcf6e32c3d7daf3b4f82df4221f9012b', 'FAILED: corollary'), + ('CJ/author_controls.py', ('--mutant', 'M10')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '0ac53204720e810598077212d3a1393945f12f4fe2e2f55cd08c78792c5dc11e', 'FAILED: h_function'), + ('CJ/author_controls.py', ('--mutant', 'M11')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '320c34b19566af0e36d7a4296e1801bc7d1d672fcc1be64dc603a4dde020b135', 'FAILED: moment'), + ('CJ/author_controls.py', ('--mutant', 'M12')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '4a857959df0b4ae040d8d161beb7b673c02e896d0329ef6a791f64173643524b', 'FAILED: remainder'), + ('CJ/author_controls.py', ('--mutant', 'M13')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '8a4f88114758bba527121f59b278439343f545be8cb0e4e629a6a17838b4339d', 'FAILED: J_cells'), + ('CJ/author_controls.py', ('--mutant', 'M14')): + (1, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', '614a66d6651a10dc76faeb681aed8d394048cc69ccd92fd9cd46887a687b6747', 'FAILED: pinned'), + ('CJ/author_controls.py', ('--bogus',)): + (2, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'aaade6ed8d5dbbe7292e71c4e94dce4deb7ccb00816135dd48c05b49fd9f417d', 'usage: cj_exact.py [--mutant M1..M14]'), + ('CJ/author_controls.py', ('--mutant', 'M15')): + (2, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'aaade6ed8d5dbbe7292e71c4e94dce4deb7ccb00816135dd48c05b49fd9f417d', 'usage: cj_exact.py [--mutant M1..M14]'), + ('CJ/author_controls.py', ('--mutant',)): + (2, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'aaade6ed8d5dbbe7292e71c4e94dce4deb7ccb00816135dd48c05b49fd9f417d', 'usage: cj_exact.py [--mutant M1..M14]'), + ('CJ/author_controls.py', ('--mutant', 'm14')): + (2, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'aaade6ed8d5dbbe7292e71c4e94dce4deb7ccb00816135dd48c05b49fd9f417d', 'usage: cj_exact.py [--mutant M1..M14]'), + ('CJ/author_controls.py', ('--mutant', 'M1', 'extra')): + (2, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'aaade6ed8d5dbbe7292e71c4e94dce4deb7ccb00816135dd48c05b49fd9f417d', 'usage: cj_exact.py [--mutant M1..M14]'), +} + +# Replacing cj_exact.py's constant 438822 (note DC's D <= 0.438822, used by Corollary CJ2) by 338822 with MUT=None +# must fail specifically at corollary, on stderr alone. +NEGATIVE_CONSTANT = (1, hashlib.sha256(b'').hexdigest(), + hashlib.sha256(b'FAILED: corollary\n').hexdigest(), 'corollary') + + +def check_rejection(result, expected): + """Compare both full captured streams, not a permissive failure-message pattern.""" + code, out, err = result + failures = [] + if type(code) is not int or code != expected[0]: + failures.append('wrong exit code') + if type(out) is not bytes or hashlib.sha256(out).hexdigest() != expected[1]: + failures.append('stdout differs from intended diagnostic') + if type(err) is not bytes or hashlib.sha256(err).hexdigest() != expected[2]: + failures.append('stderr differs from intended diagnostic') + return failures + + +def rejection_inventory_failures(manifest): + listed = {} + for obj in manifest['objects']: + for replay in obj['replays']: + for kind, code in (('mutants', 1), ('invalid', 2)): + for args in replay[kind]: + key = replay['script'], tuple(args) + if key in listed: + return ['duplicate rejection invocation: ' + repr(key)] + listed[key] = code + if set(listed) != set(REJECTION_CONTRACTS): + return ['rejection invocation inventory differs from frozen contracts'] + if any(REJECTION_CONTRACTS[key][0] != code for key, code in listed.items()): + return ['rejection invocation category differs from frozen contracts'] + return [] + + +def report_control(script, args, result, reason): + code, out, err = result + print(json.dumps(dict(script=script, args=list(args), returncode=code, + stdout_sha256=hashlib.sha256(out).hexdigest(), + stderr_sha256=hashlib.sha256(err).hexdigest(), + expected_reason=reason), sort_keys=True)) + + +def identity(data): + return len(data), hashlib.sha256(data).hexdigest() + + +def interpreter_flags(): + flags = ['-B'] + if sys.flags.optimize: + flags.append('-O') + if sys.flags.no_site: + flags.append('-S') + return flags + + +def tree_failures(root, manifest): + failures = [] + listed = {} + for obj in manifest['objects']: + for f in obj['stored']: + listed[f['path']] = (f['bytes'], f['sha256']) + present = set() + for path in sorted(root.rglob('*')): + rel = path.relative_to(root).as_posix() + if path.is_symlink(): + failures.append('symlink: ' + rel) + elif path.is_file(): + present.add(rel) + for rel in sorted(present ^ (set(listed) | OWN)): + failures.append(('unlisted file: ' if rel in present else 'missing file: ') + rel) + for rel, ident in sorted(listed.items()): + if rel in present and identity((root / rel).read_bytes()) != ident: + failures.append('identity mismatch: ' + rel) + return failures + + +def extraction_failures(root, manifest): + """Re-extract every script and stdout from its stored source comment and compare with the stored payloads.""" + failures = [] + for obj in manifest['objects']: + extracted = [f for f in obj['stored'] if 'extracted_from' in f] + for script in [f for f in extracted if f['path'].endswith('.py')]: + stdout = [f for f in extracted if f['extracted_from'] == script['extracted_from'] + and f['heading'] == script['heading'] and not f['path'].endswith('.py')] + if len(stdout) != 1: + failures.append('%s: no single stdout record for %s' % (obj['tag'], script['path'])) + continue + stdout = stdout[0] + fence = {'json': 'json', 'txt': 'text'}.get(stdout['path'].rsplit('.', 1)[-1]) + if fence is None: + failures.append('%s: unsupported stdout suffix for %s' % (obj['tag'], stdout['path'])) + continue + body = (root / script['extracted_from']).read_text(encoding='utf-8') + if body.count(script['heading']) < 1: + failures.append('%s: heading %r not found in %s' % (obj['tag'], script['heading'], script['extracted_from'])) + continue + section = body[body.index(script['heading']):] + m1 = re.search(r'```python\n(.*?)\n```\n', section, re.S) + m2 = re.search(r'```%s\n(.*?)\n```\n' % fence, section[m1.end():], re.S) if m1 else None + if not (m1 and m2): + failures.append('%s: fences not found after %r' % (obj['tag'], script['heading'])) + continue + if (m1.group(1) + '\n').encode('utf-8') != (root / script['path']).read_bytes(): + failures.append('%s: %s differs from the payload in %s' % (obj['tag'], script['path'], script['extracted_from'])) + if (m2.group(1) + '\n').encode('utf-8') != (root / stdout['path']).read_bytes(): + failures.append('%s: %s differs from the payload in %s' % (obj['tag'], stdout['path'], stdout['extracted_from'])) + return failures + + +PROCESS_TIMEOUT_SECONDS = 1800 # Unchanged production budget; tests shorten it for real timeout children. + + +def evidence_directory(script): + """An explicit destination opts in; never put generated evidence in source directories.""" + raw = os.environ.get('QS_REPLAY_EVIDENCE_DIR') + if raw is None: + return None + if not raw: + raise ValueError('QS_REPLAY_EVIDENCE_DIR must not be empty') + root = pathlib.Path(raw).expanduser().resolve() + if root.is_relative_to(HERE.resolve().parents[1]) or root.is_relative_to(script.parent.resolve()): + raise ValueError('QS replay evidence must be outside the checkout and child source directory') + root.mkdir(parents=True, exist_ok=True) + return pathlib.Path(tempfile.mkdtemp(prefix='invocation-', dir=root)) + + +def save_process_evidence(folder, record, out, err): + """Attempt every write independently. None is unavailable, not an observed empty stream.""" + record['streams'] = {} + record['evidence_errors'] = [] + for name, data in (('stdout', out), ('stderr', err)): + entry = dict(available=data is not None, bytes=len(data) if data is not None else None, + sha256=hashlib.sha256(data).hexdigest() if data is not None else None, saved=False) + record['streams'][name] = entry + try: + (folder / (name + '.bin')).write_bytes(data if data is not None else b'') + entry['saved'] = True + except Exception as exc: + record['evidence_errors'].append('%s.bin: %s: %s' % (name, type(exc).__name__, exc)) + try: + data = (json.dumps(record, sort_keys=True, indent=2, allow_nan=False) + '\n').encode('utf-8') + (folder / 'process.json').write_bytes(data) + except Exception as exc: + record['evidence_errors'].append('process.json: %s: %s' % (type(exc).__name__, exc)) + + +def run(script, *args): + command = [sys.executable, *interpreter_flags(), str(script), *args] + folder = evidence_directory(script) # Invalid/unwritable setup stops before starting a child. + record = dict(schema=1, command=command, cwd=str(script.parent), + timeout_seconds=PROCESS_TIMEOUT_SECONDS, scientific_effect='NONE') + try: + proc = subprocess.run(command, capture_output=True, timeout=PROCESS_TIMEOUT_SECONDS, + cwd=str(script.parent)) + except (subprocess.TimeoutExpired, OSError) as exc: + if folder is not None: + record.update(status='timeout' if isinstance(exc, subprocess.TimeoutExpired) else 'spawn_error', + returncode=None, exception=dict(type=type(exc).__name__, message=str(exc))) + exc.evidence_record = record + try: + save_process_evidence(folder, record, getattr(exc, 'stdout', None), getattr(exc, 'stderr', None)) + if record['evidence_errors']: + exc.add_note('QS replay evidence errors: ' + '; '.join(record['evidence_errors'])) + except Exception as secondary: + exc.add_note('QS replay evidence recording failed: %s: %s' % (type(secondary).__name__, secondary)) + raise # Never replace the primary timeout or launch error with a recording error. + if folder is not None: + record.update(status='completed', returncode=proc.returncode, exception=None) + save_process_evidence(folder, record, proc.stdout, proc.stderr) + if record['evidence_errors']: + exc = RuntimeError('QS replay evidence errors: ' + '; '.join(record['evidence_errors'])) + exc.evidence_record = record + raise exc # Even exit 0 is not success when explicitly required evidence is missing. + return proc.returncode, proc.stdout, proc.stderr + + +def replay_failures(root, manifest): + failures = rejection_inventory_failures(manifest) + if failures: + return failures # Do not execute an incomplete/changed control inventory. + for obj in manifest['objects']: + for replay in obj['replays']: + label = '%s %s' % (obj['tag'], replay['name']) + script = root / replay['script'] + code, out, err = run(script, *replay['args']) + baseline_failures = [] + if code != 0: + baseline_failures.append('%s: exit code %s' % (label, code)) + if out != (root / replay['stdout']).read_bytes(): + baseline_failures.append('%s: stdout differs from the published bytes' % label) + if err: + baseline_failures.append('%s: unexpected baseline stderr' % label) + if baseline_failures: + failures.extend(baseline_failures) + continue + report_control(replay['script'], replay['args'], (code, out, err), 'exact published baseline') + for kind in ('mutants', 'invalid'): + for args in replay[kind]: + expected = REJECTION_CONTRACTS[replay['script'], tuple(args)] + result = run(script, *args) + mismatches = check_rejection(result, expected) + failures.extend('%s %r: %s' % (label, args, why) for why in mismatches) + if not mismatches: + report_control(replay['script'], args, result, expected[3]) + return failures + + +def negative_control_failures(root, manifest): + failures = [] + with tempfile.TemporaryDirectory() as tmp: + copy = pathlib.Path(tmp) / 'packet' + shutil.copytree(root, copy, symlinks=True) + target = copy / 'CJ' / 'PROOF.md' + data = bytearray(target.read_bytes()) + data[100] ^= 0x01 + target.write_bytes(bytes(data)) + if 'identity mismatch: CJ/PROOF.md' not in tree_failures(copy, manifest): + failures.append('negative control: a one-byte change to CJ/PROOF.md was not detected') + script = copy / 'CJ' / 'author_controls.py' + text = script.read_text(encoding='utf-8') + old = 'q(Fr(438822, 10 ** 6))' + if text.count(old) != 1: + failures.append('negative control: the D bound constant was not found exactly once') + else: + script.write_text(text.replace(old, 'q(Fr(338822, 10 ** 6))'), encoding='utf-8') + result = run(script) + mismatches = check_rejection(result, NEGATIVE_CONSTANT) + failures.extend('negative control: changed D bound constant: ' + why for why in mismatches) + if not mismatches: + report_control('CJ/author_controls.py', [], result, 'changed 438822 to 338822: corollary') + return failures + + +def main(): + manifest = json.loads((HERE / 'SOURCES.json').read_text(encoding='utf-8')) + failures = tree_failures(HERE, manifest) + if not failures: + failures = extraction_failures(HERE, manifest) + if not failures: + failures = replay_failures(HERE, manifest) + if not failures: + failures = negative_control_failures(HERE, manifest) + n_scripts = sum(len(o['replays']) for o in manifest['objects']) + n_mut = sum(len(r['mutants']) for o in manifest['objects'] for r in o['replays']) + n_inv = sum(len(r['invalid']) for o in manifest['objects'] for r in o['replays']) + n_files = sum(len(o['stored']) for o in manifest['objects']) + mode = ' '.join(interpreter_flags()) + if failures: + for f in failures: + print('FAIL ' + f) + print('Lifetime note CJ incorporation replay (%s): %d failure(s)' % (mode, len(failures))) + return 1 + print('Lifetime note CJ incorporation replay (%s): %d stored identities, %d extractions, %d checker stdouts, ' + '%d mutants, %d invalid invocations and 2 negative controls PASS' % (mode, n_files, 2 * n_scripts, n_scripts, n_mut, n_inv)) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tests/test_lifetime_cj_model_j_replay_evidence.py b/tests/test_lifetime_cj_model_j_replay_evidence.py new file mode 100644 index 000000000..c1c51cddd --- /dev/null +++ b/tests/test_lifetime_cj_model_j_replay_evidence.py @@ -0,0 +1,215 @@ +"""Optional raw-process evidence; synthetic children are not mathematical evidence.""" +import hashlib +import importlib.util +import json +import os +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest +from unittest.mock import patch + +ROOT = Path(__file__).resolve().parents[1] +PACKET = ROOT / 'frontiers/lifetime_cj_model_j_20261012' +ENV = 'QS_REPLAY_EVIDENCE_DIR' + + +class RawEvidenceTests(unittest.TestCase): + def setUp(self): + spec = importlib.util.spec_from_file_location('qs_raw_subject', PACKET / 'replay.py') + self.m = importlib.util.module_from_spec(spec) + spec.loader.exec_module(self.m) + self.tmp = tempfile.TemporaryDirectory() + self.addCleanup(self.tmp.cleanup) + self.root = Path(self.tmp.name) + scripts = self.root / 'scripts' + scripts.mkdir() + self.script = scripts / 'fixture.py' + self.evidence = self.root / 'evidence' + self.env = patch.dict(os.environ, {ENV: str(self.evidence)}) + self.env.start() + self.addCleanup(self.env.stop) + + def child(self, text): + self.script.write_text(text, encoding='utf-8') + return self.script + + def record(self): + records = list(self.evidence.glob('invocation-*/process.json')) + self.assertEqual(len(records), 1, 'one independently retained child process record required') + return records[0].parent, json.loads(records[0].read_bytes()) + + def verify_stream(self, folder, rec, name, value): + stream = rec['streams'][name] + self.assertEqual(stream['available'], value is not None) + self.assertEqual(stream['bytes'], len(value) if value is not None else None) + self.assertEqual(stream['sha256'], hashlib.sha256(value).hexdigest() if value is not None else None) + self.assertTrue(stream['saved']) + self.assertEqual((folder / (name + '.bin')).read_bytes(), value if value is not None else b'') + + def test_no_capture_preserves_original_three_value_result(self): + os.environ.pop(ENV) + s = self.child("import os,sys\nos.write(1,b'\\xffok');os.write(2,b'\\x00err');sys.exit(7)\n") + self.assertEqual(self.m.run(s), (7, b'\xffok', b'\x00err')) + self.assertFalse(self.evidence.exists()) + + def test_real_crash_retains_full_binary_streams_and_invocation(self): + s = self.child("import os\nos.write(1,b'\\x00\\xffpartial')\nraise RuntimeError('synthetic crash')\n") + result = self.m.run(s, '--diagnostic') + self.assertEqual(result[0], 1) + self.assertIn(b'RuntimeError: synthetic crash', result[2]) + folder, rec = self.record() + self.assertEqual(rec['command'], [sys.executable, *self.m.interpreter_flags(), str(s), '--diagnostic']) + self.assertEqual(rec['cwd'], str(s.parent)) + self.assertEqual(rec['timeout_seconds'], 1800) + self.assertEqual(rec['status'], 'completed') + self.assertEqual(rec['returncode'], 1) + self.assertNotIn('passed', rec) + self.assertEqual(rec['evidence_errors'], []) + self.verify_stream(folder, rec, 'stdout', result[1]) + self.verify_stream(folder, rec, 'stderr', result[2]) + + def test_success_and_intended_failure_outputs_are_not_reinterpreted(self): + s = self.child("import os,sys\nos.write(1,b'answer\\n');os.write(2,b'diagnostic\\n');sys.exit(int(sys.argv[1]))\n") + for code in (0, 1, 2): + with self.subTest(code=code): + result = self.m.run(s, str(code)) + self.assertEqual(result, (code, b'answer\n', b'diagnostic\n')) + records = [json.loads(p.read_bytes()) for p in self.evidence.glob('invocation-*/process.json')] + self.assertEqual(sorted(r['returncode'] for r in records), [0, 1, 2]) + self.assertTrue(all('passed' not in r for r in records)) + + def test_repeated_invocations_never_overwrite(self): + s = self.child("print('first')\n") + self.m.run(s) + before = {p: p.read_bytes() for p in self.evidence.glob('invocation-*/*')} + self.assertEqual(len(before), 3) + self.m.run(s) + self.assertEqual(len(list(self.evidence.glob('invocation-*'))), 2) + for p, data in before.items(): + self.assertEqual(p.read_bytes(), data) + + def test_real_timeout_keeps_partial_bytes_and_timeout_exception(self): + self.assertTrue(hasattr(self.m, 'PROCESS_TIMEOUT_SECONDS'), 'explicit unchanged production timeout required') + s = self.child("import os,time\nos.write(1,b'\\xffout');os.write(2,b'\\x00err');time.sleep(10)\n") + with patch.object(self.m, 'PROCESS_TIMEOUT_SECONDS', 0.5): + with self.assertRaises(subprocess.TimeoutExpired) as caught: + self.m.run(s) + folder, rec = self.record() + self.assertEqual(rec['status'], 'timeout') + self.assertIsNone(rec['returncode']) + self.assertEqual(rec['timeout_seconds'], 0.5) + self.assertEqual(caught.exception.output, b'\xffout') + self.assertEqual(caught.exception.stderr, b'\x00err') + self.verify_stream(folder, rec, 'stdout', caught.exception.output) + self.verify_stream(folder, rec, 'stderr', caught.exception.stderr) + self.assertEqual(caught.exception.evidence_record, rec) + + def test_unavailable_empty_and_binary_timeout_capture_are_distinct(self): + for out in (None, b'', b'\xff\x00'): + for err in (None, b'', b'\x80err'): + with self.subTest(out=out, err=err), tempfile.TemporaryDirectory() as td: + target = Path(td) / 'records' + exc = subprocess.TimeoutExpired(['synthetic'], 1800, output=out, stderr=err) + with patch.dict(os.environ, {ENV: str(target)}), patch.object(self.m.subprocess, 'run', side_effect=exc): + with self.assertRaises(subprocess.TimeoutExpired) as caught: + self.m.run(self.script) + self.assertIs(caught.exception, exc) + paths = list(target.glob('invocation-*/process.json')) + self.assertEqual(len(paths), 1) + rec = json.loads(paths[0].read_bytes()) + self.verify_stream(paths[0].parent, rec, 'stdout', out) + self.verify_stream(paths[0].parent, rec, 'stderr', err) + self.assertIsNone(rec['returncode']) + + def test_real_spawn_error_retains_unknown_output_and_original_error(self): + s = self.child("print('must not execute')\n") + missing = str(self.root / 'missing-interpreter') + with patch.object(self.m.sys, 'executable', missing): + with self.assertRaises(FileNotFoundError) as caught: + self.m.run(s) + folder, rec = self.record() + self.assertEqual(rec['status'], 'spawn_error') + self.assertIsNone(rec['returncode']) + self.assertEqual(rec['exception']['type'], 'FileNotFoundError') + self.verify_stream(folder, rec, 'stdout', None) + self.verify_stream(folder, rec, 'stderr', None) + self.assertEqual(caught.exception.evidence_record, rec) + + def test_each_write_failure_still_attempts_other_evidence(self): + original = Path.write_bytes + for failed in ('stdout.bin', 'stderr.bin', 'process.json'): + with self.subTest(failed=failed), tempfile.TemporaryDirectory() as td: + target = Path(td) / 'records' + attempted = [] + def write(path, data): + attempted.append(path.name) + if path.name == failed: + raise OSError('synthetic write refusal') + return original(path, data) + exc = subprocess.TimeoutExpired(['synthetic'], 1800, output=b'out', stderr=b'err') + with patch.dict(os.environ, {ENV: str(target)}), patch.object(self.m.subprocess, 'run', side_effect=exc), patch.object(Path, 'write_bytes', write): + with self.assertRaises(subprocess.TimeoutExpired) as caught: + self.m.run(self.script) + self.assertIs(caught.exception, exc) + self.assertEqual(attempted, ['stdout.bin', 'stderr.bin', 'process.json']) + rec = caught.exception.evidence_record + self.assertEqual(len(rec['evidence_errors']), 1) + self.assertIn(failed, rec['evidence_errors'][0]) + self.assertTrue(any('evidence' in note for note in caught.exception.__notes__)) + folder = next(target.glob('invocation-*')) + for name in {'stdout.bin', 'stderr.bin', 'process.json'} - {failed}: + self.assertTrue((folder / name).is_file()) + + def test_all_write_failures_do_not_replace_primary_timeout(self): + exc = subprocess.TimeoutExpired(['synthetic'], 1800, output=b'out', stderr=b'err') + with patch.object(self.m.subprocess, 'run', side_effect=exc), patch.object(Path, 'write_bytes', side_effect=OSError('synthetic full disk')): + with self.assertRaises(subprocess.TimeoutExpired) as caught: + self.m.run(self.script) + self.assertIs(caught.exception, exc) + self.assertTrue(hasattr(exc, 'evidence_record'), 'retain failure metadata in memory') + self.assertEqual(len(exc.evidence_record['evidence_errors']), 3) + self.assertIsNone(exc.evidence_record['returncode']) + + def test_completed_child_with_failed_evidence_cannot_report_success(self): + self.child("print('actual completed child')\n") + with patch.object(Path, 'write_bytes', side_effect=OSError('synthetic full disk')): + with self.assertRaises(RuntimeError) as caught: + self.m.run(self.script) + self.assertEqual(caught.exception.evidence_record['returncode'], 0) + self.assertEqual(len(caught.exception.evidence_record['evidence_errors']), 3) + + def test_invalid_destination_stops_before_child(self): + for target in (PACKET / 'forbidden-evidence', self.script.parent / 'forbidden-evidence'): + with self.subTest(target=target), patch.dict(os.environ, {ENV: str(target)}), patch.object(self.m.subprocess, 'run') as child: + with self.assertRaises(ValueError): + self.m.run(self.script) + child.assert_not_called() + self.assertFalse(target.exists()) + self.evidence.write_text('not a directory') + with patch.object(self.m.subprocess, 'run') as child: + with self.assertRaises(OSError): + self.m.run(self.script) + child.assert_not_called() + + def test_failed_custody_creates_no_child_evidence(self): + with patch.object(self.m, 'tree_failures', return_value=['synthetic custody refusal']), patch.object(self.m.subprocess, 'run') as child: + self.assertEqual(self.m.main(), 1) + child.assert_not_called() + self.assertFalse(self.evidence.exists()) + + def test_workflow_wires_tests_and_capture_outside_source_tree(self): + text = (ROOT / '.github/workflows/lifetime-cj-model-j.yml').read_text() + self.assertIn("'tests/test_lifetime_cj_model_j_replay_evidence.py'", text) + self.assertIn('-p test_lifetime_cj_model_j_replay_evidence.py', text) + self.assertIn('QS_REPLAY_EVIDENCE_DIR="$out/children" python', text) + self.assertIn('cp tests/test_lifetime_cj_model_j_replay_evidence.py "$out/"', text) + self.assertIn('set -euo pipefail', text) + self.assertIn('git diff --exit-code', text) + self.assertIn('contents: read', text) + self.assertIn("python-version: '3.11.16'", text) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_lifetime_cj_model_j_replay_protocol.py b/tests/test_lifetime_cj_model_j_replay_protocol.py new file mode 100644 index 000000000..415de2281 --- /dev/null +++ b/tests/test_lifetime_cj_model_j_replay_protocol.py @@ -0,0 +1,231 @@ +"""Real subprocess controls for QS replay; fixtures are not mathematical evidence.""" +import copy +import hashlib +import importlib.util +import json +from pathlib import Path +import sys +import tempfile +import unittest +from unittest import mock + +ROOT = Path(__file__).resolve().parents[1] +WRAPPER = ROOT / 'frontiers/lifetime_cj_model_j_20261012/replay.py' + + +class ReplayProtocolTests(unittest.TestCase): + def setUp(self): + spec = importlib.util.spec_from_file_location('qs_replay_subject', WRAPPER) + self.m = importlib.util.module_from_spec(spec) + spec.loader.exec_module(self.m) + + @staticmethod + def baseline(): + return dict(object='A3 d>=3 hard-fibre reduction (author-side exact controls)', + counts={'Z1': 2400, 'Z2': 3600, 'Z3': 4800, 'Z4': 1200}, + mutant=None, all_pass=True, failures=[], scientific_effect='NONE') + + def invoke(self, scenario='valid'): + baseline = self.baseline() + mutant = copy.deepcopy(baseline) + mutant.update(mutant='Z2', all_pass=False, failures=["('Z2-gain', 17)"]) + invalid = {'error': 'unknown arguments'} + sha = lambda data: hashlib.sha256(data).hexdigest() + # These synthetic expectations test the real runner/matcher, not the real + # checkers' reference values. The immutable production table is checked below. + expected_mutant = (json.dumps(mutant, sort_keys=True) + '\n').encode() + expected_invalid = (json.dumps(invalid) + '\n').encode() + contracts = { + ('A3/author_controls.py', ('--mutant', 'Z2')): + (1, sha(expected_mutant), sha(b''), 'Z2-gain'), + ('A3/author_controls.py', ('--bogus',)): + (2, sha(expected_invalid), sha(b''), 'unknown arguments'), + } + base_out = (json.dumps(baseline, sort_keys=True) + '\n').encode() + mut_code, inv_code = 1, 2 + base_err = mut_err = inv_err = b'' + if scenario == 'crash': + mut_code = 1; mut_err = b'Traceback: synthetic unrelated RuntimeError\n' + mut_out = b'' + else: + if scenario == 'wrong_reason': mutant['failures'] = ["('Z4', 17)"] + elif scenario == 'extra_reason': mutant['failures'].append("('setup', 3)") + elif scenario == 'wrong_mutant': mutant['mutant'] = 'Z3' + elif scenario == 'wrong_object': mutant['object'] = 'unrelated' + elif scenario == 'wrong_effect': mutant['scientific_effect'] = 'ACCEPT' + elif scenario == 'all_pass': mutant['all_pass'] = True + elif scenario == 'integer_bool': mutant['all_pass'] = 0 + elif scenario == 'empty_failures': mutant['failures'] = [] + elif scenario == 'failures_string': mutant['failures'] = "('Z2-gain', 17)" + elif scenario == 'wrong_counts': mutant['counts']['Z1'] = True + elif scenario == 'missing_counts': del mutant['counts']['Z2'] + elif scenario == 'extra_field': mutant['unexpected'] = 'x' + elif scenario == 'bad_tuple': mutant['failures'] = ['not a failure tuple'] + elif scenario == 'tuple_prefix_only': mutant['failures'] = ["('Z2-gain-forged', 17)"] + mut_out = (json.dumps(mutant, sort_keys=True) + '\n').encode() + if scenario == 'garbage': mut_out = b'unrelated error\n' + elif scenario == 'trailing': mut_out += b'garbage\n' + elif scenario == 'duplicate': mut_out = mut_out.replace(b'"all_pass": false', b'"all_pass": false, "all_pass": false') + elif scenario == 'nonfinite': mut_out = mut_out.replace(b'"Z1": 2400', b'"Z1": NaN') + elif scenario == 'overflow': mut_out = mut_out.replace(b'"Z1": 2400', b'"Z1": 1e999') + elif scenario == 'wrong_exit': mut_code = 2 + elif scenario == 'mutant_stderr': mut_err = b'synthetic unexpected stderr\n' + inv_out = (json.dumps(invalid) + '\n').encode() + if scenario == 'invalid_crash': inv_out = b''; inv_err = b'Traceback: synthetic error\n' + elif scenario == 'invalid_wrong_reason': inv_out = b'{"error":"unrelated"}\n' + elif scenario == 'invalid_extra_field': inv_out = b'{"error":"unknown arguments","extra":1}\n' + elif scenario == 'invalid_wrong_exit': inv_code = 1 + elif scenario == 'invalid_stderr': inv_err = b'unexpected stderr\n' + if scenario == 'baseline_stderr': base_err = b'unexpected stderr\n' + actual_base = base_out if scenario != 'baseline_mismatch' else b'wrong\n' + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp); (root/'A3').mkdir() + script = root/'A3/author_controls.py' + # Every invocation launches this real isolated child; no subprocess mock. + script.write_text('import sys\na=sys.argv[1:]\n' + f'if not a: out,err,code={actual_base!r},{base_err!r},0\n' + f'elif a==["--mutant","Z2"]: out,err,code={mut_out!r},{mut_err!r},{mut_code}\n' + f'else: out,err,code={inv_out!r},{inv_err!r},{inv_code}\n' + 'sys.stdout.buffer.write(out)\nsys.stderr.buffer.write(err)\nsys.exit(code)\n') + (root/'A3/author_controls_stdout.json').write_bytes(base_out) + manifest = {'objects': [{'tag': 'A3', 'replays': [{ + 'name': 'a3d_exact.py', 'script': 'A3/author_controls.py', + 'stdout': 'A3/author_controls_stdout.json', 'args': [], + 'mutants': [['--mutant','Z2']], 'invalid': [['--bogus']]}]}]} + with mock.patch.object(self.m, 'REJECTION_CONTRACTS', contracts, create=True): + return self.m.replay_failures(root, manifest) + + def test_valid_protocol(self): + self.assertEqual(self.invoke(), []) + + def test_baseline_output_contract(self): + for scenario in ('baseline_mismatch', 'baseline_stderr'): + with self.subTest(scenario=scenario): self.assertTrue(self.invoke(scenario)) + + def test_crash_is_not_intended_rejection(self): + self.assertTrue(self.invoke('crash')) + + def test_intended_reason_and_identity(self): + for scenario in ('wrong_reason','extra_reason','wrong_mutant','wrong_object','wrong_effect', + 'empty_failures','failures_string','bad_tuple','tuple_prefix_only'): + with self.subTest(scenario=scenario): self.assertTrue(self.invoke(scenario)) + + def test_json_shape_and_types(self): + for scenario in ('all_pass','integer_bool','wrong_counts','missing_counts','extra_field', + 'garbage','trailing','duplicate','nonfinite','overflow'): + with self.subTest(scenario=scenario): self.assertTrue(self.invoke(scenario)) + + def test_mutant_exit_and_stderr(self): + for scenario in ('wrong_exit','mutant_stderr'): + with self.subTest(scenario=scenario): self.assertTrue(self.invoke(scenario)) + + def test_invalid_argument_contract(self): + for scenario in ('invalid_crash','invalid_wrong_reason','invalid_extra_field', + 'invalid_wrong_exit','invalid_stderr'): + with self.subTest(scenario=scenario): self.assertTrue(self.invoke(scenario)) + + def test_changed_constant_crash_is_rejected(self): + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp); (root/'CJ').mkdir() + proof = b'x'*150 + (root/'CJ/PROOF.md').write_bytes(proof) + script = ('from fractions import Fraction as Fr\nMUT=None\n' + 'def q(x): return x\n' + 'NEG_IQ_LO, D_UP = q(Fr(6104056, 10 ** 7)), q(Fr(438822, 10 ** 6))\n' + 'if D_UP==Fr(338822, 10 ** 6): raise RuntimeError("synthetic crash")\n' + 'print("ok")\n') + (root/'CJ/author_controls.py').write_text(script) + (root/'CJ/author_controls_stdout.json').write_bytes(b'ok\n') + manifest = {'objects': [{'tag':'CJ','replays':[], 'stored':[ + {'path':'CJ/PROOF.md','bytes':len(proof),'sha256':hashlib.sha256(proof).hexdigest()}]}]} + self.assertTrue(self.m.negative_control_failures(root, manifest)) + + +class ReferenceContractTests(unittest.TestCase): + def setUp(self): + spec = importlib.util.spec_from_file_location('qs_reference_subject', WRAPPER) + self.m = importlib.util.module_from_spec(spec) + spec.loader.exec_module(self.m) + + def matcher(self): + self.assertTrue(hasattr(self.m, 'check_rejection'), 'missing exact diagnostic matcher') + return self.m.check_rejection + + def test_fixed_table_covers_every_manifest_invocation(self): + self.assertTrue(hasattr(self.m, 'REJECTION_CONTRACTS'), 'missing frozen reference table') + manifest = json.loads(WRAPPER.with_name('SOURCES.json').read_text()) + listed = {} + for obj in manifest['objects']: + for replay in obj['replays']: + for category, code in (('mutants', 1), ('invalid', 2)): + for args in replay[category]: + key = replay['script'], tuple(args) + self.assertNotIn(key, listed) + listed[key] = code + self.assertEqual(len(listed), 19) # CJ 14 mutants + 5 invalid + self.assertEqual(set(self.m.REJECTION_CONTRACTS), set(listed)) + for key, value in self.m.REJECTION_CONTRACTS.items(): + self.assertEqual(len(value), 4) + self.assertEqual(value[0], listed[key]) + for digest in value[1:3]: self.assertRegex(digest, r'^[0-9a-f]{64}$') + self.assertIsInstance(value[3], str) + self.assertTrue(value[3]) + + def test_exact_matcher_preserves_five_diagnostic_families(self): + check = self.matcher() + # Representative valid shapes. Full exact values come from unchanged sources, + # not a permissive JSON/regex schema or the current child's reported result. + shapes = [ + (1, b'{"all_pass":false,"mutant":"Z2","failures":["Z2-gain"]}\n', b''), + (1, b'', b'{"failed":"K1 BD(a) violated"}\n'), + (1, b'{"passed":false}\n', b'FAILED:\nO2: pin Hessians\n'), + (1, b'{"passed":false}\n', b'FAILED:\nF2_FW1: ratio 2\n'), + (1, b'', b'FAILED: X9_hardgap\nmutant M5: hard-gap integral\n'), + (2, b'{"error": "unknown arguments"}\n', b''), + (2, b'', b'usage: a33_k5o.py PATH/a33_exact.py [--mutant W1|W2]\n'), + ] + for code, out, err in shapes: + expected = (code, hashlib.sha256(out).hexdigest(), hashlib.sha256(err).hexdigest(), 'synthetic intended reason') + with self.subTest(code=code, out=out, err=err): + self.assertEqual(check((code, out, err), expected), []) + for bad in ((0, out, err), (code, out+b'x', err), (code, out, err+b'x'), + (code, err, out), (code, b'', b'Traceback: unrelated error')): + if bad == (code,out,err): continue + self.assertTrue(check(bad, expected)) + + def test_table_cannot_omit_or_duplicate_manifest_controls(self): + self.assertTrue(hasattr(self.m, 'REJECTION_CONTRACTS'), 'missing inventory guard') + manifest = json.loads(WRAPPER.with_name('SOURCES.json').read_text()) + obj = manifest['objects'][0] + for variant in ('missing', 'duplicate', 'unlisted'): + bad = copy.deepcopy(manifest) + args = bad['objects'][0]['replays'][0]['mutants'] + if variant == 'missing': args.pop() + elif variant == 'duplicate': args.append(args[0]) + else: args.append(['--mutant', 'unlisted']) + with self.subTest(variant=variant), mock.patch.object(self.m, 'run', side_effect=AssertionError('child before inventory')): + self.assertTrue(self.m.replay_failures(WRAPPER.parent, bad)) + + def test_invalid_custody_never_executes_a_child(self): + with tempfile.TemporaryDirectory() as tmp: + root = Path(tmp) + (root/'SOURCES.json').write_text('{"objects":[]}') + with mock.patch.object(self.m, 'HERE', root), \ + mock.patch.object(self.m, 'replay_failures', side_effect=AssertionError('execution before custody')), \ + mock.patch.object(self.m, 'negative_control_failures', side_effect=AssertionError('control before custody')): + self.assertEqual(self.m.main(), 1) + + def test_workflow_runs_regressions_and_retains_failed_evidence(self): + text = (ROOT/'.github/workflows/lifetime-cj-model-j.yml').read_text() + self.assertIn("'tests/test_lifetime_cj_model_j_replay_protocol.py'", text) + self.assertIn('-m unittest discover -s tests -p test_lifetime_cj_model_j_replay_protocol.py -v', text) + self.assertIn('set -euo pipefail', text) + self.assertIn('if: always()', text) + self.assertIn('if-no-files-found: error', text) + self.assertIn('git diff --exit-code', text) + self.assertIn('git status --porcelain', text) + self.assertNotIn('continue-on-error', text) + + +if __name__ == '__main__': + unittest.main()