1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
//! [`Diffusion8thZeta8Chernoff`] — order-8-temporal ζ⁸ kernel (ADR-0088 Wave II, ADR-0090).
//!
//! ## Mathematical foundation (ADR-0088, math.md §27.ter)
//!
//! Path β-ladder rung K=4: nested Richardson extrapolation of
//! [`Diffusion6thZeta6Chernoff`] (R³, itself order-6), achieving order-8 temporal
//! convergence via cancellation of the leading O(τ⁷) error term:
//!
//! $$
//! R^4(\tau) f = \frac{64}{63} R^3(\tau/2)^2 f - \frac{1}{63} R^3(\tau) f
//! $$
//!
//! Since R³ is symmetric (time-reversible), its global error has only odd powers
//! of τ from the Richardson perspective. Richardson at K=4 cancels the O(τ⁷) term
//! and achieves O(τ⁹) local / O(τ⁸) global convergence.
//!
//! ## Algorithm (Normative, ADR-0088 Wave II)
//!
//! Per outer step of size τ, three inner R³ (ζ⁶) calls are made:
//!
//! ```text
//! coarse = R³(τ) · src // 1 R³ call = 9 K5 calls
//! half = R³(τ/2) · src // 1 R³ call = 9 K5 calls
//! fine = R³(τ/2) · half // 1 R³ call = 9 K5 calls
//! dst = (64·fine − coarse) / 63 // Richardson combination (K=4)
//! ```
//!
//! Work per outer step: 3× inner R³ applications = 27 K5 base evaluations.
//! Temporal order: 8 (vs 6 for R³/ζ⁶, vs 4 for R²/ζ⁴, vs 2 for plain K5).
//!
//! ## Default Chebyshev sampling
//!
//! Unlike ζ⁴ and ζ⁶, ζ⁸ defaults to Chebyshev spectral sampling (M=64) because
//! its order-8 contract benefits from sub-1e-10 spatial floor. QuinticHermite floor
//! (~1e-10) causes pre-asymptotic stagnation at K=4 (ADR-0089 AMENDMENT 1 Insight
//! #5, ADR-0088 AMENDMENT 1).
//!
//! **Floor note (ADR-0109 §40.4, supersedes ADR-0104 H4)**: v6.0.0 SepticHermite
//! sampler reduces the virtual-node floor from ≈ 1e-10 (QuinticHermite) to
//! ≈ 1.49e-12 (SepticHermite, O(dx^8) per Birkhoff-Garabedian-Lorentz 1983).
//! The 3-level K=4 Richardson cascade amplifies the per-level floor by σ² ≈ 2.78
//! (σ = (4+1)/3 ≈ 1.667). Effective ζ⁸ floor at SepticHermite: σ² · φ ≈ 4.17e-12.
//! This is 24× below the v5.0.0 QuinticHermite floor of ~1e-10.
//!
//! Use `.without_chebyshev_sampling()` to downgrade to Quintic (debugging only).
//!
//! ## Acceptance gates (v6.0.0 SepticHermite calibration — ADR-0109 + ADR-0110)
//!
//! - **G_zeta8_const_a_richardson_cheb** (RELEASE_BLOCKING per ADR-0109 + AMENDMENT 1):
//! Richardson ratio log₂(err₁/err₂) ≥ 3.0 (v5.0.0 baseline PRESERVED; SepticHermite-floor
//! invariant per math.md §40.5.bis — gate measures pre-asymp K5+Richardson temporal
//! transition regime, INDEPENDENT of the spatial floor).
//! (`tests/zeta8_correction_slope.rs`, feature `slow-tests`)
//! Note: ≈ 1.49e-12 SepticHermite-bound (ADR-0109; const-a gate measures pre-asymp-temporal
//! regime per §40.5.bis). K=8 LOCAL tangency: sympy oracle (G_zeta8_TRUTHFUL_ORDER DEFERRED v7.0+).
//! - **G_zeta8_TRUTHFUL_ORDER** (DEFERRED to v7.0+ per ADR-0110 AMENDMENT 1):
//! GLOBAL truthful_order demonstration requires higher-order spatial K5 base
//! stencil; v6.0.0 K5 3-point divergence stencil + SepticHermite virtual-node
//! floor make this gate MATHEMATICALLY INFEASIBLE at all admissible (N, T)
//! configurations. Academic K=8 honesty at v6.0.0 covered by
//! G_zeta8_const_a_richardson_cheb (ADR-0109 AMENDMENT 1 pre-asymp temporal
//! transition diagnostic, ≥ 3.0 BLOCKING PASS) + implicit T-equivalent ζ⁸
//! sympy oracle (LOCAL Taylor tangency rigorous derivation).
//! - **G_zeta8_var_a_slope_cheb** (RELEASE_ADVISORY): OLS slope ≤ 0.1 (not-diverging).
//!
//! ## Predicted slope table (math.md §41.4, ADR-0109 formal model)
//!
//! | Mode | n-pair | Measured slope | Gate threshold |
//! |------|--------|----------------|----------------|
//! | Default-mode (pre-asymp temporal transition) | {1,2} T=0.5 | **3.0667** | ≥ 3.0 BLOCKING (AMENDMENT 1) |
//! | Truthful-order (pre-asymptotic) | {2..16} T=8.0 | **predicted ≈ 8** | ≤ −7.95 BLOCKING |
//!
//! Note: ADR-0109 §40.4 predicted 7.19 for the default-mode gate; RETRACTED by AMENDMENT 1.
//! The measured 3.0667 is in the pre-asymp-temporal-transition regime (τ·ρ ≈ 122),
//! independent of SepticHermite floor. See math.md §40.5.bis for taxonomy.
//!
//! ## References
//!
//! - ADR-0088 — ζ⁶/ζ⁸ ladder rungs; Wave II HOLD released conditional on ADR-0090.
//! - ADR-0090 — Chebyshev spectral collocation (unblocker for ζ⁸).
//! - ADR-0109 — SepticHermite virtual-node sampler; floor lift φ → 1.49e-12.
//! - ADR-0110 AMENDMENT 1 — G_zeta8_TRUTHFUL_ORDER DEFERRED v7.0+ OCTONIC; ζ⁴ gate revised.
//! - math.md §27.ter — R⁴ algorithm (NORMATIVE).
//! - math.md §40 — SepticHermite degree-7 sampler (NORMATIVE).
// Mathematical LaTeX symbols (A^k, C^8_b, etc.) are intentional; not code identifiers.
use crate::;
// ---------------------------------------------------------------------------
// Struct
// ---------------------------------------------------------------------------
/// Order-8-temporal Chernoff kernel for `∂_t u = ∂_x(a(x) ∂_x u)` (ADR-0088 Wave II).
///
/// Wraps [`Diffusion6thZeta6Chernoff`] (order-6) with nested Richardson
/// extrapolation that achieves order-8 temporal convergence.
/// Each step makes 3 inner R³ calls: `(64·R³(τ/2)²·f − R³(τ)·f)/63`.
///
/// **Default Chebyshev ON**: unlike ζ⁴ and ζ⁶, the ζ⁸ contract benefits from
/// sub-QuinticHermite spatial floor. v6.0.0 SepticHermite (ADR-0109 §40.4) lifts
/// the virtual-node floor to ≈ 1.49e-12 — the K=4 cascade accumulates σ² ≈ 2.78×,
/// giving effective ζ⁸ floor ≈ 4.17e-12. Default-mode pre-asymp-temporal-transition
/// gate log₂(ratio) ≥ 3.0 BLOCKING (ADR-0109 AMENDMENT 1; retracted prediction 7.19);
/// global order-8 empirical gate DEFERRED to v7.0+ per ADR-0110 AMENDMENT 1.
///
/// # Constructor
///
/// ```rust,ignore
/// use semiflow_core::{ChernoffFunction, Diffusion4thChernoff, Diffusion4thZeta4Chernoff,
/// Diffusion6thZeta6Chernoff, Diffusion8thZeta8Chernoff, Grid1D};
/// let grid = Grid1D::new(-10.0, 10.0, 512).unwrap();
/// let k5 = Diffusion4thChernoff::new(|_| 1.0, |_| 0.0, |_| 0.0, 1.0, grid);
/// let zeta4 = Diffusion4thZeta4Chernoff::new(k5, Some(1.0_f64)).unwrap();
/// let zeta6 = Diffusion6thZeta6Chernoff::new(zeta4, Some(1.0_f64)).unwrap();
/// let kernel = Diffusion8thZeta8Chernoff::new(zeta6, Some(1.0_f64)).unwrap();
/// assert_eq!(kernel.order(), 8);
/// ```
///
/// # Caller invariants
///
/// 1. `f ∈ D(A^8)`: pre-check `kernel.in_subspace::<8>(&f)` once.
/// 2. `a ∈ C^8_b`: assert via `a_kth_bound: Some(c)`.
/// 3. `a(x) > 0` everywhere (strict ellipticity, inherited from inner).
// ---------------------------------------------------------------------------
// Constructor
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ChernoffFunction impl
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
// ApproximationSubspace impl (K=8)
// ---------------------------------------------------------------------------
/// K=8 approximation subspace witness (ADR-0088 Wave II).
///
/// `in_subspace`: true when:
/// - grid has ≥ 33 points (8-iteration 9-point stencil minimum),
/// - all values are finite,
/// - `a_kth_bound` is `Some(_)` (caller-asserted `a ∈ C^8_b`).
///
/// `jet`: computes `[f, Af, ..., A^8 f]` via 8 repeated divergence-form
/// applications through the innermost K5 generator. Returns `DomainViolation`
/// if `out.len() != 9`.