src/HOL/Analysis/Abstract_Metric_Spaces.thy
author wenzelm
Mon, 11 Sep 2023 19:30:48 +0200
changeset 78659 b5f3d1051b13
parent 78336 6bae28577994
child 78748 ca486ee0e4c5
permissions -rw-r--r--
tuned;
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
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   269
    apply (auto simp: mbounded_def subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   270
     apply blast+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   271
    done
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   272
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   273
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   274
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   275
lemma mbounded_alt_pos:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   276
  "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
   277
  by (smt (verit, del_insts) gt_ex mbounded_alt)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   278
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   279
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
   280
  by (meson mbounded_def order_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   281
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   282
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
   283
  by (simp add: mbounded_alt)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   284
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   285
lemma mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   286
   "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
   287
  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
   288
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   289
lemma mbounded_empty [iff]: "mbounded {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   290
  by (simp add: mbounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   291
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   292
lemma mbounded_mcball: "mbounded (mcball x r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   293
  using mbounded_def by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   294
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   295
lemma mbounded_mball [iff]: "mbounded (mball x r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   296
  by (meson mball_subset_mcball mbounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   297
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   298
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
   299
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   300
  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
   301
           \<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
   302
    by (metis order.trans nle_le)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   303
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   304
    by (auto simp: mbounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   305
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   306
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   307
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
   308
  by (meson inf_le1 mbounded_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   309
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   310
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
   311
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   312
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   313
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   314
  proof (cases "S={} \<or> T={}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   315
    case True then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   316
      using R by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   317
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   318
    case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   319
    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
   320
      using R mbounded_pos
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   321
      by (metis False mcball_eq_empty subset_empty)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   322
    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
   323
      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
   324
    then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   325
      using mbounded_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   326
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   327
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   328
  show "?lhs \<Longrightarrow> ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   329
    using mbounded_def by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   330
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   331
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   332
lemma mbounded_Union:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   333
  "\<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
   334
  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
   335
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   336
lemma mbounded_closure_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   337
   "mbounded S \<Longrightarrow> mbounded (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   338
  by (meson closedin_mcball closure_of_minimal mbounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   339
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   340
lemma mbounded_closure_of_eq:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   341
   "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
   342
  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
   343
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   344
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   345
lemma maxdist_thm:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   346
  assumes "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   347
      and "x \<in> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   348
      and "y \<in> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   349
    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
   350
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   351
  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
   352
    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
   353
  moreover have "d x y \<le> r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   354
    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
   355
    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
   356
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   357
    by (intro cSup_eq [symmetric]) auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   358
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   359
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   360
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   361
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
   362
  by (metis commute  subset_iff zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   363
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   364
lemma compactin_imp_mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   365
  assumes "compactin mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   366
  shows "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   367
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   368
  have "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   369
    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
   370
    using assms by (auto simp: compactin_def mbounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   371
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   372
  proof (cases "S = {}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   373
    case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   374
    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
   375
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   376
    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
   377
      by force
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   378
    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
   379
      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
   380
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   381
      using mbounded_Union mbounded_subset by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   382
  qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   383
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   384
78200
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
end (*Metric_space*)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   387
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   388
lemma mcball_eq_cball [simp]: "Met_TC.mcball = cball"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   389
  by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   390
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   391
lemma mball_eq_ball [simp]: "Met_TC.mball = ball"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   392
  by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   393
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   394
lemma mopen_eq_open [simp]: "Met_TC.mopen = open"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   395
  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
   396
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   397
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
   398
  by (simp add: Met_TC.mtopology_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   399
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   400
lemma mtopology_is_euclidean [simp]: "Met_TC.mtopology = euclidean"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   401
  by (simp add: Met_TC.mtopology_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   402
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   403
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
   404
  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
   405
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   406
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   407
subsection\<open>Subspace of a metric space\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   408
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   409
locale Submetric = Metric_space + 
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   410
  fixes A
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   411
  assumes subset: "A \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   412
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   413
sublocale Submetric \<subseteq> sub: Metric_space A d
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   414
  by (simp add: subset subspace)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   415
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   416
context Submetric
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   417
begin 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   418
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   419
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
   420
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
   421
  using subset by force+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   422
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   423
lemma mtopology_submetric: "sub.mtopology = subtopology mtopology A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   424
  unfolding topology_eq
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   425
proof (intro allI iffI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   426
  fix S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   427
  assume "openin sub.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   428
  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
   429
    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
   430
  then show "openin (subtopology mtopology A) S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   431
    by (meson openin_subopen)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   432
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   433
  fix S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   434
  assume "openin (subtopology mtopology A) S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   435
  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
   436
    by (meson openin_subtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   437
  then have "mopen T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   438
    by (simp add: mopen_def openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   439
  then have "sub.mopen (T \<inter> A)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   440
    unfolding sub.mopen_def mopen_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   441
    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
   442
  then show "openin sub.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   443
    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
   444
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   445
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   446
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
   447
  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
   448
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   449
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   450
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   451
lemma (in Metric_space) submetric_empty [iff]: "Submetric M d {}"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   452
proof qed auto
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   453
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
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
   456
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   457
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
   458
  morphisms "dest_metric" "metric"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   459
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   460
  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
   461
    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
   462
  then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   463
    by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   464
qed
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 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
   467
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   468
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
   469
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   470
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
   471
  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
   472
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   473
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
   474
  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
   475
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   476
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
   477
  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
   478
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   479
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
   480
  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
   481
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   482
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
   483
  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
   484
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   485
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
   486
  "mspace (metric (M,d)) = M"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   487
  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
   488
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   489
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
   490
  "mdist (metric (M,d)) = d"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   491
  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
   492
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   493
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
   494
  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
   495
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   496
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
   497
  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
   498
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   499
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
   500
  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
   501
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   502
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
   503
  "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
   504
  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
   505
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   506
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
   507
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   508
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
   509
  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
   510
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   511
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
   512
  "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
   513
  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
   514
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   515
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
   516
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   517
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
   518
  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
   519
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   520
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
   521
  "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
   522
  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
   523
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   524
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
   525
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   526
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
   527
  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
   528
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   529
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
   530
  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
   531
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   532
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
   533
  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
   534
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   535
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
   536
definition (in Metric_space) "Self \<equiv> metric (M,d)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   537
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   538
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
   539
  by (simp add: Self_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   540
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   541
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
   542
  by (simp add: Self_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
   543
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   544
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
   545
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   546
definition submetric where
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   547
  "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
   548
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   549
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
   550
  unfolding submetric_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   551
  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
   552
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   553
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
   554
  unfolding submetric_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   555
  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
   556
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   557
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
   558
  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
   559
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   560
lemma submetric_submetric [simp]:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   561
   "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
   562
  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
   563
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   564
lemma submetric_mspace [simp]:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   565
   "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
   566
  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
   567
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   568
lemma submetric_restrict:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   569
   "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
   570
  by (metis submetric_mspace submetric_submetric)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   571
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   572
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
   573
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   574
  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
   575
    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
   576
  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
   577
    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
   578
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   579
    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
   580
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
   581
78093
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
subsection\<open>The discrete metric\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   584
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   585
locale discrete_metric =
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   586
  fixes M :: "'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   587
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   588
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
   589
  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
   590
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   591
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
   592
  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
   593
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   594
sublocale discrete_metric \<subseteq> disc: Metric_space M dd
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   595
  by (simp add: metric_M_dd)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   596
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   597
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   598
lemma (in discrete_metric) mopen_singleton:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   599
  assumes "x \<in> M" shows "disc.mopen {x}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   600
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   601
  have "disc.mball x (1/2) \<subseteq> {x}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   602
    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
   603
  with assms show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   604
    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
   605
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   606
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   607
lemma (in discrete_metric) mtopology_discrete_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   608
   "disc.mtopology = discrete_topology M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   609
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   610
  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
   611
    by (simp add: disc.mtopology_def mopen_singleton)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   612
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   613
    by (metis disc.topspace_mtopology discrete_topology_unique)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   614
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   615
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   616
lemma (in discrete_metric) discrete_ultrametric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   617
   "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
   618
  by (simp add: dd_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   619
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   620
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   621
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
   622
  by (simp add: dd_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   623
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   624
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
   625
  by (meson dd_le1 disc.mbounded_alt)
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
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
subsection\<open>Metrizable spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   630
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   631
definition metrizable_space where
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   632
  "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
   633
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   634
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
   635
  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
   636
78258
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   637
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
   638
proof (clarsimp simp add: first_countable_def)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   639
  fix x
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   640
  assume "x \<in> M"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   641
  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
   642
  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
   643
  proof (intro exI conjI ballI)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   644
    show "countable \<B>"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   645
      by (simp add: \<B>_def countable_rat)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   646
    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
   647
    proof clarify
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   648
      fix U
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   649
      assume "openin mtopology U" and "x \<in> U"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   650
      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
   651
        by (meson openin_mtopology)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   652
      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
   653
        using Rats_dense_in_real by blast
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   654
      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
   655
        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
   656
    qed
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   657
  qed (auto simp: \<B>_def)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   658
qed
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   659
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   660
lemma metrizable_imp_first_countable:
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   661
   "metrizable_space X \<Longrightarrow> first_countable X"
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   662
  by (force simp add: metrizable_space_def Metric_space.first_countable_mtopology)
71366be2c647 The sym_diff operator (symmetric difference)
paulson <lp15@cam.ac.uk>
parents: 78248
diff changeset
   663
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   664
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
   665
  by (simp add: Met_TC.mtopology_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   666
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   667
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
   668
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   669
  have "(euclidean::'a topology) = Met_TC.mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   670
    by (simp add: Met_TC.mtopology_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   671
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   672
    using closed_closedin by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   673
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   674
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   675
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
   676
  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
   677
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
   678
lemma metrizable_space_discrete_topology [simp]:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   679
   "metrizable_space(discrete_topology U)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   680
  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
   681
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
   682
lemma empty_metrizable_space: "metrizable_space trivial_topology"
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
   683
  by simp
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   684
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   685
lemma metrizable_space_subtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   686
  assumes "metrizable_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   687
  shows "metrizable_space(subtopology X S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   688
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   689
  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
   690
    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
   691
  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
   692
    by (simp add: Submetric.intro Submetric_axioms_def)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   693
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   694
    unfolding metrizable_space_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   695
    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
   696
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   697
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   698
lemma homeomorphic_metrizable_space_aux:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   699
  assumes "X homeomorphic_space Y" "metrizable_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   700
  shows "metrizable_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   701
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   702
  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
   703
    using assms by (auto simp: metrizable_space_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   704
  then interpret m: Metric_space M d 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   705
    by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   706
  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
   707
    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
   708
    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
   709
  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
   710
  interpret m': Metric_space "topspace Y" "d'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   711
    unfolding d'_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   712
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   713
    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
   714
      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
   715
    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
   716
      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
   717
      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
   718
  qed (auto simp: m.nonneg m.commute)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   719
  have "Y = Metric_space.mtopology (topspace Y) d'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   720
    unfolding topology_eq
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   721
  proof (intro allI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   722
    fix S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   723
    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
   724
      unfolding m'.openin_mtopology
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   725
    proof (intro conjI that strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   726
      fix y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   727
      assume "y \<in> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   728
      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
   729
        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
   730
      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
   731
        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
   732
      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
   733
        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
   734
      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
   735
        using \<open>0 < r\<close> by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   736
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   737
    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
   738
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   739
      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
   740
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   741
        have y: "y \<in> topspace Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   742
          using m'.openin_mtopology ope' that by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   743
        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
   744
          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
   745
        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
   746
          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
   747
        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
   748
          using y by (force simp: m'.openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   749
        then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   750
          using \<open>0 < r\<close> r by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   751
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   752
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   753
        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
   754
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   755
    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
   756
      using m'.topspace_mtopology openin_subset by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   757
    then show "openin Y S = openin m'.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   758
      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
   759
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   760
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   761
    using m'.metrizable_space_mtopology by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   762
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   763
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   764
lemma homeomorphic_metrizable_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   765
  assumes "X homeomorphic_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   766
  shows "metrizable_space X \<longleftrightarrow> metrizable_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   767
  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
   768
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   769
lemma metrizable_space_retraction_map_image:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   770
   "retraction_map X Y r \<and> metrizable_space X
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   771
        \<Longrightarrow> metrizable_space Y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   772
  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
   773
  by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   774
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   775
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   776
lemma metrizable_imp_Hausdorff_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   777
   "metrizable_space X \<Longrightarrow> Hausdorff_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   778
  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
   779
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   780
(**
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   781
lemma metrizable_imp_kc_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   782
   "metrizable_space X \<Longrightarrow> kc_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   783
oops
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   784
  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
   785
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   786
lemma kc_space_mtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   787
   "kc_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   788
oops
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   789
  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
   790
**)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   791
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   792
lemma metrizable_imp_t1_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   793
   "metrizable_space X \<Longrightarrow> t1_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   794
  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
   795
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   796
lemma closed_imp_gdelta_in:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   797
  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
   798
  shows "gdelta_in X S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   799
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   800
  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
   801
    using X metrizable_space_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   802
  then interpret M: Metric_space M d
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   803
    by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   804
  have "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   805
    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
   806
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   807
  proof (cases "S = {}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   808
    case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   809
    then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   810
      by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   811
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   812
    case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   813
    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
   814
      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
   815
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   816
    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
   817
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   818
      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
   819
        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
   820
      have "closedin M.mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   821
        using S by (simp add: Xeq)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   822
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   823
        apply (simp add: M.closedin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   824
        by (metis * \<open>x \<in> M\<close> M.in_mball disjnt_insert1 insert_absorb subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   825
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   826
    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
   827
      using \<open>S \<subseteq> M\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   828
    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
   829
    proof (clarsimp simp: M.openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   830
      fix x y
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   831
      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
   832
      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
   833
        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
   834
      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
   835
        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
   836
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   837
    then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   838
      apply (subst Seq)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   839
      apply (force simp: Xeq intro: gdelta_in_Inter open_imp_gdelta_in)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   840
      done
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   841
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   842
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   843
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   844
lemma open_imp_fsigma_in:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   845
   "\<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
   846
  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
   847
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   848
lemma metrizable_space_euclidean:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   849
  "metrizable_space (euclidean :: 'a::metric_space topology)"
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
   850
  using Met_TC.metrizable_space_mtopology by auto
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   851
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   852
lemma (in Metric_space) regular_space_mtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   853
   "regular_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   854
unfolding regular_space_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   855
proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   856
  fix C a
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   857
  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
   858
  have "openin mtopology (topspace mtopology - C)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   859
    by (simp add: C openin_diff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   860
  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
   861
    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
   862
  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
   863
  proof (intro exI conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   864
    show "a \<in> mball a (r/2)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   865
      using \<open>0 < r\<close> a by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   866
    show "C \<subseteq> topspace mtopology - mcball a (r/2)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   867
      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
   868
  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
   869
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   870
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   871
lemma metrizable_imp_regular_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   872
   "metrizable_space X \<Longrightarrow> regular_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   873
  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
   874
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   875
lemma regular_space_euclidean:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   876
 "regular_space (euclidean :: 'a::metric_space topology)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   877
  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
   878
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   879
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   880
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
   881
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   882
lemma (in Metric_space) eventually_atin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   883
   "eventually P (atin mtopology a) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   884
        (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
   885
proof (cases "a \<in> M")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   886
  case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   887
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   888
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   889
    assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   890
    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
   891
      by (auto simp: eventually_atin)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   892
    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
   893
      by (meson openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   894
    with U show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   895
      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
   896
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   897
    assume ?rhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   898
    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
   899
      using True by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   900
    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
   901
      by (simp add: commute)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   902
    then show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   903
      unfolding eventually_atin openin_mtopology
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   904
      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
   905
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   906
qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   907
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   908
subsection \<open>Normal spaces and metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   909
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   910
lemma (in Metric_space) normal_space_mtopology:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   911
   "normal_space mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   912
  unfolding normal_space_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   913
proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   914
  fix S T
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   915
  assume "closedin mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   916
  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
   917
    by (simp add: closedin_def openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   918
  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
   919
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   920
  assume "closedin mtopology T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   921
  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
   922
    by (simp add: closedin_def openin_mtopology)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   923
  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
   924
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   925
  assume "disjnt S T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   926
  have "S \<subseteq> M" "T \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   927
    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
   928
  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
   929
    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
   930
  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
   931
    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
   932
  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
   933
  proof (intro exI conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   934
    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
   935
      by force+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   936
    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
   937
      using \<epsilon> \<open>S \<subseteq> M\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   938
    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
   939
      using \<delta> \<open>T \<subseteq> M\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   940
    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
   941
      using \<epsilon> \<delta> 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   942
      apply (clarsimp simp: disjnt_iff subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   943
      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
   944
  qed 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   945
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   946
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   947
lemma metrizable_imp_normal_space:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   948
   "metrizable_space X \<Longrightarrow> normal_space X"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   949
  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
   950
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   951
subsection\<open>Topological limitin in metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   952
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   953
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   954
lemma (in Metric_space) limitin_mspace:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   955
   "limitin mtopology f l F \<Longrightarrow> l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   956
  using limitin_topspace by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   957
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   958
lemma (in Metric_space) limitin_metric_unique:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   959
   "\<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
   960
  by (meson Hausdorff_space_mtopology limitin_Hausdorff_unique)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   961
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   962
lemma (in Metric_space) limitin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   963
   "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
   964
   (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   965
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   966
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   967
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   968
    unfolding limitin_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   969
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   970
    show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   971
      using L limitin_mspace by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   972
    fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   973
    assume "\<epsilon>>0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   974
    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
   975
      using L openin_mball by (fastforce simp: limitin_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   976
    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
   977
      using commute eventually_mono by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   978
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   979
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   980
  assume R: ?rhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   981
  then show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   982
    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
   983
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   984
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   985
lemma (in Metric_space) limit_metric_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   986
   "limitin mtopology f l sequentially \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   987
     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
   988
  by (auto simp: limitin_metric eventually_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   989
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
   990
lemma (in Submetric) limitin_submetric_iff:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   991
   "limitin sub.mtopology f l F \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   992
     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
   993
  by (simp add: limitin_subtopology mtopology_submetric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   994
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   995
lemma (in Metric_space) metric_closedin_iff_sequentially_closed:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   996
   "closedin mtopology S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   997
    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
   998
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
   999
  assume ?lhs then show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1000
    by (force simp: closedin_metric limitin_closedin range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1001
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1002
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1003
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1004
    unfolding closedin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1005
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1006
    show "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1007
      using R by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1008
    fix x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1009
    assume "x \<in> M - S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1010
    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
  1011
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1012
      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
  1013
        using that by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1014
      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
  1015
        by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1016
      then have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1017
        by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1018
      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
  1019
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1020
        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
  1021
          by linarith
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1022
        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
  1023
          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
  1024
        then show ?thesis ..
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1025
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1026
      with \<sigma> have "limitin mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1027
        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
  1028
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1029
        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
  1030
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1031
    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
  1032
      by (meson disjnt_iff in_mball)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1033
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1034
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1035
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1036
lemma (in Metric_space) limit_atin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1037
   "limitin X f y (atin mtopology x) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1038
      y \<in> topspace X \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1039
      (x \<in> M
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1040
       \<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
  1041
               \<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
  1042
  by (force simp: limitin_def eventually_atin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1043
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1044
lemma (in Metric_space) limitin_metric_dist_null:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1045
   "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
  1046
  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
  1047
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1048
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1049
subsection\<open>Cauchy sequences and complete metric spaces\<close>
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
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1052
begin
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 MCauchy :: "(nat \<Rightarrow> 'a) \<Rightarrow> bool"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1055
  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
  1056
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1057
definition mcomplete
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1058
  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
  1059
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1060
lemma mcomplete_empty [iff]: "Metric_space.mcomplete {} d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1061
  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
  1062
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1063
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
  1064
  unfolding MCauchy_def image_subset_iff comp_apply
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1065
  by (metis UNIV_I add.commute trans_le_add1) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1066
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1067
lemma mcomplete:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1068
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1069
    (\<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
  1070
     (\<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
  1071
     (\<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
  1072
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1073
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1074
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1075
  proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1076
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1077
    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
  1078
      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
  1079
    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
  1080
      by (auto simp: eventually_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1081
    with \<sigma> have "MCauchy (\<sigma> \<circ> (+)N)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1082
      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
  1083
    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
  1084
      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
  1085
    then have "limitin mtopology \<sigma> x sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1086
      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
  1087
    then show "\<exists>x. limitin mtopology \<sigma> x sequentially" ..
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1088
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1089
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
  1090
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1091
lemma mcomplete_empty_mspace: "M = {} \<Longrightarrow> mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1092
  using MCauchy_def mcomplete_def by blast
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 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
  1095
  using MCauchy_def mdist_zero by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1096
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1097
lemma convergent_imp_MCauchy:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1098
  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
  1099
  shows "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1100
  unfolding MCauchy_def image_subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1101
proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1102
  fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1103
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1104
  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
  1105
    using half_gt_zero lim limitin_metric by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1106
  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
  1107
    by (force simp: eventually_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1108
  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
  1109
    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
  1110
qed (use assms in blast)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1111
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1112
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1113
lemma mcomplete_alt:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1114
   "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
  1115
  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
  1116
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1117
lemma MCauchy_subsequence:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1118
  assumes "strict_mono r" "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1119
  shows "MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1120
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1121
  have "d (\<sigma> (r n)) (\<sigma> (r n')) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1122
    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
  1123
    for \<epsilon> N n n'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1124
    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
  1125
  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
  1126
    using MCauchy_def assms by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1127
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1128
    using assms by (simp add: MCauchy_def) metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1129
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1130
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1131
lemma MCauchy_offset:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1132
  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
  1133
  shows "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1134
  unfolding MCauchy_def image_subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1135
proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1136
  fix n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1137
  show "\<sigma> n \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1138
    using assms
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1139
    unfolding MCauchy_def image_subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1140
    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
  1141
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1142
  fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1143
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1144
  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
  1145
    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
  1146
  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
  1147
    unfolding o_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1148
    apply (rule_tac x="k+N" in exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1149
    by (smt (verit, del_insts) add.assoc le_add1 less_eqE)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1150
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1151
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1152
lemma MCauchy_convergent_subsequence:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1153
  assumes cau: "MCauchy \<sigma>" and "strict_mono r" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1154
     and lim: "limitin mtopology (\<sigma> \<circ> r) a sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1155
  shows "limitin mtopology \<sigma> a sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1156
  unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1157
proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1158
  show "a \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1159
    by (meson assms limitin_mspace)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1160
  fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1161
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1162
  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
  1163
    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
  1164
  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
  1165
    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
  1166
  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
  1167
  proof (intro conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1168
    show "\<sigma> n \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1169
      using MCauchy_def cau by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1170
    have "N1 \<le> r n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1171
      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
  1172
    then show "d (\<sigma> n) a < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1173
      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
  1174
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1175
  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
  1176
    using eventually_sequentially by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1177
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1178
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1179
lemma MCauchy_interleaving_gen:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1180
  "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
  1181
    (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
  1182
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1183
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1184
  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
  1185
    by (auto simp: strict_mono_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1186
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1187
  proof (intro conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1188
    show "MCauchy x" "MCauchy y"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1189
      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
  1190
    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
  1191
      unfolding LIMSEQ_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1192
    proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1193
      fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1194
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1195
      then obtain N where N: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1196
        "\<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
  1197
                                   (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
  1198
        using L MCauchy_def by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1199
      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
  1200
        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
  1201
      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
  1202
        by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1203
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1204
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1205
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1206
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1207
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1208
    unfolding MCauchy_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1209
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1210
    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
  1211
      using R by (auto simp: MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1212
    fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1213
    assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1214
    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
  1215
      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
  1216
    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
  1217
      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
  1218
    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
  1219
      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
  1220
      by (metis abs_mdist diff_zero real_norm_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1221
    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
  1222
    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
  1223
    proof (intro exI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1224
      fix n n'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1225
      assume "N \<le> n" and "N \<le> n'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1226
      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
  1227
        by (auto simp: N_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1228
      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
  1229
            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
  1230
            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
  1231
        using Nx Ny Nxy by blast+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1232
      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
  1233
        using MCauchy_def R by blast+
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1234
      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
  1235
      proof (cases "even n")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1236
        case nt: True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1237
        show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1238
        proof (cases "even n'")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1239
          case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1240
          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
  1241
        next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1242
          case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1243
          with nt dxyn dynn' inM triangle show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1244
            by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1245
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1246
      next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1247
        case nf: False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1248
        show ?thesis 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1249
        proof (cases "even n'")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1250
          case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1251
          then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1252
            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
  1253
        next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1254
          case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1255
          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
  1256
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1257
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1258
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1259
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1260
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1261
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1262
lemma MCauchy_interleaving:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1263
   "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
  1264
    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
  1265
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1266
  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
  1267
    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
  1268
  also have "... = ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1269
    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
  1270
  finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1271
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1272
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1273
lemma mcomplete_nest:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1274
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1275
      (\<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
  1276
          (\<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
  1277
          \<longrightarrow> \<Inter> (range C) \<noteq> {})" (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1278
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1279
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1280
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1281
    unfolding imp_conjL
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1282
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1283
    fix C :: "nat \<Rightarrow> 'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1284
    assume clo: "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1285
      and ne: "\<forall>n. C n \<noteq> ({}::'a set)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1286
      and dec: "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1287
      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
  1288
    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
  1289
      by (meson ne empty_iff set_eq_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1290
    have "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1291
      unfolding MCauchy_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1292
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1293
      show "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1294
        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
  1295
      fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1296
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1297
      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
  1298
        using cover by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1299
      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
  1300
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1301
        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
  1302
          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
  1303
        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
  1304
          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
  1305
          by (smt (verit, ccfv_threshold) in_mcball)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1306
        also have "... < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1307
          using \<open>\<epsilon> > 0\<close> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1308
        finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1309
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1310
      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
  1311
        by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1312
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1313
    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
  1314
      using L mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1315
    have "x \<in> C n" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1316
    proof (rule limitin_closedin [OF x])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1317
      show "closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1318
        by (simp add: clo)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1319
      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
  1320
        by (metis \<sigma> dec decseq_def eventually_sequentiallyI subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1321
    qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1322
    then show "\<Inter> (range C) \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1323
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1324
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1325
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1326
  assume R: ?rhs  
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1327
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1328
    unfolding mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1329
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1330
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1331
    assume "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1332
    then have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1333
      using MCauchy_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1334
    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
  1335
    have "\<forall>n. closedin mtopology (C n)" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1336
      by (auto simp: C_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1337
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1338
    have ne: "\<And>n. C n \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1339
      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
  1340
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1341
    have dec: "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1342
      unfolding monotone_on_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1343
    proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1344
      fix m n::nat
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1345
      assume "m \<le> n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1346
      then have "{n..} \<subseteq> {m..}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1347
        by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1348
      then show "C n \<subseteq> C m"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1349
        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
  1350
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1351
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1352
    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
  1353
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1354
      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
  1355
        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
  1356
      then have "\<sigma> ` {N..} \<subseteq> mcball (\<sigma> N) \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1357
        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
  1358
      then have "C N \<subseteq> mcball (\<sigma> N) \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1359
        by (simp add: C_def closure_of_minimal)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1360
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1361
        by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1362
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1363
    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
  1364
      by (metis R ex_in_conv)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1365
    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
  1366
      by (force simp: C_def metric_closure_of)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1367
    then have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1368
      using gt_ex by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1369
    show "\<exists>l. limitin mtopology \<sigma> l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1370
      unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1371
    proof (intro conjI strip exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1372
      show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1373
        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
  1374
      fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1375
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1376
      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
  1377
        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
  1378
      with * [of "\<epsilon>/2" N]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1379
      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
  1380
        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
  1381
      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
  1382
        using eventually_sequentially by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1383
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1384
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1385
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1386
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1387
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1388
lemma mcomplete_nest_sing:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1389
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1390
    (\<forall>C. (\<forall>n. closedin mtopology (C n)) \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1391
          (\<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
  1392
         \<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
  1393
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1394
  have *: False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1395
    if clo: "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1396
      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
  1397
      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
  1398
      and l: "\<forall>n. l \<in> C n"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1399
    for C :: "nat \<Rightarrow> 'a set" and l
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1400
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1401
    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
  1402
      using closedin_metric clo by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1403
    then have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1404
      by (simp add: l)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1405
    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
  1406
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1407
      have "l' \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1408
        using inM l' by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1409
      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
  1410
        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
  1411
      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
  1412
        using l l' na in_mcball by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1413
      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
  1414
        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
  1415
      then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1416
        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
  1417
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1418
    then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1419
      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
  1420
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1421
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1422
    unfolding mcomplete_nest imp_conjL 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1423
    apply (intro all_cong1 imp_cong refl)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1424
    using * 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1425
    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
  1426
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1427
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1428
lemma mcomplete_fip:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1429
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1430
    (\<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
  1431
         (\<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
  1432
        \<longrightarrow> \<Inter> \<C> \<noteq> {})" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1433
   (is "?lhs = ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1434
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1435
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1436
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1437
    unfolding mcomplete_nest_sing imp_conjL
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1438
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1439
    fix \<C> :: "'a set set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1440
    assume clo: "\<forall>C\<in>\<C>. closedin mtopology C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1441
      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
  1442
      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
  1443
    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
  1444
      by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1445
    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
  1446
          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
  1447
      by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1448
    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
  1449
    have cloD: "closedin mtopology (D n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1450
      unfolding D_def using clo C by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1451
    have neD: "D n \<noteq> {}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1452
      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
  1453
    have decD: "decseq D"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1454
      by (force simp: D_def decseq_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1455
    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
  1456
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1457
      obtain n where "inverse (Suc n) < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1458
        using \<open>0 < \<epsilon>\<close> reals_Archimedean by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1459
      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
  1460
        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
  1461
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1462
        unfolding D_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1463
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1464
    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
  1465
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1466
      have aC: "a \<in> C n" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1467
        using that by (auto simp: D_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1468
      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
  1469
        using that by (auto simp: D_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1470
      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
  1471
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1472
        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
  1473
          using clo cloD that by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1474
        have "\<Inter> (insert T (C ` {..n})) \<noteq> {}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1475
          using that C by (intro fip [rule_format]) auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1476
        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
  1477
          by (simp add: D_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1478
        have decT: "decseq (\<lambda>n. T \<inter> D n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1479
          by (force simp: D_def decseq_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1480
        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
  1481
          by (meson coverD le_infI2 that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1482
        show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1483
          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
  1484
          by (force simp: cloT neT decT coverT)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1485
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1486
      then show ?thesis by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1487
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1488
    show "\<Inter> \<C> \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1489
      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
  1490
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1491
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1492
  assume R [rule_format]: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1493
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1494
    unfolding mcomplete_nest imp_conjL
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1495
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1496
    fix C :: "nat \<Rightarrow> 'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1497
    assume clo: "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1498
      and ne: "\<forall>n. C n \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1499
      and dec: "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1500
      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
  1501
    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
  1502
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1503
      obtain k where "N \<subseteq> {..k}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1504
        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
  1505
      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
  1506
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1507
        using ne by force
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
    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
  1510
      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
  1511
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1512
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1513
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1514
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1515
lemma mcomplete_fip_sing:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1516
   "mcomplete \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1517
    (\<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
  1518
     (\<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
  1519
     (\<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
  1520
     (\<exists>l. l \<in> M \<and> \<Inter> \<C> = {l}))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1521
   (is "?lhs = ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1522
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1523
  have *: "l \<in> M" "\<Inter> \<C> = {l}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1524
    if clo: "Ball \<C> (closedin mtopology)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1525
      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
  1526
      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
  1527
      and l: "l \<in> \<Inter> \<C>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1528
    for \<C> :: "'a set set" and l
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1529
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1530
    show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1531
      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
  1532
    show  "\<Inter> \<C> = {l}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1533
    proof (cases "\<C> = {}")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1534
      case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1535
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1536
        using cover mbounded_pos by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1537
    next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1538
      case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1539
      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
  1540
        using False clo closedin_subset by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1541
      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
  1542
      proof 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1543
        assume l': "l' \<in> \<Inter> \<C>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1544
        with CM have "l' \<in> M" by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1545
        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
  1546
          by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1547
        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
  1548
          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
  1549
        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
  1550
          using l l' in_mcball by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1551
        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
  1552
          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
  1553
        with gt0 show False by auto
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
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1556
        using l by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1557
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1558
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1559
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1560
  with * show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1561
    unfolding mcomplete_fip imp_conjL ex_in_conv [symmetric]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1562
    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
  1563
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1564
  assume ?rhs then show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1565
    unfolding mcomplete_fip by (force elim!: all_forward)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1566
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1567
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1568
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1569
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1570
definition mcomplete_of :: "'a metric \<Rightarrow> bool"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1571
  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
  1572
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1573
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
  1574
  by (simp add: mcomplete_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1575
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1576
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
  1577
  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
  1578
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1579
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
  1580
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1581
  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
  1582
    by unfold_locales auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1583
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1584
    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
  1585
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1586
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1587
lemma MCauchy_iff_Cauchy [iff]: "Met_TC.MCauchy = Cauchy"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1588
  by (force simp: Cauchy_def Met_TC.MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1589
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1590
lemma mcomplete_iff_complete [iff]:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1591
  "Met_TC.mcomplete (Pure.type ::'a::metric_space itself) \<longleftrightarrow> complete (UNIV::'a set)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1592
  by (auto simp: Met_TC.mcomplete_def complete_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1593
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1594
context Submetric
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1595
begin 
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 MCauchy_submetric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1598
   "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
  1599
  using MCauchy_def sub.MCauchy_def subset by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1600
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1601
lemma closedin_mcomplete_imp_mcomplete:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1602
  assumes clo: "closedin mtopology A" and "mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1603
  shows "sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1604
  unfolding sub.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1605
proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1606
  fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1607
  assume "sub.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1608
  then have \<sigma>: "MCauchy \<sigma>" "range \<sigma> \<subseteq> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1609
    using MCauchy_submetric by blast+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1610
  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
  1611
    using \<open>mcomplete\<close> unfolding mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1612
  then have "x \<in> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1613
    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
  1614
  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
  1615
    using limitin_submetric_iff range_subsetD by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1616
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1617
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1618
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1619
lemma sequentially_closedin_mcomplete_imp_mcomplete:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1620
  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
  1621
  shows "sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1622
  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
  1623
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1624
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1625
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1626
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1627
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1628
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1629
lemma mcomplete_Un:
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1630
  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
  1631
      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
  1632
  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
  1633
proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1634
  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
  1635
    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
  1636
  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
  1637
    by (meson Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1638
  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
  1639
    by (meson A Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1640
  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
  1641
    by (meson B Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1642
  show "Metric_space.mcomplete (A \<union> B) d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1643
    unfolding MAB.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1644
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1645
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1646
    assume "MAB.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1647
    then have "range \<sigma> \<subseteq> A \<union> B"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1648
      using MAB.MCauchy_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1649
    then have "UNIV \<subseteq> \<sigma> -` A \<union> \<sigma> -` B"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1650
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1651
    then consider "infinite (\<sigma> -` A)" | "infinite (\<sigma> -` B)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1652
      using finite_subset by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1653
    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
  1654
    proof cases
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1655
      case 1
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1656
      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
  1657
        using infinite_enumerate by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1658
      then have "MA.MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1659
        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
  1660
      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
  1661
        using MA.mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1662
      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
  1663
        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
  1664
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1665
        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
  1666
    next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1667
      case 2
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1668
      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
  1669
        using infinite_enumerate by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1670
      then have "MB.MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1671
        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
  1672
      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
  1673
        using MB.mcomplete_def by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1674
      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
  1675
        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
  1676
      then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1677
        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
  1678
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1679
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1680
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1681
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1682
lemma mcomplete_Union:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1683
  assumes "finite \<S>"
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1684
    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
  1685
  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
  1686
  using assms
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1687
  by (induction rule: finite_induct) (auto simp: mcomplete_Un)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1688
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1689
lemma mcomplete_Inter:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1690
  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
  1691
    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
  1692
    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
  1693
  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
  1694
proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1695
  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
  1696
    using assms unfolding Submetric_def Submetric_axioms_def
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1697
    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
  1698
  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
  1699
    by (meson Submetric.subset subspace)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1700
  show "Metric_space.mcomplete (\<Inter>\<S>) d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1701
    unfolding MS.sub.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1702
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1703
    fix \<sigma>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1704
    assume "MS.sub.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1705
    then have "range \<sigma> \<subseteq> \<Inter>\<S>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1706
      using MS.MCauchy_submetric by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1707
    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
  1708
      using assms by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1709
    then have "range \<sigma> \<subseteq> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1710
      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
  1711
    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
  1712
      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
  1713
    have "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1714
      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
  1715
    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
  1716
      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
  1717
    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
  1718
      apply (rule_tac x="x" in exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1719
      unfolding MS.limitin_submetric_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1720
    proof (intro conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1721
      show "x \<in> \<Inter> \<S>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1722
      proof clarsimp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1723
        fix U
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1724
        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
  1725
        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
  1726
          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
  1727
        have "range \<sigma> \<subseteq> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1728
          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
  1729
        moreover have "Metric_space.mcomplete U d"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1730
          by (simp add: \<open>U \<in> \<S>\<close> comp)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1731
        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
  1732
          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
  1733
        have "x' = x"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1734
        proof (intro limitin_metric_unique)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1735
          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
  1736
            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
  1737
          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
  1738
            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
  1739
        qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1740
        then show "x \<in> U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1741
          using SU.sub.limitin_mspace x' by blast
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
      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
  1744
        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
  1745
      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
  1746
        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
  1747
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1748
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1749
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1750
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1751
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1752
lemma mcomplete_Int:
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1753
  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
  1754
      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
  1755
    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
  1756
  using mcomplete_Inter [of "{A,B}"] assms by force+
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
subsection\<open>Totally bounded subsets of metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1759
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1760
definition mtotally_bounded 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1761
  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
  1762
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1763
lemma mtotally_bounded_empty [iff]: "mtotally_bounded {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1764
by (simp add: mtotally_bounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1765
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1766
lemma finite_imp_mtotally_bounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1767
   "\<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
  1768
  by (auto simp: mtotally_bounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1769
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1770
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
  1771
  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
  1772
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1773
lemma mtotally_bounded_sing [simp]:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1774
   "mtotally_bounded {x} \<longleftrightarrow> x \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1775
  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
  1776
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1777
lemma mtotally_bounded_Un:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1778
  assumes  "mtotally_bounded S" "mtotally_bounded T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1779
  shows "mtotally_bounded (S \<union> T)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1780
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1781
  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
  1782
    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
  1783
      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
  1784
    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
  1785
  with assms show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1786
    unfolding mtotally_bounded_def by presburger
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1787
qed
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_Union:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1790
  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
  1791
  shows "mtotally_bounded (\<Union>f)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1792
  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
  1793
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1794
lemma mtotally_bounded_imp_mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1795
  assumes "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1796
  shows "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1797
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1798
  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
  1799
    using assms by (force simp: mtotally_bounded_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1800
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1801
    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
  1802
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1803
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1804
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1805
lemma mtotally_bounded_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1806
  "mtotally_bounded S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1807
    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
  1808
  (is "_ \<longleftrightarrow> _ \<and> ?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1809
proof (cases "S \<subseteq> M")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1810
  case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1811
  show ?thesis
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
    { fix \<sigma> :: "nat \<Rightarrow> 'a"                                                            
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1814
      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
  1815
      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
  1816
        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
  1817
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1818
        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
  1819
          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
  1820
        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
  1821
          by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1822
        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
  1823
        proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1824
          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
  1825
            if "d (\<sigma> i) (\<sigma> j) < \<epsilon>" for j
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1826
          proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1827
            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
  1828
              using K_imp_ex \<sigma> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1829
            then have "d w (\<sigma> i) < \<epsilon> + \<epsilon>/4"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1830
              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
  1831
            with w show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1832
              using in_mball by auto
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 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
  1835
            using True \<open>K \<subseteq> S\<close> by force
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1836
          then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1837
            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
  1838
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1839
        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
  1840
          by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1841
        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
  1842
          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
  1843
        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
  1844
          by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1845
        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
  1846
          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
  1847
        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
  1848
          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
  1849
        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
  1850
          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
  1851
        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
  1852
          using triangle'' by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1853
        also have "\<dots> < 3*\<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1854
          using dxi dxj by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1855
        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
  1856
        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
  1857
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1858
      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
  1859
                 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
  1860
        by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1861
      have "mbounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1862
        using L by (simp add: mtotally_bounded_imp_mbounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1863
      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
  1864
        by (meson \<sigma> mbounded_alt_pos range_subsetD)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1865
      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
  1866
      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
  1867
        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
  1868
      have "UNIV \<subseteq> \<sigma> -` mball (\<sigma> 0) (B+1)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1869
        using B True \<sigma> unfolding image_iff subset_iff
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1870
        by (smt (verit, best) UNIV_I in_mball vimageI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1871
      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
  1872
        using finite_subset by (auto simp: eps_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1873
      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
  1874
      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
  1875
        by (auto simp: r_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1876
      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
  1877
        using True \<sigma> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1878
      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
  1879
      proof (induction n)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1880
        case 0 then show ?case  
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1881
          by (simp add: inf0)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1882
      next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1883
        case (Suc n) then show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1884
          using nxt [of "eps n" "r n"] by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1885
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1886
      then have "r (Suc n) > r n" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1887
        by (simp add: nxt)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1888
      then have "strict_mono r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1889
        by (simp add: strict_mono_Suc_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1890
      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
  1891
        using nxt [OF _ inf] by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1892
      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
  1893
        by (simp add: eps_def power_add field_simps)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1894
      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
  1895
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1896
        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
  1897
        proof (induction k)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1898
          case 0 then show ?case 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1899
            by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1900
        next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1901
          case (Suc k)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1902
          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
  1903
            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
  1904
          with d_less[of "k+n"] Suc show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1905
            by (simp add: algebra_simps eps_plus)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1906
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1907
        also have "\<dots> < 3/2 * eps n * 2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1908
          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
  1909
        finally show ?thesis by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1910
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1911
      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
  1912
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1913
        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
  1914
        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
  1915
          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
  1916
        have N: "6 * eps N \<le> \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1917
          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
  1918
        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
  1919
          by (metis * add.commute nat_le_iff_add that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1920
        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
  1921
          by (smt (verit, best) \<sigma>rM triangle'')
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1922
        with N show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1923
          by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1924
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1925
      then have "MCauchy (\<sigma> \<circ> r)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1926
        unfolding MCauchy_def using True \<sigma> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1927
      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
  1928
        using \<open>strict_mono r\<close> by blast      
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1929
    }
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1930
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1931
    { assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1932
      have "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1933
        unfolding mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1934
      proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1935
        fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1936
        assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1937
        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
  1938
        proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1939
          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
  1940
            using \<section> by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1941
          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
  1942
          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
  1943
            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
  1944
          have [simp]: "\<sigma> n \<in> S" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1945
            using wf_less_than
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1946
          proof (induction n rule: wf_induct_rule)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1947
            case (less n) with f show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1948
              by (auto simp: \<sigma>_eq [of n])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1949
          qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1950
          then have "range \<sigma> \<subseteq> S" by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1951
          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
  1952
            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
  1953
          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
  1954
            by (meson R \<open>range \<sigma> \<subseteq> S\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1955
          with \<open>0 < \<epsilon>\<close> obtain N 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1956
            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
  1957
            by (force simp: MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1958
          show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1959
            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
  1960
            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
  1961
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1962
        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
  1963
          by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1964
      qed
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
    ultimately show ?thesis 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1967
      using True by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1968
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1969
qed (use mtotally_bounded_imp_subset in auto)
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
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1972
lemma mtotally_bounded_subset:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1973
   "\<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
  1974
  by (meson mtotally_bounded_sequentially order_trans) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1975
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1976
lemma mtotally_bounded_submetric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1977
  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
  1978
  shows "Metric_space.mtotally_bounded T d S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1979
proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1980
  interpret Submetric M d T
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1981
    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
  1982
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1983
    using assms
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1984
    unfolding sub.mtotally_bounded_def mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1985
    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
  1986
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1987
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1988
lemma mtotally_bounded_absolute:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1989
   "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
  1990
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1991
  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
  1992
  proof -
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  1993
    interpret Submetric M d S
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1994
      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
  1995
    show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1996
      using that
78283
6fa0812135e0 more small simplifications
paulson <lp15@cam.ac.uk>
parents: 78258
diff changeset
  1997
      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
  1998
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  1999
  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
  2000
    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
  2001
  ultimately show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2002
    using mtotally_bounded_imp_subset by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2003
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2004
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2005
lemma mtotally_bounded_closure_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2006
  assumes "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2007
  shows "mtotally_bounded (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2008
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2009
  have "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2010
    by (simp add: assms mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2011
  have "mtotally_bounded(mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2012
    unfolding mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2013
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2014
    fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2015
    assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2016
    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
  2017
      by (metis assms mtotally_bounded_def half_gt_zero)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2018
    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
  2019
      unfolding metric_closure_of
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2020
    proof clarsimp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2021
      fix x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2022
      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
  2023
      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
  2024
        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
  2025
      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
  2026
        using K by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2027
      then have "d x' x < \<epsilon>/2 + \<epsilon>/2"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2028
        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
  2029
      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
  2030
        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
  2031
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2032
    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
  2033
      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
  2034
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2035
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2036
    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
  2037
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2038
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2039
lemma mtotally_bounded_closure_of_eq:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2040
   "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
  2041
  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
  2042
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2043
lemma mtotally_bounded_cauchy_sequence:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2044
  assumes "MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2045
  shows "mtotally_bounded (range \<sigma>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2046
  unfolding MCauchy_def mtotally_bounded_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2047
proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2048
  fix \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2049
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2050
  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
  2051
    using assms by (force simp: MCauchy_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2052
  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
  2053
    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
  2054
  then
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2055
  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
  2056
    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
  2057
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2058
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2059
lemma MCauchy_imp_mbounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2060
   "MCauchy \<sigma> \<Longrightarrow> mbounded (range \<sigma>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2061
  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
  2062
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2063
subsection\<open>Compactness in metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2064
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2065
lemma Bolzano_Weierstrass_property:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2066
  assumes "S \<subseteq> U" "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2067
  shows
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2068
   "(\<forall>\<sigma>::nat\<Rightarrow>'a. range \<sigma> \<subseteq> S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2069
         \<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
  2070
    (\<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
  2071
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2072
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2073
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2074
  proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2075
    fix T
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2076
    assume "T \<subseteq> S" and "infinite T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2077
      and T: "U \<inter> mtopology derived_set_of T = {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2078
    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
  2079
      by (meson infinite_countable_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2080
    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
  2081
           and lr: "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2082
      by (meson \<open>T \<subseteq> S\<close> subset_trans)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2083
    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
  2084
      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
  2085
      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
  2086
    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
  2087
      by (auto simp: limitin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2088
    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
  2089
      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
  2090
    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
  2091
      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
  2092
    ultimately
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2093
    show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2094
       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
  2095
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2096
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2097
  assume R: ?rhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2098
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2099
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2100
    fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2101
    assume "range \<sigma> \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2102
    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
  2103
    proof (cases "finite (range \<sigma>)")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2104
      case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2105
      then obtain m where "infinite (\<sigma> -` {\<sigma> m})"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2106
        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
  2107
      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
  2108
        using infinite_enumerate by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2109
      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
  2110
        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
  2111
      show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2112
      proof (intro conjI exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2113
        show "limitin mtopology (\<sigma> \<circ> r) (\<sigma> m) sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2114
          using r by (simp add: limitin_metric)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2115
      qed auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2116
    next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2117
      case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2118
      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
  2119
        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
  2120
      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
  2121
        by (simp add: metric_derived_set_of) metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2122
      have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2123
        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
  2124
      have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2125
        using l metric_derived_set_of by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2126
      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
  2127
        "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
  2128
      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
  2129
      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
  2130
        by (auto simp: cut_apply)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2131
      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
  2132
        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
  2133
      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
  2134
        using wf_less_than
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2135
      proof (induction n rule: wf_induct_rule)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2136
        case (less n) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2137
        then have *: "Min (E r n) > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2138
          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
  2139
        show ?case
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2140
          using g [OF *] r_eq [of n]
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2141
          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
  2142
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2143
      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
  2144
        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
  2145
      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
  2146
        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
  2147
      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
  2148
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2149
        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
  2150
          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
  2151
        also have "... \<le> inverse(Suc n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2152
          by (simp add: E_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2153
        finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2154
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2155
      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
  2156
      proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2157
        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
  2158
          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
  2159
          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
  2160
        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
  2161
          by (rule conjunct2 [OF g [OF Min_pos]])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2162
        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
  2163
          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
  2164
        finally show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2165
          by (simp add: r_eq) 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2166
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2167
      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
  2168
        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
  2169
      show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2170
      proof (intro exI conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2171
        show "strict_mono r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2172
          by (simp add: r strict_monoI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2173
        show "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2174
          unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2175
        proof (intro conjI strip \<open>l \<in> M\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2176
          fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2177
          assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2178
          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
  2179
            using Archimedean_eventually_inverse by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2180
          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
  2181
            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
  2182
        qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2183
      qed (use \<open>l \<in> U\<close> in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2184
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2185
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2186
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2187
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2188
subsubsection \<open>More on Bolzano Weierstrass\<close>
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_A: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2191
  assumes "compactin mtopology S" "T \<subseteq> S" "infinite T"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2192
  shows "S \<inter> mtopology derived_set_of T \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2193
  by (simp add: assms compactin_imp_Bolzano_Weierstrass)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2194
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2195
lemma Bolzano_Weierstrass_B:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2196
  fixes \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2197
  assumes "S \<subseteq> M" "range \<sigma> \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2198
    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
  2199
  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
  2200
  using Bolzano_Weierstrass_property assms by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2201
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2202
lemma Bolzano_Weierstrass_C:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2203
  assumes "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2204
  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
  2205
                (\<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
  2206
  shows "mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2207
  unfolding mtotally_bounded_sequentially
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2208
  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
  2209
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2210
lemma Bolzano_Weierstrass_D:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2211
  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
  2212
  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
  2213
         \<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
  2214
  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
  2215
proof (rule ccontr)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2216
  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
  2217
  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
  2218
    by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2219
  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
  2220
       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
  2221
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2222
  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
  2223
         and lr: "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2224
    by (meson \<section> image_subsetI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2225
  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
  2226
    by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2227
  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
  2228
    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
  2229
  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
  2230
    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
  2231
  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
  2232
    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
  2233
  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
  2234
    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
  2235
  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
  2236
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2237
    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
  2238
      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
  2239
    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
  2240
      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
  2241
    also have "... < \<epsilon>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2242
      using that n rle by linarith
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2243
    finally show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2244
      by (simp add: \<epsilon> that)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2245
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2246
  then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2247
    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
  2248
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2249
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2250
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2251
lemma Bolzano_Weierstrass_E:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2252
  assumes "mtotally_bounded S" "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2253
  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
  2254
  shows "compactin mtopology S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2255
proof (clarsimp simp: compactin_def assms)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2256
  fix \<U> :: "'a set set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2257
  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
  2258
  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
  2259
    by (metis S)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2260
  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
  2261
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2262
  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
  2263
    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
  2264
  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
  2265
  proof (intro conjI exI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2266
    show "finite (f ` K)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2267
      by (simp add: \<open>finite K\<close>)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2268
    show "f ` K \<subseteq> \<U>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2269
      using \<open>K \<subseteq> S\<close> f by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2270
    show "S \<subseteq> \<Union>(f ` K)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2271
      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
  2272
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2273
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2274
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2275
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2276
lemma compactin_eq_Bolzano_Weierstrass:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2277
  "compactin mtopology S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2278
   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
  2279
  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
  2280
  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
  2281
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2282
lemma compactin_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2283
  shows "compactin mtopology S \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2284
        S \<subseteq> M \<and>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2285
        ((\<forall>\<sigma>::nat\<Rightarrow>'a. range \<sigma> \<subseteq> S
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2286
         \<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
  2287
  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
  2288
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2289
lemma compactin_imp_mtotally_bounded: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2290
  "compactin mtopology S \<Longrightarrow> mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2291
  by (simp add: Bolzano_Weierstrass_C 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 lebesgue_number:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2294
    "\<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
  2295
    \<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
  2296
  by (simp add: Bolzano_Weierstrass_D compactin_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2297
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2298
lemma compact_space_sequentially:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2299
   "compact_space mtopology \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2300
    (\<forall>\<sigma>::nat\<Rightarrow>'a. range \<sigma> \<subseteq> M
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2301
         \<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
  2302
  by (simp add: compact_space_def compactin_sequentially)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2303
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2304
lemma compact_space_eq_Bolzano_Weierstrass:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2305
   "compact_space mtopology \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2306
    (\<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
  2307
  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
  2308
  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
  2309
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2310
lemma compact_space_nest:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2311
   "compact_space mtopology \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2312
    (\<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
  2313
   (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2314
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2315
  assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2316
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2317
  proof clarify
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2318
    fix C :: "nat \<Rightarrow> 'a set"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2319
    assume "\<forall>n. closedin mtopology (C n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2320
      and "\<forall>n. C n \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2321
      and "decseq C"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2322
      and "\<Inter> (range C) = {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2323
    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
  2324
      by (metis L compact_space_imp_nest)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2325
    then obtain k where "K \<subseteq> {..k}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2326
      using finite_nat_iff_bounded_le by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2327
    then have "C k \<subseteq> \<Inter>(C ` K)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2328
      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
  2329
    then show False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2330
      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
  2331
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2332
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2333
  assume R [rule_format]: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2334
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2335
    unfolding compact_space_sequentially
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2336
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2337
    fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2338
    assume \<sigma>: "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2339
    have "mtopology closure_of \<sigma> ` {n..} \<noteq> {}" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2340
      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
  2341
    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
  2342
      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
  2343
    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
  2344
      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
  2345
    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
  2346
      using metric_closure_of by fastforce+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2347
    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
  2348
      by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2349
    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
  2350
    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
  2351
      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
  2352
    have "r n < r(Suc n)" for n
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2353
      by (simp add: Suc_le_lessD f r_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2354
    then have "strict_mono r"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2355
      by (simp add: strict_mono_Suc_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2356
    moreover have "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2357
      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
  2358
        fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2359
        assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2360
        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
  2361
          using Archimedean_eventually_inverse by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2362
        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
  2363
          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
  2364
      qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2365
    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
  2366
      using \<open>l \<in> M\<close> by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2367
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2368
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2369
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2370
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2371
lemma (in discrete_metric) mcomplete_discrete_metric: "disc.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2372
proof (clarsimp simp: disc.mcomplete_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2373
  fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2374
  assume "disc.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2375
  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
  2376
    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
  2377
  moreover have "range \<sigma> \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2378
    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
  2379
  ultimately have "limitin disc.mtopology \<sigma> (\<sigma> N) sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2380
    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
  2381
  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
  2382
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2383
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2384
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
  2385
  by (simp add: compact_space_nest mcomplete_nest)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2386
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2387
lemma (in Submetric) compactin_imp_mcomplete:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2388
   "compactin mtopology A \<Longrightarrow> sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2389
  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
  2390
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2391
lemma (in Submetric) mcomplete_imp_closedin:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2392
  assumes "sub.mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2393
  shows "closedin mtopology A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2394
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2395
  have "l \<in> A"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2396
    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
  2397
    for \<sigma> :: "nat \<Rightarrow> 'a" and l
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2398
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2399
    have "sub.MCauchy \<sigma>"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2400
      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
  2401
    then have "limitin sub.mtopology \<sigma> l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2402
      using assms unfolding sub.mcomplete_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2403
      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
  2404
    then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2405
      using limitin_submetric_iff by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2406
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2407
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2408
    using metric_closedin_iff_sequentially_closed subset by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2409
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2410
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2411
lemma (in Submetric) closedin_eq_mcomplete:
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2412
   "mcomplete \<Longrightarrow> (closedin mtopology A \<longleftrightarrow> sub.mcomplete)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2413
  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
  2414
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2415
lemma compact_space_eq_mcomplete_mtotally_bounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2416
   "compact_space mtopology \<longleftrightarrow> mcomplete \<and> mtotally_bounded M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2417
  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
  2418
            mcomplete_alt mtotally_bounded_sequentially subset_refl)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2419
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 compact_closure_of_imp_mtotally_bounded:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2422
   "\<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
  2423
      \<Longrightarrow> mtotally_bounded S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2424
  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
  2425
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2426
lemma mtotally_bounded_eq_compact_closure_of:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2427
  assumes "mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2428
  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
  2429
  (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2430
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2431
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2432
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2433
    unfolding compactin_subspace
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2434
  proof (intro conjI)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2435
    show "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2436
      using L by (simp add: mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2437
    show "mtopology closure_of S \<subseteq> topspace mtopology"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2438
      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
  2439
    then have MSM: "mtopology closure_of S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2440
      by auto
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2441
    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
  2442
    proof qed (use MSM in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2443
    have "S.sub.mtotally_bounded (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2444
      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
  2445
    then
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2446
    show "compact_space (subtopology mtopology (mtopology closure_of S))"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2447
      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
  2448
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2449
qed (auto simp: compact_closure_of_imp_mtotally_bounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2450
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2451
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2452
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2453
lemma compact_closure_of_eq_Bolzano_Weierstrass:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2454
   "compactin mtopology (mtopology closure_of S) \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2455
    (\<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
  2456
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2457
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2458
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2459
  proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2460
    fix T
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2461
    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
  2462
    show "mtopology derived_set_of T \<noteq> {}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2463
    proof (intro compact_closure_of_imp_Bolzano_Weierstrass)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2464
      show "compactin mtopology (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2465
        by (simp add: L)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2466
    qed (use T in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2467
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2468
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2469
  have "compactin mtopology (mtopology closure_of S)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2470
    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
  2471
    unfolding compactin_sequentially
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2472
  proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2473
    show MSM: "mtopology closure_of S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2474
      using closure_of_subset_topspace by fastforce
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2475
    fix \<sigma> :: "nat \<Rightarrow> 'a"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2476
    assume \<sigma>: "range \<sigma> \<subseteq> mtopology closure_of S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2477
    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
  2478
      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
  2479
    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
  2480
      by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2481
    then have "range \<tau> \<subseteq> S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2482
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2483
    moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2484
    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
  2485
      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
  2486
    moreover have "S \<subseteq> mtopology closure_of S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2487
      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
  2488
    ultimately obtain l r where lr:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2489
      "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
  2490
      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
  2491
    then have "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2492
      using limitin_mspace by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2493
    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
  2494
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2495
      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
  2496
        using \<tau> by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2497
      also have "... \<le> inverse(Suc n)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2498
        using lr strict_mono_imp_increasing by auto
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2499
      finally show ?thesis .
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2500
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2501
    have "limitin mtopology (\<sigma> \<circ> r) l sequentially"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2502
      unfolding limitin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2503
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2504
      show "l \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2505
        using limitin_mspace lr by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2506
      fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2507
      assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2508
      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
  2509
        using lr half_gt_zero limitin_metric by blast 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2510
      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
  2511
        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
  2512
      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
  2513
        by eventually_elim (smt (verit, del_insts) dr_less)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2514
      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
  2515
        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
  2516
      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
  2517
        apply eventually_elim
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2518
        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
  2519
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2520
    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
  2521
      by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2522
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2523
  then show "?rhs \<Longrightarrow> ?lhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2524
    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
  2525
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2526
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2527
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2528
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2529
lemma (in discrete_metric) mtotally_bounded_discrete_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2530
   "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
  2531
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2532
  assume L: ?lhs 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2533
  show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2534
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2535
    show "finite S"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2536
      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
  2537
          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
  2538
    show "S \<subseteq> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2539
      by (simp add: L disc.mtotally_bounded_imp_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2540
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2541
qed (simp add: disc.finite_imp_mtotally_bounded)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2542
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2543
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2544
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2545
begin
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_openin_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2548
   "mtopology derived_set_of S =
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2549
    {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
  2550
  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
  2551
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2552
lemma derived_set_of_infinite_1: 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2553
  assumes "infinite (S \<inter> mball x \<epsilon>)" 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2554
  shows "infinite (S \<inter> mcball x \<epsilon>)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2555
  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
  2556
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2557
lemma derived_set_of_infinite_2:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2558
  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
  2559
  shows "infinite (S \<inter> U)"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2560
  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
  2561
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2562
lemma derived_set_of_infinite_mball:
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> mball 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
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2565
  by (meson centre_in_mball_iff openin_mball derived_set_of_infinite_1 derived_set_of_infinite_2)
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
lemma derived_set_of_infinite_mcball:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2568
  "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
  2569
  unfolding derived_set_of_infinite_openin_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2570
  by (meson centre_in_mball_iff openin_mball derived_set_of_infinite_1 derived_set_of_infinite_2)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2571
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2572
end
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
subsection\<open>Continuous functions on metric spaces\<close>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2575
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2576
context Metric_space
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2577
begin
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2578
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2579
lemma continuous_map_to_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2580
   "continuous_map X mtopology f \<longleftrightarrow>
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2581
    (\<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
  2582
   (is "?lhs=?rhs")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2583
proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2584
  show "?lhs \<Longrightarrow> ?rhs"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2585
    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
  2586
    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
  2587
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2588
  assume R: ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2589
  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
  2590
    by (meson gt_ex in_mball)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2591
  moreover 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2592
  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
  2593
    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
  2594
  ultimately
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2595
  show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2596
    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
  2597
qed 
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2598
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2599
lemma continuous_map_from_metric:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2600
   "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
  2601
    f \<in> M \<rightarrow> topspace X \<and>
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2602
    (\<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
  2603
proof (cases "f ` M \<subseteq> topspace X")
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2604
  case True
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2605
  then show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2606
    by (fastforce simp: continuous_map openin_mtopology subset_eq)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2607
next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2608
  case False
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2609
  then show ?thesis
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  2610
    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
  2611
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2612
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2613
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
  2614
lemma continuous_map_uniform_limit:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2615
  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
  2616
    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
  2617
    and nontriv: "\<not> trivial_limit F"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2618
  shows "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2619
  unfolding continuous_map_to_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2620
proof (intro strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2621
  fix x and \<epsilon>::real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2622
  assume "x \<in> topspace X" and "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2623
  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
  2624
    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
  2625
    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
  2626
    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
  2627
    by (smt (verit, ccfv_SIG) zero_less_divide_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2628
  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
  2629
    unfolding continuous_map_to_metric
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2630
    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
  2631
  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
  2632
    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
  2633
  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
  2634
  proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2635
    have "g y \<in> M"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2636
      using U gM openin_subset that by blast
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2637
    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
  2638
      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
  2639
    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
  2640
      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
  2641
    also have "\<dots> < \<epsilon>/3 + \<epsilon>/3 + \<epsilon>/3"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2642
      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
  2643
    finally show ?thesis by simp
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2644
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2645
  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
  2646
    by (metis commute in_mball in_mono openin_subset)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2647
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2648
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2649
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2650
lemma continuous_map_uniform_limit_alt:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2651
  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
  2652
    and gim: "g \<in> topspace X \<rightarrow> M"
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2653
    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
  2654
    and nontriv: "\<not> trivial_limit F"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2655
  shows "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2656
proof (rule continuous_map_uniform_limit [OF contf])
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2657
  fix \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2658
  assume "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2659
  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
  2660
    by (simp add: Pi_iff)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2661
qed (use nontriv in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2662
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2663
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2664
lemma continuous_map_uniformly_Cauchy_limit:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2665
  assumes "mcomplete"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2666
  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
  2667
    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
  2668
  obtains g where
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2669
    "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2670
    "\<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
  2671
proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2672
  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
  2673
    using \<open>mcomplete\<close> [unfolded mcomplete, rule_format] assms
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  2674
    by (smt (verit) contf continuous_map_def eventually_mono topspace_mtopology Pi_iff)
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2675
  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
  2676
    by metis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2677
  show thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2678
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2679
    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
  2680
      if "\<epsilon> > 0" for \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2681
    proof -
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2682
      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
  2683
        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
  2684
      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
  2685
        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
  2686
      show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2687
      proof (intro eventually_sequentiallyI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2688
        fix n x
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2689
        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
  2690
        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
  2691
          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
  2692
          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
  2693
        define n' where "n' \<equiv> Max{L,N,P}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2694
        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
  2695
          using L by (simp add: n'_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2696
        moreover
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2697
        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
  2698
          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
  2699
        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
  2700
          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
  2701
        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
  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
    then show "continuous_map X mtopology g"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2705
      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
  2706
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2707
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2708
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2709
lemma metric_continuous_map:
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2710
  assumes "Metric_space M' d'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2711
  shows
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2712
   "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
  2713
    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
  2714
   (is "?lhs = ?rhs")
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
  interpret M': Metric_space M' d'
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2717
    by (simp add: assms)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2718
  show ?thesis
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2719
  proof
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2720
    assume L: ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2721
    show ?rhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2722
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2723
      show "f ` M \<subseteq> M'"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2724
        using L by (auto simp: continuous_map_def)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2725
      fix a and \<epsilon> :: real
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2726
      assume "a \<in> M" and "\<epsilon> > 0"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2727
      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
  2728
        using L unfolding continuous_map_def by fastforce+
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2729
      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
  2730
        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
  2731
      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
  2732
        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
  2733
    qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2734
  next
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2735
    assume R: ?rhs    
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2736
    show ?lhs
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2737
      unfolding continuous_map_def
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2738
    proof (intro conjI strip)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2739
      fix U
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2740
      assume "openin M'.mtopology U"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2741
      then show "openin mtopology {x \<in> topspace mtopology. f x \<in> U}"
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2742
        apply (simp add: continuous_map_def openin_mtopology M'.openin_mtopology subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2743
        by (metis R image_subset_iff)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2744
    qed (use R in auto)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2745
  qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2746
qed
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2747
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2748
end (*Metric_space*)
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  2749
78127
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
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
  2752
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2753
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
  2754
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2755
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
  2756
 "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
  2757
     \<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
  2758
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2759
lemma empty_completely_metrizable_space: 
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  2760
  "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
  2761
  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
  2762
  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
  2763
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2764
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
  2765
   "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
  2766
  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
  2767
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2768
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
  2769
   "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
  2770
  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
  2771
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2772
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
  2773
   "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
  2774
  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
  2775
  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
  2776
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2777
lemma completely_metrizable_space_euclidean:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2778
    "completely_metrizable_space (euclidean:: 'a::complete_space topology)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2779
  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
  2780
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2781
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
  2782
  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
  2783
  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
  2784
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2785
  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
  2786
                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
  2787
    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
  2788
  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
  2789
    by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2790
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2791
    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
  2792
  proof (intro conjI exI)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2793
    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
  2794
      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
  2795
    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
  2796
      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
  2797
    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
  2798
      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
  2799
    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
  2800
      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
  2801
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2802
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2803
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2804
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
  2805
    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
  2806
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2807
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2808
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
  2809
  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
  2810
  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
  2811
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2812
  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
  2813
    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
  2814
    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
  2815
    using homXY
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  2816
    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
  2817
  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
  2818
    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
  2819
  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
  2820
  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
  2821
  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
  2822
  proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2823
    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
  2824
      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
  2825
      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
  2826
    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
  2827
      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
  2828
      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
  2829
  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
  2830
  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
  2831
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2832
    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
  2833
  proof (intro exI conjI)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2834
    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
  2835
      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
  2836
    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
  2837
      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
  2838
      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
  2839
    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
  2840
    proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2841
      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
  2842
        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
  2843
      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
  2844
        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
  2845
      then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2846
        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
  2847
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2848
    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
  2849
      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
  2850
    proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2851
      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
  2852
        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
  2853
      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
  2854
        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
  2855
      then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2856
        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
  2857
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2858
    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
  2859
      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
  2860
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2861
    show "MY.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2862
      unfolding MY.mcomplete_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2863
    proof (intro strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2864
      fix \<sigma>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2865
      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
  2866
      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
  2867
        unfolding MX.MCauchy_def 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2868
      proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2869
        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
  2870
          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
  2871
        fix \<epsilon> :: real
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2872
        assume "\<epsilon> > 0"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2873
        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
  2874
          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
  2875
        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
  2876
          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
  2877
      qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2878
      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
  2879
        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
  2880
        by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2881
      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
  2882
        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
  2883
      moreover have "f \<circ> (g \<circ> \<sigma>) = \<sigma>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2884
        using \<open>MY.MCauchy \<sigma>\<close>  by (force simp add: fg MY.MCauchy_def subset_iff)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2885
      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
  2886
      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
  2887
        by blast 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2888
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2889
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2890
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2891
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2892
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
  2893
   "X homeomorphic_space Y
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2894
        \<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
  2895
  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
  2896
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2897
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
  2898
  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
  2899
  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
  2900
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2901
  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
  2902
    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
  2903
  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
  2904
    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
  2905
  then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2906
    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
  2907
        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
  2908
        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
  2909
qed
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
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2912
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2913
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
  2914
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2915
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
  2916
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
  2917
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
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
  2920
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2921
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
  2922
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2923
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
  2924
proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2925
  fix x y z
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2926
  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
  2927
  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
  2928
      (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
  2929
    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
  2930
    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
  2931
  proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2932
    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
  2933
      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
  2934
    show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2935
    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
  2936
      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
  2937
        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
  2938
      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
  2939
        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
  2940
      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
  2941
    qed auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2942
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2943
  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
  2944
    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
  2945
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
  2946
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2947
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
  2948
  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
  2949
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2950
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
  2951
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
  2952
  "Metric_space12 (mspace m1) (mdist m1) (mspace m2) (mdist m2)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2953
  by (simp add: Metric_space12_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
  2954
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2955
definition prod_metric where
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2956
 "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
  2957
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2958
lemma submetric_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2959
   "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
  2960
  apply (simp add: prod_metric_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2961
  by (simp add: submetric_def Metric_space.mspace_metric Metric_space.mdist_metric Metric_space12.prod_metric Metric_space12_def Metric_space_mspace_mdist Times_Int_Times)
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 mspace_prod_metric [simp]:"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2964
  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
  2965
  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
  2966
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2967
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
  2968
  "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
  2969
  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
  2970
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2971
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
  2972
  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
  2973
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2974
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
  2975
  "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
  2976
  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
  2977
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  2978
context Metric_space12
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2979
begin
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 component_le_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2982
   "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
  2983
  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
  2984
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2985
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
  2986
  "\<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
  2987
    \<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
  2988
  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
  2989
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2990
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
  2991
   "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
  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 mcball_prod_metric_subset:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2995
   "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
  2996
  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
  2997
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  2998
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
  2999
   "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
  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 mcball_subset_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3003
   "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
  3004
  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
  3005
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3006
lemma mtopology_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3007
  "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
  3008
  unfolding prod_topology_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3009
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
  3010
  fix U
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3011
  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
  3012
  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
  3013
    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
  3014
    by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3015
  have "S \<subseteq> M1"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3016
    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
  3017
  have "T \<subseteq> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3018
    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
  3019
  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
  3020
    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
  3021
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3022
    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
  3023
      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
  3024
    fix z
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3025
    assume "z \<in> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3026
    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
  3027
      using Ueq by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3028
    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
  3029
      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
  3030
    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
  3031
      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
  3032
    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
  3033
    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
  3034
      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
  3035
        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
  3036
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3037
    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
  3038
      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
  3039
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3040
next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3041
  fix U z
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3042
  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
  3043
  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
  3044
    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
  3045
  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
  3046
    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
  3047
  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
  3048
    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
  3049
  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
  3050
  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
  3051
  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
  3052
    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
  3053
  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
  3054
    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
  3055
  moreover have "B1 \<times> B2 \<subseteq> U"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3056
    using r prod_metric_le_components by (force simp 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
  3057
  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
  3058
    by (auto simp: zeq)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3059
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3060
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3061
lemma MCauchy_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3062
   "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
  3063
   (is "?lhs \<longleftrightarrow> ?rhs")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3064
proof safe
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3065
  assume L: ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3066
  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
  3067
    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
  3068
  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
  3069
    by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3070
  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
  3071
    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
  3072
    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
  3073
    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
  3074
        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
  3075
  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
  3076
    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
  3077
  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
  3078
    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
  3079
    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
  3080
        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
  3081
  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
  3082
    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
  3083
next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3084
  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
  3085
  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
  3086
    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
  3087
  show ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3088
    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
  3089
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3090
    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
  3091
      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
  3092
    fix \<epsilon> :: real
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3093
    assume "\<epsilon> > 0"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3094
    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
  3095
      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
  3096
    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
  3097
      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
  3098
    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
  3099
      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
  3100
    proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3101
      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
  3102
        by fastforce+
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3103
      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
  3104
        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
  3105
      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
  3106
        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
  3107
      finally show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3108
        by (simp add: \<sigma>)
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
    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
  3111
      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
  3112
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3113
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3114
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3115
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3116
lemma mcomplete_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3117
  "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
  3118
  (is "?lhs \<longleftrightarrow> ?rhs")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3119
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
  3120
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3121
  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
  3122
    by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3123
  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
  3124
    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
  3125
        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
  3126
  moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3127
  { 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
  3128
    have "M1.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3129
      unfolding M1.mcomplete_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3130
    proof (intro strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3131
      fix \<sigma>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3132
      assume "M1.MCauchy \<sigma>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3133
      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
  3134
        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
  3135
      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
  3136
        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
  3137
      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
  3138
        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
  3139
             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
  3140
    qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3141
  }
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3142
  moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3143
  { 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
  3144
    have "M2.mcomplete"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3145
      unfolding M2.mcomplete_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3146
    proof (intro strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3147
      fix \<sigma>
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3148
      assume "M2.MCauchy \<sigma>"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3149
      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
  3150
        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
  3151
      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
  3152
        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
  3153
      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
  3154
        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
  3155
             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
  3156
    qed
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
  ultimately show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3159
    using False by blast 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3160
qed auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3161
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3162
lemma mbounded_prod_metric:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3163
   "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
  3164
proof -
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3165
  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
  3166
    \<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
  3167
    for x y
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3168
  proof safe
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3169
    fix B
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3170
    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
  3171
    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
  3172
      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
  3173
    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
  3174
      by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3175
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3176
    fix B1 B2
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3177
    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
  3178
    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
  3179
      by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3180
    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
  3181
      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
  3182
    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
  3183
      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
  3184
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3185
  then show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3186
    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
  3187
qed 
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
lemma mbounded_Times:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3190
   "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
  3191
  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
  3192
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3193
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3194
lemma mtotally_bounded_Times:
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3195
   "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
  3196
    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
  3197
    (is "?lhs \<longleftrightarrow> _")
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3198
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
  3199
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3200
  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
  3201
    by auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3202
  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
  3203
    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
  3204
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3205
    show "S \<subseteq> M1"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3206
      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
  3207
    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
  3208
    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
  3209
    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
  3210
      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
  3211
      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
  3212
    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
  3213
      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
  3214
    with \<open>strict_mono r\<close> 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
  3215
      by (auto simp add: o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3216
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3217
  moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3218
  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
  3219
    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
  3220
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3221
    show "T \<subseteq> M2"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3222
      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
  3223
    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
  3224
    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
  3225
    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
  3226
      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
  3227
      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
  3228
    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
  3229
      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
  3230
    with \<open>strict_mono r\<close> 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
  3231
      by (auto simp add: o_def)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3232
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3233
  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
  3234
    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
  3235
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3236
    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
  3237
      using that 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3238
      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
  3239
    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
  3240
    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
  3241
    with 1 obtain r1 where r1: "strict_mono r1" "M1.MCauchy (fst \<circ> \<sigma> \<circ> r1)"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3242
      apply (clarsimp simp: M1.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
  3243
      by (metis SigmaE comp_eq_dest_lhs fst_conv)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3244
    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
  3245
      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
  3246
      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
  3247
    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
  3248
      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
  3249
    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
  3250
      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
  3251
    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
  3252
      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
  3253
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3254
  ultimately show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3255
    using False by blast
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3256
qed auto
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3257
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3258
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
  3259
   "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
  3260
    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
  3261
proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3262
  assume L: ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3263
  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
  3264
    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
  3265
    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
  3266
  show ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3267
    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
  3268
  proof (intro conjI strip)
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3269
    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
  3270
      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
  3271
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3272
    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
  3273
    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
  3274
    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
  3275
      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
  3276
    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
  3277
      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
  3278
    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
  3279
      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
  3280
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3281
    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
  3282
    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
  3283
    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
  3284
      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
  3285
    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
  3286
      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
  3287
    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
  3288
      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
  3289
  qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3290
next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3291
  assume ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3292
  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
  3293
    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
  3294
  then show ?lhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3295
    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
  3296
qed
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3297
78093
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  3298
end
cec875dcc59e Finally, the abstract metric space development
paulson <lp15@cam.ac.uk>
parents:
diff changeset
  3299
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3300
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3301
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
  3302
   "metrizable_space (prod_topology X Y) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3303
    (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
  3304
   (is "?lhs \<longleftrightarrow> ?rhs")
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3305
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
  3306
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3307
  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
  3308
    by fastforce
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3309
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3310
  proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3311
    show "?rhs \<Longrightarrow> ?lhs"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3312
      unfolding metrizable_space_def
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3313
      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
  3314
      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
  3315
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3316
    assume L: ?lhs 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3317
    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
  3318
      "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
  3319
      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
  3320
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3321
    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
  3322
      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
  3323
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3324
    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
  3325
      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
  3326
    ultimately show ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3327
      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
  3328
  qed
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3329
qed auto
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3330
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3331
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3332
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
  3333
   "completely_metrizable_space (prod_topology X Y) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3334
    (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
  3335
    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
  3336
   (is "?lhs \<longleftrightarrow> ?rhs")
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3337
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
  3338
  case False
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3339
  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
  3340
    by fastforce
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3341
  show ?thesis
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3342
  proof
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3343
    show "?rhs \<Longrightarrow> ?lhs"
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3344
      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
  3345
      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
  3346
          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
  3347
  next
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3348
    assume L: ?lhs 
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3349
    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
  3350
      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
  3351
    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
  3352
      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
  3353
    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
  3354
      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
  3355
      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
  3356
    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
  3357
               \<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
  3358
      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
  3359
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3360
    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
  3361
      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
  3362
    moreover
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3363
    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
  3364
      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
  3365
    ultimately show ?rhs
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3366
      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
  3367
  qed
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3368
next
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3369
  case True then show ?thesis
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3370
    using empty_completely_metrizable_space by auto
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  3371
qed 
78127
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3372
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3373
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3374
subsection \<open>The "atin-within" filter for topologies\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3375
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3376
(*FIXME: replace original definition of atin to be an abbreviation, like at / at_within
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3377
    ("atin (_) (_)/ within (_)" [1000, 60] 60)*)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3378
definition atin_within :: "['a topology, 'a, 'a set] \<Rightarrow> 'a filter"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3379
  where "atin_within X a S = inf (nhdsin X a) (principal (topspace X \<inter> S - {a}))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3380
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3381
lemma atin_within_UNIV [simp]:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3382
  shows "atin_within X a UNIV = atin X a"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3383
  by (simp add: atin_def atin_within_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3384
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3385
lemma eventually_atin_subtopology:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3386
  assumes "a \<in> topspace X"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3387
  shows "eventually P (atin (subtopology X S) a) \<longleftrightarrow> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3388
    (a \<in> S \<longrightarrow> (\<exists>U. openin (subtopology X S) U \<and> a \<in> U \<and> (\<forall>x\<in>U - {a}. P x)))"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3389
  using assms by (simp add: eventually_atin)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3390
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3391
lemma eventually_atin_within:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3392
  "eventually P (atin_within X a S) \<longleftrightarrow> a \<notin> topspace X \<or> (\<exists>T. openin X T \<and> a \<in> T \<and> (\<forall>x\<in>T. 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
  3393
proof (cases "a \<in> topspace X")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3394
  case True
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3395
  hence "eventually P (atin_within X a S) \<longleftrightarrow> 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3396
         (\<exists>T. openin X T \<and> a \<in> T \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3397
          (\<forall>x\<in>T. x \<in> topspace X \<and> 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
  3398
    by (simp add: atin_within_def eventually_inf_principal eventually_nhdsin)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3399
  also have "\<dots> \<longleftrightarrow> (\<exists>T. openin X T \<and> a \<in> T \<and> (\<forall>x\<in>T. 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
  3400
    using openin_subset by (intro ex_cong) auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3401
  finally show ?thesis by (simp add: True)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3402
qed (simp add: atin_within_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3403
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3404
lemma eventually_within_imp:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3405
   "eventually P (atin_within X a S) \<longleftrightarrow> eventually (\<lambda>x. x \<in> S \<longrightarrow> P x) (atin X a)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3406
  by (auto simp add: eventually_atin_within eventually_atin)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3407
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3408
lemma limit_within_subset:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3409
   "\<lbrakk>limitin X f l (atin_within Y a S); T \<subseteq> S\<rbrakk> \<Longrightarrow> limitin X f l (atin_within Y a T)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3410
  by (smt (verit) eventually_atin_within limitin_def subset_eq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  3411
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3412
lemma atin_subtopology_within:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3413
  assumes "a \<in> S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3414
  shows "atin (subtopology X S) a = atin_within X a S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3415
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3416
  have "eventually P (atin (subtopology X S) a) \<longleftrightarrow> eventually P (atin_within X a S)" for P
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3417
    unfolding eventually_atin eventually_atin_within openin_subtopology
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3418
    using assms by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3419
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3420
    by (meson le_filter_def order.eq_iff)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3421
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3422
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3423
lemma limit_continuous_map_within:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3424
   "\<lbrakk>continuous_map (subtopology X S) Y f; a \<in> S; a \<in> topspace X\<rbrakk>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3425
    \<Longrightarrow> limitin Y f (f a) (atin_within X a S)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3426
  by (metis Int_iff atin_subtopology_within continuous_map_atin topspace_subtopology)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3427
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3428
lemma atin_subtopology_within_if:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3429
  shows "atin (subtopology X S) a = (if a \<in> S then atin_within X a S else bot)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3430
  by (simp add: atin_subtopology_within)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3431
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3432
lemma trivial_limit_atpointof_within:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3433
   "trivial_limit(atin_within X a S) \<longleftrightarrow>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3434
        (a \<notin> X derived_set_of S)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3435
  by (auto simp: trivial_limit_def eventually_atin_within in_derived_set_of)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3436
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3437
lemma 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
  3438
   "a \<in> X derived_set_of S \<longleftrightarrow> \<not> trivial_limit(atin_within X a S)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3439
  by (simp add: trivial_limit_atpointof_within)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3440
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3441
    
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3442
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
  3443
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3444
context Metric_space
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3445
begin
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3446
  
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3447
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
  3448
    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
  3449
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3450
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
  3451
  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
  3452
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3453
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
  3454
   "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
  3455
    (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
  3456
proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3457
  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
  3458
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
  3459
  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
  3460
next
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3461
  assume R: ?rhs 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3462
  show ?lhs
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3463
  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
  3464
    case True
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3465
    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
  3466
      using R by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3467
    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
  3468
      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
  3469
    then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3470
      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
  3471
  next
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3472
    case False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3473
    with R show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3474
      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
  3475
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3476
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3477
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3478
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3479
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
  3480
  assumes 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3481
    "(\<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
  3482
          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
  3483
      \<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
  3484
  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
  3485
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3486
  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
  3487
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3488
    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
  3489
    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
  3490
    proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3491
      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
  3492
        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
  3493
      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
  3494
        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
  3495
        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
  3496
      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
  3497
        by metis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3498
      show thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3499
        proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3500
          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
  3501
            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
  3502
          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
  3503
            by auto 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3504
        qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3505
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3506
    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
  3507
      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
  3508
    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
  3509
      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
  3510
    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
  3511
      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
  3512
    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
  3513
    proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3514
      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
  3515
        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
  3516
      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
  3517
        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
  3518
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3519
    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
  3520
      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
  3521
    show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3522
      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
  3523
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3524
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3525
    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
  3526
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3527
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3528
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3529
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
  3530
  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
  3531
    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
  3532
    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
  3533
  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
  3534
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3535
  have "a \<in> M"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3536
    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
  3537
  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
  3538
    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
  3539
    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
  3540
  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
  3541
    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
  3542
  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
  3543
    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
  3544
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3545
    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
  3546
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3547
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3548
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
  3549
     "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
  3550
        (\<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
  3551
            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
  3552
            \<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
  3553
  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
  3554
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3555
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
  3556
     "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
  3557
        (\<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
  3558
            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
  3559
            \<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
  3560
  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
  3561
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3562
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
  3563
     "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
  3564
        (\<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
  3565
            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
  3566
            \<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
  3567
  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
  3568
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3569
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3570
lemma eventually_atin_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3571
   "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
  3572
    (\<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
  3573
         \<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
  3574
  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
  3575
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3576
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
  3577
   "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
  3578
    (\<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
  3579
        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
  3580
        \<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
  3581
  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
  3582
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3583
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
  3584
   "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
  3585
    (\<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
  3586
         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
  3587
        \<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
  3588
  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
  3589
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3590
end
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3591
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3592
context Metric_space12
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3593
begin
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3594
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3595
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
  3596
  "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
  3597
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3598
     (\<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
  3599
          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
  3600
          \<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
  3601
    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
  3602
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3603
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
  3604
  "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
  3605
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3606
     (\<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
  3607
          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
  3608
          \<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
  3609
    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
  3610
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3611
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
  3612
  "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
  3613
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3614
     (\<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
  3615
          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
  3616
          \<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
  3617
    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
  3618
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3619
lemma limit_atin_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3620
   "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
  3621
        l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3622
        (\<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
  3623
            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
  3624
            \<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
  3625
  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
  3626
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3627
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
  3628
   "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
  3629
        l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3630
        (\<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
  3631
            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
  3632
            \<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
  3633
  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
  3634
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3635
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
  3636
  "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
  3637
     l \<in> M2 \<and>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3638
     (\<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
  3639
          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
  3640
          \<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
  3641
  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
  3642
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3643
end
24b70433c2e8 New HOL Light material on metric spaces and topological spaces
paulson <lp15@cam.ac.uk>
parents: 78093
diff changeset
  3644
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3645
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
  3646
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
  3647
  "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
  3648
     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
  3649
     (\<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
  3650
          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
  3651
          \<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
  3652
  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
  3653
  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
  3654
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3655
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3656
context Metric_space
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3657
begin
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 atin_within_imp_M:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3660
   "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
  3661
  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
  3662
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3663
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
  3664
  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
  3665
  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
  3666
          "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
  3667
  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
  3668
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3669
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
  3670
  "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
  3671
   {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
  3672
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3673
  have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3674
    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
  3675
      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
  3676
      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
  3677
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3678
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3679
    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
  3680
      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
  3681
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3682
      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
  3683
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3684
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3685
    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
  3686
    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
  3687
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3688
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3689
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
  3690
  "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
  3691
   {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
  3692
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3693
  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
  3694
    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
  3695
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3696
    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
  3697
      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
  3698
    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
  3699
    show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3700
    proof (intro conjI exI)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3701
      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
  3702
        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
  3703
      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
  3704
        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
  3705
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3706
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3707
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3708
    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
  3709
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3710
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3711
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
  3712
   "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
  3713
    {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
  3714
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3715
  have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3716
    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
  3717
      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
  3718
      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
  3719
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3720
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3721
    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
  3722
      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
  3723
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3724
      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
  3725
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3726
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3727
    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
  3728
    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
  3729
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3730
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3731
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3732
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
  3733
   "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
  3734
    {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
  3735
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3736
  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
  3737
    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
  3738
    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
  3739
  moreover have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3740
    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
  3741
      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
  3742
      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
  3743
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3744
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3745
    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
  3746
      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
  3747
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3748
      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
  3749
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3750
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3751
    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
  3752
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3753
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3754
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
  3755
   "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
  3756
    {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
  3757
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3758
  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
  3759
    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
  3760
    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
  3761
  moreover have False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3762
    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
  3763
      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
  3764
      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
  3765
    for x \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3766
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3767
    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
  3768
      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
  3769
    then show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3770
      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
  3771
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3772
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3773
    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
  3774
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3775
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3776
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
  3777
   "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
  3778
    {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
  3779
  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
  3780
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3781
lemma closure_of_sequentially:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3782
   "mtopology closure_of S = 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3783
    {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
  3784
  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
  3785
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3786
end (*Metric_space*)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3787
    
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3788
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3789
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
  3790
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3791
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
  3792
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3793
definition Lipschitz_continuous_map 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3794
  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
  3795
      \<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
  3796
        (\<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
  3797
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3798
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
  3799
  "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
  3800
  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
  3801
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3802
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
  3803
   "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
  3804
    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
  3805
        (\<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
  3806
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3807
  have "B * mdist m1 x y \<le> (\<bar>B\<bar> + 1) * mdist m1 x y" "\<bar>B\<bar> + 1 > 0" for x y B
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3808
    by (auto simp add: mult_right_mono)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3809
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3810
    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
  3811
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3812
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3813
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3814
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
  3815
  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
  3816
  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
  3817
  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
  3818
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3819
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
  3820
  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
  3821
  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
  3822
  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
  3823
proof
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3824
  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
  3825
    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
  3826
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
  3827
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3828
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
  3829
   "\<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
  3830
           \<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
  3831
  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
  3832
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3833
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
  3834
   "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
  3835
        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
  3836
  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
  3837
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3838
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
  3839
  "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
  3840
        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
  3841
  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
  3842
  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
  3843
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3844
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
  3845
   "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
  3846
  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
  3847
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3848
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
  3849
  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
  3850
  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
  3851
  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
  3852
proof
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3853
  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
  3854
    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
  3855
  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
  3856
    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
  3857
  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
  3858
    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
  3859
  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
  3860
  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
  3861
    fix x y
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3862
    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
  3863
    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
  3864
      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
  3865
    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
  3866
      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
  3867
    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
  3868
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3869
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3870
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3871
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
  3872
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3873
definition uniformly_continuous_map 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3874
  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
  3875
      \<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
  3876
        (\<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
  3877
                           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
  3878
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3879
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
  3880
  "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
  3881
  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
  3882
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3883
lemma ucmap_A:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3884
  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
  3885
  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
  3886
    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
  3887
  shows "(\<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
  3888
  using assms
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3889
  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
  3890
  apply clarsimp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3891
  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
  3892
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3893
lemma ucmap_B:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3894
  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
  3895
              (\<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
  3896
              \<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
  3897
    and "0 < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3898
    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
  3899
    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
  3900
    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
  3901
  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
  3902
  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
  3903
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3904
lemma ucmap_C: 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3905
  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
  3906
                       ((\<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
  3907
                      \<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
  3908
    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
  3909
  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
  3910
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3911
  {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
  3912
    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
  3913
      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
  3914
      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
  3915
    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
  3916
         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
  3917
      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
  3918
    have False 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3919
      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
  3920
      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
  3921
  }
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3922
  moreover
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3923
  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
  3924
    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
  3925
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3926
    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
  3927
qed
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
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
  3930
  "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
  3931
    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
  3932
    (\<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
  3933
          \<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
  3934
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3935
proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3936
  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
  3937
    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
  3938
  show "?rhs \<Longrightarrow> ?lhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3939
    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
  3940
qed
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
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3943
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
  3944
    "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
  3945
      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
  3946
      (\<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
  3947
            ((\<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
  3948
            \<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
  3949
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3950
proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3951
  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
  3952
    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
  3953
  show "?rhs \<Longrightarrow> ?lhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3954
    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
  3955
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3956
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3957
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3958
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
  3959
   "\<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
  3960
      \<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
  3961
  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
  3962
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3963
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
  3964
  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
  3965
  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
  3966
  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
  3967
proof
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  3968
  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
  3969
    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
  3970
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
  3971
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3972
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
  3973
   "\<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
  3974
           \<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
  3975
  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
  3976
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3977
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
  3978
   "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
  3979
        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
  3980
  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
  3981
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3982
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
  3983
  "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
  3984
        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
  3985
  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
  3986
  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
  3987
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3988
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
  3989
   "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
  3990
  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
  3991
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3992
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
  3993
  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
  3994
  shows "uniformly_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
  3995
  by (smt (verit, ccfv_threshold) comp_apply f g Pi_iff 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
  3996
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  3997
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
  3998
   "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
  3999
  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
  4000
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4001
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
  4002
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
  4003
  "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
  4004
     = uniformly_continuous_on S f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4005
  by (auto simp add: uniformly_continuous_map_def uniformly_continuous_on_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4006
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4007
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
  4008
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4009
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
  4010
 "Cauchy_continuous_map \<equiv>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4011
  \<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
  4012
            \<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
  4013
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4014
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
  4015
  "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
  4016
     = Cauchy_continuous_on S f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4017
  by (auto simp add: Cauchy_continuous_map_def Cauchy_continuous_on_def Cauchy_def Met_TC.subspace Metric_space.MCauchy_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4018
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4019
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
  4020
  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
  4021
  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
  4022
proof clarsimp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4023
  fix x
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4024
  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
  4025
  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
  4026
    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
  4027
  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
  4028
    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
  4029
  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
  4030
    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
  4031
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4032
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4033
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4034
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
  4035
   "\<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
  4036
      \<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
  4037
  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
  4038
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4039
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
  4040
  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
  4041
  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
  4042
  using assms
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4043
  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
  4044
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4045
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
  4046
   "\<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
  4047
           \<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
  4048
  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
  4049
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4050
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
  4051
   "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
  4052
   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
  4053
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4054
  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
  4055
    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
  4056
  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
  4057
    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
  4058
  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
  4059
    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
  4060
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4061
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4062
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
  4063
  "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
  4064
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4065
   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
  4066
    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
  4067
  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
  4068
    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
  4069
  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
  4070
    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
  4071
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4072
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4073
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
  4074
   "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
  4075
  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
  4076
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4077
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
  4078
  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
  4079
  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
  4080
  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
  4081
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4082
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
  4083
  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
  4084
  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
  4085
  proof -
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4086
  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
  4087
    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
  4088
  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
  4089
    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
  4090
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4091
    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
  4092
             and "B>0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4093
      using that assms by (force simp add: Lipschitz_continuous_map_pos)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4094
    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
  4095
      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
  4096
    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
  4097
      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
  4098
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4099
  ultimately show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4100
    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
  4101
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4102
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4103
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
  4104
   "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
  4105
  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
  4106
  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
  4107
  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
  4108
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4109
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
  4110
  assumes "\<epsilon> > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4111
    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
  4112
  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
  4113
  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
  4114
proof (intro strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4115
  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
  4116
    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
  4117
  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
  4118
    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
  4119
  fix \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4120
  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
  4121
  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
  4122
    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
  4123
  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
  4124
    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
  4125
  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
  4126
    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
  4127
  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
  4128
  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
  4129
    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
  4130
      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
  4131
    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
  4132
      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
  4133
    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
  4134
      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
  4135
    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
  4136
      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
  4137
    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
  4138
      unfolding comp_assoc
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4139
      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
  4140
  next
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4141
    fix n
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4142
    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
  4143
      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
  4144
    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
  4145
      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
  4146
    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
  4147
      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
  4148
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4149
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4150
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4151
context Metric_space12
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4152
begin
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4153
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4154
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
  4155
  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
  4156
  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
  4157
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
  4158
  fix x
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4159
  assume "x \<in> M1"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4160
  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
  4161
    unfolding limit_atin_sequentially
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4162
  proof (intro conjI strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4163
    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
  4164
      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
  4165
    fix \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4166
    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
  4167
    then have "M1.MCauchy (\<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
  4168
      by (force simp add: M1.MCauchy_interleaving)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4169
    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
  4170
      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
  4171
    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
  4172
      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
  4173
      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
  4174
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4175
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4176
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4177
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
  4178
  assumes "M1.mcomplete"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4179
    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
  4180
  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
  4181
  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
  4182
proof clarsimp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4183
  fix \<sigma>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4184
  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
  4185
  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
  4186
    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
  4187
  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
  4188
    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
  4189
  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
  4190
    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
  4191
    by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4192
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4193
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4194
end
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4195
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4196
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
  4197
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
  4198
  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
  4199
  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
  4200
  using assms Metric_space12.Cauchy_continuous_imp_continuous_map [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
  4201
  by (auto simp add: mtopology_of_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4202
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4203
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
  4204
  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
  4205
    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
  4206
  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
  4207
  using assms Metric_space12.continuous_imp_Cauchy_continuous_map [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
  4208
  by (auto simp add: mtopology_of_def)
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 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
  4211
   "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
  4212
        \<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
  4213
  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
  4214
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4215
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
  4216
   "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
  4217
     \<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
  4218
  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
  4219
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4220
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
  4221
   "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
  4222
        \<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
  4223
  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
  4224
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4225
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
  4226
  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
  4227
    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
  4228
  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
  4229
  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
  4230
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
  4231
  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
  4232
    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
  4233
  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
  4234
    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
  4235
  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
  4236
    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
  4237
  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
  4238
  assume "\<epsilon> > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4239
    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
  4240
    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
  4241
    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
  4242
  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
  4243
    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
  4244
  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
  4245
    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
  4246
  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
  4247
  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
  4248
    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
  4249
  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
  4250
  have "M1.MCauchy \<eta>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4251
    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
  4252
  proof (intro conjI)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4253
    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
  4254
      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
  4255
    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
  4256
      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
  4257
    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
  4258
      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
  4259
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4260
  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
  4261
    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
  4262
  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
  4263
    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
  4264
    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
  4265
  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
  4266
    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
  4267
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4268
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4269
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
  4270
   "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
  4271
        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
  4272
        \<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
  4273
  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
  4274
                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
  4275
                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
  4276
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4277
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
  4278
   "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
  4279
    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
  4280
  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
  4281
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4282
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
  4283
   "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
  4284
    \<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
  4285
        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
  4286
  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
  4287
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4288
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
  4289
   "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
  4290
    \<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
  4291
  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
  4292
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4293
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
  4294
  "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
  4295
  "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
  4296
  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
  4297
      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
  4298
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4299
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
  4300
   "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
  4301
    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
  4302
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4303
proof 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4304
  show "?lhs \<Longrightarrow> ?rhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4305
    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
  4306
  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
  4307
    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
  4308
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4309
    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
  4310
      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
  4311
      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
  4312
    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
  4313
      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
  4314
      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
  4315
    show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4316
      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
  4317
    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
  4318
      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
  4319
        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
  4320
      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
  4321
        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
  4322
      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
  4323
        by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4324
      show "B1+B2 > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4325
        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
  4326
      fix x y
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4327
      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
  4328
      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
  4329
        unfolding mdist_prod_metric
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4330
        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
  4331
      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
  4332
        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
  4333
      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
  4334
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4335
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4336
  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
  4337
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4338
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4339
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4340
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
  4341
   "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
  4342
    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
  4343
   (is "?lhs \<longleftrightarrow> ?rhs")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4344
proof 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4345
  show "?lhs \<Longrightarrow> ?rhs"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4346
    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
  4347
  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
  4348
    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
  4349
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4350
    show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4351
      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
  4352
    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
  4353
      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
  4354
        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
  4355
      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
  4356
        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
  4357
      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
  4358
        by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4359
      fix \<epsilon>:: real
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4360
      assume "\<epsilon> > 0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4361
      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
  4362
        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
  4363
        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
  4364
      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
  4365
        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
  4366
        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
  4367
      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
  4368
      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
  4369
        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
  4370
          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
  4371
        fix x y
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4372
        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
  4373
        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
  4374
          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
  4375
        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
  4376
          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
  4377
          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
  4378
        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
  4379
          using * by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4380
        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
  4381
          by simp
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
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4384
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4385
  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
  4386
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4387
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4388
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4389
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
  4390
   "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
  4391
  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
  4392
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4393
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
  4394
   "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
  4395
        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
  4396
  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
  4397
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4398
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
  4399
   "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
  4400
        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
  4401
  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
  4402
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4403
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
  4404
   "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
  4405
        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
  4406
  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
  4407
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4408
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
  4409
  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
  4410
  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
  4411
proof -
78248
740b23f1138a EXPERIMENTAL replacement of f ` A <= B by f : A -> B in Analysis
paulson <lp15@cam.ac.uk>
parents: 78200
diff changeset
  4412
  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
  4413
    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
  4414
    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
  4415
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4416
    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
  4417
  proof
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4418
    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
  4419
      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
  4420
    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
  4421
      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
  4422
    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
  4423
      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
  4424
    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
  4425
      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
  4426
    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
  4427
      by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4428
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4429
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4430
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4431
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
  4432
  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
  4433
  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
  4434
  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
  4435
proof (intro conjI strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4436
  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
  4437
    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
  4438
  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
  4439
    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
  4440
  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
  4441
  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
  4442
  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
  4443
    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
  4444
  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
  4445
    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
  4446
  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
  4447
    by fastforce
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4448
  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
  4449
    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
  4450
  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
  4451
    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
  4452
  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
  4453
    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
  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 Lipschitz_coefficient_pos:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4457
  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
  4458
    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
  4459
    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
  4460
            \<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
  4461
  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
  4462
  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
  4463
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4464
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
  4465
   "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
  4466
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4467
  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
  4468
       \<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
  4469
    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
  4470
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4471
    by (fastforce simp add: Lipschitz_continuous_map_def prod_dist_def dist_real_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4472
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4473
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4474
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
  4475
  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
  4476
    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
  4477
  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
  4478
    (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
  4479
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4480
  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
  4481
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4482
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4483
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4484
  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
  4485
    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
  4486
      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
  4487
    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
  4488
      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
  4489
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4490
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4491
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4492
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
  4493
  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
  4494
    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
  4495
  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
  4496
    (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
  4497
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4498
  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
  4499
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4500
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4501
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4502
  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
  4503
    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
  4504
      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
  4505
    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
  4506
      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
  4507
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4508
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4509
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4510
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
  4511
  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
  4512
    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
  4513
  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
  4514
    (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
  4515
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4516
  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
  4517
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4518
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4519
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4520
  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
  4521
    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
  4522
      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
  4523
    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
  4524
      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
  4525
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4526
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4527
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4528
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
  4529
    "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
  4530
  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
  4531
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4532
lemma continuous_map_metric:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4533
   "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
  4534
      (\<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
  4535
  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
  4536
  by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4537
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4538
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
  4539
  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
  4540
  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
  4541
    (is "continuous_map _ _ ?h")
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4542
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4543
  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
  4544
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4545
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4546
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4547
    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
  4548
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4549
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4550
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
  4551
  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
  4552
      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
  4553
  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
  4554
    (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
  4555
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4556
  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
  4557
    by force
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4558
  show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4559
    unfolding eq
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4560
  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
  4561
    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
  4562
      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
  4563
  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
  4564
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4565
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4566
lemma continuous_on_mdist:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4567
   "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
  4568
  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
  4569
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4570
subsection \<open>Isometries\<close>
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4571
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4572
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
  4573
  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
  4574
  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
  4575
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4576
  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
  4577
    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
  4578
  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
  4579
    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
  4580
  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
  4581
    unfolding homeomorphic_maps_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4582
  proof (intro conjI; clarsimp)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4583
    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
  4584
    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
  4585
      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
  4586
        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
  4587
    qed simp
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4588
    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
  4589
      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
  4590
    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
  4591
      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
  4592
        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
  4593
    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
  4594
    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
  4595
      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
  4596
    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
  4597
      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
  4598
    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
  4599
       by simp
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4600
  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
  4601
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4602
    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
  4603
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4604
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  4605
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
  4606
  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
  4607
  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
  4608
  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
  4609
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4610
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
  4611
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4612
definition (in Metric_space) capped_dist where
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4613
  "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
  4614
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4615
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
  4616
proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4617
  fix x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4618
  assume "x \<in> M" "y \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4619
  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
  4620
    by (smt (verit, best) capped_dist_def zero)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4621
  fix z 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4622
  assume "z \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4623
  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
  4624
    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
  4625
    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
  4626
qed (use capped_dist_def commute in auto)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4627
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4628
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4629
definition capped_metric where
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4630
  "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
  4631
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4632
lemma capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4633
  "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
  4634
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4635
  interpret Metric_space "mspace m" "mdist m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4636
    by (simp add: Metric_space_mspace_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4637
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4638
    by (auto simp: capped_metric_def capped_dist_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4639
qed
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 capped_metric_mspace [simp]:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4642
  "mspace (capped_metric \<delta> m) = mspace m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4643
  apply (simp add: capped_metric not_le)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4644
  by (smt (verit, ccfv_threshold) Metric_space.mspace_metric Metric_space_def Metric_space_mspace_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4645
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4646
lemma capped_metric_mdist:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4647
  "mdist (capped_metric \<delta> m) = (\<lambda>x y. if \<delta> \<le> 0 then mdist m x y else min \<delta> (mdist m x y))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4648
  apply (simp add: capped_metric not_le)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4649
  by (smt (verit, del_insts) Metric_space.mdist_metric Metric_space_def Metric_space_mspace_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4650
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4651
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
  4652
  by (simp add: capped_metric_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4653
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4654
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
  4655
  by (simp add: capped_metric_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4656
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4657
lemma mball_of_capped_metric [simp]: 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4658
  assumes "x \<in> mspace m" "r > \<delta>" "\<delta> > 0" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4659
  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
  4660
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4661
  interpret Metric_space "mspace m" "mdist m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4662
    by (simp add: Metric_space_mspace_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4663
  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
  4664
    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
  4665
  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
  4666
    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
  4667
  ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4668
    by (simp add: mball_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4669
qed
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 Metric_space_capped_dist[simp]:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4672
  "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
  4673
  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
  4674
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4675
lemma mtopology_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4676
  "mtopology_of(capped_metric \<delta> m) = mtopology_of m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4677
proof (cases "\<delta> > 0")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4678
  case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4679
  interpret Metric_space "mspace m" "mdist m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4680
    by (simp add: Metric_space_mspace_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4681
  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
  4682
    by (metis Metric_space_mspace_mdist capped_metric_mspace)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4683
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4684
    unfolding topology_eq
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4685
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4686
    fix S
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4687
    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
  4688
    proof (cases "S \<subseteq> mspace m")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4689
      case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4690
      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
  4691
        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
  4692
      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
  4693
      proof (intro exI conjI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4694
        show "min (\<delta>/2) r > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4695
          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
  4696
        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
  4697
          using that
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4698
          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
  4699
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4700
      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
  4701
        by (meson subset_trans that)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4702
      then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4703
        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
  4704
    qed (simp add: openin_closedin_eq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4705
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4706
qed (simp add: capped_metric)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4707
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4708
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
  4709
lemma (in Metric_space) mtopology_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4710
  "Metric_space.mtopology M (capped_dist \<delta>) = mtopology"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4711
  using mtopology_capped_metric [of \<delta> "metric(M,d)"]
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4712
  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
  4713
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4714
lemma (in Metric_space) MCauchy_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4715
  "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
  4716
proof (cases "\<delta> > 0")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4717
  case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4718
  interpret Cap: Metric_space "M" "capped_dist \<delta>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4719
    by (simp add: capped_dist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4720
  show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4721
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4722
    assume \<sigma>: "Cap.MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4723
    show "MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4724
      unfolding MCauchy_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4725
    proof (intro conjI strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4726
      show "range \<sigma> \<subseteq> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4727
        using Cap.MCauchy_def \<sigma> by presburger
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4728
      fix \<epsilon> :: real
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4729
      assume "\<epsilon> > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4730
      with True \<sigma>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4731
      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
  4732
        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
  4733
      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
  4734
        by (force simp: capped_dist_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4735
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4736
  next
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4737
    assume "MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4738
    then show "Cap.MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4739
      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
  4740
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4741
qed (simp add: capped_dist_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4742
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 (in Metric_space) mcomplete_capped_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4745
   "Metric_space.mcomplete M (capped_dist \<delta>) \<longleftrightarrow> mcomplete"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4746
  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
  4747
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4748
lemma bounded_equivalent_metric:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4749
  assumes "\<delta> > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4750
  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
  4751
proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4752
  let ?m = "capped_metric (\<delta>/2) m"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4753
  fix x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4754
  show "mdist ?m x y < \<delta>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4755
    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
  4756
qed (auto simp: mtopology_capped_metric)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4757
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4758
text \<open>A technical lemma needed below\<close>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4759
lemma Sup_metric_cartesian_product:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4760
  fixes I m
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4761
  defines "S \<equiv> PiE I (mspace \<circ> m)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4762
  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
  4763
  defines "m' \<equiv> metric(S,D)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4764
  assumes "I \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4765
    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
  4766
  shows "Metric_space S D" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4767
    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
  4768
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4769
  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
  4770
    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
  4771
    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
  4772
  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
  4773
    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
  4774
    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
  4775
  show "Metric_space S D"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4776
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4777
    fix x y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4778
    show D0: "0 \<le> D x y"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4779
      using bdd  
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4780
      apply (simp add: D_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4781
      by (meson \<open>I \<noteq> {}\<close> cSUP_upper dual_order.trans ex_in_conv mdist_nonneg)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4782
    show "D x y = D y x"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4783
      by (simp add: D_def mdist_commute)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4784
    assume "x \<in> S" and "y \<in> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4785
    then
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4786
    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
  4787
      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
  4788
    also have "... \<longleftrightarrow> x = y"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4789
      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
  4790
    finally show "(D x y = 0) \<longleftrightarrow> (x = y)" .
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4791
    fix z
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4792
    assume "z \<in> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4793
    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
  4794
    proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4795
      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
  4796
        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
  4797
      also have "... \<le> D x y + D y z"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4798
        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
  4799
      finally show ?thesis .
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4800
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4801
    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
  4802
      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
  4803
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4804
  then interpret Metric_space S D .
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4805
  show ?the2
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4806
  proof (intro strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4807
    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
  4808
      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
  4809
      using that by (simp add: D_iff m'_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4810
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4811
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4812
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4813
lemma metrizable_topology_A:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4814
  assumes "metrizable_space (product_topology X I)"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  4815
  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
  4816
    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
  4817
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4818
lemma metrizable_topology_C:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4819
  assumes "completely_metrizable_space (product_topology X I)"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  4820
  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
  4821
    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
  4822
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4823
lemma metrizable_topology_B:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4824
  fixes a X I
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4825
  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
  4826
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4827
    and met: "metrizable_space (product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4828
    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
  4829
  shows  "countable L"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4830
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4831
  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
  4832
    unfolding L_def by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4833
  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
  4834
    by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4835
  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
  4836
    using assms(2) by fastforce
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4837
  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
  4838
  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
  4839
  have p: "p \<in> topspace(product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4840
    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
  4841
  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
  4842
    by (auto simp: L_def q_def \<phi>)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4843
  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
  4844
  proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4845
    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
  4846
      using U by (force simp: openin_product_topology_alt)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4847
    moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4848
    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
  4849
      using that V q
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4850
      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
  4851
    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
  4852
      by (force simp: L_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4853
    ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4854
      by (meson finite_subset)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4855
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4856
  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
  4857
    using met metrizable_space_def by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4858
  then interpret Metric_space M d
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4859
    by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4860
  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
  4861
  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
  4862
    using XI p  by (intro fin; force)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4863
  then have "countable C"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4864
    unfolding C_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4865
    by (meson countableI_type countable_UN countable_finite)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4866
  moreover have "L \<subseteq> C"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4867
  proof (clarsimp simp: C_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4868
    fix i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4869
    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
  4870
    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
  4871
      using reals_Archimedean [of "d p (q i)"]
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4872
      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
  4873
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4874
  ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4875
    using countable_subset by blast
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
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4878
lemma metrizable_topology_DD:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4879
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4880
    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
  4881
    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
  4882
  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
  4883
                    "(\<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
  4884
proof (cases "I = {}")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4885
  case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4886
  then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4887
    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
  4888
next
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4889
  case False
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4890
  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
  4891
    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
  4892
  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
  4893
    by (metis inv_into_f_f)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4894
  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
  4895
  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
  4896
    by (simp add: cm_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4897
  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
  4898
    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
  4899
  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
  4900
    by (meson bdd_above.I2)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4901
  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
  4902
  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
  4903
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4904
  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
  4905
    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
  4906
  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
  4907
  have "Metric_space M d" 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4908
    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
  4909
    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
  4910
  then interpret Metric_space M d 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4911
    by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4912
  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
  4913
    using "*" that by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4914
  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
  4915
    using m by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4916
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4917
  define m' where "m' = metric (M,d)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4918
  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
  4919
  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
  4920
    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
  4921
  proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4922
    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
  4923
      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
  4924
    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
  4925
      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
  4926
    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
  4927
      using r dense by (smt (verit, ccfv_threshold))
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4928
    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
  4929
    show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4930
    proof (intro exI conjI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4931
      obtain n where n: "real n * R > 1"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4932
        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
  4933
      have "finite (nk ` (C \<inter> {..n}))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4934
        by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4935
      moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4936
      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
  4937
        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
  4938
          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
  4939
      proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4940
        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
  4941
          by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4942
        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
  4943
          by (metis mball_of_def neq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4944
        then have "\<nexists>a. topspace (X i) \<subseteq> {a}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4945
          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
  4946
        then have "i \<in> nk ` C"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4947
          using nk \<open>i \<in> I\<close> by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4948
        then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4949
          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
  4950
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4951
      then have "J U \<subseteq> nk ` (C \<inter> {..n})"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4952
        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
  4953
      ultimately show "finite (J U)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4954
        using finite_subset by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4955
      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
  4956
        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
  4957
      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
  4958
        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
  4959
      moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4960
      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
  4961
        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
  4962
      ultimately show "x \<in> Pi\<^sub>E I U"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4963
        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
  4964
      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
  4965
      proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4966
        fix y
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4967
        assume y: "y \<in> Pi\<^sub>E I U"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4968
        then have "y \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4969
          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
  4970
        moreover 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4971
        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
  4972
          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
  4973
        then have "d z y \<le> R"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4974
          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
  4975
        ultimately show "y \<in> mball z r"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4976
          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
  4977
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4978
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4979
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4980
  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
  4981
    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
  4982
      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
  4983
      and "x \<in> S" for U S x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4984
  proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4985
    { fix i
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4986
      assume "i \<in> J U"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4987
      then have "i \<in> I"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4988
        by (auto simp: J_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4989
      then have "openin (mtopology_of (m i)) (U i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4990
        using U m by force
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4991
      then have "openin (mtopology_of (cm i)) (U i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4992
        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
  4993
      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
  4994
        using x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4995
        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
  4996
    }
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4997
    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
  4998
      by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  4999
    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
  5000
    show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5001
    proof (intro exI conjI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5002
      show "r > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5003
        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
  5004
      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
  5005
        by (auto simp: r_def that(1))
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5006
      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
  5007
      proof (cases "i \<in> J U")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5008
        case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5009
        with r show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5010
          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
  5011
      next
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5012
        case False
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5013
        then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5014
          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
  5015
      qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5016
      show "mball x r \<subseteq> S"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5017
        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
  5018
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5019
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5020
  have 3: "x \<in> M"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5021
    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
  5022
      and "x \<in> S" for S x
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5023
    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
  5024
  show thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5025
  proof
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5026
    show "Metric_space M d"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5027
      using Metric_space_axioms by blast
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5028
    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
  5029
      unfolding topology_eq openin_mtopology openin_product_topology_alt  
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5030
      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
  5031
    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
  5032
      unfolding mcomplete_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5033
    proof (intro strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5034
      fix \<sigma>
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5035
      assume \<sigma>: "MCauchy \<sigma>"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5036
      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
  5037
      proof (cases "i \<in> I")
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5038
        case True
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5039
        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
  5040
          by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5041
        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
  5042
          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
  5043
        moreover have "MI.MCauchy (\<lambda>n. \<sigma> n i)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5044
          unfolding MI.MCauchy_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5045
        proof (intro conjI strip)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5046
          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
  5047
            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
  5048
          fix \<epsilon>::real
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5049
          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
  5050
          assume "\<epsilon> > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5051
          then have "r > 0"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5052
            by (simp add: r_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5053
          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
  5054
            using \<sigma> unfolding MCauchy_def by meson
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5055
          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
  5056
          proof (intro strip exI)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5057
            fix n n'
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5058
            assume "N \<le> n" and "N \<le> n'"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5059
            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
  5060
              using *
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5061
              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
  5062
            then
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5063
            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
  5064
              unfolding cm_def r_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5065
              by (smt (verit, ccfv_SIG) capped_metric_mdist)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5066
          qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5067
        qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5068
        ultimately show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5069
          by (simp add: m mtopology_of_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5070
      qed auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5071
      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
  5072
        by metis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5073
      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
  5074
        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
  5075
        apply (simp add: MCauchy_def limitin_componentwise flip: eq)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5076
        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
  5077
    qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5078
  qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5079
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5080
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5081
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5082
lemma metrizable_topology_D:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5083
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5084
    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
  5085
    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
  5086
  shows "metrizable_space (product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5087
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5088
  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
  5089
    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
  5090
  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
  5091
    by metis 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5092
  then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5093
    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
  5094
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5095
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5096
lemma metrizable_topology_E:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5097
  assumes "topspace (product_topology X I) \<noteq> {}"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5098
    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
  5099
    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
  5100
  shows "completely_metrizable_space (product_topology X I)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5101
proof -
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5102
  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
  5103
    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
  5104
    by metis 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5105
  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
  5106
    by metis 
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5107
  then show ?thesis
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5108
    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
  5109
    by (metis (full_types) completely_metrizable_space_def)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5110
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5111
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5112
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  5113
proposition metrizable_space_product_topology:
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5114
  "metrizable_space (product_topology X I) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5115
        (product_topology X I) = trivial_topology \<or>
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5116
        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
  5117
        (\<forall>i \<in> I. metrizable_space (X i))"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5118
  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
  5119
78320
eb9a9690b8f5 cosmetic improvements, new lemmas, especially more uses of function space
paulson <lp15@cam.ac.uk>
parents: 78283
diff changeset
  5120
proposition completely_metrizable_space_product_topology:
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5121
  "completely_metrizable_space (product_topology X I) \<longleftrightarrow>
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5122
        (product_topology X I) = trivial_topology \<or>
78200
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5123
        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
  5124
        (\<forall>i \<in> I. completely_metrizable_space (X i))"
78336
6bae28577994 trivial_topology
paulson <lp15@cam.ac.uk>
parents: 78320
diff changeset
  5125
  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
  5126
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5127
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5128
lemma completely_metrizable_Euclidean_space:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5129
  "completely_metrizable_space(Euclidean_space n)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5130
  unfolding Euclidean_space_def
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5131
proof (rule completely_metrizable_space_closedin)
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5132
  show "completely_metrizable_space (powertop_real (UNIV::nat set))"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5133
    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
  5134
  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
  5135
    using closedin_Euclidean_space topspace_Euclidean_space by auto
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5136
qed
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5137
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5138
lemma metrizable_Euclidean_space:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5139
   "metrizable_space(Euclidean_space n)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5140
  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
  5141
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5142
lemma locally_connected_Euclidean_space:
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5143
   "locally_connected_space(Euclidean_space n)"
264f2b69d09c New and generalised analysis lemmas
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  5144
  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
  5145
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  5146
end
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78127
diff changeset
  5147