Skip to content

Commit eb17f0e

Browse files
committed
generalize oscillation
1 parent 8bfad47 commit eb17f0e

1 file changed

Lines changed: 175 additions & 37 deletions

File tree

Mathlib/Analysis/Oscillation.lean

Lines changed: 175 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
/-
22
Copyright (c) 2024 James Sundstrom. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: James Sundstrom
4+
Authors: James Sundstrom, Lua Viana Reis
55
-/
66
module
77

88
public import Mathlib.Data.ENNReal.Real
99
public import Mathlib.Order.WellFoundedSet
1010
public 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
2023
We also prove some simple facts about oscillation, most notably that the oscillation of `f`
2124
at `x` is 0 if and only if `f` is continuous at `x`, with versions for both `oscillation` and
@@ -28,35 +31,39 @@ oscillation, oscillationWithin
2831

2932
@[expose] public section
3033

31-
open Topology Metric Set ENNReal
34+
open Topology Metric Set ENNReal Filter
3235

3336
universe u v
3437

3538
variable {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+
3744
/-- 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
45+
noncomputable abbrev oscillationAt [TopologicalSpace E] (f : E → F) (x : E) : ENNReal :=
46+
oscillation f (𝓝 x)
4047

4148
/-- The oscillation of `f : E → F` within `D` at `x`. -/
42-
noncomputable def oscillationWithin [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :
49+
noncomputable def oscillationWithinAt [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :
4350
ENNReal :=
44-
⨅ S ∈ (𝓝[D] x).map f, ediam S
51+
oscillation f (𝓝[D] x)
4552

4653
/-- 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]
54+
theorem oscillationWithinAt_nhds_eq_oscillationAt [TopologicalSpace E] (f : E → F) (D : Set E)
55+
(x : E) (hD : D ∈ 𝓝 x) : oscillationWithinAt f D x = oscillationAt f x := by
56+
rw [oscillationAt, oscillationWithinAt, nhdsWithin_eq_nhds.2 hD]
5057

5158
/-- 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
59+
theorem oscillationWithinAt_univ_eq_oscillationAt [TopologicalSpace E] (f : E → F) (x : E) :
60+
oscillationWithinAt f univ x = oscillationAt f x :=
61+
oscillationWithinAt_nhds_eq_oscillationAt f univ x Filter.univ_mem
5562

5663
namespace ContinuousWithinAt
5764

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
65+
theorem oscillationWithinAt_eq_zero [TopologicalSpace E] {f : E → F} {D : Set E}
66+
{x : E} (hf : ContinuousWithinAt f D x) : oscillationWithinAt f D x = 0 := by
6067
rw [← nonpos_iff_eq_zero]
6168
refine _root_.le_of_forall_pos_le_add fun ε hε ↦ ?_
6269
rw [zero_add]
@@ -69,35 +76,36 @@ end ContinuousWithinAt
6976

7077
namespace ContinuousAt
7178

72-
theorem oscillation_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :
73-
oscillation f x = 0 := by
79+
theorem oscillationAt_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :
80+
oscillationAt f x = 0 := by
7481
rw [← continuousWithinAt_univ f x] at hf
75-
exact oscillationWithin_univ_eq_oscillation f x ▸ hf.oscillationWithin_eq_zero
82+
exact oscillationWithinAt_univ_eq_oscillationAt f x ▸ hf.oscillationWithinAt_eq_zero
7683

7784
end ContinuousAt
7885

79-
namespace OscillationWithin
86+
namespace OscillationWithinAt
8087

8188
/-- The oscillation within `D` of `f` at `x ∈ D` is 0 if and only if `ContinuousWithinAt f D x`. -/
8289
theorem 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
90+
{x : E} (xD : x ∈ D) : oscillationWithinAt f D x = 0 ↔ ContinuousWithinAt f D x := by
91+
refine ⟨fun hf ↦ EMetric.tendsto_nhds.mpr (fun ε ε0 ↦ ?_),
92+
fun hf ↦ hf.oscillationWithinAt_eq_zero⟩
93+
simp_rw [← hf, oscillationWithinAt, oscillation, iInf_lt_iff] at ε0
8694
obtain ⟨S, hS, Sε⟩ := ε0
8795
refine Filter.mem_of_superset hS (fun y hy ↦ lt_of_le_of_lt ?_ Sε)
8896
exact edist_le_ediam_of_mem (mem_preimage.1 hy) <| mem_preimage.1 (mem_of_mem_nhdsWithin xD hS)
8997

90-
end OscillationWithin
98+
end OscillationWithinAt
9199

92-
namespace Oscillation
100+
namespace OscillationAt
93101

94102
/-- The oscillation of `f` at `x` is 0 if and only if `f` is continuous at `x`. -/
95103
theorem 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)
104+
oscillationAt f x = 0 ↔ ContinuousAt f x := by
105+
rw [← oscillationWithinAt_univ_eq_oscillationAt, ← continuousWithinAt_univ f x]
106+
exact OscillationWithinAt.eq_zero_iff_continuousWithinAt f (mem_univ x)
99107

100-
end Oscillation
108+
end OscillationAt
101109

102110
namespace IsCompact
103111

@@ -106,7 +114,7 @@ variable {f : E → F} {D : Set E} {ε : ENNReal}
106114

107115
/-- If `oscillationWithin f D x < ε` at every `x` in a compact set `K`, then there exists `δ > 0`
108116
such 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 < ε) :
117+
theorem uniform_oscillationWithinAt (comp : IsCompact K) (hK : ∀ x ∈ K, oscillationWithinAt f D x < ε) :
110118
∃ δ > 0, ∀ x ∈ K, ediam (f '' (eball x (ENNReal.ofReal δ) ∩ D)) ≤ ε := by
111119
let S := fun r ↦
112120
{x : E | ∃ (a : ℝ), (a > r ∧ ediam (f '' (eball x (ENNReal.ofReal a) ∩ D)) ≤ ε)}
@@ -120,8 +128,8 @@ theorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscill
120128
rw [← ofReal_add (by linarith) (by linarith), sub_add_cancel]
121129
have S_cover : K ⊆ ⋃ r > 0, S r := by
122130
intro x hx
123-
have : oscillationWithin f D x < ε := hK x hx
124-
simp only [oscillationWithin, Filter.mem_map, iInf_lt_iff] at this
131+
have : oscillationWithinAt f D x < ε := hK x hx
132+
simp only [oscillationWithinAt, oscillation, Filter.mem_map, iInf_lt_iff] at this
125133
obtain ⟨n, hn₁, hn₂⟩ := this
126134
obtain ⟨r, r0, hr⟩ := EMetric.mem_nhdsWithin_iff.1 hn₁
127135
simp only [gt_iff_lt, mem_iUnion, exists_prop]
@@ -154,10 +162,140 @@ theorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscill
154162
/-- If `oscillation f x < ε` at every `x` in a compact set `K`, then there exists `δ > 0` such
155163
that the oscillation of `f` on `ball x δ` is less than `ε` for every `x` in `K`. -/
156164
theorem uniform_oscillation {K : Set E} (comp : IsCompact K)
157-
{f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillation f x < ε) :
165+
{f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillationAt f x < ε) :
158166
∃ δ > 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
167+
simp only [← oscillationWithinAt_univ_eq_oscillationAt] at hK
168+
convert! ← comp.uniform_oscillationWithinAt hK
161169
exact inter_univ _
162170

