measure_theory.integral.averageMathlib.MeasureTheory.Integral.Average

This file has been ported!

Changes since the initial port

The following section lists changes to this file in mathlib3 and mathlib4 that occured after the initial port. Most recent changes are shown first. Hovering over a commit will show all commits associated with the same mathlib3 commit.

Changes in mathlib3

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(last sync)

feat(measure_theory/integral/average): Lebesgue average (#19199)

Define the Lebesgue integral version of the average of a measurable function and prove the corresponding first moment method.

Diff
@@ -19,6 +19,8 @@ measure, then the average of any function is equal to its integral.
 For the average on a set, we use `⨍ x in s, f x ∂μ` (notation for `⨍ x, f x ∂(μ.restrict s)`). For
 average w.r.t. the volume, one can omit `∂volume`.
 
+Both have a version for the Lebesgue integral rather than Bochner.
+
 We prove several version of the first moment method: An integrable function is below/above its
 average on a set of positive measure.
 
@@ -28,11 +30,6 @@ The average is defined as an integral over `(μ univ)⁻¹ • μ` so that all t
 integrals work for the average without modifications. For theorems that require integrability of a
 function, we provide a convenience lemma `measure_theory.integrable.to_average`.
 
-## TODO
-
-Provide the first moment method for the Lebesgue integral as well. A draft is available on branch
-`first_moment_lintegral`.
-
 ## Tags
 
 integral, center mass, average value
@@ -44,19 +41,174 @@ open_locale topology big_operators ennreal convex
 variables {α E F : Type*} {m0 : measurable_space α}
   [normed_add_comm_group E] [normed_space ℝ E] [complete_space E]
   [normed_add_comm_group F] [normed_space ℝ F] [complete_space F]
-  {μ : measure α} {s t : set α}
+  {μ ν : measure α} {s t : set α}
 
 /-!
 ### Average value of a function w.r.t. a measure
 
-The average value of a function `f` w.r.t. a measure `μ` (notation: `⨍ x, f x ∂μ`) is defined as
-`(μ univ).to_real⁻¹ • ∫ x, f x ∂μ`, so it is equal to zero if `f` is not integrable or if `μ` is an
-infinite measure. If `μ` is a probability measure, then the average of any function is equal to its
-integral.
-
+The (Bochner, Lebesgue) average value of a function `f` w.r.t. a measure `μ` (notation:
+`⨍ x, f x ∂μ`, `⨍⁻ x, f x ∂μ`) is defined as the (Bochner, Lebesgue) integral divided by the total
+measure, so it is equal to zero if `μ` is an infinite measure, and (typically) equal to infinity if
+`f` is not integrable. If `μ` is a probability measure, then the average of any function is equal to
+its integral.
 -/
 
 namespace measure_theory
+section ennreal
+variables (μ) {f g : α → ℝ≥0∞}
+include m0
+
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`, notation: `⨍⁻ x, f x ∂μ`.
+It is defined as `μ univ⁻¹ * ∫⁻ x, f x ∂μ`, so it is equal to zero if `μ` is an infinite measure. If
+`μ` is a probability measure, then the average of any function is equal to its integral.
+
+For the average on a set, use `⨍⁻ x in s, f x ∂μ` (defined as `⨍⁻ x, f x ∂(μ.restrict s)`). For
+average w.r.t. the volume, one can omit `∂volume`. -/
+noncomputable def laverage (f : α → ℝ≥0∞) := ∫⁻ x, f x ∂((μ univ)⁻¹ • μ)
+
+notation `⨍⁻` binders `, ` r:(scoped:60 f, f) ` ∂` μ:70 := laverage μ r
+notation `⨍⁻` binders `, ` r:(scoped:60 f, laverage volume f) := r
+notation `⨍⁻` binders ` in ` s `, ` r:(scoped:60 f, f) ` ∂` μ:70 :=
+  laverage (measure.restrict μ s) r
+notation `⨍⁻` binders ` in ` s `, ` r:(scoped:60 f, laverage (measure.restrict volume s) f) := r
+
+@[simp] lemma laverage_zero : ⨍⁻ x, (0 : ℝ≥0∞) ∂μ = 0 := by rw [laverage, lintegral_zero]
+
+@[simp] lemma laverage_zero_measure (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂(0 : measure α) = 0 :=
+by simp [laverage]
+
+lemma laverage_eq' (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂((μ univ)⁻¹ • μ) := rfl
+
+lemma laverage_eq (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ / μ univ :=
+by rw [laverage_eq', lintegral_smul_measure, ennreal.div_eq_inv_mul]
+
+lemma laverage_eq_lintegral [is_probability_measure μ] (f : α → ℝ≥0∞) :
+  ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ :=
+by rw [laverage, measure_univ, inv_one, one_smul]
+
+@[simp] lemma measure_mul_laverage [is_finite_measure μ] (f : α → ℝ≥0∞) :
+  μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ :=
+begin
+  cases eq_or_ne μ 0 with hμ hμ,
+  { rw [hμ, lintegral_zero_measure, laverage_zero_measure, mul_zero] },
+  { rw [laverage_eq, ennreal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)] }
+end
+
+lemma set_laverage_eq (f : α → ℝ≥0∞) (s : set α) : ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ / μ s :=
+by rw [laverage_eq, restrict_apply_univ]
+
+lemma set_laverage_eq' (f : α → ℝ≥0∞) (s : set α) :
+  ⨍⁻ x in s, f x ∂μ = ∫⁻ x, f x ∂((μ s)⁻¹ • μ.restrict s) :=
+by simp only [laverage_eq', restrict_apply_univ]
+
+variable {μ}
+
+lemma laverage_congr {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ⨍⁻ x, f x ∂μ = ⨍⁻ x, g x ∂μ :=
+by simp only [laverage_eq, lintegral_congr_ae h]
+
+lemma set_laverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ :=
+by simp only [set_laverage_eq, set_lintegral_congr h, measure_congr h]
+
+lemma set_laverage_congr_fun (hs : measurable_set s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+  ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in s, g x ∂μ :=
+by simp only [laverage_eq, set_lintegral_congr_fun hs h]
+
+lemma laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ < ∞ :=
+begin
+  obtain rfl | hμ := eq_or_ne μ 0,
+  { simp },
+  { rw laverage_eq,
+    exact div_lt_top hf (measure_univ_ne_zero.2 hμ) }
+end
+
+lemma set_laverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ := laverage_lt_top
+
+lemma laverage_add_measure :
+  ⨍⁻ x, f x ∂(μ + ν) =
+    μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν :=
+begin
+  by_cases hμ : is_finite_measure μ, swap,
+  { rw not_is_finite_measure_iff at hμ,
+    simp [laverage_eq, hμ] },
+  by_cases hν : is_finite_measure ν, swap,
+  { rw not_is_finite_measure_iff at hν,
+    simp [laverage_eq, hν] },
+  haveI := hμ, haveI := hν,
+  simp only [←ennreal.mul_div_right_comm, measure_mul_laverage, ←ennreal.add_div,
+    ←lintegral_add_measure, ←measure.add_apply, ←laverage_eq],
+end
+
+lemma measure_mul_set_laverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) :
+  μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ :=
+by { haveI := fact.mk h.lt_top, rw [← measure_mul_laverage, restrict_apply_univ] }
+
+lemma laverage_union (hd : ae_disjoint μ s t) (ht : null_measurable_set t μ) :
+  ⨍⁻ x in s ∪ t, f x ∂μ =
+    μ s / (μ s + μ t) * ⨍⁻ x in s, f x ∂μ + μ t / (μ s + μ t) * ⨍⁻ x in t, f x ∂μ :=
+by rw [restrict_union₀ hd ht, laverage_add_measure, restrict_apply_univ, restrict_apply_univ]
+
+lemma laverage_union_mem_open_segment (hd : ae_disjoint μ s t) (ht : null_measurable_set t μ)
+  (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
+  ⨍⁻ x in s ∪ t, f x ∂μ ∈ open_segment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in t, f x ∂μ) :=
+begin
+  refine ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), ennreal.div_pos hs₀ $ add_ne_top.2 ⟨hsμ, htμ⟩,
+    ennreal.div_pos ht₀ $ add_ne_top.2 ⟨hsμ, htμ⟩, _, (laverage_union hd ht).symm⟩,
+  rw [←ennreal.add_div, ennreal.div_self (add_eq_zero.not.2 $ λ h, hs₀ h.1)
+    (add_ne_top.2 ⟨hsμ, htμ⟩)],
+end
+
+lemma laverage_union_mem_segment (hd : ae_disjoint μ s t) (ht : null_measurable_set t μ)
+  (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
+  ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ] :=
+begin
+  by_cases hs₀ : μ s = 0,
+  { rw ← ae_eq_empty at hs₀,
+    rw [restrict_congr_set (hs₀.union eventually_eq.rfl), empty_union],
+    exact right_mem_segment _ _ _ },
+  { refine ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), zero_le _, zero_le _, _,
+      (laverage_union hd ht).symm⟩,
+    rw [←ennreal.add_div, ennreal.div_self (add_eq_zero.not.2 $ λ h, hs₀ h.1)
+      (add_ne_top.2 ⟨hsμ, htμ⟩)] }
+end
+
+lemma laverage_mem_open_segment_compl_self [is_finite_measure μ] (hs : null_measurable_set s μ)
+  (hs₀ : μ s ≠ 0) (hsc₀ : μ sᶜ ≠ 0) :
+  ⨍⁻ x, f x ∂μ ∈ open_segment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in sᶜ, f x ∂μ) :=
+by simpa only [union_compl_self, restrict_univ]
+  using laverage_union_mem_open_segment ae_disjoint_compl_right hs.compl hs₀ hsc₀
+    (measure_ne_top _ _) (measure_ne_top _ _)
+
+@[simp] lemma laverage_const (μ : measure α) [is_finite_measure μ] [h : μ.ae.ne_bot] (c : ℝ≥0∞) :
+  ⨍⁻ x, c ∂μ = c :=
+by simp only [laverage_eq, lintegral_const, measure.restrict_apply, measurable_set.univ, univ_inter,
+  div_eq_mul_inv, mul_assoc, ennreal.mul_inv_cancel, mul_one, measure_ne_top μ univ, ne.def,
+  measure_univ_ne_zero, ae_ne_bot.1 h, not_false_iff]
+
+lemma set_laverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0∞) : ⨍⁻ x in s, c ∂μ = c :=
+by simp only [set_laverage_eq, lintegral_const, measure.restrict_apply, measurable_set.univ,
+  univ_inter, div_eq_mul_inv, mul_assoc, ennreal.mul_inv_cancel hs₀ hs, mul_one]
+
+@[simp] lemma laverage_one [is_finite_measure μ] [h : μ.ae.ne_bot] : ⨍⁻ x, (1 : ℝ≥0∞) ∂μ = 1 :=
+laverage_const _ _
+
+lemma set_laverage_one (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) : ⨍⁻ x in s, (1 : ℝ≥0∞) ∂μ = 1 :=
+set_laverage_const hs₀ hs _
+
+@[simp] lemma lintegral_laverage (μ : measure α) [is_finite_measure μ] (f : α → ℝ≥0∞) :
+  ∫⁻ x, ⨍⁻ a, f a ∂μ ∂μ = ∫⁻ x, f x ∂μ :=
+begin
+  unfreezingI { obtain rfl | hμ := eq_or_ne μ 0 },
+  { simp },
+  { rw [lintegral_const, laverage_eq,
+      ennreal.div_mul_cancel (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)] }
+end
+
+lemma set_lintegral_set_laverage (μ : measure α) [is_finite_measure μ] (f : α → ℝ≥0∞) (s : set α) :
+  ∫⁻ x in s, ⨍⁻ a in s, f a ∂μ ∂μ = ∫⁻ x in s, f x ∂μ :=
+lintegral_laverage _ _
+
+end ennreal
+
 section normed_add_comm_group
 variables (μ) {f g : α → E}
 include m0
@@ -114,9 +266,13 @@ variable {μ}
 lemma average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = ⨍ x, g x ∂μ :=
 by simp only [average_eq, integral_congr_ae h]
 
-lemma set_average_congr_set_ae (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ :=
+lemma set_average_congr (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ :=
 by simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
 
+lemma set_average_congr_fun (hs : measurable_set s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+  ⨍ x in s, f x ∂μ = ⨍ x in s, g x ∂μ :=
+by simp only [average_eq, set_integral_congr_ae hs h]
+
 lemma average_add_measure [is_finite_measure μ] {ν : measure α} [is_finite_measure ν] {f : α → E}
   (hμ : integrable f μ) (hν : integrable f ν) :
   ⨍ x, f x ∂(μ + ν) =
@@ -180,7 +336,7 @@ by simpa only [union_compl_self, restrict_univ]
   using average_union_mem_open_segment ae_disjoint_compl_right hs.compl hs₀ hsc₀
     (measure_ne_top _ _) (measure_ne_top _ _) hfi.integrable_on hfi.integrable_on
 
-@[simp] lemma average_const [is_finite_measure μ] [h : μ.ae.ne_bot] (c : E) :
+@[simp] lemma average_const (μ : measure α) [is_finite_measure μ] [h : μ.ae.ne_bot] (c : E) :
   ⨍ x, c ∂μ = c :=
 by simp only [average_eq, integral_const, measure.restrict_apply, measurable_set.univ, one_smul,
   univ_inter, smul_smul, ← ennreal.to_real_inv, ← ennreal.to_real_mul, ennreal.inv_mul_cancel,
@@ -245,23 +401,23 @@ lemma of_real_set_average {f : α → ℝ} (hf : integrable_on f s μ)
   ennreal.of_real (⨍ x in s, f x ∂μ) = (∫⁻ x in s, ennreal.of_real (f x) ∂μ) / μ s :=
 by simpa using of_real_average hf hf₀
 
-lemma average_to_real {f : α → ℝ≥0∞} (hf : ae_measurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
-  ⨍ x, (f x).to_real ∂μ = (∫⁻ x, f x ∂μ / μ univ).to_real :=
+lemma to_real_laverage {f : α → ℝ≥0∞} (hf : ae_measurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
+  (⨍⁻ x, f x ∂μ).to_real = ⨍ x, (f x).to_real ∂μ :=
 begin
   obtain rfl | hμ := eq_or_ne μ 0,
   { simp },
-  { rw [average_eq, smul_eq_mul, to_real_div,
-      ←integral_to_real hf (hf'.mono $ λ _, lt_top_iff_ne_top.2), div_eq_inv_mul] }
+  { rw [average_eq, laverage_eq, smul_eq_mul, to_real_div, div_eq_inv_mul,
+      ←integral_to_real hf (hf'.mono $ λ _, lt_top_iff_ne_top.2)] }
 end
 
-lemma set_average_to_real {f : α → ℝ≥0∞} (hf : ae_measurable f (μ.restrict s))
+lemma to_real_set_laverage {f : α → ℝ≥0∞} (hf : ae_measurable f (μ.restrict s))
   (hf' : ∀ᵐ x ∂(μ.restrict s), f x ≠ ∞) :
-  ⨍ x in s, (f x).to_real ∂μ = (∫⁻ x in s, f x ∂μ / μ s).to_real :=
-by simpa using average_to_real hf hf'
+  (∫⁻ x in s, f x ∂μ / μ s).to_real = ⨍ x in s, (f x).to_real ∂μ :=
+by simpa [laverage_eq] using to_real_laverage hf hf'
 
 /-! ### First moment method -/
 
-section first_moment
+section first_moment_real
 variables {N : set α} {f : α → ℝ}
 
 /-- **First moment method**. An integrable function is smaller than its mean on a set of positive
@@ -384,5 +540,158 @@ by simpa only [average_eq_integral]
   using exists_not_mem_null_average_le (is_probability_measure.ne_zero μ) hf hN
 
 end probability_measure
-end first_moment
+end first_moment_real
+
+section first_moment_ennreal
+variables {N : set α} {f : α → ℝ≥0∞}
+
+/-- **First moment method**. A measurable function is smaller than its mean on a set of positive
+measure. -/
+lemma measure_le_set_laverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
+  (hf : ae_measurable f (μ.restrict s)) : 0 < μ {x ∈ s | f x ≤ ⨍⁻ a in s, f a ∂μ} :=
+begin
+  obtain h | h := eq_or_ne (∫⁻ a in s, f a ∂μ) ∞,
+  { simpa [mul_top, hμ₁, laverage, h, top_div_of_ne_top hμ₁, pos_iff_ne_zero] using hμ },
+  have := measure_le_set_average_pos hμ hμ₁ (integrable_to_real_of_lintegral_ne_top hf h),
+  rw [←set_of_inter_eq_sep, ←measure.restrict_apply₀
+    (hf.ae_strongly_measurable.null_measurable_set_le ae_strongly_measurable_const)],
+  rw [←set_of_inter_eq_sep, ←measure.restrict_apply₀
+    (hf.ennreal_to_real.ae_strongly_measurable.null_measurable_set_le ae_strongly_measurable_const),
+    ←measure_diff_null (measure_eq_top_of_lintegral_ne_top hf h)] at this,
+  refine this.trans_le (measure_mono _),
+  rintro x ⟨hfx, hx⟩,
+  dsimp at hfx,
+  rwa [←to_real_laverage hf, to_real_le_to_real hx (set_laverage_lt_top h).ne] at hfx,
+  { simp_rw [ae_iff, not_ne_iff],
+    exact measure_eq_top_of_lintegral_ne_top hf h }
+end
+
+/-- **First moment method**. A measurable function is greater than its mean on a set of positive
+measure. -/
+lemma measure_set_laverage_le_pos (hμ : μ s ≠ 0) (hs : null_measurable_set s μ)
+  (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : 0 < μ {x ∈ s | ⨍⁻ a in s, f a ∂μ ≤ f x} :=
+begin
+  obtain hμ₁ | hμ₁ := eq_or_ne (μ s) ∞,
+  { simp [set_laverage_eq, hμ₁] },
+  obtain ⟨g, hg, hgf, hfg⟩ := exists_measurable_le_lintegral_eq (μ.restrict s) f,
+  have hfg' : ⨍⁻ a in s, f a ∂μ = ⨍⁻ a in s, g a ∂μ,
+  { simp_rw [laverage_eq, hfg] },
+  rw hfg at hint,
+  have := measure_set_average_le_pos hμ hμ₁
+    (integrable_to_real_of_lintegral_ne_top hg.ae_measurable hint),
+  simp_rw [←set_of_inter_eq_sep, ←measure.restrict_apply₀' hs, hfg'],
+  rw [←set_of_inter_eq_sep, ←measure.restrict_apply₀' hs,
+    ←measure_diff_null (measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint)] at this,
+  refine this.trans_le (measure_mono _),
+  rintro x ⟨hfx, hx⟩,
+  dsimp at hfx,
+  rw [←to_real_laverage hg.ae_measurable, to_real_le_to_real (set_laverage_lt_top hint).ne hx]
+    at hfx,
+  exact hfx.trans (hgf _),
+  { simp_rw [ae_iff, not_ne_iff],
+    exact measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint }
+end
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
+lemma exists_le_set_laverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : ae_measurable f (μ.restrict s)) :
+  ∃ x ∈ s, f x ≤ ⨍⁻ a in s, f a ∂μ :=
+let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_set_laverage_pos hμ hμ₁ hf).ne'
+  in ⟨x, hx, h⟩
+
+/-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
+lemma exists_set_laverage_le (hμ : μ s ≠ 0) (hs : null_measurable_set s μ)
+  (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : ∃ x ∈ s, ⨍⁻ a in s, f a ∂μ ≤ f x :=
+let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_set_laverage_le_pos hμ hs hint).ne'
+  in ⟨x, hx, h⟩
+
+/-- **First moment method**. A measurable function is greater than its mean on a set of positive
+measure. -/
+lemma measure_laverage_le_pos (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) :
+  0 < μ {x | ⨍⁻ a, f a ∂μ ≤ f x} :=
+by simpa [hint] using @measure_set_laverage_le_pos _ _ _ _ f (measure_univ_ne_zero.2 hμ)
+  null_measurable_set_univ
+
+/-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
+lemma exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ⨍⁻ a, f a ∂μ ≤ f x :=
+let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_laverage_le_pos hμ hint).ne' in ⟨x, hx⟩
+
+/-- **First moment method**. The maximum of a measurable function is greater than its mean, while
+avoiding a null set. -/
+lemma exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ (a : α), f a ∂μ ≠ ∞) (hN : μ N = 0) :
+  ∃ x ∉ N, ⨍⁻ a, f a ∂μ ≤ f x :=
+begin
+  have := measure_laverage_le_pos hμ hint,
+  rw ←measure_diff_null hN at this,
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne',
+  exact ⟨x, hxN, hx⟩,
+end
+
+section finite_measure
+variables [is_finite_measure μ]
+
+/-- **First moment method**. A measurable function is smaller than its mean on a set of positive
+measure. -/
+lemma measure_le_laverage_pos (hμ : μ ≠ 0) (hf : ae_measurable f μ) :
+  0 < μ {x | f x ≤ ⨍⁻ a, f a ∂μ} :=
+by simpa
+  using measure_le_set_laverage_pos (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _) hf.restrict
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
+lemma exists_le_laverage (hμ : μ ≠ 0) (hf : ae_measurable f μ) : ∃ x, f x ≤ ⨍⁻ a, f a ∂μ :=
+let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_laverage_pos hμ hf).ne' in ⟨x, hx⟩
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean, while
+avoiding a null set. -/
+lemma exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : ae_measurable f μ) (hN : μ N = 0) :
+  ∃ x ∉ N, f x ≤ ⨍⁻ a, f a ∂μ :=
+begin
+  have := measure_le_laverage_pos hμ hf,
+  rw ←measure_diff_null hN at this,
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne',
+  exact ⟨x, hxN, hx⟩,
+end
+
+end finite_measure
+
+section probability_measure
+variables [is_probability_measure μ]
+
+/-- **First moment method**. A measurable function is smaller than its integral on a set of
+positive measure. -/
+lemma measure_le_lintegral_pos (hf : ae_measurable f μ) : 0 < μ {x | f x ≤ ∫⁻ a, f a ∂μ} :=
+by simpa only [laverage_eq_lintegral]
+  using measure_le_laverage_pos (is_probability_measure.ne_zero μ) hf
+
+/-- **First moment method**. A measurable function is greater than its integral on a set of
+positive measure. -/
+lemma measure_lintegral_le_pos (hint : ∫⁻ a, f a ∂μ ≠ ∞) : 0 < μ {x | ∫⁻ a, f a ∂μ ≤ f x} :=
+by simpa only [laverage_eq_lintegral]
+  using measure_laverage_le_pos (is_probability_measure.ne_zero μ) hint
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its integral. -/
+lemma exists_le_lintegral (hf : ae_measurable f μ) : ∃ x, f x ≤ ∫⁻ a, f a ∂μ :=
+by simpa only [laverage_eq_lintegral]
+  using exists_le_laverage (is_probability_measure.ne_zero μ) hf
+
+/-- **First moment method**. The maximum of a measurable function is greater than its integral. -/
+lemma exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻ a, f a ∂μ ≤ f x :=
+by simpa only [laverage_eq_lintegral]
+  using exists_laverage_le (is_probability_measure.ne_zero μ) hint
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its integral,
+while avoiding a null set. -/
+lemma exists_not_mem_null_le_lintegral (hf : ae_measurable f μ) (hN : μ N = 0) :
+  ∃ x ∉ N, f x ≤ ∫⁻ a, f a ∂μ :=
+by simpa only [laverage_eq_lintegral]
+  using exists_not_mem_null_le_laverage (is_probability_measure.ne_zero μ) hf hN
+
+/-- **First moment method**. The maximum of a measurable function is greater than its integral,
+while avoiding a null set. -/
+lemma exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞)
+  (hN : μ N = 0) : ∃ x ∉ N, ∫⁻ a, f a ∂μ ≤ f x :=
+by simpa only [laverage_eq_lintegral]
+  using exists_not_mem_null_laverage_le (is_probability_measure.ne_zero μ) hint hN
+
+end probability_measure
+end first_moment_ennreal
 end measure_theory

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

feat(measure_theory/integral/set_integral): First moment method (#18731)

Integrable functions are smaller/larger than their mean on a set of positive measure. We prove it for the Bochner and Lebesgue integrals.

Diff
@@ -1,7 +1,7 @@
 /-
 Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Yury G. Kudryashov
+Authors: Yury G. Kudryashov, Yaël Dillies
 -/
 import measure_theory.integral.set_integral
 
@@ -19,24 +19,32 @@ measure, then the average of any function is equal to its integral.
 For the average on a set, we use `⨍ x in s, f x ∂μ` (notation for `⨍ x, f x ∂(μ.restrict s)`). For
 average w.r.t. the volume, one can omit `∂volume`.
 
+We prove several version of the first moment method: An integrable function is below/above its
+average on a set of positive measure.
+
 ## Implementation notes
 
 The average is defined as an integral over `(μ univ)⁻¹ • μ` so that all theorems about Bochner
 integrals work for the average without modifications. For theorems that require integrability of a
 function, we provide a convenience lemma `measure_theory.integrable.to_average`.
 
+## TODO
+
+Provide the first moment method for the Lebesgue integral as well. A draft is available on branch
+`first_moment_lintegral`.
+
 ## Tags
 
 integral, center mass, average value
 -/
 
-open measure_theory measure_theory.measure metric set filter topological_space function
+open ennreal measure_theory measure_theory.measure metric set filter topological_space function
 open_locale topology big_operators ennreal convex
 
 variables {α E F : Type*} {m0 : measurable_space α}
   [normed_add_comm_group E] [normed_space ℝ E] [complete_space E]
   [normed_add_comm_group F] [normed_space ℝ F] [complete_space F]
-  {μ : measure α} {s : set E}
+  {μ : measure α} {s t : set α}
 
 /-!
 ### Average value of a function w.r.t. a measure
@@ -49,8 +57,8 @@ integral.
 -/
 
 namespace measure_theory
-
-variable (μ)
+section normed_add_comm_group
+variables (μ) {f g : α → E}
 include m0
 
 /-- Average value of a function `f` w.r.t. a measure `μ`, notation: `⨍ x, f x ∂μ`. It is defined as
@@ -106,6 +114,9 @@ variable {μ}
 lemma average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = ⨍ x, g x ∂μ :=
 by simp only [average_eq, integral_congr_ae h]
 
+lemma set_average_congr_set_ae (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ :=
+by simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
+
 lemma average_add_measure [is_finite_measure μ] {ν : measure α} [is_finite_measure ν] {f : α → E}
   (hμ : integrable f μ) (hν : integrable f ν) :
   ⨍ x, f x ∂(μ + ν) =
@@ -182,4 +193,196 @@ by simp only [set_average_eq, integral_const, measure.restrict_apply, measurable
   univ_inter, smul_smul, ← ennreal.to_real_inv, ← ennreal.to_real_mul,
   ennreal.inv_mul_cancel hs₀ hs, ennreal.one_to_real, one_smul]
 
+@[simp] lemma integral_average (μ : measure α) [is_finite_measure μ] (f : α → E) :
+  ∫ x, ⨍ a, f a ∂μ ∂μ = ∫ x, f x ∂μ :=
+begin
+  unfreezingI { obtain rfl | hμ := eq_or_ne μ 0 },
+  { simp only [integral_zero_measure] },
+  { rw [integral_const, average_eq,
+      smul_inv_smul₀ (to_real_ne_zero.2 ⟨measure_univ_ne_zero.2 hμ, measure_ne_top _ _⟩)] }
+end
+
+lemma set_integral_set_average (μ : measure α) [is_finite_measure μ] (f : α → E) (s : set α) :
+  ∫ x in s, ⨍ a in s, f a ∂μ ∂μ = ∫ x in s, f x ∂μ :=
+integral_average _ _
+
+lemma integral_sub_average (μ : measure α) [is_finite_measure μ] (f : α → E) :
+  ∫ x, f x - ⨍ a, f a ∂μ ∂μ = 0 :=
+begin
+  by_cases hf : integrable f μ,
+  { rw [integral_sub hf (integrable_const _), integral_average, sub_self] },
+  refine integral_undef (λ h, hf _),
+  convert h.add (integrable_const _),
+  exact (sub_add_cancel _ _).symm,
+end
+
+lemma set_integral_sub_set_average (hs : μ s ≠ ∞) (f : α → E) :
+  ∫ x in s, f x - ⨍ a in s, f a ∂μ ∂μ = 0 :=
+by haveI haveI : fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩; exact integral_sub_average _ _
+
+lemma integral_average_sub [is_finite_measure μ] (hf : integrable f μ) :
+  ∫ x, ⨍ a, f a ∂μ - f x ∂μ = 0 :=
+by rw [integral_sub (integrable_const _) hf, integral_average, sub_self]
+
+lemma set_integral_set_average_sub (hs : μ s ≠ ∞) (hf : integrable_on f s μ) :
+  ∫ x in s, ⨍ a in s, f a ∂μ - f x ∂μ = 0 :=
+by haveI haveI : fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩; exact integral_average_sub hf
+
+end normed_add_comm_group
+
+lemma of_real_average {f : α → ℝ} (hf : integrable f μ) (hf₀ : 0 ≤ᵐ[μ] f) :
+  ennreal.of_real (⨍ x, f x ∂μ) = (∫⁻ x, ennreal.of_real (f x) ∂μ) / μ univ :=
+begin
+  obtain rfl | hμ := eq_or_ne μ 0,
+  { simp },
+  { rw [average_eq, smul_eq_mul, ←to_real_inv, of_real_mul (to_real_nonneg),
+      of_real_to_real (inv_ne_top.2 $ measure_univ_ne_zero.2 hμ),
+      of_real_integral_eq_lintegral_of_real hf hf₀, ennreal.div_eq_inv_mul] }
+end
+
+lemma of_real_set_average {f : α → ℝ} (hf : integrable_on f s μ)
+  (hf₀ : 0 ≤ᵐ[μ.restrict s] f) :
+  ennreal.of_real (⨍ x in s, f x ∂μ) = (∫⁻ x in s, ennreal.of_real (f x) ∂μ) / μ s :=
+by simpa using of_real_average hf hf₀
+
+lemma average_to_real {f : α → ℝ≥0∞} (hf : ae_measurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
+  ⨍ x, (f x).to_real ∂μ = (∫⁻ x, f x ∂μ / μ univ).to_real :=
+begin
+  obtain rfl | hμ := eq_or_ne μ 0,
+  { simp },
+  { rw [average_eq, smul_eq_mul, to_real_div,
+      ←integral_to_real hf (hf'.mono $ λ _, lt_top_iff_ne_top.2), div_eq_inv_mul] }
+end
+
+lemma set_average_to_real {f : α → ℝ≥0∞} (hf : ae_measurable f (μ.restrict s))
+  (hf' : ∀ᵐ x ∂(μ.restrict s), f x ≠ ∞) :
+  ⨍ x in s, (f x).to_real ∂μ = (∫⁻ x in s, f x ∂μ / μ s).to_real :=
+by simpa using average_to_real hf hf'
+
+/-! ### First moment method -/
+
+section first_moment
+variables {N : set α} {f : α → ℝ}
+
+/-- **First moment method**. An integrable function is smaller than its mean on a set of positive
+measure. -/
+lemma measure_le_set_average_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : integrable_on f s μ) :
+  0 < μ {x ∈ s | f x ≤ ⨍ a in s, f a ∂μ} :=
+begin
+  refine pos_iff_ne_zero.2 (λ H, _),
+  replace H : (μ.restrict s) {x | f x ≤ ⨍ a in s, f a ∂μ} = 0,
+  { rwa [restrict_apply₀, inter_comm],
+    exact ae_strongly_measurable.null_measurable_set_le hf.1 ae_strongly_measurable_const },
+  haveI : is_finite_measure (μ.restrict s) :=
+    ⟨by simpa only [measure.restrict_apply, measurable_set.univ, univ_inter] using hμ₁.lt_top⟩,
+  refine (integral_sub_average (μ.restrict s) f).not_gt _,
+  refine (set_integral_pos_iff_support_of_nonneg_ae _ _).2 _,
+  { refine eq_bot_mono (measure_mono (λ x hx, _)) H,
+    simp only [pi.zero_apply, sub_nonneg, mem_compl_iff, mem_set_of_eq, not_le] at hx,
+    exact hx.le },
+  { exact hf.sub (integrable_on_const.2 $ or.inr $ lt_top_iff_ne_top.2 hμ₁) },
+  { rwa [pos_iff_ne_zero, inter_comm, ←diff_compl, ←diff_inter_self_eq_diff, measure_diff_null],
+    refine eq_bot_mono (measure_mono _) (measure_inter_eq_zero_of_restrict H),
+    exact inter_subset_inter_left _ (λ a ha, (sub_eq_zero.1 $ of_not_not ha).le) }
+end
+
+/-- **First moment method**. An integrable function is greater than its mean on a set of positive
+measure. -/
+lemma measure_set_average_le_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : integrable_on f s μ) :
+  0 < μ {x ∈ s | ⨍ a in s, f a ∂μ ≤ f x} :=
+by simpa [integral_neg, neg_div] using measure_le_set_average_pos hμ hμ₁ hf.neg
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
+lemma exists_le_set_average (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : integrable_on f s μ) :
+  ∃ x ∈ s, f x ≤ ⨍ a in s, f a ∂μ :=
+let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_set_average_pos hμ hμ₁ hf).ne'
+  in ⟨x, hx, h⟩
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
+lemma exists_set_average_le (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : integrable_on f s μ) :
+  ∃ x ∈ s, ⨍ a in s, f a ∂μ ≤ f x :=
+let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_set_average_le_pos hμ hμ₁ hf).ne'
+  in ⟨x, hx, h⟩
+
+section finite_measure
+variables [is_finite_measure μ]
+
+/-- **First moment method**. An integrable function is smaller than its mean on a set of positive
+measure. -/
+lemma measure_le_average_pos (hμ : μ ≠ 0) (hf : integrable f μ) : 0 < μ {x | f x ≤ ⨍ a, f a ∂μ} :=
+by simpa using measure_le_set_average_pos (measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
+  hf.integrable_on
+
+/-- **First moment method**. An integrable function is greater than its mean on a set of positive
+measure. -/
+lemma measure_average_le_pos (hμ : μ ≠ 0) (hf : integrable f μ) : 0 < μ {x | ⨍ a, f a ∂μ ≤ f x} :=
+by simpa using measure_set_average_le_pos (measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
+  hf.integrable_on
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
+lemma exists_le_average (hμ : μ ≠ 0) (hf : integrable f μ) : ∃ x, f x ≤ ⨍ a, f a ∂μ :=
+let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_average_pos hμ hf).ne' in ⟨x, hx⟩
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
+lemma exists_average_le (hμ : μ ≠ 0) (hf : integrable f μ) : ∃ x, ⨍ a, f a ∂μ ≤ f x :=
+let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_average_le_pos hμ hf).ne' in ⟨x, hx⟩
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean, while
+avoiding a null set. -/
+lemma exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : integrable f μ) (hN : μ N = 0) :
+  ∃ x ∉ N, f x ≤ ⨍ a, f a ∂μ :=
+begin
+  have := measure_le_average_pos hμ hf,
+  rw ←measure_diff_null hN at this,
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne',
+  exact ⟨x, hxN, hx⟩,
+end
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean, while
+avoiding a null set. -/
+lemma exists_not_mem_null_average_le (hμ : μ ≠ 0) (hf : integrable f μ) (hN : μ N = 0) :
+  ∃ x ∉ N, ⨍ a, f a ∂μ ≤ f x :=
+by simpa [integral_neg, neg_div] using exists_not_mem_null_le_average hμ hf.neg hN
+
+end finite_measure
+
+section probability_measure
+variables [is_probability_measure μ]
+
+/-- **First moment method**. An integrable function is smaller than its integral on a set of
+positive measure. -/
+lemma measure_le_integral_pos (hf : integrable f μ) : 0 < μ {x | f x ≤ ∫ a, f a ∂μ} :=
+by simpa only [average_eq_integral]
+  using measure_le_average_pos (is_probability_measure.ne_zero μ) hf
+
+/-- **First moment method**. An integrable function is greater than its integral on a set of
+positive measure. -/
+lemma measure_integral_le_pos (hf : integrable f μ) : 0 < μ {x | ∫ a, f a ∂μ ≤ f x} :=
+by simpa only [average_eq_integral]
+  using measure_average_le_pos (is_probability_measure.ne_zero μ) hf
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its integral. -/
+lemma exists_le_integral (hf : integrable f μ) : ∃ x, f x ≤ ∫ a, f a ∂μ :=
+by simpa only [average_eq_integral] using exists_le_average (is_probability_measure.ne_zero μ) hf
+
+/-- **First moment method**. The maximum of an integrable function is greater than its integral. -/
+lemma exists_integral_le (hf : integrable f μ) : ∃ x, ∫ a, f a ∂μ ≤ f x :=
+by simpa only [average_eq_integral] using exists_average_le (is_probability_measure.ne_zero μ) hf
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its integral,
+while avoiding a null set. -/
+lemma exists_not_mem_null_le_integral (hf : integrable f μ) (hN : μ N = 0) :
+  ∃ x ∉ N, f x ≤ ∫ a, f a ∂μ :=
+by simpa only [average_eq_integral]
+  using exists_not_mem_null_le_average (is_probability_measure.ne_zero μ) hf hN
+
+/-- **First moment method**. The maximum of an integrable function is greater than its integral,
+while avoiding a null set. -/
+lemma exists_not_mem_null_integral_le (hf : integrable f μ) (hN : μ N = 0) :
+  ∃ x ∉ N, ∫ a, f a ∂μ ≤ f x :=
+by simpa only [average_eq_integral]
+  using exists_not_mem_null_average_le (is_probability_measure.ne_zero μ) hf hN
+
+end probability_measure
+end first_moment
 end measure_theory

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(no changes)

(first ported)

Changes in mathlib3port

mathlib3
mathlib3port
Diff
@@ -705,7 +705,7 @@ theorem exists_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, ⨍ a
 #align measure_theory.exists_average_le MeasureTheory.exists_average_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_average /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its mean, while
 avoiding a null set. -/
@@ -719,7 +719,7 @@ theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (
 #align measure_theory.exists_not_mem_null_le_average MeasureTheory.exists_not_mem_null_le_average
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_average_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its mean, while
 avoiding a null set. -/
@@ -767,7 +767,7 @@ theorem exists_integral_le (hf : Integrable f μ) : ∃ x, ∫ a, f a ∂μ ≤
 #align measure_theory.exists_integral_le MeasureTheory.exists_integral_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_integral /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its integral,
 while avoiding a null set. -/
@@ -778,7 +778,7 @@ theorem exists_not_mem_null_le_integral (hf : Integrable f μ) (hN : μ N = 0) :
 #align measure_theory.exists_not_mem_null_le_integral MeasureTheory.exists_not_mem_null_le_integral
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_integral_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its integral,
 while avoiding a null set. -/
@@ -886,7 +886,7 @@ theorem exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞)
 #align measure_theory.exists_laverage_le MeasureTheory.exists_laverage_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_laverage_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its mean, while
 avoiding a null set. -/
@@ -922,7 +922,7 @@ theorem exists_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) : ∃ x, f
 #align measure_theory.exists_le_laverage MeasureTheory.exists_le_laverage
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_laverage /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its mean, while
 avoiding a null set. -/
@@ -975,7 +975,7 @@ theorem exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻
 #align measure_theory.exists_lintegral_le MeasureTheory.exists_lintegral_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_lintegral /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its integral,
 while avoiding a null set. -/
@@ -986,7 +986,7 @@ theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0
 #align measure_theory.exists_not_mem_null_le_lintegral MeasureTheory.exists_not_mem_null_le_lintegral
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:642:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_lintegral_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its integral,
 while avoiding a null set. -/
Diff
@@ -180,10 +180,10 @@ theorem laverage_add_measure :
       μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν :=
   by
   by_cases hμ : is_finite_measure μ; swap
-  · rw [not_is_finite_measure_iff] at hμ 
+  · rw [not_is_finite_measure_iff] at hμ
     simp [laverage_eq, hμ]
   by_cases hν : is_finite_measure ν; swap
-  · rw [not_is_finite_measure_iff] at hν 
+  · rw [not_is_finite_measure_iff] at hν
     simp [laverage_eq, hν]
   haveI := hμ; haveI := hν
   simp only [← ENNReal.mul_div_right_comm, measure_mul_laverage, ← ENNReal.add_div, ←
@@ -225,7 +225,7 @@ theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurable
     ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ] :=
   by
   by_cases hs₀ : μ s = 0
-  · rw [← ae_eq_empty] at hs₀ 
+  · rw [← ae_eq_empty] at hs₀
     rw [restrict_congr_set (hs₀.union eventually_eq.rfl), empty_union]
     exact right_mem_segment _ _ _
   · refine'
@@ -465,7 +465,7 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
     (hft : IntegrableOn f t μ) : ⨍ x in s ∪ t, f x ∂μ ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] :=
   by
   by_cases hse : μ s = 0
-  · rw [← ae_eq_empty] at hse 
+  · rw [← ae_eq_empty] at hse
     rw [restrict_congr_set (hse.union eventually_eq.rfl), empty_union]
     exact right_mem_segment _ _ _
   · refine'
@@ -627,7 +627,7 @@ theorem measure_le_setAverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf
   refine' (integral_sub_average (μ.restrict s) f).not_gt _
   refine' (set_integral_pos_iff_support_of_nonneg_ae _ _).2 _
   · refine' eq_bot_mono (measure_mono fun x hx => _) H
-    simp only [Pi.zero_apply, sub_nonneg, mem_compl_iff, mem_set_of_eq, not_le] at hx 
+    simp only [Pi.zero_apply, sub_nonneg, mem_compl_iff, mem_set_of_eq, not_le] at hx
     exact hx.le
   · exact hf.sub (integrable_on_const.2 <| Or.inr <| lt_top_iff_ne_top.2 hμ₁)
   · rwa [pos_iff_ne_zero, inter_comm, ← diff_compl, ← diff_inter_self_eq_diff, measure_diff_null]
@@ -713,7 +713,7 @@ theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (
     ∃ (x : _) (_ : x ∉ N), f x ≤ ⨍ a, f a ∂μ :=
   by
   have := measure_le_average_pos hμ hf
-  rw [← measure_diff_null hN] at this 
+  rw [← measure_diff_null hN] at this
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_le_average MeasureTheory.exists_not_mem_null_le_average
@@ -813,11 +813,11 @@ theorem measure_le_setLaverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
     measure.restrict_apply₀
       (hf.ennreal_to_real.ae_strongly_measurable.null_measurable_set_le
         ae_strongly_measurable_const),
-    ← measure_diff_null (measure_eq_top_of_lintegral_ne_top hf h)] at this 
+    ← measure_diff_null (measure_eq_top_of_lintegral_ne_top hf h)] at this
   refine' this.trans_le (measure_mono _)
   rintro x ⟨hfx, hx⟩
-  dsimp at hfx 
-  rwa [← to_real_laverage hf, to_real_le_to_real hx (set_laverage_lt_top h).Ne] at hfx 
+  dsimp at hfx
+  rwa [← to_real_laverage hf, to_real_le_to_real hx (set_laverage_lt_top h).Ne] at hfx
   · simp_rw [ae_iff, not_ne_iff]
     exact measure_eq_top_of_lintegral_ne_top hf h
 #align measure_theory.measure_le_set_laverage_pos MeasureTheory.measure_le_setLaverage_pos
@@ -833,17 +833,17 @@ theorem measure_setLaverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s
   · simp [set_laverage_eq, hμ₁]
   obtain ⟨g, hg, hgf, hfg⟩ := exists_measurable_le_lintegral_eq (μ.restrict s) f
   have hfg' : ⨍⁻ a in s, f a ∂μ = ⨍⁻ a in s, g a ∂μ := by simp_rw [laverage_eq, hfg]
-  rw [hfg] at hint 
+  rw [hfg] at hint
   have :=
     measure_set_average_le_pos hμ hμ₁ (integrable_to_real_of_lintegral_ne_top hg.ae_measurable hint)
   simp_rw [← set_of_inter_eq_sep, ← measure.restrict_apply₀' hs, hfg']
   rw [← set_of_inter_eq_sep, ← measure.restrict_apply₀' hs, ←
-    measure_diff_null (measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint)] at this 
+    measure_diff_null (measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint)] at this
   refine' this.trans_le (measure_mono _)
   rintro x ⟨hfx, hx⟩
-  dsimp at hfx 
+  dsimp at hfx
   rw [← to_real_laverage hg.ae_measurable, to_real_le_to_real (set_laverage_lt_top hint).Ne hx] at
-    hfx 
+    hfx
   exact hfx.trans (hgf _)
   · simp_rw [ae_iff, not_ne_iff]
     exact measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint
@@ -894,7 +894,7 @@ theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α,
     ∃ (x : _) (_ : x ∉ N), ⨍⁻ a, f a ∂μ ≤ f x :=
   by
   have := measure_laverage_le_pos hμ hint
-  rw [← measure_diff_null hN] at this 
+  rw [← measure_diff_null hN] at this
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_laverage_le MeasureTheory.exists_not_mem_null_laverage_le
@@ -930,7 +930,7 @@ theorem exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ
     ∃ (x : _) (_ : x ∉ N), f x ≤ ⨍⁻ a, f a ∂μ :=
   by
   have := measure_le_laverage_pos hμ hf
-  rw [← measure_diff_null hN] at this 
+  rw [← measure_diff_null hN] at this
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_le_laverage MeasureTheory.exists_not_mem_null_le_laverage
Diff
@@ -3,7 +3,7 @@ Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury G. Kudryashov, Yaël Dillies
 -/
-import Mathbin.MeasureTheory.Integral.SetIntegral
+import MeasureTheory.Integral.SetIntegral
 
 #align_import measure_theory.integral.average from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
 
@@ -705,7 +705,7 @@ theorem exists_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, ⨍ a
 #align measure_theory.exists_average_le MeasureTheory.exists_average_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_average /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its mean, while
 avoiding a null set. -/
@@ -719,7 +719,7 @@ theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (
 #align measure_theory.exists_not_mem_null_le_average MeasureTheory.exists_not_mem_null_le_average
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_average_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its mean, while
 avoiding a null set. -/
@@ -767,7 +767,7 @@ theorem exists_integral_le (hf : Integrable f μ) : ∃ x, ∫ a, f a ∂μ ≤
 #align measure_theory.exists_integral_le MeasureTheory.exists_integral_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_integral /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its integral,
 while avoiding a null set. -/
@@ -778,7 +778,7 @@ theorem exists_not_mem_null_le_integral (hf : Integrable f μ) (hN : μ N = 0) :
 #align measure_theory.exists_not_mem_null_le_integral MeasureTheory.exists_not_mem_null_le_integral
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_integral_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its integral,
 while avoiding a null set. -/
@@ -886,7 +886,7 @@ theorem exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞)
 #align measure_theory.exists_laverage_le MeasureTheory.exists_laverage_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_laverage_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its mean, while
 avoiding a null set. -/
@@ -922,7 +922,7 @@ theorem exists_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) : ∃ x, f
 #align measure_theory.exists_le_laverage MeasureTheory.exists_le_laverage
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_laverage /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its mean, while
 avoiding a null set. -/
@@ -975,7 +975,7 @@ theorem exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻
 #align measure_theory.exists_lintegral_le MeasureTheory.exists_lintegral_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_lintegral /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its integral,
 while avoiding a null set. -/
@@ -986,7 +986,7 @@ theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0
 #align measure_theory.exists_not_mem_null_le_lintegral MeasureTheory.exists_not_mem_null_le_lintegral
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:641:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_lintegral_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its integral,
 while avoiding a null set. -/
Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury G. Kudryashov, Yaël Dillies
-
-! This file was ported from Lean 3 source module measure_theory.integral.average
-! leanprover-community/mathlib commit c14c8fcde993801fca8946b0d80131a1a81d1520
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathbin.MeasureTheory.Integral.SetIntegral
 
+#align_import measure_theory.integral.average from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
+
 /-!
 # Integral average of a function
 
@@ -708,7 +705,7 @@ theorem exists_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, ⨍ a
 #align measure_theory.exists_average_le MeasureTheory.exists_average_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_average /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its mean, while
 avoiding a null set. -/
@@ -722,7 +719,7 @@ theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (
 #align measure_theory.exists_not_mem_null_le_average MeasureTheory.exists_not_mem_null_le_average
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_average_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its mean, while
 avoiding a null set. -/
@@ -770,7 +767,7 @@ theorem exists_integral_le (hf : Integrable f μ) : ∃ x, ∫ a, f a ∂μ ≤
 #align measure_theory.exists_integral_le MeasureTheory.exists_integral_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_integral /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its integral,
 while avoiding a null set. -/
@@ -781,7 +778,7 @@ theorem exists_not_mem_null_le_integral (hf : Integrable f μ) (hN : μ N = 0) :
 #align measure_theory.exists_not_mem_null_le_integral MeasureTheory.exists_not_mem_null_le_integral
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_integral_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its integral,
 while avoiding a null set. -/
@@ -889,7 +886,7 @@ theorem exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞)
 #align measure_theory.exists_laverage_le MeasureTheory.exists_laverage_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_laverage_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its mean, while
 avoiding a null set. -/
@@ -925,7 +922,7 @@ theorem exists_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) : ∃ x, f
 #align measure_theory.exists_le_laverage MeasureTheory.exists_le_laverage
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_laverage /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its mean, while
 avoiding a null set. -/
@@ -978,7 +975,7 @@ theorem exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻
 #align measure_theory.exists_lintegral_le MeasureTheory.exists_lintegral_le
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_le_lintegral /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its integral,
 while avoiding a null set. -/
@@ -989,7 +986,7 @@ theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0
 #align measure_theory.exists_not_mem_null_le_lintegral MeasureTheory.exists_not_mem_null_le_lintegral
 -/
 
-/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/- ./././Mathport/Syntax/Translate/Basic.lean:635:2: warning: expanding binder collection (x «expr ∉ » N) -/
 #print MeasureTheory.exists_not_mem_null_lintegral_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its integral,
 while avoiding a null set. -/
Diff
@@ -66,6 +66,7 @@ section ENNReal
 
 variable (μ) {f g : α → ℝ≥0∞}
 
+#print MeasureTheory.laverage /-
 /-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`, notation: `⨍⁻ x, f x ∂μ`.
 It is defined as `μ univ⁻¹ * ∫⁻ x, f x ∂μ`, so it is equal to zero if `μ` is an infinite measure. If
 `μ` is a probability measure, then the average of any function is equal to its integral.
@@ -75,6 +76,7 @@ average w.r.t. the volume, one can omit `∂volume`. -/
 noncomputable def laverage (f : α → ℝ≥0∞) :=
   ∫⁻ x, f x ∂(μ univ)⁻¹ • μ
 #align measure_theory.laverage MeasureTheory.laverage
+-/
 
 notation3"⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r
 
@@ -84,26 +86,37 @@ notation3"⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (M
 
 notation3"⨍⁻ "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r
 
+#print MeasureTheory.laverage_zero /-
 @[simp]
 theorem laverage_zero : ⨍⁻ x, (0 : ℝ≥0∞) ∂μ = 0 := by rw [laverage, lintegral_zero]
 #align measure_theory.laverage_zero MeasureTheory.laverage_zero
+-/
 
+#print MeasureTheory.laverage_zero_measure /-
 @[simp]
 theorem laverage_zero_measure (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂(0 : Measure α) = 0 := by simp [laverage]
 #align measure_theory.laverage_zero_measure MeasureTheory.laverage_zero_measure
+-/
 
+#print MeasureTheory.laverage_eq' /-
 theorem laverage_eq' (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂(μ univ)⁻¹ • μ :=
   rfl
 #align measure_theory.laverage_eq' MeasureTheory.laverage_eq'
+-/
 
+#print MeasureTheory.laverage_eq /-
 theorem laverage_eq (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = (∫⁻ x, f x ∂μ) / μ univ := by
   rw [laverage_eq', lintegral_smul_measure, ENNReal.div_eq_inv_mul]
 #align measure_theory.laverage_eq MeasureTheory.laverage_eq
+-/
 
+#print MeasureTheory.laverage_eq_lintegral /-
 theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞) :
     ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [laverage, measure_univ, inv_one, one_smul]
 #align measure_theory.laverage_eq_lintegral MeasureTheory.laverage_eq_lintegral
+-/
 
+#print MeasureTheory.measure_mul_laverage /-
 @[simp]
 theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
     μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ :=
@@ -112,31 +125,43 @@ theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
   · rw [hμ, lintegral_zero_measure, laverage_zero_measure, MulZeroClass.mul_zero]
   · rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
 #align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage
+-/
 
-theorem set_laverage_eq (f : α → ℝ≥0∞) (s : Set α) :
-    ⨍⁻ x in s, f x ∂μ = (∫⁻ x in s, f x ∂μ) / μ s := by rw [laverage_eq, restrict_apply_univ]
-#align measure_theory.set_laverage_eq MeasureTheory.set_laverage_eq
+#print MeasureTheory.setLaverage_eq /-
+theorem setLaverage_eq (f : α → ℝ≥0∞) (s : Set α) : ⨍⁻ x in s, f x ∂μ = (∫⁻ x in s, f x ∂μ) / μ s :=
+  by rw [laverage_eq, restrict_apply_univ]
+#align measure_theory.set_laverage_eq MeasureTheory.setLaverage_eq
+-/
 
-theorem set_laverage_eq' (f : α → ℝ≥0∞) (s : Set α) :
+#print MeasureTheory.setLaverage_eq' /-
+theorem setLaverage_eq' (f : α → ℝ≥0∞) (s : Set α) :
     ⨍⁻ x in s, f x ∂μ = ∫⁻ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
   simp only [laverage_eq', restrict_apply_univ]
-#align measure_theory.set_laverage_eq' MeasureTheory.set_laverage_eq'
+#align measure_theory.set_laverage_eq' MeasureTheory.setLaverage_eq'
+-/
 
 variable {μ}
 
+#print MeasureTheory.laverage_congr /-
 theorem laverage_congr {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ⨍⁻ x, f x ∂μ = ⨍⁻ x, g x ∂μ := by
   simp only [laverage_eq, lintegral_congr_ae h]
 #align measure_theory.laverage_congr MeasureTheory.laverage_congr
+-/
 
-theorem set_laverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ := by
+#print MeasureTheory.setLaverage_congr /-
+theorem setLaverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ := by
   simp only [set_laverage_eq, set_lintegral_congr h, measure_congr h]
-#align measure_theory.set_laverage_congr MeasureTheory.set_laverage_congr
+#align measure_theory.set_laverage_congr MeasureTheory.setLaverage_congr
+-/
 
-theorem set_laverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+#print MeasureTheory.setLaverage_congr_fun /-
+theorem setLaverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
     ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in s, g x ∂μ := by
   simp only [laverage_eq, set_lintegral_congr_fun hs h]
-#align measure_theory.set_laverage_congr_fun MeasureTheory.set_laverage_congr_fun
+#align measure_theory.set_laverage_congr_fun MeasureTheory.setLaverage_congr_fun
+-/
 
+#print MeasureTheory.laverage_lt_top /-
 theorem laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ < ∞ :=
   by
   obtain rfl | hμ := eq_or_ne μ 0
@@ -144,11 +169,15 @@ theorem laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ
   · rw [laverage_eq]
     exact div_lt_top hf (measure_univ_ne_zero.2 hμ)
 #align measure_theory.laverage_lt_top MeasureTheory.laverage_lt_top
+-/
 
-theorem set_laverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ :=
+#print MeasureTheory.setLaverage_lt_top /-
+theorem setLaverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ :=
   laverage_lt_top
-#align measure_theory.set_laverage_lt_top MeasureTheory.set_laverage_lt_top
+#align measure_theory.set_laverage_lt_top MeasureTheory.setLaverage_lt_top
+-/
 
+#print MeasureTheory.laverage_add_measure /-
 theorem laverage_add_measure :
     ⨍⁻ x, f x ∂(μ + ν) =
       μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν :=
@@ -163,18 +192,24 @@ theorem laverage_add_measure :
   simp only [← ENNReal.mul_div_right_comm, measure_mul_laverage, ← ENNReal.add_div, ←
     lintegral_add_measure, ← measure.add_apply, ← laverage_eq]
 #align measure_theory.laverage_add_measure MeasureTheory.laverage_add_measure
+-/
 
-theorem measure_mul_set_laverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) :
+#print MeasureTheory.measure_mul_setLaverage /-
+theorem measure_mul_setLaverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) :
     μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ := by haveI := Fact.mk h.lt_top;
   rw [← measure_mul_laverage, restrict_apply_univ]
-#align measure_theory.measure_mul_set_laverage MeasureTheory.measure_mul_set_laverage
+#align measure_theory.measure_mul_set_laverage MeasureTheory.measure_mul_setLaverage
+-/
 
+#print MeasureTheory.laverage_union /-
 theorem laverage_union (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) :
     ⨍⁻ x in s ∪ t, f x ∂μ =
       μ s / (μ s + μ t) * ⨍⁻ x in s, f x ∂μ + μ t / (μ s + μ t) * ⨍⁻ x in t, f x ∂μ :=
   by rw [restrict_union₀ hd ht, laverage_add_measure, restrict_apply_univ, restrict_apply_univ]
 #align measure_theory.laverage_union MeasureTheory.laverage_union
+-/
 
+#print MeasureTheory.laverage_union_mem_openSegment /-
 theorem laverage_union_mem_openSegment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
     ⨍⁻ x in s ∪ t, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in t, f x ∂μ) :=
@@ -185,7 +220,9 @@ theorem laverage_union_mem_openSegment (hd : AEDisjoint μ s t) (ht : NullMeasur
   rw [← ENNReal.add_div,
     ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
 #align measure_theory.laverage_union_mem_open_segment MeasureTheory.laverage_union_mem_openSegment
+-/
 
+#print MeasureTheory.laverage_union_mem_segment /-
 theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
     ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ] :=
@@ -199,7 +236,9 @@ theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurable
     rw [← ENNReal.add_div,
       ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
 #align measure_theory.laverage_union_mem_segment MeasureTheory.laverage_union_mem_segment
+-/
 
+#print MeasureTheory.laverage_mem_openSegment_compl_self /-
 theorem laverage_mem_openSegment_compl_self [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ)
     (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) :
     ⨍⁻ x, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in sᶜ, f x ∂μ) := by
@@ -207,7 +246,9 @@ theorem laverage_mem_openSegment_compl_self [IsFiniteMeasure μ] (hs : NullMeasu
     laverage_union_mem_open_segment ae_disjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _)
       (measure_ne_top _ _)
 #align measure_theory.laverage_mem_open_segment_compl_self MeasureTheory.laverage_mem_openSegment_compl_self
+-/
 
+#print MeasureTheory.laverage_const /-
 @[simp]
 theorem laverage_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : ℝ≥0∞) :
     ⨍⁻ x, c ∂μ = c := by
@@ -215,21 +256,29 @@ theorem laverage_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.ne_bot]
     div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel, mul_one, measure_ne_top μ univ, Ne.def,
     measure_univ_ne_zero, ae_ne_bot.1 h, not_false_iff]
 #align measure_theory.laverage_const MeasureTheory.laverage_const
