src/HOL/Analysis/Elementary_Metric_Spaces.thy
author wenzelm
Tue, 15 Apr 2025 16:53:07 +0200
changeset 82545 0d955ab17466
parent 82486 451f428c5814
child 82518 da14e77a48b2
permissions -rw-r--r--
misc tuning and clarification;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     1
(*  Author:     L C Paulson, University of Cambridge
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     2
    Author:     Amine Chaieb, University of Cambridge
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     3
    Author:     Robert Himmelmann, TU Muenchen
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     4
    Author:     Brian Huffman, Portland State University
80133
e414bcc5a39e Acknowledgement of Ata Keskin for his Martingales material
paulson <lp15@cam.ac.uk>
parents: 79945
diff changeset
     5
    Author:     Ata Keskin, TU Muenchen
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     6
*)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     7
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
     8
chapter \<open>Elementary Metric Spaces\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     9
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    10
theory Elementary_Metric_Spaces
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    11
  imports
69616
d18dc9c5c456 split off theory combining Elementary_Topology and Abstract_Topology
immler
parents: 69615
diff changeset
    12
    Abstract_Topology_2
70951
678b2abe9f7d decision procedure for metric spaces, implemented by Maximilian Schäffeler
immler
parents: 70817
diff changeset
    13
    Metric_Arith
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    14
begin
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    15
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
    16
section \<open>Open and closed balls\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    17
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
    18
definition\<^marker>\<open>tag important\<close> ball :: "'a::metric_space \<Rightarrow> real \<Rightarrow> 'a set"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    19
  where "ball x e = {y. dist x y < e}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    20
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
    21
definition\<^marker>\<open>tag important\<close> cball :: "'a::metric_space \<Rightarrow> real \<Rightarrow> 'a set"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    22
  where "cball x e = {y. dist x y \<le> e}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    23
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
    24
definition\<^marker>\<open>tag important\<close> sphere :: "'a::metric_space \<Rightarrow> real \<Rightarrow> 'a set"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    25
  where "sphere x e = {y. dist x y = e}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    26
70951
678b2abe9f7d decision procedure for metric spaces, implemented by Maximilian Schäffeler
immler
parents: 70817
diff changeset
    27
