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

Commit aeda3fb

Browse files
committed
feat(topology/instances/real, topology/metric_space/basic, algebra/floor): integers are a proper space (#6437)
The metric space `ℤ` is a proper space. Also, under the coercion from `ℤ` to `ℝ`, inverse images of compact sets are finite. The key point for both facts is to express the inverse image of an `ℝ`-interval under the coercion as an appropriate `ℤ`-interval, using floor or ceiling of the endpoints -- I provide these facts as simp-lemmas. Indirectly related discussion: https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there.20code.20for.20X.3F/topic/Finiteness.20of.20balls.20in.20the.20integers
1 parent ff5fa52 commit aeda3fb

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

src/algebra/floor.lean

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import tactic.linarith
77
import tactic.abel
88
import algebra.ordered_group
99
import data.set.intervals.basic
10+
1011
/-!
1112
# Floor and Ceil
1213
@@ -289,3 +290,35 @@ lt_of_le_of_lt (le_nat_ceil x) (by exact_mod_cast h)
289290

290291
lemma le_of_nat_ceil_le {x : α} {n : ℕ} (h : nat_ceil x ≤ n) : x ≤ n :=
291292
le_trans (le_nat_ceil x) (by exact_mod_cast h)
293+
294+
namespace int
295+
296+
@[simp] lemma preimage_Ioo {x y : α} :
297+
((coe : ℤ → α) ⁻¹' (set.Ioo x y)) = set.Ioo (floor x) (ceil y) :=
298+
by { ext, simp [floor_lt, lt_ceil] }
299+
300+
@[simp] lemma preimage_Ico {x y : α} :
301+
((coe : ℤ → α) ⁻¹' (set.Ico x y)) = set.Ico (ceil x) (ceil y) :=
302+
by { ext, simp [ceil_le, lt_ceil] }
303+
304+
@[simp] lemma preimage_Ioc {x y : α} :
305+
((coe : ℤ → α) ⁻¹' (set.Ioc x y)) = set.Ioc (floor x) (floor y) :=
306+
by { ext, simp [floor_lt, le_floor] }
307+
308+
@[simp] lemma preimage_Icc {x y : α} :
309+
((coe : ℤ → α) ⁻¹' (set.Icc x y)) = set.Icc (ceil x) (floor y) :=
310+
by { ext, simp [ceil_le, le_floor] }
311+
312+
@[simp] lemma preimage_Ioi {x : α} : ((coe : ℤ → α) ⁻¹' (set.Ioi x)) = set.Ioi (floor x) :=
313+
by { ext, simp [floor_lt] }
314+
315+
@[simp] lemma preimage_Ici {x : α} : ((coe : ℤ → α) ⁻¹' (set.Ici x)) = set.Ici (ceil x) :=
316+
by { ext, simp [ceil_le] }
317+
318+
@[simp] lemma preimage_Iio {x : α} : ((coe : ℤ → α) ⁻¹' (set.Iio x)) = set.Iio (ceil x) :=
319+
by { ext, simp [lt_ceil] }
320+
321+
@[simp] lemma preimage_Iic {x : α} : ((coe : ℤ → α) ⁻¹' (set.Iic x)) = set.Iic (floor x) :=
322+
by { ext, simp [le_floor] }
323+
324+
end int

src/topology/instances/real.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ theorem int.dist_eq (x y : ℤ) : dist x y = abs (x - y) := rfl
5252
@[norm_cast, simp] theorem int.dist_cast_rat (x y : ℤ) : dist (x : ℚ) y = dist x y :=
5353
by rw [← int.dist_cast_real, ← rat.dist_cast]; congr' 1; norm_cast
5454

55+
instance : proper_space ℤ :=
56+
begin
57+
intros x r,
58+
apply set.finite.is_compact,
59+
have : closed_ball x r = coe ⁻¹' (closed_ball (x:ℝ) r) := rfl,
60+
simp [this, closed_ball_Icc, set.Icc_ℤ_finite],
61+
end
62+
5563
theorem uniform_continuous_of_rat : uniform_continuous (coe : ℚ → ℝ) :=
5664
uniform_continuous_comap
5765

src/topology/metric_space/basic.lean

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ topological spaces. For example:
1111
-/
1212
import topology.metric_space.emetric_space
1313
import topology.algebra.ordered
14+
import data.fintype.intervals
1415

1516
open set filter classical topological_space
1617
noncomputable theory
@@ -1700,3 +1701,23 @@ le_trans (diam_mono ball_subset_closed_ball bounded_closed_ball) (diam_closed_ba
17001701
end diam
17011702

17021703
end metric
1704+
1705+
namespace int
1706+
open metric
1707+
1708+
/-- Under the coercion from `ℤ` to `ℝ`, inverse images of compact sets are finite. -/
1709+
lemma tendsto_coe_cofinite : tendsto (coe : ℤ → ℝ) cofinite (cocompact ℝ) :=
1710+
begin
1711+
simp only [filter.has_basis_cocompact.tendsto_right_iff, eventually_iff_exists_mem],
1712+
intros s hs,
1713+
obtain ⟨r, hr⟩ : ∃ r, s ⊆ closed_ball (0:ℝ) r,
1714+
{ rw ← bounded_iff_subset_ball,
1715+
exact hs.bounded },
1716+
refine ⟨(coe ⁻¹' closed_ball (0:ℝ) r)ᶜ, _, _⟩,
1717+
{ simp [mem_cofinite, closed_ball_Icc, set.Icc_ℤ_finite] },
1718+
{ rw ← compl_subset_compl at hr,
1719+
intros y hy,
1720+
exact hr hy }
1721+
end
1722+
1723+
end int

0 commit comments

Comments
 (0)