Skip to content

Commit e067709

Browse files
committed
refactor(MeasureTheory/Integral/IntervalAverage): golf; improve code style consistency
1 parent ecff28c commit e067709

1 file changed

Lines changed: 12 additions & 25 deletions

File tree

Mathlib/MeasureTheory/Integral/IntervalAverage.lean

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ 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 ∈ Ι 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`:
23-
`∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ`.
23+
`∃ c ∈ uIoo a b, f c = ⨍ x in Ι a b, f x ∂μ`.
2424
* `exists_eq_interval_average`:
2525
`∃ c ∈ uIoo a b, f c = ⨍ x in a..b, f x`.
2626
@@ -69,27 +69,24 @@ theorem intervalAverage_congr_codiscreteWithin {a b : ℝ} {f₁ f₂ : ℝ →
6969
variable {f : ℝ → ℝ} {a b : ℝ} {μ : Measure ℝ}
7070

7171
/-- If `f : ℝ → ℝ` is continuous on `uIcc a b`, the interval has finite and nonzero `μ`-measure,
72-
then `∃ c ∈ Ι a b, f c = ⨍ x in (Ι a b), f x ∂μ`. -/
72+
then `∃ c ∈ Ι a b, f c = ⨍ x in Ι a b, f x ∂μ`. -/
7373
theorem exists_eq_interval_average_of_measure
7474
(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
76-
have hint : IntegrableOn f (Ι a b) μ := hf.integrableOn_of_subset_isCompact
77-
isCompact_uIcc measurableSet_uIoc uIoc_subset_uIcc hμfin
78-
have hs_prec : IsPreconnected (Ι a b) := isPreconnected_Ioc
79-
have hs_nemp : (Ι a b).Nonempty := by exact nonempty_of_measure_ne_zero hμ0
80-
exact exists_eq_setAverage ⟨hs_nemp, hs_prec⟩ (hf.mono uIoc_subset_uIcc) hint hμfin hμ0
75+
∃ c ∈ Ι a b, f c = ⨍ x in Ι a b, f x ∂μ :=
76+
exists_eq_setAverage ⟨nonempty_of_measure_ne_zero hμ0, isPreconnected_Ioc⟩
77+
(hf.mono uIoc_subset_uIcc) (hf.integrableOn_of_subset_isCompact
78+
isCompact_uIcc measurableSet_uIoc uIoc_subset_uIcc hμfin) hμfin hμ0
8179

8280
/-- If `f : ℝ → ℝ` is continuous on `uIcc a b`, the interval has finite and nonzero `μ`-measure,
83-
and `μ` has no atoms, then `∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ`. -/
81+
and `μ` has no atoms, then `∃ c ∈ uIoo a b, f c = ⨍ x in Ι a b, f x ∂μ`. -/
8482
theorem exists_eq_interval_average_of_noAtoms
8583
[NoAtoms μ] (hf : ContinuousOn f (uIcc a b)) (hμfin : μ (Ι a b) ≠ ⊤) (hμ0 : μ (Ι a b) ≠ 0) :
86-
∃ c ∈ uIoo a b, f c = ⨍ x in (Ι a b), f x ∂μ := by
84+
∃ c ∈ uIoo a b, f c = ⨍ x in Ι a b, f x ∂μ := by
8785
have hint : IntegrableOn f (Ι a b) μ := hf.integrableOn_of_subset_isCompact
8886
isCompact_uIcc measurableSet_uIoc uIoc_subset_uIcc hμfin
89-
have h : a ≠ b := by intro hab; subst hab; simp at hμ0
87+
have h : a ≠ b := by intro hab; simp [hab] at hμ0
9088
let s := uIoo a b
9189
have hs' : s ⊆ Ι a b := by intro x hx; rcases hx with ⟨h1, h2⟩; grind
92-
have hμfin' : μ s ≠ ⊤ := measure_ne_top_of_subset hs' hμfin
9390
have hs_ev : s =ᵐ[μ] Ι a b := by simpa using Ioo_ae_eq_Ioc
9491
have0' : μ s ≠ 0 := by
9592
have hμ : μ s = μ (Ι a b) := by rw [measure_congr hs_ev]
@@ -103,15 +100,5 @@ There exists a point in an interval such that the mean of a continuous function
103100
equals the value of the function at the point. -/
104101
theorem exists_eq_interval_average
105102
(hab : a ≠ b) (hf : ContinuousOn f (uIcc a b)) :
106-
∃ c ∈ uIoo a b, f c = ⨍ x in a..b, f x := by
107-
apply exists_eq_interval_average_of_noAtoms hf
108-
· apply ne_of_lt
109-
calc
110-
_ ≤ volume [[a, b]] := measure_mono uIoc_subset_uIcc
111-
_ < _ := by simp
112-
· apply ne_of_gt
113-
have h : (uIoo a b) ⊆ (Ι a b) := by intro x hx; rcases hx with ⟨h1, h2⟩; grind
114-
calc
115-
0 < volume (uIoo a b) := by
116-
rwa [Real.volume_uIoo, ENNReal.ofReal_pos, abs_sub_comm, abs_sub_pos]
117-
_ ≤ _ := measure_mono h
103+
∃ c ∈ uIoo a b, f c = ⨍ x in a..b, f x :=
104+
exists_eq_interval_average_of_noAtoms hf (by simp) (by simpa using sub_ne_zero.mpr hab.symm)

0 commit comments

Comments
 (0)