Mathlib.Analysis

Analysis helpers staged for upstreaming: Bernoulli KL inequalities, functional-equation facts, scalar arithmetic, half-disc polar integration, and one-dimensional smooth descent bounds.

Argument­Principle­Circle 7 to review 7 core · 9 supporting · 3 submodules Complex-analysis infrastructure for the argument principle on positively oriented circles: multiplicity-weighted zero counts, logarithmic-derivative contour integrals, homotopy invariance, and Rouché comparison. Bernstein­Szego­Trig 13 core · 10 supporting · 4 submodules Trigonometric-polynomial infrastructure for Bernstein-Szegő comparisons: degree bounds, zero counting, cosine composition, and Szegő interpolation. Certified­Contour­Interval­Arithmetic 186 to review 186 core · 144 supporting · 10 submodules Certified numerical-analysis infrastructure: exact rational intervals, effective certified-real refinement, transcendental enclosures, Lipschitz mesh quadrature, and measurable finite selection. Convex 1 core · 5 supporting · 1 submodule Convex-analysis helpers staged for upstreaming: reciprocal-product convexity and supporting inequalities for optimization arguments. Ehlich­Zeller­Mesh 9 core · 14 supporting · 2 submodules Ehlich-Zeller mesh helpers: Chebyshev-Lobatto nodes, trigonometric transforms, mesh maxima, sup-norm transfer, and Bernstein/Szegő inequalities. Finite­Dim­L1­Linf­Duality 19 core · 26 supporting · 6 submodules Finite-dimensional l1-linfinity duality helpers: polynomial evaluation maps, moment systems, weak and strong duality, and Hahn-Banach setup.
Bernoulli­KL 2 core · 2 supporting This file proves a scalar upper bound on the Kullback--Leibler divergence between two Bernoulli laws whose success probabilities both lie in the interval $[1/4,3/4]$. ★ bernoulli_kl_le_four_sq_sub_of_mem_quarter_band

Bernoulli KL Band Bound

This file proves a scalar upper bound on the Kullback--Leibler divergence between two Bernoulli laws whose success probabilities both lie in the interval [1/4,3/4][1/4,3/4]. It supplies a Mathlib-adjacent analytic estimate used by finite-sample information arguments elsewhere in the library.

def bernD reviewed
Causalean.Mathlib.Analysis

The negative Bernoulli entropy at a probability is the sum of that probability times its logarithm and its complementary probability times the logarithm of the complement.

Definition (Lean source)
noncomputable def bernD (t : ℝ) : ℝ := t * log t + (1 - t) * log (1 - t)
Causalean.Mathlib.Analysis.bernD · Causalean/Mathlib/Analysis/BernoulliKL.lean:61
theorem bernoulli_kl_le_four_sq_sub_of_mem_quarter_band reviewed
Causalean.Mathlib.Analysis

For probabilities p and q both restricted to the band [1/4, 3/4], the Bernoulli Kullback–Leibler divergence p · log(p / q) + (1 - p) · log((1 - p) / (1 - q)) is bounded above by 4 · (p - q) ^ 2.

