|
| 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