@@ -3,14 +3,14 @@ Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
3
3
Released under Apache 2.0 license as described in the file LICENSE.
4
4
Metric spaces.
5
5
6
- Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro
6
+ Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
7
7
8
8
Many definitions and theorems expected on metric spaces are already introduced on uniform spaces and
9
9
topological spaces. For example:
10
10
open and closed sets, compactness, completeness, continuity and uniform continuity
11
11
-/
12
12
import data.real.nnreal analysis.topology.topological_structures
13
- open lattice set filter classical
13
+ open lattice set filter classical topological_space
14
14
noncomputable theory
15
15
16
16
universes u v w
@@ -160,6 +160,9 @@ def closed_ball (x : α) (ε : ℝ) := {y | dist y x ≤ ε}
160
160
161
161
@[simp] theorem mem_closed_ball : y ∈ closed_ball x ε ↔ dist y x ≤ ε := iff.rfl
162
162
163
+ theorem ball_subset_closed_ball : ball x ε ⊆ closed_ball x ε :=
164
+ assume y, by simp; intros h; apply le_of_lt h
165
+
163
166
theorem pos_of_mem_ball (hy : y ∈ ball x ε) : ε > 0 :=
164
167
lt_of_le_of_lt dist_nonneg hy
165
168
@@ -450,6 +453,26 @@ by rw [← nhds_comap_dist a, tendsto_comap_iff]
450
453
theorem is_closed_ball : is_closed (closed_ball x ε) :=
451
454
is_closed_le (continuous_dist continuous_id continuous_const) continuous_const
452
455
456
+ /-- ε-characterization of the closure in metric spaces-/
457
+ theorem mem_closure_iff' {α : Type u} [metric_space α] {s : set α} {a : α} :
458
+ a ∈ closure s ↔ ∀ε>0 , ∃b ∈ s, dist a b < ε :=
459
+ ⟨begin
460
+ intros ha ε hε,
461
+ have A : ball a ε ∩ s ≠ ∅ := mem_closure_iff.1 ha _ is_open_ball (mem_ball_self hε),
462
+ cases ne_empty_iff_exists_mem.1 A with b hb,
463
+ simp,
464
+ exact ⟨b, ⟨hb.2 , by have B := hb.1 ; simpa [mem_ball'] using B⟩⟩
465
+ end ,
466
+ begin
467
+ intros H,
468
+ apply mem_closure_iff.2 ,
469
+ intros o ho ao,
470
+ rcases is_open_metric.1 ho a ao with ⟨ε, ⟨εpos, hε⟩⟩,
471
+ rcases H ε εpos with ⟨b, ⟨bs, bdist⟩⟩,
472
+ have B : b ∈ o ∩ s := ⟨hε (by simpa [dist_comm]), bs⟩,
473
+ apply ne_empty_of_mem B
474
+ end ⟩
475
+
453
476
section pi
454
477
open finset lattice
455
478
variables {π : β → Type *} [fintype β] [∀b, metric_space (π b)]
@@ -480,6 +503,206 @@ instance metric_space_pi : metric_space (Πb, π b) :=
480
503
481
504
end pi
482
505
506
+ section second_countable
507
+
508
+ /-- A separable metric space is second countable: one obtains a countable basis by taking
509
+ the balls centered at points in a dense subset, and with rational radii. We do not register
510
+ this as an instance, as there is already an instance going in the other direction
511
+ from second countable spaces to separable spaces, and we want to avoid loops.-/
512
+ lemma second_countable_of_separable_metric_space (α : Type u) [metric_space α] [separable_space α] :
513
+ second_countable_topology α :=
514
+ let ⟨S, ⟨S_countable, S_dense⟩⟩ := separable_space.exists_countable_closure_eq_univ α in
515
+ ⟨⟨⋃x ∈ S, ⋃ (n : nat), {ball x (n⁻¹)},
516
+ ⟨show countable ⋃x ∈ S, ⋃ (n : nat), {ball x (n⁻¹)},
517
+ begin
518
+ apply countable_bUnion S_countable,
519
+ intros a aS,
520
+ apply countable_Union,
521
+ simp
522
+ end ,
523
+ show uniform_space.to_topological_space α = generate_from (⋃x ∈ S, ⋃ (n : nat), {ball x (n⁻¹)}),
524
+ begin
525
+ have A : ∀ (u : set α), (u ∈ ⋃x ∈ S, ⋃ (n : nat), ({ball x ((n : ℝ)⁻¹)} : set (set α))) → is_open u :=
526
+ begin
527
+ simp,
528
+ intros u x hx i u_ball,
529
+ rw [u_ball],
530
+ apply is_open_ball
531
+ end ,
532
+ have B : is_topological_basis (⋃x ∈ S, ⋃ (n : nat), ({ball x (n⁻¹)} : set (set α))) :=
533
+ begin
534
+ apply is_topological_basis_of_open_of_nhds A,
535
+ intros a u au open_u,
536
+ rcases is_open_metric.1 open_u a au with ⟨ε, εpos, εball⟩,
537
+ have : ε / 2 > 0 := half_pos εpos,
538
+ /- The ball `ball a ε` is included in `u`. We need to find one of our balls `ball x (n⁻¹)`
539
+ containing `a` and contained in `ball a ε`. For this, we take `n` larger than `2/ε`, and
540
+ then `x` in `S` at distance at most `n⁻¹` of `a`-/
541
+ rcases exists_nat_gt (ε/2 )⁻¹ with ⟨n, εn⟩,
542
+ have : (n : ℝ) > 0 := lt_trans (inv_pos ‹ε/2 > 0 ›) εn,
543
+ have : 0 < (n : ℝ)⁻¹ := inv_pos this ,
544
+ have : (n : ℝ)⁻¹ < ε/2 := (inv_lt ‹ε/2 > 0 › ‹(n : ℝ) > 0 ›).1 εn,
545
+ have : (a : α) ∈ closure (S : set α) := by rw [S_dense]; simp,
546
+ rcases mem_closure_iff'.1 this _ ‹0 < (n : ℝ)⁻¹› with ⟨x, xS, xdist⟩,
547
+ have : a ∈ ball x (n⁻¹) := by simpa,
548
+ have : ball x (n⁻¹) ⊆ ball a ε :=
549
+ begin
550
+ intros y,
551
+ simp,
552
+ intros ydist,
553
+ calc dist y a = dist a y : dist_comm _ _
554
+ ... ≤ dist a x + dist y x : dist_triangle_right _ _ _
555
+ ... < n⁻¹ + n⁻¹ : add_lt_add xdist ydist
556
+ ... < ε/2 + ε/2 : add_lt_add ‹(n : ℝ)⁻¹ < ε/2 › ‹(n : ℝ)⁻¹ < ε/2 ›
557
+ ... = ε : add_halves _,
558
+ end ,
559
+ have : ball x (n⁻¹) ⊆ u := subset.trans this εball,
560
+ existsi ball x (↑n)⁻¹,
561
+ simp,
562
+ exact ⟨⟨x, ⟨xS, ⟨n, rfl⟩⟩⟩, ⟨by assumption, by assumption⟩⟩,
563
+ end ,
564
+ exact B.2 .2 ,
565
+ end ⟩⟩⟩
566
+
567
+ end second_countable
568
+
569
+ section compact
570
+
571
+ /--Any compact set in a metric space can be covered by finitely many balls of a given positive
572
+ radius-/
573
+ lemma finite_cover_balls_of_compact {α : Type u} [metric_space α] {s : set α}
574
+ (hs : compact s) {e : ℝ} (he : e > 0 ) :
575
+ ∃t ⊆ s, (finite t ∧ s ⊆ (⋃x∈t, ball x e)) :=
576
+ begin
577
+ apply compact_elim_finite_subcover_image hs,
578
+ { simp [is_open_ball] },
579
+ { intros x xs,
580
+ simp,
581
+ exact ⟨x, ⟨xs, by simpa⟩⟩ }
582
+ end
583
+
584
+ /--A compact set in a metric space is separable, i.e., it is the closure of a countable set-/
585
+ lemma countable_closure_of_compact {α : Type u} [metric_space α] {s : set α} (hs : compact s) :
586
+ ∃ t ⊆ s, (countable t ∧ s = closure t) :=
587
+ begin
588
+ have A : ∀ (e:ℝ), e > 0 → ∃ t ⊆ s, (finite t ∧ s ⊆ (⋃x∈t, ball x e)) :=
589
+ assume e, finite_cover_balls_of_compact hs,
590
+ have B : ∀ (e:ℝ), ∃ t ⊆ s, finite t ∧ (e > 0 → s ⊆ (⋃x∈t, ball x e)) :=
591
+ begin
592
+ intro e,
593
+ cases le_or_gt e 0 with h,
594
+ { exact ⟨∅, by finish⟩ },
595
+ { rcases A e h with ⟨s, ⟨finite_s, closure_s⟩⟩, existsi s, finish }
596
+ end ,
597
+ /-The desired countable set is obtained by taking for each `n` the centers of a finite cover
598
+ by balls of radius `1/n`, and then the union over `n`.-/
599
+ choose T T_in_s finite_T using B,
600
+ let t := ⋃n, T (n : ℕ)⁻¹,
601
+ have T₁ : t ⊆ s := begin apply Union_subset, assume n, apply T_in_s end ,
602
+ have T₂ : countable t := by finish [countable_Union, countable_finite],
603
+ have T₃ : s ⊆ closure t :=
604
+ begin
605
+ intros x x_in_s,
606
+ apply mem_closure_iff'.2 ,
607
+ intros ε εpos,
608
+ rcases exists_nat_gt ε⁻¹ with ⟨n, εn⟩,
609
+ have : (n : ℝ) > 0 := lt_trans (inv_pos εpos) εn,
610
+ have inv_n_pos : 0 < (n : ℝ)⁻¹ := inv_pos this ,
611
+ have C : x ∈ (⋃y∈ T (↑n)⁻¹, ball y (↑n)⁻¹) := mem_of_mem_of_subset x_in_s ((finite_T (↑n)⁻¹).2 inv_n_pos),
612
+ rcases mem_Union.1 C with ⟨y, _, ⟨y_in_T, rfl⟩, x_w⟩,
613
+ simp at x_w,
614
+ have : y ∈ t := mem_of_mem_of_subset y_in_T (by apply subset_Union (λ (n:ℕ), T (n : ℝ)⁻¹)),
615
+ have : dist x y < ε := lt_trans x_w ((inv_lt εpos ‹(n : ℝ) > 0 ›).1 εn),
616
+ exact ⟨y, ‹y ∈ t›, ‹dist x y < ε›⟩
617
+ end ,
618
+ have T₄ : closure t ⊆ s :=
619
+ calc closure t ⊆ closure s : closure_mono T₁
620
+ ... = s : closure_eq_of_is_closed (closed_of_compact _ hs),
621
+ exact ⟨t, ⟨T₁, T₂, subset.antisymm T₃ T₄⟩⟩
622
+ end
623
+
624
+ end compact
625
+
626
+ section proper_space
627
+
628
+ /--A metric space is proper if all closed balls are compact.-/
629
+ class proper_space (α : Type u) [metric_space α] : Prop :=
630
+ (compact_ball : ∀x:α, ∀r, compact (closed_ball x r))
631
+
632
+ /-A compact metric space is proper-/
633
+ instance proper_of_compact_metric_space [metric_space α] [compact_space α] : proper_space α :=
634
+ ⟨assume x r, compact_of_is_closed_subset compact_univ is_closed_ball (subset_univ _)⟩
635
+
636
+ /--A proper space is locally compact-/
637
+ instance locally_compact_of_proper_metric_space [metric_space α] [proper_space α] :
638
+ locally_compact_space α :=
639
+ begin
640
+ apply locally_compact_of_compact_nhds,
641
+ intros x,
642
+ existsi closed_ball x 1 ,
643
+ split,
644
+ { apply mem_nhds_iff_metric.2 ,
645
+ existsi (1 : ℝ),
646
+ simp,
647
+ exact ⟨zero_lt_one, ball_subset_closed_ball⟩ },
648
+ { apply proper_space.compact_ball }
649
+ end
650
+
651
+ /--A proper space is complete-/
652
+ instance complete_of_proper {α : Type u} [metric_space α] [proper_space α] : complete_space α :=
653
+ ⟨begin
654
+ intros f hf,
655
+ /-We want to show that the Cauchy filter `f` is converging. It suffices to find a closed
656
+ ball (therefore compact by properness) where it is nontrivial.-/
657
+ have A : ∃ t ∈ f.sets, ∀ x y ∈ t, dist x y < 1 := (cauchy_of_metric.1 hf).2 1 (by norm_num),
658
+ rcases A with ⟨t, ⟨t_fset, ht⟩⟩,
659
+ rcases inhabited_of_mem_sets hf.1 t_fset with ⟨x, xt⟩,
660
+ have : t ⊆ closed_ball x 1 := by intros y yt; simp [dist_comm]; apply le_of_lt (ht x y xt yt),
661
+ have : closed_ball x 1 ∈ f.sets := f.sets_of_superset t_fset this ,
662
+ exact complete_of_compact_set hf this (proper_space.compact_ball _ _),
663
+ end ⟩
664
+
665
+ /--A proper metric space is separable, and therefore second countable. Indeed, any ball is
666
+ compact, and therefore admits a countable dense subset. Taking a countable union over the balls
667
+ centered at a fixed point and with integer radius, one obtains a countable set which is
668
+ dense in the whole space.-/
669
+ instance second_countable_of_proper_metric_space [metric_space α] [proper_space α] :
670
+ second_countable_topology α :=
671
+ begin
672
+ /-We show that the space admits a countable dense subset. The case where the space is empty
673
+ is special, and trivial.-/
674
+ have A : (univ : set α) = ∅ → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
675
+ assume H, ⟨∅, ⟨by simp, by simp; exact H.symm⟩⟩,
676
+ have B : (univ : set α) ≠ ∅ → ∃(s : set α), countable s ∧ closure s = (univ : set α) :=
677
+ begin
678
+ /-When the space is not empty, we take a point `x` in the space, and then a countable set
679
+ `T r` which is dense in the closed ball `closed_ball x r` for each `r`. Then the set
680
+ `t = ⋃ T n` (where the union is over all integers `n`) is countable, as a countable union
681
+ of countable sets, and dense in the space by construction.-/
682
+ assume non_empty,
683
+ rcases ne_empty_iff_exists_mem.1 non_empty with ⟨x, x_univ⟩,
684
+ choose T a using show ∀ (r:ℝ), ∃ t ⊆ closed_ball x r, (countable (t : set α) ∧ closed_ball x r = closure t),
685
+ from assume r, countable_closure_of_compact (proper_space.compact_ball _ _),
686
+ let t := (⋃n:ℕ, T (n : ℝ)),
687
+ have T₁ : countable t := by finish [countable_Union],
688
+ have T₂ : closure t ⊆ univ := by simp,
689
+ have T₃ : univ ⊆ closure t :=
690
+ begin
691
+ intros y y_univ,
692
+ rcases exists_nat_gt (dist y x) with ⟨n, n_large⟩,
693
+ have h : y ∈ closed_ball x (n : ℝ) := by simp; apply le_of_lt n_large,
694
+ have h' : closed_ball x (n : ℝ) = closure (T (n : ℝ)) := by finish,
695
+ have : y ∈ closure (T (n : ℝ)) := by rwa h' at h,
696
+ show y ∈ closure t, from mem_of_mem_of_subset this (by apply closure_mono; apply subset_Union (λ(n:ℕ), T (n:ℝ))),
697
+ end ,
698
+ exact ⟨t, ⟨T₁, subset.antisymm T₂ T₃⟩⟩
699
+ end ,
700
+ haveI : separable_space α := ⟨by_cases A B⟩,
701
+ apply second_countable_of_separable_metric_space,
702
+ end
703
+
704
+ end proper_space
705
+
483
706
lemma lebesgue_number_lemma_of_metric
484
707
{s : set α} {ι} {c : ι → set α} (hs : compact s)
485
708
(hc₁ : ∀ i, is_open (c i)) (hc₂ : s ⊆ ⋃ i, c i) :
0 commit comments