Formal statement
p q :
hp_lo :
(1 : ℝ) / 4 ≤ p
hp_hi :
p ≤ 3 / 4
hq_lo :
(1 : ℝ) / 4 ≤ q
hq_hi :
q ≤ 3 / 4
p * log (p / q) + (1 - p) * log ((1 - p) / (1 - q)) ≤ 4 * (p - q) ^ 2
Proof (Lean source)
theorem bernoulli_kl_le_four_sq_sub_of_mem_quarter_band {p q : ℝ} (hp_lo : (1 : ℝ) / 4 ≤ p) (hp_hi : p ≤ 3 / 4) (hq_lo : (1 : ℝ) / 4 ≤ q) (hq_hi : q ≤ 3 / 4) : p * log (p / q) + (1 - p) * log ((1 - p) / (1 - q)) ≤ 4 * (p - q) ^ 2 := by have hp0 : p ≠ 0 := by nlinarith have hp1 : 1 - p ≠ 0 := by nlinarith have hq0 : q ≠ 0 := by nlinarith have hq1 : 1 - q ≠ 0 := by nlinarith rw [bernoulliKL_eq_bregman hp0 hp1 hq0 hq1] have hnonneg := bernH_nonneg_of_mem_quarter_band hp_lo hp_hi hq_lo hq_hi unfold bernH at hnonneg linarith
Causalean.Mathlib.Analysis.bernoulli_kl_le_four_sq_sub_of_mem_quarter_band · Causalean/Mathlib/Analysis/BernoulliKL.lean:193
2 supporting declarations (lemmas, instances)
  • hasDerivAt_bernEntropy lemma — Away from zero and one, the negative Bernoulli entropy has derivative equal to the log odds of its argument.
    x :
    hx0 :
    x ≠ 0
    hx1 :
    1 - x ≠ 0
    HasDerivAt (fun t : ℝ => t * log t + (1 - t) * log (1 - t)) (log x - log (1 - x)) x
    Proof (Lean source)
    lemma hasDerivAt_bernEntropy (x : ℝ) (hx0 : x ≠ 0) (hx1 : 1 - x ≠ 0) : HasDerivAt (fun t : ℝ => t * log t + (1 - t) * log (1 - t)) (log x - log (1 - x)) x := by have h1 : HasDerivAt (fun t : ℝ => t * log t) (log x + 1) x := Real.hasDerivAt_mul_log hx0 have hsub : HasDerivAt (fun t : ℝ => 1 - t) (0 - 1) x := (hasDerivAt_const x (1 : ℝ)).fun_sub (hasDerivAt_id' (x := x)) have h2log : HasDerivAt (fun t : ℝ => log (1 - t)) (-(1 - x)⁻¹) x := by have h : HasDerivAt (fun t : ℝ => log (1 - t)) ((1 - x)⁻¹ * (0 - 1)) x := (Real.hasDerivAt_log hx1).comp x hsub convert h using 1 ring have h2 : HasDerivAt (fun t : ℝ => (1 - t) * log (1 - t)) (-(log (1 - x)) - 1) x := by have h : HasDerivAt (fun t : ℝ => (1 - t) * log (1 - t)) _ x := hsub.fun_mul h2log convert h using 1 rw [mul_neg, mul_inv_cancel₀ hx1] ring have h : HasDerivAt (fun t : ℝ => t * log t + (1 - t) * log (1 - t)) _ x := h1.fun_add h2 convert h using 1 ring
    Causalean.Mathlib.Analysis.hasDerivAt_bernEntropy · Causalean/Mathlib/Analysis/BernoulliKL.lean:36
  • bernoulliKL_eq_bregman lemma — Bernoulli Kullback–Leibler divergence equals the Bregman remainder of the negative entropy function at the second probability.
    p q :
    hp0 :
    p ≠ 0
    hp1 :
    1 - p ≠ 0
    hq0 :
    q ≠ 0
    hq1 :
    1 - q ≠ 0
    p * log (p / q) + (1 - p) * log ((1 - p) / (1 - q))
    = bernD p - bernD q - (log q - log (1 - q)) * (p - q)
    Proof (Lean source)
    lemma bernoulliKL_eq_bregman {p q : ℝ} (hp0 : p ≠ 0) (hp1 : 1 - p ≠ 0) (hq0 : q ≠ 0) (hq1 : 1 - q ≠ 0) : p * log (p / q) + (1 - p) * log ((1 - p) / (1 - q)) = bernD p - bernD q - (log q - log (1 - q)) * (p - q) := by rw [Real.log_div hp0 hq0, Real.log_div hp1 hq1] unfold bernD ring
    Causalean.Mathlib.Analysis.bernoulliKL_eq_bregman · Causalean/Mathlib/Analysis/BernoulliKL.lean:183
Clip­Interval 3 core · 11 supporting Truncating (clipping, clamping, winsorising) a real number to a closed interval [a, b] is ubiquitous in estimation: propensity scores are clipped away from 0 and 1, outcomes and privatised statistics are clipped to a sym ★ abs_clipIcc_sub_le★ clipIcc_sub_sq_le

Clipping a real number into a closed interval

Truncating (clipping, clamping, winsorising) a real number to a closed interval [a, b] is ubiquitous in estimation: propensity scores are clipped away from 0 and 1, outcomes and privatised statistics are clipped to a symmetric band [-B, B], and so on. Every such argument needs the same four facts — the clipped value lies in the interval, values already inside are untouched, the map is 1-Lipschitz, and clipping never increases the distance (nor the squared distance) to any target that is itself inside the interval.

Mathlib proves the contraction property, but only for the subtype-valued projection Set.projIcc : ℝ → Set.Icc a b, which is awkward to use when the surrounding development works with plain reals. This file provides the real-valued companion clipIcc a b x = max a (min b x) (definitionally the underlying value of Set.projIcc) together with the facts above, so that a symmetric band [-B, B], an asymmetric propensity band [q, 1 - q], and either the max-outside or the min-outside spelling are all instances of one API.

def clipIcc reviewed
Causalean.Mathlib.Analysis

Clip to an interval. clipIcc a b x is x pushed into the closed interval from a to b: it returns a when x falls below a, b when x exceeds b, and x itself otherwise. It is the plain real-valued form of the projection onto the interval.

Definition (Lean source)
noncomputable def clipIcc (a b x : ℝ) : ℝ := max a (min b x)
Causalean.Mathlib.Analysis.clipIcc · Causalean/Mathlib/Analysis/ClipInterval.lean:31
lemma abs_clipIcc_sub_le reviewed
Causalean.Mathlib.Analysis

Clipping toward an in-interval target does not increase distance. If a real number lies in the closed interval from a to b, then for any real x, clipping x into that interval moves it no farther from the target than x itself was.

Formal statement
ht :
t ∈ Icc a b
x :
|clipIcc a b x - t| ≤ |x - t|
Proof (Lean source)
lemma abs_clipIcc_sub_le (ht : t ∈ Icc a b) (x : ℝ) : |clipIcc a b x - t| ≤ |x - t| := by simpa [clipIcc_eq_self ht] using abs_clipIcc_sub_clipIcc_le a b x t
Causalean.Mathlib.Analysis.abs_clipIcc_sub_le · Causalean/Mathlib/Analysis/ClipInterval.lean:77 · uses clipIcc
lemma clipIcc_sub_sq_le reviewed
Causalean.Mathlib.Analysis

Squared version: clipping toward an in-interval target does not increase squared distance. If a real number lies in the closed interval from a to b, then for any real x, the squared distance from the clipped value of x to the target is at most the squared distance from x itself to the target.

Formal statement
ht :
t ∈ Icc a b
x :
(clipIcc a b x - t) ^ 2 ≤ (x - t) ^ 2
Proof (Lean source)
lemma clipIcc_sub_sq_le (ht : t ∈ Icc a b) (x : ℝ) : (clipIcc a b x - t) ^ 2 ≤ (x - t) ^ 2 := by have h := abs_clipIcc_sub_le ht x calc (clipIcc a b x - t) ^ 2 = |clipIcc a b x - t| ^ 2 := (sq_abs _).symm _ ≤ |x - t| ^ 2 := by gcongr _ = (x - t) ^ 2 := sq_abs _
Causalean.Mathlib.Analysis.clipIcc_sub_sq_le · Causalean/Mathlib/Analysis/ClipInterval.lean:87 · uses clipIcc
11 supporting declarations (lemmas, instances)
Convex­Projection 7 core · 24 supporting This module provides metric projection onto a nonempty closed convex subset of a real Hilbert space, together with its variational, contraction, continuity, and measurability properties. ★ loewnerProj_frobDist_le

Projection onto closed convex sets

This module provides metric projection onto a nonempty closed convex subset of a real Hilbert space, together with its variational, contraction, continuity, and measurability properties. It also specializes the construction to a Loewner interval of real matrices, using Frobenius distance, and supplies the associated matrix inequalities.

def convexProj reviewed
Causalean.Mathlib.Analysis

Metric projection assigns each point in a real Hilbert space its nearest point in a specified nonempty closed convex set.

Definition (Lean source)
noncomputable def convexProj (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) : E → E := fun x => choose (exists_norm_eq_iInf_of_complete_convex hne hc.isComplete hconv x)
Causalean.Mathlib.Analysis.convexProj · Causalean/Mathlib/Analysis/ConvexProjection.lean:35
def loewnerSet reviewed
Causalean.Mathlib.Analysis

A Loewner interval contains the real matrices bounded between two scalar multiples of the identity matrix in positive-semidefinite order.

Definition (Lean source)
def loewnerSet (p : ℕ) (c C : ℝ) : Set (Matrix (Fin p) (Fin p) ℝ) := {G | (G - c • (1 : Matrix (Fin p) (Fin p) ℝ)).PosSemidef ∧ (C • (1 : Matrix (Fin p) (Fin p) ℝ) - G).PosSemidef}
Causalean.Mathlib.Analysis.loewnerSet · Causalean/Mathlib/Analysis/ConvexProjection.lean:128
def frobDist reviewed
Causalean.Mathlib.Analysis

The Frobenius distance between two real matrices is the square root of the sum of the squared entrywise differences.

Definition (Lean source)
noncomputable def frobDist (A B : Matrix (Fin p) (Fin p) ℝ) : ℝ := sqrt (∑ k : Fin p, ∑ l : Fin p, (A k l - B k l) ^ 2)
Causalean.Mathlib.Analysis.frobDist · Causalean/Mathlib/Analysis/ConvexProjection.lean:134
def mtx reviewed
Causalean.Mathlib.Analysis

Finite real matrices are linearly equivalent to Euclidean vectors indexed by pairs of row and column coordinates.

Definition (Lean source)
noncomputable def mtx (p : ℕ) : Matrix (Fin p) (Fin p) ℝ ≃ₗ[ℝ] EuclideanSpace ℝ (Fin p × Fin p) := (LinearEquiv.curry ℝ ℝ (Fin p) (Fin p)).symm.trans (EuclideanSpace.equiv (Fin p × Fin p) ℝ).symm.toLinearEquiv
def mtxHomeo reviewed
Causalean.Mathlib.Analysis

Finite square real matrices of dimension p are homeomorphic to Euclidean vectors indexed by their row and column coordinates.

Definition (Lean source)
noncomputable def mtxHomeo (p : ℕ) : Matrix (Fin p) (Fin p) ℝ ≃ₜ EuclideanSpace ℝ (Fin p × Fin p) := Homeomorph.piCurry.symm.trans (EuclideanSpace.equiv (Fin p × Fin p) ℝ).symm.toHomeomorph
Causalean.Mathlib.Analysis.mtxHomeo · Causalean/Mathlib/Analysis/ConvexProjection.lean:146
def loewnerProj reviewed
Causalean.Mathlib.Analysis

Loewner projection is the nearest-point projection in Frobenius geometry when the interval endpoints are ordered, and is the identity map when they are reversed.

Definition (Lean source)
noncomputable def loewnerProj (p : ℕ) (c C : ℝ) : Matrix (Fin p) (Fin p) ℝ → Matrix (Fin p) (Fin p) ℝ := if h : c ≤ C then loewnerProjAux p c C h else id
Causalean.Mathlib.Analysis.loewnerProj · Causalean/Mathlib/Analysis/ConvexProjection.lean:264
theorem loewnerProj_frobDist_le reviewed
Causalean.Mathlib.Analysis

Loewner projection is a nonexpansive (nearest-point) map. For ordered interval endpoints c ≤ C, if a target matrix already lies in the Loewner interval [cI, CI], then projecting an arbitrary matrix onto that interval, in Frobenius geometry, does not increase its Frobenius distance to the in-interval target matrix.

Formal statement
hcC :
c ≤ C
G S :
Matrix (Fin p) (Fin p) ℝ
hS :
S ∈ loewnerSet p c C
frobDist (loewnerProj p c C G) S ≤ frobDist G S
Proof (Lean source)
theorem loewnerProj_frobDist_le (hcC : c ≤ C) (G S : Matrix (Fin p) (Fin p) ℝ) (hS : S ∈ loewnerSet p c C) : frobDist (loewnerProj p c C G) S ≤ frobDist G S := by rw [frobDist_eq_norm, frobDist_eq_norm, loewnerProj, dif_pos hcC, loewnerProjAux] simp only [LinearEquiv.apply_symm_apply] exact convexProj_le_of_mem (mtx p '' loewnerSet p c C) ((loewnerSet_nonempty p c C hcC).image (mtx p)) (mtx_image_isClosed p c C) ((loewnerSet_convex p c C).linear_image (mtx p).toLinearMap) (mtx p G) (mtx p S) ⟨S, hS, rfl⟩
Causalean.Mathlib.Analysis.loewnerProj_frobDist_le · Causalean/Mathlib/Analysis/ConvexProjection.lean:282 · uses frobDist , loewnerProj , loewnerSet
24 supporting declarations (lemmas, instances)
Frechet­Functional­Equation 1 core · 0 supporting Fréchet-style finite-difference arguments appear in classical proofs of independence characterization theorems. ★ affine_of_continuous_of_second_diff_zero

Fréchet's functional equation (degree-one case)

Fréchet-style finite-difference arguments appear in classical proofs of independence characterization theorems. This file proves the foundational degree-one case: a continuous function with vanishing second forward difference is affine (affine_of_continuous_of_second_diff_zero).

The argument is classical: a vanishing second difference makes f midpoint-affine; subtracting f 0 yields an additive function; a continuous additive map of real vector spaces is -linear (AddMonoidHom.toRealLinearMap).

theorem affine_of_continuous_of_second_diff_zero reviewed
Causalean.Mathlib.Analysis

Fréchet functional equation, degree one. If f is a continuous function from the reals into a normed real vector space and its second forward difference vanishes: f(x+2s) + f(x) = 2·f(x+s) for all real x and s, then f is affine — there exist vectors a and b such that f(x) = a + x·b for every real x.

Formal statement
f :
ℝ → E
hf :
h2 :
∀ x s : ℝ, f (x + s + s) + f x = f (x + s) + f (x + s)
∃ a b : E, ∀ x, f x = a + x • b
Proof (Lean source)
theorem affine_of_continuous_of_second_diff_zero {f : ℝ → E} (hf : Continuous f) (h2 : ∀ x s : ℝ, f (x + s + s) + f x = f (x + s) + f (x + s)) : ∃ a b : E, ∀ x, f x = a + x • b := by -- Midpoint identity. have hmid : ∀ p q : ℝ, f p + f q = f ((p + q) / 2) + f ((p + q) / 2) := by intro p q have h := h2 p ((q - p) / 2) rw [show p + (q - p) / 2 + (q - p) / 2 = q from by ring, show p + (q - p) / 2 = (p + q) / 2 from by ring] at h rw [add_comm (f p) (f q)]; exact h -- Doubling identity. have hdouble : ∀ u : ℝ, f (u + u) + f 0 = f u + f u := by intro u; simpa using h2 0 u -- Additivity of `x ↦ f x - f 0`. have hadd : ∀ a b : ℝ, f (a + b) - f 0 = (f a - f 0) + (f b - f 0) := by intro a b have hm := hmid (a + a) (b + b) rw [show (a + a + (b + b)) / 2 = a + b from by ring] at hm have ha := hdouble a have hb := hdouble b -- `(f a + f a) + (f b + f b) = (f (a+b) + f (a+b)) + (f 0 + f 0)` have hsum : (f a + f a) + (f b + f b) = (f (a + b) + f (a + b)) + (f 0 + f 0) := by rw [← ha, ← hb, show (f (a + a) + f 0) + (f (b + b) + f 0) = (f (a + a) + f (b + b)) + (f 0 + f 0) from by abel, hm] -- Cancel the doubling via the `ℝ`-action. have hXY : f a + f b = f (a + b) + f 0 := by have h2s : (2 : ℝ) • (f a + f b) = (2 : ℝ) • (f (a + b) + f 0) := by rw [two_smul, two_smul, show (f a + f b) + (f a + f b) = (f a + f a) + (f b + f b) from by abel, show (f (a + b) + f 0) + (f (a + b) + f 0) = (f (a + b) + f (a + b)) + (f 0 + f 0) from by abel, hsum] exact smul_right_injective E two_ne_zero h2s have hfab : f (a + b) = (f a + f b) - f 0 := eq_sub_of_add_eq hXY.symm rw [hfab]; abel -- Continuous additive ⟹ `ℝ`-linear. have hgcont : Continuous (fun x => f x - f 0) := hf.sub continuous_const let φ : ℝ →+ E := AddMonoidHom.mk' (fun x => f x - f 0) hadd let L : ℝ →L[ℝ] E := φ.toRealLinearMap hgcont have hLx : ∀ x, L x = f x - f 0 := by intro x have : ⇑L = ⇑φ := φ.coe_toRealLinearMap hgcont rw [this]; rfl refine ⟨f 0, L 1, fun x => ?_⟩ have hlin : f x - f 0 = x • L 1 := by rw [← hLx x, show L x = L (x • (1 : ℝ)) from by rw [smul_eq_mul, mul_one], map_smul] rw [← hlin]; abel
Causalean.Mathlib.Analysis.affine_of_continuous_of_second_diff_zero · Causalean/Mathlib/Analysis/FrechetFunctionalEquation.lean:27
Gradient­Coord 1 core · 0 supporting A single bridge lemma: the a-th coordinate of the (Riesz) gradient of a real-valued function on a finite-dimensional Euclidean space equals the ordinary one-variable derivative of the function along the a-th coordinate l ★ gradient_coord_eq_deriv

Coordinates of a Euclidean gradient as directional derivatives

A single bridge lemma: the a-th coordinate of the (Riesz) gradient of a real-valued function on a finite-dimensional Euclidean space equals the ordinary one-variable derivative of the function along the a-th coordinate line. This is the standard tool for computing a gradient coordinate by coordinate — reduce each entry to a deriv of a one-parameter restriction, which the univariate calculus API can then evaluate.

lemma gradient_coord_eq_deriv reviewed
Causalean.Mathlib

Gradient coordinate as a directional derivative. For a real-valued function f on a finite-dimensional Euclidean space that is differentiable at the point x, the a-th coordinate of its gradient at x equals the derivative at 0 of the one-variable restriction t ↦ f(x + t·eₐ) along the a-th standard basis direction.

Formal statement
ι :
f :
EuclideanSpace ℝ ι → ℝ
x :
a :
ι
hf :
(gradient f x) a = deriv (fun t : ℝ => f (x + t • single a (1 : ℝ))) 0
Proof (Lean source)
lemma gradient_coord_eq_deriv {ι : Type*} [Fintype ι] [DecidableEq ι] (f : EuclideanSpace ℝ ι → ℝ) (x : EuclideanSpace ℝ ι) (a : ι) (hf : DifferentiableAt ℝ f x) : (gradient f x) a = deriv (fun t : ℝ => f (x + t • single a (1 : ℝ))) 0 := by have hinner : ⟪EuclideanSpace.single a (1 : ℝ), gradient f x⟫_ℝ = fderiv ℝ f x (single a (1 : ℝ)) := by rw [real_inner_comm] exact inner_gradient_left (𝕜 := ℝ) (f := f) (x := x) (y := single a (1 : ℝ)) have hline : HasDerivAt (fun t : ℝ => x + t • single a (1 : ℝ)) (single a (1 : ℝ)) 0 := by simpa using (((hasDerivAt_id (0 : ℝ)).smul_const (single a (1 : ℝ))).const_add x) have hderiv : HasDerivAt (fun t : ℝ => f (x + t • single a (1 : ℝ))) (fderiv ℝ f x (single a (1 : ℝ))) 0 := by have hf' : HasFDerivAt f (fderiv ℝ f x) (x + (0 : ℝ) • single a (1 : ℝ)) := by simpa using hf.hasFDerivAt exact hf'.comp_hasDerivAt (0 : ℝ) hline calc (gradient f x) a = ⟪EuclideanSpace.single a (1 : ℝ), gradient f x⟫_ℝ := by have hs : ⟪EuclideanSpace.single a (1 : ℝ), gradient f x⟫_ℝ = (gradient f x) a := by simpa using EuclideanSpace.inner_single_left a (1 : ℝ) (gradient f x) exact hs.symm _ = fderiv ℝ f x (single a (1 : ℝ)) := hinner _ = deriv (fun t : ℝ => f (x + t • single a (1 : ℝ))) 0 := hderiv.deriv.symm
Causalean.Mathlib.gradient_coord_eq_deriv · Causalean/Mathlib/Analysis/GradientCoord.lean:26
Half­Disc­Polar 3 core · 14 supporting 3 to review This module derives weighted polar-integration formulas on upper half-discs, including radial mass identities, odd-angular cancellation, quadratic angular moments, and translation-invariant variants. ★ halfDisc_weighted_polar_integral

Polar integration and cancellation on half-discs

This module derives weighted polar-integration formulas on upper half-discs, including radial mass identities, odd-angular cancellation, quadratic angular moments, and translation-invariant variants.

def planarRadius unreviewed
Causalean.Mathlib.Analysis

The Euclidean radius on the real coordinate plane. This is explicit because the product type ℝ × ℝ carries the max product norm, not the Euclidean norm.

Definition (Lean source)
-- @node: planarRadius noncomputable def planarRadius (z : ℝ × ℝ) : ℝ := sqrt (z.1 ^ 2 + z.2 ^ 2)
Causalean.Mathlib.Analysis.planarRadius · Causalean/Mathlib/Analysis/HalfDiscPolar.lean:18
def planarAngle unreviewed
Causalean.Mathlib.Analysis

The polar angle of a nonzero point, using Mathlib's polar-coordinate chart. Only its values on the open upper half-plane are used below.

Definition (Lean source)
-- @node: planarAngle noncomputable def planarAngle (z : ℝ × ℝ) : ℝ := (polarCoord z).2
Causalean.Mathlib.Analysis.planarAngle · Causalean/Mathlib/Analysis/HalfDiscPolar.lean:30
lemma halfDisc_weighted_polar_integral unreviewed
Causalean.Mathlib.Analysis

For radial and angular weight functions g and h and a radius r, the integral of the product g(radius)·h(angle) over the open upper half-disc of radius r factors as the product of the radial integral ∫ s·g(s) ds over (0, r] and the angular integral ∫ h(θ) dθ over (0, π).

Formal statement
g h :
ℝ → ℝ
r :
(∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * h (planarAngle z))
= (∫ s : ℝ in Ioc 0 r, s * g s) * (∫ θ : ℝ in Ioo 0 pi, h θ)
Proof (Lean source)
-- @node: halfDisc_weighted_polar_integral lemma halfDisc_weighted_polar_integral (g h : ℝ → ℝ) (r : ℝ) : (∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * h (planarAngle z)) = (∫ s : ℝ in Ioc 0 r, s * g s) * (∫ θ : ℝ in Ioo 0 Real.pi, h θ) := by let D : Set (ℝ × ℝ) := {z | 0 < z.2 ∧ planarRadius z ≤ r} let E : Set (ℝ × ℝ) := Ioc 0 r ×ˢ Ioo 0 Real.pi have hD : MeasurableSet D := by exact (measurableSet_lt measurable_const measurable_snd).inter (measurableSet_le ((measurable_fst.pow_const 2).add (measurable_snd.pow_const 2)).sqrt measurable_const) have hE : MeasurableSet E := measurableSet_Ioc.prod measurableSet_Ioo change (∫ z : ℝ × ℝ in D, g (planarRadius z) * h (planarAngle z)) = _ rw [← integral_indicator hD, ← integral_comp_polarCoord_symm] rw [show (∫ p in polarCoord.target, p.1 • D.indicator (fun z => g (planarRadius z) * h (planarAngle z)) (polarCoord.symm p)) = ∫ p in E, (p.1 * g p.1) * h p.2 by rw [← integral_indicator polarCoord.open_target.measurableSet, ← integral_indicator hE] apply integral_congr_ae filter_upwards with p by_cases hp : p ∈ polarCoord.target · have hptarget := hp simp only [polarCoord_target, mem_prod, mem_Ioi, mem_Ioo] at hp have hinv := polarCoord.right_inv hp have hrs : planarRadius (polarCoord.symm p) = p.1 := congrArg Prod.fst hinv have htheta : planarAngle (polarCoord.symm p) = p.2 := congrArg Prod.snd hinv have hsin : 0 < sin p.2 ↔ 0 < p.2 := by constructor · intro hs by_contra hn exact (not_lt_of_ge (Real.sin_nonpos_of_nonpos_of_neg_pi_le (le_of_not_gt hn) hp.2.1.le)) hs · intro htheta0 exact Real.sin_pos_of_pos_of_lt_pi htheta0 hp.2.2 have hy : 0 < p.1 * sin p.2 ↔ 0 < p.2 := (mul_pos_iff_of_pos_left hp.1).trans hsin have hmem : polarCoord.symm p ∈ D ↔ p ∈ E := by change (0 < (polarCoord.symm p).2 ∧ planarRadius (polarCoord.symm p) ≤ r) ↔ (0 < p.1 ∧ p.1 ≤ r) ∧ 0 < p.2 ∧ p.2 < Real.pi rw [hrs] simp only [polarCoord_symm_apply] rw [hy] constructor · rintro ⟨hptheta, hpr⟩ exact ⟨⟨hp.1, hpr⟩, hptheta, hp.2.2⟩ · rintro ⟨⟨_, hpr⟩, hptheta0, _⟩ exact ⟨hptheta0, hpr⟩ by_cases hmemD : polarCoord.symm p ∈ D · rw [indicator_of_mem hptarget, indicator_of_mem hmemD, indicator_of_mem (hmem.mp hmemD), hrs, htheta] simp [smul_eq_mul] ring · rw [indicator_of_mem hptarget] simp only [indicator] rw [if_neg hmemD, if_neg (mt hmem.mpr hmemD)] simp · have hpE : p ∉ E := by rintro ⟨⟨hp0, _⟩, hptheta0, hpthetapi⟩ apply hp simp only [polarCoord_target, mem_prod, mem_Ioi, mem_Ioo] exact ⟨hp0, lt_trans (neg_lt_zero.mpr Real.pi_pos) hptheta0, hpthetapi⟩ simp only [indicator] rw [if_neg hp, if_neg hpE] ] change (∫ p in Ioc 0 r ×ˢ Ioo 0 Real.pi, (p.1 * g p.1) * h p.2) = _ rw [Measure.volume_eq_prod] exact setIntegral_prod_mul (μ := volume) (ν := volume) (fun s : ℝ => s * g s) h (Ioc 0 r) (Ioo 0 Real.pi)
Causalean.Mathlib.Analysis.halfDisc_weighted_polar_integral · Causalean/Mathlib/Analysis/HalfDiscPolar.lean:52 · uses planarAngle , planarRadius
14 supporting declarations (lemmas, instances)
Line­Second­Deriv 2 core · 6 supporting For f : E → ℝ and a direction d : E, the restriction of f to the line s ↦ f (q + s • d) has first and second derivatives expressible as directional derivatives of f at the moving base point q + t • d: * deriv_line : deri ★ convexOn_deriv2_nonneg

Second directional derivative along an affine line

For f : E → ℝ and a direction d : E, the restriction of f to the line s ↦ f (q + s • d) has first and second derivatives expressible as directional derivatives of f at the moving base point q + t • d:

* deriv_line : deriv (fun s => f (q + s • d)) t = fderiv ℝ f (q + t • d) d * deriv_deriv_line: `deriv (deriv fun s => f (q + s • d)) t = secondDirDeriv f d (q + t • d)`

where secondDirDeriv f d q = fderiv ℝ (fun x => fderiv ℝ f x d) q d. Two consequences make secondDirDeriv usable as a curvature modulus over a constraint set:

* continuous_secondDirDeriv : it is continuous in the base point (so it is bounded on a compact set, giving the BddAbove needed for a ciSup), and * convexOn_deriv2_nonneg : a convex function of one variable has nonnegative second derivative at interior points (so such a modulus is nonnegative).

Mathlib has convexOn_of_deriv2_nonneg (sufficiency) but not the converse used here.

The statements are objective-agnostic: callers supply ContDiff ℝ 2 f and read off the directional curvature. This is the substrate behind the dirModulus / EnvelopeLineC2Data discharge for the reciprocal-product variance envelope.

def secondDirDeriv reviewed
Causalean.Mathlib.Analysis

The second directional derivative of f at q along d: the directional derivative, along d, of the map x ↦ fderiv ℝ f x d. For functions this is the value Hess f q (d, d) of the Hessian quadratic form.

Definition (Lean source)
noncomputable def secondDirDeriv (f : E → ℝ) (d : E) (q : E) : ℝ := fderiv ℝ (fun x => fderiv ℝ f x d) q d
Causalean.Mathlib.Analysis.secondDirDeriv · Causalean/Mathlib/Analysis/LineSecondDeriv.lean:41
lemma convexOn_deriv2_nonneg reviewed
Causalean.Mathlib.Analysis

A convex function of one real variable has nonnegative second derivative at interior points of its domain. If g is convex on the set S, differentiable at every point of S, x lies in the interior of S, and the derivative of g is itself differentiable at x, then the second derivative of g at x is nonnegative.

Formal statement
S :
Set
g :
ℝ → ℝ
x :
hconv :
ConvexOn ℝ S g
hdiff :
∀ y ∈ S, DifferentiableAt ℝ g y
hx :
x ∈ interior S
hdd :
0 ≤ deriv (deriv g) x
Proof (Lean source)
lemma convexOn_deriv2_nonneg {S : Set ℝ} {g : ℝ → ℝ} {x : ℝ} (hconv : ConvexOn ℝ S g) (hdiff : ∀ y ∈ S, DifferentiableAt ℝ g y) (hx : x ∈ interior S) (hdd : DifferentiableAt ℝ (deriv g) x) : 0 ≤ deriv (deriv g) x := by have hacc : AccPt x (𝓟 S) := by have hacc' : AccPt x (𝓟 (interior S)) := by simpa using (PerfectSpace.univ_preperfect.open_inter isOpen_interior x ⟨hx, mem_univ x⟩) exact hacc'.mono (principal_mono.mpr interior_subset) exact hdd.hasDerivAt.hasDerivWithinAt.nonneg_of_monotoneOn hacc (hconv.monotoneOn_deriv hdiff)
Causalean.Mathlib.Analysis.convexOn_deriv2_nonneg · Causalean/Mathlib/Analysis/LineSecondDeriv.lean:92
6 supporting declarations (lemmas, instances)
Monomial­Gram 4 core · 8 supporting This module proves that distinct multivariate monomials have a positive-definite Gram matrix on every nondegenerate real cube. ★ monomialGram_posDef

Multivariate monomial Gram matrices

This module proves that distinct multivariate monomials have a positive-definite Gram matrix on every nondegenerate real cube. It also supplies the resulting uniform quadratic coercivity bound.

def supBall reviewed
Causalean.Mathlib.Analysis

The closed sup-norm ball contains the vectors whose every coordinate lies within the stated radius of the corresponding coordinate of the center.

Definition (Lean source)
def supBall {ι : Type*} (x0 : ι → ℝ) (r : ℝ) : Set (ι → ℝ) := {x | ∀ i, |x i - x0 i| ≤ r}
Causalean.Mathlib.Analysis.supBall · Causalean/Mathlib/Analysis/MonomialGram.lean:21
def monomial reviewed
Causalean.Mathlib.Analysis

A multivariate monomial multiplies the coordinates of a vector after raising each coordinate to its assigned nonnegative integer exponent.

Definition (Lean source)
def monomial {ι : Type*} [Fintype ι] (e : ι → ℕ) (u : ι → ℝ) : ℝ := ∏ j, (u j) ^ (e j)
Causalean.Mathlib.Analysis.monomial · Causalean/Mathlib/Analysis/MonomialGram.lean:26
def monomialGram reviewed
Causalean.Mathlib.Analysis

The monomial Gram matrix records the integrals of every pairwise product of a finite family of multivariate monomials over a centered closed cube.

Definition (Lean source)
noncomputable def monomialGram {d p : ℕ} (expo : Fin p → (Fin d → ℕ)) (r : ℝ) : Matrix (Fin p) (Fin p) ℝ := of fun k l => ∫ u in {u : Fin d → ℝ | ∀ j, |u j| ≤ r}, monomial (expo k) u * monomial (expo l) u
Causalean.Mathlib.Analysis.monomialGram · Causalean/Mathlib/Analysis/MonomialGram.lean:31
theorem monomialGram_posDef reviewed
Causalean.Mathlib.Analysis

Positive-definiteness of the monomial Gram matrix. For a finite family of multivariate monomials indexed by their exponent vectors, if the cube radius r is strictly positive and the exponent vectors are pairwise distinct, then the Gram matrix of pairwise integrals of the monomials over the cube of radius r is positive-definite.

Formal statement
d p :
expo :
Fin p → (Fin d → ℕ)
r :
hr :
0 < r
hexpo :
Proof (Lean source)
theorem monomialGram_posDef {d p : ℕ} (expo : Fin p → (Fin d → ℕ)) {r : ℝ} (hr : 0 < r) (hexpo : Injective expo) : (monomialGram expo r).PosDef := by apply Matrix.PosDef.of_dotProduct_mulVec_pos (monomialGram_isHermitian expo r) intro z hz rw [show star z = z by ext k; simp] simp only [dotProduct, mulVec, Finset.mul_sum] simp_rw [← mul_assoc] rw [monomialGram_quadForm expo z] let f : (Fin d → ℝ) → ℝ := fun u => ∑ k, z k * monomial (expo k) u have hfcont : Continuous f := continuous_monomialCombination expo z have hfint : IntegrableOn (fun u => (f u) ^ 2) (cube d r) := (hfcont.pow 2).continuousOn.integrableOn_compact (isCompact_cube d r) have hnonneg : 0 ≤ ∫ u in cube d r, (f u) ^ 2 := MeasureTheory.integral_nonneg_of_ae (Filter.Eventually.of_forall fun _ => sq_nonneg _) by_contra hpos have hintzero : (∫ u in cube d r, (f u) ^ 2) = 0 := le_antisymm (le_of_not_gt hpos) hnonneg have hae_sq : (fun u => (f u) ^ 2) =ᵐ[volume.restrict (cube d r)] 0 := (MeasureTheory.setIntegral_eq_zero_iff_of_nonneg_ae (Filter.Eventually.of_forall fun _ => sq_nonneg _) hfint).mp hintzero have hae_f : f =ᵐ[volume.restrict (cube d r)] 0 := hae_sq.mono fun u hu => by simpa using (sq_eq_zero_iff.mp hu) let U : Set (Fin d → ℝ) := pi univ (fun _ => Ioo (-r) r) have hUopen : IsOpen U := isOpen_set_pi Set.finite_univ (fun _ _ => isOpen_Ioo) have hUcube : U ⊆ cube d r := by intro u hu j rw [abs_le] exact ⟨(hu j (Set.mem_univ j)).1.le, (hu j (Set.mem_univ j)).2.le⟩ have hae_U : f =ᵐ[volume.restrict U] 0 := ae_restrict_of_ae_restrict_of_subset hUcube hae_f have hpoint : EqOn f 0 U := MeasureTheory.Measure.eqOn_open_of_ae_eq hae_U hUopen hfcont.continuousOn continuous_zero.continuousOn apply hz apply monomial_coefficients_eq_zero_of_vanishes_on_openCube hr hexpo z intro u hu exact hpoint (fun j _ => hu j)
Causalean.Mathlib.Analysis.monomialGram_posDef · Causalean/Mathlib/Analysis/MonomialGram.lean:183 · uses monomialGram
8 supporting declarations (lemmas, instances)
  • continuous_monomial lemma — A multivariate real monomial varies continuously with its coordinate vector.
    ι :
    Type*
    e :
    ι → ℕ
    Proof (Lean source)
    lemma continuous_monomial {ι : Type*} [Fintype ι] (e : ι → ℕ) : Continuous (monomial e) := by unfold monomial exact continuous_finset_prod _ fun j _ => (continuous_apply j).pow (e j)
    Causalean.Mathlib.Analysis.continuous_monomial · Causalean/Mathlib/Analysis/MonomialGram.lean:51
  • continuous_monomialCombination lemma — A finite linear combination of multivariate real monomials is continuous.
    d p :
    expo :
    Fin p → (Fin d → ℕ)
    z :
    Fin p → ℝ
    Continuous (fun u => ∑ k, z k * monomial (expo k) u)
    Proof (Lean source)
    lemma continuous_monomialCombination {d p : ℕ} (expo : Fin p → (Fin d → ℕ)) (z : Fin p → ℝ) : Continuous (fun u => ∑ k, z k * monomial (expo k) u) := by exact continuous_finset_sum _ fun k _ => continuous_const.mul (continuous_monomial (expo k))
    Causalean.Mathlib.Analysis.continuous_monomialCombination · Causalean/Mathlib/Analysis/MonomialGram.lean:57
  • monomial_linearIndependent_on_cube theorem — A linear combination of distinct multivariate monomials that vanishes throughout the interior of a cube with positive radius must have every coefficient equal to zero.
    d p :
    Fin p → (Fin d → ℕ)
    r :
    hr :
    0 < r
    hexpo :
    z :
    Fin p → ℝ
    hz :
    ∀ u
    if
    (∀ j, u j ∈ Ioo (-r) r)
    then
    (∑ k, z k * monomial (expo k) u) = 0
    z = 0
    Proof (Lean source)
    theorem monomial_linearIndependent_on_cube {d p : ℕ} {expo : Fin p → (Fin d → ℕ)} {r : ℝ} (hr : 0 < r) (hexpo : Injective expo) (z : Fin p → ℝ) (hz : ∀ u, (∀ j, u j ∈ Ioo (-r) r) → (∑ k, z k * monomial (expo k) u) = 0) : z = 0 := by exact monomial_coefficients_eq_zero_of_vanishes_on_openCube hr hexpo z hz
    Causalean.Mathlib.Analysis.monomial_linearIndependent_on_cube · Causalean/Mathlib/Analysis/MonomialGram.lean:115
  • monomialGram_quadForm theorem — Evaluating the monomial Gram quadratic form at a coefficient vector equals integrating the square of the corresponding monomial combination over the cube.
    d p :
    expo :
    Fin p → (Fin d → ℕ)
    r :
    z :
    Fin p → ℝ
    ∑ k, ∑ l, z k * monomialGram expo r k l * z l
    = ∫ u in {u : Fin d → ℝ | ∀ j, |u j| ≤ r}, (∑ k, z k * monomial (expo k) u) ^ 2
    Proof (Lean source)
    theorem monomialGram_quadForm {d p : ℕ} (expo : Fin p → (Fin d → ℕ)) {r : ℝ} (z : Fin p → ℝ) : ∑ k, ∑ l, z k * monomialGram expo r k l * z l = ∫ u in {u : Fin d → ℝ | ∀ j, |u j| ≤ r}, (∑ k, z k * monomial (expo k) u) ^ 2 := by change (∑ k, ∑ l, z k * (∫ u in cube d r, monomial (expo k) u * monomial (expo l) u) * z l) = _ have hkl (k l : Fin p) : IntegrableOn (fun u => (z k * monomial (expo k) u) * (z l * monomial (expo l) u)) (cube d r) := (((continuous_const.mul (continuous_monomial (expo k))).mul (continuous_const.mul (continuous_monomial (expo l)))).continuousOn.integrableOn_compact (isCompact_cube d r)) calc _ = ∑ k, ∑ l, ∫ u in cube d r, (z k * monomial (expo k) u) * (z l * monomial (expo l) u) := by apply Finset.sum_congr rfl intro k _ apply Finset.sum_congr rfl intro l _ rw [show (fun u => (z k * monomial (expo k) u) * (z l * monomial (expo l) u)) = fun u => (z k * z l) * (monomial (expo k) u * monomial (expo l) u) by funext u ring, MeasureTheory.integral_const_mul] ring _ = ∫ u in cube d r, ∑ k, ∑ l, (z k * monomial (expo k) u) * (z l * monomial (expo l) u) := by symm rw [MeasureTheory.integral_finset_sum univ (fun k _ => integrable_finset_sum _ fun l _ => hkl k l)] apply Finset.sum_congr rfl intro k _ rw [MeasureTheory.integral_finset_sum univ (fun l _ => hkl k l)] _ = ∫ u in cube d r, (∑ k, z k * monomial (expo k) u) ^ 2 := by congr 1 funext u rw [pow_two, Finset.sum_mul_sum]
    Causalean.Mathlib.Analysis.monomialGram_quadForm · Causalean/Mathlib/Analysis/MonomialGram.lean:123
  • monomialGram_isHermitian theorem — The monomial Gram matrix is symmetric, and hence Hermitian over the real numbers.
    d p :
    expo :
    Fin p → (Fin d → ℕ)
    r :
    Proof (Lean source)
    theorem monomialGram_isHermitian {d p : ℕ} (expo : Fin p → (Fin d → ℕ)) (r : ℝ) : (monomialGram expo r).IsHermitian := by apply Matrix.IsHermitian.ext intro k l simp only [star_id_of_comm] simp [monomialGram, mul_comm]
    Causalean.Mathlib.Analysis.monomialGram_isHermitian · Causalean/Mathlib/Analysis/MonomialGram.lean:163
  • monomialGram_posSemidef theorem — Every coefficient vector gives a nonnegative quadratic form under the monomial Gram matrix.
    d p :
    expo :
    Fin p → (Fin d → ℕ)
    r :
    Proof (Lean source)
    theorem monomialGram_posSemidef {d p : ℕ} (expo : Fin p → (Fin d → ℕ)) {r : ℝ} : (monomialGram expo r).PosSemidef := by apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg (monomialGram_isHermitian expo r) intro z rw [show star z = z by ext k; simp] simp only [dotProduct, mulVec, Finset.mul_sum] simp_rw [← mul_assoc] rw [monomialGram_quadForm expo z] exact MeasureTheory.integral_nonneg_of_ae (Filter.Eventually.of_forall fun _ => sq_nonneg _)
    Causalean.Mathlib.Analysis.monomialGram_posSemidef · Causalean/Mathlib/Analysis/MonomialGram.lean:171
  • sum_sq_pos lemma — The sum of squared coordinates of a nonzero finite real-valued vector is strictly positive.
    ι :
    Type*
    z :
    ι → ℝ
    hz :
    z ≠ 0
    0 < ∑ k, (z k) ^ 2
    Proof (Lean source)
    lemma sum_sq_pos {ι : Type*} [Fintype ι] (z : ι → ℝ) (hz : z ≠ 0) : 0 < ∑ k, (z k) ^ 2 := by have hnonneg : 0 ≤ ∑ k, (z k) ^ 2 := sum_nonneg fun _ _ => sq_nonneg _ refine lt_of_le_of_ne hnonneg ?_ intro heq apply hz funext k have hk : (z k) ^ 2 = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun _ _ => sq_nonneg _)).mp heq.symm k (Finset.mem_univ k) exact sq_eq_zero_iff.mp hk
    Causalean.Mathlib.Analysis.sum_sq_pos · Causalean/Mathlib/Analysis/MonomialGram.lean:228
  • exists_monomialGram_coercive theorem — A fixed family of distinct monomials on a cube with positive radius admits a positive uniform lower bound: its Gram quadratic form dominates the squared Euclidean norm of the coefficients.
    d p :
    expo :
    Fin p → (Fin d → ℕ)
    r :
    hr :
    0 < r
    hexpo :
    ∃ cmin : ℝ
    if
    0 < cmin ∧ ∀ z : Fin p
    then
    ℝ, cmin * (∑ k, (z k) ^ 2) ≤ ∑ k, ∑ l, z k * monomialGram expo r k l * z l
    Proof (Lean source)
    theorem exists_monomialGram_coercive {d p : ℕ} (expo : Fin p → (Fin d → ℕ)) {r : ℝ} (hr : 0 < r) (hexpo : Injective expo) : ∃ cmin : ℝ, 0 < cmin ∧ ∀ z : Fin p → ℝ, cmin * (∑ k, (z k) ^ 2) ≤ ∑ k, ∑ l, z k * monomialGram expo r k l * z l := by by_cases hp : p = 0 · subst p refine ⟨1, one_pos, ?_⟩ intro z simp have hp0 : 0 < p := Nat.pos_of_ne_zero hp let q : (Fin p → ℝ) → ℝ := fun z => ∑ k, ∑ l, z k * monomialGram expo r k l * z l let s2 : (Fin p → ℝ) → ℝ := fun z => ∑ k, (z k) ^ 2 let S : Set (Fin p → ℝ) := {z | s2 z = 1} have hqcont : Continuous q := by dsimp [q] fun_prop have hs2cont : Continuous s2 := by dsimp [s2] fun_prop have hSclosed : IsClosed S := by exact isClosed_eq hs2cont continuous_const have hSbounded : Bornology.IsBounded S := by apply (Metric.isBounded_iff_subset_closedBall 0).mpr refine ⟨1, ?_⟩ intro z hz rw [Metric.mem_closedBall, dist_zero_right] apply (pi_norm_le_iff_of_nonneg zero_le_one).mpr intro k rw [Real.norm_eq_abs, ← sq_le_one_iff_abs_le_one] have hk : (z k) ^ 2 ≤ 1 := by rw [← hz] exact Finset.single_le_sum (fun i _ => sq_nonneg (z i)) (Finset.mem_univ k) exact hk have hScompact : IsCompact S := Metric.isCompact_iff_isClosed_bounded.mpr ⟨hSclosed, hSbounded⟩ let e : Fin p := ⟨0, hp0⟩ let zunit : Fin p → ℝ := single e 1 have hzunit : zunit ∈ S := by classical simp [S, s2, zunit, Pi.single_apply] obtain ⟨zmin, hzmin, hmin⟩ := hScompact.exists_isMinOn ⟨zunit, hzunit⟩ hqcont.continuousOn have hPD := monomialGram_posDef expo hr hexpo have hzmin_ne : zmin ≠ 0 := by intro hzero simp [S, s2, hzero] at hzmin have hqmin_pos : 0 < q zmin := by have h := hPD.dotProduct_mulVec_pos hzmin_ne rw [show star zmin = zmin by ext k; simp] at h simpa only [q, dotProduct, mulVec, Finset.mul_sum, ← mul_assoc] using h refine ⟨q zmin, hqmin_pos, ?_⟩ intro z by_cases hz : z = 0 · simp [hz, q] have hspos : 0 < s2 z := by exact sum_sq_pos z hz let a : ℝ := (sqrt (s2 z))⁻¹ let w : Fin p → ℝ := a • z have hsqrt : (sqrt (s2 z)) ^ 2 = s2 z := by exact (Real.sq_sqrt hspos.le) have hsqrt_ne : sqrt (s2 z) ≠ 0 := (Real.sqrt_pos.2 hspos).ne' have hwS : w ∈ S := by simp only [S, Set.mem_setOf_eq, s2, w, Pi.smul_apply, smul_eq_mul] calc ∑ k, (a * z k) ^ 2 = a ^ 2 * ∑ k, (z k) ^ 2 := by simp_rw [mul_pow, Finset.mul_sum] _ = 1 := by dsimp [a] rw [inv_pow, hsqrt] exact inv_mul_cancel₀ hspos.ne' have hscale : q w = a ^ 2 * q z := by dsimp [q, w] symm rw [Finset.mul_sum] apply Finset.sum_congr rfl intro k _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro l _ ring have hlower : q zmin ≤ q w := hmin hwS rw [hscale] at hlower change q zmin * s2 z ≤ q z calc q zmin * s2 z ≤ (a ^ 2 * q z) * s2 z := mul_le_mul_of_nonneg_right hlower hspos.le _ = q z := by dsimp [a] rw [inv_pow, hsqrt] field_simp
    Causalean.Mathlib.Analysis.exists_monomialGram_coercive · Causalean/Mathlib/Analysis/MonomialGram.lean:241
