import Mathlib /-! # Parameter-selection (cost assembly) lemma: constants first This is the honest arithmetic content of the audited "final tractability theorem". It says: *if* a method has error bounded by the four explicit rates below and costs `d·m·N·M·K` per run, *then* parameters can be chosen so that the total error is `≤ ε/4`, a repetition count `R` has `(1/4)^R ≤ δ` (no probabilistic claim is made), and the total cost is `≤ C d^α ε^(-β) log(1/δ)`, where the constants `C, α, β` are chosen **before** `d, ε, δ` (in the audited file they were chosen after `ε, δ`, which made the statement vacuous). **Stated.** Given nonnegative constants and exponents, with the error model `errBound d m N M K = C_a d^{α_a}/√m + C_t d^{α_t}/√N + C_s d^{α_s} m^{β_s}/√M + C_o d^{α_o} m^{β_o}/K` (approximation, time discretisation, statistical, optimisation), there exist `C, α, β` such that for all `d ≥ 1`, `ε ∈ (0, 1]`, `δ ∈ (0, 1/2]` there are positive integers `m, N, M, K, R` with `errBound ≤ ε/4`, `(1/4)^R ≤ δ` and `R · d·m·N·M·K ≤ C d^α ε^(-β) log(1/δ)`. **Not stated.** This is pure arithmetic about the given rate functions. It says NOTHING about the HJB equation, about whether any algorithm actually achieves these rates, or about Markov / median-of-means amplification (the `(1/4)^R` is just a number here). It is NOT a tractability theorem for HJB equations. -/ namespace NSHJB.CostAssembly /-- The assumed error model: approximation + time + statistical + optimisation rates. -/ noncomputable def errBound (Ca αa Ct αt Cs αs βs Co αo βo : ℝ) (d m N M K : ℕ) : ℝ := Ca * (d : ℝ) ^ αa / Real.sqrt m + Ct * (d : ℝ) ^ αt / Real.sqrt N + Cs * (d : ℝ) ^ αs * (m : ℝ) ^ βs / Real.sqrt M + Co * (d : ℝ) ^ αo * (m : ℝ) ^ βo / K /-- Cost of one run. -/ def runCost (d m N M K : ℕ) : ℕ := d * m * N * M * K /-- Parameter selection with constants chosen before `d, ε, δ`. -/ theorem cost_assembly (Ca αa Ct αt Cs αs βs Co αo βo : ℝ) (hCa : 0 ≤ Ca) (hCt : 0 ≤ Ct) (hCs : 0 ≤ Cs) (hCo : 0 ≤ Co) (hαa : 0 ≤ αa) (hαt : 0 ≤ αt) (hαs : 0 ≤ αs) (hαo : 0 ≤ αo) (hβs : 0 ≤ βs) (hβo : 0 ≤ βo) : ∃ C α β : ℝ, ∀ d : ℕ, 1 ≤ d → ∀ ε : ℝ, 0 < ε → ε ≤ 1 → ∀ δ : ℝ, 0 < δ → δ ≤ 1 / 2 → ∃ m N M K R : ℕ, 0 < m ∧ 0 < N ∧ 0 < M ∧ 0 < K ∧ 0 < R ∧ errBound Ca αa Ct αt Cs αs βs Co αo βo d m N M K ≤ ε / 4 ∧ (1 / 4 : ℝ) ^ R ≤ δ ∧ (R : ℝ) * (runCost d m N M K : ℝ) ≤ C * (d : ℝ) ^ α * ε ^ (-β) * Real.log (1 / δ) := by sorry end NSHJB.CostAssembly