|
| 1 | +/- |
| 2 | +Copyright (c) 2025 Louis (Yiyang) Liu. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Louis (Yiyang) Liu |
| 5 | +-/ |
| 6 | +import Mathlib.MeasureTheory.Integral.IntervalIntegral.Basic |
| 7 | +import Mathlib.Topology.Order.IntermediateValue |
| 8 | + |
| 9 | +/-! |
| 10 | +# First mean value theorem for integrals |
| 11 | +
|
| 12 | +We prove versions of the first mean value theorem for (unordered) interval integrals |
| 13 | +w.r.t. an arbitrary measure in `ℝ` |
| 14 | +
|
| 15 | +One assuming almost-every where non-negativity of `g` under an arbitrary measure, |
| 16 | +and one assuming point-wise non-negativity together with continuity of `g`. |
| 17 | +
|
| 18 | +## Main statements |
| 19 | +
|
| 20 | +- `exists_eq_const_mul_interval_integral_of_continuous_on_of_ae_nonneg`: |
| 21 | + **First mean value theorem for integrals** for (unordered) interval integrals when |
| 22 | + `g` is interval integrable on `a..b` w.r.t. an arbitrary measure `μ` and satisfies |
| 23 | + `g ≥ 0` almost everywhere on `uIcc a b`. |
| 24 | +- `exists_eq_const_mul_interval_integral_of_continuous_on_of_nonneg`: |
| 25 | + **First mean value theorem for integrals** for (unordered) interval integrals when |
| 26 | + `g` is continuous on `uIcc a b` and nonnegative there (Lebesgue measure). |
| 27 | +
|
| 28 | +## References |
| 29 | +
|
| 30 | +* [V. A. Zorich, *Mathematical Analysis I*][zorich2016], |
| 31 | + Thm. 5 (First mean-value theorem for the integral). |
| 32 | +* <https://proofwiki.org/wiki/Mean_Value_Theorem_for_Integrals/Generalization> |
| 33 | +
|
| 34 | +## Tags |
| 35 | +
|
| 36 | +mean value theorem, interval integral, measure, nonnegative, continuous, integrable |
| 37 | +-/ |
| 38 | + |
| 39 | +open MeasureTheory Set intervalIntegral Filter |
| 40 | + |
| 41 | +/-- **First mean value theorem for integrals (interval integral, arbitrary measure).** |
| 42 | +Let `μ` be a measure on `ℝ`. If `f : ℝ → ℝ` is continuous on `uIcc a b` and |
| 43 | +`g : ℝ → ℝ` is interval integrable on `a..b` w.r.t. `μ`, and `g ≥ 0` almost |
| 44 | +everywhere on `uIcc a b`, then there exists `c ∈ uIcc a b` such that |
| 45 | +`∫ x in a..b, f x * g x ∂μ = f c * ∫ x in a..b, g x ∂μ`. -/ |
| 46 | +theorem exists_eq_const_mul_interval_integral_of_continuous_on_of_ae_nonneg |
| 47 | + {a b : ℝ} {f g : ℝ → ℝ} {μ : Measure ℝ} |
| 48 | + (hf : ContinuousOn f (uIcc a b)) |
| 49 | + (hg : IntervalIntegrable g μ a b) |
| 50 | + (hg0 : ∀ᵐ x ∂(μ.restrict (uIcc a b)), 0 ≤ g x) : |
| 51 | + ∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x ∂μ) = f c * (∫ x in a..b, g x ∂μ) := by |
| 52 | + wlog a_b_case : a ≤ b generalizing a b |
| 53 | + · simp at a_b_case |
| 54 | + obtain ⟨c, c_in_uIcc, that⟩ := |
| 55 | + this |
| 56 | + (a := b) (b := a) (by rwa [uIcc_comm]) |
| 57 | + hg.symm (by rwa [uIcc_comm]) |
| 58 | + a_b_case.le |
| 59 | + refine ⟨c, ?_, ?_⟩ |
| 60 | + · rwa [uIcc_comm] |
| 61 | + · calc |
| 62 | + _ = - ∫ x in b..a, f x * g x ∂μ := by |
| 63 | + exact integral_symm b a |
| 64 | + _ = - (f c * ∫ x in b..a, g x ∂μ) := by |
| 65 | + rw [that] |
| 66 | + simp [integral_symm b a] |
| 67 | + · have is_compact_uIcc_a_b : IsCompact (uIcc a b) := by |
| 68 | + exact isCompact_uIcc |
| 69 | + obtain ⟨x_f_min, x_f_min_in_uIcc_a_b, f_min⟩ := by |
| 70 | + exact IsCompact.exists_isMinOn |
| 71 | + is_compact_uIcc_a_b nonempty_uIcc hf |
| 72 | + obtain ⟨x_f_max, x_f_max_in_uIcc_a_b, f_max⟩ := by |
| 73 | + exact IsCompact.exists_isMaxOn |
| 74 | + is_compact_uIcc_a_b nonempty_uIcc hf |
| 75 | + let m := f x_f_min |
| 76 | + let M := f x_f_max |
| 77 | + have m_le_f_x : ∀ x ∈ uIcc a b, m ≤ f x := by |
| 78 | + simpa |
| 79 | + have f_x_le_M : ∀ x ∈ uIcc a b, f x ≤ M := by |
| 80 | + simpa |
| 81 | + have f_g_int_μ_a_b : IntervalIntegrable (fun x ↦ f x * g x) μ a b := by |
| 82 | + exact IntervalIntegrable.continuousOn_mul hg hf |
| 83 | + have m_g_int_μ_a_b : IntervalIntegrable (fun x ↦ m * g x) μ a b := by |
| 84 | + unfold m |
| 85 | + exact hg.const_mul m |
| 86 | + have M_g_int_μ_a_b : IntervalIntegrable (fun x ↦ M * g x) μ a b := by |
| 87 | + unfold M |
| 88 | + exact hg.const_mul M |
| 89 | + have ae_left_uIcc : ∀ᵐ x ∂(μ.restrict (uIcc a b)), m * g x ≤ f x * g x := by |
| 90 | + rw [ae_restrict_iff' measurableSet_uIcc] |
| 91 | + have hg0' : ∀ᵐ x ∂μ, x ∈ uIcc a b → 0 ≤ g x := by |
| 92 | + rwa [← ae_restrict_iff' measurableSet_uIcc] |
| 93 | + have m_le_f_x_ae : ∀ᵐ x ∂μ, x ∈ uIcc a b → m ≤ f x := by |
| 94 | + apply Eventually.of_forall |
| 95 | + exact fun x a ↦ f_min a |
| 96 | + filter_upwards [m_le_f_x_ae, hg0'] with x h_m_le_f_x g_x_nonneg |
| 97 | + exact fun a ↦ mul_le_mul_of_nonneg_right (f_min a) (g_x_nonneg a) |
| 98 | + have ae_right_uIcc : ∀ᵐ x ∂(μ.restrict (uIcc a b)), f x * g x ≤ M * g x := by |
| 99 | + rw [ae_restrict_iff' measurableSet_uIcc] |
| 100 | + have hg0' : ∀ᵐ x ∂μ, x ∈ uIcc a b → 0 ≤ g x := by |
| 101 | + rwa [← ae_restrict_iff' measurableSet_uIcc] |
| 102 | + have m_le_f_x_ae : ∀ᵐ x ∂μ, x ∈ uIcc a b → m ≤ f x := by |
| 103 | + apply Eventually.of_forall |
| 104 | + exact fun x a ↦ f_min a |
| 105 | + filter_upwards [m_le_f_x_ae, hg0'] with x h_m_le_f_x g_x_nonneg |
| 106 | + exact fun a ↦ mul_le_mul_of_nonneg_right (f_max a) (g_x_nonneg a) |
| 107 | + have ae_left_Icc : ∀ᵐ x ∂(μ.restrict (Icc a b)), m * g x ≤ f x * g x := by |
| 108 | + simpa [a_b_case] using ae_left_uIcc |
| 109 | + have ae_right_Icc : ∀ᵐ x ∂(μ.restrict (Icc a b)), f x * g x ≤ M * g x := by |
| 110 | + simpa [a_b_case] using ae_right_uIcc |
| 111 | + have int_f_g_bounds : |
| 112 | + m * (∫ x in a..b, g x ∂μ) ≤ (∫ x in a..b, f x * g x ∂μ) |
| 113 | + ∧ (∫ x in a..b, f x * g x ∂μ) ≤ M * (∫ x in a..b, g x ∂μ) := by |
| 114 | + constructor |
| 115 | + · calc |
| 116 | + _ = (∫ x in a..b, m * g x ∂μ) := by |
| 117 | + simp |
| 118 | + _ ≤ (∫ x in a..b, f x * g x ∂μ) := by |
| 119 | + exact integral_mono_ae_restrict a_b_case m_g_int_μ_a_b f_g_int_μ_a_b ae_left_Icc |
| 120 | + · calc |
| 121 | + _ ≤ (∫ x in a..b, M * g x ∂μ) := by |
| 122 | + exact integral_mono_ae_restrict a_b_case f_g_int_μ_a_b M_g_int_μ_a_b ae_right_Icc |
| 123 | + _ = M * (∫ x in a..b, g x ∂μ) := by simp |
| 124 | + by_cases int_g_case : (∫ x in a..b, g x ∂μ) = 0 |
| 125 | + · refine ⟨x_f_min, x_f_min_in_uIcc_a_b, ?_⟩ |
| 126 | + have : 0 ≤ (∫ x in a..b, f x * g x ∂μ) ∧ (∫ x in a..b, f x * g x ∂μ) ≤ 0 := by |
| 127 | + simpa [int_g_case] using int_f_g_bounds |
| 128 | + have int_f_g_eq_zero : (∫ x in a..b, f x * g x ∂μ) = 0 := by |
| 129 | + exact le_antisymm this.2 this.1 |
| 130 | + simp [int_g_case, int_f_g_eq_zero] |
| 131 | + · let r := (∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ) |
| 132 | + have g_nonneg_Icc_a_b_ae : ∀ᵐ x ∂(μ.restrict (Icc a b)), 0 ≤ g x := by |
| 133 | + simpa [a_b_case] using hg0 |
| 134 | + have int_g_nonneg : 0 ≤ ∫ x in a..b, g x ∂μ := by |
| 135 | + exact integral_nonneg_of_ae_restrict a_b_case g_nonneg_Icc_a_b_ae |
| 136 | + have int_g_pos : 0 < ∫ x in a..b, g x ∂μ := by |
| 137 | + have int_g_neq_zero : (∫ x in a..b, g x ∂μ) ≠ 0 := by |
| 138 | + exact int_g_case |
| 139 | + exact lt_of_le_of_ne int_g_nonneg int_g_neq_zero.symm |
| 140 | + have m_le_r : m ≤ r := by |
| 141 | + have left_bound : |
| 142 | + m ≤ (∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ) := by |
| 143 | + simpa [le_div_iff₀ int_g_pos] using int_f_g_bounds.1 |
| 144 | + simpa [r] using left_bound |
| 145 | + have r_le_M : r ≤ M := by |
| 146 | + have right_bound : |
| 147 | + (∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ) ≤ M := by |
| 148 | + simpa [div_le_iff₀ int_g_pos] using int_f_g_bounds.2 |
| 149 | + simpa [r] using right_bound |
| 150 | + have r_in_Icc_m_M : r ∈ Icc m M := ⟨m_le_r, r_le_M⟩ |
| 151 | + have ivt : |
| 152 | + uIcc (f x_f_min) (f x_f_max) ⊆ f '' uIcc x_f_min x_f_max := by |
| 153 | + have f_cont_uIcc_x_f_min_x_f_max : |
| 154 | + uIcc x_f_min x_f_max ⊆ uIcc a b := by |
| 155 | + intro x hx |
| 156 | + have hx' : min x_f_min x_f_max ≤ x ∧ x ≤ max x_f_min x_f_max := by |
| 157 | + simpa [uIcc] using hx |
| 158 | + have a_b_le_min : min a b ≤ min x_f_min x_f_max := |
| 159 | + le_min x_f_min_in_uIcc_a_b.1 x_f_max_in_uIcc_a_b.1 |
| 160 | + have max_le_a_b : max x_f_min x_f_max ≤ max a b := |
| 161 | + max_le x_f_min_in_uIcc_a_b.2 x_f_max_in_uIcc_a_b.2 |
| 162 | + exact ⟨a_b_le_min.trans hx'.1, hx'.2.trans max_le_a_b⟩ |
| 163 | + intro x hx |
| 164 | + apply intermediate_value_uIcc |
| 165 | + apply ContinuousOn.mono hf f_cont_uIcc_x_f_min_x_f_max |
| 166 | + assumption |
| 167 | + rw [subset_image_iff] at ivt |
| 168 | + rcases ivt with ⟨u, u_subset_uIcc, f_eq_image_uIcc⟩ |
| 169 | + have m_le_M : m ≤ M := by |
| 170 | + exact f_min x_f_max_in_uIcc_a_b |
| 171 | + have r_in_f_image : r ∈ f '' u := by |
| 172 | + simpa [m, M, m_le_M, f_eq_image_uIcc] using r_in_Icc_m_M |
| 173 | + rw [mem_image] at r_in_f_image |
| 174 | + rcases r_in_f_image with ⟨c, c_in_u, f_c_eq_r⟩ |
| 175 | + have c_in_uIcc : c ∈ uIcc x_f_min x_f_max := by |
| 176 | + exact u_subset_uIcc c_in_u |
| 177 | + have a_le_x : a ≤ min x_f_min x_f_max := by |
| 178 | + apply le_min |
| 179 | + · simpa [a_b_case] using x_f_min_in_uIcc_a_b.1 |
| 180 | + · simpa [a_b_case] using x_f_max_in_uIcc_a_b.1 |
| 181 | + have x_le_b : max x_f_min x_f_max ≤ b := by |
| 182 | + apply max_le |
| 183 | + · simpa [a_b_case] using x_f_min_in_uIcc_a_b.2 |
| 184 | + · simpa [a_b_case] using x_f_max_in_uIcc_a_b.2 |
| 185 | + have c_in_uIcc_x_f_min_max : c ∈ uIcc x_f_min x_f_max := by |
| 186 | + simp [uIcc] |
| 187 | + rw [uIcc] at c_in_uIcc |
| 188 | + rcases c_in_uIcc with ⟨left, right⟩ |
| 189 | + constructor |
| 190 | + · exact inf_le_iff.mp left |
| 191 | + · exact le_sup_iff.mp right |
| 192 | + have c_in_uIcc_a_b : c ∈ uIcc a b := by |
| 193 | + simp [uIcc] |
| 194 | + rw [uIcc] at c_in_uIcc |
| 195 | + rcases c_in_uIcc with ⟨left, right⟩ |
| 196 | + constructor |
| 197 | + · left |
| 198 | + exact le_trans a_le_x left |
| 199 | + · right |
| 200 | + exact le_trans right x_le_b |
| 201 | + have int_f_g_eq_r_mul_int_g : |
| 202 | + (∫ x in a..b, f x * g x ∂μ) = r * (∫ x in a..b, g x ∂μ) := by |
| 203 | + have r_eq : |
| 204 | + r = (∫ x in a..b, f x * g x ∂μ) / (∫ x in a..b, g x ∂μ) := by |
| 205 | + simp [r] |
| 206 | + rw [r_eq] |
| 207 | + field_simp |
| 208 | + refine ⟨c, c_in_uIcc_a_b, ?_⟩ |
| 209 | + simpa [f_c_eq_r] |
| 210 | + |
| 211 | +/-- **First mean value theorem for integrals (interval integral).** |
| 212 | +Let `f g : ℝ → ℝ` be continuous on `uIcc a b`. If `g ≥ 0` on `uIcc a b`, |
| 213 | +then there exists `c ∈ uIcc a b` such that |
| 214 | +`∫ x in a..b, f x * g x = f c * ∫ x in a..b, g x`. -/ |
| 215 | +theorem exists_eq_const_mul_interval_integral_of_continuous_on_of_nonneg |
| 216 | + {a b : ℝ} {f g : ℝ → ℝ} |
| 217 | + (hf : ContinuousOn f (uIcc a b)) |
| 218 | + (hg : ContinuousOn g (uIcc a b)) |
| 219 | + (hg0 : ∀ x ∈ uIcc a b, 0 ≤ g x) : |
| 220 | + ∃ c ∈ uIcc a b, (∫ x in a..b, f x * g x) = f c * (∫ x in a..b, g x) := by |
| 221 | + have hg0_ae : ∀ᵐ x ∂(volume.restrict (uIcc a b)), 0 ≤ g x := by |
| 222 | + rw [ae_restrict_iff' measurableSet_uIcc] |
| 223 | + exact ae_of_all volume hg0 |
| 224 | + exact exists_eq_const_mul_interval_integral_of_continuous_on_of_ae_nonneg |
| 225 | + hf hg.intervalIntegrable hg0_ae |
0 commit comments