Skip to content

Commit 8f2af85

Browse files
committed
refactor(MeasureTheory/Integral/IntervalAverage): prove interval average theorems from set average; rename of_noAtoms
1 parent 28bc532 commit 8f2af85

1 file changed

Lines changed: 35 additions & 55 deletions

File tree

Mathlib/MeasureTheory/Integral/IntervalAverage.lean

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

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

1111
/-!
1212
# Integral average over an interval
@@ -17,9 +17,12 @@ formulas for this average:
1717
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)`;
20-
* `exists_eq_interval_average_of_measure`: `∃ c, f c = ⨍ x in (uIoc a b), f x ∂μ`.
21-
* `exists_eq_interval_average_of_NoAtoms`: `∃ c, f c = ⨍ x in (uIoc a b), f x ∂μ`.
22-
* `exists_eq_interval_average`: `∃ c, f c = ⨍ (x : ℝ) in a..b, f x`.
20+
* `exists_eq_interval_average_of_measure`:
21+
`∃ c ∈ uIcc a b, f c = ⨍ x in (Ι a b), f x ∂μ`.
22+
* `exists_eq_interval_average_of_noAtoms`:
23+
`∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ`.
24+
* `exists_eq_interval_average`:
25+
`∃ c ∈ uIoo a b, f c = ⨍ (x : ℝ) in a..b, f x`.
2326
2427
We also prove that `⨍ x in a..b, f x = ⨍ x in b..a, f x`, see `interval_average_symm`.
2528
@@ -32,7 +35,7 @@ We also prove that `⨍ x in a..b, f x = ⨍ x in b..a, f x`, see `interval_aver
3235
@[expose] public section
3336

3437

35-
open MeasureTheory Set TopologicalSpace
38+
open MeasureTheory Set
3639

3740
open scoped Interval
3841

@@ -41,7 +44,7 @@ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
4144
/-- `⨍ x in a..b, f x` is the average of `f` over the interval `Ι a b` w.r.t. the Lebesgue
4245
measure. -/
4346
notation3 "⨍ "(...)" in "a".."b",
44-
"r:60:(scoped f => average (Measure.restrict volume (uIoc a b)) f) => r
47+
"r:60:(scoped f => average (Measure.restrict volume (Ι a b)) f) => r
4548

