src/HOL/Analysis/Abstract_Metric_Spaces.thy
author paulson <lp15@cam.ac.uk>
Thu, 17 Apr 2025 22:57:26 +0100
changeset 82522 62afd98e3f3e
parent 80792 1cbdba868710
permissions -rw-r--r--
more tidying
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     1
section \<open>Abstract Metric Spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     2
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     3
theory Abstract_Metric_Spaces
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     4
  imports Elementary_Metric_Spaces Abstract_Limits Abstract_Topological_Spaces
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     5
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     6
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     7
(*Avoid a clash with the existing metric_space locale (from the type class)*)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     8
locale Metric_space =
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
     9
  fixes M :: "'a set" and d :: "'a \<Rightarrow> 'a \<Rightarrow> real"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    10
  assumes nonneg [simp]: "\<And>x y. 0 \<le> d x y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    11
  assumes commute: "\<And>x y. d x y = d y x"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    12
  assumes zero [simp]: "\<And>x y. \<lbrakk>x \<in> M; y \<in> M\<rbrakk> \<Longrightarrow> d x y = 0 \<longleftrightarrow> x=y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    13
  assumes triangle: "\<And>x y z. \<lbrakk>x \<in> M; y \<in> M; z \<in> M\<rbrakk> \<Longrightarrow> d x z \<le> d x y + d y z"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    14
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    15
text \<open>Link with the type class version\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    16
interpretation Met_TC: Metric_space UNIV dist
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    17
  by (simp add: dist_commute dist_triangle Metric_space.intro)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    18
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    19
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    20
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    21
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    22
lemma subspace: "M' \<subseteq> M \<Longrightarrow> Metric_space M' d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    23
  by (simp add: commute in_mono Metric_space.intro triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    24
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    25
lemma abs_mdist [simp] : "\<bar>d x y\<bar> = d x y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    26
  by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    27
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    28
lemma mdist_pos_less: "\<lbrakk>x \<noteq> y; x \<in> M; y \<in> M\<rbrakk> \<Longrightarrow> 0 < d x y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    29
  by (metis less_eq_real_def nonneg zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    30
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    31
lemma mdist_zero [simp]: "x \<in> M \<Longrightarrow> d x x = 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    32
  by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    33
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    34
lemma mdist_pos_eq [simp]: "\<lbrakk>x \<in> M; y \<in> M\<rbrakk> \<Longrightarrow> 0 < d x y \<longleftrightarrow> x \<noteq> y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    35
  using mdist_pos_less zero by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    36
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    37
lemma triangle': "\<lbrakk>x \<in> M; y \<in> M; z \<in> M\<rbrakk> \<Longrightarrow> d x z \<le> d x y + d z y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    38
  by (simp add: commute triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    39
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    40
lemma triangle'': "\<lbrakk>x \<in> M; y \<in> M; z \<in> M\<rbrakk> \<Longrightarrow> d x z \<le> d y x + d y z"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    41
  by (simp add: commute triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    42
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    43
lemma mdist_reverse_triangle: "\<lbrakk>x \<in> M; y \<in> M; z \<in> M\<rbrakk> \<Longrightarrow> \<bar>d x y - d y z\<bar> \<le> d x z"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    44
  by (smt (verit) commute triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    45
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    46
text\<open> Open and closed balls                                                                \<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    47
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    48
definition mball where "mball x r \<equiv> {y. x \<in> M \<and> y \<in> M \<and> d x y < r}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    49
definition mcball where "mcball x r \<equiv> {y. x \<in> M \<and> y \<in> M \<and> d x y \<le> r}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    50
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    51
lemma in_mball [simp]: "y \<in> mball x r \<longleftrightarrow> x \<in> M \<and> y \<in> M \<and> d x y < r"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
    52
  by (simp add: mball_def)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    53
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    54
lemma centre_in_mball_iff [iff]: "x \<in> mball x r \<longleftrightarrow> x \<in> M \<and> 0 < r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    55
  using in_mball mdist_zero by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    56
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    57
lemma mball_subset_mspace: "mball x r \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    58
  by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    59
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    60
lemma mball_eq_empty: "mball x r = {} \<longleftrightarrow> (x \<notin> M) \<or> r \<le> 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    61
  by (smt (verit, best) Collect_empty_eq centre_in_mball_iff mball_def nonneg)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    62
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    63
lemma mball_subset: "\<lbrakk>d x y + a \<le> b; y \<in> M\<rbrakk> \<Longrightarrow> mball x a \<subseteq> mball y b"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    64
  by (smt (verit) commute in_mball subsetI triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    65
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    66
lemma disjoint_mball: "r + r' \<le> d x x' \<Longrightarrow> disjnt (mball x r) (mball x' r')"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    67
  by (smt (verit) commute disjnt_iff in_mball triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    68
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    69
lemma mball_subset_concentric: "r \<le> s \<Longrightarrow> mball x r \<subseteq> mball x s"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    70
  by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    71
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    72
lemma in_mcball [simp]: "y \<in> mcball x r \<longleftrightarrow> x \<in> M \<and> y \<in> M \<and> d x y \<le> r"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
    73
  by (simp add: mcball_def)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    74
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    75
lemma centre_in_mcball_iff [iff]: "x \<in> mcball x r \<longleftrightarrow> x \<in> M \<and> 0 \<le> r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    76
  using mdist_zero by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    77
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    78
lemma mcball_eq_empty: "mcball x r = {} \<longleftrightarrow> (x \<notin> M) \<or> r < 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    79
  by (smt (verit, best) Collect_empty_eq centre_in_mcball_iff empty_iff mcball_def nonneg)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    80
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    81
lemma mcball_subset_mspace: "mcball x r \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    82
  by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    83
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    84
lemma mball_subset_mcball: "mball x r \<subseteq> mcball x r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    85
  by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    86
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    87
lemma mcball_subset: "\<lbrakk>d x y + a \<le> b; y \<in> M\<rbrakk> \<Longrightarrow> mcball x a \<subseteq> mcball y b"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    88
  by (smt (verit) in_mcball mdist_reverse_triangle subsetI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    89
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    90
lemma mcball_subset_concentric: "r \<le> s \<Longrightarrow> mcball x r \<subseteq> mcball x s"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    91
  by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    92
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    93
lemma mcball_subset_mball: "\<lbrakk>d x y + a < b; y \<in> M\<rbrakk> \<Longrightarrow> mcball x a \<subseteq> mball y b"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    94
  by (smt (verit) commute in_mball in_mcball subsetI triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    95
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    96
lemma mcball_subset_mball_concentric: "a < b \<Longrightarrow> mcball x a \<subseteq> mball x b"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    97
  by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    98
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
    99
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   100
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   101
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   102
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   103
subsection \<open>Metric topology                                                           \<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   104
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   105
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   106
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   107
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   108
definition mopen where 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   109
  "mopen U \<equiv> U \<subseteq> M \<and> (\<forall>x. x \<in> U \<longrightarrow> (\<exists>r>0. mball x r \<subseteq> U))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   110
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   111
definition mtopology :: "'a topology" where 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   112
  "mtopology \<equiv> topology mopen"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   113
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   114
lemma is_topology_metric_topology [iff]: "istopology mopen"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   115
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   116
  have "\<And>S T. \<lbrakk>mopen S; mopen T\<rbrakk> \<Longrightarrow> mopen (S \<inter> T)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   117
    by (smt (verit, del_insts) Int_iff in_mball mopen_def subset_eq)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   118
  moreover have "\<And>\<K>. (\<forall>K\<in>\<K>. mopen K) \<longrightarrow> mopen (\<Union>\<K>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   119
    using mopen_def by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   120
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   121
    by (simp add: istopology_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   122
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   123
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   124
lemma openin_mtopology: "openin mtopology U \<longleftrightarrow> U \<subseteq> M \<and> (\<forall>x. x \<in> U \<longrightarrow> (\<exists>r>0. mball x r \<subseteq> U))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   125
  by (simp add: mopen_def mtopology_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   126
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   127
lemma topspace_mtopology [simp]: "topspace mtopology = M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   128
  by (meson order.refl mball_subset_mspace openin_mtopology openin_subset openin_topspace subset_antisym zero_less_one)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   129
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   130
lemma subtopology_mspace [simp]: "subtopology mtopology M = mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   131
  by (metis subtopology_topspace topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   132
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   133
lemma open_in_mspace [iff]: "openin mtopology M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   134
  by (metis openin_topspace topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   135
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   136
lemma closedin_mspace [iff]: "closedin mtopology M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   137
  by (metis closedin_topspace topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   138
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   139
lemma openin_mball [iff]: "openin mtopology (mball x r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   140
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   141
  have "\<And>y. \<lbrakk>x \<in> M; d x y < r\<rbrakk> \<Longrightarrow> \<exists>s>0. mball y s \<subseteq> mball x r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   142
    by (metis add_diff_cancel_left' add_diff_eq commute less_add_same_cancel1 mball_subset order_refl)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   143
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   144
    by (auto simp: openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   145
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   146
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   147
lemma mtopology_base:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   148
   "mtopology = topology(arbitrary union_of (\<lambda>U. \<exists>x \<in> M. \<exists>r>0. U = mball x r))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   149
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   150
  have "\<And>S. \<exists>x r. x \<in> M \<and> 0 < r \<and> S = mball x r \<Longrightarrow> openin mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   151
    using openin_mball by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   152
  moreover have "\<And>U x. \<lbrakk>openin mtopology U; x \<in> U\<rbrakk> \<Longrightarrow> \<exists>B. (\<exists>x r. x \<in> M \<and> 0 < r \<and> B = mball x r) \<and> x \<in> B \<and> B \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   153
    by (metis centre_in_mball_iff in_mono openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   154
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   155
    by (smt (verit) topology_base_unique)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   156
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   157
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   158
lemma closedin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   159
   "closedin mtopology C \<longleftrightarrow> C \<subseteq> M \<and> (\<forall>x. x \<in> M - C \<longrightarrow> (\<exists>r>0. disjnt C (mball x r)))"  (is "?lhs = ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   160
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   161
  show "?lhs \<Longrightarrow> ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   162
    unfolding closedin_def openin_mtopology
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   163
    by (metis Diff_disjoint disjnt_def disjnt_subset2 topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   164
  show "?rhs \<Longrightarrow> ?lhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   165
    unfolding closedin_def openin_mtopology disjnt_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   166
    by (metis Diff_subset Diff_triv Int_Diff Int_commute inf.absorb_iff2 mball_subset_mspace topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   167
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   168
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   169
lemma closedin_mcball [iff]: "closedin mtopology (mcball x r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   170
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   171
  have "\<exists>ra>0. disjnt (mcball x r) (mball y ra)" if "x \<notin> M" for y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   172
    by (metis disjnt_empty1 gt_ex mcball_eq_empty that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   173
  moreover have "disjnt (mcball x r) (mball y (d x y - r))" if "y \<in> M" "d x y > r" for y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   174
    using that disjnt_iff in_mball in_mcball mdist_reverse_triangle by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   175
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   176
    using closedin_metric mcball_subset_mspace by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   177
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   178
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   179
lemma mball_iff_mcball: "(\<exists>r>0. mball x r \<subseteq> U) = (\<exists>r>0. mcball x r \<subseteq> U)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   180
  by (meson dense mball_subset_mcball mcball_subset_mball_concentric order_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   181
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   182
lemma openin_mtopology_mcball:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   183
  "openin mtopology U \<longleftrightarrow> U \<subseteq> M \<and> (\<forall>x. x \<in> U \<longrightarrow> (\<exists>r. 0 < r \<and> mcball x r \<subseteq> U))"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   184
  by (simp add: mball_iff_mcball openin_mtopology)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   185
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   186
lemma metric_derived_set_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   187
  "mtopology derived_set_of S = {x \<in> M. \<forall>r>0. \<exists>y\<in>S. y\<noteq>x \<and> y \<in> mball x r}" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   188
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   189
  show "?lhs \<subseteq> ?rhs"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   190
    unfolding openin_mtopology derived_set_of_def
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   191
    by clarsimp (metis in_mball openin_mball openin_mtopology zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   192
  show "?rhs \<subseteq> ?lhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   193
    unfolding openin_mtopology derived_set_of_def 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   194
    by clarify (metis subsetD topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   195
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   196
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   197
lemma metric_closure_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   198
   "mtopology closure_of S = {x \<in> M. \<forall>r>0. \<exists>y \<in> S. y \<in> mball x r}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   199
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   200
  have "\<And>x r. \<lbrakk>0 < r; x \<in> mtopology closure_of S\<rbrakk> \<Longrightarrow> \<exists>y\<in>S. y \<in> mball x r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   201
    by (metis centre_in_mball_iff in_closure_of openin_mball topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   202
  moreover have "\<And>x T. \<lbrakk>x \<in> M; \<forall>r>0. \<exists>y\<in>S. y \<in> mball x r\<rbrakk> \<Longrightarrow> x \<in> mtopology closure_of S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   203
    by (smt (verit) in_closure_of in_mball openin_mtopology subsetD topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   204
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   205
    by (auto simp: in_closure_of)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   206
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   207
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   208
lemma metric_closure_of_alt:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   209
  "mtopology closure_of S = {x \<in> M. \<forall>r>0. \<exists>y \<in> S. y \<in> mcball x r}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   210
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   211
  have "\<And>x r. \<lbrakk>\<forall>r>0. x \<in> M \<and> (\<exists>y\<in>S. y \<in> mcball x r); 0 < r\<rbrakk> \<Longrightarrow> \<exists>y\<in>S. y \<in> M \<and> d x y < r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   212
    by (meson dense in_mcball le_less_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   213
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   214
    by (fastforce simp: metric_closure_of in_closure_of)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   215
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   216
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   217
lemma metric_interior_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   218
   "mtopology interior_of S = {x \<in> M. \<exists>\<epsilon>>0. mball x \<epsilon> \<subseteq> S}" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   219
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   220
  show "?lhs \<subseteq> ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   221
    using interior_of_maximal_eq openin_mtopology by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   222
  show "?rhs \<subseteq> ?lhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   223
    using interior_of_def openin_mball by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   224
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   225
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   226
lemma metric_interior_of_alt:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   227
   "mtopology interior_of S = {x \<in> M. \<exists>\<epsilon>>0. mcball x \<epsilon> \<subseteq> S}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   228
  by (fastforce simp: mball_iff_mcball metric_interior_of)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   229
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   230
lemma in_interior_of_mball:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   231
   "x \<in> mtopology interior_of S \<longleftrightarrow> x \<in> M \<and> (\<exists>\<epsilon>>0. mball x \<epsilon> \<subseteq> S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   232
  using metric_interior_of by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   233
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   234
lemma in_interior_of_mcball:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   235
   "x \<in> mtopology interior_of S \<longleftrightarrow> x \<in> M \<and> (\<exists>\<epsilon>>0. mcball x \<epsilon> \<subseteq> S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   236
  using metric_interior_of_alt by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   237
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   238
lemma Hausdorff_space_mtopology: "Hausdorff_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   239
  unfolding Hausdorff_space_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   240
proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   241
  fix x y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   242
  assume x: "x \<in> topspace mtopology" and y: "y \<in> topspace mtopology" and "x \<noteq> y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   243
  then have gt0: "d x y / 2 > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   244
    by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   245
  have "disjnt (mball x (d x y / 2)) (mball y (d x y / 2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   246
    by (simp add: disjoint_mball)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   247
  then show "\<exists>U V. openin mtopology U \<and> openin mtopology V \<and> x \<in> U \<and> y \<in> V \<and> disjnt U V"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   248
    by (metis centre_in_mball_iff gt0 openin_mball topspace_mtopology x y)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   249
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   250
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   251
subsection\<open>Bounded sets\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   252
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   253
definition mbounded where "mbounded S \<longleftrightarrow> (\<exists>x B. S \<subseteq> mcball x B)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   254
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   255
lemma mbounded_pos: "mbounded S \<longleftrightarrow> (\<exists>x B. 0 < B \<and> S \<subseteq> mcball x B)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   256
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   257
  have "\<exists>x' r'. 0 < r' \<and> S \<subseteq> mcball x' r'" if "S \<subseteq> mcball x r" for x r
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   258
    by (metis gt_ex less_eq_real_def linorder_not_le mcball_subset_concentric order_trans that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   259
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   260
    by (auto simp: mbounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   261
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   262
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   263
lemma mbounded_alt:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   264
  "mbounded S \<longleftrightarrow> S \<subseteq> M \<and> (\<exists>B. \<forall>x \<in> S. \<forall>y \<in> S. d x y \<le> B)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   265
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   266
  have "\<And>x B. S \<subseteq> mcball x B \<Longrightarrow> \<forall>x\<in>S. \<forall>y\<in>S. d x y \<le> 2 * B"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   267
    by (smt (verit, best) commute in_mcball subsetD triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   268
  then show ?thesis
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   269
    unfolding mbounded_def by (metis in_mcball in_mono subsetI)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   270
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   271
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   272
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   273
lemma mbounded_alt_pos:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   274
  "mbounded S \<longleftrightarrow> S \<subseteq> M \<and> (\<exists>B>0. \<forall>x \<in> S. \<forall>y \<in> S. d x y \<le> B)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   275
  by (smt (verit, del_insts) gt_ex mbounded_alt)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   276
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   277
lemma mbounded_subset: "\<lbrakk>mbounded T; S \<subseteq> T\<rbrakk> \<Longrightarrow> mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   278
  by (meson mbounded_def order_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   279
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   280
lemma mbounded_subset_mspace: "mbounded S \<Longrightarrow> S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   281
  by (simp add: mbounded_alt)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   282
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   283
lemma mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   284
   "mbounded S \<longleftrightarrow> S = {} \<or> (\<forall>x \<in> S. x \<in> M) \<and> (\<exists>y B. y \<in> M \<and> (\<forall>x \<in> S. d y x \<le> B))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   285
  by (meson all_not_in_conv in_mcball mbounded_def subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   286
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   287
lemma mbounded_empty [iff]: "mbounded {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   288
  by (simp add: mbounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   289
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   290
lemma mbounded_mcball: "mbounded (mcball x r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   291
  using mbounded_def by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   292
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   293
lemma mbounded_mball [iff]: "mbounded (mball x r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   294
  by (meson mball_subset_mcball mbounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   295
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   296
lemma mbounded_insert: "mbounded (insert a S) \<longleftrightarrow> a \<in> M \<and> mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   297
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   298
  have "\<And>y B. \<lbrakk>y \<in> M; \<forall>x\<in>S. d y x \<le> B\<rbrakk>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   299
           \<Longrightarrow> \<exists>y. y \<in> M \<and> (\<exists>B \<ge> d y a. \<forall>x\<in>S. d y x \<le> B)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   300
    by (metis order.trans nle_le)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   301
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   302
    by (auto simp: mbounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   303
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   304
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   305
lemma mbounded_Int: "mbounded S \<Longrightarrow> mbounded (S \<inter> T)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   306
  by (meson inf_le1 mbounded_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   307
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   308
lemma mbounded_Un: "mbounded (S \<union> T) \<longleftrightarrow> mbounded S \<and> mbounded T" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   309
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   310
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   311
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   312
  proof (cases "S={} \<or> T={}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   313
    case True then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   314
      using R by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   315
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   316
    case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   317
    obtain x y B C where "S \<subseteq> mcball x B" "T \<subseteq> mcball y C" "B > 0" "C > 0" "x \<in> M" "y \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   318
      using R mbounded_pos
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   319
      by (metis False mcball_eq_empty subset_empty)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   320
    then have "S \<union> T \<subseteq> mcball x (B + C + d x y)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   321
      by (smt (verit) commute dual_order.trans le_supI mcball_subset mdist_pos_eq)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   322
    then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   323
      using mbounded_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   324
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   325
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   326
  show "?lhs \<Longrightarrow> ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   327
    using mbounded_def by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   328
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   329
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   330
lemma mbounded_Union:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   331
  "\<lbrakk>finite \<F>; \<And>X. X \<in> \<F> \<Longrightarrow> mbounded X\<rbrakk> \<Longrightarrow> mbounded (\<Union>\<F>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   332
  by (induction \<F> rule: finite_induct) (auto simp: mbounded_Un)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   333
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   334
lemma mbounded_closure_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   335
   "mbounded S \<Longrightarrow> mbounded (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   336
  by (meson closedin_mcball closure_of_minimal mbounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   337
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   338
lemma mbounded_closure_of_eq:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   339
   "S \<subseteq> M \<Longrightarrow> (mbounded (mtopology closure_of S) \<longleftrightarrow> mbounded S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   340
  by (metis closure_of_subset mbounded_closure_of mbounded_subset topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   341
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   342
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   343
lemma maxdist_thm:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   344
  assumes "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   345
      and "x \<in> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   346
      and "y \<in> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   347
    shows  "d x y = (SUP z\<in>S. \<bar>d x z - d z y\<bar>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   348
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   349
  have "\<bar>d x z - d z y\<bar> \<le> d x y" if "z \<in> S" for z
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   350
    by (metis all_not_in_conv assms mbounded mdist_reverse_triangle that) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   351
  moreover have "d x y \<le> r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   352
    if "\<And>z. z \<in> S \<Longrightarrow> \<bar>d x z - d z y\<bar> \<le> r" for r :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   353
    using that assms mbounded_subset_mspace mdist_zero by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   354
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   355
    by (intro cSup_eq [symmetric]) auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   356
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   357
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   358
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   359
lemma metric_eq_thm: "\<lbrakk>S \<subseteq> M; x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> (x = y) = (\<forall>z\<in>S. d x z = d y z)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   360
  by (metis commute  subset_iff zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   361
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   362
lemma compactin_imp_mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   363
  assumes "compactin mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   364
  shows "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   365
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   366
  have "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   367
    and com: "\<And>\<U>. \<lbrakk>\<forall>U\<in>\<U>. openin mtopology U; S \<subseteq> \<Union>\<U>\<rbrakk> \<Longrightarrow> \<exists>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<and> S \<subseteq> \<Union>\<F>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   368
    using assms by (auto simp: compactin_def mbounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   369
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   370
  proof (cases "S = {}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   371
    case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   372
    with \<open>S \<subseteq> M\<close> obtain a where "a \<in> S" "a \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   373
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   374
    with \<open>S \<subseteq> M\<close> gt_ex have "S \<subseteq> \<Union>(range (mball a))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   375
      by force
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   376
    then obtain \<F> where "finite \<F>" "\<F> \<subseteq> range (mball a)" "S \<subseteq> \<Union>\<F>"
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   377
      by (metis (no_types, opaque_lifting) com imageE openin_mball)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   378
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   379
      using mbounded_Union mbounded_subset by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   380
  qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   381
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   382
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   383
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   384
end (*Metric_space*)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   385
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   386
lemma mcball_eq_cball [simp]: "Met_TC.mcball = cball"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   387
  by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   388
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   389
lemma mball_eq_ball [simp]: "Met_TC.mball = ball"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   390
  by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   391
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   392
lemma mopen_eq_open [simp]: "Met_TC.mopen = open"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   393
  by (force simp: open_contains_ball Met_TC.mopen_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   394
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   395
lemma limitin_iff_tendsto [iff]: "limitin Met_TC.mtopology \<sigma> x F = tendsto \<sigma> x F"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   396
  by (simp add: Met_TC.mtopology_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   397
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   398
lemma mtopology_is_euclidean [simp]: "Met_TC.mtopology = euclidean"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   399
  by (simp add: Met_TC.mtopology_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   400
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   401
lemma mbounded_iff_bounded [iff]: "Met_TC.mbounded A \<longleftrightarrow> bounded A"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   402
  by (metis Met_TC.mbounded UNIV_I all_not_in_conv bounded_def)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   403
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   404
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   405
subsection\<open>Subspace of a metric space\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   406
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   407
locale Submetric = Metric_space + 
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   408
  fixes A
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   409
  assumes subset: "A \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   410
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   411
sublocale Submetric \<subseteq> sub: Metric_space A d
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   412
  by (simp add: subset subspace)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   413
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   414
context Submetric
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   415
begin 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   416
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   417
lemma mball_submetric_eq: "sub.mball a r = (if a \<in> A then A \<inter> mball a r else {})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   418
and mcball_submetric_eq: "sub.mcball a r = (if a \<in> A then A \<inter> mcball a r else {})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   419
  using subset by force+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   420
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   421
lemma mtopology_submetric: "sub.mtopology = subtopology mtopology A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   422
  unfolding topology_eq
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   423
proof (intro allI iffI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   424
  fix S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   425
  assume "openin sub.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   426
  then have "\<exists>T. openin (subtopology mtopology A) T \<and> x \<in> T \<and> T \<subseteq> S" if "x \<in> S" for x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   427
    by (metis mball_submetric_eq openin_mball openin_subtopology_Int2 sub.centre_in_mball_iff sub.openin_mtopology subsetD that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   428
  then show "openin (subtopology mtopology A) S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   429
    by (meson openin_subopen)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   430
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   431
  fix S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   432
  assume "openin (subtopology mtopology A) S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   433
  then obtain T where "openin mtopology T" "S = T \<inter> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   434
    by (meson openin_subtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   435
  then have "mopen T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   436
    by (simp add: mopen_def openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   437
  then have "sub.mopen (T \<inter> A)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   438
    unfolding sub.mopen_def mopen_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   439
    by (metis inf.coboundedI2 mball_submetric_eq Int_iff \<open>S = T \<inter> A\<close> inf.bounded_iff subsetI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   440
  then show "openin sub.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   441
    using \<open>S = T \<inter> A\<close> sub.mopen_def sub.openin_mtopology by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   442
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   443
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   444
lemma mbounded_submetric: "sub.mbounded T \<longleftrightarrow> mbounded T \<and> T \<subseteq> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   445
  by (meson mbounded_alt sub.mbounded_alt subset subset_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   446
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   447
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   448
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   449
lemma (in Metric_space) submetric_empty [iff]: "Submetric M d {}"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   450
proof qed auto
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   451
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   452
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   453
subsection \<open>Abstract type of metric spaces\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   454
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   455
typedef 'a metric = "{(M::'a set,d). Metric_space M d}"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   456
  morphisms "dest_metric" "metric"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   457
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   458
  have "Metric_space {} (\<lambda>x y. 0)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   459
    by (auto simp: Metric_space_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   460
  then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   461
    by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   462
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   463
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   464
definition mspace where "mspace m \<equiv> fst (dest_metric m)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   465
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   466
definition mdist where "mdist m \<equiv> snd (dest_metric m)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   467
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   468
lemma Metric_space_mspace_mdist [iff]: "Metric_space (mspace m) (mdist m)"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   469
  by (metis Product_Type.Collect_case_prodD dest_metric mdist_def mspace_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   470
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   471
lemma mdist_nonneg [simp]: "\<And>x y. 0 \<le> mdist m x y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   472
  by (metis Metric_space_def Metric_space_mspace_mdist)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   473
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   474
lemma mdist_commute: "\<And>x y. mdist m x y = mdist m y x"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   475
  by (metis Metric_space_def Metric_space_mspace_mdist)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   476
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   477
lemma mdist_zero [simp]: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk> \<Longrightarrow> mdist m x y = 0 \<longleftrightarrow> x=y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   478
  by (meson Metric_space.zero Metric_space_mspace_mdist)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   479
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   480
lemma mdist_triangle: "\<And>x y z. \<lbrakk>x \<in> mspace m; y \<in> mspace m; z \<in> mspace m\<rbrakk> \<Longrightarrow> mdist m x z \<le> mdist m x y + mdist m y z"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   481
  by (meson Metric_space.triangle Metric_space_mspace_mdist)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   482
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   483
lemma (in Metric_space) mspace_metric[simp]: 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   484
  "mspace (metric (M,d)) = M"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   485
  by (simp add: metric_inverse mspace_def subspace)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   486
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   487
lemma (in Metric_space) mdist_metric[simp]: 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   488
  "mdist (metric (M,d)) = d"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   489
  by (simp add: mdist_def metric_inverse subspace)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   490
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   491
lemma metric_collapse [simp]: "metric (mspace m, mdist m) = m"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   492
  by (simp add: dest_metric_inverse mdist_def mspace_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   493
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   494
definition mtopology_of :: "'a metric \<Rightarrow> 'a topology"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   495
  where "mtopology_of \<equiv> \<lambda>m. Metric_space.mtopology (mspace m) (mdist m)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   496
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   497
lemma topspace_mtopology_of [simp]: "topspace (mtopology_of m) = mspace m"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   498
  by (simp add: Metric_space.topspace_mtopology Metric_space_mspace_mdist mtopology_of_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   499
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   500
lemma (in Metric_space) mtopology_of [simp]:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   501
  "mtopology_of (metric (M,d)) = mtopology"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   502
  by (simp add: mtopology_of_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   503
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   504
definition "mball_of \<equiv> \<lambda>m. Metric_space.mball (mspace m) (mdist m)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   505
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   506
lemma in_mball_of [simp]: "y \<in> mball_of m x r \<longleftrightarrow> x \<in> mspace m \<and> y \<in> mspace m \<and> mdist m x y < r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   507
  by (simp add: Metric_space.in_mball mball_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   508
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   509
lemma (in Metric_space) mball_of [simp]:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   510
  "mball_of (metric (M,d)) = mball"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   511
  by (simp add: mball_of_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   512
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   513
definition "mcball_of \<equiv> \<lambda>m. Metric_space.mcball (mspace m) (mdist m)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   514
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   515
lemma in_mcball_of [simp]: "y \<in> mcball_of m x r \<longleftrightarrow> x \<in> mspace m \<and> y \<in> mspace m \<and> mdist m x y \<le> r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   516
  by (simp add: Metric_space.in_mcball mcball_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   517
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   518
lemma (in Metric_space) mcball_of [simp]:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   519
  "mcball_of (metric (M,d)) = mcball"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   520
  by (simp add: mcball_of_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   521
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   522
definition "euclidean_metric \<equiv> metric (UNIV,dist)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   523
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   524
lemma mspace_euclidean_metric [simp]: "mspace euclidean_metric = UNIV"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   525
  by (simp add: euclidean_metric_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   526
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   527
lemma mdist_euclidean_metric [simp]: "mdist euclidean_metric = dist"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   528
  by (simp add: euclidean_metric_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   529
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   530
lemma mtopology_of_euclidean [simp]: "mtopology_of euclidean_metric = euclidean"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   531
  by (simp add: Met_TC.mtopology_def mtopology_of_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   532
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   533
text \<open>Allows reference to the current metric space within the locale as a value\<close>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   534
definition (in Metric_space) "Self \<equiv> metric (M,d)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   535
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   536
lemma (in Metric_space) mspace_Self [simp]: "mspace Self = M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   537
  by (simp add: Self_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   538
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   539
lemma (in Metric_space) mdist_Self [simp]: "mdist Self = d"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   540
  by (simp add: Self_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   541
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   542
text\<open> Subspace of a metric space\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   543
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   544
definition submetric where
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   545
  "submetric \<equiv> \<lambda>m S. metric (S \<inter> mspace m, mdist m)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   546
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   547
lemma mspace_submetric [simp]: "mspace (submetric m S) = S \<inter> mspace m" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   548
  unfolding submetric_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   549
  by (meson Metric_space.subspace inf_le2 Metric_space_mspace_mdist Metric_space.mspace_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   550
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   551
lemma mdist_submetric [simp]: "mdist (submetric m S) = mdist m"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   552
  unfolding submetric_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   553
  by (meson Metric_space.subspace inf_le2 Metric_space.mdist_metric Metric_space_mspace_mdist)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   554
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   555
lemma submetric_UNIV [simp]: "submetric m UNIV = m"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   556
  by (simp add: submetric_def dest_metric_inverse mdist_def mspace_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   557
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   558
lemma submetric_submetric [simp]:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   559
   "submetric (submetric m S) T = submetric m (S \<inter> T)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   560
  by (metis submetric_def Int_assoc inf_commute mdist_submetric mspace_submetric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   561
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   562
lemma submetric_mspace [simp]:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   563
   "submetric m (mspace m) = m"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   564
  by (simp add: submetric_def dest_metric_inverse mdist_def mspace_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   565
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   566
lemma submetric_restrict:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   567
   "submetric m S = submetric m (mspace m \<inter> S)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   568
  by (metis submetric_mspace submetric_submetric)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   569
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   570
lemma mtopology_of_submetric: "mtopology_of (submetric m A) = subtopology (mtopology_of m) A"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   571
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   572
  interpret Submetric "mspace m" "mdist m" "A \<inter> mspace m"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   573
    using Metric_space_mspace_mdist Submetric.intro Submetric_axioms.intro inf_le2 by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   574
  have "sub.mtopology = subtopology (mtopology_of m) A"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   575
    by (metis inf_commute mtopology_of_def mtopology_submetric subtopology_mspace subtopology_subtopology)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   576
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   577
    by (simp add: submetric_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   578
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   579
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   580
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   581
subsection\<open>The discrete metric\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   582
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   583
locale discrete_metric =
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   584
  fixes M :: "'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   585
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   586
definition (in discrete_metric) dd :: "'a \<Rightarrow> 'a \<Rightarrow> real"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   587
  where "dd \<equiv> \<lambda>x y::'a. if x=y then 0 else 1"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   588
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   589
lemma metric_M_dd: "Metric_space M discrete_metric.dd"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   590
  by (simp add: discrete_metric.dd_def Metric_space.intro)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   591
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   592
sublocale discrete_metric \<subseteq> disc: Metric_space M dd
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   593
  by (simp add: metric_M_dd)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   594
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   595
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   596
lemma (in discrete_metric) mopen_singleton:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   597
  assumes "x \<in> M" shows "disc.mopen {x}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   598
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   599
  have "disc.mball x (1/2) \<subseteq> {x}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   600
    by (smt (verit) dd_def disc.in_mball less_divide_eq_1_pos singleton_iff subsetI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   601
  with assms show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   602
    using disc.mopen_def half_gt_zero_iff zero_less_one by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   603
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   604
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   605
lemma (in discrete_metric) mtopology_discrete_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   606
   "disc.mtopology = discrete_topology M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   607
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   608
  have "\<And>x. x \<in> M \<Longrightarrow> openin disc.mtopology {x}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   609
    by (simp add: disc.mtopology_def mopen_singleton)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   610
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   611
    by (metis disc.topspace_mtopology discrete_topology_unique)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   612
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   613
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   614
lemma (in discrete_metric) discrete_ultrametric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   615
   "dd x z \<le> max (dd x y) (dd y z)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   616
  by (simp add: dd_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   617
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   618
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   619
lemma (in discrete_metric) dd_le1: "dd x y \<le> 1"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   620
  by (simp add: dd_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   621
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   622
lemma (in discrete_metric) mbounded_discrete_metric: "disc.mbounded S \<longleftrightarrow> S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   623
  by (meson dd_le1 disc.mbounded_alt)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   624
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   625
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   626
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   627
subsection\<open>Metrizable spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   628
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   629
definition metrizable_space where
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   630
  "metrizable_space X \<equiv> \<exists>M d. Metric_space M d \<and> X = Metric_space.mtopology M d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   631
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   632
lemma (in Metric_space) metrizable_space_mtopology: "metrizable_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   633
  using local.Metric_space_axioms metrizable_space_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   634
78258
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   635
lemma (in Metric_space) first_countable_mtopology: "first_countable mtopology"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   636
proof (clarsimp simp add: first_countable_def)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   637
  fix x
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   638
  assume "x \<in> M"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   639
  define \<B> where "\<B> \<equiv> mball x ` {r \<in> \<rat>. 0 < r}"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   640
  show "\<exists>\<B>. countable \<B> \<and> (\<forall>V\<in>\<B>. openin mtopology V) \<and> (\<forall>U. openin mtopology U \<and> x \<in> U \<longrightarrow> (\<exists>V\<in>\<B>. x \<in> V \<and> V \<subseteq> U))"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   641
  proof (intro exI conjI ballI)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   642
    show "countable \<B>"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   643
      by (simp add: \<B>_def countable_rat)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   644
    show "\<forall>U. openin mtopology U \<and> x \<in> U \<longrightarrow> (\<exists>V\<in>\<B>. x \<in> V \<and> V \<subseteq> U)"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   645
    proof clarify
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   646
      fix U
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   647
      assume "openin mtopology U" and "x \<in> U"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   648
      then obtain r where "r>0" and r: "mball x r \<subseteq> U"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   649
        by (meson openin_mtopology)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   650
      then obtain q where "q \<in> Rats" "0 < q" "q < r"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   651
        using Rats_dense_in_real by blast
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   652
      then show "\<exists>V\<in>\<B>. x \<in> V \<and> V \<subseteq> U"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   653
        unfolding \<B>_def using \<open>x \<in> M\<close> r by fastforce
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   654
    qed
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   655
  qed (auto simp: \<B>_def)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   656
qed
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   657
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   658
lemma metrizable_imp_first_countable:
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   659
   "metrizable_space X \<Longrightarrow> first_countable X"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   660
  by (force simp: metrizable_space_def Metric_space.first_countable_mtopology)
78258
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   661
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   662
lemma openin_mtopology_eq_open [simp]: "openin Met_TC.mtopology = open"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   663
  by (simp add: Met_TC.mtopology_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   664
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   665
lemma closedin_mtopology_eq_closed [simp]: "closedin Met_TC.mtopology = closed"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   666
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   667
  have "(euclidean::'a topology) = Met_TC.mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   668
    by (simp add: Met_TC.mtopology_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   669
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   670
    using closed_closedin by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   671
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   672
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   673
lemma compactin_mtopology_eq_compact [simp]: "compactin Met_TC.mtopology = compact"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   674
  by (simp add: compactin_def compact_eq_Heine_Borel fun_eq_iff) meson
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   675
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
   676
lemma metrizable_space_discrete_topology [simp]:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   677
   "metrizable_space(discrete_topology U)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   678
  by (metis discrete_metric.mtopology_discrete_metric metric_M_dd metrizable_space_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   679
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
   680
lemma empty_metrizable_space: "metrizable_space trivial_topology"
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
   681
  by simp
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   682
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   683
lemma metrizable_space_subtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   684
  assumes "metrizable_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   685
  shows "metrizable_space(subtopology X S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   686
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   687
  obtain M d where "Metric_space M d" and X: "X = Metric_space.mtopology M d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   688
    using assms metrizable_space_def by blast
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   689
  then interpret Submetric M d "M \<inter> S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   690
    by (simp add: Submetric.intro Submetric_axioms_def)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   691
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   692
    unfolding metrizable_space_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   693
    by (metis X mtopology_submetric sub.Metric_space_axioms subtopology_restrict topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   694
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   695
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   696
lemma homeomorphic_metrizable_space_aux:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   697
  assumes "X homeomorphic_space Y" "metrizable_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   698
  shows "metrizable_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   699
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   700
  obtain M d where "Metric_space M d" and X: "X = Metric_space.mtopology M d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   701
    using assms by (auto simp: metrizable_space_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   702
  then interpret m: Metric_space M d 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   703
    by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   704
  obtain f g where hmf: "homeomorphic_map X Y f" and hmg: "homeomorphic_map Y X g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   705
    and fg: "(\<forall>x \<in> M. g(f x) = x) \<and> (\<forall>y \<in> topspace Y. f(g y) = y)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   706
    using assms X homeomorphic_maps_map homeomorphic_space_def by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   707
  define d' where "d' x y \<equiv> d (g x) (g y)" for x y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   708
  interpret m': Metric_space "topspace Y" "d'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   709
    unfolding d'_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   710
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   711
    show "(d (g x) (g y) = 0) = (x = y)" if "x \<in> topspace Y" "y \<in> topspace Y" for x y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   712
      by (metis fg X hmg homeomorphic_imp_surjective_map imageI m.topspace_mtopology m.zero that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   713
    show "d (g x) (g z) \<le> d (g x) (g y) + d (g y) (g z)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   714
      if "x \<in> topspace Y" and "y \<in> topspace Y" and "z \<in> topspace Y" for x y z
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   715
      by (metis X that hmg homeomorphic_eq_everything_map imageI m.topspace_mtopology m.triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   716
  qed (auto simp: m.nonneg m.commute)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   717
  have "Y = Metric_space.mtopology (topspace Y) d'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   718
    unfolding topology_eq
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   719
  proof (intro allI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   720
    fix S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   721
    have "openin m'.mtopology S" if S: "S \<subseteq> topspace Y" and "openin X (g ` S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   722
      unfolding m'.openin_mtopology
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   723
    proof (intro conjI that strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   724
      fix y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   725
      assume "y \<in> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   726
      then obtain r where "r>0" and r: "m.mball (g y) r \<subseteq> g ` S" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   727
        using X \<open>openin X (g ` S)\<close> m.openin_mtopology using \<open>y \<in> S\<close> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   728
      then have "g ` m'.mball y r \<subseteq> m.mball (g y) r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   729
        using X d'_def hmg homeomorphic_imp_surjective_map by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   730
      with S fg have "m'.mball y r \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   731
        by (smt (verit, del_insts) image_iff m'.in_mball r subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   732
      then show "\<exists>r>0. m'.mball y r \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   733
        using \<open>0 < r\<close> by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   734
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   735
    moreover have "openin X (g ` S)" if ope': "openin m'.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   736
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   737
      have "\<exists>r>0. m.mball (g y) r \<subseteq> g ` S" if "y \<in> S" for y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   738
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   739
        have y: "y \<in> topspace Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   740
          using m'.openin_mtopology ope' that by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   741
        obtain r where "r > 0" and r: "m'.mball y r \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   742
          using ope' by (meson \<open>y \<in> S\<close> m'.openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   743
        moreover have "\<And>x. \<lbrakk>x \<in> M; d (g y) x < r\<rbrakk> \<Longrightarrow> \<exists>u. u \<in> topspace Y \<and> d' y u < r \<and> x = g u"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   744
          using fg X d'_def hmf homeomorphic_imp_surjective_map by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   745
        ultimately have "m.mball (g y) r \<subseteq> g ` m'.mball y r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   746
          using y by (force simp: m'.openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   747
        then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   748
          using \<open>0 < r\<close> r by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   749
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   750
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   751
        using X hmg homeomorphic_imp_surjective_map m.openin_mtopology ope' openin_subset by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   752
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   753
    ultimately have "(S \<subseteq> topspace Y \<and> openin X (g ` S)) = openin m'.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   754
      using m'.topspace_mtopology openin_subset by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   755
    then show "openin Y S = openin m'.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   756
      by (simp add: m'.mopen_def homeomorphic_map_openness_eq [OF hmg])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   757
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   758
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   759
    using m'.metrizable_space_mtopology by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   760
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   761
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   762
lemma homeomorphic_metrizable_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   763
  assumes "X homeomorphic_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   764
  shows "metrizable_space X \<longleftrightarrow> metrizable_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   765
  using assms homeomorphic_metrizable_space_aux homeomorphic_space_sym by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   766
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   767
lemma metrizable_space_retraction_map_image:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   768
   "retraction_map X Y r \<and> metrizable_space X
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   769
        \<Longrightarrow> metrizable_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   770
  using hereditary_imp_retractive_property metrizable_space_subtopology homeomorphic_metrizable_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   771
  by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   772
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   773
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   774
lemma metrizable_imp_Hausdorff_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   775
   "metrizable_space X \<Longrightarrow> Hausdorff_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   776
  by (metis Metric_space.Hausdorff_space_mtopology metrizable_space_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   777
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   778
(**
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   779
lemma metrizable_imp_kc_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   780
   "metrizable_space X \<Longrightarrow> kc_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   781
oops
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   782
  MESON_TAC[METRIZABLE_IMP_HAUSDORFF_SPACE; HAUSDORFF_IMP_KC_SPACE]);;
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   783
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   784
lemma kc_space_mtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   785
   "kc_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   786
oops
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   787
  REWRITE_TAC[GSYM FORALL_METRIZABLE_SPACE; METRIZABLE_IMP_KC_SPACE]);;
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   788
**)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   789
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   790
lemma metrizable_imp_t1_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   791
   "metrizable_space X \<Longrightarrow> t1_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   792
  by (simp add: Hausdorff_imp_t1_space metrizable_imp_Hausdorff_space)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   793
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   794
lemma closed_imp_gdelta_in:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   795
  assumes X: "metrizable_space X" and S: "closedin X S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   796
  shows "gdelta_in X S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   797
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   798
  obtain M d where "Metric_space M d" and Xeq: "X = Metric_space.mtopology M d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   799
    using X metrizable_space_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   800
  then interpret M: Metric_space M d
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   801
    by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   802
  have "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   803
    using M.closedin_metric \<open>X = M.mtopology\<close> S by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   804
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   805
  proof (cases "S = {}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   806
    case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   807
    then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   808
      by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   809
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   810
    case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   811
    have "\<exists>y\<in>S. d x y < inverse (1 + real n)" if "x \<in> S" for x n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   812
      using \<open>S \<subseteq> M\<close> M.mdist_zero [of x] that by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   813
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   814
    have "x \<in> S" if "x \<in> M" and \<section>: "\<And>n. \<exists>y\<in>S. d x y < inverse(Suc n)" for x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   815
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   816
      have *: "\<exists>y\<in>S. d x y < \<epsilon>" if "\<epsilon> > 0" for \<epsilon>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   817
        by (metis \<section> that not0_implies_Suc order_less_le order_less_le_trans real_arch_inverse)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   818
      have "closedin M.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   819
        using S by (simp add: Xeq)
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   820
      with * \<open>x \<in> M\<close> show ?thesis
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   821
        by (force simp: M.closedin_metric disjnt_iff)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   822
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   823
    ultimately have Seq: "S = \<Inter>(range (\<lambda>n. {x\<in>M. \<exists>y\<in>S. d x y < inverse(Suc n)}))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   824
      using \<open>S \<subseteq> M\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   825
    have "openin M.mtopology {xa \<in> M. \<exists>y\<in>S. d xa y < inverse (1 + real n)}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   826
    proof (clarsimp simp: M.openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   827
      fix x y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   828
      assume "x \<in> M" "y \<in> S" and dxy: "d x y < inverse (1 + real n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   829
      then have "\<And>z. \<lbrakk>z \<in> M; d x z < inverse (1 + real n) - d x y\<rbrakk> \<Longrightarrow> \<exists>y\<in>S. d z y < inverse (1 + real n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   830
        by (smt (verit) M.commute M.triangle \<open>S \<subseteq> M\<close> in_mono)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   831
      with dxy show "\<exists>r>0. M.mball x r \<subseteq> {z \<in> M. \<exists>y\<in>S. d z y < inverse (1 + real n)}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   832
        by (rule_tac x="inverse(Suc n) - d x y" in exI) auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   833
    qed
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   834
    then have "gdelta_in X (\<Inter>(range (\<lambda>n. {x\<in>M. \<exists>y\<in>S. d x y < inverse(Suc n)})))"
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   835
      by (force simp: Xeq intro: gdelta_in_Inter open_imp_gdelta_in)
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   836
    with Seq show ?thesis
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
   837
      by presburger
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   838
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   839
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   840
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   841
lemma open_imp_fsigma_in:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   842
   "\<lbrakk>metrizable_space X; openin X S\<rbrakk> \<Longrightarrow> fsigma_in X S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   843
  by (meson closed_imp_gdelta_in fsigma_in_gdelta_in openin_closedin openin_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   844
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   845
lemma metrizable_space_euclidean:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   846
  "metrizable_space (euclidean :: 'a::metric_space topology)"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   847
  using Met_TC.metrizable_space_mtopology by auto
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   848
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   849
lemma (in Metric_space) regular_space_mtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   850
   "regular_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   851
unfolding regular_space_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   852
proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   853
  fix C a
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   854
  assume C: "closedin mtopology C" and a: "a \<in> topspace mtopology" and "a \<notin> C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   855
  have "openin mtopology (topspace mtopology - C)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   856
    by (simp add: C openin_diff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   857
  then obtain r where "r>0" and r: "mball a r \<subseteq> topspace mtopology - C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   858
    unfolding openin_mtopology using \<open>a \<notin> C\<close> a by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   859
  show "\<exists>U V. openin mtopology U \<and> openin mtopology V \<and> a \<in> U \<and> C \<subseteq> V \<and> disjnt U V"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   860
  proof (intro exI conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   861
    show "a \<in> mball a (r/2)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   862
      using \<open>0 < r\<close> a by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   863
    show "C \<subseteq> topspace mtopology - mcball a (r/2)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   864
      using C \<open>0 < r\<close> r by (fastforce simp: closedin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   865
  qed (auto simp: openin_mball closedin_mcball openin_diff disjnt_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   866
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   867
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   868
lemma metrizable_imp_regular_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   869
   "metrizable_space X \<Longrightarrow> regular_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   870
  by (metis Metric_space.regular_space_mtopology metrizable_space_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   871
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   872
lemma regular_space_euclidean:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   873
 "regular_space (euclidean :: 'a::metric_space topology)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   874
  by (simp add: metrizable_imp_regular_space metrizable_space_euclidean)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   875
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   876
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   877
subsection\<open>Limits at a point in a topological space\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   878
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   879
lemma (in Metric_space) eventually_atin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   880
   "eventually P (atin mtopology a) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   881
        (a \<in> M \<longrightarrow> (\<exists>\<delta>>0. \<forall>x. x \<in> M \<and> 0 < d x a \<and> d x a < \<delta> \<longrightarrow> P x))"  (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   882
proof (cases "a \<in> M")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   883
  case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   884
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   885
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   886
    assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   887
    with True obtain U where "openin mtopology U" "a \<in> U" and U: "\<forall>x\<in>U - {a}. P x"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   888
      by (auto simp: eventually_atin)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   889
    then obtain r where "r>0" and "mball a r \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   890
      by (meson openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   891
    with U show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   892
      by (smt (verit, ccfv_SIG) commute in_mball insert_Diff_single insert_iff subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   893
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   894
    assume ?rhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   895
    then obtain \<delta> where "\<delta>>0" and \<delta>: "\<forall>x. x \<in> M \<and> 0 < d x a \<and> d x a < \<delta> \<longrightarrow> P x"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   896
      using True by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   897
    then have "\<forall>x \<in> mball a \<delta> - {a}. P x"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   898
      by (simp add: commute)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   899
    then show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   900
      unfolding eventually_atin openin_mtopology
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   901
      by (metis True \<open>0 < \<delta>\<close> centre_in_mball_iff openin_mball openin_mtopology) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   902
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   903
qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   904
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   905
subsection \<open>Normal spaces and metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   906
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   907
lemma (in Metric_space) normal_space_mtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   908
   "normal_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   909
  unfolding normal_space_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   910
proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   911
  fix S T
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   912
  assume "closedin mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   913
  then have "\<And>x. x \<in> M - S \<Longrightarrow> (\<exists>r>0. mball x r \<subseteq> M - S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   914
    by (simp add: closedin_def openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   915
  then obtain \<delta> where d0: "\<And>x. x \<in> M - S \<Longrightarrow> \<delta> x > 0 \<and> mball x (\<delta> x) \<subseteq> M - S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   916
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   917
  assume "closedin mtopology T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   918
  then have "\<And>x. x \<in> M - T \<Longrightarrow> (\<exists>r>0. mball x r \<subseteq> M - T)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   919
    by (simp add: closedin_def openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   920
  then obtain \<epsilon> where e: "\<And>x. x \<in> M - T \<Longrightarrow> \<epsilon> x > 0 \<and> mball x (\<epsilon> x) \<subseteq> M - T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   921
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   922
  assume "disjnt S T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   923
  have "S \<subseteq> M" "T \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   924
    using \<open>closedin mtopology S\<close> \<open>closedin mtopology T\<close> closedin_metric by blast+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   925
  have \<delta>: "\<And>x. x \<in> T \<Longrightarrow> \<delta> x > 0 \<and> mball x (\<delta> x) \<subseteq> M - S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   926
    by (meson DiffI \<open>T \<subseteq> M\<close> \<open>disjnt S T\<close> d0 disjnt_iff subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   927
  have \<epsilon>: "\<And>x. x \<in> S \<Longrightarrow> \<epsilon> x > 0 \<and> mball x (\<epsilon> x) \<subseteq> M - T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   928
    by (meson Diff_iff \<open>S \<subseteq> M\<close> \<open>disjnt S T\<close> disjnt_iff e subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   929
  show "\<exists>U V. openin mtopology U \<and> openin mtopology V \<and> S \<subseteq> U \<and> T \<subseteq> V \<and> disjnt U V"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   930
  proof (intro exI conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   931
    show "openin mtopology (\<Union>x\<in>S. mball x (\<epsilon> x / 2))" "openin mtopology (\<Union>x\<in>T. mball x (\<delta> x / 2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   932
      by force+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   933
    show "S \<subseteq> (\<Union>x\<in>S. mball x (\<epsilon> x / 2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   934
      using \<epsilon> \<open>S \<subseteq> M\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   935
    show "T \<subseteq> (\<Union>x\<in>T. mball x (\<delta> x / 2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   936
      using \<delta> \<open>T \<subseteq> M\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   937
    show "disjnt (\<Union>x\<in>S. mball x (\<epsilon> x / 2)) (\<Union>x\<in>T. mball x (\<delta> x / 2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   938
      using \<epsilon> \<delta> 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   939
      apply (clarsimp simp: disjnt_iff subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   940
      by (smt (verit, ccfv_SIG) field_sum_of_halves triangle')
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   941
  qed 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   942
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   943
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   944
lemma metrizable_imp_normal_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   945
   "metrizable_space X \<Longrightarrow> normal_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   946
  by (metis Metric_space.normal_space_mtopology metrizable_space_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   947
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   948
subsection\<open>Topological limitin in metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   949
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   950
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   951
lemma (in Metric_space) limitin_mspace:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   952
   "limitin mtopology f l F \<Longrightarrow> l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   953
  using limitin_topspace by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   954
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   955
lemma (in Metric_space) limitin_metric_unique:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   956
   "\<lbrakk>limitin mtopology f l1 F; limitin mtopology f l2 F; F \<noteq> bot\<rbrakk> \<Longrightarrow> l1 = l2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   957
  by (meson Hausdorff_space_mtopology limitin_Hausdorff_unique)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   958
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   959
lemma (in Metric_space) limitin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   960
   "limitin mtopology f l F \<longleftrightarrow> l \<in> M \<and> (\<forall>\<epsilon>>0. eventually (\<lambda>x. f x \<in> M \<and> d (f x) l < \<epsilon>) F)"  
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   961
   (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   962
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   963
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   964
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   965
    unfolding limitin_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   966
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   967
    show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   968
      using L limitin_mspace by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   969
    fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   970
    assume "\<epsilon>>0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   971
    then have "\<forall>\<^sub>F x in F. f x \<in> mball l \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   972
      using L openin_mball by (fastforce simp: limitin_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   973
    then show "\<forall>\<^sub>F x in F. f x \<in> M \<and> d (f x) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   974
      using commute eventually_mono by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   975
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   976
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   977
  assume R: ?rhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   978
  then show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   979
    by (force simp: limitin_def commute openin_mtopology subset_eq elim: eventually_mono)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   980
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   981
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   982
lemma (in Metric_space) limit_metric_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   983
   "limitin mtopology f l sequentially \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   984
     l \<in> M \<and> (\<forall>\<epsilon>>0. \<exists>N. \<forall>n\<ge>N. f n \<in> M \<and> d (f n) l < \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   985
  by (auto simp: limitin_metric eventually_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   986
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   987
lemma (in Submetric) limitin_submetric_iff:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   988
   "limitin sub.mtopology f l F \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   989
     l \<in> A \<and> eventually (\<lambda>x. f x \<in> A) F \<and> limitin mtopology f l F" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   990
  by (simp add: limitin_subtopology mtopology_submetric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   991
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   992
lemma (in Metric_space) metric_closedin_iff_sequentially_closed:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   993
   "closedin mtopology S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   994
    S \<subseteq> M \<and> (\<forall>\<sigma> l. range \<sigma> \<subseteq> S \<and> limitin mtopology \<sigma> l sequentially \<longrightarrow> l \<in> S)" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   995
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   996
  assume ?lhs then show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   997
    by (force simp: closedin_metric limitin_closedin range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   998
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   999
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1000
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1001
    unfolding closedin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1002
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1003
    show "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1004
      using R by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1005
    fix x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1006
    assume "x \<in> M - S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1007
    have False if "\<forall>r>0. \<exists>y. y \<in> M \<and> y \<in> S \<and> d x y < r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1008
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1009
      have "\<forall>n. \<exists>y. y \<in> M \<and> y \<in> S \<and> d x y < inverse(Suc n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1010
        using that by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1011
      then obtain \<sigma> where \<sigma>: "\<And>n. \<sigma> n \<in> M \<and> \<sigma> n \<in> S \<and> d x (\<sigma> n) < inverse(Suc n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1012
        by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1013
      then have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1014
        by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1015
      have "\<exists>N. \<forall>n\<ge>N. d x (\<sigma> n) < \<epsilon>" if "\<epsilon>>0" for \<epsilon>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1016
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1017
        have "real (Suc (nat \<lceil>inverse \<epsilon>\<rceil>)) \<ge> inverse \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1018
          by linarith
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1019
        then have "\<forall>n \<ge> nat \<lceil>inverse \<epsilon>\<rceil>. d x (\<sigma> n) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1020
          by (metis \<sigma> inverse_inverse_eq inverse_le_imp_le nat_ceiling_le_eq nle_le not_less_eq_eq order.strict_trans2 that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1021
        then show ?thesis ..
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1022
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1023
      with \<sigma> have "limitin mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1024
        using \<open>x \<in> M - S\<close> commute limit_metric_sequentially by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1025
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1026
        by (metis R DiffD2 \<sigma> image_subset_iff \<open>x \<in> M - S\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1027
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1028
    then show "\<exists>r>0. disjnt S (mball x r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1029
      by (meson disjnt_iff in_mball)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1030
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1031
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1032
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1033
lemma (in Metric_space) limit_atin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1034
   "limitin X f y (atin mtopology x) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1035
      y \<in> topspace X \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1036
      (x \<in> M
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1037
       \<longrightarrow> (\<forall>V. openin X V \<and> y \<in> V
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1038
               \<longrightarrow> (\<exists>\<delta>>0.  \<forall>x'. x' \<in> M \<and> 0 < d x' x \<and> d x' x < \<delta> \<longrightarrow> f x' \<in> V)))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1039
  by (force simp: limitin_def eventually_atin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1040
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1041
lemma (in Metric_space) limitin_metric_dist_null:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1042
   "limitin mtopology f l F \<longleftrightarrow> l \<in> M \<and> eventually (\<lambda>x. f x \<in> M) F \<and> ((\<lambda>x. d (f x) l) \<longlongrightarrow> 0) F"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1043
  by (simp add: limitin_metric tendsto_iff eventually_conj_iff all_conj_distrib imp_conjR gt_ex)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1044
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1045
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1046
subsection\<open>Cauchy sequences and complete metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1047
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1048
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1049
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1050
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1051
definition MCauchy :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1052
  where "MCauchy \<sigma> \<equiv> range \<sigma> \<subseteq> M \<and> (\<forall>\<epsilon>>0. \<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1053
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1054
definition mcomplete
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1055
  where "mcomplete \<equiv> (\<forall>\<sigma>. MCauchy \<sigma> \<longrightarrow> (\<exists>x. limitin mtopology \<sigma> x sequentially))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1056
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1057
lemma mcomplete_empty [iff]: "Metric_space.mcomplete {} d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1058
  by (simp add: Metric_space.MCauchy_def Metric_space.mcomplete_def subspace)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1059
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1060
lemma MCauchy_imp_MCauchy_suffix: "MCauchy \<sigma> \<Longrightarrow> MCauchy (\<sigma> \<circ> (+)n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1061
  unfolding MCauchy_def image_subset_iff comp_apply
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1062
  by (metis UNIV_I add.commute trans_le_add1) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1063
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1064
lemma mcomplete:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1065
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1066
    (\<forall>\<sigma>. (\<forall>\<^sub>F n in sequentially. \<sigma> n \<in> M) \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1067
     (\<forall>\<epsilon>>0. \<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>) \<longrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1068
     (\<exists>x. limitin mtopology \<sigma> x sequentially))" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1069
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1070
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1071
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1072
  proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1073
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1074
    assume "\<forall>\<^sub>F n in sequentially. \<sigma> n \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1075
      and \<sigma>: "\<forall>\<epsilon>>0. \<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1076
    then obtain N where "\<And>n. n\<ge>N \<Longrightarrow> \<sigma> n \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1077
      by (auto simp: eventually_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1078
    with \<sigma> have "MCauchy (\<sigma> \<circ> (+)N)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1079
      unfolding MCauchy_def image_subset_iff comp_apply by (meson le_add1 trans_le_add2)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1080
    then obtain x where "limitin mtopology (\<sigma> \<circ> (+)N) x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1081
      using L MCauchy_imp_MCauchy_suffix mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1082
    then have "limitin mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1083
      unfolding o_def by (auto simp: add.commute limitin_sequentially_offset_rev)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1084
    then show "\<exists>x. limitin mtopology \<sigma> x sequentially" ..
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1085
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1086
qed (simp add: mcomplete_def MCauchy_def image_subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1087
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1088
lemma mcomplete_empty_mspace: "M = {} \<Longrightarrow> mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1089
  using MCauchy_def mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1090
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1091
lemma MCauchy_const [simp]: "MCauchy (\<lambda>n. a) \<longleftrightarrow> a \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1092
  using MCauchy_def mdist_zero by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1094
lemma convergent_imp_MCauchy:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1095
  assumes "range \<sigma> \<subseteq> M" and lim: "limitin mtopology \<sigma> l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1096
  shows "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1097
  unfolding MCauchy_def image_subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1098
proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1099
  fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1100
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1101
  then have "\<forall>\<^sub>F n in sequentially. \<sigma> n \<in> M \<and> d (\<sigma> n) l < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1102
    using half_gt_zero lim limitin_metric by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1103
  then obtain N where "\<And>n. n\<ge>N \<Longrightarrow> \<sigma> n \<in> M \<and> d (\<sigma> n) l < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1104
    by (force simp: eventually_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1105
  then show "\<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1106
    by (smt (verit) limitin_mspace mdist_reverse_triangle field_sum_of_halves lim)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1107
qed (use assms in blast)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1108
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1109
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1110
lemma mcomplete_alt:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1111
   "mcomplete \<longleftrightarrow> (\<forall>\<sigma>. MCauchy \<sigma> \<longleftrightarrow> range \<sigma> \<subseteq> M \<and> (\<exists>x. limitin mtopology \<sigma> x sequentially))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1112
  using MCauchy_def convergent_imp_MCauchy mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1113
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1114
lemma MCauchy_subsequence:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1115
  assumes "strict_mono r" "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1116
  shows "MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1117
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1118
  have "d (\<sigma> (r n)) (\<sigma> (r n')) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1119
    if "N \<le> n" "N \<le> n'" "strict_mono r" "\<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1120
    for \<epsilon> N n n'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1121
    using that by (meson le_trans strict_mono_imp_increasing)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1122
  moreover have "range (\<lambda>x. \<sigma> (r x)) \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1123
    using MCauchy_def assms by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1124
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1125
    using assms by (simp add: MCauchy_def) metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1126
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1127
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1128
lemma MCauchy_offset:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1129
  assumes cau: "MCauchy (\<sigma> \<circ> (+)k)" and \<sigma>: "\<And>n. n < k \<Longrightarrow> \<sigma> n \<in> M" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1130
  shows "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1131
  unfolding MCauchy_def image_subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1132
proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1133
  fix n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1134
  show "\<sigma> n \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1135
    using assms
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1136
    unfolding MCauchy_def image_subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1137
    by (metis UNIV_I comp_apply le_iff_add linorder_not_le)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1138
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1139
  fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1140
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1141
  obtain N where "\<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d ((\<sigma> \<circ> (+)k) n) ((\<sigma> \<circ> (+)k) n') < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1142
    using cau \<open>\<epsilon> > 0\<close> by (fastforce simp: MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1143
  then show "\<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1144
    unfolding o_def
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  1145
    by (intro exI [where x="k+N"]) (smt (verit, del_insts) add.assoc le_add1 less_eqE)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1146
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1147
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1148
lemma MCauchy_convergent_subsequence:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1149
  assumes cau: "MCauchy \<sigma>" and "strict_mono r" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1150
     and lim: "limitin mtopology (\<sigma> \<circ> r) a sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1151
  shows "limitin mtopology \<sigma> a sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1152
  unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1153
proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1154
  show "a \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1155
    by (meson assms limitin_mspace)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1156
  fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1157
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1158
  then obtain N1 where N1: "\<And>n n'. \<lbrakk>n\<ge>N1; n'\<ge>N1\<rbrakk> \<Longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1159
    using cau unfolding MCauchy_def by (meson half_gt_zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1160
  obtain N2 where N2: "\<And>n. n \<ge> N2 \<Longrightarrow> (\<sigma> \<circ> r) n \<in> M \<and> d ((\<sigma> \<circ> r) n) a < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1161
    by (metis (no_types, lifting) lim \<open>\<epsilon> > 0\<close> half_gt_zero limit_metric_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1162
  have "\<sigma> n \<in> M \<and> d (\<sigma> n) a < \<epsilon>" if "n \<ge> max N1 N2" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1163
  proof (intro conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1164
    show "\<sigma> n \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1165
      using MCauchy_def cau by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1166
    have "N1 \<le> r n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1167
      by (meson \<open>strict_mono r\<close> le_trans max.cobounded1 strict_mono_imp_increasing that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1168
    then show "d (\<sigma> n) a < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1169
      using N1[of n "r n"] N2[of n] \<open>\<sigma> n \<in> M\<close> \<open>a \<in> M\<close> triangle that by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1170
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1171
  then show "\<forall>\<^sub>F n in sequentially. \<sigma> n \<in> M \<and> d (\<sigma> n) a < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1172
    using eventually_sequentially by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1173
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1174
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1175
lemma MCauchy_interleaving_gen:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1176
  "MCauchy (\<lambda>n. if even n then x(n div 2) else y(n div 2)) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1177
    (MCauchy x \<and> MCauchy y \<and> (\<lambda>n. d (x n) (y n)) \<longlonglongrightarrow> 0)" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1178
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1179
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1180
  have evens: "strict_mono (\<lambda>n::nat. 2 * n)" and odds: "strict_mono (\<lambda>n::nat. Suc (2 * n))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1181
    by (auto simp: strict_mono_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1182
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1183
  proof (intro conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1184
    show "MCauchy x" "MCauchy y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1185
      using MCauchy_subsequence [OF evens L] MCauchy_subsequence [OF odds L] by (auto simp: o_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1186
    show "(\<lambda>n. d (x n) (y n)) \<longlonglongrightarrow> 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1187
      unfolding LIMSEQ_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1188
    proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1189
      fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1190
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1191
      then obtain N where N: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1192
        "\<And>n n'. \<lbrakk>n\<ge>N; n'\<ge>N\<rbrakk> \<Longrightarrow> d (if even n then x (n div 2) else y (n div 2))
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1193
                                   (if even n' then x (n' div 2) else y (n' div 2))  < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1194
        using L MCauchy_def by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1195
      have "d (x n) (y n) < \<epsilon>" if "n\<ge>N" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1196
        using N [of "2*n" "Suc(2*n)"] that by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1197
      then show "\<exists>N. \<forall>n\<ge>N. norm (d (x n) (y n) - 0) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1198
        by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1199
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1200
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1201
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1202
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1203
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1204
    unfolding MCauchy_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1205
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1206
    show "range (\<lambda>n. if even n then x (n div 2) else y (n div 2)) \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1207
      using R by (auto simp: MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1208
    fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1209
    assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1210
    obtain Nx where Nx: "\<And>n n'. \<lbrakk>n\<ge>Nx; n'\<ge>Nx\<rbrakk> \<Longrightarrow> d (x n) (x n')  < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1211
      by (meson half_gt_zero MCauchy_def R \<open>\<epsilon> > 0\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1212
    obtain Ny where Ny: "\<And>n n'. \<lbrakk>n\<ge>Ny; n'\<ge>Ny\<rbrakk> \<Longrightarrow> d (y n) (y n')  < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1213
      by (meson half_gt_zero MCauchy_def R \<open>\<epsilon> > 0\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1214
    obtain Nxy where Nxy: "\<And>n. n\<ge>Nxy \<Longrightarrow> d (x n) (y n) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1215
      using R \<open>\<epsilon> > 0\<close> half_gt_zero unfolding LIMSEQ_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1216
      by (metis abs_mdist diff_zero real_norm_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1217
    define N where "N \<equiv> 2 * Max{Nx,Ny,Nxy}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1218
    show "\<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (if even n then x (n div 2) else y (n div 2)) (if even n' then x (n' div 2) else y (n' div 2)) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1219
    proof (intro exI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1220
      fix n n'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1221
      assume "N \<le> n" and "N \<le> n'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1222
      then have "n div 2 \<ge> Nx" "n div 2 \<ge> Ny" "n div 2 \<ge> Nxy" "n' div 2 \<ge> Nx" "n' div 2 \<ge> Ny" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1223
        by (auto simp: N_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1224
      then have dxyn: "d (x (n div 2)) (y (n div 2)) < \<epsilon>/2" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1225
            and dxnn': "d (x (n div 2)) (x (n' div 2)) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1226
            and dynn': "d (y (n div 2)) (y (n' div 2)) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1227
        using Nx Ny Nxy by blast+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1228
      have inM: "x (n div 2) \<in> M" "x (n' div 2) \<in> M""y (n div 2) \<in> M" "y (n' div 2) \<in> M"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1229
        using MCauchy_def R by blast+
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1230
      show "d (if even n then x (n div 2) else y (n div 2)) (if even n' then x (n' div 2) else y (n' div 2)) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1231
      proof (cases "even n")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1232
        case nt: True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1233
        show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1234
        proof (cases "even n'")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1235
          case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1236
          with \<open>\<epsilon> > 0\<close> nt dxnn' show ?thesis by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1237
        next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1238
          case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1239
          with nt dxyn dynn' inM triangle show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1240
            by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1241
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1242
      next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1243
        case nf: False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1244
        show ?thesis 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1245
        proof (cases "even n'")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1246
          case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1247
          then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1248
            by (smt (verit) \<open>\<epsilon> > 0\<close> dxyn dxnn' triangle commute inM field_sum_of_halves)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1249
        next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1250
          case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1251
          with \<open>\<epsilon> > 0\<close> nf dynn' show ?thesis by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1252
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1253
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1254
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1255
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1256
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1257
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1258
lemma MCauchy_interleaving:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1259
   "MCauchy (\<lambda>n. if even n then \<sigma>(n div 2) else a) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1260
    range \<sigma> \<subseteq> M \<and> limitin mtopology \<sigma> a sequentially"  (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1261
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1262
  have "?lhs \<longleftrightarrow> (MCauchy \<sigma> \<and> a \<in> M \<and> (\<lambda>n. d (\<sigma> n) a) \<longlonglongrightarrow> 0)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1263
    by (simp add: MCauchy_interleaving_gen [where y = "\<lambda>n. a"])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1264
  also have "... = ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1265
    by (metis MCauchy_def always_eventually convergent_imp_MCauchy limitin_metric_dist_null range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1266
  finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1267
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1268
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1269
lemma mcomplete_nest:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1270
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1271
      (\<forall>C::nat \<Rightarrow>'a set. (\<forall>n. closedin mtopology (C n)) \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1272
          (\<forall>n. C n \<noteq> {}) \<and> decseq C \<and> (\<forall>\<epsilon>>0. \<exists>n a. C n \<subseteq> mcball a \<epsilon>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1273
          \<longrightarrow> \<Inter> (range C) \<noteq> {})" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1274
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1275
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1276
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1277
    unfolding imp_conjL
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1278
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1279
    fix C :: "nat \<Rightarrow> 'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1280
    assume clo: "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1281
      and ne: "\<forall>n. C n \<noteq> ({}::'a set)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1282
      and dec: "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1283
      and cover [rule_format]: "\<forall>\<epsilon>>0. \<exists>n a. C n \<subseteq> mcball a \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1284
    obtain \<sigma> where \<sigma>: "\<And>n. \<sigma> n \<in> C n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1285
      by (meson ne empty_iff set_eq_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1286
    have "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1287
      unfolding MCauchy_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1288
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1289
      show "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1290
        using \<sigma> clo metric_closedin_iff_sequentially_closed by auto 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1291
      fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1292
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1293
      then obtain N a where N: "C N \<subseteq> mcball a (\<epsilon>/3)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1294
        using cover by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1295
      have "d (\<sigma> m) (\<sigma> n) < \<epsilon>" if "N \<le> m" "N \<le> n" for m n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1296
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1297
        have "d a (\<sigma> m) \<le> \<epsilon>/3" "d a (\<sigma> n) \<le> \<epsilon>/3"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1298
          using dec N \<sigma> that by (fastforce simp: decseq_def)+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1299
        then have "d (\<sigma> m) (\<sigma> n) \<le> \<epsilon>/3 + \<epsilon>/3"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1300
          using triangle \<sigma> commute dec decseq_def subsetD that N
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1301
          by (smt (verit, ccfv_threshold) in_mcball)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1302
        also have "... < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1303
          using \<open>\<epsilon> > 0\<close> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1304
        finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1305
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1306
      then show "\<exists>N. \<forall>m n. N \<le> m \<longrightarrow> N \<le> n \<longrightarrow> d (\<sigma> m) (\<sigma> n) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1307
        by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1308
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1309
    then obtain x where x: "limitin mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1310
      using L mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1311
    have "x \<in> C n" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1312
    proof (rule limitin_closedin [OF x])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1313
      show "closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1314
        by (simp add: clo)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1315
      show "\<forall>\<^sub>F x in sequentially. \<sigma> x \<in> C n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1316
        by (metis \<sigma> dec decseq_def eventually_sequentiallyI subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1317
    qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1318
    then show "\<Inter> (range C) \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1319
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1320
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1321
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1322
  assume R: ?rhs  
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1323
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1324
    unfolding mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1325
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1326
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1327
    assume "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1328
    then have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1329
      using MCauchy_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1330
    define C where "C \<equiv> \<lambda>n. mtopology closure_of (\<sigma> ` {n..})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1331
    have "\<forall>n. closedin mtopology (C n)" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1332
      by (auto simp: C_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1333
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1334
    have ne: "\<And>n. C n \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1335
      using \<open>MCauchy \<sigma>\<close> by (auto simp: C_def MCauchy_def disjnt_iff closure_of_eq_empty_gen)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1336
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1337
    have dec: "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1338
      unfolding monotone_on_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1339
    proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1340
      fix m n::nat
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1341
      assume "m \<le> n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1342
      then have "{n..} \<subseteq> {m..}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1343
        by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1344
      then show "C n \<subseteq> C m"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1345
        unfolding C_def by (meson closure_of_mono image_mono)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1346
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1347
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1348
    have C: "\<exists>N u. C N \<subseteq> mcball u \<epsilon>" if "\<epsilon>>0" for \<epsilon>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1349
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1350
      obtain N where "\<And>m n. N \<le> m \<and> N \<le> n \<Longrightarrow> d (\<sigma> m) (\<sigma> n) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1351
        by (meson MCauchy_def \<open>0 < \<epsilon>\<close> \<open>MCauchy \<sigma>\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1352
      then have "\<sigma> ` {N..} \<subseteq> mcball (\<sigma> N) \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1353
        using MCauchy_def \<open>MCauchy \<sigma>\<close> by (force simp: less_eq_real_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1354
      then have "C N \<subseteq> mcball (\<sigma> N) \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1355
        by (simp add: C_def closure_of_minimal)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1356
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1357
        by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1358
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1359
    ultimately obtain l where x: "l \<in> \<Inter> (range C)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1360
      by (metis R ex_in_conv)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1361
    then have *: "\<And>\<epsilon> N. 0 < \<epsilon> \<Longrightarrow> \<exists>n'. N \<le> n' \<and> l \<in> M \<and> \<sigma> n' \<in> M \<and> d l (\<sigma> n') < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1362
      by (force simp: C_def metric_closure_of)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1363
    then have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1364
      using gt_ex by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1365
    show "\<exists>l. limitin mtopology \<sigma> l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1366
      unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1367
    proof (intro conjI strip exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1368
      show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1369
        using \<open>\<forall>n. closedin mtopology (C n)\<close> closedin_subset x by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1370
      fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1371
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1372
      obtain N where N: "\<And>m n. N \<le> m \<and> N \<le> n \<Longrightarrow> d (\<sigma> m) (\<sigma> n) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1373
        by (meson MCauchy_def \<open>0 < \<epsilon>\<close> \<open>MCauchy \<sigma>\<close> half_gt_zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1374
      with * [of "\<epsilon>/2" N]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1375
      have "\<forall>n\<ge>N. \<sigma> n \<in> M \<and> d (\<sigma> n) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1376
        by (smt (verit) \<open>range \<sigma> \<subseteq> M\<close> commute field_sum_of_halves range_subsetD triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1377
      then show "\<forall>\<^sub>F n in sequentially. \<sigma> n \<in> M \<and> d (\<sigma> n) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1378
        using eventually_sequentially by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1379
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1380
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1381
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1382
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1383
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1384
lemma mcomplete_nest_sing:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1385
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1386
    (\<forall>C. (\<forall>n. closedin mtopology (C n)) \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1387
          (\<forall>n. C n \<noteq> {}) \<and> decseq C \<and> (\<forall>e>0. \<exists>n a. C n \<subseteq> mcball a e)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1388
         \<longrightarrow> (\<exists>l. l \<in> M \<and> \<Inter> (range C) = {l}))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1389
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1390
  have *: False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1391
    if clo: "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1392
      and cover: "\<forall>\<epsilon>>0. \<exists>n a. C n \<subseteq> mcball a \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1393
      and no_sing: "\<And>y. y \<in> M \<Longrightarrow> \<Inter> (range C) \<noteq> {y}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1394
      and l: "\<forall>n. l \<in> C n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1395
    for C :: "nat \<Rightarrow> 'a set" and l
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1396
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1397
    have inM: "\<And>x. x \<in> \<Inter> (range C) \<Longrightarrow> x \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1398
      using closedin_metric clo by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1399
    then have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1400
      by (simp add: l)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1401
    have False if l': "l' \<in> \<Inter> (range C)" and "l' \<noteq> l" for l'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1402
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1403
      have "l' \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1404
        using inM l' by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1405
      obtain n a where na: "C n \<subseteq> mcball a (d l l' / 3)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1406
        using inM \<open>l \<in> M\<close> l' \<open>l' \<noteq> l\<close> cover by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1407
      then have "d a l \<le> (d l l' / 3)" "d a l' \<le> (d l l' / 3)" "a \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1408
        using l l' na in_mcball by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1409
      then have "d l l' \<le> (d l l' / 3) + (d l l' / 3)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1410
        using \<open>l \<in> M\<close> \<open>l' \<in> M\<close> mdist_reverse_triangle by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1411
      then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1412
        using nonneg [of l l'] \<open>l' \<noteq> l\<close> \<open>l \<in> M\<close> \<open>l' \<in> M\<close> zero by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1413
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1414
    then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1415
      by (metis l \<open>l \<in> M\<close> no_sing INT_I empty_iff insertI1 is_singletonE is_singletonI')
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1416
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1417
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1418
    unfolding mcomplete_nest imp_conjL 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1419
    apply (intro all_cong1 imp_cong refl)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1420
    using * 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1421
    by (smt (verit) Inter_iff ex_in_conv range_constant range_eqI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1422
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1423
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1424
lemma mcomplete_fip:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1425
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1426
    (\<forall>\<C>. (\<forall>C \<in> \<C>. closedin mtopology C) \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1427
         (\<forall>e>0. \<exists>C a. C \<in> \<C> \<and> C \<subseteq> mcball a e) \<and> (\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<C> \<longrightarrow> \<Inter> \<F> \<noteq> {})
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1428
        \<longrightarrow> \<Inter> \<C> \<noteq> {})" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1429
   (is "?lhs = ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1430
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1431
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1432
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1433
    unfolding mcomplete_nest_sing imp_conjL
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1434
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1435
    fix \<C> :: "'a set set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1436
    assume clo: "\<forall>C\<in>\<C>. closedin mtopology C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1437
      and cover: "\<forall>e>0. \<exists>C a. C \<in> \<C> \<and> C \<subseteq> mcball a e"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1438
      and fip: "\<forall>\<F>. finite \<F> \<longrightarrow> \<F> \<subseteq> \<C> \<longrightarrow> \<Inter> \<F> \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1439
    then have "\<forall>n. \<exists>C. C \<in> \<C> \<and> (\<exists>a. C \<subseteq> mcball a (inverse (Suc n)))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1440
      by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1441
    then obtain C where C: "\<And>n. C n \<in> \<C>" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1442
          and coverC: "\<And>n. \<exists>a. C n \<subseteq> mcball a (inverse (Suc n))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1443
      by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1444
    define D where "D \<equiv> \<lambda>n. \<Inter> (C ` {..n})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1445
    have cloD: "closedin mtopology (D n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1446
      unfolding D_def using clo C by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1447
    have neD: "D n \<noteq> {}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1448
      using fip C by (simp add: D_def image_subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1449
    have decD: "decseq D"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1450
      by (force simp: D_def decseq_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1451
    have coverD: "\<exists>n a. D n \<subseteq> mcball a \<epsilon>" if " \<epsilon> >0" for \<epsilon>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1452
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1453
      obtain n where "inverse (Suc n) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1454
        using \<open>0 < \<epsilon>\<close> reals_Archimedean by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1455
      then obtain a where "C n \<subseteq> mcball a \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1456
        by (meson coverC less_eq_real_def mcball_subset_concentric order_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1457
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1458
        unfolding D_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1459
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1460
    have *: "a \<in> \<Inter>\<C>" if a: "\<Inter> (range D) = {a}" and "a \<in> M" for a
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1461
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1462
      have aC: "a \<in> C n" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1463
        using that by (auto simp: D_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1464
      have eqa: "\<And>u. (\<forall>n. u \<in> C n) \<Longrightarrow> a = u"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1465
        using that by (auto simp: D_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1466
      have "a \<in> T" if "T \<in> \<C>" for T
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1467
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1468
        have cloT: "closedin mtopology (T \<inter> D n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1469
          using clo cloD that by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1470
        have "\<Inter> (insert T (C ` {..n})) \<noteq> {}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1471
          using that C by (intro fip [rule_format]) auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1472
        then have neT: "T \<inter> D n \<noteq> {}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1473
          by (simp add: D_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1474
        have decT: "decseq (\<lambda>n. T \<inter> D n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1475
          by (force simp: D_def decseq_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1476
        have coverT: "\<exists>n a. T \<inter> D n \<subseteq> mcball a \<epsilon>" if " \<epsilon> >0" for \<epsilon>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1477
          by (meson coverD le_infI2 that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1478
        show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1479
          using L [unfolded mcomplete_nest_sing, rule_format, of "\<lambda>n. T \<inter> D n"] a
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1480
          by (force simp: cloT neT decT coverT)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1481
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1482
      then show ?thesis by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1483
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1484
    show "\<Inter> \<C> \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1485
      by (metis L cloD neD decD coverD * empty_iff mcomplete_nest_sing)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1486
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1487
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1488
  assume R [rule_format]: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1489
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1490
    unfolding mcomplete_nest imp_conjL
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1491
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1492
    fix C :: "nat \<Rightarrow> 'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1493
    assume clo: "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1494
      and ne: "\<forall>n. C n \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1495
      and dec: "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1496
      and cover: "\<forall>\<epsilon>>0. \<exists>n a. C n \<subseteq> mcball a \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1497
    have "\<Inter>(C ` N) \<noteq> {}" if "finite N" for N
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1498
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1499
      obtain k where "N \<subseteq> {..k}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1500
        using \<open>finite N\<close> finite_nat_iff_bounded_le by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1501
      with dec have "C k \<subseteq> \<Inter>(C ` N)" by (auto simp: decseq_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1502
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1503
        using ne by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1504
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1505
    with clo cover R [of "range C"] show "\<Inter> (range C) \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1506
      by (metis (no_types, opaque_lifting) finite_subset_image image_iff UNIV_I)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1507
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1508
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1509
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1510
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1511
lemma mcomplete_fip_sing:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1512
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1513
    (\<forall>\<C>. (\<forall>C\<in>\<C>. closedin mtopology C) \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1514
     (\<forall>e>0. \<exists>c a. c \<in> \<C> \<and> c \<subseteq> mcball a e) \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1515
     (\<forall>\<F>. finite \<F> \<and> \<F> \<subseteq> \<C> \<longrightarrow> \<Inter> \<F> \<noteq> {}) \<longrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1516
     (\<exists>l. l \<in> M \<and> \<Inter> \<C> = {l}))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1517
   (is "?lhs = ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1518
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1519
  have *: "l \<in> M" "\<Inter> \<C> = {l}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1520
    if clo: "Ball \<C> (closedin mtopology)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1521
      and cover: "\<forall>e>0. \<exists>C a. C \<in> \<C> \<and> C \<subseteq> mcball a e"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1522
      and fin: "\<forall>\<F>. finite \<F> \<longrightarrow> \<F> \<subseteq> \<C> \<longrightarrow> \<Inter> \<F> \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1523
      and l: "l \<in> \<Inter> \<C>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1524
    for \<C> :: "'a set set" and l
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1525
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1526
    show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1527
      by (meson Inf_lower2 clo cover gt_ex metric_closedin_iff_sequentially_closed subsetD that(4))
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1528
    show  "\<Inter> \<C> = {l}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1529
    proof (cases "\<C> = {}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1530
      case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1531
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1532
        using cover mbounded_pos by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1533
    next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1534
      case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1535
      have CM: "\<And>a. a \<in> \<Inter>\<C> \<Longrightarrow> a \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1536
        using False clo closedin_subset by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1537
      have "l' \<notin> \<Inter> \<C>" if "l' \<noteq> l" for l'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1538
      proof 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1539
        assume l': "l' \<in> \<Inter> \<C>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1540
        with CM have "l' \<in> M" by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1541
        with that \<open>l \<in> M\<close> have gt0: "0 < d l l'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1542
          by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1543
        then obtain C a where "C \<in> \<C>" and C: "C \<subseteq> mcball a (d l l' / 3)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1544
          using cover [rule_format, of "d l l' / 3"] by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1545
        then have "d a l \<le> (d l l' / 3)" "d a l' \<le> (d l l' / 3)" "a \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1546
          using l l' in_mcball by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1547
        then have "d l l' \<le> (d l l' / 3) + (d l l' / 3)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1548
          using \<open>l \<in> M\<close> \<open>l' \<in> M\<close> mdist_reverse_triangle by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1549
        with gt0 show False by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1550
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1551
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1552
        using l by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1553
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1554
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1555
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1556
  with * show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1557
    unfolding mcomplete_fip imp_conjL ex_in_conv [symmetric]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1558
    by (elim all_forward imp_forward2 asm_rl) (blast intro:  elim: )
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1559
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1560
  assume ?rhs then show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1561
    unfolding mcomplete_fip by (force elim!: all_forward)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1562
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1563
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1564
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1565
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1566
definition mcomplete_of :: "'a metric \<Rightarrow> bool"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1567
  where "mcomplete_of \<equiv> \<lambda>m. Metric_space.mcomplete (mspace m) (mdist m)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1568
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1569
lemma (in Metric_space) mcomplete_of [simp]: "mcomplete_of (metric (M,d)) = mcomplete"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1570
  by (simp add: mcomplete_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1571
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1572
lemma mcomplete_trivial: "Metric_space.mcomplete {} (\<lambda>x y. 0)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1573
  using Metric_space.intro Metric_space.mcomplete_empty_mspace by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1574
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1575
lemma mcomplete_trivial_singleton: "Metric_space.mcomplete {\<lambda>x. a} (\<lambda>x y. 0)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1576
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1577
  interpret Metric_space "{\<lambda>x. a}" "\<lambda>x y. 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1578
    by unfold_locales auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1579
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1580
    unfolding mcomplete_def MCauchy_def image_subset_iff by (metis UNIV_I limit_metric_sequentially)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1581
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1582
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1583
lemma MCauchy_iff_Cauchy [iff]: "Met_TC.MCauchy = Cauchy"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1584
  by (force simp: Cauchy_def Met_TC.MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1585
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1586
lemma mcomplete_iff_complete [iff]:
80764
47c0aa388621 tuned: prefer notation for Pure.type;
wenzelm
parents: 78750
diff changeset
  1587
  "Met_TC.mcomplete TYPE('a::metric_space) \<longleftrightarrow> complete (UNIV::'a set)"
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1588
  by (auto simp: Met_TC.mcomplete_def complete_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1589
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1590
context Submetric
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1591
begin 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1592
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1593
lemma MCauchy_submetric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1594
   "sub.MCauchy \<sigma> \<longleftrightarrow> range \<sigma> \<subseteq> A \<and> MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1595
  using MCauchy_def sub.MCauchy_def subset by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1596
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1597
lemma closedin_mcomplete_imp_mcomplete:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1598
  assumes clo: "closedin mtopology A" and "mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1599
  shows "sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1600
  unfolding sub.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1601
proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1602
  fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1603
  assume "sub.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1604
  then have \<sigma>: "MCauchy \<sigma>" "range \<sigma> \<subseteq> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1605
    using MCauchy_submetric by blast+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1606
  then obtain x where x: "limitin mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1607
    using \<open>mcomplete\<close> unfolding mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1608
  then have "x \<in> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1609
    using \<sigma> clo metric_closedin_iff_sequentially_closed by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1610
  with \<sigma> x show "\<exists>x. limitin sub.mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1611
    using limitin_submetric_iff range_subsetD by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1612
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1613
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1614
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1615
lemma sequentially_closedin_mcomplete_imp_mcomplete:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1616
  assumes "mcomplete" and "\<And>\<sigma> l. range \<sigma> \<subseteq> A \<and> limitin mtopology \<sigma> l sequentially \<Longrightarrow> l \<in> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1617
  shows "sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1618
  using assms closedin_mcomplete_imp_mcomplete metric_closedin_iff_sequentially_closed subset by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1619
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1620
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1621
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1622
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1623
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1624
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1625
lemma mcomplete_Un:
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1626
  assumes A: "Submetric M d A" "Metric_space.mcomplete A d" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1627
      and B: "Submetric M d B" "Metric_space.mcomplete B d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1628
  shows   "Submetric M d (A \<union> B)" "Metric_space.mcomplete (A \<union> B) d" 
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1629
proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1630
  show "Submetric M d (A \<union> B)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1631
    by (meson assms le_sup_iff Submetric_axioms_def Submetric_def) 
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1632
  then interpret MAB: Metric_space "A \<union> B" d
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1633
    by (meson Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1634
  interpret MA: Metric_space A d
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1635
    by (meson A Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1636
  interpret MB: Metric_space B d
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1637
    by (meson B Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1638
  show "Metric_space.mcomplete (A \<union> B) d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1639
    unfolding MAB.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1640
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1641
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1642
    assume "MAB.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1643
    then have "range \<sigma> \<subseteq> A \<union> B"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1644
      using MAB.MCauchy_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1645
    then have "UNIV \<subseteq> \<sigma> -` A \<union> \<sigma> -` B"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1646
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1647
    then consider "infinite (\<sigma> -` A)" | "infinite (\<sigma> -` B)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1648
      using finite_subset by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1649
    then show "\<exists>x. limitin MAB.mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1650
    proof cases
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1651
      case 1
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1652
      then obtain r where "strict_mono r" and r: "\<And>n::nat. r n \<in> \<sigma> -` A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1653
        using infinite_enumerate by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1654
      then have "MA.MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1655
        using MA.MCauchy_def MAB.MCauchy_def MAB.MCauchy_subsequence \<open>MAB.MCauchy \<sigma>\<close> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1656
      with A obtain x where "limitin MA.mtopology (\<sigma> \<circ> r) x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1657
        using MA.mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1658
      then have "limitin MAB.mtopology (\<sigma> \<circ> r) x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1659
        by (metis MA.limit_metric_sequentially MAB.limit_metric_sequentially UnCI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1660
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1661
        using MAB.MCauchy_convergent_subsequence \<open>MAB.MCauchy \<sigma>\<close> \<open>strict_mono r\<close> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1662
    next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1663
      case 2
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1664
      then obtain r where "strict_mono r" and r: "\<And>n::nat. r n \<in> \<sigma> -` B"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1665
        using infinite_enumerate by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1666
      then have "MB.MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1667
        using MB.MCauchy_def MAB.MCauchy_def MAB.MCauchy_subsequence \<open>MAB.MCauchy \<sigma>\<close> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1668
      with B obtain x where "limitin MB.mtopology (\<sigma> \<circ> r) x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1669
        using MB.mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1670
      then have "limitin MAB.mtopology (\<sigma> \<circ> r) x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1671
        by (metis MB.limit_metric_sequentially MAB.limit_metric_sequentially UnCI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1672
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1673
        using MAB.MCauchy_convergent_subsequence \<open>MAB.MCauchy \<sigma>\<close> \<open>strict_mono r\<close> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1674
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1675
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1676
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1677
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1678
lemma mcomplete_Union:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1679
  assumes "finite \<S>"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1680
    and "\<And>A. A \<in> \<S> \<Longrightarrow> Submetric M d A" "\<And>A. A \<in> \<S> \<Longrightarrow> Metric_space.mcomplete A d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1681
  shows   "Submetric M d (\<Union>\<S>)" "Metric_space.mcomplete (\<Union>\<S>) d" 
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1682
  using assms
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1683
  by (induction rule: finite_induct) (auto simp: mcomplete_Un)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1684
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1685
lemma mcomplete_Inter:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1686
  assumes "finite \<S>" "\<S> \<noteq> {}"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1687
    and sub: "\<And>A. A \<in> \<S> \<Longrightarrow> Submetric M d A" 
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1688
    and comp: "\<And>A. A \<in> \<S> \<Longrightarrow> Metric_space.mcomplete A d"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1689
  shows "Submetric M d (\<Inter>\<S>)" "Metric_space.mcomplete (\<Inter>\<S>) d"
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1690
proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1691
  show "Submetric M d (\<Inter>\<S>)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1692
    using assms unfolding Submetric_def Submetric_axioms_def
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1693
    by (metis Inter_lower equals0I inf.orderE le_inf_iff) 
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1694
  then interpret MS: Submetric M d "\<Inter>\<S>" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1695
    by (meson Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1696
  show "Metric_space.mcomplete (\<Inter>\<S>) d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1697
    unfolding MS.sub.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1698
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1699
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1700
    assume "MS.sub.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1701
    then have "range \<sigma> \<subseteq> \<Inter>\<S>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1702
      using MS.MCauchy_submetric by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1703
    obtain A where "A \<in> \<S>" and A: "Metric_space.mcomplete A d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1704
      using assms by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1705
    then have "range \<sigma> \<subseteq> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1706
      using \<open>range \<sigma> \<subseteq> \<Inter>\<S>\<close> by blast
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1707
    interpret SA: Submetric M d A
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1708
      by (meson \<open>A \<in> \<S>\<close> sub Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1709
    have "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1710
      using MS.MCauchy_submetric \<open>MS.sub.MCauchy \<sigma>\<close> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1711
    then obtain x where x: "limitin SA.sub.mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1712
      by (metis A SA.sub.MCauchy_def SA.sub.mcomplete_alt MCauchy_def \<open>range \<sigma> \<subseteq> A\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1713
    show "\<exists>x. limitin MS.sub.mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1714
      unfolding MS.limitin_submetric_iff
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  1715
    proof (intro exI conjI)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1716
      show "x \<in> \<Inter> \<S>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1717
      proof clarsimp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1718
        fix U
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1719
        assume "U \<in> \<S>"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1720
        interpret SU: Submetric M d U 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1721
          by (meson \<open>U \<in> \<S>\<close> sub Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1722
        have "range \<sigma> \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1723
          using \<open>U \<in> \<S>\<close> \<open>range \<sigma> \<subseteq> \<Inter> \<S>\<close> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1724
        moreover have "Metric_space.mcomplete U d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1725
          by (simp add: \<open>U \<in> \<S>\<close> comp)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1726
        ultimately obtain x' where x': "limitin SU.sub.mtopology \<sigma> x' sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1727
          using MCauchy_def SU.sub.MCauchy_def SU.sub.mcomplete_alt \<open>MCauchy \<sigma>\<close> by meson 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1728
        have "x' = x"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1729
        proof (intro limitin_metric_unique)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1730
          show "limitin mtopology \<sigma> x' sequentially"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1731
            by (meson SU.Submetric_axioms Submetric.limitin_submetric_iff x')
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1732
          show "limitin mtopology \<sigma> x sequentially"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1733
            by (meson SA.Submetric_axioms Submetric.limitin_submetric_iff x)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1734
        qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1735
        then show "x \<in> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1736
          using SU.sub.limitin_mspace x' by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1737
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1738
      show "\<forall>\<^sub>F n in sequentially. \<sigma> n \<in> \<Inter>\<S>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1739
        by (meson \<open>range \<sigma> \<subseteq> \<Inter> \<S>\<close> always_eventually range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1740
      show "limitin mtopology \<sigma> x sequentially"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1741
        by (meson SA.Submetric_axioms Submetric.limitin_submetric_iff x)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1742
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1743
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1744
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1745
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1746
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1747
lemma mcomplete_Int:
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1748
  assumes A: "Submetric M d A" "Metric_space.mcomplete A d" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1749
      and B: "Submetric M d B" "Metric_space.mcomplete B d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1750
    shows   "Submetric M d (A \<inter> B)" "Metric_space.mcomplete (A \<inter> B) d"
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1751
  using mcomplete_Inter [of "{A,B}"] assms by force+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1752
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1753
subsection\<open>Totally bounded subsets of metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1754
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1755
definition mtotally_bounded 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1756
  where "mtotally_bounded S \<equiv> \<forall>\<epsilon>>0. \<exists>K. finite K \<and> K \<subseteq> S \<and> S \<subseteq> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1757
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1758
lemma mtotally_bounded_empty [iff]: "mtotally_bounded {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1759
by (simp add: mtotally_bounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1760
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1761
lemma finite_imp_mtotally_bounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1762
   "\<lbrakk>finite S; S \<subseteq> M\<rbrakk> \<Longrightarrow> mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1763
  by (auto simp: mtotally_bounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1764
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1765
lemma mtotally_bounded_imp_subset: "mtotally_bounded S \<Longrightarrow> S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1766
  by (force simp: mtotally_bounded_def intro!: zero_less_one)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1767
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1768
lemma mtotally_bounded_sing [simp]:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1769
   "mtotally_bounded {x} \<longleftrightarrow> x \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1770
  by (meson empty_subsetI finite.simps finite_imp_mtotally_bounded insert_subset mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1771
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1772
lemma mtotally_bounded_Un:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1773
  assumes  "mtotally_bounded S" "mtotally_bounded T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1774
  shows "mtotally_bounded (S \<union> T)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1775
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1776
  have "\<exists>K. finite K \<and> K \<subseteq> S \<union> T \<and> S \<union> T \<subseteq> (\<Union>x\<in>K. mball x e)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1777
    if  "e>0" and K: "finite K \<and> K \<subseteq> S \<and> S \<subseteq> (\<Union>x\<in>K. mball x e)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1778
      and L: "finite L \<and> L \<subseteq> T \<and> T \<subseteq> (\<Union>x\<in>L. mball x e)" for K L e
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1779
    using that by (rule_tac x="K \<union> L" in exI) auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1780
  with assms show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1781
    unfolding mtotally_bounded_def by presburger
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1782
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1783
 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1784
lemma mtotally_bounded_Union:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1785
  assumes "finite f" "\<And>S. S \<in> f \<Longrightarrow> mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1786
  shows "mtotally_bounded (\<Union>f)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1787
  using assms by (induction f) (auto simp: mtotally_bounded_Un)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1788
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1789
lemma mtotally_bounded_imp_mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1790
  assumes "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1791
  shows "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1792
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1793
  obtain K where "finite K \<and> K \<subseteq> S \<and> S \<subseteq> (\<Union>x\<in>K. mball x 1)" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1794
    using assms by (force simp: mtotally_bounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1795
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1796
    by (smt (verit) finite_imageI image_iff mbounded_Union mbounded_mball mbounded_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1797
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1798
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1799
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1800
lemma mtotally_bounded_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1801
  "mtotally_bounded S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1802
    S \<subseteq> M \<and> (\<forall>\<sigma>::nat \<Rightarrow> 'a. range \<sigma> \<subseteq> S \<longrightarrow> (\<exists>r. strict_mono r \<and> MCauchy (\<sigma> \<circ> r)))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1803
  (is "_ \<longleftrightarrow> _ \<and> ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1804
proof (cases "S \<subseteq> M")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1805
  case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1806
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1807
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1808
    { fix \<sigma> :: "nat \<Rightarrow> 'a"                                                            
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1809
      assume L: "mtotally_bounded S" and \<sigma>: "range \<sigma> \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1810
      have "\<exists>j > i. d (\<sigma> i) (\<sigma> j) < 3*\<epsilon>/2 \<and> infinite (\<sigma> -` mball (\<sigma> j) (\<epsilon>/2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1811
        if inf: "infinite (\<sigma> -` mball (\<sigma> i) \<epsilon>)" and "\<epsilon> > 0" for i \<epsilon>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1812
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1813
        obtain K where "finite K" "K \<subseteq> S" and K: "S \<subseteq> (\<Union>x\<in>K. mball x (\<epsilon>/4))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1814
          by (metis L mtotally_bounded_def \<open>\<epsilon> > 0\<close> zero_less_divide_iff zero_less_numeral)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1815
        then have K_imp_ex: "\<And>y. y \<in> S \<Longrightarrow> \<exists>x\<in>K. d x y < \<epsilon>/4"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1816
          by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1817
        have False if "\<forall>x\<in>K. d x (\<sigma> i) < \<epsilon> + \<epsilon>/4 \<longrightarrow> finite (\<sigma> -` mball x (\<epsilon>/4))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1818
        proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1819
          have "\<exists>w. w \<in> K \<and> d w (\<sigma> i) < 5 * \<epsilon>/4 \<and> d w (\<sigma> j) < \<epsilon>/4"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1820
            if "d (\<sigma> i) (\<sigma> j) < \<epsilon>" for j
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1821
          proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1822
            obtain w where w: "d w (\<sigma> j) < \<epsilon>/4" "w \<in> K"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1823
              using K_imp_ex \<sigma> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1824
            then have "d w (\<sigma> i) < \<epsilon> + \<epsilon>/4"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1825
              by (smt (verit, ccfv_SIG) True \<open>K \<subseteq> S\<close> \<sigma> rangeI subset_eq that triangle')
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1826
            with w show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1827
              using in_mball by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1828
          qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1829
          then have "(\<sigma> -` mball (\<sigma> i) \<epsilon>) \<subseteq> (\<Union>x\<in>K. if d x (\<sigma> i) < \<epsilon> + \<epsilon>/4 then \<sigma> -` mball x (\<epsilon>/4) else {})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1830
            using True \<open>K \<subseteq> S\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1831
          then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1832
            using finite_subset inf \<open>finite K\<close> that by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1833
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1834
        then obtain x where "x \<in> K" and dxi: "d x (\<sigma> i) < \<epsilon> + \<epsilon>/4" and infx: "infinite (\<sigma> -` mball x (\<epsilon>/4))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1835
          by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1836
        then obtain j where "j \<in> (\<sigma> -` mball x (\<epsilon>/4)) - {..i}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1837
          using bounded_nat_set_is_finite by (meson Diff_infinite_finite finite_atMost)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1838
        then have "j > i" and dxj: "d x (\<sigma> j) < \<epsilon>/4" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1839
          by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1840
        have "(\<sigma> -` mball x (\<epsilon>/4)) \<subseteq> (\<sigma> -` mball y (\<epsilon>/2))" if "d x y < \<epsilon>/4" "y \<in> M" for y
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1841
          using that by (simp add: mball_subset vimage_mono)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1842
        then have infj: "infinite (\<sigma> -` mball (\<sigma> j) (\<epsilon>/2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1843
          by (meson True \<open>d x (\<sigma> j) < \<epsilon>/4\<close> \<sigma> in_mono infx rangeI finite_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1844
        have "\<sigma> i \<in> M" "\<sigma> j \<in> M" "x \<in> M"  
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1845
          using True \<open>K \<subseteq> S\<close> \<open>x \<in> K\<close> \<sigma> by force+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1846
        then have "d (\<sigma> i) (\<sigma> j) \<le> d x (\<sigma> i) + d x (\<sigma> j)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1847
          using triangle'' by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1848
        also have "\<dots> < 3*\<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1849
          using dxi dxj by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1850
        finally have "d (\<sigma> i) (\<sigma> j) < 3*\<epsilon>/2" .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1851
        with \<open>i < j\<close> infj show ?thesis by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1852
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1853
      then obtain nxt where nxt: "\<And>i \<epsilon>. \<lbrakk>\<epsilon> > 0; infinite (\<sigma> -` mball (\<sigma> i) \<epsilon>)\<rbrakk> \<Longrightarrow> 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1854
                 nxt i \<epsilon> > i \<and> d (\<sigma> i) (\<sigma> (nxt i \<epsilon>)) < 3*\<epsilon>/2 \<and> infinite (\<sigma> -` mball (\<sigma> (nxt i \<epsilon>)) (\<epsilon>/2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1855
        by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1856
      have "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1857
        using L by (simp add: mtotally_bounded_imp_mbounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1858
      then obtain B where B: "\<forall>y \<in> S. d (\<sigma> 0) y \<le> B" and "B > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1859
        by (meson \<sigma> mbounded_alt_pos range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1860
      define eps where "eps \<equiv> \<lambda>n. (B+1) / 2^n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1861
      have [simp]: "eps (Suc n) = eps n / 2" "eps n > 0" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1862
        using \<open>B > 0\<close> by (auto simp: eps_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1863
      have "UNIV \<subseteq> \<sigma> -` mball (\<sigma> 0) (B+1)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1864
        using B True \<sigma> unfolding image_iff subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1865
        by (smt (verit, best) UNIV_I in_mball vimageI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1866
      then have inf0: "infinite (\<sigma> -` mball (\<sigma> 0) (eps 0))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1867
        using finite_subset by (auto simp: eps_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1868
      define r where "r \<equiv> rec_nat 0 (\<lambda>n rec. nxt rec (eps n))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1869
      have [simp]: "r 0 = 0" "r (Suc n) = nxt (r n) (eps n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1870
        by (auto simp: r_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1871
      have \<sigma>rM[simp]: "\<sigma> (r n) \<in> M" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1872
        using True \<sigma> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1873
      have inf: "infinite (\<sigma> -` mball (\<sigma> (r n)) (eps n))" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1874
      proof (induction n)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1875
        case 0 then show ?case  
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1876
          by (simp add: inf0)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1877
      next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1878
        case (Suc n) then show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1879
          using nxt [of "eps n" "r n"] by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1880
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1881
      then have "r (Suc n) > r n" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1882
        by (simp add: nxt)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1883
      then have "strict_mono r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1884
        by (simp add: strict_mono_Suc_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1885
      have d_less: "d (\<sigma> (r n)) (\<sigma> (r (Suc n))) < 3 * eps n / 2" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1886
        using nxt [OF _ inf] by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1887
      have eps_plus: "eps (k + n) = eps n * (1/2)^k" for k n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1888
        by (simp add: eps_def power_add field_simps)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1889
      have *: "d (\<sigma> (r n)) (\<sigma> (r (k + n))) < 3 * eps n" for n k
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1890
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1891
        have "d (\<sigma> (r n)) (\<sigma> (r (k+n))) \<le> 3/2 * eps n * (\<Sum>i<k. (1/2)^i)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1892
        proof (induction k)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1893
          case 0 then show ?case 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1894
            by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1895
        next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1896
          case (Suc k)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1897
          have "d (\<sigma> (r n)) (\<sigma> (r (Suc k + n))) \<le> d (\<sigma> (r n)) (\<sigma> (r (k + n))) + d (\<sigma> (r (k + n))) (\<sigma> (r (Suc (k + n))))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1898
            by (metis \<sigma>rM add.commute add_Suc_right triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1899
          with d_less[of "k+n"] Suc show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1900
            by (simp add: algebra_simps eps_plus)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1901
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1902
        also have "\<dots> < 3/2 * eps n * 2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1903
          using geometric_sum [of "1/2::real" k] by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1904
        finally show ?thesis by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1905
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1906
      have "\<exists>N. \<forall>n\<ge>N. \<forall>n'\<ge>N. d (\<sigma> (r n)) (\<sigma> (r n')) < \<epsilon>" if "\<epsilon> > 0" for \<epsilon>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1907
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1908
        define N where "N \<equiv> nat \<lceil>(log 2 (6*(B+1) / \<epsilon>))\<rceil>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1909
        have \<section>: "b \<le> 2 ^ nat \<lceil>log 2 b\<rceil>" for b
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1910
          by (smt (verit) less_log_of_power real_nat_ceiling_ge)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1911
        have N: "6 * eps N \<le> \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1912
          using \<section> [of "(6*(B+1) / \<epsilon>)"] that by (auto simp: N_def eps_def field_simps)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1913
        have "d (\<sigma> (r N)) (\<sigma> (r n)) < 3 * eps N" if "n \<ge> N" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1914
          by (metis * add.commute nat_le_iff_add that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1915
        then have "\<forall>n\<ge>N. \<forall>n'\<ge>N. d (\<sigma> (r n)) (\<sigma> (r n')) < 3 * eps N + 3 * eps N"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1916
          by (smt (verit, best) \<sigma>rM triangle'')
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1917
        with N show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1918
          by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1919
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1920
      then have "MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1921
        unfolding MCauchy_def using True \<sigma> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1922
      then have "\<exists>r. strict_mono r \<and> MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1923
        using \<open>strict_mono r\<close> by blast      
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1924
    }
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1925
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1926
    { assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1927
      have "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1928
        unfolding mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1929
      proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1930
        fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1931
        assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1932
        have False if \<section>: "\<And>K. \<lbrakk>finite K; K \<subseteq> S\<rbrakk> \<Longrightarrow> \<exists>s\<in>S. s \<notin> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1933
        proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1934
          obtain f where f: "\<And>K. \<lbrakk>finite K; K \<subseteq> S\<rbrakk> \<Longrightarrow> f K \<in> S \<and> f K \<notin> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1935
            using \<section> by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1936
          define \<sigma> where "\<sigma> \<equiv> wfrec less_than (\<lambda>seq n. f (seq ` {..<n}))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1937
          have \<sigma>_eq: "\<sigma> n = f (\<sigma> ` {..<n})" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1938
            by (simp add: cut_apply def_wfrec [OF \<sigma>_def])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1939
          have [simp]: "\<sigma> n \<in> S" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1940
            using wf_less_than
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1941
          proof (induction n rule: wf_induct_rule)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1942
            case (less n) with f show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1943
              by (auto simp: \<sigma>_eq [of n])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1944
          qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1945
          then have "range \<sigma> \<subseteq> S" by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1946
          have \<sigma>: "p < n \<Longrightarrow> \<epsilon> \<le> d (\<sigma> p) (\<sigma> n)" for n p
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1947
            using f[of "\<sigma> ` {..<n}"] True by (fastforce simp: \<sigma>_eq [of n] Ball_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1948
          then obtain r where "strict_mono r" "MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1949
            by (meson R \<open>range \<sigma> \<subseteq> S\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1950
          with \<open>0 < \<epsilon>\<close> obtain N 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1951
            where N: "\<And>n n'. \<lbrakk>n\<ge>N; n'\<ge>N\<rbrakk> \<Longrightarrow> d (\<sigma> (r n)) (\<sigma> (r n')) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1952
            by (force simp: MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1953
          show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1954
            using N [of N "Suc (r N)"] \<open>strict_mono r\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1955
            by (smt (verit) Suc_le_eq \<sigma> le_SucI order_refl strict_mono_imp_increasing)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1956
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1957
        then show "\<exists>K. finite K \<and> K \<subseteq> S \<and> S \<subseteq> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1958
          by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1959
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1960
    }
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1961
    ultimately show ?thesis 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1962
      using True by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1963
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1964
qed (use mtotally_bounded_imp_subset in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1965
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1966
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1967
lemma mtotally_bounded_subset:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1968
   "\<lbrakk>mtotally_bounded S; T \<subseteq> S\<rbrakk> \<Longrightarrow> mtotally_bounded T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1969
  by (meson mtotally_bounded_sequentially order_trans) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1970
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1971
lemma mtotally_bounded_submetric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1972
  assumes "mtotally_bounded S" "S \<subseteq> T" "T \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1973
  shows "Metric_space.mtotally_bounded T d S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1974
proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1975
  interpret Submetric M d T
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1976
    using \<open>T \<subseteq> M\<close> by unfold_locales
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1977
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1978
    using assms
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1979
    unfolding sub.mtotally_bounded_def mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1980
    by (force simp: subset_iff elim!: all_forward ex_forward)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1981
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1982
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1983
lemma mtotally_bounded_absolute:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1984
   "mtotally_bounded S \<longleftrightarrow> S \<subseteq> M \<and> Metric_space.mtotally_bounded S d S "
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1985
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1986
  have "mtotally_bounded S" if "S \<subseteq> M" "Metric_space.mtotally_bounded S d S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1987
  proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1988
    interpret Submetric M d S
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1989
      using \<open>S \<subseteq> M\<close> by unfold_locales
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1990
    show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1991
      using that
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1992
      by (meson MCauchy_submetric mtotally_bounded_sequentially sub.mtotally_bounded_sequentially)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1993
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1994
  moreover have "mtotally_bounded S \<Longrightarrow> Metric_space.mtotally_bounded S d S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1995
    by (simp add: mtotally_bounded_imp_subset mtotally_bounded_submetric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1996
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1997
    using mtotally_bounded_imp_subset by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1998
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1999
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2000
lemma mtotally_bounded_closure_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2001
  assumes "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2002
  shows "mtotally_bounded (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2003
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2004
  have "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2005
    by (simp add: assms mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2006
  have "mtotally_bounded(mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2007
    unfolding mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2008
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2009
    fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2010
    assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2011
    then obtain K where "finite K" "K \<subseteq> S" and K: "S \<subseteq> (\<Union>x\<in>K. mball x (\<epsilon>/2))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2012
      by (metis assms mtotally_bounded_def half_gt_zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2013
    have "mtopology closure_of S \<subseteq> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2014
      unfolding metric_closure_of
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2015
    proof clarsimp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2016
      fix x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2017
      assume "x \<in> M" and x: "\<forall>r>0. \<exists>y\<in>S. y \<in> M \<and> d x y < r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2018
      then obtain y where "y \<in> S" and y: "d x y < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2019
        using \<open>0 < \<epsilon>\<close> half_gt_zero by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2020
      then obtain x' where "x' \<in> K" "y \<in> mball x' (\<epsilon>/2)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2021
        using K by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2022
      then have "d x' x < \<epsilon>/2 + \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2023
        using triangle y \<open>x \<in> M\<close> commute by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2024
      then show "\<exists>x'\<in>K. x' \<in> M \<and> d x' x < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2025
        using \<open>K \<subseteq> S\<close> \<open>S \<subseteq> M\<close> \<open>x' \<in> K\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2026
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2027
    then show "\<exists>K. finite K \<and> K \<subseteq> mtopology closure_of S \<and> mtopology closure_of S \<subseteq> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2028
      using closure_of_subset_Int  \<open>K \<subseteq> S\<close> \<open>finite K\<close> K by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2029
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2030
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2031
    by (simp add: assms inf.absorb2 mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2032
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2033
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2034
lemma mtotally_bounded_closure_of_eq:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2035
   "S \<subseteq> M \<Longrightarrow> mtotally_bounded (mtopology closure_of S) \<longleftrightarrow> mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2036
  by (metis closure_of_subset mtotally_bounded_closure_of mtotally_bounded_subset topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2037
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2038
lemma mtotally_bounded_cauchy_sequence:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2039
  assumes "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2040
  shows "mtotally_bounded (range \<sigma>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2041
  unfolding MCauchy_def mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2042
proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2043
  fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2044
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2045
  then obtain N where "\<And>n. N \<le> n \<Longrightarrow> d (\<sigma> N) (\<sigma> n) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2046
    using assms by (force simp: MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2047
  then have "\<And>m. \<exists>n\<le>N. \<sigma> n \<in> M \<and> \<sigma> m \<in> M \<and> d (\<sigma> n) (\<sigma> m) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2048
    by (metis MCauchy_def assms mdist_zero nle_le range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2049
  then
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2050
  show "\<exists>K. finite K \<and> K \<subseteq> range \<sigma> \<and> range \<sigma> \<subseteq> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2051
    by (rule_tac x="\<sigma> ` {0..N}" in exI) force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2052
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2053
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2054
lemma MCauchy_imp_mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2055
   "MCauchy \<sigma> \<Longrightarrow> mbounded (range \<sigma>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2056
  by (simp add: mtotally_bounded_cauchy_sequence mtotally_bounded_imp_mbounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2057
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2058
subsection\<open>Compactness in metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2059
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2060
lemma Bolzano_Weierstrass_property:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2061
  assumes "S \<subseteq> U" "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2062
  shows
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2063
   "(\<forall>\<sigma>::nat\<Rightarrow>'a. range \<sigma> \<subseteq> S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2064
         \<longrightarrow> (\<exists>l r. l \<in> U \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially)) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2065
    (\<forall>T. T \<subseteq> S \<and> infinite T \<longrightarrow> U \<inter> mtopology derived_set_of T \<noteq> {})"  (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2066
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2067
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2068
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2069
  proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2070
    fix T
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2071
    assume "T \<subseteq> S" and "infinite T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2072
      and T: "U \<inter> mtopology derived_set_of T = {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2073
    then obtain \<sigma> :: "nat\<Rightarrow>'a" where "inj \<sigma>" "range \<sigma> \<subseteq> T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2074
      by (meson infinite_countable_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2075
    with L obtain l r where "l \<in> U" "strict_mono r" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2076
           and lr: "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2077
      by (meson \<open>T \<subseteq> S\<close> subset_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2078
    then obtain \<epsilon> where "\<epsilon> > 0" and \<epsilon>: "\<And>y. y \<in> T \<Longrightarrow> y = l \<or> \<not> d l y < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2079
      using T \<open>T \<subseteq> S\<close> \<open>S \<subseteq> M\<close> 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2080
      by (force simp: metric_derived_set_of limitin_metric disjoint_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2081
    with lr have "\<forall>\<^sub>F n in sequentially. \<sigma> (r n) \<in> M \<and> d (\<sigma> (r n)) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2082
      by (auto simp: limitin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2083
    then obtain N where N: "d (\<sigma> (r N)) l < \<epsilon>" "d (\<sigma> (r (Suc N))) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2084
      using less_le_not_le by (auto simp: eventually_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2085
    moreover have "\<sigma> (r N) \<noteq> l \<or> \<sigma> (r (Suc N)) \<noteq> l"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2086
      by (meson \<open>inj \<sigma>\<close> \<open>strict_mono r\<close> injD n_not_Suc_n strict_mono_eq)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2087
    ultimately
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2088
    show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2089
       using \<epsilon> \<open>range \<sigma> \<subseteq> T\<close> commute by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2090
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2091
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2092
  assume R: ?rhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2093
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2094
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2095
    fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2096
    assume "range \<sigma> \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2097
    show "\<exists>l r. l \<in> U \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2098
    proof (cases "finite (range \<sigma>)")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2099
      case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2100
      then obtain m where "infinite (\<sigma> -` {\<sigma> m})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2101
        by (metis image_iff inf_img_fin_dom nat_not_finite)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2102
      then obtain r where [iff]: "strict_mono r" and r: "\<And>n::nat. r n \<in> \<sigma> -` {\<sigma> m}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2103
        using infinite_enumerate by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2104
      have [iff]: "\<sigma> m \<in> U" "\<sigma> m \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2105
        using \<open>range \<sigma> \<subseteq> S\<close> assms by blast+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2106
      show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2107
      proof (intro conjI exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2108
        show "limitin mtopology (\<sigma> \<circ> r) (\<sigma> m) sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2109
          using r by (simp add: limitin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2110
      qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2111
    next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2112
      case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2113
      then obtain l where "l \<in> U" and l: "l \<in> mtopology derived_set_of (range \<sigma>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2114
        by (meson R \<open>range \<sigma> \<subseteq> S\<close> disjoint_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2115
      then obtain g where g: "\<And>\<epsilon>. \<epsilon>>0 \<Longrightarrow> \<sigma> (g \<epsilon>) \<noteq> l \<and> d l (\<sigma> (g \<epsilon>)) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2116
        by (simp add: metric_derived_set_of) metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2117
      have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2118
        using \<open>range \<sigma> \<subseteq> S\<close> assms by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2119
      have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2120
        using l metric_derived_set_of by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2121
      define E where  \<comment>\<open>a construction to ensure monotonicity\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2122
        "E \<equiv> \<lambda>rec n. insert (inverse (Suc n)) ((\<lambda>i. d l (\<sigma> i)) ` (\<Union>k<n. {0..rec k})) - {0}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2123
      define r where "r \<equiv> wfrec less_than (\<lambda>rec n. g (Min (E rec n)))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2124
      have "(\<Union>k<n. {0..cut r less_than n k}) = (\<Union>k<n. {0..r k})" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2125
        by (auto simp: cut_apply)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2126
      then have r_eq: "r n = g (Min (E r n))" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2127
        by (metis E_def def_wfrec [OF r_def] wf_less_than)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2128
      have dl_pos[simp]: "d l (\<sigma> (r n)) > 0" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2129
        using wf_less_than
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2130
      proof (induction n rule: wf_induct_rule)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2131
        case (less n) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2132
        then have *: "Min (E r n) > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2133
          using \<open>l \<in> M\<close> \<open>range \<sigma> \<subseteq> M\<close> by (auto simp: E_def image_subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2134
        show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2135
          using g [OF *] r_eq [of n]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2136
          by (metis \<open>l \<in> M\<close> \<open>range \<sigma> \<subseteq> M\<close> mdist_pos_less range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2137
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2138
      then have non_l: "\<sigma> (r n) \<noteq> l" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2139
        using \<open>range \<sigma> \<subseteq> M\<close> mdist_pos_eq by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2140
      have Min_pos: "Min (E r n) > 0" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2141
        using dl_pos \<open>l \<in> M\<close> \<open>range \<sigma> \<subseteq> M\<close> by (auto simp: E_def image_subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2142
      have d_small: "d (\<sigma>(r n)) l < inverse(Suc n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2143
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2144
        have "d (\<sigma>(r n)) l < Min (E r n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2145
          by (simp add: \<open>0 < Min (E r n)\<close> commute g r_eq) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2146
        also have "... \<le> inverse(Suc n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2147
          by (simp add: E_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2148
        finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2149
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2150
      have d_lt_d: "d l (\<sigma> (r n)) < d l (\<sigma> i)" if \<section>: "p < n" "i \<le> r p" "\<sigma> i \<noteq> l" for i p n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2151
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2152
        have 1: "d l (\<sigma> i) \<in> E r n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2153
          using \<section> \<open>l \<in> M\<close> \<open>range \<sigma> \<subseteq> M\<close> 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2154
          by (force simp: E_def image_subset_iff image_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2155
        have "d l (\<sigma> (g (Min (E r n)))) < Min (E r n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2156
          by (rule conjunct2 [OF g [OF Min_pos]])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2157
        also have "Min (E r n) \<le> d l (\<sigma> i)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2158
          using 1 unfolding E_def by (force intro!: Min.coboundedI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2159
        finally show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2160
          by (simp add: r_eq) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2161
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2162
      have r: "r p < r n" if "p < n" for p n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2163
        using d_lt_d [OF that] non_l by (meson linorder_not_le order_less_irrefl) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2164
      show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2165
      proof (intro exI conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2166
        show "strict_mono r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2167
          by (simp add: r strict_monoI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2168
        show "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2169
          unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2170
        proof (intro conjI strip \<open>l \<in> M\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2171
          fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2172
          assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2173
          then have "\<forall>\<^sub>F n in sequentially. inverse(Suc n) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2174
            using Archimedean_eventually_inverse by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2175
          then show "\<forall>\<^sub>F n in sequentially. (\<sigma> \<circ> r) n \<in> M \<and> d ((\<sigma> \<circ> r) n) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2176
            by (smt (verit) \<open>range \<sigma> \<subseteq> M\<close> commute comp_apply d_small eventually_mono range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2177
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2178
      qed (use \<open>l \<in> U\<close> in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2179
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2180
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2181
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2182
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2183
subsubsection \<open>More on Bolzano Weierstrass\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2184
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2185
lemma Bolzano_Weierstrass_A: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2186
  assumes "compactin mtopology S" "T \<subseteq> S" "infinite T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2187
  shows "S \<inter> mtopology derived_set_of T \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2188
  by (simp add: assms compactin_imp_Bolzano_Weierstrass)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2189
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2190
lemma Bolzano_Weierstrass_B:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2191
  fixes \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2192
  assumes "S \<subseteq> M" "range \<sigma> \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2193
    and "\<And>T. \<lbrakk>T \<subseteq> S \<and> infinite T\<rbrakk> \<Longrightarrow> S \<inter> mtopology derived_set_of T \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2194
  shows "\<exists>l r. l \<in> S \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2195
  using Bolzano_Weierstrass_property assms by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2196
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2197
lemma Bolzano_Weierstrass_C:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2198
  assumes "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2199
  assumes "\<And>\<sigma>:: nat \<Rightarrow> 'a. range \<sigma> \<subseteq> S \<Longrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2200
                (\<exists>l r. l \<in> S \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2201
  shows "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2202
  unfolding mtotally_bounded_sequentially
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2203
  by (metis convergent_imp_MCauchy assms image_comp image_mono subset_UNIV subset_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2204
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2205
lemma Bolzano_Weierstrass_D:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2206
  assumes "S \<subseteq> M" "S \<subseteq> \<Union>\<C>" and opeU: "\<And>U. U \<in> \<C> \<Longrightarrow> openin mtopology U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2207
  assumes \<section>: "(\<forall>\<sigma>::nat\<Rightarrow>'a. range \<sigma> \<subseteq> S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2208
         \<longrightarrow> (\<exists>l r. l \<in> S \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2209
  shows "\<exists>\<epsilon>>0. \<forall>x \<in> S. \<exists>U \<in> \<C>. mball x \<epsilon> \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2210
proof (rule ccontr)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2211
  assume "\<not> (\<exists>\<epsilon>>0. \<forall>x \<in> S. \<exists>U \<in> \<C>. mball x \<epsilon> \<subseteq> U)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2212
  then have "\<forall>n. \<exists>x\<in>S. \<forall>U\<in>\<C>. \<not> mball x (inverse (Suc n)) \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2213
    by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2214
  then obtain \<sigma> where "\<And>n. \<sigma> n \<in> S" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2215
       and \<sigma>: "\<And>n U. U \<in> \<C> \<Longrightarrow> \<not> mball (\<sigma> n) (inverse (Suc n)) \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2216
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2217
  then obtain l r where "l \<in> S" "strict_mono r" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2218
         and lr: "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2219
    by (meson \<section> image_subsetI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2220
  with \<open>S \<subseteq> \<Union>\<C>\<close> obtain B where "l \<in> B" "B \<in> \<C>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2221
    by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2222
  then obtain \<epsilon> where "\<epsilon> > 0" and \<epsilon>: "\<And>z. \<lbrakk>z \<in> M; d z l < \<epsilon>\<rbrakk> \<Longrightarrow> z \<in> B"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2223
    by (metis opeU [OF \<open>B \<in> \<C>\<close>] commute in_mball openin_mtopology subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2224
  then have "\<forall>\<^sub>F n in sequentially. \<sigma> (r n) \<in> M \<and> d (\<sigma> (r n)) l < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2225
    using lr half_gt_zero unfolding limitin_metric o_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2226
  moreover have "\<forall>\<^sub>F n in sequentially. inverse (real (Suc n)) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2227
    using Archimedean_eventually_inverse \<open>0 < \<epsilon>\<close> half_gt_zero by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2228
  ultimately obtain n where n: "d (\<sigma> (r n)) l < \<epsilon>/2" "inverse (real (Suc n)) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2229
    by (smt (verit, del_insts) eventually_sequentially le_add1 le_add2)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2230
  have "x \<in> B" if "d (\<sigma> (r n)) x < inverse (Suc(r n))" "x \<in> M" for x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2231
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2232
    have rle: "inverse (real (Suc (r n))) \<le> inverse (real (Suc n))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2233
      using \<open>strict_mono r\<close> strict_mono_imp_increasing by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2234
    have "d x l \<le> d (\<sigma> (r n)) x + d (\<sigma> (r n)) l"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2235
      using that by (metis triangle \<open>\<And>n. \<sigma> n \<in> S\<close> \<open>l \<in> S\<close> \<open>S \<subseteq> M\<close> commute subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2236
    also have "... < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2237
      using that n rle by linarith
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2238
    finally show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2239
      by (simp add: \<epsilon> that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2240
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2241
  then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2242
    using \<sigma> [of B "r n"] by (simp add: \<open>B \<in> \<C>\<close> subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2243
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2244
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2245
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2246
lemma Bolzano_Weierstrass_E:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2247
  assumes "mtotally_bounded S" "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2248
  and S: "\<And>\<C>. \<lbrakk>\<And>U. U \<in> \<C> \<Longrightarrow> openin mtopology U; S \<subseteq> \<Union>\<C>\<rbrakk> \<Longrightarrow> \<exists>\<epsilon>>0. \<forall>x \<in> S. \<exists>U \<in> \<C>. mball x \<epsilon> \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2249
  shows "compactin mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2250
proof (clarsimp simp: compactin_def assms)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2251
  fix \<U> :: "'a set set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2252
  assume \<U>: "\<forall>x\<in>\<U>. openin mtopology x" and "S \<subseteq> \<Union>\<U>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2253
  then obtain \<epsilon> where "\<epsilon>>0" and \<epsilon>: "\<And>x. x \<in> S \<Longrightarrow> \<exists>U \<in> \<U>. mball x \<epsilon> \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2254
    by (metis S)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2255
  then obtain f where f: "\<And>x. x \<in> S \<Longrightarrow> f x \<in> \<U> \<and> mball x \<epsilon> \<subseteq> f x"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2256
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2257
  then obtain K where "finite K" "K \<subseteq> S" and K: "S \<subseteq> (\<Union>x\<in>K. mball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2258
    by (metis \<open>0 < \<epsilon>\<close> \<open>mtotally_bounded S\<close> mtotally_bounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2259
  show "\<exists>\<F>. finite \<F> \<and> \<F> \<subseteq> \<U> \<and> S \<subseteq> \<Union>\<F>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2260
  proof (intro conjI exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2261
    show "finite (f ` K)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2262
      by (simp add: \<open>finite K\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2263
    show "f ` K \<subseteq> \<U>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2264
      using \<open>K \<subseteq> S\<close> f by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2265
    show "S \<subseteq> \<Union>(f ` K)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2266
      using K \<open>K \<subseteq> S\<close> by (force dest: f)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2267
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2268
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2269
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2270
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2271
lemma compactin_eq_Bolzano_Weierstrass:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2272
  "compactin mtopology S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2273
   S \<subseteq> M \<and> (\<forall>T. T \<subseteq> S \<and> infinite T \<longrightarrow> S \<inter> mtopology derived_set_of T \<noteq> {})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2274
  using Bolzano_Weierstrass_C Bolzano_Weierstrass_D Bolzano_Weierstrass_E
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2275
  by (smt (verit, del_insts) Bolzano_Weierstrass_property compactin_imp_Bolzano_Weierstrass compactin_subspace subset_refl topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2276
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2277
lemma compactin_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2278
  shows "compactin mtopology S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2279
        S \<subseteq> M \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2280
        ((\<forall>\<sigma>::nat\<Rightarrow>'a. range \<sigma> \<subseteq> S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2281
         \<longrightarrow> (\<exists>l r. l \<in> S \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially)))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2282
  by (metis Bolzano_Weierstrass_property compactin_eq_Bolzano_Weierstrass subset_refl)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2283
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2284
lemma compactin_imp_mtotally_bounded: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2285
  "compactin mtopology S \<Longrightarrow> mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2286
  by (simp add: Bolzano_Weierstrass_C compactin_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2287
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2288
lemma lebesgue_number:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2289
    "\<lbrakk>compactin mtopology S; S \<subseteq> \<Union>\<C>; \<And>U. U \<in> \<C> \<Longrightarrow> openin mtopology U\<rbrakk>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2290
    \<Longrightarrow> \<exists>\<epsilon>>0. \<forall>x \<in> S. \<exists>U \<in> \<C>. mball x \<epsilon> \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2291
  by (simp add: Bolzano_Weierstrass_D compactin_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2292
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2293
lemma compact_space_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2294
   "compact_space mtopology \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2295
    (\<forall>\<sigma>::nat\<Rightarrow>'a. range \<sigma> \<subseteq> M
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2296
         \<longrightarrow> (\<exists>l r. l \<in> M \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2297
  by (simp add: compact_space_def compactin_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2298
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2299
lemma compact_space_eq_Bolzano_Weierstrass:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2300
   "compact_space mtopology \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2301
    (\<forall>S. S \<subseteq> M \<and> infinite S \<longrightarrow> mtopology derived_set_of S \<noteq> {})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2302
  using Int_absorb1 [OF derived_set_of_subset_topspace [of mtopology]]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2303
  by (force simp: compact_space_def compactin_eq_Bolzano_Weierstrass)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2304
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2305
lemma compact_space_nest:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2306
   "compact_space mtopology \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2307
    (\<forall>C. (\<forall>n::nat. closedin mtopology (C n)) \<and> (\<forall>n. C n \<noteq> {}) \<and> decseq C \<longrightarrow> \<Inter>(range C) \<noteq> {})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2308
   (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2309
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2310
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2311
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2312
  proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2313
    fix C :: "nat \<Rightarrow> 'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2314
    assume "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2315
      and "\<forall>n. C n \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2316
      and "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2317
      and "\<Inter> (range C) = {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2318
    then obtain K where K: "finite K" "\<Inter>(C ` K) = {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2319
      by (metis L compact_space_imp_nest)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2320
    then obtain k where "K \<subseteq> {..k}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2321
      using finite_nat_iff_bounded_le by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2322
    then have "C k \<subseteq> \<Inter>(C ` K)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2323
      using \<open>decseq C\<close> by (auto simp:decseq_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2324
    then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2325
      by (simp add: K \<open>\<forall>n. C n \<noteq> {}\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2326
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2327
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2328
  assume R [rule_format]: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2329
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2330
    unfolding compact_space_sequentially
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2331
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2332
    fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2333
    assume \<sigma>: "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2334
    have "mtopology closure_of \<sigma> ` {n..} \<noteq> {}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2335
      using \<open>range \<sigma> \<subseteq> M\<close> by (auto simp: closure_of_eq_empty image_subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2336
    moreover have "decseq (\<lambda>n. mtopology closure_of \<sigma> ` {n..})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2337
      using closure_of_mono image_mono by (smt (verit) atLeast_subset_iff decseq_def) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2338
    ultimately obtain l where l: "\<And>n. l \<in> mtopology closure_of \<sigma> ` {n..}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2339
      using R [of "\<lambda>n. mtopology closure_of (\<sigma> ` {n..})"] by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2340
    then have "l \<in> M" and "\<And>n. \<forall>r>0. \<exists>k\<ge>n. \<sigma> k \<in> M \<and> d l (\<sigma> k) < r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2341
      using metric_closure_of by fastforce+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2342
    then obtain f where f: "\<And>n r. r>0 \<Longrightarrow> f n r \<ge> n \<and> \<sigma> (f n r) \<in> M \<and> d l (\<sigma> (f n r)) < r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2343
      by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2344
    define r where "r = rec_nat (f 0 1) (\<lambda>n rec. (f (Suc rec) (inverse (Suc (Suc n)))))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2345
    have r: "d l (\<sigma>(r n)) < inverse(Suc n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2346
      by (induction n) (auto simp: rec_nat_0_imp [OF r_def] rec_nat_Suc_imp [OF r_def] f)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2347
    have "r n < r(Suc n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2348
      by (simp add: Suc_le_lessD f r_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2349
    then have "strict_mono r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2350
      by (simp add: strict_mono_Suc_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2351
    moreover have "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2352
      proof (clarsimp simp: limitin_metric \<open>l \<in> M\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2353
        fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2354
        assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2355
        then have "(\<forall>\<^sub>F n in sequentially. inverse (real (Suc n)) < \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2356
          using Archimedean_eventually_inverse by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2357
        then show "\<forall>\<^sub>F n in sequentially. \<sigma> (r n) \<in> M \<and> d (\<sigma> (r n)) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2358
          by eventually_elim (metis commute \<open>range \<sigma> \<subseteq> M\<close>  order_less_trans r range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2359
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2360
    ultimately show "\<exists>l r. l \<in> M \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2361
      using \<open>l \<in> M\<close> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2362
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2363
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2364
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2365
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2366
lemma (in discrete_metric) mcomplete_discrete_metric: "disc.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2367
proof (clarsimp simp: disc.mcomplete_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2368
  fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2369
  assume "disc.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2370
  then obtain N where "\<And>n. N \<le> n \<Longrightarrow> \<sigma> N = \<sigma> n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2371
    unfolding disc.MCauchy_def by (metis dd_def dual_order.refl order_less_irrefl zero_less_one)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2372
  moreover have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2373
    using \<open>disc.MCauchy \<sigma>\<close> disc.MCauchy_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2374
  ultimately have "limitin disc.mtopology \<sigma> (\<sigma> N) sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2375
    by (metis disc.limit_metric_sequentially disc.zero range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2376
  then show "\<exists>x. limitin disc.mtopology \<sigma> x sequentially" ..
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2377
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2378
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2379
lemma compact_space_imp_mcomplete: "compact_space mtopology \<Longrightarrow> mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2380
  by (simp add: compact_space_nest mcomplete_nest)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2381
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2382
lemma (in Submetric) compactin_imp_mcomplete:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2383
   "compactin mtopology A \<Longrightarrow> sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2384
  by (simp add: compactin_subspace mtopology_submetric sub.compact_space_imp_mcomplete)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2385
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2386
lemma (in Submetric) mcomplete_imp_closedin:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2387
  assumes "sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2388
  shows "closedin mtopology A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2389
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2390
  have "l \<in> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2391
    if "range \<sigma> \<subseteq> A" and l: "limitin mtopology \<sigma> l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2392
    for \<sigma> :: "nat \<Rightarrow> 'a" and l
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2393
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2394
    have "sub.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2395
      using convergent_imp_MCauchy subset that by (force simp: MCauchy_submetric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2396
    then have "limitin sub.mtopology \<sigma> l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2397
      using assms unfolding sub.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2398
      using l limitin_metric_unique limitin_submetric_iff trivial_limit_sequentially by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2399
    then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2400
      using limitin_submetric_iff by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2401
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2402
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2403
    using metric_closedin_iff_sequentially_closed subset by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2404
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2405
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2406
lemma (in Submetric) closedin_eq_mcomplete:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2407
   "mcomplete \<Longrightarrow> (closedin mtopology A \<longleftrightarrow> sub.mcomplete)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2408
  using closedin_mcomplete_imp_mcomplete mcomplete_imp_closedin by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2409
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2410
lemma compact_space_eq_mcomplete_mtotally_bounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2411
   "compact_space mtopology \<longleftrightarrow> mcomplete \<and> mtotally_bounded M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2412
  by (meson Bolzano_Weierstrass_C compact_space_imp_mcomplete compact_space_sequentially limitin_mspace 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2413
            mcomplete_alt mtotally_bounded_sequentially subset_refl)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2414
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2415
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2416
lemma compact_closure_of_imp_mtotally_bounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2417
   "\<lbrakk>compactin mtopology (mtopology closure_of S); S \<subseteq> M\<rbrakk>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2418
      \<Longrightarrow> mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2419
  using compactin_imp_mtotally_bounded mtotally_bounded_closure_of_eq by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2420
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2421
lemma mtotally_bounded_eq_compact_closure_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2422
  assumes "mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2423
  shows "mtotally_bounded S \<longleftrightarrow> S \<subseteq> M \<and> compactin mtopology (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2424
  (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2425
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2426
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2427
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2428
    unfolding compactin_subspace
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2429
  proof (intro conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2430
    show "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2431
      using L by (simp add: mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2432
    show "mtopology closure_of S \<subseteq> topspace mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2433
      by (simp add: \<open>S \<subseteq> M\<close> closure_of_minimal)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2434
    then have MSM: "mtopology closure_of S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2435
      by auto
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2436
    interpret S: Submetric M d "mtopology closure_of S"
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2437
    proof qed (use MSM in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2438
    have "S.sub.mtotally_bounded (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2439
      using L mtotally_bounded_absolute mtotally_bounded_closure_of by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2440
    then
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2441
    show "compact_space (subtopology mtopology (mtopology closure_of S))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2442
      using S.closedin_mcomplete_imp_mcomplete S.mtopology_submetric S.sub.compact_space_eq_mcomplete_mtotally_bounded assms by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2443
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2444
qed (auto simp: compact_closure_of_imp_mtotally_bounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2445
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2446
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2447
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2448
lemma compact_closure_of_eq_Bolzano_Weierstrass:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2449
   "compactin mtopology (mtopology closure_of S) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2450
    (\<forall>T. infinite T \<and> T \<subseteq> S \<and> T \<subseteq> M \<longrightarrow> mtopology derived_set_of T \<noteq> {})"  (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2451
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2452
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2453
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2454
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2455
    fix T
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2456
    assume T: "infinite T \<and> T \<subseteq> S \<and> T \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2457
    show "mtopology derived_set_of T \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2458
    proof (intro compact_closure_of_imp_Bolzano_Weierstrass)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2459
      show "compactin mtopology (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2460
        by (simp add: L)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2461
    qed (use T in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2462
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2463
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2464
  have "compactin mtopology (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2465
    if \<section>: "\<And>T. \<lbrakk>infinite T; T \<subseteq> S\<rbrakk> \<Longrightarrow> mtopology derived_set_of T \<noteq> {}" and "S \<subseteq> M" for S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2466
    unfolding compactin_sequentially
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2467
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2468
    show MSM: "mtopology closure_of S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2469
      using closure_of_subset_topspace by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2470
    fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2471
    assume \<sigma>: "range \<sigma> \<subseteq> mtopology closure_of S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2472
    then have "\<exists>y \<in> S. d (\<sigma> n) y < inverse(Suc n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2473
      by (simp add: metric_closure_of image_subset_iff) (metis inverse_Suc of_nat_Suc)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2474
    then obtain \<tau> where \<tau>: "\<And>n. \<tau> n \<in> S \<and> d (\<sigma> n) (\<tau> n) < inverse(Suc n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2475
      by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2476
    then have "range \<tau> \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2477
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2478
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2479
    have *: "\<forall>T. T \<subseteq> S \<and> infinite T \<longrightarrow> mtopology closure_of S \<inter> mtopology derived_set_of T \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2480
      using "\<section>"(1) derived_set_of_mono derived_set_of_subset_closure_of by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2481
    moreover have "S \<subseteq> mtopology closure_of S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2482
      by (simp add: \<open>S \<subseteq> M\<close> closure_of_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2483
    ultimately obtain l r where lr:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2484
      "l \<in> mtopology closure_of S" "strict_mono r" "limitin mtopology (\<tau> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2485
      using Bolzano_Weierstrass_property \<open>S \<subseteq> M\<close> by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2486
    then have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2487
      using limitin_mspace by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2488
    have dr_less: "d ((\<sigma> \<circ> r) n) ((\<tau> \<circ> r) n) < inverse(Suc n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2489
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2490
      have "d ((\<sigma> \<circ> r) n) ((\<tau> \<circ> r) n) < inverse(Suc (r n))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2491
        using \<tau> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2492
      also have "... \<le> inverse(Suc n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2493
        using lr strict_mono_imp_increasing by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2494
      finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2495
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2496
    have "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2497
      unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2498
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2499
      show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2500
        using limitin_mspace lr by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2501
      fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2502
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2503
      then have "\<forall>\<^sub>F n in sequentially. (\<tau> \<circ> r) n \<in> M \<and> d ((\<tau> \<circ> r) n) l < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2504
        using lr half_gt_zero limitin_metric by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2505
      moreover have "\<forall>\<^sub>F n in sequentially. inverse (real (Suc n)) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2506
        using Archimedean_eventually_inverse \<open>0 < \<epsilon>\<close> half_gt_zero by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2507
      then have "\<forall>\<^sub>F n in sequentially. d ((\<sigma> \<circ> r) n) ((\<tau> \<circ> r) n) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2508
        by eventually_elim (smt (verit, del_insts) dr_less)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2509
      ultimately have "\<forall>\<^sub>F n in sequentially. d ((\<sigma> \<circ> r) n) l < \<epsilon>/2 + \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2510
        by eventually_elim (smt (verit) triangle \<open>l \<in> M\<close> MSM \<sigma> comp_apply order_trans range_subsetD)      
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2511
      then show "\<forall>\<^sub>F n in sequentially. (\<sigma> \<circ> r) n \<in> M \<and> d ((\<sigma> \<circ> r) n) l < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2512
        apply eventually_elim
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2513
        using \<open>mtopology closure_of S \<subseteq> M\<close> \<sigma> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2514
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2515
    with lr show "\<exists>l r. l \<in> mtopology closure_of S \<and> strict_mono r \<and> limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2516
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2517
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2518
  then show "?rhs \<Longrightarrow> ?lhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2519
    by (metis Int_subset_iff closure_of_restrict inf_le1 topspace_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2520
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2521
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2522
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2523
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2524
lemma (in discrete_metric) mtotally_bounded_discrete_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2525
   "disc.mtotally_bounded S \<longleftrightarrow> finite S \<and> S \<subseteq> M" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2526
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2527
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2528
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2529
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2530
    show "finite S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2531
      by (metis (no_types) L closure_of_subset_Int compactin_discrete_topology disc.mtotally_bounded_eq_compact_closure_of
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2532
          disc.topspace_mtopology discrete_metric.mcomplete_discrete_metric inf.absorb_iff2 mtopology_discrete_metric finite_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2533
    show "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2534
      by (simp add: L disc.mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2535
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2536
qed (simp add: disc.finite_imp_mtotally_bounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2537
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2538
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2539
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2540
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2541
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2542
lemma derived_set_of_infinite_openin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2543
   "mtopology derived_set_of S =
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2544
    {x \<in> M. \<forall>U. x \<in> U \<and> openin mtopology U \<longrightarrow> infinite(S \<inter> U)}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2545
  by (simp add: derived_set_of_infinite_openin Hausdorff_space_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2546
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2547
lemma derived_set_of_infinite_1: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2548
  assumes "infinite (S \<inter> mball x \<epsilon>)" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2549
  shows "infinite (S \<inter> mcball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2550
  by (meson Int_mono assms finite_subset mball_subset_mcball subset_refl)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2551
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2552
lemma derived_set_of_infinite_2:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2553
  assumes "openin mtopology U" "\<And>\<epsilon>. 0 < \<epsilon> \<Longrightarrow> infinite (S \<inter> mcball x \<epsilon>)" and "x \<in> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2554
  shows "infinite (S \<inter> U)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2555
  by (metis assms openin_mtopology_mcball finite_Int inf.absorb_iff2 inf_assoc)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2556
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2557
lemma derived_set_of_infinite_mball:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2558
  "mtopology derived_set_of S = {x \<in> M. \<forall>e>0. infinite(S \<inter> mball x e)}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2559
  unfolding derived_set_of_infinite_openin_metric
78748
ca486ee0e4c5 New proofs also some slightly faster existing proofs
paulson <lp15@cam.ac.uk>
parents: 78336
diff changeset
  2560
  by (metis (no_types, opaque_lifting) centre_in_mball_iff openin_mball derived_set_of_infinite_1 derived_set_of_infinite_2)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2561
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2562
lemma derived_set_of_infinite_mcball:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2563
  "mtopology derived_set_of S = {x \<in> M. \<forall>e>0. infinite(S \<inter> mcball x e)}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2564
  unfolding derived_set_of_infinite_openin_metric
78748
ca486ee0e4c5 New proofs also some slightly faster existing proofs
paulson <lp15@cam.ac.uk>
parents: 78336
diff changeset
  2565
  by (metis (no_types, opaque_lifting) centre_in_mball_iff openin_mball derived_set_of_infinite_1 derived_set_of_infinite_2)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2566
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2567
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2568
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2569
subsection\<open>Continuous functions on metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2570
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2571
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2572
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2573
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2574
lemma continuous_map_to_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2575
   "continuous_map X mtopology f \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2576
    (\<forall>x \<in> topspace X. \<forall>\<epsilon>>0. \<exists>U. openin X U \<and> x \<in> U \<and> (\<forall>y\<in>U. f y \<in> mball (f x) \<epsilon>))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2577
   (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2578
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2579
  show "?lhs \<Longrightarrow> ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2580
    unfolding continuous_map_eq_topcontinuous_at topcontinuous_at_def
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  2581
    by (metis PiE centre_in_mball_iff openin_mball topspace_mtopology)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2582
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2583
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2584
  then have "\<forall>x\<in>topspace X. f x \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2585
    by (meson gt_ex in_mball)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2586
  moreover 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2587
  have "\<And>x V. \<lbrakk>x \<in> topspace X; openin mtopology V; f x \<in> V\<rbrakk> \<Longrightarrow> \<exists>U. openin X U \<and> x \<in> U \<and> (\<forall>y\<in>U. f y \<in> V)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2588
    unfolding openin_mtopology by (metis Int_iff R inf.orderE)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2589
  ultimately
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2590
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2591
    by (simp add: continuous_map_eq_topcontinuous_at topcontinuous_at_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2592
qed 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2593
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2594
lemma continuous_map_from_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2595
   "continuous_map mtopology X f \<longleftrightarrow>
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  2596
    f \<in> M \<rightarrow> topspace X \<and>
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2597
    (\<forall>a \<in> M. \<forall>U. openin X U \<and> f a \<in> U \<longrightarrow> (\<exists>r>0. \<forall>x. x \<in> M \<and> d a x < r \<longrightarrow> f x \<in> U))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2598
proof (cases "f ` M \<subseteq> topspace X")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2599
  case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2600
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2601
    by (fastforce simp: continuous_map openin_mtopology subset_eq)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2602
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2603
  case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2604
  then show ?thesis
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  2605
    by (simp add: continuous_map_def image_subset_iff_funcset)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2606
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2607
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2608
text \<open>An abstract formulation, since the limits do not have to be sequential\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2609
lemma continuous_map_uniform_limit:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2610
  assumes contf: "\<forall>\<^sub>F \<xi> in F. continuous_map X mtopology (f \<xi>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2611
    and dfg: "\<And>\<epsilon>. 0 < \<epsilon> \<Longrightarrow> \<forall>\<^sub>F \<xi> in F. \<forall>x \<in> topspace X. g x \<in> M \<and> d (f \<xi> x) (g x) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2612
    and nontriv: "\<not> trivial_limit F"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2613
  shows "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2614
  unfolding continuous_map_to_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2615
proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2616
  fix x and \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2617
  assume "x \<in> topspace X" and "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2618
  then obtain \<xi> where k: "continuous_map X mtopology (f \<xi>)" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2619
    and gM: "\<forall>x \<in> topspace X. g x \<in> M" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2620
    and third: "\<forall>x \<in> topspace X. d (f \<xi> x) (g x) < \<epsilon>/3"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2621
    using eventually_conj [OF contf] contf dfg [of "\<epsilon>/3"] eventually_happens' [OF nontriv]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2622
    by (smt (verit, ccfv_SIG) zero_less_divide_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2623
  then obtain U where U: "openin X U" "x \<in> U" and Uthird: "\<forall>y\<in>U. d (f \<xi> y) (f \<xi> x) < \<epsilon>/3"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2624
    unfolding continuous_map_to_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2625
    by (metis \<open>0 < \<epsilon>\<close> \<open>x \<in> topspace X\<close> commute divide_pos_pos in_mball zero_less_numeral)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2626
  have f_inM: "f \<xi> y \<in> M" if "y\<in>U" for y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2627
    using U k openin_subset that by (fastforce simp: continuous_map_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2628
  have "d (g y) (g x) < \<epsilon>" if "y\<in>U" for y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2629
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2630
    have "g y \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2631
      using U gM openin_subset that by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2632
    have "d (g y) (g x) \<le> d (g y) (f \<xi> x) + d (f \<xi> x) (g x)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2633
      by (simp add: U \<open>g y \<in> M\<close> \<open>x \<in> topspace X\<close> f_inM gM triangle)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2634
    also have "\<dots> \<le> d (g y) (f \<xi> y) + d (f \<xi> y) (f \<xi> x) + d (f \<xi> x) (g x)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2635
      by (simp add: U \<open>g y \<in> M\<close> commute f_inM that triangle')
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2636
    also have "\<dots> < \<epsilon>/3 + \<epsilon>/3 + \<epsilon>/3"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2637
      by (smt (verit) U(1) Uthird \<open>x \<in> topspace X\<close> commute openin_subset subsetD that third)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2638
    finally show ?thesis by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2639
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2640
  with U gM show "\<exists>U. openin X U \<and> x \<in> U \<and> (\<forall>y\<in>U. g y \<in> mball (g x) \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2641
    by (metis commute in_mball in_mono openin_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2642
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2643
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2644
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2645
lemma continuous_map_uniform_limit_alt:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2646
  assumes contf: "\<forall>\<^sub>F \<xi> in F. continuous_map X mtopology (f \<xi>)"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2647
    and gim: "g \<in> topspace X \<rightarrow> M"
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2648
    and dfg: "\<And>\<epsilon>. 0 < \<epsilon> \<Longrightarrow> \<forall>\<^sub>F \<xi> in F. \<forall>x \<in> topspace X. d (f \<xi> x) (g x) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2649
    and nontriv: "\<not> trivial_limit F"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2650
  shows "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2651
proof (rule continuous_map_uniform_limit [OF contf])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2652
  fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2653
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2654
  with gim dfg show "\<forall>\<^sub>F \<xi> in F. \<forall>x\<in>topspace X. g x \<in> M \<and> d (f \<xi> x) (g x) < \<epsilon>"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2655
    by (simp add: Pi_iff)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2656
qed (use nontriv in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2657
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2658
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2659
lemma continuous_map_uniformly_Cauchy_limit:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2660
  assumes "mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2661
  assumes contf: "\<forall>\<^sub>F n in sequentially. continuous_map X mtopology (f n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2662
    and Cauchy': "\<And>\<epsilon>. \<epsilon> > 0 \<Longrightarrow> \<exists>N. \<forall>m n x. N \<le> m \<longrightarrow> N \<le> n \<longrightarrow> x \<in> topspace X \<longrightarrow> d (f m x) (f n x) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2663
  obtains g where
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2664
    "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2665
    "\<And>\<epsilon>. 0 < \<epsilon> \<Longrightarrow> \<forall>\<^sub>F n in sequentially. \<forall>x\<in>topspace X. d (f n x) (g x) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2666
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2667
  have "\<And>x. x \<in> topspace X \<Longrightarrow> \<exists>l. limitin mtopology (\<lambda>n. f n x) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2668
    using \<open>mcomplete\<close> [unfolded mcomplete, rule_format] assms
78748
ca486ee0e4c5 New proofs also some slightly faster existing proofs
paulson <lp15@cam.ac.uk>
parents: 78336
diff changeset
  2669
    unfolding continuous_map_def Pi_iff topspace_mtopology
ca486ee0e4c5 New proofs also some slightly faster existing proofs
paulson <lp15@cam.ac.uk>
parents: 78336
diff changeset
  2670
    by (smt (verit, del_insts) eventually_mono)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2671
  then obtain g where g: "\<And>x. x \<in> topspace X \<Longrightarrow> limitin mtopology (\<lambda>n. f n x) (g x) sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2672
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2673
  show thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2674
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2675
    show "\<forall>\<^sub>F n in sequentially. \<forall>x\<in>topspace X. d (f n x) (g x) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2676
      if "\<epsilon> > 0" for \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2677
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2678
      obtain N where N: "\<And>m n x. \<lbrakk>N \<le> m; N \<le> n; x \<in> topspace X\<rbrakk> \<Longrightarrow> d (f m x) (f n x) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2679
        by (meson Cauchy' \<open>0 < \<epsilon>\<close> half_gt_zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2680
      obtain P where P: "\<And>n x. \<lbrakk>n \<ge> P; x \<in> topspace X\<rbrakk> \<Longrightarrow> f n x \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2681
        using contf by (auto simp: eventually_sequentially continuous_map_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2682
      show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2683
      proof (intro eventually_sequentiallyI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2684
        fix n x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2685
        assume "max N P \<le> n" and x: "x \<in> topspace X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2686
        obtain L where "g x \<in> M" and L: "\<forall>n\<ge>L. f n x \<in> M \<and> d (f n x) (g x) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2687
          using g [OF x] \<open>\<epsilon> > 0\<close> unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2688
          by (metis (no_types, lifting) eventually_sequentially half_gt_zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2689
        define n' where "n' \<equiv> Max{L,N,P}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2690
        have L': "\<forall>m \<ge> n'. f m x \<in> M \<and> d (f m x) (g x) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2691
          using L by (simp add: n'_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2692
        moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2693
        have "d (f n x) (f n' x) < \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2694
          using N [of n n' x] \<open>max N P \<le> n\<close> n'_def x by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2695
        ultimately have "d (f n x) (g x) < \<epsilon>/2 + \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2696
          by (smt (verit, ccfv_SIG) P \<open>g x \<in> M\<close> \<open>max N P \<le> n\<close> le_refl max.bounded_iff mdist_zero triangle' x)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2697
        then show "d (f n x) (g x) < \<epsilon>" by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2698
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2699
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2700
    then show "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2701
      by (smt (verit, del_insts) eventually_mono g limitin_mspace trivial_limit_sequentially continuous_map_uniform_limit [OF contf])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2702
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2703
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2704
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2705
lemma metric_continuous_map:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2706
  assumes "Metric_space M' d'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2707
  shows
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2708
   "continuous_map mtopology (Metric_space.mtopology M' d') f \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2709
    f ` M \<subseteq> M' \<and> (\<forall>a \<in> M. \<forall>\<epsilon>>0. \<exists>\<delta>>0.  (\<forall>x. x \<in> M \<and> d a x < \<delta> \<longrightarrow> d' (f a) (f x) < \<epsilon>))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2710
   (is "?lhs = ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2711
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2712
  interpret M': Metric_space M' d'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2713
    by (simp add: assms)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2714
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2715
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2716
    assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2717
    show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2718
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2719
      show "f ` M \<subseteq> M'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2720
        using L by (auto simp: continuous_map_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2721
      fix a and \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2722
      assume "a \<in> M" and "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2723
      then have "openin mtopology {x \<in> M. f x \<in> M'.mball (f a) \<epsilon>}" "f a \<in> M'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2724
        using L unfolding continuous_map_def by fastforce+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2725
      then obtain \<delta> where "\<delta> > 0" "mball a \<delta> \<subseteq> {x \<in> M. f x \<in> M' \<and> d' (f a) (f x) < \<epsilon>}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2726
        using \<open>0 < \<epsilon>\<close> \<open>a \<in> M\<close> openin_mtopology by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2727
      then show "\<exists>\<delta>>0. \<forall>x. x \<in> M \<and> d a x < \<delta> \<longrightarrow> d' (f a) (f x) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2728
        using \<open>a \<in> M\<close> in_mball by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2729
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2730
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2731
    assume R: ?rhs    
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2732
    show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2733
      unfolding continuous_map_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2734
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2735
      fix U
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2736
      assume "openin M'.mtopology U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2737
      then show "openin mtopology {x \<in> topspace mtopology. f x \<in> U}"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  2738
        using R
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  2739
        by (force simp: continuous_map_def openin_mtopology M'.openin_mtopology subset_iff)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2740
    qed (use R in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2741
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2742
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2743
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2744
end (*Metric_space*)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2745
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2746
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2747
subsection \<open>Completely metrizable spaces\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2748
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2749
text \<open>These spaces are topologically complete\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2750
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2751
definition completely_metrizable_space where
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2752
 "completely_metrizable_space X \<equiv> 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2753
     \<exists>M d. Metric_space M d \<and> Metric_space.mcomplete M d \<and> X = Metric_space.mtopology M d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2754
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2755
lemma empty_completely_metrizable_space: 
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  2756
  "completely_metrizable_space trivial_topology"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2757
  unfolding completely_metrizable_space_def subtopology_eq_discrete_topology_empty [symmetric]
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2758
  by (metis Metric_space.mcomplete_empty_mspace discrete_metric.mtopology_discrete_metric metric_M_dd)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2759
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2760
lemma completely_metrizable_imp_metrizable_space:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2761
   "completely_metrizable_space X \<Longrightarrow> metrizable_space X"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2762
  using completely_metrizable_space_def metrizable_space_def by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2763
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2764
lemma (in Metric_space) completely_metrizable_space_mtopology:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2765
   "mcomplete \<Longrightarrow> completely_metrizable_space mtopology"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2766
  using Metric_space_axioms completely_metrizable_space_def by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2767
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2768
lemma completely_metrizable_space_discrete_topology:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2769
   "completely_metrizable_space (discrete_topology U)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2770
  unfolding completely_metrizable_space_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2771
  by (metis discrete_metric.mcomplete_discrete_metric discrete_metric.mtopology_discrete_metric metric_M_dd)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2772
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2773
lemma completely_metrizable_space_euclidean:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2774
    "completely_metrizable_space (euclidean:: 'a::complete_space topology)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2775
  using Met_TC.completely_metrizable_space_mtopology complete_UNIV by auto
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2776
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2777
lemma completely_metrizable_space_closedin:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2778
  assumes X: "completely_metrizable_space X" and S: "closedin X S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2779
  shows "completely_metrizable_space(subtopology X S)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2780
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2781
  obtain M d where "Metric_space M d" and comp: "Metric_space.mcomplete M d" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2782
                and Xeq: "X = Metric_space.mtopology M d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2783
    using assms completely_metrizable_space_def by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2784
  then interpret Metric_space M d
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2785
    by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2786
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2787
    unfolding completely_metrizable_space_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2788
  proof (intro conjI exI)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2789
    show "Metric_space S d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2790
      using S Xeq closedin_subset subspace by force
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2791
    have sub: "Submetric_axioms M S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2792
      by (metis S Xeq closedin_metric Submetric_axioms_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2793
    then show "Metric_space.mcomplete S d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2794
      using S Submetric.closedin_mcomplete_imp_mcomplete Submetric_def Xeq comp by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2795
    show "subtopology X S = Metric_space.mtopology S d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2796
      by (metis Metric_space_axioms Xeq sub Submetric.intro Submetric.mtopology_submetric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2797
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2798
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2799
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2800
lemma completely_metrizable_space_cbox: "completely_metrizable_space (top_of_set (cbox a b))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2801
    using closed_closedin completely_metrizable_space_closedin completely_metrizable_space_euclidean by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2802
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2803
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2804
lemma homeomorphic_completely_metrizable_space_aux:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2805
  assumes homXY: "X homeomorphic_space Y" and X: "completely_metrizable_space X"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2806
  shows "completely_metrizable_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2807
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2808
  obtain f g where hmf: "homeomorphic_map X Y f" and hmg: "homeomorphic_map Y X g"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2809
    and fg: "\<And>x. x \<in> topspace X \<Longrightarrow> g(f x) = x" "\<And>y. y \<in> topspace Y \<Longrightarrow> f(g y) = y"
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2810
    and fim: "f \<in> topspace X \<rightarrow> topspace Y" and gim: "g \<in> topspace Y \<rightarrow> topspace X"
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2811
    using homXY
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2812
    using homeomorphic_space_unfold by blast
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2813
  obtain M d where Md: "Metric_space M d" "Metric_space.mcomplete M d" and Xeq: "X = Metric_space.mtopology M d"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2814
    using X by (auto simp: completely_metrizable_space_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2815
  then interpret MX: Metric_space M d by metis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2816
  define D where "D \<equiv> \<lambda>x y. d (g x) (g y)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2817
  have "Metric_space (topspace Y) D"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2818
  proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2819
    show "(D x y = 0) \<longleftrightarrow> (x = y)" if "x \<in> topspace Y" "y \<in> topspace Y" for x y
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2820
      unfolding D_def
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2821
      by (metis that MX.topspace_mtopology MX.zero Xeq fg gim Pi_iff)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2822
    show "D x z \<le> D x y +D y z"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2823
      if "x \<in> topspace Y" "y \<in> topspace Y" "z \<in> topspace Y" for x y z
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2824
      using that MX.triangle Xeq gim by (auto simp: D_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2825
  qed (auto simp: D_def MX.commute)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2826
  then interpret MY: Metric_space "topspace Y" "\<lambda>x y. D x y" by metis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2827
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2828
    unfolding completely_metrizable_space_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2829
  proof (intro exI conjI)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2830
    show "Metric_space (topspace Y) D"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2831
      using MY.Metric_space_axioms by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2832
    have gball: "g ` MY.mball y r = MX.mball (g y) r" if "y \<in> topspace Y" for y r
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2833
      using that MX.topspace_mtopology Xeq gim hmg homeomorphic_imp_surjective_map
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2834
      unfolding MX.mball_def MY.mball_def  by (fastforce simp: D_def)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2835
    have "\<exists>r>0. MY.mball y r \<subseteq> S" if "openin Y S" and "y \<in> S" for S y
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2836
    proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2837
      have "openin X (g`S)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2838
        using hmg homeomorphic_map_openness_eq that by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2839
      then obtain r where "r>0" "MX.mball (g y) r \<subseteq> g`S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2840
        using MX.openin_mtopology Xeq \<open>y \<in> S\<close> by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2841
      then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2842
        by (smt (verit, ccfv_SIG) MY.in_mball gball fg image_iff in_mono openin_subset subsetI that(1))
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2843
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2844
    moreover have "openin Y S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2845
      if "S \<subseteq> topspace Y" and "\<And>y. y \<in> S \<Longrightarrow> \<exists>r>0. MY.mball y r \<subseteq> S" for S
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2846
    proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2847
      have "\<And>x. x \<in> g`S \<Longrightarrow> \<exists>r>0. MX.mball x r \<subseteq> g`S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2848
        by (smt (verit) gball imageE image_mono subset_iff that)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2849
      then have "openin X (g`S)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2850
        using MX.openin_mtopology Xeq gim that(1) by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2851
      then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2852
        using hmg homeomorphic_map_openness_eq that(1) by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2853
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2854
    ultimately show Yeq: "Y = MY.mtopology"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2855
      unfolding topology_eq MY.openin_mtopology by (metis openin_subset)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2856
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2857
    show "MY.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2858
      unfolding MY.mcomplete_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2859
    proof (intro strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2860
      fix \<sigma>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2861
      assume \<sigma>: "MY.MCauchy \<sigma>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2862
      have "MX.MCauchy (g \<circ> \<sigma>)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2863
        unfolding MX.MCauchy_def 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2864
      proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2865
        show "range (g \<circ> \<sigma>) \<subseteq> M"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2866
          using MY.MCauchy_def Xeq \<sigma> gim by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2867
        fix \<epsilon> :: real
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2868
        assume "\<epsilon> > 0"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2869
        then obtain N where "\<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> D (\<sigma> n) (\<sigma> n') < \<epsilon>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2870
          using MY.MCauchy_def \<sigma> by presburger
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2871
        then show "\<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d ((g \<circ> \<sigma>) n) ((g \<circ> \<sigma>) n') < \<epsilon>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2872
          by (auto simp: o_def D_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2873
      qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2874
      then obtain x where x: "limitin MX.mtopology (g \<circ> \<sigma>) x sequentially" "x \<in> topspace X"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2875
        using MX.limitin_mspace MX.topspace_mtopology Md Xeq unfolding MX.mcomplete_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2876
        by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2877
      with x have "limitin MY.mtopology (f \<circ> (g \<circ> \<sigma>)) (f x) sequentially"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2878
        by (metis Xeq Yeq continuous_map_limit hmf homeomorphic_imp_continuous_map)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2879
      moreover have "f \<circ> (g \<circ> \<sigma>) = \<sigma>"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  2880
        using \<open>MY.MCauchy \<sigma>\<close>  by (force simp: fg MY.MCauchy_def subset_iff)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2881
      ultimately have "limitin MY.mtopology \<sigma> (f x) sequentially" by simp
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2882
      then show "\<exists>y. limitin MY.mtopology \<sigma> y sequentially"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2883
        by blast 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2884
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2885
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2886
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2887
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2888
lemma homeomorphic_completely_metrizable_space:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2889
   "X homeomorphic_space Y
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2890
        \<Longrightarrow> completely_metrizable_space X \<longleftrightarrow> completely_metrizable_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2891
  by (meson homeomorphic_completely_metrizable_space_aux homeomorphic_space_sym)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2892
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2893
lemma completely_metrizable_space_retraction_map_image:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2894
  assumes r: "retraction_map X Y r" and X: "completely_metrizable_space X"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2895
  shows "completely_metrizable_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2896
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2897
  obtain s where s: "retraction_maps X Y r s"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2898
    using r retraction_map_def by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2899
  then have "subtopology X (s ` topspace Y) homeomorphic_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2900
    using retraction_maps_section_image2 by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2901
  then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2902
    by (metis X retract_of_space_imp_closedin retraction_maps_section_image1 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2903
        homeomorphic_completely_metrizable_space completely_metrizable_space_closedin 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2904
        completely_metrizable_imp_metrizable_space metrizable_imp_Hausdorff_space s)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2905
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2906
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2907
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2908
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2909
subsection \<open>Product metric\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2910
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2911
text\<open>For the nicest fit with the main Euclidean theories, we choose the Euclidean product, 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2912
though other definitions of the product work.\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2913
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2914
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2915
definition "prod_dist \<equiv> \<lambda>d1 d2 (x,y) (x',y'). sqrt(d1 x x' ^ 2 + d2 y y' ^ 2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2916
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2917
locale Metric_space12 = M1: Metric_space M1 d1 + M2: Metric_space M2 d2 for M1 d1 M2 d2
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2918
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2919
lemma (in Metric_space12) prod_metric: "Metric_space (M1 \<times> M2) (prod_dist d1 d2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2920
proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2921
  fix x y z
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2922
  assume xyz: "x \<in> M1 \<times> M2" "y \<in> M1 \<times> M2" "z \<in> M1 \<times> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2923
  have "sqrt ((d1 x1 z1)\<^sup>2 + (d2 x2 z2)\<^sup>2) \<le> sqrt ((d1 x1 y1)\<^sup>2 + (d2 x2 y2)\<^sup>2) + sqrt ((d1 y1 z1)\<^sup>2 + (d2 y2 z2)\<^sup>2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2924
      (is "sqrt ?L \<le> ?R")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2925
    if "x = (x1, x2)" "y = (y1, y2)" "z = (z1, z2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2926
    for x1 x2 y1 y2 z1 z2
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2927
  proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2928
    have tri: "d1 x1 z1 \<le> d1 x1 y1 + d1 y1 z1" "d2 x2 z2 \<le> d2 x2 y2 + d2 y2 z2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2929
      using that xyz M1.triangle [of x1 y1 z1] M2.triangle [of x2 y2 z2] by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2930
    show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2931
    proof (rule real_le_lsqrt)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2932
      have "?L \<le> (d1 x1 y1 + d1 y1 z1)\<^sup>2 + (d2 x2 y2 + d2 y2 z2)\<^sup>2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2933
        using tri by (smt (verit) M1.nonneg M2.nonneg power_mono)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2934
      also have "... \<le> ?R\<^sup>2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2935
        by (metis real_sqrt_sum_squares_triangle_ineq sqrt_le_D)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2936
      finally show "?L \<le> ?R\<^sup>2" .
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2937
    qed auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2938
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2939
  then show "prod_dist d1 d2 x z \<le> prod_dist d1 d2 x y + prod_dist d1 d2 y z"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2940
    by (simp add: prod_dist_def case_prod_unfold)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2941
qed (auto simp: M1.commute M2.commute case_prod_unfold prod_dist_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2942
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2943
sublocale Metric_space12 \<subseteq> Prod_metric: Metric_space "M1\<times>M2" "prod_dist d1 d2" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2944
  by (simp add: prod_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2945
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2946
text \<open>For easy reference to theorems outside of the locale\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2947
lemma Metric_space12_mspace_mdist:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2948
  "Metric_space12 (mspace m1) (mdist m1) (mspace m2) (mdist m2)"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  2949
  by (simp add: Metric_space12_def)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2950
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2951
definition prod_metric where
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2952
 "prod_metric \<equiv> \<lambda>m1 m2. metric (mspace m1 \<times> mspace m2, prod_dist (mdist m1) (mdist m2))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2953
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2954
lemma submetric_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2955
   "submetric (prod_metric m1 m2) (S \<times> T) = prod_metric (submetric m1 S) (submetric m2 T)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2956
  apply (simp add: prod_metric_def)
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  2957
  by (simp add: submetric_def Metric_space.mspace_metric Metric_space.mdist_metric Metric_space12.prod_metric Metric_space12_def Times_Int_Times)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2958
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2959
lemma mspace_prod_metric [simp]:"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2960
  mspace (prod_metric m1 m2) = mspace m1 \<times> mspace m2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2961
  by (simp add: prod_metric_def Metric_space.mspace_metric Metric_space12.prod_metric Metric_space12_mspace_mdist)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2962
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2963
lemma mdist_prod_metric [simp]: 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2964
  "mdist (prod_metric m1 m2) = prod_dist (mdist m1) (mdist m2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2965
  by (metis Metric_space.mdist_metric Metric_space12.prod_metric Metric_space12_mspace_mdist prod_metric_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2966
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2967
lemma prod_dist_dist [simp]: "prod_dist dist dist = dist"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2968
  by (simp add: prod_dist_def dist_prod_def fun_eq_iff)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2969
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2970
lemma prod_metric_euclidean [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2971
  "prod_metric euclidean_metric euclidean_metric = euclidean_metric"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2972
  by (simp add: prod_metric_def euclidean_metric_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2973
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2974
context Metric_space12
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2975
begin
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2976
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2977
lemma component_le_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2978
   "d1 x1 x2 \<le> prod_dist d1 d2 (x1,y1) (x2,y2)" "d2 y1 y2 \<le> prod_dist d1 d2 (x1,y1) (x2,y2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2979
  by (auto simp: prod_dist_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2980
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2981
lemma prod_metric_le_components:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2982
  "\<lbrakk>x1 \<in> M1; y1 \<in> M1; x2 \<in> M2; y2 \<in> M2\<rbrakk>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2983
    \<Longrightarrow> prod_dist d1 d2 (x1,x2) (y1,y2) \<le> d1 x1 y1 + d2 x2 y2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2984
  by (auto simp: prod_dist_def sqrt_sum_squares_le_sum)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2985
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2986
lemma mball_prod_metric_subset:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2987
   "Prod_metric.mball (x,y) r \<subseteq> M1.mball x r \<times> M2.mball y r"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2988
  by clarsimp (smt (verit, best) component_le_prod_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2989
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2990
lemma mcball_prod_metric_subset:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2991
   "Prod_metric.mcball (x,y) r \<subseteq> M1.mcball x r \<times> M2.mcball y r"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2992
  by clarsimp (smt (verit, best) component_le_prod_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2993
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2994
lemma mball_subset_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2995
   "M1.mball x1 r1 \<times> M2.mball x2 r2 \<subseteq> Prod_metric.mball (x1,x2) (r1 + r2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2996
  using prod_metric_le_components by force
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2997
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2998
lemma mcball_subset_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2999
   "M1.mcball x1 r1 \<times> M2.mcball x2 r2 \<subseteq> Prod_metric.mcball (x1,x2) (r1 + r2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3000
  using prod_metric_le_components by force
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3001
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3002
lemma mtopology_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3003
  "Prod_metric.mtopology = prod_topology M1.mtopology M2.mtopology"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3004
  unfolding prod_topology_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3005
proof (rule topology_base_unique [symmetric])
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3006
  fix U
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3007
  assume "U \<in> {S \<times> T |S T. openin M1.mtopology S \<and> openin M2.mtopology T}"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3008
  then obtain S T where Ueq: "U = S \<times> T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3009
    and S: "openin M1.mtopology S" and T: "openin M2.mtopology T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3010
    by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3011
  have "S \<subseteq> M1"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3012
    using M1.openin_mtopology S by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3013
  have "T \<subseteq> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3014
    using M2.openin_mtopology T by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3015
  show "openin Prod_metric.mtopology U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3016
    unfolding Prod_metric.openin_mtopology
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3017
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3018
    show "U \<subseteq> M1 \<times> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3019
      using Ueq by (simp add: Sigma_mono \<open>S \<subseteq> M1\<close> \<open>T \<subseteq> M2\<close>)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3020
    fix z
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3021
    assume "z \<in> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3022
    then obtain x1 x2 where "x1 \<in> S" "x2 \<in> T" and zeq: "z = (x1,x2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3023
      using Ueq by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3024
    obtain r1 where "r1>0" and r1: "M1.mball x1 r1 \<subseteq> S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3025
      by (meson M1.openin_mtopology \<open>openin M1.mtopology S\<close> \<open>x1 \<in> S\<close>)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3026
    obtain r2 where "r2>0" and r2: "M2.mball x2 r2 \<subseteq> T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3027
      by (meson M2.openin_mtopology \<open>openin M2.mtopology T\<close> \<open>x2 \<in> T\<close>)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3028
    have "Prod_metric.mball (x1,x2) (min r1 r2) \<subseteq> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3029
    proof (rule order_trans [OF mball_prod_metric_subset])
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3030
      show "M1.mball x1 (min r1 r2) \<times> M2.mball x2 (min r1 r2) \<subseteq> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3031
        using Ueq r1 r2 by force
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3032
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3033
    then show "\<exists>r>0. Prod_metric.mball z r \<subseteq> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3034
      by (smt (verit, del_insts) zeq \<open>0 < r1\<close> \<open>0 < r2\<close>)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3035
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3036
next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3037
  fix U z
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3038
  assume "openin Prod_metric.mtopology U" and "z \<in> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3039
  then have "U \<subseteq> M1 \<times> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3040
    by (simp add: Prod_metric.openin_mtopology)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3041
  then obtain x y where "x \<in> M1" "y \<in> M2" and zeq: "z = (x,y)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3042
    using \<open>z \<in> U\<close> by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3043
  obtain r where "r>0" and r: "Prod_metric.mball (x,y) r \<subseteq> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3044
    by (metis Prod_metric.openin_mtopology \<open>openin Prod_metric.mtopology U\<close> \<open>z \<in> U\<close> zeq)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3045
  define B1 where "B1 \<equiv> M1.mball x (r/2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3046
  define B2 where "B2 \<equiv> M2.mball y (r/2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3047
  have "openin M1.mtopology B1" "openin M2.mtopology B2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3048
    by (simp_all add: B1_def B2_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3049
  moreover have "(x,y) \<in> B1 \<times> B2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3050
    using \<open>r > 0\<close> by (simp add: \<open>x \<in> M1\<close> \<open>y \<in> M2\<close> B1_def B2_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3051
  moreover have "B1 \<times> B2 \<subseteq> U"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3052
    using r prod_metric_le_components by (force simp: B1_def B2_def)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3053
  ultimately show "\<exists>B. B \<in> {S \<times> T |S T. openin M1.mtopology S \<and> openin M2.mtopology T} \<and> z \<in> B \<and> B \<subseteq> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3054
    by (auto simp: zeq)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3055
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3056
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3057
lemma MCauchy_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3058
   "Prod_metric.MCauchy \<sigma> \<longleftrightarrow> M1.MCauchy (fst \<circ> \<sigma>) \<and> M2.MCauchy (snd \<circ> \<sigma>)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3059
   (is "?lhs \<longleftrightarrow> ?rhs")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3060
proof safe
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3061
  assume L: ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3062
  then have "range \<sigma> \<subseteq> M1 \<times> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3063
    using Prod_metric.MCauchy_def by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3064
  then have 1: "range (fst \<circ> \<sigma>) \<subseteq> M1" and 2: "range (snd \<circ> \<sigma>) \<subseteq> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3065
    by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3066
  have N1: "\<exists>N. \<forall>n\<ge>N. \<forall>n'\<ge>N. d1 (fst (\<sigma> n)) (fst (\<sigma> n')) < \<epsilon>" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3067
    and N2: "\<exists>N. \<forall>n\<ge>N. \<forall>n'\<ge>N. d2 (snd (\<sigma> n)) (snd (\<sigma> n')) < \<epsilon>" if "\<epsilon>>0" for \<epsilon> :: real
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3068
    using that L unfolding Prod_metric.MCauchy_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3069
    by (smt (verit, del_insts) add.commute add_less_imp_less_left add_right_mono 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3070
        component_le_prod_metric prod.collapse)+
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3071
  show "M1.MCauchy (fst \<circ> \<sigma>)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3072
    using 1 N1 M1.MCauchy_def by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3073
  have "\<exists>N. \<forall>n\<ge>N. \<forall>n'\<ge>N. d2 (snd (\<sigma> n)) (snd (\<sigma> n')) < \<epsilon>" if "\<epsilon>>0" for \<epsilon> :: real
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3074
    using that L unfolding Prod_metric.MCauchy_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3075
    by (smt (verit, del_insts) add.commute add_less_imp_less_left add_right_mono 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3076
        component_le_prod_metric prod.collapse)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3077
  show "M2.MCauchy (snd \<circ> \<sigma>)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3078
    using 2 N2 M2.MCauchy_def by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3079
next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3080
  assume M1: "M1.MCauchy (fst \<circ> \<sigma>)" and M2: "M2.MCauchy (snd \<circ> \<sigma>)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3081
  then have subM12: "range (fst \<circ> \<sigma>) \<subseteq> M1" "range (snd \<circ> \<sigma>) \<subseteq> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3082
    using M1.MCauchy_def M2.MCauchy_def by blast+
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3083
  show ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3084
    unfolding Prod_metric.MCauchy_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3085
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3086
    show "range \<sigma> \<subseteq> M1 \<times> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3087
      using subM12 by (smt (verit, best) SigmaI image_subset_iff o_apply prod.collapse) 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3088
    fix \<epsilon> :: real
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3089
    assume "\<epsilon> > 0"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3090
    obtain N1 where N1: "\<And>n n'. N1 \<le> n \<Longrightarrow> N1 \<le> n' \<Longrightarrow> d1 ((fst \<circ> \<sigma>) n) ((fst \<circ> \<sigma>) n') < \<epsilon>/2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3091
      by (meson M1.MCauchy_def \<open>0 < \<epsilon>\<close> M1 zero_less_divide_iff zero_less_numeral)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3092
    obtain N2 where N2: "\<And>n n'. N2 \<le> n \<Longrightarrow> N2 \<le> n' \<Longrightarrow> d2 ((snd \<circ> \<sigma>) n) ((snd \<circ> \<sigma>) n') < \<epsilon>/2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3093
      by (meson M2.MCauchy_def \<open>0 < \<epsilon>\<close> M2 zero_less_divide_iff zero_less_numeral)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3094
    have "prod_dist d1 d2 (\<sigma> n) (\<sigma> n') < \<epsilon>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3095
      if "N1 \<le> n" and "N2 \<le> n" and "N1 \<le> n'" and "N2 \<le> n'" for n n'
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3096
    proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3097
      obtain a b a' b' where \<sigma>: "\<sigma> n = (a,b)" "\<sigma> n' = (a',b')"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3098
        by fastforce+
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3099
      have "prod_dist d1 d2 (a,b) (a',b') \<le> d1 a a' + d2 b b'"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3100
        by (metis \<open>range \<sigma> \<subseteq> M1 \<times> M2\<close> \<sigma> mem_Sigma_iff prod_metric_le_components range_subsetD)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3101
      also have "\<dots> < \<epsilon>/2 + \<epsilon>/2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3102
        using N1 N2 \<sigma> that by fastforce
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3103
      finally show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3104
        by (simp add: \<sigma>)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3105
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3106
    then show "\<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> prod_dist d1 d2 (\<sigma> n) (\<sigma> n') < \<epsilon>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3107
      by (metis order.trans linorder_le_cases)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3108
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3109
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3110
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3111
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3112
lemma mcomplete_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3113
  "Prod_metric.mcomplete \<longleftrightarrow> M1 = {} \<or> M2 = {} \<or> M1.mcomplete \<and> M2.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3114
  (is "?lhs \<longleftrightarrow> ?rhs")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3115
proof (cases "M1 = {} \<or> M2 = {}")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3116
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3117
  then obtain x y where "x \<in> M1" "y \<in> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3118
    by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3119
  have "M1.mcomplete \<and> M2.mcomplete \<Longrightarrow> Prod_metric.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3120
    by (simp add: Prod_metric.mcomplete_def M1.mcomplete_def M2.mcomplete_def 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3121
        mtopology_prod_metric MCauchy_prod_metric limitin_pairwise)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3122
  moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3123
  { assume L: "Prod_metric.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3124
    have "M1.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3125
      unfolding M1.mcomplete_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3126
    proof (intro strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3127
      fix \<sigma>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3128
      assume "M1.MCauchy \<sigma>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3129
      then have "Prod_metric.MCauchy (\<lambda>n. (\<sigma> n, y))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3130
        using \<open>y \<in> M2\<close> by (simp add: M1.MCauchy_def M2.MCauchy_def MCauchy_prod_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3131
      then obtain z where "limitin Prod_metric.mtopology (\<lambda>n. (\<sigma> n, y)) z sequentially"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3132
        using L Prod_metric.mcomplete_def by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3133
      then show "\<exists>x. limitin M1.mtopology \<sigma> x sequentially"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3134
        by (auto simp: Prod_metric.mcomplete_def M1.mcomplete_def 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3135
             mtopology_prod_metric limitin_pairwise o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3136
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3137
  }
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3138
  moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3139
  { assume L: "Prod_metric.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3140
    have "M2.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3141
      unfolding M2.mcomplete_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3142
    proof (intro strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3143
      fix \<sigma>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3144
      assume "M2.MCauchy \<sigma>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3145
      then have "Prod_metric.MCauchy (\<lambda>n. (x, \<sigma> n))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3146
        using \<open>x \<in> M1\<close> by (simp add: M2.MCauchy_def M1.MCauchy_def MCauchy_prod_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3147
      then obtain z where "limitin Prod_metric.mtopology (\<lambda>n. (x, \<sigma> n)) z sequentially"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3148
        using L Prod_metric.mcomplete_def by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3149
      then show "\<exists>x. limitin M2.mtopology \<sigma> x sequentially"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3150
        by (auto simp: Prod_metric.mcomplete_def M2.mcomplete_def 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3151
             mtopology_prod_metric limitin_pairwise o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3152
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3153
  }
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3154
  ultimately show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3155
    using False by blast 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3156
qed auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3157
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3158
lemma mbounded_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3159
   "Prod_metric.mbounded U \<longleftrightarrow> M1.mbounded  (fst ` U) \<and> M2.mbounded (snd ` U)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3160
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3161
  have "(\<exists>B. U \<subseteq> Prod_metric.mcball (x,y) B) 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3162
    \<longleftrightarrow> ((\<exists>B. (fst ` U) \<subseteq> M1.mcball x B) \<and> (\<exists>B. (snd ` U) \<subseteq> M2.mcball y B))" (is "?lhs \<longleftrightarrow> ?rhs")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3163
    for x y
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3164
  proof safe
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3165
    fix B
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3166
    assume "U \<subseteq> Prod_metric.mcball (x, y) B"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3167
    then have "(fst ` U) \<subseteq> M1.mcball x B" "(snd ` U) \<subseteq> M2.mcball y B"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3168
      using mcball_prod_metric_subset by fastforce+
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3169
    then show "\<exists>B. (fst ` U) \<subseteq> M1.mcball x B" "\<exists>B. (snd ` U) \<subseteq> M2.mcball y B"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3170
      by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3171
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3172
    fix B1 B2
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3173
    assume "(fst ` U) \<subseteq> M1.mcball x B1" "(snd ` U) \<subseteq> M2.mcball y B2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3174
    then have "fst ` U \<times> snd ` U \<subseteq>  M1.mcball x B1 \<times> M2.mcball y B2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3175
      by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3176
    also have "\<dots> \<subseteq> Prod_metric.mcball (x, y) (B1+B2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3177
      by (intro mcball_subset_prod_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3178
    finally show "\<exists>B. U \<subseteq> Prod_metric.mcball (x, y) B"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3179
      by (metis subsetD subsetI subset_fst_snd)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3180
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3181
  then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3182
    by (simp add: M1.mbounded_def M2.mbounded_def Prod_metric.mbounded_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3183
qed 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3184
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3185
lemma mbounded_Times:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3186
   "Prod_metric.mbounded (S \<times> T) \<longleftrightarrow> S = {} \<or> T = {} \<or> M1.mbounded S \<and> M2.mbounded T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3187
  by (auto simp: mbounded_prod_metric)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3188
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3189
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3190
lemma mtotally_bounded_Times:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3191
   "Prod_metric.mtotally_bounded (S \<times> T) \<longleftrightarrow>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3192
    S = {} \<or> T = {} \<or> M1.mtotally_bounded S \<and> M2.mtotally_bounded T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3193
    (is "?lhs \<longleftrightarrow> _")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3194
proof (cases "S = {} \<or> T = {}")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3195
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3196
  then obtain x y where "x \<in> S" "y \<in> T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3197
    by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3198
  have "M1.mtotally_bounded S" if L: ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3199
    unfolding M1.mtotally_bounded_sequentially
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3200
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3201
    show "S \<subseteq> M1"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3202
      using Prod_metric.mtotally_bounded_imp_subset \<open>y \<in> T\<close> that by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3203
    fix \<sigma> :: "nat \<Rightarrow> 'a"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3204
    assume "range \<sigma> \<subseteq> S"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3205
    with L obtain r where "strict_mono r" "Prod_metric.MCauchy ((\<lambda>n. (\<sigma> n,y)) \<circ> r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3206
      unfolding Prod_metric.mtotally_bounded_sequentially
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3207
      by (smt (verit) SigmaI \<open>y \<in> T\<close> image_subset_iff)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3208
    then have "M1.MCauchy (fst \<circ> (\<lambda>n. (\<sigma> n,y)) \<circ> r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3209
      by (simp add: MCauchy_prod_metric o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3210
    with \<open>strict_mono r\<close> show "\<exists>r. strict_mono r \<and> M1.MCauchy (\<sigma> \<circ> r)"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3211
      by (auto simp: o_def)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3212
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3213
  moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3214
  have "M2.mtotally_bounded T" if L: ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3215
    unfolding M2.mtotally_bounded_sequentially
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3216
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3217
    show "T \<subseteq> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3218
      using Prod_metric.mtotally_bounded_imp_subset \<open>x \<in> S\<close> that by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3219
    fix \<sigma> :: "nat \<Rightarrow> 'b"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3220
    assume "range \<sigma> \<subseteq> T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3221
    with L obtain r where "strict_mono r" "Prod_metric.MCauchy ((\<lambda>n. (x,\<sigma> n)) \<circ> r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3222
      unfolding Prod_metric.mtotally_bounded_sequentially
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3223
      by (smt (verit) SigmaI \<open>x \<in> S\<close> image_subset_iff)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3224
    then have "M2.MCauchy (snd \<circ> (\<lambda>n. (x,\<sigma> n)) \<circ> r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3225
      by (simp add: MCauchy_prod_metric o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3226
    with \<open>strict_mono r\<close> show "\<exists>r. strict_mono r \<and> M2.MCauchy (\<sigma> \<circ> r)"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3227
      by (auto simp: o_def)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3228
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3229
  moreover have ?lhs if 1: "M1.mtotally_bounded S" and 2: "M2.mtotally_bounded T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3230
    unfolding Prod_metric.mtotally_bounded_sequentially
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3231
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3232
    show "S \<times> T \<subseteq> M1 \<times> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3233
      using that 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3234
      by (auto simp: M1.mtotally_bounded_sequentially M2.mtotally_bounded_sequentially)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3235
    fix \<sigma> :: "nat \<Rightarrow> 'a \<times> 'b"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3236
    assume \<sigma>: "range \<sigma> \<subseteq> S \<times> T"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3237
    with 1 obtain r1 where r1: "strict_mono r1" "M1.MCauchy (fst \<circ> \<sigma> \<circ> r1)"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3238
      by (metis M1.mtotally_bounded_sequentially comp_apply image_subset_iff mem_Sigma_iff prod.collapse)
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3239
    from \<sigma> 2 obtain r2 where r2: "strict_mono r2" "M2.MCauchy (snd \<circ> \<sigma> \<circ> r1 \<circ> r2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3240
      apply (clarsimp simp: M2.mtotally_bounded_sequentially image_subset_iff)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3241
      by (smt (verit, best) comp_apply mem_Sigma_iff prod.collapse)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3242
    then have "M1.MCauchy (fst \<circ> \<sigma> \<circ> r1 \<circ> r2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3243
      by (simp add: M1.MCauchy_subsequence r1)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3244
    with r2 have "Prod_metric.MCauchy (\<sigma> \<circ> (r1 \<circ> r2))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3245
      by (simp add: MCauchy_prod_metric o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3246
    then show "\<exists>r. strict_mono r \<and> Prod_metric.MCauchy (\<sigma> \<circ> r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3247
      using r1 r2 strict_mono_o by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3248
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3249
  ultimately show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3250
    using False by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3251
qed auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3252
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3253
lemma mtotally_bounded_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3254
   "Prod_metric.mtotally_bounded U \<longleftrightarrow>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3255
    M1.mtotally_bounded (fst ` U) \<and> M2.mtotally_bounded (snd ` U)" (is "?lhs \<longleftrightarrow> ?rhs")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3256
proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3257
  assume L: ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3258
  then have "U \<subseteq> M1 \<times> M2" 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3259
    and *: "\<And>\<sigma>. range \<sigma> \<subseteq> U \<Longrightarrow> \<exists>r::nat\<Rightarrow>nat. strict_mono r \<and> Prod_metric.MCauchy (\<sigma>\<circ>r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3260
    by (simp_all add: Prod_metric.mtotally_bounded_sequentially)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3261
  show ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3262
    unfolding M1.mtotally_bounded_sequentially M2.mtotally_bounded_sequentially
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3263
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3264
    show "fst ` U \<subseteq> M1" "snd ` U \<subseteq> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3265
      using \<open>U \<subseteq> M1 \<times> M2\<close> by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3266
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3267
    fix \<sigma> :: "nat \<Rightarrow> 'a"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3268
    assume "range \<sigma> \<subseteq> fst ` U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3269
    then obtain \<zeta> where \<zeta>: "\<And>n. \<sigma> n = fst (\<zeta> n) \<and> \<zeta> n \<in> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3270
      unfolding image_subset_iff image_iff by (meson UNIV_I)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3271
    then obtain r where "strict_mono r \<and> Prod_metric.MCauchy (\<zeta>\<circ>r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3272
      by (metis "*" image_subset_iff)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3273
    with \<zeta> show "\<exists>r. strict_mono r \<and> M1.MCauchy (\<sigma> \<circ> r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3274
      by (auto simp: MCauchy_prod_metric o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3275
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3276
    fix \<sigma>:: "nat \<Rightarrow> 'b"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3277
    assume "range \<sigma> \<subseteq> snd ` U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3278
    then obtain \<zeta> where \<zeta>: "\<And>n. \<sigma> n = snd (\<zeta> n) \<and> \<zeta> n \<in> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3279
      unfolding image_subset_iff image_iff by (meson UNIV_I)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3280
    then obtain r where "strict_mono r \<and> Prod_metric.MCauchy (\<zeta>\<circ>r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3281
      by (metis "*" image_subset_iff)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3282
    with \<zeta> show "\<exists>r. strict_mono r \<and> M2.MCauchy (\<sigma> \<circ> r)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3283
      by (auto simp: MCauchy_prod_metric o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3284
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3285
next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3286
  assume ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3287
  then have "Prod_metric.mtotally_bounded ((fst ` U) \<times> (snd ` U))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3288
    by (simp add: mtotally_bounded_Times)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3289
  then show ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3290
    by (metis Prod_metric.mtotally_bounded_subset subset_fst_snd)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3291
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3292
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  3293
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  3294
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3295
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3296
lemma metrizable_space_prod_topology:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3297
   "metrizable_space (prod_topology X Y) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3298
    (prod_topology X Y) = trivial_topology \<or> metrizable_space X \<and> metrizable_space Y"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3299
   (is "?lhs \<longleftrightarrow> ?rhs")
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3300
proof (cases "(prod_topology X Y) = trivial_topology")
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3301
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3302
  then obtain x y where "x \<in> topspace X" "y \<in> topspace Y"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3303
    by fastforce
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3304
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3305
  proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3306
    show "?rhs \<Longrightarrow> ?lhs"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3307
      unfolding metrizable_space_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3308
      using Metric_space12.mtopology_prod_metric
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3309
      by (metis False Metric_space12.prod_metric Metric_space12_def) 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3310
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3311
    assume L: ?lhs 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3312
    have "metrizable_space (subtopology (prod_topology X Y) (topspace X \<times> {y}))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3313
      "metrizable_space (subtopology (prod_topology X Y) ({x} \<times> topspace Y))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3314
      using L metrizable_space_subtopology by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3315
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3316
    have "(subtopology (prod_topology X Y) (topspace X \<times> {y})) homeomorphic_space X"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3317
      by (metis \<open>y \<in> topspace Y\<close> homeomorphic_space_prod_topology_sing1 homeomorphic_space_sym prod_topology_subtopology(2))
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3318
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3319
    have "(subtopology (prod_topology X Y) ({x} \<times> topspace Y)) homeomorphic_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3320
      by (metis \<open>x \<in> topspace X\<close> homeomorphic_space_prod_topology_sing2 homeomorphic_space_sym prod_topology_subtopology(1))
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3321
    ultimately show ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3322
      by (simp add: homeomorphic_metrizable_space)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3323
  qed
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3324
qed auto
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3325
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3326
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3327
lemma completely_metrizable_space_prod_topology:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3328
   "completely_metrizable_space (prod_topology X Y) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3329
    (prod_topology X Y) = trivial_topology \<or>
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3330
    completely_metrizable_space X \<and> completely_metrizable_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3331
   (is "?lhs \<longleftrightarrow> ?rhs")
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3332
proof (cases "(prod_topology X Y) = trivial_topology")
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3333
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3334
  then obtain x y where "x \<in> topspace X" "y \<in> topspace Y"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3335
    by fastforce
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3336
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3337
  proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3338
    show "?rhs \<Longrightarrow> ?lhs"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3339
      unfolding completely_metrizable_space_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3340
      by (metis False Metric_space12.mtopology_prod_metric Metric_space12.mcomplete_prod_metric
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3341
          Metric_space12.prod_metric Metric_space12_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3342
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3343
    assume L: ?lhs 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3344
    then have "Hausdorff_space (prod_topology X Y)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3345
      by (simp add: completely_metrizable_imp_metrizable_space metrizable_imp_Hausdorff_space)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3346
    then have H: "Hausdorff_space X \<and> Hausdorff_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3347
      using False Hausdorff_space_prod_topology by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3348
    then have "closedin (prod_topology X Y) (topspace X \<times> {y}) \<and> closedin (prod_topology X Y) ({x} \<times> topspace Y)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3349
      using \<open>x \<in> topspace X\<close> \<open>y \<in> topspace Y\<close>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3350
      by (auto simp: closedin_Hausdorff_sing_eq closedin_prod_Times_iff)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3351
    with L have "completely_metrizable_space(subtopology (prod_topology X Y) (topspace X \<times> {y}))
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3352
               \<and> completely_metrizable_space(subtopology (prod_topology X Y) ({x} \<times> topspace Y))"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3353
      by (simp add: completely_metrizable_space_closedin)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3354
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3355
    have "(subtopology (prod_topology X Y) (topspace X \<times> {y})) homeomorphic_space X"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3356
      by (metis \<open>y \<in> topspace Y\<close> homeomorphic_space_prod_topology_sing1 homeomorphic_space_sym prod_topology_subtopology(2))
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3357
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3358
    have "(subtopology (prod_topology X Y) ({x} \<times> topspace Y)) homeomorphic_space Y"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3359
      by (metis \<open>x \<in> topspace X\<close> homeomorphic_space_prod_topology_sing2 homeomorphic_space_sym prod_topology_subtopology(1))
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3360
    ultimately show ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3361
      by (simp add: homeomorphic_completely_metrizable_space)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3362
  qed
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3363
next
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3364
  case True then show ?thesis
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3365
    using empty_completely_metrizable_space by auto
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3366
qed 
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3367
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3368
    
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3369
subsection\<open>More sequential characterizations in a metric space\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3370
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3371
context Metric_space
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3372
begin
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3373
  
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3374
definition decreasing_dist :: "(nat \<Rightarrow> 'a) \<Rightarrow> 'a \<Rightarrow> bool"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3375
    where "decreasing_dist \<sigma> x \<equiv> (\<forall>m n. m < n \<longrightarrow> d (\<sigma> n) x < d (\<sigma> m) x)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3376
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3377
lemma decreasing_dist_imp_inj: "decreasing_dist \<sigma> a \<Longrightarrow> inj \<sigma>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3378
  by (metis decreasing_dist_def dual_order.irrefl linorder_inj_onI')
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3379
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3380
lemma eventually_atin_within_metric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3381
   "eventually P (atin_within mtopology a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3382
    (a \<in> M \<longrightarrow> (\<exists>\<delta>>0. \<forall>x. x \<in> M \<and> x \<in> S \<and> 0 < d x a \<and> d x a < \<delta> \<longrightarrow> P x))" (is "?lhs=?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3383
proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3384
  assume ?lhs then show ?rhs
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3385
unfolding eventually_atin_within openin_mtopology subset_iff
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3386
  by (metis commute in_mball mdist_zero order_less_irrefl topspace_mtopology)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3387
next
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3388
  assume R: ?rhs 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3389
  show ?lhs
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3390
  proof (cases "a \<in> M")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3391
    case True
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3392
    then obtain \<delta> where "\<delta> > 0" and \<delta>: "\<And>x. \<lbrakk>x \<in> M; x \<in> S; 0 < d x a; d x a < \<delta>\<rbrakk> \<Longrightarrow> P x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3393
      using R by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3394
    then have "openin mtopology (mball a \<delta>) \<and> (\<forall>x \<in> mball a \<delta>. x \<in> S \<and> x \<noteq> a \<longrightarrow> P x)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3395
      by (simp add: commute openin_mball)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3396
    then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3397
      by (metis True \<open>0 < \<delta>\<close> centre_in_mball_iff eventually_atin_within) 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3398
  next
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3399
    case False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3400
    with R show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3401
      by (simp add: eventually_atin_within)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3402
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3403
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3404
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3405
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3406
lemma eventually_atin_within_A:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3407
  assumes 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3408
    "(\<And>\<sigma>. \<lbrakk>range \<sigma> \<subseteq> (S \<inter> M) - {a}; decreasing_dist \<sigma> a;
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3409
          inj \<sigma>; limitin mtopology \<sigma> a sequentially\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3410
      \<Longrightarrow> eventually (\<lambda>n. P (\<sigma> n)) sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3411
  shows "eventually P (atin_within mtopology a S)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3412
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3413
  have False if SP: "\<And>\<delta>. \<delta>>0 \<Longrightarrow> \<exists>x \<in> M-{a}. d x a < \<delta> \<and> x \<in> S \<and> \<not> P x" and "a \<in> M"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3414
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3415
    define \<Phi> where "\<Phi> \<equiv> \<lambda>n x. x \<in> M-{a} \<and> d x a < inverse (Suc n) \<and> x \<in> S \<and> \<not> P x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3416
    obtain \<sigma> where \<sigma>: "\<And>n. \<Phi> n (\<sigma> n)" and dless: "\<And>n. d (\<sigma>(Suc n)) a < d (\<sigma> n) a"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3417
    proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3418
      obtain x0 where x0: "\<Phi> 0 x0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3419
        using SP [OF zero_less_one] by (force simp: \<Phi>_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3420
      have "\<exists>y. \<Phi> (Suc n) y \<and> d y a < d x a" if "\<Phi> n x" for n x
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3421
        using SP [of "min (inverse (Suc (Suc n))) (d x a)"] \<open>a \<in> M\<close> that
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3422
        by (auto simp: \<Phi>_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3423
      then obtain f where f: "\<And>n x. \<Phi> n x \<Longrightarrow> \<Phi> (Suc n) (f n x) \<and> d (f n x) a < d x a" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3424
        by metis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3425
      show thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3426
        proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3427
          show "\<Phi> n (rec_nat x0 f n)" for n
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3428
            by (induction n) (auto simp: x0 dest: f)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3429
          with f show "d (rec_nat x0 f (Suc n)) a < d (rec_nat x0 f n) a" for n
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3430
            by auto 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3431
        qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3432
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3433
    have 1: "range \<sigma> \<subseteq> (S \<inter> M) - {a}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3434
      using \<sigma> by (auto simp: \<Phi>_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3435
    have "d (\<sigma>(Suc (m+n))) a < d (\<sigma> n) a" for m n
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3436
      by (induction m) (auto intro: order_less_trans dless)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3437
    then have 2: "decreasing_dist \<sigma> a"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3438
      unfolding decreasing_dist_def by (metis add.commute less_imp_Suc_add)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3439
    have "\<forall>\<^sub>F xa in sequentially. d (\<sigma> xa) a < \<epsilon>" if "\<epsilon> > 0" for \<epsilon>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3440
    proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3441
      obtain N where "inverse (Suc N) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3442
        using \<open>\<epsilon> > 0\<close> reals_Archimedean by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3443
      with \<sigma> 2 show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3444
        unfolding decreasing_dist_def by (smt (verit, best) \<Phi>_def eventually_at_top_dense)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3445
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3446
    then have 4: "limitin mtopology \<sigma> a sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3447
      using \<sigma> \<open>a \<in> M\<close> by (simp add: \<Phi>_def limitin_metric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3448
    show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3449
      using 2 assms [OF 1 _ decreasing_dist_imp_inj 4] \<sigma> by (force simp: \<Phi>_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3450
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3451
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3452
    by (fastforce simp: eventually_atin_within_metric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3453
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3454
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3455
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3456
lemma eventually_atin_within_B:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3457
  assumes ev: "eventually P (atin_within mtopology a S)" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3458
    and ran: "range \<sigma> \<subseteq> (S \<inter> M) - {a}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3459
    and lim: "limitin mtopology \<sigma> a sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3460
  shows "eventually (\<lambda>n. P (\<sigma> n)) sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3461
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3462
  have "a \<in> M"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3463
    using lim limitin_mspace by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3464
  with ev obtain \<delta> where "0 < \<delta>" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3465
    and \<delta>: "\<And>\<sigma>. \<lbrakk>\<sigma> \<in> M; \<sigma> \<in> S; 0 < d \<sigma> a; d \<sigma> a < \<delta>\<rbrakk> \<Longrightarrow> P \<sigma>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3466
    by (auto simp: eventually_atin_within_metric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3467
  then have *: "\<And>n. \<sigma> n \<in> M \<and> d (\<sigma> n) a < \<delta> \<Longrightarrow> P (\<sigma> n)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3468
    using \<open>a \<in> M\<close> ran by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3469
  have "\<forall>\<^sub>F n in sequentially. \<sigma> n \<in> M \<and> d (\<sigma> n) a < \<delta>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3470
    using lim \<open>0 < \<delta>\<close> by (auto simp: limitin_metric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3471
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3472
    by (simp add: "*" eventually_mono)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3473
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3474
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3475
lemma eventually_atin_within_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3476
     "eventually P (atin_within mtopology a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3477
        (\<forall>\<sigma>. range \<sigma> \<subseteq> (S \<inter> M) - {a} \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3478
            limitin mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3479
            \<longrightarrow> eventually (\<lambda>n. P(\<sigma> n)) sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3480
  by (metis eventually_atin_within_A eventually_atin_within_B)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3481
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3482
lemma eventually_atin_within_sequentially_inj:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3483
     "eventually P (atin_within mtopology a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3484
        (\<forall>\<sigma>. range \<sigma> \<subseteq> (S \<inter> M) - {a} \<and> inj \<sigma> \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3485
            limitin mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3486
            \<longrightarrow> eventually (\<lambda>n. P(\<sigma> n)) sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3487
  by (metis eventually_atin_within_A eventually_atin_within_B)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3488
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3489
lemma eventually_atin_within_sequentially_decreasing:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3490
     "eventually P (atin_within mtopology a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3491
        (\<forall>\<sigma>. range \<sigma> \<subseteq> (S \<inter> M) - {a} \<and> decreasing_dist \<sigma> a \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3492
            limitin mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3493
            \<longrightarrow> eventually (\<lambda>n. P(\<sigma> n)) sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3494
  by (metis eventually_atin_within_A eventually_atin_within_B)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3495
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3496
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3497
lemma eventually_atin_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3498
   "eventually P (atin mtopology a) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3499
    (\<forall>\<sigma>. range \<sigma> \<subseteq> M - {a} \<and> limitin mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3500
         \<longrightarrow> eventually (\<lambda>n. P(\<sigma> n)) sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3501
  using eventually_atin_within_sequentially [where S=UNIV] by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3502
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3503
lemma eventually_atin_sequentially_inj:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3504
   "eventually P (atin mtopology a) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3505
    (\<forall>\<sigma>. range \<sigma> \<subseteq> M - {a} \<and> inj \<sigma> \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3506
        limitin mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3507
        \<longrightarrow> eventually (\<lambda>n. P(\<sigma> n)) sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3508
  using eventually_atin_within_sequentially_inj [where S=UNIV] by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3509
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3510
lemma eventually_atin_sequentially_decreasing:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3511
   "eventually P (atin mtopology a) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3512
    (\<forall>\<sigma>. range \<sigma> \<subseteq> M - {a} \<and> decreasing_dist \<sigma> a \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3513
         limitin mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3514
        \<longrightarrow> eventually (\<lambda>n. P(\<sigma> n)) sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3515
  using eventually_atin_within_sequentially_decreasing [where S=UNIV] by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3516
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3517
end
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3518
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3519
context Metric_space12
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3520
begin
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3521
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3522
lemma limit_atin_sequentially_within:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3523
  "limitin M2.mtopology f l (atin_within M1.mtopology a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3524
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3525
     (\<forall>\<sigma>. range \<sigma> \<subseteq> S \<inter> M1 - {a} \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3526
          limitin M1.mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3527
          \<longrightarrow> limitin M2.mtopology (f \<circ> \<sigma>) l sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3528
    by (auto simp: M1.eventually_atin_within_sequentially limitin_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3529
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3530
lemma limit_atin_sequentially_within_inj:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3531
  "limitin M2.mtopology f l (atin_within M1.mtopology a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3532
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3533
     (\<forall>\<sigma>. range \<sigma> \<subseteq> S \<inter> M1 - {a} \<and> inj \<sigma> \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3534
          limitin M1.mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3535
          \<longrightarrow> limitin M2.mtopology (f \<circ> \<sigma>) l sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3536
    by (auto simp: M1.eventually_atin_within_sequentially_inj limitin_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3537
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3538
lemma limit_atin_sequentially_within_decreasing:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3539
  "limitin M2.mtopology f l (atin_within M1.mtopology a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3540
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3541
     (\<forall>\<sigma>. range \<sigma> \<subseteq> S \<inter> M1 - {a} \<and> M1.decreasing_dist \<sigma> a \<and> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3542
          limitin M1.mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3543
          \<longrightarrow> limitin M2.mtopology (f \<circ> \<sigma>) l sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3544
    by (auto simp: M1.eventually_atin_within_sequentially_decreasing limitin_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3545
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3546
lemma limit_atin_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3547
   "limitin M2.mtopology f l (atin M1.mtopology a) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3548
        l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3549
        (\<forall>\<sigma>. range \<sigma> \<subseteq> M1 - {a} \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3550
            limitin M1.mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3551
            \<longrightarrow> limitin M2.mtopology (f \<circ> \<sigma>) l sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3552
  using limit_atin_sequentially_within [where S=UNIV] by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3553
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3554
lemma limit_atin_sequentially_inj:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3555
   "limitin M2.mtopology f l (atin M1.mtopology a) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3556
        l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3557
        (\<forall>\<sigma>. range \<sigma> \<subseteq> M1 - {a} \<and> inj \<sigma> \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3558
            limitin M1.mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3559
            \<longrightarrow> limitin M2.mtopology (f \<circ> \<sigma>) l sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3560
  using limit_atin_sequentially_within_inj [where S=UNIV] by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3561
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3562
lemma limit_atin_sequentially_decreasing:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3563
  "limitin M2.mtopology f l (atin M1.mtopology a) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3564
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3565
     (\<forall>\<sigma>. range \<sigma> \<subseteq> M1 - {a} \<and> M1.decreasing_dist \<sigma> a \<and> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3566
          limitin M1.mtopology \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3567
          \<longrightarrow> limitin M2.mtopology (f \<circ> \<sigma>) l sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3568
  using limit_atin_sequentially_within_decreasing [where S=UNIV] by simp
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3569
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3570
end
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3571
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3572
text \<open>An experiment: same result as within the locale, but using metric space variables\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3573
lemma limit_atin_sequentially_within:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3574
  "limitin (mtopology_of m2) f l (atin_within (mtopology_of m1) a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3575
     l \<in> mspace m2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3576
     (\<forall>\<sigma>. range \<sigma> \<subseteq> S \<inter> mspace m1 - {a} \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3577
          limitin (mtopology_of m1) \<sigma> a sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3578
          \<longrightarrow> limitin (mtopology_of m2) (f \<circ> \<sigma>) l sequentially)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3579
  using Metric_space12.limit_atin_sequentially_within [OF Metric_space12_mspace_mdist]
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3580
  by (metis mtopology_of_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3581
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3582
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3583
context Metric_space
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3584
begin
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3585
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3586
lemma atin_within_imp_M:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3587
   "atin_within mtopology x S \<noteq> bot \<Longrightarrow> x \<in> M"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3588
  by (metis derived_set_of_trivial_limit in_derived_set_of topspace_mtopology)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3589
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3590
lemma atin_within_sequentially_sequence:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3591
  assumes "atin_within mtopology x S \<noteq> bot"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3592
  obtains \<sigma> where "range \<sigma> \<subseteq> S \<inter> M - {x}" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3593
          "decreasing_dist \<sigma> x" "inj \<sigma>" "limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3594
  by (metis eventually_atin_within_A eventually_False assms)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3595
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3596
lemma derived_set_of_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3597
  "mtopology derived_set_of S =
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3598
   {x \<in> M. \<exists>\<sigma>. range \<sigma> \<subseteq> S \<inter> M - {x} \<and> limitin mtopology \<sigma> x sequentially}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3599
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3600
  have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3601
    if "range \<sigma> \<subseteq> S \<inter> M - {x}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3602
      and "limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3603
      and "atin_within mtopology x S = bot"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3604
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3605
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3606
    have "\<forall>\<^sub>F n in sequentially. P (\<sigma> n)" for P
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3607
      using that by (metis eventually_atin_within_B eventually_bot)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3608
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3609
      by (meson eventually_False_sequentially eventually_mono)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3610
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3611
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3612
    using derived_set_of_trivial_limit 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3613
    by (fastforce elim!: atin_within_sequentially_sequence intro: atin_within_imp_M)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3614
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3615
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3616
lemma derived_set_of_sequentially_alt:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3617
  "mtopology derived_set_of S =
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3618
   {x. \<exists>\<sigma>. range \<sigma> \<subseteq> S - {x} \<and> limitin mtopology \<sigma> x sequentially}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3619
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3620
  have *: "\<exists>\<sigma>. range \<sigma> \<subseteq> S \<inter> M - {x} \<and> limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3621
    if \<sigma>: "range \<sigma> \<subseteq> S - {x}" and lim: "limitin mtopology \<sigma> x sequentially" for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3622
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3623
    obtain N where "\<forall>n\<ge>N. \<sigma> n \<in> M \<and> d (\<sigma> n) x < 1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3624
      using lim limit_metric_sequentially by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3625
    with \<sigma> obtain a where a:"a \<in> S \<inter> M - {x}" by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3626
    show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3627
    proof (intro conjI exI)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3628
      show "range (\<lambda>n. if \<sigma> n \<in> M then \<sigma> n else a) \<subseteq> S \<inter> M - {x}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3629
        using a \<sigma> by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3630
      show "limitin mtopology (\<lambda>n. if \<sigma> n \<in> M then \<sigma> n else a) x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3631
        using lim limit_metric_sequentially by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3632
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3633
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3634
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3635
    by (auto simp: limitin_mspace derived_set_of_sequentially intro!: *)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3636
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3637
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3638
lemma derived_set_of_sequentially_inj:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3639
   "mtopology derived_set_of S =
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3640
    {x \<in> M. \<exists>\<sigma>. range \<sigma> \<subseteq> S \<inter> M - {x} \<and> inj \<sigma> \<and> limitin mtopology \<sigma> x sequentially}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3641
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3642
  have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3643
    if "x \<in> M" and "range \<sigma> \<subseteq> S \<inter> M - {x}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3644
      and "limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3645
      and "atin_within mtopology x S = bot"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3646
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3647
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3648
    have "\<forall>\<^sub>F n in sequentially. P (\<sigma> n)" for P
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3649
      using that derived_set_of_sequentially_alt derived_set_of_trivial_limit by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3650
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3651
      by (meson eventually_False_sequentially eventually_mono)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3652
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3653
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3654
    using derived_set_of_trivial_limit 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3655
    by (fastforce elim!: atin_within_sequentially_sequence intro: atin_within_imp_M)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3656
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3657
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3658
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3659
lemma derived_set_of_sequentially_inj_alt:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3660
   "mtopology derived_set_of S =
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3661
    {x. \<exists>\<sigma>. range \<sigma> \<subseteq> S - {x} \<and> inj \<sigma> \<and> limitin mtopology \<sigma> x sequentially}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3662
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3663
  have "\<exists>\<sigma>. range \<sigma> \<subseteq> S - {x} \<and> inj \<sigma> \<and> limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3664
    if "atin_within mtopology x S \<noteq> bot" for x
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3665
    by (metis Diff_empty Int_subset_iff atin_within_sequentially_sequence subset_Diff_insert that)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3666
  moreover have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3667
    if "range (\<lambda>x. \<sigma> (x::nat)) \<subseteq> S - {x}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3668
      and "limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3669
      and "atin_within mtopology x S = bot"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3670
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3671
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3672
    have "\<forall>\<^sub>F n in sequentially. P (\<sigma> n)" for P
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3673
      using that derived_set_of_sequentially_alt derived_set_of_trivial_limit by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3674
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3675
      by (meson eventually_False_sequentially eventually_mono)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3676
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3677
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3678
    using derived_set_of_trivial_limit by (fastforce intro: atin_within_imp_M)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3679
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3680
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3681
lemma derived_set_of_sequentially_decreasing:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3682
   "mtopology derived_set_of S =
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3683
    {x \<in> M. \<exists>\<sigma>. range \<sigma> \<subseteq> S - {x} \<and> decreasing_dist \<sigma> x \<and> limitin mtopology \<sigma> x sequentially}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3684
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3685
  have "\<exists>\<sigma>. range \<sigma> \<subseteq> S - {x} \<and> decreasing_dist \<sigma> x \<and> limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3686
    if "atin_within mtopology x S \<noteq> bot" for x
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3687
    by (metis Diff_empty atin_within_sequentially_sequence le_infE subset_Diff_insert that)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3688
  moreover have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3689
    if "x \<in> M" and "range \<sigma> \<subseteq> S - {x}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3690
      and "limitin mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3691
      and "atin_within mtopology x S = bot"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3692
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3693
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3694
    have "\<forall>\<^sub>F n in sequentially. P (\<sigma> n)" for P
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3695
      using that derived_set_of_sequentially_alt derived_set_of_trivial_limit by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3696
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3697
      by (meson eventually_False_sequentially eventually_mono)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3698
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3699
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3700
    using derived_set_of_trivial_limit by (fastforce intro: atin_within_imp_M)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3701
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3702
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3703
lemma derived_set_of_sequentially_decreasing_alt:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3704
   "mtopology derived_set_of S =
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3705
    {x. \<exists>\<sigma>. range \<sigma> \<subseteq> S - {x} \<and> decreasing_dist \<sigma> x \<and> limitin mtopology \<sigma> x sequentially}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3706
  using derived_set_of_sequentially_alt derived_set_of_sequentially_decreasing by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3707
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3708
lemma closure_of_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3709
   "mtopology closure_of S = 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3710
    {x \<in> M. \<exists>\<sigma>. range \<sigma> \<subseteq> S \<inter> M \<and> limitin mtopology \<sigma> x sequentially}"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3711
  by (auto simp: closure_of derived_set_of_sequentially)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3712
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3713
end (*Metric_space*)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3714
    
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3715
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3716
subsection \<open>Three strong notions of continuity for metric spaces\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3717
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3718
subsubsection \<open>Lipschitz continuity\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3719
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3720
definition Lipschitz_continuous_map 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3721
  where "Lipschitz_continuous_map \<equiv> 
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3722
      \<lambda>m1 m2 f. f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3723
        (\<exists>B. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3724
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3725
lemma Lipschitz_continuous_map_image: 
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3726
  "Lipschitz_continuous_map m1 m2 f \<Longrightarrow> f \<in> mspace m1 \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3727
  by (simp add: Lipschitz_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3728
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3729
lemma Lipschitz_continuous_map_pos:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3730
   "Lipschitz_continuous_map m1 m2 f \<longleftrightarrow>
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3731
    f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3732
        (\<exists>B>0. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3733
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3734
  have "B * mdist m1 x y \<le> (\<bar>B\<bar> + 1) * mdist m1 x y" "\<bar>B\<bar> + 1 > 0" for x y B
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3735
    by (auto simp: mult_right_mono)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3736
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3737
    unfolding Lipschitz_continuous_map_def by (meson dual_order.trans)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3738
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3739
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3740
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3741
lemma Lipschitz_continuous_map_eq:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3742
  assumes "Lipschitz_continuous_map m1 m2 f" "\<And>x. x \<in> mspace m1 \<Longrightarrow> f x = g x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3743
  shows "Lipschitz_continuous_map m1 m2 g"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3744
  using Lipschitz_continuous_map_def assms by (simp add: Lipschitz_continuous_map_pos Pi_iff)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3745
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3746
lemma Lipschitz_continuous_map_from_submetric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3747
  assumes "Lipschitz_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3748
  shows "Lipschitz_continuous_map (submetric m1 S) m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3749
  unfolding Lipschitz_continuous_map_def 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3750
proof
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3751
  show "f \<in> mspace (submetric m1 S) \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3752
    using Lipschitz_continuous_map_pos assms by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3753
qed (use assms in \<open>fastforce simp: Lipschitz_continuous_map_def\<close>)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3754
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3755
lemma Lipschitz_continuous_map_from_submetric_mono:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3756
   "\<lbrakk>Lipschitz_continuous_map (submetric m1 T) m2 f; S \<subseteq> T\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3757
           \<Longrightarrow> Lipschitz_continuous_map (submetric m1 S) m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3758
  by (metis Lipschitz_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3759
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3760
lemma Lipschitz_continuous_map_into_submetric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3761
   "Lipschitz_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3762
        f \<in> mspace m1 \<rightarrow> S \<and> Lipschitz_continuous_map m1 m2 f"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3763
  by (auto simp: Lipschitz_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3764
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3765
lemma Lipschitz_continuous_map_const:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3766
  "Lipschitz_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3767
        mspace m1 = {} \<or> c \<in> mspace m2"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3768
  unfolding Lipschitz_continuous_map_def Pi_iff
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3769
  by (metis all_not_in_conv mdist_nonneg mdist_zero mult_1)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3770
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3771
lemma Lipschitz_continuous_map_id:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3772
   "Lipschitz_continuous_map m1 m1 (\<lambda>x. x)"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3773
  unfolding Lipschitz_continuous_map_def by (metis funcset_id mult_1 order_refl)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3774
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3775
lemma Lipschitz_continuous_map_compose:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3776
  assumes f: "Lipschitz_continuous_map m1 m2 f" and g: "Lipschitz_continuous_map m2 m3 g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3777
  shows "Lipschitz_continuous_map m1 m3 (g \<circ> f)"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3778
  unfolding Lipschitz_continuous_map_def 
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3779
proof
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3780
  show "g \<circ> f \<in> mspace m1 \<rightarrow> mspace m3"
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3781
    by (smt (verit, best) Lipschitz_continuous_map_image Pi_iff comp_apply f g)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3782
  obtain B where B: "\<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3783
    using assms unfolding Lipschitz_continuous_map_def by presburger
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3784
  obtain C where "C>0" and C: "\<forall>x\<in>mspace m2. \<forall>y\<in>mspace m2. mdist m3 (g x) (g y) \<le> C * mdist m2 x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3785
    using assms unfolding Lipschitz_continuous_map_pos by metis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3786
  show "\<exists>B. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> B * mdist m1 x y"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3787
  proof (intro strip exI)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3788
    fix x y
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3789
    assume \<section>: "x \<in> mspace m1" "y \<in> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3790
    then have "mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> C * mdist m2 (f x) (f y)"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3791
      using C Lipschitz_continuous_map_image f by fastforce
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3792
    also have "\<dots> \<le> C * B * mdist m1 x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3793
      by (simp add: "\<section>" B \<open>0 < C\<close>)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3794
    finally show "mdist m3 ((g \<circ> f) x) ((g \<circ> f) y) \<le> C * B * mdist m1 x y" .
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3795
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3796
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3797
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3798
subsubsection \<open>Uniform continuity\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3799
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3800
definition uniformly_continuous_map 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3801
  where "uniformly_continuous_map \<equiv> 
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3802
      \<lambda>m1 m2 f. f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3803
        (\<forall>\<epsilon>>0. \<exists>\<delta>>0. \<forall>x \<in> mspace m1. \<forall>y \<in> mspace m1. 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3804
                           mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3805
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3806
lemma uniformly_continuous_map_funspace: 
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3807
  "uniformly_continuous_map m1 m2 f \<Longrightarrow> f \<in> mspace m1 \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3808
  by (simp add: uniformly_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3809
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3810
lemma ucmap_A:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3811
  assumes "uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3812
  and "(\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3813
    and "range \<rho> \<subseteq> mspace m1" "range \<sigma> \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3814
  shows "(\<lambda>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n))) \<longlonglongrightarrow> 0"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3815
  using assms 
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3816
  unfolding uniformly_continuous_map_def image_subset_iff tendsto_iff
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3817
  apply clarsimp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3818
  by (metis (mono_tags, lifting) eventually_sequentially)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3819
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3820
lemma ucmap_B:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3821
  assumes \<section>: "\<And>\<rho> \<sigma>. \<lbrakk>range \<rho> \<subseteq> mspace m1; range \<sigma> \<subseteq> mspace m1;
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3822
              (\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3823
              \<Longrightarrow> (\<lambda>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n))) \<longlonglongrightarrow> 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3824
    and "0 < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3825
    and \<rho>: "range \<rho> \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3826
    and \<sigma>: "range \<sigma> \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3827
    and "(\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3828
  shows "\<exists>n. mdist m2 (f (\<rho> (n::nat))) (f (\<sigma> n)) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3829
  using \<section> [OF \<rho> \<sigma>] assms by (meson LIMSEQ_le_const linorder_not_less)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3830
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3831
lemma ucmap_C: 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3832
  assumes \<section>: "\<And>\<rho> \<sigma> \<epsilon>. \<lbrakk>\<epsilon> > 0; range \<rho> \<subseteq> mspace m1; range \<sigma> \<subseteq> mspace m1;
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3833
                       ((\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0)\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3834
                      \<Longrightarrow> \<exists>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n)) < \<epsilon>"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3835
    and fim: "f \<in> mspace m1 \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3836
  shows "uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3837
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3838
  {assume "\<not> (\<forall>\<epsilon>>0. \<exists>\<delta>>0. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>)" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3839
    then obtain \<epsilon> where "\<epsilon> > 0" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3840
      and "\<And>n. \<exists>x\<in>mspace m1. \<exists>y\<in>mspace m1. mdist m1 y x < inverse(Suc n) \<and> mdist m2 (f y) (f x) \<ge> \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3841
      by (meson inverse_Suc linorder_not_le)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3842
    then obtain \<rho> \<sigma> where space: "range \<rho> \<subseteq> mspace m1" "range \<sigma> \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3843
         and dist: "\<And>n. mdist m1 (\<sigma> n) (\<rho> n) < inverse(Suc n) \<and> mdist m2 (f(\<sigma> n)) (f(\<rho> n)) \<ge> \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3844
      by (metis image_subset_iff)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3845
    have False 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3846
      using \<section> [OF \<open>\<epsilon> > 0\<close> space] dist Lim_null_comparison
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3847
      by (smt (verit) LIMSEQ_norm_0 inverse_eq_divide mdist_commute mdist_nonneg real_norm_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3848
  }
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3849
  moreover
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3850
  have "t \<in> mspace m2" if "t \<in> f ` mspace m1" for t
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3851
    using fim that by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3852
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3853
    by (fastforce simp: uniformly_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3854
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3855
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3856
lemma uniformly_continuous_map_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3857
  "uniformly_continuous_map m1 m2 f \<longleftrightarrow>
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3858
    f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3859
    (\<forall>\<rho> \<sigma>. range \<rho> \<subseteq> mspace m1 \<and> range \<sigma> \<subseteq> mspace m1 \<and> (\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3860
          \<longrightarrow> (\<lambda>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n))) \<longlonglongrightarrow> 0)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3861
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3862
proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3863
  show "?lhs \<Longrightarrow> ?rhs"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3864
    by (simp add: ucmap_A uniformly_continuous_map_funspace)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3865
  show "?rhs \<Longrightarrow> ?lhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3866
    by (intro ucmap_B ucmap_C) auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3867
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3868
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3869
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3870
lemma uniformly_continuous_map_sequentially_alt:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3871
    "uniformly_continuous_map m1 m2 f \<longleftrightarrow>
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3872
      f \<in> mspace m1 \<rightarrow> mspace m2 \<and>
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3873
      (\<forall>\<epsilon>>0. \<forall>\<rho> \<sigma>. range \<rho> \<subseteq> mspace m1 \<and> range \<sigma> \<subseteq> mspace m1 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3874
            ((\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3875
            \<longrightarrow> (\<exists>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n)) < \<epsilon>))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3876
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3877
proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3878
  show "?lhs \<Longrightarrow> ?rhs"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3879
    using uniformly_continuous_map_funspace by (intro conjI strip ucmap_B | fastforce simp: ucmap_A)+
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3880
  show "?rhs \<Longrightarrow> ?lhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3881
    by (intro ucmap_C) auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3882
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3883
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3884
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3885
lemma uniformly_continuous_map_eq:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3886
   "\<lbrakk>\<And>x. x \<in> mspace m1 \<Longrightarrow> f x = g x; uniformly_continuous_map m1 m2 f\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3887
      \<Longrightarrow> uniformly_continuous_map m1 m2 g"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3888
  by (simp add: uniformly_continuous_map_def Pi_iff)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3889
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3890
lemma uniformly_continuous_map_from_submetric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3891
  assumes "uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3892
  shows "uniformly_continuous_map (submetric m1 S) m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3893
  unfolding uniformly_continuous_map_def 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3894
proof
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3895
  show "f \<in> mspace (submetric m1 S) \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3896
    using assms by (auto simp: uniformly_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3897
qed (use assms in \<open>force simp: uniformly_continuous_map_def\<close>)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3898
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3899
lemma uniformly_continuous_map_from_submetric_mono:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3900
   "\<lbrakk>uniformly_continuous_map (submetric m1 T) m2 f; S \<subseteq> T\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3901
           \<Longrightarrow> uniformly_continuous_map (submetric m1 S) m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3902
  by (metis uniformly_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3903
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3904
lemma uniformly_continuous_map_into_submetric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3905
   "uniformly_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3906
        f \<in> mspace m1 \<rightarrow> S \<and> uniformly_continuous_map m1 m2 f"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3907
  by (auto simp: uniformly_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3908
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3909
lemma uniformly_continuous_map_const:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3910
  "uniformly_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3911
        mspace m1 = {} \<or> c \<in> mspace m2"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3912
  unfolding uniformly_continuous_map_def Pi_iff
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3913
  by (metis empty_iff equals0I mdist_zero)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3914
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3915
lemma uniformly_continuous_map_id [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3916
   "uniformly_continuous_map m1 m1 (\<lambda>x. x)"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3917
  by (metis funcset_id uniformly_continuous_map_def)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3918
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3919
lemma uniformly_continuous_map_compose:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3920
  assumes f: "uniformly_continuous_map m1 m2 f" and g: "uniformly_continuous_map m2 m3 g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3921
  shows "uniformly_continuous_map m1 m3 (g \<circ> f)"
78748
ca486ee0e4c5 New proofs also some slightly faster existing proofs
paulson <lp15@cam.ac.uk>
parents: 78336
diff changeset
  3922
  using f g unfolding uniformly_continuous_map_def comp_apply Pi_iff
ca486ee0e4c5 New proofs also some slightly faster existing proofs
paulson <lp15@cam.ac.uk>
parents: 78336
diff changeset
  3923
  by metis
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3924
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3925
lemma uniformly_continuous_map_real_const [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3926
   "uniformly_continuous_map m euclidean_metric (\<lambda>x. c)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3927
  by (simp add: euclidean_metric_def uniformly_continuous_map_const)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3928
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3929
text \<open>Equivalence between "abstract" and "type class" notions\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3930
lemma uniformly_continuous_map_euclidean [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3931
  "uniformly_continuous_map (submetric euclidean_metric S) euclidean_metric f
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3932
     = uniformly_continuous_on S f"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3933
  by (auto simp: uniformly_continuous_map_def uniformly_continuous_on_def)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3934
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3935
subsubsection \<open>Cauchy continuity\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3936
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3937
definition Cauchy_continuous_map where
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3938
 "Cauchy_continuous_map \<equiv>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3939
  \<lambda>m1 m2 f. \<forall>\<sigma>. Metric_space.MCauchy (mspace m1) (mdist m1) \<sigma> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3940
            \<longrightarrow> Metric_space.MCauchy (mspace m2) (mdist m2) (f \<circ> \<sigma>)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3941
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3942
lemma Cauchy_continuous_map_euclidean [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3943
  "Cauchy_continuous_map (submetric euclidean_metric S) euclidean_metric f
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3944
     = Cauchy_continuous_on S f"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  3945
  by (auto simp: Cauchy_continuous_map_def Cauchy_continuous_on_def Cauchy_def Met_TC.subspace Metric_space.MCauchy_def)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3946
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3947
lemma Cauchy_continuous_map_funspace:
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3948
  assumes "Cauchy_continuous_map m1 m2 f"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3949
  shows "f \<in> mspace m1 \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3950
proof clarsimp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3951
  fix x
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3952
  assume "x \<in> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3953
  then have "Metric_space.MCauchy (mspace m1) (mdist m1) (\<lambda>n. x)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3954
    by (simp add: Metric_space.MCauchy_const Metric_space_mspace_mdist)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3955
  then have "Metric_space.MCauchy (mspace m2) (mdist m2) (f \<circ> (\<lambda>n. x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3956
    by (meson Cauchy_continuous_map_def assms)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3957
  then show "f x \<in> mspace m2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3958
    by (simp add: Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3959
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3960
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3961
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3962
lemma Cauchy_continuous_map_eq:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3963
   "\<lbrakk>\<And>x. x \<in> mspace m1 \<Longrightarrow> f x = g x; Cauchy_continuous_map m1 m2 f\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3964
      \<Longrightarrow> Cauchy_continuous_map m1 m2 g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3965
  by (simp add: image_subset_iff Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3966
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3967
lemma Cauchy_continuous_map_from_submetric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3968
  assumes "Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3969
  shows "Cauchy_continuous_map (submetric m1 S) m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3970
  using assms
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3971
  by (simp add: image_subset_iff Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3972
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3973
lemma Cauchy_continuous_map_from_submetric_mono:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3974
   "\<lbrakk>Cauchy_continuous_map (submetric m1 T) m2 f; S \<subseteq> T\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3975
           \<Longrightarrow> Cauchy_continuous_map (submetric m1 S) m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3976
  by (metis Cauchy_continuous_map_from_submetric inf.absorb_iff2 submetric_submetric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3977
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3978
lemma Cauchy_continuous_map_into_submetric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3979
   "Cauchy_continuous_map m1 (submetric m2 S) f \<longleftrightarrow>
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3980
   f \<in> mspace m1 \<rightarrow> S \<and> Cauchy_continuous_map m1 m2 f"  (is "?lhs \<longleftrightarrow> ?rhs")
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3981
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3982
  have "?lhs \<Longrightarrow> Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3983
    by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3984
  moreover have "?rhs \<Longrightarrow> ?lhs"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3985
    by (auto simp: Cauchy_continuous_map_def  Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3986
  ultimately show ?thesis
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3987
    by (metis Cauchy_continuous_map_funspace Int_iff funcsetI funcset_mem mspace_submetric)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3988
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3989
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3990
lemma Cauchy_continuous_map_const [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3991
  "Cauchy_continuous_map m1 m2 (\<lambda>x. c) \<longleftrightarrow> mspace m1 = {} \<or> c \<in> mspace m2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3992
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3993
   have "mspace m1 = {} \<Longrightarrow> Cauchy_continuous_map m1 m2 (\<lambda>x. c)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3994
    by (simp add: Cauchy_continuous_map_def Metric_space.MCauchy_def Metric_space_mspace_mdist)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3995
  moreover have "c \<in> mspace m2 \<Longrightarrow> Cauchy_continuous_map m1 m2 (\<lambda>x. c)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3996
    by (simp add: Cauchy_continuous_map_def o_def Metric_space.MCauchy_const [OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3997
  ultimately show ?thesis
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3998
    using Cauchy_continuous_map_funspace by blast
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3999
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4000
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4001
lemma Cauchy_continuous_map_id [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4002
   "Cauchy_continuous_map m1 m1 (\<lambda>x. x)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4003
  by (simp add: Cauchy_continuous_map_def o_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4004
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4005
lemma Cauchy_continuous_map_compose:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4006
  assumes f: "Cauchy_continuous_map m1 m2 f" and g: "Cauchy_continuous_map m2 m3 g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4007
  shows "Cauchy_continuous_map m1 m3 (g \<circ> f)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4008
  by (metis (no_types, lifting) Cauchy_continuous_map_def f fun.map_comp g)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4009
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4010
lemma Lipschitz_imp_uniformly_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4011
  assumes "Lipschitz_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4012
  shows "uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4013
  proof -
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4014
  have "f \<in> mspace m1 \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4015
    by (simp add: Lipschitz_continuous_map_image assms)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4016
  moreover have "\<exists>\<delta>>0. \<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m1 y x < \<delta> \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4017
    if "\<epsilon> > 0" for \<epsilon>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4018
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4019
    obtain B where "\<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4020
             and "B>0"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4021
      using that assms by (force simp: Lipschitz_continuous_map_pos)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4022
    then have "\<forall>x\<in>mspace m1. \<forall>y\<in>mspace m1. mdist m1 y x < \<epsilon>/B \<longrightarrow> mdist m2 (f y) (f x) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4023
      by (smt (verit, ccfv_SIG) less_divide_eq mdist_nonneg mult.commute that zero_less_divide_iff)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4024
    with \<open>B>0\<close> show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4025
      by (metis divide_pos_pos that)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4026
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4027
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4028
    by (auto simp: uniformly_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4029
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4030
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4031
lemma uniformly_imp_Cauchy_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4032
   "uniformly_continuous_map m1 m2 f \<Longrightarrow> Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4033
  unfolding uniformly_continuous_map_def Cauchy_continuous_map_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4034
  apply (simp add: image_subset_iff o_def Metric_space.MCauchy_def [OF Metric_space_mspace_mdist])
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4035
  by (metis funcset_mem)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4036
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4037
lemma locally_Cauchy_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4038
  assumes "\<epsilon> > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4039
    and \<section>: "\<And>x. x \<in> mspace m1 \<Longrightarrow> Cauchy_continuous_map (submetric m1 (mball_of m1 x \<epsilon>)) m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4040
  shows "Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4041
  unfolding Cauchy_continuous_map_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4042
proof (intro strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4043
  interpret M1: Metric_space "mspace m1" "mdist m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4044
    by (simp add: Metric_space_mspace_mdist)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4045
  interpret M2: Metric_space "mspace m2" "mdist m2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4046
    by (simp add: Metric_space_mspace_mdist)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4047
  fix \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4048
  assume \<sigma>: "M1.MCauchy \<sigma>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4049
  with \<open>\<epsilon> > 0\<close> obtain N where N: "\<And>n n'. \<lbrakk>n\<ge>N; n'\<ge>N\<rbrakk> \<Longrightarrow> mdist m1 (\<sigma> n) (\<sigma> n') < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4050
    using M1.MCauchy_def by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4051
  then have "M1.mball (\<sigma> N) \<epsilon> \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4052
    by (auto simp: image_subset_iff M1.mball_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4053
  then interpret MS1: Metric_space "mball_of m1 (\<sigma> N) \<epsilon> \<inter> mspace m1" "mdist m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4054
    by (simp add: M1.subspace)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4055
  show "M2.MCauchy (f \<circ> \<sigma>)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4056
  proof (rule M2.MCauchy_offset)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4057
    have "M1.MCauchy (\<sigma> \<circ> (+) N)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4058
      by (simp add: M1.MCauchy_imp_MCauchy_suffix \<sigma>)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4059
    moreover have "range (\<sigma> \<circ> (+) N) \<subseteq> M1.mball (\<sigma> N) \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4060
      using N [OF order_refl] M1.MCauchy_def \<sigma> by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4061
    ultimately have "MS1.MCauchy (\<sigma> \<circ> (+) N)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4062
      unfolding M1.MCauchy_def MS1.MCauchy_def by (simp add: mball_of_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4063
    moreover have "\<sigma> N \<in> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4064
      using M1.MCauchy_def \<sigma> by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4065
    ultimately show "M2.MCauchy (f \<circ> \<sigma> \<circ> (+) N)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4066
      unfolding comp_assoc
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4067
      by (metis "\<section>" Cauchy_continuous_map_def mdist_submetric mspace_submetric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4068
  next
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4069
    fix n
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4070
    have "\<sigma> n \<in> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4071
      by (meson Metric_space.MCauchy_def Metric_space_mspace_mdist \<sigma> range_subsetD)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4072
    then have "\<sigma> n \<in> mball_of m1 (\<sigma> n) \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4073
      by (simp add: Metric_space.centre_in_mball_iff Metric_space_mspace_mdist assms(1) mball_of_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4074
    then show "(f \<circ> \<sigma>) n \<in> mspace m2"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4075
      using Cauchy_continuous_map_funspace [OF \<section> [of "\<sigma> n"]] \<open>\<sigma> n \<in> mspace m1\<close> by auto
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4076
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4077
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4078
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4079
context Metric_space12
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4080
begin
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4081
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4082
lemma Cauchy_continuous_imp_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4083
  assumes "Cauchy_continuous_map (metric (M1,d1)) (metric (M2,d2)) f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4084
  shows "continuous_map M1.mtopology M2.mtopology f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4085
proof (clarsimp simp: continuous_map_atin)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4086
  fix x
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4087
  assume "x \<in> M1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4088
  show "limitin M2.mtopology f (f x) (atin M1.mtopology x)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4089
    unfolding limit_atin_sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4090
  proof (intro conjI strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4091
    show "f x \<in> M2"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4092
      using Cauchy_continuous_map_funspace \<open>x \<in> M1\<close> assms by fastforce
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4093
    fix \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4094
    assume "range \<sigma> \<subseteq> M1 - {x} \<and> limitin M1.mtopology \<sigma> x sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4095
    then have "M1.MCauchy (\<lambda>n. if even n then \<sigma> (n div 2) else x)"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4096
      by (force simp: M1.MCauchy_interleaving)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4097
    then have "M2.MCauchy (f \<circ> (\<lambda>n. if even n then \<sigma> (n div 2) else x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4098
      using assms by (simp add: Cauchy_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4099
    then show "limitin M2.mtopology (f \<circ> \<sigma>) (f x) sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4100
      using M2.MCauchy_interleaving [of "f \<circ> \<sigma>" "f x"]
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4101
      by (simp add: o_def if_distrib cong: if_cong)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4102
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4103
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4104
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4105
lemma continuous_imp_Cauchy_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4106
  assumes "M1.mcomplete"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4107
    and f: "continuous_map M1.mtopology M2.mtopology f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4108
  shows "Cauchy_continuous_map (metric (M1,d1)) (metric (M2,d2)) f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4109
  unfolding Cauchy_continuous_map_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4110
proof clarsimp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4111
  fix \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4112
  assume \<sigma>: "M1.MCauchy \<sigma>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4113
  then obtain y where y: "limitin M1.mtopology \<sigma> y sequentially"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4114
    using M1.mcomplete_def assms by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4115
  have "range (f \<circ> \<sigma>) \<subseteq> M2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4116
    using \<sigma> f by (simp add: M2.subspace M1.MCauchy_def M1.metric_continuous_map image_subset_iff)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4117
  then show "M2.MCauchy (f \<circ> \<sigma>)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4118
    using continuous_map_limit [OF f y] M2.convergent_imp_MCauchy
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4119
    by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4120
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4121
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4122
end
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4123
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4124
text \<open>The same outside the locale\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4125
lemma Cauchy_continuous_imp_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4126
  assumes "Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4127
  shows "continuous_map (mtopology_of m1) (mtopology_of m2) f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4128
  using assms Metric_space12.Cauchy_continuous_imp_continuous_map [OF Metric_space12_mspace_mdist]
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4129
  by (auto simp: mtopology_of_def)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4130
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4131
lemma continuous_imp_Cauchy_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4132
  assumes "Metric_space.mcomplete (mspace m1) (mdist m1)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4133
    and "continuous_map (mtopology_of m1) (mtopology_of m2) f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4134
  shows "Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4135
  using assms Metric_space12.continuous_imp_Cauchy_continuous_map [OF Metric_space12_mspace_mdist]
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4136
  by (auto simp: mtopology_of_def)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4137
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4138
lemma uniformly_continuous_imp_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4139
   "uniformly_continuous_map m1 m2 f
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4140
        \<Longrightarrow> continuous_map (mtopology_of m1) (mtopology_of m2) f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4141
  by (simp add: Cauchy_continuous_imp_continuous_map uniformly_imp_Cauchy_continuous_map)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4142
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4143
lemma Lipschitz_continuous_imp_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4144
   "Lipschitz_continuous_map m1 m2 f
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4145
     \<Longrightarrow> continuous_map (mtopology_of m1) (mtopology_of m2) f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4146
  by (simp add: Lipschitz_imp_uniformly_continuous_map uniformly_continuous_imp_continuous_map)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4147
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4148
lemma Lipschitz_imp_Cauchy_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4149
   "Lipschitz_continuous_map m1 m2 f
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4150
        \<Longrightarrow> Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4151
  by (simp add: Lipschitz_imp_uniformly_continuous_map uniformly_imp_Cauchy_continuous_map)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4152
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4153
lemma Cauchy_imp_uniformly_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4154
  assumes f: "Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4155
    and tbo: "Metric_space.mtotally_bounded (mspace m1) (mdist m1) (mspace m1)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4156
  shows "uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4157
  unfolding uniformly_continuous_map_sequentially_alt imp_conjL
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4158
proof (intro conjI strip)
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4159
  show "f \<in> mspace m1 \<rightarrow> mspace m2"
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4160
    by (simp add: Cauchy_continuous_map_funspace f)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4161
  interpret M1: Metric_space "mspace m1" "mdist m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4162
    by (simp add: Metric_space_mspace_mdist)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4163
  interpret M2: Metric_space "mspace m2" "mdist m2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4164
    by (simp add: Metric_space_mspace_mdist)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4165
  fix \<epsilon> :: real and \<rho> \<sigma> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4166
  assume "\<epsilon> > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4167
    and \<rho>: "range \<rho> \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4168
    and \<sigma>: "range \<sigma> \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4169
    and 0: "(\<lambda>n. mdist m1 (\<rho> n) (\<sigma> n)) \<longlonglongrightarrow> 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4170
  then obtain r1 where "strict_mono r1" and r1: "M1.MCauchy (\<rho> \<circ> r1)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4171
    using M1.mtotally_bounded_sequentially tbo by meson
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4172
  then obtain r2 where "strict_mono r2" and r2: "M1.MCauchy (\<sigma> \<circ> r1 \<circ> r2)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4173
    by (metis M1.mtotally_bounded_sequentially tbo \<sigma> image_comp image_subset_iff range_subsetD)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4174
  define r where "r \<equiv> r1 \<circ> r2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4175
  have r: "strict_mono r"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4176
    by (simp add: r_def \<open>strict_mono r1\<close> \<open>strict_mono r2\<close> strict_mono_o)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4177
  define \<eta> where "\<eta> \<equiv> \<lambda>n. if even n then (\<rho> \<circ> r) (n div 2) else (\<sigma> \<circ> r) (n div 2)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4178
  have "M1.MCauchy \<eta>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4179
    unfolding \<eta>_def M1.MCauchy_interleaving_gen
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4180
  proof (intro conjI)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4181
    show "M1.MCauchy (\<rho> \<circ> r)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4182
      by (simp add: M1.MCauchy_subsequence \<open>strict_mono r2\<close> fun.map_comp r1 r_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4183
    show "M1.MCauchy (\<sigma> \<circ> r)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4184
      by (simp add: fun.map_comp r2 r_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4185
    show "(\<lambda>n. mdist m1 ((\<rho> \<circ> r) n) ((\<sigma> \<circ> r) n)) \<longlonglongrightarrow> 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4186
      using LIMSEQ_subseq_LIMSEQ [OF 0 r] by (simp add: o_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4187
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4188
  then have "Metric_space.MCauchy (mspace m2) (mdist m2) (f \<circ> \<eta>)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4189
    by (meson Cauchy_continuous_map_def f)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4190
  then have "(\<lambda>n. mdist m2 (f (\<rho> (r n))) (f (\<sigma> (r n)))) \<longlonglongrightarrow> 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4191
    using M2.MCauchy_interleaving_gen [of "f \<circ> \<rho> \<circ> r" "f \<circ> \<sigma> \<circ> r"]
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4192
    by (simp add: \<eta>_def o_def if_distrib cong: if_cong)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4193
  then show "\<exists>n. mdist m2 (f (\<rho> n)) (f (\<sigma> n)) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4194
    by (meson LIMSEQ_le_const \<open>0 < \<epsilon>\<close> linorder_not_le)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4195
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4196
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4197
lemma continuous_imp_uniformly_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4198
   "compact_space (mtopology_of m1) \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4199
        continuous_map (mtopology_of m1) (mtopology_of m2) f
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4200
        \<Longrightarrow> uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4201
  by (simp add: Cauchy_imp_uniformly_continuous_map continuous_imp_Cauchy_continuous_map
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4202
                Metric_space.compact_space_eq_mcomplete_mtotally_bounded
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4203
                Metric_space_mspace_mdist mtopology_of_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4204
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4205
lemma continuous_eq_Cauchy_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4206
   "Metric_space.mcomplete (mspace m1) (mdist m1) \<Longrightarrow> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4207
    continuous_map (mtopology_of m1) (mtopology_of m2) f \<longleftrightarrow> Cauchy_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4208
  using Cauchy_continuous_imp_continuous_map continuous_imp_Cauchy_continuous_map by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4209
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4210
lemma continuous_eq_uniformly_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4211
   "compact_space (mtopology_of m1) 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4212
    \<Longrightarrow> continuous_map (mtopology_of m1) (mtopology_of m2) f \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4213
        uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4214
  using continuous_imp_uniformly_continuous_map uniformly_continuous_imp_continuous_map by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4215
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4216
lemma Cauchy_eq_uniformly_continuous_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4217
   "Metric_space.mtotally_bounded (mspace m1) (mdist m1) (mspace m1)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4218
    \<Longrightarrow> Cauchy_continuous_map m1 m2 f \<longleftrightarrow> uniformly_continuous_map m1 m2 f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4219
  using Cauchy_imp_uniformly_continuous_map uniformly_imp_Cauchy_continuous_map by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4220
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4221
lemma Lipschitz_continuous_map_projections:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4222
  "Lipschitz_continuous_map (prod_metric m1 m2) m1 fst"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4223
  "Lipschitz_continuous_map (prod_metric m1 m2) m2 snd"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4224
  by (simp add: Lipschitz_continuous_map_def prod_dist_def fst_Pi snd_Pi; 
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4225
      metis mult_numeral_1 real_sqrt_sum_squares_ge1 real_sqrt_sum_squares_ge2)+
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4226
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4227
lemma Lipschitz_continuous_map_pairwise:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4228
   "Lipschitz_continuous_map m (prod_metric m1 m2) f \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4229
    Lipschitz_continuous_map m m1 (fst \<circ> f) \<and> Lipschitz_continuous_map m m2 (snd \<circ> f)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4230
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4231
proof 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4232
  show "?lhs \<Longrightarrow> ?rhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4233
    by (simp add: Lipschitz_continuous_map_compose Lipschitz_continuous_map_projections)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4234
  have "Lipschitz_continuous_map m (prod_metric m1 m2) (\<lambda>x. (f1 x, f2 x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4235
    if f1: "Lipschitz_continuous_map m m1 f1" and f2: "Lipschitz_continuous_map m m2 f2" for f1 f2
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4236
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4237
    obtain B1 where "B1 > 0" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4238
      and B1: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk> \<Longrightarrow> mdist m1 (f1 x) (f1 y) \<le> B1 * mdist m x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4239
      by (meson Lipschitz_continuous_map_pos f1)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4240
    obtain B2 where "B2 > 0" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4241
      and B2: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk> \<Longrightarrow> mdist m2 (f2 x) (f2 y) \<le> B2 * mdist m x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4242
      by (meson Lipschitz_continuous_map_pos f2)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4243
    show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4244
      unfolding Lipschitz_continuous_map_pos
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4245
    proof (intro exI conjI strip)
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4246
      have f1im: "f1 \<in> mspace m \<rightarrow> mspace m1"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4247
        by (simp add: Lipschitz_continuous_map_image f1)
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4248
      moreover have f2im: "f2 \<in> mspace m \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4249
        by (simp add: Lipschitz_continuous_map_image f2)
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4250
      ultimately show "(\<lambda>x. (f1 x, f2 x)) \<in> mspace m \<rightarrow> mspace (prod_metric m1 m2)"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4251
        by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4252
      show "B1+B2 > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4253
        using \<open>0 < B1\<close> \<open>0 < B2\<close> by linarith
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4254
      fix x y
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4255
      assume xy: "x \<in> mspace m" "y \<in> mspace m"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4256
      with f1im f2im have "mdist (prod_metric m1 m2) (f1 x, f2 x) (f1 y, f2 y) \<le> mdist m1 (f1 x) (f1 y) + mdist m2 (f2 x) (f2 y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4257
        unfolding mdist_prod_metric
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4258
        by (intro Metric_space12.prod_metric_le_components [OF Metric_space12_mspace_mdist]) auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4259
      also have "... \<le> (B1+B2) * mdist m x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4260
        using B1 [OF xy] B2 [OF xy] by (simp add: vector_space_over_itself.scale_left_distrib) 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4261
      finally show "mdist (prod_metric m1 m2) (f1 x, f2 x) (f1 y, f2 y) \<le> (B1+B2) * mdist m x y" .
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4262
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4263
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4264
  then show "?rhs \<Longrightarrow> ?lhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4265
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4266
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4267
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4268
lemma uniformly_continuous_map_pairwise:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4269
   "uniformly_continuous_map m (prod_metric m1 m2) f \<longleftrightarrow> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4270
    uniformly_continuous_map m m1 (fst \<circ> f) \<and> uniformly_continuous_map m m2 (snd \<circ> f)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4271
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4272
proof 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4273
  show "?lhs \<Longrightarrow> ?rhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4274
    by (simp add: Lipschitz_continuous_map_projections Lipschitz_imp_uniformly_continuous_map uniformly_continuous_map_compose)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4275
  have "uniformly_continuous_map m (prod_metric m1 m2) (\<lambda>x. (f1 x, f2 x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4276
    if f1: "uniformly_continuous_map m m1 f1" and f2: "uniformly_continuous_map m m2 f2" for f1 f2
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4277
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4278
    show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4279
      unfolding uniformly_continuous_map_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4280
    proof (intro conjI strip)
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4281
      have f1im: "f1 \<in> mspace m \<rightarrow> mspace m1"
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4282
        by (simp add: uniformly_continuous_map_funspace f1)
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4283
      moreover have f2im: "f2 \<in> mspace m \<rightarrow> mspace m2"
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4284
        by (simp add: uniformly_continuous_map_funspace f2)
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4285
      ultimately show "(\<lambda>x. (f1 x, f2 x)) \<in> mspace m \<rightarrow> mspace (prod_metric m1 m2)"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4286
        by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4287
      fix \<epsilon>:: real
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4288
      assume "\<epsilon> > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4289
      obtain \<delta>1 where "\<delta>1>0" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4290
        and \<delta>1: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m; mdist m y x < \<delta>1\<rbrakk> \<Longrightarrow> mdist m1 (f1 y) (f1 x) < \<epsilon>/2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4291
        by (metis \<open>0 < \<epsilon>\<close> f1 half_gt_zero uniformly_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4292
      obtain \<delta>2 where "\<delta>2>0" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4293
        and \<delta>2: "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m; mdist m y x < \<delta>2\<rbrakk> \<Longrightarrow> mdist m2 (f2 y) (f2 x) < \<epsilon>/2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4294
        by (metis \<open>0 < \<epsilon>\<close> f2 half_gt_zero uniformly_continuous_map_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4295
      show "\<exists>\<delta>>0. \<forall>x\<in>mspace m. \<forall>y\<in>mspace m. mdist m y x < \<delta> \<longrightarrow> mdist (prod_metric m1 m2) (f1 y, f2 y) (f1 x, f2 x) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4296
      proof (intro exI conjI strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4297
        show "min \<delta>1 \<delta>2>0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4298
          using \<open>0 < \<delta>1\<close> \<open>0 < \<delta>2\<close> by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4299
        fix x y
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4300
        assume xy: "x \<in> mspace m" "y \<in> mspace m" and d: "mdist m y x < min \<delta>1 \<delta>2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4301
        have *: "mdist m1 (f1 y) (f1 x) < \<epsilon>/2" "mdist m2 (f2 y) (f2 x) < \<epsilon>/2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4302
          using \<delta>1 \<delta>2 d xy by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4303
        have "mdist (prod_metric m1 m2) (f1 y, f2 y) (f1 x, f2 x) \<le> mdist m1 (f1 y) (f1 x) + mdist m2 (f2 y) (f2 x)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4304
          unfolding mdist_prod_metric using f1im f2im xy
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4305
          by (intro Metric_space12.prod_metric_le_components [OF Metric_space12_mspace_mdist]) auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4306
        also have "... < \<epsilon>/2 + \<epsilon>/2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4307
          using * by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4308
        finally show "mdist (prod_metric m1 m2) (f1 y, f2 y) (f1 x, f2 x) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4309
          by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4310
      qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4311
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4312
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4313
  then show "?rhs \<Longrightarrow> ?lhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4314
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4315
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4316
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4317
lemma Cauchy_continuous_map_pairwise:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4318
   "Cauchy_continuous_map m (prod_metric m1 m2) f \<longleftrightarrow> Cauchy_continuous_map m m1 (fst \<circ> f) \<and> Cauchy_continuous_map m m2 (snd \<circ> f)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4319
  by (auto simp: Cauchy_continuous_map_def Metric_space12.MCauchy_prod_metric[OF Metric_space12_mspace_mdist] comp_assoc)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4320
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4321
lemma Lipschitz_continuous_map_paired:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4322
   "Lipschitz_continuous_map m (prod_metric m1 m2) (\<lambda>x. (f x, g x)) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4323
        Lipschitz_continuous_map m m1 f \<and> Lipschitz_continuous_map m m2 g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4324
  by (simp add: Lipschitz_continuous_map_pairwise o_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4325
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4326
lemma uniformly_continuous_map_paired:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4327
   "uniformly_continuous_map m (prod_metric m1 m2) (\<lambda>x. (f x, g x)) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4328
        uniformly_continuous_map m m1 f \<and> uniformly_continuous_map m m2 g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4329
  by (simp add: uniformly_continuous_map_pairwise o_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4330
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4331
lemma Cauchy_continuous_map_paired:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4332
   "Cauchy_continuous_map m (prod_metric m1 m2) (\<lambda>x. (f x, g x)) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4333
        Cauchy_continuous_map m m1 f \<and> Cauchy_continuous_map m m2 g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4334
  by (simp add: Cauchy_continuous_map_pairwise o_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4335
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4336
lemma mbounded_Lipschitz_continuous_image:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4337
  assumes f: "Lipschitz_continuous_map m1 m2 f" and S: "Metric_space.mbounded (mspace m1) (mdist m1) S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4338
  shows "Metric_space.mbounded (mspace m2) (mdist m2) (f`S)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4339
proof -
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4340
  obtain B where fim: "f \<in> mspace m1 \<rightarrow> mspace m2"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4341
    and "B>0" and B: "\<And>x y. \<lbrakk>x \<in> mspace m1; y \<in> mspace m1\<rbrakk> \<Longrightarrow> mdist m2 (f x) (f y) \<le> B * mdist m1 x y"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4342
    by (metis Lipschitz_continuous_map_pos f)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4343
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4344
    unfolding Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist]
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4345
  proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4346
    obtain C where "S \<subseteq> mspace m1" and "C>0" and C: "\<And>x y. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> mdist m1 x y \<le> C"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4347
      using S by (auto simp: Metric_space.mbounded_alt_pos [OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4348
    show "f ` S \<subseteq> mspace m2"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4349
      using fim \<open>S \<subseteq> mspace m1\<close> by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4350
    have "\<And>x y. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> mdist m2 (f x) (f y) \<le> B * C"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4351
      by (smt (verit) B C \<open>0 < B\<close> \<open>S \<subseteq> mspace m1\<close> mdist_nonneg mult_mono subsetD)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4352
    moreover have "B*C > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4353
      by (simp add: \<open>0 < B\<close> \<open>0 < C\<close>)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4354
    ultimately show "\<exists>B>0. \<forall>x\<in>f ` S. \<forall>y\<in>f ` S. mdist m2 x y \<le> B"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4355
      by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4356
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4357
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4358
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4359
lemma mtotally_bounded_Cauchy_continuous_image:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4360
  assumes f: "Cauchy_continuous_map m1 m2 f" and S: "Metric_space.mtotally_bounded (mspace m1) (mdist m1) S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4361
  shows "Metric_space.mtotally_bounded (mspace m2) (mdist m2) (f ` S)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4362
  unfolding Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist]
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4363
proof (intro conjI strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4364
  have "S \<subseteq> mspace m1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4365
    using S by (simp add: Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4366
  then show "f ` S \<subseteq> mspace m2"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4367
    using Cauchy_continuous_map_funspace f by blast
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4368
  fix \<sigma> :: "nat \<Rightarrow> 'b"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4369
  assume "range \<sigma> \<subseteq> f ` S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4370
  then have "\<forall>n. \<exists>x. \<sigma> n = f x \<and> x \<in> S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4371
    by (meson imageE range_subsetD)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4372
  then obtain \<rho> where \<rho>: "\<And>n. \<sigma> n = f (\<rho> n)" "range \<rho> \<subseteq> S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4373
    by (metis image_subset_iff)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4374
  then have "\<sigma> = f \<circ> \<rho>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4375
    by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4376
  obtain r where "strict_mono r" "Metric_space.MCauchy (mspace m1) (mdist m1) (\<rho> \<circ> r)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4377
    by (meson \<rho> S Metric_space.mtotally_bounded_sequentially[OF Metric_space_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4378
  then have "Metric_space.MCauchy (mspace m2) (mdist m2) (f \<circ> \<rho> \<circ> r)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4379
    using f unfolding Cauchy_continuous_map_def by (metis fun.map_comp)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4380
  then show "\<exists>r. strict_mono r \<and> Metric_space.MCauchy (mspace m2) (mdist m2) (\<sigma> \<circ> r)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4381
    using \<open>\<sigma> = f \<circ> \<rho>\<close> \<open>strict_mono r\<close> by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4382
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4383
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4384
lemma Lipschitz_coefficient_pos:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4385
  assumes "x \<in> mspace m" "y \<in> mspace m" "f x \<noteq> f y" 
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4386
    and "f \<in> mspace m \<rightarrow> mspace m2" 
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4387
    and "\<And>x y. \<lbrakk>x \<in> mspace m; y \<in> mspace m\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4388
            \<Longrightarrow> mdist m2 (f x) (f y) \<le> k * mdist m x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4389
  shows  "0 < k"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4390
  using assms by (smt (verit, best) Pi_iff mdist_nonneg mdist_zero mult_nonpos_nonneg)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4391
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4392
lemma Lipschitz_continuous_map_metric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4393
   "Lipschitz_continuous_map (prod_metric m m) euclidean_metric (\<lambda>(x,y). mdist m x y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4394
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4395
  have "\<And>x y x' y'. \<lbrakk>x \<in> mspace m; y \<in> mspace m; x' \<in> mspace m; y' \<in> mspace m\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4396
       \<Longrightarrow> \<bar>mdist m x y - mdist m x' y'\<bar> \<le> 2 * sqrt ((mdist m x x')\<^sup>2 + (mdist m y y')\<^sup>2)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4397
    by (smt (verit, del_insts) mdist_commute mdist_triangle real_sqrt_sum_squares_ge2)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4398
  then show ?thesis
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4399
    by (fastforce simp: Lipschitz_continuous_map_def prod_dist_def dist_real_def)
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4400
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4401
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4402
lemma Lipschitz_continuous_map_mdist:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4403
  assumes f: "Lipschitz_continuous_map m m' f" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4404
    and g: "Lipschitz_continuous_map m m' g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4405
  shows "Lipschitz_continuous_map m euclidean_metric (\<lambda>x. mdist m' (f x) (g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4406
    (is "Lipschitz_continuous_map m _ ?h")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4407
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4408
  have eq: "?h = ((\<lambda>(x,y). mdist m' x y) \<circ> (\<lambda>x. (f x,g x)))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4409
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4410
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4411
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4412
  proof (rule Lipschitz_continuous_map_compose)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4413
    show "Lipschitz_continuous_map m (prod_metric m' m') (\<lambda>x. (f x, g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4414
      by (simp add: Lipschitz_continuous_map_paired f g)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4415
    show "Lipschitz_continuous_map (prod_metric m' m') euclidean_metric (\<lambda>(x,y). mdist m' x y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4416
      by (simp add: Lipschitz_continuous_map_metric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4417
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4418
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4419
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4420
lemma uniformly_continuous_map_mdist:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4421
  assumes f: "uniformly_continuous_map m m' f" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4422
    and g: "uniformly_continuous_map m m' g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4423
  shows "uniformly_continuous_map m euclidean_metric (\<lambda>x. mdist m' (f x) (g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4424
    (is "uniformly_continuous_map m _ ?h")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4425
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4426
  have eq: "?h = ((\<lambda>(x,y). mdist m' x y) \<circ> (\<lambda>x. (f x,g x)))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4427
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4428
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4429
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4430
  proof (rule uniformly_continuous_map_compose)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4431
    show "uniformly_continuous_map m (prod_metric m' m') (\<lambda>x. (f x, g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4432
      by (simp add: uniformly_continuous_map_paired f g)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4433
    show "uniformly_continuous_map (prod_metric m' m') euclidean_metric (\<lambda>(x,y). mdist m' x y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4434
      by (simp add: Lipschitz_continuous_map_metric Lipschitz_imp_uniformly_continuous_map)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4435
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4436
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4437
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4438
lemma Cauchy_continuous_map_mdist:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4439
  assumes f: "Cauchy_continuous_map m m' f" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4440
    and g: "Cauchy_continuous_map m m' g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4441
  shows "Cauchy_continuous_map m euclidean_metric (\<lambda>x. mdist m' (f x) (g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4442
    (is "Cauchy_continuous_map m _ ?h")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4443
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4444
  have eq: "?h = ((\<lambda>(x,y). mdist m' x y) \<circ> (\<lambda>x. (f x,g x)))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4445
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4446
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4447
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4448
  proof (rule Cauchy_continuous_map_compose)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4449
    show "Cauchy_continuous_map m (prod_metric m' m') (\<lambda>x. (f x, g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4450
      by (simp add: Cauchy_continuous_map_paired f g)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4451
    show "Cauchy_continuous_map (prod_metric m' m') euclidean_metric (\<lambda>(x,y). mdist m' x y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4452
      by (simp add: Lipschitz_continuous_map_metric Lipschitz_imp_Cauchy_continuous_map)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4453
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4454
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4455
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4456
lemma mtopology_of_prod_metric [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4457
    "mtopology_of (prod_metric m1 m2) = prod_topology (mtopology_of m1) (mtopology_of m2)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4458
  by (simp add: mtopology_of_def Metric_space12.mtopology_prod_metric[OF Metric_space12_mspace_mdist])
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4459
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4460
lemma continuous_map_metric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4461
   "continuous_map (prod_topology (mtopology_of m) (mtopology_of m)) euclidean
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4462
      (\<lambda>(x,y). mdist m x y)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4463
  using Lipschitz_continuous_imp_continuous_map [OF Lipschitz_continuous_map_metric]
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4464
  by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4465
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4466
lemma continuous_map_mdist_alt:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4467
  assumes "continuous_map X (prod_topology (mtopology_of m) (mtopology_of m)) f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4468
  shows "continuous_map X euclidean (\<lambda>x. case_prod (mdist m) (f x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4469
    (is "continuous_map _ _ ?h")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4470
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4471
  have eq: "?h = case_prod (mdist m) \<circ> f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4472
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4473
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4474
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4475
    using assms continuous_map_compose continuous_map_metric by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4476
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4477
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4478
lemma continuous_map_mdist [continuous_intros]:
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4479
  assumes f: "continuous_map X (mtopology_of m) f" 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4480
      and g: "continuous_map X (mtopology_of m) g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4481
  shows "continuous_map X euclidean (\<lambda>x. mdist m (f x) (g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4482
    (is "continuous_map X _ ?h")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4483
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4484
  have eq: "?h = ((\<lambda>(x,y). mdist m x y) \<circ> (\<lambda>x. (f x,g x)))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4485
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4486
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4487
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4488
  proof (rule continuous_map_compose)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4489
    show "continuous_map X (prod_topology (mtopology_of m) (mtopology_of m)) (\<lambda>x. (f x, g x))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4490
      by (simp add: continuous_map_paired f g)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4491
  qed (simp add: continuous_map_metric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4492
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4493
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4494
lemma continuous_on_mdist:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4495
   "a \<in> mspace m \<Longrightarrow> continuous_map (mtopology_of m) euclidean (mdist m a)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4496
  by (simp add: continuous_map_mdist)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4497
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4498
subsection \<open>Isometries\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4499
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4500
lemma (in Metric_space12) isometry_imp_embedding_map:
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4501
  assumes fim: "f \<in> M1 \<rightarrow> M2" and d: "\<And>x y. \<lbrakk>x \<in> M1; y \<in> M1\<rbrakk> \<Longrightarrow> d2 (f x) (f y) = d1 x y"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4502
  shows "embedding_map M1.mtopology M2.mtopology f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4503
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4504
  have "inj_on f M1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4505
    by (metis M1.zero d inj_onI)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4506
  then obtain g where g: "\<And>x. x \<in> M1 \<Longrightarrow> g (f x) = x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4507
    by (metis inv_into_f_f)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4508
  have "homeomorphic_maps M1.mtopology (subtopology M2.mtopology (f ` topspace M1.mtopology)) f g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4509
    unfolding homeomorphic_maps_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4510
  proof (intro conjI; clarsimp)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4511
    show "continuous_map M1.mtopology (subtopology M2.mtopology (f ` M1)) f"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4512
    proof (rule continuous_map_into_subtopology)
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4513
      show "continuous_map M1.mtopology M2.mtopology f"
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4514
        by (metis M1.metric_continuous_map M2.Metric_space_axioms d fim image_subset_iff_funcset)
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4515
    qed simp
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4516
    have "Lipschitz_continuous_map (submetric (metric(M2,d2)) (f ` M1)) (metric(M1,d1)) g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4517
      unfolding Lipschitz_continuous_map_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4518
    proof (intro conjI exI strip; simp)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4519
      show "d1 (g x) (g y) \<le> 1 * d2 x y" if "x \<in> f ` M1 \<and> x \<in> M2" and "y \<in> f ` M1 \<and> y \<in> M2" for x y
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4520
        using that d g by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4521
    qed (use g in auto)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4522
    then have "continuous_map (mtopology_of (submetric (metric(M2,d2)) (f ` M1))) M1.mtopology g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4523
      using Lipschitz_continuous_imp_continuous_map by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4524
    moreover have "mtopology_of (submetric (metric(M2,d2)) (f ` M1)) = subtopology M2.mtopology (f ` M1)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4525
      by (simp add: mtopology_of_submetric)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4526
    ultimately show "continuous_map (subtopology M2.mtopology (f ` M1)) M1.mtopology g"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4527
       by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4528
  qed (use g in auto)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4529
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4530
    by (auto simp: embedding_map_def homeomorphic_map_maps)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4531
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4532
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4533
lemma (in Metric_space12) isometry_imp_homeomorphic_map:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4534
  assumes fim: "f ` M1 = M2" and d: "\<And>x y. \<lbrakk>x \<in> M1; y \<in> M1\<rbrakk> \<Longrightarrow> d2 (f x) (f y) = d1 x y"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4535
  shows "homeomorphic_map M1.mtopology M2.mtopology f"
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4536
  by (metis image_eqI M1.topspace_mtopology M2.subtopology_mspace d embedding_map_def fim isometry_imp_embedding_map Pi_iff)
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4537
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4538
subsection\<open>"Capped" equivalent bounded metrics and general product metrics\<close>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4539
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4540
definition (in Metric_space) capped_dist where
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4541
  "capped_dist \<equiv> \<lambda>\<delta> x y. if \<delta> > 0 then min \<delta> (d x y) else d x y"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4542
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4543
lemma (in Metric_space) capped_dist: "Metric_space M (capped_dist \<delta>)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4544
proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4545
  fix x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4546
  assume "x \<in> M" "y \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4547
  then show "(capped_dist \<delta> x y = 0) = (x = y)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4548
    by (smt (verit, best) capped_dist_def zero)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4549
  fix z 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4550
  assume "z \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4551
  show "capped_dist \<delta> x z \<le> capped_dist \<delta> x y + capped_dist \<delta> y z"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4552
    unfolding capped_dist_def using \<open>x \<in> M\<close> \<open>y \<in> M\<close> \<open>z \<in> M\<close> 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4553
    by (smt (verit, del_insts) Metric_space.mdist_pos_eq Metric_space_axioms mdist_reverse_triangle)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4554
qed (use capped_dist_def commute in auto)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4555
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4556
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4557
definition capped_metric where
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4558
  "capped_metric \<delta> m \<equiv> metric(mspace m, Metric_space.capped_dist (mdist m) \<delta>)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4559
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4560
lemma capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4561
  "capped_metric \<delta> m = (if \<delta> \<le> 0 then m else metric(mspace m, \<lambda>x y. min \<delta> (mdist m x y)))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4562
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4563
  interpret Metric_space "mspace m" "mdist m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4564
    by (simp add: Metric_space_mspace_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4565
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4566
    by (auto simp: capped_metric_def capped_dist_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4567
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4568
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4569
lemma capped_metric_mspace [simp]:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4570
  "mspace (capped_metric \<delta> m) = mspace m"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4571
  by (simp add: Metric_space.capped_dist Metric_space.mspace_metric capped_metric_def)
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4572
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4573
lemma capped_metric_mdist:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4574
  "mdist (capped_metric \<delta> m) = (\<lambda>x y. if \<delta> \<le> 0 then mdist m x y else min \<delta> (mdist m x y))"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4575
  by (metis Metric_space.capped_dist Metric_space.capped_dist_def Metric_space.mdist_metric 
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4576
      Metric_space_mspace_mdist capped_metric capped_metric_def leI)
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4577
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4578
lemma mdist_capped_le: "mdist (capped_metric \<delta> m) x y \<le> mdist m x y"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4579
  by (simp add: capped_metric_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4580
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4581
lemma mdist_capped: "\<delta> > 0 \<Longrightarrow> mdist (capped_metric \<delta> m) x y \<le> \<delta>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4582
  by (simp add: capped_metric_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4583
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4584
lemma mball_of_capped_metric [simp]: 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4585
  assumes "x \<in> mspace m" "r > \<delta>" "\<delta> > 0" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4586
  shows "mball_of (capped_metric \<delta> m) x r = mspace m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4587
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4588
  interpret Metric_space "mspace m" "mdist m"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4589
    by auto
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4590
  have "Metric_space.mball (mspace m) (mdist (capped_metric \<delta> m)) x r \<subseteq> mspace m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4591
    by (metis Metric_space.mball_subset_mspace Metric_space_mspace_mdist capped_metric_mspace)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4592
  moreover have "mspace m \<subseteq> Metric_space.mball (mspace m) (mdist (capped_metric \<delta> m)) x r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4593
    by (smt (verit) Metric_space.in_mball Metric_space_mspace_mdist assms capped_metric_mspace mdist_capped subset_eq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4594
  ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4595
    by (simp add: mball_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4596
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4597
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4598
lemma Metric_space_capped_dist[simp]:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4599
  "Metric_space (mspace m) (Metric_space.capped_dist (mdist m) \<delta>)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4600
  using Metric_space.capped_dist Metric_space_mspace_mdist by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4601
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4602
lemma mtopology_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4603
  "mtopology_of(capped_metric \<delta> m) = mtopology_of m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4604
proof (cases "\<delta> > 0")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4605
  case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4606
  interpret Metric_space "mspace m" "mdist m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4607
    by (simp add: Metric_space_mspace_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4608
  interpret Cap: Metric_space "mspace m" "mdist (capped_metric \<delta> m)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4609
    by (metis Metric_space_mspace_mdist capped_metric_mspace)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4610
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4611
    unfolding topology_eq
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4612
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4613
    fix S
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4614
    show "openin (mtopology_of (capped_metric \<delta> m)) S = openin (mtopology_of m) S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4615
    proof (cases "S \<subseteq> mspace m")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4616
      case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4617
      have "mball x r \<subseteq> Cap.mball x r" for x r
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4618
        by (smt (verit, ccfv_SIG) Cap.in_mball in_mball mdist_capped_le subsetI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4619
      moreover have "\<exists>r>0. Cap.mball x r \<subseteq> S" if "r>0" "x \<in> S" and r: "mball x r \<subseteq> S" for r x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4620
      proof (intro exI conjI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4621
        show "min (\<delta>/2) r > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4622
          using \<open>r>0\<close> \<open>\<delta>>0\<close> by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4623
        show "Cap.mball x (min (\<delta>/2) r) \<subseteq> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4624
          using that
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4625
          by clarsimp (smt (verit) capped_metric_mdist field_sum_of_halves in_mball subsetD)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4626
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4627
      ultimately have "(\<exists>r>0. Cap.mball x r \<subseteq> S) = (\<exists>r>0. mball x r \<subseteq> S)" if "x \<in> S" for x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4628
        by (meson subset_trans that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4629
      then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4630
        by (simp add: mtopology_of_def openin_mtopology Cap.openin_mtopology)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4631
    qed (simp add: openin_closedin_eq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4632
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4633
qed (simp add: capped_metric)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4634
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4635
text \<open>Might have been easier to prove this within the locale to start with (using Self)\<close>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4636
lemma (in Metric_space) mtopology_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4637
  "Metric_space.mtopology M (capped_dist \<delta>) = mtopology"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4638
  using mtopology_capped_metric [of \<delta> "metric(M,d)"]
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4639
  by (simp add: Metric_space.mtopology_of capped_dist capped_metric_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4640
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4641
lemma (in Metric_space) MCauchy_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4642
  "Metric_space.MCauchy M (capped_dist \<delta>) \<sigma> \<longleftrightarrow> MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4643
proof (cases "\<delta> > 0")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4644
  case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4645
  interpret Cap: Metric_space "M" "capped_dist \<delta>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4646
    by (simp add: capped_dist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4647
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4648
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4649
    assume \<sigma>: "Cap.MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4650
    show "MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4651
      unfolding MCauchy_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4652
    proof (intro conjI strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4653
      show "range \<sigma> \<subseteq> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4654
        using Cap.MCauchy_def \<sigma> by presburger
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4655
      fix \<epsilon> :: real
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4656
      assume "\<epsilon> > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4657
      with True \<sigma>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4658
      obtain N where "\<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> capped_dist \<delta> (\<sigma> n) (\<sigma> n') < min \<delta> \<epsilon>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4659
        unfolding Cap.MCauchy_def by (metis min_less_iff_conj)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4660
      with True show "\<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> d (\<sigma> n) (\<sigma> n') < \<epsilon>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4661
        by (force simp: capped_dist_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4662
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4663
  next
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4664
    assume "MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4665
    then show "Cap.MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4666
      unfolding MCauchy_def Cap.MCauchy_def by (force simp: capped_dist_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4667
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4668
qed (simp add: capped_dist_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4669
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4670
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4671
lemma (in Metric_space) mcomplete_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4672
   "Metric_space.mcomplete M (capped_dist \<delta>) \<longleftrightarrow> mcomplete"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4673
  by (simp add: MCauchy_capped_metric Metric_space.mcomplete_def capped_dist mtopology_capped_metric mcomplete_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4674
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4675
lemma bounded_equivalent_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4676
  assumes "\<delta> > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4677
  obtains m' where "mspace m' = mspace m" "mtopology_of m' = mtopology_of m" "\<And>x y. mdist m' x y < \<delta>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4678
proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4679
  let ?m = "capped_metric (\<delta>/2) m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4680
  fix x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4681
  show "mdist ?m x y < \<delta>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4682
    by (smt (verit, best) assms field_sum_of_halves mdist_capped)    
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4683
qed (auto simp: mtopology_capped_metric)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4684
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4685
text \<open>A technical lemma needed below\<close>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4686
lemma Sup_metric_cartesian_product:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4687
  fixes I m
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4688
  defines "S \<equiv> PiE I (mspace \<circ> m)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4689
  defines "D \<equiv> \<lambda>x y. if x \<in> S \<and> y \<in> S then SUP i\<in>I. mdist (m i) (x i) (y i) else 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4690
  defines "m' \<equiv> metric(S,D)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4691
  assumes "I \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4692
    and c: "\<And>i x y. \<lbrakk>i \<in> I; x \<in> mspace(m i); y \<in> mspace(m i)\<rbrakk> \<Longrightarrow> mdist (m i) x y \<le> c"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4693
  shows "Metric_space S D" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4694
    and "\<forall>x \<in> S. \<forall>y \<in> S. \<forall>b. D x y \<le> b \<longleftrightarrow> (\<forall>i \<in> I. mdist (m i) (x i) (y i) \<le> b)"  (is "?the2")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4695
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4696
  have bdd: "bdd_above ((\<lambda>i. mdist (m i) (x i) (y i)) ` I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4697
    if "x \<in> S" "y \<in> S" for x y 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4698
    using c that by (force simp: S_def bdd_above_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4699
  have D_iff: "D x y \<le> b \<longleftrightarrow> (\<forall>i \<in> I. mdist (m i) (x i) (y i) \<le> b)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4700
    if "x \<in> S" "y \<in> S" for x y b
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4701
    using that \<open>I \<noteq> {}\<close> by (simp add: D_def PiE_iff cSup_le_iff bdd)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4702
  show "Metric_space S D"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4703
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4704
    fix x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4705
    show D0: "0 \<le> D x y"
80792
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4706
      using bdd \<open>I \<noteq> {}\<close>
1cbdba868710 A bit of tidying
paulson <lp15@cam.ac.uk>
parents: 80764
diff changeset
  4707
      by (metis D_def D_iff Orderings.order_eq_iff dual_order.trans ex_in_conv mdist_nonneg) 
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4708
    show "D x y = D y x"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4709
      by (simp add: D_def mdist_commute)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4710
    assume "x \<in> S" and "y \<in> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4711
    then
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4712
    have "D x y = 0 \<longleftrightarrow> (\<forall>i\<in>I. mdist (m i) (x i) (y i) = 0)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4713
      using D0 D_iff [of x y 0] nle_le by fastforce
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4714
    also have "... \<longleftrightarrow> x = y"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4715
      using \<open>x \<in> S\<close> \<open>y \<in> S\<close> by (fastforce simp: S_def PiE_iff extensional_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4716
    finally show "(D x y = 0) \<longleftrightarrow> (x = y)" .
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4717
    fix z
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4718
    assume "z \<in> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4719
    have "mdist (m i) (x i) (z i) \<le> D x y + D y z" if "i \<in> I" for i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4720
    proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4721
      have "mdist (m i) (x i) (z i) \<le> mdist (m i) (x i) (y i) + mdist (m i) (y i) (z i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4722
        by (metis PiE_E S_def \<open>x \<in> S\<close> \<open>y \<in> S\<close> \<open>z \<in> S\<close> comp_apply mdist_triangle that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4723
      also have "... \<le> D x y + D y z"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4724
        using \<open>x \<in> S\<close> \<open>y \<in> S\<close> \<open>z \<in> S\<close> by (meson D_iff add_mono order_refl that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4725
      finally show ?thesis .
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4726
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4727
    then show "D x z \<le> D x y + D y z"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4728
      by (simp add: D_iff \<open>x \<in> S\<close> \<open>z \<in> S\<close>)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4729
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4730
  then interpret Metric_space S D .
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4731
  show ?the2
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4732
  proof (intro strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4733
    show "(D x y \<le> b) = (\<forall>i\<in>I. mdist (m i) (x i) (y i) \<le> b)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4734
      if "x \<in> S" and "y \<in> S" for x y b
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4735
      using that by (simp add: D_iff m'_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4736
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4737
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4738
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4739
lemma metrizable_topology_A:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4740
  assumes "metrizable_space (product_topology X I)"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  4741
  shows "(product_topology X I) = trivial_topology \<or> (\<forall>i \<in> I. metrizable_space (X i))"
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4742
    by (meson assms metrizable_space_retraction_map_image retraction_map_product_projection)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4743
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4744
lemma metrizable_topology_C:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4745
  assumes "completely_metrizable_space (product_topology X I)"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  4746
  shows "(product_topology X I) = trivial_topology \<or> (\<forall>i \<in> I. completely_metrizable_space (X i))"
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4747
    by (meson assms completely_metrizable_space_retraction_map_image retraction_map_product_projection)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4748
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4749
lemma metrizable_topology_B:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4750
  fixes a X I
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4751
  defines "L \<equiv> {i \<in> I. \<nexists>a. topspace (X i) \<subseteq> {a}}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4752
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4753
    and met: "metrizable_space (product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4754
    and "\<And>i. i \<in> I \<Longrightarrow> metrizable_space (X i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4755
  shows  "countable L"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4756
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4757
  have "\<And>i. \<exists>p q. i \<in> L \<longrightarrow> p \<in> topspace(X i) \<and> q \<in> topspace(X i) \<and> p \<noteq> q"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4758
    unfolding L_def by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4759
  then obtain \<phi> \<psi> where \<phi>: "\<And>i. i \<in> L \<Longrightarrow> \<phi> i \<in> topspace(X i) \<and> \<psi> i \<in> topspace(X i) \<and> \<phi> i \<noteq> \<psi> i"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4760
    by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4761
  obtain z where z: "z \<in> (\<Pi>\<^sub>E i\<in>I. topspace (X i))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4762
    using assms(2) by fastforce
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4763
  define p where "p \<equiv> \<lambda>i. if i \<in> L then \<phi> i else z i"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4764
  define q where "q \<equiv> \<lambda>i j. if j = i then \<psi> i else p j"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4765
  have p: "p \<in> topspace(product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4766
    using z \<phi> by (auto simp: p_def L_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4767
  then have q: "\<And>i. i \<in> L \<Longrightarrow> q i \<in> topspace (product_topology X I)" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4768
    by (auto simp: L_def q_def \<phi>)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4769
  have fin: "finite {i \<in> L. q i \<notin> U}" if U: "openin (product_topology X I) U" "p \<in> U" for U
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4770
  proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4771
    obtain V where V: "finite {i \<in> I. V i \<noteq> topspace (X i)}" "(\<forall>i\<in>I. openin (X i) (V i))" "p \<in> Pi\<^sub>E I V" "Pi\<^sub>E I V \<subseteq> U"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4772
      using U by (force simp: openin_product_topology_alt)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4773
    moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4774
    have "V x \<noteq> topspace (X x)" if "x \<in> L" and "q x \<notin> U" for x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4775
      using that V q
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4776
      by (smt (verit, del_insts) PiE_iff q_def subset_eq topspace_product_topology)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4777
    then have "{i \<in> L. q i \<notin> U} \<subseteq> {i \<in> I. V i \<noteq> topspace (X i)}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4778
      by (force simp: L_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4779
    ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4780
      by (meson finite_subset)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4781
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4782
  obtain M d where "Metric_space M d" and XI: "product_topology X I = Metric_space.mtopology M d"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4783
    using met metrizable_space_def by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4784
  then interpret Metric_space M d
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4785
    by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4786
  define C where "C \<equiv> \<Union>n::nat. {i \<in> L. q i \<notin> mball p (inverse (Suc n))}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4787
  have "finite {i \<in> L. q i \<notin> mball p (inverse (real (Suc n)))}" for n
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4788
    using XI p  by (intro fin; force)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4789
  then have "countable C"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4790
    unfolding C_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4791
    by (meson countableI_type countable_UN countable_finite)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4792
  moreover have "L \<subseteq> C"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4793
  proof (clarsimp simp: C_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4794
    fix i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4795
    assume "i \<in> L" and "q i \<in> M" and "p \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4796
    then show "\<exists>n. \<not> d p (q i) < inverse (1 + real n)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4797
      using reals_Archimedean [of "d p (q i)"]
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4798
      by (metis \<phi> mdist_pos_eq not_less_iff_gr_or_eq of_nat_Suc p_def q_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4799
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4800
  ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4801
    using countable_subset by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4802
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4803
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4804
lemma metrizable_topology_DD:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4805
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4806
    and co: "countable {i \<in> I. \<nexists>a. topspace (X i) \<subseteq> {a}}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4807
    and m: "\<And>i. i \<in> I \<Longrightarrow> X i = mtopology_of (m i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4808
  obtains M d where "Metric_space M d" "product_topology X I = Metric_space.mtopology M d"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4809
                    "(\<And>i. i \<in> I \<Longrightarrow> mcomplete_of (m i)) \<Longrightarrow> Metric_space.mcomplete M d"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4810
proof (cases "I = {}")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4811
  case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4812
  then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4813
    by (metis discrete_metric.mcomplete_discrete_metric discrete_metric.mtopology_discrete_metric metric_M_dd product_topology_empty_discrete that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4814
next
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4815
  case False
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4816
  obtain nk and C:: "nat set" where nk: "{i \<in> I. \<nexists>a. topspace (X i) \<subseteq> {a}} = nk ` C" and "inj_on nk C"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4817
    using co by (force simp: countable_as_injective_image_subset)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4818
  then obtain kn where kn: "\<And>w. w \<in> C \<Longrightarrow> kn (nk w) = w"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4819
    by (metis inv_into_f_f)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4820
  define cm where "cm \<equiv> \<lambda>i. capped_metric (inverse(Suc(kn i))) (m i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4821
  have mspace_cm: "mspace (cm i) = mspace (m i)" for i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4822
    by (simp add: cm_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4823
  have c1: "\<And>i x y. mdist (cm i) x y \<le> 1"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4824
    by (simp add: cm_def capped_metric_mdist min_le_iff_disj divide_simps)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4825
  then have bdd: "bdd_above ((\<lambda>i. mdist (cm i) (x i) (y i)) ` I)" for x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4826
    by (meson bdd_above.I2)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4827
  define M where "M \<equiv> Pi\<^sub>E I (mspace \<circ> cm)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4828
  define d where "d \<equiv> \<lambda>x y. if x \<in> M \<and> y \<in> M then SUP i\<in>I. mdist (cm i) (x i) (y i) else 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4829
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4830
  have d_le1: "d x y \<le> 1" for x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4831
    using \<open>I \<noteq> {}\<close> c1 by (simp add: d_def bdd cSup_le_iff)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4832
  with \<open>I \<noteq> {}\<close> Sup_metric_cartesian_product [of I cm]
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4833
  have "Metric_space M d" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4834
    and *: "\<forall>x\<in>M. \<forall>y\<in>M. \<forall>b. (d x y \<le> b) \<longleftrightarrow> (\<forall>i\<in>I. mdist (cm i) (x i) (y i) \<le> b)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4835
    by (auto simp: False bdd M_def d_def cSUP_le_iff intro: c1) 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4836
  then interpret Metric_space M d 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4837
    by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4838
  have le_d: "mdist (cm i) (x i) (y i) \<le> d x y" if "i \<in> I" "x \<in> M" "y \<in> M" for i x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4839
    using "*" that by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4840
  have product_m: "PiE I (\<lambda>i. mspace (m i)) = topspace(product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4841
    using m by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4842
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4843
  define m' where "m' = metric (M,d)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4844
  define J where "J \<equiv> \<lambda>U. {i \<in> I. U i \<noteq> topspace (X i)}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4845
  have 1: "\<exists>U. finite (J U) \<and> (\<forall>i\<in>I. openin (X i) (U i)) \<and> x \<in> Pi\<^sub>E I U \<and> Pi\<^sub>E I U \<subseteq> mball z r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4846
    if "x \<in> M" "z \<in> M" and r: "0 < r" "d z x < r" for x z r
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4847
  proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4848
    have x: "\<And>i. i \<in> I \<Longrightarrow> x i \<in> topspace(X i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4849
      using M_def m mspace_cm that(1) by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4850
    have z: "\<And>i. i \<in> I \<Longrightarrow> z i \<in> topspace(X i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4851
      using M_def m mspace_cm that(2) by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4852
    obtain R where "0 < R" "d z x < R" "R < r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4853
      using r dense by (smt (verit, ccfv_threshold))
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4854
    define U where "U \<equiv> \<lambda>i. if R \<le> inverse(Suc(kn i)) then mball_of (m i) (z i) R else topspace(X i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4855
    show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4856
    proof (intro exI conjI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4857
      obtain n where n: "real n * R > 1"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4858
        using \<open>0 < R\<close> ex_less_of_nat_mult by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4859
      have "finite (nk ` (C \<inter> {..n}))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4860
        by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4861
      moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4862
      have "\<exists>m. m \<in> C \<and> m \<le> n \<and> i = nk m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4863
        if R: "R \<le> inverse (1 + real (kn i))" and "i \<in> I" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4864
          and neq: "mball_of (m i) (z i) R \<noteq> topspace (X i)" for i 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4865
      proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4866
        interpret MI: Metric_space "mspace (m i)" "mdist (m i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4867
          by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4868
        have "MI.mball (z i) R \<noteq> topspace (X i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4869
          by (metis mball_of_def neq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4870
        then have "\<nexists>a. topspace (X i) \<subseteq> {a}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4871
          using \<open>0 < R\<close> m subset_antisym \<open>i \<in> I\<close> z by fastforce
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4872
        then have "i \<in> nk ` C"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4873
          using nk \<open>i \<in> I\<close> by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4874
        then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4875
          by (smt (verit, ccfv_SIG) R \<open>0 < R\<close> image_iff kn lift_Suc_mono_less_iff mult_mono n not_le_imp_less of_nat_0_le_iff of_nat_Suc right_inverse)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4876
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4877
      then have "J U \<subseteq> nk ` (C \<inter> {..n})"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4878
        by (auto simp: image_iff Bex_def J_def U_def split: if_split_asm)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4879
      ultimately show "finite (J U)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4880
        using finite_subset by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4881
      show "\<forall>i\<in>I. openin (X i) (U i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4882
        by (simp add: Metric_space.openin_mball U_def mball_of_def mtopology_of_def m)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4883
      have xin: "x \<in> Pi\<^sub>E I (topspace \<circ> X)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4884
        using M_def \<open>x \<in> M\<close> x by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4885
      moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4886
      have "\<And>i. \<lbrakk>i \<in> I; R \<le> inverse (1 + real (kn i))\<rbrakk> \<Longrightarrow> mdist (m i) (z i) (x i) < R"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4887
        by (smt (verit, ccfv_SIG) \<open>d z x < R\<close> capped_metric_mdist cm_def le_d of_nat_Suc that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4888
      ultimately show "x \<in> Pi\<^sub>E I U"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4889
        using m z by (auto simp: U_def PiE_iff)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4890
      show "Pi\<^sub>E I U \<subseteq> mball z r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4891
      proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4892
        fix y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4893
        assume y: "y \<in> Pi\<^sub>E I U"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4894
        then have "y \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4895
          by (force simp: PiE_iff M_def U_def m mspace_cm split: if_split_asm)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4896
        moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4897
        have "\<forall>i\<in>I. mdist (cm i) (z i) (y i) \<le> R"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4898
          by (smt (verit) PiE_mem U_def cm_def in_mball_of inverse_Suc mdist_capped mdist_capped_le y)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4899
        then have "d z y \<le> R"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4900
          by (simp add: \<open>y \<in> M\<close> \<open>z \<in> M\<close> *)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4901
        ultimately show "y \<in> mball z r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4902
          using \<open>R < r\<close> \<open>z \<in> M\<close> by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4903
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4904
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4905
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4906
  have 2: "\<exists>r>0. mball x r \<subseteq> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4907
    if "finite (J U)" and x: "x \<in> Pi\<^sub>E I U" and S: "Pi\<^sub>E I U \<subseteq> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4908
      and U: "\<And>i. i\<in>I \<Longrightarrow> openin (X i) (U i)" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4909
      and "x \<in> S" for U S x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4910
  proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4911
    { fix i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4912
      assume "i \<in> J U"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4913
      then have "i \<in> I"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4914
        by (auto simp: J_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4915
      then have "openin (mtopology_of (m i)) (U i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4916
        using U m by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4917
      then have "openin (mtopology_of (cm i)) (U i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4918
        by (simp add: Abstract_Metric_Spaces.mtopology_capped_metric cm_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4919
      then have "\<exists>r>0. mball_of (cm i) (x i) r \<subseteq> U i"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4920
        using x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4921
        by (simp add: Metric_space.openin_mtopology PiE_mem \<open>i \<in> I\<close> mball_of_def mtopology_of_def) 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4922
    }
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4923
    then obtain rf where rf: "\<And>j. j \<in> J U \<Longrightarrow> rf j >0 \<and> mball_of (cm j) (x j) (rf j) \<subseteq> U j"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4924
      by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4925
    define r where "r \<equiv> Min (insert 1 (rf ` J U))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4926
    show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4927
    proof (intro exI conjI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4928
      show "r > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4929
        by (simp add: \<open>finite (J U)\<close> r_def rf)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4930
      have r [simp]: "\<And>j. j \<in> J U \<Longrightarrow> r \<le> rf j" "r \<le> 1"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4931
        by (auto simp: r_def that(1))
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4932
      have *: "mball_of (cm i) (x i) r \<subseteq> U i" if "i \<in> I" for i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4933
      proof (cases "i \<in> J U")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4934
        case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4935
        with r show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4936
          by (smt (verit) Metric_space.in_mball Metric_space_mspace_mdist mball_of_def rf subset_eq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4937
      next
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4938
        case False
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4939
        then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4940
          by (simp add: J_def cm_def m subset_eq that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4941
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4942
      show "mball x r \<subseteq> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4943
        by (smt (verit) x * in_mball_of M_def Metric_space.in_mball Metric_space_axioms PiE_iff le_d o_apply subset_eq S)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4944
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4945
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4946
  have 3: "x \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4947
    if \<section>: "\<And>x. x\<in>S \<Longrightarrow> \<exists>U. finite (J U) \<and> (\<forall>i\<in>I. openin (X i) (U i)) \<and> x \<in> Pi\<^sub>E I U \<and> Pi\<^sub>E I U \<subseteq> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4948
      and "x \<in> S" for S x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4949
    using \<section> [OF \<open>x \<in> S\<close>] m openin_subset by (fastforce simp: M_def PiE_iff cm_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4950
  show thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4951
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4952
    show "Metric_space M d"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4953
      using Metric_space_axioms by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4954
    show eq: "product_topology X I = Metric_space.mtopology M d"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4955
      unfolding topology_eq openin_mtopology openin_product_topology_alt  
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4956
      using J_def 1 2 3 subset_iff zero by (smt (verit, ccfv_threshold))
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4957
    show "mcomplete" if "\<And>i. i \<in> I \<Longrightarrow> mcomplete_of (m i)" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4958
      unfolding mcomplete_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4959
    proof (intro strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4960
      fix \<sigma>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4961
      assume \<sigma>: "MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4962
      have "\<exists>y. i \<in> I \<longrightarrow> limitin (X i) (\<lambda>n. \<sigma> n i) y sequentially" for i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4963
      proof (cases "i \<in> I")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4964
        case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4965
        interpret MI: Metric_space "mspace (m i)" "mdist (m i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4966
          by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4967
        have "\<And>\<sigma>. MI.MCauchy \<sigma> \<longrightarrow> (\<exists>x. limitin MI.mtopology \<sigma> x sequentially)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4968
          by (meson MI.mcomplete_def True mcomplete_of_def that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4969
        moreover have "MI.MCauchy (\<lambda>n. \<sigma> n i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4970
          unfolding MI.MCauchy_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4971
        proof (intro conjI strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4972
          show "range (\<lambda>n. \<sigma> n i) \<subseteq> mspace (m i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4973
            by (smt (verit, ccfv_threshold) MCauchy_def PiE_iff True \<sigma> eq image_subset_iff m topspace_mtopology topspace_mtopology_of topspace_product_topology)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4974
          fix \<epsilon>::real
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4975
          define r where "r \<equiv> min \<epsilon> (inverse(Suc (kn i)))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4976
          assume "\<epsilon> > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4977
          then have "r > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4978
            by (simp add: r_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4979
          then obtain N where N: "\<And>n n'. N \<le> n \<and> N \<le> n' \<Longrightarrow> d (\<sigma> n) (\<sigma> n') < r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4980
            using \<sigma> unfolding MCauchy_def by meson
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4981
          show "\<exists>N. \<forall>n n'. N \<le> n \<longrightarrow> N \<le> n' \<longrightarrow> mdist (m i) (\<sigma> n i) (\<sigma> n' i) < \<epsilon>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4982
          proof (intro strip exI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4983
            fix n n'
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4984
            assume "N \<le> n" and "N \<le> n'"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4985
            then have "mdist (cm i) (\<sigma> n i) (\<sigma> n' i) < r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4986
              using *
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4987
              by (smt (verit) Metric_space.MCauchy_def Metric_space_axioms N True \<sigma> rangeI subsetD)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4988
            then
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4989
            show "mdist (m i) (\<sigma> n i) (\<sigma> n' i) < \<epsilon>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4990
              unfolding cm_def r_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4991
              by (smt (verit, ccfv_SIG) capped_metric_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4992
          qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4993
        qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4994
        ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4995
          by (simp add: m mtopology_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4996
      qed auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4997
      then obtain y where "\<And>i. i \<in> I \<Longrightarrow> limitin (X i) (\<lambda>n. \<sigma> n i) (y i) sequentially"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4998
        by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4999
      with \<sigma> show "\<exists>x. limitin mtopology \<sigma> x sequentially"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5000
        apply (rule_tac x="\<lambda>i\<in>I. y i" in exI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5001
        apply (simp add: MCauchy_def limitin_componentwise flip: eq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5002
        by (metis eq eventually_at_top_linorder range_subsetD topspace_mtopology topspace_product_topology)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5003
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5004
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5005
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5006
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5007
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5008
lemma metrizable_topology_D:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5009
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5010
    and co: "countable {i \<in> I. \<nexists>a. topspace (X i) \<subseteq> {a}}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5011
    and met: "\<And>i. i \<in> I \<Longrightarrow> metrizable_space (X i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5012
  shows "metrizable_space (product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5013
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5014
  have "\<And>i. i \<in> I \<Longrightarrow> \<exists>m. X i = mtopology_of m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5015
    by (metis Metric_space.mtopology_of met metrizable_space_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5016
  then obtain m where m: "\<And>i. i \<in> I \<Longrightarrow> X i = mtopology_of (m i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5017
    by metis 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5018
  then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5019
    using metrizable_topology_DD [of X I m] assms by (force simp: metrizable_space_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5020
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5021
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5022
lemma metrizable_topology_E:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5023
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5024
    and "countable {i \<in> I. \<nexists>a. topspace (X i) \<subseteq> {a}}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5025
    and met: "\<And>i. i \<in> I \<Longrightarrow> completely_metrizable_space (X i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5026
  shows "completely_metrizable_space (product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5027
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5028
  have "\<And>i. i \<in> I \<Longrightarrow> \<exists>m. mcomplete_of m \<and> X i = mtopology_of m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5029
    using met Metric_space.mtopology_of Metric_space.mcomplete_of unfolding completely_metrizable_space_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5030
    by metis 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5031
  then obtain m where "\<And>i. i \<in> I \<Longrightarrow> mcomplete_of (m i) \<and> X i = mtopology_of (m i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5032
    by metis 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5033
  then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5034
    using  metrizable_topology_DD [of X I m] assms unfolding metrizable_space_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5035
    by (metis (full_types) completely_metrizable_space_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5036
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5037
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  5038
proposition metrizable_space_product_topology:
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5039
  "metrizable_space (product_topology X I) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5040
        (product_topology X I) = trivial_topology \<or>
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5041
        countable {i \<in> I. \<not> (\<exists>a. topspace(X i) \<subseteq> {a})} \<and>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5042
        (\<forall>i \<in> I. metrizable_space (X i))"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5043
  by (metis (mono_tags, lifting) empty_metrizable_space metrizable_topology_A metrizable_topology_B metrizable_topology_D subtopology_eq_discrete_topology_empty)
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5044
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  5045
proposition completely_metrizable_space_product_topology:
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5046
  "completely_metrizable_space (product_topology X I) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5047
        (product_topology X I) = trivial_topology \<or>
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5048
        countable {i \<in> I. \<not> (\<exists>a. topspace(X i) \<subseteq> {a})} \<and>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5049
        (\<forall>i \<in> I. completely_metrizable_space (X i))"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5050
  by (smt (verit, del_insts) Collect_cong completely_metrizable_imp_metrizable_space empty_completely_metrizable_space metrizable_topology_B metrizable_topology_C metrizable_topology_E subtopology_eq_discrete_topology_empty)
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5051
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5052
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5053
lemma completely_metrizable_Euclidean_space:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5054
  "completely_metrizable_space(Euclidean_space n)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5055
  unfolding Euclidean_space_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5056
proof (rule completely_metrizable_space_closedin)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5057
  show "completely_metrizable_space (powertop_real (UNIV::nat set))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5058
    by (simp add: completely_metrizable_space_product_topology completely_metrizable_space_euclidean)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5059
  show "closedin (powertop_real UNIV) {x. \<forall>i\<ge>n. x i = 0}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5060
    using closedin_Euclidean_space topspace_Euclidean_space by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5061
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5062
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5063
lemma metrizable_Euclidean_space:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5064
   "metrizable_space(Euclidean_space n)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5065
  by (simp add: completely_metrizable_Euclidean_space completely_metrizable_imp_metrizable_space)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5066
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5067
lemma locally_connected_Euclidean_space:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5068
   "locally_connected_space(Euclidean_space n)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5069
  by (simp add: locally_path_connected_Euclidean_space locally_path_connected_imp_locally_connected_space)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5070
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  5071
end
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  5072