diff --git a/.github/workflows/side24-d2-certified.yml b/.github/workflows/side24-d2-certified.yml new file mode 100644 index 000000000..9b6e58ded --- /dev/null +++ b/.github/workflows/side24-d2-certified.yml @@ -0,0 +1,92 @@ +name: SIDE24 d=2 certified small-L coefficients (outward interval replay) + +'on': + pull_request: + paths: + - 'reviews/side24_d2_certified_small_L_claude_20261005/**' + - '.github/workflows/side24-d2-certified.yml' + - 'coefficients/side24_v1/coefficient.py' + - 'coefficients/side24_v1/ENCLOSURE.json' + - 'reviews/iba1_periodic_jet_claude_20261005/RESULTS.json' + workflow_dispatch: + +permissions: + contents: read + +jobs: + certified-d2-replay: + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + flags: ['-B -S', '-B -O -S'] + name: certified-d2-replay (${{ matrix.flags }}) + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: '3.11.16' + - name: Verify the manifest and main pins, replay the checker, reject the mutants + env: + PYTHONDONTWRITEBYTECODE: '1' + FLAGS: ${{ matrix.flags }} + run: | + set -euo pipefail + python -B -S - <<'PY' + import hashlib, json, os, pathlib, subprocess, sys + root = pathlib.Path('reviews/side24_d2_certified_small_L_claude_20261005').resolve() + meta = json.loads((root / 'SOURCE_FILES.json').read_text()) + present = sorted(p.name for p in root.iterdir()) + if present != sorted([e['path'] for e in meta['files']] + ['SOURCE_FILES.json']): + raise ValueError('packet tree differs from manifest: ' + repr(present)) + def blob(data): + return hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest() + for entry in meta['files'] + meta['pins_on_main']: + path = pathlib.Path(entry['path']) if 'pins' in entry.get('kind', '') else root / entry['path'] + if path.is_symlink(): + raise ValueError('regular file required: ' + entry['path']) + data = path.read_bytes() + if blob(data) != entry['git_blob']: + raise ValueError('git blob mismatch: ' + entry['path']) + if len(data) != entry['bytes'] or hashlib.sha256(data).hexdigest() != entry['sha256']: + raise ValueError('source identity mismatch: ' + entry['path']) + flags = os.environ['FLAGS'].split() + checker = str(root / 'certified_d2.py') + run = subprocess.run([sys.executable] + flags + [checker], capture_output=True, cwd=root) + if run.returncode != 0 or run.stderr != b'' or run.stdout != (root / 'RESULTS.json').read_bytes(): + raise ValueError('replay differs from RESULTS.json (exit %d, stderr %r)' % (run.returncode, run.stderr[:200])) + # A mutant must be rejected by its named check, with a clean JSON diagnostic and no stderr. + # Exit code alone is not enough: a crash also exits 1 (finding AUD-302-MUTANT-REASON-01). + def strict_json(data): + def no_duplicates(pairs): + keys = [k for k, _ in pairs] + if len(keys) != len(set(keys)): + raise ValueError('duplicate key in mutant diagnostic') + return dict(pairs) + return json.loads(data.decode('ascii'), object_pairs_hook=no_duplicates) + expected = {'M1': 'C4_strip_and_error_bound_L4', 'M2': 'C1_reference_equals_side24_closed_form', + 'M3': 'C6_matches_iba1_diagnostic_L4', 'M4': 'C9_coarse_rule_consistent_L4'} + accepted = [] + for label, reason in expected.items(): + m = subprocess.run([sys.executable] + flags + [checker, '--mutant', label], capture_output=True, cwd=root) + if m.returncode != 1 or m.stderr != b'': + raise ValueError('mutant %s: exit %d, stderr %r' % (label, m.returncode, m.stderr[:200])) + try: + diag = strict_json(m.stdout) + except ValueError as exc: + raise ValueError('mutant %s: unreadable diagnostic %r (%s)' % (label, m.stdout[:200], exc)) + if not (isinstance(diag, dict) and set(diag) == {'mutant', 'failed_check'} + and diag['mutant'] == label and diag['failed_check'] == reason): + raise ValueError('mutant %s: wrong diagnostic %r, expected failed_check %s' % (label, m.stdout[:200], reason)) + accepted.append('%s rejected by %s' % (label, reason)) + m = subprocess.run([sys.executable] + flags + [checker, '--mutant', 'M9'], capture_output=True, cwd=root) + if m.returncode != 2 or m.stdout != b'unknown mutant\n' or m.stderr != b'': + raise ValueError('unknown-label control: exit %d, stdout %r, stderr %r' % (m.returncode, m.stdout[:80], m.stderr[:200])) + accepted.append('M9 refused as an unknown label (exit 2)') + print('certified d=2 replay: manifest, pins, replay and mutants PASS') + for line in accepted: + print(' ' + line) + PY diff --git a/reviews/side24_d2_certified_small_L_claude_20261005/NOTE.md b/reviews/side24_d2_certified_small_L_claude_20261005/NOTE.md new file mode 100644 index 000000000..852f7403a --- /dev/null +++ b/reviews/side24_d2_certified_small_L_claude_20261005/NOTE.md @@ -0,0 +1,123 @@ +# Certified `d = 2` coefficients `c_{2,L}` at small periods + +**Object:** `CL-SIDE24-D2-CERTIFIED-SMALL-L-20261005-v1`. +**Author:** Anthropic Claude, Claude Code session `017Mi3hx…`, for Dylan Roy (delegated AI work). +Claim: [main#229 6002718035](https://github.com/d6g8k5htny-coder/main/issues/229#issuecomment-6002718035), item P1. +**Scientific effect NONE.** Additive packet only. No proof, status, register, catalog, PROOF_INDEX, GRAPH or `formal/` change. +Same GitHub account as every lane, so organizational-independence credit is 0. + +## 1. What this supplies + +The second independent audit lists, as remaining work item 4 ([main#259](https://github.com/d6g8k5htny-coder/main/issues/259)): + +> For certified finite-period coefficients: supply interval quadrature and explicit Fourier/image tails with full angular covariance. + +The first audit's item 3 ([main#252](https://github.com/d6g8k5htny-coder/main/issues/252)) asks for the finite-`L` coefficient with directional integration and error control. Before this packet, the small-`L` values in `d = 2` were diagnostics only: [Math-#297](https://github.com/d6g8k5htny-coder/Math-/pull/297), and [main#259 6002327092](https://github.com/d6g8k5htny-coder/main/issues/259#issuecomment-6002327092) for `L = 2`. + +This packet gives **rigorous outward enclosures** of the coefficient (15.2) in `d = 2` for P's SIDE24 family at `L ∈ {24, 8, 2π, 4, 3, 2}`. It also certifies that, in every direction, τ², `det V` and `Σ_{A|V}` are positive. Formula (15.2) itself is imported from P, as in `side24_v1`; this packet does not review it. + +## 2. Reduction to one variable + +Write `K_L(z) = q_L(z_1) q_L(z_2)` with `q_L = θ_L/θ_L(0)` and `θ_L(t) = Σ_n e^{−(t+Ln)²/2}`. +- The spectral law has independent coordinates. One coordinate has raw moments `m2, m4, m6`. +- Its cumulants are `k2 = m2`, `k4 = m4 − 3m2²` and `k6 = m6 − 15 m4 m2 + 30 m2³`. +- Derivative covariances follow the sign rule of `reviews/iba1_periodic_jet_claude_20261005`. In particular, `Cov(f_ab, f_cd) = k2²(⟨a,b⟩⟨c,d⟩ + ⟨a,c⟩⟨b,d⟩ + ⟨a,d⟩⟨b,c⟩) + k4 Σ_i a_i b_i c_i d_i`. + +Take `u = (c, s)` and `w = (−s, c)`, and put `q = c²s²` and `e = cs(c² − s²)`. Then: +- `Σu⁴ = Σw⁴ = 1 − 2q`, `Σu²w² = 2q`, `Σu⁶ = 1 − 3q`; +- `Σu³w = −e`, `Σuw³ = e`, and `e² = q(1 − 4q)`. + +With `V = (f_uu, f_uw)` and `A = f_ww`, put `α = 3k2² + k4 − 2k4 q` and `γ = k2² + 2k4 q`: + +``` +Var V = [[α, −k4 e], [−k4 e, γ]], Cov(A, V) = (γ, k4 e), Var A = α, +det V = αγ − k4² e² = k2²(3k2² + k4) + k4(4k2² + k4) q (linear in q), +Σ_{A|V} = α − (γ³ + (2γ + α) k4² q(1 − 4q)) / det V, +τ² = 6k2³ + 9k2k4(1 − 2q) + (k6 − k4²/k2)(1 − 3q) (linear in q). +``` + +The τ² identity is the `d = 2` case of the formula proved in [Math-#298](https://github.com/d6g8k5htny-coder/Math-/pull/298) and checked against #297's code in main#229 6002226634. With `det G = k2²`: + +``` +Φ(q) = (τ²)^{2/3} Σ_{A|V} / (8π² k2 √det V), +c_{2,L} = Γ(7/6) / (24^{1/3} √π) · ∫_0^{2π} Φ(q(θ)) dθ, q(θ) = (1 − cos 4θ)/8. +``` + +Substituting `φ = 4θ` gives `∫_0^{2π} Φ(q(θ)) dθ = ∫_0^{2π} Φ((1 − cos φ)/8) dφ`. + +The Gaussian reference (`k2 = 1`, `k4 = k6 = 0`) gives `det V = 3`, `Σ_{A|V} = 8/3` and `τ² = 6`. This reproduces `side24_v1`'s closed form `Γ(7/6)(3/2)^{1/3}(4/3)/(2√3 π √π)`, which is check C1. + +## 3. Certified ingredients + +- **Arithmetic.** Every operation uses the outward-rounded rational interval class of `coefficients/side24_v1/coefficient.py` (OpenAI), together with its enclosures of π, log, exp, real roots and Γ(7/6) (analytic Stirling remainder). The checker imports that file only after its git blob matches the pin `c2d3ff33`. +- **Moments, route 1 (image sums).** `θ_L^{(j)}(0) = Σ_n He_j(Ln) e^{−(Ln)²/2}`, truncated at `|n| ≤ n₀` with `L(n₀+1) ≥ 22`. For `y ≥ 10`, `0 < He_j(y) ≤ y^6`. The ratio of consecutive tail terms is verified below 1/2 in interval arithmetic. So each two-sided tail is at most `4·(x^6 e^{−x²/2})`, with `x = L(n₀+1)`. +- **Moments, route 2 (Poisson-dual spectral sum).** By Poisson summation, `P(X = 2πk/L) ∝ e^{−(2πk/L)²/2}`. Truncating with the same tail lemma gives an independent enclosure. Check C3 requires the two routes to intersect for every `L`. +- **Quadrature.** Trefethen–Weideman, *SIAM Rev.* 56 (2014), Thm 3.2: if a `2π`-periodic `u` is analytic with `|u| ≤ M` on `|Im φ| < a`, the `N`-point trapezoid error is at most `4πM/(e^{aN} − 1)`. The strip maps under `q = (1 − cos φ)/8` onto the filled ellipse centred `1/8` with semi-axes `cosh(a)/8` and `sinh(a)/8`. + - **Analyticity.** Φ is analytic there when `Re τ² > 0` and `Re det V > 0`, so that the principal powers and the quotient are analytic. Both are affine in `Re q`, so the two extreme values `(1 ± cosh a)/8` decide it exactly. The strip `a` is the largest admissible dyadic value, halved. + - **Bound M.** `M` bounds `|Φ|` on the boundary ellipse by 128 complex interval boxes. Maximum modulus applies, and conjugate symmetry covers the lower half. + - **Node count.** `N` is chosen so the bound is below `10⁻⁴⁰`. Nodes are `q_j = sin²(πj/N)/4`, enclosed by Taylor series with alternating remainders. +- **Positivity in every direction.** τ² and `det V` are linear in `q`, so their minima over `q ∈ [0, 1/4]` are at the endpoints. `Σ_{A|V}` is enclosed on 64 subintervals, refined until positive. + +## 4. Results + +From `RESULTS.json`. Enclosures are rounded outward to 30 decimals. Every auxiliary number there is also rounded outward: upper bounds (`M`, the quadrature bound) up, lower bounds (directional minima, Gram margins) down, and ratios as two-sided intervals. + +| `L` | `c_{2,L}` enclosure | `c_{2,L}/c_2` | `a`, `N` | lower bound of min τ² over directions | +|---|---|---|---|---| +| ref | `0.073406919306034271030135962957 … 958` | 1 | 1, 128 | 6 | +| 24 | `0.073406919306034271030135962957 … 958` | `1 ± 1e-25` | 1, 128 | 5.9999999 | +| 8 | `0.073406919277779905473535403534 … 535` | `0.99999999961509942354605845` | 1, 128 | 5.9999999 | +| 2π | `0.073405684662965293708694735170 … 171` | `0.99998318083525845730400135` | 1, 128 | 5.9997420 | +| 4 | `0.067568657600538789457649064979 … 980` | `0.92046714722959966550359775` | 1, 128 | 4.5857514 | +| 3 | `0.049879432666614182044489927839 … 840` | `0.67949224866209501388496905` | 1/4, 512 | 0.76518609 | +| 2 | `0.012617593130692105902277303954 … 955` | `0.17188561037535465056755305` | 1/64, 8192 | 1.8255735e-4 | + +- **The `L = 24` enclosure lies inside `side24_v1`'s published interval** `[…427103, …427104]` (check C2). It equals the reference to far below that width, consistent with the measured anisotropy of about `4e-118` (#297). +- **The `L ∈ {8, 2π, 4, 3}` enclosures contain #297's diagnostic values** to within half a unit in their last printed digit (check C6). +- **`L = 2`.** The certified value differs from the 4096-direction diagnostic trapezoid by `1.04e-25`. The branch point of `(τ²)^{2/3}` at `Im φ ≈ 0.0412` predicts that residual for that grid: successive differences there shrink by `e^{0.0412·N_φ}`. +- **Positivity.** τ², `det V` and `Σ_{A|V}` have certified positive minima at every `L`. At `L = 2` the minimum of τ² is `Δ ≈ 1.8256e-4`, attained on the axes. +- **Gram floors** (Astra, main#229 6002455230): `V2 ≥ 9h⁴p₁p₂` and `Δ ≥ 36h⁸p₁p₂/m2` hold at every `L` (check C7). At `L = 2` the `Δ` floor is nearly attained, with a margin of `5.6e-14`. + +## 5. Checks and falsification controls + +`certified_d2.py` prints `RESULTS.json` and exits 0 only if every check passes. + +| Check | Content | +|---|---| +| C1 | The Gaussian reference equals `side24_v1`'s closed-form `c_2`; width `< 1e-30` | +| C2 | `L = 24` lies inside `side24_v1`'s published `d = 2` interval (pinned `ENCLOSURE.json`) | +| C3 | Image-sum and Poisson-dual moment enclosures intersect, at every `L` | +| C4 | Strip analyticity verified and quadrature bound `< 1e-40`, at every `L` | +| C5 | τ², `det V` and `Σ_{A|V}` positive in every direction, at every `L` | +| C6 | Agreement with #297's merged diagnostic values (pinned `RESULTS.json`) at `L ∈ {8, 2π, 4, 3}` | +| C7 | Astra's Gram floors, at every `L` | +| C8 | Relative enclosure width `< 1e-25`, at every `L` | +| C9 | The enclosure from a 4× coarser rule, with its own error bound, intersects the main one | + +Each mutant must fail a check (exit 1); an unknown label exits 2: + +| Mutant | Change | Rejected by | +|---|---|---| +| M1 | strip half-width quadrupled beyond the verified one | C4 at `L = 4` | +| M2 | transverse block not conditioned on `V` | C1 | +| M3 | wrong `det V` slope `4k2²k4 + 2k4²` | C6 at `L = 4` | +| M4 | quadrature error term dropped | C9 at `L = 4` | + +## 6. Limits + +- `d = 2` only. The `d = 3, 4` coefficients need a cone integral over a sphere of directions and are not attempted here. +- Formula (15.2), its prefactor and the conditional-covariance conventions are imported from P and from `side24_v1` and #297. No lifetime theorem, persistence pairing or uniform-in-`L` statement is claimed. +- The rigor rests on the correctness of `side24_v1`'s interval library (an outward rational grid of `10⁻⁸⁰`, with analytic series remainders) and on Python integer arithmetic. No floating point enters any reported bound. +- The anisotropy measures and other invariants beyond those listed are not re-certified. + +## 7. Reproduction + +From the repository root, with Python 3.11 and no third-party packages: + +```sh +python3 -B -S reviews/side24_d2_certified_small_L_claude_20261005/certified_d2.py # about 90 s; prints RESULTS.json +python3 -B -O -S reviews/side24_d2_certified_small_L_claude_20261005/certified_d2.py # byte-identical +python3 -B -S reviews/side24_d2_certified_small_L_claude_20261005/certified_d2.py --mutant M1 # exit 1; likewise M2–M4 +``` + +The workflow `.github/workflows/side24-d2-certified.yml` verifies the manifest and the three pins on `main`, replays both modes byte for byte, and rejects the mutants. diff --git a/reviews/side24_d2_certified_small_L_claude_20261005/RESULTS.json b/reviews/side24_d2_certified_small_L_claude_20261005/RESULTS.json new file mode 100644 index 000000000..30c5467e4 --- /dev/null +++ b/reviews/side24_d2_certified_small_L_claude_20261005/RESULTS.json @@ -0,0 +1,279 @@ +{ + "cases": { + "2": { + "c_2L": { + "lower": "0.012617593130692105902277303954", + "upper": "0.012617593130692105902277303955" + }, + "coarse_rule_nodes": 2048, + "gram_floor_margin_lower": { + "Delta": "5.61995e-14", + "V2": "1.36166e+00" + }, + "k2": { + "lower": "0.1399492996474460544657794", + "upper": "0.1399492996474460544657795" + }, + "k4_over_k2sq": { + "lower": "6.7523028e+01", + "upper": "6.7523029e+01" + }, + "k6_over_k2cu": { + "lower": "3.9457187e+03", + "upper": "3.9457188e+03" + }, + "min_over_directions_lower": { + "S": "3.6972338e-02", + "detV": "2.7052902e-02", + "tau2": "1.8255735e-04" + }, + "modulus_bound_M_upper": "1.301e-01", + "quadrature_error_bound_upper": "4.21e-56", + "ratio_to_reference": { + "lower": "0.1718856103753546505675530", + "upper": "0.1718856103753546505675531" + }, + "strip_half_width_a": "1/64", + "trapezoid_nodes_N": 8192 + }, + "24": { + "c_2L": { + "lower": "0.073406919306034271030135962957", + "upper": "0.073406919306034271030135962958" + }, + "coarse_rule_nodes": 32, + "gram_floor_margin_lower": { + "Delta": "5.99997e+00", + "V2": "1.99844e+00" + }, + "k2": { + "lower": "0.9999999999999999999999999", + "upper": "1.0000000000000000000000001" + }, + "k4_over_k2sq": { + "lower": "-7.8275779e-69", + "upper": "7.8275846e-69" + }, + "k6_over_k2cu": { + "lower": "-1.6927520e-67", + "upper": "1.6927138e-67" + }, + "min_over_directions_lower": { + "S": "2.6666666e+00", + "detV": "2.9999999e+00", + "tau2": "5.9999999e+00" + }, + "modulus_bound_M_upper": "8.049e-02", + "quadrature_error_bound_upper": "2.61e-56", + "ratio_to_reference": { + "lower": "0.9999999999999999999999999", + "upper": "1.0000000000000000000000001" + }, + "strip_half_width_a": "1", + "trapezoid_nodes_N": 128 + }, + "2pi": { + "c_2L": { + "lower": "0.073405684662965293708694735170", + "upper": "0.073405684662965293708694735171" + }, + "coarse_rule_nodes": 32, + "gram_floor_margin_lower": { + "Delta": "4.11849e+00", + "V2": "1.52969e+00" + }, + "k2": { + "lower": "0.9999997887677280831117230", + "upper": "0.9999997887677280831117231" + }, + "k4_over_k2sq": { + "lower": "8.3391192e-06", + "upper": "8.3391193e-06" + }, + "k6_over_k2cu": { + "lower": "-3.2921528e-04", + "upper": "-3.2921527e-04" + }, + "min_over_directions_lower": { + "S": "2.6666673e+00", + "detV": "3.0000058e+00", + "tau2": "5.9997420e+00" + }, + "modulus_bound_M_upper": "8.049e-02", + "quadrature_error_bound_upper": "2.61e-56", + "ratio_to_reference": { + "lower": "0.9999831808352584573040013", + "upper": "0.9999831808352584573040014" + }, + "strip_half_width_a": "1", + "trapezoid_nodes_N": 128 + }, + "3": { + "c_2L": { + "lower": "0.049879432666614182044489927839", + "upper": "0.049879432666614182044489927840" + }, + "coarse_rule_nodes": 128, + "gram_floor_margin_lower": { + "Delta": "2.11902e-04", + "V2": "2.93185e+00" + }, + "k2": { + "lower": "0.8043831847582616279147440", + "upper": "0.8043831847582616279147441" + }, + "k4_over_k2sq": { + "lower": "2.5435862e+00", + "upper": "2.5435863e+00" + }, + "k6_over_k2cu": { + "lower": "-2.0952240e+01", + "upper": "-2.0952239e+01" + }, + "min_over_directions_lower": { + "S": "1.9620040e+00", + "detV": "2.3208268e+00", + "tau2": "7.6518609e-01" + }, + "modulus_bound_M_upper": "8.671e-02", + "quadrature_error_bound_upper": "2.81e-56", + "ratio_to_reference": { + "lower": "0.6794922486620950138849690", + "upper": "0.6794922486620950138849691" + }, + "strip_half_width_a": "1/4", + "trapezoid_nodes_N": 512 + }, + "4": { + "c_2L": { + "lower": "0.067568657600538789457649064979", + "upper": "0.067568657600538789457649064980" + }, + "coarse_rule_nodes": 32, + "gram_floor_margin_lower": { + "Delta": "1.54399e-01", + "V2": "1.94859e+00" + }, + "k2": { + "lower": "0.9892723933277496349347860", + "upper": "0.9892723933277496349347861" + }, + "k4_over_k2sq": { + "lower": "1.7503166e-01", + "upper": "1.7503167e-01" + }, + "k6_over_k2cu": { + "lower": "-2.8080911e+00", + "upper": "-2.8080910e+00" + }, + "min_over_directions_lower": { + "S": "2.6462438e+00", + "detV": "3.0409663e+00", + "tau2": "4.5857514e+00" + }, + "modulus_bound_M_upper": "8.138e-02", + "quadrature_error_bound_upper": "2.64e-56", + "ratio_to_reference": { + "lower": "0.9204671472295996655035977", + "upper": "0.9204671472295996655035978" + }, + "strip_half_width_a": "1", + "trapezoid_nodes_N": 128 + }, + "8": { + "c_2L": { + "lower": "0.073406919277779905473535403534", + "upper": "0.073406919277779905473535403535" + }, + "coarse_rule_nodes": 32, + "gram_floor_margin_lower": { + "Delta": "5.56213e+00", + "V2": "1.71230e+00" + }, + "k2": { + "lower": "0.9999999999983789868097159", + "upper": "0.9999999999983789868097160" + }, + "k4_over_k2sq": { + "lower": "1.0374484e-10", + "upper": "1.0374485e-10" + }, + "k6_over_k2cu": { + "lower": "-6.6396701e-09", + "upper": "-6.6396700e-09" + }, + "min_over_directions_lower": { + "S": "2.6666666e+00", + "detV": "3.0000000e+00", + "tau2": "5.9999999e+00" + }, + "modulus_bound_M_upper": "8.049e-02", + "quadrature_error_bound_upper": "2.61e-56", + "ratio_to_reference": { + "lower": "0.9999999996150994235460584", + "upper": "0.9999999996150994235460585" + }, + "strip_half_width_a": "1", + "trapezoid_nodes_N": 128 + } + }, + "checks": { + "C1_reference_equals_side24_closed_form": true, + "C2_L24_inside_side24_interval": true, + "C3_moment_routes_agree_L2": true, + "C3_moment_routes_agree_L24": true, + "C3_moment_routes_agree_L2pi": true, + "C3_moment_routes_agree_L3": true, + "C3_moment_routes_agree_L4": true, + "C3_moment_routes_agree_L8": true, + "C4_strip_and_error_bound_L2": true, + "C4_strip_and_error_bound_L24": true, + "C4_strip_and_error_bound_L2pi": true, + "C4_strip_and_error_bound_L3": true, + "C4_strip_and_error_bound_L4": true, + "C4_strip_and_error_bound_L8": true, + "C5_positive_every_direction_L2": true, + "C5_positive_every_direction_L24": true, + "C5_positive_every_direction_L2pi": true, + "C5_positive_every_direction_L3": true, + "C5_positive_every_direction_L4": true, + "C5_positive_every_direction_L8": true, + "C6_matches_iba1_diagnostic_L2pi": true, + "C6_matches_iba1_diagnostic_L3": true, + "C6_matches_iba1_diagnostic_L4": true, + "C6_matches_iba1_diagnostic_L8": true, + "C7_gram_floors_L2": true, + "C7_gram_floors_L24": true, + "C7_gram_floors_L2pi": true, + "C7_gram_floors_L3": true, + "C7_gram_floors_L4": true, + "C7_gram_floors_L8": true, + "C8_width_L2": true, + "C8_width_L24": true, + "C8_width_L2pi": true, + "C8_width_L3": true, + "C8_width_L4": true, + "C8_width_L8": true, + "C9_coarse_rule_consistent_L2": true, + "C9_coarse_rule_consistent_L24": true, + "C9_coarse_rule_consistent_L2pi": true, + "C9_coarse_rule_consistent_L3": true, + "C9_coarse_rule_consistent_L4": true, + "C9_coarse_rule_consistent_L8": true + }, + "method": "outward rational intervals (side24_v1 library); image and Poisson-dual moment sums with explicit tails; trapezoid rule in phi = 4 theta with the analytic-strip bound", + "object": "CL-SIDE24-D2-CERTIFIED-SMALL-L-20261005-v1", + "passed": true, + "reference": { + "N": 128, + "c_2": { + "lower": "0.073406919306034271030135962957", + "upper": "0.073406919306034271030135962958" + }, + "side24_v1_closed_form": { + "lower": "0.073406919306034271030135962957", + "upper": "0.073406919306034271030135962958" + } + }, + "scientific_effect": "NONE" +} diff --git a/reviews/side24_d2_certified_small_L_claude_20261005/SOURCE_FILES.json b/reviews/side24_d2_certified_small_L_claude_20261005/SOURCE_FILES.json new file mode 100644 index 000000000..b00307c83 --- /dev/null +++ b/reviews/side24_d2_certified_small_L_claude_20261005/SOURCE_FILES.json @@ -0,0 +1,51 @@ +{ + "base": "main 54ebced", + "files": [ + { + "bytes": 10164, + "git_blob": "852f7403a8a06a1ef061e363df9502ae16f7a341", + "path": "NOTE.md", + "sha256": "407828facb8dde26a036a08a5b3978eb74d6d8a508c68e2758c291e16e911588" + }, + { + "bytes": 7624, + "git_blob": "30c5467e42d32f455b64c01331abec67a18e3ac7", + "path": "RESULTS.json", + "sha256": "bb3b272d398f77f36ab5cefeb0b394b82032adba65e6355129546c9c282f7d70" + }, + { + "bytes": 18917, + "git_blob": "6fd5b751cc4157136ae92225838c12d33dc997f3", + "path": "certified_d2.py", + "sha256": "92c7fc0939495f287d36fb21db976d1800e6d78dc9e63ae9b5b8533931960e01" + } + ], + "object": "CL-SIDE24-D2-CERTIFIED-SMALL-L-20261005-v1", + "pins_on_main": [ + { + "bytes": 8073, + "git_blob": "c2d3ff339f2b9953ec08e676240cdc5edcb17a3e", + "kind": "pins_on_main", + "path": "coefficients/side24_v1/coefficient.py", + "sha256": "03ae6d0f15160cb681f9bbb19a84dc861c3a0db3e881291ea621061cc90c86ab", + "used_for": "interval library, pi/log/exp/root/Gamma(7/6) enclosures and the reference closed form (imported after blob check)" + }, + { + "bytes": 1090, + "git_blob": "57af39a05e14ed0ba8ebc00a9b4aca4dffb067c7", + "kind": "pins_on_main", + "path": "coefficients/side24_v1/ENCLOSURE.json", + "sha256": "72b6cd92d31394cdaf5da8919a5d548e902228af1f095cc184158a71d8287811", + "used_for": "published d = 2 interval for check C2" + }, + { + "bytes": 5253, + "git_blob": "c1e5849cb198c1dbd965cc04806642800ec5a012", + "kind": "pins_on_main", + "path": "reviews/iba1_periodic_jet_claude_20261005/RESULTS.json", + "sha256": "4dbf00f768486dbd3079463699b62ca461d4bf94ead398ce19671769467124f5", + "used_for": "merged diagnostic values for check C6" + } + ], + "scientific_effect": "NONE" +} diff --git a/reviews/side24_d2_certified_small_L_claude_20261005/certified_d2.py b/reviews/side24_d2_certified_small_L_claude_20261005/certified_d2.py new file mode 100644 index 000000000..6fd5b751c --- /dev/null +++ b/reviews/side24_d2_certified_small_L_claude_20261005/certified_d2.py @@ -0,0 +1,510 @@ +"""Certified d = 2 coefficient c_{2,L} of (15.2) for the SIDE24 family at small periods L. + +Main issue 252 item 3 and main issue 259 remaining work, item 4: interval quadrature with full angular +covariance and explicit image tails. Standard library only. Every reported bound is an outward +rational enclosure built with the interval class, pi, log, exp, root and Gamma(7/6) enclosures of +coefficients/side24_v1/coefficient.py, imported only after its git blob matches the pin below. + +Field. K_L(z) = q_L(z_1) q_L(z_2), q_L = theta_L / theta_L(0), theta_L(t) = sum_n exp(-(t + L n)^2 / 2). +The spectral law has independent coordinates; one coordinate has raw moments m2, m4, m6 and cumulants +k2 = m2, k4 = m4 - 3 m2^2, k6 = m6 - 15 m4 m2 + 30 m2^3. + +Reduction. For u = (cos t, sin t) put q = cos^2 t sin^2 t = (1 - cos 4t) / 8. With the conventions of +reviews/iba1_periodic_jet_claude_20261005 (V = (f_uu, f_uw), A = f_ww): + tau^2 = 6 k2^3 + 9 k2 k4 (1 - 2q) + (k6 - k4^2/k2)(1 - 3q) (linear in q) + det V = k2^2 (3 k2^2 + k4) + k4 (4 k2^2 + k4) q (linear in q) + S = alpha - (gamma^3 + (2 gamma + alpha) k4^2 q (1 - 4q)) / det V, alpha = 3k2^2 + k4 - 2 k4 q, + gamma = k2^2 + 2 k4 q + Phi(q) = (tau^2)^(2/3) S / (8 pi^2 k2 sqrt(det V)) +and c_{2,L} = Gamma(7/6) / (24^(1/3) sqrt(pi)) * int_0^{2 pi} Phi((1 - cos phi) / 8) d phi. + +Quadrature. Trapezoid rule with N nodes in phi. If Phi is analytic on the image of the strip +|Im phi| <= a, i.e. on the filled ellipse centred 1/8 with semi-axes cosh(a)/8 and sinh(a)/8, and +|Phi| <= M there, then |error| <= 4 pi M / (e^{aN} - 1) (Trefethen and Weideman, SIAM Review 56 (2014), +Theorem 3.2). Analyticity holds when Re tau^2 > 0 and Re det V > 0 on the ellipse; both are affine in +Re q, so the two extreme values of Re q decide it. M is bounded on the boundary ellipse by complex +interval boxes (maximum modulus). + +Usage: python3 -B -S certified_d2.py [--mutant M1|M2|M3|M4] +A normal run prints RESULTS.json and exits 0. Each mutant must make a check fail (exit 1): + M1 strip half-width quadrupled beyond the verified one (the strip check fails, first at L = 4); + M2 transverse block not conditioned on V (S = alpha); + M3 wrong det V slope (4 k2^2 k4 + 2 k4^2); + M4 quadrature error term dropped. +An unknown mutant label exits 2. +""" +import hashlib +import importlib.util +import json +import os +import sys +from fractions import Fraction as Q + +HERE = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.normpath(os.path.join(HERE, '..', '..')) +SIDE24 = os.path.join(ROOT, 'coefficients', 'side24_v1', 'coefficient.py') +SIDE24_BLOB = 'c2d3ff339f2b9953ec08e676240cdc5edcb17a3e' +MUTANT = None + + +def git_blob(path): + data = open(path, 'rb').read() + return hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest() + + +def load_side24(): + if git_blob(SIDE24) != SIDE24_BLOB: + raise SystemExit('side24_v1/coefficient.py does not match the pinned blob') + spec = importlib.util.spec_from_file_location('side24_coefficient', SIDE24) + mod = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = mod + spec.loader.exec_module(mod) + return mod + + +S24 = load_side24() +I, root, PI = S24.I, S24.root, S24.pi_interval() +exp_interval, exp_point = S24.exp_interval, S24.exp_point + + +def hull(a, b): + return I(min(a.lo, b.lo), max(a.hi, b.hi)) + + +def sym(t): + return I(-t, t) + + +# ---------------------------------------------------------------- sin and cos on [0, pi + 1/10] + +def _series(x, start, terms=60): + """sum_k (-1)^k x^(2k+start) / (2k+start)! with the alternating-series remainder (|x| <= 4).""" + if not (x.lo >= 0 and x.hi <= 4): + raise ValueError('series argument out of range') + x2 = x * x + term = I(1) if start == 0 else x + total = term + for k in range(1, terms): + term = -(term * x2) / ((2 * k + start - 1) * (2 * k + start)) + total = total + term + rem = Q(4) ** (2 * terms + start) / Q(_fact(2 * terms + start)) + return total + sym(rem) + + +def _fact(n): + out = 1 + for j in range(2, n + 1): + out *= j + return out + + +def sin_point(x): + return _series(x, 1) + + +def cos_point(x): + return _series(x, 0) + + +# ---------------------------------------------------------------- spectral moments, two routes + +def hermite_even(j, y): + if j == 0: + return I(1) + y2 = y * y + if j == 2: + return y2 - 1 + if j == 4: + return y2 * y2 - 6 * y2 + 3 + if j == 6: + return y2 * y2 * y2 - 15 * y2 * y2 + 45 * y2 - 15 + raise ValueError(j) + + +def gaussian_tail(x, step, j): + """Bound on sum_{n >= 0} (x + n step)^j exp(-(x + n step)^2 / 2), for x >= 10 and x * step >= 2.""" + if not (x.lo >= 10 and (x * step).lo >= 2): + raise ArithmeticError('tail hypotheses fail') + # Ratio of consecutive terms: (1 + step/x)^j exp(-x step - step^2/2) <= (6/5)^6 e^(-2) < 1/2 once + # step / x <= 1/5; for larger step / x use the cruder (1 + step/x)^j <= exp(j step / x) <= exp(j step / 10). + ratio = (1 + step / x) ** j * exp_interval(-(x * step) - step * step / 2) + if not ratio.hi < Q(1, 2): + raise ArithmeticError('tail ratio is not below 1/2') + first = x ** j * exp_interval(-(x * x) / 2) + return 2 * first.hi + + +def moments_image(L): + """Raw moments (m2, m4, m6) from the image sums theta_L^(j)(0) with an explicit tail.""" + n = 1 + while (L * (n + 1)).lo < 22: + n += 1 + x = L * (n + 1) + th = {} + for j in (0, 2, 4, 6): + s = hermite_even(j, I(0)) + for m in range(1, n + 1): + y = L * m + s = s + 2 * hermite_even(j, y) * exp_interval(-(y * y) / 2) + # |He_j(y)| <= y^j for y >= 10, both tails. + s = s + sym(2 * gaussian_tail(x, L, 6)) + th[j] = s + q2, q4, q6 = th[2] / th[0], th[4] / th[0], th[6] / th[0] + return -q2, q4, -q6 + + +def moments_dual(L): + """The same moments from the Poisson-dual spectral sum: P(X = 2 pi k / L) is proportional to + exp(-(2 pi k / L)^2 / 2). An independent route to the inputs.""" + h = 2 * PI / L + n = 1 + while (h * (n + 1)).lo < 22 or (h * (n + 1) * h).lo < 2: + n += 1 + x = h * (n + 1) + tail = 2 * gaussian_tail(x, h, 6) + w = {j: I(1) if j == 0 else I(0) for j in (0, 2, 4, 6)} + for k in range(1, n + 1): + om = h * k + e = 2 * exp_interval(-(om * om) / 2) + om2 = om * om + w[0] = w[0] + e + w[2] = w[2] + om2 * e + w[4] = w[4] + om2 * om2 * e + w[6] = w[6] + om2 * om2 * om2 * e + for j in (0, 2, 4, 6): + w[j] = w[j] + I(0, tail) + return w[2] / w[0], w[4] / w[0], w[6] / w[0], (h, 2 * exp_interval(-(h * h) / 2) / w[0], + 2 * exp_interval(-(4 * h * h) / 2) / w[0]) + + +def cumulants(m2, m4, m6): + return m2, m4 - 3 * m2 * m2, m6 - 15 * m4 * m2 + 30 * m2 * m2 * m2 + + +# ---------------------------------------------------------------- the integrand + +def coeffs(k): + """Real coefficients of the affine maps tau^2(q) = t0 - t1 q and det V(q) = d0 + d1 q.""" + k2, k4, k6 = k + bc = k6 - k4 * k4 / k2 + t0 = 6 * k2 * k2 * k2 + 9 * k2 * k4 + bc + t1 = 18 * k2 * k4 + 3 * bc + d0 = k2 * k2 * (3 * k2 * k2 + k4) + d1 = k4 * (4 * k2 * k2 + k4) + if MUTANT == 'M3': + d1 = k4 * (4 * k2 * k2 + 2 * k4) + return t0, t1, d0, d1 + + +def phi_real(q, k, cf): + k2, k4, _ = k + t0, t1, d0, d1 = cf + tau2 = t0 - t1 * q + detv = d0 + d1 * q + alpha = 3 * k2 * k2 + k4 - 2 * k4 * q + gamma = k2 * k2 + 2 * k4 * q + S = alpha - (gamma * gamma * gamma + (2 * gamma + alpha) * k4 * k4 * q * (1 - 4 * q)) / detv + if MUTANT == 'M2': + S = alpha + return root(tau2 * tau2, 3) * S / (8 * PI * PI * k2 * root(detv, 2)), (tau2, detv, S) + + +class C: + """Rectangular complex interval.""" + + def __init__(self, re, im=None): + self.re = re if isinstance(re, I) else I(re) + self.im = I(0) if im is None else (im if isinstance(im, I) else I(im)) + + def __add__(self, o): + o = o if isinstance(o, C) else C(o) + return C(self.re + o.re, self.im + o.im) + + __radd__ = __add__ + + def __sub__(self, o): + o = o if isinstance(o, C) else C(o) + return C(self.re - o.re, self.im - o.im) + + def __rsub__(self, o): + return C(o) - self + + def __mul__(self, o): + o = o if isinstance(o, C) else C(o) + return C(self.re * o.re - self.im * o.im, self.re * o.im + self.im * o.re) + + __rmul__ = __mul__ + + def abs2(self): + return self.re * self.re + self.im * self.im + + def abs_hi(self): + return root(I(0, self.abs2().hi), 2).hi + + def abs_lo(self): + a = self.abs2().lo + return root(I(a), 2).lo if a > 0 else Q(0) + + +def modulus_bound(qc, k, cf): + """Upper bound of |Phi| on the complex box qc (Re tau^2, Re det V > 0 already verified).""" + k2, k4, _ = k + t0, t1, d0, d1 = cf + tau2 = C(t0) - C(t1) * qc + detv = C(d0) + C(d1) * qc + alpha = C(3 * k2 * k2 + k4) - C(2 * k4) * qc + gamma = C(k2 * k2) + C(2 * k4) * qc + num = gamma * gamma * gamma + (2 * gamma + alpha) * C(k4 * k4) * qc * (1 - 4 * qc) + dlo = detv.abs_lo() + if dlo <= 0: + raise ArithmeticError('det V may vanish on the ellipse') + s_hi = alpha.abs_hi() + num.abs_hi() / dlo + if MUTANT == 'M2': + s_hi = alpha.abs_hi() + t_hi = root(I(tau2.abs_hi()), 3).hi ** 2 + return t_hi * s_hi / ((8 * PI * PI * k2).lo * root(I(dlo), 2).lo) + + +def strip_ok(a, cf): + """Re tau^2 > 0 and Re det V > 0 on the filled ellipse for half-width a.""" + t0, t1, d0, d1 = cf + ea = exp_point(Q(a)) + ch = (ea + 1 / ea) / 2 + lo_u, hi_u = (1 - ch) / 8, (1 + ch) / 8 + vals = [t0 - t1 * lo_u, t0 - t1 * hi_u, d0 + d1 * lo_u, d0 + d1 * hi_u] + return min(v.lo for v in vals) + + +def boundary_bound(a, k, cf, boxes=128): + ea = exp_point(Q(a)) + ch, sh = (ea + 1 / ea) / 2, (ea - 1 / ea) / 2 + m = Q(0) + for i in range(boxes): + x = I((PI * i / boxes).lo, (PI * (i + 1) / boxes).hi) + xl, xh = I(x.lo), I(x.hi) + cosx = I(cos_point(xh).lo, cos_point(xl).hi) + if i == boxes - 1: + cosx = I(-1, cosx.hi) + sl, shh = sin_point(xl), sin_point(xh) + sinx = I(min(sl.lo, shh.lo), max(sl.hi, shh.hi)) + if (PI / 2).hi >= x.lo and (PI / 2).lo <= x.hi: + sinx = I(sinx.lo, 1) + qc = C((1 - ch * cosx) / 8, sh * sinx / 8) + m = max(m, modulus_bound(qc, k, cf)) + return m + + +def choose_strip(cf): + a = Q(2) + while strip_ok(a, cf) <= 0: + a /= 2 + if a < Q(1, 2 ** 20): + raise ArithmeticError('no admissible strip') + return a / 2 # keep a margin below the largest admissible dyadic half-width + + +def trapezoid(k, cf, N): + """(2 pi / N) sum_j Phi(q_j) with q_j = sin^2(pi j / N) / 4, by the symmetry q_{N-j} = q_j.""" + total = phi_real(I(0), k, cf)[0] + phi_real(I(Q(1, 4)), k, cf)[0] + for j in range(1, N // 2): + s = sin_point(PI * j / N) + total = total + 2 * phi_real(s * s / 4, k, cf)[0] + return total * 2 * PI / N + + +def quadrature(k, tol=Q(1, 10 ** 40), N_override=None): + cf = coeffs(k) + a = choose_strip(cf) + if strip_ok(a, cf) <= 0: + raise ArithmeticError('strip not verified') + M = boundary_bound(a, k, cf) + a_used = 4 * a if MUTANT == 'M1' else a + if MUTANT == 'M1' and strip_ok(a_used, cf) <= 0: + raise ArithmeticError('M1: strip not admissible') + N = 8 + while True: + err = 4 * PI.hi * M / (exp_point(a_used * N).lo - 1) + if err < tol: + break + N *= 2 + if N_override: + N = N_override + err = 4 * PI.hi * M / (exp_point(a_used * N).lo - 1) + T = trapezoid(k, cf, N) + E = Q(0) if MUTANT == 'M4' else err + return T + sym(E), {'a': a_used, 'N': N, 'M': M, 'error_bound': err} + + +def prefactor(): + return S24.gamma_seven_sixths() / (root(I(24), 3) * root(PI, 2)) + + +def positivity(k, cf, pieces=64): + """Lower bounds of tau^2, det V and S over every direction (q in [0, 1/4]).""" + t0, t1, d0, d1 = cf + out = {'tau2': min((t0 - t1 * Q(0)).lo, (t0 - t1 * Q(1, 4)).lo), + 'detV': min((d0 + d1 * Q(0)).lo, (d0 + d1 * Q(1, 4)).lo)} + smin = None + stack = [(Q(j, 4 * pieces), Q(j + 1, 4 * pieces)) for j in range(pieces)] + while stack: + lo, hi = stack.pop() + S = phi_real(I(lo, hi), k, cf)[1][2] + if S.lo <= 0 and hi - lo > Q(1, 2 ** 30): + mid = (lo + hi) / 2 + stack += [(lo, mid), (mid, hi)] + continue + smin = S.lo if smin is None else min(smin, S.lo) + out['S'] = smin + return out + + +# ---------------------------------------------------------------- checks and report + +ENCLOSURE = os.path.join(ROOT, 'coefficients', 'side24_v1', 'ENCLOSURE.json') +ENCLOSURE_BLOB = '57af39a05e14ed0ba8ebc00a9b4aca4dffb067c7' +JET_RESULTS = os.path.join(ROOT, 'reviews', 'iba1_periodic_jet_claude_20261005', 'RESULTS.json') +JET_RESULTS_BLOB = 'c1e5849cb198c1dbd965cc04806642800ec5a012' +PERIODS = [('4', I(4)), ('3', I(3)), ('24', I(24)), ('8', I(8)), ('2pi', 2 * PI), ('2', I(2))] + + +def pinned_json(path, blob): + if git_blob(path) != blob: + raise SystemExit('pinned file does not match its blob: ' + path) + return json.load(open(path)) + + +def dec(x, digits=30): + return S24.decimals(x, digits) + + +def sci(q, digits, up): + """Exact rational q in scientific notation, rounded toward +infinity (up) or -infinity (down).""" + q = Q(q) + if q == 0: + return '0' + a = abs(q) + e = 0 + while a >= Q(10) ** (e + 1): + e += 1 + while a < Q(10) ** e: + e -= 1 + scaled = q / Q(10) ** (e - digits + 1) + m = -((-scaled.numerator) // scaled.denominator) if up else scaled.numerator // scaled.denominator + if abs(m) >= 10 ** digits: # rounding carried into a new decade + m = -((-m) // 10) if up else m // 10 + e += 1 + sign = '-' if m < 0 else '' + t = str(abs(m)).rjust(digits, '0') + return '%s%s.%se%s%02d' % (sign, t[0], t[1:], '-' if e < 0 else '+', abs(e)) + + +def sci_upper(q, digits=4): + return sci(q, digits, True) + + +def sci_lower(q, digits=4): + return sci(q, digits, False) + + +def sci_interval(x, digits=8): + return {'lower': sci_lower(x.lo, digits), 'upper': sci_upper(x.hi, digits)} + + +def overlap(a, b): + return a.lo <= b.hi and b.lo <= a.hi + + +def half_ulp(text): + """Half a unit in the last printed digit of a value printed like '4.9879432666614182044e-2'.""" + mant, exp = text.split('e') + digits = len(mant.split('.')[1]) + return Q(5, 10 ** (digits + 1)) * Q(10) ** int(exp) + + +def main(): + global MUTANT + if len(sys.argv) == 3 and sys.argv[1] == '--mutant': + if sys.argv[2] not in ('M1', 'M2', 'M3', 'M4'): + print('unknown mutant') + sys.exit(2) + MUTANT = sys.argv[2] + elif len(sys.argv) != 1: + print(__doc__) + sys.exit(2) + + checks = {} + + def check(name, ok): + checks[name] = bool(ok) + if MUTANT and not ok: # a mutant needs only one failing check + print(json.dumps({'mutant': MUTANT, 'failed_check': name})) + sys.exit(1) + + pref = prefactor() + side24_ref = S24.reference_coefficient(2) + published = pinned_json(ENCLOSURE, ENCLOSURE_BLOB)['dimensions']['2'] + jet = pinned_json(JET_RESULTS, JET_RESULTS_BLOB)['c_2_diagnostic_small_L'] + out = {'object': 'CL-SIDE24-D2-CERTIFIED-SMALL-L-20261005-v1', 'scientific_effect': 'NONE', + 'method': 'outward rational intervals (side24_v1 library); image and Poisson-dual moment sums ' + 'with explicit tails; trapezoid rule in phi = 4 theta with the analytic-strip bound', + 'cases': {}} + + # C1: the Gaussian reference reproduces side24_v1's closed-form reference coefficient. + kref = (I(1), I(0), I(0)) + Jref, info = quadrature(kref) + cref = pref * Jref + check('C1_reference_equals_side24_closed_form', overlap(cref, side24_ref) + and cref.hi - cref.lo < Q(1, 10 ** 30)) + out['reference'] = {'c_2': dec(cref), 'side24_v1_closed_form': dec(side24_ref), 'N': info['N']} + + for name, L in PERIODS: + m_img = moments_image(L) + m2d, m4d, m6d, (h, p1, p2) = moments_dual(L) + check('C3_moment_routes_agree_L%s' % name, all(overlap(a, b) for a, b in zip(m_img, (m2d, m4d, m6d)))) + m2, m4, m6 = m_img + k = cumulants(m2, m4, m6) + cf = coeffs(k) + try: + J, info = quadrature(k) + ok = strip_ok(info['a'], cf) > 0 and info['error_bound'] < Q(1, 10 ** 40) + except ArithmeticError: + ok = False + check('C4_strip_and_error_bound_L%s' % name, ok) + if not ok: + out['cases'][name] = {'error': 'strip or error bound not verified'} + continue + c2 = pref * J + check('C8_width_L%s' % name, c2.hi - c2.lo < c2.lo / 10 ** 25) + coarse_N = max(8, info['N'] // 4) + Jc, _ = quadrature(k, N_override=coarse_N) + check('C9_coarse_rule_consistent_L%s' % name, overlap(Jc, J)) + pos = positivity(k, cf) + check('C5_positive_every_direction_L%s' % name, all(v > 0 for v in pos.values())) + # Gram floors (Astra, main#229 6002455230): V2 >= 9 h^4 p1 p2 and Delta >= 36 h^8 p1 p2 / m2. + V2, Dl = m4 - m2 * m2, m6 - m4 * m4 / m2 + fV, fD = 9 * h ** 4 * p1 * p2, 36 * h ** 8 * p1 * p2 / m2 + check('C7_gram_floors_L%s' % name, V2.lo >= fV.hi and Dl.lo >= fD.hi) + if name in jet: + v = jet[name]['N512'] + tol = half_ulp(v) + (c2.hi - c2.lo) + check('C6_matches_iba1_diagnostic_L%s' % name, abs((c2.lo + c2.hi) / 2 - Q(v)) <= tol) + if name == '24': + lo, hi = Q(published['lower']), Q(published['upper']) + check('C2_L24_inside_side24_interval', lo <= c2.lo and c2.hi <= hi) + out['cases'][name] = { + 'c_2L': dec(c2), 'ratio_to_reference': dec(c2 / cref, 25), + 'k2': dec(k[0], 25), 'k4_over_k2sq': sci_interval(k[1] / (k[0] * k[0])), + 'k6_over_k2cu': sci_interval(k[2] / (k[0] * k[0] * k[0])), + 'strip_half_width_a': str(info['a']), 'trapezoid_nodes_N': info['N'], + 'modulus_bound_M_upper': sci_upper(info['M']), 'quadrature_error_bound_upper': sci_upper(info['error_bound'], 3), + 'coarse_rule_nodes': coarse_N, + 'min_over_directions_lower': {key: sci_lower(val, 8) for key, val in sorted(pos.items())}, + 'gram_floor_margin_lower': {'V2': sci_lower(V2.lo - fV.hi, 6), 'Delta': sci_lower(Dl.lo - fD.hi, 6)}} + out['checks'] = {key: val for key, val in sorted(checks.items())} + out['passed'] = all(checks.values()) + print(json.dumps(out, indent=1, sort_keys=True)) + sys.exit(0 if out['passed'] else 1) + + +if __name__ == '__main__': + main()