4649
theorem interval_average_symm (f : ℝ → E) (a b : ℝ) : (⨍ x in a..b, f x) = ⨍ x in b..a, f x := by
4750
rw [setAverage_eq, setAverage_eq, uIoc_comm]
@@ -65,15 +68,16 @@ theorem intervalAverage_congr_codiscreteWithin {a b : ℝ} {f₁ f₂ : ℝ →
6568
rw [interval_average_eq, intervalIntegral.integral_congr_codiscreteWithin hf,
6669
← interval_average_eq]
6770

71+
variable {f : ℝ → ℝ} {a b : ℝ} {μ : Measure ℝ}
72+
6873
/-- If `f : ℝ → ℝ` is continuous on `uIcc a b`, the interval has finite and nonzero `μ`-measure,
6974
then there exists `c ∈ uIcc a b` such that
70-
`f c = ⨍ x in (uIoc a b), f x ∂μ`. -/
75+
`f c = ⨍ x in (Ι a b), f x ∂μ`. -/
7176
theorem exists_eq_interval_average_of_measure
72-
{f : ℝ → ℝ} {a b : ℝ} {μ : Measure ℝ}
7377
(hf : ContinuousOn f (uIcc a b))
74-
(hμfin : μ (uIoc a b) ≠ ⊤)
75-
(hμ0 : μ (uIoc a b) ≠ 0) :
76-
∃ c ∈ uIcc a b, f c = ⨍ x in (uIoc a b), f x ∂μ := by
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
7781
wlog h : a ≤ b generalizing a b
7882
· simp at h
7983
specialize this
@@ -82,11 +86,8 @@ theorem exists_eq_interval_average_of_measure
8286
(h.le)
8387
rcases this with ⟨c, hc, hEq⟩
8488
refine ⟨c, by rwa [uIcc_comm], by rwa [uIoc_comm]⟩
85-
let ave := average (μ.restrict (uIoc a b)) f
86-
let S₁ := {x | x ∈ uIoc a b ∧ f x ≤ ave}
87-
let S₂ := {x | x ∈ uIoc a b ∧ ave ≤ f x}
88-
have hint : IntegrableOn f (uIoc a b) μ := by
89-
have hsubset : uIoc a b ⊆ uIcc a b := uIoc_subset_uIcc
89+
have hint : IntegrableOn f (Ι a b) μ := by
90+
have hsubset : Ι a b ⊆ uIcc a b := uIoc_subset_uIcc
9091
have hcomp : IsCompact (uIcc a b) := isCompact_uIcc
9192
obtain ⟨c, hc, hmax⟩ := hcomp.exists_isMaxOn nonempty_uIcc (hf.norm)
9293
apply IntegrableOn.of_bound ?_ ?_ (|f c|) ?_
@@ -99,42 +100,21 @@ theorem exists_eq_interval_average_of_measure
99100
intro m hm
100101
apply hmax
101102
exact hsubset hm
102-
have hS₁ : 0 < μ S₁ := measure_le_setAverage_pos hμ0 hμfin hint
103-
have hS₂ : 0 < μ S₂ := measure_setAverage_le_pos hμ0 hμfin hint
104-
have hS₁nonempty : S₁.Nonempty := nonempty_of_measure_ne_zero hS₁.ne'
105-
have hS₂nonempty : S₂.Nonempty := nonempty_of_measure_ne_zero hS₂.ne'
106-
rw [nonempty_def] at *
107-
rcases hS₁nonempty with ⟨c₁, hc₁⟩
108-
rcases hS₂nonempty with ⟨c₂, hc₂⟩
109-
have hc₁Ioc : c₁ ∈ Ioc a b := by
110-
simpa [h] using hc₁.1
111-
have hc₂Ioc : c₂ ∈ Ioc a b := by
112-
simpa [h] using hc₂.1
113-
have h_subset : uIcc c₁ c₂ ⊆ Icc a b := by
114-
intro x hx
115-
rw [mem_uIcc] at hx
116-
grind
117-
have h_ivt : ∃ c ∈ uIcc c₁ c₂, f c = ave := by
118-
apply intermediate_value_uIcc
119-
· refine ContinuousOn.mono hf ?_
120-
rwa [uIcc_of_le h]
121-
· rw [mem_uIcc]
122-
grind
123-
rcases h_ivt with ⟨c, hc_mem, hfc⟩
124-
refine ⟨c, ?_, hfc⟩
125-
rw [mem_uIcc]
126-
grind
103+
have hs_prec : IsPreconnected (Ι a b) := by simpa [h] using isPreconnected_Ioc
104+
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⟩
127108

128109
/-- If `f : ℝ → ℝ` is continuous on `uIcc a b`, the interval has finite and nonzero `μ`-measure,
129110
and `μ` has no atoms, then there exists `c ∈ uIoo a b` such that
130-
`f c = ⨍ x in (uIoc a b), f x ∂μ`. -/
131-
theorem exists_eq_interval_average_of_NoAtoms
132-
{f : ℝ → ℝ} {a b : ℝ}
133-
{μ : Measure ℝ} [NoAtoms μ]
111+
`f c = ⨍ x in (Ι a b), f x ∂μ`. -/
112+
theorem exists_eq_interval_average_of_noAtoms
113+
[NoAtoms μ]
134114
(hf : ContinuousOn f (uIcc a b))
135-
(hμfin : μ (uIoc a b) ≠ ⊤)
136-
(hμ0 : μ (uIoc a b) ≠ 0) :
137-
∃ c ∈ uIoo a b, f c = ⨍ x in (uIoc a b), f x ∂μ := by
115+
(hμfin : μ (Ι a b) ≠ ⊤)
116+
(hμ0 : μ (Ι a b) ≠ 0) :
117+
∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ := by
138118
wlog h : a ≤ b generalizing a b
139119
· simp at h
140120
specialize this
@@ -145,11 +125,11 @@ theorem exists_eq_interval_average_of_NoAtoms
145125
· simpa [uIoo_comm] using hc
146126
· have hswap : Ι a b = Ι b a := uIoc_comm a b
147127
rwa [hswap]
148-
let ave := average (μ.restrict (uIoc a b)) f
149-
let S₁ := {x | x ∈ uIoc a b ∧ f x ≤ ave}
150-
let S₂ := {x | x ∈ uIoc a b ∧ ave ≤ f x}
151-
have hint : IntegrableOn f (uIoc a b) μ := by
152-
have hsubset : uIoc a b ⊆ uIcc a b := uIoc_subset_uIcc
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}
131+
have hint : IntegrableOn f (Ι a b) μ := by
132+
have hsubset : Ι a b ⊆ uIcc a b := uIoc_subset_uIcc
153133
have hcomp : IsCompact (uIcc a b) := isCompact_uIcc
154134
obtain ⟨c, hc, hmax⟩ := hcomp.exists_isMaxOn nonempty_uIcc hf.norm
155135
apply IntegrableOn.of_bound ?_ ?_ (|f c|) ?_
@@ -202,14 +182,14 @@ theorem exists_eq_interval_average_of_NoAtoms
202182
There exists a point in an interval such that the mean of a continuous function over the interval
203183
equals the value of the function at the point. -/
204184
theorem exists_eq_interval_average
205-
{f : ℝ → ℝ} {a b : ℝ} (hab : a ≠ b) (hf : ContinuousOn f (uIcc a b)) :
185+
(hab : a ≠ b) (hf : ContinuousOn f (uIcc a b)) :
206186
∃ c ∈ uIoo a b, f c = ⨍ (x : ℝ) in a..b, f x := by
207187
wlog hle : a ≤ b generalizing a b
208188
· rw [uIoo_comm, uIoc_comm]
209189
apply this hab.symm ?_ (by grind)
210190
rwa [uIcc_comm]
211191
have : Ι a b = Ioc a b := uIoc_of_le hle
212-
apply exists_eq_interval_average_of_NoAtoms hf
192+
apply exists_eq_interval_average_of_noAtoms hf
213193
· simp [this]
214194
· apply ne_of_gt
215195
rw [this, Real.volume_Ioc, ENNReal.ofReal_pos]

0 commit comments

Comments
 (0)