Offset­Peeling 3 core · 6 supporting This file gives deterministic Young/weighted-AM-GM bounds that control expressions of the form a·t^θ after subtracting a linear offset in t. ★ offset_peeling

Offset peeling inequalities

This file gives deterministic Young/weighted-AM-GM bounds that control expressions of the form a·t^θ after subtracting a linear offset in t. It provides the quarter-offset constant offsetPeelingConstant, its general coefficient version offsetPeelingConstantC, the corresponding peeling bounds offset_peeling and offset_peeling_coeff, endpoint extensions at θ = 0, and max_two_split for splitting a clipped two-term offset across summands.

def offsetPeelingConstant reviewed
Causalean.Mathlib.OffsetPeeling

Offset-peeling constant for the c = 1/4 offset: (1 − θ)·(4θ)^{θ/(1−θ)}.

Definition (Lean source)
noncomputable def offsetPeelingConstant (θ : ℝ) : ℝ := (1 - θ) * (4 * θ) ^ (θ / (1 - θ))
Causalean.Mathlib.OffsetPeeling.offsetPeelingConstant · Causalean/Mathlib/Analysis/OffsetPeeling.lean:22
def offsetPeelingConstantC reviewed
Causalean.Mathlib.OffsetPeeling

Peeling constant with a general offset coefficient c: (1 − θ)·(θ/c)^{θ/(1−θ)} (the c = 1/4 case is offsetPeelingConstant).

