Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 3d457a2

Browse files
committed
chore(topology/continuous_function): review API (#9950)
* add `simps` config for `α →ᵇ β`; * use better variable names in `topology.continuous_function.compact`; * weaken some TC assumptions in `topology.continuous_function.compact`; * migrate more API from `α →ᵇ β` to `C(α, β)`.
1 parent f23354d commit 3d457a2

File tree

3 files changed

+120
-121
lines changed

3 files changed

+120
-121
lines changed

src/topology/continuous_function/bounded.lean

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ variables {f g : α →ᵇ β} {x : α} {C : ℝ}
3737

3838
instance : has_coe_to_fun (α →ᵇ β) (λ _, α → β) := ⟨λ f, f.to_fun⟩
3939

40+
/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,
41+
because it is a composition of multiple projections. -/
42+
def simps.apply (h : α →ᵇ β) : α → β := h
43+
44+
initialize_simps_projections bounded_continuous_function (to_continuous_map_to_fun → apply)
45+
4046
protected lemma bounded (f : α →ᵇ β) : ∃C, ∀ x y : α, dist (f x) (f y) ≤ C := f.bounded'
4147
@[continuity]
4248
protected lemma continuous (f : α →ᵇ β) : continuous f := f.to_continuous_map.continuous
@@ -67,15 +73,10 @@ rfl
6773

6874
/-- If a function is bounded on a discrete space, it is automatically continuous,
6975
and therefore gives rise to an element of the type of bounded continuous functions -/
70-
def mk_of_discrete [discrete_topology α] (f : α → β)
76+
@[simps] def mk_of_discrete [discrete_topology α] (f : α → β)
7177
(C : ℝ) (h : ∀ x y : α, dist (f x) (f y) ≤ C) : α →ᵇ β :=
7278
⟨⟨f, continuous_of_discrete_topology⟩, ⟨C, h⟩⟩
7379

74-
@[simp] lemma mk_of_discrete_apply
75-
[discrete_topology α] (f : α → β) (C) (h) (a : α) :
76-
mk_of_discrete f C h a = f a :=
77-
rfl
78-
7980
section
8081
variables (α β)
8182
/--
@@ -174,12 +175,12 @@ instance : metric_space (α →ᵇ β) :=
174175
variables (α) {β}
175176

176177
/-- Constant as a continuous bounded function. -/
177-
def const (b : β) : α →ᵇ β := ⟨continuous_map.const b, 0, by simp [le_refl]⟩
178+
@[simps {fully_applied := ff}] def const (b : β) : α →ᵇ β :=
179+
⟨continuous_map.const b, 0, by simp [le_refl]⟩
178180

179181
variable {α}
180182

181-
@[simp] lemma coe_const (b : β) : ⇑(const α b) = function.const α b := rfl
182-
lemma const_apply (a : α) (b : β) : (const α b : α → β) a = b := rfl
183+
lemma const_apply' (a : α) (b : β) : (const α b : α → β) a = b := rfl
183184

184185
/-- If the target space is inhabited, so is the space of bounded continuous functions -/
185186
instance [inhabited β] : inhabited (α →ᵇ β) := ⟨const α (default β)⟩

src/topology/continuous_function/compact.lean

Lines changed: 108 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -31,215 +31,213 @@ open bounded_continuous_function
3131

3232
namespace continuous_map
3333

34-
variables (α β μ : Type*) [topological_space α] [compact_space α] [normed_group β] [metric_space μ]
34+
variables {α β E : Type*} [topological_space α] [compact_space α] [metric_space β] [normed_group E]
35+
36+
section
37+
38+
variables (α β)
3539

3640
/--
37-
When `α` is compact, the bounded continuous maps `α →ᵇ 𝕜` are
38-
equivalent to `C(α, 𝕜)`.
41+
When `α` is compact, the bounded continuous maps `α →ᵇ β` are
42+
equivalent to `C(α, β)`.
3943
-/
40-
@[simps]
41-
def equiv_bounded_of_compact : C(α, μ) ≃ (α →ᵇ μ) :=
42-
⟨mk_of_compact, forget_boundedness α μ, λ f, by { ext, refl, }, λ f, by { ext, refl, }⟩
44+
@[simps { fully_applied := ff }]
45+
def equiv_bounded_of_compact : C(α, β) ≃ (α →ᵇ β) :=
46+
⟨mk_of_compact, forget_boundedness α β, λ f, by { ext, refl, }, λ f, by { ext, refl, }⟩
4347

4448
/--
4549
When `α` is compact, the bounded continuous maps `α →ᵇ 𝕜` are
4650
additively equivalent to `C(α, 𝕜)`.
4751
-/
48-
@[simps]
49-
def add_equiv_bounded_of_compact : C(α, β) ≃+ (α →ᵇ β) :=
50-
({ ..forget_boundedness_add_hom α β,
51-
..(equiv_bounded_of_compact α β).symm, } : (α →ᵇ β) ≃+ C(α, β)).symm
52-
53-
-- It would be nice if `@[simps]` produced this directly,
54-
-- instead of the unhelpful `add_equiv_bounded_of_compact_apply_to_continuous_map`.
55-
@[simp]
56-
lemma add_equiv_bounded_of_compact_apply_apply (f : C(α, β)) (a : α) :
57-
add_equiv_bounded_of_compact α β f a = f a :=
58-
rfl
59-
60-
@[simp]
61-
lemma add_equiv_bounded_of_compact_to_equiv :
62-
(add_equiv_bounded_of_compact α β).to_equiv = equiv_bounded_of_compact α β :=
63-
rfl
52+
@[simps apply symm_apply { fully_applied := ff }]
53+
def add_equiv_bounded_of_compact [add_monoid β] [has_lipschitz_add β] :
54+
C(α, β) ≃+ (α →ᵇ β) :=
55+
({ .. forget_boundedness_add_hom α β,
56+
.. (equiv_bounded_of_compact α β).symm, } : (α →ᵇ β) ≃+ C(α, β)).symm
6457

65-
instance : metric_space C(α,μ) :=
58+
instance : metric_space C(α, β) :=
6659
metric_space.induced
67-
(equiv_bounded_of_compact α μ)
68-
(equiv_bounded_of_compact α μ).injective
60+
(equiv_bounded_of_compact α β)
61+
(equiv_bounded_of_compact α β).injective
6962
(by apply_instance)
7063

64+
/--
65+
When `α` is compact, and `β` is a metric space, the bounded continuous maps `α →ᵇ β` are
66+
isometric to `C(α, β)`.
67+
-/
68+
@[simps to_equiv apply symm_apply { fully_applied := ff }]
69+
def isometric_bounded_of_compact :
70+
C(α, β) ≃ᵢ (α →ᵇ β) :=
71+
{ isometry_to_fun := λ x y, rfl,
72+
to_equiv := equiv_bounded_of_compact α β }
73+
74+
end
75+
76+
@[simp] lemma _root_.bounded_continuous_function.dist_mk_of_compact (f g : C(α, β)) :
77+
dist (mk_of_compact f) (mk_of_compact g) = dist f g := rfl
78+
79+
@[simp] lemma _root_.bounded_continuous_function.dist_forget_boundedness (f g : α →ᵇ β) :
80+
dist (f.forget_boundedness _ _) (g.forget_boundedness _ _) = dist f g := rfl
81+
82+
open bounded_continuous_function
83+
7184
section
72-
variables {α β} (f g : C(α, β)) {C : ℝ}
85+
variables {α β} {f g : C(α, β)} {C : ℝ}
86+
87+
/-- The pointwise distance is controlled by the distance between functions, by definition. -/
88+
lemma dist_apply_le_dist (x : α) : dist (f x) (g x) ≤ dist f g :=
89+
by simp only [← dist_mk_of_compact, dist_coe_le_dist, ← mk_of_compact_apply]
7390

7491
/-- The distance between two functions is controlled by the supremum of the pointwise distances -/
7592
lemma dist_le (C0 : (0 : ℝ) ≤ C) : dist f g ≤ C ↔ ∀x:α, dist (f x) (g x) ≤ C :=
76-
@bounded_continuous_function.dist_le _ _ _ _
77-
((equiv_bounded_of_compact α β) f) ((equiv_bounded_of_compact α β) g) _ C0
93+
by simp only [← dist_mk_of_compact, dist_le C0, mk_of_compact_apply]
7894

7995
lemma dist_le_iff_of_nonempty [nonempty α] :
8096
dist f g ≤ C ↔ ∀ x, dist (f x) (g x) ≤ C :=
81-
@bounded_continuous_function.dist_le_iff_of_nonempty _ _ _ _
82-
((equiv_bounded_of_compact α β) f) ((equiv_bounded_of_compact α β) g) _ _
97+
by simp only [← dist_mk_of_compact, dist_le_iff_of_nonempty, mk_of_compact_apply]
8398

84-
lemma dist_lt_of_nonempty [nonempty α]
85-
(w : ∀x:α, dist (f x) (g x) < C) : dist f g < C :=
86-
@bounded_continuous_function.dist_lt_of_nonempty_compact _ _ _ _
87-
((equiv_bounded_of_compact α β) f) ((equiv_bounded_of_compact α β) g) _ _ _ w
88-
89-
lemma dist_lt_iff (C0 : (0 : ℝ) < C) :
99+
lemma dist_lt_iff_of_nonempty [nonempty α] :
90100
dist f g < C ↔ ∀x:α, dist (f x) (g x) < C :=
91-
@bounded_continuous_function.dist_lt_iff_of_compact _ _ _ _
92-
((equiv_bounded_of_compact α β) f) ((equiv_bounded_of_compact α β) g) _ _ C0
101+
by simp only [← dist_mk_of_compact, dist_lt_iff_of_nonempty_compact, mk_of_compact_apply]
93102

94-
lemma dist_lt_iff_of_nonempty [nonempty α] :
103+
lemma dist_lt_of_nonempty [nonempty α] (w : ∀x:α, dist (f x) (g x) < C) : dist f g < C :=
104+
(dist_lt_iff_of_nonempty).2 w
105+
106+
lemma dist_lt_iff (C0 : (0 : ℝ) < C) :
95107
dist f g < C ↔ ∀x:α, dist (f x) (g x) < C :=
96-
@bounded_continuous_function.dist_lt_iff_of_nonempty_compact _ _ _ _
97-
((equiv_bounded_of_compact α β) f) ((equiv_bounded_of_compact α β) g) _ _ _
108+
by simp only [← dist_mk_of_compact, dist_lt_iff_of_compact C0, mk_of_compact_apply]
98109

99110
end
100111

101-
variables (α β)
112+
instance [complete_space β] : complete_space (C(α, β)) :=
113+
(isometric_bounded_of_compact α β).complete_space
102114

103-
/--
104-
When `α` is compact, and `β` is a metric space, the bounded continuous maps `α →ᵇ β` are
105-
isometric to `C(α, β)`.
106-
-/
107-
@[simps]
108-
def isometric_bounded_of_compact :
109-
C(α, μ) ≃ᵢ (α →ᵇ μ) :=
110-
{ isometry_to_fun := λ x y, rfl,
111-
to_equiv := equiv_bounded_of_compact α μ }
115+
@[continuity] lemma continuous_eval : continuous (λ p : C(α, β) × α, p.1 p.2) :=
116+
continuous_eval.comp ((isometric_bounded_of_compact α β).continuous.prod_map continuous_id)
117+
118+
@[continuity] lemma continuous_evalx (x : α) : continuous (λ f : C(α, β), f x) :=
119+
continuous_eval.comp (continuous_id.prod_mk continuous_const)
120+
121+
lemma continuous_coe : @continuous (C(α, β)) (α → β) _ _ coe_fn :=
122+
continuous_pi continuous_evalx
112123

113124
-- TODO at some point we will need lemmas characterising this norm!
114-
-- At the moment the only way to reason about it is to transfer `f : C(α,β)` back to `α →ᵇ β`.
115-
instance : has_norm C(α,β) :=
125+
-- At the moment the only way to reason about it is to transfer `f : C(α,E)` back to `α →ᵇ E`.
126+
instance : has_norm C(α, E) :=
116127
{ norm := λ x, dist x 0 }
117128

118-
instance : normed_group C(α,β) :=
129+
@[simp] lemma _root_.bounded_continuous_function.norm_mk_of_compact (f : C(α, E)) :
130+
∥mk_of_compact f∥ = ∥f∥ := rfl
131+
132+
@[simp] lemma _root_.bounded_continuous_function.norm_forget_boundedness_eq (f : α →ᵇ E) :
133+
∥forget_boundedness α E f∥ = ∥f∥ :=
134+
rfl
135+
136+
open bounded_continuous_function
137+
138+
instance : normed_group C(α, E) :=
119139
{ dist_eq := λ x y,
120140
begin
121-
change dist x y = dist (x-y) 0,
122-
-- it would be nice if `equiv_rw` could rewrite in multiple places at once
123-
equiv_rw (equiv_bounded_of_compact α β) at x,
124-
equiv_rw (equiv_bounded_of_compact α β) at y,
125-
have p : dist x y = dist (x-y) 0, { rw dist_eq_norm, rw dist_zero_right, },
126-
convert p,
127-
exact ((add_equiv_bounded_of_compact α β).symm.map_sub _ _).symm,
141+
rw [← norm_mk_of_compact, ← dist_mk_of_compact, dist_eq_norm],
142+
congr' 1,
143+
exact ((add_equiv_bounded_of_compact α E).map_sub _ _).symm
128144
end, }
129145

130146
section
131-
variables {α β} (f : C(α, β))
147+
variables (f : C(α, E))
132148
-- The corresponding lemmas for `bounded_continuous_function` are stated with `{f}`,
133149
-- and so can not be used in dot notation.
134150

135151
lemma norm_coe_le_norm (x : α) : ∥f x∥ ≤ ∥f∥ :=
136-
((equiv_bounded_of_compact α β) f).norm_coe_le_norm x
152+
(mk_of_compact f).norm_coe_le_norm x
137153

138154
/-- Distance between the images of any two points is at most twice the norm of the function. -/
139155
lemma dist_le_two_norm (x y : α) : dist (f x) (f y) ≤ 2 * ∥f∥ :=
140-
((equiv_bounded_of_compact α β) f).dist_le_two_norm x y
156+
(mk_of_compact f).dist_le_two_norm x y
141157

142158
/-- The norm of a function is controlled by the supremum of the pointwise norms -/
143159
lemma norm_le {C : ℝ} (C0 : (0 : ℝ) ≤ C) : ∥f∥ ≤ C ↔ ∀x:α, ∥f x∥ ≤ C :=
144160
@bounded_continuous_function.norm_le _ _ _ _
145-
((equiv_bounded_of_compact α β) f) _ C0
161+
(mk_of_compact f) _ C0
146162

147163
lemma norm_le_of_nonempty [nonempty α] {M : ℝ} : ∥f∥ ≤ M ↔ ∀ x, ∥f x∥ ≤ M :=
148-
@bounded_continuous_function.norm_le_of_nonempty _ _ _ _ _
149-
((equiv_bounded_of_compact α β) f) _
164+
@bounded_continuous_function.norm_le_of_nonempty _ _ _ _ _ (mk_of_compact f) _
150165

151166
lemma norm_lt_iff {M : ℝ} (M0 : 0 < M) : ∥f∥ < M ↔ ∀ x, ∥f x∥ < M :=
152-
@bounded_continuous_function.norm_lt_iff_of_compact _ _ _ _ _
153-
((equiv_bounded_of_compact α β) f) _ M0
167+
@bounded_continuous_function.norm_lt_iff_of_compact _ _ _ _ _ (mk_of_compact f) _ M0
154168

155169
lemma norm_lt_iff_of_nonempty [nonempty α] {M : ℝ} :
156170
∥f∥ < M ↔ ∀ x, ∥f x∥ < M :=
157-
@bounded_continuous_function.norm_lt_iff_of_nonempty_compact _ _ _ _ _ _
158-
((equiv_bounded_of_compact α β) f) _
171+
@bounded_continuous_function.norm_lt_iff_of_nonempty_compact _ _ _ _ _ _ (mk_of_compact f) _
159172

160173
lemma apply_le_norm (f : C(α, ℝ)) (x : α) : f x ≤ ∥f∥ :=
161174
le_trans (le_abs.mpr (or.inl (le_refl (f x)))) (f.norm_coe_le_norm x)
162175

163176
lemma neg_norm_le_apply (f : C(α, ℝ)) (x : α) : -∥f∥ ≤ f x :=
164177
le_trans (neg_le_neg (f.norm_coe_le_norm x)) (neg_le.mp (neg_le_abs_self (f x)))
165178

166-
@[simp] lemma _root_.bounded_continuous_function.norm_forget_boundedness_eq (f : α →ᵇ β) :
167-
∥forget_boundedness α β f∥ = ∥f∥ :=
168-
rfl
169-
170179
lemma norm_eq_supr_norm : ∥f∥ = ⨆ x : α, ∥f x∥ :=
171-
begin
172-
equiv_rw equiv_bounded_of_compact α β at f,
173-
rw [equiv_bounded_of_compact_symm_apply, forget_boundedness_coe, f.norm_forget_boundedness_eq,
174-
f.norm_eq_supr_norm],
175-
end
180+
(mk_of_compact f).norm_eq_supr_norm
176181

177182
end
178183

179184
section
180185
variables {R : Type*} [normed_ring R]
181186

182187
instance : normed_ring C(α,R) :=
183-
{ norm_mul := λ f g,
184-
begin
185-
equiv_rw (equiv_bounded_of_compact α R) at f,
186-
equiv_rw (equiv_bounded_of_compact α R) at g,
187-
exact norm_mul_le f g,
188-
end,
188+
{ norm_mul := λ f g, norm_mul_le (mk_of_compact f) (mk_of_compact g),
189189
..(infer_instance : normed_group C(α,R)) }
190190

191191
end
192192

193193
section
194-
variables {𝕜 : Type*} [normed_field 𝕜] [normed_space 𝕜 β]
194+
variables {𝕜 : Type*} [normed_field 𝕜] [normed_space 𝕜 E]
195195

196-
instance : normed_space 𝕜 C(α,β) :=
197-
{ norm_smul_le := λ c f,
198-
begin
199-
equiv_rw (equiv_bounded_of_compact α β) at f,
200-
exact le_of_eq (norm_smul c f),
201-
end }
196+
instance : normed_space 𝕜 C(α,E) :=
197+
{ norm_smul_le := λ c f, le_of_eq (norm_smul c (mk_of_compact f)) }
202198

203-
variables (α 𝕜)
199+
section
200+
variables (α 𝕜 E)
204201

205202
/--
206203
When `α` is compact and `𝕜` is a normed field,
207204
the `𝕜`-algebra of bounded continuous maps `α →ᵇ β` is
208205
`𝕜`-linearly isometric to `C(α, β)`.
209206
-/
210207
def linear_isometry_bounded_of_compact :
211-
C(α, β) ≃ₗᵢ[𝕜] (α →ᵇ β) :=
208+
C(α, E) ≃ₗᵢ[𝕜] (α →ᵇ E) :=
212209
{ map_smul' := λ c f, by { ext, simp, },
213210
norm_map' := λ f, rfl,
214-
..add_equiv_bounded_of_compact α β }
211+
.. add_equiv_bounded_of_compact α E }
212+
213+
end
215214

216215
-- this lemma and the next are the analogues of those autogenerated by `@[simps]` for
217216
-- `equiv_bounded_of_compact`, `add_equiv_bounded_of_compact`
218-
@[simp] lemma linear_isometry_bounded_of_compact_symm_apply (f : α →ᵇ β) :
219-
(linear_isometry_bounded_of_compact α β 𝕜).symm f = f.forget_boundedness α β :=
217+
@[simp] lemma linear_isometry_bounded_of_compact_symm_apply (f : α →ᵇ E) :
218+
(linear_isometry_bounded_of_compact α E 𝕜).symm f = f.forget_boundedness α E :=
220219
rfl
221220

222-
@[simp] lemma linear_isometry_bounded_of_compact_apply_apply (f : C(α, β)) (a : α) :
223-
((linear_isometry_bounded_of_compact α β 𝕜) f) a = f a :=
221+
@[simp] lemma linear_isometry_bounded_of_compact_apply_apply (f : C(α, E)) (a : α) :
222+
(linear_isometry_bounded_of_compact α E 𝕜 f) a = f a :=
224223
rfl
225224

226225

227226
@[simp]
228227
lemma linear_isometry_bounded_of_compact_to_isometric :
229-
(linear_isometry_bounded_of_compact α β 𝕜).to_isometric =
230-
isometric_bounded_of_compact α β :=
228+
(linear_isometry_bounded_of_compact α E 𝕜).to_isometric = (isometric_bounded_of_compact α E) :=
231229
rfl
232230

233231
@[simp]
234232
lemma linear_isometry_bounded_of_compact_to_add_equiv :
235-
(linear_isometry_bounded_of_compact α β 𝕜).to_linear_equiv.to_add_equiv =
236-
add_equiv_bounded_of_compact α β :=
233+
(linear_isometry_bounded_of_compact α E 𝕜).to_linear_equiv.to_add_equiv =
234+
(add_equiv_bounded_of_compact α E) :=
237235
rfl
238236

239237
@[simp]
240238
lemma linear_isometry_bounded_of_compact_of_compact_to_equiv :
241-
(linear_isometry_bounded_of_compact α β 𝕜).to_linear_equiv.to_equiv =
242-
equiv_bounded_of_compact α β :=
239+
(linear_isometry_bounded_of_compact α E 𝕜).to_linear_equiv.to_equiv =
240+
(equiv_bounded_of_compact α E) :=
243241
rfl
244242

245243
end
@@ -280,12 +278,12 @@ def modulus (f : C(α, β)) (ε : ℝ) (h : 0 < ε) : ℝ :=
280278
classical.some (uniform_continuity f ε h)
281279

282280
lemma modulus_pos (f : C(α, β)) {ε : ℝ} {h : 0 < ε} : 0 < f.modulus ε h :=
283-
classical.some (classical.some_spec (uniform_continuity f ε h))
281+
(classical.some_spec (uniform_continuity f ε h)).fst
284282

285283
lemma dist_lt_of_dist_lt_modulus
286284
(f : C(α, β)) (ε : ℝ) (h : 0 < ε) {a b : α} (w : dist a b < f.modulus ε h) :
287285
dist (f a) (f b) < ε :=
288-
classical.some_spec (classical.some_spec (uniform_continuity f ε h)) w
286+
(classical.some_spec (uniform_continuity f ε h)).snd w
289287

290288
end uniform_continuity
291289

@@ -312,7 +310,7 @@ protected def continuous_linear_map.comp_left_continuous_compact (g : β →L[
312310

313311
@[simp] lemma continuous_linear_map.to_linear_comp_left_continuous_compact (g : β →L[𝕜] γ) :
314312
(g.comp_left_continuous_compact X : C(X, β) →ₗ[𝕜] C(X, γ)) = g.comp_left_continuous 𝕜 X :=
315-
by { ext f, simp [continuous_linear_map.comp_left_continuous_compact] }
313+
by { ext f, refl }
316314

317315
@[simp] lemma continuous_linear_map.comp_left_continuous_compact_apply (g : β →L[𝕜] γ)
318316
(f : C(X, β)) (x : X) :
@@ -346,7 +344,7 @@ def comp_right_continuous_map {X Y : Type*} (T : Type*)
346344
refine metric.continuous_iff.mpr _,
347345
intros g ε ε_pos,
348346
refine ⟨ε, ε_pos, λ g' h, _⟩,
349-
rw continuous_map.dist_lt_iff _ _ ε_pos at h ⊢,
347+
rw continuous_map.dist_lt_iff ε_pos at h ⊢,
350348
{ exact λ x, h (f x), },
351349
end }
352350

0 commit comments

Comments
 (0)