Documentation

CslibFrontier.Foundations.Analysis.Calculus.LipschitzSmoothing

Smoothing Lipschitz functions by repeated moving averages #

The moving average A_h φ (s) = h⁻¹ ∫₀ʰ φ(s + t) dt of a continuous φ : ℝ → ℝ is differentiable with derivative D_h φ (s) = h⁻¹ (φ(s + h) - φ(s)), and A_h commutes with D_h. Hence the m-fold moving average A_hᵐ φ is of class Cᵐ, with (A_hᵐ φ)⁽ᵏ⁾ = A_hᵐ⁻ᵏ (D_hᵏ φ) for k ≤ m. If ψ is c-Lipschitz, then |D_h ψ| ≤ c, every further difference quotient multiplies the sup norm by at most 2 / h, and A_h moves ψ by at most c h. This gives Proposition 11.58 of O'Donnell, Proposition 11.58 for derivatives of order at most m: for every η > 0 there is a Cᵐ function ψ̃ with |ψ̃ - ψ| ≤ c η and |ψ̃⁽ᵏ⁺¹⁾| ≤ (2m)ᵏ c / ηᵏ for k < m.

The book smooths with a Gaussian, ψ̃(s) = E[ψ(s + η g)] (its Exercise 11.38), which gives a single C^∞ function. Here the smoothing variable is instead h (U₁ + ⋯ + Uₘ) for independent Uᵢ uniform on [0, 1], a bounded-support smoothing (cf. its Exercise 11.40); it yields Cᵐ rather than C^∞, which suffices for the applications (m = 3 for the invariance principle for sums and Corollaries 11.59 and 11.61, m = 4 for Corollaries 11.68 and 11.70), and all constants are explicit.