Definition (Lean source)
noncomputable def offsetPeelingConstantC (c θ : ℝ) : ℝ := (1 - θ) * (θ / c) ^ (θ / (1 - θ))
Causalean.Mathlib.OffsetPeeling.offsetPeelingConstantC · Causalean/Mathlib/Analysis/OffsetPeeling.lean:27
lemma offset_peeling reviewed
Causalean.Mathlib.OffsetPeeling

Deterministic Young/AM-GM peeling for the quarter-offset. For an exponent strictly between zero and one and nonnegative coefficients a and t, the positive part of a·t^θ − t/4 is at most the offset-peeling constant times a raised to the power 1/(1−θ).

Formal statement
θ a t :
hθ_pos :
0 < θ
hθ_lt :
θ < 1
ha :
0 ≤ a
ht :
0 ≤ t
max 0 (a * t ^ θ - (1 / 4 : ℝ) * t) ≤ offsetPeelingConstant θ * a ^ (1 / (1 - θ))
Proof (Lean source)
lemma offset_peeling (θ a t : ℝ) (hθ_pos : 0 < θ) (hθ_lt : θ < 1) (ha : 0 ≤ a) (ht : 0 ≤ t) : max 0 (a * t ^ θ - (1 / 4 : ℝ) * t) ≤ offsetPeelingConstant θ * a ^ (1 / (1 - θ)) := by simpa [offsetPeelingConstant, offsetPeelingConstantC, div_eq_mul_inv, mul_comm] using offset_peeling_coeff (1 / 4) θ a t (by norm_num) hθ_pos hθ_lt ha ht
Causalean.Mathlib.OffsetPeeling.offset_peeling · Causalean/Mathlib/Analysis/OffsetPeeling.lean:125 · uses offsetPeelingConstant
6 supporting declarations (lemmas, instances)
  • offset_peeling_coeff lemma — Generalized offset peeling at coefficient c: for 0 < c, 0 < θ < 1, max 0 (a·t^θ − c·t) ≤ offsetPeelingConstantC c θ · a^{1/(1−θ)} (weighted AM-GM).
    c θ a t :
    hc_pos :
    0 < c
    hθ_pos :
    0 < θ
    hθ_lt :
    θ < 1
    ha :
    0 ≤ a
    ht :
    0 ≤ t
    max 0 (a * t ^ θ - c * t) ≤ offsetPeelingConstantC c θ * a ^ (1 / (1 - θ))
    Proof (Lean source)
    lemma offset_peeling_coeff (c θ a t : ℝ) (hc_pos : 0 < c) (hθ_pos : 0 < θ) (hθ_lt : θ < 1) (ha : 0 ≤ a) (ht : 0 ≤ t) : max 0 (a * t ^ θ - c * t) ≤ offsetPeelingConstantC c θ * a ^ (1 / (1 - θ)) := by have hθ_nonneg : 0 ≤ θ := le_of_lt hθ_pos have hone_sub_nonneg : 0 ≤ 1 - θ := sub_nonneg.mpr (le_of_lt hθ_lt) have hone_sub_pos : 0 < 1 - θ := sub_pos.mpr hθ_lt have hθc_pos : 0 < θ / c := div_pos hθ_pos hc_pos have hθc_nonneg : 0 ≤ θ / c := le_of_lt hθc_pos let p₁ : ℝ := c * t / θ let p₂ : ℝ := (θ / c) ^ (θ / (1 - θ)) * a ^ (1 / (1 - θ)) have hp₁ : 0 ≤ p₁ := div_nonneg (mul_nonneg (le_of_lt hc_pos) ht) hθ_nonneg have hp₂ : 0 ≤ p₂ := mul_nonneg (Real.rpow_nonneg hθc_nonneg _) (Real.rpow_nonneg ha _) have hw : θ + (1 - θ) = 1 := by ring have hamg := Real.geom_mean_le_arith_mean2_weighted hθ_nonneg hone_sub_nonneg hp₁ hp₂ hw have hrhs : θ * p₁ + (1 - θ) * p₂ = c * t + offsetPeelingConstantC c θ * a ^ (1 / (1 - θ)) := by dsimp [p₁, p₂, offsetPeelingConstantC] field_simp [ne_of_gt hθ_pos, ne_of_gt hone_sub_pos, ne_of_gt hc_pos] have hlhs : p₁ ^ θ * p₂ ^ (1 - θ) = a * t ^ θ := by dsimp [p₁, p₂] rw [Real.mul_rpow (Real.rpow_nonneg hθc_nonneg _) (Real.rpow_nonneg ha _)] rw [← Real.rpow_mul hθc_nonneg] rw [← Real.rpow_mul ha] have hpow₁ : θ / (1 - θ) * (1 - θ) = θ := by field_simp [ne_of_gt hone_sub_pos] have hpow₂ : 1 / (1 - θ) * (1 - θ) = 1 := by field_simp [ne_of_gt hone_sub_pos] rw [hpow₁, hpow₂, Real.rpow_one] rw [← mul_assoc] rw [← Real.mul_rpow hp₁ hθc_nonneg] have hdiv : c * t / θ * (θ / c) = t := by field_simp [ne_of_gt hθ_pos, ne_of_gt hc_pos] rw [hdiv] ring have hmain : a * t ^ θ ≤ c * t + offsetPeelingConstantC c θ * a ^ (1 / (1 - θ)) := by rw [← hlhs] simpa [hrhs] using hamg have hR_nonneg : 0 ≤ offsetPeelingConstantC c θ * a ^ (1 / (1 - θ)) := by dsimp [offsetPeelingConstantC] exact mul_nonneg (mul_nonneg hone_sub_nonneg (Real.rpow_nonneg hθc_nonneg _)) (Real.rpow_nonneg ha _) exact max_le (by simpa using hR_nonneg) (by linarith)
    Causalean.Mathlib.OffsetPeeling.offset_peeling_coeff · Causalean/Mathlib/Analysis/OffsetPeeling.lean:32
  • offsetPeelingConstantC_nonneg lemma — The general offset-peeling constant is nonnegative when the offset is positive and the exponent lies between zero and one.
    c θ :
    hc_nonneg :
    0 ≤ c
    hθ_nonneg :
    0 ≤ θ
    hθ_le :
    θ ≤ 1
    Proof (Lean source)
    lemma offsetPeelingConstantC_nonneg (c θ : ℝ) (hc_nonneg : 0 ≤ c) (hθ_nonneg : 0 ≤ θ) (hθ_le : θ ≤ 1) : 0 ≤ offsetPeelingConstantC c θ := by have hsub : 0 ≤ 1 - θ := sub_nonneg.mpr hθ_le have hbase : 0 ≤ θ / c := div_nonneg hθ_nonneg hc_nonneg unfold offsetPeelingConstantC exact mul_nonneg hsub (Real.rpow_nonneg hbase _)
    Causalean.Mathlib.OffsetPeeling.offsetPeelingConstantC_nonneg · Causalean/Mathlib/Analysis/OffsetPeeling.lean:88
  • offset_peeling_coeff_nonneg_theta lemma — The general offset-peeling bound remains valid at exponent zero by the same constant formula.
    c θ a t :
    hc_pos :
    0 < c
    hθ_nonneg :
    0 ≤ θ
    hθ_lt :
    θ < 1
    ha :
    0 ≤ a
    ht :
    0 ≤ t
    max 0 (a * t ^ θ - c * t) ≤ offsetPeelingConstantC c θ * a ^ (1 / (1 - θ))
    Proof (Lean source)
    lemma offset_peeling_coeff_nonneg_theta (c θ a t : ℝ) (hc_pos : 0 < c) (hθ_nonneg : 0 ≤ θ) (hθ_lt : θ < 1) (ha : 0 ≤ a) (ht : 0 ≤ t) : max 0 (a * t ^ θ - c * t) ≤ offsetPeelingConstantC c θ * a ^ (1 / (1 - θ)) := by by_cases hθ_zero : θ = 0 · subst θ have hconst : offsetPeelingConstantC c 0 = 1 := by unfold offsetPeelingConstantC simp have hsub : a * t ^ (0 : ℝ) - c * t ≤ a := by rw [Real.rpow_zero] nlinarith [mul_nonneg (le_of_lt hc_pos) ht] simpa [hconst] using max_le ha hsub · exact offset_peeling_coeff c θ a t hc_pos (lt_of_le_of_ne hθ_nonneg (Ne.symm hθ_zero)) hθ_lt ha ht
    Causalean.Mathlib.OffsetPeeling.offset_peeling_coeff_nonneg_theta · Causalean/Mathlib/Analysis/OffsetPeeling.lean:98
  • offsetPeelingConstant_nonneg lemma — The offset-peeling constant for the quarter-offset case is nonnegative when the exponent lies between zero and one.
    θ :
    hθ_nonneg :
    0 ≤ θ
    hθ_le :
    θ ≤ 1
    Proof (Lean source)
    lemma offsetPeelingConstant_nonneg (θ : ℝ) (hθ_nonneg : 0 ≤ θ) (hθ_le : θ ≤ 1) : 0 ≤ offsetPeelingConstant θ := by simpa [offsetPeelingConstant, offsetPeelingConstantC, div_eq_mul_inv, mul_comm] using offsetPeelingConstantC_nonneg (1 / 4) θ (by norm_num) hθ_nonneg hθ_le
    Causalean.Mathlib.OffsetPeeling.offsetPeelingConstant_nonneg · Causalean/Mathlib/Analysis/OffsetPeeling.lean:117
  • offset_peeling_nonneg_theta lemma — The quarter-offset peeling bound remains valid at exponent zero by continuity of the constant formula.
    θ a t :
    hθ_nonneg :
    0 ≤ θ
    hθ_lt :
    θ < 1
    ha :
    0 ≤ a
    ht :
    0 ≤ t
    max 0 (a * t ^ θ - (1 / 4 : ℝ) * t) ≤ offsetPeelingConstant θ * a ^ (1 / (1 - θ))
    Proof (Lean source)
    lemma offset_peeling_nonneg_theta (θ a t : ℝ) (hθ_nonneg : 0 ≤ θ) (hθ_lt : θ < 1) (ha : 0 ≤ a) (ht : 0 ≤ t) : max 0 (a * t ^ θ - (1 / 4 : ℝ) * t) ≤ offsetPeelingConstant θ * a ^ (1 / (1 - θ)) := by simpa [offsetPeelingConstant, offsetPeelingConstantC, div_eq_mul_inv, mul_comm] using offset_peeling_coeff_nonneg_theta (1 / 4) θ a t (by norm_num) hθ_nonneg hθ_lt ha ht
    Causalean.Mathlib.OffsetPeeling.offset_peeling_nonneg_theta · Causalean/Mathlib/Analysis/OffsetPeeling.lean:140
  • max_two_split lemma — Split a clipped two-term offset across its summands: max 0 (a − 2r) ≤ max 0 (b − r) + max 0 (c − r) when a ≤ b + c.
    a b c r :
    h :
    a ≤ b + c
    max 0 (a - 2 * r) ≤ max 0 (b - r) + max 0 (c - r)
    Proof (Lean source)
    lemma max_two_split (a b c r : ℝ) (h : a ≤ b + c) : max 0 (a - 2 * r) ≤ max 0 (b - r) + max 0 (c - r) := by have hb : b - r ≤ max 0 (b - r) := le_max_right _ _ have hc : c - r ≤ max 0 (c - r) := le_max_right _ _ have hb0 : 0 ≤ max 0 (b - r) := le_max_left _ _ have hc0 : 0 ≤ max 0 (c - r) := le_max_left _ _ apply max_le · linarith · linarith
    Causalean.Mathlib.OffsetPeeling.max_two_split · Causalean/Mathlib/Analysis/OffsetPeeling.lean:151