163171
end IsCompact
172+
173+
section MoveMe
174+
175+
variable {ι : Sort*} {κ : ι → Sort*} {α : Type*} {f : (i : ι) → κ i → α}
176+
177+
@[to_dual iInf₂_le_iff]
178+
theorem le_iSup₂_iff [CompleteSemilatticeSup α] {a : α} :
179+
a ≤ ⨆ (i) (j), f i j ↔ ∀ b, (∀ i j, f i j ≤ b) → a ≤ b := by
180+
simp [iSup, le_sSup_iff, upperBounds]
181+
182+
@[to_dual iInf₂_lt_iff]
183+
theorem lt_iSup₂_iff [CompleteLinearOrder α] {a : α} :
184+
a < ⨆ (i) (j), f i j ↔ ∃ i j, a < f i j := by
185+
have := lt_iSup_iff (f := fun (ij : PSigma κ) ↦ f ij.1 ij.2) (a := a)
186+
simp_rw [PSigma.exists, iSup_psigma] at this
187+
exact this
188+
189+
@[to_dual iInf₂_le_iff_forall_lt]
190+
theorem le_iSup₂_iff_forall_lt [CompleteLinearOrder α] {l : α} :
191+
l ≤ ⨆ (i) (j), f i j ↔ ∀ b < l, ∃ i j, b < f i j := by
192+
have := le_iSup_iff_forall_lt (f := fun (ij : PSigma κ) ↦ f ij.1 ij.2) (l := l)
193+
simp_rw [PSigma.exists, iSup_psigma] at this
194+
exact this
195+
196+
@[to_dual lt_iInf₂_iff]
197+
theorem iSup₂_lt_iff [CompleteLattice α] {l : α} :
198+
⨆ (i) (j), f i j < l ↔ ∃ b < l, ∀ i j, f i j ≤ b := by
199+
have := iSup_lt_iff (f := fun (ij : PSigma κ) ↦ f ij.1 ij.2) (l := l)
200+
simp_rw [PSigma.forall, iSup_psigma] at this
201+
exact this
202+
203+
lemma mul_biInf {p : ι → Prop} (hp : ∃ i, p i) {a : ℝ≥0∞} {f : ι → ℝ≥0∞}
204+
(hinfty : a = ∞ → ⨅ (i) (_ : p i), f i = 0 → ∃ i, ∃ (_ : p i), f i = 0) :
205+
a * ⨅ (i) (_ : p i), f i = ⨅ (i) (_ : p i), a * f i := by
206+
haveI : Nonempty {i // p i} := nonempty_subtype.mpr hp
207+
have := mul_iInf (ι := {i // p i}) (a := a) (f := (f ·))
208+
simp_rw [iInf_subtype, Subtype.exists] at this
209+
exact this hinfty
210+
211+
end MoveMe
212+
213+
section Cauchy
214+
215+
variable {f : E → F}
216+
217+
theorem EMetric.cauchy_iff_iInf_ediam_eq_zero (l : Filter F) [NeBot l] :
218+
Cauchy l ↔ ⨅ s ∈ l, ediam s = 0 := by
219+
rw [EMetric.cauchy_iff, ←nonpos_iff_eq_zero, iInf₂_le_iff_forall_lt]
220+
constructor
221+
· intro h ε hε
222+
rcases exists_between hε with ⟨η, hη⟩
223+
rcases h.right η hη.1 with ⟨s, hs₁, hs₂⟩
224+
use s, hs₁
225+
apply iSup₂_lt_iff.mpr
226+
use η, hη.2
227+
intro i hi
228+
apply iSup₂_le_iff.mpr
229+
intro j hj
230+
exact hs₂ i hi j hj |>.le
231+
· intro h
232+
use NeBot.ne'
233+
intro ε hε
234+
rcases h ε hε with ⟨s, hs₁, hs₂⟩
235+
use s, hs₁
236+
intro i hi j hj
237+
rcases iSup₂_lt_iff.mp hs₂ with ⟨l, hl, hs₃⟩
238+
specialize hs₃ i hi
239+
exact iSup₂_le_iff.mp hs₃ j hj |>.trans_lt hl
240+
241+
theorem cauchy_iff_oscillation_eq_zero (l : Filter E) [NeBot l] :
242+
Cauchy (l.map f) ↔ oscillation f l = 0 :=
243+
EMetric.cauchy_iff_iInf_ediam_eq_zero _
244+
245+
/-- A function `f` whose domain is a complete `EMetric` space converges to a point along a filter if
246+
and only if its oscillation along `l` is equal to zero. -/
247+
theorem EMetric.tendsTo_nhds_iff_oscillation_eq_zero [CompleteSpace F] (l : Filter E) [NeBot l] :
248+
(∃ x, Tendsto f l (𝓝 x)) ↔ oscillation f l = 0 := by
249+
rw [←cauchy_map_iff_exists_tendsto]
250+
exact cauchy_iff_oscillation_eq_zero _
251+
252+
end Cauchy
253+
254+
section Lipschitz
255+
256+
variable {α β γ : Type*} [PseudoEMetricSpace α] [PseudoEMetricSpace β] [PseudoEMetricSpace γ]
257+
258+
theorem LipschitzWith.oscillation_comp₂_le (g : α → β → γ) (f₁ : E → α) (f₂ : E → β)
259+
{K₁ K₂ : NNReal} (l : Filter E)
260+
(hf₁ : ∀ b, LipschitzWith K₁ (g · b)) (hf₂ : ∀ a, LipschitzWith K₂ (g a ·)) :
261+
oscillation (fun a ↦ g (f₁ a) (f₂ a)) l
262+
≤ ↑K₁ * oscillation f₁ l + ↑K₂ * oscillation f₂ l := by
263+
unfold oscillation
264+
simp_rw [mul_biInf ⟨_, Filter.univ_mem⟩ (coe_ne_top · |>.elim)]
265+
-- this would be more convenient with a `setm` tactic
266+
set a := ⨅ i ∈ map f₁ l, ↑K₁ * ediam i
267+
set b := ⨅ i ∈ map f₂ l, ↑K₂ * ediam i
268+
by_cases! ha : a = ∞; · simp [ha]
269+
by_cases! hb : b = ∞; · simp [hb]
270+
apply ENNReal.le_of_forall_pos_le_add
271+
intro ε hε hfin
272+
rcases iInf₂_le_iff_forall_lt (l := a) |>.mp le_rfl (a + ε / 2)
273+
(lt_add_right ha (by norm_num [hε.ne'])) with ⟨sa, hsa, hsa'⟩
274+
rcases iInf₂_le_iff_forall_lt (l := b) |>.mp le_rfl (b + ε / 2)
275+
(lt_add_right hb (by norm_num [hε.ne'])) with ⟨sb, hsb, hsb'⟩
276+
rw [show a + b + ε = a + ε / 2 + (b + ε / 2) by
277+
ring_nf
278+
rw [ENNReal.div_mul_cancel (by positivity) (by finiteness)]]
279+
apply ENNReal.add_lt_add hsa' hsb' |>.trans_le' _ |>.le
280+
apply iInf₂_le_of_le (image2 g sa sb) _ _
281+
· rw [mem_map] at ⊢ hsa hsb
282+
exact l.mem_of_superset (l.inter_mem hsa hsb) fun a ⟨h₁, h₂⟩ ↦ ⟨f₁ a, h₁, f₂ a, h₂, rfl⟩
283+
· exact LipschitzOnWith.ediam_image2_le _ _ _
284+
(fun s _ ↦ hf₁ s |>.lipschitzOnWith)
285+
(fun s _ ↦ hf₂ s |>.lipschitzOnWith)
286+
287+
end Lipschitz
288+
289+
section SeminormedAddCommGroup
290+
291+
variable {F : Type*} [SeminormedCommGroup F]
292+
293+
@[to_additive]
294+
theorem oscillation_mul_le (f₁ : E → F) (f₂ : E → F) (l : Filter E) :
295+
oscillation (f₁ * f₂) l ≤ oscillation f₁ l + oscillation f₂ l :=
296+
LipschitzWith.oscillation_comp₂_le (· * ·) f₁ f₂ l
297+
(fun _ => (isometry_mul_right _).lipschitz)
298+
(fun _ => (isometry_mul_left _).lipschitz)
299+
|>.trans_eq (by simp only [coe_one, one_mul])
300+
301+
end SeminormedAddCommGroup

0 commit comments

Comments
 (0)