Skip to content

Commit 20fad7b

Browse files
committed
feat: results about subtraction of measures (leanprover-community#35018)
Main results: * `sub_le_iff_le_add`: for `μ` and `ν` finite measures, `μ - ν ≤ ξ ↔ μ ≤ ξ + ν`. * `withDensity_sub`: If `μ.withDensity g` is finite, then `μ.withDensity (f - g) = μ.withDensity f - μ.withDensity g`. Co-authored-by: Remy Degenne <remydegenne@gmail.com>
1 parent 5179aba commit 20fad7b

4 files changed

Lines changed: 125 additions & 1 deletion

File tree

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5206,6 +5206,7 @@ public import Mathlib.MeasureTheory.Measure.Restrict
52065206
public import Mathlib.MeasureTheory.Measure.SeparableMeasure
52075207
public import Mathlib.MeasureTheory.Measure.Stieltjes
52085208
public import Mathlib.MeasureTheory.Measure.Sub
5209+
public import Mathlib.MeasureTheory.Measure.SubFinite
52095210
public import Mathlib.MeasureTheory.Measure.Support
52105211
public import Mathlib.MeasureTheory.Measure.Tight
52115212
public import Mathlib.MeasureTheory.Measure.TightNormed

Mathlib/MeasureTheory/Measure/Decomposition/Lebesgue.lean

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,27 @@ lemma rnDeriv_add_of_mutuallySingular (ν₁ ν₂ μ : Measure α)
10581058

10591059
end rnDeriv
10601060

1061+
lemma add_sub_of_mutuallySingular {ξ : Measure α} (h : μ ⟂ₘ ξ) : μ + (ν - ξ) = μ + ν - ξ := by
1062+
let s := h.nullSet
1063+
have hs : MeasurableSet s := h.measurableSet_nullSet
1064+
have h_le_s : μ.restrict s + (ν - ξ).restrict s = μ.restrict s + ν.restrict s - ξ.restrict s := by
1065+
rw [h.restrict_nullSet, restrict_sub_eq_restrict_sub_restrict hs]
1066+
simp
1067+
have h_le_s_compl : μ.restrict sᶜ + (ν - ξ).restrict sᶜ =
1068+
μ.restrict sᶜ + ν.restrict sᶜ - ξ.restrict sᶜ := by
1069+
rw [restrict_sub_eq_restrict_sub_restrict hs.compl, h.restrict_compl_nullSet]
1070+
simp
1071+
calc μ + (ν - ξ)
1072+
_ = μ.restrict s + μ.restrict sᶜ + (ν - ξ).restrict s + (ν - ξ).restrict sᶜ := by
1073+
rw [restrict_add_restrict_compl hs, add_assoc, restrict_add_restrict_compl hs]
1074+
_ = μ.restrict s + (ν - ξ).restrict s + (μ.restrict sᶜ + (ν - ξ).restrict sᶜ) := by abel
1075+
_ = (μ.restrict s + ν.restrict s - ξ.restrict s) +
1076+
(μ.restrict sᶜ + ν.restrict sᶜ - ξ.restrict sᶜ) := by rw [h_le_s, h_le_s_compl]
1077+
_ = (μ + ν - ξ).restrict s + (μ + ν - ξ).restrict sᶜ := by
1078+
simp [restrict_sub_eq_restrict_sub_restrict hs,
1079+
restrict_sub_eq_restrict_sub_restrict hs.compl]
1080+
_ = μ + ν - ξ := by rw [restrict_add_restrict_compl hs]
1081+
10611082
end Measure
10621083

10631084
end MeasureTheory

Mathlib/MeasureTheory/Measure/Sub.lean

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Specifically, note that if you have `α = {1,2}`, and `μ {1} = 2`, `μ {2} = 0`
3535
noncomputable instance instSub {α : Type*} [MeasurableSpace α] : Sub (Measure α) :=
3636
fun μ ν => sInf { τ | μ ≤ τ + ν }⟩
3737

38-
variable {α : Type*} {m : MeasurableSpace α} {μ ν : Measure α} {s : Set α}
38+
variable {α : Type*} {m : MeasurableSpace α} {μ ν ξ : Measure α} {s : Set α}
3939

4040
theorem sub_def : μ - ν = sInf { d | μ ≤ d + ν } := rfl
4141

@@ -145,6 +145,16 @@ theorem sub_apply_eq_zero_of_restrict_le_restrict (h_le : μ.restrict s ≤ ν.r
145145
instance isFiniteMeasure_sub [IsFiniteMeasure μ] : IsFiniteMeasure (μ - ν) :=
146146
isFiniteMeasure_of_le μ sub_le
147147

148+
/-- See `sub_le_iff_le_add` for the case where both measures are finite, which does not need the
149+
hypothesis `ν ≤ μ`. -/
150+
lemma sub_le_iff_le_add_of_le [IsFiniteMeasure ν] (h_le : ν ≤ μ) : μ - ν ≤ ξ ↔ μ ≤ ξ + ν := by
151+
refine ⟨fun h ↦ ?_, Measure.sub_le_of_le_add⟩
152+
rw [Measure.le_iff] at h ⊢
153+
intro s hs
154+
specialize h s hs
155+
simp only [Measure.coe_add, Pi.add_apply]
156+
rwa [Measure.sub_apply hs h_le, tsub_le_iff_right] at h
157+
148158
end Measure
149159

150160
end MeasureTheory
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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

Comments
 (0)