Skip to content

Commit 63657dc

Browse files
committed
refactor(MeasureTheory/Integral/IntervalIntegral/MeanValue): rename and rework proof of exists_eq_const_mul_integral_of_ae_nonneg
1 parent 6b055c9 commit 63657dc

1 file changed

Lines changed: 90 additions & 173 deletions

File tree

Mathlib/MeasureTheory/Integral/IntervalIntegral/MeanValue.lean

Lines changed: 90 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@ Copyright (c) 2025 Louis (Yiyang) Liu. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Louis (Yiyang) Liu
55
-/
6-
import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
7-
import Mathlib.Topology.Order.IntermediateValue
6+
import Mathlib.MeasureTheory.Integral.IntervalAverage
87

98
/-!
109
# First mean value theorem for integrals
1110
1211
We prove versions of the first mean value theorem for (unordered) interval integrals
1312
w.r.t. an arbitrary measure in `ℝ`
1413
15-
One assuming almost-every where non-negativity of `g` under an arbitrary measure,
16-
and one assuming point-wise non-negativity together with continuity of `g`.
14+
One assuming almost-everywhere nonnegativity of `g` under an arbitrary measure,
15+
and one assuming pointwise nonnegativity together with continuity of `g`.
1716
1817
## Main statements
1918
20-
- `exists_eq_const_mul_interval_integral_of_continuous_on_of_ae_nonneg`:
19+
- `exists_eq_const_mul_integral_of_ae_nonneg`:
2120
**First mean value theorem for integrals** for (unordered) interval integrals when
2221
`g` is interval integrable on `a..b` w.r.t. an arbitrary measure `μ` and satisfies
23-
`g ≥ 0` almost everywhere on `uIcc a b`.
24-
- `exists_eq_const_mul_interval_integral_of_continuous_on_of_nonneg`:
22+
`g ≥ 0` almost everywhere on `uIoc a b`.
23+
- `exists_eq_const_mul_integral_of_nonneg`:
2524
**First mean value theorem for integrals** for (unordered) interval integrals when
26-
`g` is continuous on `uIcc a b` and nonnegative there (Lebesgue measure).
25+
`g` is continuous on `uIoc a b` and nonnegative there (Lebesgue measure).
2726
2827
## References
2928
@@ -36,190 +35,108 @@ and one assuming point-wise non-negativity together with continuity of `g`.
3635
mean value theorem, interval integral, measure, nonnegative, continuous, integrable
3736
-/
3837

39-
open MeasureTheory Set intervalIntegral Filter
38+
open MeasureTheory Set intervalIntegral
4039

