source
stringlengths
17
118
lean4
stringlengths
0
335k
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Pointwise.lean
import Mathlib.MeasureTheory.Group.Arithmetic /-! # Pointwise set operations on `MeasurableSet`s In this file we prove several versions of the following fact: if `s` is a measurable set, then so is `a • s`. Note that the pointwise product of two measurable sets need not be measurable, so there is no `MeasurableSet.mul` etc. -/ open Pointwise open Set @[to_additive] theorem MeasurableSet.const_smul {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace G] [MeasurableSpace α] [MeasurableSMul G α] {s : Set α} (hs : MeasurableSet s) (a : G) : MeasurableSet (a • s) := by rw [← preimage_smul_inv] exact measurable_const_smul _ hs theorem MeasurableSet.const_smul_of_ne_zero {G₀ α : Type*} [GroupWithZero G₀] [MulAction G₀ α] [MeasurableSpace G₀] [MeasurableSpace α] [MeasurableSMul G₀ α] {s : Set α} (hs : MeasurableSet s) {a : G₀} (ha : a ≠ 0) : MeasurableSet (a • s) := by rw [← preimage_smul_inv₀ ha] exact measurable_const_smul _ hs theorem MeasurableSet.const_smul₀ {G₀ α : Type*} [GroupWithZero G₀] [Zero α] [MulActionWithZero G₀ α] [MeasurableSpace G₀] [MeasurableSpace α] [MeasurableSMul G₀ α] [MeasurableSingletonClass α] {s : Set α} (hs : MeasurableSet s) (a : G₀) : MeasurableSet (a • s) := by rcases eq_or_ne a 0 with (rfl | ha) exacts [(subsingleton_zero_smul_set s).measurableSet, hs.const_smul_of_ne_zero ha]
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/ModularCharacter.lean
import Mathlib.MeasureTheory.Function.LocallyIntegrable import Mathlib.MeasureTheory.Group.Integral import Mathlib.MeasureTheory.Group.Measure import Mathlib.Topology.Metrizable.Urysohn import Mathlib.MeasureTheory.Measure.Haar.Unique import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic /-! # Modular character of a locally compact group On a locally compact group, there is a natural homomorphism `G → ℝ≥0*`, which for `g : G` gives the value `μ (· * g⁻¹) / μ`, where `μ` is an (inner regular) Haar measure. This file defines this homomorphism, called the modular character, and shows that it is independent of the chosen Haar measure. TODO: Show that the character is continuous. ## Main Declarations * `modularCharacterFun`: Define the modular character function. If `μ` is a left Haar measure on `G` and `g : G`, the measure `A ↦ μ (A g⁻¹)` is also a left Haar measure, so by uniqueness is of the form `Δ(g) μ`, for `Δ(g) ∈ ℝ≥0`. This `Δ` is the modular character. The result that this does not depend on the measure chosen is `modularCharacterFun_eq_haarScalarFactor`. * `modularCharacter`: The homomorphism G →* ℝ≥0 whose toFun is `modularCharacterFun`. -/ open MeasureTheory open scoped NNReal namespace MeasureTheory namespace Measure variable {G : Type*} [TopologicalSpace G] [Group G] [IsTopologicalGroup G] [LocallyCompactSpace G] /-- The modular character as a map is `g ↦ μ (· * g⁻¹) / μ`, where `μ` is a left Haar measure. See also `modularCharacter` that defines the map as a homomorphism. -/ @[to_additive /-- The additive modular character as a map is `g ↦ μ (· - g) / μ`, where `μ` is an left additive Haar measure. -/] noncomputable def modularCharacterFun (g : G) : ℝ≥0 := letI : MeasurableSpace G := borel G haveI : BorelSpace G := ⟨rfl⟩ haarScalarFactor (map (· * g) MeasureTheory.Measure.haar) MeasureTheory.Measure.haar /-- Independence of modularCharacterFun from the chosen Haar measure. -/ @[to_additive /-- Independence of addModularCharacterFun from the chosen Haar measure -/] lemma modularCharacterFun_eq_haarScalarFactor [MeasurableSpace G] [BorelSpace G] (μ : Measure G) [IsHaarMeasure μ] (g : G) : modularCharacterFun g = haarScalarFactor (map (· * g) μ) μ := by let ν := MeasureTheory.Measure.haar (G := G) obtain ⟨⟨f, f_cont⟩, f_comp, f_nonneg, f_one⟩ : ∃ f : C(G, ℝ), HasCompactSupport f ∧ 0 ≤ f ∧ f 1 ≠ 0 := exists_continuous_nonneg_pos 1 have int_f_ne_zero (μ₀ : Measure G) [IsHaarMeasure μ₀] : ∫ x, f x ∂μ₀ ≠ 0 := ne_of_gt (f_cont.integral_pos_of_hasCompactSupport_nonneg_nonzero f_comp f_nonneg f_one) apply NNReal.coe_injective have t : (∫ x, f (x * g) ∂ν) = (∫ x, f (x * g) ∂(haarScalarFactor ν μ • μ)) := by refine integral_isMulLeftInvariant_eq_smul_of_hasCompactSupport ν μ ?_ ?_ · exact Continuous.comp' f_cont (continuous_mul_right g) · have j : (fun x ↦ f (x * g)) = (f ∘ (Homeomorph.mulRight g)) := rfl rw [j] exact HasCompactSupport.comp_homeomorph f_comp _ have r : (haarScalarFactor ν μ : ℝ) / (haarScalarFactor ν μ) = 1 := by refine div_self ?_ rw [NNReal.coe_ne_zero] apply (ne_of_lt (haarScalarFactor_pos_of_isHaarMeasure _ _)).symm calc ↑(modularCharacterFun g) = ↑(haarScalarFactor (map (· * g) ν) ν) := by borelize G; rfl _ = (∫ x, f x ∂(map (· * g) ν)) / ∫ x, f x ∂ν := haarScalarFactor_eq_integral_div _ _ f_cont f_comp (int_f_ne_zero ν) _ = (∫ x, f (x * g) ∂ν) / ∫ x, f x ∂ν := by rw [integral_map (AEMeasurable.mul_const aemeasurable_id' _) (Continuous.aestronglyMeasurable f_cont)] _ = (∫ x, f (x * g) ∂(haarScalarFactor ν μ • μ)) / ∫ x, f x ∂ν := by rw [t] _ = (∫ x, f (x * g) ∂(haarScalarFactor ν μ • μ)) / ∫ x, f x ∂(haarScalarFactor ν μ • μ) := by rw [integral_isMulLeftInvariant_eq_smul_of_hasCompactSupport ν μ f_cont f_comp] _ = (haarScalarFactor ν μ • ∫ x, f (x * g) ∂μ) / (haarScalarFactor ν μ • ∫ x, f x ∂μ) := by rw [integral_smul_nnreal_measure, integral_smul_nnreal_measure] _ = (haarScalarFactor ν μ / haarScalarFactor ν μ) * ((∫ x, f (x * g) ∂μ) / ∫ x, f x ∂μ) := mul_div_mul_comm _ _ _ _ _ = 1 * ((∫ x, f (x * g) ∂μ) / ∫ x, f x ∂μ) := by rw [r] _ = (∫ x, f (x * g) ∂μ) / ∫ x, f x ∂μ := by rw [one_mul] _ = (∫ x, f x ∂(map (· * g) μ)) / ∫ x, f x ∂μ := by rw [integral_map (AEMeasurable.mul_const aemeasurable_id' _) (Continuous.aestronglyMeasurable f_cont)] _ = haarScalarFactor (map (· * g) μ) μ := (haarScalarFactor_eq_integral_div _ _ f_cont f_comp (int_f_ne_zero μ)).symm @[to_additive] lemma map_right_mul_eq_modularCharacterFun_smul [MeasurableSpace G] [BorelSpace G] (μ : Measure G) [IsHaarMeasure μ] [InnerRegular μ] (g : G) : map (· * g) μ = modularCharacterFun g • μ := by rw [modularCharacterFun_eq_haarScalarFactor μ _] exact isMulLeftInvariant_eq_smul_of_innerRegular _ μ @[to_additive] lemma modularCharacterFun_pos (g : G) : 0 < modularCharacterFun g := by borelize G rw [modularCharacterFun_eq_haarScalarFactor MeasureTheory.Measure.haar g] exact haarScalarFactor_pos_of_isHaarMeasure _ _ @[to_additive] lemma modularCharacterFun_map_one : modularCharacterFun (1 : G) = 1 := by simp [modularCharacterFun, haarScalarFactor_self] @[to_additive] lemma modularCharacterFun_map_mul (g h : G) : modularCharacterFun (g * h) = modularCharacterFun g * modularCharacterFun h := by borelize G have mul_g_meas : Measurable (· * g) := Measurable.mul_const (fun ⦃_⦄ a ↦ a) g have mul_h_meas : Measurable (· * h) := Measurable.mul_const (fun ⦃_⦄ a ↦ a) h let ν := MeasureTheory.Measure.haar (G := G) symm calc modularCharacterFun g * modularCharacterFun h = modularCharacterFun h * modularCharacterFun g := mul_comm _ _ _ = haarScalarFactor (map (· * h) (map (· * g) ν)) (map (· * g) ν) * modularCharacterFun g := by rw [modularCharacterFun_eq_haarScalarFactor (map (· * g) ν) _] _ = haarScalarFactor (map (· * h) (map (· * g) ν)) (map (· * g) ν) * haarScalarFactor (map (· * g) ν) ν := rfl _ = haarScalarFactor (map (· * (g * h)) ν) ν := by simp only [map_map mul_h_meas mul_g_meas, comp_mul_right, ← haarScalarFactor_eq_mul] /-- The modular character homomorphism. The underlying function is `modularCharacterFun`, which is `g ↦ μ (· * g⁻¹) / μ`, where `μ` is a left Haar measure. -/ noncomputable def modularCharacter : G →* ℝ≥0 where toFun := modularCharacterFun map_one' := modularCharacterFun_map_one map_mul' := modularCharacterFun_map_mul end Measure end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/IntegralConvolution.lean
import Mathlib.MeasureTheory.Group.Convolution import Mathlib.MeasureTheory.Integral.Prod /-! # Bochner integrals of convolutions This file contains results about the Bochner integrals of convolutions of measures. These results are not placed in the main convolution file because we don't want to import Bochner integrals over there. ## Main statements * `integrable_conv_iff`: A function is integrable with respect to the convolution `μ ∗ ν` iff the function `y ↦ f (x + y)` is integrable with respect to `ν` for `μ`-almost every `x` and the function `x ↦ ∫ y, ‖f (x + y)‖ ∂ν` is integrable with respect to `μ`. * `integral_conv`: if `f` is integrable with respect to the convolution `μ ∗ ν`, then `∫ x, f x ∂(μ ∗ₘ ν) = ∫ x, ∫ y, f (x + y) ∂ν ∂μ`. -/ namespace MeasureTheory variable {M F : Type*} [Monoid M] {mM : MeasurableSpace M} [MeasurableMul₂ M] [NormedAddCommGroup F] {μ ν : Measure M} {f : M → F} @[to_additive] lemma integrable_mconv_iff [SFinite ν] (hf : AEStronglyMeasurable f (μ ∗ₘ ν)) : Integrable f (μ ∗ₘ ν) ↔ (∀ᵐ x ∂μ, Integrable (fun y ↦ f (x * y)) ν) ∧ Integrable (fun x ↦ ∫ y, ‖f (x * y)‖ ∂ν) μ := by simp [Measure.mconv, integrable_map_measure hf (by fun_prop), integrable_prod_iff (hf.comp_measurable (by fun_prop))] @[to_additive] lemma integral_mconv [NormedSpace ℝ F] [SFinite μ] [SFinite ν] (hf : Integrable f (μ ∗ₘ ν)) : ∫ x, f x ∂(μ ∗ₘ ν) = ∫ x, ∫ y, f (x * y) ∂ν ∂μ := by unfold Measure.mconv rw [integral_map (by fun_prop) hf.1, integral_prod] exact (integrable_map_measure hf.1 (by fun_prop)).mp hf end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/GeometryOfNumbers.lean
import Mathlib.Analysis.Convex.Body import Mathlib.Analysis.Convex.Measure import Mathlib.MeasureTheory.Group.FundamentalDomain /-! # Geometry of numbers In this file we prove some of the fundamental theorems in the geometry of numbers, as studied by Hermann Minkowski. ## Main results * `exists_pair_mem_lattice_not_disjoint_vadd`: Blichfeldt's principle, existence of two distinct points in a subgroup such that the translates of a set by these two points are not disjoint when the covolume of the subgroup is larger than the volume of the set. * `exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure`: Minkowski's theorem, existence of a non-zero lattice point inside a convex symmetric domain of large enough volume. ## TODO * Calculate the volume of the fundamental domain of a finite index subgroup * Voronoi diagrams * See [Pete L. Clark, *Abstract Geometry of Numbers: Linear Forms* (arXiv)](https://arxiv.org/abs/1405.2119) for some more ideas. ## References * [Pete L. Clark, *Geometry of Numbers with Applications to Number Theory*][clark_gon] p.28 -/ namespace MeasureTheory open ENNReal Module MeasureTheory MeasureTheory.Measure Set Filter open scoped Pointwise NNReal variable {E L : Type*} [MeasurableSpace E] {μ : Measure E} {F s : Set E} /-- **Blichfeldt's Theorem**. If the volume of the set `s` is larger than the covolume of the countable subgroup `L` of `E`, then there exist two distinct points `x, y ∈ L` such that `(x + s)` and `(y + s)` are not disjoint. -/ theorem exists_pair_mem_lattice_not_disjoint_vadd [AddGroup L] [Countable L] [AddAction L E] [MeasurableSpace L] [MeasurableVAdd L E] [VAddInvariantMeasure L E μ] (fund : IsAddFundamentalDomain L F μ) (hS : NullMeasurableSet s μ) (h : μ F < μ s) : ∃ x y : L, x ≠ y ∧ ¬Disjoint (x +ᵥ s) (y +ᵥ s) := by contrapose! h exact ((fund.measure_eq_tsum _).trans (measure_iUnion₀ (Pairwise.mono h fun i j hij => (hij.mono inf_le_left inf_le_left).aedisjoint) fun _ => (hS.vadd _).inter fund.nullMeasurableSet).symm).trans_le (measure_mono <| Set.iUnion_subset fun _ => Set.inter_subset_right) /-- The **Minkowski Convex Body Theorem**. If `s` is a convex symmetric domain of `E` whose volume is large enough compared to the covolume of a lattice `L` of `E`, then it contains a non-zero lattice point of `L`. -/ theorem exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure [NormedAddCommGroup E] [NormedSpace ℝ E] [BorelSpace E] [FiniteDimensional ℝ E] [IsAddHaarMeasure μ] {L : AddSubgroup E} [Countable L] (fund : IsAddFundamentalDomain L F μ) (h_symm : ∀ x ∈ s, -x ∈ s) (h_conv : Convex ℝ s) (h : μ F * 2 ^ finrank ℝ E < μ s) : ∃ x ≠ 0, ((x : L) : E) ∈ s := by have h_vol : μ F < μ ((2⁻¹ : ℝ) • s) := by rw [addHaar_smul_of_nonneg μ (by simp : 0 ≤ (2 : ℝ)⁻¹) s, ← mul_lt_mul_right (pow_ne_zero (finrank ℝ E) (two_ne_zero' _)) (by finiteness), mul_right_comm, ofReal_pow (by simp : 0 ≤ (2 : ℝ)⁻¹), ofReal_inv_of_pos zero_lt_two] norm_num rwa [← mul_pow, ENNReal.inv_mul_cancel two_ne_zero ofNat_ne_top, one_pow, one_mul] obtain ⟨x, y, hxy, h⟩ := exists_pair_mem_lattice_not_disjoint_vadd fund ((h_conv.smul _).nullMeasurableSet _) h_vol obtain ⟨_, ⟨v, hv, rfl⟩, w, hw, hvw⟩ := Set.not_disjoint_iff.mp h refine ⟨x - y, sub_ne_zero.2 hxy, ?_⟩ rw [Set.mem_inv_smul_set_iff₀ (two_ne_zero' ℝ)] at hv hw simp_rw [AddSubgroup.vadd_def, vadd_eq_add, add_comm _ w, ← sub_eq_sub_iff_add_eq_add, ← AddSubgroup.coe_sub] at hvw rw [← hvw, ← inv_smul_smul₀ (two_ne_zero' ℝ) (_ - _), smul_sub, sub_eq_add_neg, smul_add] refine h_conv hw (h_symm _ hv) ?_ ?_ ?_ <;> norm_num /-- The **Minkowski Convex Body Theorem for compact domain**. If `s` is a convex compact symmetric domain of `E` whose volume is large enough compared to the covolume of a lattice `L` of `E`, then it contains a non-zero lattice point of `L`. Compared to `exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure`, this version requires in addition that `s` is compact and `L` is discrete but provides a weaker inequality rather than a strict inequality. -/ theorem exists_ne_zero_mem_lattice_of_measure_mul_two_pow_le_measure [NormedAddCommGroup E] [NormedSpace ℝ E] [BorelSpace E] [FiniteDimensional ℝ E] [Nontrivial E] [IsAddHaarMeasure μ] {L : AddSubgroup E} [Countable L] [DiscreteTopology L] (fund : IsAddFundamentalDomain L F μ) (h_symm : ∀ x ∈ s, -x ∈ s) (h_conv : Convex ℝ s) (h_cpt : IsCompact s) (h : μ F * 2 ^ finrank ℝ E ≤ μ s) : ∃ x ≠ 0, ((x : L) : E) ∈ s := by have h_mes : μ s ≠ 0 := by intro hμ suffices μ F = 0 from fund.measure_ne_zero (NeZero.ne μ) this rw [hμ, le_zero_iff, mul_eq_zero] at h exact h.resolve_right <| pow_ne_zero _ two_ne_zero have h_nemp : s.Nonempty := nonempty_of_measure_ne_zero h_mes let u : ℕ → ℝ≥0 := (exists_seq_strictAnti_tendsto 0).choose let K : ConvexBody E := ⟨s, h_conv, h_cpt, h_nemp⟩ let S : ℕ → ConvexBody E := fun n => (1 + u n) • K let Z : ℕ → Set E := fun n => (S n) ∩ (L \ {0}) -- The convex bodies `S n` have volume strictly larger than `μ s` and thus we can apply -- `exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure` to them and obtain that -- `S n` contains a nonzero point of `L`. Since the intersection of the `S n` is equal to `s`, -- it follows that `s` contains a nonzero point of `L`. have h_zero : 0 ∈ K := K.zero_mem_of_symmetric h_symm suffices Set.Nonempty (⋂ n, Z n) by erw [← Set.iInter_inter, K.iInter_smul_eq_self h_zero] at this · obtain ⟨x, hx⟩ := this exact ⟨⟨x, by simp_all⟩, by aesop⟩ · exact (exists_seq_strictAnti_tendsto (0 : ℝ≥0)).choose_spec.2.2 have h_clos : IsClosed ((L : Set E) \ {0}) := by rsuffices ⟨U, hU⟩ : ∃ U : Set E, IsOpen U ∧ U ∩ L = {0} · rw [sdiff_eq_sdiff_iff_inf_eq_inf (z := U).mpr (by simp [Set.inter_comm .. ▸ hU.2, zero_mem])] exact AddSubgroup.isClosed_of_discrete.sdiff hU.1 exact isOpen_inter_eq_singleton_of_mem_discrete (zero_mem L) refine IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed Z (fun n => ?_) (fun n => ?_) ((S 0).isCompact.inter_right h_clos) (fun n => (S n).isClosed.inter h_clos) · refine Set.inter_subset_inter_left _ (SetLike.coe_subset_coe.mpr ?_) refine ConvexBody.smul_le_of_le K h_zero ?_ rw [add_le_add_iff_left] exact le_of_lt <| (exists_seq_strictAnti_tendsto (0 : ℝ≥0)).choose_spec.1 (Nat.lt.base n) · suffices μ F * 2 ^ finrank ℝ E < μ (S n : Set E) by have h_symm' : ∀ x ∈ S n, -x ∈ S n := by rintro _ ⟨y, hy, rfl⟩ exact ⟨-y, h_symm _ hy, by simp⟩ obtain ⟨x, hx_nz, hx_mem⟩ := exists_ne_zero_mem_lattice_of_measure_mul_two_pow_lt_measure fund h_symm' (S n).convex this exact ⟨x, hx_mem, by simp_all⟩ refine lt_of_le_of_lt h ?_ rw [ConvexBody.coe_smul', NNReal.smul_def, addHaar_smul_of_nonneg _ (NNReal.coe_nonneg _)] rw [show μ s < _ ↔ 1 * μ s < _ by rw [one_mul]] refine (mul_lt_mul_right h_mes (ne_of_lt h_cpt.measure_lt_top)).mpr ?_ rw [ofReal_pow (NNReal.coe_nonneg _)] refine one_lt_pow₀ ?_ (ne_of_gt finrank_pos) simp [u, (exists_seq_strictAnti_tendsto (0 : ℝ≥0)).choose_spec.2.1 n] end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Arithmetic.lean
import Mathlib.MeasureTheory.Measure.AEMeasurable /-! # Typeclasses for measurability of operations In this file we define classes `MeasurableMul` etc. and prove dot-style lemmas (`Measurable.mul`, `AEMeasurable.mul` etc). For binary operations we define two typeclasses: - `MeasurableMul` says that both left and right multiplication are measurable; - `MeasurableMul₂` says that `fun p : α × α => p.1 * p.2` is measurable, and similarly for other binary operations. The reason for introducing these classes is that in case of topological space `α` equipped with the Borel `σ`-algebra, instances for `MeasurableMul₂` etc. require `α` to have a second countable topology. We define separate classes for `MeasurableDiv`/`MeasurableSub` because on some types (e.g., `ℕ`, `ℝ≥0∞`) division and/or subtraction are not defined as `a * b⁻¹` / `a + (-b)`. For instances relating, e.g., `ContinuousMul` to `MeasurableMul` see file `MeasureTheory.BorelSpace`. ## Implementation notes For the heuristics of `@[to_additive]` it is important that the type with a multiplication (or another multiplicative operations) is the first (implicit) argument of all declarations. ## Tags measurable function, arithmetic operator ## TODO * Uniformize the treatment of `pow` and `smul`. * Use `@[to_additive]` to send `MeasurablePow` to `MeasurableSMul₂`. * This might require changing the definition (swapping the arguments in the function that is in the conclusion of `MeasurableSMul`.) -/ open MeasureTheory open scoped Pointwise universe u v variable {α : Type*} /-! ### Binary operations: `(· + ·)`, `(· * ·)`, `(· - ·)`, `(· / ·)` -/ /-- We say that a type has `MeasurableAdd` if `(· + c)` and `(· + c)` are measurable functions. For a typeclass assuming measurability of `uncurry (· + ·)` see `MeasurableAdd₂`. -/ class MeasurableAdd (M : Type*) [MeasurableSpace M] [Add M] : Prop where measurable_const_add : ∀ c : M, Measurable (c + ·) measurable_add_const : ∀ c : M, Measurable (· + c) export MeasurableAdd (measurable_const_add measurable_add_const) /-- We say that a type has `MeasurableAdd₂` if `uncurry (· + ·)` is a measurable functions. For a typeclass assuming measurability of `(c + ·)` and `(· + c)` see `MeasurableAdd`. -/ class MeasurableAdd₂ (M : Type*) [MeasurableSpace M] [Add M] : Prop where measurable_add : Measurable fun p : M × M => p.1 + p.2 export MeasurableAdd₂ (measurable_add) /-- We say that a type has `MeasurableMul` if `(c * ·)` and `(· * c)` are measurable functions. For a typeclass assuming measurability of `uncurry (*)` see `MeasurableMul₂`. -/ @[to_additive] class MeasurableMul (M : Type*) [MeasurableSpace M] [Mul M] : Prop where measurable_const_mul : ∀ c : M, Measurable (c * ·) measurable_mul_const : ∀ c : M, Measurable (· * c) export MeasurableMul (measurable_const_mul measurable_mul_const) /-- We say that a type has `MeasurableMul₂` if `uncurry (· * ·)` is a measurable functions. For a typeclass assuming measurability of `(c * ·)` and `(· * c)` see `MeasurableMul`. -/ @[to_additive MeasurableAdd₂] class MeasurableMul₂ (M : Type*) [MeasurableSpace M] [Mul M] : Prop where measurable_mul : Measurable fun p : M × M => p.1 * p.2 export MeasurableMul₂ (measurable_mul) section Mul variable {M α β : Type*} [MeasurableSpace M] [Mul M] {m : MeasurableSpace α} {mβ : MeasurableSpace β} {f g : α → M} {μ : Measure α} @[to_additive (attr := fun_prop, measurability)] theorem Measurable.const_mul [MeasurableMul M] (hf : Measurable f) (c : M) : Measurable fun x => c * f x := (measurable_const_mul c).comp hf @[to_additive (attr := fun_prop, measurability)] theorem AEMeasurable.const_mul [MeasurableMul M] (hf : AEMeasurable f μ) (c : M) : AEMeasurable (fun x => c * f x) μ := (MeasurableMul.measurable_const_mul c).comp_aemeasurable hf @[to_additive (attr := fun_prop, measurability)] theorem Measurable.mul_const [MeasurableMul M] (hf : Measurable f) (c : M) : Measurable fun x => f x * c := (measurable_mul_const c).comp hf @[to_additive (attr := fun_prop, measurability)] theorem AEMeasurable.mul_const [MeasurableMul M] (hf : AEMeasurable f μ) (c : M) : AEMeasurable (fun x => f x * c) μ := (measurable_mul_const c).comp_aemeasurable hf @[to_additive (attr := fun_prop)] theorem Measurable.mul [MeasurableMul₂ M] (hf : Measurable f) (hg : Measurable g) : Measurable fun a => f a * g a := measurable_mul.comp (hf.prodMk hg) /-- Compositional version of `Measurable.mul` for use by `fun_prop`. -/ @[to_additive (attr := fun_prop) /-- Compositional version of `Measurable.add` for use by `fun_prop`. -/] lemma Measurable.mul' [MeasurableMul₂ M] {f g : α → β → M} {h : α → β} (hf : Measurable ↿f) (hg : Measurable ↿g) (hh : Measurable h) : Measurable fun a ↦ (f a * g a) (h a) := by dsimp; fun_prop @[to_additive (attr := fun_prop)] theorem AEMeasurable.mul' [MeasurableMul₂ M] (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (f * g) μ := measurable_mul.comp_aemeasurable (hf.prodMk hg) @[to_additive (attr := fun_prop)] theorem AEMeasurable.mul [MeasurableMul₂ M] (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun a => f a * g a) μ := measurable_mul.comp_aemeasurable (hf.prodMk hg) @[to_additive] instance (priority := 100) MeasurableMul₂.toMeasurableMul [MeasurableMul₂ M] : MeasurableMul M := ⟨fun _ => measurable_const.mul measurable_id, fun _ => measurable_id.mul measurable_const⟩ @[to_additive] instance Pi.measurableMul {ι : Type*} {α : ι → Type*} [∀ i, Mul (α i)] [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableMul (α i)] : MeasurableMul (∀ i, α i) := ⟨fun _ => measurable_pi_iff.mpr fun i => (measurable_pi_apply i).const_mul _, fun _ => measurable_pi_iff.mpr fun i => (measurable_pi_apply i).mul_const _⟩ @[to_additive Pi.measurableAdd₂] instance Pi.measurableMul₂ {ι : Type*} {α : ι → Type*} [∀ i, Mul (α i)] [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableMul₂ (α i)] : MeasurableMul₂ (∀ i, α i) := ⟨measurable_pi_iff.mpr fun _ => measurable_fst.eval.mul measurable_snd.eval⟩ end Mul /-- A version of `measurable_div_const` that assumes `MeasurableMul` instead of `MeasurableDiv`. This can be nice to avoid unnecessary type-class assumptions. -/ @[to_additive /-- A version of `measurable_sub_const` that assumes `MeasurableAdd` instead of `MeasurableSub`. This can be nice to avoid unnecessary type-class assumptions. -/] theorem measurable_div_const' {G : Type*} [DivInvMonoid G] [MeasurableSpace G] [MeasurableMul G] (g : G) : Measurable fun h => h / g := by simp_rw [div_eq_mul_inv, measurable_mul_const] /-- This class assumes that the map `β × γ → β` given by `(x, y) ↦ x ^ y` is measurable. -/ class MeasurablePow (β γ : Type*) [MeasurableSpace β] [MeasurableSpace γ] [Pow β γ] : Prop where measurable_pow : Measurable fun p : β × γ => p.1 ^ p.2 export MeasurablePow (measurable_pow) /-- `Monoid.Pow` is measurable. -/ instance Monoid.measurablePow (M : Type*) [Monoid M] [MeasurableSpace M] [MeasurableMul₂ M] : MeasurablePow M ℕ := ⟨measurable_from_prod_countable_left fun n => by induction n with | zero => simp only [pow_zero, ← Pi.one_def, measurable_one] | succ n ih => simp only [pow_succ] exact ih.mul measurable_id⟩ section Pow variable {β γ α : Type*} [MeasurableSpace β] [MeasurableSpace γ] [Pow β γ] [MeasurablePow β γ] {m : MeasurableSpace α} {μ : Measure α} {f : α → β} {g : α → γ} @[fun_prop] theorem Measurable.pow (hf : Measurable f) (hg : Measurable g) : Measurable fun x => f x ^ g x := measurable_pow.comp (hf.prodMk hg) @[fun_prop] theorem AEMeasurable.pow (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun x => f x ^ g x) μ := measurable_pow.comp_aemeasurable (hf.prodMk hg) @[fun_prop, measurability] theorem Measurable.pow_const (hf : Measurable f) (c : γ) : Measurable fun x => f x ^ c := hf.pow measurable_const @[fun_prop, measurability] theorem AEMeasurable.pow_const (hf : AEMeasurable f μ) (c : γ) : AEMeasurable (fun x => f x ^ c) μ := hf.pow aemeasurable_const @[fun_prop, measurability] theorem Measurable.const_pow (hg : Measurable g) (c : β) : Measurable fun x => c ^ g x := measurable_const.pow hg @[fun_prop, measurability] theorem AEMeasurable.const_pow (hg : AEMeasurable g μ) (c : β) : AEMeasurable (fun x => c ^ g x) μ := aemeasurable_const.pow hg end Pow /-- We say that a type has `MeasurableSub` if `(c - ·)` and `(· - c)` are measurable functions. For a typeclass assuming measurability of `uncurry (-)` see `MeasurableSub₂`. -/ class MeasurableSub (G : Type*) [MeasurableSpace G] [Sub G] : Prop where measurable_const_sub : ∀ c : G, Measurable (c - ·) measurable_sub_const : ∀ c : G, Measurable (· - c) export MeasurableSub (measurable_const_sub measurable_sub_const) /-- We say that a type has `MeasurableSub₂` if `uncurry (· - ·)` is a measurable functions. For a typeclass assuming measurability of `(c - ·)` and `(· - c)` see `MeasurableSub`. -/ class MeasurableSub₂ (G : Type*) [MeasurableSpace G] [Sub G] : Prop where measurable_sub : Measurable fun p : G × G => p.1 - p.2 export MeasurableSub₂ (measurable_sub) /-- We say that a type has `MeasurableDiv` if `(c / ·)` and `(· / c)` are measurable functions. For a typeclass assuming measurability of `uncurry (· / ·)` see `MeasurableDiv₂`. -/ @[to_additive] class MeasurableDiv (G₀ : Type*) [MeasurableSpace G₀] [Div G₀] : Prop where measurable_const_div : ∀ c : G₀, Measurable (c / ·) measurable_div_const : ∀ c : G₀, Measurable (· / c) export MeasurableDiv (measurable_const_div measurable_div_const) /-- We say that a type has `MeasurableDiv₂` if `uncurry (· / ·)` is a measurable functions. For a typeclass assuming measurability of `(c / ·)` and `(· / c)` see `MeasurableDiv`. -/ @[to_additive MeasurableSub₂] class MeasurableDiv₂ (G₀ : Type*) [MeasurableSpace G₀] [Div G₀] : Prop where measurable_div : Measurable fun p : G₀ × G₀ => p.1 / p.2 export MeasurableDiv₂ (measurable_div) section Div variable {G α β : Type*} [MeasurableSpace G] [Div G] {m : MeasurableSpace α} {mβ : MeasurableSpace β} {f g : α → G} {μ : Measure α} @[to_additive (attr := fun_prop, measurability)] theorem Measurable.const_div [MeasurableDiv G] (hf : Measurable f) (c : G) : Measurable fun x => c / f x := (MeasurableDiv.measurable_const_div c).comp hf @[to_additive (attr := fun_prop, measurability)] theorem AEMeasurable.const_div [MeasurableDiv G] (hf : AEMeasurable f μ) (c : G) : AEMeasurable (fun x => c / f x) μ := (MeasurableDiv.measurable_const_div c).comp_aemeasurable hf @[to_additive (attr := fun_prop, measurability)] theorem Measurable.div_const [MeasurableDiv G] (hf : Measurable f) (c : G) : Measurable fun x => f x / c := (MeasurableDiv.measurable_div_const c).comp hf @[to_additive (attr := fun_prop, measurability)] theorem AEMeasurable.div_const [MeasurableDiv G] (hf : AEMeasurable f μ) (c : G) : AEMeasurable (fun x => f x / c) μ := (MeasurableDiv.measurable_div_const c).comp_aemeasurable hf @[to_additive (attr := fun_prop)] theorem Measurable.div [MeasurableDiv₂ G] (hf : Measurable f) (hg : Measurable g) : Measurable fun a => f a / g a := measurable_div.comp (hf.prodMk hg) @[to_additive (attr := fun_prop)] lemma Measurable.div' [MeasurableDiv₂ G] {f g : α → β → G} {h : α → β} (hf : Measurable ↿f) (hg : Measurable ↿g) (hh : Measurable h) : Measurable fun a ↦ (f a / g a) (h a) := by dsimp; fun_prop @[to_additive (attr := fun_prop)] theorem AEMeasurable.div' [MeasurableDiv₂ G] (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (f / g) μ := measurable_div.comp_aemeasurable (hf.prodMk hg) @[to_additive (attr := fun_prop)] theorem AEMeasurable.div [MeasurableDiv₂ G] (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun a => f a / g a) μ := measurable_div.comp_aemeasurable (hf.prodMk hg) @[to_additive] instance (priority := 100) MeasurableDiv₂.toMeasurableDiv [MeasurableDiv₂ G] : MeasurableDiv G := ⟨fun _ => measurable_const.div measurable_id, fun _ => measurable_id.div measurable_const⟩ @[to_additive] instance Pi.measurableDiv {ι : Type*} {α : ι → Type*} [∀ i, Div (α i)] [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableDiv (α i)] : MeasurableDiv (∀ i, α i) := ⟨fun _ => measurable_pi_iff.mpr fun i => (measurable_pi_apply i).const_div _, fun _ => measurable_pi_iff.mpr fun i => (measurable_pi_apply i).div_const _⟩ @[to_additive Pi.measurableSub₂] instance Pi.measurableDiv₂ {ι : Type*} {α : ι → Type*} [∀ i, Div (α i)] [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableDiv₂ (α i)] : MeasurableDiv₂ (∀ i, α i) := ⟨measurable_pi_iff.mpr fun _ => measurable_fst.eval.div measurable_snd.eval⟩ @[measurability] theorem measurableSet_eq_fun {m : MeasurableSpace α} {E} [MeasurableSpace E] [AddGroup E] [MeasurableSingletonClass E] [MeasurableSub₂ E] {f g : α → E} (hf : Measurable f) (hg : Measurable g) : MeasurableSet { x | f x = g x } := by suffices h_set_eq : { x : α | f x = g x } = { x | (f - g) x = (0 : E) } by rw [h_set_eq] exact (hf.sub hg) measurableSet_eq ext simp_rw [Set.mem_setOf_eq, Pi.sub_apply, sub_eq_zero] @[measurability] lemma measurableSet_eq_fun' {β : Type*} [AddCommMonoid β] [PartialOrder β] [CanonicallyOrderedAdd β] [Sub β] [OrderedSub β] {_ : MeasurableSpace β} [MeasurableSub₂ β] [MeasurableSingletonClass β] {f g : α → β} (hf : Measurable f) (hg : Measurable g) : MeasurableSet {x | f x = g x} := by have : {a | f a = g a} = {a | (f - g) a = 0} ∩ {a | (g - f) a = 0} := by ext simp only [Set.mem_setOf_eq, Pi.sub_apply, tsub_eq_zero_iff_le, Set.mem_inter_iff] exact ⟨fun h ↦ ⟨h.le, h.symm.le⟩, fun h ↦ le_antisymm h.1 h.2⟩ rw [this] exact ((hf.sub hg) (measurableSet_singleton 0)).inter ((hg.sub hf) (measurableSet_singleton 0)) theorem nullMeasurableSet_eq_fun {E} [MeasurableSpace E] [AddGroup E] [MeasurableSingletonClass E] [MeasurableSub₂ E] {f g : α → E} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : NullMeasurableSet { x | f x = g x } μ := by apply (measurableSet_eq_fun hf.measurable_mk hg.measurable_mk).nullMeasurableSet.congr filter_upwards [hf.ae_eq_mk, hg.ae_eq_mk] with x hfx hgx change (hf.mk f x = hg.mk g x) = (f x = g x) simp only [hfx, hgx] theorem measurableSet_eq_fun_of_countable {m : MeasurableSpace α} {E} [MeasurableSpace E] [MeasurableSingletonClass E] [Countable E] {f g : α → E} (hf : Measurable f) (hg : Measurable g) : MeasurableSet { x | f x = g x } := by have : { x | f x = g x } = ⋃ j, { x | f x = j } ∩ { x | g x = j } := by ext1 x simp only [Set.mem_setOf_eq, Set.mem_iUnion, Set.mem_inter_iff, exists_eq_right'] rw [this] refine MeasurableSet.iUnion fun j => MeasurableSet.inter ?_ ?_ · exact hf (measurableSet_singleton j) · exact hg (measurableSet_singleton j) theorem ae_eq_trim_of_measurable {α E} {m m0 : MeasurableSpace α} {μ : Measure α} [MeasurableSpace E] [AddGroup E] [MeasurableSingletonClass E] [MeasurableSub₂ E] (hm : m ≤ m0) {f g : α → E} (hf : Measurable[m] f) (hg : Measurable[m] g) (hfg : f =ᵐ[μ] g) : f =ᵐ[μ.trim hm] g := by rwa [Filter.EventuallyEq, ae_iff, trim_measurableSet_eq hm _] exact @MeasurableSet.compl α _ m (@measurableSet_eq_fun α m E _ _ _ _ _ _ hf hg) end Div /-- We say that a type has `MeasurableNeg` if `x ↦ -x` is a measurable function. -/ class MeasurableNeg (G : Type*) [Neg G] [MeasurableSpace G] : Prop where measurable_neg : Measurable (Neg.neg : G → G) /-- We say that a type has `MeasurableInv` if `x ↦ x⁻¹` is a measurable function. -/ @[to_additive] class MeasurableInv (G : Type*) [Inv G] [MeasurableSpace G] : Prop where measurable_inv : Measurable (Inv.inv : G → G) export MeasurableInv (measurable_inv) export MeasurableNeg (measurable_neg) @[to_additive] instance (priority := 100) measurableDiv_of_mul_inv (G : Type*) [MeasurableSpace G] [DivInvMonoid G] [MeasurableMul G] [MeasurableInv G] : MeasurableDiv G where measurable_const_div c := by convert measurable_inv.const_mul c using 1 ext1 apply div_eq_mul_inv measurable_div_const c := by convert measurable_id.mul_const c⁻¹ using 1 ext1 apply div_eq_mul_inv section Inv variable {G α : Type*} [Inv G] [MeasurableSpace G] [MeasurableInv G] {m : MeasurableSpace α} {f : α → G} {μ : Measure α} @[to_additive (attr := fun_prop, measurability)] theorem Measurable.inv (hf : Measurable f) : Measurable fun x => (f x)⁻¹ := measurable_inv.comp hf @[to_additive (attr := fun_prop, measurability)] theorem AEMeasurable.inv (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x)⁻¹) μ := measurable_inv.comp_aemeasurable hf @[to_additive (attr := simp)] theorem measurable_inv_iff {G : Type*} [InvolutiveInv G] [MeasurableSpace G] [MeasurableInv G] {f : α → G} : (Measurable fun x => (f x)⁻¹) ↔ Measurable f := ⟨fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv⟩ @[to_additive (attr := simp)] theorem aemeasurable_inv_iff {G : Type*} [InvolutiveInv G] [MeasurableSpace G] [MeasurableInv G] {f : α → G} : AEMeasurable (fun x => (f x)⁻¹) μ ↔ AEMeasurable f μ := ⟨fun h => by simpa only [inv_inv] using h.inv, fun h => h.inv⟩ @[to_additive] instance Pi.measurableInv {ι : Type*} {α : ι → Type*} [∀ i, Inv (α i)] [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableInv (α i)] : MeasurableInv (∀ i, α i) := ⟨measurable_pi_iff.mpr fun i => (measurable_pi_apply i).inv⟩ @[to_additive] theorem MeasurableSet.inv {s : Set G} (hs : MeasurableSet s) : MeasurableSet s⁻¹ := measurable_inv hs @[to_additive] theorem measurableEmbedding_inv [InvolutiveInv α] [MeasurableInv α] : MeasurableEmbedding (Inv.inv (α := α)) := ⟨inv_injective, measurable_inv, fun s hs ↦ s.image_inv_eq_inv ▸ hs.inv⟩ end Inv @[to_additive] theorem Measurable.mul_iff_right {G : Type*} [MeasurableSpace G] [MeasurableSpace α] [CommGroup G] [MeasurableMul₂ G] [MeasurableInv G] {f g : α → G} (hf : Measurable f) : Measurable (f * g) ↔ Measurable g := ⟨fun h ↦ show g = f * g * f⁻¹ by simp only [mul_inv_cancel_comm] ▸ h.mul hf.inv, fun h ↦ hf.mul h⟩ @[to_additive] theorem AEMeasurable.mul_iff_right {G : Type*} [MeasurableSpace G] [MeasurableSpace α] [CommGroup G] [MeasurableMul₂ G] [MeasurableInv G] {μ : Measure α} {f g : α → G} (hf : AEMeasurable f μ) : AEMeasurable (f * g) μ ↔ AEMeasurable g μ := ⟨fun h ↦ show g = f * g * f⁻¹ by simp only [mul_inv_cancel_comm] ▸ h.mul hf.inv, fun h ↦ hf.mul h⟩ @[to_additive] theorem Measurable.mul_iff_left {G : Type*} [MeasurableSpace G] [MeasurableSpace α] [CommGroup G] [MeasurableMul₂ G] [MeasurableInv G] {f g : α → G} (hf : Measurable f) : Measurable (g * f) ↔ Measurable g := mul_comm g f ▸ Measurable.mul_iff_right hf @[to_additive] theorem AEMeasurable.mul_iff_left {G : Type*} [MeasurableSpace G] [MeasurableSpace α] [CommGroup G] [MeasurableMul₂ G] [MeasurableInv G] {μ : Measure α} {f g : α → G} (hf : AEMeasurable f μ) : AEMeasurable (g * f) μ ↔ AEMeasurable g μ := mul_comm g f ▸ AEMeasurable.mul_iff_right hf /-- `DivInvMonoid.Pow` is measurable. -/ instance DivInvMonoid.measurableZPow (G : Type u) [DivInvMonoid G] [MeasurableSpace G] [MeasurableMul₂ G] [MeasurableInv G] : MeasurablePow G ℤ := ⟨measurable_from_prod_countable_left fun n => by rcases n with n | n · simp_rw [Int.ofNat_eq_coe, zpow_natCast] exact measurable_id.pow_const _ · simp_rw [zpow_negSucc] exact (measurable_id.pow_const (n + 1)).inv⟩ @[to_additive] instance (priority := 100) measurableDiv₂_of_mul_inv (G : Type*) [MeasurableSpace G] [DivInvMonoid G] [MeasurableMul₂ G] [MeasurableInv G] : MeasurableDiv₂ G := ⟨by simp only [div_eq_mul_inv] exact measurable_fst.mul measurable_snd.inv⟩ -- See note [lower instance priority] instance (priority := 100) MeasurableDiv.toMeasurableInv [MeasurableSpace α] [Group α] [MeasurableDiv α] : MeasurableInv α where measurable_inv := by simpa using measurable_const_div (1 : α) /-- We say that the action of `M` on `α` has `MeasurableConstVAdd` if for each `c` the map `x ↦ c +ᵥ x` is a measurable function. -/ class MeasurableConstVAdd (M α : Type*) [VAdd M α] [MeasurableSpace α] : Prop where measurable_const_vadd : ∀ c : M, Measurable (c +ᵥ · : α → α) /-- We say that the action of `M` on `α` has `MeasurableConstSMul` if for each `c` the map `x ↦ c • x` is a measurable function. -/ @[to_additive] class MeasurableConstSMul (M α : Type*) [SMul M α] [MeasurableSpace α] : Prop where measurable_const_smul : ∀ c : M, Measurable (c • · : α → α) /-- We say that the action of `M` on `α` has `MeasurableVAdd` if for each `c` the map `x ↦ c +ᵥ x` is a measurable function and for each `x` the map `c ↦ c +ᵥ x` is a measurable function. -/ class MeasurableVAdd (M α : Type*) [VAdd M α] [MeasurableSpace M] [MeasurableSpace α] extends MeasurableConstVAdd M α where measurable_vadd_const : ∀ x : α, Measurable (· +ᵥ x : M → α) /-- We say that the action of `M` on `α` has `MeasurableSMul` if for each `c` the map `x ↦ c • x` is a measurable function and for each `x` the map `c ↦ c • x` is a measurable function. -/ @[to_additive] class MeasurableSMul (M α : Type*) [SMul M α] [MeasurableSpace M] [MeasurableSpace α] extends MeasurableConstSMul M α where measurable_smul_const : ∀ x : α, Measurable (· • x : M → α) /-- We say that the action of `M` on `α` has `MeasurableVAdd₂` if the map `(c, x) ↦ c +ᵥ x` is a measurable function. -/ class MeasurableVAdd₂ (M α : Type*) [VAdd M α] [MeasurableSpace M] [MeasurableSpace α] : Prop where measurable_vadd : Measurable (Function.uncurry (· +ᵥ ·) : M × α → α) /-- We say that the action of `M` on `α` has `Measurable_SMul₂` if the map `(c, x) ↦ c • x` is a measurable function. -/ @[to_additive MeasurableVAdd₂] class MeasurableSMul₂ (M α : Type*) [SMul M α] [MeasurableSpace M] [MeasurableSpace α] : Prop where measurable_smul : Measurable (Function.uncurry (· • ·) : M × α → α) export MeasurableConstVAdd (measurable_const_vadd) export MeasurableConstSMul (measurable_const_smul) export MeasurableVAdd (measurable_vadd_const) export MeasurableSMul (measurable_smul_const) export MeasurableSMul₂ (measurable_smul) export MeasurableVAdd₂ (measurable_vadd) @[to_additive] instance measurableSMul_of_mul (M : Type*) [Mul M] [MeasurableSpace M] [MeasurableMul M] : MeasurableSMul M M where measurable_const_smul := measurable_id.const_mul measurable_smul_const := measurable_id.mul_const @[to_additive] instance measurableSMul₂_of_mul (M : Type*) [Mul M] [MeasurableSpace M] [MeasurableMul₂ M] : MeasurableSMul₂ M M := ⟨measurable_mul⟩ @[to_additive] instance Submonoid.instMeasurableConstSMul {M α} [MeasurableSpace α] [Monoid M] [MulAction M α] [MeasurableConstSMul M α] (s : Submonoid M) : MeasurableConstSMul s α where measurable_const_smul c := by simpa only using measurable_const_smul (c : M) @[to_additive] instance Submonoid.instMeasurableSMul {M α} [MeasurableSpace M] [MeasurableSpace α] [Monoid M] [MulAction M α] [MeasurableSMul M α] (s : Submonoid M) : MeasurableSMul s α where measurable_smul_const x := (measurable_smul_const (M := M) x).comp measurable_subtype_coe @[to_additive] instance Subgroup.instMeasurableConstSMul {G α} [MeasurableSpace α] [Group G] [MulAction G α] [MeasurableConstSMul G α] (s : Subgroup G) : MeasurableConstSMul s α := s.toSubmonoid.instMeasurableConstSMul @[to_additive] instance Subgroup.instMeasurableSMul {G α} [MeasurableSpace G] [MeasurableSpace α] [Group G] [MulAction G α] [MeasurableSMul G α] (s : Subgroup G) : MeasurableSMul s α := s.toSubmonoid.instMeasurableSMul section SMul variable {M X α β : Type*} [MeasurableSpace X] [SMul M X] {m : MeasurableSpace α} {mβ : MeasurableSpace β} {μ : Measure α} {f : α → M} {g : α → X} section MeasurableConstSMul variable [MeasurableConstSMul M X] @[to_additive (attr := fun_prop, measurability)] lemma Measurable.const_smul (hg : Measurable g) (c : M) : Measurable (c • g) := (measurable_const_smul c).comp hg /-- Compositional version of `Measurable.const_smul` for use by `fun_prop`. -/ @[to_additive (attr := fun_prop) /-- Compositional version of `Measurable.const_vadd` for use by `fun_prop`. -/] lemma Measurable.fun_const_smul {g : α → β → X} {h : α → β} (hg : Measurable ↿g) (hh : Measurable h) (c : M) : Measurable fun a ↦ (c • g a) (h a) := (hg.comp <| measurable_id.prodMk hh).const_smul _ @[deprecated (since := "2025-04-23")] alias Measurable.const_smul' := Measurable.fun_const_smul @[to_additive (attr := fun_prop, measurability)] lemma AEMeasurable.fun_const_smul (hg : AEMeasurable g μ) (c : M) : AEMeasurable (c • g ·) μ := (measurable_const_smul c).comp_aemeasurable hg @[deprecated (since := "2025-04-23")] alias AEMeasurable.const_smul' := AEMeasurable.fun_const_smul @[to_additive (attr := fun_prop, measurability)] lemma AEMeasurable.const_smul (hf : AEMeasurable g μ) (c : M) : AEMeasurable (c • g) μ := hf.fun_const_smul c @[to_additive] instance Pi.instMeasurableConstSMul {ι : Type*} {α : ι → Type*} [∀ i, SMul M (α i)] [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableConstSMul M (α i)] : MeasurableConstSMul M (∀ i, α i) where measurable_const_smul _ := measurable_pi_iff.2 fun i ↦ (measurable_pi_apply i).const_smul _ /-- If a scalar is central, then its right action is measurable when its left action is. -/ @[to_additive] nonrec instance MulOpposite.instMeasurableConstSMul [SMul M α] [SMul Mᵐᵒᵖ α] [IsCentralScalar M α] [MeasurableConstSMul M α] : MeasurableConstSMul Mᵐᵒᵖ α where measurable_const_smul := by simpa using measurable_const_smul end MeasurableConstSMul variable [MeasurableSpace M] @[to_additive (attr := fun_prop)] theorem Measurable.smul [MeasurableSMul₂ M X] (hf : Measurable f) (hg : Measurable g) : Measurable fun x => f x • g x := measurable_smul.comp (hf.prodMk hg) /-- Compositional version of `Measurable.smul` for use by `fun_prop`. -/ @[to_additive (attr := fun_prop) /-- Compositional version of `Measurable.vadd` for use by `fun_prop`. -/] lemma Measurable.smul' [MeasurableSMul₂ M X] {f : α → β → M} {g : α → β → X} {h : α → β} (hf : Measurable ↿f) (hg : Measurable ↿g) (hh : Measurable h) : Measurable fun a ↦ (f a • g a) (h a) := by dsimp; fun_prop @[to_additive (attr := fun_prop)] theorem AEMeasurable.smul [MeasurableSMul₂ M X] {μ : Measure α} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun x => f x • g x) μ := MeasurableSMul₂.measurable_smul.comp_aemeasurable (hf.prodMk hg) @[to_additive] instance (priority := 100) MeasurableSMul₂.toMeasurableSMul [MeasurableSMul₂ M X] : MeasurableSMul M X where measurable_const_smul _ := measurable_const.smul measurable_id measurable_smul_const _ := measurable_id.smul measurable_const variable [MeasurableSMul M X] @[to_additive (attr := fun_prop, measurability)] theorem Measurable.smul_const (hf : Measurable f) (y : X) : Measurable fun x => f x • y := (MeasurableSMul.measurable_smul_const y).comp hf @[to_additive (attr := fun_prop, measurability)] theorem AEMeasurable.smul_const (hf : AEMeasurable f μ) (y : X) : AEMeasurable (fun x => f x • y) μ := (MeasurableSMul.measurable_smul_const y).comp_aemeasurable hf @[to_additive] instance Pi.measurableSMul {ι : Type*} {α : ι → Type*} [∀ i, SMul M (α i)] [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableSMul M (α i)] : MeasurableSMul M (∀ i, α i) where measurable_smul_const _ := measurable_pi_iff.2 fun _ ↦ measurable_smul_const _ /-- `AddMonoid.SMul` is measurable. -/ instance AddMonoid.measurableSMul_nat₂ (M : Type*) [AddMonoid M] [MeasurableSpace M] [MeasurableAdd₂ M] : MeasurableSMul₂ ℕ M := ⟨by suffices Measurable fun p : M × ℕ => p.2 • p.1 by apply this.comp measurable_swap refine measurable_from_prod_countable_left fun n => ?_ induction n with | zero => simp only [zero_smul, ← Pi.zero_def, measurable_zero] | succ n ih => simp only [succ_nsmul] exact ih.add measurable_id⟩ /-- `SubNegMonoid.SMulInt` is measurable. -/ instance SubNegMonoid.measurableSMul_int₂ (M : Type*) [SubNegMonoid M] [MeasurableSpace M] [MeasurableAdd₂ M] [MeasurableNeg M] : MeasurableSMul₂ ℤ M := ⟨by suffices Measurable fun p : M × ℤ => p.2 • p.1 by apply this.comp measurable_swap refine measurable_from_prod_countable_left fun n => ?_ cases n with | ofNat n => simp only [Int.ofNat_eq_coe, natCast_zsmul] exact measurable_const_smul _ | negSucc n => simp only [negSucc_zsmul] exact (measurable_const_smul _).neg⟩ end SMul section IterateMulAct variable {α : Type*} {_ : MeasurableSpace α} {f : α → α} @[to_additive] theorem Measurable.measurableSMul₂_iterateMulAct (h : Measurable f) : MeasurableSMul₂ (IterateMulAct f) α where measurable_smul := suffices Measurable fun p : α × IterateMulAct f ↦ f^[p.2.val] p.1 from this.comp measurable_swap measurable_from_prod_countable_left fun n ↦ h.iterate n.val @[to_additive (attr := simp)] theorem measurableSMul_iterateMulAct : MeasurableSMul (IterateMulAct f) α ↔ Measurable f := ⟨fun _ ↦ measurable_const_smul (IterateMulAct.mk (f := f) 1), fun h ↦ have := h.measurableSMul₂_iterateMulAct; inferInstance⟩ @[to_additive (attr := simp)] theorem measurableSMul₂_iterateMulAct : MeasurableSMul₂ (IterateMulAct f) α ↔ Measurable f := ⟨fun _ ↦ measurableSMul_iterateMulAct.mp inferInstance, Measurable.measurableSMul₂_iterateMulAct⟩ end IterateMulAct section MulAction variable {G G₀ M β α : Type*} [MeasurableSpace β] [MeasurableSpace α] {f : α → β} {μ : Measure α} section Group variable {G : Type*} [Group G] [MulAction G β] [MeasurableConstSMul G β] @[to_additive] theorem measurable_const_smul_iff (c : G) : (Measurable fun x => c • f x) ↔ Measurable f := ⟨fun h => by simpa [inv_smul_smul, Pi.smul_def] using h.const_smul c⁻¹, fun h => h.const_smul c⟩ @[to_additive] theorem aemeasurable_const_smul_iff (c : G) : AEMeasurable (fun x => c • f x) μ ↔ AEMeasurable f μ := ⟨fun h => by simpa [inv_smul_smul, Pi.smul_def] using h.const_smul c⁻¹, fun h => h.const_smul c⟩ end Group section Monoid variable [Monoid M] [MulAction M β] section MeasurableConstSMul variable [MeasurableConstSMul M β] @[to_additive] instance Units.instMeasurableConstSMul : MeasurableConstSMul Mˣ β where measurable_const_smul c := measurable_const_smul (c : M) @[to_additive] nonrec theorem IsUnit.measurable_const_smul_iff {c : M} (hc : IsUnit c) : (Measurable fun x => c • f x) ↔ Measurable f := let ⟨u, hu⟩ := hc hu ▸ measurable_const_smul_iff u @[to_additive] nonrec theorem IsUnit.aemeasurable_const_smul_iff {c : M} (hc : IsUnit c) : AEMeasurable (fun x => c • f x) μ ↔ AEMeasurable f μ := let ⟨u, hu⟩ := hc hu ▸ aemeasurable_const_smul_iff u end MeasurableConstSMul section MeasurableSMul variable [MeasurableSpace M] [MeasurableSMul M β] @[to_additive] instance Units.instMeasurableSpace : MeasurableSpace Mˣ := .comap Units.val ‹_› @[to_additive] instance Units.measurableSMul : MeasurableSMul Mˣ β where measurable_smul_const x := (measurable_smul_const x : Measurable fun c : M => c • x).comp MeasurableSpace.le_map_comap end MeasurableSMul end Monoid section GroupWithZero variable [GroupWithZero G₀] [MeasurableSpace G₀] [MulAction G₀ β] [MeasurableSMul G₀ β] theorem measurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) : (Measurable fun x => c • f x) ↔ Measurable f := (IsUnit.mk0 c hc).measurable_const_smul_iff theorem aemeasurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) : AEMeasurable (fun x => c • f x) μ ↔ AEMeasurable f μ := (IsUnit.mk0 c hc).aemeasurable_const_smul_iff end GroupWithZero end MulAction /-! ### Opposite monoid -/ section Opposite open MulOpposite @[to_additive] instance MulOpposite.instMeasurableSpace {α : Type*} [h : MeasurableSpace α] : MeasurableSpace αᵐᵒᵖ := MeasurableSpace.map op h @[to_additive] theorem measurable_mul_op {α : Type*} [MeasurableSpace α] : Measurable (op : α → αᵐᵒᵖ) := fun _ => id @[to_additive] theorem measurable_mul_unop {α : Type*} [MeasurableSpace α] : Measurable (unop : αᵐᵒᵖ → α) := fun _ => id @[to_additive] instance MulOpposite.instMeasurableMul {M : Type*} [Mul M] [MeasurableSpace M] [MeasurableMul M] : MeasurableMul Mᵐᵒᵖ := ⟨fun _ => measurable_mul_op.comp (measurable_mul_unop.mul_const _), fun _ => measurable_mul_op.comp (measurable_mul_unop.const_mul _)⟩ @[to_additive] instance MulOpposite.instMeasurableMul₂ {M : Type*} [Mul M] [MeasurableSpace M] [MeasurableMul₂ M] : MeasurableMul₂ Mᵐᵒᵖ := ⟨measurable_mul_op.comp ((measurable_mul_unop.comp measurable_snd).mul (measurable_mul_unop.comp measurable_fst))⟩ /-- If a scalar is central, then its right action is measurable when its left action is. -/ @[to_additive] nonrec instance MeasurableSMul.op {M α} [MeasurableSpace M] [MeasurableSpace α] [SMul M α] [SMul Mᵐᵒᵖ α] [IsCentralScalar M α] [MeasurableSMul M α] : MeasurableSMul Mᵐᵒᵖ α where measurable_smul_const x := show Measurable fun c => op (unop c) • x by simpa only [op_smul_eq_smul] using (measurable_smul_const x).comp measurable_mul_unop /-- If a scalar is central, then its right action is measurable when its left action is. -/ nonrec instance MeasurableSMul₂.op {M α} [MeasurableSpace M] [MeasurableSpace α] [SMul M α] [SMul Mᵐᵒᵖ α] [IsCentralScalar M α] [MeasurableSMul₂ M α] : MeasurableSMul₂ Mᵐᵒᵖ α := ⟨show Measurable fun x : Mᵐᵒᵖ × α => op (unop x.1) • x.2 by simp_rw [op_smul_eq_smul] exact (measurable_mul_unop.comp measurable_fst).smul measurable_snd⟩ @[to_additive] instance measurableSMul_opposite_of_mul {M : Type*} [Mul M] [MeasurableSpace M] [MeasurableMul M] : MeasurableSMul Mᵐᵒᵖ M where measurable_const_smul c := measurable_mul_const (unop c) measurable_smul_const x := measurable_mul_unop.const_mul x @[to_additive] instance measurableSMul₂_opposite_of_mul {M : Type*} [Mul M] [MeasurableSpace M] [MeasurableMul₂ M] : MeasurableSMul₂ Mᵐᵒᵖ M := ⟨measurable_snd.mul (measurable_mul_unop.comp measurable_fst)⟩ end Opposite /-! ### Big operators: `∏` and `∑` -/ section Monoid variable {M α : Type*} [Monoid M] [MeasurableSpace M] [MeasurableMul₂ M] {m : MeasurableSpace α} {μ : Measure α} @[to_additive (attr := measurability, fun_prop)] theorem List.measurable_prod (l : List (α → M)) (hl : ∀ f ∈ l, Measurable f) : Measurable l.prod := by induction l with | nil => exact measurable_one | cons f l ihl => rw [List.forall_mem_cons] at hl rw [List.prod_cons] exact hl.1.mul (ihl hl.2) @[deprecated (since := "2025-05-30")] alias List.measurable_sum' := List.measurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias List.measurable_prod' := List.measurable_prod @[to_additive (attr := measurability, fun_prop)] theorem List.aemeasurable_prod (l : List (α → M)) (hl : ∀ f ∈ l, AEMeasurable f μ) : AEMeasurable l.prod μ := by induction l with | nil => exact aemeasurable_one | cons f l ihl => rw [List.forall_mem_cons] at hl rw [List.prod_cons] exact hl.1.mul (ihl hl.2) @[deprecated (since := "2025-05-30")] alias List.aemeasurable_sum' := List.aemeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias List.aemeasurable_prod' := List.aemeasurable_prod @[to_additive (attr := measurability, fun_prop)] theorem List.measurable_fun_prod (l : List (α → M)) (hl : ∀ f ∈ l, Measurable f) : Measurable fun x => (l.map fun f : α → M => f x).prod := by simpa only [← Pi.list_prod_apply] using l.measurable_prod hl @[to_additive (attr := measurability, fun_prop)] theorem List.aemeasurable_fun_prod (l : List (α → M)) (hl : ∀ f ∈ l, AEMeasurable f μ) : AEMeasurable (fun x => (l.map fun f : α → M => f x).prod) μ := by simpa only [← Pi.list_prod_apply] using l.aemeasurable_prod hl end Monoid section CommMonoid variable {M ι α β : Type*} [CommMonoid M] [MeasurableSpace M] [MeasurableMul₂ M] {m : MeasurableSpace α} {mβ : MeasurableSpace β} {μ : Measure α} {f : ι → α → M} @[to_additive (attr := measurability, fun_prop)] theorem Multiset.measurable_prod (l : Multiset (α → M)) (hl : ∀ f ∈ l, Measurable f) : Measurable l.prod := by rcases l with ⟨l⟩ simpa using l.measurable_prod (by simpa using hl) @[deprecated (since := "2025-05-30")] alias Multiset.measurable_sum' := Multiset.measurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias Multiset.measurable_prod' := Multiset.measurable_prod @[to_additive (attr := measurability, fun_prop)] theorem Multiset.aemeasurable_prod (l : Multiset (α → M)) (hl : ∀ f ∈ l, AEMeasurable f μ) : AEMeasurable l.prod μ := by rcases l with ⟨l⟩ simpa using l.aemeasurable_prod (by simpa using hl) @[deprecated (since := "2025-05-30")] alias Multiset.aemeasurable_sum' := Multiset.aemeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias Multiset.aemeasurable_prod' := Multiset.aemeasurable_prod @[to_additive (attr := measurability, fun_prop)] theorem Multiset.measurable_fun_prod (s : Multiset (α → M)) (hs : ∀ f ∈ s, Measurable f) : Measurable fun x => (s.map fun f : α → M => f x).prod := by simpa only [← Pi.multiset_prod_apply] using s.measurable_prod hs @[to_additive (attr := measurability, fun_prop)] theorem Multiset.aemeasurable_fun_prod (s : Multiset (α → M)) (hs : ∀ f ∈ s, AEMeasurable f μ) : AEMeasurable (fun x => (s.map fun f : α → M => f x).prod) μ := by simpa only [← Pi.multiset_prod_apply] using s.aemeasurable_prod hs @[to_additive (attr := measurability, fun_prop)] theorem Finset.measurable_fun_prod (s : Finset ι) (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun a ↦ ∏ i ∈ s, f i a := by simp_rw [← Finset.prod_apply] exact Finset.prod_induction _ _ (fun _ _ => Measurable.mul) (@measurable_one M _ _ _ _) hf @[to_additive (attr := measurability, fun_prop)] theorem Finset.measurable_prod (s : Finset ι) (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun a ↦ ∏ i ∈ s, f i a := by simp_rw [← Finset.prod_apply] exact Finset.prod_induction _ _ (fun _ _ => Measurable.mul) (@measurable_one M _ _ _ _) hf /-- Compositional version of `Finset.measurable_prod` for use by `fun_prop`. -/ @[to_additive (attr := measurability, fun_prop) /-- Compositional version of `Finset.measurable_sum` for use by `fun_prop`. -/] lemma Finset.measurable_prod_apply {f : ι → α → β → M} {g : α → β} {s : Finset ι} (hf : ∀ i ∈ s, Measurable ↿(f i)) (hg : Measurable g) : Measurable fun a ↦ (∏ i ∈ s, f i a) (g a) := by simp only [prod_apply]; fun_prop (discharger := assumption) @[deprecated (since := "2025-05-30")] alias Finset.measurable_sum' := Finset.measurable_sum_apply @[to_additive existing, deprecated (since := "2025-05-30")] alias Finset.measurable_prod' := Finset.measurable_prod_apply @[to_additive (attr := measurability, fun_prop)] theorem Finset.aemeasurable_prod (s : Finset ι) (hf : ∀ i ∈ s, AEMeasurable (f i) μ) : AEMeasurable (∏ i ∈ s, f i) μ := Multiset.aemeasurable_prod _ fun _g hg => let ⟨_i, hi, hg⟩ := Multiset.mem_map.1 hg hg ▸ hf _ hi @[deprecated (since := "2025-05-30")] alias Finset.aemeasurable_sum' := Finset.aemeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias Finset.aemeasurable_prod' := Finset.aemeasurable_prod @[to_additive (attr := measurability, fun_prop)] theorem Finset.aemeasurable_fun_prod (s : Finset ι) (hf : ∀ i ∈ s, AEMeasurable (f i) μ) : AEMeasurable (fun a => ∏ i ∈ s, f i a) μ := by simpa only [← Finset.prod_apply] using s.aemeasurable_prod hf end CommMonoid variable [MeasurableSpace α] [Mul α] [Div α] [Inv α] @[to_additive] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableMul [DiscreteMeasurableSpace α] : MeasurableMul α where measurable_const_mul _ := .of_discrete measurable_mul_const _ := .of_discrete @[to_additive DiscreteMeasurableSpace.toMeasurableAdd₂] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableMul₂ [DiscreteMeasurableSpace (α × α)] : MeasurableMul₂ α := ⟨.of_discrete⟩ @[to_additive] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableInv [DiscreteMeasurableSpace α] : MeasurableInv α := ⟨.of_discrete⟩ @[to_additive] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableDiv [DiscreteMeasurableSpace α] : MeasurableDiv α where measurable_const_div _ := .of_discrete measurable_div_const _ := .of_discrete @[to_additive DiscreteMeasurableSpace.toMeasurableSub₂] -- See note [lower instance priority] instance (priority := 100) DiscreteMeasurableSpace.toMeasurableDiv₂ [DiscreteMeasurableSpace (α × α)] : MeasurableDiv₂ α := ⟨.of_discrete⟩
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Defs.lean
import Mathlib.MeasureTheory.Measure.Map /-! # Definitions about invariant measures In this file we define typeclasses for measures invariant under (scalar) multiplication. - `MeasureTheory.SMulInvariantMeasure M α μ` says that the measure `μ` is invariant under scalar multiplication by `c : M`; - `MeasureTheory.VAddInvariantMeasure M α μ` is the additive version of this typeclass; - `MeasureTheory.Measure.IsMulLeftInvariant μ`, `MeasureTheory.Measure.IsMulRightInvariant μ` say that the measure `μ` is invariant under multiplication on the left and on the right, respectively. - `MeasureTheory.Measure.IsAddLeftInvariant μ`, `MeasureTheory.Measure.IsAddRightInvariant μ` are the additive versions of these typeclasses. For basic facts about the first two typeclasses, see `Mathlib/MeasureTheory/Group/Action`. For facts about left/right-invariant measures, see `Mathlib/MeasureTheory/Group/Measure`. ## Implementation Notes The `smul`/`vadd` typeclasses and the left/right multiplication typeclasses were defined by different people with different tastes, so the former explicitly use measures of the preimages, while the latter use `MeasureTheory.Measure.map`. If the left/right multiplication is measurable (which is the case in most if not all interesting examples), these definitions are equivalent. The definitions that use `MeasureTheory.Measure.map` imply that the left (resp., right) multiplication is `AEMeasurable`. -/ assert_not_exists Module.Basis namespace MeasureTheory /-- A measure `μ : Measure α` is invariant under an additive action of `M` on `α` if for any measurable set `s : Set α` and `c : M`, the measure of its preimage under `fun x => c +ᵥ x` is equal to the measure of `s`. -/ class VAddInvariantMeasure (M α : Type*) [VAdd M α] {_ : MeasurableSpace α} (μ : Measure α) : Prop where measure_preimage_vadd : ∀ (c : M) ⦃s : Set α⦄, MeasurableSet s → μ ((fun x => c +ᵥ x) ⁻¹' s) = μ s /-- A measure `μ : Measure α` is invariant under a multiplicative action of `M` on `α` if for any measurable set `s : Set α` and `c : M`, the measure of its preimage under `fun x => c • x` is equal to the measure of `s`. -/ @[to_additive, mk_iff smulInvariantMeasure_iff] class SMulInvariantMeasure (M α : Type*) [SMul M α] {_ : MeasurableSpace α} (μ : Measure α) : Prop where measure_preimage_smul : ∀ (c : M) ⦃s : Set α⦄, MeasurableSet s → μ ((fun x => c • x) ⁻¹' s) = μ s attribute [to_additive] smulInvariantMeasure_iff namespace Measure variable {G : Type*} [MeasurableSpace G] /-- A measure `μ` on a measurable additive group is left invariant if the measure of left translations of a set are equal to the measure of the set itself. -/ class IsAddLeftInvariant [Add G] (μ : Measure G) : Prop where map_add_left_eq_self : ∀ g : G, map (g + ·) μ = μ /-- A measure `μ` on a measurable group is left invariant if the measure of left translations of a set are equal to the measure of the set itself. -/ @[to_additive existing] class IsMulLeftInvariant [Mul G] (μ : Measure G) : Prop where map_mul_left_eq_self : ∀ g : G, map (g * ·) μ = μ /-- A measure `μ` on a measurable additive group is right invariant if the measure of right translations of a set are equal to the measure of the set itself. -/ class IsAddRightInvariant [Add G] (μ : Measure G) : Prop where map_add_right_eq_self : ∀ g : G, map (· + g) μ = μ /-- A measure `μ` on a measurable group is right invariant if the measure of right translations of a set are equal to the measure of the set itself. -/ @[to_additive existing] class IsMulRightInvariant [Mul G] (μ : Measure G) : Prop where map_mul_right_eq_self : ∀ g : G, map (· * g) μ = μ variable {μ : Measure G} @[to_additive] instance IsMulLeftInvariant.smulInvariantMeasure [Mul G] [IsMulLeftInvariant μ] : SMulInvariantMeasure G G μ := ⟨fun _x _s hs => measure_preimage_of_map_eq_self (map_mul_left_eq_self _) hs.nullMeasurableSet⟩ @[to_additive] instance [Monoid G] (s : Submonoid G) [IsMulLeftInvariant μ] : SMulInvariantMeasure {x // x ∈ s} G μ := ⟨fun ⟨x, _⟩ _ h ↦ IsMulLeftInvariant.smulInvariantMeasure.1 x h⟩ @[to_additive] instance IsMulRightInvariant.toSMulInvariantMeasure_op [Mul G] [μ.IsMulRightInvariant] : SMulInvariantMeasure Gᵐᵒᵖ G μ := ⟨fun _x _s hs => measure_preimage_of_map_eq_self (map_mul_right_eq_self _) hs.nullMeasurableSet⟩ end Measure end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/LIntegral.lean
import Mathlib.MeasureTheory.Group.Measure /-! # Lebesgue Integration on Groups We develop properties of integrals with a group as domain. This file contains properties about Lebesgue integration. -/ assert_not_exists NormedSpace namespace MeasureTheory open Measure TopologicalSpace open scoped ENNReal variable {G : Type*} [MeasurableSpace G] {μ : Measure G} section MeasurableInv variable [InvolutiveInv G] [MeasurableInv G] /-- The Lebesgue integral of a function with respect to an inverse invariant measure is invariant under the change of variables x ↦ x⁻¹. -/ @[to_additive /-- The Lebesgue integral of a function with respect to an inverse invariant measure is invariant under the change of variables x ↦ -x. -/] theorem lintegral_inv_eq_self [IsInvInvariant μ] (f : G → ℝ≥0∞) : ∫⁻ x, f x⁻¹ ∂μ = ∫⁻ x, f x ∂μ := by simpa using (lintegral_map_equiv f (μ := μ) <| MeasurableEquiv.inv G).symm end MeasurableInv section MeasurableMul variable [Group G] [MeasurableMul G] /-- Translating a function by left-multiplication does not change its Lebesgue integral with respect to a left-invariant measure. -/ @[to_additive /-- Translating a function by left-addition does not change its Lebesgue integral with respect to a left-invariant measure. -/] theorem lintegral_mul_left_eq_self [IsMulLeftInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (g * x) ∂μ) = ∫⁻ x, f x ∂μ := by convert (lintegral_map_equiv f <| MeasurableEquiv.mulLeft g).symm simp [map_mul_left_eq_self μ g] /-- Translating a function by right-multiplication does not change its Lebesgue integral with respect to a right-invariant measure. -/ @[to_additive /-- Translating a function by right-addition does not change its Lebesgue integral with respect to a right-invariant measure. -/] theorem lintegral_mul_right_eq_self [IsMulRightInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (x * g) ∂μ) = ∫⁻ x, f x ∂μ := by convert (lintegral_map_equiv f <| MeasurableEquiv.mulRight g).symm using 1 simp [map_mul_right_eq_self μ g] @[to_additive] theorem lintegral_div_right_eq_self [IsMulRightInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (x / g) ∂μ) = ∫⁻ x, f x ∂μ := by simp_rw [div_eq_mul_inv, lintegral_mul_right_eq_self f g⁻¹] @[to_additive] theorem lintegral_div_left_eq_self [IsMulLeftInvariant μ] [MeasurableInv G] [IsInvInvariant μ] (f : G → ℝ≥0∞) (g : G) : (∫⁻ x, f (g / x) ∂μ) = ∫⁻ x, f x ∂μ := by simp_rw [div_eq_mul_inv, lintegral_inv_eq_self (f <| g * ·), lintegral_mul_left_eq_self] end MeasurableMul section IsTopologicalGroup variable [TopologicalSpace G] [Group G] [IsTopologicalGroup G] [BorelSpace G] [IsMulLeftInvariant μ] /-- For nonzero regular left invariant measures, the integral of a continuous nonnegative function `f` is 0 iff `f` is 0. -/ @[to_additive /-- For nonzero regular left invariant measures, the integral of a continuous nonnegative function `f` is 0 iff `f` is 0. -/] theorem lintegral_eq_zero_of_isMulLeftInvariant [Regular μ] [NeZero μ] {f : G → ℝ≥0∞} (hf : Continuous f) : ∫⁻ x, f x ∂μ = 0 ↔ f = 0 := by rw [lintegral_eq_zero_iff hf.measurable, hf.ae_eq_iff_eq μ continuous_zero] end IsTopologicalGroup end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/MeasurableEquiv.lean
import Mathlib.MeasureTheory.Group.Arithmetic /-! # (Scalar) multiplication and (vector) addition as measurable equivalences In this file we define the following measurable equivalences: * `MeasurableEquiv.smul`: if a group `G` acts on `α` by measurable maps, then each element `c : G` defines a measurable automorphism of `α`; * `MeasurableEquiv.vadd`: additive version of `MeasurableEquiv.smul`; * `MeasurableEquiv.smul₀`: if a group with zero `G` acts on `α` by measurable maps, then each nonzero element `c : G` defines a measurable automorphism of `α`; * `MeasurableEquiv.mulLeft`: if `G` is a group with measurable multiplication, then left multiplication by `g : G` is a measurable automorphism of `G`; * `MeasurableEquiv.addLeft`: additive version of `MeasurableEquiv.mulLeft`; * `MeasurableEquiv.mulRight`: if `G` is a group with measurable multiplication, then right multiplication by `g : G` is a measurable automorphism of `G`; * `MeasurableEquiv.addRight`: additive version of `MeasurableEquiv.mulRight`; * `MeasurableEquiv.mulLeft₀`, `MeasurableEquiv.mulRight₀`: versions of `MeasurableEquiv.mulLeft` and `MeasurableEquiv.mulRight` for groups with zero; * `MeasurableEquiv.inv`: `Inv.inv` as a measurable automorphism of a group (or a group with zero); * `MeasurableEquiv.neg`: negation as a measurable automorphism of an additive group. We also deduce that the corresponding maps are measurable embeddings. ## Tags measurable, equivalence, group action -/ open scoped Pointwise NNReal namespace MeasurableEquiv variable {G G₀ α : Type*} [MeasurableSpace α] [Group G] [GroupWithZero G₀] [MulAction G α] [MulAction G₀ α] [MeasurableConstSMul G α] [MeasurableConstSMul G₀ α] /-- If a group `G` acts on `α` by measurable maps, then each element `c : G` defines a measurable automorphism of `α`. -/ @[to_additive (attr := simps! -fullyApplied toEquiv apply) /-- If an additive group `G` acts on `α` by measurable maps, then each element `c : G` defines a measurable automorphism of `α`. -/] def smul (c : G) : α ≃ᵐ α where toEquiv := MulAction.toPerm c measurable_toFun := measurable_const_smul c measurable_invFun := measurable_const_smul c⁻¹ @[to_additive] theorem _root_.measurableEmbedding_const_smul (c : G) : MeasurableEmbedding (c • · : α → α) := (smul c).measurableEmbedding @[to_additive (attr := simp)] theorem symm_smul (c : G) : (smul c : α ≃ᵐ α).symm = smul c⁻¹ := ext rfl /-- If a group with zero `G₀` acts on `α` by measurable maps, then each nonzero element `c : G₀` defines a measurable automorphism of `α` -/ def smul₀ (c : G₀) (hc : c ≠ 0) : α ≃ᵐ α := MeasurableEquiv.smul (Units.mk0 c hc) @[simp] lemma coe_smul₀ {c : G₀} (hc : c ≠ 0) : ⇑(smul₀ c hc : α ≃ᵐ α) = (c • ·) := rfl @[simp] theorem symm_smul₀ {c : G₀} (hc : c ≠ 0) : (smul₀ c hc : α ≃ᵐ α).symm = smul₀ c⁻¹ (inv_ne_zero hc) := ext rfl theorem _root_.measurableEmbedding_const_smul₀ {c : G₀} (hc : c ≠ 0) : MeasurableEmbedding (c • · : α → α) := (smul₀ c hc).measurableEmbedding variable [MeasurableSpace G] [MeasurableSpace G₀] section Mul variable [MeasurableMul G] [MeasurableMul G₀] /-- If `G` is a group with measurable multiplication, then left multiplication by `g : G` is a measurable automorphism of `G`. -/ @[to_additive /-- If `G` is an additive group with measurable addition, then addition of `g : G` on the left is a measurable automorphism of `G`. -/] def mulLeft (g : G) : G ≃ᵐ G := smul g @[to_additive (attr := simp)] theorem coe_mulLeft (g : G) : ⇑(mulLeft g) = (g * ·) := rfl @[to_additive (attr := simp)] theorem symm_mulLeft (g : G) : (mulLeft g).symm = mulLeft g⁻¹ := ext rfl @[to_additive (attr := simp)] theorem toEquiv_mulLeft (g : G) : (mulLeft g).toEquiv = Equiv.mulLeft g := rfl @[to_additive] theorem _root_.measurableEmbedding_mulLeft (g : G) : MeasurableEmbedding (g * ·) := (mulLeft g).measurableEmbedding /-- If `G` is a group with measurable multiplication, then right multiplication by `g : G` is a measurable automorphism of `G`. -/ @[to_additive /-- If `G` is an additive group with measurable addition, then addition of `g : G` on the right is a measurable automorphism of `G`. -/] def mulRight (g : G) : G ≃ᵐ G where toEquiv := Equiv.mulRight g measurable_toFun := measurable_mul_const g measurable_invFun := measurable_mul_const g⁻¹ @[to_additive] theorem _root_.measurableEmbedding_mulRight (g : G) : MeasurableEmbedding fun x => x * g := (mulRight g).measurableEmbedding @[to_additive (attr := simp)] theorem coe_mulRight (g : G) : ⇑(mulRight g) = fun x => x * g := rfl @[to_additive (attr := simp)] theorem symm_mulRight (g : G) : (mulRight g).symm = mulRight g⁻¹ := ext rfl @[to_additive (attr := simp)] theorem toEquiv_mulRight (g : G) : (mulRight g).toEquiv = Equiv.mulRight g := rfl /-- If `G₀` is a group with zero with measurable multiplication, then left multiplication by a nonzero element `g : G₀` is a measurable automorphism of `G₀`. -/ def mulLeft₀ (g : G₀) (hg : g ≠ 0) : G₀ ≃ᵐ G₀ := smul₀ g hg theorem _root_.measurableEmbedding_mulLeft₀ {g : G₀} (hg : g ≠ 0) : MeasurableEmbedding (g * ·) := (mulLeft₀ g hg).measurableEmbedding @[simp] lemma coe_mulLeft₀ {g : G₀} (hg : g ≠ 0) : ⇑(mulLeft₀ g hg) = (g * ·) := rfl @[simp] theorem symm_mulLeft₀ {g : G₀} (hg : g ≠ 0) : (mulLeft₀ g hg).symm = mulLeft₀ g⁻¹ (inv_ne_zero hg) := ext rfl @[simp] theorem toEquiv_mulLeft₀ {g : G₀} (hg : g ≠ 0) : (mulLeft₀ g hg).toEquiv = Equiv.mulLeft₀ g hg := rfl /-- If `G₀` is a group with zero with measurable multiplication, then right multiplication by a nonzero element `g : G₀` is a measurable automorphism of `G₀`. -/ def mulRight₀ (g : G₀) (hg : g ≠ 0) : G₀ ≃ᵐ G₀ where toEquiv := Equiv.mulRight₀ g hg measurable_toFun := measurable_mul_const g measurable_invFun := measurable_mul_const g⁻¹ theorem _root_.measurableEmbedding_mulRight₀ {g : G₀} (hg : g ≠ 0) : MeasurableEmbedding fun x => x * g := (mulRight₀ g hg).measurableEmbedding @[simp] theorem coe_mulRight₀ {g : G₀} (hg : g ≠ 0) : ⇑(mulRight₀ g hg) = fun x => x * g := rfl @[simp] theorem symm_mulRight₀ {g : G₀} (hg : g ≠ 0) : (mulRight₀ g hg).symm = mulRight₀ g⁻¹ (inv_ne_zero hg) := ext rfl @[simp] theorem toEquiv_mulRight₀ {g : G₀} (hg : g ≠ 0) : (mulRight₀ g hg).toEquiv = Equiv.mulRight₀ g hg := rfl end Mul /-- Inversion as a measurable automorphism of a group or group with zero. -/ @[to_additive (attr := simps! -fullyApplied toEquiv apply) /-- Negation as a measurable automorphism of an additive group. -/] def inv (G) [MeasurableSpace G] [InvolutiveInv G] [MeasurableInv G] : G ≃ᵐ G where toEquiv := Equiv.inv G measurable_toFun := measurable_inv measurable_invFun := measurable_inv @[to_additive (attr := simp)] theorem symm_inv {G} [MeasurableSpace G] [InvolutiveInv G] [MeasurableInv G] : (inv G).symm = inv G := rfl /-- `equiv.divRight` as a `MeasurableEquiv`. -/ @[to_additive /-- `equiv.subRight` as a `MeasurableEquiv` -/] def divRight [MeasurableMul G] (g : G) : G ≃ᵐ G where toEquiv := Equiv.divRight g measurable_toFun := measurable_div_const' g measurable_invFun := measurable_mul_const g @[to_additive] lemma _root_.measurableEmbedding_divRight [MeasurableMul G] (g : G) : MeasurableEmbedding fun x ↦ x / g := (divRight g).measurableEmbedding /-- `equiv.divLeft` as a `MeasurableEquiv` -/ @[to_additive /-- `equiv.subLeft` as a `MeasurableEquiv` -/] def divLeft [MeasurableMul G] [MeasurableInv G] (g : G) : G ≃ᵐ G where toEquiv := Equiv.divLeft g measurable_toFun := measurable_id.const_div g measurable_invFun := measurable_inv.mul_const g @[to_additive] lemma _root_.measurableEmbedding_divLeft [MeasurableMul G] [MeasurableInv G] (g : G) : MeasurableEmbedding fun x ↦ g / x := (divLeft g).measurableEmbedding end MeasurableEquiv namespace MeasureTheory.Measure variable {G A : Type*} [Group G] [MulAction G A] [MeasurableSpace A] [MeasurableConstSMul G A] {μ ν : Measure A} {g : G} noncomputable instance : DistribMulAction Gᵈᵐᵃ (Measure A) where smul g μ := μ.map (DomMulAct.mk.symm g⁻¹ • ·) one_smul μ := show μ.map _ = _ by simp mul_smul g g' μ := show μ.map _ = ((μ.map _).map _) by rw [map_map] · simp [Function.comp_def, mul_smul] · exact measurable_const_smul .. · exact measurable_const_smul .. smul_zero g := show (0 : Measure A).map _ = 0 by simp smul_add g μ ν := show (μ + ν).map _ = μ.map _ + ν.map _ by rw [Measure.map_add]; exact measurable_const_smul .. lemma domSMul_apply (μ : Measure A) (g : Gᵈᵐᵃ) (s : Set A) : (g • μ) s = μ (DomMulAct.mk.symm g • s) := by refine ((MeasurableEquiv.smul ((DomMulAct.mk.symm g : G)⁻¹)).map_apply _).trans ?_ congr 1 exact Set.preimage_smul_inv (DomMulAct.mk.symm g) s @[deprecated (since := "2025-08-05")] alias dmaSMul_apply := domSMul_apply instance : SMulCommClass ℝ≥0 Gᵈᵐᵃ (Measure A) where smul_comm r g μ := show r • μ.map _ = (r • μ).map _ by simp instance : SMulCommClass Gᵈᵐᵃ ℝ≥0 (Measure A) := .symm .. end MeasureTheory.Measure
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Action.lean
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.Dynamics.Minimal import Mathlib.GroupTheory.GroupAction.Hom import Mathlib.MeasureTheory.Group.MeasurableEquiv import Mathlib.MeasureTheory.Measure.Regular import Mathlib.MeasureTheory.Group.Defs import Mathlib.Order.Filter.EventuallyConst /-! # Measures invariant under group actions A measure `μ : Measure α` is said to be *invariant* under an action of a group `G` if scalar multiplication by `c : G` is a measure-preserving map for all `c`. In this file we define a typeclass for measures invariant under action of an (additive or multiplicative) group and prove some basic properties of such measures. -/ open scoped ENNReal NNReal Pointwise Topology open MeasureTheory.Measure Set Function Filter namespace MeasureTheory universe u v w variable {G : Type u} {M : Type v} {α : Type w} namespace SMulInvariantMeasure @[to_additive] instance zero [MeasurableSpace α] [SMul M α] : SMulInvariantMeasure M α (0 : Measure α) := ⟨fun _ _ _ => rfl⟩ variable [SMul M α] {m : MeasurableSpace α} {μ ν : Measure α} @[to_additive] instance add [SMulInvariantMeasure M α μ] [SMulInvariantMeasure M α ν] : SMulInvariantMeasure M α (μ + ν) := ⟨fun c _s hs => show _ + _ = _ + _ from congr_arg₂ (· + ·) (measure_preimage_smul c hs) (measure_preimage_smul c hs)⟩ @[to_additive] instance smul [SMulInvariantMeasure M α μ] (c : ℝ≥0∞) : SMulInvariantMeasure M α (c • μ) := ⟨fun a _s hs => show c • _ = c • _ from congr_arg (c • ·) (measure_preimage_smul a hs)⟩ @[to_additive] instance smul_nnreal [SMulInvariantMeasure M α μ] (c : ℝ≥0) : SMulInvariantMeasure M α (c • μ) := SMulInvariantMeasure.smul c end SMulInvariantMeasure section AE_smul variable {m : MeasurableSpace α} [SMul G α] (μ : Measure α) [SMulInvariantMeasure G α μ] {s : Set α} /-- See also `measure_preimage_smul_of_nullMeasurableSet` and `measure_preimage_smul`. -/ @[to_additive /-- See also `measure_preimage_smul_of_nullMeasurableSet` and `measure_preimage_smul`. -/] theorem measure_preimage_smul_le (c : G) (s : Set α) : μ ((c • ·) ⁻¹' s) ≤ μ s := (outerMeasure_le_iff (m := .map (c • ·) μ.1)).2 (fun _s hs ↦ (SMulInvariantMeasure.measure_preimage_smul _ hs).le) _ /-- See also `smul_ae`. -/ @[to_additive /-- See also `vadd_ae`. -/] theorem tendsto_smul_ae (c : G) : Filter.Tendsto (c • ·) (ae μ) (ae μ) := fun _s hs ↦ eq_bot_mono (measure_preimage_smul_le μ c _) hs variable {μ} @[to_additive] theorem measure_preimage_smul_null (h : μ s = 0) (c : G) : μ ((c • ·) ⁻¹' s) = 0 := eq_bot_mono (measure_preimage_smul_le μ c _) h @[to_additive] theorem measure_preimage_smul_of_nullMeasurableSet (hs : NullMeasurableSet s μ) (c : G) : μ ((c • ·) ⁻¹' s) = μ s := by rw [← measure_toMeasurable s, ← SMulInvariantMeasure.measure_preimage_smul c (measurableSet_toMeasurable μ s)] exact measure_congr (tendsto_smul_ae μ c hs.toMeasurable_ae_eq) |>.symm end AE_smul section AE variable {m : MeasurableSpace α} [Group G] [MulAction G α] (μ : Measure α) [SMulInvariantMeasure G α μ] @[to_additive (attr := simp)] theorem measure_preimage_smul (c : G) (s : Set α) : μ ((c • ·) ⁻¹' s) = μ s := (measure_preimage_smul_le μ c s).antisymm <| by simpa [preimage_preimage] using measure_preimage_smul_le μ c⁻¹ ((c • ·) ⁻¹' s) @[to_additive (attr := simp)] theorem measure_smul (c : G) (s : Set α) : μ (c • s) = μ s := by simpa only [preimage_smul_inv] using measure_preimage_smul μ c⁻¹ s variable {μ} @[to_additive] theorem measure_smul_eq_zero_iff {s} (c : G) : μ (c • s) = 0 ↔ μ s = 0 := by rw [measure_smul] @[to_additive] theorem measure_smul_null {s} (h : μ s = 0) (c : G) : μ (c • s) = 0 := (measure_smul_eq_zero_iff _).2 h @[to_additive (attr := simp)] theorem smul_mem_ae (c : G) {s : Set α} : c • s ∈ ae μ ↔ s ∈ ae μ := by simp only [mem_ae_iff, ← smul_set_compl, measure_smul_eq_zero_iff] @[to_additive (attr := simp)] theorem smul_ae (c : G) : c • ae μ = ae μ := by ext s simp only [mem_smul_filter, preimage_smul, smul_mem_ae] @[to_additive (attr := simp)] theorem eventuallyConst_smul_set_ae (c : G) {s : Set α} : EventuallyConst (c • s : Set α) (ae μ) ↔ EventuallyConst s (ae μ) := by rw [← preimage_smul_inv, eventuallyConst_preimage, Filter.map_smul, smul_ae] @[to_additive (attr := simp)] theorem smul_set_ae_le (c : G) {s t : Set α} : c • s ≤ᵐ[μ] c • t ↔ s ≤ᵐ[μ] t := by simp only [ae_le_set, ← smul_set_sdiff, measure_smul_eq_zero_iff] @[to_additive (attr := simp)] theorem smul_set_ae_eq (c : G) {s t : Set α} : c • s =ᵐ[μ] c • t ↔ s =ᵐ[μ] t := by simp only [Filter.eventuallyLE_antisymm_iff, smul_set_ae_le] end AE section MeasurableSMul variable {m : MeasurableSpace α} [MeasurableSpace M] [SMul M α] [MeasurableSMul M α] (c : M) (μ : Measure α) [SMulInvariantMeasure M α μ] @[to_additive (attr := simp)] theorem measurePreserving_smul : MeasurePreserving (c • ·) μ μ := { measurable := measurable_const_smul c map_eq := by ext1 s hs rw [map_apply (measurable_const_smul c) hs] exact SMulInvariantMeasure.measure_preimage_smul c hs } @[to_additive (attr := simp)] protected theorem map_smul : map (c • ·) μ = μ := (measurePreserving_smul c μ).map_eq end MeasurableSMul @[to_additive] theorem MeasurePreserving.smulInvariantMeasure_iterateMulAct {f : α → α} {_ : MeasurableSpace α} {μ : Measure α} (hf : MeasurePreserving f μ μ) : SMulInvariantMeasure (IterateMulAct f) α μ := ⟨fun n _s hs ↦ (hf.iterate n.val).measure_preimage hs.nullMeasurableSet⟩ @[to_additive] theorem smulInvariantMeasure_iterateMulAct {f : α → α} {_ : MeasurableSpace α} {μ : Measure α} (hf : Measurable f) : SMulInvariantMeasure (IterateMulAct f) α μ ↔ MeasurePreserving f μ μ := ⟨fun _ ↦ have := hf.measurableSMul₂_iterateMulAct measurePreserving_smul (IterateMulAct.mk (f := f) 1) μ, MeasurePreserving.smulInvariantMeasure_iterateMulAct⟩ section SMulHomClass universe uM uN uα uβ variable {M : Type uM} {N : Type uN} {α : Type uα} {β : Type uβ} [MeasurableSpace M] [MeasurableSpace N] [MeasurableSpace α] [MeasurableSpace β] @[to_additive] theorem smulInvariantMeasure_map [SMul M α] [SMul M β] [MeasurableSMul M β] (μ : Measure α) [SMulInvariantMeasure M α μ] (f : α → β) (hsmul : ∀ (m : M) a, f (m • a) = m • f a) (hf : Measurable f) : SMulInvariantMeasure M β (map f μ) where measure_preimage_smul m S hS := calc map f μ ((m • ·) ⁻¹' S) _ = μ (f ⁻¹' ((m • ·) ⁻¹' S)) := map_apply hf <| hS.preimage (measurable_const_smul _) _ = μ ((m • f ·) ⁻¹' S) := by rw [preimage_preimage] _ = μ ((f <| m • ·) ⁻¹' S) := by simp_rw [hsmul] _ = μ ((m • ·) ⁻¹' (f ⁻¹' S)) := by rw [← preimage_preimage] _ = μ (f ⁻¹' S) := by rw [SMulInvariantMeasure.measure_preimage_smul m (hS.preimage hf)] _ = map f μ S := (map_apply hf hS).symm @[to_additive] instance smulInvariantMeasure_map_smul [SMul M α] [SMul N α] [SMulCommClass N M α] [MeasurableSMul M α] [MeasurableSMul N α] (μ : Measure α) [SMulInvariantMeasure M α μ] (n : N) : SMulInvariantMeasure M α (map (n • ·) μ) := smulInvariantMeasure_map μ _ (smul_comm n) <| measurable_const_smul _ end SMulHomClass variable (G) {m : MeasurableSpace α} [Group G] [MulAction G α] (μ : Measure α) variable [MeasurableSpace G] [MeasurableSMul G α] in /-- Equivalent definitions of a measure invariant under a multiplicative action of a group. - 0: `SMulInvariantMeasure G α μ`; - 1: for every `c : G` and a measurable set `s`, the measure of the preimage of `s` under scalar multiplication by `c` is equal to the measure of `s`; - 2: for every `c : G` and a measurable set `s`, the measure of the image `c • s` of `s` under scalar multiplication by `c` is equal to the measure of `s`; - 3, 4: properties 2, 3 for any set, including non-measurable ones; - 5: for any `c : G`, scalar multiplication by `c` maps `μ` to `μ`; - 6: for any `c : G`, scalar multiplication by `c` is a measure-preserving map. -/ @[to_additive] theorem smulInvariantMeasure_tfae : List.TFAE [SMulInvariantMeasure G α μ, ∀ (c : G) (s), MeasurableSet s → μ ((c • ·) ⁻¹' s) = μ s, ∀ (c : G) (s), MeasurableSet s → μ (c • s) = μ s, ∀ (c : G) (s), μ ((c • ·) ⁻¹' s) = μ s, ∀ (c : G) (s), μ (c • s) = μ s, ∀ c : G, Measure.map (c • ·) μ = μ, ∀ c : G, MeasurePreserving (c • ·) μ μ] := by tfae_have 1 ↔ 2 := ⟨fun h => h.1, fun h => ⟨h⟩⟩ tfae_have 1 → 6 := fun h c => (measurePreserving_smul c μ).map_eq tfae_have 6 → 7 := fun H c => ⟨measurable_const_smul c, H c⟩ tfae_have 7 → 4 := fun H c => (H c).measure_preimage_emb (measurableEmbedding_const_smul c) tfae_have 4 → 5 | H, c, s => by rw [← preimage_smul_inv] apply H tfae_have 5 → 3 := fun H c s _ => H c s tfae_have 3 → 2 | H, c, s, hs => by rw [preimage_smul] exact H c⁻¹ s hs tfae_finish /-- Equivalent definitions of a measure invariant under an additive action of a group. - 0: `VAddInvariantMeasure G α μ`; - 1: for every `c : G` and a measurable set `s`, the measure of the preimage of `s` under vector addition `(c +ᵥ ·)` is equal to the measure of `s`; - 2: for every `c : G` and a measurable set `s`, the measure of the image `c +ᵥ s` of `s` under vector addition `(c +ᵥ ·)` is equal to the measure of `s`; - 3, 4: properties 2, 3 for any set, including non-measurable ones; - 5: for any `c : G`, vector addition of `c` maps `μ` to `μ`; - 6: for any `c : G`, vector addition of `c` is a measure-preserving map. -/ add_decl_doc vaddInvariantMeasure_tfae variable {G} variable [SMulInvariantMeasure G α μ] variable {μ} variable [MeasurableSpace G] [MeasurableSMul G α] in @[to_additive] theorem NullMeasurableSet.smul {s} (hs : NullMeasurableSet s μ) (c : G) : NullMeasurableSet (c • s) μ := by simpa only [← preimage_smul_inv] using hs.preimage (measurePreserving_smul _ _).quasiMeasurePreserving section IsMinimal variable (G) variable [TopologicalSpace α] [ContinuousConstSMul G α] [MulAction.IsMinimal G α] {K U : Set α} include G in /-- If measure `μ` is invariant under a group action and is nonzero on a compact set `K`, then it is positive on any nonempty open set. In case of a regular measure, one can assume `μ ≠ 0` instead of `μ K ≠ 0`, see `MeasureTheory.measure_isOpen_pos_of_smulInvariant_of_ne_zero`. -/ @[to_additive] theorem measure_isOpen_pos_of_smulInvariant_of_compact_ne_zero (hK : IsCompact K) (hμK : μ K ≠ 0) (hU : IsOpen U) (hne : U.Nonempty) : 0 < μ U := let ⟨t, ht⟩ := hK.exists_finite_cover_smul G hU hne pos_iff_ne_zero.2 fun hμU => hμK <| measure_mono_null ht <| (measure_biUnion_null_iff t.countable_toSet).2 fun _ _ => by rwa [measure_smul] /-- If measure `μ` is invariant under an additive group action and is nonzero on a compact set `K`, then it is positive on any nonempty open set. In case of a regular measure, one can assume `μ ≠ 0` instead of `μ K ≠ 0`, see `MeasureTheory.measure_isOpen_pos_of_vaddInvariant_of_ne_zero`. -/ add_decl_doc measure_isOpen_pos_of_vaddInvariant_of_compact_ne_zero include G @[to_additive] theorem isLocallyFiniteMeasure_of_smulInvariant (hU : IsOpen U) (hne : U.Nonempty) (hμU : μ U ≠ ∞) : IsLocallyFiniteMeasure μ := ⟨fun x => let ⟨g, hg⟩ := hU.exists_smul_mem G x hne ⟨(g • ·) ⁻¹' U, (hU.preimage (continuous_id.const_smul _)).mem_nhds hg, Ne.lt_top <| by rwa [measure_preimage_smul]⟩⟩ variable [Measure.Regular μ] @[to_additive] theorem measure_isOpen_pos_of_smulInvariant_of_ne_zero (hμ : μ ≠ 0) (hU : IsOpen U) (hne : U.Nonempty) : 0 < μ U := let ⟨_K, hK, hμK⟩ := Regular.exists_isCompact_not_null.mpr hμ measure_isOpen_pos_of_smulInvariant_of_compact_ne_zero G hK hμK hU hne @[to_additive] theorem measure_pos_iff_nonempty_of_smulInvariant (hμ : μ ≠ 0) (hU : IsOpen U) : 0 < μ U ↔ U.Nonempty := ⟨fun h => nonempty_of_measure_ne_zero h.ne', measure_isOpen_pos_of_smulInvariant_of_ne_zero G hμ hU⟩ @[to_additive] theorem measure_eq_zero_iff_eq_empty_of_smulInvariant (hμ : μ ≠ 0) (hU : IsOpen U) : μ U = 0 ↔ U = ∅ := by rw [← not_iff_not, ← Ne, ← pos_iff_ne_zero, measure_pos_iff_nonempty_of_smulInvariant G hμ hU, nonempty_iff_ne_empty] end IsMinimal end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Measure.lean
import Mathlib.Algebra.Group.Pointwise.Set.Card import Mathlib.GroupTheory.Complement import Mathlib.MeasureTheory.Group.Action import Mathlib.MeasureTheory.Group.Pointwise import Mathlib.MeasureTheory.Measure.Prod import Mathlib.Topology.Algebra.Module.Equiv import Mathlib.Topology.ContinuousMap.CocompactMap import Mathlib.Topology.Algebra.ContinuousMonoidHom /-! # Measures on Groups We develop some properties of measures on (topological) groups * We define properties on measures: measures that are left or right invariant w.r.t. multiplication. * We define the measure `μ.inv : A ↦ μ(A⁻¹)` and show that it is right invariant iff `μ` is left invariant. * We define a class `IsHaarMeasure μ`, requiring that the measure `μ` is left-invariant, finite on compact sets, and positive on open sets. We also give analogues of all these notions in the additive world. -/ noncomputable section open scoped NNReal ENNReal Pointwise Topology open Inv Set Function MeasureTheory.Measure Filter variable {G H : Type*} [MeasurableSpace G] [MeasurableSpace H] namespace MeasureTheory section Mul variable [Mul G] {μ : Measure G} @[to_additive] theorem map_mul_left_eq_self (μ : Measure G) [IsMulLeftInvariant μ] (g : G) : map (g * ·) μ = μ := IsMulLeftInvariant.map_mul_left_eq_self g @[to_additive] theorem map_mul_right_eq_self (μ : Measure G) [IsMulRightInvariant μ] (g : G) : map (· * g) μ = μ := IsMulRightInvariant.map_mul_right_eq_self g @[to_additive MeasureTheory.isAddLeftInvariant_smul] instance isMulLeftInvariant_smul [IsMulLeftInvariant μ] (c : ℝ≥0∞) : IsMulLeftInvariant (c • μ) := ⟨fun g => by rw [Measure.map_smul, map_mul_left_eq_self]⟩ @[to_additive MeasureTheory.isAddRightInvariant_smul] instance isMulRightInvariant_smul [IsMulRightInvariant μ] (c : ℝ≥0∞) : IsMulRightInvariant (c • μ) := ⟨fun g => by rw [Measure.map_smul, map_mul_right_eq_self]⟩ @[to_additive MeasureTheory.isAddLeftInvariant_smul_nnreal] instance isMulLeftInvariant_smul_nnreal [IsMulLeftInvariant μ] (c : ℝ≥0) : IsMulLeftInvariant (c • μ) := MeasureTheory.isMulLeftInvariant_smul (c : ℝ≥0∞) @[to_additive MeasureTheory.isAddRightInvariant_smul_nnreal] instance isMulRightInvariant_smul_nnreal [IsMulRightInvariant μ] (c : ℝ≥0) : IsMulRightInvariant (c • μ) := MeasureTheory.isMulRightInvariant_smul (c : ℝ≥0∞) section MeasurableMul variable [MeasurableMul G] @[to_additive] theorem measurePreserving_mul_left (μ : Measure G) [IsMulLeftInvariant μ] (g : G) : MeasurePreserving (g * ·) μ μ := ⟨measurable_const_mul g, map_mul_left_eq_self μ g⟩ @[to_additive] theorem MeasurePreserving.mul_left (μ : Measure G) [IsMulLeftInvariant μ] (g : G) {X : Type*} [MeasurableSpace X] {μ' : Measure X} {f : X → G} (hf : MeasurePreserving f μ' μ) : MeasurePreserving (fun x => g * f x) μ' μ := (measurePreserving_mul_left μ g).comp hf @[to_additive] theorem measurePreserving_mul_right (μ : Measure G) [IsMulRightInvariant μ] (g : G) : MeasurePreserving (· * g) μ μ := ⟨measurable_mul_const g, map_mul_right_eq_self μ g⟩ @[to_additive] theorem MeasurePreserving.mul_right (μ : Measure G) [IsMulRightInvariant μ] (g : G) {X : Type*} [MeasurableSpace X] {μ' : Measure X} {f : X → G} (hf : MeasurePreserving f μ' μ) : MeasurePreserving (fun x => f x * g) μ' μ := (measurePreserving_mul_right μ g).comp hf @[to_additive] instance Subgroup.smulInvariantMeasure {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace α] {μ : Measure α} [SMulInvariantMeasure G α μ] (H : Subgroup G) : SMulInvariantMeasure H α μ := ⟨fun y s hs => by convert SMulInvariantMeasure.measure_preimage_smul (μ := μ) (y : G) hs⟩ /-- An alternative way to prove that `μ` is left invariant under multiplication. -/ @[to_additive /-- An alternative way to prove that `μ` is left invariant under addition. -/] theorem forall_measure_preimage_mul_iff (μ : Measure G) : (∀ (g : G) (A : Set G), MeasurableSet A → μ ((fun h => g * h) ⁻¹' A) = μ A) ↔ IsMulLeftInvariant μ := by trans ∀ g, map (g * ·) μ = μ · simp_rw [Measure.ext_iff] refine forall_congr' fun g => forall_congr' fun A => forall_congr' fun hA => ?_ rw [map_apply (measurable_const_mul g) hA] exact ⟨fun h => ⟨h⟩, fun h => h.1⟩ /-- An alternative way to prove that `μ` is right invariant under multiplication. -/ @[to_additive /-- An alternative way to prove that `μ` is right invariant under addition. -/] theorem forall_measure_preimage_mul_right_iff (μ : Measure G) : (∀ (g : G) (A : Set G), MeasurableSet A → μ ((fun h => h * g) ⁻¹' A) = μ A) ↔ IsMulRightInvariant μ := by trans ∀ g, map (· * g) μ = μ · simp_rw [Measure.ext_iff] refine forall_congr' fun g => forall_congr' fun A => forall_congr' fun hA => ?_ rw [map_apply (measurable_mul_const g) hA] exact ⟨fun h => ⟨h⟩, fun h => h.1⟩ @[to_additive] instance Measure.prod.instIsMulLeftInvariant [IsMulLeftInvariant μ] [SFinite μ] {H : Type*} [Mul H] {mH : MeasurableSpace H} {ν : Measure H} [MeasurableMul H] [IsMulLeftInvariant ν] [SFinite ν] : IsMulLeftInvariant (μ.prod ν) := by constructor rintro ⟨g, h⟩ change map (Prod.map (g * ·) (h * ·)) (μ.prod ν) = μ.prod ν rw [← map_prod_map _ _ (measurable_const_mul g) (measurable_const_mul h), map_mul_left_eq_self μ g, map_mul_left_eq_self ν h] @[to_additive] instance Measure.prod.instIsMulRightInvariant [IsMulRightInvariant μ] [SFinite μ] {H : Type*} [Mul H] {mH : MeasurableSpace H} {ν : Measure H} [MeasurableMul H] [IsMulRightInvariant ν] [SFinite ν] : IsMulRightInvariant (μ.prod ν) := by constructor rintro ⟨g, h⟩ change map (Prod.map (· * g) (· * h)) (μ.prod ν) = μ.prod ν rw [← map_prod_map _ _ (measurable_mul_const g) (measurable_mul_const h), map_mul_right_eq_self μ g, map_mul_right_eq_self ν h] @[to_additive] theorem isMulLeftInvariant_map {H : Type*} [MeasurableSpace H] [Mul H] [MeasurableMul H] [IsMulLeftInvariant μ] (f : G →ₙ* H) (hf : Measurable f) (h_surj : Surjective f) : IsMulLeftInvariant (Measure.map f μ) := by refine ⟨fun h => ?_⟩ rw [map_map (measurable_const_mul _) hf] obtain ⟨g, rfl⟩ := h_surj h conv_rhs => rw [← map_mul_left_eq_self μ g] rw [map_map hf (measurable_const_mul _)] congr 2 ext y simp only [comp_apply, map_mul] end MeasurableMul end Mul section Semigroup variable [Semigroup G] [MeasurableMul G] {μ : Measure G} /-- The image of a left invariant measure under a left action is left invariant, assuming that the action preserves multiplication. -/ @[to_additive /-- The image of a left invariant measure under a left additive action is left invariant, assuming that the action preserves addition. -/] theorem isMulLeftInvariant_map_smul {α} [SMul α G] [SMulCommClass α G G] [MeasurableSpace α] [MeasurableSMul α G] [IsMulLeftInvariant μ] (a : α) : IsMulLeftInvariant (map (a • · : G → G) μ) := (forall_measure_preimage_mul_iff _).1 fun x _ hs => (smulInvariantMeasure_map_smul μ a).measure_preimage_smul x hs /-- The image of a right invariant measure under a left action is right invariant, assuming that the action preserves multiplication. -/ @[to_additive /-- The image of a right invariant measure under a left additive action is right invariant, assuming that the action preserves addition. -/] theorem isMulRightInvariant_map_smul {α} [SMul α G] [SMulCommClass α Gᵐᵒᵖ G] [MeasurableSpace α] [MeasurableSMul α G] [IsMulRightInvariant μ] (a : α) : IsMulRightInvariant (map (a • · : G → G) μ) := (forall_measure_preimage_mul_right_iff _).1 fun x _ hs => (smulInvariantMeasure_map_smul μ a).measure_preimage_smul (MulOpposite.op x) hs /-- The image of a left invariant measure under right multiplication is left invariant. -/ @[to_additive isMulLeftInvariant_map_add_right /-- The image of a left invariant measure under right addition is left invariant. -/] instance isMulLeftInvariant_map_mul_right [IsMulLeftInvariant μ] (g : G) : IsMulLeftInvariant (map (· * g) μ) := isMulLeftInvariant_map_smul (MulOpposite.op g) /-- The image of a right invariant measure under left multiplication is right invariant. -/ @[to_additive isMulRightInvariant_map_add_left /-- The image of a right invariant measure under left addition is right invariant. -/] instance isMulRightInvariant_map_mul_left [IsMulRightInvariant μ] (g : G) : IsMulRightInvariant (map (g * ·) μ) := isMulRightInvariant_map_smul g end Semigroup section DivInvMonoid variable [DivInvMonoid G] @[to_additive] theorem map_div_right_eq_self (μ : Measure G) [IsMulRightInvariant μ] (g : G) : map (· / g) μ = μ := by simp_rw [div_eq_mul_inv, map_mul_right_eq_self μ g⁻¹] end DivInvMonoid section Group variable [Group G] [MeasurableMul G] @[to_additive] theorem measurePreserving_div_right (μ : Measure G) [IsMulRightInvariant μ] (g : G) : MeasurePreserving (· / g) μ μ := by simp_rw [div_eq_mul_inv, measurePreserving_mul_right μ g⁻¹] /-- We shorten this from `measure_preimage_mul_left`, since left invariant is the preferred option for measures in this formalization. -/ @[to_additive (attr := simp) /-- We shorten this from `measure_preimage_add_left`, since left invariant is the preferred option for measures in this formalization. -/] theorem measure_preimage_mul (μ : Measure G) [IsMulLeftInvariant μ] (g : G) (A : Set G) : μ ((fun h => g * h) ⁻¹' A) = μ A := calc μ ((fun h => g * h) ⁻¹' A) = map (fun h => g * h) μ A := ((MeasurableEquiv.mulLeft g).map_apply A).symm _ = μ A := by rw [map_mul_left_eq_self μ g] @[to_additive (attr := simp)] theorem measure_preimage_mul_right (μ : Measure G) [IsMulRightInvariant μ] (g : G) (A : Set G) : μ ((fun h => h * g) ⁻¹' A) = μ A := calc μ ((fun h => h * g) ⁻¹' A) = map (fun h => h * g) μ A := ((MeasurableEquiv.mulRight g).map_apply A).symm _ = μ A := by rw [map_mul_right_eq_self μ g] @[to_additive] theorem map_mul_left_ae (μ : Measure G) [IsMulLeftInvariant μ] (x : G) : Filter.map (fun h => x * h) (ae μ) = ae μ := ((MeasurableEquiv.mulLeft x).map_ae μ).trans <| congr_arg ae <| map_mul_left_eq_self μ x @[to_additive] theorem map_mul_right_ae (μ : Measure G) [IsMulRightInvariant μ] (x : G) : Filter.map (fun h => h * x) (ae μ) = ae μ := ((MeasurableEquiv.mulRight x).map_ae μ).trans <| congr_arg ae <| map_mul_right_eq_self μ x @[to_additive] theorem map_div_right_ae (μ : Measure G) [IsMulRightInvariant μ] (x : G) : Filter.map (fun t => t / x) (ae μ) = ae μ := ((MeasurableEquiv.divRight x).map_ae μ).trans <| congr_arg ae <| map_div_right_eq_self μ x @[to_additive] theorem eventually_mul_left_iff (μ : Measure G) [IsMulLeftInvariant μ] (t : G) {p : G → Prop} : (∀ᵐ x ∂μ, p (t * x)) ↔ ∀ᵐ x ∂μ, p x := by conv_rhs => rw [Filter.Eventually, ← map_mul_left_ae μ t] rfl @[to_additive] theorem eventually_mul_right_iff (μ : Measure G) [IsMulRightInvariant μ] (t : G) {p : G → Prop} : (∀ᵐ x ∂μ, p (x * t)) ↔ ∀ᵐ x ∂μ, p x := by conv_rhs => rw [Filter.Eventually, ← map_mul_right_ae μ t] rfl @[to_additive] theorem eventually_div_right_iff (μ : Measure G) [IsMulRightInvariant μ] (t : G) {p : G → Prop} : (∀ᵐ x ∂μ, p (x / t)) ↔ ∀ᵐ x ∂μ, p x := by conv_rhs => rw [Filter.Eventually, ← map_div_right_ae μ t] rfl @[to_additive AddSubgroup.index_mul_measure] lemma Subgroup.index_mul_measure (H : Subgroup G) [H.FiniteIndex] (hH : MeasurableSet (H : Set G)) (μ : Measure G) [IsMulLeftInvariant μ] : H.index * μ H = μ univ := by obtain ⟨s, hs, -⟩ := H.exists_isComplement_left 1 have hs' : Finite s := hs.finite_left_iff.mpr inferInstance calc H.index * μ H = ∑' a : s, μ (a.val • H) := by simp [measure_smul, hs.encard_left] _ = μ univ := by rw [← measure_iUnion _ fun _ ↦ hH.const_smul _] · simp [hs.mul_eq] · exact fun a b hab ↦ hs.pairwiseDisjoint_smul a.2 b.2 (Subtype.val_injective.ne hab) end Group namespace Measure -- TODO: noncomputable has to be specified explicitly. https://github.com/leanprover-community/mathlib4/issues/1074 (item 8) /-- The measure `A ↦ μ (A⁻¹)`, where `A⁻¹` is the pointwise inverse of `A`. -/ @[to_additive /-- The measure `A ↦ μ (- A)`, where `- A` is the pointwise negation of `A`. -/] protected noncomputable def inv [Inv G] (μ : Measure G) : Measure G := Measure.map inv μ /-- A measure is invariant under negation if `- μ = μ`. Equivalently, this means that for all measurable `A` we have `μ (- A) = μ A`, where `- A` is the pointwise negation of `A`. -/ class IsNegInvariant [Neg G] (μ : Measure G) : Prop where neg_eq_self : μ.neg = μ /-- A measure is invariant under inversion if `μ⁻¹ = μ`. Equivalently, this means that for all measurable `A` we have `μ (A⁻¹) = μ A`, where `A⁻¹` is the pointwise inverse of `A`. -/ @[to_additive existing] class IsInvInvariant [Inv G] (μ : Measure G) : Prop where inv_eq_self : μ.inv = μ section Inv variable [Inv G] @[to_additive] theorem inv_def (μ : Measure G) : μ.inv = Measure.map inv μ := rfl @[to_additive (attr := simp)] theorem inv_eq_self (μ : Measure G) [IsInvInvariant μ] : μ.inv = μ := IsInvInvariant.inv_eq_self @[to_additive (attr := simp)] theorem map_inv_eq_self (μ : Measure G) [IsInvInvariant μ] : map Inv.inv μ = μ := IsInvInvariant.inv_eq_self variable [MeasurableInv G] @[to_additive] theorem measurePreserving_inv (μ : Measure G) [IsInvInvariant μ] : MeasurePreserving Inv.inv μ μ := ⟨measurable_inv, map_inv_eq_self μ⟩ @[to_additive] instance inv.instSFinite (μ : Measure G) [SFinite μ] : SFinite μ.inv := by rw [Measure.inv]; infer_instance end Inv section InvolutiveInv variable [InvolutiveInv G] [MeasurableInv G] @[to_additive (attr := simp)] theorem inv_apply (μ : Measure G) (s : Set G) : μ.inv s = μ s⁻¹ := (MeasurableEquiv.inv G).map_apply s @[to_additive (attr := simp)] protected theorem inv_inv (μ : Measure G) : μ.inv.inv = μ := (MeasurableEquiv.inv G).map_symm_map @[to_additive (attr := simp)] theorem measure_inv (μ : Measure G) [IsInvInvariant μ] (A : Set G) : μ A⁻¹ = μ A := by rw [← inv_apply, inv_eq_self] @[to_additive] theorem measure_preimage_inv (μ : Measure G) [IsInvInvariant μ] (A : Set G) : μ (Inv.inv ⁻¹' A) = μ A := μ.measure_inv A @[to_additive] instance inv.instSigmaFinite (μ : Measure G) [SigmaFinite μ] : SigmaFinite μ.inv := (MeasurableEquiv.inv G).sigmaFinite_map end InvolutiveInv section DivisionMonoid variable [DivisionMonoid G] [MeasurableMul G] [MeasurableInv G] {μ : Measure G} @[to_additive] instance inv.instIsMulRightInvariant [IsMulLeftInvariant μ] : IsMulRightInvariant μ.inv := by constructor intro g conv_rhs => rw [← map_mul_left_eq_self μ g⁻¹] simp_rw [Measure.inv, map_map (measurable_mul_const g) measurable_inv, map_map measurable_inv (measurable_const_mul g⁻¹), Function.comp_def, mul_inv_rev, inv_inv] @[to_additive] instance inv.instIsMulLeftInvariant [IsMulRightInvariant μ] : IsMulLeftInvariant μ.inv := by constructor intro g conv_rhs => rw [← map_mul_right_eq_self μ g⁻¹] simp_rw [Measure.inv, map_map (measurable_const_mul g) measurable_inv, map_map measurable_inv (measurable_mul_const g⁻¹), Function.comp_def, mul_inv_rev, inv_inv] @[to_additive] theorem measurePreserving_div_left (μ : Measure G) [IsInvInvariant μ] [IsMulLeftInvariant μ] (g : G) : MeasurePreserving (fun t => g / t) μ μ := by simp_rw [div_eq_mul_inv] exact (measurePreserving_mul_left μ g).comp (measurePreserving_inv μ) @[to_additive] theorem map_div_left_eq_self (μ : Measure G) [IsInvInvariant μ] [IsMulLeftInvariant μ] (g : G) : map (fun t => g / t) μ = μ := (measurePreserving_div_left μ g).map_eq @[to_additive] theorem measurePreserving_mul_right_inv (μ : Measure G) [IsInvInvariant μ] [IsMulLeftInvariant μ] (g : G) : MeasurePreserving (fun t => (g * t)⁻¹) μ μ := (measurePreserving_inv μ).comp <| measurePreserving_mul_left μ g @[to_additive] theorem map_mul_right_inv_eq_self (μ : Measure G) [IsInvInvariant μ] [IsMulLeftInvariant μ] (g : G) : map (fun t => (g * t)⁻¹) μ = μ := (measurePreserving_mul_right_inv μ g).map_eq end DivisionMonoid section Group variable [Group G] {μ : Measure G} section MeasurableMul variable [MeasurableMul G] @[to_additive] instance : (count : Measure G).IsMulLeftInvariant where map_mul_left_eq_self g := by ext s hs rw [count_apply hs, map_apply (measurable_const_mul _) hs, count_apply (measurable_const_mul _ hs), encard_preimage_of_bijective (Group.mulLeft_bijective _)] @[to_additive] instance : (count : Measure G).IsMulRightInvariant where map_mul_right_eq_self g := by ext s hs rw [count_apply hs, map_apply (measurable_mul_const _) hs, count_apply (measurable_mul_const _ hs), encard_preimage_of_bijective (Group.mulRight_bijective _)] /- TODO: To avoid repeating the proofs, the following two lemmas should be consequences of a similar result about `SMulInvariantMeasure`. -/ @[to_additive] protected theorem IsMulLeftInvariant.comap {H} [Group H] {mH : MeasurableSpace H} [MeasurableMul H] (μ : Measure H) [IsMulLeftInvariant μ] {f : G →* H} (hf : MeasurableEmbedding f) : (μ.comap f).IsMulLeftInvariant where map_mul_left_eq_self g := by ext s hs rw [map_apply (by fun_prop) hs] repeat rw [hf.comap_apply] have : f '' ((g * ·) ⁻¹' s) = (f g * ·) ⁻¹' (f '' s) := by ext constructor · rintro ⟨y, hy, rfl⟩ exact ⟨g * y, hy, by simp⟩ · intro ⟨y, yins, hy⟩ exact ⟨g⁻¹ * y, by simp [yins], by simp [hy]⟩ rw [this, ← map_apply (by fun_prop), IsMulLeftInvariant.map_mul_left_eq_self] exact hf.measurableSet_image.mpr hs @[to_additive] protected theorem IsMulRightInvariant.comap {H} [Group H] {mH : MeasurableSpace H} [MeasurableMul H] (μ : Measure H) [IsMulRightInvariant μ] {f : G →* H} (hf : MeasurableEmbedding f) : (μ.comap f).IsMulRightInvariant where map_mul_right_eq_self g := by ext s hs rw [map_apply (by fun_prop) hs] repeat rw [hf.comap_apply] have : f '' ((· * g) ⁻¹' s) = (· * f g) ⁻¹' (f '' s) := by ext constructor · rintro ⟨y, hy, rfl⟩ exact ⟨y * g, hy, by simp⟩ · intro ⟨y, yins, hy⟩ exact ⟨y * g⁻¹, by simp [yins], by simp [hy]⟩ rw [this, ← map_apply (by fun_prop), IsMulRightInvariant.map_mul_right_eq_self] exact hf.measurableSet_image.mpr hs end MeasurableMul variable [MeasurableInv G] @[to_additive] instance : (count : Measure G).IsInvInvariant where inv_eq_self := by ext s hs; rw [count_apply hs, inv_apply, count_apply hs.inv, encard_inv] variable [MeasurableMul G] @[to_additive] theorem map_div_left_ae (μ : Measure G) [IsMulLeftInvariant μ] [IsInvInvariant μ] (x : G) : Filter.map (fun t => x / t) (ae μ) = ae μ := ((MeasurableEquiv.divLeft x).map_ae μ).trans <| congr_arg ae <| map_div_left_eq_self μ x end Group end Measure section IsTopologicalGroup variable [TopologicalSpace G] [BorelSpace G] {μ : Measure G} [Group G] @[to_additive] instance Measure.IsFiniteMeasureOnCompacts.inv [ContinuousInv G] [IsFiniteMeasureOnCompacts μ] : IsFiniteMeasureOnCompacts μ.inv := IsFiniteMeasureOnCompacts.map μ (Homeomorph.inv G) @[to_additive] instance Measure.IsOpenPosMeasure.inv [ContinuousInv G] [IsOpenPosMeasure μ] : IsOpenPosMeasure μ.inv := (Homeomorph.inv G).continuous.isOpenPosMeasure_map (Homeomorph.inv G).surjective @[to_additive] instance Measure.Regular.inv [ContinuousInv G] [Regular μ] : Regular μ.inv := Regular.map (Homeomorph.inv G) @[to_additive] instance Measure.InnerRegular.inv [ContinuousInv G] [InnerRegular μ] : InnerRegular μ.inv := InnerRegular.map (Homeomorph.inv G) /-- The image of an inner regular measure under map of a left action is again inner regular. -/ @[to_additive /-- The image of a inner regular measure under map of a left additive action is again inner regular -/] instance innerRegular_map_smul {α} [Monoid α] [MulAction α G] [ContinuousConstSMul α G] [InnerRegular μ] (a : α) : InnerRegular (Measure.map (a • · : G → G) μ) := InnerRegular.map_of_continuous (continuous_const_smul a) /-- The image of an inner regular measure under left multiplication is again inner regular. -/ @[to_additive /-- The image of an inner regular measure under left addition is again inner regular. -/] instance innerRegular_map_mul_left [IsTopologicalGroup G] [InnerRegular μ] (g : G) : InnerRegular (Measure.map (g * ·) μ) := InnerRegular.map_of_continuous (continuous_mul_left g) /-- The image of an inner regular measure under right multiplication is again inner regular. -/ @[to_additive /-- The image of an inner regular measure under right addition is again inner regular. -/] instance innerRegular_map_mul_right [IsTopologicalGroup G] [InnerRegular μ] (g : G) : InnerRegular (Measure.map (· * g) μ) := InnerRegular.map_of_continuous (continuous_mul_right g) variable [IsTopologicalGroup G] @[to_additive] theorem regular_inv_iff : μ.inv.Regular ↔ μ.Regular := Regular.map_iff (Homeomorph.inv G) @[to_additive] theorem innerRegular_inv_iff : μ.inv.InnerRegular ↔ μ.InnerRegular := InnerRegular.map_iff (Homeomorph.inv G) /-- Continuity of the measure of translates of a compact set: Given a compact set `k` in a topological group, for `g` close enough to the origin, `μ (g • k \ k)` is arbitrarily small. -/ @[to_additive] lemma eventually_nhds_one_measure_smul_diff_lt [LocallyCompactSpace G] [IsFiniteMeasureOnCompacts μ] [InnerRegularCompactLTTop μ] {k : Set G} (hk : IsCompact k) (h'k : IsClosed k) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∀ᶠ g in 𝓝 (1 : G), μ (g • k \ k) < ε := by obtain ⟨U, hUk, hU, hμUk⟩ : ∃ (U : Set G), k ⊆ U ∧ IsOpen U ∧ μ U < μ k + ε := hk.exists_isOpen_lt_add hε obtain ⟨V, hV1, hVkU⟩ : ∃ V ∈ 𝓝 (1 : G), V * k ⊆ U := compact_open_separated_mul_left hk hU hUk filter_upwards [hV1] with g hg calc μ (g • k \ k) ≤ μ (U \ k) := by gcongr exact (smul_set_subset_smul hg).trans hVkU _ < ε := measure_diff_lt_of_lt_add h'k.nullMeasurableSet hUk hk.measure_lt_top.ne hμUk /-- Continuity of the measure of translates of a compact set: Given a closed compact set `k` in a topological group, the measure of `g • k \ k` tends to zero as `g` tends to `1`. -/ @[to_additive] lemma tendsto_measure_smul_diff_isCompact_isClosed [LocallyCompactSpace G] [IsFiniteMeasureOnCompacts μ] [InnerRegularCompactLTTop μ] {k : Set G} (hk : IsCompact k) (h'k : IsClosed k) : Tendsto (fun g : G ↦ μ (g • k \ k)) (𝓝 1) (𝓝 0) := ENNReal.nhds_zero_basis.tendsto_right_iff.mpr <| fun _ h ↦ eventually_nhds_one_measure_smul_diff_lt hk h'k h.ne' section IsMulLeftInvariant variable [IsMulLeftInvariant μ] /-- If a left-invariant measure gives positive mass to a compact set, then it gives positive mass to any open set. -/ @[to_additive /-- If a left-invariant measure gives positive mass to a compact set, then it gives positive mass to any open set. -/] theorem isOpenPosMeasure_of_mulLeftInvariant_of_compact (K : Set G) (hK : IsCompact K) (h : μ K ≠ 0) : IsOpenPosMeasure μ := by refine ⟨fun U hU hne => ?_⟩ contrapose! h rw [← nonpos_iff_eq_zero] rw [← hU.interior_eq] at hne obtain ⟨t, hKt⟩ : ∃ t : Finset G, K ⊆ ⋃ (g : G) (_ : g ∈ t), (fun h : G => g * h) ⁻¹' U := compact_covered_by_mul_left_translates hK hne calc μ K ≤ μ (⋃ (g : G) (_ : g ∈ t), (fun h : G => g * h) ⁻¹' U) := measure_mono hKt _ ≤ ∑ g ∈ t, μ ((fun h : G => g * h) ⁻¹' U) := measure_biUnion_finset_le _ _ _ = 0 := by simp [measure_preimage_mul, h] /-- A nonzero left-invariant regular measure gives positive mass to any open set. -/ @[to_additive /-- A nonzero left-invariant regular measure gives positive mass to any open set. -/] instance (priority := 80) isOpenPosMeasure_of_mulLeftInvariant_of_regular [Regular μ] [NeZero μ] : IsOpenPosMeasure μ := let ⟨K, hK, h2K⟩ := Regular.exists_isCompact_not_null.mpr (NeZero.ne μ) isOpenPosMeasure_of_mulLeftInvariant_of_compact K hK h2K /-- A nonzero left-invariant inner regular measure gives positive mass to any open set. -/ @[to_additive /-- A nonzero left-invariant inner regular measure gives positive mass to any open set. -/] instance (priority := 80) isOpenPosMeasure_of_mulLeftInvariant_of_innerRegular [InnerRegular μ] [NeZero μ] : IsOpenPosMeasure μ := let ⟨K, hK, h2K⟩ := InnerRegular.exists_isCompact_not_null.mpr (NeZero.ne μ) isOpenPosMeasure_of_mulLeftInvariant_of_compact K hK h2K @[to_additive] theorem null_iff_of_isMulLeftInvariant [Regular μ] {s : Set G} (hs : IsOpen s) : μ s = 0 ↔ s = ∅ ∨ μ = 0 := by rcases eq_zero_or_neZero μ with rfl | hμ · simp · simp only [or_false, hs.measure_eq_zero_iff μ, NeZero.ne μ] @[to_additive] theorem measure_ne_zero_iff_nonempty_of_isMulLeftInvariant [Regular μ] (hμ : μ ≠ 0) {s : Set G} (hs : IsOpen s) : μ s ≠ 0 ↔ s.Nonempty := by simpa [null_iff_of_isMulLeftInvariant (μ := μ) hs, hμ] using nonempty_iff_ne_empty.symm @[to_additive] theorem measure_pos_iff_nonempty_of_isMulLeftInvariant [Regular μ] (h3μ : μ ≠ 0) {s : Set G} (hs : IsOpen s) : 0 < μ s ↔ s.Nonempty := pos_iff_ne_zero.trans <| measure_ne_zero_iff_nonempty_of_isMulLeftInvariant h3μ hs /-- If a left-invariant measure gives finite mass to a nonempty open set, then it gives finite mass to any compact set. -/ @[to_additive /-- If a left-invariant measure gives finite mass to a nonempty open set, then it gives finite mass to any compact set. -/] theorem measure_lt_top_of_isCompact_of_isMulLeftInvariant (U : Set G) (hU : IsOpen U) (h'U : U.Nonempty) (h : μ U ≠ ∞) {K : Set G} (hK : IsCompact K) : μ K < ∞ := by rw [← hU.interior_eq] at h'U obtain ⟨t, hKt⟩ : ∃ t : Finset G, K ⊆ ⋃ g ∈ t, (fun h : G => g * h) ⁻¹' U := compact_covered_by_mul_left_translates hK h'U exact (measure_mono hKt).trans_lt <| measure_biUnion_lt_top t.finite_toSet <| by simp [h.lt_top] /-- If a left-invariant measure gives finite mass to a set with nonempty interior, then it gives finite mass to any compact set. -/ @[to_additive /-- If a left-invariant measure gives finite mass to a set with nonempty interior, then it gives finite mass to any compact set. -/] theorem measure_lt_top_of_isCompact_of_isMulLeftInvariant' {U : Set G} (hU : (interior U).Nonempty) (h : μ U ≠ ∞) {K : Set G} (hK : IsCompact K) : μ K < ∞ := measure_lt_top_of_isCompact_of_isMulLeftInvariant (interior U) isOpen_interior hU ((measure_mono interior_subset).trans_lt (lt_top_iff_ne_top.2 h)).ne hK /-- In a noncompact locally compact group, a left-invariant measure which is positive on open sets has infinite mass. -/ @[to_additive (attr := simp) /-- In a noncompact locally compact additive group, a left-invariant measure which is positive on open sets has infinite mass. -/] theorem measure_univ_of_isMulLeftInvariant [WeaklyLocallyCompactSpace G] [NoncompactSpace G] (μ : Measure G) [IsOpenPosMeasure μ] [μ.IsMulLeftInvariant] : μ univ = ∞ := by /- Consider a closed compact set `K` with nonempty interior. For any compact set `L`, one may find `g = g (L)` such that `L` is disjoint from `g • K`. Iterating this, one finds infinitely many translates of `K` which are disjoint from each other. As they all have the same positive mass, it follows that the space has infinite measure. -/ obtain ⟨K, K1, hK, Kclosed⟩ : ∃ K ∈ 𝓝 (1 : G), IsCompact K ∧ IsClosed K := exists_mem_nhds_isCompact_isClosed 1 have K_pos : 0 < μ K := measure_pos_of_mem_nhds μ K1 have A : ∀ L : Set G, IsCompact L → ∃ g : G, Disjoint L (g • K) := fun L hL => exists_disjoint_smul_of_isCompact hL hK choose! g hg using A set L : ℕ → Set G := fun n => (fun T => T ∪ g T • K)^[n] K have Lcompact : ∀ n, IsCompact (L n) := fun n ↦ by induction n with | zero => exact hK | succ n IH => simp_rw [L, iterate_succ'] apply IsCompact.union IH (hK.smul (g (L n))) have Lclosed : ∀ n, IsClosed (L n) := fun n ↦ by induction n with | zero => exact Kclosed | succ n IH => simp_rw [L, iterate_succ'] apply IsClosed.union IH (Kclosed.smul (g (L n))) have M : ∀ n, μ (L n) = (n + 1 : ℕ) * μ K := fun n ↦ by induction n with | zero => simp only [L, one_mul, Nat.cast_one, iterate_zero, id, Nat.zero_add] | succ n IH => calc μ (L (n + 1)) = μ (L n) + μ (g (L n) • K) := by simp_rw [L, iterate_succ'] exact measure_union' (hg _ (Lcompact _)) (Lclosed _).measurableSet _ = (n + 1 + 1 : ℕ) * μ K := by simp only [IH, measure_smul, add_mul, Nat.cast_add, Nat.cast_one, one_mul] have N : Tendsto (fun n => μ (L n)) atTop (𝓝 (∞ * μ K)) := by simp_rw [M] apply ENNReal.Tendsto.mul_const _ (Or.inl ENNReal.top_ne_zero) exact ENNReal.tendsto_nat_nhds_top.comp (tendsto_add_atTop_nat _) simp only [ENNReal.top_mul', K_pos.ne', if_false] at N apply top_le_iff.1 exact le_of_tendsto' N fun n => measure_mono (subset_univ _) @[to_additive] lemma _root_.MeasurableSet.mul_closure_one_eq {s : Set G} (hs : MeasurableSet s) : s * (closure {1} : Set G) = s := by induction s, hs using MeasurableSet.induction_on_open with | isOpen U hU => exact hU.mul_closure_one_eq | compl t _ iht => exact compl_mul_closure_one_eq_iff.2 iht | iUnion f _ _ ihf => simp_rw [iUnion_mul f, ihf] @[to_additive (attr := simp)] lemma measure_mul_closure_one (s : Set G) (μ : Measure G) : μ (s * (closure {1} : Set G)) = μ s := by apply le_antisymm ?_ (measure_mono (subset_mul_closure_one s)) conv_rhs => rw [measure_eq_iInf] simp only [le_iInf_iff] intro t kt t_meas apply measure_mono rw [← t_meas.mul_closure_one_eq] exact smul_subset_smul_right kt end IsMulLeftInvariant @[to_additive] lemma innerRegularWRT_isCompact_isClosed_measure_ne_top_of_group [h : InnerRegularCompactLTTop μ] : InnerRegularWRT μ (fun s ↦ IsCompact s ∧ IsClosed s) (fun s ↦ MeasurableSet s ∧ μ s ≠ ∞) := by intro s ⟨s_meas, μs⟩ r hr rcases h.innerRegular ⟨s_meas, μs⟩ r hr with ⟨K, Ks, K_comp, hK⟩ refine ⟨closure K, ?_, ⟨K_comp.closure, isClosed_closure⟩, ?_⟩ · exact IsCompact.closure_subset_measurableSet K_comp s_meas Ks · rwa [K_comp.measure_closure] end IsTopologicalGroup section CommSemigroup variable [CommSemigroup G] /-- In an abelian group every left invariant measure is also right-invariant. We don't declare the converse as an instance, since that would loop type-class inference, and we use `IsMulLeftInvariant` as the default hypothesis in abelian groups. -/ @[to_additive IsAddLeftInvariant.isAddRightInvariant /-- In an abelian additive group every left invariant measure is also right-invariant. We don't declare the converse as an instance, since that would loop type-class inference, and we use `IsAddLeftInvariant` as the default hypothesis in abelian groups. -/] instance (priority := 100) IsMulLeftInvariant.isMulRightInvariant {μ : Measure G} [IsMulLeftInvariant μ] : IsMulRightInvariant μ := ⟨fun g => by simp_rw [mul_comm, map_mul_left_eq_self]⟩ end CommSemigroup section Haar namespace Measure /-- A measure on an additive group is an additive Haar measure if it is left-invariant, and gives finite mass to compact sets and positive mass to open sets. Textbooks generally require an additional regularity assumption to ensure nice behavior on arbitrary locally compact groups. Use `[IsAddHaarMeasure μ] [Regular μ]` or `[IsAddHaarMeasure μ] [InnerRegular μ]` in these situations. Note that a Haar measure in our sense is automatically regular and inner regular on second countable locally compact groups, as checked just below this definition. -/ class IsAddHaarMeasure {G : Type*} [AddGroup G] [TopologicalSpace G] [MeasurableSpace G] (μ : Measure G) : Prop extends IsFiniteMeasureOnCompacts μ, IsAddLeftInvariant μ, IsOpenPosMeasure μ /-- A measure on a group is a Haar measure if it is left-invariant, and gives finite mass to compact sets and positive mass to open sets. Textbooks generally require an additional regularity assumption to ensure nice behavior on arbitrary locally compact groups. Use `[IsHaarMeasure μ] [Regular μ]` or `[IsHaarMeasure μ] [InnerRegular μ]` in these situations. Note that a Haar measure in our sense is automatically regular and inner regular on second countable locally compact groups, as checked just below this definition. -/ @[to_additive existing] class IsHaarMeasure {G : Type*} [Group G] [TopologicalSpace G] [MeasurableSpace G] (μ : Measure G) : Prop extends IsFiniteMeasureOnCompacts μ, IsMulLeftInvariant μ, IsOpenPosMeasure μ variable [Group G] [TopologicalSpace G] (μ : Measure G) [IsHaarMeasure μ] @[to_additive (attr := simp)] theorem haar_singleton [ContinuousMul G] [BorelSpace G] (g : G) : μ {g} = μ {(1 : G)} := by convert measure_preimage_mul μ g⁻¹ _ simp only [mul_one, preimage_mul_left_singleton, inv_inv] @[to_additive IsAddHaarMeasure.smul] theorem IsHaarMeasure.smul {c : ℝ≥0∞} (cpos : c ≠ 0) (ctop : c ≠ ∞) : IsHaarMeasure (c • μ) := { lt_top_of_isCompact := fun _K hK => ENNReal.mul_lt_top ctop.lt_top hK.measure_lt_top toIsOpenPosMeasure := isOpenPosMeasure_smul μ cpos } @[to_additive IsAddHaarMeasure.nnreal_smul] lemma IsHaarMeasure.nnreal_smul {c : ℝ≥0} (hc : c ≠ 0) : IsHaarMeasure (c • μ) := .smul _ (by simp [hc]) (Option.some_ne_none _) /-- If a left-invariant measure gives positive mass to some compact set with nonempty interior, then it is a Haar measure. -/ @[to_additive /-- If a left-invariant measure gives positive mass to some compact set with nonempty interior, then it is an additive Haar measure. -/] theorem isHaarMeasure_of_isCompact_nonempty_interior [IsTopologicalGroup G] [BorelSpace G] (μ : Measure G) [IsMulLeftInvariant μ] (K : Set G) (hK : IsCompact K) (h'K : (interior K).Nonempty) (h : μ K ≠ 0) (h' : μ K ≠ ∞) : IsHaarMeasure μ := { lt_top_of_isCompact := fun _L hL => measure_lt_top_of_isCompact_of_isMulLeftInvariant' h'K h' hL toIsOpenPosMeasure := isOpenPosMeasure_of_mulLeftInvariant_of_compact K hK h } /-- The image of a Haar measure under a continuous surjective proper group homomorphism is again a Haar measure. See also `MulEquiv.isHaarMeasure_map` and `ContinuousMulEquiv.isHaarMeasure_map`. -/ @[to_additive /-- The image of an additive Haar measure under a continuous surjective proper additive group homomorphism is again an additive Haar measure. See also `AddEquiv.isAddHaarMeasure_map`, `ContinuousAddEquiv.isAddHaarMeasure_map` and `ContinuousLinearEquiv.isAddHaarMeasure_map`. -/] theorem isHaarMeasure_map [BorelSpace G] [ContinuousMul G] {H : Type*} [Group H] [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [IsTopologicalGroup H] (f : G →* H) (hf : Continuous f) (h_surj : Surjective f) (h_prop : Tendsto f (cocompact G) (cocompact H)) : IsHaarMeasure (Measure.map f μ) := { toIsMulLeftInvariant := isMulLeftInvariant_map f.toMulHom hf.measurable h_surj lt_top_of_isCompact := by intro K hK rw [← hK.measure_closure, map_apply hf.measurable isClosed_closure.measurableSet] set g : CocompactMap G H := ⟨⟨f, hf⟩, h_prop⟩ exact IsCompact.measure_lt_top (g.isCompact_preimage_of_isClosed hK.closure isClosed_closure) toIsOpenPosMeasure := hf.isOpenPosMeasure_map h_surj } protected theorem IsHaarMeasure.comap [BorelSpace G] [MeasurableMul G] [Group H] [TopologicalSpace H] [BorelSpace H] {mH : MeasurableMul H} (μ : Measure H) [IsHaarMeasure μ] {f : G →* H} (hf : Topology.IsOpenEmbedding f) : (μ.comap f).IsHaarMeasure where map_mul_left_eq_self := (IsMulLeftInvariant.comap μ hf.measurableEmbedding).map_mul_left_eq_self lt_top_of_isCompact := (IsFiniteMeasureOnCompacts.comap' μ hf.continuous hf.measurableEmbedding).lt_top_of_isCompact open_pos := (IsOpenPosMeasure.comap μ hf).open_pos /-- The image of a finite Haar measure under a continuous surjective group homomorphism is again a Haar measure. See also `isHaarMeasure_map`. -/ @[to_additive /-- The image of a finite additive Haar measure under a continuous surjective additive group homomorphism is again an additive Haar measure. See also `isAddHaarMeasure_map`. -/] theorem isHaarMeasure_map_of_isFiniteMeasure [BorelSpace G] [ContinuousMul G] {H : Type*} [Group H] [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [ContinuousMul H] [IsFiniteMeasure μ] (f : G →* H) (hf : Continuous f) (h_surj : Surjective f) : IsHaarMeasure (Measure.map f μ) where toIsMulLeftInvariant := isMulLeftInvariant_map f.toMulHom hf.measurable h_surj toIsOpenPosMeasure := hf.isOpenPosMeasure_map h_surj /-- The image of a Haar measure under map of a left action is again a Haar measure. -/ @[to_additive /-- The image of a Haar measure under map of a left additive action is again a Haar measure -/] instance isHaarMeasure_map_smul {α} [BorelSpace G] [IsTopologicalGroup G] [Group α] [MulAction α G] [SMulCommClass α G G] [MeasurableSpace α] [MeasurableSMul α G] [ContinuousConstSMul α G] (a : α) : IsHaarMeasure (Measure.map (a • · : G → G) μ) where toIsMulLeftInvariant := isMulLeftInvariant_map_smul _ lt_top_of_isCompact K hK := by let F := (Homeomorph.smul a (α := G)).toMeasurableEquiv change map F μ K < ∞ rw [F.map_apply K] exact IsCompact.measure_lt_top <| (Homeomorph.isCompact_preimage (Homeomorph.smul a)).2 hK toIsOpenPosMeasure := (continuous_const_smul a).isOpenPosMeasure_map (MulAction.surjective a) /-- The image of a Haar measure under right multiplication is again a Haar measure. -/ @[to_additive isHaarMeasure_map_add_right /-- The image of a Haar measure under right addition is again a Haar measure. -/] instance isHaarMeasure_map_mul_right [BorelSpace G] [IsTopologicalGroup G] (g : G) : IsHaarMeasure (Measure.map (· * g) μ) := isHaarMeasure_map_smul μ (MulOpposite.op g) /-- A convenience wrapper for `MeasureTheory.Measure.isHaarMeasure_map`. -/ @[to_additive /-- A convenience wrapper for `MeasureTheory.Measure.isAddHaarMeasure_map`. -/] nonrec theorem _root_.MulEquiv.isHaarMeasure_map [BorelSpace G] [ContinuousMul G] {H : Type*} [Group H] [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [IsTopologicalGroup H] (e : G ≃* H) (he : Continuous e) (hesymm : Continuous e.symm) : IsHaarMeasure (Measure.map e μ) := let f : G ≃ₜ H := .mk e he hesymm -- We need to write `e.toMonoidHom` instead of just `e`, to avoid unification issues. isHaarMeasure_map μ e.toMonoidHom he e.surjective f.isClosedEmbedding.tendsto_cocompact /-- A convenience wrapper for MeasureTheory.Measure.isHaarMeasure_map. -/ @[to_additive /-- A convenience wrapper for MeasureTheory.Measure.isAddHaarMeasure_map. -/] instance _root_.ContinuousMulEquiv.isHaarMeasure_map [BorelSpace G] [IsTopologicalGroup G] {H : Type*} [Group H] [TopologicalSpace H] [MeasurableSpace H] [BorelSpace H] [IsTopologicalGroup H] (e : G ≃ₜ* H) : (μ.map e).IsHaarMeasure := e.toMulEquiv.isHaarMeasure_map μ e.continuous e.symm.continuous /-- A convenience wrapper for `MeasureTheory.Measure.isAddHaarMeasure_map`. -/ instance _root_.ContinuousLinearEquiv.isAddHaarMeasure_map {E F R S : Type*} [Semiring R] [Semiring S] [AddCommGroup E] [Module R E] [AddCommGroup F] [Module S F] [TopologicalSpace E] [IsTopologicalAddGroup E] [TopologicalSpace F] [IsTopologicalAddGroup F] {σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] [MeasurableSpace E] [BorelSpace E] [MeasurableSpace F] [BorelSpace F] (L : E ≃SL[σ] F) (μ : Measure E) [IsAddHaarMeasure μ] : IsAddHaarMeasure (μ.map L) := AddEquiv.isAddHaarMeasure_map _ (L : E ≃+ F) L.continuous L.symm.continuous /-- A Haar measure on a σ-compact space is σ-finite. See Note [lower instance priority] -/ @[to_additive /-- A Haar measure on a σ-compact space is σ-finite. See Note [lower instance priority] -/] instance (priority := 100) IsHaarMeasure.sigmaFinite [SigmaCompactSpace G] : SigmaFinite μ := ⟨⟨{ set := compactCovering G set_mem := fun _ => mem_univ _ finite := fun n => IsCompact.measure_lt_top <| isCompact_compactCovering G n spanning := iUnion_compactCovering G }⟩⟩ @[to_additive] instance prod.instIsHaarMeasure {G : Type*} [Group G] [TopologicalSpace G] {_ : MeasurableSpace G} {H : Type*} [Group H] [TopologicalSpace H] {_ : MeasurableSpace H} (μ : Measure G) (ν : Measure H) [IsHaarMeasure μ] [IsHaarMeasure ν] [SFinite μ] [SFinite ν] [MeasurableMul G] [MeasurableMul H] : IsHaarMeasure (μ.prod ν) where /-- If the neutral element of a group is not isolated, then a Haar measure on this group has no atoms. The additive version of this instance applies in particular to show that an additive Haar measure on a nontrivial finite-dimensional real vector space has no atom. -/ @[to_additive /-- If the zero element of an additive group is not isolated, then an additive Haar measure on this group has no atoms. This applies in particular to show that an additive Haar measure on a nontrivial finite-dimensional real vector space has no atom. -/] instance (priority := 100) IsHaarMeasure.noAtoms [IsTopologicalGroup G] [BorelSpace G] [T1Space G] [WeaklyLocallyCompactSpace G] [(𝓝[≠] (1 : G)).NeBot] (μ : Measure G) [μ.IsHaarMeasure] : NoAtoms μ := by cases eq_or_ne (μ 1) 0 with | inl h => constructor; simpa | inr h => obtain ⟨K, K_compact, K_nhds⟩ : ∃ K : Set G, IsCompact K ∧ K ∈ 𝓝 1 := exists_compact_mem_nhds 1 have K_inf : Set.Infinite K := infinite_of_mem_nhds (1 : G) K_nhds exact absurd (K_inf.meas_eq_top ⟨_, h, fun x _ ↦ (haar_singleton _ _).ge⟩) K_compact.measure_lt_top.ne instance IsAddHaarMeasure.domSMul {G A : Type*} [Group G] [AddCommGroup A] [DistribMulAction G A] [MeasurableSpace A] [TopologicalSpace A] [BorelSpace A] [IsTopologicalAddGroup A] [ContinuousConstSMul G A] {μ : Measure A} [μ.IsAddHaarMeasure] (g : Gᵈᵐᵃ) : (g • μ).IsAddHaarMeasure := (DistribMulAction.toAddEquiv _ (DomMulAct.mk.symm g⁻¹)).isAddHaarMeasure_map _ (continuous_const_smul _) (continuous_const_smul _) end Measure end Haar end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/FundamentalDomain.lean
import Mathlib.MeasureTheory.Group.Action import Mathlib.MeasureTheory.Group.Pointwise import Mathlib.MeasureTheory.Integral.Lebesgue.Map import Mathlib.MeasureTheory.Integral.Bochner.Set /-! # Fundamental domain of a group action A set `s` is said to be a *fundamental domain* of an action of a group `G` on a measurable space `α` with respect to a measure `μ` if * `s` is a measurable set; * the sets `g • s` over all `g : G` cover almost all points of the whole space; * the sets `g • s`, are pairwise a.e. disjoint, i.e., `μ (g₁ • s ∩ g₂ • s) = 0` whenever `g₁ ≠ g₂`; we require this for `g₂ = 1` in the definition, then deduce it for any two `g₁ ≠ g₂`. In this file we prove that in case of a countable group `G` and a measure-preserving action, any two fundamental domains have the same measure, and for a `G`-invariant function, its integrals over any two fundamental domains are equal to each other. We also generate additive versions of all theorems in this file using the `to_additive` attribute. * We define the `HasFundamentalDomain` typeclass, in particular to be able to define the `covolume` of a quotient of `α` by a group `G`, which under reasonable conditions does not depend on the choice of fundamental domain. * We define the `QuotientMeasureEqMeasurePreimage` typeclass to describe a situation in which a measure `μ` on `α ⧸ G` can be computed by taking a measure `ν` on `α` of the intersection of the pullback with a fundamental domain. ## Main declarations * `MeasureTheory.IsFundamentalDomain`: Predicate for a set to be a fundamental domain of the action of a group * `MeasureTheory.fundamentalFrontier`: Fundamental frontier of a set under the action of a group. Elements of `s` that belong to some other translate of `s`. * `MeasureTheory.fundamentalInterior`: Fundamental interior of a set under the action of a group. Elements of `s` that do not belong to any other translate of `s`. -/ open scoped ENNReal Pointwise Topology NNReal ENNReal MeasureTheory open MeasureTheory MeasureTheory.Measure Set Function TopologicalSpace Filter namespace MeasureTheory /-- A measurable set `s` is a *fundamental domain* for an additive action of an additive group `G` on a measurable space `α` with respect to a measure `α` if the sets `g +ᵥ s`, `g : G`, are pairwise a.e. disjoint and cover the whole space. -/ structure IsAddFundamentalDomain (G : Type*) {α : Type*} [Zero G] [VAdd G α] [MeasurableSpace α] (s : Set α) (μ : Measure α := by volume_tac) : Prop where protected nullMeasurableSet : NullMeasurableSet s μ protected ae_covers : ∀ᵐ x ∂μ, ∃ g : G, g +ᵥ x ∈ s protected aedisjoint : Pairwise <| (AEDisjoint μ on fun g : G => g +ᵥ s) /-- A measurable set `s` is a *fundamental domain* for an action of a group `G` on a measurable space `α` with respect to a measure `α` if the sets `g • s`, `g : G`, are pairwise a.e. disjoint and cover the whole space. -/ @[to_additive IsAddFundamentalDomain] structure IsFundamentalDomain (G : Type*) {α : Type*} [One G] [SMul G α] [MeasurableSpace α] (s : Set α) (μ : Measure α := by volume_tac) : Prop where protected nullMeasurableSet : NullMeasurableSet s μ protected ae_covers : ∀ᵐ x ∂μ, ∃ g : G, g • x ∈ s protected aedisjoint : Pairwise <| (AEDisjoint μ on fun g : G => g • s) variable {G H α β E : Type*} namespace IsFundamentalDomain variable [Group G] [Group H] [MulAction G α] [MeasurableSpace α] [MulAction H β] [MeasurableSpace β] [NormedAddCommGroup E] {s t : Set α} {μ : Measure α} /-- If for each `x : α`, exactly one of `g • x`, `g : G`, belongs to a measurable set `s`, then `s` is a fundamental domain for the action of `G` on `α`. -/ @[to_additive /-- If for each `x : α`, exactly one of `g +ᵥ x`, `g : G`, belongs to a measurable set `s`, then `s` is a fundamental domain for the additive action of `G` on `α`. -/] theorem mk' (h_meas : NullMeasurableSet s μ) (h_exists : ∀ x : α, ∃! g : G, g • x ∈ s) : IsFundamentalDomain G s μ where nullMeasurableSet := h_meas ae_covers := Eventually.of_forall fun x => (h_exists x).exists aedisjoint a b hab := Disjoint.aedisjoint <| disjoint_left.2 fun x hxa hxb => by rw [mem_smul_set_iff_inv_smul_mem] at hxa hxb exact hab (inv_injective <| (h_exists x).unique hxa hxb) /-- For `s` to be a fundamental domain, it's enough to check `MeasureTheory.AEDisjoint (g • s) s` for `g ≠ 1`. -/ @[to_additive /-- For `s` to be a fundamental domain, it's enough to check `MeasureTheory.AEDisjoint (g +ᵥ s) s` for `g ≠ 0`. -/] theorem mk'' (h_meas : NullMeasurableSet s μ) (h_ae_covers : ∀ᵐ x ∂μ, ∃ g : G, g • x ∈ s) (h_ae_disjoint : ∀ g, g ≠ (1 : G) → AEDisjoint μ (g • s) s) (h_qmp : ∀ g : G, QuasiMeasurePreserving ((g • ·) : α → α) μ μ) : IsFundamentalDomain G s μ where nullMeasurableSet := h_meas ae_covers := h_ae_covers aedisjoint := pairwise_aedisjoint_of_aedisjoint_forall_ne_one h_ae_disjoint h_qmp /-- If a measurable space has a finite measure `μ` and a countable group `G` acts quasi-measure-preservingly, then to show that a set `s` is a fundamental domain, it is sufficient to check that its translates `g • s` are (almost) disjoint and that the sum `∑' g, μ (g • s)` is sufficiently large. -/ @[to_additive /-- If a measurable space has a finite measure `μ` and a countable additive group `G` acts quasi-measure-preservingly, then to show that a set `s` is a fundamental domain, it is sufficient to check that its translates `g +ᵥ s` are (almost) disjoint and that the sum `∑' g, μ (g +ᵥ s)` is sufficiently large. -/] theorem mk_of_measure_univ_le [IsFiniteMeasure μ] [Countable G] (h_meas : NullMeasurableSet s μ) (h_ae_disjoint : ∀ g ≠ (1 : G), AEDisjoint μ (g • s) s) (h_qmp : ∀ g : G, QuasiMeasurePreserving (g • · : α → α) μ μ) (h_measure_univ_le : μ (univ : Set α) ≤ ∑' g : G, μ (g • s)) : IsFundamentalDomain G s μ := have aedisjoint : Pairwise (AEDisjoint μ on fun g : G => g • s) := pairwise_aedisjoint_of_aedisjoint_forall_ne_one h_ae_disjoint h_qmp { nullMeasurableSet := h_meas aedisjoint ae_covers := by replace h_meas : ∀ g : G, NullMeasurableSet (g • s) μ := fun g => by rw [← inv_inv g, ← preimage_smul]; exact h_meas.preimage (h_qmp g⁻¹) have h_meas' : NullMeasurableSet {a | ∃ g : G, g • a ∈ s} μ := by rw [← iUnion_smul_eq_setOf_exists]; exact .iUnion h_meas rw [ae_iff_measure_eq h_meas', ← iUnion_smul_eq_setOf_exists] refine le_antisymm (measure_mono <| subset_univ _) ?_ rw [measure_iUnion₀ aedisjoint h_meas] exact h_measure_univ_le } @[to_additive] theorem iUnion_smul_ae_eq (h : IsFundamentalDomain G s μ) : ⋃ g : G, g • s =ᵐ[μ] univ := eventuallyEq_univ.2 <| h.ae_covers.mono fun _ ⟨g, hg⟩ => mem_iUnion.2 ⟨g⁻¹, _, hg, inv_smul_smul _ _⟩ @[to_additive] theorem measure_ne_zero [Countable G] [SMulInvariantMeasure G α μ] (hμ : μ ≠ 0) (h : IsFundamentalDomain G s μ) : μ s ≠ 0 := by have hc := measure_univ_pos.mpr hμ contrapose! hc rw [← measure_congr h.iUnion_smul_ae_eq] refine le_trans (measure_iUnion_le _) ?_ simp_rw [measure_smul, hc, tsum_zero, le_refl] @[to_additive] theorem mono (h : IsFundamentalDomain G s μ) {ν : Measure α} (hle : ν ≪ μ) : IsFundamentalDomain G s ν := ⟨h.1.mono_ac hle, hle h.2, h.aedisjoint.mono fun _ _ h => hle h⟩ @[to_additive] theorem preimage_of_equiv {ν : Measure β} (h : IsFundamentalDomain G s μ) {f : β → α} (hf : QuasiMeasurePreserving f ν μ) {e : G → H} (he : Bijective e) (hef : ∀ g, Semiconj f (e g • ·) (g • ·)) : IsFundamentalDomain H (f ⁻¹' s) ν where nullMeasurableSet := h.nullMeasurableSet.preimage hf ae_covers := (hf.ae h.ae_covers).mono fun x ⟨g, hg⟩ => ⟨e g, by rwa [mem_preimage, hef g x]⟩ aedisjoint a b hab := by lift e to G ≃ H using he have : (e.symm a⁻¹)⁻¹ ≠ (e.symm b⁻¹)⁻¹ := by simp [hab] have := (h.aedisjoint this).preimage hf simp only [Semiconj] at hef simpa only [onFun, ← preimage_smul_inv, preimage_preimage, ← hef, e.apply_symm_apply, inv_inv] using this @[to_additive] theorem image_of_equiv {ν : Measure β} (h : IsFundamentalDomain G s μ) (f : α ≃ β) (hf : QuasiMeasurePreserving f.symm ν μ) (e : H ≃ G) (hef : ∀ g, Semiconj f (e g • ·) (g • ·)) : IsFundamentalDomain H (f '' s) ν := by rw [f.image_eq_preimage_symm] refine h.preimage_of_equiv hf e.symm.bijective fun g x => ?_ rcases f.surjective x with ⟨x, rfl⟩ rw [← hef _ _, f.symm_apply_apply, f.symm_apply_apply, e.apply_symm_apply] @[to_additive] theorem pairwise_aedisjoint_of_ac {ν} (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) : Pairwise fun g₁ g₂ : G => AEDisjoint ν (g₁ • s) (g₂ • s) := h.aedisjoint.mono fun _ _ H => hν H @[to_additive] theorem smul_of_comm {G' : Type*} [Group G'] [MulAction G' α] [MeasurableSpace G'] [MeasurableSMul G' α] [SMulInvariantMeasure G' α μ] [SMulCommClass G' G α] (h : IsFundamentalDomain G s μ) (g : G') : IsFundamentalDomain G (g • s) μ := h.image_of_equiv (MulAction.toPerm g) (measurePreserving_smul _ _).quasiMeasurePreserving (Equiv.refl _) <| smul_comm g variable [MeasurableSpace G] [MeasurableSMul G α] [SMulInvariantMeasure G α μ] @[to_additive] theorem nullMeasurableSet_smul (h : IsFundamentalDomain G s μ) (g : G) : NullMeasurableSet (g • s) μ := h.nullMeasurableSet.smul g @[to_additive] theorem restrict_restrict (h : IsFundamentalDomain G s μ) (g : G) (t : Set α) : (μ.restrict t).restrict (g • s) = μ.restrict (g • s ∩ t) := restrict_restrict₀ ((h.nullMeasurableSet_smul g).mono restrict_le_self) @[to_additive] theorem smul (h : IsFundamentalDomain G s μ) (g : G) : IsFundamentalDomain G (g • s) μ := h.image_of_equiv (MulAction.toPerm g) (measurePreserving_smul _ _).quasiMeasurePreserving ⟨fun g' => g⁻¹ * g' * g, fun g' => g * g' * g⁻¹, fun g' => by simp [mul_assoc], fun g' => by simp [mul_assoc]⟩ fun g' x => by simp [smul_smul, mul_assoc] variable [Countable G] {ν : Measure α} @[to_additive] theorem sum_restrict_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) : (sum fun g : G => ν.restrict (g • s)) = ν := by rw [← restrict_iUnion_ae (h.aedisjoint.mono fun i j h => hν h) fun g => (h.nullMeasurableSet_smul g).mono_ac hν, restrict_congr_set (hν h.iUnion_smul_ae_eq), restrict_univ] @[to_additive] theorem lintegral_eq_tsum_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂ν = ∑' g : G, ∫⁻ x in g • s, f x ∂ν := by rw [← lintegral_sum_measure, h.sum_restrict_of_ac hν] @[to_additive] theorem sum_restrict (h : IsFundamentalDomain G s μ) : (sum fun g : G => μ.restrict (g • s)) = μ := h.sum_restrict_of_ac (refl _) @[to_additive] theorem lintegral_eq_tsum (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in g • s, f x ∂μ := h.lintegral_eq_tsum_of_ac (refl _) f @[to_additive] theorem lintegral_eq_tsum' (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in s, f (g⁻¹ • x) ∂μ := calc ∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in g • s, f x ∂μ := h.lintegral_eq_tsum f _ = ∑' g : G, ∫⁻ x in g⁻¹ • s, f x ∂μ := ((Equiv.inv G).tsum_eq _).symm _ = ∑' g : G, ∫⁻ x in s, f (g⁻¹ • x) ∂μ := tsum_congr fun g => Eq.symm <| (measurePreserving_smul g⁻¹ μ).setLIntegral_comp_emb (measurableEmbedding_const_smul _) _ _ @[to_additive] lemma lintegral_eq_tsum'' (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in s, f (g • x) ∂μ := (lintegral_eq_tsum' h f).trans ((Equiv.inv G).tsum_eq (fun g ↦ ∫⁻ (x : α) in s, f (g • x) ∂μ)) @[to_additive] theorem setLIntegral_eq_tsum (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) (t : Set α) : ∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in t ∩ g • s, f x ∂μ := calc ∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in g • s, f x ∂μ.restrict t := h.lintegral_eq_tsum_of_ac restrict_le_self.absolutelyContinuous _ _ = ∑' g : G, ∫⁻ x in t ∩ g • s, f x ∂μ := by simp only [h.restrict_restrict, inter_comm] @[to_additive] theorem setLIntegral_eq_tsum' (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) (t : Set α) : ∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := calc ∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in t ∩ g • s, f x ∂μ := h.setLIntegral_eq_tsum f t _ = ∑' g : G, ∫⁻ x in t ∩ g⁻¹ • s, f x ∂μ := ((Equiv.inv G).tsum_eq _).symm _ = ∑' g : G, ∫⁻ x in g⁻¹ • (g • t ∩ s), f x ∂μ := by simp only [smul_set_inter, inv_smul_smul] _ = ∑' g : G, ∫⁻ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := tsum_congr fun g => Eq.symm <| (measurePreserving_smul g⁻¹ μ).setLIntegral_comp_emb (measurableEmbedding_const_smul _) _ _ @[to_additive] theorem measure_eq_tsum_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) (t : Set α) : ν t = ∑' g : G, ν (t ∩ g • s) := by have H : ν.restrict t ≪ μ := Measure.restrict_le_self.absolutelyContinuous.trans hν simpa only [setLIntegral_one, Pi.one_def, Measure.restrict_apply₀ ((h.nullMeasurableSet_smul _).mono_ac H), inter_comm] using h.lintegral_eq_tsum_of_ac H 1 @[to_additive] theorem measure_eq_tsum' (h : IsFundamentalDomain G s μ) (t : Set α) : μ t = ∑' g : G, μ (t ∩ g • s) := h.measure_eq_tsum_of_ac AbsolutelyContinuous.rfl t @[to_additive] theorem measure_eq_tsum (h : IsFundamentalDomain G s μ) (t : Set α) : μ t = ∑' g : G, μ (g • t ∩ s) := by simpa only [setLIntegral_one] using h.setLIntegral_eq_tsum' (fun _ => 1) t @[to_additive] theorem measure_zero_of_invariant (h : IsFundamentalDomain G s μ) (t : Set α) (ht : ∀ g : G, g • t = t) (hts : μ (t ∩ s) = 0) : μ t = 0 := by rw [measure_eq_tsum h]; simp [ht, hts] /-- Given a measure space with an action of a finite group `G`, the measure of any `G`-invariant set is determined by the measure of its intersection with a fundamental domain for the action of `G`. -/ @[to_additive measure_eq_card_smul_of_vadd_ae_eq_self /-- Given a measure space with an action of a finite additive group `G`, the measure of any `G`-invariant set is determined by the measure of its intersection with a fundamental domain for the action of `G`. -/] theorem measure_eq_card_smul_of_smul_ae_eq_self [Finite G] (h : IsFundamentalDomain G s μ) (t : Set α) (ht : ∀ g : G, (g • t : Set α) =ᵐ[μ] t) : μ t = Nat.card G • μ (t ∩ s) := by haveI : Fintype G := Fintype.ofFinite G rw [h.measure_eq_tsum] replace ht : ∀ g : G, (g • t ∩ s : Set α) =ᵐ[μ] (t ∩ s : Set α) := fun g => ae_eq_set_inter (ht g) (ae_eq_refl s) simp_rw [measure_congr (ht _), tsum_fintype, Finset.sum_const, Nat.card_eq_fintype_card, Finset.card_univ] @[to_additive] protected theorem setLIntegral_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) (f : α → ℝ≥0∞) (hf : ∀ (g : G) (x), f (g • x) = f x) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ := calc ∫⁻ x in s, f x ∂μ = ∑' g : G, ∫⁻ x in s ∩ g • t, f x ∂μ := ht.setLIntegral_eq_tsum _ _ _ = ∑' g : G, ∫⁻ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := by simp only [hf, inter_comm] _ = ∫⁻ x in t, f x ∂μ := (hs.setLIntegral_eq_tsum' _ _).symm @[to_additive] theorem measure_set_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) {A : Set α} (hA₀ : MeasurableSet A) (hA : ∀ g : G, (fun x => g • x) ⁻¹' A = A) : μ (A ∩ s) = μ (A ∩ t) := by have : ∫⁻ x in s, A.indicator 1 x ∂μ = ∫⁻ x in t, A.indicator 1 x ∂μ := by refine hs.setLIntegral_eq ht (Set.indicator A fun _ => 1) fun g x ↦ ?_ convert (Set.indicator_comp_right (g • · : α → α) (g := fun _ ↦ (1 : ℝ≥0∞))).symm rw [hA g] simpa [Measure.restrict_apply hA₀, lintegral_indicator hA₀] using this /-- If `s` and `t` are two fundamental domains of the same action, then their measures are equal. -/ @[to_additive /-- If `s` and `t` are two fundamental domains of the same action, then their measures are equal. -/] protected theorem measure_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) : μ s = μ t := by simpa only [setLIntegral_one] using hs.setLIntegral_eq ht (fun _ => 1) fun _ _ => rfl @[to_additive] protected theorem aestronglyMeasurable_on_iff {β : Type*} [TopologicalSpace β] [PseudoMetrizableSpace β] (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) {f : α → β} (hf : ∀ (g : G) (x), f (g • x) = f x) : AEStronglyMeasurable f (μ.restrict s) ↔ AEStronglyMeasurable f (μ.restrict t) := calc AEStronglyMeasurable f (μ.restrict s) ↔ AEStronglyMeasurable f (Measure.sum fun g : G => μ.restrict (g • t ∩ s)) := by simp only [← ht.restrict_restrict, ht.sum_restrict_of_ac restrict_le_self.absolutelyContinuous] _ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g • (g⁻¹ • s ∩ t))) := by simp only [smul_set_inter, inter_comm, smul_inv_smul, aestronglyMeasurable_sum_measure_iff] _ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g⁻¹ • (g⁻¹⁻¹ • s ∩ t))) := inv_surjective.forall _ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g⁻¹ • (g • s ∩ t))) := by simp only [inv_inv] _ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g • s ∩ t)) := by refine forall_congr' fun g => ?_ have he : MeasurableEmbedding (g⁻¹ • · : α → α) := measurableEmbedding_const_smul _ rw [← image_smul, ← ((measurePreserving_smul g⁻¹ μ).restrict_image_emb he _).aestronglyMeasurable_comp_iff he] simp only [Function.comp_def, hf] _ ↔ AEStronglyMeasurable f (μ.restrict t) := by simp only [← aestronglyMeasurable_sum_measure_iff, ← hs.restrict_restrict, hs.sum_restrict_of_ac restrict_le_self.absolutelyContinuous] @[to_additive] protected theorem hasFiniteIntegral_on_iff (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) {f : α → E} (hf : ∀ (g : G) (x), f (g • x) = f x) : HasFiniteIntegral f (μ.restrict s) ↔ HasFiniteIntegral f (μ.restrict t) := by dsimp only [HasFiniteIntegral] rw [hs.setLIntegral_eq ht] intro g x; rw [hf] @[to_additive] protected theorem integrableOn_iff (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) {f : α → E} (hf : ∀ (g : G) (x), f (g • x) = f x) : IntegrableOn f s μ ↔ IntegrableOn f t μ := and_congr (hs.aestronglyMeasurable_on_iff ht hf) (hs.hasFiniteIntegral_on_iff ht hf) variable [NormedSpace ℝ E] @[to_additive] theorem integral_eq_tsum_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) (f : α → E) (hf : Integrable f ν) : ∫ x, f x ∂ν = ∑' g : G, ∫ x in g • s, f x ∂ν := by rw [← MeasureTheory.integral_sum_measure, h.sum_restrict_of_ac hν] rw [h.sum_restrict_of_ac hν] exact hf @[to_additive] theorem integral_eq_tsum (h : IsFundamentalDomain G s μ) (f : α → E) (hf : Integrable f μ) : ∫ x, f x ∂μ = ∑' g : G, ∫ x in g • s, f x ∂μ := integral_eq_tsum_of_ac h (by rfl) f hf @[to_additive] theorem integral_eq_tsum' (h : IsFundamentalDomain G s μ) (f : α → E) (hf : Integrable f μ) : ∫ x, f x ∂μ = ∑' g : G, ∫ x in s, f (g⁻¹ • x) ∂μ := calc ∫ x, f x ∂μ = ∑' g : G, ∫ x in g • s, f x ∂μ := h.integral_eq_tsum f hf _ = ∑' g : G, ∫ x in g⁻¹ • s, f x ∂μ := ((Equiv.inv G).tsum_eq _).symm _ = ∑' g : G, ∫ x in s, f (g⁻¹ • x) ∂μ := tsum_congr fun g => (measurePreserving_smul g⁻¹ μ).setIntegral_image_emb (measurableEmbedding_const_smul _) _ _ @[to_additive] lemma integral_eq_tsum'' (h : IsFundamentalDomain G s μ) (f : α → E) (hf : Integrable f μ) : ∫ x, f x ∂μ = ∑' g : G, ∫ x in s, f (g • x) ∂μ := (integral_eq_tsum' h f hf).trans ((Equiv.inv G).tsum_eq (fun g ↦ ∫ (x : α) in s, f (g • x) ∂μ)) @[to_additive] theorem setIntegral_eq_tsum (h : IsFundamentalDomain G s μ) {f : α → E} {t : Set α} (hf : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∑' g : G, ∫ x in t ∩ g • s, f x ∂μ := calc ∫ x in t, f x ∂μ = ∑' g : G, ∫ x in g • s, f x ∂μ.restrict t := h.integral_eq_tsum_of_ac restrict_le_self.absolutelyContinuous f hf _ = ∑' g : G, ∫ x in t ∩ g • s, f x ∂μ := by simp only [h.restrict_restrict, inter_comm] @[to_additive] theorem setIntegral_eq_tsum' (h : IsFundamentalDomain G s μ) {f : α → E} {t : Set α} (hf : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∑' g : G, ∫ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := calc ∫ x in t, f x ∂μ = ∑' g : G, ∫ x in t ∩ g • s, f x ∂μ := h.setIntegral_eq_tsum hf _ = ∑' g : G, ∫ x in t ∩ g⁻¹ • s, f x ∂μ := ((Equiv.inv G).tsum_eq _).symm _ = ∑' g : G, ∫ x in g⁻¹ • (g • t ∩ s), f x ∂μ := by simp only [smul_set_inter, inv_smul_smul] _ = ∑' g : G, ∫ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := tsum_congr fun g => (measurePreserving_smul g⁻¹ μ).setIntegral_image_emb (measurableEmbedding_const_smul _) _ _ @[to_additive] protected theorem setIntegral_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) {f : α → E} (hf : ∀ (g : G) (x), f (g • x) = f x) : ∫ x in s, f x ∂μ = ∫ x in t, f x ∂μ := by by_cases hfs : IntegrableOn f s μ · have hft : IntegrableOn f t μ := by rwa [ht.integrableOn_iff hs hf] calc ∫ x in s, f x ∂μ = ∑' g : G, ∫ x in s ∩ g • t, f x ∂μ := ht.setIntegral_eq_tsum hfs _ = ∑' g : G, ∫ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := by simp only [hf, inter_comm] _ = ∫ x in t, f x ∂μ := (hs.setIntegral_eq_tsum' hft).symm · rw [integral_undef hfs, integral_undef] rwa [hs.integrableOn_iff ht hf] at hfs /-- If the action of a countable group `G` admits an invariant measure `μ` with a fundamental domain `s`, then every null-measurable set `t` such that the sets `g • t ∩ s` are pairwise a.e.-disjoint has measure at most `μ s`. -/ @[to_additive /-- If the additive action of a countable group `G` admits an invariant measure `μ` with a fundamental domain `s`, then every null-measurable set `t` such that the sets `g +ᵥ t ∩ s` are pairwise a.e.-disjoint has measure at most `μ s`. -/] theorem measure_le_of_pairwise_disjoint (hs : IsFundamentalDomain G s μ) (ht : NullMeasurableSet t μ) (hd : Pairwise (AEDisjoint μ on fun g : G => g • t ∩ s)) : μ t ≤ μ s := calc μ t = ∑' g : G, μ (g • t ∩ s) := hs.measure_eq_tsum t _ = μ (⋃ g : G, g • t ∩ s) := Eq.symm <| measure_iUnion₀ hd fun _ => (ht.smul _).inter hs.nullMeasurableSet _ ≤ μ s := measure_mono (iUnion_subset fun _ => inter_subset_right) /-- If the action of a countable group `G` admits an invariant measure `μ` with a fundamental domain `s`, then every null-measurable set `t` of measure strictly greater than `μ s` contains two points `x y` such that `g • x = y` for some `g ≠ 1`. -/ @[to_additive /-- If the additive action of a countable group `G` admits an invariant measure `μ` with a fundamental domain `s`, then every null-measurable set `t` of measure strictly greater than `μ s` contains two points `x y` such that `g +ᵥ x = y` for some `g ≠ 0`. -/] theorem exists_ne_one_smul_eq (hs : IsFundamentalDomain G s μ) (htm : NullMeasurableSet t μ) (ht : μ s < μ t) : ∃ x ∈ t, ∃ y ∈ t, ∃ g, g ≠ (1 : G) ∧ g • x = y := by contrapose! ht refine hs.measure_le_of_pairwise_disjoint htm (Pairwise.aedisjoint fun g₁ g₂ hne => ?_) dsimp [Function.onFun] refine (Disjoint.inf_left _ ?_).inf_right _ rw [Set.disjoint_left] rintro _ ⟨x, hx, rfl⟩ ⟨y, hy, hxy : g₂ • y = g₁ • x⟩ refine ht x hx y hy (g₂⁻¹ * g₁) (mt inv_mul_eq_one.1 hne.symm) ?_ rw [mul_smul, ← hxy, inv_smul_smul] /-- If `f` is invariant under the action of a countable group `G`, and `μ` is a `G`-invariant measure with a fundamental domain `s`, then the `essSup` of `f` restricted to `s` is the same as that of `f` on all of its domain. -/ @[to_additive /-- If `f` is invariant under the action of a countable additive group `G`, and `μ` is a `G`-invariant measure with a fundamental domain `s`, then the `essSup` of `f` restricted to `s` is the same as that of `f` on all of its domain. -/] theorem essSup_measure_restrict (hs : IsFundamentalDomain G s μ) {f : α → ℝ≥0∞} (hf : ∀ γ : G, ∀ x : α, f (γ • x) = f x) : essSup f (μ.restrict s) = essSup f μ := by refine le_antisymm (essSup_mono_measure' Measure.restrict_le_self) ?_ rw [essSup_eq_sInf (μ.restrict s) f, essSup_eq_sInf μ f] refine sInf_le_sInf ?_ rintro a (ha : (μ.restrict s) {x : α | a < f x} = 0) rw [Measure.restrict_apply₀' hs.nullMeasurableSet] at ha refine measure_zero_of_invariant hs _ ?_ ha intro γ ext x rw [mem_smul_set_iff_inv_smul_mem] simp only [mem_setOf_eq, hf γ⁻¹ x] end IsFundamentalDomain /-! ### Interior/frontier of a fundamental domain -/ section MeasurableSpace variable (G) [Group G] [MulAction G α] (s : Set α) {x : α} /-- The boundary of a fundamental domain, those points of the domain that also lie in a nontrivial translate. -/ @[to_additive MeasureTheory.addFundamentalFrontier /-- The boundary of a fundamental domain, those points of the domain that also lie in a nontrivial translate. -/] def fundamentalFrontier : Set α := s ∩ ⋃ (g : G) (_ : g ≠ 1), g • s /-- The interior of a fundamental domain, those points of the domain not lying in any translate. -/ @[to_additive MeasureTheory.addFundamentalInterior /-- The interior of a fundamental domain, those points of the domain not lying in any translate. -/] def fundamentalInterior : Set α := s \ ⋃ (g : G) (_ : g ≠ 1), g • s variable {G s} @[to_additive (attr := simp) MeasureTheory.mem_addFundamentalFrontier] theorem mem_fundamentalFrontier : x ∈ fundamentalFrontier G s ↔ x ∈ s ∧ ∃ g : G, g ≠ 1 ∧ x ∈ g • s := by simp [fundamentalFrontier] @[to_additive (attr := simp) MeasureTheory.mem_addFundamentalInterior] theorem mem_fundamentalInterior : x ∈ fundamentalInterior G s ↔ x ∈ s ∧ ∀ g : G, g ≠ 1 → x ∉ g • s := by simp [fundamentalInterior] @[to_additive MeasureTheory.addFundamentalFrontier_subset] theorem fundamentalFrontier_subset : fundamentalFrontier G s ⊆ s := inter_subset_left @[to_additive MeasureTheory.addFundamentalInterior_subset] theorem fundamentalInterior_subset : fundamentalInterior G s ⊆ s := diff_subset variable (G s) @[to_additive MeasureTheory.disjoint_addFundamentalInterior_addFundamentalFrontier] theorem disjoint_fundamentalInterior_fundamentalFrontier : Disjoint (fundamentalInterior G s) (fundamentalFrontier G s) := disjoint_sdiff_self_left.mono_right inf_le_right @[to_additive (attr := simp) MeasureTheory.addFundamentalInterior_union_addFundamentalFrontier] theorem fundamentalInterior_union_fundamentalFrontier : fundamentalInterior G s ∪ fundamentalFrontier G s = s := diff_union_inter _ _ @[to_additive (attr := simp) MeasureTheory.addFundamentalFrontier_union_addFundamentalInterior] theorem fundamentalFrontier_union_fundamentalInterior : fundamentalFrontier G s ∪ fundamentalInterior G s = s := inter_union_diff _ _ @[to_additive (attr := simp) MeasureTheory.sdiff_addFundamentalInterior] theorem sdiff_fundamentalInterior : s \ fundamentalInterior G s = fundamentalFrontier G s := sdiff_sdiff_right_self @[to_additive (attr := simp) MeasureTheory.sdiff_addFundamentalFrontier] theorem sdiff_fundamentalFrontier : s \ fundamentalFrontier G s = fundamentalInterior G s := diff_self_inter @[to_additive (attr := simp) MeasureTheory.addFundamentalFrontier_vadd] theorem fundamentalFrontier_smul [Group H] [MulAction H α] [SMulCommClass H G α] (g : H) : fundamentalFrontier G (g • s) = g • fundamentalFrontier G s := by simp_rw [fundamentalFrontier, smul_set_inter, smul_set_iUnion, smul_comm g (_ : G) (_ : Set α)] @[to_additive (attr := simp) MeasureTheory.addFundamentalInterior_vadd] theorem fundamentalInterior_smul [Group H] [MulAction H α] [SMulCommClass H G α] (g : H) : fundamentalInterior G (g • s) = g • fundamentalInterior G s := by simp_rw [fundamentalInterior, smul_set_sdiff, smul_set_iUnion, smul_comm g (_ : G) (_ : Set α)] @[to_additive MeasureTheory.pairwise_disjoint_addFundamentalInterior] theorem pairwise_disjoint_fundamentalInterior : Pairwise (Disjoint on fun g : G => g • fundamentalInterior G s) := by refine fun a b hab => disjoint_left.2 ?_ rintro _ ⟨x, hx, rfl⟩ ⟨y, hy, hxy⟩ rw [mem_fundamentalInterior] at hx hy refine hx.2 (a⁻¹ * b) ?_ ?_ · rwa [Ne, inv_mul_eq_iff_eq_mul, mul_one, eq_comm] · simpa [mul_smul, ← hxy, mem_inv_smul_set_iff] using hy.1 variable [Countable G] [MeasurableSpace G] [MeasurableSpace α] [MeasurableSMul G α] {μ : Measure α} [SMulInvariantMeasure G α μ] @[to_additive MeasureTheory.NullMeasurableSet.addFundamentalFrontier] protected theorem NullMeasurableSet.fundamentalFrontier (hs : NullMeasurableSet s μ) : NullMeasurableSet (fundamentalFrontier G s) μ := hs.inter <| .iUnion fun _ => .iUnion fun _ => hs.smul _ @[to_additive MeasureTheory.NullMeasurableSet.addFundamentalInterior] protected theorem NullMeasurableSet.fundamentalInterior (hs : NullMeasurableSet s μ) : NullMeasurableSet (fundamentalInterior G s) μ := hs.diff <| .iUnion fun _ => .iUnion fun _ => hs.smul _ end MeasurableSpace namespace IsFundamentalDomain variable [Countable G] [Group G] [MulAction G α] [MeasurableSpace α] {μ : Measure α} {s : Set α} (hs : IsFundamentalDomain G s μ) include hs section Group @[to_additive MeasureTheory.IsAddFundamentalDomain.measure_addFundamentalFrontier] theorem measure_fundamentalFrontier : μ (fundamentalFrontier G s) = 0 := by simpa only [fundamentalFrontier, iUnion₂_inter, one_smul, measure_iUnion_null_iff, inter_comm s, Function.onFun] using fun g (hg : g ≠ 1) => hs.aedisjoint hg @[to_additive MeasureTheory.IsAddFundamentalDomain.measure_addFundamentalInterior] theorem measure_fundamentalInterior : μ (fundamentalInterior G s) = μ s := measure_diff_null' hs.measure_fundamentalFrontier end Group variable [MeasurableSpace G] [MeasurableSMul G α] [SMulInvariantMeasure G α μ] protected theorem fundamentalInterior : IsFundamentalDomain G (fundamentalInterior G s) μ where nullMeasurableSet := hs.nullMeasurableSet.fundamentalInterior _ _ ae_covers := by simp_rw [ae_iff, not_exists, ← mem_inv_smul_set_iff, setOf_forall, ← compl_setOf, setOf_mem_eq, ← compl_iUnion] have : ((⋃ g : G, g⁻¹ • s) \ ⋃ g : G, g⁻¹ • fundamentalFrontier G s) ⊆ ⋃ g : G, g⁻¹ • fundamentalInterior G s := by simp_rw [diff_subset_iff, ← iUnion_union_distrib, ← smul_set_union (α := G) (β := α), fundamentalFrontier_union_fundamentalInterior]; rfl refine eq_bot_mono (μ.mono <| compl_subset_compl.2 this) ?_ simp only [iUnion_inv_smul, compl_sdiff, ENNReal.bot_eq_zero, himp_eq, sup_eq_union, @iUnion_smul_eq_setOf_exists _ _ _ _ s] exact measure_union_null (measure_iUnion_null fun _ => measure_smul_null hs.measure_fundamentalFrontier _) hs.ae_covers aedisjoint := (pairwise_disjoint_fundamentalInterior _ _).mono fun _ _ => Disjoint.aedisjoint end IsFundamentalDomain section FundamentalDomainMeasure variable (G) [Group G] [MulAction G α] [MeasurableSpace α] (μ : Measure α) local notation "α_mod_G" => MulAction.orbitRel G α local notation "π" => @Quotient.mk _ α_mod_G variable {G} @[to_additive addMeasure_map_restrict_apply] lemma measure_map_restrict_apply (s : Set α) {U : Set (Quotient α_mod_G)} (meas_U : MeasurableSet U) : (μ.restrict s).map π U = μ ((π ⁻¹' U) ∩ s) := by rw [map_apply (f := π) (fun V hV ↦ measurableSet_quotient.mp hV) meas_U, Measure.restrict_apply (t := (Quotient.mk α_mod_G ⁻¹' U)) (measurableSet_quotient.mp meas_U)] @[to_additive] lemma IsFundamentalDomain.quotientMeasure_eq [Countable G] [MeasurableSpace G] {s t : Set α} [SMulInvariantMeasure G α μ] [MeasurableSMul G α] (fund_dom_s : IsFundamentalDomain G s μ) (fund_dom_t : IsFundamentalDomain G t μ) : (μ.restrict s).map π = (μ.restrict t).map π := by ext U meas_U rw [measure_map_restrict_apply (meas_U := meas_U), measure_map_restrict_apply (meas_U := meas_U)] apply MeasureTheory.IsFundamentalDomain.measure_set_eq fund_dom_s fund_dom_t · exact measurableSet_quotient.mp meas_U · intro g ext x have : Quotient.mk α_mod_G (g • x) = Quotient.mk α_mod_G x := by apply Quotient.sound use g simp only [mem_preimage, this] end FundamentalDomainMeasure /-! ## `HasFundamentalDomain` typeclass We define `HasFundamentalDomain` in order to be able to define the `covolume` of a quotient of `α` by a group `G`, which under reasonable conditions does not depend on the choice of fundamental domain. Even though any "sensible" action should have a fundamental domain, this is a rather delicate question which was recently addressed by Misha Kapovich: https://arxiv.org/abs/2301.05325 TODO: Formalize the existence of a Dirichlet domain as in Kapovich's paper. -/ section HasFundamentalDomain /-- We say a quotient of `α` by `G` `HasAddFundamentalDomain` if there is a measurable set `s` for which `IsAddFundamentalDomain G s` holds. -/ class HasAddFundamentalDomain (G α : Type*) [Zero G] [VAdd G α] [MeasurableSpace α] (ν : Measure α := by volume_tac) : Prop where ExistsIsAddFundamentalDomain : ∃ s : Set α, IsAddFundamentalDomain G s ν /-- We say a quotient of `α` by `G` `HasFundamentalDomain` if there is a measurable set `s` for which `IsFundamentalDomain G s` holds. -/ class HasFundamentalDomain (G : Type*) (α : Type*) [One G] [SMul G α] [MeasurableSpace α] (ν : Measure α := by volume_tac) : Prop where ExistsIsFundamentalDomain : ∃ (s : Set α), IsFundamentalDomain G s ν attribute [to_additive existing] MeasureTheory.HasFundamentalDomain open Classical in /-- The `covolume` of an action of `G` on `α` the volume of some fundamental domain, or `0` if none exists. -/ @[to_additive addCovolume /-- The `addCovolume` of an action of `G` on `α` is the volume of some fundamental domain, or `0` if none exists. -/] noncomputable def covolume (G α : Type*) [One G] [SMul G α] [MeasurableSpace α] (ν : Measure α := by volume_tac) : ℝ≥0∞ := if funDom : HasFundamentalDomain G α ν then ν funDom.ExistsIsFundamentalDomain.choose else 0 variable [Group G] [MulAction G α] [MeasurableSpace α] /-- If there is a fundamental domain `s`, then `HasFundamentalDomain` holds. -/ @[to_additive] lemma IsFundamentalDomain.hasFundamentalDomain (ν : Measure α) {s : Set α} (fund_dom_s : IsFundamentalDomain G s ν) : HasFundamentalDomain G α ν := ⟨⟨s, fund_dom_s⟩⟩ /-- The `covolume` can be computed by taking the `volume` of any given fundamental domain `s`. -/ @[to_additive] lemma IsFundamentalDomain.covolume_eq_volume (ν : Measure α) [Countable G] [MeasurableSpace G] [MeasurableSMul G α] [SMulInvariantMeasure G α ν] {s : Set α} (fund_dom_s : IsFundamentalDomain G s ν) : covolume G α ν = ν s := by dsimp [covolume] simp only [(fund_dom_s.hasFundamentalDomain ν), ↓reduceDIte] rw [fund_dom_s.measure_eq] exact (fund_dom_s.hasFundamentalDomain ν).ExistsIsFundamentalDomain.choose_spec end HasFundamentalDomain /-! ## `QuotientMeasureEqMeasurePreimage` typeclass This typeclass describes a situation in which a measure `μ` on `α ⧸ G` can be computed by taking a measure `ν` on `α` of the intersection of the pullback with a fundamental domain. It's curious that in measure theory, measures can be pushed forward, while in geometry, volumes can be pulled back. And yet here, we are describing a situation involving measures in a geometric way. Another viewpoint is that if a set is small enough to fit in a single fundamental domain, then its `ν` measure in `α` is the same as the `μ` measure of its pushforward in `α ⧸ G`. -/ section QuotientMeasureEqMeasurePreimage section additive variable [AddGroup G] [AddAction G α] [MeasurableSpace α] local notation "α_mod_G" => AddAction.orbitRel G α local notation "π" => @Quotient.mk _ α_mod_G /-- A measure `μ` on the `AddQuotient` of `α` mod `G` satisfies `AddQuotientMeasureEqMeasurePreimage` if: for any fundamental domain `t`, and any measurable subset `U` of the quotient, `μ U = volume ((π ⁻¹' U) ∩ t)`. -/ class AddQuotientMeasureEqMeasurePreimage (ν : Measure α := by volume_tac) (μ : Measure (Quotient α_mod_G)) : Prop where addProjection_respects_measure' : ∀ (t : Set α) (_ : IsAddFundamentalDomain G t ν), μ = (ν.restrict t).map π end additive variable [Group G] [MulAction G α] [MeasurableSpace α] local notation "α_mod_G" => MulAction.orbitRel G α local notation "π" => @Quotient.mk _ α_mod_G /-- Measures `ν` on `α` and `μ` on the `Quotient` of `α` mod `G` satisfy `QuotientMeasureEqMeasurePreimage` if: for any fundamental domain `t`, and any measurable subset `U` of the quotient, `μ U = ν ((π ⁻¹' U) ∩ t)`. -/ class QuotientMeasureEqMeasurePreimage (ν : Measure α := by volume_tac) (μ : Measure (Quotient α_mod_G)) : Prop where projection_respects_measure' (t : Set α) : IsFundamentalDomain G t ν → μ = (ν.restrict t).map π attribute [to_additive] MeasureTheory.QuotientMeasureEqMeasurePreimage @[to_additive addProjection_respects_measure] lemma IsFundamentalDomain.projection_respects_measure {ν : Measure α} (μ : Measure (Quotient α_mod_G)) [i : QuotientMeasureEqMeasurePreimage ν μ] {t : Set α} (fund_dom_t : IsFundamentalDomain G t ν) : μ = (ν.restrict t).map π := i.projection_respects_measure' t fund_dom_t @[to_additive addProjection_respects_measure_apply] lemma IsFundamentalDomain.projection_respects_measure_apply {ν : Measure α} (μ : Measure (Quotient α_mod_G)) [i : QuotientMeasureEqMeasurePreimage ν μ] {t : Set α} (fund_dom_t : IsFundamentalDomain G t ν) {U : Set (Quotient α_mod_G)} (meas_U : MeasurableSet U) : μ U = ν (π ⁻¹' U ∩ t) := by rw [fund_dom_t.projection_respects_measure (μ := μ), measure_map_restrict_apply ν t meas_U] variable {ν : Measure α} /-- Any two measures satisfying `QuotientMeasureEqMeasurePreimage` are equal. -/ @[to_additive] lemma QuotientMeasureEqMeasurePreimage.unique [hasFun : HasFundamentalDomain G α ν] (μ μ' : Measure (Quotient α_mod_G)) [QuotientMeasureEqMeasurePreimage ν μ] [QuotientMeasureEqMeasurePreimage ν μ'] : μ = μ' := by obtain ⟨𝓕, h𝓕⟩ := hasFun.ExistsIsFundamentalDomain rw [h𝓕.projection_respects_measure (μ := μ), h𝓕.projection_respects_measure (μ := μ')] /-- The quotient map to `α ⧸ G` is measure-preserving between the restriction of `volume` to a fundamental domain in `α` and a related measure satisfying `QuotientMeasureEqMeasurePreimage`. -/ @[to_additive IsAddFundamentalDomain.measurePreserving_add_quotient_mk] theorem IsFundamentalDomain.measurePreserving_quotient_mk {𝓕 : Set α} (h𝓕 : IsFundamentalDomain G 𝓕 ν) (μ : Measure (Quotient α_mod_G)) [QuotientMeasureEqMeasurePreimage ν μ] : MeasurePreserving π (ν.restrict 𝓕) μ where measurable := measurable_quotient_mk' (s := α_mod_G) map_eq := by haveI : HasFundamentalDomain G α ν := ⟨𝓕, h𝓕⟩ rw [h𝓕.projection_respects_measure (μ := μ)] variable [SMulInvariantMeasure G α ν] [Countable G] [MeasurableSpace G] [MeasurableSMul G α] /-- Given a measure upstairs (i.e., on `α`), and a choice `s` of fundamental domain, there's always an artificial way to generate a measure downstairs such that the pair satisfies the `QuotientMeasureEqMeasurePreimage` typeclass. -/ @[to_additive] lemma IsFundamentalDomain.quotientMeasureEqMeasurePreimage_quotientMeasure {s : Set α} (fund_dom_s : IsFundamentalDomain G s ν) : QuotientMeasureEqMeasurePreimage ν ((ν.restrict s).map π) where projection_respects_measure' t fund_dom_t := by rw [fund_dom_s.quotientMeasure_eq _ fund_dom_t] /-- One can prove `QuotientMeasureEqMeasurePreimage` by checking behavior with respect to a single fundamental domain. -/ @[to_additive] lemma IsFundamentalDomain.quotientMeasureEqMeasurePreimage {μ : Measure (Quotient α_mod_G)} {s : Set α} (fund_dom_s : IsFundamentalDomain G s ν) (h : μ = (ν.restrict s).map π) : QuotientMeasureEqMeasurePreimage ν μ := by simpa [h] using fund_dom_s.quotientMeasureEqMeasurePreimage_quotientMeasure /-- If a fundamental domain has volume 0, then `QuotientMeasureEqMeasurePreimage` holds. -/ @[to_additive] theorem IsFundamentalDomain.quotientMeasureEqMeasurePreimage_of_zero {s : Set α} (fund_dom_s : IsFundamentalDomain G s ν) (vol_s : ν s = 0) : QuotientMeasureEqMeasurePreimage ν (0 : Measure (Quotient α_mod_G)) := by apply fund_dom_s.quotientMeasureEqMeasurePreimage ext U meas_U simp only [Measure.coe_zero, Pi.zero_apply] convert (measure_inter_null_of_null_right (h := vol_s) (Quotient.mk α_mod_G ⁻¹' U)).symm rw [measure_map_restrict_apply (meas_U := meas_U)] /-- If a measure `μ` on a quotient satisfies `QuotientMeasureEqMeasurePreimage` with respect to a sigma-finite measure `ν`, then it is itself `SigmaFinite`. -/ @[to_additive] lemma QuotientMeasureEqMeasurePreimage.sigmaFiniteQuotient [i : SigmaFinite ν] [i' : HasFundamentalDomain G α ν] (μ : Measure (Quotient α_mod_G)) [QuotientMeasureEqMeasurePreimage ν μ] : SigmaFinite μ := by rw [sigmaFinite_iff] obtain ⟨A, hA_meas, hA, hA'⟩ := Measure.toFiniteSpanningSetsIn (h := i) simp only [mem_setOf_eq] at hA_meas refine ⟨⟨fun n ↦ π '' (A n), by simp, fun n ↦ ?_, ?_⟩⟩ · obtain ⟨s, fund_dom_s⟩ := i' have : π ⁻¹' (π '' (A n)) = _ := MulAction.quotient_preimage_image_eq_union_mul (A n) (G := G) have measπAn : MeasurableSet (π '' A n) := by let _ : Setoid α := α_mod_G rw [measurableSet_quotient, Quotient.mk''_eq_mk, this] apply MeasurableSet.iUnion exact fun g ↦ MeasurableSet.const_smul (hA_meas n) g rw [fund_dom_s.projection_respects_measure_apply (μ := μ) measπAn, this, iUnion_inter] refine lt_of_le_of_lt ?_ (hA n) rw [fund_dom_s.measure_eq_tsum (A n)] exact measure_iUnion_le _ · rw [← image_iUnion, hA'] refine image_univ_of_surjective (by convert Quotient.mk'_surjective) /-- A measure `μ` on `α ⧸ G` satisfying `QuotientMeasureEqMeasurePreimage` and having finite covolume is a finite measure. -/ @[to_additive] theorem QuotientMeasureEqMeasurePreimage.isFiniteMeasure_quotient (μ : Measure (Quotient α_mod_G)) [QuotientMeasureEqMeasurePreimage ν μ] [hasFun : HasFundamentalDomain G α ν] (h : covolume G α ν ≠ ∞) : IsFiniteMeasure μ := by obtain ⟨𝓕, h𝓕⟩ := hasFun.ExistsIsFundamentalDomain rw [h𝓕.projection_respects_measure (μ := μ)] have : Fact (ν 𝓕 < ∞) := by apply Fact.mk convert Ne.lt_top h exact (h𝓕.covolume_eq_volume ν).symm infer_instance /-- A finite measure `μ` on `α ⧸ G` satisfying `QuotientMeasureEqMeasurePreimage` has finite covolume. -/ @[to_additive] theorem QuotientMeasureEqMeasurePreimage.covolume_ne_top (μ : Measure (Quotient α_mod_G)) [QuotientMeasureEqMeasurePreimage ν μ] [IsFiniteMeasure μ] : covolume G α ν < ∞ := by by_cases hasFun : HasFundamentalDomain G α ν · obtain ⟨𝓕, h𝓕⟩ := hasFun.ExistsIsFundamentalDomain have H : μ univ < ∞ := IsFiniteMeasure.measure_univ_lt_top rw [h𝓕.projection_respects_measure_apply (μ := μ) MeasurableSet.univ] at H simpa [h𝓕.covolume_eq_volume ν] using H · simp [covolume, hasFun] end QuotientMeasureEqMeasurePreimage section QuotientMeasureEqMeasurePreimage variable [Group G] [MulAction G α] [MeasureSpace α] [Countable G] [MeasurableSpace G] [SMulInvariantMeasure G α volume] [MeasurableSMul G α] local notation "α_mod_G" => MulAction.orbitRel G α local notation "π" => @Quotient.mk _ α_mod_G /-- If a measure `μ` on a quotient satisfies `QuotientVolumeEqVolumePreimage` with respect to a sigma-finite measure, then it is itself `SigmaFinite`. -/ @[to_additive MeasureTheory.instSigmaFiniteAddQuotientOrbitRelInstMeasurableSpaceToMeasurableSpace] instance [SigmaFinite (volume : Measure α)] [HasFundamentalDomain G α] (μ : Measure (Quotient α_mod_G)) [QuotientMeasureEqMeasurePreimage volume μ] : SigmaFinite μ := QuotientMeasureEqMeasurePreimage.sigmaFiniteQuotient (ν := (volume : Measure α)) (μ := μ) end QuotientMeasureEqMeasurePreimage end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/UnitInterval.lean
import Mathlib.MeasureTheory.Measure.Haar.Unique /-! # The canonical measure on the unit interval This file provides a `MeasureTheory.MeasureSpace` instance on `unitInterval`, and shows it is a probability measure with no atoms. It also contains some basic results on the volume of various interval sets. -/ open scoped unitInterval open MeasureTheory Measure Set namespace unitInterval noncomputable instance : MeasureSpace I := Measure.Subtype.measureSpace theorem volume_def : (volume : Measure I) = volume.comap Subtype.val := rfl instance : IsProbabilityMeasure (volume : Measure I) where measure_univ := by rw [Measure.Subtype.volume_univ nullMeasurableSet_Icc, Real.volume_Icc, sub_zero, ENNReal.ofReal_one] lemma measurableEmbedding_coe : MeasurableEmbedding ((↑) : I → ℝ) where injective := Subtype.val_injective measurable := measurable_subtype_coe measurableSet_image' _ := measurableSet_Icc.subtype_image lemma volume_apply {s : Set I} : volume s = volume (Subtype.val '' s) := measurableEmbedding_coe.comap_apply .. lemma measurePreserving_coe : MeasurePreserving ((↑) : I → ℝ) volume (volume.restrict I) := measurePreserving_subtype_coe measurableSet_Icc instance : NoAtoms (volume : Measure I) where measure_singleton x := by simp [volume_apply] @[fun_prop, measurability] theorem measurable_symm : Measurable σ := continuous_symm.measurable /-- `unitInterval.symm` bundled as a measurable equivalence. -/ @[simps] def symmMeasurableEquiv : I ≃ᵐ I where toFun := σ invFun := σ left_inv := symm_symm right_inv := symm_symm measurable_toFun := measurable_symm measurable_invFun := measurable_symm @[simp] lemma symm_symmMeasurableEquiv : symmMeasurableEquiv.symm = symmMeasurableEquiv := rfl @[simp] lemma coe_symmMeasurableEquiv : symmMeasurableEquiv = σ := rfl lemma measurePreserving_symm : MeasurePreserving symm volume volume where measurable := measurable_symm map_eq := by ext s hs apply symmMeasurableEquiv.map_apply _ |>.trans conv_lhs => rw [coe_symmMeasurableEquiv, volume_apply, image_coe_preimage_symm, ← map_apply (by fun_prop) (measurableSet_Icc.subtype_image hs), volume.measurePreserving_sub_left 1 |>.map_eq, ← volume_apply] open Set variable (x : I) @[simp] lemma volume_Iic : volume (Iic x) = .ofReal x := by simp only [volume_apply, image_subtype_val_Icc_Iic, Real.volume_Icc, sub_zero] @[simp] lemma volume_Iio : volume (Iio x) = .ofReal x := by simp only [← volume_image_subtype_coe measurableSet_Icc, image_subtype_val_Icc_Iio, Real.volume_Ico, sub_zero] @[simp] lemma volume_Ici : volume (Ici x) = .ofReal (1 - x) := by simp only [volume_apply, image_subtype_val_Icc_Ici, Real.volume_Icc] @[simp] lemma volume_Ioi : volume (Ioi x) = .ofReal (1 - x) := by simp only [volume_apply, image_subtype_val_Icc_Ioi, Real.volume_Ioc] variable (y : I) @[simp] lemma volume_Icc : volume (Icc x y) = .ofReal (y - x) := by simp only [volume_apply, image_subtype_val_Icc, Real.volume_Icc] @[simp] lemma volume_uIcc : volume (uIcc x y) = edist y x := by simp only [uIcc, volume_apply, image_subtype_val_Icc, Icc.coe_inf, Icc.coe_sup, Real.volume_Icc, max_sub_min_eq_abs, edist_dist, Subtype.dist_eq, Real.dist_eq] @[simp] lemma volume_Ico : volume (Ico x y) = .ofReal (y - x) := by simp only [volume_apply, image_subtype_val_Ico, Real.volume_Ico] @[simp] lemma volume_Ioc : volume (Ioc x y) = .ofReal (y - x) := by simp only [volume_apply, image_subtype_val_Ioc, Real.volume_Ioc] @[simp] lemma volume_uIoc : volume (uIoc x y) = edist y x := by simp only [uIoc, volume_apply, image_subtype_val_Ioc, Icc.coe_inf, Icc.coe_sup, Real.volume_Ioc, max_sub_min_eq_abs, edist_dist, Subtype.dist_eq, Real.dist_eq] @[simp] lemma volume_Ioo : volume (Ioo x y) = .ofReal (y - x) := by simp only [volume_apply, image_subtype_val_Ioo, Real.volume_Ioo] @[simp] lemma volume_uIoo : volume (uIoo x y) = edist y x := by simp only [uIoo, volume_apply, image_subtype_val_Ioo, Icc.coe_inf, Icc.coe_sup, Real.volume_Ioo, max_sub_min_eq_abs, edist_dist, Subtype.dist_eq, Real.dist_eq] end unitInterval
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/ClosedCompactCylinders.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic import Mathlib.MeasureTheory.Constructions.Cylinders /-! # Cylinders with closed compact bases We define the set of all cylinders with closed compact bases. Those sets play a role in the proof of Kolmogorov's extension theorem. ## Main definitions * `closedCompactCylinders X`: the set of all cylinders of `Π i, X i` based on closed compact sets. ## Main statements * `mem_measurableCylinders_of_mem_closedCompactCylinders`: in a topological space with second countable topology and measurable open sets, a set in `closedCompactCylinders X` is a measurable cylinder. -/ open Set namespace MeasureTheory variable {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] {t : Set (Π i, X i)} variable (X) in /-- The set of all cylinders based on closed compact sets. Note that such a set is closed, but not compact in general (for instance, the whole space is always a closed compact cylinder). -/ def closedCompactCylinders : Set (Set (Π i, X i)) := ⋃ (s) (S) (_ : IsClosed S) (_ : IsCompact S), {cylinder s S} variable (X) in theorem empty_mem_closedCompactCylinders : ∅ ∈ closedCompactCylinders X := by simp_rw [closedCompactCylinders, mem_iUnion, mem_singleton_iff] exact ⟨∅, ∅, isClosed_empty, isCompact_empty, (cylinder_empty _).symm⟩ theorem mem_closedCompactCylinders (t : Set (Π i, X i)) : t ∈ closedCompactCylinders X ↔ ∃ (s S : _), IsClosed S ∧ IsCompact S ∧ t = cylinder s S := by simp_rw [closedCompactCylinders, mem_iUnion, mem_singleton_iff, exists_prop] /-- A finset `s` such that `t = cylinder s S`. `S` is given by `closedCompactCylinders.set`. -/ noncomputable def closedCompactCylinders.finset (ht : t ∈ closedCompactCylinders X) : Finset ι := ((mem_closedCompactCylinders t).mp ht).choose /-- A set `S` such that `t = cylinder s S`. `s` is given by `closedCompactCylinders.finset`. -/ def closedCompactCylinders.set (ht : t ∈ closedCompactCylinders X) : Set (Π i : closedCompactCylinders.finset ht, X i) := ((mem_closedCompactCylinders t).mp ht).choose_spec.choose theorem closedCompactCylinders.isClosed (ht : t ∈ closedCompactCylinders X) : IsClosed (closedCompactCylinders.set ht) := ((mem_closedCompactCylinders t).mp ht).choose_spec.choose_spec.1 theorem closedCompactCylinders.isCompact (ht : t ∈ closedCompactCylinders X) : IsCompact (closedCompactCylinders.set ht) := ((mem_closedCompactCylinders t).mp ht).choose_spec.choose_spec.2.1 theorem closedCompactCylinders.eq_cylinder (ht : t ∈ closedCompactCylinders X) : t = cylinder (closedCompactCylinders.finset ht) (closedCompactCylinders.set ht) := ((mem_closedCompactCylinders t).mp ht).choose_spec.choose_spec.2.2 theorem cylinder_mem_closedCompactCylinders (s : Finset ι) (S : Set (Π i : s, X i)) (hS_closed : IsClosed S) (hS_compact : IsCompact S) : cylinder s S ∈ closedCompactCylinders X := by rw [mem_closedCompactCylinders] exact ⟨s, S, hS_closed, hS_compact, rfl⟩ theorem mem_measurableCylinders_of_mem_closedCompactCylinders [∀ i, MeasurableSpace (X i)] [∀ i, SecondCountableTopology (X i)] [∀ i, OpensMeasurableSpace (X i)] (ht : t ∈ closedCompactCylinders X) : t ∈ measurableCylinders X := by rw [mem_measurableCylinders] refine ⟨closedCompactCylinders.finset ht, closedCompactCylinders.set ht, ?_, ?_⟩ · exact (closedCompactCylinders.isClosed ht).measurableSet · exact closedCompactCylinders.eq_cylinder ht end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/Pi.lean
import Mathlib.Algebra.BigOperators.Fin import Mathlib.Logic.Encodable.Pi import Mathlib.MeasureTheory.Group.Measure import Mathlib.MeasureTheory.MeasurableSpace.Pi import Mathlib.MeasureTheory.Measure.Prod import Mathlib.Topology.Constructions /-! # Indexed product measures In this file we define and prove properties about finite products of measures (and at some point, countable products of measures). ## Main definition * `MeasureTheory.Measure.pi`: The product of finitely many σ-finite measures. Given `μ : (i : ι) → Measure (α i)` for `[Fintype ι]` it has type `Measure ((i : ι) → α i)`. To apply Fubini's theorem or Tonelli's theorem along some subset, we recommend using the marginal construction `MeasureTheory.lmarginal` and (todo) `MeasureTheory.marginal`. This allows you to apply the theorems without any bookkeeping with measurable equivalences. ## Implementation Notes We define `MeasureTheory.OuterMeasure.pi`, the product of finitely many outer measures, as the maximal outer measure `n` with the property that `n (pi univ s) ≤ ∏ i, m i (s i)`, where `pi univ s` is the product of the sets `{s i | i : ι}`. We then show that this induces a product of measures, called `MeasureTheory.Measure.pi`. For a collection of σ-finite measures `μ` and a collection of measurable sets `s` we show that `Measure.pi μ (pi univ s) = ∏ i, m i (s i)`. To do this, we follow the following steps: * We know that there is some ordering on `ι`, given by an element of `[Countable ι]`. * Using this, we have an equivalence `MeasurableEquiv.piMeasurableEquivTProd` between `∀ ι, α i` and an iterated product of `α i`, called `List.tprod α l` for some list `l`. * On this iterated product we can easily define a product measure `MeasureTheory.Measure.tprod` by iterating `MeasureTheory.Measure.prod` * Using the previous two steps we construct `MeasureTheory.Measure.pi'` on `(i : ι) → α i` for countable `ι`. * We know that `MeasureTheory.Measure.pi'` sends products of sets to products of measures, and since `MeasureTheory.Measure.pi` is the maximal such measure (or at least, it comes from an outer measure which is the maximal such outer measure), we get the same rule for `MeasureTheory.Measure.pi`. ## Tags finitary product measure -/ noncomputable section open Function Set MeasureTheory.OuterMeasure Filter MeasurableSpace Encodable open scoped Topology ENNReal universe u v variable {ι ι' : Type*} {α : ι → Type*} namespace MeasureTheory variable [Fintype ι] {m : ∀ i, OuterMeasure (α i)} /-- An upper bound for the measure in a finite product space. It is defined to by taking the image of the set under all projections, and taking the product of the measures of these images. For measurable boxes it is equal to the correct measure. -/ @[simp] def piPremeasure (m : ∀ i, OuterMeasure (α i)) (s : Set (∀ i, α i)) : ℝ≥0∞ := ∏ i, m i (eval i '' s) theorem piPremeasure_pi {s : ∀ i, Set (α i)} (hs : (pi univ s).Nonempty) : piPremeasure m (pi univ s) = ∏ i, m i (s i) := by simp [hs, piPremeasure] theorem piPremeasure_pi' {s : ∀ i, Set (α i)} : piPremeasure m (pi univ s) = ∏ i, m i (s i) := by cases isEmpty_or_nonempty ι · simp [piPremeasure] rcases (pi univ s).eq_empty_or_nonempty with h | h · rcases univ_pi_eq_empty_iff.mp h with ⟨i, hi⟩ have : ∃ i, m i (s i) = 0 := ⟨i, by simp [hi]⟩ simpa [h, Finset.card_univ, zero_pow Fintype.card_ne_zero, @eq_comm _ (0 : ℝ≥0∞), Finset.prod_eq_zero_iff, piPremeasure] · simp [h, piPremeasure] theorem piPremeasure_pi_mono {s t : Set (∀ i, α i)} (h : s ⊆ t) : piPremeasure m s ≤ piPremeasure m t := Finset.prod_le_prod' fun _ _ => measure_mono (Set.image_mono h) theorem piPremeasure_pi_eval {s : Set (∀ i, α i)} : piPremeasure m (pi univ fun i => eval i '' s) = piPremeasure m s := by simp only [eval, piPremeasure_pi']; rfl namespace OuterMeasure /-- `OuterMeasure.pi m` is the finite product of the outer measures `{m i | i : ι}`. It is defined to be the maximal outer measure `n` with the property that `n (pi univ s) ≤ ∏ i, m i (s i)`, where `pi univ s` is the product of the sets `{s i | i : ι}`. -/ protected def pi (m : ∀ i, OuterMeasure (α i)) : OuterMeasure (∀ i, α i) := boundedBy (piPremeasure m) theorem pi_pi_le (m : ∀ i, OuterMeasure (α i)) (s : ∀ i, Set (α i)) : OuterMeasure.pi m (pi univ s) ≤ ∏ i, m i (s i) := by rcases (pi univ s).eq_empty_or_nonempty with h | h · simp [h] exact (boundedBy_le _).trans_eq (piPremeasure_pi h) theorem le_pi {m : ∀ i, OuterMeasure (α i)} {n : OuterMeasure (∀ i, α i)} : n ≤ OuterMeasure.pi m ↔ ∀ s : ∀ i, Set (α i), (pi univ s).Nonempty → n (pi univ s) ≤ ∏ i, m i (s i) := by rw [OuterMeasure.pi, le_boundedBy']; constructor · intro h s hs; refine (h _ hs).trans_eq (piPremeasure_pi hs) · intro h s hs; refine le_trans (n.mono <| subset_pi_eval_image univ s) (h _ ?_) simp [univ_pi_nonempty_iff, hs] end OuterMeasure namespace Measure variable [∀ i, MeasurableSpace (α i)] (μ : ∀ i, Measure (α i)) section Tprod open List variable {δ : Type*} {X : δ → Type*} [∀ i, MeasurableSpace (X i)] -- for some reason the equation compiler doesn't like this definition /-- A product of measures in `tprod α l`. -/ protected def tprod (l : List δ) (μ : ∀ i, Measure (X i)) : Measure (TProd X l) := by induction l with | nil => exact dirac PUnit.unit | cons i l ih => exact (μ i).prod (α := X i) ih @[simp] theorem tprod_nil (μ : ∀ i, Measure (X i)) : Measure.tprod [] μ = dirac PUnit.unit := rfl @[simp] theorem tprod_cons (i : δ) (l : List δ) (μ : ∀ i, Measure (X i)) : Measure.tprod (i :: l) μ = (μ i).prod (Measure.tprod l μ) := rfl instance sigmaFinite_tprod (l : List δ) (μ : ∀ i, Measure (X i)) [∀ i, SigmaFinite (μ i)] : SigmaFinite (Measure.tprod l μ) := by induction l with | nil => rw [tprod_nil]; infer_instance | cons i l ih => rw [tprod_cons]; exact @prod.instSigmaFinite _ _ _ _ _ _ _ ih theorem tprod_tprod (l : List δ) (μ : ∀ i, Measure (X i)) [∀ i, SigmaFinite (μ i)] (s : ∀ i, Set (X i)) : Measure.tprod l μ (Set.tprod l s) = (l.map fun i => (μ i) (s i)).prod := by induction l with | nil => simp | cons a l ih => rw [tprod_cons, Set.tprod] dsimp only [foldr_cons, map_cons, prod_cons] rw [prod_prod, ih] end Tprod section Encodable open List MeasurableEquiv variable [Encodable ι] open scoped Classical in /-- The product measure on an encodable finite type, defined by mapping `Measure.tprod` along the equivalence `MeasurableEquiv.piMeasurableEquivTProd`. The definition `MeasureTheory.Measure.pi` should be used instead of this one. -/ def pi' : Measure (∀ i, α i) := Measure.map (TProd.elim' mem_sortedUniv) (Measure.tprod (sortedUniv ι) μ) theorem pi'_pi [∀ i, SigmaFinite (μ i)] (s : ∀ i, Set (α i)) : pi' μ (pi univ s) = ∏ i, μ i (s i) := by classical rw [pi'] rw [← MeasurableEquiv.piMeasurableEquivTProd_symm_apply, MeasurableEquiv.map_apply, MeasurableEquiv.piMeasurableEquivTProd_symm_apply, elim_preimage_pi, tprod_tprod _ μ, ← List.prod_toFinset, sortedUniv_toFinset] <;> exact sortedUniv_nodup ι end Encodable theorem pi_caratheodory : MeasurableSpace.pi ≤ (OuterMeasure.pi fun i => (μ i).toOuterMeasure).caratheodory := by refine iSup_le ?_ intro i s hs rw [MeasurableSpace.comap] at hs rcases hs with ⟨s, hs, rfl⟩ apply boundedBy_caratheodory intro t simp_rw [piPremeasure] refine Finset.prod_add_prod_le' (Finset.mem_univ i) ?_ ?_ ?_ · simp [image_inter_preimage, image_diff_preimage, measure_inter_add_diff _ hs, le_refl] · rintro j - _; gcongr; apply inter_subset_left · rintro j - _; gcongr; apply diff_subset /-- `Measure.pi μ` is the finite product of the measures `{μ i | i : ι}`. It is defined to be measure corresponding to `MeasureTheory.OuterMeasure.pi`. -/ protected irreducible_def pi : Measure (∀ i, α i) := toMeasure (OuterMeasure.pi fun i => (μ i).toOuterMeasure) (pi_caratheodory μ) instance _root_.MeasureTheory.MeasureSpace.pi {α : ι → Type*} [∀ i, MeasureSpace (α i)] : MeasureSpace (∀ i, α i) := ⟨Measure.pi fun _ => volume⟩ theorem pi_pi_aux [∀ i, SigmaFinite (μ i)] (s : ∀ i, Set (α i)) (hs : ∀ i, MeasurableSet (s i)) : Measure.pi μ (pi univ s) = ∏ i, μ i (s i) := by refine le_antisymm ?_ ?_ · rw [Measure.pi, toMeasure_apply _ _ (MeasurableSet.pi countable_univ fun i _ => hs i)] apply OuterMeasure.pi_pi_le · haveI : Encodable ι := Fintype.toEncodable ι simp_rw [← pi'_pi μ s, Measure.pi, toMeasure_apply _ _ (MeasurableSet.pi countable_univ fun i _ => hs i)] suffices (pi' μ).toOuterMeasure ≤ OuterMeasure.pi fun i => (μ i).toOuterMeasure by exact this _ clear hs s rw [OuterMeasure.le_pi] intro s _ exact (pi'_pi μ s).le variable {μ} /-- `Measure.pi μ` has finite spanning sets in rectangles of finite spanning sets. -/ def FiniteSpanningSetsIn.pi {C : ∀ i, Set (Set (α i))} (hμ : ∀ i, (μ i).FiniteSpanningSetsIn (C i)) : (Measure.pi μ).FiniteSpanningSetsIn (pi univ '' pi univ C) := by haveI := fun i => (hμ i).sigmaFinite haveI := Fintype.toEncodable ι refine ⟨fun n => Set.pi univ fun i => (hμ i).set ((@decode (ι → ℕ) _ n).iget i), fun n => ?_, fun n => ?_, ?_⟩ <;> -- TODO (kmill) If this let comes before the refine, while the noncomputability checker -- correctly sees this definition is computable, the Lean VM fails to see the binding is -- computationally irrelevant. The `noncomputable section` doesn't help because all it does -- is insert `noncomputable` for you when necessary. let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget · refine mem_image_of_mem _ fun i _ => (hμ i).set_mem _ · calc Measure.pi μ (Set.pi univ fun i => (hμ i).set (e n i)) ≤ Measure.pi μ (Set.pi univ fun i => toMeasurable (μ i) ((hμ i).set (e n i))) := measure_mono (pi_mono fun i _ => subset_toMeasurable _ _) _ = ∏ i, μ i (toMeasurable (μ i) ((hμ i).set (e n i))) := (pi_pi_aux μ _ fun i => measurableSet_toMeasurable _ _) _ = ∏ i, μ i ((hμ i).set (e n i)) := by simp only [measure_toMeasurable] _ < ∞ := ENNReal.prod_lt_top fun i _ => (hμ i).finite _ · simp_rw [(surjective_decode_iget (ι → ℕ)).iUnion_comp fun x => Set.pi univ fun i => (hμ i).set (x i), iUnion_univ_pi fun i => (hμ i).set, (hμ _).spanning, Set.pi_univ] /-- A measure on a finite product space equals the product measure if they are equal on rectangles with as sides sets that generate the corresponding σ-algebras. -/ theorem pi_eq_generateFrom {C : ∀ i, Set (Set (α i))} (hC : ∀ i, generateFrom (C i) = by apply_assumption) (h2C : ∀ i, IsPiSystem (C i)) (h3C : ∀ i, (μ i).FiniteSpanningSetsIn (C i)) {μν : Measure (∀ i, α i)} (h₁ : ∀ s : ∀ i, Set (α i), (∀ i, s i ∈ C i) → μν (pi univ s) = ∏ i, μ i (s i)) : Measure.pi μ = μν := by have h4C : ∀ (i) (s : Set (α i)), s ∈ C i → MeasurableSet s := by intro i s hs; rw [← hC]; exact measurableSet_generateFrom hs refine (FiniteSpanningSetsIn.pi h3C).ext (generateFrom_eq_pi hC fun i => (h3C i).isCountablySpanning).symm (IsPiSystem.pi h2C) ?_ rintro _ ⟨s, hs, rfl⟩ rw [mem_univ_pi] at hs haveI := fun i => (h3C i).sigmaFinite simp_rw [h₁ s hs, pi_pi_aux μ s fun i => h4C i _ (hs i)] /-- A measure on a finite product space equals the product measure if they are equal on rectangles. -/ theorem pi_eq [∀ i, SigmaFinite (μ i)] {μ' : Measure (∀ i, α i)} (h : ∀ s : ∀ i, Set (α i), (∀ i, MeasurableSet (s i)) → μ' (pi univ s) = ∏ i, μ i (s i)) : Measure.pi μ = μ' := pi_eq_generateFrom (fun _ => generateFrom_measurableSet) (fun _ => isPiSystem_measurableSet) (fun i => (μ i).toFiniteSpanningSetsIn) h variable (μ) theorem pi'_eq_pi [Encodable ι] [∀ i, SigmaFinite (μ i)] : pi' μ = Measure.pi μ := Eq.symm <| pi_eq fun s _ => pi'_pi μ s @[simp] theorem pi_pi [∀ i, SigmaFinite (μ i)] (s : ∀ i, Set (α i)) : Measure.pi μ (pi univ s) = ∏ i, μ i (s i) := by haveI : Encodable ι := Fintype.toEncodable ι rw [← pi'_eq_pi, pi'_pi] nonrec theorem pi_univ [∀ i, SigmaFinite (μ i)] : Measure.pi μ univ = ∏ i, μ i univ := by rw [← pi_univ, pi_pi μ] @[simp] lemma pi_singleton [∀ i, SigmaFinite (μ i)] (f : ∀ i, α i) : Measure.pi μ {f} = ∏ i, μ i {f i} := by simpa [Set.univ_pi_singleton, -pi_pi] using pi_pi μ fun i ↦ {f i} instance pi.instIsFiniteMeasure [∀ i, IsFiniteMeasure (μ i)] : IsFiniteMeasure (Measure.pi μ) := ⟨Measure.pi_univ μ ▸ ENNReal.prod_lt_top (fun i _ ↦ measure_lt_top (μ i) _)⟩ instance {α : ι → Type*} [∀ i, MeasureSpace (α i)] [∀ i, IsFiniteMeasure (volume : Measure (α i))] : IsFiniteMeasure (volume : Measure (∀ i, α i)) := pi.instIsFiniteMeasure _ instance pi.instIsProbabilityMeasure [∀ i, IsProbabilityMeasure (μ i)] : IsProbabilityMeasure (Measure.pi μ) := ⟨by simp only [Measure.pi_univ, measure_univ, Finset.prod_const_one]⟩ instance {α : ι → Type*} [∀ i, MeasureSpace (α i)] [∀ i, IsProbabilityMeasure (volume : Measure (α i))] : IsProbabilityMeasure (volume : Measure (∀ i, α i)) := pi.instIsProbabilityMeasure _ variable [∀ i, SigmaFinite (μ i)] theorem pi_ball [∀ i, MetricSpace (α i)] (x : ∀ i, α i) {r : ℝ} (hr : 0 < r) : Measure.pi μ (Metric.ball x r) = ∏ i, μ i (Metric.ball (x i) r) := by rw [ball_pi _ hr, pi_pi] theorem pi_closedBall [∀ i, MetricSpace (α i)] (x : ∀ i, α i) {r : ℝ} (hr : 0 ≤ r) : Measure.pi μ (Metric.closedBall x r) = ∏ i, μ i (Metric.closedBall (x i) r) := by rw [closedBall_pi _ hr, pi_pi] instance pi.sigmaFinite : SigmaFinite (Measure.pi μ) := (FiniteSpanningSetsIn.pi fun i => (μ i).toFiniteSpanningSetsIn).sigmaFinite instance {α : ι → Type*} [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] : SigmaFinite (volume : Measure (∀ i, α i)) := pi.sigmaFinite _ theorem pi_of_empty {α : Type*} [Fintype α] [IsEmpty α] {β : α → Type*} {m : ∀ a, MeasurableSpace (β a)} (μ : ∀ a : α, Measure (β a)) (x : ∀ a, β a := isEmptyElim) : Measure.pi μ = dirac x := by haveI : ∀ a, SigmaFinite (μ a) := isEmptyElim refine pi_eq fun s _ => ?_ rw [Fintype.prod_empty, dirac_apply_of_mem] exact isEmptyElim (α := α) lemma volume_pi_eq_dirac {ι : Type*} [Fintype ι] [IsEmpty ι] {α : ι → Type*} [∀ i, MeasureSpace (α i)] (x : ∀ a, α a := isEmptyElim) : (volume : Measure (∀ i, α i)) = Measure.dirac x := Measure.pi_of_empty _ _ @[simp] theorem pi_empty_univ {α : Type*} [Fintype α] [IsEmpty α] {β : α → Type*} {m : ∀ α, MeasurableSpace (β α)} (μ : ∀ a : α, Measure (β a)) : Measure.pi μ (Set.univ) = 1 := by rw [pi_of_empty, measure_univ] theorem pi_eval_preimage_null {i : ι} {s : Set (α i)} (hs : μ i s = 0) : Measure.pi μ (eval i ⁻¹' s) = 0 := by classical -- WLOG, `s` is measurable rcases exists_measurable_superset_of_null hs with ⟨t, hst, _, hμt⟩ suffices Measure.pi μ (eval i ⁻¹' t) = 0 from measure_mono_null (preimage_mono hst) this -- Now rewrite it as `Set.pi`, and apply `pi_pi` rw [← univ_pi_update_univ, pi_pi] apply Finset.prod_eq_zero (Finset.mem_univ i) simp [hμt] theorem quasiMeasurePreserving_eval (i : ι) : QuasiMeasurePreserving (Function.eval i) (Measure.pi μ) (μ i) := by classical refine ⟨by fun_prop, AbsolutelyContinuous.mk fun s hs h2s => ?_⟩ rw [map_apply (by fun_prop) hs, pi_eval_preimage_null μ h2s] lemma pi_map_eval [DecidableEq ι] (i : ι) : (Measure.pi μ).map (Function.eval i) = (∏ j ∈ Finset.univ.erase i, μ j Set.univ) • (μ i) := by ext s hs classical rw [Measure.map_apply (measurable_pi_apply i) hs, ← Set.univ_pi_update_univ, Measure.pi_pi, Measure.smul_apply, smul_eq_mul, ← Finset.prod_erase_mul _ _ (a := i) (by simp)] congrm ?_ * ?_ swap; · simp refine Finset.prod_congr rfl fun j hj ↦ ?_ simp [Function.update, Finset.ne_of_mem_erase hj] lemma pi_map_pi {X Y : ι → Type*} {mX : ∀ i, MeasurableSpace (X i)} {μ : (i : ι) → Measure (X i)} [∀ i, MeasurableSpace (Y i)] {f : (i : ι) → X i → Y i} [hμ : ∀ i, SigmaFinite ((μ i).map (f i))] (hf : ∀ i, AEMeasurable (f i) (μ i)) : (Measure.pi μ).map (fun x i ↦ (f i (x i))) = Measure.pi (fun i ↦ (μ i).map (f i)) := by have (i : ι) := (hμ i).of_map _ (hf i) refine (pi_eq fun s hs ↦ ?_).symm rw [map_apply_of_aemeasurable _ (.univ_pi hs)] swap · exact aemeasurable_pi_lambda _ fun i ↦ (hf i).comp_quasiMeasurePreserving (quasiMeasurePreserving_eval _ i) have : (fun (x : Π i, X i) i ↦ f i (x i)) ⁻¹' (Set.univ.pi s) = Set.univ.pi (fun i ↦ (f i) ⁻¹' (s i)) := by ext x; simp rw [this, pi_pi] congr with i rw [map_apply_of_aemeasurable (hf i) (hs i)] omit [∀ i, SigmaFinite (μ i)] in lemma _root_.MeasureTheory.measurePreserving_eval [∀ i, IsProbabilityMeasure (μ i)] (i : ι) : MeasurePreserving (Function.eval i) (Measure.pi μ) (μ i) := by refine ⟨measurable_pi_apply i, ?_⟩ classical rw [Measure.pi_map_eval, Finset.prod_eq_one, one_smul] exact fun _ _ ↦ measure_univ theorem pi_hyperplane (i : ι) [NoAtoms (μ i)] (x : α i) : Measure.pi μ { f : ∀ i, α i | f i = x } = 0 := show Measure.pi μ (eval i ⁻¹' {x}) = 0 from pi_eval_preimage_null _ (measure_singleton x) theorem ae_eval_ne (i : ι) [NoAtoms (μ i)] (x : α i) : ∀ᵐ y : ∀ i, α i ∂Measure.pi μ, y i ≠ x := compl_mem_ae_iff.2 (pi_hyperplane μ i x) theorem restrict_pi_pi (s : (i : ι) → Set (α i)) : (Measure.pi μ).restrict (Set.univ.pi fun i ↦ s i) = .pi (fun i ↦ (μ i).restrict (s i)) := by refine (pi_eq fun _ h ↦ ?_).symm simp_rw [restrict_apply (MeasurableSet.univ_pi h), restrict_apply (h _), ← Set.pi_inter_distrib, pi_pi] variable {μ} theorem tendsto_eval_ae_ae {i : ι} : Tendsto (eval i) (ae (Measure.pi μ)) (ae (μ i)) := fun _ hs => pi_eval_preimage_null μ hs theorem ae_pi_le_pi : ae (Measure.pi μ) ≤ Filter.pi fun i => ae (μ i) := le_iInf fun _ => tendsto_eval_ae_ae.le_comap theorem ae_eq_pi {β : ι → Type*} {f f' : ∀ i, α i → β i} (h : ∀ i, f i =ᵐ[μ i] f' i) : (fun (x : ∀ i, α i) i => f i (x i)) =ᵐ[Measure.pi μ] fun x i => f' i (x i) := (eventually_all.2 fun i => tendsto_eval_ae_ae.eventually (h i)).mono fun _ hx => funext hx theorem ae_le_pi {β : ι → Type*} [∀ i, Preorder (β i)] {f f' : ∀ i, α i → β i} (h : ∀ i, f i ≤ᵐ[μ i] f' i) : (fun (x : ∀ i, α i) i => f i (x i)) ≤ᵐ[Measure.pi μ] fun x i => f' i (x i) := (eventually_all.2 fun i => tendsto_eval_ae_ae.eventually (h i)).mono fun _ hx => hx theorem ae_le_set_pi {I : Set ι} {s t : ∀ i, Set (α i)} (h : ∀ i ∈ I, s i ≤ᵐ[μ i] t i) : Set.pi I s ≤ᵐ[Measure.pi μ] Set.pi I t := ((eventually_all_finite I.toFinite).2 fun i hi => tendsto_eval_ae_ae.eventually (h i hi)).mono fun _ hst hx i hi => hst i hi <| hx i hi theorem ae_eq_set_pi {I : Set ι} {s t : ∀ i, Set (α i)} (h : ∀ i ∈ I, s i =ᵐ[μ i] t i) : Set.pi I s =ᵐ[Measure.pi μ] Set.pi I t := (ae_le_set_pi fun i hi => (h i hi).le).antisymm (ae_le_set_pi fun i hi => (h i hi).symm.le) lemma pi_map_piCongrLeft [hι' : Fintype ι'] (e : ι ≃ ι') {β : ι' → Type*} [∀ i, MeasurableSpace (β i)] (μ : (i : ι') → Measure (β i)) [∀ i, SigmaFinite (μ i)] : (Measure.pi fun i ↦ μ (e i)).map (MeasurableEquiv.piCongrLeft (fun i ↦ β i) e) = Measure.pi μ := by let e_meas : ((b : ι) → β (e b)) ≃ᵐ ((a : ι') → β a) := MeasurableEquiv.piCongrLeft (fun i ↦ β i) e refine Measure.pi_eq (fun s _ ↦ ?_) |>.symm rw [e_meas.measurableEmbedding.map_apply] let s' : (i : ι) → Set (β (e i)) := fun i ↦ s (e i) have : e_meas ⁻¹' pi univ s = pi univ s' := by ext x simp only [mem_preimage, Set.mem_pi, mem_univ, forall_true_left, s'] refine (e.forall_congr ?_).symm intro i rw [MeasurableEquiv.piCongrLeft_apply_apply e x i] rw [this, pi_pi, Finset.prod_equiv e.symm] · simp only [Finset.mem_univ, implies_true] intro i _ simp only [s'] congr all_goals rw [e.apply_symm_apply] lemma pi_map_piOptionEquivProd {β : Option ι → Type*} [∀ i, MeasurableSpace (β i)] (μ : (i : Option ι) → Measure (β i)) [∀ (i : Option ι), SigmaFinite (μ i)] : ((Measure.pi fun i ↦ μ (some i)).prod (μ none)).map (MeasurableEquiv.piOptionEquivProd β).symm = Measure.pi μ := by refine pi_eq (fun s _ ↦ ?_) |>.symm let e_meas : ((i : ι) → β (some i)) × β none ≃ᵐ ((i : Option ι) → β i) := MeasurableEquiv.piOptionEquivProd β |>.symm have me := MeasurableEquiv.measurableEmbedding e_meas have : e_meas ⁻¹' pi univ s = (pi univ (fun i ↦ s (some i))) ×ˢ (s none) := by ext x simp only [mem_preimage, Set.mem_pi, mem_univ, forall_true_left, mem_prod] refine ⟨by tauto, fun _ i ↦ ?_⟩ rcases i <;> tauto simp only [e_meas, me.map_apply, univ_option, Finset.prod_insertNone, this, prod_prod, pi_pi, mul_comm] section Intervals variable [∀ i, PartialOrder (α i)] [∀ i, NoAtoms (μ i)] theorem pi_Iio_ae_eq_pi_Iic {s : Set ι} {f : ∀ i, α i} : (pi s fun i => Iio (f i)) =ᵐ[Measure.pi μ] pi s fun i => Iic (f i) := ae_eq_set_pi fun _ _ => Iio_ae_eq_Iic theorem pi_Ioi_ae_eq_pi_Ici {s : Set ι} {f : ∀ i, α i} : (pi s fun i => Ioi (f i)) =ᵐ[Measure.pi μ] pi s fun i => Ici (f i) := ae_eq_set_pi fun _ _ => Ioi_ae_eq_Ici theorem univ_pi_Iio_ae_eq_Iic {f : ∀ i, α i} : (pi univ fun i => Iio (f i)) =ᵐ[Measure.pi μ] Iic f := by rw [← pi_univ_Iic]; exact pi_Iio_ae_eq_pi_Iic theorem univ_pi_Ioi_ae_eq_Ici {f : ∀ i, α i} : (pi univ fun i => Ioi (f i)) =ᵐ[Measure.pi μ] Ici f := by rw [← pi_univ_Ici]; exact pi_Ioi_ae_eq_pi_Ici theorem pi_Ioo_ae_eq_pi_Icc {s : Set ι} {f g : ∀ i, α i} : (pi s fun i => Ioo (f i) (g i)) =ᵐ[Measure.pi μ] pi s fun i => Icc (f i) (g i) := ae_eq_set_pi fun _ _ => Ioo_ae_eq_Icc theorem pi_Ioo_ae_eq_pi_Ioc {s : Set ι} {f g : ∀ i, α i} : (pi s fun i => Ioo (f i) (g i)) =ᵐ[Measure.pi μ] pi s fun i => Ioc (f i) (g i) := ae_eq_set_pi fun _ _ => Ioo_ae_eq_Ioc theorem univ_pi_Ioo_ae_eq_Icc {f g : ∀ i, α i} : (pi univ fun i => Ioo (f i) (g i)) =ᵐ[Measure.pi μ] Icc f g := by rw [← pi_univ_Icc]; exact pi_Ioo_ae_eq_pi_Icc theorem pi_Ioc_ae_eq_pi_Icc {s : Set ι} {f g : ∀ i, α i} : (pi s fun i => Ioc (f i) (g i)) =ᵐ[Measure.pi μ] pi s fun i => Icc (f i) (g i) := ae_eq_set_pi fun _ _ => Ioc_ae_eq_Icc theorem univ_pi_Ioc_ae_eq_Icc {f g : ∀ i, α i} : (pi univ fun i => Ioc (f i) (g i)) =ᵐ[Measure.pi μ] Icc f g := by rw [← pi_univ_Icc]; exact pi_Ioc_ae_eq_pi_Icc theorem pi_Ico_ae_eq_pi_Icc {s : Set ι} {f g : ∀ i, α i} : (pi s fun i => Ico (f i) (g i)) =ᵐ[Measure.pi μ] pi s fun i => Icc (f i) (g i) := ae_eq_set_pi fun _ _ => Ico_ae_eq_Icc theorem univ_pi_Ico_ae_eq_Icc {f g : ∀ i, α i} : (pi univ fun i => Ico (f i) (g i)) =ᵐ[Measure.pi μ] Icc f g := by rw [← pi_univ_Icc]; exact pi_Ico_ae_eq_pi_Icc end Intervals /-- If one of the measures `μ i` has no atoms, them `Measure.pi µ` has no atoms. The instance below assumes that all `μ i` have no atoms. -/ theorem pi_noAtoms (i : ι) [NoAtoms (μ i)] : NoAtoms (Measure.pi μ) := ⟨fun x => flip measure_mono_null (pi_hyperplane μ i (x i)) (singleton_subset_iff.2 rfl)⟩ instance pi_noAtoms' [h : Nonempty ι] [∀ i, NoAtoms (μ i)] : NoAtoms (Measure.pi μ) := h.elim fun i => pi_noAtoms i instance {α : ι → Type*} [Nonempty ι] [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] [∀ i, NoAtoms (volume : Measure (α i))] : NoAtoms (volume : Measure (∀ i, α i)) := pi_noAtoms' instance pi.isLocallyFiniteMeasure [∀ i, TopologicalSpace (α i)] [∀ i, IsLocallyFiniteMeasure (μ i)] : IsLocallyFiniteMeasure (Measure.pi μ) := by refine ⟨fun x => ?_⟩ choose s hxs ho hμ using fun i => (μ i).exists_isOpen_measure_lt_top (x i) refine ⟨pi univ s, set_pi_mem_nhds finite_univ fun i _ => IsOpen.mem_nhds (ho i) (hxs i), ?_⟩ rw [pi_pi] exact ENNReal.prod_lt_top fun i _ => hμ i instance {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, MeasureSpace (X i)] [∀ i, SigmaFinite (volume : Measure (X i))] [∀ i, IsLocallyFiniteMeasure (volume : Measure (X i))] : IsLocallyFiniteMeasure (volume : Measure (∀ i, X i)) := pi.isLocallyFiniteMeasure variable (μ) @[to_additive] instance pi.isMulLeftInvariant [∀ i, Group (α i)] [∀ i, MeasurableMul (α i)] [∀ i, IsMulLeftInvariant (μ i)] : IsMulLeftInvariant (Measure.pi μ) := by refine ⟨fun v => (pi_eq fun s hs => ?_).symm⟩ rw [map_apply (measurable_const_mul _) (MeasurableSet.univ_pi hs), show (v * ·) ⁻¹' univ.pi s = univ.pi fun i => (v i * ·) ⁻¹' s i by rfl, pi_pi] simp_rw [measure_preimage_mul] @[to_additive] instance {G : ι → Type*} [∀ i, Group (G i)] [∀ i, MeasureSpace (G i)] [∀ i, MeasurableMul (G i)] [∀ i, SigmaFinite (volume : Measure (G i))] [∀ i, IsMulLeftInvariant (volume : Measure (G i))] : IsMulLeftInvariant (volume : Measure (∀ i, G i)) := pi.isMulLeftInvariant _ @[to_additive] instance pi.isMulRightInvariant [∀ i, Group (α i)] [∀ i, MeasurableMul (α i)] [∀ i, IsMulRightInvariant (μ i)] : IsMulRightInvariant (Measure.pi μ) := by refine ⟨fun v => (pi_eq fun s hs => ?_).symm⟩ rw [map_apply (measurable_mul_const _) (MeasurableSet.univ_pi hs), show (· * v) ⁻¹' univ.pi s = univ.pi fun i => (· * v i) ⁻¹' s i by rfl, pi_pi] simp_rw [measure_preimage_mul_right] @[to_additive] instance {G : ι → Type*} [∀ i, Group (G i)] [∀ i, MeasureSpace (G i)] [∀ i, MeasurableMul (G i)] [∀ i, SigmaFinite (volume : Measure (G i))] [∀ i, IsMulRightInvariant (volume : Measure (G i))] : IsMulRightInvariant (volume : Measure (∀ i, G i)) := pi.isMulRightInvariant _ @[to_additive] instance pi.isInvInvariant [∀ i, Group (α i)] [∀ i, MeasurableInv (α i)] [∀ i, IsInvInvariant (μ i)] : IsInvInvariant (Measure.pi μ) := by refine ⟨(Measure.pi_eq fun s hs => ?_).symm⟩ have A : Inv.inv ⁻¹' pi univ s = Set.pi univ fun i => Inv.inv ⁻¹' s i := by ext; simp simp_rw [Measure.inv, Measure.map_apply measurable_inv (MeasurableSet.univ_pi hs), A, pi_pi, measure_preimage_inv] @[to_additive] instance {G : ι → Type*} [∀ i, Group (G i)] [∀ i, MeasureSpace (G i)] [∀ i, MeasurableInv (G i)] [∀ i, SigmaFinite (volume : Measure (G i))] [∀ i, IsInvInvariant (volume : Measure (G i))] : IsInvInvariant (volume : Measure (∀ i, G i)) := pi.isInvInvariant _ instance pi.isOpenPosMeasure [∀ i, TopologicalSpace (α i)] [∀ i, IsOpenPosMeasure (μ i)] : IsOpenPosMeasure (MeasureTheory.Measure.pi μ) := by constructor rintro U U_open ⟨a, ha⟩ obtain ⟨s, ⟨hs, hsU⟩⟩ := isOpen_pi_iff'.1 U_open a ha refine ne_of_gt (lt_of_lt_of_le ?_ (measure_mono hsU)) simp only [pi_pi] rw [CanonicallyOrderedAdd.prod_pos] intro i _ apply (hs i).1.measure_pos (μ i) ⟨a i, (hs i).2⟩ instance {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, MeasureSpace (X i)] [∀ i, IsOpenPosMeasure (volume : Measure (X i))] [∀ i, SigmaFinite (volume : Measure (X i))] : IsOpenPosMeasure (volume : Measure (∀ i, X i)) := pi.isOpenPosMeasure _ instance pi.isFiniteMeasureOnCompacts [∀ i, TopologicalSpace (α i)] [∀ i, IsFiniteMeasureOnCompacts (μ i)] : IsFiniteMeasureOnCompacts (MeasureTheory.Measure.pi μ) := by constructor intro K hK suffices Measure.pi μ (Set.univ.pi fun j => Function.eval j '' K) < ⊤ by exact lt_of_le_of_lt (measure_mono (univ.subset_pi_eval_image K)) this rw [Measure.pi_pi] refine WithTop.prod_lt_top ?_ exact fun i _ => IsCompact.measure_lt_top (IsCompact.image hK (continuous_apply i)) instance {X : ι → Type*} [∀ i, MeasureSpace (X i)] [∀ i, TopologicalSpace (X i)] [∀ i, SigmaFinite (volume : Measure (X i))] [∀ i, IsFiniteMeasureOnCompacts (volume : Measure (X i))] : IsFiniteMeasureOnCompacts (volume : Measure (∀ i, X i)) := pi.isFiniteMeasureOnCompacts _ @[to_additive] instance pi.isHaarMeasure [∀ i, Group (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, IsHaarMeasure (μ i)] [∀ i, MeasurableMul (α i)] : IsHaarMeasure (Measure.pi μ) where @[to_additive] instance {G : ι → Type*} [∀ i, Group (G i)] [∀ i, MeasureSpace (G i)] [∀ i, MeasurableMul (G i)] [∀ i, TopologicalSpace (G i)] [∀ i, SigmaFinite (volume : Measure (G i))] [∀ i, IsHaarMeasure (volume : Measure (G i))] : IsHaarMeasure (volume : Measure (∀ i, G i)) := pi.isHaarMeasure _ end Measure theorem volume_pi [∀ i, MeasureSpace (α i)] : (volume : Measure (∀ i, α i)) = Measure.pi fun _ => volume := rfl theorem volume_pi_pi [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] (s : ∀ i, Set (α i)) : volume (pi univ s) = ∏ i, volume (s i) := Measure.pi_pi (fun _ => volume) s theorem volume_pi_ball [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] [∀ i, MetricSpace (α i)] (x : ∀ i, α i) {r : ℝ} (hr : 0 < r) : volume (Metric.ball x r) = ∏ i, volume (Metric.ball (x i) r) := Measure.pi_ball _ _ hr theorem volume_pi_closedBall [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] [∀ i, MetricSpace (α i)] (x : ∀ i, α i) {r : ℝ} (hr : 0 ≤ r) : volume (Metric.closedBall x r) = ∏ i, volume (Metric.closedBall (x i) r) := Measure.pi_closedBall _ _ hr open Measure /-- We intentionally restrict this only to the nondependent function space, since type-class inference cannot find an instance for `ι → ℝ` when this is stated for dependent function spaces. -/ @[to_additive /-- We intentionally restrict this only to the nondependent function space, since type-class inference cannot find an instance for `ι → ℝ` when this is stated for dependent function spaces. -/] instance Pi.isMulLeftInvariant_volume {α} [Group α] [MeasureSpace α] [SigmaFinite (volume : Measure α)] [MeasurableMul α] [IsMulLeftInvariant (volume : Measure α)] : IsMulLeftInvariant (volume : Measure (ι → α)) := pi.isMulLeftInvariant _ /-- We intentionally restrict this only to the nondependent function space, since type-class inference cannot find an instance for `ι → ℝ` when this is stated for dependent function spaces. -/ @[to_additive /-- We intentionally restrict this only to the nondependent function space, since type-class inference cannot find an instance for `ι → ℝ` when this is stated for dependent function spaces. -/] instance Pi.isInvInvariant_volume {α} [Group α] [MeasureSpace α] [SigmaFinite (volume : Measure α)] [MeasurableInv α] [IsInvInvariant (volume : Measure α)] : IsInvInvariant (volume : Measure (ι → α)) := pi.isInvInvariant _ /-! ### Measure-preserving equivalences In this section we prove that some measurable equivalences (e.g., between `Fin 1 → α` and `α` or between `Fin 2 → α` and `α × α`) preserve measure or volume. These lemmas can be used to prove that measures of corresponding sets (images or preimages) have equal measures and functions `f ∘ e` and `f` have equal integrals, see lemmas in the `MeasureTheory.measurePreserving` prefix. -/ section MeasurePreserving variable {m : ∀ i, MeasurableSpace (α i)} (μ : ∀ i, Measure (α i)) [∀ i, SigmaFinite (μ i)] variable [Fintype ι'] theorem measurePreserving_piEquivPiSubtypeProd (p : ι → Prop) [DecidablePred p] : MeasurePreserving (MeasurableEquiv.piEquivPiSubtypeProd α p) (Measure.pi μ) ((Measure.pi fun i : Subtype p => μ i).prod (Measure.pi fun i => μ i)) := by set e := (MeasurableEquiv.piEquivPiSubtypeProd α p).symm refine MeasurePreserving.symm e ?_ refine ⟨e.measurable, (pi_eq fun s _ => ?_).symm⟩ have : e ⁻¹' pi univ s = (pi univ fun i : { i // p i } => s i) ×ˢ pi univ fun i : { i // ¬p i } => s i := Equiv.preimage_piEquivPiSubtypeProd_symm_pi p s rw [e.map_apply, this, prod_prod, pi_pi, pi_pi] exact Fintype.prod_subtype_mul_prod_subtype p fun i => μ i (s i) theorem volume_preserving_piEquivPiSubtypeProd (α : ι → Type*) [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] (p : ι → Prop) [DecidablePred p] : MeasurePreserving (MeasurableEquiv.piEquivPiSubtypeProd α p) := measurePreserving_piEquivPiSubtypeProd (fun _ => volume) p theorem measurePreserving_piCongrLeft (f : ι' ≃ ι) : MeasurePreserving (MeasurableEquiv.piCongrLeft α f) (Measure.pi fun i' => μ (f i')) (Measure.pi μ) where measurable := (MeasurableEquiv.piCongrLeft α f).measurable map_eq := by refine (pi_eq fun s _ => ?_).symm rw [MeasurableEquiv.map_apply, MeasurableEquiv.coe_piCongrLeft f, Equiv.piCongrLeft_preimage_univ_pi, pi_pi _ _, f.prod_comp (fun i => μ i (s i))] theorem volume_measurePreserving_piCongrLeft (α : ι → Type*) (f : ι' ≃ ι) [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] : MeasurePreserving (MeasurableEquiv.piCongrLeft α f) volume volume := measurePreserving_piCongrLeft (fun _ ↦ volume) f theorem measurePreserving_arrowProdEquivProdArrow (α β γ : Type*) [MeasurableSpace α] [MeasurableSpace β] [Fintype γ] (μ : γ → Measure α) (ν : γ → Measure β) [∀ i, SigmaFinite (μ i)] [∀ i, SigmaFinite (ν i)] : MeasurePreserving (MeasurableEquiv.arrowProdEquivProdArrow α β γ) (.pi fun i ↦ (μ i).prod (ν i)) ((Measure.pi fun i ↦ μ i).prod (Measure.pi fun i ↦ ν i)) where measurable := (MeasurableEquiv.arrowProdEquivProdArrow α β γ).measurable map_eq := by refine (FiniteSpanningSetsIn.ext ?_ (isPiSystem_pi.prod isPiSystem_pi) ((FiniteSpanningSetsIn.pi fun i ↦ (μ i).toFiniteSpanningSetsIn).prod (FiniteSpanningSetsIn.pi (fun i ↦ (ν i).toFiniteSpanningSetsIn))) ?_).symm · refine (generateFrom_eq_prod generateFrom_pi generateFrom_pi ?_ ?_).symm · exact (FiniteSpanningSetsIn.pi (fun i ↦ (μ i).toFiniteSpanningSetsIn)).isCountablySpanning · exact (FiniteSpanningSetsIn.pi (fun i ↦ (ν i).toFiniteSpanningSetsIn)).isCountablySpanning · rintro _ ⟨s, ⟨s, _, rfl⟩, ⟨_, ⟨t, _, rfl⟩, rfl⟩⟩ rw [MeasurableEquiv.map_apply, MeasurableEquiv.arrowProdEquivProdArrow, MeasurableEquiv.coe_mk] rw [show Equiv.arrowProdEquivProdArrow γ _ _ ⁻¹' (univ.pi s ×ˢ univ.pi t) = (univ.pi fun i ↦ s i ×ˢ t i) by ext; simp [Set.mem_pi, forall_and]] simp_rw [pi_pi, prod_prod, pi_pi, Finset.prod_mul_distrib] theorem volume_measurePreserving_arrowProdEquivProdArrow (α β γ : Type*) [MeasureSpace α] [MeasureSpace β] [Fintype γ] [SigmaFinite (volume : Measure α)] [SigmaFinite (volume : Measure β)] : MeasurePreserving (MeasurableEquiv.arrowProdEquivProdArrow α β γ) := measurePreserving_arrowProdEquivProdArrow α β γ (fun _ ↦ volume) (fun _ ↦ volume) theorem measurePreserving_sumPiEquivProdPi_symm {X : ι ⊕ ι' → Type*} {m : ∀ i, MeasurableSpace (X i)} (μ : ∀ i, Measure (X i)) [∀ i, SigmaFinite (μ i)] : MeasurePreserving (MeasurableEquiv.sumPiEquivProdPi X).symm ((Measure.pi fun i => μ (.inl i)).prod (Measure.pi fun i => μ (.inr i))) (Measure.pi μ) where measurable := (MeasurableEquiv.sumPiEquivProdPi X).symm.measurable map_eq := by refine (pi_eq fun s _ => ?_).symm simp_rw [MeasurableEquiv.map_apply, MeasurableEquiv.coe_sumPiEquivProdPi_symm, Equiv.sumPiEquivProdPi_symm_preimage_univ_pi, Measure.prod_prod, Measure.pi_pi, Fintype.prod_sum_type] theorem volume_measurePreserving_sumPiEquivProdPi_symm (X : ι ⊕ ι' → Type*) [∀ i, MeasureSpace (X i)] [∀ i, SigmaFinite (volume : Measure (X i))] : MeasurePreserving (MeasurableEquiv.sumPiEquivProdPi X).symm volume volume := measurePreserving_sumPiEquivProdPi_symm (fun _ ↦ volume) theorem measurePreserving_sumPiEquivProdPi {X : ι ⊕ ι' → Type*} {_m : ∀ i, MeasurableSpace (X i)} (μ : ∀ i, Measure (X i)) [∀ i, SigmaFinite (μ i)] : MeasurePreserving (MeasurableEquiv.sumPiEquivProdPi X) (Measure.pi μ) ((Measure.pi fun i => μ (.inl i)).prod (Measure.pi fun i => μ (.inr i))) := measurePreserving_sumPiEquivProdPi_symm μ |>.symm theorem volume_measurePreserving_sumPiEquivProdPi (X : ι ⊕ ι' → Type*) [∀ i, MeasureSpace (X i)] [∀ i, SigmaFinite (volume : Measure (X i))] : MeasurePreserving (MeasurableEquiv.sumPiEquivProdPi X) volume volume := measurePreserving_sumPiEquivProdPi (fun _ ↦ volume) theorem measurePreserving_piFinSuccAbove {n : ℕ} {α : Fin (n + 1) → Type u} {m : ∀ i, MeasurableSpace (α i)} (μ : ∀ i, Measure (α i)) [∀ i, SigmaFinite (μ i)] (i : Fin (n + 1)) : MeasurePreserving (MeasurableEquiv.piFinSuccAbove α i) (Measure.pi μ) ((μ i).prod <| Measure.pi fun j => μ (i.succAbove j)) := by set e := (MeasurableEquiv.piFinSuccAbove α i).symm refine MeasurePreserving.symm e ?_ refine ⟨e.measurable, (pi_eq fun s _ => ?_).symm⟩ rw [e.map_apply, i.prod_univ_succAbove _, ← pi_pi, ← prod_prod] congr 1 with ⟨x, f⟩ simp [e, i.forall_iff_succAbove] theorem volume_preserving_piFinSuccAbove {n : ℕ} (α : Fin (n + 1) → Type u) [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] (i : Fin (n + 1)) : MeasurePreserving (MeasurableEquiv.piFinSuccAbove α i) := measurePreserving_piFinSuccAbove (fun _ => volume) i theorem measurePreserving_piUnique {X : ι → Type*} [Unique ι] {m : ∀ i, MeasurableSpace (X i)} (μ : ∀ i, Measure (X i)) : MeasurePreserving (MeasurableEquiv.piUnique X) (Measure.pi μ) (μ default) where measurable := (MeasurableEquiv.piUnique X).measurable map_eq := by set e := MeasurableEquiv.piUnique X have : (piPremeasure fun i => (μ i).toOuterMeasure) = Measure.map e.symm (μ default) := by ext1 s rw [piPremeasure, Fintype.prod_unique, e.symm.map_apply, coe_toOuterMeasure] congr 1; exact e.toEquiv.image_eq_preimage_symm s simp_rw [Measure.pi, OuterMeasure.pi, this, ← coe_toOuterMeasure, boundedBy_eq_self, toOuterMeasure_toMeasure, MeasurableEquiv.map_map_symm] theorem volume_preserving_piUnique (X : ι → Type*) [Unique ι] [∀ i, MeasureSpace (X i)] : MeasurePreserving (MeasurableEquiv.piUnique X) volume volume := measurePreserving_piUnique _ theorem measurePreserving_funUnique {β : Type u} {_m : MeasurableSpace β} (μ : Measure β) (α : Type v) [Unique α] : MeasurePreserving (MeasurableEquiv.funUnique α β) (Measure.pi fun _ : α => μ) μ := measurePreserving_piUnique _ theorem volume_preserving_funUnique (α : Type u) (β : Type v) [Unique α] [MeasureSpace β] : MeasurePreserving (MeasurableEquiv.funUnique α β) volume volume := measurePreserving_funUnique volume α theorem measurePreserving_piFinTwo {α : Fin 2 → Type u} {m : ∀ i, MeasurableSpace (α i)} (μ : ∀ i, Measure (α i)) [∀ i, SigmaFinite (μ i)] : MeasurePreserving (MeasurableEquiv.piFinTwo α) (Measure.pi μ) ((μ 0).prod (μ 1)) := by refine ⟨MeasurableEquiv.measurable _, (Measure.prod_eq fun s t _ _ => ?_).symm⟩ rw [MeasurableEquiv.map_apply, MeasurableEquiv.piFinTwo_apply, Fin.preimage_apply_01_prod, Measure.pi_pi, Fin.prod_univ_two] rfl theorem volume_preserving_piFinTwo (α : Fin 2 → Type u) [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] : MeasurePreserving (MeasurableEquiv.piFinTwo α) volume volume := measurePreserving_piFinTwo _ theorem measurePreserving_finTwoArrow_vec {α : Type u} {_ : MeasurableSpace α} (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν] : MeasurePreserving MeasurableEquiv.finTwoArrow (Measure.pi ![μ, ν]) (μ.prod ν) := haveI : ∀ i, SigmaFinite (![μ, ν] i) := Fin.forall_fin_two.2 ⟨‹_›, ‹_›⟩ measurePreserving_piFinTwo _ theorem measurePreserving_finTwoArrow {α : Type u} {m : MeasurableSpace α} (μ : Measure α) [SigmaFinite μ] : MeasurePreserving MeasurableEquiv.finTwoArrow (Measure.pi fun _ => μ) (μ.prod μ) := by simpa only [Matrix.vec_single_eq_const, Matrix.vecCons_const] using measurePreserving_finTwoArrow_vec μ μ theorem volume_preserving_finTwoArrow (α : Type u) [MeasureSpace α] [SigmaFinite (volume : Measure α)] : MeasurePreserving (@MeasurableEquiv.finTwoArrow α _) volume volume := measurePreserving_finTwoArrow volume theorem measurePreserving_pi_empty {ι : Type u} {α : ι → Type v} [Fintype ι] [IsEmpty ι] {m : ∀ i, MeasurableSpace (α i)} (μ : ∀ i, Measure (α i)) : MeasurePreserving (MeasurableEquiv.ofUniqueOfUnique (∀ i, α i) Unit) (Measure.pi μ) (Measure.dirac ()) := by set e := MeasurableEquiv.ofUniqueOfUnique (∀ i, α i) Unit refine ⟨e.measurable, ?_⟩ rw [Measure.pi_of_empty, Measure.map_dirac e.measurable] theorem volume_preserving_pi_empty {ι : Type u} (α : ι → Type v) [Fintype ι] [IsEmpty ι] [∀ i, MeasureSpace (α i)] : MeasurePreserving (MeasurableEquiv.ofUniqueOfUnique (∀ i, α i) Unit) volume volume := measurePreserving_pi_empty fun _ => volume theorem measurePreserving_piFinsetUnion {ι : Type*} {α : ι → Type*} {_ : ∀ i, MeasurableSpace (α i)} [DecidableEq ι] {s t : Finset ι} (h : Disjoint s t) (μ : ∀ i, Measure (α i)) [∀ i, SigmaFinite (μ i)] : MeasurePreserving (MeasurableEquiv.piFinsetUnion α h) ((Measure.pi fun i : s ↦ μ i).prod (Measure.pi fun i : t ↦ μ i)) (Measure.pi fun i : ↥(s ∪ t) ↦ μ i) := let e := Equiv.Finset.union s t h measurePreserving_piCongrLeft (fun i : ↥(s ∪ t) ↦ μ i) e |>.comp <| measurePreserving_sumPiEquivProdPi_symm fun b ↦ μ (e b) theorem volume_preserving_piFinsetUnion {ι : Type*} [DecidableEq ι] (α : ι → Type*) {s t : Finset ι} (h : Disjoint s t) [∀ i, MeasureSpace (α i)] [∀ i, SigmaFinite (volume : Measure (α i))] : MeasurePreserving (MeasurableEquiv.piFinsetUnion α h) volume volume := measurePreserving_piFinsetUnion h (fun _ ↦ volume) theorem measurePreserving_pi {ι : Type*} [Fintype ι] {α : ι → Type v} {β : ι → Type*} [∀ i, MeasurableSpace (α i)] [∀ i, MeasurableSpace (β i)] (μ : (i : ι) → Measure (α i)) (ν : (i : ι) → Measure (β i)) {f : (i : ι) → (α i) → (β i)} [hν : ∀ i, SigmaFinite (ν i)] (hf : ∀ i, MeasurePreserving (f i) (μ i) (ν i)) : MeasurePreserving (fun a i ↦ f i (a i)) (Measure.pi μ) (Measure.pi ν) where measurable := measurable_pi_iff.mpr <| fun i ↦ (hf i).measurable.comp (measurable_pi_apply i) map_eq := by have (i : ι) : SigmaFinite ((μ i).map (f i)) := (hf i).map_eq ▸ hν i rw [pi_map_pi (fun i ↦ (hf i).aemeasurable)] exact congrArg _ <| funext fun i ↦ (hf i).map_eq theorem volume_preserving_pi {α' β' : ι → Type*} [∀ i, MeasureSpace (α' i)] [∀ i, MeasureSpace (β' i)] [∀ i, SigmaFinite (volume : Measure (β' i))] {f : (i : ι) → (α' i) → (β' i)} (hf : ∀ i, MeasurePreserving (f i)) : MeasurePreserving (fun (a : (i : ι) → α' i) (i : ι) ↦ (f i) (a i)) := measurePreserving_pi _ _ hf /-- The measurable equiv `(α₁ → β₁) ≃ᵐ (α₂ → β₂)` induced by `α₁ ≃ α₂` and `β₁ ≃ᵐ β₂` is measure preserving. -/ theorem measurePreserving_arrowCongr' {α₁ β₁ α₂ β₂ : Type*} [Fintype α₁] [Fintype α₂] [MeasurableSpace β₁] [MeasurableSpace β₂] (μ : α₁ → Measure β₁) (ν : α₂ → Measure β₂) [∀ i, SigmaFinite (ν i)] (eα : α₁ ≃ α₂) (eβ : β₁ ≃ᵐ β₂) (hm : ∀ i, MeasurePreserving eβ (μ i) (ν (eα i))) : MeasurePreserving (MeasurableEquiv.arrowCongr' eα eβ) (Measure.pi fun i ↦ μ i) (Measure.pi fun i ↦ ν i) := by classical convert (measurePreserving_piCongrLeft (fun i : α₂ ↦ ν i) eα).comp (measurePreserving_pi μ (fun i : α₁ ↦ ν (eα i)) hm) simp only [MeasurableEquiv.arrowCongr', Equiv.arrowCongr', Equiv.arrowCongr, EquivLike.coe_coe, comp_def, MeasurableEquiv.coe_mk, Equiv.coe_fn_mk, MeasurableEquiv.piCongrLeft, Equiv.piCongrLeft, Equiv.symm_symm, Equiv.piCongrLeft', eq_rec_constant, Equiv.coe_fn_symm_mk] /-- The measurable equiv `(α₁ → β₁) ≃ᵐ (α₂ → β₂)` induced by `α₁ ≃ α₂` and `β₁ ≃ᵐ β₂` is volume preserving. -/ theorem volume_preserving_arrowCongr' {α₁ β₁ α₂ β₂ : Type*} [Fintype α₁] [Fintype α₂] [MeasureSpace β₁] [MeasureSpace β₂] [SigmaFinite (volume : Measure β₂)] (hα : α₁ ≃ α₂) (hβ : β₁ ≃ᵐ β₂) (hm : MeasurePreserving hβ) : MeasurePreserving (MeasurableEquiv.arrowCongr' hα hβ) := measurePreserving_arrowCongr' (fun _ ↦ volume) (fun _ ↦ volume) hα hβ (fun _ ↦ hm) end MeasurePreserving end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/HaarToSphere.lean
import Mathlib.Algebra.Order.Field.Pointwise import Mathlib.Analysis.Normed.Module.Ball.RadialEquiv import Mathlib.Analysis.SpecialFunctions.Integrals.Basic import Mathlib.MeasureTheory.Integral.Prod import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar /-! # Generalized polar coordinate change Consider an `n`-dimensional normed space `E` and an additive Haar measure `μ` on `E`. Then `μ.toSphere` is the measure on the unit sphere such that `μ.toSphere s` equals `n • μ (Set.Ioo 0 1 • s)`. If `n ≠ 0`, then `μ` can be represented (up to `homeomorphUnitSphereProd`) as the product of `μ.toSphere` and the Lebesgue measure on `(0, +∞)` taken with density `fun r ↦ r ^ n`. One can think about this fact as a version of polar coordinate change formula for a general nontrivial normed space. -/ open Set Function Metric MeasurableSpace intervalIntegral open scoped Pointwise ENNReal NNReal local notation "dim" => Module.finrank ℝ noncomputable section namespace MeasureTheory variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [MeasurableSpace E] namespace Measure /-- If `μ` is an additive Haar measure on a normed space `E`, then `μ.toSphere` is the measure on the unit sphere in `E` such that `μ.toSphere s = Module.finrank ℝ E • μ (Set.Ioo (0 : ℝ) 1 • s)`. -/ def toSphere (μ : Measure E) : Measure (sphere (0 : E) 1) := dim E • ((μ.comap (Subtype.val ∘ (homeomorphUnitSphereProd E).symm)).restrict (univ ×ˢ Iio ⟨1, mem_Ioi.2 one_pos⟩)).fst variable (μ : Measure E) theorem toSphere_apply_aux (s : Set (sphere (0 : E) 1)) (r : Ioi (0 : ℝ)) : μ ((↑) '' (homeomorphUnitSphereProd E ⁻¹' s ×ˢ Iio r)) = μ (Ioo (0 : ℝ) r • ((↑) '' s)) := by rw [← image2_smul, image2_image_right, ← Homeomorph.image_symm, image_image, ← image_subtype_val_Ioi_Iio, image2_image_left, image2_swap, ← image_prod] rfl variable [BorelSpace E] theorem toSphere_apply' {s : Set (sphere (0 : E) 1)} (hs : MeasurableSet s) : μ.toSphere s = dim E * μ (Ioo (0 : ℝ) 1 • ((↑) '' s)) := by rw [toSphere, smul_apply, fst_apply hs, restrict_apply (measurable_fst hs), ((MeasurableEmbedding.subtype_coe (measurableSet_singleton _).compl).comp (Homeomorph.measurableEmbedding _)).comap_apply, image_comp, Homeomorph.image_symm, univ_prod, ← Set.prod_eq, nsmul_eq_mul, toSphere_apply_aux] theorem toSphere_apply_univ' : μ.toSphere univ = dim E * μ (ball 0 1 \ {0}) := by rw [μ.toSphere_apply' .univ, image_univ, Subtype.range_coe, Ioo_smul_sphere_zero] <;> simp variable [FiniteDimensional ℝ E] [μ.IsAddHaarMeasure] @[simp] theorem toSphere_apply_univ : μ.toSphere univ = dim E * μ (ball 0 1) := by nontriviality E rw [toSphere_apply_univ', measure_diff_null (measure_singleton _)] @[simp] theorem toSphere_real_apply_univ : μ.toSphere.real univ = dim E * μ.real (ball 0 1) := by simp [measureReal_def] theorem toSphere_eq_zero_iff_finrank : μ.toSphere = 0 ↔ dim E = 0 := by rw [← measure_univ_eq_zero, toSphere_apply_univ] simp [IsOpen.measure_ne_zero] theorem toSphere_eq_zero_iff : μ.toSphere = 0 ↔ Subsingleton E := μ.toSphere_eq_zero_iff_finrank.trans Module.finrank_zero_iff @[simp] theorem toSphere_ne_zero [Nontrivial E] : μ.toSphere ≠ 0 := by simp [toSphere_eq_zero_iff, not_subsingleton] instance : IsFiniteMeasure μ.toSphere where measure_univ_lt_top := by rw [toSphere_apply_univ'] exact ENNReal.mul_lt_top (ENNReal.natCast_lt_top _) <| measure_ball_lt_top.trans_le' <| measure_mono diff_subset /-- The measure on `(0, +∞)` that has density `(· ^ n)` with respect to the Lebesgue measure. -/ def volumeIoiPow (n : ℕ) : Measure (Ioi (0 : ℝ)) := .withDensity (.comap Subtype.val volume) fun r ↦ .ofReal (r.1 ^ n) lemma volumeIoiPow_apply_Iio (n : ℕ) (x : Ioi (0 : ℝ)) : volumeIoiPow n (Iio x) = ENNReal.ofReal (x.1 ^ (n + 1) / (n + 1)) := by have hr₀ : 0 ≤ x.1 := le_of_lt x.2 rw [volumeIoiPow, withDensity_apply _ measurableSet_Iio, setLIntegral_subtype measurableSet_Ioi _ fun a : ℝ ↦ .ofReal (a ^ n), image_subtype_val_Ioi_Iio, restrict_congr_set Ioo_ae_eq_Ioc, ← ofReal_integral_eq_lintegral_ofReal (intervalIntegrable_pow _).1, ← integral_of_le hr₀] · simp · filter_upwards [ae_restrict_mem measurableSet_Ioc] with y hy exact pow_nonneg hy.1.le _ /-- The intervals `(0, k + 1)` have finite measure `MeasureTheory.Measure.volumeIoiPow _` and cover the whole open ray `(0, +∞)`. -/ def finiteSpanningSetsIn_volumeIoiPow_range_Iio (n : ℕ) : FiniteSpanningSetsIn (volumeIoiPow n) (range Iio) where set k := Iio ⟨k + 1, mem_Ioi.2 k.cast_add_one_pos⟩ set_mem _ := mem_range_self _ finite k := by simp [volumeIoiPow_apply_Iio] spanning := iUnion_eq_univ_iff.2 fun x ↦ ⟨⌊x.1⌋₊, Nat.lt_floor_add_one x.1⟩ instance (n : ℕ) : SigmaFinite (volumeIoiPow n) := (finiteSpanningSetsIn_volumeIoiPow_range_Iio n).sigmaFinite /-- The homeomorphism `homeomorphUnitSphereProd E` sends an additive Haar measure `μ` to the product of `μ.toSphere` and `MeasureTheory.Measure.volumeIoiPow (dim E - 1)`, where `dim E = Module.finrank ℝ E` is the dimension of `E`. -/ theorem measurePreserving_homeomorphUnitSphereProd : MeasurePreserving (homeomorphUnitSphereProd E) (μ.comap (↑)) (μ.toSphere.prod (volumeIoiPow (dim E - 1))) := by nontriviality E refine ⟨(homeomorphUnitSphereProd E).measurable, .symm ?_⟩ refine prod_eq_generateFrom generateFrom_measurableSet ((borel_eq_generateFrom_Iio _).symm.trans BorelSpace.measurable_eq.symm) isPiSystem_measurableSet isPiSystem_Iio μ.toSphere.toFiniteSpanningSetsIn (finiteSpanningSetsIn_volumeIoiPow_range_Iio _) fun s hs ↦ forall_mem_range.2 fun r ↦ ?_ have : Ioo (0 : ℝ) r = r.1 • Ioo (0 : ℝ) 1 := by simp [LinearOrderedField.smul_Ioo r.2.out] have hpos : 0 < dim E := Module.finrank_pos rw [(Homeomorph.measurableEmbedding _).map_apply, toSphere_apply' _ hs, volumeIoiPow_apply_Iio, comap_subtype_coe_apply (measurableSet_singleton _).compl, toSphere_apply_aux, this, smul_assoc, μ.addHaar_smul_of_nonneg r.2.out.le, Nat.sub_add_cancel hpos, Nat.cast_pred hpos, sub_add_cancel, mul_right_comm, ← ENNReal.ofReal_natCast, ← ENNReal.ofReal_mul, mul_div_cancel₀] exacts [(Nat.cast_pos.2 hpos).ne', Nat.cast_nonneg _] end Measure variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] [Nontrivial E] (μ : Measure E) [FiniteDimensional ℝ E] [BorelSpace E] [μ.IsAddHaarMeasure] lemma integrable_fun_norm_addHaar {f : ℝ → F} : Integrable (f ‖·‖) μ ↔ IntegrableOn (fun y : ℝ ↦ y ^ (dim E - 1) • f y) (Ioi 0) := by have := μ.measurePreserving_homeomorphUnitSphereProd.integrable_comp_emb (g := f ∘ (↑) ∘ Prod.snd) (Homeomorph.measurableEmbedding _) simp only [comp_def, homeomorphUnitSphereProd_apply_snd_coe] at this rw [← restrict_compl_singleton (μ := μ) 0, ← IntegrableOn, integrableOn_iff_comap_subtypeVal (by measurability), comp_def, this, Integrable.comp_snd_iff (β := Ioi 0) (f := (f <| Subtype.val ·)), integrableOn_iff_comap_subtypeVal, comp_def, Measure.volumeIoiPow, integrable_withDensity_iff_integrable_smul', integrable_congr] · refine .of_forall ?_ rintro ⟨x, hx : 0 < x⟩ simp (disch := positivity) [ENNReal.toReal_ofReal] · fun_prop · simp · measurability · simp lemma integral_fun_norm_addHaar (f : ℝ → F) : ∫ x, f (‖x‖) ∂μ = dim E • μ.real (ball 0 1) • ∫ y in Ioi (0 : ℝ), y ^ (dim E - 1) • f y := calc ∫ x, f (‖x‖) ∂μ = ∫ x : ({(0)}ᶜ : Set E), f (‖x.1‖) ∂(μ.comap (↑)) := by rw [integral_subtype_comap (measurableSet_singleton _).compl fun x ↦ f (‖x‖), restrict_compl_singleton] _ = ∫ x : sphere (0 : E) 1 × Ioi (0 : ℝ), f x.2 ∂μ.toSphere.prod (.volumeIoiPow (dim E - 1)) := μ.measurePreserving_homeomorphUnitSphereProd.integral_comp (Homeomorph.measurableEmbedding _) (f ∘ Subtype.val ∘ Prod.snd) _ = μ.toSphere.real univ • ∫ x : Ioi (0 : ℝ), f x ∂.volumeIoiPow (dim E - 1) := integral_fun_snd (f ∘ Subtype.val) _ = _ := by simp only [Measure.volumeIoiPow, ENNReal.ofReal] rw [integral_withDensity_eq_integral_smul, μ.toSphere_real_apply_univ, ← nsmul_eq_mul, smul_assoc, integral_subtype_comap measurableSet_Ioi fun a ↦ Real.toNNReal (a ^ (dim E - 1)) • f a, setIntegral_congr_fun measurableSet_Ioi fun x hx ↦ ?_] · rw [NNReal.smul_def, Real.coe_toNNReal _ (pow_nonneg hx.out.le _)] · exact (measurable_subtype_coe.pow_const _).real_toNNReal end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/ProjectiveFamilyContent.lean
import Mathlib.MeasureTheory.Constructions.Projective import Mathlib.MeasureTheory.Measure.AddContent import Mathlib.MeasureTheory.SetAlgebra /-! # Additive content built from a projective family of measures Let `P` be a projective family of measures on a family of measurable spaces indexed by `ι`. That is, for each finite set `I` of indices, `P I` is a measure on `Π j : I, α j`, and for `J ⊆ I`, the projection from `Π i : I, α i` to `Π i : J, α i` maps `P I` to `P J`. We build an additive content `projectiveFamilyContent` on the measurable cylinders, by setting `projectiveFamilyContent s = P I S` for `s = cylinder I S`, where `I` is a finite set of indices and `S` is a measurable set in `Π i : I, α i`. This content will be used to define the projective limit of the family of measures `P`. For a countable index set and a projective family given by a sequence of kernels, the projective limit is given by the Ionescu-Tulcea theorem. For an arbitrary index set but under topological conditions on the spaces, this is the result of the Kolmogorov extension theorem. (both results are not yet in Mathlib) ## Main definitions * `projectiveFamilyContent`: additive content on the measurable cylinders, defined from a projective family of measures. -/ open Finset open scoped ENNReal namespace MeasureTheory variable {ι : Type*} {α : ι → Type*} {mα : ∀ i, MeasurableSpace (α i)} {P : ∀ J : Finset ι, Measure (Π j : J, α j)} {s t : Set (Π i, α i)} {I : Finset ι} {S : Set (Π i : I, α i)} section MeasurableCylinders lemma isSetAlgebra_measurableCylinders : IsSetAlgebra (measurableCylinders α) where empty_mem := empty_mem_measurableCylinders α compl_mem _ := compl_mem_measurableCylinders union_mem _ _ := union_mem_measurableCylinders lemma isSetRing_measurableCylinders : IsSetRing (measurableCylinders α) := isSetAlgebra_measurableCylinders.isSetRing lemma isSetSemiring_measurableCylinders : MeasureTheory.IsSetSemiring (measurableCylinders α) := isSetRing_measurableCylinders.isSetSemiring end MeasurableCylinders section ProjectiveFamilyFun open Classical in /-- For `P` a family of measures, with `P J` a measure on `Π j : J, α j`, we define a function `projectiveFamilyFun P s` by setting it to `P I S` if `s = cylinder I S` for a measurable `S` and to 0 if `s` is not a measurable cylinder. -/ noncomputable def projectiveFamilyFun (P : ∀ J : Finset ι, Measure (Π j : J, α j)) (s : Set (Π i, α i)) : ℝ≥0∞ := if hs : s ∈ measurableCylinders α then P (measurableCylinders.finset hs) (measurableCylinders.set hs) else 0 lemma projectiveFamilyFun_congr (hP : IsProjectiveMeasureFamily P) (hs : s ∈ measurableCylinders α) (hs_eq : s = cylinder I S) (hS : MeasurableSet S) : projectiveFamilyFun P s = P I S := by rw [projectiveFamilyFun, dif_pos hs] exact hP.congr_cylinder (measurableCylinders.measurableSet hs) hS ((measurableCylinders.eq_cylinder hs).symm.trans hs_eq) lemma projectiveFamilyFun_empty (hP : IsProjectiveMeasureFamily P) : projectiveFamilyFun P ∅ = 0 := by rw [projectiveFamilyFun_congr hP (empty_mem_measurableCylinders α) (cylinder_empty ∅).symm MeasurableSet.empty, measure_empty] lemma projectiveFamilyFun_union (hP : IsProjectiveMeasureFamily P) (hs : s ∈ measurableCylinders α) (ht : t ∈ measurableCylinders α) (hst : Disjoint s t) : projectiveFamilyFun P (s ∪ t) = projectiveFamilyFun P s + projectiveFamilyFun P t := by obtain ⟨I, S, hS, hs_eq⟩ := (mem_measurableCylinders _).1 hs obtain ⟨J, T, hT, ht_eq⟩ := (mem_measurableCylinders _).1 ht classical let S' := restrict₂ (subset_union_left (s₂ := J)) ⁻¹' S let T' := restrict₂ (subset_union_right (s₁ := I)) ⁻¹' T have hS' : MeasurableSet S' := measurable_restrict₂ _ hS have hT' : MeasurableSet T' := measurable_restrict₂ _ hT have h_eq1 : s = cylinder (I ∪ J) S' := by rw [hs_eq]; exact cylinder_eq_cylinder_union I S J have h_eq2 : t = cylinder (I ∪ J) T' := by rw [ht_eq]; exact cylinder_eq_cylinder_union J T I have h_eq3 : s ∪ t = cylinder (I ∪ J) (S' ∪ T') := by rw [hs_eq, ht_eq]; exact union_cylinder _ _ _ _ rw [projectiveFamilyFun_congr hP hs h_eq1 hS', projectiveFamilyFun_congr hP ht h_eq2 hT', projectiveFamilyFun_congr hP (union_mem_measurableCylinders hs ht) h_eq3 (hS'.union hT')] cases isEmpty_or_nonempty (Π i, α i) with | inl h => simp [hP.eq_zero_of_isEmpty] | inr h => rw [measure_union _ hT'] rwa [hs_eq, ht_eq, disjoint_cylinder_iff] at hst end ProjectiveFamilyFun section ProjectiveFamilyContent /-- For `P` a projective family of measures, we define an additive content on the measurable cylinders, by setting `projectiveFamilyContent s = P I S` for `s = cylinder I S`, where `I` is a finite set of indices and `S` is a measurable set in `Π i : I, α i`. -/ noncomputable def projectiveFamilyContent (hP : IsProjectiveMeasureFamily P) : AddContent (measurableCylinders α) := isSetRing_measurableCylinders.addContent_of_union (projectiveFamilyFun P) (projectiveFamilyFun_empty hP) (projectiveFamilyFun_union hP) lemma projectiveFamilyContent_eq (hP : IsProjectiveMeasureFamily P) : projectiveFamilyContent hP s = projectiveFamilyFun P s := rfl lemma projectiveFamilyContent_congr (hP : IsProjectiveMeasureFamily P) (s : Set (Π i, α i)) (hs_eq : s = cylinder I S) (hS : MeasurableSet S) : projectiveFamilyContent hP s = P I S := by rw [projectiveFamilyContent_eq, projectiveFamilyFun_congr hP ((mem_measurableCylinders s).mpr ⟨I, S, hS, hs_eq⟩) hs_eq hS] lemma projectiveFamilyContent_cylinder (hP : IsProjectiveMeasureFamily P) (hS : MeasurableSet S) : projectiveFamilyContent hP (cylinder I S) = P I S := projectiveFamilyContent_congr _ _ rfl hS lemma projectiveFamilyContent_mono (hP : IsProjectiveMeasureFamily P) (hs : s ∈ measurableCylinders α) (ht : t ∈ measurableCylinders α) (hst : s ⊆ t) : projectiveFamilyContent hP s ≤ projectiveFamilyContent hP t := addContent_mono isSetSemiring_measurableCylinders hs ht hst lemma projectiveFamilyContent_iUnion_le (hP : IsProjectiveMeasureFamily P) {s : ℕ → Set (Π i : ι, α i)} (hs : ∀ n, s n ∈ measurableCylinders α) (n : ℕ) : projectiveFamilyContent hP (⋃ i ≤ n, s i) ≤ ∑ i ∈ range (n + 1), projectiveFamilyContent hP (s i) := calc projectiveFamilyContent hP (⋃ i ≤ n, s i) _ = projectiveFamilyContent hP (⋃ i ∈ range (n + 1), s i) := by simp only [mem_range_succ_iff] _ ≤ ∑ i ∈ range (n + 1), projectiveFamilyContent hP (s i) := addContent_biUnion_le isSetRing_measurableCylinders (fun i _ ↦ hs i) lemma projectiveFamilyContent_ne_top [∀ J, IsFiniteMeasure (P J)] (hP : IsProjectiveMeasureFamily P) : projectiveFamilyContent hP s ≠ ∞ := by rw [projectiveFamilyContent_eq hP, projectiveFamilyFun] split_ifs with hs <;> finiteness lemma projectiveFamilyContent_diff (hP : IsProjectiveMeasureFamily P) (hs : s ∈ measurableCylinders α) (ht : t ∈ measurableCylinders α) : projectiveFamilyContent hP s - projectiveFamilyContent hP t ≤ projectiveFamilyContent hP (s \ t) := le_addContent_diff (projectiveFamilyContent hP) isSetRing_measurableCylinders hs ht lemma projectiveFamilyContent_diff_of_subset [∀ J, IsFiniteMeasure (P J)] (hP : IsProjectiveMeasureFamily P) (hs : s ∈ measurableCylinders α) (ht : t ∈ measurableCylinders α) (hts : t ⊆ s) : projectiveFamilyContent hP (s \ t) = projectiveFamilyContent hP s - projectiveFamilyContent hP t := addContent_diff_of_ne_top (projectiveFamilyContent hP) isSetRing_measurableCylinders (fun _ _ ↦ projectiveFamilyContent_ne_top hP) hs ht hts end ProjectiveFamilyContent end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/SubmoduleQuotient.lean
import Mathlib.LinearAlgebra.Quotient.Defs import Mathlib.MeasureTheory.MeasurableSpace.Constructions /-! # Measurability on the quotient of a module by a submodule -/ namespace Submodule.Quotient variable {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] {p : Submodule R M} instance [MeasurableSpace M] : MeasurableSpace (M ⧸ p) := Quotient.instMeasurableSpace instance [MeasurableSpace M] [DiscreteMeasurableSpace M] : DiscreteMeasurableSpace (M ⧸ p) := Quotient.instDiscreteMeasurableSpace end Submodule.Quotient
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/Projective.lean
import Mathlib.MeasureTheory.Constructions.Cylinders import Mathlib.MeasureTheory.Measure.Typeclasses.Probability /-! # Projective measure families and projective limits A family of measures indexed by finite sets of `ι` is projective if, for finite sets `J ⊆ I`, the projection from `∀ i : I, α i` to `∀ i : J, α i` maps `P I` to `P J`. A measure `μ` is the projective limit of such a family of measures if for all `I : Finset ι`, the projection from `∀ i, α i` to `∀ i : I, α i` maps `μ` to `P I`. ## Main definitions * `MeasureTheory.IsProjectiveMeasureFamily`: `P : ∀ J : Finset ι, Measure (∀ j : J, α j)` is projective if the projection from `∀ i : I, α i` to `∀ i : J, α i` maps `P I` to `P J` for all `J ⊆ I`. * `MeasureTheory.IsProjectiveLimit`: `μ` is the projective limit of the measure family `P` if for all `I : Finset ι`, the map of `μ` by the projection to `I` is `P I`. ## Main statements * `MeasureTheory.IsProjectiveLimit.unique`: the projective limit of a family of finite measures is unique. -/ open Set namespace MeasureTheory variable {ι : Type*} {α : ι → Type*} [∀ i, MeasurableSpace (α i)] {P : ∀ J : Finset ι, Measure (∀ j : J, α j)} /-- A family of measures indexed by finite sets of `ι` is projective if, for finite sets `J ⊆ I`, the projection from `∀ i : I, α i` to `∀ i : J, α i` maps `P I` to `P J`. -/ def IsProjectiveMeasureFamily (P : ∀ J : Finset ι, Measure (∀ j : J, α j)) : Prop := ∀ (I J : Finset ι) (hJI : J ⊆ I), P J = (P I).map (Finset.restrict₂ hJI) namespace IsProjectiveMeasureFamily variable {I J : Finset ι} lemma eq_zero_of_isEmpty [h : IsEmpty (Π i, α i)] (hP : IsProjectiveMeasureFamily P) (I : Finset ι) : P I = 0 := by classical obtain ⟨i, hi⟩ := isEmpty_pi.mp h rw [hP (insert i I) I (I.subset_insert i)] have : IsEmpty (Π j : ↑(insert i I), α j) := by simp [hi] rw [(P (insert i I)).eq_zero_of_isEmpty] simp /-- Auxiliary lemma for `measure_univ_eq`. -/ lemma measure_univ_eq_of_subset (hP : IsProjectiveMeasureFamily P) (hJI : J ⊆ I) : P I univ = P J univ := by classical have : (univ : Set (∀ i : I, α i)) = Finset.restrict₂ hJI ⁻¹' (univ : Set (∀ i : J, α i)) := by rw [preimage_univ] rw [this, ← Measure.map_apply _ MeasurableSet.univ] · rw [hP I J hJI] · exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _) lemma measure_univ_eq (hP : IsProjectiveMeasureFamily P) (I J : Finset ι) : P I univ = P J univ := by classical rw [← hP.measure_univ_eq_of_subset I.subset_union_left, ← hP.measure_univ_eq_of_subset (I.subset_union_right (s₂ := J))] lemma congr_cylinder_of_subset (hP : IsProjectiveMeasureFamily P) {S : Set (∀ i : I, α i)} {T : Set (∀ i : J, α i)} (hT : MeasurableSet T) (h_eq : cylinder I S = cylinder J T) (hJI : J ⊆ I) : P I S = P J T := by cases isEmpty_or_nonempty (∀ i, α i) with | inl h => suffices ∀ I, P I univ = 0 by simp only [Measure.measure_univ_eq_zero] at this simp [this] intro I simp only [isEmpty_pi] at h obtain ⟨i, hi_empty⟩ := h rw [measure_univ_eq hP I {i}] have : (univ : Set ((j : {x // x ∈ ({i} : Finset ι)}) → α j)) = ∅ := by simp [hi_empty] simp [this] | inr h => have : S = Finset.restrict₂ hJI ⁻¹' T := eq_of_cylinder_eq_of_subset h_eq hJI rw [hP I J hJI, Measure.map_apply _ hT, this] exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _) lemma congr_cylinder (hP : IsProjectiveMeasureFamily P) {S : Set (∀ i : I, α i)} {T : Set (∀ i : J, α i)} (hS : MeasurableSet S) (hT : MeasurableSet T) (h_eq : cylinder I S = cylinder J T) : P I S = P J T := by classical let U := Finset.restrict₂ Finset.subset_union_left ⁻¹' S ∩ Finset.restrict₂ Finset.subset_union_right ⁻¹' T suffices P (I ∪ J) U = P I S ∧ P (I ∪ J) U = P J T from this.1.symm.trans this.2 constructor · have h_eq_union : cylinder I S = cylinder (I ∪ J) U := by rw [← inter_cylinder, h_eq, inter_self] exact hP.congr_cylinder_of_subset hS h_eq_union.symm Finset.subset_union_left · have h_eq_union : cylinder J T = cylinder (I ∪ J) U := by rw [← inter_cylinder, h_eq, inter_self] exact hP.congr_cylinder_of_subset hT h_eq_union.symm Finset.subset_union_right end IsProjectiveMeasureFamily /-- A measure `μ` is the projective limit of a family of measures indexed by finite sets of `ι` if for all `I : Finset ι`, the projection from `∀ i, α i` to `∀ i : I, α i` maps `μ` to `P I`. -/ def IsProjectiveLimit (μ : Measure (∀ i, α i)) (P : ∀ J : Finset ι, Measure (∀ j : J, α j)) : Prop := ∀ I : Finset ι, (μ.map I.restrict) = P I namespace IsProjectiveLimit variable {μ ν : Measure (∀ i, α i)} lemma measure_cylinder (h : IsProjectiveLimit μ P) (I : Finset ι) {s : Set (∀ i : I, α i)} (hs : MeasurableSet s) : μ (cylinder I s) = P I s := by rw [cylinder, ← Measure.map_apply _ hs, h I] exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _) lemma measure_univ_eq (hμ : IsProjectiveLimit μ P) (I : Finset ι) : μ univ = P I univ := by rw [← cylinder_univ I, hμ.measure_cylinder _ MeasurableSet.univ] lemma isFiniteMeasure [∀ i, IsFiniteMeasure (P i)] (hμ : IsProjectiveLimit μ P) : IsFiniteMeasure μ := by constructor rw [hμ.measure_univ_eq (∅ : Finset ι)] exact measure_lt_top _ _ lemma isProbabilityMeasure [∀ i, IsProbabilityMeasure (P i)] (hμ : IsProjectiveLimit μ P) : IsProbabilityMeasure μ := by constructor rw [hμ.measure_univ_eq (∅ : Finset ι)] exact measure_univ lemma measure_univ_unique (hμ : IsProjectiveLimit μ P) (hν : IsProjectiveLimit ν P) : μ univ = ν univ := by rw [hμ.measure_univ_eq (∅ : Finset ι), hν.measure_univ_eq (∅ : Finset ι)] /-- The projective limit of a family of finite measures is unique. -/ theorem unique [∀ i, IsFiniteMeasure (P i)] (hμ : IsProjectiveLimit μ P) (hν : IsProjectiveLimit ν P) : μ = ν := by haveI : IsFiniteMeasure μ := hμ.isFiniteMeasure refine ext_of_generate_finite (measurableCylinders α) generateFrom_measurableCylinders.symm isPiSystem_measurableCylinders (fun s hs ↦ ?_) (hμ.measure_univ_unique hν) obtain ⟨I, S, hS, rfl⟩ := (mem_measurableCylinders _).mp hs rw [hμ.measure_cylinder _ hS, hν.measure_cylinder _ hS] end IsProjectiveLimit end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/Cylinders.lean
import Mathlib.MeasureTheory.MeasurableSpace.Constructions import Mathlib.MeasureTheory.PiSystem import Mathlib.Topology.Constructions /-! # π-systems of cylinders and square cylinders The instance `MeasurableSpace.pi` on `∀ i, α i`, where each `α i` has a `MeasurableSpace` `m i`, is defined as `⨆ i, (m i).comap (fun a => a i)`. That is, a function `g : β → ∀ i, α i` is measurable iff for all `i`, the function `b ↦ g b i` is measurable. We define two π-systems generating `MeasurableSpace.pi`, cylinders and square cylinders. ## Main definitions Given a finite set `s` of indices, a cylinder is the product of a set of `∀ i : s, α i` and of `univ` on the other indices. A square cylinder is a cylinder for which the set on `∀ i : s, α i` is a product set. * `cylinder s S`: cylinder with base set `S : Set (∀ i : s, α i)` where `s` is a `Finset` * `squareCylinders C` with `C : ∀ i, Set (Set (α i))`: set of all square cylinders such that for all `i` in the finset defining the box, the projection to `α i` belongs to `C i`. The main application of this is with `C i = {s : Set (α i) | MeasurableSet s}`. * `measurableCylinders`: set of all cylinders with measurable base sets. * `cylinderEvents Δ`: The σ-algebra of cylinder events on `Δ`. It is the smallest σ-algebra making the projections on the `i`-th coordinate continuous for all `i ∈ Δ`. ## Main statements * `generateFrom_squareCylinders`: square cylinders formed from measurable sets generate the product σ-algebra * `generateFrom_measurableCylinders`: cylinders formed from measurable sets generate the product σ-algebra -/ open Function Set namespace MeasureTheory variable {ι : Type _} {α : ι → Type _} section squareCylinders /-- Given a finite set `s` of indices, a square cylinder is the product of a set `S` of `∀ i : s, α i` and of `univ` on the other indices. The set `S` is a product of sets `t i` such that for all `i : s`, `t i ∈ C i`. `squareCylinders` is the set of all such squareCylinders. -/ def squareCylinders (C : ∀ i, Set (Set (α i))) : Set (Set (∀ i, α i)) := {S | ∃ s : Finset ι, ∃ t ∈ univ.pi C, S = (s : Set ι).pi t} theorem squareCylinders_eq_iUnion_image (C : ∀ i, Set (Set (α i))) : squareCylinders C = ⋃ s : Finset ι, (fun t ↦ (s : Set ι).pi t) '' univ.pi C := by ext1 f simp only [squareCylinders, mem_iUnion, mem_image, mem_univ_pi, mem_setOf_eq, eq_comm (a := f)] theorem isPiSystem_squareCylinders {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsPiSystem (C i)) (hC_univ : ∀ i, univ ∈ C i) : IsPiSystem (squareCylinders C) := by rintro S₁ ⟨s₁, t₁, h₁, rfl⟩ S₂ ⟨s₂, t₂, h₂, rfl⟩ hst_nonempty classical let t₁' := s₁.piecewise t₁ (fun i ↦ univ) let t₂' := s₂.piecewise t₂ (fun i ↦ univ) have h1 : ∀ i ∈ (s₁ : Set ι), t₁ i = t₁' i := fun i hi ↦ (Finset.piecewise_eq_of_mem _ _ _ hi).symm have h1' : ∀ i ∉ (s₁ : Set ι), t₁' i = univ := fun i hi ↦ Finset.piecewise_eq_of_notMem _ _ _ hi have h2 : ∀ i ∈ (s₂ : Set ι), t₂ i = t₂' i := fun i hi ↦ (Finset.piecewise_eq_of_mem _ _ _ hi).symm have h2' : ∀ i ∉ (s₂ : Set ι), t₂' i = univ := fun i hi ↦ Finset.piecewise_eq_of_notMem _ _ _ hi rw [Set.pi_congr rfl h1, Set.pi_congr rfl h2, ← union_pi_inter h1' h2'] refine ⟨s₁ ∪ s₂, fun i ↦ t₁' i ∩ t₂' i, ?_, ?_⟩ · rw [mem_univ_pi] intro i have : (t₁' i ∩ t₂' i).Nonempty := by obtain ⟨f, hf⟩ := hst_nonempty rw [Set.pi_congr rfl h1, Set.pi_congr rfl h2, mem_inter_iff, mem_pi, mem_pi] at hf refine ⟨f i, ⟨?_, ?_⟩⟩ · by_cases hi₁ : i ∈ s₁ · exact hf.1 i hi₁ · rw [h1' i hi₁] exact mem_univ _ · by_cases hi₂ : i ∈ s₂ · exact hf.2 i hi₂ · rw [h2' i hi₂] exact mem_univ _ refine hC i _ ?_ _ ?_ this · by_cases hi₁ : i ∈ s₁ · rw [← h1 i hi₁] exact h₁ i (mem_univ _) · rw [h1' i hi₁] exact hC_univ i · by_cases hi₂ : i ∈ s₂ · rw [← h2 i hi₂] exact h₂ i (mem_univ _) · rw [h2' i hi₂] exact hC_univ i · rw [Finset.coe_union] theorem comap_eval_le_generateFrom_squareCylinders_singleton (α : ι → Type*) [m : ∀ i, MeasurableSpace (α i)] (i : ι) : MeasurableSpace.comap (Function.eval i) (m i) ≤ MeasurableSpace.generateFrom ((fun t ↦ ({i} : Set ι).pi t) '' univ.pi fun i ↦ {s : Set (α i) | MeasurableSet s}) := by simp only [singleton_pi] rw [MeasurableSpace.comap_eq_generateFrom] refine MeasurableSpace.generateFrom_mono fun S ↦ ?_ simp only [mem_setOf_eq, mem_image, mem_univ_pi, forall_exists_index, and_imp] intro t ht h classical refine ⟨fun j ↦ if hji : j = i then by convert t else univ, fun j ↦ ?_, ?_⟩ · by_cases hji : j = i · simp only [hji, eq_mpr_eq_cast, dif_pos] convert ht simp only [cast_heq] · simp only [hji, not_false_iff, dif_neg, MeasurableSet.univ] · grind /-- The square cylinders formed from measurable sets generate the product σ-algebra. -/ theorem generateFrom_squareCylinders [∀ i, MeasurableSpace (α i)] : MeasurableSpace.generateFrom (squareCylinders fun i ↦ {s : Set (α i) | MeasurableSet s}) = MeasurableSpace.pi := by apply le_antisymm · rw [MeasurableSpace.generateFrom_le_iff] rintro S ⟨s, t, h, rfl⟩ simp only [mem_univ_pi, mem_setOf_eq] at h exact MeasurableSet.pi (Finset.countable_toSet _) (fun i _ ↦ h i) · refine iSup_le fun i ↦ ?_ refine (comap_eval_le_generateFrom_squareCylinders_singleton α i).trans ?_ refine MeasurableSpace.generateFrom_mono ?_ rw [← Finset.coe_singleton, squareCylinders_eq_iUnion_image] exact subset_iUnion (fun (s : Finset ι) ↦ (fun t : ∀ i, Set (α i) ↦ (s : Set ι).pi t) '' univ.pi (fun i ↦ setOf MeasurableSet)) ({i} : Finset ι) end squareCylinders section cylinder /-- Given a finite set `s` of indices, a cylinder is the preimage of a set `S` of `∀ i : s, α i` by the projection from `∀ i, α i` to `∀ i : s, α i`. -/ def cylinder (s : Finset ι) (S : Set (∀ i : s, α i)) : Set (∀ i, α i) := s.restrict ⁻¹' S @[simp] theorem mem_cylinder (s : Finset ι) (S : Set (∀ i : s, α i)) (f : ∀ i, α i) : f ∈ cylinder s S ↔ s.restrict f ∈ S := mem_preimage @[simp] theorem cylinder_empty (s : Finset ι) : cylinder s (∅ : Set (∀ i : s, α i)) = ∅ := by rw [cylinder, preimage_empty] @[simp] theorem cylinder_univ (s : Finset ι) : cylinder s (univ : Set (∀ i : s, α i)) = univ := by rw [cylinder, preimage_univ] @[simp] theorem cylinder_eq_empty_iff [h_nonempty : Nonempty (∀ i, α i)] (s : Finset ι) (S : Set (∀ i : s, α i)) : cylinder s S = ∅ ↔ S = ∅ := by refine ⟨fun h ↦ ?_, fun h ↦ by (rw [h]; exact cylinder_empty _)⟩ by_contra hS rw [← Ne, ← nonempty_iff_ne_empty] at hS let f := hS.some have hf : f ∈ S := hS.choose_spec classical let f' : ∀ i, α i := fun i ↦ if hi : i ∈ s then f ⟨i, hi⟩ else h_nonempty.some i have hf' : f' ∈ cylinder s S := by rw [mem_cylinder] simpa only [Finset.restrict_def, Finset.coe_mem, dif_pos, f'] rw [h] at hf' exact notMem_empty _ hf' theorem inter_cylinder (s₁ s₂ : Finset ι) (S₁ : Set (∀ i : s₁, α i)) (S₂ : Set (∀ i : s₂, α i)) [DecidableEq ι] : cylinder s₁ S₁ ∩ cylinder s₂ S₂ = cylinder (s₁ ∪ s₂) (Finset.restrict₂ Finset.subset_union_left ⁻¹' S₁ ∩ Finset.restrict₂ Finset.subset_union_right ⁻¹' S₂) := rfl theorem inter_cylinder_same (s : Finset ι) (S₁ : Set (∀ i : s, α i)) (S₂ : Set (∀ i : s, α i)) : cylinder s S₁ ∩ cylinder s S₂ = cylinder s (S₁ ∩ S₂) := rfl theorem union_cylinder (s₁ s₂ : Finset ι) (S₁ : Set (∀ i : s₁, α i)) (S₂ : Set (∀ i : s₂, α i)) [DecidableEq ι] : cylinder s₁ S₁ ∪ cylinder s₂ S₂ = cylinder (s₁ ∪ s₂) (Finset.restrict₂ Finset.subset_union_left ⁻¹' S₁ ∪ Finset.restrict₂ Finset.subset_union_right ⁻¹' S₂) := rfl theorem union_cylinder_same (s : Finset ι) (S₁ : Set (∀ i : s, α i)) (S₂ : Set (∀ i : s, α i)) : cylinder s S₁ ∪ cylinder s S₂ = cylinder s (S₁ ∪ S₂) := rfl theorem compl_cylinder (s : Finset ι) (S : Set (∀ i : s, α i)) : (cylinder s S)ᶜ = cylinder s (Sᶜ) := by ext1 f; simp only [mem_compl_iff, mem_cylinder] theorem diff_cylinder_same (s : Finset ι) (S T : Set (∀ i : s, α i)) : cylinder s S \ cylinder s T = cylinder s (S \ T) := by ext1 f; simp only [mem_diff, mem_cylinder] theorem eq_of_cylinder_eq_of_subset [h_nonempty : Nonempty (∀ i, α i)] {I J : Finset ι} {S : Set (∀ i : I, α i)} {T : Set (∀ i : J, α i)} (h_eq : cylinder I S = cylinder J T) (hJI : J ⊆ I) : S = Finset.restrict₂ hJI ⁻¹' T := by rw [Set.ext_iff] at h_eq simp only [mem_cylinder] at h_eq ext1 f simp only [mem_preimage] classical specialize h_eq fun i ↦ if hi : i ∈ I then f ⟨i, hi⟩ else h_nonempty.some i have h_mem : ∀ j : J, ↑j ∈ I := fun j ↦ hJI j.prop simpa only [Finset.restrict_def, Finset.coe_mem, dite_true, h_mem] using h_eq theorem cylinder_eq_cylinder_union [DecidableEq ι] (I : Finset ι) (S : Set (∀ i : I, α i)) (J : Finset ι) : cylinder I S = cylinder (I ∪ J) (Finset.restrict₂ Finset.subset_union_left ⁻¹' S) := by ext1 f; simp only [mem_cylinder, Finset.restrict_def, Finset.restrict₂_def, mem_preimage] theorem disjoint_cylinder_iff [Nonempty (∀ i, α i)] {s t : Finset ι} {S : Set (∀ i : s, α i)} {T : Set (∀ i : t, α i)} [DecidableEq ι] : Disjoint (cylinder s S) (cylinder t T) ↔ Disjoint (Finset.restrict₂ Finset.subset_union_left ⁻¹' S) (Finset.restrict₂ Finset.subset_union_right ⁻¹' T) := by simp_rw [Set.disjoint_iff, subset_empty_iff, inter_cylinder, cylinder_eq_empty_iff] theorem IsClosed.cylinder [∀ i, TopologicalSpace (α i)] (s : Finset ι) {S : Set (∀ i : s, α i)} (hs : IsClosed S) : IsClosed (cylinder s S) := hs.preimage (continuous_pi fun _ ↦ continuous_apply _) theorem _root_.MeasurableSet.cylinder [∀ i, MeasurableSpace (α i)] (s : Finset ι) {S : Set (∀ i : s, α i)} (hS : MeasurableSet S) : MeasurableSet (cylinder s S) := measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _) hS /-- The indicator of a cylinder only depends on the variables whose the cylinder depends on. -/ theorem dependsOn_cylinder_indicator_const {M : Type*} [Zero M] {I : Finset ι} (S : Set (Π i : I, α i)) (c : M) : DependsOn ((cylinder I S).indicator (fun _ ↦ c)) I := fun x y hxy ↦ Set.indicator_const_eq_indicator_const (by simp [Finset.restrict_def, hxy]) end cylinder section cylinders /-- Given a finite set `s` of indices, a cylinder is the preimage of a set `S` of `∀ i : s, α i` by the projection from `∀ i, α i` to `∀ i : s, α i`. `measurableCylinders` is the set of all cylinders with measurable base `S`. -/ def measurableCylinders (α : ι → Type*) [∀ i, MeasurableSpace (α i)] : Set (Set (∀ i, α i)) := ⋃ (s) (S) (_ : MeasurableSet S), {cylinder s S} theorem empty_mem_measurableCylinders (α : ι → Type*) [∀ i, MeasurableSpace (α i)] : ∅ ∈ measurableCylinders α := by simp_rw [measurableCylinders, mem_iUnion, mem_singleton_iff] exact ⟨∅, ∅, MeasurableSet.empty, (cylinder_empty _).symm⟩ variable [∀ i, MeasurableSpace (α i)] {s t : Set (∀ i, α i)} @[simp] theorem mem_measurableCylinders (t : Set (∀ i, α i)) : t ∈ measurableCylinders α ↔ ∃ s S, MeasurableSet S ∧ t = cylinder s S := by simp_rw [measurableCylinders, mem_iUnion, exists_prop, mem_singleton_iff] @[measurability] theorem _root_.MeasurableSet.of_mem_measurableCylinders {s : Set (Π i, α i)} (hs : s ∈ measurableCylinders α) : MeasurableSet s := by obtain ⟨I, t, mt, rfl⟩ := (mem_measurableCylinders s).1 hs exact mt.cylinder /-- A finset `s` such that `t = cylinder s S`. `S` is given by `measurableCylinders.set`. -/ noncomputable def measurableCylinders.finset (ht : t ∈ measurableCylinders α) : Finset ι := ((mem_measurableCylinders t).mp ht).choose /-- A set `S` such that `t = cylinder s S`. `s` is given by `measurableCylinders.finset`. -/ def measurableCylinders.set (ht : t ∈ measurableCylinders α) : Set (∀ i : measurableCylinders.finset ht, α i) := ((mem_measurableCylinders t).mp ht).choose_spec.choose theorem measurableCylinders.measurableSet (ht : t ∈ measurableCylinders α) : MeasurableSet (measurableCylinders.set ht) := ((mem_measurableCylinders t).mp ht).choose_spec.choose_spec.left theorem measurableCylinders.eq_cylinder (ht : t ∈ measurableCylinders α) : t = cylinder (measurableCylinders.finset ht) (measurableCylinders.set ht) := ((mem_measurableCylinders t).mp ht).choose_spec.choose_spec.right theorem cylinder_mem_measurableCylinders (s : Finset ι) (S : Set (∀ i : s, α i)) (hS : MeasurableSet S) : cylinder s S ∈ measurableCylinders α := by rw [mem_measurableCylinders]; exact ⟨s, S, hS, rfl⟩ theorem inter_mem_measurableCylinders (hs : s ∈ measurableCylinders α) (ht : t ∈ measurableCylinders α) : s ∩ t ∈ measurableCylinders α := by rw [mem_measurableCylinders] at * obtain ⟨s₁, S₁, hS₁, rfl⟩ := hs obtain ⟨s₂, S₂, hS₂, rfl⟩ := ht classical refine ⟨s₁ ∪ s₂, Finset.restrict₂ Finset.subset_union_left ⁻¹' S₁ ∩ {f | Finset.restrict₂ Finset.subset_union_right f ∈ S₂}, ?_, ?_⟩ · refine MeasurableSet.inter ?_ ?_ · exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _) hS₁ · exact measurable_pi_lambda _ (fun _ ↦ measurable_pi_apply _) hS₂ · exact inter_cylinder _ _ _ _ theorem isPiSystem_measurableCylinders : IsPiSystem (measurableCylinders α) := fun _ hS _ hT _ ↦ inter_mem_measurableCylinders hS hT theorem compl_mem_measurableCylinders (hs : s ∈ measurableCylinders α) : sᶜ ∈ measurableCylinders α := by rw [mem_measurableCylinders] at hs ⊢ obtain ⟨s, S, hS, rfl⟩ := hs refine ⟨s, Sᶜ, hS.compl, ?_⟩ rw [compl_cylinder] theorem univ_mem_measurableCylinders (α : ι → Type*) [∀ i, MeasurableSpace (α i)] : Set.univ ∈ measurableCylinders α := by rw [← compl_empty]; exact compl_mem_measurableCylinders (empty_mem_measurableCylinders α) theorem union_mem_measurableCylinders (hs : s ∈ measurableCylinders α) (ht : t ∈ measurableCylinders α) : s ∪ t ∈ measurableCylinders α := by rw [union_eq_compl_compl_inter_compl] exact compl_mem_measurableCylinders (inter_mem_measurableCylinders (compl_mem_measurableCylinders hs) (compl_mem_measurableCylinders ht)) theorem diff_mem_measurableCylinders (hs : s ∈ measurableCylinders α) (ht : t ∈ measurableCylinders α) : s \ t ∈ measurableCylinders α := by rw [diff_eq_compl_inter] exact inter_mem_measurableCylinders (compl_mem_measurableCylinders ht) hs /-- The measurable cylinders generate the product σ-algebra. -/ theorem generateFrom_measurableCylinders : MeasurableSpace.generateFrom (measurableCylinders α) = MeasurableSpace.pi := by apply le_antisymm · refine MeasurableSpace.generateFrom_le (fun S hS ↦ ?_) obtain ⟨s, S, hSm, rfl⟩ := (mem_measurableCylinders _).mp hS exact hSm.cylinder · refine iSup_le fun i ↦ ?_ refine (comap_eval_le_generateFrom_squareCylinders_singleton α i).trans ?_ refine MeasurableSpace.generateFrom_mono (fun x ↦ ?_) simp only [singleton_pi, mem_image, mem_pi, mem_univ, mem_setOf_eq, forall_true_left, mem_measurableCylinders, forall_exists_index, and_imp] rintro t ht rfl refine ⟨{i}, {f | f ⟨i, Finset.mem_singleton_self i⟩ ∈ t i}, measurable_pi_apply _ (ht i), ?_⟩ ext1 x simp only [mem_preimage, Function.eval, mem_cylinder, mem_setOf_eq, Finset.restrict] /-- The cylinders of a product space indexed by `ℕ` can be seen as depending on the first coordinates. -/ theorem measurableCylinders_nat {X : ℕ → Type*} [∀ n, MeasurableSpace (X n)] : measurableCylinders X = ⋃ (a) (S) (_ : MeasurableSet S), {cylinder (Finset.Iic a) S} := by ext s simp only [mem_measurableCylinders, exists_prop, mem_iUnion] refine ⟨?_, fun ⟨N, S, mS, s_eq⟩ ↦ ⟨Finset.Iic N, S, mS, s_eq⟩⟩ rintro ⟨t, S, mS, rfl⟩ refine ⟨t.sup id, Finset.restrict₂ t.subset_Iic_sup_id ⁻¹' S, Finset.measurable_restrict₂ _ mS, ?_⟩ unfold cylinder rw [← preimage_comp, Finset.restrict₂_comp_restrict] exact mem_singleton _ end cylinders /-! ### Cylinder events as a sigma-algebra -/ section cylinderEvents variable {α ι : Type*} {X : ι → Type*} {mα : MeasurableSpace α} [m : ∀ i, MeasurableSpace (X i)] {Δ Δ₁ Δ₂ : Set ι} {i : ι} /-- The σ-algebra of cylinder events on `Δ`. It is the smallest σ-algebra making the projections on the `i`-th coordinate measurable for all `i ∈ Δ`. -/ def cylinderEvents (Δ : Set ι) : MeasurableSpace (∀ i, X i) := ⨆ i ∈ Δ, (m i).comap fun σ ↦ σ i @[simp] lemma cylinderEvents_univ : cylinderEvents (X := X) univ = MeasurableSpace.pi := by simp [cylinderEvents, MeasurableSpace.pi] @[gcongr] lemma cylinderEvents_mono (h : Δ₁ ⊆ Δ₂) : cylinderEvents (X := X) Δ₁ ≤ cylinderEvents Δ₂ := biSup_mono h lemma cylinderEvents_le_pi : cylinderEvents (X := X) Δ ≤ MeasurableSpace.pi := by simpa using cylinderEvents_mono (subset_univ _) lemma measurable_cylinderEvents_iff {g : α → ∀ i, X i} : @Measurable _ _ _ (cylinderEvents Δ) g ↔ ∀ ⦃i⦄, i ∈ Δ → Measurable fun a ↦ g a i := by simp_rw [measurable_iff_comap_le, cylinderEvents, MeasurableSpace.comap_iSup, MeasurableSpace.comap_comp, Function.comp_def, iSup_le_iff] @[fun_prop] lemma measurable_cylinderEvent_apply (hi : i ∈ Δ) : Measurable[cylinderEvents Δ] fun f : ∀ i, X i => f i := measurable_cylinderEvents_iff.1 measurable_id hi lemma Measurable.eval_cylinderEvents {g : α → ∀ i, X i} (hi : i ∈ Δ) (hg : @Measurable _ _ _ (cylinderEvents Δ) g) : Measurable fun a ↦ g a i := (measurable_cylinderEvent_apply hi).comp hg @[fun_prop] lemma measurable_cylinderEvents_lambda (f : α → ∀ i, X i) (hf : ∀ i, Measurable fun a ↦ f a i) : Measurable f := measurable_pi_iff.mpr hf /-- The function `(f, x) ↦ update f a x : (Π a, X a) × X a → Π a, X a` is measurable. -/ lemma measurable_update_cylinderEvents' [DecidableEq ι] : @Measurable _ _ (.prod (cylinderEvents Δ) (m i)) (cylinderEvents Δ) (fun p : (∀ i, X i) × X i ↦ update p.1 i p.2) := by rw [measurable_cylinderEvents_iff] intro j hj dsimp [update] split_ifs with h · subst h dsimp exact measurable_snd · exact measurable_cylinderEvents_iff.1 measurable_fst hj lemma measurable_uniqueElim_cylinderEvents [Unique ι] : Measurable (uniqueElim : X (default : ι) → ∀ i, X i) := by simp_rw [measurable_pi_iff, Unique.forall_iff, uniqueElim_default]; exact measurable_id /-- The function `update f a : X a → Π a, X a` is always measurable. This doesn't require `f` to be measurable. This should not be confused with the statement that `update f a x` is measurable. -/ @[measurability] lemma measurable_update_cylinderEvents (f : ∀ a : ι, X a) {a : ι} [DecidableEq ι] : @Measurable _ _ _ (cylinderEvents Δ) (update f a) := measurable_update_cylinderEvents'.comp measurable_prodMk_left lemma measurable_update_cylinderEvents_left {a : ι} [DecidableEq ι] {x : X a} : @Measurable _ _ (cylinderEvents Δ) (cylinderEvents Δ) (update · a x) := measurable_update_cylinderEvents'.comp measurable_prodMk_right lemma measurable_restrict_cylinderEvents (Δ : Set ι) : Measurable[cylinderEvents (X := X) Δ] (restrict Δ) := by rw [@measurable_pi_iff]; exact fun i ↦ measurable_cylinderEvent_apply i.2 end cylinderEvents end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/AddChar.lean
import Mathlib.Algebra.Group.AddChar import Mathlib.MeasureTheory.MeasurableSpace.Defs /-! # Measurable space instance for additive characters This file endows `AddChar A M` with the discrete measurable space structure whenever `A` is a finite discrete measurable space. ## TODO Give the definition in the correct generality. -/ namespace AddChar variable {A M : Type*} [AddMonoid A] [Monoid M] [MeasurableSpace A] [MeasurableSpace M] @[nolint unusedArguments] instance instMeasurableSpace [DiscreteMeasurableSpace A] [Finite A] : MeasurableSpace (AddChar A M) := ⊤ instance instDiscreteMeasurableSpace [DiscreteMeasurableSpace A] [Finite A] : DiscreteMeasurableSpace (AddChar A M) := ⟨fun _ ↦ trivial⟩ end AddChar
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/Polish/EmbeddingReal.lean
import Mathlib.Analysis.Real.Cardinality import Mathlib.MeasureTheory.Constructions.Polish.Basic /-! # A Polish Borel space is measurably equivalent to a set of reals -/ open Set Function PolishSpace PiNat TopologicalSpace Bornology Metric Filter Topology MeasureTheory namespace MeasureTheory variable (α : Type*) [MeasurableSpace α] [StandardBorelSpace α] theorem exists_nat_measurableEquiv_range_coe_fin_of_finite [Finite α] : ∃ n : ℕ, Nonempty (α ≃ᵐ range ((↑) : Fin n → ℝ)) := by obtain ⟨n, ⟨n_equiv⟩⟩ := Finite.exists_equiv_fin α refine ⟨n, ⟨PolishSpace.Equiv.measurableEquiv (n_equiv.trans ?_)⟩⟩ exact Equiv.ofInjective _ (Nat.cast_injective.comp Fin.val_injective) theorem measurableEquiv_range_coe_nat_of_infinite_of_countable [Infinite α] [Countable α] : Nonempty (α ≃ᵐ range ((↑) : ℕ → ℝ)) := by have : PolishSpace (range ((↑) : ℕ → ℝ)) := Nat.isClosedEmbedding_coe_real.isClosedMap.isClosed_range.polishSpace refine ⟨PolishSpace.Equiv.measurableEquiv ?_⟩ refine (nonempty_equiv_of_countable.some : α ≃ ℕ).trans ?_ exact Equiv.ofInjective ((↑) : ℕ → ℝ) Nat.cast_injective /-- Any standard Borel space is measurably equivalent to a subset of the reals. -/ theorem exists_subset_real_measurableEquiv : ∃ s : Set ℝ, MeasurableSet s ∧ Nonempty (α ≃ᵐ s) := by by_cases hα : Countable α · cases finite_or_infinite α · obtain ⟨n, h_nonempty_equiv⟩ := exists_nat_measurableEquiv_range_coe_fin_of_finite α refine ⟨_, ?_, h_nonempty_equiv⟩ letI : MeasurableSpace (Fin n) := borel (Fin n) haveI : BorelSpace (Fin n) := ⟨rfl⟩ apply MeasurableEmbedding.measurableSet_range (mα := by infer_instance) exact continuous_of_discreteTopology.measurableEmbedding (Nat.cast_injective.comp Fin.val_injective) · refine ⟨_, ?_, measurableEquiv_range_coe_nat_of_infinite_of_countable α⟩ apply MeasurableEmbedding.measurableSet_range (mα := by infer_instance) exact continuous_of_discreteTopology.measurableEmbedding Nat.cast_injective · refine ⟨univ, MeasurableSet.univ, ⟨(PolishSpace.measurableEquivOfNotCountable hα ?_ : α ≃ᵐ (univ : Set ℝ))⟩⟩ rw [countable_coe_iff] exact Cardinal.not_countable_real /-- Any standard Borel space embeds measurably into the reals. -/ theorem exists_measurableEmbedding_real : ∃ f : α → ℝ, MeasurableEmbedding f := by obtain ⟨s, hs, ⟨e⟩⟩ := exists_subset_real_measurableEquiv α exact ⟨(↑) ∘ e, (MeasurableEmbedding.subtype_coe hs).comp e.measurableEmbedding⟩ /-- A measurable embedding of a standard Borel space into `ℝ`. -/ noncomputable def embeddingReal (Ω : Type*) [MeasurableSpace Ω] [StandardBorelSpace Ω] : Ω → ℝ := (exists_measurableEmbedding_real Ω).choose lemma measurableEmbedding_embeddingReal (Ω : Type*) [MeasurableSpace Ω] [StandardBorelSpace Ω] : MeasurableEmbedding (embeddingReal Ω) := (exists_measurableEmbedding_real Ω).choose_spec @[fun_prop] lemma measurable_embeddingReal (Ω : Type*) [MeasurableSpace Ω] [StandardBorelSpace Ω] : Measurable (embeddingReal Ω) := (measurableEmbedding_embeddingReal Ω).measurable end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/Polish/StronglyMeasurable.lean
import Mathlib.MeasureTheory.Constructions.Polish.Basic import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic /-! # Results about strongly measurable functions In measure theory it is often assumed that some space is a `PolishSpace`, i.e. a separable and completely metrizable topological space, because it ensures a nice interaction between the topology and the measurable space structure. Moreover a strongly measurable function whose codomain is a metric space is measurable and has a separable range (see `stronglyMeasurable_iff_measurable_separable`). Therefore if the codomain is also complete, by corestricting the function to the closure of its range, some results about measurable functions can be extended to strongly measurable functions without assuming separability on the codomain. The purpose of this file is to collect those results. -/ open Filter MeasureTheory Set TopologicalSpace open scoped Topology variable {ι X E : Type*} [MeasurableSpace X] [TopologicalSpace E] [IsCompletelyMetrizableSpace E] [Countable ι] {l : Filter ι} [l.IsCountablyGenerated] {f : ι → X → E} namespace MeasureTheory.StronglyMeasurable theorem measurableSet_exists_tendsto (hf : ∀ i, StronglyMeasurable (f i)) : MeasurableSet {x | ∃ c, Tendsto (f · x) l (𝓝 c)} := by obtain rfl | hl := eq_or_neBot l · simp_all borelize E letI := upgradeIsCompletelyMetrizable E let s := closure (⋃ i, range (f i)) have : PolishSpace s := { toSecondCountableTopology := @UniformSpace.secondCountable_of_separable s _ _ (IsSeparable.iUnion (fun i ↦ (hf i).isSeparable_range)).closure.separableSpace toIsCompletelyMetrizableSpace := isClosed_closure.isCompletelyMetrizableSpace } let g i x : s := ⟨f i x, subset_closure <| mem_iUnion.2 ⟨i, ⟨x, rfl⟩⟩⟩ have mg i : Measurable (g i) := (hf i).measurable.subtype_mk convert MeasureTheory.measurableSet_exists_tendsto (l := l) mg with x refine ⟨fun ⟨c, hc⟩ ↦ ⟨⟨c, ?_⟩, tendsto_subtype_rng.2 hc⟩, fun ⟨c, hc⟩ ↦ ⟨c, tendsto_subtype_rng.1 hc⟩⟩ exact mem_closure_of_tendsto hc (Eventually.of_forall fun i ↦ mem_iUnion.2 ⟨i, ⟨x, rfl⟩⟩) theorem limUnder [hE : Nonempty E] (hf : ∀ i, StronglyMeasurable (f i)) : StronglyMeasurable (fun x ↦ limUnder l (f · x)) := by obtain rfl | hl := eq_or_neBot l · simpa [limUnder, Filter.map_bot] using stronglyMeasurable_const borelize E let e := Classical.choice hE rw [stronglyMeasurable_iff_measurable_separable]; constructor · let conv := {x | ∃ c, Tendsto (f · x) l (𝓝 c)} have mconv : MeasurableSet conv := StronglyMeasurable.measurableSet_exists_tendsto hf have : (fun x ↦ _root_.limUnder l (f · x)) = ((↑) : conv → X).extend (fun x ↦ _root_.limUnder l (f · x)) (fun _ ↦ e) := by ext x by_cases hx : x ∈ conv · rw [Function.extend_val_apply hx] · rw [Function.extend_val_apply' hx, limUnder_of_not_tendsto hx] rw [this] refine (MeasurableEmbedding.subtype_coe mconv).measurable_extend (measurable_of_tendsto_metrizable' l (fun i ↦ (hf i).measurable.comp measurable_subtype_coe) (tendsto_pi_nhds.2 fun ⟨x, ⟨c, hc⟩⟩ ↦ ?_)) measurable_const rwa [hc.limUnder_eq] · let s := closure (⋃ i, range (f i)) ∪ {e} have hs : IsSeparable s := (IsSeparable.iUnion (fun i ↦ (hf i).isSeparable_range)).closure.union (finite_singleton e).isSeparable refine hs.mono ?_ rintro - ⟨x, rfl⟩ by_cases hx : ∃ c, Tendsto (f · x) l (𝓝 c) · obtain ⟨c, hc⟩ := hx simp_rw [hc.limUnder_eq] exact subset_union_left <| mem_closure_of_tendsto hc (Eventually.of_forall fun i ↦ mem_iUnion.2 ⟨i, ⟨x, rfl⟩⟩) · simp_rw [limUnder_of_not_tendsto hx] exact subset_union_right (mem_singleton e) end MeasureTheory.StronglyMeasurable
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric import Mathlib.MeasureTheory.Constructions.BorelSpace.Order import Mathlib.Topology.MetricSpace.Perfect import Mathlib.Topology.Separation.CountableSeparatingOn /-! # The Borel sigma-algebra on Polish spaces We discuss several results pertaining to the relationship between the topology and the Borel structure on Polish spaces. ## Main definitions and results First, we define standard Borel spaces. * A `StandardBorelSpace α` is a typeclass for measurable spaces which arise as the Borel sets of some Polish topology. Next, we define the class of analytic sets and establish its basic properties. * `MeasureTheory.AnalyticSet s`: a set in a topological space is analytic if it is the continuous image of a Polish space. Equivalently, it is empty, or the image of `ℕ → ℕ`. * `MeasureTheory.AnalyticSet.image_of_continuous`: a continuous image of an analytic set is analytic. * `MeasurableSet.analyticSet`: in a Polish space, any Borel-measurable set is analytic. Then, we show Lusin's theorem that two disjoint analytic sets can be separated by Borel sets. * `MeasurablySeparable s t` states that there exists a measurable set containing `s` and disjoint from `t`. * `AnalyticSet.measurablySeparable` shows that two disjoint analytic sets are separated by a Borel set. We then prove the Lusin-Souslin theorem that a continuous injective image of a Borel subset of a Polish space is Borel. The proof of this nontrivial result relies on the above results on analytic sets. * `MeasurableSet.image_of_continuousOn_injOn` asserts that, if `s` is a Borel measurable set in a Polish space, then the image of `s` under a continuous injective map is still Borel measurable. * `Continuous.measurableEmbedding` states that a continuous injective map on a Polish space is a measurable embedding for the Borel sigma-algebra. * `ContinuousOn.measurableEmbedding` is the same result for a map restricted to a measurable set on which it is continuous. * `Measurable.measurableEmbedding` states that a measurable injective map from a standard Borel space to a second-countable topological space is a measurable embedding. * `isClopenable_iff_measurableSet`: in a Polish space, a set is clopenable (i.e., it can be made open and closed by using a finer Polish topology) if and only if it is Borel-measurable. We use this to prove several versions of the Borel isomorphism theorem. * `PolishSpace.measurableEquivOfNotCountable` : Any two uncountable standard Borel spaces are Borel isomorphic. * `PolishSpace.Equiv.measurableEquiv` : Any two standard Borel spaces of the same cardinality are Borel isomorphic. -/ open Set Function PolishSpace PiNat TopologicalSpace Bornology Metric Filter Topology MeasureTheory /-! ### Standard Borel Spaces -/ variable (α : Type*) /-- A standard Borel space is a measurable space arising as the Borel sets of some Polish topology. This is useful in situations where a space has no natural topology or the natural topology in a space is non-Polish. To endow a standard Borel space `α` with a compatible Polish topology, use `letI := upgradeStandardBorel α`. One can then use `eq_borel_upgradeStandardBorel α` to rewrite the `MeasurableSpace α` instance to `borel α t`, where `t` is the new topology. -/ class StandardBorelSpace [MeasurableSpace α] : Prop where /-- There exists a compatible Polish topology. -/ polish : ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α /-- A convenience class similar to `UpgradedPolishSpace`. No instance should be registered. Instead one should use `letI := upgradeStandardBorel α`. -/ class UpgradedStandardBorel extends MeasurableSpace α, TopologicalSpace α, BorelSpace α, PolishSpace α /-- Use as `letI := upgradeStandardBorel α` to endow a standard Borel space `α` with a compatible Polish topology. Warning: following this with `borelize α` will cause an error. Instead, one can rewrite with `eq_borel_upgradeStandardBorel α`. TODO: fix the corresponding bug in `borelize`. -/ noncomputable def upgradeStandardBorel [MeasurableSpace α] [h : StandardBorelSpace α] : UpgradedStandardBorel α := by choose τ hb hp using h.polish constructor /-- The `MeasurableSpace α` instance on a `StandardBorelSpace` `α` is equal to the Borel sets of `upgradeStandardBorel α`. -/ theorem eq_borel_upgradeStandardBorel [MeasurableSpace α] [StandardBorelSpace α] : ‹MeasurableSpace α› = @borel _ (upgradeStandardBorel α).toTopologicalSpace := @BorelSpace.measurable_eq _ (upgradeStandardBorel α).toTopologicalSpace _ (upgradeStandardBorel α).toBorelSpace variable {α} section variable [MeasurableSpace α] -- See note [lower instance priority] instance (priority := 100) standardBorel_of_polish [τ : TopologicalSpace α] [BorelSpace α] [PolishSpace α] : StandardBorelSpace α := by exists τ -- See note [lower instance priority] instance (priority := 100) standardBorelSpace_of_discreteMeasurableSpace [DiscreteMeasurableSpace α] [Countable α] : StandardBorelSpace α := let _ : TopologicalSpace α := ⊥ have : DiscreteTopology α := ⟨rfl⟩ inferInstance -- See note [lower instance priority] instance (priority := 100) countablyGenerated_of_standardBorel [StandardBorelSpace α] : MeasurableSpace.CountablyGenerated α := letI := upgradeStandardBorel α inferInstance -- See note [lower instance priority] instance (priority := 100) measurableSingleton_of_standardBorel [StandardBorelSpace α] : MeasurableSingletonClass α := letI := upgradeStandardBorel α inferInstance namespace StandardBorelSpace variable {β : Type*} [MeasurableSpace β] section instances /-- A product of two standard Borel spaces is standard Borel. -/ instance prod [StandardBorelSpace α] [StandardBorelSpace β] : StandardBorelSpace (α × β) := letI := upgradeStandardBorel α letI := upgradeStandardBorel β inferInstance /-- A product of countably many standard Borel spaces is standard Borel. -/ instance pi_countable {ι : Type*} [Countable ι] {α : ι → Type*} [∀ n, MeasurableSpace (α n)] [∀ n, StandardBorelSpace (α n)] : StandardBorelSpace (∀ n, α n) := letI := fun n => upgradeStandardBorel (α n) inferInstance end instances end StandardBorelSpace end variable {ι : Type*} namespace MeasureTheory variable [TopologicalSpace α] /-! ### Analytic sets -/ /-- An analytic set is a set which is the continuous image of some Polish space. There are several equivalent characterizations of this definition. For the definition, we pick one that avoids universe issues: a set is analytic if and only if it is a continuous image of `ℕ → ℕ` (or if it is empty). The above more usual characterization is given in `analyticSet_iff_exists_polishSpace_range`. Warning: these are analytic sets in the context of descriptive set theory (which is why they are registered in the namespace `MeasureTheory`). They have nothing to do with analytic sets in the context of complex analysis. -/ irreducible_def AnalyticSet (s : Set α) : Prop := s = ∅ ∨ ∃ f : (ℕ → ℕ) → α, Continuous f ∧ range f = s theorem analyticSet_empty : AnalyticSet (∅ : Set α) := by rw [AnalyticSet] exact Or.inl rfl theorem analyticSet_range_of_polishSpace {β : Type*} [TopologicalSpace β] [PolishSpace β] {f : β → α} (f_cont : Continuous f) : AnalyticSet (range f) := by cases isEmpty_or_nonempty β · rw [range_eq_empty] exact analyticSet_empty · rw [AnalyticSet] obtain ⟨g, g_cont, hg⟩ : ∃ g : (ℕ → ℕ) → β, Continuous g ∧ Surjective g := exists_nat_nat_continuous_surjective β refine Or.inr ⟨f ∘ g, f_cont.comp g_cont, ?_⟩ rw [hg.range_comp] /-- The image of an open set under a continuous map is analytic. -/ theorem _root_.IsOpen.analyticSet_image {β : Type*} [TopologicalSpace β] [PolishSpace β] {s : Set β} (hs : IsOpen s) {f : β → α} (f_cont : Continuous f) : AnalyticSet (f '' s) := by rw [image_eq_range] haveI : PolishSpace s := hs.polishSpace exact analyticSet_range_of_polishSpace (f_cont.comp continuous_subtype_val) /-- A set is analytic if and only if it is the continuous image of some Polish space. -/ theorem analyticSet_iff_exists_polishSpace_range {s : Set α} : AnalyticSet s ↔ ∃ (β : Type) (h : TopologicalSpace β) (_ : @PolishSpace β h) (f : β → α), @Continuous _ _ h _ f ∧ range f = s := by constructor · intro h rw [AnalyticSet] at h rcases h with h | h · refine ⟨Empty, inferInstance, inferInstance, Empty.elim, continuous_bot, ?_⟩ rw [h] exact range_eq_empty _ · exact ⟨ℕ → ℕ, inferInstance, inferInstance, h⟩ · rintro ⟨β, h, h', f, f_cont, f_range⟩ rw [← f_range] exact analyticSet_range_of_polishSpace f_cont /-- The continuous image of an analytic set is analytic -/ theorem AnalyticSet.image_of_continuousOn {β : Type*} [TopologicalSpace β] {s : Set α} (hs : AnalyticSet s) {f : α → β} (hf : ContinuousOn f s) : AnalyticSet (f '' s) := by rcases analyticSet_iff_exists_polishSpace_range.1 hs with ⟨γ, γtop, γpolish, g, g_cont, gs⟩ have : f '' s = range (f ∘ g) := by rw [range_comp, gs] rw [this] apply analyticSet_range_of_polishSpace apply hf.comp_continuous g_cont fun x => _ rw [← gs] exact mem_range_self theorem AnalyticSet.image_of_continuous {β : Type*} [TopologicalSpace β] {s : Set α} (hs : AnalyticSet s) {f : α → β} (hf : Continuous f) : AnalyticSet (f '' s) := hs.image_of_continuousOn hf.continuousOn /-- A countable intersection of analytic sets is analytic. -/ theorem AnalyticSet.iInter [hι : Nonempty ι] [Countable ι] [T2Space α] {s : ι → Set α} (hs : ∀ n, AnalyticSet (s n)) : AnalyticSet (⋂ n, s n) := by rcases hι with ⟨i₀⟩ /- For the proof, write each `s n` as the continuous image under a map `f n` of a Polish space `β n`. The product space `γ = Π n, β n` is also Polish, and so is the subset `t` of sequences `x n` for which `f n (x n)` is independent of `n`. The set `t` is Polish, and the range of `x ↦ f 0 (x 0)` on `t` is exactly `⋂ n, s n`, so this set is analytic. -/ choose β hβ h'β f f_cont f_range using fun n => analyticSet_iff_exists_polishSpace_range.1 (hs n) let γ := ∀ n, β n let t : Set γ := ⋂ n, { x | f n (x n) = f i₀ (x i₀) } have t_closed : IsClosed t := by apply isClosed_iInter intro n exact isClosed_eq ((f_cont n).comp (continuous_apply n)) ((f_cont i₀).comp (continuous_apply i₀)) haveI : PolishSpace t := t_closed.polishSpace let F : t → α := fun x => f i₀ ((x : γ) i₀) have F_cont : Continuous F := (f_cont i₀).comp ((continuous_apply i₀).comp continuous_subtype_val) have F_range : range F = ⋂ n : ι, s n := by apply Subset.antisymm · rintro y ⟨x, rfl⟩ refine mem_iInter.2 fun n => ?_ have : f n ((x : γ) n) = F x := (mem_iInter.1 x.2 n :) rw [← this, ← f_range n] exact mem_range_self _ · intro y hy have A : ∀ n, ∃ x : β n, f n x = y := by intro n rw [← mem_range, f_range n] exact mem_iInter.1 hy n choose x hx using A have xt : x ∈ t := by refine mem_iInter.2 fun n => ?_ simp [γ, hx] refine ⟨⟨x, xt⟩, ?_⟩ exact hx i₀ rw [← F_range] exact analyticSet_range_of_polishSpace F_cont /-- A countable union of analytic sets is analytic. -/ theorem AnalyticSet.iUnion [Countable ι] {s : ι → Set α} (hs : ∀ n, AnalyticSet (s n)) : AnalyticSet (⋃ n, s n) := by /- For the proof, write each `s n` as the continuous image under a map `f n` of a Polish space `β n`. The union space `γ = Σ n, β n` is also Polish, and the map `F : γ → α` which coincides with `f n` on `β n` sends it to `⋃ n, s n`. -/ choose β hβ h'β f f_cont f_range using fun n => analyticSet_iff_exists_polishSpace_range.1 (hs n) let γ := Σ n, β n let F : γ → α := fun ⟨n, x⟩ ↦ f n x have F_cont : Continuous F := continuous_sigma f_cont have F_range : range F = ⋃ n, s n := by simp only [γ, F, range_sigma_eq_iUnion_range, f_range] rw [← F_range] exact analyticSet_range_of_polishSpace F_cont theorem _root_.IsClosed.analyticSet [PolishSpace α] {s : Set α} (hs : IsClosed s) : AnalyticSet s := by haveI : PolishSpace s := hs.polishSpace rw [← @Subtype.range_val α s] exact analyticSet_range_of_polishSpace continuous_subtype_val /-- Given a Borel-measurable set in a Polish space, there exists a finer Polish topology making it clopen. This is in fact an equivalence, see `isClopenable_iff_measurableSet`. -/ theorem _root_.MeasurableSet.isClopenable [PolishSpace α] [MeasurableSpace α] [BorelSpace α] {s : Set α} (hs : MeasurableSet s) : IsClopenable s := by revert s apply MeasurableSet.induction_on_open · exact fun u hu => hu.isClopenable · exact fun u _ h'u => h'u.compl · exact fun f _ _ hf => IsClopenable.iUnion hf /-- A Borel-measurable set in a Polish space is analytic. -/ theorem _root_.MeasurableSet.analyticSet {α : Type*} [t : TopologicalSpace α] [PolishSpace α] [MeasurableSpace α] [BorelSpace α] {s : Set α} (hs : MeasurableSet s) : AnalyticSet s := by /- For a short proof (avoiding measurable induction), one sees `s` as a closed set for a finer topology `t'`. It is analytic for this topology. As the identity from `t'` to `t` is continuous and the image of an analytic set is analytic, it follows that `s` is also analytic for `t`. -/ obtain ⟨t', t't, t'_polish, s_closed, _⟩ : ∃ t' : TopologicalSpace α, t' ≤ t ∧ @PolishSpace α t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs.isClopenable have A := @IsClosed.analyticSet α t' t'_polish s s_closed convert @AnalyticSet.image_of_continuous α t' α t s A id (continuous_id_of_le t't) simp only [id, image_id'] /-- Given a Borel-measurable function from a Polish space to a second-countable space, there exists a finer Polish topology on the source space for which the function is continuous. -/ theorem _root_.Measurable.exists_continuous {α β : Type*} [t : TopologicalSpace α] [PolishSpace α] [MeasurableSpace α] [BorelSpace α] [tβ : TopologicalSpace β] [MeasurableSpace β] [OpensMeasurableSpace β] {f : α → β} [SecondCountableTopology (range f)] (hf : Measurable f) : ∃ t' : TopologicalSpace α, t' ≤ t ∧ @Continuous α β t' tβ f ∧ @PolishSpace α t' := by obtain ⟨b, b_count, -, hb⟩ : ∃ b : Set (Set (range f)), b.Countable ∧ ∅ ∉ b ∧ IsTopologicalBasis b := exists_countable_basis (range f) haveI : Countable b := b_count.to_subtype have : ∀ s : b, IsClopenable (rangeFactorization f ⁻¹' s) := fun s ↦ by apply MeasurableSet.isClopenable exact hf.subtype_mk (hb.isOpen s.2).measurableSet choose T Tt Tpolish _ Topen using this obtain ⟨t', t'T, t't, t'_polish⟩ : ∃ t' : TopologicalSpace α, (∀ i, t' ≤ T i) ∧ t' ≤ t ∧ @PolishSpace α t' := exists_polishSpace_forall_le (t := t) T Tt Tpolish refine ⟨t', t't, ?_, t'_polish⟩ have : Continuous[t', _] (rangeFactorization f) := hb.continuous_iff.2 fun s hs => t'T ⟨s, hs⟩ _ (Topen ⟨s, hs⟩) exact continuous_subtype_val.comp this /-- The image of a measurable set in a standard Borel space under a measurable map is an analytic set. -/ theorem _root_.MeasurableSet.analyticSet_image {X Y : Type*} [MeasurableSpace X] [StandardBorelSpace X] [TopologicalSpace Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] {f : X → Y} [SecondCountableTopology (range f)] {s : Set X} (hs : MeasurableSet s) (hf : Measurable f) : AnalyticSet (f '' s) := by letI := upgradeStandardBorel X rw [eq_borel_upgradeStandardBorel X] at hs rcases hf.exists_continuous with ⟨τ', hle, hfc, hτ'⟩ letI m' : MeasurableSpace X := @borel _ τ' haveI b' : BorelSpace X := ⟨rfl⟩ have hle := borel_anti hle exact (hle _ hs).analyticSet.image_of_continuous hfc /-- Preimage of an analytic set is an analytic set. -/ protected lemma AnalyticSet.preimage {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] [PolishSpace X] [T2Space Y] {s : Set Y} (hs : AnalyticSet s) {f : X → Y} (hf : Continuous f) : AnalyticSet (f ⁻¹' s) := by rcases analyticSet_iff_exists_polishSpace_range.1 hs with ⟨Z, _, _, g, hg, rfl⟩ have : IsClosed {x : X × Z | f x.1 = g x.2} := isClosed_eq hf.fst' hg.snd' convert this.analyticSet.image_of_continuous continuous_fst ext x simp [eq_comm] /-! ### Separating sets with measurable sets -/ /-- Two sets `u` and `v` in a measurable space are measurably separable if there exists a measurable set containing `u` and disjoint from `v`. This is mostly interesting for Borel-separable sets. -/ def MeasurablySeparable {α : Type*} [MeasurableSpace α] (s t : Set α) : Prop := ∃ u, s ⊆ u ∧ Disjoint t u ∧ MeasurableSet u theorem MeasurablySeparable.iUnion [Countable ι] {α : Type*} [MeasurableSpace α] {s t : ι → Set α} (h : ∀ m n, MeasurablySeparable (s m) (t n)) : MeasurablySeparable (⋃ n, s n) (⋃ m, t m) := by choose u hsu htu hu using h refine ⟨⋃ m, ⋂ n, u m n, ?_, ?_, ?_⟩ · refine iUnion_subset fun m => subset_iUnion_of_subset m ?_ exact subset_iInter fun n => hsu m n · simp_rw [disjoint_iUnion_left, disjoint_iUnion_right] intro n m apply Disjoint.mono_right _ (htu m n) apply iInter_subset · refine MeasurableSet.iUnion fun m => ?_ exact MeasurableSet.iInter fun n => hu m n /-- The hard part of the Lusin separation theorem saying that two disjoint analytic sets are contained in disjoint Borel sets (see the full statement in `AnalyticSet.measurablySeparable`). Here, we prove this when our analytic sets are the ranges of functions from `ℕ → ℕ`. -/ theorem measurablySeparable_range_of_disjoint [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α] {f g : (ℕ → ℕ) → α} (hf : Continuous f) (hg : Continuous g) (h : Disjoint (range f) (range g)) : MeasurablySeparable (range f) (range g) := by /- We follow [Kechris, *Classical Descriptive Set Theory* (Theorem 14.7)][kechris1995]. If the ranges are not Borel-separated, then one can find two cylinders of length one whose images are not Borel-separated, and then two smaller cylinders of length two whose images are not Borel-separated, and so on. One thus gets two sequences of cylinders, that decrease to two points `x` and `y`. Their images are different by the disjointness assumption, hence contained in two disjoint open sets by the T2 property. By continuity, long enough cylinders around `x` and `y` have images which are separated by these two disjoint open sets, a contradiction. -/ by_contra hfg have I : ∀ n x y, ¬MeasurablySeparable (f '' cylinder x n) (g '' cylinder y n) → ∃ x' y', x' ∈ cylinder x n ∧ y' ∈ cylinder y n ∧ ¬MeasurablySeparable (f '' cylinder x' (n + 1)) (g '' cylinder y' (n + 1)) := by intro n x y contrapose! intro H rw [← iUnion_cylinder_update x n, ← iUnion_cylinder_update y n, image_iUnion, image_iUnion] refine MeasurablySeparable.iUnion fun i j => ?_ exact H _ _ (update_mem_cylinder _ _ _) (update_mem_cylinder _ _ _) -- consider the set of pairs of cylinders of some length whose images are not Borel-separated let A := { p : ℕ × (ℕ → ℕ) × (ℕ → ℕ) // ¬MeasurablySeparable (f '' cylinder p.2.1 p.1) (g '' cylinder p.2.2 p.1) } -- for each such pair, one can find longer cylinders whose images are not Borel-separated either have : ∀ p : A, ∃ q : A, q.1.1 = p.1.1 + 1 ∧ q.1.2.1 ∈ cylinder p.1.2.1 p.1.1 ∧ q.1.2.2 ∈ cylinder p.1.2.2 p.1.1 := by rintro ⟨⟨n, x, y⟩, hp⟩ rcases I n x y hp with ⟨x', y', hx', hy', h'⟩ exact ⟨⟨⟨n + 1, x', y'⟩, h'⟩, rfl, hx', hy'⟩ choose F hFn hFx hFy using this let p0 : A := ⟨⟨0, fun _ => 0, fun _ => 0⟩, by simp [hfg]⟩ -- construct inductively decreasing sequences of cylinders whose images are not separated let p : ℕ → A := fun n => F^[n] p0 have prec : ∀ n, p (n + 1) = F (p n) := fun n => by simp only [p, iterate_succ', Function.comp] -- check that at the `n`-th step we deal with cylinders of length `n` have pn_fst : ∀ n, (p n).1.1 = n := fun n ↦ by induction n with | zero => rfl | succ n IH => simp only [prec, hFn, IH] -- check that the cylinders we construct are indeed decreasing, by checking that the coordinates -- are stationary. have Ix : ∀ m n, m + 1 ≤ n → (p n).1.2.1 m = (p (m + 1)).1.2.1 m := by intro m apply Nat.le_induction · rfl intro n hmn IH have I : (F (p n)).val.snd.fst m = (p n).val.snd.fst m := by apply hFx (p n) m rw [pn_fst] exact hmn rw [prec, I, IH] have Iy : ∀ m n, m + 1 ≤ n → (p n).1.2.2 m = (p (m + 1)).1.2.2 m := by intro m apply Nat.le_induction · rfl intro n hmn IH have I : (F (p n)).val.snd.snd m = (p n).val.snd.snd m := by apply hFy (p n) m rw [pn_fst] exact hmn rw [prec, I, IH] -- denote by `x` and `y` the limit points of these two sequences of cylinders. set x : ℕ → ℕ := fun n => (p (n + 1)).1.2.1 n with hx set y : ℕ → ℕ := fun n => (p (n + 1)).1.2.2 n with hy -- by design, the cylinders around these points have images which are not Borel-separable. have M : ∀ n, ¬MeasurablySeparable (f '' cylinder x n) (g '' cylinder y n) := by intro n convert (p n).2 using 3 · rw [pn_fst, ← mem_cylinder_iff_eq, mem_cylinder_iff] intro i hi rw [hx] exact (Ix i n hi).symm · rw [pn_fst, ← mem_cylinder_iff_eq, mem_cylinder_iff] intro i hi rw [hy] exact (Iy i n hi).symm -- consider two open sets separating `f x` and `g y`. obtain ⟨u, v, u_open, v_open, xu, yv, huv⟩ : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ f x ∈ u ∧ g y ∈ v ∧ Disjoint u v := by apply t2_separation exact disjoint_iff_forall_ne.1 h (mem_range_self _) (mem_range_self _) letI : MetricSpace (ℕ → ℕ) := metricSpaceNatNat obtain ⟨εx, εxpos, hεx⟩ : ∃ (εx : ℝ), εx > 0 ∧ Metric.ball x εx ⊆ f ⁻¹' u := by apply Metric.mem_nhds_iff.1 exact hf.continuousAt.preimage_mem_nhds (u_open.mem_nhds xu) obtain ⟨εy, εypos, hεy⟩ : ∃ (εy : ℝ), εy > 0 ∧ Metric.ball y εy ⊆ g ⁻¹' v := by apply Metric.mem_nhds_iff.1 exact hg.continuousAt.preimage_mem_nhds (v_open.mem_nhds yv) obtain ⟨n, hn⟩ : ∃ n : ℕ, (1 / 2 : ℝ) ^ n < min εx εy := exists_pow_lt_of_lt_one (lt_min εxpos εypos) (by norm_num) -- for large enough `n`, these open sets separate the images of long cylinders around `x` and `y` have B : MeasurablySeparable (f '' cylinder x n) (g '' cylinder y n) := by refine ⟨u, ?_, ?_, u_open.measurableSet⟩ · rw [image_subset_iff] apply Subset.trans _ hεx intro z hz rw [mem_cylinder_iff_dist_le] at hz exact hz.trans_lt (hn.trans_le (min_le_left _ _)) · refine Disjoint.mono_left ?_ huv.symm change g '' cylinder y n ⊆ v rw [image_subset_iff] apply Subset.trans _ hεy intro z hz rw [mem_cylinder_iff_dist_le] at hz exact hz.trans_lt (hn.trans_le (min_le_right _ _)) -- this is a contradiction. exact M n B /-- The **Lusin separation theorem**: if two analytic sets are disjoint, then they are contained in disjoint Borel sets. -/ theorem AnalyticSet.measurablySeparable [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α] {s t : Set α} (hs : AnalyticSet s) (ht : AnalyticSet t) (h : Disjoint s t) : MeasurablySeparable s t := by rw [AnalyticSet] at hs ht rcases hs with (rfl | ⟨f, f_cont, rfl⟩) · refine ⟨∅, Subset.refl _, by simp, MeasurableSet.empty⟩ rcases ht with (rfl | ⟨g, g_cont, rfl⟩) · exact ⟨univ, subset_univ _, by simp, MeasurableSet.univ⟩ exact measurablySeparable_range_of_disjoint f_cont g_cont h /-- **Suslin's Theorem**: in a Hausdorff topological space, an analytic set with an analytic complement is measurable. -/ theorem AnalyticSet.measurableSet_of_compl [T2Space α] [MeasurableSpace α] [OpensMeasurableSpace α] {s : Set α} (hs : AnalyticSet s) (hsc : AnalyticSet sᶜ) : MeasurableSet s := by rcases hs.measurablySeparable hsc disjoint_compl_right with ⟨u, hsu, hdu, hmu⟩ obtain rfl : s = u := hsu.antisymm (disjoint_compl_left_iff_subset.1 hdu) exact hmu end MeasureTheory /-! ### Measurability of preimages under measurable maps -/ namespace Measurable open MeasurableSpace variable {X Y Z β : Type*} [MeasurableSpace X] [StandardBorelSpace X] [TopologicalSpace Y] [T0Space Y] [MeasurableSpace Y] [OpensMeasurableSpace Y] [MeasurableSpace β] [MeasurableSpace Z] /-- If `f : X → Z` is a surjective Borel measurable map from a standard Borel space to a countably separated measurable space, then the preimage of a set `s` is measurable if and only if the set is measurable. One implication is the definition of measurability, the other one heavily relies on `X` being a standard Borel space. -/ theorem measurableSet_preimage_iff_of_surjective [CountablySeparated Z] {f : X → Z} (hf : Measurable f) (hsurj : Surjective f) {s : Set Z} : MeasurableSet (f ⁻¹' s) ↔ MeasurableSet s := by refine ⟨fun h => ?_, fun h => hf h⟩ rcases exists_opensMeasurableSpace_of_countablySeparated Z with ⟨τ, _, _, _⟩ apply AnalyticSet.measurableSet_of_compl · rw [← image_preimage_eq s hsurj] exact h.analyticSet_image hf · rw [← image_preimage_eq sᶜ hsurj] exact h.compl.analyticSet_image hf theorem map_measurableSpace_eq [CountablySeparated Z] {f : X → Z} (hf : Measurable f) (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = ‹MeasurableSpace Z› := MeasurableSpace.ext fun _ => hf.measurableSet_preimage_iff_of_surjective hsurj theorem map_measurableSpace_eq_borel [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f) (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = borel Y := by have d := hf.mono le_rfl OpensMeasurableSpace.borel_le letI := borel Y; haveI : BorelSpace Y := ⟨rfl⟩ exact d.map_measurableSpace_eq hsurj theorem borelSpace_codomain [SecondCountableTopology Y] {f : X → Y} (hf : Measurable f) (hsurj : Surjective f) : BorelSpace Y := ⟨(hf.map_measurableSpace_eq hsurj).symm.trans <| hf.map_measurableSpace_eq_borel hsurj⟩ /-- If `f : X → Z` is a Borel measurable map from a standard Borel space to a countably separated measurable space then the preimage of a set `s` is measurable if and only if the set is measurable in `Set.range f`. -/ theorem measurableSet_preimage_iff_preimage_val {f : X → Z} [CountablySeparated (range f)] (hf : Measurable f) {s : Set Z} : MeasurableSet (f ⁻¹' s) ↔ MeasurableSet ((↑) ⁻¹' s : Set (range f)) := have hf' : Measurable (rangeFactorization f) := hf.subtype_mk hf'.measurableSet_preimage_iff_of_surjective (s := Subtype.val ⁻¹' s) rangeFactorization_surjective /-- If `f : X → Z` is a Borel measurable map from a standard Borel space to a countably separated measurable space and the range of `f` is measurable, then the preimage of a set `s` is measurable if and only if the intersection with `Set.range f` is measurable. -/ theorem measurableSet_preimage_iff_inter_range {f : X → Z} [CountablySeparated (range f)] (hf : Measurable f) (hr : MeasurableSet (range f)) {s : Set Z} : MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (s ∩ range f) := by rw [hf.measurableSet_preimage_iff_preimage_val, inter_comm, ← (MeasurableEmbedding.subtype_coe hr).measurableSet_image, Subtype.image_preimage_coe] /-- If `f : X → Z` is a Borel measurable map from a standard Borel space to a countably separated measurable space, then for any measurable space `β` and `g : Z → β`, the composition `g ∘ f` is measurable if and only if the restriction of `g` to the range of `f` is measurable. -/ theorem measurable_comp_iff_restrict {f : X → Z} [CountablySeparated (range f)] (hf : Measurable f) {g : Z → β} : Measurable (g ∘ f) ↔ Measurable (restrict (range f) g) := forall₂_congr fun s _ => measurableSet_preimage_iff_preimage_val hf (s := g ⁻¹' s) /-- If `f : X → Z` is a surjective Borel measurable map from a standard Borel space to a countably separated measurable space, then for any measurable space `α` and `g : Z → α`, the composition `g ∘ f` is measurable if and only if `g` is measurable. -/ theorem measurable_comp_iff_of_surjective [CountablySeparated Z] {f : X → Z} (hf : Measurable f) (hsurj : Surjective f) {g : Z → β} : Measurable (g ∘ f) ↔ Measurable g := forall₂_congr fun s _ => measurableSet_preimage_iff_of_surjective hf hsurj (s := g ⁻¹' s) end Measurable theorem Continuous.map_eq_borel {X Y : Type*} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X] [TopologicalSpace Y] [T0Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f) (hsurj : Surjective f) : MeasurableSpace.map f ‹MeasurableSpace X› = borel Y := by borelize Y exact hf.measurable.map_measurableSpace_eq hsurj theorem Continuous.map_borel_eq {X Y : Type*} [TopologicalSpace X] [PolishSpace X] [TopologicalSpace Y] [T0Space Y] [SecondCountableTopology Y] {f : X → Y} (hf : Continuous f) (hsurj : Surjective f) : MeasurableSpace.map f (borel X) = borel Y := by borelize X exact hf.map_eq_borel hsurj instance Quotient.borelSpace {X : Type*} [TopologicalSpace X] [PolishSpace X] [MeasurableSpace X] [BorelSpace X] {s : Setoid X} [T0Space (Quotient s)] [SecondCountableTopology (Quotient s)] : BorelSpace (Quotient s) := ⟨continuous_quotient_mk'.map_eq_borel Quotient.mk'_surjective⟩ /-- When the subgroup `N < G` is not necessarily `Normal`, we have a `CosetSpace` as opposed to `QuotientGroup` (the next `instance`). TODO: typeclass inference should normally find this, but currently doesn't. E.g., `MeasurableSMul G (G ⧸ Γ)` fails to synthesize, even though `G ⧸ Γ` is the quotient of `G` by the action of `Γ`; it seems unable to pick up the `BorelSpace` instance. -/ @[to_additive AddCosetSpace.borelSpace] instance CosetSpace.borelSpace {G : Type*} [TopologicalSpace G] [PolishSpace G] [Group G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [T2Space (G ⧸ N)] [SecondCountableTopology (G ⧸ N)] : BorelSpace (G ⧸ N) := Quotient.borelSpace @[to_additive] instance QuotientGroup.borelSpace {G : Type*} [TopologicalSpace G] [PolishSpace G] [Group G] [IsTopologicalGroup G] [MeasurableSpace G] [BorelSpace G] {N : Subgroup G} [N.Normal] [IsClosed (N : Set G)] : BorelSpace (G ⧸ N) := ⟨continuous_mk.map_eq_borel mk_surjective⟩ /-! ### Injective images of Borel sets -/ variable {γ : Type*} /-- The **Lusin-Souslin theorem**: the range of a continuous injective function defined on a Polish space is Borel-measurable. -/ theorem MeasureTheory.measurableSet_range_of_continuous_injective {β : Type*} [TopologicalSpace γ] [PolishSpace γ] [TopologicalSpace β] [T2Space β] [MeasurableSpace β] [OpensMeasurableSpace β] {f : γ → β} (f_cont : Continuous f) (f_inj : Injective f) : MeasurableSet (range f) := by /- We follow [Fremlin, *Measure Theory* (volume 4, 423I)][fremlin_vol4]. Let `b = {s i}` be a countable basis for `α`. When `s i` and `s j` are disjoint, their images are disjoint analytic sets, hence by the separation theorem one can find a Borel-measurable set `q i j` separating them. Let `E i = closure (f '' s i) ∩ ⋂ j, q i j \ q j i`. It contains `f '' (s i)` and it is measurable. Let `F n = ⋃ E i`, where the union is taken over those `i` for which `diam (s i)` is bounded by some number `u n` tending to `0` with `n`. We claim that `range f = ⋂ F n`, from which the measurability is obvious. The inclusion `⊆` is straightforward. To show `⊇`, consider a point `x` in the intersection. For each `n`, it belongs to some `E i` with `diam (s i) ≤ u n`. Pick a point `y i ∈ s i`. We claim that for such `i` and `j`, the intersection `s i ∩ s j` is nonempty: if it were empty, then thanks to the separating set `q i j` in the definition of `E i` one could not have `x ∈ E i ∩ E j`. Since these two sets have small diameter, it follows that `y i` and `y j` are close. Thus, `y` is a Cauchy sequence, converging to a limit `z`. We claim that `f z = x`, completing the proof. Otherwise, one could find open sets `v` and `w` separating `f z` from `x`. Then, for large `n`, the image `f '' (s i)` would be included in `v` by continuity of `f`, so its closure would be contained in the closure of `v`, and therefore it would be disjoint from `w`. This is a contradiction since `x` belongs both to this closure and to `w`. -/ letI := TopologicalSpace.upgradeIsCompletelyMetrizable γ obtain ⟨b, b_count, b_nonempty, hb⟩ : ∃ b : Set (Set γ), b.Countable ∧ ∅ ∉ b ∧ IsTopologicalBasis b := exists_countable_basis γ haveI : Encodable b := b_count.toEncodable let A := { p : b × b // Disjoint (p.1 : Set γ) p.2 } -- for each pair of disjoint sets in the topological basis `b`, consider Borel sets separating -- their images, by injectivity of `f` and the Lusin separation theorem. have : ∀ p : A, ∃ q : Set β, f '' (p.1.1 : Set γ) ⊆ q ∧ Disjoint (f '' (p.1.2 : Set γ)) q ∧ MeasurableSet q := by intro p apply AnalyticSet.measurablySeparable ((hb.isOpen p.1.1.2).analyticSet_image f_cont) ((hb.isOpen p.1.2.2).analyticSet_image f_cont) exact Disjoint.image p.2 f_inj.injOn (subset_univ _) (subset_univ _) choose q hq1 hq2 q_meas using this -- define sets `E i` and `F n` as in the proof sketch above let E : b → Set β := fun s => closure (f '' s) ∩ ⋂ (t : b) (ht : Disjoint s.1 t.1), q ⟨(s, t), ht⟩ \ q ⟨(t, s), ht.symm⟩ obtain ⟨u, u_anti, u_pos, u_lim⟩ : ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) := exists_seq_strictAnti_tendsto (0 : ℝ) let F : ℕ → Set β := fun n => ⋃ (s : b) (_ : IsBounded s.1 ∧ diam s.1 ≤ u n), E s -- it is enough to show that `range f = ⋂ F n`, as the latter set is obviously measurable. suffices range f = ⋂ n, F n by have E_meas : ∀ s : b, MeasurableSet (E s) := by intro b refine isClosed_closure.measurableSet.inter ?_ refine MeasurableSet.iInter fun s => ?_ exact MeasurableSet.iInter fun hs => (q_meas _).diff (q_meas _) have F_meas : ∀ n, MeasurableSet (F n) := by intro n refine MeasurableSet.iUnion fun s => ?_ exact MeasurableSet.iUnion fun _ => E_meas _ rw [this] exact MeasurableSet.iInter fun n => F_meas n -- we check both inclusions. apply Subset.antisymm -- we start with the easy inclusion `range f ⊆ ⋂ F n`. One just needs to unfold the definitions. · rintro x ⟨y, rfl⟩ refine mem_iInter.2 fun n => ?_ obtain ⟨s, sb, ys, hs⟩ : ∃ (s : Set γ), s ∈ b ∧ y ∈ s ∧ s ⊆ ball y (u n / 2) := by apply hb.mem_nhds_iff.1 exact ball_mem_nhds _ (half_pos (u_pos n)) have diam_s : diam s ≤ u n := by apply (diam_mono hs isBounded_ball).trans convert diam_ball (x := y) (half_pos (u_pos n)).le ring refine mem_iUnion.2 ⟨⟨s, sb⟩, ?_⟩ refine mem_iUnion.2 ⟨⟨isBounded_ball.subset hs, diam_s⟩, ?_⟩ apply mem_inter (subset_closure (mem_image_of_mem _ ys)) refine mem_iInter.2 fun t => mem_iInter.2 fun ht => ⟨?_, ?_⟩ · apply hq1 exact mem_image_of_mem _ ys · apply disjoint_left.1 (hq2 ⟨(t, ⟨s, sb⟩), ht.symm⟩) exact mem_image_of_mem _ ys -- Now, let us prove the harder inclusion `⋂ F n ⊆ range f`. · intro x hx -- pick for each `n` a good set `s n` of small diameter for which `x ∈ E (s n)`. have C1 : ∀ n, ∃ (s : b) (_ : IsBounded s.1 ∧ diam s.1 ≤ u n), x ∈ E s := fun n => by simpa only [F, mem_iUnion] using mem_iInter.1 hx n choose s hs hxs using C1 have C2 : ∀ n, (s n).1.Nonempty := by intro n rw [nonempty_iff_ne_empty] grind -- choose a point `y n ∈ s n`. choose y hy using C2 have I : ∀ m n, ((s m).1 ∩ (s n).1).Nonempty := by intro m n rw [← not_disjoint_iff_nonempty_inter] by_contra! h have A : x ∈ q ⟨(s m, s n), h⟩ \ q ⟨(s n, s m), h.symm⟩ := haveI := mem_iInter.1 (hxs m).2 (s n) (mem_iInter.1 this h :) have B : x ∈ q ⟨(s n, s m), h.symm⟩ \ q ⟨(s m, s n), h⟩ := haveI := mem_iInter.1 (hxs n).2 (s m) (mem_iInter.1 this h.symm :) exact A.2 B.1 -- the points `y n` are nearby, and therefore they form a Cauchy sequence. have cauchy_y : CauchySeq y := by have : Tendsto (fun n => 2 * u n) atTop (𝓝 0) := by simpa only [mul_zero] using u_lim.const_mul 2 refine cauchySeq_of_le_tendsto_0' (fun n => 2 * u n) (fun m n hmn => ?_) this rcases I m n with ⟨z, zsm, zsn⟩ calc dist (y m) (y n) ≤ dist (y m) z + dist z (y n) := dist_triangle _ _ _ _ ≤ u m + u n := (add_le_add ((dist_le_diam_of_mem (hs m).1 (hy m) zsm).trans (hs m).2) ((dist_le_diam_of_mem (hs n).1 zsn (hy n)).trans (hs n).2)) _ ≤ 2 * u m := by linarith [u_anti.antitone hmn] haveI : Nonempty γ := ⟨y 0⟩ -- let `z` be its limit. let z := limUnder atTop y have y_lim : Tendsto y atTop (𝓝 z) := cauchy_y.tendsto_limUnder suffices f z = x by rw [← this] exact mem_range_self _ -- assume for a contradiction that `f z ≠ x`. by_contra! hne -- introduce disjoint open sets `v` and `w` separating `f z` from `x`. obtain ⟨v, w, v_open, w_open, fzv, xw, hvw⟩ := t2_separation hne obtain ⟨δ, δpos, hδ⟩ : ∃ δ > (0 : ℝ), ball z δ ⊆ f ⁻¹' v := by apply Metric.mem_nhds_iff.1 exact f_cont.continuousAt.preimage_mem_nhds (v_open.mem_nhds fzv) obtain ⟨n, hn⟩ : ∃ n, u n + dist (y n) z < δ := haveI : Tendsto (fun n => u n + dist (y n) z) atTop (𝓝 0) := by simpa only [add_zero] using u_lim.add (tendsto_iff_dist_tendsto_zero.1 y_lim) ((tendsto_order.1 this).2 _ δpos).exists -- for large enough `n`, the image of `s n` is contained in `v`, by continuity of `f`. have fsnv : f '' s n ⊆ v := by rw [image_subset_iff] apply Subset.trans _ hδ intro a ha calc dist a z ≤ dist a (y n) + dist (y n) z := dist_triangle _ _ _ _ ≤ u n + dist (y n) z := by grw [dist_le_diam_of_mem (hs n).1 ha (hy n), (hs n).2] _ < δ := hn -- as `x` belongs to the closure of `f '' (s n)`, it belongs to the closure of `v`. have : x ∈ closure v := closure_mono fsnv (hxs n).1 -- this is a contradiction, as `x` is supposed to belong to `w`, which is disjoint from -- the closure of `v`. exact disjoint_left.1 (hvw.closure_left w_open) this xw theorem IsClosed.measurableSet_image_of_continuousOn_injOn [TopologicalSpace γ] [PolishSpace γ] {β : Type*} [TopologicalSpace β] [T2Space β] [MeasurableSpace β] [OpensMeasurableSpace β] {s : Set γ} (hs : IsClosed s) {f : γ → β} (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableSet (f '' s) := by rw [image_eq_range] haveI : PolishSpace s := IsClosed.polishSpace hs apply measurableSet_range_of_continuous_injective · rwa [continuousOn_iff_continuous_restrict] at f_cont · rwa [injOn_iff_injective] at f_inj variable {α β : Type*} [MeasurableSpace β] section variable [tβ : TopologicalSpace β] [T2Space β] [MeasurableSpace α] {s : Set γ} {f : γ → β} /-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a Polish space, then its image under a continuous injective map is also Borel-measurable. -/ theorem MeasurableSet.image_of_continuousOn_injOn [OpensMeasurableSpace β] [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] (hs : MeasurableSet s) (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableSet (f '' s) := by obtain ⟨t', t't, t'_polish, s_closed, _⟩ : ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs.isClopenable exact @IsClosed.measurableSet_image_of_continuousOn_injOn γ t' t'_polish β _ _ _ _ s s_closed f (f_cont.mono_dom t't) f_inj /-- The Lusin-Souslin theorem: if `s` is Borel-measurable in a standard Borel space, then its image under a measurable injective map taking values in a countably separate measurable space is also Borel-measurable. -/ theorem MeasurableSet.image_of_measurable_injOn {f : γ → α} [MeasurableSpace.CountablySeparated α] [MeasurableSpace γ] [StandardBorelSpace γ] (hs : MeasurableSet s) (f_meas : Measurable f) (f_inj : InjOn f s) : MeasurableSet (f '' s) := by letI := upgradeStandardBorel γ let tγ : TopologicalSpace γ := inferInstance rcases exists_opensMeasurableSpace_of_countablySeparated α with ⟨τ, _, _, _⟩ -- for a finer Polish topology, `f` is continuous. Therefore, one may apply the corresponding -- result for continuous maps. obtain ⟨t', t't, f_cont, t'_polish⟩ : ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @Continuous γ _ t' _ f ∧ @PolishSpace γ t' := f_meas.exists_continuous have M : MeasurableSet[@borel γ t'] s := @Continuous.measurable γ γ t' (@borel γ t') (@BorelSpace.opensMeasurable γ t' (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl)) tγ _ _ _ (continuous_id_of_le t't) s hs exact @MeasurableSet.image_of_continuousOn_injOn γ _ _ _ _ s f _ t' t'_polish (@borel γ t') (@BorelSpace.mk _ _ (borel γ) rfl) M (@Continuous.continuousOn γ _ t' _ f s f_cont) f_inj /-- An injective continuous function on a Polish space is a measurable embedding. -/ theorem Continuous.measurableEmbedding [BorelSpace β] [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] (f_cont : Continuous f) (f_inj : Injective f) : MeasurableEmbedding f := { injective := f_inj measurable := f_cont.measurable measurableSet_image' := fun _u hu => hu.image_of_continuousOn_injOn f_cont.continuousOn f_inj.injOn } /-- If `s` is Borel-measurable in a Polish space and `f` is continuous injective on `s`, then the restriction of `f` to `s` is a measurable embedding. -/ theorem ContinuousOn.measurableEmbedding [BorelSpace β] [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] (hs : MeasurableSet s) (f_cont : ContinuousOn f s) (f_inj : InjOn f s) : MeasurableEmbedding (s.restrict f) := { injective := injOn_iff_injective.1 f_inj measurable := (continuousOn_iff_continuous_restrict.1 f_cont).measurable measurableSet_image' := by intro u hu have A : MeasurableSet (((↑) : s → γ) '' u) := (MeasurableEmbedding.subtype_coe hs).measurableSet_image.2 hu have B : MeasurableSet (f '' (((↑) : s → γ) '' u)) := A.image_of_continuousOn_injOn (f_cont.mono (Subtype.coe_image_subset s u)) (f_inj.mono (Subtype.coe_image_subset s u)) rwa [← image_comp] at B } /-- An injective measurable function from a standard Borel space to a countably separated measurable space is a measurable embedding. -/ theorem Measurable.measurableEmbedding {f : γ → α} [MeasurableSpace.CountablySeparated α] [MeasurableSpace γ] [StandardBorelSpace γ] (f_meas : Measurable f) (f_inj : Injective f) : MeasurableEmbedding f := { injective := f_inj measurable := f_meas measurableSet_image' := fun _u hu => hu.image_of_measurable_injOn f_meas f_inj.injOn } /-- If one Polish topology on a type refines another, they have the same Borel sets. -/ theorem MeasureTheory.borel_eq_borel_of_le {t t' : TopologicalSpace γ} (ht : PolishSpace (h := t)) (ht' : PolishSpace (h := t')) (hle : t ≤ t') : @borel _ t = @borel _ t' := by refine le_antisymm ?_ (borel_anti hle) intro s hs have e := @Continuous.measurableEmbedding _ _ (@borel _ t') t' _ _ (@BorelSpace.mk _ _ (borel γ) rfl) t _ (@borel _ t) (@BorelSpace.mk _ t (@borel _ t) rfl) (continuous_id_of_le hle) injective_id convert e.measurableSet_image.2 hs simp only [id_eq, image_id'] /-- In a Polish space, a set is clopenable if and only if it is Borel-measurable. -/ theorem MeasureTheory.isClopenable_iff_measurableSet [tγ : TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [BorelSpace γ] : IsClopenable s ↔ MeasurableSet s := by -- we already know that a measurable set is clopenable. Conversely, assume that `s` is clopenable. refine ⟨fun hs => ?_, fun hs => hs.isClopenable⟩ borelize γ -- consider a finer topology `t'` in which `s` is open and closed. obtain ⟨t', t't, t'_polish, _, s_open⟩ : ∃ t' : TopologicalSpace γ, t' ≤ tγ ∧ @PolishSpace γ t' ∧ IsClosed[t'] s ∧ IsOpen[t'] s := hs rw [← borel_eq_borel_of_le t'_polish _ t't] · exact MeasurableSpace.measurableSet_generateFrom s_open infer_instance end section LinearOrder variable {α β : Type*} {t : Set α} {g : α → β} [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] [LinearOrder α] [OrderTopology α] [PolishSpace α] [TopologicalSpace β] [MeasurableSpace β] [BorelSpace β] [LinearOrder β] [OrderTopology β] theorem MeasurableSet.image_of_monotoneOn_of_continuousOn (ht : MeasurableSet t) (hg : MonotoneOn g t) (h'g : ContinuousOn g t) : MeasurableSet (g '' t) := by /- We use that the image of a measurable set by a continuous injective map is measurable. Therefore, we need to remove the points where the map is not injective. There are only countably many points that have several preimages, so this set is also measurable. -/ let u : Set β := {c | ∃ x, ∃ y, x ∈ t ∧ y ∈ t ∧ x < y ∧ g x = c ∧ g y = c} have hu : Set.Countable u := MonotoneOn.countable_setOf_two_preimages hg let t' := t ∩ g ⁻¹' u have ht' : MeasurableSet t' := by have : t' = ⋃ c ∈ u, t ∩ g⁻¹' {c} := by ext; simp [t'] rw [this] apply MeasurableSet.biUnion hu (fun c hc ↦ ?_) obtain ⟨v, hv, tv⟩ : ∃ v, OrdConnected v ∧ t ∩ g ⁻¹' {c} = t ∩ v := ordConnected_singleton.preimage_monotoneOn hg exact tv ▸ ht.inter hv.measurableSet have : g '' t = g '' (t \ t') ∪ g '' t' := by simp [← image_union, t'] rw [this] apply MeasurableSet.union · apply (ht.diff ht').image_of_continuousOn_injOn (h'g.mono diff_subset) intro x hx y hy hxy contrapose! hxy wlog H : x < y generalizing x y with h · have : y < x := lt_of_le_of_ne (not_lt.1 H) hxy.symm exact (h hy hx hxy.symm this).symm intro h exact hx.2 ⟨hx.1, x, y, hx.1, hy.1, H, rfl, h.symm⟩ · exact hu.mono (by simp [t']) |>.measurableSet /-- The image of a measurable set under a monotone map is measurable. -/ theorem MeasurableSet.image_of_monotoneOn [SecondCountableTopology β] (ht : MeasurableSet t) (hg : MonotoneOn g t) : MeasurableSet (g '' t) := by /- Since there are only countably many discontinuity points, the result follows by reduction to the continuous case, which we have already proved. -/ let t' := {x ∈ t | ¬ ContinuousWithinAt g t x} have ht' : Set.Countable t' := hg.countable_not_continuousWithinAt have : g '' t = g '' (t \ t') ∪ g '' t' := by rw [← image_union] congr! ext simp only [sdiff_sep_self, not_not, mem_union, mem_setOf_eq, t'] tauto rw [this] apply MeasurableSet.union _ (ht'.image g).measurableSet apply MeasurableSet.image_of_monotoneOn_of_continuousOn (ht.diff ht'.measurableSet) (hg.mono diff_subset) intro x hx simp only [sdiff_sep_self, not_not, mem_setOf_eq, t'] at hx exact hx.2.mono diff_subset /-- The image of a measurable set under an antitone map is measurable. -/ theorem MeasurableSet.image_of_antitoneOn [SecondCountableTopology β] (ht : MeasurableSet t) (hg : AntitoneOn g t) : MeasurableSet (g '' t) := (ht.image_of_monotoneOn hg.dual_right :) end LinearOrder /-- The set of points for which a sequence of measurable functions converges to a given function is measurable. -/ @[measurability] lemma MeasureTheory.measurableSet_tendsto_fun [MeasurableSpace γ] [Countable ι] {l : Filter ι} [l.IsCountablyGenerated] [TopologicalSpace γ] [SecondCountableTopology γ] [PseudoMetrizableSpace γ] [OpensMeasurableSpace γ] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) {g : β → γ} (hg : Measurable g) : MeasurableSet { x | Tendsto (fun n ↦ f n x) l (𝓝 (g x)) } := by letI := TopologicalSpace.pseudoMetrizableSpacePseudoMetric γ simp_rw [tendsto_iff_dist_tendsto_zero (f := fun n ↦ f n _)] exact measurableSet_tendsto (𝓝 0) (fun n ↦ (hf n).dist hg) /-- The set of points for which a measurable sequence of functions converges is measurable. -/ @[measurability] theorem MeasureTheory.measurableSet_exists_tendsto [TopologicalSpace γ] [PolishSpace γ] [MeasurableSpace γ] [hγ : OpensMeasurableSpace γ] [Countable ι] {l : Filter ι} [l.IsCountablyGenerated] {f : ι → β → γ} (hf : ∀ i, Measurable (f i)) : MeasurableSet { x | ∃ c, Tendsto (fun n => f n x) l (𝓝 c) } := by rcases l.eq_or_neBot with rfl | hl · simp letI := TopologicalSpace.upgradeIsCompletelyMetrizable γ rcases l.exists_antitone_basis with ⟨u, hu⟩ simp_rw [← cauchy_map_iff_exists_tendsto] change MeasurableSet { x | _ ∧ _ } have : ∀ x, (map (f · x) l ×ˢ map (f · x) l).HasAntitoneBasis fun n => ((f · x) '' u n) ×ˢ ((f · x) '' u n) := fun x => (hu.map _).prod (hu.map _) simp_rw [and_iff_right (hl.map _), Filter.HasBasis.le_basis_iff (this _).toHasBasis Metric.uniformity_basis_dist_inv_nat_succ, Set.setOf_forall] refine MeasurableSet.biInter Set.countable_univ fun K _ => ?_ simp_rw [Set.setOf_exists, true_and] refine MeasurableSet.iUnion fun N => ?_ simp_rw [prod_image_image_eq, image_subset_iff, prod_subset_iff, Set.setOf_forall] exact MeasurableSet.biInter (to_countable (u N)) fun i _ => MeasurableSet.biInter (to_countable (u N)) fun j _ => measurableSet_lt (Measurable.dist (hf i) (hf j)) measurable_const section StandardBorelSpace variable [MeasurableSpace α] [StandardBorelSpace α] /-- If `s` is a measurable set in a standard Borel space, there is a compatible Polish topology making `s` clopen. -/ theorem MeasurableSet.isClopenable' {s : Set α} (hs : MeasurableSet s) : ∃ _ : TopologicalSpace α, BorelSpace α ∧ PolishSpace α ∧ IsClosed s ∧ IsOpen s := by letI := upgradeStandardBorel α obtain ⟨t, hle, ht, s_clopen⟩ := hs.isClopenable refine ⟨t, ?_, ht, s_clopen⟩ constructor rw [eq_borel_upgradeStandardBorel α, borel_eq_borel_of_le ht _ hle] infer_instance /-- A measurable subspace of a standard Borel space is standard Borel. -/ theorem MeasurableSet.standardBorel {s : Set α} (hs : MeasurableSet s) : StandardBorelSpace s := by obtain ⟨_, _, _, s_closed, _⟩ := hs.isClopenable' haveI := s_closed.polishSpace infer_instance end StandardBorelSpace /-! ### The Borel Isomorphism Theorem -/ namespace PolishSpace variable {β : Type*} variable [MeasurableSpace α] [MeasurableSpace β] [StandardBorelSpace α] [StandardBorelSpace β] /-- If two standard Borel spaces admit Borel measurable injections to one another, then they are Borel isomorphic. -/ noncomputable def borelSchroederBernstein {f : α → β} {g : β → α} (fmeas : Measurable f) (finj : Function.Injective f) (gmeas : Measurable g) (ginj : Function.Injective g) : α ≃ᵐ β := letI := upgradeStandardBorel α letI := upgradeStandardBorel β (fmeas.measurableEmbedding finj).schroederBernstein (gmeas.measurableEmbedding ginj) /-- Any uncountable standard Borel space is Borel isomorphic to the Cantor space `ℕ → Bool`. -/ noncomputable def measurableEquivNatBoolOfNotCountable (h : ¬Countable α) : α ≃ᵐ (ℕ → Bool) := by apply Nonempty.some letI := upgradeStandardBorel α obtain ⟨f, -, fcts, finj⟩ := isClosed_univ.exists_nat_bool_injection_of_not_countable (α := α) (by rwa [← countable_coe_iff, (Equiv.Set.univ _).countable_iff]) obtain ⟨g, gmeas, ginj⟩ := MeasurableSpace.measurable_injection_nat_bool_of_countablySeparated α exact ⟨borelSchroederBernstein gmeas ginj fcts.measurable finj⟩ /-- The **Borel Isomorphism Theorem**: Any two uncountable standard Borel spaces are Borel isomorphic. -/ noncomputable def measurableEquivOfNotCountable (hα : ¬Countable α) (hβ : ¬Countable β) : α ≃ᵐ β := (measurableEquivNatBoolOfNotCountable hα).trans (measurableEquivNatBoolOfNotCountable hβ).symm /-- The **Borel Isomorphism Theorem**: If two standard Borel spaces have the same cardinality, they are Borel isomorphic. -/ noncomputable def Equiv.measurableEquiv (e : α ≃ β) : α ≃ᵐ β := by by_cases h : Countable α · letI := Countable.of_equiv α e refine ⟨e, ?_, ?_⟩ <;> apply measurable_of_countable refine measurableEquivOfNotCountable h ?_ rwa [e.countable_iff] at h end PolishSpace
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/WithTop.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic import Mathlib.Topology.Order.WithTop /-! # Borel measurable space on `WithTop` For `ι` a linear order with the order topology, we define the Borel measurable space on `WithTop ι`. We then prove that the natural inclusion `ι → WithTop ι` is measurable, and that the function `WithTop.untopA : WithTop ι → ι` (which sends `⊤` to an arbitrary element of `ι`) is measurable. ## Main statements * `measurable_of_measurable_comp_coe`: if `f : WithTop ι → α` is such that `f ∘ coe` is measurable, then `f` is measurable. * `Measurable.withTop_coe`: the function `fun x : ι ↦ (x : WithTop ι)` is measurable. * `Measurable.untopD`: for `d : ι`, the function `WithTop.untopD d : WithTop ι → ι` is measurable. * `Measurable.untopA`: the function `WithTop.untopA : WithTop ι → ι` is measurable. -/ namespace WithTop variable {ι : Type*} [LinearOrder ι] [TopologicalSpace ι] [OrderTopology ι] instance : MeasurableSpace (WithTop ι) := borel _ instance : BorelSpace (WithTop ι) := ⟨rfl⟩ variable [MeasurableSpace ι] [BorelSpace ι] /-- Measurable equivalence between the non-top elements of `WithTop ι` and `ι`. -/ noncomputable def MeasurableEquiv.neTopEquiv : { r : WithTop ι | r ≠ ⊤ } ≃ᵐ ι := (WithTop.neTopHomeomorph ι).toMeasurableEquiv lemma measurable_of_measurable_comp_coe {α : Type*} {mα : MeasurableSpace α} {f : WithTop ι → α} (h : Measurable fun p : ι ↦ f p) : Measurable f := measurable_of_measurable_on_compl_singleton ⊤ (MeasurableEquiv.neTopEquiv.symm.measurable_comp_iff.1 h) lemma measurable_untopD (d : ι) : Measurable (untopD d) := measurable_of_measurable_comp_coe measurable_id lemma measurable_untopA [Nonempty ι] : Measurable (WithTop.untopA (α := ι)) := measurable_untopD _ lemma measurable_coe : Measurable (fun x : ι ↦ (x : WithTop ι)) := continuous_coe.measurable @[fun_prop] lemma _root_.Measurable.withTop_coe {α} {mα : MeasurableSpace α} {f : α → ι} (hf : Measurable f) : Measurable (fun x ↦ (f x : WithTop ι)) := measurable_coe.comp hf @[fun_prop] lemma _root_.Measurable.untopD {α} {mα : MeasurableSpace α} (d : ι) {f : α → WithTop ι} (hf : Measurable f) : Measurable (fun x ↦ (f x).untopD d) := (measurable_untopD d).comp hf @[fun_prop] lemma _root_.Measurable.untopA {α} {mα : MeasurableSpace α} [Nonempty ι] {f : α → WithTop ι} (hf : Measurable f) : Measurable (fun x ↦ (f x).untopA) := hf.untopD _ /-- Measurable equivalence between `WithTop ι` and `ι ⊕ Unit`. -/ def measurableEquivSum : WithTop ι ≃ᵐ ι ⊕ Unit := { Equiv.optionEquivSumPUnit ι with measurable_toFun := measurable_of_measurable_comp_coe measurable_inl measurable_invFun := measurable_fun_sum measurable_coe (@measurable_const _ Unit _ _ ⊤) } end WithTop
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/ContinuousLinearMap.lean
import Mathlib.Analysis.Normed.Operator.Bilinear import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic import Mathlib.Topology.Algebra.Module.FiniteDimension /-! # Measurable functions in normed spaces -/ open MeasureTheory variable {α : Type*} [MeasurableSpace α] namespace ContinuousLinearMap variable {R E F : Type*} [Semiring R] [SeminormedAddCommGroup E] [Module R E] [MeasurableSpace E] [OpensMeasurableSpace E] [SeminormedAddCommGroup F] [Module R F] [MeasurableSpace F] [BorelSpace F] @[fun_prop, measurability] protected theorem measurable (L : E →L[R] F) : Measurable L := L.continuous.measurable @[fun_prop] theorem measurable_comp (L : E →L[R] F) {φ : α → E} (φ_meas : Measurable φ) : Measurable fun a : α => L (φ a) := L.measurable.comp φ_meas end ContinuousLinearMap namespace ContinuousLinearMap variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] instance instMeasurableSpace : MeasurableSpace (E →L[𝕜] F) := borel _ instance instBorelSpace : BorelSpace (E →L[𝕜] F) := ⟨rfl⟩ @[fun_prop, measurability] theorem measurable_apply [MeasurableSpace F] [BorelSpace F] (x : E) : Measurable fun f : E →L[𝕜] F => f x := (apply 𝕜 F x).continuous.measurable theorem measurable_apply' [MeasurableSpace E] [OpensMeasurableSpace E] [MeasurableSpace F] [BorelSpace F] : Measurable fun (x : E) (f : E →L[𝕜] F) => f x := measurable_pi_lambda _ fun f => f.measurable @[measurability] theorem measurable_coe [MeasurableSpace F] [BorelSpace F] : Measurable fun (f : E →L[𝕜] F) (x : E) => f x := measurable_pi_lambda _ measurable_apply end ContinuousLinearMap section ContinuousLinearMapNontriviallyNormedField variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E] [BorelSpace E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] @[fun_prop, measurability] theorem Measurable.apply_continuousLinearMap {φ : α → F →L[𝕜] E} (hφ : Measurable φ) (v : F) : Measurable fun a => φ a v := (ContinuousLinearMap.apply 𝕜 E v).measurable.comp hφ @[measurability] theorem AEMeasurable.apply_continuousLinearMap {φ : α → F →L[𝕜] E} {μ : Measure α} (hφ : AEMeasurable φ μ) (v : F) : AEMeasurable (fun a => φ a v) μ := (ContinuousLinearMap.apply 𝕜 E v).measurable.comp_aemeasurable hφ end ContinuousLinearMapNontriviallyNormedField section NormedSpace variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] [MeasurableSpace 𝕜] variable [BorelSpace 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [MeasurableSpace E] [BorelSpace E] theorem measurable_smul_const {f : α → 𝕜} {c : E} (hc : c ≠ 0) : (Measurable fun x => f x • c) ↔ Measurable f := (isClosedEmbedding_smul_left hc).measurableEmbedding.measurable_comp_iff theorem aemeasurable_smul_const {f : α → 𝕜} {μ : Measure α} {c : E} (hc : c ≠ 0) : AEMeasurable (fun x => f x • c) μ ↔ AEMeasurable f μ := (isClosedEmbedding_smul_left hc).measurableEmbedding.aemeasurable_comp_iff end NormedSpace
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Metric.lean
import Mathlib.Analysis.Normed.Group.Continuity import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic import Mathlib.Topology.MetricSpace.Thickening /-! # Borel sigma algebras on (pseudo-)metric spaces ## Main statements * `measurable_dist`, `measurable_infEdist`, `measurable_norm`, `measurable_enorm`, `Measurable.dist`, `Measurable.infEdist`, `Measurable.norm`, `Measurable.enorm`: measurability of various metric-related notions; * `tendsto_measure_thickening_of_isClosed`: the measure of a closed set is the limit of the measure of its ε-thickenings as ε → 0. * `exists_borelSpace_of_countablyGenerated_of_separatesPoints`: if a measurable space is countably generated and separates points, it arises as the Borel sets of some second countable separable metrizable topology. -/ open Set Filter MeasureTheory MeasurableSpace TopologicalSpace open scoped Topology NNReal ENNReal MeasureTheory universe u v w x y variable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α} section PseudoMetricSpace variable [PseudoMetricSpace α] [MeasurableSpace α] [OpensMeasurableSpace α] variable [MeasurableSpace β] {x : α} {ε : ℝ} open Metric @[measurability] theorem measurableSet_ball : MeasurableSet (Metric.ball x ε) := Metric.isOpen_ball.measurableSet @[measurability] theorem measurableSet_closedBall : MeasurableSet (Metric.closedBall x ε) := Metric.isClosed_closedBall.measurableSet @[measurability] theorem measurable_infDist {s : Set α} : Measurable fun x => infDist x s := (continuous_infDist_pt s).measurable @[measurability, fun_prop] theorem Measurable.infDist {f : β → α} (hf : Measurable f) {s : Set α} : Measurable fun x => infDist (f x) s := measurable_infDist.comp hf @[measurability] theorem measurable_infNndist {s : Set α} : Measurable fun x => infNndist x s := (continuous_infNndist_pt s).measurable @[measurability, fun_prop] theorem Measurable.infNndist {f : β → α} (hf : Measurable f) {s : Set α} : Measurable fun x => infNndist (f x) s := measurable_infNndist.comp hf section variable [SecondCountableTopology α] @[measurability] theorem measurable_dist : Measurable fun p : α × α => dist p.1 p.2 := continuous_dist.measurable @[measurability, fun_prop] theorem Measurable.dist {f g : β → α} (hf : Measurable f) (hg : Measurable g) : Measurable fun b => dist (f b) (g b) := continuous_dist.measurable2 hf hg @[fun_prop, measurability] lemma AEMeasurable.dist {f g : β → α} {μ : Measure β} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun b ↦ dist (f b) (g b)) μ := continuous_dist.aemeasurable2 hf hg @[measurability] theorem measurable_nndist : Measurable fun p : α × α => nndist p.1 p.2 := continuous_nndist.measurable @[measurability, fun_prop] theorem Measurable.nndist {f g : β → α} (hf : Measurable f) (hg : Measurable g) : Measurable fun b => nndist (f b) (g b) := continuous_nndist.measurable2 hf hg end end PseudoMetricSpace section PseudoEMetricSpace variable [PseudoEMetricSpace α] [MeasurableSpace α] [OpensMeasurableSpace α] variable [MeasurableSpace β] {x : α} {ε : ℝ≥0∞} open EMetric @[measurability] theorem measurableSet_eball : MeasurableSet (EMetric.ball x ε) := EMetric.isOpen_ball.measurableSet @[measurability, fun_prop] theorem measurable_edist_right : Measurable (edist x) := (continuous_const.edist continuous_id).measurable @[measurability, fun_prop] theorem measurable_edist_left : Measurable fun y => edist y x := (continuous_id.edist continuous_const).measurable @[measurability] theorem measurable_infEdist {s : Set α} : Measurable fun x => infEdist x s := continuous_infEdist.measurable @[measurability, fun_prop] theorem Measurable.infEdist {f : β → α} (hf : Measurable f) {s : Set α} : Measurable fun x => infEdist (f x) s := measurable_infEdist.comp hf open Metric EMetric /-- If a set has a closed thickening with finite measure, then the measure of its `r`-closed thickenings converges to the measure of its closure as `r` tends to `0`. -/ theorem tendsto_measure_cthickening {μ : Measure α} {s : Set α} (hs : ∃ R > 0, μ (cthickening R s) ≠ ∞) : Tendsto (fun r => μ (cthickening r s)) (𝓝 0) (𝓝 (μ (closure s))) := by have A : Tendsto (fun r => μ (cthickening r s)) (𝓝[Ioi 0] 0) (𝓝 (μ (closure s))) := by rw [closure_eq_iInter_cthickening] exact tendsto_measure_biInter_gt (fun r _ => isClosed_cthickening.nullMeasurableSet) (fun i j _ ij => cthickening_mono ij _) hs have B : Tendsto (fun r => μ (cthickening r s)) (𝓝[Iic 0] 0) (𝓝 (μ (closure s))) := by apply Tendsto.congr' _ tendsto_const_nhds filter_upwards [self_mem_nhdsWithin (α := ℝ)] with _ hr rw [cthickening_of_nonpos hr] convert B.sup A exact (nhdsLE_sup_nhdsGT 0).symm /-- If a closed set has a closed thickening with finite measure, then the measure of its closed `r`-thickenings converge to its measure as `r` tends to `0`. -/ theorem tendsto_measure_cthickening_of_isClosed {μ : Measure α} {s : Set α} (hs : ∃ R > 0, μ (cthickening R s) ≠ ∞) (h's : IsClosed s) : Tendsto (fun r => μ (cthickening r s)) (𝓝 0) (𝓝 (μ s)) := by convert tendsto_measure_cthickening hs exact h's.closure_eq.symm /-- If a set has a thickening with finite measure, then the measures of its `r`-thickenings converge to the measure of its closure as `r > 0` tends to `0`. -/ theorem tendsto_measure_thickening {μ : Measure α} {s : Set α} (hs : ∃ R > 0, μ (thickening R s) ≠ ∞) : Tendsto (fun r => μ (thickening r s)) (𝓝[>] 0) (𝓝 (μ (closure s))) := by rw [closure_eq_iInter_thickening] exact tendsto_measure_biInter_gt (fun r _ => isOpen_thickening.nullMeasurableSet) (fun i j _ ij => thickening_mono ij _) hs /-- If a closed set has a thickening with finite measure, then the measure of its `r`-thickenings converge to its measure as `r > 0` tends to `0`. -/ theorem tendsto_measure_thickening_of_isClosed {μ : Measure α} {s : Set α} (hs : ∃ R > 0, μ (thickening R s) ≠ ∞) (h's : IsClosed s) : Tendsto (fun r => μ (thickening r s)) (𝓝[>] 0) (𝓝 (μ s)) := by convert tendsto_measure_thickening hs exact h's.closure_eq.symm variable [SecondCountableTopology α] @[measurability] theorem measurable_edist : Measurable fun p : α × α => edist p.1 p.2 := continuous_edist.measurable @[measurability, fun_prop] theorem Measurable.edist {f g : β → α} (hf : Measurable f) (hg : Measurable g) : Measurable fun b => edist (f b) (g b) := continuous_edist.measurable2 hf hg @[measurability, fun_prop] theorem AEMeasurable.edist {f g : β → α} {μ : Measure β} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun a => edist (f a) (g a)) μ := continuous_edist.aemeasurable2 hf hg end PseudoEMetricSpace /-- Given a compact set in a proper space, the measure of its `r`-closed thickenings converges to its measure as `r` tends to `0`. -/ theorem tendsto_measure_cthickening_of_isCompact [MetricSpace α] [MeasurableSpace α] [OpensMeasurableSpace α] [ProperSpace α] {μ : Measure α} [IsFiniteMeasureOnCompacts μ] {s : Set α} (hs : IsCompact s) : Tendsto (fun r => μ (Metric.cthickening r s)) (𝓝 0) (𝓝 (μ s)) := tendsto_measure_cthickening_of_isClosed ⟨1, zero_lt_one, hs.isBounded.cthickening.measure_lt_top.ne⟩ hs.isClosed /-- If a measurable space is countably generated and separates points, it arises as the Borel sets of some second countable t4 topology (i.e. a separable metrizable one). -/ theorem exists_borelSpace_of_countablyGenerated_of_separatesPoints (α : Type*) [m : MeasurableSpace α] [CountablyGenerated α] [SeparatesPoints α] : ∃ _ : TopologicalSpace α, SecondCountableTopology α ∧ T4Space α ∧ BorelSpace α := by rcases measurableEquiv_nat_bool_of_countablyGenerated α with ⟨s, ⟨f⟩⟩ letI := induced f inferInstance let F := f.toEquiv.toHomeomorphOfIsInducing <| .induced _ exact ⟨inferInstance, F.secondCountableTopology, F.symm.t4Space, f.measurableEmbedding.borelSpace F.isInducing⟩ /-- If a measurable space on `α` is countably generated and separates points, there is some second countable t4 topology on `α` (i.e. a separable metrizable one) for which every open set is measurable. -/ theorem exists_opensMeasurableSpace_of_countablySeparated (α : Type*) [m : MeasurableSpace α] [CountablySeparated α] : ∃ _ : TopologicalSpace α, SecondCountableTopology α ∧ T4Space α ∧ OpensMeasurableSpace α := by rcases exists_countablyGenerated_le_of_countablySeparated α with ⟨m', _, _, m'le⟩ rcases exists_borelSpace_of_countablyGenerated_of_separatesPoints (m := m') with ⟨τ, _, _, τm'⟩ exact ⟨τ, ‹_›, ‹_›, @OpensMeasurableSpace.mk _ _ m (τm'.measurable_eq.symm.le.trans m'le)⟩ section ContinuousENorm variable {ε : Type*} [MeasurableSpace ε] [TopologicalSpace ε] [ContinuousENorm ε] [OpensMeasurableSpace ε] [MeasurableSpace β] @[measurability, fun_prop] lemma measurable_enorm : Measurable (enorm : ε → ℝ≥0∞) := continuous_enorm.measurable @[measurability, fun_prop] protected lemma Measurable.enorm {f : β → ε} (hf : Measurable f) : Measurable (‖f ·‖ₑ) := measurable_enorm.comp hf @[measurability, fun_prop] protected lemma AEMeasurable.enorm {f : β → ε} {μ : Measure β} (hf : AEMeasurable f μ) : AEMeasurable (‖f ·‖ₑ) μ := measurable_enorm.comp_aemeasurable hf end ContinuousENorm section NormedAddCommGroup variable [MeasurableSpace α] [NormedAddCommGroup α] [OpensMeasurableSpace α] [MeasurableSpace β] @[fun_prop, measurability] theorem measurable_norm : Measurable (norm : α → ℝ) := continuous_norm.measurable @[measurability, fun_prop] theorem Measurable.norm {f : β → α} (hf : Measurable f) : Measurable fun a => norm (f a) := measurable_norm.comp hf @[measurability, fun_prop] theorem AEMeasurable.norm {f : β → α} {μ : Measure β} (hf : AEMeasurable f μ) : AEMeasurable (fun a => norm (f a)) μ := measurable_norm.comp_aemeasurable hf @[measurability] theorem measurable_nnnorm : Measurable (nnnorm : α → ℝ≥0) := continuous_nnnorm.measurable @[measurability, fun_prop] protected theorem Measurable.nnnorm {f : β → α} (hf : Measurable f) : Measurable fun a => ‖f a‖₊ := measurable_nnnorm.comp hf @[measurability, fun_prop] protected lemma AEMeasurable.nnnorm {f : β → α} {μ : Measure β} (hf : AEMeasurable f μ) : AEMeasurable (fun a => ‖f a‖₊) μ := measurable_nnnorm.comp_aemeasurable hf end NormedAddCommGroup
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Metrizable.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric import Mathlib.MeasureTheory.Constructions.BorelSpace.Real import Mathlib.Topology.Metrizable.Real import Mathlib.Topology.IndicatorConstPointwise /-! # Measurable functions in (pseudo-)metrizable Borel spaces -/ open Filter MeasureTheory TopologicalSpace Topology NNReal ENNReal MeasureTheory variable {α β : Type*} [MeasurableSpace α] section Limits variable [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] open Metric /-- A limit (over a general filter) of measurable functions valued in a (pseudo) metrizable space is measurable. -/ theorem measurable_of_tendsto_metrizable' {ι} {f : ι → α → β} {g : α → β} (u : Filter ι) [NeBot u] [IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) : Measurable g := by letI : PseudoMetricSpace β := pseudoMetrizableSpacePseudoMetric β apply measurable_of_isClosed' intro s h1s h2s h3s have : Measurable fun x => infNndist (g x) s := by suffices Tendsto (fun i x => infNndist (f i x) s) u (𝓝 fun x => infNndist (g x) s) from NNReal.measurable_of_tendsto' u (fun i => (hf i).infNndist) this rw [tendsto_pi_nhds] at lim ⊢ intro x exact ((continuous_infNndist_pt s).tendsto (g x)).comp (lim x) have h4s : g ⁻¹' s = (fun x => infNndist (g x) s) ⁻¹' {0} := by ext x simp [← h1s.mem_iff_infDist_zero h2s, ← NNReal.coe_eq_zero] rw [h4s] exact this (measurableSet_singleton 0) /-- A sequential limit of measurable functions valued in a (pseudo) metrizable space is measurable. -/ theorem measurable_of_tendsto_metrizable {f : ℕ → α → β} {g : α → β} (hf : ∀ i, Measurable (f i)) (lim : Tendsto f atTop (𝓝 g)) : Measurable g := measurable_of_tendsto_metrizable' atTop hf lim theorem aemeasurable_of_tendsto_metrizable_ae {ι} {μ : Measure α} {f : ι → α → β} {g : α → β} (u : Filter ι) [hu : NeBot u] [IsCountablyGenerated u] (hf : ∀ n, AEMeasurable (f n) μ) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) u (𝓝 (g x))) : AEMeasurable g μ := by classical rcases u.exists_seq_tendsto with ⟨v, hv⟩ have h'f : ∀ n, AEMeasurable (f (v n)) μ := fun n => hf (v n) set p : α → (ℕ → β) → Prop := fun x f' => Tendsto (fun n => f' n) atTop (𝓝 (g x)) have hp : ∀ᵐ x ∂μ, p x fun n => f (v n) x := by filter_upwards [h_tendsto] with x hx using hx.comp hv set aeSeqLim := fun x => ite (x ∈ aeSeqSet h'f p) (g x) (⟨f (v 0) x⟩ : Nonempty β).some refine ⟨aeSeqLim, measurable_of_tendsto_metrizable' atTop (aeSeq.measurable h'f p) (tendsto_pi_nhds.mpr fun x => ?_), ?_⟩ · simp_rw [aeSeqLim, aeSeq] split_ifs with hx · simp_rw [aeSeq.mk_eq_fun_of_mem_aeSeqSet h'f hx] exact @aeSeq.fun_prop_of_mem_aeSeqSet _ α β _ _ _ _ _ h'f x hx · exact tendsto_const_nhds · exact (ite_ae_eq_of_measure_compl_zero g (fun x => (⟨f (v 0) x⟩ : Nonempty β).some) (aeSeqSet h'f p) (aeSeq.measure_compl_aeSeqSet_eq_zero h'f hp)).symm theorem aemeasurable_of_tendsto_metrizable_ae' {μ : Measure α} {f : ℕ → α → β} {g : α → β} (hf : ∀ n, AEMeasurable (f n) μ) (h_ae_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : AEMeasurable g μ := aemeasurable_of_tendsto_metrizable_ae atTop hf h_ae_tendsto theorem aemeasurable_of_unif_approx {β} [MeasurableSpace β] [PseudoMetricSpace β] [BorelSpace β] {μ : Measure α} {g : α → β} (hf : ∀ ε > (0 : ℝ), ∃ f : α → β, AEMeasurable f μ ∧ ∀ᵐ x ∂μ, dist (f x) (g x) ≤ ε) : AEMeasurable g μ := by obtain ⟨u, -, u_pos, u_lim⟩ : ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) := exists_seq_strictAnti_tendsto (0 : ℝ) choose f Hf using fun n : ℕ => hf (u n) (u_pos n) have : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x)) := by have : ∀ᵐ x ∂μ, ∀ n, dist (f n x) (g x) ≤ u n := ae_all_iff.2 fun n => (Hf n).2 filter_upwards [this] intro x hx rw [tendsto_iff_dist_tendsto_zero] exact squeeze_zero (fun n => dist_nonneg) hx u_lim exact aemeasurable_of_tendsto_metrizable_ae' (fun n => (Hf n).1) this theorem measurable_of_tendsto_metrizable_ae {μ : Measure α} [μ.IsComplete] {f : ℕ → α → β} {g : α → β} (hf : ∀ n, Measurable (f n)) (h_ae_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Measurable g := aemeasurable_iff_measurable.mp (aemeasurable_of_tendsto_metrizable_ae' (fun i => (hf i).aemeasurable) h_ae_tendsto) theorem measurable_limit_of_tendsto_metrizable_ae {ι} [Countable ι] [Nonempty ι] {μ : Measure α} {f : ι → α → β} {L : Filter ι} [L.IsCountablyGenerated] (hf : ∀ n, AEMeasurable (f n) μ) (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) L (𝓝 l)) : ∃ f_lim : α → β, Measurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := by classical inhabit ι rcases eq_or_neBot L with (rfl | hL) · exact ⟨(hf default).mk _, (hf default).measurable_mk, Eventually.of_forall fun x => tendsto_bot⟩ let p : α → (ι → β) → Prop := fun x f' => ∃ l : β, Tendsto (fun n => f' n) L (𝓝 l) have hp_mem : ∀ x ∈ aeSeqSet hf p, p x fun n => f n x := fun x hx => aeSeq.fun_prop_of_mem_aeSeqSet hf hx have h_ae_eq : ∀ᵐ x ∂μ, ∀ n, aeSeq hf p n x = f n x := aeSeq.aeSeq_eq_fun_ae hf h_ae_tendsto set f_lim : α → β := fun x => dite (x ∈ aeSeqSet hf p) (fun h => (hp_mem x h).choose) fun _ => (⟨f default x⟩ : Nonempty β).some have hf_lim : ∀ x, Tendsto (fun n => aeSeq hf p n x) L (𝓝 (f_lim x)) := by intro x simp only [aeSeq, f_lim] split_ifs with h · refine (hp_mem x h).choose_spec.congr fun n => ?_ exact (aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h n).symm · exact tendsto_const_nhds have h_ae_tendsto_f_lim : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) L (𝓝 (f_lim x)) := h_ae_eq.mono fun x hx => (hf_lim x).congr hx have h_f_lim_meas : Measurable f_lim := measurable_of_tendsto_metrizable' L (aeSeq.measurable hf p) (tendsto_pi_nhds.mpr fun x => hf_lim x) exact ⟨f_lim, h_f_lim_meas, h_ae_tendsto_f_lim⟩ end Limits section TendstoIndicator variable {α : Type*} [MeasurableSpace α] {A : Set α} variable {ι : Type*} (L : Filter ι) [IsCountablyGenerated L] {As : ι → Set α} /-- If the indicator functions of measurable sets `Aᵢ` converge to the indicator function of a set `A` along a nontrivial countably generated filter, then `A` is also measurable. -/ lemma measurableSet_of_tendsto_indicator [NeBot L] (As_mble : ∀ i, MeasurableSet (As i)) (h_lim : ∀ x, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) : MeasurableSet A := by simp_rw [← measurable_indicator_const_iff (1 : ℝ≥0∞)] at As_mble ⊢ exact ENNReal.measurable_of_tendsto' L As_mble ((tendsto_indicator_const_iff_forall_eventually L (1 : ℝ≥0∞)).mpr h_lim) /-- If the indicator functions of a.e.-measurable sets `Aᵢ` converge a.e. to the indicator function of a set `A` along a nontrivial countably generated filter, then `A` is also a.e.-measurable. -/ lemma nullMeasurableSet_of_tendsto_indicator [NeBot L] {μ : Measure α} (As_mble : ∀ i, NullMeasurableSet (As i) μ) (h_lim : ∀ᵐ x ∂μ, ∀ᶠ i in L, x ∈ As i ↔ x ∈ A) : NullMeasurableSet A μ := by simp_rw [← aemeasurable_indicator_const_iff (1 : ℝ≥0∞)] at As_mble ⊢ apply aemeasurable_of_tendsto_metrizable_ae L As_mble simpa [tendsto_indicator_const_apply_iff_eventually] using h_lim end TendstoIndicator
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean
import Mathlib.Topology.Semicontinuous import Mathlib.MeasureTheory.Function.AEMeasurableSequence import Mathlib.MeasureTheory.Order.Lattice import Mathlib.Topology.Order.Lattice import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic /-! # Borel sigma algebras on spaces with orders ## Main statements * `borel_eq_generateFrom_Ixx` (where Ixx is one of {Iio, Ioi, Iic, Ici, Ico, Ioc}): The Borel sigma algebra of a linear order topology is generated by intervals of the given kind. * `Dense.borel_eq_generateFrom_Ico_mem`, `Dense.borel_eq_generateFrom_Ioc_mem`: The Borel sigma algebra of a dense linear order topology is generated by intervals of a given kind, with endpoints from dense subsets. * `ext_of_Ico`, `ext_of_Ioc`: A locally finite Borel measure on a second countable conditionally complete linear order is characterized by the measures of intervals of the given kind. * `ext_of_Iic`, `ext_of_Ici`: A finite Borel measure on a second countable linear order is characterized by the measures of intervals of the given kind. * `UpperSemicontinuous.measurable`, `LowerSemicontinuous.measurable`: Semicontinuous functions are measurable. * `Measurable.iSup`, `Measurable.iInf`, `Measurable.sSup`, `Measurable.sInf`: Countable supremums and infimums of measurable functions to conditionally complete linear orders are measurable. * `Measurable.liminf`, `Measurable.limsup`: Countable liminfs and limsups of measurable functions to conditionally complete linear orders are measurable. -/ open Set Filter MeasureTheory MeasurableSpace TopologicalSpace open scoped Topology NNReal ENNReal MeasureTheory universe u v w x y variable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α} section OrderTopology variable (α) variable [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] theorem borel_eq_generateFrom_Iio : borel α = .generateFrom (range Iio) := by refine le_antisymm ?_ (generateFrom_le ?_) · rw [borel_eq_generateFrom_of_subbasis (@OrderTopology.topology_eq_generate_intervals α _ _ _)] letI : MeasurableSpace α := MeasurableSpace.generateFrom (range Iio) have H : ∀ a : α, MeasurableSet (Iio a) := fun a => GenerateMeasurable.basic _ ⟨_, rfl⟩ refine generateFrom_le ?_ rintro _ ⟨a, rfl | rfl⟩ · rcases em (∃ b, a ⋖ b) with ⟨b, hb⟩ | hcovBy · rw [hb.Ioi_eq, ← compl_Iio] exact (H _).compl · rcases isOpen_biUnion_countable (Ioi a) Ioi fun _ _ ↦ isOpen_Ioi with ⟨t, hat, htc, htU⟩ have : Ioi a = ⋃ b ∈ t, Ici b := by refine Subset.antisymm ?_ <| iUnion₂_subset fun b hb ↦ Ici_subset_Ioi.2 (hat hb) refine Subset.trans ?_ <| iUnion₂_mono fun _ _ ↦ Ioi_subset_Ici_self simpa [CovBy, htU, subset_def] using hcovBy simp only [this, ← compl_Iio] exact .biUnion htc <| fun _ _ ↦ (H _).compl · apply H · rw [forall_mem_range] intro a exact GenerateMeasurable.basic _ isOpen_Iio theorem borel_eq_generateFrom_Ioi : borel α = .generateFrom (range Ioi) := @borel_eq_generateFrom_Iio αᵒᵈ _ (by infer_instance : SecondCountableTopology α) _ _ theorem borel_eq_generateFrom_Iic : borel α = MeasurableSpace.generateFrom (range Iic) := by rw [borel_eq_generateFrom_Ioi] refine le_antisymm ?_ ?_ · refine MeasurableSpace.generateFrom_le fun t ht => ?_ obtain ⟨u, rfl⟩ := ht rw [← compl_Iic] exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl · refine MeasurableSpace.generateFrom_le fun t ht => ?_ obtain ⟨u, rfl⟩ := ht rw [← compl_Ioi] exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl theorem borel_eq_generateFrom_Ici : borel α = MeasurableSpace.generateFrom (range Ici) := @borel_eq_generateFrom_Iic αᵒᵈ _ _ _ _ end OrderTopology section Orders variable [TopologicalSpace α] {mα : MeasurableSpace α} [OpensMeasurableSpace α] variable {mδ : MeasurableSpace δ} section Preorder variable [Preorder α] [OrderClosedTopology α] {a b x : α} {μ : Measure α} @[simp, measurability] theorem measurableSet_Ici : MeasurableSet (Ici a) := isClosed_Ici.measurableSet theorem nullMeasurableSet_Ici : NullMeasurableSet (Ici a) μ := measurableSet_Ici.nullMeasurableSet @[simp, measurability] theorem measurableSet_Iic : MeasurableSet (Iic a) := isClosed_Iic.measurableSet theorem nullMeasurableSet_Iic : NullMeasurableSet (Iic a) μ := measurableSet_Iic.nullMeasurableSet @[simp, measurability] theorem measurableSet_Icc : MeasurableSet (Icc a b) := isClosed_Icc.measurableSet theorem nullMeasurableSet_Icc : NullMeasurableSet (Icc a b) μ := measurableSet_Icc.nullMeasurableSet instance nhdsWithin_Ici_isMeasurablyGenerated : (𝓝[Ici b] a).IsMeasurablyGenerated := measurableSet_Ici.nhdsWithin_isMeasurablyGenerated _ instance nhdsWithin_Iic_isMeasurablyGenerated : (𝓝[Iic b] a).IsMeasurablyGenerated := measurableSet_Iic.nhdsWithin_isMeasurablyGenerated _ instance nhdsWithin_Icc_isMeasurablyGenerated : IsMeasurablyGenerated (𝓝[Icc a b] x) := by rw [← Ici_inter_Iic, nhdsWithin_inter] infer_instance instance atTop_isMeasurablyGenerated : (Filter.atTop : Filter α).IsMeasurablyGenerated := @Filter.iInf_isMeasurablyGenerated _ _ _ _ fun a => (measurableSet_Ici : MeasurableSet (Ici a)).principal_isMeasurablyGenerated instance atBot_isMeasurablyGenerated : (Filter.atBot : Filter α).IsMeasurablyGenerated := @Filter.iInf_isMeasurablyGenerated _ _ _ _ fun a => (measurableSet_Iic : MeasurableSet (Iic a)).principal_isMeasurablyGenerated instance [R1Space α] : IsMeasurablyGenerated (cocompact α) where exists_measurable_subset := by intro _ hs obtain ⟨t, ht, hts⟩ := mem_cocompact.mp hs exact ⟨(closure t)ᶜ, ht.closure.compl_mem_cocompact, isClosed_closure.measurableSet.compl, (compl_subset_compl.2 subset_closure).trans hts⟩ end Preorder section PartialOrder variable [PartialOrder α] [OrderClosedTopology α] [SecondCountableTopology α] {a b : α} @[measurability] theorem measurableSet_le' : MeasurableSet { p : α × α | p.1 ≤ p.2 } := OrderClosedTopology.isClosed_le'.measurableSet @[measurability] theorem measurableSet_le {f g : δ → α} (hf : Measurable f) (hg : Measurable g) : MeasurableSet { a | f a ≤ g a } := hf.prodMk hg measurableSet_le' end PartialOrder section LinearOrder variable [LinearOrder α] [OrderClosedTopology α] {a b x : α} {μ : Measure α} -- we open this scope only here to avoid issues with list being treated as intervals above open Interval @[simp, measurability] theorem measurableSet_Iio : MeasurableSet (Iio a) := isOpen_Iio.measurableSet theorem nullMeasurableSet_Iio : NullMeasurableSet (Iio a) μ := measurableSet_Iio.nullMeasurableSet @[simp, measurability] theorem measurableSet_Ioi : MeasurableSet (Ioi a) := isOpen_Ioi.measurableSet theorem nullMeasurableSet_Ioi : NullMeasurableSet (Ioi a) μ := measurableSet_Ioi.nullMeasurableSet @[simp, measurability] theorem measurableSet_Ioo : MeasurableSet (Ioo a b) := isOpen_Ioo.measurableSet theorem nullMeasurableSet_Ioo : NullMeasurableSet (Ioo a b) μ := measurableSet_Ioo.nullMeasurableSet @[simp, measurability] theorem measurableSet_Ioc : MeasurableSet (Ioc a b) := measurableSet_Ioi.inter measurableSet_Iic theorem nullMeasurableSet_Ioc : NullMeasurableSet (Ioc a b) μ := measurableSet_Ioc.nullMeasurableSet @[simp, measurability] theorem measurableSet_Ico : MeasurableSet (Ico a b) := measurableSet_Ici.inter measurableSet_Iio theorem nullMeasurableSet_Ico : NullMeasurableSet (Ico a b) μ := measurableSet_Ico.nullMeasurableSet instance nhdsWithin_Ioi_isMeasurablyGenerated : (𝓝[Ioi b] a).IsMeasurablyGenerated := measurableSet_Ioi.nhdsWithin_isMeasurablyGenerated _ instance nhdsWithin_Iio_isMeasurablyGenerated : (𝓝[Iio b] a).IsMeasurablyGenerated := measurableSet_Iio.nhdsWithin_isMeasurablyGenerated _ instance nhdsWithin_uIcc_isMeasurablyGenerated : IsMeasurablyGenerated (𝓝[[[a, b]]] x) := nhdsWithin_Icc_isMeasurablyGenerated @[measurability] theorem measurableSet_lt' [SecondCountableTopology α] : MeasurableSet { p : α × α | p.1 < p.2 } := (isOpen_lt continuous_fst continuous_snd).measurableSet @[measurability] theorem measurableSet_lt [SecondCountableTopology α] {f g : δ → α} (hf : Measurable f) (hg : Measurable g) : MeasurableSet { a | f a < g a } := hf.prodMk hg measurableSet_lt' theorem nullMeasurableSet_lt [SecondCountableTopology α] {μ : Measure δ} {f g : δ → α} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : NullMeasurableSet { a | f a < g a } μ := (hf.prodMk hg).nullMeasurable measurableSet_lt' theorem nullMeasurableSet_lt' [SecondCountableTopology α] {μ : Measure (α × α)} : NullMeasurableSet { p : α × α | p.1 < p.2 } μ := measurableSet_lt'.nullMeasurableSet theorem nullMeasurableSet_le [SecondCountableTopology α] {μ : Measure δ} {f g : δ → α} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : NullMeasurableSet { a | f a ≤ g a } μ := (hf.prodMk hg).nullMeasurable measurableSet_le' theorem Set.OrdConnected.measurableSet (h : OrdConnected s) : MeasurableSet s := by let u := ⋃ (x ∈ s) (y ∈ s), Ioo x y have huopen : IsOpen u := isOpen_biUnion fun _ _ => isOpen_biUnion fun _ _ => isOpen_Ioo have humeas : MeasurableSet u := huopen.measurableSet have hfinite : (s \ u).Finite := s.finite_diff_iUnion_Ioo have : u ⊆ s := iUnion₂_subset fun x hx => iUnion₂_subset fun y hy => Ioo_subset_Icc_self.trans (h.out hx hy) rw [← union_diff_cancel this] exact humeas.union hfinite.measurableSet theorem IsPreconnected.measurableSet (h : IsPreconnected s) : MeasurableSet s := h.ordConnected.measurableSet theorem generateFrom_Ico_mem_le_borel {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] (s t : Set α) : MeasurableSpace.generateFrom { S | ∃ l ∈ s, ∃ u ∈ t, l < u ∧ Ico l u = S } ≤ borel α := by apply generateFrom_le borelize α rintro _ ⟨a, -, b, -, -, rfl⟩ exact measurableSet_Ico theorem Dense.borel_eq_generateFrom_Ico_mem_aux {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → y ∈ s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } := by set S : Set (Set α) := { S | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } refine le_antisymm ?_ (generateFrom_Ico_mem_le_borel _ _) letI : MeasurableSpace α := generateFrom S rw [borel_eq_generateFrom_Iio] refine generateFrom_le (forall_mem_range.2 fun a => ?_) rcases hd.exists_countable_dense_subset_bot_top with ⟨t, hts, hc, htd, htb, -⟩ by_cases! ha : ∀ b < a, (Ioo b a).Nonempty · convert_to MeasurableSet (⋃ (l ∈ t) (u ∈ t) (_ : l < u) (_ : u ≤ a), Ico l u) · ext y simp only [mem_iUnion, mem_Iio, mem_Ico] constructor · intro hy rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) y with ⟨l, hlt, hly⟩ rcases htd.exists_mem_open isOpen_Ioo (ha y hy) with ⟨u, hut, hyu, hua⟩ exact ⟨l, hlt, u, hut, hly.trans_lt hyu, hua.le, hly, hyu⟩ · rintro ⟨l, -, u, -, -, hua, -, hyu⟩ exact hyu.trans_le hua · refine MeasurableSet.biUnion hc fun a ha => MeasurableSet.biUnion hc fun b hb => ?_ refine MeasurableSet.iUnion fun hab => MeasurableSet.iUnion fun _ => ?_ exact .basic _ ⟨a, hts ha, b, hts hb, hab, mem_singleton _⟩ · replace ha : a ∈ s := hIoo ha.choose a ha.choose_spec.1 ha.choose_spec.2 convert_to MeasurableSet (⋃ (l ∈ t) (_ : l < a), Ico l a) · symm simp only [← Ici_inter_Iio, ← iUnion_inter, inter_eq_right, subset_def, mem_iUnion, mem_Ici, mem_Iio] intro x hx rcases htd.exists_le' (fun b hb => htb _ hb (hbot b hb)) x with ⟨z, hzt, hzx⟩ exact ⟨z, hzt, hzx.trans_lt hx, hzx⟩ · refine .biUnion hc fun x hx => MeasurableSet.iUnion fun hlt => ?_ exact .basic _ ⟨x, hts hx, a, ha, hlt, mem_singleton _⟩ theorem Dense.borel_eq_generateFrom_Ico_mem {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMinOrder α] {s : Set α} (hd : Dense s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ico l u = S } := hd.borel_eq_generateFrom_Ico_mem_aux (by simp) fun _ _ hxy H => ((nonempty_Ioo.2 hxy).ne_empty H).elim theorem borel_eq_generateFrom_Ico (α : Type*) [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] : borel α = .generateFrom { S : Set α | ∃ (l u : α), l < u ∧ Ico l u = S } := by simpa only [exists_prop, mem_univ, true_and] using (@dense_univ α _).borel_eq_generateFrom_Ico_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ => mem_univ _ theorem Dense.borel_eq_generateFrom_Ioc_mem_aux {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s) (hbot : ∀ x, IsTop x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → x ∈ s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } := by convert hd.orderDual.borel_eq_generateFrom_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _ using 2 · ext s constructor <;> rintro ⟨l, hl, u, hu, hlt, rfl⟩ exacts [⟨u, hu, l, hl, hlt, Ico_toDual⟩, ⟨u, hu, l, hl, hlt, Ioc_toDual⟩] · erw [Ioo_toDual] exact he theorem Dense.borel_eq_generateFrom_Ioc_mem {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMaxOrder α] {s : Set α} (hd : Dense s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } := hd.borel_eq_generateFrom_Ioc_mem_aux (by simp) fun _ _ hxy H => ((nonempty_Ioo.2 hxy).ne_empty H).elim theorem borel_eq_generateFrom_Ioc (α : Type*) [TopologicalSpace α] [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] : borel α = .generateFrom { S : Set α | ∃ l u, l < u ∧ Ioc l u = S } := by simpa only [exists_prop, mem_univ, true_and] using (@dense_univ α _).borel_eq_generateFrom_Ioc_mem_aux (fun _ _ => mem_univ _) fun _ _ _ _ => mem_univ _ namespace MeasureTheory.Measure /-- Two finite measures on a Borel space are equal if they agree on all closed-open intervals. If `α` is a conditionally complete linear order with no top element, `MeasureTheory.Measure.ext_of_Ico` is an extensionality lemma with weaker assumptions on `μ` and `ν`. -/ theorem ext_of_Ico_finite {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α) [IsFiniteMeasure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν := by refine ext_of_generate_finite _ (BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ico α)) (isPiSystem_Ico (id : α → α) id) ?_ hμν rintro - ⟨a, b, hlt, rfl⟩ exact h hlt /-- Two finite measures on a Borel space are equal if they agree on all open-closed intervals. If `α` is a conditionally complete linear order with no top element, `MeasureTheory.Measure.ext_of_Ioc` is an extensionality lemma with weaker assumptions on `μ` and `ν`. -/ theorem ext_of_Ioc_finite {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α) [IsFiniteMeasure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := by refine @ext_of_Ico_finite αᵒᵈ _ _ _ _ _ ‹_› μ ν _ hμν fun a b hab => ?_ erw [Ico_toDual (α := α)] exact h hab /-- Two measures which are finite on closed-open intervals are equal if they agree on all closed-open intervals. -/ theorem ext_of_Ico' {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] [NoMaxOrder α] (μ ν : Measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ico a b) ≠ ∞) (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν := by rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, hsb, _⟩ have : (⋃ (l ∈ s) (u ∈ s) (_ : l < u), {Ico l u} : Set (Set α)).Countable := hsc.biUnion fun l _ => hsc.biUnion fun u _ => countable_iUnion fun _ => countable_singleton _ simp only [← setOf_eq_eq_singleton, ← setOf_exists] at this refine Measure.ext_of_generateFrom_of_cover_subset (BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ico α)) (isPiSystem_Ico id id) ?_ this ?_ ?_ ?_ · rintro _ ⟨l, -, u, -, h, rfl⟩ exact ⟨l, u, h, rfl⟩ · refine sUnion_eq_univ_iff.2 fun x => ?_ rcases hsd.exists_le' hsb x with ⟨l, hls, hlx⟩ rcases hsd.exists_gt x with ⟨u, hus, hxu⟩ exact ⟨_, ⟨l, hls, u, hus, hlx.trans_lt hxu, rfl⟩, hlx, hxu⟩ · rintro _ ⟨l, -, u, -, hlt, rfl⟩ exact hμ hlt · rintro _ ⟨l, u, hlt, rfl⟩ exact h hlt /-- Two measures which are finite on closed-open intervals are equal if they agree on all open-closed intervals. -/ theorem ext_of_Ioc' {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] [NoMinOrder α] (μ ν : Measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ioc a b) ≠ ∞) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := by refine @ext_of_Ico' αᵒᵈ _ _ _ _ _ ‹_› _ μ ν ?_ ?_ <;> intro a b hab <;> erw [Ico_toDual (α := α)] exacts [hμ hab, h hab] /-- Two measures which are finite on closed-open intervals are equal if they agree on all closed-open intervals. -/ theorem ext_of_Ico {α : Type*} [TopologicalSpace α] {_m : MeasurableSpace α} [SecondCountableTopology α] [ConditionallyCompleteLinearOrder α] [OrderTopology α] [BorelSpace α] [NoMaxOrder α] (μ ν : Measure α) [IsLocallyFiniteMeasure μ] (h : ∀ ⦃a b⦄, a < b → μ (Ico a b) = ν (Ico a b)) : μ = ν := μ.ext_of_Ico' ν (fun _ _ _ => measure_Ico_lt_top.ne) h /-- Two measures which are finite on closed-open intervals are equal if they agree on all open-closed intervals. -/ theorem ext_of_Ioc {α : Type*} [TopologicalSpace α] {_m : MeasurableSpace α} [SecondCountableTopology α] [ConditionallyCompleteLinearOrder α] [OrderTopology α] [BorelSpace α] [NoMinOrder α] (μ ν : Measure α) [IsLocallyFiniteMeasure μ] (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := μ.ext_of_Ioc' ν (fun _ _ _ => measure_Ioc_lt_top.ne) h /-- Two finite measures on a Borel space are equal if they agree on all left-infinite right-closed intervals. -/ theorem ext_of_Iic {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α) [IsFiniteMeasure μ] (h : ∀ a, μ (Iic a) = ν (Iic a)) : μ = ν := by refine ext_of_Ioc_finite μ ν ?_ fun a b hlt => ?_ · rcases exists_countable_dense_bot_top α with ⟨s, hsc, hsd, -, hst⟩ have : DirectedOn (· ≤ ·) s := directedOn_iff_directed.2 (Subtype.mono_coe _).directed_le simp only [← biSup_measure_Iic hsc (hsd.exists_ge' hst) this, h] rw [← Iic_diff_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) nullMeasurableSet_Iic, measure_diff (Iic_subset_Iic.2 hlt.le) nullMeasurableSet_Iic, h a, h b] · rw [← h a] finiteness · finiteness /-- Two finite measures on a Borel space are equal if they agree on all left-closed right-infinite intervals. -/ theorem ext_of_Ici {α : Type*} [TopologicalSpace α] {_ : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α) [IsFiniteMeasure μ] (h : ∀ a, μ (Ici a) = ν (Ici a)) : μ = ν := @ext_of_Iic αᵒᵈ _ _ _ _ _ ‹_› _ _ _ h end MeasureTheory.Measure @[measurability] theorem measurableSet_uIcc : MeasurableSet (uIcc a b) := measurableSet_Icc @[measurability] theorem measurableSet_uIoc : MeasurableSet (uIoc a b) := measurableSet_Ioc variable [SecondCountableTopology α] @[measurability, fun_prop] theorem Measurable.max {f g : δ → α} (hf : Measurable f) (hg : Measurable g) : Measurable fun a => max (f a) (g a) := by simpa only [max_def'] using hf.piecewise (measurableSet_le hg hf) hg @[measurability, fun_prop] nonrec theorem AEMeasurable.max {f g : δ → α} {μ : Measure δ} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun a => max (f a) (g a)) μ := ⟨fun a => max (hf.mk f a) (hg.mk g a), hf.measurable_mk.max hg.measurable_mk, EventuallyEq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩ @[measurability, fun_prop] theorem Measurable.min {f g : δ → α} (hf : Measurable f) (hg : Measurable g) : Measurable fun a => min (f a) (g a) := by simpa only [min_def] using hf.piecewise (measurableSet_le hf hg) hg @[measurability, fun_prop] nonrec theorem AEMeasurable.min {f g : δ → α} {μ : Measure δ} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun a => min (f a) (g a)) μ := ⟨fun a => min (hf.mk f a) (hg.mk g a), hf.measurable_mk.min hg.measurable_mk, EventuallyEq.comp₂ hf.ae_eq_mk _ hg.ae_eq_mk⟩ end LinearOrder section Lattice variable [TopologicalSpace γ] {mγ : MeasurableSpace γ} [BorelSpace γ] instance (priority := 100) ContinuousSup.measurableSup [Max γ] [ContinuousSup γ] : MeasurableSup γ where measurable_const_sup _ := (continuous_const.sup continuous_id).measurable measurable_sup_const _ := (continuous_id.sup continuous_const).measurable instance (priority := 100) ContinuousSup.measurableSup₂ [SecondCountableTopology γ] [Max γ] [ContinuousSup γ] : MeasurableSup₂ γ := ⟨continuous_sup.measurable⟩ instance (priority := 100) ContinuousInf.measurableInf [Min γ] [ContinuousInf γ] : MeasurableInf γ where measurable_const_inf _ := (continuous_const.inf continuous_id).measurable measurable_inf_const _ := (continuous_id.inf continuous_const).measurable instance (priority := 100) ContinuousInf.measurableInf₂ [SecondCountableTopology γ] [Min γ] [ContinuousInf γ] : MeasurableInf₂ γ := ⟨continuous_inf.measurable⟩ end Lattice end Orders section BorelSpace variable [TopologicalSpace α] {mα : MeasurableSpace α} [BorelSpace α] variable [TopologicalSpace β] {mβ : MeasurableSpace β} [BorelSpace β] variable {mδ : MeasurableSpace δ} section LinearOrder variable [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] theorem measurable_of_Iio {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iio x)) : Measurable f := by convert measurable_generateFrom (α := δ) _ · exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Iio _) · rintro _ ⟨x, rfl⟩; exact hf x theorem UpperSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α} (hf : UpperSemicontinuous f) : Measurable f := measurable_of_Iio fun y => (hf.isOpen_preimage y).measurableSet theorem measurable_of_Ioi {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ioi x)) : Measurable f := by convert measurable_generateFrom (α := δ) _ · exact BorelSpace.measurable_eq.trans (borel_eq_generateFrom_Ioi _) · rintro _ ⟨x, rfl⟩; exact hf x theorem LowerSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α} (hf : LowerSemicontinuous f) : Measurable f := measurable_of_Ioi fun y => (hf.isOpen_preimage y).measurableSet theorem measurable_of_Iic {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Iic x)) : Measurable f := by apply measurable_of_Ioi simp_rw [← compl_Iic, preimage_compl, MeasurableSet.compl_iff] assumption theorem measurable_of_Ici {f : δ → α} (hf : ∀ x, MeasurableSet (f ⁻¹' Ici x)) : Measurable f := by apply measurable_of_Iio simp_rw [← compl_Ici, preimage_compl, MeasurableSet.compl_iff] assumption /-- If a function is the least upper bound of countably many measurable functions, then it is measurable. -/ theorem Measurable.isLUB {ι} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, Measurable (f i)) (hg : ∀ b, IsLUB { a | ∃ i, f i b = a } (g b)) : Measurable g := by change ∀ b, IsLUB (range fun i => f i b) (g b) at hg rw [‹BorelSpace α›.measurable_eq, borel_eq_generateFrom_Ioi α] apply measurable_generateFrom rintro _ ⟨a, rfl⟩ simp_rw [Set.preimage, mem_Ioi, lt_isLUB_iff (hg _), exists_range_iff, setOf_exists] exact MeasurableSet.iUnion fun i => hf i (isOpen_lt' _).measurableSet /-- If a function is the least upper bound of countably many measurable functions on a measurable set `s`, and coincides with a measurable function outside of `s`, then it is measurable. -/ theorem Measurable.isLUB_of_mem {ι} [Countable ι] {f : ι → δ → α} {g g' : δ → α} (hf : ∀ i, Measurable (f i)) {s : Set δ} (hs : MeasurableSet s) (hg : ∀ b ∈ s, IsLUB { a | ∃ i, f i b = a } (g b)) (hg' : EqOn g g' sᶜ) (g'_meas : Measurable g') : Measurable g := by classical rcases isEmpty_or_nonempty ι with hι | ⟨⟨i⟩⟩ · rcases eq_empty_or_nonempty s with rfl | ⟨x, hx⟩ · convert g'_meas rwa [compl_empty, eqOn_univ] at hg' · have A : ∀ b ∈ s, IsBot (g b) := by simpa using hg have B : ∀ b ∈ s, g b = g x := by intro b hb apply le_antisymm (A b hb (g x)) (A x hx (g b)) have : g = s.piecewise (fun _y ↦ g x) g' := by ext b by_cases hb : b ∈ s · simp [hb, B] · simp [hb, hg' hb] rw [this] exact Measurable.piecewise hs measurable_const g'_meas · have : Nonempty ι := ⟨i⟩ let f' : ι → δ → α := fun i ↦ s.piecewise (f i) g' suffices ∀ b, IsLUB { a | ∃ i, f' i b = a } (g b) from Measurable.isLUB (fun i ↦ Measurable.piecewise hs (hf i) g'_meas) this intro b by_cases hb : b ∈ s · have A : ∀ i, f' i b = f i b := fun i ↦ by simp [f', hb] simpa [A] using hg b hb · have A : ∀ i, f' i b = g' b := fun i ↦ by simp [f', hb] simp [A, hg' hb, isLUB_singleton] theorem AEMeasurable.isLUB {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, AEMeasurable (f i) μ) (hg : ∀ᵐ b ∂μ, IsLUB { a | ∃ i, f i b = a } (g b)) : AEMeasurable g μ := by classical nontriviality α haveI hα : Nonempty α := inferInstance rcases isEmpty_or_nonempty ι with hι | hι · simp only [IsEmpty.exists_iff, setOf_false, isLUB_empty_iff] at hg exact aemeasurable_const' (hg.mono fun a ha => hg.mono fun b hb => (ha _).antisymm (hb _)) let p : δ → (ι → α) → Prop := fun x f' => IsLUB { a | ∃ i, f' i = a } (g x) let g_seq := (aeSeqSet hf p).piecewise g fun _ => hα.some have hg_seq : ∀ b, IsLUB { a | ∃ i, aeSeq hf p i b = a } (g_seq b) := by intro b simp only [g_seq, aeSeq, Set.piecewise] split_ifs with h · have h_set_eq : { a : α | ∃ i : ι, (hf i).mk (f i) b = a } = { a : α | ∃ i : ι, f i b = a } := by ext x simp_rw [Set.mem_setOf_eq, aeSeq.mk_eq_fun_of_mem_aeSeqSet hf h] rw [h_set_eq] exact aeSeq.fun_prop_of_mem_aeSeqSet hf h · exact IsGreatest.isLUB ⟨(@exists_const (hα.some = hα.some) ι _).2 rfl, fun x ⟨i, hi⟩ => hi.ge⟩ refine ⟨g_seq, Measurable.isLUB (aeSeq.measurable hf p) hg_seq, ?_⟩ exact (ite_ae_eq_of_measure_compl_zero g (fun _ => hα.some) (aeSeqSet hf p) (aeSeq.measure_compl_aeSeqSet_eq_zero hf hg)).symm /-- If a function is the greatest lower bound of countably many measurable functions, then it is measurable. -/ theorem Measurable.isGLB {ι} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, Measurable (f i)) (hg : ∀ b, IsGLB { a | ∃ i, f i b = a } (g b)) : Measurable g := Measurable.isLUB (α := αᵒᵈ) hf hg /-- If a function is the greatest lower bound of countably many measurable functions on a measurable set `s`, and coincides with a measurable function outside of `s`, then it is measurable. -/ theorem Measurable.isGLB_of_mem {ι} [Countable ι] {f : ι → δ → α} {g g' : δ → α} (hf : ∀ i, Measurable (f i)) {s : Set δ} (hs : MeasurableSet s) (hg : ∀ b ∈ s, IsGLB { a | ∃ i, f i b = a } (g b)) (hg' : EqOn g g' sᶜ) (g'_meas : Measurable g') : Measurable g := Measurable.isLUB_of_mem (α := αᵒᵈ) hf hs hg hg' g'_meas theorem AEMeasurable.isGLB {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, AEMeasurable (f i) μ) (hg : ∀ᵐ b ∂μ, IsGLB { a | ∃ i, f i b = a } (g b)) : AEMeasurable g μ := AEMeasurable.isLUB (α := αᵒᵈ) hf hg protected theorem Monotone.measurable [LinearOrder β] [OrderClosedTopology β] {f : β → α} (hf : Monotone f) : Measurable f := suffices h : ∀ x, OrdConnected (f ⁻¹' Ioi x) from measurable_of_Ioi fun x => (h x).measurableSet fun _ => ordConnected_def.mpr fun _a ha _ _ _c hc => lt_of_lt_of_le ha (hf hc.1) theorem aemeasurable_restrict_of_monotoneOn [LinearOrder β] [OrderClosedTopology β] {μ : Measure β} {s : Set β} (hs : MeasurableSet s) {f : β → α} (hf : MonotoneOn f s) : AEMeasurable f (μ.restrict s) := have : Monotone (f ∘ (↑) : s → α) := fun ⟨x, hx⟩ ⟨y, hy⟩ => fun (hxy : x ≤ y) => hf hx hy hxy aemeasurable_restrict_of_measurable_subtype hs this.measurable protected theorem Antitone.measurable [LinearOrder β] [OrderClosedTopology β] {f : β → α} (hf : Antitone f) : Measurable f := @Monotone.measurable αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ hf theorem aemeasurable_restrict_of_antitoneOn [LinearOrder β] [OrderClosedTopology β] {μ : Measure β} {s : Set β} (hs : MeasurableSet s) {f : β → α} (hf : AntitoneOn f s) : AEMeasurable f (μ.restrict s) := @aemeasurable_restrict_of_monotoneOn αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ _ hs _ hf theorem MeasurableSet.of_mem_nhdsGT_aux {s : Set α} (h : ∀ x ∈ s, s ∈ 𝓝[>] x) (h' : ∀ x ∈ s, ∃ y, x < y) : MeasurableSet s := by choose! M hM using h' suffices H : (s \ interior s).Countable by have : s = interior s ∪ s \ interior s := by rw [union_diff_cancel interior_subset] rw [this] exact isOpen_interior.measurableSet.union H.measurableSet have A : ∀ x ∈ s, ∃ y ∈ Ioi x, Ioo x y ⊆ s := fun x hx => (mem_nhdsGT_iff_exists_Ioo_subset' (hM x hx)).1 (h x hx) choose! y hy h'y using A have B : Set.PairwiseDisjoint (s \ interior s) fun x => Ioo x (y x) := by intro x hx x' hx' hxx' rcases lt_or_gt_of_ne hxx' with (h' | h') · refine disjoint_left.2 fun z hz h'z => ?_ have : x' ∈ interior s := mem_interior.2 ⟨Ioo x (y x), h'y _ hx.1, isOpen_Ioo, ⟨h', h'z.1.trans hz.2⟩⟩ exact False.elim (hx'.2 this) · refine disjoint_left.2 fun z hz h'z => ?_ have : x ∈ interior s := mem_interior.2 ⟨Ioo x' (y x'), h'y _ hx'.1, isOpen_Ioo, ⟨h', hz.1.trans h'z.2⟩⟩ exact False.elim (hx.2 this) exact B.countable_of_Ioo fun x hx => hy x hx.1 /-- If a set is a right-neighborhood of all of its points, then it is measurable. -/ theorem MeasurableSet.of_mem_nhdsGT {s : Set α} (h : ∀ x ∈ s, s ∈ 𝓝[>] x) : MeasurableSet s := by by_cases H : ∃ x ∈ s, IsTop x · rcases H with ⟨x₀, x₀s, h₀⟩ have : s = { x₀ } ∪ s \ { x₀ } := by rw [union_diff_cancel (singleton_subset_iff.2 x₀s)] rw [this] refine (measurableSet_singleton _).union ?_ have A : ∀ x ∈ s \ { x₀ }, x < x₀ := fun x hx => lt_of_le_of_ne (h₀ _) (by simpa using hx.2) refine .of_mem_nhdsGT_aux (fun x hx => ?_) fun x hx => ⟨x₀, A x hx⟩ obtain ⟨u, hu, us⟩ : ∃ (u : α), u ∈ Ioi x ∧ Ioo x u ⊆ s := (mem_nhdsGT_iff_exists_Ioo_subset' (A x hx)).1 (h x hx.1) refine (mem_nhdsGT_iff_exists_Ioo_subset' (A x hx)).2 ⟨u, hu, fun y hy => ⟨us hy, ?_⟩⟩ exact ne_of_lt (hy.2.trans_le (h₀ _)) · refine .of_mem_nhdsGT_aux h ?_ simp only [IsTop] at H push_neg at H exact H lemma measurableSet_bddAbove_range {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) : MeasurableSet {b | BddAbove (range (fun i ↦ f i b))} := by rcases isEmpty_or_nonempty α with hα|hα · have : ∀ b, range (fun i ↦ f i b) = ∅ := fun b ↦ eq_empty_of_isEmpty _ simp [this] have A : ∀ (i : ι) (c : α), MeasurableSet {x | f i x ≤ c} := by intro i c exact measurableSet_le (hf i) measurable_const have B : ∀ (c : α), MeasurableSet {x | ∀ i, f i x ≤ c} := by intro c rw [setOf_forall] exact MeasurableSet.iInter (fun i ↦ A i c) obtain ⟨u, hu⟩ : ∃ (u : ℕ → α), Tendsto u atTop atTop := exists_seq_tendsto (atTop : Filter α) have : {b | BddAbove (range (fun i ↦ f i b))} = {x | ∃ n, ∀ i, f i x ≤ u n} := by apply Subset.antisymm · rintro x ⟨c, hc⟩ obtain ⟨n, hn⟩ : ∃ n, c ≤ u n := (tendsto_atTop.1 hu c).exists exact ⟨n, fun i ↦ (hc ((mem_range_self i))).trans hn⟩ · rintro x ⟨n, hn⟩ refine ⟨u n, ?_⟩ rintro - ⟨i, rfl⟩ exact hn i rw [this, setOf_exists] exact MeasurableSet.iUnion (fun n ↦ B (u n)) lemma measurableSet_bddBelow_range {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) : MeasurableSet {b | BddBelow (range (fun i ↦ f i b))} := measurableSet_bddAbove_range (α := αᵒᵈ) hf end LinearOrder section ConditionallyCompleteLattice @[measurability, fun_prop] theorem Measurable.iSup_Prop {α} {mα : MeasurableSpace α} [ConditionallyCompleteLattice α] (p : Prop) {f : δ → α} (hf : Measurable f) : Measurable fun b => ⨆ _ : p, f b := by classical simp_rw [ciSup_eq_ite] split_ifs with h · exact hf · exact measurable_const @[measurability, fun_prop] theorem Measurable.iInf_Prop {α} {mα : MeasurableSpace α} [ConditionallyCompleteLattice α] (p : Prop) {f : δ → α} (hf : Measurable f) : Measurable fun b => ⨅ _ : p, f b := by classical simp_rw [ciInf_eq_ite] split_ifs with h · exact hf · exact measurable_const end ConditionallyCompleteLattice section ConditionallyCompleteLinearOrder variable [ConditionallyCompleteLinearOrder α] [OrderTopology α] [SecondCountableTopology α] @[measurability, fun_prop] protected theorem Measurable.iSup {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) : Measurable (fun b ↦ ⨆ i, f i b) := by rcases isEmpty_or_nonempty ι with hι|hι · simp [iSup_of_empty'] have A : MeasurableSet {b | BddAbove (range (fun i ↦ f i b))} := measurableSet_bddAbove_range hf have : Measurable (fun (_b : δ) ↦ sSup (∅ : Set α)) := measurable_const apply Measurable.isLUB_of_mem hf A _ _ this · intro b hb apply isLUB_ciSup simpa · intro b hb apply csSup_of_not_bddAbove simpa -- TODO: Why does this error? -- /-- Compositional version of `Measurable.iSup` for use by `fun_prop`. -/ -- @[fun_prop] -- protected lemma Measurable.iSup'' {_ : MeasurableSpace γ} {ι : Sort*} [Countable ι] -- {f : ι → γ → δ → α} {h : γ → δ} (hf : ∀ i, Measurable ↿(f i)) (hh : Measurable h) : -- Measurable fun a ↦ (⨆ i, f i a) (h a) := by -- simp_rw [iSup_apply] -- exact .iSup fun i ↦ by fun_prop @[measurability, fun_prop] protected theorem AEMeasurable.iSup {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} (hf : ∀ i, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨆ i, f i b) μ := by refine ⟨fun b ↦ ⨆ i, (hf i).mk (f i) b, .iSup (fun i ↦ (hf i).measurable_mk), ?_⟩ filter_upwards [ae_all_iff.2 (fun i ↦ (hf i).ae_eq_mk)] with b hb using by simp [hb] @[measurability, fun_prop] protected theorem Measurable.iInf {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) : Measurable fun b => ⨅ i, f i b := .iSup (α := αᵒᵈ) hf @[measurability, fun_prop] protected theorem AEMeasurable.iInf {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} (hf : ∀ i, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨅ i, f i b) μ := .iSup (α := αᵒᵈ) hf protected theorem Measurable.sSup {ι} {f : ι → δ → α} {s : Set ι} (hs : s.Countable) (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun x => sSup ((fun i => f i x) '' s) := by simp_rw [image_eq_range] have : Countable s := hs.to_subtype exact .iSup fun i ↦ hf i i.2 protected theorem Measurable.sInf {ι} {f : ι → δ → α} {s : Set ι} (hs : s.Countable) (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun x => sInf ((fun i => f i x) '' s) := .sSup (α := αᵒᵈ) hs hf theorem Measurable.biSup {ι} (s : Set ι) {f : ι → δ → α} (hs : s.Countable) (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun b => ⨆ i ∈ s, f i b := by haveI : Encodable s := hs.toEncodable by_cases H : ∀ i, i ∈ s · have : ∀ b, ⨆ i ∈ s, f i b = ⨆ (i : s), f i b := fun b ↦ cbiSup_eq_of_forall (f := fun i ↦ f i b) H simp only [this] exact .iSup (fun (i : s) ↦ hf i i.2) · have : ∀ b, ⨆ i ∈ s, f i b = (⨆ (i : s), f i b) ⊔ sSup ∅ := fun b ↦ cbiSup_eq_of_not_forall (f := fun i ↦ f i b) H simp only [this] apply Measurable.sup _ measurable_const exact .iSup (fun (i : s) ↦ hf i i.2) theorem AEMeasurable.biSup {ι} {μ : Measure δ} (s : Set ι) {f : ι → δ → α} (hs : s.Countable) (hf : ∀ i ∈ s, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨆ i ∈ s, f i b) μ := by classical let g : ι → δ → α := fun i ↦ if hi : i ∈ s then (hf i hi).mk (f i) else fun _b ↦ sSup ∅ have : ∀ i ∈ s, Measurable (g i) := by intro i hi simpa [g, hi] using (hf i hi).measurable_mk refine ⟨fun b ↦ ⨆ (i) (_ : i ∈ s), g i b, .biSup s hs this, ?_⟩ have : ∀ i ∈ s, ∀ᵐ b ∂μ, f i b = g i b := fun i hi ↦ by simpa [g, hi] using (hf i hi).ae_eq_mk filter_upwards [(ae_ball_iff hs).2 this] with b hb exact iSup_congr fun i => iSup_congr (hb i) theorem Measurable.biInf {ι} (s : Set ι) {f : ι → δ → α} (hs : s.Countable) (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun b => ⨅ i ∈ s, f i b := .biSup (α := αᵒᵈ) s hs hf theorem AEMeasurable.biInf {ι} {μ : Measure δ} (s : Set ι) {f : ι → δ → α} (hs : s.Countable) (hf : ∀ i ∈ s, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨅ i ∈ s, f i b) μ := .biSup (α := αᵒᵈ) s hs hf /-- `liminf` over a general filter is measurable. See `Measurable.liminf` for the version over `ℕ`. -/ theorem Measurable.liminf' {ι ι'} {f : ι → δ → α} {v : Filter ι} (hf : ∀ i, Measurable (f i)) {p : ι' → Prop} {s : ι' → Set ι} (hv : v.HasCountableBasis p s) (hs : ∀ j, (s j).Countable) : Measurable fun x => liminf (f · x) v := by classical /- We would like to write the liminf as `⨆ (j : Subtype p), ⨅ (i : s j), f i x`, as the measurability would follow from the measurability of infs and sups. Unfortunately, this is not true in general conditionally complete linear orders because of issues with empty sets or sets which are not bounded above or below. A slightly more complicated expression for the liminf, valid in general, is given in `Filter.HasBasis.liminf_eq_ite`. This expression, built from `if ... then ... else` and infs and sups, can be readily checked to be measurable. -/ have : Countable (Subtype p) := hv.countable rcases isEmpty_or_nonempty (Subtype p) with hp|hp · simp [hv.liminf_eq_sSup_iUnion_iInter] by_cases H : ∃ (j : Subtype p), s j = ∅ · simp_rw [hv.liminf_eq_ite, if_pos H, measurable_const] simp_rw [hv.liminf_eq_ite, if_neg H] have : ∀ i, Countable (s i) := fun i ↦ countable_coe_iff.2 (hs i) let m : Subtype p → Set δ := fun j ↦ {x | BddBelow (range (fun (i : s j) ↦ f i x))} have m_meas : ∀ j, MeasurableSet (m j) := fun j ↦ measurableSet_bddBelow_range (fun (i : s j) ↦ hf i) have mc_meas : MeasurableSet {x | ∀ (j : Subtype p), x ∉ m j} := by rw [setOf_forall] exact MeasurableSet.iInter (fun j ↦ (m_meas j).compl) refine measurable_const.piecewise mc_meas <| .iSup fun j ↦ ?_ let reparam : δ → Subtype p → Subtype p := fun x ↦ liminf_reparam (fun i ↦ f i x) s p let F0 : Subtype p → δ → α := fun j x ↦ ⨅ (i : s j), f i x have F0_meas : ∀ j, Measurable (F0 j) := fun j ↦ .iInf (fun (i : s j) ↦ hf i) set F1 : δ → α := fun x ↦ F0 (reparam x j) x with hF1 change Measurable F1 let g : ℕ → Subtype p := Classical.choose (exists_surjective_nat (Subtype p)) have Z : ∀ x, ∃ n, x ∈ m (g n) ∨ ∀ k, x ∉ m k := by intro x by_cases! H : ∃ k, x ∈ m k · rcases H with ⟨k, hk⟩ rcases Classical.choose_spec (exists_surjective_nat (Subtype p)) k with ⟨n, rfl⟩ exact ⟨n, Or.inl hk⟩ · exact ⟨0, Or.inr H⟩ have : F1 = fun x ↦ if x ∈ m j then F0 j x else F0 (g (Nat.find (Z x))) x := by ext x have A : reparam x j = if x ∈ m j then j else g (Nat.find (Z x)) := rfl split_ifs with hjx · have : reparam x j = j := by rw [A, if_pos hjx] simp only [hF1, this] · have : reparam x j = g (Nat.find (Z x)) := by rw [A, if_neg hjx] simp only [hF1, this] rw [this] apply Measurable.piecewise (m_meas j) (F0_meas j) apply Measurable.find (fun n ↦ F0_meas (g n)) (fun n ↦ ?_) exact (m_meas (g n)).union mc_meas /-- `limsup` over a general filter is measurable. See `Measurable.limsup` for the version over `ℕ`. -/ theorem Measurable.limsup' {ι ι'} {f : ι → δ → α} {u : Filter ι} (hf : ∀ i, Measurable (f i)) {p : ι' → Prop} {s : ι' → Set ι} (hu : u.HasCountableBasis p s) (hs : ∀ i, (s i).Countable) : Measurable fun x => limsup (fun i => f i x) u := .liminf' (α := αᵒᵈ) hf hu hs /-- `liminf` over `ℕ` is measurable. See `Measurable.liminf'` for a version with a general filter. -/ @[measurability, fun_prop] theorem Measurable.liminf {f : ℕ → δ → α} (hf : ∀ i, Measurable (f i)) : Measurable fun x => liminf (fun i => f i x) atTop := .liminf' hf atTop_countable_basis fun _ => to_countable _ /-- `limsup` over `ℕ` is measurable. See `Measurable.limsup'` for a version with a general filter. -/ @[measurability, fun_prop] theorem Measurable.limsup {f : ℕ → δ → α} (hf : ∀ i, Measurable (f i)) : Measurable fun x => limsup (fun i => f i x) atTop := .limsup' hf atTop_countable_basis fun _ => to_countable _ end ConditionallyCompleteLinearOrder @[deprecated (since := "2025-05-30")] alias Homemorph.toMeasurableEquiv := Homeomorph.toMeasurableEquiv end BorelSpace section ENNReal /-- One can cut out `ℝ≥0∞` into the sets `{0}`, `Ico (t^n) (t^(n+1))` for `n : ℤ` and `{∞}`. This gives a way to compute the measure of a set in terms of sets on which a given function `f` does not fluctuate by more than `t`. -/ theorem measure_eq_measure_preimage_add_measure_tsum_Ico_zpow {α : Type*} {mα : MeasurableSpace α} (μ : Measure α) {f : α → ℝ≥0∞} (hf : Measurable f) {s : Set α} (hs : MeasurableSet s) {t : ℝ≥0} (ht : 1 < t) : μ s = μ (s ∩ f ⁻¹' {0}) + μ (s ∩ f ⁻¹' {∞}) + ∑' n : ℤ, μ (s ∩ f ⁻¹' Ico ((t : ℝ≥0∞) ^ n) ((t : ℝ≥0∞) ^ (n + 1))) := by have A : μ s = μ (s ∩ f ⁻¹' {0}) + μ (s ∩ f ⁻¹' Ioi 0) := by rw [← measure_union] · rw [← inter_union_distrib_left, ← preimage_union, singleton_union, Ioi_insert, ← _root_.bot_eq_zero, Ici_bot, preimage_univ, inter_univ] · exact disjoint_singleton_left.mpr notMem_Ioi_self |>.preimage f |>.inter_right' s |>.inter_left' s · exact hs.inter (hf measurableSet_Ioi) have B : μ (s ∩ f ⁻¹' Ioi 0) = μ (s ∩ f ⁻¹' {∞}) + μ (s ∩ f ⁻¹' Ioo 0 ∞) := by rw [← measure_union] · rw [← inter_union_distrib_left] congr ext x simp only [mem_singleton_iff, mem_union, mem_Ioo, mem_Ioi, mem_preimage] obtain (H | H) : f x = ∞ ∨ f x < ∞ := eq_or_lt_of_le le_top · simp only [H, or_false, ENNReal.zero_lt_top, not_top_lt, and_false] · simp only [H, H.ne, and_true, false_or] · refine disjoint_left.2 fun x hx h'x => ?_ have : f x < ∞ := h'x.2.2 exact lt_irrefl _ (this.trans_le (le_of_eq hx.2.symm)) · exact hs.inter (hf measurableSet_Ioo) have C : μ (s ∩ f ⁻¹' Ioo 0 ∞) = ∑' n : ℤ, μ (s ∩ f ⁻¹' Ico ((t : ℝ≥0∞) ^ n) ((t : ℝ≥0∞) ^ (n + 1))) := by rw [← measure_iUnion, ENNReal.Ioo_zero_top_eq_iUnion_Ico_zpow (ENNReal.one_lt_coe_iff.2 ht) ENNReal.coe_ne_top, preimage_iUnion, inter_iUnion] · intro i j hij wlog h : i < j generalizing i j · exact (this hij.symm (hij.lt_or_gt.resolve_left h)).symm refine disjoint_left.2 fun x hx h'x => lt_irrefl (f x) ?_ calc f x < (t : ℝ≥0∞) ^ (i + 1) := hx.2.2 _ ≤ (t : ℝ≥0∞) ^ j := ENNReal.zpow_le_of_le (ENNReal.one_le_coe_iff.2 ht.le) h _ ≤ f x := h'x.2.1 · intro n exact hs.inter (hf measurableSet_Ico) rw [A, B, C, add_assoc] end ENNReal
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean
import Mathlib.MeasureTheory.Group.Arithmetic import Mathlib.Topology.GDelta.MetrizableSpace import Mathlib.Topology.Instances.EReal.Lemmas import Mathlib.Topology.Instances.Rat /-! # Borel (measurable) space ## Main definitions * `borel α` : the least `σ`-algebra that contains all open sets; * `class BorelSpace` : a space with `TopologicalSpace` and `MeasurableSpace` structures such that `‹MeasurableSpace α› = borel α`; * `class OpensMeasurableSpace` : a space with `TopologicalSpace` and `MeasurableSpace` structures such that all open sets are measurable; equivalently, `borel α ≤ ‹MeasurableSpace α›`. * `BorelSpace` instances on `Empty`, `Unit`, `Bool`, `Nat`, `Int`, `Rat`; * `MeasurableSpace` and `BorelSpace` instances on `ℝ`, `ℝ≥0`, `ℝ≥0∞`. ## Main statements * `IsOpen.measurableSet`, `IsClosed.measurableSet`: open and closed sets are measurable; * `Continuous.measurable` : a continuous function is measurable; * `Continuous.measurable2` : if `f : α → β` and `g : α → γ` are measurable and `op : β × γ → δ` is continuous, then `fun x => op (f x, g y)` is measurable; * `Measurable.add` etc. : dot notation for arithmetic operations on `Measurable` predicates, and similarly for `dist` and `edist`; * `AEMeasurable.add` : similar dot notation for almost everywhere measurable functions; -/ noncomputable section open Filter MeasureTheory Set Topology open scoped NNReal ENNReal MeasureTheory universe u v w x y variable {α β γ γ₂ δ : Type*} {ι : Sort y} {s t u : Set α} open MeasurableSpace TopologicalSpace /-- `MeasurableSpace` structure generated by `TopologicalSpace`. -/ def borel (α : Type u) [TopologicalSpace α] : MeasurableSpace α := generateFrom { s : Set α | IsOpen s } theorem borel_anti : Antitone (@borel α) := fun _ _ h => MeasurableSpace.generateFrom_le fun _ hs => .basic _ (h _ hs) theorem borel_eq_top_of_discrete [TopologicalSpace α] [DiscreteTopology α] : borel α = ⊤ := top_le_iff.1 fun s _ => GenerateMeasurable.basic s (isOpen_discrete s) theorem borel_eq_generateFrom_of_subbasis {s : Set (Set α)} [t : TopologicalSpace α] [SecondCountableTopology α] (hs : t = .generateFrom s) : borel α = .generateFrom s := le_antisymm (generateFrom_le fun u (hu : t.IsOpen u) => by rw [hs] at hu induction hu with | basic u hu => exact GenerateMeasurable.basic u hu | univ => exact @MeasurableSet.univ α (generateFrom s) | inter s₁ s₂ _ _ hs₁ hs₂ => exact @MeasurableSet.inter α (generateFrom s) _ _ hs₁ hs₂ | sUnion f hf ih => rcases isOpen_sUnion_countable f (by rwa [hs]) with ⟨v, hv, vf, vu⟩ rw [← vu] exact @MeasurableSet.sUnion α (generateFrom s) _ hv fun x xv => ih _ (vf xv)) (generateFrom_le fun u hu => GenerateMeasurable.basic _ <| show t.IsOpen u by rw [hs]; exact GenerateOpen.basic _ hu) theorem TopologicalSpace.IsTopologicalBasis.borel_eq_generateFrom [TopologicalSpace α] [SecondCountableTopology α] {s : Set (Set α)} (hs : IsTopologicalBasis s) : borel α = .generateFrom s := borel_eq_generateFrom_of_subbasis hs.eq_generateFrom theorem isPiSystem_isOpen [TopologicalSpace α] : IsPiSystem ({s : Set α | IsOpen s}) := fun _s hs _t ht _ => IsOpen.inter hs ht lemma isPiSystem_isClosed [TopologicalSpace α] : IsPiSystem ({s : Set α | IsClosed s}) := fun _s hs _t ht _ ↦ IsClosed.inter hs ht theorem borel_eq_generateFrom_isClosed [TopologicalSpace α] : borel α = .generateFrom { s | IsClosed s } := le_antisymm (generateFrom_le fun _t ht => @MeasurableSet.of_compl α _ (generateFrom { s | IsClosed s }) (GenerateMeasurable.basic _ <| isClosed_compl_iff.2 ht)) (generateFrom_le fun _t ht => @MeasurableSet.of_compl α _ (borel α) (GenerateMeasurable.basic _ <| isOpen_compl_iff.2 ht)) theorem borel_comap {f : α → β} {t : TopologicalSpace β} : @borel α (t.induced f) = (@borel β t).comap f := comap_generateFrom.symm theorem Continuous.borel_measurable [TopologicalSpace α] [TopologicalSpace β] {f : α → β} (hf : Continuous f) : @Measurable α β (borel α) (borel β) f := Measurable.of_le_map <| generateFrom_le fun s hs => GenerateMeasurable.basic (f ⁻¹' s) (hs.preimage hf) /-- A space with `MeasurableSpace` and `TopologicalSpace` structures such that all open sets are measurable. -/ class OpensMeasurableSpace (α : Type*) [TopologicalSpace α] [h : MeasurableSpace α] : Prop where /-- Borel-measurable sets are measurable. -/ borel_le : borel α ≤ h /-- A space with `MeasurableSpace` and `TopologicalSpace` structures such that the `σ`-algebra of measurable sets is exactly the `σ`-algebra generated by open sets. -/ class BorelSpace (α : Type*) [TopologicalSpace α] [MeasurableSpace α] : Prop where /-- The measurable sets are exactly the Borel-measurable sets. -/ measurable_eq : ‹MeasurableSpace α› = borel α namespace Mathlib.Tactic.Borelize open Lean Elab Term Tactic Meta /-- The behaviour of `borelize α` depends on the existing assumptions on `α`. - if `α` is a topological space with instances `[MeasurableSpace α] [BorelSpace α]`, then `borelize α` replaces the former instance by `borel α`; - otherwise, `borelize α` adds instances `borel α : MeasurableSpace α` and `⟨rfl⟩ : BorelSpace α`. Finally, `borelize α β γ` runs `borelize α; borelize β; borelize γ`. -/ syntax "borelize" (ppSpace colGt term:max)* : tactic /-- Add instances `borel e : MeasurableSpace e` and `⟨rfl⟩ : BorelSpace e`. -/ def addBorelInstance (e : Expr) : TacticM Unit := do let t ← Lean.Elab.Term.exprToSyntax e evalTactic <| ← `(tactic| refine_lift letI : MeasurableSpace $t := borel $t haveI : BorelSpace $t := ⟨rfl⟩ ?_) /-- Given a type `e`, an assumption `i : MeasurableSpace e`, and an instance `[BorelSpace e]`, replace `i` with `borel e`. -/ def borelToRefl (e : Expr) (i : FVarId) : TacticM Unit := do let te ← Lean.Elab.Term.exprToSyntax e evalTactic <| ← `(tactic| have := @BorelSpace.measurable_eq $te _ _ _) try liftMetaTactic fun m => return [← subst m i] catch _ => let et ← synthInstance (← mkAppOptM ``TopologicalSpace #[e]) throwError m!"\ `‹TopologicalSpace {e}› := {et}\n\ depends on\n\ {Expr.fvar i} : MeasurableSpace {e}`\n\ so `borelize` isn't available" evalTactic <| ← `(tactic| refine_lift letI : MeasurableSpace $te := borel $te ?_) /-- Given a type `$t`, if there is an assumption `[i : MeasurableSpace $t]`, then try to prove `[BorelSpace $t]` and replace `i` with `borel $t`. Otherwise, add instances `borel $t : MeasurableSpace $t` and `⟨rfl⟩ : BorelSpace $t`. -/ def borelize (t : Term) : TacticM Unit := withMainContext <| do let u ← mkFreshLevelMVar let e ← withoutRecover <| Tactic.elabTermEnsuringType t (mkSort (mkLevelSucc u)) let i? ← findLocalDeclWithType? (← mkAppOptM ``MeasurableSpace #[e]) i?.elim (addBorelInstance e) (borelToRefl e) elab_rules : tactic | `(tactic| borelize $[$t:term]*) => t.forM borelize end Mathlib.Tactic.Borelize instance (priority := 100) OrderDual.opensMeasurableSpace {α : Type*} [TopologicalSpace α] [MeasurableSpace α] [h : OpensMeasurableSpace α] : OpensMeasurableSpace αᵒᵈ where borel_le := h.borel_le instance (priority := 100) OrderDual.borelSpace {α : Type*} [TopologicalSpace α] [MeasurableSpace α] [h : BorelSpace α] : BorelSpace αᵒᵈ where measurable_eq := h.measurable_eq /-- In a `BorelSpace` all open sets are measurable. -/ instance (priority := 100) BorelSpace.opensMeasurable {α : Type*} [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] : OpensMeasurableSpace α := ⟨ge_of_eq <| BorelSpace.measurable_eq⟩ instance Subtype.borelSpace {α : Type*} [TopologicalSpace α] [MeasurableSpace α] [hα : BorelSpace α] (p : α → Prop) : BorelSpace (Subtype p) := ⟨by borelize α; symm; apply borel_comap⟩ instance Countable.instBorelSpace [Countable α] [MeasurableSpace α] [MeasurableSingletonClass α] [TopologicalSpace α] [DiscreteTopology α] : BorelSpace α := by have : ∀ s, @MeasurableSet α inferInstance s := fun s ↦ s.to_countable.measurableSet have : ∀ s, @MeasurableSet α (borel α) s := fun s ↦ measurableSet_generateFrom (isOpen_discrete s) exact ⟨by aesop⟩ instance Subtype.opensMeasurableSpace {α : Type*} [TopologicalSpace α] [MeasurableSpace α] [h : OpensMeasurableSpace α] (p : α → Prop) : OpensMeasurableSpace (Subtype p) := ⟨by rw [borel_comap] exact comap_mono h.1⟩ lemma opensMeasurableSpace_iff_forall_measurableSet [TopologicalSpace α] [MeasurableSpace α] : OpensMeasurableSpace α ↔ (∀ (s : Set α), IsOpen s → MeasurableSet s) := by refine ⟨fun h s hs ↦ ?_, fun h ↦ ⟨generateFrom_le h⟩⟩ exact OpensMeasurableSpace.borel_le _ <| GenerateMeasurable.basic _ hs instance (priority := 100) BorelSpace.countablyGenerated {α : Type*} [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] [SecondCountableTopology α] : CountablyGenerated α := by obtain ⟨b, bct, -, hb⟩ := exists_countable_basis α refine ⟨⟨b, bct, ?_⟩⟩ borelize α exact hb.borel_eq_generateFrom section variable [TopologicalSpace α] [MeasurableSpace α] [OpensMeasurableSpace α] [TopologicalSpace β] [MeasurableSpace β] [OpensMeasurableSpace β] [TopologicalSpace γ] [MeasurableSpace γ] [BorelSpace γ] [TopologicalSpace γ₂] [MeasurableSpace γ₂] [BorelSpace γ₂] [MeasurableSpace δ] theorem IsOpen.measurableSet (h : IsOpen s) : MeasurableSet s := OpensMeasurableSpace.borel_le _ <| GenerateMeasurable.basic _ h theorem IsOpen.nullMeasurableSet {μ} (h : IsOpen s) : NullMeasurableSet s μ := h.measurableSet.nullMeasurableSet open scoped Function in -- required for scoped `on` notation @[elab_as_elim] theorem MeasurableSet.induction_on_open {C : ∀ s : Set γ, MeasurableSet s → Prop} (isOpen : ∀ U (hU : IsOpen U), C U hU.measurableSet) (compl : ∀ t (ht : MeasurableSet t), C t ht → C tᶜ ht.compl) (iUnion : ∀ f : ℕ → Set γ, Pairwise (Disjoint on f) → ∀ (hf : ∀ i, MeasurableSet (f i)), (∀ i, C (f i) (hf i)) → C (⋃ i, f i) (.iUnion hf)) : ∀ t (ht : MeasurableSet t), C t ht := fun t ht ↦ MeasurableSpace.induction_on_inter BorelSpace.measurable_eq isPiSystem_isOpen (isOpen _ isOpen_empty) isOpen compl iUnion t ht instance (priority := 1000) {s : Set α} [h : HasCountableSeparatingOn α IsOpen s] : CountablySeparated s := by rw [CountablySeparated.subtype_iff] exact .mono (fun _ ↦ IsOpen.measurableSet) Subset.rfl @[measurability] theorem measurableSet_interior : MeasurableSet (interior s) := isOpen_interior.measurableSet theorem IsGδ.measurableSet (h : IsGδ s) : MeasurableSet s := by rcases h with ⟨S, hSo, hSc, rfl⟩ exact MeasurableSet.sInter hSc fun t ht => (hSo t ht).measurableSet theorem measurableSet_of_continuousAt {β} [PseudoEMetricSpace β] (f : α → β) : MeasurableSet { x | ContinuousAt f x } := (IsGδ.setOf_continuousAt f).measurableSet theorem IsClosed.measurableSet (h : IsClosed s) : MeasurableSet s := h.isOpen_compl.measurableSet.of_compl theorem IsClosed.nullMeasurableSet {μ} (h : IsClosed s) : NullMeasurableSet s μ := h.measurableSet.nullMeasurableSet theorem IsCompact.measurableSet [T2Space α] (h : IsCompact s) : MeasurableSet s := h.isClosed.measurableSet theorem IsCompact.nullMeasurableSet [T2Space α] {μ} (h : IsCompact s) : NullMeasurableSet s μ := h.isClosed.nullMeasurableSet /-- If two points are topologically inseparable, then they can't be separated by a Borel measurable set. -/ theorem Inseparable.mem_measurableSet_iff {x y : γ} (h : Inseparable x y) {s : Set γ} (hs : MeasurableSet s) : x ∈ s ↔ y ∈ s := MeasurableSet.induction_on_open (fun _ ↦ h.mem_open_iff) (fun _ _ ↦ Iff.not) (fun _ _ _ h ↦ by simp [h]) s hs /-- If `K` is a compact set in an R₁ space and `s ⊇ K` is a Borel measurable superset, then `s` includes the closure of `K` as well. -/ theorem IsCompact.closure_subset_measurableSet [R1Space γ] {K s : Set γ} (hK : IsCompact K) (hs : MeasurableSet s) (hKs : K ⊆ s) : closure K ⊆ s := by rw [hK.closure_eq_biUnion_inseparable, iUnion₂_subset_iff] exact fun x hx y hy ↦ (hy.mem_measurableSet_iff hs).1 (hKs hx) /-- In an R₁ topological space with Borel measure `μ`, the measure of the closure of a compact set `K` is equal to the measure of `K`. See also `MeasureTheory.Measure.OuterRegular.measure_closure_eq_of_isCompact` for a version that assumes `μ` to be outer regular but does not assume the `σ`-algebra to be Borel. -/ theorem IsCompact.measure_closure [R1Space γ] {K : Set γ} (hK : IsCompact K) (μ : Measure γ) : μ (closure K) = μ K := by refine le_antisymm ?_ (measure_mono subset_closure) calc μ (closure K) ≤ μ (toMeasurable μ K) := measure_mono <| hK.closure_subset_measurableSet (measurableSet_toMeasurable ..) (subset_toMeasurable ..) _ = μ K := measure_toMeasurable .. @[measurability] theorem measurableSet_closure : MeasurableSet (closure s) := isClosed_closure.measurableSet @[measurability] theorem measurableSet_frontier : MeasurableSet (frontier s) := measurableSet_closure.diff measurableSet_interior theorem measurable_of_isOpen {f : δ → γ} (hf : ∀ s, IsOpen s → MeasurableSet (f ⁻¹' s)) : Measurable f := by rw [‹BorelSpace γ›.measurable_eq] exact measurable_generateFrom hf theorem measurable_of_isClosed {f : δ → γ} (hf : ∀ s, IsClosed s → MeasurableSet (f ⁻¹' s)) : Measurable f := by apply measurable_of_isOpen; intro s hs rw [← MeasurableSet.compl_iff, ← preimage_compl]; apply hf; rw [isClosed_compl_iff]; exact hs theorem measurable_of_isClosed' {f : δ → γ} (hf : ∀ s, IsClosed s → s.Nonempty → s ≠ univ → MeasurableSet (f ⁻¹' s)) : Measurable f := by apply measurable_of_isClosed; intro s hs rcases eq_empty_or_nonempty s with h1 | h1 · simp [h1] by_cases h2 : s = univ · simp [h2] exact hf s hs h1 h2 instance nhds_isMeasurablyGenerated (a : α) : (𝓝 a).IsMeasurablyGenerated := by rw [nhds, iInf_subtype'] refine @Filter.iInf_isMeasurablyGenerated α _ _ _ fun i => ?_ exact i.2.2.measurableSet.principal_isMeasurablyGenerated /-- If `s` is a measurable set, then `𝓝[s] a` is a measurably generated filter for each `a`. This cannot be an `instance` because it depends on a non-instance `hs : MeasurableSet s`. -/ theorem MeasurableSet.nhdsWithin_isMeasurablyGenerated {s : Set α} (hs : MeasurableSet s) (a : α) : (𝓝[s] a).IsMeasurablyGenerated := haveI := hs.principal_isMeasurablyGenerated Filter.inf_isMeasurablyGenerated _ _ instance (priority := 100) OpensMeasurableSpace.separatesPoints [T0Space α] : SeparatesPoints α := by rw [separatesPoints_iff] intro x y hxy apply Inseparable.eq rw [inseparable_iff_forall_isOpen] exact fun s hs => hxy _ hs.measurableSet theorem borel_eq_top_of_countable {α : Type*} [TopologicalSpace α] [T0Space α] [Countable α] : borel α = ⊤ := by refine top_unique fun s _ ↦ ?_ borelize α exact .of_discrete -- see Note [lower instance priority] instance (priority := 100) OpensMeasurableSpace.toMeasurableSingletonClass [T1Space α] : MeasurableSingletonClass α := ⟨fun _ => isClosed_singleton.measurableSet⟩ instance Pi.opensMeasurableSpace {ι : Type*} {X : ι → Type*} [Countable ι] [t' : ∀ i, TopologicalSpace (X i)] [∀ i, MeasurableSpace (X i)] [∀ i, SecondCountableTopology (X i)] [∀ i, OpensMeasurableSpace (X i)] : OpensMeasurableSpace (∀ i, X i) := by constructor have : Pi.topologicalSpace = .generateFrom { t | ∃ (s : ∀ a, Set (X a)) (i : Finset ι), (∀ a ∈ i, s a ∈ countableBasis (X a)) ∧ t = pi (↑i) s } := by simp only [funext fun a => @eq_generateFrom_countableBasis (X a) _ _, pi_generateFrom_eq] rw [borel_eq_generateFrom_of_subbasis this] apply generateFrom_le rintro _ ⟨s, i, hi, rfl⟩ refine MeasurableSet.pi i.countable_toSet fun a ha => IsOpen.measurableSet ?_ rw [eq_generateFrom_countableBasis (X a)] exact .basic _ (hi a ha) /-- The typeclass `SecondCountableTopologyEither α β` registers the fact that at least one of the two spaces has second countable topology. This is the right assumption to ensure that continuous maps from `α` to `β` are strongly measurable. -/ class SecondCountableTopologyEither (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] : Prop where /-- The projection out of `SecondCountableTopologyEither` -/ out : SecondCountableTopology α ∨ SecondCountableTopology β instance (priority := 100) secondCountableTopologyEither_of_left (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] [SecondCountableTopology α] : SecondCountableTopologyEither α β where out := Or.inl (by infer_instance) instance (priority := 100) secondCountableTopologyEither_of_right (α β : Type*) [TopologicalSpace α] [TopologicalSpace β] [SecondCountableTopology β] : SecondCountableTopologyEither α β where out := Or.inr (by infer_instance) /-- If either `α` or `β` has second-countable topology, then the open sets in `α × β` belong to the product sigma-algebra. -/ instance Prod.opensMeasurableSpace [h : SecondCountableTopologyEither α β] : OpensMeasurableSpace (α × β) := by apply opensMeasurableSpace_iff_forall_measurableSet.2 (fun s hs ↦ ?_) rcases h.out with hα|hβ · let F : Set α → Set β := fun a ↦ {y | ∃ b, IsOpen b ∧ y ∈ b ∧ a ×ˢ b ⊆ s} have A : ∀ a, IsOpen (F a) := by intro a apply isOpen_iff_forall_mem_open.2 rintro y ⟨b, b_open, yb, hb⟩ exact ⟨b, fun z zb ↦ ⟨b, b_open, zb, hb⟩, b_open, yb⟩ have : s = ⋃ a ∈ countableBasis α, a ×ˢ F a := by apply Subset.antisymm · rintro ⟨y1, y2⟩ hy rcases isOpen_prod_iff.1 hs y1 y2 hy with ⟨u, v, u_open, v_open, yu, yv, huv⟩ obtain ⟨a, ha, ya, au⟩ : ∃ a ∈ countableBasis α, y1 ∈ a ∧ a ⊆ u := IsTopologicalBasis.exists_subset_of_mem_open (isBasis_countableBasis α) yu u_open simp only [mem_iUnion, mem_prod, exists_and_left, exists_prop] exact ⟨a, ya, ha, v, v_open, yv, (Set.prod_mono_left au).trans huv⟩ · rintro ⟨y1, y2⟩ hy simp only [mem_iUnion, mem_prod, exists_and_left, exists_prop] at hy rcases hy with ⟨a, ya, -, b, -, yb, hb⟩ exact hb (mem_prod.2 ⟨ya, yb⟩) rw [this] apply MeasurableSet.biUnion (countable_countableBasis α) (fun a ha ↦ ?_) exact (isOpen_of_mem_countableBasis ha).measurableSet.prod (A a).measurableSet · let F : Set β → Set α := fun a ↦ {y | ∃ b, IsOpen b ∧ y ∈ b ∧ b ×ˢ a ⊆ s} have A : ∀ a, IsOpen (F a) := by intro a apply isOpen_iff_forall_mem_open.2 rintro y ⟨b, b_open, yb, hb⟩ exact ⟨b, fun z zb ↦ ⟨b, b_open, zb, hb⟩, b_open, yb⟩ have : s = ⋃ a ∈ countableBasis β, F a ×ˢ a := by apply Subset.antisymm · rintro ⟨y1, y2⟩ hy rcases isOpen_prod_iff.1 hs y1 y2 hy with ⟨u, v, u_open, v_open, yu, yv, huv⟩ obtain ⟨a, ha, ya, au⟩ : ∃ a ∈ countableBasis β, y2 ∈ a ∧ a ⊆ v := IsTopologicalBasis.exists_subset_of_mem_open (isBasis_countableBasis β) yv v_open simp only [mem_iUnion, mem_prod, exists_and_left, exists_prop] exact ⟨a, ⟨u, u_open, yu, (Set.prod_mono_right au).trans huv⟩, ha, ya⟩ · rintro ⟨y1, y2⟩ hy simp only [mem_iUnion, mem_prod, exists_and_left, exists_prop] at hy rcases hy with ⟨a, ⟨b, -, yb, hb⟩, -, ya⟩ exact hb (mem_prod.2 ⟨yb, ya⟩) rw [this] apply MeasurableSet.biUnion (countable_countableBasis β) (fun a ha ↦ ?_) exact (A a).measurableSet.prod (isOpen_of_mem_countableBasis ha).measurableSet variable {α' : Type*} [TopologicalSpace α'] [MeasurableSpace α'] theorem interior_ae_eq_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) : interior s =ᵐ[μ] s := interior_subset.eventuallyLE.antisymm <| subset_closure.eventuallyLE.trans (ae_le_set.2 h) theorem measure_interior_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) : μ (interior s) = μ s := measure_congr (interior_ae_eq_of_null_frontier h) theorem nullMeasurableSet_of_null_frontier {s : Set α} {μ : Measure α} (h : μ (frontier s) = 0) : NullMeasurableSet s μ := ⟨interior s, isOpen_interior.measurableSet, (interior_ae_eq_of_null_frontier h).symm⟩ theorem closure_ae_eq_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) : closure s =ᵐ[μ] s := ((ae_le_set.2 h).trans interior_subset.eventuallyLE).antisymm <| subset_closure.eventuallyLE theorem measure_closure_of_null_frontier {μ : Measure α'} {s : Set α'} (h : μ (frontier s) = 0) : μ (closure s) = μ s := measure_congr (closure_ae_eq_of_null_frontier h) theorem null_frontier_inter {μ : Measure α'} {s s' : Set α'} (h : μ (frontier s) = 0) (h' : μ (frontier s') = 0) : μ (frontier (s ∩ s')) = 0 := by apply bot_unique calc μ (frontier (s ∩ s')) _ ≤ μ (frontier s ∪ frontier s') := measure_mono <| (frontier_inter_subset _ _).trans (by grind) _ ≤ μ (frontier s) + μ (frontier s') := measure_union_le _ _ _ = 0 := by simp [h, h'] instance separatesPointsOfOpensMeasurableSpaceOfT0Space [T0Space α] : MeasurableSpace.SeparatesPoints α where separates x y := by contrapose! exact fun a => exists_measurableSet_of_ne a /-- A continuous function from an `OpensMeasurableSpace` to a `BorelSpace` is measurable. -/ @[fun_prop] theorem Continuous.measurable {f : α → γ} (hf : Continuous f) : Measurable f := hf.borel_measurable.mono OpensMeasurableSpace.borel_le (le_of_eq <| BorelSpace.measurable_eq) /-- A continuous function from an `OpensMeasurableSpace` to a `BorelSpace` is ae-measurable. -/ @[fun_prop] theorem Continuous.aemeasurable {f : α → γ} (h : Continuous f) {μ : Measure α} : AEMeasurable f μ := h.measurable.aemeasurable theorem IsClosedEmbedding.measurable {f : α → γ} (hf : IsClosedEmbedding f) : Measurable f := hf.continuous.measurable /-- If a function is defined piecewise in terms of functions which are continuous on their respective pieces, then it is measurable. -/ theorem ContinuousOn.measurable_piecewise {f g : α → γ} {s : Set α} [∀ j : α, Decidable (j ∈ s)] (hf : ContinuousOn f s) (hg : ContinuousOn g sᶜ) (hs : MeasurableSet s) : Measurable (s.piecewise f g) := by refine measurable_of_isOpen fun t ht => ?_ rw [piecewise_preimage, Set.ite] apply MeasurableSet.union · rcases _root_.continuousOn_iff'.1 hf t ht with ⟨u, u_open, hu⟩ rw [hu] exact u_open.measurableSet.inter hs · rcases _root_.continuousOn_iff'.1 hg t ht with ⟨u, u_open, hu⟩ rw [diff_eq_compl_inter, inter_comm, hu] exact u_open.measurableSet.inter hs.compl @[to_additive] instance (priority := 100) ContinuousMul.measurableMul [Mul γ] [ContinuousMul γ] : MeasurableMul γ where measurable_const_mul _ := (continuous_const.mul continuous_id).measurable measurable_mul_const _ := (continuous_id.mul continuous_const).measurable instance (priority := 100) ContinuousSub.measurableSub [Sub γ] [ContinuousSub γ] : MeasurableSub γ where measurable_const_sub _ := (continuous_const.sub continuous_id).measurable measurable_sub_const _ := (continuous_id.sub continuous_const).measurable @[to_additive] instance (priority := 100) ContinuousInv.measurableInv [Inv γ] [ContinuousInv γ] : MeasurableInv γ := ⟨continuous_inv.measurable⟩ @[to_additive] instance (priority := 100) ContinuousConstSMul.toMeasurableConstSMul {M α} [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] [SMul M α] [ContinuousConstSMul M α] : MeasurableConstSMul M α where measurable_const_smul _ := (continuous_const_smul _).measurable @[to_additive] instance (priority := 100) ContinuousSMul.toMeasurableSMul {M α} [TopologicalSpace M] [TopologicalSpace α] [MeasurableSpace M] [MeasurableSpace α] [OpensMeasurableSpace M] [BorelSpace α] [SMul M α] [ContinuousSMul M α] : MeasurableSMul M α where measurable_smul_const _ := (continuous_id.smul continuous_const).measurable section Homeomorph @[measurability] protected theorem Homeomorph.measurable (h : α ≃ₜ γ) : Measurable h := h.continuous.measurable /-- A homeomorphism between two Borel spaces is a measurable equivalence. -/ def Homeomorph.toMeasurableEquiv (h : γ ≃ₜ γ₂) : γ ≃ᵐ γ₂ where measurable_toFun := h.measurable measurable_invFun := h.symm.measurable toEquiv := h.toEquiv lemma Homeomorph.measurableEmbedding (h : γ ≃ₜ γ₂) : MeasurableEmbedding h := h.toMeasurableEquiv.measurableEmbedding @[simp] theorem Homeomorph.toMeasurableEquiv_coe (h : γ ≃ₜ γ₂) : (h.toMeasurableEquiv : γ → γ₂) = h := rfl @[simp] theorem Homeomorph.toMeasurableEquiv_symm_coe (h : γ ≃ₜ γ₂) : (h.toMeasurableEquiv.symm : γ₂ → γ) = h.symm := rfl end Homeomorph @[measurability] theorem ContinuousMap.measurable (f : C(α, γ)) : Measurable f := f.continuous.measurable @[fun_prop] theorem measurable_of_continuousOn_compl_singleton [T1Space α] {f : α → γ} (a : α) (hf : ContinuousOn f {a}ᶜ) : Measurable f := measurable_of_measurable_on_compl_singleton a (continuousOn_iff_continuous_restrict.1 hf).measurable theorem Continuous.measurable2 [SecondCountableTopologyEither α β] {f : δ → α} {g : δ → β} {c : α → β → γ} (h : Continuous fun p : α × β => c p.1 p.2) (hf : Measurable f) (hg : Measurable g) : Measurable fun a => c (f a) (g a) := h.measurable.comp (hf.prodMk hg) theorem Continuous.aemeasurable2 [SecondCountableTopologyEither α β] {f : δ → α} {g : δ → β} {c : α → β → γ} {μ : Measure δ} (h : Continuous fun p : α × β => c p.1 p.2) (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun a => c (f a) (g a)) μ := h.measurable.comp_aemeasurable (hf.prodMk hg) instance (priority := 100) ContinuousInv₀.measurableInv [GroupWithZero γ] [T1Space γ] [ContinuousInv₀ γ] : MeasurableInv γ := ⟨measurable_of_continuousOn_compl_singleton 0 continuousOn_inv₀⟩ @[deprecated (since := "2025-09-01")] alias HasContinuousInv₀.measurableInv := ContinuousInv₀.measurableInv @[to_additive] instance (priority := 100) ContinuousMul.measurableMul₂ [SecondCountableTopology γ] [Mul γ] [ContinuousMul γ] : MeasurableMul₂ γ := ⟨continuous_mul.measurable⟩ instance (priority := 100) ContinuousSub.measurableSub₂ [SecondCountableTopology γ] [Sub γ] [ContinuousSub γ] : MeasurableSub₂ γ := ⟨continuous_sub.measurable⟩ instance (priority := 100) ContinuousSMul.measurableSMul₂ {M α} [TopologicalSpace M] [MeasurableSpace M] [OpensMeasurableSpace M] [TopologicalSpace α] [SecondCountableTopologyEither M α] [MeasurableSpace α] [BorelSpace α] [SMul M α] [ContinuousSMul M α] : MeasurableSMul₂ M α := ⟨continuous_smul.measurable⟩ end section BorelSpace variable [TopologicalSpace α] [mα : MeasurableSpace α] [BorelSpace α] [mβ : TopologicalSpace β] [MeasurableSpace β] [BorelSpace β] [TopologicalSpace γ] [MeasurableSpace γ] [BorelSpace γ] [MeasurableSpace δ] theorem pi_le_borel_pi {ι : Type*} {X : ι → Type*} [∀ i, TopologicalSpace (X i)] [∀ i, MeasurableSpace (X i)] [∀ i, BorelSpace (X i)] : MeasurableSpace.pi ≤ borel (∀ i, X i) := by have : ‹∀ i, MeasurableSpace (X i)› = fun i => borel (X i) := funext fun i => BorelSpace.measurable_eq rw [this] exact iSup_le fun i => comap_le_iff_le_map.2 <| (continuous_apply i).borel_measurable theorem prod_le_borel_prod : Prod.instMeasurableSpace ≤ borel (α × β) := by rw [‹BorelSpace α›.measurable_eq, ‹BorelSpace β›.measurable_eq] refine sup_le ?_ ?_ · exact comap_le_iff_le_map.mpr continuous_fst.borel_measurable · exact comap_le_iff_le_map.mpr continuous_snd.borel_measurable instance Pi.borelSpace {ι : Type*} {X : ι → Type*} [Countable ι] [∀ i, TopologicalSpace (X i)] [∀ i, MeasurableSpace (X i)] [∀ i, SecondCountableTopology (X i)] [∀ i, BorelSpace (X i)] : BorelSpace (∀ i, X i) := ⟨le_antisymm pi_le_borel_pi OpensMeasurableSpace.borel_le⟩ instance Prod.borelSpace [SecondCountableTopologyEither α β] : BorelSpace (α × β) := ⟨le_antisymm prod_le_borel_prod OpensMeasurableSpace.borel_le⟩ /-- Given a measurable embedding to a Borel space which is also a topological embedding, then the source space is also a Borel space. -/ lemma MeasurableEmbedding.borelSpace {α β : Type*} [MeasurableSpace α] [TopologicalSpace α] [MeasurableSpace β] [TopologicalSpace β] [hβ : BorelSpace β] {e : α → β} (h'e : MeasurableEmbedding e) (h''e : IsInducing e) : BorelSpace α := by constructor have : MeasurableSpace.comap e (borel β) = ‹_› := by simpa [hβ.measurable_eq] using h'e.comap_eq rw [← this, ← borel_comap, h''e.eq_induced] instance _root_.ULift.instBorelSpace : BorelSpace (ULift α) := MeasurableEquiv.ulift.measurableEmbedding.borelSpace Homeomorph.ulift.isInducing instance DiscreteMeasurableSpace.toBorelSpace {α : Type*} [TopologicalSpace α] [DiscreteTopology α] [MeasurableSpace α] [DiscreteMeasurableSpace α] : BorelSpace α := by constructor; ext; simp [MeasurableSpace.measurableSet_generateFrom, MeasurableSet.of_discrete] protected theorem Topology.IsEmbedding.measurableEmbedding {f : α → β} (h₁ : IsEmbedding f) (h₂ : MeasurableSet (range f)) : MeasurableEmbedding f := show MeasurableEmbedding (((↑) : range f → β) ∘ h₁.toHomeomorph.toMeasurableEquiv) from (MeasurableEmbedding.subtype_coe h₂).comp (MeasurableEquiv.measurableEmbedding _) protected theorem Topology.IsClosedEmbedding.measurableEmbedding {f : α → β} (h : IsClosedEmbedding f) : MeasurableEmbedding f := h.isEmbedding.measurableEmbedding h.isClosed_range.measurableSet protected theorem Topology.IsOpenEmbedding.measurableEmbedding {f : α → β} (h : IsOpenEmbedding f) : MeasurableEmbedding f := h.isEmbedding.measurableEmbedding h.isOpen_range.measurableSet instance Empty.borelSpace : BorelSpace Empty := ⟨borel_eq_top_of_discrete.symm⟩ instance Unit.borelSpace : BorelSpace Unit := ⟨borel_eq_top_of_discrete.symm⟩ instance Bool.borelSpace : BorelSpace Bool := ⟨borel_eq_top_of_discrete.symm⟩ instance Nat.borelSpace : BorelSpace ℕ := ⟨borel_eq_top_of_discrete.symm⟩ instance Int.borelSpace : BorelSpace ℤ := ⟨borel_eq_top_of_discrete.symm⟩ instance Rat.borelSpace : BorelSpace ℚ := ⟨borel_eq_top_of_countable.symm⟩ /- Instances on `Real` and `Complex` are special cases of `RCLike` but without these instances, Lean fails to prove `BorelSpace (ι → ℝ)`, so we leave them here. -/ instance Real.measurableSpace : MeasurableSpace ℝ := borel ℝ instance Real.borelSpace : BorelSpace ℝ := ⟨rfl⟩ instance NNReal.measurableSpace : MeasurableSpace ℝ≥0 := Subtype.instMeasurableSpace instance NNReal.borelSpace : BorelSpace ℝ≥0 := Subtype.borelSpace _ instance ENNReal.measurableSpace : MeasurableSpace ℝ≥0∞ := borel ℝ≥0∞ instance ENNReal.borelSpace : BorelSpace ℝ≥0∞ := ⟨rfl⟩ instance EReal.measurableSpace : MeasurableSpace EReal := borel EReal instance EReal.borelSpace : BorelSpace EReal := ⟨rfl⟩ namespace MeasureTheory.Measure.IsFiniteMeasureOnCompacts variable {mα} in protected theorem map (μ : Measure α) [IsFiniteMeasureOnCompacts μ] (f : α ≃ₜ β) : IsFiniteMeasureOnCompacts (μ.map f) := by refine ⟨fun K hK ↦ ?_⟩ rw [← f.toMeasurableEquiv_coe, MeasurableEquiv.map_apply] exact IsCompact.measure_lt_top (f.isCompact_preimage.2 hK) variable {mβ} in protected theorem comap (μ : Measure β) [IsFiniteMeasureOnCompacts μ] (f : α ≃ₜ β) : IsFiniteMeasureOnCompacts (μ.comap f) := IsFiniteMeasureOnCompacts.comap' μ f.continuous f.measurableEmbedding end MeasureTheory.Measure.IsFiniteMeasureOnCompacts end BorelSpace
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Complex.lean
import Mathlib.Analysis.Complex.Basic import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic /-! # Equip `ℂ` with the Borel sigma-algebra -/ noncomputable section instance (priority := 900) RCLike.measurableSpace {𝕜 : Type*} [RCLike 𝕜] : MeasurableSpace 𝕜 := borel 𝕜 instance (priority := 900) RCLike.borelSpace {𝕜 : Type*} [RCLike 𝕜] : BorelSpace 𝕜 := ⟨rfl⟩ instance Complex.measurableSpace : MeasurableSpace ℂ := borel ℂ instance Complex.borelSpace : BorelSpace ℂ := ⟨rfl⟩
.lake/packages/mathlib/Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order import Mathlib.MeasureTheory.MeasurableSpace.Prod import Mathlib.MeasureTheory.Measure.Typeclasses.NoAtoms import Mathlib.Topology.Instances.Real.Lemmas /-! # Borel (measurable) spaces ℝ, ℝ≥0, ℝ≥0∞ ## Main statements * `borel_eq_generateFrom_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic): the Borel sigma algebra on ℝ is generated by intervals with rational endpoints; * `isPiSystem_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic): intervals with rational endpoints form a pi system on ℝ; * `measurable_real_toNNReal`, `measurable_coe_nnreal_real`, `measurable_coe_nnreal_ennreal`, `ENNReal.measurable_ofReal`, `ENNReal.measurable_toReal`: measurability of various coercions between ℝ, ℝ≥0, and ℝ≥0∞; * `Measurable.real_toNNReal`, `Measurable.coe_nnreal_real`, `Measurable.coe_nnreal_ennreal`, `Measurable.ennreal_ofReal`, `Measurable.ennreal_toNNReal`, `Measurable.ennreal_toReal`: measurability of functions composed with various coercions between ℝ, ℝ≥0, and ℝ≥0∞ (also similar results for a.e.-measurability); * `Measurable.ennreal*` : measurability of special cases for arithmetic operations on `ℝ≥0∞`. -/ open Set Filter MeasureTheory MeasurableSpace open scoped Topology NNReal ENNReal universe u v w x y variable {α β γ δ : Type*} {ι : Sort y} {s t u : Set α} namespace Real theorem borel_eq_generateFrom_Ioo_rat : borel ℝ = .generateFrom (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) (b : ℝ)}) := isTopologicalBasis_Ioo_rat.borel_eq_generateFrom theorem borel_eq_generateFrom_Iio_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Iio (a : ℝ)}) := by rw [borel_eq_generateFrom_Iio] refine le_antisymm (generateFrom_le ?_) (generateFrom_mono <| iUnion_subset fun q ↦ singleton_subset_iff.mpr <| mem_range_self _) rintro _ ⟨a, rfl⟩ have : IsLUB (range ((↑) : ℚ → ℝ) ∩ Iio a) a := by simp [isLUB_iff_le_iff, mem_upperBounds, ← le_iff_forall_rat_lt_imp_le] rw [← this.biUnion_Iio_eq, ← image_univ, ← image_inter_preimage, univ_inter, biUnion_image] exact MeasurableSet.biUnion (to_countable _) fun b _ => GenerateMeasurable.basic (Iio (b : ℝ)) (by simp) theorem borel_eq_generateFrom_Ioi_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Ioi (a : ℝ)}) := by rw [borel_eq_generateFrom_Ioi] refine le_antisymm (generateFrom_le ?_) (generateFrom_mono <| iUnion_subset fun q ↦ singleton_subset_iff.mpr <| mem_range_self _) rintro _ ⟨a, rfl⟩ have : IsGLB (range ((↑) : ℚ → ℝ) ∩ Ioi a) a := by simp [isGLB_iff_le_iff, mem_lowerBounds, ← le_iff_forall_lt_rat_imp_le] rw [← this.biUnion_Ioi_eq, ← image_univ, ← image_inter_preimage, univ_inter, biUnion_image] exact MeasurableSet.biUnion (to_countable _) fun b _ => GenerateMeasurable.basic (Ioi (b : ℝ)) (by simp) theorem borel_eq_generateFrom_Iic_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Iic (a : ℝ)}) := by rw [borel_eq_generateFrom_Ioi_rat, iUnion_singleton_eq_range, iUnion_singleton_eq_range] refine le_antisymm (generateFrom_le ?_) (generateFrom_le ?_) <;> rintro _ ⟨q, rfl⟩ <;> dsimp only <;> [rw [← compl_Iic]; rw [← compl_Ioi]] <;> exact MeasurableSet.compl (GenerateMeasurable.basic _ (mem_range_self q)) theorem borel_eq_generateFrom_Ici_rat : borel ℝ = .generateFrom (⋃ a : ℚ, {Ici (a : ℝ)}) := by rw [borel_eq_generateFrom_Iio_rat, iUnion_singleton_eq_range, iUnion_singleton_eq_range] refine le_antisymm (generateFrom_le ?_) (generateFrom_le ?_) <;> rintro _ ⟨q, rfl⟩ <;> dsimp only <;> [rw [← compl_Ici]; rw [← compl_Iio]] <;> exact MeasurableSet.compl (GenerateMeasurable.basic _ (mem_range_self q)) theorem isPiSystem_Ioo_rat : IsPiSystem (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) (b : ℝ)}) := by convert isPiSystem_Ioo ((↑) : ℚ → ℝ) ((↑) : ℚ → ℝ) ext x simp [eq_comm] theorem isPiSystem_Iio_rat : IsPiSystem (⋃ a : ℚ, {Iio (a : ℝ)}) := by convert isPiSystem_image_Iio (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] theorem isPiSystem_Ioi_rat : IsPiSystem (⋃ a : ℚ, {Ioi (a : ℝ)}) := by convert isPiSystem_image_Ioi (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] theorem isPiSystem_Iic_rat : IsPiSystem (⋃ a : ℚ, {Iic (a : ℝ)}) := by convert isPiSystem_image_Iic (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] theorem isPiSystem_Ici_rat : IsPiSystem (⋃ a : ℚ, {Ici (a : ℝ)}) := by convert isPiSystem_image_Ici (((↑) : ℚ → ℝ) '' univ) ext x simp only [iUnion_singleton_eq_range, mem_range, image_univ, mem_image, exists_exists_eq_and] /-- The intervals `(-(n + 1), (n + 1))` form a finite spanning sets in the set of open intervals with rational endpoints for a locally finite measure `μ` on `ℝ`. -/ def finiteSpanningSetsInIooRat (μ : Measure ℝ) [IsLocallyFiniteMeasure μ] : μ.FiniteSpanningSetsIn (⋃ (a : ℚ) (b : ℚ) (_ : a < b), {Ioo (a : ℝ) (b : ℝ)}) where set n := Ioo (-(n + 1)) (n + 1) set_mem n := by simp only [mem_iUnion, mem_singleton_iff] refine ⟨-(n + 1 : ℕ), n + 1, ?_, by simp⟩ -- TODO: norm_cast fails here? push_cast exact neg_lt_self n.cast_add_one_pos finite _ := measure_Ioo_lt_top spanning := iUnion_eq_univ_iff.2 fun x => ⟨⌊|x|⌋₊, neg_lt.1 ((neg_le_abs x).trans_lt (Nat.lt_floor_add_one _)), (le_abs_self x).trans_lt (Nat.lt_floor_add_one _)⟩ theorem measure_ext_Ioo_rat {μ ν : Measure ℝ} [IsLocallyFiniteMeasure μ] (h : ∀ a b : ℚ, μ (Ioo a b) = ν (Ioo a b)) : μ = ν := (finiteSpanningSetsInIooRat μ).ext borel_eq_generateFrom_Ioo_rat isPiSystem_Ioo_rat <| by simp only [mem_iUnion, mem_singleton_iff] rintro _ ⟨a, b, -, rfl⟩ apply h end Real variable {mα : MeasurableSpace α} @[measurability, fun_prop] theorem measurable_real_toNNReal : Measurable Real.toNNReal := continuous_real_toNNReal.measurable @[measurability, fun_prop] theorem Measurable.real_toNNReal {f : α → ℝ} (hf : Measurable f) : Measurable fun x => Real.toNNReal (f x) := measurable_real_toNNReal.comp hf @[measurability, fun_prop] theorem AEMeasurable.real_toNNReal {f : α → ℝ} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => Real.toNNReal (f x)) μ := measurable_real_toNNReal.comp_aemeasurable hf @[measurability] theorem measurable_coe_nnreal_real : Measurable ((↑) : ℝ≥0 → ℝ) := NNReal.continuous_coe.measurable @[measurability, fun_prop] theorem Measurable.coe_nnreal_real {f : α → ℝ≥0} (hf : Measurable f) : Measurable fun x => (f x : ℝ) := measurable_coe_nnreal_real.comp hf @[measurability, fun_prop] theorem AEMeasurable.coe_nnreal_real {f : α → ℝ≥0} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x : ℝ)) μ := measurable_coe_nnreal_real.comp_aemeasurable hf @[measurability] theorem measurable_coe_nnreal_ennreal : Measurable ((↑) : ℝ≥0 → ℝ≥0∞) := ENNReal.continuous_coe.measurable @[measurability, fun_prop] theorem Measurable.coe_nnreal_ennreal {f : α → ℝ≥0} (hf : Measurable f) : Measurable fun x => (f x : ℝ≥0∞) := ENNReal.continuous_coe.measurable.comp hf @[measurability, fun_prop] theorem AEMeasurable.coe_nnreal_ennreal {f : α → ℝ≥0} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x : ℝ≥0∞)) μ := ENNReal.continuous_coe.measurable.comp_aemeasurable hf @[measurability, fun_prop] theorem Measurable.ennreal_ofReal {f : α → ℝ} (hf : Measurable f) : Measurable fun x => ENNReal.ofReal (f x) := ENNReal.continuous_ofReal.measurable.comp hf @[measurability, fun_prop] lemma AEMeasurable.ennreal_ofReal {f : α → ℝ} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x ↦ ENNReal.ofReal (f x)) μ := ENNReal.continuous_ofReal.measurable.comp_aemeasurable hf @[simp, norm_cast] theorem measurable_coe_nnreal_real_iff {f : α → ℝ≥0} : Measurable (fun x => f x : α → ℝ) ↔ Measurable f := ⟨fun h => by simpa only [Real.toNNReal_coe] using h.real_toNNReal, Measurable.coe_nnreal_real⟩ @[simp, norm_cast] theorem aemeasurable_coe_nnreal_real_iff {f : α → ℝ≥0} {μ : Measure α} : AEMeasurable (fun x => f x : α → ℝ) μ ↔ AEMeasurable f μ := ⟨fun h ↦ by simpa only [Real.toNNReal_coe] using h.real_toNNReal, AEMeasurable.coe_nnreal_real⟩ /-- The set of finite `ℝ≥0∞` numbers is `MeasurableEquiv` to `ℝ≥0`. -/ def MeasurableEquiv.ennrealEquivNNReal : { r : ℝ≥0∞ | r ≠ ∞ } ≃ᵐ ℝ≥0 := ENNReal.neTopHomeomorphNNReal.toMeasurableEquiv namespace ENNReal theorem measurable_of_measurable_nnreal {f : ℝ≥0∞ → α} (h : Measurable fun p : ℝ≥0 => f p) : Measurable f := measurable_of_measurable_on_compl_singleton ∞ (MeasurableEquiv.ennrealEquivNNReal.symm.measurable_comp_iff.1 h) /-- `ℝ≥0∞` is `MeasurableEquiv` to `ℝ≥0 ⊕ Unit`. -/ def ennrealEquivSum : ℝ≥0∞ ≃ᵐ ℝ≥0 ⊕ Unit := { Equiv.optionEquivSumPUnit ℝ≥0 with measurable_toFun := measurable_of_measurable_nnreal measurable_inl measurable_invFun := measurable_fun_sum measurable_coe_nnreal_ennreal (@measurable_const ℝ≥0∞ Unit _ _ ∞) } open Function (uncurry) theorem measurable_of_measurable_nnreal_prod {_ : MeasurableSpace β} {_ : MeasurableSpace γ} {f : ℝ≥0∞ × β → γ} (H₁ : Measurable fun p : ℝ≥0 × β => f (p.1, p.2)) (H₂ : Measurable fun x => f (∞, x)) : Measurable f := let e : ℝ≥0∞ × β ≃ᵐ (ℝ≥0 × β) ⊕ (Unit × β) := (ennrealEquivSum.prodCongr (MeasurableEquiv.refl β)).trans (MeasurableEquiv.sumProdDistrib _ _ _) e.symm.measurable_comp_iff.1 <| measurable_fun_sum H₁ (H₂.comp measurable_id.snd) theorem measurable_of_measurable_nnreal_nnreal {_ : MeasurableSpace β} {f : ℝ≥0∞ × ℝ≥0∞ → β} (h₁ : Measurable fun p : ℝ≥0 × ℝ≥0 => f (p.1, p.2)) (h₂ : Measurable fun r : ℝ≥0 => f (∞, r)) (h₃ : Measurable fun r : ℝ≥0 => f (r, ∞)) : Measurable f := measurable_of_measurable_nnreal_prod (measurable_swap_iff.1 <| measurable_of_measurable_nnreal_prod (h₁.comp measurable_swap) h₃) (measurable_of_measurable_nnreal h₂) @[measurability] theorem measurable_ofReal : Measurable ENNReal.ofReal := ENNReal.continuous_ofReal.measurable @[measurability] theorem measurable_toReal : Measurable ENNReal.toReal := ENNReal.measurable_of_measurable_nnreal measurable_coe_nnreal_real @[measurability] theorem measurable_toNNReal : Measurable ENNReal.toNNReal := ENNReal.measurable_of_measurable_nnreal measurable_id instance instMeasurableMul₂ : MeasurableMul₂ ℝ≥0∞ := by refine ⟨measurable_of_measurable_nnreal_nnreal ?_ ?_ ?_⟩ · simp only [← ENNReal.coe_mul, measurable_mul.coe_nnreal_ennreal] · simp only [ENNReal.top_mul', ENNReal.coe_eq_zero] exact measurable_const.piecewise (measurableSet_singleton _) measurable_const · simp only [ENNReal.mul_top', ENNReal.coe_eq_zero] exact measurable_const.piecewise (measurableSet_singleton _) measurable_const instance instMeasurableSub₂ : MeasurableSub₂ ℝ≥0∞ := ⟨by apply measurable_of_measurable_nnreal_nnreal <;> simp [tsub_eq_zero_of_le]; exact continuous_sub.measurable.coe_nnreal_ennreal⟩ instance instMeasurableInv : MeasurableInv ℝ≥0∞ := ⟨continuous_inv.measurable⟩ instance : MeasurableSMul ℝ≥0 ℝ≥0∞ where measurable_const_smul _ := by simp_rw [ENNReal.smul_def]; exact measurable_const_smul _ measurable_smul_const _ := by simp_rw [ENNReal.smul_def] exact measurable_coe_nnreal_ennreal.mul_const _ /-- A limit (over a general filter) of measurable `ℝ≥0∞`-valued functions is measurable. -/ theorem measurable_of_tendsto' {ι : Type*} {f : ι → α → ℝ≥0∞} {g : α → ℝ≥0∞} (u : Filter ι) [NeBot u] [IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) : Measurable g := by rcases u.exists_seq_tendsto with ⟨x, hx⟩ rw [tendsto_pi_nhds] at lim have : (fun y => liminf (fun n => (f (x n) y : ℝ≥0∞)) atTop) = g := by ext1 y exact ((lim y).comp hx).liminf_eq rw [← this] change Measurable fun y => liminf (fun n => (f (x n) y : ℝ≥0∞)) atTop exact .liminf fun n => hf (x n) /-- A sequential limit of measurable `ℝ≥0∞`-valued functions is measurable. -/ theorem measurable_of_tendsto {f : ℕ → α → ℝ≥0∞} {g : α → ℝ≥0∞} (hf : ∀ i, Measurable (f i)) (lim : Tendsto f atTop (𝓝 g)) : Measurable g := measurable_of_tendsto' atTop hf lim /-- A limit (over a general filter) of a.e.-measurable `ℝ≥0∞`-valued functions is a.e.-measurable. -/ lemma aemeasurable_of_tendsto' {ι : Type*} {f : ι → α → ℝ≥0∞} {g : α → ℝ≥0∞} {μ : Measure α} (u : Filter ι) [NeBot u] [IsCountablyGenerated u] (hf : ∀ i, AEMeasurable (f i) μ) (hlim : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) u (𝓝 (g a))) : AEMeasurable g μ := by rcases u.exists_seq_tendsto with ⟨v, hv⟩ have h'f : ∀ n, AEMeasurable (f (v n)) μ := fun n ↦ hf (v n) set p : α → (ℕ → ℝ≥0∞) → Prop := fun x f' ↦ Tendsto f' atTop (𝓝 (g x)) have hp : ∀ᵐ x ∂μ, p x fun n ↦ f (v n) x := by filter_upwards [hlim] with x hx using hx.comp hv classical set aeSeqLim := fun x ↦ ite (x ∈ aeSeqSet h'f p) (g x) (⟨f (v 0) x⟩ : Nonempty ℝ≥0∞).some refine ⟨aeSeqLim, measurable_of_tendsto' atTop (aeSeq.measurable h'f p) (tendsto_pi_nhds.mpr fun x ↦ ?_), ?_⟩ · unfold aeSeqLim simp_rw [aeSeq] split_ifs with hx · simp_rw [aeSeq.mk_eq_fun_of_mem_aeSeqSet h'f hx] exact aeSeq.fun_prop_of_mem_aeSeqSet h'f hx · exact tendsto_const_nhds · exact (ite_ae_eq_of_measure_compl_zero g (fun x ↦ (⟨f (v 0) x⟩ : Nonempty ℝ≥0∞).some) (aeSeqSet h'f p) (aeSeq.measure_compl_aeSeqSet_eq_zero h'f hp)).symm /-- A limit of a.e.-measurable `ℝ≥0∞`-valued functions is a.e.-measurable. -/ lemma aemeasurable_of_tendsto {f : ℕ → α → ℝ≥0∞} {g : α → ℝ≥0∞} {μ : Measure α} (hf : ∀ i, AEMeasurable (f i) μ) (hlim : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) atTop (𝓝 (g a))) : AEMeasurable g μ := aemeasurable_of_tendsto' atTop hf hlim end ENNReal @[measurability, fun_prop] theorem Measurable.ennreal_toNNReal {f : α → ℝ≥0∞} (hf : Measurable f) : Measurable fun x => (f x).toNNReal := ENNReal.measurable_toNNReal.comp hf @[measurability, fun_prop] theorem AEMeasurable.ennreal_toNNReal {f : α → ℝ≥0∞} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x).toNNReal) μ := ENNReal.measurable_toNNReal.comp_aemeasurable hf @[simp, norm_cast] theorem measurable_coe_nnreal_ennreal_iff {f : α → ℝ≥0} : (Measurable fun x => (f x : ℝ≥0∞)) ↔ Measurable f := ⟨fun h => h.ennreal_toNNReal, fun h => h.coe_nnreal_ennreal⟩ @[simp, norm_cast] theorem aemeasurable_coe_nnreal_ennreal_iff {f : α → ℝ≥0} {μ : Measure α} : AEMeasurable (fun x => (f x : ℝ≥0∞)) μ ↔ AEMeasurable f μ := ⟨fun h => h.ennreal_toNNReal, fun h => h.coe_nnreal_ennreal⟩ @[measurability, fun_prop] theorem Measurable.ennreal_toReal {f : α → ℝ≥0∞} (hf : Measurable f) : Measurable fun x => ENNReal.toReal (f x) := ENNReal.measurable_toReal.comp hf @[measurability, fun_prop] theorem AEMeasurable.ennreal_toReal {f : α → ℝ≥0∞} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => ENNReal.toReal (f x)) μ := ENNReal.measurable_toReal.comp_aemeasurable hf /-- note: `ℝ≥0∞` can probably be generalized in a future version of this lemma. -/ @[measurability, fun_prop] theorem Measurable.ennreal_tsum {ι} [Countable ι] {f : ι → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) : Measurable fun x => ∑' i, f i x := by simp_rw [ENNReal.tsum_eq_iSup_sum] exact .iSup fun s ↦ s.measurable_fun_sum fun i _ => h i @[measurability, fun_prop] theorem Measurable.ennreal_tsum' {ι} [Countable ι] {f : ι → α → ℝ≥0∞} (h : ∀ i, Measurable (f i)) : Measurable (∑' i, f i) := by convert Measurable.ennreal_tsum h with x exact tsum_apply (Pi.summable.2 fun _ => ENNReal.summable) @[measurability, fun_prop] theorem Measurable.nnreal_tsum {ι} [Countable ι] {f : ι → α → ℝ≥0} (h : ∀ i, Measurable (f i)) : Measurable fun x => ∑' i, f i x := by simp_rw [NNReal.tsum_eq_toNNReal_tsum] exact (Measurable.ennreal_tsum fun i => (h i).coe_nnreal_ennreal).ennreal_toNNReal @[measurability, fun_prop] theorem AEMeasurable.ennreal_tsum {ι} [Countable ι] {f : ι → α → ℝ≥0∞} {μ : Measure α} (h : ∀ i, AEMeasurable (f i) μ) : AEMeasurable (fun x => ∑' i, f i x) μ := by simp_rw [ENNReal.tsum_eq_iSup_sum] exact .iSup fun s ↦ Finset.aemeasurable_fun_sum s fun i _ => h i @[measurability, fun_prop] theorem AEMeasurable.nnreal_tsum {α : Type*} {_ : MeasurableSpace α} {ι : Type*} [Countable ι] {f : ι → α → NNReal} {μ : Measure α} (h : ∀ i : ι, AEMeasurable (f i) μ) : AEMeasurable (fun x : α => ∑' i : ι, f i x) μ := by simp_rw [NNReal.tsum_eq_toNNReal_tsum] exact (AEMeasurable.ennreal_tsum fun i => (h i).coe_nnreal_ennreal).ennreal_toNNReal @[measurability, fun_prop] theorem measurable_coe_real_ereal : Measurable ((↑) : ℝ → EReal) := continuous_coe_real_ereal.measurable @[measurability] theorem Measurable.coe_real_ereal {f : α → ℝ} (hf : Measurable f) : Measurable fun x => (f x : EReal) := measurable_coe_real_ereal.comp hf @[measurability] theorem AEMeasurable.coe_real_ereal {f : α → ℝ} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x : EReal)) μ := measurable_coe_real_ereal.comp_aemeasurable hf /-- The set of finite `EReal` numbers is `MeasurableEquiv` to `ℝ`. -/ def MeasurableEquiv.erealEquivReal : ({⊥, ⊤}ᶜ : Set EReal) ≃ᵐ ℝ := EReal.neBotTopHomeomorphReal.toMeasurableEquiv theorem EReal.measurable_of_measurable_real {f : EReal → α} (h : Measurable fun p : ℝ => f p) : Measurable f := measurable_of_measurable_on_compl_finite {⊥, ⊤} (by simp) (MeasurableEquiv.erealEquivReal.symm.measurable_comp_iff.1 h) @[measurability] theorem measurable_ereal_toReal : Measurable EReal.toReal := EReal.measurable_of_measurable_real (by simpa using measurable_id) @[measurability, fun_prop] theorem Measurable.ereal_toReal {f : α → EReal} (hf : Measurable f) : Measurable fun x => (f x).toReal := measurable_ereal_toReal.comp hf @[measurability, fun_prop] theorem AEMeasurable.ereal_toReal {f : α → EReal} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x).toReal) μ := measurable_ereal_toReal.comp_aemeasurable hf @[measurability] theorem measurable_coe_ennreal_ereal : Measurable ((↑) : ℝ≥0∞ → EReal) := continuous_coe_ennreal_ereal.measurable @[measurability, fun_prop] theorem Measurable.coe_ereal_ennreal {f : α → ℝ≥0∞} (hf : Measurable f) : Measurable fun x => (f x : EReal) := measurable_coe_ennreal_ereal.comp hf @[measurability, fun_prop] theorem AEMeasurable.coe_ereal_ennreal {f : α → ℝ≥0∞} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x : EReal)) μ := measurable_coe_ennreal_ereal.comp_aemeasurable hf @[measurability] theorem measurable_ereal_toENNReal : Measurable EReal.toENNReal := EReal.measurable_of_measurable_real (by simpa using ENNReal.measurable_ofReal) @[measurability, fun_prop] theorem Measurable.ereal_toENNReal {f : α → EReal} (hf : Measurable f) : Measurable fun x => (f x).toENNReal := measurable_ereal_toENNReal.comp hf @[measurability, fun_prop] theorem AEMeasurable.ereal_toENNReal {f : α → EReal} {μ : Measure α} (hf : AEMeasurable f μ) : AEMeasurable (fun x => (f x).toENNReal) μ := measurable_ereal_toENNReal.comp_aemeasurable hf namespace NNReal instance : MeasurableSMul₂ ℝ≥0 ℝ≥0∞ where measurable_smul := show Measurable fun r : ℝ≥0 × ℝ≥0∞ ↦ (r.1 : ℝ≥0) * r.2 by fun_prop /-- A limit (over a general filter) of measurable `ℝ≥0`-valued functions is measurable. -/ theorem measurable_of_tendsto' {ι} {f : ι → α → ℝ≥0} {g : α → ℝ≥0} (u : Filter ι) [NeBot u] [IsCountablyGenerated u] (hf : ∀ i, Measurable (f i)) (lim : Tendsto f u (𝓝 g)) : Measurable g := by simp_rw [← measurable_coe_nnreal_ennreal_iff] at hf ⊢ refine ENNReal.measurable_of_tendsto' u hf ?_ rw [tendsto_pi_nhds] at lim ⊢ exact fun x => (ENNReal.continuous_coe.tendsto (g x)).comp (lim x) /-- A sequential limit of measurable `ℝ≥0`-valued functions is measurable. -/ theorem measurable_of_tendsto {f : ℕ → α → ℝ≥0} {g : α → ℝ≥0} (hf : ∀ i, Measurable (f i)) (lim : Tendsto f atTop (𝓝 g)) : Measurable g := measurable_of_tendsto' atTop hf lim end NNReal namespace EReal lemma measurableEmbedding_coe : MeasurableEmbedding Real.toEReal := isOpenEmbedding_coe.measurableEmbedding instance : MeasurableAdd₂ EReal := ⟨EReal.lowerSemicontinuous_add.measurable⟩ section MeasurableMul variable {α β γ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} lemma measurable_of_real_prod {f : EReal × β → γ} (h_real : Measurable fun p : ℝ × β ↦ f (p.1, p.2)) (h_bot : Measurable fun x ↦ f (⊥, x)) (h_top : Measurable fun x ↦ f (⊤, x)) : Measurable f := .of_union₃_range_cover (measurableEmbedding_prodMk_left _) (measurableEmbedding_prodMk_left _) (measurableEmbedding_coe.prodMap .id) (by simp [-univ_subset_iff, subset_def, EReal.forall]) h_bot h_top h_real lemma measurable_of_real_real {f : EReal × EReal → β} (h_real : Measurable fun p : ℝ × ℝ ↦ f (p.1, p.2)) (h_bot_left : Measurable fun r : ℝ ↦ f (⊥, r)) (h_top_left : Measurable fun r : ℝ ↦ f (⊤, r)) (h_bot_right : Measurable fun r : ℝ ↦ f (r, ⊥)) (h_top_right : Measurable fun r : ℝ ↦ f (r, ⊤)) : Measurable f := by refine measurable_of_real_prod ?_ ?_ ?_ · refine measurable_swap_iff.mp <| measurable_of_real_prod ?_ h_bot_right h_top_right exact h_real.comp measurable_swap · exact measurable_of_measurable_real h_bot_left · exact measurable_of_measurable_real h_top_left private lemma measurable_const_mul (c : EReal) : Measurable fun (x : EReal) ↦ c * x := by refine measurable_of_measurable_real ?_ have h1 : (fun (p : ℝ) ↦ (⊥ : EReal) * p) = fun p ↦ if p = 0 then (0 : EReal) else (if p < 0 then ⊤ else ⊥) := by ext p split_ifs with h1 h2 · simp [h1] · rw [bot_mul_coe_of_neg h2] · rw [bot_mul_coe_of_pos] exact lt_of_le_of_ne (not_lt.mp h2) (Ne.symm h1) have h2 : Measurable fun (p : ℝ) ↦ if p = 0 then (0 : EReal) else if p < 0 then ⊤ else ⊥ := by refine Measurable.piecewise (measurableSet_singleton _) measurable_const ?_ exact Measurable.piecewise measurableSet_Iio measurable_const measurable_const induction c with | bot => rwa [h1] | coe c => exact (measurable_id.const_mul _).coe_real_ereal | top => simp_rw [← neg_bot, neg_mul] apply Measurable.neg rwa [h1] instance : MeasurableMul₂ EReal := by refine ⟨measurable_of_real_real ?_ ?_ ?_ ?_ ?_⟩ · exact (measurable_fst.mul measurable_snd).coe_real_ereal · exact (measurable_const_mul _).comp measurable_coe_real_ereal · exact (measurable_const_mul _).comp measurable_coe_real_ereal · simp_rw [mul_comm _ ⊥] exact (measurable_const_mul _).comp measurable_coe_real_ereal · simp_rw [mul_comm _ ⊤] exact (measurable_const_mul _).comp measurable_coe_real_ereal end MeasurableMul end EReal /-- If a function `f : α → ℝ≥0` is measurable and the measure is σ-finite, then there exists spanning measurable sets with finite measure on which `f` is bounded. See also `StronglyMeasurable.exists_spanning_measurableSet_norm_le` for functions into normed groups. -/ theorem exists_spanning_measurableSet_le {f : α → ℝ≥0} (hf : Measurable f) (μ : Measure α) [SigmaFinite μ] : ∃ s : ℕ → Set α, (∀ n, MeasurableSet (s n) ∧ μ (s n) < ∞ ∧ ∀ x ∈ s n, f x ≤ n) ∧ ⋃ i, s i = Set.univ := by let sigma_finite_sets := spanningSets μ let norm_sets := fun n : ℕ => { x | f x ≤ n } have norm_sets_spanning : ⋃ n, norm_sets n = Set.univ := by ext1 x simp only [Set.mem_iUnion, Set.mem_univ, iff_true] exact exists_nat_ge (f x) let sets n := sigma_finite_sets n ∩ norm_sets n have h_meas : ∀ n, MeasurableSet (sets n) := by refine fun n => MeasurableSet.inter ?_ ?_ · exact measurableSet_spanningSets μ n · exact hf measurableSet_Iic have h_finite : ∀ n, μ (sets n) < ∞ := by refine fun n => (measure_mono Set.inter_subset_left).trans_lt ?_ exact measure_spanningSets_lt_top μ n refine ⟨sets, fun n => ⟨h_meas n, h_finite n, ?_⟩, ?_⟩ · exact fun x hx => hx.2 · have : ⋃ i, sigma_finite_sets i ∩ norm_sets i = (⋃ i, sigma_finite_sets i) ∩ ⋃ i, norm_sets i := by refine Set.iUnion_inter_of_monotone (monotone_spanningSets μ) fun i j hij x => ?_ simp only [norm_sets, Set.mem_setOf_eq] refine fun hif => hif.trans ?_ exact mod_cast hij rw [this, norm_sets_spanning, iUnion_spanningSets μ, Set.inter_univ] variable (μ : Measure ℝ) [IsFiniteMeasureOnCompacts μ] lemma tendsto_measure_Icc_nhdsWithin_right' (b : ℝ) : Tendsto (fun δ ↦ μ (Icc (b - δ) (b + δ))) (𝓝[>] (0 : ℝ)) (𝓝 (μ {b})) := by rw [Real.singleton_eq_inter_Icc] apply tendsto_measure_biInter_gt (fun r hr ↦ nullMeasurableSet_Icc) · intro r s _rpos hrs exact Icc_subset_Icc (by linarith) (by linarith) · exact ⟨1, zero_lt_one, isCompact_Icc.measure_ne_top⟩ lemma tendsto_measure_Icc_nhdsWithin_right (b : ℝ) : Tendsto (fun δ ↦ μ (Icc (b - δ) (b + δ))) (𝓝[≥] (0 : ℝ)) (𝓝 (μ {b})) := by simp only [← nhdsGT_sup_nhdsWithin_singleton, nhdsWithin_singleton, tendsto_sup, tendsto_measure_Icc_nhdsWithin_right' μ b, true_and, tendsto_pure_left] intro s hs simpa using mem_of_mem_nhds hs lemma tendsto_measure_Icc [NoAtoms μ] (b : ℝ) : Tendsto (fun δ ↦ μ (Icc (b - δ) (b + δ))) (𝓝 (0 : ℝ)) (𝓝 0) := by rw [← nhdsLT_sup_nhdsGE, tendsto_sup] constructor · apply tendsto_const_nhds.congr' filter_upwards [self_mem_nhdsWithin] with r (hr : r < 0) rw [Icc_eq_empty (by linarith), measure_empty] · simpa only [measure_singleton] using tendsto_measure_Icc_nhdsWithin_right μ b
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/Jacobian.lean
import Mathlib.Analysis.Calculus.FDeriv.Congr import Mathlib.MeasureTheory.Constructions.BorelSpace.ContinuousLinearMap import Mathlib.MeasureTheory.Covering.BesicovitchVectorSpace import Mathlib.MeasureTheory.Measure.Lebesgue.EqHaar import Mathlib.Analysis.Normed.Module.Ball.Pointwise import Mathlib.MeasureTheory.Constructions.Polish.Basic import Mathlib.Analysis.Calculus.InverseFunctionTheorem.ApproximatesLinearOn import Mathlib.Topology.Algebra.Module.Determinant /-! # Change of variables in higher-dimensional integrals Let `μ` be a Lebesgue measure on a finite-dimensional real vector space `E`. Let `f : E → E` be a function which is injective and differentiable on a measurable set `s`, with derivative `f'`. Then we prove that `f '' s` is measurable, and its measure is given by the formula `μ (f '' s) = ∫⁻ x in s, |(f' x).det| ∂μ` (where `(f' x).det` is almost everywhere measurable, but not Borel-measurable in general). This formula is proved in `lintegral_abs_det_fderiv_eq_addHaar_image`. We deduce the change of variables formula for the Lebesgue and Bochner integrals, in `lintegral_image_eq_lintegral_abs_det_fderiv_mul` and `integral_image_eq_integral_abs_det_fderiv_smul` respectively. Specialized versions in one dimension (using the derivative instead of the determinant of the Fréchet derivative) can be found in the file `Mathlib/MeasureTheory/Function/JacobianOneDim.lean`, together with versions for monotone and antitone functions. ## Main results * `addHaar_image_eq_zero_of_differentiableOn_of_addHaar_eq_zero`: if `f` is differentiable on a set `s` with zero measure, then `f '' s` also has zero measure. * `addHaar_image_eq_zero_of_det_fderivWithin_eq_zero`: if `f` is differentiable on a set `s`, and its derivative is never invertible, then `f '' s` has zero measure (a version of Sard's lemma). * `aemeasurable_fderivWithin`: if `f` is differentiable on a measurable set `s`, then `f'` is almost everywhere measurable on `s`. For the next statements, `s` is a measurable set and `f` is differentiable on `s` (with a derivative `f'`) and injective on `s`. * `measurable_image_of_fderivWithin`: the image `f '' s` is measurable. * `measurableEmbedding_of_fderivWithin`: the function `s.restrict f` is a measurable embedding. * `lintegral_abs_det_fderiv_eq_addHaar_image`: the image measure is given by `μ (f '' s) = ∫⁻ x in s, |(f' x).det| ∂μ`. * `lintegral_image_eq_lintegral_abs_det_fderiv_mul`: for `g : E → ℝ≥0∞`, one has `∫⁻ x in f '' s, g x ∂μ = ∫⁻ x in s, ENNReal.ofReal |(f' x).det| * g (f x) ∂μ`. * `integral_image_eq_integral_abs_det_fderiv_smul`: for `g : E → F`, one has `∫ x in f '' s, g x ∂μ = ∫ x in s, |(f' x).det| • g (f x) ∂μ`. * `integrableOn_image_iff_integrableOn_abs_det_fderiv_smul`: for `g : E → F`, the function `g` is integrable on `f '' s` if and only if `|(f' x).det| • g (f x))` is integrable on `s`. ## Implementation Typical versions of these results in the literature have much stronger assumptions: `s` would typically be open, and the derivative `f' x` would depend continuously on `x` and be invertible everywhere, to have the local inverse theorem at our disposal. The proof strategy under our weaker assumptions is more involved. We follow [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2]. The first remark is that, if `f` is sufficiently well approximated by a linear map `A` on a set `s`, then `f` expands the volume of `s` by at least `A.det - ε` and at most `A.det + ε`, where the closeness condition depends on `A` in a non-explicit way (see `addHaar_image_le_mul_of_det_lt` and `mul_le_addHaar_image_of_lt_det`). This fact holds for balls by a simple inclusion argument, and follows for general sets using the Besicovitch covering theorem to cover the set by balls with measures adding up essentially to `μ s`. When `f` is differentiable on `s`, one may partition `s` into countably many subsets `s ∩ t n` (where `t n` is measurable), on each of which `f` is well approximated by a linear map, so that the above results apply. See `exists_partition_approximatesLinearOn_of_hasFDerivWithinAt`, which follows from the pointwise differentiability (in a non-completely trivial way, as one should ensure a form of uniformity on the sets of the partition). Combining the above two results would give the conclusion, except for two difficulties: it is not obvious why `f '' s` and `f'` should be measurable, which prevents us from using countable additivity for the measure and the integral. It turns out that `f '' s` is indeed measurable, and that `f'` is almost everywhere measurable, which is enough to recover countable additivity. The measurability of `f '' s` follows from the deep Lusin-Souslin theorem ensuring that, in a Polish space, a continuous injective image of a measurable set is measurable. The key point to check the almost everywhere measurability of `f'` is that, if `f` is approximated up to `δ` by a linear map on a set `s`, then `f'` is within `δ` of `A` on a full measure subset of `s` (namely, its density points). With the above approximation argument, it follows that `f'` is the almost everywhere limit of a sequence of measurable functions (which are constant on the pieces of the good discretization), and is therefore almost everywhere measurable. ## Tags Change of variables in integrals ## References [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2] -/ open MeasureTheory MeasureTheory.Measure Metric Filter Set Module Asymptotics TopologicalSpace open scoped NNReal ENNReal Topology Pointwise variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] {s : Set E} {f : E → E} {f' : E → E →L[ℝ] E} /-! ### Decomposition lemmas We state lemmas ensuring that a differentiable function can be approximated, on countably many measurable pieces, by linear maps (with a prescribed precision depending on the linear map). -/ /-- Assume that a function `f` has a derivative at every point of a set `s`. Then one may cover `s` with countably many closed sets `t n` on which `f` is well approximated by linear maps `A n`. -/ theorem exists_closed_cover_approximatesLinearOn_of_hasFDerivWithinAt [SecondCountableTopology F] (f : E → F) (s : Set E) (f' : E → E →L[ℝ] F) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (r : (E →L[ℝ] F) → ℝ≥0) (rpos : ∀ A, r A ≠ 0) : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] F), (∀ n, IsClosed (t n)) ∧ (s ⊆ ⋃ n, t n) ∧ (∀ n, ApproximatesLinearOn f (A n) (s ∩ t n) (r (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := by /- Choose countably many linear maps `f' z`. For every such map, if `f` has a derivative at `x` close enough to `f' z`, then `f y - f x` is well approximated by `f' z (y - x)` for `y` close enough to `x`, say on a ball of radius `r` (or even `u n` for some `n`, where `u` is a fixed sequence tending to `0`). Let `M n z` be the points where this happens. Then this set is relatively closed inside `s`, and moreover in every closed ball of radius `u n / 3` inside it the map is well approximated by `f' z`. Using countably many closed balls to split `M n z` into small diameter subsets `K n z p`, one obtains the desired sets `t q` after reindexing. -/ -- exclude the trivial case where `s` is empty rcases eq_empty_or_nonempty s with (rfl | hs) · refine ⟨fun _ => ∅, fun _ => 0, ?_, ?_, ?_, ?_⟩ <;> simp -- we will use countably many linear maps. Select these from all the derivatives since the -- space of linear maps is second-countable obtain ⟨T, T_count, hT⟩ : ∃ T : Set s, T.Countable ∧ ⋃ x ∈ T, ball (f' (x : E)) (r (f' x)) = ⋃ x : s, ball (f' x) (r (f' x)) := TopologicalSpace.isOpen_iUnion_countable _ fun x => isOpen_ball -- fix a sequence `u` of positive reals tending to zero. obtain ⟨u, _, u_pos, u_lim⟩ : ∃ u : ℕ → ℝ, StrictAnti u ∧ (∀ n : ℕ, 0 < u n) ∧ Tendsto u atTop (𝓝 0) := exists_seq_strictAnti_tendsto (0 : ℝ) -- `M n z` is the set of points `x` such that `f y - f x` is close to `f' z (y - x)` for `y` -- in the ball of radius `u n` around `x`. let M : ℕ → T → Set E := fun n z => {x | x ∈ s ∧ ∀ y ∈ s ∩ ball x (u n), ‖f y - f x - f' z (y - x)‖ ≤ r (f' z) * ‖y - x‖} -- As `f` is differentiable everywhere on `s`, the sets `M n z` cover `s` by design. have s_subset : ∀ x ∈ s, ∃ (n : ℕ) (z : T), x ∈ M n z := by intro x xs obtain ⟨z, zT, hz⟩ : ∃ z ∈ T, f' x ∈ ball (f' (z : E)) (r (f' z)) := by have : f' x ∈ ⋃ z ∈ T, ball (f' (z : E)) (r (f' z)) := by rw [hT] refine mem_iUnion.2 ⟨⟨x, xs⟩, ?_⟩ simpa only [mem_ball, Subtype.coe_mk, dist_self] using (rpos (f' x)).bot_lt rwa [mem_iUnion₂, bex_def] at this obtain ⟨ε, εpos, hε⟩ : ∃ ε : ℝ, 0 < ε ∧ ‖f' x - f' z‖ + ε ≤ r (f' z) := by refine ⟨r (f' z) - ‖f' x - f' z‖, ?_, le_of_eq (by abel)⟩ simpa only [sub_pos] using mem_ball_iff_norm.mp hz obtain ⟨δ, δpos, hδ⟩ : ∃ (δ : ℝ), 0 < δ ∧ ball x δ ∩ s ⊆ {y | ‖f y - f x - (f' x) (y - x)‖ ≤ ε * ‖y - x‖} := Metric.mem_nhdsWithin_iff.1 ((hf' x xs).isLittleO.def εpos) obtain ⟨n, hn⟩ : ∃ n, u n < δ := ((tendsto_order.1 u_lim).2 _ δpos).exists refine ⟨n, ⟨z, zT⟩, ⟨xs, ?_⟩⟩ intro y hy calc ‖f y - f x - (f' z) (y - x)‖ = ‖f y - f x - (f' x) (y - x) + (f' x - f' z) (y - x)‖ := by congr 1 simp only [ContinuousLinearMap.coe_sub', map_sub, Pi.sub_apply] abel _ ≤ ‖f y - f x - (f' x) (y - x)‖ + ‖(f' x - f' z) (y - x)‖ := norm_add_le _ _ _ ≤ ε * ‖y - x‖ + ‖f' x - f' z‖ * ‖y - x‖ := by refine add_le_add (hδ ?_) (ContinuousLinearMap.le_opNorm _ _) rw [inter_comm] exact inter_subset_inter_right _ (ball_subset_ball hn.le) hy _ ≤ r (f' z) * ‖y - x‖ := by rw [← add_mul, add_comm] gcongr -- the sets `M n z` are relatively closed in `s`, as all the conditions defining it are clearly -- closed have closure_M_subset : ∀ n z, s ∩ closure (M n z) ⊆ M n z := by rintro n z x ⟨xs, hx⟩ refine ⟨xs, fun y hy => ?_⟩ obtain ⟨a, aM, a_lim⟩ : ∃ a : ℕ → E, (∀ k, a k ∈ M n z) ∧ Tendsto a atTop (𝓝 x) := mem_closure_iff_seq_limit.1 hx have L1 : Tendsto (fun k : ℕ => ‖f y - f (a k) - (f' z) (y - a k)‖) atTop (𝓝 ‖f y - f x - (f' z) (y - x)‖) := by apply Tendsto.norm have L : Tendsto (fun k => f (a k)) atTop (𝓝 (f x)) := by apply (hf' x xs).continuousWithinAt.tendsto.comp apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ a_lim exact Eventually.of_forall fun k => (aM k).1 apply Tendsto.sub (tendsto_const_nhds.sub L) exact ((f' z).continuous.tendsto _).comp (tendsto_const_nhds.sub a_lim) have L2 : Tendsto (fun k : ℕ => (r (f' z) : ℝ) * ‖y - a k‖) atTop (𝓝 (r (f' z) * ‖y - x‖)) := (tendsto_const_nhds.sub a_lim).norm.const_mul _ have I : ∀ᶠ k in atTop, ‖f y - f (a k) - (f' z) (y - a k)‖ ≤ r (f' z) * ‖y - a k‖ := by have L : Tendsto (fun k => dist y (a k)) atTop (𝓝 (dist y x)) := tendsto_const_nhds.dist a_lim filter_upwards [(tendsto_order.1 L).2 _ hy.2] intro k hk exact (aM k).2 y ⟨hy.1, hk⟩ exact le_of_tendsto_of_tendsto L1 L2 I -- choose a dense sequence `d p` rcases TopologicalSpace.exists_dense_seq E with ⟨d, hd⟩ -- split `M n z` into subsets `K n z p` of small diameters by intersecting with the ball -- `closedBall (d p) (u n / 3)`. let K : ℕ → T → ℕ → Set E := fun n z p => closure (M n z) ∩ closedBall (d p) (u n / 3) -- on the sets `K n z p`, the map `f` is well approximated by `f' z` by design. have K_approx : ∀ (n) (z : T) (p), ApproximatesLinearOn f (f' z) (s ∩ K n z p) (r (f' z)) := by intro n z p x hx y hy have yM : y ∈ M n z := closure_M_subset _ _ ⟨hy.1, hy.2.1⟩ refine yM.2 _ ⟨hx.1, ?_⟩ calc dist x y ≤ dist x (d p) + dist y (d p) := dist_triangle_right _ _ _ _ ≤ u n / 3 + u n / 3 := add_le_add hx.2.2 hy.2.2 _ < u n := by linarith [u_pos n] -- the sets `K n z p` are also closed, again by design. have K_closed : ∀ (n) (z : T) (p), IsClosed (K n z p) := fun n z p => isClosed_closure.inter isClosed_closedBall -- reindex the sets `K n z p`, to let them only depend on an integer parameter `q`. obtain ⟨F, hF⟩ : ∃ F : ℕ → ℕ × T × ℕ, Function.Surjective F := by haveI : Encodable T := T_count.toEncodable have : Nonempty T := by rcases hs with ⟨x, xs⟩ rcases s_subset x xs with ⟨n, z, _⟩ exact ⟨z⟩ inhabit ↥T exact ⟨_, Encodable.surjective_decode_iget (ℕ × T × ℕ)⟩ -- these sets `t q = K n z p` will do refine ⟨fun q => K (F q).1 (F q).2.1 (F q).2.2, fun q => f' (F q).2.1, fun n => K_closed _ _ _, fun x xs => ?_, fun q => K_approx _ _ _, fun _ q => ⟨(F q).2.1, (F q).2.1.1.2, rfl⟩⟩ -- the only fact that needs further checking is that they cover `s`. -- we already know that any point `x ∈ s` belongs to a set `M n z`. obtain ⟨n, z, hnz⟩ : ∃ (n : ℕ) (z : T), x ∈ M n z := s_subset x xs -- by density, it also belongs to a ball `closedBall (d p) (u n / 3)`. obtain ⟨p, hp⟩ : ∃ p : ℕ, x ∈ closedBall (d p) (u n / 3) := by have : Set.Nonempty (ball x (u n / 3)) := by simp only [nonempty_ball]; linarith [u_pos n] obtain ⟨p, hp⟩ : ∃ p : ℕ, d p ∈ ball x (u n / 3) := hd.exists_mem_open isOpen_ball this exact ⟨p, (mem_ball'.1 hp).le⟩ -- choose `q` for which `t q = K n z p`. obtain ⟨q, hq⟩ : ∃ q, F q = (n, z, p) := hF _ -- then `x` belongs to `t q`. apply mem_iUnion.2 ⟨q, _⟩ simp -zeta only [K, hq, mem_inter_iff, hp, and_true] exact subset_closure hnz variable [MeasurableSpace E] [BorelSpace E] (μ : Measure E) [IsAddHaarMeasure μ] open scoped Function -- required for scoped `on` notation /-- Assume that a function `f` has a derivative at every point of a set `s`. Then one may partition `s` into countably many disjoint relatively measurable sets (i.e., intersections of `s` with measurable sets `t n`) on which `f` is well approximated by linear maps `A n`. -/ theorem exists_partition_approximatesLinearOn_of_hasFDerivWithinAt [SecondCountableTopology F] (f : E → F) (s : Set E) (f' : E → E →L[ℝ] F) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (r : (E →L[ℝ] F) → ℝ≥0) (rpos : ∀ A, r A ≠ 0) : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] F), Pairwise (Disjoint on t) ∧ (∀ n, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n, t n) ∧ (∀ n, ApproximatesLinearOn f (A n) (s ∩ t n) (r (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := by rcases exists_closed_cover_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' r rpos with ⟨t, A, t_closed, st, t_approx, ht⟩ refine ⟨disjointed t, A, disjoint_disjointed _, MeasurableSet.disjointed fun n => (t_closed n).measurableSet, ?_, ?_, ht⟩ · rw [iUnion_disjointed]; exact st · intro n; exact (t_approx n).mono_set (inter_subset_inter_right _ (disjointed_subset _ _)) namespace MeasureTheory /-! ### Local lemmas We check that a function which is well enough approximated by a linear map expands the volume essentially like this linear map, and that its derivative (if it exists) is almost everywhere close to the approximating linear map. -/ /-- Let `f` be a function which is sufficiently close (in the Lipschitz sense) to a given linear map `A`. Then it expands the volume of any set by at most `m` for any `m > det A`. -/ theorem addHaar_image_le_mul_of_det_lt (A : E →L[ℝ] E) {m : ℝ≥0} (hm : ENNReal.ofReal |A.det| < m) : ∀ᶠ δ in 𝓝[>] (0 : ℝ≥0), ∀ (s : Set E) (f : E → E), ApproximatesLinearOn f A s δ → μ (f '' s) ≤ m * μ s := by apply nhdsWithin_le_nhds let d := ENNReal.ofReal |A.det| -- construct a small neighborhood of `A '' (closedBall 0 1)` with measure comparable to -- the determinant of `A`. obtain ⟨ε, hε, εpos⟩ : ∃ ε : ℝ, μ (closedBall 0 ε + A '' closedBall 0 1) < m * μ (closedBall 0 1) ∧ 0 < ε := by have HC : IsCompact (A '' closedBall 0 1) := (ProperSpace.isCompact_closedBall _ _).image A.continuous have L0 : Tendsto (fun ε => μ (cthickening ε (A '' closedBall 0 1))) (𝓝[>] 0) (𝓝 (μ (A '' closedBall 0 1))) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds exact tendsto_measure_cthickening_of_isCompact HC have L1 : Tendsto (fun ε => μ (closedBall 0 ε + A '' closedBall 0 1)) (𝓝[>] 0) (𝓝 (μ (A '' closedBall 0 1))) := by apply L0.congr' _ filter_upwards [self_mem_nhdsWithin] with r hr rw [← HC.add_closedBall_zero (le_of_lt hr), add_comm] have L2 : Tendsto (fun ε => μ (closedBall 0 ε + A '' closedBall 0 1)) (𝓝[>] 0) (𝓝 (d * μ (closedBall 0 1))) := by convert L1 exact (addHaar_image_continuousLinearMap _ _ _).symm have I : d * μ (closedBall 0 1) < m * μ (closedBall 0 1) := (ENNReal.mul_lt_mul_right (measure_closedBall_pos μ _ zero_lt_one).ne' measure_closedBall_lt_top.ne).2 hm have H : ∀ᶠ b : ℝ in 𝓝[>] 0, μ (closedBall 0 b + A '' closedBall 0 1) < m * μ (closedBall 0 1) := (tendsto_order.1 L2).2 _ I exact (H.and self_mem_nhdsWithin).exists have : Iio (⟨ε, εpos.le⟩ : ℝ≥0) ∈ 𝓝 (0 : ℝ≥0) := by apply Iio_mem_nhds; exact εpos filter_upwards [this] -- fix a function `f` which is close enough to `A`. intro δ hδ s f hf simp only [mem_Iio, ← NNReal.coe_lt_coe, NNReal.coe_mk] at hδ -- This function expands the volume of any ball by at most `m` have I : ∀ x r, x ∈ s → 0 ≤ r → μ (f '' (s ∩ closedBall x r)) ≤ m * μ (closedBall x r) := by intro x r xs r0 have K : f '' (s ∩ closedBall x r) ⊆ A '' closedBall 0 r + closedBall (f x) (ε * r) := by rintro y ⟨z, ⟨zs, zr⟩, rfl⟩ rw [mem_closedBall_iff_norm] at zr apply Set.mem_add.2 ⟨A (z - x), _, f z - f x - A (z - x) + f x, _, _⟩ · apply mem_image_of_mem simpa only [dist_eq_norm, mem_closedBall, mem_closedBall_zero_iff, sub_zero] using zr · rw [mem_closedBall_iff_norm, add_sub_cancel_right] calc ‖f z - f x - A (z - x)‖ ≤ δ * ‖z - x‖ := hf _ zs _ xs _ ≤ ε * r := by gcongr · simp only [map_sub] abel have : A '' closedBall 0 r + closedBall (f x) (ε * r) = {f x} + r • (A '' closedBall 0 1 + closedBall 0 ε) := by rw [smul_add, ← add_assoc, add_comm {f x}, add_assoc, smul_closedBall _ _ εpos.le, smul_zero, singleton_add_closedBall_zero, ← image_smul_set, _root_.smul_closedBall _ _ zero_le_one, smul_zero, Real.norm_eq_abs, abs_of_nonneg r0, mul_one, mul_comm] rw [this] at K calc μ (f '' (s ∩ closedBall x r)) ≤ μ ({f x} + r • (A '' closedBall 0 1 + closedBall 0 ε)) := measure_mono K _ = ENNReal.ofReal (r ^ finrank ℝ E) * μ (A '' closedBall 0 1 + closedBall 0 ε) := by simp only [abs_of_nonneg r0, addHaar_smul, image_add_left, abs_pow, singleton_add, measure_preimage_add] _ ≤ ENNReal.ofReal (r ^ finrank ℝ E) * (m * μ (closedBall 0 1)) := by rw [add_comm]; gcongr _ = m * μ (closedBall x r) := by simp only [addHaar_closedBall' μ _ r0]; ring -- covering `s` by closed balls with total measure very close to `μ s`, one deduces that the -- measure of `f '' s` is at most `m * (μ s + a)` for any positive `a`. have J : ∀ᶠ a in 𝓝[>] (0 : ℝ≥0∞), μ (f '' s) ≤ m * (μ s + a) := by filter_upwards [self_mem_nhdsWithin] with a ha rw [mem_Ioi] at ha obtain ⟨t, r, t_count, ts, rpos, st, μt⟩ : ∃ (t : Set E) (r : E → ℝ), t.Countable ∧ t ⊆ s ∧ (∀ x : E, x ∈ t → 0 < r x) ∧ (s ⊆ ⋃ x ∈ t, closedBall x (r x)) ∧ (∑' x : ↥t, μ (closedBall (↑x) (r ↑x))) ≤ μ s + a := Besicovitch.exists_closedBall_covering_tsum_measure_le μ ha.ne' (fun _ => Ioi 0) s fun x _ δ δpos => ⟨δ / 2, by simp [half_pos δpos, δpos]⟩ haveI : Encodable t := t_count.toEncodable calc μ (f '' s) ≤ μ (⋃ x : t, f '' (s ∩ closedBall x (r x))) := by rw [biUnion_eq_iUnion] at st apply measure_mono rw [← image_iUnion, ← inter_iUnion] exact Set.image_mono (subset_inter (Subset.refl _) st) _ ≤ ∑' x : t, μ (f '' (s ∩ closedBall x (r x))) := measure_iUnion_le _ _ ≤ ∑' x : t, m * μ (closedBall x (r x)) := (ENNReal.tsum_le_tsum fun x => I x (r x) (ts x.2) (rpos x x.2).le) _ ≤ m * (μ s + a) := by rw [ENNReal.tsum_mul_left]; gcongr -- taking the limit in `a`, one obtains the conclusion have L : Tendsto (fun a => (m : ℝ≥0∞) * (μ s + a)) (𝓝[>] 0) (𝓝 (m * (μ s + 0))) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds apply ENNReal.Tendsto.const_mul (tendsto_const_nhds.add tendsto_id) simp only [ENNReal.coe_ne_top, Ne, or_true, not_false_iff] rw [add_zero] at L exact ge_of_tendsto L J /-- Let `f` be a function which is sufficiently close (in the Lipschitz sense) to a given linear map `A`. Then it expands the volume of any set by at least `m` for any `m < det A`. -/ theorem mul_le_addHaar_image_of_lt_det (A : E →L[ℝ] E) {m : ℝ≥0} (hm : (m : ℝ≥0∞) < ENNReal.ofReal |A.det|) : ∀ᶠ δ in 𝓝[>] (0 : ℝ≥0), ∀ (s : Set E) (f : E → E), ApproximatesLinearOn f A s δ → (m : ℝ≥0∞) * μ s ≤ μ (f '' s) := by apply nhdsWithin_le_nhds -- The assumption `hm` implies that `A` is invertible. If `f` is close enough to `A`, it is also -- invertible. One can then pass to the inverses, and deduce the estimate from -- `addHaar_image_le_mul_of_det_lt` applied to `f⁻¹` and `A⁻¹`. -- exclude first the trivial case where `m = 0`. rcases eq_or_lt_of_le (zero_le m) with (rfl | mpos) · filter_upwards simp only [forall_const, zero_mul, imp_true_iff, zero_le, ENNReal.coe_zero] have hA : A.det ≠ 0 := by intro h; simp only [h, ENNReal.not_lt_zero, ENNReal.ofReal_zero, abs_zero] at hm -- let `B` be the continuous linear equiv version of `A`. let B := A.toContinuousLinearEquivOfDetNeZero hA -- the determinant of `B.symm` is bounded by `m⁻¹` have I : ENNReal.ofReal |(B.symm : E →L[ℝ] E).det| < (m⁻¹ : ℝ≥0) := by simp only [ENNReal.ofReal, abs_inv, Real.toNNReal_inv, ContinuousLinearEquiv.det_coe_symm, ENNReal.coe_lt_coe] at hm ⊢ exact NNReal.inv_lt_inv mpos.ne' hm -- therefore, we may apply `addHaar_image_le_mul_of_det_lt` to `B.symm` and `m⁻¹`. obtain ⟨δ₀, δ₀pos, hδ₀⟩ : ∃ δ : ℝ≥0, 0 < δ ∧ ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g (B.symm : E →L[ℝ] E) t δ → μ (g '' t) ≤ ↑m⁻¹ * μ t := by have : ∀ᶠ δ : ℝ≥0 in 𝓝[>] 0, ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g (B.symm : E →L[ℝ] E) t δ → μ (g '' t) ≤ ↑m⁻¹ * μ t := addHaar_image_le_mul_of_det_lt μ B.symm I rcases (this.and self_mem_nhdsWithin).exists with ⟨δ₀, h, h'⟩ exact ⟨δ₀, h', h⟩ -- record smallness conditions for `δ` that will be needed to apply `hδ₀` below. have L1 : ∀ᶠ δ in 𝓝 (0 : ℝ≥0), Subsingleton E ∨ δ < ‖(B.symm : E →L[ℝ] E)‖₊⁻¹ := by by_cases h : Subsingleton E · simp only [h, true_or, eventually_const] simp only [h, false_or] apply Iio_mem_nhds simpa only [h, false_or, inv_pos] using B.subsingleton_or_nnnorm_symm_pos have L2 : ∀ᶠ δ in 𝓝 (0 : ℝ≥0), ‖(B.symm : E →L[ℝ] E)‖₊ * (‖(B.symm : E →L[ℝ] E)‖₊⁻¹ - δ)⁻¹ * δ < δ₀ := by have : Tendsto (fun δ => ‖(B.symm : E →L[ℝ] E)‖₊ * (‖(B.symm : E →L[ℝ] E)‖₊⁻¹ - δ)⁻¹ * δ) (𝓝 0) (𝓝 (‖(B.symm : E →L[ℝ] E)‖₊ * (‖(B.symm : E →L[ℝ] E)‖₊⁻¹ - 0)⁻¹ * 0)) := by rcases eq_or_ne ‖(B.symm : E →L[ℝ] E)‖₊ 0 with (H | H) · simpa only [H, zero_mul] using tendsto_const_nhds refine Tendsto.mul (tendsto_const_nhds.mul ?_) tendsto_id refine (Tendsto.sub tendsto_const_nhds tendsto_id).inv₀ ?_ simpa only [tsub_zero, inv_eq_zero, Ne] using H simp only [mul_zero] at this exact (tendsto_order.1 this).2 δ₀ δ₀pos -- let `δ` be small enough, and `f` approximated by `B` up to `δ`. filter_upwards [L1, L2] intro δ h1δ h2δ s f hf have hf' : ApproximatesLinearOn f (B : E →L[ℝ] E) s δ := by convert hf let F := hf'.toPartialEquiv h1δ -- the condition to be checked can be reformulated in terms of the inverse maps suffices H : μ (F.symm '' F.target) ≤ (m⁻¹ : ℝ≥0) * μ F.target by change (m : ℝ≥0∞) * μ F.source ≤ μ F.target rwa [← F.symm_image_target_eq_source, mul_comm, ← ENNReal.le_div_iff_mul_le, div_eq_mul_inv, mul_comm, ← ENNReal.coe_inv mpos.ne'] · apply Or.inl simpa only [ENNReal.coe_eq_zero, Ne] using mpos.ne' · simp only [ENNReal.coe_ne_top, true_or, Ne, not_false_iff] -- as `f⁻¹` is well approximated by `B⁻¹`, the conclusion follows from `hδ₀` -- and our choice of `δ`. exact hδ₀ _ _ ((hf'.to_inv h1δ).mono_num h2δ.le) /-- If a differentiable function `f` is approximated by a linear map `A` on a set `s`, up to `δ`, then at almost every `x` in `s` one has `‖f' x - A‖ ≤ δ`. -/ theorem _root_.ApproximatesLinearOn.norm_fderiv_sub_le {A : E →L[ℝ] E} {δ : ℝ≥0} (hf : ApproximatesLinearOn f A s δ) (hs : MeasurableSet s) (f' : E → E →L[ℝ] E) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : ∀ᵐ x ∂μ.restrict s, ‖f' x - A‖₊ ≤ δ := by /- The conclusion will hold at the Lebesgue density points of `s` (which have full measure). At such a point `x`, for any `z` and any `ε > 0` one has for small `r` that `{x} + r • closedBall z ε` intersects `s`. At a point `y` in the intersection, `f y - f x` is close both to `f' x (r z)` (by differentiability) and to `A (r z)` (by linear approximation), so these two quantities are close, i.e., `(f' x - A) z` is small. -/ filter_upwards [Besicovitch.ae_tendsto_measure_inter_div μ s, ae_restrict_mem hs] -- start from a Lebesgue density point `x`, belonging to `s`. intro x hx xs -- consider an arbitrary vector `z`. apply ContinuousLinearMap.opNorm_le_bound _ δ.2 fun z => ?_ -- to show that `‖(f' x - A) z‖ ≤ δ ‖z‖`, it suffices to do it up to some error that vanishes -- asymptotically in terms of `ε > 0`. suffices H : ∀ ε, 0 < ε → ‖(f' x - A) z‖ ≤ (δ + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ε by have : Tendsto (fun ε : ℝ => ((δ : ℝ) + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ε) (𝓝[>] 0) (𝓝 ((δ + 0) * (‖z‖ + 0) + ‖f' x - A‖ * 0)) := Tendsto.mono_left (Continuous.tendsto (by fun_prop) 0) nhdsWithin_le_nhds simp only [add_zero, mul_zero] at this apply le_of_tendsto_of_tendsto tendsto_const_nhds this filter_upwards [self_mem_nhdsWithin] exact H -- fix a positive `ε`. intro ε εpos -- for small enough `r`, the rescaled ball `r • closedBall z ε` intersects `s`, as `x` is a -- density point have B₁ : ∀ᶠ r in 𝓝[>] (0 : ℝ), (s ∩ ({x} + r • closedBall z ε)).Nonempty := eventually_nonempty_inter_smul_of_density_one μ s x hx _ measurableSet_closedBall (measure_closedBall_pos μ z εpos).ne' obtain ⟨ρ, ρpos, hρ⟩ : ∃ ρ > 0, ball x ρ ∩ s ⊆ {y : E | ‖f y - f x - (f' x) (y - x)‖ ≤ ε * ‖y - x‖} := mem_nhdsWithin_iff.1 ((hf' x xs).isLittleO.def εpos) -- for small enough `r`, the rescaled ball `r • closedBall z ε` is included in the set where -- `f y - f x` is well approximated by `f' x (y - x)`. have B₂ : ∀ᶠ r in 𝓝[>] (0 : ℝ), {x} + r • closedBall z ε ⊆ ball x ρ := by apply nhdsWithin_le_nhds exact eventually_singleton_add_smul_subset isBounded_closedBall (ball_mem_nhds x ρpos) -- fix a small positive `r` satisfying the above properties, as well as a corresponding `y`. obtain ⟨r, ⟨y, ⟨ys, hy⟩⟩, rρ, rpos⟩ : ∃ r : ℝ, (s ∩ ({x} + r • closedBall z ε)).Nonempty ∧ {x} + r • closedBall z ε ⊆ ball x ρ ∧ 0 < r := (B₁.and (B₂.and self_mem_nhdsWithin)).exists -- write `y = x + r a` with `a ∈ closedBall z ε`. obtain ⟨a, az, ya⟩ : ∃ a, a ∈ closedBall z ε ∧ y = x + r • a := by simp only [mem_smul_set, image_add_left, mem_preimage, singleton_add] at hy rcases hy with ⟨a, az, ha⟩ exact ⟨a, az, by simp only [ha, add_neg_cancel_left]⟩ have norm_a : ‖a‖ ≤ ‖z‖ + ε := calc ‖a‖ = ‖z + (a - z)‖ := by simp only [add_sub_cancel] _ ≤ ‖z‖ + ‖a - z‖ := norm_add_le _ _ _ ≤ ‖z‖ + ε := by grw [mem_closedBall_iff_norm.1 az] -- use the approximation properties to control `(f' x - A) a`, and then `(f' x - A) z` as `z` is -- close to `a`. have I : r * ‖(f' x - A) a‖ ≤ r * (δ + ε) * (‖z‖ + ε) := calc r * ‖(f' x - A) a‖ = ‖(f' x - A) (r • a)‖ := by simp only [ContinuousLinearMap.map_smul, norm_smul, Real.norm_eq_abs, abs_of_nonneg rpos.le] _ = ‖f y - f x - A (y - x) - (f y - f x - (f' x) (y - x))‖ := by simp only [ya, add_sub_cancel_left, sub_sub_sub_cancel_left, ContinuousLinearMap.coe_sub', Pi.sub_apply, ContinuousLinearMap.map_smul, smul_sub] _ ≤ ‖f y - f x - A (y - x)‖ + ‖f y - f x - (f' x) (y - x)‖ := norm_sub_le _ _ _ ≤ δ * ‖y - x‖ + ε * ‖y - x‖ := (add_le_add (hf _ ys _ xs) (hρ ⟨rρ hy, ys⟩)) _ = r * (δ + ε) * ‖a‖ := by simp only [ya, add_sub_cancel_left, norm_smul, Real.norm_eq_abs, abs_of_nonneg rpos.le] ring _ ≤ r * (δ + ε) * (‖z‖ + ε) := by gcongr calc ‖(f' x - A) z‖ = ‖(f' x - A) a + (f' x - A) (z - a)‖ := by congr 1 simp only [ContinuousLinearMap.coe_sub', map_sub, Pi.sub_apply] abel _ ≤ ‖(f' x - A) a‖ + ‖(f' x - A) (z - a)‖ := norm_add_le _ _ _ ≤ (δ + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ‖z - a‖ := by apply add_le_add · rw [mul_assoc] at I; exact (mul_le_mul_iff_right₀ rpos).1 I · apply ContinuousLinearMap.le_opNorm _ ≤ (δ + ε) * (‖z‖ + ε) + ‖f' x - A‖ * ε := by rw [mem_closedBall_iff_norm'] at az gcongr /-! ### Measure zero of the image, over non-measurable sets If a set has measure `0`, then its image under a differentiable map has measure zero. This doesn't require the set to be measurable. In the same way, if `f` is differentiable on a set `s` with non-invertible derivative everywhere, then `f '' s` has measure `0`, again without measurability assumptions. -/ /-- A differentiable function maps sets of measure zero to sets of measure zero. -/ theorem addHaar_image_eq_zero_of_differentiableOn_of_addHaar_eq_zero (hf : DifferentiableOn ℝ f s) (hs : μ s = 0) : μ (f '' s) = 0 := by refine le_antisymm ?_ (zero_le _) have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ ∀ (t : Set E), ApproximatesLinearOn f A t δ → μ (f '' t) ≤ (Real.toNNReal |A.det| + 1 : ℝ≥0) * μ t := by intro A let m : ℝ≥0 := Real.toNNReal |A.det| + 1 have I : ENNReal.ofReal |A.det| < m := by simp only [m, ENNReal.ofReal, lt_add_iff_pos_right, zero_lt_one, ENNReal.coe_lt_coe] rcases ((addHaar_image_le_mul_of_det_lt μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, h'⟩ exact ⟨δ, h', fun t ht => h t f ht⟩ choose δ hδ using this obtain ⟨t, A, _, _, t_cover, ht, -⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = fderivWithin ℝ f s y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s (fderivWithin ℝ f s) (fun x xs => (hf x xs).hasFDerivWithinAt) δ fun A => (hδ A).1.ne' calc μ (f '' s) ≤ μ (⋃ n, f '' (s ∩ t n)) := by apply measure_mono rw [← image_iUnion, ← inter_iUnion] exact Set.image_mono (subset_inter Subset.rfl t_cover) _ ≤ ∑' n, μ (f '' (s ∩ t n)) := measure_iUnion_le _ _ ≤ ∑' n, (Real.toNNReal |(A n).det| + 1 : ℝ≥0) * μ (s ∩ t n) := by apply ENNReal.tsum_le_tsum fun n => ?_ apply (hδ (A n)).2 exact ht n _ ≤ ∑' n, ((Real.toNNReal |(A n).det| + 1 : ℝ≥0) : ℝ≥0∞) * 0 := by gcongr with n exact le_trans (measure_mono inter_subset_left) (le_of_eq hs) _ = 0 := by simp only [tsum_zero, mul_zero] /-- A version of **Sard's lemma** in fixed dimension: given a differentiable function from `E` to `E` and a set where the differential is not invertible, then the image of this set has zero measure. Here, we give an auxiliary statement towards this result. -/ theorem addHaar_image_eq_zero_of_det_fderivWithin_eq_zero_aux (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (R : ℝ) (hs : s ⊆ closedBall 0 R) (ε : ℝ≥0) (εpos : 0 < ε) (h'f' : ∀ x ∈ s, (f' x).det = 0) : μ (f '' s) ≤ ε * μ (closedBall 0 R) := by rcases eq_empty_or_nonempty s with (rfl | h's); · simp only [measure_empty, zero_le, image_empty] have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ ∀ (t : Set E), ApproximatesLinearOn f A t δ → μ (f '' t) ≤ (Real.toNNReal |A.det| + ε : ℝ≥0) * μ t := by intro A let m : ℝ≥0 := Real.toNNReal |A.det| + ε have I : ENNReal.ofReal |A.det| < m := by simp only [m, ENNReal.ofReal, lt_add_iff_pos_right, εpos, ENNReal.coe_lt_coe] rcases ((addHaar_image_le_mul_of_det_lt μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, h'⟩ exact ⟨δ, h', fun t ht => h t f ht⟩ choose δ hδ using this obtain ⟨t, A, t_disj, t_meas, t_cover, ht, Af'⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' δ fun A => (hδ A).1.ne' calc μ (f '' s) ≤ μ (⋃ n, f '' (s ∩ t n)) := by rw [← image_iUnion, ← inter_iUnion] gcongr exact subset_inter Subset.rfl t_cover _ ≤ ∑' n, μ (f '' (s ∩ t n)) := measure_iUnion_le _ _ ≤ ∑' n, (Real.toNNReal |(A n).det| + ε : ℝ≥0) * μ (s ∩ t n) := by gcongr exact (hδ (A _)).2 _ (ht _) _ = ∑' n, ε * μ (s ∩ t n) := by congr with n rcases Af' h's n with ⟨y, ys, hy⟩ simp only [hy, h'f' y ys, Real.toNNReal_zero, abs_zero, zero_add] _ ≤ ε * ∑' n, μ (closedBall 0 R ∩ t n) := by rw [ENNReal.tsum_mul_left] gcongr _ = ε * μ (⋃ n, closedBall 0 R ∩ t n) := by rw [measure_iUnion] · exact pairwise_disjoint_mono t_disj fun n => inter_subset_right · intro n exact measurableSet_closedBall.inter (t_meas n) _ ≤ ε * μ (closedBall 0 R) := by grw [← inter_iUnion, inter_subset_left] /-- A version of Sard lemma in fixed dimension: given a differentiable function from `E` to `E` and a set where the differential is not invertible, then the image of this set has zero measure. -/ theorem addHaar_image_eq_zero_of_det_fderivWithin_eq_zero (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (h'f' : ∀ x ∈ s, (f' x).det = 0) : μ (f '' s) = 0 := by suffices H : ∀ R, μ (f '' (s ∩ closedBall 0 R)) = 0 by apply le_antisymm _ (zero_le _) rw [← iUnion_inter_closedBall_nat s 0] calc μ (f '' ⋃ n : ℕ, s ∩ closedBall 0 n) ≤ ∑' n : ℕ, μ (f '' (s ∩ closedBall 0 n)) := by rw [image_iUnion]; exact measure_iUnion_le _ _ ≤ 0 := by simp only [H, tsum_zero, nonpos_iff_eq_zero] intro R have A : ∀ (ε : ℝ≥0), 0 < ε → μ (f '' (s ∩ closedBall 0 R)) ≤ ε * μ (closedBall 0 R) := fun ε εpos => addHaar_image_eq_zero_of_det_fderivWithin_eq_zero_aux μ (fun x hx => (hf' x hx.1).mono inter_subset_left) R inter_subset_right ε εpos fun x hx => h'f' x hx.1 have B : Tendsto (fun ε : ℝ≥0 => (ε : ℝ≥0∞) * μ (closedBall 0 R)) (𝓝[>] 0) (𝓝 0) := by have : Tendsto (fun ε : ℝ≥0 => (ε : ℝ≥0∞) * μ (closedBall 0 R)) (𝓝 0) (𝓝 (((0 : ℝ≥0) : ℝ≥0∞) * μ (closedBall 0 R))) := ENNReal.Tendsto.mul_const (ENNReal.tendsto_coe.2 tendsto_id) (Or.inr measure_closedBall_lt_top.ne) simp only [zero_mul, ENNReal.coe_zero] at this exact Tendsto.mono_left this nhdsWithin_le_nhds apply le_antisymm _ (zero_le _) apply ge_of_tendsto B filter_upwards [self_mem_nhdsWithin] exact A /-! ### Weak measurability statements We show that the derivative of a function on a set is almost everywhere measurable, and that the image `f '' s` is measurable if `f` is injective on `s`. The latter statement follows from the Lusin-Souslin theorem. -/ /-- The derivative of a function on a measurable set is almost everywhere measurable on this set with respect to Lebesgue measure. Note that, in general, it is not genuinely measurable there, as `f'` is not unique (but only on a set of measure `0`, as the argument shows). -/ theorem aemeasurable_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : AEMeasurable f' (μ.restrict s) := by /- It suffices to show that `f'` can be uniformly approximated by a measurable function. Fix `ε > 0`. Thanks to `exists_partition_approximatesLinearOn_of_hasFDerivWithinAt`, one can find a countable measurable partition of `s` into sets `s ∩ t n` on which `f` is well approximated by linear maps `A n`. On almost all of `s ∩ t n`, it follows from `ApproximatesLinearOn.norm_fderiv_sub_le` that `f'` is uniformly approximated by `A n`, which gives the conclusion. -/ -- fix a precision `ε` refine aemeasurable_of_unif_approx fun ε εpos => ?_ let δ : ℝ≥0 := ⟨ε, le_of_lt εpos⟩ have δpos : 0 < δ := εpos -- partition `s` into sets `s ∩ t n` on which `f` is approximated by linear maps `A n`. obtain ⟨t, A, t_disj, t_meas, t_cover, ht, _⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) δ) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' (fun _ => δ) fun _ => δpos.ne' -- define a measurable function `g` which coincides with `A n` on `t n`. obtain ⟨g, g_meas, hg⟩ : ∃ g : E → E →L[ℝ] E, Measurable g ∧ ∀ (n : ℕ) (x : E), x ∈ t n → g x = A n := exists_measurable_piecewise t t_meas (fun n _ => A n) (fun n => measurable_const) <| t_disj.mono fun i j h => by simp only [h.inter_eq, eqOn_empty] refine ⟨g, g_meas.aemeasurable, ?_⟩ -- reduce to checking that `f'` and `g` are close on almost all of `s ∩ t n`, for all `n`. suffices H : ∀ᵐ x : E ∂sum fun n ↦ μ.restrict (s ∩ t n), dist (g x) (f' x) ≤ ε by have : μ.restrict s ≤ sum fun n => μ.restrict (s ∩ t n) := by have : s = ⋃ n, s ∩ t n := by rw [← inter_iUnion] exact Subset.antisymm (subset_inter Subset.rfl t_cover) inter_subset_left conv_lhs => rw [this] exact restrict_iUnion_le exact ae_mono this H -- fix such an `n`. refine ae_sum_iff.2 fun n => ?_ -- on almost all `s ∩ t n`, `f' x` is close to `A n` thanks to -- `ApproximatesLinearOn.norm_fderiv_sub_le`. have E₁ : ∀ᵐ x : E ∂μ.restrict (s ∩ t n), ‖f' x - A n‖₊ ≤ δ := (ht n).norm_fderiv_sub_le μ (hs.inter (t_meas n)) f' fun x hx => (hf' x hx.1).mono inter_subset_left -- moreover, `g x` is equal to `A n` there. have E₂ : ∀ᵐ x : E ∂μ.restrict (s ∩ t n), g x = A n := by suffices H : ∀ᵐ x : E ∂μ.restrict (t n), g x = A n from ae_mono (restrict_mono inter_subset_right le_rfl) H filter_upwards [ae_restrict_mem (t_meas n)] exact hg n -- putting these two properties together gives the conclusion. filter_upwards [E₁, E₂] with x hx1 hx2 rw [← nndist_eq_nnnorm] at hx1 rw [hx2, dist_comm] exact hx1 theorem aemeasurable_ofReal_abs_det_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : AEMeasurable (fun x => ENNReal.ofReal |(f' x).det|) (μ.restrict s) := by apply ENNReal.measurable_ofReal.comp_aemeasurable refine continuous_abs.measurable.comp_aemeasurable ?_ refine ContinuousLinearMap.continuous_det.measurable.comp_aemeasurable ?_ exact aemeasurable_fderivWithin μ hs hf' theorem aemeasurable_toNNReal_abs_det_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : AEMeasurable (fun x => |(f' x).det|.toNNReal) (μ.restrict s) := by apply measurable_real_toNNReal.comp_aemeasurable refine continuous_abs.measurable.comp_aemeasurable ?_ refine ContinuousLinearMap.continuous_det.measurable.comp_aemeasurable ?_ exact aemeasurable_fderivWithin μ hs hf' /-- If a function is differentiable and injective on a measurable set, then the image is measurable. -/ theorem measurable_image_of_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : MeasurableSet (f '' s) := haveI : DifferentiableOn ℝ f s := fun x hx => (hf' x hx).differentiableWithinAt hs.image_of_continuousOn_injOn (DifferentiableOn.continuousOn this) hf /-- If a function is differentiable and injective on a null measurable set, then the image is null measurable. -/ theorem nullMeasurable_image_of_fderivWithin (hs : NullMeasurableSet s μ) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : NullMeasurableSet (f '' s) μ := by rcases hs.exists_measurable_subset_ae_eq with ⟨t, ts, ht, t_eq_s⟩ have A : f '' s =ᵐ[μ] f '' t := by have : s = t ∪ (s \ t) := by simp [union_eq_self_of_subset_left ts] rw [this, image_union] refine union_ae_eq_left_of_ae_eq_empty (ae_eq_empty.mpr ?_) apply addHaar_image_eq_zero_of_differentiableOn_of_addHaar_eq_zero _ (fun x hx ↦ ?_) (ae_eq_set.1 t_eq_s).2 exact (hf' x hx.1).differentiableWithinAt.mono diff_subset apply NullMeasurableSet.congr _ A.symm apply MeasurableSet.nullMeasurableSet apply measurable_image_of_fderivWithin ht _ (hf.mono ts) (f' := f') intro x hx exact (hf' x (ts hx)).mono ts /-- If a function is differentiable and injective on a measurable set `s`, then its restriction to `s` is a measurable embedding. -/ theorem measurableEmbedding_of_fderivWithin (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : MeasurableEmbedding (s.restrict f) := haveI : DifferentiableOn ℝ f s := fun x hx => (hf' x hx).differentiableWithinAt this.continuousOn.measurableEmbedding hs hf /-! ### Proving the estimate for the measure of the image We show the formula `∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ = μ (f '' s)`, in `lintegral_abs_det_fderiv_eq_addHaar_image`. For this, we show both inequalities in both directions, first up to controlled errors and then letting these errors tend to `0`. -/ theorem addHaar_image_le_lintegral_abs_det_fderiv_aux1 (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) {ε : ℝ≥0} (εpos : 0 < ε) : μ (f '' s) ≤ (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * ε * μ s := by /- To bound `μ (f '' s)`, we cover `s` by sets where `f` is well-approximated by linear maps `A n` (and where `f'` is almost everywhere close to `A n`), and then use that `f` expands the measure of such a set by at most `(A n).det + ε`. -/ have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ (∀ B : E →L[ℝ] E, ‖B - A‖ ≤ δ → |B.det - A.det| ≤ ε) ∧ ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g A t δ → μ (g '' t) ≤ (ENNReal.ofReal |A.det| + ε) * μ t := by intro A let m : ℝ≥0 := Real.toNNReal |A.det| + ε have I : ENNReal.ofReal |A.det| < m := by simp only [m, ENNReal.ofReal, lt_add_iff_pos_right, εpos, ENNReal.coe_lt_coe] rcases ((addHaar_image_le_mul_of_det_lt μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, δpos⟩ obtain ⟨δ', δ'pos, hδ'⟩ : ∃ (δ' : ℝ), 0 < δ' ∧ ∀ B, dist B A < δ' → dist B.det A.det < ↑ε := by refine continuousAt_iff.1 ?_ ε εpos exact ContinuousLinearMap.continuous_det.continuousAt let δ'' : ℝ≥0 := ⟨δ' / 2, (half_pos δ'pos).le⟩ refine ⟨min δ δ'', lt_min δpos (half_pos δ'pos), ?_, ?_⟩ · intro B hB rw [← Real.dist_eq] apply (hδ' B _).le rw [dist_eq_norm] calc ‖B - A‖ ≤ (min δ δ'' : ℝ≥0) := hB _ ≤ δ'' := by simp only [le_refl, NNReal.coe_min, min_le_iff, or_true] _ < δ' := half_lt_self δ'pos · intro t g htg exact h t g (htg.mono_num (min_le_left _ _)) choose δ hδ using this obtain ⟨t, A, t_disj, t_meas, t_cover, ht, -⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' δ fun A => (hδ A).1.ne' calc μ (f '' s) ≤ μ (⋃ n, f '' (s ∩ t n)) := by apply measure_mono rw [← image_iUnion, ← inter_iUnion] exact Set.image_mono (subset_inter Subset.rfl t_cover) _ ≤ ∑' n, μ (f '' (s ∩ t n)) := measure_iUnion_le _ _ ≤ ∑' n, (ENNReal.ofReal |(A n).det| + ε) * μ (s ∩ t n) := by apply ENNReal.tsum_le_tsum fun n => ?_ apply (hδ (A n)).2.2 exact ht n _ = ∑' n, ∫⁻ _ in s ∩ t n, ENNReal.ofReal |(A n).det| + ε ∂μ := by simp only [lintegral_const, MeasurableSet.univ, Measure.restrict_apply, univ_inter] _ ≤ ∑' n, ∫⁻ x in s ∩ t n, ENNReal.ofReal |(f' x).det| + 2 * ε ∂μ := by apply ENNReal.tsum_le_tsum fun n => ?_ apply lintegral_mono_ae filter_upwards [(ht n).norm_fderiv_sub_le μ (hs.inter (t_meas n)) f' fun x hx => (hf' x hx.1).mono inter_subset_left] intro x hx have I : |(A n).det| ≤ |(f' x).det| + ε := calc |(A n).det| = |(f' x).det - ((f' x).det - (A n).det)| := by congr 1; abel _ ≤ |(f' x).det| + |(f' x).det - (A n).det| := abs_sub _ _ _ ≤ |(f' x).det| + ε := add_le_add le_rfl ((hδ (A n)).2.1 _ hx) calc ENNReal.ofReal |(A n).det| + ε ≤ ENNReal.ofReal (|(f' x).det| + ε) + ε := by gcongr _ = ENNReal.ofReal |(f' x).det| + 2 * ε := by simp only [ENNReal.ofReal_add, abs_nonneg, two_mul, add_assoc, NNReal.zero_le_coe, ENNReal.ofReal_coe_nnreal] _ = ∫⁻ x in ⋃ n, s ∩ t n, ENNReal.ofReal |(f' x).det| + 2 * ε ∂μ := by have M : ∀ n : ℕ, MeasurableSet (s ∩ t n) := fun n => hs.inter (t_meas n) rw [lintegral_iUnion M] exact pairwise_disjoint_mono t_disj fun n => inter_subset_right _ = ∫⁻ x in s, ENNReal.ofReal |(f' x).det| + 2 * ε ∂μ := by rw [← inter_iUnion, inter_eq_self_of_subset_left t_cover] _ = (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * ε * μ s := by simp only [lintegral_add_right' _ aemeasurable_const, setLIntegral_const] theorem addHaar_image_le_lintegral_abs_det_fderiv_aux2 (hs : MeasurableSet s) (h's : μ s ≠ ∞) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : μ (f '' s) ≤ ∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ := by -- We just need to let the error tend to `0` in the previous lemma. have : Tendsto (fun ε : ℝ≥0 => (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * ε * μ s) (𝓝[>] 0) (𝓝 ((∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) + 2 * (0 : ℝ≥0) * μ s)) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds refine tendsto_const_nhds.add ?_ refine ENNReal.Tendsto.mul_const ?_ (Or.inr h's) exact ENNReal.Tendsto.const_mul (ENNReal.tendsto_coe.2 tendsto_id) (Or.inr ENNReal.coe_ne_top) simp only [add_zero, zero_mul, mul_zero, ENNReal.coe_zero] at this apply ge_of_tendsto this filter_upwards [self_mem_nhdsWithin] intro ε εpos rw [mem_Ioi] at εpos exact addHaar_image_le_lintegral_abs_det_fderiv_aux1 μ hs hf' εpos theorem addHaar_image_le_lintegral_abs_det_fderiv (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : μ (f '' s) ≤ ∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ := by /- We already know the result for finite-measure sets. We cover `s` by finite-measure sets using `spanningSets μ`, and apply the previous result to each of these parts. -/ let u n := disjointed (spanningSets μ) n have u_meas : ∀ n, MeasurableSet (u n) := by intro n apply MeasurableSet.disjointed fun i => ?_ exact measurableSet_spanningSets μ i have A : s = ⋃ n, s ∩ u n := by rw [← inter_iUnion, iUnion_disjointed, iUnion_spanningSets, inter_univ] calc μ (f '' s) ≤ ∑' n, μ (f '' (s ∩ u n)) := by conv_lhs => rw [A, image_iUnion] exact measure_iUnion_le _ _ ≤ ∑' n, ∫⁻ x in s ∩ u n, ENNReal.ofReal |(f' x).det| ∂μ := by apply ENNReal.tsum_le_tsum fun n => ?_ apply addHaar_image_le_lintegral_abs_det_fderiv_aux2 μ (hs.inter (u_meas n)) _ fun x hx => (hf' x hx.1).mono inter_subset_left have : μ (u n) < ∞ := lt_of_le_of_lt (measure_mono (disjointed_subset _ _)) (measure_spanningSets_lt_top μ n) exact ne_of_lt (lt_of_le_of_lt (measure_mono inter_subset_right) this) _ = ∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ := by conv_rhs => rw [A] rw [lintegral_iUnion] · intro n; exact hs.inter (u_meas n) · exact pairwise_disjoint_mono (disjoint_disjointed _) fun n => inter_subset_right theorem lintegral_abs_det_fderiv_le_addHaar_image_aux1 (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) {ε : ℝ≥0} (εpos : 0 < ε) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) ≤ μ (f '' s) + 2 * ε * μ s := by /- To bound `∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ`, we cover `s` by sets where `f` is well-approximated by linear maps `A n` (and where `f'` is almost everywhere close to `A n`), and then use that `f` expands the measure of such a set by at least `(A n).det - ε`. -/ have : ∀ A : E →L[ℝ] E, ∃ δ : ℝ≥0, 0 < δ ∧ (∀ B : E →L[ℝ] E, ‖B - A‖ ≤ δ → |B.det - A.det| ≤ ε) ∧ ∀ (t : Set E) (g : E → E), ApproximatesLinearOn g A t δ → ENNReal.ofReal |A.det| * μ t ≤ μ (g '' t) + ε * μ t := by intro A obtain ⟨δ', δ'pos, hδ'⟩ : ∃ (δ' : ℝ), 0 < δ' ∧ ∀ B, dist B A < δ' → dist B.det A.det < ↑ε := by refine continuousAt_iff.1 ?_ ε εpos exact ContinuousLinearMap.continuous_det.continuousAt let δ'' : ℝ≥0 := ⟨δ' / 2, (half_pos δ'pos).le⟩ have I'' : ∀ B : E →L[ℝ] E, ‖B - A‖ ≤ ↑δ'' → |B.det - A.det| ≤ ↑ε := by intro B hB rw [← Real.dist_eq] apply (hδ' B _).le rw [dist_eq_norm] exact hB.trans_lt (half_lt_self δ'pos) rcases eq_or_ne A.det 0 with (hA | hA) · refine ⟨δ'', half_pos δ'pos, I'', ?_⟩ simp only [hA, forall_const, zero_mul, ENNReal.ofReal_zero, imp_true_iff, zero_le, abs_zero] let m : ℝ≥0 := Real.toNNReal |A.det| - ε have I : (m : ℝ≥0∞) < ENNReal.ofReal |A.det| := by simp only [m, ENNReal.ofReal, ENNReal.coe_sub] apply ENNReal.sub_lt_self ENNReal.coe_ne_top · simpa only [abs_nonpos_iff, Real.toNNReal_eq_zero, ENNReal.coe_eq_zero, Ne] using hA · simp only [εpos.ne', ENNReal.coe_eq_zero, Ne, not_false_iff] rcases ((mul_le_addHaar_image_of_lt_det μ A I).and self_mem_nhdsWithin).exists with ⟨δ, h, δpos⟩ refine ⟨min δ δ'', lt_min δpos (half_pos δ'pos), ?_, ?_⟩ · intro B hB apply I'' _ (hB.trans _) simp only [le_refl, NNReal.coe_min, min_le_iff, or_true] · intro t g htg rcases eq_or_ne (μ t) ∞ with (ht | ht) · simp only [ht, εpos.ne', ENNReal.mul_top, ENNReal.coe_eq_zero, le_top, Ne, not_false_iff, _root_.add_top] have := h t g (htg.mono_num (min_le_left _ _)) rwa [ENNReal.coe_sub, ENNReal.sub_mul, tsub_le_iff_right] at this simp only [ht, imp_true_iff, Ne, not_false_iff] choose δ hδ using this obtain ⟨t, A, t_disj, t_meas, t_cover, ht, -⟩ : ∃ (t : ℕ → Set E) (A : ℕ → E →L[ℝ] E), Pairwise (Disjoint on t) ∧ (∀ n : ℕ, MeasurableSet (t n)) ∧ (s ⊆ ⋃ n : ℕ, t n) ∧ (∀ n : ℕ, ApproximatesLinearOn f (A n) (s ∩ t n) (δ (A n))) ∧ (s.Nonempty → ∀ n, ∃ y ∈ s, A n = f' y) := exists_partition_approximatesLinearOn_of_hasFDerivWithinAt f s f' hf' δ fun A => (hδ A).1.ne' have s_eq : s = ⋃ n, s ∩ t n := by rw [← inter_iUnion] exact Subset.antisymm (subset_inter Subset.rfl t_cover) inter_subset_left calc (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = ∑' n, ∫⁻ x in s ∩ t n, ENNReal.ofReal |(f' x).det| ∂μ := by conv_lhs => rw [s_eq] rw [lintegral_iUnion] · exact fun n => hs.inter (t_meas n) · exact pairwise_disjoint_mono t_disj fun n => inter_subset_right _ ≤ ∑' n, ∫⁻ _ in s ∩ t n, ENNReal.ofReal |(A n).det| + ε ∂μ := by apply ENNReal.tsum_le_tsum fun n => ?_ apply lintegral_mono_ae filter_upwards [(ht n).norm_fderiv_sub_le μ (hs.inter (t_meas n)) f' fun x hx => (hf' x hx.1).mono inter_subset_left] intro x hx have I : |(f' x).det| ≤ |(A n).det| + ε := calc |(f' x).det| = |(A n).det + ((f' x).det - (A n).det)| := by congr 1; abel _ ≤ |(A n).det| + |(f' x).det - (A n).det| := abs_add_le _ _ _ ≤ |(A n).det| + ε := add_le_add le_rfl ((hδ (A n)).2.1 _ hx) calc ENNReal.ofReal |(f' x).det| ≤ ENNReal.ofReal (|(A n).det| + ε) := ENNReal.ofReal_le_ofReal I _ = ENNReal.ofReal |(A n).det| + ε := by simp only [ENNReal.ofReal_add, abs_nonneg, NNReal.zero_le_coe, ENNReal.ofReal_coe_nnreal] _ = ∑' n, (ENNReal.ofReal |(A n).det| * μ (s ∩ t n) + ε * μ (s ∩ t n)) := by simp only [setLIntegral_const, lintegral_add_right _ measurable_const] _ ≤ ∑' n, (μ (f '' (s ∩ t n)) + ε * μ (s ∩ t n) + ε * μ (s ∩ t n)) := by gcongr exact (hδ (A _)).2.2 _ _ (ht _) _ = μ (f '' s) + 2 * ε * μ s := by conv_rhs => rw [s_eq] rw [image_iUnion, measure_iUnion]; rotate_left · intro i j hij apply Disjoint.image _ hf inter_subset_left inter_subset_left exact Disjoint.mono inter_subset_right inter_subset_right (t_disj hij) · intro i exact measurable_image_of_fderivWithin (hs.inter (t_meas i)) (fun x hx => (hf' x hx.1).mono inter_subset_left) (hf.mono inter_subset_left) rw [measure_iUnion]; rotate_left · exact pairwise_disjoint_mono t_disj fun i => inter_subset_right · exact fun i => hs.inter (t_meas i) rw [← ENNReal.tsum_mul_left, ← ENNReal.tsum_add] congr 1 ext1 i rw [mul_assoc, two_mul, add_assoc] theorem lintegral_abs_det_fderiv_le_addHaar_image_aux2 (hs : MeasurableSet s) (h's : μ s ≠ ∞) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) ≤ μ (f '' s) := by -- We just need to let the error tend to `0` in the previous lemma. have : Tendsto (fun ε : ℝ≥0 => μ (f '' s) + 2 * ε * μ s) (𝓝[>] 0) (𝓝 (μ (f '' s) + 2 * (0 : ℝ≥0) * μ s)) := by apply Tendsto.mono_left _ nhdsWithin_le_nhds refine tendsto_const_nhds.add ?_ refine ENNReal.Tendsto.mul_const ?_ (Or.inr h's) exact ENNReal.Tendsto.const_mul (ENNReal.tendsto_coe.2 tendsto_id) (Or.inr ENNReal.coe_ne_top) simp only [add_zero, zero_mul, mul_zero, ENNReal.coe_zero] at this apply ge_of_tendsto this filter_upwards [self_mem_nhdsWithin] intro ε εpos rw [mem_Ioi] at εpos exact lintegral_abs_det_fderiv_le_addHaar_image_aux1 μ hs hf' hf εpos theorem lintegral_abs_det_fderiv_le_addHaar_image (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) ≤ μ (f '' s) := by /- We already know the result for finite-measure sets. We cover `s` by finite-measure sets using `spanningSets μ`, and apply the previous result to each of these parts. -/ let u n := disjointed (spanningSets μ) n have u_meas : ∀ n, MeasurableSet (u n) := by intro n apply MeasurableSet.disjointed fun i => ?_ exact measurableSet_spanningSets μ i have A : s = ⋃ n, s ∩ u n := by rw [← inter_iUnion, iUnion_disjointed, iUnion_spanningSets, inter_univ] calc (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = ∑' n, ∫⁻ x in s ∩ u n, ENNReal.ofReal |(f' x).det| ∂μ := by conv_lhs => rw [A] rw [lintegral_iUnion] · intro n; exact hs.inter (u_meas n) · exact pairwise_disjoint_mono (disjoint_disjointed _) fun n => inter_subset_right _ ≤ ∑' n, μ (f '' (s ∩ u n)) := by apply ENNReal.tsum_le_tsum fun n => ?_ apply lintegral_abs_det_fderiv_le_addHaar_image_aux2 μ (hs.inter (u_meas n)) _ (fun x hx => (hf' x hx.1).mono inter_subset_left) (hf.mono inter_subset_left) have : μ (u n) < ∞ := lt_of_le_of_lt (measure_mono (disjointed_subset _ _)) (measure_spanningSets_lt_top μ n) exact ne_of_lt (lt_of_le_of_lt (measure_mono inter_subset_right) this) _ = μ (f '' s) := by conv_rhs => rw [A, image_iUnion] rw [measure_iUnion] · intro i j hij apply Disjoint.image _ hf inter_subset_left inter_subset_left exact Disjoint.mono inter_subset_right inter_subset_right (disjoint_disjointed _ hij) · intro i exact measurable_image_of_fderivWithin (hs.inter (u_meas i)) (fun x hx => (hf' x hx.1).mono inter_subset_left) (hf.mono inter_subset_left) /-- Change of variable formula for differentiable functions, set version: if a function `f` is injective and differentiable on a measurable set `s`, then the measure of `f '' s` is given by the integral of `|(f' x).det|` on `s`. Note that the measurability of `f '' s` is given by `measurable_image_of_fderivWithin`. -/ theorem lintegral_abs_det_fderiv_eq_addHaar_image (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = μ (f '' s) := le_antisymm (lintegral_abs_det_fderiv_le_addHaar_image μ hs hf' hf) (addHaar_image_le_lintegral_abs_det_fderiv μ hs hf') /-- Change of variable formula for differentiable functions, set version: if a function `f` is injective and differentiable on a null measurable set `s`, then the measure of `f '' s` is given by the integral of `|(f' x).det|` on `s`. Note that the null-measurability of `f '' s` is given by `nullMeasurable_image_of_fderivWithin`. -/ theorem lintegral_abs_det_fderiv_eq_addHaar_image₀ (hs : NullMeasurableSet s μ) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = μ (f '' s) := by rcases hs.exists_measurable_subset_ae_eq with ⟨t, ts, ht, t_eq_s⟩ have A : μ (f '' s) = μ (f '' t) := by apply measure_congr have : s = t ∪ (s \ t) := by simp [union_eq_self_of_subset_left ts] rw [this, image_union] refine union_ae_eq_left_of_ae_eq_empty (ae_eq_empty.mpr ?_) apply addHaar_image_eq_zero_of_differentiableOn_of_addHaar_eq_zero _ (fun x hx ↦ ?_) (ae_eq_set.1 t_eq_s).2 exact (hf' x hx.1).differentiableWithinAt.mono diff_subset have B : (∫⁻ x in s, ENNReal.ofReal |(f' x).det| ∂μ) = (∫⁻ x in t, ENNReal.ofReal |(f' x).det| ∂μ) := setLIntegral_congr t_eq_s.symm rw [A, B, lintegral_abs_det_fderiv_eq_addHaar_image _ ht _ (hf.mono ts)] intro x hx exact (hf' x (ts hx)).mono ts /-- Change of variable formula for differentiable functions, set version: if a function `f` is injective and differentiable on a null measurable set `s`, then the pushforward of the measure with density `|(f' x).det|` on `s` is the Lebesgue measure on the image set. -/ theorem map_withDensity_abs_det_fderiv_eq_addHaar (hs : NullMeasurableSet s μ) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : Measure.map f ((μ.restrict s).withDensity fun x => ENNReal.ofReal |(f' x).det|) = μ.restrict (f '' s) := by have h'f : AEMeasurable f (μ.restrict s) := by apply ContinuousOn.aemeasurable₀ (fun x hx ↦ ?_) hs exact (hf' x hx).differentiableWithinAt.continuousWithinAt have h''f : AEMeasurable f ((μ.restrict s).withDensity fun x => ENNReal.ofReal |(f' x).det|) := by apply h'f.mono_ac exact withDensity_absolutelyContinuous _ _ apply Measure.ext fun t ht => ?_ have h't : NullMeasurableSet (f ⁻¹' t) (μ.restrict s) := h'f.nullMeasurableSet_preimage ht rw [map_apply_of_aemeasurable h''f ht, withDensity_apply₀ _ h't, Measure.restrict_apply ht, restrict_restrict₀ h't, lintegral_abs_det_fderiv_eq_addHaar_image₀ μ ((nullMeasurableSet_restrict hs).1 h't) (fun x hx => (hf' x hx.2).mono inter_subset_right) (hf.mono inter_subset_right), image_preimage_inter] /-- Change of variable formula for differentiable functions, set version: if a function `f` is injective and differentiable on a measurable set `s`, then the pushforward of the measure with density `|(f' x).det|` on `s` is the Lebesgue measure on the image set. This version is expressed in terms of the restricted function `s.restrict f`. For a version for the original function, see `map_withDensity_abs_det_fderiv_eq_addHaar`. -/ theorem restrict_map_withDensity_abs_det_fderiv_eq_addHaar (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) : Measure.map (s.restrict f) (comap (↑) (μ.withDensity fun x => ENNReal.ofReal |(f' x).det|)) = μ.restrict (f '' s) := by obtain ⟨u, u_meas, uf⟩ : ∃ u, Measurable u ∧ EqOn u f s := by classical refine ⟨piecewise s f 0, ?_, piecewise_eqOn _ _ _⟩ refine ContinuousOn.measurable_piecewise ?_ continuous_zero.continuousOn hs have : DifferentiableOn ℝ f s := fun x hx => (hf' x hx).differentiableWithinAt exact this.continuousOn have u' : ∀ x ∈ s, HasFDerivWithinAt u (f' x) s x := fun x hx => (hf' x hx).congr (fun y hy => uf hy) (uf hx) set F : s → E := u ∘ (↑) with hF have A : Measure.map F (comap (↑) (μ.withDensity fun x => ENNReal.ofReal |(f' x).det|)) = μ.restrict (u '' s) := by rw [hF, ← Measure.map_map u_meas measurable_subtype_coe, map_comap_subtype_coe hs, restrict_withDensity hs] exact map_withDensity_abs_det_fderiv_eq_addHaar μ hs.nullMeasurableSet u' (hf.congr uf.symm) rw [uf.image_eq] at A have : F = s.restrict f := by ext x exact uf x.2 rwa [this] at A /-! ### Change of variable formulas in integrals -/ /- Change of variable formula for differentiable functions: if a function `f` is injective and differentiable on a measurable set `s`, then the Lebesgue integral of a function `g : E → ℝ≥0∞` on `f '' s` coincides with the integral of `|(f' x).det| * g ∘ f` on `s`. Note that the measurability of `f '' s` is given by `measurable_image_of_fderivWithin`. -/ theorem lintegral_image_eq_lintegral_abs_det_fderiv_mul (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) (g : E → ℝ≥0∞) : ∫⁻ x in f '' s, g x ∂μ = ∫⁻ x in s, ENNReal.ofReal |(f' x).det| * g (f x) ∂μ := by rw [← restrict_map_withDensity_abs_det_fderiv_eq_addHaar μ hs hf' hf, (measurableEmbedding_of_fderivWithin hs hf' hf).lintegral_map] simp only [Set.restrict_apply, ← Function.comp_apply (f := g)] rw [← (MeasurableEmbedding.subtype_coe hs).lintegral_map, map_comap_subtype_coe hs, setLIntegral_withDensity_eq_setLIntegral_mul_non_measurable₀ _ _ _ hs] · simp only [Pi.mul_apply] · simp only [eventually_true, ENNReal.ofReal_lt_top] · exact aemeasurable_ofReal_abs_det_fderivWithin μ hs hf' /-- Integrability in the change of variable formula for differentiable functions: if a function `f` is injective and differentiable on a measurable set `s`, then a function `g : E → F` is integrable on `f '' s` if and only if `|(f' x).det| • g ∘ f` is integrable on `s`. -/ theorem integrableOn_image_iff_integrableOn_abs_det_fderiv_smul (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) (g : E → F) : IntegrableOn g (f '' s) μ ↔ IntegrableOn (fun x => |(f' x).det| • g (f x)) s μ := by rw [IntegrableOn, ← restrict_map_withDensity_abs_det_fderiv_eq_addHaar μ hs hf' hf, (measurableEmbedding_of_fderivWithin hs hf' hf).integrable_map_iff] simp only [Set.restrict_eq, ← Function.comp_assoc, ENNReal.ofReal] rw [← (MeasurableEmbedding.subtype_coe hs).integrable_map_iff, map_comap_subtype_coe hs, restrict_withDensity hs, integrable_withDensity_iff_integrable_coe_smul₀] · simp_rw [IntegrableOn, Real.coe_toNNReal _ (abs_nonneg _), Function.comp_apply] · exact aemeasurable_toNNReal_abs_det_fderivWithin μ hs hf' /-- Change of variable formula for differentiable functions: if a function `f` is injective and differentiable on a measurable set `s`, then the Bochner integral of a function `g : E → F` on `f '' s` coincides with the integral of `|(f' x).det| • g ∘ f` on `s`. -/ theorem integral_image_eq_integral_abs_det_fderiv_smul (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) (hf : InjOn f s) (g : E → F) : ∫ x in f '' s, g x ∂μ = ∫ x in s, |(f' x).det| • g (f x) ∂μ := by rw [← restrict_map_withDensity_abs_det_fderiv_eq_addHaar μ hs hf' hf, (measurableEmbedding_of_fderivWithin hs hf' hf).integral_map] simp only [Set.restrict_apply, ← Function.comp_apply (f := g), ENNReal.ofReal] rw [← (MeasurableEmbedding.subtype_coe hs).integral_map, map_comap_subtype_coe hs, setIntegral_withDensity_eq_setIntegral_smul₀ (aemeasurable_toNNReal_abs_det_fderivWithin μ hs hf') _ hs] congr with x rw [NNReal.smul_def, Real.coe_toNNReal _ (abs_nonneg (f' x).det)] theorem integral_target_eq_integral_abs_det_fderiv_smul {f : OpenPartialHomeomorph E E} (hf' : ∀ x ∈ f.source, HasFDerivAt f (f' x) x) (g : E → F) : ∫ x in f.target, g x ∂μ = ∫ x in f.source, |(f' x).det| • g (f x) ∂μ := by have : f '' f.source = f.target := PartialEquiv.image_source_eq_target f.toPartialEquiv rw [← this] apply integral_image_eq_integral_abs_det_fderiv_smul μ f.open_source.measurableSet _ f.injOn intro x hx exact (hf' x hx).hasFDerivWithinAt section withDensity lemma _root_.MeasurableEmbedding.withDensity_ofReal_comap_apply_eq_integral_abs_det_fderiv_mul (hs : MeasurableSet s) (hf : MeasurableEmbedding f) {g : E → ℝ} (hg : ∀ᵐ x ∂μ, x ∈ f '' s → 0 ≤ g x) (hg_int : IntegrableOn g (f '' s) μ) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : (μ.withDensity (fun x ↦ ENNReal.ofReal (g x))).comap f s = ENNReal.ofReal (∫ x in s, |(f' x).det| * g (f x) ∂μ) := by rw [Measure.comap_apply f hf.injective (fun t ht ↦ hf.measurableSet_image' ht) _ hs, withDensity_apply _ (hf.measurableSet_image' hs), ← ofReal_integral_eq_lintegral_ofReal hg_int ((ae_restrict_iff' (hf.measurableSet_image' hs)).mpr hg), integral_image_eq_integral_abs_det_fderiv_smul μ hs hf' hf.injective.injOn] simp_rw [smul_eq_mul] lemma _root_.MeasurableEquiv.withDensity_ofReal_map_symm_apply_eq_integral_abs_det_fderiv_mul (hs : MeasurableSet s) (f : E ≃ᵐ E) {g : E → ℝ} (hg : ∀ᵐ x ∂μ, x ∈ f '' s → 0 ≤ g x) (hg_int : IntegrableOn g (f '' s) μ) (hf' : ∀ x ∈ s, HasFDerivWithinAt f (f' x) s x) : (μ.withDensity (fun x ↦ ENNReal.ofReal (g x))).map f.symm s = ENNReal.ofReal (∫ x in s, |(f' x).det| * g (f x) ∂μ) := by rw [MeasurableEquiv.map_symm, MeasurableEmbedding.withDensity_ofReal_comap_apply_eq_integral_abs_det_fderiv_mul μ hs f.measurableEmbedding hg hg_int hf'] end withDensity end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/AEEqFun.lean
import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable import Mathlib.MeasureTheory.Integral.Lebesgue.Add import Mathlib.Order.Filter.Germ.Basic import Mathlib.Topology.ContinuousMap.Algebra /-! # Almost everywhere equal functions We build a space of equivalence classes of functions, where two functions are treated as identical if they are almost everywhere equal. We form the set of equivalence classes under the relation of being almost everywhere equal, which is sometimes known as the `L⁰` space. To use this space as a basis for the `L^p` spaces and for the Bochner integral, we consider equivalence classes of strongly measurable functions (or, equivalently, of almost everywhere strongly measurable functions.) See `Mathlib/MeasureTheory/Function/L1Space/AEEqFun.lean` for `L¹` space. ## Notation * `α →ₘ[μ] β` is the type of `L⁰` space, where `α` is a measurable space, `β` is a topological space, and `μ` is a measure on `α`. `f : α →ₘ β` is a "function" in `L⁰`. In comments, `[f]` is also used to denote an `L⁰` function. `ₘ` can be typed as `\_m`. Sometimes it is shown as a box if font is missing. ## Main statements * The linear structure of `L⁰` : Addition and scalar multiplication are defined on `L⁰` in the natural way, i.e., `[f] + [g] := [f + g]`, `c • [f] := [c • f]`. So defined, `α →ₘ β` inherits the linear structure of `β`. For example, if `β` is a module, then `α →ₘ β` is a module over the same ring. See `mk_add_mk`, `neg_mk`, `mk_sub`, `smul_mk`, `coeFn_add`, `coeFn_neg`, `coeFn_sub`, `coeFn_smul` * The order structure of `L⁰` : `≤` can be defined in a similar way: `[f] ≤ [g]` if `f a ≤ g a` for almost all `a` in domain. And `α →ₘ β` inherits the preorder and partial order of `β`. TODO: Define `sup` and `inf` on `L⁰` so that it forms a lattice. It seems that `β` must be a linear order, since otherwise `f ⊔ g` may not be a measurable function. ## Implementation notes * `f.cast`: To find a representative of `f : α →ₘ β`, use the coercion `(f : α → β)`, which is implemented as `f.toFun`. For each operation `op` in `L⁰`, there is a lemma called `coe_fn_op`, characterizing, say, `(f op g : α → β)`. * `AEEqFun.mk`: To constructs an `L⁰` function `α →ₘ β` from an almost everywhere strongly measurable function `f : α → β`, use `ae_eq_fun.mk` * `comp`: Use `comp g f` to get `[g ∘ f]` from `g : β → γ` and `[f] : α →ₘ γ` when `g` is continuous. Use `compMeasurable` if `g` is only measurable (this requires the target space to be second countable). * `comp₂`: Use `comp₂ g f₁ f₂` to get `[fun a ↦ g (f₁ a) (f₂ a)]`. For example, `[f + g]` is `comp₂ (+)` ## Tags function space, almost everywhere equal, `L⁰`, ae_eq_fun -/ -- Guard against import creep assert_not_exists InnerProductSpace noncomputable section open Topology Set Filter TopologicalSpace ENNReal EMetric MeasureTheory Function variable {α β γ δ : Type*} [MeasurableSpace α] {μ ν : Measure α} namespace MeasureTheory section MeasurableSpace variable [TopologicalSpace β] variable (β) /-- The equivalence relation of being almost everywhere equal for almost everywhere strongly measurable functions. -/ def Measure.aeEqSetoid (μ : Measure α) : Setoid { f : α → β // AEStronglyMeasurable f μ } := ⟨fun f g => (f : α → β) =ᵐ[μ] g, fun {f} => ae_eq_refl f.val, fun {_ _} => ae_eq_symm, fun {_ _ _} => ae_eq_trans⟩ variable (α) /-- The space of equivalence classes of almost everywhere strongly measurable functions, where two strongly measurable functions are equivalent if they agree almost everywhere, i.e., they differ on a set of measure `0`. -/ def AEEqFun (μ : Measure α) : Type _ := Quotient (μ.aeEqSetoid β) variable {α β} @[inherit_doc MeasureTheory.AEEqFun] notation:25 α " →ₘ[" μ "] " β => AEEqFun α β μ end MeasurableSpace variable [TopologicalSpace δ] namespace AEEqFun section variable [TopologicalSpace β] /-- Construct the equivalence class `[f]` of an almost everywhere measurable function `f`, based on the equivalence relation of being almost everywhere equal. -/ def mk {β : Type*} [TopologicalSpace β] (f : α → β) (hf : AEStronglyMeasurable f μ) : α →ₘ[μ] β := Quotient.mk'' ⟨f, hf⟩ open scoped Classical in /-- Coercion from a space of equivalence classes of almost everywhere strongly measurable functions to functions. We ensure that if `f` has a constant representative, then we choose that one. -/ @[coe] def cast (f : α →ₘ[μ] β) : α → β := if h : ∃ (b : β), f = mk (const α b) aestronglyMeasurable_const then const α <| Classical.choose h else AEStronglyMeasurable.mk _ (Quotient.out f : { f : α → β // AEStronglyMeasurable f μ }).2 /-- A measurable representative of an `AEEqFun` [f] -/ instance instCoeFun : CoeFun (α →ₘ[μ] β) fun _ => α → β := ⟨cast⟩ @[fun_prop] protected theorem stronglyMeasurable (f : α →ₘ[μ] β) : StronglyMeasurable f := by simp only [cast] split_ifs with h · exact stronglyMeasurable_const · apply AEStronglyMeasurable.stronglyMeasurable_mk @[fun_prop] protected theorem aestronglyMeasurable (f : α →ₘ[μ] β) : AEStronglyMeasurable f μ := f.stronglyMeasurable.aestronglyMeasurable @[fun_prop] protected theorem measurable [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] (f : α →ₘ[μ] β) : Measurable f := f.stronglyMeasurable.measurable @[fun_prop] protected theorem aemeasurable [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] (f : α →ₘ[μ] β) : AEMeasurable f μ := f.measurable.aemeasurable @[simp] theorem quot_mk_eq_mk (f : α → β) (hf) : (Quot.mk (@Setoid.r _ <| μ.aeEqSetoid β) ⟨f, hf⟩ : α →ₘ[μ] β) = mk f hf := rfl @[simp] theorem mk_eq_mk {f g : α → β} {hf hg} : (mk f hf : α →ₘ[μ] β) = mk g hg ↔ f =ᵐ[μ] g := Quotient.eq'' @[simp] theorem mk_coeFn (f : α →ₘ[μ] β) : mk f f.aestronglyMeasurable = f := by conv_lhs => simp only [cast] split_ifs with h · exact Classical.choose_spec h |>.symm conv_rhs => rw [← Quotient.out_eq' f] rw [← mk, mk_eq_mk] exact (AEStronglyMeasurable.ae_eq_mk _).symm @[ext] theorem ext {f g : α →ₘ[μ] β} (h : f =ᵐ[μ] g) : f = g := by rwa [← f.mk_coeFn, ← g.mk_coeFn, mk_eq_mk] theorem coeFn_mk (f : α → β) (hf) : (mk f hf : α →ₘ[μ] β) =ᵐ[μ] f := by rw [← mk_eq_mk (hf := AEEqFun.aestronglyMeasurable ..) (hg := hf), mk_coeFn] @[elab_as_elim] theorem induction_on (f : α →ₘ[μ] β) {p : (α →ₘ[μ] β) → Prop} (H : ∀ f hf, p (mk f hf)) : p f := Quotient.inductionOn' f <| Subtype.forall.2 H @[elab_as_elim] theorem induction_on₂ {α' β' : Type*} [MeasurableSpace α'] [TopologicalSpace β'] {μ' : Measure α'} (f : α →ₘ[μ] β) (f' : α' →ₘ[μ'] β') {p : (α →ₘ[μ] β) → (α' →ₘ[μ'] β') → Prop} (H : ∀ f hf f' hf', p (mk f hf) (mk f' hf')) : p f f' := induction_on f fun f hf => induction_on f' <| H f hf @[elab_as_elim] theorem induction_on₃ {α' β' : Type*} [MeasurableSpace α'] [TopologicalSpace β'] {μ' : Measure α'} {α'' β'' : Type*} [MeasurableSpace α''] [TopologicalSpace β''] {μ'' : Measure α''} (f : α →ₘ[μ] β) (f' : α' →ₘ[μ'] β') (f'' : α'' →ₘ[μ''] β'') {p : (α →ₘ[μ] β) → (α' →ₘ[μ'] β') → (α'' →ₘ[μ''] β'') → Prop} (H : ∀ f hf f' hf' f'' hf'', p (mk f hf) (mk f' hf') (mk f'' hf'')) : p f f' f'' := induction_on f fun f hf => induction_on₂ f' f'' <| H f hf end /-! ### Composition of an a.e. equal function with a (quasi-)measure-preserving function -/ section compQuasiMeasurePreserving variable [TopologicalSpace γ] [MeasurableSpace β] {ν : MeasureTheory.Measure β} {f : α → β} open MeasureTheory.Measure (QuasiMeasurePreserving) /-- Composition of an almost everywhere equal function and a quasi-measure-preserving function. See also `AEEqFun.compMeasurePreserving`. -/ def compQuasiMeasurePreserving (g : β →ₘ[ν] γ) (f : α → β) (hf : QuasiMeasurePreserving f μ ν) : α →ₘ[μ] γ := Quotient.liftOn' g (fun g ↦ mk (g ∘ f) <| g.2.comp_quasiMeasurePreserving hf) fun _ _ h ↦ mk_eq_mk.2 <| h.comp_tendsto hf.tendsto_ae @[simp] theorem compQuasiMeasurePreserving_mk {g : β → γ} (hg : AEStronglyMeasurable g ν) (hf : QuasiMeasurePreserving f μ ν) : (mk g hg).compQuasiMeasurePreserving f hf = mk (g ∘ f) (hg.comp_quasiMeasurePreserving hf) := rfl theorem compQuasiMeasurePreserving_eq_mk (g : β →ₘ[ν] γ) (hf : QuasiMeasurePreserving f μ ν) : g.compQuasiMeasurePreserving f hf = mk (g ∘ f) (g.aestronglyMeasurable.comp_quasiMeasurePreserving hf) := by rw [← compQuasiMeasurePreserving_mk g.aestronglyMeasurable hf, mk_coeFn] theorem coeFn_compQuasiMeasurePreserving (g : β →ₘ[ν] γ) (hf : QuasiMeasurePreserving f μ ν) : g.compQuasiMeasurePreserving f hf =ᵐ[μ] g ∘ f := by rw [compQuasiMeasurePreserving_eq_mk] apply coeFn_mk end compQuasiMeasurePreserving section compMeasurePreserving variable [TopologicalSpace γ] [MeasurableSpace β] {ν : MeasureTheory.Measure β} {f : α → β} {g : β → γ} /-- Composition of an almost everywhere equal function and a quasi-measure-preserving function. This is an important special case of `AEEqFun.compQuasiMeasurePreserving`. We use a separate definition so that lemmas that need `f` to be measure preserving can be `@[simp]` lemmas. -/ def compMeasurePreserving (g : β →ₘ[ν] γ) (f : α → β) (hf : MeasurePreserving f μ ν) : α →ₘ[μ] γ := g.compQuasiMeasurePreserving f hf.quasiMeasurePreserving @[simp] theorem compMeasurePreserving_mk (hg : AEStronglyMeasurable g ν) (hf : MeasurePreserving f μ ν) : (mk g hg).compMeasurePreserving f hf = mk (g ∘ f) (hg.comp_quasiMeasurePreserving hf.quasiMeasurePreserving) := rfl theorem compMeasurePreserving_eq_mk (g : β →ₘ[ν] γ) (hf : MeasurePreserving f μ ν) : g.compMeasurePreserving f hf = mk (g ∘ f) (g.aestronglyMeasurable.comp_quasiMeasurePreserving hf.quasiMeasurePreserving) := g.compQuasiMeasurePreserving_eq_mk _ theorem coeFn_compMeasurePreserving (g : β →ₘ[ν] γ) (hf : MeasurePreserving f μ ν) : g.compMeasurePreserving f hf =ᵐ[μ] g ∘ f := g.coeFn_compQuasiMeasurePreserving _ end compMeasurePreserving variable [TopologicalSpace β] [TopologicalSpace γ] /-- Given a continuous function `g : β → γ`, and an almost everywhere equal function `[f] : α →ₘ β`, return the equivalence class of `g ∘ f`, i.e., the almost everywhere equal function `[g ∘ f] : α →ₘ γ`. -/ def comp (g : β → γ) (hg : Continuous g) (f : α →ₘ[μ] β) : α →ₘ[μ] γ := Quotient.liftOn' f (fun f => mk (g ∘ (f : α → β)) (hg.comp_aestronglyMeasurable f.2)) fun _ _ H => mk_eq_mk.2 <| H.fun_comp g @[simp] theorem comp_mk (g : β → γ) (hg : Continuous g) (f : α → β) (hf) : comp g hg (mk f hf : α →ₘ[μ] β) = mk (g ∘ f) (hg.comp_aestronglyMeasurable hf) := rfl @[simp] theorem comp_id (f : α →ₘ[μ] β) : comp id (continuous_id) f = f := by rcases f; rfl @[simp] theorem comp_comp (g : γ → δ) (g' : β → γ) (hg : Continuous g) (hg' : Continuous g') (f : α →ₘ[μ] β) : comp g hg (comp g' hg' f) = comp (g ∘ g') (hg.comp hg') f := by rcases f; rfl theorem comp_eq_mk (g : β → γ) (hg : Continuous g) (f : α →ₘ[μ] β) : comp g hg f = mk (g ∘ f) (hg.comp_aestronglyMeasurable f.aestronglyMeasurable) := by rw [← comp_mk g hg f f.aestronglyMeasurable, mk_coeFn] theorem coeFn_comp (g : β → γ) (hg : Continuous g) (f : α →ₘ[μ] β) : comp g hg f =ᵐ[μ] g ∘ f := by rw [comp_eq_mk] apply coeFn_mk theorem comp_compQuasiMeasurePreserving {β : Type*} [MeasurableSpace β] {ν} (g : γ → δ) (hg : Continuous g) (f : β →ₘ[ν] γ) {φ : α → β} (hφ : Measure.QuasiMeasurePreserving φ μ ν) : (comp g hg f).compQuasiMeasurePreserving φ hφ = comp g hg (f.compQuasiMeasurePreserving φ hφ) := by rcases f; rfl section CompMeasurable variable [MeasurableSpace β] [PseudoMetrizableSpace β] [BorelSpace β] [MeasurableSpace γ] [PseudoMetrizableSpace γ] [OpensMeasurableSpace γ] [SecondCountableTopology γ] /-- Given a measurable function `g : β → γ`, and an almost everywhere equal function `[f] : α →ₘ β`, return the equivalence class of `g ∘ f`, i.e., the almost everywhere equal function `[g ∘ f] : α →ₘ γ`. This requires that `γ` has a second countable topology. -/ def compMeasurable (g : β → γ) (hg : Measurable g) (f : α →ₘ[μ] β) : α →ₘ[μ] γ := Quotient.liftOn' f (fun f' => mk (g ∘ (f' : α → β)) (hg.comp_aemeasurable f'.2.aemeasurable).aestronglyMeasurable) fun _ _ H => mk_eq_mk.2 <| H.fun_comp g @[simp] theorem compMeasurable_mk (g : β → γ) (hg : Measurable g) (f : α → β) (hf : AEStronglyMeasurable f μ) : compMeasurable g hg (mk f hf : α →ₘ[μ] β) = mk (g ∘ f) (hg.comp_aemeasurable hf.aemeasurable).aestronglyMeasurable := rfl theorem compMeasurable_eq_mk (g : β → γ) (hg : Measurable g) (f : α →ₘ[μ] β) : compMeasurable g hg f = mk (g ∘ f) (hg.comp_aemeasurable f.aemeasurable).aestronglyMeasurable := by rw [← compMeasurable_mk g hg f f.aestronglyMeasurable, mk_coeFn] theorem coeFn_compMeasurable (g : β → γ) (hg : Measurable g) (f : α →ₘ[μ] β) : compMeasurable g hg f =ᵐ[μ] g ∘ f := by rw [compMeasurable_eq_mk] apply coeFn_mk end CompMeasurable /-- The class of `x ↦ (f x, g x)`. -/ def pair (f : α →ₘ[μ] β) (g : α →ₘ[μ] γ) : α →ₘ[μ] β × γ := Quotient.liftOn₂' f g (fun f g => mk (fun x => (f.1 x, g.1 x)) (f.2.prodMk g.2)) fun _f _g _f' _g' Hf Hg => mk_eq_mk.2 <| Hf.prodMk Hg @[simp] theorem pair_mk_mk (f : α → β) (hf) (g : α → γ) (hg) : (mk f hf : α →ₘ[μ] β).pair (mk g hg) = mk (fun x => (f x, g x)) (hf.prodMk hg) := rfl theorem pair_eq_mk (f : α →ₘ[μ] β) (g : α →ₘ[μ] γ) : f.pair g = mk (fun x => (f x, g x)) (f.aestronglyMeasurable.prodMk g.aestronglyMeasurable) := by simp only [← pair_mk_mk, mk_coeFn, f.aestronglyMeasurable, g.aestronglyMeasurable] theorem coeFn_pair (f : α →ₘ[μ] β) (g : α →ₘ[μ] γ) : f.pair g =ᵐ[μ] fun x => (f x, g x) := by rw [pair_eq_mk] apply coeFn_mk /-- Given a continuous function `g : β → γ → δ`, and almost everywhere equal functions `[f₁] : α →ₘ β` and `[f₂] : α →ₘ γ`, return the equivalence class of the function `fun a => g (f₁ a) (f₂ a)`, i.e., the almost everywhere equal function `[fun a => g (f₁ a) (f₂ a)] : α →ₘ γ` -/ def comp₂ (g : β → γ → δ) (hg : Continuous (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : α →ₘ[μ] δ := comp _ hg (f₁.pair f₂) @[simp] theorem comp₂_mk_mk (g : β → γ → δ) (hg : Continuous (uncurry g)) (f₁ : α → β) (f₂ : α → γ) (hf₁ hf₂) : comp₂ g hg (mk f₁ hf₁ : α →ₘ[μ] β) (mk f₂ hf₂) = mk (fun a => g (f₁ a) (f₂ a)) (hg.comp_aestronglyMeasurable (hf₁.prodMk hf₂)) := rfl theorem comp₂_eq_pair (g : β → γ → δ) (hg : Continuous (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : comp₂ g hg f₁ f₂ = comp _ hg (f₁.pair f₂) := rfl theorem comp₂_eq_mk (g : β → γ → δ) (hg : Continuous (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : comp₂ g hg f₁ f₂ = mk (fun a => g (f₁ a) (f₂ a)) (hg.comp_aestronglyMeasurable (f₁.aestronglyMeasurable.prodMk f₂.aestronglyMeasurable)) := by rw [comp₂_eq_pair, pair_eq_mk, comp_mk]; rfl theorem coeFn_comp₂ (g : β → γ → δ) (hg : Continuous (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : comp₂ g hg f₁ f₂ =ᵐ[μ] fun a => g (f₁ a) (f₂ a) := by rw [comp₂_eq_mk] apply coeFn_mk section variable [MeasurableSpace β] [PseudoMetrizableSpace β] [BorelSpace β] [MeasurableSpace γ] [PseudoMetrizableSpace γ] [BorelSpace γ] [SecondCountableTopologyEither β γ] [MeasurableSpace δ] [PseudoMetrizableSpace δ] [OpensMeasurableSpace δ] [SecondCountableTopology δ] /-- Given a measurable function `g : β → γ → δ`, and almost everywhere equal functions `[f₁] : α →ₘ β` and `[f₂] : α →ₘ γ`, return the equivalence class of the function `fun a => g (f₁ a) (f₂ a)`, i.e., the almost everywhere equal function `[fun a => g (f₁ a) (f₂ a)] : α →ₘ γ`. This requires `δ` to have second-countable topology. -/ def comp₂Measurable (g : β → γ → δ) (hg : Measurable (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : α →ₘ[μ] δ := compMeasurable _ hg (f₁.pair f₂) @[simp] theorem comp₂Measurable_mk_mk (g : β → γ → δ) (hg : Measurable (uncurry g)) (f₁ : α → β) (f₂ : α → γ) (hf₁ hf₂) : comp₂Measurable g hg (mk f₁ hf₁ : α →ₘ[μ] β) (mk f₂ hf₂) = mk (fun a => g (f₁ a) (f₂ a)) (hg.comp_aemeasurable (hf₁.aemeasurable.prodMk hf₂.aemeasurable)).aestronglyMeasurable := rfl theorem comp₂Measurable_eq_pair (g : β → γ → δ) (hg : Measurable (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : comp₂Measurable g hg f₁ f₂ = compMeasurable _ hg (f₁.pair f₂) := rfl theorem comp₂Measurable_eq_mk (g : β → γ → δ) (hg : Measurable (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : comp₂Measurable g hg f₁ f₂ = mk (fun a => g (f₁ a) (f₂ a)) (hg.comp_aemeasurable (f₁.aemeasurable.prodMk f₂.aemeasurable)).aestronglyMeasurable := by rw [comp₂Measurable_eq_pair, pair_eq_mk, compMeasurable_mk]; rfl theorem coeFn_comp₂Measurable (g : β → γ → δ) (hg : Measurable (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : comp₂Measurable g hg f₁ f₂ =ᵐ[μ] fun a => g (f₁ a) (f₂ a) := by rw [comp₂Measurable_eq_mk] apply coeFn_mk end /-- Interpret `f : α →ₘ[μ] β` as a germ at `ae μ` forgetting that `f` is almost everywhere strongly measurable. -/ def toGerm (f : α →ₘ[μ] β) : Germ (ae μ) β := Quotient.liftOn' f (fun f => ((f : α → β) : Germ (ae μ) β)) fun _ _ H => Germ.coe_eq.2 H @[simp] theorem mk_toGerm (f : α → β) (hf) : (mk f hf : α →ₘ[μ] β).toGerm = f := rfl theorem toGerm_eq (f : α →ₘ[μ] β) : f.toGerm = (f : α → β) := by rw [← mk_toGerm f f.aestronglyMeasurable, mk_coeFn] theorem toGerm_injective : Injective (toGerm : (α →ₘ[μ] β) → Germ (ae μ) β) := fun f g H => ext <| Germ.coe_eq.1 <| by rwa [← toGerm_eq, ← toGerm_eq] @[simp] theorem compQuasiMeasurePreserving_toGerm {β : Type*} [MeasurableSpace β] {f : α → β} {ν} (g : β →ₘ[ν] γ) (hf : Measure.QuasiMeasurePreserving f μ ν) : (g.compQuasiMeasurePreserving f hf).toGerm = g.toGerm.compTendsto f hf.tendsto_ae := by rcases g; rfl @[simp] theorem compMeasurePreserving_toGerm {β : Type*} [MeasurableSpace β] {f : α → β} {ν} (g : β →ₘ[ν] γ) (hf : MeasurePreserving f μ ν) : (g.compMeasurePreserving f hf).toGerm = g.toGerm.compTendsto f hf.quasiMeasurePreserving.tendsto_ae := compQuasiMeasurePreserving_toGerm _ _ theorem comp_toGerm (g : β → γ) (hg : Continuous g) (f : α →ₘ[μ] β) : (comp g hg f).toGerm = f.toGerm.map g := induction_on f fun f _ => by simp theorem compMeasurable_toGerm [MeasurableSpace β] [BorelSpace β] [PseudoMetrizableSpace β] [PseudoMetrizableSpace γ] [SecondCountableTopology γ] [MeasurableSpace γ] [OpensMeasurableSpace γ] (g : β → γ) (hg : Measurable g) (f : α →ₘ[μ] β) : (compMeasurable g hg f).toGerm = f.toGerm.map g := induction_on f fun f _ => by simp theorem comp₂_toGerm (g : β → γ → δ) (hg : Continuous (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : (comp₂ g hg f₁ f₂).toGerm = f₁.toGerm.map₂ g f₂.toGerm := induction_on₂ f₁ f₂ fun f₁ _ f₂ _ => by simp theorem comp₂Measurable_toGerm [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] [PseudoMetrizableSpace γ] [SecondCountableTopologyEither β γ] [MeasurableSpace γ] [BorelSpace γ] [PseudoMetrizableSpace δ] [SecondCountableTopology δ] [MeasurableSpace δ] [OpensMeasurableSpace δ] (g : β → γ → δ) (hg : Measurable (uncurry g)) (f₁ : α →ₘ[μ] β) (f₂ : α →ₘ[μ] γ) : (comp₂Measurable g hg f₁ f₂).toGerm = f₁.toGerm.map₂ g f₂.toGerm := induction_on₂ f₁ f₂ fun f₁ _ f₂ _ => by simp /-- Given a predicate `p` and an equivalence class `[f]`, return true if `p` holds of `f a` for almost all `a` -/ def LiftPred (p : β → Prop) (f : α →ₘ[μ] β) : Prop := f.toGerm.LiftPred p /-- Given a relation `r` and equivalence class `[f]` and `[g]`, return true if `r` holds of `(f a, g a)` for almost all `a` -/ def LiftRel (r : β → γ → Prop) (f : α →ₘ[μ] β) (g : α →ₘ[μ] γ) : Prop := f.toGerm.LiftRel r g.toGerm theorem liftRel_mk_mk {r : β → γ → Prop} {f : α → β} {g : α → γ} {hf hg} : LiftRel r (mk f hf : α →ₘ[μ] β) (mk g hg) ↔ ∀ᵐ a ∂μ, r (f a) (g a) := Iff.rfl theorem liftRel_iff_coeFn {r : β → γ → Prop} {f : α →ₘ[μ] β} {g : α →ₘ[μ] γ} : LiftRel r f g ↔ ∀ᵐ a ∂μ, r (f a) (g a) := by rw [← liftRel_mk_mk (hf := f.aestronglyMeasurable) (hg := g.aestronglyMeasurable), mk_coeFn, mk_coeFn] section Order instance instPreorder [Preorder β] : Preorder (α →ₘ[μ] β) := Preorder.lift toGerm @[simp] theorem mk_le_mk [Preorder β] {f g : α → β} (hf hg) : (mk f hf : α →ₘ[μ] β) ≤ mk g hg ↔ f ≤ᵐ[μ] g := Iff.rfl @[simp, norm_cast] theorem coeFn_le [Preorder β] {f g : α →ₘ[μ] β} : (f : α → β) ≤ᵐ[μ] g ↔ f ≤ g := liftRel_iff_coeFn.symm instance instPartialOrder [PartialOrder β] : PartialOrder (α →ₘ[μ] β) := PartialOrder.lift toGerm toGerm_injective section Lattice section Sup variable [SemilatticeSup β] [ContinuousSup β] instance instSup : Max (α →ₘ[μ] β) where max f g := AEEqFun.comp₂ (· ⊔ ·) continuous_sup f g theorem coeFn_sup (f g : α →ₘ[μ] β) : ⇑(f ⊔ g) =ᵐ[μ] fun x => f x ⊔ g x := coeFn_comp₂ _ _ _ _ protected theorem le_sup_left (f g : α →ₘ[μ] β) : f ≤ f ⊔ g := by rw [← coeFn_le] filter_upwards [coeFn_sup f g] with _ ha rw [ha] exact le_sup_left protected theorem le_sup_right (f g : α →ₘ[μ] β) : g ≤ f ⊔ g := by rw [← coeFn_le] filter_upwards [coeFn_sup f g] with _ ha rw [ha] exact le_sup_right protected theorem sup_le (f g f' : α →ₘ[μ] β) (hf : f ≤ f') (hg : g ≤ f') : f ⊔ g ≤ f' := by rw [← coeFn_le] at hf hg ⊢ filter_upwards [hf, hg, coeFn_sup f g] with _ haf hag ha_sup rw [ha_sup] exact sup_le haf hag end Sup section Inf variable [SemilatticeInf β] [ContinuousInf β] instance instInf : Min (α →ₘ[μ] β) where min f g := AEEqFun.comp₂ (· ⊓ ·) continuous_inf f g theorem coeFn_inf (f g : α →ₘ[μ] β) : ⇑(f ⊓ g) =ᵐ[μ] fun x => f x ⊓ g x := coeFn_comp₂ _ _ _ _ protected theorem inf_le_left (f g : α →ₘ[μ] β) : f ⊓ g ≤ f := by rw [← coeFn_le] filter_upwards [coeFn_inf f g] with _ ha rw [ha] exact inf_le_left protected theorem inf_le_right (f g : α →ₘ[μ] β) : f ⊓ g ≤ g := by rw [← coeFn_le] filter_upwards [coeFn_inf f g] with _ ha rw [ha] exact inf_le_right protected theorem le_inf (f' f g : α →ₘ[μ] β) (hf : f' ≤ f) (hg : f' ≤ g) : f' ≤ f ⊓ g := by rw [← coeFn_le] at hf hg ⊢ filter_upwards [hf, hg, coeFn_inf f g] with _ haf hag ha_inf rw [ha_inf] exact le_inf haf hag end Inf instance instLattice [Lattice β] [TopologicalLattice β] : Lattice (α →ₘ[μ] β) := { AEEqFun.instPartialOrder with sup := max le_sup_left := AEEqFun.le_sup_left le_sup_right := AEEqFun.le_sup_right sup_le := AEEqFun.sup_le inf := min inf_le_left := AEEqFun.inf_le_left inf_le_right := AEEqFun.inf_le_right le_inf := AEEqFun.le_inf } end Lattice end Order variable (α) /-- The equivalence class of a constant function: `[fun _ : α => b]`, based on the equivalence relation of being almost everywhere equal -/ def const (b : β) : α →ₘ[μ] β := mk (fun _ : α ↦ b) aestronglyMeasurable_const theorem coeFn_const (b : β) : (const α b : α →ₘ[μ] β) =ᵐ[μ] Function.const α b := coeFn_mk _ _ /-- If the measure is nonzero, we can strengthen `coeFn_const` to get an equality. -/ @[simp] theorem coeFn_const_eq [NeZero μ] (b : β) (x : α) : (const α b : α →ₘ[μ] β) x = b := by simp only [cast] split_ifs with h case neg => exact h.elim ⟨b, rfl⟩ have := Classical.choose_spec h set b' := Classical.choose h simp_rw [const, mk_eq_mk, EventuallyEq, ← const_def, eventually_const] at this rw [Function.const, this] variable {α} instance instInhabited [Inhabited β] : Inhabited (α →ₘ[μ] β) := ⟨const α default⟩ @[to_additive] instance instOne [One β] : One (α →ₘ[μ] β) := ⟨const α 1⟩ @[to_additive] theorem one_def [One β] : (1 : α →ₘ[μ] β) = mk (fun _ : α => 1) aestronglyMeasurable_const := rfl @[to_additive] theorem coeFn_one [One β] : ⇑(1 : α →ₘ[μ] β) =ᵐ[μ] 1 := coeFn_const .. @[to_additive (attr := simp)] theorem coeFn_one_eq [NeZero μ] [One β] {x : α} : (1 : α →ₘ[μ] β) x = 1 := coeFn_const_eq .. @[to_additive (attr := simp)] theorem one_toGerm [One β] : (1 : α →ₘ[μ] β).toGerm = 1 := rfl -- Note we set up the scalar actions before the `Monoid` structures in case we want to -- try to override the `nsmul` or `zsmul` fields in future. section SMul variable {𝕜 𝕜' : Type*} variable [SMul 𝕜 γ] [ContinuousConstSMul 𝕜 γ] variable [SMul 𝕜' γ] [ContinuousConstSMul 𝕜' γ] instance instSMul : SMul 𝕜 (α →ₘ[μ] γ) := ⟨fun c f => comp (c • ·) (continuous_id.const_smul c) f⟩ @[simp] theorem smul_mk (c : 𝕜) (f : α → γ) (hf : AEStronglyMeasurable f μ) : c • (mk f hf : α →ₘ[μ] γ) = mk (c • f) (hf.const_smul _) := rfl theorem coeFn_smul (c : 𝕜) (f : α →ₘ[μ] γ) : ⇑(c • f) =ᵐ[μ] c • ⇑f := coeFn_comp _ _ _ theorem smul_toGerm (c : 𝕜) (f : α →ₘ[μ] γ) : (c • f).toGerm = c • f.toGerm := comp_toGerm _ _ _ instance instSMulCommClass [SMulCommClass 𝕜 𝕜' γ] : SMulCommClass 𝕜 𝕜' (α →ₘ[μ] γ) := ⟨fun a b f => induction_on f fun f hf => by simp_rw [smul_mk, smul_comm]⟩ instance instIsScalarTower [SMul 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' γ] : IsScalarTower 𝕜 𝕜' (α →ₘ[μ] γ) := ⟨fun a b f => induction_on f fun f hf => by simp_rw [smul_mk, smul_assoc]⟩ instance instIsCentralScalar [SMul 𝕜ᵐᵒᵖ γ] [IsCentralScalar 𝕜 γ] : IsCentralScalar 𝕜 (α →ₘ[μ] γ) := ⟨fun a f => induction_on f fun f hf => by simp_rw [smul_mk, op_smul_eq_smul]⟩ end SMul section Mul variable [Mul γ] [ContinuousMul γ] @[to_additive] instance instMul : Mul (α →ₘ[μ] γ) := ⟨comp₂ (· * ·) continuous_mul⟩ @[to_additive (attr := simp)] theorem mk_mul_mk (f g : α → γ) (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : (mk f hf : α →ₘ[μ] γ) * mk g hg = mk (f * g) (hf.mul hg) := rfl @[to_additive] theorem coeFn_mul (f g : α →ₘ[μ] γ) : ⇑(f * g) =ᵐ[μ] f * g := coeFn_comp₂ _ _ _ _ @[to_additive (attr := simp)] theorem mul_toGerm (f g : α →ₘ[μ] γ) : (f * g).toGerm = f.toGerm * g.toGerm := comp₂_toGerm _ _ _ _ end Mul instance instAddMonoid [AddMonoid γ] [ContinuousAdd γ] : AddMonoid (α →ₘ[μ] γ) := toGerm_injective.addMonoid toGerm zero_toGerm add_toGerm fun _ _ => smul_toGerm _ _ instance instAddCommMonoid [AddCommMonoid γ] [ContinuousAdd γ] : AddCommMonoid (α →ₘ[μ] γ) := toGerm_injective.addCommMonoid toGerm zero_toGerm add_toGerm fun _ _ => smul_toGerm _ _ section Monoid variable [Monoid γ] [ContinuousMul γ] instance instPowNat : Pow (α →ₘ[μ] γ) ℕ := ⟨fun f n => comp _ (continuous_pow n) f⟩ @[simp] theorem mk_pow (f : α → γ) (hf) (n : ℕ) : (mk f hf : α →ₘ[μ] γ) ^ n = mk (f ^ n) ((_root_.continuous_pow n).comp_aestronglyMeasurable hf) := rfl theorem coeFn_pow (f : α →ₘ[μ] γ) (n : ℕ) : ⇑(f ^ n) =ᵐ[μ] (⇑f) ^ n := coeFn_comp _ _ _ @[simp] theorem pow_toGerm (f : α →ₘ[μ] γ) (n : ℕ) : (f ^ n).toGerm = f.toGerm ^ n := comp_toGerm _ _ _ @[to_additive existing] instance instMonoid : Monoid (α →ₘ[μ] γ) := toGerm_injective.monoid toGerm one_toGerm mul_toGerm pow_toGerm /-- `AEEqFun.toGerm` as a `MonoidHom`. -/ @[to_additive (attr := simps) /-- `AEEqFun.toGerm` as an `AddMonoidHom`. -/] def toGermMonoidHom : (α →ₘ[μ] γ) →* (ae μ).Germ γ where toFun := toGerm map_one' := one_toGerm map_mul' := mul_toGerm end Monoid @[to_additive existing] instance instCommMonoid [CommMonoid γ] [ContinuousMul γ] : CommMonoid (α →ₘ[μ] γ) := toGerm_injective.commMonoid toGerm one_toGerm mul_toGerm pow_toGerm section Group variable [Group γ] [IsTopologicalGroup γ] section Inv @[to_additive] instance instInv : Inv (α →ₘ[μ] γ) := ⟨comp Inv.inv continuous_inv⟩ @[to_additive (attr := simp)] theorem inv_mk (f : α → γ) (hf) : (mk f hf : α →ₘ[μ] γ)⁻¹ = mk f⁻¹ hf.inv := rfl @[to_additive] theorem coeFn_inv (f : α →ₘ[μ] γ) : ⇑f⁻¹ =ᵐ[μ] f⁻¹ := coeFn_comp _ _ _ @[to_additive] theorem inv_toGerm (f : α →ₘ[μ] γ) : f⁻¹.toGerm = f.toGerm⁻¹ := comp_toGerm _ _ _ end Inv section Div @[to_additive] instance instDiv : Div (α →ₘ[μ] γ) := ⟨comp₂ Div.div continuous_div'⟩ @[to_additive (attr := simp)] theorem mk_div (f g : α → γ) (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : mk (f / g) (hf.div hg) = (mk f hf : α →ₘ[μ] γ) / mk g hg := rfl @[to_additive] theorem coeFn_div (f g : α →ₘ[μ] γ) : ⇑(f / g) =ᵐ[μ] f / g := coeFn_comp₂ _ _ _ _ @[to_additive] theorem div_toGerm (f g : α →ₘ[μ] γ) : (f / g).toGerm = f.toGerm / g.toGerm := comp₂_toGerm _ _ _ _ end Div section ZPow instance instPowInt : Pow (α →ₘ[μ] γ) ℤ := ⟨fun f n => comp _ (continuous_zpow n) f⟩ @[simp] theorem mk_zpow (f : α → γ) (hf) (n : ℤ) : (mk f hf : α →ₘ[μ] γ) ^ n = mk (f ^ n) ((continuous_zpow n).comp_aestronglyMeasurable hf) := rfl theorem coeFn_zpow (f : α →ₘ[μ] γ) (n : ℤ) : ⇑(f ^ n) =ᵐ[μ] (⇑f) ^ n := coeFn_comp _ _ _ @[simp] theorem zpow_toGerm (f : α →ₘ[μ] γ) (n : ℤ) : (f ^ n).toGerm = f.toGerm ^ n := comp_toGerm _ _ _ end ZPow end Group instance instAddGroup [AddGroup γ] [IsTopologicalAddGroup γ] : AddGroup (α →ₘ[μ] γ) := toGerm_injective.addGroup toGerm zero_toGerm add_toGerm neg_toGerm sub_toGerm (fun _ _ => smul_toGerm _ _) fun _ _ => smul_toGerm _ _ instance instAddCommGroup [AddCommGroup γ] [IsTopologicalAddGroup γ] : AddCommGroup (α →ₘ[μ] γ) := { add_comm := add_comm } @[to_additive existing] instance instGroup [Group γ] [IsTopologicalGroup γ] : Group (α →ₘ[μ] γ) := toGerm_injective.group _ one_toGerm mul_toGerm inv_toGerm div_toGerm pow_toGerm zpow_toGerm @[to_additive existing] instance instCommGroup [CommGroup γ] [IsTopologicalGroup γ] : CommGroup (α →ₘ[μ] γ) := { mul_comm := mul_comm } section Module variable {𝕜 : Type*} instance instMulAction [Monoid 𝕜] [MulAction 𝕜 γ] [ContinuousConstSMul 𝕜 γ] : MulAction 𝕜 (α →ₘ[μ] γ) := toGerm_injective.mulAction toGerm smul_toGerm instance instDistribMulAction [Monoid 𝕜] [AddMonoid γ] [ContinuousAdd γ] [DistribMulAction 𝕜 γ] [ContinuousConstSMul 𝕜 γ] : DistribMulAction 𝕜 (α →ₘ[μ] γ) := toGerm_injective.distribMulAction (toGermAddMonoidHom : (α →ₘ[μ] γ) →+ _) fun c : 𝕜 => smul_toGerm c instance instModule [Semiring 𝕜] [AddCommMonoid γ] [ContinuousAdd γ] [Module 𝕜 γ] [ContinuousConstSMul 𝕜 γ] : Module 𝕜 (α →ₘ[μ] γ) := toGerm_injective.module 𝕜 (toGermAddMonoidHom : (α →ₘ[μ] γ) →+ _) smul_toGerm end Module open ENNReal /-- For `f : α → ℝ≥0∞`, define `∫ [f]` to be `∫ f` -/ def lintegral (f : α →ₘ[μ] ℝ≥0∞) : ℝ≥0∞ := Quotient.liftOn' f (fun f => ∫⁻ a, (f : α → ℝ≥0∞) a ∂μ) fun _ _ => lintegral_congr_ae @[simp] theorem lintegral_mk (f : α → ℝ≥0∞) (hf) : (mk f hf : α →ₘ[μ] ℝ≥0∞).lintegral = ∫⁻ a, f a ∂μ := rfl theorem lintegral_coeFn (f : α →ₘ[μ] ℝ≥0∞) : ∫⁻ a, f a ∂μ = f.lintegral := by rw [← lintegral_mk (hf := f.aestronglyMeasurable), mk_coeFn] @[simp] nonrec theorem lintegral_zero : lintegral (0 : α →ₘ[μ] ℝ≥0∞) = 0 := lintegral_zero @[simp] theorem lintegral_eq_zero_iff {f : α →ₘ[μ] ℝ≥0∞} : lintegral f = 0 ↔ f = 0 := induction_on f fun _f hf => (lintegral_eq_zero_iff' hf.aemeasurable).trans mk_eq_mk.symm theorem lintegral_add (f g : α →ₘ[μ] ℝ≥0∞) : lintegral (f + g) = lintegral f + lintegral g := induction_on₂ f g fun f hf g _ => by simp [lintegral_add_left' hf.aemeasurable] theorem lintegral_mono {f g : α →ₘ[μ] ℝ≥0∞} : f ≤ g → lintegral f ≤ lintegral g := induction_on₂ f g fun _f _ _g _ hfg => lintegral_mono_ae hfg section Abs theorem coeFn_abs {β} [TopologicalSpace β] [Lattice β] [TopologicalLattice β] [AddGroup β] [IsTopologicalAddGroup β] (f : α →ₘ[μ] β) : ⇑|f| =ᵐ[μ] fun x => |f x| := by simp_rw [abs] filter_upwards [AEEqFun.coeFn_sup f (-f), AEEqFun.coeFn_neg f] with x hx_sup hx_neg rw [hx_sup, hx_neg, Pi.neg_apply] end Abs section Star variable {R : Type*} [TopologicalSpace R] instance [Star R] [ContinuousStar R] : Star (α →ₘ[μ] R) where star f := (AEEqFun.comp _ continuous_star f) lemma coeFn_star [Star R] [ContinuousStar R] (f : α →ₘ[μ] R) : ↑(star f) =ᵐ[μ] (star f : α → R) := coeFn_comp _ (continuous_star) f instance [InvolutiveStar R] [ContinuousStar R] : InvolutiveStar (α →ₘ[μ] R) where star_involutive f := comp_comp _ _ _ _ f |>.trans <| by simp [star_involutive.comp_self] instance [Star R] [TrivialStar R] [ContinuousStar R] : TrivialStar (α →ₘ[μ] R) where star_trivial f := show comp _ _ f = f by simp [funext star_trivial, ← Function.id_def] end Star section PosPart variable [LinearOrder γ] [OrderClosedTopology γ] [Zero γ] /-- Positive part of an `AEEqFun`. -/ def posPart (f : α →ₘ[μ] γ) : α →ₘ[μ] γ := comp (fun x => max x 0) (continuous_id.max continuous_const) f @[simp] theorem posPart_mk (f : α → γ) (hf) : posPart (mk f hf : α →ₘ[μ] γ) = mk (fun x => max (f x) 0) ((continuous_id.max continuous_const).comp_aestronglyMeasurable hf) := rfl theorem coeFn_posPart (f : α →ₘ[μ] γ) : ⇑(posPart f) =ᵐ[μ] fun a => max (f a) 0 := coeFn_comp _ _ _ end PosPart section AELimit /-- The ae-limit is ae-unique. -/ theorem tendsto_ae_unique {ι : Type*} [T2Space β] {g h : α → β} {f : ι → α → β} {l : Filter ι} [l.NeBot] (hg : ∀ᵐ ω ∂μ, Tendsto (fun i => f i ω) l (𝓝 (g ω))) (hh : ∀ᵐ ω ∂μ, Tendsto (fun i => f i ω) l (𝓝 (h ω))) : g =ᵐ[μ] h := by filter_upwards [hg, hh] with ω hg1 hh1 using tendsto_nhds_unique hg1 hh1 end AELimit end AEEqFun end MeasureTheory namespace ContinuousMap open MeasureTheory variable [TopologicalSpace α] [BorelSpace α] (μ) variable [TopologicalSpace β] [SecondCountableTopologyEither α β] [PseudoMetrizableSpace β] /-- The equivalence class of `μ`-almost-everywhere measurable functions associated to a continuous map. -/ def toAEEqFun (f : C(α, β)) : α →ₘ[μ] β := AEEqFun.mk f f.continuous.aestronglyMeasurable theorem coeFn_toAEEqFun (f : C(α, β)) : f.toAEEqFun μ =ᵐ[μ] f := AEEqFun.coeFn_mk f _ variable [Group β] [IsTopologicalGroup β] /-- The `MulHom` from the group of continuous maps from `α` to `β` to the group of equivalence classes of `μ`-almost-everywhere measurable functions. -/ @[to_additive /-- The `AddHom` from the group of continuous maps from `α` to `β` to the group of equivalence classes of `μ`-almost-everywhere measurable functions. -/] def toAEEqFunMulHom : C(α, β) →* α →ₘ[μ] β where toFun := ContinuousMap.toAEEqFun μ map_one' := rfl map_mul' f g := AEEqFun.mk_mul_mk _ _ f.continuous.aestronglyMeasurable g.continuous.aestronglyMeasurable variable {𝕜 : Type*} [Semiring 𝕜] variable [TopologicalSpace γ] [PseudoMetrizableSpace γ] [AddCommGroup γ] [Module 𝕜 γ] [IsTopologicalAddGroup γ] [ContinuousConstSMul 𝕜 γ] [SecondCountableTopologyEither α γ] /-- The linear map from the group of continuous maps from `α` to `β` to the group of equivalence classes of `μ`-almost-everywhere measurable functions. -/ def toAEEqFunLinearMap : C(α, γ) →ₗ[𝕜] α →ₘ[μ] γ := { toAEEqFunAddHom μ with map_smul' := fun c f => AEEqFun.smul_mk c f f.continuous.aestronglyMeasurable } end ContinuousMap
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/FactorsThrough.lean
import Mathlib.MeasureTheory.Constructions.Polish.StronglyMeasurable import Mathlib.Probability.Process.Filtration /-! # Factorization of a map from measurability Consider `f : X → Y` and `g : X → Z` and assume that `g` is measurable with respect to the pullback along `f`. Then `g` factors through `f`, which means that (if `Z` is nonempty) there exists `h : Y → Z` such that `g = h ∘ f`. If `Z` is completely metrizable, the factorization map `h` can be taken to be measurable. This is the content of the [Doob-Dynkin lemma](https://en.wikipedia.org/wiki/Doob–Dynkin_lemma): see `exists_eq_measurable_comp`. -/ namespace MeasureTheory open Filter Filtration Set TopologicalSpace open scoped Topology variable {X Y Z : Type*} [mY : MeasurableSpace Y] {f : X → Y} {g : X → Z} section FactorsThrough /-- If a function `g` is measurable with respect to the pullback along some function `f`, then to prove `g x = g y` it is enough to prove `f x = f y`. -/ theorem _root_.Measurable.factorsThrough [MeasurableSpace Z] [MeasurableSingletonClass Z] (hg : Measurable[mY.comap f] g) : g.FactorsThrough f := by refine fun x₁ x₂ h ↦ eq_of_mem_singleton ?_ obtain ⟨s, -, hs⟩ := hg (measurableSet_singleton (g x₂)) rw [← mem_preimage, ← hs, mem_preimage, h, ← mem_preimage, hs, mem_preimage, mem_singleton_iff] /-- If a function `g` is strongly measurable with respect to the pullback along some function `f`, then to prove `g x = g y` it is enough to prove `f x = f y`. If `Z` is not empty there exists `h : Y → Z` such that `g = h ∘ f`. If `Z` is also completely metrizable, the factorization map `h` can be taken to be measurable (see `exists_eq_measurable_comp`). -/ theorem StronglyMeasurable.factorsThrough [TopologicalSpace Z] [PseudoMetrizableSpace Z] [T1Space Z] (hg : StronglyMeasurable[mY.comap f] g) : g.FactorsThrough f := by borelize Z exact hg.measurable.factorsThrough /-- If a function `g` is strongly measurable with respect to the pullback along some function `f`, then there exists some strongly measurable function `h : Y → Z` such that `g = h ∘ f`. -/ theorem StronglyMeasurable.exists_eq_measurable_comp [Nonempty Z] [TopologicalSpace Z] [IsCompletelyMetrizableSpace Z] (hg : StronglyMeasurable[mY.comap f] g) : ∃ h : Y → Z, StronglyMeasurable h ∧ g = h ∘ f := by let mX : MeasurableSpace X := mY.comap f induction g, hg using StronglyMeasurable.induction' with | const z => exact ⟨fun _ ↦ z, stronglyMeasurable_const, rfl⟩ | @pcw g₁ g₂ s hg₁ hg₂ hs h₁ h₂ => obtain ⟨t, ht, rfl⟩ := hs obtain ⟨h₁, mh₁, rfl⟩ := h₁ obtain ⟨h₂, mh₂, rfl⟩ := h₂ classical exact ⟨t.piecewise h₁ h₂, mh₁.piecewise ht mh₂, by rw [piecewise_comp]⟩ | @lim g i hg hi h₁ h₂ => choose h mh hh using h₁ refine ⟨fun y ↦ _root_.limUnder atTop (h · y), StronglyMeasurable.limUnder mh, ?_⟩ ext x rw [Function.comp_apply, Tendsto.limUnder_eq] simp_all /-- If a function `g` is measurable with respect to the pullback along some function `f`, then there exists some measurable function `h : Y → Z` such that `g = h ∘ f`. -/ theorem _root_.Measurable.exists_eq_measurable_comp [Nonempty Z] [MeasurableSpace Z] [StandardBorelSpace Z] (hg : Measurable[mY.comap f] g) : ∃ h : Y → Z, Measurable h ∧ g = h ∘ f := by letI := upgradeStandardBorel Z obtain ⟨h, mh, hh⟩ := hg.stronglyMeasurable.exists_eq_measurable_comp exact ⟨h, mh.measurable, hh⟩ end FactorsThrough variable {ι : Type*} {X : ι → Type*} [∀ i, MeasurableSpace (X i)] {f : (Π i, X i) → Z} section piLE variable [Preorder ι] {i : ι} /-- If a function is measurable with respect to the σ-algebra generated by the first coordinates, then it only depends on those first coordinates. -/ theorem _root_.Measurable.dependsOn_of_piLE [MeasurableSpace Z] [MeasurableSingletonClass Z] (hf : Measurable[piLE i] f) : DependsOn f (Iic i) := dependsOn_iff_factorsThrough.2 hf.factorsThrough /-- If a function is strongly measurable with respect to the σ-algebra generated by the first coordinates, then it only depends on those first coordinates. -/ theorem StronglyMeasurable.dependsOn_of_piLE [TopologicalSpace Z] [PseudoMetrizableSpace Z] [T1Space Z] (hf : StronglyMeasurable[piLE i] f) : DependsOn f (Iic i) := dependsOn_iff_factorsThrough.2 hf.factorsThrough end piLE section piFinset variable {s : Finset ι} /-- If a function is measurable with respect to the σ-algebra generated by the first coordinates, then it only depends on those first coordinates. -/ theorem _root_.Measurable.dependsOn_of_piFinset [MeasurableSpace Z] [MeasurableSingletonClass Z] (hf : Measurable[piFinset s] f) : DependsOn f s := dependsOn_iff_factorsThrough.2 hf.factorsThrough /-- If a function is strongly measurable with respect to the σ-algebra generated by the first coordinates, then it only depends on those first coordinates. -/ theorem StronglyMeasurable.dependsOn_of_piFinset [TopologicalSpace Z] [PseudoMetrizableSpace Z] [T1Space Z] (hf : StronglyMeasurable[piFinset s] f) : DependsOn f s := dependsOn_iff_factorsThrough.2 hf.factorsThrough end piFinset end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/UnifTight.lean
import Mathlib.MeasureTheory.Function.ConvergenceInMeasure import Mathlib.MeasureTheory.Function.UniformIntegrable /-! # Uniform tightness This file contains the definitions for uniform tightness for a family of Lp functions. It is used as a hypothesis to the version of Vitali's convergence theorem for Lp spaces that works also for spaces of infinite measure. This version of Vitali's theorem is also proved later in the file. ## Main definitions * `MeasureTheory.UnifTight`: A sequence of functions `f` is uniformly tight in `L^p` if for all `ε > 0`, there exists some measurable set `s` with finite measure such that the Lp-norm of `f i` restricted to `sᶜ` is smaller than `ε` for all `i`. ## Main results * `MeasureTheory.unifTight_finite`: a finite sequence of Lp functions is uniformly tight. * `MeasureTheory.tendsto_Lp_of_tendsto_ae`: a sequence of Lp functions which is uniformly integrable and uniformly tight converges in Lp if it converges almost everywhere. * `MeasureTheory.tendstoInMeasure_iff_tendsto_Lp`: Vitali convergence theorem: a sequence of Lp functions converges in Lp if and only if it is uniformly integrable, uniformly tight and converges in measure. ## Tags uniform integrable, uniformly tight, Vitali convergence theorem -/ namespace MeasureTheory open Set Filter Topology MeasureTheory NNReal ENNReal variable {α β ι : Type*} {m : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup β] section UnifTight /- This follows closely the `UnifIntegrable` section from `Mathlib/MeasureTheory/Functions/UniformIntegrable.lean`. -/ variable {f g : ι → α → β} {p : ℝ≥0∞} /-- A sequence of functions `f` is uniformly tight in `L^p` if for all `ε > 0`, there exists some measurable set `s` with finite measure such that the Lp-norm of `f i` restricted to `sᶜ` is smaller than `ε` for all `i`. -/ def UnifTight {_ : MeasurableSpace α} (f : ι → α → β) (p : ℝ≥0∞) (μ : Measure α) : Prop := ∀ ⦃ε : ℝ≥0⦄, 0 < ε → ∃ s : Set α, μ s ≠ ∞ ∧ ∀ i, eLpNorm (sᶜ.indicator (f i)) p μ ≤ ε theorem unifTight_iff_ennreal {_ : MeasurableSpace α} (f : ι → α → β) (p : ℝ≥0∞) (μ : Measure α) : UnifTight f p μ ↔ ∀ ⦃ε : ℝ≥0∞⦄, 0 < ε → ∃ s : Set α, μ s ≠ ∞ ∧ ∀ i, eLpNorm (sᶜ.indicator (f i)) p μ ≤ ε := by simp only [ENNReal.forall_ennreal, ENNReal.coe_pos] refine (and_iff_left ?_).symm simp only [zero_lt_top, le_top, implies_true, and_true, true_implies] use ∅; simpa only [measure_empty] using zero_ne_top theorem unifTight_iff_real {_ : MeasurableSpace α} (f : ι → α → β) (p : ℝ≥0∞) (μ : Measure α) : UnifTight f p μ ↔ ∀ ⦃ε : ℝ⦄, 0 < ε → ∃ s : Set α, μ s ≠ ∞ ∧ ∀ i, eLpNorm (sᶜ.indicator (f i)) p μ ≤ .ofReal ε := by refine ⟨fun hut rε hrε ↦ hut (Real.toNNReal_pos.mpr hrε), fun hut ε hε ↦ ?_⟩ obtain ⟨s, hμs, hfε⟩ := hut hε use s, hμs; intro i exact (hfε i).trans_eq (ofReal_coe_nnreal (p := ε)) namespace UnifTight theorem eventually_cofinite_indicator (hf : UnifTight f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∀ᶠ s in μ.cofinite.smallSets, ∀ i, eLpNorm (s.indicator (f i)) p μ ≤ ε := by by_cases hε_top : ε = ∞ · subst hε_top; simp rcases hf (pos_iff_ne_zero.2 (toNNReal_ne_zero.mpr ⟨hε,hε_top⟩)) with ⟨s, hμs, hfs⟩ refine (eventually_smallSets' ?_).2 ⟨sᶜ, ?_, fun i ↦ (coe_toNNReal hε_top) ▸ hfs i⟩ · intro s t hst ht i exact (eLpNorm_mono <| norm_indicator_le_of_subset hst _).trans (ht i) · rwa [Measure.compl_mem_cofinite, lt_top_iff_ne_top] protected theorem exists_measurableSet_indicator (hf : UnifTight f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ s, MeasurableSet s ∧ μ s < ∞ ∧ ∀ i, eLpNorm (sᶜ.indicator (f i)) p μ ≤ ε := let ⟨s, hμs, hsm, hfs⟩ := (hf.eventually_cofinite_indicator hε).exists_measurable_mem_of_smallSets ⟨sᶜ, hsm.compl, hμs, by rwa [compl_compl s]⟩ protected theorem add (hf : UnifTight f p μ) (hg : UnifTight g p μ) (hf_meas : ∀ i, AEStronglyMeasurable (f i) μ) (hg_meas : ∀ i, AEStronglyMeasurable (g i) μ) : UnifTight (f + g) p μ := fun ε hε ↦ by rcases exists_Lp_half β μ p (coe_ne_zero.mpr hε.ne') with ⟨η, hη_pos, hη⟩ by_cases hη_top : η = ∞ · replace hη := hη_top ▸ hη refine ⟨∅, (by simp), fun i ↦ ?_⟩ simp only [compl_empty, indicator_univ, Pi.add_apply] exact (hη (f i) (g i) (hf_meas i) (hg_meas i) le_top le_top).le obtain ⟨s, hμs, hsm, hfs, hgs⟩ : ∃ s ∈ μ.cofinite, MeasurableSet s ∧ (∀ i, eLpNorm (s.indicator (f i)) p μ ≤ η) ∧ (∀ i, eLpNorm (s.indicator (g i)) p μ ≤ η) := ((hf.eventually_cofinite_indicator hη_pos.ne').and (hg.eventually_cofinite_indicator hη_pos.ne')).exists_measurable_mem_of_smallSets refine ⟨sᶜ, ne_of_lt hμs, fun i ↦ ?_⟩ have η_cast : ↑η.toNNReal = η := coe_toNNReal hη_top calc eLpNorm (indicator sᶜᶜ (f i + g i)) p μ = eLpNorm (indicator s (f i) + indicator s (g i)) p μ := by rw [compl_compl, indicator_add'] _ ≤ ε := le_of_lt <| hη _ _ ((hf_meas i).indicator hsm) ((hg_meas i).indicator hsm) (η_cast ▸ hfs i) (η_cast ▸ hgs i) protected theorem neg (hf : UnifTight f p μ) : UnifTight (-f) p μ := by simp_rw [UnifTight, Pi.neg_apply, Set.indicator_neg', eLpNorm_neg] exact hf protected theorem sub (hf : UnifTight f p μ) (hg : UnifTight g p μ) (hf_meas : ∀ i, AEStronglyMeasurable (f i) μ) (hg_meas : ∀ i, AEStronglyMeasurable (g i) μ) : UnifTight (f - g) p μ := by rw [sub_eq_add_neg] exact hf.add hg.neg hf_meas fun i => (hg_meas i).neg protected theorem aeeq (hf : UnifTight f p μ) (hfg : ∀ n, f n =ᵐ[μ] g n) : UnifTight g p μ := by intro ε hε obtain ⟨s, hμs, hfε⟩ := hf hε refine ⟨s, hμs, fun n => (le_of_eq <| eLpNorm_congr_ae ?_).trans (hfε n)⟩ filter_upwards [hfg n] with x hx simp only [indicator, mem_compl_iff, hx] end UnifTight /-- If two functions agree a.e., then one is tight iff the other is tight. -/ theorem unifTight_congr_ae {g : ι → α → β} (hfg : ∀ n, f n =ᵐ[μ] g n) : UnifTight f p μ ↔ UnifTight g p μ := ⟨fun h => h.aeeq hfg, fun h => h.aeeq fun i => (hfg i).symm⟩ /-- A constant sequence is tight. -/ theorem unifTight_const {g : α → β} (hp_ne_top : p ≠ ∞) (hg : MemLp g p μ) : UnifTight (fun _ : ι => g) p μ := by intro ε hε by_cases hε_top : ε = ∞ · exact ⟨∅, (by simp), fun _ => hε_top.symm ▸ le_top⟩ obtain ⟨s, _, hμs, hgε⟩ := hg.exists_eLpNorm_indicator_compl_lt hp_ne_top (coe_ne_zero.mpr hε.ne') exact ⟨s, ne_of_lt hμs, fun _ => hgε.le⟩ /-- A single function is tight. -/ theorem unifTight_of_subsingleton [Subsingleton ι] (hp_top : p ≠ ∞) {f : ι → α → β} (hf : ∀ i, MemLp (f i) p μ) : UnifTight f p μ := fun ε hε ↦ by by_cases hε_top : ε = ∞ · exact ⟨∅, by simp, fun _ => hε_top.symm ▸ le_top⟩ by_cases hι : Nonempty ι case neg => exact ⟨∅, (by simp), fun i => False.elim <| hι <| Nonempty.intro i⟩ obtain ⟨i⟩ := hι obtain ⟨s, _, hμs, hfε⟩ := (hf i).exists_eLpNorm_indicator_compl_lt hp_top (coe_ne_zero.2 hε.ne') refine ⟨s, ne_of_lt hμs, fun j => ?_⟩ convert hfε.le /-- This lemma is less general than `MeasureTheory.unifTight_finite` which applies to all sequences indexed by a finite type. -/ private theorem unifTight_fin (hp_top : p ≠ ∞) {n : ℕ} {f : Fin n → α → β} (hf : ∀ i, MemLp (f i) p μ) : UnifTight f p μ := by revert f induction n with | zero => exact fun {f} hf ↦ unifTight_of_subsingleton hp_top hf | succ n h => intro f hfLp ε hε by_cases hε_top : ε = ∞ · exact ⟨∅, (by simp), fun _ => hε_top.symm ▸ le_top⟩ let g : Fin n → α → β := fun k => f k.castSucc have hgLp : ∀ i, MemLp (g i) p μ := fun i => hfLp i.castSucc obtain ⟨S, hμS, hFε⟩ := h hgLp hε obtain ⟨s, _, hμs, hfε⟩ := (hfLp (Fin.last n)).exists_eLpNorm_indicator_compl_lt hp_top (coe_ne_zero.2 hε.ne') refine ⟨s ∪ S, (by finiteness), fun i => ?_⟩ by_cases! hi : i.val < n · rw [show f i = g ⟨i.val, hi⟩ from rfl, compl_union, ← indicator_indicator] apply (eLpNorm_indicator_le _).trans exact hFε (Fin.castLT i hi) · obtain rfl : i = Fin.last n := Fin.ext (le_antisymm i.is_le hi) rw [compl_union, inter_comm, ← indicator_indicator] exact (eLpNorm_indicator_le _).trans hfε.le /-- A finite sequence of Lp functions is uniformly tight. -/ theorem unifTight_finite [Finite ι] (hp_top : p ≠ ∞) {f : ι → α → β} (hf : ∀ i, MemLp (f i) p μ) : UnifTight f p μ := fun ε hε ↦ by obtain ⟨n, hn⟩ := Finite.exists_equiv_fin ι set g : Fin n → α → β := f ∘ hn.some.symm have hg : ∀ i, MemLp (g i) p μ := fun _ => hf _ obtain ⟨s, hμs, hfε⟩ := unifTight_fin hp_top hg hε refine ⟨s, hμs, fun i => ?_⟩ simpa only [g, Function.comp_apply, Equiv.symm_apply_apply] using hfε (hn.some i) end UnifTight section VitaliConvergence variable {μ : Measure α} {p : ℝ≥0∞} {f : ℕ → α → β} {g : α → β} /-! Both directions and an iff version of Vitali's convergence theorem on measure spaces of not necessarily finite volume. See `Thm III.6.15` of Dunford & Schwartz, Part I (1958). -/ /- We start with the reverse direction. We only need to show that uniform tightness follows from convergence in Lp. Mathlib already has the analogous `unifIntegrable_of_tendsto_Lp` and `tendstoInMeasure_of_tendsto_eLpNorm`. -/ /-- Intermediate lemma for `unifTight_of_tendsto_Lp`. -/ private theorem unifTight_of_tendsto_Lp_zero (hp' : p ≠ ∞) (hf : ∀ n, MemLp (f n) p μ) (hf_tendsto : Tendsto (fun n ↦ eLpNorm (f n) p μ) atTop (𝓝 0)) : UnifTight f p μ := by intro ε hε rw [ENNReal.tendsto_atTop_zero] at hf_tendsto obtain ⟨N, hNε⟩ := hf_tendsto ε (by simpa only [gt_iff_lt, ENNReal.coe_pos]) let F : Fin N → α → β := fun n => f n have hF : ∀ n, MemLp (F n) p μ := fun n => hf n obtain ⟨s, hμs, hFε⟩ := unifTight_fin hp' hF hε refine ⟨s, hμs, fun n => ?_⟩ by_cases! hn : n < N · exact hFε ⟨n, hn⟩ · exact (eLpNorm_indicator_le _).trans (hNε n hn) /-- Convergence in Lp implies uniform tightness. -/ private theorem unifTight_of_tendsto_Lp (hp' : p ≠ ∞) (hf : ∀ n, MemLp (f n) p μ) (hg : MemLp g p μ) (hfg : Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0)) : UnifTight f p μ := by have : f = (fun _ => g) + fun n => f n - g := by ext1 n; simp rw [this] refine UnifTight.add ?_ ?_ (fun _ => hg.aestronglyMeasurable) fun n => (hf n).1.sub hg.aestronglyMeasurable · exact unifTight_const hp' hg · exact unifTight_of_tendsto_Lp_zero hp' (fun n => (hf n).sub hg) hfg /- Next we deal with the forward direction. The `MemLp` and `TendstoInMeasure` hypotheses are unwrapped and strengthened (by known lemmas) to also have the `StronglyMeasurable` and a.e. convergence hypotheses. The bulk of the proof is done under these stronger hypotheses. -/ /-- Bulk of the proof under strengthened hypotheses. Invoked from `tendsto_Lp_of_tendsto_ae`. -/ private theorem tendsto_Lp_of_tendsto_ae_of_meas (hp : 1 ≤ p) (hp' : p ≠ ∞) {f : ℕ → α → β} {g : α → β} (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hg' : MemLp g p μ) (hui : UnifIntegrable f p μ) (hut : UnifTight f p μ) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0) := by rw [ENNReal.tendsto_atTop_zero] intro ε hε by_cases hfinε : ε ≠ ∞; swap · rw [not_ne_iff.mp hfinε]; exact ⟨0, fun n _ => le_top⟩ by_cases hμ : μ = 0 · rw [hμ]; use 0; intro n _; rw [eLpNorm_measure_zero]; exact zero_le ε have hε' : 0 < ε / 3 := ENNReal.div_pos hε.ne' (ofNat_ne_top) -- use tightness to divide the domain into interior and exterior obtain ⟨Eg, hmEg, hμEg, hgε⟩ := MemLp.exists_eLpNorm_indicator_compl_lt hp' hg' hε'.ne' obtain ⟨Ef, hmEf, hμEf, hfε⟩ := hut.exists_measurableSet_indicator hε'.ne' have hmE := hmEf.union hmEg have hfmE := (measure_union_le Ef Eg).trans_lt (add_lt_top.mpr ⟨hμEf, hμEg⟩) set E : Set α := Ef ∪ Eg -- use uniform integrability to get control on the limit over E have hgE' := MemLp.restrict E hg' have huiE := hui.restrict E have hfgE : (∀ᵐ x ∂(μ.restrict E), Tendsto (fun n => f n x) atTop (𝓝 (g x))) := ae_restrict_of_ae hfg -- `tendsto_Lp_of_tendsto_ae_of_meas` needs to -- synthesize an argument `[IsFiniteMeasure (μ.restrict E)]`. -- It is enough to have in the context a term of `Fact (μ E < ∞)`, which is our `ffmE` below, -- which is automatically fed into `Restrict.isFiniteInstance`. have ffmE := Fact.mk hfmE have hInner := tendsto_Lp_finite_of_tendsto_ae_of_meas hp hp' hf hg hgE' huiE hfgE rw [ENNReal.tendsto_atTop_zero] at hInner -- get a sufficiently large N for given ε, and consider any n ≥ N obtain ⟨N, hfngε⟩ := hInner (ε / 3) hε' use N; intro n hn -- get interior estimates have hmfngE : AEStronglyMeasurable _ μ := (((hf n).sub hg).indicator hmE).aestronglyMeasurable have hfngEε := calc eLpNorm (E.indicator (f n - g)) p μ = eLpNorm (f n - g) p (μ.restrict E) := eLpNorm_indicator_eq_eLpNorm_restrict hmE _ ≤ ε / 3 := hfngε n hn -- get exterior estimates have hmgEc : AEStronglyMeasurable _ μ := (hg.indicator hmE.compl).aestronglyMeasurable have hgEcε := calc eLpNorm (Eᶜ.indicator g) p μ ≤ eLpNorm (Efᶜ.indicator (Egᶜ.indicator g)) p μ := by unfold E; rw [compl_union, ← indicator_indicator] _ ≤ eLpNorm (Egᶜ.indicator g) p μ := eLpNorm_indicator_le _ _ ≤ ε / 3 := hgε.le have hmfnEc : AEStronglyMeasurable _ μ := ((hf n).indicator hmE.compl).aestronglyMeasurable have hfnEcε : eLpNorm (Eᶜ.indicator (f n)) p μ ≤ ε / 3 := calc eLpNorm (Eᶜ.indicator (f n)) p μ ≤ eLpNorm (Egᶜ.indicator (Efᶜ.indicator (f n))) p μ := by unfold E; rw [compl_union, inter_comm, ← indicator_indicator] _ ≤ eLpNorm (Efᶜ.indicator (f n)) p μ := eLpNorm_indicator_le _ _ ≤ ε / 3 := hfε n have hmfngEc : AEStronglyMeasurable _ μ := (((hf n).sub hg).indicator hmE.compl).aestronglyMeasurable have hfngEcε := calc eLpNorm (Eᶜ.indicator (f n - g)) p μ = eLpNorm (Eᶜ.indicator (f n) - Eᶜ.indicator g) p μ := by rw [(Eᶜ.indicator_sub' _ _)] _ ≤ eLpNorm (Eᶜ.indicator (f n)) p μ + eLpNorm (Eᶜ.indicator g) p μ := by apply eLpNorm_sub_le (by assumption) (by assumption) hp _ ≤ ε / 3 + ε / 3 := add_le_add hfnEcε hgEcε -- finally, combine interior and exterior estimates calc eLpNorm (f n - g) p μ = eLpNorm (Eᶜ.indicator (f n - g) + E.indicator (f n - g)) p μ := by congr; exact (E.indicator_compl_add_self _).symm _ ≤ eLpNorm (indicator Eᶜ (f n - g)) p μ + eLpNorm (indicator E (f n - g)) p μ := by apply eLpNorm_add_le (by assumption) (by assumption) hp _ ≤ (ε / 3 + ε / 3) + ε / 3 := add_le_add hfngEcε hfngEε _ = ε := by simp only [ENNReal.add_thirds] /-- Lemma used in `tendsto_Lp_of_tendsto_ae`. -/ private theorem ae_tendsto_ae_congr {f f' : ℕ → α → β} {g g' : α → β} (hff' : ∀ (n : ℕ), f n =ᵐ[μ] f' n) (hgg' : g =ᵐ[μ] g') (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : ∀ᵐ x ∂μ, Tendsto (fun n => f' n x) atTop (𝓝 (g' x)) := by have hff'' := eventually_countable_forall.mpr hff' filter_upwards [hff'', hgg', hfg] with x hff'x hgg'x hfgx apply Tendsto.congr hff'x rw [← hgg'x]; exact hfgx /-- Forward direction of Vitali's convergence theorem, with a.e. instead of `InMeasure` convergence -/ theorem tendsto_Lp_of_tendsto_ae (hp : 1 ≤ p) (hp' : p ≠ ∞) {f : ℕ → α → β} {g : α → β} (haef : ∀ n, AEStronglyMeasurable (f n) μ) (hg' : MemLp g p μ) (hui : UnifIntegrable f p μ) (hut : UnifTight f p μ) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0) := by -- come up with an a.e. equal strongly measurable replacement `f` for `g` have hf := fun n => (haef n).stronglyMeasurable_mk have hff' := fun n => (haef n).ae_eq_mk (μ := μ) have hui' := hui.ae_eq hff' have hut' := hut.aeeq hff' have hg := hg'.aestronglyMeasurable.stronglyMeasurable_mk have hgg' := hg'.aestronglyMeasurable.ae_eq_mk (μ := μ) have hg'' := hg'.ae_eq hgg' have haefg' := ae_tendsto_ae_congr hff' hgg' hfg set f' := fun n => (haef n).mk (μ := μ) set g' := hg'.aestronglyMeasurable.mk (μ := μ) have haefg (n : ℕ) : f n - g =ᵐ[μ] f' n - g' := (hff' n).sub hgg' have hsnfg (n : ℕ) := eLpNorm_congr_ae (p := p) (haefg n) apply Filter.Tendsto.congr (fun n => (hsnfg n).symm) exact tendsto_Lp_of_tendsto_ae_of_meas hp hp' hf hg hg'' hui' hut' haefg' /-- Forward direction of Vitali's convergence theorem: if `f` is a sequence of uniformly integrable, uniformly tight functions that converge in measure to some function `g` in a finite measure space, then `f` converge in Lp to `g`. -/ theorem tendsto_Lp_of_tendstoInMeasure (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hg : MemLp g p μ) (hui : UnifIntegrable f p μ) (hut : UnifTight f p μ) (hfg : TendstoInMeasure μ f atTop g) : Tendsto (fun n ↦ eLpNorm (f n - g) p μ) atTop (𝓝 0) := by refine tendsto_of_subseq_tendsto fun ns hns => ?_ obtain ⟨ms, _, hms'⟩ := TendstoInMeasure.exists_seq_tendsto_ae fun ε hε => (hfg ε hε).comp hns exact ⟨ms, tendsto_Lp_of_tendsto_ae hp hp' (fun _ => hf _) hg (fun ε hε => -- `UnifIntegrable` on a subsequence let ⟨δ, hδ, hδ'⟩ := hui hε ⟨δ, hδ, fun i s hs hμs => hδ' _ s hs hμs⟩) (fun ε hε => -- `UnifTight` on a subsequence let ⟨s, hμs, hfε⟩ := hut hε ⟨s, hμs, fun i => hfε _⟩) hms'⟩ /-- **Vitali's convergence theorem** (non-finite measure version). A sequence of functions `f` converges to `g` in Lp if and only if it is uniformly integrable, uniformly tight and converges to `g` in measure. -/ theorem tendstoInMeasure_iff_tendsto_Lp (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ n, MemLp (f n) p μ) (hg : MemLp g p μ) : TendstoInMeasure μ f atTop g ∧ UnifIntegrable f p μ ∧ UnifTight f p μ ↔ Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0) where mp h := tendsto_Lp_of_tendstoInMeasure hp hp' (fun n => (hf n).1) hg h.2.1 h.2.2 h.1 mpr h := ⟨tendstoInMeasure_of_tendsto_eLpNorm (lt_of_lt_of_le zero_lt_one hp).ne' (fun n => (hf n).aestronglyMeasurable) hg.aestronglyMeasurable h, unifIntegrable_of_tendsto_Lp hp hp' hf hg h, unifTight_of_tendsto_Lp hp' hf hg h⟩ end VitaliConvergence end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SimpleFunc.lean
import Mathlib.Algebra.Order.Pi import Mathlib.Algebra.Algebra.Pi import Mathlib.MeasureTheory.Constructions.BorelSpace.Order /-! # Simple functions A function `f` from a measurable space to any type is called *simple*, if every preimage `f ⁻¹' {x}` is measurable, and the range is finite. In this file, we define simple functions and establish their basic properties; and we construct a sequence of simple functions approximating an arbitrary Borel measurable function `f : α → ℝ≥0∞`. The theorem `Measurable.ennreal_induction` shows that in order to prove something for an arbitrary measurable function into `ℝ≥0∞`, it is sufficient to show that the property holds for (multiples of) characteristic functions and is closed under addition and supremum of increasing sequences of functions. -/ noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory variable {α β γ δ : Type*} /-- A function `f` from a measurable space to any type is called *simple*, if every preimage `f ⁻¹' {x}` is measurable, and the range is finite. This structure bundles a function with these properties. -/ structure SimpleFunc.{u, v} (α : Type u) [MeasurableSpace α] (β : Type v) where /-- The underlying function -/ toFun : α → β measurableSet_fiber' : ∀ x, MeasurableSet (toFun ⁻¹' {x}) finite_range' : (Set.range toFun).Finite local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc section Measurable variable [MeasurableSpace α] instance instFunLike : FunLike (α →ₛ β) α β where coe := toFun coe_injective' | ⟨_, _, _⟩, ⟨_, _, _⟩, rfl => rfl theorem coe_injective ⦃f g : α →ₛ β⦄ (H : (f : α → β) = g) : f = g := DFunLike.ext' H @[ext] theorem ext {f g : α →ₛ β} (H : ∀ a, f a = g a) : f = g := DFunLike.ext _ _ H theorem finite_range (f : α →ₛ β) : (Set.range f).Finite := f.finite_range' theorem measurableSet_fiber (f : α →ₛ β) (x : β) : MeasurableSet (f ⁻¹' {x}) := f.measurableSet_fiber' x @[simp] theorem coe_mk (f : α → β) (h h') : ⇑(mk f h h') = f := rfl theorem apply_mk (f : α → β) (h h') (x : α) : SimpleFunc.mk f h h' x = f x := rfl /-- Simple function defined on a finite type. -/ def ofFinite [Finite α] [MeasurableSingletonClass α] (f : α → β) : α →ₛ β where toFun := f measurableSet_fiber' x := (toFinite (f ⁻¹' {x})).measurableSet finite_range' := Set.finite_range f /-- Simple function defined on the empty type. -/ def ofIsEmpty [IsEmpty α] : α →ₛ β := ofFinite isEmptyElim /-- Range of a simple function `α →ₛ β` as a `Finset β`. -/ protected def range (f : α →ₛ β) : Finset β := f.finite_range.toFinset @[simp] theorem mem_range {f : α →ₛ β} {b} : b ∈ f.range ↔ b ∈ range f := Finite.mem_toFinset _ theorem mem_range_self (f : α →ₛ β) (x : α) : f x ∈ f.range := mem_range.2 ⟨x, rfl⟩ @[simp] theorem coe_range (f : α →ₛ β) : (↑f.range : Set β) = Set.range f := f.finite_range.coe_toFinset theorem mem_range_of_measure_ne_zero {f : α →ₛ β} {x : β} {μ : Measure α} (H : μ (f ⁻¹' {x}) ≠ 0) : x ∈ f.range := let ⟨a, ha⟩ := nonempty_of_measure_ne_zero H mem_range.2 ⟨a, ha⟩ theorem forall_mem_range {f : α →ₛ β} {p : β → Prop} : (∀ y ∈ f.range, p y) ↔ ∀ x, p (f x) := by simp only [mem_range, Set.forall_mem_range] theorem exists_range_iff {f : α →ₛ β} {p : β → Prop} : (∃ y ∈ f.range, p y) ↔ ∃ x, p (f x) := by simpa only [mem_range, exists_prop] using Set.exists_range_iff theorem preimage_eq_empty_iff (f : α →ₛ β) (b : β) : f ⁻¹' {b} = ∅ ↔ b ∉ f.range := preimage_singleton_eq_empty.trans <| not_congr mem_range.symm theorem exists_forall_le [Nonempty β] [Preorder β] [IsDirected β (· ≤ ·)] (f : α →ₛ β) : ∃ C, ∀ x, f x ≤ C := f.range.exists_le.imp fun _ => forall_mem_range.1 /-- Constant function as a `SimpleFunc`. -/ def const (α) {β} [MeasurableSpace α] (b : β) : α →ₛ β := ⟨fun _ => b, fun _ => MeasurableSet.const _, finite_range_const⟩ instance instInhabited [Inhabited β] : Inhabited (α →ₛ β) := ⟨const _ default⟩ theorem const_apply (a : α) (b : β) : (const α b) a = b := rfl @[simp] theorem coe_const (b : β) : ⇑(const α b) = Function.const α b := rfl @[simp] theorem range_const (α) [MeasurableSpace α] [Nonempty α] (b : β) : (const α b).range = {b} := Finset.coe_injective <| by simp +unfoldPartialApp [Function.const] theorem range_const_subset (α) [MeasurableSpace α] (b : β) : (const α b).range ⊆ {b} := Finset.coe_subset.1 <| by simp theorem simpleFunc_bot {α} (f : @SimpleFunc α ⊥ β) [Nonempty β] : ∃ c, ∀ x, f x = c := by have hf_meas := @SimpleFunc.measurableSet_fiber α _ ⊥ f simp_rw [MeasurableSpace.measurableSet_bot_iff] at hf_meas exact (exists_eq_const_of_preimage_singleton hf_meas).imp fun c hc ↦ congr_fun hc theorem simpleFunc_bot' {α} [Nonempty β] (f : @SimpleFunc α ⊥ β) : ∃ c, f = @SimpleFunc.const α _ ⊥ c := letI : MeasurableSpace α := ⊥; (simpleFunc_bot f).imp fun _ ↦ ext theorem measurableSet_cut (r : α → β → Prop) (f : α →ₛ β) (h : ∀ b, MeasurableSet { a | r a b }) : MeasurableSet { a | r a (f a) } := by have : { a | r a (f a) } = ⋃ b ∈ range f, { a | r a b } ∩ f ⁻¹' {b} := by ext a suffices r a (f a) ↔ ∃ i, r a (f i) ∧ f a = f i by simpa exact ⟨fun h => ⟨a, ⟨h, rfl⟩⟩, fun ⟨a', ⟨h', e⟩⟩ => e.symm ▸ h'⟩ rw [this] exact MeasurableSet.biUnion f.finite_range.countable fun b _ => MeasurableSet.inter (h b) (f.measurableSet_fiber _) @[measurability] theorem measurableSet_preimage (f : α →ₛ β) (s) : MeasurableSet (f ⁻¹' s) := measurableSet_cut (fun _ b => b ∈ s) f fun b => MeasurableSet.const (b ∈ s) /-- A simple function is measurable -/ @[measurability, fun_prop] protected theorem measurable [MeasurableSpace β] (f : α →ₛ β) : Measurable f := fun s _ => measurableSet_preimage f s @[measurability] protected theorem aemeasurable [MeasurableSpace β] {μ : Measure α} (f : α →ₛ β) : AEMeasurable f μ := f.measurable.aemeasurable protected theorem sum_measure_preimage_singleton (f : α →ₛ β) {μ : Measure α} (s : Finset β) : (∑ y ∈ s, μ (f ⁻¹' {y})) = μ (f ⁻¹' ↑s) := sum_measure_preimage_singleton _ fun _ _ => f.measurableSet_fiber _ theorem sum_range_measure_preimage_singleton (f : α →ₛ β) (μ : Measure α) : (∑ y ∈ f.range, μ (f ⁻¹' {y})) = μ univ := by rw [f.sum_measure_preimage_singleton, coe_range, preimage_range] open scoped Classical in /-- If-then-else as a `SimpleFunc`. -/ def piecewise (s : Set α) (hs : MeasurableSet s) (f g : α →ₛ β) : α →ₛ β := ⟨s.piecewise f g, fun _ => letI : MeasurableSpace β := ⊤ f.measurable.piecewise hs g.measurable trivial, (f.finite_range.union g.finite_range).subset range_ite_subset⟩ open scoped Classical in @[simp] theorem coe_piecewise {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) : ⇑(piecewise s hs f g) = s.piecewise f g := rfl open scoped Classical in theorem piecewise_apply {s : Set α} (hs : MeasurableSet s) (f g : α →ₛ β) (a) : piecewise s hs f g a = if a ∈ s then f a else g a := rfl open scoped Classical in @[simp] theorem piecewise_compl {s : Set α} (hs : MeasurableSet sᶜ) (f g : α →ₛ β) : piecewise sᶜ hs f g = piecewise s hs.of_compl g f := coe_injective <| by simp @[simp] theorem piecewise_univ (f g : α →ₛ β) : piecewise univ MeasurableSet.univ f g = f := coe_injective <| by simp @[simp] theorem piecewise_empty (f g : α →ₛ β) : piecewise ∅ MeasurableSet.empty f g = g := coe_injective <| by simp open scoped Classical in @[simp] theorem piecewise_same (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) : piecewise s hs f f = f := coe_injective <| Set.piecewise_same _ _ theorem support_indicator [Zero β] {s : Set α} (hs : MeasurableSet s) (f : α →ₛ β) : Function.support (f.piecewise s hs (SimpleFunc.const α 0)) = s ∩ Function.support f := Set.support_indicator open scoped Classical in theorem range_indicator {s : Set α} (hs : MeasurableSet s) (hs_nonempty : s.Nonempty) (hs_ne_univ : s ≠ univ) (x y : β) : (piecewise s hs (const α x) (const α y)).range = {x, y} := by simp only [← Finset.coe_inj, coe_range, coe_piecewise, range_piecewise, coe_const, Finset.coe_insert, Finset.coe_singleton, hs_nonempty.image_const, (nonempty_compl.2 hs_ne_univ).image_const, singleton_union, Function.const] theorem measurable_bind [MeasurableSpace γ] (f : α →ₛ β) (g : β → α → γ) (hg : ∀ b, Measurable (g b)) : Measurable fun a => g (f a) a := fun s hs => f.measurableSet_cut (fun a b => g b a ∈ s) fun b => hg b hs /-- If `f : α →ₛ β` is a simple function and `g : β → α →ₛ γ` is a family of simple functions, then `f.bind g` binds the first argument of `g` to `f`. In other words, `f.bind g a = g (f a) a`. -/ def bind (f : α →ₛ β) (g : β → α →ₛ γ) : α →ₛ γ := ⟨fun a => g (f a) a, fun c => f.measurableSet_cut (fun a b => g b a = c) fun b => (g b).measurableSet_preimage {c}, (f.finite_range.biUnion fun b _ => (g b).finite_range).subset <| by rintro _ ⟨a, rfl⟩; simp⟩ @[simp] theorem bind_apply (f : α →ₛ β) (g : β → α →ₛ γ) (a) : f.bind g a = g (f a) a := rfl /-- Given a function `g : β → γ` and a simple function `f : α →ₛ β`, `f.map g` return the simple function `g ∘ f : α →ₛ γ` -/ def map (g : β → γ) (f : α →ₛ β) : α →ₛ γ := bind f (const α ∘ g) theorem map_apply (g : β → γ) (f : α →ₛ β) (a) : f.map g a = g (f a) := rfl theorem map_map (g : β → γ) (h : γ → δ) (f : α →ₛ β) : (f.map g).map h = f.map (h ∘ g) := rfl @[simp] theorem coe_map (g : β → γ) (f : α →ₛ β) : (f.map g : α → γ) = g ∘ f := rfl @[simp] theorem range_map [DecidableEq γ] (g : β → γ) (f : α →ₛ β) : (f.map g).range = f.range.image g := Finset.coe_injective <| by simp only [coe_range, coe_map, Finset.coe_image, range_comp] @[simp] theorem map_const (g : β → γ) (b : β) : (const α b).map g = const α (g b) := rfl open scoped Classical in theorem map_preimage (f : α →ₛ β) (g : β → γ) (s : Set γ) : f.map g ⁻¹' s = f ⁻¹' ↑{b ∈ f.range | g b ∈ s} := by simp only [coe_range, sep_mem_eq, coe_map, Finset.coe_filter, ← mem_preimage, inter_comm, preimage_inter_range, ← Finset.mem_coe] exact preimage_comp open scoped Classical in theorem map_preimage_singleton (f : α →ₛ β) (g : β → γ) (c : γ) : f.map g ⁻¹' {c} = f ⁻¹' ↑{b ∈ f.range | g b = c} := map_preimage _ _ _ /-- Composition of a `SimpleFun` and a measurable function is a `SimpleFunc`. -/ def comp [MeasurableSpace β] (f : β →ₛ γ) (g : α → β) (hgm : Measurable g) : α →ₛ γ where toFun := f ∘ g finite_range' := f.finite_range.subset <| Set.range_comp_subset_range _ _ measurableSet_fiber' z := hgm (f.measurableSet_fiber z) @[simp] theorem coe_comp [MeasurableSpace β] (f : β →ₛ γ) {g : α → β} (hgm : Measurable g) : ⇑(f.comp g hgm) = f ∘ g := rfl theorem range_comp_subset_range [MeasurableSpace β] (f : β →ₛ γ) {g : α → β} (hgm : Measurable g) : (f.comp g hgm).range ⊆ f.range := Finset.coe_subset.1 <| by simp only [coe_range, coe_comp, Set.range_comp_subset_range] /-- Extend a `SimpleFunc` along a measurable embedding: `f₁.extend g hg f₂` is the function `F : β →ₛ γ` such that `F ∘ g = f₁` and `F y = f₂ y` whenever `y ∉ range g`. -/ def extend [MeasurableSpace β] (f₁ : α →ₛ γ) (g : α → β) (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) : β →ₛ γ where toFun := Function.extend g f₁ f₂ finite_range' := (f₁.finite_range.union <| f₂.finite_range.subset (image_subset_range _ _)).subset (range_extend_subset _ _ _) measurableSet_fiber' := by letI : MeasurableSpace γ := ⊤; haveI : MeasurableSingletonClass γ := ⟨fun _ => trivial⟩ exact fun x => hg.measurable_extend f₁.measurable f₂.measurable (measurableSet_singleton _) @[simp] theorem extend_apply [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) (x : α) : (f₁.extend g hg f₂) (g x) = f₁ x := hg.injective.extend_apply _ _ _ @[simp] theorem extend_apply' [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) {y : β} (h : ¬∃ x, g x = y) : (f₁.extend g hg f₂) y = f₂ y := Function.extend_apply' _ _ _ h @[simp] theorem extend_comp_eq' [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) : f₁.extend g hg f₂ ∘ g = f₁ := funext fun _ => extend_apply _ _ _ _ @[simp] theorem extend_comp_eq [MeasurableSpace β] (f₁ : α →ₛ γ) {g : α → β} (hg : MeasurableEmbedding g) (f₂ : β →ₛ γ) : (f₁.extend g hg f₂).comp g hg.measurable = f₁ := coe_injective <| extend_comp_eq' _ hg _ /-- If `f` is a simple function taking values in `β → γ` and `g` is another simple function with the same domain and codomain `β`, then `f.seq g = f a (g a)`. -/ def seq (f : α →ₛ β → γ) (g : α →ₛ β) : α →ₛ γ := f.bind fun f => g.map f @[simp] theorem seq_apply (f : α →ₛ β → γ) (g : α →ₛ β) (a : α) : f.seq g a = f a (g a) := rfl /-- Combine two simple functions `f : α →ₛ β` and `g : α →ₛ β` into `fun a => (f a, g a)`. -/ def pair (f : α →ₛ β) (g : α →ₛ γ) : α →ₛ β × γ := (f.map Prod.mk).seq g @[simp] theorem pair_apply (f : α →ₛ β) (g : α →ₛ γ) (a) : pair f g a = (f a, g a) := rfl theorem pair_preimage (f : α →ₛ β) (g : α →ₛ γ) (s : Set β) (t : Set γ) : pair f g ⁻¹' s ×ˢ t = f ⁻¹' s ∩ g ⁻¹' t := rfl -- A special form of `pair_preimage` theorem pair_preimage_singleton (f : α →ₛ β) (g : α →ₛ γ) (b : β) (c : γ) : pair f g ⁻¹' {(b, c)} = f ⁻¹' {b} ∩ g ⁻¹' {c} := by rw [← singleton_prod_singleton] exact pair_preimage _ _ _ _ @[simp] theorem map_fst_pair (f : α →ₛ β) (g : α →ₛ γ) : (f.pair g).map Prod.fst = f := rfl @[simp] theorem map_snd_pair (f : α →ₛ β) (g : α →ₛ γ) : (f.pair g).map Prod.snd = g := rfl @[simp] theorem bind_const (f : α →ₛ β) : f.bind (const α) = f := by ext; simp @[to_additive] instance instOne [One β] : One (α →ₛ β) := ⟨const α 1⟩ @[to_additive] instance instMul [Mul β] : Mul (α →ₛ β) := ⟨fun f g => (f.map (· * ·)).seq g⟩ @[to_additive] instance instDiv [Div β] : Div (α →ₛ β) := ⟨fun f g => (f.map (· / ·)).seq g⟩ @[to_additive] instance instInv [Inv β] : Inv (α →ₛ β) := ⟨fun f => f.map Inv.inv⟩ instance instSup [Max β] : Max (α →ₛ β) := ⟨fun f g => (f.map (· ⊔ ·)).seq g⟩ instance instInf [Min β] : Min (α →ₛ β) := ⟨fun f g => (f.map (· ⊓ ·)).seq g⟩ instance instLE [LE β] : LE (α →ₛ β) := ⟨fun f g => ∀ a, f a ≤ g a⟩ @[to_additive (attr := simp)] theorem const_one [One β] : const α (1 : β) = 1 := rfl @[to_additive (attr := simp, norm_cast)] theorem coe_one [One β] : ⇑(1 : α →ₛ β) = 1 := rfl @[to_additive (attr := simp, norm_cast)] theorem coe_mul [Mul β] (f g : α →ₛ β) : ⇑(f * g) = ⇑f * ⇑g := rfl @[to_additive (attr := simp, norm_cast)] theorem coe_inv [Inv β] (f : α →ₛ β) : ⇑(f⁻¹) = (⇑f)⁻¹ := rfl @[to_additive (attr := simp, norm_cast)] theorem coe_div [Div β] (f g : α →ₛ β) : ⇑(f / g) = ⇑f / ⇑g := rfl @[simp, norm_cast] theorem coe_sup [Max β] (f g : α →ₛ β) : ⇑(f ⊔ g) = ⇑f ⊔ ⇑g := rfl @[simp, norm_cast] theorem coe_inf [Min β] (f g : α →ₛ β) : ⇑(f ⊓ g) = ⇑f ⊓ ⇑g := rfl @[to_additive] theorem mul_apply [Mul β] (f g : α →ₛ β) (a : α) : (f * g) a = f a * g a := rfl @[to_additive] theorem div_apply [Div β] (f g : α →ₛ β) (x : α) : (f / g) x = f x / g x := rfl @[to_additive] theorem inv_apply [Inv β] (f : α →ₛ β) (x : α) : f⁻¹ x = (f x)⁻¹ := rfl theorem sup_apply [Max β] (f g : α →ₛ β) (a : α) : (f ⊔ g) a = f a ⊔ g a := rfl theorem inf_apply [Min β] (f g : α →ₛ β) (a : α) : (f ⊓ g) a = f a ⊓ g a := rfl @[to_additive (attr := simp)] theorem range_one [Nonempty α] [One β] : (1 : α →ₛ β).range = {1} := Finset.ext fun x => by simp @[simp] theorem range_eq_empty_of_isEmpty {β} [hα : IsEmpty α] (f : α →ₛ β) : f.range = ∅ := by ext simp theorem eq_zero_of_mem_range_zero [Zero β] : ∀ {y : β}, y ∈ (0 : α →ₛ β).range → y = 0 := @(forall_mem_range.2 fun _ => rfl) @[to_additive] theorem mul_eq_map₂ [Mul β] (f g : α →ₛ β) : f * g = (pair f g).map fun p : β × β => p.1 * p.2 := rfl theorem sup_eq_map₂ [Max β] (f g : α →ₛ β) : f ⊔ g = (pair f g).map fun p : β × β => p.1 ⊔ p.2 := rfl @[to_additive] theorem const_mul_eq_map [Mul β] (f : α →ₛ β) (b : β) : const α b * f = f.map fun a => b * a := rfl @[to_additive] theorem map_mul [Mul β] [Mul γ] {g : β → γ} (hg : ∀ x y, g (x * y) = g x * g y) (f₁ f₂ : α →ₛ β) : (f₁ * f₂).map g = f₁.map g * f₂.map g := ext fun _ => hg _ _ variable {K : Type*} @[to_additive] instance instSMul [SMul K β] : SMul K (α →ₛ β) := ⟨fun k f => f.map (k • ·)⟩ @[to_additive (attr := simp)] theorem coe_smul [SMul K β] (c : K) (f : α →ₛ β) : ⇑(c • f) = c • ⇑f := rfl @[to_additive (attr := simp)] theorem smul_apply [SMul K β] (k : K) (f : α →ₛ β) (a : α) : (k • f) a = k • f a := rfl instance hasNatSMul [AddMonoid β] : SMul ℕ (α →ₛ β) := inferInstance @[to_additive existing hasNatSMul] instance hasNatPow [Monoid β] : Pow (α →ₛ β) ℕ := ⟨fun f n => f.map (· ^ n)⟩ @[simp] theorem coe_pow [Monoid β] (f : α →ₛ β) (n : ℕ) : ⇑(f ^ n) = (⇑f) ^ n := rfl theorem pow_apply [Monoid β] (n : ℕ) (f : α →ₛ β) (a : α) : (f ^ n) a = f a ^ n := rfl instance hasIntPow [DivInvMonoid β] : Pow (α →ₛ β) ℤ := ⟨fun f n => f.map (· ^ n)⟩ @[simp] theorem coe_zpow [DivInvMonoid β] (f : α →ₛ β) (z : ℤ) : ⇑(f ^ z) = (⇑f) ^ z := rfl theorem zpow_apply [DivInvMonoid β] (z : ℤ) (f : α →ₛ β) (a : α) : (f ^ z) a = f a ^ z := rfl -- TODO: work out how to generate these instances with `to_additive`, which gets confused by the -- argument order swap between `coe_smul` and `coe_pow`. section Additive instance instAddMonoid [AddMonoid β] : AddMonoid (α →ₛ β) := fast_instance% Function.Injective.addMonoid (fun f => show α → β from f) coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ instance instAddCommMonoid [AddCommMonoid β] : AddCommMonoid (α →ₛ β) := fast_instance% Function.Injective.addCommMonoid (fun f => show α → β from f) coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ instance instAddGroup [AddGroup β] : AddGroup (α →ₛ β) := Function.Injective.addGroup (fun f => show α → β from f) coe_injective coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ instance instAddCommGroup [AddCommGroup β] : AddCommGroup (α →ₛ β) := fast_instance% Function.Injective.addCommGroup (fun f => show α → β from f) coe_injective coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ end Additive @[to_additive existing] instance instMonoid [Monoid β] : Monoid (α →ₛ β) := fast_instance% Function.Injective.monoid (fun f => show α → β from f) coe_injective coe_one coe_mul coe_pow @[to_additive existing] instance instCommMonoid [CommMonoid β] : CommMonoid (α →ₛ β) := fast_instance% Function.Injective.commMonoid (fun f => show α → β from f) coe_injective coe_one coe_mul coe_pow @[to_additive existing] instance instGroup [Group β] : Group (α →ₛ β) := fast_instance% Function.Injective.group (fun f => show α → β from f) coe_injective coe_one coe_mul coe_inv coe_div coe_pow coe_zpow @[to_additive existing] instance instCommGroup [CommGroup β] : CommGroup (α →ₛ β) := fast_instance% Function.Injective.commGroup (fun f => show α → β from f) coe_injective coe_one coe_mul coe_inv coe_div coe_pow coe_zpow instance [Monoid K] [MulAction K β] : MulAction K (α →ₛ β) := fast_instance% Function.Injective.mulAction (fun f => show α → β from f) coe_injective coe_smul instance instModule [Semiring K] [AddCommMonoid β] [Module K β] : Module K (α →ₛ β) := fast_instance% Function.Injective.module K ⟨⟨fun f => show α → β from f, coe_zero⟩, coe_add⟩ coe_injective coe_smul theorem smul_eq_map [SMul K β] (k : K) (f : α →ₛ β) : k • f = f.map (k • ·) := rfl lemma smul_const [SMul K β] (k : K) (b : β) : (k • const α b : α →ₛ β) = const α (k • b) := ext fun _ ↦ rfl instance [NonUnitalNonAssocSemiring β] : NonUnitalNonAssocSemiring (α →ₛ β) := fast_instance% Function.Injective.nonUnitalNonAssocSemiring (fun f => show α → β from f) coe_injective coe_zero coe_add coe_mul coe_smul instance [NonUnitalSemiring β] : NonUnitalSemiring (α →ₛ β) := fast_instance% Function.Injective.nonUnitalSemiring (fun f => show α → β from f) SimpleFunc.coe_injective coe_zero coe_add coe_mul coe_smul instance [NatCast β] : NatCast (α →ₛ β) where natCast n := const _ (NatCast.natCast n) @[simp, norm_cast] lemma coe_natCast [NatCast β] (n : ℕ) : ⇑(↑n : α →ₛ β) = fun _ ↦ ↑n := rfl instance [NonAssocSemiring β] : NonAssocSemiring (α →ₛ β) := fast_instance% Function.Injective.nonAssocSemiring (fun f => show α → β from f) coe_injective coe_zero coe_one coe_add coe_mul coe_smul coe_natCast instance [IntCast β] : IntCast (α →ₛ β) where intCast n := const _ (IntCast.intCast n) @[simp, norm_cast] lemma coe_intCast [IntCast β] (n : ℤ) : ⇑(↑n : α →ₛ β) = fun _ ↦ ↑n := rfl instance [NonAssocRing β] : NonAssocRing (α →ₛ β) := fast_instance% Function.Injective.nonAssocRing (fun f => show α → β from f) coe_injective coe_zero coe_one coe_add coe_mul coe_neg coe_sub coe_smul coe_smul coe_natCast coe_intCast instance [NonUnitalCommSemiring β] : NonUnitalCommSemiring (α →ₛ β) := fast_instance% Function.Injective.nonUnitalCommSemiring (fun f => show α → β from f) coe_injective coe_zero coe_add coe_mul coe_smul instance [CommSemiring β] : CommSemiring (α →ₛ β) := fast_instance% Function.Injective.commSemiring (fun f => show α → β from f) coe_injective coe_zero coe_one coe_add coe_mul coe_smul coe_pow coe_natCast instance [NonUnitalCommRing β] : NonUnitalCommRing (α →ₛ β) := fast_instance% Function.Injective.nonUnitalCommRing (fun f => show α → β from f) coe_injective coe_zero coe_add coe_mul coe_neg coe_sub coe_smul coe_smul instance [CommRing β] : CommRing (α →ₛ β) := fast_instance% Function.Injective.commRing (fun f => show α → β from f) coe_injective coe_zero coe_one coe_add coe_mul coe_neg coe_sub coe_smul coe_smul coe_pow coe_natCast coe_intCast instance [Semiring β] : Semiring (α →ₛ β) := fast_instance% Function.Injective.semiring (fun f => show α → β from f) coe_injective coe_zero coe_one coe_add coe_mul coe_smul coe_pow coe_natCast instance [NonUnitalRing β] : NonUnitalRing (α →ₛ β) := fast_instance% Function.Injective.nonUnitalRing (fun f => show α → β from f) coe_injective coe_zero coe_add coe_mul coe_neg coe_sub coe_smul coe_smul instance [Ring β] : Ring (α →ₛ β) := fast_instance% Function.Injective.ring (fun f => show α → β from f) coe_injective coe_zero coe_one coe_add coe_mul coe_neg coe_sub coe_smul coe_smul coe_pow coe_natCast coe_intCast instance [SMul K γ] [SMul γ β] [SMul K β] [IsScalarTower K γ β] : IsScalarTower K γ (α →ₛ β) where smul_assoc _ _ _ := ext fun _ ↦ smul_assoc .. instance [SMul γ β] [SMul K β] [SMulCommClass K γ β] : SMulCommClass K γ (α →ₛ β) where smul_comm _ _ _ := ext fun _ ↦ smul_comm .. instance [CommSemiring K] [Semiring β] [Algebra K β] : Algebra K (α →ₛ β) where algebraMap :={ toFun r := const α <| algebraMap K β r map_one' := ext fun _ ↦ algebraMap K β |>.map_one ▸ rfl map_mul' _ _ := ext fun _ ↦ algebraMap K β |>.map_mul .. map_zero' := ext fun _ ↦ algebraMap K β |>.map_zero ▸ rfl map_add' _ _ := ext fun _ ↦ algebraMap K β |>.map_add ..} commutes' _ _ := ext fun _ ↦ Algebra.commutes .. smul_def' _ _ := ext fun _ ↦ Algebra.smul_def .. @[simp] lemma const_algebraMap [CommSemiring K] [Semiring β] [Algebra K β] (k : K) : const α (algebraMap K β k) = algebraMap K (α →ₛ β) k := rfl @[simp] lemma coe_algebraMap [CommSemiring K] [Semiring β] [Algebra K β] (k : K) (x : α) : ⇑(algebraMap K (α →ₛ β)) k x = algebraMap K (α → β) k x := rfl section Star instance [Star β] : Star (α →ₛ β) where star f := f.map Star.star @[simp] lemma coe_star [Star β] {f : α →ₛ β} : ⇑(star f) = star ⇑f := rfl instance [InvolutiveStar β] : InvolutiveStar (α →ₛ β) where star_involutive _ := ext fun _ ↦ star_star _ instance [AddMonoid β] [StarAddMonoid β] : StarAddMonoid (α →ₛ β) where star_add _ _ := ext fun _ ↦ star_add .. instance [Mul β] [StarMul β] : StarMul (α →ₛ β) where star_mul _ _ := ext fun _ ↦ star_mul .. instance [NonUnitalNonAssocSemiring β] [StarRing β] : StarRing (α →ₛ β) where star_add _ _ := ext fun _ ↦ star_add .. end Star section Preorder variable [Preorder β] {s : Set α} {f f₁ f₂ g g₁ g₂ : α →ₛ β} {hs : MeasurableSet s} instance instPreorder : Preorder (α →ₛ β) := Preorder.lift (⇑) @[simp, norm_cast] lemma coe_le_coe : ⇑f ≤ g ↔ f ≤ g := .rfl @[simp, norm_cast] lemma coe_lt_coe : ⇑f < g ↔ f < g := .rfl @[deprecated (since := "2025-10-21")] alias coe_le := coe_le_coe @[simp] lemma mk_le_mk {f g : α → β} {hf hg hf' hg'} : mk f hf hf' ≤ mk g hg hg' ↔ f ≤ g := Iff.rfl @[simp] lemma mk_lt_mk {f g : α → β} {hf hg hf' hg'} : mk f hf hf' < mk g hg hg' ↔ f < g := Iff.rfl @[gcongr] protected alias ⟨_, GCongr.mk_le_mk⟩ := mk_le_mk @[gcongr] protected alias ⟨_, GCongr.mk_lt_mk⟩ := mk_lt_mk @[gcongr] protected alias ⟨_, GCongr.coe_le_coe⟩ := coe_le_coe @[gcongr] protected alias ⟨_, GCongr.coe_lt_coe⟩ := coe_lt_coe open scoped Classical in @[gcongr] lemma piecewise_mono (hf : ∀ a ∈ s, f₁ a ≤ f₂ a) (hg : ∀ a ∉ s, g₁ a ≤ g₂ a) : piecewise s hs f₁ g₁ ≤ piecewise s hs f₂ g₂ := Set.piecewise_mono hf hg end Preorder instance instPartialOrder [PartialOrder β] : PartialOrder (α →ₛ β) := { SimpleFunc.instPreorder with le_antisymm := fun _f _g hfg hgf => ext fun a => le_antisymm (hfg a) (hgf a) } instance instOrderBot [LE β] [OrderBot β] : OrderBot (α →ₛ β) where bot := const α ⊥ bot_le _ _ := bot_le instance instOrderTop [LE β] [OrderTop β] : OrderTop (α →ₛ β) where top := const α ⊤ le_top _ _ := le_top @[to_additive] instance [CommMonoid β] [PartialOrder β] [IsOrderedMonoid β] : IsOrderedMonoid (α →ₛ β) where mul_le_mul_left _ _ h _ _ := mul_le_mul_left' (h _) _ instance instSemilatticeInf [SemilatticeInf β] : SemilatticeInf (α →ₛ β) := { SimpleFunc.instPartialOrder with inf := (· ⊓ ·) inf_le_left := fun _ _ _ => inf_le_left inf_le_right := fun _ _ _ => inf_le_right le_inf := fun _f _g _h hfh hgh a => le_inf (hfh a) (hgh a) } instance instSemilatticeSup [SemilatticeSup β] : SemilatticeSup (α →ₛ β) := { SimpleFunc.instPartialOrder with sup := (· ⊔ ·) le_sup_left := fun _ _ _ => le_sup_left le_sup_right := fun _ _ _ => le_sup_right sup_le := fun _f _g _h hfh hgh a => sup_le (hfh a) (hgh a) } instance instLattice [Lattice β] : Lattice (α →ₛ β) := { SimpleFunc.instSemilatticeSup, SimpleFunc.instSemilatticeInf with } instance instBoundedOrder [LE β] [BoundedOrder β] : BoundedOrder (α →ₛ β) := { SimpleFunc.instOrderBot, SimpleFunc.instOrderTop with } theorem finset_sup_apply [SemilatticeSup β] [OrderBot β] {f : γ → α →ₛ β} (s : Finset γ) (a : α) : s.sup f a = s.sup fun c => f c a := by classical refine Finset.induction_on s rfl ?_ intro a s _ ih rw [Finset.sup_insert, Finset.sup_insert, sup_apply, ih] section Restrict variable [Zero β] open scoped Classical in /-- Restrict a simple function `f : α →ₛ β` to a set `s`. If `s` is measurable, then `f.restrict s a = if a ∈ s then f a else 0`, otherwise `f.restrict s = const α 0`. -/ def restrict (f : α →ₛ β) (s : Set α) : α →ₛ β := if hs : MeasurableSet s then piecewise s hs f 0 else 0 theorem restrict_of_not_measurable {f : α →ₛ β} {s : Set α} (hs : ¬MeasurableSet s) : restrict f s = 0 := dif_neg hs @[simp] theorem coe_restrict (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) : ⇑(restrict f s) = indicator s f := by classical rw [restrict, dif_pos hs, coe_piecewise, coe_zero, piecewise_eq_indicator] @[simp] theorem restrict_univ (f : α →ₛ β) : restrict f univ = f := by simp [restrict] @[simp] theorem restrict_empty (f : α →ₛ β) : restrict f ∅ = 0 := by simp [restrict] open scoped Classical in theorem map_restrict_of_zero [Zero γ] {g : β → γ} (hg : g 0 = 0) (f : α →ₛ β) (s : Set α) : (f.restrict s).map g = (f.map g).restrict s := ext fun x => if hs : MeasurableSet s then by simp [hs, Set.indicator_comp_of_zero hg] else by simp [restrict_of_not_measurable hs, hg] theorem map_coe_ennreal_restrict (f : α →ₛ ℝ≥0) (s : Set α) : (f.restrict s).map ((↑) : ℝ≥0 → ℝ≥0∞) = (f.map (↑)).restrict s := map_restrict_of_zero ENNReal.coe_zero _ _ theorem map_coe_nnreal_restrict (f : α →ₛ ℝ≥0) (s : Set α) : (f.restrict s).map ((↑) : ℝ≥0 → ℝ) = (f.map (↑)).restrict s := map_restrict_of_zero NNReal.coe_zero _ _ theorem restrict_apply (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) (a) : restrict f s a = indicator s f a := by simp only [f.coe_restrict hs] theorem restrict_preimage (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) {t : Set β} (ht : (0 : β) ∉ t) : restrict f s ⁻¹' t = s ∩ f ⁻¹' t := by simp [hs, indicator_preimage_of_notMem _ _ ht, inter_comm] theorem restrict_preimage_singleton (f : α →ₛ β) {s : Set α} (hs : MeasurableSet s) {r : β} (hr : r ≠ 0) : restrict f s ⁻¹' {r} = s ∩ f ⁻¹' {r} := f.restrict_preimage hs hr.symm theorem mem_restrict_range {r : β} {s : Set α} {f : α →ₛ β} (hs : MeasurableSet s) : r ∈ (restrict f s).range ↔ r = 0 ∧ s ≠ univ ∨ r ∈ f '' s := by rw [← Finset.mem_coe, coe_range, coe_restrict _ hs, mem_range_indicator] open scoped Classical in theorem mem_image_of_mem_range_restrict {r : β} {s : Set α} {f : α →ₛ β} (hr : r ∈ (restrict f s).range) (h0 : r ≠ 0) : r ∈ f '' s := if hs : MeasurableSet s then by simpa [mem_restrict_range hs, h0, -mem_range] using hr else by rw [restrict_of_not_measurable hs] at hr exact (h0 <| eq_zero_of_mem_range_zero hr).elim open scoped Classical in @[gcongr, mono] theorem restrict_mono [Preorder β] (s : Set α) {f g : α →ₛ β} (H : f ≤ g) : f.restrict s ≤ g.restrict s := if hs : MeasurableSet s then fun x => by simp only [coe_restrict _ hs, indicator_le_indicator (H x)] else by simp only [restrict_of_not_measurable hs, le_refl] end Restrict section Approx section variable [SemilatticeSup β] [OrderBot β] [Zero β] /-- Fix a sequence `i : ℕ → β`. Given a function `α → β`, its `n`-th approximation by simple functions is defined so that in case `β = ℝ≥0∞` it sends each `a` to the supremum of the set `{i k | k ≤ n ∧ i k ≤ f a}`, see `approx_apply` and `iSup_approx_apply` for details. -/ def approx (i : ℕ → β) (f : α → β) (n : ℕ) : α →ₛ β := (Finset.range n).sup fun k => restrict (const α (i k)) { a : α | i k ≤ f a } open scoped Classical in theorem approx_apply [TopologicalSpace β] [OrderClosedTopology β] [MeasurableSpace β] [OpensMeasurableSpace β] {i : ℕ → β} {f : α → β} {n : ℕ} (a : α) (hf : Measurable f) : (approx i f n : α →ₛ β) a = (Finset.range n).sup fun k => if i k ≤ f a then i k else 0 := by dsimp only [approx] rw [finset_sup_apply] congr funext k rw [restrict_apply] · simp only [coe_const, mem_setOf_eq, indicator_apply, Function.const_apply] · exact hf measurableSet_Ici theorem monotone_approx (i : ℕ → β) (f : α → β) : Monotone (approx i f) := fun _ _ h => Finset.sup_mono <| Finset.range_subset_range.2 h theorem approx_comp [TopologicalSpace β] [OrderClosedTopology β] [MeasurableSpace β] [OpensMeasurableSpace β] [MeasurableSpace γ] {i : ℕ → β} {f : γ → β} {g : α → γ} {n : ℕ} (a : α) (hf : Measurable f) (hg : Measurable g) : (approx i (f ∘ g) n : α →ₛ β) a = (approx i f n : γ →ₛ β) (g a) := by rw [approx_apply _ hf, approx_apply _ (hf.comp hg), Function.comp_apply] end theorem iSup_approx_apply [TopologicalSpace β] [CompleteLattice β] [OrderClosedTopology β] [Zero β] [MeasurableSpace β] [OpensMeasurableSpace β] (i : ℕ → β) (f : α → β) (a : α) (hf : Measurable f) (h_zero : (0 : β) = ⊥) : ⨆ n, (approx i f n : α →ₛ β) a = ⨆ (k) (_ : i k ≤ f a), i k := by refine le_antisymm (iSup_le fun n => ?_) (iSup_le fun k => iSup_le fun hk => ?_) · rw [approx_apply a hf, h_zero] refine Finset.sup_le fun k _ => ?_ split_ifs with h · exact le_iSup_of_le k (le_iSup (fun _ : i k ≤ f a => i k) h) · exact bot_le · refine le_iSup_of_le (k + 1) ?_ rw [approx_apply a hf] have : k ∈ Finset.range (k + 1) := Finset.mem_range.2 (Nat.lt_succ_self _) refine le_trans (le_of_eq ?_) (Finset.le_sup this) rw [if_pos hk] end Approx section EApprox variable {f : α → ℝ≥0∞} /-- A sequence of `ℝ≥0∞`s such that its range is the set of non-negative rational numbers. -/ def ennrealRatEmbed (n : ℕ) : ℝ≥0∞ := ENNReal.ofReal ((Encodable.decode (α := ℚ) n).getD (0 : ℚ)) theorem ennrealRatEmbed_encode (q : ℚ) : ennrealRatEmbed (Encodable.encode q) = Real.toNNReal q := by rw [ennrealRatEmbed, Encodable.encodek]; rfl /-- Approximate a function `α → ℝ≥0∞` by a sequence of simple functions. -/ def eapprox : (α → ℝ≥0∞) → ℕ → α →ₛ ℝ≥0∞ := approx ennrealRatEmbed theorem eapprox_lt_top (f : α → ℝ≥0∞) (n : ℕ) (a : α) : eapprox f n a < ∞ := by simp only [eapprox, approx, finset_sup_apply, restrict] rw [Finset.sup_lt_iff (α := ℝ≥0∞) WithTop.top_pos] intro b _ split_ifs · simp only [coe_zero, coe_piecewise, piecewise_eq_indicator, coe_const] calc { a : α | ennrealRatEmbed b ≤ f a }.indicator (fun _ => ennrealRatEmbed b) a ≤ ennrealRatEmbed b := indicator_le_self _ _ a _ < ⊤ := ENNReal.coe_lt_top · exact WithTop.top_pos @[gcongr, mono] theorem monotone_eapprox (f : α → ℝ≥0∞) : Monotone (eapprox f) := monotone_approx _ f @[deprecated monotone_eapprox (since := "2025-08-13")] lemma eapprox_mono {m n : ℕ} (hmn : m ≤ n) : eapprox f m ≤ eapprox f n := monotone_eapprox _ hmn lemma iSup_eapprox_apply (hf : Measurable f) (a : α) : ⨆ n, (eapprox f n : α →ₛ ℝ≥0∞) a = f a := by rw [eapprox, iSup_approx_apply ennrealRatEmbed f a hf rfl] refine le_antisymm (iSup_le fun i => iSup_le fun hi => hi) (le_of_not_gt ?_) intro h rcases ENNReal.lt_iff_exists_rat_btwn.1 h with ⟨q, _, lt_q, q_lt⟩ have : (Real.toNNReal q : ℝ≥0∞) ≤ ⨆ (k : ℕ) (_ : ennrealRatEmbed k ≤ f a), ennrealRatEmbed k := by refine le_iSup_of_le (Encodable.encode q) ?_ rw [ennrealRatEmbed_encode q] exact le_iSup_of_le (le_of_lt q_lt) le_rfl exact lt_irrefl _ (lt_of_le_of_lt this lt_q) lemma iSup_coe_eapprox (hf : Measurable f) : ⨆ n, ⇑(eapprox f n) = f := by simpa [funext_iff] using iSup_eapprox_apply hf theorem eapprox_comp [MeasurableSpace γ] {f : γ → ℝ≥0∞} {g : α → γ} {n : ℕ} (hf : Measurable f) (hg : Measurable g) : (eapprox (f ∘ g) n : α → ℝ≥0∞) = (eapprox f n : γ →ₛ ℝ≥0∞) ∘ g := funext fun a => approx_comp a hf hg lemma tendsto_eapprox {f : α → ℝ≥0∞} (hf_meas : Measurable f) (a : α) : Tendsto (fun n ↦ eapprox f n a) atTop (𝓝 (f a)) := by nth_rw 2 [← iSup_coe_eapprox hf_meas] rw [iSup_apply] exact tendsto_atTop_iSup fun _ _ hnm ↦ monotone_eapprox f hnm a /-- Approximate a function `α → ℝ≥0∞` by a series of simple functions taking their values in `ℝ≥0`. -/ def eapproxDiff (f : α → ℝ≥0∞) : ℕ → α →ₛ ℝ≥0 | 0 => (eapprox f 0).map ENNReal.toNNReal | n + 1 => (eapprox f (n + 1) - eapprox f n).map ENNReal.toNNReal theorem sum_eapproxDiff (f : α → ℝ≥0∞) (n : ℕ) (a : α) : (∑ k ∈ Finset.range (n + 1), (eapproxDiff f k a : ℝ≥0∞)) = eapprox f n a := by induction n with | zero => simp [eapproxDiff, (eapprox_lt_top f 0 a).ne] | succ n IH => rw [Finset.sum_range_succ, IH, eapproxDiff, coe_map, Function.comp_apply, coe_sub, Pi.sub_apply, ENNReal.coe_toNNReal, add_tsub_cancel_of_le (monotone_eapprox f (Nat.le_succ _) _)] apply (lt_of_le_of_lt _ (eapprox_lt_top f (n + 1) a)).ne rw [tsub_le_iff_right] exact le_self_add theorem tsum_eapproxDiff (f : α → ℝ≥0∞) (hf : Measurable f) (a : α) : (∑' n, (eapproxDiff f n a : ℝ≥0∞)) = f a := by simp_rw [ENNReal.tsum_eq_iSup_nat' (tendsto_add_atTop_nat 1), sum_eapproxDiff, iSup_eapprox_apply hf a] end EApprox end Measurable section Measure variable {m : MeasurableSpace α} {μ ν : Measure α} /-- Integral of a simple function whose codomain is `ℝ≥0∞`. -/ def lintegral {_m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) : ℝ≥0∞ := ∑ x ∈ f.range, x * μ (f ⁻¹' {x}) theorem lintegral_eq_of_subset (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞} (hs : ∀ x, f x ≠ 0 → μ (f ⁻¹' {f x}) ≠ 0 → f x ∈ s) : f.lintegral μ = ∑ x ∈ s, x * μ (f ⁻¹' {x}) := by refine Finset.sum_bij_ne_zero (fun r _ _ => r) ?_ ?_ ?_ ?_ · simpa only [forall_mem_range, mul_ne_zero_iff, and_imp] · intros assumption · intro b _ hb refine ⟨b, ?_, hb, rfl⟩ rw [mem_range, ← preimage_singleton_nonempty] exact nonempty_of_measure_ne_zero (mul_ne_zero_iff.1 hb).2 · intros rfl theorem lintegral_eq_of_subset' (f : α →ₛ ℝ≥0∞) {s : Finset ℝ≥0∞} (hs : f.range \ {0} ⊆ s) : f.lintegral μ = ∑ x ∈ s, x * μ (f ⁻¹' {x}) := f.lintegral_eq_of_subset fun x hfx _ => hs <| Finset.mem_sdiff.2 ⟨f.mem_range_self x, mt Finset.mem_singleton.1 hfx⟩ /-- Calculate the integral of `(g ∘ f)`, where `g : β → ℝ≥0∞` and `f : α →ₛ β`. -/ theorem map_lintegral (g : β → ℝ≥0∞) (f : α →ₛ β) : (f.map g).lintegral μ = ∑ x ∈ f.range, g x * μ (f ⁻¹' {x}) := by simp only [lintegral, range_map] refine Finset.sum_image' _ fun b hb => ?_ rcases mem_range.1 hb with ⟨a, rfl⟩ rw [map_preimage_singleton, ← f.sum_measure_preimage_singleton, Finset.mul_sum] refine Finset.sum_congr ?_ ?_ · congr · grind theorem add_lintegral (f g : α →ₛ ℝ≥0∞) : (f + g).lintegral μ = f.lintegral μ + g.lintegral μ := calc (f + g).lintegral μ = ∑ x ∈ (pair f g).range, (x.1 * μ (pair f g ⁻¹' {x}) + x.2 * μ (pair f g ⁻¹' {x})) := by rw [add_eq_map₂, map_lintegral]; exact Finset.sum_congr rfl fun a _ => add_mul _ _ _ _ = (∑ x ∈ (pair f g).range, x.1 * μ (pair f g ⁻¹' {x})) + ∑ x ∈ (pair f g).range, x.2 * μ (pair f g ⁻¹' {x}) := by rw [Finset.sum_add_distrib] _ = ((pair f g).map Prod.fst).lintegral μ + ((pair f g).map Prod.snd).lintegral μ := by rw [map_lintegral, map_lintegral] _ = lintegral f μ + lintegral g μ := rfl theorem const_mul_lintegral (f : α →ₛ ℝ≥0∞) (x : ℝ≥0∞) : (const α x * f).lintegral μ = x * f.lintegral μ := calc (f.map fun a => x * a).lintegral μ = ∑ r ∈ f.range, x * r * μ (f ⁻¹' {r}) := map_lintegral _ _ _ = x * ∑ r ∈ f.range, r * μ (f ⁻¹' {r}) := by simp_rw [Finset.mul_sum, mul_assoc] /-- Integral of a simple function `α →ₛ ℝ≥0∞` as a bilinear map. -/ def lintegralₗ {m : MeasurableSpace α} : (α →ₛ ℝ≥0∞) →ₗ[ℝ≥0∞] Measure α →ₗ[ℝ≥0∞] ℝ≥0∞ where toFun f := { toFun := lintegral f map_add' := by simp [lintegral, mul_add, Finset.sum_add_distrib] map_smul' := fun c μ => by simp [lintegral, mul_left_comm _ c, Finset.mul_sum, Measure.smul_apply c] } map_add' f g := LinearMap.ext fun _ => add_lintegral f g map_smul' c f := LinearMap.ext fun _ => const_mul_lintegral f c @[simp] theorem zero_lintegral : (0 : α →ₛ ℝ≥0∞).lintegral μ = 0 := LinearMap.ext_iff.1 lintegralₗ.map_zero μ theorem lintegral_add {ν} (f : α →ₛ ℝ≥0∞) : f.lintegral (μ + ν) = f.lintegral μ + f.lintegral ν := (lintegralₗ f).map_add μ ν theorem lintegral_smul {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (f : α →ₛ ℝ≥0∞) (c : R) : f.lintegral (c • μ) = c • f.lintegral μ := by simpa only [smul_one_smul] using (lintegralₗ f).map_smul (c • 1) μ @[simp] theorem lintegral_zero [MeasurableSpace α] (f : α →ₛ ℝ≥0∞) : f.lintegral 0 = 0 := (lintegralₗ f).map_zero theorem lintegral_finset_sum {ι} (f : α →ₛ ℝ≥0∞) (μ : ι → Measure α) (s : Finset ι) : f.lintegral (∑ i ∈ s, μ i) = ∑ i ∈ s, f.lintegral (μ i) := map_sum (lintegralₗ f) .. theorem lintegral_sum {m : MeasurableSpace α} {ι} (f : α →ₛ ℝ≥0∞) (μ : ι → Measure α) : f.lintegral (Measure.sum μ) = ∑' i, f.lintegral (μ i) := by simp only [lintegral, Measure.sum_apply, f.measurableSet_preimage, ← Finset.tsum_subtype, ← ENNReal.tsum_mul_left] apply ENNReal.tsum_comm open scoped Classical in theorem restrict_lintegral (f : α →ₛ ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) : (restrict f s).lintegral μ = ∑ r ∈ f.range, r * μ (f ⁻¹' {r} ∩ s) := calc (restrict f s).lintegral μ = ∑ r ∈ f.range, r * μ (restrict f s ⁻¹' {r}) := lintegral_eq_of_subset _ fun x hx => if hxs : x ∈ s then fun _ => by simp only [f.restrict_apply hs, indicator_of_mem hxs, mem_range_self] else False.elim <| hx <| by simp [*] _ = ∑ r ∈ f.range, r * μ (f ⁻¹' {r} ∩ s) := Finset.sum_congr rfl <| forall_mem_range.2 fun b => if hb : f b = 0 then by simp only [hb, zero_mul] else by rw [restrict_preimage_singleton _ hs hb, inter_comm] theorem lintegral_restrict {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (s : Set α) (μ : Measure α) : f.lintegral (μ.restrict s) = ∑ y ∈ f.range, y * μ (f ⁻¹' {y} ∩ s) := by simp only [lintegral, Measure.restrict_apply, f.measurableSet_preimage] theorem restrict_lintegral_eq_lintegral_restrict (f : α →ₛ ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) : (restrict f s).lintegral μ = f.lintegral (μ.restrict s) := by rw [f.restrict_lintegral hs, lintegral_restrict] theorem lintegral_restrict_iUnion_of_directed {ι : Type*} [Countable ι] (f : α →ₛ ℝ≥0∞) {s : ι → Set α} (hd : Directed (· ⊆ ·) s) (μ : Measure α) : f.lintegral (μ.restrict (⋃ i, s i)) = ⨆ i, f.lintegral (μ.restrict (s i)) := by simp only [lintegral, Measure.restrict_iUnion_apply_eq_iSup hd (measurableSet_preimage ..), ENNReal.mul_iSup] refine finsetSum_iSup fun i j ↦ (hd i j).imp fun k ⟨hik, hjk⟩ ↦ fun a ↦ ?_ -- TODO https://github.com/leanprover-community/mathlib4/pull/14739 make `gcongr` close this goal constructor <;> · gcongr; refine Measure.restrict_mono ?_ le_rfl _; assumption theorem const_lintegral (c : ℝ≥0∞) : (const α c).lintegral μ = c * μ univ := by rw [lintegral] cases isEmpty_or_nonempty α · simp [μ.eq_zero_of_isEmpty] · simp only [range_const, coe_const, Finset.sum_singleton] unfold Function.const; rw [preimage_const_of_mem (mem_singleton c)] theorem const_lintegral_restrict (c : ℝ≥0∞) (s : Set α) : (const α c).lintegral (μ.restrict s) = c * μ s := by rw [const_lintegral, Measure.restrict_apply MeasurableSet.univ, univ_inter] theorem restrict_const_lintegral (c : ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) : ((const α c).restrict s).lintegral μ = c * μ s := by rw [restrict_lintegral_eq_lintegral_restrict _ hs, const_lintegral_restrict] theorem lintegral_mono_fun {f g : α →ₛ ℝ≥0∞} (h : f ≤ g) : f.lintegral μ ≤ g.lintegral μ := by refine Monotone.of_left_le_map_sup (f := (lintegral · μ)) (fun f g ↦ ?_) h calc f.lintegral μ = ((pair f g).map Prod.fst).lintegral μ := by rw [map_fst_pair] _ ≤ ((pair f g).map fun p ↦ p.1 ⊔ p.2).lintegral μ := by simp only [map_lintegral] gcongr exact le_sup_left theorem le_sup_lintegral (f g : α →ₛ ℝ≥0∞) : f.lintegral μ ⊔ g.lintegral μ ≤ (f ⊔ g).lintegral μ := Monotone.le_map_sup (fun _ _ ↦ lintegral_mono_fun) f g theorem lintegral_mono_measure {f : α →ₛ ℝ≥0∞} (h : μ ≤ ν) : f.lintegral μ ≤ f.lintegral ν := by simp only [lintegral] gcongr apply h /-- `SimpleFunc.lintegral` is monotone both in function and in measure. -/ @[mono, gcongr] theorem lintegral_mono {f g : α →ₛ ℝ≥0∞} (hfg : f ≤ g) (hμν : μ ≤ ν) : f.lintegral μ ≤ g.lintegral ν := (lintegral_mono_fun hfg).trans (lintegral_mono_measure hμν) /-- `SimpleFunc.lintegral` depends only on the measures of `f ⁻¹' {y}`. -/ theorem lintegral_eq_of_measure_preimage [MeasurableSpace β] {f : α →ₛ ℝ≥0∞} {g : β →ₛ ℝ≥0∞} {ν : Measure β} (H : ∀ y, μ (f ⁻¹' {y}) = ν (g ⁻¹' {y})) : f.lintegral μ = g.lintegral ν := by simp only [lintegral, ← H] apply lintegral_eq_of_subset simp only [H] intros exact mem_range_of_measure_ne_zero ‹_› /-- If two simple functions are equal a.e., then their `lintegral`s are equal. -/ theorem lintegral_congr {f g : α →ₛ ℝ≥0∞} (h : f =ᵐ[μ] g) : f.lintegral μ = g.lintegral μ := lintegral_eq_of_measure_preimage fun y => measure_congr <| Eventually.set_eq <| h.mono fun x hx => by simp [hx] theorem lintegral_map' {β} [MeasurableSpace β] {μ' : Measure β} (f : α →ₛ ℝ≥0∞) (g : β →ₛ ℝ≥0∞) (m' : α → β) (eq : ∀ a, f a = g (m' a)) (h : ∀ s, MeasurableSet s → μ' s = μ (m' ⁻¹' s)) : f.lintegral μ = g.lintegral μ' := lintegral_eq_of_measure_preimage fun y => by simp only [preimage, eq] exact (h (g ⁻¹' {y}) (g.measurableSet_preimage _)).symm theorem lintegral_map {β} [MeasurableSpace β] (g : β →ₛ ℝ≥0∞) {f : α → β} (hf : Measurable f) : g.lintegral (Measure.map f μ) = (g.comp f hf).lintegral μ := Eq.symm <| lintegral_map' _ _ f (fun _ => rfl) fun _s hs => Measure.map_apply hf hs end Measure section FinMeasSupp open Finset Function open scoped Classical in theorem support_eq [MeasurableSpace α] [Zero β] (f : α →ₛ β) : support f = ⋃ y ∈ {y ∈ f.range | y ≠ 0}, f ⁻¹' {y} := Set.ext fun x => by simp only [mem_support, Set.mem_preimage, mem_filter, mem_range_self, true_and, exists_prop, mem_iUnion, mem_singleton_iff, exists_eq_right'] variable {m : MeasurableSpace α} [Zero β] [Zero γ] {μ : Measure α} {f : α →ₛ β} theorem measurableSet_support [MeasurableSpace α] (f : α →ₛ β) : MeasurableSet (support f) := by rw [f.support_eq] exact Finset.measurableSet_biUnion _ fun y _ => measurableSet_fiber _ _ lemma measure_support_lt_top (f : α →ₛ β) (hf : ∀ y, y ≠ 0 → μ (f ⁻¹' {y}) < ∞) : μ (support f) < ∞ := by classical rw [support_eq] refine (measure_biUnion_finset_le _ _).trans_lt (ENNReal.sum_lt_top.mpr fun y hy => ?_) rw [Finset.mem_filter] at hy exact hf y hy.2 /-- A `SimpleFunc` has finite measure support if it is equal to `0` outside of a set of finite measure. -/ protected def FinMeasSupp {_m : MeasurableSpace α} (f : α →ₛ β) (μ : Measure α) : Prop := f =ᶠ[μ.cofinite] 0 theorem finMeasSupp_iff_support : f.FinMeasSupp μ ↔ μ (support f) < ∞ := Iff.rfl theorem finMeasSupp_iff : f.FinMeasSupp μ ↔ ∀ y, y ≠ 0 → μ (f ⁻¹' {y}) < ∞ := by classical constructor · refine fun h y hy => lt_of_le_of_lt (measure_mono ?_) h exact fun x hx (H : f x = 0) => hy <| H ▸ Eq.symm hx · intro H rw [finMeasSupp_iff_support, support_eq] exact measure_biUnion_lt_top (finite_toSet _) fun y hy ↦ H y (mem_filter.1 hy).2 namespace FinMeasSupp theorem meas_preimage_singleton_ne_zero (h : f.FinMeasSupp μ) {y : β} (hy : y ≠ 0) : μ (f ⁻¹' {y}) < ∞ := finMeasSupp_iff.1 h y hy protected theorem map {g : β → γ} (hf : f.FinMeasSupp μ) (hg : g 0 = 0) : (f.map g).FinMeasSupp μ := flip lt_of_le_of_lt hf (measure_mono <| support_comp_subset hg f) theorem of_map {g : β → γ} (h : (f.map g).FinMeasSupp μ) (hg : ∀ b, g b = 0 → b = 0) : f.FinMeasSupp μ := flip lt_of_le_of_lt h <| measure_mono <| support_subset_comp @(hg) _ theorem map_iff {g : β → γ} (hg : ∀ {b}, g b = 0 ↔ b = 0) : (f.map g).FinMeasSupp μ ↔ f.FinMeasSupp μ := ⟨fun h => h.of_map fun _ => hg.1, fun h => h.map <| hg.2 rfl⟩ protected theorem pair {g : α →ₛ γ} (hf : f.FinMeasSupp μ) (hg : g.FinMeasSupp μ) : (pair f g).FinMeasSupp μ := calc μ (support <| pair f g) = μ (support f ∪ support g) := congr_arg μ <| support_prodMk f g _ ≤ μ (support f) + μ (support g) := measure_union_le _ _ _ < _ := add_lt_top.2 ⟨hf, hg⟩ protected theorem map₂ [Zero δ] (hf : f.FinMeasSupp μ) {g : α →ₛ γ} (hg : g.FinMeasSupp μ) {op : β → γ → δ} (H : op 0 0 = 0) : ((pair f g).map (Function.uncurry op)).FinMeasSupp μ := (hf.pair hg).map H protected theorem add {β} [AddZeroClass β] {f g : α →ₛ β} (hf : f.FinMeasSupp μ) (hg : g.FinMeasSupp μ) : (f + g).FinMeasSupp μ := by rw [add_eq_map₂] exact hf.map₂ hg (zero_add 0) protected theorem mul {β} [MulZeroClass β] {f g : α →ₛ β} (hf : f.FinMeasSupp μ) (hg : g.FinMeasSupp μ) : (f * g).FinMeasSupp μ := by rw [mul_eq_map₂] exact hf.map₂ hg (zero_mul 0) theorem lintegral_lt_top {f : α →ₛ ℝ≥0∞} (hm : f.FinMeasSupp μ) (hf : ∀ᵐ a ∂μ, f a ≠ ∞) : f.lintegral μ < ∞ := by refine sum_lt_top.2 fun a ha => ?_ rcases eq_or_ne a ∞ with (rfl | ha) · simp only [ae_iff, Ne, Classical.not_not] at hf simp [Set.preimage, hf] · by_cases ha0 : a = 0 · subst a simp · exact mul_lt_top ha.lt_top (finMeasSupp_iff.1 hm _ ha0) theorem of_lintegral_ne_top {f : α →ₛ ℝ≥0∞} (h : f.lintegral μ ≠ ∞) : f.FinMeasSupp μ := by refine finMeasSupp_iff.2 fun b hb => ?_ rw [f.lintegral_eq_of_subset' (Finset.subset_insert b _)] at h refine ENNReal.lt_top_of_mul_ne_top_right ?_ hb exact (lt_top_of_sum_ne_top h (Finset.mem_insert_self _ _)).ne theorem iff_lintegral_lt_top {f : α →ₛ ℝ≥0∞} (hf : ∀ᵐ a ∂μ, f a ≠ ∞) : f.FinMeasSupp μ ↔ f.lintegral μ < ∞ := ⟨fun h => h.lintegral_lt_top hf, fun h => of_lintegral_ne_top h.ne⟩ end FinMeasSupp lemma measure_support_lt_top_of_lintegral_ne_top {f : α →ₛ ℝ≥0∞} (hf : f.lintegral μ ≠ ∞) : μ (support f) < ∞ := by refine measure_support_lt_top f ?_ rw [← finMeasSupp_iff] exact FinMeasSupp.of_lintegral_ne_top hf end FinMeasSupp /-- To prove something for an arbitrary simple function, it suffices to show that the property holds for (multiples of) characteristic functions and is closed under addition (of functions with disjoint support). It is possible to make the hypotheses in `h_add` a bit stronger, and such conditions can be added once we need them (for example it is only necessary to consider the case where `g` is a multiple of a characteristic function, and that this multiple doesn't appear in the image of `f`). To use in an induction proof, the syntax is `induction f using SimpleFunc.induction with`. -/ @[elab_as_elim] protected theorem induction {α γ} [MeasurableSpace α] [AddZeroClass γ] {motive : SimpleFunc α γ → Prop} (const : ∀ (c) {s} (hs : MeasurableSet s), motive (SimpleFunc.piecewise s hs (SimpleFunc.const _ c) (SimpleFunc.const _ 0))) (add : ∀ ⦃f g : SimpleFunc α γ⦄, Disjoint (support f) (support g) → motive f → motive g → motive (f + g)) (f : SimpleFunc α γ) : motive f := by classical generalize h : f.range \ {0} = s rw [← Finset.coe_inj, Finset.coe_sdiff, Finset.coe_singleton, SimpleFunc.coe_range] at h induction s using Finset.induction generalizing f with | empty => rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h convert const 0 MeasurableSet.univ ext x simp [h] | insert x s hxs ih => have mx := f.measurableSet_preimage {x} let g := SimpleFunc.piecewise (f ⁻¹' {x}) mx 0 f have Pg : motive g := by apply ih simp only [g, SimpleFunc.coe_piecewise, range_piecewise] rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert, insert_diff_self_of_notMem, diff_eq_empty.mpr, Set.empty_union] · rw [Set.image_subset_iff] convert Set.subset_univ _ exact preimage_const_of_mem (mem_singleton _) · rwa [Finset.mem_coe] convert add _ Pg (const x mx) · ext1 y by_cases hy : y ∈ f ⁻¹' {x} · simpa [g, hy] · simp [g, hy] rw [disjoint_iff_inf_le] rintro y by_cases hy : y ∈ f ⁻¹' {x} <;> simp [g, hy] /-- To prove something for an arbitrary simple function, it suffices to show that the property holds for constant functions and that it is closed under piecewise combinations of functions. To use in an induction proof, the syntax is `induction f with`. -/ @[induction_eliminator] protected theorem induction' {α γ} [MeasurableSpace α] [Nonempty γ] {P : SimpleFunc α γ → Prop} (const : ∀ (c), P (SimpleFunc.const _ c)) (pcw : ∀ ⦃f g : SimpleFunc α γ⦄ {s} (hs : MeasurableSet s), P f → P g → P (f.piecewise s hs g)) (f : SimpleFunc α γ) : P f := by let c : γ := Classical.ofNonempty classical generalize h : f.range \ {c} = s rw [← Finset.coe_inj, Finset.coe_sdiff, Finset.coe_singleton, SimpleFunc.coe_range] at h induction s using Finset.induction generalizing f with | empty => rw [Finset.coe_empty, diff_eq_empty, range_subset_singleton] at h convert const c ext x simp [h] | insert x s hxs ih => have mx := f.measurableSet_preimage {x} let g := SimpleFunc.piecewise (f ⁻¹' {x}) mx (SimpleFunc.const α c) f have Pg : P g := by apply ih simp only [g, SimpleFunc.coe_piecewise, range_piecewise] rw [image_compl_preimage, union_diff_distrib, diff_diff_comm, h, Finset.coe_insert, insert_diff_self_of_notMem, diff_eq_empty.mpr, Set.empty_union] · rw [Set.image_subset_iff] convert Set.subset_univ _ exact preimage_const_of_mem (mem_singleton _) · rwa [Finset.mem_coe] convert pcw mx.compl Pg (const x) · ext1 y by_cases hy : y ∈ f ⁻¹' {x} · simpa [g, hy] · simp [g, hy] /-- In a topological vector space, the addition of a measurable function and a simple function is measurable. -/ theorem _root_.Measurable.add_simpleFunc {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddCancelMonoid E] [MeasurableAdd E] {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) : Measurable (g + (f : α → E)) := by classical induction f using SimpleFunc.induction with | @const c s hs => simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const, SimpleFunc.coe_zero] rw [← s.piecewise_same g, ← piecewise_add] exact Measurable.piecewise hs (hg.add_const _) (hg.add_const _) | @add f f' hff' hf hf' => have : (g + ↑(f + f')) = (Function.support f).piecewise (g + (f : α → E)) (g + f') := by ext x by_cases hx : x ∈ Function.support f · simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not, Set.piecewise_eq_of_mem _ _ _ hx, _root_.add_right_inj, add_eq_left] using Set.disjoint_left.1 hff' hx · simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not, Set.piecewise_eq_of_notMem _ _ _ hx, _root_.add_right_inj, add_eq_right] using hx rw [this] exact Measurable.piecewise f.measurableSet_support hf hf' /-- In a topological vector space, the addition of a simple function and a measurable function is measurable. -/ theorem _root_.Measurable.simpleFunc_add {E : Type*} {_ : MeasurableSpace α} [MeasurableSpace E] [AddCancelMonoid E] [MeasurableAdd E] {g : α → E} (hg : Measurable g) (f : SimpleFunc α E) : Measurable ((f : α → E) + g) := by classical induction f using SimpleFunc.induction with | @const c s hs => simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const, SimpleFunc.coe_zero] rw [← s.piecewise_same g, ← piecewise_add] exact Measurable.piecewise hs (hg.const_add _) (hg.const_add _) | @add f f' hff' hf hf' => have : (↑(f + f') + g) = (Function.support f).piecewise ((f : α → E) + g) (f' + g) := by ext x by_cases hx : x ∈ Function.support f · simpa only [coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not, Set.piecewise_eq_of_mem _ _ _ hx, _root_.add_left_inj, add_eq_left] using Set.disjoint_left.1 hff' hx · simpa only [SimpleFunc.coe_add, Pi.add_apply, Function.mem_support, ne_eq, not_not, Set.piecewise_eq_of_notMem _ _ _ hx, _root_.add_left_inj, add_eq_right] using hx rw [this] exact Measurable.piecewise f.measurableSet_support hf hf' end SimpleFunc end MeasureTheory open MeasureTheory MeasureTheory.SimpleFunc variable {α : Type*} {mα : MeasurableSpace α} {μ : Measure α} /-- To prove something for an arbitrary measurable function into `ℝ≥0∞`, it suffices to show that the property holds for (multiples of) characteristic functions and is closed under addition and supremum of increasing sequences of functions. It is possible to make the hypotheses in the induction steps a bit stronger, and such conditions can be added once we need them (for example in `h_add` it is only necessary to consider the sum of a simple function with a multiple of a characteristic function and that the intersection of their images is a subset of `{0}`. -/ @[elab_as_elim] theorem Measurable.ennreal_induction {motive : (α → ℝ≥0∞) → Prop} (indicator : ∀ (c : ℝ≥0∞) ⦃s⦄, MeasurableSet s → motive (Set.indicator s fun _ => c)) (add : ∀ ⦃f g : α → ℝ≥0∞⦄, Disjoint (support f) (support g) → Measurable f → Measurable g → motive f → motive g → motive (f + g)) (iSup : ∀ ⦃f : ℕ → α → ℝ≥0∞⦄, (∀ n, Measurable (f n)) → Monotone f → (∀ n, motive (f n)) → motive fun x => ⨆ n, f n x) ⦃f : α → ℝ≥0∞⦄ (hf : Measurable f) : motive f := by convert iSup (fun n => (eapprox f n).measurable) (monotone_eapprox f) _ using 2 · rw [iSup_eapprox_apply hf] · exact fun n => SimpleFunc.induction (fun c s hs => indicator c hs) (fun f g hfg hf hg => add hfg f.measurable g.measurable hf hg) (eapprox f n) /-- To prove something for an arbitrary measurable function into `ℝ≥0∞`, it suffices to show that the property holds for (multiples of) characteristic functions with finite mass according to some sigma-finite measure and is closed under addition and supremum of increasing sequences of functions. It is possible to make the hypotheses in the induction steps a bit stronger, and such conditions can be added once we need them (for example in `h_add` it is only necessary to consider the sum of a simple function with a multiple of a characteristic function and that the intersection of their images is a subset of `{0}`. -/ @[elab_as_elim] lemma Measurable.ennreal_sigmaFinite_induction [SigmaFinite μ] {motive : (α → ℝ≥0∞) → Prop} (indicator : ∀ (c : ℝ≥0∞) ⦃s⦄, MeasurableSet s → μ s < ∞ → motive (Set.indicator s fun _ ↦ c)) (add : ∀ ⦃f g : α → ℝ≥0∞⦄, Disjoint (support f) (support g) → Measurable f → Measurable g → motive f → motive g → motive (f + g)) (iSup : ∀ ⦃f : ℕ → α → ℝ≥0∞⦄, (∀ n, Measurable (f n)) → Monotone f → (∀ n, motive (f n)) → motive fun x => ⨆ n, f n x) ⦃f : α → ℝ≥0∞⦄ (hf : Measurable f) : motive f := by refine Measurable.ennreal_induction (fun c s hs ↦ ?_) add iSup hf convert iSup (f := fun n ↦ (s ∩ spanningSets μ n).indicator fun _ ↦ c) (fun n ↦ measurable_const.indicator (hs.inter (measurableSet_spanningSets ..))) (fun m n hmn a ↦ Set.indicator_le_indicator_of_subset (by gcongr) (by simp) _) (fun n ↦ indicator _ (hs.inter (measurableSet_spanningSets ..)) (measure_inter_lt_top_of_right_ne_top (measure_spanningSets_lt_top ..).ne)) with a simp [← Set.indicator_iUnion_apply (M := ℝ≥0∞) rfl, ← Set.inter_iUnion]
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpOrder.lean
import Mathlib.Analysis.Normed.Order.Lattice import Mathlib.MeasureTheory.Function.ConvergenceInMeasure import Mathlib.MeasureTheory.Function.LpSpace.Basic /-! # Order related properties of Lp spaces ## Results - `Lp E p μ` is an `OrderedAddCommGroup` when `E` is a `NormedLatticeAddCommGroup`. ## TODO - move definitions of `Lp.posPart` and `Lp.negPart` to this file, and define them as `PosPart.pos` and `NegPart.neg` given by the lattice structure. -/ open TopologicalSpace MeasureTheory open scoped ENNReal variable {α E : Type*} {m : MeasurableSpace α} {μ : Measure α} {p : ℝ≥0∞} namespace MeasureTheory namespace Lp section Order variable [NormedAddCommGroup E] section PartialOrder variable [PartialOrder E] theorem coeFn_le (f g : Lp E p μ) : f ≤ᵐ[μ] g ↔ f ≤ g := by rw [← Subtype.coe_le_coe, ← AEEqFun.coeFn_le] theorem coeFn_nonneg (f : Lp E p μ) : 0 ≤ᵐ[μ] f ↔ 0 ≤ f := by rw [← coeFn_le] have h0 := Lp.coeFn_zero E p μ constructor <;> intro h <;> filter_upwards [h, h0] with _ _ h2 · rwa [h2] · rwa [← h2] variable [OrderClosedTopology E] [IsOrderedAddMonoid E] instance instAddLeftMono : AddLeftMono (Lp E p μ) := by refine ⟨fun f g₁ g₂ hg₁₂ => ?_⟩ rw [← coeFn_le] at hg₁₂ ⊢ filter_upwards [coeFn_add f g₁, coeFn_add f g₂, hg₁₂] with _ h1 h2 h3 rw [h1, h2, Pi.add_apply, Pi.add_apply] exact add_le_add le_rfl h3 instance instIsOrderedAddMonoid : IsOrderedAddMonoid (Lp E p μ) := { add_le_add_left := fun _ _ => add_le_add_left } instance [Fact (1 ≤ p)] : OrderClosedTopology (Lp E p μ) where isClosed_le' := isClosed_le_of_isClosed_nonneg <| IsSeqClosed.isClosed <| fun f f₀ (hf : ∀ n, 0 ≤ f n) h_tendsto ↦ by simp only [← coeFn_nonneg] at hf ⊢ obtain ⟨φ, -, hφ⟩ := tendstoInMeasure_of_tendsto_Lp h_tendsto |>.exists_seq_tendsto_ae filter_upwards [countable_iInter_mem.mpr hf, hφ] with x hx hφx exact ge_of_tendsto' hφx fun _ ↦ Set.mem_iInter.mp hx _ end PartialOrder section Lattice variable [Lattice E] [HasSolidNorm E] [IsOrderedAddMonoid E] theorem _root_.MeasureTheory.MemLp.sup {f g : α → E} (hf : MemLp f p μ) (hg : MemLp g p μ) : MemLp (f ⊔ g) p μ := MemLp.mono' (hf.norm.add hg.norm) (hf.1.sup hg.1) (Filter.Eventually.of_forall fun x => norm_sup_le_add (f x) (g x)) theorem _root_.MeasureTheory.MemLp.inf {f g : α → E} (hf : MemLp f p μ) (hg : MemLp g p μ) : MemLp (f ⊓ g) p μ := MemLp.mono' (hf.norm.add hg.norm) (hf.1.inf hg.1) (Filter.Eventually.of_forall fun x => norm_inf_le_add (f x) (g x)) theorem _root_.MeasureTheory.MemLp.abs {f : α → E} (hf : MemLp f p μ) : MemLp |f| p μ := hf.sup hf.neg instance instLattice : Lattice (Lp E p μ) := Subtype.lattice (fun f g hf hg => by rw [mem_Lp_iff_memLp] at * exact (memLp_congr_ae (AEEqFun.coeFn_sup _ _)).mpr (hf.sup hg)) fun f g hf hg => by rw [mem_Lp_iff_memLp] at * exact (memLp_congr_ae (AEEqFun.coeFn_inf _ _)).mpr (hf.inf hg) theorem coeFn_sup (f g : Lp E p μ) : ⇑(f ⊔ g) =ᵐ[μ] ⇑f ⊔ ⇑g := AEEqFun.coeFn_sup _ _ theorem coeFn_inf (f g : Lp E p μ) : ⇑(f ⊓ g) =ᵐ[μ] ⇑f ⊓ ⇑g := AEEqFun.coeFn_inf _ _ theorem coeFn_abs (f : Lp E p μ) : ⇑|f| =ᵐ[μ] fun x => |f x| := AEEqFun.coeFn_abs _ instance instHasSolidNorm [Fact (1 ≤ p)] : HasSolidNorm (Lp E p μ) := { solid := fun f g hfg => by rw [← coeFn_le] at hfg simp_rw [Lp.norm_def, ENNReal.toReal_le_toReal (Lp.eLpNorm_ne_top f) (Lp.eLpNorm_ne_top g)] refine eLpNorm_mono_ae ?_ filter_upwards [hfg, Lp.coeFn_abs f, Lp.coeFn_abs g] with x hx hxf hxg rw [hxf, hxg] at hx exact HasSolidNorm.solid hx } end Lattice end Order end Lp end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/Intersectivity.lean
import Mathlib.MeasureTheory.Integral.Average /-! # Bergelson's intersectivity lemma This file proves the Bergelson intersectivity lemma: In a finite measure space, a sequence of events that have measure at least `r` has an infinite subset whose finite intersections all have positive volume. This is in some sense a finitary version of the second Borel-Cantelli lemma. ## References [Bergelson, *Sets of recurrence of `ℤᵐ`-actions and properties of sets of differences in `ℤᵐ`][bergelson1985] ## TODO Restate the theorem using the upper density of a set of naturals, once we have it. This will make `bergelson'` be actually strong (and please then rename it to `strong_bergelson`). Use the ergodic theorem to deduce the refinement of the Poincaré recurrence theorem proved by Bergelson. -/ open Filter Function MeasureTheory Set open scoped ENNReal variable {ι α : Type*} [MeasurableSpace α] {μ : Measure α} [IsFiniteMeasure μ] {r : ℝ≥0∞} /-- **Bergelson Intersectivity Lemma**: In a finite measure space, a sequence of events that have measure at least `r` has an infinite subset whose finite intersections all have positive volume. TODO: The infinity of `t` should be strengthened to `t` having positive natural density. -/ lemma bergelson' {s : ℕ → Set α} (hs : ∀ n, MeasurableSet (s n)) (hr₀ : r ≠ 0) (hr : ∀ n, r ≤ μ (s n)) : ∃ t : Set ℕ, t.Infinite ∧ ∀ ⦃u⦄, u ⊆ t → u.Finite → 0 < μ (⋂ n ∈ u, s n) := by -- We let `M f` be the set on which the norm of `f` exceeds its essential supremum, and `N` be the -- union of `M` of the finite products of the indicators of the `s n`. let M (f : α → ℝ) : Set α := {x | eLpNormEssSup f μ < ‖f x‖₊} let N : Set α := ⋃ u : Finset ℕ, M (Set.indicator (⋂ n ∈ u, s n) 1) -- `N` is a null set since `M f` is a null set for each `f`. have hN₀ : μ N = 0 := measure_iUnion_null fun u ↦ meas_eLpNormEssSup_lt -- The important thing about `N` is that if we remove `N` from our space, then finite unions of -- the `s n` are null iff they are empty. have hN₁ (u : Finset ℕ) : ((⋂ n ∈ u, s n) \ N).Nonempty → 0 < μ (⋂ n ∈ u, s n) := by simp_rw [pos_iff_ne_zero] rintro ⟨x, hx⟩ hu refine hx.2 (mem_iUnion.2 ⟨u, ?_⟩) rw [mem_setOf, indicator_of_mem hx.1, eLpNormEssSup_eq_zero_iff.2] · simp · rwa [indicator_ae_eq_zero, Function.support_one, inter_univ] -- Define `f n` to be the average of the first `n + 1` indicators of the `s k`. let f (n : ℕ) : α → ℝ≥0∞ := (↑(n + 1) : ℝ≥0∞)⁻¹ • ∑ k ∈ Finset.range (n + 1), (s k).indicator 1 -- We gather a few simple properties of `f`. have hfapp : ∀ n a, f n a = (↑(n + 1))⁻¹ * ∑ k ∈ Finset.range (n + 1), (s k).indicator 1 a := by simp only [f, Pi.smul_apply, Finset.sum_apply, forall_const, imp_true_iff, smul_eq_mul] have hf n : Measurable (f n) := by fun_prop (disch := exact hs _) have hf₁ n : f n ≤ 1 := by rintro a rw [hfapp, ← ENNReal.div_eq_inv_mul] refine (ENNReal.div_le_iff_le_mul (Or.inl <| Nat.cast_ne_zero.2 n.succ_ne_zero) <| Or.inr one_ne_zero).2 ?_ rw [mul_comm, ← nsmul_eq_mul, ← Finset.card_range n.succ] exact Finset.sum_le_card_nsmul _ _ _ fun _ _ ↦ indicator_le (fun _ _ ↦ le_rfl) _ -- By assumption, `f n` has integral at least `r`. have hrf n : r ≤ ∫⁻ a, f n a ∂μ := by simp_rw [hfapp] rw [lintegral_const_mul _ <| Finset.measurable_fun_sum _ fun _ _ ↦ measurable_one.indicator <| hs _, lintegral_finset_sum _ fun _ _ ↦ measurable_one.indicator (hs _)] simp only [lintegral_indicator_one (hs _)] rw [← ENNReal.div_eq_inv_mul, ENNReal.le_div_iff_mul_le (by simp) (by simp), ← nsmul_eq_mul'] simpa using Finset.card_nsmul_le_sum (Finset.range (n + 1)) _ _ fun _ _ ↦ hr _ -- Collect some basic fact have hμ : μ ≠ 0 := by rintro rfl; exact hr₀ <| le_bot_iff.1 <| hr 0 have : ∫⁻ x, limsup (f · x) atTop ∂μ ≤ μ univ := by rw [← lintegral_one] exact lintegral_mono fun a ↦ limsup_le_of_le ⟨0, fun R _ ↦ bot_le⟩ <| Eventually.of_forall fun n ↦ hf₁ _ _ -- By the first moment method, there exists some `x ∉ N` such that `limsup f n x` is at least `r`. obtain ⟨x, hxN, hx⟩ := exists_notMem_null_laverage_le hμ (ne_top_of_le_ne_top (by finiteness) this) hN₀ replace hx : r / μ univ ≤ limsup (f · x) atTop := calc _ ≤ limsup (⨍⁻ x, f · x ∂μ) atTop := le_limsup_of_le ⟨1, eventually_map.2 ?_⟩ fun b hb ↦ ?_ _ ≤ ⨍⁻ x, limsup (f · x) atTop ∂μ := limsup_lintegral_le 1 hf (ae_of_all _ <| hf₁ ·) (by simp) _ ≤ limsup (f · x) atTop := hx -- This exactly means that the `s n` containing `x` have all their finite intersection non-null. · refine ⟨{n | x ∈ s n}, fun hxs ↦ ?_, fun u hux hu ↦ ?_⟩ -- This next block proves that a set of strictly positive natural density is infinite, mixed -- with the fact that `{n | x ∈ s n}` has strictly positive natural density. -- TODO: Separate it out to a lemma once we have a natural density API. · refine ENNReal.div_ne_zero.2 ⟨hr₀, by finiteness⟩ <| eq_bot_mono hx <| Tendsto.limsup_eq <| tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (h := fun n ↦ (n.succ : ℝ≥0∞)⁻¹ * hxs.toFinset.card) ?_ bot_le fun n ↦ mul_le_mul_left' ?_ _ · simpa using ENNReal.Tendsto.mul_const (ENNReal.tendsto_inv_nat_nhds_zero.comp <| tendsto_add_atTop_nat 1) (.inr <| ENNReal.natCast_ne_top _) · classical simpa only [Finset.sum_apply, indicator_apply, Pi.one_apply, Finset.sum_boole, Nat.cast_le] using Finset.card_le_card fun m hm ↦ hxs.mem_toFinset.2 (Finset.mem_filter.1 hm).2 · simp_rw [← hu.mem_toFinset] exact hN₁ _ ⟨x, mem_iInter₂.2 fun n hn ↦ hux <| hu.mem_toFinset.1 hn, hxN⟩ · refine Eventually.of_forall fun n ↦ ?_ obtain rfl | _ := eq_zero_or_neZero μ · simp · rw [← laverage_const μ 1] exact lintegral_mono (hf₁ _) · obtain ⟨n, hn⟩ := hb.exists rw [laverage_eq] at hn exact (ENNReal.div_le_div_right (hrf _) _).trans hn /-- **Bergelson Intersectivity Lemma**: In a finite measure space, a sequence of events that have measure at least `r` has an infinite subset whose finite intersections all have positive volume. -/ lemma bergelson [Infinite ι] {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i)) (hr₀ : r ≠ 0) (hr : ∀ i, r ≤ μ (s i)) : ∃ t : Set ι, t.Infinite ∧ ∀ ⦃u⦄, u ⊆ t → u.Finite → 0 < μ (⋂ i ∈ u, s i) := by obtain ⟨t, ht, h⟩ := bergelson' (fun n ↦ hs <| Infinite.natEmbedding _ n) hr₀ (fun n ↦ hr _) refine ⟨_, ht.image <| (Infinite.natEmbedding _).injective.injOn, fun u hut hu ↦ (h (preimage_subset_of_surjOn (Infinite.natEmbedding _).injective hut) <| hu.preimage (Embedding.injective _).injOn).trans_le <| measure_mono <| subset_iInter₂ fun i hi ↦ ?_⟩ obtain ⟨n, -, rfl⟩ := hut hi exact iInter₂_subset n hi
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/UniformIntegrable.lean
import Mathlib.MeasureTheory.Function.ConvergenceInMeasure import Mathlib.MeasureTheory.Function.L1Space.Integrable /-! # Uniform integrability This file contains the definitions for uniform integrability (both in the measure theory sense as well as the probability theory sense). This file also contains the Vitali convergence theorem which establishes a relation between uniform integrability, convergence in measure and Lp convergence. Uniform integrability plays a vital role in the theory of martingales most notably is used to formulate the martingale convergence theorem. ## Main definitions * `MeasureTheory.UnifIntegrable`: uniform integrability in the measure theory sense. In particular, a sequence of functions `f` is uniformly integrable if for all `ε > 0`, there exists some `δ > 0` such that for all sets `s` of smaller measure than `δ`, the Lp-norm of `f i` restricted `s` is smaller than `ε` for all `i`. * `MeasureTheory.UniformIntegrable`: uniform integrability in the probability theory sense. In particular, a sequence of measurable functions `f` is uniformly integrable in the probability theory sense if it is uniformly integrable in the measure theory sense and has uniformly bounded Lp-norm. ## Main results * `MeasureTheory.unifIntegrable_finite`: a finite sequence of Lp functions is uniformly integrable. * `MeasureTheory.tendsto_Lp_finite_of_tendsto_ae`: a sequence of Lp functions which is uniformly integrable converges in Lp if they converge almost everywhere. * `MeasureTheory.tendstoInMeasure_iff_tendsto_Lp_finite`: Vitali convergence theorem: a sequence of Lp functions converges in Lp if and only if it is uniformly integrable and converges in measure. ## Tags uniform integrable, uniformly absolutely continuous integral, Vitali convergence theorem -/ noncomputable section open scoped MeasureTheory NNReal ENNReal Topology namespace MeasureTheory open Set Filter TopologicalSpace variable {α β ι : Type*} {m : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup β] /-- Uniform integrability in the measure theory sense. A sequence of functions `f` is said to be uniformly integrable if for all `ε > 0`, there exists some `δ > 0` such that for all sets `s` with measure less than `δ`, the Lp-norm of `f i` restricted on `s` is less than `ε`. Uniform integrability is also known as uniformly absolutely continuous integrals. -/ def UnifIntegrable {_ : MeasurableSpace α} (f : ι → α → β) (p : ℝ≥0∞) (μ : Measure α) : Prop := ∀ ⦃ε : ℝ⦄ (_ : 0 < ε), ∃ (δ : ℝ) (_ : 0 < δ), ∀ i s, MeasurableSet s → μ s ≤ ENNReal.ofReal δ → eLpNorm (s.indicator (f i)) p μ ≤ ENNReal.ofReal ε /-- In probability theory, a family of measurable functions is uniformly integrable if it is uniformly integrable in the measure theory sense and is uniformly bounded. -/ def UniformIntegrable {_ : MeasurableSpace α} (f : ι → α → β) (p : ℝ≥0∞) (μ : Measure α) : Prop := (∀ i, AEStronglyMeasurable (f i) μ) ∧ UnifIntegrable f p μ ∧ ∃ C : ℝ≥0, ∀ i, eLpNorm (f i) p μ ≤ C namespace UniformIntegrable protected theorem aestronglyMeasurable {f : ι → α → β} {p : ℝ≥0∞} (hf : UniformIntegrable f p μ) (i : ι) : AEStronglyMeasurable (f i) μ := hf.1 i protected theorem unifIntegrable {f : ι → α → β} {p : ℝ≥0∞} (hf : UniformIntegrable f p μ) : UnifIntegrable f p μ := hf.2.1 protected theorem memLp {f : ι → α → β} {p : ℝ≥0∞} (hf : UniformIntegrable f p μ) (i : ι) : MemLp (f i) p μ := ⟨hf.1 i, let ⟨_, _, hC⟩ := hf.2 lt_of_le_of_lt (hC i) ENNReal.coe_lt_top⟩ end UniformIntegrable section UnifIntegrable /-! ### `UnifIntegrable` This section deals with uniform integrability in the measure theory sense. -/ namespace UnifIntegrable variable {f g : ι → α → β} {p : ℝ≥0∞} protected theorem add (hf : UnifIntegrable f p μ) (hg : UnifIntegrable g p μ) (hp : 1 ≤ p) (hf_meas : ∀ i, AEStronglyMeasurable (f i) μ) (hg_meas : ∀ i, AEStronglyMeasurable (g i) μ) : UnifIntegrable (f + g) p μ := by intro ε hε have hε2 : 0 < ε / 2 := half_pos hε obtain ⟨δ₁, hδ₁_pos, hfδ₁⟩ := hf hε2 obtain ⟨δ₂, hδ₂_pos, hgδ₂⟩ := hg hε2 refine ⟨min δ₁ δ₂, lt_min hδ₁_pos hδ₂_pos, fun i s hs hμs => ?_⟩ simp_rw [Pi.add_apply, Set.indicator_add'] refine (eLpNorm_add_le ((hf_meas i).indicator hs) ((hg_meas i).indicator hs) hp).trans ?_ have hε_halves : ENNReal.ofReal ε = ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2) := by rw [← ENNReal.ofReal_add hε2.le hε2.le, add_halves] rw [hε_halves] exact add_le_add (hfδ₁ i s hs (hμs.trans (ENNReal.ofReal_le_ofReal (min_le_left _ _)))) (hgδ₂ i s hs (hμs.trans (ENNReal.ofReal_le_ofReal (min_le_right _ _)))) protected theorem neg (hf : UnifIntegrable f p μ) : UnifIntegrable (-f) p μ := by simp_rw [UnifIntegrable, Pi.neg_apply, Set.indicator_neg', eLpNorm_neg] exact hf protected theorem sub (hf : UnifIntegrable f p μ) (hg : UnifIntegrable g p μ) (hp : 1 ≤ p) (hf_meas : ∀ i, AEStronglyMeasurable (f i) μ) (hg_meas : ∀ i, AEStronglyMeasurable (g i) μ) : UnifIntegrable (f - g) p μ := by rw [sub_eq_add_neg] exact hf.add hg.neg hp hf_meas fun i => (hg_meas i).neg protected theorem ae_eq (hf : UnifIntegrable f p μ) (hfg : ∀ n, f n =ᵐ[μ] g n) : UnifIntegrable g p μ := by classical intro ε hε obtain ⟨δ, hδ_pos, hfδ⟩ := hf hε refine ⟨δ, hδ_pos, fun n s hs hμs => (le_of_eq <| eLpNorm_congr_ae ?_).trans (hfδ n s hs hμs)⟩ filter_upwards [hfg n] with x hx simp_rw [Set.indicator_apply, hx] /-- Uniform integrability is preserved by restriction of the functions to a set. -/ protected theorem indicator (hf : UnifIntegrable f p μ) (E : Set α) : UnifIntegrable (fun i => E.indicator (f i)) p μ := fun ε hε ↦ by obtain ⟨δ, hδ_pos, hε⟩ := hf hε refine ⟨δ, hδ_pos, fun i s hs hμs ↦ ?_⟩ calc eLpNorm (s.indicator (E.indicator (f i))) p μ = eLpNorm (E.indicator (s.indicator (f i))) p μ := by simp only [indicator_indicator, inter_comm] _ ≤ eLpNorm (s.indicator (f i)) p μ := eLpNorm_indicator_le _ _ ≤ ENNReal.ofReal ε := hε _ _ hs hμs /-- Uniform integrability is preserved by restriction of the measure to a set. -/ protected theorem restrict (hf : UnifIntegrable f p μ) (E : Set α) : UnifIntegrable f p (μ.restrict E) := fun ε hε ↦ by obtain ⟨δ, hδ_pos, hδε⟩ := hf hε refine ⟨δ, hδ_pos, fun i s hs hμs ↦ ?_⟩ rw [μ.restrict_apply hs, ← measure_toMeasurable] at hμs calc eLpNorm (indicator s (f i)) p (μ.restrict E) = eLpNorm (f i) p (μ.restrict (s ∩ E)) := by rw [eLpNorm_indicator_eq_eLpNorm_restrict hs, μ.restrict_restrict hs] _ ≤ eLpNorm (f i) p (μ.restrict (toMeasurable μ (s ∩ E))) := eLpNorm_mono_measure _ <| Measure.restrict_mono (subset_toMeasurable _ _) le_rfl _ = eLpNorm (indicator (toMeasurable μ (s ∩ E)) (f i)) p μ := (eLpNorm_indicator_eq_eLpNorm_restrict (measurableSet_toMeasurable _ _)).symm _ ≤ ENNReal.ofReal ε := hδε i _ (measurableSet_toMeasurable _ _) hμs end UnifIntegrable theorem unifIntegrable_zero_meas [MeasurableSpace α] {p : ℝ≥0∞} {f : ι → α → β} : UnifIntegrable f p (0 : Measure α) := fun ε _ => ⟨1, one_pos, fun i s _ _ => by simp⟩ theorem unifIntegrable_congr_ae {p : ℝ≥0∞} {f g : ι → α → β} (hfg : ∀ n, f n =ᵐ[μ] g n) : UnifIntegrable f p μ ↔ UnifIntegrable g p μ := ⟨fun hf => hf.ae_eq hfg, fun hg => hg.ae_eq fun n => (hfg n).symm⟩ theorem tendsto_indicator_ge (f : α → β) (x : α) : Tendsto (fun M : ℕ => { x | (M : ℝ) ≤ ‖f x‖₊ }.indicator f x) atTop (𝓝 0) := by refine tendsto_atTop_of_eventually_const (i₀ := Nat.ceil (‖f x‖₊ : ℝ) + 1) fun n hn => ?_ rw [Set.indicator_of_notMem] simp only [not_le, Set.mem_setOf_eq] refine lt_of_le_of_lt (Nat.le_ceil _) ?_ refine lt_of_lt_of_le (lt_add_one _) ?_ norm_cast variable {p : ℝ≥0∞} section variable {f : α → β} /-- This lemma is weaker than `MeasureTheory.MemLp.integral_indicator_norm_ge_nonneg_le` as the latter provides `0 ≤ M` and does not require the measurability of `f`. -/ theorem MemLp.integral_indicator_norm_ge_le (hf : MemLp f 1 μ) (hmeas : StronglyMeasurable f) {ε : ℝ} (hε : 0 < ε) : ∃ M : ℝ, (∫⁻ x, ‖{ x | M ≤ ‖f x‖₊ }.indicator f x‖₊ ∂μ) ≤ ENNReal.ofReal ε := by have htendsto : ∀ᵐ x ∂μ, Tendsto (fun M : ℕ => { x | (M : ℝ) ≤ ‖f x‖₊ }.indicator f x) atTop (𝓝 0) := univ_mem' (id fun x => tendsto_indicator_ge f x) have hmeas : ∀ M : ℕ, AEStronglyMeasurable ({ x | (M : ℝ) ≤ ‖f x‖₊ }.indicator f) μ := by intro M apply hf.1.indicator apply StronglyMeasurable.measurableSet_le stronglyMeasurable_const hmeas.nnnorm.measurable.coe_nnreal_real.stronglyMeasurable have hbound : HasFiniteIntegral (fun x => ‖f x‖) μ := by rw [memLp_one_iff_integrable] at hf exact hf.norm.2 have : Tendsto (fun n : ℕ ↦ ∫⁻ a, ENNReal.ofReal ‖{ x | n ≤ ‖f x‖₊ }.indicator f a - 0‖ ∂μ) atTop (𝓝 0) := by refine tendsto_lintegral_norm_of_dominated_convergence hmeas hbound ?_ htendsto refine fun n => univ_mem' (id fun x => ?_) by_cases hx : (n : ℝ) ≤ ‖f x‖ · dsimp rwa [Set.indicator_of_mem] · dsimp rw [Set.indicator_of_notMem, norm_zero] · exact norm_nonneg _ · assumption rw [ENNReal.tendsto_atTop_zero] at this obtain ⟨M, hM⟩ := this (ENNReal.ofReal ε) (ENNReal.ofReal_pos.2 hε) simp only [sub_zero] at hM refine ⟨M, ?_⟩ convert hM M le_rfl simp only [coe_nnnorm, ENNReal.ofReal_eq_coe_nnreal (norm_nonneg _)] rfl /-- This lemma is superseded by `MeasureTheory.MemLp.integral_indicator_norm_ge_nonneg_le` which does not require measurability. -/ theorem MemLp.integral_indicator_norm_ge_nonneg_le_of_meas (hf : MemLp f 1 μ) (hmeas : StronglyMeasurable f) {ε : ℝ} (hε : 0 < ε) : ∃ M : ℝ, 0 ≤ M ∧ (∫⁻ x, ‖{ x | M ≤ ‖f x‖₊ }.indicator f x‖ₑ ∂μ) ≤ ENNReal.ofReal ε := let ⟨M, hM⟩ := hf.integral_indicator_norm_ge_le hmeas hε ⟨max M 0, le_max_right _ _, by simpa⟩ theorem MemLp.integral_indicator_norm_ge_nonneg_le (hf : MemLp f 1 μ) {ε : ℝ} (hε : 0 < ε) : ∃ M : ℝ, 0 ≤ M ∧ (∫⁻ x, ‖{ x | M ≤ ‖f x‖₊ }.indicator f x‖ₑ ∂μ) ≤ ENNReal.ofReal ε := by have hf_mk : MemLp (hf.1.mk f) 1 μ := (memLp_congr_ae hf.1.ae_eq_mk).mp hf obtain ⟨M, hM_pos, hfM⟩ := hf_mk.integral_indicator_norm_ge_nonneg_le_of_meas hf.1.stronglyMeasurable_mk hε refine ⟨M, hM_pos, (le_of_eq ?_).trans hfM⟩ refine lintegral_congr_ae ?_ filter_upwards [hf.1.ae_eq_mk] with x hx simp only [Set.indicator_apply, coe_nnnorm, Set.mem_setOf_eq, hx.symm] theorem MemLp.eLpNormEssSup_indicator_norm_ge_eq_zero (hf : MemLp f ∞ μ) (hmeas : StronglyMeasurable f) : ∃ M : ℝ, eLpNormEssSup ({ x | M ≤ ‖f x‖₊ }.indicator f) μ = 0 := by have hbdd : eLpNormEssSup f μ < ∞ := hf.eLpNorm_lt_top refine ⟨(eLpNorm f ∞ μ + 1).toReal, ?_⟩ rw [eLpNormEssSup_indicator_eq_eLpNormEssSup_restrict] · have : μ.restrict { x : α | (eLpNorm f ⊤ μ + 1).toReal ≤ ‖f x‖₊ } = 0 := by simp only [coe_nnnorm, eLpNorm_exponent_top, Measure.restrict_eq_zero] have : { x : α | (eLpNormEssSup f μ + 1).toReal ≤ ‖f x‖ } ⊆ { x : α | eLpNormEssSup f μ < ‖f x‖₊ } := by intro x hx rw [Set.mem_setOf_eq, ← ENNReal.toReal_lt_toReal hbdd.ne ENNReal.coe_lt_top.ne, ENNReal.coe_toReal, coe_nnnorm] refine lt_of_lt_of_le ?_ hx rw [ENNReal.toReal_lt_toReal hbdd.ne] · exact ENNReal.lt_add_right hbdd.ne one_ne_zero · finiteness rw [← nonpos_iff_eq_zero] refine (measure_mono this).trans ?_ have hle := enorm_ae_le_eLpNormEssSup f μ simp_rw [ae_iff, not_le] at hle exact nonpos_iff_eq_zero.2 hle rw [this, eLpNormEssSup_measure_zero] exact measurableSet_le measurable_const hmeas.nnnorm.measurable.subtype_coe /- This lemma is slightly weaker than `MeasureTheory.MemLp.eLpNorm_indicator_norm_ge_pos_le` as the latter provides `0 < M`. -/ theorem MemLp.eLpNorm_indicator_norm_ge_le (hf : MemLp f p μ) (hmeas : StronglyMeasurable f) {ε : ℝ} (hε : 0 < ε) : ∃ M : ℝ, eLpNorm ({ x | M ≤ ‖f x‖₊ }.indicator f) p μ ≤ ENNReal.ofReal ε := by by_cases hp_ne_zero : p = 0 · refine ⟨1, hp_ne_zero.symm ▸ ?_⟩ simp [eLpNorm_exponent_zero] by_cases hp_ne_top : p = ∞ · subst hp_ne_top obtain ⟨M, hM⟩ := hf.eLpNormEssSup_indicator_norm_ge_eq_zero hmeas refine ⟨M, ?_⟩ simp only [eLpNorm_exponent_top, hM, zero_le] obtain ⟨M, hM', hM⟩ := MemLp.integral_indicator_norm_ge_nonneg_le (μ := μ) (hf.norm_rpow hp_ne_zero hp_ne_top) (Real.rpow_pos_of_pos hε p.toReal) refine ⟨M ^ (1 / p.toReal), ?_⟩ rw [eLpNorm_eq_lintegral_rpow_enorm hp_ne_zero hp_ne_top, ← ENNReal.rpow_one (ENNReal.ofReal ε)] conv_rhs => rw [← mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm] rw [ENNReal.rpow_mul, ENNReal.rpow_le_rpow_iff (one_div_pos.2 <| ENNReal.toReal_pos hp_ne_zero hp_ne_top), ENNReal.ofReal_rpow_of_pos hε] convert hM using 3 with x rw [enorm_indicator_eq_indicator_enorm, enorm_indicator_eq_indicator_enorm] have hiff : M ^ (1 / p.toReal) ≤ ‖f x‖₊ ↔ M ≤ ‖‖f x‖ ^ p.toReal‖₊ := by rw [coe_nnnorm, coe_nnnorm, Real.norm_rpow_of_nonneg (norm_nonneg _), norm_norm, ← Real.rpow_le_rpow_iff hM' (Real.rpow_nonneg (norm_nonneg _) _) (one_div_pos.2 <| ENNReal.toReal_pos hp_ne_zero hp_ne_top), ← Real.rpow_mul (norm_nonneg _), mul_one_div_cancel (ENNReal.toReal_pos hp_ne_zero hp_ne_top).ne.symm, Real.rpow_one] by_cases hx : x ∈ { x : α | M ^ (1 / p.toReal) ≤ ‖f x‖₊ } · rw [Set.indicator_of_mem hx, Set.indicator_of_mem, Real.enorm_of_nonneg (by positivity), ← ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) ENNReal.toReal_nonneg, ofReal_norm] rw [Set.mem_setOf_eq] rwa [← hiff] · rw [Set.indicator_of_notMem hx, Set.indicator_of_notMem] · simp [ENNReal.toReal_pos hp_ne_zero hp_ne_top] · rw [Set.mem_setOf_eq] rwa [← hiff] /-- This lemma implies that a single function is uniformly integrable (in the probability sense). -/ theorem MemLp.eLpNorm_indicator_norm_ge_pos_le (hf : MemLp f p μ) (hmeas : StronglyMeasurable f) {ε : ℝ} (hε : 0 < ε) : ∃ M : ℝ, 0 < M ∧ eLpNorm ({ x | M ≤ ‖f x‖₊ }.indicator f) p μ ≤ ENNReal.ofReal ε := by obtain ⟨M, hM⟩ := hf.eLpNorm_indicator_norm_ge_le hmeas hε refine ⟨max M 1, lt_of_lt_of_le zero_lt_one (le_max_right _ _), le_trans (eLpNorm_mono fun x => ?_) hM⟩ rw [norm_indicator_eq_indicator_norm, norm_indicator_eq_indicator_norm] refine Set.indicator_le_indicator_of_subset (fun x hx => ?_) (fun x => norm_nonneg (f x)) x rw [Set.mem_setOf_eq] at hx -- removing the `rw` breaks the proof! exact (max_le_iff.1 hx).1 end theorem eLpNorm_indicator_le_of_bound {f : α → β} (hp_top : p ≠ ∞) {ε : ℝ} (hε : 0 < ε) {M : ℝ} (hf : ∀ x, ‖f x‖ < M) : ∃ (δ : ℝ) (_ : 0 < δ), ∀ s, MeasurableSet s → μ s ≤ ENNReal.ofReal δ → eLpNorm (s.indicator f) p μ ≤ ENNReal.ofReal ε := by by_cases! hM : M ≤ 0 · refine ⟨1, zero_lt_one, fun s _ _ => ?_⟩ rw [(_ : f = 0)] · simp · ext x rw [Pi.zero_apply, ← norm_le_zero_iff] exact (lt_of_lt_of_le (hf x) hM).le refine ⟨(ε / M) ^ p.toReal, Real.rpow_pos_of_pos (div_pos hε hM) _, fun s hs hμ => ?_⟩ by_cases hp : p = 0 · simp [hp] rw [eLpNorm_indicator_eq_eLpNorm_restrict hs] have haebdd : ∀ᵐ x ∂μ.restrict s, ‖f x‖ ≤ M := by filter_upwards exact fun x => (hf x).le refine le_trans (eLpNorm_le_of_ae_bound haebdd) ?_ rw [Measure.restrict_apply MeasurableSet.univ, Set.univ_inter, ← ENNReal.le_div_iff_mul_le (Or.inl _) (Or.inl ENNReal.ofReal_ne_top)] · rw [ENNReal.rpow_inv_le_iff (ENNReal.toReal_pos hp hp_top)] refine le_trans hμ ?_ rw [← ENNReal.ofReal_rpow_of_pos (div_pos hε hM), ENNReal.rpow_le_rpow_iff (ENNReal.toReal_pos hp hp_top), ENNReal.ofReal_div_of_pos hM] · simpa only [ENNReal.ofReal_eq_zero, not_le, Ne] section variable {f : α → β} /-- Auxiliary lemma for `MeasureTheory.MemLp.eLpNorm_indicator_le`. -/ theorem MemLp.eLpNorm_indicator_le' (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) (hf : MemLp f p μ) (hmeas : StronglyMeasurable f) {ε : ℝ} (hε : 0 < ε) : ∃ (δ : ℝ) (_ : 0 < δ), ∀ s, MeasurableSet s → μ s ≤ ENNReal.ofReal δ → eLpNorm (s.indicator f) p μ ≤ 2 * ENNReal.ofReal ε := by obtain ⟨M, hMpos, hM⟩ := hf.eLpNorm_indicator_norm_ge_pos_le hmeas hε obtain ⟨δ, hδpos, hδ⟩ := eLpNorm_indicator_le_of_bound (f := { x | ‖f x‖ < M }.indicator f) hp_top hε (by intro x rw [norm_indicator_eq_indicator_norm, Set.indicator_apply] · split_ifs with h exacts [h, hMpos]) refine ⟨δ, hδpos, fun s hs hμs => ?_⟩ rw [(_ : f = { x : α | M ≤ ‖f x‖₊ }.indicator f + { x : α | ‖f x‖ < M }.indicator f)] · rw [eLpNorm_indicator_eq_eLpNorm_restrict hs] refine le_trans (eLpNorm_add_le ?_ ?_ hp_one) ?_ · exact StronglyMeasurable.aestronglyMeasurable (hmeas.indicator (measurableSet_le measurable_const hmeas.nnnorm.measurable.subtype_coe)) · exact StronglyMeasurable.aestronglyMeasurable (hmeas.indicator (measurableSet_lt hmeas.nnnorm.measurable.subtype_coe measurable_const)) · rw [two_mul] refine add_le_add (le_trans (eLpNorm_mono_measure _ Measure.restrict_le_self) hM) ?_ rw [← eLpNorm_indicator_eq_eLpNorm_restrict hs] exact hδ s hs hμs · ext x by_cases hx : M ≤ ‖f x‖ · rw [Pi.add_apply, Set.indicator_of_mem, Set.indicator_of_notMem, add_zero] <;> simpa · rw [Pi.add_apply, Set.indicator_of_notMem, Set.indicator_of_mem, zero_add] <;> simpa using hx /-- This lemma is superseded by `MeasureTheory.MemLp.eLpNorm_indicator_le` which does not require measurability on `f`. -/ theorem MemLp.eLpNorm_indicator_le_of_meas (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) (hf : MemLp f p μ) (hmeas : StronglyMeasurable f) {ε : ℝ} (hε : 0 < ε) : ∃ (δ : ℝ) (_ : 0 < δ), ∀ s, MeasurableSet s → μ s ≤ ENNReal.ofReal δ → eLpNorm (s.indicator f) p μ ≤ ENNReal.ofReal ε := by obtain ⟨δ, hδpos, hδ⟩ := hf.eLpNorm_indicator_le' hp_one hp_top hmeas (half_pos hε) refine ⟨δ, hδpos, fun s hs hμs => le_trans (hδ s hs hμs) ?_⟩ rw [ENNReal.ofReal_div_of_pos zero_lt_two, (by simp : ENNReal.ofReal 2 = 2), ENNReal.mul_div_cancel] <;> norm_num theorem MemLp.eLpNorm_indicator_le (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) (hf : MemLp f p μ) {ε : ℝ} (hε : 0 < ε) : ∃ (δ : ℝ) (_ : 0 < δ), ∀ s, MeasurableSet s → μ s ≤ ENNReal.ofReal δ → eLpNorm (s.indicator f) p μ ≤ ENNReal.ofReal ε := by have hℒp := hf obtain ⟨⟨f', hf', heq⟩, _⟩ := hf obtain ⟨δ, hδpos, hδ⟩ := (hℒp.ae_eq heq).eLpNorm_indicator_le_of_meas hp_one hp_top hf' hε refine ⟨δ, hδpos, fun s hs hμs => ?_⟩ convert hδ s hs hμs using 1 rw [eLpNorm_indicator_eq_eLpNorm_restrict hs, eLpNorm_indicator_eq_eLpNorm_restrict hs] exact eLpNorm_congr_ae heq.restrict /-- A constant function is uniformly integrable. -/ theorem unifIntegrable_const {g : α → β} (hp : 1 ≤ p) (hp_ne_top : p ≠ ∞) (hg : MemLp g p μ) : UnifIntegrable (fun _ : ι => g) p μ := by intro ε hε obtain ⟨δ, hδ_pos, hgδ⟩ := hg.eLpNorm_indicator_le hp hp_ne_top hε exact ⟨δ, hδ_pos, fun _ => hgδ⟩ /-- A single function is uniformly integrable. -/ theorem unifIntegrable_subsingleton [Subsingleton ι] (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) {f : ι → α → β} (hf : ∀ i, MemLp (f i) p μ) : UnifIntegrable f p μ := by intro ε hε by_cases hι : Nonempty ι · obtain ⟨i⟩ := hι obtain ⟨δ, hδpos, hδ⟩ := (hf i).eLpNorm_indicator_le hp_one hp_top hε refine ⟨δ, hδpos, fun j s hs hμs => ?_⟩ convert hδ s hs hμs · exact ⟨1, zero_lt_one, fun i => False.elim <| hι <| Nonempty.intro i⟩ /-- This lemma is less general than `MeasureTheory.unifIntegrable_finite` which applies to all sequences indexed by a finite type. -/ theorem unifIntegrable_fin (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) {n : ℕ} {f : Fin n → α → β} (hf : ∀ i, MemLp (f i) p μ) : UnifIntegrable f p μ := by revert f induction n with | zero => exact fun {f} hf ↦ unifIntegrable_subsingleton hp_one hp_top hf | succ n h => intro f hfLp ε hε let g : Fin n → α → β := fun k => f k.castSucc have hgLp : ∀ i, MemLp (g i) p μ := fun i => hfLp i.castSucc obtain ⟨δ₁, hδ₁pos, hδ₁⟩ := h hgLp hε obtain ⟨δ₂, hδ₂pos, hδ₂⟩ := (hfLp (Fin.last n)).eLpNorm_indicator_le hp_one hp_top hε refine ⟨min δ₁ δ₂, lt_min hδ₁pos hδ₂pos, fun i s hs hμs => ?_⟩ by_cases! hi : i.val < n · rw [(_ : f i = g ⟨i.val, hi⟩)] · exact hδ₁ _ s hs (le_trans hμs <| ENNReal.ofReal_le_ofReal <| min_le_left _ _) · simp [g] · obtain rfl : i = Fin.last n := Fin.ext (le_antisymm (Fin.is_le i) hi) exact hδ₂ _ hs (le_trans hμs <| ENNReal.ofReal_le_ofReal <| min_le_right _ _) /-- A finite sequence of Lp functions is uniformly integrable. -/ theorem unifIntegrable_finite [Finite ι] (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) {f : ι → α → β} (hf : ∀ i, MemLp (f i) p μ) : UnifIntegrable f p μ := by obtain ⟨n, hn⟩ := Finite.exists_equiv_fin ι intro ε hε let g : Fin n → α → β := f ∘ hn.some.symm have hg : ∀ i, MemLp (g i) p μ := fun _ => hf _ obtain ⟨δ, hδpos, hδ⟩ := unifIntegrable_fin hp_one hp_top hg hε refine ⟨δ, hδpos, fun i s hs hμs => ?_⟩ simpa [g] using hδ (hn.some i) s hs hμs end theorem eLpNorm_sub_le_of_dist_bdd (μ : Measure α) {p : ℝ≥0∞} (hp' : p ≠ ∞) {s : Set α} (hs : MeasurableSet[m] s) {f g : α → β} {c : ℝ} (hc : 0 ≤ c) (hf : ∀ x ∈ s, dist (f x) (g x) ≤ c) : eLpNorm (s.indicator (f - g)) p μ ≤ ENNReal.ofReal c * μ s ^ (1 / p.toReal) := by by_cases hp : p = 0 · simp [hp] have : ∀ x, ‖s.indicator (f - g) x‖ ≤ ‖s.indicator (fun _ => c) x‖ := by intro x by_cases hx : x ∈ s · rw [Set.indicator_of_mem hx, Set.indicator_of_mem hx, Pi.sub_apply, ← dist_eq_norm, Real.norm_eq_abs, abs_of_nonneg hc] exact hf x hx · simp [Set.indicator_of_notMem hx] grw [eLpNorm_mono this, eLpNorm_indicator_const hs hp hp', ← ofReal_norm_eq_enorm, Real.norm_eq_abs, abs_of_nonneg hc] /-- A sequence of uniformly integrable functions which converges μ-a.e. converges in Lp. -/ theorem tendsto_Lp_finite_of_tendsto_ae_of_meas [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' : p ≠ ∞) {f : ℕ → α → β} {g : α → β} (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hg' : MemLp g p μ) (hui : UnifIntegrable f p μ) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0) := by rw [ENNReal.tendsto_atTop_zero] intro ε hε by_cases! h : ∞ ≤ ε · rw [top_le_iff] at h exact ⟨0, fun n _ => by simp [h]⟩ by_cases hμ : μ = 0 · exact ⟨0, fun n _ => by simp [hμ]⟩ have hε' : 0 < ε.toReal / 3 := div_pos (ENNReal.toReal_pos hε.ne' h.ne) (by simp) have hdivp : 0 ≤ 1 / p.toReal := by positivity have hpow : 0 < measureUnivNNReal μ ^ (1 / p.toReal) := Real.rpow_pos_of_pos (measureUnivNNReal_pos hμ) _ obtain ⟨δ₁, hδ₁, heLpNorm₁⟩ := hui hε' obtain ⟨δ₂, hδ₂, heLpNorm₂⟩ := hg'.eLpNorm_indicator_le hp hp' hε' obtain ⟨t, htm, ht₁, ht₂⟩ := tendstoUniformlyOn_of_ae_tendsto' hf hg hfg (lt_min hδ₁ hδ₂) rw [Metric.tendstoUniformlyOn_iff] at ht₂ specialize ht₂ (ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal))) (div_pos (ENNReal.toReal_pos (gt_iff_lt.1 hε).ne.symm h.ne) (mul_pos (by simp) hpow)) obtain ⟨N, hN⟩ := eventually_atTop.1 ht₂; clear ht₂ refine ⟨N, fun n hn => ?_⟩ rw [← t.indicator_self_add_compl (f n - g)] grw [eLpNorm_add_le (((hf n).sub hg).indicator htm).aestronglyMeasurable (((hf n).sub hg).indicator htm.compl).aestronglyMeasurable hp, sub_eq_add_neg, Set.indicator_add' t, Set.indicator_neg', eLpNorm_add_le ((hf n).indicator htm).aestronglyMeasurable (hg.indicator htm).neg.aestronglyMeasurable hp] have hnf : eLpNorm (t.indicator (f n)) p μ ≤ ENNReal.ofReal (ε.toReal / 3) := by refine heLpNorm₁ n t htm (le_trans ht₁ ?_) rw [ENNReal.ofReal_le_ofReal_iff hδ₁.le] exact min_le_left _ _ have hng : eLpNorm (t.indicator g) p μ ≤ ENNReal.ofReal (ε.toReal / 3) := by refine heLpNorm₂ t htm (le_trans ht₁ ?_) rw [ENNReal.ofReal_le_ofReal_iff hδ₂.le] exact min_le_right _ _ have hlt : eLpNorm (tᶜ.indicator (f n - g)) p μ ≤ ENNReal.ofReal (ε.toReal / 3) := by specialize hN n hn have : 0 ≤ ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal)) := by positivity have := eLpNorm_sub_le_of_dist_bdd μ hp' htm.compl this fun x hx => (dist_comm (g x) (f n x) ▸ (hN x hx).le : dist (f n x) (g x) ≤ ε.toReal / (3 * measureUnivNNReal μ ^ (1 / p.toReal))) refine le_trans this ?_ rw [div_mul_eq_div_mul_one_div, ← ENNReal.ofReal_toReal (measure_lt_top μ tᶜ).ne, ENNReal.ofReal_rpow_of_nonneg ENNReal.toReal_nonneg hdivp, ← ENNReal.ofReal_mul, mul_assoc] · refine ENNReal.ofReal_le_ofReal (mul_le_of_le_one_right hε'.le ?_) rw [mul_comm, mul_one_div, div_le_one] · refine Real.rpow_le_rpow ENNReal.toReal_nonneg (ENNReal.toReal_le_of_le_ofReal (measureUnivNNReal_pos hμ).le ?_) hdivp rw [ENNReal.ofReal_coe_nnreal, coe_measureUnivNNReal] exact measure_mono (Set.subset_univ _) · exact Real.rpow_pos_of_pos (measureUnivNNReal_pos hμ) _ · positivity have : ENNReal.ofReal (ε.toReal / 3) = ε / 3 := by rw [ENNReal.ofReal_div_of_pos (show (0 : ℝ) < 3 by simp), ENNReal.ofReal_toReal h.ne] simp rw [this] at hnf hng hlt rw [eLpNorm_neg, ← ENNReal.add_thirds ε, ← sub_eq_add_neg] gcongr /-- A sequence of uniformly integrable functions which converges μ-a.e. converges in Lp. -/ theorem tendsto_Lp_finite_of_tendsto_ae [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' : p ≠ ∞) {f : ℕ → α → β} {g : α → β} (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hg : MemLp g p μ) (hui : UnifIntegrable f p μ) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0) := by have : ∀ n, eLpNorm (f n - g) p μ = eLpNorm ((hf n).mk (f n) - hg.1.mk g) p μ := fun n => eLpNorm_congr_ae ((hf n).ae_eq_mk.sub hg.1.ae_eq_mk) simp_rw [this] refine tendsto_Lp_finite_of_tendsto_ae_of_meas hp hp' (fun n => (hf n).stronglyMeasurable_mk) hg.1.stronglyMeasurable_mk (hg.ae_eq hg.1.ae_eq_mk) (hui.ae_eq fun n => (hf n).ae_eq_mk) ?_ have h_ae_forall_eq : ∀ᵐ x ∂μ, ∀ n, f n x = (hf n).mk (f n) x := by rw [ae_all_iff] exact fun n => (hf n).ae_eq_mk filter_upwards [hfg, h_ae_forall_eq, hg.1.ae_eq_mk] with x hx_tendsto hxf_eq hxg_eq rw [← hxg_eq] convert hx_tendsto using 1 ext1 n exact (hxf_eq n).symm variable {f : ℕ → α → β} {g : α → β} theorem unifIntegrable_of_tendsto_Lp_zero (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ n, MemLp (f n) p μ) (hf_tendsto : Tendsto (fun n => eLpNorm (f n) p μ) atTop (𝓝 0)) : UnifIntegrable f p μ := by intro ε hε rw [ENNReal.tendsto_atTop_zero] at hf_tendsto obtain ⟨N, hN⟩ := hf_tendsto (ENNReal.ofReal ε) (by simpa) let F : Fin N → α → β := fun n => f n have hF : ∀ n, MemLp (F n) p μ := fun n => hf n obtain ⟨δ₁, hδpos₁, hδ₁⟩ := unifIntegrable_fin hp hp' hF hε refine ⟨δ₁, hδpos₁, fun n s hs hμs => ?_⟩ by_cases! hn : n < N · exact hδ₁ ⟨n, hn⟩ s hs hμs · exact (eLpNorm_indicator_le _).trans (hN n hn) /-- Convergence in Lp implies uniform integrability. -/ theorem unifIntegrable_of_tendsto_Lp (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ n, MemLp (f n) p μ) (hg : MemLp g p μ) (hfg : Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0)) : UnifIntegrable f p μ := by have : f = (fun _ => g) + fun n => f n - g := by ext1 n; simp rw [this] refine UnifIntegrable.add ?_ ?_ hp (fun _ => hg.aestronglyMeasurable) fun n => (hf n).1.sub hg.aestronglyMeasurable · exact unifIntegrable_const hp hp' hg · exact unifIntegrable_of_tendsto_Lp_zero hp hp' (fun n => (hf n).sub hg) hfg /-- Forward direction of Vitali's convergence theorem: if `f` is a sequence of uniformly integrable functions that converge in measure to some function `g` in a finite measure space, then `f` converge in Lp to `g`. -/ theorem tendsto_Lp_finite_of_tendstoInMeasure [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hg : MemLp g p μ) (hui : UnifIntegrable f p μ) (hfg : TendstoInMeasure μ f atTop g) : Tendsto (fun n ↦ eLpNorm (f n - g) p μ) atTop (𝓝 0) := by refine tendsto_of_subseq_tendsto fun ns hns => ?_ obtain ⟨ms, _, hms'⟩ := TendstoInMeasure.exists_seq_tendsto_ae fun ε hε => (hfg ε hε).comp hns exact ⟨ms, tendsto_Lp_finite_of_tendsto_ae hp hp' (fun _ => hf _) hg (fun ε hε => let ⟨δ, hδ, hδ'⟩ := hui hε ⟨δ, hδ, fun i s hs hμs => hδ' _ s hs hμs⟩) hms'⟩ /-- **Vitali's convergence theorem**: A sequence of functions `f` converges to `g` in Lp if and only if it is uniformly integrable and converges to `g` in measure. -/ theorem tendstoInMeasure_iff_tendsto_Lp_finite [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ n, MemLp (f n) p μ) (hg : MemLp g p μ) : TendstoInMeasure μ f atTop g ∧ UnifIntegrable f p μ ↔ Tendsto (fun n => eLpNorm (f n - g) p μ) atTop (𝓝 0) := ⟨fun h => tendsto_Lp_finite_of_tendstoInMeasure hp hp' (fun n => (hf n).1) hg h.2 h.1, fun h => ⟨tendstoInMeasure_of_tendsto_eLpNorm (lt_of_lt_of_le zero_lt_one hp).ne.symm (fun n => (hf n).aestronglyMeasurable) hg.aestronglyMeasurable h, unifIntegrable_of_tendsto_Lp hp hp' hf hg h⟩⟩ /-- This lemma is superseded by `unifIntegrable_of` which do not require `C` to be positive. -/ theorem unifIntegrable_of' (hp : 1 ≤ p) (hp' : p ≠ ∞) {f : ι → α → β} (hf : ∀ i, StronglyMeasurable (f i)) (h : ∀ ε : ℝ, 0 < ε → ∃ C : ℝ≥0, 0 < C ∧ ∀ i, eLpNorm ({ x | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ ≤ ENNReal.ofReal ε) : UnifIntegrable f p μ := by have hpzero := (lt_of_lt_of_le zero_lt_one hp).ne.symm by_cases hμ : μ Set.univ = 0 · rw [Measure.measure_univ_eq_zero] at hμ exact hμ.symm ▸ unifIntegrable_zero_meas intro ε hε obtain ⟨C, hCpos, hC⟩ := h (ε / 2) (half_pos hε) refine ⟨(ε / (2 * C)) ^ ENNReal.toReal p, Real.rpow_pos_of_pos (div_pos hε (mul_pos two_pos (NNReal.coe_pos.2 hCpos))) _, fun i s hs hμs => ?_⟩ by_cases hμs' : μ s = 0 · rw [(eLpNorm_eq_zero_iff ((hf i).indicator hs).aestronglyMeasurable hpzero).2 (indicator_meas_zero hμs')] simp calc eLpNorm (Set.indicator s (f i)) p μ ≤ eLpNorm (Set.indicator (s ∩ { x | C ≤ ‖f i x‖₊ }) (f i)) p μ + eLpNorm (Set.indicator (s ∩ { x | ‖f i x‖₊ < C }) (f i)) p μ := by refine le_trans (Eq.le ?_) (eLpNorm_add_le (StronglyMeasurable.aestronglyMeasurable ((hf i).indicator (hs.inter (stronglyMeasurable_const.measurableSet_le (hf i).nnnorm)))) (StronglyMeasurable.aestronglyMeasurable ((hf i).indicator (hs.inter ((hf i).nnnorm.measurableSet_lt stronglyMeasurable_const)))) hp) congr change _ = fun x => (s ∩ { x : α | C ≤ ‖f i x‖₊ }).indicator (f i) x + (s ∩ { x : α | ‖f i x‖₊ < C }).indicator (f i) x rw [← Set.indicator_union_of_disjoint] · rw [← Set.inter_union_distrib_left, (by ext; simp [le_or_gt] : { x : α | C ≤ ‖f i x‖₊ } ∪ { x : α | ‖f i x‖₊ < C } = Set.univ), Set.inter_univ] · refine (Disjoint.inf_right' _ ?_).inf_left' _ rw [disjoint_iff_inf_le] rintro x ⟨hx₁, hx₂⟩ rw [Set.mem_setOf_eq] at hx₁ hx₂ exact False.elim (hx₂.ne (eq_of_le_of_not_lt hx₁ (not_lt.2 hx₂.le)).symm) _ ≤ eLpNorm (Set.indicator { x | C ≤ ‖f i x‖₊ } (f i)) p μ + (C : ℝ≥0∞) * μ s ^ (1 / ENNReal.toReal p) := by refine add_le_add (eLpNorm_mono fun x => norm_indicator_le_of_subset Set.inter_subset_right _ _) ?_ rw [← Set.indicator_indicator] rw [eLpNorm_indicator_eq_eLpNorm_restrict hs] have : ∀ᵐ x ∂μ.restrict s, ‖{ x : α | ‖f i x‖₊ < C }.indicator (f i) x‖ ≤ C := by filter_upwards simp_rw [norm_indicator_eq_indicator_norm] exact Set.indicator_le' (fun x (hx : _ < _) => hx.le) fun _ _ => NNReal.coe_nonneg _ refine le_trans (eLpNorm_le_of_ae_bound this) ?_ rw [mul_comm, Measure.restrict_apply' hs, Set.univ_inter, ENNReal.ofReal_coe_nnreal, one_div] _ ≤ ENNReal.ofReal (ε / 2) + C * ENNReal.ofReal (ε / (2 * C)) := by grw [hC i] gcongr rwa [one_div, ENNReal.rpow_inv_le_iff (ENNReal.toReal_pos hpzero hp'), ENNReal.ofReal_rpow_of_pos (div_pos hε (mul_pos two_pos (NNReal.coe_pos.2 hCpos)))] _ ≤ ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2) := by gcongr rw [← ENNReal.ofReal_coe_nnreal, ← ENNReal.ofReal_mul (NNReal.coe_nonneg _), ← div_div, mul_div_cancel₀ _ (NNReal.coe_pos.2 hCpos).ne.symm] _ ≤ ENNReal.ofReal ε := by rw [← ENNReal.ofReal_add (half_pos hε).le (half_pos hε).le, add_halves] theorem unifIntegrable_of (hp : 1 ≤ p) (hp' : p ≠ ∞) {f : ι → α → β} (hf : ∀ i, AEStronglyMeasurable (f i) μ) (h : ∀ ε : ℝ, 0 < ε → ∃ C : ℝ≥0, ∀ i, eLpNorm ({ x | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ ≤ ENNReal.ofReal ε) : UnifIntegrable f p μ := by set g : ι → α → β := fun i => (hf i).choose refine (unifIntegrable_of' hp hp' (fun i => (Exists.choose_spec <| hf i).1) fun ε hε => ?_).ae_eq fun i => (Exists.choose_spec <| hf i).2.symm obtain ⟨C, hC⟩ := h ε hε have hCg : ∀ i, eLpNorm ({ x | C ≤ ‖g i x‖₊ }.indicator (g i)) p μ ≤ ENNReal.ofReal ε := by intro i refine le_trans (le_of_eq <| eLpNorm_congr_ae ?_) (hC i) filter_upwards [(Exists.choose_spec <| hf i).2] with x hx by_cases hfx : x ∈ { x | C ≤ ‖f i x‖₊ } · rw [Set.indicator_of_mem hfx, Set.indicator_of_mem, hx] rwa [Set.mem_setOf, hx] at hfx · rw [Set.indicator_of_notMem hfx, Set.indicator_of_notMem] rwa [Set.mem_setOf, hx] at hfx refine ⟨max C 1, lt_max_of_lt_right one_pos, fun i => le_trans (eLpNorm_mono fun x => ?_) (hCg i)⟩ rw [norm_indicator_eq_indicator_norm, norm_indicator_eq_indicator_norm] exact Set.indicator_le_indicator_of_subset (fun x hx => Set.mem_setOf_eq ▸ le_trans (le_max_left _ _) hx) (fun _ => norm_nonneg _) _ end UnifIntegrable section UniformIntegrable /-! `UniformIntegrable` In probability theory, uniform integrability normally refers to the condition that a sequence of function `(fₙ)` satisfies for all `ε > 0`, there exists some `C ≥ 0` such that `∫ x in {|fₙ| ≥ C}, fₙ x ∂μ ≤ ε` for all `n`. In this section, we will develop some API for `UniformIntegrable` and prove that `UniformIntegrable` is equivalent to this definition of uniform integrability. -/ variable {p : ℝ≥0∞} {f : ι → α → β} theorem uniformIntegrable_zero_meas [MeasurableSpace α] : UniformIntegrable f p (0 : Measure α) := ⟨fun _ => aestronglyMeasurable_zero_measure _, unifIntegrable_zero_meas, 0, fun _ => eLpNorm_measure_zero.le⟩ theorem UniformIntegrable.ae_eq {g : ι → α → β} (hf : UniformIntegrable f p μ) (hfg : ∀ n, f n =ᵐ[μ] g n) : UniformIntegrable g p μ := by obtain ⟨hfm, hunif, C, hC⟩ := hf refine ⟨fun i => (hfm i).congr (hfg i), (unifIntegrable_congr_ae hfg).1 hunif, C, fun i => ?_⟩ rw [← eLpNorm_congr_ae (hfg i)] exact hC i theorem uniformIntegrable_congr_ae {g : ι → α → β} (hfg : ∀ n, f n =ᵐ[μ] g n) : UniformIntegrable f p μ ↔ UniformIntegrable g p μ := ⟨fun h => h.ae_eq hfg, fun h => h.ae_eq fun i => (hfg i).symm⟩ /-- A finite sequence of Lp functions is uniformly integrable in the probability sense. -/ theorem uniformIntegrable_finite [Finite ι] (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) (hf : ∀ i, MemLp (f i) p μ) : UniformIntegrable f p μ := by cases nonempty_fintype ι refine ⟨fun n => (hf n).1, unifIntegrable_finite hp_one hp_top hf, ?_⟩ by_cases hι : Nonempty ι · choose _ hf using hf set C := (Finset.univ.image fun i : ι => eLpNorm (f i) p μ).max' ⟨eLpNorm (f hι.some) p μ, Finset.mem_image.2 ⟨hι.some, Finset.mem_univ _, rfl⟩⟩ refine ⟨C.toNNReal, fun i => ?_⟩ rw [ENNReal.coe_toNNReal] · exact Finset.le_max' (α := ℝ≥0∞) _ _ (Finset.mem_image.2 ⟨i, Finset.mem_univ _, rfl⟩) · refine ne_of_lt ((Finset.max'_lt_iff _ _).2 fun y hy => ?_) rw [Finset.mem_image] at hy obtain ⟨i, -, rfl⟩ := hy exact hf i · exact ⟨0, fun i => False.elim <| hι <| Nonempty.intro i⟩ /-- A single function is uniformly integrable in the probability sense. -/ theorem uniformIntegrable_subsingleton [Subsingleton ι] (hp_one : 1 ≤ p) (hp_top : p ≠ ∞) (hf : ∀ i, MemLp (f i) p μ) : UniformIntegrable f p μ := uniformIntegrable_finite hp_one hp_top hf /-- A constant sequence of functions is uniformly integrable in the probability sense. -/ theorem uniformIntegrable_const {g : α → β} (hp : 1 ≤ p) (hp_ne_top : p ≠ ∞) (hg : MemLp g p μ) : UniformIntegrable (fun _ : ι => g) p μ := ⟨fun _ => hg.1, unifIntegrable_const hp hp_ne_top hg, ⟨(eLpNorm g p μ).toNNReal, fun _ => le_of_eq (ENNReal.coe_toNNReal hg.2.ne).symm⟩⟩ /-- This lemma is superseded by `uniformIntegrable_of` which only requires `AEStronglyMeasurable`. -/ theorem uniformIntegrable_of' [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ i, StronglyMeasurable (f i)) (h : ∀ ε : ℝ, 0 < ε → ∃ C : ℝ≥0, ∀ i, eLpNorm ({ x | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ ≤ ENNReal.ofReal ε) : UniformIntegrable f p μ := by refine ⟨fun i => (hf i).aestronglyMeasurable, unifIntegrable_of hp hp' (fun i => (hf i).aestronglyMeasurable) h, ?_⟩ obtain ⟨C, hC⟩ := h 1 one_pos refine ⟨((C : ℝ≥0∞) * μ Set.univ ^ p.toReal⁻¹ + 1).toNNReal, fun i => ?_⟩ calc eLpNorm (f i) p μ ≤ eLpNorm ({ x : α | ‖f i x‖₊ < C }.indicator (f i)) p μ + eLpNorm ({ x : α | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ := by refine le_trans (eLpNorm_mono_enorm fun x => ?_) (eLpNorm_add_le (StronglyMeasurable.aestronglyMeasurable ((hf i).indicator ((hf i).nnnorm.measurableSet_lt stronglyMeasurable_const))) (StronglyMeasurable.aestronglyMeasurable ((hf i).indicator (stronglyMeasurable_const.measurableSet_le (hf i).nnnorm))) hp) rw [Pi.add_apply, Set.indicator_apply] split_ifs with hx · rw [Set.indicator_of_notMem, add_zero] simpa using hx · rw [Set.indicator_of_mem, zero_add] simpa using hx _ ≤ (C : ℝ≥0∞) * μ Set.univ ^ p.toReal⁻¹ + 1 := by have : ∀ᵐ x ∂μ, ‖{ x : α | ‖f i x‖₊ < C }.indicator (f i) x‖₊ ≤ C := by filter_upwards simp_rw [nnnorm_indicator_eq_indicator_nnnorm] exact Set.indicator_le fun x (hx : _ < _) => hx.le refine add_le_add (le_trans (eLpNorm_le_of_ae_bound this) ?_) (ENNReal.ofReal_one ▸ hC i) simp_rw [NNReal.val_eq_coe, ENNReal.ofReal_coe_nnreal, mul_comm] exact le_rfl _ = ((C : ℝ≥0∞) * μ Set.univ ^ p.toReal⁻¹ + 1 : ℝ≥0∞).toNNReal := by rw [ENNReal.coe_toNNReal (by finiteness)] /-- A sequence of functions `(fₙ)` is uniformly integrable in the probability sense if for all `ε > 0`, there exists some `C` such that `∫ x in {|fₙ| ≥ C}, fₙ x ∂μ ≤ ε` for all `n`. -/ theorem uniformIntegrable_of [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' : p ≠ ∞) (hf : ∀ i, AEStronglyMeasurable (f i) μ) (h : ∀ ε : ℝ, 0 < ε → ∃ C : ℝ≥0, ∀ i, eLpNorm ({ x | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ ≤ ENNReal.ofReal ε) : UniformIntegrable f p μ := by set g : ι → α → β := fun i => (hf i).choose have hgmeas : ∀ i, StronglyMeasurable (g i) := fun i => (Exists.choose_spec <| hf i).1 have hgeq : ∀ i, g i =ᵐ[μ] f i := fun i => (Exists.choose_spec <| hf i).2.symm refine (uniformIntegrable_of' hp hp' hgmeas fun ε hε => ?_).ae_eq hgeq obtain ⟨C, hC⟩ := h ε hε refine ⟨C, fun i => le_trans (le_of_eq <| eLpNorm_congr_ae ?_) (hC i)⟩ filter_upwards [(Exists.choose_spec <| hf i).2] with x hx by_cases hfx : x ∈ { x | C ≤ ‖f i x‖₊ } · rw [Set.indicator_of_mem hfx, Set.indicator_of_mem, hx] rwa [Set.mem_setOf, hx] at hfx · rw [Set.indicator_of_notMem hfx, Set.indicator_of_notMem] rwa [Set.mem_setOf, hx] at hfx /-- This lemma is superseded by `UniformIntegrable.spec` which does not require measurability. -/ theorem UniformIntegrable.spec' (hp : p ≠ 0) (hp' : p ≠ ∞) (hf : ∀ i, StronglyMeasurable (f i)) (hfu : UniformIntegrable f p μ) {ε : ℝ} (hε : 0 < ε) : ∃ C : ℝ≥0, ∀ i, eLpNorm ({ x | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ ≤ ENNReal.ofReal ε := by obtain ⟨-, hfu, M, hM⟩ := hfu obtain ⟨δ, hδpos, hδ⟩ := hfu hε obtain ⟨C, hC⟩ : ∃ C : ℝ≥0, ∀ i, μ { x | C ≤ ‖f i x‖₊ } ≤ ENNReal.ofReal δ := by by_contra! hcon choose ℐ hℐ using hcon lift δ to ℝ≥0 using hδpos.le have : ∀ C : ℝ≥0, C • (δ : ℝ≥0∞) ^ (1 / p.toReal) ≤ eLpNorm (f (ℐ C)) p μ := by intro C calc C • (δ : ℝ≥0∞) ^ (1 / p.toReal) ≤ C • μ { x | C ≤ ‖f (ℐ C) x‖₊ } ^ (1 / p.toReal) := by rw [ENNReal.smul_def, ENNReal.smul_def, smul_eq_mul, smul_eq_mul] simp_rw [ENNReal.ofReal_coe_nnreal] at hℐ refine mul_le_mul' le_rfl (ENNReal.rpow_le_rpow (hℐ C).le (one_div_nonneg.2 ENNReal.toReal_nonneg)) _ ≤ eLpNorm ({ x | C ≤ ‖f (ℐ C) x‖₊ }.indicator (f (ℐ C))) p μ := by refine le_eLpNorm_of_bddBelow hp hp' _ (measurableSet_le measurable_const (hf _).nnnorm.measurable) (Eventually.of_forall fun x hx => ?_) rwa [nnnorm_indicator_eq_indicator_nnnorm, Set.indicator_of_mem hx] _ ≤ eLpNorm (f (ℐ C)) p μ := eLpNorm_indicator_le _ specialize this (2 * max M 1 * δ⁻¹ ^ (1 / p.toReal)) rw [← ENNReal.coe_rpow_of_nonneg _ (one_div_nonneg.2 ENNReal.toReal_nonneg), ← ENNReal.coe_smul, smul_eq_mul, mul_assoc, NNReal.inv_rpow, inv_mul_cancel₀ (NNReal.rpow_pos (NNReal.coe_pos.1 hδpos)).ne.symm, mul_one, ENNReal.coe_mul, ← NNReal.inv_rpow] at this refine (lt_of_le_of_lt (le_trans (hM <| ℐ <| 2 * max M 1 * δ⁻¹ ^ (1 / p.toReal)) (le_max_left (M : ℝ≥0∞) 1)) (lt_of_lt_of_le ?_ this)).ne rfl rw [← ENNReal.coe_one, ← ENNReal.coe_max, ← ENNReal.coe_mul, ENNReal.coe_lt_coe] exact lt_two_mul_self (lt_max_of_lt_right one_pos) exact ⟨C, fun i => hδ i _ (measurableSet_le measurable_const (hf i).nnnorm.measurable) (hC i)⟩ theorem UniformIntegrable.spec (hp : p ≠ 0) (hp' : p ≠ ∞) (hfu : UniformIntegrable f p μ) {ε : ℝ} (hε : 0 < ε) : ∃ C : ℝ≥0, ∀ i, eLpNorm ({ x | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ ≤ ENNReal.ofReal ε := by set g : ι → α → β := fun i => (hfu.1 i).choose have hgmeas : ∀ i, StronglyMeasurable (g i) := fun i => (Exists.choose_spec <| hfu.1 i).1 have hgunif : UniformIntegrable g p μ := hfu.ae_eq fun i => (Exists.choose_spec <| hfu.1 i).2 obtain ⟨C, hC⟩ := hgunif.spec' hp hp' hgmeas hε refine ⟨C, fun i => le_trans (le_of_eq <| eLpNorm_congr_ae ?_) (hC i)⟩ filter_upwards [(Exists.choose_spec <| hfu.1 i).2] with x hx by_cases hfx : x ∈ { x | C ≤ ‖f i x‖₊ } · rw [Set.indicator_of_mem hfx, Set.indicator_of_mem, hx] rwa [Set.mem_setOf, hx] at hfx · rw [Set.indicator_of_notMem hfx, Set.indicator_of_notMem] rwa [Set.mem_setOf, hx] at hfx /-- The definition of uniform integrable in mathlib is equivalent to the definition commonly found in literature. -/ theorem uniformIntegrable_iff [IsFiniteMeasure μ] (hp : 1 ≤ p) (hp' : p ≠ ∞) : UniformIntegrable f p μ ↔ (∀ i, AEStronglyMeasurable (f i) μ) ∧ ∀ ε : ℝ, 0 < ε → ∃ C : ℝ≥0, ∀ i, eLpNorm ({ x | C ≤ ‖f i x‖₊ }.indicator (f i)) p μ ≤ ENNReal.ofReal ε := ⟨fun h => ⟨h.1, fun _ => h.spec (lt_of_lt_of_le zero_lt_one hp).ne.symm hp'⟩, fun h => uniformIntegrable_of hp hp' h.1 h.2⟩ /-- The averaging of a uniformly integrable sequence is also uniformly integrable. -/ theorem uniformIntegrable_average {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (hp : 1 ≤ p) {f : ℕ → α → E} (hf : UniformIntegrable f p μ) : UniformIntegrable (fun (n : ℕ) => (n : ℝ)⁻¹ • (∑ i ∈ Finset.range n, f i)) p μ := by obtain ⟨hf₁, hf₂, hf₃⟩ := hf refine ⟨fun n => ?_, fun ε hε => ?_, ?_⟩ · exact (Finset.aestronglyMeasurable_sum _ fun i _ => hf₁ i).const_smul _ · obtain ⟨δ, hδ₁, hδ₂⟩ := hf₂ hε refine ⟨δ, hδ₁, fun n s hs hle => ?_⟩ simp_rw [Finset.smul_sum, Finset.indicator_sum] refine le_trans (eLpNorm_sum_le (fun i _ => ((hf₁ i).const_smul _).indicator hs) hp) ?_ have this i : s.indicator ((n : ℝ)⁻¹ • f i) = (↑n : ℝ)⁻¹ • s.indicator (f i) := indicator_const_smul _ _ _ obtain rfl | hn := eq_or_ne n 0 · simp simp_rw [this, eLpNorm_const_smul, ← Finset.mul_sum] rw [enorm_inv (by positivity), Real.enorm_natCast, ← ENNReal.div_eq_inv_mul] refine ENNReal.div_le_of_le_mul' ?_ simpa using Finset.sum_le_card_nsmul (.range n) _ _ fun i _ => hδ₂ _ _ hs hle · obtain ⟨C, hC⟩ := hf₃ simp_rw [Finset.smul_sum] refine ⟨C, fun n => (eLpNorm_sum_le (fun i _ => (hf₁ i).const_smul _) hp).trans ?_⟩ obtain rfl | hn := eq_or_ne n 0 · simp simp_rw [eLpNorm_const_smul, ← Finset.mul_sum] rw [enorm_inv (by positivity), Real.enorm_natCast, ← ENNReal.div_eq_inv_mul] refine ENNReal.div_le_of_le_mul' ?_ simpa using Finset.sum_le_card_nsmul (.range n) _ _ fun i _ => hC i /-- The averaging of a uniformly integrable real-valued sequence is also uniformly integrable. -/ theorem uniformIntegrable_average_real (hp : 1 ≤ p) {f : ℕ → α → ℝ} (hf : UniformIntegrable f p μ) : UniformIntegrable (fun n => (∑ i ∈ Finset.range n, f i) / (n : α → ℝ)) p μ := by convert uniformIntegrable_average hp hf using 2 with n ext x simp [div_eq_inv_mul] end UniformIntegrable end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ContinuousMapDense.lean
import Mathlib.MeasureTheory.Measure.Regular import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp import Mathlib.Topology.UrysohnsLemma import Mathlib.MeasureTheory.Function.LpSpace.ContinuousFunctions import Mathlib.MeasureTheory.Integral.Bochner.Basic /-! # Approximation in Lᵖ by continuous functions This file proves that bounded continuous functions are dense in `Lp E p μ`, for `p < ∞`, if the domain `α` of the functions is a normal topological space and the measure `μ` is weakly regular. It also proves the same results for approximation by continuous functions with compact support when the space is locally compact and `μ` is regular. The result is presented in several versions. First concrete versions giving an approximation up to `ε` in these various contexts, and then abstract versions stating that the topological closure of the relevant subgroups of `Lp` are the whole space. * `MeasureTheory.MemLp.exists_hasCompactSupport_eLpNorm_sub_le` states that, in a locally compact space, an `ℒp` function can be approximated by continuous functions with compact support, in the sense that `eLpNorm (f - g) p μ` is small. * `MeasureTheory.MemLp.exists_hasCompactSupport_integral_rpow_sub_le`: same result, but expressed in terms of `∫ ‖f - g‖^p`. Versions with `Integrable` instead of `MemLp` are specialized to the case `p = 1`. Versions with `boundedContinuous` instead of `HasCompactSupport` drop the locally compact assumption and give only approximation by a bounded continuous function. * `MeasureTheory.Lp.boundedContinuousFunction_dense`: The subgroup `MeasureTheory.Lp.boundedContinuousFunction` of `Lp E p μ`, the additive subgroup of `Lp E p μ` consisting of equivalence classes containing a continuous representative, is dense in `Lp E p μ`. * `BoundedContinuousFunction.toLp_denseRange`: For finite-measure `μ`, the continuous linear map `BoundedContinuousFunction.toLp p μ 𝕜` from `α →ᵇ E` to `Lp E p μ` has dense range. * `ContinuousMap.toLp_denseRange`: For compact `α` and finite-measure `μ`, the continuous linear map `ContinuousMap.toLp p μ 𝕜` from `C(α, E)` to `Lp E p μ` has dense range. Note that for `p = ∞` this result is not true: the characteristic function of the set `[0, ∞)` in `ℝ` cannot be continuously approximated in `L∞`. The proof is in three steps. First, since simple functions are dense in `Lp`, it suffices to prove the result for a scalar multiple of a characteristic function of a measurable set `s`. Secondly, since the measure `μ` is weakly regular, the set `s` can be approximated above by an open set and below by a closed set. Finally, since the domain `α` is normal, we use Urysohn's lemma to find a continuous function interpolating between these two sets. ## Related results Are you looking for a result on "directional" approximation (above or below with respect to an order) of functions whose codomain is `ℝ≥0∞` or `ℝ`, by semicontinuous functions? See the Vitali-Carathéodory theorem, in the file `Mathlib/MeasureTheory/Integral/Bochner/VitaliCaratheodory.lean`. -/ open scoped ENNReal NNReal Topology BoundedContinuousFunction open MeasureTheory TopologicalSpace ContinuousMap Set Bornology variable {α : Type*} [TopologicalSpace α] [NormalSpace α] [MeasurableSpace α] [BorelSpace α] variable {E : Type*} [NormedAddCommGroup E] {μ : Measure α} {p : ℝ≥0∞} namespace MeasureTheory variable [NormedSpace ℝ E] /-- A variant of Urysohn's lemma, `ℒ^p` version, for an outer regular measure `μ`: consider two sets `s ⊆ u` which are respectively closed and open with `μ s < ∞`, and a vector `c`. Then one may find a continuous function `f` equal to `c` on `s` and to `0` outside of `u`, bounded by `‖c‖` everywhere, and such that the `ℒ^p` norm of `f - s.indicator (fun y ↦ c)` is arbitrarily small. Additionally, this function `f` belongs to `ℒ^p`. -/ theorem exists_continuous_eLpNorm_sub_le_of_closed [μ.OuterRegular] (hp : p ≠ ∞) {s u : Set α} (s_closed : IsClosed s) (u_open : IsOpen u) (hsu : s ⊆ u) (hs : μ s ≠ ∞) (c : E) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ f : α → E, Continuous f ∧ eLpNorm (fun x => f x - s.indicator (fun _y => c) x) p μ ≤ ε ∧ (∀ x, ‖f x‖ ≤ ‖c‖) ∧ Function.support f ⊆ u ∧ MemLp f p μ := by obtain ⟨η, η_pos, hη⟩ : ∃ η : ℝ≥0, 0 < η ∧ ∀ s : Set α, μ s ≤ η → eLpNorm (s.indicator fun _x => c) p μ ≤ ε := exists_eLpNorm_indicator_le hp c hε have ηpos : (0 : ℝ≥0∞) < η := ENNReal.coe_lt_coe.2 η_pos obtain ⟨V, sV, V_open, h'V, hV⟩ : ∃ (V : Set α), V ⊇ s ∧ IsOpen V ∧ μ V < ∞ ∧ μ (V \ s) < η := s_closed.measurableSet.exists_isOpen_diff_lt hs ηpos.ne' let v := u ∩ V have hsv : s ⊆ v := subset_inter hsu sV have hμv : μ v < ∞ := (measure_mono inter_subset_right).trans_lt h'V obtain ⟨g, hgv, hgs, hg_range⟩ := exists_continuous_zero_one_of_isClosed (u_open.inter V_open).isClosed_compl s_closed (disjoint_compl_left_iff.2 hsv) -- Multiply this by `c` to get a continuous approximation to the function `f`; the key point is -- that this is pointwise bounded by the indicator of the set `v \ s`, which has small measure. have g_norm : ∀ x, ‖g x‖ = g x := fun x => by rw [Real.norm_eq_abs, abs_of_nonneg (hg_range x).1] have gc_bd0 : ∀ x, ‖g x • c‖ ≤ ‖c‖ := by intro x simp only [norm_smul, g_norm x] apply mul_le_of_le_one_left (norm_nonneg _) exact (hg_range x).2 have gc_bd : ∀ x, ‖g x • c - s.indicator (fun _x => c) x‖ ≤ ‖(v \ s).indicator (fun _x => c) x‖ := by intro x by_cases hv : x ∈ v · rw [← Set.diff_union_of_subset hsv] at hv rcases hv with hsv | hs · simpa only [hsv.2, Set.indicator_of_notMem, not_false_iff, sub_zero, hsv, Set.indicator_of_mem] using gc_bd0 x · simp [hgs hs, hs] · simp [hgv hv, show x ∉ s from fun h => hv (hsv h)] have gc_support : (Function.support fun x : α => g x • c) ⊆ v := by refine Function.support_subset_iff'.2 fun x hx => ?_ simp only [hgv hx, Pi.zero_apply, zero_smul] have gc_mem : MemLp (fun x => g x • c) p μ := by refine MemLp.smul (memLp_top_const _) ?_ (p := p) (q := ∞) refine ⟨g.continuous.aestronglyMeasurable, ?_⟩ have : eLpNorm (v.indicator fun _x => (1 : ℝ)) p μ < ⊤ := (eLpNorm_indicator_const_le _ _).trans_lt <| by simp [lt_top_iff_ne_top, hμv.ne] refine (eLpNorm_mono fun x => ?_).trans_lt this by_cases hx : x ∈ v · simp only [hx, abs_of_nonneg (hg_range x).1, (hg_range x).2, Real.norm_eq_abs, indicator_of_mem, CStarRing.norm_one] · simp only [hgv hx, Pi.zero_apply, Real.norm_eq_abs, abs_zero, abs_nonneg] refine ⟨fun x => g x • c, g.continuous.smul continuous_const, (eLpNorm_mono gc_bd).trans ?_, gc_bd0, gc_support.trans inter_subset_left, gc_mem⟩ exact hη _ ((measure_mono (diff_subset_diff inter_subset_right Subset.rfl)).trans hV.le) /-- In a locally compact space, any function in `ℒp` can be approximated by compactly supported continuous functions when `p < ∞`, version in terms of `eLpNorm`. -/ theorem MemLp.exists_hasCompactSupport_eLpNorm_sub_le [R1Space α] [WeaklyLocallyCompactSpace α] [μ.Regular] (hp : p ≠ ∞) {f : α → E} (hf : MemLp f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α → E, HasCompactSupport g ∧ eLpNorm (f - g) p μ ≤ ε ∧ Continuous g ∧ MemLp g p μ := by suffices H : ∃ g : α → E, eLpNorm (f - g) p μ ≤ ε ∧ Continuous g ∧ MemLp g p μ ∧ HasCompactSupport g by rcases H with ⟨g, hg, g_cont, g_mem, g_support⟩ exact ⟨g, g_support, hg, g_cont, g_mem⟩ -- It suffices to check that the set of functions we consider approximates characteristic -- functions, is stable under addition and consists of ae strongly measurable functions. -- First check the latter easy facts. apply hf.induction_dense hp _ _ _ _ hε rotate_left -- stability under addition · rintro f g ⟨f_cont, f_mem, hf⟩ ⟨g_cont, g_mem, hg⟩ exact ⟨f_cont.add g_cont, f_mem.add g_mem, hf.add hg⟩ -- ae strong measurability · rintro f ⟨_f_cont, f_mem, _hf⟩ exact f_mem.aestronglyMeasurable -- We are left with approximating characteristic functions. -- This follows from `exists_continuous_eLpNorm_sub_le_of_closed`. intro c t ht htμ ε hε rcases exists_Lp_half E μ p hε with ⟨δ, δpos, hδ⟩ obtain ⟨η, ηpos, hη⟩ : ∃ η : ℝ≥0, 0 < η ∧ ∀ s : Set α, μ s ≤ η → eLpNorm (s.indicator fun _x => c) p μ ≤ δ := exists_eLpNorm_indicator_le hp c δpos.ne' have hη_pos' : (0 : ℝ≥0∞) < η := ENNReal.coe_pos.2 ηpos obtain ⟨s, st, s_compact, s_closed, μs⟩ : ∃ s, s ⊆ t ∧ IsCompact s ∧ IsClosed s ∧ μ (t \ s) < η := ht.exists_isCompact_isClosed_diff_lt htμ.ne hη_pos'.ne' have hsμ : μ s < ∞ := (measure_mono st).trans_lt htμ have I1 : eLpNorm ((s.indicator fun _y => c) - t.indicator fun _y => c) p μ ≤ δ := by rw [← eLpNorm_neg, neg_sub, ← indicator_diff st] exact hη _ μs.le obtain ⟨k, k_compact, sk⟩ : ∃ k : Set α, IsCompact k ∧ s ⊆ interior k := exists_compact_superset s_compact rcases exists_continuous_eLpNorm_sub_le_of_closed hp s_closed isOpen_interior sk hsμ.ne c δpos.ne' with ⟨f, f_cont, I2, _f_bound, f_support, f_mem⟩ have I3 : eLpNorm (f - t.indicator fun _y => c) p μ ≤ ε := by convert (hδ _ _ (f_mem.aestronglyMeasurable.sub (aestronglyMeasurable_const.indicator s_closed.measurableSet)) ((aestronglyMeasurable_const.indicator s_closed.measurableSet).sub (aestronglyMeasurable_const.indicator ht)) I2 I1).le using 2 simp only [sub_add_sub_cancel] refine ⟨f, I3, f_cont, f_mem, HasCompactSupport.intro k_compact fun x hx => ?_⟩ rw [← Function.notMem_support] contrapose! hx exact interior_subset (f_support hx) /-- In a locally compact space, any function in `ℒp` can be approximated by compactly supported continuous functions when `0 < p < ∞`, version in terms of `∫`. -/ theorem MemLp.exists_hasCompactSupport_integral_rpow_sub_le [R1Space α] [WeaklyLocallyCompactSpace α] [μ.Regular] {p : ℝ} (hp : 0 < p) {f : α → E} (hf : MemLp f (ENNReal.ofReal p) μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α → E, HasCompactSupport g ∧ (∫ x, ‖f x - g x‖ ^ p ∂μ) ≤ ε ∧ Continuous g ∧ MemLp g (ENNReal.ofReal p) μ := by have I : 0 < ε ^ (1 / p) := Real.rpow_pos_of_pos hε _ have A : ENNReal.ofReal (ε ^ (1 / p)) ≠ 0 := by simp only [Ne, ENNReal.ofReal_eq_zero, not_le, I] have B : ENNReal.ofReal p ≠ 0 := by simpa only [Ne, ENNReal.ofReal_eq_zero, not_le] using hp rcases hf.exists_hasCompactSupport_eLpNorm_sub_le ENNReal.coe_ne_top A with ⟨g, g_support, hg, g_cont, g_mem⟩ change eLpNorm _ (ENNReal.ofReal p) _ ≤ _ at hg refine ⟨g, g_support, ?_, g_cont, g_mem⟩ rwa [(hf.sub g_mem).eLpNorm_eq_integral_rpow_norm B ENNReal.coe_ne_top, ENNReal.ofReal_le_ofReal_iff I.le, one_div, ENNReal.toReal_ofReal hp.le, Real.rpow_le_rpow_iff _ hε.le (inv_pos.2 hp)] at hg positivity /-- In a locally compact space, any integrable function can be approximated by compactly supported continuous functions, version in terms of `∫⁻`. -/ theorem Integrable.exists_hasCompactSupport_lintegral_sub_le [R1Space α] [WeaklyLocallyCompactSpace α] [μ.Regular] {f : α → E} (hf : Integrable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α → E, HasCompactSupport g ∧ ∫⁻ x, ‖f x - g x‖ₑ ∂μ ≤ ε ∧ Continuous g ∧ Integrable g μ := by simp only [← memLp_one_iff_integrable, ← eLpNorm_one_eq_lintegral_enorm] at hf ⊢ exact hf.exists_hasCompactSupport_eLpNorm_sub_le ENNReal.one_ne_top hε /-- In a locally compact space, any integrable function can be approximated by compactly supported continuous functions, version in terms of `∫`. -/ theorem Integrable.exists_hasCompactSupport_integral_sub_le [R1Space α] [WeaklyLocallyCompactSpace α] [μ.Regular] {f : α → E} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α → E, HasCompactSupport g ∧ (∫ x, ‖f x - g x‖ ∂μ) ≤ ε ∧ Continuous g ∧ Integrable g μ := by simp only [← memLp_one_iff_integrable, ← ENNReal.ofReal_one] at hf ⊢ simpa using hf.exists_hasCompactSupport_integral_rpow_sub_le zero_lt_one hε /-- Any function in `ℒp` can be approximated by bounded continuous functions when `p < ∞`, version in terms of `eLpNorm`. -/ theorem MemLp.exists_boundedContinuous_eLpNorm_sub_le [μ.WeaklyRegular] (hp : p ≠ ∞) {f : α → E} (hf : MemLp f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α →ᵇ E, eLpNorm (f - (g : α → E)) p μ ≤ ε ∧ MemLp g p μ := by suffices H : ∃ g : α → E, eLpNorm (f - g) p μ ≤ ε ∧ Continuous g ∧ MemLp g p μ ∧ IsBounded (range g) by rcases H with ⟨g, hg, g_cont, g_mem, g_bd⟩ exact ⟨⟨⟨g, g_cont⟩, Metric.isBounded_range_iff.1 g_bd⟩, hg, g_mem⟩ -- It suffices to check that the set of functions we consider approximates characteristic -- functions, is stable under addition and made of ae strongly measurable functions. -- First check the latter easy facts. apply hf.induction_dense hp _ _ _ _ hε rotate_left -- stability under addition · rintro f g ⟨f_cont, f_mem, f_bd⟩ ⟨g_cont, g_mem, g_bd⟩ refine ⟨f_cont.add g_cont, f_mem.add g_mem, ?_⟩ let f' : α →ᵇ E := ⟨⟨f, f_cont⟩, Metric.isBounded_range_iff.1 f_bd⟩ let g' : α →ᵇ E := ⟨⟨g, g_cont⟩, Metric.isBounded_range_iff.1 g_bd⟩ exact (f' + g').isBounded_range -- ae strong measurability · exact fun f ⟨_, h, _⟩ => h.aestronglyMeasurable -- We are left with approximating characteristic functions. -- This follows from `exists_continuous_eLpNorm_sub_le_of_closed`. intro c t ht htμ ε hε rcases exists_Lp_half E μ p hε with ⟨δ, δpos, hδ⟩ obtain ⟨η, ηpos, hη⟩ : ∃ η : ℝ≥0, 0 < η ∧ ∀ s : Set α, μ s ≤ η → eLpNorm (s.indicator fun _x => c) p μ ≤ δ := exists_eLpNorm_indicator_le hp c δpos.ne' have hη_pos' : (0 : ℝ≥0∞) < η := ENNReal.coe_pos.2 ηpos obtain ⟨s, st, s_closed, μs⟩ : ∃ s, s ⊆ t ∧ IsClosed s ∧ μ (t \ s) < η := ht.exists_isClosed_diff_lt htμ.ne hη_pos'.ne' have hsμ : μ s < ∞ := (measure_mono st).trans_lt htμ have I1 : eLpNorm ((s.indicator fun _y => c) - t.indicator fun _y => c) p μ ≤ δ := by rw [← eLpNorm_neg, neg_sub, ← indicator_diff st] exact hη _ μs.le rcases exists_continuous_eLpNorm_sub_le_of_closed hp s_closed isOpen_univ (subset_univ _) hsμ.ne c δpos.ne' with ⟨f, f_cont, I2, f_bound, -, f_mem⟩ have I3 : eLpNorm (f - t.indicator fun _y => c) p μ ≤ ε := by convert (hδ _ _ (f_mem.aestronglyMeasurable.sub (aestronglyMeasurable_const.indicator s_closed.measurableSet)) ((aestronglyMeasurable_const.indicator s_closed.measurableSet).sub (aestronglyMeasurable_const.indicator ht)) I2 I1).le using 2 simp only [sub_add_sub_cancel] refine ⟨f, I3, f_cont, f_mem, ?_⟩ exact (BoundedContinuousFunction.ofNormedAddCommGroup f f_cont _ f_bound).isBounded_range /-- Any function in `ℒp` can be approximated by bounded continuous functions when `0 < p < ∞`, version in terms of `∫`. -/ theorem MemLp.exists_boundedContinuous_integral_rpow_sub_le [μ.WeaklyRegular] {p : ℝ} (hp : 0 < p) {f : α → E} (hf : MemLp f (ENNReal.ofReal p) μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α →ᵇ E, (∫ x, ‖f x - g x‖ ^ p ∂μ) ≤ ε ∧ MemLp g (ENNReal.ofReal p) μ := by have I : 0 < ε ^ (1 / p) := Real.rpow_pos_of_pos hε _ have A : ENNReal.ofReal (ε ^ (1 / p)) ≠ 0 := by simp only [Ne, ENNReal.ofReal_eq_zero, not_le, I] have B : ENNReal.ofReal p ≠ 0 := by simpa only [Ne, ENNReal.ofReal_eq_zero, not_le] using hp rcases hf.exists_boundedContinuous_eLpNorm_sub_le ENNReal.coe_ne_top A with ⟨g, hg, g_mem⟩ change eLpNorm _ (ENNReal.ofReal p) _ ≤ _ at hg refine ⟨g, ?_, g_mem⟩ rwa [(hf.sub g_mem).eLpNorm_eq_integral_rpow_norm B ENNReal.coe_ne_top, ENNReal.ofReal_le_ofReal_iff I.le, one_div, ENNReal.toReal_ofReal hp.le, Real.rpow_le_rpow_iff _ hε.le (inv_pos.2 hp)] at hg positivity /-- Any integrable function can be approximated by bounded continuous functions, version in terms of `∫⁻`. -/ theorem Integrable.exists_boundedContinuous_lintegral_sub_le [μ.WeaklyRegular] {f : α → E} (hf : Integrable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α →ᵇ E, ∫⁻ x, ‖f x - g x‖ₑ ∂μ ≤ ε ∧ Integrable g μ := by simp only [← memLp_one_iff_integrable, ← eLpNorm_one_eq_lintegral_enorm] at hf ⊢ exact hf.exists_boundedContinuous_eLpNorm_sub_le ENNReal.one_ne_top hε /-- Any integrable function can be approximated by bounded continuous functions, version in terms of `∫`. -/ theorem Integrable.exists_boundedContinuous_integral_sub_le [μ.WeaklyRegular] {f : α → E} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : ∃ g : α →ᵇ E, (∫ x, ‖f x - g x‖ ∂μ) ≤ ε ∧ Integrable g μ := by simp only [← memLp_one_iff_integrable, ← ENNReal.ofReal_one] at hf ⊢ simpa using hf.exists_boundedContinuous_integral_rpow_sub_le zero_lt_one hε namespace Lp variable (E μ) /-- A function in `Lp` can be approximated in `Lp` by continuous functions. -/ theorem boundedContinuousFunction_dense [SecondCountableTopologyEither α E] [Fact (1 ≤ p)] (hp : p ≠ ∞) [μ.WeaklyRegular] : Dense (boundedContinuousFunction E p μ : Set (Lp E p μ)) := by intro f refine (mem_closure_iff_nhds_basis EMetric.nhds_basis_closed_eball).2 fun ε hε ↦ ?_ obtain ⟨g, hg, g_mem⟩ : ∃ g : α →ᵇ E, eLpNorm ((f : α → E) - (g : α → E)) p μ ≤ ε ∧ MemLp g p μ := (Lp.memLp f).exists_boundedContinuous_eLpNorm_sub_le hp hε.ne' refine ⟨g_mem.toLp _, ⟨g, rfl⟩, ?_⟩ rwa [EMetric.mem_closedBall', ← Lp.toLp_coeFn f (Lp.memLp f), Lp.edist_toLp_toLp] /-- A function in `Lp` can be approximated in `Lp` by continuous functions. -/ theorem boundedContinuousFunction_topologicalClosure [SecondCountableTopologyEither α E] [Fact (1 ≤ p)] (hp : p ≠ ∞) [μ.WeaklyRegular] : (boundedContinuousFunction E p μ).topologicalClosure = ⊤ := SetLike.ext' <| (boundedContinuousFunction_dense E μ hp).closure_eq end Lp end MeasureTheory variable [SecondCountableTopologyEither α E] [_i : Fact (1 ≤ p)] variable (𝕜 : Type*) [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] [NormedSpace ℝ E] variable (E) (μ) namespace BoundedContinuousFunction theorem toLp_denseRange [μ.WeaklyRegular] [IsFiniteMeasure μ] (hp : p ≠ ∞) : DenseRange (toLp p μ 𝕜 : (α →ᵇ E) →L[𝕜] Lp E p μ) := by simpa only [← range_toLp p μ (𝕜 := 𝕜)] using MeasureTheory.Lp.boundedContinuousFunction_dense E μ hp end BoundedContinuousFunction namespace ContinuousMap /-- Continuous functions are dense in `MeasureTheory.Lp`, `1 ≤ p < ∞`. This theorem assumes that the domain is a compact space because otherwise `ContinuousMap.toLp` is undefined. Use `BoundedContinuousFunction.toLp_denseRange` if the domain is not a compact space. -/ theorem toLp_denseRange [CompactSpace α] [μ.WeaklyRegular] [IsFiniteMeasure μ] (hp : p ≠ ∞) : DenseRange (toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ) := by refine (BoundedContinuousFunction.toLp_denseRange _ _ 𝕜 hp).mono ?_ refine range_subset_iff.2 fun f ↦ ?_ exact ⟨f.toContinuousMap, rfl⟩ end ContinuousMap
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/Holder.lean
import Mathlib.MeasureTheory.Integral.Bochner.Basic /-! # Continuous bilinear maps on `MeasureTheory.Lp` spaces Given a continuous bilinear map `B : E →L[𝕜] F →L[𝕜] G`, we define an associated map `ContinuousLinearMap.holder : Lp E p μ → Lp F q μ → Lp G r μ` where `p q r` are a Hölder triple. We bundle this into a bilinear map `ContinuousLinearMap.holderₗ` and a continuous bilinear map `ContinuousLinearMap.holderL` under some additional assumptions. We also declare a heterogeneous scalar multiplication (`HSMul`) instance on `MeasureTheory.Lp` spaces. Although this could use the `ContinuousLinearMap.holder` construction above, we opt not to do so in order to minimize the necessary type class assumptions. When `p q : ℝ≥0∞` are Hölder conjugate (i.e., `HolderConjugate p q`), we also construct the natural map `ContinuousLinearMap.lpPairing : Lp E p μ →L[𝕜] Lp F q μ →L[𝕜] G` given by `fun f g ↦ ∫ x, B (f x) (g x) ∂μ`. When `B := (NormedSpace.inclusionInDoubleDual 𝕜 E).flip`, this is the natural map `Lp (StrongDual 𝕜 E) p μ →L[𝕜] StrongDual 𝕜 (Lp E q μ)`. -/ open ENNReal MeasureTheory Lp open scoped NNReal noncomputable section /-! ### Induced bilinear maps -/ section Bilinear variable {α 𝕜 E F G : Type*} {m : MeasurableSpace α} {μ : Measure α} {p q r : ENNReal} [hpqr : HolderTriple p q r] [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] [NormedSpace 𝕜 G] (B : E →L[𝕜] F →L[𝕜] G) namespace ContinuousLinearMap variable (r) in theorem memLp_of_bilin {f : α → E} {g : α → F} (hf : MemLp f p μ) (hg : MemLp g q μ) : MemLp (fun x ↦ B (f x) (g x)) r μ := MeasureTheory.MemLp.of_bilin (r := r) (B · ·) ‖B‖₊ hf hg (B.aestronglyMeasurable_comp₂ hf.1 hg.1) (.of_forall fun _ ↦ B.le_opNorm₂ _ _) variable (r) in /-- The map between `MeasureTheory.Lp` spaces satisfying `ENNReal.HolderTriple` induced by a continuous bilinear map on the underlying spaces. -/ def holder (f : Lp E p μ) (g : Lp F q μ) : Lp G r μ := (B.memLp_of_bilin r (Lp.memLp f) (Lp.memLp g)).toLp lemma coeFn_holder (f : Lp E p μ) (g : Lp F q μ) : B.holder r f g =ᵐ[μ] fun x ↦ B (f x) (g x) := by rw [holder] exact MemLp.coeFn_toLp _ lemma nnnorm_holder_apply_apply_le (f : Lp E p μ) (g : Lp F q μ) : ‖B.holder r f g‖₊ ≤ ‖B‖₊ * ‖f‖₊ * ‖g‖₊ := by simp_rw [← ENNReal.coe_le_coe, ENNReal.coe_mul, ← enorm_eq_nnnorm, Lp.enorm_def] apply eLpNorm_congr_ae (coeFn_holder B f g) |>.trans_le exact eLpNorm_le_eLpNorm_mul_eLpNorm_of_nnnorm (Lp.memLp f).1 (Lp.memLp g).1 (B · ·) ‖B‖₊ (.of_forall fun _ ↦ B.le_opNorm₂ _ _) lemma norm_holder_apply_apply_le (f : Lp E p μ) (g : Lp F q μ) : ‖B.holder r f g‖ ≤ ‖B‖ * ‖f‖ * ‖g‖ := NNReal.coe_le_coe.mpr <| nnnorm_holder_apply_apply_le B f g lemma holder_add_left (f₁ f₂ : Lp E p μ) (g : Lp F q μ) : B.holder r (f₁ + f₂) g = B.holder r f₁ g + B.holder r f₂ g := by simp only [holder, ← MemLp.toLp_add] apply MemLp.toLp_congr filter_upwards [AEEqFun.coeFn_add f₁.val f₂.val] with x hx simp [hx] lemma holder_add_right (f : Lp E p μ) (g₁ g₂ : Lp F q μ) : B.holder r f (g₁ + g₂) = B.holder r f g₁ + B.holder r f g₂ := by simp only [holder, ← MemLp.toLp_add] apply MemLp.toLp_congr filter_upwards [AEEqFun.coeFn_add g₁.val g₂.val] with x hx simp [hx] lemma holder_smul_left (c : 𝕜) (f : Lp E p μ) (g : Lp F q μ) : B.holder r (c • f) g = c • B.holder r f g := by simp only [holder, ← MemLp.toLp_const_smul] apply MemLp.toLp_congr filter_upwards [Lp.coeFn_smul c f] with x hx simp [hx] lemma holder_smul_right (c : 𝕜) (f : Lp E p μ) (g : Lp F q μ) : B.holder r f (c • g) = c • B.holder r f g := by simp only [holder, ← MemLp.toLp_const_smul] apply MemLp.toLp_congr filter_upwards [Lp.coeFn_smul c g] with x hx simp [hx] variable (μ p q r) in /-- `MeasureTheory.Lp.holder` as a bilinear map. -/ @[simps! apply_apply] def holderₗ : Lp E p μ →ₗ[𝕜] Lp F q μ →ₗ[𝕜] Lp G r μ := .mk₂ 𝕜 (B.holder r) B.holder_add_left B.holder_smul_left B.holder_add_right B.holder_smul_right variable [Fact (1 ≤ p)] [Fact (1 ≤ q)] [Fact (1 ≤ r)] variable (μ p q r) in /-- `MeasureTheory.Lp.holder` as a continuous bilinear map. -/ @[simps! apply_apply] def holderL : Lp E p μ →L[𝕜] Lp F q μ →L[𝕜] Lp G r μ := LinearMap.mkContinuous₂ (B.holderₗ μ p q r) ‖B‖ (norm_holder_apply_apply_le B) lemma norm_holderL_le : ‖(B.holderL μ p q r)‖ ≤ ‖B‖ := LinearMap.mkContinuous₂_norm_le _ (norm_nonneg B) _ variable [HolderConjugate p q] [NormedSpace ℝ G] [SMulCommClass ℝ 𝕜 G] [CompleteSpace G] variable (μ p q) in /-- The natural pairing between `Lp E p μ` and `Lp F q μ` (for Hölder conjugate `p q : ℝ≥0∞`) with values in a space `G` induced by a bilinear map `B : E →L[𝕜] F →L[𝕜] G`. This is given by `∫ x, B (f x) (g x) ∂μ`. In the special case when `B := (NormedSpace.inclusionInDoubleDual 𝕜 E).flip`, which is definitionally the same as `B := ContinuousLinearMap.id 𝕜 (E →L[𝕜] 𝕜)`, this is the natural map `Lp (StrongDual 𝕜 E) p μ →L[𝕜] StrongDual 𝕜 (Lp E q μ)`. -/ def lpPairing (B : E →L[𝕜] F →L[𝕜] G) : Lp E p μ →L[𝕜] Lp F q μ →L[𝕜] G := (L1.integralCLM' 𝕜 |>.postcomp <| Lp F q μ) ∘L (B.holderL μ p q 1) lemma lpPairing_eq_integral (f : Lp E p μ) (g : Lp F q μ) : B.lpPairing μ p q f g = ∫ x, B (f x) (g x) ∂μ := by change L1.integralCLM _ = _ rw [← L1.integral_def, L1.integral_eq_integral] exact integral_congr_ae <| B.coeFn_holder _ _ end ContinuousLinearMap end Bilinear namespace MeasureTheory namespace Lp /-! ### Heterogeneous scalar multiplication While the previous section is *nominally* more general than this one, and indeed, we could use the constructions of the previous section to define the scalar multiplication herein, we would lose some slight generality as we would need to require that `𝕜` is a nontrivially normed field everywhere. Moreover, it would only simplify a few proofs. -/ section SMul variable {α 𝕜' 𝕜 E : Type*} {m : MeasurableSpace α} {μ : Measure α} {p q r : ℝ≥0∞} [hpqr : HolderTriple p q r] section MulActionWithZero variable [NormedRing 𝕜] [NormedAddCommGroup E] [MulActionWithZero 𝕜 E] [IsBoundedSMul 𝕜 E] /-- Heterogeneous scalar multiplication of `MeasureTheory.Lp` functions by `MeasureTheory.Lp` functions when the exponents satisfy `ENNReal.HolderTriple p q r`. -/ instance : HSMul (Lp 𝕜 p μ) (Lp E q μ) (Lp E r μ) where hSMul f g := (Lp.memLp g).smul (Lp.memLp f) |>.toLp (⇑f • ⇑g) lemma smul_def {f : Lp 𝕜 p μ} {g : Lp E q μ} : f • g = ((Lp.memLp g).smul (Lp.memLp f)).toLp (⇑f • ⇑g) := rfl lemma coeFn_lpSMul (f : Lp 𝕜 p μ) (g : Lp E q μ) : (f • g : Lp E r μ) =ᵐ[μ] ⇑f • g := by rw [smul_def] exact MemLp.coeFn_toLp _ protected lemma norm_smul_le (f : Lp 𝕜 p μ) (g : Lp E q μ) : ‖f • g‖ ≤ ‖f‖ * ‖g‖ := by simp only [Lp.norm_def, ← ENNReal.toReal_mul] refine ENNReal.toReal_mono (by finiteness) ?_ rw [eLpNorm_congr_ae (coeFn_lpSMul f g)] exact eLpNorm_smul_le_mul_eLpNorm (Lp.aestronglyMeasurable g) (Lp.aestronglyMeasurable f) end MulActionWithZero section Module variable [NormedRing 𝕜] [NormedAddCommGroup E] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] protected lemma smul_add (f₁ f₂ : Lp 𝕜 p μ) (g : Lp E q μ) : (f₁ + f₂) • g = f₁ • g + f₂ • g := by simp only [smul_def, ← MemLp.toLp_add] apply MemLp.toLp_congr filter_upwards [AEEqFun.coeFn_add f₁.val f₂.val] with x hx simp [hx, add_smul] protected lemma add_smul (f : Lp 𝕜 p μ) (g₁ g₂ : Lp E q μ) : f • (g₁ + g₂) = f • g₁ + f • g₂ := by simp only [smul_def, ← MemLp.toLp_add] apply MemLp.toLp_congr _ _ ?_ filter_upwards [AEEqFun.coeFn_add g₁.val g₂.val] with x hx simp [hx, smul_add] variable (E q) in @[simp] protected lemma smul_zero (f : Lp 𝕜 p μ) : f • (0 : Lp E q μ) = (0 : Lp E r μ) := by convert MemLp.zero (ε := E) |>.toLp_zero apply MemLp.toLp_congr _ _ ?_ filter_upwards [Lp.coeFn_zero E q μ] with x hx rw [Pi.smul_apply', hx] simp variable (𝕜 p) in @[simp] protected lemma zero_smul (f : Lp E q μ) : (0 : Lp 𝕜 p μ) • f = (0 : Lp E r μ) := by convert MemLp.zero (ε := E) |>.toLp_zero apply MemLp.toLp_congr _ _ ?_ filter_upwards [Lp.coeFn_zero 𝕜 p μ] with x hx rw [Pi.smul_apply', hx] simp @[simp] protected lemma smul_neg (f : Lp 𝕜 p μ) (g : Lp E q μ) : f • -g = -(f • g) := by simp [eq_neg_iff_add_eq_zero, ← Lp.add_smul] @[simp] protected lemma neg_smul (f : Lp 𝕜 p μ) (g : Lp E q μ) : -f • g = -(f • g) := by simp [eq_neg_iff_add_eq_zero, ← Lp.smul_add] protected lemma neg_smul_neg (f : Lp 𝕜 p μ) (g : Lp E q μ) : -f • -g = f • g := by simp variable [NormedRing 𝕜'] [Module 𝕜' E] [Module 𝕜' 𝕜] [IsBoundedSMul 𝕜' E] [IsBoundedSMul 𝕜' 𝕜] protected lemma smul_assoc [IsScalarTower 𝕜' 𝕜 E] (c : 𝕜') (f : Lp 𝕜 p μ) (g : Lp E q μ) : (c • f) • g = c • (f • g) := by simp only [smul_def, ← MemLp.toLp_const_smul] apply MemLp.toLp_congr filter_upwards [Lp.coeFn_smul c f] with x hx simp [-smul_eq_mul, hx] protected lemma smul_comm [SMulCommClass 𝕜' 𝕜 E] (c : 𝕜') (f : Lp 𝕜 p μ) (g : Lp E q μ) : c • f • g = f • c • g := by simp only [smul_def, ← MemLp.toLp_const_smul] apply MemLp.toLp_congr filter_upwards [Lp.coeFn_smul c f, Lp.coeFn_smul c g] with x hfx hgx simp [smul_comm, hgx] end Module end SMul end Lp end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/AEEqOfLIntegral.lean
import Mathlib.MeasureTheory.Function.StronglyMeasurable.ENNReal import Mathlib.MeasureTheory.Measure.WithDensity /-! # From equality of integrals to equality of functions This file provides various statements of the general form "if two functions have the same integral on all sets, then they are equal almost everywhere". The different lemmas use various hypotheses on the class of functions, on the target space or on the possible finiteness of the measure. This file is about Lebesgue integrals. See the file `AEEqOfIntegral` for Bochner integrals. ## Main statements The results listed below apply to two functions `f, g`, under the hypothesis that for all measurable sets `s` with finite measure, `∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ`. The conclusion is then `f =ᵐ[μ] g`. The main lemmas are: * `ae_eq_of_forall_setLIntegral_eq_of_sigmaFinite`: case of a sigma-finite measure. * `AEMeasurable.ae_eq_of_forall_setLIntegral_eq`: for functions which are `AEMeasurable` and have finite integral. -/ open Filter open scoped ENNReal NNReal MeasureTheory Topology namespace MeasureTheory variable {α : Type*} {m m0 : MeasurableSpace α} {μ : Measure α} {p : ℝ≥0∞} theorem ae_const_le_iff_forall_lt_measure_zero {β} [LinearOrder β] [TopologicalSpace β] [OrderTopology β] [FirstCountableTopology β] (f : α → β) (c : β) : (∀ᵐ x ∂μ, c ≤ f x) ↔ ∀ b < c, μ {x | f x ≤ b} = 0 := by rw [ae_iff] push_neg constructor · intro h b hb exact measure_mono_null (fun y hy => (lt_of_le_of_lt hy hb : _)) h intro hc by_cases! h : ∀ b, c ≤ b · have : {a : α | f a < c} = ∅ := by apply Set.eq_empty_iff_forall_notMem.2 fun x hx => ?_ exact (lt_irrefl _ (lt_of_lt_of_le hx (h (f x)))).elim simp [this] by_cases! H : ¬IsLUB (Set.Iio c) c · have : c ∈ upperBounds (Set.Iio c) := fun y hy => le_of_lt hy obtain ⟨b, b_up, bc⟩ : ∃ b : β, b ∈ upperBounds (Set.Iio c) ∧ b < c := by simpa [IsLUB, IsLeast, this, lowerBounds] using H exact measure_mono_null (fun x hx => b_up hx) (hc b bc) obtain ⟨u, _, u_lt, u_lim, -⟩ : ∃ u : ℕ → β, StrictMono u ∧ (∀ n : ℕ, u n < c) ∧ Tendsto u atTop (𝓝 c) ∧ ∀ n : ℕ, u n ∈ Set.Iio c := H.exists_seq_strictMono_tendsto_of_notMem (lt_irrefl c) h have h_Union : {x | f x < c} = ⋃ n : ℕ, {x | f x ≤ u n} := by ext1 x simp_rw [Set.mem_iUnion, Set.mem_setOf_eq] constructor <;> intro h · obtain ⟨n, hn⟩ := ((tendsto_order.1 u_lim).1 _ h).exists; exact ⟨n, hn.le⟩ · obtain ⟨n, hn⟩ := h; exact hn.trans_lt (u_lt _) rw [h_Union, measure_iUnion_null_iff] intro n exact hc _ (u_lt n) lemma ae_le_const_iff_forall_gt_measure_zero {β} [LinearOrder β] [TopologicalSpace β] [OrderTopology β] [FirstCountableTopology β] {μ : Measure α} (f : α → β) (c : β) : (∀ᵐ x ∂μ, f x ≤ c) ↔ ∀ b, c < b → μ {x | b ≤ f x} = 0 := ae_const_le_iff_forall_lt_measure_zero (β := βᵒᵈ) _ _ theorem ae_le_of_forall_setLIntegral_le_of_sigmaFinite₀ [SigmaFinite μ] {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (h : ∀ s, MeasurableSet s → μ s < ∞ → ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ) : f ≤ᵐ[μ] g := by have A : ∀ (ε N : ℝ≥0) (p : ℕ), 0 < ε → μ ({x | g x + ε ≤ f x ∧ g x ≤ N} ∩ spanningSets μ p) = 0 := by intro ε N p εpos let s := {x | g x + ε ≤ f x ∧ g x ≤ N} ∩ spanningSets μ p have s_lt_top : μ s < ∞ := (measure_mono (Set.inter_subset_right)).trans_lt (measure_spanningSets_lt_top μ p) have A : (∫⁻ x in s, g x ∂μ) + ε * μ s ≤ (∫⁻ x in s, g x ∂μ) + 0 := calc (∫⁻ x in s, g x ∂μ) + ε * μ s = (∫⁻ x in s, g x ∂μ) + ∫⁻ _ in s, ε ∂μ := by simp only [lintegral_const, Set.univ_inter, MeasurableSet.univ, Measure.restrict_apply] _ = ∫⁻ x in s, g x + ε ∂μ := (lintegral_add_right _ measurable_const).symm _ ≤ ∫⁻ x in s, f x ∂μ := setLIntegral_mono_ae hf.restrict <| ae_of_all _ fun x hx => hx.1.1 _ ≤ (∫⁻ x in s, g x ∂μ) + 0 := by rw [add_zero, ← Measure.restrict_toMeasurable s_lt_top.ne] refine h _ (measurableSet_toMeasurable ..) ?_ rwa [measure_toMeasurable] have B : (∫⁻ x in s, g x ∂μ) ≠ ∞ := (setLIntegral_lt_top_of_le_nnreal s_lt_top.ne ⟨N, fun _ h ↦ h.1.2⟩).ne have : (ε : ℝ≥0∞) * μ s ≤ 0 := ENNReal.le_of_add_le_add_left B A simpa only [ENNReal.coe_eq_zero, nonpos_iff_eq_zero, mul_eq_zero, εpos.ne', false_or] obtain ⟨u, _, u_pos, u_lim⟩ : ∃ u : ℕ → ℝ≥0, StrictAnti u ∧ (∀ n, 0 < u n) ∧ Tendsto u atTop (𝓝 0) := exists_seq_strictAnti_tendsto (0 : ℝ≥0) let s := fun n : ℕ => {x | g x + u n ≤ f x ∧ g x ≤ (n : ℝ≥0)} ∩ spanningSets μ n have μs : ∀ n, μ (s n) = 0 := fun n => A _ _ _ (u_pos n) have B : {x | f x ≤ g x}ᶜ ⊆ ⋃ n, s n := by intro x hx simp only [Set.mem_compl_iff, Set.mem_setOf, not_le] at hx have L1 : ∀ᶠ n in atTop, g x + u n ≤ f x := by have : Tendsto (fun n => g x + u n) atTop (𝓝 (g x + (0 : ℝ≥0))) := tendsto_const_nhds.add (ENNReal.tendsto_coe.2 u_lim) simp only [ENNReal.coe_zero, add_zero] at this exact this.eventually_le_const hx have L2 : ∀ᶠ n : ℕ in (atTop : Filter ℕ), g x ≤ (n : ℝ≥0) := have : Tendsto (fun n : ℕ => ((n : ℝ≥0) : ℝ≥0∞)) atTop (𝓝 ∞) := by simp only [ENNReal.coe_natCast] exact ENNReal.tendsto_nat_nhds_top this.eventually_const_le (hx.trans_le le_top) apply Set.mem_iUnion.2 exact ((L1.and L2).and (eventually_mem_spanningSets μ x)).exists refine le_antisymm ?_ bot_le calc μ {x : α | (fun x : α => f x ≤ g x) x}ᶜ ≤ μ (⋃ n, s n) := measure_mono B _ ≤ ∑' n, μ (s n) := measure_iUnion_le _ _ = 0 := by simp only [μs, tsum_zero] theorem ae_le_of_forall_setLIntegral_le_of_sigmaFinite [SigmaFinite μ] {f g : α → ℝ≥0∞} (hf : Measurable f) (h : ∀ s, MeasurableSet s → μ s < ∞ → (∫⁻ x in s, f x ∂μ) ≤ ∫⁻ x in s, g x ∂μ) : f ≤ᵐ[μ] g := ae_le_of_forall_setLIntegral_le_of_sigmaFinite₀ hf.aemeasurable h theorem ae_eq_of_forall_setLIntegral_eq_of_sigmaFinite₀ [SigmaFinite μ] {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (h : ∀ s, MeasurableSet s → μ s < ∞ → ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ) : f =ᵐ[μ] g := by have A : f ≤ᵐ[μ] g := ae_le_of_forall_setLIntegral_le_of_sigmaFinite₀ hf fun s hs h's => le_of_eq (h s hs h's) have B : g ≤ᵐ[μ] f := ae_le_of_forall_setLIntegral_le_of_sigmaFinite₀ hg fun s hs h's => ge_of_eq (h s hs h's) filter_upwards [A, B] with x using le_antisymm theorem ae_eq_of_forall_setLIntegral_eq_of_sigmaFinite [SigmaFinite μ] {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (h : ∀ s, MeasurableSet s → μ s < ∞ → ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ) : f =ᵐ[μ] g := ae_eq_of_forall_setLIntegral_eq_of_sigmaFinite₀ hf.aemeasurable hg.aemeasurable h theorem AEMeasurable.ae_eq_of_forall_setLIntegral_eq {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (hfi : ∫⁻ x, f x ∂μ ≠ ∞) (hgi : ∫⁻ x, g x ∂μ ≠ ∞) (hfg : ∀ ⦃s⦄, MeasurableSet s → μ s < ∞ → ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ) : f =ᵐ[μ] g := by have hf' : AEFinStronglyMeasurable f μ := ENNReal.aefinStronglyMeasurable_of_aemeasurable hfi hf have hg' : AEFinStronglyMeasurable g μ := ENNReal.aefinStronglyMeasurable_of_aemeasurable hgi hg let s := hf'.sigmaFiniteSet let t := hg'.sigmaFiniteSet suffices f =ᵐ[μ.restrict (s ∪ t)] g by refine ae_of_ae_restrict_of_ae_restrict_compl _ this ?_ simp only [Set.compl_union] have h1 : f =ᵐ[μ.restrict sᶜ] 0 := hf'.ae_eq_zero_compl have h2 : g =ᵐ[μ.restrict tᶜ] 0 := hg'.ae_eq_zero_compl rw [ae_restrict_iff' (hf'.measurableSet.compl.inter hg'.measurableSet.compl)] rw [EventuallyEq, ae_restrict_iff' hf'.measurableSet.compl] at h1 rw [EventuallyEq, ae_restrict_iff' hg'.measurableSet.compl] at h2 filter_upwards [h1, h2] with x h1 h2 hx rw [h1 (Set.inter_subset_left hx), h2 (Set.inter_subset_right hx)] refine ae_eq_of_forall_setLIntegral_eq_of_sigmaFinite₀ hf.restrict hg.restrict fun u hu huμ ↦ ?_ rw [Measure.restrict_restrict hu] rw [Measure.restrict_apply hu] at huμ exact hfg (hu.inter (hf'.measurableSet.union hg'.measurableSet)) huμ section PiSystem variable {s : Set (Set α)} {f g : α → ℝ≥0∞} theorem lintegral_eq_lintegral_of_isPiSystem (h_eq : m0 = MeasurableSpace.generateFrom s) (h_inter : IsPiSystem s) (basic : ∀ t ∈ s, ∫⁻ x in t, f x ∂μ = ∫⁻ x in t, g x ∂μ) (h_univ : ∫⁻ x, f x ∂μ = ∫⁻ x, g x ∂μ) (hf_int : ∫⁻ x, f x ∂μ ≠ ∞) : ∀ t (_ : MeasurableSet t), ∫⁻ x in t, f x ∂μ = ∫⁻ x in t, g x ∂μ := by refine MeasurableSpace.induction_on_inter h_eq h_inter ?_ basic ?_ ?_ · simp · intro t ht h_eq rw [setLIntegral_compl ht, setLIntegral_compl ht, h_eq, h_univ] · refine ne_of_lt ?_ calc ∫⁻ x in t, g x ∂μ _ ≤ ∫⁻ x, g x ∂μ := setLIntegral_le_lintegral t _ _ < ∞ := by rw [← h_univ]; exact hf_int.lt_top · refine ne_of_lt ?_ calc ∫⁻ x in t, f x ∂μ _ ≤ ∫⁻ x, f x ∂μ := setLIntegral_le_lintegral t _ _ < ∞ := hf_int.lt_top · intro t htd htm h simp_rw [lintegral_iUnion htm htd, h] lemma lintegral_eq_lintegral_of_isPiSystem_of_univ_mem (h_eq : m0 = MeasurableSpace.generateFrom s) (h_inter : IsPiSystem s) (h_univ : Set.univ ∈ s) (basic : ∀ t ∈ s, ∫⁻ x in t, f x ∂μ = ∫⁻ x in t, g x ∂μ) (hf_int : ∫⁻ x, f x ∂μ ≠ ∞) {t : Set α} (ht : MeasurableSet t) : ∫⁻ x in t, f x ∂μ = ∫⁻ x in t, g x ∂μ := by refine lintegral_eq_lintegral_of_isPiSystem h_eq h_inter basic ?_ hf_int t ht rw [← setLIntegral_univ, ← setLIntegral_univ g] exact basic _ h_univ /-- If two a.e.-measurable functions `α × β → ℝ≥0∞` with finite integrals have the same integral on every rectangle, then they are almost everywhere equal. -/ lemma ae_eq_of_setLIntegral_prod_eq {β : Type*} {mβ : MeasurableSpace β} {μ : Measure (α × β)} {f g : α × β → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (hf_int : ∫⁻ x, f x ∂μ ≠ ∞) (h : ∀ ⦃s : Set α⦄ (_ : MeasurableSet s) ⦃t : Set β⦄ (_ : MeasurableSet t), ∫⁻ x in s ×ˢ t, f x ∂μ = ∫⁻ x in s ×ˢ t, g x ∂μ) : f =ᵐ[μ] g := by have hg_int : ∫⁻ x, g x ∂μ ≠ ∞ := by rwa [← setLIntegral_univ, ← Set.univ_prod_univ, ← h .univ .univ, Set.univ_prod_univ, setLIntegral_univ] refine AEMeasurable.ae_eq_of_forall_setLIntegral_eq hf hg hf_int hg_int fun s hs _ ↦ ?_ refine lintegral_eq_lintegral_of_isPiSystem_of_univ_mem generateFrom_prod.symm isPiSystem_prod ?_ ?_ hf_int hs · exact ⟨Set.univ, .univ, Set.univ, .univ, Set.univ_prod_univ⟩ · rintro _ ⟨s, hs, t, ht, rfl⟩ exact h hs ht end PiSystem section WithDensity variable {m : MeasurableSpace α} {μ : Measure α} theorem withDensity_eq_iff_of_sigmaFinite [SigmaFinite μ] {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : μ.withDensity f = μ.withDensity g ↔ f =ᵐ[μ] g := ⟨fun hfg ↦ by refine ae_eq_of_forall_setLIntegral_eq_of_sigmaFinite₀ hf hg fun s hs _ ↦ ?_ rw [← withDensity_apply f hs, ← withDensity_apply g hs, ← hfg], withDensity_congr_ae⟩ theorem withDensity_eq_iff {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (hfi : ∫⁻ x, f x ∂μ ≠ ∞) : μ.withDensity f = μ.withDensity g ↔ f =ᵐ[μ] g := ⟨fun hfg ↦ by refine AEMeasurable.ae_eq_of_forall_setLIntegral_eq hf hg hfi ?_ fun s hs _ ↦ ?_ · rwa [← setLIntegral_univ, ← withDensity_apply g MeasurableSet.univ, ← hfg, withDensity_apply f MeasurableSet.univ, setLIntegral_univ] · rw [← withDensity_apply f hs, ← withDensity_apply g hs, ← hfg], withDensity_congr_ae⟩ end WithDensity end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/EssSup.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order import Mathlib.MeasureTheory.Measure.Count import Mathlib.Order.Filter.ENNReal import Mathlib.Probability.UniformOn /-! # Essential supremum and infimum We define the essential supremum and infimum of a function `f : α → β` with respect to a measure `μ` on `α`. The essential supremum is the infimum of the constants `c : β` such that `f x ≤ c` almost everywhere. TODO: The essential supremum of functions `α → ℝ≥0∞` is used in particular to define the norm in the `L∞` space (see `Mathlib/MeasureTheory/Function/LpSeminorm/Defs.lean`). There is a different quantity which is sometimes also called essential supremum: the least upper-bound among measurable functions of a family of measurable functions (in an almost-everywhere sense). We do not define that quantity here, which is simply the supremum of a map with values in `α →ₘ[μ] β` (see `Mathlib/MeasureTheory/Function/AEEqFun.lean`). ## Main definitions * `essSup f μ := (ae μ).limsup f` * `essInf f μ := (ae μ).liminf f` -/ open Filter MeasureTheory ProbabilityTheory Set TopologicalSpace open scoped ENNReal NNReal variable {α β : Type*} {m : MeasurableSpace α} {μ ν : Measure α} section ConditionallyCompleteLattice variable [ConditionallyCompleteLattice β] {f : α → β} /-- Essential supremum of `f` with respect to measure `μ`: the smallest `c : β` such that `f x ≤ c` a.e. -/ def essSup {_ : MeasurableSpace α} (f : α → β) (μ : Measure α) := (ae μ).limsup f /-- Essential infimum of `f` with respect to measure `μ`: the greatest `c : β` such that `c ≤ f x` a.e. -/ def essInf {_ : MeasurableSpace α} (f : α → β) (μ : Measure α) := (ae μ).liminf f theorem essSup_congr_ae {f g : α → β} (hfg : f =ᵐ[μ] g) : essSup f μ = essSup g μ := limsup_congr hfg theorem essInf_congr_ae {f g : α → β} (hfg : f =ᵐ[μ] g) : essInf f μ = essInf g μ := @essSup_congr_ae α βᵒᵈ _ _ _ _ _ hfg @[simp] theorem essSup_const' [NeZero μ] (c : β) : essSup (fun _ : α => c) μ = c := limsup_const _ @[simp] theorem essInf_const' [NeZero μ] (c : β) : essInf (fun _ : α => c) μ = c := liminf_const _ theorem essSup_const (c : β) (hμ : μ ≠ 0) : essSup (fun _ : α => c) μ = c := have := NeZero.mk hμ; essSup_const' _ theorem essInf_const (c : β) (hμ : μ ≠ 0) : essInf (fun _ : α => c) μ = c := have := NeZero.mk hμ; essInf_const' _ section SMul variable {R : Type*} [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] [NoZeroSMulDivisors R ℝ≥0∞] {c : R} @[simp] lemma essSup_smul_measure (hc : c ≠ 0) (f : α → β) : essSup f (c • μ) = essSup f μ := by simp_rw [essSup, Measure.ae_smul_measure_eq hc] end SMul variable [Nonempty α] lemma essSup_eq_ciSup (hμ : ∀ a, μ {a} ≠ 0) (hf : BddAbove (Set.range f)) : essSup f μ = ⨆ a, f a := by rw [essSup, ae_eq_top.2 hμ, limsup_top_eq_ciSup hf] lemma essInf_eq_ciInf (hμ : ∀ a, μ {a} ≠ 0) (hf : BddBelow (Set.range f)) : essInf f μ = ⨅ a, f a := by rw [essInf, ae_eq_top.2 hμ, liminf_top_eq_ciInf hf] variable [MeasurableSingletonClass α] @[simp] lemma essSup_count_eq_ciSup (hf : BddAbove (Set.range f)) : essSup f .count = ⨆ a, f a := essSup_eq_ciSup (by simp) hf @[simp] lemma essInf_count_eq_ciInf (hf : BddBelow (Set.range f)) : essInf f .count = ⨅ a, f a := essInf_eq_ciInf (by simp) hf @[simp] lemma essSup_uniformOn_eq_ciSup [Finite α] (hf : BddAbove (Set.range f)) : essSup f (uniformOn univ) = ⨆ a, f a := essSup_eq_ciSup (by simpa [uniformOn, cond_apply]) hf @[simp] lemma essInf_cond_count_eq_ciInf [Finite α] (hf : BddBelow (Set.range f)) : essInf f (uniformOn univ) = ⨅ a, f a := essInf_eq_ciInf (by simpa [uniformOn, cond_apply]) hf end ConditionallyCompleteLattice section ConditionallyCompleteLinearOrder variable [ConditionallyCompleteLinearOrder β] {x : β} {f : α → β} theorem essSup_eq_sInf {m : MeasurableSpace α} (μ : Measure α) (f : α → β) : essSup f μ = sInf { a | μ { x | a < f x } = 0 } := by dsimp [essSup, limsup, limsSup] simp only [eventually_map, ae_iff, not_le] theorem essInf_eq_sSup {m : MeasurableSpace α} (μ : Measure α) (f : α → β) : essInf f μ = sSup { a | μ { x | f x < a } = 0 } := by dsimp [essInf, liminf, limsInf] simp only [eventually_map, ae_iff, not_le] theorem ae_lt_of_essSup_lt (hx : essSup f μ < x) (hf : IsBoundedUnder (· ≤ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, f y < x := eventually_lt_of_limsup_lt hx hf theorem ae_lt_of_lt_essInf (hx : x < essInf f μ) (hf : IsBoundedUnder (· ≥ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, x < f y := eventually_lt_of_lt_liminf hx hf variable [TopologicalSpace β] [FirstCountableTopology β] [OrderTopology β] theorem ae_le_essSup (hf : IsBoundedUnder (· ≤ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, f y ≤ essSup f μ := eventually_le_limsup hf theorem ae_essInf_le (hf : IsBoundedUnder (· ≥ ·) (ae μ) f := by isBoundedDefault) : ∀ᵐ y ∂μ, essInf f μ ≤ f y := eventually_liminf_le hf theorem meas_essSup_lt (hf : IsBoundedUnder (· ≤ ·) (ae μ) f := by isBoundedDefault) : μ { y | essSup f μ < f y } = 0 := by simp_rw [← not_le] exact ae_le_essSup hf theorem meas_lt_essInf (hf : IsBoundedUnder (· ≥ ·) (ae μ) f := by isBoundedDefault) : μ { y | f y < essInf f μ } = 0 := by simp_rw [← not_le] exact ae_essInf_le hf end ConditionallyCompleteLinearOrder section CompleteLattice variable [CompleteLattice β] @[simp] theorem essSup_measure_zero {m : MeasurableSpace α} {f : α → β} : essSup f (0 : Measure α) = ⊥ := le_bot_iff.mp (sInf_le (by simp)) @[simp] theorem essInf_measure_zero {_ : MeasurableSpace α} {f : α → β} : essInf f (0 : Measure α) = ⊤ := @essSup_measure_zero α βᵒᵈ _ _ _ theorem essSup_mono_ae {f g : α → β} (hfg : f ≤ᵐ[μ] g) : essSup f μ ≤ essSup g μ := limsup_le_limsup hfg theorem essInf_mono_ae {f g : α → β} (hfg : f ≤ᵐ[μ] g) : essInf f μ ≤ essInf g μ := liminf_le_liminf hfg theorem essSup_le_of_ae_le {f : α → β} (c : β) (hf : f ≤ᵐ[μ] fun _ => c) : essSup f μ ≤ c := limsup_le_of_le (by isBoundedDefault) hf theorem le_essInf_of_ae_le {f : α → β} (c : β) (hf : (fun _ => c) ≤ᵐ[μ] f) : c ≤ essInf f μ := @essSup_le_of_ae_le α βᵒᵈ _ _ _ _ c hf theorem essSup_const_bot : essSup (fun _ : α => (⊥ : β)) μ = (⊥ : β) := limsup_const_bot theorem essInf_const_top : essInf (fun _ : α => (⊤ : β)) μ = (⊤ : β) := liminf_const_top theorem OrderIso.essSup_apply {m : MeasurableSpace α} {γ} [CompleteLattice γ] (f : α → β) (μ : Measure α) (g : β ≃o γ) : g (essSup f μ) = essSup (fun x => g (f x)) μ := by refine OrderIso.limsup_apply g ?_ ?_ ?_ ?_ all_goals isBoundedDefault theorem OrderIso.essInf_apply {_ : MeasurableSpace α} {γ} [CompleteLattice γ] (f : α → β) (μ : Measure α) (g : β ≃o γ) : g (essInf f μ) = essInf (fun x => g (f x)) μ := @OrderIso.essSup_apply α βᵒᵈ _ _ γᵒᵈ _ _ _ g.dual theorem essSup_mono_measure {f : α → β} (hμν : ν ≪ μ) : essSup f ν ≤ essSup f μ := by refine limsup_le_limsup_of_le (Measure.ae_le_iff_absolutelyContinuous.mpr hμν) ?_ ?_ all_goals isBoundedDefault theorem essSup_mono_measure' {α : Type*} {β : Type*} {_ : MeasurableSpace α} {μ ν : MeasureTheory.Measure α} [CompleteLattice β] {f : α → β} (hμν : ν ≤ μ) : essSup f ν ≤ essSup f μ := essSup_mono_measure (Measure.absolutelyContinuous_of_le hμν) theorem essInf_antitone_measure {f : α → β} (hμν : μ ≪ ν) : essInf f ν ≤ essInf f μ := by refine liminf_le_liminf_of_le (Measure.ae_le_iff_absolutelyContinuous.mpr hμν) ?_ ?_ all_goals isBoundedDefault lemma essSup_eq_iSup (hμ : ∀ a, μ {a} ≠ 0) (f : α → β) : essSup f μ = ⨆ i, f i := by rw [essSup, ae_eq_top.2 hμ, limsup_top_eq_iSup] lemma essInf_eq_iInf (hμ : ∀ a, μ {a} ≠ 0) (f : α → β) : essInf f μ = ⨅ i, f i := by rw [essInf, ae_eq_top.2 hμ, liminf_top_eq_iInf] @[simp] lemma essSup_count [MeasurableSingletonClass α] (f : α → β) : essSup f .count = ⨆ i, f i := essSup_eq_iSup (by simp) _ @[simp] lemma essInf_count [MeasurableSingletonClass α] (f : α → β) : essInf f .count = ⨅ i, f i := essInf_eq_iInf (by simp) _ section TopologicalSpace variable {γ : Type*} {mγ : MeasurableSpace γ} {f : α → γ} {g : γ → β} theorem essSup_comp_le_essSup_map_measure (hf : AEMeasurable f μ) : essSup (g ∘ f) μ ≤ essSup g (Measure.map f μ) := by refine limsSup_le_limsSup_of_le ?_ rw [← Filter.map_map] exact Filter.map_mono (Measure.tendsto_ae_map hf) theorem MeasurableEmbedding.essSup_map_measure (hf : MeasurableEmbedding f) : essSup g (Measure.map f μ) = essSup (g ∘ f) μ := by refine le_antisymm ?_ (essSup_comp_le_essSup_map_measure hf.measurable.aemeasurable) refine limsSup_le_limsSup (by isBoundedDefault) (by isBoundedDefault) (fun c h_le => ?_) rw [eventually_map] at h_le ⊢ exact hf.ae_map_iff.mpr h_le variable [MeasurableSpace β] [TopologicalSpace β] [SecondCountableTopology β] [OrderClosedTopology β] [OpensMeasurableSpace β] theorem essSup_map_measure_of_measurable (hg : Measurable g) (hf : AEMeasurable f μ) : essSup g (Measure.map f μ) = essSup (g ∘ f) μ := by refine le_antisymm ?_ (essSup_comp_le_essSup_map_measure hf) refine limsSup_le_limsSup (by isBoundedDefault) (by isBoundedDefault) (fun c h_le => ?_) rw [eventually_map] at h_le ⊢ rw [ae_map_iff hf (measurableSet_le hg measurable_const)] exact h_le theorem essSup_map_measure (hg : AEMeasurable g (Measure.map f μ)) (hf : AEMeasurable f μ) : essSup g (Measure.map f μ) = essSup (g ∘ f) μ := by rw [essSup_congr_ae hg.ae_eq_mk, essSup_map_measure_of_measurable hg.measurable_mk hf] refine essSup_congr_ae ?_ have h_eq := ae_of_ae_map hf hg.ae_eq_mk rw [← EventuallyEq] at h_eq exact h_eq.symm end TopologicalSpace end CompleteLattice namespace ENNReal variable {f : α → ℝ≥0∞} lemma essSup_piecewise {s : Set α} [DecidablePred (· ∈ s)] {g} (hs : MeasurableSet s) : essSup (s.piecewise f g) μ = max (essSup f (μ.restrict s)) (essSup g (μ.restrict sᶜ)) := by simp only [essSup, limsup_piecewise, blimsup_eq_limsup, ae_restrict_eq, hs, hs.compl]; rfl theorem essSup_indicator_eq_essSup_restrict {s : Set α} {f : α → ℝ≥0∞} (hs : MeasurableSet s) : essSup (s.indicator f) μ = essSup f (μ.restrict s) := by classical simp only [← piecewise_eq_indicator, essSup_piecewise hs, max_eq_left_iff] exact limsup_const_bot.trans_le (zero_le _) theorem ae_le_essSup (f : α → ℝ≥0∞) : ∀ᵐ y ∂μ, f y ≤ essSup f μ := eventually_le_limsup f @[simp] theorem essSup_eq_zero_iff : essSup f μ = 0 ↔ f =ᵐ[μ] 0 := limsup_eq_zero_iff theorem essSup_const_mul {a : ℝ≥0∞} : essSup (fun x : α => a * f x) μ = a * essSup f μ := limsup_const_mul theorem essSup_mul_le (f g : α → ℝ≥0∞) : essSup (f * g) μ ≤ essSup f μ * essSup g μ := limsup_mul_le f g theorem essSup_add_le (f g : α → ℝ≥0∞) : essSup (f + g) μ ≤ essSup f μ + essSup g μ := limsup_add_le f g theorem essSup_liminf_le {ι} [Countable ι] [Preorder ι] (f : ι → α → ℝ≥0∞) : essSup (fun x => atTop.liminf fun n => f n x) μ ≤ atTop.liminf fun n => essSup (fun x => f n x) μ := by simp_rw [essSup] exact ENNReal.limsup_liminf_le_liminf_limsup fun a b => f b a theorem coe_essSup {f : α → ℝ≥0} (hf : IsBoundedUnder (· ≤ ·) (ae μ) f) : ((essSup f μ : ℝ≥0) : ℝ≥0∞) = essSup (fun x => (f x : ℝ≥0∞)) μ := (ENNReal.coe_sInf <| hf).trans <| eq_of_forall_le_iff fun r => by simp [essSup, limsup, limsSup, eventually_map, ENNReal.forall_ennreal]; rfl lemma essSup_restrict_eq_of_support_subset {s : Set α} {f : α → ℝ≥0∞} (hsf : f.support ⊆ s) : essSup f (μ.restrict s) = essSup f μ := by apply le_antisymm (essSup_mono_measure' Measure.restrict_le_self) apply le_of_forall_lt (fun c hc ↦ ?_) obtain ⟨d, cd, hd⟩ : ∃ d, c < d ∧ d < essSup f μ := exists_between hc let t := {x | d < f x} have A : 0 < (μ.restrict t) t := by simp only [Measure.restrict_apply_self] rw [essSup_eq_sInf] at hd have : d ∉ {a | μ {x | a < f x} = 0} := notMem_of_lt_csInf hd (OrderBot.bddBelow _) exact bot_lt_iff_ne_bot.2 this have B : 0 < (μ.restrict s) t := by have : μ.restrict t ≤ μ.restrict s := by apply Measure.restrict_mono _ le_rfl apply subset_trans _ hsf intro x (hx : d < f x) exact (lt_of_le_of_lt bot_le hx).ne' exact lt_of_lt_of_le A (this _) apply cd.trans_le rw [essSup_eq_sInf] apply le_sInf (fun b hb ↦ ?_) contrapose! hb exact ne_of_gt (B.trans_le (measure_mono (fun x hx ↦ hb.trans hx))) end ENNReal
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConvergenceInMeasure.lean
import Mathlib.MeasureTheory.Function.Egorov import Mathlib.MeasureTheory.Function.LpSpace.Complete /-! # Convergence in measure We define convergence in measure which is one of the many notions of convergence in probability. A sequence of functions `f` is said to converge in measure to some function `g` if for all `ε > 0`, the measure of the set `{x | ε ≤ edist (f i x) (g x)}` tends to 0 as `i` converges along some given filter `l`. Convergence in measure is most notably used in the formulation of the weak law of large numbers and is also useful in theorems such as the Vitali convergence theorem. This file provides some basic lemmas for working with convergence in measure and establishes some relations between convergence in measure and other notions of convergence. ## Main definitions * `MeasureTheory.TendstoInMeasure (μ : Measure α) (f : ι → α → E) (g : α → E)`: `f` converges in `μ`-measure to `g`. ## Main results * `MeasureTheory.tendstoInMeasure_of_tendsto_ae`: convergence almost everywhere in a finite measure space implies convergence in measure. * `MeasureTheory.TendstoInMeasure.exists_seq_tendsto_ae`: if `f` is a sequence of functions which converges in measure to `g`, then `f` has a subsequence which convergence almost everywhere to `g`. * `MeasureTheory.exists_seq_tendstoInMeasure_atTop_iff`: for a sequence of functions `f`, convergence in measure is equivalent to the fact that every subsequence has another subsequence that converges almost surely. * `MeasureTheory.tendstoInMeasure_of_tendsto_eLpNorm`: convergence in Lp implies convergence in measure. -/ open TopologicalSpace Filter open scoped NNReal ENNReal MeasureTheory Topology namespace MeasureTheory variable {α ι κ E : Type*} {m : MeasurableSpace α} {μ : Measure α} /-- A sequence of functions `f` is said to converge in measure to some function `g` if for all `ε > 0`, the measure of the set `{x | ε ≤ dist (f i x) (g x)}` tends to 0 as `i` converges along some given filter `l`. -/ def TendstoInMeasure [EDist E] {_ : MeasurableSpace α} (μ : Measure α) (f : ι → α → E) (l : Filter ι) (g : α → E) : Prop := ∀ ε, 0 < ε → Tendsto (fun i => μ { x | ε ≤ edist (f i x) (g x) }) l (𝓝 0) lemma tendstoInMeasure_of_ne_top [EDist E] {f : ι → α → E} {l : Filter ι} {g : α → E} (h : ∀ ε, 0 < ε → ε ≠ ∞ → Tendsto (fun i => μ { x | ε ≤ edist (f i x) (g x) }) l (𝓝 0)) : TendstoInMeasure μ f l g := by intro ε hε by_cases hε_top : ε = ∞ · have h1 : Tendsto (fun n ↦ μ {ω | 1 ≤ edist (f n ω) (g ω)}) l (𝓝 0) := h 1 (by simp) (by simp) refine tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds h1 (fun _ ↦ zero_le') ?_ intro n simp only [hε_top] gcongr simp · exact h ε hε hε_top theorem tendstoInMeasure_iff_enorm [SeminormedAddCommGroup E] {l : Filter ι} {f : ι → α → E} {g : α → E} : TendstoInMeasure μ f l g ↔ ∀ ε, 0 < ε → ε ≠ ∞ → Tendsto (fun i => μ { x | ε ≤ ‖f i x - g x‖ₑ }) l (𝓝 0) := by simp_rw [← edist_eq_enorm_sub] exact ⟨fun h ε hε hε_top ↦ h ε hε, tendstoInMeasure_of_ne_top⟩ lemma tendstoInMeasure_iff_dist [PseudoMetricSpace E] {f : ι → α → E} {l : Filter ι} {g : α → E} : TendstoInMeasure μ f l g ↔ ∀ ε, 0 < ε → Tendsto (fun i => μ { x | ε ≤ dist (f i x) (g x) }) l (𝓝 0) := by refine ⟨fun h ε hε ↦ ?_, fun h ↦ ?_⟩ · convert h (ENNReal.ofReal ε) (ENNReal.ofReal_pos.mpr hε) with i a rw [edist_dist, ENNReal.ofReal_le_ofReal_iff (by positivity)] · refine tendstoInMeasure_of_ne_top fun ε hε hε_top ↦ ?_ convert h ε.toReal (ENNReal.toReal_pos hε.ne' hε_top) with i a rw [edist_dist, ENNReal.le_ofReal_iff_toReal_le hε_top (by positivity)] theorem tendstoInMeasure_iff_norm [SeminormedAddCommGroup E] {l : Filter ι} {f : ι → α → E} {g : α → E} : TendstoInMeasure μ f l g ↔ ∀ ε, 0 < ε → Tendsto (fun i => μ { x | ε ≤ ‖f i x - g x‖ }) l (𝓝 0) := by simp_rw [tendstoInMeasure_iff_dist, dist_eq_norm_sub] theorem tendstoInMeasure_iff_tendsto_toNNReal [EDist E] [IsFiniteMeasure μ] {f : ι → α → E} {l : Filter ι} {g : α → E} : TendstoInMeasure μ f l g ↔ ∀ ε, 0 < ε → Tendsto (fun i => (μ { x | ε ≤ edist (f i x) (g x) }).toNNReal) l (𝓝 0) := by have hfin ε i : μ { x | ε ≤ edist (f i x) (g x) } ≠ ⊤ := measure_ne_top μ {x | ε ≤ edist (f i x) (g x)} refine ⟨fun h ε hε ↦ ?_, fun h ε hε ↦ ?_⟩ · have hf : (fun i => (μ { x | ε ≤ edist (f i x) (g x) }).toNNReal) = ENNReal.toNNReal ∘ (fun i ↦ (μ { x | ε ≤ edist (f i x) (g x) })) := rfl rw [hf, ENNReal.tendsto_toNNReal_iff' (hfin ε)] exact h ε hε · rw [← ENNReal.tendsto_toNNReal_iff ENNReal.zero_ne_top (hfin ε)] exact h ε hε lemma TendstoInMeasure.mono [EDist E] {f : ι → α → E} {g : α → E} {u v : Filter ι} (huv : v ≤ u) (hg : TendstoInMeasure μ f u g) : TendstoInMeasure μ f v g := fun ε hε => (hg ε hε).mono_left huv lemma TendstoInMeasure.comp [EDist E] {f : ι → α → E} {g : α → E} {u : Filter ι} {v : Filter κ} {ns : κ → ι} (hg : TendstoInMeasure μ f u g) (hns : Tendsto ns v u) : TendstoInMeasure μ (f ∘ ns) v g := fun ε hε ↦ (hg ε hε).comp hns namespace TendstoInMeasure variable [EDist E] {l : Filter ι} {f f' : ι → α → E} {g g' : α → E} protected theorem congr' (h_left : ∀ᶠ i in l, f i =ᵐ[μ] f' i) (h_right : g =ᵐ[μ] g') (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f' l g' := by intro ε hε suffices (fun i ↦ μ { x | ε ≤ edist (f' i x) (g' x) }) =ᶠ[l] fun i ↦ μ { x | ε ≤ edist (f i x) (g x) } by rw [tendsto_congr' this] exact h_tendsto ε hε filter_upwards [h_left] with i h_ae_eq refine measure_congr ?_ filter_upwards [h_ae_eq, h_right] with x hxf hxg rw [eq_iff_iff] change ε ≤ edist (f' i x) (g' x) ↔ ε ≤ edist (f i x) (g x) rw [hxg, hxf] protected theorem congr (h_left : ∀ i, f i =ᵐ[μ] f' i) (h_right : g =ᵐ[μ] g') (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f' l g' := TendstoInMeasure.congr' (Eventually.of_forall h_left) h_right h_tendsto theorem congr_left (h : ∀ i, f i =ᵐ[μ] f' i) (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f' l g := h_tendsto.congr h EventuallyEq.rfl theorem congr_right (h : g =ᵐ[μ] g') (h_tendsto : TendstoInMeasure μ f l g) : TendstoInMeasure μ f l g' := h_tendsto.congr (fun _ => EventuallyEq.rfl) h end TendstoInMeasure section ExistsSeqTendstoAe variable [PseudoEMetricSpace E] variable {f : ℕ → α → E} {g : α → E} theorem tendstoInMeasure_of_tendsto_ae_of_measurable_edist [IsFiniteMeasure μ] (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : TendstoInMeasure μ f atTop g := by refine fun ε hε => ENNReal.tendsto_atTop_zero.mpr fun δ hδ => ?_ by_cases hδi : δ = ∞ · simp only [hδi, imp_true_iff, le_top, exists_const] lift δ to ℝ≥0 using hδi rw [gt_iff_lt, ENNReal.coe_pos, ← NNReal.coe_pos] at hδ obtain ⟨t, _, ht, hunif⟩ := tendstoUniformlyOn_of_ae_tendsto_of_measurable_edist' hf hfg hδ rw [ENNReal.ofReal_coe_nnreal] at ht rw [EMetric.tendstoUniformlyOn_iff] at hunif obtain ⟨N, hN⟩ := eventually_atTop.1 (hunif ε hε) refine ⟨N, fun n hn => ?_⟩ suffices { x : α | ε ≤ edist (f n x) (g x) } ⊆ t from (measure_mono this).trans ht rw [← Set.compl_subset_compl] intro x hx rw [Set.mem_compl_iff, Set.notMem_setOf_iff, edist_comm, not_le] exact hN n hn x hx /-- Convergence a.e. implies convergence in measure in a finite measure space. -/ theorem tendstoInMeasure_of_tendsto_ae [IsFiniteMeasure μ] (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) : TendstoInMeasure μ f atTop g := by have hg : AEStronglyMeasurable g μ := aestronglyMeasurable_of_tendsto_ae _ hf hfg refine TendstoInMeasure.congr (fun i => (hf i).ae_eq_mk.symm) hg.ae_eq_mk.symm ?_ refine tendstoInMeasure_of_tendsto_ae_of_measurable_edist (fun n ↦ ((hf n).stronglyMeasurable_mk.edist hg.stronglyMeasurable_mk).measurable) ?_ have hf_eq_ae : ∀ᵐ x ∂μ, ∀ n, (hf n).mk (f n) x = f n x := ae_all_iff.mpr fun n => (hf n).ae_eq_mk.symm filter_upwards [hf_eq_ae, hg.ae_eq_mk, hfg] with x hxf hxg hxfg rw [← hxg, funext fun n => hxf n] exact hxfg namespace ExistsSeqTendstoAe theorem exists_nat_measure_lt_two_inv (hfg : TendstoInMeasure μ f atTop g) (n : ℕ) : ∃ N, ∀ m ≥ N, μ { x | (2 : ℝ≥0∞)⁻¹ ^ n ≤ edist (f m x) (g x) } ≤ (2⁻¹ : ℝ≥0∞) ^ n := by specialize hfg ((2⁻¹ : ℝ≥0∞) ^ n) (ENNReal.pow_pos (by simp) _) rw [ENNReal.tendsto_atTop_zero] at hfg exact hfg ((2 : ℝ≥0∞)⁻¹ ^ n) (pos_iff_ne_zero.mpr <| pow_ne_zero _ <| by simp) /-- Given a sequence of functions `f` which converges in measure to `g`, `seqTendstoAeSeqAux` is a sequence such that `∀ m ≥ seqTendstoAeSeqAux n, μ {x | 2⁻¹ ^ n ≤ dist (f m x) (g x)} ≤ 2⁻¹ ^ n`. -/ noncomputable def seqTendstoAeSeqAux (hfg : TendstoInMeasure μ f atTop g) (n : ℕ) := Classical.choose (exists_nat_measure_lt_two_inv hfg n) /-- Transformation of `seqTendstoAeSeqAux` to makes sure it is strictly monotone. -/ noncomputable def seqTendstoAeSeq (hfg : TendstoInMeasure μ f atTop g) : ℕ → ℕ | 0 => seqTendstoAeSeqAux hfg 0 | n + 1 => max (seqTendstoAeSeqAux hfg (n + 1)) (seqTendstoAeSeq hfg n + 1) theorem seqTendstoAeSeq_succ (hfg : TendstoInMeasure μ f atTop g) {n : ℕ} : seqTendstoAeSeq hfg (n + 1) = max (seqTendstoAeSeqAux hfg (n + 1)) (seqTendstoAeSeq hfg n + 1) := by rw [seqTendstoAeSeq] theorem seqTendstoAeSeq_spec (hfg : TendstoInMeasure μ f atTop g) (n k : ℕ) (hn : seqTendstoAeSeq hfg n ≤ k) : μ { x | (2 : ℝ≥0∞)⁻¹ ^ n ≤ edist (f k x) (g x) } ≤ (2 : ℝ≥0∞)⁻¹ ^ n := by cases n · exact Classical.choose_spec (exists_nat_measure_lt_two_inv hfg 0) k hn · exact Classical.choose_spec (exists_nat_measure_lt_two_inv hfg _) _ (le_trans (le_max_left _ _) hn) theorem seqTendstoAeSeq_strictMono (hfg : TendstoInMeasure μ f atTop g) : StrictMono (seqTendstoAeSeq hfg) := by refine strictMono_nat_of_lt_succ fun n => ?_ rw [seqTendstoAeSeq_succ] exact lt_of_lt_of_le (lt_add_one <| seqTendstoAeSeq hfg n) (le_max_right _ _) end ExistsSeqTendstoAe /-- If `f` is a sequence of functions which converges in measure to `g`, then there exists a subsequence of `f` which converges a.e. to `g`. -/ theorem TendstoInMeasure.exists_seq_tendsto_ae (hfg : TendstoInMeasure μ f atTop g) : ∃ ns : ℕ → ℕ, StrictMono ns ∧ ∀ᵐ x ∂μ, Tendsto (fun i => f (ns i) x) atTop (𝓝 (g x)) := by /- Since `f` tends to `g` in measure, it has a subsequence `k ↦ f (ns k)` such that `μ {|f (ns k) - g| ≥ 2⁻ᵏ} ≤ 2⁻ᵏ` for all `k`. Defining `s := ⋂ k, ⋃ i ≥ k, {|f (ns k) - g| ≥ 2⁻ᵏ}`, we see that `μ s = 0` by the first Borel-Cantelli lemma. On the other hand, as `s` is precisely the set for which `f (ns k)` doesn't converge to `g`, `f (ns k)` converges almost everywhere to `g` as required. -/ have h_lt_ε_real (ε : ℝ≥0∞) (hε : 0 < ε) : ∃ k : ℕ, 2 * (2 : ℝ≥0∞)⁻¹ ^ k < ε := by obtain ⟨k, h_k⟩ : ∃ k : ℕ, (2 : ℝ≥0∞)⁻¹ ^ k < ε := ENNReal.exists_inv_two_pow_lt hε.ne' refine ⟨k + 1, lt_of_eq_of_lt ?_ h_k⟩ rw [pow_succ', ← mul_assoc, ENNReal.mul_inv_cancel, one_mul] · positivity · simp set ns := ExistsSeqTendstoAe.seqTendstoAeSeq hfg use ns let S := fun k => { x | (2 : ℝ≥0∞)⁻¹ ^ k ≤ edist (f (ns k) x) (g x) } have hμS_le : ∀ k, μ (S k) ≤ (2 : ℝ≥0∞)⁻¹ ^ k := fun k => ExistsSeqTendstoAe.seqTendstoAeSeq_spec hfg k (ns k) le_rfl set s := Filter.atTop.limsup S with hs have hμs : μ s = 0 := by refine measure_limsup_atTop_eq_zero (ne_top_of_le_ne_top ?_ (ENNReal.tsum_le_tsum hμS_le)) simpa only [ENNReal.tsum_geometric, ENNReal.one_sub_inv_two, inv_inv] using ENNReal.ofNat_ne_top have h_tendsto : ∀ x ∈ sᶜ, Tendsto (fun i => f (ns i) x) atTop (𝓝 (g x)) := by refine fun x hx => EMetric.tendsto_atTop.mpr fun ε hε => ?_ rw [hs, limsup_eq_iInf_iSup_of_nat] at hx simp only [S, Set.iSup_eq_iUnion, Set.iInf_eq_iInter, Set.compl_iInter, Set.compl_iUnion, Set.mem_iUnion, Set.mem_iInter, Set.mem_compl_iff, Set.mem_setOf_eq, not_le] at hx obtain ⟨N, hNx⟩ := hx obtain ⟨k, hk_lt_ε⟩ := h_lt_ε_real ε hε refine ⟨max N (k - 1), fun n hn_ge => lt_of_le_of_lt ?_ hk_lt_ε⟩ specialize hNx n ((le_max_left _ _).trans hn_ge) have h_inv_n_le_k : (2 : ℝ≥0∞)⁻¹ ^ n ≤ 2 * (2 : ℝ≥0∞)⁻¹ ^ k := by nth_rw 2 [← pow_one (2 : ℝ≥0∞)] rw [mul_comm, ← ENNReal.inv_pow, ← ENNReal.inv_pow, ENNReal.inv_le_iff_le_mul, ← mul_assoc, mul_comm (_ ^ n), mul_assoc, ← ENNReal.inv_le_iff_le_mul, inv_inv, ← pow_add] · gcongr · simp · omega all_goals simp exact le_trans hNx.le h_inv_n_le_k rw [ae_iff] refine ⟨ExistsSeqTendstoAe.seqTendstoAeSeq_strictMono hfg, measure_mono_null (fun x => ?_) hμs⟩ rw [Set.mem_setOf_eq, ← @Classical.not_not (x ∈ s), not_imp_not] exact h_tendsto x theorem TendstoInMeasure.exists_seq_tendstoInMeasure_atTop {u : Filter ι} [NeBot u] [IsCountablyGenerated u] {f : ι → α → E} {g : α → E} (hfg : TendstoInMeasure μ f u g) : ∃ ns : ℕ → ι, Tendsto ns atTop u ∧ TendstoInMeasure μ (fun n => f (ns n)) atTop g := by obtain ⟨ns, h_tendsto_ns⟩ : ∃ ns : ℕ → ι, Tendsto ns atTop u := exists_seq_tendsto u exact ⟨ns, h_tendsto_ns, fun ε hε => (hfg ε hε).comp h_tendsto_ns⟩ theorem TendstoInMeasure.exists_seq_tendsto_ae' {u : Filter ι} [NeBot u] [IsCountablyGenerated u] {f : ι → α → E} {g : α → E} (hfg : TendstoInMeasure μ f u g) : ∃ ns : ℕ → ι, Tendsto ns atTop u ∧ ∀ᵐ x ∂μ, Tendsto (fun i => f (ns i) x) atTop (𝓝 (g x)) := by obtain ⟨ms, hms1, hms2⟩ := hfg.exists_seq_tendstoInMeasure_atTop obtain ⟨ns, hns1, hns2⟩ := hms2.exists_seq_tendsto_ae exact ⟨ms ∘ ns, hms1.comp hns1.tendsto_atTop, hns2⟩ /-- `TendstoInMeasure` is equivalent to every subsequence having another subsequence which converges almost surely. -/ theorem exists_seq_tendstoInMeasure_atTop_iff [IsFiniteMeasure μ] {f : ℕ → α → E} (hf : ∀ (n : ℕ), AEStronglyMeasurable (f n) μ) {g : α → E} : TendstoInMeasure μ f atTop g ↔ ∀ ns : ℕ → ℕ, StrictMono ns → ∃ ns' : ℕ → ℕ, StrictMono ns' ∧ ∀ᵐ (ω : α) ∂μ, Tendsto (fun i ↦ f (ns (ns' i)) ω) atTop (𝓝 (g ω)) := by refine ⟨fun hfg _ hns ↦ (hfg.comp hns.tendsto_atTop).exists_seq_tendsto_ae, not_imp_not.mp (fun h1 ↦ ?_)⟩ rw [tendstoInMeasure_iff_tendsto_toNNReal] at h1 push_neg at * obtain ⟨ε, hε, h2⟩ := h1 obtain ⟨δ, ns, hδ, hns, h3⟩ : ∃ (δ : ℝ≥0) (ns : ℕ → ℕ), 0 < δ ∧ StrictMono ns ∧ ∀ n, δ ≤ (μ {x | ε ≤ edist (f (ns n) x) (g x)}).toNNReal := by obtain ⟨s, hs, h4⟩ := not_tendsto_iff_exists_frequently_notMem.1 h2 obtain ⟨δ, hδ, h5⟩ := NNReal.nhds_zero_basis.mem_iff.1 hs obtain ⟨ns, hns, h6⟩ := extraction_of_frequently_atTop h4 exact ⟨δ, ns, hδ, hns, fun n ↦ Set.notMem_Iio.1 (Set.notMem_subset h5 (h6 n))⟩ refine ⟨ns, hns, fun ns' _ ↦ ?_⟩ by_contra h6 have h7 := tendstoInMeasure_iff_tendsto_toNNReal.mp <| tendstoInMeasure_of_tendsto_ae (fun n ↦ hf _) h6 exact lt_irrefl _ (lt_of_le_of_lt (ge_of_tendsto' (h7 ε hε) (fun n ↦ h3 _)) hδ) end ExistsSeqTendstoAe section TendstoInMeasureUnique /-- The limit in measure is ae unique. -/ theorem tendstoInMeasure_ae_unique [EMetricSpace E] {g h : α → E} {f : ι → α → E} {u : Filter ι} [NeBot u] [IsCountablyGenerated u] (hg : TendstoInMeasure μ f u g) (hh : TendstoInMeasure μ f u h) : g =ᵐ[μ] h := by obtain ⟨ns, h1, h1'⟩ := hg.exists_seq_tendsto_ae' obtain ⟨ns', h2, h2'⟩ := (hh.comp h1).exists_seq_tendsto_ae' filter_upwards [h1', h2'] with ω hg1 hh1 exact tendsto_nhds_unique (hg1.comp h2) hh1 end TendstoInMeasureUnique section AEMeasurableOf variable [MeasurableSpace E] [NormedAddCommGroup E] [BorelSpace E] theorem TendstoInMeasure.aemeasurable {u : Filter ι} [NeBot u] [IsCountablyGenerated u] {f : ι → α → E} {g : α → E} (hf : ∀ n, AEMeasurable (f n) μ) (h_tendsto : TendstoInMeasure μ f u g) : AEMeasurable g μ := by obtain ⟨ns, -, hns⟩ := h_tendsto.exists_seq_tendsto_ae' exact aemeasurable_of_tendsto_metrizable_ae atTop (fun n => hf (ns n)) hns end AEMeasurableOf section TendstoInMeasureOf variable [NormedAddCommGroup E] {p : ℝ≥0∞} variable {f : ι → α → E} {g : α → E} /-- This lemma is superseded by `MeasureTheory.tendstoInMeasure_of_tendsto_eLpNorm` where we allow `p = ∞` and only require `AEStronglyMeasurable`. -/ theorem tendstoInMeasure_of_tendsto_eLpNorm_of_stronglyMeasurable (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) {l : Filter ι} (hfg : Tendsto (fun n => eLpNorm (f n - g) p μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by refine tendstoInMeasure_of_ne_top fun ε hε hε_top ↦ ?_ replace hfg := ENNReal.Tendsto.const_mul (a := 1 / ε ^ p.toReal) (Tendsto.ennrpow_const p.toReal hfg) (Or.inr <| by simp [hε.ne']) simp only [mul_zero, ENNReal.zero_rpow_of_pos (ENNReal.toReal_pos hp_ne_zero hp_ne_top)] at hfg rw [ENNReal.tendsto_nhds_zero] at hfg ⊢ intro δ hδ refine (hfg δ hδ).mono fun n hn => ?_ refine le_trans ?_ hn rw [one_div, ← ENNReal.inv_mul_le_iff, inv_inv] · convert mul_meas_ge_le_pow_eLpNorm' μ hp_ne_zero hp_ne_top ((hf n).sub hg).aestronglyMeasurable ε using 6 simp [edist_eq_enorm_sub] · simp [hε_top] · simp [hε.ne'] /-- This lemma is superseded by `MeasureTheory.tendstoInMeasure_of_tendsto_eLpNorm` where we allow `p = ∞`. -/ theorem tendstoInMeasure_of_tendsto_eLpNorm_of_ne_top (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hg : AEStronglyMeasurable g μ) {l : Filter ι} (hfg : Tendsto (fun n => eLpNorm (f n - g) p μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by refine TendstoInMeasure.congr (fun i => (hf i).ae_eq_mk.symm) hg.ae_eq_mk.symm ?_ refine tendstoInMeasure_of_tendsto_eLpNorm_of_stronglyMeasurable hp_ne_zero hp_ne_top (fun i => (hf i).stronglyMeasurable_mk) hg.stronglyMeasurable_mk ?_ have : (fun n => eLpNorm ((hf n).mk (f n) - hg.mk g) p μ) = fun n => eLpNorm (f n - g) p μ := by ext1 n; refine eLpNorm_congr_ae (EventuallyEq.sub (hf n).ae_eq_mk.symm hg.ae_eq_mk.symm) rw [this] exact hfg /-- See also `MeasureTheory.tendstoInMeasure_of_tendsto_eLpNorm` which work for general Lp-convergence for all `p ≠ 0`. -/ theorem tendstoInMeasure_of_tendsto_eLpNorm_top {E} [NormedAddCommGroup E] {f : ι → α → E} {g : α → E} {l : Filter ι} (hfg : Tendsto (fun n => eLpNorm (f n - g) ∞ μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by refine tendstoInMeasure_of_ne_top fun δ hδ hδ_top ↦ ?_ simp only [eLpNorm_exponent_top, eLpNormEssSup] at hfg rw [ENNReal.tendsto_nhds_zero] at hfg ⊢ intro ε hε specialize hfg (δ / 2) (ENNReal.div_pos_iff.2 ⟨hδ.ne', ENNReal.ofNat_ne_top⟩) refine hfg.mono fun n hn => ?_ simp only [Pi.sub_apply] at * have : essSup (fun x : α => ‖f n x - g x‖ₑ) μ < δ := hn.trans_lt (ENNReal.half_lt_self hδ.ne' hδ_top) refine ((le_of_eq ?_).trans (ae_lt_of_essSup_lt this).le).trans hε.le congr with x simp [edist_eq_enorm_sub] /-- Convergence in Lp implies convergence in measure. -/ theorem tendstoInMeasure_of_tendsto_eLpNorm {l : Filter ι} (hp_ne_zero : p ≠ 0) (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hg : AEStronglyMeasurable g μ) (hfg : Tendsto (fun n => eLpNorm (f n - g) p μ) l (𝓝 0)) : TendstoInMeasure μ f l g := by by_cases hp_ne_top : p = ∞ · subst hp_ne_top exact tendstoInMeasure_of_tendsto_eLpNorm_top hfg · exact tendstoInMeasure_of_tendsto_eLpNorm_of_ne_top hp_ne_zero hp_ne_top hf hg hfg /-- Convergence in Lp implies convergence in measure. -/ theorem tendstoInMeasure_of_tendsto_Lp [hp : Fact (1 ≤ p)] {f : ι → Lp E p μ} {g : Lp E p μ} {l : Filter ι} (hfg : Tendsto f l (𝓝 g)) : TendstoInMeasure μ (fun n => f n) l g := tendstoInMeasure_of_tendsto_eLpNorm (zero_lt_one.trans_le hp.elim).ne.symm (fun _ => Lp.aestronglyMeasurable _) (Lp.aestronglyMeasurable _) ((Lp.tendsto_Lp_iff_tendsto_eLpNorm' _ _).mp hfg) end TendstoInMeasureOf end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/AbsolutelyContinuous.lean
import Mathlib.Analysis.BoundedVariation import Mathlib.Order.SuccPred.IntervalSucc /-! # Absolutely Continuous Functions This file defines absolutely continuous functions on a closed interval `uIcc a b` and proves some basic properties about absolutely continuous functions. A function `f` is *absolutely continuous* on `uIcc a b` if for any `ε > 0`, there is `δ > 0` such that for any finite disjoint collection of intervals `uIoc (a i) (b i)` for `i < n` where `a i`, `b i` are all in `uIcc a b` for `i < n`, if `∑ i ∈ range n, dist (a i) (b i) < δ`, then `∑ i ∈ range n, dist (f (a i)) (f (b i)) < ε`. We give a filter version of the definition of absolutely continuous functions in `AbsolutelyContinuousOnInterval` based on `AbsolutelyContinuousOnInterval.totalLengthFilter` and `AbsolutelyContinuousOnInterval.disjWithin` and prove its equivalence with the `ε`-`δ` definition in `absolutelyContinuousOnInterval_iff`. We use the filter version to prove that absolutely continuous functions are closed under * addition - `AbsolutelyContinuousOnInterval.fun_add`, `AbsolutelyContinuousOnInterval.add`; * negation - `AbsolutelyContinuousOnInterval.fun_neg`, `AbsolutelyContinuousOnInterval.neg`; * subtraction - `AbsolutelyContinuousOnInterval.fun_sub`, `AbsolutelyContinuousOnInterval.sub`; * scalar multiplication - `AbsolutelyContinuousOnInterval.const_smul`, `AbsolutelyContinuousOnInterval.const_mul`; * multiplication - `AbsolutelyContinuousOnInterval.fun_smul`, `AbsolutelyContinuousOnInterval.smul`, `AbsolutelyContinuousOnInterval.fun_mul`, `AbsolutelyContinuousOnInterval.mul`; and that absolutely continuous implies uniform continuous in `AbsolutelyContinuousOnInterval.uniformlyContinuousOn` We use the `ε`-`δ` definition to prove that * Lipschitz continuous functions are absolutely continuous - `LipschitzOnWith.absolutelyContinuousOnInterval`; * absolutely continuous functions have bounded variation - `AbsolutelyContinuousOnInterval.boundedVariationOn`. We conclude that * absolutely continuous functions are a.e. differentiable - `AbsolutelyContinuousOnInterval.ae_differentiableAt`. ## Tags absolutely continuous -/ variable {X F : Type*} [PseudoMetricSpace X] [SeminormedAddCommGroup F] open Set Filter Function open scoped Topology NNReal namespace AbsolutelyContinuousOnInterval /-- The filter on the collection of all the finite sequences of `uIoc` intervals induced by the function that maps the finite sequence of the intervals to the total length of the intervals. Details: 1. Technically the filter is on `ℕ × (ℕ → X × X)`. A finite sequence `uIoc (a i) (b i)`, `i < n` is represented by any `E : ℕ × (ℕ → X × X)` which satisfies `E.1 = n` and `E.2 i = (a i, b i)` for `i < n`. Its total length is `∑ i ∈ Finset.range n, dist (a i) (b i)`. 2. For a sequence `G : ℕ → ℕ × (ℕ → X × X)`, `G` convergence along `totalLengthFilter` means that the total length of `G j`, i.e., `∑ i ∈ Finset.range (G j).1, dist ((G j).2 i).1 ((G j).2 i).2)`, tends to `0` as `j` tends to infinity. -/ def totalLengthFilter : Filter (ℕ × (ℕ → X × X)) := Filter.comap (fun E ↦ ∑ i ∈ Finset.range E.1, dist (E.2 i).1 (E.2 i).2) (𝓝 0) lemma hasBasis_totalLengthFilter : totalLengthFilter.HasBasis (fun (ε : ℝ) => 0 < ε) (fun (ε : ℝ) => {E : ℕ × (ℕ → X × X) | ∑ i ∈ Finset.range E.1, dist (E.2 i).1 (E.2 i).2 < ε}) := by convert Filter.HasBasis.comap (α := ℝ) _ (nhds_basis_Ioo_pos _) using 1 ext ε E simp only [mem_setOf_eq, zero_sub, zero_add, mem_preimage, mem_Ioo, iff_and_self] suffices 0 ≤ ∑ i ∈ Finset.range E.1, dist (E.2 i).1 (E.2 i).2 by grind exact Finset.sum_nonneg (fun _ _ ↦ dist_nonneg) /-- The subcollection of all the finite sequences of `uIoc` intervals consisting of `uIoc (a i) (b i)`, `i < n` where `a i`, `b i` are all in `uIcc a b` for `i < n` and `uIoc (a i) (b i)` are mutually disjoint for `i < n`. Technically the finite sequence `uIoc (a i) (b i)`, `i < n` is represented by any `E : ℕ × (ℕ → ℝ × ℝ)` which satisfies `E.1 = n` and `E.2 i = (a i, b i)` for `i < n`. -/ def disjWithin (a b : ℝ) := {E : ℕ × (ℕ → ℝ × ℝ) | (∀ i ∈ Finset.range E.1, (E.2 i).1 ∈ uIcc a b ∧ (E.2 i).2 ∈ uIcc a b) ∧ Set.PairwiseDisjoint (Finset.range E.1) (fun i ↦ uIoc (E.2 i).1 (E.2 i).2)} lemma disjWithin_comm (a b : ℝ) : disjWithin a b = disjWithin b a := by rw [disjWithin, disjWithin, uIcc_comm] lemma disjWithin_mono {a b c d : ℝ} (habcd : uIcc c d ⊆ uIcc a b) : disjWithin c d ⊆ disjWithin a b := by grind [disjWithin] /-- `AbsolutelyContinuousOnInterval f a b`: A function `f` is *absolutely continuous* on `uIcc a b` if the function which (intuitively) maps `uIoc (a i) (b i)`, `i < n` to `∑ i ∈ Finset.range n, dist (f (a i)) (f (b i))` tendsto `𝓝 0` wrt `totalLengthFilter` restricted to `disjWithin a b`. This is equivalent to the traditional `ε`-`δ` definition: for any `ε > 0`, there is `δ > 0` such that for any finite disjoint collection of intervals `uIoc (a i) (b i)` for `i < n` where `a i`, `b i` are all in `uIcc a b` for `i < n`, if `∑ i ∈ range n, dist (a i) (b i) < δ`, then `∑ i ∈ range n, dist (f (a i)) (f (b i)) < ε`. -/ def _root_.AbsolutelyContinuousOnInterval (f : ℝ → X) (a b : ℝ) := Tendsto (fun E ↦ ∑ i ∈ Finset.range E.1, dist (f (E.2 i).1) (f (E.2 i).2)) (totalLengthFilter ⊓ 𝓟 (disjWithin a b)) (𝓝 0) /-- The traditional `ε`-`δ` definition of absolutely continuous: A function `f` is *absolutely continuous* on `uIcc a b` if for any `ε > 0`, there is `δ > 0` such that for any finite disjoint collection of intervals `uIoc (a i) (b i)` for `i < n` where `a i`, `b i` are all in `uIcc a b` for `i < n`, if `∑ i ∈ range n, dist (a i) (b i) < δ`, then `∑ i ∈ range n, dist (f (a i)) (f (b i)) < ε`. -/ theorem _root_.absolutelyContinuousOnInterval_iff (f : ℝ → X) (a b : ℝ) : AbsolutelyContinuousOnInterval f a b ↔ ∀ ε > (0 : ℝ), ∃ δ > (0 : ℝ), ∀ E, E ∈ disjWithin a b → ∑ i ∈ Finset.range E.1, dist (E.2 i).1 (E.2 i).2 < δ → ∑ i ∈ Finset.range E.1, dist (f (E.2 i).1) (f (E.2 i).2) < ε := by simp [AbsolutelyContinuousOnInterval, Metric.tendsto_nhds, Filter.HasBasis.eventually_iff (hasBasis_totalLengthFilter.inf_principal _), imp.swap, abs_of_nonneg (Finset.sum_nonneg (fun _ _ ↦ dist_nonneg))] variable {f g : ℝ → X} {a b c d : ℝ} theorem symm (hf : AbsolutelyContinuousOnInterval f a b) : AbsolutelyContinuousOnInterval f b a := by simp_all [AbsolutelyContinuousOnInterval, disjWithin_comm] theorem mono (hf : AbsolutelyContinuousOnInterval f a b) (habcd : uIcc c d ⊆ uIcc a b) : AbsolutelyContinuousOnInterval f c d := by simp only [AbsolutelyContinuousOnInterval, Tendsto] at * refine le_trans (Filter.map_mono ?_) hf gcongr; exact disjWithin_mono habcd variable {f g : ℝ → F} theorem fun_add (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (fun x ↦ f x + g x) a b := by apply squeeze_zero (fun t ↦ ?_) (fun t ↦ ?_) (by simpa using hf.add hg) · exact Finset.sum_nonneg (fun i hi ↦ by positivity) · rw [← Finset.sum_add_distrib] gcongr exact dist_add_add_le _ _ _ _ theorem add (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (f + g) a b := hf.fun_add hg theorem fun_neg (hf : AbsolutelyContinuousOnInterval f a b) : AbsolutelyContinuousOnInterval (fun x ↦ -(f x)) a b := by apply squeeze_zero (fun t ↦ ?_) (fun t ↦ ?_) (by simpa using hf) · exact Finset.sum_nonneg (fun i hi ↦ by positivity) · simp theorem neg (hf : AbsolutelyContinuousOnInterval f a b) : AbsolutelyContinuousOnInterval (-f) a b := hf.fun_neg theorem fun_sub (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (fun x ↦ f x - g x) a b := by simp_rw [fun x ↦ show f x - g x = f x + (-(g x)) by abel] exact hf.fun_add (hg.fun_neg) theorem sub (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (f - g) a b := hf.fun_sub hg theorem const_smul {M : Type*} [SeminormedRing M] [Module M F] [NormSMulClass M F] (α : M) (hf : AbsolutelyContinuousOnInterval f a b) : AbsolutelyContinuousOnInterval (fun x ↦ α • f x) a b := by apply squeeze_zero (fun t ↦ ?_) (fun t ↦ ?_) (by simpa using hf.const_mul ‖α‖) · exact Finset.sum_nonneg (fun i hi ↦ by positivity) · simp [Finset.mul_sum, dist_smul₀] theorem const_mul {f : ℝ → ℝ} (α : ℝ) (hf : AbsolutelyContinuousOnInterval f a b) : AbsolutelyContinuousOnInterval (fun x ↦ α * f x) a b := hf.const_smul α lemma uniformity_eq_comap_totalLengthFilter : uniformity X = comap (fun x ↦ (1, fun _ ↦ x)) totalLengthFilter := by refine Filter.HasBasis.eq_of_same_basis Metric.uniformity_basis_dist ?_ convert hasBasis_totalLengthFilter.comap _ simp /-- If `f` is absolutely continuous on `uIcc a b`, then `f` is uniformly continuous on `uIcc a b`. -/ theorem uniformlyContinuousOn (hf : AbsolutelyContinuousOnInterval f a b) : UniformContinuousOn f (uIcc a b) := by simp only [UniformContinuousOn, Filter.tendsto_iff_comap, uniformity_eq_comap_totalLengthFilter] simp only [AbsolutelyContinuousOnInterval, Filter.tendsto_iff_comap] at hf convert Filter.comap_mono hf · simp only [comap_inf, comap_principal] congr ext p simp only [disjWithin, Finset.mem_range, preimage_setOf_eq, Nat.lt_one_iff, forall_eq, mem_setOf_eq, mem_prod] simp · simp [totalLengthFilter, comap_comap, Function.comp_def] /-- If `f` is absolutely continuous on `uIcc a b`, then `f` is continuous on `uIcc a b`. -/ theorem continuousOn (hf : AbsolutelyContinuousOnInterval f a b) : ContinuousOn f (uIcc a b) := hf.uniformlyContinuousOn.continuousOn /-- If `f` is absolutely continuous on `uIcc a b`, then `f` is bounded on `uIcc a b`. -/ theorem exists_bound (hf : AbsolutelyContinuousOnInterval f a b) : ∃ (C : ℝ), ∀ x ∈ uIcc a b, ‖f x‖ ≤ C := isCompact_Icc.exists_bound_of_continuousOn (hf.continuousOn) /-- If `f` and `g` are absolutely continuous on `uIcc a b`, then `f • g` is absolutely continuous on `uIcc a b`. -/ theorem fun_smul {M : Type*} [SeminormedRing M] [Module M F] [NormSMulClass M F] {f : ℝ → M} {g : ℝ → F} (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (fun x ↦ f x • g x) a b := by obtain ⟨C, hC⟩ := hf.exists_bound obtain ⟨D, hD⟩ := hg.exists_bound unfold AbsolutelyContinuousOnInterval at hf hg apply squeeze_zero' ?_ ?_ (by simpa using (hg.const_mul C).add (hf.const_mul D)) · exact Filter.Eventually.of_forall <| fun _ ↦ Finset.sum_nonneg (fun i hi ↦ dist_nonneg) rw [eventually_inf_principal] filter_upwards with (n, I) hnI simp only [Finset.mul_sum, ← Finset.sum_add_distrib] gcongr with i hi trans dist (f (I i).1 • g (I i).1) (f (I i).1 • g (I i).2) + dist (f (I i).1 • g (I i).2) (f (I i).2 • g (I i).2) · exact dist_triangle _ _ _ · simp only [disjWithin, mem_setOf_eq] at hnI gcongr · rw [dist_smul₀] gcongr exact hC _ (hnI.left i hi |>.left) · rw [mul_comm] grw [dist_pair_smul] gcongr rw [dist_zero_right] exact hD _ (hnI.left i hi |>.right) /-- If `f` and `g` are absolutely continuous on `uIcc a b`, then `f • g` is absolutely continuous on `uIcc a b`. -/ theorem smul {M : Type*} [SeminormedRing M] [Module M F] [NormSMulClass M F] {f : ℝ → M} {g : ℝ → F} (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (f • g) a b := hf.fun_smul hg /-- If `f` and `g` are absolutely continuous on `uIcc a b`, then `f * g` is absolutely continuous on `uIcc a b`. -/ theorem fun_mul {f g : ℝ → ℝ} (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (fun x ↦ f x * g x) a b := hf.fun_smul hg /-- If `f` and `g` are absolutely continuous on `uIcc a b`, then `f * g` is absolutely continuous on `uIcc a b`. -/ theorem mul {f g : ℝ → ℝ} (hf : AbsolutelyContinuousOnInterval f a b) (hg : AbsolutelyContinuousOnInterval g a b) : AbsolutelyContinuousOnInterval (f * g) a b := hf.fun_mul hg /-- If `f` is Lipschitz on `uIcc a b`, then `f` is absolutely continuous on `uIcc a b`. -/ theorem _root_.LipschitzOnWith.absolutelyContinuousOnInterval {f : ℝ → X} {K : ℝ≥0} (hfK : LipschitzOnWith K f (uIcc a b)) : AbsolutelyContinuousOnInterval f a b := by rw [absolutelyContinuousOnInterval_iff] intro ε hε refine ⟨ε / (K + 1), by positivity, fun (n, I) hnI₁ hnI₂ ↦ ?_⟩ calc _ ≤ ∑ i ∈ Finset.range n, K * dist (I i).1 (I i).2 := by apply Finset.sum_le_sum intro i hi have := hfK (hnI₁.left i hi).left (hnI₁.left i hi).right apply ENNReal.toReal_mono (Ne.symm (not_eq_of_beq_eq_false rfl)) at this rwa [ENNReal.toReal_mul, ← dist_edist, ← dist_edist] at this _ = K * ∑ i ∈ Finset.range n, dist (I i).1 (I i).2 := by symm; exact Finset.mul_sum _ _ _ _ ≤ K * (ε / (K + 1)) := by gcongr _ < (K + 1) * (ε / (K + 1)) := by gcongr; linarith _ = ε := by field /-- If `f` is absolutely continuous on `uIcc a b`, then `f` has bounded variation on `uIcc a b`. -/ theorem boundedVariationOn (hf : AbsolutelyContinuousOnInterval f a b) : BoundedVariationOn f (uIcc a b) := by -- We may assume wlog that `a ≤ b`. wlog hab₀ : a ≤ b generalizing a b · specialize @this b a hf.symm (by linarith) rwa [uIcc_comm] rw [uIcc_of_le hab₀] -- Split the cases `a = b` (which is trivial) and `a < b`. rcases hab₀.eq_or_lt with rfl | hab · simp [BoundedVariationOn] -- Now remains the case `a < b`. -- Use the `ε`-`δ` definition of AC to get a `δ > 0` such that whenever a finite set of disjoint -- intervals `uIoc (a i) (b i)`, `i < n` have total length `< δ` and `a i, b i` are all in -- `[a, b]`, we have `∑ i ∈ range n, dist (f (a i)) (f (b i)) < 1`. rw [absolutelyContinuousOnInterval_iff] at hf obtain ⟨δ, hδ₁, hδ₂⟩ := hf 1 (by linarith) have hab₁ : 0 < b - a := by linarith -- Split `[a, b]` into subintervals `[a + i * δ', a + (i + 1) * δ']` for `i = 0, ..., n`, where -- `a + (n + 1) * δ' = b` and `δ' < δ`. obtain ⟨n, hn⟩ := exists_nat_one_div_lt (div_pos hδ₁ hab₁) set δ' := (b - a) / (n + 1) have hδ₃ : δ' < δ := by dsimp only [δ'] convert mul_lt_mul_of_pos_right hn hab₁ using 1 <;> field have h_mono : Monotone fun (i : ℕ) ↦ a + ↑i * δ' := by apply Monotone.const_add apply Monotone.mul_const Nat.mono_cast simp only [δ'] refine div_nonneg ?_ ?_ <;> linarith -- The variation of `f` on `[a, b]` is the sum of the variations on these subintervals. have v_sum : eVariationOn f (Icc a b) = ∑ i ∈ Finset.range (n + 1), eVariationOn f (Icc (a + i * δ') (a + (i + 1) * δ')) := by convert eVariationOn.sum' f (I := fun i ↦ a + i * δ') h_mono |>.symm · simp · simp only [Nat.cast_add, Nat.cast_one, δ']; field · norm_cast -- The variation of `f` on any subinterval `[x, y]` of `[a, b]` of length `< δ` is `≤ 1`. have v_each (x y : ℝ) (_ : a ≤ x) (_ : x ≤ y) (_ : y < x + δ) (_ : y ≤ b) : eVariationOn f (Icc x y) ≤ 1 := by simp only [eVariationOn, iSup_le_iff] intro p obtain ⟨hp₁, hp₂⟩ := p.2.property -- Focus on a partition `p` of `[x, y]` and show its variation with `f` is `≤ 1`. have vf : ∑ i ∈ Finset.range p.1, dist (f (p.2.val i)) (f (p.2.val (i + 1))) < 1 := by apply hδ₂ (p.1, (fun i ↦ (p.2.val i, p.2.val (i + 1)))) · constructor · have : Icc x y ⊆ uIcc a b := by rw [uIcc_of_le hab₀]; gcongr intro i hi constructor <;> exact this (hp₂ _) · rw [PairwiseDisjoint] convert hp₁.pairwise_disjoint_on_Ioc_succ.set_pairwise (Finset.range p.1) using 3 rw [uIoc_of_le (hp₁ (by omega)), Nat.succ_eq_succ] · suffices p.2.val p.1 - p.2.val 0 < δ by convert this rw [← Finset.sum_range_sub] congr; ext i rw [dist_comm, Real.dist_eq, abs_eq_self.mpr] linarith [@hp₁ i (i + 1) (by omega)] linarith [mem_Icc.mp (hp₂ p.1), mem_Icc.mp (hp₂ 0)] -- Reduce edist in the goal to dist and clear up have veq: (∑ i ∈ Finset.range p.1, edist (f (p.2.val (i + 1))) (f (p.2.val i))).toReal = ∑ i ∈ Finset.range p.1, dist (f (p.2.val i)) (f (p.2.val (i + 1))) := by rw [ENNReal.toReal_sum (by simp [edist_ne_top])] simp_rw [← dist_edist]; congr; ext i; nth_rw 1 [dist_comm] have not_top : ∑ i ∈ Finset.range p.1, edist (f (p.2.val (i + 1))) (f (p.2.val i)) ≠ ⊤ := by simp [edist_ne_top] rw [← ENNReal.ofReal_toReal not_top] convert ENNReal.ofReal_le_ofReal (veq.symm ▸ vf.le) simp -- Reduce to goal that the variation of `f` on each of these subintervals is finite. simp only [BoundedVariationOn, v_sum, ne_eq, ENNReal.sum_eq_top, Finset.mem_range, not_exists, not_and] intro i hi -- Reduce finiteness to `≤ 1`. suffices eVariationOn f (Icc (a + i * δ') (a + (i + 1) * δ')) ≤ 1 from fun hC ↦ by simp [hC] at this -- Verify that `[a + i * δ', a + (i + 1) * δ']` is indeed a subinterval of `[a, b]` apply v_each · convert h_mono (show 0 ≤ i by omega); simp · convert h_mono (show i ≤ i + 1 by omega); norm_cast · rw [add_mul, ← add_assoc]; simpa · convert h_mono (show i + 1 ≤ n + 1 by omega) · norm_cast · simp only [Nat.cast_add, Nat.cast_one, δ']; field /-- If `f` is absolute continuous on `uIcc a b`, then `f'` exists a.e. on `uIcc a b`. -/ theorem ae_differentiableAt {f : ℝ → ℝ} {a b : ℝ} (hf : AbsolutelyContinuousOnInterval f a b) : ∀ᵐ (x : ℝ), x ∈ uIcc a b → DifferentiableAt ℝ f x := hf.boundedVariationOn.ae_differentiableAt_of_mem_uIcc end AbsolutelyContinuousOnInterval
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/L2Space.lean
import Mathlib.Analysis.InnerProductSpace.LinearMap import Mathlib.Analysis.RCLike.Lemmas import Mathlib.MeasureTheory.Function.LpSpace.ContinuousFunctions import Mathlib.MeasureTheory.Function.StronglyMeasurable.Inner import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap /-! # `L^2` space If `E` is an inner product space over `𝕜` (`ℝ` or `ℂ`), then `Lp E 2 μ` (defined in `Mathlib/MeasureTheory/Function/LpSpace.lean`) is also an inner product space, with inner product defined as `inner f g := ∫ a, ⟪f a, g a⟫ ∂μ`. ### Main results * `mem_L1_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product `fun x ↦ ⟪f x, g x⟫` belongs to `Lp 𝕜 1 μ`. * `integrable_inner` : for `f` and `g` in `Lp E 2 μ`, the pointwise inner product `fun x ↦ ⟪f x, g x⟫` is integrable. * `L2.innerProductSpace` : `Lp E 2 μ` is an inner product space. -/ noncomputable section open TopologicalSpace MeasureTheory MeasureTheory.Lp Filter open scoped NNReal ENNReal MeasureTheory InnerProductSpace namespace MeasureTheory section variable {α F : Type*} {m : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup F] theorem MemLp.integrable_sq {f : α → ℝ} (h : MemLp f 2 μ) : Integrable (fun x => f x ^ 2) μ := by simpa [← memLp_one_iff_integrable] using h.norm_rpow two_ne_zero ENNReal.ofNat_ne_top theorem memLp_two_iff_integrable_sq_norm {f : α → F} (hf : AEStronglyMeasurable f μ) : MemLp f 2 μ ↔ Integrable (fun x => ‖f x‖ ^ 2) μ := by rw [← memLp_one_iff_integrable] convert (memLp_norm_rpow_iff hf two_ne_zero ENNReal.ofNat_ne_top).symm · simp · rw [div_eq_mul_inv, ENNReal.mul_inv_cancel two_ne_zero ENNReal.ofNat_ne_top] theorem memLp_two_iff_integrable_sq {f : α → ℝ} (hf : AEStronglyMeasurable f μ) : MemLp f 2 μ ↔ Integrable (fun x => f x ^ 2) μ := by convert memLp_two_iff_integrable_sq_norm hf using 3 simp end section InnerProductSpace variable {α : Type*} {m : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α} variable {E 𝕜 : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => inner 𝕜 x y theorem MemLp.const_inner (c : E) {f : α → E} (hf : MemLp f p μ) : MemLp (fun a => ⟪c, f a⟫) p μ := hf.of_le_mul (AEStronglyMeasurable.inner aestronglyMeasurable_const hf.1) (Eventually.of_forall fun _ => norm_inner_le_norm _ _) theorem MemLp.inner_const {f : α → E} (hf : MemLp f p μ) (c : E) : MemLp (fun a => ⟪f a, c⟫) p μ := hf.of_le_mul (c := ‖c‖) (AEStronglyMeasurable.inner hf.1 aestronglyMeasurable_const) (Eventually.of_forall fun x => by rw [mul_comm]; exact norm_inner_le_norm _ _) variable {f : α → E} @[fun_prop] theorem Integrable.const_inner (c : E) (hf : Integrable f μ) : Integrable (fun x => ⟪c, f x⟫) μ := by rw [← memLp_one_iff_integrable] at hf ⊢; exact hf.const_inner c @[fun_prop] theorem Integrable.inner_const (hf : Integrable f μ) (c : E) : Integrable (fun x => ⟪f x, c⟫) μ := by rw [← memLp_one_iff_integrable] at hf ⊢; exact hf.inner_const c variable [CompleteSpace E] [NormedSpace ℝ E] theorem _root_.integral_inner {f : α → E} (hf : Integrable f μ) (c : E) : ∫ x, ⟪c, f x⟫ ∂μ = ⟪c, ∫ x, f x ∂μ⟫ := ((innerSL 𝕜 c).restrictScalars ℝ).integral_comp_comm hf variable (𝕜) theorem _root_.integral_eq_zero_of_forall_integral_inner_eq_zero (f : α → E) (hf : Integrable f μ) (hf_int : ∀ c : E, ∫ x, ⟪c, f x⟫ ∂μ = 0) : ∫ x, f x ∂μ = 0 := by specialize hf_int (∫ x, f x ∂μ); rwa [integral_inner hf, inner_self_eq_zero] at hf_int end InnerProductSpace namespace L2 variable {α E F 𝕜 : Type*} [RCLike 𝕜] [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [NormedAddCommGroup F] local notation "⟪" x ", " y "⟫" => inner 𝕜 x y theorem eLpNorm_rpow_two_norm_lt_top (f : Lp F 2 μ) : eLpNorm (fun x => ‖f x‖ ^ (2 : ℝ)) 1 μ < ∞ := by have h_two : ENNReal.ofReal (2 : ℝ) = 2 := by simp rw [eLpNorm_norm_rpow f zero_lt_two, one_mul, h_two] exact ENNReal.rpow_lt_top_of_nonneg zero_le_two (Lp.eLpNorm_ne_top f) theorem eLpNorm_inner_lt_top (f g : α →₂[μ] E) : eLpNorm (fun x : α => ⟪f x, g x⟫) 1 μ < ∞ := by have h : ∀ x, ‖⟪f x, g x⟫‖ ≤ ‖‖f x‖ ^ (2 : ℝ) + ‖g x‖ ^ (2 : ℝ)‖ := by intro x rw [← @Nat.cast_two ℝ, Real.rpow_natCast, Real.rpow_natCast] calc ‖⟪f x, g x⟫‖ ≤ ‖f x‖ * ‖g x‖ := norm_inner_le_norm _ _ _ ≤ 2 * ‖f x‖ * ‖g x‖ := (mul_le_mul_of_nonneg_right (le_mul_of_one_le_left (norm_nonneg _) one_le_two) (norm_nonneg _)) -- TODO(kmill): the type ascription is getting around an elaboration error _ ≤ ‖(‖f x‖ ^ 2 + ‖g x‖ ^ 2 : ℝ)‖ := (two_mul_le_add_sq _ _).trans (le_abs_self _) refine (eLpNorm_mono_ae (ae_of_all _ h)).trans_lt ((eLpNorm_add_le ?_ ?_ le_rfl).trans_lt ?_) · exact ((Lp.aestronglyMeasurable f).norm.aemeasurable.pow_const _).aestronglyMeasurable · exact ((Lp.aestronglyMeasurable g).norm.aemeasurable.pow_const _).aestronglyMeasurable rw [ENNReal.add_lt_top] exact ⟨eLpNorm_rpow_two_norm_lt_top f, eLpNorm_rpow_two_norm_lt_top g⟩ section InnerProductSpace open scoped ComplexConjugate instance : Inner 𝕜 (α →₂[μ] E) := ⟨fun f g => ∫ a, ⟪f a, g a⟫ ∂μ⟩ theorem inner_def (f g : α →₂[μ] E) : ⟪f, g⟫ = ∫ a : α, ⟪f a, g a⟫ ∂μ := rfl theorem integral_inner_eq_sq_eLpNorm (f : α →₂[μ] E) : ∫ a, ⟪f a, f a⟫ ∂μ = ENNReal.toReal (∫⁻ a, (‖f a‖₊ : ℝ≥0∞) ^ (2 : ℝ) ∂μ) := by simp_rw [inner_self_eq_norm_sq_to_K] norm_cast rw [integral_eq_lintegral_of_nonneg_ae] rotate_left · exact Filter.Eventually.of_forall fun x => sq_nonneg _ · exact ((Lp.aestronglyMeasurable f).norm.aemeasurable.pow_const _).aestronglyMeasurable congr ext1 x have h_two : (2 : ℝ) = ((2 : ℕ) : ℝ) := by simp rw [← Real.rpow_natCast _ 2, ← h_two, ← ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) zero_le_two, ofReal_norm_eq_enorm] norm_cast private theorem norm_sq_eq_re_inner (f : α →₂[μ] E) : ‖f‖ ^ 2 = RCLike.re ⟪f, f⟫ := by have h_two : (2 : ℝ≥0∞).toReal = 2 := by simp rw [inner_def, integral_inner_eq_sq_eLpNorm, norm_def, ← ENNReal.toReal_pow, RCLike.ofReal_re, ENNReal.toReal_eq_toReal_iff' (ENNReal.pow_ne_top (Lp.eLpNorm_ne_top f)) _] · rw [← ENNReal.rpow_natCast, eLpNorm_eq_eLpNorm' two_ne_zero ENNReal.ofNat_ne_top, eLpNorm', ← ENNReal.rpow_mul, one_div, h_two] simp [enorm_eq_nnnorm] · refine (lintegral_rpow_enorm_lt_top_of_eLpNorm'_lt_top zero_lt_two (ε := E) ?_).ne rw [← h_two, ← eLpNorm_eq_eLpNorm' two_ne_zero ENNReal.ofNat_ne_top] finiteness @[deprecated (since := "2025-04-22")] alias norm_sq_eq_inner' := norm_sq_eq_re_inner theorem mem_L1_inner (f g : α →₂[μ] E) : AEEqFun.mk (fun x => ⟪f x, g x⟫) ((Lp.aestronglyMeasurable f).inner (Lp.aestronglyMeasurable g)) ∈ Lp 𝕜 1 μ := by simp_rw [mem_Lp_iff_eLpNorm_lt_top, eLpNorm_aeeqFun]; exact eLpNorm_inner_lt_top f g theorem integrable_inner (f g : α →₂[μ] E) : Integrable (fun x : α => ⟪f x, g x⟫) μ := (integrable_congr (AEEqFun.coeFn_mk (fun x => ⟪f x, g x⟫) ((Lp.aestronglyMeasurable f).inner (Lp.aestronglyMeasurable g)))).mp (AEEqFun.integrable_iff_mem_L1.mpr (mem_L1_inner f g)) private theorem add_left' (f f' g : α →₂[μ] E) : ⟪f + f', g⟫ = ⟪f, g⟫ + ⟪f', g⟫ := by simp_rw [inner_def, ← integral_add (integrable_inner (𝕜 := 𝕜) f g) (integrable_inner f' g), ← inner_add_left] refine integral_congr_ae ((coeFn_add f f').mono fun x hx => ?_) simp only [hx, Pi.add_apply] private theorem smul_left' (f g : α →₂[μ] E) (r : 𝕜) : ⟪r • f, g⟫ = conj r * ⟪f, g⟫ := by rw [inner_def, inner_def, ← smul_eq_mul, ← integral_smul] refine integral_congr_ae ((coeFn_smul r f).mono fun x hx => ?_) simp only rw [smul_eq_mul, ← inner_smul_left, hx, Pi.smul_apply] instance innerProductSpace : InnerProductSpace 𝕜 (α →₂[μ] E) where norm_sq_eq_re_inner := norm_sq_eq_re_inner conj_inner_symm _ _ := by simp_rw [inner_def, ← integral_conj, inner_conj_symm] add_left := add_left' smul_left := smul_left' end InnerProductSpace section IndicatorConstLp variable (𝕜) {s t : Set α} /-- The inner product in `L2` of the indicator of a set `indicatorConstLp 2 hs hμs c` and `f` is equal to the integral of the inner product over `s`: `∫ x in s, ⟪c, f x⟫ ∂μ`. -/ theorem inner_indicatorConstLp_eq_setIntegral_inner (f : Lp E 2 μ) (hs : MeasurableSet s) (c : E) (hμs : μ s ≠ ∞) : (⟪indicatorConstLp 2 hs hμs c, f⟫ : 𝕜) = ∫ x in s, ⟪c, f x⟫ ∂μ := by rw [inner_def, ← integral_add_compl hs (L2.integrable_inner _ f)] have h_left : (∫ x in s, ⟪(indicatorConstLp 2 hs hμs c) x, f x⟫ ∂μ) = ∫ x in s, ⟪c, f x⟫ ∂μ := by suffices h_ae_eq : ∀ᵐ x ∂μ, x ∈ s → ⟪indicatorConstLp 2 hs hμs c x, f x⟫ = ⟪c, f x⟫ from setIntegral_congr_ae hs h_ae_eq have h_indicator : ∀ᵐ x : α ∂μ, x ∈ s → indicatorConstLp 2 hs hμs c x = c := indicatorConstLp_coeFn_mem refine h_indicator.mono fun x hx hxs => ?_ congr exact hx hxs have h_right : (∫ x in sᶜ, ⟪(indicatorConstLp 2 hs hμs c) x, f x⟫ ∂μ) = 0 := by suffices h_ae_eq : ∀ᵐ x ∂μ, x ∉ s → ⟪indicatorConstLp 2 hs hμs c x, f x⟫ = 0 by simp_rw [← Set.mem_compl_iff] at h_ae_eq suffices h_int_zero : (∫ x in sᶜ, ⟪indicatorConstLp 2 hs hμs c x, f x⟫ ∂μ) = ∫ _ in sᶜ, 0 ∂μ by rw [h_int_zero] simp exact setIntegral_congr_ae hs.compl h_ae_eq have h_indicator : ∀ᵐ x : α ∂μ, x ∉ s → indicatorConstLp 2 hs hμs c x = 0 := indicatorConstLp_coeFn_notMem refine h_indicator.mono fun x hx hxs => ?_ rw [hx hxs] exact inner_zero_left _ rw [h_left, h_right, add_zero] /-- The inner product in `L2` of the indicator of a set `indicatorConstLp 2 hs hμs c` and `f` is equal to the inner product of the constant `c` and the integral of `f` over `s`. -/ theorem inner_indicatorConstLp_eq_inner_setIntegral [CompleteSpace E] [NormedSpace ℝ E] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : E) (f : Lp E 2 μ) : (⟪indicatorConstLp 2 hs hμs c, f⟫ : 𝕜) = ⟪c, ∫ x in s, f x ∂μ⟫ := by rw [← integral_inner (integrableOn_Lp_of_measure_ne_top f fact_one_le_two_ennreal.elim hμs), L2.inner_indicatorConstLp_eq_setIntegral_inner] variable {𝕜} /-- The inner product in `L2` of the indicator of a set `indicatorConstLp 2 hs hμs (1 : 𝕜)` and a real or complex function `f` is equal to the integral of `f` over `s`. -/ theorem inner_indicatorConstLp_one (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (f : Lp 𝕜 2 μ) : ⟪indicatorConstLp 2 hs hμs (1 : 𝕜), f⟫ = ∫ x in s, f x ∂μ := by rw [L2.inner_indicatorConstLp_eq_inner_setIntegral 𝕜 hs hμs (1 : 𝕜) f]; simp /-- The inner product in `L2` of two `indicatorConstLp`s, i.e. functions which are constant `a : E` and `b : E` on measurable `s t : Set α` with finite measure, respectively, is `⟪a, b⟫` times the measure of `s ∩ t`. -/ lemma inner_indicatorConstLp_indicatorConstLp [CompleteSpace E] (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞ := by finiteness) (hμt : μ t ≠ ∞ := by finiteness) (a b : E) : ⟪indicatorConstLp 2 hs hμs a, indicatorConstLp 2 ht hμt b⟫ = μ.real (s ∩ t) • ⟪a, b⟫ := by let : InnerProductSpace ℝ E := InnerProductSpace.rclikeToReal 𝕜 E rw [inner_indicatorConstLp_eq_inner_setIntegral, setIntegral_indicatorConstLp hs, inner_smul_right_eq_smul, Set.inter_comm] /-- The inner product in `L2` of indicators of two sets with finite measure is the measure of the intersection. -/ lemma inner_indicatorConstLp_one_indicatorConstLp_one (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞ := by finiteness) (hμt : μ t ≠ ∞ := by finiteness) : ⟪indicatorConstLp 2 hs hμs (1 : 𝕜), indicatorConstLp 2 ht hμt (1 : 𝕜)⟫ = μ.real (s ∩ t) := by simp [inner_indicatorConstLp_indicatorConstLp, RCLike.ofReal_alg] lemma real_inner_indicatorConstLp_one_indicatorConstLp_one (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞ := by finiteness) (hμt : μ t ≠ ∞ := by finiteness) : ⟪indicatorConstLp 2 hs hμs (1 : ℝ), indicatorConstLp 2 ht hμt (1 : ℝ)⟫_ℝ = μ.real (s ∩ t) := by simp [inner_indicatorConstLp_indicatorConstLp] end IndicatorConstLp end L2 section InnerContinuous variable {α 𝕜 : Type*} [TopologicalSpace α] [MeasurableSpace α] [BorelSpace α] [RCLike 𝕜] variable (μ : Measure α) [IsFiniteMeasure μ] open scoped BoundedContinuousFunction ComplexConjugate local notation "⟪" x ", " y "⟫" => inner 𝕜 x y /-- For bounded continuous functions `f`, `g` on a finite-measure topological space `α`, the L^2 inner product is the integral of their pointwise inner product. -/ theorem BoundedContinuousFunction.inner_toLp (f g : α →ᵇ 𝕜) : ⟪BoundedContinuousFunction.toLp 2 μ 𝕜 f, BoundedContinuousFunction.toLp 2 μ 𝕜 g⟫ = ∫ x, g x * conj (f x) ∂μ := by apply integral_congr_ae have hf_ae := f.coeFn_toLp 2 μ 𝕜 have hg_ae := g.coeFn_toLp 2 μ 𝕜 filter_upwards [hf_ae, hg_ae] with _ hf hg rw [hf, hg] simp variable [CompactSpace α] /-- For continuous functions `f`, `g` on a compact, finite-measure topological space `α`, the L^2 inner product is the integral of their pointwise inner product. -/ theorem ContinuousMap.inner_toLp (f g : C(α, 𝕜)) : ⟪ContinuousMap.toLp 2 μ 𝕜 f, ContinuousMap.toLp 2 μ 𝕜 g⟫ = ∫ x, g x * conj (f x) ∂μ := by apply integral_congr_ae have hf_ae := f.coeFn_toLp (p := 2) (𝕜 := 𝕜) μ have hg_ae := g.coeFn_toLp (p := 2) (𝕜 := 𝕜) μ filter_upwards [hf_ae, hg_ae] with _ hf hg rw [hf, hg] simp end InnerContinuous end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/AEMeasurableOrder.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order /-! # Measurability criterion for ennreal-valued functions Consider a function `f : α → ℝ≥0∞`. If the level sets `{f < p}` and `{q < f}` have measurable supersets which are disjoint up to measure zero when `p` and `q` are finite numbers satisfying `p < q`, then `f` is almost-everywhere measurable. This is proved in `ENNReal.aemeasurable_of_exist_almost_disjoint_supersets`, and deduced from an analogous statement for any target space which is a complete linear dense order, called `MeasureTheory.aemeasurable_of_exist_almost_disjoint_supersets`. Note that it should be enough to assume that the space is a conditionally complete linear order, but the proof would be more painful. Since our only use for now is for `ℝ≥0∞`, we keep it as simple as possible. -/ open MeasureTheory Set TopologicalSpace open ENNReal NNReal /-- If a function `f : α → β` is such that the level sets `{f < p}` and `{q < f}` have measurable supersets which are disjoint up to measure zero when `p < q`, then `f` is almost-everywhere measurable. It is even enough to have this for `p` and `q` in a countable dense set. -/ theorem MeasureTheory.aemeasurable_of_exist_almost_disjoint_supersets {α : Type*} {m : MeasurableSpace α} (μ : Measure α) {β : Type*} [CompleteLinearOrder β] [DenselyOrdered β] [TopologicalSpace β] [OrderTopology β] [SecondCountableTopology β] [MeasurableSpace β] [BorelSpace β] (s : Set β) (s_count : s.Countable) (s_dense : Dense s) (f : α → β) (h : ∀ p ∈ s, ∀ q ∈ s, p < q → ∃ u v, MeasurableSet u ∧ MeasurableSet v ∧ { x | f x < p } ⊆ u ∧ { x | q < f x } ⊆ v ∧ μ (u ∩ v) = 0) : AEMeasurable f μ := by classical haveI : Encodable s := s_count.toEncodable have h' : ∀ p q, ∃ u v, MeasurableSet u ∧ MeasurableSet v ∧ { x | f x < p } ⊆ u ∧ { x | q < f x } ⊆ v ∧ (p ∈ s → q ∈ s → p < q → μ (u ∩ v) = 0) := by intro p q by_cases H : p ∈ s ∧ q ∈ s ∧ p < q · rcases h p H.1 q H.2.1 H.2.2 with ⟨u, v, hu, hv, h'u, h'v, hμ⟩ exact ⟨u, v, hu, hv, h'u, h'v, fun _ _ _ => hμ⟩ · refine ⟨univ, univ, MeasurableSet.univ, MeasurableSet.univ, subset_univ _, subset_univ _, fun ps qs pq => ?_⟩ exact (H ⟨ps, qs, pq⟩).elim choose! u v huv using h' let u' : β → Set α := fun p => ⋂ q ∈ s ∩ Ioi p, u p q have u'_meas : ∀ i, MeasurableSet (u' i) := by intro i exact MeasurableSet.biInter (s_count.mono inter_subset_left) fun b _ => (huv i b).1 let f' : α → β := fun x => ⨅ i : s, piecewise (u' i) (fun _ => (i : β)) (fun _ => (⊤ : β)) x have f'_meas : Measurable f' := by fun_prop (disch := simp_all) let t := ⋃ (p : s) (q : ↥(s ∩ Ioi p)), u' p ∩ v p q have μt : μ t ≤ 0 := calc μ t ≤ ∑' (p : s) (q : ↥(s ∩ Ioi p)), μ (u' p ∩ v p q) := by refine (measure_iUnion_le _).trans ?_ refine ENNReal.tsum_le_tsum fun p => ?_ haveI := (s_count.mono (s.inter_subset_left (t := Ioi ↑p))).to_subtype apply measure_iUnion_le _ ≤ ∑' (p : s) (q : ↥(s ∩ Ioi p)), μ (u p q ∩ v p q) := by gcongr with p q exact biInter_subset_of_mem q.2 _ = ∑' (p : s) (_ : ↥(s ∩ Ioi p)), (0 : ℝ≥0∞) := by grind _ = 0 := by simp only [tsum_zero] have ff' : ∀ᵐ x ∂μ, f x = f' x := by have : ∀ᵐ x ∂μ, x ∉ t := by have : μ t = 0 := le_antisymm μt bot_le change μ _ = 0 convert this ext y simp only [mem_setOf_eq, mem_compl_iff, not_notMem] filter_upwards [this] with x hx apply (iInf_eq_of_forall_ge_of_forall_gt_exists_lt _ _).symm · intro i by_cases H : x ∈ u' i swap · simp only [H, le_top, not_false_iff, piecewise_eq_of_notMem] simp only [H, piecewise_eq_of_mem] contrapose! hx obtain ⟨r, ⟨xr, rq⟩, rs⟩ : ∃ r, r ∈ Ioo (i : β) (f x) ∩ s := dense_iff_inter_open.1 s_dense (Ioo i (f x)) isOpen_Ioo (nonempty_Ioo.2 hx) have A : x ∈ v i r := (huv i r).2.2.2.1 rq refine mem_iUnion.2 ⟨i, ?_⟩ refine mem_iUnion.2 ⟨⟨r, ⟨rs, xr⟩⟩, ?_⟩ exact ⟨H, A⟩ · intro q hq obtain ⟨r, ⟨xr, rq⟩, rs⟩ : ∃ r, r ∈ Ioo (f x) q ∩ s := dense_iff_inter_open.1 s_dense (Ioo (f x) q) isOpen_Ioo (nonempty_Ioo.2 hq) refine ⟨⟨r, rs⟩, ?_⟩ have A : x ∈ u' r := mem_biInter fun i _ => (huv r i).2.2.1 xr simp only [A, rq, piecewise_eq_of_mem] exact ⟨f', f'_meas, ff'⟩ /-- If a function `f : α → ℝ≥0∞` is such that the level sets `{f < p}` and `{q < f}` have measurable supersets which are disjoint up to measure zero when `p` and `q` are finite numbers satisfying `p < q`, then `f` is almost-everywhere measurable. -/ theorem ENNReal.aemeasurable_of_exist_almost_disjoint_supersets {α : Type*} {m : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) (h : ∀ (p : ℝ≥0) (q : ℝ≥0), p < q → ∃ u v, MeasurableSet u ∧ MeasurableSet v ∧ { x | f x < p } ⊆ u ∧ { x | (q : ℝ≥0∞) < f x } ⊆ v ∧ μ (u ∩ v) = 0) : AEMeasurable f μ := by obtain ⟨s, s_count, s_dense, _, s_top⟩ : ∃ s : Set ℝ≥0∞, s.Countable ∧ Dense s ∧ 0 ∉ s ∧ ∞ ∉ s := ENNReal.exists_countable_dense_no_zero_top have I : ∀ x ∈ s, x ≠ ∞ := fun x xs hx => s_top (hx ▸ xs) apply MeasureTheory.aemeasurable_of_exist_almost_disjoint_supersets μ s s_count s_dense _ rintro p hp q hq hpq lift p to ℝ≥0 using I p hp lift q to ℝ≥0 using I q hq exact h p q (ENNReal.coe_lt_coe.1 hpq)
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/JacobianOneDim.lean
import Mathlib.Analysis.Calculus.Deriv.Slope import Mathlib.MeasureTheory.Function.Jacobian /-! # Change of variable formulas for integrals in dimension 1 We record in this file versions of the general change of variables formula in integrals for functions from `R` to `ℝ`. This makes it possible to replace the determinant of the Fréchet derivative with the one-dimensional derivative. We also give more specific versions of these theorems for monotone and antitone functions: this makes it possible to drop the injectivity assumption of the general theorems, as the derivative is zero on the set of non-injectivity, which means that it can be discarded. See also `Mathlib/MeasureTheory/Integral/IntervalIntegral/IntegrationByParts.lean` for versions of the change of variables formula in dimension 1 for non-monotone functions, formulated with the interval integral and with stronger requirements on the integrand. -/ open MeasureTheory MeasureTheory.Measure Metric Filter Set Module Asymptotics TopologicalSpace ContinuousLinearMap open scoped NNReal ENNReal Topology Pointwise variable {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] {s : Set ℝ} {f f' : ℝ → ℝ} {g : ℝ → F} namespace MeasureTheory /-- Integrability in the change of variable formula for differentiable functions (one-variable version): if a function `f` is injective and differentiable on a measurable set `s ⊆ ℝ`, then the Lebesgue integral of a function `g : ℝ → ℝ≥0∞` on `f '' s` coincides with the Lebesgue integral of `|(f' x)| * g ∘ f` on `s`. -/ theorem lintegral_image_eq_lintegral_abs_deriv_mul (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : InjOn f s) (g : ℝ → ℝ≥0∞) : ∫⁻ x in f '' s, g x = ∫⁻ x in s, ENNReal.ofReal (|f' x|) * g (f x) := by simpa only [det_one_smulRight] using lintegral_image_eq_lintegral_abs_det_fderiv_mul volume hs (fun x hx => (hf' x hx).hasFDerivWithinAt) hf g /-- Integrability in the change of variable formula for differentiable functions (one-variable version): if a function `f` is injective and differentiable on a measurable set `s ⊆ ℝ`, then a function `g : ℝ → F` is integrable on `f '' s` if and only if `|(f' x)| • g ∘ f` is integrable on `s`. -/ theorem integrableOn_image_iff_integrableOn_abs_deriv_smul (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : InjOn f s) (g : ℝ → F) : IntegrableOn g (f '' s) ↔ IntegrableOn (fun x => |f' x| • g (f x)) s := by simpa only [det_one_smulRight] using integrableOn_image_iff_integrableOn_abs_det_fderiv_smul volume hs (fun x hx => (hf' x hx).hasFDerivWithinAt) hf g /-- Change of variable formula for differentiable functions (one-variable version): if a function `f` is injective and differentiable on a measurable set `s ⊆ ℝ`, then the Bochner integral of a function `g : ℝ → F` on `f '' s` coincides with the integral of `|(f' x)| • g ∘ f` on `s`. -/ theorem integral_image_eq_integral_abs_deriv_smul (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : InjOn f s) (g : ℝ → F) : ∫ x in f '' s, g x = ∫ x in s, |f' x| • g (f x) := by simpa only [det_one_smulRight] using integral_image_eq_integral_abs_det_fderiv_smul volume hs (fun x hx => (hf' x hx).hasFDerivWithinAt) hf g /-- Technical structure theorem for monotone differentiable functions. If a function `f` is monotone on a measurable set and has a derivative `f'`, one can decompose the set as a disjoint union `a ∪ b ∪ c` of measurable sets where `a` is countable (the points which are isolated on the left or on the right, where `f'` is not well controlled), `f` is locally constant on `b` and `f' = 0` there (the preimages of the countably many points with several preimages), and `f` is injective on `c` with nonnegative derivative (the other points). -/ theorem exists_decomposition_of_monotoneOn_hasDerivWithinAt (hs : MeasurableSet s) (hf : MonotoneOn f s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : ∃ (a b c : Set ℝ), a ∪ (b ∪ c) = s ∧ MeasurableSet a ∧ MeasurableSet b ∧ MeasurableSet c ∧ Disjoint a (b ∪ c) ∧ Disjoint b c ∧ a.Countable ∧ (f '' b).Countable ∧ (∀ x ∈ b, f' x = 0) ∧ (∀ x ∈ c, 0 ≤ f' x) ∧ InjOn f c := by let a := {x ∈ s | 𝓝[s ∩ Ioi x] x = ⊥} ∪ {x ∈ s | 𝓝[s ∩ Iio x] x = ⊥} have a_count : a.Countable := countable_setOf_isolated_right_within.union countable_setOf_isolated_left_within let s₁ := s \ a have hs₁ : MeasurableSet s₁ := hs.diff a_count.measurableSet let u : Set ℝ := {c | ∃ x y, x ∈ s₁ ∧ y ∈ s₁ ∧ x < y ∧ f x = c ∧ f y = c} have hu : Set.Countable u := MonotoneOn.countable_setOf_two_preimages (hf.mono diff_subset) let b := s₁ ∩ f ⁻¹' u have hb : MeasurableSet b := by have : b = ⋃ z ∈ u, s₁ ∩ f⁻¹' {z} := by ext; simp [b] rw [this] apply MeasurableSet.biUnion hu (fun z hz ↦ ?_) obtain ⟨v, hv, tv⟩ : ∃ v, OrdConnected v ∧ (s \ a) ∩ f ⁻¹' {z} = (s \ a) ∩ v := ordConnected_singleton.preimage_monotoneOn (hf.mono diff_subset) exact tv ▸ (hs.diff a_count.measurableSet).inter hv.measurableSet let c := s₁ \ b have hc : MeasurableSet c := hs₁.diff hb refine ⟨a, b, c, ?_, a_count.measurableSet, hb, hc, ?_, ?_, a_count, ?_, ?_, ?_, ?_⟩ · ext x simp only [diff_self_inter, inter_union_diff, union_diff_self, mem_union, mem_setOf_eq, or_iff_right_iff_imp, a, b, s₁, c] tauto · simpa [b, c, s₁] using disjoint_sdiff_right · simpa [c] using disjoint_sdiff_right · exact hu.mono (by simp [b]) · /- We have to show that the derivative is `0` at `x ∈ b`. For that, we use that there is another point `p` with `f p = f x`, by definition of `b`. If `p < x`, then `f` is locally constant to the left of `x`. As `x` is not isolated to its left (since we are not in the set `a`), it follows that `f' x = 0`. The same argument works if `x < p`, using the right neighborhood instead. -/ intro x hx obtain ⟨p, ps₁, px, fpx⟩ : ∃ p ∈ s₁, p ≠ x ∧ f p = f x := by rcases hx.2 with ⟨p, q, ps₁, qs₁, pq, hp, hq⟩ rcases eq_or_ne p x with h'p | h'p · exact ⟨q, qs₁, (h'p.symm.le.trans_lt pq).ne', hq⟩ · exact ⟨p, ps₁, h'p, hp⟩ -- we treat separately the cases `p < x` and `x < p` as we couldn't unify their proofs nicely rcases lt_or_gt_of_ne px with px | px · have K : HasDerivWithinAt f 0 (s ∩ Ioo p x) x := by have E (y) (hy : y ∈ s ∩ Ioo p x) : f y = f x := by apply le_antisymm (hf hy.1 hx.1.1 hy.2.2.le) rw [← fpx] exact hf ps₁.1 hy.1 hy.2.1.le have : HasDerivWithinAt (fun y ↦ f x) 0 (s ∩ Ioo p x) x := hasDerivWithinAt_const x (s ∩ Ioo p x) (f x) exact this.congr E rfl have K' : HasDerivWithinAt f (f' x) (s ∩ Ioo p x) x := (hf' x hx.1.1).mono inter_subset_left apply UniqueDiffWithinAt.eq_deriv _ _ K' K have J1 : (s ∩ Ioo p x) \ {x} = s ∩ Ioo p x := by simp have J2 : 𝓝[s ∩ Ioo p x] x = 𝓝[s ∩ Iio x] x := by simp [nhdsWithin_inter, nhdsWithin_Ioo_eq_nhdsLT px] rw [uniqueDiffWithinAt_iff_accPt, accPt_principal_iff_nhdsWithin, J1, J2] simp only [mem_inter_iff, mem_diff, hx.1.1, mem_union, mem_setOf_eq, true_and, not_or, mem_preimage, b, s₁, a] at hx exact neBot_iff.2 hx.1.2 · have K : HasDerivWithinAt f 0 (s ∩ Ioo x p) x := by have E (y) (hy : y ∈ s ∩ Ioo x p) : f y = f x := by apply le_antisymm _ (hf hx.1.1 hy.1 hy.2.1.le) rw [← fpx] exact hf hy.1 ps₁.1 hy.2.2.le have : HasDerivWithinAt (fun y ↦ f x) 0 (s ∩ Ioo x p) x := hasDerivWithinAt_const x (s ∩ Ioo x p) (f x) exact this.congr E rfl have K' : HasDerivWithinAt f (f' x) (s ∩ Ioo x p) x := (hf' x hx.1.1).mono inter_subset_left apply UniqueDiffWithinAt.eq_deriv _ _ K' K have J1 : (s ∩ Ioo x p) \ {x} = (s ∩ Ioo x p) := by simp have J2 : 𝓝[s ∩ Ioo x p] x = 𝓝[s ∩ Ioi x] x := by simp [nhdsWithin_inter, nhdsWithin_Ioo_eq_nhdsGT px] rw [uniqueDiffWithinAt_iff_accPt, accPt_principal_iff_nhdsWithin, J1, J2] simp only [mem_inter_iff, mem_diff, hx.1.1, mem_union, mem_setOf_eq, true_and, not_or, mem_preimage, b, s₁, a] at hx exact neBot_iff.2 hx.1.1 · /- We have to show that the derivative is nonnegative at points of `c`. As these points are not isolated in `s`, this follows from the fact that `f` is monotone on `s`. -/ intro x hx apply (hf' x hx.1.1).nonneg_of_monotoneOn _ hf simp only [mem_diff, hx.1.1, mem_union, mem_setOf_eq, true_and, not_or, c, s₁, a, b] at hx rw [accPt_principal_iff_nhdsWithin] have : (𝓝[s ∩ Iio x] x).NeBot := neBot_iff.2 hx.1.2 apply this.mono apply nhdsWithin_mono rintro y ⟨yt, yx : y < x⟩ exact ⟨yt, by simpa using yx.ne⟩ · intro x hx y hy hxy contrapose! hxy wlog H : x < y generalizing x y with h · have : y < x := by order exact (h hy hx hxy.symm this).symm refine fun h ↦ hx.2 ⟨hx.1, ?_⟩ exact ⟨x, y, hx.1, hy.1, H, rfl, h.symm⟩ /- Change of variable formula for differentiable functions: if a real function `f` is monotone and differentiable on a measurable set `s`, then the Lebesgue integral of a function `u : ℝ → ℝ≥0∞` on `f '' s` coincides with the integral of `(f' x) * u ∘ f` on `s`. Note that the measurability of `f '' s` is given by `MeasurableSet.image_of_monotoneOn`. -/ theorem lintegral_image_eq_lintegral_deriv_mul_of_monotoneOn (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : MonotoneOn f s) (u : ℝ → ℝ≥0∞) : ∫⁻ x in f '' s, u x = ∫⁻ x in s, ENNReal.ofReal (f' x) * u (f x) := by rcases exists_decomposition_of_monotoneOn_hasDerivWithinAt hs hf hf' with ⟨a, b, c, h_union, ha, hb, hc, h_disj, h_disj', a_count, fb_count, deriv_b, deriv_c, inj_c⟩ have I : ∫⁻ x in s, ENNReal.ofReal (f' x) * u (f x) = ∫⁻ x in c, ENNReal.ofReal (f' x) * u (f x) := by have : ∫⁻ x in a, ENNReal.ofReal (f' x) * u (f x) = 0 := setLIntegral_measure_zero a _ (a_count.measure_zero volume) rw [← h_union, lintegral_union (hb.union hc) h_disj, this, zero_add] have : ∫⁻ x in b, ENNReal.ofReal (f' x) * u (f x) = 0 := setLIntegral_eq_zero hb (fun x hx ↦ by simp [deriv_b x hx]) rw [lintegral_union hc h_disj', this, zero_add] have J : ∫⁻ x in f '' s, u x = ∫⁻ x in f '' c, u x := by apply setLIntegral_congr rw [← h_union, image_union, image_union] have A : (f '' a ∪ (f '' b ∪ f '' c) : Set ℝ) =ᵐ[volume] (f '' b ∪ f '' c : Set ℝ) := by refine union_ae_eq_right_of_ae_eq_empty (ae_eq_empty.mpr ?_) exact (a_count.image _).measure_zero _ have B : (f '' b ∪ f '' c : Set ℝ) =ᵐ[volume] f '' c := union_ae_eq_right_of_ae_eq_empty (ae_eq_empty.mpr (fb_count.measure_zero _)) exact A.trans B rw [I, J] have c_s : c ⊆ s := by rw [← h_union]; exact subset_union_right.trans subset_union_right let F' : ℝ → (ℝ →L[ℝ] ℝ) := fun x ↦ ContinuousLinearMap.smulRight (1 : ℝ →L[ℝ] ℝ) (f' x) have hf' (x : ℝ) (hx : x ∈ c) : HasFDerivWithinAt f (F' x) c x := (hf' x (c_s hx)).hasFDerivWithinAt.mono c_s have : ∫⁻ x in c, ENNReal.ofReal (f' x) * u (f x) = ∫⁻ x in c, ENNReal.ofReal (|(F' x).det|) * u (f x) := by apply setLIntegral_congr_fun hc (fun x hx ↦ ?_) simp only [LinearMap.det_ring, ContinuousLinearMap.coe_coe, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, smul_eq_mul, one_mul, F'] rw [abs_of_nonneg (deriv_c x hx)] rw [this] exact lintegral_image_eq_lintegral_abs_det_fderiv_mul _ hc hf' inj_c _ /-- Change of variable formula for differentiable functions, set version: if a real function `f` is monotone and differentiable on a measurable set `s`, then the measure of `f '' s` is given by the integral of `f' x` on `s` . Note that the measurability of `f '' s` is given by `MeasurableSet.image_of_monotoneOn`. -/ theorem lintegral_deriv_eq_volume_image_of_monotoneOn (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : MonotoneOn f s) : (∫⁻ x in s, ENNReal.ofReal (f' x)) = volume (f '' s) := by simpa using (lintegral_image_eq_lintegral_deriv_mul_of_monotoneOn hs hf' hf 1).symm /-- Integrability in the change of variable formula for differentiable functions: if a real function `f` is monotone and differentiable on a measurable set `s`, then a function `g : ℝ → F` is integrable on `f '' s` if and only if `f' x • g ∘ f` is integrable on `s` . -/ theorem integrableOn_image_iff_integrableOn_deriv_smul_of_monotoneOn (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : MonotoneOn f s) (g : ℝ → F) : IntegrableOn g (f '' s) ↔ IntegrableOn (fun x ↦ (f' x) • g (f x)) s := by rcases exists_decomposition_of_monotoneOn_hasDerivWithinAt hs hf hf' with ⟨a, b, c, h_union, ha, hb, hc, h_disj, h_disj', a_count, fb_count, deriv_b, deriv_c, inj_c⟩ have I : IntegrableOn (fun x => (f' x) • g (f x)) s ↔ IntegrableOn (fun x => (f' x) • g (f x)) c := by have A : IntegrableOn (fun x ↦ f' x • g (f x)) a := IntegrableOn.of_measure_zero (a_count.measure_zero volume) have B : IntegrableOn (fun x ↦ f' x • g (f x)) b := by have : IntegrableOn (fun x ↦ (0 : F)) b := by simp exact this.congr_fun (fun x hx ↦ by simp [deriv_b x hx]) hb simp only [← h_union, integrableOn_union, A, B, true_and] have J : IntegrableOn g (f '' s) ↔ IntegrableOn g (f '' c) := by apply integrableOn_congr_set_ae rw [← h_union, image_union, image_union] have A : (f '' a ∪ (f '' b ∪ f '' c) : Set ℝ) =ᵐ[volume] (f '' b ∪ f '' c : Set ℝ) := by refine union_ae_eq_right_of_ae_eq_empty (ae_eq_empty.mpr ?_) exact (a_count.image _).measure_zero _ have B : (f '' b ∪ f '' c : Set ℝ) =ᵐ[volume] f '' c := union_ae_eq_right_of_ae_eq_empty (ae_eq_empty.mpr (fb_count.measure_zero _)) exact A.trans B rw [I, J] have c_s : c ⊆ s := by rw [← h_union]; exact subset_union_right.trans subset_union_right let F' : ℝ → (ℝ →L[ℝ] ℝ) := fun x ↦ ContinuousLinearMap.smulRight (1 : ℝ →L[ℝ] ℝ) (f' x) have hF' (x : ℝ) (hx : x ∈ c) : HasFDerivWithinAt f (F' x) c x := (hf' x (c_s hx)).hasFDerivWithinAt.mono c_s rw [integrableOn_image_iff_integrableOn_abs_det_fderiv_smul _ hc hF' inj_c] apply integrableOn_congr_fun (fun x hx ↦ ?_) hc simp only [LinearMap.det_ring, ContinuousLinearMap.coe_coe, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, smul_eq_mul, one_mul, F'] rw [abs_of_nonneg (deriv_c x hx)] /-- Change of variable formula for differentiable functions: if a real function `f` is monotone and differentiable on a measurable set `s`, then the Bochner integral of a function `g : ℝ → F` on `f '' s` coincides with the integral of `(f' x) • g ∘ f` on `s` . -/ theorem integral_image_eq_integral_deriv_smul_of_monotoneOn (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : MonotoneOn f s) (g : ℝ → F) : ∫ x in f '' s, g x = ∫ x in s, f' x • g (f x) := by by_cases H : IntegrableOn g (f '' s); swap · rw [integral_undef H, integral_undef] simpa [integrableOn_image_iff_integrableOn_deriv_smul_of_monotoneOn hs hf' hf] using H have H' : IntegrableOn (fun x ↦ (f' x) • g (f x)) s := (integrableOn_image_iff_integrableOn_deriv_smul_of_monotoneOn hs hf' hf g).1 H rcases exists_decomposition_of_monotoneOn_hasDerivWithinAt hs hf hf' with ⟨a, b, c, h_union, ha, hb, hc, h_disj, h_disj', a_count, fb_count, deriv_b, deriv_c, inj_c⟩ have a_s : a ⊆ s := by rw [← h_union]; exact subset_union_left have bc_s : b ∪ c ⊆ s := by rw [← h_union]; exact subset_union_right have b_s : b ⊆ s := by rw [← h_union]; exact subset_union_left.trans subset_union_right have c_s : c ⊆ s := by rw [← h_union]; exact subset_union_right.trans subset_union_right have I : ∫ x in s, f' x • g (f x) = ∫ x in c, f' x • g (f x) := by have : ∫ x in a, f' x • g (f x) = 0 := setIntegral_measure_zero _ (a_count.measure_zero volume) rw [← h_union, setIntegral_union h_disj (hb.union hc) (H'.mono_set a_s) (H'.mono_set bc_s), this, zero_add] have : ∫ x in b, f' x • g (f x) = 0 := setIntegral_eq_zero_of_forall_eq_zero (fun x hx ↦ by simp [deriv_b x hx]) rw [setIntegral_union h_disj' hc (H'.mono_set b_s) (H'.mono_set c_s), this, zero_add] have J : ∫ x in f '' s, g x = ∫ x in f '' c, g x := by apply setIntegral_congr_set rw [← h_union, image_union, image_union] have A : (f '' a ∪ (f '' b ∪ f '' c) : Set ℝ) =ᵐ[volume] (f '' b ∪ f '' c : Set ℝ) := by refine union_ae_eq_right_of_ae_eq_empty (ae_eq_empty.mpr ?_) exact (a_count.image _).measure_zero _ have B : (f '' b ∪ f '' c : Set ℝ) =ᵐ[volume] f '' c := union_ae_eq_right_of_ae_eq_empty (ae_eq_empty.mpr (fb_count.measure_zero _)) exact A.trans B rw [I, J] let F' : ℝ → (ℝ →L[ℝ] ℝ) := fun x ↦ ContinuousLinearMap.smulRight (1 : ℝ →L[ℝ] ℝ) (f' x) have hF' (x : ℝ) (hx : x ∈ c) : HasFDerivWithinAt f (F' x) c x := (hf' x (c_s hx)).hasFDerivWithinAt.mono c_s have : ∫ x in c, f' x • g (f x) = ∫ x in c, |(F' x).det| • g (f x) := by apply setIntegral_congr_fun hc (fun x hx ↦ ?_) simp only [LinearMap.det_ring, ContinuousLinearMap.coe_coe, ContinuousLinearMap.smulRight_apply, ContinuousLinearMap.one_apply, smul_eq_mul, one_mul, F'] rw [abs_of_nonneg (deriv_c x hx)] rw [this] exact integral_image_eq_integral_abs_det_fderiv_smul _ hc hF' inj_c _ /- Change of variable formula for differentiable functions: if a real function `f` is antitone and differentiable on a measurable set `s`, then the Lebesgue integral of a function `u : ℝ → ℝ≥0∞` on `f '' s` coincides with the integral of `(-f' x) * u ∘ f` on `s`. Note that the measurability of `f '' s` is given by `MeasurableSet.image_of_antitoneOn`. -/ theorem lintegral_image_eq_lintegral_deriv_mul_of_antitoneOn (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : AntitoneOn f s) (u : ℝ → ℝ≥0∞) : ∫⁻ x in f '' s, u x = ∫⁻ x in s, ENNReal.ofReal (-f' x) * u (f x) := by let n : ℝ → ℝ := (fun x ↦ - x) let e := n ∘ f have hg' (x) (hx : x ∈ s) : HasDerivWithinAt e (-f' x) s x := (hf' x hx).neg have A : ∫⁻ x in e '' s, u (n x) = ∫⁻ x in s, ENNReal.ofReal (-f' x) * (u ∘ n) (e x) := by rw [← lintegral_image_eq_lintegral_deriv_mul_of_monotoneOn hs hg' hf.neg (u ∘ n)]; rfl have B : ∫⁻ x in n '' (e '' s), u x = ∫⁻ x in e '' s, ENNReal.ofReal (|-1|) * u (n x) := lintegral_image_eq_lintegral_abs_deriv_mul (hs.image_of_monotoneOn hf.neg) (fun x hx ↦ hasDerivWithinAt_neg _ _) neg_injective.injOn _ simp only [abs_neg, abs_one, ENNReal.ofReal_one, one_mul] at B rw [A, ← image_comp] at B convert B using 4 with x hx x <;> simp [n, e] /-- Change of variable formula for differentiable functions, set version: if a real function `f` is antitone and differentiable on a measurable set `s`, then the measure of `f '' s` is given by the integral of `-f' x` on `s` . Note that the measurability of `f '' s` is given by `MeasurableSet.image_of_antitoneOn`. -/ theorem lintegral_deriv_eq_volume_image_of_antitoneOn (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : AntitoneOn f s) : (∫⁻ x in s, ENNReal.ofReal (-f' x)) = volume (f '' s) := by simpa using (lintegral_image_eq_lintegral_deriv_mul_of_antitoneOn hs hf' hf 1).symm /-- Integrability in the change of variable formula for differentiable functions: if a real function `f` is antitone and differentiable on a measurable set `s`, then a function `g : ℝ → F` is integrable on `f '' s` if and only if `-f' x • g ∘ f` is integrable on `s` . -/ theorem integrableOn_image_iff_integrableOn_deriv_smul_of_antitoneOn (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : AntitoneOn f s) (g : ℝ → F) : IntegrableOn g (f '' s) ↔ IntegrableOn (fun x ↦ (-f' x) • g (f x)) s := by let n : ℝ → ℝ := (fun x ↦ - x) let e := n ∘ f have hg' (x) (hx : x ∈ s) : HasDerivWithinAt e (-f' x) s x := (hf' x hx).neg have A : IntegrableOn (fun x ↦ g (n x)) (e '' s) ↔ IntegrableOn (fun x ↦ (-f' x) • (g ∘ n) (e x)) s := by rw [← integrableOn_image_iff_integrableOn_deriv_smul_of_monotoneOn hs hg' hf.neg (g ∘ n)]; rfl have B : IntegrableOn g (n '' (e '' s)) ↔ IntegrableOn (fun x ↦ (|-1| : ℝ) • g (n x)) (e '' s) := integrableOn_image_iff_integrableOn_abs_deriv_smul (hs.image_of_monotoneOn hf.neg) (fun x hx ↦ hasDerivWithinAt_neg _ _) neg_injective.injOn _ simp only [abs_neg, abs_one, one_smul] at B rw [A, ← image_comp] at B convert B using 3 with x hx x <;> simp [n, e] /-- Change of variable formula for differentiable functions: if a real function `f` is antitone and differentiable on a measurable set `s`, then the Bochner integral of a function `g : ℝ → F` on `f '' s` coincides with the integral of `(-f' x) • g ∘ f` on `s` . -/ theorem integral_image_eq_integral_deriv_smul_of_antitone (hs : MeasurableSet s) (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) (hf : AntitoneOn f s) (g : ℝ → F) : ∫ x in f '' s, g x = ∫ x in s, (-f' x) • g (f x) := by let n : ℝ → ℝ := (fun x ↦ - x) let e := n ∘ f have hg' (x) (hx : x ∈ s) : HasDerivWithinAt e (-f' x) s x := (hf' x hx).neg have A : ∫ x in e '' s, g (n x) = ∫ x in s, (-f' x) • (g ∘ n) (e x) := by rw [← integral_image_eq_integral_deriv_smul_of_monotoneOn hs hg' hf.neg (g ∘ n)]; rfl have B : ∫ x in n '' (e '' s), g x = ∫ x in e '' s, (|-1| : ℝ) • g (n x) := integral_image_eq_integral_abs_deriv_smul (hs.image_of_monotoneOn hf.neg) (fun x hx ↦ hasDerivWithinAt_neg _ _) neg_injective.injOn _ simp only [abs_neg, abs_one, one_smul] at B rw [A, ← image_comp] at B convert B using 3 with x hx x <;> simp [n, e] section WithDensity lemma _root_.MeasurableEmbedding.withDensity_ofReal_comap_apply_eq_integral_abs_deriv_mul {f : ℝ → ℝ} (hf : MeasurableEmbedding f) {s : Set ℝ} (hs : MeasurableSet s) {g : ℝ → ℝ} (hg : ∀ᵐ x, x ∈ f '' s → 0 ≤ g x) (hf_int : IntegrableOn g (f '' s)) {f' : ℝ → ℝ} (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : (volume.withDensity (fun x ↦ ENNReal.ofReal (g x))).comap f s = ENNReal.ofReal (∫ x in s, |f' x| * g (f x)) := by rw [hf.withDensity_ofReal_comap_apply_eq_integral_abs_det_fderiv_mul volume hs hg hf_int hf'] simp only [det_one_smulRight] lemma _root_.MeasurableEquiv.withDensity_ofReal_map_symm_apply_eq_integral_abs_deriv_mul (f : ℝ ≃ᵐ ℝ) {s : Set ℝ} (hs : MeasurableSet s) {g : ℝ → ℝ} (hg : ∀ᵐ x, x ∈ f '' s → 0 ≤ g x) (hf_int : IntegrableOn g (f '' s)) {f' : ℝ → ℝ} (hf' : ∀ x ∈ s, HasDerivWithinAt f (f' x) s x) : (volume.withDensity (fun x ↦ ENNReal.ofReal (g x))).map f.symm s = ENNReal.ofReal (∫ x in s, |f' x| * g (f x)) := by rw [MeasurableEquiv.withDensity_ofReal_map_symm_apply_eq_integral_abs_det_fderiv_mul volume hs f hg hf_int hf'] simp only [det_one_smulRight] lemma _root_.MeasurableEmbedding.withDensity_ofReal_comap_apply_eq_integral_abs_deriv_mul' {f : ℝ → ℝ} (hf : MeasurableEmbedding f) {s : Set ℝ} (hs : MeasurableSet s) {f' : ℝ → ℝ} (hf' : ∀ x, HasDerivAt f (f' x) x) {g : ℝ → ℝ} (hg : 0 ≤ᵐ[volume] g) (hg_int : Integrable g) : (volume.withDensity (fun x ↦ ENNReal.ofReal (g x))).comap f s = ENNReal.ofReal (∫ x in s, |f' x| * g (f x)) := hf.withDensity_ofReal_comap_apply_eq_integral_abs_deriv_mul hs (by filter_upwards [hg] with x hx using fun _ ↦ hx) hg_int.integrableOn (fun x _ => (hf' x).hasDerivWithinAt) lemma _root_.MeasurableEquiv.withDensity_ofReal_map_symm_apply_eq_integral_abs_deriv_mul' (f : ℝ ≃ᵐ ℝ) {s : Set ℝ} (hs : MeasurableSet s) {f' : ℝ → ℝ} (hf' : ∀ x, HasDerivAt f (f' x) x) {g : ℝ → ℝ} (hg : 0 ≤ᵐ[volume] g) (hg_int : Integrable g) : (volume.withDensity (fun x ↦ ENNReal.ofReal (g x))).map f.symm s = ENNReal.ofReal (∫ x in s, |f' x| * g (f x)) := by rw [MeasurableEquiv.withDensity_ofReal_map_symm_apply_eq_integral_abs_det_fderiv_mul volume hs f (by filter_upwards [hg] with x hx using fun _ ↦ hx) hg_int.integrableOn (fun x _ => (hf' x).hasDerivWithinAt)] simp only [det_one_smulRight] end WithDensity end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean
import Mathlib.MeasureTheory.Integral.IntegrableOn /-! # Locally integrable functions A function is called *locally integrable* (`MeasureTheory.LocallyIntegrable`) if it is integrable on a neighborhood of every point. More generally, it is *locally integrable on `s`* if it is locally integrable on a neighbourhood within `s` of any point of `s`. This file contains properties of locally integrable functions, and integrability results on compact sets. ## Main statements * `Continuous.locallyIntegrable`: A continuous function is locally integrable. * `ContinuousOn.locallyIntegrableOn`: A function which is continuous on `s` is locally integrable on `s`. -/ open MeasureTheory MeasureTheory.Measure Set Function TopologicalSpace Bornology open scoped Topology Interval ENNReal variable {X Y ε ε' ε'' E F R : Type*} [MeasurableSpace X] [TopologicalSpace X] variable [MeasurableSpace Y] [TopologicalSpace Y] variable [TopologicalSpace ε] [ContinuousENorm ε] [TopologicalSpace ε'] [ContinuousENorm ε'] [TopologicalSpace ε''] [ESeminormedAddMonoid ε''] [NormedAddCommGroup E] [NormedAddCommGroup F] {f g : X → ε} {μ : Measure X} {s : Set X} namespace MeasureTheory section LocallyIntegrableOn /-- A function `f : X → E` is *locally integrable on s*, for `s ⊆ X`, if for every `x ∈ s` there is a neighbourhood of `x` within `s` on which `f` is integrable. (Note this is, in general, strictly weaker than local integrability with respect to `μ.restrict s`.) -/ def LocallyIntegrableOn (f : X → ε) (s : Set X) (μ : Measure X := by volume_tac) : Prop := ∀ x : X, x ∈ s → IntegrableAtFilter f (𝓝[s] x) μ theorem LocallyIntegrableOn.mono_set (hf : LocallyIntegrableOn f s μ) {t : Set X} (hst : t ⊆ s) : LocallyIntegrableOn f t μ := fun x hx => (hf x <| hst hx).filter_mono (nhdsWithin_mono x hst) theorem LocallyIntegrableOn.enorm (hf : LocallyIntegrableOn f s μ) : LocallyIntegrableOn (‖f ·‖ₑ) s μ := fun t ht ↦ let ⟨U, hU_nhd, hU_int⟩ := hf t ht ⟨U, hU_nhd, hU_int.enorm⟩ theorem LocallyIntegrableOn.norm {f : X → E} (hf : LocallyIntegrableOn f s μ) : LocallyIntegrableOn (fun x => ‖f x‖) s μ := fun t ht => let ⟨U, hU_nhd, hU_int⟩ := hf t ht ⟨U, hU_nhd, hU_int.norm⟩ theorem LocallyIntegrableOn.mono_enorm (hf : LocallyIntegrableOn f s μ) {g : X → ε'} (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ x ∂μ, ‖g x‖ₑ ≤ ‖f x‖ₑ) : LocallyIntegrableOn g s μ := by intro x hx rcases hf x hx with ⟨t, t_mem, ht⟩ exact ⟨t, t_mem, ht.mono_enorm hg.restrict (ae_restrict_of_ae h)⟩ theorem LocallyIntegrableOn.mono {f : X → E} (hf : LocallyIntegrableOn f s μ) {g : X → F} (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ x ∂μ, ‖g x‖ ≤ ‖f x‖) : LocallyIntegrableOn g s μ := by intro x hx rcases hf x hx with ⟨t, t_mem, ht⟩ exact ⟨t, t_mem, Integrable.mono ht hg.restrict (ae_restrict_of_ae h)⟩ theorem IntegrableOn.locallyIntegrableOn (hf : IntegrableOn f s μ) : LocallyIntegrableOn f s μ := fun _ _ => ⟨s, self_mem_nhdsWithin, hf⟩ /-- If a function is locally integrable on a compact set, then it is integrable on that set. -/ theorem LocallyIntegrableOn.integrableOn_isCompact [PseudoMetrizableSpace ε] (hf : LocallyIntegrableOn f s μ) (hs : IsCompact s) : IntegrableOn f s μ := IsCompact.induction_on hs integrableOn_empty (fun _u _v huv hv => hv.mono_set huv) (fun _u _v hu hv => integrableOn_union.mpr ⟨hu, hv⟩) hf theorem LocallyIntegrableOn.integrableOn_compact_subset [PseudoMetrizableSpace ε] (hf : LocallyIntegrableOn f s μ) {t : Set X} (hst : t ⊆ s) (ht : IsCompact t) : IntegrableOn f t μ := (hf.mono_set hst).integrableOn_isCompact ht /-- If a function `f` is locally integrable on a set `s` in a second countable topological space, then there exist countably many open sets `u` covering `s` such that `f` is integrable on each set `u ∩ s`. -/ theorem LocallyIntegrableOn.exists_countable_integrableOn [SecondCountableTopology X] (hf : LocallyIntegrableOn f s μ) : ∃ T : Set (Set X), T.Countable ∧ (∀ u ∈ T, IsOpen u) ∧ (s ⊆ ⋃ u ∈ T, u) ∧ (∀ u ∈ T, IntegrableOn f (u ∩ s) μ) := by have : ∀ x : s, ∃ u, IsOpen u ∧ x.1 ∈ u ∧ IntegrableOn f (u ∩ s) μ := by rintro ⟨x, hx⟩ rcases hf x hx with ⟨t, ht, h't⟩ rcases mem_nhdsWithin.1 ht with ⟨u, u_open, x_mem, u_sub⟩ exact ⟨u, u_open, x_mem, h't.mono_set u_sub⟩ choose u u_open xu hu using this obtain ⟨T, T_count, hT⟩ : ∃ T : Set s, T.Countable ∧ s ⊆ ⋃ i ∈ T, u i := by have : s ⊆ ⋃ x : s, u x := fun y hy => mem_iUnion_of_mem ⟨y, hy⟩ (xu ⟨y, hy⟩) obtain ⟨T, hT_count, hT_un⟩ := isOpen_iUnion_countable u u_open exact ⟨T, hT_count, by rwa [hT_un]⟩ refine ⟨u '' T, T_count.image _, ?_, by rwa [biUnion_image], ?_⟩ · rintro v ⟨w, -, rfl⟩ exact u_open _ · rintro v ⟨w, -, rfl⟩ exact hu _ /-- If a function `f` is locally integrable on a set `s` in a second countable topological space, then there exists a sequence of open sets `u n` covering `s` such that `f` is integrable on each set `u n ∩ s`. -/ theorem LocallyIntegrableOn.exists_nat_integrableOn [SecondCountableTopology X] (hf : LocallyIntegrableOn f s μ) : ∃ u : ℕ → Set X, (∀ n, IsOpen (u n)) ∧ (s ⊆ ⋃ n, u n) ∧ (∀ n, IntegrableOn f (u n ∩ s) μ) := by rcases hf.exists_countable_integrableOn with ⟨T, T_count, T_open, sT, hT⟩ let T' : Set (Set X) := insert ∅ T have T'_count : T'.Countable := Countable.insert ∅ T_count have T'_ne : T'.Nonempty := by simp only [T', insert_nonempty] rcases T'_count.exists_eq_range T'_ne with ⟨u, hu⟩ refine ⟨u, ?_, ?_, ?_⟩ · intro n have : u n ∈ T' := by rw [hu]; exact mem_range_self n rcases mem_insert_iff.1 this with h|h · rw [h] exact isOpen_empty · exact T_open _ h · intro x hx obtain ⟨v, hv, h'v⟩ : ∃ v, v ∈ T ∧ x ∈ v := by simpa only [mem_iUnion, exists_prop] using sT hx have : v ∈ range u := by rw [← hu]; exact subset_insert ∅ T hv obtain ⟨n, rfl⟩ : ∃ n, u n = v := by simpa only [mem_range] using this exact mem_iUnion_of_mem _ h'v · intro n have : u n ∈ T' := by rw [hu]; exact mem_range_self n rcases mem_insert_iff.1 this with h|h · simp only [h, empty_inter, integrableOn_empty] · exact hT _ h theorem LocallyIntegrableOn.aestronglyMeasurable [PseudoMetrizableSpace ε] [SecondCountableTopology X] (hf : LocallyIntegrableOn f s μ) : AEStronglyMeasurable f (μ.restrict s) := by rcases hf.exists_nat_integrableOn with ⟨u, -, su, hu⟩ have : s = ⋃ n, u n ∩ s := by rw [← iUnion_inter]; exact (inter_eq_right.mpr su).symm rw [this, aestronglyMeasurable_iUnion_iff] exact fun i : ℕ => (hu i).aestronglyMeasurable /-- If `s` is locally closed (e.g. open or closed), then `f` is locally integrable on `s` iff it is integrable on every compact subset contained in `s`. -/ theorem locallyIntegrableOn_iff [PseudoMetrizableSpace ε] [LocallyCompactSpace X] (hs : IsLocallyClosed s) : LocallyIntegrableOn f s μ ↔ ∀ (k : Set X), k ⊆ s → IsCompact k → IntegrableOn f k μ := by refine ⟨fun hf k hk ↦ hf.integrableOn_compact_subset hk, fun hf x hx ↦ ?_⟩ rcases hs with ⟨U, Z, hU, hZ, rfl⟩ rcases exists_compact_subset hU hx.1 with ⟨K, hK, hxK, hKU⟩ rw [nhdsWithin_inter_of_mem (nhdsWithin_le_nhds <| hU.mem_nhds hx.1)] refine ⟨Z ∩ K, inter_mem_nhdsWithin _ (mem_interior_iff_mem_nhds.1 hxK), ?_⟩ exact hf (Z ∩ K) (fun y hy ↦ ⟨hKU hy.2, hy.1⟩) (.inter_left hK hZ) protected theorem LocallyIntegrableOn.add [ContinuousAdd ε''] {f g : X → ε''} (hf : LocallyIntegrableOn f s μ) (hg : LocallyIntegrableOn g s μ) : LocallyIntegrableOn (f + g) s μ := fun x hx ↦ (hf x hx).add (hg x hx) -- TODO: once mathlib has a ENormedAddCommSubMonoid, generalise this lemma also protected theorem LocallyIntegrableOn.sub {f g : X → E} (hf : LocallyIntegrableOn f s μ) (hg : LocallyIntegrableOn g s μ) : LocallyIntegrableOn (f - g) s μ := fun x hx ↦ (hf x hx).sub (hg x hx) protected theorem LocallyIntegrableOn.neg {f : X → E} (hf : LocallyIntegrableOn f s μ) : LocallyIntegrableOn (-f) s μ := fun x hx ↦ (hf x hx).neg end LocallyIntegrableOn /-- A function `f : X → ε` is *locally integrable* if it is integrable on a neighborhood of every point. In particular, it is integrable on all compact sets, see `LocallyIntegrable.integrableOn_isCompact`. -/ def LocallyIntegrable (f : X → ε) (μ : Measure X := by volume_tac) : Prop := ∀ x : X, IntegrableAtFilter f (𝓝 x) μ theorem locallyIntegrable_comap (hs : MeasurableSet s) : LocallyIntegrable (fun x : s ↦ f x) (μ.comap Subtype.val) ↔ LocallyIntegrableOn f s μ := by simp_rw [LocallyIntegrableOn, Subtype.forall', ← map_nhds_subtype_val] exact forall_congr' fun _ ↦ (MeasurableEmbedding.subtype_coe hs).integrableAtFilter_iff_comap.symm theorem locallyIntegrableOn_univ : LocallyIntegrableOn f univ μ ↔ LocallyIntegrable f μ := by simp only [LocallyIntegrableOn, nhdsWithin_univ, mem_univ, true_imp_iff]; rfl theorem LocallyIntegrable.locallyIntegrableOn (hf : LocallyIntegrable f μ) (s : Set X) : LocallyIntegrableOn f s μ := fun x _ => (hf x).filter_mono nhdsWithin_le_nhds theorem Integrable.locallyIntegrable (hf : Integrable f μ) : LocallyIntegrable f μ := fun _ => hf.integrableAtFilter _ theorem LocallyIntegrable.mono_enorm (hf : LocallyIntegrable f μ) {g : X → ε'} (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ x ∂μ, ‖g x‖ₑ ≤ ‖f x‖ₑ) : LocallyIntegrable g μ := by rw [← locallyIntegrableOn_univ] at hf ⊢ exact hf.mono_enorm hg h theorem LocallyIntegrable.mono {f : X → E} (hf : LocallyIntegrable f μ) {g : X → F} (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ x ∂μ, ‖g x‖ ≤ ‖f x‖) : LocallyIntegrable g μ := by rw [← locallyIntegrableOn_univ] at hf ⊢ exact hf.mono hg h /-- If `f` is locally integrable with respect to `μ.restrict s`, it is locally integrable on `s`. (See `locallyIntegrableOn_iff_locallyIntegrable_restrict` for an iff statement when `s` is closed.) -/ theorem locallyIntegrableOn_of_locallyIntegrable_restrict [OpensMeasurableSpace X] (hf : LocallyIntegrable f (μ.restrict s)) : LocallyIntegrableOn f s μ := by intro x _ obtain ⟨t, ht_mem, ht_int⟩ := hf x obtain ⟨u, hu_sub, hu_o, hu_mem⟩ := mem_nhds_iff.mp ht_mem refine ⟨_, inter_mem_nhdsWithin s (hu_o.mem_nhds hu_mem), ?_⟩ simpa only [IntegrableOn, Measure.restrict_restrict hu_o.measurableSet, inter_comm] using ht_int.mono_set hu_sub /-- If `s` is closed, being locally integrable on `s` w.r.t. `μ` is equivalent to being locally integrable with respect to `μ.restrict s`. For the one-way implication without assuming `s` closed, see `locallyIntegrableOn_of_locallyIntegrable_restrict`. -/ theorem locallyIntegrableOn_iff_locallyIntegrable_restrict [OpensMeasurableSpace X] (hs : IsClosed s) : LocallyIntegrableOn f s μ ↔ LocallyIntegrable f (μ.restrict s) := by refine ⟨fun hf x => ?_, locallyIntegrableOn_of_locallyIntegrable_restrict⟩ by_cases h : x ∈ s · obtain ⟨t, ht_nhds, ht_int⟩ := hf x h obtain ⟨u, hu_o, hu_x, hu_sub⟩ := mem_nhdsWithin.mp ht_nhds refine ⟨u, hu_o.mem_nhds hu_x, ?_⟩ rw [IntegrableOn, restrict_restrict hu_o.measurableSet] exact ht_int.mono_set hu_sub · rw [← isOpen_compl_iff] at hs refine ⟨sᶜ, hs.mem_nhds h, ?_⟩ rw [IntegrableOn, restrict_restrict, inter_comm, inter_compl_self, ← IntegrableOn] exacts [integrableOn_empty, hs.measurableSet] /-- If a function is locally integrable, then it is integrable on any compact set. -/ theorem LocallyIntegrable.integrableOn_isCompact [PseudoMetrizableSpace ε] {k : Set X} (hf : LocallyIntegrable f μ) (hk : IsCompact k) : IntegrableOn f k μ := (hf.locallyIntegrableOn k).integrableOn_isCompact hk /-- If a function is locally integrable, then it is integrable on an open neighborhood of any compact set. -/ theorem LocallyIntegrable.integrableOn_nhds_isCompact [PseudoMetrizableSpace ε] (hf : LocallyIntegrable f μ) {k : Set X} (hk : IsCompact k) : ∃ u, IsOpen u ∧ k ⊆ u ∧ IntegrableOn f u μ := by refine IsCompact.induction_on hk ?_ ?_ ?_ ?_ · refine ⟨∅, isOpen_empty, Subset.rfl, integrableOn_empty⟩ · rintro s t hst ⟨u, u_open, tu, hu⟩ exact ⟨u, u_open, hst.trans tu, hu⟩ · rintro s t ⟨u, u_open, su, hu⟩ ⟨v, v_open, tv, hv⟩ exact ⟨u ∪ v, u_open.union v_open, union_subset_union su tv, hu.union hv⟩ · intro x _ rcases hf x with ⟨u, ux, hu⟩ rcases mem_nhds_iff.1 ux with ⟨v, vu, v_open, xv⟩ exact ⟨v, nhdsWithin_le_nhds (v_open.mem_nhds xv), v, v_open, Subset.rfl, hu.mono_set vu⟩ theorem locallyIntegrable_iff [PseudoMetrizableSpace ε] [LocallyCompactSpace X] : LocallyIntegrable f μ ↔ ∀ k : Set X, IsCompact k → IntegrableOn f k μ := ⟨fun hf _k hk => hf.integrableOn_isCompact hk, fun hf x => let ⟨K, hK, h2K⟩ := exists_compact_mem_nhds x ⟨K, h2K, hf K hK⟩⟩ theorem LocallyIntegrable.aestronglyMeasurable [PseudoMetrizableSpace ε] [SecondCountableTopology X] (hf : LocallyIntegrable f μ) : AEStronglyMeasurable f μ := by simpa only [restrict_univ] using (locallyIntegrableOn_univ.mpr hf).aestronglyMeasurable /-- If a function is locally integrable in a second countable topological space, then there exists a sequence of open sets covering the space on which it is integrable. -/ theorem LocallyIntegrable.exists_nat_integrableOn [SecondCountableTopology X] (hf : LocallyIntegrable f μ) : ∃ u : ℕ → Set X, (∀ n, IsOpen (u n)) ∧ ((⋃ n, u n) = univ) ∧ (∀ n, IntegrableOn f (u n) μ) := by rcases (hf.locallyIntegrableOn univ).exists_nat_integrableOn with ⟨u, u_open, u_union, hu⟩ refine ⟨u, u_open, eq_univ_of_univ_subset u_union, fun n ↦ ?_⟩ simpa only [inter_univ] using hu n theorem MemLp.locallyIntegrable [IsLocallyFiniteMeasure μ] {p : ℝ≥0∞} (hf : MemLp f p μ) (hp : 1 ≤ p) : LocallyIntegrable f μ := by intro x rcases μ.finiteAt_nhds x with ⟨U, hU, h'U⟩ have : Fact (μ U < ⊤) := ⟨h'U⟩ refine ⟨U, hU, ?_⟩ rw [IntegrableOn, ← memLp_one_iff_integrable] apply (hf.restrict U).mono_exponent hp theorem locallyIntegrable_const_enorm [IsLocallyFiniteMeasure μ] {c : ε} (hc : ‖c‖ₑ ≠ ∞) : LocallyIntegrable (fun _ => c) μ := (memLp_top_const_enorm hc).locallyIntegrable le_top theorem locallyIntegrable_const [IsLocallyFiniteMeasure μ] (c : E) : LocallyIntegrable (fun _ => c) μ := locallyIntegrable_const_enorm enorm_ne_top theorem locallyIntegrableOn_const_enorm [IsLocallyFiniteMeasure μ] {c : ε} (hc : ‖c‖ₑ ≠ ∞) : LocallyIntegrableOn (fun _ => c) s μ := (locallyIntegrable_const_enorm hc).locallyIntegrableOn s theorem locallyIntegrableOn_const [IsLocallyFiniteMeasure μ] (c : E) : LocallyIntegrableOn (fun _ => c) s μ := locallyIntegrableOn_const_enorm enorm_ne_top theorem locallyIntegrable_zero : LocallyIntegrable (fun _ ↦ (0 : ε'')) μ := (integrable_zero X ε'' μ).locallyIntegrable theorem locallyIntegrableOn_zero : LocallyIntegrableOn (fun _ ↦ (0 : ε'')) s μ := locallyIntegrable_zero.locallyIntegrableOn s theorem LocallyIntegrable.indicator {f : X → ε''} (hf : LocallyIntegrable f μ) {s : Set X} (hs : MeasurableSet s) : LocallyIntegrable (s.indicator f) μ := by intro x rcases hf x with ⟨U, hU, h'U⟩ exact ⟨U, hU, h'U.indicator hs⟩ theorem locallyIntegrable_map_homeomorph [BorelSpace X] [BorelSpace Y] (e : X ≃ₜ Y) {f : Y → ε''} {μ : Measure X} : LocallyIntegrable f (Measure.map e μ) ↔ LocallyIntegrable (f ∘ e) μ := by refine ⟨fun h x => ?_, fun h x => ?_⟩ · rcases h (e x) with ⟨U, hU, h'U⟩ refine ⟨e ⁻¹' U, e.continuous.continuousAt.preimage_mem_nhds hU, ?_⟩ exact (integrableOn_map_equiv e.toMeasurableEquiv).1 h'U · rcases h (e.symm x) with ⟨U, hU, h'U⟩ refine ⟨e.symm ⁻¹' U, e.symm.continuous.continuousAt.preimage_mem_nhds hU, ?_⟩ apply (integrableOn_map_equiv e.toMeasurableEquiv).2 simp only [Homeomorph.toMeasurableEquiv_coe] convert h'U ext x simp only [mem_preimage, Homeomorph.symm_apply_apply] protected theorem LocallyIntegrable.add [ContinuousAdd ε''] {f g : X → ε''} (hf : LocallyIntegrable f μ) (hg : LocallyIntegrable g μ) : LocallyIntegrable (f + g) μ := fun x ↦ (hf x).add (hg x) protected theorem LocallyIntegrable.sub {f g : X → E} (hf : LocallyIntegrable f μ) (hg : LocallyIntegrable g μ) : LocallyIntegrable (f - g) μ := fun x ↦ (hf x).sub (hg x) protected theorem LocallyIntegrable.neg {f : X → E} (hf : LocallyIntegrable f μ) : LocallyIntegrable (-f) μ := fun x ↦ (hf x).neg protected theorem LocallyIntegrable.smul {f : X → E} {𝕜 : Type*} [NormedAddCommGroup 𝕜] [SMulZeroClass 𝕜 E] [IsBoundedSMul 𝕜 E] (hf : LocallyIntegrable f μ) (c : 𝕜) : LocallyIntegrable (c • f) μ := fun x ↦ (hf x).smul c variable {ε''' : Type*} [TopologicalSpace ε'''] [ESeminormedAddCommMonoid ε'''] [ContinuousAdd ε'''] in theorem locallyIntegrable_finset_sum' {ι} (s : Finset ι) {f : ι → X → ε'''} (hf : ∀ i ∈ s, LocallyIntegrable (f i) μ) : LocallyIntegrable (∑ i ∈ s, f i) μ := Finset.sum_induction f (fun g => LocallyIntegrable g μ) (fun _ _ => LocallyIntegrable.add) locallyIntegrable_zero hf variable {ε''' : Type*} [TopologicalSpace ε'''] [ESeminormedAddCommMonoid ε'''] [ContinuousAdd ε'''] in theorem locallyIntegrable_finset_sum {ι} (s : Finset ι) {f : ι → X → ε'''} (hf : ∀ i ∈ s, LocallyIntegrable (f i) μ) : LocallyIntegrable (fun a ↦ ∑ i ∈ s, f i a) μ := by simpa only [← Finset.sum_apply] using locallyIntegrable_finset_sum' s hf /-- If `f` is locally integrable and `g` is continuous with compact support, then `g • f` is integrable. -/ theorem LocallyIntegrable.integrable_smul_left_of_hasCompactSupport {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] [OpensMeasurableSpace X] [T2Space X] {f : X → E} (hf : LocallyIntegrable f μ) {g : X → 𝕜} (hg : Continuous g) (h'g : HasCompactSupport g) : Integrable (fun x ↦ g x • f x) μ := by let K := tsupport g have hK : IsCompact K := h'g have : K.indicator (fun x ↦ g x • f x) = (fun x ↦ g x • f x) := by apply indicator_eq_self.2 apply support_subset_iff'.2 intro x hx simp [image_eq_zero_of_notMem_tsupport hx] rw [← this, indicator_smul] apply Integrable.smul_of_top_right · rw [integrable_indicator_iff hK.measurableSet] exact hf.integrableOn_isCompact hK · exact hg.memLp_top_of_hasCompactSupport h'g μ /-- If `f` is locally integrable and `g` is continuous with compact support, then `f • g` is integrable. -/ theorem LocallyIntegrable.integrable_smul_right_of_hasCompactSupport {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] [OpensMeasurableSpace X] [T2Space X] {f : X → 𝕜} (hf : LocallyIntegrable f μ) {g : X → E} (hg : Continuous g) (h'g : HasCompactSupport g) : Integrable (fun x ↦ f x • g x) μ := by let K := tsupport g have hK : IsCompact K := h'g have : K.indicator (fun x ↦ f x • g x) = (fun x ↦ f x • g x) := by apply indicator_eq_self.2 apply support_subset_iff'.2 intro x hx simp [image_eq_zero_of_notMem_tsupport hx] rw [← this, indicator_smul_left] apply Integrable.smul_of_top_left · rw [integrable_indicator_iff hK.measurableSet] exact hf.integrableOn_isCompact hK · exact hg.memLp_top_of_hasCompactSupport h'g μ open Filter variable [PseudoMetrizableSpace ε] theorem integrable_iff_integrableAtFilter_cocompact : Integrable f μ ↔ (IntegrableAtFilter f (cocompact X) μ ∧ LocallyIntegrable f μ) := by refine ⟨fun hf ↦ ⟨hf.integrableAtFilter _, hf.locallyIntegrable⟩, fun ⟨⟨s, hsc, hs⟩, hloc⟩ ↦ ?_⟩ obtain ⟨t, htc, ht⟩ := mem_cocompact'.mp hsc rewrite [← integrableOn_univ, ← compl_union_self s, integrableOn_union] exact ⟨(hloc.integrableOn_isCompact htc).mono ht le_rfl, hs⟩ theorem integrable_iff_integrableAtFilter_atBot_atTop [PseudoMetrizableSpace ε''] {f : X → ε''} [LinearOrder X] [CompactIccSpace X] : Integrable f μ ↔ (IntegrableAtFilter f atBot μ ∧ IntegrableAtFilter f atTop μ) ∧ LocallyIntegrable f μ := by constructor · exact fun hf ↦ ⟨⟨hf.integrableAtFilter _, hf.integrableAtFilter _⟩, hf.locallyIntegrable⟩ · refine fun h ↦ integrable_iff_integrableAtFilter_cocompact.mpr ⟨?_, h.2⟩ exact (IntegrableAtFilter.sup_iff.mpr h.1).filter_mono cocompact_le_atBot_atTop theorem integrable_iff_integrableAtFilter_atBot [LinearOrder X] [OrderTop X] [CompactIccSpace X] : Integrable f μ ↔ IntegrableAtFilter f atBot μ ∧ LocallyIntegrable f μ := by constructor · exact fun hf ↦ ⟨hf.integrableAtFilter _, hf.locallyIntegrable⟩ · refine fun h ↦ integrable_iff_integrableAtFilter_cocompact.mpr ⟨?_, h.2⟩ exact h.1.filter_mono cocompact_le_atBot theorem integrable_iff_integrableAtFilter_atTop [LinearOrder X] [OrderBot X] [CompactIccSpace X] : Integrable f μ ↔ IntegrableAtFilter f atTop μ ∧ LocallyIntegrable f μ := integrable_iff_integrableAtFilter_atBot (X := Xᵒᵈ) variable {a : X} theorem integrableOn_Iic_iff_integrableAtFilter_atBot [LinearOrder X] [CompactIccSpace X] : IntegrableOn f (Iic a) μ ↔ IntegrableAtFilter f atBot μ ∧ LocallyIntegrableOn f (Iic a) μ := by refine ⟨fun h ↦ ⟨⟨Iic a, Iic_mem_atBot a, h⟩, h.locallyIntegrableOn⟩, fun ⟨⟨s, hsl, hs⟩, h⟩ ↦ ?_⟩ haveI : Nonempty X := Nonempty.intro a obtain ⟨a', ha'⟩ := mem_atBot_sets.mp hsl refine (integrableOn_union.mpr ⟨hs.mono ha' le_rfl, ?_⟩).mono Iic_subset_Iic_union_Icc le_rfl exact h.integrableOn_compact_subset Icc_subset_Iic_self isCompact_Icc theorem integrableOn_Ici_iff_integrableAtFilter_atTop [LinearOrder X] [CompactIccSpace X] : IntegrableOn f (Ici a) μ ↔ IntegrableAtFilter f atTop μ ∧ LocallyIntegrableOn f (Ici a) μ := integrableOn_Iic_iff_integrableAtFilter_atBot (X := Xᵒᵈ) theorem integrableOn_Iio_iff_integrableAtFilter_atBot_nhdsWithin [LinearOrder X] [CompactIccSpace X] [NoMinOrder X] [OrderTopology X] : IntegrableOn f (Iio a) μ ↔ IntegrableAtFilter f atBot μ ∧ IntegrableAtFilter f (𝓝[<] a) μ ∧ LocallyIntegrableOn f (Iio a) μ := by constructor · intro h exact ⟨⟨Iio a, Iio_mem_atBot a, h⟩, ⟨Iio a, self_mem_nhdsWithin, h⟩, h.locallyIntegrableOn⟩ · intro ⟨hbot, ⟨s, hsl, hs⟩, hlocal⟩ obtain ⟨s', ⟨hs'_mono, hs'⟩⟩ := mem_nhdsLT_iff_exists_Ioo_subset.mp hsl refine (integrableOn_union.mpr ⟨?_, hs.mono hs' le_rfl⟩).mono Iio_subset_Iic_union_Ioo le_rfl exact integrableOn_Iic_iff_integrableAtFilter_atBot.mpr ⟨hbot, hlocal.mono_set (Iic_subset_Iio.mpr hs'_mono)⟩ theorem integrableOn_Ioi_iff_integrableAtFilter_atTop_nhdsWithin [LinearOrder X] [CompactIccSpace X] [NoMaxOrder X] [OrderTopology X] : IntegrableOn f (Ioi a) μ ↔ IntegrableAtFilter f atTop μ ∧ IntegrableAtFilter f (𝓝[>] a) μ ∧ LocallyIntegrableOn f (Ioi a) μ := integrableOn_Iio_iff_integrableAtFilter_atBot_nhdsWithin (X := Xᵒᵈ) end MeasureTheory open MeasureTheory section borel variable [OpensMeasurableSpace X] variable {K : Set X} {f : X → E} {a b : X} /-- A continuous function `f` is locally integrable with respect to any locally finite measure. -/ theorem Continuous.locallyIntegrable [IsLocallyFiniteMeasure μ] [SecondCountableTopologyEither X E] (hf : Continuous f) : LocallyIntegrable f μ := hf.integrableAt_nhds /-- A function `f` continuous on a set `K` is locally integrable on this set with respect to any locally finite measure. -/ theorem ContinuousOn.locallyIntegrableOn [IsLocallyFiniteMeasure μ] [SecondCountableTopologyEither X E] (hf : ContinuousOn f K) (hK : MeasurableSet K) : LocallyIntegrableOn f K μ := fun _x hx => hf.integrableAt_nhdsWithin hK hx variable [IsFiniteMeasureOnCompacts μ] /-- A function `f` continuous on a compact set `K` is integrable on this set with respect to any locally finite measure. -/ theorem ContinuousOn.integrableOn_compact' (hK : IsCompact K) (h'K : MeasurableSet K) (hf : ContinuousOn f K) : IntegrableOn f K μ := by refine ⟨ContinuousOn.aestronglyMeasurable_of_isCompact hf hK h'K, ?_⟩ have : Fact (μ K < ∞) := ⟨hK.measure_lt_top⟩ obtain ⟨C, hC⟩ : ∃ C, ∀ x ∈ f '' K, ‖x‖ ≤ C := IsBounded.exists_norm_le (hK.image_of_continuousOn hf).isBounded apply HasFiniteIntegral.of_bounded (C := C) filter_upwards [ae_restrict_mem h'K] with x hx using hC _ (mem_image_of_mem f hx) theorem ContinuousOn.integrableOn_compact [T2Space X] (hK : IsCompact K) (hf : ContinuousOn f K) : IntegrableOn f K μ := hf.integrableOn_compact' hK hK.measurableSet theorem ContinuousOn.integrableOn_Icc [Preorder X] [CompactIccSpace X] [T2Space X] (hf : ContinuousOn f (Icc a b)) : IntegrableOn f (Icc a b) μ := hf.integrableOn_compact isCompact_Icc theorem Continuous.integrableOn_Icc [Preorder X] [CompactIccSpace X] [T2Space X] (hf : Continuous f) : IntegrableOn f (Icc a b) μ := hf.continuousOn.integrableOn_Icc theorem Continuous.integrableOn_Ioc [Preorder X] [CompactIccSpace X] [T2Space X] (hf : Continuous f) : IntegrableOn f (Ioc a b) μ := hf.integrableOn_Icc.mono_set Ioc_subset_Icc_self theorem ContinuousOn.integrableOn_uIcc [LinearOrder X] [CompactIccSpace X] [T2Space X] (hf : ContinuousOn f [[a, b]]) : IntegrableOn f [[a, b]] μ := hf.integrableOn_Icc theorem Continuous.integrableOn_uIcc [LinearOrder X] [CompactIccSpace X] [T2Space X] (hf : Continuous f) : IntegrableOn f [[a, b]] μ := hf.integrableOn_Icc open scoped Interval in theorem Continuous.integrableOn_uIoc [LinearOrder X] [CompactIccSpace X] [T2Space X] (hf : Continuous f) : IntegrableOn f (Ι a b) μ := hf.integrableOn_Ioc /-- A continuous function with compact support is integrable on the whole space. -/ theorem Continuous.integrable_of_hasCompactSupport (hf : Continuous f) (hcf : HasCompactSupport f) : Integrable f μ := (integrableOn_iff_integrable_of_support_subset (subset_tsupport f)).mp <| hf.continuousOn.integrableOn_compact' hcf (isClosed_tsupport _).measurableSet end borel open scoped ENNReal section Monotone variable [BorelSpace X] [ConditionallyCompleteLinearOrder X] [ConditionallyCompleteLinearOrder E] [OrderTopology X] [OrderTopology E] [SecondCountableTopology E] {p : ℝ≥0∞} {f : X → E} theorem MonotoneOn.memLp_top (hmono : MonotoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (h's : MeasurableSet s) : MemLp f ∞ (μ.restrict s) := by borelize E have hbelow : BddBelow (f '' s) := ⟨f a, fun x ⟨y, hy, hyx⟩ => hyx ▸ hmono ha.1 hy (ha.2 hy)⟩ have habove : BddAbove (f '' s) := ⟨f b, fun x ⟨y, hy, hyx⟩ => hyx ▸ hmono hy hb.1 (hb.2 hy)⟩ have : IsBounded (f '' s) := Metric.isBounded_of_bddAbove_of_bddBelow habove hbelow rcases isBounded_iff_forall_norm_le.mp this with ⟨C, hC⟩ have A : MemLp (fun _ => C) ⊤ (μ.restrict s) := memLp_top_const _ apply MemLp.mono A (aemeasurable_restrict_of_monotoneOn h's hmono).aestronglyMeasurable apply (ae_restrict_iff' h's).mpr apply ae_of_all _ fun y hy ↦ ?_ exact (hC _ (mem_image_of_mem f hy)).trans (le_abs_self _) theorem MonotoneOn.memLp_of_measure_ne_top (hmono : MonotoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (hs : μ s ≠ ∞) (h's : MeasurableSet s) : MemLp f p (μ.restrict s) := (hmono.memLp_top ha hb h's).mono_exponent_of_measure_support_ne_top (s := univ) (by simp) (by simpa using hs) le_top theorem MonotoneOn.memLp_isCompact [IsFiniteMeasureOnCompacts μ] (hs : IsCompact s) (hmono : MonotoneOn f s) : MemLp f p (μ.restrict s) := by obtain rfl | h := s.eq_empty_or_nonempty · simp · exact hmono.memLp_of_measure_ne_top (hs.isLeast_sInf h) (hs.isGreatest_sSup h) hs.measure_lt_top.ne hs.measurableSet theorem AntitoneOn.memLp_top (hanti : AntitoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (h's : MeasurableSet s) : MemLp f ∞ (μ.restrict s) := MonotoneOn.memLp_top (E := Eᵒᵈ) hanti ha hb h's theorem AntitoneOn.memLp_of_measure_ne_top (hanti : AntitoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (hs : μ s ≠ ∞) (h's : MeasurableSet s) : MemLp f p (μ.restrict s) := MonotoneOn.memLp_of_measure_ne_top (E := Eᵒᵈ) hanti ha hb hs h's theorem AntitoneOn.memLp_isCompact [IsFiniteMeasureOnCompacts μ] (hs : IsCompact s) (hanti : AntitoneOn f s) : MemLp f p (μ.restrict s) := MonotoneOn.memLp_isCompact (E := Eᵒᵈ) hs hanti theorem MonotoneOn.integrableOn_of_measure_ne_top (hmono : MonotoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (hs : μ s ≠ ∞) (h's : MeasurableSet s) : IntegrableOn f s μ := memLp_one_iff_integrable.1 (hmono.memLp_of_measure_ne_top ha hb hs h's) theorem MonotoneOn.integrableOn_isCompact [IsFiniteMeasureOnCompacts μ] (hs : IsCompact s) (hmono : MonotoneOn f s) : IntegrableOn f s μ := memLp_one_iff_integrable.1 (hmono.memLp_isCompact hs) theorem AntitoneOn.integrableOn_of_measure_ne_top (hanti : AntitoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (hs : μ s ≠ ∞) (h's : MeasurableSet s) : IntegrableOn f s μ := memLp_one_iff_integrable.1 (hanti.memLp_of_measure_ne_top ha hb hs h's) theorem AntitoneOn.integrableOn_isCompact [IsFiniteMeasureOnCompacts μ] (hs : IsCompact s) (hanti : AntitoneOn f s) : IntegrableOn f s μ := memLp_one_iff_integrable.1 (hanti.memLp_isCompact hs) theorem Monotone.locallyIntegrable [IsLocallyFiniteMeasure μ] (hmono : Monotone f) : LocallyIntegrable f μ := by intro x rcases μ.finiteAt_nhds x with ⟨U, hU, h'U⟩ obtain ⟨a, b, xab, hab, abU⟩ : ∃ a b : X, x ∈ Icc a b ∧ Icc a b ∈ 𝓝 x ∧ Icc a b ⊆ U := exists_Icc_mem_subset_of_mem_nhds hU have ab : a ≤ b := xab.1.trans xab.2 refine ⟨Icc a b, hab, ?_⟩ exact (hmono.monotoneOn _).integrableOn_of_measure_ne_top (isLeast_Icc ab) (isGreatest_Icc ab) ((measure_mono abU).trans_lt h'U).ne measurableSet_Icc theorem Antitone.locallyIntegrable [IsLocallyFiniteMeasure μ] (hanti : Antitone f) : LocallyIntegrable f μ := hanti.dual_right.locallyIntegrable end Monotone namespace MeasureTheory variable [OpensMeasurableSpace X] {A K : Set X} section Mul variable [NormedRing R] [SecondCountableTopologyEither X R] {g g' : X → R} theorem IntegrableOn.mul_continuousOn_of_subset (hg : IntegrableOn g A μ) (hg' : ContinuousOn g' K) (hA : MeasurableSet A) (hK : IsCompact K) (hAK : A ⊆ K) : IntegrableOn (fun x => g x * g' x) A μ := by rcases IsCompact.exists_bound_of_continuousOn hK hg' with ⟨C, hC⟩ rw [IntegrableOn, ← memLp_one_iff_integrable] at hg ⊢ have : ∀ᵐ x ∂μ.restrict A, ‖g x * g' x‖ ≤ C * ‖g x‖ := by filter_upwards [ae_restrict_mem hA] with x hx refine (norm_mul_le _ _).trans ?_ rw [mul_comm] gcongr exact hC x (hAK hx) exact MemLp.of_le_mul hg (hg.aestronglyMeasurable.mul <| (hg'.mono hAK).aestronglyMeasurable hA) this theorem IntegrableOn.mul_continuousOn [T2Space X] (hg : IntegrableOn g K μ) (hg' : ContinuousOn g' K) (hK : IsCompact K) : IntegrableOn (fun x => g x * g' x) K μ := hg.mul_continuousOn_of_subset hg' hK.measurableSet hK (Subset.refl _) theorem IntegrableOn.continuousOn_mul_of_subset (hg : ContinuousOn g K) (hg' : IntegrableOn g' A μ) (hK : IsCompact K) (hA : MeasurableSet A) (hAK : A ⊆ K) : IntegrableOn (fun x => g x * g' x) A μ := by rcases IsCompact.exists_bound_of_continuousOn hK hg with ⟨C, hC⟩ rw [IntegrableOn, ← memLp_one_iff_integrable] at hg' ⊢ have : ∀ᵐ x ∂μ.restrict A, ‖g x * g' x‖ ≤ C * ‖g' x‖ := by filter_upwards [ae_restrict_mem hA] with x hx refine (norm_mul_le _ _).trans ?_ gcongr exact hC x (hAK hx) exact MemLp.of_le_mul hg' (((hg.mono hAK).aestronglyMeasurable hA).mul hg'.aestronglyMeasurable) this theorem IntegrableOn.continuousOn_mul [T2Space X] (hg : ContinuousOn g K) (hg' : IntegrableOn g' K μ) (hK : IsCompact K) : IntegrableOn (fun x => g x * g' x) K μ := hg'.continuousOn_mul_of_subset hg hK hK.measurableSet Subset.rfl end Mul section SMul variable {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 E] [NormSMulClass 𝕜 E] theorem IntegrableOn.continuousOn_smul_of_subset [SecondCountableTopologyEither X 𝕜] {f : X → 𝕜} (hf : ContinuousOn f K) {g : X → E} (hg : IntegrableOn g A μ) (hK : IsCompact K) (hA : MeasurableSet A) (hAK : A ⊆ K) : IntegrableOn (fun x => f x • g x) A μ := by rcases IsCompact.exists_bound_of_continuousOn hK hf with ⟨C, hC⟩ rw [IntegrableOn, ← memLp_one_iff_integrable] at hg ⊢ have : ∀ᵐ x ∂μ.restrict A, ‖f x • g x‖ ≤ C * ‖g x‖ := by filter_upwards [ae_restrict_mem hA] with x hx refine (norm_smul_le _ _).trans ?_ gcongr exact hC x (hAK hx) exact MemLp.of_le_mul hg (((hf.mono hAK).aestronglyMeasurable hA).smul hg.aestronglyMeasurable) this theorem IntegrableOn.continuousOn_smul [T2Space X] [SecondCountableTopologyEither X 𝕜] {g : X → E} (hg : IntegrableOn g K μ) {f : X → 𝕜} (hf : ContinuousOn f K) (hK : IsCompact K) : IntegrableOn (fun x => f x • g x) K μ := hg.continuousOn_smul_of_subset hf hK hK.measurableSet Subset.rfl theorem IntegrableOn.smul_continuousOn_of_subset [SecondCountableTopologyEither X E] {f : X → 𝕜} (hf : IntegrableOn f A μ) {g : X → E} (hg : ContinuousOn g K) (hA : MeasurableSet A) (hK : IsCompact K) (hAK : A ⊆ K) : IntegrableOn (fun x => f x • g x) A μ := by rcases IsCompact.exists_bound_of_continuousOn hK hg with ⟨C, hC⟩ rw [IntegrableOn, ← memLp_one_iff_integrable] at hf ⊢ have : ∀ᵐ x ∂μ.restrict A, ‖f x • g x‖ ≤ C * ‖f x‖ := by filter_upwards [ae_restrict_mem hA] with x hx refine (norm_smul_le _ _).trans ?_ rw [mul_comm] gcongr exact hC x (hAK hx) exact MemLp.of_le_mul hf (hf.aestronglyMeasurable.smul <| (hg.mono hAK).aestronglyMeasurable hA) this theorem IntegrableOn.smul_continuousOn [T2Space X] [SecondCountableTopologyEither X E] {f : X → 𝕜} (hf : IntegrableOn f K μ) {g : X → E} (hg : ContinuousOn g K) (hK : IsCompact K) : IntegrableOn (fun x => f x • g x) K μ := hf.smul_continuousOn_of_subset hg hK.measurableSet hK (Subset.refl _) end SMul namespace LocallyIntegrableOn theorem continuousOn_mul [LocallyCompactSpace X] [T2Space X] [NormedRing R] [SecondCountableTopologyEither X R] {f g : X → R} {s : Set X} (hf : LocallyIntegrableOn f s μ) (hg : ContinuousOn g s) (hs : IsLocallyClosed s) : LocallyIntegrableOn (fun x => g x * f x) s μ := by rw [MeasureTheory.locallyIntegrableOn_iff hs] at hf ⊢ exact fun k hk_sub hk_c => (hf k hk_sub hk_c).continuousOn_mul (hg.mono hk_sub) hk_c theorem mul_continuousOn [LocallyCompactSpace X] [T2Space X] [NormedRing R] [SecondCountableTopologyEither X R] {f g : X → R} {s : Set X} (hf : LocallyIntegrableOn f s μ) (hg : ContinuousOn g s) (hs : IsLocallyClosed s) : LocallyIntegrableOn (fun x => f x * g x) s μ := by rw [MeasureTheory.locallyIntegrableOn_iff hs] at hf ⊢ exact fun k hk_sub hk_c => (hf k hk_sub hk_c).mul_continuousOn (hg.mono hk_sub) hk_c theorem continuousOn_smul [LocallyCompactSpace X] [T2Space X] {𝕜 : Type*} [NormedRing 𝕜] [SecondCountableTopologyEither X 𝕜] [Module 𝕜 E] [NormSMulClass 𝕜 E] {f : X → E} {g : X → 𝕜} {s : Set X} (hs : IsLocallyClosed s) (hf : LocallyIntegrableOn f s μ) (hg : ContinuousOn g s) : LocallyIntegrableOn (fun x => g x • f x) s μ := by rw [MeasureTheory.locallyIntegrableOn_iff hs] at hf ⊢ exact fun k hk_sub hk_c => (hf k hk_sub hk_c).continuousOn_smul (hg.mono hk_sub) hk_c theorem smul_continuousOn [LocallyCompactSpace X] [T2Space X] {𝕜 : Type*} [NormedRing 𝕜] [SecondCountableTopologyEither X E] [Module 𝕜 E] [NormSMulClass 𝕜 E] {f : X → 𝕜} {g : X → E} {s : Set X} (hs : IsLocallyClosed s) (hf : LocallyIntegrableOn f s μ) (hg : ContinuousOn g s) : LocallyIntegrableOn (fun x => f x • g x) s μ := by rw [MeasureTheory.locallyIntegrableOn_iff hs] at hf ⊢ exact fun k hk_sub hk_c => (hf k hk_sub hk_c).smul_continuousOn (hg.mono hk_sub) hk_c end LocallyIntegrableOn end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/Floor.lean
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order /-! # Measurability of `⌊x⌋` etc In this file we prove that `Int.floor`, `Int.ceil`, `Int.fract`, `Nat.floor`, and `Nat.ceil` are measurable under some assumptions on the (semi)ring. -/ open Set section FloorRing variable {α R : Type*} [MeasurableSpace α] [Ring R] [LinearOrder R] [FloorRing R] [TopologicalSpace R] [OrderTopology R] [MeasurableSpace R] theorem Int.measurable_floor [OpensMeasurableSpace R] : Measurable (Int.floor : R → ℤ) := measurable_to_countable fun x => by simpa only [Int.preimage_floor_singleton] using measurableSet_Ico @[measurability, fun_prop] theorem Measurable.floor [OpensMeasurableSpace R] {f : α → R} (hf : Measurable f) : Measurable fun x => ⌊f x⌋ := Int.measurable_floor.comp hf theorem Int.measurable_ceil [OpensMeasurableSpace R] : Measurable (Int.ceil : R → ℤ) := measurable_to_countable fun x => by simpa only [Int.preimage_ceil_singleton] using measurableSet_Ioc @[measurability, fun_prop] theorem Measurable.ceil [OpensMeasurableSpace R] {f : α → R} (hf : Measurable f) : Measurable fun x => ⌈f x⌉ := Int.measurable_ceil.comp hf theorem measurable_fract [IsStrictOrderedRing R] [BorelSpace R] : Measurable (Int.fract : R → R) := by intro s hs rw [Int.preimage_fract] exact MeasurableSet.iUnion fun z => measurable_id.sub_const _ (hs.inter measurableSet_Ico) @[measurability, fun_prop] theorem Measurable.fract [IsStrictOrderedRing R] [BorelSpace R] {f : α → R} (hf : Measurable f) : Measurable fun x => Int.fract (f x) := measurable_fract.comp hf theorem MeasurableSet.image_fract [IsStrictOrderedRing R] [BorelSpace R] {s : Set R} (hs : MeasurableSet s) : MeasurableSet (Int.fract '' s) := by simp only [Int.image_fract, sub_eq_add_neg, image_add_right'] exact MeasurableSet.iUnion fun m => (measurable_add_const _ hs).inter measurableSet_Ico end FloorRing section FloorSemiring variable {α R : Type*} [MeasurableSpace α] [Semiring R] [LinearOrder R] [FloorSemiring R] [TopologicalSpace R] [OrderTopology R] [MeasurableSpace R] [OpensMeasurableSpace R] {f : α → R} theorem Nat.measurable_floor [IsStrictOrderedRing R] : Measurable (Nat.floor : R → ℕ) := measurable_to_countable fun n => by rcases eq_or_ne ⌊n⌋₊ 0 with h | h <;> simp [h, Nat.preimage_floor_of_ne_zero, -floor_eq_zero] @[measurability, fun_prop] theorem Measurable.nat_floor [IsStrictOrderedRing R] (hf : Measurable f) : Measurable fun x => ⌊f x⌋₊ := Nat.measurable_floor.comp hf theorem Nat.measurable_ceil : Measurable (Nat.ceil : R → ℕ) := measurable_to_countable fun n => by rcases eq_or_ne ⌈n⌉₊ 0 with h | h <;> simp_all [Nat.preimage_ceil_of_ne_zero, -ceil_eq_zero] @[measurability, fun_prop] theorem Measurable.nat_ceil (hf : Measurable f) : Measurable fun x => ⌈f x⌉₊ := Nat.measurable_ceil.comp hf end FloorSemiring
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SimpleFuncDenseLp.lean
import Mathlib.MeasureTheory.Function.L1Space.AEEqFun import Mathlib.MeasureTheory.Function.LpSpace.Complete import Mathlib.MeasureTheory.Function.LpSpace.Indicator /-! # Density of simple functions Show that each `Lᵖ` Borel measurable function can be approximated in `Lᵖ` norm by a sequence of simple functions. ## Main definitions * `MeasureTheory.Lp.simpleFunc`, the type of `Lp` simple functions * `coeToLp`, the embedding of `Lp.simpleFunc E p μ` into `Lp E p μ` ## Main results * `tendsto_approxOn_Lp_eLpNorm` (Lᵖ convergence): If `E` is a `NormedAddCommGroup` and `f` is measurable and `MemLp` (for `p < ∞`), then the simple functions `SimpleFunc.approxOn f hf s 0 h₀ n` may be considered as elements of `Lp E p μ`, and they tend in Lᵖ to `f`. * `Lp.simpleFunc.isDenseEmbedding`: the embedding `coeToLp` of the `Lp` simple functions into `Lp` is dense. * `Lp.simpleFunc.induction`, `Lp.induction`, `MemLp.induction`, `Integrable.induction`: to prove a predicate for all elements of one of these classes of functions, it suffices to check that it behaves correctly on simple functions. ## TODO For `E` finite-dimensional, simple functions `α →ₛ E` are dense in L^∞ -- prove this. ## Notation * `α →ₛ β` (local notation): the type of simple functions `α → β`. * `α →₁ₛ[μ] E`: the type of `L1` simple functions `α → β`. -/ noncomputable section open Set Function Filter TopologicalSpace ENNReal EMetric Finset open scoped Topology ENNReal MeasureTheory variable {α β ι E F 𝕜 : Type*} namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc /-! ### Lp approximation by simple functions -/ section Lp variable [MeasurableSpace β] [MeasurableSpace E] [NormedAddCommGroup E] [NormedAddCommGroup F] {q : ℝ} {p : ℝ≥0∞} theorem nnnorm_approxOn_le [OpensMeasurableSpace E] {f : β → E} (hf : Measurable f) {s : Set E} {y₀ : E} (h₀ : y₀ ∈ s) [SeparableSpace s] (x : β) (n : ℕ) : ‖approxOn f hf s y₀ h₀ n x - f x‖₊ ≤ ‖f x - y₀‖₊ := by have := edist_approxOn_le hf h₀ x n rw [edist_comm y₀] at this simp only [edist_nndist, nndist_eq_nnnorm] at this exact mod_cast this theorem norm_approxOn_y₀_le [OpensMeasurableSpace E] {f : β → E} (hf : Measurable f) {s : Set E} {y₀ : E} (h₀ : y₀ ∈ s) [SeparableSpace s] (x : β) (n : ℕ) : ‖approxOn f hf s y₀ h₀ n x - y₀‖ ≤ ‖f x - y₀‖ + ‖f x - y₀‖ := by simpa [enorm, edist_eq_enorm_sub, ← ENNReal.coe_add, norm_sub_rev] using edist_approxOn_y0_le hf h₀ x n theorem norm_approxOn_zero_le [OpensMeasurableSpace E] {f : β → E} (hf : Measurable f) {s : Set E} (h₀ : (0 : E) ∈ s) [SeparableSpace s] (x : β) (n : ℕ) : ‖approxOn f hf s 0 h₀ n x‖ ≤ ‖f x‖ + ‖f x‖ := by simpa [enorm, edist_eq_enorm_sub, ← ENNReal.coe_add, norm_sub_rev] using edist_approxOn_y0_le hf h₀ x n theorem tendsto_approxOn_Lp_eLpNorm [OpensMeasurableSpace E] {f : β → E} (hf : Measurable f) {s : Set E} {y₀ : E} (h₀ : y₀ ∈ s) [SeparableSpace s] (hp_ne_top : p ≠ ∞) {μ : Measure β} (hμ : ∀ᵐ x ∂μ, f x ∈ closure s) (hi : eLpNorm (fun x => f x - y₀) p μ < ∞) : Tendsto (fun n => eLpNorm (⇑(approxOn f hf s y₀ h₀ n) - f) p μ) atTop (𝓝 0) := by by_cases hp_zero : p = 0 · simpa only [hp_zero, eLpNorm_exponent_zero] using tendsto_const_nhds have hp : 0 < p.toReal := toReal_pos hp_zero hp_ne_top suffices Tendsto (fun n => ∫⁻ x, ‖approxOn f hf s y₀ h₀ n x - f x‖ₑ ^ p.toReal ∂μ) atTop (𝓝 0) by simp only [eLpNorm_eq_lintegral_rpow_enorm hp_zero hp_ne_top] convert continuous_rpow_const.continuousAt.tendsto.comp this simp [zero_rpow_of_pos (_root_.inv_pos.mpr hp)] -- We simply check the conditions of the Dominated Convergence Theorem: -- (1) The function "`p`-th power of distance between `f` and the approximation" is measurable have hF_meas n : Measurable fun x => ‖approxOn f hf s y₀ h₀ n x - f x‖ₑ ^ p.toReal := by simpa only [← edist_eq_enorm_sub] using (approxOn f hf s y₀ h₀ n).measurable_bind (fun y x => edist y (f x) ^ p.toReal) fun y => (measurable_edist_right.comp hf).pow_const p.toReal -- (2) The functions "`p`-th power of distance between `f` and the approximation" are uniformly -- bounded, at any given point, by `fun x => ‖f x - y₀‖ ^ p.toReal` have h_bound n : (fun x ↦ ‖approxOn f hf s y₀ h₀ n x - f x‖ₑ ^ p.toReal) ≤ᵐ[μ] (‖f · - y₀‖ₑ ^ p.toReal) := .of_forall fun x => rpow_le_rpow (coe_mono (nnnorm_approxOn_le hf h₀ x n)) toReal_nonneg -- (3) The bounding function `fun x => ‖f x - y₀‖ ^ p.toReal` has finite integral have h_fin : (∫⁻ a : β, ‖f a - y₀‖ₑ ^ p.toReal ∂μ) ≠ ⊤ := (lintegral_rpow_enorm_lt_top_of_eLpNorm_lt_top hp_zero hp_ne_top hi).ne -- (4) The functions "`p`-th power of distance between `f` and the approximation" tend pointwise -- to zero have h_lim : ∀ᵐ a : β ∂μ, Tendsto (‖approxOn f hf s y₀ h₀ · a - f a‖ₑ ^ p.toReal) atTop (𝓝 0) := by filter_upwards [hμ] with a ha have : Tendsto (fun n => (approxOn f hf s y₀ h₀ n) a - f a) atTop (𝓝 (f a - f a)) := (tendsto_approxOn hf h₀ ha).sub tendsto_const_nhds convert continuous_rpow_const.continuousAt.tendsto.comp (tendsto_coe.mpr this.nnnorm) simp [zero_rpow_of_pos hp] -- Then we apply the Dominated Convergence Theorem simpa using tendsto_lintegral_of_dominated_convergence _ hF_meas h_bound h_fin h_lim theorem memLp_approxOn [BorelSpace E] {f : β → E} {μ : Measure β} (fmeas : Measurable f) (hf : MemLp f p μ) {s : Set E} {y₀ : E} (h₀ : y₀ ∈ s) [SeparableSpace s] (hi₀ : MemLp (fun _ => y₀) p μ) (n : ℕ) : MemLp (approxOn f fmeas s y₀ h₀ n) p μ := by refine ⟨(approxOn f fmeas s y₀ h₀ n).aestronglyMeasurable, ?_⟩ suffices eLpNorm (fun x => approxOn f fmeas s y₀ h₀ n x - y₀) p μ < ⊤ by have : MemLp (fun x => approxOn f fmeas s y₀ h₀ n x - y₀) p μ := ⟨(approxOn f fmeas s y₀ h₀ n - const β y₀).aestronglyMeasurable, this⟩ convert eLpNorm_add_lt_top this hi₀ ext x simp have hf' : MemLp (fun x => ‖f x - y₀‖) p μ := by have h_meas : Measurable fun x => ‖f x - y₀‖ := by simp only [← dist_eq_norm] exact (continuous_id.dist continuous_const).measurable.comp fmeas refine ⟨h_meas.aemeasurable.aestronglyMeasurable, ?_⟩ rw [eLpNorm_norm] convert eLpNorm_add_lt_top hf hi₀.neg with x simp [sub_eq_add_neg] have : ∀ᵐ x ∂μ, ‖approxOn f fmeas s y₀ h₀ n x - y₀‖ ≤ ‖‖f x - y₀‖ + ‖f x - y₀‖‖ := by filter_upwards with x convert norm_approxOn_y₀_le fmeas h₀ x n using 1 rw [Real.norm_eq_abs, abs_of_nonneg] positivity calc eLpNorm (fun x => approxOn f fmeas s y₀ h₀ n x - y₀) p μ ≤ eLpNorm (fun x => ‖f x - y₀‖ + ‖f x - y₀‖) p μ := eLpNorm_mono_ae this _ < ⊤ := eLpNorm_add_lt_top hf' hf' theorem tendsto_approxOn_range_Lp_eLpNorm [BorelSpace E] {f : β → E} (hp_ne_top : p ≠ ∞) {μ : Measure β} (fmeas : Measurable f) [SeparableSpace (range f ∪ {0} : Set E)] (hf : eLpNorm f p μ < ∞) : Tendsto (fun n => eLpNorm (⇑(approxOn f fmeas (range f ∪ {0}) 0 (by simp) n) - f) p μ) atTop (𝓝 0) := by refine tendsto_approxOn_Lp_eLpNorm fmeas _ hp_ne_top ?_ ?_ · filter_upwards with x using subset_closure (by simp) · simpa using hf theorem memLp_approxOn_range [BorelSpace E] {f : β → E} {μ : Measure β} (fmeas : Measurable f) [SeparableSpace (range f ∪ {0} : Set E)] (hf : MemLp f p μ) (n : ℕ) : MemLp (approxOn f fmeas (range f ∪ {0}) 0 (by simp) n) p μ := memLp_approxOn fmeas hf (y₀ := 0) (by simp) MemLp.zero n theorem tendsto_approxOn_range_Lp [BorelSpace E] {f : β → E} [hp : Fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) {μ : Measure β} (fmeas : Measurable f) [SeparableSpace (range f ∪ {0} : Set E)] (hf : MemLp f p μ) : Tendsto (fun n => (memLp_approxOn_range fmeas hf n).toLp (approxOn f fmeas (range f ∪ {0}) 0 (by simp) n)) atTop (𝓝 (hf.toLp f)) := by simpa only [Lp.tendsto_Lp_iff_tendsto_eLpNorm''] using tendsto_approxOn_range_Lp_eLpNorm hp_ne_top fmeas hf.2 /-- Any function in `ℒp` can be approximated by a simple function if `p < ∞`. -/ theorem _root_.MeasureTheory.MemLp.exists_simpleFunc_eLpNorm_sub_lt {E : Type*} [NormedAddCommGroup E] {f : β → E} {μ : Measure β} (hf : MemLp f p μ) (hp_ne_top : p ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : β →ₛ E, eLpNorm (f - ⇑g) p μ < ε ∧ MemLp g p μ := by borelize E let f' := hf.1.mk f rsuffices ⟨g, hg, g_mem⟩ : ∃ g : β →ₛ E, eLpNorm (f' - ⇑g) p μ < ε ∧ MemLp g p μ · refine ⟨g, ?_, g_mem⟩ suffices eLpNorm (f - ⇑g) p μ = eLpNorm (f' - ⇑g) p μ by rwa [this] apply eLpNorm_congr_ae filter_upwards [hf.1.ae_eq_mk] with x hx simpa only [Pi.sub_apply, sub_left_inj] using hx have hf' : MemLp f' p μ := hf.ae_eq hf.1.ae_eq_mk have f'meas : Measurable f' := hf.1.measurable_mk have : SeparableSpace (range f' ∪ {0} : Set E) := StronglyMeasurable.separableSpace_range_union_singleton hf.1.stronglyMeasurable_mk rcases ((tendsto_approxOn_range_Lp_eLpNorm hp_ne_top f'meas hf'.2).eventually <| gt_mem_nhds hε.bot_lt).exists with ⟨n, hn⟩ rw [← eLpNorm_neg, neg_sub] at hn exact ⟨_, hn, memLp_approxOn_range f'meas hf' _⟩ end Lp /-! ### L1 approximation by simple functions -/ section Integrable variable [MeasurableSpace β] variable [MeasurableSpace E] [NormedAddCommGroup E] theorem tendsto_approxOn_L1_enorm [OpensMeasurableSpace E] {f : β → E} (hf : Measurable f) {s : Set E} {y₀ : E} (h₀ : y₀ ∈ s) [SeparableSpace s] {μ : Measure β} (hμ : ∀ᵐ x ∂μ, f x ∈ closure s) (hi : HasFiniteIntegral (fun x => f x - y₀) μ) : Tendsto (fun n => ∫⁻ x, ‖approxOn f hf s y₀ h₀ n x - f x‖ₑ ∂μ) atTop (𝓝 0) := by simpa [eLpNorm_one_eq_lintegral_enorm] using tendsto_approxOn_Lp_eLpNorm hf h₀ one_ne_top hμ (by simpa [eLpNorm_one_eq_lintegral_enorm] using hi) theorem integrable_approxOn [BorelSpace E] {f : β → E} {μ : Measure β} (fmeas : Measurable f) (hf : Integrable f μ) {s : Set E} {y₀ : E} (h₀ : y₀ ∈ s) [SeparableSpace s] (hi₀ : Integrable (fun _ => y₀) μ) (n : ℕ) : Integrable (approxOn f fmeas s y₀ h₀ n) μ := by rw [← memLp_one_iff_integrable] at hf hi₀ ⊢ exact memLp_approxOn fmeas hf h₀ hi₀ n theorem tendsto_approxOn_range_L1_enorm [OpensMeasurableSpace E] {f : β → E} {μ : Measure β} [SeparableSpace (range f ∪ {0} : Set E)] (fmeas : Measurable f) (hf : Integrable f μ) : Tendsto (fun n => ∫⁻ x, ‖approxOn f fmeas (range f ∪ {0}) 0 (by simp) n x - f x‖ₑ ∂μ) atTop (𝓝 0) := by apply tendsto_approxOn_L1_enorm fmeas · filter_upwards with x using subset_closure (by simp) · simpa using hf.2 theorem integrable_approxOn_range [BorelSpace E] {f : β → E} {μ : Measure β} (fmeas : Measurable f) [SeparableSpace (range f ∪ {0} : Set E)] (hf : Integrable f μ) (n : ℕ) : Integrable (approxOn f fmeas (range f ∪ {0}) 0 (by simp) n) μ := integrable_approxOn fmeas hf _ (integrable_zero _ _ _) n end Integrable section SimpleFuncProperties variable [MeasurableSpace α] variable [NormedAddCommGroup E] [NormedAddCommGroup F] variable {μ : Measure α} {p : ℝ≥0∞} /-! ### Properties of simple functions in `Lp` spaces A simple function `f : α →ₛ E` into a normed group `E` verifies, for a measure `μ`: - `MemLp f 0 μ` and `MemLp f ∞ μ`, since `f` is a.e.-measurable and bounded, - for `0 < p < ∞`, `MemLp f p μ ↔ Integrable f μ ↔ f.FinMeasSupp μ ↔ ∀ y, y ≠ 0 → μ (f ⁻¹' {y}) < ∞`. -/ theorem exists_forall_norm_le (f : α →ₛ F) : ∃ C, ∀ x, ‖f x‖ ≤ C := exists_forall_le (f.map fun x => ‖x‖) theorem memLp_zero (f : α →ₛ E) (μ : Measure α) : MemLp f 0 μ := memLp_zero_iff_aestronglyMeasurable.mpr f.aestronglyMeasurable theorem memLp_top (f : α →ₛ E) (μ : Measure α) : MemLp f ∞ μ := let ⟨C, hfC⟩ := f.exists_forall_norm_le memLp_top_of_bound f.aestronglyMeasurable C <| Eventually.of_forall hfC protected theorem eLpNorm'_eq {p : ℝ} (f : α →ₛ F) (μ : Measure α) : eLpNorm' f p μ = (∑ y ∈ f.range, ‖y‖ₑ ^ p * μ (f ⁻¹' {y})) ^ (1 / p) := by have h_map : (‖f ·‖ₑ ^ p) = f.map (‖·‖ₑ ^ p) := by simp; rfl rw [eLpNorm'_eq_lintegral_enorm, h_map, lintegral_eq_lintegral, map_lintegral] theorem measure_preimage_lt_top_of_memLp (hp_pos : p ≠ 0) (hp_ne_top : p ≠ ∞) (f : α →ₛ E) (hf : MemLp f p μ) (y : E) (hy_ne : y ≠ 0) : μ (f ⁻¹' {y}) < ∞ := by have hp_pos_real : 0 < p.toReal := ENNReal.toReal_pos hp_pos hp_ne_top have hf_eLpNorm := MemLp.eLpNorm_lt_top hf rw [eLpNorm_eq_eLpNorm' hp_pos hp_ne_top, f.eLpNorm'_eq, one_div, ← @ENNReal.lt_rpow_inv_iff _ _ p.toReal⁻¹ (by simp [hp_pos_real]), @ENNReal.top_rpow_of_pos p.toReal⁻¹⁻¹ (by simp [hp_pos_real]), ENNReal.sum_lt_top] at hf_eLpNorm by_cases hyf : y ∈ f.range swap · suffices h_empty : f ⁻¹' {y} = ∅ by rw [h_empty, measure_empty]; exact ENNReal.coe_lt_top ext1 x rw [Set.mem_preimage, Set.mem_singleton_iff, mem_empty_iff_false, iff_false] refine fun hxy => hyf ?_ rw [mem_range, Set.mem_range] exact ⟨x, hxy⟩ specialize hf_eLpNorm y hyf rw [ENNReal.mul_lt_top_iff] at hf_eLpNorm cases hf_eLpNorm with | inl hf_eLpNorm => exact hf_eLpNorm.2 | inr hf_eLpNorm => cases hf_eLpNorm with | inl hf_eLpNorm => refine absurd ?_ hy_ne simpa [hp_pos_real] using hf_eLpNorm | inr hf_eLpNorm => simp [hf_eLpNorm] theorem memLp_of_finite_measure_preimage (p : ℝ≥0∞) {f : α →ₛ E} (hf : ∀ y, y ≠ 0 → μ (f ⁻¹' {y}) < ∞) : MemLp f p μ := by by_cases hp0 : p = 0 · rw [hp0, memLp_zero_iff_aestronglyMeasurable]; exact f.aestronglyMeasurable by_cases hp_top : p = ∞ · rw [hp_top]; exact memLp_top f μ refine ⟨f.aestronglyMeasurable, ?_⟩ rw [eLpNorm_eq_eLpNorm' hp0 hp_top, f.eLpNorm'_eq] refine ENNReal.rpow_lt_top_of_nonneg (by simp) (ENNReal.sum_lt_top.mpr fun y _ => ?_).ne by_cases hy0 : y = 0 · simp [hy0, ENNReal.toReal_pos hp0 hp_top] · refine ENNReal.mul_lt_top ?_ (hf y hy0) exact ENNReal.rpow_lt_top_of_nonneg ENNReal.toReal_nonneg ENNReal.coe_ne_top theorem memLp_iff {f : α →ₛ E} (hp_pos : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp f p μ ↔ ∀ y, y ≠ 0 → μ (f ⁻¹' {y}) < ∞ := ⟨fun h => measure_preimage_lt_top_of_memLp hp_pos hp_ne_top f h, fun h => memLp_of_finite_measure_preimage p h⟩ theorem integrable_iff {f : α →ₛ E} : Integrable f μ ↔ ∀ y, y ≠ 0 → μ (f ⁻¹' {y}) < ∞ := memLp_one_iff_integrable.symm.trans <| memLp_iff one_ne_zero ENNReal.coe_ne_top theorem memLp_iff_integrable {f : α →ₛ E} (hp_pos : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp f p μ ↔ Integrable f μ := (memLp_iff hp_pos hp_ne_top).trans integrable_iff.symm theorem memLp_iff_finMeasSupp {f : α →ₛ E} (hp_pos : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp f p μ ↔ f.FinMeasSupp μ := (memLp_iff hp_pos hp_ne_top).trans finMeasSupp_iff.symm theorem integrable_iff_finMeasSupp {f : α →ₛ E} : Integrable f μ ↔ f.FinMeasSupp μ := integrable_iff.trans finMeasSupp_iff.symm theorem FinMeasSupp.integrable {f : α →ₛ E} (h : f.FinMeasSupp μ) : Integrable f μ := integrable_iff_finMeasSupp.2 h theorem integrable_pair {f : α →ₛ E} {g : α →ₛ F} : Integrable f μ → Integrable g μ → Integrable (pair f g) μ := by simpa only [integrable_iff_finMeasSupp] using FinMeasSupp.pair theorem memLp_of_isFiniteMeasure (f : α →ₛ E) (p : ℝ≥0∞) (μ : Measure α) [IsFiniteMeasure μ] : MemLp f p μ := let ⟨C, hfC⟩ := f.exists_forall_norm_le MemLp.of_bound f.aestronglyMeasurable C <| Eventually.of_forall hfC @[fun_prop] theorem integrable_of_isFiniteMeasure [IsFiniteMeasure μ] (f : α →ₛ E) : Integrable f μ := memLp_one_iff_integrable.mp (f.memLp_of_isFiniteMeasure 1 μ) theorem measure_preimage_lt_top_of_integrable (f : α →ₛ E) (hf : Integrable f μ) {x : E} (hx : x ≠ 0) : μ (f ⁻¹' {x}) < ∞ := integrable_iff.mp hf x hx theorem measure_support_lt_top_of_memLp (f : α →ₛ E) (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : μ (support f) < ∞ := f.measure_support_lt_top ((memLp_iff hp_ne_zero hp_ne_top).mp hf) theorem measure_support_lt_top_of_integrable (f : α →ₛ E) (hf : Integrable f μ) : μ (support f) < ∞ := f.measure_support_lt_top (integrable_iff.mp hf) theorem measure_lt_top_of_memLp_indicator (hp_pos : p ≠ 0) (hp_ne_top : p ≠ ∞) {c : E} (hc : c ≠ 0) {s : Set α} (hs : MeasurableSet s) (hcs : MemLp ((const α c).piecewise s hs (const α 0)) p μ) : μ s < ⊤ := by have : Function.support (const α c) = Set.univ := Function.support_const hc simpa only [memLp_iff_finMeasSupp hp_pos hp_ne_top, finMeasSupp_iff_support, support_indicator, Set.inter_univ, this] using hcs end SimpleFuncProperties end SimpleFunc /-! Construction of the space of `Lp` simple functions, and its dense embedding into `Lp`. -/ namespace Lp open AEEqFun variable [MeasurableSpace α] [NormedAddCommGroup E] [NormedAddCommGroup F] (p : ℝ≥0∞) (μ : Measure α) variable (E) /-- `Lp.simpleFunc` is a subspace of Lp consisting of equivalence classes of an integrable simple function. -/ def simpleFunc : AddSubgroup (Lp E p μ) where carrier := { f : Lp E p μ | ∃ s : α →ₛ E, (AEEqFun.mk s s.aestronglyMeasurable : α →ₘ[μ] E) = f } zero_mem' := ⟨0, rfl⟩ add_mem' := by rintro f g ⟨s, hs⟩ ⟨t, ht⟩ use s + t simp only [← hs, ← ht, AEEqFun.mk_add_mk, AddSubgroup.coe_add, SimpleFunc.coe_add] neg_mem' := by rintro f ⟨s, hs⟩ use -s simp only [← hs, AEEqFun.neg_mk, SimpleFunc.coe_neg, AddSubgroup.coe_neg] variable {E p μ} namespace simpleFunc section Instances /-! Simple functions in Lp space form a `NormedSpace`. -/ protected theorem eq' {f g : Lp.simpleFunc E p μ} : (f : α →ₘ[μ] E) = (g : α →ₘ[μ] E) → f = g := Subtype.eq ∘ Subtype.eq /-! Implementation note: If `Lp.simpleFunc E p μ` were defined as a `𝕜`-submodule of `Lp E p μ`, then the next few lemmas, putting a normed `𝕜`-group structure on `Lp.simpleFunc E p μ`, would be unnecessary. But instead, `Lp.simpleFunc E p μ` is defined as an `AddSubgroup` of `Lp E p μ`, which does not permit this (but has the advantage of working when `E` itself is a normed group, i.e. has no scalar action). -/ variable [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] /-- If `E` is a normed space, `Lp.simpleFunc E p μ` is a `SMul`. Not declared as an instance as it is (as of writing) used only in the construction of the Bochner integral. -/ protected def smul : SMul 𝕜 (Lp.simpleFunc E p μ) := ⟨fun k f => ⟨k • (f : Lp E p μ), by rcases f with ⟨f, ⟨s, hs⟩⟩ use k • s apply Eq.trans (AEEqFun.smul_mk k s s.aestronglyMeasurable).symm _ rw [hs] rfl⟩⟩ attribute [local instance] simpleFunc.smul @[simp, norm_cast] theorem coe_smul (c : 𝕜) (f : Lp.simpleFunc E p μ) : ((c • f : Lp.simpleFunc E p μ) : Lp E p μ) = c • (f : Lp E p μ) := rfl /-- If `E` is a normed space, `Lp.simpleFunc E p μ` is a module. Not declared as an instance as it is (as of writing) used only in the construction of the Bochner integral. -/ protected def module : Module 𝕜 (Lp.simpleFunc E p μ) where one_smul f := by ext1; exact one_smul _ _ mul_smul x y f := by ext1; exact mul_smul _ _ _ smul_add x f g := by ext1; exact smul_add _ _ _ smul_zero x := by ext1; exact smul_zero _ add_smul x y f := by ext1; exact add_smul _ _ _ zero_smul f := by ext1; exact zero_smul _ _ attribute [local instance] simpleFunc.module /-- If `E` is a normed space, `Lp.simpleFunc E p μ` is a normed space. Not declared as an instance as it is (as of writing) used only in the construction of the Bochner integral. -/ protected theorem isBoundedSMul [Fact (1 ≤ p)] : IsBoundedSMul 𝕜 (Lp.simpleFunc E p μ) := IsBoundedSMul.of_norm_smul_le fun r f => (norm_smul_le r (f : Lp E p μ) :) attribute [local instance] simpleFunc.isBoundedSMul /-- If `E` is a normed space, `Lp.simpleFunc E p μ` is a normed space. Not declared as an instance as it is (as of writing) used only in the construction of the Bochner integral. -/ protected def normedSpace {𝕜} [NormedField 𝕜] [NormedSpace 𝕜 E] [Fact (1 ≤ p)] : NormedSpace 𝕜 (Lp.simpleFunc E p μ) := ⟨norm_smul_le (α := 𝕜) (β := Lp.simpleFunc E p μ)⟩ end Instances attribute [local instance] simpleFunc.module simpleFunc.normedSpace simpleFunc.isBoundedSMul section ToLp /-- Construct the equivalence class `[f]` of a simple function `f` satisfying `MemLp`. -/ abbrev toLp (f : α →ₛ E) (hf : MemLp f p μ) : Lp.simpleFunc E p μ := ⟨hf.toLp f, ⟨f, rfl⟩⟩ theorem toLp_eq_toLp (f : α →ₛ E) (hf : MemLp f p μ) : (toLp f hf : Lp E p μ) = hf.toLp f := rfl theorem toLp_eq_mk (f : α →ₛ E) (hf : MemLp f p μ) : (toLp f hf : α →ₘ[μ] E) = AEEqFun.mk f f.aestronglyMeasurable := rfl theorem toLp_zero : toLp (0 : α →ₛ E) MemLp.zero = (0 : Lp.simpleFunc E p μ) := rfl theorem toLp_add (f g : α →ₛ E) (hf : MemLp f p μ) (hg : MemLp g p μ) : toLp (f + g) (hf.add hg) = toLp f hf + toLp g hg := rfl theorem toLp_neg (f : α →ₛ E) (hf : MemLp f p μ) : toLp (-f) hf.neg = -toLp f hf := rfl theorem toLp_sub (f g : α →ₛ E) (hf : MemLp f p μ) (hg : MemLp g p μ) : toLp (f - g) (hf.sub hg) = toLp f hf - toLp g hg := by simp only [sub_eq_add_neg, ← toLp_neg, ← toLp_add] variable [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] theorem toLp_smul (f : α →ₛ E) (hf : MemLp f p μ) (c : 𝕜) : toLp (c • f) (hf.const_smul c) = c • toLp f hf := rfl nonrec theorem norm_toLp [Fact (1 ≤ p)] (f : α →ₛ E) (hf : MemLp f p μ) : ‖toLp f hf‖ = ENNReal.toReal (eLpNorm f p μ) := norm_toLp f hf end ToLp section ToSimpleFunc /-- Find a representative of a `Lp.simpleFunc`. -/ def toSimpleFunc (f : Lp.simpleFunc E p μ) : α →ₛ E := Classical.choose f.2 /-- `(toSimpleFunc f)` is measurable. -/ @[measurability] protected theorem measurable [MeasurableSpace E] (f : Lp.simpleFunc E p μ) : Measurable (toSimpleFunc f) := (toSimpleFunc f).measurable protected theorem stronglyMeasurable (f : Lp.simpleFunc E p μ) : StronglyMeasurable (toSimpleFunc f) := (toSimpleFunc f).stronglyMeasurable @[measurability] protected theorem aemeasurable [MeasurableSpace E] (f : Lp.simpleFunc E p μ) : AEMeasurable (toSimpleFunc f) μ := (simpleFunc.measurable f).aemeasurable protected theorem aestronglyMeasurable (f : Lp.simpleFunc E p μ) : AEStronglyMeasurable (toSimpleFunc f) μ := (simpleFunc.stronglyMeasurable f).aestronglyMeasurable theorem toSimpleFunc_eq_toFun (f : Lp.simpleFunc E p μ) : toSimpleFunc f =ᵐ[μ] f := show ⇑(toSimpleFunc f) =ᵐ[μ] ⇑(f : α →ₘ[μ] E) by convert (AEEqFun.coeFn_mk (toSimpleFunc f) (toSimpleFunc f).aestronglyMeasurable).symm using 2 exact (Classical.choose_spec f.2).symm /-- `toSimpleFunc f` satisfies the predicate `MemLp`. -/ protected theorem memLp (f : Lp.simpleFunc E p μ) : MemLp (toSimpleFunc f) p μ := MemLp.ae_eq (toSimpleFunc_eq_toFun f).symm <| mem_Lp_iff_memLp.mp (f : Lp E p μ).2 theorem toLp_toSimpleFunc (f : Lp.simpleFunc E p μ) : toLp (toSimpleFunc f) (simpleFunc.memLp f) = f := simpleFunc.eq' (Classical.choose_spec f.2) theorem toSimpleFunc_toLp (f : α →ₛ E) (hfi : MemLp f p μ) : toSimpleFunc (toLp f hfi) =ᵐ[μ] f := by rw [← AEEqFun.mk_eq_mk]; exact Classical.choose_spec (toLp f hfi).2 variable (E μ) theorem zero_toSimpleFunc : toSimpleFunc (0 : Lp.simpleFunc E p μ) =ᵐ[μ] 0 := by filter_upwards [toSimpleFunc_eq_toFun (0 : Lp.simpleFunc E p μ), Lp.coeFn_zero E 1 μ] with _ h₁ _ rwa [h₁] variable {E μ} theorem add_toSimpleFunc (f g : Lp.simpleFunc E p μ) : toSimpleFunc (f + g) =ᵐ[μ] toSimpleFunc f + toSimpleFunc g := by filter_upwards [toSimpleFunc_eq_toFun (f + g), toSimpleFunc_eq_toFun f, toSimpleFunc_eq_toFun g, Lp.coeFn_add (f : Lp E p μ) g] with _ simp only [AddSubgroup.coe_add, Pi.add_apply] iterate 4 intro h; rw [h] theorem neg_toSimpleFunc (f : Lp.simpleFunc E p μ) : toSimpleFunc (-f) =ᵐ[μ] -toSimpleFunc f := by filter_upwards [toSimpleFunc_eq_toFun (-f), toSimpleFunc_eq_toFun f, Lp.coeFn_neg (f : Lp E p μ)] with _ simp only [Pi.neg_apply, AddSubgroup.coe_neg] repeat intro h; rw [h] theorem sub_toSimpleFunc (f g : Lp.simpleFunc E p μ) : toSimpleFunc (f - g) =ᵐ[μ] toSimpleFunc f - toSimpleFunc g := by filter_upwards [toSimpleFunc_eq_toFun (f - g), toSimpleFunc_eq_toFun f, toSimpleFunc_eq_toFun g, Lp.coeFn_sub (f : Lp E p μ) g] with _ simp only [AddSubgroup.coe_sub, Pi.sub_apply] repeat' intro h; rw [h] variable [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] theorem smul_toSimpleFunc (k : 𝕜) (f : Lp.simpleFunc E p μ) : toSimpleFunc (k • f) =ᵐ[μ] k • ⇑(toSimpleFunc f) := by filter_upwards [toSimpleFunc_eq_toFun (k • f), toSimpleFunc_eq_toFun f, Lp.coeFn_smul k (f : Lp E p μ)] with _ simp only [Pi.smul_apply, coe_smul] repeat intro h; rw [h] theorem norm_toSimpleFunc [Fact (1 ≤ p)] (f : Lp.simpleFunc E p μ) : ‖f‖ = ENNReal.toReal (eLpNorm (toSimpleFunc f) p μ) := by simpa [toLp_toSimpleFunc] using norm_toLp (toSimpleFunc f) (simpleFunc.memLp f) end ToSimpleFunc section Induction variable (p) in /-- The characteristic function of a finite-measure measurable set `s`, as an `Lp` simple function. -/ def indicatorConst {s : Set α} (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : E) : Lp.simpleFunc E p μ := toLp ((SimpleFunc.const _ c).piecewise s hs (SimpleFunc.const _ 0)) (memLp_indicator_const p hs c (Or.inr hμs)) @[simp] theorem coe_indicatorConst {s : Set α} (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : E) : (↑(indicatorConst p hs hμs c) : Lp E p μ) = indicatorConstLp p hs hμs c := rfl theorem toSimpleFunc_indicatorConst {s : Set α} (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : E) : toSimpleFunc (indicatorConst p hs hμs c) =ᵐ[μ] (SimpleFunc.const _ c).piecewise s hs (SimpleFunc.const _ 0) := Lp.simpleFunc.toSimpleFunc_toLp _ _ /-- To prove something for an arbitrary `Lp` simple function, with `0 < p < ∞`, it suffices to show that the property holds for (multiples of) characteristic functions of finite-measure measurable sets and is closed under addition (of functions with disjoint support). -/ @[elab_as_elim] protected theorem induction (hp_pos : p ≠ 0) (hp_ne_top : p ≠ ∞) {P : Lp.simpleFunc E p μ → Prop} (indicatorConst : ∀ (c : E) {s : Set α} (hs : MeasurableSet s) (hμs : μ s < ∞), P (Lp.simpleFunc.indicatorConst p hs hμs.ne c)) (add : ∀ ⦃f g : α →ₛ E⦄, ∀ hf : MemLp f p μ, ∀ hg : MemLp g p μ, Disjoint (support f) (support g) → P (Lp.simpleFunc.toLp f hf) → P (Lp.simpleFunc.toLp g hg) → P (Lp.simpleFunc.toLp f hf + Lp.simpleFunc.toLp g hg)) (f : Lp.simpleFunc E p μ) : P f := by suffices ∀ f : α →ₛ E, ∀ hf : MemLp f p μ, P (toLp f hf) by rw [← toLp_toSimpleFunc f] apply this clear f apply SimpleFunc.induction · intro c s hs hf by_cases hc : c = 0 · convert indicatorConst 0 MeasurableSet.empty (by simp) using 1 ext1 simp [hc] exact indicatorConst c hs (SimpleFunc.measure_lt_top_of_memLp_indicator hp_pos hp_ne_top hc hs hf) · intro f g hfg hf hg hfg' obtain ⟨hf', hg'⟩ : MemLp f p μ ∧ MemLp g p μ := (memLp_add_of_disjoint hfg f.stronglyMeasurable g.stronglyMeasurable).mp hfg' exact add hf' hg' hfg (hf hf') (hg hg') end Induction section CoeToLp variable [Fact (1 ≤ p)] protected theorem uniformContinuous : UniformContinuous ((↑) : Lp.simpleFunc E p μ → Lp E p μ) := uniformContinuous_comap lemma isUniformEmbedding : IsUniformEmbedding ((↑) : Lp.simpleFunc E p μ → Lp E p μ) := isUniformEmbedding_comap Subtype.val_injective theorem isUniformInducing : IsUniformInducing ((↑) : Lp.simpleFunc E p μ → Lp E p μ) := simpleFunc.isUniformEmbedding.isUniformInducing lemma isDenseEmbedding (hp_ne_top : p ≠ ∞) : IsDenseEmbedding ((↑) : Lp.simpleFunc E p μ → Lp E p μ) := by borelize E apply simpleFunc.isUniformEmbedding.isDenseEmbedding intro f rw [mem_closure_iff_seq_limit] have hfi' : MemLp f p μ := Lp.memLp f haveI : SeparableSpace (range f ∪ {0} : Set E) := (Lp.stronglyMeasurable f).separableSpace_range_union_singleton refine ⟨fun n => toLp (SimpleFunc.approxOn f (Lp.stronglyMeasurable f).measurable (range f ∪ {0}) 0 _ n) (SimpleFunc.memLp_approxOn_range (Lp.stronglyMeasurable f).measurable hfi' n), fun n => mem_range_self _, ?_⟩ convert SimpleFunc.tendsto_approxOn_range_Lp hp_ne_top (Lp.stronglyMeasurable f).measurable hfi' rw [toLp_coeFn f (Lp.memLp f)] protected theorem isDenseInducing (hp_ne_top : p ≠ ∞) : IsDenseInducing ((↑) : Lp.simpleFunc E p μ → Lp E p μ) := (simpleFunc.isDenseEmbedding hp_ne_top).isDenseInducing protected theorem denseRange (hp_ne_top : p ≠ ∞) : DenseRange ((↑) : Lp.simpleFunc E p μ → Lp E p μ) := (simpleFunc.isDenseInducing hp_ne_top).dense protected theorem dense (hp_ne_top : p ≠ ∞) : Dense (Lp.simpleFunc E p μ : Set (Lp E p μ)) := by simpa only [denseRange_subtype_val] using simpleFunc.denseRange (E := E) (μ := μ) hp_ne_top variable [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] variable (α E 𝕜) /-- The embedding of Lp simple functions into Lp functions, as a continuous linear map. -/ def coeToLp : Lp.simpleFunc E p μ →L[𝕜] Lp E p μ := { AddSubgroup.subtype (Lp.simpleFunc E p μ) with map_smul' := fun _ _ => rfl cont := Lp.simpleFunc.uniformContinuous.continuous } variable {α E 𝕜} end CoeToLp section Order variable {G : Type*} [NormedAddCommGroup G] theorem coeFn_le [PartialOrder G] (f g : Lp.simpleFunc G p μ) : (f : α → G) ≤ᵐ[μ] g ↔ f ≤ g := by rw [← Subtype.coe_le_coe, ← Lp.coeFn_le] variable (p μ G) theorem coeFn_zero : (0 : Lp.simpleFunc G p μ) =ᵐ[μ] (0 : α → G) := Lp.coeFn_zero _ _ _ variable {p μ G} variable [PartialOrder G] theorem coeFn_nonneg (f : Lp.simpleFunc G p μ) : (0 : α → G) ≤ᵐ[μ] f ↔ 0 ≤ f := by rw [← Subtype.coe_le_coe, Lp.coeFn_nonneg, AddSubmonoid.coe_zero] theorem exists_simpleFunc_nonneg_ae_eq {f : Lp.simpleFunc G p μ} (hf : 0 ≤ f) : ∃ f' : α →ₛ G, 0 ≤ f' ∧ f =ᵐ[μ] f' := by rcases f with ⟨⟨f, hp⟩, g, (rfl : _ = f)⟩ change 0 ≤ᵐ[μ] g at hf classical refine ⟨g.map ({x : G | 0 ≤ x}.piecewise id 0), fun x ↦ ?_, (AEEqFun.coeFn_mk _ _).trans ?_⟩ · simpa using Set.indicator_apply_nonneg id · filter_upwards [hf] with x (hx : 0 ≤ g x) simpa using Set.indicator_of_mem hx id |>.symm variable (p μ G) /-- Coercion from nonnegative simple functions of Lp to nonnegative functions of Lp. -/ def coeSimpleFuncNonnegToLpNonneg : { g : Lp.simpleFunc G p μ // 0 ≤ g } → { g : Lp G p μ // 0 ≤ g } := fun g => ⟨g, g.2⟩ theorem denseRange_coeSimpleFuncNonnegToLpNonneg [hp : Fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) : DenseRange (coeSimpleFuncNonnegToLpNonneg p μ G) := fun g ↦ by borelize G rw [mem_closure_iff_seq_limit] have hg_memLp : MemLp (g : α → G) p μ := Lp.memLp (g : Lp G p μ) have zero_mem : (0 : G) ∈ (range (g : α → G) ∪ {0} : Set G) ∩ { y | 0 ≤ y } := by simp only [union_singleton, mem_inter_iff, mem_insert_iff, true_or, mem_setOf_eq, le_refl, and_self_iff] have : SeparableSpace ((range (g : α → G) ∪ {0}) ∩ { y | 0 ≤ y } : Set G) := by apply IsSeparable.separableSpace apply IsSeparable.mono _ Set.inter_subset_left exact (Lp.stronglyMeasurable (g : Lp G p μ)).isSeparable_range.union (finite_singleton _).isSeparable have g_meas : Measurable (g : α → G) := (Lp.stronglyMeasurable (g : Lp G p μ)).measurable let x n := SimpleFunc.approxOn (g : α → G) g_meas ((range (g : α → G) ∪ {0}) ∩ { y | 0 ≤ y }) 0 zero_mem n have hx_nonneg : ∀ n, 0 ≤ x n := by intro n a change x n a ∈ { y : G | 0 ≤ y } have A : (range (g : α → G) ∪ {0} : Set G) ∩ { y | 0 ≤ y } ⊆ { y | 0 ≤ y } := inter_subset_right apply A exact SimpleFunc.approxOn_mem g_meas _ n a have hx_memLp : ∀ n, MemLp (x n) p μ := SimpleFunc.memLp_approxOn _ hg_memLp _ ⟨aestronglyMeasurable_const, by simp⟩ have h_toLp := fun n => MemLp.coeFn_toLp (hx_memLp n) have hx_nonneg_Lp : ∀ n, 0 ≤ toLp (x n) (hx_memLp n) := by intro n rw [← Lp.simpleFunc.coeFn_le, Lp.simpleFunc.toLp_eq_toLp] filter_upwards [Lp.simpleFunc.coeFn_zero p μ G, h_toLp n] with a ha0 ha_toLp rw [ha0, ha_toLp] exact hx_nonneg n a have hx_tendsto : Tendsto (fun n : ℕ => eLpNorm ((x n : α → G) - (g : α → G)) p μ) atTop (𝓝 0) := by apply SimpleFunc.tendsto_approxOn_Lp_eLpNorm g_meas zero_mem hp_ne_top · have hg_nonneg : (0 : α → G) ≤ᵐ[μ] g := (Lp.coeFn_nonneg _).mpr g.2 refine hg_nonneg.mono fun a ha => subset_closure ?_ simpa using ha · simp_rw [sub_zero]; finiteness refine ⟨fun n => (coeSimpleFuncNonnegToLpNonneg p μ G) ⟨toLp (x n) (hx_memLp n), hx_nonneg_Lp n⟩, fun n => mem_range_self _, ?_⟩ suffices Tendsto (fun n : ℕ => (toLp (x n) (hx_memLp n) : Lp G p μ)) atTop (𝓝 (g : Lp G p μ)) by rw [tendsto_iff_dist_tendsto_zero] at this ⊢ simp_rw [Subtype.dist_eq] exact this rw [Lp.tendsto_Lp_iff_tendsto_eLpNorm'] refine Filter.Tendsto.congr (fun n => eLpNorm_congr_ae (EventuallyEq.sub ?_ ?_)) hx_tendsto · symm rw [Lp.simpleFunc.toLp_eq_toLp] exact h_toLp n · rfl variable {p μ G} end Order end simpleFunc end Lp variable [MeasurableSpace α] [NormedAddCommGroup E] {f : α → E} {p : ℝ≥0∞} {μ : Measure α} /-- To prove something for an arbitrary `Lp` function in a second countable Borel normed group, it suffices to show that * the property holds for (multiples of) characteristic functions; * is closed under addition; * the set of functions in `Lp` for which the property holds is closed. -/ @[elab_as_elim] theorem Lp.induction [_i : Fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) (motive : Lp E p μ → Prop) (indicatorConst : ∀ (c : E) {s : Set α} (hs : MeasurableSet s) (hμs : μ s < ∞), motive (Lp.simpleFunc.indicatorConst p hs hμs.ne c)) (add : ∀ ⦃f g⦄, ∀ hf : MemLp f p μ, ∀ hg : MemLp g p μ, Disjoint (support f) (support g) → motive (hf.toLp f) → motive (hg.toLp g) → motive (hf.toLp f + hg.toLp g)) (isClosed : IsClosed { f : Lp E p μ | motive f }) : ∀ f : Lp E p μ, motive f := by refine fun f => (Lp.simpleFunc.denseRange hp_ne_top).induction_on f isClosed ?_ refine Lp.simpleFunc.induction (α := α) (E := E) (lt_of_lt_of_le zero_lt_one _i.elim).ne' hp_ne_top ?_ ?_ · exact fun c s => indicatorConst c · exact fun f g hf hg => add hf hg /-- To prove something for an arbitrary `MemLp` function in a second countable Borel normed group, it suffices to show that * the property holds for (multiples of) characteristic functions; * is closed under addition; * the set of functions in the `Lᵖ` space for which the property holds is closed. * the property is closed under the almost-everywhere equal relation. It is possible to make the hypotheses in the induction steps a bit stronger, and such conditions can be added once we need them (for example in `h_add` it is only necessary to consider the sum of a simple function with a multiple of a characteristic function and that the intersection of their images is a subset of `{0}`). -/ @[elab_as_elim] theorem MemLp.induction [_i : Fact (1 ≤ p)] (hp_ne_top : p ≠ ∞) (motive : (α → E) → Prop) (indicator : ∀ (c : E) ⦃s⦄, MeasurableSet s → μ s < ∞ → motive (s.indicator fun _ => c)) (add : ∀ ⦃f g : α → E⦄, Disjoint (support f) (support g) → MemLp f p μ → MemLp g p μ → motive f → motive g → motive (f + g)) (closed : IsClosed { f : Lp E p μ | motive f }) (ae : ∀ ⦃f g⦄, f =ᵐ[μ] g → MemLp f p μ → motive f → motive g) : ∀ ⦃f : α → E⦄, MemLp f p μ → motive f := by have : ∀ f : SimpleFunc α E, MemLp f p μ → motive f := by apply SimpleFunc.induction · intro c s hs h by_cases hc : c = 0 · subst hc; convert indicator 0 MeasurableSet.empty (by simp) using 1; ext; simp have hp_pos : p ≠ 0 := (lt_of_lt_of_le zero_lt_one _i.elim).ne' exact indicator c hs (SimpleFunc.measure_lt_top_of_memLp_indicator hp_pos hp_ne_top hc hs h) · intro f g hfg hf hg int_fg rw [SimpleFunc.coe_add, memLp_add_of_disjoint hfg f.stronglyMeasurable g.stronglyMeasurable] at int_fg exact add hfg int_fg.1 int_fg.2 (hf int_fg.1) (hg int_fg.2) have : ∀ f : Lp.simpleFunc E p μ, motive f := by intro f exact ae (Lp.simpleFunc.toSimpleFunc_eq_toFun f) (Lp.simpleFunc.memLp f) (this (Lp.simpleFunc.toSimpleFunc f) (Lp.simpleFunc.memLp f)) have : ∀ f : Lp E p μ, motive f := fun f => (Lp.simpleFunc.denseRange hp_ne_top).induction_on f closed this exact fun f hf => ae hf.coeFn_toLp (Lp.memLp _) (this (hf.toLp f)) /-- If a set of ae strongly measurable functions is stable under addition and approximates characteristic functions in `ℒp`, then it is dense in `ℒp`. -/ theorem MemLp.induction_dense (hp_ne_top : p ≠ ∞) (P : (α → E) → Prop) (h0P : ∀ (c : E) ⦃s : Set α⦄, MeasurableSet s → μ s < ∞ → ∀ {ε : ℝ≥0∞}, ε ≠ 0 → ∃ g : α → E, eLpNorm (g - s.indicator fun _ => c) p μ ≤ ε ∧ P g) (h1P : ∀ f g, P f → P g → P (f + g)) (h2P : ∀ f, P f → AEStronglyMeasurable f μ) {f : α → E} (hf : MemLp f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ g : α → E, eLpNorm (f - g) p μ ≤ ε ∧ P g := by rcases eq_or_ne p 0 with (rfl | hp_pos) · rcases h0P (0 : E) MeasurableSet.empty (by simp only [measure_empty, zero_lt_top]) hε with ⟨g, _, Pg⟩ exact ⟨g, by simp only [eLpNorm_exponent_zero, zero_le'], Pg⟩ suffices H : ∀ (f' : α →ₛ E) (δ : ℝ≥0∞) (hδ : δ ≠ 0), MemLp f' p μ → ∃ g, eLpNorm (⇑f' - g) p μ ≤ δ ∧ P g by obtain ⟨η, ηpos, hη⟩ := exists_Lp_half E μ p hε rcases hf.exists_simpleFunc_eLpNorm_sub_lt hp_ne_top ηpos.ne' with ⟨f', hf', f'_mem⟩ rcases H f' η ηpos.ne' f'_mem with ⟨g, hg, Pg⟩ refine ⟨g, ?_, Pg⟩ convert (hη _ _ (hf.aestronglyMeasurable.sub f'.aestronglyMeasurable) (f'.aestronglyMeasurable.sub (h2P g Pg)) hf'.le hg).le using 2 simp only [sub_add_sub_cancel] apply SimpleFunc.induction · intro c s hs ε εpos Hs rcases eq_or_ne c 0 with (rfl | hc) · rcases h0P (0 : E) MeasurableSet.empty (by simp only [measure_empty, zero_lt_top]) εpos with ⟨g, hg, Pg⟩ rw [← eLpNorm_neg, neg_sub] at hg refine ⟨g, ?_, Pg⟩ convert hg ext x simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_zero, piecewise_eq_indicator, indicator_zero', Pi.zero_apply, indicator_zero] · have : μ s < ∞ := SimpleFunc.measure_lt_top_of_memLp_indicator hp_pos hp_ne_top hc hs Hs rcases h0P c hs this εpos with ⟨g, hg, Pg⟩ rw [← eLpNorm_neg, neg_sub] at hg exact ⟨g, hg, Pg⟩ · intro f f' hff' hf hf' δ δpos int_ff' obtain ⟨η, ηpos, hη⟩ := exists_Lp_half E μ p δpos rw [SimpleFunc.coe_add, memLp_add_of_disjoint hff' f.stronglyMeasurable f'.stronglyMeasurable] at int_ff' rcases hf η ηpos.ne' int_ff'.1 with ⟨g, hg, Pg⟩ rcases hf' η ηpos.ne' int_ff'.2 with ⟨g', hg', Pg'⟩ refine ⟨g + g', ?_, h1P g g' Pg Pg'⟩ convert (hη _ _ (f.aestronglyMeasurable.sub (h2P g Pg)) (f'.aestronglyMeasurable.sub (h2P g' Pg')) hg hg').le using 2 rw [SimpleFunc.coe_add] abel section Integrable @[inherit_doc MeasureTheory.Lp.simpleFunc] notation:25 α " →₁ₛ[" μ "] " E => @MeasureTheory.Lp.simpleFunc α E _ _ 1 μ theorem L1.SimpleFunc.toLp_one_eq_toL1 (f : α →ₛ E) (hf : Integrable f μ) : (Lp.simpleFunc.toLp f (memLp_one_iff_integrable.2 hf) : α →₁[μ] E) = hf.toL1 f := rfl @[fun_prop] protected theorem L1.SimpleFunc.integrable (f : α →₁ₛ[μ] E) : Integrable (Lp.simpleFunc.toSimpleFunc f) μ := by rw [← memLp_one_iff_integrable]; exact Lp.simpleFunc.memLp f /-- To prove something for an arbitrary integrable function in a normed group, it suffices to show that * the property holds for (multiples of) characteristic functions; * is closed under addition; * the set of functions in the `L¹` space for which the property holds is closed. * the property is closed under the almost-everywhere equal relation. It is possible to make the hypotheses in the induction steps a bit stronger, and such conditions can be added once we need them (for example in `h_add` it is only necessary to consider the sum of a simple function with a multiple of a characteristic function and that the intersection of their images is a subset of `{0}`). -/ @[elab_as_elim] theorem Integrable.induction (P : (α → E) → Prop) (h_ind : ∀ (c : E) ⦃s⦄, MeasurableSet s → μ s < ∞ → P (s.indicator fun _ => c)) (h_add : ∀ ⦃f g : α → E⦄, Disjoint (support f) (support g) → Integrable f μ → Integrable g μ → P f → P g → P (f + g)) (h_closed : IsClosed { f : α →₁[μ] E | P f }) (h_ae : ∀ ⦃f g⦄, f =ᵐ[μ] g → Integrable f μ → P f → P g) : ∀ ⦃f : α → E⦄, Integrable f μ → P f := by simp only [← memLp_one_iff_integrable] at * exact MemLp.induction one_ne_top (motive := P) h_ind h_add h_closed h_ae end Integrable end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SimpleFuncDense.lean
import Mathlib.MeasureTheory.Function.SimpleFunc import Mathlib.MeasureTheory.Constructions.BorelSpace.Metrizable /-! # Density of simple functions Show that each Borel measurable function can be approximated pointwise by a sequence of simple functions. ## Main definitions * `MeasureTheory.SimpleFunc.nearestPt (e : ℕ → α) (N : ℕ) : α →ₛ ℕ`: the `SimpleFunc` sending each `x : α` to the point `e k` which is the nearest to `x` among `e 0`, ..., `e N`. * `MeasureTheory.SimpleFunc.approxOn (f : β → α) (hf : Measurable f) (s : Set α) (y₀ : α) (h₀ : y₀ ∈ s) [SeparableSpace s] (n : ℕ) : β →ₛ α` : a simple function that takes values in `s` and approximates `f`. ## Main results * `tendsto_approxOn` (pointwise convergence): If `f x ∈ s`, then the sequence of simple approximations `MeasureTheory.SimpleFunc.approxOn f hf s y₀ h₀ n`, evaluated at `x`, tends to `f x` as `n` tends to `∞`. ## Notation * `α →ₛ β` (local notation): the type of simple functions `α → β`. -/ open Set Function Filter TopologicalSpace EMetric MeasureTheory open scoped Topology ENNReal variable {α β : Type*} noncomputable section namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc /-! ### Pointwise approximation by simple functions -/ variable [MeasurableSpace α] [PseudoEMetricSpace α] [OpensMeasurableSpace α] /-- `nearestPtInd e N x` is the index `k` such that `e k` is the nearest point to `x` among the points `e 0`, ..., `e N`. If more than one point are at the same distance from `x`, then `nearestPtInd e N x` returns the least of their indexes. -/ noncomputable def nearestPtInd (e : ℕ → α) : ℕ → α →ₛ ℕ | 0 => const α 0 | N + 1 => piecewise (⋂ k ≤ N, { x | edist (e (N + 1)) x < edist (e k) x }) (MeasurableSet.iInter fun _ => MeasurableSet.iInter fun _ => measurableSet_lt measurable_edist_right measurable_edist_right) (const α <| N + 1) (nearestPtInd e N) /-- `nearestPt e N x` is the nearest point to `x` among the points `e 0`, ..., `e N`. If more than one point are at the same distance from `x`, then `nearestPt e N x` returns the point with the least possible index. -/ noncomputable def nearestPt (e : ℕ → α) (N : ℕ) : α →ₛ α := (nearestPtInd e N).map e @[simp] theorem nearestPtInd_zero (e : ℕ → α) : nearestPtInd e 0 = const α 0 := rfl @[simp] theorem nearestPt_zero (e : ℕ → α) : nearestPt e 0 = const α (e 0) := rfl theorem nearestPtInd_succ (e : ℕ → α) (N : ℕ) (x : α) : nearestPtInd e (N + 1) x = if ∀ k ≤ N, edist (e (N + 1)) x < edist (e k) x then N + 1 else nearestPtInd e N x := by simp only [nearestPtInd, coe_piecewise, Set.piecewise] congr simp theorem nearestPtInd_le (e : ℕ → α) (N : ℕ) (x : α) : nearestPtInd e N x ≤ N := by induction N with | zero => simp | succ N ihN => simp only [nearestPtInd_succ] split_ifs exacts [le_rfl, ihN.trans N.le_succ] theorem edist_nearestPt_le (e : ℕ → α) (x : α) {k N : ℕ} (hk : k ≤ N) : edist (nearestPt e N x) x ≤ edist (e k) x := by induction N generalizing k with | zero => simp [nonpos_iff_eq_zero.1 hk, le_refl] | succ N ihN => simp only [nearestPt, nearestPtInd_succ, map_apply] split_ifs with h · rcases hk.eq_or_lt with (rfl | hk) exacts [le_rfl, (h k (Nat.lt_succ_iff.1 hk)).le] · push_neg at h rcases h with ⟨l, hlN, hxl⟩ rcases hk.eq_or_lt with (rfl | hk) exacts [(ihN hlN).trans hxl, ihN (Nat.lt_succ_iff.1 hk)] theorem tendsto_nearestPt {e : ℕ → α} {x : α} (hx : x ∈ closure (range e)) : Tendsto (fun N => nearestPt e N x) atTop (𝓝 x) := by refine (atTop_basis.tendsto_iff nhds_basis_eball).2 fun ε hε => ?_ rcases EMetric.mem_closure_iff.1 hx ε hε with ⟨_, ⟨N, rfl⟩, hN⟩ rw [edist_comm] at hN exact ⟨N, trivial, fun n hn => (edist_nearestPt_le e x hn).trans_lt hN⟩ variable [MeasurableSpace β] {f : β → α} /-- Approximate a measurable function by a sequence of simple functions `F n` such that `F n x ∈ s`. -/ noncomputable def approxOn (f : β → α) (hf : Measurable f) (s : Set α) (y₀ : α) (h₀ : y₀ ∈ s) [SeparableSpace s] (n : ℕ) : β →ₛ α := haveI : Nonempty s := ⟨⟨y₀, h₀⟩⟩ comp (nearestPt (fun k => Nat.casesOn k y₀ ((↑) ∘ denseSeq s) : ℕ → α) n) f hf @[simp] theorem approxOn_zero {f : β → α} (hf : Measurable f) {s : Set α} {y₀ : α} (h₀ : y₀ ∈ s) [SeparableSpace s] (x : β) : approxOn f hf s y₀ h₀ 0 x = y₀ := rfl theorem approxOn_mem {f : β → α} (hf : Measurable f) {s : Set α} {y₀ : α} (h₀ : y₀ ∈ s) [SeparableSpace s] (n : ℕ) (x : β) : approxOn f hf s y₀ h₀ n x ∈ s := by haveI : Nonempty s := ⟨⟨y₀, h₀⟩⟩ suffices ∀ n, (Nat.casesOn n y₀ ((↑) ∘ denseSeq s) : α) ∈ s by apply this rintro (_ | n) exacts [h₀, Subtype.mem _] lemma approxOn_range_nonneg [Zero α] [Preorder α] {f : β → α} (hf : 0 ≤ f) {hfm : Measurable f} [SeparableSpace (range f ∪ {0} : Set α)] (n : ℕ) : 0 ≤ approxOn f hfm (range f ∪ {0}) 0 (by simp) n := by have : range f ∪ {0} ⊆ Set.Ici 0 := by simp only [Set.union_singleton, Set.insert_subset_iff, Set.mem_Ici, le_refl, true_and] rintro - ⟨x, rfl⟩ exact hf x exact fun _ ↦ this <| approxOn_mem .. @[simp] theorem approxOn_comp {γ : Type*} [MeasurableSpace γ] {f : β → α} (hf : Measurable f) {g : γ → β} (hg : Measurable g) {s : Set α} {y₀ : α} (h₀ : y₀ ∈ s) [SeparableSpace s] (n : ℕ) : approxOn (f ∘ g) (hf.comp hg) s y₀ h₀ n = (approxOn f hf s y₀ h₀ n).comp g hg := rfl theorem tendsto_approxOn {f : β → α} (hf : Measurable f) {s : Set α} {y₀ : α} (h₀ : y₀ ∈ s) [SeparableSpace s] {x : β} (hx : f x ∈ closure s) : Tendsto (fun n => approxOn f hf s y₀ h₀ n x) atTop (𝓝 <| f x) := by haveI : Nonempty s := ⟨⟨y₀, h₀⟩⟩ rw [← @Subtype.range_coe _ s, ← image_univ, ← (denseRange_denseSeq s).closure_eq] at hx simp -iota only [approxOn, coe_comp] refine tendsto_nearestPt (closure_minimal ?_ isClosed_closure hx) simp -iota only [Nat.range_casesOn, closure_union, range_comp] exact Subset.trans (image_closure_subset_closure_image continuous_subtype_val) subset_union_right theorem edist_approxOn_mono {f : β → α} (hf : Measurable f) {s : Set α} {y₀ : α} (h₀ : y₀ ∈ s) [SeparableSpace s] (x : β) {m n : ℕ} (h : m ≤ n) : edist (approxOn f hf s y₀ h₀ n x) (f x) ≤ edist (approxOn f hf s y₀ h₀ m x) (f x) := by dsimp only [approxOn, coe_comp, Function.comp_def] exact edist_nearestPt_le _ _ ((nearestPtInd_le _ _ _).trans h) theorem edist_approxOn_le {f : β → α} (hf : Measurable f) {s : Set α} {y₀ : α} (h₀ : y₀ ∈ s) [SeparableSpace s] (x : β) (n : ℕ) : edist (approxOn f hf s y₀ h₀ n x) (f x) ≤ edist y₀ (f x) := edist_approxOn_mono hf h₀ x (zero_le n) theorem edist_approxOn_y0_le {f : β → α} (hf : Measurable f) {s : Set α} {y₀ : α} (h₀ : y₀ ∈ s) [SeparableSpace s] (x : β) (n : ℕ) : edist y₀ (approxOn f hf s y₀ h₀ n x) ≤ edist y₀ (f x) + edist y₀ (f x) := calc edist y₀ (approxOn f hf s y₀ h₀ n x) ≤ edist y₀ (f x) + edist (approxOn f hf s y₀ h₀ n x) (f x) := edist_triangle_right _ _ _ _ ≤ edist y₀ (f x) + edist y₀ (f x) := by grw [edist_approxOn_le hf h₀ x n] end SimpleFunc end MeasureTheory section CompactSupport variable {X Y α : Type*} [Zero α] [TopologicalSpace X] [TopologicalSpace Y] [MeasurableSpace X] [MeasurableSpace Y] [OpensMeasurableSpace X] [OpensMeasurableSpace Y] /-- A continuous function with compact support on a product space can be uniformly approximated by simple functions. The subtlety is that we do not assume that the spaces are separable, so the product of the Borel sigma algebras might not contain all open sets, but still it contains enough of them to approximate compactly supported continuous functions. -/ lemma HasCompactSupport.exists_simpleFunc_approx_of_prod [PseudoMetricSpace α] {f : X × Y → α} (hf : Continuous f) (h'f : HasCompactSupport f) {ε : ℝ} (hε : 0 < ε) : ∃ (g : SimpleFunc (X × Y) α), ∀ x, dist (f x) (g x) < ε := by have M : ∀ (K : Set (X × Y)), IsCompact K → ∃ (g : SimpleFunc (X × Y) α), ∃ (s : Set (X × Y)), MeasurableSet s ∧ K ⊆ s ∧ ∀ x ∈ s, dist (f x) (g x) < ε := by intro K hK apply IsCompact.induction_on (p := fun t ↦ ∃ (g : SimpleFunc (X × Y) α), ∃ (s : Set (X × Y)), MeasurableSet s ∧ t ⊆ s ∧ ∀ x ∈ s, dist (f x) (g x) < ε) hK · exact ⟨0, ∅, by simp⟩ · intro t t' htt' ⟨g, s, s_meas, ts, hg⟩ exact ⟨g, s, s_meas, htt'.trans ts, hg⟩ · intro t t' ⟨g, s, s_meas, ts, hg⟩ ⟨g', s', s'_meas, t's', hg'⟩ refine ⟨g.piecewise s s_meas g', s ∪ s', s_meas.union s'_meas, union_subset_union ts t's', fun p hp ↦ ?_⟩ by_cases H : p ∈ s · simpa [H, SimpleFunc.piecewise_apply] using hg p H · simp only [SimpleFunc.piecewise_apply, H, ite_false] apply hg' simpa [H] using (mem_union _ _ _).1 hp · rintro ⟨x, y⟩ - obtain ⟨u, v, hu, xu, hv, yv, huv⟩ : ∃ u v, IsOpen u ∧ x ∈ u ∧ IsOpen v ∧ y ∈ v ∧ u ×ˢ v ⊆ {z | dist (f z) (f (x, y)) < ε} := mem_nhds_prod_iff'.1 <| Metric.continuousAt_iff'.1 hf.continuousAt ε hε refine ⟨u ×ˢ v, nhdsWithin_le_nhds <| (hu.prod hv).mem_nhds (mk_mem_prod xu yv), ?_⟩ exact ⟨SimpleFunc.const _ (f (x, y)), u ×ˢ v, hu.measurableSet.prod hv.measurableSet, Subset.rfl, fun z hz ↦ huv hz⟩ obtain ⟨g, s, s_meas, fs, hg⟩ : ∃ (g : SimpleFunc (X × Y) α) (s : Set (X × Y)), MeasurableSet s ∧ tsupport f ⊆ s ∧ ∀ (x : X × Y), x ∈ s → dist (f x) (g x) < ε := M _ h'f refine ⟨g.piecewise s s_meas 0, fun p ↦ ?_⟩ by_cases H : p ∈ s · simpa [H, SimpleFunc.piecewise_apply] using hg p H · have : f p = 0 := by contrapose! H rw [← Function.mem_support] at H exact fs (subset_tsupport _ H) simp [SimpleFunc.piecewise_apply, H, this, hε] /-- A continuous function with compact support on a product space is measurable for the product sigma-algebra. The subtlety is that we do not assume that the spaces are separable, so the product of the Borel sigma algebras might not contain all open sets, but still it contains enough of them to approximate compactly supported continuous functions. -/ lemma HasCompactSupport.measurable_of_prod [TopologicalSpace α] [PseudoMetrizableSpace α] [MeasurableSpace α] [BorelSpace α] {f : X × Y → α} (hf : Continuous f) (h'f : HasCompactSupport f) : Measurable f := by letI : PseudoMetricSpace α := TopologicalSpace.pseudoMetrizableSpacePseudoMetric α obtain ⟨u, -, u_pos, u_lim⟩ : ∃ u, StrictAnti u ∧ (∀ (n : ℕ), 0 < u n) ∧ Tendsto u atTop (𝓝 0) := exists_seq_strictAnti_tendsto (0 : ℝ) have : ∀ n, ∃ (g : SimpleFunc (X × Y) α), ∀ x, dist (f x) (g x) < u n := fun n ↦ h'f.exists_simpleFunc_approx_of_prod hf (u_pos n) choose g hg using this have A : ∀ x, Tendsto (fun n ↦ g n x) atTop (𝓝 (f x)) := by intro x rw [tendsto_iff_dist_tendsto_zero] apply squeeze_zero (fun n ↦ dist_nonneg) (fun n ↦ ?_) u_lim rw [dist_comm] exact (hg n x).le apply measurable_of_tendsto_metrizable (fun n ↦ (g n).measurable) (tendsto_pi_nhds.2 A) end CompactSupport
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/Egorov.lean
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic /-! # Egorov theorem This file contains the Egorov theorem which states that an almost everywhere convergent sequence on a finite measure space converges uniformly except on an arbitrarily small set. This theorem is useful for the Vitali convergence theorem as well as theorems regarding convergence in measure. ## Main results * `MeasureTheory.tendstoUniformlyOn_of_ae_tendsto`: Egorov's theorem which shows that a sequence of almost everywhere convergent functions converges uniformly except on an arbitrarily small set. -/ noncomputable section open MeasureTheory NNReal ENNReal Topology namespace MeasureTheory open Set Filter TopologicalSpace variable {α β ι : Type*} {m : MeasurableSpace α} [PseudoEMetricSpace β] {μ : Measure α} namespace Egorov /-- Given a sequence of functions `f` and a function `g`, `notConvergentSeq f g n j` is the set of elements such that `f k x` and `g x` are separated by at least `1 / (n + 1)` for some `k ≥ j`. This definition is useful for Egorov's theorem. -/ def notConvergentSeq [Preorder ι] (f : ι → α → β) (g : α → β) (n : ℕ) (j : ι) : Set α := ⋃ (k) (_ : j ≤ k), { x | (n : ℝ≥0∞)⁻¹ < edist (f k x) (g x) } variable {n : ℕ} {j : ι} {s : Set α} {ε : ℝ} {f : ι → α → β} {g : α → β} theorem mem_notConvergentSeq_iff [Preorder ι] {x : α} : x ∈ notConvergentSeq f g n j ↔ ∃ k ≥ j, (n : ℝ≥0∞)⁻¹ < edist (f k x) (g x) := by simp_rw [notConvergentSeq, Set.mem_iUnion, exists_prop, mem_setOf] theorem notConvergentSeq_antitone [Preorder ι] : Antitone (notConvergentSeq f g n) := fun _ _ hjk => Set.iUnion₂_mono' fun l hl => ⟨l, le_trans hjk hl, Set.Subset.rfl⟩ theorem measure_inter_notConvergentSeq_eq_zero [SemilatticeSup ι] [Nonempty ι] (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : μ (s ∩ ⋂ j, notConvergentSeq f g n j) = 0 := by simp_rw [EMetric.tendsto_atTop, ae_iff] at hfg rw [← nonpos_iff_eq_zero, ← hfg] refine measure_mono fun x => ?_ simp only [Set.mem_inter_iff, Set.mem_iInter, mem_notConvergentSeq_iff] push_neg rintro ⟨hmem, hx⟩ refine ⟨hmem, (n : ℝ≥0∞)⁻¹, by simp, fun N => ?_⟩ obtain ⟨n, hn₁, hn₂⟩ := hx N exact ⟨n, hn₁, hn₂.le⟩ theorem notConvergentSeq_measurableSet [Preorder ι] [Countable ι] (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) : MeasurableSet (notConvergentSeq f g n j) := MeasurableSet.iUnion fun k ↦ MeasurableSet.iUnion fun _ ↦ measurableSet_lt measurable_const <| hf k theorem measure_notConvergentSeq_tendsto_zero [SemilatticeSup ι] [Countable ι] (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : Tendsto (fun j => μ (s ∩ notConvergentSeq f g n j)) atTop (𝓝 0) := by rcases isEmpty_or_nonempty ι with h | h · have : (fun j => μ (s ∩ notConvergentSeq f g n j)) = fun j => 0 := by simp only [eq_iff_true_of_subsingleton] rw [this] exact tendsto_const_nhds rw [← measure_inter_notConvergentSeq_eq_zero hfg n, Set.inter_iInter] refine tendsto_measure_iInter_atTop (fun n ↦ (hsm.inter <| notConvergentSeq_measurableSet hf).nullMeasurableSet) (fun k l hkl => Set.inter_subset_inter_right _ <| notConvergentSeq_antitone hkl) ⟨h.some, ne_top_of_le_ne_top hs (measure_mono Set.inter_subset_left)⟩ variable [SemilatticeSup ι] [Nonempty ι] [Countable ι] theorem exists_notConvergentSeq_lt (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : ∃ j : ι, μ (s ∩ notConvergentSeq f g n j) ≤ ENNReal.ofReal (ε * 2⁻¹ ^ n) := by have ⟨N, hN⟩ := (ENNReal.tendsto_atTop ENNReal.zero_ne_top).1 (measure_notConvergentSeq_tendsto_zero hf hsm hs hfg n) (.ofReal (ε * 2⁻¹ ^ n)) (by positivity) rw [zero_add] at hN exact ⟨N, (hN N le_rfl).2⟩ /-- Given some `ε > 0`, `notConvergentSeqLTIndex` provides the index such that `notConvergentSeq` (intersected with a set of finite measure) has measure less than `ε * 2⁻¹ ^ n`. This definition is useful for Egorov's theorem. -/ def notConvergentSeqLTIndex (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : ι := Classical.choose <| exists_notConvergentSeq_lt hε hf hsm hs hfg n theorem notConvergentSeqLTIndex_spec (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : μ (s ∩ notConvergentSeq f g n (notConvergentSeqLTIndex hε hf hsm hs hfg n)) ≤ ENNReal.ofReal (ε * 2⁻¹ ^ n) := Classical.choose_spec <| exists_notConvergentSeq_lt hε hf hsm hs hfg n /-- Given some `ε > 0`, `iUnionNotConvergentSeq` is the union of `notConvergentSeq` with specific indices such that `iUnionNotConvergentSeq` has measure less equal than `ε`. This definition is useful for Egorov's theorem. -/ def iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Set α := ⋃ n, s ∩ notConvergentSeq f g n (notConvergentSeqLTIndex (half_pos hε) hf hsm hs hfg n) theorem iUnionNotConvergentSeq_measurableSet (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : MeasurableSet <| iUnionNotConvergentSeq hε hf hsm hs hfg := MeasurableSet.iUnion fun _ ↦ hsm.inter <| notConvergentSeq_measurableSet hf theorem measure_iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : μ (iUnionNotConvergentSeq hε hf hsm hs hfg) ≤ ENNReal.ofReal ε := by refine le_trans (measure_iUnion_le _) (le_trans (ENNReal.tsum_le_tsum <| notConvergentSeqLTIndex_spec (half_pos hε) hf hsm hs hfg) ?_) simp_rw [ENNReal.ofReal_mul (half_pos hε).le] rw [ENNReal.tsum_mul_left, ← ENNReal.ofReal_tsum_of_nonneg, inv_eq_one_div, tsum_geometric_two, ← ENNReal.ofReal_mul (half_pos hε).le, div_mul_cancel₀ ε two_ne_zero] · intro n; positivity · rw [inv_eq_one_div] exact summable_geometric_two theorem iUnionNotConvergentSeq_subset (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : iUnionNotConvergentSeq hε hf hsm hs hfg ⊆ s := by rw [iUnionNotConvergentSeq, ← Set.inter_iUnion] exact Set.inter_subset_left theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hsm hs hfg) := by rw [EMetric.tendstoUniformlyOn_iff] intro δ hδ obtain ⟨N, hN⟩ := ENNReal.exists_inv_nat_lt hδ.ne' rw [eventually_atTop] refine ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hsm hs hfg N, fun n hn x hx => ?_⟩ simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion, Set.mem_inter_iff, not_and, exists_and_left] at hx obtain ⟨hxs, hx⟩ := hx specialize hx hxs N rw [Egorov.mem_notConvergentSeq_iff] at hx push_neg at hx rw [edist_comm] exact lt_of_le_of_lt (hx n hn) hN end Egorov variable [SemilatticeSup ι] [Nonempty ι] [Countable ι] {f : ι → α → β} {g : α → β} {s : Set α} /-- **Egorov's theorem**: If `f : ι → α → β` is a sequence of functions that converges to `g : α → β` almost everywhere on a measurable set `s` of finite measure, and the distance between `f n a` and `g a` is measurable for all `n`, then for all `ε > 0`, there exists a subset `t ⊆ s` such that `μ t ≤ ε` and `f` converges to `g` uniformly on `s \ t`. We require the index type `ι` to be countable, and usually `ι = ℕ`. In other words, a sequence of almost everywhere convergent functions converges uniformly except on an arbitrarily small set. -/ theorem tendstoUniformlyOn_of_ae_tendsto_of_measurable_edist (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ} (hε : 0 < ε) : ∃ t ⊆ s, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop (s \ t) := ⟨Egorov.iUnionNotConvergentSeq hε hf hsm hs hfg, Egorov.iUnionNotConvergentSeq_subset hε hf hsm hs hfg, Egorov.iUnionNotConvergentSeq_measurableSet hε hf hsm hs hfg, Egorov.measure_iUnionNotConvergentSeq hε hf hsm hs hfg, Egorov.tendstoUniformlyOn_diff_iUnionNotConvergentSeq hε hf hsm hs hfg⟩ /-- **Egorov's theorem**: If `f : ι → α → β` is a sequence of strongly measurable functions that converges to `g : α → β` almost everywhere on a measurable set `s` of finite measure, then for all `ε > 0`, there exists a subset `t ⊆ s` such that `μ t ≤ ε` and `f` converges to `g` uniformly on `s \ t`. We require the index type `ι` to be countable, and usually `ι = ℕ`. In other words, a sequence of almost everywhere convergent functions converges uniformly except on an arbitrarily small set. -/ theorem tendstoUniformlyOn_of_ae_tendsto (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ} (hε : 0 < ε) : ∃ t ⊆ s, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop (s \ t) := tendstoUniformlyOn_of_ae_tendsto_of_measurable_edist (fun n ↦ ((hf n).edist hg).measurable) hsm hs hfg hε /-- Egorov's theorem for finite measure spaces. Version with measurable distances. -/ theorem tendstoUniformlyOn_of_ae_tendsto_of_measurable_edist' [IsFiniteMeasure μ] (hf : ∀ n, Measurable (fun a ↦ edist (f n a) (g a))) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ} (hε : 0 < ε) : ∃ t, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ := by have ⟨t, _, ht, htendsto⟩ := tendstoUniformlyOn_of_ae_tendsto_of_measurable_edist hf MeasurableSet.univ (measure_ne_top μ Set.univ) (by filter_upwards [hfg] with _ htendsto _ using htendsto) hε refine ⟨_, ht, ?_⟩ rwa [Set.compl_eq_univ_diff] /-- Egorov's theorem for finite measure spaces. -/ theorem tendstoUniformlyOn_of_ae_tendsto' [IsFiniteMeasure μ] (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hfg : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x))) {ε : ℝ} (hε : 0 < ε) : ∃ t, MeasurableSet t ∧ μ t ≤ ENNReal.ofReal ε ∧ TendstoUniformlyOn f g atTop tᶜ := tendstoUniformlyOn_of_ae_tendsto_of_measurable_edist' (fun n ↦ ((hf n).edist hg).measurable) hfg hε end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/AEEqOfIntegral.lean
import Mathlib.Analysis.InnerProductSpace.Continuous import Mathlib.Analysis.Normed.Module.HahnBanach import Mathlib.MeasureTheory.Function.AEEqOfLIntegral import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lp import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap import Mathlib.Order.Filter.Ring /-! # From equality of integrals to equality of functions This file provides various statements of the general form "if two functions have the same integral on all sets, then they are equal almost everywhere". The different lemmas use various hypotheses on the class of functions, on the target space or on the possible finiteness of the measure. This file is about Bochner integrals. See the file `AEEqOfLIntegral` for Lebesgue integrals. ## Main statements All results listed below apply to two functions `f, g`, together with two main hypotheses, * `f` and `g` are integrable on all measurable sets with finite measure, * for all measurable sets `s` with finite measure, `∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ`. The conclusion is then `f =ᵐ[μ] g`. The main lemmas are: * `ae_eq_of_forall_setIntegral_eq_of_sigmaFinite`: case of a sigma-finite measure. * `AEFinStronglyMeasurable.ae_eq_of_forall_setIntegral_eq`: for functions which are `AEFinStronglyMeasurable`. * `Lp.ae_eq_of_forall_setIntegral_eq`: for elements of `Lp`, for `0 < p < ∞`. * `Integrable.ae_eq_of_forall_setIntegral_eq`: for integrable functions. For each of these results, we also provide a lemma about the equality of one function and 0. For example, `Lp.ae_eq_zero_of_forall_setIntegral_eq_zero`. Generally useful lemmas which are not related to integrals: * `ae_eq_zero_of_forall_inner`: if for all constants `c`, `(fun x => ⟪c, f x⟫_𝕜) =ᵐ[μ] 0` then `f =ᵐ[μ] 0`. * `ae_eq_zero_of_forall_dual`: if for all constants `c` in the `StrongDual` space, `fun x => c (f x) =ᵐ[μ] 0` then `f =ᵐ[μ] 0`. -/ open MeasureTheory TopologicalSpace NormedSpace Filter open scoped ENNReal NNReal MeasureTheory Topology namespace MeasureTheory section AeEqOfForall variable {α E 𝕜 : Type*} {m : MeasurableSpace α} {μ : Measure α} [RCLike 𝕜] open scoped InnerProductSpace in theorem ae_eq_zero_of_forall_inner [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [SecondCountableTopology E] {f : α → E} (hf : ∀ c : E, (fun x => ⟪c, f x⟫_𝕜) =ᵐ[μ] 0) : f =ᵐ[μ] 0 := by let s := denseSeq E have hs : DenseRange s := denseRange_denseSeq E have hf' : ∀ᵐ x ∂μ, ∀ n : ℕ, ⟪s n, f x⟫_𝕜 = 0 := ae_all_iff.mpr fun n => hf (s n) refine hf'.mono fun x hx => ?_ rw [Pi.zero_apply, ← @inner_self_eq_zero 𝕜] have h_closed : IsClosed {c : E | ⟪c, f x⟫_𝕜 = 0} := isClosed_eq (continuous_id.inner continuous_const) continuous_const exact @isClosed_property ℕ E _ s (fun c => ⟪c, f x⟫_𝕜 = 0) hs h_closed hx _ local notation "⟪" x ", " y "⟫" => y x variable (𝕜) theorem ae_eq_zero_of_forall_dual_of_isSeparable [NormedAddCommGroup E] [NormedSpace 𝕜 E] {t : Set E} (ht : TopologicalSpace.IsSeparable t) {f : α → E} (hf : ∀ c : StrongDual 𝕜 E, (fun x => ⟪f x, c⟫) =ᵐ[μ] 0) (h't : ∀ᵐ x ∂μ, f x ∈ t) : f =ᵐ[μ] 0 := by rcases ht with ⟨d, d_count, hd⟩ haveI : Encodable d := d_count.toEncodable have : ∀ x : d, ∃ g : StrongDual 𝕜 E, ‖g‖ ≤ 1 ∧ g x = ‖(x : E)‖ := fun x => exists_dual_vector'' 𝕜 (x : E) choose s hs using this have A : ∀ a : E, a ∈ t → (∀ x, ⟪a, s x⟫ = (0 : 𝕜)) → a = 0 := by intro a hat ha contrapose! ha have a_pos : 0 < ‖a‖ := by simp only [ha, norm_pos_iff, Ne, not_false_iff] have a_mem : a ∈ closure d := hd hat obtain ⟨x, hx⟩ : ∃ x : d, dist a x < ‖a‖ / 2 := by rcases Metric.mem_closure_iff.1 a_mem (‖a‖ / 2) (half_pos a_pos) with ⟨x, h'x, hx⟩ exact ⟨⟨x, h'x⟩, hx⟩ use x have I : ‖a‖ / 2 < ‖(x : E)‖ := by have : ‖a‖ ≤ ‖(x : E)‖ + ‖a - x‖ := norm_le_insert' _ _ have : ‖a - x‖ < ‖a‖ / 2 := by rwa [dist_eq_norm] at hx linarith intro h apply lt_irrefl ‖s x x‖ calc ‖s x x‖ = ‖s x (x - a)‖ := by simp only [h, sub_zero, ContinuousLinearMap.map_sub] _ ≤ 1 * ‖(x : E) - a‖ := ContinuousLinearMap.le_of_opNorm_le _ (hs x).1 _ _ < ‖a‖ / 2 := by rw [one_mul]; rwa [dist_eq_norm'] at hx _ < ‖(x : E)‖ := I _ = ‖s x x‖ := by simp [(hs x).2] have hfs : ∀ y : d, ∀ᵐ x ∂μ, ⟪f x, s y⟫ = (0 : 𝕜) := fun y => hf (s y) have hf' : ∀ᵐ x ∂μ, ∀ y : d, ⟪f x, s y⟫ = (0 : 𝕜) := by rwa [ae_all_iff] filter_upwards [hf', h't] with x hx h'x exact A (f x) h'x hx theorem ae_eq_zero_of_forall_dual [NormedAddCommGroup E] [NormedSpace 𝕜 E] [SecondCountableTopology E] {f : α → E} (hf : ∀ c : StrongDual 𝕜 E, (fun x => ⟪f x, c⟫) =ᵐ[μ] 0) : f =ᵐ[μ] 0 := ae_eq_zero_of_forall_dual_of_isSeparable 𝕜 (.of_separableSpace Set.univ) hf (Eventually.of_forall fun _ => Set.mem_univ _) variable {𝕜} end AeEqOfForall variable {α E : Type*} {m m0 : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {p : ℝ≥0∞} section AeEqOfForallSetIntegralEq section Real variable {f : α → ℝ} theorem ae_nonneg_of_forall_setIntegral_nonneg (hf : Integrable f μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) : 0 ≤ᵐ[μ] f := by simp_rw [EventuallyLE, Pi.zero_apply] rw [ae_const_le_iff_forall_lt_measure_zero] intro b hb_neg let s := {x | f x ≤ b} have hs : NullMeasurableSet s μ := nullMeasurableSet_le hf.1.aemeasurable aemeasurable_const have mus : μ s < ∞ := Integrable.measure_le_lt_top hf hb_neg have h_int_gt : (∫ x in s, f x ∂μ) ≤ b * μ.real s := by have h_const_le : (∫ x in s, f x ∂μ) ≤ ∫ _ in s, b ∂μ := by refine setIntegral_mono_ae_restrict hf.integrableOn (integrableOn_const mus.ne) ?_ rw [EventuallyLE, ae_restrict_iff₀ (hs.mono μ.restrict_le_self)] exact Eventually.of_forall fun x hxs => hxs rwa [setIntegral_const, smul_eq_mul, mul_comm] at h_const_le contrapose! h_int_gt with H calc b * μ.real s < 0 := mul_neg_of_neg_of_pos hb_neg <| ENNReal.toReal_pos H mus.ne _ ≤ ∫ x in s, f x ∂μ := by rw [← μ.restrict_toMeasurable mus.ne] exact hf_zero _ (measurableSet_toMeasurable ..) (by rwa [measure_toMeasurable]) theorem ae_le_of_forall_setIntegral_le {f g : α → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) (hf_le : ∀ s, MeasurableSet s → μ s < ∞ → (∫ x in s, f x ∂μ) ≤ ∫ x in s, g x ∂μ) : f ≤ᵐ[μ] g := by rw [← eventually_sub_nonneg] refine ae_nonneg_of_forall_setIntegral_nonneg (hg.sub hf) fun s hs => ?_ rw [integral_sub' hg.integrableOn hf.integrableOn, sub_nonneg] exact hf_le s hs theorem ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter {f : α → ℝ} {t : Set α} (hf : IntegrableOn f t μ) (hf_zero : ∀ s, MeasurableSet s → μ (s ∩ t) < ∞ → 0 ≤ ∫ x in s ∩ t, f x ∂μ) : 0 ≤ᵐ[μ.restrict t] f := by refine ae_nonneg_of_forall_setIntegral_nonneg hf fun s hs h's => ?_ simp_rw [Measure.restrict_restrict hs] apply hf_zero s hs rwa [Measure.restrict_apply hs] at h's theorem ae_nonneg_of_forall_setIntegral_nonneg_of_sigmaFinite [SigmaFinite μ] {f : α → ℝ} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) : 0 ≤ᵐ[μ] f := by apply ae_of_forall_measure_lt_top_ae_restrict intro t t_meas t_lt_top apply ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter (hf_int_finite t t_meas t_lt_top) intro s s_meas _ exact hf_zero _ (s_meas.inter t_meas) (lt_of_le_of_lt (measure_mono (Set.inter_subset_right)) t_lt_top) theorem AEFinStronglyMeasurable.ae_nonneg_of_forall_setIntegral_nonneg {f : α → ℝ} (hf : AEFinStronglyMeasurable f μ) (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) : 0 ≤ᵐ[μ] f := by let t := hf.sigmaFiniteSet suffices 0 ≤ᵐ[μ.restrict t] f from ae_of_ae_restrict_of_ae_restrict_compl _ this hf.ae_eq_zero_compl.symm.le haveI : SigmaFinite (μ.restrict t) := hf.sigmaFinite_restrict refine ae_nonneg_of_forall_setIntegral_nonneg_of_sigmaFinite (fun s hs hμts => ?_) fun s hs hμts => ?_ · rw [IntegrableOn, Measure.restrict_restrict hs] rw [Measure.restrict_apply hs] at hμts exact hf_int_finite (s ∩ t) (hs.inter hf.measurableSet) hμts · rw [Measure.restrict_restrict hs] rw [Measure.restrict_apply hs] at hμts exact hf_zero (s ∩ t) (hs.inter hf.measurableSet) hμts theorem ae_nonneg_restrict_of_forall_setIntegral_nonneg {f : α → ℝ} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → 0 ≤ ∫ x in s, f x ∂μ) {t : Set α} (ht : MeasurableSet t) (hμt : μ t ≠ ∞) : 0 ≤ᵐ[μ.restrict t] f := by refine ae_nonneg_restrict_of_forall_setIntegral_nonneg_inter (hf_int_finite t ht (lt_top_iff_ne_top.mpr hμt)) fun s hs _ => ?_ refine hf_zero (s ∩ t) (hs.inter ht) ?_ exact (measure_mono Set.inter_subset_right).trans_lt (lt_top_iff_ne_top.mpr hμt) theorem ae_eq_zero_restrict_of_forall_setIntegral_eq_zero_real {f : α → ℝ} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) {t : Set α} (ht : MeasurableSet t) (hμt : μ t ≠ ∞) : f =ᵐ[μ.restrict t] 0 := by suffices h_and : f ≤ᵐ[μ.restrict t] 0 ∧ 0 ≤ᵐ[μ.restrict t] f from h_and.1.mp (h_and.2.mono fun x hx1 hx2 => le_antisymm hx2 hx1) refine ⟨?_, ae_nonneg_restrict_of_forall_setIntegral_nonneg hf_int_finite (fun s hs hμs => (hf_zero s hs hμs).symm.le) ht hμt⟩ suffices h_neg : 0 ≤ᵐ[μ.restrict t] -f by refine h_neg.mono fun x hx => ?_ rw [Pi.neg_apply] at hx simpa using hx refine ae_nonneg_restrict_of_forall_setIntegral_nonneg (fun s hs hμs => (hf_int_finite s hs hμs).neg) (fun s hs hμs => ?_) ht hμt simp_rw [Pi.neg_apply] rw [integral_neg, neg_nonneg] exact (hf_zero s hs hμs).le end Real theorem ae_eq_zero_restrict_of_forall_setIntegral_eq_zero {f : α → E} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) {t : Set α} (ht : MeasurableSet t) (hμt : μ t ≠ ∞) : f =ᵐ[μ.restrict t] 0 := by rcases (hf_int_finite t ht hμt.lt_top).aestronglyMeasurable.isSeparable_ae_range with ⟨u, u_sep, hu⟩ refine ae_eq_zero_of_forall_dual_of_isSeparable ℝ u_sep (fun c => ?_) hu refine ae_eq_zero_restrict_of_forall_setIntegral_eq_zero_real ?_ ?_ ht hμt · intro s hs hμs exact ContinuousLinearMap.integrable_comp c (hf_int_finite s hs hμs) · intro s hs hμs rw [ContinuousLinearMap.integral_comp_comm c (hf_int_finite s hs hμs), hf_zero s hs hμs] exact ContinuousLinearMap.map_zero _ theorem ae_eq_restrict_of_forall_setIntegral_eq {f g : α → E} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hg_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn g s μ) (hfg_zero : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ) {t : Set α} (ht : MeasurableSet t) (hμt : μ t ≠ ∞) : f =ᵐ[μ.restrict t] g := by rw [← sub_ae_eq_zero] have hfg' : ∀ s : Set α, MeasurableSet s → μ s < ∞ → (∫ x in s, (f - g) x ∂μ) = 0 := by intro s hs hμs rw [integral_sub' (hf_int_finite s hs hμs) (hg_int_finite s hs hμs)] exact sub_eq_zero.mpr (hfg_zero s hs hμs) have hfg_int : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn (f - g) s μ := fun s hs hμs => (hf_int_finite s hs hμs).sub (hg_int_finite s hs hμs) exact ae_eq_zero_restrict_of_forall_setIntegral_eq_zero hfg_int hfg' ht hμt theorem ae_eq_zero_of_forall_setIntegral_eq_of_sigmaFinite [SigmaFinite μ] {f : α → E} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) : f =ᵐ[μ] 0 := by let S := spanningSets μ rw [← @Measure.restrict_univ _ _ μ, ← iUnion_spanningSets μ, EventuallyEq, ae_iff, Measure.restrict_apply' (MeasurableSet.iUnion (measurableSet_spanningSets μ))] rw [Set.inter_iUnion, measure_iUnion_null_iff] intro n have h_meas_n : MeasurableSet (S n) := measurableSet_spanningSets μ n have hμn : μ (S n) < ∞ := measure_spanningSets_lt_top μ n rw [← Measure.restrict_apply' h_meas_n] exact ae_eq_zero_restrict_of_forall_setIntegral_eq_zero hf_int_finite hf_zero h_meas_n hμn.ne theorem ae_eq_of_forall_setIntegral_eq_of_sigmaFinite [SigmaFinite μ] {f g : α → E} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hg_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn g s μ) (hfg_eq : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ) : f =ᵐ[μ] g := by rw [← sub_ae_eq_zero] have hfg : ∀ s : Set α, MeasurableSet s → μ s < ∞ → (∫ x in s, (f - g) x ∂μ) = 0 := by intro s hs hμs rw [integral_sub' (hf_int_finite s hs hμs) (hg_int_finite s hs hμs), sub_eq_zero.mpr (hfg_eq s hs hμs)] have hfg_int : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn (f - g) s μ := fun s hs hμs => (hf_int_finite s hs hμs).sub (hg_int_finite s hs hμs) exact ae_eq_zero_of_forall_setIntegral_eq_of_sigmaFinite hfg_int hfg theorem AEFinStronglyMeasurable.ae_eq_zero_of_forall_setIntegral_eq_zero {f : α → E} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) (hf : AEFinStronglyMeasurable f μ) : f =ᵐ[μ] 0 := by let t := hf.sigmaFiniteSet suffices f =ᵐ[μ.restrict t] 0 from ae_of_ae_restrict_of_ae_restrict_compl _ this hf.ae_eq_zero_compl haveI : SigmaFinite (μ.restrict t) := hf.sigmaFinite_restrict refine ae_eq_zero_of_forall_setIntegral_eq_of_sigmaFinite ?_ ?_ · intro s hs hμs rw [IntegrableOn, Measure.restrict_restrict hs] rw [Measure.restrict_apply hs] at hμs exact hf_int_finite _ (hs.inter hf.measurableSet) hμs · intro s hs hμs rw [Measure.restrict_restrict hs] rw [Measure.restrict_apply hs] at hμs exact hf_zero _ (hs.inter hf.measurableSet) hμs theorem AEFinStronglyMeasurable.ae_eq_of_forall_setIntegral_eq {f g : α → E} (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hg_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn g s μ) (hfg_eq : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ) (hf : AEFinStronglyMeasurable f μ) (hg : AEFinStronglyMeasurable g μ) : f =ᵐ[μ] g := by rw [← sub_ae_eq_zero] have hfg : ∀ s : Set α, MeasurableSet s → μ s < ∞ → (∫ x in s, (f - g) x ∂μ) = 0 := by intro s hs hμs rw [integral_sub' (hf_int_finite s hs hμs) (hg_int_finite s hs hμs), sub_eq_zero.mpr (hfg_eq s hs hμs)] have hfg_int : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn (f - g) s μ := fun s hs hμs => (hf_int_finite s hs hμs).sub (hg_int_finite s hs hμs) exact (hf.sub hg).ae_eq_zero_of_forall_setIntegral_eq_zero hfg_int hfg theorem Lp.ae_eq_zero_of_forall_setIntegral_eq_zero (f : Lp E p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) : f =ᵐ[μ] 0 := AEFinStronglyMeasurable.ae_eq_zero_of_forall_setIntegral_eq_zero hf_int_finite hf_zero (Lp.finStronglyMeasurable _ hp_ne_zero hp_ne_top).aefinStronglyMeasurable theorem Lp.ae_eq_of_forall_setIntegral_eq (f g : Lp E p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn f s μ) (hg_int_finite : ∀ s, MeasurableSet s → μ s < ∞ → IntegrableOn g s μ) (hfg : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ) : f =ᵐ[μ] g := AEFinStronglyMeasurable.ae_eq_of_forall_setIntegral_eq hf_int_finite hg_int_finite hfg (Lp.finStronglyMeasurable _ hp_ne_zero hp_ne_top).aefinStronglyMeasurable (Lp.finStronglyMeasurable _ hp_ne_zero hp_ne_top).aefinStronglyMeasurable theorem ae_eq_zero_of_forall_setIntegral_eq_of_finStronglyMeasurable_trim (hm : m ≤ m0) {f : α → E} (hf_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) (hf : FinStronglyMeasurable f (μ.trim hm)) : f =ᵐ[μ] 0 := by obtain ⟨t, ht_meas, htf_zero, htμ⟩ := hf.exists_set_sigmaFinite haveI : SigmaFinite ((μ.restrict t).trim hm) := by rwa [restrict_trim hm μ ht_meas] at htμ have htf_zero : f =ᵐ[μ.restrict tᶜ] 0 := by rw [EventuallyEq, ae_restrict_iff' (MeasurableSet.compl (hm _ ht_meas))] exact Eventually.of_forall htf_zero have hf_meas_m : StronglyMeasurable[m] f := hf.stronglyMeasurable suffices f =ᵐ[μ.restrict t] 0 from ae_of_ae_restrict_of_ae_restrict_compl _ this htf_zero refine measure_eq_zero_of_trim_eq_zero hm ?_ refine ae_eq_zero_of_forall_setIntegral_eq_of_sigmaFinite ?_ ?_ · intro s hs hμs unfold IntegrableOn rw [restrict_trim hm (μ.restrict t) hs, Measure.restrict_restrict (hm s hs)] rw [← restrict_trim hm μ ht_meas, Measure.restrict_apply hs, trim_measurableSet_eq hm (hs.inter ht_meas)] at hμs refine Integrable.trim hm ?_ hf_meas_m exact hf_int_finite _ (hs.inter ht_meas) hμs · intro s hs hμs rw [restrict_trim hm (μ.restrict t) hs, Measure.restrict_restrict (hm s hs)] rw [← restrict_trim hm μ ht_meas, Measure.restrict_apply hs, trim_measurableSet_eq hm (hs.inter ht_meas)] at hμs rw [← integral_trim hm hf_meas_m] exact hf_zero _ (hs.inter ht_meas) hμs theorem Integrable.ae_eq_zero_of_forall_setIntegral_eq_zero {f : α → E} (hf : Integrable f μ) (hf_zero : ∀ s, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) : f =ᵐ[μ] 0 := by have hf_Lp : MemLp f 1 μ := memLp_one_iff_integrable.mpr hf let f_Lp := hf_Lp.toLp f have hf_f_Lp : f =ᵐ[μ] f_Lp := (MemLp.coeFn_toLp hf_Lp).symm refine hf_f_Lp.trans ?_ refine Lp.ae_eq_zero_of_forall_setIntegral_eq_zero f_Lp one_ne_zero ENNReal.coe_ne_top ?_ ?_ · exact fun s _ _ => Integrable.integrableOn (L1.integrable_coeFn _) · intro s hs hμs rw [integral_congr_ae (ae_restrict_of_ae hf_f_Lp.symm)] exact hf_zero s hs hμs theorem Integrable.ae_eq_of_forall_setIntegral_eq (f g : α → E) (hf : Integrable f μ) (hg : Integrable g μ) (hfg : ∀ s : Set α, MeasurableSet s → μ s < ∞ → ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ) : f =ᵐ[μ] g := by rw [← sub_ae_eq_zero] have hfg' : ∀ s : Set α, MeasurableSet s → μ s < ∞ → (∫ x in s, (f - g) x ∂μ) = 0 := by intro s hs hμs rw [integral_sub' hf.integrableOn hg.integrableOn] exact sub_eq_zero.mpr (hfg s hs hμs) exact Integrable.ae_eq_zero_of_forall_setIntegral_eq_zero (hf.sub hg) hfg' variable {β : Type*} [TopologicalSpace β] [MeasurableSpace β] [BorelSpace β] /-- If an integrable function has zero integral on all closed sets, then it is zero almost everywhere. -/ lemma ae_eq_zero_of_forall_setIntegral_isClosed_eq_zero {μ : Measure β} {f : β → E} (hf : Integrable f μ) (h'f : ∀ (s : Set β), IsClosed s → ∫ x in s, f x ∂μ = 0) : f =ᵐ[μ] 0 := by suffices ∀ s, MeasurableSet s → ∫ x in s, f x ∂μ = 0 from hf.ae_eq_zero_of_forall_setIntegral_eq_zero (fun s hs _ ↦ this s hs) have A : ∀ (t : Set β), MeasurableSet t → ∫ (x : β) in t, f x ∂μ = 0 → ∫ (x : β) in tᶜ, f x ∂μ = 0 := by intro t t_meas ht have I : ∫ x, f x ∂μ = 0 := by rw [← setIntegral_univ]; exact h'f _ isClosed_univ simpa [ht, I] using integral_add_compl t_meas hf intro s hs induction s, hs using MeasurableSet.induction_on_open with | isOpen U hU => exact compl_compl U ▸ A _ hU.measurableSet.compl (h'f _ hU.isClosed_compl) | compl s hs ihs => exact A s hs ihs | iUnion g g_disj g_meas hg => simp [integral_iUnion g_meas g_disj hf.integrableOn, hg] /-- If an integrable function has zero integral on all compact sets in a sigma-compact space, then it is zero almost everywhere. -/ lemma ae_eq_zero_of_forall_setIntegral_isCompact_eq_zero [SigmaCompactSpace β] [R1Space β] {μ : Measure β} {f : β → E} (hf : Integrable f μ) (h'f : ∀ (s : Set β), IsCompact s → ∫ x in s, f x ∂μ = 0) : f =ᵐ[μ] 0 := by apply ae_eq_zero_of_forall_setIntegral_isClosed_eq_zero hf (fun s hs ↦ ?_) let t : ℕ → Set β := fun n ↦ closure (compactCovering β n) ∩ s suffices H : Tendsto (fun n ↦ ∫ x in t n, f x ∂μ) atTop (𝓝 (∫ x in s, f x ∂μ)) by have A : ∀ n, ∫ x in t n, f x ∂μ = 0 := fun n ↦ h'f _ ((isCompact_compactCovering β n).closure.inter_right hs) simp_rw [A, tendsto_const_nhds_iff] at H exact H.symm have B : s = ⋃ n, t n := by rw [← Set.iUnion_inter, iUnion_closure_compactCovering, Set.univ_inter] rw [B] apply tendsto_setIntegral_of_monotone · intro n exact (isClosed_closure.inter hs).measurableSet · intro m n hmn simp only [t, Set.le_iff_subset] gcongr · exact hf.integrableOn /-- If a locally integrable function has zero integral on all compact sets in a sigma-compact space, then it is zero almost everywhere. -/ lemma ae_eq_zero_of_forall_setIntegral_isCompact_eq_zero' [SigmaCompactSpace β] [R1Space β] {μ : Measure β} {f : β → E} (hf : LocallyIntegrable f μ) (h'f : ∀ (s : Set β), IsCompact s → ∫ x in s, f x ∂μ = 0) : f =ᵐ[μ] 0 := by rw [← μ.restrict_univ, ← iUnion_closure_compactCovering] apply (ae_restrict_iUnion_iff _ _).2 (fun n ↦ ?_) apply ae_eq_zero_of_forall_setIntegral_isCompact_eq_zero · exact hf.integrableOn_isCompact (isCompact_compactCovering β n).closure · intro s hs rw [Measure.restrict_restrict' measurableSet_closure] exact h'f _ (hs.inter_right isClosed_closure) end AeEqOfForallSetIntegralEq end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean
import Mathlib.MeasureTheory.MeasurableSpace.Basic import Mathlib.MeasureTheory.Measure.MeasureSpaceDef /-! # Sequence of measurable functions associated to a sequence of a.e.-measurable functions We define here tools to prove statements about limits (infi, supr...) of sequences of `AEMeasurable` functions. Given a sequence of a.e.-measurable functions `f : ι → α → β` with hypothesis `hf : ∀ i, AEMeasurable (f i) μ`, and a pointwise property `p : α → (ι → β) → Prop` such that we have `hp : ∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, we define a sequence of measurable functions `aeSeq hf p` and a measurable set `aeSeqSet hf p`, such that * `μ (aeSeqSet hf p)ᶜ = 0` * `x ∈ aeSeqSet hf p → ∀ i : ι, aeSeq hf hp i x = f i x` * `x ∈ aeSeqSet hf p → p x (fun n ↦ f n x)` -/ open MeasureTheory variable {ι : Sort*} {α β γ : Type*} [MeasurableSpace α] [MeasurableSpace β] {f : ι → α → β} {μ : Measure α} {p : α → (ι → β) → Prop} /-- If we have the additional hypothesis `∀ᵐ x ∂μ, p x (fun n ↦ f n x)`, this is a measurable set whose complement has measure 0 such that for all `x ∈ aeSeqSet`, `f i x` is equal to `(hf i).mk (f i) x` for all `i` and we have the pointwise property `p x (fun n ↦ f n x)`. -/ def aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : Set α := (toMeasurable μ { x | (∀ i, f i x = (hf i).mk (f i) x) ∧ p x fun n => f n x }ᶜ)ᶜ open Classical in /-- A sequence of measurable functions that are equal to `f` and verify property `p` on the measurable set `aeSeqSet hf p`. -/ noncomputable def aeSeq (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) : ι → α → β := fun i x => ite (x ∈ aeSeqSet hf p) ((hf i).mk (f i) x) (⟨f i x⟩ : Nonempty β).some namespace aeSeq section MemAESeqSet theorem mk_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : (hf i).mk (f i) x = f i x := haveI h_ss : aeSeqSet hf p ⊆ { x | ∀ i, f i x = (hf i).mk (f i) x } := by rw [aeSeqSet, ← compl_compl { x | ∀ i, f i x = (hf i).mk (f i) x }, Set.compl_subset_compl] refine Set.Subset.trans (Set.compl_subset_compl.mpr fun x h => ?_) (subset_toMeasurable _ _) exact h.1 (h_ss hx i).symm theorem aeSeq_eq_mk_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = (hf i).mk (f i) x := by simp only [aeSeq, hx, if_true] theorem aeSeq_eq_fun_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) (i : ι) : aeSeq hf p i x = f i x := by simp only [aeSeq_eq_mk_of_mem_aeSeqSet hf hx i, mk_eq_fun_of_mem_aeSeqSet hf hx i] theorem prop_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) : p x fun n => aeSeq hf p n x := by simp only [aeSeq, hx, if_true] rw [funext fun n => mk_eq_fun_of_mem_aeSeqSet hf hx n] have h_ss : aeSeqSet hf p ⊆ { x | p x fun n => f n x } := by rw [← compl_compl { x | p x fun n => f n x }, aeSeqSet, Set.compl_subset_compl] refine Set.Subset.trans (Set.compl_subset_compl.mpr ?_) (subset_toMeasurable _ _) exact fun x hx => hx.2 have hx' := Set.mem_of_subset_of_mem h_ss hx exact hx' theorem fun_prop_of_mem_aeSeqSet (hf : ∀ i, AEMeasurable (f i) μ) {x : α} (hx : x ∈ aeSeqSet hf p) : p x fun n => f n x := by have h_eq : (fun n => f n x) = fun n => aeSeq hf p n x := funext fun n => (aeSeq_eq_fun_of_mem_aeSeqSet hf hx n).symm rw [h_eq] exact prop_of_mem_aeSeqSet hf hx end MemAESeqSet theorem aeSeqSet_measurableSet {hf : ∀ i, AEMeasurable (f i) μ} : MeasurableSet (aeSeqSet hf p) := (measurableSet_toMeasurable _ _).compl theorem measurable (hf : ∀ i, AEMeasurable (f i) μ) (p : α → (ι → β) → Prop) (i : ι) : Measurable (aeSeq hf p i) := Measurable.ite aeSeqSet_measurableSet (hf i).measurable_mk <| measurable_const' fun _ _ => rfl theorem measure_compl_aeSeqSet_eq_zero [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x fun n => f n x) : μ (aeSeqSet hf p)ᶜ = 0 := by rw [aeSeqSet, compl_compl, measure_toMeasurable] have hf_eq := fun i => (hf i).ae_eq_mk simp_rw [Filter.EventuallyEq, ← ae_all_iff] at hf_eq exact Filter.Eventually.and hf_eq hp theorem aeSeq_eq_mk_ae [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x fun n => f n x) : ∀ᵐ a : α ∂μ, ∀ i : ι, aeSeq hf p i a = (hf i).mk (f i) a := have h_ss : aeSeqSet hf p ⊆ { a : α | ∀ i, aeSeq hf p i a = (hf i).mk (f i) a } := fun x hx i => by simp only [aeSeq, hx, if_true] (ae_iff.2 (measure_compl_aeSeqSet_eq_zero hf hp)).mono h_ss theorem aeSeq_eq_fun_ae [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x fun n => f n x) : ∀ᵐ a : α ∂μ, ∀ i : ι, aeSeq hf p i a = f i a := haveI h_ss : { a : α | ¬∀ i : ι, aeSeq hf p i a = f i a } ⊆ (aeSeqSet hf p)ᶜ := fun _ => mt fun hx i => aeSeq_eq_fun_of_mem_aeSeqSet hf hx i measure_mono_null h_ss (measure_compl_aeSeqSet_eq_zero hf hp) theorem aeSeq_n_eq_fun_n_ae [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x fun n => f n x) (n : ι) : aeSeq hf p n =ᵐ[μ] f n := ae_all_iff.mp (aeSeq_eq_fun_ae hf hp) n theorem iSup [SupSet β] [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x fun n => f n x) : ⨆ n, aeSeq hf p n =ᵐ[μ] ⨆ n, f n := by simp_rw [Filter.EventuallyEq, ae_iff, iSup_apply] have h_ss : aeSeqSet hf p ⊆ { a : α | ⨆ i : ι, aeSeq hf p i a = ⨆ i : ι, f i a } := by intro x hx congr exact funext fun i => aeSeq_eq_fun_of_mem_aeSeqSet hf hx i exact measure_mono_null (Set.compl_subset_compl.mpr h_ss) (measure_compl_aeSeqSet_eq_zero hf hp) theorem iInf [InfSet β] [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) (hp : ∀ᵐ x ∂μ, p x fun n ↦ f n x) : ⨅ n, aeSeq hf p n =ᵐ[μ] ⨅ n, f n := iSup (β := βᵒᵈ) hf hp end aeSeq
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConvergenceInDistribution.lean
import Mathlib.MeasureTheory.Measure.ProbabilityMeasure /-! # Convergence in distribution We introduce a definition of convergence in distribution of random variables: this is the weak convergence of the laws of the random variables. In Mathlib terms this is a `Tendsto` in the `ProbabilityMeasure` type. The definition assumes that the random variables are defined on the same probability space, which is the most common setting in applications. Convergence in distribution for random variables on different probability spaces can be talked about using the `ProbabilityMeasure` type directly. ## Main definitions * `TendstoInDistribution X l Z μ`: the sequence of random variables `X n` converges in distribution to the random variable `Z` along the filter `l` with respect to the probability measure `μ`. ## Main statements * `TendstoInDistribution.continuous_comp`: **Continuous mapping theorem**. If `X n` tends to `Z` in distribution and `g` is continuous, then `g ∘ X n` tends to `g ∘ Z` in distribution. -/ open Filter open scoped Topology namespace MeasureTheory variable {Ω ι E : Type*} {m : MeasurableSpace Ω} {μ : Measure Ω} [IsProbabilityMeasure μ] [TopologicalSpace E] {mE : MeasurableSpace E} {X Y : ι → Ω → E} {Z : Ω → E} {l : Filter ι} section TendstoInDistribution /-- Convergence in distribution of random variables. This is the weak convergence of the laws of the random variables: `Tendsto` in the `ProbabilityMeasure` type. -/ structure TendstoInDistribution [OpensMeasurableSpace E] (X : ι → Ω → E) (l : Filter ι) (Z : Ω → E) (μ : Measure Ω := by volume_tac) [IsProbabilityMeasure μ] : Prop where forall_aemeasurable : ∀ i, AEMeasurable (X i) μ aemeasurable_limit : AEMeasurable Z μ := by fun_prop tendsto : Tendsto (β := ProbabilityMeasure E) (fun n ↦ ⟨μ.map (X n), Measure.isProbabilityMeasure_map (forall_aemeasurable n)⟩) l (𝓝 ⟨μ.map Z, Measure.isProbabilityMeasure_map aemeasurable_limit⟩) lemma tendstoInDistribution_const [OpensMeasurableSpace E] (hZ : AEMeasurable Z μ) : TendstoInDistribution (fun _ ↦ Z) l Z μ where forall_aemeasurable := fun _ ↦ by fun_prop tendsto := tendsto_const_nhds lemma tendstoInDistribution_unique [HasOuterApproxClosed E] [BorelSpace E] (X : ι → Ω → E) {Z W : Ω → E} [l.NeBot] (h1 : TendstoInDistribution X l Z μ) (h2 : TendstoInDistribution X l W μ) : μ.map Z = μ.map W := by have h_eq := tendsto_nhds_unique h1.tendsto h2.tendsto rw [Subtype.ext_iff] at h_eq simpa using h_eq /-- **Continuous mapping theorem**: if `X n` tends to `Z` in distribution and `g` is continuous, then `g ∘ X n` tends to `g ∘ Z` in distribution. -/ theorem TendstoInDistribution.continuous_comp {F : Type*} [OpensMeasurableSpace E] [TopologicalSpace F] [MeasurableSpace F] [BorelSpace F] {g : E → F} (hg : Continuous g) (h : TendstoInDistribution X l Z μ) : TendstoInDistribution (fun n ↦ g ∘ X n) l (g ∘ Z) μ where forall_aemeasurable := fun n ↦ hg.measurable.comp_aemeasurable (h.forall_aemeasurable n) aemeasurable_limit := hg.measurable.comp_aemeasurable h.aemeasurable_limit tendsto := by convert ProbabilityMeasure.tendsto_map_of_tendsto_of_continuous _ _ h.tendsto hg · simp only [ProbabilityMeasure.map, ProbabilityMeasure.coe_mk, Subtype.mk.injEq] rw [AEMeasurable.map_map_of_aemeasurable hg.aemeasurable (h.forall_aemeasurable _)] · simp only [ProbabilityMeasure.map, ProbabilityMeasure.coe_mk] congr rw [AEMeasurable.map_map_of_aemeasurable hg.aemeasurable h.aemeasurable_limit] end TendstoInDistribution end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL1.lean
import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL2 import Mathlib.MeasureTheory.Measure.Real /-! # Conditional expectation in L1 This file contains two more steps of the construction of the conditional expectation, which is completed in `MeasureTheory.Function.ConditionalExpectation.Basic`. See that file for a description of the full process. The conditional expectation of an `L²` function is defined in `MeasureTheory.Function.ConditionalExpectation.CondexpL2`. In this file, we perform two steps. * Show that the conditional expectation of the indicator of a measurable set with finite measure is integrable and define a map `Set α → (E →L[ℝ] (α →₁[μ] E))` which to a set associates a linear map. That linear map sends `x ∈ E` to the conditional expectation of the indicator of the set with value `x`. * Extend that map to `condExpL1CLM : (α →₁[μ] E) →L[ℝ] (α →₁[μ] E)`. This is done using the same construction as the Bochner integral (see the file `MeasureTheory/Integral/SetToL1`). ## Main definitions * `condExpL1`: Conditional expectation of a function as a linear map from `L1` to itself. -/ noncomputable section open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap open scoped NNReal ENNReal Topology MeasureTheory namespace MeasureTheory variable {α F F' G G' 𝕜 : Type*} [RCLike 𝕜] -- 𝕜 for ℝ or ℂ -- F for a Lp submodule [NormedAddCommGroup F] [NormedSpace 𝕜 F] -- F' for integrals on a Lp submodule [NormedAddCommGroup F'] [NormedSpace 𝕜 F'] [NormedSpace ℝ F'] [CompleteSpace F'] -- G for a Lp add_subgroup [NormedAddCommGroup G] -- G' for integrals on a Lp add_subgroup [NormedAddCommGroup G'] [NormedSpace ℝ G'] [CompleteSpace G'] section CondexpInd /-! ## Conditional expectation of an indicator as a continuous linear map. The goal of this section is to build `condExpInd (hm : m ≤ m0) (μ : Measure α) (s : Set s) : G →L[ℝ] α →₁[μ] G`, which takes `x : G` to the conditional expectation of the indicator of the set `s` with value `x`, seen as an element of `α →₁[μ] G`. -/ variable {m m0 : MeasurableSpace α} {μ : Measure α} {s t : Set α} [NormedSpace ℝ G] section CondexpIndL1Fin /-- Conditional expectation of the indicator of a measurable set with finite measure, as a function in L1. -/ def condExpIndL1Fin (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : α →₁[μ] G := (integrable_condExpIndSMul hm hs hμs x).toL1 _ theorem condExpIndL1Fin_ae_eq_condExpIndSMul (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : condExpIndL1Fin hm hs hμs x =ᵐ[μ] condExpIndSMul hm hs hμs x := (integrable_condExpIndSMul hm hs hμs x).coeFn_toL1 variable {hm : m ≤ m0} [SigmaFinite (μ.trim hm)] -- Porting note: this lemma fills the hole in `refine' (MemLp.coeFn_toLp _) ...` -- which is not automatically filled in Lean 4 private theorem q {hs : MeasurableSet s} {hμs : μ s ≠ ∞} {x : G} : MemLp (condExpIndSMul hm hs hμs x) 1 μ := by rw [memLp_one_iff_integrable]; apply integrable_condExpIndSMul theorem condExpIndL1Fin_add (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x y : G) : condExpIndL1Fin hm hs hμs (x + y) = condExpIndL1Fin hm hs hμs x + condExpIndL1Fin hm hs hμs y := by ext1 unfold condExpIndL1Fin Integrable.toL1 grw [Lp.coeFn_add, MemLp.coeFn_toLp, MemLp.coeFn_toLp, MemLp.coeFn_toLp, condExpIndSMul_add, Lp.coeFn_add] theorem condExpIndL1Fin_smul (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : ℝ) (x : G) : condExpIndL1Fin hm hs hμs (c • x) = c • condExpIndL1Fin hm hs hμs x := by ext1 grw [Lp.coeFn_smul, condExpIndL1Fin_ae_eq_condExpIndSMul, condExpIndL1Fin_ae_eq_condExpIndSMul, condExpIndSMul_smul, Lp.coeFn_smul] theorem condExpIndL1Fin_smul' [NormedSpace ℝ F] [SMulCommClass ℝ 𝕜 F] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : 𝕜) (x : F) : condExpIndL1Fin hm hs hμs (c • x) = c • condExpIndL1Fin hm hs hμs x := by ext1 grw [Lp.coeFn_smul, condExpIndL1Fin_ae_eq_condExpIndSMul, condExpIndL1Fin_ae_eq_condExpIndSMul, condExpIndSMul_smul, Lp.coeFn_smul] theorem norm_condExpIndL1Fin_le (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : ‖condExpIndL1Fin hm hs hμs x‖ ≤ μ.real s * ‖x‖ := by rw [L1.norm_eq_integral_norm, ← ENNReal.toReal_ofReal (norm_nonneg x), measureReal_def, ← ENNReal.toReal_mul, ← ENNReal.ofReal_le_iff_le_toReal (ENNReal.mul_ne_top hμs ENNReal.ofReal_ne_top), ofReal_integral_norm_eq_lintegral_enorm] swap; · rw [← memLp_one_iff_integrable]; exact Lp.memLp _ have h_eq : ∫⁻ a, ‖condExpIndL1Fin hm hs hμs x a‖ₑ ∂μ = ∫⁻ a, ‖condExpIndSMul hm hs hμs x a‖ₑ ∂μ := by refine lintegral_congr_ae ?_ filter_upwards [condExpIndL1Fin_ae_eq_condExpIndSMul hm hs hμs x] with z hz rw [hz] rw [h_eq, ofReal_norm_eq_enorm] exact lintegral_nnnorm_condExpIndSMul_le hm hs hμs x theorem condExpIndL1Fin_disjoint_union (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) (hst : Disjoint s t) (x : G) : condExpIndL1Fin hm (hs.union ht) ((measure_union_le s t).trans_lt (lt_top_iff_ne_top.mpr (ENNReal.add_ne_top.mpr ⟨hμs, hμt⟩))).ne x = condExpIndL1Fin hm hs hμs x + condExpIndL1Fin hm ht hμt x := by ext1 grw [Lp.coeFn_add, condExpIndL1Fin_ae_eq_condExpIndSMul, condExpIndL1Fin_ae_eq_condExpIndSMul, condExpIndL1Fin_ae_eq_condExpIndSMul] rw [condExpIndSMul] rw [indicatorConstLp_disjoint_union hs ht hμs hμt hst (1 : ℝ)] rw [map_add] push_cast rw [map_add] grw [Lp.coeFn_add] rfl end CondexpIndL1Fin section CondexpIndL1 open scoped Classical in /-- Conditional expectation of the indicator of a set, as a function in L1. Its value for sets which are not both measurable and of finite measure is not used: we set it to 0. -/ def condExpIndL1 {m m0 : MeasurableSpace α} (hm : m ≤ m0) (μ : Measure α) (s : Set α) [SigmaFinite (μ.trim hm)] (x : G) : α →₁[μ] G := if hs : MeasurableSet s ∧ μ s ≠ ∞ then condExpIndL1Fin hm hs.1 hs.2 x else 0 variable {hm : m ≤ m0} [SigmaFinite (μ.trim hm)] theorem condExpIndL1_of_measurableSet_of_measure_ne_top (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : condExpIndL1 hm μ s x = condExpIndL1Fin hm hs hμs x := by simp only [condExpIndL1, And.intro hs hμs, dif_pos, Ne, not_false_iff, and_self_iff] theorem condExpIndL1_of_measure_eq_top (hμs : μ s = ∞) (x : G) : condExpIndL1 hm μ s x = 0 := by simp only [condExpIndL1, hμs, not_true, Ne, dif_neg, not_false_iff, and_false] theorem condExpIndL1_of_not_measurableSet (hs : ¬MeasurableSet s) (x : G) : condExpIndL1 hm μ s x = 0 := by simp only [condExpIndL1, hs, dif_neg, not_false_iff, false_and] theorem condExpIndL1_add (x y : G) : condExpIndL1 hm μ s (x + y) = condExpIndL1 hm μ s x + condExpIndL1 hm μ s y := by by_cases hs : MeasurableSet s swap; · simp_rw [condExpIndL1_of_not_measurableSet hs]; rw [zero_add] by_cases hμs : μ s = ∞ · simp_rw [condExpIndL1_of_measure_eq_top hμs]; rw [zero_add] · simp_rw [condExpIndL1_of_measurableSet_of_measure_ne_top hs hμs] exact condExpIndL1Fin_add hs hμs x y theorem condExpIndL1_smul (c : ℝ) (x : G) : condExpIndL1 hm μ s (c • x) = c • condExpIndL1 hm μ s x := by by_cases hs : MeasurableSet s swap; · simp_rw [condExpIndL1_of_not_measurableSet hs]; rw [smul_zero] by_cases hμs : μ s = ∞ · simp_rw [condExpIndL1_of_measure_eq_top hμs]; rw [smul_zero] · simp_rw [condExpIndL1_of_measurableSet_of_measure_ne_top hs hμs] exact condExpIndL1Fin_smul hs hμs c x theorem condExpIndL1_smul' [NormedSpace ℝ F] [SMulCommClass ℝ 𝕜 F] (c : 𝕜) (x : F) : condExpIndL1 hm μ s (c • x) = c • condExpIndL1 hm μ s x := by by_cases hs : MeasurableSet s swap; · simp_rw [condExpIndL1_of_not_measurableSet hs]; rw [smul_zero] by_cases hμs : μ s = ∞ · simp_rw [condExpIndL1_of_measure_eq_top hμs]; rw [smul_zero] · simp_rw [condExpIndL1_of_measurableSet_of_measure_ne_top hs hμs] exact condExpIndL1Fin_smul' hs hμs c x theorem norm_condExpIndL1_le (x : G) : ‖condExpIndL1 hm μ s x‖ ≤ μ.real s * ‖x‖ := by by_cases hs : MeasurableSet s swap · simp_rw [condExpIndL1_of_not_measurableSet hs]; rw [Lp.norm_zero] exact mul_nonneg ENNReal.toReal_nonneg (norm_nonneg _) by_cases hμs : μ s = ∞ · rw [condExpIndL1_of_measure_eq_top hμs x, Lp.norm_zero] exact mul_nonneg ENNReal.toReal_nonneg (norm_nonneg _) · rw [condExpIndL1_of_measurableSet_of_measure_ne_top hs hμs x] exact norm_condExpIndL1Fin_le hs hμs x theorem continuous_condExpIndL1 : Continuous fun x : G => condExpIndL1 hm μ s x := continuous_of_linear_of_bound condExpIndL1_add condExpIndL1_smul norm_condExpIndL1_le theorem condExpIndL1_disjoint_union (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) (hst : Disjoint s t) (x : G) : condExpIndL1 hm μ (s ∪ t) x = condExpIndL1 hm μ s x + condExpIndL1 hm μ t x := by have hμst : μ (s ∪ t) ≠ ∞ := ((measure_union_le s t).trans_lt (lt_top_iff_ne_top.mpr (ENNReal.add_ne_top.mpr ⟨hμs, hμt⟩))).ne rw [condExpIndL1_of_measurableSet_of_measure_ne_top hs hμs x, condExpIndL1_of_measurableSet_of_measure_ne_top ht hμt x, condExpIndL1_of_measurableSet_of_measure_ne_top (hs.union ht) hμst x] exact condExpIndL1Fin_disjoint_union hs ht hμs hμt hst x end CondexpIndL1 variable (G) /-- Conditional expectation of the indicator of a set, as a linear map from `G` to L1. -/ def condExpInd {m m0 : MeasurableSpace α} (hm : m ≤ m0) (μ : Measure α) [SigmaFinite (μ.trim hm)] (s : Set α) : G →L[ℝ] α →₁[μ] G where toFun := condExpIndL1 hm μ s map_add' := condExpIndL1_add map_smul' := condExpIndL1_smul cont := continuous_condExpIndL1 variable {G} theorem condExpInd_ae_eq_condExpIndSMul (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : condExpInd G hm μ s x =ᵐ[μ] condExpIndSMul hm hs hμs x := by grw [← condExpIndL1Fin_ae_eq_condExpIndSMul] simp [condExpInd, condExpIndL1, hs, hμs] variable {hm : m ≤ m0} [SigmaFinite (μ.trim hm)] theorem aestronglyMeasurable_condExpInd (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : AEStronglyMeasurable[m] (condExpInd G hm μ s x) μ := (aestronglyMeasurable_condExpIndSMul hm hs hμs x).congr (condExpInd_ae_eq_condExpIndSMul hm hs hμs x).symm @[simp] theorem condExpInd_empty : condExpInd G hm μ ∅ = (0 : G →L[ℝ] α →₁[μ] G) := by ext x grw [condExpInd_ae_eq_condExpIndSMul, condExpIndSMul_empty, zero_apply, Lp.coeFn_zero, Lp.coeFn_zero] theorem condExpInd_smul' [NormedSpace ℝ F] [SMulCommClass ℝ 𝕜 F] (c : 𝕜) (x : F) : condExpInd F hm μ s (c • x) = c • condExpInd F hm μ s x := condExpIndL1_smul' c x theorem norm_condExpInd_apply_le (x : G) : ‖condExpInd G hm μ s x‖ ≤ μ.real s * ‖x‖ := norm_condExpIndL1_le x theorem norm_condExpInd_le : ‖(condExpInd G hm μ s : G →L[ℝ] α →₁[μ] G)‖ ≤ μ.real s := ContinuousLinearMap.opNorm_le_bound _ ENNReal.toReal_nonneg norm_condExpInd_apply_le theorem condExpInd_disjoint_union_apply (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) (hst : Disjoint s t) (x : G) : condExpInd G hm μ (s ∪ t) x = condExpInd G hm μ s x + condExpInd G hm μ t x := condExpIndL1_disjoint_union hs ht hμs hμt hst x theorem condExpInd_disjoint_union (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) (hst : Disjoint s t) : (condExpInd G hm μ (s ∪ t) : G →L[ℝ] α →₁[μ] G) = condExpInd G hm μ s + condExpInd G hm μ t := by ext1 x; push_cast; exact condExpInd_disjoint_union_apply hs ht hμs hμt hst x variable (G) theorem dominatedFinMeasAdditive_condExpInd (hm : m ≤ m0) (μ : Measure α) [SigmaFinite (μ.trim hm)] : DominatedFinMeasAdditive μ (condExpInd G hm μ : Set α → G →L[ℝ] α →₁[μ] G) 1 := ⟨fun _ _ => condExpInd_disjoint_union, fun _ _ _ => norm_condExpInd_le.trans (one_mul _).symm.le⟩ variable {G} theorem setIntegral_condExpInd (hs : MeasurableSet[m] s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) (x : G') : ∫ a in s, condExpInd G' hm μ t x a ∂μ = μ.real (t ∩ s) • x := calc ∫ a in s, condExpInd G' hm μ t x a ∂μ = ∫ a in s, condExpIndSMul hm ht hμt x a ∂μ := setIntegral_congr_ae (hm s hs) ((condExpInd_ae_eq_condExpIndSMul hm ht hμt x).mono fun _ hx _ => hx) _ = μ.real (t ∩ s) • x := setIntegral_condExpIndSMul hs ht hμs hμt x theorem condExpInd_of_measurable (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) (c : G) : condExpInd G hm μ s c = indicatorConstLp 1 (hm s hs) hμs c := by ext1 grw [indicatorConstLp_coeFn, condExpInd_ae_eq_condExpIndSMul, condExpIndSMul_ae_eq_smul] rw [condExpL2_indicator_of_measurable hm hs hμs (1 : ℝ)] filter_upwards [@indicatorConstLp_coeFn α _ _ 2 μ _ s (hm s hs) hμs (1 : ℝ)] with x hx rw [hx] by_cases hx_mem : x ∈ s <;> simp [hx_mem] theorem condExpInd_nonneg {E} [NormedAddCommGroup E] [PartialOrder E] [NormedSpace ℝ E] [IsOrderedModule ℝ E] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) (hx : 0 ≤ x) : 0 ≤ condExpInd E hm μ s x := by rw [← coeFn_le] refine EventuallyLE.trans_eq ?_ (condExpInd_ae_eq_condExpIndSMul hm hs hμs x).symm exact (coeFn_zero E 1 μ).trans_le (condExpIndSMul_nonneg hs hμs x hx) end CondexpInd section CondexpL1 variable {m m0 : MeasurableSpace α} {μ : Measure α} {hm : m ≤ m0} [SigmaFinite (μ.trim hm)] {f g : α → F'} {s : Set α} variable (F') /-- Conditional expectation of a function as a linear map from `α →₁[μ] F'` to itself. -/ def condExpL1CLM (hm : m ≤ m0) (μ : Measure α) [SigmaFinite (μ.trim hm)] : (α →₁[μ] F') →L[ℝ] α →₁[μ] F' := L1.setToL1 (dominatedFinMeasAdditive_condExpInd F' hm μ) variable {F'} theorem condExpL1CLM_smul (c : 𝕜) (f : α →₁[μ] F') : condExpL1CLM F' hm μ (c • f) = c • condExpL1CLM F' hm μ f := by refine L1.setToL1_smul (dominatedFinMeasAdditive_condExpInd F' hm μ) ?_ c f exact fun c s x => condExpInd_smul' c x theorem condExpL1CLM_indicatorConstLp (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : F') : (condExpL1CLM F' hm μ) (indicatorConstLp 1 hs hμs x) = condExpInd F' hm μ s x := L1.setToL1_indicatorConstLp (dominatedFinMeasAdditive_condExpInd F' hm μ) hs hμs x theorem condExpL1CLM_indicatorConst (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : F') : (condExpL1CLM F' hm μ) ↑(simpleFunc.indicatorConst 1 hs hμs x) = condExpInd F' hm μ s x := by rw [Lp.simpleFunc.coe_indicatorConst]; exact condExpL1CLM_indicatorConstLp hs hμs x /-- Auxiliary lemma used in the proof of `setIntegral_condExpL1CLM`. -/ theorem setIntegral_condExpL1CLM_of_measure_ne_top (f : α →₁[μ] F') (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) : ∫ x in s, condExpL1CLM F' hm μ f x ∂μ = ∫ x in s, f x ∂μ := by refine @Lp.induction _ _ _ _ _ _ _ ENNReal.one_ne_top (fun f : α →₁[μ] F' => ∫ x in s, condExpL1CLM F' hm μ f x ∂μ = ∫ x in s, f x ∂μ) ?_ ?_ (isClosed_eq ?_ ?_) f · intro x t ht hμt simp_rw [condExpL1CLM_indicatorConst ht hμt.ne x] rw [Lp.simpleFunc.coe_indicatorConst, setIntegral_indicatorConstLp (hm _ hs)] exact setIntegral_condExpInd hs ht hμs hμt.ne x · intro f g hf_Lp hg_Lp _ hf hg simp_rw [(condExpL1CLM F' hm μ).map_add] rw [setIntegral_congr_ae (hm s hs) ((Lp.coeFn_add (condExpL1CLM F' hm μ (hf_Lp.toLp f)) (condExpL1CLM F' hm μ (hg_Lp.toLp g))).mono fun x hx _ => hx)] rw [setIntegral_congr_ae (hm s hs) ((Lp.coeFn_add (hf_Lp.toLp f) (hg_Lp.toLp g)).mono fun x hx _ => hx)] simp_rw [Pi.add_apply] rw [integral_add (L1.integrable_coeFn _).integrableOn (L1.integrable_coeFn _).integrableOn, integral_add (L1.integrable_coeFn _).integrableOn (L1.integrable_coeFn _).integrableOn, hf, hg] · exact (continuous_setIntegral s).comp (condExpL1CLM F' hm μ).continuous · exact continuous_setIntegral s /-- The integral of the conditional expectation `condExpL1CLM` over an `m`-measurable set is equal to the integral of `f` on that set. See also `setIntegral_condExp`, the similar statement for `condExp`. -/ theorem setIntegral_condExpL1CLM (f : α →₁[μ] F') (hs : MeasurableSet[m] s) : ∫ x in s, condExpL1CLM F' hm μ f x ∂μ = ∫ x in s, f x ∂μ := by let S := spanningSets (μ.trim hm) have hS_meas : ∀ i, MeasurableSet[m] (S i) := measurableSet_spanningSets (μ.trim hm) have hS_meas0 : ∀ i, MeasurableSet (S i) := fun i => hm _ (hS_meas i) have hs_eq : s = ⋃ i, S i ∩ s := by simp_rw [Set.inter_comm] rw [← Set.inter_iUnion, iUnion_spanningSets (μ.trim hm), Set.inter_univ] have hS_finite : ∀ i, μ (S i ∩ s) < ∞ := by refine fun i => (measure_mono Set.inter_subset_left).trans_lt ?_ have hS_finite_trim := measure_spanningSets_lt_top (μ.trim hm) i rwa [trim_measurableSet_eq hm (hS_meas i)] at hS_finite_trim have h_mono : Monotone fun i => S i ∩ s := by intro i j hij x simp_rw [Set.mem_inter_iff] exact fun h => ⟨monotone_spanningSets (μ.trim hm) hij h.1, h.2⟩ have h_eq_forall : (fun i => ∫ x in S i ∩ s, condExpL1CLM F' hm μ f x ∂μ) = fun i => ∫ x in S i ∩ s, f x ∂μ := funext fun i => setIntegral_condExpL1CLM_of_measure_ne_top f (@MeasurableSet.inter α m _ _ (hS_meas i) hs) (hS_finite i).ne have h_right : Tendsto (fun i => ∫ x in S i ∩ s, f x ∂μ) atTop (𝓝 (∫ x in s, f x ∂μ)) := by have h := tendsto_setIntegral_of_monotone (fun i => (hS_meas0 i).inter (hm s hs)) h_mono (L1.integrable_coeFn f).integrableOn rwa [← hs_eq] at h have h_left : Tendsto (fun i => ∫ x in S i ∩ s, condExpL1CLM F' hm μ f x ∂μ) atTop (𝓝 (∫ x in s, condExpL1CLM F' hm μ f x ∂μ)) := by have h := tendsto_setIntegral_of_monotone (fun i => (hS_meas0 i).inter (hm s hs)) h_mono (L1.integrable_coeFn (condExpL1CLM F' hm μ f)).integrableOn rwa [← hs_eq] at h rw [h_eq_forall] at h_left exact tendsto_nhds_unique h_left h_right theorem aestronglyMeasurable_condExpL1CLM (f : α →₁[μ] F') : AEStronglyMeasurable[m] (condExpL1CLM F' hm μ f) μ := by refine @Lp.induction _ _ _ _ _ _ _ ENNReal.one_ne_top (fun f : α →₁[μ] F' => AEStronglyMeasurable[m] (condExpL1CLM F' hm μ f) μ) ?_ ?_ ?_ f · intro c s hs hμs rw [condExpL1CLM_indicatorConst hs hμs.ne c] exact aestronglyMeasurable_condExpInd hs hμs.ne c · intro f g hf hg _ hfm hgm rw [(condExpL1CLM F' hm μ).map_add] exact (hfm.add hgm).congr (coeFn_add ..).symm · have : {f : Lp F' 1 μ | AEStronglyMeasurable[m] (condExpL1CLM F' hm μ f) μ} = condExpL1CLM F' hm μ ⁻¹' {f | AEStronglyMeasurable[m] f μ} := rfl rw [this] refine IsClosed.preimage (condExpL1CLM F' hm μ).continuous ?_ exact isClosed_aestronglyMeasurable hm theorem condExpL1CLM_lpMeas (f : lpMeas F' ℝ m 1 μ) : condExpL1CLM F' hm μ (f : α →₁[μ] F') = ↑f := by let g := lpMeasToLpTrimLie F' ℝ 1 μ hm f have hfg : f = (lpMeasToLpTrimLie F' ℝ 1 μ hm).symm g := by simp only [g, LinearIsometryEquiv.symm_apply_apply] rw [hfg] refine @Lp.induction α F' m _ 1 (μ.trim hm) _ ENNReal.coe_ne_top (fun g : α →₁[μ.trim hm] F' => condExpL1CLM F' hm μ ((lpMeasToLpTrimLie F' ℝ 1 μ hm).symm g : α →₁[μ] F') = ↑((lpMeasToLpTrimLie F' ℝ 1 μ hm).symm g)) ?_ ?_ ?_ g · intro c s hs hμs rw [@Lp.simpleFunc.coe_indicatorConst _ _ m, lpMeasToLpTrimLie_symm_indicator hs hμs.ne c, condExpL1CLM_indicatorConstLp] exact condExpInd_of_measurable hs ((le_trim hm).trans_lt hμs).ne c · intro f g hf hg _ hf_eq hg_eq rw [LinearIsometryEquiv.map_add] push_cast rw [map_add, hf_eq, hg_eq] · refine isClosed_eq ?_ ?_ · refine (condExpL1CLM F' hm μ).continuous.comp (continuous_induced_dom.comp ?_) exact LinearIsometryEquiv.continuous _ · refine continuous_induced_dom.comp ?_ exact LinearIsometryEquiv.continuous _ theorem condExpL1CLM_of_aestronglyMeasurable' (f : α →₁[μ] F') (hfm : AEStronglyMeasurable[m] f μ) : condExpL1CLM F' hm μ f = f := condExpL1CLM_lpMeas (⟨f, hfm⟩ : lpMeas F' ℝ m 1 μ) /-- Conditional expectation of a function, in L1. Its value is 0 if the function is not integrable. The function-valued `condExp` should be used instead in most cases. -/ def condExpL1 (hm : m ≤ m0) (μ : Measure α) [SigmaFinite (μ.trim hm)] (f : α → F') : α →₁[μ] F' := setToFun μ (condExpInd F' hm μ) (dominatedFinMeasAdditive_condExpInd F' hm μ) f theorem condExpL1_undef (hf : ¬Integrable f μ) : condExpL1 hm μ f = 0 := setToFun_undef (dominatedFinMeasAdditive_condExpInd F' hm μ) hf theorem condExpL1_eq (hf : Integrable f μ) : condExpL1 hm μ f = condExpL1CLM F' hm μ (hf.toL1 f) := setToFun_eq (dominatedFinMeasAdditive_condExpInd F' hm μ) hf @[simp] theorem condExpL1_zero : condExpL1 hm μ (0 : α → F') = 0 := setToFun_zero _ @[simp] theorem condExpL1_measure_zero (hm : m ≤ m0) : condExpL1 hm (0 : Measure α) f = 0 := setToFun_measure_zero _ rfl theorem aestronglyMeasurable_condExpL1 {f : α → F'} : AEStronglyMeasurable[m] (condExpL1 hm μ f) μ := by by_cases hf : Integrable f μ · rw [condExpL1_eq hf] exact aestronglyMeasurable_condExpL1CLM _ · rw [condExpL1_undef hf] exact stronglyMeasurable_zero.aestronglyMeasurable.congr (coeFn_zero ..).symm theorem condExpL1_congr_ae (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (h : f =ᵐ[μ] g) : condExpL1 hm μ f = condExpL1 hm μ g := setToFun_congr_ae _ h theorem integrable_condExpL1 (f : α → F') : Integrable (condExpL1 hm μ f) μ := L1.integrable_coeFn _ /-- The integral of the conditional expectation `condExpL1` over an `m`-measurable set is equal to the integral of `f` on that set. See also `setIntegral_condExp`, the similar statement for `condExp`. -/ theorem setIntegral_condExpL1 (hf : Integrable f μ) (hs : MeasurableSet[m] s) : ∫ x in s, condExpL1 hm μ f x ∂μ = ∫ x in s, f x ∂μ := by simp_rw [condExpL1_eq hf] rw [setIntegral_condExpL1CLM (hf.toL1 f) hs] exact setIntegral_congr_ae (hm s hs) (hf.coeFn_toL1.mono fun x hx _ => hx) theorem condExpL1_add (hf : Integrable f μ) (hg : Integrable g μ) : condExpL1 hm μ (f + g) = condExpL1 hm μ f + condExpL1 hm μ g := setToFun_add _ hf hg theorem condExpL1_neg (f : α → F') : condExpL1 hm μ (-f) = -condExpL1 hm μ f := setToFun_neg _ f theorem condExpL1_smul (c : 𝕜) (f : α → F') : condExpL1 hm μ (c • f) = c • condExpL1 hm μ f := by refine setToFun_smul _ ?_ c f exact fun c _ x => condExpInd_smul' c x theorem condExpL1_sub (hf : Integrable f μ) (hg : Integrable g μ) : condExpL1 hm μ (f - g) = condExpL1 hm μ f - condExpL1 hm μ g := setToFun_sub _ hf hg theorem condExpL1_of_aestronglyMeasurable' (hfm : AEStronglyMeasurable[m] f μ) (hfi : Integrable f μ) : condExpL1 hm μ f =ᵐ[μ] f := by rw [condExpL1_eq hfi] refine EventuallyEq.trans ?_ (Integrable.coeFn_toL1 hfi) rw [condExpL1CLM_of_aestronglyMeasurable'] exact hfm.congr hfi.coeFn_toL1.symm theorem condExpL1_mono {E} [NormedAddCommGroup E] [PartialOrder E] [OrderClosedTopology E] [IsOrderedAddMonoid E] [CompleteSpace E] [NormedSpace ℝ E] [IsOrderedModule ℝ E] {f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) (hfg : f ≤ᵐ[μ] g) : condExpL1 hm μ f ≤ᵐ[μ] condExpL1 hm μ g := by rw [coeFn_le] have h_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x : E, 0 ≤ x → 0 ≤ condExpInd E hm μ s x := fun s hs hμs x hx => condExpInd_nonneg hs hμs.ne x hx exact setToFun_mono (dominatedFinMeasAdditive_condExpInd E hm μ) h_nonneg hf hg hfg end CondexpL1 end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConditionalExpectation/Indicator.lean
import Mathlib.MeasureTheory.Function.ConditionalExpectation.Basic /-! # Conditional expectation of indicator functions This file proves some results about the conditional expectation of an indicator function and as a corollary, also proves several results about the behaviour of the conditional expectation on a restricted measure. ## Main result * `MeasureTheory.condExp_indicator`: If `s` is an `m`-measurable set, then the conditional expectation of the indicator function of `s` is almost everywhere equal to the indicator of `s` of the conditional expectation. Namely, `𝔼[s.indicator f | m] = s.indicator 𝔼[f | m]` a.e. -/ noncomputable section open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap open scoped NNReal ENNReal Topology MeasureTheory namespace MeasureTheory variable {α E : Type*} {m m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {μ : Measure α} {f : α → E} {s : Set α} theorem condExp_ae_eq_restrict_zero (hs : MeasurableSet[m] s) (hf : f =ᵐ[μ.restrict s] 0) : μ[f|m] =ᵐ[μ.restrict s] 0 := by by_cases hm : m ≤ m0 swap; · simp_rw [condExp_of_not_le hm]; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm]; rfl haveI : SigmaFinite (μ.trim hm) := hμm have : SigmaFinite ((μ.restrict s).trim hm) := by rw [← restrict_trim hm _ hs] exact Restrict.sigmaFinite _ s by_cases hf_int : Integrable f μ swap; · rw [condExp_of_not_integrable hf_int] refine ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' hm ?_ ?_ ?_ ?_ ?_ · exact fun t _ _ => integrable_condExp.integrableOn.integrableOn · exact fun t _ _ => (integrable_zero _ _ _).integrableOn · intro t ht _ rw [Measure.restrict_restrict (hm _ ht), setIntegral_condExp hm hf_int (ht.inter hs), ← Measure.restrict_restrict (hm _ ht)] refine setIntegral_congr_ae (hm _ ht) ?_ filter_upwards [hf] with x hx _ using hx · exact stronglyMeasurable_condExp.aestronglyMeasurable · exact stronglyMeasurable_zero.aestronglyMeasurable /-- Auxiliary lemma for `condExp_indicator`. -/ theorem condExp_indicator_aux (hs : MeasurableSet[m] s) (hf : f =ᵐ[μ.restrict sᶜ] 0) : μ[s.indicator f|m] =ᵐ[μ] s.indicator (μ[f|m]) := by by_cases hm : m ≤ m0 swap; · simp_rw [condExp_of_not_le hm, Set.indicator_zero']; rfl have hsf_zero : ∀ g : α → E, g =ᵐ[μ.restrict sᶜ] 0 → s.indicator g =ᵐ[μ] g := fun g => indicator_ae_eq_of_restrict_compl_ae_eq_zero (hm _ hs) refine ((hsf_zero (μ[f|m]) (condExp_ae_eq_restrict_zero hs.compl hf)).trans ?_).symm exact condExp_congr_ae (hsf_zero f hf).symm /-- The conditional expectation of the indicator of a function over an `m`-measurable set with respect to the σ-algebra `m` is a.e. equal to the indicator of the conditional expectation. -/ theorem condExp_indicator (hf_int : Integrable f μ) (hs : MeasurableSet[m] s) : μ[s.indicator f|m] =ᵐ[μ] s.indicator (μ[f|m]) := by by_cases hm : m ≤ m0 swap; · simp_rw [condExp_of_not_le hm, Set.indicator_zero']; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm, Set.indicator_zero']; rfl haveI : SigmaFinite (μ.trim hm) := hμm -- use `have` to perform what should be the first calc step because of an error I don't -- understand have : s.indicator (μ[f|m]) =ᵐ[μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m]) := by rw [Set.indicator_self_add_compl s f] refine (this.trans ?_).symm calc s.indicator (μ[s.indicator f + sᶜ.indicator f|m]) =ᵐ[μ] s.indicator (μ[s.indicator f|m] + μ[sᶜ.indicator f|m]) := by filter_upwards [condExp_add (hf_int.indicator (hm _ hs)) (hf_int.indicator (hm _ hs.compl)) m] with x hx classical rw [Set.indicator_apply, Set.indicator_apply, hx] _ = s.indicator (μ[s.indicator f|m]) + s.indicator (μ[sᶜ.indicator f|m]) := (s.indicator_add' _ _) _ =ᵐ[μ] s.indicator (μ[s.indicator f|m]) + s.indicator (sᶜ.indicator (μ[sᶜ.indicator f|m])) := by refine Filter.EventuallyEq.rfl.add ?_ have : sᶜ.indicator (μ[sᶜ.indicator f|m]) =ᵐ[μ] μ[sᶜ.indicator f|m] := by refine (condExp_indicator_aux hs.compl ?_).symm.trans ?_ · exact indicator_ae_eq_restrict_compl (hm _ hs.compl) · rw [Set.indicator_indicator, Set.inter_self] filter_upwards [this] with x hx by_cases hxs : x ∈ s · simp only [hx, hxs, Set.indicator_of_mem] · simp only [hxs, Set.indicator_of_notMem, not_false_iff] _ =ᵐ[μ] s.indicator (μ[s.indicator f|m]) := by rw [Set.indicator_indicator, Set.inter_compl_self, Set.indicator_empty', add_zero] _ =ᵐ[μ] μ[s.indicator f|m] := by refine (condExp_indicator_aux hs ?_).symm.trans ?_ · exact indicator_ae_eq_restrict_compl (hm _ hs) · rw [Set.indicator_indicator, Set.inter_self] theorem condExp_restrict_ae_eq_restrict (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs_m : MeasurableSet[m] s) (hf_int : Integrable f μ) : (μ.restrict s)[f|m] =ᵐ[μ.restrict s] μ[f|m] := by have : SigmaFinite ((μ.restrict s).trim hm) := by rw [← restrict_trim hm _ hs_m]; infer_instance rw [ae_eq_restrict_iff_indicator_ae_eq (hm _ hs_m)] refine EventuallyEq.trans ?_ (condExp_indicator hf_int hs_m) refine ae_eq_condExp_of_forall_setIntegral_eq hm (hf_int.indicator (hm _ hs_m)) ?_ ?_ ?_ · intro t ht _ rw [← integrable_indicator_iff (hm _ ht), Set.indicator_indicator, Set.inter_comm, ← Set.indicator_indicator] suffices h_int_restrict : Integrable (t.indicator ((μ.restrict s)[f|m])) (μ.restrict s) by rw [integrable_indicator_iff (hm _ hs_m), IntegrableOn] exact h_int_restrict exact integrable_condExp.indicator (hm _ ht) · intro t ht _ calc ∫ x in t, s.indicator ((μ.restrict s)[f|m]) x ∂μ = ∫ x in t, ((μ.restrict s)[f|m]) x ∂μ.restrict s := by rw [integral_indicator (hm _ hs_m), Measure.restrict_restrict (hm _ hs_m), Measure.restrict_restrict (hm _ ht), Set.inter_comm] _ = ∫ x in t, f x ∂μ.restrict s := setIntegral_condExp hm hf_int.integrableOn ht _ = ∫ x in t, s.indicator f x ∂μ := by rw [integral_indicator (hm _ hs_m), Measure.restrict_restrict (hm _ hs_m), Measure.restrict_restrict (hm _ ht), Set.inter_comm] · exact (stronglyMeasurable_condExp.indicator hs_m).aestronglyMeasurable /-- If the restriction to an `m`-measurable set `s` of a σ-algebra `m` is equal to the restriction to `s` of another σ-algebra `m₂` (hypothesis `hs`), then `μ[f | m] =ᵐ[μ.restrict s] μ[f | m₂]`. -/ theorem condExp_ae_eq_restrict_of_measurableSpace_eq_on {m m₂ m0 : MeasurableSpace α} {μ : Measure α} (hm : m ≤ m0) (hm₂ : m₂ ≤ m0) [SigmaFinite (μ.trim hm)] [SigmaFinite (μ.trim hm₂)] (hs_m : MeasurableSet[m] s) (hs : ∀ t, MeasurableSet[m] (s ∩ t) ↔ MeasurableSet[m₂] (s ∩ t)) : μ[f|m] =ᵐ[μ.restrict s] μ[f|m₂] := by rw [ae_eq_restrict_iff_indicator_ae_eq (hm _ hs_m)] have hs_m₂ : MeasurableSet[m₂] s := by rwa [← Set.inter_univ s, ← hs Set.univ, Set.inter_univ] by_cases hf_int : Integrable f μ swap; · simp_rw [condExp_of_not_integrable hf_int]; rfl refine ((condExp_indicator hf_int hs_m).symm.trans ?_).trans (condExp_indicator hf_int hs_m₂) refine ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' hm₂ (fun s _ _ => integrable_condExp.integrableOn) (fun s _ _ => integrable_condExp.integrableOn) ?_ ?_ stronglyMeasurable_condExp.aestronglyMeasurable swap · have : StronglyMeasurable[m] (μ[s.indicator f|m]) := stronglyMeasurable_condExp refine this.aestronglyMeasurable.of_measurableSpace_le_on hm hs_m (fun t => (hs t).mp) ?_ exact condExp_ae_eq_restrict_zero hs_m.compl (indicator_ae_eq_restrict_compl (hm _ hs_m)) intro t ht _ have : ∫ x in t, (μ[s.indicator f|m]) x ∂μ = ∫ x in s ∩ t, (μ[s.indicator f|m]) x ∂μ := by rw [← integral_add_compl (hm _ hs_m) integrable_condExp.integrableOn] suffices ∫ x in sᶜ, (μ[s.indicator f|m]) x ∂μ.restrict t = 0 by rw [this, add_zero, Measure.restrict_restrict (hm _ hs_m)] rw [Measure.restrict_restrict (MeasurableSet.compl (hm _ hs_m))] suffices μ[s.indicator f|m] =ᵐ[μ.restrict sᶜ] 0 by rw [Set.inter_comm, ← Measure.restrict_restrict (hm₂ _ ht)] calc ∫ x : α in t, (μ[s.indicator f|m]) x ∂μ.restrict sᶜ = ∫ x : α in t, 0 ∂μ.restrict sᶜ := by refine setIntegral_congr_ae (hm₂ _ ht) ?_ filter_upwards [this] with x hx _ using hx _ = 0 := integral_zero _ _ refine condExp_ae_eq_restrict_zero hs_m.compl ?_ exact indicator_ae_eq_restrict_compl (hm _ hs_m) have hst_m : MeasurableSet[m] (s ∩ t) := (hs _).mpr (hs_m₂.inter ht) simp_rw [this, setIntegral_condExp hm₂ (hf_int.indicator (hm _ hs_m)) ht, setIntegral_condExp hm (hf_int.indicator (hm _ hs_m)) hst_m, integral_indicator (hm _ hs_m), Measure.restrict_restrict (hm _ hs_m), ← Set.inter_assoc, Set.inter_self] end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean
import Mathlib.MeasureTheory.Function.ConditionalExpectation.CondexpL1 /-! # Conditional expectation We build the conditional expectation of an integrable function `f` with value in a Banach space with respect to a measure `μ` (defined on a measurable space structure `m₀`) and a measurable space structure `m` with `hm : m ≤ m₀` (a sub-sigma-algebra). This is an `m`-strongly measurable function `μ[f|hm]` which is integrable and verifies `∫ x in s, μ[f|hm] x ∂μ = ∫ x in s, f x ∂μ` for all `m`-measurable sets `s`. It is unique as an element of `L¹`. The construction is done in four steps: * Define the conditional expectation of an `L²` function, as an element of `L²`. This is the orthogonal projection on the subspace of almost everywhere `m`-measurable functions. * Show that the conditional expectation of the indicator of a measurable set with finite measure is integrable and define a map `Set α → (E →L[ℝ] (α →₁[μ] E))` which to a set associates a linear map. That linear map sends `x ∈ E` to the conditional expectation of the indicator of the set with value `x`. * Extend that map to `condExpL1CLM : (α →₁[μ] E) →L[ℝ] (α →₁[μ] E)`. This is done using the same construction as the Bochner integral (see the file `MeasureTheory/Integral/SetToL1`). * Define the conditional expectation of a function `f : α → E`, which is an integrable function `α → E` equal to 0 if `f` is not integrable, and equal to an `m`-measurable representative of `condExpL1CLM` applied to `[f]`, the equivalence class of `f` in `L¹`. The first step is done in `MeasureTheory.Function.ConditionalExpectation.CondexpL2`, the two next steps in `MeasureTheory.Function.ConditionalExpectation.CondexpL1` and the final step is performed in this file. ## Main results The conditional expectation and its properties * `condExp (m : MeasurableSpace α) (μ : Measure α) (f : α → E)`: conditional expectation of `f` with respect to `m`. * `integrable_condExp` : `condExp` is integrable. * `stronglyMeasurable_condExp` : `condExp` is `m`-strongly-measurable. * `setIntegral_condExp (hf : Integrable f μ) (hs : MeasurableSet[m] s)` : if `m ≤ m₀` (the σ-algebra over which the measure is defined), then the conditional expectation verifies `∫ x in s, condExp m μ f x ∂μ = ∫ x in s, f x ∂μ` for any `m`-measurable set `s`. While `condExp` is function-valued, we also define `condExpL1` with value in `L1` and a continuous linear map `condExpL1CLM` from `L1` to `L1`. `condExp` should be used in most cases. Uniqueness of the conditional expectation * `ae_eq_condExp_of_forall_setIntegral_eq`: an a.e. `m`-measurable function which verifies the equality of integrals is a.e. equal to `condExp`. ## Notation For a measure `μ` defined on a measurable space structure `m₀`, another measurable space structure `m` with `hm : m ≤ m₀` (a sub-σ-algebra) and a function `f`, we define the notation * `μ[f|m] = condExp m μ f`. ## TODO See https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/Conditional.20expectation.20of.20product for how to prove that we can pull `m`-measurable continuous linear maps out of the `m`-conditional expectation. This would generalise `MeasureTheory.condExp_mul_of_stronglyMeasurable_left`. ## Tags conditional expectation, conditional expected value -/ open TopologicalSpace MeasureTheory.Lp Filter open scoped ENNReal Topology MeasureTheory namespace MeasureTheory -- 𝕜 for ℝ or ℂ -- E for integrals on a Lp submodule variable {α β E 𝕜 : Type*} [RCLike 𝕜] {m m₀ : MeasurableSpace α} {μ : Measure α} {f g : α → E} {s : Set α} section NormedAddCommGroup variable [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] open scoped Classical in variable (m) in /-- Conditional expectation of a function, with notation `μ[f|m]`. It is defined as 0 if any one of the following conditions is true: - `m` is not a sub-σ-algebra of `m₀`, - `μ` is not σ-finite with respect to `m`, - `f` is not integrable. -/ noncomputable irreducible_def condExp (μ : Measure[m₀] α) (f : α → E) : α → E := if hm : m ≤ m₀ then if h : SigmaFinite (μ.trim hm) ∧ Integrable f μ then if StronglyMeasurable[m] f then f else have := h.1; aestronglyMeasurable_condExpL1.mk (condExpL1 hm μ f) else 0 else 0 @[inherit_doc MeasureTheory.condExp] scoped macro:max μ:term noWs "[" f:term "|" m:term "]" : term => `(MeasureTheory.condExp $m $μ $f) /-- Unexpander for `μ[f|m]` notation. -/ @[app_unexpander MeasureTheory.condExp] def condExpUnexpander : Lean.PrettyPrinter.Unexpander | `($_ $m $μ $f) => `($μ[$f|$m]) | _ => throw () /-- info: μ[f|m] : α → E -/ #guard_msgs in #check μ[f|m] /-- info: μ[f|m] sorry : E -/ #guard_msgs in #check μ[f|m] (sorry : α) theorem condExp_of_not_le (hm_not : ¬m ≤ m₀) : μ[f|m] = 0 := by rw [condExp, dif_neg hm_not] theorem condExp_of_not_sigmaFinite (hm : m ≤ m₀) (hμm_not : ¬SigmaFinite (μ.trim hm)) : μ[f|m] = 0 := by rw [condExp, dif_pos hm, dif_neg]; push_neg; exact fun h => absurd h hμm_not open scoped Classical in theorem condExp_of_sigmaFinite (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim hm)] : μ[f|m] = if Integrable f μ then if StronglyMeasurable[m] f then f else aestronglyMeasurable_condExpL1.mk (condExpL1 hm μ f) else 0 := by rw [condExp, dif_pos hm] grind theorem condExp_of_stronglyMeasurable (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim hm)] {f : α → E} (hf : StronglyMeasurable[m] f) (hfi : Integrable f μ) : μ[f|m] = f := by rw [condExp_of_sigmaFinite hm, if_pos hfi, if_pos hf] @[simp] theorem condExp_const (hm : m ≤ m₀) (c : E) [IsFiniteMeasure μ] : μ[fun _ : α ↦ c|m] = fun _ ↦ c := condExp_of_stronglyMeasurable hm stronglyMeasurable_const (integrable_const c) theorem condExp_ae_eq_condExpL1 (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim hm)] (f : α → E) : μ[f|m] =ᵐ[μ] condExpL1 hm μ f := by rw [condExp_of_sigmaFinite hm] by_cases hfi : Integrable f μ · rw [if_pos hfi] by_cases hfm : StronglyMeasurable[m] f · rw [if_pos hfm] exact (condExpL1_of_aestronglyMeasurable' hfm.aestronglyMeasurable hfi).symm · rw [if_neg hfm] exact aestronglyMeasurable_condExpL1.ae_eq_mk.symm rw [if_neg hfi, condExpL1_undef hfi] exact (coeFn_zero _ _ _).symm theorem condExp_ae_eq_condExpL1CLM (hm : m ≤ m₀) [SigmaFinite (μ.trim hm)] (hf : Integrable f μ) : μ[f|m] =ᵐ[μ] condExpL1CLM E hm μ (hf.toL1 f) := by refine (condExp_ae_eq_condExpL1 hm f).trans (Eventually.of_forall fun x => ?_) rw [condExpL1_eq hf] theorem condExp_of_not_integrable (hf : ¬Integrable f μ) : μ[f|m] = 0 := by by_cases hm : m ≤ m₀ swap; · rw [condExp_of_not_le hm] by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condExp_of_not_sigmaFinite hm hμm] rw [condExp_of_sigmaFinite, if_neg hf] @[simp] theorem condExp_zero : μ[(0 : α → E)|m] = 0 := by by_cases hm : m ≤ m₀ swap; · rw [condExp_of_not_le hm] by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condExp_of_not_sigmaFinite hm hμm] exact condExp_of_stronglyMeasurable hm stronglyMeasurable_zero (integrable_zero _ _ _) theorem stronglyMeasurable_condExp : StronglyMeasurable[m] (μ[f|m]) := by by_cases hm : m ≤ m₀ swap; · rw [condExp_of_not_le hm]; exact stronglyMeasurable_zero by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condExp_of_not_sigmaFinite hm hμm]; exact stronglyMeasurable_zero rw [condExp_of_sigmaFinite hm] split_ifs with hfi hfm · exact hfm · exact aestronglyMeasurable_condExpL1.stronglyMeasurable_mk · exact stronglyMeasurable_zero @[gcongr] theorem condExp_congr_ae (h : f =ᵐ[μ] g) : μ[f|m] =ᵐ[μ] μ[g|m] := by by_cases hm : m ≤ m₀ swap; · simp_rw [condExp_of_not_le hm]; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm]; rfl exact (condExp_ae_eq_condExpL1 hm f).trans (Filter.EventuallyEq.trans (by rw [condExpL1_congr_ae hm h]) (condExp_ae_eq_condExpL1 hm g).symm) lemma condExp_congr_ae_trim (hm : m ≤ m₀) (hfg : f =ᵐ[μ] g) : μ[f|m] =ᵐ[μ.trim hm] μ[g|m] := StronglyMeasurable.ae_eq_trim_of_stronglyMeasurable hm stronglyMeasurable_condExp stronglyMeasurable_condExp (condExp_congr_ae hfg) theorem condExp_of_aestronglyMeasurable' (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim hm)] {f : α → E} (hf : AEStronglyMeasurable[m] f μ) (hfi : Integrable f μ) : μ[f|m] =ᵐ[μ] f := by refine ((condExp_congr_ae hf.ae_eq_mk).trans ?_).trans hf.ae_eq_mk.symm rw [condExp_of_stronglyMeasurable hm hf.stronglyMeasurable_mk ((integrable_congr hf.ae_eq_mk).mp hfi)] @[fun_prop] theorem integrable_condExp : Integrable (μ[f|m]) μ := by by_cases hm : m ≤ m₀ swap; · rw [condExp_of_not_le hm]; exact integrable_zero _ _ _ by_cases hμm : SigmaFinite (μ.trim hm) swap; · rw [condExp_of_not_sigmaFinite hm hμm]; exact integrable_zero _ _ _ exact (integrable_condExpL1 f).congr (condExp_ae_eq_condExpL1 hm f).symm /-- The integral of the conditional expectation `μ[f|hm]` over an `m`-measurable set is equal to the integral of `f` on that set. -/ theorem setIntegral_condExp (hm : m ≤ m₀) [SigmaFinite (μ.trim hm)] (hf : Integrable f μ) (hs : MeasurableSet[m] s) : ∫ x in s, (μ[f|m]) x ∂μ = ∫ x in s, f x ∂μ := by rw [setIntegral_congr_ae (hm s hs) ((condExp_ae_eq_condExpL1 hm f).mono fun x hx _ => hx)] exact setIntegral_condExpL1 hf hs theorem integral_condExp (hm : m ≤ m₀) [hμm : SigmaFinite (μ.trim hm)] : ∫ x, (μ[f|m]) x ∂μ = ∫ x, f x ∂μ := by by_cases hf : Integrable f μ · suffices ∫ x in Set.univ, (μ[f|m]) x ∂μ = ∫ x in Set.univ, f x ∂μ by simp_rw [setIntegral_univ] at this; exact this exact setIntegral_condExp hm hf .univ simp only [condExp_of_not_integrable hf, Pi.zero_apply, integral_zero, integral_undef hf] /-- **Law of total probability** using `condExp` as conditional probability. -/ theorem integral_condExp_indicator [mβ : MeasurableSpace β] {Y : α → β} (hY : Measurable Y) [SigmaFinite (μ.trim hY.comap_le)] {A : Set α} (hA : MeasurableSet A) : ∫ x, (μ[(A.indicator fun _ ↦ (1 : ℝ))|mβ.comap Y]) x ∂μ = μ.real A := by rw [integral_condExp, integral_indicator hA, setIntegral_const, smul_eq_mul, mul_one] /-- **Uniqueness of the conditional expectation** If a function is a.e. `m`-measurable, verifies an integrability condition and has same integral as `f` on all `m`-measurable sets, then it is a.e. equal to `μ[f|hm]`. -/ theorem ae_eq_condExp_of_forall_setIntegral_eq (hm : m ≤ m₀) [SigmaFinite (μ.trim hm)] {f g : α → E} (hf : Integrable f μ) (hg_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn g s μ) (hg_eq : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → ∫ x in s, g x ∂μ = ∫ x in s, f x ∂μ) (hgm : AEStronglyMeasurable[m] g μ) : g =ᵐ[μ] μ[f|m] := by refine ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' hm hg_int_finite (fun s _ _ => integrable_condExp.integrableOn) (fun s hs hμs => ?_) hgm (StronglyMeasurable.aestronglyMeasurable stronglyMeasurable_condExp) rw [hg_eq s hs hμs, setIntegral_condExp hm hf hs] theorem condExp_bot' [hμ : NeZero μ] (f : α → E) : μ[f|⊥] = fun _ => (μ.real Set.univ)⁻¹ • ∫ x, f x ∂μ := by by_cases hμ_finite : IsFiniteMeasure μ swap · have h : ¬SigmaFinite (μ.trim bot_le) := by rwa [sigmaFinite_trim_bot_iff] rw [not_isFiniteMeasure_iff] at hμ_finite rw [condExp_of_not_sigmaFinite bot_le h] simp only [hμ_finite, ENNReal.toReal_top, inv_zero, zero_smul, measureReal_def] rfl have h_meas : StronglyMeasurable[⊥] (μ[f|⊥]) := stronglyMeasurable_condExp obtain ⟨c, h_eq⟩ := stronglyMeasurable_bot_iff.mp h_meas rw [h_eq] have h_integral : ∫ x, (μ[f|⊥]) x ∂μ = ∫ x, f x ∂μ := integral_condExp bot_le simp_rw [h_eq, integral_const] at h_integral rw [← h_integral, ← smul_assoc, smul_eq_mul, inv_mul_cancel₀, one_smul] rw [Ne, measureReal_def, ENNReal.toReal_eq_zero_iff, not_or] exact ⟨NeZero.ne _, measure_ne_top μ Set.univ⟩ theorem condExp_bot_ae_eq (f : α → E) : μ[f|⊥] =ᵐ[μ] fun _ => (μ.real Set.univ)⁻¹ • ∫ x, f x ∂μ := by rcases eq_zero_or_neZero μ with rfl | hμ · rw [ae_zero]; exact eventually_bot · exact Eventually.of_forall <| congr_fun (condExp_bot' f) theorem condExp_bot [IsProbabilityMeasure μ] (f : α → E) : μ[f|⊥] = fun _ => ∫ x, f x ∂μ := by refine (condExp_bot' f).trans ?_ rw [measureReal_univ_eq_one, inv_one, one_smul] theorem condExp_add (hf : Integrable f μ) (hg : Integrable g μ) (m : MeasurableSpace α) : μ[f + g|m] =ᵐ[μ] μ[f|m] + μ[g|m] := by by_cases hm : m ≤ m₀ swap; · simp_rw [condExp_of_not_le hm]; simp by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm]; simp refine (condExp_ae_eq_condExpL1 hm _).trans ?_ rw [condExpL1_add hf hg] exact (coeFn_add _ _).trans ((condExp_ae_eq_condExpL1 hm _).symm.add (condExp_ae_eq_condExpL1 hm _).symm) theorem condExp_finset_sum {ι : Type*} {s : Finset ι} {f : ι → α → E} (hf : ∀ i ∈ s, Integrable (f i) μ) (m : MeasurableSpace α) : μ[∑ i ∈ s, f i|m] =ᵐ[μ] ∑ i ∈ s, μ[f i|m] := by classical induction s using Finset.induction_on with | empty => rw [Finset.sum_empty, Finset.sum_empty, condExp_zero] | insert i s his heq => rw [Finset.sum_insert his, Finset.sum_insert his] exact (condExp_add (hf i <| Finset.mem_insert_self i s) (integrable_finset_sum' _ <| Finset.forall_of_forall_insert hf) _).trans ((EventuallyEq.refl _ _).add <| heq <| Finset.forall_of_forall_insert hf) theorem condExp_smul [NormedSpace 𝕜 E] (c : 𝕜) (f : α → E) (m : MeasurableSpace α) : μ[c • f|m] =ᵐ[μ] c • μ[f|m] := by by_cases hm : m ≤ m₀ swap; · simp_rw [condExp_of_not_le hm]; simp by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm]; simp refine (condExp_ae_eq_condExpL1 hm _).trans ?_ rw [condExpL1_smul c f] refine (condExp_ae_eq_condExpL1 hm f).mp ?_ refine (coeFn_smul c (condExpL1 hm μ f)).mono fun x hx1 hx2 => ?_ simp only [hx1, hx2, Pi.smul_apply] theorem condExp_neg (f : α → E) (m : MeasurableSpace α) : μ[-f|m] =ᵐ[μ] -μ[f|m] := by calc μ[-f|m] = μ[(-1 : ℝ) • f|m] := by rw [neg_one_smul ℝ f] _ =ᵐ[μ] (-1 : ℝ) • μ[f|m] := condExp_smul .. _ = -μ[f|m] := neg_one_smul ℝ (μ[f|m]) theorem condExp_sub (hf : Integrable f μ) (hg : Integrable g μ) (m : MeasurableSpace α) : μ[f - g|m] =ᵐ[μ] μ[f|m] - μ[g|m] := by simp_rw [sub_eq_add_neg] exact (condExp_add hf hg.neg _).trans (EventuallyEq.rfl.add (condExp_neg ..)) /-- **Tower property of the conditional expectation**. Taking the `m₂`-conditional expectation then the `m₁`-conditional expectation, where `m₁` is a smaller σ-algebra, is the same as taking the `m₁`-conditional expectation directly. -/ theorem condExp_condExp_of_le {m₁ m₂ m₀ : MeasurableSpace α} {μ : Measure α} (hm₁₂ : m₁ ≤ m₂) (hm₂ : m₂ ≤ m₀) [SigmaFinite (μ.trim hm₂)] : μ[μ[f|m₂]|m₁] =ᵐ[μ] μ[f|m₁] := by by_cases hμm₁ : SigmaFinite (μ.trim (hm₁₂.trans hm₂)) swap; · simp_rw [condExp_of_not_sigmaFinite (hm₁₂.trans hm₂) hμm₁]; rfl by_cases hf : Integrable f μ swap; · simp_rw [condExp_of_not_integrable hf, condExp_zero]; rfl refine ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' (hm₁₂.trans hm₂) (fun s _ _ => integrable_condExp.integrableOn) (fun s _ _ => integrable_condExp.integrableOn) ?_ stronglyMeasurable_condExp.aestronglyMeasurable stronglyMeasurable_condExp.aestronglyMeasurable intro s hs _ rw [setIntegral_condExp (hm₁₂.trans hm₂) integrable_condExp hs] rw [setIntegral_condExp (hm₁₂.trans hm₂) hf hs, setIntegral_condExp hm₂ hf (hm₁₂ s hs)] /-- Conditional expectation commutes with continuous linear maps. -/ theorem _root_.ContinuousLinearMap.comp_condExp_comm {F : Type*} [NormedAddCommGroup F] [CompleteSpace F] [NormedSpace ℝ F] (hf_int : Integrable f μ) (T : E →L[ℝ] F) : T ∘ μ[f|m] =ᵐ[μ] μ[T ∘ f|m] := by by_cases hm : m ≤ m₀ · by_cases hμ : SigmaFinite (μ.trim hm) · refine ae_eq_condExp_of_forall_setIntegral_eq hm ?_ (fun s ms hs => ?_) (fun s ms hs => ?_) ?_ · exact T.integrable_comp hf_int · exact (T.integrable_comp integrable_condExp).integrableOn · calc ∫ x in s, (T ∘ μ[f|m]) x ∂μ = T (∫ x in s, μ[f|m] x ∂μ) := T.integral_comp_comm integrable_condExp.restrict _ = T (∫ x in s, f x ∂μ) := congrArg T (setIntegral_condExp hm hf_int ms) _ = ∫ x in s, (T ∘ f) x ∂μ := (T.integral_comp_comm hf_int.restrict).symm · exact T.cont.comp_aestronglyMeasurable stronglyMeasurable_condExp.aestronglyMeasurable · simp [condExp_of_not_sigmaFinite hm hμ] · simp [condExp_of_not_le hm] /-- Conditional expectation commutes with affine functions. Note that `IsFiniteMeasure μ` is a necessary assumption because we want constant functions to be integrable. -/ theorem _root_.ContinuousLinearMap.comp_condExp_add_const_comm {F : Type*} [NormedAddCommGroup F] [CompleteSpace F] [NormedSpace ℝ F] [IsFiniteMeasure μ] (hm : m ≤ m₀) (hf_int : Integrable f μ) (T : E →L[ℝ] F) (a : F) : (fun x ↦ T (μ[f|m] x) + a) =ᵐ[μ] μ[fun y ↦ T (f y) + a|m] := by have hp : (fun x ↦ T (μ[f|m] x) + a) =ᵐ[μ] μ[T ∘ f|m] + μ[(fun y ↦ a)|m] := by filter_upwards [T.comp_condExp_comm hf_int] with b hb simpa [condExp_const hm a] exact hp.trans (condExp_add (T.integrable_comp hf_int) (integrable_const a) m).symm section RCLike variable [InnerProductSpace 𝕜 E] lemma MemLp.condExpL2_ae_eq_condExp' (hm : m ≤ m₀) (hf1 : Integrable f μ) (hf2 : MemLp f 2 μ) [SigmaFinite (μ.trim hm)] : condExpL2 E 𝕜 hm hf2.toLp =ᵐ[μ] μ[f|m] := by refine ae_eq_condExp_of_forall_setIntegral_eq hm hf1 (fun s hs htop ↦ integrableOn_condExpL2_of_measure_ne_top hm htop.ne _) (fun s hs htop ↦ ?_) (aestronglyMeasurable_condExpL2 hm _) rw [integral_condExpL2_eq hm (hf2.toLp _) hs htop.ne] refine setIntegral_congr_ae (hm _ hs) ?_ filter_upwards [hf2.coeFn_toLp] with ω hω _ using hω lemma MemLp.condExpL2_ae_eq_condExp (hm : m ≤ m₀) (hf : MemLp f 2 μ) [IsFiniteMeasure μ] : condExpL2 E 𝕜 hm hf.toLp =ᵐ[μ] μ[f|m] := hf.condExpL2_ae_eq_condExp' hm (memLp_one_iff_integrable.1 <| hf.mono_exponent one_le_two) end RCLike section Real variable [InnerProductSpace ℝ E] -- TODO: Generalize via the conditional Jensen inequality lemma eLpNorm_condExp_le : eLpNorm (μ[f|m]) 2 μ ≤ eLpNorm f 2 μ := by by_cases hm : m ≤ m₀; swap · simp [condExp_of_not_le hm] by_cases hfμ : SigmaFinite (μ.trim hm); swap · rw [condExp_of_not_sigmaFinite hm hfμ] simp by_cases hfi : Integrable f μ; swap · rw [condExp_of_not_integrable hfi] simp obtain hf | hf := eq_or_ne (eLpNorm f 2 μ) ∞ · simp [hf] replace hf : MemLp f 2 μ := ⟨hfi.1, Ne.lt_top' fun a ↦ hf a.symm⟩ rw [← eLpNorm_congr_ae (hf.condExpL2_ae_eq_condExp' (𝕜 := ℝ) hm hfi)] refine le_trans (eLpNorm_condExpL2_le hm _) ?_ rw [eLpNorm_congr_ae hf.coeFn_toLp] protected lemma MemLp.condExp (hf : MemLp f 2 μ) : MemLp (μ[f|m]) 2 μ := by by_cases hm : m ≤ m₀ · exact ⟨(stronglyMeasurable_condExp.mono hm).aestronglyMeasurable, eLpNorm_condExp_le.trans_lt hf.eLpNorm_lt_top⟩ · simp [condExp_of_not_le hm] end Real end NormedAddCommGroup section NormedRing variable {R : Type*} [NormedRing R] [NormedSpace ℝ R] [CompleteSpace R] @[simp] lemma condExp_ofNat (n : ℕ) [n.AtLeastTwo] (f : α → R) : μ[ofNat(n) * f|m] =ᵐ[μ] ofNat(n) * μ[f|m] := by simpa [Nat.cast_smul_eq_nsmul] using condExp_smul (μ := μ) (m := m) (n : ℝ) f end NormedRing section NormedLatticeAddCommGroup variable [NormedAddCommGroup E] [CompleteSpace E] [NormedSpace ℝ E] /-- **Lebesgue dominated convergence theorem**: sufficient conditions under which almost everywhere convergence of a sequence of functions implies the convergence of their image by `condExpL1`. -/ theorem tendsto_condExpL1_of_dominated_convergence (hm : m ≤ m₀) [SigmaFinite (μ.trim hm)] {fs : ℕ → α → E} {f : α → E} (bound_fs : α → ℝ) (hfs_meas : ∀ n, AEStronglyMeasurable (fs n) μ) (h_int_bound_fs : Integrable bound_fs μ) (hfs_bound : ∀ n, ∀ᵐ x ∂μ, ‖fs n x‖ ≤ bound_fs x) (hfs : ∀ᵐ x ∂μ, Tendsto (fun n => fs n x) atTop (𝓝 (f x))) : Tendsto (fun n => condExpL1 hm μ (fs n)) atTop (𝓝 (condExpL1 hm μ f)) := tendsto_setToFun_of_dominated_convergence _ bound_fs hfs_meas h_int_bound_fs hfs_bound hfs /-- If two sequences of functions have a.e. equal conditional expectations at each step, converge and verify dominated convergence hypotheses, then the conditional expectations of their limits are a.e. equal. -/ theorem tendsto_condExp_unique (fs gs : ℕ → α → E) (f g : α → E) (hfs_int : ∀ n, Integrable (fs n) μ) (hgs_int : ∀ n, Integrable (gs n) μ) (hfs : ∀ᵐ x ∂μ, Tendsto (fun n => fs n x) atTop (𝓝 (f x))) (hgs : ∀ᵐ x ∂μ, Tendsto (fun n => gs n x) atTop (𝓝 (g x))) (bound_fs : α → ℝ) (h_int_bound_fs : Integrable bound_fs μ) (bound_gs : α → ℝ) (h_int_bound_gs : Integrable bound_gs μ) (hfs_bound : ∀ n, ∀ᵐ x ∂μ, ‖fs n x‖ ≤ bound_fs x) (hgs_bound : ∀ n, ∀ᵐ x ∂μ, ‖gs n x‖ ≤ bound_gs x) (hfg : ∀ n, μ[fs n|m] =ᵐ[μ] μ[gs n|m]) : μ[f|m] =ᵐ[μ] μ[g|m] := by by_cases hm : m ≤ m₀; swap; · simp_rw [condExp_of_not_le hm]; rfl by_cases hμm : SigmaFinite (μ.trim hm); swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm]; rfl refine (condExp_ae_eq_condExpL1 hm f).trans ((condExp_ae_eq_condExpL1 hm g).trans ?_).symm rw [← Lp.ext_iff] have hn_eq : ∀ n, condExpL1 hm μ (gs n) = condExpL1 hm μ (fs n) := by intro n ext1 refine (condExp_ae_eq_condExpL1 hm (gs n)).symm.trans ((hfg n).symm.trans ?_) exact condExp_ae_eq_condExpL1 hm (fs n) have hcond_fs : Tendsto (fun n => condExpL1 hm μ (fs n)) atTop (𝓝 (condExpL1 hm μ f)) := tendsto_condExpL1_of_dominated_convergence hm _ (fun n => (hfs_int n).1) h_int_bound_fs hfs_bound hfs have hcond_gs : Tendsto (fun n => condExpL1 hm μ (gs n)) atTop (𝓝 (condExpL1 hm μ g)) := tendsto_condExpL1_of_dominated_convergence hm _ (fun n => (hgs_int n).1) h_int_bound_gs hgs_bound hgs exact tendsto_nhds_unique_of_eventuallyEq hcond_gs hcond_fs (Eventually.of_forall hn_eq) variable [PartialOrder E] [OrderClosedTopology E] [IsOrderedAddMonoid E] [IsOrderedModule ℝ E] lemma condExp_mono (hf : Integrable f μ) (hg : Integrable g μ) (hfg : f ≤ᵐ[μ] g) : μ[f|m] ≤ᵐ[μ] μ[g|m] := by by_cases hm : m ≤ m₀ swap; · simp_rw [condExp_of_not_le hm]; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm]; rfl exact (condExp_ae_eq_condExpL1 hm _).trans_le ((condExpL1_mono hf hg hfg).trans_eq (condExp_ae_eq_condExpL1 hm _).symm) lemma condExp_nonneg (hf : 0 ≤ᵐ[μ] f) : 0 ≤ᵐ[μ] μ[f|m] := by by_cases hfint : Integrable f μ · rw [(condExp_zero.symm : (0 : α → E) = μ[0|m])] exact condExp_mono (integrable_zero _ _ _) hfint hf · rw [condExp_of_not_integrable hfint] lemma condExp_nonpos (hf : f ≤ᵐ[μ] 0) : μ[f|m] ≤ᵐ[μ] 0 := by by_cases hfint : Integrable f μ · rw [(condExp_zero.symm : (0 : α → E) = μ[0|m])] exact condExp_mono hfint (integrable_zero _ _ _) hf · rw [condExp_of_not_integrable hfint] end NormedLatticeAddCommGroup end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConditionalExpectation/Unique.lean
import Mathlib.MeasureTheory.Function.AEEqOfIntegral import Mathlib.MeasureTheory.Function.ConditionalExpectation.AEMeasurable /-! # Uniqueness of the conditional expectation Two Lp functions `f, g` which are almost everywhere strongly measurable with respect to a σ-algebra `m` and verify `∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ` for all `m`-measurable sets `s` are equal almost everywhere. This proves the uniqueness of the conditional expectation, which is not yet defined in this file but is introduced in `Mathlib/MeasureTheory/Function/ConditionalExpectation/Basic.lean`. ## Main statements * `Lp.ae_eq_of_forall_setIntegral_eq'`: two `Lp` functions verifying the equality of integrals defining the conditional expectation are equal. * `ae_eq_of_forall_setIntegral_eq_of_sigma_finite'`: two functions verifying the equality of integrals defining the conditional expectation are equal almost everywhere. Requires `[SigmaFinite (μ.trim hm)]`. -/ open scoped ENNReal MeasureTheory namespace MeasureTheory variable {α E' F' 𝕜 : Type*} {p : ℝ≥0∞} {m m0 : MeasurableSpace α} {μ : Measure α} [RCLike 𝕜] -- 𝕜 for ℝ or ℂ -- E' for an inner product space on which we compute integrals [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E'] [CompleteSpace E'] [NormedSpace ℝ E'] -- F' for integrals on a Lp submodule [NormedAddCommGroup F'] [NormedSpace ℝ F'] [CompleteSpace F'] section UniquenessOfConditionalExpectation /-! ## Uniqueness of the conditional expectation -/ theorem lpMeas.ae_eq_zero_of_forall_setIntegral_eq_zero (hm : m ≤ m0) (f : lpMeas E' 𝕜 m p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn (f : Lp E' p μ) s μ) (hf_zero : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → ∫ x in s, (f : Lp E' p μ) x ∂μ = 0) : f =ᵐ[μ] (0 : α → E') := by obtain ⟨g, hg_sm, hfg⟩ := lpMeas.ae_fin_strongly_measurable' hm f hp_ne_zero hp_ne_top refine hfg.trans ?_ refine ae_eq_zero_of_forall_setIntegral_eq_of_finStronglyMeasurable_trim hm ?_ ?_ hg_sm · intro s hs hμs have hfg_restrict : f =ᵐ[μ.restrict s] g := ae_restrict_of_ae hfg rw [IntegrableOn, integrable_congr hfg_restrict.symm] exact hf_int_finite s hs hμs · intro s hs hμs have hfg_restrict : f =ᵐ[μ.restrict s] g := ae_restrict_of_ae hfg rw [integral_congr_ae hfg_restrict.symm] exact hf_zero s hs hμs variable (𝕜) include 𝕜 in theorem Lp.ae_eq_zero_of_forall_setIntegral_eq_zero' (hm : m ≤ m0) (f : Lp E' p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn f s μ) (hf_zero : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → ∫ x in s, f x ∂μ = 0) (hf_meas : AEStronglyMeasurable[m] f μ) : f =ᵐ[μ] 0 := by let f_meas : lpMeas E' 𝕜 m p μ := ⟨f, hf_meas⟩ have hf_f_meas : f =ᵐ[μ] f_meas := by simp [f_meas] refine hf_f_meas.trans ?_ exact lpMeas.ae_eq_zero_of_forall_setIntegral_eq_zero hm f_meas hp_ne_zero hp_ne_top hf_int_finite hf_zero include 𝕜 in /-- **Uniqueness of the conditional expectation** -/ theorem Lp.ae_eq_of_forall_setIntegral_eq' (hm : m ≤ m0) (f g : Lp E' p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hf_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn f s μ) (hg_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn g s μ) (hfg : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ) (hf_meas : AEStronglyMeasurable[m] f μ) (hg_meas : AEStronglyMeasurable[m] g μ) : f =ᵐ[μ] g := by suffices h_sub : ⇑(f - g) =ᵐ[μ] 0 by rw [← sub_ae_eq_zero]; exact (Lp.coeFn_sub f g).symm.trans h_sub have hfg' : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → (∫ x in s, (f - g) x ∂μ) = 0 := by intro s hs hμs rw [integral_congr_ae (ae_restrict_of_ae (Lp.coeFn_sub f g))] rw [integral_sub' (hf_int_finite s hs hμs) (hg_int_finite s hs hμs)] exact sub_eq_zero.mpr (hfg s hs hμs) have hfg_int : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn (⇑(f - g)) s μ := by intro s hs hμs rw [IntegrableOn, integrable_congr (ae_restrict_of_ae (Lp.coeFn_sub f g))] exact (hf_int_finite s hs hμs).sub (hg_int_finite s hs hμs) exact Lp.ae_eq_zero_of_forall_setIntegral_eq_zero' 𝕜 hm (f - g) hp_ne_zero hp_ne_top hfg_int hfg' <| (hf_meas.sub hg_meas).congr (Lp.coeFn_sub f g).symm variable {𝕜} theorem ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] {f g : α → F'} (hf_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn f s μ) (hg_int_finite : ∀ s, MeasurableSet[m] s → μ s < ∞ → IntegrableOn g s μ) (hfg_eq : ∀ s : Set α, MeasurableSet[m] s → μ s < ∞ → ∫ x in s, f x ∂μ = ∫ x in s, g x ∂μ) (hfm : AEStronglyMeasurable[m] f μ) (hgm : AEStronglyMeasurable[m] g μ) : f =ᵐ[μ] g := by rw [← ae_eq_trim_iff_of_aestronglyMeasurable hm hfm hgm] have hf_mk_int_finite (s) : MeasurableSet[m] s → μ.trim hm s < ∞ → @IntegrableOn _ _ m _ _ (hfm.mk f) s (μ.trim hm) := by intro hs hμs rw [trim_measurableSet_eq hm hs] at hμs rw [IntegrableOn, restrict_trim hm _ hs] refine Integrable.trim hm ?_ hfm.stronglyMeasurable_mk exact Integrable.congr (hf_int_finite s hs hμs) (ae_restrict_of_ae hfm.ae_eq_mk) have hg_mk_int_finite (s) : MeasurableSet[m] s → μ.trim hm s < ∞ → @IntegrableOn _ _ m _ _ (hgm.mk g) s (μ.trim hm) := by intro hs hμs rw [trim_measurableSet_eq hm hs] at hμs rw [IntegrableOn, restrict_trim hm _ hs] refine Integrable.trim hm ?_ hgm.stronglyMeasurable_mk exact Integrable.congr (hg_int_finite s hs hμs) (ae_restrict_of_ae hgm.ae_eq_mk) have hfg_mk_eq : ∀ s : Set α, MeasurableSet[m] s → μ.trim hm s < ∞ → ∫ x in s, hfm.mk f x ∂μ.trim hm = ∫ x in s, hgm.mk g x ∂μ.trim hm := by intro s hs hμs rw [trim_measurableSet_eq hm hs] at hμs rw [restrict_trim hm _ hs, ← integral_trim hm hfm.stronglyMeasurable_mk, ← integral_trim hm hgm.stronglyMeasurable_mk, integral_congr_ae (ae_restrict_of_ae hfm.ae_eq_mk.symm), integral_congr_ae (ae_restrict_of_ae hgm.ae_eq_mk.symm)] exact hfg_eq s hs hμs exact ae_eq_of_forall_setIntegral_eq_of_sigmaFinite hf_mk_int_finite hg_mk_int_finite hfg_mk_eq end UniquenessOfConditionalExpectation section IntegralNormLE variable {s : Set α} /-- Let `m` be a sub-σ-algebra of `m0`, `f` an `m0`-measurable function and `g` an `m`-measurable function, such that their integrals coincide on `m`-measurable sets with finite measure. Then `∫ x in s, ‖g x‖ ∂μ ≤ ∫ x in s, ‖f x‖ ∂μ` on all `m`-measurable sets with finite measure. -/ theorem integral_norm_le_of_forall_fin_meas_integral_eq (hm : m ≤ m0) {f g : α → ℝ} (hf : StronglyMeasurable f) (hfi : IntegrableOn f s μ) (hg : StronglyMeasurable[m] g) (hgi : IntegrableOn g s μ) (hgf : ∀ t, MeasurableSet[m] t → μ t < ∞ → ∫ x in t, g x ∂μ = ∫ x in t, f x ∂μ) (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) : (∫ x in s, ‖g x‖ ∂μ) ≤ ∫ x in s, ‖f x‖ ∂μ := by rw [integral_norm_eq_pos_sub_neg hgi, integral_norm_eq_pos_sub_neg hfi] have h_meas_nonneg_g : MeasurableSet[m] {x | 0 ≤ g x} := (@stronglyMeasurable_const _ _ m _ _).measurableSet_le hg have h_meas_nonneg_f : MeasurableSet {x | 0 ≤ f x} := stronglyMeasurable_const.measurableSet_le hf have h_meas_nonpos_g : MeasurableSet[m] {x | g x ≤ 0} := hg.measurableSet_le (@stronglyMeasurable_const _ _ m _ _) have h_meas_nonpos_f : MeasurableSet {x | f x ≤ 0} := hf.measurableSet_le stronglyMeasurable_const refine sub_le_sub ?_ ?_ · rw [Measure.restrict_restrict (hm _ h_meas_nonneg_g), Measure.restrict_restrict h_meas_nonneg_f, hgf _ (@MeasurableSet.inter α m _ _ h_meas_nonneg_g hs) ((measure_mono Set.inter_subset_right).trans_lt (lt_top_iff_ne_top.mpr hμs)), ← Measure.restrict_restrict (hm _ h_meas_nonneg_g), ← Measure.restrict_restrict h_meas_nonneg_f] exact setIntegral_le_nonneg (hm _ h_meas_nonneg_g) hf hfi · rw [Measure.restrict_restrict (hm _ h_meas_nonpos_g), Measure.restrict_restrict h_meas_nonpos_f, hgf _ (@MeasurableSet.inter α m _ _ h_meas_nonpos_g hs) ((measure_mono Set.inter_subset_right).trans_lt (lt_top_iff_ne_top.mpr hμs)), ← Measure.restrict_restrict (hm _ h_meas_nonpos_g), ← Measure.restrict_restrict h_meas_nonpos_f] exact setIntegral_nonpos_le (hm _ h_meas_nonpos_g) hf hfi /-- Let `m` be a sub-σ-algebra of `m0`, `f` an `m0`-measurable function and `g` an `m`-measurable function, such that their integrals coincide on `m`-measurable sets with finite measure. Then `∫⁻ x in s, ‖g x‖ₑ ∂μ ≤ ∫⁻ x in s, ‖f x‖ₑ ∂μ` on all `m`-measurable sets with finite measure. -/ theorem lintegral_enorm_le_of_forall_fin_meas_integral_eq (hm : m ≤ m0) {f g : α → ℝ} (hf : StronglyMeasurable f) (hfi : IntegrableOn f s μ) (hg : StronglyMeasurable[m] g) (hgi : IntegrableOn g s μ) (hgf : ∀ t, MeasurableSet[m] t → μ t < ∞ → ∫ x in t, g x ∂μ = ∫ x in t, f x ∂μ) (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) : (∫⁻ x in s, ‖g x‖ₑ ∂μ) ≤ ∫⁻ x in s, ‖f x‖ₑ ∂μ := by rw [← ofReal_integral_norm_eq_lintegral_enorm hfi, ← ofReal_integral_norm_eq_lintegral_enorm hgi, ENNReal.ofReal_le_ofReal_iff] · exact integral_norm_le_of_forall_fin_meas_integral_eq hm hf hfi hg hgi hgf hs hμs · positivity end IntegralNormLE end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConditionalExpectation/AEMeasurable.lean
import Mathlib.MeasureTheory.Function.LpSeminorm.Trim import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lp /-! # Functions a.e. measurable with respect to a sub-σ-algebra A function `f` verifies `AEStronglyMeasurable[m] f μ` if it is `μ`-a.e. equal to an `m`-strongly measurable function. This is similar to `AEStronglyMeasurable`, but the `MeasurableSpace` structures used for the measurability statement and for the measure are different. We define `lpMeas F 𝕜 m p μ`, the subspace of `Lp F p μ` containing functions `f` verifying `AEStronglyMeasurable[m] f μ`, i.e. functions which are `μ`-a.e. equal to an `m`-strongly measurable function. ## Main statements We define an `IsometryEquiv` between `lpMeasSubgroup` and the `Lp` space corresponding to the measure `μ.trim hm`. As a consequence, the completeness of `Lp` implies completeness of `lpMeas`. `Lp.induction_stronglyMeasurable` (see also `MemLp.induction_stronglyMeasurable`): To prove something for an `Lp` function a.e. strongly measurable with respect to a sub-σ-algebra `m` in a normed space, it suffices to show that * the property holds for (multiples of) characteristic functions which are measurable w.r.t. `m`; * is closed under addition; * the set of functions in `Lp` strongly measurable w.r.t. `m` for which the property holds is closed. -/ open TopologicalSpace Filter open scoped ENNReal MeasureTheory namespace MeasureTheory theorem ae_eq_trim_iff_of_aestronglyMeasurable {α β} [TopologicalSpace β] [MetrizableSpace β] {m m0 : MeasurableSpace α} {μ : Measure α} {f g : α → β} (hm : m ≤ m0) (hfm : AEStronglyMeasurable[m] f μ) (hgm : AEStronglyMeasurable[m] g μ) : hfm.mk f =ᵐ[μ.trim hm] hgm.mk g ↔ f =ᵐ[μ] g := (hfm.stronglyMeasurable_mk.ae_eq_trim_iff hm hgm.stronglyMeasurable_mk).trans ⟨fun h => hfm.ae_eq_mk.trans (h.trans hgm.ae_eq_mk.symm), fun h => hfm.ae_eq_mk.symm.trans (h.trans hgm.ae_eq_mk)⟩ theorem AEStronglyMeasurable.comp_ae_measurable' {α β γ : Type*} [TopologicalSpace β] {mα : MeasurableSpace α} {_ : MeasurableSpace γ} {f : α → β} {μ : Measure γ} {g : γ → α} (hf : AEStronglyMeasurable f (μ.map g)) (hg : AEMeasurable g μ) : AEStronglyMeasurable[mα.comap g] (f ∘ g) μ := ⟨hf.mk f ∘ g, hf.stronglyMeasurable_mk.comp_measurable (measurable_iff_comap_le.mpr le_rfl), ae_eq_comp hg hf.ae_eq_mk⟩ variable {α F 𝕜 : Type*} {p : ℝ≥0∞} [RCLike 𝕜] -- 𝕜 for ℝ or ℂ -- F for a Lp submodule [NormedAddCommGroup F] [NormedSpace 𝕜 F] section LpMeas /-! ## The subset `lpMeas` of `Lp` functions a.e. measurable with respect to a sub-sigma-algebra -/ variable (F) /-- `lpMeasSubgroup F m p μ` is the subspace of `Lp F p μ` containing functions `f` verifying `AEStronglyMeasurable[m] f μ`, i.e. functions which are `μ`-a.e. equal to an `m`-strongly measurable function. -/ def lpMeasSubgroup (m : MeasurableSpace α) [MeasurableSpace α] (p : ℝ≥0∞) (μ : Measure α) : AddSubgroup (Lp F p μ) where carrier := {f : Lp F p μ | AEStronglyMeasurable[m] f μ} zero_mem' := ⟨(0 : α → F), @stronglyMeasurable_zero _ _ m _ _, Lp.coeFn_zero _ _ _⟩ add_mem' {f g} hf hg := (hf.add hg).congr (Lp.coeFn_add f g).symm neg_mem' {f} hf := AEStronglyMeasurable.congr hf.neg (Lp.coeFn_neg f).symm variable (𝕜) /-- `lpMeas F 𝕜 m p μ` is the subspace of `Lp F p μ` containing functions `f` verifying `AEStronglyMeasurable[m] f μ`, i.e. functions which are `μ`-a.e. equal to an `m`-strongly measurable function. -/ def lpMeas (m : MeasurableSpace α) [MeasurableSpace α] (p : ℝ≥0∞) (μ : Measure α) : Submodule 𝕜 (Lp F p μ) where carrier := {f : Lp F p μ | AEStronglyMeasurable[m] f μ} zero_mem' := ⟨(0 : α → F), @stronglyMeasurable_zero _ _ m _ _, Lp.coeFn_zero _ _ _⟩ add_mem' {f g} hf hg := (hf.add hg).congr (Lp.coeFn_add f g).symm smul_mem' c f hf := (hf.const_smul c).congr (Lp.coeFn_smul c f).symm variable {F 𝕜} theorem mem_lpMeasSubgroup_iff_aestronglyMeasurable {m m0 : MeasurableSpace α} {μ : Measure α} {f : Lp F p μ} : f ∈ lpMeasSubgroup F m p μ ↔ AEStronglyMeasurable[m] f μ := by rw [← AddSubgroup.mem_carrier, lpMeasSubgroup, Set.mem_setOf_eq] theorem mem_lpMeas_iff_aestronglyMeasurable {m m0 : MeasurableSpace α} {μ : Measure α} {f : Lp F p μ} : f ∈ lpMeas F 𝕜 m p μ ↔ AEStronglyMeasurable[m] f μ := by rw [← SetLike.mem_coe, ← Submodule.mem_carrier, lpMeas, Set.mem_setOf_eq] theorem lpMeas.aestronglyMeasurable {m _ : MeasurableSpace α} {μ : Measure α} (f : lpMeas F 𝕜 m p μ) : AEStronglyMeasurable[m] (f : α → F) μ := mem_lpMeas_iff_aestronglyMeasurable.mp f.mem theorem mem_lpMeas_self {m0 : MeasurableSpace α} (μ : Measure α) (f : Lp F p μ) : f ∈ lpMeas F 𝕜 m0 p μ := mem_lpMeas_iff_aestronglyMeasurable.mpr (Lp.aestronglyMeasurable f) theorem mem_lpMeas_indicatorConstLp {m m0 : MeasurableSpace α} (hm : m ≤ m0) {μ : Measure α} {s : Set α} (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) {c : F} : indicatorConstLp p (hm s hs) hμs c ∈ lpMeas F 𝕜 m p μ := ⟨s.indicator fun _ : α => c, (@stronglyMeasurable_const _ _ m _ _).indicator hs, indicatorConstLp_coeFn⟩ section CompleteSubspace /-! ## The subspace `lpMeas` is complete. We define an `IsometryEquiv` between `lpMeasSubgroup` and the `Lp` space corresponding to the measure `μ.trim hm`. As a consequence, the completeness of `Lp` implies completeness of `lpMeasSubgroup` (and `lpMeas`). -/ variable {m m0 : MeasurableSpace α} {μ : Measure α} /-- If `f` belongs to `lpMeasSubgroup F m p μ`, then the measurable function it is almost everywhere equal to (given by `AEMeasurable.mk`) belongs to `ℒp` for the measure `μ.trim hm`. -/ theorem memLp_trim_of_mem_lpMeasSubgroup (hm : m ≤ m0) (f : Lp F p μ) (hf_meas : f ∈ lpMeasSubgroup F m p μ) : MemLp (mem_lpMeasSubgroup_iff_aestronglyMeasurable.mp hf_meas).choose p (μ.trim hm) := by have hf : AEStronglyMeasurable[m] f μ := mem_lpMeasSubgroup_iff_aestronglyMeasurable.mp hf_meas let g := hf.choose obtain ⟨hg, hfg⟩ := hf.choose_spec change MemLp g p (μ.trim hm) refine ⟨hg.aestronglyMeasurable, ?_⟩ have h_eLpNorm_fg : eLpNorm g p (μ.trim hm) = eLpNorm f p μ := by rw [eLpNorm_trim hm hg] exact eLpNorm_congr_ae hfg.symm rw [h_eLpNorm_fg] exact Lp.eLpNorm_lt_top f /-- If `f` belongs to `Lp` for the measure `μ.trim hm`, then it belongs to the subgroup `lpMeasSubgroup F m p μ`. -/ theorem mem_lpMeasSubgroup_toLp_of_trim (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) : (memLp_of_memLp_trim hm (Lp.memLp f)).toLp f ∈ lpMeasSubgroup F m p μ := by let hf_mem_ℒp := memLp_of_memLp_trim hm (Lp.memLp f) rw [mem_lpMeasSubgroup_iff_aestronglyMeasurable] refine AEStronglyMeasurable.congr ?_ (MemLp.coeFn_toLp hf_mem_ℒp).symm exact (Lp.aestronglyMeasurable f).of_trim hm variable (F p μ) /-- Map from `lpMeasSubgroup` to `Lp F p (μ.trim hm)`. -/ noncomputable def lpMeasSubgroupToLpTrim (hm : m ≤ m0) (f : lpMeasSubgroup F m p μ) : Lp F p (μ.trim hm) := MemLp.toLp (mem_lpMeasSubgroup_iff_aestronglyMeasurable.mp f.mem).choose (memLp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem) variable (𝕜) in /-- Map from `lpMeas` to `Lp F p (μ.trim hm)`. -/ noncomputable def lpMeasToLpTrim (hm : m ≤ m0) (f : lpMeas F 𝕜 m p μ) : Lp F p (μ.trim hm) := MemLp.toLp (mem_lpMeas_iff_aestronglyMeasurable.mp f.mem).choose (memLp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem) /-- Map from `Lp F p (μ.trim hm)` to `lpMeasSubgroup`, inverse of `lpMeasSubgroupToLpTrim`. -/ noncomputable def lpTrimToLpMeasSubgroup (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) : lpMeasSubgroup F m p μ := ⟨(memLp_of_memLp_trim hm (Lp.memLp f)).toLp f, mem_lpMeasSubgroup_toLp_of_trim hm f⟩ variable (𝕜) in /-- Map from `Lp F p (μ.trim hm)` to `lpMeas`, inverse of `Lp_meas_to_Lp_trim`. -/ noncomputable def lpTrimToLpMeas (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) : lpMeas F 𝕜 m p μ := ⟨(memLp_of_memLp_trim hm (Lp.memLp f)).toLp f, mem_lpMeasSubgroup_toLp_of_trim hm f⟩ variable {F p μ} theorem lpMeasSubgroupToLpTrim_ae_eq (hm : m ≤ m0) (f : lpMeasSubgroup F m p μ) : lpMeasSubgroupToLpTrim F p μ hm f =ᵐ[μ] f := (ae_eq_of_ae_eq_trim (MemLp.coeFn_toLp (memLp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem))).trans (mem_lpMeasSubgroup_iff_aestronglyMeasurable.mp f.mem).choose_spec.2.symm theorem lpTrimToLpMeasSubgroup_ae_eq (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) : lpTrimToLpMeasSubgroup F p μ hm f =ᵐ[μ] f := MemLp.coeFn_toLp (memLp_of_memLp_trim hm (Lp.memLp f)) theorem lpMeasToLpTrim_ae_eq (hm : m ≤ m0) (f : lpMeas F 𝕜 m p μ) : lpMeasToLpTrim F 𝕜 p μ hm f =ᵐ[μ] f := (ae_eq_of_ae_eq_trim (MemLp.coeFn_toLp (memLp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem))).trans (mem_lpMeasSubgroup_iff_aestronglyMeasurable.mp f.mem).choose_spec.2.symm theorem lpTrimToLpMeas_ae_eq (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) : lpTrimToLpMeas F 𝕜 p μ hm f =ᵐ[μ] f := MemLp.coeFn_toLp (memLp_of_memLp_trim hm (Lp.memLp f)) /-- `lpTrimToLpMeasSubgroup` is a right inverse of `lpMeasSubgroupToLpTrim`. -/ theorem lpMeasSubgroupToLpTrim_right_inv (hm : m ≤ m0) : Function.RightInverse (lpTrimToLpMeasSubgroup F p μ hm) (lpMeasSubgroupToLpTrim F p μ hm) := by intro f ext1 refine (Lp.stronglyMeasurable _).ae_eq_trim_of_stronglyMeasurable hm (Lp.stronglyMeasurable _) ?_ exact (lpMeasSubgroupToLpTrim_ae_eq hm _).trans (lpTrimToLpMeasSubgroup_ae_eq hm _) /-- `lpTrimToLpMeasSubgroup` is a left inverse of `lpMeasSubgroupToLpTrim`. -/ theorem lpMeasSubgroupToLpTrim_left_inv (hm : m ≤ m0) : Function.LeftInverse (lpTrimToLpMeasSubgroup F p μ hm) (lpMeasSubgroupToLpTrim F p μ hm) := by intro f ext1 ext1 exact (lpTrimToLpMeasSubgroup_ae_eq hm _).trans (lpMeasSubgroupToLpTrim_ae_eq hm _) theorem lpMeasSubgroupToLpTrim_add (hm : m ≤ m0) (f g : lpMeasSubgroup F m p μ) : lpMeasSubgroupToLpTrim F p μ hm (f + g) = lpMeasSubgroupToLpTrim F p μ hm f + lpMeasSubgroupToLpTrim F p μ hm g := by ext1 grw [Lp.coeFn_add] refine (Lp.stronglyMeasurable _).ae_eq_trim_of_stronglyMeasurable hm ?_ ?_ · exact (Lp.stronglyMeasurable _).add (Lp.stronglyMeasurable _) grw [lpMeasSubgroupToLpTrim_ae_eq, lpMeasSubgroupToLpTrim_ae_eq, lpMeasSubgroupToLpTrim_ae_eq, ← Lp.coeFn_add] rfl theorem lpMeasSubgroupToLpTrim_neg (hm : m ≤ m0) (f : lpMeasSubgroup F m p μ) : lpMeasSubgroupToLpTrim F p μ hm (-f) = -lpMeasSubgroupToLpTrim F p μ hm f := by ext1 grw [Lp.coeFn_neg] refine (Lp.stronglyMeasurable _).ae_eq_trim_of_stronglyMeasurable hm (Lp.stronglyMeasurable _).neg ?_ grw [lpMeasSubgroupToLpTrim_ae_eq, lpMeasSubgroupToLpTrim_ae_eq, ← Lp.coeFn_neg] rfl theorem lpMeasSubgroupToLpTrim_sub (hm : m ≤ m0) (f g : lpMeasSubgroup F m p μ) : lpMeasSubgroupToLpTrim F p μ hm (f - g) = lpMeasSubgroupToLpTrim F p μ hm f - lpMeasSubgroupToLpTrim F p μ hm g := by rw [sub_eq_add_neg, sub_eq_add_neg, lpMeasSubgroupToLpTrim_add, lpMeasSubgroupToLpTrim_neg] theorem lpMeasToLpTrim_smul (hm : m ≤ m0) (c : 𝕜) (f : lpMeas F 𝕜 m p μ) : lpMeasToLpTrim F 𝕜 p μ hm (c • f) = c • lpMeasToLpTrim F 𝕜 p μ hm f := by ext1 grw [Lp.coeFn_smul] refine (Lp.stronglyMeasurable _).ae_eq_trim_of_stronglyMeasurable hm ?_ ?_ · exact (Lp.stronglyMeasurable _).const_smul c grw [lpMeasToLpTrim_ae_eq] push_cast grw [Lp.coeFn_smul, lpMeasToLpTrim_ae_eq] /-- `lpMeasSubgroupToLpTrim` preserves the norm. -/ theorem lpMeasSubgroupToLpTrim_norm_map [hp : Fact (1 ≤ p)] (hm : m ≤ m0) (f : lpMeasSubgroup F m p μ) : ‖lpMeasSubgroupToLpTrim F p μ hm f‖ = ‖f‖ := by rw [Lp.norm_def, eLpNorm_trim hm (Lp.stronglyMeasurable _), eLpNorm_congr_ae (lpMeasSubgroupToLpTrim_ae_eq hm _), ← Lp.norm_def] congr theorem isometry_lpMeasSubgroupToLpTrim [hp : Fact (1 ≤ p)] (hm : m ≤ m0) : Isometry (lpMeasSubgroupToLpTrim F p μ hm) := Isometry.of_dist_eq fun f g => by rw [dist_eq_norm, ← lpMeasSubgroupToLpTrim_sub, lpMeasSubgroupToLpTrim_norm_map, dist_eq_norm] variable (F p μ) /-- `lpMeasSubgroup` and `Lp F p (μ.trim hm)` are isometric. -/ noncomputable def lpMeasSubgroupToLpTrimIso [Fact (1 ≤ p)] (hm : m ≤ m0) : lpMeasSubgroup F m p μ ≃ᵢ Lp F p (μ.trim hm) where toFun := lpMeasSubgroupToLpTrim F p μ hm invFun := lpTrimToLpMeasSubgroup F p μ hm left_inv := lpMeasSubgroupToLpTrim_left_inv hm right_inv := lpMeasSubgroupToLpTrim_right_inv hm isometry_toFun := isometry_lpMeasSubgroupToLpTrim hm variable (𝕜) /-- `lpMeasSubgroup` and `lpMeas` are isometric. -/ noncomputable def lpMeasSubgroupToLpMeasIso [Fact (1 ≤ p)] : lpMeasSubgroup F m p μ ≃ᵢ lpMeas F 𝕜 m p μ := IsometryEquiv.refl (lpMeasSubgroup F m p μ) /-- `lpMeas` and `Lp F p (μ.trim hm)` are isometric, with a linear equivalence. -/ noncomputable def lpMeasToLpTrimLie [Fact (1 ≤ p)] (hm : m ≤ m0) : lpMeas F 𝕜 m p μ ≃ₗᵢ[𝕜] Lp F p (μ.trim hm) where toFun := lpMeasToLpTrim F 𝕜 p μ hm invFun := lpTrimToLpMeas F 𝕜 p μ hm left_inv := lpMeasSubgroupToLpTrim_left_inv hm right_inv := lpMeasSubgroupToLpTrim_right_inv hm map_add' := lpMeasSubgroupToLpTrim_add hm map_smul' := lpMeasToLpTrim_smul hm norm_map' := lpMeasSubgroupToLpTrim_norm_map hm variable {F 𝕜 p μ} instance [hm : Fact (m ≤ m0)] [CompleteSpace F] [hp : Fact (1 ≤ p)] : CompleteSpace (lpMeasSubgroup F m p μ) := by rw [(lpMeasSubgroupToLpTrimIso F p μ hm.elim).completeSpace_iff]; infer_instance instance [hm : Fact (m ≤ m0)] [CompleteSpace F] [hp : Fact (1 ≤ p)] : CompleteSpace (lpMeas F 𝕜 m p μ) := by rw [(lpMeasSubgroupToLpMeasIso F 𝕜 p μ).symm.completeSpace_iff]; infer_instance theorem isComplete_aestronglyMeasurable [hp : Fact (1 ≤ p)] [CompleteSpace F] (hm : m ≤ m0) : IsComplete {f : Lp F p μ | AEStronglyMeasurable[m] f μ} := by rw [← completeSpace_coe_iff_isComplete] haveI : Fact (m ≤ m0) := ⟨hm⟩ change CompleteSpace (lpMeasSubgroup F m p μ) infer_instance theorem isClosed_aestronglyMeasurable [Fact (1 ≤ p)] [CompleteSpace F] (hm : m ≤ m0) : IsClosed {f : Lp F p μ | AEStronglyMeasurable[m] f μ} := IsComplete.isClosed (isComplete_aestronglyMeasurable hm) end CompleteSubspace section StronglyMeasurable variable {m m0 : MeasurableSpace α} {μ : Measure α} /-- We do not get `ae_fin_strongly_measurable f (μ.trim hm)`, since we don't have `f =ᵐ[μ.trim hm] Lp_meas_to_Lp_trim F 𝕜 p μ hm f` but only the weaker `f =ᵐ[μ] Lp_meas_to_Lp_trim F 𝕜 p μ hm f`. -/ theorem lpMeas.ae_fin_strongly_measurable' (hm : m ≤ m0) (f : lpMeas F 𝕜 m p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : ∃ g, FinStronglyMeasurable g (μ.trim hm) ∧ f.1 =ᵐ[μ] g := ⟨lpMeasSubgroupToLpTrim F p μ hm f, Lp.finStronglyMeasurable _ hp_ne_zero hp_ne_top, (lpMeasSubgroupToLpTrim_ae_eq hm f).symm⟩ /-- When applying the inverse of `lpMeasToLpTrimLie` (which takes a function in the Lp space of the sub-sigma algebra and returns its version in the larger Lp space) to an indicator of the sub-sigma-algebra, we obtain an indicator in the Lp space of the larger sigma-algebra. -/ theorem lpMeasToLpTrimLie_symm_indicator [one_le_p : Fact (1 ≤ p)] [NormedSpace ℝ F] {hm : m ≤ m0} {s : Set α} {μ : Measure α} (hs : MeasurableSet[m] s) (hμs : μ.trim hm s ≠ ∞) (c : F) : ((lpMeasToLpTrimLie F ℝ p μ hm).symm (indicatorConstLp p hs hμs c) : Lp F p μ) = indicatorConstLp p (hm s hs) ((le_trim hm).trans_lt hμs.lt_top).ne c := by ext1 change lpTrimToLpMeas F ℝ p μ hm (indicatorConstLp p hs hμs c) =ᵐ[μ] (indicatorConstLp p _ _ c : α → F) grw [lpTrimToLpMeas_ae_eq, ae_eq_of_ae_eq_trim indicatorConstLp_coeFn, indicatorConstLp_coeFn] theorem lpMeasToLpTrimLie_symm_toLp [one_le_p : Fact (1 ≤ p)] [NormedSpace ℝ F] (hm : m ≤ m0) (f : α → F) (hf : MemLp f p (μ.trim hm)) : ((lpMeasToLpTrimLie F ℝ p μ hm).symm (hf.toLp f) : Lp F p μ) = (memLp_of_memLp_trim hm hf).toLp f := by ext1 change lpTrimToLpMeas F ℝ p μ hm (MemLp.toLp f hf) =ᵐ[μ] (MemLp.toLp f _ : α → F) grw [lpTrimToLpMeas_ae_eq, ae_eq_of_ae_eq_trim (MemLp.coeFn_toLp hf), MemLp.coeFn_toLp] end StronglyMeasurable end LpMeas section Induction variable {m m0 : MeasurableSpace α} {μ : Measure α} [Fact (1 ≤ p)] [NormedSpace ℝ F] /-- Auxiliary lemma for `Lp.induction_stronglyMeasurable`. -/ @[elab_as_elim] theorem Lp.induction_stronglyMeasurable_aux (hm : m ≤ m0) (hp_ne_top : p ≠ ∞) (P : Lp F p μ → Prop) (h_ind : ∀ (c : F) {s : Set α} (hs : MeasurableSet[m] s) (hμs : μ s < ∞), P (Lp.simpleFunc.indicatorConst p (hm s hs) hμs.ne c)) (h_add : ∀ ⦃f g⦄, ∀ hf : MemLp f p μ, ∀ hg : MemLp g p μ, AEStronglyMeasurable[m] f μ → AEStronglyMeasurable[m] g μ → Disjoint (Function.support f) (Function.support g) → P (hf.toLp f) → P (hg.toLp g) → P (hf.toLp f + hg.toLp g)) (h_closed : IsClosed {f : lpMeas F ℝ m p μ | P f}) : ∀ f : Lp F p μ, AEStronglyMeasurable[m] f μ → P f := by intro f hf let f' := (⟨f, hf⟩ : lpMeas F ℝ m p μ) let g := lpMeasToLpTrimLie F ℝ p μ hm f' have hfg : f' = (lpMeasToLpTrimLie F ℝ p μ hm).symm g := by simp only [f', g, LinearIsometryEquiv.symm_apply_apply] change P ↑f' rw [hfg] refine @Lp.induction α F m _ p (μ.trim hm) _ hp_ne_top (fun g => P ((lpMeasToLpTrimLie F ℝ p μ hm).symm g)) ?_ ?_ ?_ g · intro b t ht hμt rw [@Lp.simpleFunc.coe_indicatorConst _ _ m, lpMeasToLpTrimLie_symm_indicator ht hμt.ne b] have hμt' : μ t < ∞ := (le_trim hm).trans_lt hμt specialize h_ind b ht hμt' rwa [Lp.simpleFunc.coe_indicatorConst] at h_ind · intro f g hf hg h_disj hfP hgP rw [LinearIsometryEquiv.map_add] push_cast have h_eq : ∀ (f : α → F) (hf : MemLp f p (μ.trim hm)), ((lpMeasToLpTrimLie F ℝ p μ hm).symm (MemLp.toLp f hf) : Lp F p μ) = (memLp_of_memLp_trim hm hf).toLp f := lpMeasToLpTrimLie_symm_toLp hm rw [h_eq f hf] at hfP ⊢ rw [h_eq g hg] at hgP ⊢ exact h_add (memLp_of_memLp_trim hm hf) (memLp_of_memLp_trim hm hg) (hf.aestronglyMeasurable.of_trim hm) (hg.aestronglyMeasurable.of_trim hm) h_disj hfP hgP · change IsClosed ((lpMeasToLpTrimLie F ℝ p μ hm).symm ⁻¹' {g : lpMeas F ℝ m p μ | P ↑g}) exact IsClosed.preimage (LinearIsometryEquiv.continuous _) h_closed /-- To prove something for an `Lp` function a.e. strongly measurable with respect to a sub-σ-algebra `m` in a normed space, it suffices to show that * the property holds for (multiples of) characteristic functions which are measurable w.r.t. `m`; * is closed under addition; * the set of functions in `Lp` strongly measurable w.r.t. `m` for which the property holds is closed. -/ @[elab_as_elim] theorem Lp.induction_stronglyMeasurable (hm : m ≤ m0) (hp_ne_top : p ≠ ∞) (P : Lp F p μ → Prop) (h_ind : ∀ (c : F) {s : Set α} (hs : MeasurableSet[m] s) (hμs : μ s < ∞), P (Lp.simpleFunc.indicatorConst p (hm s hs) hμs.ne c)) (h_add : ∀ ⦃f g⦄, ∀ hf : MemLp f p μ, ∀ hg : MemLp g p μ, StronglyMeasurable[m] f → StronglyMeasurable[m] g → Disjoint (Function.support f) (Function.support g) → P (hf.toLp f) → P (hg.toLp g) → P (hf.toLp f + hg.toLp g)) (h_closed : IsClosed {f : lpMeas F ℝ m p μ | P f}) : ∀ f : Lp F p μ, AEStronglyMeasurable[m] f μ → P f := by intro f hf suffices h_add_ae : ∀ ⦃f g⦄, ∀ hf : MemLp f p μ, ∀ hg : MemLp g p μ, AEStronglyMeasurable[m] f μ → AEStronglyMeasurable[m] g μ → Disjoint (Function.support f) (Function.support g) → P (hf.toLp f) → P (hg.toLp g) → P (hf.toLp f + hg.toLp g) from Lp.induction_stronglyMeasurable_aux hm hp_ne_top _ h_ind h_add_ae h_closed f hf intro f g hf hg hfm hgm h_disj hPf hPg let s_f : Set α := Function.support (hfm.mk f) have hs_f : MeasurableSet[m] s_f := hfm.stronglyMeasurable_mk.measurableSet_support have hs_f_eq : s_f =ᵐ[μ] Function.support f := hfm.ae_eq_mk.symm.support let s_g : Set α := Function.support (hgm.mk g) have hs_g : MeasurableSet[m] s_g := hgm.stronglyMeasurable_mk.measurableSet_support have hs_g_eq : s_g =ᵐ[μ] Function.support g := hgm.ae_eq_mk.symm.support have h_inter_empty : (s_f ∩ s_g : Set α) =ᵐ[μ] (∅ : Set α) := by refine (hs_f_eq.inter hs_g_eq).trans ?_ suffices Function.support f ∩ Function.support g = ∅ by rw [this] exact Set.disjoint_iff_inter_eq_empty.mp h_disj let f' := (s_f \ s_g).indicator (hfm.mk f) have hff' : f =ᵐ[μ] f' := by have : s_f \ s_g =ᵐ[μ] s_f := by rw [← Set.diff_inter_self_eq_diff, Set.inter_comm] refine ((ae_eq_refl s_f).diff h_inter_empty).trans ?_ rw [Set.diff_empty] refine ((indicator_ae_eq_of_ae_eq_set this).trans ?_).symm rw [Set.indicator_support] exact hfm.ae_eq_mk.symm have hf'_meas : StronglyMeasurable[m] f' := hfm.stronglyMeasurable_mk.indicator (hs_f.diff hs_g) have hf'_Lp : MemLp f' p μ := hf.ae_eq hff' let g' := (s_g \ s_f).indicator (hgm.mk g) have hgg' : g =ᵐ[μ] g' := by have : s_g \ s_f =ᵐ[μ] s_g := by rw [← Set.diff_inter_self_eq_diff] refine ((ae_eq_refl s_g).diff h_inter_empty).trans ?_ rw [Set.diff_empty] refine ((indicator_ae_eq_of_ae_eq_set this).trans ?_).symm rw [Set.indicator_support] exact hgm.ae_eq_mk.symm have hg'_meas : StronglyMeasurable[m] g' := hgm.stronglyMeasurable_mk.indicator (hs_g.diff hs_f) have hg'_Lp : MemLp g' p μ := hg.ae_eq hgg' have h_disj : Disjoint (Function.support f') (Function.support g') := haveI : Disjoint (s_f \ s_g) (s_g \ s_f) := disjoint_sdiff_sdiff this.mono Set.support_indicator_subset Set.support_indicator_subset rw [← MemLp.toLp_congr hf'_Lp hf hff'.symm] at hPf ⊢ rw [← MemLp.toLp_congr hg'_Lp hg hgg'.symm] at hPg ⊢ exact h_add hf'_Lp hg'_Lp hf'_meas hg'_meas h_disj hPf hPg /-- To prove something for an arbitrary `MemLp` function a.e. strongly measurable with respect to a sub-σ-algebra `m` in a normed space, it suffices to show that * the property holds for (multiples of) characteristic functions which are measurable w.r.t. `m`; * is closed under addition; * the set of functions in the `Lᵖ` space strongly measurable w.r.t. `m` for which the property holds is closed. * the property is closed under the almost-everywhere equal relation. -/ @[elab_as_elim] theorem MemLp.induction_stronglyMeasurable (hm : m ≤ m0) (hp_ne_top : p ≠ ∞) (P : (α → F) → Prop) (h_ind : ∀ (c : F) ⦃s⦄, MeasurableSet[m] s → μ s < ∞ → P (s.indicator fun _ => c)) (h_add : ∀ ⦃f g : α → F⦄, Disjoint (Function.support f) (Function.support g) → MemLp f p μ → MemLp g p μ → StronglyMeasurable[m] f → StronglyMeasurable[m] g → P f → P g → P (f + g)) (h_closed : IsClosed {f : lpMeas F ℝ m p μ | P f}) (h_ae : ∀ ⦃f g⦄, f =ᵐ[μ] g → MemLp f p μ → P f → P g) : ∀ ⦃f : α → F⦄, MemLp f p μ → AEStronglyMeasurable[m] f μ → P f := by intro f hf hfm let f_Lp := hf.toLp f have hfm_Lp : AEStronglyMeasurable[m] f_Lp μ := hfm.congr hf.coeFn_toLp.symm refine h_ae hf.coeFn_toLp (Lp.memLp _) ?_ change P f_Lp refine Lp.induction_stronglyMeasurable hm hp_ne_top (fun f => P f) ?_ ?_ h_closed f_Lp hfm_Lp · intro c s hs hμs rw [Lp.simpleFunc.coe_indicatorConst] refine h_ae indicatorConstLp_coeFn.symm ?_ (h_ind c hs hμs) exact memLp_indicator_const p (hm s hs) c (Or.inr hμs.ne) · intro f g hf_mem hg_mem hfm hgm h_disj hfP hgP have hfP' : P f := h_ae hf_mem.coeFn_toLp (Lp.memLp _) hfP have hgP' : P g := h_ae hg_mem.coeFn_toLp (Lp.memLp _) hgP specialize h_add h_disj hf_mem hg_mem hfm hgm hfP' hgP' refine h_ae ?_ (hf_mem.add hg_mem) h_add exact (hf_mem.coeFn_toLp.symm.add hg_mem.coeFn_toLp.symm).trans (Lp.coeFn_add _ _).symm end Induction end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConditionalExpectation/CondexpL2.lean
import Mathlib.Analysis.InnerProductSpace.Projection.Basic import Mathlib.MeasureTheory.Function.ConditionalExpectation.Unique import Mathlib.MeasureTheory.Function.L2Space /-! # Conditional expectation in L2 This file contains one step of the construction of the conditional expectation, which is completed in `MeasureTheory.Function.ConditionalExpectation.Basic`. See that file for a description of the full process. We build the conditional expectation of an `L²` function, as an element of `L²`. This is the orthogonal projection on the subspace of almost everywhere `m`-measurable functions. ## Main definitions * `condExpL2`: Conditional expectation of a function in L2 with respect to a sigma-algebra: it is the orthogonal projection on the subspace `lpMeas`. ## Implementation notes Most of the results in this file are valid for a complete real normed space `F`. However, some lemmas also use `𝕜 : RCLike`: * `condExpL2` is defined only for an `InnerProductSpace` for now, and we use `𝕜` for its field. * results about scalar multiplication are stated not only for `ℝ` but also for `𝕜` if we happen to have `NormedSpace 𝕜 F`. -/ open TopologicalSpace Filter ContinuousLinearMap open scoped ENNReal Topology MeasureTheory namespace MeasureTheory variable {α E E' F G G' 𝕜 : Type*} [RCLike 𝕜] -- 𝕜 for ℝ or ℂ -- E for an inner product space [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] [CompleteSpace E] -- E' for an inner product space on which we compute integrals [NormedAddCommGroup E'] [InnerProductSpace 𝕜 E'] [CompleteSpace E'] [NormedSpace ℝ E'] -- F for a Lp submodule [NormedAddCommGroup F] [NormedSpace 𝕜 F] -- G for a Lp add_subgroup [NormedAddCommGroup G] -- G' for integrals on a Lp add_subgroup [NormedAddCommGroup G'] [NormedSpace ℝ G'] [CompleteSpace G'] variable {m m0 : MeasurableSpace α} {μ : Measure α} {s t : Set α} local notation "⟪" x ", " y "⟫" => inner 𝕜 x y variable (E 𝕜) /-- Conditional expectation of a function in L2 with respect to a sigma-algebra -/ noncomputable def condExpL2 (hm : m ≤ m0) : (α →₂[μ] E) →L[𝕜] lpMeas E 𝕜 m 2 μ := haveI : Fact (m ≤ m0) := ⟨hm⟩ (lpMeas E 𝕜 m 2 μ).orthogonalProjection variable {E 𝕜} theorem aestronglyMeasurable_condExpL2 (hm : m ≤ m0) (f : α →₂[μ] E) : AEStronglyMeasurable[m] (condExpL2 E 𝕜 hm f : α → E) μ := lpMeas.aestronglyMeasurable _ theorem integrableOn_condExpL2_of_measure_ne_top (hm : m ≤ m0) (hμs : μ s ≠ ∞) (f : α →₂[μ] E) : IntegrableOn (ε := E) (condExpL2 E 𝕜 hm f) s μ := integrableOn_Lp_of_measure_ne_top (condExpL2 E 𝕜 hm f : α →₂[μ] E) fact_one_le_two_ennreal.elim hμs theorem integrable_condExpL2_of_isFiniteMeasure (hm : m ≤ m0) [IsFiniteMeasure μ] {f : α →₂[μ] E} : Integrable (ε := E) (condExpL2 E 𝕜 hm f) μ := integrableOn_univ.mp <| integrableOn_condExpL2_of_measure_ne_top hm (measure_ne_top _ _) f theorem norm_condExpL2_le_one (hm : m ≤ m0) : ‖@condExpL2 α E 𝕜 _ _ _ _ _ _ μ hm‖ ≤ 1 := haveI : Fact (m ≤ m0) := ⟨hm⟩ Submodule.orthogonalProjection_norm_le _ theorem norm_condExpL2_le (hm : m ≤ m0) (f : α →₂[μ] E) : ‖condExpL2 E 𝕜 hm f‖ ≤ ‖f‖ := ((@condExpL2 _ E 𝕜 _ _ _ _ _ _ μ hm).le_opNorm f).trans (mul_le_of_le_one_left (norm_nonneg _) (norm_condExpL2_le_one hm)) theorem eLpNorm_condExpL2_le (hm : m ≤ m0) (f : α →₂[μ] E) : eLpNorm (ε := E) (condExpL2 E 𝕜 hm f) 2 μ ≤ eLpNorm f 2 μ := by rw [← ENNReal.toReal_le_toReal (Lp.eLpNorm_ne_top _) (Lp.eLpNorm_ne_top _), ← Lp.norm_def, ← Lp.norm_def, Submodule.norm_coe] exact norm_condExpL2_le hm f theorem norm_condExpL2_coe_le (hm : m ≤ m0) (f : α →₂[μ] E) : ‖(condExpL2 E 𝕜 hm f : α →₂[μ] E)‖ ≤ ‖f‖ := by rw [Lp.norm_def, Lp.norm_def] exact ENNReal.toReal_mono (Lp.eLpNorm_ne_top _) (eLpNorm_condExpL2_le hm f) theorem inner_condExpL2_left_eq_right (hm : m ≤ m0) {f g : α →₂[μ] E} : ⟪(condExpL2 E 𝕜 hm f : α →₂[μ] E), g⟫ = ⟪f, (condExpL2 E 𝕜 hm g : α →₂[μ] E)⟫ := haveI : Fact (m ≤ m0) := ⟨hm⟩ Submodule.inner_starProjection_left_eq_right _ f g theorem condExpL2_indicator_of_measurable (hm : m ≤ m0) (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) (c : E) : (condExpL2 E 𝕜 hm (indicatorConstLp 2 (hm s hs) hμs c) : α →₂[μ] E) = indicatorConstLp 2 (hm s hs) hμs c := by rw [condExpL2] haveI : Fact (m ≤ m0) := ⟨hm⟩ have h_mem : indicatorConstLp 2 (hm s hs) hμs c ∈ lpMeas E 𝕜 m 2 μ := mem_lpMeas_indicatorConstLp hm hs hμs let ind := (⟨indicatorConstLp 2 (hm s hs) hμs c, h_mem⟩ : lpMeas E 𝕜 m 2 μ) have h_coe_ind : (ind : α →₂[μ] E) = indicatorConstLp 2 (hm s hs) hμs c := rfl have h_orth_mem := Submodule.orthogonalProjection_mem_subspace_eq_self ind rw [← h_coe_ind, h_orth_mem] theorem inner_condExpL2_eq_inner_fun (hm : m ≤ m0) (f g : α →₂[μ] E) (hg : AEStronglyMeasurable[m] g μ) : ⟪(condExpL2 E 𝕜 hm f : α →₂[μ] E), g⟫ = ⟪f, g⟫ := by symm rw [← sub_eq_zero, ← inner_sub_left, condExpL2] simp only [← Submodule.starProjection_apply, mem_lpMeas_iff_aestronglyMeasurable.mpr hg, Submodule.starProjection_inner_eq_zero f g] section Real variable {hm : m ≤ m0} theorem integral_condExpL2_eq_of_fin_meas_real (f : Lp 𝕜 2 μ) (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) : ∫ x in s, (condExpL2 𝕜 𝕜 hm f : α → 𝕜) x ∂μ = ∫ x in s, f x ∂μ := by rw [← L2.inner_indicatorConstLp_one (𝕜 := 𝕜) (hm s hs) hμs f] have h_eq_inner : ∫ x in s, (condExpL2 𝕜 𝕜 hm f : α → 𝕜) x ∂μ = ⟪indicatorConstLp 2 (hm s hs) hμs (1 : 𝕜), condExpL2 𝕜 𝕜 hm f⟫ := by rw [L2.inner_indicatorConstLp_one (hm s hs) hμs] rw [h_eq_inner, ← inner_condExpL2_left_eq_right, condExpL2_indicator_of_measurable hm hs hμs] theorem lintegral_nnnorm_condExpL2_le (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) (f : Lp ℝ 2 μ) : ∫⁻ x in s, ‖(condExpL2 ℝ ℝ hm f : α → ℝ) x‖₊ ∂μ ≤ ∫⁻ x in s, ‖f x‖₊ ∂μ := by let h_meas := lpMeas.aestronglyMeasurable (condExpL2 ℝ ℝ hm f) let g := h_meas.choose have hg_meas : StronglyMeasurable[m] g := h_meas.choose_spec.1 have hg_eq : g =ᵐ[μ] condExpL2 ℝ ℝ hm f := h_meas.choose_spec.2.symm have hg_eq_restrict : g =ᵐ[μ.restrict s] condExpL2 ℝ ℝ hm f := ae_restrict_of_ae hg_eq have hg_nnnorm_eq : (fun x => (‖g x‖₊ : ℝ≥0∞)) =ᵐ[μ.restrict s] fun x => (‖(condExpL2 ℝ ℝ hm f : α → ℝ) x‖₊ : ℝ≥0∞) := by refine hg_eq_restrict.mono fun x hx => ?_ dsimp only simp_rw [hx] rw [lintegral_congr_ae hg_nnnorm_eq.symm] refine lintegral_enorm_le_of_forall_fin_meas_integral_eq hm (Lp.stronglyMeasurable f) ?_ ?_ ?_ ?_ hs hμs · exact integrableOn_Lp_of_measure_ne_top f fact_one_le_two_ennreal.elim hμs · exact hg_meas · rw [IntegrableOn, integrable_congr hg_eq_restrict] exact integrableOn_condExpL2_of_measure_ne_top hm hμs f · intro t ht hμt rw [← integral_condExpL2_eq_of_fin_meas_real (hm := hm) f ht hμt.ne] exact setIntegral_congr_ae (hm t ht) (hg_eq.mono fun x hx _ => hx) theorem condExpL2_ae_eq_zero_of_ae_eq_zero (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) {f : Lp ℝ 2 μ} (hf : f =ᵐ[μ.restrict s] 0) : condExpL2 ℝ ℝ hm f =ᵐ[μ.restrict s] (0 : α → ℝ) := by suffices h_nnnorm_eq_zero : ∫⁻ x in s, ‖(condExpL2 ℝ ℝ hm f : α → ℝ) x‖₊ ∂μ = 0 by rw [lintegral_eq_zero_iff] at h_nnnorm_eq_zero · refine h_nnnorm_eq_zero.mono fun x hx => ?_ dsimp only at hx rw [Pi.zero_apply] at hx ⊢ · rwa [ENNReal.coe_eq_zero, nnnorm_eq_zero] at hx · refine Measurable.coe_nnreal_ennreal (Measurable.nnnorm ?_) exact (Lp.stronglyMeasurable _).measurable refine le_antisymm ?_ (zero_le _) refine (lintegral_nnnorm_condExpL2_le hs hμs f).trans (le_of_eq ?_) rw [lintegral_eq_zero_iff] · refine hf.mono fun x hx => ?_ dsimp only rw [hx] simp · exact (Lp.stronglyMeasurable _).enorm (ε := ℝ) theorem lintegral_nnnorm_condExpL2_indicator_le_real (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (ht : MeasurableSet[m] t) (hμt : μ t ≠ ∞) : ∫⁻ a in t, ‖(condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) a‖₊ ∂μ ≤ μ (s ∩ t) := by refine (lintegral_nnnorm_condExpL2_le ht hμt _).trans (le_of_eq ?_) have h_eq : ∫⁻ x in t, ‖(indicatorConstLp 2 hs hμs (1 : ℝ)) x‖₊ ∂μ = ∫⁻ x in t, s.indicator (fun _ => (1 : ℝ≥0∞)) x ∂μ := by refine lintegral_congr_ae (ae_restrict_of_ae ?_) refine (@indicatorConstLp_coeFn _ _ _ 2 _ _ _ hs hμs (1 : ℝ)).mono fun x hx => ?_ dsimp only rw [hx] classical simp_rw [Set.indicator_apply] split_ifs <;> simp rw [h_eq, lintegral_indicator hs, lintegral_const, Measure.restrict_restrict hs] simp only [one_mul, Set.univ_inter, MeasurableSet.univ, Measure.restrict_apply] end Real /-- `condExpL2` commutes with taking inner products with constants. See the lemma `condExpL2_comp_continuousLinearMap` for a more general result about commuting with continuous linear maps. -/ theorem condExpL2_const_inner (hm : m ≤ m0) (f : Lp E 2 μ) (c : E) : condExpL2 𝕜 𝕜 hm (((Lp.memLp f).const_inner c).toLp fun a => ⟪c, f a⟫) =ᵐ[μ] fun a => ⟪c, (condExpL2 E 𝕜 hm f : α → E) a⟫ := by have h_mem_Lp : MemLp (fun a => ⟪c, (condExpL2 E 𝕜 hm f : α → E) a⟫) 2 μ := by refine MemLp.const_inner _ ?_; exact Lp.memLp _ have h_eq : h_mem_Lp.toLp _ =ᵐ[μ] fun a => ⟪c, (condExpL2 E 𝕜 hm f : α → E) a⟫ := h_mem_Lp.coeFn_toLp refine EventuallyEq.trans ?_ h_eq refine Lp.ae_eq_of_forall_setIntegral_eq' 𝕜 hm _ _ two_ne_zero ENNReal.coe_ne_top (fun s _ hμs => integrableOn_condExpL2_of_measure_ne_top hm hμs.ne _) ?_ ?_ ?_ ?_ · intro s _ hμs rw [IntegrableOn, integrable_congr (ae_restrict_of_ae h_eq)] exact (integrableOn_condExpL2_of_measure_ne_top hm hμs.ne _).const_inner _ · intro s hs hμs rw [integral_condExpL2_eq_of_fin_meas_real _ hs hμs.ne, integral_congr_ae (ae_restrict_of_ae h_eq), ← L2.inner_indicatorConstLp_eq_setIntegral_inner 𝕜 (↑(condExpL2 E 𝕜 hm f)) (hm s hs) c hμs.ne, ← inner_condExpL2_left_eq_right, condExpL2_indicator_of_measurable _ hs, L2.inner_indicatorConstLp_eq_setIntegral_inner 𝕜 f (hm s hs) c hμs.ne, setIntegral_congr_ae (hm s hs) ((MemLp.coeFn_toLp ((Lp.memLp f).const_inner c)).mono fun x hx _ => hx)] · exact lpMeas.aestronglyMeasurable _ · refine AEStronglyMeasurable.congr ?_ h_eq.symm exact (lpMeas.aestronglyMeasurable _).const_inner /-- `condExpL2` verifies the equality of integrals defining the conditional expectation. -/ theorem integral_condExpL2_eq (hm : m ≤ m0) (f : Lp E' 2 μ) (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) : ∫ x in s, (condExpL2 E' 𝕜 hm f : α → E') x ∂μ = ∫ x in s, f x ∂μ := by rw [← sub_eq_zero, ← integral_sub' (integrableOn_Lp_of_measure_ne_top _ fact_one_le_two_ennreal.elim hμs) (integrableOn_Lp_of_measure_ne_top _ fact_one_le_two_ennreal.elim hμs)] refine integral_eq_zero_of_forall_integral_inner_eq_zero 𝕜 _ ?_ ?_ · rw [integrable_congr (ae_restrict_of_ae (Lp.coeFn_sub (↑(condExpL2 E' 𝕜 hm f)) f).symm)] exact integrableOn_Lp_of_measure_ne_top _ fact_one_le_two_ennreal.elim hμs intro c simp_rw [Pi.sub_apply, inner_sub_right] rw [integral_sub ((integrableOn_Lp_of_measure_ne_top _ fact_one_le_two_ennreal.elim hμs).const_inner c) ((integrableOn_Lp_of_measure_ne_top _ fact_one_le_two_ennreal.elim hμs).const_inner c)] have h_ae_eq_f := MemLp.coeFn_toLp (E := 𝕜) ((Lp.memLp f).const_inner c) rw [sub_eq_zero, ← setIntegral_congr_ae (hm s hs) ((condExpL2_const_inner hm f c).mono fun x hx _ => hx), ← setIntegral_congr_ae (hm s hs) (h_ae_eq_f.mono fun x hx _ => hx)] exact integral_condExpL2_eq_of_fin_meas_real _ hs hμs variable {E'' 𝕜' : Type*} [RCLike 𝕜'] [NormedAddCommGroup E''] [InnerProductSpace 𝕜' E''] [CompleteSpace E''] [NormedSpace ℝ E''] variable (𝕜 𝕜') theorem condExpL2_comp_continuousLinearMap (hm : m ≤ m0) (T : E' →L[ℝ] E'') (f : α →₂[μ] E') : (condExpL2 E'' 𝕜' hm (T.compLp f) : α →₂[μ] E'') =ᵐ[μ] T.compLp (condExpL2 E' 𝕜 hm f : α →₂[μ] E') := by refine Lp.ae_eq_of_forall_setIntegral_eq' 𝕜' hm _ _ two_ne_zero ENNReal.coe_ne_top (fun s _ hμs => integrableOn_condExpL2_of_measure_ne_top hm hμs.ne _) (fun s _ hμs => integrableOn_Lp_of_measure_ne_top _ fact_one_le_two_ennreal.elim hμs.ne) ?_ ?_ ?_ · intro s hs hμs rw [T.setIntegral_compLp _ (hm s hs), T.integral_comp_comm (integrableOn_Lp_of_measure_ne_top _ fact_one_le_two_ennreal.elim hμs.ne), integral_condExpL2_eq hm f hs hμs.ne, integral_condExpL2_eq hm (T.compLp f) hs hμs.ne, T.setIntegral_compLp _ (hm s hs), T.integral_comp_comm (integrableOn_Lp_of_measure_ne_top f fact_one_le_two_ennreal.elim hμs.ne)] · exact lpMeas.aestronglyMeasurable _ · have h_coe := T.coeFn_compLp (condExpL2 E' 𝕜 hm f : α →₂[μ] E') rw [← EventuallyEq] at h_coe refine AEStronglyMeasurable.congr ?_ h_coe.symm exact T.continuous.comp_aestronglyMeasurable (lpMeas.aestronglyMeasurable (condExpL2 E' 𝕜 hm f)) variable {𝕜 𝕜'} section CondexpL2Indicator variable (𝕜) theorem condExpL2_indicator_ae_eq_smul (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E') : condExpL2 E' 𝕜 hm (indicatorConstLp 2 hs hμs x) =ᵐ[μ] fun a => (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs (1 : ℝ)) : α → ℝ) a • x := by rw [indicatorConstLp_eq_toSpanSingleton_compLp hs hμs x] have h_comp := condExpL2_comp_continuousLinearMap ℝ 𝕜 hm (toSpanSingleton ℝ x) (indicatorConstLp 2 hs hμs (1 : ℝ)) refine h_comp.trans ?_ exact (toSpanSingleton ℝ x).coeFn_compLp _ theorem condExpL2_indicator_eq_toSpanSingleton_comp (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E') : (condExpL2 E' 𝕜 hm (indicatorConstLp 2 hs hμs x) : α →₂[μ] E') = (toSpanSingleton ℝ x).compLp (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1)) := by ext1 refine (condExpL2_indicator_ae_eq_smul 𝕜 hm hs hμs x).trans ?_ have h_comp := (toSpanSingleton ℝ x).coeFn_compLp (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α →₂[μ] ℝ) rw [← EventuallyEq] at h_comp refine EventuallyEq.trans ?_ h_comp.symm filter_upwards with y using rfl variable {𝕜} theorem setLIntegral_nnnorm_condExpL2_indicator_le (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E') {t : Set α} (ht : MeasurableSet[m] t) (hμt : μ t ≠ ∞) : ∫⁻ a in t, ‖(condExpL2 E' 𝕜 hm (indicatorConstLp 2 hs hμs x) : α → E') a‖₊ ∂μ ≤ μ (s ∩ t) * ‖x‖₊ := calc ∫⁻ a in t, ‖(condExpL2 E' 𝕜 hm (indicatorConstLp 2 hs hμs x) : α → E') a‖₊ ∂μ = ∫⁻ a in t, ‖(condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) a • x‖₊ ∂μ := setLIntegral_congr_fun_ae (hm t ht) ((condExpL2_indicator_ae_eq_smul 𝕜 hm hs hμs x).mono fun a ha _ => by rw [ha]) _ = (∫⁻ a in t, ‖(condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) a‖₊ ∂μ) * ‖x‖₊ := by simp_rw [nnnorm_smul, ENNReal.coe_mul] rw [lintegral_mul_const] exact (Lp.stronglyMeasurable _).enorm (ε := ℝ) _ ≤ μ (s ∩ t) * ‖x‖₊ := by grw [lintegral_nnnorm_condExpL2_indicator_le_real hs hμs ht hμt] theorem lintegral_nnnorm_condExpL2_indicator_le (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E') [SigmaFinite (μ.trim hm)] : ∫⁻ a, ‖(condExpL2 E' 𝕜 hm (indicatorConstLp 2 hs hμs x) : α → E') a‖₊ ∂μ ≤ μ s * ‖x‖₊ := by refine lintegral_le_of_forall_fin_meas_trim_le hm (μ s * ‖x‖₊) fun t ht hμt => ?_ refine (setLIntegral_nnnorm_condExpL2_indicator_le hm hs hμs x ht hμt).trans ?_ gcongr apply Set.inter_subset_left /-- If the measure `μ.trim hm` is sigma-finite, then the conditional expectation of a measurable set with finite measure is integrable. -/ theorem integrable_condExpL2_indicator (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E') : Integrable (ε := E') (condExpL2 E' 𝕜 hm (indicatorConstLp 2 hs hμs x)) μ := by refine integrable_of_forall_fin_meas_le' hm (μ s * ‖x‖₊) (ENNReal.mul_lt_top hμs.lt_top ENNReal.coe_lt_top) ?_ ?_ · exact Lp.aestronglyMeasurable _ · refine fun t ht hμt => (setLIntegral_nnnorm_condExpL2_indicator_le hm hs hμs x ht hμt).trans ?_ gcongr apply Set.inter_subset_left end CondexpL2Indicator section CondexpIndSMul variable [NormedSpace ℝ G] {hm : m ≤ m0} /-- Conditional expectation of the indicator of a measurable set with finite measure, in L2. -/ noncomputable def condExpIndSMul (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : Lp G 2 μ := (toSpanSingleton ℝ x).compLpL 2 μ (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs (1 : ℝ))) theorem aestronglyMeasurable_condExpIndSMul (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : AEStronglyMeasurable[m] (condExpIndSMul hm hs hμs x) μ := by have h : AEStronglyMeasurable[m] (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) μ := aestronglyMeasurable_condExpL2 _ _ rw [condExpIndSMul] exact ((toSpanSingleton ℝ x).continuous.comp_aestronglyMeasurable h).congr (coeFn_compLpL _ _).symm theorem condExpIndSMul_add (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x y : G) : condExpIndSMul hm hs hμs (x + y) = condExpIndSMul hm hs hμs x + condExpIndSMul hm hs hμs y := by simp_rw [condExpIndSMul]; rw [toSpanSingleton_add, add_compLpL, add_apply] theorem condExpIndSMul_smul [NormedSpace ℝ F] [SMulCommClass ℝ 𝕜 F] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : 𝕜) (x : F) : condExpIndSMul hm hs hμs (c • x) = c • condExpIndSMul hm hs hμs x := by simp_rw [condExpIndSMul, toSpanSingleton_smul, smul_compLpL, smul_apply] @[deprecated (since := "2025-08-28")] alias condExpIndSMul_smul' := condExpIndSMul_smul theorem condExpIndSMul_ae_eq_smul (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : condExpIndSMul hm hs hμs x =ᵐ[μ] fun a => (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) a • x := (toSpanSingleton ℝ x).coeFn_compLpL _ theorem setLIntegral_nnnorm_condExpIndSMul_le (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) {t : Set α} (ht : MeasurableSet[m] t) (hμt : μ t ≠ ∞) : (∫⁻ a in t, ‖condExpIndSMul hm hs hμs x a‖₊ ∂μ) ≤ μ (s ∩ t) * ‖x‖₊ := calc ∫⁻ a in t, ‖condExpIndSMul hm hs hμs x a‖₊ ∂μ = ∫⁻ a in t, ‖(condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) a • x‖₊ ∂μ := setLIntegral_congr_fun_ae (hm t ht) ((condExpIndSMul_ae_eq_smul hm hs hμs x).mono fun a ha _ => by rw [ha]) _ = (∫⁻ a in t, ‖(condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) a‖₊ ∂μ) * ‖x‖₊ := by simp_rw [nnnorm_smul, ENNReal.coe_mul] rw [lintegral_mul_const] exact (Lp.stronglyMeasurable _).enorm (ε := ℝ) _ ≤ μ (s ∩ t) * ‖x‖₊ := by grw [lintegral_nnnorm_condExpL2_indicator_le_real hs hμs ht hμt] theorem lintegral_nnnorm_condExpIndSMul_le (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) [SigmaFinite (μ.trim hm)] : ∫⁻ a, ‖condExpIndSMul hm hs hμs x a‖₊ ∂μ ≤ μ s * ‖x‖₊ := by refine lintegral_le_of_forall_fin_meas_trim_le hm (μ s * ‖x‖₊) fun t ht hμt => ?_ refine (setLIntegral_nnnorm_condExpIndSMul_le hm hs hμs x ht hμt).trans ?_ gcongr apply Set.inter_subset_left /-- If the measure `μ.trim hm` is sigma-finite, then the conditional expectation of a measurable set with finite measure is integrable. -/ theorem integrable_condExpIndSMul (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : G) : Integrable (condExpIndSMul hm hs hμs x) μ := by refine integrable_of_forall_fin_meas_le' hm (μ s * ‖x‖₊) (ENNReal.mul_lt_top hμs.lt_top ENNReal.coe_lt_top) ?_ ?_ · exact Lp.aestronglyMeasurable _ · refine fun t ht hμt => (setLIntegral_nnnorm_condExpIndSMul_le hm hs hμs x ht hμt).trans ?_ gcongr apply Set.inter_subset_left theorem condExpIndSMul_empty {x : G} : condExpIndSMul hm MeasurableSet.empty ((measure_empty (μ := μ)).le.trans_lt ENNReal.coe_lt_top).ne x = 0 := by rw [condExpIndSMul, indicatorConstLp_empty] simp only [Submodule.coe_zero, ContinuousLinearMap.map_zero] theorem setIntegral_condExpL2_indicator (hs : MeasurableSet[m] s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) : ∫ x in s, (condExpL2 ℝ ℝ hm (indicatorConstLp 2 ht hμt 1) : α → ℝ) x ∂μ = μ.real (t ∩ s) := calc ∫ x in s, (condExpL2 ℝ ℝ hm (indicatorConstLp 2 ht hμt 1) : α → ℝ) x ∂μ = ∫ x in s, indicatorConstLp 2 ht hμt (1 : ℝ) x ∂μ := @integral_condExpL2_eq α _ ℝ _ _ _ _ _ _ _ _ _ hm (indicatorConstLp 2 ht hμt (1 : ℝ)) hs hμs _ = μ.real (t ∩ s) • (1 : ℝ) := setIntegral_indicatorConstLp (hm s hs) ht hμt 1 _ = μ.real (t ∩ s) := by rw [smul_eq_mul, mul_one] theorem setIntegral_condExpIndSMul (hs : MeasurableSet[m] s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) (x : G') : ∫ a in s, (condExpIndSMul hm ht hμt x) a ∂μ = μ.real (t ∩ s) • x := calc ∫ a in s, (condExpIndSMul hm ht hμt x) a ∂μ = ∫ a in s, (condExpL2 ℝ ℝ hm (indicatorConstLp 2 ht hμt 1) : α → ℝ) a • x ∂μ := setIntegral_congr_ae (hm s hs) ((condExpIndSMul_ae_eq_smul hm ht hμt x).mono fun _ hx _ => hx) _ = (∫ a in s, (condExpL2 ℝ ℝ hm (indicatorConstLp 2 ht hμt 1) : α → ℝ) a ∂μ) • x := (integral_smul_const _ x) _ = μ.real (t ∩ s) • x := by rw [setIntegral_condExpL2_indicator hs ht hμs hμt] theorem condExpL2_indicator_nonneg (hm : m ≤ m0) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) [SigmaFinite (μ.trim hm)] : (0 : α → ℝ) ≤ᵐ[μ] condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) := by have h : AEStronglyMeasurable[m] (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) μ := aestronglyMeasurable_condExpL2 _ _ refine EventuallyLE.trans_eq ?_ h.ae_eq_mk.symm refine @ae_le_of_ae_le_trim _ _ _ _ _ _ hm (0 : α → ℝ) _ ?_ refine ae_nonneg_of_forall_setIntegral_nonneg_of_sigmaFinite ?_ ?_ · rintro t - - refine @Integrable.integrableOn _ _ m _ _ _ _ _ ?_ refine Integrable.trim hm ?_ h.stronglyMeasurable_mk rw [integrable_congr h.ae_eq_mk.symm] exact integrable_condExpL2_indicator hm hs hμs _ · intro t ht hμt rw [← setIntegral_trim hm h.stronglyMeasurable_mk ht] have h_ae : ∀ᵐ x ∂μ, x ∈ t → h.mk _ x = (condExpL2 ℝ ℝ hm (indicatorConstLp 2 hs hμs 1) : α → ℝ) x := by filter_upwards [h.ae_eq_mk] with x hx using fun _ => hx.symm rw [setIntegral_congr_ae (hm t ht) h_ae, setIntegral_condExpL2_indicator ht hs ((le_trim hm).trans_lt hμt).ne hμs] exact ENNReal.toReal_nonneg theorem condExpIndSMul_nonneg {E} [NormedAddCommGroup E] [PartialOrder E] [NormedSpace ℝ E] [IsOrderedModule ℝ E] [SigmaFinite (μ.trim hm)] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) (hx : 0 ≤ x) : (0 : α → E) ≤ᵐ[μ] condExpIndSMul hm hs hμs x := by refine EventuallyLE.trans_eq ?_ (condExpIndSMul_ae_eq_smul hm hs hμs x).symm filter_upwards [condExpL2_indicator_nonneg hm hs hμs] with a ha exact smul_nonneg ha hx end CondexpIndSMul end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/ConditionalExpectation/Real.lean
import Mathlib.MeasureTheory.Function.ConditionalExpectation.Indicator import Mathlib.MeasureTheory.Function.UniformIntegrable import Mathlib.MeasureTheory.VectorMeasure.Decomposition.RadonNikodym /-! # Conditional expectation of real-valued functions This file proves some results regarding the conditional expectation of real-valued functions. ## Main results * `MeasureTheory.rnDeriv_ae_eq_condExp`: the conditional expectation `μ[f | m]` is equal to the Radon-Nikodym derivative of `fμ` restricted on `m` with respect to `μ` restricted on `m`. * `MeasureTheory.Integrable.uniformIntegrable_condExp`: the conditional expectation of a function form a uniformly integrable class. * `MeasureTheory.condExp_mul_of_stronglyMeasurable_left`: the pull-out property of the conditional expectation. -/ noncomputable section open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap open scoped NNReal ENNReal Topology MeasureTheory namespace MeasureTheory variable {α : Type*} {m m0 : MeasurableSpace α} {μ : Measure α} theorem rnDeriv_ae_eq_condExp {hm : m ≤ m0} [hμm : SigmaFinite (μ.trim hm)] {f : α → ℝ} (hf : Integrable f μ) : SignedMeasure.rnDeriv ((μ.withDensityᵥ f).trim hm) (μ.trim hm) =ᵐ[μ] μ[f|m] := by refine ae_eq_condExp_of_forall_setIntegral_eq hm hf ?_ ?_ ?_ · exact fun _ _ _ => (integrable_of_integrable_trim hm (SignedMeasure.integrable_rnDeriv ((μ.withDensityᵥ f).trim hm) (μ.trim hm))).integrableOn · intro s hs _ conv_rhs => rw [← hf.withDensityᵥ_trim_eq_integral hm hs, ← SignedMeasure.withDensityᵥ_rnDeriv_eq ((μ.withDensityᵥ f).trim hm) (μ.trim hm) (hf.withDensityᵥ_trim_absolutelyContinuous hm)] rw [withDensityᵥ_apply (SignedMeasure.integrable_rnDeriv ((μ.withDensityᵥ f).trim hm) (μ.trim hm)) hs, ← setIntegral_trim hm _ hs] exact (SignedMeasure.measurable_rnDeriv _ _).stronglyMeasurable · exact (SignedMeasure.measurable_rnDeriv _ _).stronglyMeasurable.aestronglyMeasurable -- TODO: the following couple of lemmas should be generalized and proved using Jensen's inequality -- for the conditional expectation (not in mathlib yet) . theorem eLpNorm_one_condExp_le_eLpNorm (f : α → ℝ) : eLpNorm (μ[f|m]) 1 μ ≤ eLpNorm f 1 μ := by by_cases hf : Integrable f μ swap; · rw [condExp_of_not_integrable hf, eLpNorm_zero]; exact zero_le _ by_cases hm : m ≤ m0 swap; · rw [condExp_of_not_le hm, eLpNorm_zero]; exact zero_le _ by_cases hsig : SigmaFinite (μ.trim hm) swap; · rw [condExp_of_not_sigmaFinite hm hsig, eLpNorm_zero]; exact zero_le _ calc eLpNorm (μ[f|m]) 1 μ ≤ eLpNorm (μ[(|f|)|m]) 1 μ := by refine eLpNorm_mono_ae ?_ filter_upwards [condExp_mono hf hf.abs (ae_of_all μ (fun x => le_abs_self (f x) : ∀ x, f x ≤ |f x|)), (condExp_neg ..).symm.le.trans (condExp_mono hf.neg hf.abs (ae_of_all μ (fun x => neg_le_abs (f x) : ∀ x, -f x ≤ |f x|)))] with x hx₁ hx₂ exact abs_le_abs hx₁ hx₂ _ = eLpNorm f 1 μ := by rw [eLpNorm_one_eq_lintegral_enorm, eLpNorm_one_eq_lintegral_enorm, ← ENNReal.toReal_eq_toReal_iff' (hasFiniteIntegral_iff_enorm.mp integrable_condExp.2).ne (hasFiniteIntegral_iff_enorm.mp hf.2).ne, ← integral_norm_eq_lintegral_enorm (stronglyMeasurable_condExp.mono hm).aestronglyMeasurable, ← integral_norm_eq_lintegral_enorm hf.1] simp_rw [Real.norm_eq_abs] rw (config := {occs := .pos [2]}) [← integral_condExp hm] refine integral_congr_ae ?_ have : 0 ≤ᵐ[μ] μ[(|f|)|m] := by rw [← condExp_zero] exact condExp_mono (integrable_zero _ _ _) hf.abs (ae_of_all μ (fun x => abs_nonneg (f x) : ∀ x, 0 ≤ |f x|)) filter_upwards [this] with x hx exact abs_eq_self.2 hx theorem integral_abs_condExp_le (f : α → ℝ) : ∫ x, |(μ[f|m]) x| ∂μ ≤ ∫ x, |f x| ∂μ := by by_cases hm : m ≤ m0 swap · simp_rw [condExp_of_not_le hm, Pi.zero_apply, abs_zero, integral_zero] positivity by_cases hfint : Integrable f μ swap · simp only [condExp_of_not_integrable hfint, Pi.zero_apply, abs_zero, integral_const, Algebra.id.smul_eq_mul, mul_zero] positivity rw [integral_eq_lintegral_of_nonneg_ae, integral_eq_lintegral_of_nonneg_ae] · apply ENNReal.toReal_mono <;> simp_rw [← Real.norm_eq_abs, ofReal_norm_eq_enorm] · exact hfint.2.ne · rw [← eLpNorm_one_eq_lintegral_enorm, ← eLpNorm_one_eq_lintegral_enorm] exact eLpNorm_one_condExp_le_eLpNorm _ · filter_upwards with x using abs_nonneg _ · simp_rw [← Real.norm_eq_abs] exact hfint.1.norm · filter_upwards with x using abs_nonneg _ · simp_rw [← Real.norm_eq_abs] exact (stronglyMeasurable_condExp.mono hm).aestronglyMeasurable.norm theorem setIntegral_abs_condExp_le {s : Set α} (hs : MeasurableSet[m] s) (f : α → ℝ) : ∫ x in s, |(μ[f|m]) x| ∂μ ≤ ∫ x in s, |f x| ∂μ := by by_cases hnm : m ≤ m0 swap · simp_rw [condExp_of_not_le hnm, Pi.zero_apply, abs_zero, integral_zero] positivity by_cases hfint : Integrable f μ swap · simp only [condExp_of_not_integrable hfint, Pi.zero_apply, abs_zero, integral_const, Algebra.id.smul_eq_mul, mul_zero] positivity have : ∫ x in s, |(μ[f|m]) x| ∂μ = ∫ x, |(μ[s.indicator f|m]) x| ∂μ := by rw [← integral_indicator (hnm _ hs)] refine integral_congr_ae ?_ have : (fun x => |(μ[s.indicator f|m]) x|) =ᵐ[μ] fun x => |s.indicator (μ[f|m]) x| := (condExp_indicator hfint hs).fun_comp abs refine EventuallyEq.trans (Eventually.of_forall fun x => ?_) this.symm rw [← Real.norm_eq_abs, norm_indicator_eq_indicator_norm] simp only [Real.norm_eq_abs] rw [this, ← integral_indicator (hnm _ hs)] refine (integral_abs_condExp_le _).trans (le_of_eq <| integral_congr_ae <| Eventually.of_forall fun x => ?_) simp_rw [← Real.norm_eq_abs, norm_indicator_eq_indicator_norm] /-- If the real-valued function `f` is bounded almost everywhere by `R`, then so is its conditional expectation. -/ theorem ae_bdd_condExp_of_ae_bdd {R : ℝ≥0} {f : α → ℝ} (hbdd : ∀ᵐ x ∂μ, |f x| ≤ R) : ∀ᵐ x ∂μ, |(μ[f|m]) x| ≤ R := by by_cases hnm : m ≤ m0 swap · simp_rw [condExp_of_not_le hnm, Pi.zero_apply, abs_zero] exact Eventually.of_forall fun _ => R.coe_nonneg by_cases hfint : Integrable f μ swap · simp_rw [condExp_of_not_integrable hfint] filter_upwards [hbdd] with x hx rw [Pi.zero_apply, abs_zero] exact (abs_nonneg _).trans hx by_contra h change μ _ ≠ 0 at h simp only [← zero_lt_iff, Set.compl_def, Set.mem_setOf_eq, not_le] at h suffices μ.real {x | ↑R < |(μ[f|m]) x|} * ↑R < μ.real {x | ↑R < |(μ[f|m]) x|} * ↑R by exact this.ne rfl refine lt_of_lt_of_le (setIntegral_gt_gt R.coe_nonneg ?_ h.ne') ?_ · exact integrable_condExp.abs.integrableOn refine (setIntegral_abs_condExp_le ?_ _).trans ?_ · simp_rw [← Real.norm_eq_abs] exact @measurableSet_lt _ _ _ _ _ m _ _ _ _ _ measurable_const stronglyMeasurable_condExp.norm.measurable simp only [← smul_eq_mul, ← setIntegral_const] refine setIntegral_mono_ae hfint.abs.integrableOn ?_ hbdd refine ⟨aestronglyMeasurable_const, lt_of_le_of_lt ?_ (integrable_condExp.integrableOn : IntegrableOn (μ[f|m]) {x | ↑R < |(μ[f|m]) x|} μ).2⟩ refine setLIntegral_mono (stronglyMeasurable_condExp.mono hnm).measurable.nnnorm.coe_nnreal_ennreal fun x hx => ?_ rw [enorm_eq_nnnorm, enorm_eq_nnnorm, ENNReal.coe_le_coe, Real.nnnorm_of_nonneg R.coe_nonneg] exact Subtype.mk_le_mk.2 (le_of_lt hx) /-- Given an integrable function `g`, the conditional expectations of `g` with respect to a sequence of sub-σ-algebras is uniformly integrable. -/ theorem Integrable.uniformIntegrable_condExp {ι : Type*} [IsFiniteMeasure μ] {g : α → ℝ} (hint : Integrable g μ) {ℱ : ι → MeasurableSpace α} (hℱ : ∀ i, ℱ i ≤ m0) : UniformIntegrable (fun i => μ[g|ℱ i]) 1 μ := by let A : MeasurableSpace α := m0 have hmeas : ∀ n, ∀ C, MeasurableSet {x | C ≤ ‖(μ[g|ℱ n]) x‖₊} := fun n C => measurableSet_le measurable_const (stronglyMeasurable_condExp.mono (hℱ n)).measurable.nnnorm have hg : MemLp g 1 μ := memLp_one_iff_integrable.2 hint refine uniformIntegrable_of le_rfl ENNReal.one_ne_top (fun n => (stronglyMeasurable_condExp.mono (hℱ n)).aestronglyMeasurable) fun ε hε => ?_ by_cases hne : eLpNorm g 1 μ = 0 · rw [eLpNorm_eq_zero_iff hg.1 one_ne_zero] at hne refine ⟨0, fun n => (le_of_eq <| (eLpNorm_eq_zero_iff ((stronglyMeasurable_condExp.mono (hℱ n)).aestronglyMeasurable.indicator (hmeas n 0)) one_ne_zero).2 ?_).trans (zero_le _)⟩ filter_upwards [condExp_congr_ae (m := ℱ n) hne] with x hx simp only [zero_le', Set.setOf_true, Set.indicator_univ, Pi.zero_apply, hx, condExp_zero] obtain ⟨δ, hδ, h⟩ := hg.eLpNorm_indicator_le le_rfl ENNReal.one_ne_top hε set C : ℝ≥0 := ⟨δ, hδ.le⟩⁻¹ * (eLpNorm g 1 μ).toNNReal with hC have hCpos : 0 < C := mul_pos (inv_pos.2 hδ) (ENNReal.toNNReal_pos hne hg.eLpNorm_lt_top.ne) have : ∀ n, μ {x : α | C ≤ ‖(μ[g|ℱ n]) x‖₊} ≤ ENNReal.ofReal δ := by intro n have : C ^ ENNReal.toReal 1 * μ {x | ENNReal.ofNNReal C ≤ ‖μ[g|ℱ n] x‖₊} ≤ eLpNorm μ[g|ℱ n] 1 μ ^ ENNReal.toReal 1 := by rw [ENNReal.toReal_one, ENNReal.rpow_one] convert mul_meas_ge_le_pow_eLpNorm μ one_ne_zero ENNReal.one_ne_top (stronglyMeasurable_condExp.mono (hℱ n)).aestronglyMeasurable C · rw [ENNReal.toReal_one, ENNReal.rpow_one, enorm_eq_nnnorm] rw [ENNReal.toReal_one, ENNReal.rpow_one, mul_comm, ← ENNReal.le_div_iff_mul_le (Or.inl (ENNReal.coe_ne_zero.2 hCpos.ne')) (Or.inl ENNReal.coe_lt_top.ne)] at this simp_rw [ENNReal.coe_le_coe] at this refine this.trans ?_ rw [ENNReal.div_le_iff_le_mul (Or.inl (ENNReal.coe_ne_zero.2 hCpos.ne')) (Or.inl ENNReal.coe_lt_top.ne), hC, Nonneg.inv_mk, ENNReal.coe_mul, ENNReal.coe_toNNReal hg.eLpNorm_lt_top.ne, ← mul_assoc, ← ENNReal.ofReal_eq_coe_nnreal, ← ENNReal.ofReal_mul hδ.le, mul_inv_cancel₀ hδ.ne', ENNReal.ofReal_one, one_mul, ENNReal.rpow_one] exact eLpNorm_one_condExp_le_eLpNorm _ refine ⟨C, fun n => le_trans ?_ (h {x : α | C ≤ ‖(μ[g|ℱ n]) x‖₊} (hmeas n C) (this n))⟩ have hmeasℱ : MeasurableSet[ℱ n] {x : α | C ≤ ‖(μ[g|ℱ n]) x‖₊} := @measurableSet_le _ _ _ _ _ (ℱ n) _ _ _ _ _ measurable_const (@Measurable.nnnorm _ _ _ _ _ (ℱ n) _ stronglyMeasurable_condExp.measurable) rw [← eLpNorm_congr_ae (condExp_indicator hint hmeasℱ)] exact eLpNorm_one_condExp_le_eLpNorm _ section PullOut -- TODO: this section could be generalized beyond multiplication, to any bounded bilinear map. /-- Auxiliary lemma for `condExp_mul_of_stronglyMeasurable_left`. -/ theorem condExp_stronglyMeasurable_simpleFunc_mul (hm : m ≤ m0) (f : @SimpleFunc α m ℝ) {g : α → ℝ} (hg : Integrable g μ) : μ[(f * g : α → ℝ)|m] =ᵐ[μ] f * μ[g|m] := by have : ∀ (s c) (f : α → ℝ), Set.indicator s (Function.const α c) * f = s.indicator (c • f) := by intro s c f ext1 x by_cases hx : x ∈ s · simp only [hx, Pi.mul_apply, Set.indicator_of_mem, Pi.smul_apply, Algebra.id.smul_eq_mul, Function.const_apply] · simp only [hx, Pi.mul_apply, Set.indicator_of_notMem, not_false_iff, zero_mul] apply @SimpleFunc.induction _ _ m _ (fun f => _) (fun c s hs => ?_) (fun g₁ g₂ _ h_eq₁ h_eq₂ => ?_) f · simp only [SimpleFunc.const_zero, SimpleFunc.coe_piecewise, SimpleFunc.coe_const, SimpleFunc.coe_zero, Set.piecewise_eq_indicator] rw [this, this] refine (condExp_indicator (hg.smul c) hs).trans ?_ filter_upwards [condExp_smul c g m] with x hx classical simp_rw [Set.indicator_apply, hx] · have h_add := @SimpleFunc.coe_add _ _ m _ g₁ g₂ calc μ[⇑(g₁ + g₂) * g|m] =ᵐ[μ] μ[⇑g₁ * g|m] + μ[⇑g₂ * g|m] := by rw [h_add, add_mul]; exact condExp_add (hg.simpleFunc_mul' hm _) (hg.simpleFunc_mul' hm _) _ _ =ᵐ[μ] ⇑g₁ * μ[g|m] + ⇑g₂ * μ[g|m] := EventuallyEq.add h_eq₁ h_eq₂ _ =ᵐ[μ] ⇑(g₁ + g₂) * μ[g|m] := by rw [h_add, add_mul] theorem condExp_stronglyMeasurable_mul_of_bound (hm : m ≤ m0) [IsFiniteMeasure μ] {f g : α → ℝ} (hf : StronglyMeasurable[m] f) (hg : Integrable g μ) (c : ℝ) (hf_bound : ∀ᵐ x ∂μ, ‖f x‖ ≤ c) : μ[f * g|m] =ᵐ[μ] f * μ[g|m] := by let fs := hf.approxBounded c have hfs_tendsto : ∀ᵐ x ∂μ, Tendsto (fs · x) atTop (𝓝 (f x)) := hf.tendsto_approxBounded_ae hf_bound by_cases hμ : μ = 0 · simp only [hμ, ae_zero]; norm_cast have : (ae μ).NeBot := ae_neBot.2 hμ have hc : 0 ≤ c := by rcases hf_bound.exists with ⟨_x, hx⟩ exact (norm_nonneg _).trans hx have hfs_bound : ∀ n x, ‖fs n x‖ ≤ c := hf.norm_approxBounded_le hc have : μ[f * μ[g|m]|m] = f * μ[g|m] := by refine condExp_of_stronglyMeasurable hm (hf.mul stronglyMeasurable_condExp) ?_ exact integrable_condExp.bdd_mul' (hf.mono hm).aestronglyMeasurable hf_bound rw [← this] refine tendsto_condExp_unique (fun n x => fs n x * g x) (fun n x => fs n x * (μ[g|m]) x) (f * g) (f * μ[g|m]) ?_ ?_ ?_ ?_ (c * ‖g ·‖) ?_ (c * ‖(μ[g|m]) ·‖) ?_ ?_ ?_ ?_ · exact fun n => hg.bdd_mul' ((SimpleFunc.stronglyMeasurable (fs n)).mono hm).aestronglyMeasurable (Eventually.of_forall (hfs_bound n)) · exact fun n => integrable_condExp.bdd_mul' ((SimpleFunc.stronglyMeasurable (fs n)).mono hm).aestronglyMeasurable (Eventually.of_forall (hfs_bound n)) · filter_upwards [hfs_tendsto] with x hx exact hx.mul tendsto_const_nhds · filter_upwards [hfs_tendsto] with x hx exact hx.mul tendsto_const_nhds · exact hg.norm.const_mul c · fun_prop · refine fun n => Eventually.of_forall fun x => ?_ exact (norm_mul_le _ _).trans (mul_le_mul_of_nonneg_right (hfs_bound n x) (norm_nonneg _)) · refine fun n => Eventually.of_forall fun x => ?_ exact (norm_mul_le _ _).trans (mul_le_mul_of_nonneg_right (hfs_bound n x) (norm_nonneg _)) · intro n simp_rw [← Pi.mul_apply] refine (condExp_stronglyMeasurable_simpleFunc_mul hm _ hg).trans ?_ rw [condExp_of_stronglyMeasurable hm ((SimpleFunc.stronglyMeasurable _).mul stronglyMeasurable_condExp) _] exact integrable_condExp.bdd_mul' ((SimpleFunc.stronglyMeasurable (fs n)).mono hm).aestronglyMeasurable (Eventually.of_forall (hfs_bound n)) theorem condExp_stronglyMeasurable_mul_of_bound₀ (hm : m ≤ m0) [IsFiniteMeasure μ] {f g : α → ℝ} (hf : AEStronglyMeasurable[m] f μ) (hg : Integrable g μ) (c : ℝ) (hf_bound : ∀ᵐ x ∂μ, ‖f x‖ ≤ c) : μ[f * g|m] =ᵐ[μ] f * μ[g|m] := by grw [hf.ae_eq_mk] refine condExp_stronglyMeasurable_mul_of_bound hm hf.stronglyMeasurable_mk hg c ?_ filter_upwards [hf_bound, hf.ae_eq_mk] with x hxc hx_eq rwa [← hx_eq] /-- Pull-out property of the conditional expectation. -/ theorem condExp_mul_of_stronglyMeasurable_left {f g : α → ℝ} (hf : StronglyMeasurable[m] f) (hfg : Integrable (f * g) μ) (hg : Integrable g μ) : μ[f * g|m] =ᵐ[μ] f * μ[g|m] := by by_cases hm : m ≤ m0; swap; · simp_rw [condExp_of_not_le hm]; rw [mul_zero] by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condExp_of_not_sigmaFinite hm hμm]; rw [mul_zero] haveI : SigmaFinite (μ.trim hm) := hμm obtain ⟨sets, sets_prop, h_univ⟩ := hf.exists_spanning_measurableSet_norm_le hm μ simp_rw [forall_and] at sets_prop obtain ⟨h_meas, h_finite, h_norm⟩ := sets_prop suffices ∀ n, ∀ᵐ x ∂μ, x ∈ sets n → (μ[f * g|m]) x = f x * (μ[g|m]) x by rw [← ae_all_iff] at this filter_upwards [this] with x hx obtain ⟨i, hi⟩ : ∃ i, x ∈ sets i := by have h_mem : x ∈ ⋃ i, sets i := by rw [h_univ]; exact Set.mem_univ _ simpa using h_mem exact hx i hi refine fun n => ae_imp_of_ae_restrict ?_ suffices (μ.restrict (sets n))[f * g|m] =ᵐ[μ.restrict (sets n)] f * (μ.restrict (sets n))[g|m] by refine (condExp_restrict_ae_eq_restrict hm (h_meas n) hfg).symm.trans ?_ exact this.trans (EventuallyEq.rfl.mul (condExp_restrict_ae_eq_restrict hm (h_meas n) hg)) suffices (μ.restrict (sets n))[(sets n).indicator f * g|m] =ᵐ[μ.restrict (sets n)] (sets n).indicator f * (μ.restrict (sets n))[g|m] by refine EventuallyEq.trans ?_ (this.trans ?_) · exact condExp_congr_ae ((indicator_ae_eq_restrict <| hm _ <| h_meas n).symm.mul EventuallyEq.rfl) · exact (indicator_ae_eq_restrict <| hm _ <| h_meas n).mul EventuallyEq.rfl have : IsFiniteMeasure (μ.restrict (sets n)) := by constructor rw [Measure.restrict_apply_univ] exact h_finite n refine condExp_stronglyMeasurable_mul_of_bound hm (hf.indicator (h_meas n)) hg.integrableOn n ?_ filter_upwards with x by_cases hxs : x ∈ sets n · simpa only [hxs, Set.indicator_of_mem] using h_norm n x hxs · simp only [hxs, Set.indicator_of_notMem, not_false_iff, _root_.norm_zero, Nat.cast_nonneg] /-- Pull-out property of the conditional expectation. -/ lemma condExp_mul_of_stronglyMeasurable_right {f g : α → ℝ} (hg : StronglyMeasurable[m] g) (hfg : Integrable (f * g) μ) (hf : Integrable f μ) : μ[f * g | m] =ᵐ[μ] μ[f | m] * g := by simpa [mul_comm] using condExp_mul_of_stronglyMeasurable_left hg (mul_comm f g ▸ hfg) hf /-- Pull-out property of the conditional expectation. -/ theorem condExp_mul_of_aestronglyMeasurable_left {f g : α → ℝ} (hf : AEStronglyMeasurable[m] f μ) (hfg : Integrable (f * g) μ) (hg : Integrable g μ) : μ[f * g|m] =ᵐ[μ] f * μ[g|m] := by have : μ[f * g|m] =ᵐ[μ] μ[hf.mk f * g|m] := condExp_congr_ae (hf.ae_eq_mk.mul EventuallyEq.rfl) refine this.trans ?_ have : f * μ[g|m] =ᵐ[μ] hf.mk f * μ[g|m] := hf.ae_eq_mk.mul EventuallyEq.rfl refine (condExp_mul_of_stronglyMeasurable_left hf.stronglyMeasurable_mk ?_ hg).trans this.symm refine (integrable_congr ?_).mp hfg exact hf.ae_eq_mk.mul EventuallyEq.rfl /-- Pull-out property of the conditional expectation. -/ lemma condExp_mul_of_aestronglyMeasurable_right {f g : α → ℝ} (hg : AEStronglyMeasurable[m] g μ) (hfg : Integrable (f * g) μ) (hf : Integrable f μ) : μ[f * g | m] =ᵐ[μ] μ[f | m] * g := by simpa [mul_comm] using condExp_mul_of_aestronglyMeasurable_left hg (mul_comm f g ▸ hfg) hf end PullOut end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/StronglyMeasurable/Lp.lean
import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lemmas /-! # Finitely strongly measurable functions in `Lp` Functions in `Lp` for `0 < p < ∞` are finitely strongly measurable. ## Main statements * `MemLp.aefinStronglyMeasurable`: if `MemLp f p μ` with `0 < p < ∞`, then `AEFinStronglyMeasurable f μ`. * `Lp.finStronglyMeasurable`: for `0 < p < ∞`, `Lp` functions are finitely strongly measurable. ## References * [Hytönen, Tuomas, Jan Van Neerven, Mark Veraar, and Lutz Weis. Analysis in Banach spaces. Springer, 2016.][Hytonen_VanNeerven_Veraar_Wies_2016] -/ open MeasureTheory Filter TopologicalSpace Function open scoped ENNReal Topology MeasureTheory namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc variable {α G : Type*} {p : ℝ≥0∞} {m m0 : MeasurableSpace α} {μ : Measure α} [NormedAddCommGroup G] {f : α → G} theorem MemLp.finStronglyMeasurable_of_stronglyMeasurable (hf : MemLp f p μ) (hf_meas : StronglyMeasurable f) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : FinStronglyMeasurable f μ := by borelize G haveI : SeparableSpace (Set.range f ∪ {0} : Set G) := hf_meas.separableSpace_range_union_singleton let fs := SimpleFunc.approxOn f hf_meas.measurable (Set.range f ∪ {0}) 0 (by simp) refine ⟨fs, ?_, ?_⟩ · have h_fs_Lp : ∀ n, MemLp (fs n) p μ := SimpleFunc.memLp_approxOn_range hf_meas.measurable hf exact fun n => (fs n).measure_support_lt_top_of_memLp (h_fs_Lp n) hp_ne_zero hp_ne_top · intro x apply SimpleFunc.tendsto_approxOn apply subset_closure simp theorem MemLp.aefinStronglyMeasurable (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : AEFinStronglyMeasurable f μ := ⟨hf.aestronglyMeasurable.mk f, ((memLp_congr_ae hf.aestronglyMeasurable.ae_eq_mk).mp hf).finStronglyMeasurable_of_stronglyMeasurable hf.aestronglyMeasurable.stronglyMeasurable_mk hp_ne_zero hp_ne_top, hf.aestronglyMeasurable.ae_eq_mk⟩ theorem Integrable.aefinStronglyMeasurable (hf : Integrable f μ) : AEFinStronglyMeasurable f μ := (memLp_one_iff_integrable.mpr hf).aefinStronglyMeasurable one_ne_zero ENNReal.coe_ne_top theorem Lp.finStronglyMeasurable (f : Lp G p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : FinStronglyMeasurable f μ := (Lp.memLp f).finStronglyMeasurable_of_stronglyMeasurable (Lp.stronglyMeasurable f) hp_ne_zero hp_ne_top end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/StronglyMeasurable/Lemmas.lean
import Mathlib.Analysis.Normed.Operator.BoundedLinearMaps import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable import Mathlib.MeasureTheory.Measure.WithDensity import Mathlib.Topology.Algebra.Module.FiniteDimension /-! # Strongly measurable and finitely strongly measurable functions This file contains some further development of strongly measurable and finitely strongly measurable functions, started in `Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean`. ## References * [Hytönen, Tuomas, Jan Van Neerven, Mark Veraar, and Lutz Weis. Analysis in Banach spaces. Springer, 2016.][Hytonen_VanNeerven_Veraar_Wies_2016] -/ open MeasureTheory Filter Set ENNReal NNReal variable {α β γ : Type*} {m : MeasurableSpace α} {μ : Measure α} [TopologicalSpace β] [TopologicalSpace γ] {f g : α → β} @[fun_prop] lemma aestronglyMeasurable_dirac [MeasurableSingletonClass α] {a : α} {f : α → β} : AEStronglyMeasurable f (Measure.dirac a) := ⟨fun _ ↦ f a, stronglyMeasurable_const, ae_eq_dirac f⟩ theorem MeasureTheory.AEStronglyMeasurable.comp_measurePreserving {γ : Type*} {_ : MeasurableSpace γ} {_ : MeasurableSpace α} {f : γ → α} {μ : Measure γ} {ν : Measure α} (hg : AEStronglyMeasurable g ν) (hf : MeasurePreserving f μ ν) : AEStronglyMeasurable (g ∘ f) μ := hg.comp_quasiMeasurePreserving hf.quasiMeasurePreserving theorem MeasureTheory.MeasurePreserving.aestronglyMeasurable_comp_iff {β : Type*} {f : α → β} {mα : MeasurableSpace α} {μa : Measure α} {mβ : MeasurableSpace β} {μb : Measure β} (hf : MeasurePreserving f μa μb) (h₂ : MeasurableEmbedding f) {g : β → γ} : AEStronglyMeasurable (g ∘ f) μa ↔ AEStronglyMeasurable g μb := by rw [← hf.map_eq, h₂.aestronglyMeasurable_map_iff] section NormedSpace variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] theorem aestronglyMeasurable_smul_const_iff {f : α → 𝕜} {c : E} (hc : c ≠ 0) : AEStronglyMeasurable (fun x => f x • c) μ ↔ AEStronglyMeasurable f μ := (isClosedEmbedding_smul_left hc).isEmbedding.aestronglyMeasurable_comp_iff end NormedSpace section ContinuousLinearMapNontriviallyNormedField variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G] theorem StronglyMeasurable.apply_continuousLinearMap {_m : MeasurableSpace α} {φ : α → F →L[𝕜] E} (hφ : StronglyMeasurable φ) (v : F) : StronglyMeasurable fun a => φ a v := (ContinuousLinearMap.apply 𝕜 E v).continuous.comp_stronglyMeasurable hφ @[measurability] theorem MeasureTheory.AEStronglyMeasurable.apply_continuousLinearMap {φ : α → F →L[𝕜] E} (hφ : AEStronglyMeasurable φ μ) (v : F) : AEStronglyMeasurable (fun a => φ a v) μ := (ContinuousLinearMap.apply 𝕜 E v).continuous.comp_aestronglyMeasurable hφ theorem ContinuousLinearMap.aestronglyMeasurable_comp₂ (L : E →L[𝕜] F →L[𝕜] G) {f : α → E} {g : α → F} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : AEStronglyMeasurable (fun x => L (f x) (g x)) μ := L.continuous₂.comp_aestronglyMeasurable₂ hf hg end ContinuousLinearMapNontriviallyNormedField theorem aestronglyMeasurable_withDensity_iff {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : α → ℝ≥0} (hf : Measurable f) {g : α → E} : AEStronglyMeasurable g (μ.withDensity fun x => (f x : ℝ≥0∞)) ↔ AEStronglyMeasurable (fun x => (f x : ℝ) • g x) μ := by constructor · rintro ⟨g', g'meas, hg'⟩ have A : MeasurableSet { x : α | f x ≠ 0 } := (hf (measurableSet_singleton 0)).compl refine ⟨fun x => (f x : ℝ) • g' x, hf.coe_nnreal_real.stronglyMeasurable.smul g'meas, ?_⟩ apply @ae_of_ae_restrict_of_ae_restrict_compl _ _ _ { x | f x ≠ 0 } · rw [EventuallyEq, ae_withDensity_iff hf.coe_nnreal_ennreal] at hg' rw [ae_restrict_iff' A] filter_upwards [hg'] with a ha h'a have : (f a : ℝ≥0∞) ≠ 0 := by simpa only [Ne, ENNReal.coe_eq_zero] using h'a rw [ha this] · filter_upwards [ae_restrict_mem A.compl] with x hx simp only [Classical.not_not, mem_setOf_eq, mem_compl_iff] at hx simp [hx] · rintro ⟨g', g'meas, hg'⟩ refine ⟨fun x => (f x : ℝ)⁻¹ • g' x, hf.coe_nnreal_real.inv.stronglyMeasurable.smul g'meas, ?_⟩ rw [EventuallyEq, ae_withDensity_iff hf.coe_nnreal_ennreal] filter_upwards [hg'] with x hx h'x rw [← hx, smul_smul, inv_mul_cancel₀, one_smul] simp only [Ne, ENNReal.coe_eq_zero] at h'x simpa only [NNReal.coe_eq_zero, Ne] using h'x
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/StronglyMeasurable/ENNReal.lean
import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable import Mathlib.MeasureTheory.Integral.Lebesgue.Add /-! # Finitely strongly measurable functions with value in ENNReal A measurable function with finite Lebesgue integral can be approximated by simple functions whose support has finite measure. -/ open MeasureTheory open scoped ENNReal variable {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ℝ≥0∞} lemma ENNReal.finStronglyMeasurable_of_measurable (hf : ∫⁻ x, f x ∂μ ≠ ∞) (hf_meas : Measurable f) : FinStronglyMeasurable f μ := ⟨SimpleFunc.eapprox f, measure_support_eapprox_lt_top hf_meas hf, SimpleFunc.tendsto_eapprox hf_meas⟩ lemma ENNReal.aefinStronglyMeasurable_of_aemeasurable (hf : ∫⁻ x, f x ∂μ ≠ ∞) (hf_meas : AEMeasurable f μ) : AEFinStronglyMeasurable f μ := by refine ⟨hf_meas.mk f, ENNReal.finStronglyMeasurable_of_measurable ?_ hf_meas.measurable_mk, hf_meas.ae_eq_mk⟩ rwa [lintegral_congr_ae hf_meas.ae_eq_mk.symm]
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/StronglyMeasurable/Inner.lean
import Mathlib.Analysis.InnerProductSpace.Continuous import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable /-! # Inner products of strongly measurable functions are strongly measurable. -/ variable {α 𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] namespace MeasureTheory /-! ## Strongly measurable functions -/ local notation "⟪" x ", " y "⟫" => inner 𝕜 x y namespace StronglyMeasurable @[fun_prop] protected theorem inner {_ : MeasurableSpace α} {f g : α → E} (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable fun t => ⟪f t, g t⟫ := Continuous.comp_stronglyMeasurable continuous_inner (hf.prodMk hg) end StronglyMeasurable namespace AEStronglyMeasurable variable {m m₀ : MeasurableSpace α} {μ : Measure[m₀] α} {f g : α → E} {c : E} @[fun_prop] protected theorem re {f : α → 𝕜} (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (fun x => RCLike.re (f x)) μ := RCLike.continuous_re.comp_aestronglyMeasurable hf @[fun_prop] protected theorem im {f : α → 𝕜} (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (fun x => RCLike.im (f x)) μ := RCLike.continuous_im.comp_aestronglyMeasurable hf @[fun_prop] protected theorem inner {_ : MeasurableSpace α} {μ : Measure α} {f g : α → E} (hf : AEStronglyMeasurable[m] f μ) (hg : AEStronglyMeasurable[m] g μ) : AEStronglyMeasurable[m] (fun x => ⟪f x, g x⟫) μ := continuous_inner.comp_aestronglyMeasurable (hf.prodMk hg) @[fun_prop] lemma inner_const (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (⟪f ·, c⟫) μ := hf.inner aestronglyMeasurable_const @[fun_prop] lemma const_inner (hg : AEStronglyMeasurable[m] g μ) : AEStronglyMeasurable[m] (⟪c, g ·⟫) μ := aestronglyMeasurable_const.inner hg end AEStronglyMeasurable end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/StronglyMeasurable/Basic.lean
import Mathlib.Analysis.Normed.Module.Basic import Mathlib.MeasureTheory.Function.SimpleFuncDense /-! # Strongly measurable and finitely strongly measurable functions A function `f` is said to be strongly measurable if `f` is the sequential limit of simple functions. It is said to be finitely strongly measurable with respect to a measure `μ` if the supports of those simple functions have finite measure. If the target space has a second countable topology, strongly measurable and measurable are equivalent. If the measure is sigma-finite, strongly measurable and finitely strongly measurable are equivalent. The main property of finitely strongly measurable functions is `FinStronglyMeasurable.exists_set_sigmaFinite`: there exists a measurable set `t` such that the function is supported on `t` and `μ.restrict t` is sigma-finite. As a consequence, we can prove some results for those functions as if the measure was sigma-finite. We provide a solid API for strongly measurable functions, as a basis for the Bochner integral. ## Main definitions * `StronglyMeasurable f`: `f : α → β` is the limit of a sequence `fs : ℕ → SimpleFunc α β`. * `FinStronglyMeasurable f μ`: `f : α → β` is the limit of a sequence `fs : ℕ → SimpleFunc α β` such that for all `n ∈ ℕ`, the measure of the support of `fs n` is finite. ## References * [Hytönen, Tuomas, Jan Van Neerven, Mark Veraar, and Lutz Weis. Analysis in Banach spaces. Springer, 2016.][Hytonen_VanNeerven_Veraar_Wies_2016] -/ -- Guard against import creep assert_not_exists InnerProductSpace open MeasureTheory Filter TopologicalSpace Function Set MeasureTheory.Measure open ENNReal Topology MeasureTheory NNReal variable {α β γ ι : Type*} [Countable ι] namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc section Definitions variable [TopologicalSpace β] /-- A function is `StronglyMeasurable` if it is the limit of simple functions. -/ @[fun_prop] def StronglyMeasurable [MeasurableSpace α] (f : α → β) : Prop := ∃ fs : ℕ → α →ₛ β, ∀ x, Tendsto (fun n => fs n x) atTop (𝓝 (f x)) add_aesop_rules safe tactic (rule_sets := [Measurable]) (index := [target @StronglyMeasurable ..]) (by fun_prop (disch := measurability)) /-- The notation for StronglyMeasurable giving the measurable space instance explicitly. -/ scoped notation "StronglyMeasurable[" m "]" => @MeasureTheory.StronglyMeasurable _ _ _ m /-- A function is `FinStronglyMeasurable` with respect to a measure if it is the limit of simple functions with support with finite measure. -/ def FinStronglyMeasurable [Zero β] {_ : MeasurableSpace α} (f : α → β) (μ : Measure α := by volume_tac) : Prop := ∃ fs : ℕ → α →ₛ β, (∀ n, μ (support (fs n)) < ∞) ∧ ∀ x, Tendsto (fun n => fs n x) atTop (𝓝 (f x)) end Definitions open MeasureTheory /-! ## Strongly measurable functions -/ section StronglyMeasurable variable {_ : MeasurableSpace α} {μ : Measure α} {f : α → β} {g : ℕ → α} {m : ℕ} variable [TopologicalSpace β] @[fun_prop] theorem SimpleFunc.stronglyMeasurable (f : α →ₛ β) : StronglyMeasurable f := ⟨fun _ => f, fun _ => tendsto_const_nhds⟩ @[simp, nontriviality] lemma StronglyMeasurable.of_subsingleton_dom [Subsingleton α] : StronglyMeasurable f := ⟨fun _ => SimpleFunc.ofFinite f, fun _ => tendsto_const_nhds⟩ @[simp, nontriviality] lemma StronglyMeasurable.of_subsingleton_cod [Subsingleton β] : StronglyMeasurable f := by let f_sf : α →ₛ β := ⟨f, fun x => ?_, Set.Subsingleton.finite Set.subsingleton_of_subsingleton⟩ · exact ⟨fun _ => f_sf, fun x => tendsto_const_nhds⟩ · simp [Set.preimage, eq_iff_true_of_subsingleton] @[fun_prop] theorem stronglyMeasurable_const {b : β} : StronglyMeasurable fun _ : α => b := ⟨fun _ => SimpleFunc.const α b, fun _ => tendsto_const_nhds⟩ @[to_additive] theorem stronglyMeasurable_one [One β] : StronglyMeasurable (1 : α → β) := stronglyMeasurable_const /-- A version of `stronglyMeasurable_const` that assumes `f x = f y` for all `x, y`. This version works for functions between empty types. -/ theorem stronglyMeasurable_const' (hf : ∀ x y, f x = f y) : StronglyMeasurable f := by nontriviality α inhabit α convert stronglyMeasurable_const (β := β) using 1 exact funext fun x => hf x default variable [MeasurableSingletonClass α] section aux omit [TopologicalSpace β] /-- Auxiliary definition for `StronglyMeasurable.of_discrete`. -/ private noncomputable def simpleFuncAux (f : α → β) (g : ℕ → α) : ℕ → SimpleFunc α β | 0 => .const _ (f (g 0)) | n + 1 => .piecewise {g n} (.singleton _) (.const _ <| f (g n)) (simpleFuncAux f g n) private lemma simpleFuncAux_eq_of_lt : ∀ n > m, simpleFuncAux f g n (g m) = f (g m) | _, .refl => by simp [simpleFuncAux] | _, Nat.le.step (m := n) hmn => by obtain hnm | hnm := eq_or_ne (g n) (g m) <;> simp [simpleFuncAux, Set.piecewise_eq_of_notMem, hnm.symm, simpleFuncAux_eq_of_lt _ hmn] private lemma simpleFuncAux_eventuallyEq : ∀ᶠ n in atTop, simpleFuncAux f g n (g m) = f (g m) := eventually_atTop.2 ⟨_, simpleFuncAux_eq_of_lt⟩ end aux @[fun_prop] lemma StronglyMeasurable.of_discrete [Countable α] : StronglyMeasurable f := by nontriviality α nontriviality β obtain ⟨g, hg⟩ := exists_surjective_nat α exact ⟨simpleFuncAux f g, hg.forall.2 fun m ↦ tendsto_nhds_of_eventually_eq simpleFuncAux_eventuallyEq⟩ end StronglyMeasurable namespace StronglyMeasurable variable {f g : α → β} section BasicPropertiesInAnyTopologicalSpace variable [TopologicalSpace β] /-- A sequence of simple functions such that `∀ x, Tendsto (fun n => hf.approx n x) atTop (𝓝 (f x))`. That property is given by `stronglyMeasurable.tendsto_approx`. -/ protected noncomputable def approx {_ : MeasurableSpace α} (hf : StronglyMeasurable f) : ℕ → α →ₛ β := hf.choose protected theorem tendsto_approx {_ : MeasurableSpace α} (hf : StronglyMeasurable f) : ∀ x, Tendsto (fun n => hf.approx n x) atTop (𝓝 (f x)) := hf.choose_spec /-- Similar to `stronglyMeasurable.approx`, but enforces that the norm of every function in the sequence is less than `c` everywhere. If `‖f x‖ ≤ c` this sequence of simple functions verifies `Tendsto (fun n => hf.approxBounded n x) atTop (𝓝 (f x))`. -/ noncomputable def approxBounded {_ : MeasurableSpace α} [Norm β] [SMul ℝ β] (hf : StronglyMeasurable f) (c : ℝ) : ℕ → SimpleFunc α β := fun n => (hf.approx n).map fun x => min 1 (c / ‖x‖) • x theorem tendsto_approxBounded_of_norm_le {β} {f : α → β} [NormedAddCommGroup β] [NormedSpace ℝ β] {m : MeasurableSpace α} (hf : StronglyMeasurable[m] f) {c : ℝ} {x : α} (hfx : ‖f x‖ ≤ c) : Tendsto (fun n => hf.approxBounded c n x) atTop (𝓝 (f x)) := by have h_tendsto := hf.tendsto_approx x simp only [StronglyMeasurable.approxBounded, SimpleFunc.coe_map, Function.comp_apply] by_cases hfx0 : ‖f x‖ = 0 · rw [norm_eq_zero] at hfx0 rw [hfx0] at h_tendsto ⊢ have h_tendsto_norm : Tendsto (fun n => ‖hf.approx n x‖) atTop (𝓝 0) := by convert h_tendsto.norm rw [norm_zero] refine squeeze_zero_norm (fun n => ?_) h_tendsto_norm calc ‖min 1 (c / ‖hf.approx n x‖) • hf.approx n x‖ = ‖min 1 (c / ‖hf.approx n x‖)‖ * ‖hf.approx n x‖ := norm_smul _ _ _ ≤ ‖(1 : ℝ)‖ * ‖hf.approx n x‖ := by refine mul_le_mul_of_nonneg_right ?_ (norm_nonneg _) rw [norm_one, Real.norm_of_nonneg] · exact min_le_left _ _ · exact le_min zero_le_one (div_nonneg ((norm_nonneg _).trans hfx) (norm_nonneg _)) _ = ‖hf.approx n x‖ := by rw [norm_one, one_mul] rw [← one_smul ℝ (f x)] refine Tendsto.smul ?_ h_tendsto have : min 1 (c / ‖f x‖) = 1 := by rw [min_eq_left_iff, one_le_div (lt_of_le_of_ne (norm_nonneg _) (Ne.symm hfx0))] exact hfx nth_rw 2 [this.symm] refine Tendsto.min tendsto_const_nhds ?_ exact Tendsto.div tendsto_const_nhds h_tendsto.norm hfx0 theorem tendsto_approxBounded_ae {β} {f : α → β} [NormedAddCommGroup β] [NormedSpace ℝ β] {m m0 : MeasurableSpace α} {μ : Measure α} (hf : StronglyMeasurable[m] f) {c : ℝ} (hf_bound : ∀ᵐ x ∂μ, ‖f x‖ ≤ c) : ∀ᵐ x ∂μ, Tendsto (fun n => hf.approxBounded c n x) atTop (𝓝 (f x)) := by filter_upwards [hf_bound] with x hfx using tendsto_approxBounded_of_norm_le hf hfx theorem norm_approxBounded_le {β} {f : α → β} [SeminormedAddCommGroup β] [NormedSpace ℝ β] {m : MeasurableSpace α} {c : ℝ} (hf : StronglyMeasurable[m] f) (hc : 0 ≤ c) (n : ℕ) (x : α) : ‖hf.approxBounded c n x‖ ≤ c := by simp only [StronglyMeasurable.approxBounded, SimpleFunc.coe_map, Function.comp_apply] refine (norm_smul_le _ _).trans ?_ by_cases h0 : ‖hf.approx n x‖ = 0 · simp only [h0, _root_.div_zero, min_eq_right, zero_le_one, norm_zero, mul_zero] exact hc rcases le_total ‖hf.approx n x‖ c with h | h · rw [min_eq_left _] · simpa only [norm_one, one_mul] using h · rwa [one_le_div (lt_of_le_of_ne (norm_nonneg _) (Ne.symm h0))] · rw [min_eq_right _] · rw [norm_div, norm_norm, mul_comm, mul_div, div_eq_mul_inv, mul_comm, ← mul_assoc, inv_mul_cancel₀ h0, one_mul, Real.norm_of_nonneg hc] · rwa [div_le_one (lt_of_le_of_ne (norm_nonneg _) (Ne.symm h0))] theorem _root_.stronglyMeasurable_bot_iff [Nonempty β] [T2Space β] : StronglyMeasurable[⊥] f ↔ ∃ c, f = fun _ => c := by rcases isEmpty_or_nonempty α with hα | hα · simp [eq_iff_true_of_subsingleton] refine ⟨fun hf => ?_, fun hf_eq => ?_⟩ · refine ⟨f hα.some, ?_⟩ let fs := hf.approx have h_fs_tendsto : ∀ x, Tendsto (fun n => fs n x) atTop (𝓝 (f x)) := hf.tendsto_approx have : ∀ n, ∃ c, ∀ x, fs n x = c := fun n => SimpleFunc.simpleFunc_bot (fs n) let cs n := (this n).choose have h_cs_eq : ∀ n, ⇑(fs n) = fun _ => cs n := fun n => funext (this n).choose_spec conv at h_fs_tendsto => enter [x, 1, n]; rw [h_cs_eq] have h_tendsto : Tendsto cs atTop (𝓝 (f hα.some)) := h_fs_tendsto hα.some ext1 x exact tendsto_nhds_unique (h_fs_tendsto x) h_tendsto · obtain ⟨c, rfl⟩ := hf_eq exact stronglyMeasurable_const end BasicPropertiesInAnyTopologicalSpace theorem finStronglyMeasurable_of_set_sigmaFinite [TopologicalSpace β] [Zero β] {m : MeasurableSpace α} {μ : Measure α} (hf_meas : StronglyMeasurable f) {t : Set α} (ht : MeasurableSet t) (hft_zero : ∀ x ∈ tᶜ, f x = 0) (htμ : SigmaFinite (μ.restrict t)) : FinStronglyMeasurable f μ := by haveI : SigmaFinite (μ.restrict t) := htμ let S := spanningSets (μ.restrict t) have hS_meas : ∀ n, MeasurableSet (S n) := measurableSet_spanningSets (μ.restrict t) let f_approx := hf_meas.approx let fs n := SimpleFunc.restrict (f_approx n) (S n ∩ t) have h_fs_t_compl : ∀ n, ∀ x, x ∉ t → fs n x = 0 := by intro n x hxt rw [SimpleFunc.restrict_apply _ ((hS_meas n).inter ht)] refine Set.indicator_of_notMem ?_ _ simp [hxt] refine ⟨fs, ?_, fun x => ?_⟩ · simp_rw [SimpleFunc.support_eq, ← Finset.mem_coe] classical refine fun n => measure_biUnion_lt_top {y ∈ (fs n).range | y ≠ 0}.finite_toSet fun y hy => ?_ rw [SimpleFunc.restrict_preimage_singleton _ ((hS_meas n).inter ht)] swap · letI : (y : β) → Decidable (y = 0) := fun y => Classical.propDecidable _ rw [Finset.mem_coe, Finset.mem_filter] at hy exact hy.2 refine (measure_mono Set.inter_subset_left).trans_lt ?_ have h_lt_top := measure_spanningSets_lt_top (μ.restrict t) n rwa [Measure.restrict_apply' ht] at h_lt_top · by_cases hxt : x ∈ t swap · rw [funext fun n => h_fs_t_compl n x hxt, hft_zero x hxt] exact tendsto_const_nhds have h : Tendsto (fun n => (f_approx n) x) atTop (𝓝 (f x)) := hf_meas.tendsto_approx x obtain ⟨n₁, hn₁⟩ : ∃ n, ∀ m, n ≤ m → fs m x = f_approx m x := by obtain ⟨n, hn⟩ : ∃ n, ∀ m, n ≤ m → x ∈ S m ∩ t := by rsuffices ⟨n, hn⟩ : ∃ n, ∀ m, n ≤ m → x ∈ S m · exact ⟨n, fun m hnm => Set.mem_inter (hn m hnm) hxt⟩ rsuffices ⟨n, hn⟩ : ∃ n, x ∈ S n · exact ⟨n, fun m hnm => monotone_spanningSets (μ.restrict t) hnm hn⟩ rw [← Set.mem_iUnion, iUnion_spanningSets (μ.restrict t)] trivial refine ⟨n, fun m hnm => ?_⟩ simp_rw [fs, SimpleFunc.restrict_apply _ ((hS_meas m).inter ht), Set.indicator_of_mem (hn m hnm)] rw [tendsto_atTop'] at h ⊢ intro s hs obtain ⟨n₂, hn₂⟩ := h s hs refine ⟨max n₁ n₂, fun m hm => ?_⟩ rw [hn₁ m ((le_max_left _ _).trans hm.le)] exact hn₂ m ((le_max_right _ _).trans hm.le) /-- If the measure is sigma-finite, all strongly measurable functions are `FinStronglyMeasurable`. -/ @[aesop 5% apply (rule_sets := [Measurable])] protected theorem finStronglyMeasurable [TopologicalSpace β] [Zero β] {m0 : MeasurableSpace α} (hf : StronglyMeasurable f) (μ : Measure α) [SigmaFinite μ] : FinStronglyMeasurable f μ := hf.finStronglyMeasurable_of_set_sigmaFinite MeasurableSet.univ (by simp) (by rwa [Measure.restrict_univ]) /-- A strongly measurable function is measurable. -/ @[fun_prop] protected theorem measurable {_ : MeasurableSpace α} [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] (hf : StronglyMeasurable f) : Measurable f := measurable_of_tendsto_metrizable (fun n => (hf.approx n).measurable) (tendsto_pi_nhds.mpr hf.tendsto_approx) /-- A strongly measurable function is almost everywhere measurable. -/ @[fun_prop] protected theorem aemeasurable {_ : MeasurableSpace α} [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] {μ : Measure α} (hf : StronglyMeasurable f) : AEMeasurable f μ := hf.measurable.aemeasurable theorem _root_.Continuous.comp_stronglyMeasurable {_ : MeasurableSpace α} [TopologicalSpace β] [TopologicalSpace γ] {g : β → γ} {f : α → β} (hg : Continuous g) (hf : StronglyMeasurable f) : StronglyMeasurable fun x => g (f x) := ⟨fun n => SimpleFunc.map g (hf.approx n), fun x => (hg.tendsto _).comp (hf.tendsto_approx x)⟩ @[to_additive] nonrec theorem measurableSet_mulSupport {m : MeasurableSpace α} [One β] [TopologicalSpace β] [MetrizableSpace β] (hf : StronglyMeasurable f) : MeasurableSet (mulSupport f) := by borelize β exact measurableSet_mulSupport hf.measurable protected theorem mono {m m' : MeasurableSpace α} [TopologicalSpace β] (hf : StronglyMeasurable[m'] f) (h_mono : m' ≤ m) : StronglyMeasurable[m] f := by let f_approx : ℕ → @SimpleFunc α m β := fun n => @SimpleFunc.mk α m β (hf.approx n) (fun x => h_mono _ (SimpleFunc.measurableSet_fiber' _ x)) (SimpleFunc.finite_range (hf.approx n)) exact ⟨f_approx, hf.tendsto_approx⟩ @[fun_prop] protected theorem fst {m : MeasurableSpace α} [TopologicalSpace β] [TopologicalSpace γ] {f : α → β × γ} (hf : StronglyMeasurable f) : StronglyMeasurable fun x ↦ (f x).1 := continuous_fst.comp_stronglyMeasurable hf @[fun_prop] protected theorem snd {m : MeasurableSpace α} [TopologicalSpace β] [TopologicalSpace γ] {f : α → β × γ} (hf : StronglyMeasurable f) : StronglyMeasurable fun x ↦ (f x).2 := continuous_snd.comp_stronglyMeasurable hf @[fun_prop] protected theorem prodMk {m : MeasurableSpace α} [TopologicalSpace β] [TopologicalSpace γ] {f : α → β} {g : α → γ} (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable fun x => (f x, g x) := by refine ⟨fun n => SimpleFunc.pair (hf.approx n) (hg.approx n), fun x => ?_⟩ rw [nhds_prod_eq] exact Tendsto.prodMk (hf.tendsto_approx x) (hg.tendsto_approx x) @[fun_prop] theorem comp_measurable [TopologicalSpace β] {_ : MeasurableSpace α} {_ : MeasurableSpace γ} {f : α → β} {g : γ → α} (hf : StronglyMeasurable f) (hg : Measurable g) : StronglyMeasurable (f ∘ g) := ⟨fun n => SimpleFunc.comp (hf.approx n) g hg, fun x => hf.tendsto_approx (g x)⟩ theorem of_uncurry_left [TopologicalSpace β] {_ : MeasurableSpace α} {_ : MeasurableSpace γ} {f : α → γ → β} (hf : StronglyMeasurable (uncurry f)) {x : α} : StronglyMeasurable (f x) := hf.comp_measurable measurable_prodMk_left theorem of_uncurry_right [TopologicalSpace β] {_ : MeasurableSpace α} {_ : MeasurableSpace γ} {f : α → γ → β} (hf : StronglyMeasurable (uncurry f)) {y : γ} : StronglyMeasurable fun x => f x y := hf.comp_measurable measurable_prodMk_right protected theorem prod_swap {_ : MeasurableSpace α} {_ : MeasurableSpace β} [TopologicalSpace γ] {f : β × α → γ} (hf : StronglyMeasurable f) : StronglyMeasurable (fun z : α × β => f z.swap) := hf.comp_measurable measurable_swap protected theorem comp_fst {_ : MeasurableSpace α} [mβ : MeasurableSpace β] [TopologicalSpace γ] {f : α → γ} (hf : StronglyMeasurable f) : StronglyMeasurable (fun z : α × β => f z.1) := hf.comp_measurable measurable_fst protected theorem comp_snd [mα : MeasurableSpace α] {_ : MeasurableSpace β} [TopologicalSpace γ] {f : β → γ} (hf : StronglyMeasurable f) : StronglyMeasurable (fun z : α × β => f z.2) := hf.comp_measurable measurable_snd section Arithmetic variable {mα : MeasurableSpace α} [TopologicalSpace β] @[to_additive (attr := fun_prop)] protected theorem mul [Mul β] [ContinuousMul β] (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable (f * g) := ⟨fun n => hf.approx n * hg.approx n, fun x => (hf.tendsto_approx x).mul (hg.tendsto_approx x)⟩ @[to_additive (attr := fun_prop, measurability)] theorem mul_const [Mul β] [ContinuousMul β] (hf : StronglyMeasurable f) (c : β) : StronglyMeasurable fun x => f x * c := hf.mul stronglyMeasurable_const @[to_additive (attr := fun_prop, measurability)] theorem const_mul [Mul β] [ContinuousMul β] (hf : StronglyMeasurable f) (c : β) : StronglyMeasurable fun x => c * f x := stronglyMeasurable_const.mul hf @[to_additive (attr := fun_prop) const_nsmul] protected theorem pow [Monoid β] [ContinuousMul β] (hf : StronglyMeasurable f) (n : ℕ) : StronglyMeasurable (f ^ n) := ⟨fun k => hf.approx k ^ n, fun x => (hf.tendsto_approx x).pow n⟩ @[to_additive (attr := fun_prop, measurability)] protected theorem inv [Inv β] [ContinuousInv β] (hf : StronglyMeasurable f) : StronglyMeasurable f⁻¹ := ⟨fun n => (hf.approx n)⁻¹, fun x => (hf.tendsto_approx x).inv⟩ @[to_additive (attr := fun_prop)] protected theorem div [Div β] [ContinuousDiv β] (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable (f / g) := ⟨fun n => hf.approx n / hg.approx n, fun x => (hf.tendsto_approx x).div' (hg.tendsto_approx x)⟩ @[to_additive] theorem mul_iff_right [CommGroup β] [IsTopologicalGroup β] (hf : StronglyMeasurable f) : StronglyMeasurable (f * g) ↔ StronglyMeasurable g := ⟨fun h ↦ show g = f * g * f⁻¹ by simp only [mul_inv_cancel_comm] ▸ h.mul hf.inv, fun h ↦ hf.mul h⟩ @[to_additive] theorem mul_iff_left [CommGroup β] [IsTopologicalGroup β] (hf : StronglyMeasurable f) : StronglyMeasurable (g * f) ↔ StronglyMeasurable g := mul_comm g f ▸ mul_iff_right hf @[to_additive (attr := fun_prop)] protected theorem smul {𝕜} [TopologicalSpace 𝕜] [SMul 𝕜 β] [ContinuousSMul 𝕜 β] {f : α → 𝕜} {g : α → β} (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable fun x => f x • g x := continuous_smul.comp_stronglyMeasurable (hf.prodMk hg) @[to_additive (attr := fun_prop, measurability)] protected theorem const_smul {𝕜} [SMul 𝕜 β] [ContinuousConstSMul 𝕜 β] (hf : StronglyMeasurable f) (c : 𝕜) : StronglyMeasurable (c • f) := ⟨fun n => c • hf.approx n, fun x => (hf.tendsto_approx x).const_smul c⟩ @[to_additive (attr := fun_prop, measurability)] protected theorem const_smul' {𝕜} [SMul 𝕜 β] [ContinuousConstSMul 𝕜 β] (hf : StronglyMeasurable f) (c : 𝕜) : StronglyMeasurable fun x => c • f x := hf.const_smul c @[to_additive (attr := fun_prop, measurability)] protected theorem smul_const {𝕜} [TopologicalSpace 𝕜] [SMul 𝕜 β] [ContinuousSMul 𝕜 β] {f : α → 𝕜} (hf : StronglyMeasurable f) (c : β) : StronglyMeasurable fun x => f x • c := continuous_smul.comp_stronglyMeasurable (hf.prodMk stronglyMeasurable_const) /-- Pointwise star on functions induced from continuous star preserves strong measurability. -/ @[measurability] protected theorem star {R : Type*} [MeasurableSpace α] [Star R] [TopologicalSpace R] [ContinuousStar R] (f : α → R) (hf : StronglyMeasurable f) : StronglyMeasurable (star f) := ⟨fun n => star (hf.approx n), fun x => (hf.tendsto_approx x).star⟩ /-- In a normed vector space, the addition of a measurable function and a strongly measurable function is measurable. Note that this is not true without further second-countability assumptions for the addition of two measurable functions. -/ theorem _root_.Measurable.add_stronglyMeasurable {α E : Type*} {_ : MeasurableSpace α} [AddCancelMonoid E] [TopologicalSpace E] [MeasurableSpace E] [BorelSpace E] [ContinuousAdd E] [PseudoMetrizableSpace E] {g f : α → E} (hg : Measurable g) (hf : StronglyMeasurable f) : Measurable (g + f) := by rcases hf with ⟨φ, hφ⟩ have : Tendsto (fun n x ↦ g x + φ n x) atTop (𝓝 (g + f)) := tendsto_pi_nhds.2 (fun x ↦ tendsto_const_nhds.add (hφ x)) apply measurable_of_tendsto_metrizable (fun n ↦ ?_) this exact hg.add_simpleFunc _ /-- In a normed vector space, the subtraction of a measurable function and a strongly measurable function is measurable. Note that this is not true without further second-countability assumptions for the subtraction of two measurable functions. -/ theorem _root_.Measurable.sub_stronglyMeasurable {α E : Type*} {_ : MeasurableSpace α} [AddGroup E] [TopologicalSpace E] [MeasurableSpace E] [BorelSpace E] [ContinuousAdd E] [ContinuousNeg E] [PseudoMetrizableSpace E] {g f : α → E} (hg : Measurable g) (hf : StronglyMeasurable f) : Measurable (g - f) := by rw [sub_eq_add_neg] exact hg.add_stronglyMeasurable hf.neg /-- In a normed vector space, the addition of a strongly measurable function and a measurable function is measurable. Note that this is not true without further second-countability assumptions for the addition of two measurable functions. -/ theorem _root_.Measurable.stronglyMeasurable_add {α E : Type*} {_ : MeasurableSpace α} [AddCancelMonoid E] [TopologicalSpace E] [MeasurableSpace E] [BorelSpace E] [ContinuousAdd E] [PseudoMetrizableSpace E] {g f : α → E} (hg : Measurable g) (hf : StronglyMeasurable f) : Measurable (f + g) := by rcases hf with ⟨φ, hφ⟩ have : Tendsto (fun n x ↦ φ n x + g x) atTop (𝓝 (f + g)) := tendsto_pi_nhds.2 (fun x ↦ (hφ x).add tendsto_const_nhds) apply measurable_of_tendsto_metrizable (fun n ↦ ?_) this exact hg.simpleFunc_add _ end Arithmetic section MulAction variable {M G G₀ : Type*} variable [TopologicalSpace β] variable [Monoid M] [MulAction M β] [ContinuousConstSMul M β] variable [Group G] [MulAction G β] [ContinuousConstSMul G β] variable [GroupWithZero G₀] [MulAction G₀ β] [ContinuousConstSMul G₀ β] theorem _root_.stronglyMeasurable_const_smul_iff {m : MeasurableSpace α} (c : G) : (StronglyMeasurable fun x => c • f x) ↔ StronglyMeasurable f := ⟨fun h => by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, fun h => h.const_smul c⟩ nonrec theorem _root_.IsUnit.stronglyMeasurable_const_smul_iff {_ : MeasurableSpace α} {c : M} (hc : IsUnit c) : (StronglyMeasurable fun x => c • f x) ↔ StronglyMeasurable f := let ⟨u, hu⟩ := hc hu ▸ stronglyMeasurable_const_smul_iff u theorem _root_.stronglyMeasurable_const_smul_iff₀ {_ : MeasurableSpace α} {c : G₀} (hc : c ≠ 0) : (StronglyMeasurable fun x => c • f x) ↔ StronglyMeasurable f := (IsUnit.mk0 _ hc).stronglyMeasurable_const_smul_iff end MulAction section Order variable [MeasurableSpace α] [TopologicalSpace β] open Filter @[fun_prop] protected theorem sup [Max β] [ContinuousSup β] (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable (f ⊔ g) := ⟨fun n => hf.approx n ⊔ hg.approx n, fun x => (hf.tendsto_approx x).sup_nhds (hg.tendsto_approx x)⟩ @[fun_prop] protected theorem inf [Min β] [ContinuousInf β] (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable (f ⊓ g) := ⟨fun n => hf.approx n ⊓ hg.approx n, fun x => (hf.tendsto_approx x).inf_nhds (hg.tendsto_approx x)⟩ end Order /-! ### Big operators: `∏` and `∑` -/ section Monoid variable {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M] {m : MeasurableSpace α} @[to_additive (attr := fun_prop, measurability)] theorem _root_.List.stronglyMeasurable_prod (l : List (α → M)) (hl : ∀ f ∈ l, StronglyMeasurable f) : StronglyMeasurable l.prod := by induction l with | nil => exact stronglyMeasurable_one | cons f l ihl => rw [List.forall_mem_cons] at hl rw [List.prod_cons] exact hl.1.mul (ihl hl.2) @[deprecated (since := "2025-05-30")] alias _root_.List.stronglyMeasurable_sum' := List.stronglyMeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias _root_.List.stronglyMeasurable_prod' := List.stronglyMeasurable_prod @[to_additive (attr := fun_prop, measurability)] theorem _root_.List.stronglyMeasurable_fun_prod (l : List (α → M)) (hl : ∀ f ∈ l, StronglyMeasurable f) : StronglyMeasurable fun x => (l.map fun f : α → M => f x).prod := by simpa only [← Pi.list_prod_apply] using l.stronglyMeasurable_prod hl end Monoid section CommMonoid variable {M : Type*} [CommMonoid M] [TopologicalSpace M] [ContinuousMul M] {m : MeasurableSpace α} @[to_additive (attr := fun_prop, measurability)] theorem _root_.Multiset.stronglyMeasurable_prod (l : Multiset (α → M)) (hl : ∀ f ∈ l, StronglyMeasurable f) : StronglyMeasurable l.prod := by rcases l with ⟨l⟩ simpa using l.stronglyMeasurable_prod (by simpa using hl) @[deprecated (since := "2025-05-30")] alias _root_.Multiset.stronglyMeasurable_sum' := Multiset.stronglyMeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias _root_.Multiset.stronglyMeasurable_prod' := Multiset.stronglyMeasurable_prod @[to_additive (attr := fun_prop, measurability)] theorem _root_.Multiset.stronglyMeasurable_fun_prod (s : Multiset (α → M)) (hs : ∀ f ∈ s, StronglyMeasurable f) : StronglyMeasurable fun x => (s.map fun f : α → M => f x).prod := by simpa only [← Pi.multiset_prod_apply] using s.stronglyMeasurable_prod hs @[to_additive (attr := measurability, fun_prop)] theorem _root_.Finset.stronglyMeasurable_prod {ι : Type*} {f : ι → α → M} (s : Finset ι) (hf : ∀ i ∈ s, StronglyMeasurable (f i)) : StronglyMeasurable (∏ i ∈ s, f i) := Finset.prod_induction _ _ (fun _a _b ha hb => ha.mul hb) (@stronglyMeasurable_one α M _ _ _) hf @[deprecated (since := "2025-05-30")] alias _root_.Finset.stronglyMeasurable_sum' := Finset.stronglyMeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias _root_.Finset.stronglyMeasurable_prod' := Finset.stronglyMeasurable_prod @[to_additive (attr := measurability, fun_prop)] theorem _root_.Finset.stronglyMeasurable_fun_prod {ι : Type*} {f : ι → α → M} (s : Finset ι) (hf : ∀ i ∈ s, StronglyMeasurable (f i)) : StronglyMeasurable fun a => ∏ i ∈ s, f i a := by simpa only [← Finset.prod_apply] using s.stronglyMeasurable_prod hf variable {n : MeasurableSpace β} in /-- Compositional version of `Finset.stronglyMeasurable_prod` for use by `fun_prop`. -/ @[to_additive (attr := measurability, fun_prop) /-- Compositional version of `Finset.stronglyMeasurable_sum` for use by `fun_prop`. -/] lemma Finset.stronglyMeasurable_prod_apply {ι : Type*} {f : ι → α → β → M} {g : α → β} {s : Finset ι} (hf : ∀ i ∈ s, StronglyMeasurable ↿(f i)) (hg : Measurable g) : StronglyMeasurable fun a ↦ (∏ i ∈ s, f i a) (g a) := by simp only [Finset.prod_apply]; fun_prop (discharger := assumption) end CommMonoid /-- The range of a strongly measurable function is separable. -/ protected theorem isSeparable_range {m : MeasurableSpace α} [TopologicalSpace β] (hf : StronglyMeasurable f) : TopologicalSpace.IsSeparable (range f) := by have : IsSeparable (closure (⋃ n, range (hf.approx n))) := .closure <| .iUnion fun n => (hf.approx n).finite_range.isSeparable apply this.mono rintro _ ⟨x, rfl⟩ apply mem_closure_of_tendsto (hf.tendsto_approx x) filter_upwards with n apply mem_iUnion_of_mem n exact mem_range_self _ theorem separableSpace_range_union_singleton {_ : MeasurableSpace α} [TopologicalSpace β] [PseudoMetrizableSpace β] (hf : StronglyMeasurable f) {b : β} : SeparableSpace (range f ∪ {b} : Set β) := letI := pseudoMetrizableSpacePseudoMetric β (hf.isSeparable_range.union (finite_singleton _).isSeparable).separableSpace section SecondCountableStronglyMeasurable variable {mα : MeasurableSpace α} [MeasurableSpace β] /-- In a space with second countable topology, measurable implies strongly measurable. -/ @[fun_prop] theorem _root_.Measurable.stronglyMeasurable [TopologicalSpace β] [PseudoMetrizableSpace β] [SecondCountableTopology β] [OpensMeasurableSpace β] (hf : Measurable f) : StronglyMeasurable f := by letI := pseudoMetrizableSpacePseudoMetric β nontriviality β; inhabit β exact ⟨SimpleFunc.approxOn f hf Set.univ default (Set.mem_univ _), fun x ↦ SimpleFunc.tendsto_approxOn hf (Set.mem_univ _) (by simp)⟩ /-- In a space with second countable topology, strongly measurable and measurable are equivalent. -/ theorem _root_.stronglyMeasurable_iff_measurable [TopologicalSpace β] [MetrizableSpace β] [BorelSpace β] [SecondCountableTopology β] : StronglyMeasurable f ↔ Measurable f := ⟨fun h => h.measurable, fun h => Measurable.stronglyMeasurable h⟩ @[fun_prop, measurability] theorem _root_.stronglyMeasurable_id [TopologicalSpace α] [PseudoMetrizableSpace α] [OpensMeasurableSpace α] [SecondCountableTopology α] : StronglyMeasurable (id : α → α) := measurable_id.stronglyMeasurable end SecondCountableStronglyMeasurable /-- A function is strongly measurable if and only if it is measurable and has separable range. -/ theorem _root_.stronglyMeasurable_iff_measurable_separable {m : MeasurableSpace α} [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] : StronglyMeasurable f ↔ Measurable f ∧ IsSeparable (range f) := by refine ⟨fun H ↦ ⟨H.measurable, H.isSeparable_range⟩, fun ⟨Hm, Hsep⟩ ↦ ?_⟩ have := Hsep.secondCountableTopology have Hm' : StronglyMeasurable (rangeFactorization f) := Hm.subtype_mk.stronglyMeasurable exact continuous_subtype_val.comp_stronglyMeasurable Hm' /-- A continuous function is strongly measurable when either the source space or the target space is second-countable. -/ theorem _root_.Continuous.stronglyMeasurable [MeasurableSpace α] [TopologicalSpace α] [OpensMeasurableSpace α] [TopologicalSpace β] [PseudoMetrizableSpace β] [h : SecondCountableTopologyEither α β] {f : α → β} (hf : Continuous f) : StronglyMeasurable f := by borelize β cases h.out · rw [stronglyMeasurable_iff_measurable_separable] refine ⟨hf.measurable, ?_⟩ exact isSeparable_range hf · exact hf.measurable.stronglyMeasurable /-- A continuous function whose support is contained in a compact set is strongly measurable. -/ @[to_additive] theorem _root_.Continuous.stronglyMeasurable_of_mulSupport_subset_isCompact [MeasurableSpace α] [TopologicalSpace α] [OpensMeasurableSpace α] [MeasurableSpace β] [TopologicalSpace β] [PseudoMetrizableSpace β] [BorelSpace β] [One β] {f : α → β} (hf : Continuous f) {k : Set α} (hk : IsCompact k) (h'f : mulSupport f ⊆ k) : StronglyMeasurable f := by letI : PseudoMetricSpace β := pseudoMetrizableSpacePseudoMetric β rw [stronglyMeasurable_iff_measurable_separable] exact ⟨hf.measurable, (isCompact_range_of_mulSupport_subset_isCompact hf hk h'f).isSeparable⟩ /-- A continuous function with compact support is strongly measurable. -/ @[to_additive] theorem _root_.Continuous.stronglyMeasurable_of_hasCompactMulSupport [MeasurableSpace α] [TopologicalSpace α] [OpensMeasurableSpace α] [MeasurableSpace β] [TopologicalSpace β] [PseudoMetrizableSpace β] [BorelSpace β] [One β] {f : α → β} (hf : Continuous f) (h'f : HasCompactMulSupport f) : StronglyMeasurable f := hf.stronglyMeasurable_of_mulSupport_subset_isCompact h'f (subset_mulTSupport f) /-- A continuous function with compact support on a product space is strongly measurable for the product sigma-algebra. The subtlety is that we do not assume that the spaces are separable, so the product of the Borel sigma algebras might not contain all open sets, but still it contains enough of them to approximate compactly supported continuous functions. -/ lemma _root_.HasCompactSupport.stronglyMeasurable_of_prod {X Y : Type*} [Zero α] [TopologicalSpace X] [TopologicalSpace Y] [MeasurableSpace X] [MeasurableSpace Y] [OpensMeasurableSpace X] [OpensMeasurableSpace Y] [TopologicalSpace α] [PseudoMetrizableSpace α] {f : X × Y → α} (hf : Continuous f) (h'f : HasCompactSupport f) : StronglyMeasurable f := by borelize α apply stronglyMeasurable_iff_measurable_separable.2 ⟨h'f.measurable_of_prod hf, ?_⟩ letI : PseudoMetricSpace α := pseudoMetrizableSpacePseudoMetric α exact IsCompact.isSeparable (s := range f) (h'f.isCompact_range hf) /-- If `g` is a topological embedding, then `f` is strongly measurable iff `g ∘ f` is. -/ theorem _root_.Embedding.comp_stronglyMeasurable_iff {m : MeasurableSpace α} [TopologicalSpace β] [PseudoMetrizableSpace β] [TopologicalSpace γ] [PseudoMetrizableSpace γ] {g : β → γ} {f : α → β} (hg : IsEmbedding g) : (StronglyMeasurable fun x => g (f x)) ↔ StronglyMeasurable f := by letI := pseudoMetrizableSpacePseudoMetric γ borelize β γ refine ⟨fun H => stronglyMeasurable_iff_measurable_separable.2 ⟨?_, ?_⟩, fun H => hg.continuous.comp_stronglyMeasurable H⟩ · let G : β → range g := rangeFactorization g have hG : IsClosedEmbedding G := { hg.codRestrict _ _ with isClosed_range := by rw [rangeFactorization_surjective.range_eq] exact isClosed_univ } have : Measurable (G ∘ f) := Measurable.subtype_mk H.measurable exact hG.measurableEmbedding.measurable_comp_iff.1 this · have : IsSeparable (g ⁻¹' range (g ∘ f)) := hg.isSeparable_preimage H.isSeparable_range rwa [range_comp, hg.injective.preimage_image] at this /-- A sequential limit of strongly measurable functions is strongly measurable. -/ theorem _root_.stronglyMeasurable_of_tendsto {ι : Type*} {m : MeasurableSpace α} [TopologicalSpace β] [PseudoMetrizableSpace β] (u : Filter ι) [NeBot u] [IsCountablyGenerated u] {f : ι → α → β} {g : α → β} (hf : ∀ i, StronglyMeasurable (f i)) (lim : Tendsto f u (𝓝 g)) : StronglyMeasurable g := by borelize β refine stronglyMeasurable_iff_measurable_separable.2 ⟨?_, ?_⟩ · exact measurable_of_tendsto_metrizable' u (fun i => (hf i).measurable) lim · rcases u.exists_seq_tendsto with ⟨v, hv⟩ have : IsSeparable (closure (⋃ i, range (f (v i)))) := .closure <| .iUnion fun i => (hf (v i)).isSeparable_range apply this.mono rintro _ ⟨x, rfl⟩ rw [tendsto_pi_nhds] at lim apply mem_closure_of_tendsto ((lim x).comp hv) filter_upwards with n apply mem_iUnion_of_mem n exact mem_range_self _ protected theorem piecewise {m : MeasurableSpace α} [TopologicalSpace β] {s : Set α} {_ : DecidablePred (· ∈ s)} (hs : MeasurableSet s) (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable (Set.piecewise s f g) := by refine ⟨fun n => SimpleFunc.piecewise s hs (hf.approx n) (hg.approx n), fun x => ?_⟩ by_cases hx : x ∈ s · simpa [@Set.piecewise_eq_of_mem _ _ _ _ _ (fun _ => Classical.propDecidable _) _ hx, hx] using hf.tendsto_approx x · simpa [@Set.piecewise_eq_of_notMem _ _ _ _ _ (fun _ => Classical.propDecidable _) _ hx, hx] using hg.tendsto_approx x /-- this is slightly different from `StronglyMeasurable.piecewise`. It can be used to show `StronglyMeasurable (ite (x=0) 0 1)` by `exact StronglyMeasurable.ite (measurableSet_singleton 0) stronglyMeasurable_const stronglyMeasurable_const`, but replacing `StronglyMeasurable.ite` by `StronglyMeasurable.piecewise` in that example proof does not work. -/ protected theorem ite {_ : MeasurableSpace α} [TopologicalSpace β] {p : α → Prop} {_ : DecidablePred p} (hp : MeasurableSet { a : α | p a }) (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable fun x => ite (p x) (f x) (g x) := StronglyMeasurable.piecewise hp hf hg @[measurability] theorem _root_.MeasurableEmbedding.stronglyMeasurable_extend {f : α → β} {g : α → γ} {g' : γ → β} {mα : MeasurableSpace α} {mγ : MeasurableSpace γ} [TopologicalSpace β] (hg : MeasurableEmbedding g) (hf : StronglyMeasurable f) (hg' : StronglyMeasurable g') : StronglyMeasurable (Function.extend g f g') := by refine ⟨fun n => SimpleFunc.extend (hf.approx n) g hg (hg'.approx n), ?_⟩ intro x by_cases hx : ∃ y, g y = x · rcases hx with ⟨y, rfl⟩ simpa only [SimpleFunc.extend_apply, hg.injective, Injective.extend_apply] using hf.tendsto_approx y · simpa only [hx, SimpleFunc.extend_apply', not_false_iff, extend_apply'] using hg'.tendsto_approx x theorem _root_.MeasurableEmbedding.exists_stronglyMeasurable_extend {f : α → β} {g : α → γ} {_ : MeasurableSpace α} {_ : MeasurableSpace γ} [TopologicalSpace β] (hg : MeasurableEmbedding g) (hf : StronglyMeasurable f) (hne : γ → Nonempty β) : ∃ f' : γ → β, StronglyMeasurable f' ∧ f' ∘ g = f := ⟨Function.extend g f fun x => Classical.choice (hne x), hg.stronglyMeasurable_extend hf (stronglyMeasurable_const' fun _ _ => rfl), funext fun _ => hg.injective.extend_apply _ _ _⟩ theorem _root_.stronglyMeasurable_of_stronglyMeasurable_union_cover {m : MeasurableSpace α} [TopologicalSpace β] {f : α → β} (s t : Set α) (hs : MeasurableSet s) (ht : MeasurableSet t) (h : univ ⊆ s ∪ t) (hc : StronglyMeasurable fun a : s => f a) (hd : StronglyMeasurable fun a : t => f a) : StronglyMeasurable f := by nontriviality β; inhabit β suffices Function.extend Subtype.val (fun x : s ↦ f x) (Function.extend (↑) (fun x : t ↦ f x) fun _ ↦ default) = f from this ▸ (MeasurableEmbedding.subtype_coe hs).stronglyMeasurable_extend hc <| (MeasurableEmbedding.subtype_coe ht).stronglyMeasurable_extend hd stronglyMeasurable_const ext x by_cases hxs : x ∈ s · lift x to s using hxs simp · lift x to t using (h trivial).resolve_left hxs rw [extend_apply', Subtype.coe_injective.extend_apply] exact fun ⟨y, hy⟩ ↦ hxs <| hy ▸ y.2 theorem _root_.stronglyMeasurable_of_restrict_of_restrict_compl {_ : MeasurableSpace α} [TopologicalSpace β] {f : α → β} {s : Set α} (hs : MeasurableSet s) (h₁ : StronglyMeasurable (s.restrict f)) (h₂ : StronglyMeasurable (sᶜ.restrict f)) : StronglyMeasurable f := stronglyMeasurable_of_stronglyMeasurable_union_cover s sᶜ hs hs.compl (union_compl_self s).ge h₁ h₂ @[measurability] protected theorem indicator {_ : MeasurableSpace α} [TopologicalSpace β] [Zero β] (hf : StronglyMeasurable f) {s : Set α} (hs : MeasurableSet s) : StronglyMeasurable (s.indicator f) := hf.piecewise hs stronglyMeasurable_const /-- To prove that a property holds for any strongly measurable function, it is enough to show that it holds for constant indicator functions of measurable sets and that it is closed under addition and pointwise limit. To use in an induction proof, the syntax is `induction f, hf using StronglyMeasurable.induction with`. -/ theorem induction [MeasurableSpace α] [AddZeroClass β] [TopologicalSpace β] {P : (f : α → β) → StronglyMeasurable f → Prop} (ind : ∀ c ⦃s : Set α⦄ (hs : MeasurableSet s), P (s.indicator fun _ ↦ c) (stronglyMeasurable_const.indicator hs)) (add : ∀ ⦃f g : α → β⦄ (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) (hfg : StronglyMeasurable (f + g)), Disjoint f.support g.support → P f hf → P g hg → P (f + g) hfg) (lim : ∀ ⦃f : ℕ → α → β⦄ ⦃g : α → β⦄ (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g), (∀ n, P (f n) (hf n)) → (∀ x, Tendsto (f · x) atTop (𝓝 (g x))) → P g hg) (f : α → β) (hf : StronglyMeasurable f) : P f hf := by let s := hf.approx refine lim (fun n ↦ (s n).stronglyMeasurable) hf (fun n ↦ ?_) hf.tendsto_approx change P (s n) (s n).stronglyMeasurable induction s n using SimpleFunc.induction with | const c hs => exact ind c hs | @add f g h_supp hf hg => exact add f.stronglyMeasurable g.stronglyMeasurable (f + g).stronglyMeasurable h_supp hf hg open scoped Classical in /-- To prove that a property holds for any strongly measurable function, it is enough to show that it holds for constant functions and that it is closed under piecewise combination of functions and pointwise limits. To use in an induction proof, the syntax is `induction f, hf using StronglyMeasurable.induction' with`. -/ theorem induction' [MeasurableSpace α] [Nonempty β] [TopologicalSpace β] {P : (f : α → β) → StronglyMeasurable f → Prop} (const : ∀ (c), P (fun _ ↦ c) stronglyMeasurable_const) (pcw : ∀ ⦃f g : α → β⦄ {s} (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) (hs : MeasurableSet s), P f hf → P g hg → P (s.piecewise f g) (hf.piecewise hs hg)) (lim : ∀ ⦃f : ℕ → α → β⦄ ⦃g : α → β⦄ (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g), (∀ n, P (f n) (hf n)) → (∀ x, Tendsto (f · x) atTop (𝓝 (g x))) → P g hg) (f : α → β) (hf : StronglyMeasurable f) : P f hf := by let s := hf.approx refine lim (fun n ↦ (s n).stronglyMeasurable) hf (fun n ↦ ?_) hf.tendsto_approx change P (s n) (s n).stronglyMeasurable induction s n with | const c => exact const c | @pcw f g s hs Pf Pg => simp_rw [SimpleFunc.coe_piecewise] exact pcw f.stronglyMeasurable g.stronglyMeasurable hs Pf Pg @[fun_prop] protected theorem dist {_ : MeasurableSpace α} {β : Type*} [PseudoMetricSpace β] {f g : α → β} (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable fun x => dist (f x) (g x) := continuous_dist.comp_stronglyMeasurable (hf.prodMk hg) @[fun_prop] protected theorem edist {_ : MeasurableSpace α} {β : Type*} [PseudoEMetricSpace β] {f g : α → β} (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : StronglyMeasurable fun x => edist (f x) (g x) := continuous_edist.comp_stronglyMeasurable (hf.prodMk hg) @[fun_prop, measurability] protected theorem norm {_ : MeasurableSpace α} {β : Type*} [SeminormedAddCommGroup β] {f : α → β} (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ‖f x‖ := continuous_norm.comp_stronglyMeasurable hf @[fun_prop, measurability] protected theorem nnnorm {_ : MeasurableSpace α} {β : Type*} [SeminormedAddCommGroup β] {f : α → β} (hf : StronglyMeasurable f) : StronglyMeasurable fun x => ‖f x‖₊ := continuous_nnnorm.comp_stronglyMeasurable hf /-- The `enorm` of a strongly measurable function is measurable. Unlike `StrongMeasurable.norm` and `StronglyMeasurable.nnnorm`, this lemma proves measurability, **not** strong measurability. This is an intentional decision: for functions taking values in ℝ≥0∞, measurability is much more useful than strong measurability. -/ @[fun_prop, measurability] protected theorem enorm {_ : MeasurableSpace α} {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] {f : α → ε} (hf : StronglyMeasurable f) : Measurable (‖f ·‖ₑ) := (continuous_enorm.comp_stronglyMeasurable hf).measurable @[fun_prop, measurability] protected theorem real_toNNReal {_ : MeasurableSpace α} {f : α → ℝ} (hf : StronglyMeasurable f) : StronglyMeasurable fun x => (f x).toNNReal := continuous_real_toNNReal.comp_stronglyMeasurable hf section PseudoMetrizableSpace variable {E : Type*} {m m₀ : MeasurableSpace α} {μ : Measure[m₀] α} {f g : α → E} [TopologicalSpace E] [Preorder E] [OrderClosedTopology E] [PseudoMetrizableSpace E] lemma measurableSet_le (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) : MeasurableSet[m] {a | f a ≤ g a} := by borelize (E × E) exact (hf.prodMk hg).measurable isClosed_le_prod.measurableSet lemma measurableSet_lt (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) : MeasurableSet[m] {a | f a < g a} := by simpa only [lt_iff_le_not_ge] using (hf.measurableSet_le hg).inter (hg.measurableSet_le hf).compl lemma ae_le_trim_of_stronglyMeasurable (hm : m ≤ m₀) (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) (hfg : f ≤ᵐ[μ] g) : f ≤ᵐ[μ.trim hm] g := by rwa [EventuallyLE, ae_iff, trim_measurableSet_eq hm] exact (hf.measurableSet_le hg).compl lemma ae_le_trim_iff (hm : m ≤ m₀) (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) : f ≤ᵐ[μ.trim hm] g ↔ f ≤ᵐ[μ] g := ⟨ae_le_of_ae_le_trim, ae_le_trim_of_stronglyMeasurable hm hf hg⟩ end PseudoMetrizableSpace section MetrizableSpace variable {E : Type*} {m m₀ : MeasurableSpace α} {μ : Measure[m₀] α} {f g : α → E} [TopologicalSpace E] [MetrizableSpace E] lemma measurableSet_eq_fun (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) : MeasurableSet[m] {a | f a = g a} := by borelize (E × E) exact (hf.prodMk hg).measurable isClosed_diagonal.measurableSet lemma ae_eq_trim_of_stronglyMeasurable (hm : m ≤ m₀) (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) (hfg : f =ᵐ[μ] g) : f =ᵐ[μ.trim hm] g := by rwa [EventuallyEq, ae_iff, trim_measurableSet_eq hm] exact (hf.measurableSet_eq_fun hg).compl lemma ae_eq_trim_iff (hm : m ≤ m₀) (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) : f =ᵐ[μ.trim hm] g ↔ f =ᵐ[μ] g := ⟨ae_eq_of_ae_eq_trim, ae_eq_trim_of_stronglyMeasurable hm hf hg⟩ end MetrizableSpace theorem stronglyMeasurable_in_set {m : MeasurableSpace α} [TopologicalSpace β] [Zero β] {s : Set α} {f : α → β} (hs : MeasurableSet s) (hf : StronglyMeasurable f) (hf_zero : ∀ x, x ∉ s → f x = 0) : ∃ fs : ℕ → α →ₛ β, (∀ x, Tendsto (fun n => fs n x) atTop (𝓝 (f x))) ∧ ∀ x ∉ s, ∀ n, fs n x = 0 := by let g_seq_s : ℕ → @SimpleFunc α m β := fun n => (hf.approx n).restrict s have hg_eq : ∀ x ∈ s, ∀ n, g_seq_s n x = hf.approx n x := by intro x hx n rw [SimpleFunc.coe_restrict _ hs, Set.indicator_of_mem hx] have hg_zero : ∀ x ∉ s, ∀ n, g_seq_s n x = 0 := by intro x hx n rw [SimpleFunc.coe_restrict _ hs, Set.indicator_of_notMem hx] refine ⟨g_seq_s, fun x => ?_, hg_zero⟩ by_cases hx : x ∈ s · simp_rw [hg_eq x hx] exact hf.tendsto_approx x · simp_rw [hg_zero x hx, hf_zero x hx] exact tendsto_const_nhds /-- If the restriction to a set `s` of a σ-algebra `m` is included in the restriction to `s` of another σ-algebra `m₂` (hypothesis `hs`), the set `s` is `m` measurable and a function `f` supported on `s` is `m`-strongly-measurable, then `f` is also `m₂`-strongly-measurable. -/ theorem stronglyMeasurable_of_measurableSpace_le_on {α E} {m m₂ : MeasurableSpace α} [TopologicalSpace E] [Zero E] {s : Set α} {f : α → E} (hs_m : MeasurableSet[m] s) (hs : ∀ t, MeasurableSet[m] (s ∩ t) → MeasurableSet[m₂] (s ∩ t)) (hf : StronglyMeasurable[m] f) (hf_zero : ∀ x ∉ s, f x = 0) : StronglyMeasurable[m₂] f := by have hs_m₂ : MeasurableSet[m₂] s := by rw [← Set.inter_univ s] refine hs Set.univ ?_ rwa [Set.inter_univ] obtain ⟨g_seq_s, hg_seq_tendsto, hg_seq_zero⟩ := stronglyMeasurable_in_set hs_m hf hf_zero let g_seq_s₂ : ℕ → @SimpleFunc α m₂ E := fun n => { toFun := g_seq_s n measurableSet_fiber' := fun x => by rw [← Set.inter_univ (g_seq_s n ⁻¹' {x}), ← Set.union_compl_self s, Set.inter_union_distrib_left, Set.inter_comm (g_seq_s n ⁻¹' {x})] refine MeasurableSet.union (hs _ (hs_m.inter ?_)) ?_ · exact @SimpleFunc.measurableSet_fiber _ _ m _ _ by_cases hx : x = 0 · suffices g_seq_s n ⁻¹' {x} ∩ sᶜ = sᶜ by rw [this] exact hs_m₂.compl ext1 y rw [hx, Set.mem_inter_iff, Set.mem_preimage, Set.mem_singleton_iff] exact ⟨fun h => h.2, fun h => ⟨hg_seq_zero y h n, h⟩⟩ · suffices g_seq_s n ⁻¹' {x} ∩ sᶜ = ∅ by rw [this] exact MeasurableSet.empty ext1 y simp only [mem_inter_iff, mem_preimage, mem_singleton_iff, mem_compl_iff, mem_empty_iff_false, iff_false, not_and, not_notMem] refine Function.mtr fun hys => ?_ rw [hg_seq_zero y hys n] exact Ne.symm hx finite_range' := @SimpleFunc.finite_range _ _ m (g_seq_s n) } exact ⟨g_seq_s₂, hg_seq_tendsto⟩ /-- If a function `f` is strongly measurable w.r.t. a sub-σ-algebra `m` and the measure is σ-finite on `m`, then there exists spanning measurable sets with finite measure on which `f` has bounded norm. In particular, `f` is integrable on each of those sets. -/ theorem exists_spanning_measurableSet_norm_le [SeminormedAddCommGroup β] {m m0 : MeasurableSpace α} (hm : m ≤ m0) (hf : StronglyMeasurable[m] f) (μ : Measure α) [SigmaFinite (μ.trim hm)] : ∃ s : ℕ → Set α, (∀ n, MeasurableSet[m] (s n) ∧ μ (s n) < ∞ ∧ ∀ x ∈ s n, ‖f x‖ ≤ n) ∧ ⋃ i, s i = Set.univ := by obtain ⟨s, hs, hs_univ⟩ := @exists_spanning_measurableSet_le _ m _ hf.nnnorm.measurable (μ.trim hm) _ refine ⟨s, fun n ↦ ⟨(hs n).1, (le_trim hm).trans_lt (hs n).2.1, fun x hx ↦ ?_⟩, hs_univ⟩ have hx_nnnorm : ‖f x‖₊ ≤ n := (hs n).2.2 x hx rw [← coe_nnnorm] norm_cast end StronglyMeasurable /-! ## Finitely strongly measurable functions -/ theorem finStronglyMeasurable_zero {α β} {m : MeasurableSpace α} {μ : Measure α} [Zero β] [TopologicalSpace β] : FinStronglyMeasurable (0 : α → β) μ := ⟨0, by simp only [Pi.zero_apply, SimpleFunc.coe_zero, support_zero, measure_empty, zero_lt_top, forall_const], fun _ => tendsto_const_nhds⟩ namespace FinStronglyMeasurable variable {m0 : MeasurableSpace α} {μ : Measure α} {f g : α → β} section sequence variable [Zero β] [TopologicalSpace β] (hf : FinStronglyMeasurable f μ) /-- A sequence of simple functions such that `∀ x, Tendsto (fun n ↦ hf.approx n x) atTop (𝓝 (f x))` and `∀ n, μ (support (hf.approx n)) < ∞`. These properties are given by `FinStronglyMeasurable.tendsto_approx` and `FinStronglyMeasurable.fin_support_approx`. -/ protected noncomputable def approx : ℕ → α →ₛ β := hf.choose protected theorem fin_support_approx : ∀ n, μ (support (hf.approx n)) < ∞ := hf.choose_spec.1 protected theorem tendsto_approx : ∀ x, Tendsto (fun n => hf.approx n x) atTop (𝓝 (f x)) := hf.choose_spec.2 end sequence /-- A finitely strongly measurable function is strongly measurable. -/ @[fun_prop] protected theorem stronglyMeasurable [Zero β] [TopologicalSpace β] (hf : FinStronglyMeasurable f μ) : StronglyMeasurable f := ⟨hf.approx, hf.tendsto_approx⟩ theorem exists_set_sigmaFinite [Zero β] [TopologicalSpace β] [T2Space β] (hf : FinStronglyMeasurable f μ) : ∃ t, MeasurableSet t ∧ (∀ x ∈ tᶜ, f x = 0) ∧ SigmaFinite (μ.restrict t) := by rcases hf with ⟨fs, hT_lt_top, h_approx⟩ let T n := support (fs n) have hT_meas : ∀ n, MeasurableSet (T n) := fun n => SimpleFunc.measurableSet_support (fs n) let t := ⋃ n, T n refine ⟨t, MeasurableSet.iUnion hT_meas, ?_, ?_⟩ · have h_fs_zero : ∀ n, ∀ x ∈ tᶜ, fs n x = 0 := by intro n x hxt rw [Set.mem_compl_iff, Set.mem_iUnion, not_exists] at hxt simpa [T] using hxt n refine fun x hxt => tendsto_nhds_unique (h_approx x) ?_ rw [funext fun n => h_fs_zero n x hxt] exact tendsto_const_nhds · refine ⟨⟨⟨fun n => tᶜ ∪ T n, fun _ => trivial, fun n => ?_, ?_⟩⟩⟩ · rw [Measure.restrict_apply' (MeasurableSet.iUnion hT_meas), Set.union_inter_distrib_right, Set.compl_inter_self t, Set.empty_union] exact (measure_mono Set.inter_subset_left).trans_lt (hT_lt_top n) · rw [← Set.union_iUnion tᶜ T] exact Set.compl_union_self _ /-- A finitely strongly measurable function is measurable. -/ protected theorem measurable [Zero β] [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] (hf : FinStronglyMeasurable f μ) : Measurable f := hf.stronglyMeasurable.measurable section Arithmetic variable [TopologicalSpace β] @[aesop safe 20 (rule_sets := [Measurable])] protected theorem mul [MulZeroClass β] [ContinuousMul β] (hf : FinStronglyMeasurable f μ) (hg : FinStronglyMeasurable g μ) : FinStronglyMeasurable (f * g) μ := by refine ⟨fun n => hf.approx n * hg.approx n, ?_, fun x => (hf.tendsto_approx x).mul (hg.tendsto_approx x)⟩ intro n exact (measure_mono (support_mul_subset_left _ _)).trans_lt (hf.fin_support_approx n) @[aesop safe 20 (rule_sets := [Measurable])] protected theorem add [AddZeroClass β] [ContinuousAdd β] (hf : FinStronglyMeasurable f μ) (hg : FinStronglyMeasurable g μ) : FinStronglyMeasurable (f + g) μ := ⟨fun n => hf.approx n + hg.approx n, fun n => (measure_mono (Function.support_add _ _)).trans_lt ((measure_union_le _ _).trans_lt (ENNReal.add_lt_top.mpr ⟨hf.fin_support_approx n, hg.fin_support_approx n⟩)), fun x => (hf.tendsto_approx x).add (hg.tendsto_approx x)⟩ @[measurability] protected theorem neg [SubtractionMonoid β] [ContinuousNeg β] (hf : FinStronglyMeasurable f μ) : FinStronglyMeasurable (-f) μ := by refine ⟨fun n ↦ -hf.approx n, fun n ↦ ?_, fun x ↦ (hf.tendsto_approx x).neg⟩ suffices μ (Function.support fun x ↦ -(hf.approx n) x) < ∞ by convert this rw [Function.support_fun_neg (hf.approx n)] exact hf.fin_support_approx n @[measurability] protected theorem sub [SubtractionMonoid β] [ContinuousSub β] (hf : FinStronglyMeasurable f μ) (hg : FinStronglyMeasurable g μ) : FinStronglyMeasurable (f - g) μ := ⟨fun n => hf.approx n - hg.approx n, fun n => (measure_mono (Function.support_sub _ _)).trans_lt ((measure_union_le _ _).trans_lt (ENNReal.add_lt_top.mpr ⟨hf.fin_support_approx n, hg.fin_support_approx n⟩)), fun x => (hf.tendsto_approx x).sub (hg.tendsto_approx x)⟩ @[measurability] protected theorem const_smul {𝕜} [TopologicalSpace 𝕜] [Zero β] [SMulZeroClass 𝕜 β] [ContinuousSMul 𝕜 β] (hf : FinStronglyMeasurable f μ) (c : 𝕜) : FinStronglyMeasurable (c • f) μ := by refine ⟨fun n => c • hf.approx n, fun n => ?_, fun x => (hf.tendsto_approx x).const_smul c⟩ rw [SimpleFunc.coe_smul] exact (measure_mono (support_const_smul_subset c _)).trans_lt (hf.fin_support_approx n) end Arithmetic section Order variable [TopologicalSpace β] [Zero β] @[aesop safe 20 (rule_sets := [Measurable])] protected theorem sup [SemilatticeSup β] [ContinuousSup β] (hf : FinStronglyMeasurable f μ) (hg : FinStronglyMeasurable g μ) : FinStronglyMeasurable (f ⊔ g) μ := by refine ⟨fun n => hf.approx n ⊔ hg.approx n, fun n => ?_, fun x => (hf.tendsto_approx x).sup_nhds (hg.tendsto_approx x)⟩ refine (measure_mono (support_sup _ _)).trans_lt ?_ exact measure_union_lt_top_iff.mpr ⟨hf.fin_support_approx n, hg.fin_support_approx n⟩ @[aesop safe 20 (rule_sets := [Measurable])] protected theorem inf [SemilatticeInf β] [ContinuousInf β] (hf : FinStronglyMeasurable f μ) (hg : FinStronglyMeasurable g μ) : FinStronglyMeasurable (f ⊓ g) μ := by refine ⟨fun n => hf.approx n ⊓ hg.approx n, fun n => ?_, fun x => (hf.tendsto_approx x).inf_nhds (hg.tendsto_approx x)⟩ refine (measure_mono (support_inf _ _)).trans_lt ?_ exact measure_union_lt_top_iff.mpr ⟨hf.fin_support_approx n, hg.fin_support_approx n⟩ end Order end FinStronglyMeasurable theorem finStronglyMeasurable_iff_stronglyMeasurable_and_exists_set_sigmaFinite {α β} {f : α → β} [TopologicalSpace β] [T2Space β] [Zero β] {_ : MeasurableSpace α} {μ : Measure α} : FinStronglyMeasurable f μ ↔ StronglyMeasurable f ∧ ∃ t, MeasurableSet t ∧ (∀ x ∈ tᶜ, f x = 0) ∧ SigmaFinite (μ.restrict t) := ⟨fun hf => ⟨hf.stronglyMeasurable, hf.exists_set_sigmaFinite⟩, fun hf => hf.1.finStronglyMeasurable_of_set_sigmaFinite hf.2.choose_spec.1 hf.2.choose_spec.2.1 hf.2.choose_spec.2.2⟩ section SecondCountableTopology variable {G : Type*} [SeminormedAddCommGroup G] [MeasurableSpace G] [BorelSpace G] [SecondCountableTopology G] {f : α → G} /-- In a space with second countable topology and a sigma-finite measure, `FinStronglyMeasurable` and `Measurable` are equivalent. -/ theorem finStronglyMeasurable_iff_measurable {_m0 : MeasurableSpace α} (μ : Measure α) [SigmaFinite μ] : FinStronglyMeasurable f μ ↔ Measurable f := ⟨fun h => h.measurable, fun h => (Measurable.stronglyMeasurable h).finStronglyMeasurable μ⟩ /-- In a space with second countable topology and a sigma-finite measure, a measurable function is `FinStronglyMeasurable`. -/ @[aesop 90% apply (rule_sets := [Measurable])] theorem finStronglyMeasurable_of_measurable {_m0 : MeasurableSpace α} (μ : Measure α) [SigmaFinite μ] (hf : Measurable f) : FinStronglyMeasurable f μ := (finStronglyMeasurable_iff_measurable μ).mpr hf end SecondCountableTopology theorem measurable_uncurry_of_continuous_of_measurable {α β ι : Type*} [TopologicalSpace ι] [MetrizableSpace ι] [MeasurableSpace ι] [SecondCountableTopology ι] [OpensMeasurableSpace ι] {mβ : MeasurableSpace β} [TopologicalSpace β] [PseudoMetrizableSpace β] [BorelSpace β] {m : MeasurableSpace α} {u : ι → α → β} (hu_cont : ∀ x, Continuous fun i => u i x) (h : ∀ i, Measurable (u i)) : Measurable (Function.uncurry u) := by obtain ⟨t_sf, ht_sf⟩ : ∃ t : ℕ → SimpleFunc ι ι, ∀ j x, Tendsto (fun n => u (t n j) x) atTop (𝓝 <| u j x) := by have h_str_meas : StronglyMeasurable (id : ι → ι) := stronglyMeasurable_id refine ⟨h_str_meas.approx, fun j x => ?_⟩ exact ((hu_cont x).tendsto j).comp (h_str_meas.tendsto_approx j) let U (n : ℕ) (p : ι × α) := u (t_sf n p.fst) p.snd have h_tendsto : Tendsto U atTop (𝓝 fun p => u p.fst p.snd) := by rw [tendsto_pi_nhds] exact fun p => ht_sf p.fst p.snd refine measurable_of_tendsto_metrizable (fun n => ?_) h_tendsto have h_meas : Measurable fun p : (t_sf n).range × α => u (↑p.fst) p.snd := by have : (fun p : ↥(t_sf n).range × α => u (↑p.fst) p.snd) = (fun p : α × (t_sf n).range => u (↑p.snd) p.fst) ∘ Prod.swap := rfl rw [this, @measurable_swap_iff α (↥(t_sf n).range) β m] exact measurable_from_prod_countable_left fun j => h j have : (fun p : ι × α => u (t_sf n p.fst) p.snd) = (fun p : ↥(t_sf n).range × α => u p.fst p.snd) ∘ fun p : ι × α => (⟨t_sf n p.fst, SimpleFunc.mem_range_self _ _⟩, p.snd) := rfl simp_rw [U, this] refine h_meas.comp (Measurable.prodMk ?_ measurable_snd) exact ((t_sf n).measurable.comp measurable_fst).subtype_mk theorem stronglyMeasurable_uncurry_of_continuous_of_stronglyMeasurable {α β ι : Type*} [TopologicalSpace ι] [MetrizableSpace ι] [MeasurableSpace ι] [SecondCountableTopology ι] [OpensMeasurableSpace ι] [TopologicalSpace β] [PseudoMetrizableSpace β] [MeasurableSpace α] {u : ι → α → β} (hu_cont : ∀ x, Continuous fun i => u i x) (h : ∀ i, StronglyMeasurable (u i)) : StronglyMeasurable (Function.uncurry u) := by borelize β obtain ⟨t_sf, ht_sf⟩ : ∃ t : ℕ → SimpleFunc ι ι, ∀ j x, Tendsto (fun n => u (t n j) x) atTop (𝓝 <| u j x) := by have h_str_meas : StronglyMeasurable (id : ι → ι) := stronglyMeasurable_id refine ⟨h_str_meas.approx, fun j x => ?_⟩ exact ((hu_cont x).tendsto j).comp (h_str_meas.tendsto_approx j) let U (n : ℕ) (p : ι × α) := u (t_sf n p.fst) p.snd have h_tendsto : Tendsto U atTop (𝓝 fun p => u p.fst p.snd) := by rw [tendsto_pi_nhds] exact fun p => ht_sf p.fst p.snd refine stronglyMeasurable_of_tendsto _ (fun n => ?_) h_tendsto have h_str_meas : StronglyMeasurable fun p : (t_sf n).range × α => u (↑p.fst) p.snd := by refine stronglyMeasurable_iff_measurable_separable.2 ⟨?_, ?_⟩ · have : (fun p : ↥(t_sf n).range × α => u (↑p.fst) p.snd) = (fun p : α × (t_sf n).range => u (↑p.snd) p.fst) ∘ Prod.swap := rfl rw [this, measurable_swap_iff] exact measurable_from_prod_countable_left fun j => (h j).measurable · have : IsSeparable (⋃ i : (t_sf n).range, range (u i)) := .iUnion fun i => (h i).isSeparable_range apply this.mono rintro _ ⟨⟨i, x⟩, rfl⟩ simp only [mem_iUnion, mem_range] exact ⟨i, x, rfl⟩ have : (fun p : ι × α => u (t_sf n p.fst) p.snd) = (fun p : ↥(t_sf n).range × α => u p.fst p.snd) ∘ fun p : ι × α => (⟨t_sf n p.fst, SimpleFunc.mem_range_self _ _⟩, p.snd) := rfl simp_rw [U, this] refine h_str_meas.comp_measurable (Measurable.prodMk ?_ measurable_snd) exact ((t_sf n).measurable.comp measurable_fst).subtype_mk end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/StronglyMeasurable/AEStronglyMeasurable.lean
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic /-! # Strongly measurable and finitely strongly measurable functions A function `f` is said to be almost everywhere strongly measurable if `f` is almost everywhere equal to a strongly measurable function, i.e. the sequential limit of simple functions. It is said to be almost everywhere finitely strongly measurable with respect to a measure `μ` if the supports of those simple functions have finite measure. Almost everywhere strongly measurable functions form the largest class of functions that can be integrated using the Bochner integral. ## Main definitions * `AEStronglyMeasurable f μ`: `f` is almost everywhere equal to a `StronglyMeasurable` function. * `AEFinStronglyMeasurable f μ`: `f` is almost everywhere equal to a `FinStronglyMeasurable` function. * `AEFinStronglyMeasurable.sigmaFiniteSet`: a measurable set `t` such that `f =ᵐ[μ.restrict tᶜ] 0` and `μ.restrict t` is sigma-finite. ## Main statements * `AEFinStronglyMeasurable.exists_set_sigmaFinite`: there exists a measurable set `t` such that `f =ᵐ[μ.restrict tᶜ] 0` and `μ.restrict t` is sigma-finite. We provide a solid API for almost everywhere strongly measurable functions, as a basis for the Bochner integral. ## References * [Hytönen, Tuomas, Jan Van Neerven, Mark Veraar, and Lutz Weis. Analysis in Banach spaces. Springer, 2016.][Hytonen_VanNeerven_Veraar_Wies_2016] -/ open MeasureTheory Filter TopologicalSpace Function Set MeasureTheory.Measure open ENNReal Topology MeasureTheory NNReal variable {α β γ ι : Type*} [Countable ι] namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc section Definitions variable [TopologicalSpace β] /-- A function is `AEStronglyMeasurable` with respect to a measure `μ` if it is almost everywhere equal to the limit of a sequence of simple functions. One can specify the sigma-algebra according to which simple functions are taken using the `AEStronglyMeasurable[m]` notation in the `MeasureTheory` scope. -/ @[fun_prop] def AEStronglyMeasurable [m : MeasurableSpace α] {m₀ : MeasurableSpace α} (f : α → β) (μ : Measure[m₀] α := by volume_tac) : Prop := ∃ g : α → β, StronglyMeasurable[m] g ∧ f =ᵐ[μ] g add_aesop_rules safe tactic (rule_sets := [Measurable]) (index := [target @AEStronglyMeasurable ..]) (by fun_prop (disch := measurability)) /-- A function is `m`-`AEStronglyMeasurable` with respect to a measure `μ` if it is almost everywhere equal to the limit of a sequence of `m`-simple functions. -/ scoped notation "AEStronglyMeasurable[" m "]" => @MeasureTheory.AEStronglyMeasurable _ _ _ m /-- A function is `AEFinStronglyMeasurable` with respect to a measure if it is almost everywhere equal to the limit of a sequence of simple functions with support with finite measure. -/ def AEFinStronglyMeasurable [Zero β] {_ : MeasurableSpace α} (f : α → β) (μ : Measure α := by volume_tac) : Prop := ∃ g, FinStronglyMeasurable g μ ∧ f =ᵐ[μ] g end Definitions namespace FinStronglyMeasurable variable {m0 : MeasurableSpace α} {μ : Measure α} {f g : α → β} theorem aefinStronglyMeasurable [Zero β] [TopologicalSpace β] (hf : FinStronglyMeasurable f μ) : AEFinStronglyMeasurable f μ := ⟨f, hf, ae_eq_refl f⟩ end FinStronglyMeasurable theorem aefinStronglyMeasurable_zero {α β} {_ : MeasurableSpace α} (μ : Measure α) [Zero β] [TopologicalSpace β] : AEFinStronglyMeasurable (0 : α → β) μ := ⟨0, finStronglyMeasurable_zero, EventuallyEq.rfl⟩ /-! ## Almost everywhere strongly measurable functions -/ section AEStronglyMeasurable variable [TopologicalSpace β] [TopologicalSpace γ] {m m₀ : MeasurableSpace α} {μ ν : Measure[m₀] α} {f g : α → β} @[fun_prop] protected theorem StronglyMeasurable.aestronglyMeasurable (hf : StronglyMeasurable[m] f) : AEStronglyMeasurable[m] f μ := ⟨f, hf, EventuallyEq.refl _ _⟩ @[fun_prop, measurability] theorem aestronglyMeasurable_const {b : β} : AEStronglyMeasurable[m] (fun _ : α => b) μ := stronglyMeasurable_const.aestronglyMeasurable @[to_additive (attr := fun_prop, measurability)] theorem aestronglyMeasurable_one [One β] : AEStronglyMeasurable[m] (1 : α → β) μ := stronglyMeasurable_one.aestronglyMeasurable @[simp, nontriviality] lemma AEStronglyMeasurable.of_subsingleton_dom [Subsingleton α] : AEStronglyMeasurable[m] f μ := StronglyMeasurable.of_subsingleton_dom.aestronglyMeasurable @[simp, nontriviality] lemma AEStronglyMeasurable.of_subsingleton_cod [Subsingleton β] : AEStronglyMeasurable[m] f μ := StronglyMeasurable.of_subsingleton_cod.aestronglyMeasurable @[fun_prop, simp] theorem aestronglyMeasurable_zero_measure (f : α → β) : AEStronglyMeasurable[m] f (0 : Measure[m₀] α) := by nontriviality α inhabit α exact ⟨fun _ => f default, stronglyMeasurable_const, rfl⟩ @[fun_prop, measurability] theorem SimpleFunc.aestronglyMeasurable (f : α →ₛ β) : AEStronglyMeasurable f μ := f.stronglyMeasurable.aestronglyMeasurable namespace AEStronglyMeasurable @[fun_prop] lemma of_discrete [Countable α] [MeasurableSingletonClass α] : AEStronglyMeasurable f μ := StronglyMeasurable.of_discrete.aestronglyMeasurable section Mk /-- A `StronglyMeasurable` function such that `f =ᵐ[μ] hf.mk f`. See lemmas `stronglyMeasurable_mk` and `ae_eq_mk`. -/ protected noncomputable def mk (f : α → β) (hf : AEStronglyMeasurable[m] f μ) : α → β := hf.choose @[fun_prop] lemma stronglyMeasurable_mk (hf : AEStronglyMeasurable[m] f μ) : StronglyMeasurable[m] (hf.mk f) := hf.choose_spec.1 @[fun_prop] theorem measurable_mk [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] (hf : AEStronglyMeasurable[m] f μ) : Measurable[m] (hf.mk f) := hf.stronglyMeasurable_mk.measurable theorem ae_eq_mk (hf : AEStronglyMeasurable[m] f μ) : f =ᵐ[μ] hf.mk f := hf.choose_spec.2 @[fun_prop] protected theorem aemeasurable {β} [MeasurableSpace β] [TopologicalSpace β] [PseudoMetrizableSpace β] [BorelSpace β] {f : α → β} (hf : AEStronglyMeasurable f μ) : AEMeasurable f μ := ⟨hf.mk f, hf.stronglyMeasurable_mk.measurable, hf.ae_eq_mk⟩ end Mk theorem congr (hf : AEStronglyMeasurable[m] f μ) (h : f =ᵐ[μ] g) : AEStronglyMeasurable[m] g μ := ⟨hf.mk f, hf.stronglyMeasurable_mk, h.symm.trans hf.ae_eq_mk⟩ theorem _root_.aestronglyMeasurable_congr (h : f =ᵐ[μ] g) : AEStronglyMeasurable[m] f μ ↔ AEStronglyMeasurable[m] g μ := ⟨fun hf => hf.congr h, fun hg => hg.congr h.symm⟩ theorem mono_measure {ν : Measure α} (hf : AEStronglyMeasurable[m] f μ) (h : ν ≤ μ) : AEStronglyMeasurable[m] f ν := ⟨hf.mk f, hf.stronglyMeasurable_mk, Eventually.filter_mono (ae_mono h) hf.ae_eq_mk⟩ protected lemma mono_ac (h : ν ≪ μ) (hμ : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] f ν := let ⟨g, hg, hg'⟩ := hμ; ⟨g, hg, h.ae_eq hg'⟩ theorem mono_set {s t} (h : s ⊆ t) (ht : AEStronglyMeasurable[m] f (μ.restrict t)) : AEStronglyMeasurable[m] f (μ.restrict s) := ht.mono_measure (restrict_mono h le_rfl) lemma mono {m'} (hm : m ≤ m') (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m'] f μ := let ⟨f', hf'_meas, hff'⟩ := hf; ⟨f', hf'_meas.mono hm, hff'⟩ lemma of_trim {m₀' : MeasurableSpace α} (hm₀ : m₀' ≤ m₀) (hf : AEStronglyMeasurable[m] f (μ.trim hm₀)) : AEStronglyMeasurable[m] f μ := by obtain ⟨g, hg_meas, hfg⟩ := hf; exact ⟨g, hg_meas, ae_eq_of_ae_eq_trim hfg⟩ @[fun_prop] protected theorem restrict (hfm : AEStronglyMeasurable[m] f μ) {s} : AEStronglyMeasurable[m] f (μ.restrict s) := hfm.mono_measure Measure.restrict_le_self theorem ae_mem_imp_eq_mk {s} (h : AEStronglyMeasurable[m] f (μ.restrict s)) : ∀ᵐ x ∂μ, x ∈ s → f x = h.mk f x := ae_imp_of_ae_restrict h.ae_eq_mk /-- The composition of a continuous function and an ae strongly measurable function is ae strongly measurable. -/ @[fun_prop] theorem _root_.Continuous.comp_aestronglyMeasurable {g : β → γ} {f : α → β} (hg : Continuous g) (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (fun x => g (f x)) μ := ⟨_, hg.comp_stronglyMeasurable hf.stronglyMeasurable_mk, EventuallyEq.fun_comp hf.ae_eq_mk g⟩ /-- A continuous function from `α` to `β` is ae strongly measurable when one of the two spaces is second countable. -/ @[fun_prop] theorem _root_.Continuous.aestronglyMeasurable [TopologicalSpace α] [OpensMeasurableSpace α] [PseudoMetrizableSpace β] [SecondCountableTopologyEither α β] (hf : Continuous f) : AEStronglyMeasurable f μ := hf.stronglyMeasurable.aestronglyMeasurable @[fun_prop] protected theorem fst {f : α → β × γ} (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (fun x ↦ (f x).1) μ := continuous_fst.comp_aestronglyMeasurable hf @[fun_prop] protected theorem snd {f : α → β × γ} (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (fun x ↦ (f x).2) μ := continuous_snd.comp_aestronglyMeasurable hf @[fun_prop] protected theorem prodMk {f : α → β} {g : α → γ} (hf : AEStronglyMeasurable[m] f μ) (hg : AEStronglyMeasurable[m] g μ) : AEStronglyMeasurable[m] (fun x => (f x, g x)) μ := ⟨fun x => (hf.mk f x, hg.mk g x), hf.stronglyMeasurable_mk.prodMk hg.stronglyMeasurable_mk, hf.ae_eq_mk.prodMk hg.ae_eq_mk⟩ /-- The composition of a continuous function of two variables and two ae strongly measurable functions is ae strongly measurable. -/ theorem _root_.Continuous.comp_aestronglyMeasurable₂ {β' : Type*} [TopologicalSpace β'] {g : β → β' → γ} {f : α → β} {f' : α → β'} (hg : Continuous g.uncurry) (hf : AEStronglyMeasurable[m] f μ) (h'f : AEStronglyMeasurable[m] f' μ) : AEStronglyMeasurable[m] (fun x => g (f x) (f' x)) μ := hg.comp_aestronglyMeasurable (hf.prodMk h'f) /-- In a space with second countable topology, measurable implies ae strongly measurable. -/ @[fun_prop] theorem _root_.Measurable.aestronglyMeasurable [MeasurableSpace β] [PseudoMetrizableSpace β] [SecondCountableTopology β] [OpensMeasurableSpace β] (hf : Measurable[m] f) : AEStronglyMeasurable[m] f μ := hf.stronglyMeasurable.aestronglyMeasurable /-- If the restriction to a set `s` of a σ-algebra `m` is included in the restriction to `s` of another σ-algebra `m₂` (hypothesis `hs`), the set `s` is `m` measurable and a function `f` almost everywhere supported on `s` is `m`-ae-strongly-measurable, then `f` is also `m₂`-ae-strongly-measurable. -/ lemma of_measurableSpace_le_on {m' m₀ : MeasurableSpace α} {μ : Measure[m₀] α} [Zero β] (hm : m ≤ m₀) {s : Set α} (hs_m : MeasurableSet[m] s) (hs : ∀ t, MeasurableSet[m] (s ∩ t) → MeasurableSet[m'] (s ∩ t)) (hf : AEStronglyMeasurable[m] f μ) (hf_zero : f =ᵐ[μ.restrict sᶜ] 0) : AEStronglyMeasurable[m'] f μ := by have h_ind_eq : s.indicator (hf.mk f) =ᵐ[μ] f := by refine Filter.EventuallyEq.trans ?_ <| indicator_ae_eq_of_restrict_compl_ae_eq_zero (hm _ hs_m) hf_zero filter_upwards [hf.ae_eq_mk] with x hx by_cases hxs : x ∈ s · simp [hxs, hx] · simp [hxs] suffices StronglyMeasurable[m'] (s.indicator (hf.mk f)) from this.aestronglyMeasurable.congr h_ind_eq exact (hf.stronglyMeasurable_mk.indicator hs_m).stronglyMeasurable_of_measurableSpace_le_on hs_m hs fun x hxs => Set.indicator_of_notMem hxs _ section Arithmetic @[to_additive (attr := fun_prop)] protected theorem mul [Mul β] [ContinuousMul β] (hf : AEStronglyMeasurable[m] f μ) (hg : AEStronglyMeasurable[m] g μ) : AEStronglyMeasurable[m] (f * g) μ := ⟨hf.mk f * hg.mk g, by fun_prop, hf.ae_eq_mk.mul hg.ae_eq_mk⟩ @[to_additive (attr := fun_prop, measurability)] protected theorem mul_const [Mul β] [ContinuousMul β] (hf : AEStronglyMeasurable[m] f μ) (c : β) : AEStronglyMeasurable[m] (fun x => f x * c) μ := hf.mul aestronglyMeasurable_const @[to_additive (attr := fun_prop, measurability)] protected theorem const_mul [Mul β] [ContinuousMul β] (hf : AEStronglyMeasurable[m] f μ) (c : β) : AEStronglyMeasurable[m] (fun x => c * f x) μ := aestronglyMeasurable_const.mul hf @[to_additive (attr := fun_prop, measurability)] protected theorem inv [Inv β] [ContinuousInv β] (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] f⁻¹ μ := ⟨(hf.mk f)⁻¹, hf.stronglyMeasurable_mk.inv, hf.ae_eq_mk.inv⟩ @[to_additive (attr := fun_prop)] protected theorem div [Group β] [IsTopologicalGroup β] (hf : AEStronglyMeasurable[m] f μ) (hg : AEStronglyMeasurable[m] g μ) : AEStronglyMeasurable[m] (f / g) μ := ⟨hf.mk f / hg.mk g, hf.stronglyMeasurable_mk.div hg.stronglyMeasurable_mk, hf.ae_eq_mk.div hg.ae_eq_mk⟩ @[to_additive] theorem mul_iff_right [CommGroup β] [IsTopologicalGroup β] (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (f * g) μ ↔ AEStronglyMeasurable[m] g μ := ⟨fun h ↦ show g = f * g * f⁻¹ by simp only [mul_inv_cancel_comm] ▸ h.mul hf.inv, fun h ↦ hf.mul h⟩ @[to_additive] theorem mul_iff_left [CommGroup β] [IsTopologicalGroup β] (hf : AEStronglyMeasurable[m] f μ) : AEStronglyMeasurable[m] (g * f) μ ↔ AEStronglyMeasurable[m] g μ := mul_comm g f ▸ AEStronglyMeasurable.mul_iff_right hf @[to_additive (attr := fun_prop)] protected theorem smul {𝕜} [TopologicalSpace 𝕜] [SMul 𝕜 β] [ContinuousSMul 𝕜 β] {f : α → 𝕜} {g : α → β} (hf : AEStronglyMeasurable[m] f μ) (hg : AEStronglyMeasurable[m] g μ) : AEStronglyMeasurable[m] (fun x => f x • g x) μ := continuous_smul.comp_aestronglyMeasurable (hf.prodMk hg) @[to_additive (attr := fun_prop) const_nsmul] protected theorem pow [Monoid β] [ContinuousMul β] (hf : AEStronglyMeasurable[m] f μ) (n : ℕ) : AEStronglyMeasurable[m] (f ^ n) μ := ⟨hf.mk f ^ n, hf.stronglyMeasurable_mk.pow _, hf.ae_eq_mk.pow_const _⟩ @[to_additive (attr := fun_prop, measurability)] protected theorem const_smul {𝕜} [SMul 𝕜 β] [ContinuousConstSMul 𝕜 β] (hf : AEStronglyMeasurable[m] f μ) (c : 𝕜) : AEStronglyMeasurable[m] (c • f) μ := ⟨c • hf.mk f, hf.stronglyMeasurable_mk.const_smul c, hf.ae_eq_mk.const_smul c⟩ @[to_additive (attr := fun_prop, measurability)] protected theorem const_smul' {𝕜} [SMul 𝕜 β] [ContinuousConstSMul 𝕜 β] (hf : AEStronglyMeasurable[m] f μ) (c : 𝕜) : AEStronglyMeasurable[m] (fun x => c • f x) μ := hf.const_smul c @[to_additive (attr := fun_prop, measurability)] protected theorem smul_const {𝕜} [TopologicalSpace 𝕜] [SMul 𝕜 β] [ContinuousSMul 𝕜 β] {f : α → 𝕜} (hf : AEStronglyMeasurable[m] f μ) (c : β) : AEStronglyMeasurable[m] (fun x => f x • c) μ := continuous_smul.comp_aestronglyMeasurable (hf.prodMk aestronglyMeasurable_const) end Arithmetic section Star @[fun_prop, measurability] protected theorem star {R : Type*} [TopologicalSpace R] [Star R] [ContinuousStar R] {f : α → R} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (star f) μ := ⟨star (hf.mk f), hf.stronglyMeasurable_mk.star, hf.ae_eq_mk.star⟩ end Star section Order @[fun_prop] protected theorem sup [SemilatticeSup β] [ContinuousSup β] (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : AEStronglyMeasurable (f ⊔ g) μ := ⟨hf.mk f ⊔ hg.mk g, hf.stronglyMeasurable_mk.sup hg.stronglyMeasurable_mk, hf.ae_eq_mk.sup hg.ae_eq_mk⟩ @[fun_prop] protected theorem inf [SemilatticeInf β] [ContinuousInf β] (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : AEStronglyMeasurable (f ⊓ g) μ := ⟨hf.mk f ⊓ hg.mk g, hf.stronglyMeasurable_mk.inf hg.stronglyMeasurable_mk, hf.ae_eq_mk.inf hg.ae_eq_mk⟩ end Order /-! ### Big operators: `∏` and `∑` -/ section Monoid variable {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M] @[to_additive (attr := fun_prop, measurability)] theorem _root_.List.aestronglyMeasurable_prod (l : List (α → M)) (hl : ∀ f ∈ l, AEStronglyMeasurable f μ) : AEStronglyMeasurable l.prod μ := by induction l with | nil => exact aestronglyMeasurable_one | cons f l ihl => rw [List.forall_mem_cons] at hl rw [List.prod_cons] exact hl.1.mul (ihl hl.2) @[deprecated (since := "2025-05-30")] alias _root_.List.aestronglyMeasurable_sum' := List.aestronglyMeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias _root_.List.aestronglyMeasurable_prod' := List.aestronglyMeasurable_prod @[to_additive (attr := fun_prop, measurability)] theorem _root_.List.aestronglyMeasurable_fun_prod (l : List (α → M)) (hl : ∀ f ∈ l, AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun x => (l.map fun f : α → M => f x).prod) μ := by simpa only [← Pi.list_prod_apply] using l.aestronglyMeasurable_prod hl end Monoid section CommMonoid variable {M : Type*} [CommMonoid M] [TopologicalSpace M] [ContinuousMul M] @[to_additive (attr := fun_prop, measurability)] theorem _root_.Multiset.aestronglyMeasurable_prod (l : Multiset (α → M)) (hl : ∀ f ∈ l, AEStronglyMeasurable f μ) : AEStronglyMeasurable l.prod μ := by rcases l with ⟨l⟩ simpa using l.aestronglyMeasurable_prod (by simpa using hl) @[deprecated (since := "2025-05-30")] alias _root_.Multiset.aestronglyMeasurable_sum' := Multiset.aestronglyMeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias _root_.Multiset.aestronglyMeasurable_prod' := Multiset.aestronglyMeasurable_prod @[to_additive (attr := fun_prop, measurability)] theorem _root_.Multiset.aestronglyMeasurable_fun_prod (s : Multiset (α → M)) (hs : ∀ f ∈ s, AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun x => (s.map fun f : α → M => f x).prod) μ := by simpa only [← Pi.multiset_prod_apply] using s.aestronglyMeasurable_prod hs @[to_additive (attr := fun_prop, measurability)] theorem _root_.Finset.aestronglyMeasurable_prod {ι : Type*} {f : ι → α → M} (s : Finset ι) (hf : ∀ i ∈ s, AEStronglyMeasurable (f i) μ) : AEStronglyMeasurable (∏ i ∈ s, f i) μ := Multiset.aestronglyMeasurable_prod _ fun _g hg => let ⟨_i, hi, hg⟩ := Multiset.mem_map.1 hg hg ▸ hf _ hi @[deprecated (since := "2025-05-30")] alias _root_.Finset.aestronglyMeasurable_sum' := Finset.aestronglyMeasurable_sum @[to_additive existing, deprecated (since := "2025-05-30")] alias _root_.Finset.aestronglyMeasurable_prod' := Finset.aestronglyMeasurable_prod @[to_additive (attr := fun_prop, measurability)] theorem _root_.Finset.aestronglyMeasurable_fun_prod {ι : Type*} {f : ι → α → M} (s : Finset ι) (hf : ∀ i ∈ s, AEStronglyMeasurable (f i) μ) : AEStronglyMeasurable (fun a => ∏ i ∈ s, f i a) μ := by simpa only [← Finset.prod_apply] using s.aestronglyMeasurable_prod hf end CommMonoid section SecondCountableAEStronglyMeasurable variable [MeasurableSpace β] /-- In a space with second countable topology, measurable implies strongly measurable. -/ @[fun_prop] theorem _root_.AEMeasurable.aestronglyMeasurable [PseudoMetrizableSpace β] [OpensMeasurableSpace β] [SecondCountableTopology β] (hf : AEMeasurable f μ) : AEStronglyMeasurable f μ := ⟨hf.mk f, hf.measurable_mk.stronglyMeasurable, hf.ae_eq_mk⟩ @[fun_prop, measurability] theorem _root_.aestronglyMeasurable_id {α : Type*} [TopologicalSpace α] [PseudoMetrizableSpace α] {_ : MeasurableSpace α} [OpensMeasurableSpace α] [SecondCountableTopology α] {μ : Measure α} : AEStronglyMeasurable (id : α → α) μ := aemeasurable_id.aestronglyMeasurable /-- In a space with second countable topology, strongly measurable and measurable are equivalent. -/ theorem _root_.aestronglyMeasurable_iff_aemeasurable [PseudoMetrizableSpace β] [BorelSpace β] [SecondCountableTopology β] : AEStronglyMeasurable f μ ↔ AEMeasurable f μ := ⟨fun h => h.aemeasurable, fun h => h.aestronglyMeasurable⟩ end SecondCountableAEStronglyMeasurable @[fun_prop] protected theorem dist {β : Type*} [PseudoMetricSpace β] {f g : α → β} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : AEStronglyMeasurable (fun x => dist (f x) (g x)) μ := continuous_dist.comp_aestronglyMeasurable (hf.prodMk hg) @[fun_prop, measurability] protected theorem norm {β : Type*} [SeminormedAddCommGroup β] {f : α → β} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun x => ‖f x‖) μ := continuous_norm.comp_aestronglyMeasurable hf @[fun_prop, measurability] protected theorem nnnorm {β : Type*} [SeminormedAddCommGroup β] {f : α → β} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun x => ‖f x‖₊) μ := continuous_nnnorm.comp_aestronglyMeasurable hf /-- The `enorm` of a strongly a.e. measurable function is a.e. measurable. Note that unlike `AEStronglyMeasurable.norm` and `AEStronglyMeasurable.nnnorm`, this lemma proves a.e. measurability, **not** a.e. strong measurability. This is an intentional decision: for functions taking values in `ℝ≥0∞`, a.e. measurability is much more useful than a.e. strong measurability. -/ @[fun_prop, measurability] protected theorem enorm {β : Type*} [TopologicalSpace β] [ContinuousENorm β] {f : α → β} (hf : AEStronglyMeasurable f μ) : AEMeasurable (‖f ·‖ₑ) μ := (continuous_enorm.comp_aestronglyMeasurable hf).aemeasurable /-- Given a.e. strongly measurable functions `f` and `g`, `edist f g` is measurable. Note that this lemma proves a.e. measurability, **not** a.e. strong measurability. This is an intentional decision: for functions taking values in ℝ≥0∞, a.e. measurability is much more useful than a.e. strong measurability. -/ @[fun_prop] protected theorem edist {β : Type*} [PseudoMetricSpace β] {f g : α → β} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : AEMeasurable (fun a => edist (f a) (g a)) μ := (continuous_edist.comp_aestronglyMeasurable (hf.prodMk hg)).aemeasurable @[fun_prop, measurability] protected theorem real_toNNReal {f : α → ℝ} (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun x => (f x).toNNReal) μ := continuous_real_toNNReal.comp_aestronglyMeasurable hf theorem _root_.aestronglyMeasurable_indicator_iff [Zero β] {s : Set α} (hs : MeasurableSet s) : AEStronglyMeasurable (indicator s f) μ ↔ AEStronglyMeasurable f (μ.restrict s) := by constructor · intro h exact (h.mono_measure Measure.restrict_le_self).congr (indicator_ae_eq_restrict hs) · intro h refine ⟨indicator s (h.mk f), h.stronglyMeasurable_mk.indicator hs, ?_⟩ have A : s.indicator f =ᵐ[μ.restrict s] s.indicator (h.mk f) := (indicator_ae_eq_restrict hs).trans (h.ae_eq_mk.trans <| (indicator_ae_eq_restrict hs).symm) have B : s.indicator f =ᵐ[μ.restrict sᶜ] s.indicator (h.mk f) := (indicator_ae_eq_restrict_compl hs).trans (indicator_ae_eq_restrict_compl hs).symm exact ae_of_ae_restrict_of_ae_restrict_compl _ A B theorem _root_.aestronglyMeasurable_indicator_iff₀ [Zero β] {s : Set α} (hs : NullMeasurableSet s μ) : AEStronglyMeasurable (indicator s f) μ ↔ AEStronglyMeasurable f (μ.restrict s) := by rw [← aestronglyMeasurable_congr (indicator_ae_eq_of_ae_eq_set hs.toMeasurable_ae_eq), aestronglyMeasurable_indicator_iff (measurableSet_toMeasurable ..), restrict_congr_set hs.toMeasurable_ae_eq] @[fun_prop, measurability] protected theorem indicator [Zero β] (hfm : AEStronglyMeasurable f μ) {s : Set α} (hs : MeasurableSet s) : AEStronglyMeasurable (s.indicator f) μ := (aestronglyMeasurable_indicator_iff hs).mpr hfm.restrict @[fun_prop, measurability] protected theorem indicator₀ [Zero β] (hfm : AEStronglyMeasurable f μ) {s : Set α} (hs : NullMeasurableSet s μ) : AEStronglyMeasurable (s.indicator f) μ := (aestronglyMeasurable_indicator_iff₀ hs).2 hfm.restrict theorem nullMeasurableSet_eq_fun {E} [TopologicalSpace E] [MetrizableSpace E] {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : NullMeasurableSet { x | f x = g x } μ := by apply (hf.stronglyMeasurable_mk.measurableSet_eq_fun hg.stronglyMeasurable_mk).nullMeasurableSet.congr filter_upwards [hf.ae_eq_mk, hg.ae_eq_mk] with x hfx hgx change (hf.mk f x = hg.mk g x) = (f x = g x) simp only [hfx, hgx] @[to_additive] lemma nullMeasurableSet_mulSupport {E} [TopologicalSpace E] [MetrizableSpace E] [One E] {f : α → E} (hf : AEStronglyMeasurable f μ) : NullMeasurableSet (mulSupport f) μ := (hf.nullMeasurableSet_eq_fun stronglyMeasurable_const.aestronglyMeasurable).compl theorem nullMeasurableSet_lt [Preorder β] [OrderClosedTopology β] [PseudoMetrizableSpace β] {f g : α → β} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : NullMeasurableSet { a | f a < g a } μ := by apply (hf.stronglyMeasurable_mk.measurableSet_lt hg.stronglyMeasurable_mk).nullMeasurableSet.congr filter_upwards [hf.ae_eq_mk, hg.ae_eq_mk] with x hfx hgx change (hf.mk f x < hg.mk g x) = (f x < g x) simp only [hfx, hgx] theorem nullMeasurableSet_le [Preorder β] [OrderClosedTopology β] [PseudoMetrizableSpace β] {f g : α → β} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) : NullMeasurableSet { a | f a ≤ g a } μ := by apply (hf.stronglyMeasurable_mk.measurableSet_le hg.stronglyMeasurable_mk).nullMeasurableSet.congr filter_upwards [hf.ae_eq_mk, hg.ae_eq_mk] with x hfx hgx change (hf.mk f x ≤ hg.mk g x) = (f x ≤ g x) simp only [hfx, hgx] theorem _root_.aestronglyMeasurable_of_aestronglyMeasurable_trim {α} {m m0 : MeasurableSpace α} {μ : Measure α} (hm : m ≤ m0) {f : α → β} (hf : AEStronglyMeasurable[m] f (μ.trim hm)) : AEStronglyMeasurable f μ := ⟨hf.mk f, StronglyMeasurable.mono hf.stronglyMeasurable_mk hm, ae_eq_of_ae_eq_trim hf.ae_eq_mk⟩ theorem comp_aemeasurable {γ : Type*} {_ : MeasurableSpace γ} {_ : MeasurableSpace α} {f : γ → α} {μ : Measure γ} (hg : AEStronglyMeasurable g (Measure.map f μ)) (hf : AEMeasurable f μ) : AEStronglyMeasurable (g ∘ f) μ := ⟨hg.mk g ∘ hf.mk f, hg.stronglyMeasurable_mk.comp_measurable hf.measurable_mk, (ae_eq_comp hf hg.ae_eq_mk).trans (hf.ae_eq_mk.fun_comp (hg.mk g))⟩ theorem comp_measurable {γ : Type*} {_ : MeasurableSpace γ} {_ : MeasurableSpace α} {f : γ → α} {μ : Measure γ} (hg : AEStronglyMeasurable g (Measure.map f μ)) (hf : Measurable f) : AEStronglyMeasurable (g ∘ f) μ := hg.comp_aemeasurable hf.aemeasurable theorem comp_quasiMeasurePreserving {γ : Type*} {_ : MeasurableSpace γ} {_ : MeasurableSpace α} {f : γ → α} {μ : Measure γ} {ν : Measure α} (hg : AEStronglyMeasurable g ν) (hf : QuasiMeasurePreserving f μ ν) : AEStronglyMeasurable (g ∘ f) μ := (hg.mono_ac hf.absolutelyContinuous).comp_measurable hf.measurable theorem isSeparable_ae_range (hf : AEStronglyMeasurable f μ) : ∃ t : Set β, IsSeparable t ∧ ∀ᵐ x ∂μ, f x ∈ t := by refine ⟨range (hf.mk f), hf.stronglyMeasurable_mk.isSeparable_range, ?_⟩ filter_upwards [hf.ae_eq_mk] with x hx simp [hx] /-- A function is almost everywhere strongly measurable if and only if it is almost everywhere measurable, and up to a zero measure set its range is contained in a separable set. -/ theorem _root_.aestronglyMeasurable_iff_aemeasurable_separable [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] : AEStronglyMeasurable f μ ↔ AEMeasurable f μ ∧ ∃ t : Set β, IsSeparable t ∧ ∀ᵐ x ∂μ, f x ∈ t := by refine ⟨fun H => ⟨H.aemeasurable, H.isSeparable_ae_range⟩, ?_⟩ rintro ⟨H, ⟨t, t_sep, ht⟩⟩ rcases eq_empty_or_nonempty t with (rfl | h₀) · simp only [mem_empty_iff_false, eventually_false_iff_eq_bot, ae_eq_bot] at ht rw [ht] exact aestronglyMeasurable_zero_measure f · obtain ⟨g, g_meas, gt, fg⟩ : ∃ g : α → β, Measurable g ∧ range g ⊆ t ∧ f =ᵐ[μ] g := H.exists_ae_eq_range_subset ht h₀ refine ⟨g, ?_, fg⟩ exact stronglyMeasurable_iff_measurable_separable.2 ⟨g_meas, t_sep.mono gt⟩ theorem _root_.aestronglyMeasurable_iff_nullMeasurable_separable [PseudoMetrizableSpace β] [MeasurableSpace β] [BorelSpace β] : AEStronglyMeasurable f μ ↔ NullMeasurable f μ ∧ ∃ t : Set β, IsSeparable t ∧ ∀ᵐ x ∂μ, f x ∈ t := aestronglyMeasurable_iff_aemeasurable_separable.trans <| and_congr_left fun ⟨_, hsep, h⟩ ↦ have := hsep.secondCountableTopology ⟨AEMeasurable.nullMeasurable, fun hf ↦ hf.aemeasurable_of_aerange h⟩ theorem _root_.MeasurableEmbedding.aestronglyMeasurable_map_iff {γ : Type*} {mγ : MeasurableSpace γ} {mα : MeasurableSpace α} {f : γ → α} {μ : Measure γ} (hf : MeasurableEmbedding f) {g : α → β} : AEStronglyMeasurable g (Measure.map f μ) ↔ AEStronglyMeasurable (g ∘ f) μ := by refine ⟨fun H => H.comp_measurable hf.measurable, ?_⟩ rintro ⟨g₁, hgm₁, heq⟩ rcases hf.exists_stronglyMeasurable_extend hgm₁ fun x => ⟨g x⟩ with ⟨g₂, hgm₂, rfl⟩ exact ⟨g₂, hgm₂, hf.ae_map_iff.2 heq⟩ theorem _root_.Topology.IsEmbedding.aestronglyMeasurable_comp_iff [PseudoMetrizableSpace β] [PseudoMetrizableSpace γ] {g : β → γ} {f : α → β} (hg : IsEmbedding g) : AEStronglyMeasurable (fun x => g (f x)) μ ↔ AEStronglyMeasurable f μ := by letI := pseudoMetrizableSpacePseudoMetric γ borelize β γ refine ⟨fun H => aestronglyMeasurable_iff_aemeasurable_separable.2 ⟨?_, ?_⟩, fun H => hg.continuous.comp_aestronglyMeasurable H⟩ · let G : β → range g := rangeFactorization g have hG : IsClosedEmbedding G := { hg.codRestrict _ _ with isClosed_range := by rw [rangeFactorization_surjective.range_eq]; exact isClosed_univ } have : AEMeasurable (G ∘ f) μ := AEMeasurable.subtype_mk H.aemeasurable exact hG.measurableEmbedding.aemeasurable_comp_iff.1 this · rcases (aestronglyMeasurable_iff_aemeasurable_separable.1 H).2 with ⟨t, ht, h't⟩ exact ⟨g ⁻¹' t, hg.isSeparable_preimage ht, h't⟩ /-- An almost everywhere sequential limit of almost everywhere strongly measurable functions is almost everywhere strongly measurable. -/ theorem _root_.aestronglyMeasurable_of_tendsto_ae {ι : Type*} [PseudoMetrizableSpace β] (u : Filter ι) [NeBot u] [IsCountablyGenerated u] {f : ι → α → β} {g : α → β} (hf : ∀ i, AEStronglyMeasurable (f i) μ) (lim : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) u (𝓝 (g x))) : AEStronglyMeasurable g μ := by borelize β refine aestronglyMeasurable_iff_aemeasurable_separable.2 ⟨?_, ?_⟩ · exact aemeasurable_of_tendsto_metrizable_ae _ (fun n => (hf n).aemeasurable) lim · rcases u.exists_seq_tendsto with ⟨v, hv⟩ have : ∀ n : ℕ, ∃ t : Set β, IsSeparable t ∧ f (v n) ⁻¹' t ∈ ae μ := fun n => (aestronglyMeasurable_iff_aemeasurable_separable.1 (hf (v n))).2 choose t t_sep ht using this refine ⟨closure (⋃ i, t i), .closure <| .iUnion t_sep, ?_⟩ filter_upwards [ae_all_iff.2 ht, lim] with x hx h'x apply mem_closure_of_tendsto (h'x.comp hv) filter_upwards with n using mem_iUnion_of_mem n (hx n) /-- If a sequence of almost everywhere strongly measurable functions converges almost everywhere, one can select a strongly measurable function as the almost everywhere limit. -/ theorem _root_.exists_stronglyMeasurable_limit_of_tendsto_ae [PseudoMetrizableSpace β] {f : ℕ → α → β} (hf : ∀ n, AEStronglyMeasurable (f n) μ) (h_ae_tendsto : ∀ᵐ x ∂μ, ∃ l : β, Tendsto (fun n => f n x) atTop (𝓝 l)) : ∃ f_lim : α → β, StronglyMeasurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x)) := by borelize β obtain ⟨g, _, hg⟩ : ∃ g : α → β, Measurable g ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (g x)) := measurable_limit_of_tendsto_metrizable_ae (fun n => (hf n).aemeasurable) h_ae_tendsto have Hg : AEStronglyMeasurable g μ := aestronglyMeasurable_of_tendsto_ae _ hf hg refine ⟨Hg.mk g, Hg.stronglyMeasurable_mk, ?_⟩ filter_upwards [hg, Hg.ae_eq_mk] with x hx h'x rwa [h'x] at hx /-- If `f` is almost everywhere strongly measurable and its range is almost everywhere contained in a nonempty measurable set `s`, then there is a strongly measurable representative `g` of `f` whose range is contained in `s`. -/ lemma exists_stronglyMeasurable_range_subset {α β : Type*} [TopologicalSpace β] [PseudoMetrizableSpace β] [mb : MeasurableSpace β] [BorelSpace β] [m : MeasurableSpace α] {μ : Measure α} {f : α → β} (hf : AEStronglyMeasurable f μ) {s : Set β} (hs : MeasurableSet s) (h_nonempty : s.Nonempty) (h_mem : ∀ᵐ x ∂μ, f x ∈ s) : ∃ g : α → β, StronglyMeasurable g ∧ (∀ x, g x ∈ s) ∧ f =ᵐ[μ] g := by obtain ⟨f', hf', hff'⟩ := hf classical refine ⟨(f' ⁻¹' s).piecewise f' (fun _ ↦ h_nonempty.some), ?meas, ?subset, ?ae_eq⟩ case meas => exact hf'.piecewise (hf'.measurable hs) stronglyMeasurable_const case subset => rw [← Set.range_subset_iff] simpa [Set.range_piecewise] using fun _ _ ↦ h_nonempty.some_mem case ae_eq => apply hff'.trans filter_upwards [h_mem, hff'] with x hx hx' exact Eq.symm <| (f' ⁻¹' s).piecewise_eq_of_mem f' _ (by simpa [hx'] using hx) theorem piecewise {s : Set α} [DecidablePred (· ∈ s)] (hs : MeasurableSet s) (hf : AEStronglyMeasurable f (μ.restrict s)) (hg : AEStronglyMeasurable g (μ.restrict sᶜ)) : AEStronglyMeasurable (s.piecewise f g) μ := by refine ⟨s.piecewise (hf.mk f) (hg.mk g), StronglyMeasurable.piecewise hs hf.stronglyMeasurable_mk hg.stronglyMeasurable_mk, ?_⟩ refine ae_of_ae_restrict_of_ae_restrict_compl s ?_ ?_ · have h := hf.ae_eq_mk rw [Filter.EventuallyEq, ae_restrict_iff' hs] at h rw [ae_restrict_iff' hs] filter_upwards [h] with x hx intro hx_mem simp only [hx_mem, Set.piecewise_eq_of_mem, hx hx_mem] · have h := hg.ae_eq_mk rw [Filter.EventuallyEq, ae_restrict_iff' hs.compl] at h rw [ae_restrict_iff' hs.compl] filter_upwards [h] with x hx intro hx_mem rw [Set.mem_compl_iff] at hx_mem simp only [hx_mem, not_false_eq_true, Set.piecewise_eq_of_notMem, hx hx_mem] @[fun_prop] theorem sum_measure [PseudoMetrizableSpace β] {m : MeasurableSpace α} {μ : ι → Measure α} (h : ∀ i, AEStronglyMeasurable f (μ i)) : AEStronglyMeasurable f (Measure.sum μ) := by borelize β refine aestronglyMeasurable_iff_aemeasurable_separable.2 ⟨AEMeasurable.sum_measure fun i => (h i).aemeasurable, ?_⟩ have A : ∀ i : ι, ∃ t : Set β, IsSeparable t ∧ f ⁻¹' t ∈ ae (μ i) := fun i => (aestronglyMeasurable_iff_aemeasurable_separable.1 (h i)).2 choose t t_sep ht using A refine ⟨⋃ i, t i, .iUnion t_sep, ?_⟩ simp only [Measure.ae_sum_eq, mem_iUnion, eventually_iSup] intro i filter_upwards [ht i] with x hx exact ⟨i, hx⟩ @[simp] theorem _root_.aestronglyMeasurable_sum_measure_iff [PseudoMetrizableSpace β] {_m : MeasurableSpace α} {μ : ι → Measure α} : AEStronglyMeasurable f (sum μ) ↔ ∀ i, AEStronglyMeasurable f (μ i) := ⟨fun h _ => h.mono_measure (Measure.le_sum _ _), sum_measure⟩ @[simp] theorem _root_.aestronglyMeasurable_add_measure_iff [PseudoMetrizableSpace β] {ν : Measure α} : AEStronglyMeasurable f (μ + ν) ↔ AEStronglyMeasurable f μ ∧ AEStronglyMeasurable f ν := by rw [← sum_cond, aestronglyMeasurable_sum_measure_iff, Bool.forall_bool, and_comm] rfl @[fun_prop, measurability] theorem add_measure [PseudoMetrizableSpace β] {ν : Measure α} {f : α → β} (hμ : AEStronglyMeasurable f μ) (hν : AEStronglyMeasurable f ν) : AEStronglyMeasurable f (μ + ν) := aestronglyMeasurable_add_measure_iff.2 ⟨hμ, hν⟩ @[fun_prop, measurability] protected theorem iUnion [PseudoMetrizableSpace β] {s : ι → Set α} (h : ∀ i, AEStronglyMeasurable f (μ.restrict (s i))) : AEStronglyMeasurable f (μ.restrict (⋃ i, s i)) := (sum_measure h).mono_measure <| restrict_iUnion_le @[simp] theorem _root_.aestronglyMeasurable_iUnion_iff [PseudoMetrizableSpace β] {s : ι → Set α} : AEStronglyMeasurable f (μ.restrict (⋃ i, s i)) ↔ ∀ i, AEStronglyMeasurable f (μ.restrict (s i)) := ⟨fun h _ => h.mono_measure <| restrict_mono (subset_iUnion _ _) le_rfl, AEStronglyMeasurable.iUnion⟩ @[simp] theorem _root_.aestronglyMeasurable_union_iff [PseudoMetrizableSpace β] {s t : Set α} : AEStronglyMeasurable f (μ.restrict (s ∪ t)) ↔ AEStronglyMeasurable f (μ.restrict s) ∧ AEStronglyMeasurable f (μ.restrict t) := by simp only [union_eq_iUnion, aestronglyMeasurable_iUnion_iff, Bool.forall_bool, cond, and_comm] theorem aestronglyMeasurable_uIoc_iff [LinearOrder α] [PseudoMetrizableSpace β] {f : α → β} {a b : α} : AEStronglyMeasurable f (μ.restrict <| uIoc a b) ↔ AEStronglyMeasurable f (μ.restrict <| Ioc a b) ∧ AEStronglyMeasurable f (μ.restrict <| Ioc b a) := by rw [uIoc_eq_union, aestronglyMeasurable_union_iff] @[fun_prop, measurability] theorem smul_measure {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (h : AEStronglyMeasurable f μ) (c : R) : AEStronglyMeasurable f (c • μ) := ⟨h.mk f, h.stronglyMeasurable_mk, ae_smul_measure h.ae_eq_mk c⟩ section MulAction variable {M G G₀ : Type*} variable [Monoid M] [MulAction M β] [ContinuousConstSMul M β] variable [Group G] [MulAction G β] [ContinuousConstSMul G β] variable [GroupWithZero G₀] [MulAction G₀ β] [ContinuousConstSMul G₀ β] theorem _root_.aestronglyMeasurable_const_smul_iff (c : G) : AEStronglyMeasurable (fun x => c • f x) μ ↔ AEStronglyMeasurable f μ := ⟨fun h => by simpa only [inv_smul_smul] using h.const_smul' c⁻¹, fun h => h.const_smul c⟩ nonrec theorem _root_.IsUnit.aestronglyMeasurable_const_smul_iff {c : M} (hc : IsUnit c) : AEStronglyMeasurable (fun x => c • f x) μ ↔ AEStronglyMeasurable f μ := let ⟨u, hu⟩ := hc hu ▸ aestronglyMeasurable_const_smul_iff u theorem _root_.aestronglyMeasurable_const_smul_iff₀ {c : G₀} (hc : c ≠ 0) : AEStronglyMeasurable (fun x => c • f x) μ ↔ AEStronglyMeasurable f μ := (IsUnit.mk0 _ hc).aestronglyMeasurable_const_smul_iff end MulAction end AEStronglyMeasurable end AEStronglyMeasurable /-! ## Almost everywhere finitely strongly measurable functions -/ namespace AEFinStronglyMeasurable variable {m : MeasurableSpace α} {μ : Measure α} [TopologicalSpace β] {f g : α → β} section Mk variable [Zero β] /-- A `fin_strongly_measurable` function such that `f =ᵐ[μ] hf.mk f`. See lemmas `fin_strongly_measurable_mk` and `ae_eq_mk`. -/ protected noncomputable def mk (f : α → β) (hf : AEFinStronglyMeasurable f μ) : α → β := hf.choose theorem finStronglyMeasurable_mk (hf : AEFinStronglyMeasurable f μ) : FinStronglyMeasurable (hf.mk f) μ := hf.choose_spec.1 theorem ae_eq_mk (hf : AEFinStronglyMeasurable f μ) : f =ᵐ[μ] hf.mk f := hf.choose_spec.2 @[fun_prop] protected theorem aemeasurable {β} [Zero β] [MeasurableSpace β] [TopologicalSpace β] [PseudoMetrizableSpace β] [BorelSpace β] {f : α → β} (hf : AEFinStronglyMeasurable f μ) : AEMeasurable f μ := ⟨hf.mk f, hf.finStronglyMeasurable_mk.measurable, hf.ae_eq_mk⟩ end Mk section Arithmetic @[aesop safe 20 (rule_sets := [Measurable])] protected theorem mul [MulZeroClass β] [ContinuousMul β] (hf : AEFinStronglyMeasurable f μ) (hg : AEFinStronglyMeasurable g μ) : AEFinStronglyMeasurable (f * g) μ := ⟨hf.mk f * hg.mk g, hf.finStronglyMeasurable_mk.mul hg.finStronglyMeasurable_mk, hf.ae_eq_mk.mul hg.ae_eq_mk⟩ @[aesop safe 20 (rule_sets := [Measurable])] protected theorem add [AddZeroClass β] [ContinuousAdd β] (hf : AEFinStronglyMeasurable f μ) (hg : AEFinStronglyMeasurable g μ) : AEFinStronglyMeasurable (f + g) μ := ⟨hf.mk f + hg.mk g, hf.finStronglyMeasurable_mk.add hg.finStronglyMeasurable_mk, hf.ae_eq_mk.add hg.ae_eq_mk⟩ @[measurability] protected theorem neg [SubtractionMonoid β] [ContinuousNeg β] (hf : AEFinStronglyMeasurable f μ) : AEFinStronglyMeasurable (-f) μ := ⟨-hf.mk f, hf.finStronglyMeasurable_mk.neg, hf.ae_eq_mk.neg⟩ @[measurability] protected theorem sub [SubtractionMonoid β] [ContinuousSub β] (hf : AEFinStronglyMeasurable f μ) (hg : AEFinStronglyMeasurable g μ) : AEFinStronglyMeasurable (f - g) μ := ⟨hf.mk f - hg.mk g, hf.finStronglyMeasurable_mk.sub hg.finStronglyMeasurable_mk, hf.ae_eq_mk.sub hg.ae_eq_mk⟩ @[measurability] protected theorem const_smul {𝕜} [TopologicalSpace 𝕜] [Zero β] [SMulZeroClass 𝕜 β] [ContinuousSMul 𝕜 β] (hf : AEFinStronglyMeasurable f μ) (c : 𝕜) : AEFinStronglyMeasurable (c • f) μ := ⟨c • hf.mk f, hf.finStronglyMeasurable_mk.const_smul c, hf.ae_eq_mk.const_smul c⟩ end Arithmetic section Order variable [Zero β] @[aesop safe 20 (rule_sets := [Measurable])] protected theorem sup [SemilatticeSup β] [ContinuousSup β] (hf : AEFinStronglyMeasurable f μ) (hg : AEFinStronglyMeasurable g μ) : AEFinStronglyMeasurable (f ⊔ g) μ := ⟨hf.mk f ⊔ hg.mk g, hf.finStronglyMeasurable_mk.sup hg.finStronglyMeasurable_mk, hf.ae_eq_mk.sup hg.ae_eq_mk⟩ @[aesop safe 20 (rule_sets := [Measurable])] protected theorem inf [SemilatticeInf β] [ContinuousInf β] (hf : AEFinStronglyMeasurable f μ) (hg : AEFinStronglyMeasurable g μ) : AEFinStronglyMeasurable (f ⊓ g) μ := ⟨hf.mk f ⊓ hg.mk g, hf.finStronglyMeasurable_mk.inf hg.finStronglyMeasurable_mk, hf.ae_eq_mk.inf hg.ae_eq_mk⟩ end Order variable [Zero β] [T2Space β] theorem exists_set_sigmaFinite (hf : AEFinStronglyMeasurable f μ) : ∃ t, MeasurableSet t ∧ f =ᵐ[μ.restrict tᶜ] 0 ∧ SigmaFinite (μ.restrict t) := by rcases hf with ⟨g, hg, hfg⟩ obtain ⟨t, ht, hgt_zero, htμ⟩ := hg.exists_set_sigmaFinite refine ⟨t, ht, ?_, htμ⟩ refine EventuallyEq.trans (ae_restrict_of_ae hfg) ?_ rw [EventuallyEq, ae_restrict_iff' ht.compl] exact Eventually.of_forall hgt_zero /-- A measurable set `t` such that `f =ᵐ[μ.restrict tᶜ] 0` and `sigma_finite (μ.restrict t)`. -/ def sigmaFiniteSet (hf : AEFinStronglyMeasurable f μ) : Set α := hf.exists_set_sigmaFinite.choose protected theorem measurableSet (hf : AEFinStronglyMeasurable f μ) : MeasurableSet hf.sigmaFiniteSet := hf.exists_set_sigmaFinite.choose_spec.1 theorem ae_eq_zero_compl (hf : AEFinStronglyMeasurable f μ) : f =ᵐ[μ.restrict hf.sigmaFiniteSetᶜ] 0 := hf.exists_set_sigmaFinite.choose_spec.2.1 instance sigmaFinite_restrict (hf : AEFinStronglyMeasurable f μ) : SigmaFinite (μ.restrict hf.sigmaFiniteSet) := hf.exists_set_sigmaFinite.choose_spec.2.2 end AEFinStronglyMeasurable section SecondCountableTopology variable {G : Type*} [SeminormedAddCommGroup G] [MeasurableSpace G] [BorelSpace G] [SecondCountableTopology G] {f : α → G} /-- In a space with second countable topology and a sigma-finite measure, `AEFinStronglyMeasurable` and `AEMeasurable` are equivalent. -/ theorem aefinStronglyMeasurable_iff_aemeasurable {_m0 : MeasurableSpace α} (μ : Measure α) [SigmaFinite μ] : AEFinStronglyMeasurable f μ ↔ AEMeasurable f μ := by simp_rw [AEFinStronglyMeasurable, AEMeasurable, finStronglyMeasurable_iff_measurable] /-- In a space with second countable topology and a sigma-finite measure, an `AEMeasurable` function is `AEFinStronglyMeasurable`. -/ @[aesop 90% apply (rule_sets := [Measurable])] theorem aefinStronglyMeasurable_of_aemeasurable {_m0 : MeasurableSpace α} (μ : Measure α) [SigmaFinite μ] (hf : AEMeasurable f μ) : AEFinStronglyMeasurable f μ := (aefinStronglyMeasurable_iff_aemeasurable μ).mpr hf end SecondCountableTopology end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/L1Space/AEEqFun.lean
import Mathlib.MeasureTheory.Function.L1Space.Integrable /-! # `L¹` space In this file we establish an API between `Integrable` and the space `L¹` of equivalence classes of integrable functions, already defined as a special case of `L^p` spaces for `p = 1`. ## Notation * `α →₁[μ] β` is the type of `L¹` space, where `α` is a `MeasureSpace` and `β` is a `NormedAddCommGroup`. `f : α →ₘ β` is a "function" in `L¹`. In comments, `[f]` is also used to denote an `L¹` function. `₁` can be typed as `\1`. ## Tags function space, l1 -/ noncomputable section open EMetric ENNReal Filter MeasureTheory NNReal Set variable {α β ε ε' : Type*} {m : MeasurableSpace α} {μ ν : Measure α} variable [NormedAddCommGroup β] [TopologicalSpace ε] [ContinuousENorm ε] [TopologicalSpace ε'] [ESeminormedAddMonoid ε'] namespace MeasureTheory namespace AEEqFun section /-- A class of almost everywhere equal functions is `Integrable` if its function representative is integrable. -/ def Integrable (f : α →ₘ[μ] ε) : Prop := MeasureTheory.Integrable f μ theorem integrable_mk {f : α → ε} (hf : AEStronglyMeasurable f μ) : Integrable (mk f hf : α →ₘ[μ] ε) ↔ MeasureTheory.Integrable f μ := by simp only [Integrable] apply integrable_congr exact coeFn_mk f hf theorem integrable_coeFn {f : α →ₘ[μ] ε} : MeasureTheory.Integrable f μ ↔ Integrable f := by rw [← integrable_mk f.aestronglyMeasurable, mk_coeFn] theorem integrable_zero : Integrable (0 : α →ₘ[μ] ε') := (MeasureTheory.integrable_zero α ε' μ).congr (coeFn_mk _ _).symm end section theorem Integrable.neg {f : α →ₘ[μ] β} : Integrable f → Integrable (-f) := induction_on f fun _f hfm hfi => (integrable_mk _).2 ((integrable_mk hfm).1 hfi).neg section theorem integrable_iff_mem_L1 {f : α →ₘ[μ] β} : Integrable f ↔ f ∈ (α →₁[μ] β) := by rw [← integrable_coeFn, ← memLp_one_iff_integrable, Lp.mem_Lp_iff_memLp] -- TODO: generalise these lemmas to `ENormedSpace` or similar theorem Integrable.add {f g : α →ₘ[μ] β} : Integrable f → Integrable g → Integrable (f + g) := by refine induction_on₂ f g fun f hf g hg hfi hgi => ?_ simp only [integrable_mk, mk_add_mk] at hfi hgi ⊢ exact hfi.add hgi theorem Integrable.sub {f g : α →ₘ[μ] β} (hf : Integrable f) (hg : Integrable g) : Integrable (f - g) := (sub_eq_add_neg f g).symm ▸ hf.add hg.neg end section IsBoundedSMul variable {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 β] [IsBoundedSMul 𝕜 β] theorem Integrable.smul {c : 𝕜} {f : α →ₘ[μ] β} : Integrable f → Integrable (c • f) := induction_on f fun _f hfm hfi => (integrable_mk _).2 <| by simpa using ((integrable_mk hfm).1 hfi).smul c end IsBoundedSMul end end AEEqFun namespace L1 theorem integrable_coeFn (f : α →₁[μ] β) : Integrable f μ := by rw [← memLp_one_iff_integrable] exact Lp.memLp f theorem hasFiniteIntegral_coeFn (f : α →₁[μ] β) : HasFiniteIntegral f μ := (integrable_coeFn f).hasFiniteIntegral @[fun_prop] theorem stronglyMeasurable_coeFn (f : α →₁[μ] β) : StronglyMeasurable f := Lp.stronglyMeasurable f @[fun_prop] theorem measurable_coeFn [MeasurableSpace β] [BorelSpace β] (f : α →₁[μ] β) : Measurable f := (Lp.stronglyMeasurable f).measurable @[fun_prop] theorem aestronglyMeasurable_coeFn (f : α →₁[μ] β) : AEStronglyMeasurable f μ := Lp.aestronglyMeasurable f @[fun_prop] theorem aemeasurable_coeFn [MeasurableSpace β] [BorelSpace β] (f : α →₁[μ] β) : AEMeasurable f μ := (Lp.stronglyMeasurable f).measurable.aemeasurable theorem edist_def (f g : α →₁[μ] β) : edist f g = ∫⁻ a, edist (f a) (g a) ∂μ := by simp only [Lp.edist_def, eLpNorm, one_ne_zero, eLpNorm'_eq_lintegral_enorm, Pi.sub_apply, toReal_one, ENNReal.rpow_one, ne_eq, not_false_eq_true, div_self, ite_false] simp [edist_eq_enorm_sub] theorem dist_def (f g : α →₁[μ] β) : dist f g = (∫⁻ a, edist (f a) (g a) ∂μ).toReal := by simp_rw [dist_edist, edist_def] theorem norm_def (f : α →₁[μ] β) : ‖f‖ = (∫⁻ a, ‖f a‖ₑ ∂μ).toReal := by simp [Lp.norm_def, eLpNorm, eLpNorm'_eq_lintegral_enorm] /-- Computing the norm of a difference between two L¹-functions. Note that this is not a special case of `norm_def` since `(f - g) x` and `f x - g x` are not equal (but only a.e.-equal). -/ theorem norm_sub_eq_lintegral (f g : α →₁[μ] β) : ‖f - g‖ = (∫⁻ x, ‖f x - g x‖ₑ ∂μ).toReal := by rw [norm_def] congr 1 rw [lintegral_congr_ae] filter_upwards [Lp.coeFn_sub f g] with _ ha simp only [ha, Pi.sub_apply] theorem ofReal_norm_eq_lintegral (f : α →₁[μ] β) : ENNReal.ofReal ‖f‖ = ∫⁻ x, ‖f x‖ₑ ∂μ := by rw [norm_def, ENNReal.ofReal_toReal] exact ne_of_lt (hasFiniteIntegral_coeFn f) /-- Computing the norm of a difference between two L¹-functions. Note that this is not a special case of `ofReal_norm_eq_lintegral` since `(f - g) x` and `f x - g x` are not equal (but only a.e.-equal). -/ theorem ofReal_norm_sub_eq_lintegral (f g : α →₁[μ] β) : ENNReal.ofReal ‖f - g‖ = ∫⁻ x, ‖f x - g x‖ₑ ∂μ := by simp_rw [ofReal_norm_eq_lintegral, ← edist_zero_eq_enorm] apply lintegral_congr_ae filter_upwards [Lp.coeFn_sub f g] with _ ha simp only [ha, Pi.sub_apply] end L1 namespace Integrable /-- Construct the equivalence class `[f]` of an integrable function `f`, as a member of the space `Lp β 1 μ`. -/ def toL1 (f : α → β) (hf : Integrable f μ) : α →₁[μ] β := (memLp_one_iff_integrable.2 hf).toLp f @[simp] theorem toL1_coeFn (f : α →₁[μ] β) (hf : Integrable f μ) : hf.toL1 f = f := by simp [Integrable.toL1] theorem coeFn_toL1 {f : α → β} (hf : Integrable f μ) : hf.toL1 f =ᵐ[μ] f := AEEqFun.coeFn_mk _ _ @[simp] theorem toL1_zero (h : Integrable (0 : α → β) μ) : h.toL1 0 = 0 := rfl @[simp] theorem toL1_eq_mk (f : α → β) (hf : Integrable f μ) : (hf.toL1 f : α →ₘ[μ] β) = AEEqFun.mk f hf.aestronglyMeasurable := rfl @[simp] theorem toL1_eq_toL1_iff (f g : α → β) (hf : Integrable f μ) (hg : Integrable g μ) : toL1 f hf = toL1 g hg ↔ f =ᵐ[μ] g := MemLp.toLp_eq_toLp_iff _ _ theorem toL1_add (f g : α → β) (hf : Integrable f μ) (hg : Integrable g μ) : toL1 (f + g) (hf.add hg) = toL1 f hf + toL1 g hg := rfl theorem toL1_neg (f : α → β) (hf : Integrable f μ) : toL1 (-f) (Integrable.neg hf) = -toL1 f hf := rfl theorem toL1_sub (f g : α → β) (hf : Integrable f μ) (hg : Integrable g μ) : toL1 (f - g) (hf.sub hg) = toL1 f hf - toL1 g hg := rfl theorem norm_toL1 (f : α → β) (hf : Integrable f μ) : ‖hf.toL1 f‖ = (∫⁻ a, edist (f a) 0 ∂μ).toReal := by simp [toL1, Lp.norm_toLp, eLpNorm, eLpNorm'_eq_lintegral_enorm] theorem enorm_toL1 {f : α → β} (hf : Integrable f μ) : ‖hf.toL1 f‖ₑ = ∫⁻ a, ‖f a‖ₑ ∂μ := by simp only [Lp.enorm_def, toL1_eq_mk, eLpNorm_aeeqFun] simp [eLpNorm, eLpNorm'] theorem norm_toL1_eq_lintegral_norm (f : α → β) (hf : Integrable f μ) : ‖hf.toL1 f‖ = ENNReal.toReal (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) := by rw [norm_toL1, lintegral_norm_eq_lintegral_edist] @[simp] theorem edist_toL1_toL1 (f g : α → β) (hf : Integrable f μ) (hg : Integrable g μ) : edist (hf.toL1 f) (hg.toL1 g) = ∫⁻ a, edist (f a) (g a) ∂μ := by simp only [toL1, Lp.edist_toLp_toLp, eLpNorm, one_ne_zero, eLpNorm'_eq_lintegral_enorm, Pi.sub_apply, toReal_one, ENNReal.rpow_one, ne_eq, not_false_eq_true, div_self, ite_false] simp [edist_eq_enorm_sub] theorem edist_toL1_zero (f : α → β) (hf : Integrable f μ) : edist (hf.toL1 f) 0 = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [edist_zero_right, Lp.enorm_def, toL1_eq_mk, eLpNorm_aeeqFun] apply eLpNorm_one_eq_lintegral_enorm variable {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 β] [IsBoundedSMul 𝕜 β] theorem toL1_smul (f : α → β) (hf : Integrable f μ) (k : 𝕜) : toL1 (fun a => k • f a) (hf.smul k) = k • toL1 f hf := rfl theorem toL1_smul' (f : α → β) (hf : Integrable f μ) (k : 𝕜) : toL1 (k • f) (hf.smul k) = k • toL1 f hf := rfl end Integrable end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/L1Space/HasFiniteIntegral.lean
import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable import Mathlib.MeasureTheory.Integral.Lebesgue.DominatedConvergence import Mathlib.MeasureTheory.Integral.Lebesgue.Norm import Mathlib.MeasureTheory.Measure.WithDensity /-! # Function with finite integral In this file we define the predicate `HasFiniteIntegral`, which is then used to define the predicate `Integrable` in the corresponding file. ## Main definition * Let `f : α → β` be a function, where `α` is a `MeasureSpace` and `β` a `NormedAddCommGroup`. Then `HasFiniteIntegral f` means `∫⁻ a, ‖f a‖ₑ < ∞`. ## Tags finite integral -/ noncomputable section open Topology ENNReal MeasureTheory NNReal open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory variable {α β γ ε ε' ε'' : Type*} {m : MeasurableSpace α} {μ ν : Measure α} variable [NormedAddCommGroup β] [NormedAddCommGroup γ] [ENorm ε] [ENorm ε'] [TopologicalSpace ε''] [ESeminormedAddMonoid ε''] namespace MeasureTheory /-! ### Some results about the Lebesgue integral involving a normed group -/ lemma lintegral_enorm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ‖f a‖ₑ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [edist_zero_eq_enorm] theorem lintegral_norm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [ofReal_norm_eq_enorm, edist_zero_eq_enorm] theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ) (hh : AEStronglyMeasurable h μ) : (∫⁻ a, edist (f a) (g a) ∂μ) ≤ (∫⁻ a, edist (f a) (h a) ∂μ) + ∫⁻ a, edist (g a) (h a) ∂μ := by rw [← lintegral_add_left' (hf.edist hh)] refine lintegral_mono fun a => ?_ apply edist_triangle_right -- Yaël: Why do the following four lemmas even exist? theorem lintegral_enorm_zero : ∫⁻ _ : α, ‖(0 : ε'')‖ₑ ∂μ = 0 := by simp theorem lintegral_enorm_add_left {f : α → ε''} (hf : AEStronglyMeasurable f μ) (g : α → ε') : ∫⁻ a, ‖f a‖ₑ + ‖g a‖ₑ ∂μ = ∫⁻ a, ‖f a‖ₑ ∂μ + ∫⁻ a, ‖g a‖ₑ ∂μ := lintegral_add_left' hf.enorm _ theorem lintegral_enorm_add_right (f : α → ε') {g : α → ε''} (hg : AEStronglyMeasurable g μ) : ∫⁻ a, ‖f a‖ₑ + ‖g a‖ₑ ∂μ = ∫⁻ a, ‖f a‖ₑ ∂μ + ∫⁻ a, ‖g a‖ₑ ∂μ := lintegral_add_right' _ hg.enorm theorem lintegral_enorm_neg {f : α → β} : ∫⁻ a, ‖(-f) a‖ₑ ∂μ = ∫⁻ a, ‖f a‖ₑ ∂μ := by simp /-! ### The predicate `HasFiniteIntegral` -/ /-- `HasFiniteIntegral f μ` means that the integral `∫⁻ a, ‖f a‖ ∂μ` is finite. `HasFiniteIntegral f` means `HasFiniteIntegral f volume`. -/ @[fun_prop] def HasFiniteIntegral {_ : MeasurableSpace α} (f : α → ε) (μ : Measure α := by volume_tac) : Prop := ∫⁻ a, ‖f a‖ₑ ∂μ < ∞ theorem hasFiniteIntegral_def {_ : MeasurableSpace α} (f : α → ε) (μ : Measure α) : HasFiniteIntegral f μ ↔ (∫⁻ a, ‖f a‖ₑ ∂μ < ∞) := Iff.rfl theorem hasFiniteIntegral_iff_enorm {f : α → ε} : HasFiniteIntegral f μ ↔ ∫⁻ a, ‖f a‖ₑ ∂μ < ∞ := by simp only [HasFiniteIntegral] theorem hasFiniteIntegral_iff_norm (f : α → β) : HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) < ∞ := by simp only [hasFiniteIntegral_iff_enorm, ofReal_norm_eq_enorm] theorem hasFiniteIntegral_iff_edist (f : α → β) : HasFiniteIntegral f μ ↔ (∫⁻ a, edist (f a) 0 ∂μ) < ∞ := by simp only [hasFiniteIntegral_iff_norm, edist_dist, dist_zero_right] theorem hasFiniteIntegral_iff_ofReal {f : α → ℝ} (h : 0 ≤ᵐ[μ] f) : HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal (f a) ∂μ) < ∞ := by rw [hasFiniteIntegral_iff_enorm, lintegral_enorm_of_ae_nonneg h] theorem hasFiniteIntegral_iff_ofNNReal {f : α → ℝ≥0} : HasFiniteIntegral (fun x => (f x : ℝ)) μ ↔ (∫⁻ a, f a ∂μ) < ∞ := by simp [hasFiniteIntegral_iff_norm] theorem HasFiniteIntegral.mono_enorm {f : α → ε} {g : α → ε'} (hg : HasFiniteIntegral g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ ≤ ‖g a‖ₑ) : HasFiniteIntegral f μ := by simp only [hasFiniteIntegral_iff_enorm] at * calc (∫⁻ a, ‖f a‖ₑ ∂μ) ≤ ∫⁻ a : α, ‖g a‖ₑ ∂μ := lintegral_mono_ae h _ < ∞ := hg theorem HasFiniteIntegral.mono {f : α → β} {g : α → γ} (hg : HasFiniteIntegral g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ ‖g a‖) : HasFiniteIntegral f μ := hg.mono_enorm <| h.mono fun _x hx ↦ enorm_le_iff_norm_le.mpr hx theorem HasFiniteIntegral.mono'_enorm {f : α → ε} {g : α → ℝ≥0∞} (hg : HasFiniteIntegral g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ ≤ g a) : HasFiniteIntegral f μ := hg.mono_enorm <| h.mono fun _x hx ↦ le_trans hx le_rfl theorem HasFiniteIntegral.mono' {f : α → β} {g : α → ℝ} (hg : HasFiniteIntegral g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : HasFiniteIntegral f μ := hg.mono <| h.mono fun _x hx => le_trans hx (le_abs_self _) theorem HasFiniteIntegral.congr'_enorm {f : α → ε} {g : α → ε'} (hf : HasFiniteIntegral f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ = ‖g a‖ₑ) : HasFiniteIntegral g μ := hf.mono_enorm <| EventuallyEq.le <| EventuallyEq.symm h theorem HasFiniteIntegral.congr' {f : α → β} {g : α → γ} (hf : HasFiniteIntegral f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : HasFiniteIntegral g μ := hf.mono <| EventuallyEq.le <| EventuallyEq.symm h theorem hasFiniteIntegral_congr'_enorm {f : α → ε} {g : α → ε'} (h : ∀ᵐ a ∂μ, ‖f a‖ₑ = ‖g a‖ₑ) : HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ := ⟨fun hf => hf.congr'_enorm h, fun hg => hg.congr'_enorm <| EventuallyEq.symm h⟩ theorem hasFiniteIntegral_congr' {f : α → β} {g : α → γ} (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ := ⟨fun hf => hf.congr' h, fun hg => hg.congr' <| EventuallyEq.symm h⟩ theorem HasFiniteIntegral.congr {f g : α → ε} (hf : HasFiniteIntegral f μ) (h : f =ᵐ[μ] g) : HasFiniteIntegral g μ := hf.congr'_enorm <| h.fun_comp enorm theorem hasFiniteIntegral_congr {f g : α → ε} (h : f =ᵐ[μ] g) : HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ := hasFiniteIntegral_congr'_enorm <| h.fun_comp enorm theorem hasFiniteIntegral_const_iff_enorm {c : ε} (hc : ‖c‖ₑ ≠ ∞) : HasFiniteIntegral (fun _ : α ↦ c) μ ↔ ‖c‖ₑ = 0 ∨ IsFiniteMeasure μ := by simpa [hasFiniteIntegral_iff_enorm, lt_top_iff_ne_top, ENNReal.mul_eq_top, or_iff_not_imp_left, isFiniteMeasure_iff] using fun h h' ↦ (hc h').elim theorem hasFiniteIntegral_const_iff {c : β} : HasFiniteIntegral (fun _ : α => c) μ ↔ c = 0 ∨ IsFiniteMeasure μ := by rw [hasFiniteIntegral_const_iff_enorm enorm_ne_top] simp lemma hasFiniteIntegral_const_iff_isFiniteMeasure_enorm {c : ε} (hc : ‖c‖ₑ ≠ 0) (hc' : ‖c‖ₑ ≠ ∞) : HasFiniteIntegral (fun _ ↦ c) μ ↔ IsFiniteMeasure μ := by simp [hasFiniteIntegral_const_iff_enorm hc', hc, isFiniteMeasure_iff] lemma hasFiniteIntegral_const_iff_isFiniteMeasure {c : β} (hc : c ≠ 0) : HasFiniteIntegral (fun _ ↦ c) μ ↔ IsFiniteMeasure μ := hasFiniteIntegral_const_iff_isFiniteMeasure_enorm (enorm_ne_zero.mpr hc) enorm_ne_top @[fun_prop] theorem hasFiniteIntegral_const_enorm [IsFiniteMeasure μ] {c : ε} (hc : ‖c‖ₑ ≠ ∞) : HasFiniteIntegral (fun _ : α ↦ c) μ := (hasFiniteIntegral_const_iff_enorm hc).2 <| .inr ‹_› @[fun_prop] theorem hasFiniteIntegral_const [IsFiniteMeasure μ] (c : β) : HasFiniteIntegral (fun _ : α => c) μ := hasFiniteIntegral_const_iff.2 <| .inr ‹_› theorem HasFiniteIntegral.of_mem_Icc_of_ne_top [IsFiniteMeasure μ] {a b : ℝ≥0∞} (ha : a ≠ ⊤) (hb : b ≠ ⊤) {X : α → ℝ≥0∞} (h : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) : HasFiniteIntegral X μ := by have : ‖max ‖a‖ₑ ‖b‖ₑ‖ₑ ≠ ⊤ := by simp [ha, hb] apply (hasFiniteIntegral_const_enorm this (μ := μ)).mono'_enorm filter_upwards [h.mono fun ω h ↦ h.1, h.mono fun ω h ↦ h.2] with ω h₁ h₂ using by simp [h₂] theorem HasFiniteIntegral.of_mem_Icc [IsFiniteMeasure μ] (a b : ℝ) {X : α → ℝ} (h : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) : HasFiniteIntegral X μ := by apply (hasFiniteIntegral_const (max ‖a‖ ‖b‖)).mono' filter_upwards [h.mono fun ω h ↦ h.1, h.mono fun ω h ↦ h.2] with ω using abs_le_max_abs_abs theorem HasFiniteIntegral.of_bounded_enorm [IsFiniteMeasure μ] {f : α → ε} {C : ℝ≥0∞} (hC' : ‖C‖ₑ ≠ ∞ := by finiteness) (hC : ∀ᵐ a ∂μ, ‖f a‖ₑ ≤ C) : HasFiniteIntegral f μ := (hasFiniteIntegral_const_enorm hC').mono'_enorm hC @[deprecated (since := "2025-07-26")] alias hasFiniteIntegral_of_bounded_enorm := HasFiniteIntegral.of_bounded_enorm theorem HasFiniteIntegral.of_bounded [IsFiniteMeasure μ] {f : α → β} {C : ℝ} (hC : ∀ᵐ a ∂μ, ‖f a‖ ≤ C) : HasFiniteIntegral f μ := (hasFiniteIntegral_const C).mono' hC @[deprecated (since := "2025-07-26")] alias hasFiniteIntegral_of_bounded := HasFiniteIntegral.of_bounded -- TODO: generalise this to f with codomain ε -- requires generalising `norm_le_pi_norm` and friends to enorms @[simp] theorem HasFiniteIntegral.of_finite [Finite α] [IsFiniteMeasure μ] {f : α → β} : HasFiniteIntegral f μ := let ⟨_⟩ := nonempty_fintype α .of_bounded <| ae_of_all μ <| norm_le_pi_norm f theorem HasFiniteIntegral.mono_measure {f : α → ε} (h : HasFiniteIntegral f ν) (hμ : μ ≤ ν) : HasFiniteIntegral f μ := lt_of_le_of_lt (lintegral_mono' hμ le_rfl) h @[fun_prop] theorem HasFiniteIntegral.add_measure {f : α → ε} (hμ : HasFiniteIntegral f μ) (hν : HasFiniteIntegral f ν) : HasFiniteIntegral f (μ + ν) := by simp only [HasFiniteIntegral, lintegral_add_measure] at * exact add_lt_top.2 ⟨hμ, hν⟩ theorem HasFiniteIntegral.left_of_add_measure {f : α → ε} (h : HasFiniteIntegral f (μ + ν)) : HasFiniteIntegral f μ := h.mono_measure <| Measure.le_add_right <| le_rfl theorem HasFiniteIntegral.right_of_add_measure {f : α → ε} (h : HasFiniteIntegral f (μ + ν)) : HasFiniteIntegral f ν := h.mono_measure <| Measure.le_add_left <| le_rfl @[simp] theorem hasFiniteIntegral_add_measure {f : α → ε} : HasFiniteIntegral f (μ + ν) ↔ HasFiniteIntegral f μ ∧ HasFiniteIntegral f ν := ⟨fun h => ⟨h.left_of_add_measure, h.right_of_add_measure⟩, fun h => h.1.add_measure h.2⟩ theorem HasFiniteIntegral.smul_measure {f : α → ε} (h : HasFiniteIntegral f μ) {c : ℝ≥0∞} (hc : c ≠ ∞) : HasFiniteIntegral f (c • μ) := by simp only [HasFiniteIntegral, lintegral_smul_measure] at * exact mul_lt_top hc.lt_top h @[fun_prop, simp] theorem hasFiniteIntegral_zero_measure {m : MeasurableSpace α} (f : α → ε) : HasFiniteIntegral f (0 : Measure α) := by simp only [HasFiniteIntegral, lintegral_zero_measure, zero_lt_top] variable (α μ) in @[fun_prop, simp] theorem hasFiniteIntegral_zero {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] : HasFiniteIntegral (fun _ : α => (0 : ε)) μ := by simp [hasFiniteIntegral_iff_enorm] @[fun_prop] theorem HasFiniteIntegral.neg {f : α → β} (hfi : HasFiniteIntegral f μ) : HasFiniteIntegral (-f) μ := by simpa [hasFiniteIntegral_iff_enorm] using hfi @[simp] theorem hasFiniteIntegral_neg_iff {f : α → β} : HasFiniteIntegral (-f) μ ↔ HasFiniteIntegral f μ := ⟨fun h => neg_neg f ▸ h.neg, HasFiniteIntegral.neg⟩ @[fun_prop] theorem HasFiniteIntegral.enorm {f : α → ε} (hfi : HasFiniteIntegral f μ) : HasFiniteIntegral (‖f ·‖ₑ) μ := by simpa [hasFiniteIntegral_iff_enorm] using hfi @[fun_prop] theorem HasFiniteIntegral.norm {f : α → β} (hfi : HasFiniteIntegral f μ) : HasFiniteIntegral (fun a => ‖f a‖) μ := by simpa [hasFiniteIntegral_iff_enorm] using hfi theorem hasFiniteIntegral_enorm_iff (f : α → ε) : HasFiniteIntegral (‖f ·‖ₑ) μ ↔ HasFiniteIntegral f μ := hasFiniteIntegral_congr'_enorm <| Eventually.of_forall fun x => enorm_enorm (f x) theorem hasFiniteIntegral_norm_iff (f : α → β) : HasFiniteIntegral (fun a => ‖f a‖) μ ↔ HasFiniteIntegral f μ := hasFiniteIntegral_congr' <| Eventually.of_forall fun x => norm_norm (f x) theorem HasFiniteIntegral.of_subsingleton [Subsingleton α] [IsFiniteMeasure μ] {f : α → β} : HasFiniteIntegral f μ := .of_finite theorem HasFiniteIntegral.of_isEmpty [IsEmpty α] {f : α → β} : HasFiniteIntegral f μ := .of_finite @[simp] theorem HasFiniteIntegral.of_subsingleton_codomain {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] [Subsingleton ε] {f : α → ε} : HasFiniteIntegral f μ := hasFiniteIntegral_zero _ _ |>.congr <| .of_forall fun _ ↦ Subsingleton.elim _ _ theorem hasFiniteIntegral_toReal_of_lintegral_ne_top {f : α → ℝ≥0∞} (hf : ∫⁻ x, f x ∂μ ≠ ∞) : HasFiniteIntegral (fun x ↦ (f x).toReal) μ := by have h x : ‖(f x).toReal‖ₑ = .ofReal (f x).toReal := by rw [Real.enorm_of_nonneg ENNReal.toReal_nonneg] simp_rw [hasFiniteIntegral_iff_enorm, h] refine lt_of_le_of_lt (lintegral_mono fun x => ?_) (lt_top_iff_ne_top.2 hf) by_cases hfx : f x = ∞ · simp [hfx] · lift f x to ℝ≥0 using hfx with fx h simp lemma hasFiniteIntegral_toReal_iff {f : α → ℝ≥0∞} (hf : ∀ᵐ x ∂μ, f x ≠ ∞) : HasFiniteIntegral (fun x ↦ (f x).toReal) μ ↔ ∫⁻ x, f x ∂μ ≠ ∞ := by have : ∀ᵐ x ∂μ, .ofReal (f x).toReal = f x := by filter_upwards [hf] with x hx; simp [hx] simp [hasFiniteIntegral_iff_enorm, Real.enorm_of_nonneg ENNReal.toReal_nonneg, lintegral_congr_ae this, lt_top_iff_ne_top] theorem isFiniteMeasure_withDensity_ofReal {f : α → ℝ} (hfi : HasFiniteIntegral f μ) : IsFiniteMeasure (μ.withDensity fun x => ENNReal.ofReal <| f x) := by refine isFiniteMeasure_withDensity ((lintegral_mono fun x => ?_).trans_lt hfi).ne exact Real.ofReal_le_enorm (f x) section DominatedConvergence variable {F : ℕ → α → β} {f : α → β} {bound : α → ℝ} {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] {F' : ℕ → α → ε} {f' : α → ε} {bound' : α → ℝ≥0∞} theorem all_ae_ofReal_F_le_bound (h : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) : ∀ n, ∀ᵐ a ∂μ, ENNReal.ofReal ‖F n a‖ ≤ ENNReal.ofReal (bound a) := fun n => (h n).mono fun _ h => ENNReal.ofReal_le_ofReal h theorem ae_tendsto_enorm (h : ∀ᵐ a ∂μ, Tendsto (fun n ↦ F' n a) atTop <| 𝓝 <| f' a) : ∀ᵐ a ∂μ, Tendsto (fun n ↦ ‖F' n a‖ₑ) atTop <| 𝓝 <| ‖f' a‖ₑ := h.mono fun _ h ↦ Tendsto.comp (Continuous.tendsto continuous_enorm _) h theorem all_ae_tendsto_ofReal_norm (h : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop <| 𝓝 <| f a) : ∀ᵐ a ∂μ, Tendsto (fun n => ENNReal.ofReal ‖F n a‖) atTop <| 𝓝 <| ENNReal.ofReal ‖f a‖ := by convert ae_tendsto_enorm h <;> simp theorem all_ae_ofReal_f_le_bound (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : ∀ᵐ a ∂μ, ENNReal.ofReal ‖f a‖ ≤ ENNReal.ofReal (bound a) := by have F_le_bound := all_ae_ofReal_F_le_bound h_bound rw [← ae_all_iff] at F_le_bound apply F_le_bound.mp ((all_ae_tendsto_ofReal_norm h_lim).mono _) intro a tendsto_norm F_le_bound exact le_of_tendsto' tendsto_norm F_le_bound theorem ae_enorm_le_bound (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F' n a‖ₑ ≤ bound' a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n ↦ F' n a) atTop (𝓝 (f' a))) : ∀ᵐ a ∂μ, ‖f' a‖ₑ ≤ bound' a := by rw [← ae_all_iff] at h_bound apply h_bound.mp ((ae_tendsto_enorm h_lim).mono _) intro a tendsto_norm h_bound exact le_of_tendsto' tendsto_norm h_bound theorem hasFiniteIntegral_of_dominated_convergence_enorm (bound_hasFiniteIntegral : HasFiniteIntegral bound' μ) (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F' n a‖ₑ ≤ bound' a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n ↦ F' n a) atTop (𝓝 (f' a))) : HasFiniteIntegral f' μ := by /- `‖F' n a‖ₑ ≤ bound' a` and `‖F' n a‖ₑ --> ‖f' a‖ₑ` implies `‖f a‖ₑ ≤ bound' a`, and so `∫ ‖f'‖ₑ ≤ ∫ bound' < ∞` since `bound'` has finite integral -/ rw [hasFiniteIntegral_iff_enorm] calc (∫⁻ a, ‖f' a‖ₑ ∂μ) ≤ ∫⁻ a, bound' a ∂μ := lintegral_mono_ae <| ae_enorm_le_bound h_bound h_lim _ < ∞ := bound_hasFiniteIntegral theorem hasFiniteIntegral_of_dominated_convergence (bound_hasFiniteIntegral : HasFiniteIntegral bound μ) (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : HasFiniteIntegral f μ := by /- `‖F n a‖ ≤ bound a` and `‖F n a‖ --> ‖f a‖` implies `‖f a‖ ≤ bound a`, and so `∫ ‖f‖ ≤ ∫ bound < ∞` since `bound` is has_finite_integral -/ rw [hasFiniteIntegral_iff_norm] calc (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) ≤ ∫⁻ a, ENNReal.ofReal (bound a) ∂μ := lintegral_mono_ae <| all_ae_ofReal_f_le_bound h_bound h_lim _ < ∞ := by rw [← hasFiniteIntegral_iff_ofReal] · exact bound_hasFiniteIntegral exact (h_bound 0).mono fun a h => le_trans (norm_nonneg _) h -- TODO: generalise this to `f` and `F` taking values in a new class `ENormedSubmonoid` theorem tendsto_lintegral_norm_of_dominated_convergence (F_measurable : ∀ n, AEStronglyMeasurable (F n) μ) (bound_hasFiniteIntegral : HasFiniteIntegral bound μ) (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : Tendsto (fun n => ∫⁻ a, ENNReal.ofReal ‖F n a - f a‖ ∂μ) atTop (𝓝 0) := by have f_measurable : AEStronglyMeasurable f μ := aestronglyMeasurable_of_tendsto_ae _ F_measurable h_lim let b a := 2 * ENNReal.ofReal (bound a) /- `‖F n a‖ ≤ bound a` and `F n a --> f a` implies `‖f a‖ ≤ bound a`, and thus by the triangle inequality, have `‖F n a - f a‖ ≤ 2 * (bound a)`. -/ have hb : ∀ n, ∀ᵐ a ∂μ, ENNReal.ofReal ‖F n a - f a‖ ≤ b a := by intro n filter_upwards [all_ae_ofReal_F_le_bound h_bound n, all_ae_ofReal_f_le_bound h_bound h_lim] with a h₁ h₂ calc ENNReal.ofReal ‖F n a - f a‖ ≤ ENNReal.ofReal ‖F n a‖ + ENNReal.ofReal ‖f a‖ := by rw [← ENNReal.ofReal_add] · apply ofReal_le_ofReal apply norm_sub_le · exact norm_nonneg _ · exact norm_nonneg _ _ ≤ ENNReal.ofReal (bound a) + ENNReal.ofReal (bound a) := add_le_add h₁ h₂ _ = b a := by rw [← two_mul] -- On the other hand, `F n a --> f a` implies that `‖F n a - f a‖ --> 0` have h : ∀ᵐ a ∂μ, Tendsto (fun n => ENNReal.ofReal ‖F n a - f a‖) atTop (𝓝 0) := by rw [← ENNReal.ofReal_zero] refine h_lim.mono fun a h => (continuous_ofReal.tendsto _).comp ?_ rwa [← tendsto_iff_norm_sub_tendsto_zero] /- Therefore, by the dominated convergence theorem for nonnegative integration, have ` ∫ ‖f a - F n a‖ --> 0 ` -/ suffices Tendsto (fun n => ∫⁻ a, ENNReal.ofReal ‖F n a - f a‖ ∂μ) atTop (𝓝 (∫⁻ _ : α, 0 ∂μ)) by rwa [lintegral_zero] at this -- Using the dominated convergence theorem. refine tendsto_lintegral_of_dominated_convergence' _ ?_ hb ?_ ?_ -- Show `fun a => ‖f a - F n a‖` is almost everywhere measurable for all `n` · exact fun n => measurable_ofReal.comp_aemeasurable ((F_measurable n).sub f_measurable).norm.aemeasurable -- Show `2 * bound` `HasFiniteIntegral` · rw [hasFiniteIntegral_iff_ofReal] at bound_hasFiniteIntegral · calc ∫⁻ a, b a ∂μ = 2 * ∫⁻ a, ENNReal.ofReal (bound a) ∂μ := by rw [lintegral_const_mul'] finiteness _ ≠ ∞ := mul_ne_top coe_ne_top bound_hasFiniteIntegral.ne filter_upwards [h_bound 0] with _ h using le_trans (norm_nonneg _) h -- Show `‖f a - F n a‖ --> 0` · exact h end DominatedConvergence section PosPart /-! Lemmas used for defining the positive part of an `L¹` function -/ @[fun_prop] theorem HasFiniteIntegral.max_zero {f : α → ℝ} (hf : HasFiniteIntegral f μ) : HasFiniteIntegral (fun a => max (f a) 0) μ := hf.mono <| Eventually.of_forall fun x => by simp [abs_le, le_abs_self] @[fun_prop] theorem HasFiniteIntegral.min_zero {f : α → ℝ} (hf : HasFiniteIntegral f μ) : HasFiniteIntegral (fun a => min (f a) 0) μ := hf.mono <| Eventually.of_forall fun x => by simpa [abs_le] using neg_abs_le _ end PosPart section NormedSpace variable {𝕜 : Type*} @[fun_prop] theorem HasFiniteIntegral.smul [NormedAddCommGroup 𝕜] [SMulZeroClass 𝕜 β] [IsBoundedSMul 𝕜 β] (c : 𝕜) {f : α → β} (hf : HasFiniteIntegral f μ) : HasFiniteIntegral (c • f) μ := by simp only [HasFiniteIntegral] calc ∫⁻ a : α, ‖c • f a‖ₑ ∂μ ≤ ∫⁻ a : α, ‖c‖ₑ * ‖f a‖ₑ ∂μ := lintegral_mono fun i ↦ enorm_smul_le _ < ∞ := by rw [lintegral_const_mul'] exacts [mul_lt_top coe_lt_top hf, coe_ne_top] -- TODO: weaken the hypothesis to a version of `ENormSMulClass` with `≤`, -- once such a typeclass exists. -- This will let us unify with `HasFiniteIntegral.smul` above. @[fun_prop] theorem HasFiniteIntegral.smul_enorm [NormedAddGroup 𝕜] [SMul 𝕜 ε''] [ENormSMulClass 𝕜 ε''] (c : 𝕜) {f : α → ε''} (hf : HasFiniteIntegral f μ) : HasFiniteIntegral (c • f) μ := by simp only [HasFiniteIntegral] calc ∫⁻ a : α, ‖c • f a‖ₑ ∂μ = ∫⁻ a : α, ‖c‖ₑ * ‖f a‖ₑ ∂μ := lintegral_congr fun i ↦ enorm_smul _ _ _ < ∞ := by rw [lintegral_const_mul'] exacts [mul_lt_top coe_lt_top hf, coe_ne_top] theorem hasFiniteIntegral_smul_iff [NormedRing 𝕜] [MulActionWithZero 𝕜 β] [IsBoundedSMul 𝕜 β] {c : 𝕜} (hc : IsUnit c) (f : α → β) : HasFiniteIntegral (c • f) μ ↔ HasFiniteIntegral f μ := by obtain ⟨c, rfl⟩ := hc constructor · intro h simpa only [smul_smul, Units.inv_mul, one_smul] using h.smul ((c⁻¹ : 𝕜ˣ) : 𝕜) exact HasFiniteIntegral.smul _ @[fun_prop] theorem HasFiniteIntegral.const_mul [NormedRing 𝕜] {f : α → 𝕜} (h : HasFiniteIntegral f μ) (c : 𝕜) : HasFiniteIntegral (fun x => c * f x) μ := h.smul c @[fun_prop] theorem HasFiniteIntegral.mul_const [NormedRing 𝕜] {f : α → 𝕜} (h : HasFiniteIntegral f μ) (c : 𝕜) : HasFiniteIntegral (fun x => f x * c) μ := h.smul (MulOpposite.op c) section count variable [MeasurableSingletonClass α] /-- A function has finite integral for the counting measure iff its enorm has finite `tsum`. -/ -- Note that asking for mere summability makes no sense, as every sequence in ℝ≥0∞ is summable. lemma hasFiniteIntegral_count_iff_enorm {f : α → ε} : HasFiniteIntegral f Measure.count ↔ tsum (‖f ·‖ₑ) < ⊤ := by simp only [hasFiniteIntegral_iff_enorm, lintegral_count] /-- A function has finite integral for the counting measure iff its norm is summable. -/ lemma hasFiniteIntegral_count_iff {f : α → β} : HasFiniteIntegral f Measure.count ↔ Summable (‖f ·‖) := by simp only [hasFiniteIntegral_iff_enorm, enorm, lintegral_count, lt_top_iff_ne_top, tsum_coe_ne_top_iff_summable, ← summable_coe, coe_nnnorm] end count section restrict variable {E : Type*} [NormedAddCommGroup E] {f : α → ε} @[fun_prop] lemma HasFiniteIntegral.restrict (h : HasFiniteIntegral f μ) {s : Set α} : HasFiniteIntegral f (μ.restrict s) := by refine lt_of_le_of_lt ?_ h simpa [Measure.restrict_univ] using lintegral_mono_set (subset_univ s) end restrict end NormedSpace end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/L1Space/Integrable.lean
import Mathlib.MeasureTheory.Function.L1Space.HasFiniteIntegral import Mathlib.MeasureTheory.Function.LpOrder import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lemmas /-! # Integrable functions In this file, the predicate `Integrable` is defined and basic properties of integrable functions are proved. Such a predicate is already available under the name `MemLp 1`. We give a direct definition which is easier to use, and show that it is equivalent to `MemLp 1`. ## Main definition * Let `f : α → β` be a function, where `α` is a `MeasureSpace` and `β` a `NormedAddCommGroup` which also a `MeasurableSpace`. Then `f` is called `Integrable` if `f` is `Measurable` and `HasFiniteIntegral f` holds. ## Implementation notes To prove something for an arbitrary integrable function, a useful theorem is `Integrable.induction` in the file `SetIntegral`. ## Tags integrable -/ noncomputable section open EMetric ENNReal Filter MeasureTheory NNReal Set TopologicalSpace open scoped Topology variable {α β γ δ ε ε' ε'' : Type*} {m : MeasurableSpace α} {μ ν : Measure α} [MeasurableSpace δ] variable [NormedAddCommGroup β] [NormedAddCommGroup γ] [TopologicalSpace ε] [ContinuousENorm ε] [TopologicalSpace ε'] [ContinuousENorm ε'] [ENorm ε''] namespace MeasureTheory /-! ### The predicate `Integrable` -/ /-- `Integrable f μ` means that `f` is measurable and that the integral `∫⁻ a, ‖f a‖ ∂μ` is finite. `Integrable f` means `Integrable f volume`. -/ @[fun_prop] def Integrable {α} {_ : MeasurableSpace α} (f : α → ε) (μ : Measure α := by volume_tac) : Prop := AEStronglyMeasurable f μ ∧ HasFiniteIntegral f μ /-- Notation for `Integrable` with respect to a non-standard σ-algebra. -/ scoped notation "Integrable[" mα "]" => @Integrable _ _ _ _ mα theorem memLp_one_iff_integrable {f : α → ε} : MemLp f 1 μ ↔ Integrable f μ := by simp_rw [Integrable, hasFiniteIntegral_iff_enorm, MemLp, eLpNorm_one_eq_lintegral_enorm] @[fun_prop] theorem Integrable.aestronglyMeasurable {f : α → ε} (hf : Integrable f μ) : AEStronglyMeasurable f μ := hf.1 @[fun_prop] theorem Integrable.aemeasurable [MeasurableSpace ε] [BorelSpace ε] [PseudoMetrizableSpace ε] {f : α → ε} (hf : Integrable f μ) : AEMeasurable f μ := hf.aestronglyMeasurable.aemeasurable @[fun_prop] theorem Integrable.hasFiniteIntegral {f : α → ε} (hf : Integrable f μ) : HasFiniteIntegral f μ := hf.2 theorem Integrable.mono_enorm {f : α → ε} {g : α → ε'} (hg : Integrable g μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ ≤ ‖g a‖ₑ) : Integrable f μ := ⟨hf, hg.hasFiniteIntegral.mono_enorm h⟩ theorem Integrable.mono {f : α → β} {g : α → γ} (hg : Integrable g μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ ‖g a‖) : Integrable f μ := ⟨hf, hg.hasFiniteIntegral.mono h⟩ theorem Integrable.mono'_enorm {f : α → ε} {g : α → ℝ≥0∞} (hg : Integrable g μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ ≤ g a) : Integrable f μ := ⟨hf, hg.hasFiniteIntegral.mono_enorm h⟩ theorem Integrable.mono' {f : α → β} {g : α → ℝ} (hg : Integrable g μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : Integrable f μ := ⟨hf, hg.hasFiniteIntegral.mono' h⟩ theorem Integrable.congr'_enorm {f : α → ε} {g : α → ε'} (hf : Integrable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ = ‖g a‖ₑ) : Integrable g μ := ⟨hg, hf.hasFiniteIntegral.congr'_enorm h⟩ theorem Integrable.congr' {f : α → β} {g : α → γ} (hf : Integrable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : Integrable g μ := ⟨hg, hf.hasFiniteIntegral.congr' h⟩ theorem integrable_congr'_enorm {f : α → ε} {g : α → ε'} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ = ‖g a‖ₑ) : Integrable f μ ↔ Integrable g μ := ⟨fun h2f => h2f.congr'_enorm hg h, fun h2g => h2g.congr'_enorm hf <| EventuallyEq.symm h⟩ theorem integrable_congr' {f : α → β} {g : α → γ} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : Integrable f μ ↔ Integrable g μ := integrable_congr'_enorm hf hg <| h.mono fun _x hx ↦ enorm_eq_iff_norm_eq.mpr hx theorem Integrable.congr {f g : α → ε} (hf : Integrable f μ) (h : f =ᵐ[μ] g) : Integrable g μ := ⟨hf.1.congr h, hf.2.congr h⟩ theorem integrable_congr {f g : α → ε} (h : f =ᵐ[μ] g) : Integrable f μ ↔ Integrable g μ := ⟨fun hf => hf.congr h, fun hg => hg.congr h.symm⟩ theorem integrable_const_iff_enorm {c : ε} (hc : ‖c‖ₑ ≠ ∞) : Integrable (fun _ : α => c) μ ↔ ‖c‖ₑ = 0 ∨ IsFiniteMeasure μ := by have : AEStronglyMeasurable (fun _ : α => c) μ := aestronglyMeasurable_const rw [Integrable, and_iff_right this, hasFiniteIntegral_const_iff_enorm hc] lemma integrable_const_iff {c : β} : Integrable (fun _ : α => c) μ ↔ c = 0 ∨ IsFiniteMeasure μ := by rw [integrable_const_iff_enorm enorm_ne_top] simp lemma integrable_const_iff_isFiniteMeasure_enorm {c : ε} (hc : ‖c‖ₑ ≠ 0) (hc' : ‖c‖ₑ ≠ ∞) : Integrable (fun _ ↦ c) μ ↔ IsFiniteMeasure μ := by simp [integrable_const_iff_enorm hc', hc, isFiniteMeasure_iff] lemma integrable_const_iff_isFiniteMeasure {c : β} (hc : c ≠ 0) : Integrable (fun _ ↦ c) μ ↔ IsFiniteMeasure μ := by simp [integrable_const_iff, hc, isFiniteMeasure_iff] theorem Integrable.of_mem_Icc_enorm [IsFiniteMeasure μ] {a b : ℝ≥0∞} (ha : a ≠ ∞) (hb : b ≠ ∞) {X : α → ℝ≥0∞} (hX : AEMeasurable X μ) (h : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) : Integrable X μ := ⟨hX.aestronglyMeasurable, .of_mem_Icc_of_ne_top ha hb h⟩ theorem Integrable.of_mem_Icc [IsFiniteMeasure μ] (a b : ℝ) {X : α → ℝ} (hX : AEMeasurable X μ) (h : ∀ᵐ ω ∂μ, X ω ∈ Set.Icc a b) : Integrable X μ := ⟨hX.aestronglyMeasurable, .of_mem_Icc a b h⟩ @[simp, fun_prop] theorem integrable_const_enorm [IsFiniteMeasure μ] {c : ε} (hc : ‖c‖ₑ ≠ ∞) : Integrable (fun _ : α ↦ c) μ := (integrable_const_iff_enorm hc).2 <| .inr ‹_› @[fun_prop] theorem integrable_const [IsFiniteMeasure μ] (c : β) : Integrable (fun _ : α => c) μ := integrable_const_iff.2 <| .inr ‹_› -- TODO: an `ENorm`-version of this lemma requires `HasFiniteIntegral.of_finite` @[fun_prop, simp] lemma Integrable.of_finite [Finite α] [MeasurableSingletonClass α] [IsFiniteMeasure μ] {f : α → β} : Integrable f μ := ⟨.of_discrete, .of_finite⟩ /-- This lemma is a special case of `Integrable.of_finite`. -/ lemma Integrable.of_isEmpty [IsEmpty α] {f : α → β} : Integrable f μ := .of_finite /-- This lemma is a special case of `Integrable.of_finite`. -/ lemma Integrable.of_subsingleton [Subsingleton α] [IsFiniteMeasure μ] {f : α → β} : Integrable f μ := .of_finite theorem MemLp.integrable_enorm_rpow {f : α → ε} {p : ℝ≥0∞} (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : Integrable (fun x : α => ‖f x‖ₑ ^ p.toReal) μ := by rw [← memLp_one_iff_integrable] exact hf.enorm_rpow hp_ne_zero hp_ne_top theorem MemLp.integrable_norm_rpow {f : α → β} {p : ℝ≥0∞} (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : Integrable (fun x : α => ‖f x‖ ^ p.toReal) μ := by rw [← memLp_one_iff_integrable] exact hf.norm_rpow hp_ne_zero hp_ne_top theorem MemLp.integrable_enorm_rpow' [IsFiniteMeasure μ] {f : α → ε} {p : ℝ≥0∞} (hf : MemLp f p μ) : Integrable (fun x : α => ‖f x‖ₑ ^ p.toReal) μ := by by_cases h_zero : p = 0 · simp [h_zero] by_cases h_top : p = ∞ · simp [h_top] exact hf.integrable_enorm_rpow h_zero h_top theorem MemLp.integrable_norm_rpow' [IsFiniteMeasure μ] {f : α → β} {p : ℝ≥0∞} (hf : MemLp f p μ) : Integrable (fun x : α => ‖f x‖ ^ p.toReal) μ := by by_cases h_zero : p = 0 · simp [h_zero] by_cases h_top : p = ∞ · simp [h_top] exact hf.integrable_norm_rpow h_zero h_top lemma MemLp.integrable_enorm_pow {f : α → ε} {p : ℕ} (hf : MemLp f p μ) (hp : p ≠ 0) : Integrable (fun x : α ↦ ‖f x‖ₑ ^ p) μ := by simpa using hf.integrable_enorm_rpow (mod_cast hp) (by simp) lemma MemLp.integrable_norm_pow {f : α → β} {p : ℕ} (hf : MemLp f p μ) (hp : p ≠ 0) : Integrable (fun x : α => ‖f x‖ ^ p) μ := by simpa using hf.integrable_norm_rpow (mod_cast hp) (by simp) lemma MemLp.integrable_enorm_pow' [IsFiniteMeasure μ] {f : α → ε} {p : ℕ} (hf : MemLp f p μ) : Integrable (fun x : α ↦ ‖f x‖ₑ ^ p) μ := by simpa using hf.integrable_enorm_rpow' lemma MemLp.integrable_norm_pow' [IsFiniteMeasure μ] {f : α → β} {p : ℕ} (hf : MemLp f p μ) : Integrable (fun x : α => ‖f x‖ ^ p) μ := by simpa using hf.integrable_norm_rpow' lemma integrable_enorm_rpow_iff {f : α → ε} {p : ℝ≥0∞} (hf : AEStronglyMeasurable f μ) (p_zero : p ≠ 0) (p_top : p ≠ ∞) : Integrable (fun x : α => ‖f x‖ₑ ^ p.toReal) μ ↔ MemLp f p μ := by rw [← memLp_enorm_rpow_iff (q := p) hf p_zero p_top, ← memLp_one_iff_integrable, ENNReal.div_self p_zero p_top] lemma integrable_norm_rpow_iff {f : α → β} {p : ℝ≥0∞} (hf : AEStronglyMeasurable f μ) (p_zero : p ≠ 0) (p_top : p ≠ ∞) : Integrable (fun x : α => ‖f x‖ ^ p.toReal) μ ↔ MemLp f p μ := by rw [← memLp_norm_rpow_iff (q := p) hf p_zero p_top, ← memLp_one_iff_integrable, ENNReal.div_self p_zero p_top] theorem Integrable.mono_measure {f : α → ε} (h : Integrable f ν) (hμ : μ ≤ ν) : Integrable f μ := ⟨h.aestronglyMeasurable.mono_measure hμ, h.hasFiniteIntegral.mono_measure hμ⟩ theorem Integrable.of_measure_le_smul {ε} [TopologicalSpace ε] [ESeminormedAddMonoid ε] {μ' : Measure α} {c : ℝ≥0∞} (hc : c ≠ ∞) (hμ'_le : μ' ≤ c • μ) {f : α → ε} (hf : Integrable f μ) : Integrable f μ' := by rw [← memLp_one_iff_integrable] at hf ⊢ exact hf.of_measure_le_smul hc hμ'_le @[fun_prop] theorem Integrable.add_measure [PseudoMetrizableSpace ε] {f : α → ε} (hμ : Integrable f μ) (hν : Integrable f ν) : Integrable f (μ + ν) := by simp_rw [← memLp_one_iff_integrable] at hμ hν ⊢ refine ⟨hμ.aestronglyMeasurable.add_measure hν.aestronglyMeasurable, ?_⟩ rw [eLpNorm_one_add_measure, ENNReal.add_lt_top] exact ⟨hμ.eLpNorm_lt_top, hν.eLpNorm_lt_top⟩ theorem Integrable.left_of_add_measure {f : α → ε} (h : Integrable f (μ + ν)) : Integrable f μ := by rw [← memLp_one_iff_integrable] at h ⊢ exact h.left_of_add_measure theorem Integrable.right_of_add_measure {f : α → ε} (h : Integrable f (μ + ν)) : Integrable f ν := by rw [← memLp_one_iff_integrable] at h ⊢ exact h.right_of_add_measure @[simp] theorem integrable_add_measure [PseudoMetrizableSpace ε] {f : α → ε} : Integrable f (μ + ν) ↔ Integrable f μ ∧ Integrable f ν := ⟨fun h => ⟨h.left_of_add_measure, h.right_of_add_measure⟩, fun h => h.1.add_measure h.2⟩ @[simp] theorem integrable_zero_measure {f : α → ε} : Integrable f (0 : Measure α) := by constructor <;> fun_prop /-- In a measurable space with measurable singletons, every function is integrable with respect to a Dirac measure. See `integrable_dirac'` for a version which requires `f` to be strongly measurable but does not need singletons to be measurable. -/ @[fun_prop] lemma integrable_dirac [MeasurableSingletonClass α] {a : α} {f : α → ε} (hfa : ‖f a‖ₑ < ∞) : Integrable f (Measure.dirac a) := ⟨aestronglyMeasurable_dirac, by simpa [HasFiniteIntegral]⟩ /-- Every strongly measurable function is integrable with respect to a Dirac measure. See `integrable_dirac` for a version which requires that singletons are measurable sets but has no hypothesis on `f`. -/ @[fun_prop] lemma integrable_dirac' {a : α} {f : α → ε} (hf : StronglyMeasurable f) (hfa : ‖f a‖ₑ < ∞) : Integrable f (Measure.dirac a) := ⟨hf.aestronglyMeasurable, by simpa [HasFiniteIntegral, lintegral_dirac' _ hf.enorm]⟩ theorem integrable_finset_sum_measure [PseudoMetrizableSpace ε] {ι} {m : MeasurableSpace α} {f : α → ε} {μ : ι → Measure α} {s : Finset ι} : Integrable f (∑ i ∈ s, μ i) ↔ ∀ i ∈ s, Integrable f (μ i) := by classical induction s using Finset.induction_on <;> simp [*] section variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] @[fun_prop] theorem Integrable.smul_measure {f : α → ε} (h : Integrable f μ) {c : ℝ≥0∞} (hc : c ≠ ∞) : Integrable f (c • μ) := by rw [← memLp_one_iff_integrable] at h ⊢ exact h.smul_measure hc @[fun_prop] theorem Integrable.smul_measure_nnreal {f : α → ε} (h : Integrable f μ) {c : ℝ≥0} : Integrable f (c • μ) := by apply h.smul_measure simp theorem integrable_smul_measure {f : α → ε} {c : ℝ≥0∞} (h₁ : c ≠ 0) (h₂ : c ≠ ∞) : Integrable f (c • μ) ↔ Integrable f μ := ⟨fun h => by simpa only [smul_smul, ENNReal.inv_mul_cancel h₁ h₂, one_smul] using h.smul_measure (ENNReal.inv_ne_top.2 h₁), fun h => h.smul_measure h₂⟩ theorem integrable_inv_smul_measure {f : α → ε} {c : ℝ≥0∞} (h₁ : c ≠ 0) (h₂ : c ≠ ∞) : Integrable f (c⁻¹ • μ) ↔ Integrable f μ := integrable_smul_measure (by simpa using h₂) (by simpa using h₁) theorem Integrable.to_average {f : α → ε} (h : Integrable f μ) : Integrable f ((μ univ)⁻¹ • μ) := by rcases eq_or_ne μ 0 with (rfl | hne) · rwa [smul_zero] · apply h.smul_measure simpa open scoped Classical in theorem integrable_average [IsFiniteMeasure μ] {f : α → ε} : Integrable f ((μ univ)⁻¹ • μ) ↔ Integrable f μ := (eq_or_ne μ 0).by_cases (fun h => by simp [h]) fun h => integrable_smul_measure (ENNReal.inv_ne_zero.2 <| by finiteness) (ENNReal.inv_ne_top.2 <| mt Measure.measure_univ_eq_zero.1 h) end section variable {α' : Type*} [MeasurableSpace α'] theorem integrable_map_measure {f : α → α'} {g : α' → ε} (hg : AEStronglyMeasurable g (Measure.map f μ)) (hf : AEMeasurable f μ) : Integrable g (Measure.map f μ) ↔ Integrable (g ∘ f) μ := by simp_rw [← memLp_one_iff_integrable] exact memLp_map_measure_iff hg hf theorem Integrable.comp_aemeasurable {f : α → α'} {g : α' → ε} (hg : Integrable g (Measure.map f μ)) (hf : AEMeasurable f μ) : Integrable (g ∘ f) μ := (integrable_map_measure hg.aestronglyMeasurable hf).mp hg theorem Integrable.comp_measurable {f : α → α'} {g : α' → ε} (hg : Integrable g (Measure.map f μ)) (hf : Measurable f) : Integrable (g ∘ f) μ := hg.comp_aemeasurable hf.aemeasurable end theorem _root_.MeasurableEmbedding.integrable_map_iff {f : α → δ} (hf : MeasurableEmbedding f) {g : δ → ε} : Integrable g (Measure.map f μ) ↔ Integrable (g ∘ f) μ := by simp_rw [← memLp_one_iff_integrable] exact hf.memLp_map_measure_iff theorem integrable_map_equiv (f : α ≃ᵐ δ) (g : δ → ε) : Integrable g (Measure.map f μ) ↔ Integrable (g ∘ f) μ := by simp_rw [← memLp_one_iff_integrable] exact f.memLp_map_measure_iff theorem MeasurePreserving.integrable_comp {ν : Measure δ} {g : δ → ε} {f : α → δ} (hf : MeasurePreserving f μ ν) (hg : AEStronglyMeasurable g ν) : Integrable (g ∘ f) μ ↔ Integrable g ν := by rw [← hf.map_eq] at hg ⊢ exact (integrable_map_measure hg hf.measurable.aemeasurable).symm theorem MeasurePreserving.integrable_comp_of_integrable {ν : Measure δ} {g : δ → ε} {f : α → δ} (hf : MeasurePreserving f μ ν) (hg : Integrable g ν) : Integrable (g ∘ f) μ := hf.integrable_comp hg.aestronglyMeasurable |>.mpr hg theorem MeasurePreserving.integrable_comp_emb {f : α → δ} {ν} (h₁ : MeasurePreserving f μ ν) (h₂ : MeasurableEmbedding f) {g : δ → ε} : Integrable (g ∘ f) μ ↔ Integrable g ν := h₁.map_eq ▸ Iff.symm h₂.integrable_map_iff theorem lintegral_edist_lt_top {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : (∫⁻ a, edist (f a) (g a) ∂μ) < ∞ := lt_of_le_of_lt (lintegral_edist_triangle hf.aestronglyMeasurable aestronglyMeasurable_zero) (ENNReal.add_lt_top.2 <| by simp_rw [Pi.zero_apply, ← hasFiniteIntegral_iff_edist] exact ⟨hf.hasFiniteIntegral, hg.hasFiniteIntegral⟩) section ESeminormedAddMonoid variable {ε' : Type*} [TopologicalSpace ε'] [ESeminormedAddMonoid ε'] variable (α ε') in @[simp] theorem integrable_zero (μ : Measure α) : Integrable (fun _ => (0 : ε')) μ := by simp [Integrable, aestronglyMeasurable_const] theorem Integrable.add' {f g : α → ε'} (hf : Integrable f μ) (hg : Integrable g μ) : HasFiniteIntegral (f + g) μ := calc ∫⁻ a, ‖f a + g a‖ₑ ∂μ ≤ ∫⁻ a, ‖f a‖ₑ + ‖g a‖ₑ ∂μ := lintegral_mono fun _ ↦ enorm_add_le _ _ _ = _ := lintegral_enorm_add_left hf.aestronglyMeasurable _ _ < ∞ := add_lt_top.2 ⟨hf.hasFiniteIntegral, hg.hasFiniteIntegral⟩ @[fun_prop] theorem Integrable.add [ContinuousAdd ε'] {f g : α → ε'} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f + g) μ := ⟨hf.aestronglyMeasurable.add hg.aestronglyMeasurable, hf.add' hg⟩ @[fun_prop] theorem Integrable.add'' [ContinuousAdd ε'] {f g : α → ε'} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (fun x ↦ f x + g x) μ := hf.add hg @[simp] lemma Integrable.of_subsingleton_codomain [Subsingleton ε'] {f : α → ε'} : Integrable f μ := integrable_zero _ _ _ |>.congr <| .of_forall fun _ ↦ Subsingleton.elim _ _ end ESeminormedAddMonoid section ESeminormedAddCommMonoid variable {ε' : Type*} [TopologicalSpace ε'] [ESeminormedAddCommMonoid ε'] [ContinuousAdd ε'] @[fun_prop] theorem integrable_finset_sum' {ι} (s : Finset ι) {f : ι → α → ε'} (hf : ∀ i ∈ s, Integrable (f i) μ) : Integrable (∑ i ∈ s, f i) μ := Finset.sum_induction f (fun g => Integrable g μ) (fun _ _ => Integrable.add) (integrable_zero _ _ _) hf @[fun_prop] theorem integrable_finset_sum {ι} (s : Finset ι) {f : ι → α → ε'} (hf : ∀ i ∈ s, Integrable (f i) μ) : Integrable (fun a => ∑ i ∈ s, f i a) μ := by simpa only [← Finset.sum_apply] using integrable_finset_sum' s hf end ESeminormedAddCommMonoid /-- If `f` is integrable, then so is `-f`. See `Integrable.neg'` for the same statement, but formulated with `x ↦ - f x` instead of `-f`. -/ @[fun_prop] theorem Integrable.neg {f : α → β} (hf : Integrable f μ) : Integrable (-f) μ := ⟨hf.aestronglyMeasurable.neg, by fun_prop⟩ /-- If `f` is integrable, then so is `fun x ↦ - f x`. See `Integrable.neg` for the same statement, but formulated with `-f` instead of `fun x ↦ - f x`. -/ @[fun_prop] theorem Integrable.neg' {f : α → β} (hf : Integrable f μ) : Integrable (fun x ↦ - f x) μ := ⟨hf.aestronglyMeasurable.neg, hf.hasFiniteIntegral.neg⟩ @[simp] theorem integrable_neg_iff {f : α → β} : Integrable (-f) μ ↔ Integrable f μ := ⟨fun h => neg_neg f ▸ h.neg, Integrable.neg⟩ /-- if `f` is integrable, then `f + g` is integrable iff `g` is. See `integrable_add_iff_integrable_right'` for the same statement with `fun x ↦ f x + g x` instead of `f + g`. -/ @[simp] lemma integrable_add_iff_integrable_right {f g : α → β} (hf : Integrable f μ) : Integrable (f + g) μ ↔ Integrable g μ := ⟨fun h ↦ show g = f + g + (-f) by simp only [add_neg_cancel_comm] ▸ h.add hf.neg, fun h ↦ hf.add h⟩ /-- if `f` is integrable, then `fun x ↦ f x + g x` is integrable iff `g` is. See `integrable_add_iff_integrable_right` for the same statement with `f + g` instead of `fun x ↦ f x + g x`. -/ @[simp] lemma integrable_add_iff_integrable_right' {f g : α → β} (hf : Integrable f μ) : Integrable (fun x ↦ f x + g x) μ ↔ Integrable g μ := integrable_add_iff_integrable_right hf /-- if `f` is integrable, then `g + f` is integrable iff `g` is. See `integrable_add_iff_integrable_left'` for the same statement with `fun x ↦ g x + f x` instead of `g + f`. -/ @[simp] lemma integrable_add_iff_integrable_left {f g : α → β} (hf : Integrable f μ) : Integrable (g + f) μ ↔ Integrable g μ := by rw [add_comm, integrable_add_iff_integrable_right hf] /-- if `f` is integrable, then `fun x ↦ g x + f x` is integrable iff `g` is. See `integrable_add_iff_integrable_left'` for the same statement with `g + f` instead of `fun x ↦ g x + f x`. -/ @[simp] lemma integrable_add_iff_integrable_left' {f g : α → β} (hf : Integrable f μ) : Integrable (fun x ↦ g x + f x) μ ↔ Integrable g μ := integrable_add_iff_integrable_left hf lemma integrable_left_of_integrable_add_of_nonneg {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : 0 ≤ᵐ[μ] f) (hg : 0 ≤ᵐ[μ] g) (h_int : Integrable (f + g) μ) : Integrable f μ := by refine h_int.mono' h_meas ?_ filter_upwards [hf, hg] with a haf hag exact (Real.norm_of_nonneg haf).symm ▸ le_add_of_nonneg_right hag lemma integrable_right_of_integrable_add_of_nonneg {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : 0 ≤ᵐ[μ] f) (hg : 0 ≤ᵐ[μ] g) (h_int : Integrable (f + g) μ) : Integrable g μ := integrable_left_of_integrable_add_of_nonneg ((AEStronglyMeasurable.add_iff_right h_meas).mp h_int.aestronglyMeasurable) hg hf (add_comm f g ▸ h_int) lemma integrable_add_iff_of_nonneg {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : 0 ≤ᵐ[μ] f) (hg : 0 ≤ᵐ[μ] g) : Integrable (f + g) μ ↔ Integrable f μ ∧ Integrable g μ := ⟨fun h ↦ ⟨integrable_left_of_integrable_add_of_nonneg h_meas hf hg h, integrable_right_of_integrable_add_of_nonneg h_meas hf hg h⟩, fun ⟨hf, hg⟩ ↦ hf.add hg⟩ lemma integrable_add_iff_of_nonpos {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : f ≤ᵐ[μ] 0) (hg : g ≤ᵐ[μ] 0) : Integrable (f + g) μ ↔ Integrable f μ ∧ Integrable g μ := by rw [← integrable_neg_iff, ← integrable_neg_iff (f := f), ← integrable_neg_iff (f := g), neg_add] exact integrable_add_iff_of_nonneg h_meas.neg (hf.mono (fun _ ↦ neg_nonneg_of_nonpos)) (hg.mono (fun _ ↦ neg_nonneg_of_nonpos)) lemma integrable_add_const_iff [IsFiniteMeasure μ] {f : α → β} {c : β} : Integrable (fun x ↦ f x + c) μ ↔ Integrable f μ := integrable_add_iff_integrable_left (integrable_const _) lemma integrable_const_add_iff [IsFiniteMeasure μ] {f : α → β} {c : β} : Integrable (fun x ↦ c + f x) μ ↔ Integrable f μ := integrable_add_iff_integrable_right (integrable_const _) -- TODO: generalise these lemmas to an `ENormedAddCommSubMonoid` @[fun_prop] theorem Integrable.sub {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f - g) μ := by simpa only [sub_eq_add_neg] using hf.add hg.neg @[fun_prop] theorem Integrable.sub' {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (fun a ↦ f a - g a) μ := by simpa only [sub_eq_add_neg] using hf.add hg.neg @[fun_prop] theorem Integrable.enorm {f : α → ε} (hf : Integrable f μ) : Integrable (‖f ·‖ₑ) μ := by constructor <;> fun_prop @[fun_prop] theorem Integrable.norm {f : α → β} (hf : Integrable f μ) : Integrable (fun a => ‖f a‖) μ := by constructor <;> fun_prop @[fun_prop] theorem Integrable.inf {β} [NormedAddCommGroup β] [Lattice β] [HasSolidNorm β] [IsOrderedAddMonoid β] {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f ⊓ g) μ := by rw [← memLp_one_iff_integrable] at hf hg ⊢ exact hf.inf hg @[fun_prop] theorem Integrable.sup {β} [NormedAddCommGroup β] [Lattice β] [HasSolidNorm β] [IsOrderedAddMonoid β] {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f ⊔ g) μ := by rw [← memLp_one_iff_integrable] at hf hg ⊢ exact hf.sup hg @[fun_prop] theorem Integrable.abs {β} [NormedAddCommGroup β] [Lattice β] [HasSolidNorm β] [IsOrderedAddMonoid β] {f : α → β} (hf : Integrable f μ) : Integrable (fun a => |f a|) μ := by rw [← memLp_one_iff_integrable] at hf ⊢ exact hf.abs -- TODO: generalise this to enorms, once there is an `ENormedDivisionRing` class theorem Integrable.bdd_mul {F : Type*} [NormedDivisionRing F] {f g : α → F} (hint : Integrable g μ) (hm : AEStronglyMeasurable f μ) (hfbdd : ∃ C, ∀ x, ‖f x‖ ≤ C) : Integrable (fun x => f x * g x) μ := by rcases isEmpty_or_nonempty α with hα | hα · rw [μ.eq_zero_of_isEmpty] exact integrable_zero_measure · refine ⟨hm.mul hint.1, ?_⟩ obtain ⟨C, hC⟩ := hfbdd have hCnonneg : 0 ≤ C := le_trans (norm_nonneg _) (hC hα.some) have : (fun x => ‖f x * g x‖₊) ≤ fun x => ⟨C, hCnonneg⟩ * ‖g x‖₊ := by intro x simp only [nnnorm_mul] exact mul_le_mul_of_nonneg_right (hC x) (zero_le _) refine lt_of_le_of_lt (lintegral_mono_nnreal this) ?_ simp only [ENNReal.coe_mul] rw [lintegral_const_mul' _ _ ENNReal.coe_ne_top] exact ENNReal.mul_lt_top ENNReal.coe_lt_top hint.2 -- TODO: generalise the following lemmas to enorm classes /-- **Hölder's inequality for integrable functions**: the scalar multiplication of an integrable vector-valued function by a scalar function with finite essential supremum is integrable. -/ theorem Integrable.essSup_smul {R : Type*} [NormedRing R] [Module R β] [IsBoundedSMul R β] {f : α → β} (hf : Integrable f μ) {g : α → R} (g_aestronglyMeasurable : AEStronglyMeasurable g μ) (ess_sup_g : essSup (‖g ·‖ₑ) μ ≠ ∞) : Integrable (fun x : α => g x • f x) μ := by rw [← memLp_one_iff_integrable] at * refine ⟨g_aestronglyMeasurable.smul hf.1, ?_⟩ have hg' : eLpNorm g ∞ μ ≠ ∞ := by rwa [eLpNorm_exponent_top] calc eLpNorm (fun x : α => g x • f x) 1 μ ≤ _ := by simpa using MeasureTheory.eLpNorm_smul_le_mul_eLpNorm hf.1 g_aestronglyMeasurable (p := ∞) (q := 1) _ < ∞ := ENNReal.mul_lt_top hg'.lt_top hf.2 /-- Hölder's inequality for integrable functions: the scalar multiplication of an integrable scalar-valued function by a vector-value function with finite essential supremum is integrable. -/ theorem Integrable.smul_essSup {𝕜 : Type*} [NormedRing 𝕜] [MulActionWithZero 𝕜 β] [IsBoundedSMul 𝕜 β] {f : α → 𝕜} (hf : Integrable f μ) {g : α → β} (g_aestronglyMeasurable : AEStronglyMeasurable g μ) (ess_sup_g : essSup (‖g ·‖ₑ) μ ≠ ∞) : Integrable (fun x : α => f x • g x) μ := by rw [← memLp_one_iff_integrable] at * refine ⟨hf.1.smul g_aestronglyMeasurable, ?_⟩ have hg' : eLpNorm g ∞ μ ≠ ∞ := by rwa [eLpNorm_exponent_top] calc eLpNorm (fun x : α => f x • g x) 1 μ ≤ _ := by simpa using MeasureTheory.eLpNorm_smul_le_mul_eLpNorm g_aestronglyMeasurable hf.1 (p := 1) (q := ∞) _ < ∞ := ENNReal.mul_lt_top hf.2 hg'.lt_top theorem integrable_enorm_iff {f : α → ε} (hf : AEStronglyMeasurable f μ) : Integrable (‖f ·‖ₑ) μ ↔ Integrable f μ := by simp_rw [Integrable, and_iff_right hf, and_iff_right hf.enorm.aestronglyMeasurable, hasFiniteIntegral_enorm_iff] theorem integrable_norm_iff {f : α → β} (hf : AEStronglyMeasurable f μ) : Integrable (fun a => ‖f a‖) μ ↔ Integrable f μ := by simp_rw [Integrable, and_iff_right hf, and_iff_right hf.norm, hasFiniteIntegral_norm_iff] -- TODO: generalise this lemma to an `ENormedAddCommSubMonoid` theorem integrable_of_norm_sub_le {f₀ f₁ : α → β} {g : α → ℝ} (hf₁_m : AEStronglyMeasurable f₁ μ) (hf₀_i : Integrable f₀ μ) (hg_i : Integrable g μ) (h : ∀ᵐ a ∂μ, ‖f₀ a - f₁ a‖ ≤ g a) : Integrable f₁ μ := haveI : ∀ᵐ a ∂μ, ‖f₁ a‖ ≤ ‖f₀ a‖ + g a := by apply h.mono intro a ha calc ‖f₁ a‖ ≤ ‖f₀ a‖ + ‖f₀ a - f₁ a‖ := norm_le_insert _ _ _ ≤ ‖f₀ a‖ + g a := by gcongr Integrable.mono' (hf₀_i.norm.add hg_i) hf₁_m this lemma integrable_of_le_of_le {f g₁ g₂ : α → ℝ} (hf : AEStronglyMeasurable f μ) (h_le₁ : g₁ ≤ᵐ[μ] f) (h_le₂ : f ≤ᵐ[μ] g₂) (h_int₁ : Integrable g₁ μ) (h_int₂ : Integrable g₂ μ) : Integrable f μ := by have : ∀ᵐ x ∂μ, ‖f x‖ ≤ max ‖g₁ x‖ ‖g₂ x‖ := by filter_upwards [h_le₁, h_le₂] with x hx1 hx2 simp only [Real.norm_eq_abs] exact abs_le_max_abs_abs hx1 hx2 have h_le_add : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖‖g₁ x‖ + ‖g₂ x‖‖ := by filter_upwards [this] with x hx refine hx.trans ?_ conv_rhs => rw [Real.norm_of_nonneg (by positivity)] exact max_le_add_of_nonneg (norm_nonneg _) (norm_nonneg _) exact Integrable.mono (by fun_prop) hf h_le_add -- TODO: generalising this to enorms requires defining a product instance for enormed monoids first @[fun_prop] theorem Integrable.prodMk {f : α → β} {g : α → γ} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (fun x => (f x, g x)) μ := ⟨by fun_prop, (hf.norm.add' hg.norm).mono <| Eventually.of_forall fun x => calc max ‖f x‖ ‖g x‖ ≤ ‖f x‖ + ‖g x‖ := max_le_add_of_nonneg (norm_nonneg _) (norm_nonneg _) _ ≤ ‖‖f x‖ + ‖g x‖‖ := le_abs_self _⟩ theorem MemLp.integrable {q : ℝ≥0∞} (hq1 : 1 ≤ q) {f : α → ε} [IsFiniteMeasure μ] (hfq : MemLp f q μ) : Integrable f μ := memLp_one_iff_integrable.mp (hfq.mono_exponent hq1) /-- A non-quantitative version of Markov inequality for integrable functions: the measure of points where `‖f x‖ₑ ≥ ε` is finite for all positive `ε`. -/ theorem Integrable.measure_enorm_ge_lt_top {E : Type*} [TopologicalSpace E] [ContinuousENorm E] {f : α → E} (hf : Integrable f μ) {ε : ℝ≥0∞} (hε : 0 < ε) (hε' : ε ≠ ∞) : μ { x | ε ≤ ‖f x‖ₑ } < ∞ := by refine meas_ge_le_mul_pow_eLpNorm_enorm μ one_ne_zero one_ne_top hf.1 hε.ne' (by simp [hε']) |>.trans_lt ?_ apply ENNReal.mul_lt_top · simpa only [ENNReal.toReal_one, ENNReal.rpow_one, ENNReal.inv_lt_top, ENNReal.ofReal_pos] using hε · simpa only [ENNReal.toReal_one, ENNReal.rpow_one] using (memLp_one_iff_integrable.2 hf).eLpNorm_lt_top /-- A non-quantitative version of Markov inequality for integrable functions: the measure of points where `‖f x‖ ≥ ε` is finite for all positive `ε`. -/ theorem Integrable.measure_norm_ge_lt_top {f : α → β} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : μ { x | ε ≤ ‖f x‖ } < ∞ := by convert Integrable.measure_enorm_ge_lt_top hf (ofReal_pos.mpr hε) ofReal_ne_top with x rw [← Real.enorm_of_nonneg hε.le, enorm_le_iff_norm_le, Real.norm_of_nonneg hε.le] /-- A non-quantitative version of Markov inequality for integrable functions: the measure of points where `‖f x‖ₑ > ε` is finite for all positive `ε`. -/ lemma Integrable.measure_norm_gt_lt_top_enorm {E : Type*} [TopologicalSpace E] [ContinuousENorm E] {f : α → E} (hf : Integrable f μ) {ε : ℝ≥0∞} (hε : 0 < ε) : μ {x | ε < ‖f x‖ₑ} < ∞ := by by_cases hε' : ε = ∞ · simp [hε'] exact lt_of_le_of_lt (measure_mono (fun _ h ↦ (Set.mem_setOf_eq ▸ h).le)) (hf.measure_enorm_ge_lt_top hε hε') /-- A non-quantitative version of Markov inequality for integrable functions: the measure of points where `‖f x‖ > ε` is finite for all positive `ε`. -/ lemma Integrable.measure_norm_gt_lt_top {f : α → β} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : μ {x | ε < ‖f x‖} < ∞ := lt_of_le_of_lt (measure_mono (fun _ h ↦ (Set.mem_setOf_eq ▸ h).le)) (hf.measure_norm_ge_lt_top hε) -- TODO: try generalising all lemmas below to enorm classes /-- If `f` is `ℝ`-valued and integrable, then for any `c > 0` the set `{x | f x ≥ c}` has finite measure. -/ lemma Integrable.measure_ge_lt_top {f : α → ℝ} (hf : Integrable f μ) {ε : ℝ} (ε_pos : 0 < ε) : μ {a : α | ε ≤ f a} < ∞ := by refine lt_of_le_of_lt (measure_mono ?_) (hf.measure_norm_ge_lt_top ε_pos) intro x hx simp only [Real.norm_eq_abs, Set.mem_setOf_eq] at hx ⊢ exact hx.trans (le_abs_self _) /-- If `f` is `ℝ`-valued and integrable, then for any `c < 0` the set `{x | f x ≤ c}` has finite measure. -/ lemma Integrable.measure_le_lt_top {f : α → ℝ} (hf : Integrable f μ) {c : ℝ} (c_neg : c < 0) : μ {a : α | f a ≤ c} < ∞ := by refine lt_of_le_of_lt (measure_mono ?_) (hf.measure_norm_ge_lt_top (show 0 < -c by linarith)) intro x hx simp only [Real.norm_eq_abs, Set.mem_setOf_eq] at hx ⊢ exact (show -c ≤ - f x by linarith).trans (neg_le_abs _) /-- If `f` is `ℝ`-valued and integrable, then for any `c > 0` the set `{x | f x > c}` has finite measure. -/ lemma Integrable.measure_gt_lt_top {f : α → ℝ} (hf : Integrable f μ) {ε : ℝ} (ε_pos : 0 < ε) : μ {a : α | ε < f a} < ∞ := lt_of_le_of_lt (measure_mono (fun _ hx ↦ (Set.mem_setOf_eq ▸ hx).le)) (Integrable.measure_ge_lt_top hf ε_pos) /-- If `f` is `ℝ`-valued and integrable, then for any `c < 0` the set `{x | f x < c}` has finite measure. -/ lemma Integrable.measure_lt_lt_top {f : α → ℝ} (hf : Integrable f μ) {c : ℝ} (c_neg : c < 0) : μ {a : α | f a < c} < ∞ := lt_of_le_of_lt (measure_mono (fun _ hx ↦ (Set.mem_setOf_eq ▸ hx).le)) (Integrable.measure_le_lt_top hf c_neg) theorem LipschitzWith.integrable_comp_iff_of_antilipschitz {K K'} {f : α → β} {g : β → γ} (hg : LipschitzWith K g) (hg' : AntilipschitzWith K' g) (g0 : g 0 = 0) : Integrable (g ∘ f) μ ↔ Integrable f μ := by simp [← memLp_one_iff_integrable, hg.memLp_comp_iff_of_antilipschitz hg' g0] @[fun_prop] theorem Integrable.real_toNNReal {f : α → ℝ} (hf : Integrable f μ) : Integrable (fun x => ((f x).toNNReal : ℝ)) μ := by refine ⟨by fun_prop, ?_⟩ rw [hasFiniteIntegral_iff_norm] refine lt_of_le_of_lt ?_ ((hasFiniteIntegral_iff_norm _).1 hf.hasFiniteIntegral) apply lintegral_mono intro x simp [abs_le, le_abs_self] theorem ofReal_toReal_ae_eq {f : α → ℝ≥0∞} (hf : ∀ᵐ x ∂μ, f x < ∞) : (fun x => ENNReal.ofReal (f x).toReal) =ᵐ[μ] f := by filter_upwards [hf] intro x hx simp only [hx.ne, ofReal_toReal, Ne, not_false_iff] theorem coe_toNNReal_ae_eq {f : α → ℝ≥0∞} (hf : ∀ᵐ x ∂μ, f x < ∞) : (fun x => ((f x).toNNReal : ℝ≥0∞)) =ᵐ[μ] f := by filter_upwards [hf] intro x hx simp only [hx.ne, Ne, not_false_iff, coe_toNNReal] section count variable [MeasurableSingletonClass α] {f : α → β} /-- A function is integrable for the counting measure iff its norm is summable. -/ lemma integrable_count_iff : Integrable f Measure.count ↔ Summable (‖f ·‖) := by -- Note: this proof would be much easier if we assumed `SecondCountableTopology G`. Without -- this we have to justify the claim that `f` lands a.e. in a separable subset, which is true -- (because summable functions have countable range) but slightly tedious to check. rw [Integrable, hasFiniteIntegral_count_iff, and_iff_right_iff_imp] intro hs have hs' : (Function.support f).Countable := by simpa only [Ne, Pi.zero_apply, eq_comm, Function.support, norm_eq_zero] using hs.countable_support letI : MeasurableSpace β := borel β haveI : BorelSpace β := ⟨rfl⟩ refine aestronglyMeasurable_iff_aemeasurable_separable.mpr ⟨?_, ?_⟩ · refine (measurable_zero.measurable_of_countable_ne ?_).aemeasurable simpa only [Ne, Pi.zero_apply, eq_comm, Function.support] using hs' · refine ⟨f '' univ, ?_, ae_of_all _ fun a ↦ ⟨a, ⟨mem_univ _, rfl⟩⟩⟩ suffices f '' univ ⊆ (f '' f.support) ∪ {0} from (((hs'.image f).union (countable_singleton 0)).mono this).isSeparable grind [Function.mem_support] end count section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] theorem integrable_withDensity_iff_integrable_coe_smul {f : α → ℝ≥0} (hf : Measurable f) {g : α → E} : Integrable g (μ.withDensity fun x => f x) ↔ Integrable (fun x => (f x : ℝ) • g x) μ := by by_cases H : AEStronglyMeasurable (fun x : α => (f x : ℝ) • g x) μ · simp only [Integrable, aestronglyMeasurable_withDensity_iff hf, hasFiniteIntegral_iff_enorm, H, true_and] rw [lintegral_withDensity_eq_lintegral_mul₀' hf.coe_nnreal_ennreal.aemeasurable] · simp [enorm_smul] · simpa [aemeasurable_withDensity_ennreal_iff hf, enorm_smul] using H.enorm · simp only [Integrable, aestronglyMeasurable_withDensity_iff hf, H, false_and] theorem integrable_withDensity_iff_integrable_smul {f : α → ℝ≥0} (hf : Measurable f) {g : α → E} : Integrable g (μ.withDensity fun x => f x) ↔ Integrable (fun x => f x • g x) μ := integrable_withDensity_iff_integrable_coe_smul hf theorem integrable_withDensity_iff_integrable_smul' {f : α → ℝ≥0∞} (hf : Measurable f) (hflt : ∀ᵐ x ∂μ, f x < ∞) {g : α → E} : Integrable g (μ.withDensity f) ↔ Integrable (fun x => (f x).toReal • g x) μ := by rw [← withDensity_congr_ae (coe_toNNReal_ae_eq hflt), integrable_withDensity_iff_integrable_smul] · simp_rw [NNReal.smul_def, ENNReal.toReal] · exact hf.ennreal_toNNReal theorem integrable_withDensity_iff_integrable_coe_smul₀ {f : α → ℝ≥0} (hf : AEMeasurable f μ) {g : α → E} : Integrable g (μ.withDensity fun x => f x) ↔ Integrable (fun x => (f x : ℝ) • g x) μ := calc Integrable g (μ.withDensity fun x => f x) ↔ Integrable g (μ.withDensity fun x => (hf.mk f x : ℝ≥0)) := by suffices (fun x => (f x : ℝ≥0∞)) =ᵐ[μ] (fun x => (hf.mk f x : ℝ≥0)) by rw [withDensity_congr_ae this] filter_upwards [hf.ae_eq_mk] with x hx simp [hx] _ ↔ Integrable (fun x => ((hf.mk f x : ℝ≥0) : ℝ) • g x) μ := integrable_withDensity_iff_integrable_coe_smul hf.measurable_mk _ ↔ Integrable (fun x => (f x : ℝ) • g x) μ := by apply integrable_congr filter_upwards [hf.ae_eq_mk] with x hx simp [hx] theorem integrable_withDensity_iff_integrable_smul₀' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hflt : ∀ᵐ x ∂μ, f x < ∞) {g : α → E} : Integrable g (μ.withDensity f) ↔ Integrable (fun x => (f x).toReal • g x) μ := by rw [← withDensity_congr_ae (coe_toNNReal_ae_eq hflt), integrable_withDensity_iff_integrable_coe_smul₀] · congr! · exact hf.ennreal_toNNReal theorem integrable_withDensity_iff_integrable_smul₀ {f : α → ℝ≥0} (hf : AEMeasurable f μ) {g : α → E} : Integrable g (μ.withDensity fun x => f x) ↔ Integrable (fun x => f x • g x) μ := integrable_withDensity_iff_integrable_coe_smul₀ hf end theorem integrable_withDensity_iff {f : α → ℝ≥0∞} (hf : Measurable f) (hflt : ∀ᵐ x ∂μ, f x < ∞) {g : α → ℝ} : Integrable g (μ.withDensity f) ↔ Integrable (fun x => g x * (f x).toReal) μ := by have : (fun x => g x * (f x).toReal) = fun x => (f x).toReal • g x := by simp [mul_comm] rw [this] exact integrable_withDensity_iff_integrable_smul' hf hflt section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] theorem memL1_smul_of_L1_withDensity {f : α → ℝ≥0} (f_meas : Measurable f) (u : Lp E 1 (μ.withDensity fun x => f x)) : MemLp (fun x => f x • u x) 1 μ := memLp_one_iff_integrable.2 <| (integrable_withDensity_iff_integrable_smul f_meas).1 <| memLp_one_iff_integrable.1 (Lp.memLp u) variable (μ) /-- The map `u ↦ f • u` is an isometry between the `L^1` spaces for `μ.withDensity f` and `μ`. -/ noncomputable def withDensitySMulLI {f : α → ℝ≥0} (f_meas : Measurable f) : Lp E 1 (μ.withDensity fun x => f x) →ₗᵢ[ℝ] Lp E 1 μ where toFun u := (memL1_smul_of_L1_withDensity f_meas u).toLp _ map_add' := by intro u v ext1 filter_upwards [(memL1_smul_of_L1_withDensity f_meas u).coeFn_toLp, (memL1_smul_of_L1_withDensity f_meas v).coeFn_toLp, (memL1_smul_of_L1_withDensity f_meas (u + v)).coeFn_toLp, Lp.coeFn_add ((memL1_smul_of_L1_withDensity f_meas u).toLp _) ((memL1_smul_of_L1_withDensity f_meas v).toLp _), (ae_withDensity_iff f_meas.coe_nnreal_ennreal).1 (Lp.coeFn_add u v)] intro x hu hv huv h' h'' rw [huv, h', Pi.add_apply, hu, hv] rcases eq_or_ne (f x) 0 with (hx | hx) · simp only [hx, zero_smul, add_zero] · rw [h'' _, Pi.add_apply, smul_add] simpa only [Ne, ENNReal.coe_eq_zero] using hx map_smul' := by intro r u ext1 filter_upwards [(ae_withDensity_iff f_meas.coe_nnreal_ennreal).1 (Lp.coeFn_smul r u), (memL1_smul_of_L1_withDensity f_meas (r • u)).coeFn_toLp, Lp.coeFn_smul r ((memL1_smul_of_L1_withDensity f_meas u).toLp _), (memL1_smul_of_L1_withDensity f_meas u).coeFn_toLp] intro x h h' h'' h''' rw [RingHom.id_apply, h', h'', Pi.smul_apply, h'''] rcases eq_or_ne (f x) 0 with (hx | hx) · simp only [hx, zero_smul, smul_zero] · rw [h _, smul_comm, Pi.smul_apply] simpa only [Ne, ENNReal.coe_eq_zero] using hx norm_map' := by intro u simp only [eLpNorm, LinearMap.coe_mk, AddHom.coe_mk, one_ne_zero, ENNReal.one_ne_top, ENNReal.toReal_one, if_false, eLpNorm', ENNReal.rpow_one, _root_.div_one, Lp.norm_def] rw [lintegral_withDensity_eq_lintegral_mul_non_measurable _ f_meas.coe_nnreal_ennreal (Filter.Eventually.of_forall fun x => ENNReal.coe_lt_top)] congr 1 apply lintegral_congr_ae filter_upwards [(memL1_smul_of_L1_withDensity f_meas u).coeFn_toLp] with x hx rw [hx] simp [NNReal.smul_def, enorm_smul] @[simp] theorem withDensitySMulLI_apply {f : α → ℝ≥0} (f_meas : Measurable f) (u : Lp E 1 (μ.withDensity fun x => f x)) : withDensitySMulLI μ (E := E) f_meas u = (memL1_smul_of_L1_withDensity f_meas u).toLp fun x => f x • u x := rfl end section ENNReal theorem mem_L1_toReal_of_lintegral_ne_top {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hfi : ∫⁻ x, f x ∂μ ≠ ∞) : MemLp (fun x ↦ (f x).toReal) 1 μ := by rw [MemLp, eLpNorm_one_eq_lintegral_enorm] exact ⟨(AEMeasurable.ennreal_toReal hfm).aestronglyMeasurable, hasFiniteIntegral_toReal_of_lintegral_ne_top hfi⟩ theorem integrable_toReal_of_lintegral_ne_top {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hfi : ∫⁻ x, f x ∂μ ≠ ∞) : Integrable (fun x ↦ (f x).toReal) μ := memLp_one_iff_integrable.1 <| mem_L1_toReal_of_lintegral_ne_top hfm hfi lemma integrable_toReal_iff {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_ne_top : ∀ᵐ x ∂μ, f x ≠ ∞) : Integrable (fun x ↦ (f x).toReal) μ ↔ ∫⁻ x, f x ∂μ ≠ ∞ := by rw [Integrable, hasFiniteIntegral_toReal_iff hf_ne_top] simp only [hf.ennreal_toReal.aestronglyMeasurable, ne_eq, true_and] lemma lintegral_ofReal_ne_top_iff_integrable {f : α → ℝ} (hfm : AEStronglyMeasurable f μ) (hf : 0 ≤ᵐ[μ] f) : ∫⁻ a, ENNReal.ofReal (f a) ∂μ ≠ ∞ ↔ Integrable f μ := by rw [Integrable, hasFiniteIntegral_iff_ofReal hf] simp [hfm] end ENNReal section PosPart /-! ### Lemmas used for defining the positive part of an `L¹` function -/ @[fun_prop] theorem Integrable.pos_part {f : α → ℝ} (hf : Integrable f μ) : Integrable (fun a => max (f a) 0) μ := by constructor <;> fun_prop @[fun_prop] theorem Integrable.neg_part {f : α → ℝ} (hf : Integrable f μ) : Integrable (fun a => max (-f a) 0) μ := hf.neg.pos_part end PosPart section IsBoundedSMul variable {𝕜 : Type*} {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] @[fun_prop] theorem Integrable.smul [NormedAddCommGroup 𝕜] [SMulZeroClass 𝕜 β] [IsBoundedSMul 𝕜 β] (c : 𝕜) {f : α → β} (hf : Integrable f μ) : Integrable (c • f) μ := by constructor <;> fun_prop @[fun_prop] theorem Integrable.fun_smul [NormedAddCommGroup 𝕜] [SMulZeroClass 𝕜 β] [IsBoundedSMul 𝕜 β] (c : 𝕜) {f : α → β} (hf : Integrable f μ) : Integrable (fun x ↦ c • f x) μ := hf.smul c @[fun_prop] theorem Integrable.smul_enorm [NormedAddCommGroup 𝕜] [SMul 𝕜 ε] [ContinuousConstSMul 𝕜 ε] [ENormSMulClass 𝕜 ε] (c : 𝕜) {f : α → ε} (hf : Integrable f μ) : Integrable (c • f) μ := by constructor <;> fun_prop theorem Integrable.fun_smul_enorm [NormedAddCommGroup 𝕜] [SMul 𝕜 ε] [ContinuousConstSMul 𝕜 ε] [ENormSMulClass 𝕜 ε] (c : 𝕜) {f : α → ε} (hf : Integrable f μ) : Integrable (fun x ↦ c • f x) μ := hf.smul_enorm c theorem _root_.IsUnit.integrable_smul_iff [NormedRing 𝕜] [MulActionWithZero 𝕜 β] [IsBoundedSMul 𝕜 β] {c : 𝕜} (hc : IsUnit c) (f : α → β) : Integrable (c • f) μ ↔ Integrable f μ := and_congr hc.aestronglyMeasurable_const_smul_iff (hasFiniteIntegral_smul_iff hc f) theorem integrable_smul_iff [NormedDivisionRing 𝕜] [MulActionWithZero 𝕜 β] [IsBoundedSMul 𝕜 β] {c : 𝕜} (hc : c ≠ 0) (f : α → β) : Integrable (c • f) μ ↔ Integrable f μ := (IsUnit.mk0 _ hc).integrable_smul_iff f theorem integrable_fun_smul_iff [NormedDivisionRing 𝕜] [MulActionWithZero 𝕜 β] [IsBoundedSMul 𝕜 β] {c : 𝕜} (hc : c ≠ 0) (f : α → β) : Integrable (fun x ↦ c • f x) μ ↔ Integrable f μ := integrable_smul_iff hc f variable [NormedRing 𝕜] [Module 𝕜 β] [IsBoundedSMul 𝕜 β] theorem Integrable.smul_of_top_right {f : α → β} {φ : α → 𝕜} (hf : Integrable f μ) (hφ : MemLp φ ∞ μ) : Integrable (φ • f) μ := by rw [← memLp_one_iff_integrable] at hf ⊢ exact MemLp.smul hf hφ theorem Integrable.smul_of_top_left {f : α → β} {φ : α → 𝕜} (hφ : Integrable φ μ) (hf : MemLp f ∞ μ) : Integrable (φ • f) μ := by rw [← memLp_one_iff_integrable] at hφ ⊢ exact MemLp.smul hf hφ @[fun_prop] theorem Integrable.smul_const {f : α → 𝕜} (hf : Integrable f μ) (c : β) : Integrable (fun x => f x • c) μ := hf.smul_of_top_left (memLp_top_const c) end IsBoundedSMul section NormedSpaceOverCompleteField variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] theorem integrable_smul_const {f : α → 𝕜} {c : E} (hc : c ≠ 0) : Integrable (fun x => f x • c) μ ↔ Integrable f μ := by simp_rw [Integrable, aestronglyMeasurable_smul_const_iff (f := f) hc, and_congr_right_iff, hasFiniteIntegral_iff_enorm, enorm_smul] intro _; rw [lintegral_mul_const' _ _ enorm_ne_top, ENNReal.mul_lt_top_iff] have : ∀ x : ℝ≥0∞, x = 0 → x < ∞ := by simp simp [hc, or_iff_left_of_imp (this _)] end NormedSpaceOverCompleteField section NormedRing variable {𝕜 : Type*} [NormedRing 𝕜] {f : α → 𝕜} @[fun_prop] theorem Integrable.const_mul {f : α → 𝕜} (h : Integrable f μ) (c : 𝕜) : Integrable (fun x => c * f x) μ := h.smul c theorem Integrable.const_mul' {f : α → 𝕜} (h : Integrable f μ) (c : 𝕜) : Integrable ((fun _ : α => c) * f) μ := Integrable.const_mul h c @[fun_prop] theorem Integrable.mul_const {f : α → 𝕜} (h : Integrable f μ) (c : 𝕜) : Integrable (fun x => f x * c) μ := h.smul (MulOpposite.op c) theorem Integrable.mul_const' {f : α → 𝕜} (h : Integrable f μ) (c : 𝕜) : Integrable (f * fun _ : α => c) μ := Integrable.mul_const h c theorem integrable_const_mul_iff {c : 𝕜} (hc : IsUnit c) (f : α → 𝕜) : Integrable (fun x => c * f x) μ ↔ Integrable f μ := hc.integrable_smul_iff f theorem integrable_mul_const_iff {c : 𝕜} (hc : IsUnit c) (f : α → 𝕜) : Integrable (fun x => f x * c) μ ↔ Integrable f μ := hc.op.integrable_smul_iff f theorem Integrable.bdd_mul' {f g : α → 𝕜} {c : ℝ} (hg : Integrable g μ) (hf : AEStronglyMeasurable f μ) (hf_bound : ∀ᵐ x ∂μ, ‖f x‖ ≤ c) : Integrable (fun x => f x * g x) μ := by refine Integrable.mono' (hg.norm.smul c) (hf.mul hg.1) ?_ filter_upwards [hf_bound] with x hx rw [Pi.smul_apply, smul_eq_mul] exact (norm_mul_le _ _).trans (mul_le_mul_of_nonneg_right hx (norm_nonneg _)) theorem Integrable.mul_of_top_right {f : α → 𝕜} {φ : α → 𝕜} (hf : Integrable f μ) (hφ : MemLp φ ∞ μ) : Integrable (φ * f) μ := hf.smul_of_top_right hφ theorem Integrable.mul_of_top_left {f : α → 𝕜} {φ : α → 𝕜} (hφ : Integrable φ μ) (hf : MemLp f ∞ μ) : Integrable (φ * f) μ := hφ.smul_of_top_left hf lemma MemLp.integrable_mul {p q : ℝ≥0∞} {f g : α → 𝕜} (hf : MemLp f p μ) (hg : MemLp g q μ) [HolderTriple p q 1] : Integrable (f * g) μ := memLp_one_iff_integrable.1 <| hg.mul hf end NormedRing section NormedDivisionRing variable {𝕜 : Type*} [NormedDivisionRing 𝕜] {f : α → 𝕜} @[fun_prop] theorem Integrable.div_const {f : α → 𝕜} (h : Integrable f μ) (c : 𝕜) : Integrable (fun x => f x / c) μ := by simp_rw [div_eq_mul_inv, h.mul_const] end NormedDivisionRing section RCLike variable {𝕜 : Type*} [RCLike 𝕜] {f : α → 𝕜} @[fun_prop] theorem Integrable.ofReal {f : α → ℝ} (hf : Integrable f μ) : Integrable (fun x => (f x : 𝕜)) μ := by rw [← memLp_one_iff_integrable] at hf ⊢ exact hf.ofReal theorem Integrable.re_im_iff : Integrable (fun x => RCLike.re (f x)) μ ∧ Integrable (fun x => RCLike.im (f x)) μ ↔ Integrable f μ := by simp_rw [← memLp_one_iff_integrable] exact memLp_re_im_iff @[fun_prop] theorem Integrable.re (hf : Integrable f μ) : Integrable (fun x => RCLike.re (f x)) μ := by rw [← memLp_one_iff_integrable] at hf ⊢ exact hf.re @[fun_prop] theorem Integrable.im (hf : Integrable f μ) : Integrable (fun x => RCLike.im (f x)) μ := by rw [← memLp_one_iff_integrable] at hf ⊢ exact hf.im end RCLike section Trim variable {H : Type*} [NormedAddCommGroup H] {m0 : MeasurableSpace α} {μ' : Measure α} {f : α → H} theorem Integrable.trim (hm : m ≤ m0) (hf_int : Integrable f μ') (hf : StronglyMeasurable[m] f) : Integrable f (μ'.trim hm) := by refine ⟨hf.aestronglyMeasurable, ?_⟩ rw [HasFiniteIntegral, lintegral_trim hm _] · exact hf_int.2 · fun_prop theorem integrable_of_integrable_trim (hm : m ≤ m0) (hf_int : Integrable f (μ'.trim hm)) : Integrable f μ' := by obtain ⟨hf_meas_ae, hf⟩ := hf_int refine ⟨aestronglyMeasurable_of_aestronglyMeasurable_trim hm hf_meas_ae, ?_⟩ simpa [HasFiniteIntegral, lintegral_trim_ae hm hf_meas_ae.enorm] using hf end Trim section SigmaFinite variable {E : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] theorem integrable_of_forall_fin_meas_le' {μ : Measure α} (hm : m ≤ m0) [SigmaFinite (μ.trim hm)] (C : ℝ≥0∞) (hC : C < ∞) {f : α → ε} (hf_meas : AEStronglyMeasurable f μ) (hf : ∀ s, MeasurableSet[m] s → μ s ≠ ∞ → ∫⁻ x in s, ‖f x‖ₑ ∂μ ≤ C) : Integrable f μ := ⟨hf_meas, (lintegral_le_of_forall_fin_meas_trim_le hm C hf).trans_lt hC⟩ theorem integrable_of_forall_fin_meas_le [SigmaFinite μ] (C : ℝ≥0∞) (hC : C < ∞) {f : α → ε} (hf_meas : AEStronglyMeasurable[m] f μ) (hf : ∀ s : Set α, MeasurableSet[m] s → μ s ≠ ∞ → ∫⁻ x in s, ‖f x‖ₑ ∂μ ≤ C) : Integrable f μ := have : SigmaFinite (μ.trim le_rfl) := by rwa [@trim_eq_self _ m] integrable_of_forall_fin_meas_le' le_rfl C hC hf_meas hf end SigmaFinite section restrict variable {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] {f : α → ε} /-- One should usually use `MeasureTheory.Integrable.integrableOn` instead. -/ lemma Integrable.restrict (hf : Integrable f μ) {s : Set α} : Integrable f (μ.restrict s) := hf.mono_measure Measure.restrict_le_self end restrict end MeasureTheory section ContinuousLinearMap open MeasureTheory variable {E H : Type*} [NormedAddCommGroup E] [NormedAddCommGroup H] {𝕜 𝕜' : Type*} [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜'] [NormedSpace 𝕜' E] [NormedSpace 𝕜 H] variable {σ : 𝕜 →+* 𝕜'} {σ' : 𝕜' →+* 𝕜} [RingHomIsometric σ] [RingHomIsometric σ'] [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] @[fun_prop] theorem ContinuousLinearMap.integrable_comp {φ : α → H} (L : H →SL[σ] E) (φ_int : Integrable φ μ) : Integrable (fun a : α => L (φ a)) μ := ((Integrable.norm φ_int).const_mul ‖L‖).mono' (by fun_prop) (Eventually.of_forall fun a => L.le_opNorm (φ a)) @[simp] theorem ContinuousLinearEquiv.integrable_comp_iff {φ : α → H} (L : H ≃SL[σ] E) : Integrable (fun a : α ↦ L (φ a)) μ ↔ Integrable φ μ := ⟨fun h ↦ by simpa using ContinuousLinearMap.integrable_comp (L.symm : E →SL[σ'] H) h, fun h ↦ ContinuousLinearMap.integrable_comp (L : H →SL[σ] E) h⟩ @[simp] theorem LinearIsometryEquiv.integrable_comp_iff {φ : α → H} (L : H ≃ₛₗᵢ[σ] E) : Integrable (fun a : α ↦ L (φ a)) μ ↔ Integrable φ μ := ContinuousLinearEquiv.integrable_comp_iff (L : H ≃SL[σ] E) theorem MeasureTheory.Integrable.apply_continuousLinearMap {φ : α → H →SL[σ] E} (φ_int : Integrable φ μ) (v : H) : Integrable (fun a => φ a v) μ := (ContinuousLinearMap.apply' E σ v).integrable_comp φ_int end ContinuousLinearMap namespace MeasureTheory variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] @[fun_prop] lemma Integrable.fst {f : α → E × F} (hf : Integrable f μ) : Integrable (fun x ↦ (f x).1) μ := (ContinuousLinearMap.fst ℝ E F).integrable_comp hf @[fun_prop] lemma Integrable.snd {f : α → E × F} (hf : Integrable f μ) : Integrable (fun x ↦ (f x).2) μ := (ContinuousLinearMap.snd ℝ E F).integrable_comp hf lemma integrable_prod {f : α → E × F} : Integrable f μ ↔ Integrable (fun x ↦ (f x).1) μ ∧ Integrable (fun x ↦ (f x).2) μ := ⟨fun h ↦ ⟨h.fst, h.snd⟩, fun h ↦ h.1.prodMk h.2⟩ section Limit /-- If `G n` tends to `f` a.e. and each `‖G n ·‖ₑ` is `AEMeasurable`, then the lower Lebesgue integral of `‖f ·‖ₑ` is at most the liminf of the lower Lebesgue integral of `‖G n ·‖ₑ`. -/ theorem lintegral_enorm_le_liminf_of_tendsto {G : ℕ → ℝ → ℝ} {f : ℝ → ℝ} {μ : Measure ℝ} (hGf : ∀ᵐ x ∂μ, Tendsto (fun (n : ℕ) ↦ G n x) atTop (𝓝 (f x))) (hG : ∀ (n : ℕ), AEMeasurable (fun x ↦ ‖G n x‖ₑ) μ) : ∫⁻ x, ‖f x‖ₑ ∂μ ≤ liminf (fun n ↦ ∫⁻ x, ‖G n x‖ₑ ∂μ) atTop := lintegral_congr_ae (by filter_upwards [hGf] with x hx using hx.enorm.liminf_eq) ▸ (MeasureTheory.lintegral_liminf_le' hG) /-- If `G n` tends to `f` a.e., each `G n` is `AEStronglyMeasurable` and the liminf of the lower Lebesgue integral of `‖G n ·‖ₑ` is finite, then `f` is Lebesgue integrable. -/ theorem integrable_of_tendsto {G : ℕ → ℝ → ℝ} {f : ℝ → ℝ} {μ : Measure ℝ} (hGf : ∀ᵐ x ∂μ, Tendsto (fun (n : ℕ) ↦ G n x) atTop (𝓝 (f x))) (hG : ∀ (n : ℕ), AEStronglyMeasurable (G n) μ) (hG' : liminf (fun n ↦ ∫⁻ x, ‖G n x‖ₑ ∂μ) atTop ≠ ⊤) : Integrable f μ := ⟨aestronglyMeasurable_of_tendsto_ae _ hG hGf, lt_of_le_of_lt (lintegral_enorm_le_liminf_of_tendsto hGf (fun n ↦ (hG n).aemeasurable.enorm)) hG'.lt_top⟩ end Limit end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SpecialFunctions/RCLike.lean
import Mathlib.Analysis.RCLike.Lemmas import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex /-! # Measurability of the basic `RCLike` functions -/ noncomputable section open NNReal ENNReal namespace RCLike variable {𝕜 : Type*} [RCLike 𝕜] @[measurability] theorem measurable_re : Measurable (re : 𝕜 → ℝ) := continuous_re.measurable @[measurability] theorem measurable_im : Measurable (im : 𝕜 → ℝ) := continuous_im.measurable end RCLike section RCLikeComposition variable {α 𝕜 : Type*} [RCLike 𝕜] {m : MeasurableSpace α} {f : α → 𝕜} {μ : MeasureTheory.Measure α} @[measurability, fun_prop] theorem Measurable.re (hf : Measurable f) : Measurable fun x => RCLike.re (f x) := RCLike.measurable_re.comp hf @[measurability, fun_prop] theorem AEMeasurable.re (hf : AEMeasurable f μ) : AEMeasurable (fun x => RCLike.re (f x)) μ := RCLike.measurable_re.comp_aemeasurable hf @[measurability, fun_prop] theorem Measurable.im (hf : Measurable f) : Measurable fun x => RCLike.im (f x) := RCLike.measurable_im.comp hf @[measurability, fun_prop] theorem AEMeasurable.im (hf : AEMeasurable f μ) : AEMeasurable (fun x => RCLike.im (f x)) μ := RCLike.measurable_im.comp_aemeasurable hf end RCLikeComposition section variable {α 𝕜 : Type*} [RCLike 𝕜] [MeasurableSpace α] {f : α → 𝕜} {μ : MeasureTheory.Measure α} @[measurability] theorem RCLike.measurable_ofReal : Measurable ((↑) : ℝ → 𝕜) := RCLike.continuous_ofReal.measurable theorem measurable_of_re_im (hre : Measurable fun x => RCLike.re (f x)) (him : Measurable fun x => RCLike.im (f x)) : Measurable f := by convert Measurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp hre) ((RCLike.measurable_ofReal.comp him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm theorem aemeasurable_of_re_im (hre : AEMeasurable (fun x => RCLike.re (f x)) μ) (him : AEMeasurable (fun x => RCLike.im (f x)) μ) : AEMeasurable f μ := by convert AEMeasurable.add (M := 𝕜) (RCLike.measurable_ofReal.comp_aemeasurable hre) ((RCLike.measurable_ofReal.comp_aemeasurable him).mul_const RCLike.I) exact (RCLike.re_add_im _).symm end
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SpecialFunctions/Arctan.lean
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan import Mathlib.MeasureTheory.Constructions.BorelSpace.Basic /-! # Measurability of arctan -/ namespace Real @[measurability] theorem measurable_arctan : Measurable arctan := continuous_arctan.measurable end Real section RealComposition open Real variable {α : Type*} {m : MeasurableSpace α} {f : α → ℝ} @[measurability, fun_prop] theorem Measurable.arctan (hf : Measurable f) : Measurable fun x => arctan (f x) := measurable_arctan.comp hf end RealComposition
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SpecialFunctions/Inner.lean
import Mathlib.Analysis.InnerProductSpace.Continuous import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex /-! # Measurability of scalar products -/ variable {α : Type*} {𝕜 : Type*} {E : Type*} variable [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E] local notation "⟪" x ", " y "⟫" => inner 𝕜 x y @[fun_prop] theorem Measurable.inner {_ : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {f g : α → E} (hf : Measurable f) (hg : Measurable g) : Measurable fun t => ⟪f t, g t⟫ := Continuous.measurable2 continuous_inner hf hg @[measurability, fun_prop] theorem Measurable.const_inner {_ : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {c : E} {f : α → E} (hf : Measurable f) : Measurable fun t => ⟪c, f t⟫ := Measurable.inner measurable_const hf @[measurability, fun_prop] theorem Measurable.inner_const {_ : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {c : E} {f : α → E} (hf : Measurable f) : Measurable fun t => ⟪f t, c⟫ := Measurable.inner hf measurable_const @[fun_prop] theorem AEMeasurable.inner {m : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {μ : MeasureTheory.Measure α} {f g : α → E} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : AEMeasurable (fun x => ⟪f x, g x⟫) μ := by fun_prop @[measurability, fun_prop] theorem AEMeasurable.const_inner {m : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {μ : MeasureTheory.Measure α} {f : α → E} {c : E} (hf : AEMeasurable f μ) : AEMeasurable (fun x => ⟪c, f x⟫) μ := AEMeasurable.inner aemeasurable_const hf @[measurability, fun_prop] theorem AEMeasurable.inner_const {m : MeasurableSpace α} [MeasurableSpace E] [OpensMeasurableSpace E] [SecondCountableTopology E] {μ : MeasureTheory.Measure α} {f : α → E} {c : E} (hf : AEMeasurable f μ) : AEMeasurable (fun x => ⟪f x, c⟫) μ := AEMeasurable.inner hf aemeasurable_const
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SpecialFunctions/Basic.lean
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric import Mathlib.MeasureTheory.Constructions.BorelSpace.Real /-! # Measurability of real and complex functions We show that most standard real and complex functions are measurable, notably `exp`, `cos`, `sin`, `cosh`, `sinh`, `log`, `pow`, `arcsin`, `arccos`. See also `MeasureTheory.Function.SpecialFunctions.Arctan` and `MeasureTheory.Function.SpecialFunctions.Inner`, which have been split off to minimize imports. -/ -- Guard against import creep: assert_not_exists InnerProductSpace Real.arctan FiniteDimensional.proper noncomputable section open NNReal ENNReal MeasureTheory namespace Real variable {α : Type*} {_ : MeasurableSpace α} {f : α → ℝ} {μ : MeasureTheory.Measure α} @[measurability] theorem measurable_exp : Measurable exp := continuous_exp.measurable @[measurability] theorem measurable_log : Measurable log := measurable_of_measurable_on_compl_singleton 0 <| Continuous.measurable <| continuousOn_iff_continuous_restrict.1 continuousOn_log lemma measurable_of_measurable_exp (hf : Measurable (fun x ↦ exp (f x))) : Measurable f := by have : f = fun x ↦ log (exp (f x)) := by ext; rw [log_exp] rw [this] exact measurable_log.comp hf lemma aemeasurable_of_aemeasurable_exp (hf : AEMeasurable (fun x ↦ exp (f x)) μ) : AEMeasurable f μ := by have : f = fun x ↦ log (exp (f x)) := by ext; rw [log_exp] rw [this] exact measurable_log.comp_aemeasurable hf lemma aemeasurable_of_aemeasurable_exp_mul {t : ℝ} (ht : t ≠ 0) (hf : AEMeasurable (fun x ↦ exp (t * f x)) μ) : AEMeasurable f μ := by simpa only [mul_div_cancel_left₀ _ ht] using (aemeasurable_of_aemeasurable_exp hf).div (aemeasurable_const (b := t)) @[measurability] theorem measurable_sin : Measurable sin := continuous_sin.measurable @[measurability] theorem measurable_cos : Measurable cos := continuous_cos.measurable @[measurability] theorem measurable_sinh : Measurable sinh := continuous_sinh.measurable @[measurability] theorem measurable_cosh : Measurable cosh := continuous_cosh.measurable @[measurability] theorem measurable_arcsin : Measurable arcsin := continuous_arcsin.measurable @[measurability] theorem measurable_arccos : Measurable arccos := continuous_arccos.measurable end Real namespace Complex @[measurability] theorem measurable_re : Measurable re := continuous_re.measurable @[measurability] theorem measurable_im : Measurable im := continuous_im.measurable @[measurability] theorem measurable_ofReal : Measurable ((↑) : ℝ → ℂ) := continuous_ofReal.measurable @[measurability] theorem measurable_exp : Measurable exp := continuous_exp.measurable @[measurability] theorem measurable_sin : Measurable sin := continuous_sin.measurable @[measurability] theorem measurable_cos : Measurable cos := continuous_cos.measurable @[measurability] theorem measurable_sinh : Measurable sinh := continuous_sinh.measurable @[measurability] theorem measurable_cosh : Measurable cosh := continuous_cosh.measurable @[measurability] theorem measurable_arg : Measurable arg := have A : Measurable fun x : ℂ => Real.arcsin (x.im / ‖x‖) := Real.measurable_arcsin.comp (measurable_im.div measurable_norm) have B : Measurable fun x : ℂ => Real.arcsin ((-x).im / ‖x‖) := Real.measurable_arcsin.comp ((measurable_im.comp measurable_neg).div measurable_norm) Measurable.ite (isClosed_le continuous_const continuous_re).measurableSet A <| Measurable.ite (isClosed_le continuous_const continuous_im).measurableSet (B.add_const _) (B.sub_const _) @[measurability] theorem measurable_log : Measurable log := (measurable_ofReal.comp <| Real.measurable_log.comp measurable_norm).add <| (measurable_ofReal.comp measurable_arg).mul_const I end Complex section RealComposition open Real variable {α : Type*} {m : MeasurableSpace α} {f : α → ℝ} (hf : Measurable f) include hf @[measurability, fun_prop] protected theorem Measurable.exp : Measurable fun x => Real.exp (f x) := Real.measurable_exp.comp hf @[measurability, fun_prop] protected theorem Measurable.log : Measurable fun x => log (f x) := measurable_log.comp hf @[measurability, fun_prop] protected theorem Measurable.cos : Measurable fun x ↦ cos (f x) := measurable_cos.comp hf @[measurability, fun_prop] protected theorem Measurable.sin : Measurable fun x ↦ sin (f x) := measurable_sin.comp hf @[measurability, fun_prop] protected theorem Measurable.cosh : Measurable fun x ↦ cosh (f x) := measurable_cosh.comp hf @[measurability, fun_prop] protected theorem Measurable.sinh : Measurable fun x ↦ sinh (f x) := measurable_sinh.comp hf @[measurability, fun_prop] protected theorem Measurable.sqrt : Measurable fun x => √(f x) := continuous_sqrt.measurable.comp hf end RealComposition section RealComposition open Real variable {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ℝ} (hf : AEMeasurable f μ) include hf @[measurability, fun_prop] protected lemma AEMeasurable.exp : AEMeasurable (fun x ↦ exp (f x)) μ := measurable_exp.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.log : AEMeasurable (fun x ↦ log (f x)) μ := measurable_log.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.cos : AEMeasurable (fun x ↦ cos (f x)) μ := measurable_cos.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.sin : AEMeasurable (fun x ↦ sin (f x)) μ := measurable_sin.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.cosh : AEMeasurable (fun x ↦ cosh (f x)) μ := measurable_cosh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.sinh : AEMeasurable (fun x ↦ sinh (f x)) μ := measurable_sinh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.sqrt : AEMeasurable (fun x ↦ √(f x)) μ := continuous_sqrt.measurable.comp_aemeasurable hf end RealComposition section ComplexComposition open Complex variable {α : Type*} {m : MeasurableSpace α} {f : α → ℂ} (hf : Measurable f) include hf @[measurability, fun_prop] protected theorem Measurable.cexp : Measurable fun x => Complex.exp (f x) := Complex.measurable_exp.comp hf @[measurability, fun_prop] protected theorem Measurable.ccos : Measurable fun x => Complex.cos (f x) := Complex.measurable_cos.comp hf @[measurability, fun_prop] protected theorem Measurable.csin : Measurable fun x => Complex.sin (f x) := Complex.measurable_sin.comp hf @[measurability, fun_prop] protected theorem Measurable.ccosh : Measurable fun x => Complex.cosh (f x) := Complex.measurable_cosh.comp hf @[measurability, fun_prop] protected theorem Measurable.csinh : Measurable fun x => Complex.sinh (f x) := Complex.measurable_sinh.comp hf @[measurability, fun_prop] protected theorem Measurable.carg : Measurable fun x => arg (f x) := measurable_arg.comp hf @[measurability, fun_prop] protected theorem Measurable.clog : Measurable fun x => Complex.log (f x) := measurable_log.comp hf end ComplexComposition section ComplexComposition open Complex variable {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ℂ} (hf : AEMeasurable f μ) include hf @[measurability, fun_prop] protected lemma AEMeasurable.cexp : AEMeasurable (fun x ↦ exp (f x)) μ := measurable_exp.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.ccos : AEMeasurable (fun x ↦ cos (f x)) μ := measurable_cos.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.csin : AEMeasurable (fun x ↦ sin (f x)) μ := measurable_sin.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.ccosh : AEMeasurable (fun x ↦ cosh (f x)) μ := measurable_cosh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.csinh : AEMeasurable (fun x ↦ sinh (f x)) μ := measurable_sinh.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.carg : AEMeasurable (fun x ↦ arg (f x)) μ := measurable_arg.comp_aemeasurable hf @[measurability, fun_prop] protected lemma AEMeasurable.clog : AEMeasurable (fun x ↦ log (f x)) μ := measurable_log.comp_aemeasurable hf end ComplexComposition @[measurability, fun_prop] protected theorem Measurable.complex_ofReal {α : Type*} {m : MeasurableSpace α} {f : α → ℝ} (hf : Measurable f) : Measurable fun x ↦ (f x : ℂ) := Complex.measurable_ofReal.comp hf @[measurability, fun_prop] protected theorem AEMeasurable.complex_ofReal {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ℝ} (hf : AEMeasurable f μ) : AEMeasurable (fun x ↦ (f x : ℂ)) μ := Complex.measurable_ofReal.comp_aemeasurable hf section PowInstances instance Complex.hasMeasurablePow : MeasurablePow ℂ ℂ := ⟨Measurable.ite (measurable_fst (measurableSet_singleton 0)) (Measurable.ite (measurable_snd (measurableSet_singleton 0)) measurable_one measurable_zero) (measurable_fst.clog.mul measurable_snd).cexp⟩ instance Real.hasMeasurablePow : MeasurablePow ℝ ℝ := ⟨Complex.measurable_re.comp <| (Complex.measurable_ofReal.comp measurable_fst).pow (Complex.measurable_ofReal.comp measurable_snd)⟩ instance NNReal.hasMeasurablePow : MeasurablePow ℝ≥0 ℝ := ⟨(measurable_fst.coe_nnreal_real.pow measurable_snd).subtype_mk⟩ instance ENNReal.hasMeasurablePow : MeasurablePow ℝ≥0∞ ℝ := by refine ⟨ENNReal.measurable_of_measurable_nnreal_prod ?_ ?_⟩ · simp_rw [ENNReal.coe_rpow_def] refine Measurable.ite ?_ measurable_const (measurable_fst.pow measurable_snd).coe_nnreal_ennreal exact MeasurableSet.inter (measurable_fst (measurableSet_singleton 0)) (measurable_snd measurableSet_Iio) · simp_rw [ENNReal.top_rpow_def] refine Measurable.ite measurableSet_Ioi measurable_const ?_ exact Measurable.ite (measurableSet_singleton 0) measurable_const measurable_const end PowInstances
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/SpecialFunctions/Sinc.lean
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Sinc import Mathlib.MeasureTheory.Function.SpecialFunctions.Basic import Mathlib.MeasureTheory.Function.L1Space.Integrable /-! # Measurability and integrability of the sinc function ## Main statements * `measurable_sinc`: the sinc function is measurable. * `integrable_sinc`: the sinc function is integrable with respect to any finite measure on `ℝ`. -/ open MeasureTheory variable {α : Type*} {_ : MeasurableSpace α} {f : α → ℝ} {μ : Measure α} namespace Real @[fun_prop, measurability] lemma measurable_sinc : Measurable sinc := continuous_sinc.measurable @[fun_prop, measurability] lemma stronglyMeasurable_sinc : StronglyMeasurable sinc := measurable_sinc.stronglyMeasurable @[fun_prop] lemma integrable_sinc {μ : Measure ℝ} [IsFiniteMeasure μ] : Integrable sinc μ := by refine Integrable.mono' (g := fun _ ↦ 1) (by fun_prop) (by fun_prop) <| ae_of_all _ fun x ↦ ?_ rw [Real.norm_eq_abs] exact abs_sinc_le_one x end Real open Real @[fun_prop, measurability] protected theorem Measurable.sinc (hf : Measurable f) : Measurable fun x ↦ sinc (f x) := Real.measurable_sinc.comp hf @[fun_prop, measurability] protected theorem AEMeasurable.sinc (hf : AEMeasurable f μ) : AEMeasurable (fun x ↦ sinc (f x)) μ := Real.measurable_sinc.comp_aemeasurable hf @[fun_prop, measurability] protected theorem MeasureTheory.StronglyMeasurable.sinc (hf : StronglyMeasurable f) : StronglyMeasurable fun x ↦ sinc (f x) := Real.stronglyMeasurable_sinc.comp_measurable hf.measurable @[fun_prop, measurability] protected theorem MeasureTheory.AEStronglyMeasurable.sinc (hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun x ↦ sinc (f x)) μ := by rw [aestronglyMeasurable_iff_aemeasurable] at hf ⊢ exact hf.sinc
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSpace/Complete.lean
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity import Mathlib.MeasureTheory.Function.LpSpace.Basic /-! # `Lp` is a complete space In this file we show that `Lp` is a complete space for `1 ≤ p`, in `MeasureTheory.Lp.instCompleteSpace`. -/ open MeasureTheory Filter open scoped ENNReal Topology variable {α E : Type*} {m : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α} [NormedAddCommGroup E] namespace MeasureTheory.Lp theorem eLpNorm'_lim_eq_lintegral_liminf {ι} [Nonempty ι] [LinearOrder ι] {f : ι → α → E} {p : ℝ} {f_lim : α → E} (h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) : eLpNorm' f_lim p μ = (∫⁻ a, atTop.liminf (‖f · a‖ₑ ^ p) ∂μ) ^ (1 / p) := by suffices h_no_pow : (∫⁻ a, ‖f_lim a‖ₑ ^ p ∂μ) = ∫⁻ a, atTop.liminf fun m => ‖f m a‖ₑ ^ p ∂μ by rw [eLpNorm'_eq_lintegral_enorm, h_no_pow] refine lintegral_congr_ae (h_lim.mono fun a ha => ?_) dsimp only rw [Tendsto.liminf_eq] refine (ENNReal.continuous_rpow_const.tendsto ‖f_lim a‖₊).comp ?_ exact (continuous_enorm.tendsto (f_lim a)).comp ha theorem eLpNorm'_lim_le_liminf_eLpNorm' {f : ℕ → α → E} {p : ℝ} (hp_pos : 0 < p) (hf : ∀ n, AEStronglyMeasurable (f n) μ) {f_lim : α → E} (h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) : eLpNorm' f_lim p μ ≤ atTop.liminf fun n => eLpNorm' (f n) p μ := by rw [eLpNorm'_lim_eq_lintegral_liminf h_lim] rw [one_div, ← ENNReal.le_rpow_inv_iff (by simp [hp_pos] : 0 < p⁻¹), inv_inv] refine (lintegral_liminf_le' fun m => (hf m).enorm.pow_const _).trans_eq ?_ have h_pow_liminf : atTop.liminf (fun n ↦ eLpNorm' (f n) p μ) ^ p = atTop.liminf fun n ↦ eLpNorm' (f n) p μ ^ p := by have h_rpow_mono := ENNReal.strictMono_rpow_of_pos hp_pos have h_rpow_surj := (ENNReal.rpow_left_bijective hp_pos.ne.symm).2 refine (h_rpow_mono.orderIsoOfSurjective _ h_rpow_surj).liminf_apply ?_ ?_ ?_ ?_ all_goals isBoundedDefault rw [h_pow_liminf] simp_rw [eLpNorm'_eq_lintegral_enorm, ← ENNReal.rpow_mul, one_div, inv_mul_cancel₀ hp_pos.ne.symm, ENNReal.rpow_one] theorem eLpNorm_exponent_top_lim_eq_essSup_liminf {ι} [Nonempty ι] [LinearOrder ι] {f : ι → α → E} {f_lim : α → E} (h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) : eLpNorm f_lim ∞ μ = essSup (fun x => atTop.liminf fun m => ‖f m x‖ₑ) μ := by rw [eLpNorm_exponent_top, eLpNormEssSup_eq_essSup_enorm] refine essSup_congr_ae (h_lim.mono fun x hx => ?_) dsimp only apply (Tendsto.liminf_eq ..).symm exact (continuous_enorm.tendsto (f_lim x)).comp hx theorem eLpNorm_exponent_top_lim_le_liminf_eLpNorm_exponent_top {ι} [Nonempty ι] [Countable ι] [LinearOrder ι] {f : ι → α → E} {f_lim : α → E} (h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) : eLpNorm f_lim ∞ μ ≤ atTop.liminf fun n => eLpNorm (f n) ∞ μ := by rw [eLpNorm_exponent_top_lim_eq_essSup_liminf h_lim] simp_rw [eLpNorm_exponent_top, eLpNormEssSup] exact ENNReal.essSup_liminf_le _ theorem eLpNorm_lim_le_liminf_eLpNorm {f : ℕ → α → E} (hf : ∀ n, AEStronglyMeasurable (f n) μ) (f_lim : α → E) (h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) : eLpNorm f_lim p μ ≤ atTop.liminf fun n => eLpNorm (f n) p μ := by obtain rfl | hp0 := eq_or_ne p 0 · simp by_cases hp_top : p = ∞ · simp_rw [hp_top] exact eLpNorm_exponent_top_lim_le_liminf_eLpNorm_exponent_top h_lim simp_rw [eLpNorm_eq_eLpNorm' hp0 hp_top] have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0 hp_top exact eLpNorm'_lim_le_liminf_eLpNorm' hp_pos hf h_lim /-! ### `Lp` is complete iff Cauchy sequences of `ℒp` have limits in `ℒp` -/ theorem tendsto_Lp_iff_tendsto_eLpNorm' {ι} {fi : Filter ι} [Fact (1 ≤ p)] (f : ι → Lp E p μ) (f_lim : Lp E p μ) : fi.Tendsto f (𝓝 f_lim) ↔ fi.Tendsto (fun n => eLpNorm (⇑(f n) - ⇑f_lim) p μ) (𝓝 0) := by rw [tendsto_iff_dist_tendsto_zero] simp_rw [dist_def] rw [← ENNReal.toReal_zero, ENNReal.tendsto_toReal_iff (fun n => ?_) ENNReal.zero_ne_top] rw [eLpNorm_congr_ae (Lp.coeFn_sub _ _).symm] exact Lp.eLpNorm_ne_top _ theorem tendsto_Lp_iff_tendsto_eLpNorm {ι} {fi : Filter ι} [Fact (1 ≤ p)] (f : ι → Lp E p μ) (f_lim : α → E) (f_lim_ℒp : MemLp f_lim p μ) : fi.Tendsto f (𝓝 (f_lim_ℒp.toLp f_lim)) ↔ fi.Tendsto (fun n => eLpNorm (⇑(f n) - f_lim) p μ) (𝓝 0) := by rw [tendsto_Lp_iff_tendsto_eLpNorm'] suffices h_eq : (fun n => eLpNorm (⇑(f n) - ⇑(MemLp.toLp f_lim f_lim_ℒp)) p μ) = (fun n => eLpNorm (⇑(f n) - f_lim) p μ) by rw [h_eq] exact funext fun n => eLpNorm_congr_ae (EventuallyEq.rfl.sub (MemLp.coeFn_toLp f_lim_ℒp)) theorem tendsto_Lp_iff_tendsto_eLpNorm'' {ι} {fi : Filter ι} [Fact (1 ≤ p)] (f : ι → α → E) (f_ℒp : ∀ n, MemLp (f n) p μ) (f_lim : α → E) (f_lim_ℒp : MemLp f_lim p μ) : fi.Tendsto (fun n => (f_ℒp n).toLp (f n)) (𝓝 (f_lim_ℒp.toLp f_lim)) ↔ fi.Tendsto (fun n => eLpNorm (f n - f_lim) p μ) (𝓝 0) := by rw [Lp.tendsto_Lp_iff_tendsto_eLpNorm' (fun n => (f_ℒp n).toLp (f n)) (f_lim_ℒp.toLp f_lim)] refine Filter.tendsto_congr fun n => ?_ apply eLpNorm_congr_ae filter_upwards [((f_ℒp n).sub f_lim_ℒp).coeFn_toLp, Lp.coeFn_sub ((f_ℒp n).toLp (f n)) (f_lim_ℒp.toLp f_lim)] with _ hx₁ hx₂ rw [← hx₂] exact hx₁ theorem tendsto_Lp_of_tendsto_eLpNorm {ι} {fi : Filter ι} [Fact (1 ≤ p)] {f : ι → Lp E p μ} (f_lim : α → E) (f_lim_ℒp : MemLp f_lim p μ) (h_tendsto : fi.Tendsto (fun n => eLpNorm (⇑(f n) - f_lim) p μ) (𝓝 0)) : fi.Tendsto f (𝓝 (f_lim_ℒp.toLp f_lim)) := (tendsto_Lp_iff_tendsto_eLpNorm f f_lim f_lim_ℒp).mpr h_tendsto theorem cauchySeq_Lp_iff_cauchySeq_eLpNorm {ι} [Nonempty ι] [SemilatticeSup ι] [hp : Fact (1 ≤ p)] (f : ι → Lp E p μ) : CauchySeq f ↔ Tendsto (fun n : ι × ι => eLpNorm (⇑(f n.fst) - ⇑(f n.snd)) p μ) atTop (𝓝 0) := by simp_rw [cauchySeq_iff_tendsto_dist_atTop_0, dist_def] rw [← ENNReal.toReal_zero, ENNReal.tendsto_toReal_iff (fun n => ?_) ENNReal.zero_ne_top] rw [eLpNorm_congr_ae (Lp.coeFn_sub _ _).symm] exact eLpNorm_ne_top _ theorem completeSpace_lp_of_cauchy_complete_eLpNorm [hp : Fact (1 ≤ p)] (H : ∀ (f : ℕ → α → E) (_ : ∀ n, MemLp (f n) p μ) (B : ℕ → ℝ≥0∞) (_ : ∑' i, B i < ∞) (_ : ∀ N n m : ℕ, N ≤ n → N ≤ m → eLpNorm (f n - f m) p μ < B N), ∃ (f_lim : α → E), MemLp f_lim p μ ∧ atTop.Tendsto (fun n => eLpNorm (f n - f_lim) p μ) (𝓝 0)) : CompleteSpace (Lp E p μ) := by let B := fun n : ℕ => ((1 : ℝ) / 2) ^ n have hB_pos : ∀ n, 0 < B n := fun n => pow_pos (div_pos zero_lt_one zero_lt_two) n refine Metric.complete_of_convergent_controlled_sequences B hB_pos fun f hf => ?_ rsuffices ⟨f_lim, hf_lim_meas, h_tendsto⟩ : ∃ (f_lim : α → E), MemLp f_lim p μ ∧ atTop.Tendsto (fun n => eLpNorm (⇑(f n) - f_lim) p μ) (𝓝 0) · exact ⟨hf_lim_meas.toLp f_lim, tendsto_Lp_of_tendsto_eLpNorm f_lim hf_lim_meas h_tendsto⟩ obtain ⟨M, hB⟩ : Summable B := summable_geometric_two let B1 n := ENNReal.ofReal (B n) have hB1_has : HasSum B1 (ENNReal.ofReal M) := by have h_tsum_B1 : ∑' i, B1 i = ENNReal.ofReal M := by change (∑' n : ℕ, ENNReal.ofReal (B n)) = ENNReal.ofReal M rw [← hB.tsum_eq] exact (ENNReal.ofReal_tsum_of_nonneg (fun n => le_of_lt (hB_pos n)) hB.summable).symm have h_sum := (@ENNReal.summable _ B1).hasSum rwa [h_tsum_B1] at h_sum have hB1 : ∑' i, B1 i < ∞ := by rw [hB1_has.tsum_eq] exact ENNReal.ofReal_lt_top let f1 : ℕ → α → E := fun n => f n refine H f1 (fun n => Lp.memLp (f n)) B1 hB1 fun N n m hn hm => ?_ specialize hf N n m hn hm rw [dist_def] at hf dsimp only [f1] rwa [ENNReal.lt_ofReal_iff_toReal_lt] rw [eLpNorm_congr_ae (Lp.coeFn_sub _ _).symm] exact Lp.eLpNorm_ne_top _ /-! ### Prove that controlled Cauchy sequences of `ℒp` have limits in `ℒp` -/ private theorem eLpNorm'_sum_norm_sub_le_tsum_of_cauchy_eLpNorm' {f : ℕ → α → E} (hf : ∀ n, AEStronglyMeasurable (f n) μ) {p : ℝ} (hp1 : 1 ≤ p) {B : ℕ → ℝ≥0∞} (h_cau : ∀ N n m : ℕ, N ≤ n → N ≤ m → eLpNorm' (f n - f m) p μ < B N) (n : ℕ) : eLpNorm' (fun x => ∑ i ∈ Finset.range (n + 1), ‖f (i + 1) x - f i x‖) p μ ≤ ∑' i, B i := by let f_norm_diff i x := ‖f (i + 1) x - f i x‖ have hgf_norm_diff : ∀ n, (fun x => ∑ i ∈ Finset.range (n + 1), ‖f (i + 1) x - f i x‖) = ∑ i ∈ Finset.range (n + 1), f_norm_diff i := fun n => funext fun x => by simp [f_norm_diff] rw [hgf_norm_diff] refine (eLpNorm'_sum_le (fun i _ => ((hf (i + 1)).sub (hf i)).norm) hp1).trans ?_ simp_rw [eLpNorm'_norm] refine (Finset.sum_le_sum ?_).trans <| ENNReal.sum_le_tsum _ exact fun m _ => (h_cau m (m + 1) m (Nat.le_succ m) (le_refl m)).le private theorem lintegral_rpow_sum_enorm_sub_le_rpow_tsum {f : ℕ → α → E} {p : ℝ} (hp1 : 1 ≤ p) {B : ℕ → ℝ≥0∞} (n : ℕ) (hn : eLpNorm' (fun x => ∑ i ∈ Finset.range (n + 1), ‖f (i + 1) x - f i x‖) p μ ≤ ∑' i, B i) : (∫⁻ a, (∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ) ≤ (∑' i, B i) ^ p := by have hp_pos : 0 < p := zero_lt_one.trans_le hp1 rw [← inv_inv p, @ENNReal.le_rpow_inv_iff _ _ p⁻¹ (by simp [hp_pos]), inv_inv p] simp_rw [eLpNorm'_eq_lintegral_enorm, one_div] at hn have h_nnnorm_nonneg : (fun a => ‖∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖‖ₑ ^ p) = fun a => (∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖ₑ) ^ p := by ext1 a congr simp_rw [← ofReal_norm_eq_enorm] rw [← ENNReal.ofReal_sum_of_nonneg] · rw [Real.norm_of_nonneg _] exact Finset.sum_nonneg fun x _ => norm_nonneg _ · exact fun x _ => norm_nonneg _ rwa [h_nnnorm_nonneg] at hn private theorem lintegral_rpow_tsum_coe_enorm_sub_le_tsum {f : ℕ → α → E} (hf : ∀ n, AEStronglyMeasurable (f n) μ) {p : ℝ} (hp1 : 1 ≤ p) {B : ℕ → ℝ≥0∞} (h : ∀ n, ∫⁻ a, (∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ ≤ (∑' i, B i) ^ p) : (∫⁻ a, (∑' i, ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ) ^ (1 / p) ≤ ∑' i, B i := by have hp_pos : 0 < p := zero_lt_one.trans_le hp1 suffices h_pow : (∫⁻ a, (∑' i, ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ) ≤ (∑' i, B i) ^ p by rwa [one_div, ← ENNReal.le_rpow_inv_iff (by simp [hp_pos] : 0 < p⁻¹), inv_inv] have h_tsum_1 : ∀ g : ℕ → ℝ≥0∞, ∑' i, g i = atTop.liminf fun n => ∑ i ∈ Finset.range (n + 1), g i := by intro g rw [ENNReal.tsum_eq_liminf_sum_nat, ← liminf_nat_add _ 1] simp_rw [h_tsum_1 _] rw [← h_tsum_1] have h_liminf_pow : ∫⁻ a, (atTop.liminf fun n => ∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ = ∫⁻ a, atTop.liminf fun n => (∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ := by refine lintegral_congr fun x => ?_ have h_rpow_mono := ENNReal.strictMono_rpow_of_pos (zero_lt_one.trans_le hp1) have h_rpow_surj := (ENNReal.rpow_left_bijective hp_pos.ne.symm).2 refine (h_rpow_mono.orderIsoOfSurjective _ h_rpow_surj).liminf_apply ?_ ?_ ?_ ?_ all_goals isBoundedDefault rw [h_liminf_pow] refine (lintegral_liminf_le' fun n ↦ ?_).trans <| liminf_le_of_frequently_le' <| .of_forall h exact ((Finset.range _).aemeasurable_fun_sum fun i _ ↦ ((hf _).sub (hf i)).enorm).pow_const _ private theorem tsum_enorm_sub_ae_lt_top {f : ℕ → α → E} (hf : ∀ n, AEStronglyMeasurable (f n) μ) {p : ℝ} (hp1 : 1 ≤ p) {B : ℕ → ℝ≥0∞} (hB : ∑' i, B i ≠ ∞) (h : (∫⁻ a, (∑' i, ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ) ^ (1 / p) ≤ ∑' i, B i) : ∀ᵐ x ∂μ, ∑' i, ‖f (i + 1) x - f i x‖ₑ < ∞ := by have hp_pos : 0 < p := zero_lt_one.trans_le hp1 have h_integral : ∫⁻ a, (∑' i, ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ < ∞ := by have h_tsum_lt_top : (∑' i, B i) ^ p < ∞ := ENNReal.rpow_lt_top_of_nonneg hp_pos.le hB refine lt_of_le_of_lt ?_ h_tsum_lt_top rwa [one_div, ← ENNReal.le_rpow_inv_iff (by simp [hp_pos] : 0 < p⁻¹), inv_inv] at h have rpow_ae_lt_top : ∀ᵐ x ∂μ, (∑' i, ‖f (i + 1) x - f i x‖ₑ) ^ p < ∞ := by refine ae_lt_top' (AEMeasurable.pow_const ?_ _) h_integral.ne exact AEMeasurable.ennreal_tsum fun n => ((hf (n + 1)).sub (hf n)).enorm refine rpow_ae_lt_top.mono fun x hx => ?_ rwa [← ENNReal.lt_rpow_inv_iff hp_pos, ENNReal.top_rpow_of_pos (by simp [hp_pos] : 0 < p⁻¹)] at hx theorem ae_tendsto_of_cauchy_eLpNorm' [CompleteSpace E] {f : ℕ → α → E} {p : ℝ} (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hp1 : 1 ≤ p) {B : ℕ → ℝ≥0∞} (hB : ∑' i, B i ≠ ∞) (h_cau : ∀ N n m : ℕ, N ≤ n → N ≤ m → eLpNorm' (f n - f m) p μ < B N) : ∀ᵐ x ∂μ, ∃ l : E, atTop.Tendsto (fun n => f n x) (𝓝 l) := by have h_summable : ∀ᵐ x ∂μ, Summable fun i : ℕ => f (i + 1) x - f i x := by have h1 : ∀ n, eLpNorm' (fun x => ∑ i ∈ Finset.range (n + 1), ‖f (i + 1) x - f i x‖) p μ ≤ ∑' i, B i := eLpNorm'_sum_norm_sub_le_tsum_of_cauchy_eLpNorm' hf hp1 h_cau have h2 n : ∫⁻ a, (∑ i ∈ Finset.range (n + 1), ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ ≤ (∑' i, B i) ^ p := lintegral_rpow_sum_enorm_sub_le_rpow_tsum hp1 n (h1 n) have h3 : (∫⁻ a, (∑' i, ‖f (i + 1) a - f i a‖ₑ) ^ p ∂μ) ^ (1 / p) ≤ ∑' i, B i := lintegral_rpow_tsum_coe_enorm_sub_le_tsum hf hp1 h2 have h4 : ∀ᵐ x ∂μ, ∑' i, ‖f (i + 1) x - f i x‖ₑ < ∞ := tsum_enorm_sub_ae_lt_top hf hp1 hB h3 exact h4.mono fun x hx => .of_nnnorm <| ENNReal.tsum_coe_ne_top_iff_summable.mp hx.ne have h : ∀ᵐ x ∂μ, ∃ l : E, atTop.Tendsto (fun n => ∑ i ∈ Finset.range n, (f (i + 1) x - f i x)) (𝓝 l) := by refine h_summable.mono fun x hx => ?_ let hx_sum := hx.hasSum.tendsto_sum_nat exact ⟨∑' i, (f (i + 1) x - f i x), hx_sum⟩ refine h.mono fun x hx => ?_ obtain ⟨l, hx⟩ := hx have h_rw_sum : (fun n => ∑ i ∈ Finset.range n, (f (i + 1) x - f i x)) = fun n => f n x - f 0 x := by ext1 n change (∑ i ∈ Finset.range n, ((fun m => f m x) (i + 1) - (fun m => f m x) i)) = f n x - f 0 x rw [Finset.sum_range_sub (fun m => f m x)] rw [h_rw_sum] at hx have hf_rw : (fun n => f n x) = fun n => f n x - f 0 x + f 0 x := by ext1 n abel rw [hf_rw] exact ⟨l + f 0 x, Tendsto.add_const _ hx⟩ theorem ae_tendsto_of_cauchy_eLpNorm [CompleteSpace E] {f : ℕ → α → E} (hf : ∀ n, AEStronglyMeasurable (f n) μ) (hp : 1 ≤ p) {B : ℕ → ℝ≥0∞} (hB : ∑' i, B i ≠ ∞) (h_cau : ∀ N n m : ℕ, N ≤ n → N ≤ m → eLpNorm (f n - f m) p μ < B N) : ∀ᵐ x ∂μ, ∃ l : E, atTop.Tendsto (fun n => f n x) (𝓝 l) := by by_cases hp_top : p = ∞ · simp_rw [hp_top] at * have h_cau_ae : ∀ᵐ x ∂μ, ∀ N n m, N ≤ n → N ≤ m → ‖(f n - f m) x‖ₑ < B N := by simp_rw [ae_all_iff] exact fun N n m hnN hmN => ae_lt_of_essSup_lt (h_cau N n m hnN hmN) simp_rw [eLpNorm_exponent_top, eLpNormEssSup] at h_cau refine h_cau_ae.mono fun x hx => cauchySeq_tendsto_of_complete ?_ refine cauchySeq_of_le_tendsto_0 (fun n => (B n).toReal) ?_ ?_ · intro n m N hnN hmN specialize hx N n m hnN hmN rw [_root_.dist_eq_norm, ← ENNReal.ofReal_le_iff_le_toReal (ENNReal.ne_top_of_tsum_ne_top hB N), ofReal_norm_eq_enorm] exact hx.le · rw [← ENNReal.toReal_zero] exact Tendsto.comp (g := ENNReal.toReal) (ENNReal.tendsto_toReal ENNReal.zero_ne_top) (ENNReal.tendsto_atTop_zero_of_tsum_ne_top hB) have hp1 : 1 ≤ p.toReal := by rw [← ENNReal.ofReal_le_iff_le_toReal hp_top, ENNReal.ofReal_one] exact hp have h_cau' : ∀ N n m : ℕ, N ≤ n → N ≤ m → eLpNorm' (f n - f m) p.toReal μ < B N := by intro N n m hn hm specialize h_cau N n m hn hm rwa [eLpNorm_eq_eLpNorm' (zero_lt_one.trans_le hp).ne.symm hp_top] at h_cau exact ae_tendsto_of_cauchy_eLpNorm' hf hp1 hB h_cau' theorem cauchy_tendsto_of_tendsto {f : ℕ → α → E} (hf : ∀ n, AEStronglyMeasurable (f n) μ) (f_lim : α → E) {B : ℕ → ℝ≥0∞} (hB : ∑' i, B i ≠ ∞) (h_cau : ∀ N n m : ℕ, N ≤ n → N ≤ m → eLpNorm (f n - f m) p μ < B N) (h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) : atTop.Tendsto (fun n => eLpNorm (f n - f_lim) p μ) (𝓝 0) := by rw [ENNReal.tendsto_atTop_zero] intro ε hε have h_B : ∃ N : ℕ, B N ≤ ε := by suffices h_tendsto_zero : ∃ N : ℕ, ∀ n : ℕ, N ≤ n → B n ≤ ε from ⟨h_tendsto_zero.choose, h_tendsto_zero.choose_spec _ le_rfl⟩ exact (ENNReal.tendsto_atTop_zero.mp (ENNReal.tendsto_atTop_zero_of_tsum_ne_top hB)) ε hε obtain ⟨N, h_B⟩ := h_B refine ⟨N, fun n hn => ?_⟩ have h_sub : eLpNorm (f n - f_lim) p μ ≤ atTop.liminf fun m => eLpNorm (f n - f m) p μ := by refine eLpNorm_lim_le_liminf_eLpNorm (fun m => (hf n).sub (hf m)) (f n - f_lim) ?_ refine h_lim.mono fun x hx => ?_ simp_rw [sub_eq_add_neg] exact Tendsto.add tendsto_const_nhds (Tendsto.neg hx) refine h_sub.trans ?_ refine liminf_le_of_frequently_le' (frequently_atTop.mpr ?_) refine fun N1 => ⟨max N N1, le_max_right _ _, ?_⟩ exact (h_cau N n (max N N1) hn (le_max_left _ _)).le.trans h_B theorem memLp_of_cauchy_tendsto (hp : 1 ≤ p) {f : ℕ → α → E} (hf : ∀ n, MemLp (f n) p μ) (f_lim : α → E) (h_lim_meas : AEStronglyMeasurable f_lim μ) (h_tendsto : atTop.Tendsto (fun n => eLpNorm (f n - f_lim) p μ) (𝓝 0)) : MemLp f_lim p μ := by refine ⟨h_lim_meas, ?_⟩ rw [ENNReal.tendsto_atTop_zero] at h_tendsto obtain ⟨N, h_tendsto_1⟩ := h_tendsto 1 zero_lt_one specialize h_tendsto_1 N (le_refl N) have h_add : f_lim = f_lim - f N + f N := by abel rw [h_add] refine lt_of_le_of_lt (eLpNorm_add_le (h_lim_meas.sub (hf N).1) (hf N).1 hp) ?_ rw [ENNReal.add_lt_top] constructor · refine lt_of_le_of_lt ?_ ENNReal.one_lt_top have h_neg : f_lim - f N = -(f N - f_lim) := by simp rwa [h_neg, eLpNorm_neg] · exact (hf N).2 theorem cauchy_complete_eLpNorm [CompleteSpace E] (hp : 1 ≤ p) {f : ℕ → α → E} (hf : ∀ n, MemLp (f n) p μ) {B : ℕ → ℝ≥0∞} (hB : ∑' i, B i ≠ ∞) (h_cau : ∀ N n m : ℕ, N ≤ n → N ≤ m → eLpNorm (f n - f m) p μ < B N) : ∃ (f_lim : α → E), MemLp f_lim p μ ∧ atTop.Tendsto (fun n => eLpNorm (f n - f_lim) p μ) (𝓝 0) := by obtain ⟨f_lim, h_f_lim_meas, h_lim⟩ : ∃ f_lim : α → E, StronglyMeasurable f_lim ∧ ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x)) := exists_stronglyMeasurable_limit_of_tendsto_ae (fun n => (hf n).1) (ae_tendsto_of_cauchy_eLpNorm (fun n => (hf n).1) hp hB h_cau) have h_tendsto' : atTop.Tendsto (fun n => eLpNorm (f n - f_lim) p μ) (𝓝 0) := cauchy_tendsto_of_tendsto (fun m => (hf m).1) f_lim hB h_cau h_lim have h_ℒp_lim : MemLp f_lim p μ := memLp_of_cauchy_tendsto hp hf f_lim h_f_lim_meas.aestronglyMeasurable h_tendsto' exact ⟨f_lim, h_ℒp_lim, h_tendsto'⟩ /-- `Lp` is complete for `1 ≤ p`. -/ instance instCompleteSpace [CompleteSpace E] [hp : Fact (1 ≤ p)] : CompleteSpace (Lp E p μ) := completeSpace_lp_of_cauchy_complete_eLpNorm fun _f hf _B hB h_cau => cauchy_complete_eLpNorm hp.elim hf hB.ne h_cau end MeasureTheory.Lp
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSpace/Indicator.lean
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity import Mathlib.MeasureTheory.Function.LpSpace.Basic import Mathlib.MeasureTheory.Measure.Real import Mathlib.Order.Filter.IndicatorFunction /-! # Indicator of a set as an element of `Lp` For a set `s` with `(hs : MeasurableSet s)` and `(hμs : μ s < ∞)`, we build `indicatorConstLp p hs hμs c`, the element of `Lp` corresponding to `s.indicator (fun _ => c)`. ## Main definitions * `MeasureTheory.indicatorConstLp`: Indicator of a set as an element of `Lp`. * `MeasureTheory.Lp.const`: Constant function as an element of `Lp` for a finite measure. -/ noncomputable section open MeasureTheory Filter open scoped NNReal ENNReal Topology symmDiff variable {α E : Type*} {m : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α} [NormedAddCommGroup E] namespace MeasureTheory /-- The `eLpNorm` of the indicator of a set is uniformly small if the set itself has small measure, for any `p < ∞`. Given here as an existential `∀ ε > 0, ∃ η > 0, ...` to avoid later management of `ℝ≥0∞`-arithmetic. -/ theorem exists_eLpNorm_indicator_le (hp : p ≠ ∞) (c : E) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ η : ℝ≥0, 0 < η ∧ ∀ s : Set α, μ s ≤ η → eLpNorm (s.indicator fun _ => c) p μ ≤ ε := by rcases eq_or_ne p 0 with (rfl | h'p) · exact ⟨1, zero_lt_one, fun s _ => by simp⟩ have hp₀ : 0 < p := bot_lt_iff_ne_bot.2 h'p have hp₀' : 0 ≤ 1 / p.toReal := div_nonneg zero_le_one ENNReal.toReal_nonneg have hp₀'' : 0 < p.toReal := ENNReal.toReal_pos hp₀.ne' hp obtain ⟨η, hη_pos, hη_le⟩ : ∃ η : ℝ≥0, 0 < η ∧ ‖c‖ₑ * (η : ℝ≥0∞) ^ (1 / p.toReal) ≤ ε := by have : Filter.Tendsto (fun x : ℝ≥0 => ((‖c‖₊ * x ^ (1 / p.toReal) : ℝ≥0) : ℝ≥0∞)) (𝓝 0) (𝓝 (0 : ℝ≥0)) := by rw [ENNReal.tendsto_coe] convert (NNReal.continuousAt_rpow_const (Or.inr hp₀')).tendsto.const_mul _ simp [hp₀''.ne'] have hε' : 0 < ε := hε.bot_lt obtain ⟨δ, hδ, hδε'⟩ := NNReal.nhds_zero_basis.eventually_iff.mp (this.eventually_le_const hε') obtain ⟨η, hη, hηδ⟩ := exists_between hδ refine ⟨η, hη, ?_⟩ simpa only [← ENNReal.coe_rpow_of_nonneg _ hp₀', enorm, ← ENNReal.coe_mul] using hδε' hηδ refine ⟨η, hη_pos, fun s hs => ?_⟩ grw [eLpNorm_indicator_const_le, ← hη_le, hs] section Topology variable {X : Type*} [TopologicalSpace X] [MeasurableSpace X] {μ : Measure X} [IsFiniteMeasureOnCompacts μ] /-- A bounded measurable function with compact support is in L^p. -/ theorem _root_.HasCompactSupport.memLp_of_bound {f : X → E} (hf : HasCompactSupport f) (h2f : AEStronglyMeasurable f μ) (C : ℝ) (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : MemLp f p μ := by have := memLp_top_of_bound h2f C hfC exact this.mono_exponent_of_measure_support_ne_top (fun x ↦ image_eq_zero_of_notMem_tsupport) (hf.measure_lt_top.ne) le_top /-- A continuous function with compact support is in L^p. -/ theorem _root_.Continuous.memLp_of_hasCompactSupport [OpensMeasurableSpace X] {f : X → E} (hf : Continuous f) (h'f : HasCompactSupport f) : MemLp f p μ := by have := hf.memLp_top_of_hasCompactSupport h'f μ exact this.mono_exponent_of_measure_support_ne_top (fun x ↦ image_eq_zero_of_notMem_tsupport) (h'f.measure_lt_top.ne) le_top end Topology section IndicatorConstLp open Set Function variable {s : Set α} {hs : MeasurableSet s} {hμs : μ s ≠ ∞} {c : E} /-- Indicator of a set as an element of `Lp`. -/ def indicatorConstLp (p : ℝ≥0∞) (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (c : E) : Lp E p μ := MemLp.toLp (s.indicator fun _ => c) (memLp_indicator_const p hs c (Or.inr hμs)) /-- A version of `Set.indicator_add` for `MeasureTheory.indicatorConstLp` -/ theorem indicatorConstLp_add {c' : E} : indicatorConstLp p hs hμs c + indicatorConstLp p hs hμs c' = indicatorConstLp p hs hμs (c + c') := by simp_rw [indicatorConstLp, ← MemLp.toLp_add, indicator_add] rfl /-- A version of `Set.indicator_sub` for `MeasureTheory.indicatorConstLp` -/ theorem indicatorConstLp_sub {c' : E} : indicatorConstLp p hs hμs c - indicatorConstLp p hs hμs c' = indicatorConstLp p hs hμs (c - c') := by simp_rw [indicatorConstLp, ← MemLp.toLp_sub, indicator_sub] rfl theorem indicatorConstLp_coeFn : ⇑(indicatorConstLp p hs hμs c) =ᵐ[μ] s.indicator fun _ => c := MemLp.coeFn_toLp (memLp_indicator_const p hs c (Or.inr hμs)) theorem indicatorConstLp_coeFn_mem : ∀ᵐ x : α ∂μ, x ∈ s → indicatorConstLp p hs hμs c x = c := indicatorConstLp_coeFn.mono fun _x hx hxs => hx.trans (Set.indicator_of_mem hxs _) theorem indicatorConstLp_coeFn_notMem : ∀ᵐ x : α ∂μ, x ∉ s → indicatorConstLp p hs hμs c x = 0 := indicatorConstLp_coeFn.mono fun _x hx hxs => hx.trans (Set.indicator_of_notMem hxs _) @[deprecated (since := "2025-05-24")] alias indicatorConstLp_coeFn_nmem := indicatorConstLp_coeFn_notMem theorem norm_indicatorConstLp (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : ‖indicatorConstLp p hs hμs c‖ = ‖c‖ * μ.real s ^ (1 / p.toReal) := by rw [Lp.norm_def, eLpNorm_congr_ae indicatorConstLp_coeFn, eLpNorm_indicator_const hs hp_ne_zero hp_ne_top, ENNReal.toReal_mul, measureReal_def, ENNReal.toReal_rpow, toReal_enorm] theorem norm_indicatorConstLp_top (hμs_ne_zero : μ s ≠ 0) : ‖indicatorConstLp ∞ hs hμs c‖ = ‖c‖ := by rw [Lp.norm_def, eLpNorm_congr_ae indicatorConstLp_coeFn, eLpNorm_indicator_const' hs hμs_ne_zero ENNReal.top_ne_zero, ENNReal.toReal_top, _root_.div_zero, ENNReal.rpow_zero, mul_one, toReal_enorm] theorem norm_indicatorConstLp' (hp_pos : p ≠ 0) (hμs_pos : μ s ≠ 0) : ‖indicatorConstLp p hs hμs c‖ = ‖c‖ * μ.real s ^ (1 / p.toReal) := by by_cases hp_top : p = ∞ · rw [hp_top, ENNReal.toReal_top, _root_.div_zero, Real.rpow_zero, mul_one] exact norm_indicatorConstLp_top hμs_pos · exact norm_indicatorConstLp hp_pos hp_top theorem norm_indicatorConstLp_le : ‖indicatorConstLp p hs hμs c‖ ≤ ‖c‖ * μ.real s ^ (1 / p.toReal) := by rw [indicatorConstLp, Lp.norm_toLp] refine ENNReal.toReal_le_of_le_ofReal (by positivity) ?_ refine (eLpNorm_indicator_const_le _ _).trans_eq ?_ rw [ENNReal.ofReal_mul (norm_nonneg _), ofReal_norm, measureReal_def, ENNReal.toReal_rpow, ENNReal.ofReal_toReal] finiteness theorem nnnorm_indicatorConstLp_le : ‖indicatorConstLp p hs hμs c‖₊ ≤ ‖c‖₊ * (μ s).toNNReal ^ (1 / p.toReal) := norm_indicatorConstLp_le theorem enorm_indicatorConstLp_le : ‖indicatorConstLp p hs hμs c‖ₑ ≤ ‖c‖ₑ * μ s ^ (1 / p.toReal) := by simpa [ENNReal.coe_rpow_of_nonneg, ENNReal.coe_toNNReal hμs, Lp.enorm_def, ← enorm_eq_nnnorm] using ENNReal.coe_le_coe.2 <| nnnorm_indicatorConstLp_le (c := c) (hμs := hμs) theorem edist_indicatorConstLp_eq_enorm {t : Set α} {ht : MeasurableSet t} {hμt : μ t ≠ ∞} : edist (indicatorConstLp p hs hμs c) (indicatorConstLp p ht hμt c) = ‖indicatorConstLp p (hs.symmDiff ht) (by finiteness) c‖ₑ := by unfold indicatorConstLp rw [Lp.edist_toLp_toLp, eLpNorm_indicator_sub_indicator, Lp.enorm_toLp] theorem dist_indicatorConstLp_eq_norm {t : Set α} {ht : MeasurableSet t} {hμt : μ t ≠ ∞} : dist (indicatorConstLp p hs hμs c) (indicatorConstLp p ht hμt c) = ‖indicatorConstLp p (hs.symmDiff ht) (by finiteness) c‖ := by -- Squeezed for performance reasons simp only [Lp.dist_edist, edist_indicatorConstLp_eq_enorm, enorm, ENNReal.coe_toReal, Lp.coe_nnnorm] /-- A family of `indicatorConstLp` functions tends to an `indicatorConstLp`, if the underlying sets tend to the set in the sense of the measure of the symmetric difference. -/ theorem tendsto_indicatorConstLp_set [hp₁ : Fact (1 ≤ p)] {β : Type*} {l : Filter β} {t : β → Set α} {ht : ∀ b, MeasurableSet (t b)} {hμt : ∀ b, μ (t b) ≠ ∞} (hp : p ≠ ∞) (h : Tendsto (fun b ↦ μ (t b ∆ s)) l (𝓝 0)) : Tendsto (fun b ↦ indicatorConstLp p (ht b) (hμt b) c) l (𝓝 (indicatorConstLp p hs hμs c)) := by rw [tendsto_iff_dist_tendsto_zero] have hp₀ : p ≠ 0 := (one_pos.trans_le hp₁.out).ne' simp only [dist_indicatorConstLp_eq_norm, norm_indicatorConstLp hp₀ hp] convert tendsto_const_nhds.mul (((ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp h).rpow_const _) · simp [ENNReal.toReal_eq_zero_iff, hp, hp₀] · simp /-- A family of `indicatorConstLp` functions is continuous in the parameter, if `μ (s y ∆ s x)` tends to zero as `y` tends to `x` for all `x`. -/ theorem continuous_indicatorConstLp_set [Fact (1 ≤ p)] {X : Type*} [TopologicalSpace X] {s : X → Set α} {hs : ∀ x, MeasurableSet (s x)} {hμs : ∀ x, μ (s x) ≠ ∞} (hp : p ≠ ∞) (h : ∀ x, Tendsto (fun y ↦ μ (s y ∆ s x)) (𝓝 x) (𝓝 0)) : Continuous fun x ↦ indicatorConstLp p (hs x) (hμs x) c := continuous_iff_continuousAt.2 fun x ↦ tendsto_indicatorConstLp_set hp (h x) @[simp] theorem indicatorConstLp_empty : indicatorConstLp p MeasurableSet.empty (by simp : μ ∅ ≠ ∞) c = 0 := by simp only [indicatorConstLp, Set.indicator_empty', MemLp.toLp_zero] theorem indicatorConstLp_inj {s t : Set α} (hs : MeasurableSet s) (hsμ : μ s ≠ ∞) (ht : MeasurableSet t) (htμ : μ t ≠ ∞) {c : E} (hc : c ≠ 0) : indicatorConstLp p hs hsμ c = indicatorConstLp p ht htμ c ↔ s =ᵐ[μ] t := by simp_rw [← indicator_const_eventuallyEq hc, indicatorConstLp, MemLp.toLp_eq_toLp_iff] theorem memLp_add_of_disjoint {f g : α → E} (h : Disjoint (support f) (support g)) (hf : StronglyMeasurable f) (hg : StronglyMeasurable g) : MemLp (f + g) p μ ↔ MemLp f p μ ∧ MemLp g p μ := by borelize E refine ⟨fun hfg => ⟨?_, ?_⟩, fun h => h.1.add h.2⟩ · rw [← Set.indicator_add_eq_left h]; exact hfg.indicator (measurableSet_support hf.measurable) · rw [← Set.indicator_add_eq_right h]; exact hfg.indicator (measurableSet_support hg.measurable) /-- The indicator of a disjoint union of two sets is the sum of the indicators of the sets. -/ theorem indicatorConstLp_disjoint_union {s t : Set α} (hs : MeasurableSet s) (ht : MeasurableSet t) (hμs : μ s ≠ ∞) (hμt : μ t ≠ ∞) (hst : Disjoint s t) (c : E) : indicatorConstLp p (hs.union ht) (by finiteness) c = indicatorConstLp p hs hμs c + indicatorConstLp p ht hμt c := by ext1 grw [Lp.coeFn_add, indicatorConstLp_coeFn] refine EventuallyEq.trans ?_ (EventuallyEq.fun_add indicatorConstLp_coeFn.symm indicatorConstLp_coeFn.symm) rw [Set.indicator_union_of_disjoint hst] end IndicatorConstLp section const variable (μ p) variable [IsFiniteMeasure μ] (c : E) /-- Constant function as an element of `MeasureTheory.Lp` for a finite measure. -/ protected def Lp.const : E →+ Lp E p μ where toFun c := ⟨AEEqFun.const α c, const_mem_Lp α μ c⟩ map_zero' := rfl map_add' _ _ := rfl lemma Lp.coeFn_const : Lp.const p μ c =ᵐ[μ] Function.const α c := AEEqFun.coeFn_const α c @[simp] lemma Lp.const_val : (Lp.const p μ c).1 = AEEqFun.const α c := rfl @[simp] lemma MemLp.toLp_const : MemLp.toLp _ (memLp_const c) = Lp.const p μ c := rfl @[simp] lemma indicatorConstLp_univ : indicatorConstLp p .univ (measure_ne_top μ _) c = Lp.const p μ c := by rw [← MemLp.toLp_const, indicatorConstLp] simp only [Set.indicator_univ] theorem Lp.norm_const [NeZero μ] (hp_zero : p ≠ 0) : ‖Lp.const p μ c‖ = ‖c‖ * μ.real Set.univ ^ (1 / p.toReal) := by have := NeZero.ne μ rw [← MemLp.toLp_const, Lp.norm_toLp, eLpNorm_const] <;> try assumption rw [measureReal_def, ENNReal.toReal_mul, toReal_enorm, ← ENNReal.toReal_rpow] theorem Lp.norm_const' (hp_zero : p ≠ 0) (hp_top : p ≠ ∞) : ‖Lp.const p μ c‖ = ‖c‖ * μ.real Set.univ ^ (1 / p.toReal) := by rw [← MemLp.toLp_const, Lp.norm_toLp, eLpNorm_const'] <;> try assumption rw [measureReal_def, ENNReal.toReal_mul, toReal_enorm, ← ENNReal.toReal_rpow] theorem Lp.norm_const_le : ‖Lp.const p μ c‖ ≤ ‖c‖ * μ.real Set.univ ^ (1 / p.toReal) := by rw [← indicatorConstLp_univ] exact norm_indicatorConstLp_le /-- `MeasureTheory.Lp.const` as a `LinearMap`. -/ @[simps] protected def Lp.constₗ (𝕜 : Type*) [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] : E →ₗ[𝕜] Lp E p μ where toFun := Lp.const p μ map_add' := map_add _ map_smul' _ _ := rfl /-- `MeasureTheory.Lp.const` as a `ContinuousLinearMap`. -/ @[simps! apply] protected def Lp.constL (𝕜 : Type*) [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] [Fact (1 ≤ p)] : E →L[𝕜] Lp E p μ := (Lp.constₗ p μ 𝕜).mkContinuous (μ.real Set.univ ^ (1 / p.toReal)) fun _ ↦ (Lp.norm_const_le _ _ _).trans_eq (mul_comm _ _) theorem Lp.norm_constL_le (𝕜 : Type*) [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [Fact (1 ≤ p)] : ‖(Lp.constL p μ 𝕜 : E →L[𝕜] Lp E p μ)‖ ≤ μ.real Set.univ ^ (1 / p.toReal) := LinearMap.mkContinuous_norm_le _ (by positivity) _ end const namespace Lp variable {β : Type*} [MeasurableSpace β] {μb : MeasureTheory.Measure β} {f : α → β} theorem indicatorConstLp_compMeasurePreserving {s : Set β} (hs : MeasurableSet s) (hμs : μb s ≠ ∞) (c : E) (hf : MeasurePreserving f μ μb) : Lp.compMeasurePreserving f hf (indicatorConstLp p hs hμs c) = indicatorConstLp p (hs.preimage hf.measurable) (by rwa [hf.measure_preimage hs.nullMeasurableSet]) c := rfl end Lp theorem indicatorConstLp_eq_toSpanSingleton_compLp {s : Set α} [NormedSpace ℝ E] (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) : indicatorConstLp 2 hs hμs x = (ContinuousLinearMap.toSpanSingleton ℝ x).compLp (indicatorConstLp 2 hs hμs (1 : ℝ)) := by ext1 refine indicatorConstLp_coeFn.trans ?_ have h_compLp := (ContinuousLinearMap.toSpanSingleton ℝ x).coeFn_compLp (indicatorConstLp 2 hs hμs (1 : ℝ)) rw [← EventuallyEq] at h_compLp refine EventuallyEq.trans ?_ h_compLp.symm refine (@indicatorConstLp_coeFn _ _ _ 2 μ _ s hs hμs (1 : ℝ)).mono fun y hy => ?_ dsimp only rw [hy] simp_rw [ContinuousLinearMap.toSpanSingleton_apply] by_cases hy_mem : y ∈ s <;> simp [hy_mem] end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSpace/Basic.lean
import Mathlib.Analysis.Normed.Operator.NNNorm import Mathlib.MeasureTheory.Function.LpSeminorm.ChebyshevMarkov import Mathlib.MeasureTheory.Function.LpSeminorm.CompareExp import Mathlib.MeasureTheory.Function.LpSeminorm.TriangleInequality /-! # Lp space This file provides the space `Lp E p μ` as the subtype of elements of `α →ₘ[μ] E` (see `MeasureTheory.AEEqFun`) such that `eLpNorm f p μ` is finite. For `1 ≤ p`, `eLpNorm` defines a norm and `Lp` is a complete metric space (the latter is proved at `Mathlib/MeasureTheory/Function/LpSpace/Complete.lean`). ## Main definitions * `Lp E p μ` : elements of `α →ₘ[μ] E` such that `eLpNorm f p μ` is finite. Defined as an `AddSubgroup` of `α →ₘ[μ] E`. Lipschitz functions vanishing at zero act by composition on `Lp`. We define this action, and prove that it is continuous. In particular, * `ContinuousLinearMap.compLp` defines the action on `Lp` of a continuous linear map. * `Lp.posPart` is the positive part of an `Lp` function. * `Lp.negPart` is the negative part of an `Lp` function. ## Notation * `α →₁[μ] E` : the type `Lp E 1 μ`. * `α →₂[μ] E` : the type `Lp E 2 μ`. ## Implementation Since `Lp` is defined as an `AddSubgroup`, dot notation does not work. Use `Lp.Measurable f` to say that the coercion of `f` to a genuine function is measurable, instead of the non-working `f.Measurable`. To prove that two `Lp` elements are equal, it suffices to show that their coercions to functions coincide almost everywhere (this is registered as an `ext` rule). This can often be done using `filter_upwards`. For instance, a proof from first principles that `f + (g + h) = (f + g) + h` could read (in the `Lp` namespace) ``` example (f g h : Lp E p μ) : (f + g) + h = f + (g + h) := by ext1 filter_upwards [coeFn_add (f + g) h, coeFn_add f g, coeFn_add f (g + h), coeFn_add g h] with _ ha1 ha2 ha3 ha4 simp only [ha1, ha2, ha3, ha4, add_assoc] ``` The lemma `coeFn_add` states that the coercion of `f + g` coincides almost everywhere with the sum of the coercions of `f` and `g`. All such lemmas use `coeFn` in their name, to distinguish the function coercion from the coercion to almost everywhere defined functions. -/ noncomputable section open MeasureTheory Filter open scoped NNReal ENNReal variable {α 𝕜 𝕜' E F : Type*} {m : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] namespace MeasureTheory /-! ### Lp space The space of equivalence classes of measurable functions for which `eLpNorm f p μ < ∞`. -/ @[simp] theorem eLpNorm_aeeqFun {α E : Type*} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] {p : ℝ≥0∞} {f : α → E} (hf : AEStronglyMeasurable f μ) : eLpNorm (AEEqFun.mk f hf) p μ = eLpNorm f p μ := eLpNorm_congr_ae (AEEqFun.coeFn_mk _ _) theorem MemLp.eLpNorm_mk_lt_top {α E : Type*} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] {p : ℝ≥0∞} {f : α → E} (hfp : MemLp f p μ) : eLpNorm (AEEqFun.mk f hfp.1) p μ < ∞ := by simp [hfp.2] /-- Lp space -/ def Lp {α} (E : Type*) {m : MeasurableSpace α} [NormedAddCommGroup E] (p : ℝ≥0∞) (μ : Measure α := by volume_tac) : AddSubgroup (α →ₘ[μ] E) where carrier := { f | eLpNorm f p μ < ∞ } zero_mem' := by simp [eLpNorm_congr_ae AEEqFun.coeFn_zero, eLpNorm_zero] add_mem' {f g} hf hg := by simp [eLpNorm_congr_ae (AEEqFun.coeFn_add f g), eLpNorm_add_lt_top ⟨f.aestronglyMeasurable, hf⟩ ⟨g.aestronglyMeasurable, hg⟩] neg_mem' {f} hf := by rwa [Set.mem_setOf_eq, eLpNorm_congr_ae (AEEqFun.coeFn_neg f), eLpNorm_neg] /-- `α →₁[μ] E` is the type of `L¹` or integrable functions from `α` to `E`. -/ scoped notation:25 α' " →₁[" μ "] " E => MeasureTheory.Lp (α := α') E 1 μ /-- `α →₂[μ] E` is the type of `L²` or square-integrable functions from `α` to `E`. -/ scoped notation:25 α' " →₂[" μ "] " E => MeasureTheory.Lp (α := α') E 2 μ namespace MemLp /-- make an element of Lp from a function verifying `MemLp` -/ def toLp (f : α → E) (h_mem_ℒp : MemLp f p μ) : Lp E p μ := ⟨AEEqFun.mk f h_mem_ℒp.1, h_mem_ℒp.eLpNorm_mk_lt_top⟩ theorem toLp_val {f : α → E} (h : MemLp f p μ) : (toLp f h).1 = AEEqFun.mk f h.1 := rfl theorem coeFn_toLp {f : α → E} (hf : MemLp f p μ) : hf.toLp f =ᵐ[μ] f := AEEqFun.coeFn_mk _ _ theorem toLp_congr {f g : α → E} (hf : MemLp f p μ) (hg : MemLp g p μ) (hfg : f =ᵐ[μ] g) : hf.toLp f = hg.toLp g := by simp [toLp, hfg] @[simp] theorem toLp_eq_toLp_iff {f g : α → E} (hf : MemLp f p μ) (hg : MemLp g p μ) : hf.toLp f = hg.toLp g ↔ f =ᵐ[μ] g := by simp [toLp] @[simp] theorem toLp_zero (h : MemLp (0 : α → E) p μ) : h.toLp 0 = 0 := rfl theorem toLp_add {f g : α → E} (hf : MemLp f p μ) (hg : MemLp g p μ) : (hf.add hg).toLp (f + g) = hf.toLp f + hg.toLp g := rfl theorem toLp_neg {f : α → E} (hf : MemLp f p μ) : hf.neg.toLp (-f) = -hf.toLp f := rfl theorem toLp_sub {f g : α → E} (hf : MemLp f p μ) (hg : MemLp g p μ) : (hf.sub hg).toLp (f - g) = hf.toLp f - hg.toLp g := rfl end MemLp namespace Lp instance instCoeFun : CoeFun (Lp E p μ) (fun _ => α → E) := ⟨fun f => ((f : α →ₘ[μ] E) : α → E)⟩ @[ext high] theorem ext {f g : Lp E p μ} (h : f =ᵐ[μ] g) : f = g := by cases f cases g simp only [Subtype.mk_eq_mk] exact AEEqFun.ext h theorem mem_Lp_iff_eLpNorm_lt_top {f : α →ₘ[μ] E} : f ∈ Lp E p μ ↔ eLpNorm f p μ < ∞ := Iff.rfl theorem mem_Lp_iff_memLp {f : α →ₘ[μ] E} : f ∈ Lp E p μ ↔ MemLp f p μ := by simp [mem_Lp_iff_eLpNorm_lt_top, MemLp, f.stronglyMeasurable.aestronglyMeasurable] protected theorem antitone [IsFiniteMeasure μ] {p q : ℝ≥0∞} (hpq : p ≤ q) : Lp E q μ ≤ Lp E p μ := fun f hf => (MemLp.mono_exponent ⟨f.aestronglyMeasurable, hf⟩ hpq).2 @[simp] theorem coeFn_mk {f : α →ₘ[μ] E} (hf : eLpNorm f p μ < ∞) : ((⟨f, hf⟩ : Lp E p μ) : α → E) = f := rfl -- not @[simp] because dsimp can prove this theorem coe_mk {f : α →ₘ[μ] E} (hf : eLpNorm f p μ < ∞) : ((⟨f, hf⟩ : Lp E p μ) : α →ₘ[μ] E) = f := rfl @[simp] theorem toLp_coeFn (f : Lp E p μ) (hf : MemLp f p μ) : hf.toLp f = f := by simp [MemLp.toLp] theorem eLpNorm_lt_top (f : Lp E p μ) : eLpNorm f p μ < ∞ := f.prop @[aesop (rule_sets := [finiteness]) safe apply] theorem eLpNorm_ne_top (f : Lp E p μ) : eLpNorm f p μ ≠ ∞ := (eLpNorm_lt_top f).ne @[fun_prop, measurability] protected theorem stronglyMeasurable (f : Lp E p μ) : StronglyMeasurable f := f.val.stronglyMeasurable @[fun_prop, measurability] protected theorem aestronglyMeasurable (f : Lp E p μ) : AEStronglyMeasurable f μ := f.val.aestronglyMeasurable protected theorem memLp (f : Lp E p μ) : MemLp f p μ := ⟨Lp.aestronglyMeasurable f, f.prop⟩ variable (E p μ) theorem coeFn_zero : ⇑(0 : Lp E p μ) =ᵐ[μ] 0 := AEEqFun.coeFn_zero variable {E p μ} theorem coeFn_neg (f : Lp E p μ) : ⇑(-f) =ᵐ[μ] -f := AEEqFun.coeFn_neg _ theorem coeFn_add (f g : Lp E p μ) : ⇑(f + g) =ᵐ[μ] f + g := AEEqFun.coeFn_add _ _ theorem coeFn_sub (f g : Lp E p μ) : ⇑(f - g) =ᵐ[μ] f - g := AEEqFun.coeFn_sub _ _ theorem const_mem_Lp (α) {_ : MeasurableSpace α} (μ : Measure α) (c : E) [IsFiniteMeasure μ] : @AEEqFun.const α _ _ μ _ c ∈ Lp E p μ := (memLp_const c).eLpNorm_mk_lt_top instance instNorm : Norm (Lp E p μ) where norm f := ENNReal.toReal (eLpNorm f p μ) -- note: we need this to be defeq to the instance from `SeminormedAddGroup.toNNNorm`, so -- can't use `ENNReal.toNNReal (eLpNorm f p μ)` instance instNNNorm : NNNorm (Lp E p μ) where nnnorm f := ⟨‖f‖, ENNReal.toReal_nonneg⟩ instance instDist : Dist (Lp E p μ) where dist f g := ‖f - g‖ instance instEDist : EDist (Lp E p μ) where edist f g := eLpNorm (⇑f - ⇑g) p μ theorem norm_def (f : Lp E p μ) : ‖f‖ = ENNReal.toReal (eLpNorm f p μ) := rfl theorem nnnorm_def (f : Lp E p μ) : ‖f‖₊ = ENNReal.toNNReal (eLpNorm f p μ) := rfl @[simp, norm_cast] protected theorem coe_nnnorm (f : Lp E p μ) : (‖f‖₊ : ℝ) = ‖f‖ := rfl @[simp] theorem enorm_def (f : Lp E p μ) : ‖f‖ₑ = eLpNorm f p μ := ENNReal.coe_toNNReal <| Lp.eLpNorm_ne_top f @[simp] lemma norm_toLp (f : α → E) (hf : MemLp f p μ) : ‖hf.toLp f‖ = ENNReal.toReal (eLpNorm f p μ) := by rw [norm_def, eLpNorm_congr_ae (MemLp.coeFn_toLp hf)] @[simp] theorem nnnorm_toLp (f : α → E) (hf : MemLp f p μ) : ‖hf.toLp f‖₊ = ENNReal.toNNReal (eLpNorm f p μ) := NNReal.eq <| norm_toLp f hf lemma enorm_toLp {f : α → E} (hf : MemLp f p μ) : ‖hf.toLp f‖ₑ = eLpNorm f p μ := by simp [enorm, nnnorm_toLp f hf, ENNReal.coe_toNNReal hf.2.ne] theorem dist_def (f g : Lp E p μ) : dist f g = (eLpNorm (⇑f - ⇑g) p μ).toReal := by simp_rw [dist, norm_def] refine congr_arg _ ?_ apply eLpNorm_congr_ae (coeFn_sub _ _) theorem edist_def (f g : Lp E p μ) : edist f g = eLpNorm (⇑f - ⇑g) p μ := rfl protected theorem edist_dist (f g : Lp E p μ) : edist f g = .ofReal (dist f g) := by rw [edist_def, dist_def, ← eLpNorm_congr_ae (coeFn_sub _ _), ENNReal.ofReal_toReal (eLpNorm_ne_top (f - g))] protected theorem dist_edist (f g : Lp E p μ) : dist f g = (edist f g).toReal := MeasureTheory.Lp.dist_def .. theorem dist_eq_norm (f g : Lp E p μ) : dist f g = ‖f - g‖ := rfl @[simp] theorem edist_toLp_toLp (f g : α → E) (hf : MemLp f p μ) (hg : MemLp g p μ) : edist (hf.toLp f) (hg.toLp g) = eLpNorm (f - g) p μ := by rw [edist_def] exact eLpNorm_congr_ae (hf.coeFn_toLp.sub hg.coeFn_toLp) @[simp] theorem edist_toLp_zero (f : α → E) (hf : MemLp f p μ) : edist (hf.toLp f) 0 = eLpNorm f p μ := by simpa using edist_toLp_toLp f 0 hf MemLp.zero @[simp] theorem nnnorm_zero : ‖(0 : Lp E p μ)‖₊ = 0 := by rw [nnnorm_def] change (eLpNorm (⇑(0 : α →ₘ[μ] E)) p μ).toNNReal = 0 simp [eLpNorm_congr_ae AEEqFun.coeFn_zero, eLpNorm_zero] @[simp] theorem norm_zero : ‖(0 : Lp E p μ)‖ = 0 := congr_arg ((↑) : ℝ≥0 → ℝ) nnnorm_zero @[simp] theorem norm_measure_zero (f : Lp E p (0 : MeasureTheory.Measure α)) : ‖f‖ = 0 := by -- Squeezed for performance reasons simp only [norm_def, eLpNorm_measure_zero, ENNReal.toReal_zero] @[simp] theorem norm_exponent_zero (f : Lp E 0 μ) : ‖f‖ = 0 := by -- Squeezed for performance reasons simp only [norm_def, eLpNorm_exponent_zero, ENNReal.toReal_zero] theorem nnnorm_eq_zero_iff {f : Lp E p μ} (hp : 0 < p) : ‖f‖₊ = 0 ↔ f = 0 := by refine ⟨fun hf => ?_, fun hf => by simp [hf]⟩ rw [nnnorm_def, ENNReal.toNNReal_eq_zero_iff] at hf cases hf with | inl hf => rw [eLpNorm_eq_zero_iff (Lp.aestronglyMeasurable f) hp.ne.symm] at hf exact Subtype.eq (AEEqFun.ext (hf.trans AEEqFun.coeFn_zero.symm)) | inr hf => exact absurd hf (eLpNorm_ne_top f) theorem norm_eq_zero_iff {f : Lp E p μ} (hp : 0 < p) : ‖f‖ = 0 ↔ f = 0 := NNReal.coe_eq_zero.trans (nnnorm_eq_zero_iff hp) theorem eq_zero_iff_ae_eq_zero {f : Lp E p μ} : f = 0 ↔ f =ᵐ[μ] 0 := by rw [← (Lp.memLp f).toLp_eq_toLp_iff MemLp.zero, MemLp.toLp_zero, toLp_coeFn] @[simp] theorem nnnorm_neg (f : Lp E p μ) : ‖-f‖₊ = ‖f‖₊ := by rw [nnnorm_def, nnnorm_def, eLpNorm_congr_ae (coeFn_neg _), eLpNorm_neg] @[simp] theorem norm_neg (f : Lp E p μ) : ‖-f‖ = ‖f‖ := congr_arg ((↑) : ℝ≥0 → ℝ) (nnnorm_neg f) theorem nnnorm_le_mul_nnnorm_of_ae_le_mul {c : ℝ≥0} {f : Lp E p μ} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) : ‖f‖₊ ≤ c * ‖g‖₊ := by simp only [nnnorm_def] have := eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul h p rwa [← ENNReal.toNNReal_le_toNNReal, ENNReal.smul_def, smul_eq_mul, ENNReal.toNNReal_mul, ENNReal.toNNReal_coe] at this · finiteness · exact ENNReal.mul_ne_top ENNReal.coe_ne_top (by finiteness) theorem norm_le_mul_norm_of_ae_le_mul {c : ℝ} {f : Lp E p μ} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ c * ‖g x‖) : ‖f‖ ≤ c * ‖g‖ := by rcases le_or_gt 0 c with hc | hc · lift c to ℝ≥0 using hc exact NNReal.coe_le_coe.mpr (nnnorm_le_mul_nnnorm_of_ae_le_mul h) · simp only [norm_def] have := eLpNorm_eq_zero_and_zero_of_ae_le_mul_neg h hc p simp [this] theorem norm_le_norm_of_ae_le {f : Lp E p μ} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) : ‖f‖ ≤ ‖g‖ := by rw [norm_def, norm_def] exact ENNReal.toReal_mono (by finiteness) (eLpNorm_mono_ae h) theorem mem_Lp_of_nnnorm_ae_le_mul {c : ℝ≥0} {f : α →ₘ[μ] E} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) : f ∈ Lp E p μ := mem_Lp_iff_memLp.2 <| MemLp.of_nnnorm_le_mul (Lp.memLp g) f.aestronglyMeasurable h theorem mem_Lp_of_ae_le_mul {c : ℝ} {f : α →ₘ[μ] E} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ c * ‖g x‖) : f ∈ Lp E p μ := mem_Lp_iff_memLp.2 <| MemLp.of_le_mul (Lp.memLp g) f.aestronglyMeasurable h theorem mem_Lp_of_nnnorm_ae_le {f : α →ₘ[μ] E} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ ‖g x‖₊) : f ∈ Lp E p μ := mem_Lp_iff_memLp.2 <| MemLp.of_le (Lp.memLp g) f.aestronglyMeasurable h theorem mem_Lp_of_ae_le {f : α →ₘ[μ] E} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) : f ∈ Lp E p μ := mem_Lp_of_nnnorm_ae_le h theorem mem_Lp_of_ae_nnnorm_bound [IsFiniteMeasure μ] {f : α →ₘ[μ] E} (C : ℝ≥0) (hfC : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ C) : f ∈ Lp E p μ := mem_Lp_iff_memLp.2 <| MemLp.of_bound f.aestronglyMeasurable _ hfC theorem mem_Lp_of_ae_bound [IsFiniteMeasure μ] {f : α →ₘ[μ] E} (C : ℝ) (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : f ∈ Lp E p μ := mem_Lp_iff_memLp.2 <| MemLp.of_bound f.aestronglyMeasurable _ hfC theorem nnnorm_le_of_ae_bound [IsFiniteMeasure μ] {f : Lp E p μ} {C : ℝ≥0} (hfC : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ C) : ‖f‖₊ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ * C := by by_cases hμ : μ = 0 · by_cases hp : p.toReal⁻¹ = 0 · simp [hp, hμ, nnnorm_def] · simp [hμ, nnnorm_def] rw [← ENNReal.coe_le_coe, nnnorm_def, ENNReal.coe_toNNReal (eLpNorm_ne_top _)] refine (eLpNorm_le_of_ae_nnnorm_bound hfC).trans_eq ?_ rw [← coe_measureUnivNNReal μ, ← ENNReal.coe_rpow_of_ne_zero (measureUnivNNReal_pos hμ).ne', ENNReal.coe_mul, mul_comm, ENNReal.smul_def, smul_eq_mul] theorem norm_le_of_ae_bound [IsFiniteMeasure μ] {f : Lp E p μ} {C : ℝ} (hC : 0 ≤ C) (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : ‖f‖ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ * C := by lift C to ℝ≥0 using hC have := nnnorm_le_of_ae_bound hfC rwa [← NNReal.coe_le_coe, NNReal.coe_mul, NNReal.coe_rpow] at this instance instNormedAddCommGroup [hp : Fact (1 ≤ p)] : NormedAddCommGroup (Lp E p μ) := { AddGroupNorm.toNormedAddCommGroup { toFun := (norm : Lp E p μ → ℝ) map_zero' := norm_zero neg' := by simp only [norm_neg, implies_true] -- squeezed for performance reasons add_le' := fun f g => by suffices ‖f + g‖ₑ ≤ ‖f‖ₑ + ‖g‖ₑ by -- Squeezed for performance reasons simpa only [ge_iff_le, enorm, ←ENNReal.coe_add, ENNReal.coe_le_coe] using this simp only [Lp.enorm_def] exact (eLpNorm_congr_ae (AEEqFun.coeFn_add _ _)).trans_le (eLpNorm_add_le (Lp.aestronglyMeasurable _) (Lp.aestronglyMeasurable _) hp.out) eq_zero_of_map_eq_zero' := fun _ => (norm_eq_zero_iff <| zero_lt_one.trans_le hp.1).1 } with edist := edist edist_dist := Lp.edist_dist } -- check no diamond is created example [Fact (1 ≤ p)] : PseudoEMetricSpace.toEDist = (Lp.instEDist : EDist (Lp E p μ)) := by with_reducible_and_instances rfl example [Fact (1 ≤ p)] : SeminormedAddGroup.toNNNorm = (Lp.instNNNorm : NNNorm (Lp E p μ)) := by with_reducible_and_instances rfl section IsBoundedSMul variable [NormedRing 𝕜] [NormedRing 𝕜'] [Module 𝕜 E] [Module 𝕜' E] variable [IsBoundedSMul 𝕜 E] [IsBoundedSMul 𝕜' E] theorem const_smul_mem_Lp (c : 𝕜) (f : Lp E p μ) : c • (f : α →ₘ[μ] E) ∈ Lp E p μ := by rw [mem_Lp_iff_eLpNorm_lt_top, eLpNorm_congr_ae (AEEqFun.coeFn_smul _ _)] exact eLpNorm_const_smul_le.trans_lt <| (by finiteness) variable (𝕜 E p μ) /-- The `𝕜`-submodule of elements of `α →ₘ[μ] E` whose `Lp` norm is finite. This is `Lp E p μ`, with extra structure. -/ def LpSubmodule : Submodule 𝕜 (α →ₘ[μ] E) := { Lp E p μ with smul_mem' := fun c f hf => by simpa using const_smul_mem_Lp c ⟨f, hf⟩ } variable {𝕜 E p μ} theorem coe_LpSubmodule : (LpSubmodule 𝕜 E p μ).toAddSubgroup = Lp E p μ := rfl instance instModule : Module 𝕜 (Lp E p μ) := { (LpSubmodule 𝕜 E p μ).module with } theorem coeFn_smul (c : 𝕜) (f : Lp E p μ) : ⇑(c • f) =ᵐ[μ] c • ⇑f := AEEqFun.coeFn_smul _ _ instance instIsCentralScalar [Module 𝕜ᵐᵒᵖ E] [IsBoundedSMul 𝕜ᵐᵒᵖ E] [IsCentralScalar 𝕜 E] : IsCentralScalar 𝕜 (Lp E p μ) where op_smul_eq_smul k f := Subtype.ext <| op_smul_eq_smul k (f : α →ₘ[μ] E) instance instSMulCommClass [SMulCommClass 𝕜 𝕜' E] : SMulCommClass 𝕜 𝕜' (Lp E p μ) where smul_comm k k' f := Subtype.ext <| smul_comm k k' (f : α →ₘ[μ] E) instance instIsScalarTower [SMul 𝕜 𝕜'] [IsScalarTower 𝕜 𝕜' E] : IsScalarTower 𝕜 𝕜' (Lp E p μ) where smul_assoc k k' f := Subtype.ext <| smul_assoc k k' (f : α →ₘ[μ] E) instance instIsBoundedSMul [Fact (1 ≤ p)] : IsBoundedSMul 𝕜 (Lp E p μ) := IsBoundedSMul.of_enorm_smul_le fun r f => by simpa only [eLpNorm_congr_ae (coeFn_smul _ _), enorm_def] using eLpNorm_const_smul_le (c := r) (f := f) (p := p) end IsBoundedSMul section NormedSpace variable {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 E] instance instNormedSpace [Fact (1 ≤ p)] : NormedSpace 𝕜 (Lp E p μ) where norm_smul_le _ _ := norm_smul_le _ _ end NormedSpace end Lp namespace MemLp variable {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] theorem toLp_const_smul {f : α → E} (c : 𝕜) (hf : MemLp f p μ) : (hf.const_smul c).toLp (c • f) = c • hf.toLp f := rfl end MemLp variable {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] theorem MemLp.enorm_rpow_div {f : α → ε} (hf : MemLp f p μ) (q : ℝ≥0∞) : MemLp (‖f ·‖ₑ ^ q.toReal) (p / q) μ := by refine ⟨(hf.1.enorm.pow_const q.toReal).aestronglyMeasurable, ?_⟩ by_cases q_top : q = ∞ · simp [q_top] by_cases q_zero : q = 0 · simp only [q_zero, ENNReal.toReal_zero] by_cases p_zero : p = 0 · simp [p_zero] rw [ENNReal.div_zero p_zero] simpa only [ENNReal.rpow_zero, eLpNorm_exponent_top] using (memLp_top_const_enorm (by simp)).2 rw [eLpNorm_enorm_rpow _ (ENNReal.toReal_pos q_zero q_top)] apply ENNReal.rpow_lt_top_of_nonneg ENNReal.toReal_nonneg rw [ENNReal.ofReal_toReal q_top, div_eq_mul_inv, mul_assoc, ENNReal.inv_mul_cancel q_zero q_top, mul_one] exact hf.2.ne theorem MemLp.norm_rpow_div {f : α → E} (hf : MemLp f p μ) (q : ℝ≥0∞) : MemLp (fun x : α => ‖f x‖ ^ q.toReal) (p / q) μ := by refine ⟨(hf.1.norm.aemeasurable.pow_const q.toReal).aestronglyMeasurable, ?_⟩ by_cases q_top : q = ∞ · simp [q_top] by_cases q_zero : q = 0 · simp only [q_zero, ENNReal.toReal_zero, Real.rpow_zero] by_cases p_zero : p = 0 · simp [p_zero] rw [ENNReal.div_zero p_zero] exact (memLp_top_const (1 : ℝ)).2 rw [eLpNorm_norm_rpow _ (ENNReal.toReal_pos q_zero q_top)] apply ENNReal.rpow_lt_top_of_nonneg ENNReal.toReal_nonneg rw [ENNReal.ofReal_toReal q_top, div_eq_mul_inv, mul_assoc, ENNReal.inv_mul_cancel q_zero q_top, mul_one] exact hf.2.ne theorem memLp_enorm_rpow_iff {q : ℝ≥0∞} {f : α → ε} (hf : AEStronglyMeasurable f μ) (q_zero : q ≠ 0) (q_top : q ≠ ∞) : MemLp (‖f ·‖ₑ ^ q.toReal) (p / q) μ ↔ MemLp f p μ := by refine ⟨fun h => ?_, fun h => h.enorm_rpow_div q⟩ apply (memLp_enorm_iff hf).1 convert h.enorm_rpow_div q⁻¹ using 1 · ext x have : q.toReal * q.toReal⁻¹ = 1 := CommGroupWithZero.mul_inv_cancel q.toReal <| ENNReal.toReal_ne_zero.mpr ⟨q_zero, q_top⟩ simp [← ENNReal.rpow_mul, this, ENNReal.rpow_one] · rw [div_eq_mul_inv, inv_inv, div_eq_mul_inv, mul_assoc, ENNReal.inv_mul_cancel q_zero q_top, mul_one] theorem memLp_norm_rpow_iff {q : ℝ≥0∞} {f : α → E} (hf : AEStronglyMeasurable f μ) (q_zero : q ≠ 0) (q_top : q ≠ ∞) : MemLp (fun x : α => ‖f x‖ ^ q.toReal) (p / q) μ ↔ MemLp f p μ := by refine ⟨fun h => ?_, fun h => h.norm_rpow_div q⟩ apply (memLp_norm_iff hf).1 convert h.norm_rpow_div q⁻¹ using 1 · ext x rw [Real.norm_eq_abs, Real.abs_rpow_of_nonneg (norm_nonneg _), ← Real.rpow_mul (abs_nonneg _), ENNReal.toReal_inv, mul_inv_cancel₀, abs_of_nonneg (norm_nonneg _), Real.rpow_one] simp [ENNReal.toReal_eq_zero_iff, q_zero, q_top] · rw [div_eq_mul_inv, inv_inv, div_eq_mul_inv, mul_assoc, ENNReal.inv_mul_cancel q_zero q_top, mul_one] theorem MemLp.enorm_rpow {f : α → ε} (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp (fun x : α => ‖f x‖ₑ ^ p.toReal) 1 μ := by convert hf.enorm_rpow_div p rw [div_eq_mul_inv, ENNReal.mul_inv_cancel hp_ne_zero hp_ne_top] theorem MemLp.norm_rpow {f : α → E} (hf : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp (fun x : α => ‖f x‖ ^ p.toReal) 1 μ := by convert hf.norm_rpow_div p rw [div_eq_mul_inv, ENNReal.mul_inv_cancel hp_ne_zero hp_ne_top] theorem AEEqFun.compMeasurePreserving_mem_Lp {β : Type*} [MeasurableSpace β] {μb : MeasureTheory.Measure β} {g : β →ₘ[μb] E} (hg : g ∈ Lp E p μb) {f : α → β} (hf : MeasurePreserving f μ μb) : g.compMeasurePreserving f hf ∈ Lp E p μ := by rw [Lp.mem_Lp_iff_eLpNorm_lt_top] at hg ⊢ rwa [eLpNorm_compMeasurePreserving] namespace Lp /-! ### Composition with a measure-preserving function -/ variable {β : Type*} [MeasurableSpace β] {μb : MeasureTheory.Measure β} {f : α → β} /-- Composition of an `L^p` function with a measure-preserving function is an `L^p` function. -/ def compMeasurePreserving (f : α → β) (hf : MeasurePreserving f μ μb) : Lp E p μb →+ Lp E p μ where toFun g := ⟨g.1.compMeasurePreserving f hf, g.1.compMeasurePreserving_mem_Lp g.2 hf⟩ map_zero' := rfl map_add' := by rintro ⟨⟨_⟩, _⟩ ⟨⟨_⟩, _⟩; rfl @[simp] theorem compMeasurePreserving_val (g : Lp E p μb) (hf : MeasurePreserving f μ μb) : (compMeasurePreserving f hf g).1 = g.1.compMeasurePreserving f hf := rfl theorem coeFn_compMeasurePreserving (g : Lp E p μb) (hf : MeasurePreserving f μ μb) : compMeasurePreserving f hf g =ᵐ[μ] g ∘ f := g.1.coeFn_compMeasurePreserving hf @[simp] theorem norm_compMeasurePreserving (g : Lp E p μb) (hf : MeasurePreserving f μ μb) : ‖compMeasurePreserving f hf g‖ = ‖g‖ := congr_arg ENNReal.toReal <| g.1.eLpNorm_compMeasurePreserving hf theorem isometry_compMeasurePreserving [Fact (1 ≤ p)] (hf : MeasurePreserving f μ μb) : Isometry (compMeasurePreserving f hf : Lp E p μb → Lp E p μ) := AddMonoidHomClass.isometry_of_norm _ (norm_compMeasurePreserving · hf) theorem toLp_compMeasurePreserving {g : β → E} (hg : MemLp g p μb) (hf : MeasurePreserving f μ μb) : compMeasurePreserving f hf (hg.toLp g) = (hg.comp_measurePreserving hf).toLp _ := rfl variable (𝕜 : Type*) [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] /-- `MeasureTheory.Lp.compMeasurePreserving` as a linear map. -/ @[simps] def compMeasurePreservingₗ (f : α → β) (hf : MeasurePreserving f μ μb) : Lp E p μb →ₗ[𝕜] Lp E p μ where __ := compMeasurePreserving f hf map_smul' c g := by rcases g with ⟨⟨_⟩, _⟩; rfl /-- `MeasureTheory.Lp.compMeasurePreserving` as a linear isometry. -/ @[simps!] def compMeasurePreservingₗᵢ [Fact (1 ≤ p)] (f : α → β) (hf : MeasurePreserving f μ μb) : Lp E p μb →ₗᵢ[𝕜] Lp E p μ where toLinearMap := compMeasurePreservingₗ 𝕜 f hf norm_map' := (norm_compMeasurePreserving · hf) end Lp end MeasureTheory open MeasureTheory /-! ### Composition on `L^p` We show that Lipschitz functions vanishing at zero act by composition on `L^p`, and specialize this to the composition with continuous linear maps, and to the definition of the positive part of an `L^p` function. -/ section Composition variable {g : E → F} {c : ℝ≥0} theorem LipschitzWith.comp_memLp {α E F} {K} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] {f : α → E} {g : E → F} (hg : LipschitzWith K g) (g0 : g 0 = 0) (hL : MemLp f p μ) : MemLp (g ∘ f) p μ := have : ∀ x, ‖g (f x)‖ ≤ K * ‖f x‖ := fun x ↦ by -- TODO: add `LipschitzWith.nnnorm_sub_le` and `LipschitzWith.nnnorm_le` simpa [g0] using hg.norm_sub_le (f x) 0 hL.of_le_mul (hg.continuous.comp_aestronglyMeasurable hL.1) (Eventually.of_forall this) theorem MeasureTheory.MemLp.of_comp_antilipschitzWith {α E F} {K'} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] {f : α → E} {g : E → F} (hL : MemLp (g ∘ f) p μ) (hg : UniformContinuous g) (hg' : AntilipschitzWith K' g) (g0 : g 0 = 0) : MemLp f p μ := by have A : ∀ x, ‖f x‖ ≤ K' * ‖g (f x)‖ := by intro x -- TODO: add `AntilipschitzWith.le_mul_nnnorm_sub` and `AntilipschitzWith.le_mul_norm` rw [← dist_zero_right, ← dist_zero_right, ← g0] apply hg'.le_mul_dist have B : AEStronglyMeasurable f μ := (hg'.isUniformEmbedding hg).isEmbedding.aestronglyMeasurable_comp_iff.1 hL.1 exact hL.of_le_mul B (Filter.Eventually.of_forall A) lemma MeasureTheory.MemLp.continuousLinearMap_comp [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] {f : α → E} (h_Lp : MemLp f p μ) (L : E →L[𝕜] F) : MemLp (fun x ↦ L (f x)) p μ := LipschitzWith.comp_memLp L.lipschitz (by simp) h_Lp namespace LipschitzWith theorem memLp_comp_iff_of_antilipschitz {α E F} {K K'} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] {f : α → E} {g : E → F} (hg : LipschitzWith K g) (hg' : AntilipschitzWith K' g) (g0 : g 0 = 0) : MemLp (g ∘ f) p μ ↔ MemLp f p μ := ⟨fun h => h.of_comp_antilipschitzWith hg.uniformContinuous hg' g0, fun h => hg.comp_memLp g0 h⟩ /-- When `g` is a Lipschitz function sending `0` to `0` and `f` is in `Lp`, then `g ∘ f` is well defined as an element of `Lp`. -/ def compLp (hg : LipschitzWith c g) (g0 : g 0 = 0) (f : Lp E p μ) : Lp F p μ := ⟨AEEqFun.comp g hg.continuous (f : α →ₘ[μ] E), by suffices ∀ᵐ x ∂μ, ‖AEEqFun.comp g hg.continuous (f : α →ₘ[μ] E) x‖ ≤ c * ‖f x‖ from Lp.mem_Lp_of_ae_le_mul this filter_upwards [AEEqFun.coeFn_comp g hg.continuous (f : α →ₘ[μ] E)] with a ha simp only [ha] rw [← dist_zero_right, ← dist_zero_right, ← g0] exact hg.dist_le_mul (f a) 0⟩ theorem coeFn_compLp (hg : LipschitzWith c g) (g0 : g 0 = 0) (f : Lp E p μ) : hg.compLp g0 f =ᵐ[μ] g ∘ f := AEEqFun.coeFn_comp _ hg.continuous _ @[simp] theorem compLp_zero (hg : LipschitzWith c g) (g0 : g 0 = 0) : hg.compLp g0 (0 : Lp E p μ) = 0 := by rw [Lp.eq_zero_iff_ae_eq_zero] apply (coeFn_compLp _ _ _).trans filter_upwards [Lp.coeFn_zero E p μ] with _ ha simp only [ha, g0, Function.comp_apply, Pi.zero_apply] theorem norm_compLp_sub_le (hg : LipschitzWith c g) (g0 : g 0 = 0) (f f' : Lp E p μ) : ‖hg.compLp g0 f - hg.compLp g0 f'‖ ≤ c * ‖f - f'‖ := by apply Lp.norm_le_mul_norm_of_ae_le_mul filter_upwards [hg.coeFn_compLp g0 f, hg.coeFn_compLp g0 f', Lp.coeFn_sub (hg.compLp g0 f) (hg.compLp g0 f'), Lp.coeFn_sub f f'] with a ha1 ha2 ha3 ha4 simp only [ha1, ha2, ha3, ha4, ← dist_eq_norm, Pi.sub_apply, Function.comp_apply] exact hg.dist_le_mul (f a) (f' a) theorem norm_compLp_le (hg : LipschitzWith c g) (g0 : g 0 = 0) (f : Lp E p μ) : ‖hg.compLp g0 f‖ ≤ c * ‖f‖ := by -- squeezed for performance reasons simpa only [compLp_zero, sub_zero] using hg.norm_compLp_sub_le g0 f 0 theorem lipschitzWith_compLp [Fact (1 ≤ p)] (hg : LipschitzWith c g) (g0 : g 0 = 0) : LipschitzWith c (hg.compLp g0 : Lp E p μ → Lp F p μ) := -- squeezed for performance reasons LipschitzWith.of_dist_le_mul fun f g => by simp only [dist_eq_norm, norm_compLp_sub_le] theorem continuous_compLp [Fact (1 ≤ p)] (hg : LipschitzWith c g) (g0 : g 0 = 0) : Continuous (hg.compLp g0 : Lp E p μ → Lp F p μ) := (lipschitzWith_compLp hg g0).continuous end LipschitzWith namespace ContinuousLinearMap variable {𝕜 𝕜' : Type*} [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕜'] [NormedSpace 𝕜 E] [NormedSpace 𝕜' F] variable {σ : 𝕜 →+* 𝕜'} [RingHomIsometric σ] /-- Composing `f : Lp` with `L : E →L[𝕜] F`. -/ def compLp (L : E →SL[σ] F) (f : Lp E p μ) : Lp F p μ := L.lipschitz.compLp (map_zero L) f theorem coeFn_compLp (L : E →SL[σ] F) (f : Lp E p μ) : ∀ᵐ a ∂μ, (L.compLp f) a = L (f a) := LipschitzWith.coeFn_compLp _ _ _ theorem coeFn_compLp' (L : E →SL[σ] F) (f : Lp E p μ) : L.compLp f =ᵐ[μ] fun a => L (f a) := L.coeFn_compLp f theorem comp_memLp (L : E →SL[σ] F) (f : Lp E p μ) : MemLp (L ∘ f) p μ := (Lp.memLp (L.compLp f)).ae_eq (L.coeFn_compLp' f) theorem comp_memLp' (L : E →SL[σ] F) {f : α → E} (hf : MemLp f p μ) : MemLp (L ∘ f) p μ := (L.comp_memLp (hf.toLp f)).ae_eq (EventuallyEq.fun_comp hf.coeFn_toLp _) section RCLike variable {K : Type*} [RCLike K] theorem _root_.MeasureTheory.MemLp.ofReal {f : α → ℝ} (hf : MemLp f p μ) : MemLp (fun x => (f x : K)) p μ := (@RCLike.ofRealCLM K _).comp_memLp' hf theorem _root_.MeasureTheory.memLp_re_im_iff {f : α → K} : MemLp (fun x ↦ RCLike.re (f x)) p μ ∧ MemLp (fun x ↦ RCLike.im (f x)) p μ ↔ MemLp f p μ := by refine ⟨?_, fun hf => ⟨hf.re, hf.im⟩⟩ rintro ⟨hre, him⟩ convert MeasureTheory.MemLp.add (ε := K) hre.ofReal (him.ofReal.const_mul RCLike.I) ext1 x rw [Pi.add_apply, mul_comm, RCLike.re_add_im] end RCLike theorem add_compLp (L L' : E →SL[σ] F) (f : Lp E p μ) : (L + L').compLp f = L.compLp f + L'.compLp f := by ext1 grw [Lp.coeFn_add, coeFn_compLp'] refine EventuallyEq.trans ?_ (EventuallyEq.fun_add (L.coeFn_compLp' f).symm (L'.coeFn_compLp' f).symm) filter_upwards with x rw [coe_add', Pi.add_def] theorem smul_compLp {𝕜''} [NormedRing 𝕜''] [Module 𝕜'' F] [IsBoundedSMul 𝕜'' F] [SMulCommClass 𝕜' 𝕜'' F] (c : 𝕜'') (L : E →SL[σ] F) (f : Lp E p μ) : (c • L).compLp f = c • L.compLp f := by ext1 grw [Lp.coeFn_smul, coeFn_compLp'] refine (L.coeFn_compLp' f).mono fun x hx => ?_ rw [Pi.smul_apply, hx, coe_smul', Pi.smul_def] theorem norm_compLp_le (L : E →SL[σ] F) (f : Lp E p μ) : ‖L.compLp f‖ ≤ ‖L‖ * ‖f‖ := LipschitzWith.norm_compLp_le _ _ _ variable (μ p) /-- Composing `f : Lp E p μ` with `L : E →L[𝕜] F`, seen as a `𝕜`-linear map on `Lp E p μ`. -/ def compLpₗ (L : E →SL[σ] F) : Lp E p μ →ₛₗ[σ] Lp F p μ where toFun f := L.compLp f map_add' f g := by ext1 filter_upwards [Lp.coeFn_add f g, coeFn_compLp L (f + g), coeFn_compLp L f, coeFn_compLp L g, Lp.coeFn_add (L.compLp f) (L.compLp g)] intro a ha1 ha2 ha3 ha4 ha5 simp only [ha1, ha2, ha3, ha4, ha5, map_add, Pi.add_apply] map_smul' c f := by ext1 filter_upwards [Lp.coeFn_smul c f, coeFn_compLp L (c • f), Lp.coeFn_smul (σ c) (L.compLp f), coeFn_compLp L f] with _ ha1 ha2 ha3 ha4 simp only [ha1, ha2, ha3, ha4, Pi.smul_apply, map_smulₛₗ] /-- Composing `f : Lp E p μ` with `L : E →L[𝕜] F`, seen as a continuous `𝕜`-linear map on `Lp E p μ`. See also the similar * `LinearMap.compLeft` for functions, * `ContinuousLinearMap.compLeftContinuous` for continuous functions, * `ContinuousLinearMap.compLeftContinuousBounded` for bounded continuous functions, * `ContinuousLinearMap.compLeftContinuousCompact` for continuous functions on compact spaces. -/ def compLpL [Fact (1 ≤ p)] (L : E →SL[σ] F) : Lp E p μ →SL[σ] Lp F p μ := LinearMap.mkContinuous (L.compLpₗ p μ) ‖L‖ L.norm_compLp_le variable {μ p} theorem coeFn_compLpL [Fact (1 ≤ p)] (L : E →SL[σ] F) (f : Lp E p μ) : L.compLpL p μ f =ᵐ[μ] fun a => L (f a) := L.coeFn_compLp f theorem add_compLpL [Fact (1 ≤ p)] (L L' : E →SL[σ] F) : (L + L').compLpL p μ = L.compLpL p μ + L'.compLpL p μ := by ext1 f; exact add_compLp L L' f theorem smul_compLpL [Fact (1 ≤ p)] {𝕜''} [NormedRing 𝕜''] [Module 𝕜'' F] [IsBoundedSMul 𝕜'' F] [SMulCommClass 𝕜' 𝕜'' F] (c : 𝕜'') (L : E →SL[σ] F) : (c • L).compLpL p μ = c • L.compLpL p μ := by ext1 f; exact smul_compLp c L f theorem norm_compLpL_le [Fact (1 ≤ p)] (L : E →SL[σ] F) : ‖L.compLpL p μ‖ ≤ ‖L‖ := LinearMap.mkContinuous_norm_le _ (norm_nonneg _) _ end ContinuousLinearMap namespace MeasureTheory.Lp section PosPart theorem lipschitzWith_pos_part : LipschitzWith 1 fun x : ℝ => max x 0 := LipschitzWith.id.max_const _ theorem _root_.MeasureTheory.MemLp.pos_part {f : α → ℝ} (hf : MemLp f p μ) : MemLp (fun x => max (f x) 0) p μ := lipschitzWith_pos_part.comp_memLp (max_eq_right le_rfl) hf theorem _root_.MeasureTheory.MemLp.neg_part {f : α → ℝ} (hf : MemLp f p μ) : MemLp (fun x => max (-f x) 0) p μ := lipschitzWith_pos_part.comp_memLp (max_eq_right le_rfl) hf.neg /-- Positive part of a function in `L^p`. -/ def posPart (f : Lp ℝ p μ) : Lp ℝ p μ := lipschitzWith_pos_part.compLp (max_eq_right le_rfl) f /-- Negative part of a function in `L^p`. -/ def negPart (f : Lp ℝ p μ) : Lp ℝ p μ := posPart (-f) @[norm_cast] theorem coe_posPart (f : Lp ℝ p μ) : (posPart f : α →ₘ[μ] ℝ) = (f : α →ₘ[μ] ℝ).posPart := rfl theorem coeFn_posPart (f : Lp ℝ p μ) : ⇑(posPart f) =ᵐ[μ] fun a => max (f a) 0 := AEEqFun.coeFn_posPart _ theorem coeFn_negPart_eq_max (f : Lp ℝ p μ) : ∀ᵐ a ∂μ, negPart f a = max (-f a) 0 := by rw [negPart] filter_upwards [coeFn_posPart (-f), coeFn_neg f] with _ h₁ h₂ rw [h₁, h₂, Pi.neg_apply] theorem coeFn_negPart (f : Lp ℝ p μ) : ∀ᵐ a ∂μ, negPart f a = -min (f a) 0 := (coeFn_negPart_eq_max f).mono fun a h => by rw [h, ← max_neg_neg, neg_zero] theorem continuous_posPart [Fact (1 ≤ p)] : Continuous fun f : Lp ℝ p μ => posPart f := LipschitzWith.continuous_compLp _ _ theorem continuous_negPart [Fact (1 ≤ p)] : Continuous fun f : Lp ℝ p μ => negPart f := by unfold negPart exact continuous_posPart.comp continuous_neg end PosPart end MeasureTheory.Lp end Composition namespace MeasureTheory.Lp /-- A version of **Markov's inequality** with elements of Lp. -/ lemma pow_mul_meas_ge_le_enorm (f : Lp E p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (ε : ℝ≥0∞) : (ε * μ {x | ε ≤ ‖f x‖ₑ ^ p.toReal}) ^ (1 / p.toReal) ≤ ENNReal.ofReal ‖f‖ := (ENNReal.ofReal_toReal (eLpNorm_ne_top f)).symm ▸ pow_mul_meas_ge_le_eLpNorm μ hp_ne_zero hp_ne_top (Lp.aestronglyMeasurable f) ε /-- A version of **Markov's inequality** with elements of Lp. -/ lemma mul_meas_ge_le_pow_enorm (f : Lp E p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (ε : ℝ≥0∞) : ε * μ {x | ε ≤ ‖f x‖ₑ ^ p.toReal} ≤ ENNReal.ofReal ‖f‖ ^ p.toReal := (ENNReal.ofReal_toReal (eLpNorm_ne_top f)).symm ▸ mul_meas_ge_le_pow_eLpNorm μ hp_ne_zero hp_ne_top (Lp.aestronglyMeasurable f) ε /-- A version of **Markov's inequality** with elements of Lp. -/ theorem mul_meas_ge_le_pow_enorm' (f : Lp E p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (ε : ℝ≥0∞) : ε ^ p.toReal * μ {x | ε ≤ ‖f x‖₊ } ≤ ENNReal.ofReal ‖f‖ ^ p.toReal := (ENNReal.ofReal_toReal (eLpNorm_ne_top f)).symm ▸ mul_meas_ge_le_pow_eLpNorm' μ hp_ne_zero hp_ne_top (Lp.aestronglyMeasurable f) ε /-- A version of **Markov's inequality** with elements of Lp. -/ theorem meas_ge_le_mul_pow_enorm (f : Lp E p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : μ {x | ε ≤ ‖f x‖₊} ≤ ε⁻¹ ^ p.toReal * ENNReal.ofReal ‖f‖ ^ p.toReal := (ENNReal.ofReal_toReal (eLpNorm_ne_top f)).symm ▸ meas_ge_le_mul_pow_eLpNorm_enorm μ hp_ne_zero hp_ne_top (Lp.aestronglyMeasurable f) hε (by simp) section Star variable {R : Type*} [NormedAddCommGroup R] [StarAddMonoid R] [NormedStarGroup R] protected noncomputable instance {p : ℝ≥0∞} : Star (Lp R p μ) where star f := ⟨star (f : α →ₘ[μ] R), by simpa [Lp.mem_Lp_iff_eLpNorm_lt_top] using Lp.eLpNorm_lt_top f⟩ lemma coeFn_star {p : ℝ≥0∞} (f : Lp R p μ) : (star f : Lp R p μ) =ᵐ[μ] star f := (f : α →ₘ[μ] R).coeFn_star noncomputable instance {p : ℝ≥0∞} : InvolutiveStar (Lp R p μ) where star_involutive _ := Subtype.ext <| star_involutive _ noncomputable instance [TrivialStar R] {p : ℝ≥0∞} : TrivialStar (Lp R p μ) where star_trivial _ := Subtype.ext <| star_trivial _ end Star end MeasureTheory.Lp
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSpace/ContinuousCompMeasurePreserving.lean
import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp import Mathlib.MeasureTheory.Measure.ContinuousPreimage /-! # Continuity of `MeasureTheory.Lp.compMeasurePreserving` In this file we prove that the composition of an `L^p` function `g` with a continuous measure-preserving map `f` is continuous in both arguments. First, we prove it for indicator functions, in terms of convergence of `μ ((f a ⁻¹' s) ∆ (g ⁻¹' s))` to zero. Then we prove the continuity of the function of two arguments defined on `MeasureTheory.Lp E p ν × {f : C(X, Y) // MeasurePreserving f μ ν}`. Finally, we provide dot notation convenience lemmas. -/ open Filter Set MeasureTheory open scoped ENNReal Topology symmDiff variable {X Y : Type*} [TopologicalSpace X] [MeasurableSpace X] [BorelSpace X] [R1Space X] [TopologicalSpace Y] [MeasurableSpace Y] [BorelSpace Y] [R1Space Y] {μ : Measure X} {ν : Measure Y} [μ.InnerRegularCompactLTTop] [IsLocallyFiniteMeasure ν] namespace MeasureTheory namespace Lp variable (μ ν) variable (E : Type*) [NormedAddCommGroup E] {p : ℝ≥0∞} [Fact (1 ≤ p)] /-- Let `X` and `Y` be R₁ topological spaces with Borel σ-algebras and measures `μ` and `ν`, respectively. Suppose that `μ` is inner regular for finite measure sets with respect to compact sets and `ν` is a locally finite measure. Let `1 ≤ p < ∞` be an extended nonnegative real number. Then the composition of a function `g : Lp E p ν` and a measure-preserving continuous function `f : C(X, Y)` is continuous in both variables. -/ theorem compMeasurePreserving_continuous (hp : p ≠ ∞) : Continuous fun gf : Lp E p ν × {f : C(X, Y) // MeasurePreserving f μ ν} ↦ compMeasurePreserving gf.2.1 gf.2.2 gf.1 := by have hp₀ : p ≠ 0 := (one_pos.trans_le Fact.out).ne' refine continuous_prod_of_dense_continuous_lipschitzWith _ 1 (MeasureTheory.Lp.simpleFunc.dense hp) ?_ fun f ↦ (isometry_compMeasurePreserving f.2).lipschitz intro f hf lift f to Lp.simpleFunc E p ν using hf induction f using Lp.simpleFunc.induction hp₀ hp with | add hfp hgp _ ihf ihg => exact ihf.add ihg | @indicatorConst c s hs hνs => dsimp only [Lp.simpleFunc.coe_indicatorConst, Lp.indicatorConstLp_compMeasurePreserving] refine continuous_indicatorConstLp_set hp fun f ↦ ?_ apply tendsto_measure_symmDiff_preimage_nhds_zero continuousAt_subtype_val _ f.2 hs.nullMeasurableSet hνs.ne exact .of_forall Subtype.property end Lp end MeasureTheory variable {E : Type*} [NormedAddCommGroup E] {p : ℝ≥0∞} [Fact (1 ≤ p)] theorem Filter.Tendsto.compMeasurePreservingLp {α : Type*} {l : Filter α} {f : α → Lp E p ν} {f₀ : Lp E p ν} {g : α → C(X, Y)} {g₀ : C(X, Y)} (hf : Tendsto f l (𝓝 f₀)) (hg : Tendsto g l (𝓝 g₀)) (hgm : ∀ a, MeasurePreserving (g a) μ ν) (hgm₀ : MeasurePreserving g₀ μ ν) (hp : p ≠ ∞) : Tendsto (fun a ↦ Lp.compMeasurePreserving (g a) (hgm a) (f a)) l (𝓝 (Lp.compMeasurePreserving g₀ hgm₀ f₀)) := by have := (Lp.compMeasurePreserving_continuous μ ν E hp).tendsto ⟨f₀, g₀, hgm₀⟩ replace hg : Tendsto (fun a ↦ ⟨g a, hgm a⟩ : α → {g : C(X, Y) // MeasurePreserving g μ ν}) l (𝓝 ⟨g₀, hgm₀⟩) := tendsto_subtype_rng.2 hg convert this.comp (hf.prodMk_nhds hg) variable {Z : Type*} [TopologicalSpace Z] {f : Z → Lp E p ν} {g : Z → C(X, Y)} {s : Set Z} {z : Z} theorem ContinuousWithinAt.compMeasurePreservingLp (hf : ContinuousWithinAt f s z) (hg : ContinuousWithinAt g s z) (hgm : ∀ z, MeasurePreserving (g z) μ ν) (hp : p ≠ ∞) : ContinuousWithinAt (fun z ↦ Lp.compMeasurePreserving (g z) (hgm z) (f z)) s z := Tendsto.compMeasurePreservingLp hf hg _ _ hp theorem ContinuousAt.compMeasurePreservingLp (hf : ContinuousAt f z) (hg : ContinuousAt g z) (hgm : ∀ z, MeasurePreserving (g z) μ ν) (hp : p ≠ ∞) : ContinuousAt (fun z ↦ Lp.compMeasurePreserving (g z) (hgm z) (f z)) z := Tendsto.compMeasurePreservingLp hf hg _ _ hp theorem ContinuousOn.compMeasurePreservingLp (hf : ContinuousOn f s) (hg : ContinuousOn g s) (hgm : ∀ z, MeasurePreserving (g z) μ ν) (hp : p ≠ ∞) : ContinuousOn (fun z ↦ Lp.compMeasurePreserving (g z) (hgm z) (f z)) s := fun z hz ↦ (hf z hz).compMeasurePreservingLp (hg z hz) hgm hp theorem Continuous.compMeasurePreservingLp (hf : Continuous f) (hg : Continuous g) (hgm : ∀ z, MeasurePreserving (g z) μ ν) (hp : p ≠ ∞) : Continuous (fun z ↦ Lp.compMeasurePreserving (g z) (hgm z) (f z)) := continuous_iff_continuousAt.mpr fun _ ↦ hf.continuousAt.compMeasurePreservingLp hg.continuousAt hgm hp
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSpace/ContinuousFunctions.lean
import Mathlib.Analysis.Normed.Operator.NormedSpace import Mathlib.MeasureTheory.Function.LpSpace.Basic import Mathlib.MeasureTheory.Measure.OpenPos import Mathlib.Topology.ContinuousMap.Compact /-! # Continuous functions in Lp space When `α` is a topological space equipped with a finite Borel measure, there is a bounded linear map from the normed space of bounded continuous functions (`α →ᵇ E`) to `Lp E p μ`. We construct this as `BoundedContinuousFunction.toLp`. -/ open BoundedContinuousFunction MeasureTheory Filter open scoped ENNReal variable {α E : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {μ : Measure α} [TopologicalSpace α] [BorelSpace α] [NormedAddCommGroup E] [SecondCountableTopologyEither α E] variable (E p μ) in /-- An additive subgroup of `Lp E p μ`, consisting of the equivalence classes which contain a bounded continuous representative. -/ def MeasureTheory.Lp.boundedContinuousFunction : AddSubgroup (Lp E p μ) := AddSubgroup.addSubgroupOf ((ContinuousMap.toAEEqFunAddHom μ).comp (toContinuousMapAddMonoidHom α E)).range (Lp E p μ) /-- By definition, the elements of `Lp.boundedContinuousFunction E p μ` are the elements of `Lp E p μ` which contain a bounded continuous representative. -/ theorem MeasureTheory.Lp.mem_boundedContinuousFunction_iff {f : Lp E p μ} : f ∈ MeasureTheory.Lp.boundedContinuousFunction E p μ ↔ ∃ f₀ : α →ᵇ E, f₀.toContinuousMap.toAEEqFun μ = (f : α →ₘ[μ] E) := AddSubgroup.mem_addSubgroupOf namespace BoundedContinuousFunction variable [IsFiniteMeasure μ] /-- A bounded continuous function on a finite-measure space is in `Lp`. -/ theorem mem_Lp (f : α →ᵇ E) : f.toContinuousMap.toAEEqFun μ ∈ Lp E p μ := by refine Lp.mem_Lp_of_ae_bound ‖f‖ ?_ filter_upwards [f.toContinuousMap.coeFn_toAEEqFun μ] with x _ convert f.norm_coe_le_norm x using 2 /-- The `Lp`-norm of a bounded continuous function is at most a constant (depending on the measure of the whole space) times its sup-norm. -/ theorem Lp_nnnorm_le (f : α →ᵇ E) : ‖(⟨f.toContinuousMap.toAEEqFun μ, mem_Lp f⟩ : Lp E p μ)‖₊ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ * ‖f‖₊ := by apply Lp.nnnorm_le_of_ae_bound refine (f.toContinuousMap.coeFn_toAEEqFun μ).mono ?_ intro x hx rw [← NNReal.coe_le_coe, coe_nnnorm, coe_nnnorm] convert f.norm_coe_le_norm x using 2 /-- The `Lp`-norm of a bounded continuous function is at most a constant (depending on the measure of the whole space) times its sup-norm. -/ theorem Lp_norm_le (f : α →ᵇ E) : ‖(⟨f.toContinuousMap.toAEEqFun μ, mem_Lp f⟩ : Lp E p μ)‖ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ * ‖f‖ := Lp_nnnorm_le f variable (p μ) /-- The normed group homomorphism of considering a bounded continuous function on a finite-measure space as an element of `Lp`. -/ def toLpHom [Fact (1 ≤ p)] : NormedAddGroupHom (α →ᵇ E) (Lp E p μ) := { AddMonoidHom.codRestrict ((ContinuousMap.toAEEqFunAddHom μ).comp (toContinuousMapAddMonoidHom α E)) (Lp E p μ) mem_Lp with bound' := ⟨_, Lp_norm_le⟩ } theorem range_toLpHom [Fact (1 ≤ p)] : ((toLpHom p μ).range : AddSubgroup (Lp E p μ)) = MeasureTheory.Lp.boundedContinuousFunction E p μ := by symm exact AddMonoidHom.addSubgroupOf_range_eq_of_le ((ContinuousMap.toAEEqFunAddHom μ).comp (toContinuousMapAddMonoidHom α E)) (by rintro - ⟨f, rfl⟩; exact mem_Lp f : _ ≤ Lp E p μ) variable (𝕜 : Type*) [Fact (1 ≤ p)] [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] /-- The bounded linear map of considering a bounded continuous function on a finite-measure space as an element of `Lp`. -/ noncomputable def toLp : (α →ᵇ E) →L[𝕜] Lp E p μ := LinearMap.mkContinuous (LinearMap.codRestrict (Lp.LpSubmodule 𝕜 E p μ) ((ContinuousMap.toAEEqFunLinearMap μ).comp (toContinuousMapLinearMap α E 𝕜)) mem_Lp) _ Lp_norm_le theorem coeFn_toLp (f : α →ᵇ E) : toLp (E := E) p μ 𝕜 f =ᵐ[μ] f := AEEqFun.coeFn_mk f _ variable {𝕜} theorem range_toLp : (LinearMap.range (toLp p μ 𝕜 : (α →ᵇ E) →L[𝕜] Lp E p μ)).toAddSubgroup = MeasureTheory.Lp.boundedContinuousFunction E p μ := range_toLpHom p μ variable {p} theorem toLp_norm_le {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] : ‖(toLp p μ 𝕜 : (α →ᵇ E) →L[𝕜] Lp E p μ)‖ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ := LinearMap.mkContinuous_norm_le _ (measureUnivNNReal μ ^ p.toReal⁻¹).coe_nonneg _ theorem toLp_inj {f g : α →ᵇ E} [μ.IsOpenPosMeasure] : toLp (E := E) p μ 𝕜 f = toLp (E := E) p μ 𝕜 g ↔ f = g := by refine ⟨fun h => ?_, by tauto⟩ rw [← DFunLike.coe_fn_eq, ← (map_continuous f).ae_eq_iff_eq μ (map_continuous g)] refine (coeFn_toLp p μ 𝕜 f).symm.trans (EventuallyEq.trans ?_ <| coeFn_toLp p μ 𝕜 g) rw [h] theorem toLp_injective [μ.IsOpenPosMeasure] : Function.Injective (⇑(toLp p μ 𝕜 : (α →ᵇ E) →L[𝕜] Lp E p μ)) := fun _f _g hfg => (toLp_inj μ).mp hfg end BoundedContinuousFunction namespace ContinuousMap variable [CompactSpace α] [IsFiniteMeasure μ] variable (𝕜 : Type*) (p μ) [Fact (1 ≤ p)] [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] /-- The bounded linear map of considering a continuous function on a compact finite-measure space `α` as an element of `Lp`. By definition, the norm on `C(α, E)` is the sup-norm, transferred from the space `α →ᵇ E` of bounded continuous functions, so this construction is just a matter of transferring the structure from `BoundedContinuousFunction.toLp` along the isometry. -/ noncomputable def toLp : C(α, E) →L[𝕜] Lp E p μ := (BoundedContinuousFunction.toLp p μ 𝕜).comp (linearIsometryBoundedOfCompact α E 𝕜).toLinearIsometry.toContinuousLinearMap variable {𝕜} theorem range_toLp : (LinearMap.range (toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ)).toAddSubgroup = MeasureTheory.Lp.boundedContinuousFunction E p μ := by refine SetLike.ext' ?_ have := (linearIsometryBoundedOfCompact α E 𝕜).surjective convert Function.Surjective.range_comp this (BoundedContinuousFunction.toLp (E := E) p μ 𝕜) rw [← BoundedContinuousFunction.range_toLp p μ (𝕜 := 𝕜), Submodule.coe_toAddSubgroup, LinearMap.coe_range] variable {p} theorem coeFn_toLp (f : C(α, E)) : toLp (E := E) p μ 𝕜 f =ᵐ[μ] f := AEEqFun.coeFn_mk f _ theorem toLp_def (f : C(α, E)) : toLp (E := E) p μ 𝕜 f = BoundedContinuousFunction.toLp (E := E) p μ 𝕜 (linearIsometryBoundedOfCompact α E 𝕜 f) := rfl @[simp] theorem toLp_comp_toContinuousMap (f : α →ᵇ E) : toLp (E := E) p μ 𝕜 f.toContinuousMap = BoundedContinuousFunction.toLp (E := E) p μ 𝕜 f := rfl @[simp] theorem coe_toLp (f : C(α, E)) : (toLp (E := E) p μ 𝕜 f : α →ₘ[μ] E) = f.toAEEqFun μ := rfl theorem toLp_injective [μ.IsOpenPosMeasure] : Function.Injective (⇑(toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ)) := (BoundedContinuousFunction.toLp_injective _).comp (linearIsometryBoundedOfCompact α E 𝕜).injective theorem toLp_inj {f g : C(α, E)} [μ.IsOpenPosMeasure] : toLp (E := E) p μ 𝕜 f = toLp (E := E) p μ 𝕜 g ↔ f = g := (toLp_injective μ).eq_iff variable {μ} /-- If a sum of continuous functions `g n` is convergent, and the same sum converges in `Lᵖ` to `h`, then in fact `g n` converges uniformly to `h`. -/ theorem hasSum_of_hasSum_Lp {β : Type*} [μ.IsOpenPosMeasure] {g : β → C(α, E)} {f : C(α, E)} (hg : Summable g) (hg2 : HasSum (toLp (E := E) p μ 𝕜 ∘ g) (toLp (E := E) p μ 𝕜 f)) : HasSum g f := by convert Summable.hasSum hg exact toLp_injective μ (hg2.unique ((toLp p μ 𝕜).hasSum <| Summable.hasSum hg)) variable (μ) {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] theorem toLp_norm_eq_toLp_norm_coe : ‖(toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ)‖ = ‖(BoundedContinuousFunction.toLp p μ 𝕜 : (α →ᵇ E) →L[𝕜] Lp E p μ)‖ := ContinuousLinearMap.opNorm_comp_linearIsometryEquiv _ _ /-- Bound for the operator norm of `ContinuousMap.toLp`. -/ theorem toLp_norm_le : ‖(toLp p μ 𝕜 : C(α, E) →L[𝕜] Lp E p μ)‖ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ := by rw [toLp_norm_eq_toLp_norm_coe] exact BoundedContinuousFunction.toLp_norm_le μ end ContinuousMap
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSpace/DomAct/Basic.lean
import Mathlib.MeasureTheory.Function.AEEqFun.DomAct import Mathlib.MeasureTheory.Function.LpSpace.Indicator /-! # Action of `Mᵈᵐᵃ` on `Lᵖ` spaces In this file we define action of `Mᵈᵐᵃ` on `MeasureTheory.Lp E p μ` If `f : α → E` is a function representing an equivalence class in `Lᵖ(α, E)`, `M` acts on `α`, and `c : M`, then `(.mk c : Mᵈᵐᵃ) • [f]` is represented by the function `a ↦ f (c • a)`. We also prove basic properties of this action. -/ open MeasureTheory Filter open scoped ENNReal namespace DomMulAct variable {M N α E : Type*} [MeasurableSpace M] [MeasurableSpace N] [MeasurableSpace α] [NormedAddCommGroup E] {μ : MeasureTheory.Measure α} {p : ℝ≥0∞} section SMul variable [SMul M α] [SMulInvariantMeasure M α μ] [MeasurableSMul M α] @[to_additive] instance : SMul Mᵈᵐᵃ (Lp E p μ) where smul c f := Lp.compMeasurePreserving (mk.symm c • ·) (measurePreserving_smul _ _) f @[to_additive (attr := simp)] theorem smul_Lp_val (c : Mᵈᵐᵃ) (f : Lp E p μ) : (c • f).1 = c • f.1 := rfl @[to_additive] theorem smul_Lp_ae_eq (c : Mᵈᵐᵃ) (f : Lp E p μ) : c • f =ᵐ[μ] (f <| mk.symm c • ·) := Lp.coeFn_compMeasurePreserving _ _ @[to_additive] theorem mk_smul_toLp (c : M) {f : α → E} (hf : MemLp f p μ) : mk c • hf.toLp f = (hf.comp_measurePreserving <| measurePreserving_smul c μ).toLp (f <| c • ·) := rfl @[to_additive (attr := simp)] theorem smul_Lp_const [IsFiniteMeasure μ] (c : Mᵈᵐᵃ) (a : E) : c • Lp.const p μ a = Lp.const p μ a := rfl @[to_additive] theorem mk_smul_indicatorConstLp (c : M) {s : Set α} (hs : MeasurableSet s) (hμs : μ s ≠ ∞) (b : E) : mk c • indicatorConstLp p hs hμs b = indicatorConstLp p (hs.preimage <| measurable_const_smul c) (by rwa [SMulInvariantMeasure.measure_preimage_smul c hs]) b := rfl instance [SMul N α] [SMulCommClass M N α] [SMulInvariantMeasure N α μ] [MeasurableSMul N α] : SMulCommClass Mᵈᵐᵃ Nᵈᵐᵃ (Lp E p μ) := Subtype.val_injective.smulCommClass (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] : SMulCommClass Mᵈᵐᵃ 𝕜 (Lp E p μ) := Subtype.val_injective.smulCommClass (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 E] [IsBoundedSMul 𝕜 E] : SMulCommClass 𝕜 Mᵈᵐᵃ (Lp E p μ) := .symm _ _ _ -- We don't have a typeclass for additive versions of the next few lemmas -- Should we add `AddDistribAddAction` with `to_additive` both from `MulDistribMulAction` -- and `DistribMulAction`? @[to_additive] theorem smul_Lp_add (c : Mᵈᵐᵃ) : ∀ f g : Lp E p μ, c • (f + g) = c • f + c • g := by rintro ⟨⟨⟩, _⟩ ⟨⟨⟩, _⟩; rfl attribute [simp] DomAddAct.vadd_Lp_add @[to_additive (attr := simp 1001)] theorem smul_Lp_zero (c : Mᵈᵐᵃ) : c • (0 : Lp E p μ) = 0 := rfl @[to_additive] theorem smul_Lp_neg (c : Mᵈᵐᵃ) (f : Lp E p μ) : c • (-f) = -(c • f) := by rcases f with ⟨⟨_⟩, _⟩; rfl @[to_additive] theorem smul_Lp_sub (c : Mᵈᵐᵃ) : ∀ f g : Lp E p μ, c • (f - g) = c • f - c • g := by rintro ⟨⟨⟩, _⟩ ⟨⟨⟩, _⟩; rfl instance : DistribSMul Mᵈᵐᵃ (Lp E p μ) where smul_zero _ := rfl smul_add := by rintro _ ⟨⟨⟩, _⟩ ⟨⟨⟩, _⟩; rfl -- The next few lemmas follow from the `IsIsometricSMul` instance if `1 ≤ p` @[to_additive (attr := simp)] theorem norm_smul_Lp (c : Mᵈᵐᵃ) (f : Lp E p μ) : ‖c • f‖ = ‖f‖ := Lp.norm_compMeasurePreserving _ _ @[to_additive (attr := simp)] theorem nnnorm_smul_Lp (c : Mᵈᵐᵃ) (f : Lp E p μ) : ‖c • f‖₊ = ‖f‖₊ := NNReal.eq <| Lp.norm_compMeasurePreserving _ _ @[to_additive (attr := simp)] theorem dist_smul_Lp (c : Mᵈᵐᵃ) (f g : Lp E p μ) : dist (c • f) (c • g) = dist f g := by simp only [dist, ← smul_Lp_sub, norm_smul_Lp] @[to_additive (attr := simp)] theorem edist_smul_Lp (c : Mᵈᵐᵃ) (f g : Lp E p μ) : edist (c • f) (c • g) = edist f g := by simp only [Lp.edist_dist, dist_smul_Lp] variable [Fact (1 ≤ p)] @[to_additive] instance : IsIsometricSMul Mᵈᵐᵃ (Lp E p μ) := ⟨edist_smul_Lp⟩ end SMul section MulAction variable [Monoid M] [MulAction M α] [SMulInvariantMeasure M α μ] [MeasurableSMul M α] @[to_additive] instance : MulAction Mᵈᵐᵃ (Lp E p μ) := Subtype.val_injective.mulAction _ fun _ _ ↦ rfl instance : DistribMulAction Mᵈᵐᵃ (Lp E p μ) := Subtype.val_injective.distribMulAction ⟨⟨_, rfl⟩, fun _ _ ↦ rfl⟩ fun _ _ ↦ rfl end MulAction end DomMulAct
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSpace/DomAct/Continuous.lean
import Mathlib.MeasureTheory.Function.LpSpace.DomAct.Basic import Mathlib.MeasureTheory.Function.LpSpace.ContinuousCompMeasurePreserving import Mathlib.Topology.Algebra.Constructions.DomMulAct /-! # Continuity of the action of `Mᵈᵐᵃ` on `MeasureSpace.Lp E p μ` In this file we prove that under certain conditions, the action of `Mᵈᵐᵃ` on `MeasureTheory.Lp E p μ` is continuous in both variables. Recall that `Mᵈᵐᵃ` acts on `MeasureTheory.Lp E p μ` by `mk c • f = MeasureTheory.Lp.compMeasurePreserving (c • ·) _ f`. This action is defined, if `M` acts on `X` by measure-preserving maps. If `M` acts on `X` by continuous maps preserving a locally finite measure which is inner regular for finite measure sets with respect to compact sets, then the action of `Mᵈᵐᵃ` on `Lp E p μ` described above, `1 ≤ p < ∞`, is continuous in both arguments. In particular, it applies to the case when `X = M` is a locally compact topological group, and `μ` is the Haar measure. ## Tags measure theory, group action, domain action, continuous action, Lp space -/ open scoped ENNReal open DomMulAct namespace MeasureTheory variable {X M E : Type*} [TopologicalSpace X] [R1Space X] [MeasurableSpace X] [BorelSpace X] [Monoid M] [TopologicalSpace M] [MeasurableSpace M] [OpensMeasurableSpace M] [SMul M X] [ContinuousSMul M X] [NormedAddCommGroup E] {μ : Measure X} [IsLocallyFiniteMeasure μ] [μ.InnerRegularCompactLTTop] [SMulInvariantMeasure M X μ] {p : ℝ≥0∞} [Fact (1 ≤ p)] [hp : Fact (p ≠ ∞)] @[to_additive] instance Lp.instContinuousSMulDomMulAct : ContinuousSMul Mᵈᵐᵃ (Lp E p μ) where continuous_smul := let g : C(Mᵈᵐᵃ × Lp E p μ, C(X, X)) := (ContinuousMap.mk (fun a : M × X ↦ a.1 • a.2) continuous_smul).curry.comp <| .comp (.mk DomMulAct.mk.symm) ContinuousMap.fst continuous_snd.compMeasurePreservingLp g.continuous _ Fact.out end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/AEEqFun/DomAct.lean
import Mathlib.MeasureTheory.Function.AEEqFun import Mathlib.MeasureTheory.Group.Action import Mathlib.GroupTheory.GroupAction.DomAct.Basic import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lemmas /-! # Action of `DomMulAct` and `DomAddAct` on `α →ₘ[μ] β` If `M` acts on `α` by measure-preserving transformations, then `Mᵈᵐᵃ` acts on `α →ₘ[μ] β` by sending each function `f` to `f ∘ (DomMulAct.mk.symm c • ·)`. We define this action and basic instances about it. ## Implementation notes In fact, it suffices to require that `(c • ·)` is only quasi-measure-preserving but we do not have a typeclass for quasi-measure-preserving actions yet. ## Keywords -/ open MeasureTheory namespace DomMulAct variable {M N α β} [MeasurableSpace M] [MeasurableSpace N] [MeasurableSpace α] {μ : MeasureTheory.Measure α} [TopologicalSpace β] section SMul variable [SMul M α] [MeasurableSMul M α] [SMulInvariantMeasure M α μ] @[to_additive] instance : SMul Mᵈᵐᵃ (α →ₘ[μ] β) where smul c f := f.compMeasurePreserving (mk.symm c • ·) (measurePreserving_smul _ _) @[to_additive] theorem smul_aeeqFun_aeeq (c : Mᵈᵐᵃ) (f : α →ₘ[μ] β) : c • f =ᵐ[μ] (f <| mk.symm c • ·) := f.coeFn_compMeasurePreserving _ @[to_additive (attr := simp)] theorem mk_smul_mk_aeeqFun (c : M) (f : α → β) (hf : AEStronglyMeasurable f μ) : mk c • AEEqFun.mk f hf = AEEqFun.mk (f <| c • ·) (hf.comp_measurePreserving (measurePreserving_smul _ _)) := rfl @[to_additive (attr := simp)] theorem smul_aeeqFun_const (c : Mᵈᵐᵃ) (b : β) : c • (AEEqFun.const α b : α →ₘ[μ] β) = AEEqFun.const α b := rfl instance [SMul N β] [ContinuousConstSMul N β] : SMulCommClass Mᵈᵐᵃ N (α →ₘ[μ] β) where smul_comm := by rintro _ _ ⟨_⟩; rfl instance [SMul N β] [ContinuousConstSMul N β] : SMulCommClass N Mᵈᵐᵃ (α →ₘ[μ] β) := .symm _ _ _ @[to_additive] instance [SMul N α] [MeasurableSMul N α] [SMulInvariantMeasure N α μ] [SMulCommClass M N α] : SMulCommClass Mᵈᵐᵃ Nᵈᵐᵃ (α →ₘ[μ] β) where smul_comm := mk.surjective.forall.2 fun c₁ ↦ mk.surjective.forall.2 fun c₂ ↦ (AEEqFun.induction_on · fun f hf ↦ by simp only [mk_smul_mk_aeeqFun, smul_comm]) instance [Zero β] : SMulZeroClass Mᵈᵐᵃ (α →ₘ[μ] β) where smul_zero _ := rfl -- TODO: add `AEEqFun.addZeroClass` instance [AddMonoid β] [ContinuousAdd β] : DistribSMul Mᵈᵐᵃ (α →ₘ[μ] β) where smul_add := by rintro _ ⟨⟩ ⟨⟩; rfl end SMul section MulAction variable [Monoid M] [MulAction M α] [MeasurableSMul M α] [SMulInvariantMeasure M α μ] @[to_additive] instance : MulAction Mᵈᵐᵃ (α →ₘ[μ] β) where one_smul := (AEEqFun.induction_on · fun _ _ ↦ by simp only [← mk_one, mk_smul_mk_aeeqFun, one_smul]) mul_smul := mk.surjective.forall.2 fun _ ↦ mk.surjective.forall.2 fun _ ↦ (AEEqFun.induction_on · fun _ _ ↦ by simp only [← mk_mul, mk_smul_mk_aeeqFun, mul_smul]) instance [Monoid β] [ContinuousMul β] : MulDistribMulAction Mᵈᵐᵃ (α →ₘ[μ] β) where smul_one _ := rfl smul_mul := by rintro _ ⟨⟩ ⟨⟩; rfl instance [AddMonoid β] [ContinuousAdd β] : DistribMulAction Mᵈᵐᵃ (α →ₘ[μ] β) where smul_zero := smul_zero smul_add := smul_add end MulAction end DomMulAct
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSeminorm/Trim.lean
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic /-! # Lp seminorm with respect to trimmed measure In this file we prove basic properties of the Lp-seminorm of a function with respect to the restriction of a measure to a sub-σ-algebra. -/ namespace MeasureTheory open Filter open scoped ENNReal variable {α E ε : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} [NormedAddCommGroup E] [TopologicalSpace ε] [ContinuousENorm ε] theorem eLpNorm'_trim (hm : m ≤ m0) {f : α → ε} (hf : StronglyMeasurable[m] f) : eLpNorm' f q (μ.trim hm) = eLpNorm' f q μ := by simp_rw [eLpNorm'] congr 1 exact lintegral_trim hm (by fun_prop) theorem limsup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : limsup f (ae (μ.trim hm)) = limsup f (ae μ) := by simp_rw [limsup_eq] suffices h_set_eq : { a : ℝ≥0∞ | ∀ᵐ n ∂μ.trim hm, f n ≤ a } = { a : ℝ≥0∞ | ∀ᵐ n ∂μ, f n ≤ a } by rw [h_set_eq] ext1 a suffices h_meas_eq : μ { x | ¬f x ≤ a } = μ.trim hm { x | ¬f x ≤ a } by simp_rw [Set.mem_setOf_eq, ae_iff, h_meas_eq] refine (trim_measurableSet_eq hm ?_).symm exact (measurableSet_le hf measurable_const).compl theorem essSup_trim (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) : essSup f (μ.trim hm) = essSup f μ := by simp_rw [essSup] exact limsup_trim hm hf theorem eLpNormEssSup_trim (hm : m ≤ m0) {f : α → ε} (hf : StronglyMeasurable[m] f) : eLpNormEssSup f (μ.trim hm) = eLpNormEssSup f μ := essSup_trim _ (@StronglyMeasurable.enorm _ m _ _ _ _ hf) theorem eLpNorm_trim (hm : m ≤ m0) {f : α → ε} (hf : StronglyMeasurable[m] f) : eLpNorm f p (μ.trim hm) = eLpNorm f p μ := by by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · simpa only [h_top, eLpNorm_exponent_top] using eLpNormEssSup_trim hm hf simpa only [eLpNorm_eq_eLpNorm' h0 h_top] using eLpNorm'_trim hm hf theorem eLpNorm_trim_ae (hm : m ≤ m0) {f : α → ε} (hf : AEStronglyMeasurable[m] f (μ.trim hm)) : eLpNorm f p (μ.trim hm) = eLpNorm f p μ := by rw [eLpNorm_congr_ae hf.ae_eq_mk, eLpNorm_congr_ae (ae_eq_of_ae_eq_trim hf.ae_eq_mk)] exact eLpNorm_trim hm hf.stronglyMeasurable_mk theorem memLp_of_memLp_trim (hm : m ≤ m0) {f : α → ε} (hf : MemLp f p (μ.trim hm)) : MemLp f p μ := ⟨aestronglyMeasurable_of_aestronglyMeasurable_trim hm hf.1, (le_of_eq (eLpNorm_trim_ae hm hf.1).symm).trans_lt hf.2⟩ end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSeminorm/Prod.lean
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic import Mathlib.MeasureTheory.Measure.Prod /-! # ℒp spaces and products -/ open scoped ENNReal namespace MeasureTheory variable {α β ε : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} [TopologicalSpace ε] [ContinuousENorm ε] {μ : Measure α} {ν : Measure β} {p : ℝ≥0∞} lemma MemLp.comp_fst {f : α → ε} (hf : MemLp f p μ) (ν : Measure β) [IsFiniteMeasure ν] : MemLp (fun x ↦ f x.1) p (μ.prod ν) := by have hf' : MemLp f p (ν .univ • μ) := hf.smul_measure (by simp) change MemLp (f ∘ Prod.fst) p (μ.prod ν) rw [← memLp_map_measure_iff ?_ (by fun_prop)] · simpa using hf' · simpa using hf'.1 lemma MemLp.comp_snd {f : β → ε} (hf : MemLp f p ν) (μ : Measure α) [IsFiniteMeasure μ] [SFinite ν] : MemLp (fun x ↦ f x.2) p (μ.prod ν) := by have hf' : MemLp f p (μ .univ • ν) := hf.smul_measure (by simp) change MemLp (f ∘ Prod.snd) p (μ.prod ν) rw [← memLp_map_measure_iff ?_ (by fun_prop)] · simpa using hf' · simpa using hf'.1 end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSeminorm/Basic.lean
import Mathlib.Analysis.Normed.Group.Indicator import Mathlib.Data.Fintype.Order import Mathlib.MeasureTheory.Function.AEEqFun import Mathlib.MeasureTheory.Function.LpSeminorm.Defs import Mathlib.MeasureTheory.Function.SpecialFunctions.Basic import Mathlib.MeasureTheory.Integral.Lebesgue.Countable import Mathlib.MeasureTheory.Integral.Lebesgue.Sub /-! # Basic theorems about ℒp space -/ noncomputable section open TopologicalSpace MeasureTheory Filter open scoped NNReal ENNReal Topology ComplexConjugate variable {α ε ε' E F G : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ ν : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] [ENorm ε] [ENorm ε'] namespace MeasureTheory section Lp section Top theorem MemLp.eLpNorm_lt_top [TopologicalSpace ε] {f : α → ε} (hfp : MemLp f p μ) : eLpNorm f p μ < ∞ := hfp.2 @[aesop (rule_sets := [finiteness]) unsafe 95% apply] theorem MemLp.eLpNorm_ne_top [TopologicalSpace ε] {f : α → ε} (hfp : MemLp f p μ) : eLpNorm f p μ ≠ ∞ := hfp.2.ne theorem lintegral_rpow_enorm_lt_top_of_eLpNorm'_lt_top {f : α → ε} (hq0_lt : 0 < q) (hfq : eLpNorm' f q μ < ∞) : ∫⁻ a, ‖f a‖ₑ ^ q ∂μ < ∞ := by rw [lintegral_rpow_enorm_eq_rpow_eLpNorm' hq0_lt] exact ENNReal.rpow_lt_top_of_nonneg (le_of_lt hq0_lt) (ne_of_lt hfq) theorem lintegral_rpow_enorm_lt_top_of_eLpNorm_lt_top {f : α → ε} (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) (hfp : eLpNorm f p μ < ∞) : ∫⁻ a, ‖f a‖ₑ ^ p.toReal ∂μ < ∞ := by apply lintegral_rpow_enorm_lt_top_of_eLpNorm'_lt_top · exact ENNReal.toReal_pos hp_ne_zero hp_ne_top · simpa [eLpNorm_eq_eLpNorm' hp_ne_zero hp_ne_top] using hfp theorem eLpNorm_lt_top_iff_lintegral_rpow_enorm_lt_top {f : α → ε} (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : eLpNorm f p μ < ∞ ↔ ∫⁻ a, (‖f a‖ₑ) ^ p.toReal ∂μ < ∞ := ⟨lintegral_rpow_enorm_lt_top_of_eLpNorm_lt_top hp_ne_zero hp_ne_top, by intro h have hp' := ENNReal.toReal_pos hp_ne_zero hp_ne_top have : 0 < 1 / p.toReal := div_pos zero_lt_one hp' simpa [eLpNorm_eq_lintegral_rpow_enorm hp_ne_zero hp_ne_top] using ENNReal.rpow_lt_top_of_nonneg (le_of_lt this) (ne_of_lt h)⟩ end Top section Zero @[simp] theorem eLpNorm'_exponent_zero {f : α → ε} : eLpNorm' f 0 μ = 1 := by rw [eLpNorm', div_zero, ENNReal.rpow_zero] @[simp] theorem eLpNorm_exponent_zero {f : α → ε} : eLpNorm f 0 μ = 0 := by simp [eLpNorm] @[simp] theorem memLp_zero_iff_aestronglyMeasurable [TopologicalSpace ε] {f : α → ε} : MemLp f 0 μ ↔ AEStronglyMeasurable f μ := by simp [MemLp, eLpNorm_exponent_zero] section ESeminormedAddMonoid variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] @[simp] theorem eLpNorm'_zero (hp0_lt : 0 < q) : eLpNorm' (0 : α → ε) q μ = 0 := by simp [eLpNorm'_eq_lintegral_enorm, hp0_lt] @[simp] theorem eLpNorm'_zero' (hq0_ne : q ≠ 0) (hμ : μ ≠ 0) : eLpNorm' (0 : α → ε) q μ = 0 := by rcases le_or_gt 0 q with hq0 | hq_neg · exact eLpNorm'_zero (lt_of_le_of_ne hq0 hq0_ne.symm) · simp [eLpNorm'_eq_lintegral_enorm, hμ, hq_neg] @[simp] theorem eLpNormEssSup_zero : eLpNormEssSup (0 : α → ε) μ = 0 := by simp [eLpNormEssSup, ← bot_eq_zero', essSup_const_bot] @[simp] theorem eLpNorm_zero : eLpNorm (0 : α → ε) p μ = 0 := by by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · simp only [h_top, eLpNorm_exponent_top, eLpNormEssSup_zero] rw [← Ne] at h0 simp [eLpNorm_eq_eLpNorm' h0 h_top, ENNReal.toReal_pos h0 h_top] @[simp] theorem eLpNorm_zero' : eLpNorm (fun _ : α => (0 : ε)) p μ = 0 := eLpNorm_zero @[simp] lemma MemLp.zero : MemLp (0 : α → ε) p μ := ⟨aestronglyMeasurable_zero, by rw [eLpNorm_zero]; exact ENNReal.coe_lt_top⟩ @[simp] lemma MemLp.zero' : MemLp (fun _ : α => (0 : ε)) p μ := MemLp.zero variable [MeasurableSpace α] theorem eLpNorm'_measure_zero_of_pos {f : α → ε} (hq_pos : 0 < q) : eLpNorm' f q (0 : Measure α) = 0 := by simp [eLpNorm', hq_pos] theorem eLpNorm'_measure_zero_of_exponent_zero {f : α → ε} : eLpNorm' f 0 (0 : Measure α) = 1 := by simp [eLpNorm'] theorem eLpNorm'_measure_zero_of_neg {f : α → ε} (hq_neg : q < 0) : eLpNorm' f q (0 : Measure α) = ∞ := by simp [eLpNorm', hq_neg] end ESeminormedAddMonoid @[simp] theorem eLpNormEssSup_measure_zero {f : α → ε} : eLpNormEssSup f (0 : Measure α) = 0 := by simp [eLpNormEssSup] @[simp] theorem eLpNorm_measure_zero {f : α → ε} : eLpNorm f p (0 : Measure α) = 0 := by by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · simp [h_top] rw [← Ne] at h0 simp [eLpNorm_eq_eLpNorm' h0 h_top, eLpNorm', ENNReal.toReal_pos h0 h_top] section ContinuousENorm variable {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] @[simp] lemma memLp_measure_zero {f : α → ε} : MemLp f p (0 : Measure α) := by simp [MemLp] end ContinuousENorm end Zero section Neg @[simp] theorem eLpNorm'_neg (f : α → F) (q : ℝ) (μ : Measure α) : eLpNorm' (-f) q μ = eLpNorm' f q μ := by simp [eLpNorm'_eq_lintegral_enorm] @[simp] theorem eLpNorm_neg (f : α → F) (p : ℝ≥0∞) (μ : Measure α) : eLpNorm (-f) p μ = eLpNorm f p μ := by by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · simp [h_top, eLpNormEssSup_eq_essSup_enorm] simp [eLpNorm_eq_eLpNorm' h0 h_top] lemma eLpNorm_sub_comm (f g : α → E) (p : ℝ≥0∞) (μ : Measure α) : eLpNorm (f - g) p μ = eLpNorm (g - f) p μ := by simp [← eLpNorm_neg (f := f - g)] theorem MemLp.neg {f : α → E} (hf : MemLp f p μ) : MemLp (-f) p μ := ⟨AEStronglyMeasurable.neg hf.1, by simp [hf.right]⟩ theorem memLp_neg_iff {f : α → E} : MemLp (-f) p μ ↔ MemLp f p μ := ⟨fun h => neg_neg f ▸ h.neg, MemLp.neg⟩ end Neg section Const variable {ε' ε'' : Type*} [TopologicalSpace ε'] [ContinuousENorm ε'] [TopologicalSpace ε''] [ESeminormedAddMonoid ε''] theorem eLpNorm'_const (c : ε) (hq_pos : 0 < q) : eLpNorm' (fun _ : α => c) q μ = ‖c‖ₑ * μ Set.univ ^ (1 / q) := by rw [eLpNorm'_eq_lintegral_enorm, lintegral_const, ENNReal.mul_rpow_of_nonneg _ _ (by simp [hq_pos.le] : 0 ≤ 1 / q)] congr rw [← ENNReal.rpow_mul] suffices hq_cancel : q * (1 / q) = 1 by rw [hq_cancel, ENNReal.rpow_one] rw [one_div, mul_inv_cancel₀ (ne_of_lt hq_pos).symm] -- Generalising this to ESeminormedAddMonoid requires a case analysis whether ‖c‖ₑ = ⊤, -- and will happen in a future PR. theorem eLpNorm'_const' [IsFiniteMeasure μ] (c : F) (hc_ne_zero : c ≠ 0) (hq_ne_zero : q ≠ 0) : eLpNorm' (fun _ : α => c) q μ = ‖c‖ₑ * μ Set.univ ^ (1 / q) := by rw [eLpNorm'_eq_lintegral_enorm, lintegral_const, ENNReal.mul_rpow_of_ne_top _ (by finiteness)] · congr rw [← ENNReal.rpow_mul] suffices hp_cancel : q * (1 / q) = 1 by rw [hp_cancel, ENNReal.rpow_one] rw [one_div, mul_inv_cancel₀ hq_ne_zero] · have : ‖c‖ₑ ≠ 0 := by simp [hc_ne_zero] finiteness theorem eLpNormEssSup_const (c : ε) (hμ : μ ≠ 0) : eLpNormEssSup (fun _ : α => c) μ = ‖c‖ₑ := by rw [eLpNormEssSup_eq_essSup_enorm, essSup_const _ hμ] theorem eLpNorm'_const_of_isProbabilityMeasure (c : ε) (hq_pos : 0 < q) [IsProbabilityMeasure μ] : eLpNorm' (fun _ : α => c) q μ = ‖c‖ₑ := by simp [eLpNorm'_const c hq_pos, measure_univ] theorem eLpNorm_const (c : ε) (h0 : p ≠ 0) (hμ : μ ≠ 0) : eLpNorm (fun _ : α => c) p μ = ‖c‖ₑ * μ Set.univ ^ (1 / ENNReal.toReal p) := by by_cases h_top : p = ∞ · simp [h_top, eLpNormEssSup_const c hμ] simp [eLpNorm_eq_eLpNorm' h0 h_top, eLpNorm'_const, ENNReal.toReal_pos h0 h_top] theorem eLpNorm_const' (c : ε) (h0 : p ≠ 0) (h_top : p ≠ ∞) : eLpNorm (fun _ : α => c) p μ = ‖c‖ₑ * μ Set.univ ^ (1 / ENNReal.toReal p) := by simp [eLpNorm_eq_eLpNorm' h0 h_top, eLpNorm'_const, ENNReal.toReal_pos h0 h_top] -- NB. If ‖c‖ₑ = ∞ and μ is finite, this claim is false: the right has side is true, -- but the left-hand side is false (as the norm is infinite). theorem eLpNorm_const_lt_top_iff_enorm {c : ε''} (hc' : ‖c‖ₑ ≠ ∞) {p : ℝ≥0∞} (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : eLpNorm (fun _ : α ↦ c) p μ < ∞ ↔ ‖c‖ₑ = 0 ∨ μ Set.univ < ∞ := by have hp : 0 < p.toReal := ENNReal.toReal_pos hp_ne_zero hp_ne_top by_cases hμ : μ = 0 · simp only [hμ, Measure.coe_zero, Pi.zero_apply, or_true, ENNReal.zero_lt_top, eLpNorm_measure_zero] by_cases hc : ‖c‖ₑ = 0 · rw [eLpNorm_lt_top_iff_lintegral_rpow_enorm_lt_top hp_ne_zero hp_ne_top] simp [hc, ENNReal.zero_rpow_of_pos hp] rw [eLpNorm_const' c hp_ne_zero hp_ne_top] obtain hμ_top | hμ_ne_top := eq_or_ne (μ .univ) ∞ · simp [hc, hμ_top, hp] rw [ENNReal.mul_lt_top_iff] simpa [hμ, hc, hμ_ne_top, hμ_ne_top.lt_top, hc'.lt_top] using by finiteness theorem eLpNorm_const_lt_top_iff {p : ℝ≥0∞} {c : F} (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : eLpNorm (fun _ : α => c) p μ < ∞ ↔ c = 0 ∨ μ Set.univ < ∞ := by rw [eLpNorm_const_lt_top_iff_enorm enorm_ne_top hp_ne_zero hp_ne_top]; simp theorem memLp_const_enorm {c : ε'} (hc : ‖c‖ₑ ≠ ⊤) [IsFiniteMeasure μ] : MemLp (fun _ : α ↦ c) p μ := by refine ⟨aestronglyMeasurable_const, ?_⟩ by_cases h0 : p = 0 · simp [h0] by_cases hμ : μ = 0 · simp [hμ] rw [eLpNorm_const c h0 hμ] finiteness theorem memLp_const (c : E) [IsFiniteMeasure μ] : MemLp (fun _ : α => c) p μ := memLp_const_enorm enorm_ne_top theorem memLp_top_const_enorm {c : ε'} (hc : ‖c‖ₑ ≠ ⊤) : MemLp (fun _ : α ↦ c) ∞ μ := ⟨aestronglyMeasurable_const, by by_cases h : μ = 0 <;> simp [eLpNorm_const _, h, hc.lt_top]⟩ theorem memLp_top_const (c : E) : MemLp (fun _ : α => c) ∞ μ := memLp_top_const_enorm enorm_ne_top theorem memLp_const_iff_enorm {p : ℝ≥0∞} {c : ε''} (hc : ‖c‖ₑ ≠ ⊤) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp (fun _ : α ↦ c) p μ ↔ ‖c‖ₑ = 0 ∨ μ Set.univ < ∞ := by simp_all [MemLp, aestronglyMeasurable_const, eLpNorm_const_lt_top_iff_enorm hc hp_ne_zero hp_ne_top] theorem memLp_const_iff {p : ℝ≥0∞} {c : E} (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : MemLp (fun _ : α => c) p μ ↔ c = 0 ∨ μ Set.univ < ∞ := by rw [memLp_const_iff_enorm enorm_ne_top hp_ne_zero hp_ne_top]; simp end Const variable {f : α → F} lemma eLpNorm'_mono_enorm_ae {f : α → ε} {g : α → ε'} (hq : 0 ≤ q) (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖g x‖ₑ) : eLpNorm' f q μ ≤ eLpNorm' g q μ := by simp only [eLpNorm'_eq_lintegral_enorm] gcongr ?_ ^ (1/q) refine lintegral_mono_ae (h.mono fun x hx => ?_) gcongr lemma eLpNorm'_mono_nnnorm_ae {f : α → F} {g : α → G} (hq : 0 ≤ q) (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ ‖g x‖₊) : eLpNorm' f q μ ≤ eLpNorm' g q μ := by simp only [eLpNorm'_eq_lintegral_enorm] gcongr ?_ ^ (1/q) refine lintegral_mono_ae (h.mono fun x hx => ?_) dsimp [enorm] gcongr theorem eLpNorm'_mono_ae {f : α → F} {g : α → G} (hq : 0 ≤ q) (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) : eLpNorm' f q μ ≤ eLpNorm' g q μ := eLpNorm'_mono_enorm_ae hq (by simpa only [enorm_le_iff_norm_le] using h) theorem eLpNorm'_congr_enorm_ae {f g : α → ε} (hfg : ∀ᵐ x ∂μ, ‖f x‖ₑ = ‖g x‖ₑ) : eLpNorm' f q μ = eLpNorm' g q μ := by have : (‖f ·‖ₑ ^ q) =ᵐ[μ] (‖g ·‖ₑ ^ q) := hfg.mono fun x hx ↦ by simp [hx] simp only [eLpNorm'_eq_lintegral_enorm, lintegral_congr_ae this] theorem eLpNorm'_congr_nnnorm_ae {f g : α → F} (hfg : ∀ᵐ x ∂μ, ‖f x‖₊ = ‖g x‖₊) : eLpNorm' f q μ = eLpNorm' g q μ := by have : (‖f ·‖ₑ ^ q) =ᵐ[μ] (‖g ·‖ₑ ^ q) := hfg.mono fun x hx ↦ by simp [enorm, hx] simp only [eLpNorm'_eq_lintegral_enorm, lintegral_congr_ae this] theorem eLpNorm'_congr_norm_ae {f g : α → F} (hfg : ∀ᵐ x ∂μ, ‖f x‖ = ‖g x‖) : eLpNorm' f q μ = eLpNorm' g q μ := eLpNorm'_congr_nnnorm_ae <| hfg.mono fun _x hx => NNReal.eq hx theorem eLpNorm'_congr_ae {f g : α → ε} (hfg : f =ᵐ[μ] g) : eLpNorm' f q μ = eLpNorm' g q μ := eLpNorm'_congr_enorm_ae (hfg.fun_comp _) theorem eLpNormEssSup_congr_ae {f g : α → ε} (hfg : f =ᵐ[μ] g) : eLpNormEssSup f μ = eLpNormEssSup g μ := essSup_congr_ae (hfg.fun_comp enorm) theorem eLpNormEssSup_mono_enorm_ae {f g : α → ε} (hfg : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖g x‖ₑ) : eLpNormEssSup f μ ≤ eLpNormEssSup g μ := essSup_mono_ae <| hfg theorem eLpNormEssSup_mono_nnnorm_ae {f g : α → F} (hfg : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ ‖g x‖₊) : eLpNormEssSup f μ ≤ eLpNormEssSup g μ := essSup_mono_ae <| hfg.mono fun _x hx => ENNReal.coe_le_coe.mpr hx theorem eLpNorm_mono_enorm_ae {f : α → ε} {g : α → ε'} (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖g x‖ₑ) : eLpNorm f p μ ≤ eLpNorm g p μ := by simp only [eLpNorm] split_ifs · exact le_rfl · exact essSup_mono_ae h · exact eLpNorm'_mono_enorm_ae ENNReal.toReal_nonneg h theorem eLpNorm_mono_nnnorm_ae {f : α → F} {g : α → G} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ ‖g x‖₊) : eLpNorm f p μ ≤ eLpNorm g p μ := by simp only [eLpNorm] split_ifs · exact le_rfl · exact essSup_mono_ae (h.mono fun x hx => ENNReal.coe_le_coe.mpr hx) · exact eLpNorm'_mono_nnnorm_ae ENNReal.toReal_nonneg h theorem eLpNorm_mono_ae {f : α → F} {g : α → G} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) : eLpNorm f p μ ≤ eLpNorm g p μ := eLpNorm_mono_enorm_ae (by simpa only [enorm_le_iff_norm_le] using h) theorem eLpNorm_mono_ae' {ε' : Type*} [ENorm ε'] {f : α → ε} {g : α → ε'} (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖g x‖ₑ) : eLpNorm f p μ ≤ eLpNorm g p μ := eLpNorm_mono_enorm_ae (by simpa only [enorm_le_iff_norm_le] using h) theorem eLpNorm_mono_ae_real {f : α → F} {g : α → ℝ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ g x) : eLpNorm f p μ ≤ eLpNorm g p μ := eLpNorm_mono_ae <| h.mono fun _x hx => hx.trans ((le_abs_self _).trans (Real.norm_eq_abs _).symm.le) theorem eLpNorm_mono_enorm {f : α → ε} {g : α → ε'} (h : ∀ x, ‖f x‖ₑ ≤ ‖g x‖ₑ) : eLpNorm f p μ ≤ eLpNorm g p μ := eLpNorm_mono_enorm_ae (Eventually.of_forall h) theorem eLpNorm_mono_nnnorm {f : α → F} {g : α → G} (h : ∀ x, ‖f x‖₊ ≤ ‖g x‖₊) : eLpNorm f p μ ≤ eLpNorm g p μ := eLpNorm_mono_nnnorm_ae (Eventually.of_forall h) theorem eLpNorm_mono {f : α → F} {g : α → G} (h : ∀ x, ‖f x‖ ≤ ‖g x‖) : eLpNorm f p μ ≤ eLpNorm g p μ := eLpNorm_mono_ae (Eventually.of_forall h) theorem eLpNorm_mono_real {f : α → F} {g : α → ℝ} (h : ∀ x, ‖f x‖ ≤ g x) : eLpNorm f p μ ≤ eLpNorm g p μ := eLpNorm_mono_ae_real (Eventually.of_forall h) theorem eLpNormEssSup_le_of_ae_enorm_bound {f : α → ε} {C : ℝ≥0∞} (hfC : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ C) : eLpNormEssSup f μ ≤ C := essSup_le_of_ae_le C hfC theorem eLpNormEssSup_le_of_ae_nnnorm_bound {f : α → F} {C : ℝ≥0} (hfC : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ C) : eLpNormEssSup f μ ≤ C := essSup_le_of_ae_le (C : ℝ≥0∞) <| hfC.mono fun _x hx => ENNReal.coe_le_coe.mpr hx theorem eLpNormEssSup_le_of_ae_bound {f : α → F} {C : ℝ} (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : eLpNormEssSup f μ ≤ ENNReal.ofReal C := eLpNormEssSup_le_of_ae_nnnorm_bound <| hfC.mono fun _x hx => hx.trans C.le_coe_toNNReal theorem eLpNormEssSup_lt_top_of_ae_enorm_bound {f : α → ε} {C : ℝ≥0} (hfC : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ C) : eLpNormEssSup f μ < ∞ := (eLpNormEssSup_le_of_ae_enorm_bound hfC).trans_lt ENNReal.coe_lt_top theorem eLpNormEssSup_lt_top_of_ae_nnnorm_bound {f : α → F} {C : ℝ≥0} (hfC : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ C) : eLpNormEssSup f μ < ∞ := (eLpNormEssSup_le_of_ae_nnnorm_bound hfC).trans_lt ENNReal.coe_lt_top theorem eLpNormEssSup_lt_top_of_ae_bound {f : α → F} {C : ℝ} (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : eLpNormEssSup f μ < ∞ := (eLpNormEssSup_le_of_ae_bound hfC).trans_lt ENNReal.ofReal_lt_top theorem eLpNorm_le_of_ae_enorm_bound {ε} [TopologicalSpace ε] [ESeminormedAddMonoid ε] {f : α → ε} {C : ℝ≥0∞} (hfC : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ C) : eLpNorm f p μ ≤ C • μ Set.univ ^ p.toReal⁻¹ := by rcases eq_zero_or_neZero μ with rfl | hμ · simp by_cases hp : p = 0 · simp [hp] have : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖C‖ₑ := hfC.mono fun x hx ↦ hx.trans (Preorder.le_refl C) refine (eLpNorm_mono_enorm_ae this).trans_eq ?_ rw [eLpNorm_const _ hp (NeZero.ne μ), one_div, enorm_eq_self, smul_eq_mul] theorem eLpNorm_le_of_ae_nnnorm_bound {f : α → F} {C : ℝ≥0} (hfC : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ C) : eLpNorm f p μ ≤ C • μ Set.univ ^ p.toReal⁻¹ := by rcases eq_zero_or_neZero μ with rfl | hμ · simp by_cases hp : p = 0 · simp [hp] have : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ ‖(C : ℝ)‖₊ := hfC.mono fun x hx => hx.trans_eq C.nnnorm_eq.symm refine (eLpNorm_mono_ae this).trans_eq ?_ rw [eLpNorm_const _ hp (NeZero.ne μ), C.enorm_eq, one_div, ENNReal.smul_def, smul_eq_mul] theorem eLpNorm_le_of_ae_bound {f : α → F} {C : ℝ} (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : eLpNorm f p μ ≤ μ Set.univ ^ p.toReal⁻¹ * ENNReal.ofReal C := by rw [← mul_comm] exact eLpNorm_le_of_ae_nnnorm_bound (hfC.mono fun x hx => hx.trans C.le_coe_toNNReal) theorem eLpNorm_congr_enorm_ae {f : α → ε} {g : α → ε'} (hfg : ∀ᵐ x ∂μ, ‖f x‖ₑ = ‖g x‖ₑ) : eLpNorm f p μ = eLpNorm g p μ := le_antisymm (eLpNorm_mono_enorm_ae <| EventuallyEq.le hfg) (eLpNorm_mono_enorm_ae <| (EventuallyEq.symm hfg).le) theorem eLpNorm_congr_nnnorm_ae {f : α → F} {g : α → G} (hfg : ∀ᵐ x ∂μ, ‖f x‖₊ = ‖g x‖₊) : eLpNorm f p μ = eLpNorm g p μ := le_antisymm (eLpNorm_mono_nnnorm_ae <| EventuallyEq.le hfg) (eLpNorm_mono_nnnorm_ae <| (EventuallyEq.symm hfg).le) theorem eLpNorm_congr_norm_ae {f : α → F} {g : α → G} (hfg : ∀ᵐ x ∂μ, ‖f x‖ = ‖g x‖) : eLpNorm f p μ = eLpNorm g p μ := eLpNorm_congr_nnnorm_ae <| hfg.mono fun _x hx => NNReal.eq hx open scoped symmDiff in theorem eLpNorm_indicator_sub_indicator (s t : Set α) (f : α → E) : eLpNorm (s.indicator f - t.indicator f) p μ = eLpNorm ((s ∆ t).indicator f) p μ := eLpNorm_congr_norm_ae <| ae_of_all _ fun x ↦ by simp [Set.apply_indicator_symmDiff norm_neg] @[simp] theorem eLpNorm'_norm {f : α → F} : eLpNorm' (fun a => ‖f a‖) q μ = eLpNorm' f q μ := by simp [eLpNorm'_eq_lintegral_enorm] @[simp] theorem eLpNorm'_enorm {f : α → ε} : eLpNorm' (fun a => ‖f a‖ₑ) q μ = eLpNorm' f q μ := by simp [eLpNorm'_eq_lintegral_enorm] @[simp] theorem eLpNorm_norm (f : α → F) : eLpNorm (fun x => ‖f x‖) p μ = eLpNorm f p μ := eLpNorm_congr_norm_ae <| Eventually.of_forall fun _ => norm_norm _ @[simp] theorem eLpNorm_enorm (f : α → ε) : eLpNorm (fun x ↦ ‖f x‖ₑ) p μ = eLpNorm f p μ := eLpNorm_congr_enorm_ae <| Eventually.of_forall fun _ => enorm_enorm _ theorem eLpNorm'_enorm_rpow (f : α → ε) (p q : ℝ) (hq_pos : 0 < q) : eLpNorm' (‖f ·‖ₑ ^ q) p μ = eLpNorm' f (p * q) μ ^ q := by simp_rw [eLpNorm', ← ENNReal.rpow_mul, ← one_div_mul_one_div, one_div, mul_assoc, inv_mul_cancel₀ hq_pos.ne.symm, mul_one, enorm_eq_self, ← ENNReal.rpow_mul, mul_comm] /-- `f : α → ℝ` and `ENNReal.ofReal ∘ f : α → ℝ≥0∞` have the same `eLpNorm`. Usually, you should not use this lemma (but use enorms everywhere.) -/ lemma eLpNorm_ofReal (f : α → ℝ) (hf : ∀ᵐ x ∂μ, 0 ≤ f x) : eLpNorm (ENNReal.ofReal ∘ f) p μ = eLpNorm f p μ := eLpNorm_congr_enorm_ae <| hf.mono fun _x hx ↦ Real.enorm_ofReal_of_nonneg hx theorem eLpNorm'_norm_rpow (f : α → F) (p q : ℝ) (hq_pos : 0 < q) : eLpNorm' (fun x => ‖f x‖ ^ q) p μ = eLpNorm' f (p * q) μ ^ q := by simp_rw [eLpNorm', ← ENNReal.rpow_mul, ← one_div_mul_one_div, one_div, mul_assoc, inv_mul_cancel₀ hq_pos.ne.symm, mul_one, ← ofReal_norm_eq_enorm, Real.norm_eq_abs, abs_eq_self.mpr (Real.rpow_nonneg (norm_nonneg _) _), mul_comm p, ← ENNReal.ofReal_rpow_of_nonneg (norm_nonneg _) hq_pos.le, ENNReal.rpow_mul] theorem eLpNorm_enorm_rpow (f : α → ε) (hq_pos : 0 < q) : eLpNorm (‖f ·‖ₑ ^ q) p μ = eLpNorm f (p * ENNReal.ofReal q) μ ^ q := by by_cases h0 : p = 0 · simp [h0, ENNReal.zero_rpow_of_pos hq_pos] by_cases hp_top : p = ∞ · simp only [hp_top, eLpNorm_exponent_top, ENNReal.top_mul', hq_pos.not_ge, ENNReal.ofReal_eq_zero, if_false, eLpNorm_exponent_top, eLpNormEssSup_eq_essSup_enorm] have h_rpow : essSup (‖‖f ·‖ₑ ^ q‖ₑ) μ = essSup (‖f ·‖ₑ ^ q) μ := by congr rw [h_rpow] have h_rpow_mono := ENNReal.strictMono_rpow_of_pos hq_pos have h_rpow_surj := (ENNReal.rpow_left_bijective hq_pos.ne.symm).2 let iso := h_rpow_mono.orderIsoOfSurjective _ h_rpow_surj exact (iso.essSup_apply (fun x => ‖f x‖ₑ) μ).symm rw [eLpNorm_eq_eLpNorm' h0 hp_top, eLpNorm_eq_eLpNorm' _ (by finiteness)] swap · refine mul_ne_zero h0 ?_ rwa [Ne, ENNReal.ofReal_eq_zero, not_le] rw [ENNReal.toReal_mul, ENNReal.toReal_ofReal hq_pos.le] exact eLpNorm'_enorm_rpow f p.toReal q hq_pos theorem eLpNorm_norm_rpow (f : α → F) (hq_pos : 0 < q) : eLpNorm (fun x => ‖f x‖ ^ q) p μ = eLpNorm f (p * ENNReal.ofReal q) μ ^ q := by rw [← eLpNorm_enorm_rpow f hq_pos] symm convert eLpNorm_ofReal (fun x ↦ ‖f x‖ ^ q) (by filter_upwards with x using by positivity) rw [Function.comp_apply, ← ofReal_norm_eq_enorm] exact ENNReal.ofReal_rpow_of_nonneg (by positivity) (by positivity) theorem eLpNorm_congr_ae {f g : α → ε} (hfg : f =ᵐ[μ] g) : eLpNorm f p μ = eLpNorm g p μ := eLpNorm_congr_enorm_ae <| hfg.mono fun _x hx => hx ▸ rfl theorem memLp_congr_ae [TopologicalSpace ε] {f g : α → ε} (hfg : f =ᵐ[μ] g) : MemLp f p μ ↔ MemLp g p μ := by simp only [MemLp, eLpNorm_congr_ae hfg, aestronglyMeasurable_congr hfg] theorem MemLp.ae_eq [TopologicalSpace ε] {f g : α → ε} (hfg : f =ᵐ[μ] g) (hf_Lp : MemLp f p μ) : MemLp g p μ := (memLp_congr_ae hfg).1 hf_Lp section ContinuousENorm variable {ε ε' : Type*} [TopologicalSpace ε] [TopologicalSpace ε'] [ContinuousENorm ε] [ContinuousENorm ε'] theorem MemLp.of_le_enorm {f : α → ε} {g : α → ε'} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (hfg : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ ‖g x‖ₑ) : MemLp f p μ := ⟨hf, (eLpNorm_mono_ae' hfg).trans_lt (by finiteness)⟩ theorem MemLp.of_le {f : α → E} {g : α → F} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (hfg : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) : MemLp f p μ := ⟨hf, (eLpNorm_mono_ae hfg).trans_lt (by finiteness)⟩ alias MemLp.mono := MemLp.of_le theorem MemLp.mono'_enorm {f : α → ε} {g : α → ℝ≥0∞} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ ≤ g a) : MemLp f p μ := MemLp.of_le_enorm hg hf <| h.mono fun _x hx ↦ le_trans hx le_rfl theorem MemLp.mono' {f : α → E} {g : α → ℝ} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : MemLp f p μ := hg.of_le hf <| h.mono fun _x hx => le_trans hx (le_abs_self _) theorem MemLp.congr_enorm {f : α → ε} {g : α → ε'} (hf : MemLp f p μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ = ‖g a‖ₑ) : MemLp g p μ := hf.of_le_enorm hg <| EventuallyEq.le <| EventuallyEq.symm h theorem MemLp.congr_norm {f : α → E} {g : α → F} (hf : MemLp f p μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : MemLp g p μ := hf.mono hg <| EventuallyEq.le <| EventuallyEq.symm h theorem memLp_congr_enorm {f : α → ε} {g : α → ε'} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ₑ = ‖g a‖ₑ) : MemLp f p μ ↔ MemLp g p μ := ⟨fun h2f => h2f.congr_enorm hg h, fun h2g => h2g.congr_enorm hf <| EventuallyEq.symm h⟩ theorem memLp_congr_norm {f : α → E} {g : α → F} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : MemLp f p μ ↔ MemLp g p μ := ⟨fun h2f => h2f.congr_norm hg h, fun h2g => h2g.congr_norm hf <| EventuallyEq.symm h⟩ theorem memLp_top_of_bound_enorm {f : α → ε} (hf : AEStronglyMeasurable f μ) (C : ℝ≥0) (hfC : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ C) : MemLp f ∞ μ := ⟨hf, by rw [eLpNorm_exponent_top] exact eLpNormEssSup_lt_top_of_ae_enorm_bound hfC⟩ theorem memLp_top_of_bound {f : α → E} (hf : AEStronglyMeasurable f μ) (C : ℝ) (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : MemLp f ∞ μ := ⟨hf, by rw [eLpNorm_exponent_top] exact eLpNormEssSup_lt_top_of_ae_bound hfC⟩ theorem MemLp.of_enorm_bound [IsFiniteMeasure μ] {f : α → ε} (hf : AEStronglyMeasurable f μ) {C : ℝ≥0∞} (hC : C ≠ ∞) (hfC : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ C) : MemLp f p μ := by apply (memLp_const_enorm hC).of_le_enorm (ε' := ℝ≥0∞) hf <| hfC.mono fun _x hx ↦ ?_ rw [enorm_eq_self]; exact hx theorem MemLp.of_bound [IsFiniteMeasure μ] {f : α → E} (hf : AEStronglyMeasurable f μ) (C : ℝ) (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : MemLp f p μ := (memLp_const C).of_le hf (hfC.mono fun _x hx => le_trans hx (le_abs_self _)) theorem memLp_of_bounded [IsFiniteMeasure μ] {a b : ℝ} {f : α → ℝ} (h : ∀ᵐ x ∂μ, f x ∈ Set.Icc a b) (hX : AEStronglyMeasurable f μ) (p : ENNReal) : MemLp f p μ := have ha : ∀ᵐ x ∂μ, a ≤ f x := h.mono fun ω h => h.1 have hb : ∀ᵐ x ∂μ, f x ≤ b := h.mono fun ω h => h.2 (memLp_const (max |a| |b|)).mono' hX (by filter_upwards [ha, hb] with x using abs_le_max_abs_abs) @[gcongr, mono] theorem eLpNorm'_mono_measure (f : α → ε) (hμν : ν ≤ μ) (hq : 0 ≤ q) : eLpNorm' f q ν ≤ eLpNorm' f q μ := by simp_rw [eLpNorm'] gcongr @[gcongr, mono] theorem eLpNormEssSup_mono_measure (f : α → ε) (hμν : ν ≪ μ) : eLpNormEssSup f ν ≤ eLpNormEssSup f μ := by simp_rw [eLpNormEssSup] exact essSup_mono_measure hμν @[gcongr, mono] theorem eLpNorm_mono_measure (f : α → ε) (hμν : ν ≤ μ) : eLpNorm f p ν ≤ eLpNorm f p μ := by by_cases hp0 : p = 0 · simp [hp0] by_cases hp_top : p = ∞ · simp [hp_top, eLpNormEssSup_mono_measure f (Measure.absolutelyContinuous_of_le hμν)] simp_rw [eLpNorm_eq_eLpNorm' hp0 hp_top] exact eLpNorm'_mono_measure f hμν ENNReal.toReal_nonneg theorem MemLp.mono_measure {f : α → ε} (hμν : ν ≤ μ) (hf : MemLp f p μ) : MemLp f p ν := ⟨hf.1.mono_measure hμν, (eLpNorm_mono_measure f hμν).trans_lt hf.2⟩ end ContinuousENorm section Indicator variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] {c : ε} {hf : AEStronglyMeasurable f μ} {s : Set α} {ε' : Type*} [TopologicalSpace ε'] [ContinuousENorm ε'] lemma eLpNorm_indicator_eq_eLpNorm_restrict {f : α → ε} {s : Set α} (hs : MeasurableSet s) : eLpNorm (s.indicator f) p μ = eLpNorm f p (μ.restrict s) := by by_cases hp_zero : p = 0 · simp only [hp_zero, eLpNorm_exponent_zero] by_cases hp_top : p = ∞ · simp_rw [hp_top, eLpNorm_exponent_top, eLpNormEssSup_eq_essSup_enorm, enorm_indicator_eq_indicator_enorm, ENNReal.essSup_indicator_eq_essSup_restrict hs] simp_rw [eLpNorm_eq_lintegral_rpow_enorm hp_zero hp_top] rw [← lintegral_indicator hs] congr simp_rw [enorm_indicator_eq_indicator_enorm] rw [eq_comm, ← Function.comp_def (fun x : ℝ≥0∞ => x ^ p.toReal), Set.indicator_comp_of_zero, Function.comp_def] simp [ENNReal.toReal_pos hp_zero hp_top] lemma eLpNormEssSup_indicator_eq_eLpNormEssSup_restrict (hs : MeasurableSet s) : eLpNormEssSup (s.indicator f) μ = eLpNormEssSup f (μ.restrict s) := by simp_rw [← eLpNorm_exponent_top, eLpNorm_indicator_eq_eLpNorm_restrict hs] lemma eLpNorm_restrict_le (f : α → ε') (p : ℝ≥0∞) (μ : Measure α) (s : Set α) : eLpNorm f p (μ.restrict s) ≤ eLpNorm f p μ := eLpNorm_mono_measure f Measure.restrict_le_self lemma eLpNorm_indicator_le (f : α → ε) : eLpNorm (s.indicator f) p μ ≤ eLpNorm f p μ := by refine eLpNorm_mono_ae' <| .of_forall fun x ↦ ?_ rw [enorm_indicator_eq_indicator_enorm] exact s.indicator_le_self _ x lemma eLpNormEssSup_indicator_le (s : Set α) (f : α → ε) : eLpNormEssSup (s.indicator f) μ ≤ eLpNormEssSup f μ := by refine essSup_mono_ae (Eventually.of_forall fun x => ?_) simp_rw [enorm_indicator_eq_indicator_enorm] exact Set.indicator_le_self s _ x lemma eLpNormEssSup_indicator_const_le (s : Set α) (c : ε) : eLpNormEssSup (s.indicator fun _ : α => c) μ ≤ ‖c‖ₑ := by by_cases hμ0 : μ = 0 · rw [hμ0, eLpNormEssSup_measure_zero] exact zero_le _ · exact (eLpNormEssSup_indicator_le s fun _ => c).trans (eLpNormEssSup_const c hμ0).le lemma eLpNormEssSup_indicator_const_eq (s : Set α) (c : ε) (hμs : μ s ≠ 0) : eLpNormEssSup (s.indicator fun _ : α => c) μ = ‖c‖ₑ := by refine le_antisymm (eLpNormEssSup_indicator_const_le s c) ?_ by_contra! h have h' := ae_iff.mp (ae_lt_of_essSup_lt h) push_neg at h' refine hμs (measure_mono_null (fun x hx_mem => ?_) h') rw [Set.mem_setOf_eq, Set.indicator_of_mem hx_mem] lemma eLpNorm_indicator_const₀ (hs : NullMeasurableSet s μ) (hp : p ≠ 0) (hp_top : p ≠ ∞) : eLpNorm (s.indicator fun _ => c) p μ = ‖c‖ₑ * μ s ^ (1 / p.toReal) := have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp hp_top calc eLpNorm (s.indicator fun _ => c) p μ = (∫⁻ x, (‖(s.indicator fun _ ↦ c) x‖ₑ ^ p.toReal) ∂μ) ^ (1 / p.toReal) := eLpNorm_eq_lintegral_rpow_enorm hp hp_top _ = (∫⁻ x, (s.indicator fun _ ↦ ‖c‖ₑ ^ p.toReal) x ∂μ) ^ (1 / p.toReal) := by congr 2 refine (Set.comp_indicator_const c (fun x ↦ (‖x‖ₑ) ^ p.toReal) ?_) simp [hp_pos] _ = ‖c‖ₑ * μ s ^ (1 / p.toReal) := by rw [lintegral_indicator_const₀ hs, ENNReal.mul_rpow_of_nonneg, ← ENNReal.rpow_mul, mul_one_div_cancel hp_pos.ne', ENNReal.rpow_one] positivity lemma eLpNorm_indicator_const (hs : MeasurableSet s) (hp : p ≠ 0) (hp_top : p ≠ ∞) : eLpNorm (s.indicator fun _ => c) p μ = ‖c‖ₑ * μ s ^ (1 / p.toReal) := eLpNorm_indicator_const₀ hs.nullMeasurableSet hp hp_top lemma eLpNorm_indicator_const' (hs : MeasurableSet s) (hμs : μ s ≠ 0) (hp : p ≠ 0) : eLpNorm (s.indicator fun _ => c) p μ = ‖c‖ₑ * μ s ^ (1 / p.toReal) := by by_cases hp_top : p = ∞ · simp [hp_top, eLpNormEssSup_indicator_const_eq s c hμs] · exact eLpNorm_indicator_const hs hp hp_top variable (c) in lemma eLpNorm_indicator_const_le (p : ℝ≥0∞) : eLpNorm (s.indicator fun _ => c) p μ ≤ ‖c‖ₑ * μ s ^ (1 / p.toReal) := by obtain rfl | hp := eq_or_ne p 0 · simp only [eLpNorm_exponent_zero, zero_le'] obtain rfl | h'p := eq_or_ne p ∞ · simp only [eLpNorm_exponent_top, ENNReal.toReal_top, _root_.div_zero, ENNReal.rpow_zero, mul_one] exact eLpNormEssSup_indicator_const_le _ _ let t := toMeasurable μ s calc eLpNorm (s.indicator fun _ => c) p μ ≤ eLpNorm (t.indicator fun _ ↦ c) p μ := eLpNorm_mono_enorm (enorm_indicator_le_of_subset (subset_toMeasurable _ _) _) _ = ‖c‖ₑ * μ t ^ (1 / p.toReal) := eLpNorm_indicator_const (measurableSet_toMeasurable ..) hp h'p _ = ‖c‖ₑ * μ s ^ (1 / p.toReal) := by rw [measure_toMeasurable] lemma MemLp.indicator {f : α → ε} (hs : MeasurableSet s) (hf : MemLp f p μ) : MemLp (s.indicator f) p μ := ⟨hf.aestronglyMeasurable.indicator hs, lt_of_le_of_lt (eLpNorm_indicator_le f) (by finiteness)⟩ lemma memLp_indicator_iff_restrict {f : α → ε} (hs : MeasurableSet s) : MemLp (s.indicator f) p μ ↔ MemLp f p (μ.restrict s) := by simp [MemLp, aestronglyMeasurable_indicator_iff hs, eLpNorm_indicator_eq_eLpNorm_restrict hs] lemma memLp_indicator_const (p : ℝ≥0∞) (hs : MeasurableSet s) (c : E) (hμsc : c = 0 ∨ μ s ≠ ∞) : MemLp (s.indicator fun _ => c) p μ := by rw [memLp_indicator_iff_restrict hs] obtain rfl | hμ := hμsc · exact MemLp.zero · have := Fact.mk hμ.lt_top apply memLp_const lemma eLpNormEssSup_piecewise (f g : α → ε) [DecidablePred (· ∈ s)] (hs : MeasurableSet s) : eLpNormEssSup (Set.piecewise s f g) μ = max (eLpNormEssSup f (μ.restrict s)) (eLpNormEssSup g (μ.restrict sᶜ)) := by simp only [eLpNormEssSup, ← ENNReal.essSup_piecewise hs] congr with x by_cases hx : x ∈ s <;> simp [hx] lemma eLpNorm_top_piecewise (f g : α → ε) [DecidablePred (· ∈ s)] (hs : MeasurableSet s) : eLpNorm (Set.piecewise s f g) ∞ μ = max (eLpNorm f ∞ (μ.restrict s)) (eLpNorm g ∞ (μ.restrict sᶜ)) := eLpNormEssSup_piecewise f g hs protected lemma MemLp.piecewise {f : α → ε} [DecidablePred (· ∈ s)] {g} (hs : MeasurableSet s) (hf : MemLp f p (μ.restrict s)) (hg : MemLp g p (μ.restrict sᶜ)) : MemLp (s.piecewise f g) p μ := by by_cases hp_zero : p = 0 · simp only [hp_zero, memLp_zero_iff_aestronglyMeasurable] exact AEStronglyMeasurable.piecewise hs hf.1 hg.1 refine ⟨AEStronglyMeasurable.piecewise hs hf.1 hg.1, ?_⟩ obtain rfl | hp_top := eq_or_ne p ∞ · rw [eLpNorm_top_piecewise f g hs] exact max_lt hf.2 hg.2 rw [eLpNorm_lt_top_iff_lintegral_rpow_enorm_lt_top hp_zero hp_top, ← lintegral_add_compl _ hs, ENNReal.add_lt_top] constructor · have h (x) (hx : x ∈ s) : ‖Set.piecewise s f g x‖ₑ ^ p.toReal = ‖f x‖ₑ ^ p.toReal := by simp [hx] rw [setLIntegral_congr_fun hs h] exact lintegral_rpow_enorm_lt_top_of_eLpNorm_lt_top hp_zero hp_top hf.2 · have h (x) (hx : x ∈ sᶜ) : ‖Set.piecewise s f g x‖ₑ ^ p.toReal = ‖g x‖ₑ ^ p.toReal := by have hx' : x ∉ s := hx simp [hx'] rw [setLIntegral_congr_fun hs.compl h] exact lintegral_rpow_enorm_lt_top_of_eLpNorm_lt_top hp_zero hp_top hg.2 end Indicator section ENormedAddMonoid variable {ε : Type*} [TopologicalSpace ε] [ENormedAddMonoid ε] /-- For a function `f` with support in `s`, the Lᵖ norms of `f` with respect to `μ` and `μ.restrict s` are the same. -/ theorem eLpNorm_restrict_eq_of_support_subset {s : Set α} {f : α → ε} (hsf : f.support ⊆ s) : eLpNorm f p (μ.restrict s) = eLpNorm f p μ := by by_cases hp0 : p = 0 · simp [hp0] by_cases hp_top : p = ∞ · simp only [hp_top, eLpNorm_exponent_top, eLpNormEssSup_eq_essSup_enorm] exact ENNReal.essSup_restrict_eq_of_support_subset fun x hx ↦ hsf <| enorm_ne_zero.1 hx · simp_rw [eLpNorm_eq_eLpNorm' hp0 hp_top, eLpNorm'_eq_lintegral_enorm] congr 1 apply setLIntegral_eq_of_support_subset have : ¬(p.toReal ≤ 0) := by simpa only [not_le] using ENNReal.toReal_pos hp0 hp_top simpa [this] using hsf end ENormedAddMonoid section ContinuousENorm variable {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] theorem MemLp.restrict (s : Set α) {f : α → ε} (hf : MemLp f p μ) : MemLp f p (μ.restrict s) := hf.mono_measure Measure.restrict_le_self theorem eLpNorm'_smul_measure {p : ℝ} (hp : 0 ≤ p) {f : α → ε} (c : ℝ≥0∞) : eLpNorm' f p (c • μ) = c ^ (1 / p) * eLpNorm' f p μ := by simp [eLpNorm', ENNReal.mul_rpow_of_nonneg, hp] end ContinuousENorm section SMul variable {R : Type*} [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] [NoZeroSMulDivisors R ℝ≥0∞] {c : R} @[simp] lemma eLpNormEssSup_smul_measure (hc : c ≠ 0) (f : α → ε) : eLpNormEssSup f (c • μ) = eLpNormEssSup f μ := by simp_rw [eLpNormEssSup] exact essSup_smul_measure hc _ end SMul section ContinuousENorm variable {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] /-- Use `eLpNorm_smul_measure_of_ne_top` instead. -/ private theorem eLpNorm_smul_measure_of_ne_zero_of_ne_top {p : ℝ≥0∞} (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε} (c : ℝ≥0∞) : eLpNorm f p (c • μ) = c ^ (1 / p).toReal • eLpNorm f p μ := by simp_rw [eLpNorm_eq_eLpNorm' hp_ne_zero hp_ne_top] rw [eLpNorm'_smul_measure ENNReal.toReal_nonneg] congr simp_rw [one_div] rw [ENNReal.toReal_inv] /-- See `eLpNorm_smul_measure_of_ne_zero'` for a version with scalar multiplication by `ℝ≥0`. -/ theorem eLpNorm_smul_measure_of_ne_zero {c : ℝ≥0∞} (hc : c ≠ 0) (f : α → ε) (p : ℝ≥0∞) (μ : Measure α) : eLpNorm f p (c • μ) = c ^ (1 / p).toReal • eLpNorm f p μ := by by_cases hp0 : p = 0 · simp [hp0] by_cases hp_top : p = ∞ · simp [hp_top, eLpNormEssSup_smul_measure hc] exact eLpNorm_smul_measure_of_ne_zero_of_ne_top hp0 hp_top c /-- See `eLpNorm_smul_measure_of_ne_zero` for a version with scalar multiplication by `ℝ≥0∞`. -/ lemma eLpNorm_smul_measure_of_ne_zero' {c : ℝ≥0} (hc : c ≠ 0) (f : α → ε) (p : ℝ≥0∞) (μ : Measure α) : eLpNorm f p (c • μ) = c ^ p.toReal⁻¹ • eLpNorm f p μ := (eLpNorm_smul_measure_of_ne_zero (ENNReal.coe_ne_zero.2 hc) ..).trans (by simp; norm_cast) /-- See `eLpNorm_smul_measure_of_ne_top'` for a version with scalar multiplication by `ℝ≥0`. -/ theorem eLpNorm_smul_measure_of_ne_top {p : ℝ≥0∞} (hp_ne_top : p ≠ ∞) (f : α → ε) (c : ℝ≥0∞) : eLpNorm f p (c • μ) = c ^ (1 / p).toReal • eLpNorm f p μ := by by_cases hp0 : p = 0 · simp [hp0] · exact eLpNorm_smul_measure_of_ne_zero_of_ne_top hp0 hp_ne_top c /-- See `eLpNorm_smul_measure_of_ne_top'` for a version with scalar multiplication by `ℝ≥0∞`. -/ lemma eLpNorm_smul_measure_of_ne_top' (hp : p ≠ ∞) (c : ℝ≥0) (f : α → ε) : eLpNorm f p (c • μ) = c ^ p.toReal⁻¹ • eLpNorm f p μ := by have : 0 ≤ p.toReal⁻¹ := by positivity refine (eLpNorm_smul_measure_of_ne_top hp ..).trans ?_ simp [ENNReal.smul_def, ENNReal.coe_rpow_of_nonneg, this] theorem eLpNorm_one_smul_measure {f : α → ε} (c : ℝ≥0∞) : eLpNorm f 1 (c • μ) = c * eLpNorm f 1 μ := by rw [eLpNorm_smul_measure_of_ne_top] <;> simp theorem MemLp.of_measure_le_smul {μ' : Measure α} {c : ℝ≥0∞} (hc : c ≠ ∞) (hμ'_le : μ' ≤ c • μ) {f : α → ε} (hf : MemLp f p μ) : MemLp f p μ' := by refine ⟨hf.1.mono_ac (Measure.absolutelyContinuous_of_le_smul hμ'_le), ?_⟩ refine (eLpNorm_mono_measure f hμ'_le).trans_lt ?_ by_cases hc0 : c = 0 · simp [hc0] rw [eLpNorm_smul_measure_of_ne_zero hc0, smul_eq_mul] refine ENNReal.mul_lt_top (Ne.lt_top ?_) hf.2 simp [hc, hc0] theorem MemLp.smul_measure {f : α → ε} {c : ℝ≥0∞} (hf : MemLp f p μ) (hc : c ≠ ∞) : MemLp f p (c • μ) := hf.of_measure_le_smul hc le_rfl variable {ε : Type*} [ENorm ε] in theorem eLpNorm_one_add_measure (f : α → ε) (μ ν : Measure α) : eLpNorm f 1 (μ + ν) = eLpNorm f 1 μ + eLpNorm f 1 ν := by simp_rw [eLpNorm_one_eq_lintegral_enorm] rw [lintegral_add_measure _ μ ν] theorem eLpNorm_le_add_measure_right (f : α → ε) (μ ν : Measure α) {p : ℝ≥0∞} : eLpNorm f p μ ≤ eLpNorm f p (μ + ν) := eLpNorm_mono_measure f <| Measure.le_add_right <| le_refl _ theorem eLpNorm_le_add_measure_left (f : α → ε) (μ ν : Measure α) {p : ℝ≥0∞} : eLpNorm f p ν ≤ eLpNorm f p (μ + ν) := eLpNorm_mono_measure f <| Measure.le_add_left <| le_refl _ variable {ε : Type*} [ENorm ε] in lemma eLpNormEssSup_eq_iSup (hμ : ∀ a, μ {a} ≠ 0) (f : α → ε) : eLpNormEssSup f μ = ⨆ a, ‖f a‖ₑ := essSup_eq_iSup hμ _ variable {ε : Type*} [ENorm ε] in @[simp] lemma eLpNormEssSup_count [MeasurableSingletonClass α] (f : α → ε) : eLpNormEssSup f .count = ⨆ a, ‖f a‖ₑ := essSup_count _ theorem MemLp.left_of_add_measure {f : α → ε} (h : MemLp f p (μ + ν)) : MemLp f p μ := h.mono_measure <| Measure.le_add_right <| le_refl _ theorem MemLp.right_of_add_measure {f : α → ε} (h : MemLp f p (μ + ν)) : MemLp f p ν := h.mono_measure <| Measure.le_add_left <| le_refl _ theorem MemLp.enorm {f : α → ε} (h : MemLp f p μ) : MemLp (‖f ·‖ₑ) p μ := ⟨h.aestronglyMeasurable.enorm.aestronglyMeasurable, by simp_rw [MeasureTheory.eLpNorm_enorm, h.eLpNorm_lt_top]⟩ theorem MemLp.norm {f : α → E} (h : MemLp f p μ) : MemLp (fun x => ‖f x‖) p μ := h.of_le h.aestronglyMeasurable.norm (Eventually.of_forall fun x => by simp) theorem memLp_enorm_iff {f : α → ε} (hf : AEStronglyMeasurable f μ) : MemLp (‖f ·‖ₑ) p μ ↔ MemLp f p μ := ⟨fun h => ⟨hf, by rw [← eLpNorm_enorm]; exact h.2⟩, fun h => h.enorm⟩ theorem memLp_norm_iff {f : α → E} (hf : AEStronglyMeasurable f μ) : MemLp (fun x => ‖f x‖) p μ ↔ MemLp f p μ := ⟨fun h => ⟨hf, by rw [← eLpNorm_norm]; exact h.2⟩, fun h => h.norm⟩ end ContinuousENorm section ESeminormedAddMonoid variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] theorem eLpNorm'_eq_zero_of_ae_zero {f : α → ε} (hq0_lt : 0 < q) (hf_zero : f =ᵐ[μ] 0) : eLpNorm' f q μ = 0 := by rw [eLpNorm'_congr_ae hf_zero, eLpNorm'_zero hq0_lt] theorem eLpNorm'_eq_zero_of_ae_zero' (hq0_ne : q ≠ 0) (hμ : μ ≠ 0) {f : α → ε} (hf_zero : f =ᵐ[μ] 0) : eLpNorm' f q μ = 0 := by rw [eLpNorm'_congr_ae hf_zero, eLpNorm'_zero' hq0_ne hμ] theorem eLpNorm_eq_zero_of_ae_zero {f : α → ε} (hf : f =ᵐ[μ] 0) : eLpNorm f p μ = 0 := by rw [← eLpNorm_zero (p := p) (μ := μ) (α := α) (ε := ε)] exact eLpNorm_congr_ae hf theorem eLpNorm'_eq_zero_of_ae_eq_zero {f : α → ε} {p : ℝ} (hp : 0 < p) (hf : ∀ᵐ (x : α) ∂μ, ‖f x‖ₑ = 0) : eLpNorm' f p μ = 0 := by rw [← eLpNorm'_zero hp (μ := μ) (ε := ε), eLpNorm'_congr_enorm_ae] simp only [hf, Pi.zero_apply, enorm_zero] variable {ε : Type*} [ENorm ε] in theorem ae_le_eLpNormEssSup {f : α → ε} : ∀ᵐ y ∂μ, ‖f y‖ₑ ≤ eLpNormEssSup f μ := ae_le_essSup -- NB. Changing this lemma to use ‖‖ₑ makes it false (only => still holds); -- unlike a nnnorm, the enorm can be ∞. lemma eLpNormEssSup_lt_top_iff_isBoundedUnder : eLpNormEssSup f μ < ⊤ ↔ IsBoundedUnder (· ≤ ·) (ae μ) fun x ↦ ‖f x‖₊ where mp h := ⟨(eLpNormEssSup f μ).toNNReal, by simp_rw [← ENNReal.coe_le_coe, ENNReal.coe_toNNReal h.ne]; exact ae_le_eLpNormEssSup⟩ mpr := by rintro ⟨C, hC⟩; exact eLpNormEssSup_lt_top_of_ae_nnnorm_bound (C := C) hC variable {ε : Type*} [ENorm ε] in theorem meas_eLpNormEssSup_lt {f : α → ε} : μ { y | eLpNormEssSup f μ < ‖f y‖ₑ } = 0 := meas_essSup_lt lemma eLpNorm_lt_top_of_finite [Finite α] [IsFiniteMeasure μ] : eLpNorm f p μ < ∞ := by obtain rfl | hp₀ := eq_or_ne p 0 · simp obtain rfl | hp := eq_or_ne p ∞ · simp only [eLpNorm_exponent_top, eLpNormEssSup_lt_top_iff_isBoundedUnder] exact .le_of_finite rw [eLpNorm_lt_top_iff_lintegral_rpow_enorm_lt_top hp₀ hp] refine IsFiniteMeasure.lintegral_lt_top_of_bounded_to_ennreal μ ?_ simp_rw [enorm, ← ENNReal.coe_rpow_of_nonneg _ ENNReal.toReal_nonneg] norm_cast exact Finite.exists_le _ @[simp] lemma MemLp.of_discrete [DiscreteMeasurableSpace α] [Finite α] [IsFiniteMeasure μ] : MemLp f p μ := let ⟨C, hC⟩ := Finite.exists_le (‖f ·‖₊); .of_bound .of_discrete C <| .of_forall hC @[simp] lemma eLpNorm_of_isEmpty [IsEmpty α] (f : α → ε) (p : ℝ≥0∞) : eLpNorm f p μ = 0 := by simp [Subsingleton.elim f 0] end ESeminormedAddMonoid section ENormedAddMonoid variable {ε : Type*} [TopologicalSpace ε] [ENormedAddMonoid ε] theorem ae_eq_zero_of_eLpNorm'_eq_zero {f : α → ε} (hq0 : 0 ≤ q) (hf : AEStronglyMeasurable f μ) (h : eLpNorm' f q μ = 0) : f =ᵐ[μ] 0 := by simp only [eLpNorm'_eq_lintegral_enorm, lintegral_eq_zero_iff' (hf.enorm.pow_const q), one_div, ENNReal.rpow_eq_zero_iff, inv_pos, inv_neg'', hq0.not_gt, and_false, or_false] at h refine h.left.mono fun x hx ↦ ?_ simp only [Pi.ofNat_apply, ENNReal.rpow_eq_zero_iff, enorm_eq_zero, h.2.not_gt, and_false, or_false] at hx simp [hx.1] theorem eLpNorm'_eq_zero_iff (hq0_lt : 0 < q) {f : α → ε} (hf : AEStronglyMeasurable f μ) : eLpNorm' f q μ = 0 ↔ f =ᵐ[μ] 0 := ⟨ae_eq_zero_of_eLpNorm'_eq_zero (le_of_lt hq0_lt) hf, eLpNorm'_eq_zero_of_ae_zero hq0_lt⟩ variable {ε : Type*} [ENorm ε] in theorem enorm_ae_le_eLpNormEssSup {_ : MeasurableSpace α} (f : α → ε) (μ : Measure α) : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ eLpNormEssSup f μ := ENNReal.ae_le_essSup fun x => ‖f x‖ₑ @[simp] theorem eLpNormEssSup_eq_zero_iff {f : α → ε} : eLpNormEssSup f μ = 0 ↔ f =ᵐ[μ] 0 := by simp [EventuallyEq, eLpNormEssSup_eq_essSup_enorm] theorem eLpNorm_eq_zero_iff {f : α → ε} (hf : AEStronglyMeasurable f μ) (h0 : p ≠ 0) : eLpNorm f p μ = 0 ↔ f =ᵐ[μ] 0 := by by_cases h_top : p = ∞ · rw [h_top, eLpNorm_exponent_top, eLpNormEssSup_eq_zero_iff] rw [eLpNorm_eq_eLpNorm' h0 h_top] exact eLpNorm'_eq_zero_iff (ENNReal.toReal_pos h0 h_top) hf end ENormedAddMonoid section MapMeasure variable {ε : Type*} [TopologicalSpace ε] [ContinuousENorm ε] {β : Type*} {mβ : MeasurableSpace β} {f : α → β} {g : β → ε} theorem eLpNormEssSup_map_measure (hg : AEStronglyMeasurable g (Measure.map f μ)) (hf : AEMeasurable f μ) : eLpNormEssSup g (Measure.map f μ) = eLpNormEssSup (g ∘ f) μ := essSup_map_measure hg.enorm hf theorem eLpNorm_map_measure (hg : AEStronglyMeasurable g (Measure.map f μ)) (hf : AEMeasurable f μ) : eLpNorm g p (Measure.map f μ) = eLpNorm (g ∘ f) p μ := by by_cases hp_zero : p = 0 · simp only [hp_zero, eLpNorm_exponent_zero] by_cases hp_top : p = ∞ · simp_rw [hp_top, eLpNorm_exponent_top] exact eLpNormEssSup_map_measure hg hf simp_rw [eLpNorm_eq_lintegral_rpow_enorm hp_zero hp_top, lintegral_map' (hg.enorm.pow_const p.toReal) hf, Function.comp_apply] theorem memLp_map_measure_iff (hg : AEStronglyMeasurable g (Measure.map f μ)) (hf : AEMeasurable f μ) : MemLp g p (Measure.map f μ) ↔ MemLp (g ∘ f) p μ := by simp [MemLp, eLpNorm_map_measure hg hf, hg.comp_aemeasurable hf, hg] theorem MemLp.comp_of_map (hg : MemLp g p (Measure.map f μ)) (hf : AEMeasurable f μ) : MemLp (g ∘ f) p μ := (memLp_map_measure_iff hg.aestronglyMeasurable hf).1 hg theorem eLpNorm_comp_measurePreserving {ν : MeasureTheory.Measure β} (hg : AEStronglyMeasurable g ν) (hf : MeasurePreserving f μ ν) : eLpNorm (g ∘ f) p μ = eLpNorm g p ν := Eq.symm <| hf.map_eq ▸ eLpNorm_map_measure (hf.map_eq ▸ hg) hf.aemeasurable theorem AEEqFun.eLpNorm_compMeasurePreserving {ν : MeasureTheory.Measure β} (g : β →ₘ[ν] E) (hf : MeasurePreserving f μ ν) : eLpNorm (g.compMeasurePreserving f hf) p μ = eLpNorm g p ν := by rw [eLpNorm_congr_ae (g.coeFn_compMeasurePreserving _)] exact eLpNorm_comp_measurePreserving g.aestronglyMeasurable hf theorem MemLp.comp_measurePreserving {ν : MeasureTheory.Measure β} (hg : MemLp g p ν) (hf : MeasurePreserving f μ ν) : MemLp (g ∘ f) p μ := .comp_of_map (hf.map_eq.symm ▸ hg) hf.aemeasurable theorem _root_.MeasurableEmbedding.eLpNormEssSup_map_measure (hf : MeasurableEmbedding f) : eLpNormEssSup g (Measure.map f μ) = eLpNormEssSup (g ∘ f) μ := hf.essSup_map_measure theorem _root_.MeasurableEmbedding.eLpNorm_map_measure (hf : MeasurableEmbedding f) : eLpNorm g p (Measure.map f μ) = eLpNorm (g ∘ f) p μ := by by_cases hp_zero : p = 0 · simp only [hp_zero, eLpNorm_exponent_zero] by_cases hp : p = ∞ · simp_rw [hp, eLpNorm_exponent_top] exact hf.essSup_map_measure · simp_rw [eLpNorm_eq_lintegral_rpow_enorm hp_zero hp, hf.lintegral_map, Function.comp_apply] theorem _root_.MeasurableEmbedding.memLp_map_measure_iff (hf : MeasurableEmbedding f) : MemLp g p (Measure.map f μ) ↔ MemLp (g ∘ f) p μ := by simp_rw [MemLp, hf.aestronglyMeasurable_map_iff, hf.eLpNorm_map_measure] theorem _root_.MeasurableEquiv.memLp_map_measure_iff (f : α ≃ᵐ β) : MemLp g p (Measure.map f μ) ↔ MemLp (g ∘ f) p μ := f.measurableEmbedding.memLp_map_measure_iff end MapMeasure section Monotonicity variable {ε ε' : Type*} [TopologicalSpace ε] [ContinuousENorm ε] [TopologicalSpace ε'] [ContinuousENorm ε'] theorem eLpNorm'_le_nnreal_smul_eLpNorm'_of_ae_le_mul {f : α → F} {g : α → G} {c : ℝ≥0} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) {p : ℝ} (hp : 0 < p) : eLpNorm' f p μ ≤ c • eLpNorm' g p μ := by simp_rw [eLpNorm'_eq_lintegral_enorm] rw [← ENNReal.rpow_le_rpow_iff hp, ENNReal.smul_def, smul_eq_mul, ENNReal.mul_rpow_of_nonneg _ _ hp.le] simp_rw [← ENNReal.rpow_mul, one_div, inv_mul_cancel₀ hp.ne.symm, ENNReal.rpow_one, enorm, ← ENNReal.coe_rpow_of_nonneg _ hp.le, ← lintegral_const_mul' _ _ ENNReal.coe_ne_top, ← ENNReal.coe_mul] apply lintegral_mono_ae simp_rw [ENNReal.coe_le_coe, ← NNReal.mul_rpow, NNReal.rpow_le_rpow_iff hp] exact h -- TODO: eventually, deprecate and remove the nnnorm version theorem eLpNorm'_le_nnreal_smul_eLpNorm'_of_ae_le_mul' {f : α → ε} {g : α → ε'} {c : ℝ≥0} (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) {p : ℝ} (hp : 0 < p) : eLpNorm' f p μ ≤ c • eLpNorm' g p μ := by simp_rw [eLpNorm'_eq_lintegral_enorm] rw [← ENNReal.rpow_le_rpow_iff hp, ENNReal.smul_def, smul_eq_mul, ENNReal.mul_rpow_of_nonneg _ _ hp.le] simp_rw [← ENNReal.rpow_mul, one_div, inv_mul_cancel₀ hp.ne', ENNReal.rpow_one, ← ENNReal.coe_rpow_of_nonneg _ hp.le, ← lintegral_const_mul' _ _ ENNReal.coe_ne_top] apply lintegral_mono_ae have aux (x) : (↑c) ^ p * ‖g x‖ₑ ^ p = (↑c * ‖g x‖ₑ) ^ p := by have : ¬(p < 0) := by linarith simp [ENNReal.mul_rpow_eq_ite, this] simpa [ENNReal.coe_rpow_of_nonneg _ hp.le, aux, ENNReal.rpow_le_rpow_iff hp] section ESeminormedAddMonoid variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] /-- If `‖f x‖ₑ ≤ c * ‖g x‖ₑ` a.e., `eLpNorm' f p μ ≤ c * eLpNorm' g p μ` for all `p ∈ (0, ∞)`. -/ theorem eLpNorm'_le_mul_eLpNorm'_of_ae_le_mul {f : α → ε} {c : ℝ≥0∞} {g : α → ε'} {p : ℝ} (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) (hp : 0 < p) : eLpNorm' f p μ ≤ c * eLpNorm' g p μ := by have hp' : ¬(p < 0) := by linarith by_cases hc : c = ⊤ · by_cases hg' : eLpNorm' g p μ = 0 · have : ∀ᵐ (x : α) ∂μ, ‖g x‖ₑ = 0 := by simp [eLpNorm'_eq_lintegral_enorm, hp', hp] at hg' rw [MeasureTheory.lintegral_eq_zero_iff' (by fun_prop)] at hg' exact hg'.mono fun x hx ↦ by simpa [hp, hp'] using hx have : ∀ᵐ (x : α) ∂μ, ‖f x‖ₑ = 0 := (this.and h).mono fun x ⟨h, h'⟩ ↦ by simp_all simpa only [hg', mul_zero, nonpos_iff_eq_zero] using eLpNorm'_eq_zero_of_ae_eq_zero hp this · simp_all have : c ^ p ≠ ⊤ := by simp [hp.le, hc] simp_rw [eLpNorm'_eq_lintegral_enorm] rw [← ENNReal.rpow_le_rpow_iff hp, ENNReal.mul_rpow_of_nonneg _ _ hp.le] simp_rw [← ENNReal.rpow_mul, one_div, inv_mul_cancel₀ hp.ne', ENNReal.rpow_one, ← lintegral_const_mul' _ _ this] apply lintegral_mono_ae have aux (x) : (↑c) ^ p * ‖g x‖ₑ ^ p = (↑c * ‖g x‖ₑ) ^ p := by simp [ENNReal.mul_rpow_eq_ite, hp'] simpa [ENNReal.coe_rpow_of_nonneg _ hp.le, aux, ENNReal.rpow_le_rpow_iff hp] end ESeminormedAddMonoid -- TODO: eventually, deprecate and remove the nnnorm version theorem eLpNormEssSup_le_nnreal_smul_eLpNormEssSup_of_ae_le_mul' {f : α → ε} {g : α → ε'} {c : ℝ≥0∞} (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) : eLpNormEssSup f μ ≤ c • eLpNormEssSup g μ := calc essSup (‖f ·‖ₑ) μ ≤ essSup (c * ‖g ·‖ₑ) μ := essSup_mono_ae <| h _ = c • essSup (‖g ·‖ₑ) μ := ENNReal.essSup_const_mul theorem eLpNormEssSup_le_nnreal_smul_eLpNormEssSup_of_ae_le_mul {f : α → F} {g : α → G} {c : ℝ≥0} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) : eLpNormEssSup f μ ≤ c • eLpNormEssSup g μ := calc essSup (‖f ·‖ₑ) μ ≤ essSup (fun x => (↑(c * ‖g x‖₊) : ℝ≥0∞)) μ := essSup_mono_ae <| h.mono fun _ hx => ENNReal.coe_le_coe.mpr hx _ = essSup (c * ‖g ·‖ₑ) μ := by simp_rw [ENNReal.coe_mul, enorm] _ = c • essSup (‖g ·‖ₑ) μ := ENNReal.essSup_const_mul -- TODO: eventually, deprecate and remove the nnnorm version theorem eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul' {f : α → ε} {g : α → ε'} {c : ℝ≥0} (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) (p : ℝ≥0∞) : eLpNorm f p μ ≤ c • eLpNorm g p μ := by by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · rw [h_top] exact eLpNormEssSup_le_nnreal_smul_eLpNormEssSup_of_ae_le_mul' h simp_rw [eLpNorm_eq_eLpNorm' h0 h_top] exact eLpNorm'_le_nnreal_smul_eLpNorm'_of_ae_le_mul' h (ENNReal.toReal_pos h0 h_top) theorem eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul {f : α → F} {g : α → G} {c : ℝ≥0} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) (p : ℝ≥0∞) : eLpNorm f p μ ≤ c • eLpNorm g p μ := by by_cases h0 : p = 0 · simp [h0] by_cases h_top : p = ∞ · rw [h_top] exact eLpNormEssSup_le_nnreal_smul_eLpNormEssSup_of_ae_le_mul h simp_rw [eLpNorm_eq_eLpNorm' h0 h_top] exact eLpNorm'_le_nnreal_smul_eLpNorm'_of_ae_le_mul h (ENNReal.toReal_pos h0 h_top) -- TODO: add the whole family of lemmas? private theorem le_mul_iff_eq_zero_of_nonneg_of_neg_of_nonneg {α} [Semiring α] [LinearOrder α] [IsStrictOrderedRing α] {a b c : α} (ha : 0 ≤ a) (hb : b < 0) (hc : 0 ≤ c) : a ≤ b * c ↔ a = 0 ∧ c = 0 := by constructor · intro h exact ⟨(h.trans (mul_nonpos_of_nonpos_of_nonneg hb.le hc)).antisymm ha, (nonpos_of_mul_nonneg_right (ha.trans h) hb).antisymm hc⟩ · rintro ⟨rfl, rfl⟩ rw [mul_zero] /-- When `c` is negative, `‖f x‖ ≤ c * ‖g x‖` is nonsense and forces both `f` and `g` to have an `eLpNorm` of `0`. -/ theorem eLpNorm_eq_zero_and_zero_of_ae_le_mul_neg {f : α → F} {g : α → G} {c : ℝ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ c * ‖g x‖) (hc : c < 0) (p : ℝ≥0∞) : eLpNorm f p μ = 0 ∧ eLpNorm g p μ = 0 := by simp_rw [le_mul_iff_eq_zero_of_nonneg_of_neg_of_nonneg (norm_nonneg _) hc (norm_nonneg _), norm_eq_zero, eventually_and] at h change f =ᵐ[μ] 0 ∧ g =ᵐ[μ] 0 at h simp [eLpNorm_congr_ae h.1, eLpNorm_congr_ae h.2] theorem eLpNorm_le_mul_eLpNorm_of_ae_le_mul {f : α → F} {g : α → G} {c : ℝ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ c * ‖g x‖) (p : ℝ≥0∞) : eLpNorm f p μ ≤ ENNReal.ofReal c * eLpNorm g p μ := eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul (h.mono fun _x hx => hx.trans <| mul_le_mul_of_nonneg_right c.le_coe_toNNReal (norm_nonneg _)) _ -- TODO: eventually, deprecate and remove the nnnorm version /-- If `‖f x‖ₑ ≤ c * ‖g x‖ₑ`, then `eLpNorm f p μ ≤ c * eLpNorm g p μ`. This version assumes `c` is finite, but requires no measurability hypothesis on `g`. -/ theorem eLpNorm_le_mul_eLpNorm_of_ae_le_mul' {f : α → ε} {g : α → ε'} {c : ℝ≥0} (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) (p : ℝ≥0∞) : eLpNorm f p μ ≤ c * eLpNorm g p μ := by apply eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul' h variable {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] in /-- If `‖f x‖ₑ ≤ c * ‖g x‖ₑ`, then `eLpNorm f p μ ≤ c * eLpNorm g p μ`. This version allows `c = ∞`, but requires `g` to be a.e. strongly measurable. -/ theorem eLpNorm_le_mul_eLpNorm_of_ae_le_mul'' {f : α → ε} {c : ℝ≥0∞} {g : α → ε'} (p : ℝ≥0∞) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) : eLpNorm f p μ ≤ c * eLpNorm g p μ := by by_cases h₀ : p = 0 · simp [h₀] simp only [eLpNorm, h₀, ↓reduceIte, mul_ite] by_cases hp' : p = ⊤ · simpa [hp'] using eLpNormEssSup_le_nnreal_smul_eLpNormEssSup_of_ae_le_mul' h · simpa [hp'] using eLpNorm'_le_mul_eLpNorm'_of_ae_le_mul hg h (ENNReal.toReal_pos h₀ hp') theorem MemLp.of_nnnorm_le_mul {f : α → E} {g : α → F} {c : ℝ≥0} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (hfg : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) : MemLp f p μ := ⟨hf, (eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul hfg p).trans_lt <| ENNReal.mul_lt_top ENNReal.coe_lt_top (by finiteness)⟩ theorem MemLp.of_enorm_le_mul {f : α → ε} {g : α → ε'} {c : ℝ≥0} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (hfg : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) : MemLp f p μ := ⟨hf, (eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul' hfg p).trans_lt <| ENNReal.mul_lt_top ENNReal.coe_lt_top (by finiteness)⟩ theorem MemLp.of_le_mul {f : α → E} {g : α → F} {c : ℝ} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (hfg : ∀ᵐ x ∂μ, ‖f x‖ ≤ c * ‖g x‖) : MemLp f p μ := ⟨hf, (eLpNorm_le_mul_eLpNorm_of_ae_le_mul hfg p).trans_lt <| ENNReal.mul_lt_top ENNReal.ofReal_lt_top (by finiteness)⟩ -- TODO: eventually, deprecate and remove the nnnorm version theorem MemLp.of_le_mul' {f : α → ε} {g : α → ε'} {c : ℝ≥0} (hg : MemLp g p μ) (hf : AEStronglyMeasurable f μ) (hfg : ∀ᵐ x ∂μ, ‖f x‖ₑ ≤ c * ‖g x‖ₑ) : MemLp f p μ := ⟨hf, (eLpNorm_le_mul_eLpNorm_of_ae_le_mul' hfg p).trans_lt <| ENNReal.mul_lt_top ENNReal.coe_lt_top (by finiteness)⟩ end Monotonicity /-! ### Bounded actions by normed rings In this section we show inequalities on the norm. -/ section IsBoundedSMul variable {𝕜 : Type*} [NormedRing 𝕜] [MulActionWithZero 𝕜 F] [IsBoundedSMul 𝕜 F] {c : 𝕜} {f : α → F} theorem eLpNorm'_const_smul_le (hq : 0 < q) : eLpNorm' (c • f) q μ ≤ ‖c‖ₑ * eLpNorm' f q μ := eLpNorm'_le_nnreal_smul_eLpNorm'_of_ae_le_mul (Eventually.of_forall fun _ => nnnorm_smul_le ..) hq theorem eLpNormEssSup_const_smul_le : eLpNormEssSup (c • f) μ ≤ ‖c‖ₑ * eLpNormEssSup f μ := eLpNormEssSup_le_nnreal_smul_eLpNormEssSup_of_ae_le_mul (Eventually.of_forall fun _ => by simp [nnnorm_smul_le]) theorem eLpNorm_const_smul_le : eLpNorm (c • f) p μ ≤ ‖c‖ₑ * eLpNorm f p μ := eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul (Eventually.of_forall fun _ => by simp [nnnorm_smul_le]) _ theorem MemLp.const_smul (hf : MemLp f p μ) (c : 𝕜) : MemLp (c • f) p μ := ⟨hf.1.const_smul c, eLpNorm_const_smul_le.trans_lt (ENNReal.mul_lt_top ENNReal.coe_lt_top hf.2)⟩ theorem MemLp.const_mul {f : α → 𝕜} (hf : MemLp f p μ) (c : 𝕜) : MemLp (fun x => c * f x) p μ := hf.const_smul c theorem MemLp.mul_const {f : α → 𝕜} (hf : MemLp f p μ) (c : 𝕜) : MemLp (fun x => f x * c) p μ := hf.const_smul (MulOpposite.op c) end IsBoundedSMul section ENormSMulClass variable {𝕜 : Type*} [NormedRing 𝕜] {ε : Type*} [TopologicalSpace ε] [ESeminormedAddMonoid ε] [SMul 𝕜 ε] [ENormSMulClass 𝕜 ε] {c : 𝕜} {f : α → ε} theorem eLpNorm'_const_smul_le' (hq : 0 < q) : eLpNorm' (c • f) q μ ≤ ‖c‖ₑ * eLpNorm' f q μ := eLpNorm'_le_nnreal_smul_eLpNorm'_of_ae_le_mul' (Eventually.of_forall fun _ ↦ le_of_eq (enorm_smul ..)) hq theorem eLpNormEssSup_const_smul_le' : eLpNormEssSup (c • f) μ ≤ ‖c‖ₑ * eLpNormEssSup f μ := eLpNormEssSup_le_nnreal_smul_eLpNormEssSup_of_ae_le_mul' (Eventually.of_forall fun _ => by simp [enorm_smul]) theorem eLpNorm_const_smul_le' : eLpNorm (c • f) p μ ≤ ‖c‖ₑ * eLpNorm f p μ := eLpNorm_le_nnreal_smul_eLpNorm_of_ae_le_mul' (Eventually.of_forall fun _ => le_of_eq (enorm_smul ..)) _ theorem MemLp.const_smul' [ContinuousConstSMul 𝕜 ε] (hf : MemLp f p μ) (c : 𝕜) : MemLp (c • f) p μ := ⟨hf.1.const_smul c, eLpNorm_const_smul_le'.trans_lt (ENNReal.mul_lt_top ENNReal.coe_lt_top hf.2)⟩ theorem MemLp.const_mul' {f : α → 𝕜} (hf : MemLp f p μ) (c : 𝕜) : MemLp (fun x => c * f x) p μ := hf.const_smul c end ENormSMulClass /-! ### Bounded actions by normed division rings The inequalities in the previous section are now tight. TODO: do these results hold for any `NormedRing` assuming `NormSMulClass`? -/ section NormedSpace variable {𝕜 : Type*} [NormedDivisionRing 𝕜] [Module 𝕜 F] [NormSMulClass 𝕜 F] theorem eLpNorm'_const_smul {f : α → F} (c : 𝕜) (hq_pos : 0 < q) : eLpNorm' (c • f) q μ = ‖c‖ₑ * eLpNorm' f q μ := by obtain rfl | hc := eq_or_ne c 0 · simp [eLpNorm'_eq_lintegral_enorm, hq_pos] refine le_antisymm (eLpNorm'_const_smul_le hq_pos) <| ENNReal.mul_le_of_le_div' ?_ simpa [enorm_inv, hc, ENNReal.div_eq_inv_mul] using eLpNorm'_const_smul_le (c := c⁻¹) (f := c • f) hq_pos theorem eLpNormEssSup_const_smul (c : 𝕜) (f : α → F) : eLpNormEssSup (c • f) μ = ‖c‖ₑ * eLpNormEssSup f μ := by simp_rw [eLpNormEssSup_eq_essSup_enorm, Pi.smul_apply, enorm_smul, ENNReal.essSup_const_mul] theorem eLpNorm_const_smul (c : 𝕜) (f : α → F) (p : ℝ≥0∞) (μ : Measure α) : eLpNorm (c • f) p μ = ‖c‖ₑ * eLpNorm f p μ := by obtain rfl | hc := eq_or_ne c 0 · simp refine le_antisymm eLpNorm_const_smul_le <| ENNReal.mul_le_of_le_div' ?_ simpa [enorm_inv, hc, ENNReal.div_eq_inv_mul] using eLpNorm_const_smul_le (c := c⁻¹) (f := c • f) lemma eLpNorm_nsmul [NormedSpace ℝ F] (n : ℕ) (f : α → F) : eLpNorm (n • f) p μ = n * eLpNorm f p μ := by simpa [Nat.cast_smul_eq_nsmul] using eLpNorm_const_smul (n : ℝ) f .. end NormedSpace theorem le_eLpNorm_of_bddBelow (hp : p ≠ 0) (hp' : p ≠ ∞) {f : α → F} (C : ℝ≥0) {s : Set α} (hs : MeasurableSet s) (hf : ∀ᵐ x ∂μ, x ∈ s → C ≤ ‖f x‖₊) : C • μ s ^ (1 / p.toReal) ≤ eLpNorm f p μ := by rw [ENNReal.smul_def, smul_eq_mul, eLpNorm_eq_lintegral_rpow_enorm hp hp', one_div, ENNReal.le_rpow_inv_iff (ENNReal.toReal_pos hp hp'), ENNReal.mul_rpow_of_nonneg _ _ ENNReal.toReal_nonneg, ← ENNReal.rpow_mul, inv_mul_cancel₀ (ENNReal.toReal_pos hp hp').ne.symm, ENNReal.rpow_one, ← setLIntegral_const, ← lintegral_indicator hs] refine lintegral_mono_ae ?_ filter_upwards [hf] with x hx by_cases hxs : x ∈ s · simp only [Set.indicator_of_mem, hxs, true_implies] at hx ⊢ gcongr rwa [coe_le_enorm] · simp [Set.indicator_of_notMem hxs] section Star variable {R : Type*} [NormedAddCommGroup R] [StarAddMonoid R] [NormedStarGroup R] @[simp] theorem eLpNorm_star {p : ℝ≥0∞} {f : α → R} : eLpNorm (star f) p μ = eLpNorm f p μ := eLpNorm_congr_norm_ae <| .of_forall <| by simp @[simp] theorem AEEqFun.eLpNorm_star {p : ℝ≥0∞} {f : α →ₘ[μ] R} : eLpNorm (star f : α →ₘ[μ] R) p μ = eLpNorm f p μ := eLpNorm_congr_ae (coeFn_star f) |>.trans <| by simp protected theorem MemLp.star {p : ℝ≥0∞} {f : α → R} (hf : MemLp f p μ) : MemLp (star f) p μ := ⟨hf.1.star, by simpa using hf.2⟩ end Star section RCLike variable {𝕜 : Type*} [RCLike 𝕜] {f : α → 𝕜} @[simp] lemma eLpNorm_conj (f : α → 𝕜) (p : ℝ≥0∞) (μ : Measure α) : eLpNorm (conj f) p μ = eLpNorm f p μ := by simp [← eLpNorm_norm] theorem MemLp.re (hf : MemLp f p μ) : MemLp (fun x => RCLike.re (f x)) p μ := by have : ∀ x, ‖RCLike.re (f x)‖ ≤ 1 * ‖f x‖ := by intro x rw [one_mul] exact RCLike.norm_re_le_norm (f x) refine hf.of_le_mul ?_ (Eventually.of_forall this) exact RCLike.continuous_re.comp_aestronglyMeasurable hf.1 theorem MemLp.im (hf : MemLp f p μ) : MemLp (fun x => RCLike.im (f x)) p μ := by have : ∀ x, ‖RCLike.im (f x)‖ ≤ 1 * ‖f x‖ := by intro x rw [one_mul] exact RCLike.norm_im_le_norm (f x) refine hf.of_le_mul ?_ (Eventually.of_forall this) exact RCLike.continuous_im.comp_aestronglyMeasurable hf.1 end RCLike section Liminf variable [MeasurableSpace E] [OpensMeasurableSpace E] {R : ℝ≥0} theorem ae_bdd_liminf_atTop_rpow_of_eLpNorm_bdd {p : ℝ≥0∞} {f : ℕ → α → E} (hfmeas : ∀ n, Measurable (f n)) (hbdd : ∀ n, eLpNorm (f n) p μ ≤ R) : ∀ᵐ x ∂μ, liminf (fun n => ((‖f n x‖ₑ) ^ p.toReal : ℝ≥0∞)) atTop < ∞ := by by_cases hp0 : p.toReal = 0 · simp only [hp0, ENNReal.rpow_zero] filter_upwards with _ rw [liminf_const (1 : ℝ≥0∞)] exact ENNReal.one_lt_top have hp : p ≠ 0 := fun h => by simp [h] at hp0 have hp' : p ≠ ∞ := fun h => by simp [h] at hp0 refine ae_lt_top (.liminf fun n => (hfmeas n).nnnorm.coe_nnreal_ennreal.pow_const p.toReal) (lt_of_le_of_lt (lintegral_liminf_le fun n => (hfmeas n).nnnorm.coe_nnreal_ennreal.pow_const p.toReal) (lt_of_le_of_lt ?_ (by finiteness : (R : ℝ≥0∞) ^ p.toReal < ∞))).ne simp_rw [eLpNorm_eq_lintegral_rpow_enorm hp hp', one_div] at hbdd simp_rw [liminf_eq, eventually_atTop] exact sSup_le fun b ⟨a, ha⟩ => (ha a le_rfl).trans ((ENNReal.rpow_inv_le_iff (ENNReal.toReal_pos hp hp')).1 (hbdd _)) theorem ae_bdd_liminf_atTop_of_eLpNorm_bdd {p : ℝ≥0∞} (hp : p ≠ 0) {f : ℕ → α → E} (hfmeas : ∀ n, Measurable (f n)) (hbdd : ∀ n, eLpNorm (f n) p μ ≤ R) : ∀ᵐ x ∂μ, liminf (fun n => (‖f n x‖ₑ)) atTop < ∞ := by by_cases hp' : p = ∞ · subst hp' simp_rw [eLpNorm_exponent_top] at hbdd have : ∀ n, ∀ᵐ x ∂μ, (‖f n x‖ₑ) < R + 1 := fun n => ae_lt_of_essSup_lt (lt_of_le_of_lt (hbdd n) <| ENNReal.lt_add_right ENNReal.coe_ne_top one_ne_zero) rw [← ae_all_iff] at this filter_upwards [this] with x hx using lt_of_le_of_lt (liminf_le_of_frequently_le' <| Frequently.of_forall fun n => (hx n).le) (ENNReal.add_lt_top.2 ⟨ENNReal.coe_lt_top, ENNReal.one_lt_top⟩) filter_upwards [ae_bdd_liminf_atTop_rpow_of_eLpNorm_bdd hfmeas hbdd] with x hx have hppos : 0 < p.toReal := ENNReal.toReal_pos hp hp' have : liminf (fun n => (‖f n x‖ₑ) ^ p.toReal) atTop = liminf (fun n => (‖f n x‖ₑ)) atTop ^ p.toReal := by change liminf (fun n => ENNReal.orderIsoRpow p.toReal hppos (‖f n x‖ₑ)) atTop = ENNReal.orderIsoRpow p.toReal hppos (liminf (fun n => (‖f n x‖ₑ)) atTop) refine (OrderIso.liminf_apply (ENNReal.orderIsoRpow p.toReal _) ?_ ?_ ?_ ?_).symm <;> isBoundedDefault rw [this] at hx rw [← ENNReal.rpow_one (liminf (‖f · x‖ₑ) atTop), ← mul_inv_cancel₀ hppos.ne.symm, ENNReal.rpow_mul] exact ENNReal.rpow_lt_top_of_nonneg (inv_nonneg.2 hppos.le) hx.ne end Liminf /-- A continuous function with compact support belongs to `L^∞`. See `Continuous.memLp_of_hasCompactSupport` for a version for `L^p`. -/ theorem _root_.Continuous.memLp_top_of_hasCompactSupport {X : Type*} [TopologicalSpace X] [MeasurableSpace X] [OpensMeasurableSpace X] {f : X → E} (hf : Continuous f) (h'f : HasCompactSupport f) (μ : Measure X) : MemLp f ⊤ μ := by borelize E rcases hf.bounded_above_of_compact_support h'f with ⟨C, hC⟩ apply memLp_top_of_bound ?_ C (Filter.Eventually.of_forall hC) exact (hf.stronglyMeasurable_of_hasCompactSupport h'f).aestronglyMeasurable section UnifTight /-- A single function that is `MemLp f p μ` is tight with respect to `μ`. -/ theorem MemLp.exists_eLpNorm_indicator_compl_lt {β : Type*} [NormedAddCommGroup β] (hp_top : p ≠ ∞) {f : α → β} (hf : MemLp f p μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ s : Set α, MeasurableSet s ∧ μ s < ∞ ∧ eLpNorm (sᶜ.indicator f) p μ < ε := by rcases eq_or_ne p 0 with rfl | hp₀ · use ∅; simp [pos_iff_ne_zero.2 hε] -- first take care of `p = 0` · obtain ⟨s, hsm, hs, hε⟩ : ∃ s, MeasurableSet s ∧ μ s < ∞ ∧ ∫⁻ a in sᶜ, (‖f a‖ₑ) ^ p.toReal ∂μ < ε ^ p.toReal := by apply exists_setLIntegral_compl_lt · exact ((eLpNorm_lt_top_iff_lintegral_rpow_enorm_lt_top hp₀ hp_top).1 hf.2).ne · simp [*] refine ⟨s, hsm, hs, ?_⟩ rwa [eLpNorm_indicator_eq_eLpNorm_restrict hsm.compl, eLpNorm_eq_lintegral_rpow_enorm hp₀ hp_top, one_div, ENNReal.rpow_inv_lt_iff] simp [ENNReal.toReal_pos, *] end UnifTight end Lp end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSeminorm/ChebyshevMarkov.lean
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic /-! # Chebyshev-Markov inequality in terms of Lp seminorms In this file we formulate several versions of the Chebyshev-Markov inequality in terms of the `MeasureTheory.eLpNorm` seminorm. -/ open scoped NNReal ENNReal namespace MeasureTheory variable {α E ε' : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [TopologicalSpace ε'] [ContinuousENorm ε'] {p : ℝ≥0∞} (μ : Measure α) theorem pow_mul_meas_ge_le_eLpNorm (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε'} (hf : AEStronglyMeasurable f μ) (ε : ℝ≥0∞) : (ε * μ { x | ε ≤ ‖f x‖ₑ ^ p.toReal }) ^ (1 / p.toReal) ≤ eLpNorm f p μ := by rw [eLpNorm_eq_lintegral_rpow_enorm hp_ne_zero hp_ne_top] gcongr exact mul_meas_ge_le_lintegral₀ (hf.enorm.pow_const _) ε theorem mul_meas_ge_le_pow_eLpNorm (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε'} (hf : AEStronglyMeasurable f μ) (ε : ℝ≥0∞) : ε * μ { x | ε ≤ ‖f x‖ₑ ^ p.toReal } ≤ eLpNorm f p μ ^ p.toReal := by have : 1 / p.toReal * p.toReal = 1 := by refine one_div_mul_cancel ?_ rw [Ne, ENNReal.toReal_eq_zero_iff] exact not_or_intro hp_ne_zero hp_ne_top rw [← ENNReal.rpow_one (ε * μ { x | ε ≤ ‖f x‖ₑ ^ p.toReal }), ← this, ENNReal.rpow_mul] gcongr exact pow_mul_meas_ge_le_eLpNorm μ hp_ne_zero hp_ne_top hf ε /-- A version of Chebyshev-Markov's inequality using Lp-norms. -/ theorem mul_meas_ge_le_pow_eLpNorm' (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε'} (hf : AEStronglyMeasurable f μ) (ε : ℝ≥0∞) : ε ^ p.toReal * μ { x | ε ≤ ‖f x‖ₑ } ≤ eLpNorm f p μ ^ p.toReal := by convert mul_meas_ge_le_pow_eLpNorm μ hp_ne_zero hp_ne_top hf (ε ^ p.toReal) using 4 ext x rw [ENNReal.rpow_le_rpow_iff (ENNReal.toReal_pos hp_ne_zero hp_ne_top)] theorem meas_ge_le_mul_pow_eLpNorm_enorm (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε'} (hf : AEStronglyMeasurable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) (hmeas_top : ε = ∞ → μ {x | ‖f x‖ₑ = ⊤} = 0) : μ { x | ε ≤ ‖f x‖ₑ } ≤ ε⁻¹ ^ p.toReal * eLpNorm f p μ ^ p.toReal := by by_cases h : ε = ∞ · have : (0 : ℝ≥0∞) ^ p.toReal = 0 := by rw [ENNReal.zero_rpow_of_pos (ENNReal.toReal_pos hp_ne_zero hp_ne_top)] simp [h, this, hmeas_top] · have hεpow : ε ^ p.toReal ≠ 0 := (ENNReal.rpow_pos (pos_iff_ne_zero.2 hε) h).ne.symm have hεpow' : ε ^ p.toReal ≠ ∞ := by finiteness rw [ENNReal.inv_rpow, ← ENNReal.mul_le_mul_left hεpow hεpow', ← mul_assoc, ENNReal.mul_inv_cancel hεpow hεpow', one_mul] exact mul_meas_ge_le_pow_eLpNorm' μ hp_ne_zero hp_ne_top hf ε @[deprecated meas_ge_le_mul_pow_eLpNorm_enorm (since := "2025-05-01")] theorem meas_ge_le_mul_pow_eLpNorm (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → E} (hf : AEStronglyMeasurable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) : μ { x | ε ≤ ‖f x‖₊ } ≤ ε⁻¹ ^ p.toReal * eLpNorm f p μ ^ p.toReal := meas_ge_le_mul_pow_eLpNorm_enorm μ hp_ne_zero hp_ne_top hf hε (by simp) theorem MemLp.meas_ge_lt_top'_enorm {μ : Measure α} {f : α → ε'} (hℒp : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) (hε' : ε = ∞ → μ {x | ‖f x‖ₑ = ⊤} = 0) : μ { x | ε ≤ ‖f x‖ₑ } < ∞ := by apply meas_ge_le_mul_pow_eLpNorm_enorm μ hp_ne_zero hp_ne_top hℒp.aestronglyMeasurable hε hε' |>.trans_lt (ENNReal.mul_lt_top ?_ ?_) · simp [hε, lt_top_iff_ne_top] · simp [hℒp.eLpNorm_lt_top.ne, lt_top_iff_ne_top] theorem MemLp.meas_ge_lt_top' {μ : Measure α} {f : α → E} (hℒp : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : μ { x | ε ≤ ‖f x‖₊ } < ∞ := by by_cases h : ε = ∞ · simp [h] exact hℒp.meas_ge_lt_top'_enorm hp_ne_zero hp_ne_top hε (by simp) theorem MemLp.meas_ge_lt_top_enorm {μ : Measure α} {f : α → ε'} (hℒp : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {ε : ℝ≥0} (hε : ε ≠ 0) : μ { x | ε ≤ ‖f x‖ₑ } < ∞ := hℒp.meas_ge_lt_top'_enorm hp_ne_zero hp_ne_top (by simp [hε]) (by simp) theorem MemLp.meas_ge_lt_top {μ : Measure α} {f : α → E} (hℒp : MemLp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {ε : ℝ≥0} (hε : ε ≠ 0) : μ { x | ε ≤ ‖f x‖₊ } < ∞ := by simp_rw [← ENNReal.coe_le_coe] apply hℒp.meas_ge_lt_top' hp_ne_zero hp_ne_top (by simp [hε]) end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSeminorm/Defs.lean
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal import Mathlib.MeasureTheory.Function.EssSup import Mathlib.MeasureTheory.Function.StronglyMeasurable.AEStronglyMeasurable import Mathlib.MeasureTheory.Integral.Lebesgue.Basic /-! # ℒp space This file describes properties of almost everywhere strongly measurable functions with finite `p`-seminorm, denoted by `eLpNorm f p μ` and defined for `p:ℝ≥0∞` as `0` if `p=0`, `(∫ ‖f a‖^p ∂μ) ^ (1/p)` for `0 < p < ∞` and `essSup ‖f‖ μ` for `p=∞`. The Prop-valued `MemLp f p μ` states that a function `f : α → E` has finite `p`-seminorm and is almost everywhere strongly measurable. ## Main definitions * `eLpNorm' f p μ` : `(∫ ‖f a‖^p ∂μ) ^ (1/p)` for `f : α → F` and `p : ℝ`, where `α` is a measurable space and `F` is a normed group. * `eLpNormEssSup f μ` : seminorm in `ℒ∞`, equal to the essential supremum `essSup ‖f‖ μ`. * `eLpNorm f p μ` : for `p : ℝ≥0∞`, seminorm in `ℒp`, equal to `0` for `p=0`, to `eLpNorm' f p μ` for `0 < p < ∞` and to `eLpNormEssSup f μ` for `p = ∞`. * `MemLp f p μ` : property that the function `f` is almost everywhere strongly measurable and has finite `p`-seminorm for the measure `μ` (`eLpNorm f p μ < ∞`) -/ noncomputable section open scoped NNReal ENNReal variable {α ε ε' E F G : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] [ENorm ε] [ENorm ε'] namespace MeasureTheory section Lp /-! ### ℒp seminorm We define the ℒp seminorm, denoted by `eLpNorm f p μ`. For real `p`, it is given by an integral formula (for which we use the notation `eLpNorm' f p μ`), and for `p = ∞` it is the essential supremum (for which we use the notation `eLpNormEssSup f μ`). We also define a predicate `MemLp f p μ`, requesting that a function is almost everywhere measurable and has finite `eLpNorm f p μ`. This paragraph is devoted to the basic properties of these definitions. It is constructed as follows: for a given property, we prove it for `eLpNorm'` and `eLpNormEssSup` when it makes sense, deduce it for `eLpNorm`, and translate it in terms of `MemLp`. -/ /-- `(∫ ‖f a‖^q ∂μ) ^ (1/q)`, which is a seminorm on the space of measurable functions for which this quantity is finite. Note: this is a purely auxiliary quantity; lemmas about `eLpNorm'` should only be used to prove results about `eLpNorm`; every `eLpNorm'` lemma should have a `eLpNorm` version. -/ def eLpNorm' {_ : MeasurableSpace α} (f : α → ε) (q : ℝ) (μ : Measure α) : ℝ≥0∞ := (∫⁻ a, ‖f a‖ₑ ^ q ∂μ) ^ (1 / q) lemma eLpNorm'_eq_lintegral_enorm {_ : MeasurableSpace α} (f : α → ε) (q : ℝ) (μ : Measure α) : eLpNorm' f q μ = (∫⁻ a, ‖f a‖ₑ ^ q ∂μ) ^ (1 / q) := rfl /-- seminorm for `ℒ∞`, equal to the essential supremum of `‖f‖`. -/ def eLpNormEssSup {_ : MeasurableSpace α} (f : α → ε) (μ : Measure α) := essSup (fun x => ‖f x‖ₑ) μ lemma eLpNormEssSup_eq_essSup_enorm {_ : MeasurableSpace α} (f : α → ε) (μ : Measure α) : eLpNormEssSup f μ = essSup (‖f ·‖ₑ) μ := rfl /-- `ℒp` seminorm, equal to `0` for `p=0`, to `(∫ ‖f a‖^p ∂μ) ^ (1/p)` for `0 < p < ∞` and to `essSup ‖f‖ μ` for `p = ∞`. -/ def eLpNorm {_ : MeasurableSpace α} (f : α → ε) (p : ℝ≥0∞) (μ : Measure α := by volume_tac) : ℝ≥0∞ := if p = 0 then 0 else if p = ∞ then eLpNormEssSup f μ else eLpNorm' f (ENNReal.toReal p) μ variable {μ ν : Measure α} theorem eLpNorm_eq_eLpNorm' (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε} : eLpNorm f p μ = eLpNorm' f (ENNReal.toReal p) μ := by simp [eLpNorm, hp_ne_zero, hp_ne_top] lemma eLpNorm_nnreal_eq_eLpNorm' {f : α → ε} {p : ℝ≥0} (hp : p ≠ 0) : eLpNorm f p μ = eLpNorm' f p μ := eLpNorm_eq_eLpNorm' (by exact_mod_cast hp) ENNReal.coe_ne_top theorem eLpNorm_eq_lintegral_rpow_enorm (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) {f : α → ε} : eLpNorm f p μ = (∫⁻ x, ‖f x‖ₑ ^ p.toReal ∂μ) ^ (1 / p.toReal) := by rw [eLpNorm_eq_eLpNorm' hp_ne_zero hp_ne_top, eLpNorm'_eq_lintegral_enorm] lemma eLpNorm_nnreal_eq_lintegral {f : α → ε} {p : ℝ≥0} (hp : p ≠ 0) : eLpNorm f p μ = (∫⁻ x, ‖f x‖ₑ ^ (p : ℝ) ∂μ) ^ (1 / (p : ℝ)) := eLpNorm_nnreal_eq_eLpNorm' hp theorem eLpNorm_one_eq_lintegral_enorm {f : α → ε} : eLpNorm f 1 μ = ∫⁻ x, ‖f x‖ₑ ∂μ := by simp_rw [eLpNorm_eq_lintegral_rpow_enorm one_ne_zero ENNReal.coe_ne_top, ENNReal.toReal_one, one_div_one, ENNReal.rpow_one] @[simp] theorem eLpNorm_exponent_top {f : α → ε} : eLpNorm f ∞ μ = eLpNormEssSup f μ := by simp [eLpNorm] /-- The property that `f : α → E` is a.e. strongly measurable and `(∫ ‖f a‖ ^ p ∂μ) ^ (1/p)` is finite if `p < ∞`, or `essSup ‖f‖ < ∞` if `p = ∞`. -/ def MemLp {α} {_ : MeasurableSpace α} [TopologicalSpace ε] (f : α → ε) (p : ℝ≥0∞) (μ : Measure α := by volume_tac) : Prop := AEStronglyMeasurable f μ ∧ eLpNorm f p μ < ∞ theorem MemLp.aestronglyMeasurable [TopologicalSpace ε] {f : α → ε} {p : ℝ≥0∞} (h : MemLp f p μ) : AEStronglyMeasurable f μ := h.1 lemma MemLp.aemeasurable [MeasurableSpace ε] [TopologicalSpace ε] [TopologicalSpace.PseudoMetrizableSpace ε] [BorelSpace ε] {f : α → ε} {p : ℝ≥0∞} (hf : MemLp f p μ) : AEMeasurable f μ := hf.aestronglyMeasurable.aemeasurable theorem lintegral_rpow_enorm_eq_rpow_eLpNorm' {f : α → ε} (hq0_lt : 0 < q) : ∫⁻ a, ‖f a‖ₑ ^ q ∂μ = eLpNorm' f q μ ^ q := by rw [eLpNorm'_eq_lintegral_enorm, ← ENNReal.rpow_mul, one_div, inv_mul_cancel₀, ENNReal.rpow_one] exact hq0_lt.ne' lemma eLpNorm_nnreal_pow_eq_lintegral {f : α → ε} {p : ℝ≥0} (hp : p ≠ 0) : eLpNorm f p μ ^ (p : ℝ) = ∫⁻ x, ‖f x‖ₑ ^ (p : ℝ) ∂μ := by simp [eLpNorm_eq_eLpNorm' (by exact_mod_cast hp) ENNReal.coe_ne_top, lintegral_rpow_enorm_eq_rpow_eLpNorm' ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hp)] end Lp end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSeminorm/CompareExp.lean
import Mathlib.Data.ENNReal.Holder import Mathlib.MeasureTheory.Function.LpSeminorm.Basic import Mathlib.MeasureTheory.Integral.MeanInequalities /-! # Compare Lp seminorms for different values of `p` In this file we compare `MeasureTheory.eLpNorm'` and `MeasureTheory.eLpNorm` for different exponents. -/ open Filter ENNReal open scoped Topology namespace MeasureTheory section SameSpace variable {α ε ε' : Type*} {m : MeasurableSpace α} {μ : Measure α} {f : α → ε} [TopologicalSpace ε] [ContinuousENorm ε] [TopologicalSpace ε'] [ESeminormedAddMonoid ε'] theorem eLpNorm'_le_eLpNorm'_mul_rpow_measure_univ {p q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) (hf : AEStronglyMeasurable f μ) : eLpNorm' f p μ ≤ eLpNorm' f q μ * μ Set.univ ^ (1 / p - 1 / q) := by have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq by_cases hpq_eq : p = q · rw [hpq_eq, sub_self, ENNReal.rpow_zero, mul_one] have hpq : p < q := lt_of_le_of_ne hpq hpq_eq let g := fun _ : α => (1 : ℝ≥0∞) have h_rw : (∫⁻ a, ‖f a‖ₑ ^ p ∂μ) = ∫⁻ a, (‖f a‖ₑ * g a) ^ p ∂μ := lintegral_congr fun a => by simp [g] repeat' rw [eLpNorm'_eq_lintegral_enorm] rw [h_rw] let r := p * q / (q - p) have hpqr : 1 / p = 1 / q + 1 / r := by simp [field] calc (∫⁻ a : α, (‖f a‖ₑ * g a) ^ p ∂μ) ^ (1 / p) ≤ (∫⁻ a : α, ‖f a‖ₑ ^ q ∂μ) ^ (1 / q) * (∫⁻ a : α, g a ^ r ∂μ) ^ (1 / r) := ENNReal.lintegral_Lp_mul_le_Lq_mul_Lr hp0_lt hpq hpqr μ hf.enorm aemeasurable_const _ = (∫⁻ a : α, ‖f a‖ₑ ^ q ∂μ) ^ (1 / q) * μ Set.univ ^ (1 / p - 1 / q) := by rw [hpqr]; simp [r, g] theorem eLpNorm'_le_eLpNormEssSup_mul_rpow_measure_univ {q : ℝ} (hq_pos : 0 < q) : eLpNorm' f q μ ≤ eLpNormEssSup f μ * μ Set.univ ^ (1 / q) := by have h_le : (∫⁻ a : α, ‖f a‖ₑ ^ q ∂μ) ≤ ∫⁻ _ : α, eLpNormEssSup f μ ^ q ∂μ := by refine lintegral_mono_ae ?_ have h_nnnorm_le_eLpNorm_ess_sup := enorm_ae_le_eLpNormEssSup f μ exact h_nnnorm_le_eLpNorm_ess_sup.mono fun x hx => by gcongr rw [eLpNorm', ← ENNReal.rpow_one (eLpNormEssSup f μ)] nth_rw 2 [← mul_inv_cancel₀ (ne_of_lt hq_pos).symm] rw [ENNReal.rpow_mul, one_div, ← ENNReal.mul_rpow_of_nonneg _ _ (by simp [hq_pos.le] : 0 ≤ q⁻¹)] gcongr rwa [lintegral_const] at h_le theorem eLpNorm_le_eLpNorm_mul_rpow_measure_univ {p q : ℝ≥0∞} (hpq : p ≤ q) (hf : AEStronglyMeasurable f μ) : eLpNorm f p μ ≤ eLpNorm f q μ * μ Set.univ ^ (1 / p.toReal - 1 / q.toReal) := by by_cases hp0 : p = 0 · simp [hp0, zero_le] rw [← Ne] at hp0 have hp0_lt : 0 < p := lt_of_le_of_ne (zero_le _) hp0.symm have hq0_lt : 0 < q := lt_of_lt_of_le hp0_lt hpq by_cases hq_top : q = ∞ · simp only [hq_top, _root_.div_zero, one_div, ENNReal.toReal_top, sub_zero, eLpNorm_exponent_top] by_cases hp_top : p = ∞ · simp [hp_top] rw [eLpNorm_eq_eLpNorm' hp0 hp_top] have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0_lt.ne' hp_top refine (eLpNorm'_le_eLpNormEssSup_mul_rpow_measure_univ hp_pos).trans (le_of_eq ?_) congr exact one_div _ have hp_lt_top : p < ∞ := hpq.trans_lt (lt_top_iff_ne_top.mpr hq_top) have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0_lt.ne' hp_lt_top.ne rw [eLpNorm_eq_eLpNorm' hp0_lt.ne.symm hp_lt_top.ne, eLpNorm_eq_eLpNorm' hq0_lt.ne.symm hq_top] have hpq_real : p.toReal ≤ q.toReal := ENNReal.toReal_mono hq_top hpq exact eLpNorm'_le_eLpNorm'_mul_rpow_measure_univ hp_pos hpq_real hf theorem eLpNorm'_le_eLpNorm'_of_exponent_le {p q : ℝ} (hp0_lt : 0 < p) (hpq : p ≤ q) (μ : Measure α) [IsProbabilityMeasure μ] (hf : AEStronglyMeasurable f μ) : eLpNorm' f p μ ≤ eLpNorm' f q μ := by have h_le_μ := eLpNorm'_le_eLpNorm'_mul_rpow_measure_univ hp0_lt hpq hf rwa [measure_univ, ENNReal.one_rpow, mul_one] at h_le_μ theorem eLpNorm'_le_eLpNormEssSup {q : ℝ} (hq_pos : 0 < q) [IsProbabilityMeasure μ] : eLpNorm' f q μ ≤ eLpNormEssSup f μ := (eLpNorm'_le_eLpNormEssSup_mul_rpow_measure_univ hq_pos).trans_eq (by simp [measure_univ]) theorem eLpNorm_le_eLpNorm_of_exponent_le {p q : ℝ≥0∞} (hpq : p ≤ q) [IsProbabilityMeasure μ] (hf : AEStronglyMeasurable f μ) : eLpNorm f p μ ≤ eLpNorm f q μ := (eLpNorm_le_eLpNorm_mul_rpow_measure_univ hpq hf).trans (le_of_eq (by simp [measure_univ])) theorem eLpNorm'_lt_top_of_eLpNorm'_lt_top_of_exponent_le {p q : ℝ} [IsFiniteMeasure μ] (hf : AEStronglyMeasurable f μ) (hfq_lt_top : eLpNorm' f q μ < ∞) (hp_nonneg : 0 ≤ p) (hpq : p ≤ q) : eLpNorm' f p μ < ∞ := by rcases le_or_gt p 0 with hp_nonpos | hp_pos · rw [le_antisymm hp_nonpos hp_nonneg] simp have hq_pos : 0 < q := lt_of_lt_of_le hp_pos hpq calc eLpNorm' f p μ ≤ eLpNorm' f q μ * μ Set.univ ^ (1 / p - 1 / q) := eLpNorm'_le_eLpNorm'_mul_rpow_measure_univ hp_pos hpq hf _ < ∞ := by rw [ENNReal.mul_lt_top_iff] refine Or.inl ⟨hfq_lt_top, ENNReal.rpow_lt_top_of_nonneg ?_ (by finiteness)⟩ rwa [le_sub_comm, sub_zero, one_div, one_div, inv_le_inv₀ hq_pos hp_pos] theorem MemLp.mono_exponent {p q : ℝ≥0∞} [IsFiniteMeasure μ] (hfq : MemLp f q μ) (hpq : p ≤ q) : MemLp f p μ := by obtain ⟨hfq_m, hfq_lt_top⟩ := hfq by_cases hp0 : p = 0 · rwa [hp0, memLp_zero_iff_aestronglyMeasurable] rw [← Ne] at hp0 refine ⟨hfq_m, ?_⟩ by_cases hp_top : p = ∞ · have hq_top : q = ∞ := by rwa [hp_top, top_le_iff] at hpq rw [hp_top] rwa [hq_top] at hfq_lt_top have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0 hp_top by_cases hq_top : q = ∞ · rw [eLpNorm_eq_eLpNorm' hp0 hp_top] rw [hq_top, eLpNorm_exponent_top] at hfq_lt_top refine lt_of_le_of_lt (eLpNorm'_le_eLpNormEssSup_mul_rpow_measure_univ hp_pos) ?_ refine ENNReal.mul_lt_top hfq_lt_top ?_ exact ENNReal.rpow_lt_top_of_nonneg (by simp [hp_pos.le]) (by finiteness) have hq0 : q ≠ 0 := by by_contra hq_eq_zero have hp_eq_zero : p = 0 := le_antisymm (by rwa [hq_eq_zero] at hpq) (zero_le _) rw [hp_eq_zero, ENNReal.toReal_zero] at hp_pos exact (lt_irrefl _) hp_pos have hpq_real : p.toReal ≤ q.toReal := ENNReal.toReal_mono hq_top hpq rw [eLpNorm_eq_eLpNorm' hp0 hp_top] rw [eLpNorm_eq_eLpNorm' hq0 hq_top] at hfq_lt_top exact eLpNorm'_lt_top_of_eLpNorm'_lt_top_of_exponent_le hfq_m hfq_lt_top hp_pos.le hpq_real /-- If a function is supported on a finite-measure set and belongs to `ℒ^p`, then it belongs to `ℒ^q` for any `q ≤ p`. -/ lemma MemLp.mono_exponent_of_measure_support_ne_top {p q : ℝ≥0∞} {f : α → ε'} (hfq : MemLp f q μ) {s : Set α} (hf : ∀ x, x ∉ s → f x = 0) (hs : μ s ≠ ∞) (hpq : p ≤ q) : MemLp f p μ := by have : (toMeasurable μ s).indicator f = f := by apply Set.indicator_eq_self.2 apply Function.support_subset_iff'.2 fun x hx ↦ hf x ?_ contrapose! hx exact subset_toMeasurable μ s hx rw [← this, memLp_indicator_iff_restrict (measurableSet_toMeasurable μ s)] at hfq ⊢ have : Fact (μ (toMeasurable μ s) < ∞) := ⟨by simpa [lt_top_iff_ne_top] using hs⟩ exact hfq.mono_exponent hpq end SameSpace section Bilinear variable {α E F G : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G] {μ : Measure α} {f : α → E} {g : α → F} open NNReal theorem eLpNorm_le_eLpNorm_top_mul_eLpNorm (p : ℝ≥0∞) (f : α → E) {g : α → F} (hg : AEStronglyMeasurable g μ) (b : E → F → G) (c : ℝ≥0) (h : ∀ᵐ x ∂μ, ‖b (f x) (g x)‖₊ ≤ c * ‖f x‖₊ * ‖g x‖₊) : eLpNorm (fun x => b (f x) (g x)) p μ ≤ c * eLpNorm f ∞ μ * eLpNorm g p μ := by calc eLpNorm (fun x => b (f x) (g x)) p μ ≤ eLpNorm (fun x => (c : ℝ) • ‖f x‖ * ‖g x‖) p μ := eLpNorm_mono_ae_real h _ ≤ c * eLpNorm f ∞ μ * eLpNorm g p μ := ?_ simp only [smul_mul_assoc, ← Pi.smul_def, eLpNorm_const_smul] rw [Real.enorm_eq_ofReal c.coe_nonneg, ENNReal.ofReal_coe_nnreal, mul_assoc] gcongr obtain (rfl | rfl | hp) := ENNReal.trichotomy p · simp · rw [← eLpNorm_norm f, ← eLpNorm_norm g] simp_rw [eLpNorm_exponent_top, eLpNormEssSup_eq_essSup_enorm, enorm_mul, enorm_norm] exact ENNReal.essSup_mul_le (‖f ·‖ₑ) (‖g ·‖ₑ) obtain ⟨hp₁, hp₂⟩ := ENNReal.toReal_pos_iff.mp hp simp_rw [eLpNorm_eq_lintegral_rpow_enorm hp₁.ne' hp₂.ne, eLpNorm_exponent_top, eLpNormEssSup, one_div, ENNReal.rpow_inv_le_iff hp, enorm_mul, enorm_norm] rw [ENNReal.mul_rpow_of_nonneg (hz := hp.le), ENNReal.rpow_inv_rpow hp.ne', ← lintegral_const_mul'' _ (by fun_prop)] simp only [← ENNReal.mul_rpow_of_nonneg (hz := hp.le)] apply lintegral_mono_ae filter_upwards [h, enorm_ae_le_eLpNormEssSup f μ] with x hb hf gcongr exact hf theorem eLpNorm_le_eLpNorm_mul_eLpNorm_top (p : ℝ≥0∞) {f : α → E} (hf : AEStronglyMeasurable f μ) (g : α → F) (b : E → F → G) (c : ℝ≥0) (h : ∀ᵐ x ∂μ, ‖b (f x) (g x)‖₊ ≤ c * ‖f x‖₊ * ‖g x‖₊) : eLpNorm (fun x => b (f x) (g x)) p μ ≤ c * eLpNorm f p μ * eLpNorm g ∞ μ := calc eLpNorm (fun x ↦ b (f x) (g x)) p μ ≤ c * eLpNorm g ∞ μ * eLpNorm f p μ := eLpNorm_le_eLpNorm_top_mul_eLpNorm p g hf (flip b) c <| by convert h using 3 with x simp only [mul_assoc, mul_comm ‖f x‖₊] _ = c * eLpNorm f p μ * eLpNorm g ∞ μ := by simp only [mul_assoc]; rw [mul_comm (eLpNorm _ _ _)] theorem eLpNorm'_le_eLpNorm'_mul_eLpNorm' {p q r : ℝ} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (b : E → F → G) (c : ℝ≥0) (h : ∀ᵐ x ∂μ, ‖b (f x) (g x)‖₊ ≤ c * ‖f x‖₊ * ‖g x‖₊) (hro_lt : 0 < r) (hrp : r < p) (hpqr : 1 / r = 1 / p + 1 / q) : eLpNorm' (fun x => b (f x) (g x)) r μ ≤ c * eLpNorm' f p μ * eLpNorm' g q μ := by calc eLpNorm' (fun x => b (f x) (g x)) r μ ≤ eLpNorm' (fun x ↦ (c : ℝ) • ‖f x‖ * ‖g x‖) r μ := by simp only [eLpNorm'] gcongr ?_ ^ _ refine lintegral_mono_ae <| h.mono fun a ha ↦ ?_ gcongr simp only [enorm_eq_nnnorm, ENNReal.coe_le_coe] simpa using ha _ ≤ c * eLpNorm' f p μ * eLpNorm' g q μ := by simp only [smul_mul_assoc, ← Pi.smul_def, eLpNorm'_const_smul _ hro_lt] rw [Real.enorm_eq_ofReal c.coe_nonneg, ENNReal.ofReal_coe_nnreal, mul_assoc] gcongr simpa only [eLpNorm', enorm_mul, enorm_norm] using ENNReal.lintegral_Lp_mul_le_Lq_mul_Lr hro_lt hrp hpqr μ hf.enorm hg.enorm /-- Hölder's inequality, as an inequality on the `ℒp` seminorm of an elementwise operation `fun x => b (f x) (g x)`. -/ theorem eLpNorm_le_eLpNorm_mul_eLpNorm_of_nnnorm {p q r : ℝ≥0∞} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (b : E → F → G) (c : ℝ≥0) (h : ∀ᵐ x ∂μ, ‖b (f x) (g x)‖₊ ≤ c * ‖f x‖₊ * ‖g x‖₊) [hpqr : HolderTriple p q r] : eLpNorm (fun x => b (f x) (g x)) r μ ≤ c * eLpNorm f p μ * eLpNorm g q μ := by have hpqr := hpqr.one_div_eq obtain (rfl | rfl | hp) := ENNReal.trichotomy p · simp_all · have : r = q := by simpa using hpqr exact this ▸ eLpNorm_le_eLpNorm_top_mul_eLpNorm r f hg b c h obtain (rfl | rfl | hq) := ENNReal.trichotomy q · simp_all · have : r = p := by simpa using hpqr exact this ▸ eLpNorm_le_eLpNorm_mul_eLpNorm_top p hf g b c h obtain ⟨hp₁, hp₂⟩ := ENNReal.toReal_pos_iff.mp hp obtain ⟨hq₁, hq₂⟩ := ENNReal.toReal_pos_iff.mp hq have hpqr' : 1 / r.toReal = 1 / p.toReal + 1 / q.toReal := by have := congr(ENNReal.toReal $(hpqr)) rw [ENNReal.toReal_add (by simpa using hp₁.ne') (by simpa using hq₁.ne')] at this simpa have hr : 0 < r.toReal := one_div_pos.mp <| by rw [hpqr']; positivity obtain ⟨hr₁, hr₂⟩ := ENNReal.toReal_pos_iff.mp hr have hrp : r.toReal < p.toReal := lt_of_one_div_lt_one_div hp <| hpqr' ▸ lt_add_of_pos_right _ (by positivity) rw [eLpNorm_eq_eLpNorm', eLpNorm_eq_eLpNorm', eLpNorm_eq_eLpNorm'] · exact eLpNorm'_le_eLpNorm'_mul_eLpNorm' hf hg b c h hr hrp hpqr' all_goals first | positivity | finiteness /-- Hölder's inequality, as an inequality on the `ℒp` seminorm of an elementwise operation `fun x => b (f x) (g x)`. -/ theorem eLpNorm_le_eLpNorm_mul_eLpNorm'_of_norm {p q r : ℝ≥0∞} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (b : E → F → G) (c : ℝ≥0) (h : ∀ᵐ x ∂μ, ‖b (f x) (g x)‖ ≤ c * ‖f x‖ * ‖g x‖) [hpqr : HolderTriple p q r] : eLpNorm (fun x => b (f x) (g x)) r μ ≤ c * eLpNorm f p μ * eLpNorm g q μ := eLpNorm_le_eLpNorm_mul_eLpNorm_of_nnnorm hf hg b c h open NNReal in theorem MemLp.of_bilin {p q r : ℝ≥0∞} {f : α → E} {g : α → F} (b : E → F → G) (c : ℝ≥0) (hf : MemLp f p μ) (hg : MemLp g q μ) (h : AEStronglyMeasurable (fun x ↦ b (f x) (g x)) μ) (hb : ∀ᵐ (x : α) ∂μ, ‖b (f x) (g x)‖₊ ≤ c * ‖f x‖₊ * ‖g x‖₊) [hpqr : HolderTriple p q r] : MemLp (fun x ↦ b (f x) (g x)) r μ := by refine ⟨h, ?_⟩ apply (eLpNorm_le_eLpNorm_mul_eLpNorm_of_nnnorm hf.1 hg.1 b c hb (hpqr := hpqr)).trans_lt have := hf.2 have := hg.2 finiteness end Bilinear section IsBoundedSMul variable {𝕜 α E F : Type*} {m : MeasurableSpace α} {μ : Measure α} [NormedRing 𝕜] [NormedAddCommGroup E] [MulActionWithZero 𝕜 E] [IsBoundedSMul 𝕜 E] [NormedAddCommGroup F] [MulActionWithZero 𝕜 F] [IsBoundedSMul 𝕜 F] {f : α → E} theorem eLpNorm_smul_le_eLpNorm_top_mul_eLpNorm (p : ℝ≥0∞) (hf : AEStronglyMeasurable f μ) (φ : α → 𝕜) : eLpNorm (φ • f) p μ ≤ eLpNorm φ ∞ μ * eLpNorm f p μ := by simpa using (eLpNorm_le_eLpNorm_top_mul_eLpNorm p φ hf (· • ·) 1 (.of_forall fun _ => by simpa using nnnorm_smul_le _ _) :) theorem eLpNorm_smul_le_eLpNorm_mul_eLpNorm_top (p : ℝ≥0∞) (f : α → E) {φ : α → 𝕜} (hφ : AEStronglyMeasurable φ μ) : eLpNorm (φ • f) p μ ≤ eLpNorm φ p μ * eLpNorm f ∞ μ := by simpa using (eLpNorm_le_eLpNorm_mul_eLpNorm_top p hφ f (· • ·) 1 (.of_forall fun _ => by simpa using nnnorm_smul_le _ _) :) theorem eLpNorm'_smul_le_mul_eLpNorm' {p q r : ℝ} {f : α → E} (hf : AEStronglyMeasurable f μ) {φ : α → 𝕜} (hφ : AEStronglyMeasurable φ μ) (hp0_lt : 0 < p) (hpq : p < q) (hpqr : 1 / p = 1 / q + 1 / r) : eLpNorm' (φ • f) p μ ≤ eLpNorm' φ q μ * eLpNorm' f r μ := by simpa using eLpNorm'_le_eLpNorm'_mul_eLpNorm' hφ hf (· • ·) 1 (.of_forall fun _ => by simpa using nnnorm_smul_le _ _) hp0_lt hpq hpqr /-- Hölder's inequality, as an inequality on the `ℒp` seminorm of a scalar product `φ • f`. -/ theorem eLpNorm_smul_le_mul_eLpNorm {p q r : ℝ≥0∞} {f : α → E} (hf : AEStronglyMeasurable f μ) {φ : α → 𝕜} (hφ : AEStronglyMeasurable φ μ) [hpqr : HolderTriple p q r] : eLpNorm (φ • f) r μ ≤ eLpNorm φ p μ * eLpNorm f q μ := by simpa using (eLpNorm_le_eLpNorm_mul_eLpNorm_of_nnnorm hφ hf (· • ·) 1 (.of_forall fun _ => by simpa using nnnorm_smul_le _ _) : _) theorem MemLp.smul {p q r : ℝ≥0∞} {f : α → E} {φ : α → 𝕜} (hf : MemLp f q μ) (hφ : MemLp φ p μ) [hpqr : HolderTriple p q r] : MemLp (φ • f) r μ := ⟨hφ.1.smul hf.1, eLpNorm_smul_le_mul_eLpNorm hf.1 hφ.1 |>.trans_lt <| ENNReal.mul_lt_top hφ.eLpNorm_lt_top hf.eLpNorm_lt_top⟩ end IsBoundedSMul section Mul variable {α : Type*} {_ : MeasurableSpace α} {𝕜 : Type*} [NormedRing 𝕜] {μ : Measure α} {p q r : ℝ≥0∞} {f : α → 𝕜} {φ : α → 𝕜} theorem MemLp.mul (hf : MemLp f q μ) (hφ : MemLp φ p μ) [hpqr : HolderTriple p q r] : MemLp (φ * f) r μ := MemLp.smul hf hφ /-- Variant of `MemLp.mul` where the function is written as `fun x ↦ φ x * f x` instead of `φ * f`. -/ theorem MemLp.mul' (hf : MemLp f q μ) (hφ : MemLp φ p μ) [hpqr : HolderTriple p q r] : MemLp (fun x ↦ φ x * f x) r μ := MemLp.smul hf hφ end Mul section Prod variable {ι α 𝕜 : Type*} {_ : MeasurableSpace α} [NormedCommRing 𝕜] {μ : Measure α} {f : ι → α → 𝕜} {p : ι → ℝ≥0∞} {s : Finset ι} open Finset in /-- See `MemLp.prod'` for the applied version. -/ protected lemma MemLp.prod (hf : ∀ i ∈ s, MemLp (f i) (p i) μ) : MemLp (∏ i ∈ s, f i) (∑ i ∈ s, (p i)⁻¹)⁻¹ μ := by induction s using cons_induction with | empty => by_cases hμ : μ = 0 <;> simp [MemLp, eLpNormEssSup_const, hμ, aestronglyMeasurable_const, Pi.one_def] | cons i s hi ih => rw [prod_cons] exact (ih <| forall_of_forall_cons hf).mul (hf i <| mem_cons_self ..) (hpqr := ⟨by simp⟩) /-- See `MemLp.prod` for the unapplied version. -/ protected lemma MemLp.prod' (hf : ∀ i ∈ s, MemLp (f i) (p i) μ) : MemLp (fun ω ↦ ∏ i ∈ s, f i ω) (∑ i ∈ s, (p i)⁻¹)⁻¹ μ := by simpa [Finset.prod_fn] using MemLp.prod hf end Prod end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Function/LpSeminorm/TriangleInequality.lean
import Mathlib.MeasureTheory.Function.LpSeminorm.Basic import Mathlib.MeasureTheory.Integral.MeanInequalities /-! # Triangle inequality for `Lp`-seminorm In this file we prove several versions of the triangle inequality for the `Lp` seminorm, as well as simple corollaries. -/ open Filter open scoped ENNReal Topology namespace MeasureTheory variable {α E ε ε' : Type*} {m : MeasurableSpace α} [NormedAddCommGroup E] [TopologicalSpace ε] [ESeminormedAddMonoid ε] [TopologicalSpace ε'] [ESeminormedAddCommMonoid ε'] {p : ℝ≥0∞} {q : ℝ} {μ : Measure α} {f g : α → ε} theorem eLpNorm'_add_le (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (hq1 : 1 ≤ q) : eLpNorm' (f + g) q μ ≤ eLpNorm' f q μ + eLpNorm' g q μ := calc (∫⁻ a, ‖(f + g) a‖ₑ ^ q ∂μ) ^ (1 / q) ≤ (∫⁻ a, ((‖f ·‖ₑ) + (‖g ·‖ₑ)) a ^ q ∂μ) ^ (1 / q) := by gcongr with a simp only [Pi.add_apply, enorm_add_le] _ ≤ eLpNorm' f q μ + eLpNorm' g q μ := ENNReal.lintegral_Lp_add_le hf.enorm hg.enorm hq1 theorem eLpNorm'_add_le_of_le_one (hf : AEStronglyMeasurable f μ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) : eLpNorm' (f + g) q μ ≤ 2 ^ (1 / q - 1) * (eLpNorm' f q μ + eLpNorm' g q μ) := calc (∫⁻ a, ‖(f + g) a‖ₑ ^ q ∂μ) ^ (1 / q) ≤ (∫⁻ a, (((‖f ·‖ₑ)) + (‖g ·‖ₑ)) a ^ q ∂μ) ^ (1 / q) := by gcongr with a simp only [Pi.add_apply, enorm_add_le] _ ≤ (2 : ℝ≥0∞) ^ (1 / q - 1) * (eLpNorm' f q μ + eLpNorm' g q μ) := ENNReal.lintegral_Lp_add_le_of_le_one hf.enorm hq0 hq1 theorem eLpNormEssSup_add_le : eLpNormEssSup (f + g) μ ≤ eLpNormEssSup f μ + eLpNormEssSup g μ := by refine le_trans (essSup_mono_ae (Eventually.of_forall fun x => ?_)) (ENNReal.essSup_add_le _ _) simp_rw [Pi.add_apply] exact enorm_add_le _ _ theorem eLpNorm_add_le (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (hp1 : 1 ≤ p) : eLpNorm (f + g) p μ ≤ eLpNorm f p μ + eLpNorm g p μ := by by_cases hp0 : p = 0 · simp [hp0] by_cases hp_top : p = ∞ · simp [hp_top, eLpNormEssSup_add_le] have hp1_real : 1 ≤ p.toReal := by rwa [← ENNReal.toReal_one, ENNReal.toReal_le_toReal ENNReal.one_ne_top hp_top] repeat rw [eLpNorm_eq_eLpNorm' hp0 hp_top] exact eLpNorm'_add_le hf hg hp1_real /-- A constant for the inequality `‖f + g‖_{L^p} ≤ C * (‖f‖_{L^p} + ‖g‖_{L^p})`. It is equal to `1` for `p ≥ 1` or `p = 0`, and `2^(1/p-1)` in the more tricky interval `(0, 1)`. -/ noncomputable def LpAddConst (p : ℝ≥0∞) : ℝ≥0∞ := if p ∈ Set.Ioo (0 : ℝ≥0∞) 1 then (2 : ℝ≥0∞) ^ (1 / p.toReal - 1) else 1 theorem LpAddConst_of_one_le {p : ℝ≥0∞} (hp : 1 ≤ p) : LpAddConst p = 1 := by rw [LpAddConst, if_neg] intro h exact lt_irrefl _ (h.2.trans_le hp) theorem LpAddConst_zero : LpAddConst 0 = 1 := by rw [LpAddConst, if_neg] intro h exact lt_irrefl _ h.1 theorem LpAddConst_lt_top (p : ℝ≥0∞) : LpAddConst p < ∞ := by rw [LpAddConst] split_ifs with h · apply ENNReal.rpow_lt_top_of_nonneg _ ENNReal.ofNat_ne_top rw [one_div, sub_nonneg, ← ENNReal.toReal_inv, ← ENNReal.toReal_one] exact ENNReal.toReal_mono (by simpa using h.1.ne') (ENNReal.one_le_inv.2 h.2.le) · exact ENNReal.one_lt_top theorem eLpNorm_add_le' (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (p : ℝ≥0∞) : eLpNorm (f + g) p μ ≤ LpAddConst p * (eLpNorm f p μ + eLpNorm g p μ) := by rcases eq_or_ne p 0 with (rfl | hp) · simp only [eLpNorm_exponent_zero, add_zero, mul_zero, le_zero_iff] rcases lt_or_ge p 1 with (h'p | h'p) · simp only [eLpNorm_eq_eLpNorm' hp (h'p.trans ENNReal.one_lt_top).ne] convert eLpNorm'_add_le_of_le_one hf ENNReal.toReal_nonneg _ · have : p ∈ Set.Ioo (0 : ℝ≥0∞) 1 := ⟨hp.bot_lt, h'p⟩ simp only [LpAddConst, if_pos this] · simpa using ENNReal.toReal_mono ENNReal.one_ne_top h'p.le · simpa [LpAddConst_of_one_le h'p] using eLpNorm_add_le hf hg h'p variable (μ ε) in /-- Technical lemma to control the addition of functions in `L^p` even for `p < 1`: Given `δ > 0`, there exists `η` such that two functions bounded by `η` in `L^p` have a sum bounded by `δ`. One could take `η = δ / 2` for `p ≥ 1`, but the point of the lemma is that it works also for `p < 1`. -/ theorem exists_Lp_half (p : ℝ≥0∞) {δ : ℝ≥0∞} (hδ : δ ≠ 0) : ∃ η : ℝ≥0∞, 0 < η ∧ ∀ (f g : α → ε), AEStronglyMeasurable f μ → AEStronglyMeasurable g μ → eLpNorm f p μ ≤ η → eLpNorm g p μ ≤ η → eLpNorm (f + g) p μ < δ := by have : Tendsto (fun η : ℝ≥0∞ => LpAddConst p * (η + η)) (𝓝[>] 0) (𝓝 (LpAddConst p * (0 + 0))) := (ENNReal.Tendsto.const_mul (tendsto_id.add tendsto_id) (Or.inr (LpAddConst_lt_top p).ne)).mono_left nhdsWithin_le_nhds simp only [add_zero, mul_zero] at this rcases (((tendsto_order.1 this).2 δ hδ.bot_lt).and self_mem_nhdsWithin).exists with ⟨η, hη, ηpos⟩ refine ⟨η, ηpos, fun f g hf hg Hf Hg => ?_⟩ calc eLpNorm (f + g) p μ ≤ LpAddConst p * (eLpNorm f p μ + eLpNorm g p μ) := eLpNorm_add_le' hf hg p _ ≤ LpAddConst p * (η + η) := by gcongr _ < δ := hη theorem eLpNorm_sub_le' {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (p : ℝ≥0∞) : eLpNorm (f - g) p μ ≤ LpAddConst p * (eLpNorm f p μ + eLpNorm g p μ) := by simpa only [sub_eq_add_neg, eLpNorm_neg] using eLpNorm_add_le' hf hg.neg p theorem eLpNorm_sub_le {f g : α → E} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (hp : 1 ≤ p) : eLpNorm (f - g) p μ ≤ eLpNorm f p μ + eLpNorm g p μ := by simpa [LpAddConst_of_one_le hp] using eLpNorm_sub_le' hf hg p theorem eLpNorm_add_lt_top (hf : MemLp f p μ) (hg : MemLp g p μ) : eLpNorm (f + g) p μ < ∞ := calc eLpNorm (f + g) p μ ≤ LpAddConst p * (eLpNorm f p μ + eLpNorm g p μ) := eLpNorm_add_le' hf.aestronglyMeasurable hg.aestronglyMeasurable p _ < ∞ := by apply ENNReal.mul_lt_top (LpAddConst_lt_top p) exact ENNReal.add_lt_top.2 ⟨hf.2, hg.2⟩ theorem eLpNorm'_sum_le [ContinuousAdd ε'] {ι} {f : ι → α → ε'} {s : Finset ι} (hfs : ∀ i, i ∈ s → AEStronglyMeasurable (f i) μ) (hq1 : 1 ≤ q) : eLpNorm' (∑ i ∈ s, f i) q μ ≤ ∑ i ∈ s, eLpNorm' (f i) q μ := Finset.le_sum_of_subadditive_on_pred (fun f : α → ε' => eLpNorm' f q μ) (fun f => AEStronglyMeasurable f μ) (eLpNorm'_zero (zero_lt_one.trans_le hq1)).le (fun _f _g hf hg => eLpNorm'_add_le hf hg hq1) (fun _f _g hf hg => hf.add hg) _ hfs theorem eLpNorm_sum_le [ContinuousAdd ε'] {ι} {f : ι → α → ε'} {s : Finset ι} (hfs : ∀ i, i ∈ s → AEStronglyMeasurable (f i) μ) (hp1 : 1 ≤ p) : eLpNorm (∑ i ∈ s, f i) p μ ≤ ∑ i ∈ s, eLpNorm (f i) p μ := Finset.le_sum_of_subadditive_on_pred (fun f : α → ε' => eLpNorm f p μ) (fun f => AEStronglyMeasurable f μ) eLpNorm_zero.le (fun _f _g hf hg => eLpNorm_add_le hf hg hp1) (fun _f _g hf hg => hf.add hg) _ hfs theorem MemLp.add [ContinuousAdd ε] (hf : MemLp f p μ) (hg : MemLp g p μ) : MemLp (f + g) p μ := ⟨AEStronglyMeasurable.add hf.1 hg.1, eLpNorm_add_lt_top hf hg⟩ theorem MemLp.sub {f g : α → E} (hf : MemLp f p μ) (hg : MemLp g p μ) : MemLp (f - g) p μ := by rw [sub_eq_add_neg] exact hf.add hg.neg theorem memLp_finset_sum [ContinuousAdd ε'] {ι} (s : Finset ι) {f : ι → α → ε'} (hf : ∀ i ∈ s, MemLp (f i) p μ) : MemLp (fun a => ∑ i ∈ s, f i a) p μ := by haveI : DecidableEq ι := Classical.decEq _ revert hf refine Finset.induction_on s ?_ ?_ · simp only [MemLp.zero', Finset.sum_empty, imp_true_iff] · intro i s his ih hf simp only [his, Finset.sum_insert, not_false_iff] exact (hf i (s.mem_insert_self i)).add (ih fun j hj => hf j (Finset.mem_insert_of_mem hj)) theorem memLp_finset_sum' [ContinuousAdd ε'] {ι} (s : Finset ι) {f : ι → α → ε'} (hf : ∀ i ∈ s, MemLp (f i) p μ) : MemLp (∑ i ∈ s, f i) p μ := by convert memLp_finset_sum s hf using 1 ext x simp end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/Trim.lean
import Mathlib.MeasureTheory.Measure.Typeclasses.SFinite /-! # Restriction of a measure to a sub-σ-algebra ## Main definitions * `MeasureTheory.Measure.trim`: restriction of a measure to a sub-sigma algebra. -/ open scoped ENNReal namespace MeasureTheory variable {α β : Type*} /-- Restriction of a measure to a sub-σ-algebra. It is common to see a measure `μ` on a measurable space structure `m0` as being also a measure on any `m ≤ m0`. Since measures in mathlib have to be trimmed to the measurable space, `μ` itself cannot be a measure on `m`, hence the definition of `μ.trim hm`. This notion is related to `OuterMeasure.trim`, see the lemma `toOuterMeasure_trim_eq_trim_toOuterMeasure`. -/ noncomputable def Measure.trim {m m0 : MeasurableSpace α} (μ : @Measure α m0) (hm : m ≤ m0) : @Measure α m := @OuterMeasure.toMeasure α m μ.toOuterMeasure (hm.trans (le_toOuterMeasure_caratheodory μ)) @[simp] theorem trim_eq_self [MeasurableSpace α] {μ : Measure α} : μ.trim le_rfl = μ := by simp [Measure.trim] variable {m m0 : MeasurableSpace α} {mβ : MeasurableSpace β} {μ : Measure α} {s : Set α} theorem toOuterMeasure_trim_eq_trim_toOuterMeasure (μ : Measure α) (hm : m ≤ m0) : @Measure.toOuterMeasure _ m (μ.trim hm) = @OuterMeasure.trim _ m μ.toOuterMeasure := by rw [Measure.trim, toMeasure_toOuterMeasure (ms := m)] @[simp] theorem zero_trim (hm : m ≤ m0) : (0 : Measure α).trim hm = (0 : @Measure α m) := by simp [Measure.trim, @OuterMeasure.toMeasure_zero _ m] theorem trim_measurableSet_eq (hm : m ≤ m0) (hs : @MeasurableSet α m s) : μ.trim hm s = μ s := by rw [Measure.trim, toMeasure_apply (ms := m) _ _ hs, Measure.coe_toOuterMeasure] theorem le_trim (hm : m ≤ m0) : μ s ≤ μ.trim hm s := by simp_rw [Measure.trim] exact @le_toMeasure_apply _ m _ _ _ lemma trim_eq_map (hm : m ≤ m0) : μ.trim hm = @Measure.map _ _ _ m id μ := by refine @Measure.ext α m _ _ (fun s hs ↦ ?_) rw [Measure.map_apply (measurable_id'' hm) hs, trim_measurableSet_eq hm hs, Set.preimage_id] lemma map_trim_comap {f : α → β} (hf : Measurable f) : @Measure.map _ _ (mβ.comap f) _ f (μ.trim hf.comap_le) = μ.map f := by ext s hs rw [Measure.map_apply hf hs, Measure.map_apply _ hs, trim_measurableSet_eq] · exact ⟨s, hs, rfl⟩ · exact Measurable.of_comap_le le_rfl lemma trim_comap_apply {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) : μ.trim hf.comap_le (f ⁻¹' s) = μ.map f s := by rw [← map_trim_comap hf, Measure.map_apply (Measurable.of_comap_le le_rfl) hs] lemma ae_map_iff_ae_trim {f : α → β} (hf : Measurable f) {p : β → Prop} (hp : MeasurableSet { x | p x }) : (∀ᵐ y ∂μ.map f, p y) ↔ ∀ᵐ x ∂(μ.trim hf.comap_le), p (f x) := by rw [← map_trim_comap hf, ae_map_iff (Measurable.of_comap_le le_rfl).aemeasurable hp] lemma trim_add {ν : Measure α} (hm : m ≤ m0) : (μ + ν).trim hm = μ.trim hm + ν.trim hm := @Measure.ext _ m _ _ (fun s hs ↦ by simp [trim_measurableSet_eq hm hs]) theorem measure_eq_zero_of_trim_eq_zero (hm : m ≤ m0) (h : μ.trim hm s = 0) : μ s = 0 := le_antisymm ((le_trim hm).trans (le_of_eq h)) (zero_le _) theorem measure_trim_toMeasurable_eq_zero {hm : m ≤ m0} (hs : μ.trim hm s = 0) : μ (@toMeasurable α m (μ.trim hm) s) = 0 := measure_eq_zero_of_trim_eq_zero hm (by rwa [@measure_toMeasurable _ m]) theorem ae_of_ae_trim (hm : m ≤ m0) {μ : Measure α} {P : α → Prop} (h : ∀ᵐ x ∂μ.trim hm, P x) : ∀ᵐ x ∂μ, P x := measure_eq_zero_of_trim_eq_zero hm h theorem ae_eq_of_ae_eq_trim {E} {hm : m ≤ m0} {f₁ f₂ : α → E} (h12 : f₁ =ᵐ[μ.trim hm] f₂) : f₁ =ᵐ[μ] f₂ := measure_eq_zero_of_trim_eq_zero hm h12 theorem ae_le_of_ae_le_trim {E} [LE E] {hm : m ≤ m0} {f₁ f₂ : α → E} (h12 : f₁ ≤ᵐ[μ.trim hm] f₂) : f₁ ≤ᵐ[μ] f₂ := measure_eq_zero_of_trim_eq_zero hm h12 theorem trim_trim {m₁ m₂ : MeasurableSpace α} {hm₁₂ : m₁ ≤ m₂} {hm₂ : m₂ ≤ m0} : (μ.trim hm₂).trim hm₁₂ = μ.trim (hm₁₂.trans hm₂) := by refine @Measure.ext _ m₁ _ _ (fun t ht => ?_) rw [trim_measurableSet_eq hm₁₂ ht, trim_measurableSet_eq (hm₁₂.trans hm₂) ht, trim_measurableSet_eq hm₂ (hm₁₂ t ht)] theorem restrict_trim (hm : m ≤ m0) (μ : Measure α) (hs : @MeasurableSet α m s) : @Measure.restrict α m (μ.trim hm) s = (μ.restrict s).trim hm := by refine @Measure.ext _ m _ _ (fun t ht => ?_) rw [@Measure.restrict_apply α m _ _ _ ht, trim_measurableSet_eq hm ht, Measure.restrict_apply (hm t ht), trim_measurableSet_eq hm (@MeasurableSet.inter α m t s ht hs)] instance isFiniteMeasure_trim (hm : m ≤ m0) [IsFiniteMeasure μ] : IsFiniteMeasure (μ.trim hm) where measure_univ_lt_top := by rw [trim_measurableSet_eq hm (@MeasurableSet.univ _ m)] exact measure_lt_top _ _ theorem sigmaFiniteTrim_mono {m m₂ m0 : MeasurableSpace α} {μ : Measure α} (hm : m ≤ m0) (hm₂ : m₂ ≤ m) [SigmaFinite (μ.trim (hm₂.trans hm))] : SigmaFinite (μ.trim hm) := by refine ⟨⟨?_⟩⟩ refine { set := spanningSets (μ.trim (hm₂.trans hm)) set_mem := fun _ => Set.mem_univ _ finite := fun i => ?_ spanning := iUnion_spanningSets _ } calc (μ.trim hm) (spanningSets (μ.trim (hm₂.trans hm)) i) = ((μ.trim hm).trim hm₂) (spanningSets (μ.trim (hm₂.trans hm)) i) := by rw [@trim_measurableSet_eq α m₂ m (μ.trim hm) _ hm₂ (measurableSet_spanningSets _ _)] _ = (μ.trim (hm₂.trans hm)) (spanningSets (μ.trim (hm₂.trans hm)) i) := by rw [@trim_trim _ _ μ _ _ hm₂ hm] _ < ∞ := measure_spanningSets_lt_top _ _ theorem sigmaFinite_trim_bot_iff : SigmaFinite (μ.trim bot_le) ↔ IsFiniteMeasure μ := by rw [sigmaFinite_bot_iff] refine ⟨fun h => ⟨?_⟩, fun h => ⟨?_⟩⟩ <;> have h_univ := h.measure_univ_lt_top · rwa [trim_measurableSet_eq bot_le MeasurableSet.univ] at h_univ · rwa [trim_measurableSet_eq bot_le MeasurableSet.univ] lemma Measure.AbsolutelyContinuous.trim {ν : Measure α} (hμν : μ ≪ ν) (hm : m ≤ m0) : μ.trim hm ≪ ν.trim hm := by refine Measure.AbsolutelyContinuous.mk (fun s hs hsν ↦ ?_) rw [trim_measurableSet_eq hm hs] at hsν ⊢ exact hμν hsν end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/MutuallySingular.lean
import Mathlib.MeasureTheory.Measure.Restrict /-! # Mutually singular measures Two measures `μ`, `ν` are said to be mutually singular (`MeasureTheory.Measure.MutuallySingular`, localized notation `μ ⟂ₘ ν`) if there exists a measurable set `s` such that `μ s = 0` and `ν sᶜ = 0`. The measurability of `s` is an unnecessary assumption (see `MeasureTheory.Measure.MutuallySingular.mk`) but we keep it because this way `rcases (h : μ ⟂ₘ ν)` gives us a measurable set and usually it is easy to prove measurability. In this file we define the predicate `MeasureTheory.Measure.MutuallySingular` and prove basic facts about it. ## Tags measure, mutually singular -/ open Set open MeasureTheory NNReal ENNReal Filter namespace MeasureTheory namespace Measure variable {α : Type*} {m0 : MeasurableSpace α} {μ μ₁ μ₂ ν ν₁ ν₂ : Measure α} /-- Two measures `μ`, `ν` are said to be mutually singular if there exists a measurable set `s` such that `μ s = 0` and `ν sᶜ = 0`. -/ def MutuallySingular {_ : MeasurableSpace α} (μ ν : Measure α) : Prop := ∃ s : Set α, MeasurableSet s ∧ μ s = 0 ∧ ν sᶜ = 0 @[inherit_doc MeasureTheory.Measure.MutuallySingular] scoped[MeasureTheory] infixl:60 " ⟂ₘ " => MeasureTheory.Measure.MutuallySingular namespace MutuallySingular theorem mk {s t : Set α} (hs : μ s = 0) (ht : ν t = 0) (hst : univ ⊆ s ∪ t) : MutuallySingular μ ν := by use toMeasurable μ s, measurableSet_toMeasurable _ _, (measure_toMeasurable _).trans hs refine measure_mono_null (fun x hx => (hst trivial).resolve_left fun hxs => hx ?_) ht exact subset_toMeasurable _ _ hxs /-- A set such that `μ h.nullSet = 0` and `ν h.nullSetᶜ = 0`. -/ def nullSet (h : μ ⟂ₘ ν) : Set α := h.choose lemma measurableSet_nullSet (h : μ ⟂ₘ ν) : MeasurableSet h.nullSet := h.choose_spec.1 @[simp] lemma measure_nullSet (h : μ ⟂ₘ ν) : μ h.nullSet = 0 := h.choose_spec.2.1 @[simp] lemma measure_compl_nullSet (h : μ ⟂ₘ ν) : ν h.nullSetᶜ = 0 := h.choose_spec.2.2 -- TODO: this is proved by simp, but is not simplified in other contexts without the @[simp] -- attribute. Also, the linter does not complain about that attribute. @[simp] lemma restrict_nullSet (h : μ ⟂ₘ ν) : μ.restrict h.nullSet = 0 := by simp -- TODO: this is proved by simp, but is not simplified in other contexts without the @[simp] -- attribute. Also, the linter does not complain about that attribute. @[simp] lemma restrict_compl_nullSet (h : μ ⟂ₘ ν) : ν.restrict h.nullSetᶜ = 0 := by simp @[simp] theorem zero_right : μ ⟂ₘ 0 := ⟨∅, MeasurableSet.empty, measure_empty, rfl⟩ @[symm] theorem symm (h : ν ⟂ₘ μ) : μ ⟂ₘ ν := let ⟨i, hi, his, hit⟩ := h ⟨iᶜ, hi.compl, hit, (compl_compl i).symm ▸ his⟩ theorem comm : μ ⟂ₘ ν ↔ ν ⟂ₘ μ := ⟨fun h => h.symm, fun h => h.symm⟩ @[simp] theorem zero_left : 0 ⟂ₘ μ := zero_right.symm theorem mono_ac (h : μ₁ ⟂ₘ ν₁) (hμ : μ₂ ≪ μ₁) (hν : ν₂ ≪ ν₁) : μ₂ ⟂ₘ ν₂ := let ⟨s, hs, h₁, h₂⟩ := h ⟨s, hs, hμ h₁, hν h₂⟩ lemma congr_ac (hμμ₂ : μ ≪ μ₂) (hμ₂μ : μ₂ ≪ μ) (hνν₂ : ν ≪ ν₂) (hν₂ν : ν₂ ≪ ν) : μ ⟂ₘ ν ↔ μ₂ ⟂ₘ ν₂ := ⟨fun h ↦ h.mono_ac hμ₂μ hν₂ν, fun h ↦ h.mono_ac hμμ₂ hνν₂⟩ theorem mono (h : μ₁ ⟂ₘ ν₁) (hμ : μ₂ ≤ μ₁) (hν : ν₂ ≤ ν₁) : μ₂ ⟂ₘ ν₂ := h.mono_ac hμ.absolutelyContinuous hν.absolutelyContinuous @[simp] lemma self_iff (μ : Measure α) : μ ⟂ₘ μ ↔ μ = 0 := by refine ⟨?_, fun h ↦ by (rw [h]; exact zero_left)⟩ rintro ⟨s, hs, hμs, hμs_compl⟩ suffices μ Set.univ = 0 by rwa [measure_univ_eq_zero] at this rw [← Set.union_compl_self s, measure_union disjoint_compl_right hs.compl, hμs, hμs_compl, add_zero] @[simp] theorem sum_left {ι : Type*} [Countable ι] {μ : ι → Measure α} : sum μ ⟂ₘ ν ↔ ∀ i, μ i ⟂ₘ ν := by refine ⟨fun h i => h.mono (le_sum _ _) le_rfl, fun H => ?_⟩ choose s hsm hsμ hsν using H refine ⟨⋂ i, s i, MeasurableSet.iInter hsm, ?_, ?_⟩ · rw [sum_apply _ (MeasurableSet.iInter hsm), ENNReal.tsum_eq_zero] exact fun i => measure_mono_null (iInter_subset _ _) (hsμ i) · rwa [compl_iInter, measure_iUnion_null_iff] @[simp] theorem sum_right {ι : Type*} [Countable ι] {ν : ι → Measure α} : μ ⟂ₘ sum ν ↔ ∀ i, μ ⟂ₘ ν i := comm.trans <| sum_left.trans <| forall_congr' fun _ => comm @[simp] theorem add_left_iff : μ₁ + μ₂ ⟂ₘ ν ↔ μ₁ ⟂ₘ ν ∧ μ₂ ⟂ₘ ν := by rw [← sum_cond, sum_left, Bool.forall_bool, cond, cond, and_comm] @[simp] theorem add_right_iff : μ ⟂ₘ ν₁ + ν₂ ↔ μ ⟂ₘ ν₁ ∧ μ ⟂ₘ ν₂ := comm.trans <| add_left_iff.trans <| and_congr comm comm theorem add_left (h₁ : ν₁ ⟂ₘ μ) (h₂ : ν₂ ⟂ₘ μ) : ν₁ + ν₂ ⟂ₘ μ := add_left_iff.2 ⟨h₁, h₂⟩ theorem add_right (h₁ : μ ⟂ₘ ν₁) (h₂ : μ ⟂ₘ ν₂) : μ ⟂ₘ ν₁ + ν₂ := add_right_iff.2 ⟨h₁, h₂⟩ theorem smul (r : ℝ≥0∞) (h : ν ⟂ₘ μ) : r • ν ⟂ₘ μ := h.mono_ac (AbsolutelyContinuous.rfl.smul_left r) AbsolutelyContinuous.rfl theorem smul_nnreal (r : ℝ≥0) (h : ν ⟂ₘ μ) : r • ν ⟂ₘ μ := h.smul r lemma restrict (h : μ ⟂ₘ ν) (s : Set α) : μ.restrict s ⟂ₘ ν := by refine ⟨h.nullSet, h.measurableSet_nullSet, ?_, h.measure_compl_nullSet⟩ rw [Measure.restrict_apply h.measurableSet_nullSet] exact measure_mono_null Set.inter_subset_left h.measure_nullSet end MutuallySingular lemma eq_zero_of_absolutelyContinuous_of_mutuallySingular {μ ν : Measure α} (h_ac : μ ≪ ν) (h_ms : μ ⟂ₘ ν) : μ = 0 := by rw [← Measure.MutuallySingular.self_iff] exact h_ms.mono_ac Measure.AbsolutelyContinuous.rfl h_ac lemma absolutelyContinuous_of_add_of_mutuallySingular {ν₁ ν₂ : Measure α} (h : μ ≪ ν₁ + ν₂) (h_ms : μ ⟂ₘ ν₂) : μ ≪ ν₁ := by refine AbsolutelyContinuous.mk fun s hs hs_zero ↦ ?_ let t := h_ms.nullSet have ht : MeasurableSet t := h_ms.measurableSet_nullSet have htμ : μ t = 0 := h_ms.measure_nullSet have htν₂ : ν₂ tᶜ = 0 := h_ms.measure_compl_nullSet have : μ s = μ (s ∩ tᶜ) := by conv_lhs => rw [← inter_union_compl s t] rw [measure_union, measure_inter_null_of_null_right _ htμ, zero_add] · exact (disjoint_compl_right.inter_right' _ ).inter_left' _ · exact hs.inter ht.compl rw [this] refine h ?_ simp only [Measure.coe_add, Pi.add_apply, add_eq_zero] exact ⟨measure_inter_null_of_null_left _ hs_zero, measure_inter_null_of_null_right _ htν₂⟩ lemma _root_.MeasurableEmbedding.mutuallySingular_map {β : Type*} {_ : MeasurableSpace β} {f : α → β} (hf : MeasurableEmbedding f) (hμν : μ ⟂ₘ ν) : μ.map f ⟂ₘ ν.map f := by refine ⟨f '' hμν.nullSet, hf.measurableSet_image' hμν.measurableSet_nullSet, ?_, ?_⟩ · rw [hf.map_apply, hf.injective.preimage_image, hμν.measure_nullSet] · rw [hf.map_apply, Set.preimage_compl, hf.injective.preimage_image, hμν.measure_compl_nullSet] lemma exists_null_set_measure_lt_of_disjoint (h : Disjoint μ ν) {ε : ℝ≥0} (hε : 0 < ε) : ∃ s, μ s = 0 ∧ ν sᶜ ≤ 2 * ε := by have h₁ : (μ ⊓ ν) univ = 0 := le_bot_iff.1 (h (inf_le_left (b := ν)) inf_le_right) ▸ rfl simp_rw [Measure.inf_apply MeasurableSet.univ, inter_univ] at h₁ have h₂ : ∀ n : ℕ, ∃ t, μ t + ν tᶜ < ε * (1 / 2) ^ n := by intro n obtain ⟨m, ⟨t, ht₁, rfl⟩, hm₂⟩ : ∃ x ∈ {m | ∃ t, m = μ t + ν tᶜ}, x < ε * (1 / 2 : ℝ≥0∞) ^ n := by refine exists_lt_of_csInf_lt ⟨ν univ, ∅, by simp⟩ <| h₁ ▸ ENNReal.mul_pos ?_ (by simp) norm_cast exact hε.ne.symm exact ⟨t, hm₂⟩ choose t ht₂ using h₂ refine ⟨⋂ n, t n, ?_, ?_⟩ · refine eq_zero_of_le_mul_pow (by simp) fun n ↦ ((measure_mono <| iInter_subset_of_subset n fun _ ht ↦ ht).trans (le_add_right le_rfl)).trans (ht₂ n).le · rw [compl_iInter, (by simp [ENNReal.tsum_mul_left, mul_comm] : 2 * (ε : ℝ≥0∞) = ∑' (n : ℕ), ε * (1 / 2 : ℝ≥0∞) ^ n)] refine (measure_iUnion_le _).trans ?_ exact ENNReal.summable.tsum_le_tsum (fun n ↦ (le_add_left le_rfl).trans (ht₂ n).le) ENNReal.summable lemma mutuallySingular_of_disjoint (h : Disjoint μ ν) : μ ⟂ₘ ν := by have h' (n : ℕ) : ∃ s, μ s = 0 ∧ ν sᶜ ≤ (1 / 2) ^ n := by convert exists_null_set_measure_lt_of_disjoint h (ε := (1 / 2) ^ (n + 1)) <| pow_pos (by simp) (n + 1) push_cast rw [pow_succ, ← mul_assoc, mul_comm, ← mul_assoc] norm_cast rw [div_mul_cancel₀, one_mul] · push_cast simp · simp choose s hs₂ hs₃ using h' refine Measure.MutuallySingular.mk (t := (⋃ n, s n)ᶜ) (measure_iUnion_null hs₂) ?_ ?_ · rw [compl_iUnion] refine eq_zero_of_le_mul_pow (ε := 1) (by simp : (1 / 2 : ℝ≥0∞) < 1) <| fun n ↦ ?_ rw [ENNReal.coe_one, one_mul] exact (measure_mono <| iInter_subset_of_subset n fun _ ht ↦ ht).trans (hs₃ n) · rw [union_compl_self] lemma MutuallySingular.disjoint (h : μ ⟂ₘ ν) : Disjoint μ ν := by have h_bot_iff (ξ : Measure α) : ξ ≤ ⊥ ↔ ξ = 0 := by rw [le_bot_iff] rfl intro ξ hξμ hξν rw [h_bot_iff] ext s hs simp only [Measure.coe_zero, Pi.zero_apply] rw [← inter_union_compl s h.nullSet, measure_union, add_eq_zero] · exact ⟨measure_inter_null_of_null_right _ <| absolutelyContinuous_of_le hξμ h.measure_nullSet, measure_inter_null_of_null_right _ <| absolutelyContinuous_of_le hξν h.measure_compl_nullSet⟩ · exact Disjoint.mono inter_subset_right inter_subset_right disjoint_compl_right · exact hs.inter h.measurableSet_nullSet.compl lemma MutuallySingular.disjoint_ae (h : μ ⟂ₘ ν) : Disjoint (ae μ) (ae ν) := by rw [disjoint_iff_inf_le] intro s _ refine ⟨s ∪ h.nullSetᶜ, ?_, s ∪ h.nullSet, ?_, ?_⟩ · rw [mem_ae_iff, compl_union, compl_compl] exact measure_inter_null_of_null_right _ h.measure_nullSet · rw [mem_ae_iff, compl_union] exact measure_inter_null_of_null_right _ h.measure_compl_nullSet · rw [union_eq_compl_compl_inter_compl, union_eq_compl_compl_inter_compl, ← compl_union, compl_compl, inter_union_compl, compl_compl] lemma disjoint_of_disjoint_ae (h : Disjoint (ae μ) (ae ν)) : Disjoint μ ν := by rw [disjoint_iff_inf_le] at h ⊢ refine Measure.le_intro fun s hs _ ↦ ?_ rw [Measure.inf_apply hs] have : (⊥ : Measure α) = 0 := rfl simp only [this, Measure.coe_zero, Pi.zero_apply, nonpos_iff_eq_zero] specialize h (mem_bot (s := sᶜ)) rw [mem_inf_iff] at h obtain ⟨t₁, ht₁, t₂, ht₂, h_eq'⟩ := h have h_eq : s = t₁ᶜ ∪ t₂ᶜ := by rw [union_eq_compl_compl_inter_compl, compl_compl, compl_compl, ← h_eq', compl_compl] rw [mem_ae_iff] at ht₁ ht₂ refine le_antisymm ?_ zero_le' refine sInf_le_of_le (a := 0) (b := 0) ?_ le_rfl rw [h_eq] refine ⟨t₁ᶜ ∩ t₂, Eq.symm ?_⟩ rw [add_eq_zero] constructor · refine measure_inter_null_of_null_left _ ?_ exact measure_inter_null_of_null_left _ ht₁ · rw [compl_inter, compl_compl, union_eq_compl_compl_inter_compl, union_eq_compl_compl_inter_compl, ← compl_union, compl_compl, compl_compl, inter_comm, inter_comm t₁, union_comm, inter_union_compl] exact ht₂ lemma mutuallySingular_tfae : List.TFAE [ μ ⟂ₘ ν, Disjoint μ ν, Disjoint (ae μ) (ae ν) ] := by tfae_have 1 → 2 | h => h.disjoint tfae_have 2 → 1 | h => mutuallySingular_of_disjoint h tfae_have 1 → 3 | h => h.disjoint_ae tfae_have 3 → 2 | h => disjoint_of_disjoint_ae h tfae_finish lemma mutuallySingular_iff_disjoint : μ ⟂ₘ ν ↔ Disjoint μ ν := mutuallySingular_tfae.out 0 1 lemma mutuallySingular_iff_disjoint_ae : μ ⟂ₘ ν ↔ Disjoint (ae μ) (ae ν) := mutuallySingular_tfae.out 0 2 end Measure end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/Count.lean
import Mathlib.MeasureTheory.Measure.Dirac import Mathlib.Topology.Algebra.InfiniteSum.ENNReal /-! # Counting measure In this file we define the counting measure `MeasureTheory.Measure.count` as `MeasureTheory.Measure.sum MeasureTheory.Measure.dirac` and prove basic properties of this measure. -/ open Set open scoped ENNReal Finset variable {α β : Type*} [MeasurableSpace α] [MeasurableSpace β] {s : Set α} noncomputable section namespace MeasureTheory.Measure /-- Counting measure on any measurable space. -/ def count : Measure α := sum dirac @[simp] lemma count_ne_zero'' [Nonempty α] : (count : Measure α) ≠ 0 := by simp [count] theorem le_count_apply : ∑' _ : s, (1 : ℝ≥0∞) ≤ count s := calc (∑' _ : s, 1 : ℝ≥0∞) = ∑' i, indicator s 1 i := tsum_subtype s 1 _ ≤ ∑' i, dirac i s := ENNReal.tsum_le_tsum fun _ => le_dirac_apply _ ≤ count s := le_sum_apply _ _ theorem count_apply (hs : MeasurableSet s) : count s = s.encard := by simp [count, hs, ← tsum_subtype] @[simp] theorem count_apply_finset' {s : Finset α} (hs : MeasurableSet (s : Set α)) : count (↑s : Set α) = #s := by simp [count_apply hs] @[simp] theorem count_apply_finset [MeasurableSingletonClass α] (s : Finset α) : count (↑s : Set α) = #s := count_apply_finset' s.measurableSet theorem count_apply_finite' {s : Set α} (s_fin : s.Finite) (s_mble : MeasurableSet s) : count s = #s_fin.toFinset := by simp [← @count_apply_finset' _ _ s_fin.toFinset (by simpa only [Finite.coe_toFinset] using s_mble)] theorem count_apply_finite [MeasurableSingletonClass α] (s : Set α) (hs : s.Finite) : count s = #hs.toFinset := by rw [← count_apply_finset, Finite.coe_toFinset] /-- `count` measure evaluates to infinity at infinite sets. -/ theorem count_apply_infinite (hs : s.Infinite) : count s = ∞ := by refine top_unique (le_of_tendsto' ENNReal.tendsto_nat_nhds_top fun n => ?_) rcases hs.exists_subset_card_eq n with ⟨t, ht, rfl⟩ calc (#t : ℝ≥0∞) = ∑ i ∈ t, 1 := by simp _ = ∑' i : (t : Set α), 1 := (t.tsum_subtype 1).symm _ ≤ count (t : Set α) := le_count_apply _ ≤ count s := measure_mono ht @[simp] theorem count_apply_eq_top' (s_mble : MeasurableSet s) : count s = ∞ ↔ s.Infinite := by by_cases hs : s.Finite · simp [Set.Infinite, hs, count_apply_finite' hs s_mble] · change s.Infinite at hs simp [hs, count_apply_infinite] @[simp] theorem count_apply_eq_top [MeasurableSingletonClass α] : count s = ∞ ↔ s.Infinite := by by_cases hs : s.Finite · exact count_apply_eq_top' hs.measurableSet · change s.Infinite at hs simp [hs, count_apply_infinite] @[simp] theorem count_apply_lt_top' (s_mble : MeasurableSet s) : count s < ∞ ↔ s.Finite := calc count s < ∞ ↔ count s ≠ ∞ := lt_top_iff_ne_top _ ↔ ¬s.Infinite := not_congr (count_apply_eq_top' s_mble) _ ↔ s.Finite := Classical.not_not @[simp] theorem count_apply_lt_top [MeasurableSingletonClass α] : count s < ∞ ↔ s.Finite := calc count s < ∞ ↔ count s ≠ ∞ := lt_top_iff_ne_top _ ↔ ¬s.Infinite := not_congr count_apply_eq_top _ ↔ s.Finite := Classical.not_not @[simp] theorem count_eq_zero_iff : count s = 0 ↔ s = ∅ where mp h := eq_empty_of_forall_notMem fun x hx ↦ by simpa [hx] using ((ENNReal.le_tsum x).trans <| le_sum_apply _ _).trans_eq h mpr := by rintro rfl; exact measure_empty lemma count_ne_zero_iff : count s ≠ 0 ↔ s.Nonempty := count_eq_zero_iff.not.trans nonempty_iff_ne_empty.symm alias ⟨_, count_ne_zero⟩ := count_ne_zero_iff @[simp] lemma ae_count_iff {p : α → Prop} : (∀ᵐ x ∂count, p x) ↔ ∀ x, p x := by refine ⟨fun h x ↦ ?_, ae_of_all _⟩ rw [ae_iff, count_eq_zero_iff] at h by_contra hx rwa [← mem_empty_iff_false x, ← h] @[simp] theorem count_singleton' {a : α} (ha : MeasurableSet ({a} : Set α)) : count ({a} : Set α) = 1 := by rw [count_apply_finite' (Set.finite_singleton a) ha, Set.Finite.toFinset] simp [ ] theorem count_singleton [MeasurableSingletonClass α] (a : α) : count ({a} : Set α) = 1 := count_singleton' (measurableSet_singleton a) @[simp] theorem _root_.MeasureTheory.count_real_singleton' {a : α} (ha : MeasurableSet ({a} : Set α)) : count.real ({a} : Set α) = 1 := by rw [measureReal_def, count_singleton' ha, ENNReal.toReal_one] theorem _root_.MeasureTheory.count_real_singleton [MeasurableSingletonClass α] (a : α) : count.real ({a} : Set α) = 1 := count_real_singleton' (measurableSet_singleton a) theorem count_injective_image' {f : β → α} (hf : Function.Injective f) {s : Set β} (s_mble : MeasurableSet s) (fs_mble : MeasurableSet (f '' s)) : count (f '' s) = count s := by classical by_cases hs : s.Finite · lift s to Finset β using hs rw [← Finset.coe_image, count_apply_finset' _, count_apply_finset' s_mble, s.card_image_of_injective hf] simpa only [Finset.coe_image] using fs_mble · rw [count_apply_infinite hs] rw [← finite_image_iff hf.injOn] at hs rw [count_apply_infinite hs] theorem count_injective_image [MeasurableSingletonClass α] [MeasurableSingletonClass β] {f : β → α} (hf : Function.Injective f) (s : Set β) : count (f '' s) = count s := by by_cases hs : s.Finite · exact count_injective_image' hf hs.measurableSet (Finite.image f hs).measurableSet rw [count_apply_infinite hs] rw [← finite_image_iff hf.injOn] at hs rw [count_apply_infinite hs] instance count.instSigmaFinite [MeasurableSingletonClass α] [Countable α] : SigmaFinite (count : Measure α) := by simp [sigmaFinite_iff_measure_singleton_lt_top] instance count.isFiniteMeasure [Finite α] : IsFiniteMeasure (Measure.count : Measure α) := ⟨by simp [Measure.count_apply]⟩ @[simp] lemma count_univ : count (univ : Set α) = ENat.card α := by simp [count_apply .univ, encard_univ] end Measure end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/SeparableMeasure.lean
import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp import Mathlib.MeasureTheory.SetAlgebra /-! # Separable measure The goal of this file is to give a sufficient condition on the measure space `(X, μ)` and the `NormedAddCommGroup E` for the space `MeasureTheory.Lp E p μ` to have `SecondCountableTopology` when `1 ≤ p < ∞`. To do so we define the notion of a `MeasureTheory.MeasureDense` family and a separable measure (`MeasureTheory.IsSeparable`). We prove that if `X` is `MeasurableSpace.CountablyGenerated` and `μ` is s-finite, then `μ` is separable. We then prove that if `μ` is separable and `E` is second-countable, then `Lp E p μ` is second-countable. A family `𝒜` of subsets of `X` is said to be **measure-dense** if it contains only measurable sets and can approximate any measurable set with finite measure, in the sense that for any measurable set `s` such that `μ s ≠ ∞`, `μ (s ∆ t)` can be made arbitrarily small when `t ∈ 𝒜`. We show below that such a family can be chosen to contain only sets with finite measure. The term "measure-dense" is justified by the fact that the approximating condition translates to the usual notion of density in the metric space made by constant indicators of measurable sets equipped with the `Lᵖ` norm. A measure `μ` is **separable** if it admits a countable and measure-dense family of sets. The term "separable" is justified by the fact that the definition translates to the usual notion of separability in the metric space made by constant indicators equipped with the `Lᵖ` norm. ## Main definitions * `MeasureTheory.Measure.MeasureDense μ 𝒜`: `𝒜` is a measure-dense family if it only contains measurable sets and if the following condition is satisfied: if `s` is measurable with finite measure, then for any `ε > 0` there exists `t ∈ 𝒜` such that `μ (s ∆ t) < ε `. * `MeasureTheory.IsSeparable`: A measure is separable if there exists a countable and measure-dense family. ## Main statements * `MeasureTheory.instSecondCountableLp`: If `μ` is separable, `E` is second-countable and `1 ≤ p < ∞` then `Lp E p μ` is second-countable. This is in particular true if `X` is countably generated and `μ` is s-finite. ## Implementation notes Through the whole file we consider a measurable space `X` equipped with a measure `μ`, and also a normed commutative group `E`. We also consider an extended non-negative real `p` such that `1 ≤ p < ∞`. This is registered as instances via `one_le_p : Fact (1 ≤ p)` and `p_ne_top : Fact (p ≠ ∞)`, so the properties are accessible via `one_le_p.elim` and `p_ne_top.elim`. Through the whole file, when we write that an extended non-negative real is finite, it is always written `≠ ∞` rather than `< ∞`. See `Ne.lt_top` and `ne_of_lt` to switch from one to the other. ## References * [D. L. Cohn, *Measure Theory*][cohn2013measure] ## Tags separable measure, measure-dense, Lp space, second-countable -/ open MeasurableSpace Set ENNReal TopologicalSpace symmDiff Real namespace MeasureTheory variable {X E : Type*} [m : MeasurableSpace X] [NormedAddCommGroup E] {μ : Measure X} variable {p : ℝ≥0∞} [one_le_p : Fact (1 ≤ p)] [p_ne_top : Fact (p ≠ ∞)] {𝒜 : Set (Set X)} section MeasureDense /-! ### Definition of a measure-dense family, basic properties and sufficient conditions -/ /-- A family `𝒜` of sets of a measure space is said to be measure-dense if it contains only measurable sets and can approximate any measurable set with finite measure, in the sense that for any measurable set `s` with finite measure the symmetric difference `s ∆ t` can be made arbitrarily small when `t ∈ 𝒜`. We show below that such a family can be chosen to contain only sets with finite measures. The term "measure-dense" is justified by the fact that the approximating condition translates to the usual notion of density in the metric space made by constant indicators of measurable sets equipped with the `Lᵖ` norm. -/ structure Measure.MeasureDense (μ : Measure X) (𝒜 : Set (Set X)) : Prop where /-- Each set has to be measurable. -/ measurable : ∀ s ∈ 𝒜, MeasurableSet s /-- Any measurable set can be approximated by sets in the family. -/ approx : ∀ s, MeasurableSet s → μ s ≠ ∞ → ∀ ε : ℝ, 0 < ε → ∃ t ∈ 𝒜, μ (s ∆ t) < ENNReal.ofReal ε theorem Measure.MeasureDense.nonempty (h𝒜 : μ.MeasureDense 𝒜) : 𝒜.Nonempty := by rcases h𝒜.approx ∅ MeasurableSet.empty (by simp) 1 (by simp) with ⟨t, ht, -⟩ exact ⟨t, ht⟩ theorem Measure.MeasureDense.nonempty' (h𝒜 : μ.MeasureDense 𝒜) : {s | s ∈ 𝒜 ∧ μ s ≠ ∞}.Nonempty := by rcases h𝒜.approx ∅ MeasurableSet.empty (by simp) 1 (by simp) with ⟨t, ht, hμt⟩ refine ⟨t, ht, ?_⟩ convert ne_top_of_lt hμt rw [← bot_eq_empty, bot_symmDiff] /-- The set of measurable sets is measure-dense. -/ theorem measureDense_measurableSet : μ.MeasureDense {s | MeasurableSet s} where measurable _ h := h approx s hs _ ε ε_pos := ⟨s, hs, by simpa⟩ theorem Measure.MeasureDense.completion (h𝒜 : μ.MeasureDense 𝒜) : μ.completion.MeasureDense 𝒜 where measurable s hs := (h𝒜.measurable s hs).nullMeasurableSet approx s hs hμs ε ε_pos := by obtain ⟨t, ht, hμst⟩ := h𝒜.approx (toMeasurable μ s) (measurableSet_toMeasurable μ s) (by simpa) ε ε_pos refine ⟨t, ht, ?_⟩ convert hμst using 1 rw [completion_apply] exact measure_congr <| ae_eq_set_symmDiff (NullMeasurableSet.toMeasurable_ae_eq hs).symm Filter.EventuallyEq.rfl /-- If a family of sets `𝒜` is measure-dense in `X`, then any measurable set with finite measure can be approximated by sets in `𝒜` with finite measure. -/ lemma Measure.MeasureDense.fin_meas_approx (h𝒜 : μ.MeasureDense 𝒜) {s : Set X} (ms : MeasurableSet s) (hμs : μ s ≠ ∞) (ε : ℝ) (ε_pos : 0 < ε) : ∃ t ∈ 𝒜, μ t ≠ ∞ ∧ μ (s ∆ t) < ENNReal.ofReal ε := by rcases h𝒜.approx s ms hμs ε ε_pos with ⟨t, t_mem, ht⟩ exact ⟨t, t_mem, (measure_ne_top_iff_of_symmDiff <| ne_top_of_lt ht).1 hμs, ht⟩ variable (p) in /-- If `𝒜` is a measure-dense family of sets and `c : E`, then the set of constant indicators with constant `c` whose underlying set is in `𝒜` is dense in the set of constant indicators which are in `Lp E p μ` when `1 ≤ p < ∞`. -/ theorem Measure.MeasureDense.indicatorConstLp_subset_closure (h𝒜 : μ.MeasureDense 𝒜) (c : E) : {indicatorConstLp p hs hμs c | (s : Set X) (hs : MeasurableSet s) (hμs : μ s ≠ ∞)} ⊆ closure {indicatorConstLp p (h𝒜.measurable s hs) hμs c | (s : Set X) (hs : s ∈ 𝒜) (hμs : μ s ≠ ∞)} := by obtain rfl | hc := eq_or_ne c 0 · refine Subset.trans ?_ subset_closure rintro - ⟨s, ms, hμs, rfl⟩ obtain ⟨t, ht, hμt⟩ := h𝒜.nonempty' refine ⟨t, ht, hμt, ?_⟩ simp_rw [indicatorConstLp] simp · have p_pos : 0 < p := lt_of_lt_of_le (by simp) one_le_p.elim rintro - ⟨s, ms, hμs, rfl⟩ refine Metric.mem_closure_iff.2 fun ε hε ↦ ?_ have aux : 0 < (ε / ‖c‖) ^ p.toReal := rpow_pos_of_pos (div_pos hε (norm_pos_iff.2 hc)) _ obtain ⟨t, ht, hμt, hμst⟩ := h𝒜.fin_meas_approx ms hμs ((ε / ‖c‖) ^ p.toReal) aux refine ⟨indicatorConstLp p (h𝒜.measurable t ht) hμt c, ⟨t, ht, hμt, rfl⟩, ?_⟩ rw [dist_indicatorConstLp_eq_norm, norm_indicatorConstLp p_pos.ne.symm p_ne_top.elim] calc ‖c‖ * μ.real (s ∆ t) ^ (1 / p.toReal) < ‖c‖ * (ENNReal.ofReal ((ε / ‖c‖) ^ p.toReal)).toReal ^ (1 / p.toReal) := by have := toReal_pos p_pos.ne.symm p_ne_top.elim rw [measureReal_def] gcongr exact ofReal_ne_top _ = ε := by rw [toReal_ofReal (rpow_nonneg (div_nonneg hε.le (norm_nonneg _)) _), one_div, Real.rpow_rpow_inv (div_nonneg hε.le (norm_nonneg _)) (toReal_pos p_pos.ne.symm p_ne_top.elim).ne.symm, mul_div_cancel₀ _ (norm_ne_zero_iff.2 hc)] /-- If a family of sets `𝒜` is measure-dense in `X`, then it is also the case for the sets in `𝒜` with finite measure. -/ theorem Measure.MeasureDense.fin_meas (h𝒜 : μ.MeasureDense 𝒜) : μ.MeasureDense {s | s ∈ 𝒜 ∧ μ s ≠ ∞} where measurable s h := h𝒜.measurable s h.1 approx s ms hμs ε ε_pos := by rcases Measure.MeasureDense.fin_meas_approx h𝒜 ms hμs ε ε_pos with ⟨t, t_mem, hμt, hμst⟩ exact ⟨t, ⟨t_mem, hμt⟩, hμst⟩ variable (μ) in /-- If a measurable space equipped with a finite measure is generated by an algebra of sets, then this algebra of sets is measure-dense. -/ theorem Measure.MeasureDense.of_generateFrom_isSetAlgebra_finite [IsFiniteMeasure μ] (h𝒜 : IsSetAlgebra 𝒜) (hgen : m = MeasurableSpace.generateFrom 𝒜) : μ.MeasureDense 𝒜 where measurable s hs := hgen ▸ measurableSet_generateFrom hs approx s ms := by -- We want to show that any measurable set can be approximated by sets in `𝒜`. To do so, it is -- enough to show that such sets constitute a `σ`-algebra containing `𝒜`. This is contained in -- the theorem `generateFrom_induction`. have : MeasurableSet s ∧ ∀ (ε : ℝ), 0 < ε → ∃ t ∈ 𝒜, μ.real (s ∆ t) < ε := by rw [hgen] at ms induction s, ms using generateFrom_induction with -- If `t ∈ 𝒜`, then `μ (t ∆ t) = 0` which is less than any `ε > 0`. | hC t t_mem _ => exact ⟨hgen ▸ measurableSet_generateFrom t_mem, fun ε ε_pos ↦ ⟨t, t_mem, by simpa⟩⟩ -- `∅ ∈ 𝒜` and `μ (∅ ∆ ∅) = 0` which is less than any `ε > 0`. | empty => exact ⟨MeasurableSet.empty, fun ε ε_pos ↦ ⟨∅, h𝒜.empty_mem, by simpa⟩⟩ -- If `s` is measurable and `t ∈ 𝒜` such that `μ (s ∆ t) < ε`, then `tᶜ ∈ 𝒜` and -- `μ (sᶜ ∆ tᶜ) = μ (s ∆ t) < ε` so `sᶜ` can be approximated. | compl t _ ht => refine ⟨ht.1.compl, fun ε ε_pos ↦ ?_⟩ obtain ⟨u, u_mem, hμtcu⟩ := ht.2 ε ε_pos exact ⟨uᶜ, h𝒜.compl_mem u_mem, by rwa [compl_symmDiff_compl]⟩ -- Let `(fₙ)` be a sequence of measurable sets and `ε > 0`. | iUnion f _ hf => refine ⟨MeasurableSet.iUnion (fun n ↦ (hf n).1), fun ε ε_pos ↦ ?_⟩ -- We have `μ (⋃ n ≤ N, fₙ) ⟶ μ (⋃ n, fₙ)`. have := tendsto_measure_iUnion_accumulate (μ := μ) (f := f) rw [← tendsto_toReal_iff (fun _ ↦ measure_ne_top _ _) (measure_ne_top _ _)] at this -- So there exists `N` such that `μ (⋃ n, fₙ) - μ (⋃ n ≤ N, fₙ) < ε/2`. rcases Metric.tendsto_atTop.1 this (ε / 2) (by linarith [ε_pos]) with ⟨N, hN⟩ -- For any `n ≤ N` there exists `gₙ ∈ 𝒜` such that `μ (fₙ ∆ gₙ) < ε/(2*(N+1))`. choose g g_mem hg using fun n ↦ (hf n).2 (ε / (2 * (N + 1))) (div_pos ε_pos (by linarith)) -- Therefore we have -- `μ ((⋃ n, fₙ) ∆ (⋃ n ≤ N, gₙ))` -- `≤ μ ((⋃ n, fₙ) ∆ (⋃ n ≤ N, fₙ)) + μ ((⋃ n ≤ N, fₙ) ∆ (⋃ n ≤ N, gₙ))` -- `< ε/2 + ∑ n ≤ N, μ (fₙ ∆ gₙ)` (see `biSup_symmDiff_biSup_le`) -- `< ε/2 + (N+1)*ε/(2*(N+1)) = ε/2`. refine ⟨⋃ n ∈ Finset.range (N + 1), g n, h𝒜.biUnion_mem _ (fun i _ ↦ g_mem i), ?_⟩ calc μ.real ((⋃ n, f n) ∆ (⋃ n ∈ (Finset.range (N + 1)), g n)) ≤ (μ ((⋃ n, f n) \ ((⋃ n ∈ (Finset.range (N + 1)), f n)) ∪ ((⋃ n ∈ (Finset.range (N + 1)), f n) ∆ (⋃ n ∈ (Finset.range (N + 1)), g ↑n)))).toReal := toReal_mono (measure_ne_top _ _) (measure_mono <| symmDiff_of_ge (iUnion_subset <| fun i ↦ iUnion_subset (fun _ ↦ subset_iUnion f i)) ▸ symmDiff_triangle ..) _ ≤ (μ ((⋃ n, f n) \ ((⋃ n ∈ (Finset.range (N + 1)), f n)))).toReal + (μ ((⋃ n ∈ (Finset.range (N + 1)), f n) ∆ (⋃ n ∈ (Finset.range (N + 1)), g ↑n))).toReal := by rw [← toReal_add (measure_ne_top _ _) (measure_ne_top _ _)] exact toReal_mono (add_ne_top.2 ⟨measure_ne_top _ _, measure_ne_top _ _⟩) <| measure_union_le _ _ _ < ε := by rw [← add_halves ε] apply _root_.add_lt_add · rw [measure_diff (h_fin := measure_ne_top _ _), toReal_sub_of_le (ha := measure_ne_top _ _)] · apply lt_of_le_of_lt (sub_le_dist ..) simp only [Finset.mem_range, Nat.lt_add_one_iff] exact (dist_comm (α := ℝ) .. ▸ hN N (le_refl N)) · exact measure_mono <| iUnion_subset <| fun i ↦ iUnion_subset fun _ ↦ subset_iUnion f i · exact iUnion_subset <| fun i ↦ iUnion_subset (fun _ ↦ subset_iUnion f i) · exact MeasurableSet.biUnion (countable_coe_iff.1 inferInstance) (fun n _ ↦ (hf n).1.nullMeasurableSet) · calc (μ ((⋃ n ∈ (Finset.range (N + 1)), f n) ∆ (⋃ n ∈ (Finset.range (N + 1)), g ↑n))).toReal ≤ μ.real (⋃ n ∈ (Finset.range (N + 1)), f n ∆ g n) := toReal_mono (measure_ne_top _ _) (measure_mono biSup_symmDiff_biSup_le) _ ≤ ∑ n ∈ Finset.range (N + 1), μ.real (f n ∆ g n) := by simp_rw [measureReal_def, ← toReal_sum (fun _ _ ↦ measure_ne_top _ _)] exact toReal_mono (ne_of_lt <| sum_lt_top.2 fun _ _ ↦ measure_lt_top μ _) (measure_biUnion_finset_le _ _) _ < ∑ n ∈ Finset.range (N + 1), (ε / (2 * (N + 1))) := Finset.sum_lt_sum (fun i _ ↦ le_of_lt (hg i)) ⟨0, by simp, hg 0⟩ _ ≤ ε / 2 := by simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul, Nat.cast_add, Nat.cast_one] rw [div_mul_eq_div_mul_one_div, ← mul_assoc, mul_comm ((N : ℝ) + 1), mul_assoc] exact mul_le_of_le_one_right (by linarith [ε_pos]) <| le_of_eq <| mul_one_div_cancel <| Nat.cast_add_one_ne_zero _ rintro - ε ε_pos rcases this.2 ε ε_pos with ⟨t, t_mem, hμst⟩ exact ⟨t, t_mem, (lt_ofReal_iff_toReal_lt (measure_ne_top _ _)).2 hμst⟩ /-- If a measure space `X` is generated by an algebra of sets which contains a monotone countable family of sets with finite measure spanning `X` (thus the measure is `σ`-finite), then this algebra of sets is measure-dense. -/ theorem Measure.MeasureDense.of_generateFrom_isSetAlgebra_sigmaFinite (h𝒜 : IsSetAlgebra 𝒜) (S : μ.FiniteSpanningSetsIn 𝒜) (hgen : m = MeasurableSpace.generateFrom 𝒜) : μ.MeasureDense 𝒜 where measurable s hs := hgen ▸ measurableSet_generateFrom hs approx s ms hμs ε ε_pos := by -- We use partial unions of (Sₙ) to get a monotone family spanning `X`. let T := Accumulate S.set have T_mem (n) : T n ∈ 𝒜 := by simpa using h𝒜.biUnion_mem {k | k ≤ n}.toFinset (fun k _ ↦ S.set_mem k) have T_finite (n) : μ (T n) < ∞ := by simpa using measure_biUnion_lt_top {k | k ≤ n}.toFinset.finite_toSet (fun k _ ↦ S.finite k) have T_spanning : ⋃ n, T n = univ := S.spanning ▸ iUnion_accumulate -- We use the fact that we already know this is true for finite measures. As `⋃ n, T n = X`, -- we have that `μ ((T n) ∩ s) ⟶ μ s`. have mono : Monotone (fun n ↦ (T n) ∩ s) := fun m n hmn ↦ inter_subset_inter_left s (biUnion_subset_biUnion_left fun k hkm ↦ Nat.le_trans hkm hmn) have := tendsto_measure_iUnion_atTop (μ := μ) mono rw [← tendsto_toReal_iff] at this · -- We can therefore choose `N` such that `μ s - μ ((S N) ∩ s) < ε/2`. rcases Metric.tendsto_atTop.1 this (ε / 2) (by linarith [ε_pos]) with ⟨N, hN⟩ have : Fact (μ (T N) < ∞) := Fact.mk <| T_finite N -- Then we can apply the previous result to the measure `μ ((S N) ∩ •)`. -- There exists `t ∈ 𝒜` such that `μ ((S N) ∩ (s ∆ t)) < ε/2`. rcases (Measure.MeasureDense.of_generateFrom_isSetAlgebra_finite (μ.restrict (T N)) h𝒜 hgen).approx s ms (ne_of_lt (lt_of_le_of_lt (μ.restrict_apply_le _ s) hμs.lt_top)) (ε / 2) (by linarith [ε_pos]) with ⟨t, t_mem, ht⟩ -- We can then use `t ∩ (S N)`, because `S N ∈ 𝒜` by hypothesis. -- `μ (s ∆ (t ∩ S N))` -- `≤ μ (s ∆ (s ∩ S N)) + μ ((s ∩ S N) ∆ (t ∩ S N))` -- `= μ s - μ (s ∩ S N) + μ (s ∆ t) ∩ S N) < ε`. refine ⟨t ∩ T N, h𝒜.inter_mem t_mem (T_mem N), ?_⟩ calc μ (s ∆ (t ∩ T N)) ≤ μ (s \ (s ∩ T N)) + μ ((s ∆ t) ∩ T N) := by rw [← symmDiff_of_le (inter_subset_left ..), symmDiff_comm _ s, inter_symmDiff_distrib_right] exact measure_symmDiff_le _ _ _ _ < ENNReal.ofReal (ε / 2) + ENNReal.ofReal (ε / 2) := by apply ENNReal.add_lt_add · rw [measure_diff (inter_subset_left ..) (ms.inter (hgen ▸ measurableSet_generateFrom (T_mem N))).nullMeasurableSet (ne_top_of_le_ne_top hμs (measure_mono (inter_subset_left ..))), lt_ofReal_iff_toReal_lt (sub_ne_top hμs), toReal_sub_of_le (measure_mono (inter_subset_left ..)) hμs] apply lt_of_le_of_lt (sub_le_dist ..) nth_rw 1 [← univ_inter s] rw [inter_comm s, dist_comm, ← T_spanning, iUnion_inter _ T] apply hN N (le_refl _) · rwa [← μ.restrict_apply' (hgen ▸ measurableSet_generateFrom (T_mem N))] _ = ENNReal.ofReal ε := by rw [← ofReal_add (by linarith [ε_pos]) (by linarith [ε_pos]), add_halves] · exact fun n ↦ ne_top_of_le_ne_top hμs (measure_mono (inter_subset_right ..)) · exact ne_top_of_le_ne_top hμs (measure_mono (iUnion_subset (fun i ↦ inter_subset_right ..))) end MeasureDense section IsSeparable /-! ### Definition of a separable measure space, sufficient condition -/ /-- A measure `μ` is separable if there exists a countable and measure-dense family of sets. The term "separable" is justified by the fact that the definition translates to the usual notion of separability in the metric space made by constant indicators equipped with the `Lᵖ` norm. -/ class IsSeparable (μ : Measure X) : Prop where exists_countable_measureDense : ∃ 𝒜, 𝒜.Countable ∧ μ.MeasureDense 𝒜 variable (μ) /-- By definition, a separable measure admits a countable and measure-dense family of sets. -/ theorem exists_countable_measureDense [IsSeparable μ] : ∃ 𝒜, 𝒜.Countable ∧ μ.MeasureDense 𝒜 := IsSeparable.exists_countable_measureDense /-- If a measurable space is countably generated and equipped with a `σ`-finite measure, then the measure is separable. This is not an instance because it is used below to prove the more general case where `μ` is s-finite. -/ theorem isSeparable_of_sigmaFinite [CountablyGenerated X] [SigmaFinite μ] : IsSeparable μ where exists_countable_measureDense := by have h := countable_countableGeneratingSet (α := X) have hgen := generateFrom_countableGeneratingSet (α := X) let 𝒜 := (countableGeneratingSet X) ∪ {μ.toFiniteSpanningSetsIn.set n | n : ℕ} have count_𝒜 : 𝒜.Countable := countable_union.2 ⟨h, countable_iff_exists_subset_range.2 ⟨μ.toFiniteSpanningSetsIn.set, fun _ hx ↦ hx⟩⟩ refine ⟨generateSetAlgebra 𝒜, countable_generateSetAlgebra count_𝒜, Measure.MeasureDense.of_generateFrom_isSetAlgebra_sigmaFinite isSetAlgebra_generateSetAlgebra { set := μ.toFiniteSpanningSetsIn.set set_mem := fun n ↦ self_subset_generateSetAlgebra (𝒜 := 𝒜) <| Or.inr ⟨n, rfl⟩ finite := μ.toFiniteSpanningSetsIn.finite spanning := μ.toFiniteSpanningSetsIn.spanning } (le_antisymm ?_ (generateFrom_le (fun s hs ↦ ?_)))⟩ · rw [← hgen] exact generateFrom_mono <| le_trans self_subset_generateSetAlgebra <| generateSetAlgebra_mono <| subset_union_left .. · induction hs with | base t t_mem => rcases t_mem with t_mem | ⟨n, rfl⟩ · exact hgen ▸ measurableSet_generateFrom t_mem · exact μ.toFiniteSpanningSetsIn.set_mem n | empty => exact MeasurableSet.empty | compl t _ t_mem => exact MeasurableSet.compl t_mem | union t u _ _ t_mem u_mem => exact MeasurableSet.union t_mem u_mem /-- If a measurable space is countably generated and equipped with an s-finite measure, then the measure is separable. -/ instance [CountablyGenerated X] [SFinite μ] : IsSeparable μ where exists_countable_measureDense := by have := isSeparable_of_sigmaFinite (μ.restrict μ.sigmaFiniteSet) rcases exists_countable_measureDense (μ.restrict μ.sigmaFiniteSet) with ⟨𝒜, count_𝒜, h𝒜⟩ let ℬ := {s ∩ μ.sigmaFiniteSet | s ∈ 𝒜} refine ⟨ℬ, count_𝒜.image (fun s ↦ s ∩ μ.sigmaFiniteSet), ?_, ?_⟩ · rintro - ⟨s, s_mem, rfl⟩ exact (h𝒜.measurable s s_mem).inter measurableSet_sigmaFiniteSet · intro s ms hμs ε ε_pos rcases restrict_compl_sigmaFiniteSet_eq_zero_or_top μ s with hs | hs · have : (μ.restrict μ.sigmaFiniteSet) s ≠ ∞ := ne_top_of_le_ne_top hμs <| μ.restrict_le_self _ rcases h𝒜.approx s ms this ε ε_pos with ⟨t, t_mem, ht⟩ refine ⟨t ∩ μ.sigmaFiniteSet, ⟨t, t_mem, rfl⟩, ?_⟩ have : μ (s ∆ (t ∩ μ.sigmaFiniteSet) \ μ.sigmaFiniteSet) = 0 := by rw [diff_eq_compl_inter, inter_symmDiff_distrib_left, ← ENNReal.bot_eq_zero, eq_bot_iff] calc μ ((μ.sigmaFiniteSetᶜ ∩ s) ∆ (μ.sigmaFiniteSetᶜ ∩ (t ∩ μ.sigmaFiniteSet))) ≤ μ ((μ.sigmaFiniteSetᶜ ∩ s) ∪ (μ.sigmaFiniteSetᶜ ∩ (t ∩ μ.sigmaFiniteSet))) := measure_mono symmDiff_subset_union _ ≤ μ (μ.sigmaFiniteSetᶜ ∩ s) + μ (μ.sigmaFiniteSetᶜ ∩ (t ∩ μ.sigmaFiniteSet)) := measure_union_le _ _ _ = 0 := by rw [inter_comm, ← μ.restrict_apply ms, hs, ← inter_assoc, inter_comm, ← inter_assoc, inter_compl_self, empty_inter, measure_empty, zero_add] rwa [← measure_inter_add_diff _ measurableSet_sigmaFiniteSet, this, add_zero, inter_symmDiff_distrib_right, inter_assoc, inter_self, ← inter_symmDiff_distrib_right, ← μ.restrict_apply' measurableSet_sigmaFiniteSet] · refine False.elim <| hμs ?_ rw [eq_top_iff, ← hs] exact μ.restrict_le_self _ instance [hμ : IsSeparable μ] : IsSeparable μ.completion := by obtain ⟨𝒜, count_𝒜, h𝒜⟩ := exists_countable_measureDense μ exact ⟨𝒜, count_𝒜, h𝒜.completion⟩ end IsSeparable section SecondCountableLp /-! ### A sufficient condition for $L^p$ spaces to be second-countable -/ /-- If the measure `μ` is separable (in particular if `X` is countably generated and `μ` is `s`-finite), if `E` is a second-countable `NormedAddCommGroup`, and if `1 ≤ p < +∞`, then the associated `Lᵖ` space is second-countable. -/ instance Lp.SecondCountableTopology [IsSeparable μ] [TopologicalSpace.SeparableSpace E] : SecondCountableTopology (Lp E p μ) := by -- It is enough to show that the space is separable, i.e. admits a countable and dense subset. refine @UniformSpace.secondCountable_of_separable _ _ _ ?_ -- There exists a countable and measure-dense family, and we can keep only the sets with finite -- measure while preserving the two properties. This family is denoted `𝒜₀`. rcases exists_countable_measureDense μ with ⟨𝒜, count_𝒜, h𝒜⟩ have h𝒜₀ := Measure.MeasureDense.fin_meas h𝒜 set 𝒜₀ := {s | s ∈ 𝒜 ∧ μ s ≠ ∞} have count_𝒜₀ : 𝒜₀.Countable := count_𝒜.mono fun _ ⟨h, _⟩ ↦ h -- `1 ≤ p` so `p ≠ 0`, we prove it now as it is often needed. have p_ne_zero : p ≠ 0 := ne_of_gt <| lt_of_lt_of_le (by simp) one_le_p.elim -- `E` is second-countable, therefore separable and admits a countable and dense subset `u`. rcases exists_countable_dense E with ⟨u, countable_u, dense_u⟩ -- The countable and dense subset of `Lᵖ` we are going to build is the set of finite sums of -- constant indicators with support in `𝒜₀`, and is denoted `D`. To make manipulations easier, -- we define the function `key` which given an integer `n` and two families of `n` elements -- in `u` and `𝒜₀` associates the corresponding sum. let key (n : ℕ) (d : Fin n → u) (s : Fin n → 𝒜₀) : (Lp E p μ) := ∑ i, indicatorConstLp p (h𝒜₀.measurable (s i) (Subtype.mem (s i))) (s i).2.2 (d i : E) let D := {s : Lp E p μ | ∃ n d t, s = key n d t} refine ⟨D, ?_, ?_⟩ · -- Countability directly follows from countability of `u` and `𝒜₀`. The function `f` below -- is the uncurried version of `key`, which is easier to manipulate as countability of the -- domain is automatically inferred. let f (nds : Σ n : ℕ, (Fin n → u) × (Fin n → 𝒜₀)) : Lp E p μ := key nds.1 nds.2.1 nds.2.2 have := count_𝒜₀.to_subtype have := countable_u.to_subtype have : D ⊆ range f := by rintro - ⟨n, d, s, rfl⟩ use ⟨n, (d, s)⟩ exact (countable_range f).mono this · -- Let's turn to the density. Thanks to the density of simple functions in `Lᵖ`, it is enough -- to show that the closure of `D` contains constant indicators which are in `Lᵖ` (i. e. the -- set has finite measure), is closed by sum and closed. -- This is given by `Lp.induction`. refine Lp.induction p_ne_top.elim (motive := fun f ↦ f ∈ closure D) ?_ ?_ isClosed_closure · intro a s ms hμs -- We want to approximate `a • 𝟙ₛ`. apply ne_of_lt at hμs rw [SeminormedAddCommGroup.mem_closure_iff] intro ε ε_pos have μs_pow_nonneg : 0 ≤ μ.real s ^ (1 / p.toReal) := Real.rpow_nonneg ENNReal.toReal_nonneg _ -- To do so, we first pick `b ∈ u` such that `‖a - b‖ < ε / (3 * (1 + (μ s)^(1/p)))`. have approx_a_pos : 0 < ε / (3 * (1 + μ.real s ^ (1 / p.toReal))) := div_pos ε_pos (by linarith [μs_pow_nonneg]) have ⟨b, b_mem, hb⟩ := SeminormedAddCommGroup.mem_closure_iff.1 (dense_u a) _ approx_a_pos -- Then we pick `t ∈ 𝒜₀` such that `‖b • 𝟙ₛ - b • 𝟙ₜ‖ < ε / 3`. rcases SeminormedAddCommGroup.mem_closure_iff.1 (h𝒜₀.indicatorConstLp_subset_closure p b ⟨s, ms, hμs, rfl⟩) (ε / 3) (by linarith [ε_pos]) with ⟨-, ⟨t, ht, hμt, rfl⟩, hst⟩ have mt := h𝒜₀.measurable t ht -- We now show that `‖a • 𝟙ₛ - b • 𝟙ₜ‖ₚ < ε`, as follows: -- `‖a • 𝟙ₛ - b • 𝟙ₜ‖ₚ` -- `= ‖a • 𝟙ₛ - b • 𝟙ₛ + b • 𝟙ₛ - b • 𝟙ₜ‖ₚ` -- `≤ ‖a - b‖ * ‖𝟙ₛ‖ₚ + ε / 3` -- `= ‖a - b‖ * (μ s)^(1/p) + ε / 3` -- `< ε * (μ s)^(1/p) / (3 * (1 + (μ s)^(1/p))) + ε / 3` -- `≤ ε / 3 + ε / 3 < ε`. refine ⟨indicatorConstLp p mt hμt b, ⟨1, fun _ ↦ ⟨b, b_mem⟩, fun _ ↦ ⟨t, ht⟩, by simp [key]⟩, ?_⟩ rw [Lp.simpleFunc.coe_indicatorConst, ← sub_add_sub_cancel _ (indicatorConstLp p ms hμs b), ← add_halves ε] refine lt_of_le_of_lt (b := ε / 3 + ε / 3) (norm_add_le_of_le ?_ hst.le) (by linarith [ε_pos]) rw [indicatorConstLp_sub, norm_indicatorConstLp p_ne_zero p_ne_top.elim] calc ‖a - b‖ * μ.real s ^ (1 / p.toReal) ≤ (ε / (3 * (1 + μ.real s ^ (1 / p.toReal)))) * μ.real s ^ (1 / p.toReal) := mul_le_mul_of_nonneg_right (le_of_lt hb) μs_pow_nonneg _ ≤ ε / 3 := by rw [← mul_one (ε / 3), div_mul_eq_div_mul_one_div, mul_assoc, one_div_mul_eq_div] exact mul_le_mul_of_nonneg_left ((div_le_one (by linarith [μs_pow_nonneg])).2 (by linarith)) (by linarith [ε_pos]) · -- Now we have to show that the closure of `D` is closed by sum. Let `f` and `g` be two -- functions in `Lᵖ` which are also in the closure of `D`. rintro f g hf hg - f_mem g_mem rw [SeminormedAddCommGroup.mem_closure_iff] at * intro ε ε_pos -- For `ε > 0`, there exists `bf, bg ∈ D` such that `‖f - bf‖ₚ < ε/2` and `‖g - bg‖ₚ < ε/2`. rcases f_mem (ε / 2) (by linarith [ε_pos]) with ⟨bf, ⟨nf, df, sf, bf_eq⟩, hbf⟩ rcases g_mem (ε / 2) (by linarith [ε_pos]) with ⟨bg, ⟨ng, dg, sg, bg_eq⟩, hbg⟩ -- It is obvious that `D` is closed by sum, it suffices to concatenate the family of -- elements of `u` and the family of elements of `𝒜₀`. let d := fun i : Fin (nf + ng) ↦ if h : i < nf then df (Fin.castLT i h) else dg (Fin.subNat nf (Fin.cast (Nat.add_comm ..) i) (le_of_not_gt h)) let s := fun i : Fin (nf + ng) ↦ if h : i < nf then sf (Fin.castLT i h) else sg (Fin.subNat nf (Fin.cast (Nat.add_comm ..) i) (le_of_not_gt h)) -- So we can use `bf + bg`. refine ⟨bf + bg, ⟨nf + ng, d, s, ?_⟩, ?_⟩ · simp [key, d, s, Fin.sum_univ_add, bf_eq, bg_eq] · -- We have -- `‖f + g - (bf + bg)‖ₚ` -- `≤ ‖f - bf‖ₚ + ‖g - bg‖ₚ` -- `< ε/2 + ε/2 = ε`. calc ‖MemLp.toLp f hf + MemLp.toLp g hg - (bf + bg)‖ = ‖(MemLp.toLp f hf) - bf + ((MemLp.toLp g hg) - bg)‖ := by congr; abel _ ≤ ‖(MemLp.toLp f hf) - bf‖ + ‖(MemLp.toLp g hg) - bg‖ := norm_add_le .. _ < ε := by linarith [hbf, hbg] end SecondCountableLp end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/FiniteMeasurePi.lean
import Mathlib.MeasureTheory.Measure.LevyProkhorovMetric /-! # Products of finite measures and probability measures This file introduces finite products of finite measures and probability measures. The constructions are obtained from special cases of products of general measures. Taking products nevertheless has specific properties in the cases of finite measures and probability measures, notably the fact that the product measures depend continuously on their factors in the topology of weak convergence when the underlying space is metrizable and separable. ## Main definitions * `MeasureTheory.FiniteMeasure.pi`: The product of finitely many finite measures. * `MeasureTheory.ProbabilityMeasure.pi`: The product of finitely many probability measures. ## Main results `MeasureTheory.ProbabilityMeasure.continuous_pi`: the product probability measure depends continuously on the factors. -/ open MeasureTheory Topology Metric Filter Set ENNReal NNReal open scoped Topology ENNReal NNReal BoundedContinuousFunction namespace MeasureTheory variable {ι : Type*} {α : ι → Type*} [Fintype ι] [∀ i, MeasurableSpace (α i)] namespace FiniteMeasure /-- The product of finitely many finite measures. -/ noncomputable def pi (μ : Π i, FiniteMeasure (α i)) : FiniteMeasure (Π i, α i) := ⟨Measure.pi (fun i ↦ μ i), inferInstance⟩ variable (μ : Π i, FiniteMeasure (α i)) @[simp] lemma toMeasure_pi : (FiniteMeasure.pi μ).toMeasure = Measure.pi (fun i ↦ μ i) := rfl @[simp] lemma pi_pi (s : Π i, Set (α i)) : (FiniteMeasure.pi μ) (Set.pi univ s) = ∏ i, μ i (s i) := by simp [coeFn_def] @[simp] lemma mass_pi : (FiniteMeasure.pi μ).mass = ∏ i, (μ i).mass := by simp only [mass] rw [← pi_univ (univ : Set ι), pi_pi] lemma pi_map_pi {β : ι → Type*} [∀ i, MeasurableSpace (β i)] {f : Π i, α i → β i} (f_mble : ∀ i, AEMeasurable (f i) (μ i)) : (FiniteMeasure.pi μ).map (fun x i ↦ (f i (x i))) = FiniteMeasure.pi (fun i ↦ (μ i).map (f i)) := by apply Subtype.ext simp only [val_eq_toMeasure, toMeasure_map, toMeasure_pi] rw [Measure.pi_map_pi f_mble] end FiniteMeasure namespace ProbabilityMeasure /-- The product of finitely many probability measures. -/ noncomputable def pi (μ : Π i, ProbabilityMeasure (α i)) : ProbabilityMeasure (Π i, α i) := ⟨Measure.pi (fun i ↦ μ i), inferInstance⟩ variable (μ : Π i, ProbabilityMeasure (α i)) @[simp] lemma toMeasure_pi : (ProbabilityMeasure.pi μ).toMeasure = Measure.pi (fun i ↦ μ i) := rfl @[simp] lemma pi_pi (s : Π i, Set (α i)) : ProbabilityMeasure.pi μ (Set.pi univ s) = ∏ i, μ i (s i) := by simp [coeFn_def] open TopologicalSpace /-- The map associating to finitely many probability measures their product is a continuous map. -/ @[fun_prop] theorem continuous_pi [∀ i, TopologicalSpace (α i)] [∀ i, SecondCountableTopology (α i)] [∀ i, PseudoMetrizableSpace (α i)] [∀ i, OpensMeasurableSpace (α i)] : Continuous (fun (μ : Π i, ProbabilityMeasure (α i)) ↦ ProbabilityMeasure.pi μ) := by refine continuous_iff_continuousAt.2 (fun μ ↦ ?_) /- It suffices to check the convergence along elements of a π-system containing arbitrarily small neighborhoods of any point, by `tendsto_probabilityMeasure_of_tendsto_of_mem`. We take as a π-system the sets of the form `s₁ × ... × sₙ` where all the `sᵢ` have null frontier. -/ let S : Set (Set (Π i, α i)) := {t | ∃ (s : Π i, Set (α i)), t = univ.pi s ∧ (∀ i, MeasurableSet (s i)) ∧ (∀ i, μ i (frontier (s i)) = 0)} have : IsPiSystem S := by rintro - ⟨s, rfl, smeas, hs⟩ - ⟨s', rfl, s'meas, hs'⟩ - refine ⟨fun i ↦ s i ∩ s' i, pi_inter_distrib.symm, fun i ↦ (smeas i).inter (s'meas i), fun i ↦ ?_⟩ simp_rw [null_iff_toMeasure_null] at hs hs' ⊢ exact null_frontier_inter (hs i) (hs' i) apply this.tendsto_probabilityMeasure_of_tendsto_of_mem · rintro - ⟨s, rfl, smeas, hs⟩ exact MeasurableSet.univ_pi smeas · letI : ∀ i, PseudoMetricSpace (α i) := fun i ↦ TopologicalSpace.pseudoMetrizableSpacePseudoMetric (α i) intro u u_open x xu obtain ⟨ε, εpos, hε⟩ : ∃ ε > 0, ball x ε ⊆ u := Metric.isOpen_iff.1 u_open x xu have A (i) : ∃ r ∈ Ioo 0 ε, (μ i : Measure (α i)) (frontier (Metric.thickening r {x i})) = 0 := exists_null_frontier_thickening _ _ εpos choose! r rpos hr using A refine ⟨univ.pi (fun i ↦ ball (x i) (r i)), ⟨fun i ↦ ball (x i) (r i), rfl, fun i ↦ measurableSet_ball, fun i ↦ by simpa using hr i⟩, ?_, ?_⟩ · apply IsOpen.mem_nhds · exact isOpen_set_pi finite_univ (by simp) · simpa using fun i ↦ (rpos i).1 · calc univ.pi fun i ↦ ball (x i) (r i) _ ⊆ univ.pi fun i ↦ ball (x i) ε := by gcongr with i hi; exact (rpos i).2.le _ ⊆ u := by rwa [← ball_pi _ εpos] · rintro - ⟨s, rfl, smeas, hs⟩ simp only [pi_pi] apply tendsto_finset_prod _ (fun i hi ↦ ?_) exact tendsto_measure_of_null_frontier_of_tendsto (Tendsto.apply_nhds (fun ⦃U⦄ a ↦ a) i) (hs i) end ProbabilityMeasure end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/Tilted.lean
import Mathlib.MeasureTheory.Measure.Decomposition.RadonNikodym /-! # Exponentially tilted measures The exponential tilting of a measure `μ` on `α` by a function `f : α → ℝ` is the measure with density `x ↦ exp (f x) / ∫ y, exp (f y) ∂μ` with respect to `μ`. This is sometimes also called the Esscher transform. The definition is mostly used for `f` linear, in which case the exponentially tilted measure belongs to the natural exponential family of the base measure. Exponentially tilted measures for general `f` can be used for example to establish variational expressions for the Kullback-Leibler divergence. ## Main definitions * `Measure.tilted μ f`: exponential tilting of `μ` by `f`, equal to `μ.withDensity (fun x ↦ ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ))`. -/ open Real open scoped ENNReal NNReal namespace MeasureTheory variable {α : Type*} {mα : MeasurableSpace α} {μ : Measure α} {f : α → ℝ} /-- Exponentially tilted measure. When `x ↦ exp (f x)` is integrable, `μ.tilted f` is the probability measure with density with respect to `μ` proportional to `exp (f x)`. Otherwise it is 0. -/ noncomputable def Measure.tilted (μ : Measure α) (f : α → ℝ) : Measure α := μ.withDensity (fun x ↦ ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ)) @[simp] lemma tilted_of_not_integrable (hf : ¬ Integrable (fun x ↦ exp (f x)) μ) : μ.tilted f = 0 := by rw [Measure.tilted, integral_undef hf] simp @[simp] lemma tilted_of_not_aemeasurable (hf : ¬ AEMeasurable f μ) : μ.tilted f = 0 := by refine tilted_of_not_integrable ?_ suffices ¬ AEMeasurable (fun x ↦ exp (f x)) μ by exact fun h ↦ this h.1.aemeasurable exact fun h ↦ hf (aemeasurable_of_aemeasurable_exp h) @[simp] lemma tilted_zero_measure (f : α → ℝ) : (0 : Measure α).tilted f = 0 := by simp [Measure.tilted] @[simp] lemma tilted_const' (μ : Measure α) (c : ℝ) : μ.tilted (fun _ ↦ c) = (μ Set.univ)⁻¹ • μ := by cases eq_zero_or_neZero μ with | inl h => rw [h]; simp | inr h0 => simp only [Measure.tilted, withDensity_const, integral_const, smul_eq_mul] by_cases h_univ : μ Set.univ = ∞ · simp only [measureReal_def, h_univ, ENNReal.toReal_top, zero_mul, div_zero, ENNReal.ofReal_zero, zero_smul, ENNReal.inv_top] congr rw [div_eq_mul_inv, mul_inv, mul_comm, mul_assoc, inv_mul_cancel₀ (exp_pos _).ne', mul_one, measureReal_def, ← ENNReal.toReal_inv, ENNReal.ofReal_toReal] simp [h0.out] lemma tilted_const (μ : Measure α) [IsProbabilityMeasure μ] (c : ℝ) : μ.tilted (fun _ ↦ c) = μ := by simp @[simp] lemma tilted_zero' (μ : Measure α) : μ.tilted 0 = (μ Set.univ)⁻¹ • μ := by change μ.tilted (fun _ ↦ 0) = (μ Set.univ)⁻¹ • μ simp lemma tilted_zero (μ : Measure α) [IsProbabilityMeasure μ] : μ.tilted 0 = μ := by simp lemma tilted_congr {g : α → ℝ} (hfg : f =ᵐ[μ] g) : μ.tilted f = μ.tilted g := by have h_int_eq : ∫ x, exp (f x) ∂μ = ∫ x, exp (g x) ∂μ := by refine integral_congr_ae ?_ filter_upwards [hfg] with x hx rw [hx] refine withDensity_congr_ae ?_ filter_upwards [hfg] with x hx rw [h_int_eq, hx] lemma tilted_eq_withDensity_nnreal (μ : Measure α) (f : α → ℝ) : μ.tilted f = μ.withDensity (fun x ↦ ((↑) : ℝ≥0 → ℝ≥0∞) (⟨exp (f x) / ∫ x, exp (f x) ∂μ, by positivity⟩ : ℝ≥0)) := by rw [Measure.tilted] congr with x rw [ENNReal.ofReal_eq_coe_nnreal] lemma tilted_apply' (μ : Measure α) (f : α → ℝ) {s : Set α} (hs : MeasurableSet s) : μ.tilted f s = ∫⁻ a in s, ENNReal.ofReal (exp (f a) / ∫ x, exp (f x) ∂μ) ∂μ := by rw [Measure.tilted, withDensity_apply _ hs] lemma tilted_apply (μ : Measure α) [SFinite μ] (f : α → ℝ) (s : Set α) : μ.tilted f s = ∫⁻ a in s, ENNReal.ofReal (exp (f a) / ∫ x, exp (f x) ∂μ) ∂μ := by rw [Measure.tilted, withDensity_apply' _ s] lemma tilted_apply_eq_ofReal_integral' {s : Set α} (f : α → ℝ) (hs : MeasurableSet s) : μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by by_cases hf : Integrable (fun x ↦ exp (f x)) μ · rw [tilted_apply' _ _ hs, ← ofReal_integral_eq_lintegral_ofReal] · exact hf.integrableOn.div_const _ · exact ae_of_all _ (fun _ ↦ by positivity) · simp only [hf, not_false_eq_true, tilted_of_not_integrable, Measure.coe_zero, Pi.zero_apply, integral_undef hf, div_zero, integral_zero, ENNReal.ofReal_zero] lemma tilted_apply_eq_ofReal_integral [SFinite μ] (f : α → ℝ) (s : Set α) : μ.tilted f s = ENNReal.ofReal (∫ a in s, exp (f a) / ∫ x, exp (f x) ∂μ ∂μ) := by by_cases hf : Integrable (fun x ↦ exp (f x)) μ · rw [tilted_apply _ _, ← ofReal_integral_eq_lintegral_ofReal] · exact hf.integrableOn.div_const _ · exact ae_of_all _ (fun _ ↦ by positivity) · simp [tilted_of_not_integrable hf, integral_undef hf] lemma isProbabilityMeasure_tilted [NeZero μ] (hf : Integrable (fun x ↦ exp (f x)) μ) : IsProbabilityMeasure (μ.tilted f) := by constructor simp_rw [tilted_apply' _ _ MeasurableSet.univ, setLIntegral_univ, ENNReal.ofReal_div_of_pos (integral_exp_pos hf), div_eq_mul_inv] rw [lintegral_mul_const'' _ hf.1.aemeasurable.ennreal_ofReal, ← ofReal_integral_eq_lintegral_ofReal hf (ae_of_all _ fun _ ↦ (exp_pos _).le), ENNReal.mul_inv_cancel] · simp only [ne_eq, ENNReal.ofReal_eq_zero, not_le] exact integral_exp_pos hf · simp instance isZeroOrProbabilityMeasure_tilted : IsZeroOrProbabilityMeasure (μ.tilted f) := by rcases eq_zero_or_neZero μ with hμ | hμ · simp only [hμ, tilted_zero_measure] infer_instance by_cases hf : Integrable (fun x ↦ exp (f x)) μ · have := isProbabilityMeasure_tilted hf infer_instance · simp only [hf, not_false_eq_true, tilted_of_not_integrable] infer_instance section lintegral lemma setLIntegral_tilted' (f : α → ℝ) (g : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) : ∫⁻ x in s, g x ∂(μ.tilted f) = ∫⁻ x in s, ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ) * g x ∂μ := by by_cases hf : AEMeasurable f μ · rw [Measure.tilted, setLIntegral_withDensity_eq_setLIntegral_mul_non_measurable₀] · simp only [Pi.mul_apply] · refine AEMeasurable.restrict ?_ exact ((measurable_exp.comp_aemeasurable hf).div_const _).ennreal_ofReal · exact hs · filter_upwards simp only [ENNReal.ofReal_lt_top, implies_true] · have hf' : ¬ Integrable (fun x ↦ exp (f x)) μ := by exact fun h ↦ hf (aemeasurable_of_aemeasurable_exp h.1.aemeasurable) simp only [hf, not_false_eq_true, tilted_of_not_aemeasurable, Measure.restrict_zero, lintegral_zero_measure] rw [integral_undef hf'] simp lemma setLIntegral_tilted [SFinite μ] (f : α → ℝ) (g : α → ℝ≥0∞) (s : Set α) : ∫⁻ x in s, g x ∂(μ.tilted f) = ∫⁻ x in s, ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ) * g x ∂μ := by by_cases hf : AEMeasurable f μ · rw [Measure.tilted, setLIntegral_withDensity_eq_setLIntegral_mul_non_measurable₀'] · simp only [Pi.mul_apply] · refine AEMeasurable.restrict ?_ exact ((measurable_exp.comp_aemeasurable hf).div_const _).ennreal_ofReal · filter_upwards simp only [ENNReal.ofReal_lt_top, implies_true] · have hf' : ¬ Integrable (fun x ↦ exp (f x)) μ := by exact fun h ↦ hf (aemeasurable_of_aemeasurable_exp h.1.aemeasurable) simp only [hf, not_false_eq_true, tilted_of_not_aemeasurable, Measure.restrict_zero, lintegral_zero_measure] rw [integral_undef hf'] simp lemma lintegral_tilted (f : α → ℝ) (g : α → ℝ≥0∞) : ∫⁻ x, g x ∂(μ.tilted f) = ∫⁻ x, ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ) * (g x) ∂μ := by rw [← setLIntegral_univ, setLIntegral_tilted' f g MeasurableSet.univ, setLIntegral_univ] end lintegral section integral variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] lemma setIntegral_tilted' (f : α → ℝ) (g : α → E) {s : Set α} (hs : MeasurableSet s) : ∫ x in s, g x ∂(μ.tilted f) = ∫ x in s, (exp (f x) / ∫ x, exp (f x) ∂μ) • (g x) ∂μ := by by_cases hf : AEMeasurable f μ · rw [tilted_eq_withDensity_nnreal, setIntegral_withDensity_eq_setIntegral_smul₀ _ _ hs] · congr · suffices AEMeasurable (fun x ↦ exp (f x) / ∫ x, exp (f x) ∂μ) μ by rw [← aemeasurable_coe_nnreal_real_iff] refine AEMeasurable.restrict ?_ simpa only [NNReal.coe_mk] exact (measurable_exp.comp_aemeasurable hf).div_const _ · have hf' : ¬ Integrable (fun x ↦ exp (f x)) μ := by exact fun h ↦ hf (aemeasurable_of_aemeasurable_exp h.1.aemeasurable) simp only [hf, not_false_eq_true, tilted_of_not_aemeasurable, Measure.restrict_zero, integral_zero_measure] rw [integral_undef hf'] simp lemma setIntegral_tilted [SFinite μ] (f : α → ℝ) (g : α → E) (s : Set α) : ∫ x in s, g x ∂(μ.tilted f) = ∫ x in s, (exp (f x) / ∫ x, exp (f x) ∂μ) • (g x) ∂μ := by by_cases hf : AEMeasurable f μ · rw [tilted_eq_withDensity_nnreal, setIntegral_withDensity_eq_setIntegral_smul₀'] · congr · suffices AEMeasurable (fun x ↦ exp (f x) / ∫ x, exp (f x) ∂μ) μ by rw [← aemeasurable_coe_nnreal_real_iff] refine AEMeasurable.restrict ?_ simpa only [NNReal.coe_mk] exact (measurable_exp.comp_aemeasurable hf).div_const _ · have hf' : ¬ Integrable (fun x ↦ exp (f x)) μ := by exact fun h ↦ hf (aemeasurable_of_aemeasurable_exp h.1.aemeasurable) simp only [hf, not_false_eq_true, tilted_of_not_aemeasurable, Measure.restrict_zero, integral_zero_measure] rw [integral_undef hf'] simp lemma integral_tilted (f : α → ℝ) (g : α → E) : ∫ x, g x ∂(μ.tilted f) = ∫ x, (exp (f x) / ∫ x, exp (f x) ∂μ) • (g x) ∂μ := by rw [← setIntegral_univ, setIntegral_tilted' f g MeasurableSet.univ, setIntegral_univ] end integral lemma integral_exp_tilted (f g : α → ℝ) : ∫ x, exp (g x) ∂(μ.tilted f) = (∫ x, exp ((f + g) x) ∂μ) / ∫ x, exp (f x) ∂μ := by cases eq_zero_or_neZero μ with | inl h => rw [h]; simp | inr h0 => rw [integral_tilted f] simp_rw [smul_eq_mul] have : ∀ x, (exp (f x) / ∫ x, exp (f x) ∂μ) * exp (g x) = (exp ((f + g) x) / ∫ x, exp (f x) ∂μ) := by intro x rw [Pi.add_apply, exp_add] ring simp_rw [this, div_eq_mul_inv] rw [integral_mul_const] lemma tilted_tilted (hf : Integrable (fun x ↦ exp (f x)) μ) (g : α → ℝ) : (μ.tilted f).tilted g = μ.tilted (f + g) := by cases eq_zero_or_neZero μ with | inl h => simp [h] | inr h0 => ext1 s hs rw [tilted_apply' _ _ hs, tilted_apply' _ _ hs, setLIntegral_tilted' f _ hs] congr with x rw [← ENNReal.ofReal_mul (by positivity), integral_exp_tilted f, Pi.add_apply, exp_add] congr 1 simp only [Pi.add_apply] have := (integral_exp_pos hf).ne' simp [field] lemma tilted_comm (hf : Integrable (fun x ↦ exp (f x)) μ) {g : α → ℝ} (hg : Integrable (fun x ↦ exp (g x)) μ) : (μ.tilted f).tilted g = (μ.tilted g).tilted f := by rw [tilted_tilted hf, add_comm, tilted_tilted hg] @[simp] lemma tilted_neg_same' (hf : Integrable (fun x ↦ exp (f x)) μ) : (μ.tilted f).tilted (-f) = (μ Set.univ)⁻¹ • μ := by rw [tilted_tilted hf]; simp lemma tilted_neg_same [IsProbabilityMeasure μ] (hf : Integrable (fun x ↦ exp (f x)) μ) : (μ.tilted f).tilted (-f) = μ := by simp [hf] lemma tilted_absolutelyContinuous (μ : Measure α) (f : α → ℝ) : μ.tilted f ≪ μ := withDensity_absolutelyContinuous _ _ lemma absolutelyContinuous_tilted (hf : Integrable (fun x ↦ exp (f x)) μ) : μ ≪ μ.tilted f := by cases eq_zero_or_neZero μ with | inl h => simp only [h, tilted_zero_measure]; exact fun _ _ ↦ by simp | inr h0 => refine withDensity_absolutelyContinuous' ?_ ?_ · exact (hf.1.aemeasurable.div_const _).ennreal_ofReal · filter_upwards simp only [ne_eq, ENNReal.ofReal_eq_zero, not_le] exact fun _ ↦ div_pos (exp_pos _) (integral_exp_pos hf) lemma integrable_tilted_iff {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {f : α → ℝ} (hf : Integrable (fun x ↦ exp (f x)) μ) (g : α → E) : Integrable g (μ.tilted f) ↔ Integrable (fun x ↦ exp (f x) • g x) μ := by by_cases hμ : μ = 0 · simp [hμ] have hf_meas : AEMeasurable f μ := aemeasurable_of_aemeasurable_exp hf.1.aemeasurable rw [Measure.tilted, integrable_withDensity_iff_integrable_smul₀' (by fun_prop) (by simp)] calc Integrable (fun x ↦ (ENNReal.ofReal (exp (f x) / ∫ a, exp (f a) ∂μ)).toReal • g x) μ _ ↔ Integrable (fun x ↦ (exp (f x) / ∫ a, exp (f a) ∂μ) • g x) μ := by congr! with a rw [ENNReal.toReal_ofReal] positivity _ ↔ Integrable (fun x ↦ (∫ a, exp (f a) ∂μ)⁻¹ • exp (f x) • g x) μ := by congr! 2 with a rw [smul_smul, div_eq_inv_mul] _ ↔ Integrable (fun x ↦ exp (f x) • g x) μ := by rw [integrable_fun_smul_iff] simp only [ne_eq, inv_eq_zero] have : NeZero μ := ⟨hμ⟩ exact (integral_exp_pos hf).ne' lemma rnDeriv_tilted_right (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν] (hf : Integrable (fun x ↦ exp (f x)) ν) : μ.rnDeriv (ν.tilted f) =ᵐ[ν] fun x ↦ ENNReal.ofReal (exp (-f x) * ∫ x, exp (f x) ∂ν) * μ.rnDeriv ν x := by cases eq_zero_or_neZero ν with | inl h => simp_rw [h, ae_zero, Filter.EventuallyEq]; exact Filter.eventually_bot | inr h0 => refine (Measure.rnDeriv_withDensity_right μ ν ?_ ?_ ?_).trans ?_ · exact (hf.1.aemeasurable.div_const _).ennreal_ofReal · filter_upwards simp only [ne_eq, ENNReal.ofReal_eq_zero, not_le] exact fun _ ↦ div_pos (exp_pos _) (integral_exp_pos hf) · refine ae_of_all _ (by simp) · filter_upwards with x congr rw [← ENNReal.ofReal_inv_of_pos, inv_div', ← exp_neg, div_eq_mul_inv, inv_inv] exact div_pos (exp_pos _) (integral_exp_pos hf) lemma toReal_rnDeriv_tilted_right (μ ν : Measure α) [SigmaFinite μ] [SigmaFinite ν] (hf : Integrable (fun x ↦ exp (f x)) ν) : (fun x ↦ (μ.rnDeriv (ν.tilted f) x).toReal) =ᵐ[ν] fun x ↦ exp (-f x) * (∫ x, exp (f x) ∂ν) * (μ.rnDeriv ν x).toReal := by filter_upwards [rnDeriv_tilted_right μ ν hf] with x hx rw [hx] simp only [ENNReal.toReal_mul, mul_eq_mul_right_iff, ENNReal.toReal_ofReal_eq_iff] exact Or.inl (by positivity) variable (μ) in lemma rnDeriv_tilted_left {ν : Measure α} [SigmaFinite μ] [SigmaFinite ν] (hfν : AEMeasurable f ν) : (μ.tilted f).rnDeriv ν =ᵐ[ν] fun x ↦ ENNReal.ofReal (exp (f x) / (∫ x, exp (f x) ∂μ)) * μ.rnDeriv ν x := by let g := fun x ↦ ENNReal.ofReal (exp (f x) / (∫ x, exp (f x) ∂μ)) refine Measure.rnDeriv_withDensity_left (μ := μ) (ν := ν) (f := g) ?_ ?_ · exact ((measurable_exp.comp_aemeasurable hfν).div_const _).ennreal_ofReal · exact ae_of_all _ (fun x ↦ by simp [g]) variable (μ) in lemma toReal_rnDeriv_tilted_left {ν : Measure α} [SigmaFinite μ] [SigmaFinite ν] (hfν : AEMeasurable f ν) : (fun x ↦ ((μ.tilted f).rnDeriv ν x).toReal) =ᵐ[ν] fun x ↦ exp (f x) / (∫ x, exp (f x) ∂μ) * (μ.rnDeriv ν x).toReal := by filter_upwards [rnDeriv_tilted_left μ hfν] with x hx rw [hx] simp only [ENNReal.toReal_mul, mul_eq_mul_right_iff, ENNReal.toReal_ofReal_eq_iff] exact Or.inl (by positivity) lemma rnDeriv_tilted_left_self [SigmaFinite μ] (hf : AEMeasurable f μ) : (μ.tilted f).rnDeriv μ =ᵐ[μ] fun x ↦ ENNReal.ofReal (exp (f x) / ∫ x, exp (f x) ∂μ) := by refine (rnDeriv_tilted_left μ hf).trans ?_ filter_upwards [Measure.rnDeriv_self μ] with x hx rw [hx, mul_one] lemma log_rnDeriv_tilted_left_self [SigmaFinite μ] (hf : Integrable (fun x ↦ exp (f x)) μ) : (fun x ↦ log ((μ.tilted f).rnDeriv μ x).toReal) =ᵐ[μ] fun x ↦ f x - log (∫ x, exp (f x) ∂μ) := by cases eq_zero_or_neZero μ with | inl h => simp_rw [h, ae_zero, Filter.EventuallyEq]; exact Filter.eventually_bot | inr h0 => have hf' : AEMeasurable f μ := aemeasurable_of_aemeasurable_exp hf.1.aemeasurable filter_upwards [rnDeriv_tilted_left_self hf'] with x hx rw [hx, ENNReal.toReal_ofReal (by positivity), log_div (exp_pos _).ne', log_exp] exact (integral_exp_pos hf).ne' end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/DiracProba.lean
import Mathlib.Topology.Separation.CompletelyRegular import Mathlib.MeasureTheory.Measure.ProbabilityMeasure /-! # Dirac deltas as probability measures and embedding of a space into probability measures on it ## Main definitions * `diracProba`: The Dirac delta mass at a point as a probability measure. ## Main results * `isEmbedding_diracProba`: If `X` is a completely regular T0 space with its Borel sigma algebra, then the mapping that takes a point `x : X` to the delta-measure `diracProba x` is an embedding `X ↪ ProbabilityMeasure X`. ## Tags probability measure, Dirac delta, embedding -/ open Topology Metric Filter Set ENNReal NNReal BoundedContinuousFunction open scoped Topology ENNReal NNReal BoundedContinuousFunction lemma CompletelyRegularSpace.exists_BCNN {X : Type*} [TopologicalSpace X] [CompletelyRegularSpace X] {K : Set X} (K_closed : IsClosed K) {x : X} (x_notin_K : x ∉ K) : ∃ (f : X →ᵇ ℝ≥0), f x = 1 ∧ (∀ y ∈ K, f y = 0) := by obtain ⟨g, g_cont, gx_zero, g_one_on_K⟩ := CompletelyRegularSpace.completely_regular x K K_closed x_notin_K have g_bdd : ∀ x y, dist (Real.toNNReal (g x)) (Real.toNNReal (g y)) ≤ 1 := by refine fun x y ↦ ((Real.lipschitzWith_toNNReal).dist_le_mul (g x) (g y)).trans ?_ simpa using Real.dist_le_of_mem_Icc_01 (g x).prop (g y).prop set g' := BoundedContinuousFunction.mkOfBound ⟨fun x ↦ Real.toNNReal (g x), continuous_real_toNNReal.comp g_cont.subtype_val⟩ 1 g_bdd set f := 1 - g' refine ⟨f, by simp [f, g', gx_zero], fun y y_in_K ↦ by simp [f, g', g_one_on_K y_in_K, tsub_self]⟩ namespace MeasureTheory section embed_to_probabilityMeasure variable {X : Type*} [MeasurableSpace X] /-- The Dirac delta mass at a point `x : X` as a `ProbabilityMeasure`. -/ noncomputable def diracProba (x : X) : ProbabilityMeasure X := ⟨Measure.dirac x, Measure.dirac.isProbabilityMeasure⟩ /-- The assignment `x ↦ diracProba x` is injective if all singletons are measurable. -/ lemma injective_diracProba {X : Type*} [MeasurableSpace X] [MeasurableSpace.SeparatesPoints X] : Function.Injective (fun (x : X) ↦ diracProba x) := by intro x y x_eq_y rw [← dirac_eq_dirac_iff] rwa [Subtype.ext_iff] at x_eq_y @[simp] lemma diracProba_toMeasure_apply' (x : X) {A : Set X} (A_mble : MeasurableSet A) : (diracProba x).toMeasure A = A.indicator 1 x := Measure.dirac_apply' x A_mble @[simp] lemma diracProba_toMeasure_apply_of_mem {x : X} {A : Set X} (x_in_A : x ∈ A) : (diracProba x).toMeasure A = 1 := Measure.dirac_apply_of_mem x_in_A @[simp] lemma diracProba_toMeasure_apply [MeasurableSingletonClass X] (x : X) (A : Set X) : (diracProba x).toMeasure A = A.indicator 1 x := Measure.dirac_apply _ _ variable [TopologicalSpace X] [OpensMeasurableSpace X] /-- The assignment `x ↦ diracProba x` is continuous `X → ProbabilityMeasure X`. -/ lemma continuous_diracProba : Continuous (fun (x : X) ↦ diracProba x) := by rw [continuous_iff_continuousAt] apply fun x ↦ ProbabilityMeasure.tendsto_iff_forall_lintegral_tendsto.mpr fun f ↦ ?_ have f_mble : Measurable (fun X ↦ (f X : ℝ≥0∞)) := measurable_coe_nnreal_ennreal_iff.mpr f.continuous.measurable simp only [diracProba, ProbabilityMeasure.coe_mk, lintegral_dirac' _ f_mble] exact (ENNReal.continuous_coe.comp f.continuous).continuousAt @[deprecated (since := "2025-08-15")] alias injective_diracProba_of_T0 := injective_diracProba lemma not_tendsto_diracProba_of_not_tendsto [CompletelyRegularSpace X] {x : X} (L : Filter X) (h : ¬ Tendsto id L (𝓝 x)) : ¬ Tendsto diracProba L (𝓝 (diracProba x)) := by obtain ⟨U, U_nhds, hU⟩ : ∃ U, U ∈ 𝓝 x ∧ ∃ᶠ x in L, x ∉ U := by by_contra! con apply h intro U U_nhds simpa only [not_frequently, not_not] using con U U_nhds have Uint_nhds : interior U ∈ 𝓝 x := by simpa only [interior_mem_nhds] using U_nhds obtain ⟨f, fx_eq_one, f_vanishes_outside⟩ := CompletelyRegularSpace.exists_BCNN isOpen_interior.isClosed_compl (by simpa only [mem_compl_iff, not_not] using mem_of_mem_nhds Uint_nhds) rw [ProbabilityMeasure.tendsto_iff_forall_lintegral_tendsto, not_forall] use f simp only [diracProba, ProbabilityMeasure.coe_mk, fx_eq_one, lintegral_dirac' _ (measurable_coe_nnreal_ennreal_iff.mpr f.continuous.measurable)] apply not_tendsto_iff_exists_frequently_notMem.mpr refine ⟨Ioi 0, Ioi_mem_nhds (by simp only [ENNReal.coe_one, zero_lt_one]), hU.mp (Eventually.of_forall ?_)⟩ intro x x_notin_U rw [f_vanishes_outside x (compl_subset_compl.mpr (show interior U ⊆ U from interior_subset) x_notin_U)] simp only [ENNReal.coe_zero, mem_Ioi, lt_self_iff_false, not_false_eq_true] lemma tendsto_diracProba_iff_tendsto [CompletelyRegularSpace X] {x : X} (L : Filter X) : Tendsto diracProba L (𝓝 (diracProba x)) ↔ Tendsto id L (𝓝 x) := by constructor · contrapose exact not_tendsto_diracProba_of_not_tendsto L · intro h have aux := (@continuous_diracProba X _ _ _).continuousAt (x := x) simp only [ContinuousAt] at aux exact aux.comp h /-- An inverse function to `diracProba` (only really an inverse under hypotheses that guarantee injectivity of `diracProba`). -/ noncomputable def diracProbaInverse : range (diracProba (X := X)) → X := fun μ' ↦ (mem_range.mp μ'.prop).choose -- We redeclare `X` here to temporarily avoid the `[TopologicalSpace X]` instance. @[simp] lemma diracProba_diracProbaInverse {X : Type*} [MeasurableSpace X] (μ : range (diracProba (X := X))) : diracProba (diracProbaInverse μ) = μ := (mem_range.mp μ.prop).choose_spec lemma diracProbaInverse_eq [T0Space X] {x : X} {μ : range (diracProba (X := X))} (h : μ = diracProba x) : diracProbaInverse μ = x := by apply injective_diracProba (X := X) simp only [← h] exact (mem_range.mp μ.prop).choose_spec /-- In a T0 topological space `X`, the assignment `x ↦ diracProba x` is a bijection to its range in `ProbabilityMeasure X`. -/ noncomputable def diracProbaEquiv [T0Space X] : X ≃ range (diracProba (X := X)) where toFun := fun x ↦ ⟨diracProba x, by exact mem_range_self x⟩ invFun := diracProbaInverse left_inv x := by apply diracProbaInverse_eq; rfl right_inv μ := Subtype.ext (by simp only [diracProba_diracProbaInverse]) /-- The composition of `diracProbaEquiv.symm` and `diracProba` is the subtype inclusion. -/ lemma diracProba_comp_diracProbaEquiv_symm_eq_val [T0Space X] : diracProba ∘ (diracProbaEquiv (X := X)).symm = fun μ ↦ μ.val := by funext μ; simp [diracProbaEquiv] lemma tendsto_diracProbaEquivSymm_iff_tendsto [T0Space X] [CompletelyRegularSpace X] {μ : range (diracProba (X := X))} (F : Filter (range (diracProba (X := X)))) : Tendsto diracProbaEquiv.symm F (𝓝 (diracProbaEquiv.symm μ)) ↔ Tendsto id F (𝓝 μ) := by have key := tendsto_diracProba_iff_tendsto (F.map diracProbaEquiv.symm) (x := diracProbaEquiv.symm μ) rw [← (diracProbaEquiv (X := X)).symm_comp_self, ← tendsto_map'_iff] at key simp only [tendsto_map'_iff, map_map, Equiv.self_comp_symm, map_id] at key simp only [← key, diracProba_comp_diracProbaEquiv_symm_eq_val] convert tendsto_subtype_rng.symm exact apply_rangeSplitting (fun x ↦ diracProba x) μ /-- In a T0 topological space, `diracProbaEquiv` is continuous. -/ lemma continuous_diracProbaEquiv [T0Space X] : Continuous (diracProbaEquiv (X := X)) := Continuous.subtype_mk continuous_diracProba mem_range_self /-- In a completely regular T0 topological space, the inverse of `diracProbaEquiv` is continuous. -/ lemma continuous_diracProbaEquivSymm [T0Space X] [CompletelyRegularSpace X] : Continuous (diracProbaEquiv (X := X)).symm := by apply continuous_iff_continuousAt.mpr intro μ apply continuousAt_of_tendsto_nhds (y := diracProbaInverse μ) exact (tendsto_diracProbaEquivSymm_iff_tendsto _).mpr fun _ mem_nhds ↦ mem_nhds /-- In a completely regular T0 topological space `X`, `diracProbaEquiv` is a homeomorphism to its image in `ProbabilityMeasure X`. -/ noncomputable def diracProbaHomeomorph [T0Space X] [CompletelyRegularSpace X] : X ≃ₜ range (diracProba (X := X)) := @Homeomorph.mk X _ _ _ diracProbaEquiv continuous_diracProbaEquiv continuous_diracProbaEquivSymm /-- If `X` is a completely regular T0 space with its Borel sigma algebra, then the mapping that takes a point `x : X` to the delta-measure `diracProba x` is an embedding `X → ProbabilityMeasure X`. -/ theorem isEmbedding_diracProba [T0Space X] [CompletelyRegularSpace X] : IsEmbedding (fun (x : X) ↦ diracProba x) := IsEmbedding.subtypeVal.comp diracProbaHomeomorph.isEmbedding end embed_to_probabilityMeasure end MeasureTheory
.lake/packages/mathlib/Mathlib/MeasureTheory/Measure/AEDisjoint.lean
import Mathlib.MeasureTheory.Measure.MeasureSpaceDef /-! # Almost everywhere disjoint sets We say that sets `s` and `t` are `μ`-a.e. disjoint (see `MeasureTheory.AEDisjoint`) if their intersection has measure zero. This assumption can be used instead of `Disjoint` in most theorems in measure theory. -/ open Set Function namespace MeasureTheory variable {ι α : Type*} {m : MeasurableSpace α} (μ : Measure α) /-- Two sets are said to be `μ`-a.e. disjoint if their intersection has measure zero. -/ def AEDisjoint (s t : Set α) := μ (s ∩ t) = 0 variable {μ} {s t u v : Set α} /-- If `s : ι → Set α` is a countable family of pairwise a.e. disjoint sets, then there exists a family of measurable null sets `t i` such that `s i \ t i` are pairwise disjoint. -/ theorem exists_null_pairwise_disjoint_diff [Countable ι] {s : ι → Set α} (hd : Pairwise (AEDisjoint μ on s)) : ∃ t : ι → Set α, (∀ i, MeasurableSet (t i)) ∧ (∀ i, μ (t i) = 0) ∧ Pairwise (Disjoint on fun i => s i \ t i) := by refine ⟨fun i => toMeasurable μ (s i ∩ ⋃ j ∈ ({i}ᶜ : Set ι), s j), fun i => measurableSet_toMeasurable _ _, fun i => ?_, ?_⟩ · simp only [measure_toMeasurable, inter_iUnion] exact (measure_biUnion_null_iff <| to_countable _).2 fun j hj => hd (Ne.symm hj) · simp only [Pairwise, disjoint_left, onFun, mem_diff, not_and, and_imp, Classical.not_not] intro i j hne x hi hU hj replace hU : x ∉ s i ∩ iUnion fun j ↦ iUnion fun _ ↦ s j := fun h ↦ hU (subset_toMeasurable _ _ h) simp only [mem_inter_iff, mem_iUnion, not_and, not_exists] at hU exact (hU hi j hne.symm hj).elim namespace AEDisjoint protected theorem eq (h : AEDisjoint μ s t) : μ (s ∩ t) = 0 := h @[symm] protected theorem symm (h : AEDisjoint μ s t) : AEDisjoint μ t s := by rwa [AEDisjoint, inter_comm] protected theorem symmetric : Symmetric (AEDisjoint μ) := fun _ _ => AEDisjoint.symm protected theorem comm : AEDisjoint μ s t ↔ AEDisjoint μ t s := ⟨AEDisjoint.symm, AEDisjoint.symm⟩ protected theorem _root_.Disjoint.aedisjoint (h : Disjoint s t) : AEDisjoint μ s t := by rw [AEDisjoint, disjoint_iff_inter_eq_empty.1 h, measure_empty] protected theorem _root_.Pairwise.aedisjoint {f : ι → Set α} (hf : Pairwise (Disjoint on f)) : Pairwise (AEDisjoint μ on f) := hf.mono fun _i _j h => h.aedisjoint protected theorem _root_.Set.PairwiseDisjoint.aedisjoint {f : ι → Set α} {s : Set ι} (hf : s.PairwiseDisjoint f) : s.Pairwise (AEDisjoint μ on f) := hf.mono' fun _i _j h => h.aedisjoint theorem mono_ae (h : AEDisjoint μ s t) (hu : u ≤ᵐ[μ] s) (hv : v ≤ᵐ[μ] t) : AEDisjoint μ u v := measure_mono_null_ae (hu.inter hv) h protected theorem mono (h : AEDisjoint μ s t) (hu : u ⊆ s) (hv : v ⊆ t) : AEDisjoint μ u v := mono_ae h (HasSubset.Subset.eventuallyLE hu) (HasSubset.Subset.eventuallyLE hv) protected theorem congr (h : AEDisjoint μ s t) (hu : u =ᵐ[μ] s) (hv : v =ᵐ[μ] t) : AEDisjoint μ u v := mono_ae h (Filter.EventuallyEq.le hu) (Filter.EventuallyEq.le hv) @[simp] theorem iUnion_left_iff {ι : Sort*} [Countable ι] {s : ι → Set α} : AEDisjoint μ (⋃ i, s i) t ↔ ∀ i, AEDisjoint μ (s i) t := by simp only [AEDisjoint, iUnion_inter, measure_iUnion_null_iff] @[simp] theorem iUnion_right_iff {ι : Sort*} [Countable ι] {t : ι → Set α} : AEDisjoint μ s (⋃ i, t i) ↔ ∀ i, AEDisjoint μ s (t i) := by simp only [AEDisjoint, inter_iUnion, measure_iUnion_null_iff] @[simp] theorem union_left_iff : AEDisjoint μ (s ∪ t) u ↔ AEDisjoint μ s u ∧ AEDisjoint μ t u := by simp [union_eq_iUnion, and_comm] @[simp] theorem union_right_iff : AEDisjoint μ s (t ∪ u) ↔ AEDisjoint μ s t ∧ AEDisjoint μ s u := by simp [union_eq_iUnion, and_comm] theorem union_left (hs : AEDisjoint μ s u) (ht : AEDisjoint μ t u) : AEDisjoint μ (s ∪ t) u := union_left_iff.mpr ⟨hs, ht⟩ theorem union_right (ht : AEDisjoint μ s t) (hu : AEDisjoint μ s u) : AEDisjoint μ s (t ∪ u) := union_right_iff.2 ⟨ht, hu⟩ theorem diff_ae_eq_left (h : AEDisjoint μ s t) : (s \ t : Set α) =ᵐ[μ] s := @diff_self_inter _ s t ▸ diff_null_ae_eq_self h theorem diff_ae_eq_right (h : AEDisjoint μ s t) : (t \ s : Set α) =ᵐ[μ] t := diff_ae_eq_left <| AEDisjoint.symm h theorem measure_diff_left (h : AEDisjoint μ s t) : μ (s \ t) = μ s := measure_congr <| AEDisjoint.diff_ae_eq_left h theorem measure_diff_right (h : AEDisjoint μ s t) : μ (t \ s) = μ t := measure_congr <| AEDisjoint.diff_ae_eq_right h /-- If `s` and `t` are `μ`-a.e. disjoint, then `s \ u` and `t` are disjoint for some measurable null set `u`. -/ theorem exists_disjoint_diff (h : AEDisjoint μ s t) : ∃ u, MeasurableSet u ∧ μ u = 0 ∧ Disjoint (s \ u) t := ⟨toMeasurable μ (s ∩ t), measurableSet_toMeasurable _ _, (measure_toMeasurable _).trans h, disjoint_sdiff_self_left.mono_left (b := s \ t) fun x hx => by simpa using ⟨hx.1, fun hxt => hx.2 <| subset_toMeasurable _ _ ⟨hx.1, hxt⟩⟩⟩ theorem of_null_right (h : μ t = 0) : AEDisjoint μ s t := measure_mono_null inter_subset_right h theorem of_null_left (h : μ s = 0) : AEDisjoint μ s t := AEDisjoint.symm (of_null_right h) end AEDisjoint theorem aedisjoint_compl_left : AEDisjoint μ sᶜ s := (@disjoint_compl_left _ _ s).aedisjoint theorem aedisjoint_compl_right : AEDisjoint μ s sᶜ := (@disjoint_compl_right _ _ s).aedisjoint end MeasureTheory