+-/
 
-theorem set_laverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0∞) : ⨍⁻ x in s, c ∂μ = c := by
+#print MeasureTheory.setLaverage_const /-
+theorem setLaverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0∞) : ⨍⁻ x in s, c ∂μ = c := by
   simp only [set_laverage_eq, lintegral_const, measure.restrict_apply, MeasurableSet.univ,
     univ_inter, div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel hs₀ hs, mul_one]
-#align measure_theory.set_laverage_const MeasureTheory.set_laverage_const
+#align measure_theory.set_laverage_const MeasureTheory.setLaverage_const
+-/
 
+#print MeasureTheory.laverage_one /-
 @[simp]
 theorem laverage_one [IsFiniteMeasure μ] [h : μ.ae.ne_bot] : ⨍⁻ x, (1 : ℝ≥0∞) ∂μ = 1 :=
   laverage_const _ _
 #align measure_theory.laverage_one MeasureTheory.laverage_one
+-/
 
-theorem set_laverage_one (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) : ⨍⁻ x in s, (1 : ℝ≥0∞) ∂μ = 1 :=
-  set_laverage_const hs₀ hs _
-#align measure_theory.set_laverage_one MeasureTheory.set_laverage_one
+#print MeasureTheory.setLaverage_one /-
+theorem setLaverage_one (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) : ⨍⁻ x in s, (1 : ℝ≥0∞) ∂μ = 1 :=
+  setLaverage_const hs₀ hs _
+#align measure_theory.set_laverage_one MeasureTheory.setLaverage_one
+-/
 
+#print MeasureTheory.lintegral_laverage /-
 @[simp]
 theorem lintegral_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
     ∫⁻ x, ⨍⁻ a, f a ∂μ ∂μ = ∫⁻ x, f x ∂μ :=
@@ -240,11 +289,14 @@ theorem lintegral_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → 
     rw [lintegral_const, laverage_eq,
       ENNReal.div_mul_cancel (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
 #align measure_theory.lintegral_laverage MeasureTheory.lintegral_laverage
+-/
 
-theorem set_lintegral_set_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) (s : Set α) :
+#print MeasureTheory.setLintegral_setLaverage /-
+theorem setLintegral_setLaverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) (s : Set α) :
     ∫⁻ x in s, ⨍⁻ a in s, f a ∂μ ∂μ = ∫⁻ x in s, f x ∂μ :=
   lintegral_laverage _ _
-#align measure_theory.set_lintegral_set_laverage MeasureTheory.set_lintegral_set_laverage
+#align measure_theory.set_lintegral_set_laverage MeasureTheory.setLintegral_setLaverage
+-/
 
 end ENNReal
 
@@ -324,17 +376,17 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
 -/
 
-#print MeasureTheory.set_average_eq /-
-theorem set_average_eq (f : α → E) (s : Set α) :
+#print MeasureTheory.setAverage_eq /-
+theorem setAverage_eq (f : α → E) (s : Set α) :
     ⨍ x in s, f x ∂μ = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by rw [average_eq, restrict_apply_univ]
-#align measure_theory.set_average_eq MeasureTheory.set_average_eq
+#align measure_theory.set_average_eq MeasureTheory.setAverage_eq
 -/
 
