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

Commit 620af85

Browse files
committed
refactor(topology/instances): put , , and in separate files (#12207)
The goal here is to make `metric_space ℕ` and `metric_space ℤ` available earlier, so that I can state `has_bounded_smul ℕ A` somewhere reasonable. No lemmas have been added, deleted, or changed here - they've just been moved out of `topology/instances/real` and into `topology/instances/{nat,int,rat,real}`. The resulting import structure is: * `rat_lemmas` → `rat` * `rat` → {`real`, `int`, `nat`} * `real` → {`int`} * `nat` → {`int`}
1 parent eae6ae3 commit 620af85

7 files changed

Lines changed: 236 additions & 187 deletions

File tree

src/analysis/normed_space/basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import analysis.normed.group.infinite_sum
99
import data.matrix.basic
1010
import topology.algebra.module.basic
1111
import topology.instances.ennreal
12+
import topology.instances.rat
1213
import topology.sequences
1314

1415
/-!

src/topology/instances/int.lean

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/-
2+
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Johannes Hölzl, Mario Carneiro
5+
-/
6+
import topology.metric_space.basic
7+
import order.filter.archimedean
8+
/-!
9+
# Topology on the integers
10+
11+
The structure of a metric space on `ℤ` is introduced in this file, induced from `ℝ`.
12+
-/
13+
noncomputable theory
14+
open metric set filter
15+
16+
namespace int
17+
18+
instance : has_dist ℤ := ⟨λ x y, dist (x : ℝ) y⟩
19+
20+
theorem dist_eq (x y : ℤ) : dist x y = |x - y| := rfl
21+
22+
@[norm_cast, simp] theorem dist_cast_real (x y : ℤ) : dist (x : ℝ) y = dist x y := rfl
23+
24+
lemma pairwise_one_le_dist : pairwise (λ m n : ℤ, 1 ≤ dist m n) :=
25+
begin
26+
intros m n hne,
27+
rw dist_eq, norm_cast, rwa [← zero_add (1 : ℤ), int.add_one_le_iff, abs_pos, sub_ne_zero]
28+
end
29+
30+
lemma uniform_embedding_coe_real : uniform_embedding (coe : ℤ → ℝ) :=
31+
uniform_embedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist
32+
33+
lemma closed_embedding_coe_real : closed_embedding (coe : ℤ → ℝ) :=
34+
closed_embedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist
35+
36+
instance : metric_space ℤ := int.uniform_embedding_coe_real.comap_metric_space _
37+
38+
theorem preimage_ball (x : ℤ) (r : ℝ) : coe ⁻¹' (ball (x : ℝ) r) = ball x r := rfl
39+
40+
theorem preimage_closed_ball (x : ℤ) (r : ℝ) :
41+
coe ⁻¹' (closed_ball (x : ℝ) r) = closed_ball x r := rfl
42+
43+
theorem ball_eq_Ioo (x : ℤ) (r : ℝ) : ball x r = Ioo ⌊↑x - r⌋ ⌈↑x + r⌉ :=
44+
by rw [← preimage_ball, real.ball_eq_Ioo, preimage_Ioo]
45+
46+
theorem closed_ball_eq_Icc (x : ℤ) (r : ℝ) : closed_ball x r = Icc ⌈↑x - r⌉ ⌊↑x + r⌋ :=
47+
by rw [← preimage_closed_ball, real.closed_ball_eq_Icc, preimage_Icc]
48+
49+
instance : proper_space ℤ :=
50+
begin
51+
intros x r,
52+
rw closed_ball_eq_Icc,
53+
exact (set.finite_Icc _ _).is_compact,
54+
end
55+
56+
@[simp] lemma cocompact_eq : cocompact ℤ = at_bot ⊔ at_top :=
57+
by simp only [← comap_dist_right_at_top_eq_cocompact (0 : ℤ), dist_eq, sub_zero, cast_zero,
58+
← cast_abs, ← @comap_comap _ _ _ _ abs, int.comap_coe_at_top, comap_abs_at_top]
59+
60+
@[simp] lemma cofinite_eq : (cofinite : filter ℤ) = at_bot ⊔ at_top :=
61+
by rw [← cocompact_eq_cofinite, cocompact_eq]
62+
63+
end int

src/topology/instances/nat.lean

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/-
2+
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Johannes Hölzl, Mario Carneiro
5+
-/
6+
import topology.instances.int
7+
/-!
8+
# Topology on the natural numbers
9+
10+
The structure of a metric space on `ℕ` is introduced in this file, induced from `ℝ`.
11+
-/
12+
noncomputable theory
13+
open metric set filter
14+
15+
namespace nat
16+
17+
noncomputable instance : has_dist ℕ := ⟨λ x y, dist (x : ℝ) y⟩
18+
19+
theorem dist_eq (x y : ℕ) : dist x y = |x - y| := rfl
20+
21+
lemma dist_coe_int (x y : ℕ) : dist (x : ℤ) (y : ℤ) = dist x y := rfl
22+
23+
@[norm_cast, simp] theorem dist_cast_real (x y : ℕ) : dist (x : ℝ) y = dist x y := rfl
24+
25+
lemma pairwise_one_le_dist : pairwise (λ m n : ℕ, 1 ≤ dist m n) :=
26+
begin
27+
intros m n hne,
28+
rw ← dist_coe_int,
29+
apply int.pairwise_one_le_dist,
30+
exact_mod_cast hne
31+
end
32+
33+
lemma uniform_embedding_coe_real : uniform_embedding (coe : ℕ → ℝ) :=
34+
uniform_embedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist
35+
36+
lemma closed_embedding_coe_real : closed_embedding (coe : ℕ → ℝ) :=
37+
closed_embedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist
38+
39+
instance : metric_space ℕ := nat.uniform_embedding_coe_real.comap_metric_space _
40+
41+
theorem preimage_ball (x : ℕ) (r : ℝ) : coe ⁻¹' (ball (x : ℝ) r) = ball x r := rfl
42+
43+
theorem preimage_closed_ball (x : ℕ) (r : ℝ) :
44+
coe ⁻¹' (closed_ball (x : ℝ) r) = closed_ball x r := rfl
45+
46+
theorem closed_ball_eq_Icc (x : ℕ) (r : ℝ) :
47+
closed_ball x r = Icc ⌈↑x - r⌉₊ ⌊↑x + r⌋₊ :=
48+
begin
49+
rcases le_or_lt 0 r with hr|hr,
50+
{ rw [← preimage_closed_ball, real.closed_ball_eq_Icc, preimage_Icc],
51+
exact add_nonneg (cast_nonneg x) hr },
52+
{ rw closed_ball_eq_empty.2 hr,
53+
apply (Icc_eq_empty _).symm,
54+
rw not_le,
55+
calc ⌊(x : ℝ) + r⌋₊ ≤ ⌊(x : ℝ)⌋₊ : by { apply floor_mono, linarith }
56+
... < ⌈↑x - r⌉₊ : by { rw [floor_coe, nat.lt_ceil], linarith } }
57+
end
58+
59+
instance : proper_space ℕ :=
60+
begin
61+
intros x r,
62+
rw closed_ball_eq_Icc,
63+
exact (set.finite_Icc _ _).is_compact,
64+
end
65+
66+
instance : noncompact_space ℕ :=
67+
noncompact_space_of_ne_bot $ by simp [filter.at_top_ne_bot]
68+
69+
end nat

src/topology/instances/rat.lean

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/-
2+
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Johannes Hölzl, Mario Carneiro
5+
-/
6+
import topology.metric_space.basic
7+
import topology.instances.int
8+
import topology.instances.nat
9+
import topology.instances.real
10+
/-!
11+
# Topology on the ratonal numbers
12+
13+
The structure of a metric space on `ℚ` is introduced in this file, induced from `ℝ`.
14+
-/
15+
noncomputable theory
16+
open metric set filter
17+
18+
namespace rat
19+
20+
instance : metric_space ℚ :=
21+
metric_space.induced coe rat.cast_injective real.metric_space
22+
23+
theorem dist_eq (x y : ℚ) : dist x y = |x - y| := rfl
24+
25+
@[norm_cast, simp] lemma dist_cast (x y : ℚ) : dist (x : ℝ) y = dist x y := rfl
26+
27+
theorem uniform_continuous_coe_real : uniform_continuous (coe : ℚ → ℝ) :=
28+
uniform_continuous_comap
29+
30+
theorem uniform_embedding_coe_real : uniform_embedding (coe : ℚ → ℝ) :=
31+
uniform_embedding_comap rat.cast_injective
32+
33+
theorem dense_embedding_coe_real : dense_embedding (coe : ℚ → ℝ) :=
34+
uniform_embedding_coe_real.dense_embedding $
35+
λ x, mem_closure_iff_nhds.2 $ λ t ht,
36+
let ⟨ε,ε0, hε⟩ := metric.mem_nhds_iff.1 ht in
37+
let ⟨q, h⟩ := exists_rat_near x ε0 in
38+
⟨_, hε (mem_ball'.2 h), q, rfl⟩
39+
40+
theorem embedding_coe_real : embedding (coe : ℚ → ℝ) := dense_embedding_coe_real.to_embedding
41+
42+
theorem continuous_coe_real : continuous (coe : ℚ → ℝ) := uniform_continuous_coe_real.continuous
43+
44+
end rat
45+
46+
@[norm_cast, simp] theorem nat.dist_cast_rat (x y : ℕ) : dist (x : ℚ) y = dist x y :=
47+
by rw [← nat.dist_cast_real, ← rat.dist_cast]; congr' 1; norm_cast
48+
49+
lemma nat.uniform_embedding_coe_rat : uniform_embedding (coe : ℕ → ℚ) :=
50+
uniform_embedding_bot_of_pairwise_le_dist zero_lt_one $ by simpa using nat.pairwise_one_le_dist
51+
52+
lemma nat.closed_embedding_coe_rat : closed_embedding (coe : ℕ → ℚ) :=
53+
closed_embedding_of_pairwise_le_dist zero_lt_one $ by simpa using nat.pairwise_one_le_dist
54+
55+
@[norm_cast, simp] theorem int.dist_cast_rat (x y : ℤ) : dist (x : ℚ) y = dist x y :=
56+
by rw [← int.dist_cast_real, ← rat.dist_cast]; congr' 1; norm_cast
57+
58+
lemma int.uniform_embedding_coe_rat : uniform_embedding (coe : ℤ → ℚ) :=
59+
uniform_embedding_bot_of_pairwise_le_dist zero_lt_one $ by simpa using int.pairwise_one_le_dist
60+
61+
lemma int.closed_embedding_coe_rat : closed_embedding (coe : ℤ → ℚ) :=
62+
closed_embedding_of_pairwise_le_dist zero_lt_one $ by simpa using int.pairwise_one_le_dist
63+
64+
instance : noncompact_space ℚ := int.closed_embedding_coe_rat.noncompact_space
65+
66+
-- TODO(Mario): Find a way to use rat_add_continuous_lemma
67+
theorem rat.uniform_continuous_add : uniform_continuous (λp : ℚ × ℚ, p.1 + p.2) :=
68+
rat.uniform_embedding_coe_real.to_uniform_inducing.uniform_continuous_iff.2 $
69+
by simp only [(∘), rat.cast_add]; exact real.uniform_continuous_add.comp
70+
(rat.uniform_continuous_coe_real.prod_map rat.uniform_continuous_coe_real)
71+
72+
theorem rat.uniform_continuous_neg : uniform_continuous (@has_neg.neg ℚ _) :=
73+
metric.uniform_continuous_iff.2 $ λ ε ε0, ⟨_, ε0, λ a b h,
74+
by rw dist_comm at h; simpa [rat.dist_eq] using h⟩
75+
76+
instance : uniform_add_group ℚ :=
77+
uniform_add_group.mk' rat.uniform_continuous_add rat.uniform_continuous_neg
78+
79+
instance : topological_add_group ℚ := by apply_instance
80+
81+
instance : order_topology ℚ :=
82+
induced_order_topology _ (λ x y, rat.cast_lt) (@exists_rat_btwn _ _ _)
83+
84+
lemma rat.uniform_continuous_abs : uniform_continuous (abs : ℚ → ℚ) :=
85+
metric.uniform_continuous_iff.2 $ λ ε ε0,
86+
⟨ε, ε0, λ a b h, lt_of_le_of_lt
87+
(by simpa [rat.dist_eq] using abs_abs_sub_abs_le_abs_sub _ _) h⟩
88+
89+
lemma rat.continuous_mul : continuous (λp : ℚ × ℚ, p.1 * p.2) :=
90+
rat.embedding_coe_real.continuous_iff.2 $ by simp [(∘)]; exact
91+
real.continuous_mul.comp ((rat.continuous_coe_real.prod_map rat.continuous_coe_real))
92+
93+
instance : topological_ring ℚ :=
94+
{ continuous_mul := rat.continuous_mul, ..rat.topological_add_group }
95+
96+
lemma rat.totally_bounded_Icc (a b : ℚ) : totally_bounded (Icc a b) :=
97+
begin
98+
have := totally_bounded_preimage rat.uniform_embedding_coe_real (totally_bounded_Icc a b),
99+
rwa (set.ext (λ q, _) : Icc _ _ = _), simp
100+
end

0 commit comments

Comments
 (0)