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.
BernoulliKL 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 . It supplies a Mathlib-adjacent analytic estimate used by finite-sample information arguments elsewhere in the library.
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.
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
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
hasDerivAt_bernEntropylemma — Away from zero and one, the negative Bernoulli entropy has derivative equal to the log odds of its argument.hypothesesx :ℝhx0 :x ≠ 0hx1 :1 - x ≠ 0conclusionProof (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 -
bernoulliKL_eq_bregmanlemma — Bernoulli Kullback–Leibler divergence equals the Bregman remainder of the negative entropy function at the second probability.hypothesesp q :ℝhp0 :p ≠ 0hp1 :1 - p ≠ 0hq0 :q ≠ 0hq1 :1 - q ≠ 0Proof (Lean source)
ClipInterval 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.
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.
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.
Proof (Lean source)
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.
Proof (Lean source)
11 supporting declarations (lemmas, instances)
-
coe_projIcc_eq_clipIcclemma — Clipping into an interval is exactly Mathlib's projection onto that interval, read as a plain real number instead of as an element of the interval. This is the bridge that makes every fact about the projection available to a development that never leaves the reals.Proof (Lean source)
lemma coe_projIcc_eq_clipIcc (hab : a ≤ b) (x : ℝ) : (Set.projIcc a b hab x : ℝ) = clipIcc a b x := rfl -
clipIcc_mem_Icclemma — A clipped value always lies in the interval it was clipped to (provided the interval is nonempty, i.e. its left endpoint does not exceed its right endpoint).Proof (Lean source)
-
clipIcc_eq_min_maxlemma — Clipping from below first and then from above gives the same answer as clipping from above first and then from below. This reconciles the two spellings of the same operation that occur in practice, max a (min b x) and min b (max a x).Proof (Lean source)
lemma clipIcc_eq_min_max (hab : a ≤ b) (x : ℝ) : clipIcc a b x = min b (max a x) := by rw [clipIcc, max_min_distrib_left, max_eq_right hab] -
lipschitzWith_clipIcclemma — Clipping is a contraction: two numbers are never pushed further apart by being clipped to a common interval.Proof (Lean source)
lemma lipschitzWith_clipIcc (a b : ℝ) : LipschitzWith 1 (clipIcc a b) := (LipschitzWith.id.const_min b).const_max a -
abs_clipIcc_sub_clipIcc_lelemma — Clipping two numbers to the same interval never increases the distance between them.Proof (Lean source)
lemma abs_clipIcc_sub_clipIcc_le (a b x y : ℝ) : |clipIcc a b x - clipIcc a b y| ≤ |x - y| := by simpa [Real.dist_eq] using (lipschitzWith_clipIcc a b).dist_le_mul x y -
abs_min_max_sub_min_max_lelemma — Capping from above and then flooring from below is a contraction as well: two numbers put through that order of operations are never pushed further apart. Unlike clipIcc_eq_min_max, this needs no assumption on the two thresholds, which is what makes it usable for a propensity band [q, 1 - q] whose definition carries no q ≤ 1/2 hypothesis.Proof (Lean source)
lemma abs_min_max_sub_min_max_le (a b x y : ℝ) : |min b (max a x) - min b (max a y)| ≤ |x - y| := by have h : LipschitzWith 1 (fun z : ℝ => min b (max a z)) := (LipschitzWith.id.const_max a).const_min b simpa [Real.dist_eq] using h.dist_le_mul x y -
continuous_clipIcclemma — Clipping to a fixed interval is a continuous operation.Proof (Lean source)
lemma continuous_clipIcc (a b : ℝ) : Continuous (clipIcc a b) := continuous_const.max (continuous_const.min continuous_id) -
measurable_clipIcclemma — Clipping to a fixed interval is measurable, so clipping a random variable again yields a random variable.Proof (Lean source)
lemma measurable_clipIcc (a b : ℝ) : Measurable (clipIcc a b) := (continuous_clipIcc a b).measurable -
abs_clipIcc_neg_lelemma — Clipping to a symmetric band around zero produces a value whose magnitude is at most the half-width of the band.Proof (Lean source)
lemma abs_clipIcc_neg_le (hB : 0 ≤ B) (x : ℝ) : |clipIcc (-B) B x| ≤ B := abs_le.mpr (clipIcc_mem_Icc (by linarith) x) -
clipIcc_neg_eq_selflemma — Clipping to a symmetric band around zero leaves untouched any number whose magnitude is already within the half-width of the band.Proof (Lean source)
lemma clipIcc_neg_eq_self (hx : |x| ≤ B) : clipIcc (-B) B x = x := clipIcc_eq_self (Set.mem_Icc.mpr (abs_le.mp hx))
ConvexProjection 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.
Metric projection assigns each point in a real Hilbert space its nearest point in a specified nonempty closed convex set.
Definition (Lean source)
A Loewner interval contains the real matrices bounded between two scalar multiples of the identity matrix in positive-semidefinite order.
Definition (Lean source)
The Frobenius distance between two real matrices is the square root of the sum of the squared entrywise differences.
Finite real matrices are linearly equivalent to Euclidean vectors indexed by pairs of row and column coordinates.
Finite square real matrices of dimension p are homeomorphic to Euclidean vectors indexed by their row and column coordinates.
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.
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
Proof (Lean source)
24 supporting declarations (lemmas, instances)
-
convexProj_speclemma — A point's metric projection onto a nonempty closed convex set belongs to that set and attains the smallest possible distance from the point among all points in the set.hypothesesconclusionconvexProj K hne hc hconv x ∈ K ∧ ‖x - convexProj K hne hc hconv x‖ = ⨅ y : K, ‖x - y‖Proof (Lean source)
lemma convexProj_spec (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) (x : E) : convexProj K hne hc hconv x ∈ K ∧ ‖x - convexProj K hne hc hconv x‖ = ⨅ y : K, ‖x - y‖ := Classical.choose_spec (exists_norm_eq_iInf_of_complete_convex hne hc.isComplete hconv x) -
convexProj_memtheorem — The metric projection of every point belongs to its nonempty closed convex target set.hypothesesconclusionconvexProj K hne hc hconv x ∈ KProof (Lean source)
theorem convexProj_mem (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) (x : E) : convexProj K hne hc hconv x ∈ K := (convexProj_spec K hne hc hconv x).1 -
convexProj_variationaltheorem — The residual from a point to its metric projection has nonpositive inner product with every feasible direction based at the projection.hypothesesconclusion⟪x - convexProj K hne hc hconv x, y - convexProj K hne hc hconv x⟫_ℝ ≤ 0Proof (Lean source)
theorem convexProj_variational (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) (x : E) (y : E) (hy : y ∈ K) : ⟪x - convexProj K hne hc hconv x, y - convexProj K hne hc hconv x⟫_ℝ ≤ 0 := by exact (norm_eq_iInf_iff_real_inner_le_zero hconv (convexProj_mem K hne hc hconv x)).1 (convexProj_spec K hne hc hconv x).2 y hy -
convexProj_le_of_memtheorem — Projecting a point onto a nonempty closed convex set cannot increase its distance from any point already in that set.hypothesesconclusion‖convexProj K hne hc hconv x - y‖ ≤ ‖x - y‖Proof (Lean source)
theorem convexProj_le_of_mem (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) (x y : E) (hy : y ∈ K) : ‖convexProj K hne hc hconv x - y‖ ≤ ‖x - y‖ := by let p := convexProj K hne hc hconv x have hv := convexProj_variational K hne hc hconv x y hy have hi : 0 ≤ ⟪x - p, p - y⟫_ℝ := by rw [show p - y = -(y - p) by abel, inner_neg_right] simpa [p] using neg_nonneg.mpr hv rw [← sq_le_sq₀ (norm_nonneg _) (norm_nonneg _)] rw [show x - y = (x - p) + (p - y) by abel, norm_add_sq_real] nlinarith [sq_nonneg ‖x - p‖] -
convexProj_eq_selftheorem — Every point in a nonempty closed convex target set is unchanged by metric projection onto that set.hypothesesconclusionconvexProj K hne hc hconv x = xProof (Lean source)
theorem convexProj_eq_self (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) (x : E) (hx : x ∈ K) : convexProj K hne hc hconv x = x := by have h := convexProj_le_of_mem K hne hc hconv x x hx have : ‖convexProj K hne hc hconv x - x‖ = 0 := le_antisymm (by simpa using h) (norm_nonneg _) exact sub_eq_zero.mp (norm_eq_zero.mp this) -
convexProj_lipschitztheorem — Metric projection onto a nonempty closed convex set is nonexpansive: projected distances never exceed the original distances.hypothesesconclusionLipschitzWith 1 (convexProj K hne hc hconv)Proof (Lean source)
theorem convexProj_lipschitz (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) : LipschitzWith 1 (convexProj K hne hc hconv) := by apply LipschitzWith.of_dist_le_mul intro x y let px := convexProj K hne hc hconv x let py := convexProj K hne hc hconv y have hx := convexProj_variational K hne hc hconv x py (convexProj_mem K hne hc hconv y) have hy := convexProj_variational K hne hc hconv y px (convexProj_mem K hne hc hconv x) have hi : ⟪px - py, px - py⟫_ℝ ≤ ⟪x - y, px - py⟫_ℝ := by simp only [inner_sub_left, inner_sub_right, real_inner_comm] at hx hy ⊢ nlinarith have hs : ‖px - py‖ ^ 2 ≤ ‖x - y‖ * ‖px - py‖ := by rw [← real_inner_self_eq_norm_sq] exact hi.trans (real_inner_le_norm _ _) have hn : ‖px - py‖ ≤ ‖x - y‖ := by by_cases hz : ‖px - py‖ = 0 · simp [hz] · have hp : 0 < ‖px - py‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hz) nlinarith simpa [dist_eq_norm, px, py] using hn -
continuous_convexProjtheorem — Metric projection onto a nonempty closed convex set varies continuously with the point being projected.hypothesesconclusionContinuous (convexProj K hne hc hconv)Proof (Lean source)
theorem continuous_convexProj (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) : Continuous (convexProj K hne hc hconv) := (convexProj_lipschitz K hne hc hconv).continuous -
measurable_convexProjtheorem — Metric projection onto a nonempty closed convex set is measurable under the Borel sigma-algebra of the Hilbert space.hypothesesconclusionMeasurable (convexProj K hne hc hconv)Proof (Lean source)
theorem measurable_convexProj [MeasurableSpace E] [BorelSpace E] (K : Set E) (hne : K.Nonempty) (hc : IsClosed K) (hconv : Convex ℝ K) : Measurable (convexProj K hne hc hconv) := (continuous_convexProj K hne hc hconv).measurable -
frobDist_eq_normtheorem — The Frobenius distance between two finite real matrices equals the Euclidean norm of their difference after vectorizing the entries.Proof (Lean source)
-
frobDist_commtheorem — Frobenius distance is symmetric in its two matrix arguments. -
frobDist_triangletheorem — Frobenius distance satisfies the triangle inequality.Proof (Lean source)
theorem frobDist_triangle (A B D : Matrix (Fin p) (Fin p) ℝ) : frobDist A D ≤ frobDist A B + frobDist B D := by rw [frobDist_eq_norm, frobDist_eq_norm, frobDist_eq_norm] exact norm_sub_le_norm_sub_add_norm_sub (mtx p A) (mtx p B) (mtx p D) -
loewnerSet_nonemptytheorem — A Loewner interval with ordered scalar endpoints is nonempty.Proof (Lean source)
theorem loewnerSet_nonempty (p : ℕ) (c C : ℝ) (hcC : c ≤ C) : (loewnerSet p c C).Nonempty := by refine ⟨c • (1 : Matrix (Fin p) (Fin p) ℝ), ?_⟩ constructor · simpa using (Matrix.PosSemidef.zero : (0 : Matrix (Fin p) (Fin p) ℝ).PosSemidef) · convert (Matrix.PosSemidef.one.smul (α := ℝ) (sub_nonneg.mpr hcC) : ((C - c) • (1 : Matrix (Fin p) (Fin p) ℝ)).PosSemidef) using 1 ext i j simp only [Matrix.sub_apply, Matrix.smul_apply, smul_eq_mul] ring -
loewnerSet_convextheorem — Every Loewner interval of finite real matrices is convex.Proof (Lean source)
theorem loewnerSet_convex (p : ℕ) (c C : ℝ) : Convex ℝ (loewnerSet p c C) := by intro A hA B hB a b ha hb hab constructor · convert (hA.1.smul (α := ℝ) ha).add (hB.1.smul (α := ℝ) hb) using 1 ext i j simp only [Matrix.add_apply, Matrix.smul_apply, Matrix.sub_apply, smul_eq_mul] rw [show b = 1 - a by linarith] ring · convert (hA.2.smul (α := ℝ) ha).add (hB.2.smul (α := ℝ) hb) using 1 ext i j simp only [Matrix.add_apply, Matrix.smul_apply, Matrix.sub_apply, smul_eq_mul] rw [show b = 1 - a by linarith] ring -
isClosed_posSemideftheorem — Real positive-semidefinite matrices indexed by any finite set form a closed set in the coordinatewise topology.Proof (Lean source)
theorem isClosed_posSemidef {ι : Type*} [Finite ι] : IsClosed {A : Matrix ι ι ℝ | A.PosSemidef} := by classical letI := ofFinite ι rw [show {A : Matrix ι ι ℝ | A.PosSemidef} = {A | A.IsHermitian} ∩ {A | ∀ x, 0 ≤ dotProduct x (A.mulVec x)} by ext A; simp [Matrix.posSemidef_iff_dotProduct_mulVec]] apply IsClosed.inter · rw [show {A : Matrix ι ι ℝ | A.IsHermitian} = ⋂ i, ⋂ j, {A | A i j = A j i} by ext A simp only [IsHermitian, Set.mem_iInter, Set.mem_setOf_eq] constructor · intro h i j exact congr_fun (congr_fun h i) j |>.symm · intro h ext i j exact (h i j).symm] exact isClosed_iInter fun i => isClosed_iInter fun j => isClosed_eq (continuous_id.matrix_elem i j) (continuous_id.matrix_elem j i) · rw [show {A : Matrix ι ι ℝ | ∀ x, 0 ≤ dotProduct x (A.mulVec x)} = ⋂ x, {A | 0 ≤ dotProduct x (A.mulVec x)} by ext A; simp] exact isClosed_iInter fun x => isClosed_Ici.preimage (continuous_const.dotProduct (continuous_id.matrix_mulVec continuous_const)) -
loewnerSet_isClosedtheorem — Every Loewner interval of finite real matrices is closed in the coordinatewise product topology.Proof (Lean source)
theorem loewnerSet_isClosed (p : ℕ) (c C : ℝ) : IsClosed (loewnerSet p c C) := by exact (isClosed_posSemidef (ι := Fin p)).preimage (by fun_prop) |>.inter ((isClosed_posSemidef (ι := Fin p)).preimage (by fun_prop)) -
loewnerSet_posDeftheorem — Every matrix in a Loewner interval with a strictly positive lower endpoint is positive definite.hypothesesconclusionG.PosDefProof (Lean source)
-
loewnerProj_memtheorem — When its endpoints are ordered, Loewner projection sends every finite real matrix into the corresponding Loewner interval.hypothesesconclusionloewnerProj p c C G ∈ loewnerSet p c CProof (Lean source)
theorem loewnerProj_mem (hcC : c ≤ C) (G : Matrix (Fin p) (Fin p) ℝ) : loewnerProj p c C G ∈ loewnerSet p c C := by rw [loewnerProj, dif_pos hcC, loewnerProjAux] have hm := convexProj_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) rcases hm with ⟨S, hS, heq⟩ simpa [← heq] using hS -
measurable_loewnerProjtheorem — Loewner projection is measurable under the coordinatewise Borel sigma-algebra on finite real matrix spaces.Proof (Lean source)
theorem measurable_loewnerProj (p : ℕ) [MeasurableSpace (Matrix (Fin p) (Fin p) ℝ)] [BorelSpace (Matrix (Fin p) (Fin p) ℝ)] (c C : ℝ) : Measurable (loewnerProj p c C) := by by_cases h : c ≤ C · rw [loewnerProj, dif_pos h] unfold loewnerProjAux have he : (mtx p : Matrix (Fin p) (Fin p) ℝ → EuclideanSpace ℝ (Fin p × Fin p)) = mtxHomeo p := rfl have hes : ((mtx p).symm : EuclideanSpace ℝ (Fin p × Fin p) → Matrix (Fin p) (Fin p) ℝ) = (mtxHomeo p).symm := rfl rw [show (fun G => (mtx p).symm (convexProj (mtx p '' loewnerSet p c C) ((loewnerSet_nonempty p c C h).image (mtx p)) (mtx_image_isClosed p c C) ((loewnerSet_convex p c C).linear_image (mtx p).toLinearMap) (mtx p G))) = (mtxHomeo p).symm ∘ convexProj (mtx p '' loewnerSet p c C) ((loewnerSet_nonempty p c C h).image (mtx p)) (mtx_image_isClosed p c C) ((loewnerSet_convex p c C).linear_image (mtx p).toLinearMap) ∘ mtxHomeo p by funext G; simp [Function.comp_apply, he, hes]] exact (mtxHomeo p).symm.continuous.comp ((continuous_convexProj _ _ _ _).comp (mtxHomeo p).continuous) |>.measurable · rw [loewnerProj, dif_neg h] exact measurable_id -
mulVec_sub_norm_letheorem — Multiplying a vector by the difference of two finite real matrices has Euclidean norm at most their Frobenius distance times the vector's Euclidean norm.hypothesesProof (Lean source)
theorem mulVec_sub_norm_le (A B : Matrix (Fin p) (Fin p) ℝ) (v : Fin p → ℝ) : sqrt (∑ k, ((A - B).mulVec v k) ^ 2) ≤ frobDist A B * sqrt (∑ k, (v k) ^ 2) := by rw [frobDist, ← Real.sqrt_mul (sum_nonneg fun _ _ => sum_nonneg fun _ _ => sq_nonneg (A _ _ - B _ _))] apply Real.sqrt_le_sqrt rw [Finset.sum_mul] apply Finset.sum_le_sum intro k _ simpa [mulVec, dotProduct, frobDist, Matrix.sub_apply] using (Finset.sum_mul_sq_le_sq_mul_sq univ (fun l : Fin p => A k l - B k l) v) -
loewnerSet_inv_mulVec_norm_letheorem — The inverse of a matrix in a Loewner interval with a positive lower endpoint expands Euclidean norm by at most the reciprocal of that endpoint.hypothesesProof (Lean source)
theorem loewnerSet_inv_mulVec_norm_le (hc : 0 < c) {G : Matrix (Fin p) (Fin p) ℝ} (hG : (G - c • (1 : Matrix (Fin p) (Fin p) ℝ)).PosSemidef) (v : Fin p → ℝ) : sqrt (∑ k, (G⁻¹.mulVec v k) ^ 2) ≤ sqrt (∑ k, (v k) ^ 2) / c := by let z := G⁻¹.mulVec v have hpd := loewnerSet_posDef hc hG have hu : IsUnit G := hpd.isUnit have hudet : IsUnit G.det := (Matrix.isUnit_iff_isUnit_det G).mp hu have hGz : G.mulVec z = v := by change G.mulVec (G⁻¹.mulVec v) = v calc _ = (G * G⁻¹).mulVec v := Matrix.mulVec_mulVec v G G⁻¹ _ = v := by rw [Matrix.mul_nonsing_inv G hudet, Matrix.one_mulVec] have hquad := hG.dotProduct_mulVec_nonneg z have hlower : c * ∑ k, (z k) ^ 2 ≤ ∑ k, z k * v k := by rw [Matrix.sub_mulVec, hGz] at hquad have hq : (∑ k, z k * (c * z k)) ≤ ∑ k, z k * v k := by simpa [dotProduct, Matrix.smul_mulVec, Matrix.one_mulVec, mul_sub, Finset.sum_sub_distrib] using hquad calc c * ∑ k, (z k) ^ 2 = ∑ k, c * (z k) ^ 2 := Finset.mul_sum _ _ _ _ = ∑ k, z k * (c * z k) := by apply Finset.sum_congr rfl intro k hk ring _ ≤ _ := hq have hcs := Real.sum_mul_le_sqrt_mul_sqrt Finset.univ z v have hsquares : c * (sqrt (∑ k, (z k) ^ 2)) ^ 2 ≤ sqrt (∑ k, (z k) ^ 2) * sqrt (∑ k, (v k) ^ 2) := by rw [Real.sq_sqrt (sum_nonneg fun _ _ => sq_nonneg (z _))] exact hlower.trans hcs have hznonneg := Real.sqrt_nonneg (∑ k, (z k) ^ 2) have hbound : c * sqrt (∑ k, (z k) ^ 2) ≤ sqrt (∑ k, (v k) ^ 2) := by by_cases hz : sqrt (∑ k, (z k) ^ 2) = 0 · simp [hz] · have hzpos : 0 < sqrt (∑ k, (z k) ^ 2) := lt_of_le_of_ne hznonneg (Ne.symm hz) nlinarith apply (le_div_iff₀ hc).2 simpa [z, mul_comm] using hbound -
matrixMeasurableSpaceinstance — Finite real matrices carry the coordinatewise product sigma-algebra. -
matrixBorelSpaceinstance — The coordinatewise measurable structure on finite real matrices agrees with their Borel sigma-algebra.instance matrixBorelSpace (p : ℕ) : BorelSpace (Matrix (Fin p) (Fin p) ℝ) := ⟨by change pi = borel (Fin p → Fin p → ℝ) exact BorelSpace.measurable_eq⟩ -
loewnerProj_eq_selftheorem — Every matrix already in a nonempty Loewner interval is unchanged by metric projection onto that interval.hypothesesconclusionloewnerProj p c C G = GProof (Lean source)
theorem loewnerProj_eq_self {p : ℕ} {c C : ℝ} (hcC : c ≤ C) (G : Matrix (Fin p) (Fin p) ℝ) (hG : G ∈ loewnerSet p c C) : loewnerProj p c C G = G := by rw [loewnerProj, dif_pos hcC, loewnerProjAux] rw [convexProj_eq_self (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) ⟨G, hG, rfl⟩] exact (mtx p).symm_apply_apply G
FrechetFunctionalEquation 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).
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
Proof (Lean source)
GradientCoord 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.
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
Proof (Lean source)
HalfDiscPolar 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.
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)
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)
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
Proof (Lean source)
14 supporting declarations (lemmas, instances)
-
planarRadius_measurablelemma — The Euclidean radius on the coordinate plane is Borel measurable.conclusionProof (Lean source)
-- @node: planarRadius_measurable lemma planarRadius_measurable : Measurable planarRadius := by exact ((measurable_fst.pow_const 2).add (measurable_snd.pow_const 2)).sqrt -
integral_cos_zero_to_pilemma — The cosine has zero integral on a half-circle. -
integral_cos_sq_zero_to_pilemma — The quadratic cosine moment on a half-circle is π / 2. -
halfDisc_weighted_cos_cancellationlemma — A cosine angular tilt has zero integral against every radial weight on an upper half-disc.hypothesesg :ℝ → ℝr :ℝconclusion= 0Proof (Lean source)
-- @node: halfDisc_weighted_cos_cancellation lemma halfDisc_weighted_cos_cancellation (g : ℝ → ℝ) (r : ℝ) : (∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * cos (planarAngle z)) = 0 := by rw [halfDisc_weighted_polar_integral] have hcos : (∫ θ : ℝ in Ioo 0 pi, cos θ) = 0 := by rw [← integral_Ioc_eq_integral_Ioo] exact integral_cos_zero_to_pi rw [hcos, mul_zero] -
halfDisc_radialSet_weighted_cos_cancellationlemma — A cosine angular tilt has zero mass on every measurable radial subset of an upper half-disc. This is the setwise interface used to identify radial pushforwards, rather than merely their total masses.hypothesesconclusion(∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r} ∩ planarRadius ⁻¹' A, g (planarRadius z) * cos (planarAngle z))= 0Proof (Lean source)
-- @node: halfDisc_radialSet_weighted_cos_cancellation lemma halfDisc_radialSet_weighted_cos_cancellation (g : ℝ → ℝ) (r : ℝ) {A : Set ℝ} (hA : MeasurableSet A) : (∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r} ∩ planarRadius ⁻¹' A, g (planarRadius z) * cos (planarAngle z)) = 0 := by let D : Set (ℝ × ℝ) := {z | 0 < z.2 ∧ planarRadius z ≤ r} let R : Set (ℝ × ℝ) := planarRadius ⁻¹' A have hR : MeasurableSet R := hA.preimage planarRadius_measurable have hcancel := halfDisc_weighted_cos_cancellation (A.indicator g) r change (∫ z : ℝ × ℝ in D ∩ R, g (planarRadius z) * cos (planarAngle z)) = 0 rw [← hcancel] have hDR : D ∩ R = R ∩ D := inter_comm D R rw [hDR] rw [← Measure.restrict_restrict hR] rw [← integral_indicator hR] apply integral_congr_ae filter_upwards with z simp only [R, indicator, mem_preimage] split_ifs <;> simp_all -
planarFirst_div_radius_eq_coslemma — On the open upper half-plane, the first coordinate divided by the radius is the cosine of the polar angle.Proof (Lean source)
-- @node: planarFirst_div_radius_eq_cos lemma planarFirst_div_radius_eq_cos (z : ℝ × ℝ) (hz : 0 < z.2) : z.1 / planarRadius z = cos (planarAngle z) := by have hsource : z ∈ polarCoord.source := by simp only [polarCoord_source, mem_union, mem_setOf_eq] exact inr hz.ne' have hinv := polarCoord.left_inv hsource have hx := congrArg Prod.fst hinv have hr : planarRadius z = (polarCoord z).1 := rfl simp only [polarCoord_symm_apply] at hx rw [hr] unfold planarAngle have hpos : 0 < (polarCoord z).1 := by simpa only [polarCoord_target, mem_prod, mem_Ioi, mem_Ioo] using (polarCoord.map_source hsource).1 apply (div_eq_iff hpos.ne').2 rw [← hx] ring -
halfDisc_weighted_first_div_radius_cancellationlemma — A radial weight times the Cartesian direction cosine has zero integral on an open upper half-disc.hypothesesg :ℝ → ℝr :ℝconclusion= 0Proof (Lean source)
-- @node: halfDisc_weighted_first_div_radius_cancellation lemma halfDisc_weighted_first_div_radius_cancellation (g : ℝ → ℝ) (r : ℝ) : (∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * (z.1 / planarRadius z)) = 0 := by have heq : (∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * (z.1 / planarRadius z)) = ∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * cos (planarAngle z) := by apply integral_congr_ae have hD : MeasurableSet {z : ℝ × ℝ | 0 < z.2 ∧ planarRadius z ≤ r} := 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) exact ae_restrict_of_forall_mem hD fun z hz => by change g (planarRadius z) * (z.1 / planarRadius z) = g (planarRadius z) * cos (planarAngle z) rw [planarFirst_div_radius_eq_cos z hz.1] rw [heq] exact halfDisc_weighted_cos_cancellation g r -
closedHalfDisc_weighted_first_div_radius_cancellationlemma — Replacing the open diameter of an upper half-disc by the closed diameter does not affect the Cartesian cosine integral.hypothesesg :ℝ → ℝr :ℝconclusion= 0Proof (Lean source)
-- @node: closedHalfDisc_weighted_first_div_radius_cancellation lemma closedHalfDisc_weighted_first_div_radius_cancellation (g : ℝ → ℝ) (r : ℝ) : (∫ z : ℝ × ℝ in {z | 0 ≤ z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * (z.1 / planarRadius z)) = 0 := by rw [setIntegral_congr_set (show {z : ℝ × ℝ | 0 ≤ z.2 ∧ planarRadius z ≤ r} =ᵐ[volume] {z | 0 < z.2 ∧ planarRadius z ≤ r} by show ∀ᵐ z ∂(volume : Measure (ℝ × ℝ)), (0 ≤ z.2 ∧ planarRadius z ≤ r) = (0 < z.2 ∧ planarRadius z ≤ r) rw [ae_iff] apply measure_mono_null (t := {z : ℝ × ℝ | z.2 = 0}) · intro z hz simp only [mem_setOf_eq] by_contra hy apply hz apply propext constructor · rintro ⟨hy0, hr⟩ exact ⟨lt_of_le_of_ne hy0 (Ne.symm hy), hr⟩ · rintro ⟨hy0, hr⟩ exact ⟨hy0.le, hr⟩ · rw [Measure.volume_eq_prod] rw [show {z : ℝ × ℝ | z.2 = 0} = univ ×ˢ ({0} : Set ℝ) by ext z simp] rw [Measure.prod_prod] simp)] exact halfDisc_weighted_first_div_radius_cancellation g r -
translatedClosedHalfDisc_weighted_first_div_radius_cancellationlemma — Translation preserves the zero Cartesian-cosine integral over a closed upper half-disc.hypothesesg :ℝ → ℝr :ℝc :ℝ × ℝconclusion(∫ z : ℝ × ℝ in {z | 0 ≤ (z - c).2 ∧ planarRadius (z - c) ≤ r}, g (planarRadius (z - c)) * ((z - c).1 / planarRadius (z - c)))= 0Proof (Lean source)
-- @node: translatedClosedHalfDisc_weighted_first_div_radius_cancellation lemma translatedClosedHalfDisc_weighted_first_div_radius_cancellation (g : ℝ → ℝ) (r : ℝ) (c : ℝ × ℝ) : (∫ z : ℝ × ℝ in {z | 0 ≤ (z - c).2 ∧ planarRadius (z - c) ≤ r}, g (planarRadius (z - c)) * ((z - c).1 / planarRadius (z - c))) = 0 := by let D : Set (ℝ × ℝ) := {u | 0 ≤ u.2 ∧ planarRadius u ≤ r} let T : (ℝ × ℝ) → (ℝ × ℝ) := fun u => c + u have hT : MeasurableEmbedding T := (Homeomorph.addLeft c).measurableEmbedding have hmp : MeasurePreserving T (volume : Measure (ℝ × ℝ)) volume := measurePreserving_add_left volume c have hset : {z : ℝ × ℝ | 0 ≤ (z - c).2 ∧ planarRadius (z - c) ≤ r} = T '' D := by ext z constructor · intro hz refine ⟨z - c, ?_, ?_⟩ · exact hz · simp [T] · rintro ⟨u, hu, rfl⟩ simpa [T, D] using hu rw [hset, hmp.setIntegral_image_emb hT] have hfun : (fun u : ℝ × ℝ => g (planarRadius (T u - c)) * ((T u - c).1 / planarRadius (T u - c))) = fun u => g (planarRadius u) * (u.1 / planarRadius u) := by funext u simp [T] rw [hfun] exact closedHalfDisc_weighted_first_div_radius_cancellation g r -
halfDisc_weighted_cos_sqlemma — The cosine-squared angular moment converts a radial weight into the nonzero π/2 factor used to cancel the affine regression term.hypothesesg :ℝ → ℝr :ℝconclusionProof (Lean source)
-- @node: halfDisc_weighted_cos_sq lemma halfDisc_weighted_cos_sq (g : ℝ → ℝ) (r : ℝ) : (∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z) * cos (planarAngle z) ^ 2) = (∫ s : ℝ in Ioc 0 r, s * g s) * (pi / 2) := by have hcosSq : (∫ θ : ℝ in Ioo 0 pi, cos θ ^ 2) = pi / 2 := by rw [← integral_Ioc_eq_integral_Ioo] exact integral_cos_sq_zero_to_pi calc _ = (∫ s : ℝ in Ioc 0 r, s * g s) * (∫ θ : ℝ in Ioo 0 pi, cos θ ^ 2) := halfDisc_weighted_polar_integral g (fun θ => cos θ ^ 2) r _ = _ := by rw [hcosSq] -
halfDisc_radial_integrallemma — A radial integrand on a half-disc admits the expected polar-coordinate decomposition.hypothesesg :ℝ → ℝr :ℝconclusion(∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z))Proof (Lean source)
-- @node: halfDisc_radial_integral lemma halfDisc_radial_integral (g : ℝ → ℝ) (r : ℝ) : (∫ z : ℝ × ℝ in {z | 0 < z.2 ∧ planarRadius z ≤ r}, g (planarRadius z)) = ∫ s : ℝ in Ioc 0 r, Real.pi * s * g s := 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)) = _ rw [← integral_indicator hD, ← integral_comp_polarCoord_symm] rw [show (∫ p in polarCoord.target, p.1 • D.indicator (fun z => g (planarRadius z)) (polarCoord.symm p)) = ∫ p in E, p.1 * g p.1 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 hrs : planarRadius (polarCoord.symm p) = p.1 := by exact congrArg fst (polarCoord.right_inv hp) 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 htheta exact Real.sin_pos_of_pos_of_lt_pi htheta 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⟩, hptheta, _⟩ exact ⟨hptheta, hpr⟩ by_cases h : polarCoord.symm p ∈ D · rw [indicator_of_mem hptarget, indicator_of_mem h, indicator_of_mem (hmem.mp h), hrs] rfl · rw [indicator_of_mem hptarget] simp only [indicator] rw [if_neg h, if_neg (mt hmem.mpr h)] 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] ] rw [show (fun p : ℝ × ℝ => p.1 * g p.1) = fun p => (p.1 * g p.1) * (1 : ℝ) by funext p; ring] change (∫ p in Ioc 0 r ×ˢ Ioo 0 Real.pi, (p.1 * g p.1) * (1 : ℝ)) = _ rw [Measure.volume_eq_prod] rw [setIntegral_prod_mul (μ := volume) (ν := volume) (fun s : ℝ => s * g s) (fun _ : ℝ => (1 : ℝ)) (Ioc 0 r) (Ioo 0 Real.pi)] rw [setIntegral_one_eq_measureReal, Measure.real_def, Real.volume_Ioo] simp only [sub_zero, ENNReal.toReal_ofReal Real.pi_pos.le] rw [mul_comm, ← integral_const_mul] apply integral_congr_ae filter_upwards with s ring -
halfDisc_cos_radial_cancellationlemma — Multiplication by cosine contributes zero after angular integration on every radial shell.hypothesesg :ℝ → ℝr :ℝProof (Lean source)
lemma halfDisc_cos_radial_cancellation (g : ℝ → ℝ) (r : ℝ) : (∫ s : ℝ in Ioc 0 r, s * g s * (∫ θ : ℝ in Ioc 0 pi, cos θ)) = 0 := by rw [integral_cos_zero_to_pi] simp -
translatedHalfDisc_weighted_cos_cancellationlemma — Translating an upper half-disc does not change the cosine cancellation.hypothesesg :ℝ → ℝr :ℝc :ℝ × ℝconclusion(∫ z : ℝ × ℝ in (fun u : ℝ × ℝ => c + u) '' {u | 0 < u.2 ∧ planarRadius u ≤ r}, g (planarRadius (z - c)) * cos (planarAngle (z - c)))= 0Proof (Lean source)
-- @node: translatedHalfDisc_weighted_cos_cancellation lemma translatedHalfDisc_weighted_cos_cancellation (g : ℝ → ℝ) (r : ℝ) (c : ℝ × ℝ) : (∫ z : ℝ × ℝ in (fun u : ℝ × ℝ => c + u) '' {u | 0 < u.2 ∧ planarRadius u ≤ r}, g (planarRadius (z - c)) * cos (planarAngle (z - c))) = 0 := by let D : Set (ℝ × ℝ) := {u | 0 < u.2 ∧ planarRadius u ≤ r} let T : (ℝ × ℝ) → (ℝ × ℝ) := fun u => c + u have hT : MeasurableEmbedding T := (Homeomorph.addLeft c).measurableEmbedding have hmp : MeasurePreserving T (volume : Measure (ℝ × ℝ)) volume := measurePreserving_add_left volume c rw [show (fun u : ℝ × ℝ => c + u) = T by rfl] rw [hmp.setIntegral_image_emb hT (fun z => g (planarRadius (z - c)) * cos (planarAngle (z - c))) D] have hpoint : (fun u : ℝ × ℝ => g (planarRadius (T u - c)) * cos (planarAngle (T u - c))) = fun u => g (planarRadius u) * cos (planarAngle u) := by funext u simp [T] rw [hpoint] exact halfDisc_weighted_cos_cancellation g r -
translatedHalfDisc_radialSet_weighted_cos_cancellationlemma — Translation preserves cosine cancellation on every measurable radial subset of a half-disc.hypothesesconclusion(∫ z : ℝ × ℝ in ((fun u : ℝ × ℝ => c + u) '' {u | 0 < u.2 ∧ planarRadius u ≤ r}) ∩ {z | planarRadius (z - c) ∈ A}, g (planarRadius (z - c)) * cos (planarAngle (z - c)))= 0Proof (Lean source)
-- @node: translatedHalfDisc_radialSet_weighted_cos_cancellation lemma translatedHalfDisc_radialSet_weighted_cos_cancellation (g : ℝ → ℝ) (r : ℝ) (c : ℝ × ℝ) {A : Set ℝ} (hA : MeasurableSet A) : (∫ z : ℝ × ℝ in ((fun u : ℝ × ℝ => c + u) '' {u | 0 < u.2 ∧ planarRadius u ≤ r}) ∩ {z | planarRadius (z - c) ∈ A}, g (planarRadius (z - c)) * cos (planarAngle (z - c))) = 0 := by let D : Set (ℝ × ℝ) := (fun u : ℝ × ℝ => c + u) '' {u | 0 < u.2 ∧ planarRadius u ≤ r} let R : Set (ℝ × ℝ) := {z | planarRadius (z - c) ∈ A} have hR : MeasurableSet R := by exact hA.preimage (planarRadius_measurable.comp (by fun_prop)) have hcancel := translatedHalfDisc_weighted_cos_cancellation (A.indicator g) r c change (∫ z : ℝ × ℝ in D ∩ R, g (planarRadius (z - c)) * cos (planarAngle (z - c))) = 0 rw [← hcancel] have hDR : D ∩ R = R ∩ D := inter_comm D R rw [hDR] rw [← Measure.restrict_restrict hR] rw [← integral_indicator hR] apply integral_congr_ae filter_upwards with z simp only [R, indicator, mem_setOf_eq] split_ifs <;> simp_all
LineSecondDeriv 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 C² 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.
The second directional derivative of f at q along d: the directional derivative, along d, of the map x ↦ fderiv ℝ f x d. For C² functions this is the value Hess f q (d, d) of the Hessian quadratic form.
Definition (Lean source)
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
Proof (Lean source)
6 supporting declarations (lemmas, instances)
-
hasDerivAt_linelemma — The line s ↦ q + s • d is differentiable with derivative d, as a HasDerivAt.Proof (Lean source)
lemma hasDerivAt_line (q d : E) (t : ℝ) : HasDerivAt (fun s : ℝ => q + s • d) d t := by simpa using ((hasDerivAt_id t).smul_const d).const_add q -
deriv_linelemma — First directional derivative along a line.hypothesesProof (Lean source)
lemma deriv_line {f : E → ℝ} (q d : E) (t : ℝ) (hf : DifferentiableAt ℝ f (q + t • d)) : deriv (fun s : ℝ => f (q + s • d)) t = fderiv ℝ f (q + t • d) d := by exact (hf.hasFDerivAt.comp_hasDerivAt t (hasDerivAt_line q d t)).deriv -
contDiff_one_fderiv_applylemma — x ↦ fderiv ℝ f x d is Cⁿ when f is Cⁿ⁺¹. It is the composition of the derivative map with the continuous linear evaluation L ↦ L d.hypothesesProof (Lean source)
lemma contDiff_one_fderiv_apply {n : ℕ} {f : E → ℝ} (hf : ContDiff ℝ (n + 1) f) (d : E) : ContDiff ℝ n (fun x => fderiv ℝ f x d) := by exact (ContinuousLinearMap.apply ℝ ℝ d).contDiff.comp (hf.fderiv_right (m := n) (by rfl)) -
differentiable_fderiv_applylemma — x ↦ fderiv ℝ f x d is differentiable when f is C².hypothesesconclusionDifferentiable ℝ (fun x => fderiv ℝ f x d)Proof (Lean source)
lemma differentiable_fderiv_apply {f : E → ℝ} (hf : ContDiff ℝ 2 f) (d : E) : Differentiable ℝ (fun x => fderiv ℝ f x d) := (contDiff_one_fderiv_apply hf d).differentiable (by norm_num) -
deriv_deriv_linelemma — Second directional derivative along a line. The second derivative of the line restriction at parameter t is the second directional derivative of f at the moving base point q + t • d. Note this is an identity of deriv (not derivWithin): it holds at every t because the line restriction is differentiable on all of ℝ.hypothesesconclusionderiv (deriv fun s : ℝ => f (q + s • d)) t = secondDirDeriv f d (q + t • d)Proof (Lean source)
lemma deriv_deriv_line {f : E → ℝ} (hf : ContDiff ℝ 2 f) (q d : E) (t : ℝ) : deriv (deriv fun s : ℝ => f (q + s • d)) t = secondDirDeriv f d (q + t • d) := by have hstep : (deriv fun s : ℝ => f (q + s • d)) = fun s => fderiv ℝ f (q + s • d) d := by funext s exact deriv_line q d s ((hf.differentiable two_ne_zero) (q + s • d)) rw [hstep] exact deriv_line q d t ((differentiable_fderiv_apply hf d) (q + t • d)) -
continuous_secondDirDerivlemma — The curvature modulus is continuous in the base point. Hence bounded on any compact set, which supplies the BddAbove hypothesis of le_ciSup.Proof (Lean source)
lemma continuous_secondDirDeriv {f : E → ℝ} (hf : ContDiff ℝ 2 f) (d : E) : Continuous (secondDirDeriv f d) := by exact (ContinuousLinearMap.apply ℝ ℝ d).continuous.comp ((contDiff_one_fderiv_apply hf d).continuous_fderiv (by norm_num))
MonomialGram 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.
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)
A multivariate monomial multiplies the coordinates of a vector after raising each coordinate to its assigned nonnegative integer exponent.
The monomial Gram matrix records the integrals of every pairwise product of a finite family of multivariate monomials over a centered closed cube.
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
Proof (Lean source)
8 supporting declarations (lemmas, instances)
-
continuous_monomiallemma — A multivariate real monomial varies continuously with its coordinate vector.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) -
continuous_monomialCombinationlemma — A finite linear combination of multivariate real monomials is continuous.hypothesesconclusionContinuous (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)) -
monomial_linearIndependent_on_cubetheorem — 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.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 -
monomialGram_quadFormtheorem — Evaluating the monomial Gram quadratic form at a coefficient vector equals integrating the square of the corresponding monomial combination over the cube.hypothesesconclusion∑ k, ∑ l, z k * monomialGram expo r k l * z lProof (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] -
monomialGram_isHermitiantheorem — The monomial Gram matrix is symmetric, and hence Hermitian over the real numbers.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] -
monomialGram_posSemideftheorem — Every coefficient vector gives a nonnegative quadratic form under the monomial Gram matrix.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 _) -
sum_sq_poslemma — The sum of squared coordinates of a nonzero finite real-valued vector is strictly positive.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 -
exists_monomialGram_coercivetheorem — 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.hypothesesconclusion∃ cmin : ℝif0 < cmin ∧ ∀ z : Fin pthenℝ, cmin * (∑ k, (z k) ^ 2) ≤ ∑ k, ∑ l, z k * monomialGram expo r k l * z lProof (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
OffsetPeeling 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.
Offset-peeling constant for the c = 1/4 offset: (1 − θ)·(4θ)^{θ/(1−θ)}.
Definition (Lean source)
Peeling constant with a general offset coefficient c: (1 − θ)·(θ/c)^{θ/(1−θ)} (the c = 1/4 case is offsetPeelingConstant).
Definition (Lean source)
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
Proof (Lean source)
6 supporting declarations (lemmas, instances)
-
offset_peeling_coefflemma — 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).hypothesesc θ a t :ℝhc_pos :0 < chθ_pos :0 < θhθ_lt :θ < 1ha :0 ≤ aht :0 ≤ tconclusionmax 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) -
offsetPeelingConstantC_nonneglemma — The general offset-peeling constant is nonnegative when the offset is positive and the exponent lies between zero and one.hypothesesc θ :ℝhc_nonneg :0 ≤ chθ_nonneg :0 ≤ θhθ_le :θ ≤ 1conclusion0 ≤ offsetPeelingConstantC c θ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 _) -
offset_peeling_coeff_nonneg_thetalemma — The general offset-peeling bound remains valid at exponent zero by the same constant formula.hypothesesc θ a t :ℝhc_pos :0 < chθ_nonneg :0 ≤ θhθ_lt :θ < 1ha :0 ≤ aht :0 ≤ tconclusionmax 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 -
offsetPeelingConstant_nonneglemma — The offset-peeling constant for the quarter-offset case is nonnegative when the exponent lies between zero and one.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 -
offset_peeling_nonneg_thetalemma — The quarter-offset peeling bound remains valid at exponent zero by continuity of the constant formula.hypothesesθ a t :ℝhθ_nonneg :0 ≤ θhθ_lt :θ < 1ha :0 ≤ aht :0 ≤ tconclusionmax 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 -
max_two_splitlemma — 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.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
RpowArith 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).
For any real number x, its reciprocal equals its real power raised to the exponent −1.
Formal statement
Proof (Lean source)
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
Proof (Lean source)
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
Proof (Lean source)
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
Proof (Lean source)
SecondOrderDescent 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.
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)
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
Proof (Lean source)
8 supporting declarations (lemmas, instances)
-
descentStep_of_eq_zerotheorem — With zero curvature bound, the clipped quadratic-model step is the endpoint.Proof (Lean source)
-
descentStep_of_postheorem — With a positive curvature bound, the clipped quadratic-model step is the smaller of the available interval length and the unconstrained quadratic-model optimizer.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'] -
descentStep_mem_Icctheorem — The clipped quadratic-model step is feasible whenever the interval length, slope margin, and curvature bound are nonnegative.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 _ _⟩ -
second_order_upper_boundtheorem — 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.hypothesesf :ℝ → ℝM T :ℝhf :ContDiffOn ℝ 2 f (Icc 0 T)hf0 :DifferentiableAt ℝ f 0t :ℝht :t ∈ Icc 0 Tconclusionf t ≤ f 0 + deriv f 0 * t + (M / 2) * t ^ 2Proof (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 -
first_order_upper_boundtheorem — A real function with nonpositive second derivative in an interval's interior lies below its tangent line at the left endpoint.hypothesesconclusionf t ≤ f 0 + deriv f 0 * tProof (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 -
second_order_descent_gap_mintheorem — With positive curvature, the clipped quadratic-model step gives at least half of the linear descent term.hypothesesf :ℝ → ℝM c T :ℝhT :0 ≤ Thc :0 ≤ chMpos :0 < Mhf :ContDiffOn ℝ 2 f (Icc 0 T)hf0 :DifferentiableAt ℝ f 0hslope :deriv f 0 ≤ -cProof (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 -
first_order_descent_gaptheorem — With zero curvature, the endpoint step gives the full linear descent guaranteed by the negative initial slope.hypothesesf :ℝ → ℝc T :ℝhT :0 ≤ Thf :ContDiffOn ℝ 2 f (Icc 0 T)hf0 :DifferentiableAt ℝ f 0hslope :deriv f 0 ≤ -cconclusionf 0 - f T ≥ c * TProof (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 -
second_order_descent_gap_halftheorem — In both zero and positive curvature regimes, the clipped quadratic-model step gives a uniform half-linear decrease.hypothesesf :ℝ → ℝM c T :ℝhT :0 ≤ Thc :0 ≤ chMnn :0 ≤ Mhf :ContDiffOn ℝ 2 f (Icc 0 T)hf0 :DifferentiableAt ℝ f 0hslope :deriv f 0 ≤ -cconclusionProof (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
SmoothReciprocal 2 core · 3 supporting The reciprocal x ↦ x⁻¹ is singular at 0. ★ recipC_contDiff
A globally C¹ 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 C¹ on all of ℝ. This is the reusable core of the "globally C¹ 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.
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 C¹ (see recipC_contDiff).
Definition (Lean source)
Global continuous differentiability of the floored reciprocal. For a strictly positive threshold ε, the floored reciprocal recipC ε is continuously differentiable on all of the reals.
Proof (Lean source)
3 supporting declarations (lemmas, instances)
-
recipC_eq_invlemma — On the region x ≥ ε/2 (with ε > 0) the floored reciprocal is exactly x⁻¹, because the smooth cutoff has already saturated to 1 there.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_oflemma — 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.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 -
recipC_contDiff_twolemma — recipC ε is globally C². Specialization of recipC_contDiff_of; this is the order the reciprocal-product envelope's directional curvature modulus needs.Proof (Lean source)
@[fun_prop] lemma recipC_contDiff_two (ε : ℝ) (hε : 0 < ε) : ContDiff ℝ 2 (recipC ε) := recipC_contDiff_of 2 ε hε
WeightedCauchySchwarz 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.
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
Proof (Lean source)
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
Proof (Lean source)
2 supporting declarations (lemmas, instances)
-
abs_weighted_mean_le_sqrt_weighted_sqlemma — 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.hypothesesProof (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 _ _ -
weighted_sqrt_le_sqrt_weightedlemma — 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.hypothesesProof (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