LeanFun RevOLVER

2.6 Best approximation

Best uniform approximation provides a benchmark for interpolation. For real functions, equioscillation characterizes the unique minimizing polynomial.

2.6.1 Best polynomial error

The best error is the benchmark against which a polynomial approximation can be compared. The first theorem shows that its infimum is attained.

For \(f\in C([-1,1],\mathbb C)\), define

\[ E_N(f)=\inf _{\deg p\le N}\| f-p\| _\infty , \]

the infimum over complex polynomials \(p\) of degree at most \(N\), restricted to \([-1,1]\). Here \(\| \cdot \| _\infty \) is the norm of \(C([-1,1],\mathbb C)\). The interpolant \(I_N f\) is the cardinal sum \(\sum _{j=0}^N f(x_j)\ell _j\), evaluating \(f\) only at its extrema nodes in \([-1,1]\).

Reference: [ATAP, Chapter 16].

Lean Formalisation
def Polynomial.Chebyshev.polynomialOnInterval (p : Polynomial ℂ) : C(↑(Set.Icc (-1) 1), ℂ)
Lean definition
/-- Restrict a complex polynomial to the real approximation interval. -/
noncomputable def polynomialOnInterval (p : ℂ[X]) : C(Icc (-1 : ℝ) 1, ℂ) :=
  ⟨fun x ↦ p.eval (x : ℂ), by fun_prop⟩
source

The complex best-error infimum \(E_N(f)\) on \([-1,1]\) is attained by a polynomial of degree at most \(N\). For continuous real data on any compact interval \([a,b]\), a real degree-at-most-\(N\) minimizer exists as well. Existence alone does not require \(a{\lt}b\).

Reference: [ATAP, Theorem 10.1].

Lean Formalisation
theorem Polynomial.Chebyshev.exists_bestUniformError (N : ℕ) (f : C(↑(Set.Icc (-1) 1), ℂ)) :
  ∃ p,
    p.degree < ↑(N + 1) ∧ ‖f - Polynomial.Chebyshev.polynomialOnInterval p‖ = Polynomial.Chebyshev.bestUniformError N f
Lean proof
/-- The infimum defining the complex best uniform error is attained (ATAP 10.1). -/
theorem exists_bestUniformError (N : ℕ) (f : C(Icc (-1 : ℝ) 1, ℂ)) :
    ∃ p : ℂ[X], p.degree < ((N + 1 : ℕ) : WithBot ℕ) ∧
      ‖f - polynomialOnInterval p‖ = bestUniformError N f := by
  let L := polynomialOnIntervalLinear.comp (degreeLT ℂ (N + 1)).subtype
  obtain ⟨p, hp⟩ := L.range.exists_norm_sub_le_of_finiteDimensional f
  obtain ⟨q, hq⟩ := p.property
  refine ⟨q, mem_degreeLT.mp q.property, le_antisymm ?_ (bestUniformError_le N f (mem_degreeLT.mp q.property))⟩
  apply le_csInf
  · exact ⟨_, 0, by simp, rfl⟩
  · rintro e ⟨r, hr, rfl⟩
    have h := hp ⟨L ⟨r, mem_degreeLT.mpr hr⟩, LinearMap.mem_range_self L _⟩
    simpa [← hq, L, polynomialOnIntervalLinear, toContinuousMapOnAlgHom] using h
source
Infimum bounds
Theorem 2.6.3 Best-error infimum bounds
✓ 🤖

The competitor-error set is nonempty and bounded below by zero. Thus \(0\le E_N(f)\le \| f-p\| _\infty \) for every polynomial of degree at most \(N\).

Reference: [ATAP, Chapter 16].

Lean Formalisation
theorem Polynomial.Chebyshev.bestUniformError_nonneg (N : ℕ) (f : C(↑(Set.Icc (-1) 1), ℂ)) :
  0 ≤ Polynomial.Chebyshev.bestUniformError N f
Lean proof
/-- The best error is nonnegative; the infimum is over a nonempty bounded-below set. -/
theorem bestUniformError_nonneg (N : ℕ) (f : C(Icc (-1 : ℝ) 1, ℂ)) :
    0 ≤ bestUniformError N f := by
  apply le_csInf (competitorErrors_nonempty N f)
  rintro e ⟨p, _, rfl⟩
  exact norm_nonneg _
source

2.6.2 Equioscillation

For real data, a pattern of alternating extreme errors characterizes the best approximant. The lower-bound theorem also applies before the extreme errors have equal magnitude.

Definition 2.6.4 Equioscillating error
✓ 🤖
#

A real continuous error \(e\) on \([a,b]\) equioscillates for degree \(N\) if there are \(a\le x_0{\lt}\cdots {\lt}x_{N+1}\le b\) and \(\sigma \in \{ -1,1\} \) such that \(e(x_i)=\sigma (-1)^i\| e\| _\infty \). The zero-error case is included.

Reference: [ATAP, Theorem 10.1].

Lean Formalisation
def Polynomial.Equioscillates {a b : ℝ} (n : ℕ) (e : C(↑(Set.Icc a b), ℝ)) : Prop
Lean definition
/-- An error curve attains its uniform norm with alternating signs at `n+2`
strictly increasing points. The zero-error case is included (ATAP 10.1). -/
def Equioscillates {a b : ℝ} (n : ℕ) (e : C(Icc a b, ℝ)) : Prop :=
  ∃ (x : Fin (n + 2) → Icc a b) (σ : ℝ), StrictMono x ∧ |σ| = 1 ∧
    ∀ i, e (x i) = σ * (-1 : ℝ) ^ (i : ℕ) * ‖e‖