-#print MeasureTheory.set_average_eq' /-
-theorem set_average_eq' (f : α → E) (s : Set α) :
+#print MeasureTheory.setAverage_eq' /-
+theorem setAverage_eq' (f : α → E) (s : Set α) :
     ⨍ x in s, f x ∂μ = ∫ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
   simp only [average_eq', restrict_apply_univ]
-#align measure_theory.set_average_eq' MeasureTheory.set_average_eq'
+#align measure_theory.set_average_eq' MeasureTheory.setAverage_eq'
 -/
 
 variable {μ}
@@ -345,13 +397,17 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = 
 #align measure_theory.average_congr MeasureTheory.average_congr
 -/
 
-theorem set_average_congr (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
+#print MeasureTheory.setAverage_congr /-
+theorem setAverage_congr (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
   simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
-#align measure_theory.set_average_congr MeasureTheory.set_average_congr
+#align measure_theory.set_average_congr MeasureTheory.setAverage_congr
+-/
 
-theorem set_average_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+#print MeasureTheory.setAverage_congr_fun /-
+theorem setAverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
     ⨍ x in s, f x ∂μ = ⨍ x in s, g x ∂μ := by simp only [average_eq, set_integral_congr_ae hs h]
-#align measure_theory.set_average_congr_fun MeasureTheory.set_average_congr_fun
+#align measure_theory.set_average_congr_fun MeasureTheory.setAverage_congr_fun
+-/
 
 #print MeasureTheory.average_add_measure /-
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
@@ -373,11 +429,11 @@ theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi
 #align measure_theory.average_pair MeasureTheory.average_pair
 -/
 
-#print MeasureTheory.measure_smul_set_average /-
-theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
+#print MeasureTheory.measure_smul_setAverage /-
+theorem measure_smul_setAverage (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
     (μ s).toReal • ⨍ x in s, f x ∂μ = ∫ x in s, f x ∂μ := by haveI := Fact.mk h.lt_top;
   rw [← measure_smul_average, restrict_apply_univ]
-#align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_set_average
+#align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_setAverage
 -/
 
 #print MeasureTheory.average_union /-
@@ -446,13 +502,13 @@ theorem average_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.ne_bot]
 #align measure_theory.average_const MeasureTheory.average_const
 -/
 
-#print MeasureTheory.set_average_const /-
-theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) : ⨍ x in s, c ∂μ = c :=
+#print MeasureTheory.setAverage_const /-
+theorem setAverage_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) : ⨍ x in s, c ∂μ = c :=
   by
   simp only [set_average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
     smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel hs₀ hs,
     ENNReal.one_toReal, one_smul]
-#align measure_theory.set_average_const MeasureTheory.set_average_const
+#align measure_theory.set_average_const MeasureTheory.setAverage_const
 -/
 
 #print MeasureTheory.integral_average /-
@@ -468,11 +524,11 @@ theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
 #align measure_theory.integral_average MeasureTheory.integral_average
 -/
 
-#print MeasureTheory.setAverage_setAverage /-
-theorem setAverage_setAverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
+#print MeasureTheory.setIntegral_setAverage /-
+theorem setIntegral_setAverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
     ∫ x in s, ⨍ a in s, f a ∂μ ∂μ = ∫ x in s, f x ∂μ :=
   integral_average _ _
-#align measure_theory.set_integral_set_average MeasureTheory.setAverage_setAverage
+#align measure_theory.set_integral_set_average MeasureTheory.setIntegral_setAverage
 -/
 
 #print MeasureTheory.integral_sub_average /-
@@ -502,12 +558,12 @@ theorem integral_average_sub [IsFiniteMeasure μ] (hf : Integrable f μ) :
 #align measure_theory.integral_average_sub MeasureTheory.integral_average_sub
 -/
 
-#print MeasureTheory.setAverage_setAverage_sub /-
-theorem setAverage_setAverage_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+#print MeasureTheory.setIntegral_setAverage_sub /-
+theorem setIntegral_setAverage_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     ∫ x in s, ⨍ a in s, f a ∂μ - f x ∂μ = 0 :=
   haveI haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
   integral_average_sub hf
-#align measure_theory.set_integral_set_average_sub MeasureTheory.setAverage_setAverage_sub
+#align measure_theory.set_integral_set_average_sub MeasureTheory.setIntegral_setAverage_sub
 -/
 
 end NormedAddCommGroup
@@ -532,6 +588,7 @@ theorem ofReal_setAverage {f : α → ℝ} (hf : IntegrableOn f s μ) (hf₀ : 0
 #align measure_theory.of_real_set_average MeasureTheory.ofReal_setAverage
 -/
 
+#print MeasureTheory.toReal_laverage /-
 theorem toReal_laverage {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
     (⨍⁻ x, f x ∂μ).toReal = ⨍ x, (f x).toReal ∂μ :=
   by
@@ -541,12 +598,15 @@ theorem toReal_laverage {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' :
     rw [average_eq, laverage_eq, smul_eq_mul, to_real_div, div_eq_inv_mul, ←
       integral_to_real hf (hf'.mono fun _ => lt_top_iff_ne_top.2)]
 #align measure_theory.to_real_laverage MeasureTheory.toReal_laverage
+-/
 
-theorem toReal_set_laverage {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
+#print MeasureTheory.toReal_setLaverage /-
+theorem toReal_setLaverage {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
     (hf' : ∀ᵐ x ∂μ.restrict s, f x ≠ ∞) :
     ((∫⁻ x in s, f x ∂μ) / μ s).toReal = ⨍ x in s, (f x).toReal ∂μ := by
   simpa [laverage_eq] using to_real_laverage hf hf'
-#align measure_theory.to_real_set_laverage MeasureTheory.toReal_set_laverage
+#align measure_theory.to_real_set_laverage MeasureTheory.toReal_setLaverage
+-/
 
 /-! ### First moment method -/
 
@@ -740,9 +800,10 @@ section FirstMomentEnnreal
 
 variable {N : Set α} {f : α → ℝ≥0∞}
 
+#print MeasureTheory.measure_le_setLaverage_pos /-
 /-- **First moment method**. A measurable function is smaller than its mean on a set of positive
 measure. -/
-theorem measure_le_set_laverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
+theorem measure_le_setLaverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
     (hf : AEMeasurable f (μ.restrict s)) : 0 < μ ({x ∈ s | f x ≤ ⨍⁻ a in s, f a ∂μ}) :=
   by
   obtain h | h := eq_or_ne (∫⁻ a in s, f a ∂μ) ∞
@@ -762,11 +823,13 @@ theorem measure_le_set_laverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
   rwa [← to_real_laverage hf, to_real_le_to_real hx (set_laverage_lt_top h).Ne] at hfx 
   · simp_rw [ae_iff, not_ne_iff]
     exact measure_eq_top_of_lintegral_ne_top hf h
-#align measure_theory.measure_le_set_laverage_pos MeasureTheory.measure_le_set_laverage_pos
+#align measure_theory.measure_le_set_laverage_pos MeasureTheory.measure_le_setLaverage_pos
+-/
 
+#print MeasureTheory.measure_setLaverage_le_pos /-
 /-- **First moment method**. A measurable function is greater than its mean on a set of positive
 measure. -/
-theorem measure_set_laverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
+theorem measure_setLaverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
     (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : 0 < μ ({x ∈ s | ⨍⁻ a in s, f a ∂μ ≤ f x}) :=
   by
   obtain hμ₁ | hμ₁ := eq_or_ne (μ s) ∞
@@ -787,22 +850,28 @@ theorem measure_set_laverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s
   exact hfx.trans (hgf _)
   · simp_rw [ae_iff, not_ne_iff]
     exact measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint
-#align measure_theory.measure_set_laverage_le_pos MeasureTheory.measure_set_laverage_le_pos
+#align measure_theory.measure_set_laverage_le_pos MeasureTheory.measure_setLaverage_le_pos
+-/
 
+#print MeasureTheory.exists_le_setLaverage /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
-theorem exists_le_set_laverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : AEMeasurable f (μ.restrict s)) :
+theorem exists_le_setLaverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : AEMeasurable f (μ.restrict s)) :
     ∃ x ∈ s, f x ≤ ⨍⁻ a in s, f a ∂μ :=
-  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_set_laverage_pos hμ hμ₁ hf).ne'
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_setLaverage_pos hμ hμ₁ hf).ne'
   ⟨x, hx, h⟩
-#align measure_theory.exists_le_set_laverage MeasureTheory.exists_le_set_laverage
+#align measure_theory.exists_le_set_laverage MeasureTheory.exists_le_setLaverage
+-/
 
+#print MeasureTheory.exists_setLaverage_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
-theorem exists_set_laverage_le (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
+theorem exists_setLaverage_le (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
     (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : ∃ x ∈ s, ⨍⁻ a in s, f a ∂μ ≤ f x :=
-  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_set_laverage_le_pos hμ hs hint).ne'
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_setLaverage_le_pos hμ hs hint).ne'
   ⟨x, hx, h⟩
-#align measure_theory.exists_set_laverage_le MeasureTheory.exists_set_laverage_le
+#align measure_theory.exists_set_laverage_le MeasureTheory.exists_setLaverage_le
+-/
 
+#print MeasureTheory.measure_laverage_le_pos /-
 /-- **First moment method**. A measurable function is greater than its mean on a set of positive
 measure. -/
 theorem measure_laverage_le_pos (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) :
@@ -810,14 +879,18 @@ theorem measure_laverage_le_pos (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠
   simpa [hint] using
     @measure_set_laverage_le_pos _ _ _ _ f (measure_univ_ne_zero.2 hμ) null_measurable_set_univ
 #align measure_theory.measure_laverage_le_pos MeasureTheory.measure_laverage_le_pos
+-/
 
+#print MeasureTheory.exists_laverage_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
 theorem exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ⨍⁻ a, f a ∂μ ≤ f x :=
   let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_laverage_le_pos hμ hint).ne'
   ⟨x, hx⟩
 #align measure_theory.exists_laverage_le MeasureTheory.exists_laverage_le
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_laverage_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its mean, while
 avoiding a null set. -/
 theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α, f a ∂μ ≠ ∞) (hN : μ N = 0) :
@@ -828,11 +901,13 @@ theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α,
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_laverage_le MeasureTheory.exists_not_mem_null_laverage_le
+-/
 
 section FiniteMeasure
 
 variable [IsFiniteMeasure μ]
 
+#print MeasureTheory.measure_le_laverage_pos /-
 /-- **First moment method**. A measurable function is smaller than its mean on a set of positive
 measure. -/
 theorem measure_le_laverage_pos (hμ : μ ≠ 0) (hf : AEMeasurable f μ) :
@@ -840,14 +915,18 @@ theorem measure_le_laverage_pos (hμ : μ ≠ 0) (hf : AEMeasurable f μ) :
   simpa using
     measure_le_set_laverage_pos (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _) hf.restrict
 #align measure_theory.measure_le_laverage_pos MeasureTheory.measure_le_laverage_pos
+-/
 
+#print MeasureTheory.exists_le_laverage /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
 theorem exists_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) : ∃ x, f x ≤ ⨍⁻ a, f a ∂μ :=
   let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_laverage_pos hμ hf).ne'
   ⟨x, hx⟩
 #align measure_theory.exists_le_laverage MeasureTheory.exists_le_laverage
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_le_laverage /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its mean, while
 avoiding a null set. -/
 theorem exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) (hN : μ N = 0) :
@@ -858,6 +937,7 @@ theorem exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_le_laverage MeasureTheory.exists_not_mem_null_le_laverage
+-/
 
 end FiniteMeasure
 
@@ -865,32 +945,41 @@ section ProbabilityMeasure
 
 variable [IsProbabilityMeasure μ]
 
+#print MeasureTheory.measure_le_lintegral_pos /-
 /-- **First moment method**. A measurable function is smaller than its integral on a set of
 positive measure. -/
 theorem measure_le_lintegral_pos (hf : AEMeasurable f μ) : 0 < μ {x | f x ≤ ∫⁻ a, f a ∂μ} := by
   simpa only [laverage_eq_lintegral] using
     measure_le_laverage_pos (is_probability_measure.ne_zero μ) hf
 #align measure_theory.measure_le_lintegral_pos MeasureTheory.measure_le_lintegral_pos
+-/
 
+#print MeasureTheory.measure_lintegral_le_pos /-
 /-- **First moment method**. A measurable function is greater than its integral on a set of
 positive measure. -/
 theorem measure_lintegral_le_pos (hint : ∫⁻ a, f a ∂μ ≠ ∞) : 0 < μ {x | ∫⁻ a, f a ∂μ ≤ f x} := by
   simpa only [laverage_eq_lintegral] using
     measure_laverage_le_pos (is_probability_measure.ne_zero μ) hint
 #align measure_theory.measure_lintegral_le_pos MeasureTheory.measure_lintegral_le_pos
+-/
 
+#print MeasureTheory.exists_le_lintegral /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its integral. -/
 theorem exists_le_lintegral (hf : AEMeasurable f μ) : ∃ x, f x ≤ ∫⁻ a, f a ∂μ := by
   simpa only [laverage_eq_lintegral] using exists_le_laverage (is_probability_measure.ne_zero μ) hf
 #align measure_theory.exists_le_lintegral MeasureTheory.exists_le_lintegral
+-/
 
+#print MeasureTheory.exists_lintegral_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its integral. -/
 theorem exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻ a, f a ∂μ ≤ f x := by
   simpa only [laverage_eq_lintegral] using
     exists_laverage_le (is_probability_measure.ne_zero μ) hint
 #align measure_theory.exists_lintegral_le MeasureTheory.exists_lintegral_le
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_le_lintegral /-
 /-- **First moment method**. The minimum of a measurable function is smaller than its integral,
 while avoiding a null set. -/
 theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0) :
@@ -898,8 +987,10 @@ theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0
   simpa only [laverage_eq_lintegral] using
     exists_not_mem_null_le_laverage (is_probability_measure.ne_zero μ) hf hN
 #align measure_theory.exists_not_mem_null_le_lintegral MeasureTheory.exists_not_mem_null_le_lintegral
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_lintegral_le /-
 /-- **First moment method**. The maximum of a measurable function is greater than its integral,
 while avoiding a null set. -/
 theorem exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) (hN : μ N = 0) :
@@ -907,6 +998,7 @@ theorem exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) (h
   simpa only [laverage_eq_lintegral] using
     exists_not_mem_null_laverage_le (is_probability_measure.ne_zero μ) hint hN
 #align measure_theory.exists_not_mem_null_lintegral_le MeasureTheory.exists_not_mem_null_lintegral_le
+-/
 
 end ProbabilityMeasure
 
Diff
@@ -455,6 +455,7 @@ theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞)
 #align measure_theory.set_average_const MeasureTheory.set_average_const
 -/
 
+#print MeasureTheory.integral_average /-
 @[simp]
 theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
     ∫ x, ⨍ a, f a ∂μ ∂μ = ∫ x, f x ∂μ :=
@@ -465,12 +466,16 @@ theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
     rw [integral_const, average_eq,
       smul_inv_smul₀ (to_real_ne_zero.2 ⟨measure_univ_ne_zero.2 hμ, measure_ne_top _ _⟩)]
 #align measure_theory.integral_average MeasureTheory.integral_average
+-/
 
-theorem set_integral_set_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
+#print MeasureTheory.setAverage_setAverage /-
+theorem setAverage_setAverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
     ∫ x in s, ⨍ a in s, f a ∂μ ∂μ = ∫ x in s, f x ∂μ :=
   integral_average _ _
-#align measure_theory.set_integral_set_average MeasureTheory.set_integral_set_average
+#align measure_theory.set_integral_set_average MeasureTheory.setAverage_setAverage
+-/
 
+#print MeasureTheory.integral_sub_average /-
 theorem integral_sub_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
     ∫ x, f x - ⨍ a, f a ∂μ ∂μ = 0 :=
   by
