11/-
22Copyright (c) 2024 James Sundstrom. All rights reserved.
33Released under Apache 2.0 license as described in the file LICENSE.
4- Authors: James Sundstrom
4+ Authors: James Sundstrom, Lua Viana Reis
55-/
66module
77
88public import Mathlib.Data.ENNReal.Real
99public import Mathlib.Order.WellFoundedSet
1010public import Mathlib.Topology.EMetricSpace.Diam
11+ public import Mathlib.Topology.EMetricSpace.Lipschitz
12+ public import Mathlib.Topology.UniformSpace.Cauchy
13+ public import Mathlib.Analysis.Normed.Group.Uniform
1114
1215/-!
1316# Oscillation
1417
15- In this file we define the oscillation of a function `f: E → F` at a point `x ` of `E`. (`E ` is
16- required to be a TopologicalSpace and `F` a PseudoEMetricSpace.) The oscillation of `f` at `x ` is
17- defined to be the infimum of `diam f '' N` for all neighborhoods `N` of `x `. We also define
18- `oscillationWithin f D x `, which is the oscillation at `x ` of `f` restricted to `D`.
18+ In this file we define the oscillation of a function `f: E → F` along a filter `l ` of `E`. (`F ` is
19+ required to be a PseudoEMetricSpace.) The oscillation of `f` at `l ` is
20+ defined to be the infimum of `diam f '' N` for all sets `N` in `l `. We also define
21+ `oscillationWithin f D l `, which is the oscillation at `l ` of `f` restricted to `D`.
1922
2023We also prove some simple facts about oscillation, most notably that the oscillation of `f`
2124at `x` is 0 if and only if `f` is continuous at `x`, with versions for both `oscillation` and
@@ -28,35 +31,42 @@ oscillation, oscillationWithin
2831
2932@[expose] public section
3033
31- open Topology Metric Set ENNReal
34+ open Topology Metric Set ENNReal Filter
3235
3336universe u v
3437
3538variable {E : Type u} {F : Type v} [PseudoEMetricSpace F]
3639
40+ /-- The oscillation of `f : E → F` along `l`. -/
41+ noncomputable def oscillation (f : E → F) (l : Filter E) : ENNReal :=
42+ ⨅ S ∈ l.map f, ediam S
43+
44+ theorem oscillation_le_ediam_range {f : E → F} {l} : oscillation f l ≤ ediam (range f) :=
45+ iInf_le_of_le (range f) (by simp)
46+
3747/-- The oscillation of `f : E → F` at `x`. -/
38- noncomputable def oscillation [TopologicalSpace E] (f : E → F) (x : E) : ENNReal :=
39- ⨅ S ∈ (𝓝 x).map f, ediam S
48+ noncomputable abbrev oscillationAt [TopologicalSpace E] (f : E → F) (x : E) : ENNReal :=
49+ oscillation f (𝓝 x)
4050
4151/-- The oscillation of `f : E → F` within `D` at `x`. -/
42- noncomputable def oscillationWithin [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :
52+ noncomputable abbrev oscillationWithinAt [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :
4353 ENNReal :=
44- ⨅ S ∈ (𝓝[D] x).map f, ediam S
54+ oscillation f (𝓝[D] x)
4555
4656/-- The oscillation of `f` at `x` within a neighborhood `D` of `x` is equal to `oscillation f x` -/
47- theorem oscillationWithin_nhds_eq_oscillation [TopologicalSpace E] (f : E → F) (D : Set E) (x : E)
48- (hD : D ∈ 𝓝 x) : oscillationWithin f D x = oscillation f x := by
49- rw [oscillation, oscillationWithin , nhdsWithin_eq_nhds.2 hD]
57+ theorem oscillationWithinAt_nhds_eq_oscillationAt [TopologicalSpace E] (f : E → F) (D : Set E)
58+ (x : E) ( hD : D ∈ 𝓝 x) : oscillationWithinAt f D x = oscillationAt f x := by
59+ rw [oscillationAt, oscillationWithinAt , nhdsWithin_eq_nhds.2 hD]
5060
5161/-- The oscillation of `f` at `x` within `univ` is equal to `oscillation f x` -/
52- theorem oscillationWithin_univ_eq_oscillation [TopologicalSpace E] (f : E → F) (x : E) :
53- oscillationWithin f univ x = oscillation f x :=
54- oscillationWithin_nhds_eq_oscillation f univ x Filter.univ_mem
62+ theorem oscillationWithinAt_univ_eq_oscillationAt [TopologicalSpace E] (f : E → F) (x : E) :
63+ oscillationWithinAt f univ x = oscillationAt f x :=
64+ oscillationWithinAt_nhds_eq_oscillationAt f univ x Filter.univ_mem
5565
5666namespace ContinuousWithinAt
5767
58- theorem oscillationWithin_eq_zero [TopologicalSpace E] {f : E → F} {D : Set E}
59- {x : E} (hf : ContinuousWithinAt f D x) : oscillationWithin f D x = 0 := by
68+ theorem oscillationWithinAt_eq_zero [TopologicalSpace E] {f : E → F} {D : Set E}
69+ {x : E} (hf : ContinuousWithinAt f D x) : oscillationWithinAt f D x = 0 := by
6070 rw [← nonpos_iff_eq_zero]
6171 refine _root_.le_of_forall_pos_le_add fun ε hε ↦ ?_
6272 rw [zero_add]
@@ -69,35 +79,36 @@ end ContinuousWithinAt
6979
7080namespace ContinuousAt
7181
72- theorem oscillation_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :
73- oscillation f x = 0 := by
82+ theorem oscillationAt_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :
83+ oscillationAt f x = 0 := by
7484 rw [← continuousWithinAt_univ f x] at hf
75- exact oscillationWithin_univ_eq_oscillation f x ▸ hf.oscillationWithin_eq_zero
85+ exact oscillationWithinAt_univ_eq_oscillationAt f x ▸ hf.oscillationWithinAt_eq_zero
7686
7787end ContinuousAt
7888
79- namespace OscillationWithin
89+ namespace OscillationWithinAt
8090
8191/-- The oscillation within `D` of `f` at `x ∈ D` is 0 if and only if `ContinuousWithinAt f D x`. -/
8292theorem eq_zero_iff_continuousWithinAt [TopologicalSpace E] (f : E → F) {D : Set E}
83- {x : E} (xD : x ∈ D) : oscillationWithin f D x = 0 ↔ ContinuousWithinAt f D x := by
84- refine ⟨fun hf ↦ EMetric.tendsto_nhds.mpr (fun ε ε0 ↦ ?_), fun hf ↦ hf.oscillationWithin_eq_zero⟩
85- simp_rw [← hf, oscillationWithin, iInf_lt_iff] at ε0
93+ {x : E} (xD : x ∈ D) : oscillationWithinAt f D x = 0 ↔ ContinuousWithinAt f D x := by
94+ refine ⟨fun hf ↦ EMetric.tendsto_nhds.mpr (fun ε ε0 ↦ ?_),
95+ fun hf ↦ hf.oscillationWithinAt_eq_zero⟩
96+ simp_rw [← hf, oscillationWithinAt, oscillation, iInf_lt_iff] at ε0
8697 obtain ⟨S, hS, Sε⟩ := ε0
8798 refine Filter.mem_of_superset hS (fun y hy ↦ lt_of_le_of_lt ?_ Sε)
8899 exact edist_le_ediam_of_mem (mem_preimage.1 hy) <| mem_preimage.1 (mem_of_mem_nhdsWithin xD hS)
89100
90- end OscillationWithin
101+ end OscillationWithinAt
91102
92- namespace Oscillation
103+ namespace OscillationAt
93104
94105/-- The oscillation of `f` at `x` is 0 if and only if `f` is continuous at `x`. -/
95106theorem eq_zero_iff_continuousAt [TopologicalSpace E] (f : E → F) (x : E) :
96- oscillation f x = 0 ↔ ContinuousAt f x := by
97- rw [← oscillationWithin_univ_eq_oscillation , ← continuousWithinAt_univ f x]
98- exact OscillationWithin .eq_zero_iff_continuousWithinAt f (mem_univ x)
107+ oscillationAt f x = 0 ↔ ContinuousAt f x := by
108+ rw [← oscillationWithinAt_univ_eq_oscillationAt , ← continuousWithinAt_univ f x]
109+ exact OscillationWithinAt .eq_zero_iff_continuousWithinAt f (mem_univ x)
99110
100- end Oscillation
111+ end OscillationAt
101112
102113namespace IsCompact
103114
@@ -106,7 +117,8 @@ variable {f : E → F} {D : Set E} {ε : ENNReal}
106117
107118/-- If `oscillationWithin f D x < ε` at every `x` in a compact set `K`, then there exists `δ > 0`
108119such that the oscillation of `f` on `ball x δ ∩ D` is less than `ε` for every `x` in `K`. -/
109- theorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscillationWithin f D x < ε) :
120+ theorem uniform_oscillationWithinAt (comp : IsCompact K)
121+ (hK : ∀ x ∈ K, oscillationWithinAt f D x < ε) :
110122 ∃ δ > 0 , ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ) ∩ D)) ≤ ε := by
111123 let S := fun r ↦
112124 {x : E | ∃ (a : ℝ), (a > r ∧ ediam (f '' (eball x (ENNReal.ofReal a) ∩ D)) ≤ ε)}
@@ -120,8 +132,8 @@ theorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscill
120132 rw [← ofReal_add (by linarith) (by linarith), sub_add_cancel]
121133 have S_cover : K ⊆ ⋃ r > 0 , S r := by
122134 intro x hx
123- have : oscillationWithin f D x < ε := hK x hx
124- simp only [oscillationWithin , Filter.mem_map, iInf_lt_iff] at this
135+ have : oscillationWithinAt f D x < ε := hK x hx
136+ simp only [oscillationWithinAt, oscillation , Filter.mem_map, iInf_lt_iff] at this
125137 obtain ⟨n, hn₁, hn₂⟩ := this
126138 obtain ⟨r, r0, hr⟩ := EMetric.mem_nhdsWithin_iff.1 hn₁
127139 simp only [gt_iff_lt, mem_iUnion, exists_prop]
@@ -154,10 +166,164 @@ theorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscill
154166/-- If `oscillation f x < ε` at every `x` in a compact set `K`, then there exists `δ > 0` such
155167that the oscillation of `f` on `ball x δ` is less than `ε` for every `x` in `K`. -/
156168theorem uniform_oscillation {K : Set E} (comp : IsCompact K)
157- {f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillation f x < ε) :
169+ {f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillationAt f x < ε) :
158170 ∃ δ > 0 , ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ))) ≤ ε := by
159- simp only [← oscillationWithin_univ_eq_oscillation ] at hK
160- convert! ← comp.uniform_oscillationWithin hK
171+ simp only [← oscillationWithinAt_univ_eq_oscillationAt ] at hK
172+ convert! ← comp.uniform_oscillationWithinAt hK
161173 exact inter_univ _
162174
163175end IsCompact
176+
177+ section MoveMe
178+
179+ variable {ι : Sort *} {κ : ι → Sort *} {α : Type *} {f : (i : ι) → κ i → α}
180+
181+ @ [to_dual iInf₂_le_iff]
182+ theorem le_iSup₂_iff [CompleteSemilatticeSup α] {a : α} :
183+ a ≤ ⨆ (i) (j), f i j ↔ ∀ b, (∀ i j, f i j ≤ b) → a ≤ b := by
184+ simp [iSup, le_sSup_iff, upperBounds]
185+
186+ @ [to_dual iInf₂_lt_iff]
187+ theorem lt_iSup₂_iff [CompleteLinearOrder α] {a : α} :
188+ a < ⨆ (i) (j), f i j ↔ ∃ i j, a < f i j := by
189+ have := lt_iSup_iff (f := fun (ij : PSigma κ) ↦ f ij.1 ij.2 ) (a := a)
190+ simp_rw [PSigma.exists, iSup_psigma] at this
191+ exact this
192+
193+ @ [to_dual iInf₂_le_iff_forall_lt]
194+ theorem le_iSup₂_iff_forall_lt [CompleteLinearOrder α] {l : α} :
195+ l ≤ ⨆ (i) (j), f i j ↔ ∀ b < l, ∃ i j, b < f i j := by
196+ have := le_iSup_iff_forall_lt (f := fun (ij : PSigma κ) ↦ f ij.1 ij.2 ) (l := l)
197+ simp_rw [PSigma.exists, iSup_psigma] at this
198+ exact this
199+
200+ @ [to_dual lt_iInf₂_iff]
201+ theorem iSup₂_lt_iff [CompleteLattice α] {l : α} :
202+ ⨆ (i) (j), f i j < l ↔ ∃ b < l, ∀ i j, f i j ≤ b := by
203+ have := iSup_lt_iff (f := fun (ij : PSigma κ) ↦ f ij.1 ij.2 ) (l := l)
204+ simp_rw [PSigma.forall, iSup_psigma] at this
205+ exact this
206+
207+ lemma mul_biInf {p : ι → Prop } (hp : ∃ i, p i) {a : ℝ≥0 ∞} {f : ι → ℝ≥0 ∞}
208+ (hinfty : a = ∞ → ⨅ (i) (_ : p i), f i = 0 → ∃ i, ∃ (_ : p i), f i = 0 ) :
209+ a * ⨅ (i) (_ : p i), f i = ⨅ (i) (_ : p i), a * f i := by
210+ haveI : Nonempty {i // p i} := nonempty_subtype.mpr hp
211+ have := mul_iInf (ι := {i // p i}) (a := a) (f := (f ·))
212+ simp_rw [iInf_subtype, Subtype.exists] at this
213+ exact this hinfty
214+
215+ @ [to_dual iInf₂_eq_of_forall_ge_of_forall_gt_exists_lt]
216+ theorem iSup₂_eq_of_forall_le_of_forall_lt_exists_gt [CompleteLattice α] {b : α}
217+ (h₁ : ∀ i j, f i j ≤ b) (h₂ : ∀ w, w < b → ∃ i j, w < f i j) : ⨆ (i) (j), f i j = b := by
218+ have := iSup_eq_of_forall_le_of_forall_lt_exists_gt
219+ (f := fun (ij : PSigma κ) ↦ f ij.1 ij.2 ) (b := b)
220+ simp_rw [PSigma.forall, PSigma.exists, iSup_psigma] at this
221+ exact this h₁ h₂
222+
223+ end MoveMe
224+
225+ section Cauchy
226+
227+ variable {f : E → F}
228+
229+ theorem EMetric.cauchy_iff_iInf_ediam_eq_zero (l : Filter F) [NeBot l] :
230+ Cauchy l ↔ ⨅ s ∈ l, ediam s = 0 := by
231+ rw [EMetric.cauchy_iff, ←nonpos_iff_eq_zero, iInf₂_le_iff_forall_lt]
232+ constructor
233+ · intro h ε hε
234+ rcases exists_between hε with ⟨η, hη⟩
235+ rcases h.right η hη.1 with ⟨s, hs₁, hs₂⟩
236+ use s, hs₁
237+ apply iSup₂_lt_iff.mpr
238+ use η, hη.2
239+ intro i hi
240+ apply iSup₂_le_iff.mpr
241+ intro j hj
242+ exact hs₂ i hi j hj |>.le
243+ · intro h
244+ use NeBot.ne'
245+ intro ε hε
246+ rcases h ε hε with ⟨s, hs₁, hs₂⟩
247+ use s, hs₁
248+ intro i hi j hj
249+ rcases iSup₂_lt_iff.mp hs₂ with ⟨l, hl, hs₃⟩
250+ specialize hs₃ i hi
251+ exact iSup₂_le_iff.mp hs₃ j hj |>.trans_lt hl
252+
253+ theorem cauchy_iff_oscillation_eq_zero (l : Filter E) [NeBot l] :
254+ Cauchy (l.map f) ↔ oscillation f l = 0 :=
255+ EMetric.cauchy_iff_iInf_ediam_eq_zero _
256+
257+ /-- A function `f` whose domain is a complete `EMetric` space converges to a point along a filter if
258+ and only if its oscillation along `l` is equal to zero. -/
259+ theorem EMetric.tendsTo_nhds_iff_oscillation_eq_zero [CompleteSpace F] (l : Filter E) [NeBot l] :
260+ (∃ x, Tendsto f l (𝓝 x)) ↔ oscillation f l = 0 := by
261+ rw [←cauchy_map_iff_exists_tendsto]
262+ exact cauchy_iff_oscillation_eq_zero _
263+
264+ end Cauchy
265+
266+ section Lipschitz
267+
268+ variable {α β γ : Type *} [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]
269+
270+ theorem LipschitzWith.oscillation_comp₂_le (g : α → β → γ) (f₁ : E → α) (f₂ : E → β)
271+ {K₁ K₂ : NNReal} (l : Filter E)
272+ (hf₁ : ∀ b, LipschitzWith K₁ (g · b)) (hf₂ : ∀ a, LipschitzWith K₂ (g a ·)) :
273+ oscillation (fun a ↦ g (f₁ a) (f₂ a)) l
274+ ≤ ↑K₁ * oscillation f₁ l + ↑K₂ * oscillation f₂ l := by
275+ unfold oscillation
276+ simp_rw [mul_biInf ⟨_, Filter.univ_mem⟩ (coe_ne_top · |>.elim)]
277+ -- this would be more convenient with a `setm` tactic
278+ set a := ⨅ i ∈ map f₁ l, ↑K₁ * ediam i
279+ set b := ⨅ i ∈ map f₂ l, ↑K₂ * ediam i
280+ by_cases! ha : a = ∞; · simp [ha]
281+ by_cases! hb : b = ∞; · simp [hb]
282+ apply _root_.le_of_forall_pos_le_add
283+ intro ε hε
284+ rcases iInf₂_le_iff_forall_lt (l := a) |>.mp le_rfl (a + ε / 2 )
285+ (lt_add_right ha (by norm_num [hε.ne'])) with ⟨sa, hsa, hsa'⟩
286+ rcases iInf₂_le_iff_forall_lt (l := b) |>.mp le_rfl (b + ε / 2 )
287+ (lt_add_right hb (by norm_num [hε.ne'])) with ⟨sb, hsb, hsb'⟩
288+ rw [show a + b + ε = a + ε / 2 + (b + ε / 2 ) by
289+ ring_nf
290+ rw [ENNReal.div_mul_cancel (by positivity) (by finiteness)]]
291+ apply ENNReal.add_lt_add hsa' hsb' |>.trans_le' _ |>.le
292+ apply iInf₂_le_of_le (image2 g sa sb) _ _
293+ · rw [mem_map] at ⊢ hsa hsb
294+ exact l.mem_of_superset (l.inter_mem hsa hsb) fun a ⟨h₁, h₂⟩ ↦ ⟨f₁ a, h₁, f₂ a, h₂, rfl⟩
295+ · exact LipschitzOnWith.ediam_image2_le _ _ _
296+ (fun s _ ↦ hf₁ s |>.lipschitzOnWith)
297+ (fun s _ ↦ hf₂ s |>.lipschitzOnWith)
298+
299+ end Lipschitz
300+
301+ section SeminormedAddCommGroup
302+
303+ variable {F : Type *} [SeminormedCommGroup F]
304+
305+ @[to_additive]
306+ theorem oscillation_mul_le (f₁ : E → F) (f₂ : E → F) (l : Filter E) :
307+ oscillation (f₁ * f₂) l ≤ oscillation f₁ l + oscillation f₂ l :=
308+ LipschitzWith.oscillation_comp₂_le (· * ·) f₁ f₂ l
309+ (fun _ => (isometry_mul_right _).lipschitz)
310+ (fun _ => (isometry_mul_left _).lipschitz)
311+ |>.trans_eq (by simp only [coe_one, one_mul])
312+
313+ @[to_additive]
314+ theorem oscillation_le_add_div (f₁ : E → F) (f₂ : E → F) (l : Filter E) :
315+ oscillation f₁ l ≤ oscillation f₂ l + oscillation (f₁ / f₂) l := by
316+ nth_rw 1 [show f₁ = f₂ * (f₁ / f₂) by simp]
317+ exact oscillation_mul_le ..
318+
319+ @ [to_additive oscillation_le_two_mul_iSup_enorm]
320+ theorem oscillation_le_two_mul_iSup_enorm' (f : E → F) (l : Filter E) :
321+ oscillation f l ≤ 2 * iSup (‖f ·‖ₑ) := by
322+ apply oscillation_le_ediam_range.trans
323+ refine ediam_le fun x hx y hy => ?_
324+ rw [edist_eq_enorm_div x y, two_mul]
325+ apply enorm_div_le.trans <| add_le_add _ _
326+ · exact hx.out.elim fun z hz ↦ hz ▸ le_iSup (‖f ·‖ₑ) ..
327+ · exact hy.out.elim fun z hz ↦ hz ▸ le_iSup (‖f ·‖ₑ) ..
328+
329+ end SeminormedAddCommGroup
0 commit comments