Rpow­Arith 4 core · 0 supporting This file provides reusable arithmetic identities and inequalities for real powers and square roots, especially for sample-size factors and negative exponents. ★ inv_eq_rpow_neg_one★ div_rpow_of_nonneg_of_pos★ rpow_natCast_nonpos_le_one★ inv_mul_sqrt_eq_rpow_neg_half

Small real-power arithmetic helpers

This file provides reusable arithmetic identities and inequalities for real powers and square roots, especially for sample-size factors and negative exponents. The main lemmas identify reciprocals with real powers (inv_eq_rpow_neg_one), factor (A / n) ^ p into an A part and an n part (div_rpow_of_nonneg_of_pos), bound nonpositive powers of natural casts (rpow_natCast_nonpos_le_one), and rewrite q⁻¹ * sqrt q as q ^ (-1/2) (inv_mul_sqrt_eq_rpow_neg_half).

lemma inv_eq_rpow_neg_one reviewed
Causalean.Mathlib.RpowArith

For any real number x, its reciprocal equals its real power raised to the exponent −1.

Formal statement
x :
x⁻¹ = x ^ (-1 : ℝ)
Proof (Lean source)
lemma inv_eq_rpow_neg_one (x : ℝ) : x⁻¹ = x ^ (-1 : ℝ) := by rw [Real.rpow_neg_one]
Causalean.Mathlib.RpowArith.inv_eq_rpow_neg_one · Causalean/Mathlib/Analysis/RpowArith.lean:24
lemma div_rpow_of_nonneg_of_pos reviewed
Causalean.Mathlib.RpowArith

