@@ -489,6 +489,8 @@ instance emetric_space_of_metric_space [a : metric_space α] : emetric_space α
489
489
uniformity_edist := uniformity_edist,
490
490
..a }
491
491
492
+ section real
493
+
492
494
/-- Instantiate the reals as a metric space. -/
493
495
instance : metric_space ℝ :=
494
496
{ dist := λx y, abs (x - y),
@@ -517,6 +519,12 @@ orderable_topology_of_nhds_abs $ λ x, begin
517
519
exact mem_infi_sets _ (mem_infi_sets ε0 (mem_principal_sets.2 ss)) },
518
520
end
519
521
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
+
520
528
def metric_space.replace_uniformity {α} [U : uniform_space α] (m : metric_space α)
521
529
(H : @uniformity _ U = @uniformity _ (metric_space.to_uniform_space α)) :
522
530
metric_space α :=
@@ -557,6 +565,8 @@ metric_space.induced subtype.val (λ x y, subtype.eq) t
557
565
theorem subtype.dist_eq {p : α → Prop } [t : metric_space α] (x y : subtype p) :
558
566
dist x y = dist x.1 y.1 := rfl
559
567
568
+ section prod
569
+
560
570
instance prod.metric_space_max [metric_space β] : metric_space (α × β) :=
561
571
{ dist := λ x y, max (dist x.1 y.1 ) (dist x.2 y.2 ),
562
572
dist_self := λ x, by simp,
@@ -585,6 +595,99 @@ instance prod.metric_space_max [metric_space β] : metric_space (α × β) :=
585
595
end ,
586
596
to_uniform_space := prod.uniform_space }
587
597
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
+
588
691
theorem uniform_continuous_dist' : uniform_continuous (λp:α×α, dist p.1 p.2 ) :=
589
692
uniform_continuous_of_metric.2 (λ ε ε0 , ⟨ε/2 , half_pos ε0 ,
590
693
begin
@@ -784,8 +887,8 @@ end second_countable
784
887
785
888
section compact
786
889
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 -/
789
892
lemma finite_cover_balls_of_compact {α : Type u} [metric_space α] {s : set α}
790
893
(hs : compact s) {e : ℝ} (he : e > 0 ) :
791
894
∃t ⊆ s, (finite t ∧ s ⊆ (⋃x∈t, ball x e)) :=
@@ -797,7 +900,7 @@ begin
797
900
exact ⟨x, ⟨xs, by simpa⟩⟩ }
798
901
end
799
902
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 -/
801
904
lemma countable_closure_of_compact {α : Type u} [metric_space α] {s : set α} (hs : compact s) :
802
905
∃ t ⊆ s, (countable t ∧ s = closure t) :=
803
906
begin
@@ -810,8 +913,8 @@ begin
810
913
{ exact ⟨∅, by finish⟩ },
811
914
{ rcases A e h with ⟨s, ⟨finite_s, closure_s⟩⟩, existsi s, finish }
812
915
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`. -/
815
918
choose T T_in_s finite_T using B,
816
919
let t := ⋃n, T (n : ℕ)⁻¹,
817
920
have T₁ : t ⊆ s := begin apply Union_subset, assume n, apply T_in_s end ,
@@ -841,16 +944,16 @@ end compact
841
944
842
945
section proper_space
843
946
844
- /--A metric space is proper if all closed balls are compact.-/
947
+ /-- A metric space is proper if all closed balls are compact. -/
845
948
class proper_space (α : Type u) [metric_space α] : Prop :=
846
949
(compact_ball : ∀x:α, ∀r, compact (closed_ball x r))
847
950
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 α :=
850
953
⟨assume x r, compact_of_is_closed_subset compact_univ is_closed_ball (subset_univ _)⟩
851
954
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 α] :
854
957
locally_compact_space α :=
855
958
begin
856
959
apply locally_compact_of_compact_nhds,
@@ -864,7 +967,7 @@ begin
864
967
{ apply proper_space.compact_ball }
865
968
end
866
969
867
- /--A proper space is complete-/
970
+ /-- A proper space is complete -/
868
971
instance complete_of_proper {α : Type u} [metric_space α] [proper_space α] : complete_space α :=
869
972
⟨begin
870
973
intros f hf,
@@ -878,23 +981,23 @@ instance complete_of_proper {α : Type u} [metric_space α] [proper_space α] :
878
981
exact complete_of_compact_set hf this (proper_space.compact_ball _ _),
879
982
end ⟩
880
983
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
882
985
compact, and therefore admits a countable dense subset. Taking a countable union over the balls
883
986
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 α] :
886
989
second_countable_topology α :=
887
990
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. -/
890
993
have A : (univ : set α) = ∅ → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
891
994
assume H, ⟨∅, ⟨by simp, by simp; exact H.symm⟩⟩,
892
995
have B : (univ : set α) ≠ ∅ → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
893
996
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
895
998
`T r` which is dense in the closed ball `closed_ball x r` for each `r`. Then the set
896
999
`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. -/
898
1001
assume non_empty,
899
1002
rcases ne_empty_iff_exists_mem.1 non_empty with ⟨x, x_univ⟩,
900
1003
choose T a using show ∀ (r:ℝ), ∃ t ⊆ closed_ball x r, (countable (t : set α) ∧ closed_ball x r = closure t),
0 commit comments