src/HOL/Analysis/Elementary_Metric_Spaces.thy
author wenzelm
Tue, 24 Jan 2023 20:39:11 +0100
changeset 77082 4e724a439035
parent 76796 454984e807db
child 77140 9a60c1759543
permissions -rw-r--r--
tuned comments;
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
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     5
*)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     6
71198
1bf7d1acbe74 tuned Analysis manual
immler
parents: 71192
diff changeset
     7
section \<open>Elementary Metric Spaces\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     8
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
     9
theory Elementary_Metric_Spaces
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    10
  imports
69616
d18dc9c5c456 split off theory combining Elementary_Topology and Abstract_Topology
immler
parents: 69615
diff changeset
    11
    Abstract_Topology_2
70951
678b2abe9f7d decision procedure for metric spaces, implemented by Maximilian Schäffeler
immler
parents: 70817
diff changeset
    12
    Metric_Arith
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    13
begin
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    14
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    15
subsection \<open>Open and closed balls\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    16
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
    17
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
    18
  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
    19
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
    20
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
    21
  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
    22
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
    23
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
    24
  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
    25
70951
678b2abe9f7d decision procedure for metric spaces, implemented by Maximilian Schäffeler
immler
parents: 70817
diff changeset
    26
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
    27
  by (simp add: ball_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    28
70951
678b2abe9f7d decision procedure for metric spaces, implemented by Maximilian Schäffeler
immler
parents: 70817
diff changeset
    29
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
    30
  by (simp add: cball_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    31
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    32
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
    33
  by (simp add: sphere_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    34
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    35
lemma ball_trivial [simp]: "ball x 0 = {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
    36
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    37
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    38
lemma cball_trivial [simp]: "cball x 0 = {x}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
    39
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    40
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    41
lemma sphere_trivial [simp]: "sphere x 0 = {x}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
    42
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    43
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    44
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
    45
  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
    46
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    47
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
    48
  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
    49
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    50
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
    51
  for a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    52
  by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    53
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    54
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
    55
  by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    56
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    57
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
    58
  by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    59
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    60
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
    61
  by (simp add: subset_eq)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    62
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    63
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
    64
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    65
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    66
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
    67
  by force
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    68
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    69
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
    70
  by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    71
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    72
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
    73
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    74
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    75
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
    76
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    77
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    78
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
    79
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    80
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    81
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
    82
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    83
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    84
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
    85
  by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    86
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    87
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
    88
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    89
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    90
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
    91
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    92
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    93
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
    94
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    95
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    96
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
    97
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    98
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
    99
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
   100
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   101
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   102
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
   103
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   104
  have "open (dist x -` {..<e})"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   105
    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
   106
  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
   107
    by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   108
  finally show ?thesis .
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   109
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   110
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   111
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
   112
  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
   113
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   114
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
   115
  by (auto simp: open_contains_ball)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   116
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   117
lemma openE[elim?]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   118
  assumes "open S" "x\<in>S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   119
  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
   120
  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
   121
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   122
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
   123
  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
   124
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   125
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
   126
  unfolding mem_ball set_eq_iff
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   127
  by (simp add: not_less) metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   128
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   129
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
   130
  by simp
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   131
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   132
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
   133
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   134
  have "closed (dist x -` {..e})"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   135
    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
   136
  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
   137
    by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   138
  finally show ?thesis .
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   139
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   140
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   141
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
   142
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   143
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   144
    fix x and e::real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   145
    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
   146
    then have "\<exists>d>0. cball x d \<subseteq> S"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   147
      unfolding subset_eq by (rule_tac x="e/2" in exI, auto)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   148
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   149
  moreover
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   150
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   151
    fix x and e::real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   152
    assume "x\<in>S" "e>0" "cball x e \<subseteq> S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   153
    then have "\<exists>d>0. ball x d \<subseteq> S"
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
   154
      using mem_ball_imp_mem_cball by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   155
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   156
  ultimately show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   157
    unfolding open_contains_ball by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   158
qed
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 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
   161
  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
   162
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   163
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
   164
  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
   165
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   166
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
   167
  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
   168
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   169
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
   170
  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
   171
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   172
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
   173
  by (subst at_within_open) auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   174
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   175
lemma atLeastAtMost_eq_cball:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   176
  fixes a b::real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   177
  shows "{a .. b} = cball ((a + b)/2) ((b - a)/2)"
71174
nipkow
parents: 71028
diff changeset
   178
  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
   179
71028
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   180
lemma cball_eq_atLeastAtMost:
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   181
  fixes a b::real
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   182
  shows "cball a b = {a - b .. a + b}"
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   183
  by (auto simp: dist_real_def)
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   184
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   185
lemma greaterThanLessThan_eq_ball:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   186
  fixes a b::real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   187
  shows "{a <..< b} = ball ((a + b)/2) ((b - a)/2)"
71174
nipkow
parents: 71028
diff changeset
   188
  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
   189
71028
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   190
lemma ball_eq_greaterThanLessThan:
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   191
  fixes a b::real
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   192
  shows "ball a b = {a - b <..< a + b}"
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   193
  by (auto simp: dist_real_def)
c2465b429e6e Line_Segment is independent of Convex_Euclidean_Space
immler
parents: 70960
diff changeset
   194
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   195
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
   196
  by (simp add: interior_open)
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_eq_empty [simp]: "cball x e = {} \<longleftrightarrow> e < 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   199
  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
   200
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   201
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
   202
  by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   203
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   204
lemma cball_sing:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   205
  fixes x :: "'a::metric_space"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   206
  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
   207
  by simp
69611
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 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
   210
  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
   211
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   212
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
   213
  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
   214
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   215
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
   216
  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
   217
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   218
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
   219
  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
   220
71192
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   221
lemma cball_scale:
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   222
  assumes "a \<noteq> 0"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   223
  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
   224
proof -
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   225
  have 1: "(\<lambda>x. a *\<^sub>R x) ` cball c r \<subseteq> cball (a *\<^sub>R c) (\<bar>a\<bar> * r)" if "a \<noteq> 0" for a r and c :: 'a
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   226
  proof safe
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   227
    fix x
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   228
    assume x: "x \<in> cball c r"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   229
    have "dist (a *\<^sub>R c) (a *\<^sub>R x) = norm (a *\<^sub>R c - a *\<^sub>R x)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   230
      by (auto simp: dist_norm)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   231
    also have "a *\<^sub>R c - a *\<^sub>R x = a *\<^sub>R (c - x)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   232
      by (simp add: algebra_simps)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   233
    finally show "a *\<^sub>R x \<in> 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
   234
      using that x by (auto simp: dist_norm)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   235
  qed
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   236
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   237
  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
   238
    unfolding image_image using assms by simp
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   239
  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))"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   240
    using assms by (intro image_mono 1) auto
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   241
  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
   242
    using assms by (simp add: algebra_simps)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   243
  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
   244
  moreover from assms have "(\<lambda>x. a *\<^sub>R x) ` cball c r \<subseteq> 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
   245
    by (intro 1) auto
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   246
  ultimately show ?thesis by blast
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   247
qed
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   248
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   249
lemma ball_scale:
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   250
  assumes "a \<noteq> 0"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   251
  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
   252
proof -
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   253
  have 1: "(\<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
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   254
  proof safe
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   255
    fix x
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   256
    assume x: "x \<in> ball c r"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   257
    have "dist (a *\<^sub>R c) (a *\<^sub>R x) = norm (a *\<^sub>R c - a *\<^sub>R x)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   258
      by (auto simp: dist_norm)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   259
    also have "a *\<^sub>R c - a *\<^sub>R x = a *\<^sub>R (c - x)"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   260
      by (simp add: algebra_simps)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   261
    finally show "a *\<^sub>R x \<in> 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
   262
      using that x by (auto simp: dist_norm)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   263
  qed
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   264
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   265
  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
   266
    unfolding image_image using assms by simp
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   267
  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))"
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   268
    using assms by (intro image_mono 1) auto
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   269
  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
   270
    using assms by (simp add: algebra_simps)
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   271
  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
   272
  moreover from assms have "(\<lambda>x. a *\<^sub>R x) ` ball c r \<subseteq> 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
   273
    by (intro 1) auto
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   274
  ultimately show ?thesis by blast
a8ccea88b725 Flattened dependency tree of HOL-Analysis
Manuel Eberl <eberlm@in.tum.de>
parents: 71174
diff changeset
   275
qed
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   276
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   277
subsection \<open>Limit Points\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   278
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   279
lemma islimpt_approachable:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   280
  fixes x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   281
  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
   282
  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
   283
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   284
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
   285
  for x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   286
  unfolding islimpt_approachable
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   287
  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
   288
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   289
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   290
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
   291
  for x :: "'a::metric_space"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   292
  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
   293
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   294
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
   295
  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
   296
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   297
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
   298
  for x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   299
  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
   300
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   301
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
   302
  unfolding islimpt_eq_acc_point
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   303
  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
   304
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   305
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
   306
  unfolding islimpt_eq_infinite_ball
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   307
  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
   308
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   309
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   310
subsection \<open>Perfect Metric Spaces\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   311
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   312
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
   313
  for x :: "'a::{perfect_space,metric_space}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   314
  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
   315
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   316
lemma cball_eq_sing:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   317
  fixes x :: "'a::{metric_space,perfect_space}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   318
  shows "cball x e = {x} \<longleftrightarrow> e = 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   319
  by (smt (verit, best) open_ball ball_eq_empty ball_subset_cball cball_empty cball_trivial 
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   320
      not_open_singleton subset_singleton_iff)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   321
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   322
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   323
subsection \<open>Finite and discrete\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   324
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   325
lemma finite_ball_include:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   326
  fixes a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   327
  assumes "finite S" 
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   328
  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
   329
  using assms
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   330
proof induction
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   331
  case (insert x S)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   332
  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
   333
  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
   334
  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
   335
  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
   336
    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
   337
  ultimately show ?case by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   338
qed (auto intro: zero_less_one)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   339
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   340
lemma finite_set_avoid:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   341
  fixes a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   342
  assumes "finite S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   343
  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
   344
  using assms
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   345
proof induction
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   346
  case (insert x S)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   347
  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
   348
    by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   349
  show ?case
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   350
    by (smt (verit, del_insts) dist_pos_lt insert.IH insert_iff)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   351