Factoring a real power of a quotient. For a nonnegative numerator A and a strictly positive denominator n, the real power (A/n)^p equals A^p times n raised to the power −p, for any real exponent p.

Formal statement
A p n :
hA :
0 ≤ A
hn :
0 < n
(A / n) ^ p = A ^ p * n ^ (-p)
Proof (Lean source)
lemma div_rpow_of_nonneg_of_pos (A p n : ℝ) (hA : 0 ≤ A) (hn : 0 < n) : (A / n) ^ p = A ^ p * n ^ (-p) := by have hnnonneg : 0 ≤ n := le_of_lt hn have hinv_nonneg : 0 ≤ n⁻¹ := inv_nonneg.mpr hnnonneg have hinv := inv_eq_rpow_neg_one n calc (A / n) ^ p = (A * n⁻¹) ^ p := by rw [div_eq_mul_inv] _ = A ^ p * (n⁻¹) ^ p := by rw [Real.mul_rpow hA hinv_nonneg] _ = A ^ p * (n ^ (-1 : ℝ)) ^ p := by rw [hinv] _ = A ^ p * n ^ ((-1 : ℝ) * p) := by rw [Real.rpow_mul hnnonneg] _ = A ^ p * n ^ (-p) := by congr 1 ring_nf
Causalean.Mathlib.RpowArith.div_rpow_of_nonneg_of_pos · Causalean/Mathlib/Analysis/RpowArith.lean:29
lemma rpow_natCast_nonpos_le_one reviewed
Causalean.Mathlib.RpowArith

Nonpositive real power of a natural number is at most one. For a nonpositive real exponent e, the real power of any natural-number cast raised to e is at most 1.

Formal statement
n :
e :
he :
e ≤ 0
(n : ℝ) ^ e ≤ 1
Proof (Lean source)
lemma rpow_natCast_nonpos_le_one (n : ℕ) (e : ℝ) (he : e ≤ 0) : (n : ℝ) ^ e ≤ 1 := by cases n with | zero => by_cases he_zero : e = 0 · simp [he_zero] · simp [Real.zero_rpow he_zero] | succ n => have hn_ge_one : 1 ≤ ((n + 1 : ℕ) : ℝ) := by exact_mod_cast (Nat.succ_le_succ (zero_le n)) exact Real.rpow_le_one_of_one_le_of_nonpos hn_ge_one he
Causalean.Mathlib.RpowArith.rpow_natCast_nonpos_le_one · Causalean/Mathlib/Analysis/RpowArith.lean:51
lemma inv_mul_sqrt_eq_rpow_neg_half reviewed
Causalean.Mathlib.RpowArith

Reciprocal times square root as a negative-half power. For a nonnegative real number q, the reciprocal of q times the square root of q equals q raised to the power −1/2.

Formal statement
q :
hq :
0 ≤ q
q⁻¹ * sqrt q = q ^ (-(1 / 2 : ℝ))
Proof (Lean source)
lemma inv_mul_sqrt_eq_rpow_neg_half (q : ℝ) (hq : 0 ≤ q) : q⁻¹ * sqrt q = q ^ (-(1 / 2 : ℝ)) := by rcases hq.eq_or_lt with rfl | hq · simp · calc q⁻¹ * sqrt q = q ^ (-1 : ℝ) * q ^ (1 / (2 : ℝ)) := by rw [Real.sqrt_eq_rpow] rw [Real.rpow_neg hq.le, Real.rpow_one] _ = q ^ ((-1 : ℝ) + 1 / (2 : ℝ)) := by rw [← Real.rpow_add hq] _ = q ^ (-(1 / 2 : ℝ)) := by ring_nf
Causalean.Mathlib.RpowArith.inv_mul_sqrt_eq_rpow_neg_half · Causalean/Mathlib/Analysis/RpowArith.lean:66
Second­Order­Descent 2 core · 8 supporting This module provides the one-dimensional smooth-optimization descent lemma. ★ second_order_descent_gap

Second-order descent for one real variable

This module provides the one-dimensional smooth-optimization descent lemma. A real function whose second derivative is bounded above in a segment's interior lies below the corresponding quadratic Taylor model, and a negative initial slope gives an explicit positive decrease at the clipped quadratic-model step.

The statements are objective-agnostic. Callers supply the regularity on Set.Icc 0 T and the interior pointwise second-derivative bound; this file only turns those hypotheses into the quadratic upper bound and the optimized descent gap.

def descentStep reviewed
Causalean.Mathlib.Analysis

The quadratic-model step chooses the endpoint when curvature is zero and otherwise clips the unconstrained optimizer at the available interval length.

Definition (Lean source)
noncomputable def descentStep (M c T : ℝ) : ℝ := if M = 0 then T else min T (c / M)
Causalean.Mathlib.Analysis.descentStep · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:24
theorem second_order_descent_gap reviewed
Causalean.Mathlib.Analysis

Quadratic-model descent gap. For a real function f on [0, T] where the interval length T, the slope margin c, and the curvature bound M are all nonnegative, f is twice continuously differentiable on [0, T], f is differentiable at 0, its second derivative is bounded above by M throughout the open interval, and its derivative at 0 is at most −c, then the clipped quadratic-model step lies in [0, T], and the resulting decrease f(0) − f(step) is at least c·step − (M/2)·step².