4140
/-- **First mean value theorem for integrals (interval integral, arbitrary measure).**
4241
Let `μ` be a measure on `ℝ`. If `f : ℝ → ℝ` is continuous on `uIcc a b` and
4342
`g : ℝ → ℝ` is interval integrable on `a..b` w.r.t. `μ`, and `g ≥ 0` almost
44-
everywhere on `uIcc a b`, then there exists `c ∈ uIcc a b` such that
43+
everywhere on `uIoc a b`, then there exists `c ∈ uIcc a b` such that
4544
`∫ x in a..b, f x * g x ∂μ = f c * ∫ x in a..b, g x ∂μ`. -/
46-
theorem exists_eq_const_mul_interval_integral_of_continuous_on_of_ae_nonneg
45+
theorem exists_eq_const_mul_integral_of_ae_nonneg
4746
{a b : ℝ} {f g : ℝ → ℝ} {μ : Measure ℝ}
4847
(hf : ContinuousOn f (uIcc a b))
4948
(hg : IntervalIntegrable g μ a b)
50-
(hg0 : ∀ᵐ x ∂(μ.restrict (uIcc a b)), 0 ≤ g x) :
49+
(hg0 : ∀ᵐ x ∂(μ.restrict (uIoc a b)), 0 ≤ g x) :
5150
∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x ∂μ) = f c * (∫ x in a..b, g x ∂μ) := by
52-
wlog a_b_case : a ≤ b generalizing a b
53-
· simp at a_b_case
51+
wlog hle : a ≤ b generalizing a b
52+
· simp at hle
5453
obtain ⟨c, c_in_uIcc, that⟩ :=
55-
this
56-
(a := b) (b := a) (by rwa [uIcc_comm])
57-
hg.symm (by rwa [uIcc_comm])
58-
a_b_case.le
59-
refine ⟨c, ?_, ?_⟩
60-
· rwa [uIcc_comm]
61-
· calc
62-
_ = - ∫ x in b..a, f x * g x ∂μ := by
63-
exact integral_symm b a
64-
_ = - (f c * ∫ x in b..a, g x ∂μ) := by
65-
rw [that]
66-
simp [integral_symm b a]
67-
· have is_compact_uIcc_a_b : IsCompact (uIcc a b) := by
68-
exact isCompact_uIcc
69-
obtain ⟨x_f_min, x_f_min_in_uIcc_a_b, f_min⟩ := by
70-
exact IsCompact.exists_isMinOn
71-
is_compact_uIcc_a_b nonempty_uIcc hf
72-
obtain ⟨x_f_max, x_f_max_in_uIcc_a_b, f_max⟩ := by
73-
exact IsCompact.exists_isMaxOn
74-
is_compact_uIcc_a_b nonempty_uIcc hf
75-
let m := f x_f_min
76-
let M := f x_f_max
77-
have m_le_f_x : ∀ x ∈ uIcc a b, m ≤ f x := by
78-
simpa
79-
have f_x_le_M : ∀ x ∈ uIcc a b, f x ≤ M := by
80-
simpa
81-
have f_g_int_μ_a_b : IntervalIntegrable (fun x ↦ f x * g x) μ a b := by
82-
exact IntervalIntegrable.continuousOn_mul hg hf
83-
have m_g_int_μ_a_b : IntervalIntegrable (fun x ↦ m * g x) μ a b := by
84-
unfold m
85-
exact hg.const_mul m
86-
have M_g_int_μ_a_b : IntervalIntegrable (fun x ↦ M * g x) μ a b := by
87-
unfold M
88-
exact hg.const_mul M
89-
have ae_left_uIcc : ∀ᵐ x ∂(μ.restrict (uIcc a b)), m * g x ≤ f x * g x := by
90-
rw [ae_restrict_iff' measurableSet_uIcc]
91-
have hg0' : ∀ᵐ x ∂μ, x ∈ uIcc a b → 0 ≤ g x := by
92-
rwa [← ae_restrict_iff' measurableSet_uIcc]
93-
have m_le_f_x_ae : ∀ᵐ x ∂μ, x ∈ uIcc a b → m ≤ f x := by
94-
apply Eventually.of_forall
95-
exact fun x a ↦ f_min a
96-
filter_upwards [m_le_f_x_ae, hg0'] with x h_m_le_f_x g_x_nonneg
97-
exact fun a ↦ mul_le_mul_of_nonneg_right (f_min a) (g_x_nonneg a)
98-
have ae_right_uIcc : ∀ᵐ x ∂(μ.restrict (uIcc a b)), f x * g x ≤ M * g x := by
99-
rw [ae_restrict_iff' measurableSet_uIcc]
100-
have hg0' : ∀ᵐ x ∂μ, x ∈ uIcc a b → 0 ≤ g x := by
101-
rwa [← ae_restrict_iff' measurableSet_uIcc]
102-
have m_le_f_x_ae : ∀ᵐ x ∂μ, x ∈ uIcc a b → m ≤ f x := by
103-
apply Eventually.of_forall
104-
exact fun x a ↦ f_min a
105-
filter_upwards [m_le_f_x_ae, hg0'] with x h_m_le_f_x g_x_nonneg
106-
exact fun a ↦ mul_le_mul_of_nonneg_right (f_max a) (g_x_nonneg a)
107-
have ae_left_Icc : ∀ᵐ x ∂(μ.restrict (Icc a b)), m * g x ≤ f x * g x := by
108-
simpa [a_b_case] using ae_left_uIcc
109-
have ae_right_Icc : ∀ᵐ x ∂(μ.restrict (Icc a b)), f x * g x ≤ M * g x := by
110-
simpa [a_b_case] using ae_right_uIcc
111-
have int_f_g_bounds :
112-
m * (∫ x in a..b, g x ∂μ) ≤ (∫ x in a..b, f x * g x ∂μ)
113-
∧ (∫ x in a..b, f x * g x ∂μ) ≤ M * (∫ x in a..b, g x ∂μ) := by
114-
constructor
115-
· calc
116-
_ = (∫ x in a..b, m * g x ∂μ) := by
117-
simp
118-
_ ≤ (∫ x in a..b, f x * g x ∂μ) := by
119-
exact integral_mono_ae_restrict a_b_case m_g_int_μ_a_b f_g_int_μ_a_b ae_left_Icc
120-
· calc
121-
_ ≤ (∫ x in a..b, M * g x ∂μ) := by
122-
exact integral_mono_ae_restrict a_b_case f_g_int_μ_a_b M_g_int_μ_a_b ae_right_Icc
123-
_ = M * (∫ x in a..b, g x ∂μ) := by simp
124-
by_cases int_g_case : (∫ x in a..b, g x ∂μ) = 0
125-
· refine ⟨x_f_min, x_f_min_in_uIcc_a_b, ?_⟩
126-
have : 0 ≤ (∫ x in a..b, f x * g x ∂μ) ∧ (∫ x in a..b, f x * g x ∂μ) ≤ 0 := by
127-
simpa [int_g_case] using int_f_g_bounds
128-
have int_f_g_eq_zero : (∫ x in a..b, f x * g x ∂μ) = 0 := by
129-
exact le_antisymm this.2 this.1
130-
simp [int_g_case, int_f_g_eq_zero]
131-
· let r := (∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ)
132-
have g_nonneg_Icc_a_b_ae : ∀ᵐ x ∂(μ.restrict (Icc a b)), 0 ≤ g x := by
133-
simpa [a_b_case] using hg0
134-
have int_g_nonneg : 0 ≤ ∫ x in a..b, g x ∂μ := by
135-
exact integral_nonneg_of_ae_restrict a_b_case g_nonneg_Icc_a_b_ae
136-
have int_g_pos : 0 < ∫ x in a..b, g x ∂μ := by
137-
have int_g_neq_zero : (∫ x in a..b, g x ∂μ) ≠ 0 := by
138-
exact int_g_case
139-
exact lt_of_le_of_ne int_g_nonneg int_g_neq_zero.symm
140-
have m_le_r : m ≤ r := by
141-
have left_bound :
142-
m ≤ (∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ) := by
143-
simpa [le_div_iff₀ int_g_pos] using int_f_g_bounds.1
144-
simpa [r] using left_bound
145-
have r_le_M : r ≤ M := by
146-
have right_bound :
147-
(∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ) ≤ M := by
148-
simpa [div_le_iff₀ int_g_pos] using int_f_g_bounds.2
149-
simpa [r] using right_bound
150-
have r_in_Icc_m_M : r ∈ Icc m M := ⟨m_le_r, r_le_M⟩
151-
have ivt :
152-
uIcc (f x_f_min) (f x_f_max) ⊆ f '' uIcc x_f_min x_f_max := by
153-
have f_cont_uIcc_x_f_min_x_f_max :
154-
uIcc x_f_min x_f_max ⊆ uIcc a b := by
155-
intro x hx
156-
have hx' : min x_f_min x_f_max ≤ x ∧ x ≤ max x_f_min x_f_max := by
157-
simpa [uIcc] using hx
158-
have a_b_le_min : min a b ≤ min x_f_min x_f_max :=
159-
le_min x_f_min_in_uIcc_a_b.1 x_f_max_in_uIcc_a_b.1
160-
have max_le_a_b : max x_f_min x_f_max ≤ max a b :=
161-
max_le x_f_min_in_uIcc_a_b.2 x_f_max_in_uIcc_a_b.2
162-
exact ⟨a_b_le_min.trans hx'.1, hx'.2.trans max_le_a_b⟩
54+
this (a := b) (b := a) (by rwa [uIcc_comm]) hg.symm (by rwa [uIoc_comm]) hle.le
55+
refine ⟨c, by rwa [uIcc_comm], by simpa [integral_symm b a]⟩
56+
let s := uIoc a b
57+
have hs : s = Ioc a b := uIoc_of_le hle
58+
have hs_meas : MeasurableSet s := measurableSet_uIoc
59+
let ρ := fun x ↦ ENNReal.ofReal (g x)
60+
let ν := μ.withDensity ρ
61+
have hρ_ae : AEMeasurable ρ (μ.restrict s) := by
62+
apply AEMeasurable.ennreal_ofReal
63+
apply AEStronglyMeasurable.aemeasurable
64+
apply IntervalIntegrable.aestronglyMeasurable
65+
simpa [hle]
66+
have hρ_top : ∀ᵐ x ∂ μ.restrict s, ρ x < ⊤ := by simp [ρ]
67+
have h_toReal_ae : (fun x ↦ (ρ x).toReal) =ᵐ[μ.restrict s] g := by
68+
apply hg0.mono
69+
intro x hx
70+
simpa [ρ]
71+
have hfg : ∫ x in a..b, f x * g x ∂μ = ∫ x in s, f x ∂ν := by
72+
calc
73+
_ = ∫ x in s, f x * g x ∂μ := by simp [hs, integral_of_le hle]
74+
_ = ∫ x in s, (ρ x).toReal * f x ∂μ := by
75+
apply MeasureTheory.integral_congr_ae
76+
apply h_toReal_ae.mono
16377
intro x hx
164-
apply intermediate_value_uIcc
165-
apply ContinuousOn.mono hf f_cont_uIcc_x_f_min_x_f_max
166-
assumption
167-
rw [subset_image_iff] at ivt
168-
rcases ivt with ⟨u, u_subset_uIcc, f_eq_image_uIcc⟩
169-
have m_le_M : m ≤ M := by
170-
exact f_min x_f_max_in_uIcc_a_b
171-
have r_in_f_image : r ∈ f '' u := by
172-
simpa [m, M, m_le_M, f_eq_image_uIcc] using r_in_Icc_m_M
173-
rw [mem_image] at r_in_f_image
174-
rcases r_in_f_image with ⟨c, c_in_u, f_c_eq_r⟩
175-
have c_in_uIcc : c ∈ uIcc x_f_min x_f_max := by
176-
exact u_subset_uIcc c_in_u
177-
have a_le_x : a ≤ min x_f_min x_f_max := by
178-
apply le_min
179-
· simpa [a_b_case] using x_f_min_in_uIcc_a_b.1
180-
· simpa [a_b_case] using x_f_max_in_uIcc_a_b.1
181-
have x_le_b : max x_f_min x_f_max ≤ b := by
182-
apply max_le
183-
· simpa [a_b_case] using x_f_min_in_uIcc_a_b.2
184-
· simpa [a_b_case] using x_f_max_in_uIcc_a_b.2
185-
have c_in_uIcc_x_f_min_max : c ∈ uIcc x_f_min x_f_max := by
186-
simp [uIcc]
187-
rw [uIcc] at c_in_uIcc
188-
rcases c_in_uIcc with ⟨left, right⟩
189-
constructor
190-
· exact inf_le_iff.mp left
191-
· exact le_sup_iff.mp right
192-
have c_in_uIcc_a_b : c ∈ uIcc a b := by
193-
simp [uIcc]
194-
rw [uIcc] at c_in_uIcc
195-
rcases c_in_uIcc with ⟨left, right⟩
196-
constructor
197-
· left
198-
exact le_trans a_le_x left
199-
· right
200-
exact le_trans right x_le_b
201-
have int_f_g_eq_r_mul_int_g :
202-
(∫ x in a..b, f x * g x ∂μ) = r * (∫ x in a..b, g x ∂μ) := by
203-
have r_eq :
204-
r = (∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ) := by
205-
simp [r]
206-
rw [r_eq]
78+
simp [hx, mul_comm]
79+
_ = _ := by
80+
have h := setIntegral_withDensity_eq_setIntegral_toReal_smul₀
81+
hρ_ae hρ_top f hs_meas
82+
simp [ν, h]
83+
have hg1 : ∫ x in a..b, g x ∂μ = ∫ x in s, (1 : ℝ) ∂ν := by
84+
have h := setIntegral_withDensity_eq_setIntegral_toReal_smul₀
85+
hρ_ae hρ_top (fun _ ↦ (1 : ℝ)) hs_meas
86+
calc
87+
_ = ∫ x in s, g x ∂μ := by simp [hs, integral_of_le hle]
88+
_ = ∫ x in s, (ρ x).toReal ∂μ := by rw [integral_congr_ae h_toReal_ae]
89+
_ = _ := by simp [ν, h]
90+
by_cases hzero : ∫ x in s, (1 : ℝ) ∂ν = 0
91+
· refine ⟨a, by simp, ?_⟩
92+
calc
93+
_ = ∫ x in s, f x ∂ν := hfg
94+
_ = 0 := by
95+
rw [hzero, integral_eq_zero_iff_of_le_of_nonneg_ae
96+
hle (by rwa [← uIoc_of_le hle]) hg, ← uIoc_of_le hle] at hg1
97+
have hfg_zero : ∫ x in a..b, f x * g x ∂μ = 0 := by
98+
have hfg_ae : (fun x ↦ f x * g x) =ᵐ[μ.restrict s] 0 := by
99+
apply hg1.mono
100+
intro x hx
101+
simp [hx]
102+
simp [integral_congr_ae_restrict hfg_ae]
103+
rw [← hfg, hfg_zero]
104+
_ = _ := by simp [hzero, hg1]
105+
· have hzero' : (ν s).toReal ≠ 0 := by simpa using hzero
106+
have hνfin : ν s ≠ ⊤ := by
107+
intro this
108+
apply hzero'
109+
simp [this]
110+
have0 : ν s ≠ 0 := by
111+
intro this
112+
apply hzero'
113+
simp [this]
114+
obtain ⟨c, hc, havg⟩ := exists_eq_interval_average_of_measure
115+
hf hνfin hν0
116+
refine ⟨c, hc, ?_⟩
117+
calc
118+
_ = ∫ x in s, f x ∂ν := hfg
119+
_ = f c * ∫ x in s, (1 : ℝ) ∂ν := by
120+
rw [havg]
121+
refold_let s
122+
simp [setAverage_eq]
123+
rw [measureReal_def]
124+
have hreal0 : (ν s).toReal ≠ 0 := ENNReal.toReal_ne_zero.mpr ⟨hν0, hνfin⟩
207125
field_simp
208-
refine ⟨c, c_in_uIcc_a_b, ?_⟩
209-
simpa [f_c_eq_r]
126+
_ = _ := by simp [hg1]
210127

211128
/-- **First mean value theorem for integrals (interval integral).**
212-
Let `f g : ℝ → ℝ` be continuous on `uIcc a b`. If `g ≥ 0` on `uIcc a b`,
129+
Let `f g : ℝ → ℝ` be continuous on `uIcc a b`. If `g ≥ 0` on `uIoc a b`,
213130
then there exists `c ∈ uIcc a b` such that
214131
`∫ x in a..b, f x * g x = f c * ∫ x in a..b, g x`. -/
215-
theorem exists_eq_const_mul_interval_integral_of_continuous_on_of_nonneg
132+
theorem exists_eq_const_mul_integral_of_nonneg
216133
{a b : ℝ} {f g : ℝ → ℝ}
217134
(hf : ContinuousOn f (uIcc a b))
218135
(hg : ContinuousOn g (uIcc a b))
219-
(hg0 : ∀ x ∈ uIcc a b, 0 ≤ g x) :
136+
(hg0 : ∀ x ∈ uIoc a b, 0 ≤ g x) :
220137
∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x) = f c * (∫ x in a..b, g x) := by
221-
have hg0_ae : ∀ᵐ x ∂(volume.restrict (uIcc a b)), 0 ≤ g x := by
222-
rw [ae_restrict_iff' measurableSet_uIcc]
138+
have hg0_ae : ∀ᵐ x ∂(volume.restrict (uIoc a b)), 0 ≤ g x := by
139+
rw [ae_restrict_iff' measurableSet_uIoc]
223140
exact ae_of_all volume hg0
224-
exact exists_eq_const_mul_interval_integral_of_continuous_on_of_ae_nonneg
141+
exact exists_eq_const_mul_integral_of_ae_nonneg
225142
hf hg.intervalIntegrable hg0_ae

0 commit comments

Comments
 (0)