Skip to content

Commit 6a56042

Browse files
committed
refactor(MeasureTheory/Integral/IntervalAverage): strengthen exists_eq_..._noAtoms; golf exists_eq_..._measure and exists_eq_..._noAtoms
1 parent 84335ba commit 6a56042

1 file changed

Lines changed: 40 additions & 72 deletions

File tree

Mathlib/MeasureTheory/Integral/IntervalAverage.lean

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

8-
public import Mathlib.MeasureTheory.Integral.Average.MeanValue
8+
public import Mathlib.MeasureTheory.Integral.Average
99
public import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic
1010

1111
/-!
@@ -18,7 +18,7 @@ formulas for this average:
1818
* `interval_average_eq`: `⨍ x in a..b, f x = (b - a)⁻¹ • ∫ x in a..b, f x`;
1919
* `interval_average_eq_div`: `⨍ x in a..b, f x = (∫ x in a..b, f x) / (b - a)`;
2020
* `exists_eq_interval_average_of_measure`:
21-
`∃ c ∈ uIcc a b, f c = ⨍ x in (Ι a b), f x ∂μ`.
21+
`∃ c ∈ Ι a b, f c = ⨍ x in (Ι a b), f x ∂μ`.
2222
* `exists_eq_interval_average_of_noAtoms`:
2323
`∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ`.
2424
* `exists_eq_interval_average`:
@@ -35,7 +35,7 @@ We also prove that `⨍ x in a..b, f x = ⨍ x in b..a, f x`, see `interval_aver
3535
@[expose] public section
3636

3737

38-
open MeasureTheory Set
38+
open MeasureTheory Set intervalIntegral
3939

4040
open scoped Interval
4141

@@ -52,10 +52,9 @@ theorem interval_average_symm (f : ℝ → E) (a b : ℝ) : (⨍ x in a..b, f x)
5252
theorem interval_average_eq (f : ℝ → E) (a b : ℝ) :
5353
(⨍ x in a..b, f x) = (b - a)⁻¹ • ∫ x in a..b, f x := by
5454
rcases le_or_gt a b with h | h
55-
· rw [setAverage_eq, uIoc_of_le h, Real.volume_real_Ioc_of_le h,
56-
intervalIntegral.integral_of_le h]
57-
· rw [setAverage_eq, uIoc_of_ge h.le, Real.volume_real_Ioc_of_le h.le,
58-
intervalIntegral.integral_of_ge h.le, smul_neg, ← neg_smul, ← inv_neg, neg_sub]
55+
· rw [setAverage_eq, uIoc_of_le h, Real.volume_real_Ioc_of_le h, integral_of_le h]
56+
· rw [setAverage_eq, uIoc_of_ge h.le, Real.volume_real_Ioc_of_le h.le, integral_of_ge h.le,
57+
smul_neg, ← neg_smul, ← inv_neg, neg_sub]
5958

6059
theorem interval_average_eq_div (f : ℝ → ℝ) (a b : ℝ) :
6160
(⨍ x in a..b, f x) = (∫ x in a..b, f x) / (b - a) := by
@@ -65,35 +64,28 @@ theorem interval_average_eq_div (f : ℝ → ℝ) (a b : ℝ) :
6564
theorem intervalAverage_congr_codiscreteWithin {a b : ℝ} {f₁ f₂ : ℝ → ℝ}
6665
(hf : f₁ =ᶠ[Filter.codiscreteWithin (Ι a b)] f₂) :
6766
⨍ (x : ℝ) in a..b, f₁ x = ⨍ (x : ℝ) in a..b, f₂ x := by
68-
rw [interval_average_eq, intervalIntegral.integral_congr_codiscreteWithin hf,
69-
← interval_average_eq]
67+
rw [interval_average_eq, integral_congr_codiscreteWithin hf, ← interval_average_eq]
7068

7169
variable {f : ℝ → ℝ} {a b : ℝ} {μ : Measure ℝ}
7270

7371
/-- If `f : ℝ → ℝ` is continuous on `uIcc a b`, the interval has finite and nonzero `μ`-measure,
74-
then there exists `c ∈ uIcc a b` such that
75-
`f c = ⨍ x in (Ι a b), f x ∂μ`. -/
72+
then `∃ c ∈ Ι a b, f c = ⨍ x in (Ι a b), f x ∂μ`. -/
7673
theorem exists_eq_interval_average_of_measure
77-
(hf : ContinuousOn f (uIcc a b))
78-
(hμfin : μ (Ι a b) ≠ ⊤)
79-
(hμ0 : μ (Ι a b) ≠ 0) :
80-
∃ c ∈ uIcc a b, f c = ⨍ x in (Ι a b), f x ∂μ := by
74+
(hf : ContinuousOn f (uIcc a b)) (hμfin : μ (Ι a b) ≠ ⊤) (hμ0 : μ (Ι a b) ≠ 0) :
75+
∃ c ∈ Ι a b, f c = ⨍ x in (Ι a b), f x ∂μ := by
8176
wlog h : a ≤ b generalizing a b
8277
· simp at h
83-
specialize this
84-
(a := b) (b := a) (by rwa [uIcc_comm])
85-
(by rwa [uIoc_comm]) (by rwa [uIoc_comm])
86-
(h.le)
87-
rcases this with ⟨c, hc, hEq⟩
88-
refine ⟨c, by rwa [uIcc_comm], by rwa [uIoc_comm]⟩
78+
specialize this (by rwa [uIcc_comm]) (by rwa [uIoc_comm]) (by rwa [uIoc_comm]) h.le
79+
rcases this with ⟨c, hc, heq⟩
80+
refine ⟨c, by rwa [uIoc_comm], by rwa [uIoc_comm]⟩
8981
have hint : IntegrableOn f (Ι a b) μ := by
9082
have hsubset : Ι a b ⊆ uIcc a b := uIoc_subset_uIcc
9183
have hcomp : IsCompact (uIcc a b) := isCompact_uIcc
92-
obtain ⟨c, hc, hmax⟩ := hcomp.exists_isMaxOn nonempty_uIcc (hf.norm)
84+
obtain ⟨c, hc, hmax⟩ := hcomp.exists_isMaxOn nonempty_uIcc hf.norm
9385
apply IntegrableOn.of_bound ?_ ?_ (|f c|) ?_
9486
· rwa [lt_top_iff_ne_top]
9587
· apply ContinuousOn.aestronglyMeasurable
96-
· exact ContinuousOn.mono hf hsubset
88+
· exact hf.mono hsubset
9789
· exact measurableSet_uIoc
9890
· rw [ae_restrict_iff' measurableSet_uIoc]
9991
apply ae_of_all
@@ -102,81 +94,57 @@ theorem exists_eq_interval_average_of_measure
10294
exact hsubset hm
10395
have hs_prec : IsPreconnected (Ι a b) := by simpa [h] using isPreconnected_Ioc
10496
have hs_nemp : (Ι a b).Nonempty := by exact nonempty_of_measure_ne_zero hμ0
105-
rcases exists_eq_setAverage
106-
⟨hs_nemp, hs_prec⟩ (hf.mono uIoc_subset_uIcc) hint hμfin hμ0 with ⟨c, hc, hfc⟩
107-
exact ⟨c, uIoc_subset_uIcc hc, hfc⟩
97+
exact exists_eq_setAverage ⟨hs_nemp, hs_prec⟩ (hf.mono uIoc_subset_uIcc) hint hμfin hμ0
10898

10999
/-- If `f : ℝ → ℝ` is continuous on `uIcc a b`, the interval has finite and nonzero `μ`-measure,
110-
and `μ` has no atoms, then there exists `c ∈ uIoo a b` such that
111-
`f c = ⨍ x in (Ι a b), f x ∂μ`. -/
100+
and `μ` has no atoms, then `∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ`. -/
112101
theorem exists_eq_interval_average_of_noAtoms
113-
[NoAtoms μ]
114-
(hf : ContinuousOn f (uIcc a b))
115-
(hμfin : μ (Ι a b) ≠ ⊤)
116-
(hμ0 : μ (Ι a b) ≠ 0) :
102+
[NoAtoms μ] (hf : ContinuousOn f (uIcc a b)) (hμfin : μ (Ι a b) ≠ ⊤) (hμ0 : μ (Ι a b) ≠ 0) :
117103
∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ := by
118104
wlog h : a ≤ b generalizing a b
119105
· simp at h
120106
specialize this
121107
(a := b) (b := a) (by rwa [uIcc_comm])
122108
(by rwa [uIoc_comm]) (by rwa [uIoc_comm]) (h.le)
123-
rcases this with ⟨c, hc, hEq
109+
rcases this with ⟨c, hc, heq
124110
refine ⟨c, ?_, ?_⟩
125111
· simpa [uIoo_comm] using hc
126112
· have hswap : Ι a b = Ι b a := uIoc_comm a b
127113
rwa [hswap]
128-
let ave := ⨍ x in (Ι a b), f x ∂μ
129-
let S₁ := {x | x ∈ Ι a b ∧ f x ≤ ave}
130-
let S₂ := {x | x ∈ Ι a b ∧ ave ≤ f x}
131114
have hint : IntegrableOn f (Ι a b) μ := by
132115
have hsubset : Ι a b ⊆ uIcc a b := uIoc_subset_uIcc
133116
have hcomp : IsCompact (uIcc a b) := isCompact_uIcc
134117
obtain ⟨c, hc, hmax⟩ := hcomp.exists_isMaxOn nonempty_uIcc hf.norm
135118
apply IntegrableOn.of_bound ?_ ?_ (|f c|) ?_
136119
· rwa [lt_top_iff_ne_top]
137120
· apply ContinuousOn.aestronglyMeasurable
138-
· exact ContinuousOn.mono hf hsubset
121+
· exact hf.mono hsubset
139122
· exact measurableSet_uIoc
140123
· rw [ae_restrict_iff' measurableSet_uIoc]
141124
apply ae_of_all
142125
intro m hm
143126
apply hmax
144127
exact hsubset hm
145-
have hS₁ : 0 < μ S₁ := measure_le_setAverage_pos hμ0 hμfin hint
146-
have hS₂ : 0 < μ S₂ := measure_setAverage_le_pos hμ0 hμfin hint
147-
have hb0 : μ {b} = 0 := measure_singleton b
148-
have hS₁pos' : 0 < μ (S₁ \ {b}) := by
149-
have hcap0 : μ (S₁ ∩ {b}) = 0 := measure_inter_null_of_null_right S₁ hb0
150-
have : μ (S₁ \ {b}) = μ S₁ := AEDisjoint.measure_diff_left hcap0
151-
grind
152-
have hS₂pos' : 0 < μ (S₂ \ {b}) := by
153-
have hcap0 : μ (S₂ ∩ {b}) = 0 := measure_inter_null_of_null_right S₂ hb0
154-
have : μ (S₂ \ {b}) = μ S₂ := AEDisjoint.measure_diff_left hcap0
155-
grind
156-
have hS₁nonempty : (S₁ \ {b}).Nonempty := nonempty_of_measure_ne_zero hS₁pos'.ne'
157-
have hS₂nonempty : (S₂ \ {b}).Nonempty := nonempty_of_measure_ne_zero hS₂pos'.ne'
158-
rcases hS₁nonempty with ⟨c₁, hc₁⟩
159-
rcases hS₂nonempty with ⟨c₂, hc₂⟩
160-
have hc₁Ioc : c₁ ∈ Ioc a b := by
161-
simpa [h] using (hc₁.1 : c₁ ∈ S₁).1
162-
have hc₂Ioc : c₂ ∈ Ioc a b := by
163-
simpa [h] using (hc₂.1 : c₂ ∈ S₂).1
164-
have h_subset : uIcc c₁ c₂ ⊆ Icc a b := by
165-
intro x hx
166-
rw [mem_uIcc] at hx
167-
grind
168-
have h_ivt : ∃ c ∈ uIcc c₁ c₂, f c = ave := by
169-
apply intermediate_value_uIcc
170-
· refine ContinuousOn.mono hf ?_
171-
rwa [uIcc_of_le h]
172-
· rw [mem_uIcc]
173-
grind
174-
rcases h_ivt with ⟨c, hc_mem, hfc⟩
175-
refine ⟨c, ?_, hfc⟩
176-
rw [mem_uIcc] at hc_mem
177-
apply mem_uIoo_of_lt
178-
· grind
179-
· grind
128+
have h' : a ≠ b := by
129+
intro hab
130+
subst hab
131+
simp at hμ0
132+
have hab : a < b := lt_of_le_of_ne h h'
133+
let s := Ioo a b
134+
have hs_conn : IsConnected s := isConnected_Ioo hab
135+
have hab' : s = uIoo a b := by rw [uIoo_of_le h]
136+
have hs : s ⊆ [[a, b]] := by simpa [hab'] using uIoo_subset_uIcc_self
137+
have hf' : ContinuousOn f s := hf.mono hs
138+
have hs' : s ⊆ Ι a b := by simpa [uIoc_of_le h] using Ioo_subset_Ioc_self
139+
have hint' : IntegrableOn f s μ := hint.mono_set hs'
140+
have hμfin' : μ s ≠ ⊤ := measure_ne_top_of_subset hs' hμfin
141+
have0' : μ s ≠ 0 := by
142+
have hμ : μ s = μ (Ι a b) := by rw [uIoc_of_le h, measure_congr Ioo_ae_eq_Ioc]
143+
rwa [hμ]
144+
obtain ⟨c, hc, heq⟩ := exists_eq_setAverage hs_conn hf' hint' hμfin' hμ0'
145+
refine ⟨c, by rwa [uIoo_of_le h], ?_⟩
146+
have hs_ev : s =ᵐ[μ] Ι a b := by simpa [uIoc_of_le h] using Ioo_ae_eq_Ioc
147+
rwa [← setAverage_congr hs_ev]
180148

181149
/-- The mean value theorem for integrals:
182150
There exists a point in an interval such that the mean of a continuous function over the interval

0 commit comments

Comments
 (0)