Formal statement
f :
ℝ → ℝ
M c T :
hT :
0 ≤ T
hc :
0 ≤ c
hMnn :
0 ≤ M
hf :
ContDiffOn ℝ 2 f (Icc 0 T)
hf0 :
hM :
∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M
hslope :
deriv f 0 ≤ -c
descentStep M c T ∈ Icc 0 T ∧
f 0 - f (descentStep M c T) ≥ c * descentStep M c T - (M / 2) * descentStep M c T ^ 2
Proof (Lean source)
theorem second_order_descent_gap {f : ℝ → ℝ} {M c T : ℝ} (hT : 0 ≤ T) (hc : 0 ≤ c) (hMnn : 0 ≤ M) (hf : ContDiffOn ℝ 2 f (Icc 0 T)) (hf0 : DifferentiableAt ℝ f 0) (hM : ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M) (hslope : deriv f 0 ≤ -c) : descentStep M c T ∈ Icc 0 T ∧ f 0 - f (descentStep M c T) ≥ c * descentStep M c T - (M / 2) * descentStep M c T ^ 2 := by let s := descentStep M c T have hs : s ∈ Icc 0 T := descentStep_mem_Icc hMnn hc hT refine ⟨hs, ?_⟩ have hs0 : 0 ≤ s := hs.1 have hub : f s ≤ f 0 + deriv f 0 * s + (M / 2) * s ^ 2 := second_order_upper_bound hf hf0 hM hs have hslope_mul : deriv f 0 * s ≤ -c * s := mul_le_mul_of_nonneg_right hslope hs0 nlinarith
Causalean.Mathlib.Analysis.second_order_descent_gap · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:115 · uses descentStep
8 supporting declarations (lemmas, instances)
  • descentStep_of_eq_zero theorem — With zero curvature bound, the clipped quadratic-model step is the endpoint.
    c T :
    descentStep 0 c T = T
    Proof (Lean source)
    @[simp] theorem descentStep_of_eq_zero (c T : ℝ) : descentStep 0 c T = T := by simp [descentStep]
    Causalean.Mathlib.Analysis.descentStep_of_eq_zero · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:32
  • descentStep_of_pos theorem — With a positive curvature bound, the clipped quadratic-model step is the smaller of the available interval length and the unconstrained quadratic-model optimizer.
    M :
    hM :
    0 < M
    c T :
    descentStep M c T = min T (c / M)
    Proof (Lean source)
    theorem descentStep_of_pos {M : ℝ} (hM : 0 < M) (c T : ℝ) : descentStep M c T = min T (c / M) := by simp [descentStep, hM.ne']
    Causalean.Mathlib.Analysis.descentStep_of_pos · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:37
  • descentStep_mem_Icc theorem — The clipped quadratic-model step is feasible whenever the interval length, slope margin, and curvature bound are nonnegative.
    M c T :
    hM :
    0 ≤ M
    hc :
    0 ≤ c
    hT :
    0 ≤ T
    descentStep M c T ∈ Icc 0 T
    Proof (Lean source)
    theorem descentStep_mem_Icc {M c T : ℝ} (hM : 0 ≤ M) (hc : 0 ≤ c) (hT : 0 ≤ T) : descentStep M c T ∈ Icc 0 T := by unfold descentStep split_ifs with h · exact ⟨hT, le_rfl⟩ · have hMpos : 0 < M := lt_of_le_of_ne hM (Ne.symm h) exact ⟨le_min hT (div_nonneg hc hM), min_le_left _ _⟩
    Causalean.Mathlib.Analysis.descentStep_mem_Icc · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:43
  • second_order_upper_bound theorem — A twice differentiable real function whose second derivative is bounded above on an interval's interior is no larger than its tangent at the left endpoint plus the quadratic curvature allowance.
    f :
    ℝ → ℝ
    M T :
    hf :
    ContDiffOn ℝ 2 f (Icc 0 T)
    hf0 :
    hM :
    ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M
    t :
    ht :
    t ∈ Icc 0 T
    f t ≤ f 0 + deriv f 0 * t + (M / 2) * t ^ 2
    Proof (Lean source)
    theorem second_order_upper_bound {f : ℝ → ℝ} {M T : ℝ} (hf : ContDiffOn ℝ 2 f (Icc 0 T)) (hf0 : DifferentiableAt ℝ f 0) (hM : ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M) {t : ℝ} (ht : t ∈ Icc 0 T) : f t ≤ f 0 + deriv f 0 * t + (M / 2) * t ^ 2 := by rcases ht with ⟨ht0, htT⟩ rcases ht0.eq_or_lt with rfl | htpos · simp · have hf' : ContDiffOn ℝ 2 f (Icc 0 t) := hf.mono (Icc_subset_Icc le_rfl htT) have huIcc : uIcc (0 : ℝ) t = Icc 0 t := uIcc_of_le htpos.le have huIoo : uIoo (0 : ℝ) t = Ioo 0 t := uIoo_of_le htpos.le have htay : ∃ x' ∈ Ioo (0 : ℝ) t, f t - taylorWithinEval f 1 (Icc 0 t) 0 t = iteratedDeriv 2 f x' * (t - 0) ^ 2 / (factorial 2) := by have h0 := taylor_mean_remainder_lagrange_iteratedDeriv (f := f) (x := t) (x₀ := 0) (n := 1) htpos.ne (by rw [huIcc] exact_mod_cast hf') rw [huIcc, huIoo] at h0 simpa using h0 have hpoly : taylorWithinEval f 1 (Icc 0 t) 0 t = f 0 + deriv f 0 * t := by rw [taylorWithinEval_succ, taylor_within_zero_eval, iteratedDerivWithin_one] · rw [hf0.derivWithin ((uniqueDiffOn_Icc htpos) 0 ⟨le_rfl, htpos.le⟩)] simp [mul_comm] have hid : iteratedDeriv 2 f = deriv (deriv f) := by rw [iteratedDeriv_succ, iteratedDeriv_one] rcases htay with ⟨ξ, hξ, heq⟩ have hb : deriv (deriv f) ξ ≤ M := hM ξ ⟨hξ.1, hξ.2.trans_le htT⟩ have heq' : f t - (f 0 + deriv f 0 * t) = deriv (deriv f) ξ * t ^ 2 / 2 := by rw [hpoly, hid] at heq simpa [sub_zero, factorial] using heq have hquad : deriv (deriv f) ξ * t ^ 2 / 2 ≤ M * t ^ 2 / 2 := by nlinarith [sq_nonneg t, hb] nlinarith
    Causalean.Mathlib.Analysis.second_order_upper_bound · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:55
  • first_order_upper_bound theorem — A real function with nonpositive second derivative in an interval's interior lies below its tangent line at the left endpoint.
    f :
    ℝ → ℝ
    T :
    hf :
    ContDiffOn ℝ 2 f (Icc 0 T)
    hf0 :
    hM :
    ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ 0
    t :
    ht :
    t ∈ Icc 0 T
    f t ≤ f 0 + deriv f 0 * t
    Proof (Lean source)
    theorem first_order_upper_bound {f : ℝ → ℝ} {T : ℝ} (hf : ContDiffOn ℝ 2 f (Icc 0 T)) (hf0 : DifferentiableAt ℝ f 0) (hM : ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ 0) {t : ℝ} (ht : t ∈ Icc 0 T) : f t ≤ f 0 + deriv f 0 * t := by have h := second_order_upper_bound (M := 0) hf hf0 hM ht simpa using h
    Causalean.Mathlib.Analysis.first_order_upper_bound · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:100
  • second_order_descent_gap_min theorem — With positive curvature, the clipped quadratic-model step gives at least half of the linear descent term.
    f :
    ℝ → ℝ
    M c T :
    hT :
    0 ≤ T
    hc :
    0 ≤ c
    hMpos :
    0 < M
    hf :
    ContDiffOn ℝ 2 f (Icc 0 T)
    hf0 :
    hM :
    ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M
    hslope :
    deriv f 0 ≤ -c
    f 0 - f (min T (c / M)) ≥ (c / 2) * min T (c / M)
    Proof (Lean source)
    theorem second_order_descent_gap_min {f : ℝ → ℝ} {M c T : ℝ} (hT : 0 ≤ T) (hc : 0 ≤ c) (hMpos : 0 < M) (hf : ContDiffOn ℝ 2 f (Icc 0 T)) (hf0 : DifferentiableAt ℝ f 0) (hM : ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M) (hslope : deriv f 0 ≤ -c) : f 0 - f (min T (c / M)) ≥ (c / 2) * min T (c / M) := by let s := min T (c / M) have hraw : f 0 - f s ≥ c * s - (M / 2) * s ^ 2 := by simpa [s, descentStep_of_pos hMpos] using (second_order_descent_gap hT hc hMpos.le hf hf0 hM hslope).2 have hsle : s ≤ c / M := min_le_right T (c / M) have hMs : s * M ≤ c := (le_div_iff₀ hMpos).mp hsle have hs0 : 0 ≤ s := le_min hT (div_nonneg hc hMpos.le) nlinarith
    Causalean.Mathlib.Analysis.second_order_descent_gap_min · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:142
  • first_order_descent_gap theorem — With zero curvature, the endpoint step gives the full linear descent guaranteed by the negative initial slope.
    f :
    ℝ → ℝ
    c T :
    hT :
    0 ≤ T
    hf :
    ContDiffOn ℝ 2 f (Icc 0 T)
    hf0 :
    hM :
    ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ 0
    hslope :
    deriv f 0 ≤ -c
    f 0 - f T ≥ c * T
    Proof (Lean source)
    theorem first_order_descent_gap {f : ℝ → ℝ} {c T : ℝ} (hT : 0 ≤ T) (hf : ContDiffOn ℝ 2 f (Icc 0 T)) (hf0 : DifferentiableAt ℝ f 0) (hM : ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ 0) (hslope : deriv f 0 ≤ -c) : f 0 - f T ≥ c * T := by have hub : f T ≤ f 0 + deriv f 0 * T := first_order_upper_bound hf hf0 hM (right_mem_Icc.mpr hT) have hslope_mul : deriv f 0 * T ≤ -c * T := mul_le_mul_of_nonneg_right hslope hT nlinarith
    Causalean.Mathlib.Analysis.first_order_descent_gap · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:162
  • second_order_descent_gap_half theorem — In both zero and positive curvature regimes, the clipped quadratic-model step gives a uniform half-linear decrease.
    f :
    ℝ → ℝ
    M c T :
    hT :
    0 ≤ T
    hc :
    0 ≤ c
    hMnn :
    0 ≤ M
    hf :
    ContDiffOn ℝ 2 f (Icc 0 T)
    hf0 :
    hM :
    ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M
    hslope :
    deriv f 0 ≤ -c
    descentStep M c T ∈ Icc 0 T ∧ f 0 - f (descentStep M c T) ≥ (c / 2) * descentStep M c T
    Proof (Lean source)
    theorem second_order_descent_gap_half {f : ℝ → ℝ} {M c T : ℝ} (hT : 0 ≤ T) (hc : 0 ≤ c) (hMnn : 0 ≤ M) (hf : ContDiffOn ℝ 2 f (Icc 0 T)) (hf0 : DifferentiableAt ℝ f 0) (hM : ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ M) (hslope : deriv f 0 ≤ -c) : descentStep M c T ∈ Icc 0 T ∧ f 0 - f (descentStep M c T) ≥ (c / 2) * descentStep M c T := by refine ⟨descentStep_mem_Icc hMnn hc hT, ?_⟩ rcases hMnn.eq_or_lt with hMzero | hMpos · rw [← hMzero, descentStep_of_eq_zero] have hM0 : ∀ t ∈ Ioo 0 T, deriv (deriv f) t ≤ 0 := by simpa [← hMzero] using hM have hgap : f 0 - f T ≥ c * T := first_order_descent_gap hT hf hf0 hM0 hslope nlinarith · rw [descentStep_of_pos hMpos] exact second_order_descent_gap_min hT hc hMpos hf hf0 hM hslope
    Causalean.Mathlib.Analysis.second_order_descent_gap_half · Causalean/Mathlib/Analysis/SecondOrderDescent.lean:176
Smooth­Reciprocal 2 core · 3 supporting The reciprocal x ↦ x⁻¹ is singular at 0. ★ recipC_contDiff

A globally reciprocal with a floor near the singularity

The reciprocal x ↦ x⁻¹ is singular at 0. recipC ε is a modification that agrees with x⁻¹ on x ≥ ε/2 but is smoothly damped to 0 on the neighbourhood of the singularity, so it is globally on all of . This is the reusable core of the "globally extension of an objective that is singular on the boundary of its feasible box" pattern: multiply the singular part by a Real.smoothTransition cutoff that is 1 on the feasible region and 0 past the boundary.

def recipC reviewed
Causalean.Mathlib

Floored reciprocal. The reciprocal x⁻¹ multiplied by a smooth cutoff that is 1 once x is a definite distance above 0 and 0 near and below 0. It coincides with x⁻¹ on x ≥ ε/2 (see recipC_eq_inv) yet is globally (see recipC_contDiff).

Definition (Lean source)
noncomputable def recipC (ε : ℝ) (x : ℝ) : ℝ := Real.smoothTransition ((x - ε / 4) / (ε / 4)) * x⁻¹
lemma recipC_contDiff reviewed
Causalean.Mathlib

Global continuous differentiability of the floored reciprocal. For a strictly positive threshold ε, the floored reciprocal recipC ε is continuously differentiable on all of the reals.