source
Theorem 2.6.5 De la Vallée Poussin bound and sufficient alternation
✓ 🤖

Let \(p\) have degree at most \(N\). If \(N+2\) increasing points satisfy \(\sigma (-1)^i(f(x_i)-p(x_i))\ge L\), where \(|\sigma |=1\), then every polynomial \(q\) of degree at most \(N\) satisfies \(L\le \| f-q\| _\infty \). In particular, an equioscillating error certifies a best approximant.

Reference: [ATAP, Theorem 10.1 and Exercise 10.3].

Lean Formalisation
theorem Polynomial.lower_bound_of_alternating_error {a b L : ℝ} {n : ℕ} {f : C(↑(Set.Icc a b), ℝ)} {p : Polynomial ℝ}
  (hp : p.degree ≤ ↑n) {x : Fin (n + 2) → ↑(Set.Icc a b)} (hx : StrictMono x) {σ : ℝ} (hσ : |σ| = 1)
  (he : ∀ (i : Fin (n + 2)), L ≤ σ * (-1) ^ ↑i * (f (x i) - Polynomial.eval (↑(x i)) p)) {q : Polynomial ℝ}
  (hq : q.degree ≤ ↑n) : L ≤ ‖f - q.toContinuousMapOn (Set.Icc a b)‖