lemma mem_ball [simp, metric_unfold]: "y \<in> ball x e \<longleftrightarrow> dist x y < e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    28
  by (simp add: ball_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    29
70951
678b2abe9f7d decision procedure for metric spaces, implemented by Maximilian Schäffeler
immler
parents: 70817
diff changeset
    30
lemma mem_cball [simp, metric_unfold]: "y \<in> cball x e \<longleftrightarrow> dist x y \<le> e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    31
  by (simp add: cball_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    32
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    33
lemma mem_sphere [simp]: "y \<in> sphere x e \<longleftrightarrow> dist x y = e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    34
  by (simp add: sphere_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    35
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    36
lemma ball_trivial [simp]: "ball x 0 = {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
    37
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    38
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    39
lemma cball_trivial [simp]: "cball x 0 = {x}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
    40
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    41
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    42
lemma sphere_trivial [simp]: "sphere x 0 = {x}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
    43
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    44
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    45
lemma disjoint_ballI: "dist x y \<ge> r+s \<Longrightarrow> ball x r \<inter> ball y s = {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    46
  using dist_triangle_less_add not_le by fastforce
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    47
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    48
lemma disjoint_cballI: "dist x y > r + s \<Longrightarrow> cball x r \<inter> cball y s = {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    49
  by (metis add_mono disjoint_iff_not_equal dist_triangle2 dual_order.trans leD mem_cball)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    50
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    51
lemma sphere_empty [simp]: "r < 0 \<Longrightarrow> sphere a r = {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    52
  for a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    53
  by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    54
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    55
lemma centre_in_ball [simp]: "x \<in> ball x e \<longleftrightarrow> 0 < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    56
  by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    57
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    58
lemma centre_in_cball [simp]: "x \<in> cball x e \<longleftrightarrow> 0 \<le> e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    59
  by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    60
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    61
lemma ball_subset_cball [simp, intro]: "ball x e \<subseteq> cball x e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    62
  by (simp add: subset_eq)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    63
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    64
lemma mem_ball_imp_mem_cball: "x \<in> ball y e \<Longrightarrow> x \<in> cball y e"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    65
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    66
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    67
lemma sphere_cball [simp,intro]: "sphere z r \<subseteq> cball z r"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    68
  by force
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    69
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    70
lemma cball_diff_sphere: "cball a r - sphere a r = ball a r"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    71
  by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    72
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    73
lemma subset_ball[intro]: "d \<le> e \<Longrightarrow> ball x d \<subseteq> ball x e"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    74
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    75
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    76
lemma subset_cball[intro]: "d \<le> e \<Longrightarrow> cball x d \<subseteq> cball x e"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    77
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    78
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    79
lemma mem_ball_leI: "x \<in> ball y e \<Longrightarrow> e \<le> f \<Longrightarrow> x \<in> ball y f"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    80
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    81
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    82
lemma mem_cball_leI: "x \<in> cball y e \<Longrightarrow> e \<le> f \<Longrightarrow> x \<in> cball y f"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    83
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    84
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    85
lemma cball_trans: "y \<in> cball z b \<Longrightarrow> x \<in> cball y a \<Longrightarrow> x \<in> cball z (b + a)"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
    86
  by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    87
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    88
lemma ball_max_Un: "ball a (max r s) = ball a r \<union> ball a s"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    89
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    90
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    91
lemma ball_min_Int: "ball a (min r s) = ball a r \<inter> ball a s"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    92
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    93
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    94
lemma cball_max_Un: "cball a (max r s) = cball a r \<union> cball a s"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    95
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    96
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    97
lemma cball_min_Int: "cball a (min r s) = cball a r \<inter> cball a s"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
    98
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    99
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   100
lemma cball_diff_eq_sphere: "cball a r - ball a r =  sphere a r"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   101
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   102
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   103
lemma open_ball [intro, simp]: "open (ball x e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   104
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   105
  have "open (dist x -` {..<e})"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   106
    by (intro open_vimage open_lessThan continuous_intros)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   107
  also have "dist x -` {..<e} = ball x e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   108
    by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   109
  finally show ?thesis .
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   110
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   111
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   112
lemma open_contains_ball: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0. ball x e \<subseteq> S)"
71633
07bec530f02e cleaned proofs
nipkow
parents: 71198
diff changeset
   113
  by (simp add: open_dist subset_eq Ball_def dist_commute)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   114
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   115
lemma openI [intro?]: "(\<And>x. x\<in>S \<Longrightarrow> \<exists>e>0. ball x e \<subseteq> S) \<Longrightarrow> open S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   116
  by (auto simp: open_contains_ball)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   117
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   118
lemma openE[elim?]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   119
  assumes "open S" "x\<in>S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   120
  obtains e where "e>0" "ball x e \<subseteq> S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   121
  using assms unfolding open_contains_ball by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   122
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   123
lemma open_contains_ball_eq: "open S \<Longrightarrow> x\<in>S \<longleftrightarrow> (\<exists>e>0. ball x e \<subseteq> S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   124
  by (metis open_contains_ball subset_eq centre_in_ball)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   125
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   126
lemma ball_eq_empty[simp]: "ball x e = {} \<longleftrightarrow> e \<le> 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   127
  unfolding mem_ball set_eq_iff
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   128
  by (simp add: not_less) metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   129
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   130
lemma ball_empty: "e \<le> 0 \<Longrightarrow> ball x e = {}" 
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   131
  by simp
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   132
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   133
lemma closed_cball [iff]: "closed (cball x e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   134
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   135
  have "closed (dist x -` {..e})"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   136
    by (intro closed_vimage closed_atMost continuous_intros)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   137
  also have "dist x -` {..e} = cball x e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   138
    by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   139
  finally show ?thesis .
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   140
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   141
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   142
lemma open_contains_cball: "open S \<longleftrightarrow> (\<forall>x\<in>S. \<exists>e>0.  cball x e \<subseteq> S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   143
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   144
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   145
    fix x and e::real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   146
    assume "x\<in>S" "e>0" "ball x e \<subseteq> S"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   147
    then have "\<exists>d>0. cball x d \<subseteq> S"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   148
      unfolding subset_eq by (intro exI [where x="e/2"], auto)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   149
  }
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   150
  then show ?thesis
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   151
    unfolding open_contains_ball by force
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   152
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   153
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   154
lemma open_contains_cball_eq: "open S \<Longrightarrow> (\<forall>x. x \<in> S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   155
  by (metis open_contains_cball subset_eq order_less_imp_le centre_in_cball)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   156
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   157
lemma eventually_nhds_ball: "d > 0 \<Longrightarrow> eventually (\<lambda>x. x \<in> ball z d) (nhds z)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   158
  by (rule eventually_nhds_in_open) simp_all
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   159
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   160
lemma eventually_at_ball: "d > 0 \<Longrightarrow> eventually (\<lambda>t. t \<in> ball z d \<and> t \<in> A) (at z within A)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   161
  unfolding eventually_at by (intro exI[of _ d]) (simp_all add: dist_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   162
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   163
lemma eventually_at_ball': "d > 0 \<Longrightarrow> eventually (\<lambda>t. t \<in> ball z d \<and> t \<noteq> z \<and> t \<in> A) (at z within A)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   164
  unfolding eventually_at by (intro exI[of _ d]) (simp_all add: dist_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   165
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   166
lemma at_within_ball: "e > 0 \<Longrightarrow> dist x y < e \<Longrightarrow> at y within ball x e = at y"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   167
  by (subst at_within_open) auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   168
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   169
lemma atLeastAtMost_eq_cball:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   170
  fixes a b::real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   171
  shows "{a .. b} = cball ((a + b)/2) ((b - a)/2)"
71174
nipkow
parents: 71028
diff changeset
   172
  by (auto simp: dist_real_def field_simps)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   173
71028
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   174
lemma cball_eq_atLeastAtMost:
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   175
  fixes a b::real
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   176
  shows "cball a b = {a - b .. a + b}"
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   177
  by (auto simp: dist_real_def)
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   178
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   179
lemma greaterThanLessThan_eq_ball:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   180
  fixes a b::real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   181
  shows "{a <..< b} = ball ((a + b)/2) ((b - a)/2)"
71174
nipkow
parents: 71028
diff changeset
   182
  by (auto simp: dist_real_def field_simps)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   183
71028
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   184
lemma ball_eq_greaterThanLessThan:
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   185
  fixes a b::real
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   186
  shows "ball a b = {a - b <..< a + b}"
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   187
  by (auto simp: dist_real_def)
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   188
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   189
lemma interior_ball [simp]: "interior (ball x e) = ball x e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   190
  by (simp add: interior_open)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   191
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   192
lemma cball_eq_empty [simp]: "cball x e = {} \<longleftrightarrow> e < 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   193
  by (smt (verit, best) Diff_empty ball_eq_empty cball_diff_sphere centre_in_ball centre_in_cball sphere_empty)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   194
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   195
lemma cball_empty [simp]: "e < 0 \<Longrightarrow> cball x e = {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   196
  by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   197
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   198
lemma cball_sing:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   199
  fixes x :: "'a::metric_space"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   200
  shows "e = 0 \<Longrightarrow> cball x e = {x}"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   201
  by simp
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   202
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   203
lemma ball_divide_subset: "d \<ge> 1 \<Longrightarrow> ball x (e/d) \<subseteq> ball x e"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   204
  by (metis ball_eq_empty div_by_1 frac_le linear subset_ball zero_less_one)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   205
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   206
lemma ball_divide_subset_numeral: "ball x (e / numeral w) \<subseteq> ball x e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   207
  using ball_divide_subset one_le_numeral by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   208
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   209
lemma cball_divide_subset: "d \<ge> 1 \<Longrightarrow> cball x (e/d) \<subseteq> cball x e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   210
  by (smt (verit, best) cball_empty div_by_1 frac_le subset_cball zero_le_divide_iff)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   211
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   212
lemma cball_divide_subset_numeral: "cball x (e / numeral w) \<subseteq> cball x e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   213
  using cball_divide_subset one_le_numeral by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   214
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   215
lemma cball_scale:
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   216
  assumes "a \<noteq> 0"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   217
  shows   "(\<lambda>x. a *\<^sub>R x) ` cball c r = cball (a *\<^sub>R c :: 'a :: real_normed_vector) (\<bar>a\<bar> * r)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   218
proof -
82470
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   219
  have *: "(\<lambda>x. a *\<^sub>R x) ` cball c r \<subseteq> cball (a *\<^sub>R c) (\<bar>a\<bar> * r)" for a r and c :: 'a
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   220
    by (auto simp: dist_norm simp flip: scaleR_right_diff_distrib intro!: mult_left_mono)
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   221
  have "cball (a *\<^sub>R c) (\<bar>a\<bar> * r) = (\<lambda>x. a *\<^sub>R x) ` (\<lambda>x. inverse a *\<^sub>R x) ` cball (a *\<^sub>R c) (\<bar>a\<bar> * r)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   222
    unfolding image_image using assms by simp
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   223
  also have "\<dots> \<subseteq> (\<lambda>x. a *\<^sub>R x) ` cball (inverse a *\<^sub>R (a *\<^sub>R c)) (\<bar>inverse a\<bar> * (\<bar>a\<bar> * r))"
82470
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   224
    using "*" by blast
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   225
  also have "\<dots> = (\<lambda>x. a *\<^sub>R x) ` cball c r"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   226
    using assms by (simp add: algebra_simps)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   227
  finally have "cball (a *\<^sub>R c) (\<bar>a\<bar> * r) \<subseteq> (\<lambda>x. a *\<^sub>R x) ` cball c r" .
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   228
  moreover from assms have "(\<lambda>x. a *\<^sub>R x) ` cball c r \<subseteq> cball (a *\<^sub>R c) (\<bar>a\<bar> * r)"
82470
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   229
    using "*" by blast
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   230
  ultimately show ?thesis by blast
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   231
qed
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   232
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   233
lemma ball_scale:
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   234
  assumes "a \<noteq> 0"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   235
  shows   "(\<lambda>x. a *\<^sub>R x) ` ball c r = ball (a *\<^sub>R c :: 'a :: real_normed_vector) (\<bar>a\<bar> * r)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   236
proof -
82470
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   237
  have *: "(\<lambda>x. a *\<^sub>R x) ` ball c r \<subseteq> ball (a *\<^sub>R c) (\<bar>a\<bar> * r)" if "a \<noteq> 0" for a r and c :: 'a
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   238
    using that by (auto simp: dist_norm simp flip: scaleR_right_diff_distrib)
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   239
  have "ball (a *\<^sub>R c) (\<bar>a\<bar> * r) = (\<lambda>x. a *\<^sub>R x) ` (\<lambda>x. inverse a *\<^sub>R x) ` ball (a *\<^sub>R c) (\<bar>a\<bar> * r)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   240
    unfolding image_image using assms by simp
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   241
  also have "\<dots> \<subseteq> (\<lambda>x. a *\<^sub>R x) ` ball (inverse a *\<^sub>R (a *\<^sub>R c)) (\<bar>inverse a\<bar> * (\<bar>a\<bar> * r))"
82470
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   242
    using assms by (intro image_mono *) auto
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   243
  also have "\<dots> = (\<lambda>x. a *\<^sub>R x) ` ball c r"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   244
    using assms by (simp add: algebra_simps)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   245
  finally have "ball (a *\<^sub>R c) (\<bar>a\<bar> * r) \<subseteq> (\<lambda>x. a *\<^sub>R x) ` ball c r" .
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   246
  moreover from assms have "(\<lambda>x. a *\<^sub>R x) ` ball c r \<subseteq> ball (a *\<^sub>R c) (\<bar>a\<bar> * r)"
82470
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   247
    by (intro *) auto
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   248
  ultimately show ?thesis by blast
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   249
qed
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   250
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   251
lemma sphere_scale:
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   252
  assumes "a \<noteq> 0"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   253
  shows   "(\<lambda>x. a *\<^sub>R x) ` sphere c r = sphere (a *\<^sub>R c :: 'a :: real_normed_vector) (\<bar>a\<bar> * r)"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   254
proof -
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   255
  have *: "(\<lambda>x. a *\<^sub>R x) ` sphere c r \<subseteq> sphere (a *\<^sub>R c) (\<bar>a\<bar> * r)" for a r and c :: 'a
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   256
    by (metis (no_types, opaque_lifting) scaleR_right_diff_distrib dist_norm image_subsetI mem_sphere norm_scaleR)
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   257
  have "sphere (a *\<^sub>R c) (\<bar>a\<bar> * r) = (\<lambda>x. a *\<^sub>R x) ` (\<lambda>x. inverse a *\<^sub>R x) ` sphere (a *\<^sub>R c) (\<bar>a\<bar> * r)"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   258
    unfolding image_image using assms by simp
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   259
  also have "\<dots> \<subseteq> (\<lambda>x. a *\<^sub>R x) ` sphere (inverse a *\<^sub>R (a *\<^sub>R c)) (\<bar>inverse a\<bar> * (\<bar>a\<bar> * r))"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   260
    using "*" by blast
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   261
  also have "\<dots> = (\<lambda>x. a *\<^sub>R x) ` sphere c r"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   262
    using assms by (simp add: algebra_simps)
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   263
  finally have "sphere (a *\<^sub>R c) (\<bar>a\<bar> * r) \<subseteq> (\<lambda>x. a *\<^sub>R x) ` sphere c r" .
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   264
  moreover have "(\<lambda>x. a *\<^sub>R x) ` sphere c r \<subseteq> sphere (a *\<^sub>R c) (\<bar>a\<bar> * r)"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   265
    using "*" by blast
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   266
  ultimately show ?thesis by blast
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   267
qed
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   268
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   269
text \<open>As above, but scaled by a complex number\<close>
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   270
lemma sphere_cscale:
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   271
  assumes "a \<noteq> 0"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   272
  shows   "(\<lambda>x. a * x) ` sphere c r = sphere (a * c :: complex) (cmod a * r)"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   273
proof -
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   274
  have *: "(\<lambda>x. a * x) ` sphere c r \<subseteq> sphere (a * c) (cmod a * r)" for a r c
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   275
    using dist_mult_left by fastforce
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   276
  have "sphere (a * c) (cmod a * r) = (\<lambda>x. a * x) ` (\<lambda>x. inverse a * x) ` sphere (a * c) (cmod a * r)"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   277
    by (simp add: image_image inverse_eq_divide)
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   278
  also have "\<dots> \<subseteq> (\<lambda>x. a * x) ` sphere (inverse a * (a * c)) (cmod (inverse a) * (cmod a * r))"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   279
    using "*" by blast
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   280
  also have "\<dots> = (\<lambda>x. a * x) ` sphere c r"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   281
    using assms by (simp add: field_simps flip: norm_mult)
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   282
  finally have "sphere (a * c) (cmod a * r) \<subseteq> (\<lambda>x. a * x) ` sphere c r" .
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   283
  moreover have "(\<lambda>x. a * x) ` sphere c r \<subseteq> sphere (a * c) (cmod a * r)"
785615e37846 A couple of new lemmas
paulson <lp15@cam.ac.uk>
parents: 80914
diff changeset
   284
    using "*" by blast
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   285
  ultimately show ?thesis by blast
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   286
qed
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   287
77223
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   288
lemma frequently_atE:
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   289
  fixes x :: "'a :: metric_space"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   290
  assumes "frequently P (at x within s)"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   291
  shows   "\<exists>f. filterlim f (at x within s) sequentially \<and> (\<forall>n. P (f n))"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   292
proof -
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   293
  have "\<exists>y. y \<in> s \<inter> (ball x (1 / real (Suc n)) - {x}) \<and> P y" for n
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   294
  proof -
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   295
    have "\<exists>z\<in>s. z \<noteq> x \<and> dist z x < (1 / real (Suc n)) \<and> P z"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   296
      by (metis assms divide_pos_pos frequently_at of_nat_0_less_iff zero_less_Suc zero_less_one)
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   297
    then show ?thesis
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   298
      by (auto simp: dist_commute conj_commute)
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   299
  qed
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   300
  then obtain f where f: "\<And>n. f n \<in> s \<inter> (ball x (1 / real (Suc n)) - {x}) \<and> P (f n)"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   301
    by metis
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   302
  have "filterlim f (nhds x) sequentially"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   303
    unfolding tendsto_iff
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   304
  proof clarify
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   305
    fix e :: real
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   306
    assume e: "e > 0"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   307
    then obtain n where n: "Suc n > 1 / e"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   308
      by (meson le_nat_floor lessI not_le)
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   309
    have "dist (f k) x < e" if "k \<ge> n" for k
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   310
    proof -
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   311
      have "dist (f k) x < 1 / real (Suc k)"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   312
        using f[of k] by (auto simp: dist_commute)
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   313
      also have "\<dots> \<le> 1 / real (Suc n)"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   314
        using that by (intro divide_left_mono) auto
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   315
      also have "\<dots> < e"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   316
        using n e by (simp add: field_simps)
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   317
      finally show ?thesis .
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   318
    qed
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   319
    thus "\<forall>\<^sub>F k in sequentially. dist (f k) x < e"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   320
      unfolding eventually_at_top_linorder by blast
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   321
  qed
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   322
  moreover have "f n \<noteq> x" for n
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   323
    using f[of n] by auto
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   324
  ultimately have "filterlim f (at x within s) sequentially"
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   325
    using f by (auto simp: filterlim_at)
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   326
  with f show ?thesis
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   327
    by blast
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   328
qed
607e1e345e8f Lots of new material chiefly about complex analysis
paulson <lp15@cam.ac.uk>
parents: 77179
diff changeset
   329
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   330
section \<open>Limit Points\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   331
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   332
lemma islimpt_approachable:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   333
  fixes x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   334
  shows "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   335
  unfolding islimpt_iff_eventually eventually_at by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   336
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   337
lemma islimpt_approachable_le: "x islimpt S \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> S. x' \<noteq> x \<and> dist x' x \<le> e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   338
  for x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   339
  unfolding islimpt_approachable
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   340
  using approachable_lt_le2 [where f="\<lambda>y. dist y x" and P="\<lambda>y. y \<notin> S \<or> y = x" and Q="\<lambda>x. True"]
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   341
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   342
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   343
lemma limpt_of_limpts: "x islimpt {y. y islimpt S} \<Longrightarrow> x islimpt S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   344
  for x :: "'a::metric_space"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   345
  by (metis islimpt_def islimpt_eq_acc_point mem_Collect_eq)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   346
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   347
lemma closed_limpts:  "closed {x::'a::metric_space. x islimpt S}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   348
  using closed_limpt limpt_of_limpts by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   349
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   350
lemma limpt_of_closure: "x islimpt closure S \<longleftrightarrow> x islimpt S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   351
  for x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   352
  by (auto simp: closure_def islimpt_Un dest: limpt_of_limpts)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   353
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   354
lemma islimpt_eq_infinite_ball: "x islimpt S \<longleftrightarrow> (\<forall>e>0. infinite(S \<inter> ball x e))"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   355
  unfolding islimpt_eq_acc_point
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   356
  by (metis open_ball Int_commute Int_mono finite_subset open_contains_ball_eq subset_eq)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   357
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   358
lemma islimpt_eq_infinite_cball: "x islimpt S \<longleftrightarrow> (\<forall>e>0. infinite(S \<inter> cball x e))"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   359
  unfolding islimpt_eq_infinite_ball
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   360
  by (metis open_ball ball_subset_cball centre_in_ball finite_Int inf.absorb_iff2 inf_assoc open_contains_cball_eq)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   361
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   362
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   363
section \<open>Perfect Metric Spaces\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   364
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   365
lemma perfect_choose_dist: "0 < r \<Longrightarrow> \<exists>a. a \<noteq> x \<and> dist a x < r"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   366
  for x :: "'a::{perfect_space,metric_space}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   367
  using islimpt_UNIV [of x] by (simp add: islimpt_approachable)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   368
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   369
lemma cball_eq_sing:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   370
  fixes x :: "'a::{metric_space,perfect_space}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   371
  shows "cball x e = {x} \<longleftrightarrow> e = 0"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   372
  by (metis cball_trivial centre_in_cball finite.emptyI finite.insertI finite_Int
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   373
      islimpt_UNIV islimpt_eq_infinite_cball less_eq_real_def) 
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   374
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   375
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   376
section \<open>Finite and discrete\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   377
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   378
lemma finite_ball_include:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   379
  fixes a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   380
  assumes "finite S" 
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   381
  shows "\<exists>e>0. S \<subseteq> ball a e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   382
  using assms
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   383
proof induction
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   384
  case (insert x S)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   385
  then obtain e0 where "e0>0" and e0:"S \<subseteq> ball a e0" by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   386
  define e where "e = max e0 (2 * dist a x)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   387
  have "e>0" unfolding e_def using \<open>e0>0\<close> by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   388
  moreover have "insert x S \<subseteq> ball a e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   389
    using e0 \<open>e>0\<close> unfolding e_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   390
  ultimately show ?case by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   391
qed (auto intro: zero_less_one)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   392
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   393
lemma finite_set_avoid:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   394
  fixes a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   395
  assumes "finite S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   396
  shows "\<exists>d>0. \<forall>x\<in>S. x \<noteq> a \<longrightarrow> d \<le> dist a x"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   397
  using assms
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   398
proof induction
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   399
  case (insert x S)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   400
  then obtain d where "d > 0" and d: "\<forall>x\<in>S. x \<noteq> a \<longrightarrow> d \<le> dist a x"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   401
    by blast
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   402
  then show ?case
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   403
    by (metis dist_nz dual_order.strict_implies_order insertE leI order.strict_trans2)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   404
qed (auto intro: zero_less_one)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   405
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   406
lemma discrete_imp_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   407
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   408
  assumes e: "0 < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   409
    and d: "\<forall>x \<in> S. \<forall>y \<in> S. dist y x < e \<longrightarrow> y = x"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   410
  shows "closed S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   411
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   412
  have False if C: "\<And>e. e>0 \<Longrightarrow> \<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e" for x
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   413
  proof -
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   414
    obtain y where y: "y \<in> S" "y \<noteq> x" "dist y x < e/2"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   415
      by (meson C e half_gt_zero)
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   416
    then have mp: "min (e/2) (dist x y) > 0"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   417
      by (simp add: dist_commute)
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   418
    from d y C[OF mp] show ?thesis
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   419
      by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   420
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   421
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   422
    by (metis islimpt_approachable closed_limpt [where 'a='a])
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   423
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   424
77140
9a60c1759543 Lots more new material thanks to Manuel Eberl
paulson <lp15@cam.ac.uk>
parents: 76796
diff changeset
   425
lemma discrete_imp_not_islimpt:
9a60c1759543 Lots more new material thanks to Manuel Eberl
paulson <lp15@cam.ac.uk>
parents: 76796
diff changeset
   426
  assumes e: "0 < e"
9a60c1759543 Lots more new material thanks to Manuel Eberl
paulson <lp15@cam.ac.uk>
parents: 76796
diff changeset
   427
    and d: "\<And>x y. x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> dist y x < e \<Longrightarrow> y = x"
9a60c1759543 Lots more new material thanks to Manuel Eberl
paulson <lp15@cam.ac.uk>
parents: 76796
diff changeset
   428
  shows "\<not> x islimpt S"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   429
  by (metis closed_limpt d discrete_imp_closed e islimpt_approachable)
77140
9a60c1759543 Lots more new material thanks to Manuel Eberl
paulson <lp15@cam.ac.uk>
parents: 76796
diff changeset
   430
  
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   431
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   432
section \<open>Interior\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   433
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   434
lemma mem_interior: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. ball x e \<subseteq> S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   435
  using open_contains_ball_eq [where S="interior S"]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   436
  by (simp add: open_subset_interior)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   437
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   438
lemma mem_interior_cball: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   439
  by (meson ball_subset_cball interior_subset mem_interior open_contains_cball open_interior
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   440
      subset_trans)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   441
78037
37894dff0111 More material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 77490
diff changeset
   442
lemma ball_iff_cball: "(\<exists>r>0. ball x r \<subseteq> U) \<longleftrightarrow> (\<exists>r>0. cball x r \<subseteq> U)"
37894dff0111 More material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 77490
diff changeset
   443
  by (meson mem_interior mem_interior_cball)
37894dff0111 More material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 77490
diff changeset
   444
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   445
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   446
section \<open>Frontier\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   447
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   448
lemma frontier_straddle:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   449
  fixes a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   450
  shows "a \<in> frontier S \<longleftrightarrow> (\<forall>e>0. (\<exists>x\<in>S. dist a x < e) \<and> (\<exists>x. x \<notin> S \<and> dist a x < e))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   451
  unfolding frontier_def closure_interior
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   452
  by (auto simp: mem_interior subset_eq ball_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   453
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   454
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   455
section \<open>Limits\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   456
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   457
proposition Lim: "(f \<longlongrightarrow> l) net \<longleftrightarrow> trivial_limit net \<or> (\<forall>e>0. eventually (\<lambda>x. dist (f x) l < e) net)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   458
  by (auto simp: tendsto_iff trivial_limit_eq)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   459
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   460
text \<open>Show that they yield usual definitions in the various cases.\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   461
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   462
proposition Lim_within_le: "(f \<longlongrightarrow> l)(at a within S) \<longleftrightarrow>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   463
    (\<forall>e>0. \<exists>d>0. \<forall>x\<in>S. 0 < dist x a \<and> dist x a \<le> d \<longrightarrow> dist (f x) l < e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   464
  by (auto simp: tendsto_iff eventually_at_le)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   465
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   466
proposition Lim_within: "(f \<longlongrightarrow> l) (at a within S) \<longleftrightarrow>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   467
    (\<forall>e >0. \<exists>d>0. \<forall>x \<in> S. 0 < dist x a \<and> dist x a  < d \<longrightarrow> dist (f x) l < e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   468
  by (auto simp: tendsto_iff eventually_at)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   469
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   470
corollary Lim_withinI [intro?]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   471
  assumes "\<And>e. e > 0 \<Longrightarrow> \<exists>d>0. \<forall>x \<in> S. 0 < dist x a \<and> dist x a < d \<longrightarrow> dist (f x) l \<le> e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   472
  shows "(f \<longlongrightarrow> l) (at a within S)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   473
  unfolding Lim_within by (smt (verit, ccfv_SIG) assms zero_less_dist_iff)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   474
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   475
proposition Lim_at: "(f \<longlongrightarrow> l) (at a) \<longleftrightarrow>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   476
    (\<forall>e >0. \<exists>d>0. \<forall>x. 0 < dist x a \<and> dist x a < d  \<longrightarrow> dist (f x) l < e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   477
  by (auto simp: tendsto_iff eventually_at)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   478
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   479
lemma Lim_transform_within_set:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   480
  fixes a :: "'a::metric_space" and l :: "'b::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   481
  shows "\<lbrakk>(f \<longlongrightarrow> l) (at a within S); eventually (\<lambda>x. x \<in> S \<longleftrightarrow> x \<in> T) (at a)\<rbrakk>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   482
         \<Longrightarrow> (f \<longlongrightarrow> l) (at a within T)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   483
  by (simp add: eventually_at Lim_within) (smt (verit, best))
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   484
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   485
text \<open>Another limit point characterization.\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   486
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   487
lemma limpt_sequential_inj:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   488
  fixes x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   489
  shows "x islimpt S \<longleftrightarrow>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   490
         (\<exists>f. (\<forall>n::nat. f n \<in> S - {x}) \<and> inj f \<and> (f \<longlongrightarrow> x) sequentially)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   491
         (is "?lhs = ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   492
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   493
  assume ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   494
  then have "\<forall>e>0. \<exists>x'\<in>S. x' \<noteq> x \<and> dist x' x < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   495
    by (force simp: islimpt_approachable)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   496
  then obtain y where y: "\<And>e. e>0 \<Longrightarrow> y e \<in> S \<and> y e \<noteq> x \<and> dist (y e) x < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   497
    by metis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   498
  define f where "f \<equiv> rec_nat (y 1) (\<lambda>n fn. y (min (inverse(2 ^ (Suc n))) (dist fn x)))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   499
  have [simp]: "f 0 = y 1"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   500
            and fSuc: "f(Suc n) = y (min (inverse(2 ^ (Suc n))) (dist (f n) x))" for n
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   501
    by (simp_all add: f_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   502
  have f: "f n \<in> S \<and> (f n \<noteq> x) \<and> dist (f n) x < inverse(2 ^ n)" for n
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   503
  proof (induction n)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   504
    case 0 show ?case
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   505
      by (simp add: y)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   506
  next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   507
    case (Suc n) then show ?case
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   508
      by (smt (verit, best) fSuc dist_pos_lt inverse_positive_iff_positive y zero_less_power)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   509
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   510
  show ?rhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   511
  proof (intro exI conjI allI)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   512
    show "\<And>n. f n \<in> S - {x}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   513
      using f by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   514
    have "dist (f n) x < dist (f m) x" if "m < n" for m n
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   515
    using that
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   516
    proof (induction n)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   517
      case 0 then show ?case by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   518
    next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   519
      case (Suc n)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   520
      then consider "m < n" | "m = n" using less_Suc_eq by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   521
      then show ?case
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   522
        by (smt (verit, ccfv_threshold) Suc.IH dist_nz f fSuc y)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   523
    qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   524
    then show "inj f"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   525
      by (metis less_irrefl linorder_injI)
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   526
    have "\<And>e n. \<lbrakk>0 < e; nat \<lceil>1 / e::real\<rceil> \<le> n\<rbrakk> \<Longrightarrow> inverse (2 ^ n) < e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   527
      by (simp add: divide_simps order_le_less_trans)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   528
    then show "f \<longlonglongrightarrow> x"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   529
      by (metis dual_order.strict_trans f lim_sequentially)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   530
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   531
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   532
  assume ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   533
  then show ?lhs
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
   534
    by (fastforce simp: islimpt_approachable lim_sequentially)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   535
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   536
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   537
lemma Lim_dist_ubound:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   538
  assumes "\<not>(trivial_limit net)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   539
    and "(f \<longlongrightarrow> l) net"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   540
    and "eventually (\<lambda>x. dist a (f x) \<le> e) net"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   541
  shows "dist a l \<le> e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   542
  using assms by (fast intro: tendsto_le tendsto_intros)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   543
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   544
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   545
section \<open>Continuity\<close>
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   546
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   547
text\<open>Derive the epsilon-delta forms, which we often use as "definitions"\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   548
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   549
proposition continuous_within_eps_delta:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   550
  "continuous (at x within s) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x'\<in> s.  dist x' x < d --> dist (f x') (f x) < e)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   551
  unfolding continuous_within and Lim_within  by fastforce
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   552
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   553
corollary continuous_at_eps_delta:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   554
  "continuous (at x) f \<longleftrightarrow> (\<forall>e > 0. \<exists>d > 0. \<forall>x'. dist x' x < d \<longrightarrow> dist (f x') (f x) < e)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   555
  using continuous_within_eps_delta [of x UNIV f] by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   556
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   557
lemma continuous_at_right_real_increasing:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   558
  fixes f :: "real \<Rightarrow> real"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   559
  assumes nondecF: "\<And>x y. x \<le> y \<Longrightarrow> f x \<le> f y"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   560
  shows "continuous (at_right a) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. f (a + d) - f a < e)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   561
  apply (simp add: greaterThan_def dist_real_def continuous_within Lim_within_le)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   562
  apply (intro all_cong ex_cong)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   563
  by (smt (verit, best) nondecF)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   564
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   565
lemma continuous_at_left_real_increasing:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   566
  assumes nondecF: "\<And> x y. x \<le> y \<Longrightarrow> f x \<le> ((f y) :: real)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   567
  shows "(continuous (at_left (a :: real)) f) \<longleftrightarrow> (\<forall>e > 0. \<exists>delta > 0. f a - f (a - delta) < e)"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   568
  apply (simp add: lessThan_def dist_real_def continuous_within Lim_within_le)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   569
  apply (intro all_cong ex_cong)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   570
  by (smt (verit) nondecF)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   571
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   572
text\<open>Versions in terms of open balls.\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   573
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   574
lemma continuous_within_ball:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   575
  "continuous (at x within S) f \<longleftrightarrow>
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   576
    (\<forall>e > 0. \<exists>d > 0. f ` (ball x d \<inter> S) \<subseteq> ball (f x) e)"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   577
  (is "?lhs = ?rhs")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   578
proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   579
  assume ?lhs
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   580
  {
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   581
    fix e :: real
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   582
    assume "e > 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   583
    then obtain d where "d>0" and d: "\<forall>y\<in>S. 0 < dist y x \<and> dist y x < d \<longrightarrow> dist (f y) (f x) < e"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   584
      using \<open>?lhs\<close>[unfolded continuous_within Lim_within] by auto
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   585
    { fix y
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   586
      assume "y \<in> f ` (ball x d \<inter> S)" then have "y \<in> ball (f x) e"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   587
        using d \<open>e > 0\<close> by (auto simp: dist_commute)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   588
    }
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   589
    then have "\<exists>d>0. f ` (ball x d \<inter> S) \<subseteq> ball (f x) e"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   590
      using \<open>d > 0\<close> by blast
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   591
  }
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   592
  then show ?rhs by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   593
next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   594
  assume ?rhs
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   595
  then show ?lhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   596
    apply (simp add: continuous_within Lim_within ball_def subset_eq)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   597
    by (metis (mono_tags, lifting) Int_iff dist_commute mem_Collect_eq)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   598
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   599
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   600
lemma continuous_at_ball:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   601
  "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. f ` (ball x d) \<subseteq> ball (f x) e)"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   602
  apply (simp add: continuous_at Lim_at subset_eq Ball_def Bex_def image_iff)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   603
  by (smt (verit, ccfv_threshold) dist_commute dist_self)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   604
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   605
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   606
text\<open>Define setwise continuity in terms of limits within the set.\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   607
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   608
lemma continuous_on_iff:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   609
  "continuous_on s f \<longleftrightarrow>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   610
    (\<forall>x\<in>s. \<forall>e>0. \<exists>d>0. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   611
  unfolding continuous_on_def Lim_within
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   612
  by (metis dist_pos_lt dist_self)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   614
lemma continuous_within_E:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   615
  assumes "continuous (at x within S) f" "e>0"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   616
  obtains d where "d>0"  "\<And>x'. \<lbrakk>x'\<in> S; dist x' x \<le> d\<rbrakk> \<Longrightarrow> dist (f x') (f x) < e"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   617
  using assms unfolding continuous_within_eps_delta
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   618
  by (metis dense order_le_less_trans)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   619
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   620
lemma continuous_onI [intro?]:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   621
  assumes "\<And>x e. \<lbrakk>e > 0; x \<in> S\<rbrakk> \<Longrightarrow> \<exists>d>0. \<forall>x'\<in>S. dist x' x < d \<longrightarrow> dist (f x') (f x) \<le> e"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   622
  shows "continuous_on S f"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   623
apply (simp add: continuous_on_iff, clarify)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   624
apply (rule ex_forward [OF assms [OF half_gt_zero]], auto)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   625
done
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   626
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   627
text\<open>Some simple consequential lemmas.\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   628
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   629
lemma continuous_onE:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   630
    assumes "continuous_on s f" "x\<in>s" "e>0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   631
    obtains d where "d>0"  "\<And>x'. \<lbrakk>x' \<in> s; dist x' x \<le> d\<rbrakk> \<Longrightarrow> dist (f x') (f x) < e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   632
  using assms
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   633
  unfolding continuous_on_iff by (metis dense order_le_less_trans)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   634
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   635
text\<open>The usual transformation theorems.\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   636
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   637
lemma continuous_transform_within:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   638
  fixes f g :: "'a::metric_space \<Rightarrow> 'b::topological_space"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   639
  assumes "continuous (at x within s) f"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   640
    and "0 < d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   641
    and "x \<in> s"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   642
    and "\<And>x'. \<lbrakk>x' \<in> s; dist x' x < d\<rbrakk> \<Longrightarrow> f x' = g x'"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   643
  shows "continuous (at x within s) g"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   644
  using assms
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   645
  unfolding continuous_within by (force intro: Lim_transform_within)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   646
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   647
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   648
section \<open>Closure and Limit Characterization\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   649
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   650
lemma closure_approachable:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   651
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   652
  shows "x \<in> closure S \<longleftrightarrow> (\<forall>e>0. \<exists>y\<in>S. dist y x < e)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   653
  using dist_self by (force simp: closure_def islimpt_approachable)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   654
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   655
lemma closure_approachable_le:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   656
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   657
  shows "x \<in> closure S \<longleftrightarrow> (\<forall>e>0. \<exists>y\<in>S. dist y x \<le> e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   658
  unfolding closure_approachable
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   659
  using dense by force
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   660
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   661
lemma closure_approachableD:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   662
  assumes "x \<in> closure S" "e>0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   663
  shows "\<exists>y\<in>S. dist x y < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   664
  using assms unfolding closure_approachable by (auto simp: dist_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   665
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   666
lemma closed_approachable:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   667
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   668
  shows "closed S \<Longrightarrow> (\<forall>e>0. \<exists>y\<in>S. dist y x < e) \<longleftrightarrow> x \<in> S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   669
  by (metis closure_closed closure_approachable)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   670
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   671
lemma closure_contains_Inf:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   672
  fixes S :: "real set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   673
  assumes "S \<noteq> {}" "bdd_below S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   674
  shows "Inf S \<in> closure S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   675
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   676
  have *: "\<forall>x\<in>S. Inf S \<le> x"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   677
    using cInf_lower[of _ S] assms by metis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   678
  { fix e :: real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   679
    assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   680
    then have "Inf S < Inf S + e" by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   681
    with assms obtain x where "x \<in> S" "x < Inf S + e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   682
      using cInf_lessD by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   683
    with * have "\<exists>x\<in>S. dist x (Inf S) < e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   684
      using dist_real_def by force
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   685
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   686
  then show ?thesis unfolding closure_approachable by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   687
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   688
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   689
lemma closure_contains_Sup:
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   690
  fixes S :: "real set"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   691
  assumes "S \<noteq> {}" "bdd_above S"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   692
  shows "Sup S \<in> closure S"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   693
proof -
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   694
  have *: "\<forall>x\<in>S. x \<le> Sup S"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   695
    using cSup_upper[of _ S] assms by metis
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   696
  {
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   697
    fix e :: real
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   698
    assume "e > 0"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   699
    then have "Sup S - e < Sup S" by simp
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   700
    with assms obtain x where "x \<in> S" "Sup S - e < x"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   701
      using less_cSupE by blast
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   702
    with * have "\<exists>x\<in>S. dist x (Sup S) < e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   703
      using dist_real_def by force
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   704
  }
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   705
  then show ?thesis unfolding closure_approachable by auto
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   706
qed
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   707
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   708
lemma not_trivial_limit_within_ball:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   709
  "\<not> trivial_limit (at x within S) \<longleftrightarrow> (\<forall>e>0. S \<inter> ball x e - {x} \<noteq> {})"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   710
  (is "?lhs \<longleftrightarrow> ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   711
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   712
  show ?rhs if ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   713
  proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   714
    { fix e :: real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   715
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   716
      then obtain y where "y \<in> S - {x}" and "dist y x < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   717
        using \<open>?lhs\<close> not_trivial_limit_within[of x S] closure_approachable[of x "S - {x}"]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   718
        by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   719
      then have "y \<in> S \<inter> ball x e - {x}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   720
        unfolding ball_def by (simp add: dist_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   721
      then have "S \<inter> ball x e - {x} \<noteq> {}" by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   722
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   723
    then show ?thesis by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   724
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   725
  show ?lhs if ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   726
  proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   727
    { fix e :: real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   728
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   729
      then obtain y where "y \<in> S \<inter> ball x e - {x}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   730
        using \<open>?rhs\<close> by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   731
      then have "y \<in> S - {x}" and "dist y x < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   732
        unfolding ball_def by (simp_all add: dist_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   733
      then have "\<exists>y \<in> S - {x}. dist y x < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   734
        by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   735
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   736
    then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   737
      using not_trivial_limit_within[of x S] closure_approachable[of x "S - {x}"]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   738
      by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   739
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   740
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   741
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   742
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   743
section \<open>Boundedness\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   744
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   745
  (* FIXME: This has to be unified with BSEQ!! *)
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
   746
definition\<^marker>\<open>tag important\<close> (in metric_space) bounded :: "'a set \<Rightarrow> bool"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   747
  where "bounded S \<longleftrightarrow> (\<exists>x e. \<forall>y\<in>S. dist x y \<le> e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   748
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   749
lemma bounded_subset_cball: "bounded S \<longleftrightarrow> (\<exists>e x. S \<subseteq> cball x e \<and> 0 \<le> e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   750
  unfolding bounded_def subset_eq  by auto (meson order_trans zero_le_dist)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   751
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   752
lemma bounded_any_center: "bounded S \<longleftrightarrow> (\<exists>e. \<forall>y\<in>S. dist a y \<le> e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   753
  unfolding bounded_def
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   754
  by auto (metis add.commute add_le_cancel_right dist_commute dist_triangle_le)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   755
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   756
lemma bounded_iff: "bounded S \<longleftrightarrow> (\<exists>a. \<forall>x\<in>S. norm x \<le> a)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   757
  unfolding bounded_any_center [where a=0]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   758
  by (simp add: dist_norm)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   759
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   760
lemma bdd_above_norm: "bdd_above (norm ` X) \<longleftrightarrow> bounded X"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   761
  by (simp add: bounded_iff bdd_above_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   762
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   763
lemma bounded_norm_comp: "bounded ((\<lambda>x. norm (f x)) ` S) = bounded (f ` S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   764
  by (simp add: bounded_iff)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   765
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   766
lemma boundedI:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   767
  assumes "\<And>x. x \<in> S \<Longrightarrow> norm x \<le> B"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   768
  shows "bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   769
  using assms bounded_iff by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   770
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   771
lemma bounded_empty [simp]: "bounded {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   772
  by (simp add: bounded_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   773
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   774
lemma bounded_subset: "bounded T \<Longrightarrow> S \<subseteq> T \<Longrightarrow> bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   775
  by (metis bounded_def subset_eq)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   776
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   777
lemma bounded_interior[intro]: "bounded S \<Longrightarrow> bounded(interior S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   778
  by (metis bounded_subset interior_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   779
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   780
lemma bounded_closure[intro]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   781
  assumes "bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   782
  shows "bounded (closure S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   783
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   784
  from assms obtain x and a where a: "\<forall>y\<in>S. dist x y \<le> a"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   785
    unfolding bounded_def by auto
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   786
  { fix y
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   787
    assume "y \<in> closure S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   788
    then obtain f where f: "\<forall>n. f n \<in> S"  "(f \<longlongrightarrow> y) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   789
      unfolding closure_sequential by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   790
    have "\<forall>n. f n \<in> S \<longrightarrow> dist x (f n) \<le> a" using a by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   791
    then have "eventually (\<lambda>n. dist x (f n) \<le> a) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   792
      by (simp add: f(1))
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   793
    then have "dist x y \<le> a"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   794
      using Lim_dist_ubound f(2) trivial_limit_sequentially by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   795
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   796
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   797
    unfolding bounded_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   798
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   799
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   800
lemma bounded_closure_image: "bounded (f ` closure S) \<Longrightarrow> bounded (f ` S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   801
  by (simp add: bounded_subset closure_subset image_mono)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   802
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   803
lemma bounded_cball[simp,intro]: "bounded (cball x e)"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   804
  unfolding bounded_def  using mem_cball by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   805
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   806
lemma bounded_ball[simp,intro]: "bounded (ball x e)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   807
  by (metis ball_subset_cball bounded_cball bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   808
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   809
lemma bounded_Un[simp]: "bounded (S \<union> T) \<longleftrightarrow> bounded S \<and> bounded T"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   810
  by (auto simp: bounded_def) (metis Un_iff bounded_any_center le_max_iff_disj)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   811
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   812
lemma bounded_Union[intro]: "finite F \<Longrightarrow> \<forall>S\<in>F. bounded S \<Longrightarrow> bounded (\<Union>F)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   813
  by (induct rule: finite_induct[of F]) auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   814
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   815
lemma bounded_UN [intro]: "finite A \<Longrightarrow> \<forall>x\<in>A. bounded (B x) \<Longrightarrow> bounded (\<Union>x\<in>A. B x)"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   816
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   817
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   818
lemma bounded_insert [simp]: "bounded (insert x S) \<longleftrightarrow> bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   819
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   820
  have "\<forall>y\<in>{x}. dist x y \<le> 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   821
    by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   822
  then have "bounded {x}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   823
    unfolding bounded_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   824
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   825
    by (metis insert_is_Un bounded_Un)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   826
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   827
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   828
lemma bounded_subset_ballI: "S \<subseteq> ball x r \<Longrightarrow> bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   829
  by (meson bounded_ball bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   830
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   831
lemma bounded_subset_ballD:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   832
  assumes "bounded S" shows "\<exists>r. 0 < r \<and> S \<subseteq> ball x r"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   833
proof -
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   834
  obtain e::real and y where "S \<subseteq> cball y e" "0 \<le> e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   835
    using assms by (auto simp: bounded_subset_cball)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   836
  then show ?thesis
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   837
    by (intro exI[where x="dist x y + e + 1"]) metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   838
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   839
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   840
lemma finite_imp_bounded [intro]: "finite S \<Longrightarrow> bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   841
  by (induct set: finite) simp_all
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   842
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   843
lemma bounded_Int[intro]: "bounded S \<or> bounded T \<Longrightarrow> bounded (S \<inter> T)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   844
  by (metis Int_lower1 Int_lower2 bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   845
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   846
lemma bounded_diff[intro]: "bounded S \<Longrightarrow> bounded (S - T)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   847
  by (metis Diff_subset bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   848
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   849
lemma bounded_dist_comp:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   850
  assumes "bounded (f ` S)" "bounded (g ` S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   851
  shows "bounded ((\<lambda>x. dist (f x) (g x)) ` S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   852
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   853
  from assms obtain M1 M2 where *: "dist (f x) undefined \<le> M1" "dist undefined (g x) \<le> M2" if "x \<in> S" for x
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   854
    by (auto simp: bounded_any_center[of _ undefined] dist_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   855
  have "dist (f x) (g x) \<le> M1 + M2" if "x \<in> S" for x
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   856
    using *[OF that]
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   857
    by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   858
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   859
    by (auto intro!: boundedI)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   860
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   861
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   862
lemma bounded_Times:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   863
  assumes "bounded s" "bounded t"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   864
  shows "bounded (s \<times> t)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   865
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   866
  obtain x y a b where "\<forall>z\<in>s. dist x z \<le> a" "\<forall>z\<in>t. dist y z \<le> b"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   867
    using assms [unfolded bounded_def] by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   868
  then have "\<forall>z\<in>s \<times> t. dist (x, y) z \<le> sqrt (a\<^sup>2 + b\<^sup>2)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   869
    by (auto simp: dist_Pair_Pair real_sqrt_le_mono add_mono power_mono)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   870
  then show ?thesis unfolding bounded_any_center [where a="(x, y)"] by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   871
qed
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   872
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   873
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
   874
section \<open>Compactness\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   875
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   876
lemma compact_imp_bounded:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   877
  assumes "compact U"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   878
  shows "bounded U"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   879
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   880
  have "compact U" "\<forall>x\<in>U. open (ball x 1)" "U \<subseteq> (\<Union>x\<in>U. ball x 1)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   881
    using assms by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   882
  then obtain D where D: "D \<subseteq> U" "finite D" "U \<subseteq> (\<Union>x\<in>D. ball x 1)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   883
    by (metis compactE_image)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   884
  from \<open>finite D\<close> have "bounded (\<Union>x\<in>D. ball x 1)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   885
    by (simp add: bounded_UN)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   886
  then show "bounded U" using \<open>U \<subseteq> (\<Union>x\<in>D. ball x 1)\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   887
    by (rule bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   888
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   889
77490
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   890
lemma continuous_on_compact_bound:
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   891
  assumes "compact A" "continuous_on A f"
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   892
  obtains B where "B \<ge> 0" "\<And>x. x \<in> A \<Longrightarrow> norm (f x) \<le> B"
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   893
proof -
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   894
  have "compact (f ` A)" by (metis assms compact_continuous_image)
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   895
  then obtain B where "\<forall>x\<in>A. norm (f x) \<le> B"
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   896
    by (auto dest!: compact_imp_bounded simp: bounded_iff)
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   897
  hence "max B 0 \<ge> 0" and "\<forall>x\<in>A. norm (f x) \<le> max B 0" by auto
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   898
  thus ?thesis using that by blast
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   899
qed
2c86ea8961b5 Some new lemmas. Some tidying up
paulson <lp15@cam.ac.uk>
parents: 77273
diff changeset
   900
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   901
lemma closure_Int_ball_not_empty:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   902
  assumes "S \<subseteq> closure T" "x \<in> S" "r > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   903
  shows "T \<inter> ball x r \<noteq> {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   904
  using assms centre_in_ball closure_iff_nhds_not_empty by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   905
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   906
lemma compact_sup_maxdistance:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   907
  fixes S :: "'a::metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   908
  assumes "compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   909
    and "S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   910
  shows "\<exists>x\<in>S. \<exists>y\<in>S. \<forall>u\<in>S. \<forall>v\<in>S. dist u v \<le> dist x y"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   911
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   912
  have "compact (S \<times> S)"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   913
    using \<open>compact S\<close> by (intro compact_Times)
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   914
  moreover have "S \<times> S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   915
    using \<open>S \<noteq> {}\<close> by auto
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   916
  moreover have "continuous_on (S \<times> S) (\<lambda>x. dist (fst x) (snd x))"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   917
    by (intro continuous_at_imp_continuous_on ballI continuous_intros)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   918
  ultimately show ?thesis
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   919
    using continuous_attains_sup[of "S \<times> S" "\<lambda>x. dist (fst x) (snd x)"] by auto
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   920
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   921
77273
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   922
text \<open>
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   923
  If \<open>A\<close> is a compact subset of an open set \<open>B\<close> in a metric space, then there exists an \<open>\<epsilon> > 0\<close>
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   924
  such that the Minkowski sum of \<open>A\<close> with an open ball of radius \<open>\<epsilon>\<close> is also a subset of \<open>B\<close>.
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   925
\<close>
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   926
lemma compact_subset_open_imp_ball_epsilon_subset:
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   927
  assumes "compact A" "open B" "A \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   928
  obtains e where "e > 0"  "(\<Union>x\<in>A. ball x e) \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   929
proof -
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   930
  have "\<forall>x\<in>A. \<exists>e. e > 0 \<and> ball x e \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   931
    using assms unfolding open_contains_ball by blast
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   932
  then obtain e where e: "\<And>x. x \<in> A \<Longrightarrow> e x > 0" "\<And>x. x \<in> A \<Longrightarrow> ball x (e x) \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   933
    by metis
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   934
  define C where "C = e ` A"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   935
  obtain X where X: "X \<subseteq> A" "finite X" "A \<subseteq> (\<Union>c\<in>X. ball c (e c / 2))"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   936
    using assms(1)
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   937
  proof (rule compactE_image)
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   938
    show "open (ball x (e x / 2))" if "x \<in> A" for x
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   939
      by simp
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   940
    show "A \<subseteq> (\<Union>c\<in>A. ball c (e c / 2))"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   941
      using e by auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   942
  qed auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   943
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   944
  define e' where "e' = Min (insert 1 ((\<lambda>x. e x / 2) ` X))"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   945
  have "e' > 0"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   946
    unfolding e'_def using e X by (subst Min_gr_iff) auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   947
  have e': "e' \<le> e x / 2" if "x \<in> X" for x
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   948
    using that X unfolding e'_def by (intro Min.coboundedI) auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   949
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   950
  show ?thesis
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   951
  proof 
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   952
    show "e' > 0"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   953
      by fact
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   954
  next
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   955
    show "(\<Union>x\<in>A. ball x e') \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   956
    proof clarify
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   957
      fix x y assume xy: "x \<in> A" "y \<in> ball x e'"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   958
      from xy(1) X obtain z where z: "z \<in> X" "x \<in> ball z (e z / 2)"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   959
        by auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   960
      have "dist y z \<le> dist x y + dist z x"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   961
        by (metis dist_commute dist_triangle)
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   962
      also have "dist z x < e z / 2"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   963
        using xy z by auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   964
      also have "dist x y < e'"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   965
        using xy by auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   966
      also have "\<dots> \<le> e z / 2"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   967
        using z by (intro e') auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   968
      finally have "y \<in> ball z (e z)"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   969
        by (simp add: dist_commute)
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   970
      also have "\<dots> \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   971
        using z X by (intro e) auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   972
      finally show "y \<in> B" .
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   973
    qed
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   974
  qed
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   975
qed
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   976
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   977
lemma compact_subset_open_imp_cball_epsilon_subset:
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   978
  assumes "compact A" "open B" "A \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   979
  obtains e where "e > 0"  "(\<Union>x\<in>A. cball x e) \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   980
proof -
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   981
  obtain e where "e > 0" and e: "(\<Union>x\<in>A. ball x e) \<subseteq> B"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   982
    using compact_subset_open_imp_ball_epsilon_subset [OF assms] by blast
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   983
  then have "(\<Union>x\<in>A. cball x (e / 2)) \<subseteq> (\<Union>x\<in>A. ball x e)"
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   984
    by auto
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   985
  with \<open>0 < e\<close> that show ?thesis
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   986
    by (metis e half_gt_zero_iff order_trans)
f82317de6f28 A bit more tidying and some new material
paulson <lp15@cam.ac.uk>
parents: 77223
diff changeset
   987
qed
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   988
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   989
subsubsection\<open>Totally bounded\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   990
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   991
proposition seq_compact_imp_totally_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   992
  assumes "seq_compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   993
  shows "\<forall>e>0. \<exists>k. finite k \<and> k \<subseteq> S \<and> S \<subseteq> (\<Union>x\<in>k. ball x e)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   994
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   995
  { fix e::real assume "e > 0" assume *: "\<And>k. finite k \<Longrightarrow> k \<subseteq> S \<Longrightarrow> \<not> S \<subseteq> (\<Union>x\<in>k. ball x e)"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   996
    let ?Q = "\<lambda>x n r. r \<in> S \<and> (\<forall>m < (n::nat). \<not> (dist (x m) r < e))"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   997
    have "\<exists>x. \<forall>n::nat. ?Q x n (x n)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   998
    proof (rule dependent_wellorder_choice)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   999
      fix n x assume "\<And>y. y < n \<Longrightarrow> ?Q x y (x y)"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1000
      then have "\<not> S \<subseteq> (\<Union>x\<in>x ` {0..<n}. ball x e)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1001
        using *[of "x ` {0 ..< n}"] by (auto simp: subset_eq)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1002
      then obtain z where z:"z\<in>S" "z \<notin> (\<Union>x\<in>x ` {0..<n}. ball x e)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1003
        unfolding subset_eq by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1004
      show "\<exists>r. ?Q x n r"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1005
        using z by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1006
    qed simp
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1007
    then obtain x where "\<forall>n::nat. x n \<in> S" and x:"\<And>n m. m < n \<Longrightarrow> \<not> (dist (x m) (x n) < e)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1008
      by blast
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1009
    then obtain l r where "l \<in> S" and r:"strict_mono  r" and "((x \<circ> r) \<longlongrightarrow> l) sequentially"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1010
      using assms by (metis seq_compact_def)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1011
    then have "Cauchy (x \<circ> r)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1012
      using LIMSEQ_imp_Cauchy by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1013
    then obtain N::nat where "\<And>m n. N \<le> m \<Longrightarrow> N \<le> n \<Longrightarrow> dist ((x \<circ> r) m) ((x \<circ> r) n) < e"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1014
      unfolding Cauchy_def using \<open>e > 0\<close> by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1015
    then have False
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1016
      using x[of "r N" "r (N+1)"] r by (auto simp: strict_mono_def) }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1017
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1018
    by metis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1019
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1020
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1021
subsubsection\<open>Heine-Borel theorem\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1022
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1023
proposition seq_compact_imp_Heine_Borel:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1024
  fixes S :: "'a :: metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1025
  assumes "seq_compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1026
  shows "compact S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1027
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1028
  from seq_compact_imp_totally_bounded[OF \<open>seq_compact S\<close>]
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1029
  obtain f where f: "\<forall>e>0. finite (f e) \<and> f e \<subseteq> S \<and> S \<subseteq> (\<Union>x\<in>f e. ball x e)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1030
    unfolding choice_iff' ..
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1031
  define K where "K = (\<lambda>(x, r). ball x r) ` ((\<Union>e \<in> \<rat> \<inter> {0 <..}. f e) \<times> \<rat>)"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1032
  have "countably_compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1033
    using \<open>seq_compact S\<close> by (rule seq_compact_imp_countably_compact)
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1034
  then show "compact S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1035
  proof (rule countably_compact_imp_compact)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1036
    show "countable K"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1037
      unfolding K_def using f
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1038
      by (auto intro: countable_finite countable_subset countable_rat
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1039
               intro!: countable_image countable_SIGMA countable_UN)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1040
    show "\<forall>b\<in>K. open b" by (auto simp: K_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1041
  next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1042
    fix T x
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1043
    assume T: "open T" "x \<in> T" and x: "x \<in> S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1044
    from openE[OF T] obtain e where "0 < e" "ball x e \<subseteq> T"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1045
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1046
    then have "0 < e/2" "ball x (e/2) \<subseteq> T"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1047
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1048
    from Rats_dense_in_real[OF \<open>0 < e/2\<close>] obtain r where "r \<in> \<rat>" "0 < r" "r < e/2"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1049
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1050
    from f[rule_format, of r] \<open>0 < r\<close> \<open>x \<in> S\<close> obtain k where "k \<in> f r" "x \<in> ball k r"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1051
      by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1052
    from \<open>r \<in> \<rat>\<close> \<open>0 < r\<close> \<open>k \<in> f r\<close> have "ball k r \<in> K"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1053
      by (auto simp: K_def)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1054
    then show "\<exists>b\<in>K. x \<in> b \<and> b \<inter> S \<subseteq> T"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1055
    proof (rule bexI[rotated], safe)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1056
      fix y
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1057
      assume "y \<in> ball k r"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1058
      with \<open>r < e/2\<close> \<open>x \<in> ball k r\<close> have "dist x y < e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1059
        by (intro dist_triangle_half_r [of k _ e]) (auto simp: dist_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1060
      with \<open>ball x e \<subseteq> T\<close> show "y \<in> T"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1061
        by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1062
    next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1063
      show "x \<in> ball k r" by fact
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1064
    qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1065
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1066
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1067
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1068
proposition compact_eq_seq_compact_metric:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1069
  "compact (S :: 'a::metric_space set) \<longleftrightarrow> seq_compact S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1070
  using compact_imp_seq_compact seq_compact_imp_Heine_Borel by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1071
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1072
proposition compact_def: \<comment> \<open>this is the definition of compactness in HOL Light\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1073
  "compact (S :: 'a::metric_space set) \<longleftrightarrow>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1074
   (\<forall>f. (\<forall>n. f n \<in> S) \<longrightarrow> (\<exists>l\<in>S. \<exists>r::nat\<Rightarrow>nat. strict_mono r \<and> (f \<circ> r) \<longlonglongrightarrow> l))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1075
  unfolding compact_eq_seq_compact_metric seq_compact_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1076
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1077
subsubsection \<open>Complete the chain of compactness variants\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1078
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1079
proposition compact_eq_Bolzano_Weierstrass:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1080
  fixes S :: "'a::metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1081
  shows "compact S \<longleftrightarrow> (\<forall>T. infinite T \<and> T \<subseteq> S \<longrightarrow> (\<exists>x \<in> S. x islimpt T))"
78475
a5f6d2fc1b1f More cosmetic changes
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1082
  by (meson Bolzano_Weierstrass_imp_seq_compact Heine_Borel_imp_Bolzano_Weierstrass seq_compact_imp_Heine_Borel)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1083
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1084
proposition Bolzano_Weierstrass_imp_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1085
  "(\<And>T. \<lbrakk>infinite T; T \<subseteq> S\<rbrakk> \<Longrightarrow> (\<exists>x \<in> S. x islimpt T)) \<Longrightarrow> bounded S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1086
  using compact_imp_bounded unfolding compact_eq_Bolzano_Weierstrass by metis
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1087
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1088
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1089
section \<open>Banach fixed point theorem\<close>
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1090
  
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1091
theorem Banach_fix:
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1092
  assumes s: "complete s" "s \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1093
    and c: "0 \<le> c" "c < 1"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1094
    and f: "f ` s \<subseteq> s"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1095
    and lipschitz: "\<forall>x\<in>s. \<forall>y\<in>s. dist (f x) (f y) \<le> c * dist x y"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1096
  shows "\<exists>!x\<in>s. f x = x"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1097
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1098
  from c have "1 - c > 0" by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1099
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1100
  from s(2) obtain z0 where z0: "z0 \<in> s" by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1101
  define z where "z n = (f ^^ n) z0" for n
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1102
  with f z0 have z_in_s: "z n \<in> s" for n :: nat
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1103
    by (induct n) auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1104
  define d where "d = dist (z 0) (z 1)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1105
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1106
  have fzn: "f (z n) = z (Suc n)" for n
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1107
    by (simp add: z_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1108
  have cf_z: "dist (z n) (z (Suc n)) \<le> (c ^ n) * d" for n :: nat
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1109
  proof (induct n)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1110
    case 0
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1111
    then show ?case
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1112
      by (simp add: d_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1113
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1114
    case (Suc m)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1115
    with \<open>0 \<le> c\<close> have "c * dist (z m) (z (Suc m)) \<le> c ^ Suc m * d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1116
      using mult_left_mono[of "dist (z m) (z (Suc m))" "c ^ m * d" c] by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1117
    then show ?case
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1118
      using lipschitz[THEN bspec[where x="z m"], OF z_in_s, THEN bspec[where x="z (Suc m)"], OF z_in_s]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1119
      by (simp add: fzn mult_le_cancel_left)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1120
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1121
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1122
  have cf_z2: "(1 - c) * dist (z m) (z (m + n)) \<le> (c ^ m) * d * (1 - c ^ n)" for n m :: nat
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1123
  proof (induct n)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1124
    case 0
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1125
    show ?case by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1126
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1127
    case (Suc k)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1128
    from c have "(1 - c) * dist (z m) (z (m + Suc k)) \<le>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1129
        (1 - c) * (dist (z m) (z (m + k)) + dist (z (m + k)) (z (Suc (m + k))))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1130
      by (simp add: dist_triangle)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1131
    also from c cf_z[of "m + k"] have "\<dots> \<le> (1 - c) * (dist (z m) (z (m + k)) + c ^ (m + k) * d)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1132
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1133
    also from Suc have "\<dots> \<le> c ^ m * d * (1 - c ^ k) + (1 - c) * c ^ (m + k) * d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1134
      by (simp add: field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1135
    also have "\<dots> = (c ^ m) * (d * (1 - c ^ k) + (1 - c) * c ^ k * d)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1136
      by (simp add: power_add field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1137
    also from c have "\<dots> \<le> (c ^ m) * d * (1 - c ^ Suc k)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1138
      by (simp add: field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1139
    finally show ?case by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1140
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1141
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1142
  have "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (z m) (z n) < e" if "e > 0" for e
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1143
  proof (cases "d = 0")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1144
    case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1145
    from \<open>1 - c > 0\<close> have "(1 - c) * x \<le> 0 \<longleftrightarrow> x \<le> 0" for x
72569
d56e4eeae967 mult_le_cancel_iff1, mult_le_cancel_iff2, mult_less_iff1 generalised from the real_ versions
paulson <lp15@cam.ac.uk>
parents: 72228
diff changeset
  1146
      by (simp add: mult_le_0_iff)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1147
    with c cf_z2[of 0] True have "z n = z0" for n
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1148
      by (simp add: z_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1149
    with \<open>e > 0\<close> show ?thesis by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1150
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1151
    case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1152
    with zero_le_dist[of "z 0" "z 1"] have "d > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1153
      by (metis d_def less_le)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1154
    with \<open>1 - c > 0\<close> \<open>e > 0\<close> have "0 < e * (1 - c) / d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1155
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1156
    with c obtain N where N: "c ^ N < e * (1 - c) / d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1157
      using real_arch_pow_inv[of "e * (1 - c) / d" c] by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1158
    have *: "dist (z m) (z n) < e" if "m > n" and as: "m \<ge> N" "n \<ge> N" for m n :: nat
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1159
    proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1160
      from c \<open>n \<ge> N\<close> have *: "c ^ n \<le> c ^ N"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1161
        using power_decreasing[OF \<open>n\<ge>N\<close>, of c] by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1162
      from c \<open>m > n\<close> have "1 - c ^ (m - n) > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1163
        using power_strict_mono[of c 1 "m - n"] by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1164
      with \<open>d > 0\<close> \<open>0 < 1 - c\<close> have **: "d * (1 - c ^ (m - n)) / (1 - c) > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1165
        by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1166
      from cf_z2[of n "m - n"] \<open>m > n\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1167
      have "dist (z m) (z n) \<le> c ^ n * d * (1 - c ^ (m - n)) / (1 - c)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1168
        by (simp add: pos_le_divide_eq[OF \<open>1 - c > 0\<close>] mult.commute dist_commute)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1169
      also have "\<dots> \<le> c ^ N * d * (1 - c ^ (m - n)) / (1 - c)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1170
        using mult_right_mono[OF * order_less_imp_le[OF **]]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1171
        by (simp add: mult.assoc)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1172
      also have "\<dots> < (e * (1 - c) / d) * d * (1 - c ^ (m - n)) / (1 - c)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1173
        using mult_strict_right_mono[OF N **] by (auto simp: mult.assoc)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1174
      also from c \<open>1 - c ^ (m - n) > 0\<close> \<open>e > 0\<close> have "\<dots> \<le> e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1175
        using mult_right_le_one_le[of e "1 - c ^ (m - n)"] by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1176
      finally show ?thesis by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1177
    qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1178
    have "dist (z n) (z m) < e" if "N \<le> m" "N \<le> n" for m n :: nat
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1179
      using  *[of n m] *[of m n]
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1180
      using \<open>0 < e\<close> dist_commute_lessI that by fastforce
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1181
    then show ?thesis by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1182
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1183
  then have "Cauchy z"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1184
    by (metis metric_CauchyI)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1185
  then obtain x where "x\<in>s" and x:"(z \<longlongrightarrow> x) sequentially"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1186
    using s(1)[unfolded compact_def complete_def, THEN spec[where x=z]] and z_in_s by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1187
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1188
  define e where "e = dist (f x) x"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1189
  have "e = 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1190
  proof (rule ccontr)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1191
    assume "e \<noteq> 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1192
    then have "e > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1193
      unfolding e_def using zero_le_dist[of "f x" x]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1194
      by (metis dist_eq_0_iff dist_nz e_def)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1195
    then obtain N where N:"\<forall>n\<ge>N. dist (z n) x < e/2"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1196
      using x[unfolded lim_sequentially, THEN spec[where x="e/2"]] by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1197
    then have N':"dist (z N) x < e/2" by auto
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1198
    have *: "c * dist (z N) x \<le> dist (z N) x"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1199
      unfolding mult_le_cancel_right2
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1200
      using zero_le_dist[of "z N" x] and c
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1201
      by (metis dist_eq_0_iff dist_nz order_less_asym less_le)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1202
    have "dist (f (z N)) (f x) \<le> c * dist (z N) x"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1203
      using lipschitz[THEN bspec[where x="z N"], THEN bspec[where x=x]]
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1204
      using z_in_s[of N] \<open>x\<in>s\<close> c
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1205
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1206
    also have "\<dots> < e/2"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1207
      using N' and c using * by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1208
    finally show False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1209
      unfolding fzn
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1210
      using N[THEN spec[where x="Suc N"]] and dist_triangle_half_r[of "z (Suc N)" "f x" e x]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1211
      unfolding e_def
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1212
      by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1213
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1214
  then have "f x = x" by (auto simp: e_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1215
  moreover have "y = x" if "f y = y" "y \<in> s" for y
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1216
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1217
    from \<open>x \<in> s\<close> \<open>f x = x\<close> that have "dist x y \<le> c * dist x y"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1218
      using lipschitz by fastforce
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1219
    with c and zero_le_dist[of x y] have "dist x y = 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1220
      by (simp add: mult_le_cancel_right1)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1221
    then show ?thesis by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1222
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1223
  ultimately show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1224
    using \<open>x\<in>s\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1225
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1226
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1227
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1228
section \<open>Edelstein fixed point theorem\<close>
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1229
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1230
theorem Edelstein_fix:
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1231
  fixes S :: "'a::metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1232
  assumes S: "compact S" "S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1233
    and gs: "(g ` S) \<subseteq> S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1234
    and dist: "\<forall>x\<in>S. \<forall>y\<in>S. x \<noteq> y \<longrightarrow> dist (g x) (g y) < dist x y"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1235
  shows "\<exists>!x\<in>S. g x = x"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1236
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1237
  let ?D = "(\<lambda>x. (x, x)) ` S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1238
  have D: "compact ?D" "?D \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1239
    by (rule compact_continuous_image)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1240
       (auto intro!: S continuous_Pair continuous_ident simp: continuous_on_eq_continuous_within)
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1241
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1242
  have "\<And>x y e. x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> 0 < e \<Longrightarrow> dist y x < e \<Longrightarrow> dist (g y) (g x) < e"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1243
    using dist by fastforce
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1244
  then have "continuous_on S g"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1245
    by (auto simp: continuous_on_iff)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1246
  then have cont: "continuous_on ?D (\<lambda>x. dist ((g \<circ> fst) x) (snd x))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1247
    unfolding continuous_on_eq_continuous_within
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1248
    by (intro continuous_dist ballI continuous_within_compose)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1249
       (auto intro!: continuous_fst continuous_snd continuous_ident simp: image_image)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1250
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1251
  obtain a where "a \<in> S" and le: "\<And>x. x \<in> S \<Longrightarrow> dist (g a) a \<le> dist (g x) x"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1252
    using continuous_attains_inf[OF D cont] by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1253
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1254
  have "g a = a"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1255
    by (metis \<open>a \<in> S\<close> dist gs image_subset_iff le order.strict_iff_not)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1256
  moreover have "\<And>x. x \<in> S \<Longrightarrow> g x = x \<Longrightarrow> x = a"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1257
    using dist[THEN bspec[where x=a]] \<open>g a = a\<close> and \<open>a\<in>S\<close> by auto
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1258
  ultimately show "\<exists>!x\<in>S. g x = x"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1259
    using \<open>a \<in> S\<close> by blast
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1260
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1261
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1262
section \<open>The diameter of a set\<close>
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1263
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1264
definition\<^marker>\<open>tag important\<close> diameter :: "'a::metric_space set \<Rightarrow> real" where
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1265
  "diameter S = (if S = {} then 0 else SUP (x,y)\<in>S\<times>S. dist x y)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1266
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1267
lemma diameter_empty [simp]: "diameter{} = 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1268
  by (auto simp: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1269
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1270
lemma diameter_singleton [simp]: "diameter{x} = 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1271
  by (auto simp: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1272
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1273
lemma diameter_le:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1274
  assumes "S \<noteq> {} \<or> 0 \<le> d"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1275
    and no: "\<And>x y. \<lbrakk>x \<in> S; y \<in> S\<rbrakk> \<Longrightarrow> norm(x - y) \<le> d"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1276
  shows "diameter S \<le> d"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1277
  using assms
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1278
  by (auto simp: dist_norm diameter_def intro: cSUP_least)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1279
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1280
lemma diameter_bounded_bound:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1281
  fixes S :: "'a :: metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1282
  assumes S: "bounded S" "x \<in> S" "y \<in> S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1283
  shows "dist x y \<le> diameter S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1284
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1285
  from S obtain z d where z: "\<And>x. x \<in> S \<Longrightarrow> dist z x \<le> d"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1286
    unfolding bounded_def by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1287
  have "bdd_above (case_prod dist ` (S\<times>S))"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1288
  proof (intro bdd_aboveI, safe)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1289
    fix a b
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1290
    assume "a \<in> S" "b \<in> S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1291
    with z[of a] z[of b] dist_triangle[of a b z]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1292
    show "dist a b \<le> 2 * d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1293
      by (simp add: dist_commute)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1294
  qed
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1295
  moreover have "(x,y) \<in> S\<times>S" using S by auto
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1296
  ultimately have "dist x y \<le> (SUP (x,y)\<in>S\<times>S. dist x y)"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1297
    by (rule cSUP_upper2) simp
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1298
  with \<open>x \<in> S\<close> show ?thesis
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1299
    by (auto simp: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1300
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1301
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1302
lemma diameter_lower_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1303
  fixes S :: "'a :: metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1304
  assumes S: "bounded S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1305
    and d: "0 < d" "d < diameter S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1306
  shows "\<exists>x\<in>S. \<exists>y\<in>S. d < dist x y"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1307
proof (rule ccontr)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1308
  assume contr: "\<not> ?thesis"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1309
  moreover have "S \<noteq> {}"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1310
    using d by (auto simp: diameter_def)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1311
  ultimately have "diameter S \<le> d"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1312
    by (auto simp: not_less diameter_def intro!: cSUP_least)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1313
  with \<open>d < diameter S\<close> show False by auto
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1314
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1315
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1316
lemma diameter_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1317
  assumes "bounded S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1318
  shows "\<forall>x\<in>S. \<forall>y\<in>S. dist x y \<le> diameter S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1319
    and "\<forall>d>0. d < diameter S \<longrightarrow> (\<exists>x\<in>S. \<exists>y\<in>S. dist x y > d)"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1320
  using diameter_bounded_bound[of S] diameter_lower_bounded[of S] assms
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1321
  by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1322
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1323
lemma bounded_two_points: "bounded S \<longleftrightarrow> (\<exists>e. \<forall>x\<in>S. \<forall>y\<in>S. dist x y \<le> e)"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1324
  by (meson bounded_def diameter_bounded(1))
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1325
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1326
lemma diameter_compact_attained:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1327
  assumes "compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1328
    and "S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1329
  shows "\<exists>x\<in>S. \<exists>y\<in>S. dist x y = diameter S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1330
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1331
  have b: "bounded S" using assms(1)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1332
    by (rule compact_imp_bounded)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1333
  then obtain x y where xys: "x\<in>S" "y\<in>S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1334
    and xy: "\<forall>u\<in>S. \<forall>v\<in>S. dist u v \<le> dist x y"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1335
    using compact_sup_maxdistance[OF assms] by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1336
  then have "diameter S \<le> dist x y"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1337
    unfolding diameter_def by (force intro!: cSUP_least)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1338
  then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1339
    by (metis b diameter_bounded_bound order_antisym xys)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1340
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1341
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1342
lemma diameter_ge_0:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1343
  assumes "bounded S"  shows "0 \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1344
  by (metis all_not_in_conv assms diameter_bounded_bound diameter_empty dist_self order_refl)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1345
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1346
lemma diameter_subset:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1347
  assumes "S \<subseteq> T" "bounded T"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1348
  shows "diameter S \<le> diameter T"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1349
proof (cases "S = {} \<or> T = {}")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1350
  case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1351
  with assms show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1352
    by (force simp: diameter_ge_0)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1353
next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1354
  case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1355
  then have "bdd_above ((\<lambda>x. case x of (x, xa) \<Rightarrow> dist x xa) ` (T \<times> T))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1356
    using \<open>bounded T\<close> diameter_bounded_bound by (force simp: bdd_above_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1357
  with False \<open>S \<subseteq> T\<close> show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1358
    apply (simp add: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1359
    apply (rule cSUP_subset_mono, auto)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1360
    done
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1361
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1362
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1363
lemma diameter_closure:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1364
  assumes "bounded S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1365
  shows "diameter(closure S) = diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1366
proof (rule order_antisym)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1367
  have "False" if d_less_d: "diameter S < diameter (closure S)"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1368
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1369
    define d where "d = diameter(closure S) - diameter(S)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1370
    have "d > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1371
      using that by (simp add: d_def)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1372
    then have dle: "diameter(closure(S)) - d / 2 < diameter(closure(S))"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1373
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1374
    have dd: "diameter (closure S) - d / 2 = (diameter(closure(S)) + diameter(S)) / 2"
70817
dd675800469d dedicated fact collections for algebraic simplification rules potentially splitting goals
haftmann
parents: 70724
diff changeset
  1375
      by (simp add: d_def field_split_simps)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1376
     have bocl: "bounded (closure S)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1377
      using assms by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1378
    moreover have "0 \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1379
      using assms diameter_ge_0 by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1380
    ultimately obtain x y where "x \<in> closure S" "y \<in> closure S" and xy: "diameter(closure(S)) - d / 2 < dist x y"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1381
      by (smt (verit) dle d_less_d d_def dd diameter_lower_bounded)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1382
    then obtain x' y' where x'y': "x' \<in> S" "dist x' x < d/4" "y' \<in> S" "dist y' y < d/4"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1383
      by (metis \<open>0 < d\<close> zero_less_divide_iff zero_less_numeral closure_approachable)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1384
    then have "dist x' y' \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1385
      using assms diameter_bounded_bound by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1386
    with x'y' have "dist x y \<le> d / 4 + diameter S + d / 4"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1387
      by (meson add_mono dist_triangle dist_triangle3 less_eq_real_def order_trans)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1388
    then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1389
      using xy d_def by linarith
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1390
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1391
  then show "diameter (closure S) \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1392
    by fastforce
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1393
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1394
    show "diameter S \<le> diameter (closure S)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1395
      by (simp add: assms bounded_closure closure_subset diameter_subset)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1396
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1397
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1398
proposition Lebesgue_number_lemma:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1399
  assumes "compact S" "\<C> \<noteq> {}" "S \<subseteq> \<Union>\<C>" and ope: "\<And>B. B \<in> \<C> \<Longrightarrow> open B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1400
  obtains \<delta> where "0 < \<delta>" "\<And>T. \<lbrakk>T \<subseteq> S; diameter T < \<delta>\<rbrakk> \<Longrightarrow> \<exists>B \<in> \<C>. T \<subseteq> B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1401
proof (cases "S = {}")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1402
  case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1403
  then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1404
    by (metis \<open>\<C> \<noteq> {}\<close> zero_less_one empty_subsetI equals0I subset_trans that)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1405
next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1406
  case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1407
  { fix x assume "x \<in> S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1408
    then obtain C where C: "x \<in> C" "C \<in> \<C>"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1409
      using \<open>S \<subseteq> \<Union>\<C>\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1410
    then obtain r where r: "r>0" "ball x (2*r) \<subseteq> C"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1411
      by (metis field_sum_of_halves half_gt_zero mult.commute mult_2_right ope open_contains_ball)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1412
    then have "\<exists>r C. r > 0 \<and> ball x (2*r) \<subseteq> C \<and> C \<in> \<C>"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1413
      using C by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1414
  }
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1415
  then obtain r where r: "\<And>x. x \<in> S \<Longrightarrow> r x > 0 \<and> (\<exists>C \<in> \<C>. ball x (2*r x) \<subseteq> C)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1416
    by metis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1417
  then have "S \<subseteq> (\<Union>x \<in> S. ball x (r x))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1418
    by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1419
  then obtain \<T> where "finite \<T>" "S \<subseteq> \<Union>\<T>" and \<T>: "\<T> \<subseteq> (\<lambda>x. ball x (r x)) ` S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1420
    by (rule compactE [OF \<open>compact S\<close>]) auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1421
  then obtain S0 where "S0 \<subseteq> S" "finite S0" and S0: "\<T> = (\<lambda>x. ball x (r x)) ` S0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1422
    by (meson finite_subset_image)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1423
  then have "S0 \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1424
    using False \<open>S \<subseteq> \<Union>\<T>\<close> by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1425
  define \<delta> where "\<delta> = Inf (r ` S0)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1426
  have "\<delta> > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1427
    using \<open>finite S0\<close> \<open>S0 \<subseteq> S\<close> \<open>S0 \<noteq> {}\<close> r by (auto simp: \<delta>_def finite_less_Inf_iff)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1428
  show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1429
  proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1430
    show "0 < \<delta>"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1431
      by (simp add: \<open>0 < \<delta>\<close>)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1432
    show "\<exists>B \<in> \<C>. T \<subseteq> B" if "T \<subseteq> S" and dia: "diameter T < \<delta>" for T
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1433
    proof (cases "T = {}")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1434
      case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1435
      then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1436
        using \<open>\<C> \<noteq> {}\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1437
    next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1438
      case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1439
      then obtain y where "y \<in> T" by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1440
      then have "y \<in> S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1441
        using \<open>T \<subseteq> S\<close> by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1442
      then obtain x where "x \<in> S0" and x: "y \<in> ball x (r x)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1443
        using \<open>S \<subseteq> \<Union>\<T>\<close> S0 that by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1444
      have "ball y \<delta> \<subseteq> ball y (r x)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1445
        by (metis \<delta>_def \<open>S0 \<noteq> {}\<close> \<open>finite S0\<close> \<open>x \<in> S0\<close> empty_is_image finite_imageI finite_less_Inf_iff imageI less_irrefl not_le subset_ball)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1446
      also have "... \<subseteq> ball x (2*r x)"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  1447
        using x by metric
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1448
      finally obtain C where "C \<in> \<C>" "ball y \<delta> \<subseteq> C"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1449
        by (meson r \<open>S0 \<subseteq> S\<close> \<open>x \<in> S0\<close> dual_order.trans subsetCE)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1450
      have "bounded T"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1451
        using \<open>compact S\<close> bounded_subset compact_imp_bounded \<open>T \<subseteq> S\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1452
      then have "T \<subseteq> ball y \<delta>"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1453
        using \<open>y \<in> T\<close> dia diameter_bounded_bound by fastforce
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1454
      then show ?thesis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1455
        by (meson \<open>C \<in> \<C>\<close> \<open>ball y \<delta> \<subseteq> C\<close> subset_eq)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1456
    qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1457
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1458
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1459
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1460
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1461
section \<open>Metric spaces with the Heine-Borel property\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1462
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1463
text \<open>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1464
  A metric space (or topological vector space) is said to have the
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1465
  Heine-Borel property if every closed and bounded subset is compact.
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1466
\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1467
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1468
class heine_borel = metric_space +
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1469
  assumes bounded_imp_convergent_subsequence:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1470
    "bounded (range f) \<Longrightarrow> \<exists>l r. strict_mono (r::nat\<Rightarrow>nat) \<and> ((f \<circ> r) \<longlongrightarrow> l) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1471
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1472
proposition bounded_closed_imp_seq_compact:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1473
  fixes S::"'a::heine_borel set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1474
  assumes "bounded S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1475
    and "closed S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1476
  shows "seq_compact S"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1477
  unfolding seq_compact_def
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1478
proof (intro strip)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1479
  fix f :: "nat \<Rightarrow> 'a"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1480
  assume f: "\<forall>n. f n \<in> S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1481
  with \<open>bounded S\<close> have "bounded (range f)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1482
    by (auto intro: bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1483
  obtain l r where r: "strict_mono (r :: nat \<Rightarrow> nat)" and l: "((f \<circ> r) \<longlongrightarrow> l) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1484
    using bounded_imp_convergent_subsequence [OF \<open>bounded (range f)\<close>] by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1485
  from f have fr: "\<forall>n. (f \<circ> r) n \<in> S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1486
    by simp
78475
a5f6d2fc1b1f More cosmetic changes
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1487
  show "\<exists>l\<in>S. \<exists>r. strict_mono r \<and> (f \<circ> r) \<longlonglongrightarrow> l"
a5f6d2fc1b1f More cosmetic changes
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  1488
    using assms(2) closed_sequentially fr l r by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1489
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1490
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1491
lemma compact_eq_bounded_closed:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1492
  fixes S :: "'a::heine_borel set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1493
  shows "compact S \<longleftrightarrow> bounded S \<and> closed S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1494
  using bounded_closed_imp_seq_compact compact_eq_seq_compact_metric compact_imp_bounded compact_imp_closed 
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1495
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1496
73885
26171a89466a A few useful lemmas about derivatives, colinearity and other topics
paulson <lp15@cam.ac.uk>
parents: 72569
diff changeset
  1497
lemma bounded_infinite_imp_islimpt:
26171a89466a A few useful lemmas about derivatives, colinearity and other topics
paulson <lp15@cam.ac.uk>
parents: 72569
diff changeset
  1498
  fixes S :: "'a::heine_borel set"
26171a89466a A few useful lemmas about derivatives, colinearity and other topics
paulson <lp15@cam.ac.uk>
parents: 72569
diff changeset
  1499
  assumes "T \<subseteq> S" "bounded S" "infinite T"
26171a89466a A few useful lemmas about derivatives, colinearity and other topics
paulson <lp15@cam.ac.uk>
parents: 72569
diff changeset
  1500
  obtains x where "x islimpt S" 
26171a89466a A few useful lemmas about derivatives, colinearity and other topics
paulson <lp15@cam.ac.uk>
parents: 72569
diff changeset
  1501
  by (meson assms closed_limpt compact_eq_Bolzano_Weierstrass compact_eq_bounded_closed islimpt_subset) 
26171a89466a A few useful lemmas about derivatives, colinearity and other topics
paulson <lp15@cam.ac.uk>
parents: 72569
diff changeset
  1502
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1503
lemma compact_Inter:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1504
  fixes \<F> :: "'a :: heine_borel set set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1505
  assumes com: "\<And>S. S \<in> \<F> \<Longrightarrow> compact S" and "\<F> \<noteq> {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1506
  shows "compact(\<Inter> \<F>)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1507
  using assms
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1508
  by (meson Inf_lower all_not_in_conv bounded_subset closed_Inter compact_eq_bounded_closed)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1509
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1510
lemma compact_closure [simp]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1511
  fixes S :: "'a::heine_borel set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1512
  shows "compact(closure S) \<longleftrightarrow> bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1513
by (meson bounded_closure bounded_subset closed_closure closure_subset compact_eq_bounded_closed)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1514
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1515
instance\<^marker>\<open>tag important\<close> real :: heine_borel
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1516
proof
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1517
  fix f :: "nat \<Rightarrow> real"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1518
  assume f: "bounded (range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1519
  obtain r :: "nat \<Rightarrow> nat" where r: "strict_mono r" "monoseq (f \<circ> r)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1520
    unfolding comp_def by (metis seq_monosub)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1521
  then have "Bseq (f \<circ> r)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1522
    unfolding Bseq_eq_bounded by (metis f BseqI' bounded_iff comp_apply rangeI)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1523
  with r show "\<exists>l r. strict_mono r \<and> (f \<circ> r) \<longlonglongrightarrow> l"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1524
    using Bseq_monoseq_convergent[of "f \<circ> r"] by (auto simp: convergent_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1525
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1526
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1527
lemma compact_lemma_general:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1528
  fixes f :: "nat \<Rightarrow> 'a"
80914
d97fdabd9e2b standardize mixfix annotations via "isabelle update -a -u mixfix_cartouches" --- to simplify systematic editing;
wenzelm
parents: 80133
diff changeset
  1529
  fixes proj::"'a \<Rightarrow> 'b \<Rightarrow> 'c::heine_borel" (infixl \<open>proj\<close> 60)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1530
  fixes unproj:: "('b \<Rightarrow> 'c) \<Rightarrow> 'a"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1531
  assumes finite_basis: "finite basis"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1532
  assumes bounded_proj: "\<And>k. k \<in> basis \<Longrightarrow> bounded ((\<lambda>x. x proj k) ` range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1533
  assumes proj_unproj: "\<And>e k. k \<in> basis \<Longrightarrow> (unproj e) proj k = e k"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1534
  assumes unproj_proj: "\<And>x. unproj (\<lambda>k. x proj k) = x"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1535
  shows "\<forall>d\<subseteq>basis. \<exists>l::'a. \<exists> r::nat\<Rightarrow>nat.
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1536
    strict_mono r \<and> (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) proj i) (l proj i) < e) sequentially)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1537
proof safe
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1538
  fix d :: "'b set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1539
  assume d: "d \<subseteq> basis"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1540
  with finite_basis have "finite d"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1541
    by (blast intro: finite_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1542
  from this d show "\<exists>l::'a. \<exists>r::nat\<Rightarrow>nat. strict_mono r \<and>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1543
    (\<forall>e>0. eventually (\<lambda>n. \<forall>i\<in>d. dist (f (r n) proj i) (l proj i) < e) sequentially)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1544
  proof (induct d)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1545
    case empty
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1546
    then show ?case
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1547
      unfolding strict_mono_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1548
  next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1549
    case (insert k d)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1550
    have k[intro]: "k \<in> basis"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1551
      using insert by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1552
    have s': "bounded ((\<lambda>x. x proj k) ` range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1553
      using k
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1554
      by (rule bounded_proj)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1555
    obtain l1::"'a" and r1 where r1: "strict_mono r1"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1556
      and lr1: "\<forall>e > 0. \<forall>\<^sub>F n in sequentially. \<forall>i\<in>d. dist (f (r1 n) proj i) (l1 proj i) < e"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1557
      using insert by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1558
    have f': "\<forall>n. f (r1 n) proj k \<in> (\<lambda>x. x proj k) ` range f"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1559
      by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1560
    have "bounded (range (\<lambda>i. f (r1 i) proj k))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1561
      by (metis (lifting) bounded_subset f' image_subsetI s')
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1562
    then obtain l2 r2 where r2: "strict_mono r2" and lr2: "(\<lambda>i. f (r1 (r2 i)) proj k) \<longlonglongrightarrow> l2"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1563
      using bounded_imp_convergent_subsequence[of "\<lambda>i. f (r1 i) proj k"]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1564
      by (auto simp: o_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1565
    define r where "r = r1 \<circ> r2"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1566
    have r: "strict_mono r"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1567
      using r1 and r2 unfolding r_def o_def strict_mono_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1568
    moreover
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1569
    define l where "l = unproj (\<lambda>i. if i = k then l2 else l1 proj i)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1570
    { fix e::real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1571
      assume "e > 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1572
      from lr1 \<open>e > 0\<close> have N1: "\<forall>\<^sub>F n in sequentially. \<forall>i\<in>d. dist (f (r1 n) proj i) (l1 proj i) < e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1573
        by blast
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1574
      from lr2 \<open>e > 0\<close> have N2: "\<forall>\<^sub>F n in sequentially. dist (f (r1 (r2 n)) proj k) l2 < e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1575
        by (rule tendstoD)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1576
      from r2 N1 have N1': "\<forall>\<^sub>F n in sequentially. \<forall>i\<in>d. dist (f (r1 (r2 n)) proj i) (l1 proj i) < e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1577
        by (rule eventually_subseq)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1578
      have "\<forall>\<^sub>F n in sequentially. \<forall>i\<in>insert k d. dist (f (r n) proj i) (l proj i) < e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1579
        using N1' N2
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1580
        by eventually_elim (use insert.prems in \<open>auto simp: l_def r_def o_def proj_unproj\<close>)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1581
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1582
    ultimately show ?case by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1583
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1584
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1585
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1586
lemma bounded_fst: "bounded s \<Longrightarrow> bounded (fst ` s)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1587
  unfolding bounded_def
73932
fd21b4a93043 added opaque_combs and renamed hide_lams to opaque_lifting
desharna
parents: 72569
diff changeset
  1588
  by (metis (erased, opaque_lifting) dist_fst_le image_iff order_trans)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1589
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1590
lemma bounded_snd: "bounded s \<Longrightarrow> bounded (snd ` s)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1591
  unfolding bounded_def
73932
fd21b4a93043 added opaque_combs and renamed hide_lams to opaque_lifting
desharna
parents: 72569
diff changeset
  1592
  by (metis (no_types, opaque_lifting) dist_snd_le image_iff order.trans)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1593
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1594
instance\<^marker>\<open>tag important\<close> prod :: (heine_borel, heine_borel) heine_borel
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1595
proof
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1596
  fix f :: "nat \<Rightarrow> 'a \<times> 'b"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1597
  assume f: "bounded (range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1598
  then have "bounded (fst ` range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1599
    by (rule bounded_fst)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1600
  then have s1: "bounded (range (fst \<circ> f))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1601
    by (simp add: image_comp)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1602
  obtain l1 r1 where r1: "strict_mono r1" and l1: "(\<lambda>n. fst (f (r1 n))) \<longlonglongrightarrow> l1"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1603
    using bounded_imp_convergent_subsequence [OF s1] unfolding o_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1604
  from f have s2: "bounded (range (snd \<circ> f \<circ> r1))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1605
    by (auto simp: image_comp intro: bounded_snd bounded_subset)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1606
  obtain l2 r2 where r2: "strict_mono r2" and l2: "(\<lambda>n. snd (f (r1 (r2 n)))) \<longlonglongrightarrow> l2"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1607
    using bounded_imp_convergent_subsequence [OF s2]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1608
    unfolding o_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1609
  have l1': "((\<lambda>n. fst (f (r1 (r2 n)))) \<longlongrightarrow> l1) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1610
    using LIMSEQ_subseq_LIMSEQ [OF l1 r2] unfolding o_def .
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1611
  have l: "((f \<circ> (r1 \<circ> r2)) \<longlongrightarrow> (l1, l2)) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1612
    using tendsto_Pair [OF l1' l2] unfolding o_def by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1613
  have r: "strict_mono (r1 \<circ> r2)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1614
    using r1 r2 unfolding strict_mono_def by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1615
  show "\<exists>l r. strict_mono r \<and> ((f \<circ> r) \<longlongrightarrow> l) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1616
    using l r by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1617
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1618
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1619
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1620
section \<open>Completeness\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1621
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1622
proposition (in metric_space) completeI:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1623
  assumes "\<And>f. \<forall>n. f n \<in> s \<Longrightarrow> Cauchy f \<Longrightarrow> \<exists>l\<in>s. f \<longlonglongrightarrow> l"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1624
  shows "complete s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1625
  using assms unfolding complete_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1626
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1627
proposition (in metric_space) completeE:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1628
  assumes "complete s" and "\<forall>n. f n \<in> s" and "Cauchy f"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1629
  obtains l where "l \<in> s" and "f \<longlonglongrightarrow> l"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1630
  using assms unfolding complete_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1631
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1632
(* TODO: generalize to uniform spaces *)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1633
lemma compact_imp_complete:
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1634
  fixes S :: "'a::metric_space set"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1635
  assumes "compact S"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1636
  shows "complete S"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1637
  unfolding complete_def
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1638
proof clarify
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1639
  fix f
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1640
  assume as: "(\<forall>n::nat. f n \<in> S)" "Cauchy f"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1641
  from as(1) obtain l r where lr: "l\<in>S" "strict_mono r" "(f \<circ> r) \<longlonglongrightarrow> l"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1642
    using assms unfolding compact_def by blast
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1643
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1644
  note lr' = seq_suble [OF lr(2)]
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1645
  {
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1646
    fix e :: real
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1647
    assume "e > 0"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1648
    from as(2) obtain N where N:"\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (f m) (f n) < e/2"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1649
      unfolding Cauchy_def using \<open>e > 0\<close> by (meson half_gt_zero)
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1650
    then obtain M where M:"\<forall>n\<ge>M. dist ((f \<circ> r) n) l < e/2"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1651
      by (metis dist_self lim_sequentially lr(3))
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1652
    {
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1653
      fix n :: nat
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1654
      assume n: "n \<ge> max N M"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1655
      have "dist ((f \<circ> r) n) l < e/2"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1656
        using n M by auto
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1657
      moreover have "r n \<ge> N"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1658
        using lr'[of n] n by auto
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1659
      then have "dist (f n) ((f \<circ> r) n) < e/2"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1660
        using N and n by auto
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1661
      ultimately have "dist (f n) l < e" using n M
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1662
        by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1663
    }
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1664
    then have "\<exists>N. \<forall>n\<ge>N. dist (f n) l < e" by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1665
  }
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1666
  then show "\<exists>l\<in>S. (f \<longlongrightarrow> l) sequentially" using \<open>l\<in>S\<close>
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1667
    unfolding lim_sequentially by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1668
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1669
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1670
proposition compact_eq_totally_bounded:
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1671
  "compact S \<longleftrightarrow> complete S \<and> (\<forall>e>0. \<exists>k. finite k \<and> S \<subseteq> (\<Union>x\<in>k. ball x e))"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1672
    (is "_ \<longleftrightarrow> ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1673
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1674
  assume assms: "?rhs"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1675
  then obtain k where k: "\<And>e. 0 < e \<Longrightarrow> finite (k e)" "\<And>e. 0 < e \<Longrightarrow> S \<subseteq> (\<Union>x\<in>k e. ball x e)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1676
    by (auto simp: choice_iff')
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1677
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1678
  show "compact S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1679
  proof cases
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1680
    assume "S = {}"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1681
    then show "compact S" by (simp add: compact_def)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1682
  next
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1683
    assume "S \<noteq> {}"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1684
    show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1685
      unfolding compact_def
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1686
    proof safe
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1687
      fix f :: "nat \<Rightarrow> 'a"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1688
      assume f: "\<forall>n. f n \<in> S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1689
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1690
      define e where "e n = 1 / (2 * Suc n)" for n
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1691
      then have [simp]: "\<And>n. 0 < e n" by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1692
      define B where "B n U = (SOME b. infinite {n. f n \<in> b} \<and> (\<exists>x. b \<subseteq> ball x (e n) \<inter> U))" for n U
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1693
      {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1694
        fix n U
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1695
        assume "infinite {n. f n \<in> U}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1696
        then have "\<exists>b\<in>k (e n). infinite {i\<in>{n. f n \<in> U}. f i \<in> ball b (e n)}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1697
          using k f by (intro pigeonhole_infinite_rel) (auto simp: subset_eq)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1698
        then obtain a where
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1699
          "a \<in> k (e n)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1700
          "infinite {i \<in> {n. f n \<in> U}. f i \<in> ball a (e n)}" ..
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1701
        then have "\<exists>b. infinite {i. f i \<in> b} \<and> (\<exists>x. b \<subseteq> ball x (e n) \<inter> U)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1702
          by (intro exI[of _ "ball a (e n) \<inter> U"] exI[of _ a]) (auto simp: ac_simps)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1703
        from someI_ex[OF this]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1704
        have "infinite {i. f i \<in> B n U}" "\<exists>x. B n U \<subseteq> ball x (e n) \<inter> U"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1705
          unfolding B_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1706
      }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1707
      note B = this
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1708
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1709
      define F where "F = rec_nat (B 0 UNIV) B"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1710
      {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1711
        fix n
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1712
        have "infinite {i. f i \<in> F n}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1713
          by (induct n) (auto simp: F_def B)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1714
      }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1715
      then have F: "\<And>n. \<exists>x. F (Suc n) \<subseteq> ball x (e n) \<inter> F n"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1716
        using B by (simp add: F_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1717
      then have F_dec: "\<And>m n. m \<le> n \<Longrightarrow> F n \<subseteq> F m"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1718
        using decseq_SucI[of F] by (auto simp: decseq_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1719
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1720
      obtain sel where sel: "\<And>k i. i < sel k i" "\<And>k i. f (sel k i) \<in> F k"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1721
      proof (atomize_elim, unfold all_conj_distrib[symmetric], intro choice allI)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1722
        fix k i
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1723
        have "infinite ({n. f n \<in> F k} - {.. i})"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1724
          using \<open>infinite {n. f n \<in> F k}\<close> by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1725
        from infinite_imp_nonempty[OF this]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1726
        show "\<exists>x>i. f x \<in> F k"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1727
          by (simp add: set_eq_iff not_le conj_commute)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1728
      qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1729
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1730
      define t where "t = rec_nat (sel 0 0) (\<lambda>n i. sel (Suc n) i)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1731
      have "strict_mono t"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1732
        unfolding strict_mono_Suc_iff by (simp add: t_def sel)
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1733
      moreover have "\<forall>i. (f \<circ> t) i \<in> S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1734
        using f by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1735
      moreover
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1736
      have t: "(f \<circ> t) n \<in> F n" for n
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1737
        by (cases n) (simp_all add: t_def sel)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1738
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1739
      have "Cauchy (f \<circ> t)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1740
      proof (safe intro!: metric_CauchyI exI elim!: nat_approx_posE)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1741
        fix r :: real and N n m
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1742
        assume "1 / Suc N < r" "Suc N \<le> n" "Suc N \<le> m"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1743
        then have "(f \<circ> t) n \<in> F (Suc N)" "(f \<circ> t) m \<in> F (Suc N)" "2 * e N < r"
71174
nipkow
parents: 71028
diff changeset
  1744
          using F_dec t by (auto simp: e_def field_simps)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1745
        with F[of N] obtain x where "dist x ((f \<circ> t) n) < e N" "dist x ((f \<circ> t) m) < e N"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1746
          by (auto simp: subset_eq)
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  1747
        with \<open>2 * e N < r\<close> show "dist ((f \<circ> t) m) ((f \<circ> t) n) < r"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  1748
          by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1749
      qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1750
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1751
      ultimately show "\<exists>l\<in>S. \<exists>r. strict_mono r \<and> (f \<circ> r) \<longlonglongrightarrow> l"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1752
        using assms unfolding complete_def by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1753
    qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1754
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1755
qed (metis compact_imp_complete compact_imp_seq_compact seq_compact_imp_totally_bounded)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1756
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1757
lemma cauchy_imp_bounded:
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1758
  assumes "Cauchy S"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1759
  shows "bounded (range S)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1760
proof -
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1761
  from assms obtain N :: nat where "\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (S m) (S n) < 1"
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1762
    by (meson Cauchy_def zero_less_one)
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1763
  then have N:"\<forall>n. N \<le> n \<longrightarrow> dist (S N) (S n) < 1" by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1764
  moreover
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1765
  have "bounded (S ` {0..N})"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1766
    using finite_imp_bounded[of "S ` {1..N}"] by auto
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1767
  then obtain a where a:"\<forall>x\<in>S ` {0..N}. dist (S N) x \<le> a"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1768
    unfolding bounded_any_center [where a="S N"] by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1769
  ultimately show "?thesis"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1770
    unfolding bounded_any_center [where a="S N"]
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1771
    apply (intro exI [where x="max a 1"])
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1772
    apply (force simp: le_max_iff_disj less_le_not_le)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1773
    done
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1774
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1775
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1776
instance heine_borel < complete_space
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1777
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1778
  fix f :: "nat \<Rightarrow> 'a" assume "Cauchy f"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1779
  then show "convergent f"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1780
    unfolding convergent_def
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1781
    using Cauchy_converges_subseq cauchy_imp_bounded bounded_imp_convergent_subsequence by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1782
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1783
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1784
lemma complete_UNIV: "complete (UNIV :: ('a::complete_space) set)"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1785
  by (meson Cauchy_convergent UNIV_I completeI convergent_def)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1786
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1787
lemma complete_imp_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1788
  fixes S :: "'a::metric_space set"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1789
  shows "complete S \<Longrightarrow> closed S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1790
  by (metis LIMSEQ_imp_Cauchy LIMSEQ_unique closed_sequential_limits completeE)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1791
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1792
lemma complete_Int_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1793
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1794
  assumes "complete S" and "closed t"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1795
  shows "complete (S \<inter> t)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1796
  by (metis Int_iff assms closed_sequentially completeE completeI)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1797
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1798
lemma complete_closed_subset:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1799
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1800
  assumes "closed S" and "S \<subseteq> t" and "complete t"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1801
  shows "complete S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1802
  using assms complete_Int_closed [of t S] by (simp add: Int_absorb1)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1803
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1804
lemma complete_eq_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1805
  fixes S :: "('a::complete_space) set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1806
  shows "complete S \<longleftrightarrow> closed S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1807
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1808
  assume "closed S" then show "complete S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1809
    using subset_UNIV complete_UNIV by (rule complete_closed_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1810
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1811
  assume "complete S" then show "closed S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1812
    by (rule complete_imp_closed)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1813
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1814
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1815
lemma convergent_eq_Cauchy:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1816
  fixes S :: "nat \<Rightarrow> 'a::complete_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1817
  shows "(\<exists>l. (S \<longlongrightarrow> l) sequentially) \<longleftrightarrow> Cauchy S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1818
  unfolding Cauchy_convergent_iff convergent_def ..
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1819
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1820
lemma convergent_imp_bounded:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1821
  fixes S :: "nat \<Rightarrow> 'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1822
  shows "(S \<longlongrightarrow> l) sequentially \<Longrightarrow> bounded (range S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1823
  by (intro cauchy_imp_bounded LIMSEQ_imp_Cauchy)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1824
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1825
lemma frontier_subset_compact:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1826
  fixes S :: "'a::heine_borel set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1827
  shows "compact S \<Longrightarrow> frontier S \<subseteq> S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1828
  using frontier_subset_closed compact_eq_bounded_closed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1829
  by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1830
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1831
lemma banach_fix_type:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1832
  fixes f::"'a::complete_space\<Rightarrow>'a"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1833
  assumes c:"0 \<le> c" "c < 1"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1834
      and lipschitz:"\<forall>x. \<forall>y. dist (f x) (f y) \<le> c * dist x y"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1835
  shows "\<exists>!x. (f x = x)"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1836
  using assms Banach_fix[OF complete_UNIV UNIV_not_empty c subset_UNIV, of f]
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1837
  by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1838
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1839
section \<open>Cauchy continuity\<close>
78131
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1840
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1841
definition Cauchy_continuous_on where
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1842
  "Cauchy_continuous_on \<equiv> \<lambda>S f. \<forall>\<sigma>. Cauchy \<sigma> \<longrightarrow> range \<sigma> \<subseteq> S \<longrightarrow> Cauchy (f \<circ> \<sigma>)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1843
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1844
lemma continuous_closed_imp_Cauchy_continuous:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1845
  fixes S :: "('a::complete_space) set"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1846
  shows "\<lbrakk>continuous_on S f; closed S\<rbrakk> \<Longrightarrow> Cauchy_continuous_on S f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1847
  unfolding Cauchy_continuous_on_def
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1848
  by (metis LIMSEQ_imp_Cauchy completeE complete_eq_closed continuous_on_sequentially range_subsetD)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1849
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1850
lemma uniformly_continuous_imp_Cauchy_continuous:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1851
  fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1852
  shows "uniformly_continuous_on S f \<Longrightarrow> Cauchy_continuous_on S f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1853
  by (simp add: uniformly_continuous_on_def Cauchy_continuous_on_def Cauchy_def image_subset_iff) metis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1854
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1855
lemma Cauchy_continuous_on_imp_continuous:
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1856
  fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1857
  assumes "Cauchy_continuous_on S f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1858
  shows "continuous_on S f"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1859
proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1860
  have False if x: "\<forall>n. \<exists>x'\<in>S. dist x' x < inverse(Suc n) \<and> \<not> dist (f x') (f x) < \<epsilon>" "\<epsilon>>0" "x \<in> S" for x and \<epsilon>::real
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1861
  proof -
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1862
    obtain \<rho> where \<rho>: "\<forall>n. \<rho> n \<in> S" and dx: "\<forall>n. dist (\<rho> n) x < inverse(Suc n)" and dfx: "\<forall>n. \<not> dist (f (\<rho> n)) (f x) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1863
      using x by metis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1864
    define \<sigma> where "\<sigma> \<equiv> \<lambda>n. if even n then \<rho> n else x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1865
    with \<rho> \<open>x \<in> S\<close> have "range \<sigma> \<subseteq> S"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1866
      by auto
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1867
    have "\<sigma> \<longlonglongrightarrow> x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1868
      unfolding tendsto_iff
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1869
    proof (intro strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1870
      fix e :: real
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1871
      assume "e>0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1872
      then obtain N where "inverse (Suc N) < e"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1873
        using reals_Archimedean by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1874
      then have "\<forall>n. N \<le> n \<longrightarrow> dist (\<rho> n) x < e"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1875
        by (smt (verit, ccfv_SIG) dx inverse_Suc inverse_less_iff_less inverse_positive_iff_positive of_nat_Suc of_nat_mono)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1876
      with \<open>e>0\<close> show "\<forall>\<^sub>F n in sequentially. dist (\<sigma> n) x < e"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1877
        by (auto simp add: eventually_sequentially \<sigma>_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1878
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1879
    then have "Cauchy \<sigma>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1880
      by (intro LIMSEQ_imp_Cauchy)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1881
    then have Cf: "Cauchy (f \<circ> \<sigma>)"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1882
      by (meson Cauchy_continuous_on_def \<open>range \<sigma> \<subseteq> S\<close> assms)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1883
    have "(f \<circ> \<sigma>) \<longlonglongrightarrow> f x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1884
      unfolding tendsto_iff 
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1885
    proof (intro strip)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1886
      fix e :: real
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1887
      assume "e>0"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1888
      then obtain N where N: "\<forall>m\<ge>N. \<forall>n\<ge>N. dist ((f \<circ> \<sigma>) m) ((f \<circ> \<sigma>) n) < e"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1889
        using Cf unfolding Cauchy_def by presburger
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1890
      moreover have "(f \<circ> \<sigma>) (Suc(N+N)) = f x"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1891
        by (simp add: \<sigma>_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1892
      ultimately have "\<forall>n\<ge>N. dist ((f \<circ> \<sigma>) n) (f x) < e"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1893
        by (metis add_Suc le_add2)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1894
      then show "\<forall>\<^sub>F n in sequentially. dist ((f \<circ> \<sigma>) n) (f x) < e"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1895
        using eventually_sequentially by blast
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1896
    qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1897
    moreover have "\<And>n. \<not> dist (f (\<sigma> (2*n))) (f x) < \<epsilon>"
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1898
      using dfx by (simp add: \<sigma>_def)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1899
    ultimately show False
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1900
      using \<open>\<epsilon>>0\<close> by (fastforce simp: mult_2 nat_le_iff_add tendsto_iff eventually_sequentially)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1901
  qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1902
  then show ?thesis
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1903
    unfolding continuous_on_iff by (meson inverse_Suc)
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1904
qed
1cadc477f644 Even more material from the HOL Light metric space library
paulson <lp15@cam.ac.uk>
parents: 78037
diff changeset
  1905
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1906
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1907
section\<^marker>\<open>tag unimportant\<close>\<open> Finite intersection property\<close>
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1908
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1909
text\<open>Also developed in HOL's toplogical spaces theory, but the Heine-Borel type class isn't available there.\<close>
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1910
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1911
lemma closed_imp_fip:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1912
  fixes S :: "'a::heine_borel set"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1913
  assumes "closed S"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1914
      and T: "T \<in> \<F>" "bounded T"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1915
      and clof: "\<And>T. T \<in> \<F> \<Longrightarrow> closed T"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1916
      and "\<And>\<F>'. \<lbrakk>finite \<F>'; \<F>' \<subseteq> \<F>\<rbrakk> \<Longrightarrow> S \<inter> \<Inter>\<F>' \<noteq> {}"
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1917
    shows "S \<inter> \<Inter>\<F> \<noteq> {}"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1918
proof -
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1919
  have "compact (S \<inter> T)"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1920
    using \<open>closed S\<close> clof compact_eq_bounded_closed T by blast
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1921
  then have "(S \<inter> T) \<inter> \<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1922
    by (smt (verit, best) Inf_insert Int_assoc assms compact_imp_fip finite_insert insert_subset)
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1923
  then show ?thesis by blast
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1924
qed
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1925
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1926
lemma closed_imp_fip_compact:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1927
  fixes S :: "'a::heine_borel set"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1928
  shows
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1929
   "\<lbrakk>closed S; \<And>T. T \<in> \<F> \<Longrightarrow> compact T;
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1930
     \<And>\<F>'. \<lbrakk>finite \<F>'; \<F>' \<subseteq> \<F>\<rbrakk> \<Longrightarrow> S \<inter> \<Inter>\<F>' \<noteq> {}\<rbrakk> \<Longrightarrow> S \<inter> \<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1931
  by (metis closed_imp_fip compact_eq_bounded_closed equals0I finite.emptyI order.refl)
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1932
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1933
lemma closed_fip_Heine_Borel:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1934
  fixes \<F> :: "'a::heine_borel set set"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1935
  assumes "T \<in> \<F>" "bounded T"
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1936
      and "\<And>T. T \<in> \<F> \<Longrightarrow> closed T"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1937
      and "\<And>\<F>'. \<lbrakk>finite \<F>'; \<F>' \<subseteq> \<F>\<rbrakk> \<Longrightarrow> \<Inter>\<F>' \<noteq> {}"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1938
    shows "\<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1939
  using closed_imp_fip [OF closed_UNIV] assms by auto
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1940
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1941
lemma compact_fip_Heine_Borel:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1942
  fixes \<F> :: "'a::heine_borel set set"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1943
  assumes clof: "\<And>T. T \<in> \<F> \<Longrightarrow> compact T"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1944
      and none: "\<And>\<F>'. \<lbrakk>finite \<F>'; \<F>' \<subseteq> \<F>\<rbrakk> \<Longrightarrow> \<Inter>\<F>' \<noteq> {}"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1945
    shows "\<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1946
  by (metis InterI clof closed_fip_Heine_Borel compact_eq_bounded_closed equals0D none)
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1947
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1948
lemma compact_sequence_with_limit:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1949
  fixes f :: "nat \<Rightarrow> 'a::heine_borel"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1950
  shows "f \<longlonglongrightarrow> l \<Longrightarrow> compact (insert l (range f))"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1951
  by (simp add: closed_limpt compact_eq_bounded_closed convergent_imp_bounded islimpt_insert sequence_unique_limpt)
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1952
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1953
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1954
section \<open>Properties of Balls and Spheres\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1955
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1956
lemma compact_cball[simp]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1957
  fixes x :: "'a::heine_borel"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1958
  shows "compact (cball x e)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1959
  using compact_eq_bounded_closed bounded_cball closed_cball by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1960
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1961
lemma compact_frontier_bounded[intro]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1962
  fixes S :: "'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1963
  shows "bounded S \<Longrightarrow> compact (frontier S)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1964
  unfolding frontier_def
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1965
  using compact_eq_bounded_closed by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1966
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1967
lemma compact_frontier[intro]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1968
  fixes S :: "'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1969
  shows "compact S \<Longrightarrow> compact (frontier S)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1970
  using compact_eq_bounded_closed compact_frontier_bounded by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1971
77179
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1972
lemma no_limpt_imp_countable:
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1973
  assumes "\<And>z. \<not>z islimpt (X :: 'a :: {real_normed_vector, heine_borel} set)"
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1974
  shows   "countable X"
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1975
proof -
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1976
  have "countable (\<Union>n. cball 0 (real n) \<inter> X)"
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1977
  proof (intro countable_UN[OF _ countable_finite])
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1978
    fix n :: nat
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1979
    show "finite (cball 0 (real n) \<inter> X)"
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1980
      using assms by (intro finite_not_islimpt_in_compact) auto
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1981
  qed auto
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1982
  also have "(\<Union>n. cball 0 (real n)) = (UNIV :: 'a set)"
79945
ca004ccf2352 New material from a variety of sources (including AFP)
paulson <lp15@cam.ac.uk>
parents: 79772
diff changeset
  1983
    by (force simp: real_arch_simple)
77179
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1984
  hence "(\<Union>n. cball 0 (real n) \<inter> X) = X"
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1985
    by blast
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1986
  finally show "countable X" .
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1987
qed
6d2ca97a8f46 More of Manuel's material, and some changes
paulson <lp15@cam.ac.uk>
parents: 77140
diff changeset
  1988
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1989
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  1990
section \<open>Distance from a Set\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1991
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1992
lemma distance_attains_sup:
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1993
  assumes "compact S" "S \<noteq> {}"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1994
  shows "\<exists>x\<in>S. \<forall>y\<in>S. dist a y \<le> dist a x"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1995
proof (rule continuous_attains_sup [OF assms])
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1996
  show "continuous_on S (dist a)"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1997
    unfolding continuous_on
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  1998
    using Lim_at_imp_Lim_at_within continuous_at_dist isCont_def by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1999
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2000
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2001
text \<open>For \emph{minimal} distance, we only need closure, not compactness.\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2002
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2003
lemma distance_attains_inf:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2004
  fixes a :: "'a::heine_borel"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2005
  assumes "closed S" and "S \<noteq> {}"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2006
  obtains x where "x\<in>S" "\<And>y. y \<in> S \<Longrightarrow> dist a x \<le> dist a y"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2007
proof -
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2008
  from assms obtain b where "b \<in> S" by auto
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2009
  let ?B = "S \<inter> cball a (dist b a)"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2010
  have "?B \<noteq> {}" using \<open>b \<in> S\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2011
    by (auto simp: dist_commute)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2012
  moreover have "continuous_on ?B (dist a)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2013
    by (auto intro!: continuous_at_imp_continuous_on continuous_dist continuous_ident continuous_const)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2014
  moreover have "compact ?B"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2015
    by (intro closed_Int_compact \<open>closed S\<close> compact_cball)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2016
  ultimately obtain x where "x \<in> ?B" "\<forall>y\<in>?B. dist a x \<le> dist a y"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2017
    by (metis continuous_attains_inf)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2018
  with that show ?thesis by fastforce
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2019
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2020
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2021
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2022
section \<open>Infimum Distance\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2023
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  2024
definition\<^marker>\<open>tag important\<close> "infdist x A = (if A = {} then 0 else INF a\<in>A. dist x a)"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2025
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2026
lemma bdd_below_image_dist[intro, simp]: "bdd_below (dist x ` A)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2027
  by (auto intro!: zero_le_dist)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2028
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2029
lemma infdist_notempty: "A \<noteq> {} \<Longrightarrow> infdist x A = (INF a\<in>A. dist x a)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2030
  by (simp add: infdist_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2031
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2032
lemma infdist_nonneg: "0 \<le> infdist x A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2033
  by (auto simp: infdist_def intro: cINF_greatest)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2034
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2035
lemma infdist_le: "a \<in> A \<Longrightarrow> infdist x A \<le> dist x a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2036
  by (auto intro: cINF_lower simp add: infdist_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2037
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2038
lemma infdist_le2: "a \<in> A \<Longrightarrow> dist x a \<le> d \<Longrightarrow> infdist x A \<le> d"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2039
  by (auto intro!: cINF_lower2 simp add: infdist_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2040
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2041
lemma infdist_zero[simp]: "a \<in> A \<Longrightarrow> infdist a A = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2042
  by (auto intro!: antisym infdist_nonneg infdist_le2)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2043
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  2044
lemma infdist_Un_min:
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  2045
  assumes "A \<noteq> {}" "B \<noteq> {}"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  2046
  shows "infdist x (A \<union> B) = min (infdist x A) (infdist x B)"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  2047
using assms by (simp add: infdist_def cINF_union inf_real_def)
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  2048
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2049
lemma infdist_triangle: "infdist x A \<le> infdist y A + dist x y"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2050
proof (cases "A = {}")
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2051
  case True
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2052
  then show ?thesis by (simp add: infdist_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2053
next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2054
  case False
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2055
  then obtain a where "a \<in> A" by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2056
  have "infdist x A \<le> Inf {dist x y + dist y a |a. a \<in> A}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2057
  proof (rule cInf_greatest)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2058
    from \<open>A \<noteq> {}\<close> show "{dist x y + dist y a |a. a \<in> A} \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2059
      by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2060
    fix d
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2061
    assume "d \<in> {dist x y + dist y a |a. a \<in> A}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2062
    then obtain a where d: "d = dist x y + dist y a" "a \<in> A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2063
      by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2064
    show "infdist x A \<le> d"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2065
      using infdist_notempty[OF \<open>A \<noteq> {}\<close>]
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2066
      by (metis d dist_commute dist_triangle3 infdist_le2)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2067
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2068
  also have "\<dots> = dist x y + infdist y A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2069
  proof (rule cInf_eq, safe)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2070
    fix a
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2071
    assume "a \<in> A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2072
    then show "dist x y + infdist y A \<le> dist x y + dist y a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2073
      by (auto intro: infdist_le)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2074
  next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2075
    fix i
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2076
    assume inf: "\<And>d. d \<in> {dist x y + dist y a |a. a \<in> A} \<Longrightarrow> i \<le> d"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2077
    then have "i - dist x y \<le> infdist y A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2078
      unfolding infdist_notempty[OF \<open>A \<noteq> {}\<close>] using \<open>a \<in> A\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2079
      by (intro cINF_greatest) (auto simp: field_simps)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2080
    then show "i \<le> dist x y + infdist y A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2081
      by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2082
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2083
  finally show ?thesis by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2084
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2085
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  2086
lemma infdist_triangle_abs: "\<bar>infdist x A - infdist y A\<bar> \<le> dist x y"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2087
  by (metis abs_diff_le_iff diff_le_eq dist_commute infdist_triangle)
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  2088
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2089
lemma in_closure_iff_infdist_zero:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2090
  assumes "A \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2091
  shows "x \<in> closure A \<longleftrightarrow> infdist x A = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2092
proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2093
  assume "x \<in> closure A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2094
  show "infdist x A = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2095
  proof (rule ccontr)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2096
    assume "infdist x A \<noteq> 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2097
    with infdist_nonneg[of x A] have "infdist x A > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2098
      by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2099
    then have "ball x (infdist x A) \<inter> closure A = {}"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2100
      by (meson \<open>x \<in> closure A\<close> closure_approachableD infdist_le linorder_not_le)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2101
    then have "x \<notin> closure A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2102
      by (metis \<open>0 < infdist x A\<close> centre_in_ball disjoint_iff_not_equal)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2103
    then show False using \<open>x \<in> closure A\<close> by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2104
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2105
next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2106
  assume x: "infdist x A = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2107
  then obtain a where "a \<in> A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2108
    by atomize_elim (metis all_not_in_conv assms)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2109
  have False if "e > 0" "\<not> (\<exists>y\<in>A. dist y x < e)" for e
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2110
  proof -
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2111
    have "infdist x A \<ge> e" using \<open>a \<in> A\<close>
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2112
      unfolding infdist_def using that
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2113
      by (force simp: dist_commute intro: cINF_greatest)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2114
    with x \<open>e > 0\<close> show False by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2115
  qed
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2116
  then show "x \<in> closure A"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2117
    using closure_approachable by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2118
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2119
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2120
lemma in_closed_iff_infdist_zero:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2121
  assumes "closed A" "A \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2122
  shows "x \<in> A \<longleftrightarrow> infdist x A = 0"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2123
  by (metis assms closure_closed in_closure_iff_infdist_zero)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2124
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2125
lemma infdist_pos_not_in_closed:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2126
  assumes "closed S" "S \<noteq> {}" "x \<notin> S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2127
  shows "infdist x S > 0"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2128
  by (meson assms dual_order.order_iff_strict in_closed_iff_infdist_zero infdist_nonneg)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2129
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2130
lemma
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2131
  infdist_attains_inf:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2132
  fixes X::"'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2133
  assumes "closed X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2134
  assumes "X \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2135
  obtains x where "x \<in> X" "infdist y X = dist y x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2136
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2137
  have "bdd_below (dist y ` X)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2138
    by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2139
  from distance_attains_inf[OF assms, of y]
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2140
  obtain x where "x \<in> X" "\<And>z. z \<in> X \<Longrightarrow> dist y x \<le> dist y z" by auto
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2141
  then have "infdist y X = dist y x"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2142
    by (metis antisym assms(2) cINF_greatest infdist_def infdist_le)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2143
  with \<open>x \<in> X\<close> show ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2144
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2145
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2146
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2147
text \<open>Every metric space is a T4 space:\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2148
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2149
instance metric_space \<subseteq> t4_space
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2150
proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2151
  fix S T::"'a set" assume H: "closed S" "closed T" "S \<inter> T = {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2152
  consider "S = {}" | "T = {}" | "S \<noteq> {} \<and> T \<noteq> {}" by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2153
  then show "\<exists>U V. open U \<and> open V \<and> S \<subseteq> U \<and> T \<subseteq> V \<and> U \<inter> V = {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2154
  proof (cases)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2155
    case 1 then show ?thesis by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2156
  next
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2157
    case 2 then show ?thesis by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2158
  next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2159
    case 3
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2160
    define U where "U = (\<Union>x\<in>S. ball x ((infdist x T)/2))"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2161
    have A: "open U" unfolding U_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2162
    have "infdist x T > 0" if "x \<in> S" for x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2163
      using H that 3 by (auto intro!: infdist_pos_not_in_closed)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2164
    then have B: "S \<subseteq> U" unfolding U_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2165
    define V where "V = (\<Union>x\<in>T. ball x ((infdist x S)/2))"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2166
    have C: "open V" unfolding V_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2167
    have "infdist x S > 0" if "x \<in> T" for x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2168
      using H that 3 by (auto intro!: infdist_pos_not_in_closed)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2169
    then have D: "T \<subseteq> V" unfolding V_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2170
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2171
    have "(ball x ((infdist x T)/2)) \<inter> (ball y ((infdist y S)/2)) = {}" if "x \<in> S" "y \<in> T" for x y
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2172
    proof auto
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2173
      fix z assume H: "dist x z * 2 < infdist x T" "dist y z * 2 < infdist y S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2174
      have "2 * dist x y \<le> 2 * dist x z + 2 * dist y z"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2175
        by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2176
      also have "... < infdist x T + infdist y S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2177
        using H by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2178
      finally have "dist x y < infdist x T \<or> dist x y < infdist y S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2179
        by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2180
      then show False
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2181
        using infdist_le[OF \<open>x \<in> S\<close>, of y] infdist_le[OF \<open>y \<in> T\<close>, of x] by (auto simp add: dist_commute)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2182
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2183
    then have E: "U \<inter> V = {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2184
      unfolding U_def V_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2185
    show ?thesis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2186
      using A B C D E by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2187
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2188
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2189
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2190
lemma tendsto_infdist [tendsto_intros]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2191
  assumes f: "(f \<longlongrightarrow> l) F"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2192
  shows "((\<lambda>x. infdist (f x) A) \<longlongrightarrow> infdist l A) F"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2193
proof (rule tendstoI)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2194
  fix e ::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2195
  assume "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2196
  from tendstoD[OF f this]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2197
  show "eventually (\<lambda>x. dist (infdist (f x) A) (infdist l A) < e) F"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2198
  proof (eventually_elim)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2199
    fix x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2200
    from infdist_triangle[of l A "f x"] infdist_triangle[of "f x" A l]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2201
    have "dist (infdist (f x) A) (infdist l A) \<le> dist (f x) l"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2202
      by (simp add: dist_commute dist_real_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2203
    also assume "dist (f x) l < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2204
    finally show "dist (infdist (f x) A) (infdist l A) < e" .
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2205
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2206
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2207
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2208
lemma continuous_infdist[continuous_intros]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2209
  assumes "continuous F f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2210
  shows "continuous F (\<lambda>x. infdist (f x) A)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2211
  using assms unfolding continuous_def by (rule tendsto_infdist)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2212
70723
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  2213
lemma continuous_on_infdist [continuous_intros]:
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  2214
  assumes "continuous_on S f"
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  2215
  shows "continuous_on S (\<lambda>x. infdist (f x) A)"
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  2216
using assms unfolding continuous_on by (auto intro: tendsto_infdist)
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  2217
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2218
lemma compact_infdist_le:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2219
  fixes A::"'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2220
  assumes "A \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2221
  assumes "compact A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2222
  assumes "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2223
  shows "compact {x. infdist x A \<le> e}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2224
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2225
  from continuous_closed_vimage[of "{0..e}" "\<lambda>x. infdist x A"]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2226
    continuous_infdist[OF continuous_ident, of _ UNIV A]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2227
  have "closed {x. infdist x A \<le> e}" by (auto simp: vimage_def infdist_nonneg)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2228
  moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2229
  from assms obtain x0 b where b: "\<And>x. x \<in> A \<Longrightarrow> dist x0 x \<le> b" "closed A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2230
    by (auto simp: compact_eq_bounded_closed bounded_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2231
  {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2232
    fix y
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2233
    assume "infdist y A \<le> e"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2234
    moreover
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2235
    from infdist_attains_inf[OF \<open>closed A\<close> \<open>A \<noteq> {}\<close>, of y]
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2236
    obtain z where "z \<in> A" "infdist y A = dist y z" by blast
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2237
    ultimately
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2238
    have "dist x0 y \<le> b + e" using b by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2239
  } then
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2240
  have "bounded {x. infdist x A \<le> e}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2241
    by (auto simp: bounded_any_center[where a=x0] intro!: exI[where x="b + e"])
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2242
  ultimately show "compact {x. infdist x A \<le> e}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2243
    by (simp add: compact_eq_bounded_closed)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2244
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2245
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2246
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2247
section \<open>Separation between Points and Sets\<close>
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2248
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2249
proposition separate_point_closed:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2250
  fixes S :: "'a::heine_borel set"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2251
  assumes "closed S" and "a \<notin> S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2252
  shows "\<exists>d>0. \<forall>x\<in>S. d \<le> dist a x"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2253
  by (metis assms distance_attains_inf empty_iff gt_ex zero_less_dist_iff)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2254
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2255
proposition separate_compact_closed:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2256
  fixes S T :: "'a::heine_borel set"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2257
  assumes "compact S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2258
    and T: "closed T" "S \<inter> T = {}"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2259
  shows "\<exists>d>0. \<forall>x\<in>S. \<forall>y\<in>T. d \<le> dist x y"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2260
proof cases
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2261
  assume "S \<noteq> {} \<and> T \<noteq> {}"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2262
  then have "S \<noteq> {}" "T \<noteq> {}" by auto
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2263
  let ?inf = "\<lambda>x. infdist x T"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2264
  have "continuous_on S ?inf"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2265
    by (auto intro!: continuous_at_imp_continuous_on continuous_infdist continuous_ident)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2266
  then obtain x where x: "x \<in> S" "\<forall>y\<in>S. ?inf x \<le> ?inf y"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2267
    using continuous_attains_inf[OF \<open>compact S\<close> \<open>S \<noteq> {}\<close>] by auto
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2268
  then have "0 < ?inf x"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2269
    using T \<open>T \<noteq> {}\<close> in_closed_iff_infdist_zero by (auto simp: less_le infdist_nonneg)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2270
  moreover have "\<forall>x'\<in>S. \<forall>y\<in>T. ?inf x \<le> dist x' y"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2271
    using x by (auto intro: order_trans infdist_le)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2272
  ultimately show ?thesis by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2273
qed (auto intro!: exI[of _ 1])
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2274
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2275
proposition separate_closed_compact:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2276
  fixes S T :: "'a::heine_borel set"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2277
  assumes S: "closed S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2278
    and T: "compact T"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2279
    and dis: "S \<inter> T = {}"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2280
  shows "\<exists>d>0. \<forall>x\<in>S. \<forall>y\<in>T. d \<le> dist x y"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2281
  by (metis separate_compact_closed[OF T S] dis dist_commute inf_commute)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2282
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2283
proposition compact_in_open_separated:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2284
  fixes A::"'a::heine_borel set"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2285
  assumes A: "A \<noteq> {}" "compact A"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2286
  assumes "open B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2287
  assumes "A \<subseteq> B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2288
  obtains e where "e > 0" "{x. infdist x A \<le> e} \<subseteq> B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2289
proof atomize_elim
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2290
  have "closed (- B)" "compact A" "- B \<inter> A = {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2291
    using assms by (auto simp: open_Diff compact_eq_bounded_closed)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2292
  from separate_closed_compact[OF this]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2293
  obtain d'::real where d': "d'>0" "\<And>x y. x \<notin> B \<Longrightarrow> y \<in> A \<Longrightarrow> d' \<le> dist x y"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2294
    by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2295
  define d where "d = d' / 2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2296
  hence "d>0" "d < d'" using d' by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2297
  with d' have d: "\<And>x y. x \<notin> B \<Longrightarrow> y \<in> A \<Longrightarrow> d < dist x y"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2298
    by force
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2299
  show "\<exists>e>0. {x. infdist x A \<le> e} \<subseteq> B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2300
  proof (rule ccontr)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2301
    assume "\<nexists>e. 0 < e \<and> {x. infdist x A \<le> e} \<subseteq> B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2302
    with \<open>d > 0\<close> obtain x where x: "infdist x A \<le> d" "x \<notin> B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2303
      by auto
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2304
    then show False
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2305
      by (metis A compact_eq_bounded_closed infdist_attains_inf x d linorder_not_less)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2306
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2307
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2308
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2309
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2310
section \<open>Uniform Continuity\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2311
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2312
lemma uniformly_continuous_onE:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2313
  assumes "uniformly_continuous_on s f" "0 < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2314
  obtains d where "d>0" "\<And>x x'. \<lbrakk>x\<in>s; x'\<in>s; dist x' x < d\<rbrakk> \<Longrightarrow> dist (f x') (f x) < e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2315
  using assms
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2316
  by (auto simp: uniformly_continuous_on_def)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2317
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2318
lemma uniformly_continuous_on_sequentially:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2319
  "uniformly_continuous_on s f \<longleftrightarrow> (\<forall>x y. (\<forall>n. x n \<in> s) \<and> (\<forall>n. y n \<in> s) \<and>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2320
    (\<lambda>n. dist (x n) (y n)) \<longlonglongrightarrow> 0 \<longrightarrow> (\<lambda>n. dist (f(x n)) (f(y n))) \<longlonglongrightarrow> 0)" (is "?lhs = ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2321
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2322
  assume ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2323
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2324
    fix x y
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2325
    assume x: "\<forall>n. x n \<in> s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2326
      and y: "\<forall>n. y n \<in> s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2327
      and xy: "((\<lambda>n. dist (x n) (y n)) \<longlongrightarrow> 0) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2328
    {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2329
      fix e :: real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2330
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2331
      then obtain d where "d > 0" and d: "\<forall>x\<in>s. \<forall>x'\<in>s. dist x' x < d \<longrightarrow> dist (f x') (f x) < e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2332
        by (metis \<open>?lhs\<close> uniformly_continuous_onE)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2333
      obtain N where N: "\<forall>n\<ge>N. dist (x n) (y n) < d"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2334
        using xy[unfolded lim_sequentially dist_norm] and \<open>d>0\<close> by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2335
      then have "\<exists>N. \<forall>n\<ge>N. dist (f (x n)) (f (y n)) < e"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2336
        using d x y by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2337
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2338
    then have "((\<lambda>n. dist (f(x n)) (f(y n))) \<longlongrightarrow> 0) sequentially"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2339
      unfolding lim_sequentially and dist_real_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2340
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2341
  then show ?rhs by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2342
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2343
  assume ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2344
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2345
    assume "\<not> ?lhs"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2346
    then obtain e where "e > 0" "\<forall>d>0. \<exists>x\<in>s. \<exists>x'\<in>s. dist x' x < d \<and> \<not> dist (f x') (f x) < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2347
      unfolding uniformly_continuous_on_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2348
    then obtain fa where fa:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2349
      "\<forall>x. 0 < x \<longrightarrow> fst (fa x) \<in> s \<and> snd (fa x) \<in> s \<and> dist (fst (fa x)) (snd (fa x)) < x \<and> \<not> dist (f (fst (fa x))) (f (snd (fa x))) < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2350
      using choice[of "\<lambda>d x. d>0 \<longrightarrow> fst x \<in> s \<and> snd x \<in> s \<and> dist (snd x) (fst x) < d \<and> \<not> dist (f (snd x)) (f (fst x)) < e"]
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2351
      by (auto simp: Bex_def dist_commute)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2352
    define x where "x n = fst (fa (inverse (real n + 1)))" for n
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2353
    define y where "y n = snd (fa (inverse (real n + 1)))" for n
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2354
    have xyn: "\<forall>n. x n \<in> s \<and> y n \<in> s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2355
      and xy0: "\<forall>n. dist (x n) (y n) < inverse (real n + 1)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2356
      and fxy:"\<forall>n. \<not> dist (f (x n)) (f (y n)) < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2357
      unfolding x_def and y_def using fa
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2358
      by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2359
    {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2360
      fix e :: real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2361
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2362
      then obtain N :: nat where "N \<noteq> 0" and N: "0 < inverse (real N) \<and> inverse (real N) < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2363
        unfolding real_arch_inverse[of e] by auto
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2364
      with xy0 have "\<exists>N. \<forall>n\<ge>N. dist (x n) (y n) < e"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2365
        by (metis order.strict_trans inverse_positive_iff_positive less_imp_inverse_less
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2366
            nat_le_real_less)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2367
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2368
    then have "\<forall>e>0. \<exists>N. \<forall>n\<ge>N. dist (f (x n)) (f (y n)) < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2369
      using \<open>?rhs\<close>[THEN spec[where x=x], THEN spec[where x=y]] and xyn
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2370
      unfolding lim_sequentially dist_real_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2371
    then have False using fxy and \<open>e>0\<close> by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2372
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2373
  then show ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2374
    unfolding uniformly_continuous_on_def by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2375
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2376
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2377
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2378
section \<open>Continuity on a Compact Domain Implies Uniform Continuity\<close>
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2379
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2380
text\<open>From the proof of the Heine-Borel theorem: Lemma 2 in section 3.7, page 69 of
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2381
J. C. Burkill and H. Burkill. A Second Course in Mathematical Analysis (CUP, 2002)\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2382
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2383
lemma Heine_Borel_lemma:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2384
  assumes "compact S" and Ssub: "S \<subseteq> \<Union>\<G>" and opn: "\<And>G. G \<in> \<G> \<Longrightarrow> open G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2385
  obtains e where "0 < e" "\<And>x. x \<in> S \<Longrightarrow> \<exists>G \<in> \<G>. ball x e \<subseteq> G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2386
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2387
  have False if neg: "\<And>e. 0 < e \<Longrightarrow> \<exists>x \<in> S. \<forall>G \<in> \<G>. \<not> ball x e \<subseteq> G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2388
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2389
    have "\<exists>x \<in> S. \<forall>G \<in> \<G>. \<not> ball x (1 / Suc n) \<subseteq> G" for n
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2390
      using neg by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2391
    then obtain f where "\<And>n. f n \<in> S" and fG: "\<And>G n. G \<in> \<G> \<Longrightarrow> \<not> ball (f n) (1 / Suc n) \<subseteq> G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2392
      by metis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2393
    then obtain l r where "l \<in> S" "strict_mono r" and to_l: "(f \<circ> r) \<longlonglongrightarrow> l"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2394
      using \<open>compact S\<close> compact_def that by metis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2395
    then obtain G where "l \<in> G" "G \<in> \<G>"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2396
      using Ssub by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2397
    then obtain e where "0 < e" and e: "\<And>z. dist z l < e \<Longrightarrow> z \<in> G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2398
      using opn open_dist by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2399
    obtain N1 where N1: "\<And>n. n \<ge> N1 \<Longrightarrow> dist (f (r n)) l < e/2"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2400
      by (metis \<open>0 < e\<close> half_gt_zero lim_sequentially o_apply to_l)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2401
    obtain N2 where N2: "of_nat N2 > 2/e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2402
      using reals_Archimedean2 by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2403
    obtain x where "x \<in> ball (f (r (max N1 N2))) (1 / real (Suc (r (max N1 N2))))" and "x \<notin> G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2404
      using fG [OF \<open>G \<in> \<G>\<close>, of "r (max N1 N2)"] by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2405
    then have "dist (f (r (max N1 N2))) x < 1 / real (Suc (r (max N1 N2)))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2406
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2407
    also have "... \<le> 1 / real (Suc (max N1 N2))"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2408
      by (meson Suc_le_mono \<open>strict_mono r\<close> inverse_of_nat_le nat.discI seq_suble)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2409
    also have "... \<le> 1 / real (Suc N2)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2410
      by (simp add: field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2411
    also have "... < e/2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2412
      using N2 \<open>0 < e\<close> by (simp add: field_simps)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  2413
    finally have "dist (f (r (max N1 N2))) x < e/2" .
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2414
    moreover have "dist (f (r (max N1 N2))) l < e/2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2415
      using N1 max.cobounded1 by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2416
    ultimately have "dist x l < e"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2417
      by metric
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2418
    then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2419
      using e \<open>x \<notin> G\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2420
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2421
  then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2422
    by (meson that)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2423
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2424
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2425
lemma compact_uniformly_equicontinuous:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2426
  assumes "compact S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2427
      and cont: "\<And>x e. \<lbrakk>x \<in> S; 0 < e\<rbrakk>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2428
                        \<Longrightarrow> \<exists>d. 0 < d \<and>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2429
                                (\<forall>f \<in> \<F>. \<forall>x' \<in> S. dist x' x < d \<longrightarrow> dist (f x') (f x) < e)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2430
      and "0 < e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2431
  obtains d where "0 < d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2432
                  "\<And>f x x'. \<lbrakk>f \<in> \<F>; x \<in> S; x' \<in> S; dist x' x < d\<rbrakk> \<Longrightarrow> dist (f x') (f x) < e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2433
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2434
  obtain d where d_pos: "\<And>x e. \<lbrakk>x \<in> S; 0 < e\<rbrakk> \<Longrightarrow> 0 < d x e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2435
     and d_dist : "\<And>x x' e f. \<lbrakk>dist x' x < d x e; x \<in> S; x' \<in> S; 0 < e; f \<in> \<F>\<rbrakk> \<Longrightarrow> dist (f x') (f x) < e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2436
    using cont by metis
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  2437
  let ?\<G> = "((\<lambda>x. ball x (d x (e/2))) ` S)"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2438
  have Ssub: "S \<subseteq> \<Union> ?\<G>"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2439
    using \<open>0 < e\<close> d_pos by auto
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2440
  then obtain k where "0 < k" and k: "\<And>x. x \<in> S \<Longrightarrow> \<exists>G \<in> ?\<G>. ball x k \<subseteq> G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2441
    by (rule Heine_Borel_lemma [OF \<open>compact S\<close>]) auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2442
  moreover have "dist (f v) (f u) < e" if "f \<in> \<F>" "u \<in> S" "v \<in> S" "dist v u < k" for f u v
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2443
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2444
    obtain G where "G \<in> ?\<G>" "u \<in> G" "v \<in> G"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2445
      using k that
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2446
      by (metis \<open>dist v u < k\<close> \<open>u \<in> S\<close> \<open>0 < k\<close> centre_in_ball subsetD dist_commute mem_ball)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  2447
    then obtain w where w: "dist w u < d w (e/2)" "dist w v < d w (e/2)" "w \<in> S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2448
      by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2449
    with that d_dist have "dist (f w) (f v) < e/2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2450
      by (metis \<open>0 < e\<close> dist_commute half_gt_zero)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2451
    moreover
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2452
    have "dist (f w) (f u) < e/2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2453
      using that d_dist w by (metis \<open>0 < e\<close> dist_commute divide_pos_pos zero_less_numeral)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2454
    ultimately show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2455
      using dist_triangle_half_r by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2456
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2457
  ultimately show ?thesis using that by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2458
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2459
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2460
corollary compact_uniformly_continuous:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2461
  fixes f :: "'a :: metric_space \<Rightarrow> 'b :: metric_space"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2462
  assumes f: "continuous_on S f" and S: "compact S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2463
  shows "uniformly_continuous_on S f"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2464
  using f
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2465
    unfolding continuous_on_iff uniformly_continuous_on_def
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2466
    by (force intro: compact_uniformly_equicontinuous [OF S, of "{f}"])
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2467
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2468
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2469
section\<^marker>\<open>tag unimportant\<close>\<open> Theorems relating continuity and uniform continuity to closures\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2470
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2471
lemma continuous_on_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2472
   "continuous_on (closure S) f \<longleftrightarrow>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2473
    (\<forall>x e. x \<in> closure S \<and> 0 < e
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2474
           \<longrightarrow> (\<exists>d. 0 < d \<and> (\<forall>y. y \<in> S \<and> dist y x < d \<longrightarrow> dist (f y) (f x) < e)))"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2475
   (is "?lhs = ?rhs")
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2476
proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2477
  assume ?lhs then show ?rhs
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2478
    unfolding continuous_on_iff  by (metis Un_iff closure_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2479
next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2480
  assume R [rule_format]: ?rhs
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2481
  show ?lhs
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2482
  proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2483
    fix x and e::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2484
    assume "0 < e" and x: "x \<in> closure S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2485
    obtain \<delta>::real where "\<delta> > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2486
                   and \<delta>: "\<And>y. \<lbrakk>y \<in> S; dist y x < \<delta>\<rbrakk> \<Longrightarrow> dist (f y) (f x) < e/2"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2487
      using R [of x "e/2"] \<open>0 < e\<close> x by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2488
    have "dist (f y) (f x) \<le> e" if y: "y \<in> closure S" and dyx: "dist y x < \<delta>/2" for y
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2489
    proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2490
      obtain \<delta>'::real where "\<delta>' > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2491
                      and \<delta>': "\<And>z. \<lbrakk>z \<in> S; dist z y < \<delta>'\<rbrakk> \<Longrightarrow> dist (f z) (f y) < e/2"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2492
        using R [of y "e/2"] \<open>0 < e\<close> y by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2493
      obtain z where "z \<in> S" and z: "dist z y < min \<delta>' \<delta> / 2"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2494
        using closure_approachable y
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2495
        by (metis \<open>0 < \<delta>'\<close> \<open>0 < \<delta>\<close> divide_pos_pos min_less_iff_conj zero_less_numeral)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2496
      have "dist (f z) (f y) < e/2"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2497
        using \<delta>' [OF \<open>z \<in> S\<close>] z \<open>0 < \<delta>'\<close> by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2498
      moreover have "dist (f z) (f x) < e/2"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2499
        using \<delta>[OF \<open>z \<in> S\<close>] z dyx by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2500
      ultimately show ?thesis
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2501
        by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2502
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2503
    then show "\<exists>d>0. \<forall>x'\<in>closure S. dist x' x < d \<longrightarrow> dist (f x') (f x) \<le> e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2504
      by (rule_tac x="\<delta>/2" in exI) (simp add: \<open>\<delta> > 0\<close>)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2505
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2506
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2507
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2508
lemma continuous_on_closure_sequentially:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2509
  fixes f :: "'a::metric_space \<Rightarrow> 'b :: metric_space"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2510
  shows
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2511
   "continuous_on (closure S) f \<longleftrightarrow>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2512
    (\<forall>x a. a \<in> closure S \<and> (\<forall>n. x n \<in> S) \<and> x \<longlonglongrightarrow> a \<longrightarrow> (f \<circ> x) \<longlonglongrightarrow> f a)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2513
   (is "?lhs = ?rhs")
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2514
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2515
  have "continuous_on (closure S) f \<longleftrightarrow>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2516
           (\<forall>x \<in> closure S. continuous (at x within S) f)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2517
    by (force simp: continuous_on_closure continuous_within_eps_delta)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2518
  also have "... = ?rhs"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2519
    by (force simp: continuous_within_sequentially)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2520
  finally show ?thesis .
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2521
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2522
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2523
lemma uniformly_continuous_on_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2524
  fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2525
  assumes ucont: "uniformly_continuous_on S f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2526
      and cont: "continuous_on (closure S) f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2527
    shows "uniformly_continuous_on (closure S) f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2528
unfolding uniformly_continuous_on_def
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2529
proof (intro allI impI)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2530
  fix e::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2531
  assume "0 < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2532
  then obtain d::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2533
    where "d>0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2534
      and d: "\<And>x x'. \<lbrakk>x\<in>S; x'\<in>S; dist x' x < d\<rbrakk> \<Longrightarrow> dist (f x') (f x) < e/3"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2535
    using ucont [unfolded uniformly_continuous_on_def, rule_format, of "e/3"] by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2536
  show "\<exists>d>0. \<forall>x\<in>closure S. \<forall>x'\<in>closure S. dist x' x < d \<longrightarrow> dist (f x') (f x) < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2537
  proof (rule exI [where x="d/3"], clarsimp simp: \<open>d > 0\<close>)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2538
    fix x y
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2539
    assume x: "x \<in> closure S" and y: "y \<in> closure S" and dyx: "dist y x * 3 < d"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2540
    obtain d1::real where "d1 > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2541
           and d1: "\<And>w. \<lbrakk>w \<in> closure S; dist w x < d1\<rbrakk> \<Longrightarrow> dist (f w) (f x) < e/3"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2542
      using cont [unfolded continuous_on_iff, rule_format, of "x" "e/3"] \<open>0 < e\<close> x by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2543
     obtain x' where "x' \<in> S" and x': "dist x' x < min d1 (d / 3)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2544
        using closure_approachable [of x S]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2545
        by (metis \<open>0 < d1\<close> \<open>0 < d\<close> divide_pos_pos min_less_iff_conj x zero_less_numeral)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2546
    obtain d2::real where "d2 > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2547
           and d2: "\<forall>w \<in> closure S. dist w y < d2 \<longrightarrow> dist (f w) (f y) < e/3"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2548
      using cont [unfolded continuous_on_iff, rule_format, of "y" "e/3"] \<open>0 < e\<close> y by auto
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2549
    obtain y' where "y' \<in> S" and y': "dist y' y < min d2 (d / 3)"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2550
      using closure_approachable [of y S]
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2551
      by (metis \<open>0 < d2\<close> \<open>0 < d\<close> divide_pos_pos min_less_iff_conj y zero_less_numeral)
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2552
    have "dist x' x < d/3" using x' by auto
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2553
    then have "dist x' y' < d"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2554
      using dyx y' by metric
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2555
    then have "dist (f x') (f y') < e/3"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2556
      by (rule d [OF \<open>y' \<in> S\<close> \<open>x' \<in> S\<close>])
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2557
    moreover have "dist (f x') (f x) < e/3" using \<open>x' \<in> S\<close> closure_subset x' d1
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2558
      by (simp add: closure_def)
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2559
    moreover have "dist (f y') (f y) < e/3" using \<open>y' \<in> S\<close> closure_subset y' d2
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2560
      by (simp add: closure_def)
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2561
    ultimately show "dist (f y) (f x) < e" by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2562
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2563
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2564
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2565
lemma uniformly_continuous_on_extension_at_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2566
  fixes f::"'a::metric_space \<Rightarrow> 'b::complete_space"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2567
  assumes uc: "uniformly_continuous_on X f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2568
  assumes "x \<in> closure X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2569
  obtains l where "(f \<longlongrightarrow> l) (at x within X)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2570
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2571
  from assms obtain xs where xs: "xs \<longlonglongrightarrow> x" "\<And>n. xs n \<in> X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2572
    by (auto simp: closure_sequential)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2573
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2574
  from uniformly_continuous_on_Cauchy[OF uc LIMSEQ_imp_Cauchy, OF xs]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2575
  obtain l where l: "(\<lambda>n. f (xs n)) \<longlonglongrightarrow> l"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2576
    by atomize_elim (simp only: convergent_eq_Cauchy)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2577
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2578
  have "(f \<longlongrightarrow> l) (at x within X)"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2579
  proof (clarify intro!: Lim_within_LIMSEQ)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2580
    fix xs'
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2581
    assume "\<forall>n. xs' n \<noteq> x \<and> xs' n \<in> X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2582
      and xs': "xs' \<longlonglongrightarrow> x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2583
    then have "xs' n \<noteq> x" "xs' n \<in> X" for n by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2584
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2585
    from uniformly_continuous_on_Cauchy[OF uc LIMSEQ_imp_Cauchy, OF \<open>xs' \<longlonglongrightarrow> x\<close> \<open>xs' _ \<in> X\<close>]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2586
    obtain l' where l': "(\<lambda>n. f (xs' n)) \<longlonglongrightarrow> l'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2587
      by atomize_elim (simp only: convergent_eq_Cauchy)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2588
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2589
    show "(\<lambda>n. f (xs' n)) \<longlonglongrightarrow> l"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2590
    proof (rule tendstoI)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2591
      fix e::real assume "e > 0"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  2592
      define e' where "e' \<equiv> e/2"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2593
      have "e' > 0" using \<open>e > 0\<close> by (simp add: e'_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2594
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2595
      have "\<forall>\<^sub>F n in sequentially. dist (f (xs n)) l < e'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2596
        by (simp add: \<open>0 < e'\<close> l tendstoD)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2597
      moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2598
      from uc[unfolded uniformly_continuous_on_def, rule_format, OF \<open>e' > 0\<close>]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2599
      obtain d where d: "d > 0" "\<And>x x'. x \<in> X \<Longrightarrow> x' \<in> X \<Longrightarrow> dist x x' < d \<Longrightarrow> dist (f x) (f x') < e'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2600
        by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2601
      have "\<forall>\<^sub>F n in sequentially. dist (xs n) (xs' n) < d"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2602
        by (auto intro!: \<open>0 < d\<close> order_tendstoD tendsto_eq_intros xs xs')
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2603
      ultimately
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2604
      show "\<forall>\<^sub>F n in sequentially. dist (f (xs' n)) l < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2605
      proof eventually_elim
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2606
        case (elim n)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2607
        have "dist (f (xs' n)) l \<le> dist (f (xs n)) (f (xs' n)) + dist (f (xs n)) l"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2608
          by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2609
        also have "dist (f (xs n)) (f (xs' n)) < e'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2610
          by (auto intro!: d xs \<open>xs' _ \<in> _\<close> elim)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2611
        also note \<open>dist (f (xs n)) l < e'\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2612
        also have "e' + e' = e" by (simp add: e'_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2613
        finally show ?case by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2614
      qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2615
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2616
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2617
  thus ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2618
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2619
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2620
lemma uniformly_continuous_on_extension_on_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2621
  fixes f::"'a::metric_space \<Rightarrow> 'b::complete_space"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2622
  assumes uc: "uniformly_continuous_on X f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2623
  obtains g where "uniformly_continuous_on (closure X) g" "\<And>x. x \<in> X \<Longrightarrow> f x = g x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2624
    "\<And>Y h x. X \<subseteq> Y \<Longrightarrow> Y \<subseteq> closure X \<Longrightarrow> continuous_on Y h \<Longrightarrow> (\<And>x. x \<in> X \<Longrightarrow> f x = h x) \<Longrightarrow> x \<in> Y \<Longrightarrow> h x = g x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2625
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2626
  from uc have cont_f: "continuous_on X f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2627
    by (simp add: uniformly_continuous_imp_continuous)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2628
  obtain y where y: "(f \<longlongrightarrow> y x) (at x within X)" if "x \<in> closure X" for x
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2629
    using uniformly_continuous_on_extension_at_closure[OF assms] by meson
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2630
  let ?g = "\<lambda>x. if x \<in> X then f x else y x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2631
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2632
  have "uniformly_continuous_on (closure X) ?g"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2633
    unfolding uniformly_continuous_on_def
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2634
  proof safe
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2635
    fix e::real assume "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2636
    define e' where "e' \<equiv> e / 3"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2637
    have "e' > 0" using \<open>e > 0\<close> by (simp add: e'_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2638
    from uc[unfolded uniformly_continuous_on_def, rule_format, OF \<open>0 < e'\<close>]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2639
    obtain d where "d > 0" and d: "\<And>x x'. x \<in> X \<Longrightarrow> x' \<in> X \<Longrightarrow> dist x' x < d \<Longrightarrow> dist (f x') (f x) < e'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2640
      by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2641
    define d' where "d' = d / 3"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2642
    have "d' > 0" using \<open>d > 0\<close> by (simp add: d'_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2643
    show "\<exists>d>0. \<forall>x\<in>closure X. \<forall>x'\<in>closure X. dist x' x < d \<longrightarrow> dist (?g x') (?g x) < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2644
    proof (safe intro!: exI[where x=d'] \<open>d' > 0\<close>)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2645
      fix x x' assume x: "x \<in> closure X" and x': "x' \<in> closure X" and dist: "dist x' x < d'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2646
      then obtain xs xs' where xs: "xs \<longlonglongrightarrow> x" "\<And>n. xs n \<in> X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2647
        and xs': "xs' \<longlonglongrightarrow> x'" "\<And>n. xs' n \<in> X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2648
        by (auto simp: closure_sequential)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2649
      have "\<forall>\<^sub>F n in sequentially. dist (xs' n) x' < d'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2650
        and "\<forall>\<^sub>F n in sequentially. dist (xs n) x < d'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2651
        by (auto intro!: \<open>0 < d'\<close> order_tendstoD tendsto_eq_intros xs xs')
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2652
      moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2653
      have "(\<lambda>x. f (xs x)) \<longlonglongrightarrow> y x" if "x \<in> closure X" "x \<notin> X" "xs \<longlonglongrightarrow> x" "\<And>n. xs n \<in> X" for xs x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2654
        using that not_eventuallyD
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2655
        by (force intro!: filterlim_compose[OF y[OF \<open>x \<in> closure X\<close>]] simp: filterlim_at)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2656
      then have "(\<lambda>x. f (xs' x)) \<longlonglongrightarrow> ?g x'" "(\<lambda>x. f (xs x)) \<longlonglongrightarrow> ?g x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2657
        using x x'
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2658
        by (auto intro!: continuous_on_tendsto_compose[OF cont_f] simp: xs' xs)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2659
      then have "\<forall>\<^sub>F n in sequentially. dist (f (xs' n)) (?g x') < e'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2660
        "\<forall>\<^sub>F n in sequentially. dist (f (xs n)) (?g x) < e'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2661
        by (auto intro!: \<open>0 < e'\<close> order_tendstoD tendsto_eq_intros)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2662
      ultimately
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2663
      have "\<forall>\<^sub>F n in sequentially. dist (?g x') (?g x) < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2664
      proof eventually_elim
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2665
        case (elim n)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2666
        have "dist (?g x') (?g x) \<le>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2667
          dist (f (xs' n)) (?g x') + dist (f (xs' n)) (f (xs n)) + dist (f (xs n)) (?g x)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2668
          by (metis add.commute add_le_cancel_left dist_commute dist_triangle dist_triangle_le)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2669
        also
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2670
        from \<open>dist (xs' n) x' < d'\<close> \<open>dist x' x < d'\<close> \<open>dist (xs n) x < d'\<close>
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2671
        have "dist (xs' n) (xs n) < d" unfolding d'_def by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2672
        with \<open>xs _ \<in> X\<close> \<open>xs' _ \<in> X\<close> have "dist (f (xs' n)) (f (xs n)) < e'"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2673
          by (rule d)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2674
        also note \<open>dist (f (xs' n)) (?g x') < e'\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2675
        also note \<open>dist (f (xs n)) (?g x) < e'\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2676
        finally show ?case by (simp add: e'_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2677
      qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2678
      then show "dist (?g x') (?g x) < e" by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2679
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2680
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2681
  moreover have "f x = ?g x" if "x \<in> X" for x using that by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2682
  moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2683
  {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2684
    fix Y h x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2685
    assume Y: "x \<in> Y" "X \<subseteq> Y" "Y \<subseteq> closure X" and cont_h: "continuous_on Y h"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2686
      and extension: "(\<And>x. x \<in> X \<Longrightarrow> f x = h x)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2687
    {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2688
      assume "x \<notin> X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2689
      have "x \<in> closure X" using Y by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2690
      then obtain xs where xs: "xs \<longlonglongrightarrow> x" "\<And>n. xs n \<in> X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2691
        by (auto simp: closure_sequential)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2692
      from continuous_on_tendsto_compose[OF cont_h xs(1)] xs(2) Y
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2693
      have hx: "(\<lambda>x. f (xs x)) \<longlonglongrightarrow> h x"
69712
dc85b5b3a532 renamings and new material
paulson <lp15@cam.ac.uk>
parents: 69676
diff changeset
  2694
        by (auto simp: subsetD extension)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2695
      then have "(\<lambda>x. f (xs x)) \<longlonglongrightarrow> y x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2696
        using \<open>x \<notin> X\<close> not_eventuallyD xs(2)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2697
        by (force intro!: filterlim_compose[OF y[OF \<open>x \<in> closure X\<close>]] simp: filterlim_at xs)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2698
      with hx have "h x = y x" by (rule LIMSEQ_unique)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2699
    } then
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2700
    have "h x = ?g x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2701
      using extension by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2702
  }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2703
  ultimately show ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2704
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2705
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2706
lemma bounded_uniformly_continuous_image:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2707
  fixes f :: "'a :: heine_borel \<Rightarrow> 'b :: heine_borel"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2708
  assumes "uniformly_continuous_on S f" "bounded S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2709
  shows "bounded(f ` S)"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2710
  by (metis (no_types) assms bounded_closure_image compact_closure compact_continuous_image compact_eq_bounded_closed image_cong uniformly_continuous_imp_continuous uniformly_continuous_on_extension_on_closure)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2711
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2712
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2713
section \<open>With Abstract Topology (TODO: move and remove dependency?)\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2714
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2715
lemma openin_contains_ball:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2716
    "openin (top_of_set T) S \<longleftrightarrow>
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2717
     S \<subseteq> T \<and> (\<forall>x \<in> S. \<exists>e. 0 < e \<and> ball x e \<inter> T \<subseteq> S)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2718
    (is "?lhs = ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2719
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2720
  assume ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2721
  then show ?rhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2722
    by (metis IntD2 Int_commute Int_lower1 Int_mono inf.idem openE openin_open)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2723
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2724
  assume ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2725
  then show ?lhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2726
    by (smt (verit) open_ball Int_commute Int_iff centre_in_ball in_mono openin_open_Int openin_subopen)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2727
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2728
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2729
lemma openin_contains_cball:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2730
   "openin (top_of_set T) S \<longleftrightarrow>
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2731
        S \<subseteq> T \<and> (\<forall>x \<in> S. \<exists>e. 0 < e \<and> cball x e \<inter> T \<subseteq> S)"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2732
  by (fastforce simp: openin_contains_ball intro: exI [where x="_/2"])
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2733
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2734
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2735
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2736
section \<open>Closed Nest\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2737
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2738
text \<open>Bounded closed nest property (proof does not use Heine-Borel)\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2739
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2740
lemma bounded_closed_nest:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2741
  fixes S :: "nat \<Rightarrow> ('a::heine_borel) set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2742
  assumes "\<And>n. closed (S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2743
      and "\<And>n. S n \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2744
      and "\<And>m n. m \<le> n \<Longrightarrow> S n \<subseteq> S m"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2745
      and "bounded (S 0)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2746
  obtains a where "\<And>n. a \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2747
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2748
  from assms(2) obtain x where x: "\<forall>n. x n \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2749
    using choice[of "\<lambda>n x. x \<in> S n"] by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2750
  from assms(4,1) have "seq_compact (S 0)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2751
    by (simp add: bounded_closed_imp_seq_compact)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2752
  then obtain l r where lr: "l \<in> S 0" "strict_mono r" "(x \<circ> r) \<longlonglongrightarrow> l"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2753
    using x and assms(3) unfolding seq_compact_def by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2754
  have "\<forall>n. l \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2755
  proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2756
    fix n :: nat
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2757
    have "closed (S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2758
      using assms(1) by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2759
    moreover have "\<forall>i. (x \<circ> r) i \<in> S i"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2760
      using x and assms(3) and lr(2) [THEN seq_suble] by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2761
    then have "\<forall>i. (x \<circ> r) (i + n) \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2762
      using assms(3) by (fast intro!: le_add2)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2763
    moreover have "(\<lambda>i. (x \<circ> r) (i + n)) \<longlonglongrightarrow> l"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2764
      using lr(3) by (rule LIMSEQ_ignore_initial_segment)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2765
    ultimately show "l \<in> S n"
78475
a5f6d2fc1b1f More cosmetic changes
paulson <lp15@cam.ac.uk>
parents: 78131
diff changeset
  2766
      by (metis closed_sequentially)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2767
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2768
  then show ?thesis 
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2769
    using that by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2770
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2771
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2772
text \<open>Decreasing case does not even need compactness, just completeness.\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2773
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2774
lemma decreasing_closed_nest:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2775
  fixes S :: "nat \<Rightarrow> ('a::complete_space) set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2776
  assumes "\<And>n. closed (S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2777
          "\<And>n. S n \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2778
          "\<And>m n. m \<le> n \<Longrightarrow> S n \<subseteq> S m"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2779
          "\<And>e. e>0 \<Longrightarrow> \<exists>n. \<forall>x\<in>S n. \<forall>y\<in>S n. dist x y < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2780
  obtains a where "\<And>n. a \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2781
proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2782
  obtain t where t: "\<forall>n. t n \<in> S n"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2783
    by (meson assms(2) equals0I)
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2784
  have "Cauchy t"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2785
  proof (intro metric_CauchyI)
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2786
    fix \<epsilon> :: real
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2787
    assume "\<epsilon> > 0"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2788
    then obtain N where N: "\<forall>x\<in>S N. \<forall>y\<in>S N. dist x y < \<epsilon>"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2789
      using assms(4) by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2790
    {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2791
      fix m n :: nat
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2792
      assume "N \<le> m \<and> N \<le> n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2793
      then have "t m \<in> S N" "t n \<in> S N"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2794
        using assms(3) t unfolding  subset_eq t by blast+
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2795
      then have "dist (t m) (t n) < \<epsilon>"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2796
        using N by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2797
    }
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2798
    then show "\<exists>M. \<forall>m\<ge>M. \<forall>n\<ge>M. dist (t m) (t n) < \<epsilon>"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2799
      by auto
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2800
  qed
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2801
  then obtain l where l:"(t \<longlongrightarrow> l) sequentially"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2802
    using complete_UNIV unfolding complete_def by auto
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2803
  show thesis
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2804
  proof
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2805
    fix n :: nat
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2806
    { fix \<epsilon> :: real
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2807
      assume "\<epsilon> > 0"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2808
      then obtain N :: nat where N: "\<forall>n\<ge>N. dist (t n) l < \<epsilon>"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2809
        using l[unfolded lim_sequentially] by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2810
      have "t (max n N) \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2811
        by (meson assms(3) contra_subsetD max.cobounded1 t)
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2812
      then have "\<exists>y\<in>S n. dist y l < \<epsilon>"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2813
        using N max.cobounded2 by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2814
    }
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2815
    then show "l \<in> S n"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2816
      using closed_approachable[of "S n" l] assms(1) by auto
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2817
  qed
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2818
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2819
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2820
text \<open>Strengthen it to the intersection actually being a singleton.\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2821
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2822
lemma decreasing_closed_nest_sing:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2823
  fixes S :: "nat \<Rightarrow> 'a::complete_space set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2824
  assumes "\<And>n. closed(S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2825
          "\<And>n. S n \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2826
          "\<And>m n. m \<le> n \<Longrightarrow> S n \<subseteq> S m"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2827
   and \<section>: "\<And>\<epsilon>. \<epsilon>>0 \<Longrightarrow> \<exists>n. \<forall>x \<in> (S n). \<forall> y\<in>(S n). dist x y < \<epsilon>"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2828
  shows "\<exists>a. \<Inter>(range S) = {a}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2829
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2830
  obtain a where a: "\<forall>n. a \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2831
    using decreasing_closed_nest[of S] using assms by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2832
  { fix b
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2833
    assume b: "b \<in> \<Inter>(range S)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2834
    then have "dist a b = 0"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2835
      by (meson InterE a \<section> linorder_neq_iff linorder_not_less range_eqI zero_le_dist)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2836
  }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2837
  with a have "\<Inter>(range S) = {a}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2838
    unfolding image_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2839
  then show ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2840
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2841
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2842
section\<^marker>\<open>tag unimportant\<close> \<open>Making a continuous function avoid some value in a neighbourhood\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2843
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2844
lemma continuous_within_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2845
  fixes f :: "'a::metric_space \<Rightarrow> 'b::t1_space"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2846
  assumes "continuous (at x within S) f"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2847
    and "f x \<noteq> a"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2848
  shows "\<exists>e>0. \<forall>y \<in> S. dist x y < e --> f y \<noteq> a"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2849
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2850
  obtain U where "open U" and "f x \<in> U" and "a \<notin> U"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2851
    using t1_space [OF \<open>f x \<noteq> a\<close>] by fast
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2852
  have "(f \<longlongrightarrow> f x) (at x within S)"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2853
    using assms(1) by (simp add: continuous_within)
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2854
  then have "eventually (\<lambda>y. f y \<in> U) (at x within S)"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2855
    using \<open>open U\<close> and \<open>f x \<in> U\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2856
    unfolding tendsto_def by fast
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2857
  then have "eventually (\<lambda>y. f y \<noteq> a) (at x within S)"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2858
    using \<open>a \<notin> U\<close> by (fast elim: eventually_mono)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2859
  then show ?thesis
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2860
    using \<open>f x \<noteq> a\<close> by (auto simp: dist_commute eventually_at)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2861
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2862
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2863
lemma continuous_at_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2864
  fixes f :: "'a::metric_space \<Rightarrow> 'b::t1_space"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2865
  assumes "continuous (at x) f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2866
    and "f x \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2867
  shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2868
  using assms continuous_within_avoid[of x UNIV f a] by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2869
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2870
lemma continuous_on_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2871
  fixes f :: "'a::metric_space \<Rightarrow> 'b::t1_space"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2872
  assumes "continuous_on S f"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2873
    and "x \<in> S"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2874
    and "f x \<noteq> a"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2875
  shows "\<exists>e>0. \<forall>y \<in> S. dist x y < e \<longrightarrow> f y \<noteq> a"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2876
  using continuous_within_avoid[of x S f a] assms
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2877
  by (meson continuous_on_eq_continuous_within)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2878
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2879
lemma continuous_on_open_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2880
  fixes f :: "'a::metric_space \<Rightarrow> 'b::t1_space"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2881
  assumes "continuous_on S f"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2882
    and "open S"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2883
    and "x \<in> S"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2884
    and "f x \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2885
  shows "\<exists>e>0. \<forall>y. dist x y < e \<longrightarrow> f y \<noteq> a"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2886
  using continuous_at_avoid[of x f a]  assms
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2887
  by (meson continuous_on_eq_continuous_at)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2888
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  2889
section \<open>Consequences for Real Numbers\<close>
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2890
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2891
lemma closed_contains_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2892
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2893
  shows "S \<noteq> {} \<Longrightarrow> bdd_below S \<Longrightarrow> closed S \<Longrightarrow> Inf S \<in> S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2894
  by (metis closure_contains_Inf closure_closed)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2895
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2896
lemma closed_subset_contains_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2897
  fixes A C :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2898
  shows "closed C \<Longrightarrow> A \<subseteq> C \<Longrightarrow> A \<noteq> {} \<Longrightarrow> bdd_below A \<Longrightarrow> Inf A \<in> C"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2899
  by (metis closure_contains_Inf closure_minimal subset_eq)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2900
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2901
lemma closed_contains_Sup:
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2902
  fixes S :: "real set"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2903
  shows "S \<noteq> {} \<Longrightarrow> bdd_above S \<Longrightarrow> closed S \<Longrightarrow> Sup S \<in> S"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2904
  by (subst closure_closed[symmetric], assumption, rule closure_contains_Sup)
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2905
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2906
lemma closed_subset_contains_Sup:
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2907
  fixes A C :: "real set"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2908
  shows "closed C \<Longrightarrow> A \<subseteq> C \<Longrightarrow> A \<noteq> {} \<Longrightarrow> bdd_above A \<Longrightarrow> Sup A \<in> C"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2909
  by (metis closure_contains_Sup closure_minimal subset_eq)
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2910
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2911
lemma atLeastAtMost_subset_contains_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2912
  fixes A :: "real set" and a b :: real
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2913
  shows "A \<noteq> {} \<Longrightarrow> a \<le> b \<Longrightarrow> A \<subseteq> {a..b} \<Longrightarrow> Inf A \<in> {a..b}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2914
  by (rule closed_subset_contains_Inf)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2915
     (auto intro: closed_real_atLeastAtMost intro!: bdd_belowI[of A a])
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2916
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2917
lemma bounded_real: "bounded (S::real set) \<longleftrightarrow> (\<exists>a. \<forall>x\<in>S. \<bar>x\<bar> \<le> a)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2918
  by (simp add: bounded_iff)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2919
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2920
lemma bounded_imp_bdd_above: "bounded S \<Longrightarrow> bdd_above (S :: real set)"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2921
  by (meson abs_le_D1 bdd_above.unfold bounded_real)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2922
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2923
lemma bounded_imp_bdd_below: "bounded S \<Longrightarrow> bdd_below (S :: real set)"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  2924
  by (metis add.commute abs_le_D1 bdd_below.unfold bounded_def diff_le_eq dist_real_def)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2925
78890
d8045bc0544e Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
paulson <lp15@cam.ac.uk>
parents: 78475
diff changeset
  2926
lemma bounded_norm_le_SUP_norm:
d8045bc0544e Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
paulson <lp15@cam.ac.uk>
parents: 78475
diff changeset
  2927
  "bounded (range f) \<Longrightarrow> norm (f x) \<le> (SUP x. norm (f x))"
d8045bc0544e Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
paulson <lp15@cam.ac.uk>
parents: 78475
diff changeset
  2928
  by (auto intro!: cSUP_upper bounded_imp_bdd_above simp: bounded_norm_comp)
d8045bc0544e Added Kronecker's approximation theorem. Requires adding Real_Asymp to HOL-Analysis. Funny syntax issue in Probability/Projective_Family
paulson <lp15@cam.ac.uk>
parents: 78475
diff changeset
  2929
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2930
lemma bounded_has_Sup:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2931
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2932
  assumes "bounded S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2933
    and "S \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2934
  shows "\<forall>x\<in>S. x \<le> Sup S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2935
    and "\<forall>b. (\<forall>x\<in>S. x \<le> b) \<longrightarrow> Sup S \<le> b"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2936
proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2937
  show "\<forall>b. (\<forall>x\<in>S. x \<le> b) \<longrightarrow> Sup S \<le> b"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2938
    using assms by (metis cSup_least)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2939
qed (metis cSup_upper assms(1) bounded_imp_bdd_above)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2940
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2941
lemma Sup_insert:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2942
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2943
  shows "bounded S \<Longrightarrow> Sup (insert x S) = (if S = {} then x else max x (Sup S))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2944
  by (auto simp: bounded_imp_bdd_above sup_max cSup_insert_If)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2945
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2946
lemma bounded_has_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2947
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2948
  assumes "bounded S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2949
    and "S \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2950
  shows "\<forall>x\<in>S. x \<ge> Inf S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2951
    and "\<forall>b. (\<forall>x\<in>S. x \<ge> b) \<longrightarrow> Inf S \<ge> b"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2952
proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2953
  show "\<forall>b. (\<forall>x\<in>S. x \<ge> b) \<longrightarrow> Inf S \<ge> b"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2954
    using assms by (metis cInf_greatest)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2955
qed (metis cInf_lower assms(1) bounded_imp_bdd_below)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2956
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2957
lemma Inf_insert:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2958
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2959
  shows "bounded S \<Longrightarrow> Inf (insert x S) = (if S = {} then x else min x (Inf S))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2960
  by (auto simp: bounded_imp_bdd_below inf_min cInf_insert_If)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2961
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2962
lemma open_real:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2963
  fixes s :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2964
  shows "open s \<longleftrightarrow> (\<forall>x \<in> s. \<exists>e>0. \<forall>x'. \<bar>x' - x\<bar> < e --> x' \<in> s)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2965
  unfolding open_dist dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2966
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2967
lemma islimpt_approachable_real:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2968
  fixes s :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2969
  shows "x islimpt s \<longleftrightarrow> (\<forall>e>0. \<exists>x'\<in> s. x' \<noteq> x \<and> \<bar>x' - x\<bar> < e)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2970
  unfolding islimpt_approachable dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2971
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2972
lemma closed_real:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2973
  fixes s :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2974
  shows "closed s \<longleftrightarrow> (\<forall>x. (\<forall>e>0.  \<exists>x' \<in> s. x' \<noteq> x \<and> \<bar>x' - x\<bar> < e) \<longrightarrow> x \<in> s)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2975
  unfolding closed_limpt islimpt_approachable dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2976
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2977
lemma continuous_at_real_range:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2978
  fixes f :: "'a::real_normed_vector \<Rightarrow> real"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2979
  shows "continuous (at x) f \<longleftrightarrow> (\<forall>e>0. \<exists>d>0. \<forall>x'. norm(x' - x) < d --> \<bar>f x' - f x\<bar> < e)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2980
  by (metis (mono_tags, opaque_lifting) LIM_eq continuous_within norm_eq_zero real_norm_def right_minus_eq)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2981
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2982
lemma continuous_on_real_range:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2983
  fixes f :: "'a::real_normed_vector \<Rightarrow> real"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2984
  shows "continuous_on s f \<longleftrightarrow>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2985
    (\<forall>x \<in> s. \<forall>e>0. \<exists>d>0. (\<forall>x' \<in> s. norm(x' - x) < d \<longrightarrow> \<bar>f x' - f x\<bar> < e))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2986
  unfolding continuous_on_iff dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2987
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2988
lemma continuous_on_closed_Collect_le:
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2989
  fixes f g :: "'a::topological_space \<Rightarrow> real"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2990
  assumes f: "continuous_on s f" and g: "continuous_on s g" and s: "closed s"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2991
  shows "closed {x \<in> s. f x \<le> g x}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2992
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2993
  have "closed ((\<lambda>x. g x - f x) -` {0..} \<inter> s)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2994
    using closed_real_atLeast continuous_on_diff [OF g f]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2995
    by (simp add: continuous_on_closed_vimage [OF s])
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2996
  also have "((\<lambda>x. g x - f x) -` {0..} \<inter> s) = {x\<in>s. f x \<le> g x}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2997
    by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2998
  finally show ?thesis .
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2999
qed
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  3000
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3001
lemma continuous_le_on_closure:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3002
  fixes a::real
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3003
  assumes f: "continuous_on (closure s) f"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3004
      and x: "x \<in> closure(s)"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3005
      and xlo: "\<And>x. x \<in> s ==> f(x) \<le> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3006
    shows "f(x) \<le> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3007
  using image_closure_subset [OF f, where T=" {x. x \<le> a}" ] assms
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3008
    continuous_on_closed_Collect_le[of "UNIV" "\<lambda>x. x" "\<lambda>x. a"]
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3009
  by auto
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3010
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3011
lemma continuous_ge_on_closure:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3012
  fixes a::real
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3013
  assumes f: "continuous_on (closure s) f"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3014
      and x: "x \<in> closure(s)"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3015
      and xlo: "\<And>x. x \<in> s ==> f(x) \<ge> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3016
    shows "f(x) \<ge> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3017
  using image_closure_subset [OF f, where T=" {x. a \<le> x}"] assms
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3018
    continuous_on_closed_Collect_le[of "UNIV" "\<lambda>x. a" "\<lambda>x. x"]
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3019
  by auto
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3020
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3021
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3022
section\<open>The infimum of the distance between two sets\<close>
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3023
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  3024
definition\<^marker>\<open>tag important\<close> setdist :: "'a::metric_space set \<Rightarrow> 'a set \<Rightarrow> real" where
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3025
  "setdist s t \<equiv>
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3026
       (if s = {} \<or> t = {} then 0
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3027
        else Inf {dist x y| x y. x \<in> s \<and> y \<in> t})"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3028
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3029
lemma setdist_empty1 [simp]: "setdist {} t = 0"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3030
  by (simp add: setdist_def)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3031
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3032
lemma setdist_empty2 [simp]: "setdist t {} = 0"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3033
  by (simp add: setdist_def)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3034
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3035
lemma setdist_pos_le [simp]: "0 \<le> setdist s t"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3036
  by (auto simp: setdist_def ex_in_conv [symmetric] intro: cInf_greatest)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3037
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3038
lemma le_setdistI:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3039
  assumes "s \<noteq> {}" "t \<noteq> {}" "\<And>x y. \<lbrakk>x \<in> s; y \<in> t\<rbrakk> \<Longrightarrow> d \<le> dist x y"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3040
    shows "d \<le> setdist s t"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3041
  using assms
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3042
  by (auto simp: setdist_def Set.ex_in_conv [symmetric] intro: cInf_greatest)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3043
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3044
lemma setdist_le_dist: "\<lbrakk>x \<in> s; y \<in> t\<rbrakk> \<Longrightarrow> setdist s t \<le> dist x y"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3045
  unfolding setdist_def
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3046
  by (auto intro!: bdd_belowI [where m=0] cInf_lower)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3047
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3048
lemma le_setdist_iff:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3049
        "d \<le> setdist S T \<longleftrightarrow>
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3050
        (\<forall>x \<in> S. \<forall>y \<in> T. d \<le> dist x y) \<and> (S = {} \<or> T = {} \<longrightarrow> d \<le> 0)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3051
  by (smt (verit) le_setdistI setdist_def setdist_le_dist)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3052
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3053
lemma setdist_ltE:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3054
  assumes "setdist S T < b" "S \<noteq> {}" "T \<noteq> {}"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  3055
  obtains x y where "x \<in> S" "y \<in> T" "dist x y < b"
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  3056
  using assms
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  3057
  by (auto simp: not_le [symmetric] le_setdist_iff)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3058
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3059
lemma setdist_refl: "setdist S S = 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3060
  by (metis dist_eq_0_iff ex_in_conv order_antisym setdist_def setdist_le_dist setdist_pos_le)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3061
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3062
lemma setdist_sym: "setdist S T = setdist T S"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3063
  by (force simp: setdist_def dist_commute intro!: arg_cong [where f=Inf])
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3064
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3065
lemma setdist_triangle: "setdist S T \<le> setdist S {a} + setdist {a} T"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3066
proof (cases "S = {} \<or> T = {}")
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3067
  case True then show ?thesis
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3068
    using setdist_pos_le by fastforce
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3069
next
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3070
  case False
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3071
  then have "\<And>x. x \<in> S \<Longrightarrow> setdist S T - dist x a \<le> setdist {a} T"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3072
    by (smt (verit, best) dist_self dist_triangle3 empty_not_insert le_setdist_iff setdist_le_dist singleton_iff)
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3073
  then have "setdist S T - setdist {a} T \<le> setdist S {a}"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3074
    using False by (fastforce intro: le_setdistI)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3075
  then show ?thesis
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3076
    by (simp add: algebra_simps)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3077
qed
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3078
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3079
lemma setdist_singletons [simp]: "setdist {x} {y} = dist x y"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3080
  by (simp add: setdist_def)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3081
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3082
lemma setdist_Lipschitz: "\<bar>setdist {x} S - setdist {y} S\<bar> \<le> dist x y"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  3083
  unfolding setdist_singletons [symmetric]
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3084
  by (metis abs_diff_le_iff diff_le_eq setdist_triangle setdist_sym)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3085
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3086
lemma continuous_at_setdist [continuous_intros]: "continuous (at x) (\<lambda>y. (setdist {y} S))"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3087
  by (force simp: continuous_at_eps_delta dist_real_def intro: le_less_trans [OF setdist_Lipschitz])
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3088
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3089
lemma continuous_on_setdist [continuous_intros]: "continuous_on T (\<lambda>y. (setdist {y} S))"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3090
  by (metis continuous_at_setdist continuous_at_imp_continuous_on)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3091
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3092
lemma uniformly_continuous_on_setdist: "uniformly_continuous_on T (\<lambda>y. (setdist {y} S))"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3093
  by (force simp: uniformly_continuous_on_def dist_real_def intro: le_less_trans [OF setdist_Lipschitz])
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3094
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3095
lemma setdist_subset_right: "\<lbrakk>T \<noteq> {}; T \<subseteq> u\<rbrakk> \<Longrightarrow> setdist S u \<le> setdist S T"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3096
  by (smt (verit, best) in_mono le_setdist_iff)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3097
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3098
lemma setdist_subset_left: "\<lbrakk>S \<noteq> {}; S \<subseteq> T\<rbrakk> \<Longrightarrow> setdist T u \<le> setdist S u"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3099
  by (metis setdist_subset_right setdist_sym)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3100
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3101
lemma setdist_closure_1 [simp]: "setdist (closure S) T = setdist S T"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3102
proof (cases "S = {} \<or> T = {}")
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3103
  case True then show ?thesis by force
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3104
next
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3105
  case False
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3106
  { fix y
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3107
    assume "y \<in> T"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3108
    have "continuous_on (closure S) (\<lambda>a. dist a y)"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3109
      by (auto simp: continuous_intros dist_norm)
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3110
    then have *: "\<And>x. x \<in> closure S \<Longrightarrow> setdist S T \<le> dist x y"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3111
      by (fast intro: setdist_le_dist \<open>y \<in> T\<close> continuous_ge_on_closure)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3112
  } then
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3113
  show ?thesis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3114
    by (metis False antisym closure_eq_empty closure_subset le_setdist_iff setdist_subset_left)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3115
qed
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3116
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3117
lemma setdist_closure_2 [simp]: "setdist T (closure S) = setdist T S"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  3118
  by (metis setdist_closure_1 setdist_sym)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3119
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3120
lemma setdist_eq_0I: "\<lbrakk>x \<in> S; x \<in> T\<rbrakk> \<Longrightarrow> setdist S T = 0"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3121
  by (metis antisym dist_self setdist_le_dist setdist_pos_le)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3122
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3123
lemma setdist_unique:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3124
  "\<lbrakk>a \<in> S; b \<in> T; \<And>x y. x \<in> S \<and> y \<in> T ==> dist a b \<le> dist x y\<rbrakk>
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3125
   \<Longrightarrow> setdist S T = dist a b"
82486
451f428c5814 tidying some old proofs
paulson <lp15@cam.ac.uk>
parents: 82470
diff changeset
  3126
  by (force simp: setdist_le_dist le_setdist_iff intro: antisym)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3127
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3128
lemma setdist_le_sing: "x \<in> S ==> setdist S T \<le> setdist {x} T"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3129
  using setdist_subset_left by auto
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  3130
69918
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3131
lemma infdist_eq_setdist: "infdist x A = setdist {x} A"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3132
  by (simp add: infdist_def setdist_def Setcompr_eq_image)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3133
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3134
lemma setdist_eq_infdist: "setdist A B = (if A = {} then 0 else INF a\<in>A. infdist a B)"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3135
proof -
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3136
  have "Inf {dist x y |x y. x \<in> A \<and> y \<in> B} = (INF x\<in>A. Inf (dist x ` B))"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3137
    if "b \<in> B" "a \<in> A" for a b
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3138
  proof (rule order_antisym)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3139
    have "Inf {dist x y |x y. x \<in> A \<and> y \<in> B} \<le> Inf (dist x ` B)"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3140
      if  "b \<in> B" "a \<in> A" "x \<in> A" for x 
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3141
    proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3142
      have "\<And>b'. b' \<in> B \<Longrightarrow> Inf {dist x y |x y. x \<in> A \<and> y \<in> B} \<le> dist x b'"
69918
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3143
        by (metis (mono_tags, lifting) ex_in_conv setdist_def setdist_le_dist that(3))
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3144
      then show ?thesis
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3145
        by (smt (verit) cINF_greatest ex_in_conv \<open>b \<in> B\<close>)
69918
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3146
    qed
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3147
    then show "Inf {dist x y |x y. x \<in> A \<and> y \<in> B} \<le> (INF x\<in>A. Inf (dist x ` B))"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3148
      by (metis (mono_tags, lifting) cINF_greatest emptyE that)
69918
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3149
  next
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3150
    have *: "\<And>x y. \<lbrakk>b \<in> B; a \<in> A; x \<in> A; y \<in> B\<rbrakk> \<Longrightarrow> \<exists>a\<in>A. Inf (dist a ` B) \<le> dist x y"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3151
      by (meson bdd_below_image_dist cINF_lower)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3152
    show "(INF x\<in>A. Inf (dist x ` B)) \<le> Inf {dist x y |x y. x \<in> A \<and> y \<in> B}"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3153
    proof (rule conditionally_complete_lattice_class.cInf_mono)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3154
      show "bdd_below ((\<lambda>x. Inf (dist x ` B)) ` A)"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3155
        by (metis (no_types, lifting) bdd_belowI2 ex_in_conv infdist_def infdist_nonneg that(1))
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3156
    qed (use that in \<open>auto simp: *\<close>)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3157
  qed
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3158
  then show ?thesis
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3159
    by (auto simp: setdist_def infdist_def)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3160
qed
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3161
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3162
lemma infdist_mono:
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3163
  assumes "A \<subseteq> B" "A \<noteq> {}"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3164
  shows "infdist x B \<le> infdist x A"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3165
  by (simp add: assms infdist_eq_setdist setdist_subset_right)
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3166
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3167
lemma infdist_singleton [simp]: "infdist x {y} = dist x y"
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3168
  by (simp add: infdist_eq_setdist)
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3169
69918
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3170
proposition setdist_attains_inf:
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3171
  assumes "compact B" "B \<noteq> {}"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3172
  obtains y where "y \<in> B" "setdist A B = infdist y A"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3173
proof (cases "A = {}")
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3174
  case True
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3175
  then show thesis
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3176
    by (metis assms diameter_compact_attained infdist_def setdist_def that)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3177
next
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3178
  case False
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3179
  obtain y where "y \<in> B" and min: "\<And>y'. y' \<in> B \<Longrightarrow> infdist y A \<le> infdist y' A"
70723
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  3180
    by (metis continuous_attains_inf [OF assms continuous_on_infdist] continuous_on_id)
69918
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3181
  show thesis
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3182
  proof
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3183
    have "setdist A B = (INF y\<in>B. infdist y A)"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3184
      by (metis \<open>B \<noteq> {}\<close> setdist_eq_infdist setdist_sym)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3185
    also have "\<dots> = infdist y A"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3186
    proof (rule order_antisym)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3187
      show "(INF y\<in>B. infdist y A) \<le> infdist y A"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3188
        by (meson \<open>y \<in> B\<close> bdd_belowI2 cInf_lower image_eqI infdist_nonneg)
69918
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3189
    next
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3190
      show "infdist y A \<le> (INF y\<in>B. infdist y A)"
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3191
        by (simp add: \<open>B \<noteq> {}\<close> cINF_greatest min)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3192
    qed
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3193
    finally show "setdist A B = infdist y A" .
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3194
  qed (fact \<open>y \<in> B\<close>)
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3195
qed
eddcc7c726f3 new material;' strengthened material; moved proofs out of Function_Topology in order to lessen its dependencies
paulson <lp15@cam.ac.uk>
parents: 69712
diff changeset
  3196
79772
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3197
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3198
section \<open>Diameter Lemma\<close>
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3199
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3200
text \<open>taken from the AFP entry Martingales, by Ata Keskin, TU München\<close>
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3201
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3202
lemma diameter_comp_strict_mono:
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3203
  fixes s :: "nat \<Rightarrow> 'a :: metric_space"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3204
  assumes "strict_mono r" "bounded {s i |i. r n \<le> i}"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3205
  shows "diameter {s (r i) | i. n \<le> i} \<le> diameter {s i | i. r n \<le> i}"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3206
proof (rule diameter_subset)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3207
  show "{s (r i) | i. n \<le> i} \<subseteq> {s i | i. r n \<le> i}" using assms(1) monotoneD strict_mono_mono by fastforce
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3208
qed (intro assms(2))
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3209
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3210
lemma diameter_bounded_bound':
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3211
  fixes S :: "'a :: metric_space set"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3212
  assumes S: "bdd_above (case_prod dist ` (S\<times>S))" and "x \<in> S" "y \<in> S"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3213
  shows "dist x y \<le> diameter S"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3214
proof -
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3215
  have "(x,y) \<in> S\<times>S" using assms by auto
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3216
  then have "dist x y \<le> (SUP (x,y)\<in>S\<times>S. dist x y)"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3217
    by (metis S cSUP_upper case_prod_conv)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3218
  with \<open>x \<in> S\<close> show ?thesis by (auto simp: diameter_def)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3219
qed
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3220
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3221
lemma bounded_imp_dist_bounded:
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3222
  assumes "bounded (range s)"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3223
  shows "bounded ((\<lambda>(i, j). dist (s i) (s j)) ` ({n..} \<times> {n..}))"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3224
  using bounded_dist_comp[OF bounded_fst bounded_snd, OF bounded_Times(1,1)[OF assms(1,1)]] by (rule bounded_subset, force) 
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3225
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3226
text \<open>A sequence is Cauchy, if and only if it is bounded and its diameter tends to zero. The diameter is well-defined only if the sequence is bounded.\<close>
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3227
lemma cauchy_iff_diameter_tends_to_zero_and_bounded:
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3228
  fixes s :: "nat \<Rightarrow> 'a :: metric_space"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3229
  shows "Cauchy s \<longleftrightarrow> ((\<lambda>n. diameter {s i | i. i \<ge> n}) \<longlonglongrightarrow> 0 \<and> bounded (range s))"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3230
proof -
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3231
  have "{s i |i. N \<le> i} \<noteq> {}" for N by blast
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3232
  hence diameter_SUP: "diameter {s i |i. N \<le> i} = (SUP (i, j) \<in> {N..} \<times> {N..}. dist (s i) (s j))" for N unfolding diameter_def by (auto intro!: arg_cong[of _ _ Sup])
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3233
  show ?thesis 
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3234
  proof (intro iffI)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3235
    assume asm: "Cauchy s"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3236
    have "\<exists>N. \<forall>n\<ge>N. norm (diameter {s i |i. n \<le> i}) < e" if e_pos: "e > 0" for e
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3237
    proof -
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3238
      obtain N where dist_less: "dist (s n) (s m) < (1/2) * e" if "n \<ge> N" "m \<ge> N" for n m using asm e_pos by (metis Cauchy_def mult_pos_pos zero_less_divide_iff zero_less_numeral zero_less_one)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3239
      {
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3240
        fix r assume "r \<ge> N"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3241
        hence "dist (s n) (s m) < (1/2) * e" if "n \<ge> r" "m \<ge> r" for n m using dist_less that by simp
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3242
        hence "(SUP (i, j) \<in> {r..} \<times> {r..}. dist (s i) (s j)) \<le> (1/2) * e" by (intro cSup_least) fastforce+
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3243
        also have "... < e" using e_pos by simp
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3244
        finally have "diameter {s i |i. r \<le> i} < e" using diameter_SUP by presburger
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3245
      }
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3246
      moreover have "diameter {s i |i. r \<le> i} \<ge> 0" for r unfolding diameter_SUP using bounded_imp_dist_bounded[OF cauchy_imp_bounded, THEN bounded_imp_bdd_above, OF asm] by (intro cSup_upper2, auto)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3247
      ultimately show ?thesis by auto
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3248
    qed                 
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3249
    thus "(\<lambda>n. diameter {s i |i. n \<le> i}) \<longlonglongrightarrow> 0 \<and> bounded (range s)" using cauchy_imp_bounded[OF asm] by (simp add: LIMSEQ_iff)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3250
  next
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3251
    assume asm: "(\<lambda>n. diameter {s i |i. n \<le> i}) \<longlonglongrightarrow> 0 \<and> bounded (range s)"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3252
    have "\<exists>N. \<forall>n\<ge>N. \<forall>m\<ge>N. dist (s n) (s m) < e" if e_pos: "e > 0" for e
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3253
    proof -
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3254
      obtain N where diam_less: "diameter {s i |i. r \<le> i} < e" if "r \<ge> N" for r using LIMSEQ_D asm(1) e_pos by fastforce
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3255
      {
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3256
        fix n m assume "n \<ge> N" "m \<ge> N"
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3257
        hence "dist (s n) (s m) < e" using cSUP_lessD[OF bounded_imp_dist_bounded[THEN bounded_imp_bdd_above], OF _ diam_less[unfolded diameter_SUP]] asm by auto
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3258
      }
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3259
      thus ?thesis by blast
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3260
    qed
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3261
    then show "Cauchy s" by (simp add: Cauchy_def)
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3262
  qed            
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3263
qed
817d33f8aa7f Moving valuable library material from Martingales into the distribution
paulson <lp15@cam.ac.uk>
parents: 78890
diff changeset
  3264
  
70723
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  3265
end