Formal statement
ε :
:
0 < ε
ContDiff ℝ 1 (recipC ε)
Proof (Lean source)
@[fun_prop] lemma recipC_contDiff (ε : ℝ) (hε : 0 < ε) : ContDiff ℝ 1 (recipC ε) := recipC_contDiff_of 1 ε hε
Causalean.Mathlib.recipC_contDiff · Causalean/Mathlib/Analysis/SmoothReciprocal.lean:75 · uses recipC
3 supporting declarations (lemmas, instances)
  • recipC_eq_inv lemma — On the region x ≥ ε/2 (with ε > 0) the floored reciprocal is exactly x⁻¹, because the smooth cutoff has already saturated to 1 there.
    ε x :
    :
    0 < ε
    hx :
    ε / 2 ≤ x
    recipC ε x = x⁻¹
    Proof (Lean source)
    lemma recipC_eq_inv {ε x : ℝ} (hε : 0 < ε) (hx : ε / 2 ≤ x) : recipC ε x = x⁻¹ := by unfold recipC have hden : 0 < ε / 4 := by positivity have hone : 1 ≤ (x - ε / 4) / (ε / 4) := by rw [le_div_iff₀ hden] linarith rw [Real.smoothTransition.one_of_one_le hone] ring
  • recipC_contDiff_of lemma — The floored reciprocal is globally Cⁿ on all of ℝ, for EVERY smoothness order n: near the singularity the smooth cutoff vanishes to infinite order, absorbing the blow-up of x⁻¹, and away from the singularity it is a product of Cⁿ functions.
    n :
    ℕ∞
    ε :
    :
    0 < ε
    ContDiff ℝ n (recipC ε)
    Proof (Lean source)
    lemma recipC_contDiff_of (n : ℕ∞) (ε : ℝ) (hε : 0 < ε) : ContDiff ℝ n (recipC ε) := by rw [contDiff_iff_contDiffAt] intro x unfold recipC by_cases hx : x < ε / 4 · have hev : (fun y : ℝ => Real.smoothTransition ((y - ε / 4) / (ε / 4)) * y⁻¹) =ᶠ[nhds x] fun _ => 0 := by filter_upwards [Iio_mem_nhds hx] with y hy have harg : (y - ε / 4) / (ε / 4) ≤ 0 := by have hden : 0 < ε / 4 := by positivity exact div_nonpos_of_nonpos_of_nonneg (by linarith [show y < ε / 4 from hy]) hden.le rw [Real.smoothTransition.zero_of_nonpos harg] simp exact (contDiffAt_const : ContDiffAt ℝ n (fun _ : ℝ => (0 : ℝ)) x).congr_of_eventuallyEq hev · have hxpos : x ≠ 0 := by have hxge : ε / 4 ≤ x := le_of_not_gt hx have hpos : 0 < x := by linarith exact ne_of_gt hpos have hcut : ContDiffAt ℝ n (fun y : ℝ => Real.smoothTransition ((y - ε / 4) / (ε / 4))) x := by have hlin : ContDiff ℝ n (fun y : ℝ => (y - ε / 4) / (ε / 4)) := by fun_prop exact (Real.smoothTransition.contDiff.comp hlin).contDiffAt have hinv : ContDiffAt ℝ n (fun y : ℝ => y⁻¹) x := contDiffAt_inv ℝ hxpos exact hcut.mul hinv
    Causalean.Mathlib.recipC_contDiff_of · Causalean/Mathlib/Analysis/SmoothReciprocal.lean:38
  • recipC_contDiff_two lemma — recipC ε is globally C². Specialization of recipC_contDiff_of; this is the order the reciprocal-product envelope's directional curvature modulus needs.
    ε :
    :
    0 < ε
    ContDiff ℝ 2 (recipC ε)
    Proof (Lean source)
    @[fun_prop] lemma recipC_contDiff_two (ε : ℝ) (hε : 0 < ε) : ContDiff ℝ 2 (recipC ε) := recipC_contDiff_of 2 ε hε
    Causalean.Mathlib.recipC_contDiff_two · Causalean/Mathlib/Analysis/SmoothReciprocal.lean:84
Weighted­Cauchy­Schwarz 2 core · 2 supporting Mathlib's discrete Cauchy–Schwarz Finset.sum_mul_sq_le_sq_mul_sq is stated for the *unweighted* inner product. ★ weighted_inner_sq_le★ abs_weighted_inner_le

Cauchy–Schwarz against a finite nonnegative weight vector

Mathlib's discrete Cauchy–Schwarz Finset.sum_mul_sq_le_sq_mul_sq is stated for the unweighted inner product. Weighted versions (⟨f, g⟩_w = Σ wᵢ fᵢ gᵢ for a nonnegative weight vector w) get re-derived by hand all over the library, so this module records them once, over an arbitrary finite support.

* weighted_inner_sq_le — squared form (Σ wᵢ fᵢ gᵢ)² ≤ (Σ wᵢ fᵢ²)(Σ wᵢ gᵢ²). * abs_weighted_inner_le — square-root form with an absolute value on the left. * abs_weighted_mean_le_sqrt_weighted_sq — the subprobability-weight (Σ wᵢ ≤ 1) specialization |Σ wᵢ fᵢ| ≤ √(Σ wᵢ fᵢ²), i.e. Jensen for x ↦ x². * weighted_sqrt_le_sqrt_weighted — Jensen for √·: Σ wᵢ √qᵢ ≤ √(Σ wᵢ qᵢ).

All four follow from the unweighted inequality by substituting f ↦ √w · f, g ↦ √w · g and simplifying with Real.sq_sqrt.

lemma weighted_inner_sq_le reviewed
Causalean.Mathlib.Analysis

Weighted Cauchy-Schwarz inequality on a finite support, squared form. Weighting a finite collection of index points by nonnegative weights, the square of the weighted inner product of two real-valued functions is at most the product of their weighted sums of squares.

Formal statement
s :
w f g :
ι → ℝ
hw :
∀ i ∈ s, 0 ≤ w i
(∑ i ∈ s, w i * (f i * g i)) ^ 2 ≤ (∑ i ∈ s, w i * f i ^ 2) * (∑ i ∈ s, w i * g i ^ 2)
Proof (Lean source)
lemma weighted_inner_sq_le (s : Finset ι) (w f g : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) : (∑ i ∈ s, w i * (f i * g i)) ^ 2 ≤ (∑ i ∈ s, w i * f i ^ 2) * (∑ i ∈ s, w i * g i ^ 2) := by have hprod : ∀ i ∈ s, sqrt (w i) * f i * (sqrt (w i) * g i) = w i * (f i * g i) := by intro i hi have : sqrt (w i) * sqrt (w i) = w i := Real.mul_self_sqrt (hw i hi) calc sqrt (w i) * f i * (sqrt (w i) * g i) = sqrt (w i) * sqrt (w i) * (f i * g i) := by ring _ = w i * (f i * g i) := by rw [this] have hsq : ∀ (h : ι → ℝ) (i : ι) (_ : i ∈ s), (sqrt (w i) * h i) ^ 2 = w i * h i ^ 2 := by intro h i hi rw [mul_pow, Real.sq_sqrt (hw i hi)] have hsumprod : ∑ i ∈ s, sqrt (w i) * f i * (sqrt (w i) * g i) = ∑ i ∈ s, w i * (f i * g i) := by apply Finset.sum_congr rfl intro i hi exact hprod i hi have hsumsq (h : ι → ℝ) : ∑ i ∈ s, (sqrt (w i) * h i) ^ 2 = ∑ i ∈ s, w i * h i ^ 2 := by apply Finset.sum_congr rfl intro i hi exact hsq h i hi have key := Finset.sum_mul_sq_le_sq_mul_sq s (fun i => sqrt (w i) * f i) (fun i => sqrt (w i) * g i) rw [hsumprod, hsumsq f, hsumsq g] at key exact key
Causalean.Mathlib.Analysis.weighted_inner_sq_le · Causalean/Mathlib/Analysis/WeightedCauchySchwarz.lean:33
lemma abs_weighted_inner_le reviewed
Causalean.Mathlib.Analysis

Weighted Cauchy-Schwarz inequality on a finite support, square-root form. With nonnegative weights, the absolute value of the weighted inner product of two real-valued functions is at most the product of the square roots of their weighted sums of squares.

Formal statement
s :
w f g :
ι → ℝ
hw :
∀ i ∈ s, 0 ≤ w i
|∑ i ∈ s, w i * (f i * g i)|
sqrt (∑ i ∈ s, w i * f i ^ 2) * sqrt (∑ i ∈ s, w i * g i ^ 2)
Proof (Lean source)
lemma abs_weighted_inner_le (s : Finset ι) (w f g : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) : |∑ i ∈ s, w i * (f i * g i)| ≤ sqrt (∑ i ∈ s, w i * f i ^ 2) * sqrt (∑ i ∈ s, w i * g i ^ 2) := by have hP : (0 : ℝ) ≤ ∑ i ∈ s, w i * f i ^ 2 := sum_nonneg fun i hi => mul_nonneg (hw i hi) (sq_nonneg _) have hstep : |∑ i ∈ s, w i * (f i * g i)| ≤ sqrt ((∑ i ∈ s, w i * f i ^ 2) * (∑ i ∈ s, w i * g i ^ 2)) := by rw [← Real.sqrt_sq_eq_abs] exact Real.sqrt_le_sqrt (weighted_inner_sq_le s w f g hw) rwa [Real.sqrt_mul hP] at hstep
Causalean.Mathlib.Analysis.abs_weighted_inner_le · Causalean/Mathlib/Analysis/WeightedCauchySchwarz.lean:67
2 supporting declarations (lemmas, instances)
  • abs_weighted_mean_le_sqrt_weighted_sq lemma — Weighted mean is dominated by the weighted root-mean-square. For weights that are nonnegative and sum to at most one, the absolute value of the weighted average of a real-valued function is at most the square root of the weighted average of its square.
    s :
    w f :
    ι → ℝ
    hw :
    ∀ i ∈ s, 0 ≤ w i
    c :
    hmass :
    ∑ i ∈ s, w i ≤ c
    |∑ i ∈ s, w i * f i| ≤ sqrt c * sqrt (∑ i ∈ s, w i * f i ^ 2)
    Proof (Lean source)
    lemma abs_weighted_mean_le_sqrt_weighted_sq (s : Finset ι) (w f : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) (c : ℝ) (hmass : ∑ i ∈ s, w i ≤ c) : |∑ i ∈ s, w i * f i| ≤ sqrt c * sqrt (∑ i ∈ s, w i * f i ^ 2) := by have key := abs_weighted_inner_le s w f (fun _ => 1) hw simp only [mul_one, one_pow] at key have hsqrt : sqrt (∑ i ∈ s, w i) ≤ sqrt c := by have := Real.sqrt_le_sqrt hmass exact this calc _ ≤ sqrt (∑ i ∈ s, w i * f i ^ 2) * sqrt (∑ i ∈ s, w i) := key _ ≤ sqrt (∑ i ∈ s, w i * f i ^ 2) * sqrt c := mul_le_mul_of_nonneg_left hsqrt (Real.sqrt_nonneg _) _ = _ := mul_comm _ _
    Causalean.Mathlib.Analysis.abs_weighted_mean_le_sqrt_weighted_sq · Causalean/Mathlib/Analysis/WeightedCauchySchwarz.lean:82
  • weighted_sqrt_le_sqrt_weighted lemma — Jensen's inequality for the square root. Averaging nonnegative values with weights that are nonnegative and sum to at most one, the weighted average of their square roots is at most the square root of their weighted average.
    s :
    w q :
    ι → ℝ
    hw :
    ∀ i ∈ s, 0 ≤ w i
    c :
    hmass :
    ∑ i ∈ s, w i ≤ c
    hq :
    ∀ i ∈ s, 0 ≤ q i
    ∑ i ∈ s, w i * sqrt (q i) ≤ sqrt c * sqrt (∑ i ∈ s, w i * q i)
    Proof (Lean source)
    lemma weighted_sqrt_le_sqrt_weighted (s : Finset ι) (w q : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) (c : ℝ) (hmass : ∑ i ∈ s, w i ≤ c) (hq : ∀ i ∈ s, 0 ≤ q i) : ∑ i ∈ s, w i * sqrt (q i) ≤ sqrt c * sqrt (∑ i ∈ s, w i * q i) := by have key := abs_weighted_mean_le_sqrt_weighted_sq s w (fun i => sqrt (q i)) hw c hmass have hrw : ∀ i ∈ s, w i * sqrt (q i) ^ 2 = w i * q i := by intro i hi; rw [Real.sq_sqrt (hq i hi)] have hsumrw : ∑ i ∈ s, w i * sqrt (q i) ^ 2 = ∑ i ∈ s, w i * q i := by apply Finset.sum_congr rfl intro i hi exact hrw i hi rw [hsumrw] at key exact le_trans (le_abs_self _) key
    Causalean.Mathlib.Analysis.weighted_sqrt_le_sqrt_weighted · Causalean/Mathlib/Analysis/WeightedCauchySchwarz.lean:100