Lean proof
/-- Alternating errors of magnitude at least `L` certify a lower bound for
all degree-`n` competitors (de la Vallée Poussin, ATAP Exercise 10.3). -/
theorem lower_bound_of_alternating_error {a b L : ℝ} {n : ℕ}
    {f : C(Icc a b, ℝ)} {p : ℝ[X]} (hp : p.degree ≤ n)
    {x : Fin (n + 2) → Icc a b} (hx : StrictMono x) {σ : ℝ} (hσ : |σ| = 1)
    (he : ∀ i : Fin (n + 2), L ≤ σ * (-1 : ℝ) ^ (i : ℕ) * (f (x i) - p.eval (x i : ℝ)))
    {q : ℝ[X]} (hq : q.degree ≤ n) : L ≤ ‖f - q.toContinuousMapOn (Icc a b)‖ := by
  by_contra h
  have hlt : ‖f - q.toContinuousMapOn (Icc a b)‖ < L := lt_of_not_ge h
  let d := q - p
  have hpos (i : Fin (n + 2)) : 0 < σ * (-1 : ℝ) ^ (i : ℕ) * d.eval (x i : ℝ) := by
    have hn := (f - q.toContinuousMapOn (Icc a b)).norm_coe_le_norm (x i)
    have ht : |σ * (-1 : ℝ) ^ (i : ℕ) * (f (x i) - q.eval (x i : ℝ))| < L := by
      simpa only [abs_mul, hσ, abs_neg_one_pow, one_mul, Real.norm_eq_abs,
        ContinuousMap.sub_apply, toContinuousMapOn_apply, toContinuousMap_apply] using hn.trans_lt hlt
    have hl := (abs_lt.mp ht).2
    have hh := he i
    dsimp [d]
    rw [eval_sub]
    nlinarith
  have hσ2 : σ * σ = 1 := by nlinarith [sq_abs σ]
  have hsign (i : Fin (n + 1)) :
      d.eval (x i.castSucc : ℝ) * d.eval (x i.succ : ℝ) < 0 := by
    have hm := mul_pos (hpos i.castSucc) (hpos i.succ)
    have heq : (σ * (-1 : ℝ) ^ (i.castSucc : ℕ)) *
        (σ * (-1 : ℝ) ^ (i.succ : ℕ)) = -1 := by
      simp only [Fin.val_castSucc, Fin.val_succ, pow_succ]
      calc _ = -(σ * σ) * ((-1 : ℝ) ^ (i : ℕ) * (-1 : ℝ) ^ (i : ℕ)) := by ring
           _ = -1 := by rw [hσ2, ← mul_pow]; simp
    have heq' : (σ * (-1 : ℝ) ^ (i.castSucc : ℕ) * d.eval (x i.castSucc : ℝ)) *
        (σ * (-1 : ℝ) ^ (i.succ : ℕ) * d.eval (x i.succ : ℝ)) =
        -(d.eval (x i.castSucc : ℝ) * d.eval (x i.succ : ℝ)) := by
      calc _ = ((σ * (-1 : ℝ) ^ (i.castSucc : ℕ)) *
            (σ * (-1 : ℝ) ^ (i.succ : ℕ))) *
            (d.eval (x i.castSucc : ℝ) * d.eval (x i.succ : ℝ)) := by ring
           _ = _ := by rw [heq]; ring
    rw [heq'] at hm
    linarith
  have hd := le_natDegree_of_alternating_eval
    (x := fun i ↦ (x i : ℝ)) (fun _ _ h ↦ hx h) hsign
  have hdeg : d.natDegree ≤ n := natDegree_le_of_degree_le ((degree_sub_le q p).trans (max_le hq hp))
  omega
source

For example, the error in approximating \(x^2\) by \(1/2\) takes the values \(1/2,-1/2,1/2\) at \(-1,0,1\). The alternation criterion certifies this best constant approximation.

Theorem 2.6.6 Real equioscillation characterization
✓ 🤖

Let \(a{\lt}b\), let \(f\in C([a,b],\mathbb R)\), and let \(p\) have degree at most \(N\). Then \(p\) minimizes the uniform error among all real polynomials of degree at most \(N\) if and only if \(f-p\) equioscillates at \(N+2\) increasing points. This includes zero error.

Reference: [ATAP, Theorem 10.1].

Lean Formalisation
theorem Polynomial.equioscillates_of_bestApproximation {a b : ℝ} (hab : a < b) {n : ℕ} (f : C(↑(Set.Icc a b), ℝ))
  {p : Polynomial ℝ} (hp : p.degree ≤ ↑n)
  (hmin :
    ∀ (q : Polynomial ℝ),
      q.degree ≤ ↑n → ‖f - p.toContinuousMapOn (Set.Icc a b)‖ ≤ ‖f - q.toContinuousMapOn (Set.Icc a b)‖) :
  Polynomial.Equioscillates n (f - p.toContinuousMapOn (Set.Icc a b))
Lean proof
/-- Every real best approximant on a nondegenerate interval has `n+2`
alternating extrema, including the exact-polynomial case (ATAP 10.1). -/
theorem equioscillates_of_bestApproximation {a b : ℝ} (hab : a < b) {n : ℕ}
    (f : C(Icc a b, ℝ)) {p : ℝ[X]} (hp : p.degree ≤ n)
    (hmin : ∀ q : ℝ[X], q.degree ≤ n →
      ‖f - p.toContinuousMapOn (Icc a b)‖ ≤ ‖f - q.toContinuousMapOn (Icc a b)‖) :
    Equioscillates n (f - p.toContinuousMapOn (Icc a b)) := by
  let e := f - p.toContinuousMapOn (Icc a b)
  by_cases he : ‖e‖ = 0
  · have he0 : e = 0 := norm_eq_zero.mp he
    let x (i : Fin (n + 2)) : Icc a b :=
      ⟨a + (b - a) * (i : ℕ) / (n + 1), by
        have hi : (i : ℝ) ≤ n + 1 := by exact_mod_cast Nat.le_of_lt_succ i.isLt
        constructor
        · exact le_add_of_nonneg_right (div_nonneg
            (mul_nonneg (sub_nonneg.mpr hab.le) (Nat.cast_nonneg _)) (by positivity))
        · have hd : (0 : ℝ) < n + 1 := by positivity
          have hh := (div_le_iff₀ hd).2 (mul_le_mul_of_nonneg_left hi (sub_nonneg.mpr hab.le))
          linarith⟩
    have hx : StrictMono x := by
      intro i j hij
      change a + (b - a) * (i : ℕ) / (n + 1) < a + (b - a) * (j : ℕ) / (n + 1)
      gcongr
      exact_mod_cast hij
    refine ⟨x, 1, hx, by norm_num, ?_⟩
    intro i
    change e (x i) = 1 * (-1 : ℝ) ^ (i : ℕ) * ‖e‖
    rw [he0]
    simp
  · apply equioscillates_of_nonzero_minimal_error e (lt_of_le_of_ne (norm_nonneg _) (Ne.symm he))
    intro q hq
    have h := hmin (p + q) ((degree_add_le _ _).trans (max_le hp hq))
    have heq : (p + q).toContinuousMapOn (Icc a b) =
        p.toContinuousMapOn (Icc a b) + q.toContinuousMapOn (Icc a b) := by ext x; simp
    simpa only [e, heq, sub_add_eq_sub_sub] using h
source

For every \(a{\lt}b\), \(N\ge 0\), and continuous real \(f\) on \([a,b]\), there is a unique best polynomial of degree at most \(N\). Equivalently, there is a unique such polynomial whose error equioscillates.

Reference: [ATAP, Theorem 10.1 and Exercise 10.10].

Lean Formalisation
theorem Polynomial.bestApproximation_unique {a b : ℝ} (hab : a < b) {n : ℕ} (f : C(↑(Set.Icc a b), ℝ)) {p q : Polynomial ℝ}
  (hp : p.degree ≤ ↑n) (hq : q.degree ≤ ↑n)
  (hpmin :
    ∀ (r : Polynomial ℝ),
      r.degree ≤ ↑n → ‖f - p.toContinuousMapOn (Set.Icc a b)‖ ≤ ‖f - r.toContinuousMapOn (Set.Icc a b)‖)
  (hqmin :
    ∀ (r : Polynomial ℝ),
      r.degree ≤ ↑n → ‖f - q.toContinuousMapOn (Set.Icc a b)‖ ≤ ‖f - r.toContinuousMapOn (Set.Icc a b)‖) :
  p = q
Lean proof
/-- A continuous real function has at most one best degree-`n` polynomial
on a nondegenerate compact interval (ATAP 10.1). -/
theorem bestApproximation_unique {a b : ℝ} (hab : a < b) {n : ℕ}
    (f : C(Icc a b, ℝ)) {p q : ℝ[X]} (hp : p.degree ≤ n) (hq : q.degree ≤ n)
    (hpmin : ∀ r : ℝ[X], r.degree ≤ n →
      ‖f - p.toContinuousMapOn (Icc a b)‖ ≤ ‖f - r.toContinuousMapOn (Icc a b)‖)
    (hqmin : ∀ r : ℝ[X], r.degree ≤ n →
      ‖f - q.toContinuousMapOn (Icc a b)‖ ≤ ‖f - r.toContinuousMapOn (Icc a b)‖) : p = q := by
  let r : ℝ[X] := (1 / 2 : ℝ) • (p + q)
  let E := ‖f - p.toContinuousMapOn (Icc a b)‖
  have hE : 0 ≤ E := norm_nonneg _
  have hEq : ‖f - q.toContinuousMapOn (Icc a b)‖ = E :=
    le_antisymm (hqmin p hp) (hpmin q hq)
  have hr : r.degree ≤ n := (degree_smul_le _ _).trans ((degree_add_le _ _).trans (max_le hp hq))
  have hb (x : Icc a b) : |f x - p.eval (x : ℝ)| ≤ E ∧ |f x - q.eval (x : ℝ)| ≤ E := by
    constructor
    · exact (f - p.toContinuousMapOn (Icc a b)).norm_coe_le_norm x
    · exact ((f - q.toContinuousMapOn (Icc a b)).norm_coe_le_norm x).trans_eq hEq
  have heval (x : ℝ) : r.eval x = (p.eval x + q.eval x) / 2 := by simp [r, div_eq_mul_inv]; ring
  have hrle : ‖f - r.toContinuousMapOn (Icc a b)‖ ≤ E := by
    apply (ContinuousMap.norm_le _ hE).2
    intro x
    change |f x - r.eval (x : ℝ)| ≤ E
    rw [heval, abs_le]
    have h1 := abs_le.mp (hb x).1
    have h2 := abs_le.mp (hb x).2
    constructor <;> linarith
  have hreq : ‖f - r.toContinuousMapOn (Icc a b)‖ = E := le_antisymm hrle (hpmin r hr)
  have hrmin (s : ℝ[X]) (hs : s.degree ≤ n) :
      ‖f - r.toContinuousMapOn (Icc a b)‖ ≤ ‖f - s.toContinuousMapOn (Icc a b)‖ :=
    hrle.trans (hpmin s hs)
  obtain ⟨x, σ, hx, hσ, he⟩ := equioscillates_of_bestApproximation hab f hr hrmin
  have hxabs (i : Fin (n + 2)) : |f (x i) - r.eval (x i : ℝ)| = E := by
    have h := congrArg abs (he i)
    simpa only [ContinuousMap.sub_apply, toContinuousMapOn_apply, toContinuousMap_apply,
      abs_mul, hσ, abs_neg_one_pow, one_mul, hreq, abs_of_nonneg hE] using h
  have hsame (i : Fin (n + 2)) : p.eval (x i : ℝ) = q.eval (x i : ℝ) := by
    have h1 := abs_le.mp (hb (x i)).1
    have h2 := abs_le.mp (hb (x i)).2
    have ht := hxabs i
    rw [heval] at ht
    rcases abs_eq (by exact hE) |>.mp ht with h | h <;> linarith
  apply eq_of_natDegree_lt_card_of_eval_eq p q (fun _ _ h ↦ hx.injective (Subtype.ext h)) hsame
  simpa only [Fintype.card_fin, max_lt_iff] using
    And.intro ((natDegree_le_of_degree_le hp).trans_lt (show n < n + 2 by omega))
      ((natDegree_le_of_degree_le hq).trans_lt (show n < n + 2 by omega))
source

No complex uniqueness or complex sign-alternation characterization is asserted here.

2.6.3 Comparison with interpolation

The Lebesgue constant compares Chebyshev interpolation with the best polynomial of the same degree.

For \(f\in C([-1,1],\mathbb C)\),

\[ \| f-I_Nf\| _\infty \le (1+\Lambda _N)E_N(f). \]

For \(N\ge 1\), the proved logarithmic estimate also gives the factor \(2\pi +3+2\log N\) in place of \(1+\Lambda _N\).

Reference: [ATAP, Theorem 15.1 and Chapter 16].

Lean Formalisation
theorem Polynomial.Chebyshev.norm_sub_interpolationOnInterval_le_bestUniformError (N : ℕ) (f : C(↑(Set.Icc (-1) 1), ℂ)) :
  ‖f - Polynomial.Chebyshev.interpolationOnInterval N f‖ ≤
    (1 + Polynomial.Chebyshev.extremaLebesgueConstant N) * Polynomial.Chebyshev.bestUniformError N f
Lean proof
/-- Uniform near-best interpolation against the best-error infimum, without
assuming existence of a minimizing polynomial (ATAP, Chapter 16). -/
theorem norm_sub_interpolationOnInterval_le_bestUniformError
    (N : ℕ) (f : C(Icc (-1 : ℝ) 1, ℂ)) :
    ‖f - interpolationOnInterval N f‖ ≤
      (1 + extremaLebesgueConstant N) * bestUniformError N f := by
  have hL : 0 ≤ extremaLebesgueConstant N :=
    (extremaLebesgueFunction_nonneg N 0).trans
      (extremaLebesgueFunction_le_constant N (by norm_num))
  have hpos : 0 < 1 + extremaLebesgueConstant N := by linarith
  rw [mul_comm]
  apply (div_le_iff₀ hpos).mp
  apply le_csInf (competitorErrors_nonempty N f)
  rintro e ⟨p, hp, rfl⟩
  apply (div_le_iff₀ hpos).mpr
  rw [mul_comm]
  apply (ContinuousMap.norm_le _ (mul_nonneg hpos.le (norm_nonneg _))).mpr
  intro x
  have he := norm_sub_extremaInterpolant_le_lebesgueConstant hp
    (f := fun t ↦ if ht : t ∈ Icc (-1 : ℝ) 1 then f ⟨t, ht⟩ else 0)
    (ε := ‖f - polynomialOnInterval p‖)
    (fun t ht ↦ by
      simpa [ht, polynomialOnInterval] using
        (f - polynomialOnInterval p).norm_coe_le_norm ⟨t, ht⟩) x.property
  simpa [interpolationOnInterval, polynomialOnInterval, eval_extremaInterpolant,
    Polynomial.eval_finsetSum, extremaGridNode_mem_Icc, (extremaGridNode_mem_Icc N _).1,
    (extremaGridNode_mem_Icc N _).2, x.property] using he
source
Best-error converse and convex certificates
Theorem 2.6.9 Bernstein converse for the best error
✓ 🤖

For \(f\in C([-1,1],\mathbb C)\) and \(\rho {\gt}1\), if \(E_n(f)\le C\rho ^{-n}\) for every \(n\ge 0\), then \(f\) has an analytic extension to \(E_\rho \).

Reference: [ATAP, Theorem 8.3].

Lean Formalisation
theorem Polynomial.Chebyshev.exists_analytic_extension_of_bestUniformError {f : C(↑(Set.Icc (-1) 1), ℂ)} {C ρ : ℝ} (hρ : 1 < ρ)
  (hb : ∀ (n : ℕ), Polynomial.Chebyshev.bestUniformError n f ≤ C / ρ ^ n) :
  ∃ F, AnalyticOnNhd ℂ F (Complex.bernsteinEllipse ⟨ρ, hρ⟩) ∧ ∀ (x : ↑(Set.Icc (-1) 1)), F ↑↑x = f x
Lean proof
/-- Geometric decay of the attained best uniform error gives analytic
continuation (ATAP 8.3, in best-approximation form). -/
theorem exists_analytic_extension_of_bestUniformError {f : C(Icc (-1 : ℝ) 1, ℂ)} {C ρ : ℝ}
    (hρ : 1 < ρ) (hb : ∀ n, bestUniformError n f ≤ C / ρ ^ n) :
    ∃ F : ℂ → ℂ, AnalyticOnNhd ℂ F (bernsteinEllipse ⟨ρ, hρ⟩) ∧
      ∀ x : Icc (-1 : ℝ) 1, F (x : ℂ) = f x := by
  classical
  choose p hp he using fun n ↦ exists_bestUniformError n f
  let g : ℝ → ℂ := fun x ↦ if hx : x ∈ Icc (-1 : ℝ) 1 then f ⟨x, hx⟩ else 0
  have hg : ∀ n x, x ∈ Icc (-1 : ℝ) 1 → ‖g x - (p n).eval (x : ℂ)‖ ≤ C / ρ ^ n := by
    intro n x hx
    have h := (f - polynomialOnInterval (p n)).norm_coe_le_norm ⟨x, hx⟩
    rw [he n] at h
    have hh : ‖g x - (p n).eval (x : ℂ)‖ ≤ bestUniformError n f := by
      simpa only [g, dite_eq_left hx, ContinuousMap.sub_apply, polynomialOnInterval, ContinuousMap.coe_mk] using h
    exact hh.trans (hb n)
  obtain ⟨F, hF, hfg⟩ := exists_analytic_extension_of_geometric_polynomial_approximation hρ hp hg
  refine ⟨F, hF, fun x ↦ ?_⟩
  simpa only [g, dite_eq_left x.property] using hfg x x.property
source
Theorem 2.6.10 Finite-dimensional best approximation
✓ 🤖

Let \(V\) be a finite-dimensional subspace of a normed space over a proper, nontrivially normed field. For every \(f\), there exists \(p\in V\) such that \(\| f-p\| \le \| f-q\| \) for every \(q\in V\). No inner product or uniqueness assumption is needed.

Reference: [ATAP, Theorem 10.1], existence argument.

Lean Formalisation
theorem Submodule.exists_norm_sub_le_of_finiteDimensional.{u_1, u_2} {𝕜 : Type u_1} {E : Type u_2} [NontriviallyNormedField 𝕜]
  [ProperSpace 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] (V : Submodule 𝕜 E) [FiniteDimensional 𝕜 ↥V] (f : E) :
  ∃ p, ∀ (q : ↥V), ‖f - ↑p‖ ≤ ‖f - ↑q‖
Lean proof
/-- A finite-dimensional subspace of a normed space over a proper field has a
best approximant. No strict convexity or uniqueness is asserted (ATAP 10.1). -/
theorem exists_norm_sub_le_of_finiteDimensional
    {𝕜 E : Type*} [NontriviallyNormedField 𝕜] [ProperSpace 𝕜]
    [NormedAddCommGroup E] [NormedSpace 𝕜 E]
    (V : Submodule 𝕜 E) [FiniteDimensional 𝕜 V] (f : E) :
    ∃ p : V, ∀ q : V, ‖f - (p : E)‖ ≤ ‖f - (q : E)‖ := by
  let : ProperSpace V := FiniteDimensional.proper 𝕜 V
  obtain ⟨p, hp, hmin⟩ := (isCompact_closedBall (0 : V) (2 * ‖f‖)).exists_isMinOn
    (⟨0, by simp [norm_nonneg]⟩ : (Metric.closedBall (0 : V) (2 * ‖f‖)).Nonempty)
    (show ContinuousOn (fun q : V ↦ ‖f - (q : E)‖) _ from
      (continuous_const.sub continuous_subtype_val).norm.continuousOn)
  refine ⟨p, fun q ↦ ?_⟩
  by_cases hq : q ∈ Metric.closedBall (0 : V) (2 * ‖f‖)
  · exact hmin hq
  · have hzero := hmin (show (0 : V) ∈ Metric.closedBall 0 (2 * ‖f‖) by simp [norm_nonneg])
    have hq' : 2 * ‖f‖ < ‖(q : E)‖ := by simpa using hq
    have ht : ‖(q : E)‖ ≤ ‖f‖ + ‖f - (q : E)‖ := by
      simpa only [sub_sub_cancel, norm_neg, norm_sub_rev] using norm_sub_le f (f - (q : E))
    change ‖f - (p : E)‖ ≤ ‖f - ((0 : V) : E)‖ at hzero
    simp only [ZeroMemClass.coe_zero, sub_zero] at hzero
    linarith
source
Theorem 2.6.11 Alternating signs force polynomial degree
✓ 🤖

If a real polynomial changes sign across each of \(n\) consecutive intervals with strictly increasing endpoints, then its natural degree is at least \(n\). Each sign change gives a root in the open interval.

Reference: [ATAP, proof of Theorem 10.1].

Lean Formalisation
theorem Polynomial.exists_eval_eq_zero_between_of_mul_neg {p : Polynomial ℝ} {a b : ℝ} (hab : a < b)
  (hp : Polynomial.eval a p * Polynomial.eval b p < 0) : ∃ x ∈ Set.Ioo a b, Polynomial.eval x p = 0
Lean proof
/-- A strict sign change produces a root in the open interval. -/
theorem exists_eval_eq_zero_between_of_mul_neg {p : ℝ[X]} {a b : ℝ}
    (hab : a < b) (hp : p.eval a * p.eval b < 0) :
    ∃ x ∈ Ioo a b, p.eval x = 0 := by
  rcases mul_neg_iff.mp hp with h | h
  · exact intermediate_value_Ioo' hab.le p.continuous.continuousOn ⟨h.2, h.1⟩
  · exact intermediate_value_Ioo hab.le p.continuous.continuousOn ⟨h.1, h.2⟩
source
Theorem 2.6.12 Convex separation and Carathéodory certificates Mathlib
✓

A point outside a closed convex set in a real locally convex space can be strictly separated from that set by a continuous linear functional. A point in a convex hull has a positive convex combination supported on an affinely independent finite family.

Lean Formalisation
theorem geometric_hahn_banach_point_closed.{u_2} {E : Type u_2} [TopologicalSpace E] [AddCommGroup E] [Module ℝ E] {t : Set E}
  {x : E} [IsTopologicalAddGroup E] [ContinuousSMul ℝ E] [LocallyConvexSpace ℝ E] (ht₁ : Convex ℝ t) (ht₂ : IsClosed t)
  (disj : x ∉ t) : ∃ f u, f x < u ∧ ∀ b ∈ t, u < f b
Mathlib source
Theorem 2.6.13 Compact finite-dimensional convex hulls
✓ 🤖

In dimension \(d\), every convex-hull point is a convex combination of at most \(d+1\) points. The convex hull of a compact set in a finite-dimensional real normed space is compact.

Lean Formalisation
theorem mem_convexHull_exists_fin_combination.{u_1} {E : Type u_1} [AddCommGroup E] [Module ℝ E] [FiniteDimensional ℝ E]
  {s : Set E} {y : E} (hy : y ∈ (convexHull ℝ) s) :
  ∃ n ≤ Module.finrank ℝ E + 1,
    ∃ w z, (∀ (i : Fin n), 0 ≤ w i) ∧ ∑ i, w i = 1 ∧ (∀ (i : Fin n), z i ∈ s) ∧ ∑ i, w i • z i = y
Lean proof
/-- A convex-hull point in finite dimensions has a combination with at most
`finrank + 1` terms (Carathéodory's theorem). -/
theorem mem_convexHull_exists_fin_combination {E : Type*} [AddCommGroup E] [Module ℝ E]
    [FiniteDimensional ℝ E] {s : Set E} {y : E} (hy : y ∈ convexHull ℝ s) :
    ∃ n ≤ Module.finrank ℝ E + 1, ∃ (w : Fin n → ℝ) (z : Fin n → E),
      (∀ i, 0 ≤ w i) ∧ (∑ i, w i) = 1 ∧ (∀ i, z i ∈ s) ∧ ∑ i, w i • z i = y := by
  obtain ⟨ι, hι, z, w, hz, hi, hw, hsum, heq⟩ := eq_pos_convex_span_of_mem_convexHull hy
  let e := Fintype.equivFin ι
  refine ⟨Fintype.card ι, hi.card_le_finrank_succ.trans ?_, w ∘ e.symm, z ∘ e.symm,
    fun i ↦ (hw _).le, ?_, fun i ↦ hz ⟨_, rfl⟩, ?_⟩
  · exact Nat.add_le_add_right (Submodule.finrank_le _) 1
  · simpa only [Function.comp_apply] using (Equiv.sum_comp e.symm w).trans hsum
  · simpa only [Function.comp_apply] using (Equiv.sum_comp e.symm (fun i ↦ w i • z i)).trans heq
source
Theorem 2.6.14 Strict improvement from the extreme set
✓ 🤖

Let \(e,q\) be continuous real functions on a compact space, with \(\| e\| {\gt}0\). If \(e(x)q(x){\gt}0\) at every point where \(|e(x)|=\| e\| \), there exists a real \(t{\gt}0\) such that \(\| e-tq\| {\lt}\| e\| \).

Reference: [ATAP, Theorem 10.1].

Lean Formalisation
theorem ContinuousMap.exists_norm_sub_smul_lt_of_extreme_sign.{u_1} {X : Type u_1} [TopologicalSpace X] [CompactSpace X]
  (e q : C(X, ℝ)) (he : 0 < ‖e‖) (hq : ∀ (x : X), |e x| = ‖e‖ → 0 < e x * q x) : ∃ t, 0 < t ∧ ‖e - t • q‖ < ‖e‖
Lean proof
/-- A direction with the same strict sign at every extreme point reduces the
uniform error on a compact domain (ATAP 10.1). -/
theorem exists_norm_sub_smul_lt_of_extreme_sign {X : Type*} [TopologicalSpace X]
    [CompactSpace X] (e q : C(X, ℝ)) (he : 0 < ‖e‖)
    (hq : ∀ x, |e x| = ‖e‖ → 0 < e x * q x) :
    ∃ t : ℝ, 0 < t ∧ ‖e - t • q‖ < ‖e‖ := by
  have hpoint (x : X) : ∃ t > 0, |e x - t * q x| < ‖e‖ :=
    exists_step_abs_sub_lt he (by simpa only [Real.norm_eq_abs] using e.norm_coe_le_norm x) (hq x)
  choose t ht hbound using hpoint
  let U (x : X) : Set X := {y | |e y - t x * q y| < ‖e‖}
  have hU (x : X) : IsOpen (U x) := isOpen_lt (by fun_prop) continuous_const
  obtain ⟨s, hs⟩ := isCompact_univ.elim_finite_subcover U hU
    (fun x _ ↦ mem_iUnion.2 ⟨x, hbound x⟩)
  obtain ⟨u, hu, hus⟩ := exists_positive_step s t (fun i _ ↦ ht i)
  refine ⟨u, hu, (norm_lt_iff _ he).2 fun y ↦ ?_⟩
  obtain ⟨x, hx, hxy⟩ := mem_iUnion.1 (hs (mem_univ y)) |>.imp (fun _ h ↦ mem_iUnion.1 h)
  have huy := hus x hx
  have hratio : 0 < u / t x := div_pos hu (ht x)
  have hratio1 : u / t x ≤ 1 := (div_le_one (ht x)).2 huy
  have hid : e y - u * q y = (1 - u / t x) * e y + (u / t x) * (e y - t x * q y) := by
    field_simp [(ht x).ne']
    ring
  change |e y - t x * q y| < ‖e‖ at hxy
  change ‖e y - u * q y‖ < ‖e‖
  rw [Real.norm_eq_abs, hid]
  calc
    _ ≤ |(1 - u / t x) * e y| + |(u / t x) * (e y - t x * q y)| := abs_add_le _ _
    _ = (1 - u / t x) * |e y| + (u / t x) * |e y - t x * q y| := by
      rw [abs_mul, abs_mul, abs_of_nonneg (sub_nonneg.mpr hratio1), abs_of_pos hratio]
    _ < (1 - u / t x) * ‖e‖ + (u / t x) * ‖e‖ :=
      add_lt_add_of_le_of_lt
        (mul_le_mul_of_nonneg_left (by simpa only [Real.norm_eq_abs] using e.norm_coe_le_norm y)
          (sub_nonneg.mpr hratio1)) (mul_lt_mul_of_pos_left hxy hratio)
    _ = ‖e‖ := by ring
source
Definition 2.6.15 Extreme moment vectors
✓ 🤖
#

For a real error function \(e\) on \([a,b]\), set \(v_N(x)=e(x)(1,x,\ldots ,x^N)\in \mathbb R^{N+1}\).

Reference: [ATAP, Theorem 10.1], convex-separation formulation.

Lean Formalisation
def Polynomial.extremeMoment {a b : ℝ} (n : ℕ) (e : C(↑(Set.Icc a b), ℝ)) (x : ↑(Set.Icc a b)) : Fin (n + 1) → ℝ
Lean definition
/-- Error-weighted monomial evaluation vector used in the minimax certificate. -/
noncomputable def extremeMoment {a b : ℝ} (n : ℕ) (e : C(Icc a b, ℝ))
    (x : Icc a b) : Fin (n + 1) → ℝ := fun j ↦ e x * (x : ℝ) ^ (j : ℕ)
source

These are the signed evaluation vectors used in the minimax certificate.

Theorem 2.6.16 Finite positive certificate for a minimax error
✓ 🤖

Suppose \(e\) is continuous and real, \(\| e\| {\gt}0\), and \(\| e\| \le \| e-q\| \) for every polynomial \(q\) of degree at most \(N\). Then zero lies in the convex hull of \(v_N(x)\) over the extreme set \(\{ x:|e(x)|=\| e\| \} \). There are at most \(N+2\) distinct extreme points \(x_i\) and positive weights \(w_i\) with \(\sum _iw_i=1\) and \(\sum _iw_i v_N(x_i)=0\).

Reference: [ATAP, Theorem 10.1].

Lean Formalisation
theorem Polynomial.zero_mem_convexHull_extremeMoment {a b : ℝ} {n : ℕ} (e : C(↑(Set.Icc a b), ℝ)) (he : 0 < ‖e‖)
  (hmin : ∀ (q : Polynomial ℝ), q.degree ≤ ↑n → ‖e‖ ≤ ‖e - q.toContinuousMapOn (Set.Icc a b)‖) :
  0 ∈ (convexHull ℝ) (Polynomial.extremeMoment n e '' {x | |e x| = ‖e‖})
Lean proof
/-- For a nonzero best error, zero lies in the convex hull of the signed
monomial vectors at its extreme points (ATAP 10.1, separation argument). -/
theorem zero_mem_convexHull_extremeMoment {a b : ℝ} {n : ℕ} (e : C(Icc a b, ℝ))
    (he : 0 < ‖e‖)
    (hmin : ∀ q : ℝ[X], q.degree ≤ n → ‖e‖ ≤ ‖e - q.toContinuousMapOn (Icc a b)‖) :
    0 ∈ convexHull ℝ (extremeMoment n e '' {x | |e x| = ‖e‖}) := by
  have hK : IsCompact (extremeMoment n e '' {x | |e x| = ‖e‖}) :=
    (isClosed_eq (by fun_prop) continuous_const).isCompact.image (by
      unfold extremeMoment
      fun_prop)
  by_contra h
  obtain ⟨L, c, hc, hL⟩ := geometric_hahn_banach_point_closed
    (convex_convexHull ℝ _) hK.convexHull_finiteDimensional.isClosed h
  have hsign (x : Icc a b) (hx : |e x| = ‖e‖) :
      0 < e x * (dualPolynomial L).eval (x : ℝ) := by
    have ht := hL _ (subset_convexHull ℝ _ (mem_image_of_mem _ hx))
    have hv : extremeMoment n e x = e x • (fun j : Fin (n + 1) ↦ (x : ℝ) ^ (j : ℕ)) := rfl
    rw [hv, map_smul, smul_eq_mul, ← eval_dualPolynomial] at ht
    simpa only [map_zero] using hc.trans ht
  obtain ⟨t, ht, himprove⟩ := e.exists_norm_sub_smul_lt_of_extreme_sign
    ((dualPolynomial L).toContinuousMapOn (Icc a b)) he hsign
  have hq := hmin (t • dualPolynomial L)
    ((degree_smul_le _ _).trans (degree_dualPolynomial_le L))
  have hmap : (t • dualPolynomial L).toContinuousMapOn (Icc a b) =
      t • (dualPolynomial L).toContinuousMapOn (Icc a b) := by ext x; simp
  rw [hmap] at hq
  exact (not_lt_of_ge hq) himprove
source

Vanishing moments through degree \(N\) imply annihilation of all polynomials of that degree. A nonempty family of distinct nodes carrying nonzero annihilating weights must have at least \(N+2\) nodes. If there are exactly \(N+2\) increasing nodes, adjacent weights have opposite signs. Finite injective node families can be reindexed in increasing order.

Reference: [ATAP, Theorem 10.1].

Lean Formalisation
theorem Polynomial.sum_mul_eval_eq_zero_of_moments.{u_1} {ι : Type u_1} [Fintype ι] {n : ℕ} (x c : ι → ℝ)
  (h : ∀ (j : Fin (n + 1)), ∑ i, c i * x i ^ ↑j = 0) {p : Polynomial ℝ} (hp : p.degree ≤ ↑n) :
  ∑ i, c i * Polynomial.eval (x i) p = 0
Lean proof
/-- Moment annihilation implies annihilation of every polynomial in the degree space. -/
theorem sum_mul_eval_eq_zero_of_moments {ι : Type*} [Fintype ι] {n : ℕ}
    (x c : ι → ℝ) (h : ∀ j : Fin (n + 1), ∑ i, c i * x i ^ (j : ℕ) = 0)
    {p : ℝ[X]} (hp : p.degree ≤ n) : ∑ i, c i * p.eval (x i) = 0 := by
  have hp' : p ∈ degreeLT ℝ (n + 1) := mem_degreeLT.mpr
    (hp.trans_lt (by exact_mod_cast Nat.lt_succ_self n))
  simp_rw [eval_eq_sum_degreeLTEquiv hp', Finset.mul_sum]
  rw [Finset.sum_comm]
  apply Finset.sum_eq_zero
  intro j _
  calc
    _ = degreeLTEquiv ℝ (n + 1) ⟨p, hp'⟩ j * ∑ i, c i * x i ^ (j : ℕ) := by
      rw [Finset.mul_sum]
      apply Finset.sum_congr rfl
      intro i _
      ring
    _ = 0 := by rw [h j, mul_zero]
source