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

Commit a04c7e2

Browse files
sgouezeldigama0
authored andcommitted
feat(analysis/topology): miscellaneous topology (#484)
* miscellaneous topology * C is a proper metric space * Sum of metric spaces is a def instead of instance * refactor(analysis): shorten/simplify proofs
1 parent 3eb7424 commit a04c7e2

14 files changed

+653
-134
lines changed

analysis/complex.lean

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Author: Mario Carneiro
55
66
Topology of the complex numbers.
77
-/
8-
import data.complex.basic analysis.metric_space
8+
import data.complex.basic analysis.metric_space analysis.real
99

1010
noncomputable theory
1111
open filter
@@ -121,4 +121,24 @@ instance : topological_ring ℂ :=
121121

122122
instance : topological_semiring ℂ := by apply_instance
123123

124-
end complex
124+
def real_prod_homeo : homeomorph ℂ (ℝ × ℝ) :=
125+
{ to_equiv := real_prod_equiv,
126+
continuous_to_fun := continuous.prod_mk continuous_re continuous_im,
127+
continuous_inv_fun := show continuous (λ p : ℝ × ℝ, complex.mk p.1 p.2),
128+
by simp only [mk_eq_add_mul_I]; exact
129+
continuous_add
130+
(continuous_fst.comp continuous_of_real)
131+
(continuous_mul (continuous_snd.comp continuous_of_real) continuous_const) }
132+
133+
instance : proper_space ℂ :=
134+
⟨λx r, begin
135+
refine real_prod_homeo.symm.compact_preimage.1
136+
(compact_of_is_closed_subset
137+
(compact_prod _ _ (proper_space.compact_ball x.re r) (proper_space.compact_ball x.im r))
138+
(continuous_iff_is_closed.1 real_prod_homeo.symm.continuous _ is_closed_ball) _),
139+
exact λ p h, ⟨
140+
le_trans (abs_re_le_abs (⟨p.1, p.2⟩ - x)) h,
141+
le_trans (abs_im_le_abs (⟨p.1, p.2⟩ - x)) h⟩
142+
end
143+
144+
end complex

analysis/metric_space.lean

Lines changed: 121 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ instance emetric_space_of_metric_space [a : metric_space α] : emetric_space α
489489
uniformity_edist := uniformity_edist,
490490
..a }
491491

492+
section real
493+
492494
/-- Instantiate the reals as a metric space. -/
493495
instance : metric_space ℝ :=
494496
{ dist := λx y, abs (x - y),
@@ -517,6 +519,12 @@ orderable_topology_of_nhds_abs $ λ x, begin
517519
exact mem_infi_sets _ (mem_infi_sets ε0 (mem_principal_sets.2 ss)) },
518520
end
519521

