diff --git a/.github/workflows/c2-torus-transfer.yml b/.github/workflows/c2-torus-transfer.yml new file mode 100644 index 000000000..d755cc241 --- /dev/null +++ b/.github/workflows/c2-torus-transfer.yml @@ -0,0 +1,87 @@ +name: c2 torus transfer (replay) + +'on': + pull_request: + paths: + - 'frontiers/c2_torus_transfer_20261001/**' + - '.github/workflows/c2-torus-transfer.yml' + - 'frontiers/c2_exact_20261001/**' + - 'coefficients/side24_v1/PROOF.md' + - 'frontiers/candidate_third_order_20261001/PROOF.md' + - 'frontiers/cusp_coefficient_certified_20261001/RESULTS.json' + - 'frontiers/elder_third_order_20261001/PROOF.md' + - 'frontiers/cusp_torus_transfer_20261001/PROOF.md' + workflow_dispatch: + +permissions: + contents: read + +jobs: + transfer-replay: + runs-on: ubuntu-latest + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + flags: ['-B -S', '-B -O -S'] + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + persist-credentials: false + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: '3.11.16' + - name: Verify manifest, main-resident pins and byte-identical copies + env: + PYTHONDONTWRITEBYTECODE: '1' + run: | + set -euo pipefail + python -B -S - <<'PY' + import hashlib, json, pathlib + root = pathlib.Path('frontiers/c2_torus_transfer_20261001').resolve() + manifest = json.loads((root / 'SOURCE_FILES.json').read_text())['files'] + present = sorted(p.name for p in root.iterdir()) + if present != sorted([e['path'] for e in manifest] + ['SOURCE_FILES.json']): + raise ValueError('packet tree differs from manifest: ' + repr(present)) + def ident(data): + return len(data), hashlib.sha256(data).hexdigest(), hashlib.sha1(b'blob %d\0' % len(data) + data).hexdigest() + for entry in manifest: + path = root / entry['path'] + if pathlib.PurePosixPath(entry['path']).name != entry['path'] or path.is_symlink(): + raise ValueError('flat regular source required: ' + entry['path']) + if ident(path.read_bytes()) != (entry['bytes'], entry['sha256'], entry['git_blob']): + raise ValueError('source identity mismatch: ' + entry['path']) + pins = json.loads((root / 'SOURCE_MAP.json').read_text()) + for entry in pins['sources']: + if not entry['current_required']: + continue + if ident(pathlib.Path(entry['path']).read_bytes()) != (entry['bytes'], entry['sha256'], entry['git_blob']): + raise ValueError('consumed source identity mismatch on this tree: ' + entry['path']) + for copy, orig in pins['copies'].items(): + if (root / copy).read_bytes() != pathlib.Path(orig).read_bytes(): + raise ValueError('copy differs from its pinned original: ' + copy) + print('manifest, pins and copies verified') + PY + - name: Ball-arithmetic replay against RESULTS.json, mutants, controls + env: + PYTHONDONTWRITEBYTECODE: '1' + FLAGS: ${{ matrix.flags }} + run: | + set -euo pipefail + cd frontiers/c2_torus_transfer_20261001 + pids=() + for m in no-image no-theta drop-ratio eta-half fp-const; do + ( set +e; python $FLAGS transfer.py --mutant "$m" > "/tmp/mutant_$m.log" 2>&1; echo $? > "/tmp/mutant_$m.rc" ) & + pids+=($!) + done + python $FLAGS transfer.py --check + python $FLAGS controls.py + wait "${pids[@]}" + for m in no-image no-theta drop-ratio eta-half fp-const; do + rc=$(cat "/tmp/mutant_$m.rc") + if [ "$rc" -ne 1 ]; then echo "mutant $m not rejected (rc=$rc)"; cat "/tmp/mutant_$m.log"; exit 1; fi + echo "mutant $m rejected" + done + cd "$GITHUB_WORKSPACE" + git diff --exit-code + test -z "$(git status --porcelain)" diff --git a/frontiers/c2_torus_transfer_20261001/NOTE.md b/frontiers/c2_torus_transfer_20261001/NOTE.md new file mode 100644 index 000000000..5ce5bad2a --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/NOTE.md @@ -0,0 +1,312 @@ +# The third-order coefficient `c2` on the finite torus: transfer for every `L >= 10`, `d = 1, 2, 3` + +**Object:** CL-C2-TORUS-TRANSFER-20261001-v1. +**Author:** Anthropic Claude (Claude Code session `session_015wNj8LPTKXsaT68G3DgPPh`), 1 October 2026. Author of the +reference packet `frontiers/c2_exact_20261001` ([C2X]). +**Scope claim:** Math-#223 comment 5934236720. The task was posted in Math-#223 comment 5933574379 (with the finite-part +starting inequality used in Lemma F) and listed as unsupplied in main#229 (5933485698). +**Disposition:** author-side. An explicit bound for every real `L >= L0`, every orthonormal frame and `d = 1, 2, 3` on +the difference between the coefficient `c2` of the normalized periodic Gaussian kernel and its closed-form reference value. +It is certified in exact rational ball arithmetic with the standard library. There is also one structural lemma +(Lemma E) valid for every stationary kernel. +**Scientific effect:** NONE. No `STATUS`, `PROOF_INDEX`, `GRAPH`, claim, catalog, prize or source-body change. Same GitHub +account as every lane; zero organizational-independence credit. Nothing in `frontiers/c2_exact_20261001/` or in +Math-#216, #218, #220 or #224 is touched. +**Delivered under:** Dylan Roy's explicit instructions in this session, given after the 2026-09-27 owner stop (quoted in +`SOURCE_MAP.json`, `delivered_under`). `OWNER_STOP.md` addresses Cursor agents and automations and is untouched. + +## 0. Statement + +**The torus.** This is the field of [SIDE24] (1)–(2) and Math-#224 (T1), for any real side `L` and any `d`: + + K_L(z) = sum_{n in Z^d} phi(z + L n) / sum_{n in Z^d} phi(L n), phi(z) = exp(-|z|^2/2). + +Fix an orthonormal frame with axial vector `u`. The pins sit at `M = -r u/2` and `S = r u/2`. Let `A~_r^{K,u}(b, k)` be the +fixed-cone surrogate of the two-point kernel of [R] §§2–4 for the covariance `K` in this frame, exactly as in [C2X] §1. +Its fold expansion is `A~_r = A_0 + r^2 A_2 + O(r^3)` (§3). Put + + F^u_K(k) = integral_R A_2^{K,u}(b, k) db, + T(F) = f.p. integral_0^oo F(k) k^(-4/3) dk = integral_0^oo [F(k) - F(0)] k^(-4/3) dk, + c2[K, u] = (1/3) |S^(d-1)| T(F^u_K), c2[K] = (1/3) integral_(S^(d-1)) T(F^u_K) d sigma(u). + +`c2[K]` is the expression of Math-#218 (0.1). For `K = phi` it does not depend on `u` and equals the closed form of [C2X] +§0. #218's Theorem T, which identifies this expression as a coefficient of the candidate density, is a candidate +theorem for `d >= 2`. It was merged at `fb6ee97`, which is not a status promotion. In `d = 1` the theorem below is a transfer of the explicitly defined fixed-cone +expression, not an extension of #218's density theorem (review 5383099127, item 3). + +**Theorem C2T.** For `d in {1, 2, 3}`, every `L0` in the table, every real `L >= L0` and every orthonormal frame, + + |c2[K_L, u] - c2[phi]| <= eps_d(L0), hence |c2[K_L] - c2[phi]| <= eps_d(L0), + +with these values (rounded up): + +| `d` | `L >= 10` | `L >= 12` | `L >= 16` | `L >= 24` | +|---|---|---|---|---| +| `1` | `1.41035e-13` | `1.42699e-22` | `5.66439e-46` | `4.09547e-114` | +| `2` | `2.09404e-12` | `2.02307e-21` | `7.57841e-45` | `5.20139e-113` | +| `3` | `1.00039e-10` | `9.20576e-20` | `3.23748e-43` | `2.09418e-111` | + +**Relative to `c2[phi]`** (using the lower endpoints of [C2X]'s enclosures), the error is below: +- `6.2e-13`, `9.5e-12` and `6.3e-10` for `L >= 10`; +- `1.8e-113`, `2.4e-112` and `1.3e-110` for `L >= 24`. + +**Corollary (SIDE24).** [C2X] widened its published enclosures by `1e-14` relative beyond the certified enclosure (§5 +there). That margin is much larger than `eps_d(24) <= 2.1e-111`, so the published intervals contain the torus values as +they stand: +- `c2[K_24] in [0.2215244106266632, 0.2215244106267110]` in `d = 2`; +- `c2[K_24] in [0.1612340491269447, 0.1612340491269810]` in `d = 3`. + +With [SIDE24]'s enclosures of `c_{d,24}`, the interval quotients give +`c2[K_24]/c_{2,24} in [3.017759261945395, 3.017759261946047]` and +`c2[K_24]/c_{3,24} in [3.859496174547459, 3.859496174548329]`. + +**Three-term law, with its sources.** The law is `nu/(c ell^(-1/3)) - 1 = (c1/c) ell^(7/12) + (c2/c) ell^(2/3) + ...`. +On the SIDE24 torus in `d = 3` its coefficients are `-5.071062...` and `3.859496174548...`, to the stated digits. The sources +of each piece are: +- **`c1/c`** comes from [CU] (Math-#219, certified arithmetic, merged at `5a836a8`). It is consumed, not accepted here. +- **Math-#224** plays two separate roles: + - its (T1) defines the torus kernel used throughout; + - its `c1` transfer is merged at `d3a0b6c` (`PROOF.md` blob `de3d85fd`, byte-identical to the consumed head `a5e69ee`); + it is cited as the analogue, and nothing here inherits status from it. +- **The identification as density coefficients** is conditional on the chain in §8. + +**Lemma E (no `r^1` term for every stationary kernel).** Let `K` be any smooth stationary covariance (no isotropy or +evenness needed) whose pin and transverse covariances are nondegenerate at `r = 0`. Then `A~_r(b, k)` is smooth in `r` up +to `r = 0`, and at fixed `v_1 = b - k r^3/2` its Taylor expansion in `r` contains only even powers: for every `N`, +`A~_r(b, k) = sum_{j= 24`). This packet gives sharper +torus-specific constants for every `L >= 10`, together with Lemma E. The two are compatible, and neither supersedes the other. + +## 1. What is consumed, and how the proof runs + +- **[C2X] §§1–2 (main, `f9ebba1`).** The pin rows, the target `v_r`, the fixed-cone surrogate and its exact series derivation. + `exact.py` and `pseries.py` are carried as byte-identical copies, and this packet's pipeline is a re-implementation over balls + that `reference_checks` compares with them identically (§3). +- **[SIDE24] (1)–(2) (main).** The normalized periodic kernel. +- **[T] (Math-#218, merged at `fb6ee97`) (0.1) and Lemma F.** The definition of `c2`, and its identification as the `ell^(1/3)` + coefficient of the candidate density for `d >= 2` (an author-side candidate). Consumed, not reviewed. +- **[CU] (Math-#219, merged at `5a836a8`).** The certified `c1/c` enclosure quoted in §0. Consumed, not accepted. +- **[D] §2.2 (Math-#216, unmerged).** `A_r = A~_r + O(r^3)`; consumed, as in [C2X]. + +**The route.** +1. The jet covariances of `K_L` lie in explicit balls around those of `phi` (Lemma J). +2. The exact derivation of [C2X], run in ball arithmetic, encloses the coefficients of the `A_2`-integrand + `kappa e^(-E(b, k, x)) H(b, k, x)` of `K_L` (Lemma P). +3. The finite part is controlled additively by `Delta(0)`, a weighted integral of `Delta'` and an integral of `|Delta|` + (Lemma F). +4. Each of these is bounded by explicit absolute Gaussian moments (Lemma G). + +There is no multiplicative sandwich: `A_2` is signed, and `c2` is a finite part. + +## 2. Lemma J: the jets of `K_L` + +`Cov(d^a f(0), d^b f(0)) = (-1)^|b| d^(a+b) K(0)` in the frame coordinates. `K_L` is even, so `d^g K_L(0) = 0` exactly when +`|g|` is odd. For even `|g|`, write `delta = sum_(n != 0) phi(. + p_n)` with `p_n = L R n` (`R` the frame rotation) and +`theta_1 = sum_(n != 0) phi(L n)`. Then + + d^g K_L(0) - d^g phi(0) = [d^g delta(0) - theta_1 d^g phi(0)] / (1 + theta_1), + |d^g delta(0)| <= sum_(n != 0) prod_i |He_(g_i)(p_(n,i))| phi(p_n) <= sum_(n != 0) prod_i He*_(g_i)(L |n|) e^(-L^2 |n|^2 / 2). + +Here `d^m e^(-t^2/2) = (-1)^m He_m(t) e^(-t^2/2)`, `He*_m(s) = sum_j m!/(j!(m-2j)! 2^j) s^(m-2j)` majorizes `|He_m|` on +`|t| <= s` and is nondecreasing, and `|p_(n,i)| <= |p_n| = L|n|` in every frame. + +- **Shells `|n|^2 <= 4`** are enumerated exactly; every such `n` has `|n_i| <= 2`. +- **The tail `|n|^2 = s >= 5`** uses `#{n : |n|^2 = s} <= (3 sqrt s)^d` and `He*_m(t) <= (t + m)^m <= (2t)^m` for + `m <= t`, with `|g| <= L sqrt5`. The `s`-th term is at most `3^d (2L)^|g| s^a e^(-L^2 s/2)`, where `a = (d + |g|)/2`. + Consecutive ratios are at most `(6/5)^a e^(-L^2/2) <= 1/2`, so the tail is at most `2 * 3^d (2L)^|g| 5^a e^(-5L^2/2)`. + +**Monotonicity in `L`.** Each shell term has logarithmic `L`-derivative at most `|g|/L - L s <= 0` when `|g| <= L^2`, +because `t He*'(t) <= m He*(t)`. The tail bound and `theta_1` also decrease. So the value at `L0` bounds every `L >= L0`. + +The radius used for `d^g K_L(0)` is the image bound plus `theta_1 |d^g phi(0)|`. The certificate queries jets up to order `20` +and requires `|g|^2 <= 5 L0^2` and `|g| <= L0^2`. At `L0 = 10`, `theta_1 <= 1.16e-21` in `d = 3`. + +## 3. Lemma P: the ball pipeline + +A ball `B(c, rho)` is the rational interval `[c - rho, c + rho]`. +- Sums, products and reciprocals (when `|c| > rho`) are the standard outward rules. +- The radii are rounded up by an outward dyadic ceiling rule (`rup`), with at least 64-bit relative precision. This + affects precision only, not outwardness. +- The operands are integers, Fractions or balls throughout. Float scalars are not certified: `B(1) + 0.1` would round the + center without a radius. The certificate never uses one. Reuse elsewhere should coerce or reject floats (review C49). +- The centers are exact. With all radii zero the arithmetic is exactly [C2X]'s, so the centers of every output are the + reference values. + +`transfer.kernel(d, jetcov)` repeats [C2X] §2 with `pseries.R = 8` (series exact through `r^5`) and polynomials truncated +at `r^4`: +1. the pin covariance `S_r`, its inverse and determinant, by Gauss–Jordan over series of balls; +2. conditioning of the Hessian entries on the pins and then on the **full** transverse block. In `d = 3` that block is + `T = [[x1, x3], [x3, x2]]`, with no rotation reduction, because the torus is not isotropic; +3. `F = E[det H_M det H_S | T, U_r = v_r]` by Isserlis; +4. `(det ratio)^(-1/2) exp(-(dq + dQ)/2) F`. The `r^0` parts of the determinant ratio and of `q`, `Q` are removed + structurally rather than by subtracting equal balls, which would leave spurious radii. + +The output is the integrand `G` (balls), `E = (q_0 + Q_0)/2` (a homogeneous quadratic form in `w = (b, k, x)`), `det S_0` and +`det T_0`. For the surrogate, + + A~_r^{K,u}(b, k) = kappa_K integral_(T < 0) e^(-E) G dx / r^2, kappa_K = -12 (2 pi)^(-(p + n_T)/2) (det S_0 det T_0)^(-1/2), + +and the `A_2`-integrand is `kappa_K e^(-E) H` with `H = [r^4] G`. As in [C2X] §2.3, `A~_r` is real-analytic near +`r = 0`, because `K_L` and `phi` are real-analytic and the `r = 0` covariances are nondegenerate. Every pivot is certified by `|c| > rho`. + +**Reference check (exact).** With zero radii, `kernel` reproduces [C2X]'s `kernel_data` identically: +- the coefficients of `G` through `r^4`, `E` and `det S_0` in `d = 1, 2`; +- in `d = 3`, the same on the slice `x3 = 0`, which is the diagonal slice [C2X] evaluates. + +## 4. Lemma E: evenness in `r` at fixed `v_1` + +Relabel the two points: `r -> -r` sends `M = -r u/2` to `+r u/2` and `S` to `-r u/2`. Every pin row of [R] is invariant under +this relabelling as a linear form in the jets at `0`, because each is symmetric in `(M, S)` together with the sign of `r`. +The rows are `(f(M) + f(S))/2`, `(f(S) - f(M))/r`, `(f_u(S) - f_u(M))/r`, +`6 r^(-2)(f_u(M) + f_u(S) - 2(f(S) - f(M))/r)`, and the transverse pairs. + +The relabelling swaps `H_M` and `H_S`, which leaves `det H_M det H_S` unchanged, and it fixes `T = D_Theta^2 f(0)`. The +target is `v_r = (b - k r^3/2, -k r^2, 0, 12k, 0, ...)`, whose entries other than `v_1 = b - k r^3/2` depend on `r` only +through `r^2`. Hence the integrand `e^(-(q + Q)/2) (det ratio)^(-1/2) F`, as a function of `(r, v_1, k, x)`, is even in `r` as a +formal power series. The coefficients are finite sums of jet covariances, so no property of `K` beyond stationarity and +smoothness is used. +- **Smooth `K`.** The rows are averages of derivatives against smooth kernels, so the covariances, the regression and the + cone integral are smooth in `r` up to `0`. Integrating the even formal series over the fixed cone gives the even + finite-order expansion of Lemma E, to every order. +- **Real-analytic `K`.** The series converge near `r = 0`, which gives the exact form + `A~_r = Atilde(r^2, b - k r^3/2, k)` with `Atilde` real-analytic. + +**Exact checks (controls.py).** For anisotropic product kernels `prod_i e^(-s_i z_i^2/2)` (rational jets, not isotropic, +`d = 1, 2, 3`, two `s` each) the exact integrand has `G_0 = G_1 = G_3 = 0` and +`G_5 = -(k/2)(d_b G_2 - (d_b E) G_2)`, as Lemma E predicts. + +## 5. Lemmas F and G: the finite part and the Gaussian bounds + +**Lemma F.** For `C^1` functions `F_1, F_2` on `[0, oo)` with integrable decay, put `Delta = F_1 - F_2`. Then + + |T(F_1) - T(F_2)| <= 3 |Delta(0)| + 3 integral_0^1 |Delta'(s)| s^(-1/3) ds + integral_1^oo |Delta(k)| k^(-4/3) dk. + +*Proof.* `T(F) = integral_0^1 [F - F(0)] k^(-4/3) + integral_1^oo F k^(-4/3) - 3F(0)`. Next, +`|Delta(k) - Delta(0)| <= integral_0^k |Delta'|`. Exchanging the order of integration gives +`integral_s^1 k^(-4/3) dk = 3(s^(-1/3) - 1) <= 3 s^(-1/3)`. + +This is the inequality of 5933574379 with its second-derivative term replaced by a first-derivative one, so no evenness in +`k` is needed. + +**Lemma G.** Write `g_K = kappa_K e^(-E_K) H_K` and, for the derivative, `g'_K = kappa_K e^(-E_K) H'_K`, where +`H' = d_k H - (d_k E) H` is formed in ball arithmetic. Pointwise, + + |g_L - g_ref| <= |kappa_ref| e^(-E_ref) [ (|e_kappa| + |dE|) e^(|dE|) |H_L| + |H_L - H_ref| ], + +where: +- `|kappa_ref| = 12 (2 pi)^(-(p + n_T)/2) (det S_0 det T_0)^(-1/2)` is the magnitude of the negative constant + `kappa_ref`; `bound_core` bounds it above by `kap` (review C49-F01, 5382406982); +- `kappa_L = kappa_ref (1 + e_kappa)`, with `|e_kappa| <= rho/(1 - rho)` and `rho` the relative radius of + `det S_0 det T_0`; +- `|dE| = |E_L - E_ref| <= sum_i eta_i w_i^2`, from the radii of `E`'s coefficients via + `|w_i w_j| <= (w_i^2 + w_j^2)/2`; +- `|H_L| <= sum (|c| + rho)|w^e|` and `|H_L - H_ref| <= sum rho |w^e|` over `H`'s monomials. + +**Gaussian floor.** A rational `t` with `M - t diag(M)` positive semidefinite, where `E_ref = w^T M w`, is certified by +exact `LDL^T` and bisection. For diagonal `M` it is `t = 1` by an exact branch, with zero residual, as in `d = 1`. It gives +`e^(-E_ref + |dE|) <= prod_i e^(-a_i w_i^2)` with `a_i = t M_ii - eta_i > 0`. Strictness comes from `a_i > 0`, not from +the residual matrix (5384221624). + +The bounds then enlarge the cone and the `b`-line to all of `R^(1 + n_T)`: +- `|Delta(0)|` uses the monomials with no `k`; +- `integral_0^1 |Delta'| s^(-1/3)` uses `s^(j - 1/3) <= s^(j-1)` on `(0, 1]` for `j >= 1`, and `integral_0^1 s^(-1/3) = 3/2` + for `j = 0`; +- `integral_1^oo |Delta| k^(-4/3)` is bounded by `integral_0^oo |Delta|`. + +Each is a finite sum of products `integral |t|^n e^(-a t^2) dt = Gamma((n+1)/2) a^(-(n+1)/2)`, bounded above in +rationals: `sqrt(pi) < sqrt(355/113)`, `pi > 333/106`, and `isqrt` bounds. Finally +`eps = (1/3)|S^(d-1)| * [3 Delta_0 + 3 Delta'_w + Delta_int]`, with `|S^1| <= 2 * 355/113` and `|S^2| <= 4 * 355/113`. It +bounds every frame, and therefore the average over `u`. + +## 6. Numbers (`RESULTS.json`) + +| `d` | `L0` | `t` | `min a_i` | `max eta_i` | `3 Delta_0` | `3 Delta'_w` | `Delta_int` | `eps` | +|---|---|---|---|---|---|---|---|---| +| `1` | `10` | `1` | `0.75` | `9.4e-16` | `1.3e-14` | `2.0e-13` | `1.7e-15` | `1.41e-13` | +| `2` | `10` | `1/2` | `0.125` | `1.9e-15` | `3.4e-14` | `9.6e-13` | `8.9e-15` | `2.09e-12` | +| `3` | `10` | `0.3675` | `0.0919` | `2.8e-15` | `5.3e-13` | `2.3e-11` | `2.2e-13` | `1.00e-10` | + +At `L0 = 24` every radius and bound is smaller by a factor of about `1e-101`. `H` has 9, 50 and 1006 monomials in `d = 1, 2, 3`. + +**Slack.** The bound is conservative. Controls with explicit perturbations (§7) show it exceeds the true change of `c2` by +factors of `1e4` (`d = 1`) to `1e8` (`d = 3`). The causes are ball radii that grow through elimination and Isserlis without +cancellation, the absolute moments, and the cone enlarged to the whole space. The true torus change is of order `e^(-L^2/2)` times polynomial factors, so none of this matters for the conclusions. + +## 7. Verification and controls + +- `python3 -B -S transfer.py --check` recomputes `reference_checks` and all 12 bounds and compares them with `RESULTS.json` + exactly. It takes about two minutes, mostly the `d = 3` ball Isserlis step, and passes identically under `-B -O -S`. +- **Five seeded defects must each exit 1:** + - `no-image`: the image sums are dropped; + - `no-theta`: the normalization term is dropped; + - `drop-ratio`: the transverse determinant ratio is dropped; + - `eta-half`: the exponent radius is halved; + - `fp-const`: the finite-part constant `1` replaces `3`. +- **`controls.py`** (exact and floating; not part of the certificate). It takes about 13 seconds: + - **Lemma E**, exact: six anisotropic kernels (§4). + - **Reference:** a floating integrator applied to [C2X]'s exact data reproduces `c2` inside [C2X]'s certified intervals + in `d = 1, 2, 3`. + - **Falsification of Lemmas F, G and P at a measurable scale.** For the even isotropic mixtures + `K = (1 - eps) phi + eps phi(sqrt s .)`, with `s = 2` or `1/2` and `eps = 1e-3` or `1e-5`: + - `c2[K]` is computed directly, by the exact derivation with `K`'s jets and then closed-form floating integration; + - the bound of `bound_core`, fed with the balls `(phi-jet, |K-jet - phi-jet|)`, must exceed `|c2[K] - c2[phi]|`; + - all 12 cases pass. The true changes are `1e-7` to `1e-3`. + +## 8. What this does not do + +- **The definition and identification are consumed.** + - **Candidate density.** That `c2[K_L]` is its `ell^(1/3)` coefficient is [T]'s claim: Math-#218, a candidate theorem + for `d >= 2`, merged at `fb6ee97`. + - **Elder density.** The identification is [E3]'s (Math-#220), a theorem merged at `0d79778` (`PROOF.md` blob + `c8767dde`, byte-identical to the consumed head `70dcf31`). It consumes #207 (merged at `566b1a1`, `PROOF.md` blob + `f6df5a73`), #218 (merged at `fb6ee97`, `PROOF.md` blob `70ca57ef`) and the merged #187. The complete chain + #191/#198 → #207 → #218 → #220 is now on `main`. + - Neither identification is reviewed here, and the transfer of the fixed-cone expression does not depend on either + (review 5383099127, item 2). + - So is the typed replacement `A_r = A~_r + O(r^3)` ([D] §2.2) on the torus. Lemma E and Theorem C2T are statements + about the surrogate. +- **`d = 1, 2, 3` only;** the pipeline runs unchanged in `d = 4` given time. Lattices other than `L Z^d` are not treated, + although Lemma J only needs `|p_n| >= L|n|`-type counts. +- **Conservative constants** (§6). They are not estimates of the true torus deviation. +- **No review** of [C2X], [T], [D], [SIDE24], [CU], [E3], [L'], [FJ] or Math-#224. Same GitHub account as every lane; zero + organizational-independence credit. **I will not merge.** + +## 9. Provenance + +- **Sources** (`SOURCE_MAP.json`). The workflow verifies these on the checked-out tree: + - [C2X] `frontiers/c2_exact_20261001/{exact.py, pseries.py, NOTE.md, RESULTS.json}` on `main` (since `f9ebba1`; unchanged at `7fe06b0`). `exact.py` and + `pseries.py` are also carried byte-identically in this directory. + - [SIDE24] `coefficients/side24_v1/PROOF.md`. + - [T] Math-#218 `frontiers/candidate_third_order_20261001/PROOF.md` (blob `70ca57ef`), on `main` since `fb6ee97` and + byte-identical to the consumed head `0cf048d`. + - [CU] Math-#219 `frontiers/cusp_coefficient_certified_20261001/RESULTS.json` (blob `8bbd0b0c`), on `main` since + `5a836a8` and byte-identical to the consumed head `7a04873`. The `c1/c` interval is read from this file. + - [E3] Math-#220 `frontiers/elder_third_order_20261001/PROOF.md` (blob `c8767dde`), on `main` since `0d79778` and + byte-identical to the consumed head `70dcf31`. Cited for the elder identification only. + - [CT] Math-#224 `frontiers/cusp_torus_transfer_20261001/PROOF.md` (blob `de3d85fd`), on `main` since `d3a0b6c` and + byte-identical to the consumed head `a5e69ee`. Consumed for (T1); cited as the `c1` analogue. +- **Recorded and not checked on this tree:** + - [CU] Math-#219 `NOTE.md` at `7a04873` (blob `7dccfa97`). On `main` it has since changed by wording only (v1.4–v1.5); + the certified values are in the unchanged `RESULTS.json`. + - [D] Math-#216 `NOTE.md` (blob `aa078a9c`); + - [L'] Math-#227 at `2d1ec7c`: `NOTE.md` (blob `138521e8`), cited only. +- **On `main` since `7fe06b0`, cited only:** [FJ] Math-#232 + `frontiers/c2_finite_jet_transfer_20261001/PROOF.md` (blob `54cc4a1a`). +- **Files:** + - the certificate: `transfer.py`, `ball.py`, `exact.py`, `pseries.py`; + - `controls.py`; + - `RESULTS.json`, `SOURCE_MAP.json`, `SOURCE_FILES.json`. diff --git a/frontiers/c2_torus_transfer_20261001/README.md b/frontiers/c2_torus_transfer_20261001/README.md new file mode 100644 index 000000000..68eec096f --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/README.md @@ -0,0 +1,19 @@ +# `c2` on the finite torus: transfer for every `L >= 10` (Math-#218 (0.1), against `frontiers/c2_exact_20261001`) + +`CL-C2-TORUS-TRANSFER-20261001-v1`. Author-side; scientific effect NONE. See `NOTE.md`. + +For the normalized periodic Gaussian kernel `K_L` (SIDE24 is `L = 24`), every orthonormal frame and every real `L >= L0`, +`|c2[K_L] - c2[phi]| <= eps_d(L0)`: + +| `d` | `L >= 10` | `L >= 24` | +|---|---|---| +| `1` | `1.41035e-13` | `4.09547e-114` | +| `2` | `2.09404e-12` | `5.20139e-113` | +| `3` | `1.00039e-10` | `2.09418e-111` | + +Lemma E: for every smooth stationary kernel the fixed-cone surrogate has an even finite-order expansion in `r` at fixed +`b - k r^3/2`, so it has no `r^1` term and its `r^3` coefficient is `-(k/2) d_b A_0`. For real-analytic kernels, which +include `phi` and `K_L`, it is exactly `A~(r^2, b - k r^3/2, k)`. + +Replay: `python3 -B -S transfer.py --check` (exact rational ball arithmetic, standard library only; about two minutes). +Controls: `python3 -B -S controls.py`. diff --git a/frontiers/c2_torus_transfer_20261001/RESULTS.json b/frontiers/c2_torus_transfer_20261001/RESULTS.json new file mode 100644 index 000000000..919a567b2 --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/RESULTS.json @@ -0,0 +1,226 @@ +{ + "bounds": { + "d1_L10": { + "Delta0": "4.44080e-15", + "Delta_int": "1.68784e-15", + "L0": 10, + "a_min": "7.50000e-1", + "d": 1, + "dDelta_w": "6.55138e-14", + "e_kappa": "8.05025e-17", + "eps": "1.41035e-13", + "eta_max": "9.40524e-16", + "kappa_up": "8.77514e-2", + "max_jet_order": 20, + "max_radius_H": "3.13354e-13", + "n_monomials_H": 9, + "rel": "6.13074e-13", + "t_diag": "1.00000e+0", + "theta1": "3.85750e-22" + }, + "d1_L12": { + "Delta0": "4.54251e-24", + "Delta_int": "1.71392e-24", + "L0": 12, + "a_min": "7.50000e-1", + "d": 1, + "dDelta_w": "6.62356e-23", + "e_kappa": "6.27881e-26", + "eps": "1.42699e-22", + "eta_max": "7.39127e-25", + "kappa_up": "8.77514e-2", + "max_jet_order": 20, + "max_radius_H": "3.04757e-22", + "n_monomials_H": 9, + "rel": "6.20309e-22", + "t_diag": "1.00000e+0", + "theta1": "1.07604e-31" + }, + "d1_L16": { + "Delta0": "1.82806e-47", + "Delta_int": "6.83459e-48", + "L0": 16, + "a_min": "7.50000e-1", + "d": 1, + "dDelta_w": "2.62661e-46", + "e_kappa": "1.57599e-49", + "eps": "5.66439e-46", + "eta_max": "1.87017e-48", + "kappa_up": "8.77514e-2", + "max_jet_order": 20, + "max_radius_H": "1.14804e-45", + "n_monomials_H": 9, + "rel": "2.46230e-45", + "t_diag": "1.00000e+0", + "theta1": "5.14442e-56" + }, + "d1_L24": { + "Delta0": "1.33798e-115", + "Delta_int": "4.96197e-116", + "L0": 24, + "a_min": "7.50000e-1", + "d": 1, + "dDelta_w": "1.89740e-114", + "e_kappa": "5.56180e-118", + "eps": "4.09547e-114", + "eta_max": "6.64022e-117", + "kappa_up": "8.77514e-2", + "max_jet_order": 20, + "max_radius_H": "7.90074e-114", + "n_monomials_H": 9, + "rel": "1.78030e-113", + "t_diag": "1.00000e+0", + "theta1": "1.67579e-125" + }, + "d2_L10": { + "Delta0": "1.13884e-14", + "Delta_int": "8.94035e-15", + "L0": 10, + "a_min": "1.25000e-1", + "d": 2, + "dDelta_w": "3.18908e-13", + "e_kappa": "1.81351e-16", + "eps": "2.09404e-12", + "eta_max": "1.88105e-15", + "kappa_up": "3.93992e-3", + "max_jet_order": 20, + "max_radius_H": "6.32063e-13", + "n_monomials_H": 50, + "rel": "9.45285e-12", + "t_diag": "5.00000e-1", + "theta1": "7.71500e-22" + }, + "d2_L12": { + "Delta0": "1.12587e-23", + "Delta_int": "8.66171e-24", + "L0": 12, + "a_min": "1.25000e-1", + "d": 2, + "dDelta_w": "3.07836e-22", + "e_kappa": "1.37156e-25", + "eps": "2.02307e-21", + "eta_max": "1.47826e-24", + "kappa_up": "3.93992e-3", + "max_jet_order": 20, + "max_radius_H": "6.12547e-22", + "n_monomials_H": 50, + "rel": "9.13248e-21", + "t_diag": "5.00000e-1", + "theta1": "2.15208e-31" + }, + "d2_L16": { + "Delta0": "4.34211e-47", + "Delta_int": "3.25673e-47", + "L0": 16, + "a_min": "1.25000e-1", + "d": 2, + "dDelta_w": "1.15187e-45", + "e_kappa": "3.32413e-49", + "eps": "7.57841e-45", + "eta_max": "3.74033e-48", + "kappa_up": "3.93992e-3", + "max_jet_order": 20, + "max_radius_H": "2.30056e-45", + "n_monomials_H": 50, + "rel": "3.42103e-44", + "t_diag": "5.00000e-1", + "theta1": "1.02889e-55" + }, + "d2_L24": { + "Delta0": "3.06010e-115", + "Delta_int": "2.24309e-115", + "L0": 24, + "a_min": "1.25000e-1", + "d": 2, + "dDelta_w": "7.89749e-114", + "e_kappa": "1.14043e-117", + "eps": "5.20139e-113", + "eta_max": "1.32805e-116", + "kappa_up": "3.93992e-3", + "max_jet_order": 20, + "max_radius_H": "1.58088e-113", + "n_monomials_H": 50, + "rel": "2.34800e-112", + "t_diag": "5.00000e-1", + "theta1": "3.35158e-125" + }, + "d3_L10": { + "Delta0": "1.78082e-13", + "Delta_int": "2.24526e-13", + "L0": 10, + "a_min": "9.18862e-2", + "d": 3, + "dDelta_w": "7.70788e-12", + "e_kappa": "3.14352e-16", + "eps": "1.00039e-10", + "eta_max": "2.82157e-15", + "kappa_up": "7.05724e-5", + "max_jet_order": 20, + "max_radius_H": "1.90639e-12", + "n_monomials_H": 1006, + "rel": "6.20455e-10", + "t_diag": "3.67545e-1", + "theta1": "1.15725e-21" + }, + "d3_L12": { + "Delta0": "1.71757e-22", + "Delta_int": "2.07220e-22", + "L0": 12, + "a_min": "9.18862e-2", + "d": 3, + "dDelta_w": "7.08488e-21", + "e_kappa": "2.29890e-25", + "eps": "9.20576e-20", + "eta_max": "2.21738e-24", + "kappa_up": "7.05724e-5", + "max_jet_order": 20, + "max_radius_H": "1.84351e-21", + "n_monomials_H": 1006, + "rel": "5.70957e-19", + "t_diag": "3.67545e-1", + "theta1": "3.22812e-31" + }, + "d3_L16": { + "Delta0": "6.41933e-46", + "Delta_int": "7.32175e-46", + "L0": 16, + "a_min": "9.18862e-2", + "d": 3, + "dDelta_w": "2.48771e-44", + "e_kappa": "5.34636e-49", + "eps": "3.23748e-43", + "eta_max": "5.61049e-48", + "kappa_up": "7.05724e-5", + "max_jet_order": 20, + "max_radius_H": "6.91048e-45", + "n_monomials_H": 1006, + "rel": "2.00794e-42", + "t_diag": "3.67545e-1", + "theta1": "1.54333e-55" + }, + "d3_L24": { + "Delta0": "4.39620e-114", + "Delta_int": "4.76136e-114", + "L0": 24, + "a_min": "9.18862e-2", + "d": 3, + "dDelta_w": "1.60666e-112", + "e_kappa": "1.76946e-117", + "eps": "2.09418e-111", + "eta_max": "1.99207e-116", + "kappa_up": "7.05724e-5", + "max_jet_order": 20, + "max_radius_H": "4.74408e-113", + "n_monomials_H": 1006, + "rel": "1.29885e-110", + "t_diag": "3.67545e-1", + "theta1": "5.02737e-125" + } + }, + "object": "CL-C2-TORUS-TRANSFER-20261001-v1", + "reference_checks": { + "1": true, + "2": true, + "3": true + } +} diff --git a/frontiers/c2_torus_transfer_20261001/SOURCE_FILES.json b/frontiers/c2_torus_transfer_20261001/SOURCE_FILES.json new file mode 100644 index 000000000..b7506522d --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/SOURCE_FILES.json @@ -0,0 +1,59 @@ +{ + "object": "CL-C2-TORUS-TRANSFER-20261001-v1", + "files": [ + { + "path": "NOTE.md", + "bytes": 21673, + "sha256": "6d15dccc847d9457ff5d77d6286179fa87505b5d0570fea7996366bb2ba79da3", + "git_blob": "5ce5bad2a1073b9b425fc4c5e6eed5527d39eaf2" + }, + { + "path": "README.md", + "bytes": 998, + "sha256": "63a3302d33c7ef56aac23044f743e7e613db9aaf2e448d72ef05e84d5135f46c", + "git_blob": "68eec096fc928692852e75117a5bd3ce51551e5e" + }, + { + "path": "RESULTS.json", + "bytes": 5334, + "sha256": "dcfcbb15c16327277e1108f4a159ed6553bb1d0de54a931af28b29957c10398a", + "git_blob": "919a567b295b46ccc35b37cea1349c5d6f79fd6a" + }, + { + "path": "SOURCE_MAP.json", + "bytes": 7513, + "sha256": "56fae2a5c2aad309bec346cde15e8df968ea75d48b1ae194f3d1e4d0dc35629a", + "git_blob": "5365bc2d8e89f6dd0cb473caa3334f910b70a6bb" + }, + { + "path": "ball.py", + "bytes": 4495, + "sha256": "11cd2788b8fc4ea0b967c04711aeb384d5366f9c88e65975405c7ef48a7ea8ed", + "git_blob": "72205f8adf9aa741246d9ca5d7b2d4ba0f014e7a" + }, + { + "path": "controls.py", + "bytes": 8318, + "sha256": "9cce7ab25657f7ccb91d7bc23a0712a5fd85534a942519b0bd7f92a3725ea629", + "git_blob": "863023c256c209715d46bd4e0a05395a3c1f3ba8" + }, + { + "path": "exact.py", + "bytes": 16099, + "sha256": "974099926619e7c85aea9fbccb5285e54862909cd079895f16e785583c884d6c", + "git_blob": "b06819802d1b90813cd172dc372aaac771ff6720" + }, + { + "path": "pseries.py", + "bytes": 6782, + "sha256": "d1faa96ca7e7df0051fbfe78318a17d0c78d608eb9f1ed2e3a3b83a6598a9994", + "git_blob": "fac3c562b33e626d477aefecf2b1e680b0ae5f98" + }, + { + "path": "transfer.py", + "bytes": 25337, + "sha256": "59ebbdeda9111c8390c84986c2fefa7725c5916627d4409777a5abc66a6e9f33", + "git_blob": "05dc3fba1d1f1399519569f113911ed043a67fba" + } + ] +} diff --git a/frontiers/c2_torus_transfer_20261001/SOURCE_MAP.json b/frontiers/c2_torus_transfer_20261001/SOURCE_MAP.json new file mode 100644 index 000000000..5365bc2d8 --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/SOURCE_MAP.json @@ -0,0 +1,142 @@ +{ + "object": "CL-C2-TORUS-TRANSFER-20261001-v1", + "delivered_under": "explicit owner instructions of Dylan Roy in Claude Code session session_015wNj8LPTKXsaT68G3DgPPh, given after OWNER_STOP (2026-09-27): 2026-09-28 \"you have my full permisions and approval to make the proper changes and uploads\"; 2026-09-30 \"Work on closing as many mathematical items as possible while working with and supporting the other models in the GitHub. Also advance the mathematics in every place that's justified based on what we currently know. Ultra tokens, ultra depth @GitHub @Superpowers\" (repeated 2026-09-30 as \"Continue to Work on closing ...\"). Pull requests only, never merged by their author; no register, GRAPH, STATUS, lemma_closed, prize or premise edits. OWNER_STOP.md addresses Cursor agents and automations and is untouched.", + "task": "Math-#223 comment 5933574379 (task and the finite-part starting inequality), main#229 comment 5933485698 (listed as unsupplied); scope claim Math-#223 comment 5934236720", + "sources": [ + { + "label": "[C2X-code]", + "path": "frontiers/c2_exact_20261001/exact.py", + "ref": "main f9ebba1", + "consumed": "kernel_data: the exact derivation of the fixed-cone surrogate (byte-identical copy exact.py in this packet; reference_checks compares the ball pipeline with it identically)", + "current_required": true, + "bytes": 16099, + "sha256": "974099926619e7c85aea9fbccb5285e54862909cd079895f16e785583c884d6c", + "git_blob": "b06819802d1b90813cd172dc372aaac771ff6720" + }, + { + "label": "[C2X-series]", + "path": "frontiers/c2_exact_20261001/pseries.py", + "ref": "main f9ebba1", + "consumed": "pin rows, Taylor forms at -+r/2, exact division by r (byte-identical copy pseries.py in this packet)", + "current_required": true, + "bytes": 6782, + "sha256": "d1faa96ca7e7df0051fbfe78318a17d0c78d608eb9f1ed2e3a3b83a6598a9994", + "git_blob": "fac3c562b33e626d477aefecf2b1e680b0ae5f98" + }, + { + "label": "[C2X]", + "path": "frontiers/c2_exact_20261001/NOTE.md", + "ref": "main f9ebba1", + "consumed": "sections 0-2 and 5: the definition of c2 for the surrogate, the closed forms and the published enclosures (widened 1e-14 relative)", + "current_required": true, + "bytes": 14480, + "sha256": "598fc86a7c6b21bad438ef087e5aa7521f0fae08e25fa4f40f9b2ba635846dbb", + "git_blob": "a2798b87674ed5fc0d2144697e77ccb9b185b4ab" + }, + { + "label": "[C2X-results]", + "path": "frontiers/c2_exact_20261001/RESULTS.json", + "ref": "main f9ebba1", + "consumed": "the certified enclosures of c2 (lower endpoints used for the relative bounds; C2_REF_LO in transfer.py)", + "current_required": true, + "bytes": 1891, + "sha256": "94aa67f11211881d60e93ee1782e9b9d829d246d8f75d73eb05b2212278cb831", + "git_blob": "3077d9b29bc2393fbae1dd2c8420ca1bcc3707dd" + }, + { + "label": "[SIDE24]", + "path": "coefficients/side24_v1/PROOF.md", + "ref": "main f9ebba1", + "consumed": "the normalized periodic covariance K_24 and the enclosures of c_(d,24) (corollary quotients)", + "current_required": true, + "bytes": 10272, + "sha256": "c06daccc4ba4b9168522b9888b76a7d599934fc3b91bd753ee5d492262917769", + "git_blob": "44b66f04f89fcd87383b3603fa69f1feb64cdddd" + }, + { + "label": "[T]", + "path": "frontiers/candidate_third_order_20261001/PROOF.md", + "ref": "Math-#218, merged at fb6ee97 (byte-identical to the consumed head 0cf048d)", + "consumed": "(0.1): the expression c2; Lemma F and Theorem T's identification of it as the candidate-density ell^(1/3) coefficient for d >= 2 (candidate theorem; merged at fb6ee97, which is not a status promotion; cited, not reviewed)", + "current_required": true, + "bytes": 37220, + "sha256": "6c1279164499d4fe2fbeee244b40dafa2159758d20f04826cd67d7602ea97fe4", + "git_blob": "70ca57ef05199e75417d7d57928c1e1c93bf944e" + }, + { + "label": "[D]", + "path": "frontiers/third_order_coefficient_20261001/NOTE.md", + "ref": "Math-#216 head 04c08e1 (unmerged)", + "consumed": "section 2.2: the typed indicator replaced by 1{T < 0} at O(r^3) (consumed premise, as in [C2X])", + "current_required": false, + "bytes": 24186, + "sha256": "ae15c0ee173b9d01d258536a11780cc4b128c57811d1fb5db9db391ffc759ee5", + "git_blob": "aa078a9cbfc3aa859c089596892e34a8293831eb" + }, + { + "label": "[CT]", + "path": "frontiers/cusp_torus_transfer_20261001/PROOF.md", + "ref": "Math-#224, merged at d3a0b6c (blob byte-identical to the consumed head a5e69ee)", + "consumed": "(T1): the normalized periodic kernel for every L; the analogous c1 transfer (cited)", + "current_required": true, + "bytes": 15534, + "sha256": "6b818bdc34c6908505c6b2ad65584f740254a8525ddc8a45197d560386243bb0", + "git_blob": "de3d85fdcf65487adc982bae7318246c1b8f016c" + }, + { + "label": "[CU]", + "path": "frontiers/cusp_coefficient_certified_20261001/NOTE.md", + "ref": "Math-#219 head 7a04873 (merged at 5a836a8; NOTE.md changed there by wording only, so this NOTE pin is historical)", + "consumed": "the certified c1/c enclosure quoted in NOTE section 0 (consumed, not accepted)", + "current_required": false, + "bytes": 25867, + "sha256": "83c8790542b5f94b411871c2bd174fe89a881ed12a29132d4722564b1cc1cf29", + "git_blob": "7dccfa97e3713d5c8c6d05b7725763f3aa355309" + }, + { + "label": "[CU-results]", + "path": "frontiers/cusp_coefficient_certified_20261001/RESULTS.json", + "ref": "Math-#219, merged at 5a836a8 (RESULTS.json byte-identical to the consumed head 7a04873)", + "consumed": "the stored c1/c interval (consumed, not accepted)", + "current_required": true, + "bytes": 5350, + "sha256": "2de0a2381eb2f73b3f2ed7367c78d28856067b271f9e3484384c199a24cacdbe", + "git_blob": "8bbd0b0c69f6b29849fb2e3a3b2ad86974130987" + }, + { + "label": "[E3]", + "path": "frontiers/elder_third_order_20261001/PROOF.md", + "ref": "Math-#220, merged at 0d79778 (blob byte-identical to the consumed head 70dcf31); consumes #207 (merged at 566b1a1), #218 (merged at fb6ee97) and merged #187", + "consumed": "the identification of c2 as the elder-density ell^(1/3) coefficient (cited, not reviewed)", + "current_required": true, + "bytes": 70544, + "sha256": "74b5f031ba5be6f50b5e543636136df1d9b5fad0fcd2c8210320cfef02f80e37", + "git_blob": "c8767ddecf1041d234f685e95af582073a7be393" + }, + { + "label": "[L']", + "path": "frontiers/c8_torus_vanishing_remainder_20261001/NOTE.md", + "ref": "Math-#227 head 2d1ec7c (unmerged)", + "consumed": "cited only: the open r^1 question that Lemma E answers for the surrogate; #227's beta r allowance is unaffected", + "current_required": false, + "bytes": 17185, + "sha256": "f7ee8cdbbf6a551092b4abcb482b63addfde1f9d49fc855282a8115f9cd9b1bf", + "git_blob": "138521e82d6c4088a61b97a89020164dbbae6c40" + }, + { + "label": "[FJ]", + "path": "frontiers/c2_finite_jet_transfer_20261001/PROOF.md", + "ref": "main 7fe06b0 (merged Math-#232)", + "consumed": "cited only: the general eight-jet stability interface; compatible, neither supersedes the other", + "current_required": true, + "bytes": 25581, + "sha256": "971101de946fd711207454c2cd4bbc36729ca9b7c07262e122ff1d54bf5dfa16", + "git_blob": "54cc4a1ae274842bc2c01f9c207549e7b07de7bc" + } + ], + "copies": { + "exact.py": "frontiers/c2_exact_20261001/exact.py", + "pseries.py": "frontiers/c2_exact_20261001/pseries.py" + }, + "note": "current_required entries are verified byte-for-byte on the checked-out tree by the workflow, and the copies against them; the unmerged pins record the exact bytes read and are not checked against the tree." +} diff --git a/frontiers/c2_torus_transfer_20261001/ball.py b/frontiers/c2_torus_transfer_20261001/ball.py new file mode 100644 index 000000000..72205f8ad --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/ball.py @@ -0,0 +1,158 @@ +"""Rational ball arithmetic and rational bounds for CL-C2-TORUS-TRANSFER-20261001 (NOTE.md section 2). Standard library. + +A ball B(c, r) is the set [c - r, c + r] with c, r rational, r >= 0. Centers are carried EXACTLY: with every radius +zero the arithmetic is that of Fractions, so a ball pipeline reproduces the exact reference derivation in its centers. +Radii are rounded UP to dyadic rationals with RB significant bits after each operation, which only enlarges the ball. +Every operation returns a ball containing every result of the operation applied to members of the operand balls.""" +from fractions import Fraction as Fr +import math + +RB = 64 + + +def rup(x): + """smallest dyadic m / 2^e >= x with m < 2^RB (x >= 0 rational)""" + x = Fr(x) + if x <= 0: + if x < 0: + raise ValueError('negative radius') + return Fr(0) + e = RB - (x.numerator.bit_length() - x.denominator.bit_length()) + if e >= 0: + m = -((-x.numerator << e) // x.denominator) + return Fr(m, 1 << e) + m = -((-x.numerator) // (x.denominator << -e)) + return Fr(m << -e) + + +class B: + __slots__ = ('c', 'r') + + def __init__(self, c, r=0): + self.c = Fr(c) + self.r = rup(r) + + def __bool__(self): + return bool(self.c) or bool(self.r) + + def __add__(self, o): + if isinstance(o, B): + return B(self.c + o.c, self.r + o.r) + return B(self.c + o, self.r) + __radd__ = __add__ + + def __neg__(self): + return B(-self.c, self.r) + + def __sub__(self, o): + return self + (-o) + + def __rsub__(self, o): + return (-self) + o + + def __mul__(self, o): + if isinstance(o, B): + return B(self.c * o.c, abs(self.c) * o.r + abs(o.c) * self.r + self.r * o.r) + o = Fr(o) + return B(self.c * o, abs(o) * self.r) + __rmul__ = __mul__ + + def inv(self): + a = abs(self.c) + if not a > self.r: + raise ZeroDivisionError('ball contains 0') + return B(1 / self.c, self.r / (a * (a - self.r))) + + def __truediv__(self, o): + if isinstance(o, B): + return self * o.inv() + return self * (1 / Fr(o)) + + def __rtruediv__(self, o): + return self.inv() * o + + def mag(self): + """upper bound of |x| on the ball""" + return abs(self.c) + self.r + + def __repr__(self): + return 'B(%s, %s)' % (float(self.c), float(self.r)) + + +def center(x): + return x.c if isinstance(x, B) else Fr(x) + + +def radius(x): + return x.r if isinstance(x, B) else Fr(0) + + +def mag(x): + return x.mag() if isinstance(x, B) else abs(Fr(x)) + + +def nonzero_center(x): + return center(x) != 0 + + +# ---------------------------------------------------------------------------------------------- rational bounds +PI_UP = Fr(355, 113) # pi < 355/113 +PI_DN = Fr(333, 106) # 333/106 < pi + + +def exp_up(x): + """upper bound of e^x for rational x (exact partial sums: e^x >= sum_{j<=J} x^j/j! for x >= 0)""" + x = Fr(x) + if x <= 0: + # e^-y = (e^(-y/n))^n, n = 2^m with y/n <= 1; e^(-t) <= 1/sum_{j<=30} t^j/j!; each squaring rounds up + y = -x + n, m = 1, 0 + while y / n > 1: + n, m = 2 * n, m + 1 + t = y / n + s, term = Fr(0), Fr(1) + for j in range(31): + s += term + term = term * t / (j + 1) + v = rup(1 / s) + for _ in range(m): + v = rup(v * v) + return v + # e^x = 1 / e^-x <= 1 / (lower bound of e^-x); e^-x >= alternating partial sum ending on a negative term ... use + # e^x = (e^(x/n))^n with x/n <= 1/2 and e^t <= 1/(1 - t - t^2/2 ... ) avoided: e^t <= sum_{j<=J} t^j/j! + tail + n = 1 + while x / n > Fr(1, 2): + n *= 2 + t = x / n + J = 30 + s, term = Fr(0), Fr(1) + for j in range(J + 1): + s += term + term = term * t / (j + 1) + s += 2 * term # tail sum_{j>J} t^j/j! <= 2 t^(J+1)/(J+1)! for t <= 1/2 + return rup(s ** n) + + +def exp_dn(x): + """lower bound of e^x""" + return 1 / exp_up(-Fr(x)) + + +def isqrt_frac_up(x, bits=80): + """upper bound of sqrt(x), x >= 0 rational""" + x = Fr(x) + if x == 0: + return Fr(0) + sc = 1 << (2 * bits) + n = -((-x.numerator * sc) // x.denominator) + s = math.isqrt(n) + if s * s < n: + s += 1 + return Fr(s, 1 << bits) + + +def isqrt_frac_dn(x, bits=80): + x = Fr(x) + sc = 1 << (2 * bits) + n = (x.numerator * sc) // x.denominator + return Fr(math.isqrt(n), 1 << bits) diff --git a/frontiers/c2_torus_transfer_20261001/controls.py b/frontiers/c2_torus_transfer_20261001/controls.py new file mode 100644 index 000000000..863023c25 --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/controls.py @@ -0,0 +1,199 @@ +"""Floating controls for CL-C2-TORUS-TRANSFER-20261001 (NOTE.md section 6; not part of the certificate). + +Control 1 (reference). The floating integrator below, applied to the exact Gaussian-kernel data of c2_exact, returns c2 +inside the certified intervals of frontiers/c2_exact_20261001/RESULTS.json. + +Control 0 (Lemma E, exact). For anisotropic product kernels prod_i exp(-s_i z_i^2/2) (rational jets; not isotropic), +the exact integrand of the fixed-cone surrogate has G_0 = G_1 = G_3 = 0 and G_5 = -(k/2)(d_b G_2 - (d_b E) G_2): the +identities that A~_r = A~(r^2, b - k r^3/2, k) implies. These are exact identities of rational polynomials. + +Control 2 (falsification of Lemmas F, G, P at a measurable scale). For the isotropic, even, normalized mixture kernels + K_eps(z) = (1 - eps) exp(-|z|^2/2) + eps exp(-s |z|^2/2), s = 2 or 1/2, +c2[K_eps] is computed directly: c2_exact's exact derivation with the jets of K_eps (rational), then the floating +integration in closed form (k: Gamma finite parts; b: completing the square; cone: half-line / quadrant moments). The +certified bound of transfer.bound_core, fed with balls (phi-jet, |K_eps-jet - phi-jet|), must exceed |c2[K_eps] - c2[phi]|. +Both the bound and the difference are linear in eps for small eps; their ratio is the slack of the bound. + + python3 -B -S controls.py""" +from fractions import Fraction as Fr +import math +import os +import sys + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import pseries as P # noqa: E402 +import exact as X # noqa: E402 +import transfer as T # noqa: E402 +from ball import B # noqa: E402 + +GAUSS_RHO = P.rho_der +C2_INTERVALS = {1: ('0.2300445802661503', '0.2300445802661998'), 2: ('0.2215244106266632', '0.2215244106267110'), + 3: ('0.1612340491269447', '0.1612340491269810')} + + +def mix_rho(eps, s): + def rho(g): + v = GAUSS_RHO(g) + return v * ((1 - eps) + eps * s ** (sum(g) // 2)) if v else 0 + return rho + + +def half_moment_f(j, c): + """int_0^oo t^j e^(-c t^2) dt""" + return math.gamma((j + 1) / 2) * c ** (-(j + 1) / 2) / 2 + + +def quadrant_moments_f(al, be, ga, nmax): + D = 4 * al * ga - be * be + M = {(0, 0): (math.pi / 2 - math.atan(be / math.sqrt(D))) / math.sqrt(D)} + for n in range(nmax): + for i in range(n + 1): + j = n - i + R1 = M[(i - 1, j)] * i if i else half_moment_f(j, ga) + R2 = M[(i, j - 1)] * j if j else half_moment_f(i, al) + M.setdefault((i + 1, j), (R1 * 2 * ga - R2 * be) / D) + M.setdefault((i, j + 1), (R2 * 2 * al - R1 * be) / D) + return M + + +def c2_float(d, data): + """c2 = (|S^(d-1)|/3) const int db f.p. int dk k^(-4/3) int_cone exp(-E) H w for isotropic-kernel data of + exact.kernel_data (rotation-reduced in d = 3), with general exponent coefficients.""" + G = data['G'] + H = G.rcoef(4) + E = (data['q0'] + data['Q0']) * Fr(1, 2) + ak = float(E.coef_of('k', 2).scalar()) + if not (E.coef_of("k", 1).is_zero() and E.degree("k") == 2): + raise ArithmeticError("unexpected k-dependence of the exponent") + # k: f.p. int_0^oo k^(j - 4/3) e^(-ak k^2) dk = Gamma((j - 1/3)/2) ak^(-(j - 1/3)/2) / 2 + Hk = {} + for e, c in H.t.items(): + j = e[2] + a = (j - Fr(1, 3)) / 2 + val = float(c) * math.gamma(float(a)) * ak ** (-float(a)) / 2 + key = (e[1],) + e[3:] + Hk[key] = Hk.get(key, 0.0) + val + Ek = E.coef_of('k', 0) + ab = float(Ek.coef_of('b', 2).scalar()) + Lx, Rx = Ek.coef_of('b', 1), Ek.coef_of('b', 0) + # complete the square: b -> b - Lx/(2 ab); expand (b - l)^n with l a linear form in x (floats) + lin = {e[3:]: float(c) / (2 * ab) for e, c in Lx.t.items()} # l(x) = sum lin[e] x^e + Hb = {} + for key, val in Hk.items(): + n, xe = key[0], key[1:] + # (b - l)^n = sum_m C(n, m) b^m (-l)^(n-m); keep even m + lpow = {(0, 0): 1.0} + powers = [dict(lpow)] + for _ in range(n): + nxt = {} + for e1, c1 in powers[-1].items(): + for e2, c2 in lin.items(): + e = (e1[0] + e2[0], e1[1] + e2[1]) + nxt[e] = nxt.get(e, 0.0) + c1 * c2 + powers.append(nxt) + for m in range(0, n + 1, 2): + bm = 2 * half_moment_f(m, ab) + for e, c in powers[n - m].items(): + kk = (xe[0] + e[0], xe[1] + e[1]) + Hb[kk] = Hb.get(kk, 0.0) + val * math.comb(n, m) * bm * c * (-1) ** (n - m) + Ex = Rx - Lx * Lx * (Fr(1) / (4 * Ek.coef_of('b', 2).scalar())) + total = 0.0 + if d == 1: + total = sum(Hb.values()) + elif d == 2: + g = float(Ex.coef_of('x1', 2).scalar()) + for key, val in Hb.items(): + total += val * half_moment_f(key[0], g) * (-1) ** key[0] + else: + al = float(Ex.coef_of('x1', 2).scalar()) + ga = float(Ex.coef_of('x2', 2).scalar()) + bx = float(Ex.coef_of('x1', 1).coef_of('x2', 1).scalar()) + # x1 = -s, x2 = -s - t: al s^2 + bx s (s + t) + ga (s + t)^2 ; weight x1 - x2 = t + A_ = al + bx + ga + Bt = bx + 2 * ga + C_ = ga + nmax = max(k[0] + k[1] for k in Hb) + 3 + M = quadrant_moments_f(A_, Bt, C_, nmax) + for key, val in Hb.items(): + i, j = key + # x1^i x2^j = (-s)^i (-s - t)^j + for m in range(j + 1): + coef = math.comb(j, m) * (-1) ** (i + j) + total += val * coef * M[(i + m, j - m + 1)] + nn = data['p'] + (0 if d == 1 else (1 if d == 2 else 3)) + const = -12 * (2 * math.pi) ** (-nn / 2) / math.sqrt(float(data['detS0'] * data['detT0'])) + if d == 3: + const *= math.pi + sphere = {1: 2, 2: 2 * math.pi, 3: 4 * math.pi}[d] + return sphere / 3 * const * total + + +def aniso_rho(sv): + def rho(g): + v = GAUSS_RHO(g) + if not v: + return Fr(0) + out = Fr(v) + for gi, si in zip(g, sv): + out *= si ** (gi // 2) + return out + return rho + + +def evenness_checks(): + fails = 0 + nr0 = T.NR + T.NR = 5 # series exact through r^5 at pseries.R = 8 + try: + for d in (1, 2, 3): + for sv in ([Fr(1), Fr(3, 2), Fr(5, 4)], [Fr(2), Fr(1, 3), Fr(7, 5)]): + D = T.kernel(d, aniso_rho(sv[:d])) + G, E = D['G'], D['E'] + G2 = G.rcoef(2) + rhs5 = (G2.deriv('b') - E.deriv('b') * G2) * T.Poly.var('k') * Fr(-1, 2) + ok = G.rcoef(0).is_zero() and G.rcoef(1).is_zero() and G.rcoef(3).is_zero() and \ + (G.rcoef(5) - rhs5).is_zero() and not G2.is_zero() + fails += not ok + print('Lemma E, d=%d, s=%s: G0=G1=G3=0 and G5 = -(k/2)(d_b - E_b)G2: %s' + % (d, [str(x) for x in sv[:d]], ok)) + finally: + T.NR = nr0 + return fails + + +def run(): + fails = evenness_checks() + out = {} + for d in (1, 2, 3): + P.rho_der = GAUSS_RHO + ref = c2_float(d, X.kernel_data(d)) + lo, hi = (float(x) for x in C2_INTERVALS[d]) + ok = lo - 1e-12 <= ref <= hi + 1e-12 + fails += not ok + print('d=%d reference c2 (floating) %.15f in certified interval: %s' % (d, ref, ok)) + for s in (Fr(2), Fr(1, 2)): + for eps in (Fr(1, 1000), Fr(1, 100000)): + P.rho_der = mix_rho(eps, s) + c2m = c2_float(d, X.kernel_data(d)) + P.rho_der = GAUSS_RHO + mix = mix_rho(eps, s) + + def jc(g, mix=mix): + if sum(g) % 2: + return B(0) + v = GAUSS_RHO(g) + return B(v, abs(Fr(mix(g)) - v)) + bd = T.bound_core(d, T.kernel(d, jc)) + diff = abs(c2m - ref) + ok = float(bd['eps']) >= diff + fails += not ok + out[(d, s, eps)] = (diff, float(bd['eps'])) + print(' s=%s eps=%s: |c2[K]-c2[phi]| = %.3e bound = %.3e slack %.1f %s' + % (s, eps, diff, float(bd['eps']), float(bd['eps']) / diff if diff else float('inf'), + 'ok' if ok else 'FAIL')) + print('controls: %d failures' % fails) + return fails + + +if __name__ == '__main__': + sys.exit(1 if run() else 0) diff --git a/frontiers/c2_torus_transfer_20261001/exact.py b/frontiers/c2_torus_transfer_20261001/exact.py new file mode 100644 index 000000000..b06819802 --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/exact.py @@ -0,0 +1,432 @@ +"""Exact derivation of c and c2 for the Gaussian kernel, d = 1, 2, 3 (NOTE.md sections 2-3). Standard library only. + +Polynomials (Poly) in (r, b, k, x1, x2) over Q, truncated at r^NR; closed-form numbers (Num) + sum q * pi^(h/2) * sqrt(m) * theta^e, q rational, h integer, m squarefree, e in {0, 1}, +where theta = M(0, 0) is the one cone atom of d = 3 (section 3.3). Each coefficient is returned as a Num times one +Gamma atom: c = Num * Gamma(1/6) 12^(-1/6), c2 = Num * Gamma(5/6) 12^(-5/6).""" +from fractions import Fraction as Fr +import itertools +import math + +import pseries as P + +NR = 6 +VARS = ('r', 'b', 'k', 'x1', 'x2') +NV = len(VARS) +ONE = (0,) * NV +MUTANT = None + + +# ------------------------------------------------------------------------------------------- multivariate polynomials +class Poly: + __slots__ = ('t',) + + def __init__(self, t=None): + self.t = {e: c for e, c in (t or {}).items() if c} + + @staticmethod + def var(name, power=1): + e = [0] * NV + e[VARS.index(name)] = power + return Poly({tuple(e): Fr(1)}) + + @staticmethod + def const(c): + return Poly({ONE: Fr(c)}) + + def __add__(self, o): + if not isinstance(o, Poly): + o = Poly.const(o) + t = dict(self.t) + for e, c in o.t.items(): + t[e] = t.get(e, 0) + c + return Poly(t) + __radd__ = __add__ + + def __neg__(self): + return Poly({e: -c for e, c in self.t.items()}) + + def __sub__(self, o): + return self + (-o if isinstance(o, Poly) else Poly.const(-o)) + + def __mul__(self, o): + if not isinstance(o, Poly): + o = Fr(o) + return Poly({e: c * o for e, c in self.t.items()}) + t = {} + for e1, c1 in self.t.items(): + for e2, c2 in o.t.items(): + if e1[0] + e2[0] > NR: + continue + e = tuple(a + b for a, b in zip(e1, e2)) + t[e] = t.get(e, 0) + c1 * c2 + return Poly(t) + __rmul__ = __mul__ + + def rcoef(self, n): + return Poly({(0,) + e[1:]: c for e, c in self.t.items() if e[0] == n}) + + def degree(self, name): + i = VARS.index(name) + return max((e[i] for e in self.t), default=0) + + def coef_of(self, name, p): + i = VARS.index(name) + return Poly({e[:i] + (0,) + e[i + 1:]: c for e, c in self.t.items() if e[i] == p}) + + def scalar(self): + if set(self.t) - {ONE}: + raise ValueError('not a constant: %r' % (self.t,)) + return self.t.get(ONE, Fr(0)) + + def subs(self, name, poly): + i = VARS.index(name) + out, powers = Poly(), [Poly.const(1)] + for e, c in self.t.items(): + while len(powers) <= e[i]: + powers.append(powers[-1] * poly) + out = out + Poly({e[:i] + (0,) + e[i + 1:]: c}) * powers[e[i]] + return out + + def is_zero(self): + return not self.t + + +def from_series(s): + return Poly({(i,) + (0,) * (NV - 1): c for i, c in enumerate(s.c[:NR + 1]) if c}) + + +# ------------------------------------------------------------------------------------------- closed-form numbers +def squarefree(n): + q, m, p = 1, 1, 2 + while p * p <= n: + while n % (p * p) == 0: + n //= p * p + q *= p + if n % p == 0: + n //= p + m *= p + p += 1 + return q, m * n + + +def sqrt_frac(x): + x = Fr(x) + if x <= 0: + raise ValueError('sqrt of a non-positive rational') + q, m = squarefree(x.numerator * x.denominator) + return Fr(q, x.denominator), m + + +class Num: + __slots__ = ('t',) + + def __init__(self, t=None): + self.t = {k: v for k, v in (t or {}).items() if v} + + @staticmethod + def rat(q): + return Num({(0, 1, 0): Fr(q)}) + + @staticmethod + def sqrt(x): + q, m = sqrt_frac(x) + return Num({(0, m, 0): q}) + + @staticmethod + def pi_half(h): + return Num({(h, 1, 0): Fr(1)}) + + def __add__(self, o): + t = dict(self.t) + for k, v in o.t.items(): + t[k] = t.get(k, 0) + v + return Num(t) + + def __neg__(self): + return Num({k: -v for k, v in self.t.items()}) + + def __sub__(self, o): + return self + (-o) + + def __eq__(self, o): + return isinstance(o, Num) and not (self - o).t + + def __mul__(self, o): + if not isinstance(o, Num): + return Num({k: v * Fr(o) for k, v in self.t.items()}) + t = {} + for (h1, m1, e1), v1 in self.t.items(): + for (h2, m2, e2), v2 in o.t.items(): + g = math.gcd(m1, m2) + key = (h1 + h2, (m1 // g) * (m2 // g), e1 + e2) + t[key] = t.get(key, 0) + v1 * v2 * g + return Num(t) + __rmul__ = __mul__ + + def text(self): + parts = [] + for (h, m, e), v in sorted(self.t.items()): + s = str(v) + if m != 1: + s += ' sqrt(%d)' % m + if h: + s += ' pi^(%s)' % Fr(h, 2) + if e: + s += ' theta' + ('' if e == 1 else '^%d' % e) + parts.append(s) + return ' + '.join(parts) if parts else '0' + + +# ------------------------------------------------------------------------------------------- the kernel A_r +def forms_for(d): + forms = {} + for nm, sg in (('M', -1), ('S', 1)): + for i in range(d): + for j in range(i, d): + be = [0] * d + be[i] += 1 + be[j] += 1 + forms[(nm, i, j)] = P.deriv_at(tuple(be), sg, d) + trans = [] + for i in range(1, d): + for j in range(i, d): + be = [0] * d + be[i] += 1 + be[j] += 1 + forms[('T', i, j)] = {tuple(be): P.S.const(1)} + trans.append(('T', i, j)) + return forms, trans + + +def matchings(lst): + if not lst: + yield [] + return + f, rest = lst[0], lst[1:] + for mm in matchings(rest): + yield mm + for i, y in enumerate(rest): + for mm in matchings(rest[:i] + rest[i + 1:]): + yield [(f, y)] + mm + + +def perm_sign(p): + return -1 if sum(1 for i in range(len(p)) for j in range(i + 1, len(p)) if p[i] > p[j]) % 2 else 1 + + +def series_pow(x, alpha): + """(1 + x)^alpha for a Poly x without r^0 part""" + out, term, coef = Poly.const(1), Poly.const(1), Fr(1) + for n in range(1, NR + 1): + coef = coef * (Fr(alpha) - (n - 1)) / n + term = term * x + out = out + term * coef + return out + + +def series_exp(x): + out, term = Poly.const(1), Poly.const(1) + for n in range(1, NR + 1): + term = term * x * Fr(1, n) + out = out + term + return out + + +def kernel_data(d): + """A~_r(b, k) = const * [cone integral of exp(-(q0 + Q0)/2) G w] / r^2 (NOTE.md 2.3; the fixed-cone surrogate), with + w = 1 (d = 1), da over a < 0 (d = 2), (x1 - x2) dx over x2 < x1 < 0 (d = 3; the factor pi is in const).""" + forms, trans = forms_for(d) + pin = P.Pinned(d, forms) + p, nt = pin.p, len(trans) + r, b, k = Poly.var('r'), Poly.var('b'), Poly.var('k') + tgt = 11 if MUTANT == 'target' else 12 + v = [b - k * r * r * r * Fr(1, 2), -(k * r * r), Poly(), k * tgt] + [Poly()] * (p - 4) + mean = {u: sum((from_series(pin.G[u][j]) * v[j] for j in range(p)), Poly()) for u in pin.names} + hn = [u for u in pin.names if u not in trans] + if nt: + CTT = [[pin.C[(x, y)] for y in trans] for x in trans] + CTTinv = P.mat_inv(CTT) + detT = P.mat_det(CTT) + B = {u: [sum((pin.C[(u, trans[j])] * CTTinv[j][i] for j in range(nt)), P.S()) for i in range(nt)] for u in hn} + cp = {(u, w): from_series(pin.C[(u, w)] - sum((B[u][i] * pin.C[(trans[i], w)] for i in range(nt)), P.S())) + for u in hn for w in hn} + tval = {('T', 1, 1): Poly.var('x1'), ('T', 1, 2): Poly(), ('T', 2, 2): Poly.var('x2')} + zT = [tval[nm] - mean[nm] for nm in trans] + aff = {u: mean[u] + sum((from_series(B[u][i]) * zT[i] for i in range(nt)), Poly()) for u in hn} + else: + CTTinv, detT, zT = [], P.S.const(1), [] + cp = {(u, w): from_series(pin.C[(u, w)]) for u in hn for w in hn} + aff = dict((u, mean[u]) for u in hn) + F = Poly() # E[det H_M det H_S | T, U_r = v_r] by Isserlis + for pp in itertools.permutations(range(d)): + for qq in itertools.permutations(range(d)): + fac = [('M', min(i, pp[i]), max(i, pp[i])) for i in range(d)] + \ + [('S', min(i, qq[i]), max(i, qq[i])) for i in range(d)] + sg = perm_sign(pp) * perm_sign(qq) + for mt in matchings(list(range(2 * d))): + used = set(i for pr in mt for i in pr) + c = Poly.const(sg) + for (i, j) in mt: + c = c * cp[(fac[i], fac[j])] + for i in range(2 * d): + if i not in used: + c = c * aff[fac[i]] + F = F + c + q = sum((v[i] * from_series(pin.Sinv[i][j]) * v[j] for i in range(p) for j in range(p)), Poly()) + Q = sum((zT[i] * from_series(CTTinv[i][j]) * zT[j] for i in range(nt) for j in range(nt)), Poly()) + q0, Q0 = q.rcoef(0), Q.rcoef(0) + detS0, detT0 = pin.detS.c[0], detT.c[0] + ratio = from_series(pin.detS) * (1 / detS0) * from_series(detT) * (1 / detT0) - Poly.const(1) + G = series_pow(ratio, Fr(-1, 2)) * series_exp(((q - q0) + (Q - Q0)) * Fr(-1, 2)) * F + nn = p + nt + const = Num.rat(-12) * Num.sqrt(Fr(1, 2 ** nn)) * Num.pi_half(-nn) * Num.sqrt(Fr(1) / (detS0 * detT0)) + if d == 3: + const = const * Num.pi_half(2) + return {'G': G, 'q0': q0, 'Q0': Q0, 'const': const, 'p': p, 'detS0': detS0, 'detT0': detT0, 'F': F} + + +# ------------------------------------------------------------------------------------------- the integrations +SPHERE = {1: Num.rat(2), 2: Num.pi_half(2) * 2, 3: Num.pi_half(2) * 4} + + +def half_moment(j, c): + """int_0^oo t^j e^(-c t^2) dt = Gamma((j+1)/2) c^(-(j+1)/2)/2 (c > 0 rational)""" + if j % 2 == 0: + g = Fr(1) + for i in range(j // 2): + g *= Fr(2 * i + 1, 2) + return Num.pi_half(1) * Num.sqrt(Fr(1) / c) * (g / c ** (j // 2) / 2) + m = (j + 1) // 2 + return Num.rat(Fr(math.factorial(m - 1)) / c ** m / 2) + + +def quadrant_moments(al, be, ga, nmax): + """M(i, j) = int int_(s, t > 0) s^i t^j exp(-(al s^2 + be s t + ga t^2)) ds dt, i + j <= nmax, from + (i) 2 al M(i+1, j) + be M(i, j+1) = i M(i-1, j) + [i = 0] H_j(ga), + (ii) be M(i+1, j) + 2 ga M(i, j+1) = j M(i, j-1) + [j = 0] H_i(al) (H the half-line moments), + integration by parts in s and in t. M(0, 0) = theta = (pi/2 - arctan(be/sqrt(D)))/sqrt(D), D = 4 al ga - be^2. + Every M(i+1, j) with j >= 1 is reached twice (from (i, j) and from (i+1, j-1)); the two values must agree.""" + D = 4 * al * ga - be * be + if not (D > 0 and al > 0 and ga > 0): + raise ValueError('cone exponent not positive definite') + M = {(0, 0): Num({(0, 1, 1): Fr(1)})} + for n in range(nmax): + for i in range(n + 1): + j = n - i + R1 = (M[(i - 1, j)] * i if i else half_moment(j, ga)) + R2 = (M[(i, j - 1)] * j if j else half_moment(i, al)) + vals = (((i + 1, j), (R1 * (2 * ga) - R2 * be) * (Fr(1) / D)), + ((i, j + 1), (R2 * (2 * al) - R1 * be) * (Fr(1) / D))) + for key, val in vals: + if key in M: + if not M[key] == val: + raise ArithmeticError('quadrant recurrence inconsistent at %r' % (key,)) + else: + M[key] = val + return M, D + + +def gamma_ratio(a, a0): + """Gamma(a)/Gamma(a0) for a - a0 an integer (exact)""" + out, x = Fr(1), Fr(a0) + while x < a: + out *= x + x += 1 + while x > a: + x -= 1 + out /= x + return out + + +def coefficient(d, which, data=None): + """which = 0: c = (|S^(d-1)|/3) int db int_0^oo A_0 k^(-2/3) dk; + which = 2: c2 = (|S^(d-1)|/3) int db f.p. int_0^oo A_2 k^(-4/3) dk (the finite part = the subtraction of A_2(b, 0)). + Returns (Num, Gamma atom, info).""" + D_ = data or kernel_data(d) + G = D_['G'] + for n in (0, 1): + if not G.rcoef(n).is_zero(): + raise ArithmeticError('integrand does not vanish to order r^2') + if not G.rcoef(3).is_zero(): + raise ArithmeticError('A_r has an r^1 term') + H = G.rcoef(which + 2) + E = (D_['q0'] + D_['Q0']) * Fr(1, 2) + # --- k: E = ak k^2 + (k-free part) + ak = E.coef_of('k', 2).scalar() + if not (E.coef_of('k', 1).is_zero() and E.degree('k') == 2 and ak == 12): + raise ArithmeticError('unexpected k-dependence of the exponent') + a0 = Fr(1, 6) if which == 0 else Fr(5, 6) + expo = Fr(-2, 3) if which == 0 else Fr(-4, 3) + Hk = Poly() + for j in range(H.degree('k') + 1): + cj = H.coef_of('k', j) + if cj.is_zero(): + continue + if j % 2: + raise ArithmeticError('odd power of k') + # int_0^oo k^(j + expo) e^(-12 k^2) dk (finite part) = Gamma(a) 12^(-a)/2, a = (j + expo + 1)/2 + a = (j + expo + 1) / 2 + if MUTANT == 'finite-part' and j == 0 and which == 2: + a = a0 # drops the subtraction of A_2(b, 0): Gamma(-1/6) replaced by Gamma(5/6) + shift = a - a0 + Hk = Hk + cj * (gamma_ratio(a, a0) * Fr(12) ** (-int(shift)) / 2) + katom = 'Gamma(1/6) 12^(-1/6)' if which == 0 else 'Gamma(5/6) 12^(-5/6)' + # --- b: k-free exponent = ab b^2 + b L(x) + R(x); complete the square + Ek = E.coef_of('k', 0) + ab = Ek.coef_of('b', 2).scalar() + if Ek.degree('b') != 2: + raise ArithmeticError('exponent not quadratic in b') + Lx, Rx = Ek.coef_of('b', 1), Ek.coef_of('b', 0) + shifted = Hk.subs('b', Poly.var('b') - Lx * (Fr(1) / (2 * ab))) + Hb = {} + for e, c in shifted.t.items(): + if e[1] % 2: + continue + key = e[3:] + Hb[key] = Hb.get(key, Num()) + half_moment(e[1], ab) * (2 * c) + if not Hb: + raise ArithmeticError('empty integrand: the r-truncation is too low') + Ex = Rx - Lx * Lx * (Fr(1) / (4 * ab)) + total, info = Num(), {} + if d == 1: + if not Ex.is_zero(): + raise ArithmeticError('d = 1: residual exponent') + for val in Hb.values(): + total = total + val + elif d == 2: + g = Ex.coef_of('x1', 2).scalar() + if not (Ex.degree('x1') == 2 and Ex.coef_of('x1', 1).is_zero() and Ex.coef_of('x1', 0).is_zero()): + raise ArithmeticError('d = 2: cone exponent') + for key, val in Hb.items(): + total = total + val * half_moment(key[0], g) * (-1) ** key[0] # int over a < 0 + info['gamma_a'] = g + else: + X1, X2 = -Poly.var('x1'), -Poly.var('x1') - Poly.var('x2') # x1 = -s, x2 = -s - t (s -> x1, t -> x2 slots) + + def subst(poly): + out = Poly() + for e, c in poly.t.items(): + term = Poly({e[:3] + (0, 0): c}) + for _ in range(e[3]): + term = term * X1 + for _ in range(e[4]): + term = term * X2 + out = out + term + return out + Est = subst(Ex) + al = Est.coef_of('x1', 2).coef_of('x2', 0).scalar() + ga = Est.coef_of('x2', 2).coef_of('x1', 0).scalar() + be = Est.coef_of('x1', 1).coef_of('x2', 1).scalar() + chk = Poly.var('x1', 2) * al + Poly.var('x1') * Poly.var('x2') * be + Poly.var('x2', 2) * ga + if not (Est - chk).is_zero(): + raise ArithmeticError('d = 3: cone exponent not a quadratic form') + nmax = max(key[0] + key[1] for key in Hb) + 2 + M, Dc = quadrant_moments(al, -be if MUTANT == 'cone-sign' else be, ga, nmax) + for key, val in Hb.items(): + mono = subst(Poly({(0, 0, 0) + key: Fr(1)})) * Poly.var('x2') # weight x1 - x2 = t + for e, c in mono.t.items(): + total = total + val * M[(e[3], e[4])] * c + info.update({'alpha': al, 'beta': be, 'gamma': ga, 'D': Dc}) + value = SPHERE[d] * Fr(1, 3) * D_['const'] * total + return value, katom, info diff --git a/frontiers/c2_torus_transfer_20261001/pseries.py b/frontiers/c2_torus_transfer_20261001/pseries.py new file mode 100644 index 000000000..fac3c562b --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/pseries.py @@ -0,0 +1,203 @@ +"""Exact truncated power series in the separation r, and the pinned two-point structure (NOTE.md section 2). + +Field: centred Gaussian on R^d with covariance K(z) = exp(-|z|^2/2), so Cov(d^a f(0), d^b f(0)) = (-1)^|b| d^(a+b) K(0), +d^g K(0) = prod_i (-1)^(g_i/2) (g_i - 1)!! for even g and 0 otherwise. Points M = -r e1/2, S = +r e1/2. + +Every quantity is a linear form in the jets at 0 whose coefficients are power series in r: + d^beta f(x e1) = sum_j x^j/j! d^(beta + j e1) f(0), x = -+ r/2. +A Series keeps the coefficients of r^0..r^R exactly (Fractions). The pin rows divide by r, r and r^3; each division is +exact (the low coefficients vanish identically, which `shift` asserts), and costs at most three orders, so every derived +series is exact through r^(R - 3) = r^7. The certificate needs r^6 (exact.NR).""" +from fractions import Fraction as Fr + +R = 10 + + +class S: + """a power series c_0 + c_1 r + ... + c_R r^R over Q (higher orders dropped)""" + __slots__ = ('c',) + + def __init__(self, c=None): + c = list(c or []) + self.c = (c + [Fr(0)] * (R + 1))[:R + 1] + + @staticmethod + def const(x): + return S([Fr(x)]) + + def __add__(self, o): + if not isinstance(o, S): + o = S.const(o) + return S([a + b for a, b in zip(self.c, o.c)]) + __radd__ = __add__ + + def __neg__(self): + return S([-a for a in self.c]) + + def __sub__(self, o): + return self + (-o if isinstance(o, S) else S.const(-o)) + + def __rsub__(self, o): + return (-self) + o + + def __mul__(self, o): + if not isinstance(o, S): + return S([a * o for a in self.c]) + out = [Fr(0)] * (R + 1) + for i, a in enumerate(self.c): + if a: + for j in range(R + 1 - i): + if o.c[j]: + out[i + j] += a * o.c[j] + return S(out) + __rmul__ = __mul__ + + def inv(self): + a0 = self.c[0] + if a0 == 0: + raise ZeroDivisionError('series with zero constant term') + out = [Fr(0)] * (R + 1) + out[0] = 1 / a0 + for n in range(1, R + 1): + out[n] = -sum(self.c[k] * out[n - k] for k in range(1, n + 1)) / a0 + return S(out) + + def is_zero(self): + return not any(self.c) + + +def dfact(n): + out = 1 + while n > 1: + out *= n + n -= 2 + return out + + +def rho_der(g): + """d^g K(0) for K = exp(-|z|^2/2)""" + if any(x % 2 for x in g): + return 0 + out = 1 + for x in g: + out *= (-1) ** (x // 2) * dfact(x - 1) + return out + + +def cov(u, w): + """Cov of two linear forms (dict jet -> S)""" + tot = S() + for a, sa in u.items(): + for b, sb in w.items(): + v = rho_der(tuple(x + y for x, y in zip(a, b))) + if v: + tot = tot + sa * sb * ((-1) ** sum(b) * v) + return tot + + +def deriv_at(beta, sign, d): + """d^beta f at x = sign r/2 along e1, as jets: sum_(j <= R) (sign/2)^j r^j/j! d^(beta + j e1) f(0)""" + out = {} + fact = 1 + for j in range(R + 1): + if j: + fact *= j + c = [Fr(0)] * (R + 1) + c[j] = Fr(sign, 2) ** j / fact + out[(beta[0] + j,) + tuple(beta[1:])] = S(c) + return out + + +def lin(*terms): + """sum of coef * form""" + out = {} + for coef, form in terms: + for g, s in form.items(): + out[g] = out.get(g, S()) + s * coef + return {g: s for g, s in out.items() if not s.is_zero()} + + +def shift(form, p): + """divide by r^p; the coefficients of r^0..r^(p-1) must vanish identically""" + out = {} + for g, s in form.items(): + if any(x != 0 for x in s.c[:p]): + raise ArithmeticError('inexact division by r^%d at jet %r' % (p, g)) + out[g] = S(s.c[p:]) + return out + + +def pin_rows(d): + """The symmetric pin vector U_r of [R] section 2 (Math-#216 c2_check.py Pinned.pin_rows): + (f(M) + f(S))/2, (f(S) - f(M))/r, (f_x(S) - f_x(M))/r, 6/r^2 (f_x(M) + f_x(S) - 2 (f(S) - f(M))/r), + and for each transverse direction y: (f_y(M) + f_y(S))/2, (f_y(S) - f_y(M))/r. + Target v_r = (b - k r^3/2, -k r^2, 0, 12 k, 0, ..., 0).""" + e0 = (0,) * d + ex = (1,) + (0,) * (d - 1) + fa, fc = deriv_at(e0, -1, d), deriv_at(e0, 1, d) + fxa, fxc = deriv_at(ex, -1, d), deriv_at(ex, 1, d) + rows = [lin((Fr(1, 2), fa), (Fr(1, 2), fc)), + shift(lin((1, fc), (-1, fa)), 1), + shift(lin((1, fxc), (-1, fxa)), 1)] + num = lin((1, fxa), (1, fxc), (-2, shift(lin((1, fc), (-1, fa)), 1))) + rows.append({g: s * 6 for g, s in shift(num, 2).items()}) + for t in range(1, d): + ey = tuple(1 if i == t else 0 for i in range(d)) + ya, yc = deriv_at(ey, -1, d), deriv_at(ey, 1, d) + rows += [lin((Fr(1, 2), ya), (Fr(1, 2), yc)), shift(lin((1, yc), (-1, ya)), 1)] + return rows + + +def mat_inv(M): + """inverse of a square matrix of series whose r^0 part is invertible (Gauss-Jordan over Q[[r]])""" + n = len(M) + A = [row[:] + [S.const(int(i == j)) for j in range(n)] for i, row in enumerate(M)] + for c in range(n): + p = next(i for i in range(c, n) if A[i][c].c[0] != 0) + A[c], A[p] = A[p], A[c] + iv = A[c][c].inv() + A[c] = [x * iv for x in A[c]] + for i in range(n): + if i != c and not A[i][c].is_zero(): + f = A[i][c] + A[i] = [x - f * y for x, y in zip(A[i], A[c])] + return [row[n:] for row in A] + + +def mat_det(M): + n = len(M) + A = [row[:] for row in M] + det = S.const(1) + for c in range(n): + p = next(i for i in range(c, n) if A[i][c].c[0] != 0) + if p != c: + A[c], A[p] = A[p], A[c] + det = -det + det = det * A[c][c] + iv = A[c][c].inv() + for i in range(c + 1, n): + if not A[i][c].is_zero(): + f = A[i][c] * iv + A[i] = [x - f * y for x, y in zip(A[i], A[c])] + return det + + +class Pinned: + """conditional law of linear forms given U_r: mean G v (G[u][j] series), covariance C[(u, w)] (series)""" + + def __init__(self, d, forms): + self.d = d + self.rows = pin_rows(d) + p = len(self.rows) + self.p = p + Sm = [[cov(a, b) for b in self.rows] for a in self.rows] + self.Sinv = mat_inv(Sm) + self.detS = mat_det(Sm) + self.names = list(forms) + CF = {u: [cov(forms[u], row) for row in self.rows] for u in self.names} + self.G = {u: [sum((CF[u][q] * self.Sinv[q][j] for q in range(p)), S()) for j in range(p)] for u in self.names} + self.C = {} + for i, u in enumerate(self.names): + for w in self.names[i:]: + val = cov(forms[u], forms[w]) - sum((self.G[u][q] * CF[w][q] for q in range(p)), S()) + self.C[(u, w)] = self.C[(w, u)] = val diff --git a/frontiers/c2_torus_transfer_20261001/transfer.py b/frontiers/c2_torus_transfer_20261001/transfer.py new file mode 100644 index 000000000..05dc3fba1 --- /dev/null +++ b/frontiers/c2_torus_transfer_20261001/transfer.py @@ -0,0 +1,707 @@ +"""CL-C2-TORUS-TRANSFER-20261001: the third-order coefficient c2 on the finite torus, d = 1, 2, 3, every L >= L0 and +every orthonormal frame, against the closed form of frontiers/c2_exact_20261001 (NOTE.md). Standard library only. + + python3 -B -S transfer.py print the bounds + python3 -B -S transfer.py --write write RESULTS.json + python3 -B -S transfer.py --check recompute everything and compare with RESULTS.json (exit 1 on mismatch) + python3 -B -S transfer.py --mutant NAME run --check with a seeded defect (must exit 1) + +Pipeline (NOTE.md sections 1-4): + 1. jet covariances of the normalized periodic kernel K_L as balls around the Gaussian ones (Lemma J); + 2. the exact derivation of c2_exact (pin rows, conditioning, Isserlis, exp/det expansion) re-run in ball arithmetic, + with the full transverse block T = (T11, T22, T12) in d = 3 (no rotation reduction): the r^4 coefficient + H(b, k, x) of the integrand, the exponent E = (q0 + Q0)/2 and the determinants, as balls (Lemma P); + 3. the finite-part lemma and explicit Gaussian moment bounds for the difference of the two integrands (Lemmas F, G).""" +from fractions import Fraction as Fr +import itertools +import json +import math +import os +import sys + +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +from ball import (B, rup, center, radius, mag, exp_up, isqrt_frac_dn, PI_UP, PI_DN) # noqa: E402 +import pseries as P # noqa: E402 + +P.R = 8 # series exact through r^(R - 3) = r^5; the certificate needs r^4 +NR = 4 # polynomial truncation in r: the r^4 coefficient is the A_2 integrand +VARS = ('r', 'b', 'k', 'x1', 'x2', 'x3') +NV = len(VARS) +ONE = (0,) * NV +MUTANT = None +MUTANTS = ('no-image', 'no-theta', 'drop-ratio', 'eta-half', 'fp-const') +L0S = (10, 12, 16, 24) +HERE = os.path.dirname(os.path.abspath(__file__)) + + +def require(cond, msg): + if not cond: + raise AssertionError(msg) + + +# ============================================================================== 1. jet covariances (Lemma J) +def rho_der(g): + """d^g phi(0) for phi(z) = exp(-|z|^2/2) (exact integer)""" + return P.rho_der(g) + + +def he_major(m): + """coefficients of the majorant He*_m(s) = sum_j m!/(j! (m-2j)! 2^j) s^(m-2j) of the Hermite polynomial He_m: + |He_m(t)| <= He*_m(|t|), He* nondecreasing on [0, oo)""" + return {m - 2 * j: Fr(math.factorial(m), math.factorial(j) * math.factorial(m - 2 * j) * 2 ** j) + for j in range(m // 2 + 1)} + + +def he_major_at(m, s): + return sum((c * s ** p for p, c in he_major(m).items()), Fr(0)) + + +def shells(d, S=4): + """{s: #{n in Z^d : |n|^2 = s}} for 1 <= s <= S (every such n has |n_i| <= 2)""" + cnt = {} + for n in itertools.product(range(-2, 3), repeat=d): + s = sum(x * x for x in n) + if 1 <= s <= S: + cnt[s] = cnt.get(s, 0) + 1 + return cnt + + +class Images: + """Image sums of the periodization, bounded for every real L >= L0 and every orthonormal frame (Lemma J).""" + + def __init__(self, d, L0): + self.d, self.L0 = d, Fr(L0) + self.sh = shells(d) + self.cache = {} + self.theta1 = self.image(0) + + def image(self, m_tot, g=None): + """upper bound of sum_{n != 0} prod_i |He_{g_i}(p_i)| phi(p), p = L R n (|p| = L |n|, any rotation R)""" + d, L = self.d, self.L0 + g = g if g is not None else (0,) * d + key = tuple(sorted(g)) + if key in self.cache: + return self.cache[key] + n = sum(g) + require(n * n <= 5 * L * L and n <= L * L, 'jet order outside the range of Lemma J') + tot = Fr(0) + for s, c in sorted(self.sh.items()): + sq = L * L * s + t = Fr(c) * exp_up(-sq / 2) + from ball import isqrt_frac_up + hs = isqrt_frac_up(sq) + for gi in g: + t *= he_major_at(gi, hs) + tot += t + a2 = d + n # 2a, a = (d + |g|)/2 <= 20 + require(a2 <= 40, 'tail exponent') + tail = Fr(3) ** d * (2 * L) ** n * 2 * Fr(5) ** ((a2 + 1) // 2) * exp_up(-5 * L * L / 2) + val = rup(tot + tail) + self.cache[key] = val + return val + + def jetcov(self, g): + """d^g K_L(0) as a ball around d^g phi(0)""" + ref = rho_der(g) + if sum(g) % 2: + return B(0) # K_L is even: every odd total order vanishes exactly + if MUTANT == 'no-image': + return B(ref, self.theta1 * abs(ref)) + if MUTANT == 'no-theta': + return B(ref, self.image(sum(g), g)) + return B(ref, self.image(sum(g), g) + self.theta1 * abs(ref)) + + +# ============================================================================== 2. series and polynomials over balls +class S: + """power series c_0 + ... + c_R r^R with Fraction or ball coefficients""" + __slots__ = ('c',) + + def __init__(self, c=None): + c = list(c or []) + self.c = (c + [Fr(0)] * (P.R + 1))[:P.R + 1] + + @staticmethod + def const(x): + return S([x]) + + def __add__(self, o): + if not isinstance(o, S): + o = S.const(o) + return S([a + b for a, b in zip(self.c, o.c)]) + __radd__ = __add__ + + def __neg__(self): + return S([-a for a in self.c]) + + def __sub__(self, o): + return self + (-o) + + def __mul__(self, o): + if not isinstance(o, S): + return S([a * o for a in self.c]) + out = [Fr(0)] * (P.R + 1) + for i, a in enumerate(self.c): + if a: + for j in range(P.R + 1 - i): + if o.c[j]: + out[i + j] = out[i + j] + a * o.c[j] + return S(out) + __rmul__ = __mul__ + + def inv(self): + a0 = self.c[0] + ia = a0.inv() if isinstance(a0, B) else 1 / Fr(a0) + out = [Fr(0)] * (P.R + 1) + out[0] = ia + for n in range(1, P.R + 1): + acc = Fr(0) + for k in range(1, n + 1): + if self.c[k] and out[n - k]: + acc = acc + self.c[k] * out[n - k] + out[n] = -(acc * ia) + return S(out) + + def is_zero(self): + return not any(self.c) + + +def from_pseries(s): + return S(list(s.c)) + + +def cov(u, w, jetcov): + tot = S() + for a, sa in u.items(): + for b, sb in w.items(): + g = tuple(x + y for x, y in zip(a, b)) + v = jetcov(g) + if v: + tot = tot + from_pseries(sa * sb) * (v * (-1) ** sum(b)) + return tot + + +def mat_inv(M): + n = len(M) + A = [row[:] + [S.const(Fr(int(i == j))) for j in range(n)] for i, row in enumerate(M)] + for c in range(n): + p = next(i for i in range(c, n) if center(A[i][c].c[0]) != 0) + A[c], A[p] = A[p], A[c] + iv = A[c][c].inv() + A[c] = [x * iv for x in A[c]] + for i in range(n): + if i != c and not A[i][c].is_zero(): + f = A[i][c] + A[i] = [x - f * y for x, y in zip(A[i], A[c])] + return [row[n:] for row in A] + + +def mat_det(M): + n = len(M) + A = [row[:] for row in M] + det = S.const(Fr(1)) + for c in range(n): + p = next(i for i in range(c, n) if center(A[i][c].c[0]) != 0) + if p != c: + A[c], A[p] = A[p], A[c] + det = -det + det = det * A[c][c] + iv = A[c][c].inv() + for i in range(c + 1, n): + if not A[i][c].is_zero(): + f = A[i][c] * iv + A[i] = [x - f * y for x, y in zip(A[i], A[c])] + return det + + +class Poly: + """polynomial in (r, b, k, x1, x2, x3), truncated at r^NR, Fraction or ball coefficients""" + __slots__ = ('t',) + + def __init__(self, t=None): + self.t = {e: c for e, c in (t or {}).items() if c} + + @staticmethod + def var(name, power=1): + e = [0] * NV + e[VARS.index(name)] = power + return Poly({tuple(e): Fr(1)}) + + @staticmethod + def const(c): + return Poly({ONE: c}) + + def __add__(self, o): + if not isinstance(o, Poly): + o = Poly.const(o) + t = dict(self.t) + for e, c in o.t.items(): + t[e] = t[e] + c if e in t else c + return Poly(t) + __radd__ = __add__ + + def __neg__(self): + return Poly({e: -c for e, c in self.t.items()}) + + def __sub__(self, o): + return self + (-o if isinstance(o, Poly) else Poly.const(-o)) + + def __mul__(self, o): + if not isinstance(o, Poly): + return Poly({e: c * o for e, c in self.t.items()}) + t = {} + for e1, c1 in self.t.items(): + for e2, c2 in o.t.items(): + if e1[0] + e2[0] > NR: + continue + e = tuple(a + b for a, b in zip(e1, e2)) + v = c1 * c2 + t[e] = t[e] + v if e in t else v + return Poly(t) + __rmul__ = __mul__ + + def rcoef(self, n): + return Poly({(0,) + e[1:]: c for e, c in self.t.items() if e[0] == n}) + + def r_positive(self): + """the part with r-degree >= 1 (removes the r^0 terms; no subtraction of equal balls)""" + return Poly({e: c for e, c in self.t.items() if e[0] >= 1}) + + def deriv(self, name): + i = VARS.index(name) + return Poly({e[:i] + (e[i] - 1,) + e[i + 1:]: c * e[i] for e, c in self.t.items() if e[i]}) + + def subs_zero(self, name): + i = VARS.index(name) + return Poly({e: c for e, c in self.t.items() if e[i] == 0}) + + def centers(self): + return Poly({e: center(c) for e, c in self.t.items()}) + + def is_zero(self): + return not self.t + + +def from_series(s): + return Poly({(i,) + (0,) * (NV - 1): c for i, c in enumerate(s.c[:NR + 1]) if c}) + + +def series_pow(x, alpha): + """(1 + x)^alpha for a Poly x with no r^0 part (exact through r^NR)""" + require(all(e[0] >= 1 for e in x.t), 'series_pow: r^0 part') + out, term, coef = Poly.const(Fr(1)), Poly.const(Fr(1)), Fr(1) + for n in range(1, NR + 1): + coef = coef * (Fr(alpha) - (n - 1)) / n + term = term * x + out = out + term * coef + return out + + +def series_exp(x): + require(all(e[0] >= 1 for e in x.t), 'series_exp: r^0 part') + out, term = Poly.const(Fr(1)), Poly.const(Fr(1)) + for n in range(1, NR + 1): + term = term * x * Fr(1, n) + out = out + term + return out + + +# ============================================================================== 3. the kernel (Lemma P) +def forms_for(d): + forms = {} + for nm, sg in (('M', -1), ('S', 1)): + for i in range(d): + for j in range(i, d): + be = [0] * d + be[i] += 1 + be[j] += 1 + forms[(nm, i, j)] = P.deriv_at(tuple(be), sg, d) + trans = [] + for i in range(1, d): + for j in range(i, d): + be = [0] * d + be[i] += 1 + be[j] += 1 + forms[('T', i, j)] = {tuple(be): P.S.const(1)} + trans.append(('T', i, j)) + return forms, trans + + +def matchings(lst): + if not lst: + yield [] + return + f, rest = lst[0], lst[1:] + for mm in matchings(rest): + yield mm + for i, y in enumerate(rest): + for mm in matchings(rest[:i] + rest[i + 1:]): + yield [(f, y)] + mm + + +def perm_sign(p): + return -1 if sum(1 for i in range(len(p)) for j in range(i + 1, len(p)) if p[i] > p[j]) % 2 else 1 + + +TVAL = {('T', 1, 1): 'x1', ('T', 2, 2): 'x2', ('T', 1, 2): 'x3'} + + +def kernel(d, jetcov): + """A~_r(b, k) = kappa * integral over the cone {T < 0} (x-coordinates, Lebesgue) of exp(-E) G / r^2, with + E = (q0 + Q0)/2 and kappa = -12 (2 pi)^(-(p + nT)/2) (det S0 det T0)^(-1/2) (NOTE.md 1.3; c2_exact NOTE 2.3).""" + forms, trans = forms_for(d) + rows = P.pin_rows(d) + p, nt = len(rows), len(trans) + Sm = [[cov(a, b_, jetcov) for b_ in rows] for a in rows] + Sinv, detS = mat_inv(Sm), mat_det(Sm) + names = list(forms) + CF = {u: [cov(forms[u], row, jetcov) for row in rows] for u in names} + G = {u: [sum((CF[u][q] * Sinv[q][j] for q in range(p)), S()) for j in range(p)] for u in names} + C = {} + for i, u in enumerate(names): + for w in names[i:]: + val = cov(forms[u], forms[w], jetcov) - sum((G[u][q] * CF[w][q] for q in range(p)), S()) + C[(u, w)] = C[(w, u)] = val + r, b, k = Poly.var('r'), Poly.var('b'), Poly.var('k') + v = [b - k * r * r * r * Fr(1, 2), -(k * r * r), Poly(), k * 12] + [Poly()] * (p - 4) + mean = {u: sum((from_series(G[u][j]) * v[j] for j in range(p)), Poly()) for u in names} + hn = [u for u in names if u not in trans] + if nt: + CTT = [[C[(x, y)] for y in trans] for x in trans] + CTTinv, detT = mat_inv(CTT), mat_det(CTT) + Bc = {u: [sum((C[(u, trans[j])] * CTTinv[j][i] for j in range(nt)), S()) for i in range(nt)] for u in hn} + cp = {(u, w): from_series(C[(u, w)] - sum((Bc[u][i] * C[(trans[i], w)] for i in range(nt)), S())) + for u in hn for w in hn} + zT = [Poly.var(TVAL[nm]) - mean[nm] for nm in trans] + aff = {u: mean[u] + sum((from_series(Bc[u][i]) * zT[i] for i in range(nt)), Poly()) for u in hn} + else: + CTTinv, detT, zT = [], S.const(Fr(1)), [] + cp = {(u, w): from_series(C[(u, w)]) for u in hn for w in hn} + aff = dict((u, mean[u]) for u in hn) + F = Poly() + for pp in itertools.permutations(range(d)): + for qq in itertools.permutations(range(d)): + fac = [('M', min(i, pp[i]), max(i, pp[i])) for i in range(d)] + \ + [('S', min(i, qq[i]), max(i, qq[i])) for i in range(d)] + sg = perm_sign(pp) * perm_sign(qq) + for mt in matchings(list(range(2 * d))): + used = set(i for pr in mt for i in pr) + c = Poly.const(Fr(sg)) + for (i, j) in mt: + c = c * cp[(fac[i], fac[j])] + for i in range(2 * d): + if i not in used: + c = c * aff[fac[i]] + F = F + c + q = sum((v[i] * from_series(Sinv[i][j]) * v[j] for i in range(p) for j in range(p)), Poly()) + Q = sum((zT[i] * from_series(CTTinv[i][j]) * zT[j] for i in range(nt) for j in range(nt)), Poly()) + q0, Q0 = q.rcoef(0), Q.rcoef(0) + detS0, detT0 = detS.c[0], detT.c[0] + # (det S_r / det S_0)(det T_r / det T_0) - 1 from the r >= 1 coefficients only (its r^0 part is exactly 0) + rS = Poly({(i,) + (0,) * (NV - 1): detS.c[i] * (1 / detS0 if not isinstance(detS0, B) else detS0.inv()) + for i in range(1, NR + 1) if detS.c[i]}) + i0 = (1 / detT0) if not isinstance(detT0, B) else detT0.inv() + rT = Poly({(i,) + (0,) * (NV - 1): detT.c[i] * i0 for i in range(1, NR + 1) if detT.c[i]}) + ratio = rS + rT + (rS * rT) + if MUTANT == 'drop-ratio': + ratio = rS + dqQ = (q.r_positive() + Q.r_positive()) * Fr(-1, 2) + Gint = series_pow(ratio, Fr(-1, 2)) * series_exp(dqQ) * F + return {'G': Gint, 'E': (q0 + Q0) * Fr(1, 2), 'p': p, 'nt': nt, 'detS0': detS0, 'detT0': detT0} + + +# ============================================================================== 4. bounds (Lemmas F, G) +WV = ('b', 'k', 'x1', 'x2', 'x3') + + +def strip_r(poly): + out = {} + for e, c in poly.t.items(): + require(e[0] == 0, 'strip_r: r-dependent term') + out[e[1:]] = c + return out + + +def quad_matrix(Ec, nv): + """symmetric matrix M with E(w) = w^T M w for the homogeneous quadratic E (centers)""" + M = [[Fr(0)] * nv for _ in range(nv)] + for e, c in Ec.items(): + require(sum(e) == 2, 'exponent not homogeneous quadratic') + idx = [i for i in range(nv) for _ in range(e[i])] + i, j = idx + if i == j: + M[i][i] += c + else: + M[i][j] += c / 2 + M[j][i] += c / 2 + return M + + +def is_pd(M): + n = len(M) + A = [row[:] for row in M] + for c in range(n): + if A[c][c] <= 0: + return False + for i in range(c + 1, n): + f = A[i][c] / A[c][c] + for j in range(c, n): + A[i][j] -= f * A[c][j] + return True + + +def diag_scale_lower(M): + """a rational t in (0, 1] with M - t diag(M) positive semidefinite (exact LDL checks, bisection to 2^-30), so that + w^T M w >= t sum_i M_ii w_i^2""" + n = len(M) + require(is_pd(M), 'reference exponent not positive definite') + + def ok(t): + return t == 0 or is_pd([[M[i][j] * (1 - t if i == j else 1) for j in range(n)] for i in range(n)]) or \ + (t == 1 and all(M[i][j] == 0 for i in range(n) for j in range(n) if i != j)) + if ok(Fr(1)): + return Fr(1) + lo, hi = Fr(0), Fr(1) + for _ in range(30): + mid = (lo + hi) / 2 + if ok(mid): + lo = mid + else: + hi = mid + require(lo > 0, 'diagonal scaling') + return lo + + +def gamma_half_up(n): + """upper bound of Gamma(n/2), n >= 1""" + if n % 2 == 0: + return Fr(math.factorial(n // 2 - 1)) + m = (n - 1) // 2 # Gamma(m + 1/2) = (2m-1)!! sqrt(pi) / 2^m + df = 1 + for i in range(1, 2 * m, 2): + df *= i + from ball import isqrt_frac_up + return Fr(df, 2 ** m) * isqrt_frac_up(PI_UP) + + +def pow_neg_half_up(a, n): + """upper bound of a^(-n/2), a > 0 rational""" + if n % 2 == 0: + return 1 / a ** (n // 2) + return 1 / (a ** (n // 2) * isqrt_frac_dn(a)) + + +def moment_up(n, a, half=False): + """upper bound of int_R |t|^n e^(-a t^2) dt = Gamma((n+1)/2) a^(-(n+1)/2) (half: over [0, oo), one half)""" + v = gamma_half_up(n + 1) * pow_neg_half_up(a, n + 1) + return v / 2 if half else v + + +def maj_poly(H, which): + """nonnegative majorant coefficients: which = 'mag' -> |c| + rad, 'rad' -> rad""" + out = {} + for e, c in H.items(): + v = mag(c) if which == 'mag' else radius(c) + if v: + out[e] = out.get(e, Fr(0)) + v + return out + + +def mono_mul(P1, P2): + out = {} + for e1, c1 in P1.items(): + for e2, c2 in P2.items(): + e = tuple(a + b for a, b in zip(e1, e2)) + out[e] = out.get(e, Fr(0)) + c1 * c2 + return out + + +def gauss_bound(Pm, a, mode, nx): + """upper bound of the integral of sum_e Pm[e] |w^e| e^(-sum_i a_i w_i^2) over b in R, x in R^nx, with k: + 'k0' k = 0; 'kw' integral over k in [0, 1] against k^(-1/3) (k^(j - 1/3) <= k^(j-1) for j >= 1, extended to + [0, oo); for j = 0, e^(-a k^2) <= 1 and int_0^1 k^(-1/3) dk = 3/2); 'kint' integral over k in [0, oo).""" + tot = Fr(0) + for e, c in Pm.items(): + eb, ek, ex = e[0], e[1], e[2:2 + nx] + require(all(v == 0 for v in e[2 + nx:]), 'unused transverse variable') + if mode == 'k0' and ek: + continue + t = c * moment_up(eb, a[0]) + for i, v in enumerate(ex): + t *= moment_up(v, a[2 + i]) + if mode == 'kint': + t *= moment_up(ek, a[1], half=True) + elif mode == 'kw': + t *= moment_up(ek - 1, a[1], half=True) if ek else Fr(3, 2) + tot += t + return tot + + +def eta_of(dE, nv): + """eta_i with |dE(w)| <= sum_i eta_i w_i^2 from the coefficient radii of the quadratic dE + (|w_i w_j| <= (w_i^2 + w_j^2)/2)""" + acc = [Fr(0)] * nv + for e, c in dE.items(): + rad = radius(c) + if not rad: + continue + require(sum(e) == 2, 'exponent radius on a non-quadratic monomial') + idx = [i for i in range(nv) for _ in range(e[i])] + i, j = idx + if i == j: + acc[i] += rad + else: + acc[i] += rad / 2 + acc[j] += rad / 2 + return [x / 2 for x in acc] if MUTANT == 'eta-half' else acc + + +SPHERE_UP = {1: Fr(2), 2: 2 * PI_UP, 3: 4 * PI_UP} +C2_REF_LO = {1: Fr('0.2300445802661503'), 2: Fr('0.2215244106266632'), 3: Fr('0.1612340491269447')} # c2_exact + + +def bound_core(d, D): + """Lemmas F and G: an upper bound of sup_u |c2[K, u] - c2[phi]| from the ball kernel data D of K (NOTE.md 4).""" + nx = D['nt'] + nv = 2 + nx + H = strip_r(D['G'].rcoef(4)) + E = strip_r(D['E']) + M = quad_matrix({e: center(c) for e, c in E.items()}, nv) + t = diag_scale_lower(M) # E_ref(w) >= t sum_i M_ii w_i^2 + eta = eta_of(E, nv) # |E_K(w) - E_ref(w)| <= sum_i eta_i w_i^2 + a = [t * M[i][i] - eta[i] for i in range(nv)] + require(all(x > 0 for x in a), 'exponent perturbation too large') + # kappa_K / kappa_ref = (D_K / D_ref)^(-1/2), D = det S0 det T0 + DK = D['detS0'] * D['detT0'] + Dref = center(DK) + require(Dref > 0, 'reference determinant') + rho = radius(DK) / Dref + require(rho < Fr(1, 2), 'determinant radius') + e_kappa = rho / (1 - rho) # |kappa_K/kappa_ref - 1| <= (1 - rho)^(-1/2) - 1 <= rho/(1 - rho) + nn = D['p'] + nx + kap = 12 / isqrt_frac_dn(Dref) # kappa_ref <= kap + two_pi = 2 * PI_DN + kap = kap / two_pi ** (nn // 2) + if nn % 2: + kap = kap / isqrt_frac_dn(two_pi) + # H' = dH/dk - (dE/dk) H: d/dk [exp(-E) H] = exp(-E) H' + Hp = Poly({(0,) + e: c for e, c in H.items()}) + Ep = Poly({(0,) + e: c for e, c in E.items()}) + Hd = strip_r(Hp.deriv('k') - Ep.deriv('k') * Hp) + fac = {(0,) * 5: e_kappa} # |e_kappa| + sum_i eta_i w_i^2 + for i in range(nv): + e = [0] * 5 + e[i] = 2 + fac[tuple(e)] = eta[i] + + def bound(Hx, mode): + return kap * gauss_bound(dict_add(mono_mul(fac, maj_poly(Hx, 'mag')), maj_poly(Hx, 'rad')), a, mode, nx) + fp_const = 3 if MUTANT != 'fp-const' else 1 + b0, b1, b2 = bound(H, 'k0'), bound(Hd, 'kw'), bound(H, 'kint') + T_bound = fp_const * b0 + 3 * b1 + b2 + eps = rup(SPHERE_UP[d] / 3 * T_bound) + return {'d': d, 't_diag': t, 'a_min': min(a), 'eta_max': max(eta), 'e_kappa': e_kappa, 'kappa_up': kap, 'Delta0': b0, 'dDelta_w': b1, + 'Delta_int': b2, 'eps': eps, 'max_radius_H': max((radius(c) for c in H.values()), default=Fr(0)), + 'n_monomials_H': len(H)} + + +def transfer_bound(d, L0): + img = Images(d, L0) + out = bound_core(d, kernel(d, img.jetcov)) + out.update({'L0': L0, 'theta1': img.theta1, 'rel': rup(out['eps'] / C2_REF_LO[d]), + 'max_jet_order': max((sum(g) for g in img.cache), default=0)}) + return out + + +def dict_add(A, Bd): + out = dict(A) + for e, c in Bd.items(): + out[e] = out.get(e, Fr(0)) + c + return out + + +# ============================================================================== 5. reference checks +def reference_checks(): + """With every radius zero the pipeline is exact; it must reproduce c2_exact's kernel_data (d = 1, 2 identically; + d = 3 on the slice x3 = T12 = 0, which is the diagonal slice c2_exact evaluates).""" + import exact as X + out = {} + for d in (1, 2, 3): + ref = X.kernel_data(d) + mine = kernel(d, lambda g: Fr(rho_der(g))) + Gm = mine['G'].subs_zero('x3') if d == 3 else mine['G'] + Em = mine['E'].subs_zero('x3') if d == 3 else mine['E'] + ok = True + for n in range(NR + 1): + a = {e[:5]: c for e, c in Gm.rcoef(n).t.items()} + bb = {e: c for e, c in ref['G'].rcoef(n).t.items()} + ok = ok and a == bb + Eref = (ref['q0'] + ref['Q0']) * Fr(1, 2) + ok = ok and {e[:5]: c for e, c in Em.t.items()} == dict(Eref.t) + ok = ok and mine['detS0'] == ref['detS0'] + if d < 3: + ok = ok and mine['detT0'] == ref['detT0'] + out[d] = ok + require(ok, 'reference pipeline mismatch in d = %d' % d) + return out + + +# ============================================================================== 6. driver +def dec_up(x, digits=6): + """decimal string >= x (x >= 0 rational) with `digits` significant digits""" + x = Fr(x) + if x == 0: + return '0' + e = 0 + while x >= 10 ** (e + 1): + e += 1 + while x < 10 ** e: + e -= 1 + scale = Fr(10) ** (digits - 1 - e) + m = -((-x.numerator * scale.numerator) // (x.denominator * scale.denominator)) + if m >= 10 ** digits: + m, e = m // 10 + (m % 10 > 0), e + 1 + s = str(m) + return '%s.%se%+d' % (s[0], s[1:], e) + + +def fmt(x): + return dec_up(abs(x)) if x >= 0 else '-' + dec_up(-x) + + +def compute(): + res = {'object': 'CL-C2-TORUS-TRANSFER-20261001-v1', 'reference_checks': {}, 'bounds': {}} + res['reference_checks'] = {str(k): v for k, v in reference_checks().items()} + for d in (1, 2, 3): + for L0 in L0S: + t = transfer_bound(d, L0) + res['bounds']['d%d_L%d' % (d, L0)] = {k: (fmt(v) if isinstance(v, Fr) else v) for k, v in t.items()} + return res + + +def main(): + global MUTANT + args = sys.argv[1:] + if '--mutant' in args: + MUTANT = args[args.index('--mutant') + 1] + require(MUTANT in MUTANTS, 'unknown mutant') + args = ['--check'] + res = compute() + path = os.path.join(HERE, 'RESULTS.json') + if '--write' in args: + with open(path, 'w') as f: + json.dump(res, f, indent=1, sort_keys=True) + f.write('\n') + elif '--check' in args: + with open(path) as f: + stored = json.load(f) + if stored != res: + print('MISMATCH against RESULTS.json') + sys.exit(1) + print('check passed') + else: + print(json.dumps(res, indent=1, sort_keys=True)) + + +if __name__ == '__main__': + main()