@@ -480,26 +485,34 @@ theorem integral_sub_average (μ : Measure α) [IsFiniteMeasure μ] (f : α →
   convert h.add (integrable_const _)
   exact (sub_add_cancel _ _).symm
 #align measure_theory.integral_sub_average MeasureTheory.integral_sub_average
+-/
 
-theorem set_integral_sub_set_average (hs : μ s ≠ ∞) (f : α → E) :
+#print MeasureTheory.setAverage_sub_setAverage /-
+theorem setAverage_sub_setAverage (hs : μ s ≠ ∞) (f : α → E) :
     ∫ x in s, f x - ⨍ a in s, f a ∂μ ∂μ = 0 :=
   haveI haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
   integral_sub_average _ _
-#align measure_theory.set_integral_sub_set_average MeasureTheory.set_integral_sub_set_average
+#align measure_theory.set_integral_sub_set_average MeasureTheory.setAverage_sub_setAverage
+-/
 
+#print MeasureTheory.integral_average_sub /-
 theorem integral_average_sub [IsFiniteMeasure μ] (hf : Integrable f μ) :
     ∫ x, ⨍ a, f a ∂μ - f x ∂μ = 0 := by
   rw [integral_sub (integrable_const _) hf, integral_average, sub_self]
 #align measure_theory.integral_average_sub MeasureTheory.integral_average_sub
+-/
 
-theorem set_integral_set_average_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+#print MeasureTheory.setAverage_setAverage_sub /-
+theorem setAverage_setAverage_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     ∫ x in s, ⨍ a in s, f a ∂μ - f x ∂μ = 0 :=
   haveI haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
   integral_average_sub hf
-#align measure_theory.set_integral_set_average_sub MeasureTheory.set_integral_set_average_sub
+#align measure_theory.set_integral_set_average_sub MeasureTheory.setAverage_setAverage_sub
+-/
 
 end NormedAddCommGroup
 
+#print MeasureTheory.ofReal_average /-
 theorem ofReal_average {f : α → ℝ} (hf : Integrable f μ) (hf₀ : 0 ≤ᵐ[μ] f) :
     ENNReal.ofReal (⨍ x, f x ∂μ) = (∫⁻ x, ENNReal.ofReal (f x) ∂μ) / μ univ :=
   by
@@ -510,11 +523,14 @@ theorem ofReal_average {f : α → ℝ} (hf : Integrable f μ) (hf₀ : 0 ≤ᵐ
       of_real_to_real (inv_ne_top.2 <| measure_univ_ne_zero.2 hμ),
       of_real_integral_eq_lintegral_of_real hf hf₀, ENNReal.div_eq_inv_mul]
 #align measure_theory.of_real_average MeasureTheory.ofReal_average
+-/
 
-theorem ofReal_set_average {f : α → ℝ} (hf : IntegrableOn f s μ) (hf₀ : 0 ≤ᵐ[μ.restrict s] f) :
+#print MeasureTheory.ofReal_setAverage /-
+theorem ofReal_setAverage {f : α → ℝ} (hf : IntegrableOn f s μ) (hf₀ : 0 ≤ᵐ[μ.restrict s] f) :
     ENNReal.ofReal (⨍ x in s, f x ∂μ) = (∫⁻ x in s, ENNReal.ofReal (f x) ∂μ) / μ s := by
   simpa using of_real_average hf hf₀
-#align measure_theory.of_real_set_average MeasureTheory.ofReal_set_average
+#align measure_theory.of_real_set_average MeasureTheory.ofReal_setAverage
+-/
 
 theorem toReal_laverage {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
     (⨍⁻ x, f x ∂μ).toReal = ⨍ x, (f x).toReal ∂μ :=
@@ -539,9 +555,10 @@ section FirstMomentReal
 
 variable {N : Set α} {f : α → ℝ}
 
+#print MeasureTheory.measure_le_setAverage_pos /-
 /-- **First moment method**. An integrable function is smaller than its mean on a set of positive
 measure. -/
-theorem measure_le_set_average_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+theorem measure_le_setAverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     0 < μ ({x ∈ s | f x ≤ ⨍ a in s, f a ∂μ}) :=
   by
   refine' pos_iff_ne_zero.2 fun H => _
@@ -559,33 +576,41 @@ theorem measure_le_set_average_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (h
   · rwa [pos_iff_ne_zero, inter_comm, ← diff_compl, ← diff_inter_self_eq_diff, measure_diff_null]
     refine' eq_bot_mono (measure_mono _) (measure_inter_eq_zero_of_restrict H)
     exact inter_subset_inter_left _ fun a ha => (sub_eq_zero.1 <| of_not_not ha).le
-#align measure_theory.measure_le_set_average_pos MeasureTheory.measure_le_set_average_pos
+#align measure_theory.measure_le_set_average_pos MeasureTheory.measure_le_setAverage_pos
+-/
 
+#print MeasureTheory.measure_setAverage_le_pos /-
 /-- **First moment method**. An integrable function is greater than its mean on a set of positive
 measure. -/
-theorem measure_set_average_le_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+theorem measure_setAverage_le_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     0 < μ ({x ∈ s | ⨍ a in s, f a ∂μ ≤ f x}) := by
   simpa [integral_neg, neg_div] using measure_le_set_average_pos hμ hμ₁ hf.neg
-#align measure_theory.measure_set_average_le_pos MeasureTheory.measure_set_average_le_pos
+#align measure_theory.measure_set_average_le_pos MeasureTheory.measure_setAverage_le_pos
+-/
 
+#print MeasureTheory.exists_le_setAverage /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
-theorem exists_le_set_average (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+theorem exists_le_setAverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     ∃ x ∈ s, f x ≤ ⨍ a in s, f a ∂μ :=
-  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_set_average_pos hμ hμ₁ hf).ne'
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_setAverage_pos hμ hμ₁ hf).ne'
   ⟨x, hx, h⟩
-#align measure_theory.exists_le_set_average MeasureTheory.exists_le_set_average
+#align measure_theory.exists_le_set_average MeasureTheory.exists_le_setAverage
+-/
 
+#print MeasureTheory.exists_setAverage_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
-theorem exists_set_average_le (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+theorem exists_setAverage_le (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     ∃ x ∈ s, ⨍ a in s, f a ∂μ ≤ f x :=
-  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_set_average_le_pos hμ hμ₁ hf).ne'
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_setAverage_le_pos hμ hμ₁ hf).ne'
   ⟨x, hx, h⟩
-#align measure_theory.exists_set_average_le MeasureTheory.exists_set_average_le
+#align measure_theory.exists_set_average_le MeasureTheory.exists_setAverage_le
+-/
 
 section FiniteMeasure
 
 variable [IsFiniteMeasure μ]
 
+#print MeasureTheory.measure_le_average_pos /-
 /-- **First moment method**. An integrable function is smaller than its mean on a set of positive
 measure. -/
 theorem measure_le_average_pos (hμ : μ ≠ 0) (hf : Integrable f μ) : 0 < μ {x | f x ≤ ⨍ a, f a ∂μ} :=
@@ -594,7 +619,9 @@ theorem measure_le_average_pos (hμ : μ ≠ 0) (hf : Integrable f μ) : 0 < μ
     measure_le_set_average_pos (measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
       hf.integrable_on
 #align measure_theory.measure_le_average_pos MeasureTheory.measure_le_average_pos
+-/
 
+#print MeasureTheory.measure_average_le_pos /-
 /-- **First moment method**. An integrable function is greater than its mean on a set of positive
 measure. -/
 theorem measure_average_le_pos (hμ : μ ≠ 0) (hf : Integrable f μ) : 0 < μ {x | ⨍ a, f a ∂μ ≤ f x} :=
@@ -603,20 +630,26 @@ theorem measure_average_le_pos (hμ : μ ≠ 0) (hf : Integrable f μ) : 0 < μ
     measure_set_average_le_pos (measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
       hf.integrable_on
 #align measure_theory.measure_average_le_pos MeasureTheory.measure_average_le_pos
+-/
 
+#print MeasureTheory.exists_le_average /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
 theorem exists_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, f x ≤ ⨍ a, f a ∂μ :=
   let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_average_pos hμ hf).ne'
   ⟨x, hx⟩
 #align measure_theory.exists_le_average MeasureTheory.exists_le_average
+-/
 
+#print MeasureTheory.exists_average_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
 theorem exists_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, ⨍ a, f a ∂μ ≤ f x :=
   let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_average_le_pos hμ hf).ne'
   ⟨x, hx⟩
 #align measure_theory.exists_average_le MeasureTheory.exists_average_le
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_le_average /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its mean, while
 avoiding a null set. -/
 theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (hN : μ N = 0) :
@@ -627,14 +660,17 @@ theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_le_average MeasureTheory.exists_not_mem_null_le_average
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_average_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its mean, while
 avoiding a null set. -/
 theorem exists_not_mem_null_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) (hN : μ N = 0) :
     ∃ (x : _) (_ : x ∉ N), ⨍ a, f a ∂μ ≤ f x := by
   simpa [integral_neg, neg_div] using exists_not_mem_null_le_average hμ hf.neg hN
 #align measure_theory.exists_not_mem_null_average_le MeasureTheory.exists_not_mem_null_average_le
+-/
 
 end FiniteMeasure
 
@@ -642,31 +678,40 @@ section ProbabilityMeasure
 
 variable [IsProbabilityMeasure μ]
 
+#print MeasureTheory.measure_le_integral_pos /-
 /-- **First moment method**. An integrable function is smaller than its integral on a set of
 positive measure. -/
 theorem measure_le_integral_pos (hf : Integrable f μ) : 0 < μ {x | f x ≤ ∫ a, f a ∂μ} := by
   simpa only [average_eq_integral] using
     measure_le_average_pos (is_probability_measure.ne_zero μ) hf
 #align measure_theory.measure_le_integral_pos MeasureTheory.measure_le_integral_pos
+-/
 
+#print MeasureTheory.measure_integral_le_pos /-
 /-- **First moment method**. An integrable function is greater than its integral on a set of
 positive measure. -/
 theorem measure_integral_le_pos (hf : Integrable f μ) : 0 < μ {x | ∫ a, f a ∂μ ≤ f x} := by
   simpa only [average_eq_integral] using
     measure_average_le_pos (is_probability_measure.ne_zero μ) hf
 #align measure_theory.measure_integral_le_pos MeasureTheory.measure_integral_le_pos
+-/
 
+#print MeasureTheory.exists_le_integral /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its integral. -/
 theorem exists_le_integral (hf : Integrable f μ) : ∃ x, f x ≤ ∫ a, f a ∂μ := by
   simpa only [average_eq_integral] using exists_le_average (is_probability_measure.ne_zero μ) hf
 #align measure_theory.exists_le_integral MeasureTheory.exists_le_integral
+-/
 
+#print MeasureTheory.exists_integral_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its integral. -/
 theorem exists_integral_le (hf : Integrable f μ) : ∃ x, ∫ a, f a ∂μ ≤ f x := by
   simpa only [average_eq_integral] using exists_average_le (is_probability_measure.ne_zero μ) hf
 #align measure_theory.exists_integral_le MeasureTheory.exists_integral_le
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_le_integral /-
 /-- **First moment method**. The minimum of an integrable function is smaller than its integral,
 while avoiding a null set. -/
 theorem exists_not_mem_null_le_integral (hf : Integrable f μ) (hN : μ N = 0) :
@@ -674,8 +719,10 @@ theorem exists_not_mem_null_le_integral (hf : Integrable f μ) (hN : μ N = 0) :
   simpa only [average_eq_integral] using
     exists_not_mem_null_le_average (is_probability_measure.ne_zero μ) hf hN
 #align measure_theory.exists_not_mem_null_le_integral MeasureTheory.exists_not_mem_null_le_integral
+-/
 
 /- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+#print MeasureTheory.exists_not_mem_null_integral_le /-
 /-- **First moment method**. The maximum of an integrable function is greater than its integral,
 while avoiding a null set. -/
 theorem exists_not_mem_null_integral_le (hf : Integrable f μ) (hN : μ N = 0) :
@@ -683,6 +730,7 @@ theorem exists_not_mem_null_integral_le (hf : Integrable f μ) (hN : μ N = 0) :
   simpa only [average_eq_integral] using
     exists_not_mem_null_average_le (is_probability_measure.ne_zero μ) hf hN
 #align measure_theory.exists_not_mem_null_integral_le MeasureTheory.exists_not_mem_null_integral_le
+-/
 
 end ProbabilityMeasure
 
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury G. Kudryashov, Yaël Dillies
 
 ! This file was ported from Lean 3 source module measure_theory.integral.average
-! leanprover-community/mathlib commit ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f
+! leanprover-community/mathlib commit c14c8fcde993801fca8946b0d80131a1a81d1520
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -24,6 +24,8 @@ measure, then the average of any function is equal to its integral.
 For the average on a set, we use `⨍ x in s, f x ∂μ` (notation for `⨍ x, f x ∂(μ.restrict s)`). For
 average w.r.t. the volume, one can omit `∂volume`.
 
+Both have a version for the Lebesgue integral rather than Bochner.
+
 We prove several version of the first moment method: An integrable function is below/above its
 average on a set of positive measure.
 
@@ -33,11 +35,6 @@ The average is defined as an integral over `(μ univ)⁻¹ • μ` so that all t
 integrals work for the average without modifications. For theorems that require integrability of a
 function, we provide a convenience lemma `measure_theory.integrable.to_average`.
 
-## TODO
-
-Provide the first moment method for the Lebesgue integral as well. A draft is available on branch
-`first_moment_lintegral`.
-
 ## Tags
 
 integral, center mass, average value
@@ -49,22 +46,208 @@ open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSp
 open scoped Topology BigOperators ENNReal Convex
 
 variable {α E F : Type _} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
-  [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ : Measure α}
+  [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ ν : Measure α}
   {s t : Set α}
 
 /-!
 ### Average value of a function w.r.t. a measure
 
-The average value of a function `f` w.r.t. a measure `μ` (notation: `⨍ x, f x ∂μ`) is defined as
-`(μ univ).to_real⁻¹ • ∫ x, f x ∂μ`, so it is equal to zero if `f` is not integrable or if `μ` is an
-infinite measure. If `μ` is a probability measure, then the average of any function is equal to its
-integral.
-
+The (Bochner, Lebesgue) average value of a function `f` w.r.t. a measure `μ` (notation:
+`⨍ x, f x ∂μ`, `⨍⁻ x, f x ∂μ`) is defined as the (Bochner, Lebesgue) integral divided by the total
+measure, so it is equal to zero if `μ` is an infinite measure, and (typically) equal to infinity if
+`f` is not integrable. If `μ` is a probability measure, then the average of any function is equal to
+its integral.
 -/
 
 
 namespace MeasureTheory
 
+section ENNReal
+
+variable (μ) {f g : α → ℝ≥0∞}
+
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`, notation: `⨍⁻ x, f x ∂μ`.
+It is defined as `μ univ⁻¹ * ∫⁻ x, f x ∂μ`, so it is equal to zero if `μ` is an infinite measure. If
+`μ` is a probability measure, then the average of any function is equal to its integral.
+
+For the average on a set, use `⨍⁻ x in s, f x ∂μ` (defined as `⨍⁻ x, f x ∂(μ.restrict s)`). For
+average w.r.t. the volume, one can omit `∂volume`. -/
+noncomputable def laverage (f : α → ℝ≥0∞) :=
+  ∫⁻ x, f x ∂(μ univ)⁻¹ • μ
+#align measure_theory.laverage MeasureTheory.laverage
+
+notation3"⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r
+
+notation3"⨍⁻ "(...)", "r:60:(scoped f => laverage volume f) => r
+
+notation3"⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (Measure.restrict μ s) r
+
+notation3"⨍⁻ "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r
+
+@[simp]
+theorem laverage_zero : ⨍⁻ x, (0 : ℝ≥0∞) ∂μ = 0 := by rw [laverage, lintegral_zero]
+#align measure_theory.laverage_zero MeasureTheory.laverage_zero
+
+@[simp]
+theorem laverage_zero_measure (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂(0 : Measure α) = 0 := by simp [laverage]
+#align measure_theory.laverage_zero_measure MeasureTheory.laverage_zero_measure
+
+theorem laverage_eq' (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂(μ univ)⁻¹ • μ :=
+  rfl
+#align measure_theory.laverage_eq' MeasureTheory.laverage_eq'
+
+theorem laverage_eq (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = (∫⁻ x, f x ∂μ) / μ univ := by
+  rw [laverage_eq', lintegral_smul_measure, ENNReal.div_eq_inv_mul]
+#align measure_theory.laverage_eq MeasureTheory.laverage_eq
+
+theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞) :
+    ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [laverage, measure_univ, inv_one, one_smul]
+#align measure_theory.laverage_eq_lintegral MeasureTheory.laverage_eq_lintegral
+
+@[simp]
+theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
+    μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ :=
+  by
+  cases' eq_or_ne μ 0 with hμ hμ
+  · rw [hμ, lintegral_zero_measure, laverage_zero_measure, MulZeroClass.mul_zero]
+  · rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
+#align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage
+
+theorem set_laverage_eq (f : α → ℝ≥0∞) (s : Set α) :
+    ⨍⁻ x in s, f x ∂μ = (∫⁻ x in s, f x ∂μ) / μ s := by rw [laverage_eq, restrict_apply_univ]
+#align measure_theory.set_laverage_eq MeasureTheory.set_laverage_eq
+
+theorem set_laverage_eq' (f : α → ℝ≥0∞) (s : Set α) :
+    ⨍⁻ x in s, f x ∂μ = ∫⁻ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
+  simp only [laverage_eq', restrict_apply_univ]
+#align measure_theory.set_laverage_eq' MeasureTheory.set_laverage_eq'
+
+variable {μ}
+
+theorem laverage_congr {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ⨍⁻ x, f x ∂μ = ⨍⁻ x, g x ∂μ := by
+  simp only [laverage_eq, lintegral_congr_ae h]
+#align measure_theory.laverage_congr MeasureTheory.laverage_congr
+
+theorem set_laverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ := by
+  simp only [set_laverage_eq, set_lintegral_congr h, measure_congr h]
+#align measure_theory.set_laverage_congr MeasureTheory.set_laverage_congr
+
+theorem set_laverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+    ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in s, g x ∂μ := by
+  simp only [laverage_eq, set_lintegral_congr_fun hs h]
+#align measure_theory.set_laverage_congr_fun MeasureTheory.set_laverage_congr_fun
+
+theorem laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ < ∞ :=
+  by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp
+  · rw [laverage_eq]
+    exact div_lt_top hf (measure_univ_ne_zero.2 hμ)
+#align measure_theory.laverage_lt_top MeasureTheory.laverage_lt_top
+
+theorem set_laverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ :=
+  laverage_lt_top
+#align measure_theory.set_laverage_lt_top MeasureTheory.set_laverage_lt_top
+
+theorem laverage_add_measure :
+    ⨍⁻ x, f x ∂(μ + ν) =
+      μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν :=
+  by
+  by_cases hμ : is_finite_measure μ; swap
+  · rw [not_is_finite_measure_iff] at hμ 
+    simp [laverage_eq, hμ]
+  by_cases hν : is_finite_measure ν; swap
+  · rw [not_is_finite_measure_iff] at hν 
+    simp [laverage_eq, hν]
+  haveI := hμ; haveI := hν
+  simp only [← ENNReal.mul_div_right_comm, measure_mul_laverage, ← ENNReal.add_div, ←
+    lintegral_add_measure, ← measure.add_apply, ← laverage_eq]
+#align measure_theory.laverage_add_measure MeasureTheory.laverage_add_measure
+
+theorem measure_mul_set_laverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) :
+    μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ := by haveI := Fact.mk h.lt_top;
+  rw [← measure_mul_laverage, restrict_apply_univ]
+#align measure_theory.measure_mul_set_laverage MeasureTheory.measure_mul_set_laverage
+
+theorem laverage_union (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) :
+    ⨍⁻ x in s ∪ t, f x ∂μ =
+      μ s / (μ s + μ t) * ⨍⁻ x in s, f x ∂μ + μ t / (μ s + μ t) * ⨍⁻ x in t, f x ∂μ :=
+  by rw [restrict_union₀ hd ht, laverage_add_measure, restrict_apply_univ, restrict_apply_univ]
+#align measure_theory.laverage_union MeasureTheory.laverage_union
+
+theorem laverage_union_mem_openSegment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
+    (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
+    ⨍⁻ x in s ∪ t, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in t, f x ∂μ) :=
+  by
+  refine'
+    ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), ENNReal.div_pos hs₀ <| add_ne_top.2 ⟨hsμ, htμ⟩,
+      ENNReal.div_pos ht₀ <| add_ne_top.2 ⟨hsμ, htμ⟩, _, (laverage_union hd ht).symm⟩
+  rw [← ENNReal.add_div,
+    ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
+#align measure_theory.laverage_union_mem_open_segment MeasureTheory.laverage_union_mem_openSegment
+
+theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
+    (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
+    ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ] :=
+  by
+  by_cases hs₀ : μ s = 0
+  · rw [← ae_eq_empty] at hs₀ 
+    rw [restrict_congr_set (hs₀.union eventually_eq.rfl), empty_union]
+    exact right_mem_segment _ _ _
+  · refine'
+      ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), zero_le _, zero_le _, _, (laverage_union hd ht).symm⟩
+    rw [← ENNReal.add_div,
+      ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
+#align measure_theory.laverage_union_mem_segment MeasureTheory.laverage_union_mem_segment
+
+theorem laverage_mem_openSegment_compl_self [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ)
+    (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) :
+    ⨍⁻ x, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in sᶜ, f x ∂μ) := by
+  simpa only [union_compl_self, restrict_univ] using
+    laverage_union_mem_open_segment ae_disjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _)
+      (measure_ne_top _ _)
+#align measure_theory.laverage_mem_open_segment_compl_self MeasureTheory.laverage_mem_openSegment_compl_self
+
+@[simp]
+theorem laverage_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : ℝ≥0∞) :
+    ⨍⁻ x, c ∂μ = c := by
+  simp only [laverage_eq, lintegral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
+    div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel, mul_one, measure_ne_top μ univ, Ne.def,
+    measure_univ_ne_zero, ae_ne_bot.1 h, not_false_iff]
+#align measure_theory.laverage_const MeasureTheory.laverage_const
+
+theorem set_laverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0∞) : ⨍⁻ x in s, c ∂μ = c := by
+  simp only [set_laverage_eq, lintegral_const, measure.restrict_apply, MeasurableSet.univ,
+    univ_inter, div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel hs₀ hs, mul_one]
+#align measure_theory.set_laverage_const MeasureTheory.set_laverage_const
+
+@[simp]
+theorem laverage_one [IsFiniteMeasure μ] [h : μ.ae.ne_bot] : ⨍⁻ x, (1 : ℝ≥0∞) ∂μ = 1 :=
+  laverage_const _ _
+#align measure_theory.laverage_one MeasureTheory.laverage_one
+
+theorem set_laverage_one (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) : ⨍⁻ x in s, (1 : ℝ≥0∞) ∂μ = 1 :=
+  set_laverage_const hs₀ hs _
+#align measure_theory.set_laverage_one MeasureTheory.set_laverage_one
+
+@[simp]
+theorem lintegral_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
+    ∫⁻ x, ⨍⁻ a, f a ∂μ ∂μ = ∫⁻ x, f x ∂μ :=
+  by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp
+  ·
+    rw [lintegral_const, laverage_eq,
+      ENNReal.div_mul_cancel (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
+#align measure_theory.lintegral_laverage MeasureTheory.lintegral_laverage
+
+theorem set_lintegral_set_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) (s : Set α) :
+    ∫⁻ x in s, ⨍⁻ a in s, f a ∂μ ∂μ = ∫⁻ x in s, f x ∂μ :=
+  lintegral_laverage _ _
+#align measure_theory.set_lintegral_set_laverage MeasureTheory.set_lintegral_set_laverage
+
+end ENNReal
+
 section NormedAddCommGroup
 
 variable (μ) {f g : α → E}
@@ -162,9 +345,13 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = 
 #align measure_theory.average_congr MeasureTheory.average_congr
 -/
 
-theorem set_average_congr_set_ae (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
+theorem set_average_congr (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
   simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
-#align measure_theory.set_average_congr_set_ae MeasureTheory.set_average_congr_set_ae
+#align measure_theory.set_average_congr MeasureTheory.set_average_congr
+
+theorem set_average_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+    ⨍ x in s, f x ∂μ = ⨍ x in s, g x ∂μ := by simp only [average_eq, set_integral_congr_ae hs h]
+#align measure_theory.set_average_congr_fun MeasureTheory.set_average_congr_fun
 
 #print MeasureTheory.average_add_measure /-
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
@@ -250,7 +437,8 @@ theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {
 
 #print MeasureTheory.average_const /-
 @[simp]
-theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : ⨍ x, c ∂μ = c := by
+theorem average_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) :
+    ⨍ x, c ∂μ = c := by
   simp only [average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, one_smul,
     univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_ne_bot.1 h, not_false_iff,
@@ -328,26 +516,26 @@ theorem ofReal_set_average {f : α → ℝ} (hf : IntegrableOn f s μ) (hf₀ :
   simpa using of_real_average hf hf₀
 #align measure_theory.of_real_set_average MeasureTheory.ofReal_set_average
 
-theorem average_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
-    ⨍ x, (f x).toReal ∂μ = ((∫⁻ x, f x ∂μ) / μ univ).toReal :=
+theorem toReal_laverage {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
+    (⨍⁻ x, f x ∂μ).toReal = ⨍ x, (f x).toReal ∂μ :=
   by
   obtain rfl | hμ := eq_or_ne μ 0
   · simp
   ·
-    rw [average_eq, smul_eq_mul, to_real_div, ←
-      integral_to_real hf (hf'.mono fun _ => lt_top_iff_ne_top.2), div_eq_inv_mul]
-#align measure_theory.average_to_real MeasureTheory.average_toReal
+    rw [average_eq, laverage_eq, smul_eq_mul, to_real_div, div_eq_inv_mul, ←
+      integral_to_real hf (hf'.mono fun _ => lt_top_iff_ne_top.2)]
+#align measure_theory.to_real_laverage MeasureTheory.toReal_laverage
 
-theorem set_average_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
+theorem toReal_set_laverage {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
     (hf' : ∀ᵐ x ∂μ.restrict s, f x ≠ ∞) :
-    ⨍ x in s, (f x).toReal ∂μ = ((∫⁻ x in s, f x ∂μ) / μ s).toReal := by
-  simpa using average_to_real hf hf'
-#align measure_theory.set_average_to_real MeasureTheory.set_average_toReal
+    ((∫⁻ x in s, f x ∂μ) / μ s).toReal = ⨍ x in s, (f x).toReal ∂μ := by
+  simpa [laverage_eq] using to_real_laverage hf hf'
+#align measure_theory.to_real_set_laverage MeasureTheory.toReal_set_laverage
 
 /-! ### First moment method -/
 
 
-section FirstMoment
+section FirstMomentReal
 
 variable {N : Set α} {f : α → ℝ}
 
@@ -498,7 +686,183 @@ theorem exists_not_mem_null_integral_le (hf : Integrable f μ) (hN : μ N = 0) :
 
 end ProbabilityMeasure
 
-end FirstMoment
+end FirstMomentReal
+
+section FirstMomentEnnreal
+
+variable {N : Set α} {f : α → ℝ≥0∞}
+
+/-- **First moment method**. A measurable function is smaller than its mean on a set of positive
+measure. -/
+theorem measure_le_set_laverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
+    (hf : AEMeasurable f (μ.restrict s)) : 0 < μ ({x ∈ s | f x ≤ ⨍⁻ a in s, f a ∂μ}) :=
+  by
+  obtain h | h := eq_or_ne (∫⁻ a in s, f a ∂μ) ∞
+  · simpa [mul_top, hμ₁, laverage, h, top_div_of_ne_top hμ₁, pos_iff_ne_zero] using hμ
+  have := measure_le_set_average_pos hμ hμ₁ (integrable_to_real_of_lintegral_ne_top hf h)
+  rw [← set_of_inter_eq_sep, ←
+    measure.restrict_apply₀
+      (hf.ae_strongly_measurable.null_measurable_set_le ae_strongly_measurable_const)]
+  rw [← set_of_inter_eq_sep, ←
+    measure.restrict_apply₀
+      (hf.ennreal_to_real.ae_strongly_measurable.null_measurable_set_le
+        ae_strongly_measurable_const),
+    ← measure_diff_null (measure_eq_top_of_lintegral_ne_top hf h)] at this 
+  refine' this.trans_le (measure_mono _)
+  rintro x ⟨hfx, hx⟩
+  dsimp at hfx 
+  rwa [← to_real_laverage hf, to_real_le_to_real hx (set_laverage_lt_top h).Ne] at hfx 
+  · simp_rw [ae_iff, not_ne_iff]
+    exact measure_eq_top_of_lintegral_ne_top hf h
+#align measure_theory.measure_le_set_laverage_pos MeasureTheory.measure_le_set_laverage_pos
+
+/-- **First moment method**. A measurable function is greater than its mean on a set of positive
+measure. -/
+theorem measure_set_laverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
+    (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : 0 < μ ({x ∈ s | ⨍⁻ a in s, f a ∂μ ≤ f x}) :=
+  by
+  obtain hμ₁ | hμ₁ := eq_or_ne (μ s) ∞
+  · simp [set_laverage_eq, hμ₁]
+  obtain ⟨g, hg, hgf, hfg⟩ := exists_measurable_le_lintegral_eq (μ.restrict s) f
+  have hfg' : ⨍⁻ a in s, f a ∂μ = ⨍⁻ a in s, g a ∂μ := by simp_rw [laverage_eq, hfg]
+  rw [hfg] at hint 
+  have :=
+    measure_set_average_le_pos hμ hμ₁ (integrable_to_real_of_lintegral_ne_top hg.ae_measurable hint)
+  simp_rw [← set_of_inter_eq_sep, ← measure.restrict_apply₀' hs, hfg']
+  rw [← set_of_inter_eq_sep, ← measure.restrict_apply₀' hs, ←
+    measure_diff_null (measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint)] at this 
+  refine' this.trans_le (measure_mono _)
+  rintro x ⟨hfx, hx⟩
+  dsimp at hfx 
+  rw [← to_real_laverage hg.ae_measurable, to_real_le_to_real (set_laverage_lt_top hint).Ne hx] at
+    hfx 
+  exact hfx.trans (hgf _)
+  · simp_rw [ae_iff, not_ne_iff]
+    exact measure_eq_top_of_lintegral_ne_top hg.ae_measurable hint
+#align measure_theory.measure_set_laverage_le_pos MeasureTheory.measure_set_laverage_le_pos
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
+theorem exists_le_set_laverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : AEMeasurable f (μ.restrict s)) :
+    ∃ x ∈ s, f x ≤ ⨍⁻ a in s, f a ∂μ :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_set_laverage_pos hμ hμ₁ hf).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_le_set_laverage MeasureTheory.exists_le_set_laverage
+
+/-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
+theorem exists_set_laverage_le (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
+    (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : ∃ x ∈ s, ⨍⁻ a in s, f a ∂μ ≤ f x :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_set_laverage_le_pos hμ hs hint).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_set_laverage_le MeasureTheory.exists_set_laverage_le
+
+/-- **First moment method**. A measurable function is greater than its mean on a set of positive
+measure. -/
+theorem measure_laverage_le_pos (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) :
+    0 < μ {x | ⨍⁻ a, f a ∂μ ≤ f x} := by
+  simpa [hint] using
+    @measure_set_laverage_le_pos _ _ _ _ f (measure_univ_ne_zero.2 hμ) null_measurable_set_univ
+#align measure_theory.measure_laverage_le_pos MeasureTheory.measure_laverage_le_pos
+
+/-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
+theorem exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ⨍⁻ a, f a ∂μ ≤ f x :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_laverage_le_pos hμ hint).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_laverage_le MeasureTheory.exists_laverage_le
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The maximum of a measurable function is greater than its mean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α, f a ∂μ ≠ ∞) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), ⨍⁻ a, f a ∂μ ≤ f x :=
+  by
+  have := measure_laverage_le_pos hμ hint
+  rw [← measure_diff_null hN] at this 
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
+  exact ⟨x, hxN, hx⟩
+#align measure_theory.exists_not_mem_null_laverage_le MeasureTheory.exists_not_mem_null_laverage_le
+
+section FiniteMeasure
+
+variable [IsFiniteMeasure μ]
+
+/-- **First moment method**. A measurable function is smaller than its mean on a set of positive
+measure. -/
+theorem measure_le_laverage_pos (hμ : μ ≠ 0) (hf : AEMeasurable f μ) :
+    0 < μ {x | f x ≤ ⨍⁻ a, f a ∂μ} := by
+  simpa using
+    measure_le_set_laverage_pos (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _) hf.restrict
+#align measure_theory.measure_le_laverage_pos MeasureTheory.measure_le_laverage_pos
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
+theorem exists_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) : ∃ x, f x ≤ ⨍⁻ a, f a ∂μ :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_laverage_pos hμ hf).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_le_laverage MeasureTheory.exists_le_laverage
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), f x ≤ ⨍⁻ a, f a ∂μ :=
+  by
+  have := measure_le_laverage_pos hμ hf
+  rw [← measure_diff_null hN] at this 
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
+  exact ⟨x, hxN, hx⟩
+#align measure_theory.exists_not_mem_null_le_laverage MeasureTheory.exists_not_mem_null_le_laverage
+
+end FiniteMeasure
+
+section ProbabilityMeasure
+
+variable [IsProbabilityMeasure μ]
+
+/-- **First moment method**. A measurable function is smaller than its integral on a set of
+positive measure. -/
+theorem measure_le_lintegral_pos (hf : AEMeasurable f μ) : 0 < μ {x | f x ≤ ∫⁻ a, f a ∂μ} := by
+  simpa only [laverage_eq_lintegral] using
+    measure_le_laverage_pos (is_probability_measure.ne_zero μ) hf
+#align measure_theory.measure_le_lintegral_pos MeasureTheory.measure_le_lintegral_pos
+
+/-- **First moment method**. A measurable function is greater than its integral on a set of
+positive measure. -/
+theorem measure_lintegral_le_pos (hint : ∫⁻ a, f a ∂μ ≠ ∞) : 0 < μ {x | ∫⁻ a, f a ∂μ ≤ f x} := by
+  simpa only [laverage_eq_lintegral] using
+    measure_laverage_le_pos (is_probability_measure.ne_zero μ) hint
+#align measure_theory.measure_lintegral_le_pos MeasureTheory.measure_lintegral_le_pos
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its integral. -/
+theorem exists_le_lintegral (hf : AEMeasurable f μ) : ∃ x, f x ≤ ∫⁻ a, f a ∂μ := by
+  simpa only [laverage_eq_lintegral] using exists_le_laverage (is_probability_measure.ne_zero μ) hf
+#align measure_theory.exists_le_lintegral MeasureTheory.exists_le_lintegral
+
+/-- **First moment method**. The maximum of a measurable function is greater than its integral. -/
+theorem exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻ a, f a ∂μ ≤ f x := by
+  simpa only [laverage_eq_lintegral] using
+    exists_laverage_le (is_probability_measure.ne_zero μ) hint
+#align measure_theory.exists_lintegral_le MeasureTheory.exists_lintegral_le
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The minimum of a measurable function is smaller than its integral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), f x ≤ ∫⁻ a, f a ∂μ := by
+  simpa only [laverage_eq_lintegral] using
+    exists_not_mem_null_le_laverage (is_probability_measure.ne_zero μ) hf hN
+#align measure_theory.exists_not_mem_null_le_lintegral MeasureTheory.exists_not_mem_null_le_lintegral
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The maximum of a measurable function is greater than its integral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), ∫⁻ a, f a ∂μ ≤ f x := by
+  simpa only [laverage_eq_lintegral] using
+    exists_not_mem_null_laverage_le (is_probability_measure.ne_zero μ) hint hN
+#align measure_theory.exists_not_mem_null_lintegral_le MeasureTheory.exists_not_mem_null_lintegral_le
+
+end ProbabilityMeasure
+
+end FirstMomentEnnreal
 
 end MeasureTheory
 
Diff
@@ -69,8 +69,6 @@ section NormedAddCommGroup
 
 variable (μ) {f g : α → E}
 
-include m0
-
 #print MeasureTheory.average /-
 /-- Average value of a function `f` w.r.t. a measure `μ`, notation: `⨍ x, f x ∂μ`. It is defined as
 `(μ univ).to_real⁻¹ • ∫ x, f x ∂μ`, so it is equal to zero if `f` is not integrable or if `μ` is an
@@ -84,44 +82,53 @@ noncomputable def average (f : α → E) :=
 #align measure_theory.average MeasureTheory.average
 -/
 
--- mathport name: «expr⨍ , ∂ »
 notation3"⨍ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => average μ r
 
--- mathport name: «expr⨍ , »
 notation3"⨍ "(...)", "r:60:(scoped f => average volume f) => r
 
--- mathport name: «expr⨍ in , ∂ »
 notation3"⨍ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => average (Measure.restrict μ s) r
 
--- mathport name: «expr⨍ in , »
 notation3"⨍ "(...)" in "s", "r:60:(scoped f => average Measure.restrict volume s f) => r
 
+#print MeasureTheory.average_zero /-
 @[simp]
 theorem average_zero : ⨍ x, (0 : E) ∂μ = 0 := by rw [average, integral_zero]
 #align measure_theory.average_zero MeasureTheory.average_zero
+-/
 
+#print MeasureTheory.average_zero_measure /-
 @[simp]
 theorem average_zero_measure (f : α → E) : ⨍ x, f x ∂(0 : Measure α) = 0 := by
   rw [average, smul_zero, integral_zero_measure]
 #align measure_theory.average_zero_measure MeasureTheory.average_zero_measure
+-/
 
+#print MeasureTheory.average_neg /-
 @[simp]
 theorem average_neg (f : α → E) : ⨍ x, -f x ∂μ = -⨍ x, f x ∂μ :=
   integral_neg f
 #align measure_theory.average_neg MeasureTheory.average_neg
+-/
 
+#print MeasureTheory.average_eq' /-
 theorem average_eq' (f : α → E) : ⨍ x, f x ∂μ = ∫ x, f x ∂(μ univ)⁻¹ • μ :=
   rfl
 #align measure_theory.average_eq' MeasureTheory.average_eq'
+-/
 
+#print MeasureTheory.average_eq /-
 theorem average_eq (f : α → E) : ⨍ x, f x ∂μ = (μ univ).toReal⁻¹ • ∫ x, f x ∂μ := by
   rw [average_eq', integral_smul_measure, ENNReal.toReal_inv]
 #align measure_theory.average_eq MeasureTheory.average_eq
+-/
 
+#print MeasureTheory.average_eq_integral /-
 theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : ⨍ x, f x ∂μ = ∫ x, f x ∂μ := by
   rw [average, measure_univ, inv_one, one_smul]
 #align measure_theory.average_eq_integral MeasureTheory.average_eq_integral
+-/
 
+#print MeasureTheory.measure_smul_average /-
 @[simp]
 theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
     (μ univ).toReal • ⨍ x, f x ∂μ = ∫ x, f x ∂μ :=
@@ -132,26 +139,34 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
     refine' (ENNReal.toReal_pos _ <| measure_ne_top _ _).ne'
     rwa [Ne.def, measure_univ_eq_zero]
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
+-/
 
+#print MeasureTheory.set_average_eq /-
 theorem set_average_eq (f : α → E) (s : Set α) :
     ⨍ x in s, f x ∂μ = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by rw [average_eq, restrict_apply_univ]
 #align measure_theory.set_average_eq MeasureTheory.set_average_eq
+-/
 
+#print MeasureTheory.set_average_eq' /-
 theorem set_average_eq' (f : α → E) (s : Set α) :
     ⨍ x in s, f x ∂μ = ∫ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
   simp only [average_eq', restrict_apply_univ]
 #align measure_theory.set_average_eq' MeasureTheory.set_average_eq'
+-/
 
 variable {μ}
 
+#print MeasureTheory.average_congr /-
 theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = ⨍ x, g x ∂μ := by
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
+-/
 
 theorem set_average_congr_set_ae (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
   simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
 #align measure_theory.set_average_congr_set_ae MeasureTheory.set_average_congr_set_ae
 
+#print MeasureTheory.average_add_measure /-
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
     ⨍ x, f x ∂(μ + ν) =
@@ -162,17 +177,23 @@ theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeas
     integral_add_measure hμ hν, ← ENNReal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
   rw [average_eq, measure.add_apply]
 #align measure_theory.average_add_measure MeasureTheory.average_add_measure
+-/
 
+#print MeasureTheory.average_pair /-
 theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi : Integrable g μ) :
     ⨍ x, (f x, g x) ∂μ = (⨍ x, f x ∂μ, ⨍ x, g x ∂μ) :=
   integral_pair hfi.to_average hgi.to_average
 #align measure_theory.average_pair MeasureTheory.average_pair
+-/
 
+#print MeasureTheory.measure_smul_set_average /-
 theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
     (μ s).toReal • ⨍ x in s, f x ∂μ = ∫ x in s, f x ∂μ := by haveI := Fact.mk h.lt_top;
   rw [← measure_smul_average, restrict_apply_univ]
 #align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_set_average
+-/
 
+#print MeasureTheory.average_union /-
 theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
     ⨍ x in s ∪ t, f x ∂μ =
@@ -182,7 +203,9 @@ theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht
   haveI := Fact.mk hsμ.lt_top; haveI := Fact.mk htμ.lt_top
   rw [restrict_union₀ hd ht, average_add_measure hfs hft, restrict_apply_univ, restrict_apply_univ]
 #align measure_theory.average_union MeasureTheory.average_union
+-/
 
+#print MeasureTheory.average_union_mem_openSegment /-
 theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞)
     (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
@@ -194,7 +217,9 @@ theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisj
     mem_open_segment_iff_div.mpr
       ⟨(μ s).toReal, (μ t).toReal, hs₀, ht₀, (average_union hd ht hsμ htμ hfs hft).symm⟩
 #align measure_theory.average_union_mem_open_segment MeasureTheory.average_union_mem_openSegment
+-/
 
+#print MeasureTheory.average_union_mem_segment /-
 theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ)
     (hft : IntegrableOn f t μ) : ⨍ x in s ∪ t, f x ∂μ ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] :=
@@ -211,7 +236,9 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
       0 < (μ s).toReal := ENNReal.toReal_pos hse hsμ
       _ ≤ _ := le_add_of_nonneg_right ENNReal.toReal_nonneg
 #align measure_theory.average_union_mem_segment MeasureTheory.average_union_mem_segment
+-/
 
+#print MeasureTheory.average_mem_openSegment_compl_self /-
 theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {s : Set α}
     (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) (hfi : Integrable f μ) :
     ⨍ x, f x ∂μ ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
@@ -219,7 +246,9 @@ theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {
     average_union_mem_open_segment ae_disjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _)
       (measure_ne_top _ _) hfi.integrable_on hfi.integrable_on
 #align measure_theory.average_mem_open_segment_compl_self MeasureTheory.average_mem_openSegment_compl_self
+-/
 
+#print MeasureTheory.average_const /-
 @[simp]
 theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : ⨍ x, c ∂μ = c := by
   simp only [average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, one_smul,
@@ -227,13 +256,16 @@ theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : ⨍ x, c
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_ne_bot.1 h, not_false_iff,
     ENNReal.one_toReal]
 #align measure_theory.average_const MeasureTheory.average_const
+-/
 
+#print MeasureTheory.set_average_const /-
 theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) : ⨍ x in s, c ∂μ = c :=
   by
   simp only [set_average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
     smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel hs₀ hs,
     ENNReal.one_toReal, one_smul]
 #align measure_theory.set_average_const MeasureTheory.set_average_const
+-/
 
 @[simp]
 theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
Diff
@@ -1,10 +1,10 @@
 /-
 Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Yury G. Kudryashov
+Authors: Yury G. Kudryashov, Yaël Dillies
 
 ! This file was ported from Lean 3 source module measure_theory.integral.average
-! leanprover-community/mathlib commit c20927220ef87bb4962ba08bf6da2ce3cf50a6dd
+! leanprover-community/mathlib commit ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -24,25 +24,33 @@ measure, then the average of any function is equal to its integral.
 For the average on a set, we use `⨍ x in s, f x ∂μ` (notation for `⨍ x, f x ∂(μ.restrict s)`). For
 average w.r.t. the volume, one can omit `∂volume`.
 
+We prove several version of the first moment method: An integrable function is below/above its
+average on a set of positive measure.
+
 ## Implementation notes
 
 The average is defined as an integral over `(μ univ)⁻¹ • μ` so that all theorems about Bochner
 integrals work for the average without modifications. For theorems that require integrability of a
 function, we provide a convenience lemma `measure_theory.integrable.to_average`.
 
+## TODO
+
+Provide the first moment method for the Lebesgue integral as well. A draft is available on branch
+`first_moment_lintegral`.
+
 ## Tags
 
 integral, center mass, average value
 -/
 
 
-open MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
+open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
 
 open scoped Topology BigOperators ENNReal Convex
 
 variable {α E F : Type _} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ : Measure α}
-  {s : Set E}
+  {s t : Set α}
 
 /-!
 ### Average value of a function w.r.t. a measure
@@ -57,7 +65,9 @@ integral.
 
 namespace MeasureTheory
 
-variable (μ)
+section NormedAddCommGroup
+
+variable (μ) {f g : α → E}
 
 include m0
 
@@ -138,6 +148,10 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = 
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
 
+theorem set_average_congr_set_ae (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
+  simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
+#align measure_theory.set_average_congr_set_ae MeasureTheory.set_average_congr_set_ae
+
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
     ⨍ x, f x ∂(μ + ν) =
@@ -221,5 +235,238 @@ theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞)
     ENNReal.one_toReal, one_smul]
 #align measure_theory.set_average_const MeasureTheory.set_average_const
 
+@[simp]
+theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
+    ∫ x, ⨍ a, f a ∂μ ∂μ = ∫ x, f x ∂μ :=
+  by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp only [integral_zero_measure]
+  ·
+    rw [integral_const, average_eq,
+      smul_inv_smul₀ (to_real_ne_zero.2 ⟨measure_univ_ne_zero.2 hμ, measure_ne_top _ _⟩)]
+#align measure_theory.integral_average MeasureTheory.integral_average
+
+theorem set_integral_set_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
+    ∫ x in s, ⨍ a in s, f a ∂μ ∂μ = ∫ x in s, f x ∂μ :=
+  integral_average _ _
+#align measure_theory.set_integral_set_average MeasureTheory.set_integral_set_average
+
+theorem integral_sub_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
+    ∫ x, f x - ⨍ a, f a ∂μ ∂μ = 0 :=
+  by
+  by_cases hf : integrable f μ
+  · rw [integral_sub hf (integrable_const _), integral_average, sub_self]
+  refine' integral_undef fun h => hf _
+  convert h.add (integrable_const _)
+  exact (sub_add_cancel _ _).symm
+#align measure_theory.integral_sub_average MeasureTheory.integral_sub_average
+
+theorem set_integral_sub_set_average (hs : μ s ≠ ∞) (f : α → E) :
+    ∫ x in s, f x - ⨍ a in s, f a ∂μ ∂μ = 0 :=
+  haveI haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
+  integral_sub_average _ _
+#align measure_theory.set_integral_sub_set_average MeasureTheory.set_integral_sub_set_average
+
+theorem integral_average_sub [IsFiniteMeasure μ] (hf : Integrable f μ) :
+    ∫ x, ⨍ a, f a ∂μ - f x ∂μ = 0 := by
+  rw [integral_sub (integrable_const _) hf, integral_average, sub_self]
+#align measure_theory.integral_average_sub MeasureTheory.integral_average_sub
+
+theorem set_integral_set_average_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    ∫ x in s, ⨍ a in s, f a ∂μ - f x ∂μ = 0 :=
+  haveI haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
+  integral_average_sub hf
+#align measure_theory.set_integral_set_average_sub MeasureTheory.set_integral_set_average_sub
+
+end NormedAddCommGroup
+
+theorem ofReal_average {f : α → ℝ} (hf : Integrable f μ) (hf₀ : 0 ≤ᵐ[μ] f) :
+    ENNReal.ofReal (⨍ x, f x ∂μ) = (∫⁻ x, ENNReal.ofReal (f x) ∂μ) / μ univ :=
+  by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp
+  ·
+    rw [average_eq, smul_eq_mul, ← to_real_inv, of_real_mul to_real_nonneg,
+      of_real_to_real (inv_ne_top.2 <| measure_univ_ne_zero.2 hμ),
+      of_real_integral_eq_lintegral_of_real hf hf₀, ENNReal.div_eq_inv_mul]
+#align measure_theory.of_real_average MeasureTheory.ofReal_average
+
+theorem ofReal_set_average {f : α → ℝ} (hf : IntegrableOn f s μ) (hf₀ : 0 ≤ᵐ[μ.restrict s] f) :
+    ENNReal.ofReal (⨍ x in s, f x ∂μ) = (∫⁻ x in s, ENNReal.ofReal (f x) ∂μ) / μ s := by
+  simpa using of_real_average hf hf₀
+#align measure_theory.of_real_set_average MeasureTheory.ofReal_set_average
+
+theorem average_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
+    ⨍ x, (f x).toReal ∂μ = ((∫⁻ x, f x ∂μ) / μ univ).toReal :=
+  by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp
+  ·
+    rw [average_eq, smul_eq_mul, to_real_div, ←
+      integral_to_real hf (hf'.mono fun _ => lt_top_iff_ne_top.2), div_eq_inv_mul]
+#align measure_theory.average_to_real MeasureTheory.average_toReal
+
+theorem set_average_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
+    (hf' : ∀ᵐ x ∂μ.restrict s, f x ≠ ∞) :
+    ⨍ x in s, (f x).toReal ∂μ = ((∫⁻ x in s, f x ∂μ) / μ s).toReal := by
+  simpa using average_to_real hf hf'
+#align measure_theory.set_average_to_real MeasureTheory.set_average_toReal
+
+/-! ### First moment method -/
+
+
+section FirstMoment
+
+variable {N : Set α} {f : α → ℝ}
+
+/-- **First moment method**. An integrable function is smaller than its mean on a set of positive
+measure. -/
+theorem measure_le_set_average_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    0 < μ ({x ∈ s | f x ≤ ⨍ a in s, f a ∂μ}) :=
+  by
+  refine' pos_iff_ne_zero.2 fun H => _
+  replace H : (μ.restrict s) {x | f x ≤ ⨍ a in s, f a ∂μ} = 0
+  · rwa [restrict_apply₀, inter_comm]
+    exact ae_strongly_measurable.null_measurable_set_le hf.1 ae_strongly_measurable_const
+  haveI : is_finite_measure (μ.restrict s) :=
+    ⟨by simpa only [measure.restrict_apply, MeasurableSet.univ, univ_inter] using hμ₁.lt_top⟩
+  refine' (integral_sub_average (μ.restrict s) f).not_gt _
+  refine' (set_integral_pos_iff_support_of_nonneg_ae _ _).2 _
+  · refine' eq_bot_mono (measure_mono fun x hx => _) H
+    simp only [Pi.zero_apply, sub_nonneg, mem_compl_iff, mem_set_of_eq, not_le] at hx 
+    exact hx.le
+  · exact hf.sub (integrable_on_const.2 <| Or.inr <| lt_top_iff_ne_top.2 hμ₁)
+  · rwa [pos_iff_ne_zero, inter_comm, ← diff_compl, ← diff_inter_self_eq_diff, measure_diff_null]
+    refine' eq_bot_mono (measure_mono _) (measure_inter_eq_zero_of_restrict H)
+    exact inter_subset_inter_left _ fun a ha => (sub_eq_zero.1 <| of_not_not ha).le
+#align measure_theory.measure_le_set_average_pos MeasureTheory.measure_le_set_average_pos
+
+/-- **First moment method**. An integrable function is greater than its mean on a set of positive
+measure. -/
+theorem measure_set_average_le_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    0 < μ ({x ∈ s | ⨍ a in s, f a ∂μ ≤ f x}) := by
+  simpa [integral_neg, neg_div] using measure_le_set_average_pos hμ hμ₁ hf.neg
+#align measure_theory.measure_set_average_le_pos MeasureTheory.measure_set_average_le_pos
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
+theorem exists_le_set_average (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    ∃ x ∈ s, f x ≤ ⨍ a in s, f a ∂μ :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_set_average_pos hμ hμ₁ hf).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_le_set_average MeasureTheory.exists_le_set_average
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
+theorem exists_set_average_le (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    ∃ x ∈ s, ⨍ a in s, f a ∂μ ≤ f x :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_set_average_le_pos hμ hμ₁ hf).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_set_average_le MeasureTheory.exists_set_average_le
+
+section FiniteMeasure
+
+variable [IsFiniteMeasure μ]
+
+/-- **First moment method**. An integrable function is smaller than its mean on a set of positive
+measure. -/
+theorem measure_le_average_pos (hμ : μ ≠ 0) (hf : Integrable f μ) : 0 < μ {x | f x ≤ ⨍ a, f a ∂μ} :=
+  by
+  simpa using
+    measure_le_set_average_pos (measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
+      hf.integrable_on
+#align measure_theory.measure_le_average_pos MeasureTheory.measure_le_average_pos
+
+/-- **First moment method**. An integrable function is greater than its mean on a set of positive
+measure. -/
+theorem measure_average_le_pos (hμ : μ ≠ 0) (hf : Integrable f μ) : 0 < μ {x | ⨍ a, f a ∂μ ≤ f x} :=
+  by
+  simpa using
+    measure_set_average_le_pos (measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
+      hf.integrable_on
+#align measure_theory.measure_average_le_pos MeasureTheory.measure_average_le_pos
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
+theorem exists_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, f x ≤ ⨍ a, f a ∂μ :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_average_pos hμ hf).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_le_average MeasureTheory.exists_le_average
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
+theorem exists_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, ⨍ a, f a ∂μ ≤ f x :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_average_le_pos hμ hf).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_average_le MeasureTheory.exists_average_le
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), f x ≤ ⨍ a, f a ∂μ :=
+  by
+  have := measure_le_average_pos hμ hf
+  rw [← measure_diff_null hN] at this 
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
+  exact ⟨x, hxN, hx⟩
+#align measure_theory.exists_not_mem_null_le_average MeasureTheory.exists_not_mem_null_le_average
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The maximum of an integrable function is greater than its mean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), ⨍ a, f a ∂μ ≤ f x := by
+  simpa [integral_neg, neg_div] using exists_not_mem_null_le_average hμ hf.neg hN
+#align measure_theory.exists_not_mem_null_average_le MeasureTheory.exists_not_mem_null_average_le
+
+end FiniteMeasure
+
+section ProbabilityMeasure
+
+variable [IsProbabilityMeasure μ]
+
+/-- **First moment method**. An integrable function is smaller than its integral on a set of
+positive measure. -/
+theorem measure_le_integral_pos (hf : Integrable f μ) : 0 < μ {x | f x ≤ ∫ a, f a ∂μ} := by
+  simpa only [average_eq_integral] using
+    measure_le_average_pos (is_probability_measure.ne_zero μ) hf
+#align measure_theory.measure_le_integral_pos MeasureTheory.measure_le_integral_pos
+
+/-- **First moment method**. An integrable function is greater than its integral on a set of
+positive measure. -/
+theorem measure_integral_le_pos (hf : Integrable f μ) : 0 < μ {x | ∫ a, f a ∂μ ≤ f x} := by
+  simpa only [average_eq_integral] using
+    measure_average_le_pos (is_probability_measure.ne_zero μ) hf
+#align measure_theory.measure_integral_le_pos MeasureTheory.measure_integral_le_pos
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its integral. -/
+theorem exists_le_integral (hf : Integrable f μ) : ∃ x, f x ≤ ∫ a, f a ∂μ := by
+  simpa only [average_eq_integral] using exists_le_average (is_probability_measure.ne_zero μ) hf
+#align measure_theory.exists_le_integral MeasureTheory.exists_le_integral
+
+/-- **First moment method**. The maximum of an integrable function is greater than its integral. -/
+theorem exists_integral_le (hf : Integrable f μ) : ∃ x, ∫ a, f a ∂μ ≤ f x := by
+  simpa only [average_eq_integral] using exists_average_le (is_probability_measure.ne_zero μ) hf
+#align measure_theory.exists_integral_le MeasureTheory.exists_integral_le
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The minimum of an integrable function is smaller than its integral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_le_integral (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), f x ≤ ∫ a, f a ∂μ := by
+  simpa only [average_eq_integral] using
+    exists_not_mem_null_le_average (is_probability_measure.ne_zero μ) hf hN
+#align measure_theory.exists_not_mem_null_le_integral MeasureTheory.exists_not_mem_null_le_integral
+
+/- ./././Mathport/Syntax/Translate/Basic.lean:638:2: warning: expanding binder collection (x «expr ∉ » N) -/
+/-- **First moment method**. The maximum of an integrable function is greater than its integral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_integral_le (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ (x : _) (_ : x ∉ N), ∫ a, f a ∂μ ≤ f x := by
+  simpa only [average_eq_integral] using
+    exists_not_mem_null_average_le (is_probability_measure.ne_zero μ) hf hN
+#align measure_theory.exists_not_mem_null_integral_le MeasureTheory.exists_not_mem_null_integral_le
+
+end ProbabilityMeasure
+
+end FirstMoment
+
 end MeasureTheory
 
Diff
@@ -75,46 +75,46 @@ noncomputable def average (f : α → E) :=
 -/
 
 -- mathport name: «expr⨍ , ∂ »
-notation3"⨍ "(...)", "r:(scoped f => f)" ∂"μ => average μ r
+notation3"⨍ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => average μ r
 
 -- mathport name: «expr⨍ , »
-notation3"⨍ "(...)", "r:(scoped f => average volume f) => r
+notation3"⨍ "(...)", "r:60:(scoped f => average volume f) => r
 
 -- mathport name: «expr⨍ in , ∂ »
-notation3"⨍ "(...)" in "s", "r:(scoped f => f)" ∂"μ => average (Measure.restrict μ s) r
+notation3"⨍ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => average (Measure.restrict μ s) r
 
 -- mathport name: «expr⨍ in , »
-notation3"⨍ "(...)" in "s", "r:(scoped f => average Measure.restrict volume s f) => r
+notation3"⨍ "(...)" in "s", "r:60:(scoped f => average Measure.restrict volume s f) => r
 
 @[simp]
-theorem average_zero : (⨍ x, (0 : E) ∂μ) = 0 := by rw [average, integral_zero]
+theorem average_zero : ⨍ x, (0 : E) ∂μ = 0 := by rw [average, integral_zero]
 #align measure_theory.average_zero MeasureTheory.average_zero
 
 @[simp]
-theorem average_zero_measure (f : α → E) : (⨍ x, f x ∂(0 : Measure α)) = 0 := by
+theorem average_zero_measure (f : α → E) : ⨍ x, f x ∂(0 : Measure α) = 0 := by
   rw [average, smul_zero, integral_zero_measure]
 #align measure_theory.average_zero_measure MeasureTheory.average_zero_measure
 
 @[simp]
-theorem average_neg (f : α → E) : (⨍ x, -f x ∂μ) = -⨍ x, f x ∂μ :=
+theorem average_neg (f : α → E) : ⨍ x, -f x ∂μ = -⨍ x, f x ∂μ :=
   integral_neg f
 #align measure_theory.average_neg MeasureTheory.average_neg
 
-theorem average_eq' (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂(μ univ)⁻¹ • μ :=
+theorem average_eq' (f : α → E) : ⨍ x, f x ∂μ = ∫ x, f x ∂(μ univ)⁻¹ • μ :=
   rfl
 #align measure_theory.average_eq' MeasureTheory.average_eq'
 
-theorem average_eq (f : α → E) : (⨍ x, f x ∂μ) = (μ univ).toReal⁻¹ • ∫ x, f x ∂μ := by
+theorem average_eq (f : α → E) : ⨍ x, f x ∂μ = (μ univ).toReal⁻¹ • ∫ x, f x ∂μ := by
   rw [average_eq', integral_smul_measure, ENNReal.toReal_inv]
 #align measure_theory.average_eq MeasureTheory.average_eq
 
-theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
+theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : ⨍ x, f x ∂μ = ∫ x, f x ∂μ := by
   rw [average, measure_univ, inv_one, one_smul]
 #align measure_theory.average_eq_integral MeasureTheory.average_eq_integral
 
 @[simp]
 theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
-    ((μ univ).toReal • ⨍ x, f x ∂μ) = ∫ x, f x ∂μ :=
+    (μ univ).toReal • ⨍ x, f x ∂μ = ∫ x, f x ∂μ :=
   by
   cases' eq_or_ne μ 0 with hμ hμ
   · rw [hμ, integral_zero_measure, average_zero_measure, smul_zero]
@@ -124,25 +124,24 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
 
 theorem set_average_eq (f : α → E) (s : Set α) :
-    (⨍ x in s, f x ∂μ) = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by
-  rw [average_eq, restrict_apply_univ]
+    ⨍ x in s, f x ∂μ = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by rw [average_eq, restrict_apply_univ]
 #align measure_theory.set_average_eq MeasureTheory.set_average_eq
 
 theorem set_average_eq' (f : α → E) (s : Set α) :
-    (⨍ x in s, f x ∂μ) = ∫ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
+    ⨍ x in s, f x ∂μ = ∫ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
   simp only [average_eq', restrict_apply_univ]
 #align measure_theory.set_average_eq' MeasureTheory.set_average_eq'
 
 variable {μ}
 
-theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : (⨍ x, f x ∂μ) = ⨍ x, g x ∂μ := by
+theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = ⨍ x, g x ∂μ := by
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
 
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
-    (⨍ x, f x ∂μ + ν) =
-      (((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ) +
+    ⨍ x, f x ∂(μ + ν) =
+      ((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ +
         ((ν univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂ν :=
   by
   simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ← smul_add, ←
@@ -151,19 +150,19 @@ theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeas
 #align measure_theory.average_add_measure MeasureTheory.average_add_measure
 
 theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi : Integrable g μ) :
-    (⨍ x, (f x, g x) ∂μ) = (⨍ x, f x ∂μ, ⨍ x, g x ∂μ) :=
+    ⨍ x, (f x, g x) ∂μ = (⨍ x, f x ∂μ, ⨍ x, g x ∂μ) :=
   integral_pair hfi.to_average hgi.to_average
 #align measure_theory.average_pair MeasureTheory.average_pair
 
 theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
-    ((μ s).toReal • ⨍ x in s, f x ∂μ) = ∫ x in s, f x ∂μ := by haveI := Fact.mk h.lt_top;
+    (μ s).toReal • ⨍ x in s, f x ∂μ = ∫ x in s, f x ∂μ := by haveI := Fact.mk h.lt_top;
   rw [← measure_smul_average, restrict_apply_univ]
 #align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_set_average
 
 theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
-    (⨍ x in s ∪ t, f x ∂μ) =
-      (((μ s).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in s, f x ∂μ) +
+    ⨍ x in s ∪ t, f x ∂μ =
+      ((μ s).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in s, f x ∂μ +
         ((μ t).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in t, f x ∂μ :=
   by
   haveI := Fact.mk hsμ.lt_top; haveI := Fact.mk htμ.lt_top
@@ -173,7 +172,7 @@ theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht
 theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞)
     (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
-    (⨍ x in s ∪ t, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in t, f x ∂μ) :=
+    ⨍ x in s ∪ t, f x ∂μ ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in t, f x ∂μ) :=
   by
   replace hs₀ : 0 < (μ s).toReal; exact ENNReal.toReal_pos hs₀ hsμ
   replace ht₀ : 0 < (μ t).toReal; exact ENNReal.toReal_pos ht₀ htμ
@@ -184,8 +183,7 @@ theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisj
 
 theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ)
-    (hft : IntegrableOn f t μ) :
-    (⨍ x in s ∪ t, f x ∂μ) ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] :=
+    (hft : IntegrableOn f t μ) : ⨍ x in s ∪ t, f x ∂μ ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] :=
   by
   by_cases hse : μ s = 0
   · rw [← ae_eq_empty] at hse 
@@ -202,22 +200,22 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
 
 theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {s : Set α}
     (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) (hfi : Integrable f μ) :
-    (⨍ x, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
+    ⨍ x, f x ∂μ ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
   simpa only [union_compl_self, restrict_univ] using
     average_union_mem_open_segment ae_disjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _)
       (measure_ne_top _ _) hfi.integrable_on hfi.integrable_on
 #align measure_theory.average_mem_open_segment_compl_self MeasureTheory.average_mem_openSegment_compl_self
 
 @[simp]
-theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : (⨍ x, c ∂μ) = c := by
+theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : ⨍ x, c ∂μ = c := by
   simp only [average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, one_smul,
     univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_ne_bot.1 h, not_false_iff,
     ENNReal.one_toReal]
 #align measure_theory.average_const MeasureTheory.average_const
 
-theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) :
-    (⨍ x in s, c ∂μ) = c := by
+theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) : ⨍ x in s, c ∂μ = c :=
+  by
   simp only [set_average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
     smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel hs₀ hs,
     ENNReal.one_toReal, one_smul]
Diff
@@ -198,7 +198,6 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
     calc
       0 < (μ s).toReal := ENNReal.toReal_pos hse hsμ
       _ ≤ _ := le_add_of_nonneg_right ENNReal.toReal_nonneg
-      
 #align measure_theory.average_union_mem_segment MeasureTheory.average_union_mem_segment
 
 theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {s : Set α}
Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury G. Kudryashov
 
 ! This file was ported from Lean 3 source module measure_theory.integral.average
-! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
+! leanprover-community/mathlib commit c20927220ef87bb4962ba08bf6da2ce3cf50a6dd
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -13,6 +13,9 @@ import Mathbin.MeasureTheory.Integral.SetIntegral
 /-!
 # Integral average of a function
 
+> THIS FILE IS SYNCHRONIZED WITH MATHLIB4.
+> Any changes to this file require a corresponding PR to mathlib4.
+
 In this file we define `measure_theory.average μ f` (notation: `⨍ x, f x ∂μ`) to be the average
 value of `f` with respect to measure `μ`. It is defined as `∫ x, f x ∂((μ univ)⁻¹ • μ)`, so it
 is equal to zero if `f` is not integrable or if `μ` is an infinite measure. If `μ` is a probability
Diff
@@ -58,6 +58,7 @@ variable (μ)
 
 include m0
 
+#print MeasureTheory.average /-
 /-- Average value of a function `f` w.r.t. a measure `μ`, notation: `⨍ x, f x ∂μ`. It is defined as
 `(μ univ).to_real⁻¹ • ∫ x, f x ∂μ`, so it is equal to zero if `f` is not integrable or if `μ` is an
 infinite measure. If `μ` is a probability measure, then the average of any function is equal to its
@@ -68,6 +69,7 @@ average w.r.t. the volume, one can omit `∂volume`. -/
 noncomputable def average (f : α → E) :=
   ∫ x, f x ∂(μ univ)⁻¹ • μ
 #align measure_theory.average MeasureTheory.average
+-/
 
 -- mathport name: «expr⨍ , ∂ »
 notation3"⨍ "(...)", "r:(scoped f => f)" ∂"μ => average μ r
Diff
@@ -103,12 +103,12 @@ theorem average_eq (f : α → E) : (⨍ x, f x ∂μ) = (μ univ).toReal⁻¹ 
   rw [average_eq', integral_smul_measure, ENNReal.toReal_inv]
 #align measure_theory.average_eq MeasureTheory.average_eq
 
-theorem average_eq_integral [ProbabilityMeasure μ] (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
+theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
   rw [average, measure_univ, inv_one, one_smul]
 #align measure_theory.average_eq_integral MeasureTheory.average_eq_integral
 
 @[simp]
-theorem measure_smul_average [FiniteMeasure μ] (f : α → E) :
+theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
     ((μ univ).toReal • ⨍ x, f x ∂μ) = ∫ x, f x ∂μ :=
   by
   cases' eq_or_ne μ 0 with hμ hμ
@@ -134,7 +134,7 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : (⨍ x, f x ∂μ) =
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
 
-theorem average_add_measure [FiniteMeasure μ] {ν : Measure α} [FiniteMeasure ν] {f : α → E}
+theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
     (⨍ x, f x ∂μ + ν) =
       (((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ) +
@@ -196,7 +196,7 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
       
 #align measure_theory.average_union_mem_segment MeasureTheory.average_union_mem_segment
 
-theorem average_mem_openSegment_compl_self [FiniteMeasure μ] {f : α → E} {s : Set α}
+theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {s : Set α}
     (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) (hfi : Integrable f μ) :
     (⨍ x, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
   simpa only [union_compl_self, restrict_univ] using
@@ -205,7 +205,7 @@ theorem average_mem_openSegment_compl_self [FiniteMeasure μ] {f : α → E} {s
 #align measure_theory.average_mem_open_segment_compl_self MeasureTheory.average_mem_openSegment_compl_self
 
 @[simp]
-theorem average_const [FiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : (⨍ x, c ∂μ) = c := by
+theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : (⨍ x, c ∂μ) = c := by
   simp only [average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, one_smul,
     univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_ne_bot.1 h, not_false_iff,
Diff
@@ -183,7 +183,7 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
     (⨍ x in s ∪ t, f x ∂μ) ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] :=
   by
   by_cases hse : μ s = 0
-  · rw [← ae_eq_empty] at hse
+  · rw [← ae_eq_empty] at hse 
     rw [restrict_congr_set (hse.union eventually_eq.rfl), empty_union]
     exact right_mem_segment _ _ _
   · refine'
Diff
@@ -35,7 +35,7 @@ integral, center mass, average value
 
 open MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
 
-open Topology BigOperators ENNReal Convex
+open scoped Topology BigOperators ENNReal Convex
 
 variable {α E F : Type _} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ : Measure α}
Diff
@@ -151,9 +151,7 @@ theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi
 #align measure_theory.average_pair MeasureTheory.average_pair
 
 theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
-    ((μ s).toReal • ⨍ x in s, f x ∂μ) = ∫ x in s, f x ∂μ :=
-  by
-  haveI := Fact.mk h.lt_top
+    ((μ s).toReal • ⨍ x in s, f x ∂μ) = ∫ x in s, f x ∂μ := by haveI := Fact.mk h.lt_top;
   rw [← measure_smul_average, restrict_apply_univ]
 #align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_set_average
 
Diff
@@ -103,12 +103,12 @@ theorem average_eq (f : α → E) : (⨍ x, f x ∂μ) = (μ univ).toReal⁻¹ 
   rw [average_eq', integral_smul_measure, ENNReal.toReal_inv]
 #align measure_theory.average_eq MeasureTheory.average_eq
 
-theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
+theorem average_eq_integral [ProbabilityMeasure μ] (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
   rw [average, measure_univ, inv_one, one_smul]
 #align measure_theory.average_eq_integral MeasureTheory.average_eq_integral
 
 @[simp]
-theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
+theorem measure_smul_average [FiniteMeasure μ] (f : α → E) :
     ((μ univ).toReal • ⨍ x, f x ∂μ) = ∫ x, f x ∂μ :=
   by
   cases' eq_or_ne μ 0 with hμ hμ
@@ -134,7 +134,7 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : (⨍ x, f x ∂μ) =
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
 
-theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
+theorem average_add_measure [FiniteMeasure μ] {ν : Measure α} [FiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
     (⨍ x, f x ∂μ + ν) =
       (((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ) +
@@ -198,7 +198,7 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
       
 #align measure_theory.average_union_mem_segment MeasureTheory.average_union_mem_segment
 
-theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {s : Set α}
+theorem average_mem_openSegment_compl_self [FiniteMeasure μ] {f : α → E} {s : Set α}
     (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) (hfi : Integrable f μ) :
     (⨍ x, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
   simpa only [union_compl_self, restrict_univ] using
@@ -207,7 +207,7 @@ theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {
 #align measure_theory.average_mem_open_segment_compl_self MeasureTheory.average_mem_openSegment_compl_self
 
 @[simp]
-theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : (⨍ x, c ∂μ) = c := by
+theorem average_const [FiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : (⨍ x, c ∂μ) = c := by
   simp only [average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, one_smul,
     univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_ne_bot.1 h, not_false_iff,
Diff
@@ -157,7 +157,7 @@ theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞)
   rw [← measure_smul_average, restrict_apply_univ]
 #align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_set_average
 
-theorem average_union {f : α → E} {s t : Set α} (hd : AeDisjoint μ s t) (ht : NullMeasurableSet t μ)
+theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
     (⨍ x in s ∪ t, f x ∂μ) =
       (((μ s).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in s, f x ∂μ) +
@@ -167,7 +167,7 @@ theorem average_union {f : α → E} {s t : Set α} (hd : AeDisjoint μ s t) (ht
   rw [restrict_union₀ hd ht, average_add_measure hfs hft, restrict_apply_univ, restrict_apply_univ]
 #align measure_theory.average_union MeasureTheory.average_union
 
-theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AeDisjoint μ s t)
+theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞)
     (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
     (⨍ x in s ∪ t, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in t, f x ∂μ) :=
@@ -179,7 +179,7 @@ theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AeDisj
       ⟨(μ s).toReal, (μ t).toReal, hs₀, ht₀, (average_union hd ht hsμ htμ hfs hft).symm⟩
 #align measure_theory.average_union_mem_open_segment MeasureTheory.average_union_mem_openSegment
 
-theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AeDisjoint μ s t)
+theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ)
     (hft : IntegrableOn f t μ) :
     (⨍ x in s ∪ t, f x ∂μ) ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] :=
Diff
@@ -147,7 +147,7 @@ theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeas
 
 theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi : Integrable g μ) :
     (⨍ x, (f x, g x) ∂μ) = (⨍ x, f x ∂μ, ⨍ x, g x ∂μ) :=
-  integral_pair hfi.toAverage hgi.toAverage
+  integral_pair hfi.to_average hgi.to_average
 #align measure_theory.average_pair MeasureTheory.average_pair
 
 theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
Diff
@@ -35,7 +35,7 @@ integral, center mass, average value
 
 open MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
 
-open Topology BigOperators Ennreal Convex
+open Topology BigOperators ENNReal Convex
 
 variable {α E F : Type _} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ : Measure α}
@@ -100,7 +100,7 @@ theorem average_eq' (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂(μ univ
 #align measure_theory.average_eq' MeasureTheory.average_eq'
 
 theorem average_eq (f : α → E) : (⨍ x, f x ∂μ) = (μ univ).toReal⁻¹ • ∫ x, f x ∂μ := by
-  rw [average_eq', integral_smul_measure, Ennreal.toReal_inv]
+  rw [average_eq', integral_smul_measure, ENNReal.toReal_inv]
 #align measure_theory.average_eq MeasureTheory.average_eq
 
 theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
@@ -114,7 +114,7 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
   cases' eq_or_ne μ 0 with hμ hμ
   · rw [hμ, integral_zero_measure, average_zero_measure, smul_zero]
   · rw [average_eq, smul_inv_smul₀]
-    refine' (Ennreal.toReal_pos _ <| measure_ne_top _ _).ne'
+    refine' (ENNReal.toReal_pos _ <| measure_ne_top _ _).ne'
     rwa [Ne.def, measure_univ_eq_zero]
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
 
@@ -141,7 +141,7 @@ theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeas
         ((ν univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂ν :=
   by
   simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ← smul_add, ←
-    integral_add_measure hμ hν, ← Ennreal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
+    integral_add_measure hμ hν, ← ENNReal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
   rw [average_eq, measure.add_apply]
 #align measure_theory.average_add_measure MeasureTheory.average_add_measure
 
@@ -172,8 +172,8 @@ theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AeDisj
     (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
     (⨍ x in s ∪ t, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in t, f x ∂μ) :=
   by
-  replace hs₀ : 0 < (μ s).toReal; exact Ennreal.toReal_pos hs₀ hsμ
-  replace ht₀ : 0 < (μ t).toReal; exact Ennreal.toReal_pos ht₀ htμ
+  replace hs₀ : 0 < (μ s).toReal; exact ENNReal.toReal_pos hs₀ hsμ
+  replace ht₀ : 0 < (μ t).toReal; exact ENNReal.toReal_pos ht₀ htμ
   refine'
     mem_open_segment_iff_div.mpr
       ⟨(μ s).toReal, (μ t).toReal, hs₀, ht₀, (average_union hd ht hsμ htμ hfs hft).symm⟩
@@ -190,11 +190,11 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AeDisjoint
     exact right_mem_segment _ _ _
   · refine'
       mem_segment_iff_div.mpr
-        ⟨(μ s).toReal, (μ t).toReal, Ennreal.toReal_nonneg, Ennreal.toReal_nonneg, _,
+        ⟨(μ s).toReal, (μ t).toReal, ENNReal.toReal_nonneg, ENNReal.toReal_nonneg, _,
           (average_union hd ht hsμ htμ hfs hft).symm⟩
     calc
-      0 < (μ s).toReal := Ennreal.toReal_pos hse hsμ
-      _ ≤ _ := le_add_of_nonneg_right Ennreal.toReal_nonneg
+      0 < (μ s).toReal := ENNReal.toReal_pos hse hsμ
+      _ ≤ _ := le_add_of_nonneg_right ENNReal.toReal_nonneg
       
 #align measure_theory.average_union_mem_segment MeasureTheory.average_union_mem_segment
 
@@ -209,16 +209,16 @@ theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {
 @[simp]
 theorem average_const [IsFiniteMeasure μ] [h : μ.ae.ne_bot] (c : E) : (⨍ x, c ∂μ) = c := by
   simp only [average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, one_smul,
-    univ_inter, smul_smul, ← Ennreal.toReal_inv, ← Ennreal.toReal_mul, Ennreal.inv_mul_cancel,
+    univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_ne_bot.1 h, not_false_iff,
-    Ennreal.one_toReal]
+    ENNReal.one_toReal]
 #align measure_theory.average_const MeasureTheory.average_const
 
 theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) :
     (⨍ x in s, c ∂μ) = c := by
   simp only [set_average_eq, integral_const, measure.restrict_apply, MeasurableSet.univ, univ_inter,
-    smul_smul, ← Ennreal.toReal_inv, ← Ennreal.toReal_mul, Ennreal.inv_mul_cancel hs₀ hs,
-    Ennreal.one_toReal, one_smul]
+    smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel hs₀ hs,
+    ENNReal.one_toReal, one_smul]
 #align measure_theory.set_average_const MeasureTheory.set_average_const
 
 end MeasureTheory

Changes in mathlib4

mathlib3
mathlib4
chore: adapt to multiple goal linter 1 (#12338)

A PR accompanying #12339.

Zulip discussion

Diff
@@ -695,7 +695,7 @@ theorem measure_setLaverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s
   rintro x ⟨hfx, hx⟩
   dsimp at hfx
   rw [← toReal_laverage hg.aemeasurable, toReal_le_toReal (setLaverage_lt_top hint).ne hx] at hfx
-  exact hfx.trans (hgf _)
+  · exact hfx.trans (hgf _)
   · simp_rw [ae_iff, not_ne_iff]
     exact measure_eq_top_of_lintegral_ne_top hg.aemeasurable hint
 #align measure_theory.measure_set_laverage_le_pos MeasureTheory.measure_setLaverage_le_pos
chore: replace set_integral with setIntegral (#12215)

Done with a global search and replace, and then (to fix the #align lines), replace (#align \S*)setIntegral with $1set_integral.

Diff
@@ -363,11 +363,11 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = 
 #align measure_theory.average_congr MeasureTheory.average_congr
 
 theorem setAverage_congr (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
-  simp only [setAverage_eq, set_integral_congr_set_ae h, measure_congr h]
+  simp only [setAverage_eq, setIntegral_congr_set_ae h, measure_congr h]
 #align measure_theory.set_average_congr MeasureTheory.setAverage_congr
 
 theorem setAverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
-    ⨍ x in s, f x ∂μ = ⨍ x in s, g x ∂μ := by simp only [average_eq, set_integral_congr_ae hs h]
+    ⨍ x in s, f x ∂μ = ⨍ x in s, g x ∂μ := by simp only [average_eq, setIntegral_congr_ae hs h]
 #align measure_theory.set_average_congr_fun MeasureTheory.setAverage_congr_fun
 
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
@@ -525,7 +525,7 @@ theorem measure_le_setAverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf
     exact AEStronglyMeasurable.nullMeasurableSet_le hf.1 aestronglyMeasurable_const
   haveI := Fact.mk hμ₁.lt_top
   refine' (integral_sub_average (μ.restrict s) f).not_gt _
-  refine' (set_integral_pos_iff_support_of_nonneg_ae _ _).2 _
+  refine' (setIntegral_pos_iff_support_of_nonneg_ae _ _).2 _
   · refine' eq_bot_mono (measure_mono fun x hx => _) H
     simp only [Pi.zero_apply, sub_nonneg, mem_compl_iff, mem_setOf_eq, not_le] at hx
     exact hx.le
@@ -863,7 +863,7 @@ theorem tendsto_integral_smul_of_tendsto_average_norm_sub
       intro x hx
       have : g i x = 0 := by rw [← Function.nmem_support]; exact fun h ↦ hx (hi h)
       simp [this]
-    rw [← set_integral_eq_integral_of_forall_compl_eq_zero this (μ := μ)]
+    rw [← setIntegral_eq_integral_of_forall_compl_eq_zero this (μ := μ)]
     refine' integral_mono_of_nonneg (eventually_of_forall (fun x ↦ by positivity)) _
       (eventually_of_forall (fun x ↦ _))
     · apply (Integrable.sub h''i _).norm.const_mul
chore: avoid Ne.def (adaptation for nightly-2024-03-27) (#11813)
Diff
@@ -344,7 +344,7 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
   · rw [hμ, integral_zero_measure, average_zero_measure, smul_zero]
   · rw [average_eq, smul_inv_smul₀]
     refine' (ENNReal.toReal_pos _ <| measure_ne_top _ _).ne'
-    rwa [Ne.def, measure_univ_eq_zero]
+    rwa [Ne, measure_univ_eq_zero]
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
 
 theorem setAverage_eq (f : α → E) (s : Set α) :
chore: classify "simp can prove" porting notes (#11550)

Classifies by adding issue number #10618 to porting notes claiming "simp can prove it".

Diff
@@ -446,7 +446,7 @@ theorem setAverage_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (
   have := NeZero.mk hs₀; have := Fact.mk hs.lt_top; average_const _ _
 #align measure_theory.set_average_const MeasureTheory.setAverage_const
 
--- Porting note: was `@[simp]` but `simp` can prove it
+-- Porting note (#10618): was `@[simp]` but `simp` can prove it
 theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
     ∫ _, ⨍ a, f a ∂μ ∂μ = ∫ x, f x ∂μ := by simp
 #align measure_theory.integral_average MeasureTheory.integral_average
style: homogenise porting notes (#11145)

Homogenises porting notes via capitalisation and addition of whitespace.

It makes the following changes:

  • converts "--porting note" into "-- Porting note";
  • converts "porting note" into "Porting note".
Diff
@@ -242,7 +242,7 @@ theorem setLaverage_one (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) : ⨍⁻ _x in
   setLaverage_const hs₀ hs _
 #align measure_theory.set_laverage_one MeasureTheory.setLaverage_one
 
---porting note: Dropped `simp` because of `simp` seeing through `1 : α → ℝ≥0∞` and applying
+-- Porting note: Dropped `simp` because of `simp` seeing through `1 : α → ℝ≥0∞` and applying
 -- `lintegral_const`. This is suboptimal.
 theorem lintegral_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
     ∫⁻ _x, ⨍⁻ a, f a ∂μ ∂μ = ∫⁻ x, f x ∂μ := by
@@ -446,7 +446,7 @@ theorem setAverage_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (
   have := NeZero.mk hs₀; have := Fact.mk hs.lt_top; average_const _ _
 #align measure_theory.set_average_const MeasureTheory.setAverage_const
 
--- porting note: was `@[simp]` but `simp` can prove it
+-- Porting note: was `@[simp]` but `simp` can prove it
 theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
     ∫ _, ⨍ a, f a ∂μ ∂μ = ∫ x, f x ∂μ := by simp
 #align measure_theory.integral_average MeasureTheory.integral_average
chore: remove stream-of-consciousness uses of have, replace and suffices (#10640)

No changes to tactic file, it's just boring fixes throughout the library.

This follows on from #6964.

Co-authored-by: sgouezel <sebastien.gouezel@univ-rennes1.fr> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -404,9 +404,9 @@ theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisj
     (ht : NullMeasurableSet t μ) (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞)
     (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
     ⨍ x in s ∪ t, f x ∂μ ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in t, f x ∂μ) := by
-  replace hs₀ : 0 < (μ s).toReal; exact ENNReal.toReal_pos hs₀ hsμ
-  replace ht₀ : 0 < (μ t).toReal; exact ENNReal.toReal_pos ht₀ htμ
-  refine' mem_openSegment_iff_div.mpr
+  replace hs₀ : 0 < (μ s).toReal := ENNReal.toReal_pos hs₀ hsμ
+  replace ht₀ : 0 < (μ t).toReal := ENNReal.toReal_pos ht₀ htμ
+  exact mem_openSegment_iff_div.mpr
     ⟨(μ s).toReal, (μ t).toReal, hs₀, ht₀, (average_union hd ht hsμ htμ hfs hft).symm⟩
 #align measure_theory.average_union_mem_open_segment MeasureTheory.average_union_mem_openSegment
 
@@ -520,8 +520,8 @@ measure. -/
 theorem measure_le_setAverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     0 < μ ({x ∈ s | f x ≤ ⨍ a in s, f a ∂μ}) := by
   refine' pos_iff_ne_zero.2 fun H => _
-  replace H : (μ.restrict s) {x | f x ≤ ⨍ a in s, f a ∂μ} = 0
-  · rwa [restrict_apply₀, inter_comm]
+  replace H : (μ.restrict s) {x | f x ≤ ⨍ a in s, f a ∂μ} = 0 := by
+    rwa [restrict_apply₀, inter_comm]
     exact AEStronglyMeasurable.nullMeasurableSet_le hf.1 aestronglyMeasurable_const
   haveI := Fact.mk hμ₁.lt_top
   refine' (integral_sub_average (μ.restrict s) f).not_gt _
doc: @[inherit_doc] on notations (#9942)

Make all the notations that unambiguously should inherit the docstring of their definition actually inherit it.

Also write a few docstrings by hand. I only wrote the ones I was competent to write and which I was sure of. Some docstrings come from mathlib3 as they were lost during the early port.

This PR is only intended as a first pass There are many more docstrings to add.

Diff
@@ -62,18 +62,45 @@ namespace MeasureTheory
 section ENNReal
 variable (μ) {f g : α → ℝ≥0∞}
 
-/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`, notation: `⨍⁻ x, f x ∂μ`.
-It is defined as `μ univ⁻¹ * ∫⁻ x, f x ∂μ`, so it is equal to zero if `μ` is an infinite measure. If
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`, denoted `⨍⁻ x, f x ∂μ`.
+
+It is equal to `(μ univ)⁻¹ * ∫⁻ x, f x ∂μ`, so it takes value zero if `μ` is an infinite measure. If
 `μ` is a probability measure, then the average of any function is equal to its integral.
 
-For the average on a set, use `⨍⁻ x in s, f x ∂μ` (defined as `⨍⁻ x, f x ∂(μ.restrict s)`). For
+For the average on a set, use `⨍⁻ x in s, f x ∂μ`, defined as `⨍⁻ x, f x ∂(μ.restrict s)`. For the
 average w.r.t. the volume, one can omit `∂volume`. -/
 noncomputable def laverage (f : α → ℝ≥0∞) := ∫⁻ x, f x ∂(μ univ)⁻¹ • μ
 #align measure_theory.laverage MeasureTheory.laverage
 
-notation3"⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r
-notation3"⨍⁻ "(...)", "r:60:(scoped f => laverage volume f) => r
-notation3"⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (Measure.restrict μ s) r
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`.
+
+It is equal to `(μ univ)⁻¹ * ∫⁻ x, f x ∂μ`, so it takes value zero if `μ` is an infinite measure. If
+`μ` is a probability measure, then the average of any function is equal to its integral.
+
+For the average on a set, use `⨍⁻ x in s, f x ∂μ`, defined as `⨍⁻ x, f x ∂(μ.restrict s)`. For the
+average w.r.t. the volume, one can omit `∂volume`. -/
+notation3 "⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r
+
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. to the standard measure.
+
+It is equal to `(volume univ)⁻¹ * ∫⁻ x, f x`, so it takes value zero if the space has infinite
+measure. In a probability space, the average of any function is equal to its integral.
+
+For the average on a set, use `⨍⁻ x in s, f x`, defined as `⨍⁻ x, f x ∂(volume.restrict s)`. -/
+notation3 "⨍⁻ "(...)", "r:60:(scoped f => laverage volume f) => r
+
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ` on a set `s`.
+
+It is equal to `(μ s)⁻¹ * ∫⁻ x, f x ∂μ`, so it takes value zero if `s` has infinite measure. If `s`
+has measure `1`, then the average of any function is equal to its integral.
+
+For the average w.r.t. the volume, one can omit `∂volume`. -/
+notation3 "⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (Measure.restrict μ s) r
+
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. to the standard measure on a set `s`.
+
+It is equal to `(volume s)⁻¹ * ∫⁻ x, f x`, so it takes value zero if `s` has infinite measure. If
+`s` has measure `1`, then the average of any function is equal to its integral. -/
 notation3 (prettyPrint := false)
   "⨍⁻ "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r
 
@@ -237,27 +264,51 @@ section NormedAddCommGroup
 variable (μ)
 variable {f g : α → E}
 
-/-- Average value of a function `f` w.r.t. a measure `μ`, notation: `⨍ x, f x ∂μ`. It is defined as
-`(μ univ).toReal⁻¹ • ∫ x, f x ∂μ`, so it is equal to zero if `f` is not integrable or if `μ` is an
-infinite measure. If `μ` is a probability measure, then the average of any function is equal to its
-integral.
+/-- Average value of a function `f` w.r.t. a measure `μ`, denoted `⨍ x, f x ∂μ`.
+
+It is equal to `(μ univ).toReal⁻¹ • ∫ x, f x ∂μ`, so it takes value zero if `f` is not integrable or
+if `μ` is an infinite measure. If `μ` is a probability measure, then the average of any function is
+equal to its integral.
 
-For the average on a set, use `⨍ x in s, f x ∂μ` (defined as `⨍ x, f x ∂(μ.restrict s)`). For
+For the average on a set, use `⨍ x in s, f x ∂μ`, defined as `⨍ x, f x ∂(μ.restrict s)`. For the
 average w.r.t. the volume, one can omit `∂volume`. -/
 noncomputable def average (f : α → E) :=
   ∫ x, f x ∂(μ univ)⁻¹ • μ
 #align measure_theory.average MeasureTheory.average
 
-@[inherit_doc average]
+/-- Average value of a function `f` w.r.t. a measure `μ`.
+
+It is equal to `(μ univ).toReal⁻¹ • ∫ x, f x ∂μ`, so it takes value zero if `f` is not integrable or
+if `μ` is an infinite measure. If `μ` is a probability measure, then the average of any function is
+equal to its integral.
+
+For the average on a set, use `⨍ x in s, f x ∂μ`, defined as `⨍ x, f x ∂(μ.restrict s)`. For the
+average w.r.t. the volume, one can omit `∂volume`. -/
 notation3 "⨍ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => average μ r
 
-@[inherit_doc average]
+/-- Average value of a function `f` w.r.t. to the standard measure.
+
+It is equal to `(volume univ).toReal⁻¹ * ∫ x, f x`, so it takes value zero if `f` is not integrable
+or if the space has infinite measure. In a probability space, the average of any function is equal
+to its integral.
+
+For the average on a set, use `⨍ x in s, f x`, defined as `⨍ x, f x ∂(volume.restrict s)`. -/
 notation3 "⨍ "(...)", "r:60:(scoped f => average volume f) => r
 
-@[inherit_doc average]
+/-- Average value of a function `f` w.r.t. a measure `μ` on a set `s`.
+
+It is equal to `(μ s).toReal⁻¹ * ∫ x, f x ∂μ`, so it takes value zero if `f` is not integrable on
+`s` or if `s` has infinite measure. If `s` has measure `1`, then the average of any function is
+equal to its integral.
+
+For the average w.r.t. the volume, one can omit `∂volume`. -/
 notation3 "⨍ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => average (Measure.restrict μ s) r
 
-@[inherit_doc average]
+/-- Average value of a function `f` w.r.t. to the standard measure on a set `s`.
+
+It is equal to `(volume s).toReal⁻¹ * ∫ x, f x`, so it takes value zero `f` is not integrable on `s`
+or if `s` has infinite measure. If `s` has measure `1`, then the average of any function is equal to
+its integral. -/
 notation3 "⨍ "(...)" in "s", "r:60:(scoped f => average (Measure.restrict volume s) f) => r
 
 @[simp]
chore: remove uses of cases' (#9171)

I literally went through and regex'd some uses of cases', replacing them with rcases; this is meant to be a low effort PR as I hope that tools can do this in the future.

rcases is an easier replacement than cases, though with better tools we could in future do a second pass converting simple rcases added here (and existing ones) to cases.

Diff
@@ -99,7 +99,7 @@ theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞)
 @[simp]
 theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
     μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by
-  cases' eq_or_ne μ 0 with hμ hμ
+  rcases eq_or_ne μ 0 with hμ | hμ
   · rw [hμ, lintegral_zero_measure, laverage_zero_measure, mul_zero]
   · rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
 #align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage
@@ -289,7 +289,7 @@ theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : ⨍ x, f
 @[simp]
 theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
     (μ univ).toReal • ⨍ x, f x ∂μ = ∫ x, f x ∂μ := by
-  cases' eq_or_ne μ 0 with hμ hμ
+  rcases eq_or_ne μ 0 with hμ | hμ
   · rw [hμ, integral_zero_measure, average_zero_measure, smul_zero]
   · rw [average_eq, smul_inv_smul₀]
     refine' (ENNReal.toReal_pos _ <| measure_ne_top _ _).ne'
chore: space after (#8178)

Co-authored-by: Moritz Firsching <firsching@google.com>

Diff
@@ -149,14 +149,14 @@ theorem laverage_add_measure :
   · rw [not_isFiniteMeasure_iff] at hν
     simp [laverage_eq, hν]
   haveI := hμ; haveI := hν
-  simp only [←ENNReal.mul_div_right_comm, measure_mul_laverage, ←ENNReal.add_div,
-    ←lintegral_add_measure, ←Measure.add_apply, ←laverage_eq]
+  simp only [← ENNReal.mul_div_right_comm, measure_mul_laverage, ← ENNReal.add_div,
+    ← lintegral_add_measure, ← Measure.add_apply, ← laverage_eq]
 #align measure_theory.laverage_add_measure MeasureTheory.laverage_add_measure
 
 theorem measure_mul_setLaverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) :
     μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ := by
   have := Fact.mk h.lt_top
-  rw [←measure_mul_laverage, restrict_apply_univ]
+  rw [← measure_mul_laverage, restrict_apply_univ]
 #align measure_theory.measure_mul_set_laverage MeasureTheory.measure_mul_setLaverage
 
 theorem laverage_union (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) :
@@ -171,7 +171,7 @@ theorem laverage_union_mem_openSegment (hd : AEDisjoint μ s t) (ht : NullMeasur
   refine'
     ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), ENNReal.div_pos hs₀ <| add_ne_top.2 ⟨hsμ, htμ⟩,
       ENNReal.div_pos ht₀ <| add_ne_top.2 ⟨hsμ, htμ⟩, _, (laverage_union hd ht).symm⟩
-  rw [←ENNReal.add_div,
+  rw [← ENNReal.add_div,
     ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
 #align measure_theory.laverage_union_mem_open_segment MeasureTheory.laverage_union_mem_openSegment
 
@@ -179,12 +179,12 @@ theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurable
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
     ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ] := by
   by_cases hs₀ : μ s = 0
-  · rw [←ae_eq_empty] at hs₀
+  · rw [← ae_eq_empty] at hs₀
     rw [restrict_congr_set (hs₀.union EventuallyEq.rfl), empty_union]
     exact right_mem_segment _ _ _
   · refine'
       ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), zero_le _, zero_le _, _, (laverage_union hd ht).symm⟩
-    rw [←ENNReal.add_div,
+    rw [← ENNReal.add_div,
       ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
 #align measure_theory.laverage_union_mem_segment MeasureTheory.laverage_union_mem_segment
 
@@ -324,8 +324,8 @@ theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeas
     ⨍ x, f x ∂(μ + ν) =
       ((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ +
         ((ν univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂ν := by
-  simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ←smul_add,
-    ←integral_add_measure hμ hν, ←ENNReal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
+  simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ← smul_add,
+    ← integral_add_measure hμ hν, ← ENNReal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
   rw [average_eq, Measure.add_apply]
 #align measure_theory.average_add_measure MeasureTheory.average_add_measure
 
@@ -337,7 +337,7 @@ theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi
 theorem measure_smul_setAverage (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
     (μ s).toReal • ⨍ x in s, f x ∂μ = ∫ x in s, f x ∂μ := by
   haveI := Fact.mk h.lt_top
-  rw [←measure_smul_average, restrict_apply_univ]
+  rw [← measure_smul_average, restrict_apply_univ]
 #align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_setAverage
 
 theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
@@ -364,7 +364,7 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
     (hft : IntegrableOn f t μ) :
     ⨍ x in s ∪ t, f x ∂μ ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] := by
   by_cases hse : μ s = 0
-  · rw [←ae_eq_empty] at hse
+  · rw [← ae_eq_empty] at hse
     rw [restrict_congr_set (hse.union EventuallyEq.rfl), empty_union]
     exact right_mem_segment _ _ _
   · refine'
@@ -613,15 +613,15 @@ theorem measure_le_setLaverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
   obtain h | h := eq_or_ne (∫⁻ a in s, f a ∂μ) ∞
   · simpa [mul_top, hμ₁, laverage, h, top_div_of_ne_top hμ₁, pos_iff_ne_zero] using hμ
   have := measure_le_setAverage_pos hμ hμ₁ (integrable_toReal_of_lintegral_ne_top hf h)
-  rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀
+  rw [← setOf_inter_eq_sep, ← Measure.restrict_apply₀
     (hf.aestronglyMeasurable.nullMeasurableSet_le aestronglyMeasurable_const)]
-  rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀
+  rw [← setOf_inter_eq_sep, ← Measure.restrict_apply₀
     (hf.ennreal_toReal.aestronglyMeasurable.nullMeasurableSet_le aestronglyMeasurable_const),
-    ←measure_diff_null (measure_eq_top_of_lintegral_ne_top hf h)] at this
+    ← measure_diff_null (measure_eq_top_of_lintegral_ne_top hf h)] at this
   refine' this.trans_le (measure_mono _)
   rintro x ⟨hfx, hx⟩
   dsimp at hfx
-  rwa [←toReal_laverage hf, toReal_le_toReal hx (setLaverage_lt_top h).ne] at hfx
+  rwa [← toReal_laverage hf, toReal_le_toReal hx (setLaverage_lt_top h).ne] at hfx
   · simp_rw [ae_iff, not_ne_iff]
     exact measure_eq_top_of_lintegral_ne_top hf h
 #align measure_theory.measure_le_set_laverage_pos MeasureTheory.measure_le_setLaverage_pos
@@ -637,13 +637,13 @@ theorem measure_setLaverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s
   rw [hfg] at hint
   have :=
     measure_setAverage_le_pos hμ hμ₁ (integrable_toReal_of_lintegral_ne_top hg.aemeasurable hint)
-  simp_rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀' hs, hfg']
-  rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀' hs, ←
+  simp_rw [← setOf_inter_eq_sep, ← Measure.restrict_apply₀' hs, hfg']
+  rw [← setOf_inter_eq_sep, ← Measure.restrict_apply₀' hs, ←
     measure_diff_null (measure_eq_top_of_lintegral_ne_top hg.aemeasurable hint)] at this
   refine' this.trans_le (measure_mono _)
   rintro x ⟨hfx, hx⟩
   dsimp at hfx
-  rw [←toReal_laverage hg.aemeasurable, toReal_le_toReal (setLaverage_lt_top hint).ne hx] at hfx
+  rw [← toReal_laverage hg.aemeasurable, toReal_le_toReal (setLaverage_lt_top hint).ne hx] at hfx
   exact hfx.trans (hgf _)
   · simp_rw [ae_iff, not_ne_iff]
     exact measure_eq_top_of_lintegral_ne_top hg.aemeasurable hint
@@ -682,7 +682,7 @@ avoiding a null set. -/
 theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α, f a ∂μ ≠ ∞) (hN : μ N = 0) :
     ∃ x, x ∉ N ∧ ⨍⁻ a, f a ∂μ ≤ f x := by
   have := measure_laverage_le_pos hμ hint
-  rw [←measure_diff_null hN] at this
+  rw [← measure_diff_null hN] at this
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_laverage_le MeasureTheory.exists_not_mem_null_laverage_le
@@ -709,7 +709,7 @@ avoiding a null set. -/
 theorem exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) (hN : μ N = 0) :
     ∃ x, x ∉ N ∧ f x ≤ ⨍⁻ a, f a ∂μ := by
   have := measure_le_laverage_pos hμ hf
-  rw [←measure_diff_null hN] at this
+  rw [← measure_diff_null hN] at this
   obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
   exact ⟨x, hxN, hx⟩
 #align measure_theory.exists_not_mem_null_le_laverage MeasureTheory.exists_not_mem_null_le_laverage
chore: tidy various files (#7017)
Diff
@@ -603,10 +603,10 @@ theorem exists_not_mem_null_integral_le (hf : Integrable f μ) (hN : μ N = 0) :
 end ProbabilityMeasure
 end FirstMomentReal
 
-section FirstMomentEnnreal
+section FirstMomentENNReal
 variable {N : Set α} {f : α → ℝ≥0∞}
 
-/-- **First moment method**. A measurable function is smaller than its mean on a set of ositive
+/-- **First moment method**. A measurable function is smaller than its mean on a set of positive
 measure. -/
 theorem measure_le_setLaverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
     (hf : AEMeasurable f (μ.restrict s)) : 0 < μ {x ∈ s | f x ≤ ⨍⁻ a in s, f a ∂μ} := by
@@ -626,7 +626,7 @@ theorem measure_le_setLaverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
     exact measure_eq_top_of_lintegral_ne_top hf h
 #align measure_theory.measure_le_set_laverage_pos MeasureTheory.measure_le_setLaverage_pos
 
-/-- **First moment method**. A measurable function is greater than its mean on a set of ositive
+/-- **First moment method**. A measurable function is greater than its mean on a set of positive
 measure. -/
 theorem measure_setLaverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
     (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : 0 < μ {x ∈ s | ⨍⁻ a in s, f a ∂μ ≤ f x} := by
@@ -649,21 +649,21 @@ theorem measure_setLaverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s
     exact measure_eq_top_of_lintegral_ne_top hg.aemeasurable hint
 #align measure_theory.measure_set_laverage_le_pos MeasureTheory.measure_setLaverage_le_pos
 
-/-- **First moment method**. The minimum of a measurable function is smaller than its ean. -/
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
 theorem exists_le_setLaverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : AEMeasurable f (μ.restrict s)) :
     ∃ x ∈ s, f x ≤ ⨍⁻ a in s, f a ∂μ :=
   let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_setLaverage_pos hμ hμ₁ hf).ne'
   ⟨x, hx, h⟩
 #align measure_theory.exists_le_set_laverage MeasureTheory.exists_le_setLaverage
 
-/-- **First moment method**. The maximum of a measurable function is greater than its ean. -/
+/-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
 theorem exists_setLaverage_le (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
     (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : ∃ x ∈ s, ⨍⁻ a in s, f a ∂μ ≤ f x :=
   let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_setLaverage_le_pos hμ hs hint).ne'
   ⟨x, hx, h⟩
 #align measure_theory.exists_set_laverage_le MeasureTheory.exists_setLaverage_le
 
-/-- **First moment method**. A measurable function is greater than its mean on a set of ositive
+/-- **First moment method**. A measurable function is greater than its mean on a set of positive
 measure. -/
 theorem measure_laverage_le_pos (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) :
     0 < μ {x | ⨍⁻ a, f a ∂μ ≤ f x} := by
@@ -671,13 +671,13 @@ theorem measure_laverage_le_pos (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠
     @measure_setLaverage_le_pos _ _ _ _ f (measure_univ_ne_zero.2 hμ) nullMeasurableSet_univ
 #align measure_theory.measure_laverage_le_pos MeasureTheory.measure_laverage_le_pos
 
-/-- **First moment method**. The maximum of a measurable function is greater than its ean. -/
+/-- **First moment method**. The maximum of a measurable function is greater than its mean. -/
 theorem exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ⨍⁻ a, f a ∂μ ≤ f x :=
   let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_laverage_le_pos hμ hint).ne'
   ⟨x, hx⟩
 #align measure_theory.exists_laverage_le MeasureTheory.exists_laverage_le
 
-/-- **First moment method**. The maximum of a measurable function is greater than its ean, while
+/-- **First moment method**. The maximum of a measurable function is greater than its mean, while
 avoiding a null set. -/
 theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α, f a ∂μ ≠ ∞) (hN : μ N = 0) :
     ∃ x, x ∉ N ∧ ⨍⁻ a, f a ∂μ ≤ f x := by
@@ -690,7 +690,7 @@ theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α,
 section FiniteMeasure
 variable [IsFiniteMeasure μ]
 
-/-- **First moment method**. A measurable function is smaller than its mean on a set of ositive
+/-- **First moment method**. A measurable function is smaller than its mean on a set of positive
 measure. -/
 theorem measure_le_laverage_pos (hμ : μ ≠ 0) (hf : AEMeasurable f μ) :
     0 < μ {x | f x ≤ ⨍⁻ a, f a ∂μ} := by
@@ -698,13 +698,13 @@ theorem measure_le_laverage_pos (hμ : μ ≠ 0) (hf : AEMeasurable f μ) :
     measure_le_setLaverage_pos (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _) hf.restrict
 #align measure_theory.measure_le_laverage_pos MeasureTheory.measure_le_laverage_pos
 
-/-- **First moment method**. The minimum of a measurable function is smaller than its ean. -/
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean. -/
 theorem exists_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) : ∃ x, f x ≤ ⨍⁻ a, f a ∂μ :=
   let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_laverage_pos hμ hf).ne'
   ⟨x, hx⟩
 #align measure_theory.exists_le_laverage MeasureTheory.exists_le_laverage
 
-/-- **First moment method**. The minimum of a measurable function is smaller than its ean, while
+/-- **First moment method**. The minimum of a measurable function is smaller than its mean, while
 avoiding a null set. -/
 theorem exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) (hN : μ N = 0) :
     ∃ x, x ∉ N ∧ f x ≤ ⨍⁻ a, f a ∂μ := by
@@ -734,18 +734,18 @@ theorem measure_lintegral_le_pos (hint : ∫⁻ a, f a ∂μ ≠ ∞) : 0 < μ {
     measure_laverage_le_pos (IsProbabilityMeasure.ne_zero μ) hint
 #align measure_theory.measure_lintegral_le_pos MeasureTheory.measure_lintegral_le_pos
 
-/-- **First moment method**. The minimum of a measurable function is smaller than its ntegral. -/
+/-- **First moment method**. The minimum of a measurable function is smaller than its integral. -/
 theorem exists_le_lintegral (hf : AEMeasurable f μ) : ∃ x, f x ≤ ∫⁻ a, f a ∂μ := by
   simpa only [laverage_eq_lintegral] using exists_le_laverage (IsProbabilityMeasure.ne_zero μ) hf
 #align measure_theory.exists_le_lintegral MeasureTheory.exists_le_lintegral
 
-/-- **First moment method**. The maximum of a measurable function is greater than its ntegral. -/
+/-- **First moment method**. The maximum of a measurable function is greater than its integral. -/
 theorem exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻ a, f a ∂μ ≤ f x := by
   simpa only [laverage_eq_lintegral] using
     exists_laverage_le (IsProbabilityMeasure.ne_zero μ) hint
 #align measure_theory.exists_lintegral_le MeasureTheory.exists_lintegral_le
 
-/-- **First moment method**. The minimum of a measurable function is smaller than its ntegral,
+/-- **First moment method**. The minimum of a measurable function is smaller than its integral,
 while avoiding a null set. -/
 theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0) :
     ∃ x, x ∉ N ∧ f x ≤ ∫⁻ a, f a ∂μ := by
@@ -753,7 +753,7 @@ theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0
     exists_not_mem_null_le_laverage (IsProbabilityMeasure.ne_zero μ) hf hN
 #align measure_theory.exists_not_mem_null_le_lintegral MeasureTheory.exists_not_mem_null_le_lintegral
 
-/-- **First moment method**. The maximum of a measurable function is greater than its ntegral,
+/-- **First moment method**. The maximum of a measurable function is greater than its integral,
 while avoiding a null set. -/
 theorem exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) (hN : μ N = 0) :
     ∃ x, x ∉ N ∧ ∫⁻ a, f a ∂μ ≤ f x := by
@@ -762,7 +762,7 @@ theorem exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) (h
 #align measure_theory.exists_not_mem_null_lintegral_le MeasureTheory.exists_not_mem_null_lintegral_le
 
 end ProbabilityMeasure
-end FirstMomentEnnreal
+end FirstMomentENNReal
 
 /-- If the average of a function `f` along a sequence of sets `aₙ` converges to `c` (more precisely,
 we require that `⨍ y in a i, ‖f y - c‖ ∂μ` tends to `0`), then the integral of `gₙ • f` also tends
chore: drop MulZeroClass. in mul_zero/zero_mul (#6682)

Search&replace MulZeroClass.mul_zero -> mul_zero, MulZeroClass.zero_mul -> zero_mul.

These were introduced by Mathport, as the full name of mul_zero is actually MulZeroClass.mul_zero (it's exported with the short name).

Diff
@@ -100,7 +100,7 @@ theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞)
 theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
     μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by
   cases' eq_or_ne μ 0 with hμ hμ
-  · rw [hμ, lintegral_zero_measure, laverage_zero_measure, MulZeroClass.mul_zero]
+  · rw [hμ, lintegral_zero_measure, laverage_zero_measure, mul_zero]
   · rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
 #align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage
 
chore: remove unused simps (#6632)

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -782,7 +782,6 @@ theorem tendsto_integral_smul_of_tendsto_average_norm_sub
     simp only [integral_undef hi, lt_self_iff_false, not_false_eq_true]
   have I : ∀ᶠ i in l, ∫ y, g i y • (f y - c) ∂μ + (∫ y, g i y ∂μ) • c = ∫ y, g i y • f y ∂μ := by
     filter_upwards [f_int, g_int, g_supp, g_bound] with i hif hig hisupp hibound
-    dsimp
     rw [← integral_smul_const, ← integral_add]
     · simp only [smul_sub, sub_add_cancel]
     · simp_rw [smul_sub]
chore: banish Type _ and Sort _ (#6499)

We remove all possible occurences of Type _ and Sort _ in favor of Type* and Sort*.

This has nice performance benefits.

Diff
@@ -44,7 +44,7 @@ open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSp
 
 open scoped Topology BigOperators ENNReal Convex
 
-variable {α E F : Type _} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
+variable {α E F : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ ν : Measure α}
   {s t : Set α}
 
@@ -769,7 +769,7 @@ we require that `⨍ y in a i, ‖f y - c‖ ∂μ` tends to `0`), then the inte
 to `c` if `gₙ` is supported in `aₙ`, has integral converging to one and supremum at most `K / μ aₙ`.
 -/
 theorem tendsto_integral_smul_of_tendsto_average_norm_sub
-    {ι : Type _} {a : ι → Set α} {l : Filter ι} {f : α → E} {c : E} {g : ι → α → ℝ} (K : ℝ)
+    {ι : Type*} {a : ι → Set α} {l : Filter ι} {f : α → E} {c : E} {g : ι → α → ℝ} (K : ℝ)
     (hf : Tendsto (fun i ↦ ⨍ y in a i, ‖f y - c‖ ∂μ) l (𝓝 0))
     (f_int : ∀ᶠ i in l, IntegrableOn f (a i) μ)
     (hg : Tendsto (fun i ↦ ∫ y, g i y ∂μ) l (𝓝 1))
feat: The convolution of a locally integrable function f with a sequence of bump functions converges ae to f (#6102)
Diff
@@ -763,4 +763,65 @@ theorem exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) (h
 
 end ProbabilityMeasure
 end FirstMomentEnnreal
+
+/-- If the average of a function `f` along a sequence of sets `aₙ` converges to `c` (more precisely,
+we require that `⨍ y in a i, ‖f y - c‖ ∂μ` tends to `0`), then the integral of `gₙ • f` also tends
+to `c` if `gₙ` is supported in `aₙ`, has integral converging to one and supremum at most `K / μ aₙ`.
+-/
+theorem tendsto_integral_smul_of_tendsto_average_norm_sub
+    {ι : Type _} {a : ι → Set α} {l : Filter ι} {f : α → E} {c : E} {g : ι → α → ℝ} (K : ℝ)
+    (hf : Tendsto (fun i ↦ ⨍ y in a i, ‖f y - c‖ ∂μ) l (𝓝 0))
+    (f_int : ∀ᶠ i in l, IntegrableOn f (a i) μ)
+    (hg : Tendsto (fun i ↦ ∫ y, g i y ∂μ) l (𝓝 1))
+    (g_supp : ∀ᶠ i in l, Function.support (g i) ⊆ a i)
+    (g_bound : ∀ᶠ i in l, ∀ x, |g i x| ≤ K / (μ (a i)).toReal) :
+    Tendsto (fun i ↦ ∫ y, g i y • f y ∂μ) l (𝓝 c) := by
+  have g_int : ∀ᶠ i in l, Integrable (g i) μ := by
+    filter_upwards [(tendsto_order.1 hg).1 _ zero_lt_one] with i hi
+    contrapose hi
+    simp only [integral_undef hi, lt_self_iff_false, not_false_eq_true]
+  have I : ∀ᶠ i in l, ∫ y, g i y • (f y - c) ∂μ + (∫ y, g i y ∂μ) • c = ∫ y, g i y • f y ∂μ := by
+    filter_upwards [f_int, g_int, g_supp, g_bound] with i hif hig hisupp hibound
+    dsimp
+    rw [← integral_smul_const, ← integral_add]
+    · simp only [smul_sub, sub_add_cancel]
+    · simp_rw [smul_sub]
+      apply Integrable.sub _ (hig.smul_const _)
+      have A : Function.support (fun y ↦ g i y • f y) ⊆ a i := by
+        apply Subset.trans _ hisupp
+        exact Function.support_smul_subset_left _ _
+      rw [← integrableOn_iff_integrable_of_support_subset A]
+      apply Integrable.smul_of_top_right hif
+      exact memℒp_top_of_bound hig.aestronglyMeasurable.restrict
+        (K / (μ (a i)).toReal) (eventually_of_forall hibound)
+    · exact hig.smul_const _
+  have L0 : Tendsto (fun i ↦ ∫ y, g i y • (f y - c) ∂μ) l (𝓝 0) := by
+    have := hf.const_mul K
+    simp only [mul_zero] at this
+    refine' squeeze_zero_norm' _ this
+    filter_upwards [g_supp, g_bound, f_int, (tendsto_order.1 hg).1 _ zero_lt_one]
+      with i hi h'i h''i hi_int
+    have mu_ai : μ (a i) < ∞ := by
+      rw [lt_top_iff_ne_top]
+      intro h
+      simp only [h, ENNReal.top_toReal, _root_.div_zero, abs_nonpos_iff] at h'i
+      have : ∫ (y : α), g i y ∂μ = ∫ (y : α), 0 ∂μ := by congr; ext y; exact h'i y
+      simp [this] at hi_int
+    apply (norm_integral_le_integral_norm _).trans
+    simp_rw [average_eq, smul_eq_mul, ← integral_mul_left, norm_smul, ← mul_assoc, ← div_eq_mul_inv]
+    have : ∀ x, x ∉ a i → ‖g i x‖ * ‖(f x - c)‖ = 0 := by
+      intro x hx
+      have : g i x = 0 := by rw [← Function.nmem_support]; exact fun h ↦ hx (hi h)
+      simp [this]
+    rw [← set_integral_eq_integral_of_forall_compl_eq_zero this (μ := μ)]
+    refine' integral_mono_of_nonneg (eventually_of_forall (fun x ↦ by positivity)) _
+      (eventually_of_forall (fun x ↦ _))
+    · apply (Integrable.sub h''i _).norm.const_mul
+      change IntegrableOn (fun _ ↦ c) (a i) μ
+      simp [integrableOn_const, mu_ai]
+    · dsimp; gcongr; simpa using h'i x
+  have := L0.add (hg.smul_const c)
+  simp only [one_smul, zero_add] at this
+  exact Tendsto.congr' I this
+
 end MeasureTheory
refactor: use NeZero for measures (#6048)

Assume NeZero μ instead of μ.ae.NeBot everywhere, and sometimes instead of μ ≠ 0.

API changes

  • Convex.average_mem, Convex.set_average_mem, ConvexOn.average_mem_epigraph, ConcaveOn.average_mem_hypograph, ConvexOn.map_average_le, ConcaveOn.le_map_average: assume [NeZero μ] instead of μ ≠ 0;
  • MeasureTheory.condexp_bot', essSup_const', essInf_const', MeasureTheory.laverage_const, MeasureTheory.laverage_one, MeasureTheory.average_const: assume [NeZero μ] instead of [μ.ae.NeBot]
  • MeasureTheory.Measure.measure_ne_zero: replace with an instance;
  • remove @[simp] from MeasureTheory.ae_restrict_neBot, use ≠ 0 in the RHS;
  • turn MeasureTheory.IsProbabilityMeasure.ae_neBot into a theorem because inferInstance can find it now;
  • add instances:
    • [NeZero μ] : NeZero (μ univ);
    • [NeZero (μ s)] : NeZero (μ.restrict s);
    • [NeZero μ] : μ.ae.NeBot;
    • [IsProbabilityMeasure μ] : NeZero μ;
    • [IsFiniteMeasure μ] [NeZero μ] : IsProbabilityMeasure ((μ univ)⁻¹ • μ) this was a theorem MeasureTheory.isProbabilityMeasureSmul assuming μ ≠ 0;
Diff
@@ -197,11 +197,9 @@ theorem laverage_mem_openSegment_compl_self [IsFiniteMeasure μ] (hs : NullMeasu
 #align measure_theory.laverage_mem_open_segment_compl_self MeasureTheory.laverage_mem_openSegment_compl_self
 
 @[simp]
-theorem laverage_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : ℝ≥0∞) :
+theorem laverage_const (μ : Measure α) [IsFiniteMeasure μ] [h : NeZero μ] (c : ℝ≥0∞) :
     ⨍⁻ _x, c ∂μ = c := by
-  simp only [laverage_eq, lintegral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter,
-    div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel, mul_one, measure_ne_top μ univ, Ne.def,
-    measure_univ_ne_zero, ae_neBot.1 h, not_false_iff]
+  simp only [laverage, lintegral_const, measure_univ, mul_one]
 #align measure_theory.laverage_const MeasureTheory.laverage_const
 
 theorem setLaverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0∞) : ⨍⁻ _x in s, c ∂μ = c := by
@@ -209,7 +207,7 @@ theorem setLaverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0
     univ_inter, div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel hs₀ hs, mul_one]
 #align measure_theory.set_laverage_const MeasureTheory.setLaverage_const
 
-theorem laverage_one [IsFiniteMeasure μ] [μ.ae.NeBot] : ⨍⁻ _x, (1 : ℝ≥0∞) ∂μ = 1 :=
+theorem laverage_one [IsFiniteMeasure μ] [NeZero μ] : ⨍⁻ _x, (1 : ℝ≥0∞) ∂μ = 1 :=
   laverage_const _ _
 #align measure_theory.laverage_one MeasureTheory.laverage_one
 
@@ -387,19 +385,14 @@ theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {
 #align measure_theory.average_mem_open_segment_compl_self MeasureTheory.average_mem_openSegment_compl_self
 
 @[simp]
-theorem average_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : E) :
+theorem average_const (μ : Measure α) [IsFiniteMeasure μ] [h : NeZero μ] (c : E) :
     ⨍ _x, c ∂μ = c := by
-  simp only [average_eq, integral_const, Measure.restrict_apply, MeasurableSet.univ, one_smul,
-    univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
-    measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_neBot.1 h, not_false_iff,
-    ENNReal.one_toReal]
+  rw [average, integral_const, measure_univ, ENNReal.one_toReal, one_smul]
 #align measure_theory.average_const MeasureTheory.average_const
 
 theorem setAverage_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) :
-    ⨍ _ in s, c ∂μ = c := by
-  simp only [setAverage_eq, integral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter,
-    smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel hs₀ hs,
-    ENNReal.one_toReal, one_smul]
+    ⨍ _ in s, c ∂μ = c :=
+  have := NeZero.mk hs₀; have := Fact.mk hs.lt_top; average_const _ _
 #align measure_theory.set_average_const MeasureTheory.setAverage_const
 
 -- porting note: was `@[simp]` but `simp` can prove it
chore: script to replace headers with #align_import statements (#5979)

Open in Gitpod

Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -2,14 +2,11 @@
 Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury G. Kudryashov, Yaël Dillies
-
-! This file was ported from Lean 3 source module measure_theory.integral.average
-! leanprover-community/mathlib commit c14c8fcde993801fca8946b0d80131a1a81d1520
-! Please do not edit these lines, except to modify the commit id
-! if you have ported upstream changes.
 -/
 import Mathlib.MeasureTheory.Integral.SetIntegral
 
+#align_import measure_theory.integral.average from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
+
 /-!
 # Integral average of a function
 
feat: Lebesgue average (#5810)

Match https://github.com/leanprover-community/mathlib/pull/19199

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>

Diff
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
 Authors: Yury G. Kudryashov, Yaël Dillies
 
 ! This file was ported from Lean 3 source module measure_theory.integral.average
-! leanprover-community/mathlib commit ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f
+! leanprover-community/mathlib commit c14c8fcde993801fca8946b0d80131a1a81d1520
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -21,6 +21,8 @@ measure, then the average of any function is equal to its integral.
 For the average on a set, we use `⨍ x in s, f x ∂μ` (notation for `⨍ x, f x ∂(μ.restrict s)`). For
 average w.r.t. the volume, one can omit `∂volume`.
 
+Both have a version for the Lebesgue integral rather than Bochner.
+
 We prove several version of the first moment method: An integrable function is below/above its
 average on a set of positive measure.
 
@@ -46,20 +48,194 @@ open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSp
 open scoped Topology BigOperators ENNReal Convex
 
 variable {α E F : Type _} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
-  [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ : Measure α}
+  [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ ν : Measure α}
   {s t : Set α}
 
 /-!
 ### Average value of a function w.r.t. a measure
 
-The average value of a function `f` w.r.t. a measure `μ` (notation: `⨍ x, f x ∂μ`) is defined as
-`(μ univ).toReal⁻¹ • ∫ x, f x ∂μ`, so it is equal to zero if `f` is not integrable or if `μ` is an
-infinite measure. If `μ` is a probability measure, then the average of any function is equal to its
-integral.
-
+The (Bochner, Lebesgue) average value of a function `f` w.r.t. a measure `μ` (notation:
+`⨍ x, f x ∂μ`, `⨍⁻ x, f x ∂μ`) is defined as the (Bochner, Lebesgue) integral divided by the total
+measure, so it is equal to zero if `μ` is an infinite measure, and (typically) equal to infinity if
+`f` is not integrable. If `μ` is a probability measure, then the average of any function is equal to
+its integral.
 -/
 
 namespace MeasureTheory
+section ENNReal
+variable (μ) {f g : α → ℝ≥0∞}
+
+/-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`, notation: `⨍⁻ x, f x ∂μ`.
+It is defined as `μ univ⁻¹ * ∫⁻ x, f x ∂μ`, so it is equal to zero if `μ` is an infinite measure. If
+`μ` is a probability measure, then the average of any function is equal to its integral.
+
+For the average on a set, use `⨍⁻ x in s, f x ∂μ` (defined as `⨍⁻ x, f x ∂(μ.restrict s)`). For
+average w.r.t. the volume, one can omit `∂volume`. -/
+noncomputable def laverage (f : α → ℝ≥0∞) := ∫⁻ x, f x ∂(μ univ)⁻¹ • μ
+#align measure_theory.laverage MeasureTheory.laverage
+
+notation3"⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r
+notation3"⨍⁻ "(...)", "r:60:(scoped f => laverage volume f) => r
+notation3"⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (Measure.restrict μ s) r
+notation3 (prettyPrint := false)
+  "⨍⁻ "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r
+
+@[simp]
+theorem laverage_zero : ⨍⁻ _x, (0 : ℝ≥0∞) ∂μ = 0 := by rw [laverage, lintegral_zero]
+#align measure_theory.laverage_zero MeasureTheory.laverage_zero
+
+@[simp]
+theorem laverage_zero_measure (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂(0 : Measure α) = 0 := by simp [laverage]
+#align measure_theory.laverage_zero_measure MeasureTheory.laverage_zero_measure
+
+theorem laverage_eq' (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂(μ univ)⁻¹ • μ := rfl
+#align measure_theory.laverage_eq' MeasureTheory.laverage_eq'
+
+theorem laverage_eq (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = (∫⁻ x, f x ∂μ) / μ univ := by
+  rw [laverage_eq', lintegral_smul_measure, ENNReal.div_eq_inv_mul]
+#align measure_theory.laverage_eq MeasureTheory.laverage_eq
+
+theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞) :
+    ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [laverage, measure_univ, inv_one, one_smul]
+#align measure_theory.laverage_eq_lintegral MeasureTheory.laverage_eq_lintegral
+
+@[simp]
+theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
+    μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by
+  cases' eq_or_ne μ 0 with hμ hμ
+  · rw [hμ, lintegral_zero_measure, laverage_zero_measure, MulZeroClass.mul_zero]
+  · rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
+#align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage
+
+theorem setLaverage_eq (f : α → ℝ≥0∞) (s : Set α) :
+    ⨍⁻ x in s, f x ∂μ = (∫⁻ x in s, f x ∂μ) / μ s := by rw [laverage_eq, restrict_apply_univ]
+#align measure_theory.set_laverage_eq MeasureTheory.setLaverage_eq
+
+theorem setLaverage_eq' (f : α → ℝ≥0∞) (s : Set α) :
+    ⨍⁻ x in s, f x ∂μ = ∫⁻ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
+  simp only [laverage_eq', restrict_apply_univ]
+#align measure_theory.set_laverage_eq' MeasureTheory.setLaverage_eq'
+
+variable {μ}
+
+theorem laverage_congr {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ⨍⁻ x, f x ∂μ = ⨍⁻ x, g x ∂μ := by
+  simp only [laverage_eq, lintegral_congr_ae h]
+#align measure_theory.laverage_congr MeasureTheory.laverage_congr
+
+theorem setLaverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ := by
+  simp only [setLaverage_eq, set_lintegral_congr h, measure_congr h]
+#align measure_theory.set_laverage_congr MeasureTheory.setLaverage_congr
+
+theorem setLaverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+    ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in s, g x ∂μ := by
+  simp only [laverage_eq, set_lintegral_congr_fun hs h]
+#align measure_theory.set_laverage_congr_fun MeasureTheory.setLaverage_congr_fun
+
+theorem laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ < ∞ := by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp
+  · rw [laverage_eq]
+    exact div_lt_top hf (measure_univ_ne_zero.2 hμ)
+#align measure_theory.laverage_lt_top MeasureTheory.laverage_lt_top
+
+theorem setLaverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ :=
+  laverage_lt_top
+#align measure_theory.set_laverage_lt_top MeasureTheory.setLaverage_lt_top
+
+theorem laverage_add_measure :
+    ⨍⁻ x, f x ∂(μ + ν) =
+      μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν := by
+  by_cases hμ : IsFiniteMeasure μ; swap
+  · rw [not_isFiniteMeasure_iff] at hμ
+    simp [laverage_eq, hμ]
+  by_cases hν : IsFiniteMeasure ν; swap
+  · rw [not_isFiniteMeasure_iff] at hν
+    simp [laverage_eq, hν]
+  haveI := hμ; haveI := hν
+  simp only [←ENNReal.mul_div_right_comm, measure_mul_laverage, ←ENNReal.add_div,
+    ←lintegral_add_measure, ←Measure.add_apply, ←laverage_eq]
+#align measure_theory.laverage_add_measure MeasureTheory.laverage_add_measure
+
+theorem measure_mul_setLaverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) :
+    μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ := by
+  have := Fact.mk h.lt_top
+  rw [←measure_mul_laverage, restrict_apply_univ]
+#align measure_theory.measure_mul_set_laverage MeasureTheory.measure_mul_setLaverage
+
+theorem laverage_union (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) :
+    ⨍⁻ x in s ∪ t, f x ∂μ =
+      μ s / (μ s + μ t) * ⨍⁻ x in s, f x ∂μ + μ t / (μ s + μ t) * ⨍⁻ x in t, f x ∂μ :=
+  by rw [restrict_union₀ hd ht, laverage_add_measure, restrict_apply_univ, restrict_apply_univ]
+#align measure_theory.laverage_union MeasureTheory.laverage_union
+
+theorem laverage_union_mem_openSegment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
+    (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
+    ⨍⁻ x in s ∪ t, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in t, f x ∂μ) := by
+  refine'
+    ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), ENNReal.div_pos hs₀ <| add_ne_top.2 ⟨hsμ, htμ⟩,
+      ENNReal.div_pos ht₀ <| add_ne_top.2 ⟨hsμ, htμ⟩, _, (laverage_union hd ht).symm⟩
+  rw [←ENNReal.add_div,
+    ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
+#align measure_theory.laverage_union_mem_open_segment MeasureTheory.laverage_union_mem_openSegment
+
+theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
+    (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) :
+    ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ] := by
+  by_cases hs₀ : μ s = 0
+  · rw [←ae_eq_empty] at hs₀
+    rw [restrict_congr_set (hs₀.union EventuallyEq.rfl), empty_union]
+    exact right_mem_segment _ _ _
+  · refine'
+      ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), zero_le _, zero_le _, _, (laverage_union hd ht).symm⟩
+    rw [←ENNReal.add_div,
+      ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)]
+#align measure_theory.laverage_union_mem_segment MeasureTheory.laverage_union_mem_segment
+
+theorem laverage_mem_openSegment_compl_self [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ)
+    (hs₀ : μ s ≠ 0) (hsc₀ : μ sᶜ ≠ 0) :
+    ⨍⁻ x, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in sᶜ, f x ∂μ) := by
+  simpa only [union_compl_self, restrict_univ] using
+    laverage_union_mem_openSegment aedisjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _)
+      (measure_ne_top _ _)
+#align measure_theory.laverage_mem_open_segment_compl_self MeasureTheory.laverage_mem_openSegment_compl_self
+
+@[simp]
+theorem laverage_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : ℝ≥0∞) :
+    ⨍⁻ _x, c ∂μ = c := by
+  simp only [laverage_eq, lintegral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter,
+    div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel, mul_one, measure_ne_top μ univ, Ne.def,
+    measure_univ_ne_zero, ae_neBot.1 h, not_false_iff]
+#align measure_theory.laverage_const MeasureTheory.laverage_const
+
+theorem setLaverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0∞) : ⨍⁻ _x in s, c ∂μ = c := by
+  simp only [setLaverage_eq, lintegral_const, Measure.restrict_apply, MeasurableSet.univ,
+    univ_inter, div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel hs₀ hs, mul_one]
+#align measure_theory.set_laverage_const MeasureTheory.setLaverage_const
+
+theorem laverage_one [IsFiniteMeasure μ] [μ.ae.NeBot] : ⨍⁻ _x, (1 : ℝ≥0∞) ∂μ = 1 :=
+  laverage_const _ _
+#align measure_theory.laverage_one MeasureTheory.laverage_one
+
+theorem setLaverage_one (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) : ⨍⁻ _x in s, (1 : ℝ≥0∞) ∂μ = 1 :=
+  setLaverage_const hs₀ hs _
+#align measure_theory.set_laverage_one MeasureTheory.setLaverage_one
+
+--porting note: Dropped `simp` because of `simp` seeing through `1 : α → ℝ≥0∞` and applying
+-- `lintegral_const`. This is suboptimal.
+theorem lintegral_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) :
+    ∫⁻ _x, ⨍⁻ a, f a ∂μ ∂μ = ∫⁻ x, f x ∂μ := by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp
+  · rw [lintegral_const, laverage_eq,
+      ENNReal.div_mul_cancel (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
+#align measure_theory.lintegral_laverage MeasureTheory.lintegral_laverage
+
+theorem setLintegral_setLaverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) (s : Set α) :
+    ∫⁻ _x in s, ⨍⁻ a in s, f a ∂μ ∂μ = ∫⁻ x in s, f x ∂μ :=
+  lintegral_laverage _ _
+#align measure_theory.set_lintegral_set_laverage MeasureTheory.setLintegral_setLaverage
+
+end ENNReal
 
 section NormedAddCommGroup
 
@@ -125,14 +301,14 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
     rwa [Ne.def, measure_univ_eq_zero]
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
 
-theorem set_average_eq (f : α → E) (s : Set α) :
+theorem setAverage_eq (f : α → E) (s : Set α) :
     ⨍ x in s, f x ∂μ = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by rw [average_eq, restrict_apply_univ]
-#align measure_theory.set_average_eq MeasureTheory.set_average_eq
+#align measure_theory.set_average_eq MeasureTheory.setAverage_eq
 
-theorem set_average_eq' (f : α → E) (s : Set α) :
+theorem setAverage_eq' (f : α → E) (s : Set α) :
     ⨍ x in s, f x ∂μ = ∫ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
   simp only [average_eq', restrict_apply_univ]
-#align measure_theory.set_average_eq' MeasureTheory.set_average_eq'
+#align measure_theory.set_average_eq' MeasureTheory.setAverage_eq'
 
 variable {μ}
 
@@ -140,17 +316,21 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = 
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
 
-theorem set_average_congr_set_ae (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
-  simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
-#align measure_theory.set_average_congr_set_ae MeasureTheory.set_average_congr_set_ae
+theorem setAverage_congr (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
+  simp only [setAverage_eq, set_integral_congr_set_ae h, measure_congr h]
+#align measure_theory.set_average_congr MeasureTheory.setAverage_congr
+
+theorem setAverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) :
+    ⨍ x in s, f x ∂μ = ⨍ x in s, g x ∂μ := by simp only [average_eq, set_integral_congr_ae hs h]
+#align measure_theory.set_average_congr_fun MeasureTheory.setAverage_congr_fun
 
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
     ⨍ x, f x ∂(μ + ν) =
       ((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ +
         ((ν univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂ν := by
-  simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ← smul_add, ←
-    integral_add_measure hμ hν, ← ENNReal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
+  simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ←smul_add,
+    ←integral_add_measure hμ hν, ←ENNReal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
   rw [average_eq, Measure.add_apply]
 #align measure_theory.average_add_measure MeasureTheory.average_add_measure
 
@@ -159,11 +339,11 @@ theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi
   integral_pair hfi.to_average hgi.to_average
 #align measure_theory.average_pair MeasureTheory.average_pair
 
-theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
+theorem measure_smul_setAverage (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
     (μ s).toReal • ⨍ x in s, f x ∂μ = ∫ x in s, f x ∂μ := by
   haveI := Fact.mk h.lt_top
-  rw [← measure_smul_average, restrict_apply_univ]
-#align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_set_average
+  rw [←measure_smul_average, restrict_apply_univ]
+#align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_setAverage
 
 theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
@@ -189,7 +369,7 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
     (hft : IntegrableOn f t μ) :
     ⨍ x in s ∪ t, f x ∂μ ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] := by
   by_cases hse : μ s = 0
-  · rw [← ae_eq_empty] at hse
+  · rw [←ae_eq_empty] at hse
     rw [restrict_congr_set (hse.union EventuallyEq.rfl), empty_union]
     exact right_mem_segment _ _ _
   · refine'
@@ -210,29 +390,30 @@ theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {
 #align measure_theory.average_mem_open_segment_compl_self MeasureTheory.average_mem_openSegment_compl_self
 
 @[simp]
-theorem average_const [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : E) : ⨍ _, c ∂μ = c := by
+theorem average_const (μ : Measure α) [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : E) :
+    ⨍ _x, c ∂μ = c := by
   simp only [average_eq, integral_const, Measure.restrict_apply, MeasurableSet.univ, one_smul,
     univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_neBot.1 h, not_false_iff,
     ENNReal.one_toReal]
 #align measure_theory.average_const MeasureTheory.average_const
 
-theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) :
+theorem setAverage_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) :
     ⨍ _ in s, c ∂μ = c := by
-  simp only [set_average_eq, integral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter,
+  simp only [setAverage_eq, integral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter,
     smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel hs₀ hs,
     ENNReal.one_toReal, one_smul]
-#align measure_theory.set_average_const MeasureTheory.set_average_const
+#align measure_theory.set_average_const MeasureTheory.setAverage_const
 
 -- porting note: was `@[simp]` but `simp` can prove it
 theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
     ∫ _, ⨍ a, f a ∂μ ∂μ = ∫ x, f x ∂μ := by simp
 #align measure_theory.integral_average MeasureTheory.integral_average
 
-theorem setAverage_setAverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
+theorem setIntegral_setAverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
     ∫ _ in s, ⨍ a in s, f a ∂μ ∂μ = ∫ x in s, f x ∂μ :=
   integral_average _ _
-#align measure_theory.set_integral_set_average MeasureTheory.setAverage_setAverage
+#align measure_theory.set_integral_set_average MeasureTheory.setIntegral_setAverage
 
 theorem integral_sub_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
     ∫ x, f x - ⨍ a, f a ∂μ ∂μ = 0 := by
@@ -254,11 +435,11 @@ theorem integral_average_sub [IsFiniteMeasure μ] (hf : Integrable f μ) :
   rw [integral_sub (integrable_const _) hf, integral_average, sub_self]
 #align measure_theory.integral_average_sub MeasureTheory.integral_average_sub
 
-theorem setAverage_setAverage_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+theorem setIntegral_setAverage_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
     ∫ x in s, ⨍ a in s, f a ∂μ - f x ∂μ = 0 :=
   haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
   integral_average_sub hf
-#align measure_theory.set_integral_set_average_sub MeasureTheory.setAverage_setAverage_sub
+#align measure_theory.set_integral_set_average_sub MeasureTheory.setIntegral_setAverage_sub
 
 end NormedAddCommGroup
 
@@ -276,22 +457,21 @@ theorem ofReal_setAverage {f : α → ℝ} (hf : IntegrableOn f s μ) (hf₀ : 0
   simpa using ofReal_average hf hf₀
 #align measure_theory.of_real_set_average MeasureTheory.ofReal_setAverage
 
-theorem average_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
-    ⨍ x, (f x).toReal ∂μ = ((∫⁻ x, f x ∂μ) / μ univ).toReal := by
-  rw [average_eq, smul_eq_mul, toReal_div, ←
-    integral_toReal hf (hf'.mono fun _ => lt_top_iff_ne_top.2), div_eq_inv_mul]
-#align measure_theory.average_to_real MeasureTheory.average_toReal
+theorem toReal_laverage {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
+    (⨍⁻ x, f x ∂μ).toReal = ⨍ x, (f x).toReal ∂μ := by
+    rw [average_eq, laverage_eq, smul_eq_mul, toReal_div, div_eq_inv_mul, ←
+      integral_toReal hf (hf'.mono fun _ => lt_top_iff_ne_top.2)]
+#align measure_theory.to_real_laverage MeasureTheory.toReal_laverage
 
-theorem setAverage_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
+theorem toReal_setLaverage {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
     (hf' : ∀ᵐ x ∂μ.restrict s, f x ≠ ∞) :
-    ⨍ x in s, (f x).toReal ∂μ = ((∫⁻ x in s, f x ∂μ) / μ s).toReal := by
-  simpa using average_toReal hf hf'
-#align measure_theory.set_average_to_real MeasureTheory.setAverage_toReal
+    (⨍⁻ x in s, f x ∂μ).toReal = ⨍ x in s, (f x).toReal ∂μ := by
+  simpa [laverage_eq] using toReal_laverage hf hf'
+#align measure_theory.to_real_set_laverage MeasureTheory.toReal_setLaverage
 
 /-! ### First moment method -/
 
-section FirstMoment
-
+section FirstMomentReal
 variable {N : Set α} {f : α → ℝ}
 
 /-- **First moment method**. An integrable function is smaller than its mean on a set of positive
@@ -431,7 +611,166 @@ theorem exists_not_mem_null_integral_le (hf : Integrable f μ) (hN : μ N = 0) :
 #align measure_theory.exists_not_mem_null_integral_le MeasureTheory.exists_not_mem_null_integral_le
 
 end ProbabilityMeasure
+end FirstMomentReal
+
+section FirstMomentEnnreal
+variable {N : Set α} {f : α → ℝ≥0∞}
+
+/-- **First moment method**. A measurable function is smaller than its mean on a set of ositive
+measure. -/
+theorem measure_le_setLaverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞)
+    (hf : AEMeasurable f (μ.restrict s)) : 0 < μ {x ∈ s | f x ≤ ⨍⁻ a in s, f a ∂μ} := by
+  obtain h | h := eq_or_ne (∫⁻ a in s, f a ∂μ) ∞
+  · simpa [mul_top, hμ₁, laverage, h, top_div_of_ne_top hμ₁, pos_iff_ne_zero] using hμ
+  have := measure_le_setAverage_pos hμ hμ₁ (integrable_toReal_of_lintegral_ne_top hf h)
+  rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀
+    (hf.aestronglyMeasurable.nullMeasurableSet_le aestronglyMeasurable_const)]
+  rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀
+    (hf.ennreal_toReal.aestronglyMeasurable.nullMeasurableSet_le aestronglyMeasurable_const),
+    ←measure_diff_null (measure_eq_top_of_lintegral_ne_top hf h)] at this
+  refine' this.trans_le (measure_mono _)
+  rintro x ⟨hfx, hx⟩
+  dsimp at hfx
+  rwa [←toReal_laverage hf, toReal_le_toReal hx (setLaverage_lt_top h).ne] at hfx
+  · simp_rw [ae_iff, not_ne_iff]
+    exact measure_eq_top_of_lintegral_ne_top hf h
+#align measure_theory.measure_le_set_laverage_pos MeasureTheory.measure_le_setLaverage_pos
+
+/-- **First moment method**. A measurable function is greater than its mean on a set of ositive
+measure. -/
+theorem measure_setLaverage_le_pos (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
+    (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : 0 < μ {x ∈ s | ⨍⁻ a in s, f a ∂μ ≤ f x} := by
+  obtain hμ₁ | hμ₁ := eq_or_ne (μ s) ∞
+  · simp [setLaverage_eq, hμ₁]
+  obtain ⟨g, hg, hgf, hfg⟩ := exists_measurable_le_lintegral_eq (μ.restrict s) f
+  have hfg' : ⨍⁻ a in s, f a ∂μ = ⨍⁻ a in s, g a ∂μ := by simp_rw [laverage_eq, hfg]
+  rw [hfg] at hint
+  have :=
+    measure_setAverage_le_pos hμ hμ₁ (integrable_toReal_of_lintegral_ne_top hg.aemeasurable hint)
+  simp_rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀' hs, hfg']
+  rw [←setOf_inter_eq_sep, ←Measure.restrict_apply₀' hs, ←
+    measure_diff_null (measure_eq_top_of_lintegral_ne_top hg.aemeasurable hint)] at this
+  refine' this.trans_le (measure_mono _)
+  rintro x ⟨hfx, hx⟩
+  dsimp at hfx
+  rw [←toReal_laverage hg.aemeasurable, toReal_le_toReal (setLaverage_lt_top hint).ne hx] at hfx
+  exact hfx.trans (hgf _)
+  · simp_rw [ae_iff, not_ne_iff]
+    exact measure_eq_top_of_lintegral_ne_top hg.aemeasurable hint
+#align measure_theory.measure_set_laverage_le_pos MeasureTheory.measure_setLaverage_le_pos
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its ean. -/
+theorem exists_le_setLaverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : AEMeasurable f (μ.restrict s)) :
+    ∃ x ∈ s, f x ≤ ⨍⁻ a in s, f a ∂μ :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_setLaverage_pos hμ hμ₁ hf).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_le_set_laverage MeasureTheory.exists_le_setLaverage
+
+/-- **First moment method**. The maximum of a measurable function is greater than its ean. -/
+theorem exists_setLaverage_le (hμ : μ s ≠ 0) (hs : NullMeasurableSet s μ)
+    (hint : ∫⁻ a in s, f a ∂μ ≠ ∞) : ∃ x ∈ s, ⨍⁻ a in s, f a ∂μ ≤ f x :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_setLaverage_le_pos hμ hs hint).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_set_laverage_le MeasureTheory.exists_setLaverage_le
+
+/-- **First moment method**. A measurable function is greater than its mean on a set of ositive
+measure. -/
+theorem measure_laverage_le_pos (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) :
+    0 < μ {x | ⨍⁻ a, f a ∂μ ≤ f x} := by
+  simpa [hint] using
+    @measure_setLaverage_le_pos _ _ _ _ f (measure_univ_ne_zero.2 hμ) nullMeasurableSet_univ
+#align measure_theory.measure_laverage_le_pos MeasureTheory.measure_laverage_le_pos
+
+/-- **First moment method**. The maximum of a measurable function is greater than its ean. -/
+theorem exists_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ⨍⁻ a, f a ∂μ ≤ f x :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_laverage_le_pos hμ hint).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_laverage_le MeasureTheory.exists_laverage_le
+
+/-- **First moment method**. The maximum of a measurable function is greater than its ean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_laverage_le (hμ : μ ≠ 0) (hint : ∫⁻ a : α, f a ∂μ ≠ ∞) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ ⨍⁻ a, f a ∂μ ≤ f x := by
+  have := measure_laverage_le_pos hμ hint
+  rw [←measure_diff_null hN] at this
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
+  exact ⟨x, hxN, hx⟩
+#align measure_theory.exists_not_mem_null_laverage_le MeasureTheory.exists_not_mem_null_laverage_le
+
+section FiniteMeasure
+variable [IsFiniteMeasure μ]
+
+/-- **First moment method**. A measurable function is smaller than its mean on a set of ositive
+measure. -/
+theorem measure_le_laverage_pos (hμ : μ ≠ 0) (hf : AEMeasurable f μ) :
+    0 < μ {x | f x ≤ ⨍⁻ a, f a ∂μ} := by
+  simpa using
+    measure_le_setLaverage_pos (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _) hf.restrict
+#align measure_theory.measure_le_laverage_pos MeasureTheory.measure_le_laverage_pos
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its ean. -/
+theorem exists_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) : ∃ x, f x ≤ ⨍⁻ a, f a ∂μ :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_laverage_pos hμ hf).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_le_laverage MeasureTheory.exists_le_laverage
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its ean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_le_laverage (hμ : μ ≠ 0) (hf : AEMeasurable f μ) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ f x ≤ ⨍⁻ a, f a ∂μ := by
+  have := measure_le_laverage_pos hμ hf
+  rw [←measure_diff_null hN] at this
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
+  exact ⟨x, hxN, hx⟩
+#align measure_theory.exists_not_mem_null_le_laverage MeasureTheory.exists_not_mem_null_le_laverage
 
-end FirstMoment
+end FiniteMeasure
 
+section ProbabilityMeasure
+
+variable [IsProbabilityMeasure μ]
+
+/-- **First moment method**. A measurable function is smaller than its integral on a set f
+positive measure. -/
+theorem measure_le_lintegral_pos (hf : AEMeasurable f μ) : 0 < μ {x | f x ≤ ∫⁻ a, f a ∂μ} := by
+  simpa only [laverage_eq_lintegral] using
+    measure_le_laverage_pos (IsProbabilityMeasure.ne_zero μ) hf
+#align measure_theory.measure_le_lintegral_pos MeasureTheory.measure_le_lintegral_pos
+
+/-- **First moment method**. A measurable function is greater than its integral on a set f
+positive measure. -/
+theorem measure_lintegral_le_pos (hint : ∫⁻ a, f a ∂μ ≠ ∞) : 0 < μ {x | ∫⁻ a, f a ∂μ ≤ f x} := by
+  simpa only [laverage_eq_lintegral] using
+    measure_laverage_le_pos (IsProbabilityMeasure.ne_zero μ) hint
+#align measure_theory.measure_lintegral_le_pos MeasureTheory.measure_lintegral_le_pos
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its ntegral. -/
+theorem exists_le_lintegral (hf : AEMeasurable f μ) : ∃ x, f x ≤ ∫⁻ a, f a ∂μ := by
+  simpa only [laverage_eq_lintegral] using exists_le_laverage (IsProbabilityMeasure.ne_zero μ) hf
+#align measure_theory.exists_le_lintegral MeasureTheory.exists_le_lintegral
+
+/-- **First moment method**. The maximum of a measurable function is greater than its ntegral. -/
+theorem exists_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) : ∃ x, ∫⁻ a, f a ∂μ ≤ f x := by
+  simpa only [laverage_eq_lintegral] using
+    exists_laverage_le (IsProbabilityMeasure.ne_zero μ) hint
+#align measure_theory.exists_lintegral_le MeasureTheory.exists_lintegral_le
+
+/-- **First moment method**. The minimum of a measurable function is smaller than its ntegral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_le_lintegral (hf : AEMeasurable f μ) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ f x ≤ ∫⁻ a, f a ∂μ := by
+  simpa only [laverage_eq_lintegral] using
+    exists_not_mem_null_le_laverage (IsProbabilityMeasure.ne_zero μ) hf hN
+#align measure_theory.exists_not_mem_null_le_lintegral MeasureTheory.exists_not_mem_null_le_lintegral
+
+/-- **First moment method**. The maximum of a measurable function is greater than its ntegral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_lintegral_le (hint : ∫⁻ a, f a ∂μ ≠ ∞) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ ∫⁻ a, f a ∂μ ≤ f x := by
+  simpa only [laverage_eq_lintegral] using
+    exists_not_mem_null_laverage_le (IsProbabilityMeasure.ne_zero μ) hint hN
+#align measure_theory.exists_not_mem_null_lintegral_le MeasureTheory.exists_not_mem_null_lintegral_le
+
+end ProbabilityMeasure
+end FirstMomentEnnreal
 end MeasureTheory
feat: first moment method (#5326)

Forward-port leanprover-community/mathlib#18731 Also sync some parentheses with the lates mathport output.

Co-authored-by: Yaël Dillies <yael.dillies@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com>

Diff
@@ -1,10 +1,10 @@
 /-
 Copyright (c) 2022 Yury G. Kudryashov. All rights reserved.
 Released under Apache 2.0 license as described in the file LICENSE.
-Authors: Yury G. Kudryashov
+Authors: Yury G. Kudryashov, Yaël Dillies
 
 ! This file was ported from Lean 3 source module measure_theory.integral.average
-! leanprover-community/mathlib commit f2ce6086713c78a7f880485f7917ea547a215982
+! leanprover-community/mathlib commit ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f
 ! Please do not edit these lines, except to modify the commit id
 ! if you have ported upstream changes.
 -/
@@ -21,25 +21,33 @@ measure, then the average of any function is equal to its integral.
 For the average on a set, we use `⨍ x in s, f x ∂μ` (notation for `⨍ x, f x ∂(μ.restrict s)`). For
 average w.r.t. the volume, one can omit `∂volume`.
 
+We prove several version of the first moment method: An integrable function is below/above its
+average on a set of positive measure.
+
 ## Implementation notes
 
 The average is defined as an integral over `(μ univ)⁻¹ • μ` so that all theorems about Bochner
 integrals work for the average without modifications. For theorems that require integrability of a
 function, we provide a convenience lemma `MeasureTheory.Integrable.to_average`.
 
+## TODO
+
+Provide the first moment method for the Lebesgue integral as well. A draft is available on branch
+`first_moment_lintegral` in mathlib3 repository.
+
 ## Tags
 
 integral, center mass, average value
 -/
 
 
-open MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
+open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
 
 open scoped Topology BigOperators ENNReal Convex
 
 variable {α E F : Type _} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E]
   [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ : Measure α}
-  {s : Set E}
+  {s t : Set α}
 
 /-!
 ### Average value of a function w.r.t. a measure
@@ -51,10 +59,12 @@ integral.
 
 -/
 
-
 namespace MeasureTheory
 
+section NormedAddCommGroup
+
 variable (μ)
+variable {f g : α → E}
 
 /-- Average value of a function `f` w.r.t. a measure `μ`, notation: `⨍ x, f x ∂μ`. It is defined as
 `(μ univ).toReal⁻¹ • ∫ x, f x ∂μ`, so it is equal to zero if `f` is not integrable or if `μ` is an
@@ -84,7 +94,7 @@ theorem average_zero : ⨍ _, (0 : E) ∂μ = 0 := by rw [average, integral_zero
 #align measure_theory.average_zero MeasureTheory.average_zero
 
 @[simp]
-theorem average_zero_measure (f : α → E) : (⨍ x, f x ∂(0 : Measure α)) = 0 := by
+theorem average_zero_measure (f : α → E) : ⨍ x, f x ∂(0 : Measure α) = 0 := by
   rw [average, smul_zero, integral_zero_measure]
 #align measure_theory.average_zero_measure MeasureTheory.average_zero_measure
 
@@ -107,7 +117,7 @@ theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : ⨍ x, f
 
 @[simp]
 theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
-    ((μ univ).toReal • ⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
+    (μ univ).toReal • ⨍ x, f x ∂μ = ∫ x, f x ∂μ := by
   cases' eq_or_ne μ 0 with hμ hμ
   · rw [hμ, integral_zero_measure, average_zero_measure, smul_zero]
   · rw [average_eq, smul_inv_smul₀]
@@ -116,8 +126,7 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
 
 theorem set_average_eq (f : α → E) (s : Set α) :
-    ⨍ x in s, f x ∂μ = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by
-  rw [average_eq, restrict_apply_univ]
+    ⨍ x in s, f x ∂μ = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by rw [average_eq, restrict_apply_univ]
 #align measure_theory.set_average_eq MeasureTheory.set_average_eq
 
 theorem set_average_eq' (f : α → E) (s : Set α) :
@@ -131,10 +140,14 @@ theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = 
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
 
+theorem set_average_congr_set_ae (h : s =ᵐ[μ] t) : ⨍ x in s, f x ∂μ = ⨍ x in t, f x ∂μ := by
+  simp only [set_average_eq, set_integral_congr_set_ae h, measure_congr h]
+#align measure_theory.set_average_congr_set_ae MeasureTheory.set_average_congr_set_ae
+
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
     ⨍ x, f x ∂(μ + ν) =
-      (((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ) +
+      ((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ +
         ((ν univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂ν := by
   simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ← smul_add, ←
     integral_add_measure hμ hν, ← ENNReal.toReal_add (measure_ne_top μ _) (measure_ne_top ν _)]
@@ -147,7 +160,7 @@ theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi
 #align measure_theory.average_pair MeasureTheory.average_pair
 
 theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞) :
-    ((μ s).toReal • ⨍ x in s, f x ∂μ) = ∫ x in s, f x ∂μ := by
+    (μ s).toReal • ⨍ x in s, f x ∂μ = ∫ x in s, f x ∂μ := by
   haveI := Fact.mk h.lt_top
   rw [← measure_smul_average, restrict_apply_univ]
 #align measure_theory.measure_smul_set_average MeasureTheory.measure_smul_set_average
@@ -155,7 +168,7 @@ theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞)
 theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
     ⨍ x in s ∪ t, f x ∂μ =
-      (((μ s).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in s, f x ∂μ) +
+      ((μ s).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in s, f x ∂μ +
         ((μ t).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in t, f x ∂μ := by
   haveI := Fact.mk hsμ.lt_top; haveI := Fact.mk htμ.lt_top
   rw [restrict_union₀ hd ht, average_add_measure hfs hft, restrict_apply_univ, restrict_apply_univ]
@@ -211,4 +224,214 @@ theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞)
     ENNReal.one_toReal, one_smul]
 #align measure_theory.set_average_const MeasureTheory.set_average_const
 
+-- porting note: was `@[simp]` but `simp` can prove it
+theorem integral_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
+    ∫ _, ⨍ a, f a ∂μ ∂μ = ∫ x, f x ∂μ := by simp
+#align measure_theory.integral_average MeasureTheory.integral_average
+
+theorem setAverage_setAverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) (s : Set α) :
+    ∫ _ in s, ⨍ a in s, f a ∂μ ∂μ = ∫ x in s, f x ∂μ :=
+  integral_average _ _
+#align measure_theory.set_integral_set_average MeasureTheory.setAverage_setAverage
+
+theorem integral_sub_average (μ : Measure α) [IsFiniteMeasure μ] (f : α → E) :
+    ∫ x, f x - ⨍ a, f a ∂μ ∂μ = 0 := by
+  by_cases hf : Integrable f μ
+  · rw [integral_sub hf (integrable_const _), integral_average, sub_self]
+  refine integral_undef fun h => hf ?_
+  convert h.add (integrable_const (⨍ a, f a ∂μ))
+  exact (sub_add_cancel _ _).symm
+#align measure_theory.integral_sub_average MeasureTheory.integral_sub_average
+
+theorem setAverage_sub_setAverage (hs : μ s ≠ ∞) (f : α → E) :
+    ∫ x in s, f x - ⨍ a in s, f a ∂μ ∂μ = 0 :=
+  haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
+  integral_sub_average _ _
+#align measure_theory.set_integral_sub_set_average MeasureTheory.setAverage_sub_setAverage
+
+theorem integral_average_sub [IsFiniteMeasure μ] (hf : Integrable f μ) :
+    ∫ x, ⨍ a, f a ∂μ - f x ∂μ = 0 := by
+  rw [integral_sub (integrable_const _) hf, integral_average, sub_self]
+#align measure_theory.integral_average_sub MeasureTheory.integral_average_sub
+
+theorem setAverage_setAverage_sub (hs : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    ∫ x in s, ⨍ a in s, f a ∂μ - f x ∂μ = 0 :=
+  haveI : Fact (μ s < ∞) := ⟨lt_top_iff_ne_top.2 hs⟩
+  integral_average_sub hf
+#align measure_theory.set_integral_set_average_sub MeasureTheory.setAverage_setAverage_sub
+
+end NormedAddCommGroup
+
+theorem ofReal_average {f : α → ℝ} (hf : Integrable f μ) (hf₀ : 0 ≤ᵐ[μ] f) :
+    ENNReal.ofReal (⨍ x, f x ∂μ) = (∫⁻ x, ENNReal.ofReal (f x) ∂μ) / μ univ := by
+  obtain rfl | hμ := eq_or_ne μ 0
+  · simp
+  · rw [average_eq, smul_eq_mul, ← toReal_inv, ofReal_mul toReal_nonneg,
+      ofReal_toReal (inv_ne_top.2 <| measure_univ_ne_zero.2 hμ),
+      ofReal_integral_eq_lintegral_ofReal hf hf₀, ENNReal.div_eq_inv_mul]
+#align measure_theory.of_real_average MeasureTheory.ofReal_average
+
+theorem ofReal_setAverage {f : α → ℝ} (hf : IntegrableOn f s μ) (hf₀ : 0 ≤ᵐ[μ.restrict s] f) :
+    ENNReal.ofReal (⨍ x in s, f x ∂μ) = (∫⁻ x in s, ENNReal.ofReal (f x) ∂μ) / μ s := by
+  simpa using ofReal_average hf hf₀
+#align measure_theory.of_real_set_average MeasureTheory.ofReal_setAverage
+
+theorem average_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf' : ∀ᵐ x ∂μ, f x ≠ ∞) :
+    ⨍ x, (f x).toReal ∂μ = ((∫⁻ x, f x ∂μ) / μ univ).toReal := by
+  rw [average_eq, smul_eq_mul, toReal_div, ←
+    integral_toReal hf (hf'.mono fun _ => lt_top_iff_ne_top.2), div_eq_inv_mul]
+#align measure_theory.average_to_real MeasureTheory.average_toReal
+
+theorem setAverage_toReal {f : α → ℝ≥0∞} (hf : AEMeasurable f (μ.restrict s))
+    (hf' : ∀ᵐ x ∂μ.restrict s, f x ≠ ∞) :
+    ⨍ x in s, (f x).toReal ∂μ = ((∫⁻ x in s, f x ∂μ) / μ s).toReal := by
+  simpa using average_toReal hf hf'
+#align measure_theory.set_average_to_real MeasureTheory.setAverage_toReal
+
+/-! ### First moment method -/
+
+section FirstMoment
+
+variable {N : Set α} {f : α → ℝ}
+
+/-- **First moment method**. An integrable function is smaller than its mean on a set of positive
+measure. -/
+theorem measure_le_setAverage_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    0 < μ ({x ∈ s | f x ≤ ⨍ a in s, f a ∂μ}) := by
+  refine' pos_iff_ne_zero.2 fun H => _
+  replace H : (μ.restrict s) {x | f x ≤ ⨍ a in s, f a ∂μ} = 0
+  · rwa [restrict_apply₀, inter_comm]
+    exact AEStronglyMeasurable.nullMeasurableSet_le hf.1 aestronglyMeasurable_const
+  haveI := Fact.mk hμ₁.lt_top
+  refine' (integral_sub_average (μ.restrict s) f).not_gt _
+  refine' (set_integral_pos_iff_support_of_nonneg_ae _ _).2 _
+  · refine' eq_bot_mono (measure_mono fun x hx => _) H
+    simp only [Pi.zero_apply, sub_nonneg, mem_compl_iff, mem_setOf_eq, not_le] at hx
+    exact hx.le
+  · exact hf.sub (integrableOn_const.2 <| Or.inr <| lt_top_iff_ne_top.2 hμ₁)
+  · rwa [pos_iff_ne_zero, inter_comm, ← diff_compl, ← diff_inter_self_eq_diff, measure_diff_null]
+    refine' eq_bot_mono (measure_mono _) (measure_inter_eq_zero_of_restrict H)
+    exact inter_subset_inter_left _ fun a ha => (sub_eq_zero.1 <| of_not_not ha).le
+#align measure_theory.measure_le_set_average_pos MeasureTheory.measure_le_setAverage_pos
+
+/-- **First moment method**. An integrable function is greater than its mean on a set of positive
+measure. -/
+theorem measure_setAverage_le_pos (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    0 < μ ({x ∈ s | ⨍ a in s, f a ∂μ ≤ f x}) := by
+  simpa [integral_neg, neg_div] using measure_le_setAverage_pos hμ hμ₁ hf.neg
+#align measure_theory.measure_set_average_le_pos MeasureTheory.measure_setAverage_le_pos
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
+theorem exists_le_setAverage (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    ∃ x ∈ s, f x ≤ ⨍ a in s, f a ∂μ :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_le_setAverage_pos hμ hμ₁ hf).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_le_set_average MeasureTheory.exists_le_setAverage
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
+theorem exists_setAverage_le (hμ : μ s ≠ 0) (hμ₁ : μ s ≠ ∞) (hf : IntegrableOn f s μ) :
+    ∃ x ∈ s, ⨍ a in s, f a ∂μ ≤ f x :=
+  let ⟨x, hx, h⟩ := nonempty_of_measure_ne_zero (measure_setAverage_le_pos hμ hμ₁ hf).ne'
+  ⟨x, hx, h⟩
+#align measure_theory.exists_set_average_le MeasureTheory.exists_setAverage_le
+
+section FiniteMeasure
+
+variable [IsFiniteMeasure μ]
+
+/-- **First moment method**. An integrable function is smaller than its mean on a set of positive
+measure. -/
+theorem measure_le_average_pos (hμ : μ ≠ 0) (hf : Integrable f μ) :
+    0 < μ {x | f x ≤ ⨍ a, f a ∂μ} := by
+  simpa using measure_le_setAverage_pos (Measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
+    hf.integrableOn
+#align measure_theory.measure_le_average_pos MeasureTheory.measure_le_average_pos
+
+/-- **First moment method**. An integrable function is greater than its mean on a set of positive
+measure. -/
+theorem measure_average_le_pos (hμ : μ ≠ 0) (hf : Integrable f μ) :
+    0 < μ {x | ⨍ a, f a ∂μ ≤ f x} := by
+  simpa using measure_setAverage_le_pos (Measure.measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)
+    hf.integrableOn
+#align measure_theory.measure_average_le_pos MeasureTheory.measure_average_le_pos
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean. -/
+theorem exists_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, f x ≤ ⨍ a, f a ∂μ :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_le_average_pos hμ hf).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_le_average MeasureTheory.exists_le_average
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean. -/
+theorem exists_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) : ∃ x, ⨍ a, f a ∂μ ≤ f x :=
+  let ⟨x, hx⟩ := nonempty_of_measure_ne_zero (measure_average_le_pos hμ hf).ne'
+  ⟨x, hx⟩
+#align measure_theory.exists_average_le MeasureTheory.exists_average_le
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its mean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_le_average (hμ : μ ≠ 0) (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ f x ≤ ⨍ a, f a ∂μ := by
+  have := measure_le_average_pos hμ hf
+  rw [← measure_diff_null hN] at this
+  obtain ⟨x, hx, hxN⟩ := nonempty_of_measure_ne_zero this.ne'
+  exact ⟨x, hxN, hx⟩
+#align measure_theory.exists_not_mem_null_le_average MeasureTheory.exists_not_mem_null_le_average
+
+/-- **First moment method**. The maximum of an integrable function is greater than its mean, while
+avoiding a null set. -/
+theorem exists_not_mem_null_average_le (hμ : μ ≠ 0) (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ ⨍ a, f a ∂μ ≤ f x := by
+  simpa [integral_neg, neg_div] using exists_not_mem_null_le_average hμ hf.neg hN
+#align measure_theory.exists_not_mem_null_average_le MeasureTheory.exists_not_mem_null_average_le
+
+end FiniteMeasure
+
+section ProbabilityMeasure
+
+variable [IsProbabilityMeasure μ]
+
+/-- **First moment method**. An integrable function is smaller than its integral on a set of
+positive measure. -/
+theorem measure_le_integral_pos (hf : Integrable f μ) : 0 < μ {x | f x ≤ ∫ a, f a ∂μ} := by
+  simpa only [average_eq_integral] using
+    measure_le_average_pos (IsProbabilityMeasure.ne_zero μ) hf
+#align measure_theory.measure_le_integral_pos MeasureTheory.measure_le_integral_pos
+
+/-- **First moment method**. An integrable function is greater than its integral on a set of
+positive measure. -/
+theorem measure_integral_le_pos (hf : Integrable f μ) : 0 < μ {x | ∫ a, f a ∂μ ≤ f x} := by
+  simpa only [average_eq_integral] using
+    measure_average_le_pos (IsProbabilityMeasure.ne_zero μ) hf
+#align measure_theory.measure_integral_le_pos MeasureTheory.measure_integral_le_pos
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its integral. -/
+theorem exists_le_integral (hf : Integrable f μ) : ∃ x, f x ≤ ∫ a, f a ∂μ := by
+  simpa only [average_eq_integral] using exists_le_average (IsProbabilityMeasure.ne_zero μ) hf
+#align measure_theory.exists_le_integral MeasureTheory.exists_le_integral
+
+/-- **First moment method**. The maximum of an integrable function is greater than its integral. -/
+theorem exists_integral_le (hf : Integrable f μ) : ∃ x, ∫ a, f a ∂μ ≤ f x := by
+  simpa only [average_eq_integral] using exists_average_le (IsProbabilityMeasure.ne_zero μ) hf
+#align measure_theory.exists_integral_le MeasureTheory.exists_integral_le
+
+/-- **First moment method**. The minimum of an integrable function is smaller than its integral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_le_integral (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ f x ≤ ∫ a, f a ∂μ := by
+  simpa only [average_eq_integral] using
+    exists_not_mem_null_le_average (IsProbabilityMeasure.ne_zero μ) hf hN
+#align measure_theory.exists_not_mem_null_le_integral MeasureTheory.exists_not_mem_null_le_integral
+
+/-- **First moment method**. The maximum of an integrable function is greater than its integral,
+while avoiding a null set. -/
+theorem exists_not_mem_null_integral_le (hf : Integrable f μ) (hN : μ N = 0) :
+    ∃ x, x ∉ N ∧ ∫ a, f a ∂μ ≤ f x := by
+  simpa only [average_eq_integral] using
+    exists_not_mem_null_average_le (IsProbabilityMeasure.ne_zero μ) hf hN
+#align measure_theory.exists_not_mem_null_integral_le MeasureTheory.exists_not_mem_null_integral_le
+
+end ProbabilityMeasure
+
+end FirstMoment
+
 end MeasureTheory
fix: change compl precedence (#5586)

Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>

Diff
@@ -189,7 +189,7 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
 #align measure_theory.average_union_mem_segment MeasureTheory.average_union_mem_segment
 
 theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {s : Set α}
-    (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) (hfi : Integrable f μ) :
+    (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ sᶜ ≠ 0) (hfi : Integrable f μ) :
     ⨍ x, f x ∂μ ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
   simpa only [union_compl_self, restrict_univ] using
     average_union_mem_openSegment aedisjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _)
chore: copy integral notation precedence from mathport (#4963)

Also drop some of the parentheses that are no longer needed.

Diff
@@ -67,16 +67,20 @@ noncomputable def average (f : α → E) :=
   ∫ x, f x ∂(μ univ)⁻¹ • μ
 #align measure_theory.average MeasureTheory.average
 
-notation3"⨍ "(...)", "r:(scoped f => f)" ∂"μ => average μ r
+@[inherit_doc average]
+notation3 "⨍ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => average μ r
 
-notation3"⨍ "(...)", "r:(scoped f => average volume f) => r
+@[inherit_doc average]
+notation3 "⨍ "(...)", "r:60:(scoped f => average volume f) => r
 
-notation3"⨍ "(...)" in "s", "r:(scoped f => f)" ∂"μ => average (Measure.restrict μ s) r
+@[inherit_doc average]
+notation3 "⨍ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => average (Measure.restrict μ s) r
 
-notation3"⨍ "(...)" in "s", "r:(scoped f => average (Measure.restrict volume s) f) => r
+@[inherit_doc average]
+notation3 "⨍ "(...)" in "s", "r:60:(scoped f => average (Measure.restrict volume s) f) => r
 
 @[simp]
-theorem average_zero : (⨍ _, (0 : E) ∂μ) = 0 := by rw [average, integral_zero]
+theorem average_zero : ⨍ _, (0 : E) ∂μ = 0 := by rw [average, integral_zero]
 #align measure_theory.average_zero MeasureTheory.average_zero
 
 @[simp]
@@ -85,19 +89,19 @@ theorem average_zero_measure (f : α → E) : (⨍ x, f x ∂(0 : Measure α)) =
 #align measure_theory.average_zero_measure MeasureTheory.average_zero_measure
 
 @[simp]
-theorem average_neg (f : α → E) : (⨍ x, -f x ∂μ) = -⨍ x, f x ∂μ :=
+theorem average_neg (f : α → E) : ⨍ x, -f x ∂μ = -⨍ x, f x ∂μ :=
   integral_neg f
 #align measure_theory.average_neg MeasureTheory.average_neg
 
-theorem average_eq' (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂(μ univ)⁻¹ • μ :=
+theorem average_eq' (f : α → E) : ⨍ x, f x ∂μ = ∫ x, f x ∂(μ univ)⁻¹ • μ :=
   rfl
 #align measure_theory.average_eq' MeasureTheory.average_eq'
 
-theorem average_eq (f : α → E) : (⨍ x, f x ∂μ) = (μ univ).toReal⁻¹ • ∫ x, f x ∂μ := by
+theorem average_eq (f : α → E) : ⨍ x, f x ∂μ = (μ univ).toReal⁻¹ • ∫ x, f x ∂μ := by
   rw [average_eq', integral_smul_measure, ENNReal.toReal_inv]
 #align measure_theory.average_eq MeasureTheory.average_eq
 
-theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : (⨍ x, f x ∂μ) = ∫ x, f x ∂μ := by
+theorem average_eq_integral [IsProbabilityMeasure μ] (f : α → E) : ⨍ x, f x ∂μ = ∫ x, f x ∂μ := by
   rw [average, measure_univ, inv_one, one_smul]
 #align measure_theory.average_eq_integral MeasureTheory.average_eq_integral
 
@@ -112,24 +116,24 @@ theorem measure_smul_average [IsFiniteMeasure μ] (f : α → E) :
 #align measure_theory.measure_smul_average MeasureTheory.measure_smul_average
 
 theorem set_average_eq (f : α → E) (s : Set α) :
-    (⨍ x in s, f x ∂μ) = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by
+    ⨍ x in s, f x ∂μ = (μ s).toReal⁻¹ • ∫ x in s, f x ∂μ := by
   rw [average_eq, restrict_apply_univ]
 #align measure_theory.set_average_eq MeasureTheory.set_average_eq
 
 theorem set_average_eq' (f : α → E) (s : Set α) :
-    (⨍ x in s, f x ∂μ) = ∫ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
+    ⨍ x in s, f x ∂μ = ∫ x, f x ∂(μ s)⁻¹ • μ.restrict s := by
   simp only [average_eq', restrict_apply_univ]
 #align measure_theory.set_average_eq' MeasureTheory.set_average_eq'
 
 variable {μ}
 
-theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : (⨍ x, f x ∂μ) = ⨍ x, g x ∂μ := by
+theorem average_congr {f g : α → E} (h : f =ᵐ[μ] g) : ⨍ x, f x ∂μ = ⨍ x, g x ∂μ := by
   simp only [average_eq, integral_congr_ae h]
 #align measure_theory.average_congr MeasureTheory.average_congr
 
 theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeasure ν] {f : α → E}
     (hμ : Integrable f μ) (hν : Integrable f ν) :
-    (⨍ x, f x ∂μ + ν) =
+    ⨍ x, f x ∂(μ + ν) =
       (((μ univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂μ) +
         ((ν univ).toReal / ((μ univ).toReal + (ν univ).toReal)) • ⨍ x, f x ∂ν := by
   simp only [div_eq_inv_mul, mul_smul, measure_smul_average, ← smul_add, ←
@@ -138,7 +142,7 @@ theorem average_add_measure [IsFiniteMeasure μ] {ν : Measure α} [IsFiniteMeas
 #align measure_theory.average_add_measure MeasureTheory.average_add_measure
 
 theorem average_pair {f : α → E} {g : α → F} (hfi : Integrable f μ) (hgi : Integrable g μ) :
-    (⨍ x, (f x, g x) ∂μ) = (⨍ x, f x ∂μ, ⨍ x, g x ∂μ) :=
+    ⨍ x, (f x, g x) ∂μ = (⨍ x, f x ∂μ, ⨍ x, g x ∂μ) :=
   integral_pair hfi.to_average hgi.to_average
 #align measure_theory.average_pair MeasureTheory.average_pair
 
@@ -150,7 +154,7 @@ theorem measure_smul_set_average (f : α → E) {s : Set α} (h : μ s ≠ ∞)
 
 theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ)
     (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
-    (⨍ x in s ∪ t, f x ∂μ) =
+    ⨍ x in s ∪ t, f x ∂μ =
       (((μ s).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in s, f x ∂μ) +
         ((μ t).toReal / ((μ s).toReal + (μ t).toReal)) • ⨍ x in t, f x ∂μ := by
   haveI := Fact.mk hsμ.lt_top; haveI := Fact.mk htμ.lt_top
@@ -160,7 +164,7 @@ theorem average_union {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t) (ht
 theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞)
     (hfs : IntegrableOn f s μ) (hft : IntegrableOn f t μ) :
-    (⨍ x in s ∪ t, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in t, f x ∂μ) := by
+    ⨍ x in s ∪ t, f x ∂μ ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in t, f x ∂μ) := by
   replace hs₀ : 0 < (μ s).toReal; exact ENNReal.toReal_pos hs₀ hsμ
   replace ht₀ : 0 < (μ t).toReal; exact ENNReal.toReal_pos ht₀ htμ
   refine' mem_openSegment_iff_div.mpr
@@ -170,7 +174,7 @@ theorem average_union_mem_openSegment {f : α → E} {s t : Set α} (hd : AEDisj
 theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint μ s t)
     (ht : NullMeasurableSet t μ) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) (hfs : IntegrableOn f s μ)
     (hft : IntegrableOn f t μ) :
-    (⨍ x in s ∪ t, f x ∂μ) ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] := by
+    ⨍ x in s ∪ t, f x ∂μ ∈ [⨍ x in s, f x ∂μ -[ℝ] ⨍ x in t, f x ∂μ] := by
   by_cases hse : μ s = 0
   · rw [← ae_eq_empty] at hse
     rw [restrict_congr_set (hse.union EventuallyEq.rfl), empty_union]
@@ -186,14 +190,14 @@ theorem average_union_mem_segment {f : α → E} {s t : Set α} (hd : AEDisjoint
 
 theorem average_mem_openSegment_compl_self [IsFiniteMeasure μ] {f : α → E} {s : Set α}
     (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ (sᶜ) ≠ 0) (hfi : Integrable f μ) :
-    (⨍ x, f x ∂μ) ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
+    ⨍ x, f x ∂μ ∈ openSegment ℝ (⨍ x in s, f x ∂μ) (⨍ x in sᶜ, f x ∂μ) := by
   simpa only [union_compl_self, restrict_univ] using
     average_union_mem_openSegment aedisjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _)
       (measure_ne_top _ _) hfi.integrableOn hfi.integrableOn
 #align measure_theory.average_mem_open_segment_compl_self MeasureTheory.average_mem_openSegment_compl_self
 
 @[simp]
-theorem average_const [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : E) : (⨍ _, c ∂μ) = c := by
+theorem average_const [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : E) : ⨍ _, c ∂μ = c := by
   simp only [average_eq, integral_const, Measure.restrict_apply, MeasurableSet.univ, one_smul,
     univ_inter, smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel,
     measure_ne_top μ univ, Ne.def, measure_univ_eq_zero, ae_neBot.1 h, not_false_iff,
@@ -201,7 +205,7 @@ theorem average_const [IsFiniteMeasure μ] [h : μ.ae.NeBot] (c : E) : (⨍ _, c
 #align measure_theory.average_const MeasureTheory.average_const
 
 theorem set_average_const {s : Set α} (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : E) :
-    (⨍ _ in s, c ∂μ) = c := by
+    ⨍ _ in s, c ∂μ = c := by
   simp only [set_average_eq, integral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter,
     smul_smul, ← ENNReal.toReal_inv, ← ENNReal.toReal_mul, ENNReal.inv_mul_cancel hs₀ hs,
     ENNReal.one_toReal, one_smul]
feat: port MeasureTheory.Integral.Average (#4709)

Dependencies 12 + 941

942 files ported (98.7%)
431911 lines ported (98.7%)
Show graph

The unported dependencies are

The following 1 dependencies have changed in mathlib3 since they were ported, which may complicate porting this file