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

Commit 68efb10

Browse files
committed
refactor(topology/*): Hom classes for continuous maps/homs (#11909)
Add * `continuous_map_class` * `bounded_continuous_map_class` * `continuous_monoid_hom_class` * `continuous_add_monoid_hom_class` * `continuous_map.homotopy_class` to follow the `fun_like` design. Deprecate lemmas accordingly. Also rename a few fields to match the convention in the rest of the library.
1 parent 247943a commit 68efb10

File tree

16 files changed

+302
-179
lines changed

16 files changed

+302
-179
lines changed

src/algebraic_geometry/prime_spectrum/basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ variables (f : R →+* S)
502502
(comap f y).as_ideal = ideal.comap f y.as_ideal :=
503503
rfl
504504

505-
@[simp] lemma comap_id : comap (ring_hom.id R) = continuous_map.id := by { ext, refl }
505+
@[simp] lemma comap_id : comap (ring_hom.id R) = continuous_map.id _ := by { ext, refl }
506506

507507
@[simp] lemma comap_comp (f : R →+* S) (g : S →+* S') :
508508
comap (g.comp f) = (comap f).comp (comap g) :=

src/topology/algebra/continuous_monoid_hom.lean

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,96 @@ This file defines the space of continuous homomorphisms between two topological
1414
## Main definitions
1515
1616
* `continuous_monoid_hom A B`: The continuous homomorphisms `A →* B`.
17-
17+
* `continuous_add_monoid_hom α β`: The continuous additive homomorphisms `α →+ β`.
1818
-/
1919

20-
variables (A B C D E : Type*)
20+
open function
21+
22+
variables {F α β : Type*} (A B C D E : Type*)
2123
[monoid A] [monoid B] [monoid C] [monoid D] [comm_group E]
2224
[topological_space A] [topological_space B] [topological_space C] [topological_space D]
2325
[topological_space E] [topological_group E]
2426

25-
set_option old_structure_cmd true
27+
/-- The type of continuous additive monoid homomorphisms from `α` to `β`.
2628
27-
/-- Continuous homomorphisms between two topological groups. -/
28-
structure continuous_monoid_hom extends A →* B, continuous_map A B
29+
When possible, instead of parametrizing results over `(f : continuous_add_monoid_hom α β)`,
30+
you should parametrize over `(F : Type*) [continuous_add_monoid_hom_class F α β] (f : F)`.
2931
30-
/-- Continuous homomorphisms between two topological groups. -/
32+
When you extend this structure, make sure to extend `continuous_add_monoid_hom_class`. -/
3133
structure continuous_add_monoid_hom (A B : Type*) [add_monoid A] [add_monoid B]
32-
[topological_space A] [topological_space B] extends A →+ B, continuous_map A B
34+
[topological_space A] [topological_space B] extends A →+ B :=
35+
(continuous_to_fun : continuous to_fun)
36+
37+
/-- The type of continuous monoid homomorphisms from `α` to `β`.
38+
39+
When possible, instead of parametrizing results over `(f : continuous_monoid_hom α β)`,
40+
you should parametrize over `(F : Type*) [continuous_monoid_hom_class F α β] (f : F)`.
3341
34-
attribute [to_additive] continuous_monoid_hom
35-
attribute [to_additive] continuous_monoid_hom.to_monoid_hom
42+
When you extend this structure, make sure to extend `continuous_add_monoid_hom_class`. -/
43+
@[to_additive]
44+
structure continuous_monoid_hom extends A →* B :=
45+
(continuous_to_fun : continuous to_fun)
3646

37-
initialize_simps_projections continuous_monoid_hom (to_fun → apply)
47+
/-- `continuous_add_monoid_hom_class F α β` states that `F` is a type of continuous additive monoid
48+
homomorphisms.
49+
50+
You should also extend this typeclass when you extend `continuous_add_monoid_hom`. -/
51+
class continuous_add_monoid_hom_class (F α β : Type*) [add_monoid α] [add_monoid β]
52+
[topological_space α] [topological_space β] extends add_monoid_hom_class F α β :=
53+
(map_continuous (f : F) : continuous f)
54+
55+
/-- `continuous_monoid_hom_class F α β` states that `F` is a type of continuous additive monoid
56+
homomorphisms.
57+
58+
You should also extend this typeclass when you extend `continuous_monoid_hom`. -/
59+
@[to_additive]
60+
class continuous_monoid_hom_class (F α β : Type*) [monoid α] [monoid β]
61+
[topological_space α] [topological_space β] extends monoid_hom_class F α β :=
62+
(map_continuous (f : F) : continuous f)
3863

3964
/-- Reinterpret a `continuous_monoid_hom` as a `monoid_hom`. -/
4065
add_decl_doc continuous_monoid_hom.to_monoid_hom
4166

42-
/-- Reinterpret a `continuous_monoid_hom` as a `continuous_map`. -/
43-
add_decl_doc continuous_monoid_hom.to_continuous_map
44-
4567
/-- Reinterpret a `continuous_add_monoid_hom` as an `add_monoid_hom`. -/
4668
add_decl_doc continuous_add_monoid_hom.to_add_monoid_hom
4769

48-
/-- Reinterpret a `continuous_add_monoid_hom` as a `continuous_map`. -/
49-
add_decl_doc continuous_add_monoid_hom.to_continuous_map
70+
@[priority 100, to_additive] -- See note [lower instance priority]
71+
instance continuous_monoid_hom_class.to_continuous_map_class [monoid α] [monoid β]
72+
[topological_space α] [topological_space β] [continuous_monoid_hom_class F α β] :
73+
continuous_map_class F α β :=
74+
{ .. ‹continuous_monoid_hom_class F α β› }
5075

5176
namespace continuous_monoid_hom
52-
53-
variables {A B C D E}
54-
77+
variables {A B C D E} [monoid α] [monoid β] [topological_space α] [topological_space β]
78+
79+
@[to_additive]
80+
instance : continuous_monoid_hom_class (continuous_monoid_hom α β) α β :=
81+
{ coe := λ f, f.to_fun,
82+
coe_injective' := λ f g h, by { obtain ⟨⟨_, _⟩, _⟩ := f, obtain ⟨⟨_, _⟩, _⟩ := g, congr' },
83+
map_mul := λ f, f.map_mul',
84+
map_one := λ f, f.map_one',
85+
map_continuous := λ f, f.continuous_to_fun }
86+
87+
/-- Helper instance for when there's too many metavariables to apply `fun_like.has_coe_to_fun`
88+
directly. -/
5589
@[to_additive] instance : has_coe_to_fun (continuous_monoid_hom A B) (λ _, A → B) :=
56-
⟨continuous_monoid_hom.to_fun⟩
90+
fun_like.has_coe_to_fun
5791

5892
@[to_additive] lemma ext {f g : continuous_monoid_hom A B} (h : ∀ x, f x = g x) : f = g :=
59-
by cases f; cases g; congr; exact funext h
93+
fun_like.ext _ _ h
94+
95+
/-- Reinterpret a `continuous_monoid_hom` as a `continuous_map`. -/
96+
@[to_additive "Reinterpret a `continuous_add_monoid_hom` as a `continuous_map`."]
97+
def to_continuous_map (f : continuous_monoid_hom α β) : C(α, β) := { .. f}
98+
99+
@[to_additive] lemma to_continuous_map_injective : injective (to_continuous_map : _ → C(α, β)) :=
100+
λ f g h, ext $ by convert fun_like.ext_iff.1 h
60101

61102
/-- Construct a `continuous_monoid_hom` from a `continuous` `monoid_hom`. -/
62103
@[to_additive "Construct a `continuous_add_monoid_hom` from a `continuous` `add_monoid_hom`.",
63104
simps]
64-
def mk' (f : A →* B) (hf : continuous f) : continuous_monoid_hom A B := { .. f }
105+
def mk' (f : A →* B) (hf : continuous f) : continuous_monoid_hom A B :=
106+
{ continuous_to_fun := hf, .. f }
65107

66108
/-- Composition of two continuous homomorphisms. -/
67109
@[to_additive "Composition of two continuous homomorphisms.", simps]
@@ -153,7 +195,7 @@ variables (A B C D E)
153195
lemma is_inducing : inducing (to_continuous_map : continuous_monoid_hom A B → C(A, B)) := ⟨rfl⟩
154196

155197
lemma is_embedding : embedding (to_continuous_map : continuous_monoid_hom A B → C(A, B)) :=
156-
⟨is_inducing A B, λ _ _, ext ∘ continuous_map.ext_iff.mp
198+
⟨is_inducing A B, to_continuous_map_injective
157199

158200
variables {A B C D E}
159201

src/topology/category/CompHaus/default.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import category_theory.monad.limits
1111
import topology.urysohns_lemma
1212

1313
/-!
14-
1514
# The category of Compact Hausdorff Spaces
1615
1716
We construct the category of compact Hausdorff spaces.
@@ -134,7 +133,7 @@ noncomputable def stone_cech_equivalence (X : Top.{u}) (Y : CompHaus.{u}) :
134133
begin
135134
rintro ⟨f : (X : Type*) ⟶ Y, hf : continuous f⟩,
136135
ext,
137-
exact congr_fun (stone_cech_extend_extends hf) x,
136+
exact congr_fun (stone_cech_extend_extends hf) _,
138137
end }
139138

140139
/--

src/topology/compact_open.lean

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ lemma curry_apply (f : C(α × β, γ)) (a : α) (b : β) : f.curry a b = f (a,
277277
lemma continuous_uncurry_of_continuous [locally_compact_space β] (f : C(α, C(β, γ))) :
278278
continuous (function.uncurry (λ x y, f x y)) :=
279279
have hf : function.uncurry (λ x y, f x y) = ev β γ ∘ prod.map f id, by { ext, refl },
280-
hf ▸ continuous.comp continuous_ev $ continuous.prod_map f.2 id.2
280+
hf ▸ continuous.comp continuous_ev $ continuous.prod_map f.2 continuous_id
281281

282282
/-- The uncurried form of a continuous map `α → C(β, γ)` as a continuous map `α × β → γ` (if `β` is
283283
locally compact). If `α` is also locally compact, then this is a homeomorphism between the two
@@ -291,16 +291,16 @@ lemma continuous_uncurry [locally_compact_space α] [locally_compact_space β] :
291291
begin
292292
apply continuous_of_continuous_uncurry,
293293
rw ←homeomorph.comp_continuous_iff' (homeomorph.prod_assoc _ _ _),
294-
apply continuous.comp continuous_ev (continuous.prod_map continuous_ev id.2);
294+
apply continuous.comp continuous_ev (continuous.prod_map continuous_ev continuous_id);
295295
apply_instance
296296
end
297297

298298
/-- The family of constant maps: `β → C(α, β)` as a continuous map. -/
299299
def const' : C(β, C(α, β)) := curry ⟨prod.fst, continuous_fst⟩
300300

301-
@[simp] lemma coe_const' : (const' : β → C(α, β)) = const := rfl
301+
@[simp] lemma coe_const' : (const' : β → C(α, β)) = const α := rfl
302302

303-
lemma continuous_const' : continuous (const : β → C(α, β)) := const'.continuous
303+
lemma continuous_const' : continuous (const α : β → C(α, β)) := const'.continuous
304304

305305
end curry
306306

@@ -323,7 +323,7 @@ def continuous_map_of_unique [unique α] : β ≃ₜ C(α, β) :=
323323
{ to_fun := continuous_map.comp ⟨_, continuous_fst⟩ ∘ coev α β,
324324
inv_fun := ev α β ∘ (λ f, (f, default)),
325325
left_inv := λ a, rfl,
326-
right_inv := λ f, by { ext, rw unique.eq_default x, refl },
326+
right_inv := λ f, by { ext, rw unique.eq_default a, refl },
327327
continuous_to_fun := continuous.comp (continuous_comp _) continuous_coev,
328328
continuous_inv_fun :=
329329
continuous.comp continuous_ev (continuous.prod_mk continuous_id continuous_const) }

src/topology/continuous_function/algebra.lean

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,21 @@ instance has_mul [has_mul β] [has_continuous_mul β] : has_mul C(α, β) :=
4646
⟨λ f g, ⟨f * g, continuous_mul.comp (f.continuous.prod_mk g.continuous : _)⟩⟩
4747

4848
@[simp, norm_cast, to_additive]
49-
lemma coe_mul [has_mul β] [has_continuous_mul β] (f g : C(α, β)) :
50-
((f * g : C(α, β)) : α → β) = (f : α → β) * (g : α → β) := rfl
49+
lemma coe_mul [has_mul β] [has_continuous_mul β] (f g : C(α, β)) : ⇑(f * g) = f * g := rfl
5150

5251
@[simp, to_additive] lemma mul_comp [has_mul γ] [has_continuous_mul γ]
5352
(f₁ f₂ : C(β, γ)) (g : C(α, β)) :
5453
(f₁ * f₂).comp g = f₁.comp g * f₂.comp g :=
5554
rfl
5655

5756
@[to_additive]
58-
instance [has_one β] : has_one C(α, β) := ⟨const (1 : β)
57+
instance [has_one β] : has_one C(α, β) := ⟨const α 1
5958

6059
@[simp, norm_cast, to_additive]
61-
lemma coe_one [has_one β] : ((1 : C(α, β)) : α → β) = (1 : α → β) := rfl
60+
lemma coe_one [has_one β] : ⇑(1 : C(α, β)) = 1 := rfl
61+
62+
@[simp, to_additive] lemma one_comp [has_one γ] (g : C(α, β)) : (1 : C(β, γ)).comp g = 1 := rfl
6263

63-
@[simp, to_additive] lemma one_comp [has_one γ] (g : C(α, β)) :
64-
(1 : C(β, γ)).comp g = 1 :=
65-
rfl
6664
instance has_nsmul [add_monoid β] [has_continuous_add β] : has_scalar ℕ C(α, β) :=
6765
⟨λ n f, ⟨n • f, f.continuous.nsmul n⟩⟩
6866

0 commit comments

Comments
 (0)