|
| 1 | +/- |
| 2 | +Copyright (c) 2026 Rémy Degenne. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Rémy Degenne |
| 5 | +-/ |
| 6 | +module |
| 7 | + |
| 8 | +public import Mathlib.MeasureTheory.Measure.Decomposition.Lebesgue |
| 9 | +public import Mathlib.MeasureTheory.Measure.Sub |
| 10 | + |
| 11 | +import Mathlib.MeasureTheory.Integral.Lebesgue.Sub |
| 12 | + |
| 13 | +/-! |
| 14 | +# Results about subtraction of finite measures |
| 15 | +
|
| 16 | +The content of this file is not placed in `MeasureTheory.Measure.Sub` because it uses tools that are |
| 17 | +not imported in the other file: the Hahn decomposition of finite measures and measures built with |
| 18 | +`withDensity`. |
| 19 | +
|
| 20 | +## Main statements |
| 21 | +
|
| 22 | +* `sub_le_iff_le_add`: for `μ` and `ν` finite measures, `μ - ν ≤ ξ ↔ μ ≤ ξ + ν`. See also |
| 23 | + `sub_le_iff_le_add_of_le` for the case where only `ν` is finite, with the additional hypothesis |
| 24 | + `ν ≤ μ`. |
| 25 | +* `withDensity_sub`: If `μ.withDensity g` is finite, then |
| 26 | + `μ.withDensity (f - g) = μ.withDensity f - μ.withDensity g`. |
| 27 | +
|
| 28 | +-/ |
| 29 | + |
| 30 | +@[expose] public section |
| 31 | + |
| 32 | +open scoped ENNReal |
| 33 | + |
| 34 | +namespace MeasureTheory.Measure |
| 35 | + |
| 36 | +variable {α : Type*} {mα : MeasurableSpace α} {μ ν ξ : Measure α} |
| 37 | + |
| 38 | +lemma sub_le_iff_le_add [IsFiniteMeasure μ] [IsFiniteMeasure ν] : μ - ν ≤ ξ ↔ μ ≤ ξ + ν := by |
| 39 | + refine ⟨fun h ↦ ?_, sub_le_of_le_add⟩ |
| 40 | + obtain ⟨s, hs⟩ := exists_isHahnDecomposition μ ν |
| 41 | + have h_le_s : μ.restrict s ≤ ξ.restrict s + ν.restrict s := |
| 42 | + hs.le_on.trans (Measure.le_add_left le_rfl) |
| 43 | + have h_le_s_compl : μ.restrict sᶜ ≤ ξ.restrict sᶜ + ν.restrict sᶜ := by |
| 44 | + refine (sub_le_iff_le_add_of_le hs.ge_on_compl).mp ?_ |
| 45 | + rw [← restrict_sub_eq_restrict_sub_restrict hs.measurableSet.compl] |
| 46 | + exact restrict_mono subset_rfl h |
| 47 | + rw [← restrict_add_restrict_compl (μ := μ) hs.measurableSet, |
| 48 | + ← restrict_add_restrict_compl (μ := ξ) hs.measurableSet, |
| 49 | + ← restrict_add_restrict_compl (μ := ν) hs.measurableSet] |
| 50 | + suffices μ.restrict s + μ.restrict sᶜ ≤ |
| 51 | + ξ.restrict s + ν.restrict s + (ξ.restrict sᶜ + ν.restrict sᶜ) from this.trans_eq (by abel) |
| 52 | + gcongr |
| 53 | + |
| 54 | +lemma withDensity_sub_of_le {f g : α → ℝ≥0∞} [IsFiniteMeasure (μ.withDensity g)] |
| 55 | + (hg : Measurable g) (hgf : g ≤ᵐ[μ] f) : |
| 56 | + μ.withDensity (f - g) = μ.withDensity f - μ.withDensity g := by |
| 57 | + ext s hs |
| 58 | + rw [sub_apply hs (withDensity_mono hgf), withDensity_apply _ hs, withDensity_apply _ hs, |
| 59 | + withDensity_apply _ hs, ← lintegral_sub hg _ (ae_restrict_of_ae hgf)] |
| 60 | + · simp |
| 61 | + · simp [← withDensity_apply _ hs] |
| 62 | + |
| 63 | +lemma withDensity_sub {f g : α → ℝ≥0∞} [IsFiniteMeasure (μ.withDensity g)] |
| 64 | + (hf : Measurable f) (hg : Measurable g) : |
| 65 | + μ.withDensity (f - g) = μ.withDensity f - μ.withDensity g := by |
| 66 | + refine le_antisymm ?_ ?_ |
| 67 | + · let t := {x | f x ≤ g x} |
| 68 | + have ht : MeasurableSet t := measurableSet_le hf hg |
| 69 | + rw [← restrict_add_restrict_compl (μ := μ.withDensity (f - g)) ht, |
| 70 | + ← restrict_add_restrict_compl (μ := μ.withDensity f - μ.withDensity g) ht] |
| 71 | + have h_zero : (μ.withDensity (f - g)).restrict t = 0 := by |
| 72 | + simp only [restrict_eq_zero] |
| 73 | + rw [withDensity_apply _ ht, lintegral_eq_zero_iff (by fun_prop)] |
| 74 | + refine ae_restrict_of_forall_mem ht fun x hx ↦ ?_ |
| 75 | + simpa [tsub_eq_zero_iff_le] |
| 76 | + rw [h_zero, zero_add] |
| 77 | + suffices (μ.withDensity (f - g)).restrict tᶜ ≤ |
| 78 | + (μ.withDensity f - μ.withDensity g).restrict tᶜ from this.trans (Measure.le_add_left le_rfl) |
| 79 | + rw [restrict_sub_eq_restrict_sub_restrict ht.compl] |
| 80 | + simp_rw [restrict_withDensity ht.compl] |
| 81 | + have : IsFiniteMeasure ((μ.restrict tᶜ).withDensity g) := by |
| 82 | + rw [← restrict_withDensity ht.compl] |
| 83 | + infer_instance |
| 84 | + rw [withDensity_sub_of_le hg] |
| 85 | + refine ae_restrict_of_forall_mem ht.compl fun x hx ↦ ?_ |
| 86 | + simp only [Set.mem_compl_iff, Set.mem_setOf_eq, not_le, t] at hx |
| 87 | + exact hx.le |
| 88 | + · refine sub_le_of_le_add ?_ |
| 89 | + rw [← withDensity_add_right _ hg] |
| 90 | + exact withDensity_mono (ae_of_all _ fun x ↦ le_tsub_add) |
| 91 | + |
| 92 | +end MeasureTheory.Measure |
0 commit comments