qed (auto intro: zero_less_one)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   352
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   353
lemma discrete_imp_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   354
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   355
  assumes e: "0 < e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   356
    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
   357
  shows "closed S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   358
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   359
  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
   360
  proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   361
    from e have e2: "e/2 > 0" by arith
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   362
    from C[OF e2] obtain y where y: "y \<in> S" "y \<noteq> x" "dist y x < e/2"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   363
      by blast
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   364
    from e2 y(2) have mp: "min (e/2) (dist x y) > 0"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   365
      by simp
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   366
    from d y C[OF mp] show ?thesis
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   367
      by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   368
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   369
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   370
    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
   371
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   372
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   373
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   374
subsection \<open>Interior\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   375
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   376
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
   377
  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
   378
  by (simp add: open_subset_interior)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   379
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   380
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
   381
  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
   382
      subset_trans)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   383
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   384
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   385
subsection \<open>Frontier\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   386
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   387
lemma frontier_straddle:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   388
  fixes a :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   389
  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
   390
  unfolding frontier_def closure_interior
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   391
  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
   392
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   393
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   394
subsection \<open>Limits\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   395
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   396
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
   397
  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
   398
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   399
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
   400
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   401
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
   402
    (\<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
   403
  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
   404
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   405
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
   406
    (\<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
   407
  by (auto simp: tendsto_iff eventually_at)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   408
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   409
corollary Lim_withinI [intro?]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   410
  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
   411
  shows "(f \<longlongrightarrow> l) (at a within S)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   412
  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
   413
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   414
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
   415
    (\<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
   416
  by (auto simp: tendsto_iff eventually_at)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   417
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   418
lemma Lim_transform_within_set:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   419
  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
   420
  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
   421
         \<Longrightarrow> (f \<longlongrightarrow> l) (at a within T)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   422
  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
   423
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   424
text \<open>Another limit point characterization.\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   425
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   426
lemma limpt_sequential_inj:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   427
  fixes x :: "'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   428
  shows "x islimpt S \<longleftrightarrow>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   429
         (\<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
   430
         (is "?lhs = ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   431
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   432
  assume ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   433
  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
   434
    by (force simp: islimpt_approachable)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   435
  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
   436
    by metis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   437
  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
   438
  have [simp]: "f 0 = y 1"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   439
            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
   440
    by (simp_all add: f_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   441
  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
   442
  proof (induction n)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   443
    case 0 show ?case
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   444
      by (simp add: y)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   445
  next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   446
    case (Suc n) then show ?case
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   447
      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
   448
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   449
  show ?rhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   450
  proof (intro exI conjI allI)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   451
    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
   452
      using f by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   453
    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
   454
    using that
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   455
    proof (induction n)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   456
      case 0 then show ?case by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   457
    next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   458
      case (Suc n)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   459
      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
   460
      then show ?case
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   461
      proof cases
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   462
        assume "m < n"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   463
        have "dist (f(Suc n)) x = dist (y (min (inverse(2 ^ (Suc n))) (dist (f n) x))) x"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   464
          by (simp add: fSuc)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   465
        also have "\<dots> < dist (f n) x"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   466
          by (metis dist_pos_lt f min.strict_order_iff min_less_iff_conj y)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   467
        also have "\<dots> < dist (f m) x"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   468
          using Suc.IH \<open>m < n\<close> by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   469
        finally show ?thesis .
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   470
      next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   471
        assume "m = n" then show ?case
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   472
          by (smt (verit, best) dist_pos_lt f fSuc y)
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   473
      qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   474
    qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   475
    then show "inj f"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   476
      by (metis less_irrefl linorder_injI)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   477
    have "\<And>e n. \<lbrakk>0 < e; nat \<lceil>1 / e\<rceil> \<le> n\<rbrakk> \<Longrightarrow> dist (f n) x < e"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   478
      apply (rule less_trans [OF f [THEN conjunct2, THEN conjunct2]])
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   479
      by (simp add: divide_simps order_le_less_trans)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   480
    then show "f \<longlonglongrightarrow> x"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   481
      using lim_sequentially by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   482
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   483
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   484
  assume ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   485
  then show ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   486
    by (fastforce simp add: islimpt_approachable lim_sequentially)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   487
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   488
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   489
lemma Lim_dist_ubound:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   490
  assumes "\<not>(trivial_limit net)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   491
    and "(f \<longlongrightarrow> l) net"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   492
    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
   493
  shows "dist a l \<le> e"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   494
  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
   495
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   496
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   497
subsection \<open>Continuity\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   498
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   499
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
   500
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   501
proposition continuous_within_eps_delta:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   502
  "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
   503
  unfolding continuous_within and Lim_within  by fastforce
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   504
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   505
corollary continuous_at_eps_delta:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   506
  "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
   507
  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
   508
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   509
lemma continuous_at_right_real_increasing:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   510
  fixes f :: "real \<Rightarrow> real"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   511
  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
   512
  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
   513
  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
   514
  apply (intro all_cong ex_cong)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   515
  by (smt (verit, best) nondecF)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   516
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   517
lemma continuous_at_left_real_increasing:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   518
  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
   519
  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
   520
  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
   521
  apply (intro all_cong ex_cong)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   522
  by (smt (verit) nondecF)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   523
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   524
text\<open>Versions in terms of open balls.\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   525
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   526
lemma continuous_within_ball:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   527
  "continuous (at x within S) f \<longleftrightarrow>
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   528
    (\<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
   529
  (is "?lhs = ?rhs")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   530
proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   531
  assume ?lhs
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   532
  {
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   533
    fix e :: real
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   534
    assume "e > 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   535
    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
   536
      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
   537
    { fix y
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   538
      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
   539
        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
   540
    }
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   541
    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
   542
      using \<open>d > 0\<close> by blast
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   543
  }
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   544
  then show ?rhs by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   545
next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   546
  assume ?rhs
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   547
  then show ?lhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   548
    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
   549
    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
   550
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   551
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   552
lemma continuous_at_ball:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   553
  "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
   554
  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
   555
  by (smt (verit, ccfv_threshold) dist_commute dist_self)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   556
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   557
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   558
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
   559
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   560
lemma continuous_on_iff:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   561
  "continuous_on s f \<longleftrightarrow>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   562
    (\<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
   563
  unfolding continuous_on_def Lim_within
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   564
  by (metis dist_pos_lt dist_self)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   565
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   566
lemma continuous_within_E:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   567
  assumes "continuous (at x within S) f" "e>0"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   568
  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
   569
  using assms unfolding continuous_within_eps_delta
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   570
  by (metis dense order_le_less_trans)
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
lemma continuous_onI [intro?]:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   573
  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
   574
  shows "continuous_on S f"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   575
apply (simp add: continuous_on_iff, clarify)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   576
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
   577
done
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   578
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   579
text\<open>Some simple consequential lemmas.\<close>
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
lemma continuous_onE:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   582
    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
   583
    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
   584
  using assms
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   585
  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
   586
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   587
text\<open>The usual transformation theorems.\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   588
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   589
lemma continuous_transform_within:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   590
  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
   591
  assumes "continuous (at x within s) f"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   592
    and "0 < d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   593
    and "x \<in> s"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   594
    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
   595
  shows "continuous (at x within s) g"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   596
  using assms
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   597
  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
   598
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   599
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   600
subsection \<open>Closure and Limit Characterization\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   601
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   602
lemma closure_approachable:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   603
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   604
  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
   605
  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
   606
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   607
lemma closure_approachable_le:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   608
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   609
  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
   610
  unfolding closure_approachable
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   611
  using dense by force
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   612
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   613
lemma closure_approachableD:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   614
  assumes "x \<in> closure S" "e>0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   615
  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
   616
  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
   617
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   618
lemma closed_approachable:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   619
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   620
  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
   621
  by (metis closure_closed closure_approachable)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   622
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   623
lemma closure_contains_Inf:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   624
  fixes S :: "real set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   625
  assumes "S \<noteq> {}" "bdd_below S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   626
  shows "Inf S \<in> closure S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   627
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   628
  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
   629
    using cInf_lower[of _ S] assms by metis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   630
  { fix e :: real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   631
    assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   632
    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
   633
    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
   634
      using cInf_lessD by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   635
    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
   636
      using dist_real_def by force
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   637
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   638
  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
   639
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   640
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   641
lemma closure_contains_Sup:
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   642
  fixes S :: "real set"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   643
  assumes "S \<noteq> {}" "bdd_above S"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   644
  shows "Sup S \<in> closure S"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   645
proof -
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   646
  have *: "\<forall>x\<in>S. x \<le> Sup S"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   647
    using cSup_upper[of _ S] assms by metis
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   648
  {
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   649
    fix e :: real
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   650
    assume "e > 0"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   651
    then have "Sup S - e < Sup S" by simp
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   652
    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
   653
      using less_cSupE by blast
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   654
    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
   655
      using dist_real_def by force
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   656
  }
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   657
  then show ?thesis unfolding closure_approachable by auto
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   658
qed
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
   659
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   660
lemma not_trivial_limit_within_ball:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   661
  "\<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
   662
  (is "?lhs \<longleftrightarrow> ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   663
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   664
  show ?rhs if ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   665
  proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   666
    { fix e :: real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   667
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   668
      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
   669
        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
   670
        by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   671
      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
   672
        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
   673
      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
   674
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   675
    then show ?thesis by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   676
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   677
  show ?lhs if ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   678
  proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   679
    { fix e :: real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   680
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   681
      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
   682
        using \<open>?rhs\<close> by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   683
      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
   684
        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
   685
      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
   686
        by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   687
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   688
    then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   689
      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
   690
      by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   691
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   692
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   693
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   694
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   695
subsection \<open>Boundedness\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   696
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   697
  (* FIXME: This has to be unified with BSEQ!! *)
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
   698
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
   699
  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
   700
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   701
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
   702
  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
   703
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   704
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
   705
  unfolding bounded_def
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   706
  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
   707
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   708
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
   709
  unfolding bounded_any_center [where a=0]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   710
  by (simp add: dist_norm)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   711
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   712
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
   713
  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
   714
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   715
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
   716
  by (simp add: bounded_iff)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   717
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   718
lemma boundedI:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   719
  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
   720
  shows "bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   721
  using assms bounded_iff 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
lemma bounded_empty [simp]: "bounded {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   724
  by (simp add: bounded_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   725
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   726
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
   727
  by (metis bounded_def subset_eq)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   728
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   729
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
   730
  by (metis bounded_subset interior_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   731
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   732
lemma bounded_closure[intro]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   733
  assumes "bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   734
  shows "bounded (closure S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   735
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   736
  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
   737
    unfolding bounded_def by auto
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
   738
  { fix y
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   739
    assume "y \<in> closure S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   740
    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
   741
      unfolding closure_sequential by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   742
    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
   743
    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
   744
      by (simp add: f(1))
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   745
    then have "dist x y \<le> a"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   746
      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
   747
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   748
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   749
    unfolding bounded_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   750
qed
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_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
   753
  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
   754
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   755
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
   756
  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
   757
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   758
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
   759
  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
   760
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   761
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
   762
  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
   763
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   764
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
   765
  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
   766
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   767
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
   768
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   769
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   770
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
   771
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   772
  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
   773
    by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   774
  then have "bounded {x}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   775
    unfolding bounded_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   776
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   777
    by (metis insert_is_Un bounded_Un)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   778
qed
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_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
   781
  by (meson bounded_ball bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   782
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   783
lemma bounded_subset_ballD:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   784
  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
   785
proof -
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   786
  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
   787
    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
   788
  then show ?thesis
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   789
    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
   790
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   791
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   792
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
   793
  by (induct set: finite) simp_all
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   794
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   795
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
   796
  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
   797
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   798
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
   799
  by (metis Diff_subset bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   800
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   801
lemma bounded_dist_comp:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   802
  assumes "bounded (f ` S)" "bounded (g ` S)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   803
  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
   804
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   805
  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
   806
    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
   807
  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
   808
    using *[OF that]
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
   809
    by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   810
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   811
    by (auto intro!: boundedI)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   812
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   813
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   814
lemma bounded_Times:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   815
  assumes "bounded s" "bounded t"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   816
  shows "bounded (s \<times> t)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   817
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   818
  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
   819
    using assms [unfolded bounded_def] by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   820
  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
   821
    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
   822
  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
   823
qed
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   824
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
   825
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   826
subsection \<open>Compactness\<close>
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 compact_imp_bounded:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   829
  assumes "compact U"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   830
  shows "bounded U"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   831
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   832
  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
   833
    using assms by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   834
  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
   835
    by (metis compactE_image)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   836
  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
   837
    by (simp add: bounded_UN)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   838
  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
   839
    by (rule bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   840
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   841
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   842
lemma closure_Int_ball_not_empty:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   843
  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
   844
  shows "T \<inter> ball x r \<noteq> {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   845
  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
   846
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   847
lemma compact_sup_maxdistance:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   848
  fixes S :: "'a::metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   849
  assumes "compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   850
    and "S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   851
  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
   852
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   853
  have "compact (S \<times> S)"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   854
    using \<open>compact S\<close> by (intro compact_Times)
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   855
  moreover have "S \<times> S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   856
    using \<open>S \<noteq> {}\<close> by auto
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   857
  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
   858
    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
   859
  ultimately show ?thesis
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   860
    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
   861
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   862
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   863
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   864
subsubsection\<open>Totally bounded\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   865
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   866
lemma cauchy_def: "Cauchy S \<longleftrightarrow> (\<forall>e>0. \<exists>N. \<forall>m n. m \<ge> N \<and> n \<ge> N \<longrightarrow> dist (S m) (S n) < e)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   867
  unfolding Cauchy_def by metis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   868
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   869
proposition seq_compact_imp_totally_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   870
  assumes "seq_compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   871
  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
   872
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   873
  { 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
   874
    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
   875
    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
   876
    proof (rule dependent_wellorder_choice)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   877
      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
   878
      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
   879
        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
   880
      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
   881
        unfolding subset_eq by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   882
      show "\<exists>r. ?Q x n r"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   883
        using z by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   884
    qed simp
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   885
    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
   886
      by blast
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   887
    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
   888
      using assms by (metis seq_compact_def)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   889
    then have "Cauchy (x \<circ> r)"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   890
      using LIMSEQ_imp_Cauchy by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   891
    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"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   892
      unfolding cauchy_def using \<open>e > 0\<close> by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   893
    then have False
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   894
      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
   895
  then show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   896
    by metis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   897
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   898
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   899
subsubsection\<open>Heine-Borel theorem\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   900
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   901
proposition seq_compact_imp_Heine_Borel:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   902
  fixes S :: "'a :: metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   903
  assumes "seq_compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   904
  shows "compact S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   905
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   906
  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
   907
  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
   908
    unfolding choice_iff' ..
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   909
  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
   910
  have "countably_compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   911
    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
   912
  then show "compact S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   913
  proof (rule countably_compact_imp_compact)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   914
    show "countable K"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   915
      unfolding K_def using f
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   916
      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
   917
               intro!: countable_image countable_SIGMA countable_UN)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   918
    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
   919
  next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   920
    fix T x
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   921
    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
   922
    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
   923
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   924
    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
   925
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   926
    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
   927
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   928
    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
   929
      by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   930
    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
   931
      by (auto simp: K_def)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   932
    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
   933
    proof (rule bexI[rotated], safe)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   934
      fix y
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   935
      assume "y \<in> ball k r"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   936
      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
   937
        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
   938
      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
   939
        by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   940
    next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   941
      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
   942
    qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   943
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   944
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   945
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   946
proposition compact_eq_seq_compact_metric:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   947
  "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
   948
  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
   949
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   950
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
   951
  "compact (S :: 'a::metric_space set) \<longleftrightarrow>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   952
   (\<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
   953
  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
   954
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   955
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
   956
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   957
proposition compact_eq_Bolzano_Weierstrass:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   958
  fixes S :: "'a::metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   959
  shows "compact S \<longleftrightarrow> (\<forall>T. infinite T \<and> T \<subseteq> S \<longrightarrow> (\<exists>x \<in> S. x islimpt T))"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   960
  using Bolzano_Weierstrass_imp_seq_compact Heine_Borel_imp_Bolzano_Weierstrass compact_eq_seq_compact_metric 
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   961
  by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   962
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   963
proposition Bolzano_Weierstrass_imp_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
   964
  "(\<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
   965
  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
   966
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
   967
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   968
subsection \<open>Banach fixed point theorem\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   969
  
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   970
theorem banach_fix:\<comment> \<open>TODO: rename to \<open>Banach_fix\<close>\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   971
  assumes s: "complete s" "s \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   972
    and c: "0 \<le> c" "c < 1"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   973
    and f: "f ` s \<subseteq> s"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   974
    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
   975
  shows "\<exists>!x\<in>s. f x = x"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   976
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   977
  from c have "1 - c > 0" by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   978
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   979
  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
   980
  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
   981
  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
   982
    by (induct n) auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   983
  define d where "d = dist (z 0) (z 1)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   984
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   985
  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
   986
    by (simp add: z_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   987
  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
   988
  proof (induct n)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   989
    case 0
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   990
    then show ?case
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   991
      by (simp add: d_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   992
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   993
    case (Suc m)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   994
    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
   995
      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
   996
    then show ?case
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   997
      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
   998
      by (simp add: fzn mult_le_cancel_left)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
   999
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1000
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1001
  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
  1002
  proof (induct n)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1003
    case 0
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1004
    show ?case by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1005
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1006
    case (Suc k)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1007
    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
  1008
        (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
  1009
      by (simp add: dist_triangle)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1010
    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
  1011
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1012
    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
  1013
      by (simp add: field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1014
    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
  1015
      by (simp add: power_add field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1016
    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
  1017
      by (simp add: field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1018
    finally show ?case by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1019
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1020
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1021
  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
  1022
  proof (cases "d = 0")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1023
    case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1024
    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
  1025
      by (simp add: mult_le_0_iff)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1026
    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
  1027
      by (simp add: z_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1028
    with \<open>e > 0\<close> show ?thesis by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1029
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1030
    case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1031
    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
  1032
      by (metis d_def less_le)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1033
    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
  1034
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1035
    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
  1036
      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
  1037
    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
  1038
    proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1039
      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
  1040
        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
  1041
      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
  1042
        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
  1043
      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
  1044
        by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1045
      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
  1046
      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
  1047
        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
  1048
      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
  1049
        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
  1050
        by (simp add: mult.assoc)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1051
      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
  1052
        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
  1053
      also from c \<open>d > 0\<close> \<open>1 - c > 0\<close> have "\<dots> = e * (1 - c ^ (m - n))"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1054
        by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1055
      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
  1056
        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
  1057
      finally show ?thesis by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1058
    qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1059
    have "dist (z n) (z m) < e" if "N \<le> m" "N \<le> n" for m n :: nat
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1060
    proof (cases "n = m")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1061
      case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1062
      with \<open>e > 0\<close> show ?thesis by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1063
    next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1064
      case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1065
      with *[of n m] *[of m n] and that show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1066
        by (auto simp: dist_commute nat_neq_iff)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1067
    qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1068
    then show ?thesis by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1069
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1070
  then have "Cauchy z"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1071
    by (simp add: cauchy_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1072
  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
  1073
    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
  1074
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1075
  define e where "e = dist (f x) x"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1076
  have "e = 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1077
  proof (rule ccontr)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1078
    assume "e \<noteq> 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1079
    then have "e > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1080
      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
  1081
      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
  1082
    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
  1083
      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
  1084
    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
  1085
    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
  1086
      unfolding mult_le_cancel_right2
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1087
      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
  1088
      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
  1089
    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
  1090
      using lipschitz[THEN bspec[where x="z N"], THEN bspec[where x=x]]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1091
      using z_in_s[of N] \<open>x\<in>s\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1092
      using c
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1093
      by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1094
    also have "\<dots> < e/2"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1095
      using N' and c using * by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1096
    finally show False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1097
      unfolding fzn
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1098
      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
  1099
      unfolding e_def
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1100
      by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1101
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1102
  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
  1103
  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
  1104
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1105
    from \<open>x \<in> s\<close> \<open>f x = x\<close> that have "dist x y \<le> c * dist x y"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1106
      using lipschitz[THEN bspec[where x=x], THEN bspec[where x=y]] by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1107
    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
  1108
      by (simp add: mult_le_cancel_right1)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1109
    then show ?thesis by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1110
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1111
  ultimately show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1112
    using \<open>x\<in>s\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1113
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1114
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1115
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1116
subsection \<open>Edelstein fixed point theorem\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1117
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1118
theorem Edelstein_fix:
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1119
  fixes S :: "'a::metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1120
  assumes S: "compact S" "S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1121
    and gs: "(g ` S) \<subseteq> S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1122
    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
  1123
  shows "\<exists>!x\<in>S. g x = x"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1124
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1125
  let ?D = "(\<lambda>x. (x, x)) ` S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1126
  have D: "compact ?D" "?D \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1127
    by (rule compact_continuous_image)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1128
       (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
  1129
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1130
  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
  1131
    using dist by fastforce
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1132
  then have "continuous_on S g"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1133
    by (auto simp: continuous_on_iff)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1134
  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
  1135
    unfolding continuous_on_eq_continuous_within
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1136
    by (intro continuous_dist ballI continuous_within_compose)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1137
       (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
  1138
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1139
  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
  1140
    using continuous_attains_inf[OF D cont] by auto
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 "g a = a"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1143
  proof (rule ccontr)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1144
    assume "g a \<noteq> a"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1145
    with \<open>a \<in> S\<close> gs have "dist (g (g a)) (g a) < dist (g a) a"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1146
      by (intro dist[rule_format]) auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1147
    moreover have "dist (g a) a \<le> dist (g (g a)) (g a)"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1148
      using \<open>a \<in> S\<close> gs by (intro le) auto
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1149
    ultimately show False by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1150
  qed
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1151
  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
  1152
    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
  1153
  ultimately show "\<exists>!x\<in>S. g x = x"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1154
    using \<open>a \<in> S\<close> by blast
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1155
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1156
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1157
subsection \<open>The diameter of a set\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1158
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1159
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
  1160
  "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
  1161
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1162
lemma diameter_empty [simp]: "diameter{} = 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1163
  by (auto simp: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1164
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1165
lemma diameter_singleton [simp]: "diameter{x} = 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1166
  by (auto simp: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1167
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1168
lemma diameter_le:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1169
  assumes "S \<noteq> {} \<or> 0 \<le> d"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1170
    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
  1171
  shows "diameter S \<le> d"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1172
  using assms
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1173
  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
  1174
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1175
lemma diameter_bounded_bound:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1176
  fixes S :: "'a :: metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1177
  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
  1178
  shows "dist x y \<le> diameter S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1179
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1180
  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
  1181
    unfolding bounded_def by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1182
  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
  1183
  proof (intro bdd_aboveI, safe)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1184
    fix a b
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1185
    assume "a \<in> S" "b \<in> S"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1186
    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
  1187
    show "dist a b \<le> 2 * d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1188
      by (simp add: dist_commute)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1189
  qed
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1190
  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
  1191
  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
  1192
    by (rule cSUP_upper2) simp
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1193
  with \<open>x \<in> S\<close> show ?thesis
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1194
    by (auto simp: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1195
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1196
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1197
lemma diameter_lower_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1198
  fixes S :: "'a :: metric_space set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1199
  assumes S: "bounded S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1200
    and d: "0 < d" "d < diameter S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1201
  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
  1202
proof (rule ccontr)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1203
  assume contr: "\<not> ?thesis"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1204
  moreover have "S \<noteq> {}"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1205
    using d by (auto simp: diameter_def)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1206
  ultimately have "diameter S \<le> d"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1207
    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
  1208
  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
  1209
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1210
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1211
lemma diameter_bounded:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1212
  assumes "bounded S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1213
  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
  1214
    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
  1215
  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
  1216
  by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1217
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1218
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
  1219
  by (meson bounded_def diameter_bounded(1))
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1220
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1221
lemma diameter_compact_attained:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1222
  assumes "compact S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1223
    and "S \<noteq> {}"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1224
  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
  1225
proof -
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1226
  have b: "bounded S" using assms(1)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1227
    by (rule compact_imp_bounded)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1228
  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
  1229
    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
  1230
    using compact_sup_maxdistance[OF assms] by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1231
  then have "diameter S \<le> dist x y"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1232
    unfolding diameter_def by (force intro!: cSUP_least)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1233
  then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1234
    by (metis b diameter_bounded_bound order_antisym xys)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1235
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1236
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1237
lemma diameter_ge_0:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1238
  assumes "bounded S"  shows "0 \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1239
  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
  1240
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1241
lemma diameter_subset:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1242
  assumes "S \<subseteq> T" "bounded T"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1243
  shows "diameter S \<le> diameter T"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1244
proof (cases "S = {} \<or> T = {}")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1245
  case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1246
  with assms show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1247
    by (force simp: diameter_ge_0)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1248
next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1249
  case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1250
  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
  1251
    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
  1252
  with False \<open>S \<subseteq> T\<close> show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1253
    apply (simp add: diameter_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1254
    apply (rule cSUP_subset_mono, auto)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1255
    done
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1256
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1257
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1258
lemma diameter_closure:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1259
  assumes "bounded S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1260
  shows "diameter(closure S) = diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1261
proof (rule order_antisym)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1262
  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
  1263
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1264
    define d where "d = diameter(closure S) - diameter(S)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1265
    have "d > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1266
      using that by (simp add: d_def)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1267
    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
  1268
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1269
    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
  1270
      by (simp add: d_def field_split_simps)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1271
     have bocl: "bounded (closure S)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1272
      using assms by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1273
    moreover have "0 \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1274
      using assms diameter_ge_0 by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1275
    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
  1276
      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
  1277
    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
  1278
      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
  1279
    then have "dist x' y' \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1280
      using assms diameter_bounded_bound by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1281
    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
  1282
      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
  1283
    then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1284
      using xy d_def by linarith
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1285
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1286
  then show "diameter (closure S) \<le> diameter S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1287
    by fastforce
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1288
  next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1289
    show "diameter S \<le> diameter (closure S)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1290
      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
  1291
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1292
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1293
proposition Lebesgue_number_lemma:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1294
  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
  1295
  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
  1296
proof (cases "S = {}")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1297
  case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1298
  then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1299
    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
  1300
next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1301
  case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1302
  { fix x assume "x \<in> S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1303
    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
  1304
      using \<open>S \<subseteq> \<Union>\<C>\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1305
    then obtain r where r: "r>0" "ball x (2*r) \<subseteq> C"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1306
      by (metis mult.commute mult_2_right not_le ope openE field_sum_of_halves zero_le_numeral zero_less_mult_iff)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1307
    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
  1308
      using C by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1309
  }
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1310
  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
  1311
    by metis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1312
  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
  1313
    by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1314
  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
  1315
    by (rule compactE [OF \<open>compact S\<close>]) auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1316
  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
  1317
    by (meson finite_subset_image)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1318
  then have "S0 \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1319
    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
  1320
  define \<delta> where "\<delta> = Inf (r ` S0)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1321
  have "\<delta> > 0"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1322
    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
  1323
  show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1324
  proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1325
    show "0 < \<delta>"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1326
      by (simp add: \<open>0 < \<delta>\<close>)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1327
    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
  1328
    proof (cases "T = {}")
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1329
      case True
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1330
      then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1331
        using \<open>\<C> \<noteq> {}\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1332
    next
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1333
      case False
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1334
      then obtain y where "y \<in> T" by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1335
      then have "y \<in> S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1336
        using \<open>T \<subseteq> S\<close> by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1337
      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
  1338
        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
  1339
      have "ball y \<delta> \<subseteq> ball y (r x)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1340
        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
  1341
      also have "... \<subseteq> ball x (2*r x)"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  1342
        using x by metric
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1343
      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
  1344
        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
  1345
      have "bounded T"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1346
        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
  1347
      then have "T \<subseteq> ball y \<delta>"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1348
        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
  1349
      then show ?thesis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1350
        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
  1351
    qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1352
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1353
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1354
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1355
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1356
subsection \<open>Metric spaces with the Heine-Borel property\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1357
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1358
text \<open>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1359
  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
  1360
  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
  1361
\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1362
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1363
class heine_borel = metric_space +
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1364
  assumes bounded_imp_convergent_subsequence:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1365
    "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
  1366
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1367
proposition bounded_closed_imp_seq_compact:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1368
  fixes S::"'a::heine_borel set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1369
  assumes "bounded S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1370
    and "closed S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1371
  shows "seq_compact S"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1372
proof (unfold seq_compact_def, clarify)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1373
  fix f :: "nat \<Rightarrow> 'a"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1374
  assume f: "\<forall>n. f n \<in> S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1375
  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
  1376
    by (auto intro: bounded_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1377
  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
  1378
    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
  1379
  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
  1380
    by simp
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1381
  have "l \<in> S" using \<open>closed S\<close> fr l
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1382
    by (rule closed_sequentially)
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1383
  show "\<exists>l\<in>S. \<exists>r. strict_mono r \<and> ((f \<circ> r) \<longlongrightarrow> l) sequentially"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1384
    using \<open>l \<in> S\<close> r l by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1385
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1386
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1387
lemma compact_eq_bounded_closed:
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1388
  fixes S :: "'a::heine_borel set"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1389
  shows "compact S \<longleftrightarrow> bounded S \<and> closed S"
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1390
  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
  1391
  by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1392
73885
26171a89466a A few useful lemmas about derivatives, colinearity and other topics
paulson <lp15@cam.ac.uk>
parents: 72569
diff changeset
  1393
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
  1394
  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
  1395
  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
  1396
  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
  1397
  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
  1398
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1399
lemma compact_Inter:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1400
  fixes \<F> :: "'a :: heine_borel set set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1401
  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
  1402
  shows "compact(\<Inter> \<F>)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1403
  using assms
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1404
  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
  1405
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1406
lemma compact_closure [simp]:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1407
  fixes S :: "'a::heine_borel set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1408
  shows "compact(closure S) \<longleftrightarrow> bounded S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1409
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
  1410
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1411
instance\<^marker>\<open>tag important\<close> real :: heine_borel
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1412
proof
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1413
  fix f :: "nat \<Rightarrow> real"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1414
  assume f: "bounded (range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1415
  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
  1416
    unfolding comp_def by (metis seq_monosub)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1417
  then have "Bseq (f \<circ> r)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1418
    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
  1419
  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
  1420
    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
  1421
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1422
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1423
lemma compact_lemma_general:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1424
  fixes f :: "nat \<Rightarrow> 'a"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1425
  fixes proj::"'a \<Rightarrow> 'b \<Rightarrow> 'c::heine_borel" (infixl "proj" 60)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1426
  fixes unproj:: "('b \<Rightarrow> 'c) \<Rightarrow> 'a"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1427
  assumes finite_basis: "finite basis"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1428
  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
  1429
  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
  1430
  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
  1431
  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
  1432
    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
  1433
proof safe
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1434
  fix d :: "'b set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1435
  assume d: "d \<subseteq> basis"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1436
  with finite_basis have "finite d"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1437
    by (blast intro: finite_subset)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1438
  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
  1439
    (\<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
  1440
  proof (induct d)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1441
    case empty
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1442
    then show ?case
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1443
      unfolding strict_mono_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1444
  next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1445
    case (insert k d)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1446
    have k[intro]: "k \<in> basis"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1447
      using insert by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1448
    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
  1449
      using k
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1450
      by (rule bounded_proj)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1451
    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
  1452
      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
  1453
      using insert by auto
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1454
    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
  1455
      by simp
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1456
    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
  1457
      by (metis (lifting) bounded_subset f' image_subsetI s')
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1458
    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
  1459
      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
  1460
      by (auto simp: o_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1461
    define r where "r = r1 \<circ> r2"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1462
    have r: "strict_mono r"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1463
      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
  1464
    moreover
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1465
    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
  1466
    { fix e::real
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1467
      assume "e > 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1468
      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
  1469
        by blast
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1470
      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
  1471
        by (rule tendstoD)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1472
      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
  1473
        by (rule eventually_subseq)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1474
      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
  1475
        using N1' N2
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1476
        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
  1477
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1478
    ultimately show ?case by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1479
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1480
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1481
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1482
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
  1483
  unfolding bounded_def
73932
fd21b4a93043 added opaque_combs and renamed hide_lams to opaque_lifting
desharna
parents: 72569
diff changeset
  1484
  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
  1485
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1486
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
  1487
  unfolding bounded_def
73932
fd21b4a93043 added opaque_combs and renamed hide_lams to opaque_lifting
desharna
parents: 72569
diff changeset
  1488
  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
  1489
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1490
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
  1491
proof
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1492
  fix f :: "nat \<Rightarrow> 'a \<times> 'b"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1493
  assume f: "bounded (range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1494
  then have "bounded (fst ` range f)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1495
    by (rule bounded_fst)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1496
  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
  1497
    by (simp add: image_comp)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1498
  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
  1499
    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
  1500
  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
  1501
    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
  1502
  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
  1503
    using bounded_imp_convergent_subsequence [OF s2]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1504
    unfolding o_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1505
  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
  1506
    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
  1507
  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
  1508
    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
  1509
  have r: "strict_mono (r1 \<circ> r2)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1510
    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
  1511
  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
  1512
    using l r by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1513
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1514
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1515
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1516
subsection \<open>Completeness\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1517
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1518
proposition (in metric_space) completeI:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1519
  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
  1520
  shows "complete s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1521
  using assms unfolding complete_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1522
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1523
proposition (in metric_space) completeE:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1524
  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
  1525
  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
  1526
  using assms unfolding complete_def by fast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1527
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1528
(* TODO: generalize to uniform spaces *)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1529
lemma compact_imp_complete:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1530
  fixes s :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1531
  assumes "compact s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1532
  shows "complete s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1533
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1534
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1535
    fix f
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1536
    assume as: "(\<forall>n::nat. f n \<in> s)" "Cauchy f"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1537
    from as(1) obtain l r where lr: "l\<in>s" "strict_mono r" "(f \<circ> r) \<longlonglongrightarrow> l"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1538
      using assms unfolding compact_def by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1539
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1540
    note lr' = seq_suble [OF lr(2)]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1541
    {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1542
      fix e :: real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1543
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1544
      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"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1545
        unfolding cauchy_def using \<open>e > 0\<close> by (meson half_gt_zero)
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1546
      then obtain M where M:"\<forall>n\<ge>M. dist ((f \<circ> r) n) l < e/2"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1547
        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
  1548
      {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1549
        fix n :: nat
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1550
        assume n: "n \<ge> max N M"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1551
        have "dist ((f \<circ> r) n) l < e/2"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1552
          using n M by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1553
        moreover have "r n \<ge> N"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1554
          using lr'[of n] n by auto
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1555
        then have "dist (f n) ((f \<circ> r) n) < e/2"
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1556
          using N and n by auto
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  1557
        ultimately have "dist (f n) l < e" using n M
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  1558
          by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1559
      }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1560
      then have "\<exists>N. \<forall>n\<ge>N. dist (f n) l < e" by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1561
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1562
    then have "\<exists>l\<in>s. (f \<longlongrightarrow> l) sequentially" using \<open>l\<in>s\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1563
      unfolding lim_sequentially by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1564
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1565
  then show ?thesis unfolding complete_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1566
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1567
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1568
proposition compact_eq_totally_bounded:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1569
  "compact s \<longleftrightarrow> complete s \<and> (\<forall>e>0. \<exists>k. finite k \<and> s \<subseteq> (\<Union>x\<in>k. ball x e))"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1570
    (is "_ \<longleftrightarrow> ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1571
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1572
  assume assms: "?rhs"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1573
  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)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1574
    by (auto simp: choice_iff')
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1575
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1576
  show "compact s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1577
  proof cases
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1578
    assume "s = {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1579
    then show "compact s" by (simp add: compact_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1580
  next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1581
    assume "s \<noteq> {}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1582
    show ?thesis
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1583
      unfolding compact_def
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1584
    proof safe
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1585
      fix f :: "nat \<Rightarrow> 'a"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1586
      assume f: "\<forall>n. f n \<in> s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1587
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1588
      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
  1589
      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
  1590
      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
  1591
      {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1592
        fix n U
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1593
        assume "infinite {n. f n \<in> U}"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1594
        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
  1595
          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
  1596
        then obtain a where
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1597
          "a \<in> k (e n)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1598
          "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
  1599
        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
  1600
          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
  1601
        from someI_ex[OF this]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1602
        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
  1603
          unfolding B_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1604
      }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1605
      note B = this
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1606
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1607
      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
  1608
      {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1609
        fix n
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1610
        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
  1611
          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
  1612
      }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1613
      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
  1614
        using B by (simp add: F_def)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1615
      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
  1616
        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
  1617
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1618
      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
  1619
      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
  1620
        fix k i
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1621
        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
  1622
          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
  1623
        from infinite_imp_nonempty[OF this]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1624
        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
  1625
          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
  1626
      qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1627
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1628
      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
  1629
      have "strict_mono t"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1630
        unfolding strict_mono_Suc_iff by (simp add: t_def sel)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1631
      moreover have "\<forall>i. (f \<circ> t) i \<in> s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1632
        using f by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1633
      moreover
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  1634
      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
  1635
        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
  1636
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1637
      have "Cauchy (f \<circ> t)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1638
      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
  1639
        fix r :: real and N n m
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1640
        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
  1641
        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
  1642
          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
  1643
        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
  1644
          by (auto simp: subset_eq)
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  1645
        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
  1646
          by metric
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1647
      qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1648
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1649
      ultimately show "\<exists>l\<in>s. \<exists>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
  1650
        using assms unfolding complete_def by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1651
    qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1652
  qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1653
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
  1654
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1655
lemma cauchy_imp_bounded:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1656
  assumes "Cauchy s"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1657
  shows "bounded (range s)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1658
proof -
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1659
  from assms obtain N :: nat where "\<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (s m) (s n) < 1"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1660
    unfolding cauchy_def by force
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1661
  then have N:"\<forall>n. N \<le> n \<longrightarrow> dist (s N) (s n) < 1" by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1662
  moreover
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1663
  have "bounded (s ` {0..N})"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1664
    using finite_imp_bounded[of "s ` {1..N}"] by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1665
  then obtain a where a:"\<forall>x\<in>s ` {0..N}. dist (s N) x \<le> a"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1666
    unfolding bounded_any_center [where a="s N"] by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1667
  ultimately show "?thesis"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1668
    unfolding bounded_any_center [where a="s N"]
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1669
    apply (rule_tac x="max a 1" in exI, auto)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1670
    apply (erule_tac x=y in allE)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1671
    apply (erule_tac x=y in ballE, auto)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1672
    done
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1673
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1674
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1675
instance heine_borel < complete_space
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1676
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1677
  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
  1678
  then show "convergent f"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1679
    unfolding convergent_def
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1680
    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
  1681
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1682
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1683
lemma complete_UNIV: "complete (UNIV :: ('a::complete_space) set)"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1684
proof (rule completeI)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1685
  fix f :: "nat \<Rightarrow> 'a" assume "Cauchy f"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1686
  then show "\<exists>l\<in>UNIV. f \<longlonglongrightarrow> l" 
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1687
    using Cauchy_convergent convergent_def by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1688
qed
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
lemma complete_imp_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1691
  fixes S :: "'a::metric_space set"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1692
  shows "complete S \<Longrightarrow> closed S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1693
  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
  1694
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1695
lemma complete_Int_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1696
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1697
  assumes "complete S" and "closed t"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1698
  shows "complete (S \<inter> t)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1699
  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
  1700
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1701
lemma complete_closed_subset:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1702
  fixes S :: "'a::metric_space set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1703
  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
  1704
  shows "complete S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1705
  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
  1706
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1707
lemma complete_eq_closed:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1708
  fixes S :: "('a::complete_space) set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1709
  shows "complete S \<longleftrightarrow> closed S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1710
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1711
  assume "closed S" then show "complete S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1712
    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
  1713
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1714
  assume "complete S" then show "closed S"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1715
    by (rule complete_imp_closed)
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1716
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1717
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1718
lemma convergent_eq_Cauchy:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1719
  fixes S :: "nat \<Rightarrow> 'a::complete_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1720
  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
  1721
  unfolding Cauchy_convergent_iff convergent_def ..
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1722
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1723
lemma convergent_imp_bounded:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1724
  fixes S :: "nat \<Rightarrow> 'a::metric_space"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1725
  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
  1726
  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
  1727
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1728
lemma frontier_subset_compact:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1729
  fixes S :: "'a::heine_borel set"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1730
  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
  1731
  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
  1732
  by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  1733
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1734
lemma continuous_closed_imp_Cauchy_continuous:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1735
  fixes S :: "('a::complete_space) set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1736
  shows "\<lbrakk>continuous_on S f; closed S; Cauchy \<sigma>; \<And>n. (\<sigma> n) \<in> S\<rbrakk> \<Longrightarrow> Cauchy(f \<circ> \<sigma>)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1737
  by (meson LIMSEQ_imp_Cauchy completeE complete_eq_closed continuous_on_sequentially)
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1738
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1739
lemma banach_fix_type:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1740
  fixes f::"'a::complete_space\<Rightarrow>'a"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1741
  assumes c:"0 \<le> c" "c < 1"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1742
      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
  1743
  shows "\<exists>!x. (f x = x)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1744
  using assms banach_fix[OF complete_UNIV UNIV_not_empty assms(1,2) subset_UNIV, of f]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1745
  by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1746
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1747
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1748
subsection\<^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
  1749
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1750
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
  1751
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1752
lemma closed_imp_fip:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1753
  fixes S :: "'a::heine_borel set"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1754
  assumes "closed S"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1755
      and T: "T \<in> \<F>" "bounded T"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1756
      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
  1757
      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
  1758
    shows "S \<inter> \<Inter>\<F> \<noteq> {}"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1759
proof -
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1760
  have "compact (S \<inter> T)"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1761
    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
  1762
  then have "(S \<inter> T) \<inter> \<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1763
    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
  1764
  then show ?thesis by blast
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1765
qed
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1766
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1767
lemma closed_imp_fip_compact:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1768
  fixes S :: "'a::heine_borel set"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1769
  shows
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1770
   "\<lbrakk>closed S; \<And>T. T \<in> \<F> \<Longrightarrow> compact T;
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1771
     \<And>\<F>'. \<lbrakk>finite \<F>'; \<F>' \<subseteq> \<F>\<rbrakk> \<Longrightarrow> S \<inter> \<Inter>\<F>' \<noteq> {}\<rbrakk>
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1772
        \<Longrightarrow> S \<inter> \<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1773
  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
  1774
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1775
lemma closed_fip_Heine_Borel:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1776
  fixes \<F> :: "'a::heine_borel set set"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1777
  assumes "T \<in> \<F>" "bounded T"
69615
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1778
      and "\<And>T. T \<in> \<F> \<Longrightarrow> closed T"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1779
      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
  1780
    shows "\<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1781
  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
  1782
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1783
lemma compact_fip_Heine_Borel:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1784
  fixes \<F> :: "'a::heine_borel set set"
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1785
  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
  1786
      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
  1787
    shows "\<Inter>\<F> \<noteq> {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1788
  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
  1789
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1790
lemma compact_sequence_with_limit:
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1791
  fixes f :: "nat \<Rightarrow> 'a::heine_borel"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1792
  shows "f \<longlonglongrightarrow> l \<Longrightarrow> compact (insert l (range f))"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1793
  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
  1794
e502cd4d7062 moved material from Connected.thy to more appropriate places
immler
parents: 69613
diff changeset
  1795
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1796
subsection \<open>Properties of Balls and Spheres\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1797
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1798
lemma compact_cball[simp]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1799
  fixes x :: "'a::heine_borel"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1800
  shows "compact (cball x e)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1801
  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
  1802
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1803
lemma compact_frontier_bounded[intro]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1804
  fixes S :: "'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1805
  shows "bounded S \<Longrightarrow> compact (frontier S)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1806
  unfolding frontier_def
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1807
  using compact_eq_bounded_closed by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1808
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1809
lemma compact_frontier[intro]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1810
  fixes S :: "'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1811
  shows "compact S \<Longrightarrow> compact (frontier S)"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1812
  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
  1813
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1814
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1815
subsection \<open>Distance from a Set\<close>
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1816
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1817
lemma distance_attains_sup:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1818
  assumes "compact s" "s \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1819
  shows "\<exists>x\<in>s. \<forall>y\<in>s. dist a y \<le> dist a x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1820
proof (rule continuous_attains_sup [OF assms])
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1821
  {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1822
    fix x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1823
    assume "x\<in>s"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1824
    have "(dist a \<longlongrightarrow> dist a x) (at x within s)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1825
      by (intro tendsto_dist tendsto_const tendsto_ident_at)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1826
  }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1827
  then show "continuous_on s (dist a)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1828
    unfolding continuous_on ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1829
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1830
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1831
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
  1832
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1833
lemma distance_attains_inf:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1834
  fixes a :: "'a::heine_borel"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1835
  assumes "closed s" and "s \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1836
  obtains x where "x\<in>s" "\<And>y. y \<in> s \<Longrightarrow> dist a x \<le> dist a y"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1837
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1838
  from assms obtain b where "b \<in> s" by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1839
  let ?B = "s \<inter> cball a (dist b a)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1840
  have "?B \<noteq> {}" using \<open>b \<in> s\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1841
    by (auto simp: dist_commute)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1842
  moreover have "continuous_on ?B (dist a)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1843
    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
  1844
  moreover have "compact ?B"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1845
    by (intro closed_Int_compact \<open>closed s\<close> compact_cball)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1846
  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
  1847
    by (metis continuous_attains_inf)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1848
  with that show ?thesis by fastforce
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1849
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1850
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  1851
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1852
subsection \<open>Infimum Distance\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1853
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  1854
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
  1855
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1856
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
  1857
  by (auto intro!: zero_le_dist)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1858
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1859
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
  1860
  by (simp add: infdist_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1861
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1862
lemma infdist_nonneg: "0 \<le> infdist x A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1863
  by (auto simp: infdist_def intro: cINF_greatest)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1864
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1865
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
  1866
  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
  1867
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1868
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
  1869
  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
  1870
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1871
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
  1872
  by (auto intro!: antisym infdist_nonneg infdist_le2)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1873
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  1874
lemma infdist_Un_min:
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  1875
  assumes "A \<noteq> {}" "B \<noteq> {}"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  1876
  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
  1877
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
  1878
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1879
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
  1880
proof (cases "A = {}")
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1881
  case True
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1882
  then show ?thesis by (simp add: infdist_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1883
next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1884
  case False
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1885
  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
  1886
  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
  1887
  proof (rule cInf_greatest)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1888
    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
  1889
      by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1890
    fix d
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1891
    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
  1892
    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
  1893
      by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1894
    show "infdist x A \<le> d"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1895
      unfolding infdist_notempty[OF \<open>A \<noteq> {}\<close>]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1896
    proof (rule cINF_lower2)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1897
      show "a \<in> A" by fact
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1898
      show "dist x a \<le> d"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1899
        unfolding d by (rule dist_triangle)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1900
    qed simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1901
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1902
  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
  1903
  proof (rule cInf_eq, safe)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1904
    fix a
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1905
    assume "a \<in> A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1906
    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
  1907
      by (auto intro: infdist_le)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1908
  next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1909
    fix i
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1910
    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
  1911
    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
  1912
      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
  1913
      by (intro cINF_greatest) (auto simp: field_simps)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1914
    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
  1915
      by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1916
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1917
  finally show ?thesis by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1918
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1919
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  1920
lemma infdist_triangle_abs: "\<bar>infdist x A - infdist y A\<bar> \<le> dist x y"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  1921
  by (metis (full_types) abs_diff_le_iff diff_le_eq dist_commute infdist_triangle)
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  1922
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1923
lemma in_closure_iff_infdist_zero:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1924
  assumes "A \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1925
  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
  1926
proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1927
  assume "x \<in> closure A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1928
  show "infdist x A = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1929
  proof (rule ccontr)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1930
    assume "infdist x A \<noteq> 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1931
    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
  1932
      by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1933
    then have "ball x (infdist x A) \<inter> closure A = {}"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1934
      by (smt (verit, best) \<open>x \<in> closure A\<close> closure_approachableD infdist_le)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1935
    then have "x \<notin> closure A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1936
      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
  1937
    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
  1938
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1939
next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1940
  assume x: "infdist x A = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1941
  then obtain a where "a \<in> A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1942
    by atomize_elim (metis all_not_in_conv assms)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1943
  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
  1944
  proof -
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1945
    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
  1946
      unfolding infdist_def using that
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1947
      by (force simp: dist_commute intro: cINF_greatest)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1948
    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
  1949
  qed
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1950
  then show "x \<in> closure A"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1951
    using closure_approachable by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1952
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1953
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1954
lemma in_closed_iff_infdist_zero:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1955
  assumes "closed A" "A \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1956
  shows "x \<in> A \<longleftrightarrow> infdist x A = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1957
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1958
  have "x \<in> closure A \<longleftrightarrow> infdist x A = 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1959
    by (simp add: \<open>A \<noteq> {}\<close> in_closure_iff_infdist_zero)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1960
  with assms show ?thesis by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1961
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1962
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1963
lemma infdist_pos_not_in_closed:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1964
  assumes "closed S" "S \<noteq> {}" "x \<notin> S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1965
  shows "infdist x S > 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1966
  by (smt (verit, best) assms in_closed_iff_infdist_zero infdist_nonneg)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1967
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1968
lemma
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1969
  infdist_attains_inf:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1970
  fixes X::"'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1971
  assumes "closed X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1972
  assumes "X \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1973
  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
  1974
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1975
  have "bdd_below (dist y ` X)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1976
    by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1977
  from distance_attains_inf[OF assms, of y]
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1978
  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
  1979
  then have "infdist y X = dist y x"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1980
    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
  1981
  with \<open>x \<in> X\<close> show ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1982
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1983
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1984
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1985
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
  1986
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1987
instance metric_space \<subseteq> t4_space
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1988
proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1989
  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
  1990
  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
  1991
  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
  1992
  proof (cases)
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1993
    case 1 then show ?thesis by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1994
  next
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  1995
    case 2 then show ?thesis by blast
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1996
  next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1997
    case 3
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  1998
    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
  1999
    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
  2000
    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
  2001
      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
  2002
    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
  2003
    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
  2004
    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
  2005
    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
  2006
      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
  2007
    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
  2008
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2009
    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
  2010
    proof auto
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2011
      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
  2012
      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
  2013
        by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2014
      also have "... < infdist x T + infdist y S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2015
        using H by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2016
      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
  2017
        by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2018
      then show False
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2019
        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
  2020
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2021
    then have E: "U \<inter> V = {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2022
      unfolding U_def V_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2023
    show ?thesis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2024
      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
  2025
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2026
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2027
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2028
lemma tendsto_infdist [tendsto_intros]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2029
  assumes f: "(f \<longlongrightarrow> l) F"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2030
  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
  2031
proof (rule tendstoI)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2032
  fix e ::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2033
  assume "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2034
  from tendstoD[OF f this]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2035
  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
  2036
  proof (eventually_elim)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2037
    fix x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2038
    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
  2039
    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
  2040
      by (simp add: dist_commute dist_real_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2041
    also assume "dist (f x) l < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2042
    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
  2043
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2044
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2045
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2046
lemma continuous_infdist[continuous_intros]:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2047
  assumes "continuous F f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2048
  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
  2049
  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
  2050
70723
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  2051
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
  2052
  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
  2053
  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
  2054
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
  2055
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2056
lemma compact_infdist_le:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2057
  fixes A::"'a::heine_borel set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2058
  assumes "A \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2059
  assumes "compact A"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2060
  assumes "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2061
  shows "compact {x. infdist x A \<le> e}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2062
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2063
  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
  2064
    continuous_infdist[OF continuous_ident, of _ UNIV A]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2065
  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
  2066
  moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2067
  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
  2068
    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
  2069
  {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2070
    fix y
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2071
    assume "infdist y A \<le> e"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2072
    moreover
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2073
    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
  2074
    obtain z where "z \<in> A" "infdist y A = dist y z" by blast
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2075
    ultimately
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2076
    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
  2077
  } then
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2078
  have "bounded {x. infdist x A \<le> e}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2079
    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
  2080
  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
  2081
    by (simp add: compact_eq_bounded_closed)
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
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2084
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2085
subsection \<open>Separation between Points and Sets\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2086
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2087
proposition separate_point_closed:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2088
  fixes S :: "'a::heine_borel set"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2089
  assumes "closed S" and "a \<notin> S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2090
  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
  2091
  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
  2092
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2093
proposition separate_compact_closed:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2094
  fixes S T :: "'a::heine_borel set"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2095
  assumes "compact S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2096
    and T: "closed T" "S \<inter> T = {}"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2097
  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
  2098
proof cases
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2099
  assume "S \<noteq> {} \<and> T \<noteq> {}"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2100
  then have "S \<noteq> {}" "T \<noteq> {}" by auto
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2101
  let ?inf = "\<lambda>x. infdist x T"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2102
  have "continuous_on S ?inf"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2103
    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
  2104
  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
  2105
    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
  2106
  then have "0 < ?inf x"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2107
    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
  2108
  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
  2109
    using x by (auto intro: order_trans infdist_le)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2110
  ultimately show ?thesis by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2111
qed (auto intro!: exI[of _ 1])
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2112
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2113
proposition separate_closed_compact:
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2114
  fixes S T :: "'a::heine_borel set"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2115
  assumes S: "closed S"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2116
    and T: "compact T"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2117
    and dis: "S \<inter> T = {}"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2118
  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
  2119
  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
  2120
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2121
proposition compact_in_open_separated:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2122
  fixes A::"'a::heine_borel set"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2123
  assumes A: "A \<noteq> {}" "compact A"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2124
  assumes "open B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2125
  assumes "A \<subseteq> B"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2126
  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
  2127
proof atomize_elim
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2128
  have "closed (- B)" "compact A" "- B \<inter> A = {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2129
    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
  2130
  from separate_closed_compact[OF this]
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2131
  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
  2132
    by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2133
  define d where "d = d' / 2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2134
  hence "d>0" "d < d'" using d' by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2135
  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
  2136
    by force
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2137
  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
  2138
  proof (rule ccontr)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2139
    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
  2140
    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
  2141
      by auto
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2142
    then show False
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2143
      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
  2144
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2145
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2146
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2147
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2148
subsection \<open>Uniform Continuity\<close>
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2149
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2150
lemma uniformly_continuous_onE:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2151
  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
  2152
  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
  2153
  using assms
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2154
  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
  2155
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2156
lemma uniformly_continuous_on_sequentially:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2157
  "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
  2158
    (\<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
  2159
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2160
  assume ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2161
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2162
    fix x y
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2163
    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
  2164
      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
  2165
      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
  2166
    {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2167
      fix e :: real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2168
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2169
      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
  2170
        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
  2171
      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
  2172
        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
  2173
      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
  2174
        using d x y by blast
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2175
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2176
    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
  2177
      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
  2178
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2179
  then show ?rhs by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2180
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2181
  assume ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2182
  {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2183
    assume "\<not> ?lhs"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2184
    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
  2185
      unfolding uniformly_continuous_on_def by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2186
    then obtain fa where fa:
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2187
      "\<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
  2188
      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
  2189
      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
  2190
    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
  2191
    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
  2192
    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
  2193
      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
  2194
      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
  2195
      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
  2196
      by auto
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2197
    {
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2198
      fix e :: real
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2199
      assume "e > 0"
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2200
      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
  2201
        unfolding real_arch_inverse[of e] by auto
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2202
      then have "\<exists>N. \<forall>n\<ge>N. dist (x n) (y n) < e"
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2203
        by (smt (verit, ccfv_SIG) inverse_le_imp_le nat_le_real_less of_nat_le_0_iff xy0) 
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2204
    }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2205
    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
  2206
      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
  2207
      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
  2208
    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
  2209
  }
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2210
  then show ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2211
    unfolding uniformly_continuous_on_def by blast
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2212
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2213
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2214
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2215
subsection \<open>Continuity on a Compact Domain Implies Uniform Continuity\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2216
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2217
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
  2218
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
  2219
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2220
lemma Heine_Borel_lemma:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2221
  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
  2222
  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
  2223
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2224
  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
  2225
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2226
    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
  2227
      using neg by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2228
    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
  2229
      by metis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2230
    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
  2231
      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
  2232
    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
  2233
      using Ssub by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2234
    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
  2235
      using opn open_dist by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2236
    obtain N1 where N1: "\<And>n. n \<ge> N1 \<Longrightarrow> dist (f (r n)) l < e/2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2237
      using to_l apply (simp add: lim_sequentially)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2238
      using \<open>0 < e\<close> half_gt_zero that by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2239
    obtain N2 where N2: "of_nat N2 > 2/e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2240
      using reals_Archimedean2 by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2241
    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
  2242
      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
  2243
    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
  2244
      by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2245
    also have "... \<le> 1 / real (Suc (max N1 N2))"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2246
      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
  2247
    also have "... \<le> 1 / real (Suc N2)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2248
      by (simp add: field_simps)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2249
    also have "... < e/2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2250
      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
  2251
    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
  2252
    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
  2253
      using N1 max.cobounded1 by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2254
    ultimately have "dist x l < e"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2255
      by metric
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2256
    then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2257
      using e \<open>x \<notin> G\<close> by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2258
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2259
  then show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2260
    by (meson that)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2261
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2262
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2263
lemma compact_uniformly_equicontinuous:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2264
  assumes "compact S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2265
      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
  2266
                        \<Longrightarrow> \<exists>d. 0 < d \<and>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2267
                                (\<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
  2268
      and "0 < e"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2269
  obtains d where "0 < d"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2270
                  "\<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
  2271
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2272
  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
  2273
     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
  2274
    using cont by metis
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  2275
  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
  2276
  have Ssub: "S \<subseteq> \<Union> ?\<G>"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2277
    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
  2278
  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
  2279
    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
  2280
  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
  2281
  proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2282
    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
  2283
      using k that
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2284
      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
  2285
    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
  2286
      by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2287
    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
  2288
      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
  2289
    moreover
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2290
    have "dist (f w) (f u) < e/2"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2291
      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
  2292
    ultimately show ?thesis
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2293
      using dist_triangle_half_r by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2294
  qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2295
  ultimately show ?thesis using that by blast
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2296
qed
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2297
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2298
corollary compact_uniformly_continuous:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2299
  fixes f :: "'a :: metric_space \<Rightarrow> 'b :: metric_space"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2300
  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
  2301
  shows "uniformly_continuous_on S f"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2302
  using f
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2303
    unfolding continuous_on_iff uniformly_continuous_on_def
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2304
    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
  2305
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2306
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  2307
subsection\<^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
  2308
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2309
lemma continuous_on_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2310
   "continuous_on (closure S) f \<longleftrightarrow>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2311
    (\<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
  2312
           \<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
  2313
   (is "?lhs = ?rhs")
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2314
proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2315
  assume ?lhs then show ?rhs
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2316
    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
  2317
next
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2318
  assume R [rule_format]: ?rhs
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2319
  show ?lhs
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2320
  proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2321
    fix x and e::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2322
    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
  2323
    obtain \<delta>::real where "\<delta> > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2324
                   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
  2325
      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
  2326
    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
  2327
    proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2328
      obtain \<delta>'::real where "\<delta>' > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2329
                      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
  2330
        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
  2331
      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
  2332
        using closure_approachable y
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2333
        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
  2334
      have "dist (f z) (f y) < e/2"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2335
        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
  2336
      moreover have "dist (f z) (f x) < e/2"
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2337
        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
  2338
      ultimately show ?thesis
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2339
        by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2340
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2341
    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
  2342
      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
  2343
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2344
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2345
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2346
lemma continuous_on_closure_sequentially:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2347
  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
  2348
  shows
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2349
   "continuous_on (closure S) f \<longleftrightarrow>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2350
    (\<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
  2351
   (is "?lhs = ?rhs")
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2352
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2353
  have "continuous_on (closure S) f \<longleftrightarrow>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2354
           (\<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
  2355
    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
  2356
  also have "... = ?rhs"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2357
    by (force simp: continuous_within_sequentially)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2358
  finally show ?thesis .
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2359
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2360
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2361
lemma uniformly_continuous_on_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2362
  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
  2363
  assumes ucont: "uniformly_continuous_on S f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2364
      and cont: "continuous_on (closure S) f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2365
    shows "uniformly_continuous_on (closure S) f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2366
unfolding uniformly_continuous_on_def
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2367
proof (intro allI impI)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2368
  fix e::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2369
  assume "0 < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2370
  then obtain d::real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2371
    where "d>0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2372
      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
  2373
    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
  2374
  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
  2375
  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
  2376
    fix x y
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2377
    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
  2378
    obtain d1::real where "d1 > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2379
           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
  2380
      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
  2381
     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
  2382
        using closure_approachable [of x S]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2383
        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
  2384
    obtain d2::real where "d2 > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2385
           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
  2386
      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
  2387
    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
  2388
      using closure_approachable [of y S]
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2389
      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
  2390
    have "dist x' x < d/3" using x' by auto
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2391
    then have "dist x' y' < d"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2392
      using dyx y' by metric
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2393
    then have "dist (f x') (f y') < e/3"
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2394
      by (rule d [OF \<open>y' \<in> S\<close> \<open>x' \<in> S\<close>])
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2395
    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
  2396
      by (simp add: closure_def)
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2397
    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
  2398
      by (simp add: closure_def)
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2399
    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
  2400
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2401
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2402
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2403
lemma uniformly_continuous_on_extension_at_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2404
  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
  2405
  assumes uc: "uniformly_continuous_on X f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2406
  assumes "x \<in> closure X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2407
  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
  2408
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2409
  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
  2410
    by (auto simp: closure_sequential)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2411
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2412
  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
  2413
  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
  2414
    by atomize_elim (simp only: convergent_eq_Cauchy)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2415
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2416
  have "(f \<longlongrightarrow> l) (at x within X)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2417
  proof (safe intro!: Lim_within_LIMSEQ)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2418
    fix xs'
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2419
    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
  2420
      and xs': "xs' \<longlonglongrightarrow> x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2421
    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
  2422
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2423
    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
  2424
    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
  2425
      by atomize_elim (simp only: convergent_eq_Cauchy)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2426
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2427
    show "(\<lambda>n. f (xs' n)) \<longlonglongrightarrow> l"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2428
    proof (rule tendstoI)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2429
      fix e::real assume "e > 0"
72225
341b15d092f2 quite a bit of tidying
paulson <lp15@cam.ac.uk>
parents: 71633
diff changeset
  2430
      define e' where "e' \<equiv> e/2"
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2431
      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
  2432
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2433
      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
  2434
        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
  2435
      moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2436
      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
  2437
      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
  2438
        by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2439
      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
  2440
        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
  2441
      ultimately
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2442
      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
  2443
      proof eventually_elim
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2444
        case (elim n)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2445
        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
  2446
          by metric
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2447
        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
  2448
          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
  2449
        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
  2450
        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
  2451
        finally show ?case by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2452
      qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2453
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2454
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2455
  thus ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2456
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2457
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2458
lemma uniformly_continuous_on_extension_on_closure:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2459
  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
  2460
  assumes uc: "uniformly_continuous_on X f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2461
  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
  2462
    "\<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
  2463
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2464
  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
  2465
    by (simp add: uniformly_continuous_imp_continuous)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2466
  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
  2467
    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
  2468
  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
  2469
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2470
  have "uniformly_continuous_on (closure X) ?g"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2471
    unfolding uniformly_continuous_on_def
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2472
  proof safe
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2473
    fix e::real assume "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2474
    define e' where "e' \<equiv> e / 3"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2475
    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
  2476
    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
  2477
    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
  2478
      by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2479
    define d' where "d' = d / 3"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2480
    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
  2481
    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
  2482
    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
  2483
      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
  2484
      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
  2485
        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
  2486
        by (auto simp: closure_sequential)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2487
      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
  2488
        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
  2489
        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
  2490
      moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2491
      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
  2492
        using that not_eventuallyD
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2493
        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
  2494
      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
  2495
        using x x'
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2496
        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
  2497
      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
  2498
        "\<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
  2499
        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
  2500
      ultimately
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2501
      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
  2502
      proof eventually_elim
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2503
        case (elim n)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2504
        have "dist (?g x') (?g x) \<le>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2505
          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
  2506
          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
  2507
        also
70960
84f79d82df0a some applications of "metric"
immler
parents: 70951
diff changeset
  2508
        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
  2509
        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
  2510
        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
  2511
          by (rule d)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2512
        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
  2513
        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
  2514
        finally show ?case by (simp add: e'_def)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2515
      qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2516
      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
  2517
    qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2518
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2519
  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
  2520
  moreover
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2521
  {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2522
    fix Y h x
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2523
    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
  2524
      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
  2525
    {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2526
      assume "x \<notin> X"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2527
      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
  2528
      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
  2529
        by (auto simp: closure_sequential)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2530
      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
  2531
      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
  2532
        by (auto simp: subsetD extension)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2533
      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
  2534
        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
  2535
        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
  2536
      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
  2537
    } then
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2538
    have "h x = ?g x"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2539
      using extension by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2540
  }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2541
  ultimately show ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2542
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2543
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2544
lemma bounded_uniformly_continuous_image:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2545
  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
  2546
  assumes "uniformly_continuous_on S f" "bounded S"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2547
  shows "bounded(f ` S)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2548
  by (metis (no_types, lifting) 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)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2549
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2550
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2551
subsection \<open>With Abstract Topology (TODO: move and remove dependency?)\<close>
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2552
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2553
lemma openin_contains_ball:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2554
    "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
  2555
     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
  2556
    (is "?lhs = ?rhs")
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2557
proof
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2558
  assume ?lhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2559
  then show ?rhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2560
    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
  2561
next
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2562
  assume ?rhs
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2563
  then show ?lhs
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2564
    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
  2565
qed
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2566
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2567
lemma openin_contains_cball:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2568
   "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
  2569
        S \<subseteq> T \<and> (\<forall>x \<in> S. \<exists>e. 0 < e \<and> cball x e \<inter> T \<subseteq> S)"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2570
    (is "?lhs = ?rhs")
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2571
proof
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2572
  assume ?lhs
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2573
  then show ?rhs
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2574
    by (force simp add: openin_contains_ball intro: exI [where x="_/2"])
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2575
next
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2576
  assume ?rhs
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2577
  then show ?lhs
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2578
    by (force simp add: openin_contains_ball)
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2579
qed
69544
5aa5a8d6e5b5 split off theorems involving classes below metric_space and real_normed_vector
immler
parents:
diff changeset
  2580
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2581
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2582
subsection \<open>Closed Nest\<close>
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2583
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2584
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
  2585
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2586
lemma bounded_closed_nest:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2587
  fixes S :: "nat \<Rightarrow> ('a::heine_borel) set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2588
  assumes "\<And>n. closed (S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2589
      and "\<And>n. S n \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2590
      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
  2591
      and "bounded (S 0)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2592
  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
  2593
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2594
  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
  2595
    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
  2596
  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
  2597
    by (simp add: bounded_closed_imp_seq_compact)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2598
  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
  2599
    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
  2600
  have "\<forall>n. l \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2601
  proof
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2602
    fix n :: nat
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2603
    have "closed (S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2604
      using assms(1) by simp
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2605
    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
  2606
      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
  2607
    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
  2608
      using assms(3) by (fast intro!: le_add2)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2609
    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
  2610
      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
  2611
    ultimately show "l \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2612
      by (rule closed_sequentially)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2613
  qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2614
  then show ?thesis 
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2615
    using that by blast
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
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2618
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
  2619
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2620
lemma decreasing_closed_nest:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2621
  fixes S :: "nat \<Rightarrow> ('a::complete_space) set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2622
  assumes "\<And>n. closed (S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2623
          "\<And>n. S n \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2624
          "\<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
  2625
          "\<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
  2626
  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
  2627
proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2628
  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
  2629
    by (meson assms(2) equals0I)
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2630
  {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2631
    fix e :: real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2632
    assume "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2633
    then obtain N where 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
  2634
      using assms(4) by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2635
    {
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2636
      fix m n :: nat
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2637
      assume "N \<le> m \<and> N \<le> n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2638
      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
  2639
        using assms(3) t unfolding  subset_eq t by blast+
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2640
      then have "dist (t m) (t n) < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2641
        using N by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2642
    }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2643
    then have "\<exists>N. \<forall>m n. N \<le> m \<and> N \<le> n \<longrightarrow> dist (t m) (t n) < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2644
      by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2645
  }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2646
  then have "Cauchy t"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2647
    unfolding cauchy_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2648
  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
  2649
    using complete_UNIV unfolding complete_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2650
  { fix n :: nat
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2651
    { fix e :: real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2652
      assume "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2653
      then obtain N :: nat where N: "\<forall>n\<ge>N. dist (t n) l < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2654
        using l[unfolded lim_sequentially] by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2655
      have "t (max n N) \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2656
        by (meson assms(3) contra_subsetD max.cobounded1 t)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2657
      then have "\<exists>y\<in>S n. dist y l < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2658
        using N max.cobounded2 by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2659
    }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2660
    then have "l \<in> S n"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2661
      using closed_approachable[of "S n" l] assms(1) by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2662
  }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2663
  then show ?thesis
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2664
    using that by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2665
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2666
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2667
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
  2668
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2669
lemma decreasing_closed_nest_sing:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2670
  fixes S :: "nat \<Rightarrow> 'a::complete_space set"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2671
  assumes "\<And>n. closed(S n)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2672
          "\<And>n. S n \<noteq> {}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2673
          "\<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
  2674
          "\<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
  2675
  shows "\<exists>a. \<Inter>(range S) = {a}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2676
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2677
  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
  2678
    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
  2679
  { fix b
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2680
    assume b: "b \<in> \<Inter>(range S)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2681
    { fix e :: real
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2682
      assume "e > 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2683
      then have "dist a b < e"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2684
        using assms(4) and b and a by blast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2685
    }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2686
    then have "dist a b = 0"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2687
      by (metis dist_eq_0_iff dist_nz less_le)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2688
  }
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2689
  with a have "\<Inter>(range S) = {a}"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2690
    unfolding image_def by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2691
  then show ?thesis ..
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2692
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2693
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  2694
subsection\<^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
  2695
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2696
lemma continuous_within_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2697
  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
  2698
  assumes "continuous (at x within s) f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2699
    and "f x \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2700
  shows "\<exists>e>0. \<forall>y \<in> s. dist x y < e --> f y \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2701
proof -
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2702
  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
  2703
    using t1_space [OF \<open>f x \<noteq> a\<close>] by fast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2704
  have "(f \<longlongrightarrow> f x) (at x within s)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2705
    using assms(1) by (simp add: continuous_within)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2706
  then have "eventually (\<lambda>y. f y \<in> U) (at x within s)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2707
    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
  2708
    unfolding tendsto_def by fast
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2709
  then have "eventually (\<lambda>y. f y \<noteq> a) (at x within s)"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2710
    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
  2711
  then show ?thesis
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2712
    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
  2713
qed
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2714
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2715
lemma continuous_at_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2716
  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
  2717
  assumes "continuous (at x) f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2718
    and "f x \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2719
  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
  2720
  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
  2721
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2722
lemma continuous_on_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2723
  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
  2724
  assumes "continuous_on s f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2725
    and "x \<in> s"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2726
    and "f x \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2727
  shows "\<exists>e>0. \<forall>y \<in> s. 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
  2728
  using assms(1)[unfolded continuous_on_eq_continuous_within, THEN bspec[where x=x],
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2729
    OF assms(2)] continuous_within_avoid[of x s f a]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2730
  using assms(3)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2731
  by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2732
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2733
lemma continuous_on_open_avoid:
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2734
  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
  2735
  assumes "continuous_on s f"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2736
    and "open s"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2737
    and "x \<in> s"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2738
    and "f x \<noteq> a"
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2739
  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
  2740
  using assms(1)[unfolded continuous_on_eq_continuous_at[OF assms(2)], THEN bspec[where x=x], OF assms(3)]
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2741
  using continuous_at_avoid[of x f a] assms(4)
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2742
  by auto
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2743
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2744
subsection \<open>Consequences for Real Numbers\<close>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2745
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2746
lemma closed_contains_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2747
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2748
  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
  2749
  by (metis closure_contains_Inf closure_closed)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2750
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2751
lemma closed_subset_contains_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2752
  fixes A C :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2753
  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
  2754
  by (metis closure_contains_Inf closure_minimal subset_eq)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2755
70617
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2756
lemma closed_contains_Sup:
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2757
  fixes S :: "real set"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2758
  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
  2759
  by (subst closure_closed[symmetric], assumption, rule closure_contains_Sup)
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2760
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2761
lemma closed_subset_contains_Sup:
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2762
  fixes A C :: "real set"
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2763
  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
  2764
  by (metis closure_contains_Sup closure_minimal subset_eq)
c81ac117afa6 moved lemmas; reduced dependencies of Lipschitz
immler
parents: 70136
diff changeset
  2765
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2766
lemma atLeastAtMost_subset_contains_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2767
  fixes A :: "real set" and a b :: real
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2768
  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
  2769
  by (rule closed_subset_contains_Inf)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2770
     (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
  2771
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2772
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
  2773
  by (simp add: bounded_iff)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2774
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2775
lemma bounded_imp_bdd_above: "bounded S \<Longrightarrow> bdd_above (S :: real set)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2776
  by (auto simp: bounded_def bdd_above_def dist_real_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2777
     (metis abs_le_D1 abs_minus_commute diff_le_eq)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2778
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2779
lemma bounded_imp_bdd_below: "bounded S \<Longrightarrow> bdd_below (S :: real set)"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2780
  by (auto simp: bounded_def bdd_below_def dist_real_def)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2781
     (metis abs_le_D1 add.commute diff_le_eq)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2782
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2783
lemma bounded_has_Sup:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2784
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2785
  assumes "bounded S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2786
    and "S \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2787
  shows "\<forall>x\<in>S. x \<le> Sup S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2788
    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
  2789
proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2790
  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
  2791
    using assms by (metis cSup_least)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2792
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
  2793
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2794
lemma Sup_insert:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2795
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2796
  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
  2797
  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
  2798
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2799
lemma bounded_has_Inf:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2800
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2801
  assumes "bounded S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2802
    and "S \<noteq> {}"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2803
  shows "\<forall>x\<in>S. x \<ge> Inf S"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2804
    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
  2805
proof
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2806
  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
  2807
    using assms by (metis cInf_greatest)
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2808
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
  2809
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2810
lemma Inf_insert:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2811
  fixes S :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2812
  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
  2813
  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
  2814
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2815
lemma open_real:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2816
  fixes s :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2817
  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
  2818
  unfolding open_dist dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2819
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2820
lemma islimpt_approachable_real:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2821
  fixes s :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2822
  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
  2823
  unfolding islimpt_approachable dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2824
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2825
lemma closed_real:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2826
  fixes s :: "real set"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2827
  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
  2828
  unfolding closed_limpt islimpt_approachable dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2829
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2830
lemma continuous_at_real_range:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2831
  fixes f :: "'a::real_normed_vector \<Rightarrow> real"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2832
  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
  2833
  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
  2834
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2835
lemma continuous_on_real_range:
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2836
  fixes f :: "'a::real_normed_vector \<Rightarrow> real"
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2837
  shows "continuous_on s f \<longleftrightarrow>
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2838
    (\<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
  2839
  unfolding continuous_on_iff dist_norm by simp
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2840
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2841
lemma continuous_on_closed_Collect_le:
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2842
  fixes f g :: "'a::topological_space \<Rightarrow> real"
69613
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2843
  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
  2844
  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
  2845
proof -
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2846
  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
  2847
    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
  2848
    by (simp add: continuous_on_closed_vimage [OF s])
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2849
  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
  2850
    by auto
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2851
  finally show ?thesis .
1331e57b54c6 moved material from Connected.thy to more appropriate places
immler
parents: 69611
diff changeset
  2852
qed
69611
42cc3609fedf moved some material from Connected.thy to more appropriate places
immler
parents: 69544
diff changeset
  2853
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2854
lemma continuous_le_on_closure:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2855
  fixes a::real
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2856
  assumes f: "continuous_on (closure s) f"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2857
      and x: "x \<in> closure(s)"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2858
      and xlo: "\<And>x. x \<in> s ==> f(x) \<le> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2859
    shows "f(x) \<le> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2860
  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
  2861
    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
  2862
  by auto
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2863
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2864
lemma continuous_ge_on_closure:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2865
  fixes a::real
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2866
  assumes f: "continuous_on (closure s) f"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2867
      and x: "x \<in> closure(s)"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2868
      and xlo: "\<And>x. x \<in> s ==> f(x) \<ge> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2869
    shows "f(x) \<ge> a"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2870
  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
  2871
    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
  2872
  by auto
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2873
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2874
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2875
subsection\<open>The infimum of the distance between two sets\<close>
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2876
70136
f03a01a18c6e modernized tags: default scope excludes proof;
wenzelm
parents: 69922
diff changeset
  2877
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
  2878
  "setdist s t \<equiv>
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2879
       (if s = {} \<or> t = {} then 0
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2880
        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
  2881
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2882
lemma setdist_empty1 [simp]: "setdist {} t = 0"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2883
  by (simp add: setdist_def)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2884
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2885
lemma setdist_empty2 [simp]: "setdist t {} = 0"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2886
  by (simp add: setdist_def)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2887
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2888
lemma setdist_pos_le [simp]: "0 \<le> setdist s t"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2889
  by (auto simp: setdist_def ex_in_conv [symmetric] intro: cInf_greatest)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2890
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2891
lemma le_setdistI:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2892
  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
  2893
    shows "d \<le> setdist s t"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2894
  using assms
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2895
  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
  2896
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2897
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
  2898
  unfolding setdist_def
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2899
  by (auto intro!: bdd_belowI [where m=0] cInf_lower)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2900
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2901
lemma le_setdist_iff:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2902
        "d \<le> setdist S T \<longleftrightarrow>
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2903
        (\<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
  2904
  by (smt (verit) le_setdistI setdist_def setdist_le_dist)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2905
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2906
lemma setdist_ltE:
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2907
  assumes "setdist S T < b" "S \<noteq> {}" "T \<noteq> {}"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2908
    obtains x y where "x \<in> S" "y \<in> T" "dist x y < b"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2909
using assms
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2910
by (auto simp: not_le [symmetric] le_setdist_iff)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2911
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2912
lemma setdist_refl: "setdist S S = 0"
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2913
  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
  2914
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2915
lemma setdist_sym: "setdist S T = setdist T S"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2916
  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
  2917
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2918
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
  2919
proof (cases "S = {} \<or> T = {}")
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2920
  case True then show ?thesis
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2921
    using setdist_pos_le by fastforce
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2922
next
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2923
  case False
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2924
  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
  2925
    using  dist_self dist_triangle3 empty_not_insert le_setdist_iff setdist_le_dist singleton_iff
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2926
    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
  2927
  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
  2928
    using False by (fastforce intro: le_setdistI)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2929
  then show ?thesis
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2930
    by (simp add: algebra_simps)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2931
qed
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2932
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2933
lemma setdist_singletons [simp]: "setdist {x} {y} = dist x y"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2934
  by (simp add: setdist_def)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2935
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2936
lemma setdist_Lipschitz: "\<bar>setdist {x} S - setdist {y} S\<bar> \<le> dist x y"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2937
  apply (subst setdist_singletons [symmetric])
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2938
  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
  2939
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2940
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
  2941
  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
  2942
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2943
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
  2944
  by (metis continuous_at_setdist continuous_at_imp_continuous_on)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2945
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2946
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
  2947
  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
  2948
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2949
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
  2950
  by (smt (verit, best) in_mono le_setdist_iff)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2951
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2952
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
  2953
  by (metis setdist_subset_right setdist_sym)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2954
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2955
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
  2956
proof (cases "S = {} \<or> T = {}")
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2957
  case True then show ?thesis by force
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2958
next
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2959
  case False
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2960
  { fix y
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2961
    assume "y \<in> T"
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2962
    have "continuous_on (closure S) (\<lambda>a. dist a y)"
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2963
      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
  2964
    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
  2965
      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
  2966
  } then
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2967
  show ?thesis
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2968
    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
  2969
qed
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2970
72228
aa7cb84983e9 minor tidying, also s->S and t->T
paulson <lp15@cam.ac.uk>
parents: 72225
diff changeset
  2971
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
  2972
  by (metis setdist_closure_1 setdist_sym)
69618
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2973
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2974
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
  2975
  by (metis antisym dist_self setdist_le_dist setdist_pos_le)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2976
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2977
lemma setdist_unique:
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2978
  "\<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
  2979
   \<Longrightarrow> setdist S T = dist a b"
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2980
  by (force simp add: setdist_le_dist le_setdist_iff intro: antisym)
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2981
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2982
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
  2983
  using setdist_subset_left by auto
2be1baf40351 moved setdist to more appropriate places
immler
parents: 69616
diff changeset
  2984
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
  2985
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
  2986
  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
  2987
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
  2988
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
  2989
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
  2990
  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
  2991
    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
  2992
  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
  2993
    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
  2994
      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
  2995
    proof -
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2996
      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
  2997
        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
  2998
      then show ?thesis
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  2999
        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
  3000
    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
  3001
    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
  3002
      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
  3003
  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
  3004
    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
  3005
      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
  3006
    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
  3007
    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
  3008
      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
  3009
        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
  3010
    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
  3011
  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
  3012
  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
  3013
    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
  3014
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
  3015
70724
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3016
lemma infdist_mono:
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3017
  assumes "A \<subseteq> B" "A \<noteq> {}"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3018
  shows "infdist x B \<le> infdist x A"
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3019
  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
  3020
76796
454984e807db Tidied some messy proofs
paulson <lp15@cam.ac.uk>
parents: 73933
diff changeset
  3021
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
  3022
  by (simp add: infdist_eq_setdist)
65371451fde8 A few more simple results
paulson <lp15@cam.ac.uk>
parents: 70723
diff changeset
  3023
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
  3024
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
  3025
  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
  3026
  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
  3027
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
  3028
  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
  3029
  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
  3030
    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
  3031
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
  3032
  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
  3033
  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
  3034
    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
  3035
  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
  3036
  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
  3037
    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
  3038
      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
  3039
    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
  3040
    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
  3041
      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
  3042
        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
  3043
    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
  3044
      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
  3045
        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
  3046
    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
  3047
    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
  3048
  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
  3049
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
  3050
70723
4e39d87c9737 imported new material mostly due to Sébastien Gouëzel
paulson <lp15@cam.ac.uk>
parents: 70617
diff changeset
  3051
end