Skip to content

Commit 94a6006

Browse files
committed
feat: port Topology.Instances.Nat (#2616)
1 parent 7eadacc commit 94a6006

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ import Mathlib.Topology.Hom.Open
12851285
import Mathlib.Topology.Homeomorph
12861286
import Mathlib.Topology.Inseparable
12871287
import Mathlib.Topology.Instances.Int
1288+
import Mathlib.Topology.Instances.Nat
12881289
import Mathlib.Topology.Instances.Sign
12891290
import Mathlib.Topology.IsLocallyHomeomorph
12901291
import Mathlib.Topology.List
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
! This file was ported from Lean 3 source module topology.instances.nat
7+
! leanprover-community/mathlib commit 620af85adf5cd4282f962eb060e6e562e3e0c0ba
8+
! Please do not edit these lines, except to modify the commit id
9+
! if you have ported upstream changes.
10+
-/
11+
import Mathlib.Topology.Instances.Int
12+
13+
/-!
14+
# Topology on the natural numbers
15+
16+
The structure of a metric space on `ℕ` is introduced in this file, induced from `ℝ`.
17+
-/
18+
19+
noncomputable section
20+
21+
open Metric Set Filter
22+
23+
namespace Nat
24+
25+
noncomputable instance : Dist ℕ :=
26+
fun x y => dist (x : ℝ) y⟩
27+
28+
theorem dist_eq (x y : ℕ) : dist x y = |(x : ℝ) - y| := rfl
29+
#align nat.dist_eq Nat.dist_eq
30+
31+
theorem dist_coe_int (x y : ℕ) : dist (x : ℤ) (y : ℤ) = dist x y := rfl
32+
#align nat.dist_coe_int Nat.dist_coe_int
33+
34+
@[norm_cast, simp]
35+
theorem dist_cast_real (x y : ℕ) : dist (x : ℝ) y = dist x y := rfl
36+
#align nat.dist_cast_real Nat.dist_cast_real
37+
38+
theorem pairwise_one_le_dist : Pairwise fun m n : ℕ => 1 ≤ dist m n := fun m n hne =>
39+
Int.pairwise_one_le_dist <| by exact_mod_cast hne
40+
#align nat.pairwise_one_le_dist Nat.pairwise_one_le_dist
41+
42+
theorem uniformEmbedding_coe_real : UniformEmbedding ((↑) : ℕ → ℝ) :=
43+
uniformEmbedding_bot_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist
44+
#align nat.uniform_embedding_coe_real Nat.uniformEmbedding_coe_real
45+
46+
theorem closedEmbedding_coe_real : ClosedEmbedding ((↑) : ℕ → ℝ) :=
47+
closedEmbedding_of_pairwise_le_dist zero_lt_one pairwise_one_le_dist
48+
#align nat.closed_embedding_coe_real Nat.closedEmbedding_coe_real
49+
50+
instance : MetricSpace ℕ := Nat.uniformEmbedding_coe_real.comapMetricSpace _
51+
52+
theorem preimage_ball (x : ℕ) (r : ℝ) : (↑) ⁻¹' ball (x : ℝ) r = ball x r := rfl
53+
#align nat.preimage_ball Nat.preimage_ball
54+
55+
theorem preimage_closedBall (x : ℕ) (r : ℝ) : (↑) ⁻¹' closedBall (x : ℝ) r = closedBall x r := rfl
56+
#align nat.preimage_closed_ball Nat.preimage_closedBall
57+
58+
theorem closedBall_eq_Icc (x : ℕ) (r : ℝ) : closedBall x r = Icc ⌈↑x - r⌉₊ ⌊↑x + r⌋₊ := by
59+
rcases le_or_lt 0 r with (hr | hr)
60+
· rw [← preimage_closedBall, Real.closedBall_eq_Icc, preimage_Icc]
61+
exact add_nonneg (cast_nonneg x) hr
62+
· rw [closedBall_eq_empty.2 hr, Icc_eq_empty_of_lt]
63+
calc ⌊(x : ℝ) + r⌋₊ ≤ ⌊(x : ℝ)⌋₊ := floor_mono <| by linarith
64+
_ < ⌈↑x - r⌉₊ := by
65+
rw [floor_coe, Nat.lt_ceil]
66+
linarith
67+
#align nat.closed_ball_eq_Icc Nat.closedBall_eq_Icc
68+
69+
instance : ProperSpace ℕ :=
70+
fun x r => by
71+
rw [closedBall_eq_Icc]
72+
exact (Set.finite_Icc _ _).isCompact⟩
73+
74+
instance : NoncompactSpace ℕ :=
75+
noncompactSpace_of_neBot <| by simp [Filter.atTop_neBot]
76+
77+
end Nat
78+

0 commit comments

Comments
 (0)