Skip to content

Commit df3de5d

Browse files
sgouezelEtienneC30RemyDegenne
committed
feat: drop a finiteness assumptions in covariance results (#31569)
Co-authored-by: Etienne Marion <baguettes_casino0c@icloud.com> Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Rémy Degenne <4094732+RemyDegenne@users.noreply.github.com>
1 parent 629ca6e commit df3de5d

File tree

2 files changed

+68
-15
lines changed

2 files changed

+68
-15
lines changed

Mathlib/Probability/Moments/CovarianceBilin.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ lemma covarianceBilin_eq_covarianceBilinDual (x y : E) :
5656
covarianceBilin μ x y = covarianceBilinDual μ (toDualMap ℝ E x) (toDualMap ℝ E y) := rfl
5757

5858
@[simp]
59-
lemma covarianceBilin_of_not_memLp [IsFiniteMeasure μ] (h : ¬MemLp id 2 μ) :
59+
lemma covarianceBilin_of_not_memLp (h : ¬MemLp id 2 μ) :
6060
covarianceBilin μ = 0 := by
6161
ext
6262
simp [covarianceBilin_eq_covarianceBilinDual, h]
@@ -66,7 +66,7 @@ lemma covarianceBilin_apply [CompleteSpace E] [IsFiniteMeasure μ] (h : MemLp id
6666
simp_rw [covarianceBilin, ContinuousLinearMap.bilinearComp_apply, covarianceBilinDual_apply' h]
6767
simp only [LinearIsometry.coe_toContinuousLinearMap, id_eq, toDualMap_apply]
6868

69-
lemma covarianceBilin_comm [IsFiniteMeasure μ] (x y : E) :
69+
lemma covarianceBilin_comm (x y : E) :
7070
covarianceBilin μ x y = covarianceBilin μ y x := by
7171
rw [covarianceBilin_eq_covarianceBilinDual, covarianceBilinDual_comm,
7272
covarianceBilin_eq_covarianceBilinDual]
@@ -95,11 +95,11 @@ lemma covarianceBilin_real_self {μ : Measure ℝ} [IsFiniteMeasure μ] (x : ℝ
9595
rw [covarianceBilin_real, pow_two]
9696

9797
@[simp]
98-
lemma covarianceBilin_self_nonneg [IsFiniteMeasure μ] (x : E) :
98+
lemma covarianceBilin_self_nonneg (x : E) :
9999
0 ≤ covarianceBilin μ x x := by
100100
simp [covarianceBilin]
101101

102-
lemma isPosSemidef_covarianceBilin [IsFiniteMeasure μ] :
102+
lemma isPosSemidef_covarianceBilin :
103103
(covarianceBilin μ).toBilinForm.IsPosSemidef where
104104
eq := covarianceBilin_comm
105105
nonneg := covarianceBilin_self_nonneg

Mathlib/Probability/Moments/CovarianceBilinDual.lean

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ end Centered
232232

233233
section Covariance
234234

235-
variable [NormedSpace ℝ E] [BorelSpace E] [IsFiniteMeasure μ]
235+
variable [NormedSpace ℝ E] [BorelSpace E]
236236

237237
open Classical in
238238
/-- Continuous bilinear form with value `∫ x, (L₁ x - μ[L₁]) * (L₂ x - μ[L₂]) ∂μ` on `(L₁, L₂)`
@@ -241,27 +241,80 @@ noncomputable
241241
def covarianceBilinDual (μ : Measure E) : StrongDual ℝ E →L[ℝ] StrongDual ℝ E →L[ℝ] ℝ :=
242242
uncenteredCovarianceBilinDual (μ.map (fun x ↦ x - ∫ x, x ∂μ))
243243

244-
@[simp]
245-
lemma covarianceBilinDual_of_not_memLp (h : ¬ MemLp id 2 μ) (L₁ L₂ : StrongDual ℝ E) :
244+
omit [BorelSpace E] in
245+
lemma _root_.MeasureTheory.memLp_id_of_self_sub_integral {p : ℝ≥0∞}
246+
(h_Lp : MemLp (fun x ↦ x - ∫ y, y ∂μ) p μ) : MemLp id p μ := by
247+
have : (id : E → E) = fun x ↦ x - ∫ x, x ∂μ + ∫ x, x ∂μ := by ext; simp
248+
rw [this]
249+
apply h_Lp.add
250+
set c := ∫ x, x ∂μ
251+
/- We need to check that the constant `c = ∫ x, x ∂μ` is in `L^p`. Note that we don't assume
252+
that `μ` is finite, so this requires an argument. If the constant is zero, it's obvious.
253+
If it's nonzero, this means that `x` is integrable for `μ` (as otherwise the integral would be
254+
`0` by our choice of junk value), so `‖x‖ ^ (1/p)` is in `L^p`.
255+
The constant `c` is controlled by `2 ‖x - c‖` close to `0` (say when `‖x‖ ≤ ‖c‖ / 2`)
256+
and by a multiple of `‖x‖ ^ (1/p)` away from `0`. Those two functions
257+
are in `L^p` by assumptions, so the constant `c` also is. -/
258+
by_cases hx : c = 0
259+
· simp [hx]
260+
rcases eq_or_ne p 0 with rfl | hp0
261+
· simp [aestronglyMeasurable_const]
262+
rcases eq_or_ne p ∞ with rfl | hptop
263+
· exact memLp_top_const c
264+
apply (integrable_norm_rpow_iff (by fun_prop) hp0 hptop).1
265+
have I : Integrable (fun (x : E) ↦ ‖x‖) μ := by
266+
apply Integrable.norm
267+
contrapose! hx
268+
exact integral_undef hx
269+
have := (h_Lp.integrable_norm_rpow hp0 hptop).const_mul (2 ^ p.toReal)
270+
apply (((I.const_mul (2 * ‖c‖ ^ (p.toReal - 1))).add this)).mono' (by fun_prop)
271+
filter_upwards [] with y
272+
lift p to ℝ≥0 using hptop
273+
simp only [ENNReal.coe_toReal, Real.norm_eq_abs, Pi.add_apply]
274+
rw [abs_of_nonneg (by positivity)]
275+
rcases le_total ‖y‖ (‖c‖ / 2)
276+
· have : ‖c‖ ≤ ‖y‖ + ‖y - c‖ := Eq.trans_le (by abel_nf) (norm_sub_le y (y - c))
277+
calc ‖c‖ ^ (p : ℝ)
278+
_ ≤ (2 * ‖y - c‖) ^ (p : ℝ) :=
279+
Real.rpow_le_rpow (by positivity) (by linarith) (by positivity)
280+
_ = 0 + 2 ^ (p : ℝ) * ‖y - c‖ ^ (p : ℝ) := by
281+
rw [Real.mul_rpow (by simp) (by positivity)]
282+
ring
283+
_ ≤ 2 * ‖c‖ ^ (p - 1 : ℝ) * ‖y‖ + 2 ^ (p : ℝ) * ‖y - c‖ ^ (p : ℝ) := by
284+
gcongr
285+
positivity
286+
· calc ‖c‖ ^ (p : ℝ )
287+
_ = ‖c‖ ^ ((p - 1) + 1 : ℝ) := by abel_nf
288+
_ = ‖c‖ ^ (p - 1 : ℝ) * ‖c‖ := by rw [Real.rpow_add (by positivity), Real.rpow_one]
289+
_ ≤ ‖c‖ ^ (p - 1 : ℝ) * (2 * ‖y‖) := by gcongr; linarith
290+
_ = 2 * ‖c‖ ^ (p - 1 : ℝ) * ‖y‖ + 0 := by ring
291+
_ ≤ 2 * ‖c‖ ^ (p - 1 : ℝ) * ‖y‖ + 2 ^ (p : ℝ) * ‖y - c‖ ^ (p : ℝ) := by gcongr; positivity
292+
293+
lemma covarianceBilinDual_of_not_memLp' (h : ¬ MemLp (fun x ↦ x - ∫ y, y ∂μ) 2 μ)
294+
(L₁ L₂ : StrongDual ℝ E) :
246295
covarianceBilinDual μ L₁ L₂ = 0 := by
247296
rw [covarianceBilinDual, uncenteredCovarianceBilinDual_of_not_memLp]
248297
rw [(measurableEmbedding_subRight _).memLp_map_measure_iff]
249-
refine fun h_Lp ↦ h ?_
250-
have : (id : E → E) = fun x ↦ x - ∫ x, x ∂μ + ∫ x, x ∂μ := by ext; simp
251-
rw [this]
252-
exact h_Lp.add (memLp_const _)
298+
exact h
299+
300+
@[simp]
301+
lemma covarianceBilinDual_of_not_memLp (h : ¬ MemLp id 2 μ) (L₁ L₂ : StrongDual ℝ E) :
302+
covarianceBilinDual μ L₁ L₂ = 0 := by
303+
apply covarianceBilinDual_of_not_memLp'
304+
contrapose! h
305+
exact memLp_id_of_self_sub_integral h
253306

254307
@[simp]
255308
lemma covarianceBilinDual_zero : covarianceBilinDual (0 : Measure E) = 0 := by
256309
rw [covarianceBilinDual, Measure.map_zero, uncenteredCovarianceBilinDual_zero]
257310

258311
lemma covarianceBilinDual_comm (L₁ L₂ : StrongDual ℝ E) :
259312
covarianceBilinDual μ L₁ L₂ = covarianceBilinDual μ L₂ L₁ := by
260-
by_cases h : MemLp id 2 μ
313+
by_cases h : MemLp (fun x ↦ x - ∫ y, y ∂μ) 2 μ
261314
· have h' : MemLp id 2 (Measure.map (fun x ↦ x - ∫ (x : E), x ∂μ) μ) :=
262-
(measurableEmbedding_subRight _).memLp_map_measure_iff.mpr <| h.sub (memLp_const _)
315+
(measurableEmbedding_subRight _).memLp_map_measure_iff.mpr <| h
263316
simp_rw [covarianceBilinDual, uncenteredCovarianceBilinDual_apply h', mul_comm (L₁ _)]
264-
· simp [h]
317+
· simp [h, covarianceBilinDual_of_not_memLp']
265318

266319
@[simp]
267320
lemma covarianceBilinDual_self_nonneg (L : StrongDual ℝ E) : 0 ≤ covarianceBilinDual μ L L := by
@@ -271,7 +324,7 @@ lemma covarianceBilinDual_self_nonneg (L : StrongDual ℝ E) : 0 ≤ covarianceB
271324
exact real_inner_self_nonneg
272325
· simp [h]
273326

274-
variable [CompleteSpace E]
327+
variable [CompleteSpace E] [IsFiniteMeasure μ]
275328

276329
lemma covarianceBilinDual_apply (h : MemLp id 2 μ) (L₁ L₂ : StrongDual ℝ E) :
277330
covarianceBilinDual μ L₁ L₂ = ∫ x, (L₁ x - μ[L₁]) * (L₂ x - μ[L₂]) ∂μ := by

0 commit comments

Comments
 (0)