522+
lemma closed_ball_Icc {x r : ℝ} : closed_ball x r = Icc (x-r) (x+r) :=
523+
by ext y; rw [mem_closed_ball, dist_comm, real.dist_eq,
524+
abs_sub_le_iff, mem_Icc, ← sub_le_iff_le_add', sub_le]
525+
526+
end real
527+
520528
def metric_space.replace_uniformity {α} [U : uniform_space α] (m : metric_space α)
521529
(H : @uniformity _ U = @uniformity _ (metric_space.to_uniform_space α)) :
522530
metric_space α :=
@@ -557,6 +565,8 @@ metric_space.induced subtype.val (λ x y, subtype.eq) t
557565
theorem subtype.dist_eq {p : α → Prop} [t : metric_space α] (x y : subtype p) :
558566
dist x y = dist x.1 y.1 := rfl
559567

568+
section prod
569+
560570
instance prod.metric_space_max [metric_space β] : metric_space (α × β) :=
561571
{ dist := λ x y, max (dist x.1 y.1) (dist x.2 y.2),
562572
dist_self := λ x, by simp,
@@ -585,6 +595,99 @@ instance prod.metric_space_max [metric_space β] : metric_space (α × β) :=
585595
end,
586596
to_uniform_space := prod.uniform_space }
587597

598+
lemma prod.dist_eq [metric_space β] {x y : α × β} :
599+
dist x y = max (dist x.1 y.1) (dist x.2 y.2) := rfl
600+
601+
end prod
602+
603+
section sum
604+
variables [metric_space β] [inhabited α] [inhabited β]
605+
open sum (inl inr)
606+
607+
/--Distance on a disjoint union. There are many (noncanonical) ways to put a distance compatible with each factor.
608+
If the two spaces are bounded, one can say for instance that each point in the first is at distance
609+
`diam α + diam β + 1` of each point in the second.
610+
Instead, we choose a construction that works for unbounded spaces, but requires basepoints.
611+
We embed isometrically each factor, set the basepoints at distance 1,
612+
arbitrarily, and say that the distance from `a` to `b` is the sum of the distances of `a` and `b` to
613+
their respective basepoints, plus the distance 1 between the basepoints.
614+
Since there is an arbitrary choice in this construction, it is not an instance by default-/
615+
private def sum.dist : α ⊕ β → α ⊕ β → ℝ
616+
| (inl a) (inl a') := dist a a'
617+
| (inr b) (inr b') := dist b b'
618+
| (inl a) (inr b) := dist a (default α) + 1 + dist (default β) b
619+
| (inr b) (inl a) := dist b (default β) + 1 + dist (default α) a
620+
621+
private lemma sum.dist_comm (x y : α ⊕ β) : sum.dist x y = sum.dist y x :=
622+
by cases x; cases y; simp only [sum.dist, dist_comm, add_comm, add_left_comm]
623+
624+
lemma sum.one_dist_le {x : α} {y : β} : 1 ≤ sum.dist (inl x) (inr y) :=
625+
le_trans (le_add_of_nonneg_right dist_nonneg) $
626+
add_le_add_right (le_add_of_nonneg_left dist_nonneg) _
627+
628+
lemma sum.one_dist_le' {x : α} {y : β} : 1 ≤ sum.dist (inr y) (inl x) :=
629+
by rw sum.dist_comm; exact sum.one_dist_le
630+
631+
private lemma sum.dist_triangle : ∀ x y z : α ⊕ β, sum.dist x z ≤ sum.dist x y + sum.dist y z
632+
| (inl x) (inl y) (inl z) := dist_triangle _ _ _
633+
| (inl x) (inl y) (inr z) := by unfold sum.dist; rw [← add_assoc, ← add_assoc];
634+
exact add_le_add_right (add_le_add_right (dist_triangle _ _ _) _) _
635+
| (inl x) (inr y) (inl z) := by unfold sum.dist; rw [add_assoc _ (1:ℝ), add_assoc];
636+
refine le_trans (dist_triangle _ _ _) (add_le_add_left _ _);
637+
refine le_trans (le_add_of_nonneg_left (add_nonneg zero_le_one dist_nonneg)) (add_le_add_left _ _);
638+
exact le_add_of_nonneg_left (add_nonneg dist_nonneg zero_le_one)
639+
| (inr x) (inl y) (inl z) := by unfold sum.dist; rw [add_assoc _ _ (dist y z)];
640+
exact add_le_add_left (dist_triangle _ _ _) _
641+
| (inr x) (inr y) (inl z) := by unfold sum.dist; rw [← add_assoc, ← add_assoc];
642+
exact add_le_add_right (add_le_add_right (dist_triangle _ _ _) _) _
643+
| (inr x) (inl y) (inr z) := by unfold sum.dist; rw [add_assoc _ (1:ℝ), add_assoc];
644+
refine le_trans (dist_triangle _ _ _) (add_le_add_left _ _);
645+
refine le_trans (le_add_of_nonneg_left (add_nonneg zero_le_one dist_nonneg)) (add_le_add_left _ _);
646+
exact le_add_of_nonneg_left (add_nonneg dist_nonneg zero_le_one)
647+
| (inl x) (inr y) (inr z) := by unfold sum.dist; rw [add_assoc _ _ (dist y z)];
648+
exact add_le_add_left (dist_triangle _ _ _) _
649+
| (inr x) (inr y) (inr z) := dist_triangle _ _ _
650+
651+
private lemma sum.eq_of_dist_eq_zero : ∀ x y : α ⊕ β, sum.dist x y = 0 → x = y
652+
| (inl x) (inl y) h := by simp only [sum.dist] at h ⊢; exact eq_of_dist_eq_zero h
653+
| (inl x) (inr y) h :=
654+
(ne_of_gt (lt_of_lt_of_le zero_lt_one sum.one_dist_le) h).elim
655+
| (inr x) (inl y) h :=
656+
(ne_of_gt (lt_of_lt_of_le zero_lt_one sum.one_dist_le') h).elim
657+
| (inr x) (inr y) h := by simp only [sum.dist] at h ⊢; exact eq_of_dist_eq_zero h
658+
659+
private lemma sum.mem_uniformity (s : set ((α ⊕ β) × (α ⊕ β))) :
660+
s ∈ (@uniformity (α ⊕ β) _).sets ↔ ∃ ε > 0, ∀ a b, sum.dist a b < ε → (a, b) ∈ s :=
661+
begin
662+
split,
663+
{ rintro ⟨hsα, hsβ⟩,
664+
rcases mem_uniformity_dist.1 hsα with ⟨εα, εα0, hα⟩,
665+
rcases mem_uniformity_dist.1 hsβ with ⟨εβ, εβ0, hβ⟩,
666+
refine ⟨min (min εα εβ) 1, lt_min (lt_min εα0 εβ0) zero_lt_one, _⟩,
667+
rintro (a|a) (b|b) h,
668+
{ exact hα (lt_of_lt_of_le h (le_trans (min_le_left _ _) (min_le_left _ _))) },
669+
{ cases not_le_of_lt (lt_of_lt_of_le h (min_le_right _ _)) sum.one_dist_le },
670+
{ cases not_le_of_lt (lt_of_lt_of_le h (min_le_right _ _)) sum.one_dist_le' },
671+
{ exact hβ (lt_of_lt_of_le h (le_trans (min_le_left _ _) (min_le_right _ _))) } },
672+
{ rintro ⟨ε, ε0, H⟩,
673+
split; rw [filter.mem_map, mem_uniformity_dist];
674+
exact ⟨ε, ε0, λ x y h, H _ _ (by exact h)⟩ }
675+
end
676+
677+
/-- The distance on the disjoint union indeed defines a metric space. All the distance properties follow from our
678+
choice of the distance. The harder work is to show that the uniform structure defined by the distance coincides
679+
with the disjoint union uniform structure. -/
680+
def metric_space_sum : metric_space (α ⊕ β) :=
681+
{ dist := sum.dist,
682+
dist_self := λx, by cases x; simp only [sum.dist, dist_self],
683+
dist_comm := sum.dist_comm,
684+
dist_triangle := sum.dist_triangle,
685+
eq_of_dist_eq_zero := sum.eq_of_dist_eq_zero,
686+
to_uniform_space := sum.uniform_space,
687+
uniformity_dist := uniformity_dist_of_mem_uniformity _ _ sum.mem_uniformity }
688+
689+
end sum
690+
588691
theorem uniform_continuous_dist' : uniform_continuous (λp:α×α, dist p.1 p.2) :=
589692
uniform_continuous_of_metric.2 (λ ε ε0, ⟨ε/2, half_pos ε0,
590693
begin
@@ -784,8 +887,8 @@ end second_countable
784887

785888
section compact
786889

787-
/--Any compact set in a metric space can be covered by finitely many balls of a given positive
788-
radius-/
890+
/-- Any compact set in a metric space can be covered by finitely many balls of a given positive
891+
radius -/
789892
lemma finite_cover_balls_of_compact {α : Type u} [metric_space α] {s : set α}
790893
(hs : compact s) {e : ℝ} (he : e > 0) :
791894
∃t ⊆ s, (finite t ∧ s ⊆ (⋃x∈t, ball x e)) :=
@@ -797,7 +900,7 @@ begin
797900
exact ⟨x, ⟨xs, by simpa⟩⟩ }
798901
end
799902

800-
/--A compact set in a metric space is separable, i.e., it is the closure of a countable set-/
903+
/-- A compact set in a metric space is separable, i.e., it is the closure of a countable set -/
801904
lemma countable_closure_of_compact {α : Type u} [metric_space α] {s : set α} (hs : compact s) :
802905
∃ t ⊆ s, (countable t ∧ s = closure t) :=
803906
begin
@@ -810,8 +913,8 @@ begin
810913
{ exact ⟨∅, by finish⟩ },
811914
{ rcases A e h with ⟨s, ⟨finite_s, closure_s⟩⟩, existsi s, finish }
812915
end,
813-
/-The desired countable set is obtained by taking for each `n` the centers of a finite cover
814-
by balls of radius `1/n`, and then the union over `n`.-/
916+
/- The desired countable set is obtained by taking for each `n` the centers of a finite cover
917+
by balls of radius `1/n`, and then the union over `n`. -/
815918
choose T T_in_s finite_T using B,
816919
let t := ⋃n, T (n : ℕ)⁻¹,
817920
have T₁ : t ⊆ s := begin apply Union_subset, assume n, apply T_in_s end,
@@ -841,16 +944,16 @@ end compact
841944

842945
section proper_space
843946

844-
/--A metric space is proper if all closed balls are compact.-/
947+
/-- A metric space is proper if all closed balls are compact. -/
845948
class proper_space (α : Type u) [metric_space α] : Prop :=
846949
(compact_ball : ∀x:α, ∀r, compact (closed_ball x r))
847950

848-
/-A compact metric space is proper-/
849-
instance proper_of_compact_metric_space [metric_space α] [compact_space α] : proper_space α :=
951+
/- A compact metric space is proper -/
952+
instance proper_of_compact [metric_space α] [compact_space α] : proper_space α :=
850953
⟨assume x r, compact_of_is_closed_subset compact_univ is_closed_ball (subset_univ _)⟩
851954

852-
/--A proper space is locally compact-/
853-
instance locally_compact_of_proper_metric_space [metric_space α] [proper_space α] :
955+
/-- A proper space is locally compact -/
956+
instance locally_compact_of_proper [metric_space α] [proper_space α] :
854957
locally_compact_space α :=
855958
begin
856959
apply locally_compact_of_compact_nhds,
@@ -864,7 +967,7 @@ begin
864967
{ apply proper_space.compact_ball }
865968
end
866969

867-
/--A proper space is complete-/
970+
/-- A proper space is complete -/
868971
instance complete_of_proper {α : Type u} [metric_space α] [proper_space α] : complete_space α :=
869972
begin
870973
intros f hf,
@@ -878,23 +981,23 @@ instance complete_of_proper {α : Type u} [metric_space α] [proper_space α] :
878981
exact complete_of_compact_set hf this (proper_space.compact_ball _ _),
879982
end
880983

881-
/--A proper metric space is separable, and therefore second countable. Indeed, any ball is
984+
/-- A proper metric space is separable, and therefore second countable. Indeed, any ball is
882985
compact, and therefore admits a countable dense subset. Taking a countable union over the balls
883986
centered at a fixed point and with integer radius, one obtains a countable set which is
884-
dense in the whole space.-/
885-
instance second_countable_of_proper_metric_space [metric_space α] [proper_space α] :
987+
dense in the whole space. -/
988+
instance second_countable_of_proper [metric_space α] [proper_space α] :
886989
second_countable_topology α :=
887990
begin
888-
/-We show that the space admits a countable dense subset. The case where the space is empty
889-
is special, and trivial.-/
991+
/- We show that the space admits a countable dense subset. The case where the space is empty
992+
is special, and trivial. -/
890993
have A : (univ : set α) = ∅ → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
891994
assume H, ⟨∅, ⟨by simp, by simp; exact H.symm⟩⟩,
892995
have B : (univ : set α) ≠ ∅ → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
893996
begin
894-
/-When the space is not empty, we take a point `x` in the space, and then a countable set
997+
/- When the space is not empty, we take a point `x` in the space, and then a countable set
895998
`T r` which is dense in the closed ball `closed_ball x r` for each `r`. Then the set
896999
`t = ⋃ T n` (where the union is over all integers `n`) is countable, as a countable union
897-
of countable sets, and dense in the space by construction.-/
1000+
of countable sets, and dense in the space by construction. -/
8981001
assume non_empty,
8991002
rcases ne_empty_iff_exists_mem.1 non_empty with ⟨x, x_univ⟩,
9001003
choose T a using show ∀ (r:ℝ), ∃ t ⊆ closed_ball x r, (countable (t : set α) ∧ closed_ball x r = closure t),

analysis/real.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ compact_of_totally_bounded_is_closed
319319
(real.totally_bounded_Icc a b)
320320
(is_closed_inter (is_closed_ge' a) (is_closed_le' b))
321321

322+
instance : proper_space ℝ :=
323+
{ compact_ball := λx r, by rw closed_ball_Icc; apply compact_Icc }
324+
322325
open real
323326

324327
lemma real.intermediate_value {f : ℝ → ℝ} {a b t : ℝ}

0 commit comments

Comments
 (0)