The same smoothing turns the step 1_{s ≤ u} into the Cᵐ function Real.stepSmoothing m u h, the m-fold moving average of a ramp of width h: it is 1 on (-∞, u], 0 on [u + (m + 1) h, ∞), takes values in [0, 1] and has |φ⁽ᵐ⁾| ≤ 2ᵐ⁻¹ / hᵐ (cf. O'Donnell, Figure 11.2 and Exercise 11.41(b), whose smoothed step is monotone, two-sided around u and C^∞). Unlike Mathlib's Real.smoothTransition and Cslib.smoothSwitch, which are C^∞ but come without derivative bounds, it carries the explicit bound on φ⁽ᵐ⁾ that the smoothing arguments need.

Main definitions #

Main results #

References #

noncomputable def Real.movingAverage (h : ℝ) (φ : ℝ → ℝ) (s : ℝ) :

The moving average h⁻¹ ∫₀ʰ φ(s + t) dt of φ : ℝ → ℝ over windows of length h.

theorem Real.movingAverage_def (h : ℝ) (φ : ℝ → ℝ) (s : ℝ) :
h.movingAverage φ s = h⁻¹ * ∫ (t : ℝ) in 0..h, φ (s + t)

Unfolding movingAverage.

theorem Real.hasDerivAt_movingAverage {h : ℝ} {φ : ℝ → ℝ} (hφ : Continuous φ) (s : ℝ) :
HasDerivAt (h.movingAverage φ) (h⁻¹ * (φ (s + h) - φ s)) s

The moving average of a continuous φ has derivative h⁻¹ (φ(s + h) - φ(s)).

theorem Real.continuous_movingAverage {h : ℝ} {φ : ℝ → ℝ} (hφ : Continuous φ) :

The moving average of a continuous function is continuous.

theorem Real.contDiff_iterate_movingAverage {h : ℝ} {φ : ℝ → ℝ} (hφ : Continuous φ) (m : ℕ) :

The m-fold moving average of a continuous function is of class Cᵐ.

theorem Real.movingAverage_mem_Icc {h : ℝ} {φ : ℝ → ℝ} (hφ : Continuous φ) (hh : 0 < h) {a b s : ℝ} (hab : ∀ t ∈ Set.Icc s (s + h), φ t ∈ Set.Icc a b) :

A moving average with window h > 0 at s lies in [a, b] when φ does on [s, s + h].

theorem Real.iterate_movingAverage_mem_Icc {h : ℝ} {φ : ℝ → ℝ} (hφ : Continuous φ) (hh : 0 < h) {a b : ℝ} (m : ℕ) {s : ℝ} (hab : ∀ t ∈ Set.Icc s (s + ↑m * h), φ t ∈ Set.Icc a b) :

The m-fold moving average with window h > 0 at s lies in [a, b] when φ does on [s, s + m h]: it averages φ over that window.

theorem LipschitzWith.movingAverage {c : NNReal} {ψ : ℝ → ℝ} (hψ : LipschitzWith c ψ) (h : ℝ) :

A moving average of a c-Lipschitz function is c-Lipschitz.

theorem LipschitzWith.abs_movingAverage_sub_le {c : NNReal} {ψ : ℝ → ℝ} {h : ℝ} (hψ : LipschitzWith c ψ) (hh : 0 < h) (s : ℝ) :
|h.movingAverage ψ s - ψ s| ≤ ↑c * h

A moving average with window h > 0 moves a c-Lipschitz function by at most c h.

theorem LipschitzWith.abs_iterate_movingAverage_sub_le {c : NNReal} {ψ : ℝ → ℝ} {h : ℝ} (hψ : LipschitzWith c ψ) (hh : 0 < h) (m : ℕ) (s : ℝ) :
|h.movingAverage^[m] ψ s - ψ s| ≤ ↑m * ↑c * h

The m-fold moving average with window h > 0 moves a c-Lipschitz function by at most m c h.

theorem LipschitzWith.abs_iteratedDeriv_iterate_movingAverage_le {c : NNReal} {ψ : ℝ → ℝ} {h : ℝ} (hψ : LipschitzWith c ψ) (hh : 0 < h) {k m : ℕ} (hkm : k < m) (s : ℝ) :
|iteratedDeriv (k + 1) (h.movingAverage^[m] ψ) s| ≤ 2 ^ k * ↑c / h ^ k

The derivatives of the m-fold moving average of a c-Lipschitz function with window h > 0: |(A_hᵐ ψ)⁽ᵏ⁺¹⁾| ≤ 2ᵏ c / hᵏ for k < m.

theorem LipschitzWith.exists_contDiff_smoothing {c : NNReal} {ψ : ℝ → ℝ} (hψ : LipschitzWith c ψ) (m : ℕ) {η : ℝ} (hη : 0 < η) :
∃ (ψ' : ℝ → ℝ), ContDiff ℝ (↑m) ψ' ∧ (∀ (s : ℝ), |ψ' s - ψ s| ≤ ↑c * η) ∧ ∀ k < m, ∀ (s : ℝ), |iteratedDeriv (k + 1) ψ' s| ≤ (2 * ↑m) ^ k * ↑c / η ^ k

A finite-order form of Proposition 11.58 O'Donnell, Proposition 11.58: if ψ : ℝ → ℝ is c-Lipschitz, η > 0 and m : ℕ, there is a Cᵐ function ψ̃ with |ψ̃ - ψ| ≤ c η and |ψ̃⁽ᵏ⁺¹⁾| ≤ (2m)ᵏ c / ηᵏ for every k < m. One may take the m-fold moving average with window η / m. Unlike the book, which gives one C^∞ function ψ̃_η serving every order k with a constant depending only on k, here both ψ̃ and the constant (2m)ᵏ depend on the chosen order m.

Smoothed steps #

noncomputable def Real.stepSmoothing (m : ℕ) (u h : ℝ) :
ℝ → ℝ

The smoothed step stepSmoothing m u h: the m-fold moving average, with window h, of the ramp that falls linearly from 1 at u + m h to 0 at u + (m + 1) h. For h > 0 it is a Cᵐ function with values in [0, 1], equal to 1 on (-∞, u] and to 0 on [u + (m + 1) h, ∞), whose m-th derivative is at most 2ᵐ⁻¹ / hᵐ. This one-sided step is the test of the Lévy-distance arguments (cf. O'Donnell, Exercise 11.41(b), whose smoothed step is monotone, two-sided around u and C^∞). It exists beside Mathlib's Real.smoothTransition and Cslib.smoothSwitch because it comes with the explicit bound on its m-th derivative.

theorem Real.stepSmoothing_mem_Icc {h : ℝ} (m : ℕ) (u : ℝ) (hh : 0 < h) (s : ℝ) :

A smoothed step with window h > 0 takes values in [0, 1].

theorem Real.stepSmoothing_eq_one_of_le {h : ℝ} {m : ℕ} {u : ℝ} (hh : 0 < h) {s : ℝ} (hs : s ≤ u) :
stepSmoothing m u h s = 1

A smoothed step with window h > 0 is 1 on (-∞, u].

theorem Real.stepSmoothing_eq_zero_of_le {h : ℝ} {m : ℕ} {u : ℝ} (hh : 0 < h) {s : ℝ} (hs : u + (↑m + 1) * h ≤ s) :
stepSmoothing m u h s = 0

A smoothed step with window h > 0 is 0 on [u + (m + 1) h, ∞).

theorem Real.contDiff_stepSmoothing (m : ℕ) (u h : ℝ) :
ContDiff ℝ (↑m) (stepSmoothing m u h)

A smoothed step is of class Cᵐ.

theorem Real.abs_iteratedDeriv_stepSmoothing_le {h : ℝ} (m : ℕ) (u : ℝ) (hh : 0 < h) (s : ℝ) :
|iteratedDeriv m (stepSmoothing m u h) s| ≤ 2 ^ (m - 1) / h ^ m

The m-th derivative of a smoothed step with window h > 0 is at most 2ᵐ⁻¹ / hᵐ.