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

Commit bcfa726

Browse files
committed
refactor(topology/{order,*}): review API (#18312)
## Main changes * Switch from `@[class] structure topological_space` to `class`. * Introduce notation `is_open[t]`/`is_closed[t]`/`𝓤[u]` and use it instead of `t.is_open`/`@is_closed _ t`/`u.uniformity` * Don't introduce a temporary order on `topological_space`, use `galois_coinsertion` to the order-dual of `set (set α)` instead. * Drop `discrete_topology_bot`. It seems that this instance doesn't work well in Lean 4 (in fact, I failed to define it without using `@DiscreteTopology.mk`). ## Other changes ### Topological spaces * Add `is_open_mk`. * Rename `generate_from_mono` to `generate_from_anti`, move it to the `topological_space` namespace. * Add `embedding_inclusion`, `embedding_ulift_down`, and `ulift.discrete_topology`. * Move `discrete_topology.of_subset` from `topology.separation` to `topology.constructions`. * Move `embedding.discrete_topology` from `topology.separation` to `topology.maps`. * Use explicit arguments in an argument of `nhds_mk_of_nhds`. * Move some definitions and lemmas like `mk_of_closure`, `gi_generate_from` (renamed to `gci_generate_from`), `left_inverse_generate_from` to the `topological_space` namespace. These lemmas are very specific and use generic names. * Add `topological_space` and `discrete_topology` instances for `fin n`. * Drop `is_open_induced_iff'`, use non-primed version instead. * Prove `set_of_is_open_sup` by `rfl`. * Drop `nhds_bot`, use `nhds_discrete` instead. * Drop `induced_bot` and `discrete_topology_induced` ### Uniform spaces * Drop `infi_uniformity'` and `inf_uniformity'`. * Use `@uniformity α (uniform_space.comap _ _)` instead of `(h : ‹uniform_space α› = uniform_space.comap f ‹uniform_space β›)` in `uniformity_comap`. ### Locally constant functions and discrete quotients * Use quotient space topology for the coercion of a `discrete_quotient` to `Type*`, then prove `[discrete_topology]`. This way we avoid surprising diamonds in the future (especially if Lean 4 will unfold the coercion). * Merge `locally_constant.lift` and `locally_constant.locally_constant_lift` into 1 def, rename `factors` to `lift_comp_proj`. * Protect `locally_constant.is_locally_constant`. * Drop `locally_constant.iff_continuous_bot` ### Categories * Add an instance for `discrete_topology (discrete.obj X)`. * Rename `Fintype.discrete_topology` to `Fintype.bot_topology `, add lemma `Fintype.discrete_topology` sating that this is a `[discrete_topology]`. ### Topological rings * Fix&golf a proof that failed because of API changes.
1 parent 861a269 commit bcfa726

34 files changed

+324
-431
lines changed

src/analysis/locally_convex/polar.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ polar
3737

3838

3939
variables {𝕜 E F : Type*}
40+
open_locale topology
4041

4142
namespace linear_map
4243

@@ -101,7 +102,7 @@ end
101102

102103
/-- The polar set is closed in the weak topology induced by `B.flip`. -/
103104
lemma polar_weak_closed (s : set E) :
104-
@is_closed _ (weak_bilin.topological_space B.flip) (B.polar s) :=
105+
is_closed[weak_bilin.topological_space B.flip] (B.polar s) :=
105106
begin
106107
rw polar_eq_Inter,
107108
refine is_closed_Inter (λ x, is_closed_Inter (λ _, _)),

src/analysis/normed_space/pi_Lp.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ begin
368368
end
369369

370370
lemma aux_uniformity_eq :
371-
𝓤 (pi_Lp p β) = @uniformity _ (Pi.uniform_space _) :=
371+
𝓤 (pi_Lp p β) = 𝓤[Pi.uniform_space _] :=
372372
begin
373373
have A : uniform_inducing (pi_Lp.equiv p β) :=
374374
(antilipschitz_with_equiv_aux p β).uniform_inducing

src/geometry/manifold/charted_space.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ protected def to_topological_space : topological_space M :=
708708
topological_space.generate_from $ ⋃ (e : local_equiv M H) (he : e ∈ c.atlas)
709709
(s : set H) (s_open : is_open s), {e ⁻¹' s ∩ e.source}
710710

711-
lemma open_source' (he : e ∈ c.atlas) : @is_open M c.to_topological_space e.source :=
711+
lemma open_source' (he : e ∈ c.atlas) : is_open[c.to_topological_space] e.source :=
712712
begin
713713
apply topological_space.generate_open.basic,
714714
simp only [exists_prop, mem_Union, mem_singleton_iff],

src/measure_theory/constructions/polish.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ begin
231231
topology `t'`. It is analytic for this topology. As the identity from `t'` to `t` is continuous
232232
and the image of an analytic set is analytic, it follows that `s` is also analytic for `t`. -/
233233
obtain ⟨t', t't, t'_polish, s_closed, s_open⟩ :
234-
(t' : topological_space α), t' ≤ t ∧ @polish_space α t' ∧ @is_closed α t' s
235-
@is_open α t' s := hs.is_clopenable,
234+
∃ t' : topological_space α, t' ≤ t ∧ @polish_space α t' ∧ is_closed[t'] s ∧ is_open[t'] s :=
235+
hs.is_clopenable,
236236
have A := @is_closed.analytic_set α t' t'_polish s s_closed,
237237
convert @analytic_set.image_of_continuous α t' α t s A id (continuous_id_of_le t't),
238238
simp only [id.def, image_id'],
@@ -593,8 +593,8 @@ theorem _root_.measurable_set.image_of_continuous_on_inj_on
593593
measurable_set (f '' s) :=
594594
begin
595595
obtain ⟨t', t't, t'_polish, s_closed, s_open⟩ :
596-
∃ (t' : topological_space γ), t' ≤ tγ ∧ @polish_space γ t' ∧ @is_closed γ t' s ∧
597-
@is_open γ t' s := hs.is_clopenable,
596+
∃ (t' : topological_space γ), t' ≤ tγ ∧ @polish_space γ t' ∧ is_closed[t'] s ∧
597+
is_open[t'] s := hs.is_clopenable,
598598
exact @is_closed.measurable_set_image_of_continuous_on_inj_on γ t' t'_polish β _ _ _ _ s
599599
s_closed f (f_cont.mono_dom t't) f_inj,
600600
end
@@ -665,8 +665,8 @@ begin
665665
refine ⟨λ hs, _, λ hs, hs.is_clopenable⟩,
666666
-- consider a finer topology `t'` in which `s` is open and closed.
667667
obtain ⟨t', t't, t'_polish, s_closed, s_open⟩ :
668-
∃ (t' : topological_space γ), t' ≤ tγ ∧ @polish_space γ t' ∧ @is_closed γ t' s ∧
669-
@is_open γ t' s := hs,
668+
∃ (t' : topological_space γ), t' ≤ tγ ∧ @polish_space γ t' ∧ is_closed[t'] s ∧
669+
is_open[t'] s := hs,
670670
-- the identity is continuous from `t'` to `tγ`.
671671
have C : @continuous γ γ t' tγ id := continuous_id_of_le t't,
672672
-- therefore, it is also a measurable embedding, by the Lusin-Souslin theorem

src/topology/algebra/group/basic.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,8 @@ instance : has_top (group_topology α) :=
14661466
@[to_additive]
14671467
instance : has_bot (group_topology α) :=
14681468
⟨{to_topological_space := ⊥,
1469-
continuous_mul := by continuity,
1469+
continuous_mul := by
1470+
{ letI : topological_space α := ⊥, haveI := discrete_topology_bot α, continuity },
14701471
continuous_inv := continuous_bot}⟩
14711472

14721473
@[simp, to_additive] lemma to_topological_space_bot :

src/topology/algebra/ring.lean

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ instance inhabited {α : Type u} [ring α] : inhabited (ring_topology α) :=
369369

370370
@[ext]
371371
lemma ext' {f g : ring_topology α} (h : f.is_open = g.is_open) : f = g :=
372-
by { ext, rw h }
372+
by { ext : 2, exact h }
373373

374374
/-- The ordering on ring topologies on the ring `α`.
375375
`t ≤ s` if every set open in `s` is also open in `t` (`t` is finer than `s`). -/
@@ -452,24 +452,7 @@ def to_add_group_topology (t : ring_topology α) : add_group_topology α :=
452452
/-- The order embedding from ring topologies on `a` to additive group topologies on `a`. -/
453453
def to_add_group_topology.order_embedding : order_embedding (ring_topology α)
454454
(add_group_topology α) :=
455-
{ to_fun := λ t, t.to_add_group_topology,
456-
inj' :=
457-
begin
458-
intros t₁ t₂ h_eq,
459-
dsimp only at h_eq,
460-
ext,
461-
have h_t₁ : t₁.to_topological_space = t₁.to_add_group_topology.to_topological_space := rfl,
462-
rw [h_t₁, h_eq],
463-
refl,
464-
end,
465-
map_rel_iff' :=
466-
begin
467-
intros t₁ t₂,
468-
rw [embedding.coe_fn_mk],
469-
have h_le : t₁ ≤ t₂ ↔ t₁.to_topological_space ≤ t₂.to_topological_space := by refl,
470-
rw h_le,
471-
refl,
472-
end }
455+
order_embedding.of_map_le_iff to_add_group_topology $ λ _ _, iff.rfl
473456

474457
end ring_topology
475458

src/topology/algebra/uniform_group.lean

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,8 @@ by { rw [← comap_swap_uniformity, uniformity_eq_comap_nhds_one, comap_comap, (
213213
(hu : @uniform_group G u _) (hv : @uniform_group G v _)
214214
(h : @nhds _ u.to_topological_space 1 = @nhds _ v.to_topological_space 1) :
215215
u = v :=
216-
begin
217-
refine uniform_space_eq _,
218-
change @uniformity _ u = @uniformity _ v,
219-
rw [@uniformity_eq_comap_nhds_one _ u _ hu, @uniformity_eq_comap_nhds_one _ v _ hv, h]
220-
end
216+
uniform_space_eq $
217+
by rw [@uniformity_eq_comap_nhds_one _ u _ hu, @uniformity_eq_comap_nhds_one _ v _ hv, h]
221218

222219
@[to_additive] lemma uniform_group.ext_iff {G : Type*} [group G] {u v : uniform_space G}
223220
(hu : @uniform_group G u _) (hv : @uniform_group G v _) :
@@ -579,7 +576,6 @@ end
579576
[group G] [uniform_group G] : topological_group.to_uniform_space G = u :=
580577
begin
581578
ext : 1,
582-
show @uniformity G (topological_group.to_uniform_space G) = 𝓤 G,
583579
rw [uniformity_eq_comap_nhds_one' G, uniformity_eq_comap_nhds_one G]
584580
end
585581

src/topology/bases.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ begin
7171
obtain ⟨t₃, h₃, hs⟩ := h.exists_subset_inter _ h₁ _ h₂ x ⟨hx₁, hx₂⟩,
7272
exact ⟨t₃, or.inr h₃, hs⟩ },
7373
{ rw h.eq_generate_from,
74-
refine le_antisymm (le_generate_from $ λ t, _) (generate_from_mono $ subset_insert ∅ s),
74+
refine le_antisymm (le_generate_from $ λ t, _) (generate_from_anti $ subset_insert ∅ s),
7575
rintro (rfl|ht), { convert is_open_empty }, { exact generate_open.basic t ht } },
7676
end
7777

@@ -83,7 +83,7 @@ begin
8383
obtain ⟨t₃, h₃, hs⟩ := h.exists_subset_inter _ h₁ _ h₂ x hx,
8484
exact ⟨t₃, ⟨h₃, nonempty.ne_empty ⟨x, hs.1⟩⟩, hs⟩ },
8585
{ rw h.eq_generate_from,
86-
refine le_antisymm (generate_from_mono $ diff_subset s _) (le_generate_from $ λ t ht, _),
86+
refine le_antisymm (generate_from_anti $ diff_subset s _) (le_generate_from $ λ t ht, _),
8787
obtain rfl|he := eq_or_ne t ∅, { convert is_open_empty },
8888
exact generate_open.basic t ⟨ht, he⟩ },
8989
end
@@ -93,7 +93,7 @@ subcollections of `s` form a topological basis. -/
9393
lemma is_topological_basis_of_subbasis {s : set (set α)} (hs : t = generate_from s) :
9494
is_topological_basis ((λ f, ⋂₀ f) '' {f : set (set α) | f.finite ∧ f ⊆ s}) :=
9595
begin
96-
refine ⟨_, _, hs.trans (le_antisymm (le_generate_from _) $ generate_from_mono $ λ t ht, _)⟩,
96+
refine ⟨_, _, hs.trans (le_antisymm (le_generate_from _) $ generate_from_anti $ λ t ht, _)⟩,
9797
{ rintro _ ⟨t₁, ⟨hft₁, ht₁b⟩, rfl⟩ _ ⟨t₂, ⟨hft₂, ht₂b⟩, rfl⟩ x h,
9898
exact ⟨_, ⟨_, ⟨hft₁.union hft₂, union_subset ht₁b ht₂b⟩, sInter_union t₁ t₂⟩, h, subset.rfl⟩ },
9999
{ rw [sUnion_image, Union₂_eq_univ_iff],

src/topology/basic.lean

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,12 @@ universes u v w
6262
-/
6363

6464
/-- A topology on `α`. -/
65-
@[protect_proj] structure topological_space (α : Type u) :=
65+
@[protect_proj] class topological_space (α : Type u) :=
6666
(is_open : set α → Prop)
6767
(is_open_univ : is_open univ)
6868
(is_open_inter : ∀s t, is_open s → is_open t → is_open (s ∩ t))
6969
(is_open_sUnion : ∀s, (∀t∈s, is_open t) → is_open (⋃₀ s))
7070

71-
attribute [class] topological_space
72-
7371
/-- A constructor for topologies by specifying the closed sets,
7472
and showing that they satisfy the appropriate conditions. -/
7573
def topological_space.of_closed {α : Type u} (T : set (set α))
@@ -86,32 +84,36 @@ section topological_space
8684

8785
variables {α : Type u} {β : Type v} {ι : Sort w} {a : α} {s s₁ s₂ t : set α} {p p₁ p₂ : α → Prop}
8886

87+
/-- `is_open s` means that `s` is open in the ambient topological space on `α` -/
88+
def is_open [topological_space α] (s : set α) : Prop := @topological_space.is_open _ ‹_› s
89+
90+
localized "notation (name := is_open_of) `is_open[` t `]` := @is_open hole! t" in topology
91+
92+
lemma is_open_mk {p h₁ h₂ h₃} {s : set α} : is_open[⟨p, h₁, h₂, h₃⟩] s ↔ p s := iff.rfl
93+
8994
@[ext]
90-
lemma topological_space_eq : ∀ {f g : topological_space α}, f.is_open = g.is_open f = g
91-
| ⟨a, _, _, _⟩ ⟨b, _, _, _⟩ rfl := rfl
95+
lemma topological_space_eq {f g : topological_space α} (h : is_open[f] = is_open[g]) : f = g :=
96+
by unfreezingI { cases f, cases g, congr, exact h }
9297

9398
section
9499
variables [topological_space α]
95100

96-
/-- `is_open s` means that `s` is open in the ambient topological space on `α` -/
97-
def is_open (s : set α) : Prop := topological_space.is_open ‹_› s
98-
99101
@[simp]
100-
lemma is_open_univ : is_open (univ : set α) := topological_space.is_open_univ _
102+
lemma is_open_univ : is_open (univ : set α) := topological_space.is_open_univ
101103

102104
lemma is_open.inter (h₁ : is_open s₁) (h₂ : is_open s₂) : is_open (s₁ ∩ s₂) :=
103-
topological_space.is_open_inter _ s₁ s₂ h₁ h₂
105+
topological_space.is_open_inter s₁ s₂ h₁ h₂
104106

105107
lemma is_open_sUnion {s : set (set α)} (h : ∀t ∈ s, is_open t) : is_open (⋃₀ s) :=
106-
topological_space.is_open_sUnion _ s h
108+
topological_space.is_open_sUnion s h
107109

108110
end
109111

110112
lemma topological_space_eq_iff {t t' : topological_space α} :
111-
t = t' ↔ ∀ s, @is_open α t s ↔ @is_open α t' s :=
113+
t = t' ↔ ∀ s, is_open[t] s ↔ is_open[t'] s :=
112114
⟨λ h s, h ▸ iff.rfl, λ h, by { ext, exact h _ }⟩
113115

114-
lemma is_open_fold {s : set α} {t : topological_space α} : t.is_open s = @is_open α t s :=
116+
lemma is_open_fold {s : set α} {t : topological_space α} : t.is_open s = is_open[t] s :=
115117
rfl
116118

117119
variables [topological_space α]
@@ -165,6 +167,8 @@ is_open.inter
165167
class is_closed (s : set α) : Prop :=
166168
(is_open_compl : is_open sᶜ)
167169

170+
localized "notation (name := is_closed_of) `is_closed[` t `]` := @is_closed hole! t" in topology
171+
168172
@[simp] lemma is_open_compl_iff {s : set α} : is_open sᶜ ↔ is_closed s :=
169173
⟨λ h, ⟨h⟩, λ h, h.is_open_compl⟩
170174

src/topology/category/CompHaus/basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ lemma mono_iff_injective {X Y : CompHaus.{u}} (f : X ⟶ Y) : mono f ↔ functio
235235
begin
236236
split,
237237
{ introsI hf x₁ x₂ h,
238-
let g₁ : of punit ⟶ X := ⟨λ _, x₁, continuous_of_discrete_topology⟩,
239-
let g₂ : of punit ⟶ X := ⟨λ _, x₂, continuous_of_discrete_topology⟩,
238+
let g₁ : of punit ⟶ X := ⟨λ _, x₁, continuous_const⟩,
239+
let g₂ : of punit ⟶ X := ⟨λ _, x₂, continuous_const⟩,
240240
have : g₁ ≫ f = g₂ ≫ f, by { ext, exact h },
241241
rw cancel_mono at this,
242242
apply_fun (λ e, e punit.star) at this,

0 commit comments

Comments
 (0)