Skip to content

Commit d37b436

Browse files
committed
feat(MeasureTheory/Integral/MeanValue): golf exists_eq_const_mul_intervalIntegral_of_ae_nonneg
1 parent d066754 commit d37b436

1 file changed

Lines changed: 22 additions & 88 deletions

File tree

Mathlib/MeasureTheory/Integral/IntervalIntegral/MeanValue.lean

Lines changed: 22 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ Authors: Louis (Yiyang) Liu
55
-/
66
module
77

8-
public import Mathlib.MeasureTheory.Integral.IntervalAverage
8+
public import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
9+
public import Mathlib.MeasureTheory.Integral.MeanValue
910

1011
/-!
1112
# First mean value theorem for interval integrals
@@ -46,108 +47,41 @@ that `g` is interval integrable on `a..b` w.r.t. `μ`, and that `g ≥ 0` a.e. o
4647
`μ.restrict (Ι a b)`. Then
4748
`∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x ∂μ) = f c * (∫ x in a..b, g x ∂μ)`. -/
4849
theorem exists_eq_const_mul_intervalIntegral_of_ae_nonneg
49-
(hf : ContinuousOn f (uIcc a b))
50-
(hg : IntervalIntegrable g μ a b)
50+
(hf : ContinuousOn f (uIcc a b)) (hg : IntervalIntegrable g μ a b)
5151
(hg0 : ∀ᵐ x ∂(μ.restrict (Ι a b)), 0 ≤ g x) :
5252
∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x ∂μ) = f c * (∫ x in a..b, g x ∂μ) := by
53-
wlog hle : a ≤ b generalizing a b
54-
· simp at hle
53+
by_cases h : a = b
54+
· subst h
55+
refine ⟨a, by simp, by simp⟩
56+
wlog hab : a < b generalizing a b
57+
· simp only [not_lt] at hab
5558
obtain ⟨c, c_in_uIcc, that⟩ :=
56-
this (a := b) (b := a) (by rwa [uIcc_comm]) hg.symm (by rwa [uIoc_comm]) hle.le
59+
this (by rwa [uIcc_comm]) hg.symm (by rwa [uIoc_comm]) (by aesop) (lt_of_le_of_ne' hab h)
5760
refine ⟨c, by rwa [uIcc_comm], by simpa [integral_symm b a]⟩
5861
let s := Ι a b
59-
have hs : s = Ioc a b := uIoc_of_le hle
62+
have hs : s = Ioc a b := uIoc_of_le hab.le
63+
have hs' : s ⊆ [[a, b]] := uIoc_subset_uIcc
64+
have hs_conn : IsConnected s := by simpa [hs] using isConnected_Ioc hab
6065
have hs_meas : MeasurableSet s := measurableSet_uIoc
61-
let ρ := fun x ↦ ENNReal.ofReal (g x)
62-
let ν := μ.withDensity ρ
63-
have hρ_ae : AEMeasurable ρ (μ.restrict s) := by
64-
apply AEMeasurable.ennreal_ofReal
65-
apply AEStronglyMeasurable.aemeasurable
66-
apply IntervalIntegrable.aestronglyMeasurable
67-
simpa [hle]
68-
have hρ_top : ∀ᵐ x ∂ μ.restrict s, ρ x < ⊤ := by simp [ρ]
69-
have h_toReal_ae : (fun x ↦ (ρ x).toReal) =ᵐ[μ.restrict s] g := by
70-
apply hg0.mono
71-
intro x hx
72-
simpa [ρ]
73-
have hfg : ∫ x in a..b, f x * g x ∂μ = ∫ x in s, f x ∂ν := by
74-
calc
75-
_ = ∫ x in s, f x * g x ∂μ := by simp [hs, integral_of_le hle]
76-
_ = ∫ x in s, (ρ x).toReal * f x ∂μ := by
77-
apply MeasureTheory.integral_congr_ae
78-
apply h_toReal_ae.mono
79-
intro x hx
80-
simp [hx, mul_comm]
81-
_ = _ := by
82-
have h := setIntegral_withDensity_eq_setIntegral_toReal_smul₀
83-
hρ_ae hρ_top f hs_meas
84-
simp [ν, h]
85-
have hg1 : ∫ x in a..b, g x ∂μ = ∫ x in s, (1 : ℝ) ∂ν := by
86-
have h := setIntegral_withDensity_eq_setIntegral_toReal_smul₀
87-
hρ_ae hρ_top (fun _ ↦ (1 : ℝ)) hs_meas
88-
calc
89-
_ = ∫ x in s, g x ∂μ := by simp [hs, integral_of_le hle]
90-
_ = ∫ x in s, (ρ x).toReal ∂μ := by rw [integral_congr_ae h_toReal_ae]
91-
_ = _ := by simp [ν, h]
92-
by_cases hzero : ∫ x in s, (1 : ℝ) ∂ν = 0
93-
· refine ⟨a, by simp, ?_⟩
94-
calc
95-
_ = ∫ x in s, f x ∂ν := hfg
96-
_ = 0 := by
97-
rw [hzero, integral_eq_zero_iff_of_le_of_nonneg_ae
98-
hle (by rwa [← uIoc_of_le hle]) hg, ← uIoc_of_le hle] at hg1
99-
have hfg_zero : ∫ x in a..b, f x * g x ∂μ = 0 := by
100-
have hfg_ae : (fun x ↦ f x * g x) =ᵐ[μ.restrict s] 0 := by
101-
apply hg1.mono
102-
intro x hx
103-
simp [hx]
104-
simp [integral_congr_ae_restrict hfg_ae]
105-
rw [← hfg, hfg_zero]
106-
_ = _ := by simp [hzero, hg1]
107-
· have hzero' : (ν s).toReal ≠ 0 := by simpa using hzero
108-
have hνfin : ν s ≠ ⊤ := by
109-
intro this
110-
apply hzero'
111-
simp [this]
112-
have0 : ν s ≠ 0 := by
113-
intro this
114-
apply hzero'
115-
simp [this]
116-
obtain ⟨c, hc, havg⟩ := exists_eq_interval_average_of_measure
117-
hf hνfin hν0
118-
refine ⟨c, hc, ?_⟩
119-
calc
120-
_ = ∫ x in s, f x ∂ν := hfg
121-
_ = f c * ∫ x in s, (1 : ℝ) ∂ν := by
122-
rw [havg]
123-
refold_let s
124-
simp only [setAverage_eq, smul_eq_mul, MeasureTheory.integral_const, MeasurableSet.univ,
125-
measureReal_restrict_apply, univ_inter, mul_one]
126-
rw [measureReal_def]
127-
have hreal0 : (ν s).toReal ≠ 0 := ENNReal.toReal_ne_zero.mpr ⟨hν0, hνfin⟩
128-
field_simp
129-
_ = _ := by simp [hg1]
66+
have hf' : ContinuousOn f s := hf.mono hs'
67+
have hg' : IntegrableOn g s μ := by rwa [← intervalIntegrable_iff]
68+
have hfg : IntegrableOn (fun x ↦ f x * g x) s μ := by
69+
rw [← intervalIntegrable_iff]
70+
exact hg.continuousOn_smul hf
71+
obtain ⟨c, hc, h⟩ := exists_eq_const_mul_setIntegral_of_ae_nonneg hs_conn hs_meas hf' hg' hfg hg0
72+
have h' : ∫ (x : ℝ) in a..b, f x * g x ∂μ = f c * ∫ (x : ℝ) in a..b, g x ∂μ := by
73+
simp_rw [integral_of_le hab.le]; rwa [← hs]
74+
refine ⟨c, mem_of_subset_of_mem hs' hc, h'⟩
13075

13176
/-- **First mean value theorem for interval integrals (arbitrary measure, nonnegativity).**
13277
Let `f g : ℝ → ℝ` and let `μ` be a measure on `ℝ`. Assume that `f` is continuous on `uIcc a b`,
13378
that `g` is interval integrable on `a..b` w.r.t. `μ`, and that `g ≥ 0` on `Ι a b`. Then
13479
`∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x ∂μ) = f c * (∫ x in a..b, g x ∂μ)`. -/
13580
theorem exists_eq_const_mul_intervalIntegral_of_nonneg'
136-
(hf : ContinuousOn f (uIcc a b))
137-
(hg : IntervalIntegrable g μ a b)
81+
(hf : ContinuousOn f (uIcc a b)) (hg : IntervalIntegrable g μ a b)
13882
(hg0 : ∀ x ∈ Ι a b, 0 ≤ g x) :
13983
∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x ∂μ) = f c * (∫ x in a..b, g x ∂μ) := by
14084
have hg0_ae : ∀ᵐ x ∂(μ.restrict (Ι a b)), 0 ≤ g x := by
14185
rw [ae_restrict_iff' measurableSet_uIoc]
14286
exact ae_of_all μ hg0
14387
exact exists_eq_const_mul_intervalIntegral_of_ae_nonneg hf hg hg0_ae
144-
145-
/-- **First mean value theorem for interval integrals (Lebesgue measure, nonnegativity).**
146-
Let `f g : ℝ → ℝ` be continuous on `uIcc a b`. If `g ≥ 0` on `Ι a b`, then
147-
`∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x) = f c * (∫ x in a..b, g x)`. -/
148-
theorem exists_eq_const_mul_intervalIntegral_of_nonneg
149-
(hf : ContinuousOn f (uIcc a b))
150-
(hg : ContinuousOn g (uIcc a b))
151-
(hg0 : ∀ x ∈ Ι a b, 0 ≤ g x) :
152-
∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x) = f c * (∫ x in a..b, g x) := by
153-
exact exists_eq_const_mul_intervalIntegral_of_nonneg' hf hg.intervalIntegrable hg0

0 commit comments

Comments
 (0)