Skip to content

Commit

Permalink
feat: Checking ae on a countable type (#8945)
Browse files Browse the repository at this point in the history
and other simple measure lemmas

From PFR and LeanCamCombi



Co-authored-by: Yury G. Kudryashov <urkud@urkud.name>
  • Loading branch information
2 people authored and awueth committed Dec 19, 2023
1 parent 55ae821 commit 27d1097
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 33 deletions.
21 changes: 7 additions & 14 deletions Mathlib/MeasureTheory/Decomposition/Lebesgue.lean
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ instance haveLebesgueDecomposition_smul_right (μ ν : Measure α) [HaveLebesgue
refine ⟨⟨μ.singularPart ν, r⁻¹ • μ.rnDeriv ν⟩, ?_, ?_, ?_⟩
· change Measurable (r⁻¹ • μ.rnDeriv ν)
exact hmeas.const_smul _
· refine MutuallySingular.mono_ac hsing AbsolutelyContinuous.rfl ?_
exact absolutelyContinuous_of_le_smul le_rfl
· exact hsing.mono_ac AbsolutelyContinuous.rfl smul_absolutelyContinuous
· have : r⁻¹ • rnDeriv μ ν = ((r⁻¹ : ℝ≥0) : ℝ≥0∞) • rnDeriv μ ν := by simp [ENNReal.smul_def]
rw [this, withDensity_smul _ hmeas, ENNReal.smul_def r, withDensity_smul_measure,
← smul_assoc, smul_eq_mul, ENNReal.coe_inv hr, ENNReal.inv_mul_cancel, one_smul]
Expand Down Expand Up @@ -388,8 +387,8 @@ theorem singularPart_smul_right (μ ν : Measure α) (r : ℝ≥0) (hr : r ≠ 0
μ.singularPart (r • ν) = μ.singularPart ν := by
by_cases hl : HaveLebesgueDecomposition μ ν
· refine (eq_singularPart ((measurable_rnDeriv μ ν).const_smul r⁻¹) ?_ ?_).symm
· refine (mutuallySingular_singularPart μ ν).mono_ac AbsolutelyContinuous.rfl ?_
exact absolutelyContinuous_of_le_smul le_rfl
· exact (mutuallySingular_singularPart μ ν).mono_ac AbsolutelyContinuous.rfl
smul_absolutelyContinuous
· rw [ENNReal.smul_def r, withDensity_smul_measure, ← withDensity_smul]
swap; · exact (measurable_rnDeriv _ _).const_smul _
convert haveLebesgueDecomposition_add μ ν
Expand Down Expand Up @@ -546,11 +545,8 @@ See also `rnDeriv_smul_right'`, which requires sigma-finite `ν` and `μ`. -/
theorem rnDeriv_smul_right (ν μ : Measure α) [IsFiniteMeasure ν]
[ν.HaveLebesgueDecomposition μ] {r : ℝ≥0} (hr : r ≠ 0) :
ν.rnDeriv (r • μ) =ᵐ[μ] r⁻¹ • ν.rnDeriv μ := by
suffices ν.rnDeriv (r • μ) =ᵐ[r • μ] r⁻¹ • ν.rnDeriv μ by
suffices hμ : μ ≪ r • μ by exact hμ.ae_le this
refine absolutelyContinuous_of_le_smul (c := r⁻¹) ?_
rw [← ENNReal.coe_inv hr, ← ENNReal.smul_def, ← smul_assoc, smul_eq_mul,
inv_mul_cancel hr, one_smul]
refine (absolutelyContinuous_smul $ ENNReal.coe_ne_zero.2 hr).ae_le
(?_ : ν.rnDeriv (r • μ) =ᵐ[r • μ] r⁻¹ • ν.rnDeriv μ)
rw [← withDensity_eq_iff]
rotate_left
· exact (measurable_rnDeriv _ _).aemeasurable
Expand Down Expand Up @@ -1019,11 +1015,8 @@ See also `rnDeriv_smul_right`, which has no hypothesis on `μ` but requires fini
theorem rnDeriv_smul_right' (ν μ : Measure α) [SigmaFinite ν] [SigmaFinite μ]
{r : ℝ≥0} (hr : r ≠ 0) :
ν.rnDeriv (r • μ) =ᵐ[μ] r⁻¹ • ν.rnDeriv μ := by
suffices ν.rnDeriv (r • μ) =ᵐ[r • μ] r⁻¹ • ν.rnDeriv μ by
suffices hμ : μ ≪ r • μ by exact hμ.ae_le this
refine absolutelyContinuous_of_le_smul (c := r⁻¹) ?_
rw [← ENNReal.coe_inv hr, ← ENNReal.smul_def, ← smul_assoc, smul_eq_mul,
inv_mul_cancel hr, one_smul]
refine (absolutelyContinuous_smul $ ENNReal.coe_ne_zero.2 hr).ae_le
(?_ : ν.rnDeriv (r • μ) =ᵐ[r • μ] r⁻¹ • ν.rnDeriv μ)
rw [← withDensity_eq_iff_of_sigmaFinite]
· simp_rw [ENNReal.smul_def]
rw [withDensity_smul _ (measurable_rnDeriv _ _)]
Expand Down
5 changes: 0 additions & 5 deletions Mathlib/MeasureTheory/Measure/AEMeasurable.lean
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ lemma aemeasurable_of_map_neZero {mβ : MeasurableSpace β} {μ : Measure α}

namespace AEMeasurable

protected theorem nullMeasurable (h : AEMeasurable f μ) : NullMeasurable f μ :=
let ⟨_g, hgm, hg⟩ := h
hgm.nullMeasurable.congr hg.symm
#align ae_measurable.null_measurable AEMeasurable.nullMeasurable

lemma mono_ac (hf : AEMeasurable f ν) (hμν : μ ≪ ν) : AEMeasurable f μ :=
⟨hf.mk f, hf.measurable_mk, hμν.ae_le hf.ae_eq_mk⟩

Expand Down
12 changes: 7 additions & 5 deletions Mathlib/MeasureTheory/Measure/Dirac.lean
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ In this file we define the Dirac measure `MeasureTheory.Measure.dirac a`
and prove some basic facts about it.
-/

set_option autoImplicit true

open Function Set
open scoped ENNReal Classical

noncomputable section

variable [MeasurableSpace α] [MeasurableSpace β] {s : Set α}
variable {α β δ : Type*} [MeasurableSpace α] [MeasurableSpace β] {s : Set α} {a : α}

namespace MeasureTheory

Expand Down Expand Up @@ -140,11 +138,15 @@ theorem ae_eq_dirac [MeasurableSingletonClass α] {a : α} (f : α → δ) :
f =ᵐ[dirac a] const α (f a) := by simp [Filter.EventuallyEq]
#align measure_theory.ae_eq_dirac MeasureTheory.ae_eq_dirac

instance Measure.dirac.isProbabilityMeasure [MeasurableSpace α] {x : α} :
IsProbabilityMeasure (dirac x) :=
instance Measure.dirac.isProbabilityMeasure {x : α} : IsProbabilityMeasure (dirac x) :=
⟨dirac_apply_of_mem <| mem_univ x⟩
#align measure_theory.measure.dirac.is_probability_measure MeasureTheory.Measure.dirac.isProbabilityMeasure

/-! Extra instances to short-circuit type class resolution -/

instance Measure.dirac.instIsFiniteMeasure {a : α} : IsFiniteMeasure (dirac a) := inferInstance
instance Measure.dirac.instSigmaFinite {a : α} : SigmaFinite (dirac a) := inferInstance

theorem restrict_dirac' (hs : MeasurableSet s) [Decidable (a ∈ s)] :
(Measure.dirac a).restrict s = if a ∈ s then Measure.dirac a else 0 := by
split_ifs with has
Expand Down
61 changes: 53 additions & 8 deletions Mathlib/MeasureTheory/Measure/MeasureSpace.lean
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ theorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α
rw [← Set.biUnion_preimage_singleton, measure_biUnion hs (pairwiseDisjoint_fiber f s) hf]
#align measure_theory.tsum_measure_preimage_singleton MeasureTheory.tsum_measure_preimage_singleton

lemma measure_preimage_eq_zero_iff_of_countable {s : Set β} {f : α → β} (hs : s.Countable) :
μ (f ⁻¹' s) = 0 ↔ ∀ x ∈ s, μ (f ⁻¹' {x}) = 0 := by
rw [← biUnion_preimage_singleton, measure_biUnion_null_iff hs]

/-- If `s` is a `Finset`, then the measure of its preimage can be found as the sum of measures
of the fibers `f ⁻¹' {y}`. -/
theorem sum_measure_preimage_singleton (s : Finset β) {f : α → β}
Expand Down Expand Up @@ -287,11 +291,20 @@ theorem measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : Set α}
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2
#align measure_theory.measure_eq_measure_larger_of_between_null_diff MeasureTheory.measure_eq_measure_larger_of_between_null_diff

theorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ sᶜ = μ univ - μ s := by
rw [compl_eq_univ_diff]
exact measure_diff (subset_univ s) h₁ h_fin
lemma measure_compl₀ (h : NullMeasurableSet s μ) (hs : μ s ≠ ∞) :
μ sᶜ = μ Set.univ - μ s := by
rw [← measure_add_measure_compl₀ h, ENNReal.add_sub_cancel_left hs]

theorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ sᶜ = μ univ - μ s :=
measure_compl₀ h₁.nullMeasurableSet h_fin
#align measure_theory.measure_compl MeasureTheory.measure_compl

lemma measure_inter_conull' (ht : μ (s \ t) = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null']; rwa [← diff_eq]

lemma measure_inter_conull (ht : μ tᶜ = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null ht]

@[simp]
theorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ᵐ[μ] s := by
rw [ae_le_set]
Expand Down Expand Up @@ -852,6 +865,10 @@ instance instIsCentralScalar [SMul Rᵐᵒᵖ ℝ≥0∞] [IsCentralScalar R ℝ

end SMul

instance instNoZeroSMulDivisors [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[NoZeroSMulDivisors R ℝ≥0∞] : NoZeroSMulDivisors R (Measure α) where
eq_zero_or_eq_zero_of_smul_eq_zero h := by simpa [Ne.def, @ext_iff', forall_or_left] using h

instance instMulAction [Monoid R] [MulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[MeasurableSpace α] : MulAction R (Measure α) :=
Injective.mulAction _ toOuterMeasure_injective smul_toOuterMeasure
Expand Down Expand Up @@ -1219,6 +1236,8 @@ protected theorem map_smul_nnreal (c : ℝ≥0) (μ : Measure α) (f : α → β
μ.map_smul (c : ℝ≥0∞) f
#align measure_theory.measure.map_smul_nnreal MeasureTheory.Measure.map_smul_nnreal

variable {f : α → β}

lemma map_apply₀ {f : α → β} (hf : AEMeasurable f μ) {s : Set β}
(hs : NullMeasurableSet s (map f μ)) : μ.map f s = μ (f ⁻¹' s) := by
rw [map, dif_pos hf, mapₗ, dif_pos hf.measurable_mk] at hs ⊢
Expand All @@ -1228,24 +1247,33 @@ lemma map_apply₀ {f : α → β} (hf : AEMeasurable f μ) {s : Set β}
/-- We can evaluate the pushforward on measurable sets. For non-measurable sets, see
`MeasureTheory.Measure.le_map_apply` and `MeasurableEquiv.map_apply`. -/
@[simp]
theorem map_apply_of_aemeasurable {f : α → β} (hf : AEMeasurable f μ) {s : Set β}
(hs : MeasurableSet s) : μ.map f s = μ (f ⁻¹' s) :=
map_apply₀ hf hs.nullMeasurableSet
theorem map_apply_of_aemeasurable (hf : AEMeasurable f μ) {s : Set β} (hs : MeasurableSet s) :
μ.map f s = μ (f ⁻¹' s) := map_apply₀ hf hs.nullMeasurableSet
#align measure_theory.measure.map_apply_of_ae_measurable MeasureTheory.Measure.map_apply_of_aemeasurable

@[simp]
theorem map_apply {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
theorem map_apply (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
μ.map f s = μ (f ⁻¹' s) :=
map_apply_of_aemeasurable hf.aemeasurable hs
#align measure_theory.measure.map_apply MeasureTheory.Measure.map_apply

theorem map_toOuterMeasure {f : α → β} (hf : AEMeasurable f μ) :
theorem map_toOuterMeasure (hf : AEMeasurable f μ) :
(μ.map f).toOuterMeasure = (OuterMeasure.map f μ.toOuterMeasure).trim := by
rw [← trimmed, OuterMeasure.trim_eq_trim_iff]
intro s hs
rw [map_apply_of_aemeasurable hf hs, OuterMeasure.map_apply]
#align measure_theory.measure.map_to_outer_measure MeasureTheory.Measure.map_toOuterMeasure

@[simp] lemma map_eq_zero_iff (hf : AEMeasurable f μ) : μ.map f = 0 ↔ μ = 0 := by
simp_rw [← measure_univ_eq_zero, map_apply_of_aemeasurable hf .univ, preimage_univ]

@[simp] lemma mapₗ_eq_zero_iff (hf : Measurable f) : Measure.mapₗ f μ = 0 ↔ μ = 0 := by
rw [mapₗ_apply_of_measurable hf, map_eq_zero_iff hf.aemeasurable]

lemma map_ne_zero_iff (hf : AEMeasurable f μ) : μ.map f ≠ 0 ↔ μ ≠ 0 := (map_eq_zero_iff hf).not
lemma mapₗ_ne_zero_iff (hf : Measurable f) : Measure.mapₗ f μ ≠ 0 ↔ μ ≠ 0 :=
(mapₗ_eq_zero_iff hf).not

@[simp]
theorem map_id : map id μ = μ :=
ext fun _ => map_apply measurable_id
Expand Down Expand Up @@ -1615,11 +1643,19 @@ lemma add_right (h1 : μ ≪ ν) (ν' : Measure α) : μ ≪ ν + ν' := by

end AbsolutelyContinuous

alias absolutelyContinuous_refl := AbsolutelyContinuous.refl
alias absolutelyContinuous_rfl := AbsolutelyContinuous.rfl

theorem absolutelyContinuous_of_le_smul {μ' : Measure α} {c : ℝ≥0∞} (hμ'_le : μ' ≤ c • μ) :
μ' ≪ μ :=
(Measure.absolutelyContinuous_of_le hμ'_le).trans (Measure.AbsolutelyContinuous.rfl.smul c)
#align measure_theory.measure.absolutely_continuous_of_le_smul MeasureTheory.Measure.absolutelyContinuous_of_le_smul

lemma smul_absolutelyContinuous {c : ℝ≥0∞} : c • μ ≪ μ := absolutelyContinuous_of_le_smul le_rfl

lemma absolutelyContinuous_smul {c : ℝ≥0∞} (hc : c ≠ 0) : μ ≪ c • μ := by
simp [AbsolutelyContinuous, hc]

theorem ae_le_iff_absolutelyContinuous : μ.ae ≤ ν.ae ↔ μ ≪ ν :=
fun h s => by
rw [measure_zero_iff_ae_nmem, measure_zero_iff_ae_nmem]
Expand Down Expand Up @@ -1870,6 +1906,15 @@ open Measure

open MeasureTheory

protected theorem _root_.AEMeasurable.nullMeasurable {f : α → β} (h : AEMeasurable f μ) :
NullMeasurable f μ :=
let ⟨_g, hgm, hg⟩ := h; hgm.nullMeasurable.congr hg.symm
#align ae_measurable.null_measurable AEMeasurable.nullMeasurable

lemma _root_.AEMeasurable.nullMeasurableSet_preimage {f : α → β} {s : Set β}
(hf : AEMeasurable f μ) (hs : MeasurableSet s) : NullMeasurableSet (f ⁻¹' s) μ :=
hf.nullMeasurable hs

/-- The preimage of a null measurable set under a (quasi) measure preserving map is a null
measurable set. -/
theorem NullMeasurableSet.preimage {ν : Measure β} {f : α → β} {t : Set β}
Expand Down
9 changes: 8 additions & 1 deletion Mathlib/MeasureTheory/Measure/MeasureSpaceDef.lean
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ theorem measure_sUnion_null_iff {S : Set (Set α)} (hS : S.Countable) :
μ.toOuterMeasure.sUnion_null_iff hS
#align measure_theory.measure_sUnion_null_iff MeasureTheory.measure_sUnion_null_iff

lemma measure_null_iff_singleton {s : Set α} (hs : s.Countable) : μ s = 0 ↔ ∀ x ∈ s, μ {x} = 0 := by
rw [← measure_biUnion_null_iff hs, biUnion_of_singleton]

theorem measure_union_le (s₁ s₂ : Set α) : μ (s₁ ∪ s₂) ≤ μ s₁ + μ s₂ :=
μ.toOuterMeasure.union _ _
#align measure_theory.measure_union_le MeasureTheory.measure_union_le
Expand Down Expand Up @@ -428,7 +431,11 @@ theorem all_ae_of {ι : Sort _} {p : α → ι → Prop} (hp : ∀ᵐ a ∂μ,
∀ᵐ a ∂μ, p a i := by
filter_upwards [hp] with a ha using ha i

theorem ae_ball_iff {S : Set ι} (hS : S.Countable) {p : ∀ (_x : α), ∀ i ∈ S, Prop} :
lemma ae_iff_of_countable [Countable α] {p : α → Prop} : (∀ᵐ x ∂μ, p x) ↔ ∀ x, μ {x} ≠ 0 → p x := by
rw [ae_iff, measure_null_iff_singleton]
exacts [forall_congr' fun _ ↦ not_imp_comm, Set.to_countable _]

theorem ae_ball_iff {S : Set ι} (hS : S.Countable) {p : α → ∀ i ∈ S, Prop} :
(∀ᵐ x ∂μ, ∀ i (hi : i ∈ S), p x i hi) ↔ ∀ i (hi : i ∈ S), ∀ᵐ x ∂μ, p x i hi :=
eventually_countable_ball hS
#align measure_theory.ae_ball_iff MeasureTheory.ae_ball_iff
Expand Down

0 comments on commit 27d1097

Please sign in to comment.