Skip to content

Commit 96aef68

Browse files
committed
refactor(MeasureTheory/Integral/IntervalAverage): golf exists_eq_interval_average via exists_eq_interval_average_of_NoAtoms
1 parent 63657dc commit 96aef68

1 file changed

Lines changed: 18 additions & 48 deletions

File tree

Mathlib/MeasureTheory/Integral/IntervalAverage.lean

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ 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`: `∃ c, f c = ⨍ (x : ℝ) in a..b, f x`.
2120
* `exists_eq_interval_average_of_measure`: `∃ c, f c = ⨍ x in (uIoc a b), f x ∂μ`.
2221
* `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`.
2323
2424
We also prove that `⨍ x in a..b, f x = ⨍ x in b..a, f x`, see `interval_average_symm`.
2525
@@ -65,53 +65,6 @@ theorem intervalAverage_congr_codiscreteWithin {a b : ℝ} {f₁ f₂ : ℝ →
6565
rw [interval_average_eq, intervalIntegral.integral_congr_codiscreteWithin hf,
6666
← interval_average_eq]
6767

68-
/-- The mean value theorem for integrals:
69-
There exists a point in an interval such that the mean of a continuous function over the interval
70-
equals the value of the function at the point. -/
71-
theorem exists_eq_interval_average
72-
{f : ℝ → ℝ} {a b : ℝ} (hab : a ≠ b) (hf : ContinuousOn f (uIcc a b)) :
73-
∃ c ∈ uIoo a b, f c = ⨍ (x : ℝ) in a..b, f x := by
74-
wlog h : a < b generalizing a b
75-
· rw [uIcc_comm] at hf
76-
have := this hab.symm hf (lt_of_le_of_ne (le_of_not_gt h) (Ne.symm hab))
77-
rwa [uIoo_comm, interval_average_symm] at this
78-
let ave := ⨍ (x : ℝ) in a..b, f x
79-
have h_vol_fin1 : volume (uIoc a b) ≠ 0 := by simpa [h.le] using h
80-
have h_vol_fin2 : volume (uIoc a b) ≠ ⊤ := by simp [h.le]
81-
have h_intble : IntegrableOn f (uIoc a b) := by
82-
have : IntegrableOn f (uIcc a b) := hf.integrableOn_uIcc
83-
rwa [uIcc_of_lt h,integrableOn_Icc_iff_integrableOn_Ioc, ←uIoc_of_le (le_of_lt h)] at this
84-
let S1 := {x | x ∈ uIoc a b ∧ f x ≤ ave}
85-
let S2 := {x | x ∈ uIoc a b ∧ ave ≤ f x}
86-
have h_meas1 : volume (S1 \ {b}) ≠ 0 := by
87-
rw [measure_diff_null Real.volume_singleton]
88-
exact (measure_le_setAverage_pos h_vol_fin1 h_vol_fin2 h_intble).ne'
89-
have h_meas2 : volume (S2 \ {b}) ≠ 0 := by
90-
rw [measure_diff_null Real.volume_singleton]
91-
exact (measure_setAverage_le_pos h_vol_fin1 h_vol_fin2 h_intble).ne'
92-
obtain ⟨c1, ⟨hc1_mem, hc1_le⟩, hc1'⟩ := nonempty_of_measure_ne_zero h_meas1
93-
have hc1' : c1 ∈ Ioo a b := by
94-
rw [Set.uIoc_of_le (le_of_lt h)] at hc1_mem
95-
rw [notMem_singleton_iff] at hc1'
96-
exact ⟨hc1_mem.1, lt_of_le_of_ne hc1_mem.2 hc1'⟩
97-
obtain ⟨c2, ⟨hc2_mem, hc2_ge⟩, hc2'⟩ := nonempty_of_measure_ne_zero h_meas2
98-
have hc2' : c2 ∈ Ioo a b := by
99-
rw [Set.uIoc_of_le (le_of_lt h)] at hc2_mem
100-
rw [notMem_singleton_iff] at hc2'
101-
exact ⟨hc2_mem.1, lt_of_le_of_ne hc2_mem.2 hc2'⟩
102-
have h_interval : uIcc c1 c2 ⊆ uIoo a b := by
103-
rw [uIoo_of_lt h]
104-
intro x hx
105-
rw [mem_uIcc] at hx
106-
simp only [mem_Ioo]
107-
rcases hx with h1 | h2
108-
· exact ⟨lt_of_lt_of_le hc1'.1 h1.1, lt_of_le_of_lt h1.2 hc2'.2
109-
· exact ⟨lt_of_lt_of_le hc2'.1 h2.1, lt_of_le_of_lt h2.2 hc1'.2
110-
have h_interval' : uIcc c1 c2 ⊆ uIcc a b := fun x hx => Ioo_subset_Icc_self (h_interval hx)
111-
have h_ave : ave ∈ Icc (f c1) (f c2) := ⟨hc1_le,hc2_ge⟩
112-
have h_image := intermediate_value_uIcc (hf.mono h_interval') (Icc_subset_uIcc h_ave)
113-
exact ((mem_image f (uIcc c1 c2) ave).mp (h_image)).imp (fun c hc => ⟨h_interval hc.1, hc.2⟩)
114-
11568
/-- If `f : ℝ → ℝ` is continuous on `uIcc a b`, the interval has finite and nonzero `μ`-measure,
11669
then there exists `c ∈ uIcc a b` such that
11770
`f c = ⨍ x in (uIoc a b), f x ∂μ`. -/
@@ -244,3 +197,20 @@ theorem exists_eq_interval_average_of_NoAtoms
244197
apply mem_uIoo_of_lt
245198
· grind
246199
· grind
200+
201+
/-- The mean value theorem for integrals:
202+
There exists a point in an interval such that the mean of a continuous function over the interval
203+
equals the value of the function at the point. -/
204+
theorem exists_eq_interval_average
205+
{f : ℝ → ℝ} {a b : ℝ} (hab : a ≠ b) (hf : ContinuousOn f (uIcc a b)) :
206+
∃ c ∈ uIoo a b, f c = ⨍ (x : ℝ) in a..b, f x := by
207+
wlog hle : a ≤ b generalizing a b
208+
· rw [uIoo_comm, uIoc_comm]
209+
apply this hab.symm ?_ (by grind)
210+
rwa [uIcc_comm]
211+
have : Ι a b = Ioc a b := uIoc_of_le hle
212+
apply exists_eq_interval_average_of_NoAtoms hf
213+
· simp [this]
214+
· apply ne_of_gt
215+
rw [this, Real.volume_Ioc, ENNReal.ofReal_pos]
216+
grind

0 commit comments

Comments
 (0)