Skip to content

Commit e978dd5

Browse files
committed
feat: thickenedIndicator is Lipschitz (leanprover-community#30346)
Co-authored-by: Remy Degenne <remydegenne@gmail.com>
1 parent 108075f commit e978dd5

2 files changed

Lines changed: 62 additions & 3 deletions

File tree

Mathlib/Data/ENNReal/Operations.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ theorem ofReal_sub (p : ℝ) {q : ℝ} (hq : 0 ≤ q) :
449449
refine ENNReal.eq_sub_of_add_eq ofReal_ne_top ?_
450450
rw [← ofReal_add (sub_nonneg_of_le h) hq, sub_add_cancel]
451451

452+
lemma sub_sub_sub_cancel_left (ha : a ≠ ∞) (h : b ≤ a) : a - c - (a - b) = b - c := by
453+
have hb : b ≠ ∞ := ne_top_of_le_ne_top ha h
454+
lift a to ℝ≥0 using ha
455+
lift b to ℝ≥0 using hb
456+
cases c
457+
· simp
458+
· norm_cast
459+
rw [tsub_tsub_tsub_cancel_left]
460+
exact mod_cast h
461+
452462
end Sub
453463

454464
section Interval

Mathlib/Topology/MetricSpace/ThickenedIndicator.lean

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ theorem thickenedIndicatorAux_le_one (δ : ℝ) (E : Set α) (x : α) :
6262
thickenedIndicatorAux δ E x ≤ 1 := by
6363
apply tsub_le_self (α := ℝ≥0∞)
6464

65+
@[aesop safe (rule_sets := [finiteness])]
6566
theorem thickenedIndicatorAux_lt_top {δ : ℝ} {E : Set α} {x : α} :
6667
thickenedIndicatorAux δ E x < ∞ :=
6768
lt_of_le_of_lt (thickenedIndicatorAux_le_one _ _ _) one_lt_top
@@ -103,6 +104,16 @@ theorem thickenedIndicatorAux_subset (δ : ℝ) {E₁ E₂ : Set α} (subset : E
103104
thickenedIndicatorAux δ E₁ ≤ thickenedIndicatorAux δ E₂ :=
104105
fun _ => tsub_le_tsub (@rfl ℝ≥01).le (ENNReal.div_le_div (infEdist_anti subset) rfl.le)
105106

107+
lemma thickenedIndicatorAux_mono_infEdist (δ : ℝ) {E : Set α} {x y : α}
108+
(h : infEdist x E ≤ infEdist y E) :
109+
thickenedIndicatorAux δ E y ≤ thickenedIndicatorAux δ E x := by
110+
simp only [thickenedIndicatorAux]
111+
rcases le_total (infEdist x E / ENNReal.ofReal δ) 1 with hle | hle
112+
· rw [ENNReal.sub_le_sub_iff_left hle (by simp)]
113+
gcongr
114+
· rw [tsub_eq_zero_of_le hle, tsub_eq_zero_of_le]
115+
exact hle.trans (by gcongr)
116+
106117
/-- As the thickening radius δ tends to 0, the δ-thickened indicator of a set E (in α) tends
107118
pointwise (i.e., w.r.t. the product topology on `α → ℝ≥0∞`) to the indicator function of the
108119
closure of E.
@@ -167,7 +178,7 @@ theorem thickenedIndicator.coeFn_eq_comp {δ : ℝ} (δ_pos : 0 < δ) (E : Set
167178
theorem thickenedIndicator_le_one {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) (x : α) :
168179
thickenedIndicator δ_pos E x ≤ 1 := by
169180
rw [thickenedIndicator.coeFn_eq_comp]
170-
simpa using (toNNReal_le_toNNReal thickenedIndicatorAux_lt_top.ne one_ne_top).mpr
181+
simpa using (toNNReal_le_toNNReal (by finiteness) one_ne_top).mpr
171182
(thickenedIndicatorAux_le_one δ E x)
172183

173184
theorem thickenedIndicator_one_of_mem_closure {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) {x : α}
@@ -202,14 +213,23 @@ theorem indicator_le_thickenedIndicator {δ : ℝ} (δ_pos : 0 < δ) (E : Set α
202213
theorem thickenedIndicator_mono {δ₁ δ₂ : ℝ} (δ₁_pos : 0 < δ₁) (δ₂_pos : 0 < δ₂) (hle : δ₁ ≤ δ₂)
203214
(E : Set α) : ⇑(thickenedIndicator δ₁_pos E) ≤ thickenedIndicator δ₂_pos E := by
204215
intro x
205-
apply (toNNReal_le_toNNReal thickenedIndicatorAux_lt_top.ne thickenedIndicatorAux_lt_top.ne).mpr
216+
apply (toNNReal_le_toNNReal (by finiteness) (by finiteness)).mpr
206217
apply thickenedIndicatorAux_mono hle
207218

208219
theorem thickenedIndicator_subset {δ : ℝ} (δ_pos : 0 < δ) {E₁ E₂ : Set α} (subset : E₁ ⊆ E₂) :
209220
⇑(thickenedIndicator δ_pos E₁) ≤ thickenedIndicator δ_pos E₂ := fun x =>
210-
(toNNReal_le_toNNReal thickenedIndicatorAux_lt_top.ne thickenedIndicatorAux_lt_top.ne).mpr
221+
(toNNReal_le_toNNReal (by finiteness) (by finiteness)).mpr
211222
(thickenedIndicatorAux_subset δ subset x)
212223

224+
@[gcongr]
225+
lemma thickenedIndicator_mono_infEdist {δ : ℝ} (δ_pos : 0 < δ) {E : Set α} {x y : α}
226+
(h : infEdist x E ≤ infEdist y E) :
227+
thickenedIndicator δ_pos E y ≤ thickenedIndicator δ_pos E x := by
228+
simp only [thickenedIndicator_apply]
229+
gcongr
230+
· finiteness
231+
· exact thickenedIndicatorAux_mono_infEdist δ h
232+
213233
/-- As the thickening radius δ tends to 0, the δ-thickened indicator of a set E (in α) tends
214234
pointwise to the indicator function of the closure of E.
215235
@@ -229,6 +249,35 @@ theorem thickenedIndicator_tendsto_indicator_closure {δseq : ℕ → ℝ} (δse
229249
refine Tendsto.comp (tendsto_toNNReal ?_) (key x)
230250
by_cases x_mem : x ∈ closure E <;> simp [x_mem]
231251

252+
lemma lipschitzWith_thickenedIndicator {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) :
253+
LipschitzWith δ.toNNReal⁻¹ (thickenedIndicator δ_pos E) := by
254+
intro x y
255+
wlog h : infEdist x E ≤ infEdist y E generalizing x y
256+
· specialize this y x (le_of_not_ge h)
257+
rwa [edist_comm, edist_comm x]
258+
simp_rw [edist_dist, NNReal.dist_eq, thickenedIndicator_apply, coe_toNNReal_eq_toReal]
259+
rw [← ENNReal.toReal_sub_of_le (thickenedIndicatorAux_mono_infEdist _ h) (by finiteness)]
260+
simp only [thickenedIndicatorAux, abs_toReal, ne_eq, sub_eq_top_iff, one_ne_top, false_and,
261+
not_false_eq_true, and_true, ofReal_toReal]
262+
rw [ENNReal.coe_inv (by simp [δ_pos]), ENNReal.ofReal, div_eq_mul_inv, div_eq_mul_inv]
263+
by_cases h_le : infEdist y E * (↑δ.toNNReal)⁻¹ ≤ 1
264+
· calc 1 - infEdist x E * (↑δ.toNNReal)⁻¹ - (1 - infEdist y E * (↑δ.toNNReal)⁻¹)
265+
_ ≤ infEdist y E * (↑δ.toNNReal)⁻¹ - infEdist x E * (↑δ.toNNReal)⁻¹ := by
266+
rw [ENNReal.sub_sub_sub_cancel_left (by finiteness) h_le]
267+
_ ≤ (↑δ.toNNReal)⁻¹ * edist x y := by
268+
rw [← ENNReal.sub_mul (by simp [δ_pos]), mul_comm, edist_comm]
269+
gcongr
270+
simp only [tsub_le_iff_right]
271+
exact infEdist_le_edist_add_infEdist
272+
· simp only [tsub_le_iff_right]
273+
rw [tsub_eq_zero_of_le (not_le.mp h_le).le, add_zero, mul_comm]
274+
calc 1
275+
_ ≤ infEdist y E * (↑δ.toNNReal)⁻¹ := (not_le.mp h_le).le
276+
_ ≤ edist x y * (↑δ.toNNReal)⁻¹ + infEdist x E * (↑δ.toNNReal)⁻¹ := by
277+
rw [← add_mul, edist_comm]
278+
gcongr
279+
exact infEdist_le_edist_add_infEdist
280+
232281
end thickenedIndicator
233282

234283
section indicator

0 commit comments

Comments
 (0)