src/HOL/Analysis/Elementary_Normed_Spaces.thy
 author wenzelm Mon Mar 25 17:21:26 2019 +0100 (3 months ago) changeset 69981 3dced198b9ec parent 69922 4a9167f377b0 child 70065 cc89a395b5a3 permissions -rw-r--r--
more strict AFP properties;
```     1 (*  Author:     L C Paulson, University of Cambridge
```
```     2     Author:     Amine Chaieb, University of Cambridge
```
```     3     Author:     Robert Himmelmann, TU Muenchen
```
```     4     Author:     Brian Huffman, Portland State University
```
```     5 *)
```
```     6
```
```     7 section \<open>Elementary Normed Vector Spaces\<close>
```
```     8
```
```     9 theory Elementary_Normed_Spaces
```
```    10   imports
```
```    11   "HOL-Library.FuncSet"
```
```    12   Elementary_Metric_Spaces
```
```    13   Connected
```
```    14 begin
```
```    15
```
```    16 subsection%unimportant \<open>Various Lemmas Combining Imports\<close>
```
```    17
```
```    18 lemma countable_PiE:
```
```    19   "finite I \<Longrightarrow> (\<And>i. i \<in> I \<Longrightarrow> countable (F i)) \<Longrightarrow> countable (Pi\<^sub>E I F)"
```
```    20   by (induct I arbitrary: F rule: finite_induct) (auto simp: PiE_insert_eq)
```
```    21
```
```    22
```
```    23 lemma open_sums:
```
```    24   fixes T :: "('b::real_normed_vector) set"
```
```    25   assumes "open S \<or> open T"
```
```    26   shows "open (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
```
```    27   using assms
```
```    28 proof
```
```    29   assume S: "open S"
```
```    30   show ?thesis
```
```    31   proof (clarsimp simp: open_dist)
```
```    32     fix x y
```
```    33     assume "x \<in> S" "y \<in> T"
```
```    34     with S obtain e where "e > 0" and e: "\<And>x'. dist x' x < e \<Longrightarrow> x' \<in> S"
```
```    35       by (auto simp: open_dist)
```
```    36     then have "\<And>z. dist z (x + y) < e \<Longrightarrow> \<exists>x\<in>S. \<exists>y\<in>T. z = x + y"
```
```    37       by (metis \<open>y \<in> T\<close> diff_add_cancel dist_add_cancel2)
```
```    38     then show "\<exists>e>0. \<forall>z. dist z (x + y) < e \<longrightarrow> (\<exists>x\<in>S. \<exists>y\<in>T. z = x + y)"
```
```    39       using \<open>0 < e\<close> \<open>x \<in> S\<close> by blast
```
```    40   qed
```
```    41 next
```
```    42   assume T: "open T"
```
```    43   show ?thesis
```
```    44   proof (clarsimp simp: open_dist)
```
```    45     fix x y
```
```    46     assume "x \<in> S" "y \<in> T"
```
```    47     with T obtain e where "e > 0" and e: "\<And>x'. dist x' y < e \<Longrightarrow> x' \<in> T"
```
```    48       by (auto simp: open_dist)
```
```    49     then have "\<And>z. dist z (x + y) < e \<Longrightarrow> \<exists>x\<in>S. \<exists>y\<in>T. z = x + y"
```
```    50       by (metis \<open>x \<in> S\<close> add_diff_cancel_left' add_diff_eq diff_diff_add dist_norm)
```
```    51     then show "\<exists>e>0. \<forall>z. dist z (x + y) < e \<longrightarrow> (\<exists>x\<in>S. \<exists>y\<in>T. z = x + y)"
```
```    52       using \<open>0 < e\<close> \<open>y \<in> T\<close> by blast
```
```    53   qed
```
```    54 qed
```
```    55
```
```    56
```
```    57 subsection \<open>Support\<close>
```
```    58
```
```    59 definition (in monoid_add) support_on :: "'b set \<Rightarrow> ('b \<Rightarrow> 'a) \<Rightarrow> 'b set"
```
```    60   where "support_on s f = {x\<in>s. f x \<noteq> 0}"
```
```    61
```
```    62 lemma in_support_on: "x \<in> support_on s f \<longleftrightarrow> x \<in> s \<and> f x \<noteq> 0"
```
```    63   by (simp add: support_on_def)
```
```    64
```
```    65 lemma support_on_simps[simp]:
```
```    66   "support_on {} f = {}"
```
```    67   "support_on (insert x s) f =
```
```    68     (if f x = 0 then support_on s f else insert x (support_on s f))"
```
```    69   "support_on (s \<union> t) f = support_on s f \<union> support_on t f"
```
```    70   "support_on (s \<inter> t) f = support_on s f \<inter> support_on t f"
```
```    71   "support_on (s - t) f = support_on s f - support_on t f"
```
```    72   "support_on (f ` s) g = f ` (support_on s (g \<circ> f))"
```
```    73   unfolding support_on_def by auto
```
```    74
```
```    75 lemma support_on_cong:
```
```    76   "(\<And>x. x \<in> s \<Longrightarrow> f x = 0 \<longleftrightarrow> g x = 0) \<Longrightarrow> support_on s f = support_on s g"
```
```    77   by (auto simp: support_on_def)
```
```    78
```
```    79 lemma support_on_if: "a \<noteq> 0 \<Longrightarrow> support_on A (\<lambda>x. if P x then a else 0) = {x\<in>A. P x}"
```
```    80   by (auto simp: support_on_def)
```
```    81
```
```    82 lemma support_on_if_subset: "support_on A (\<lambda>x. if P x then a else 0) \<subseteq> {x \<in> A. P x}"
```
```    83   by (auto simp: support_on_def)
```
```    84
```
```    85 lemma finite_support[intro]: "finite S \<Longrightarrow> finite (support_on S f)"
```
```    86   unfolding support_on_def by auto
```
```    87
```
```    88 (* TODO: is supp_sum really needed? TODO: Generalize to Finite_Set.fold *)
```
```    89 definition (in comm_monoid_add) supp_sum :: "('b \<Rightarrow> 'a) \<Rightarrow> 'b set \<Rightarrow> 'a"
```
```    90   where "supp_sum f S = (\<Sum>x\<in>support_on S f. f x)"
```
```    91
```
```    92 lemma supp_sum_empty[simp]: "supp_sum f {} = 0"
```
```    93   unfolding supp_sum_def by auto
```
```    94
```
```    95 lemma supp_sum_insert[simp]:
```
```    96   "finite (support_on S f) \<Longrightarrow>
```
```    97     supp_sum f (insert x S) = (if x \<in> S then supp_sum f S else f x + supp_sum f S)"
```
```    98   by (simp add: supp_sum_def in_support_on insert_absorb)
```
```    99
```
```   100 lemma supp_sum_divide_distrib: "supp_sum f A / (r::'a::field) = supp_sum (\<lambda>n. f n / r) A"
```
```   101   by (cases "r = 0")
```
```   102      (auto simp: supp_sum_def sum_divide_distrib intro!: sum.cong support_on_cong)
```
```   103
```
```   104
```
```   105 subsection \<open>Intervals\<close>
```
```   106
```
```   107 lemma image_affinity_interval:
```
```   108   fixes c :: "'a::ordered_real_vector"
```
```   109   shows "((\<lambda>x. m *\<^sub>R x + c) ` {a..b}) =
```
```   110            (if {a..b}={} then {}
```
```   111             else if 0 \<le> m then {m *\<^sub>R a + c .. m  *\<^sub>R b + c}
```
```   112             else {m *\<^sub>R b + c .. m *\<^sub>R a + c})"
```
```   113          (is "?lhs = ?rhs")
```
```   114 proof (cases "m=0")
```
```   115   case True
```
```   116   then show ?thesis
```
```   117     by force
```
```   118 next
```
```   119   case False
```
```   120   show ?thesis
```
```   121   proof
```
```   122     show "?lhs \<subseteq> ?rhs"
```
```   123       by (auto simp: scaleR_left_mono scaleR_left_mono_neg)
```
```   124     show "?rhs \<subseteq> ?lhs"
```
```   125     proof (clarsimp, intro conjI impI subsetI)
```
```   126       show "\<lbrakk>0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}\<rbrakk>
```
```   127             \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}" for x
```
```   128         apply (rule_tac x="inverse m *\<^sub>R (x-c)" in rev_image_eqI)
```
```   129         using False apply (auto simp: le_diff_eq pos_le_divideRI)
```
```   130         using diff_le_eq pos_le_divideR_eq by force
```
```   131       show "\<lbrakk>\<not> 0 \<le> m; a \<le> b;  x \<in> {m *\<^sub>R b + c..m *\<^sub>R a + c}\<rbrakk>
```
```   132             \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}" for x
```
```   133         apply (rule_tac x="inverse m *\<^sub>R (x-c)" in rev_image_eqI)
```
```   134         apply (auto simp: diff_le_eq neg_le_divideR_eq)
```
```   135         using diff_eq_diff_less_eq linordered_field_class.sign_simps(11) minus_diff_eq not_less scaleR_le_cancel_left_neg by fastforce
```
```   136     qed
```
```   137   qed
```
```   138 qed
```
```   139
```
```   140 subsection \<open>Limit Points\<close>
```
```   141
```
```   142 lemma islimpt_ball:
```
```   143   fixes x y :: "'a::{real_normed_vector,perfect_space}"
```
```   144   shows "y islimpt ball x e \<longleftrightarrow> 0 < e \<and> y \<in> cball x e"
```
```   145   (is "?lhs \<longleftrightarrow> ?rhs")
```
```   146 proof
```
```   147   show ?rhs if ?lhs
```
```   148   proof
```
```   149     {
```
```   150       assume "e \<le> 0"
```
```   151       then have *: "ball x e = {}"
```
```   152         using ball_eq_empty[of x e] by auto
```
```   153       have False using \<open>?lhs\<close>
```
```   154         unfolding * using islimpt_EMPTY[of y] by auto
```
```   155     }
```
```   156     then show "e > 0" by (metis not_less)
```
```   157     show "y \<in> cball x e"
```
```   158       using closed_cball[of x e] islimpt_subset[of y "ball x e" "cball x e"]
```
```   159         ball_subset_cball[of x e] \<open>?lhs\<close>
```
```   160       unfolding closed_limpt by auto
```
```   161   qed
```
```   162   show ?lhs if ?rhs
```
```   163   proof -
```
```   164     from that have "e > 0" by auto
```
```   165     {
```
```   166       fix d :: real
```
```   167       assume "d > 0"
```
```   168       have "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d"
```
```   169       proof (cases "d \<le> dist x y")
```
```   170         case True
```
```   171         then show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d"
```
```   172         proof (cases "x = y")
```
```   173           case True
```
```   174           then have False
```
```   175             using \<open>d \<le> dist x y\<close> \<open>d>0\<close> by auto
```
```   176           then show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d"
```
```   177             by auto
```
```   178         next
```
```   179           case False
```
```   180           have "dist x (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) =
```
```   181             norm (x - y + (d / (2 * norm (y - x))) *\<^sub>R (y - x))"
```
```   182             unfolding mem_cball mem_ball dist_norm diff_diff_eq2 diff_add_eq[symmetric]
```
```   183             by auto
```
```   184           also have "\<dots> = \<bar>- 1 + d / (2 * norm (x - y))\<bar> * norm (x - y)"
```
```   185             using scaleR_left_distrib[of "- 1" "d / (2 * norm (y - x))", symmetric, of "y - x"]
```
```   186             unfolding scaleR_minus_left scaleR_one
```
```   187             by (auto simp: norm_minus_commute)
```
```   188           also have "\<dots> = \<bar>- norm (x - y) + d / 2\<bar>"
```
```   189             unfolding abs_mult_pos[of "norm (x - y)", OF norm_ge_zero[of "x - y"]]
```
```   190             unfolding distrib_right using \<open>x\<noteq>y\<close>  by auto
```
```   191           also have "\<dots> \<le> e - d/2" using \<open>d \<le> dist x y\<close> and \<open>d>0\<close> and \<open>?rhs\<close>
```
```   192             by (auto simp: dist_norm)
```
```   193           finally have "y - (d / (2 * dist y x)) *\<^sub>R (y - x) \<in> ball x e" using \<open>d>0\<close>
```
```   194             by auto
```
```   195           moreover
```
```   196           have "(d / (2*dist y x)) *\<^sub>R (y - x) \<noteq> 0"
```
```   197             using \<open>x\<noteq>y\<close>[unfolded dist_nz] \<open>d>0\<close> unfolding scaleR_eq_0_iff
```
```   198             by (auto simp: dist_commute)
```
```   199           moreover
```
```   200           have "dist (y - (d / (2 * dist y x)) *\<^sub>R (y - x)) y < d"
```
```   201             unfolding dist_norm
```
```   202             apply simp
```
```   203             unfolding norm_minus_cancel
```
```   204             using \<open>d > 0\<close> \<open>x\<noteq>y\<close>[unfolded dist_nz] dist_commute[of x y]
```
```   205             unfolding dist_norm
```
```   206             apply auto
```
```   207             done
```
```   208           ultimately show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d"
```
```   209             apply (rule_tac x = "y - (d / (2*dist y x)) *\<^sub>R (y - x)" in bexI)
```
```   210             apply auto
```
```   211             done
```
```   212         qed
```
```   213       next
```
```   214         case False
```
```   215         then have "d > dist x y" by auto
```
```   216         show "\<exists>x' \<in> ball x e. x' \<noteq> y \<and> dist x' y < d"
```
```   217         proof (cases "x = y")
```
```   218           case True
```
```   219           obtain z where **: "z \<noteq> y" "dist z y < min e d"
```
```   220             using perfect_choose_dist[of "min e d" y]
```
```   221             using \<open>d > 0\<close> \<open>e>0\<close> by auto
```
```   222           show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d"
```
```   223             unfolding \<open>x = y\<close>
```
```   224             using \<open>z \<noteq> y\<close> **
```
```   225             apply (rule_tac x=z in bexI)
```
```   226             apply (auto simp: dist_commute)
```
```   227             done
```
```   228         next
```
```   229           case False
```
```   230           then show "\<exists>x'\<in>ball x e. x' \<noteq> y \<and> dist x' y < d"
```
```   231             using \<open>d>0\<close> \<open>d > dist x y\<close> \<open>?rhs\<close>
```
```   232             apply (rule_tac x=x in bexI, auto)
```
```   233             done
```
```   234         qed
```
```   235       qed
```
```   236     }
```
```   237     then show ?thesis
```
```   238       unfolding mem_cball islimpt_approachable mem_ball by auto
```
```   239   qed
```
```   240 qed
```
```   241
```
```   242 lemma closure_ball_lemma:
```
```   243   fixes x y :: "'a::real_normed_vector"
```
```   244   assumes "x \<noteq> y"
```
```   245   shows "y islimpt ball x (dist x y)"
```
```   246 proof (rule islimptI)
```
```   247   fix T
```
```   248   assume "y \<in> T" "open T"
```
```   249   then obtain r where "0 < r" "\<forall>z. dist z y < r \<longrightarrow> z \<in> T"
```
```   250     unfolding open_dist by fast
```
```   251   (* choose point between x and y, within distance r of y. *)
```
```   252   define k where "k = min 1 (r / (2 * dist x y))"
```
```   253   define z where "z = y + scaleR k (x - y)"
```
```   254   have z_def2: "z = x + scaleR (1 - k) (y - x)"
```
```   255     unfolding z_def by (simp add: algebra_simps)
```
```   256   have "dist z y < r"
```
```   257     unfolding z_def k_def using \<open>0 < r\<close>
```
```   258     by (simp add: dist_norm min_def)
```
```   259   then have "z \<in> T"
```
```   260     using \<open>\<forall>z. dist z y < r \<longrightarrow> z \<in> T\<close> by simp
```
```   261   have "dist x z < dist x y"
```
```   262     unfolding z_def2 dist_norm
```
```   263     apply (simp add: norm_minus_commute)
```
```   264     apply (simp only: dist_norm [symmetric])
```
```   265     apply (subgoal_tac "\<bar>1 - k\<bar> * dist x y < 1 * dist x y", simp)
```
```   266     apply (rule mult_strict_right_mono)
```
```   267     apply (simp add: k_def \<open>0 < r\<close> \<open>x \<noteq> y\<close>)
```
```   268     apply (simp add: \<open>x \<noteq> y\<close>)
```
```   269     done
```
```   270   then have "z \<in> ball x (dist x y)"
```
```   271     by simp
```
```   272   have "z \<noteq> y"
```
```   273     unfolding z_def k_def using \<open>x \<noteq> y\<close> \<open>0 < r\<close>
```
```   274     by (simp add: min_def)
```
```   275   show "\<exists>z\<in>ball x (dist x y). z \<in> T \<and> z \<noteq> y"
```
```   276     using \<open>z \<in> ball x (dist x y)\<close> \<open>z \<in> T\<close> \<open>z \<noteq> y\<close>
```
```   277     by fast
```
```   278 qed
```
```   279
```
```   280
```
```   281 subsection \<open>Balls and Spheres in Normed Spaces\<close>
```
```   282
```
```   283 lemma mem_ball_0 [simp]: "x \<in> ball 0 e \<longleftrightarrow> norm x < e"
```
```   284   for x :: "'a::real_normed_vector"
```
```   285   by (simp add: dist_norm)
```
```   286
```
```   287 lemma mem_cball_0 [simp]: "x \<in> cball 0 e \<longleftrightarrow> norm x \<le> e"
```
```   288   for x :: "'a::real_normed_vector"
```
```   289   by (simp add: dist_norm)
```
```   290
```
```   291 lemma closure_ball [simp]:
```
```   292   fixes x :: "'a::real_normed_vector"
```
```   293   shows "0 < e \<Longrightarrow> closure (ball x e) = cball x e"
```
```   294   apply (rule equalityI)
```
```   295   apply (rule closure_minimal)
```
```   296   apply (rule ball_subset_cball)
```
```   297   apply (rule closed_cball)
```
```   298   apply (rule subsetI, rename_tac y)
```
```   299   apply (simp add: le_less [where 'a=real])
```
```   300   apply (erule disjE)
```
```   301   apply (rule subsetD [OF closure_subset], simp)
```
```   302   apply (simp add: closure_def, clarify)
```
```   303   apply (rule closure_ball_lemma)
```
```   304   apply simp
```
```   305   done
```
```   306
```
```   307 lemma mem_sphere_0 [simp]: "x \<in> sphere 0 e \<longleftrightarrow> norm x = e"
```
```   308   for x :: "'a::real_normed_vector"
```
```   309   by (simp add: dist_norm)
```
```   310
```
```   311 (* In a trivial vector space, this fails for e = 0. *)
```
```   312 lemma interior_cball [simp]:
```
```   313   fixes x :: "'a::{real_normed_vector, perfect_space}"
```
```   314   shows "interior (cball x e) = ball x e"
```
```   315 proof (cases "e \<ge> 0")
```
```   316   case False note cs = this
```
```   317   from cs have null: "ball x e = {}"
```
```   318     using ball_empty[of e x] by auto
```
```   319   moreover
```
```   320   have "cball x e = {}"
```
```   321   proof (rule equals0I)
```
```   322     fix y
```
```   323     assume "y \<in> cball x e"
```
```   324     then show False
```
```   325       by (metis ball_eq_empty null cs dist_eq_0_iff dist_le_zero_iff empty_subsetI mem_cball
```
```   326           subset_antisym subset_ball)
```
```   327   qed
```
```   328   then have "interior (cball x e) = {}"
```
```   329     using interior_empty by auto
```
```   330   ultimately show ?thesis by blast
```
```   331 next
```
```   332   case True note cs = this
```
```   333   have "ball x e \<subseteq> cball x e"
```
```   334     using ball_subset_cball by auto
```
```   335   moreover
```
```   336   {
```
```   337     fix S y
```
```   338     assume as: "S \<subseteq> cball x e" "open S" "y\<in>S"
```
```   339     then obtain d where "d>0" and d: "\<forall>x'. dist x' y < d \<longrightarrow> x' \<in> S"
```
```   340       unfolding open_dist by blast
```
```   341     then obtain xa where xa_y: "xa \<noteq> y" and xa: "dist xa y < d"
```
```   342       using perfect_choose_dist [of d] by auto
```
```   343     have "xa \<in> S"
```
```   344       using d[THEN spec[where x = xa]]
```
```   345       using xa by (auto simp: dist_commute)
```
```   346     then have xa_cball: "xa \<in> cball x e"
```
```   347       using as(1) by auto
```
```   348     then have "y \<in> ball x e"
```
```   349     proof (cases "x = y")
```
```   350       case True
```
```   351       then have "e > 0" using cs order.order_iff_strict xa_cball xa_y by fastforce
```
```   352       then show "y \<in> ball x e"
```
```   353         using \<open>x = y \<close> by simp
```
```   354     next
```
```   355       case False
```
```   356       have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) y < d"
```
```   357         unfolding dist_norm
```
```   358         using \<open>d>0\<close> norm_ge_zero[of "y - x"] \<open>x \<noteq> y\<close> by auto
```
```   359       then have *: "y + (d / 2 / dist y x) *\<^sub>R (y - x) \<in> cball x e"
```
```   360         using d as(1)[unfolded subset_eq] by blast
```
```   361       have "y - x \<noteq> 0" using \<open>x \<noteq> y\<close> by auto
```
```   362       hence **:"d / (2 * norm (y - x)) > 0"
```
```   363         unfolding zero_less_norm_iff[symmetric] using \<open>d>0\<close> by auto
```
```   364       have "dist (y + (d / 2 / dist y x) *\<^sub>R (y - x)) x =
```
```   365         norm (y + (d / (2 * norm (y - x))) *\<^sub>R y - (d / (2 * norm (y - x))) *\<^sub>R x - x)"
```
```   366         by (auto simp: dist_norm algebra_simps)
```
```   367       also have "\<dots> = norm ((1 + d / (2 * norm (y - x))) *\<^sub>R (y - x))"
```
```   368         by (auto simp: algebra_simps)
```
```   369       also have "\<dots> = \<bar>1 + d / (2 * norm (y - x))\<bar> * norm (y - x)"
```
```   370         using ** by auto
```
```   371       also have "\<dots> = (dist y x) + d/2"
```
```   372         using ** by (auto simp: distrib_right dist_norm)
```
```   373       finally have "e \<ge> dist x y +d/2"
```
```   374         using *[unfolded mem_cball] by (auto simp: dist_commute)
```
```   375       then show "y \<in> ball x e"
```
```   376         unfolding mem_ball using \<open>d>0\<close> by auto
```
```   377     qed
```
```   378   }
```
```   379   then have "\<forall>S \<subseteq> cball x e. open S \<longrightarrow> S \<subseteq> ball x e"
```
```   380     by auto
```
```   381   ultimately show ?thesis
```
```   382     using interior_unique[of "ball x e" "cball x e"]
```
```   383     using open_ball[of x e]
```
```   384     by auto
```
```   385 qed
```
```   386
```
```   387 lemma frontier_ball [simp]:
```
```   388   fixes a :: "'a::real_normed_vector"
```
```   389   shows "0 < e \<Longrightarrow> frontier (ball a e) = sphere a e"
```
```   390   by (force simp: frontier_def)
```
```   391
```
```   392 lemma frontier_cball [simp]:
```
```   393   fixes a :: "'a::{real_normed_vector, perfect_space}"
```
```   394   shows "frontier (cball a e) = sphere a e"
```
```   395   by (force simp: frontier_def)
```
```   396
```
```   397 corollary compact_sphere [simp]:
```
```   398   fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}"
```
```   399   shows "compact (sphere a r)"
```
```   400 using compact_frontier [of "cball a r"] by simp
```
```   401
```
```   402 corollary bounded_sphere [simp]:
```
```   403   fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}"
```
```   404   shows "bounded (sphere a r)"
```
```   405 by (simp add: compact_imp_bounded)
```
```   406
```
```   407 corollary closed_sphere  [simp]:
```
```   408   fixes a :: "'a::{real_normed_vector,perfect_space,heine_borel}"
```
```   409   shows "closed (sphere a r)"
```
```   410 by (simp add: compact_imp_closed)
```
```   411
```
```   412 lemma image_add_ball [simp]:
```
```   413   fixes a :: "'a::real_normed_vector"
```
```   414   shows "(+) b ` ball a r = ball (a+b) r"
```
```   415 apply (intro equalityI subsetI)
```
```   416 apply (force simp: dist_norm)
```
```   417 apply (rule_tac x="x-b" in image_eqI)
```
```   418 apply (auto simp: dist_norm algebra_simps)
```
```   419 done
```
```   420
```
```   421 lemma image_add_cball [simp]:
```
```   422   fixes a :: "'a::real_normed_vector"
```
```   423   shows "(+) b ` cball a r = cball (a+b) r"
```
```   424 apply (intro equalityI subsetI)
```
```   425 apply (force simp: dist_norm)
```
```   426 apply (rule_tac x="x-b" in image_eqI)
```
```   427 apply (auto simp: dist_norm algebra_simps)
```
```   428 done
```
```   429
```
```   430
```
```   431 subsection%unimportant \<open>Various Lemmas on Normed Algebras\<close>
```
```   432
```
```   433
```
```   434 lemma closed_of_nat_image: "closed (of_nat ` A :: 'a::real_normed_algebra_1 set)"
```
```   435   by (rule discrete_imp_closed[of 1]) (auto simp: dist_of_nat)
```
```   436
```
```   437 lemma closed_of_int_image: "closed (of_int ` A :: 'a::real_normed_algebra_1 set)"
```
```   438   by (rule discrete_imp_closed[of 1]) (auto simp: dist_of_int)
```
```   439
```
```   440 lemma closed_Nats [simp]: "closed (\<nat> :: 'a :: real_normed_algebra_1 set)"
```
```   441   unfolding Nats_def by (rule closed_of_nat_image)
```
```   442
```
```   443 lemma closed_Ints [simp]: "closed (\<int> :: 'a :: real_normed_algebra_1 set)"
```
```   444   unfolding Ints_def by (rule closed_of_int_image)
```
```   445
```
```   446 lemma closed_subset_Ints:
```
```   447   fixes A :: "'a :: real_normed_algebra_1 set"
```
```   448   assumes "A \<subseteq> \<int>"
```
```   449   shows   "closed A"
```
```   450 proof (intro discrete_imp_closed[OF zero_less_one] ballI impI, goal_cases)
```
```   451   case (1 x y)
```
```   452   with assms have "x \<in> \<int>" and "y \<in> \<int>" by auto
```
```   453   with \<open>dist y x < 1\<close> show "y = x"
```
```   454     by (auto elim!: Ints_cases simp: dist_of_int)
```
```   455 qed
```
```   456
```
```   457 subsection \<open>Filters\<close>
```
```   458
```
```   459 definition indirection :: "'a::real_normed_vector \<Rightarrow> 'a \<Rightarrow> 'a filter"  (infixr "indirection" 70)
```
```   460   where "a indirection v = at a within {b. \<exists>c\<ge>0. b - a = scaleR c v}"
```
```   461
```
```   462
```
```   463 subsection \<open>Trivial Limits\<close>
```
```   464
```
```   465 lemma trivial_limit_at_infinity:
```
```   466   "\<not> trivial_limit (at_infinity :: ('a::{real_normed_vector,perfect_space}) filter)"
```
```   467   unfolding trivial_limit_def eventually_at_infinity
```
```   468   apply clarsimp
```
```   469   apply (subgoal_tac "\<exists>x::'a. x \<noteq> 0", clarify)
```
```   470    apply (rule_tac x="scaleR (b / norm x) x" in exI, simp)
```
```   471   apply (cut_tac islimpt_UNIV [of "0::'a", unfolded islimpt_def])
```
```   472   apply (drule_tac x=UNIV in spec, simp)
```
```   473   done
```
```   474
```
```   475 lemma at_within_ball_bot_iff:
```
```   476   fixes x y :: "'a::{real_normed_vector,perfect_space}"
```
```   477   shows "at x within ball y r = bot \<longleftrightarrow> (r=0 \<or> x \<notin> cball y r)"
```
```   478   unfolding trivial_limit_within
```
```   479   apply (auto simp add:trivial_limit_within islimpt_ball )
```
```   480   by (metis le_less_trans less_eq_real_def zero_le_dist)
```
```   481
```
```   482
```
```   483 subsection \<open>Limits\<close>
```
```   484
```
```   485 proposition Lim_at_infinity: "(f \<longlongrightarrow> l) at_infinity \<longleftrightarrow> (\<forall>e>0. \<exists>b. \<forall>x. norm x \<ge> b \<longrightarrow> dist (f x) l < e)"
```
```   486   by (auto simp: tendsto_iff eventually_at_infinity)
```
```   487
```
```   488 corollary Lim_at_infinityI [intro?]:
```
```   489   assumes "\<And>e. e > 0 \<Longrightarrow> \<exists>B. \<forall>x. norm x \<ge> B \<longrightarrow> dist (f x) l \<le> e"
```
```   490   shows "(f \<longlongrightarrow> l) at_infinity"
```
```   491   apply (simp add: Lim_at_infinity, clarify)
```
```   492   apply (rule ex_forward [OF assms [OF half_gt_zero]], auto)
```
```   493   done
```
```   494
```
```   495 lemma Lim_transform_within_set_eq:
```
```   496   fixes a l :: "'a::real_normed_vector"
```
```   497   shows "eventually (\<lambda>x. x \<in> s \<longleftrightarrow> x \<in> t) (at a)
```
```   498          \<Longrightarrow> ((f \<longlongrightarrow> l) (at a within s) \<longleftrightarrow> (f \<longlongrightarrow> l) (at a within t))"
```
```   499   by (force intro: Lim_transform_within_set elim: eventually_mono)
```
```   500
```
```   501 lemma Lim_null:
```
```   502   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
```
```   503   shows "(f \<longlongrightarrow> l) net \<longleftrightarrow> ((\<lambda>x. f(x) - l) \<longlongrightarrow> 0) net"
```
```   504   by (simp add: Lim dist_norm)
```
```   505
```
```   506 lemma Lim_null_comparison:
```
```   507   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
```
```   508   assumes "eventually (\<lambda>x. norm (f x) \<le> g x) net" "(g \<longlongrightarrow> 0) net"
```
```   509   shows "(f \<longlongrightarrow> 0) net"
```
```   510   using assms(2)
```
```   511 proof (rule metric_tendsto_imp_tendsto)
```
```   512   show "eventually (\<lambda>x. dist (f x) 0 \<le> dist (g x) 0) net"
```
```   513     using assms(1) by (rule eventually_mono) (simp add: dist_norm)
```
```   514 qed
```
```   515
```
```   516 lemma Lim_transform_bound:
```
```   517   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
```
```   518     and g :: "'a \<Rightarrow> 'c::real_normed_vector"
```
```   519   assumes "eventually (\<lambda>n. norm (f n) \<le> norm (g n)) net"
```
```   520     and "(g \<longlongrightarrow> 0) net"
```
```   521   shows "(f \<longlongrightarrow> 0) net"
```
```   522   using assms(1) tendsto_norm_zero [OF assms(2)]
```
```   523   by (rule Lim_null_comparison)
```
```   524
```
```   525 lemma lim_null_mult_right_bounded:
```
```   526   fixes f :: "'a \<Rightarrow> 'b::real_normed_div_algebra"
```
```   527   assumes f: "(f \<longlongrightarrow> 0) F" and g: "eventually (\<lambda>x. norm(g x) \<le> B) F"
```
```   528     shows "((\<lambda>z. f z * g z) \<longlongrightarrow> 0) F"
```
```   529 proof -
```
```   530   have *: "((\<lambda>x. norm (f x) * B) \<longlongrightarrow> 0) F"
```
```   531     by (simp add: f tendsto_mult_left_zero tendsto_norm_zero)
```
```   532   have "((\<lambda>x. norm (f x) * norm (g x)) \<longlongrightarrow> 0) F"
```
```   533     apply (rule Lim_null_comparison [OF _ *])
```
```   534     apply (simp add: eventually_mono [OF g] mult_left_mono)
```
```   535     done
```
```   536   then show ?thesis
```
```   537     by (subst tendsto_norm_zero_iff [symmetric]) (simp add: norm_mult)
```
```   538 qed
```
```   539
```
```   540 lemma lim_null_mult_left_bounded:
```
```   541   fixes f :: "'a \<Rightarrow> 'b::real_normed_div_algebra"
```
```   542   assumes g: "eventually (\<lambda>x. norm(g x) \<le> B) F" and f: "(f \<longlongrightarrow> 0) F"
```
```   543     shows "((\<lambda>z. g z * f z) \<longlongrightarrow> 0) F"
```
```   544 proof -
```
```   545   have *: "((\<lambda>x. B * norm (f x)) \<longlongrightarrow> 0) F"
```
```   546     by (simp add: f tendsto_mult_right_zero tendsto_norm_zero)
```
```   547   have "((\<lambda>x. norm (g x) * norm (f x)) \<longlongrightarrow> 0) F"
```
```   548     apply (rule Lim_null_comparison [OF _ *])
```
```   549     apply (simp add: eventually_mono [OF g] mult_right_mono)
```
```   550     done
```
```   551   then show ?thesis
```
```   552     by (subst tendsto_norm_zero_iff [symmetric]) (simp add: norm_mult)
```
```   553 qed
```
```   554
```
```   555 lemma lim_null_scaleR_bounded:
```
```   556   assumes f: "(f \<longlongrightarrow> 0) net" and gB: "eventually (\<lambda>a. f a = 0 \<or> norm(g a) \<le> B) net"
```
```   557     shows "((\<lambda>n. f n *\<^sub>R g n) \<longlongrightarrow> 0) net"
```
```   558 proof
```
```   559   fix \<epsilon>::real
```
```   560   assume "0 < \<epsilon>"
```
```   561   then have B: "0 < \<epsilon> / (abs B + 1)" by simp
```
```   562   have *: "\<bar>f x\<bar> * norm (g x) < \<epsilon>" if f: "\<bar>f x\<bar> * (\<bar>B\<bar> + 1) < \<epsilon>" and g: "norm (g x) \<le> B" for x
```
```   563   proof -
```
```   564     have "\<bar>f x\<bar> * norm (g x) \<le> \<bar>f x\<bar> * B"
```
```   565       by (simp add: mult_left_mono g)
```
```   566     also have "\<dots> \<le> \<bar>f x\<bar> * (\<bar>B\<bar> + 1)"
```
```   567       by (simp add: mult_left_mono)
```
```   568     also have "\<dots> < \<epsilon>"
```
```   569       by (rule f)
```
```   570     finally show ?thesis .
```
```   571   qed
```
```   572   show "\<forall>\<^sub>F x in net. dist (f x *\<^sub>R g x) 0 < \<epsilon>"
```
```   573     apply (rule eventually_mono [OF eventually_conj [OF tendstoD [OF f B] gB] ])
```
```   574     apply (auto simp: \<open>0 < \<epsilon>\<close> divide_simps * split: if_split_asm)
```
```   575     done
```
```   576 qed
```
```   577
```
```   578 lemma Lim_norm_ubound:
```
```   579   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
```
```   580   assumes "\<not>(trivial_limit net)" "(f \<longlongrightarrow> l) net" "eventually (\<lambda>x. norm(f x) \<le> e) net"
```
```   581   shows "norm(l) \<le> e"
```
```   582   using assms by (fast intro: tendsto_le tendsto_intros)
```
```   583
```
```   584 lemma Lim_norm_lbound:
```
```   585   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
```
```   586   assumes "\<not> trivial_limit net"
```
```   587     and "(f \<longlongrightarrow> l) net"
```
```   588     and "eventually (\<lambda>x. e \<le> norm (f x)) net"
```
```   589   shows "e \<le> norm l"
```
```   590   using assms by (fast intro: tendsto_le tendsto_intros)
```
```   591
```
```   592 text\<open>Limit under bilinear function\<close>
```
```   593
```
```   594 lemma Lim_bilinear:
```
```   595   assumes "(f \<longlongrightarrow> l) net"
```
```   596     and "(g \<longlongrightarrow> m) net"
```
```   597     and "bounded_bilinear h"
```
```   598   shows "((\<lambda>x. h (f x) (g x)) \<longlongrightarrow> (h l m)) net"
```
```   599   using \<open>bounded_bilinear h\<close> \<open>(f \<longlongrightarrow> l) net\<close> \<open>(g \<longlongrightarrow> m) net\<close>
```
```   600   by (rule bounded_bilinear.tendsto)
```
```   601
```
```   602 lemma Lim_at_zero:
```
```   603   fixes a :: "'a::real_normed_vector"
```
```   604     and l :: "'b::topological_space"
```
```   605   shows "(f \<longlongrightarrow> l) (at a) \<longleftrightarrow> ((\<lambda>x. f(a + x)) \<longlongrightarrow> l) (at 0)"
```
```   606   using LIM_offset_zero LIM_offset_zero_cancel ..
```
```   607
```
```   608
```
```   609 subsection%unimportant \<open>Limit Point of Filter\<close>
```
```   610
```
```   611 lemma netlimit_at_vector:
```
```   612   fixes a :: "'a::real_normed_vector"
```
```   613   shows "netlimit (at a) = a"
```
```   614 proof (cases "\<exists>x. x \<noteq> a")
```
```   615   case True then obtain x where x: "x \<noteq> a" ..
```
```   616   have "\<not> trivial_limit (at a)"
```
```   617     unfolding trivial_limit_def eventually_at dist_norm
```
```   618     apply clarsimp
```
```   619     apply (rule_tac x="a + scaleR (d / 2) (sgn (x - a))" in exI)
```
```   620     apply (simp add: norm_sgn sgn_zero_iff x)
```
```   621     done
```
```   622   then show ?thesis
```
```   623     by (rule netlimit_within [of a UNIV])
```
```   624 qed simp
```
```   625
```
```   626 subsection \<open>Boundedness\<close>
```
```   627
```
```   628 lemma continuous_on_closure_norm_le:
```
```   629   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```   630   assumes "continuous_on (closure s) f"
```
```   631     and "\<forall>y \<in> s. norm(f y) \<le> b"
```
```   632     and "x \<in> (closure s)"
```
```   633   shows "norm (f x) \<le> b"
```
```   634 proof -
```
```   635   have *: "f ` s \<subseteq> cball 0 b"
```
```   636     using assms(2)[unfolded mem_cball_0[symmetric]] by auto
```
```   637   show ?thesis
```
```   638     by (meson "*" assms(1) assms(3) closed_cball image_closure_subset image_subset_iff mem_cball_0)
```
```   639 qed
```
```   640
```
```   641 lemma bounded_pos: "bounded S \<longleftrightarrow> (\<exists>b>0. \<forall>x\<in> S. norm x \<le> b)"
```
```   642   apply (simp add: bounded_iff)
```
```   643   apply (subgoal_tac "\<And>x (y::real). 0 < 1 + \<bar>y\<bar> \<and> (x \<le> y \<longrightarrow> x \<le> 1 + \<bar>y\<bar>)")
```
```   644   apply metis
```
```   645   apply arith
```
```   646   done
```
```   647
```
```   648 lemma bounded_pos_less: "bounded S \<longleftrightarrow> (\<exists>b>0. \<forall>x\<in> S. norm x < b)"
```
```   649   apply (simp add: bounded_pos)
```
```   650   apply (safe; rule_tac x="b+1" in exI; force)
```
```   651   done
```
```   652
```
```   653 lemma Bseq_eq_bounded:
```
```   654   fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
```
```   655   shows "Bseq f \<longleftrightarrow> bounded (range f)"
```
```   656   unfolding Bseq_def bounded_pos by auto
```
```   657
```
```   658 lemma bounded_linear_image:
```
```   659   assumes "bounded S"
```
```   660     and "bounded_linear f"
```
```   661   shows "bounded (f ` S)"
```
```   662 proof -
```
```   663   from assms(1) obtain b where "b > 0" and b: "\<forall>x\<in>S. norm x \<le> b"
```
```   664     unfolding bounded_pos by auto
```
```   665   from assms(2) obtain B where B: "B > 0" "\<forall>x. norm (f x) \<le> B * norm x"
```
```   666     using bounded_linear.pos_bounded by (auto simp: ac_simps)
```
```   667   show ?thesis
```
```   668     unfolding bounded_pos
```
```   669   proof (intro exI, safe)
```
```   670     show "norm (f x) \<le> B * b" if "x \<in> S" for x
```
```   671       by (meson B b less_imp_le mult_left_mono order_trans that)
```
```   672   qed (use \<open>b > 0\<close> \<open>B > 0\<close> in auto)
```
```   673 qed
```
```   674
```
```   675 lemma bounded_scaling:
```
```   676   fixes S :: "'a::real_normed_vector set"
```
```   677   shows "bounded S \<Longrightarrow> bounded ((\<lambda>x. c *\<^sub>R x) ` S)"
```
```   678   apply (rule bounded_linear_image, assumption)
```
```   679   apply (rule bounded_linear_scaleR_right)
```
```   680   done
```
```   681
```
```   682 lemma bounded_scaleR_comp:
```
```   683   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
```
```   684   assumes "bounded (f ` S)"
```
```   685   shows "bounded ((\<lambda>x. r *\<^sub>R f x) ` S)"
```
```   686   using bounded_scaling[of "f ` S" r] assms
```
```   687   by (auto simp: image_image)
```
```   688
```
```   689 lemma bounded_translation:
```
```   690   fixes S :: "'a::real_normed_vector set"
```
```   691   assumes "bounded S"
```
```   692   shows "bounded ((\<lambda>x. a + x) ` S)"
```
```   693 proof -
```
```   694   from assms obtain b where b: "b > 0" "\<forall>x\<in>S. norm x \<le> b"
```
```   695     unfolding bounded_pos by auto
```
```   696   {
```
```   697     fix x
```
```   698     assume "x \<in> S"
```
```   699     then have "norm (a + x) \<le> b + norm a"
```
```   700       using norm_triangle_ineq[of a x] b by auto
```
```   701   }
```
```   702   then show ?thesis
```
```   703     unfolding bounded_pos
```
```   704     using norm_ge_zero[of a] b(1) and add_strict_increasing[of b 0 "norm a"]
```
```   705     by (auto intro!: exI[of _ "b + norm a"])
```
```   706 qed
```
```   707
```
```   708 lemma bounded_translation_minus:
```
```   709   fixes S :: "'a::real_normed_vector set"
```
```   710   shows "bounded S \<Longrightarrow> bounded ((\<lambda>x. x - a) ` S)"
```
```   711 using bounded_translation [of S "-a"] by simp
```
```   712
```
```   713 lemma bounded_uminus [simp]:
```
```   714   fixes X :: "'a::real_normed_vector set"
```
```   715   shows "bounded (uminus ` X) \<longleftrightarrow> bounded X"
```
```   716 by (auto simp: bounded_def dist_norm; rule_tac x="-x" in exI; force simp: add.commute norm_minus_commute)
```
```   717
```
```   718 lemma uminus_bounded_comp [simp]:
```
```   719   fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
```
```   720   shows "bounded ((\<lambda>x. - f x) ` S) \<longleftrightarrow> bounded (f ` S)"
```
```   721   using bounded_uminus[of "f ` S"]
```
```   722   by (auto simp: image_image)
```
```   723
```
```   724 lemma bounded_plus_comp:
```
```   725   fixes f g::"'a \<Rightarrow> 'b::real_normed_vector"
```
```   726   assumes "bounded (f ` S)"
```
```   727   assumes "bounded (g ` S)"
```
```   728   shows "bounded ((\<lambda>x. f x + g x) ` S)"
```
```   729 proof -
```
```   730   {
```
```   731     fix B C
```
```   732     assume "\<And>x. x\<in>S \<Longrightarrow> norm (f x) \<le> B" "\<And>x. x\<in>S \<Longrightarrow> norm (g x) \<le> C"
```
```   733     then have "\<And>x. x \<in> S \<Longrightarrow> norm (f x + g x) \<le> B + C"
```
```   734       by (auto intro!: norm_triangle_le add_mono)
```
```   735   } then show ?thesis
```
```   736     using assms by (fastforce simp: bounded_iff)
```
```   737 qed
```
```   738
```
```   739 lemma bounded_plus:
```
```   740   fixes S ::"'a::real_normed_vector set"
```
```   741   assumes "bounded S" "bounded T"
```
```   742   shows "bounded ((\<lambda>(x,y). x + y) ` (S \<times> T))"
```
```   743   using bounded_plus_comp [of fst "S \<times> T" snd] assms
```
```   744   by (auto simp: split_def split: if_split_asm)
```
```   745
```
```   746 lemma bounded_minus_comp:
```
```   747   "bounded (f ` S) \<Longrightarrow> bounded (g ` S) \<Longrightarrow> bounded ((\<lambda>x. f x - g x) ` S)"
```
```   748   for f g::"'a \<Rightarrow> 'b::real_normed_vector"
```
```   749   using bounded_plus_comp[of "f" S "\<lambda>x. - g x"]
```
```   750   by auto
```
```   751
```
```   752 lemma bounded_minus:
```
```   753   fixes S ::"'a::real_normed_vector set"
```
```   754   assumes "bounded S" "bounded T"
```
```   755   shows "bounded ((\<lambda>(x,y). x - y) ` (S \<times> T))"
```
```   756   using bounded_minus_comp [of fst "S \<times> T" snd] assms
```
```   757   by (auto simp: split_def split: if_split_asm)
```
```   758
```
```   759 lemma not_bounded_UNIV[simp]:
```
```   760   "\<not> bounded (UNIV :: 'a::{real_normed_vector, perfect_space} set)"
```
```   761 proof (auto simp: bounded_pos not_le)
```
```   762   obtain x :: 'a where "x \<noteq> 0"
```
```   763     using perfect_choose_dist [OF zero_less_one] by fast
```
```   764   fix b :: real
```
```   765   assume b: "b >0"
```
```   766   have b1: "b +1 \<ge> 0"
```
```   767     using b by simp
```
```   768   with \<open>x \<noteq> 0\<close> have "b < norm (scaleR (b + 1) (sgn x))"
```
```   769     by (simp add: norm_sgn)
```
```   770   then show "\<exists>x::'a. b < norm x" ..
```
```   771 qed
```
```   772
```
```   773 corollary cobounded_imp_unbounded:
```
```   774     fixes S :: "'a::{real_normed_vector, perfect_space} set"
```
```   775     shows "bounded (- S) \<Longrightarrow> \<not> bounded S"
```
```   776   using bounded_Un [of S "-S"]  by (simp add: sup_compl_top)
```
```   777
```
```   778 subsection%unimportant\<open>Relations among convergence and absolute convergence for power series\<close>
```
```   779
```
```   780 lemma summable_imp_bounded:
```
```   781   fixes f :: "nat \<Rightarrow> 'a::real_normed_vector"
```
```   782   shows "summable f \<Longrightarrow> bounded (range f)"
```
```   783 by (frule summable_LIMSEQ_zero) (simp add: convergent_imp_bounded)
```
```   784
```
```   785 lemma summable_imp_sums_bounded:
```
```   786    "summable f \<Longrightarrow> bounded (range (\<lambda>n. sum f {..<n}))"
```
```   787 by (auto simp: summable_def sums_def dest: convergent_imp_bounded)
```
```   788
```
```   789 lemma power_series_conv_imp_absconv_weak:
```
```   790   fixes a:: "nat \<Rightarrow> 'a::{real_normed_div_algebra,banach}" and w :: 'a
```
```   791   assumes sum: "summable (\<lambda>n. a n * z ^ n)" and no: "norm w < norm z"
```
```   792     shows "summable (\<lambda>n. of_real(norm(a n)) * w ^ n)"
```
```   793 proof -
```
```   794   obtain M where M: "\<And>x. norm (a x * z ^ x) \<le> M"
```
```   795     using summable_imp_bounded [OF sum] by (force simp: bounded_iff)
```
```   796   then have *: "summable (\<lambda>n. norm (a n) * norm w ^ n)"
```
```   797     by (rule_tac M=M in Abel_lemma) (auto simp: norm_mult norm_power intro: no)
```
```   798   show ?thesis
```
```   799     apply (rule series_comparison_complex [of "(\<lambda>n. of_real(norm(a n) * norm w ^ n))"])
```
```   800     apply (simp only: summable_complex_of_real *)
```
```   801     apply (auto simp: norm_mult norm_power)
```
```   802     done
```
```   803 qed
```
```   804
```
```   805
```
```   806 subsection \<open>Normed spaces with the Heine-Borel property\<close>
```
```   807
```
```   808 lemma not_compact_UNIV[simp]:
```
```   809   fixes s :: "'a::{real_normed_vector,perfect_space,heine_borel} set"
```
```   810   shows "\<not> compact (UNIV::'a set)"
```
```   811     by (simp add: compact_eq_bounded_closed)
```
```   812
```
```   813 lemma not_compact_space_euclideanreal [simp]: "\<not> compact_space euclideanreal"
```
```   814   by (simp add: compact_space_def)
```
```   815
```
```   816 text\<open>Representing sets as the union of a chain of compact sets.\<close>
```
```   817 lemma closed_Union_compact_subsets:
```
```   818   fixes S :: "'a::{heine_borel,real_normed_vector} set"
```
```   819   assumes "closed S"
```
```   820   obtains F where "\<And>n. compact(F n)" "\<And>n. F n \<subseteq> S" "\<And>n. F n \<subseteq> F(Suc n)"
```
```   821                   "(\<Union>n. F n) = S" "\<And>K. \<lbrakk>compact K; K \<subseteq> S\<rbrakk> \<Longrightarrow> \<exists>N. \<forall>n \<ge> N. K \<subseteq> F n"
```
```   822 proof
```
```   823   show "compact (S \<inter> cball 0 (of_nat n))" for n
```
```   824     using assms compact_eq_bounded_closed by auto
```
```   825 next
```
```   826   show "(\<Union>n. S \<inter> cball 0 (real n)) = S"
```
```   827     by (auto simp: real_arch_simple)
```
```   828 next
```
```   829   fix K :: "'a set"
```
```   830   assume "compact K" "K \<subseteq> S"
```
```   831   then obtain N where "K \<subseteq> cball 0 N"
```
```   832     by (meson bounded_pos mem_cball_0 compact_imp_bounded subsetI)
```
```   833   then show "\<exists>N. \<forall>n\<ge>N. K \<subseteq> S \<inter> cball 0 (real n)"
```
```   834     by (metis of_nat_le_iff Int_subset_iff \<open>K \<subseteq> S\<close> real_arch_simple subset_cball subset_trans)
```
```   835 qed auto
```
```   836
```
```   837 subsection \<open>Intersecting chains of compact sets and the Baire property\<close>
```
```   838
```
```   839 proposition bounded_closed_chain:
```
```   840   fixes \<F> :: "'a::heine_borel set set"
```
```   841   assumes "B \<in> \<F>" "bounded B" and \<F>: "\<And>S. S \<in> \<F> \<Longrightarrow> closed S" and "{} \<notin> \<F>"
```
```   842       and chain: "\<And>S T. S \<in> \<F> \<and> T \<in> \<F> \<Longrightarrow> S \<subseteq> T \<or> T \<subseteq> S"
```
```   843     shows "\<Inter>\<F> \<noteq> {}"
```
```   844 proof -
```
```   845   have "B \<inter> \<Inter>\<F> \<noteq> {}"
```
```   846   proof (rule compact_imp_fip)
```
```   847     show "compact B" "\<And>T. T \<in> \<F> \<Longrightarrow> closed T"
```
```   848       by (simp_all add: assms compact_eq_bounded_closed)
```
```   849     show "\<lbrakk>finite \<G>; \<G> \<subseteq> \<F>\<rbrakk> \<Longrightarrow> B \<inter> \<Inter>\<G> \<noteq> {}" for \<G>
```
```   850     proof (induction \<G> rule: finite_induct)
```
```   851       case empty
```
```   852       with assms show ?case by force
```
```   853     next
```
```   854       case (insert U \<G>)
```
```   855       then have "U \<in> \<F>" and ne: "B \<inter> \<Inter>\<G> \<noteq> {}" by auto
```
```   856       then consider "B \<subseteq> U" | "U \<subseteq> B"
```
```   857           using \<open>B \<in> \<F>\<close> chain by blast
```
```   858         then show ?case
```
```   859         proof cases
```
```   860           case 1
```
```   861           then show ?thesis
```
```   862             using Int_left_commute ne by auto
```
```   863         next
```
```   864           case 2
```
```   865           have "U \<noteq> {}"
```
```   866             using \<open>U \<in> \<F>\<close> \<open>{} \<notin> \<F>\<close> by blast
```
```   867           moreover
```
```   868           have False if "\<And>x. x \<in> U \<Longrightarrow> \<exists>Y\<in>\<G>. x \<notin> Y"
```
```   869           proof -
```
```   870             have "\<And>x. x \<in> U \<Longrightarrow> \<exists>Y\<in>\<G>. Y \<subseteq> U"
```
```   871               by (metis chain contra_subsetD insert.prems insert_subset that)
```
```   872             then obtain Y where "Y \<in> \<G>" "Y \<subseteq> U"
```
```   873               by (metis all_not_in_conv \<open>U \<noteq> {}\<close>)
```
```   874             moreover obtain x where "x \<in> \<Inter>\<G>"
```
```   875               by (metis Int_emptyI ne)
```
```   876             ultimately show ?thesis
```
```   877               by (metis Inf_lower subset_eq that)
```
```   878           qed
```
```   879           with 2 show ?thesis
```
```   880             by blast
```
```   881         qed
```
```   882       qed
```
```   883   qed
```
```   884   then show ?thesis by blast
```
```   885 qed
```
```   886
```
```   887 corollary compact_chain:
```
```   888   fixes \<F> :: "'a::heine_borel set set"
```
```   889   assumes "\<And>S. S \<in> \<F> \<Longrightarrow> compact S" "{} \<notin> \<F>"
```
```   890           "\<And>S T. S \<in> \<F> \<and> T \<in> \<F> \<Longrightarrow> S \<subseteq> T \<or> T \<subseteq> S"
```
```   891     shows "\<Inter> \<F> \<noteq> {}"
```
```   892 proof (cases "\<F> = {}")
```
```   893   case True
```
```   894   then show ?thesis by auto
```
```   895 next
```
```   896   case False
```
```   897   show ?thesis
```
```   898     by (metis False all_not_in_conv assms compact_imp_bounded compact_imp_closed bounded_closed_chain)
```
```   899 qed
```
```   900
```
```   901 lemma compact_nest:
```
```   902   fixes F :: "'a::linorder \<Rightarrow> 'b::heine_borel set"
```
```   903   assumes F: "\<And>n. compact(F n)" "\<And>n. F n \<noteq> {}" and mono: "\<And>m n. m \<le> n \<Longrightarrow> F n \<subseteq> F m"
```
```   904   shows "\<Inter>(range F) \<noteq> {}"
```
```   905 proof -
```
```   906   have *: "\<And>S T. S \<in> range F \<and> T \<in> range F \<Longrightarrow> S \<subseteq> T \<or> T \<subseteq> S"
```
```   907     by (metis mono image_iff le_cases)
```
```   908   show ?thesis
```
```   909     apply (rule compact_chain [OF _ _ *])
```
```   910     using F apply (blast intro: dest: *)+
```
```   911     done
```
```   912 qed
```
```   913
```
```   914 text\<open>The Baire property of dense sets\<close>
```
```   915 theorem Baire:
```
```   916   fixes S::"'a::{real_normed_vector,heine_borel} set"
```
```   917   assumes "closed S" "countable \<G>"
```
```   918       and ope: "\<And>T. T \<in> \<G> \<Longrightarrow> openin (top_of_set S) T \<and> S \<subseteq> closure T"
```
```   919  shows "S \<subseteq> closure(\<Inter>\<G>)"
```
```   920 proof (cases "\<G> = {}")
```
```   921   case True
```
```   922   then show ?thesis
```
```   923     using closure_subset by auto
```
```   924 next
```
```   925   let ?g = "from_nat_into \<G>"
```
```   926   case False
```
```   927   then have gin: "?g n \<in> \<G>" for n
```
```   928     by (simp add: from_nat_into)
```
```   929   show ?thesis
```
```   930   proof (clarsimp simp: closure_approachable)
```
```   931     fix x and e::real
```
```   932     assume "x \<in> S" "0 < e"
```
```   933     obtain TF where opeF: "\<And>n. openin (top_of_set S) (TF n)"
```
```   934                and ne: "\<And>n. TF n \<noteq> {}"
```
```   935                and subg: "\<And>n. S \<inter> closure(TF n) \<subseteq> ?g n"
```
```   936                and subball: "\<And>n. closure(TF n) \<subseteq> ball x e"
```
```   937                and decr: "\<And>n. TF(Suc n) \<subseteq> TF n"
```
```   938     proof -
```
```   939       have *: "\<exists>Y. (openin (top_of_set S) Y \<and> Y \<noteq> {} \<and>
```
```   940                    S \<inter> closure Y \<subseteq> ?g n \<and> closure Y \<subseteq> ball x e) \<and> Y \<subseteq> U"
```
```   941         if opeU: "openin (top_of_set S) U" and "U \<noteq> {}" and cloU: "closure U \<subseteq> ball x e" for U n
```
```   942       proof -
```
```   943         obtain T where T: "open T" "U = T \<inter> S"
```
```   944           using \<open>openin (top_of_set S) U\<close> by (auto simp: openin_subtopology)
```
```   945         with \<open>U \<noteq> {}\<close> have "T \<inter> closure (?g n) \<noteq> {}"
```
```   946           using gin ope by fastforce
```
```   947         then have "T \<inter> ?g n \<noteq> {}"
```
```   948           using \<open>open T\<close> open_Int_closure_eq_empty by blast
```
```   949         then obtain y where "y \<in> U" "y \<in> ?g n"
```
```   950           using T ope [of "?g n", OF gin] by (blast dest:  openin_imp_subset)
```
```   951         moreover have "openin (top_of_set S) (U \<inter> ?g n)"
```
```   952           using gin ope opeU by blast
```
```   953         ultimately obtain d where U: "U \<inter> ?g n \<subseteq> S" and "d > 0" and d: "ball y d \<inter> S \<subseteq> U \<inter> ?g n"
```
```   954           by (force simp: openin_contains_ball)
```
```   955         show ?thesis
```
```   956         proof (intro exI conjI)
```
```   957           show "openin (top_of_set S) (S \<inter> ball y (d/2))"
```
```   958             by (simp add: openin_open_Int)
```
```   959           show "S \<inter> ball y (d/2) \<noteq> {}"
```
```   960             using \<open>0 < d\<close> \<open>y \<in> U\<close> opeU openin_imp_subset by fastforce
```
```   961           have "S \<inter> closure (S \<inter> ball y (d/2)) \<subseteq> S \<inter> closure (ball y (d/2))"
```
```   962             using closure_mono by blast
```
```   963           also have "... \<subseteq> ?g n"
```
```   964             using \<open>d > 0\<close> d by force
```
```   965           finally show "S \<inter> closure (S \<inter> ball y (d/2)) \<subseteq> ?g n" .
```
```   966           have "closure (S \<inter> ball y (d/2)) \<subseteq> S \<inter> ball y d"
```
```   967           proof -
```
```   968             have "closure (ball y (d/2)) \<subseteq> ball y d"
```
```   969               using \<open>d > 0\<close> by auto
```
```   970             then have "closure (S \<inter> ball y (d/2)) \<subseteq> ball y d"
```
```   971               by (meson closure_mono inf.cobounded2 subset_trans)
```
```   972             then show ?thesis
```
```   973               by (simp add: \<open>closed S\<close> closure_minimal)
```
```   974           qed
```
```   975           also have "...  \<subseteq> ball x e"
```
```   976             using cloU closure_subset d by blast
```
```   977           finally show "closure (S \<inter> ball y (d/2)) \<subseteq> ball x e" .
```
```   978           show "S \<inter> ball y (d/2) \<subseteq> U"
```
```   979             using ball_divide_subset_numeral d by blast
```
```   980         qed
```
```   981       qed
```
```   982       let ?\<Phi> = "\<lambda>n X. openin (top_of_set S) X \<and> X \<noteq> {} \<and>
```
```   983                       S \<inter> closure X \<subseteq> ?g n \<and> closure X \<subseteq> ball x e"
```
```   984       have "closure (S \<inter> ball x (e / 2)) \<subseteq> closure(ball x (e/2))"
```
```   985         by (simp add: closure_mono)
```
```   986       also have "...  \<subseteq> ball x e"
```
```   987         using \<open>e > 0\<close> by auto
```
```   988       finally have "closure (S \<inter> ball x (e / 2)) \<subseteq> ball x e" .
```
```   989       moreover have"openin (top_of_set S) (S \<inter> ball x (e / 2))" "S \<inter> ball x (e / 2) \<noteq> {}"
```
```   990         using \<open>0 < e\<close> \<open>x \<in> S\<close> by auto
```
```   991       ultimately obtain Y where Y: "?\<Phi> 0 Y \<and> Y \<subseteq> S \<inter> ball x (e / 2)"
```
```   992             using * [of "S \<inter> ball x (e/2)" 0] by metis
```
```   993       show thesis
```
```   994       proof (rule exE [OF dependent_nat_choice [of ?\<Phi> "\<lambda>n X Y. Y \<subseteq> X"]])
```
```   995         show "\<exists>x. ?\<Phi> 0 x"
```
```   996           using Y by auto
```
```   997         show "\<exists>Y. ?\<Phi> (Suc n) Y \<and> Y \<subseteq> X" if "?\<Phi> n X" for X n
```
```   998           using that by (blast intro: *)
```
```   999       qed (use that in metis)
```
```  1000     qed
```
```  1001     have "(\<Inter>n. S \<inter> closure (TF n)) \<noteq> {}"
```
```  1002     proof (rule compact_nest)
```
```  1003       show "\<And>n. compact (S \<inter> closure (TF n))"
```
```  1004         by (metis closed_closure subball bounded_subset_ballI compact_eq_bounded_closed closed_Int_compact [OF \<open>closed S\<close>])
```
```  1005       show "\<And>n. S \<inter> closure (TF n) \<noteq> {}"
```
```  1006         by (metis Int_absorb1 opeF \<open>closed S\<close> closure_eq_empty closure_minimal ne openin_imp_subset)
```
```  1007       show "\<And>m n. m \<le> n \<Longrightarrow> S \<inter> closure (TF n) \<subseteq> S \<inter> closure (TF m)"
```
```  1008         by (meson closure_mono decr dual_order.refl inf_mono lift_Suc_antimono_le)
```
```  1009     qed
```
```  1010     moreover have "(\<Inter>n. S \<inter> closure (TF n)) \<subseteq> {y \<in> \<Inter>\<G>. dist y x < e}"
```
```  1011     proof (clarsimp, intro conjI)
```
```  1012       fix y
```
```  1013       assume "y \<in> S" and y: "\<forall>n. y \<in> closure (TF n)"
```
```  1014       then show "\<forall>T\<in>\<G>. y \<in> T"
```
```  1015         by (metis Int_iff from_nat_into_surj [OF \<open>countable \<G>\<close>] subsetD subg)
```
```  1016       show "dist y x < e"
```
```  1017         by (metis y dist_commute mem_ball subball subsetCE)
```
```  1018     qed
```
```  1019     ultimately show "\<exists>y \<in> \<Inter>\<G>. dist y x < e"
```
```  1020       by auto
```
```  1021   qed
```
```  1022 qed
```
```  1023
```
```  1024
```
```  1025 subsection \<open>Continuity\<close>
```
```  1026
```
```  1027 subsubsection%unimportant \<open>Structural rules for uniform continuity\<close>
```
```  1028
```
```  1029 lemma (in bounded_linear) uniformly_continuous_on[continuous_intros]:
```
```  1030   fixes g :: "_::metric_space \<Rightarrow> _"
```
```  1031   assumes "uniformly_continuous_on s g"
```
```  1032   shows "uniformly_continuous_on s (\<lambda>x. f (g x))"
```
```  1033   using assms unfolding uniformly_continuous_on_sequentially
```
```  1034   unfolding dist_norm tendsto_norm_zero_iff diff[symmetric]
```
```  1035   by (auto intro: tendsto_zero)
```
```  1036
```
```  1037 lemma uniformly_continuous_on_dist[continuous_intros]:
```
```  1038   fixes f g :: "'a::metric_space \<Rightarrow> 'b::metric_space"
```
```  1039   assumes "uniformly_continuous_on s f"
```
```  1040     and "uniformly_continuous_on s g"
```
```  1041   shows "uniformly_continuous_on s (\<lambda>x. dist (f x) (g x))"
```
```  1042 proof -
```
```  1043   {
```
```  1044     fix a b c d :: 'b
```
```  1045     have "\<bar>dist a b - dist c d\<bar> \<le> dist a c + dist b d"
```
```  1046       using dist_triangle2 [of a b c] dist_triangle2 [of b c d]
```
```  1047       using dist_triangle3 [of c d a] dist_triangle [of a d b]
```
```  1048       by arith
```
```  1049   } note le = this
```
```  1050   {
```
```  1051     fix x y
```
```  1052     assume f: "(\<lambda>n. dist (f (x n)) (f (y n))) \<longlonglongrightarrow> 0"
```
```  1053     assume g: "(\<lambda>n. dist (g (x n)) (g (y n))) \<longlonglongrightarrow> 0"
```
```  1054     have "(\<lambda>n. \<bar>dist (f (x n)) (g (x n)) - dist (f (y n)) (g (y n))\<bar>) \<longlonglongrightarrow> 0"
```
```  1055       by (rule Lim_transform_bound [OF _ tendsto_add_zero [OF f g]],
```
```  1056         simp add: le)
```
```  1057   }
```
```  1058   then show ?thesis
```
```  1059     using assms unfolding uniformly_continuous_on_sequentially
```
```  1060     unfolding dist_real_def by simp
```
```  1061 qed
```
```  1062
```
```  1063 lemma uniformly_continuous_on_norm[continuous_intros]:
```
```  1064   fixes f :: "'a :: metric_space \<Rightarrow> 'b :: real_normed_vector"
```
```  1065   assumes "uniformly_continuous_on s f"
```
```  1066   shows "uniformly_continuous_on s (\<lambda>x. norm (f x))"
```
```  1067   unfolding norm_conv_dist using assms
```
```  1068   by (intro uniformly_continuous_on_dist uniformly_continuous_on_const)
```
```  1069
```
```  1070 lemma uniformly_continuous_on_cmul[continuous_intros]:
```
```  1071   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```  1072   assumes "uniformly_continuous_on s f"
```
```  1073   shows "uniformly_continuous_on s (\<lambda>x. c *\<^sub>R f(x))"
```
```  1074   using bounded_linear_scaleR_right assms
```
```  1075   by (rule bounded_linear.uniformly_continuous_on)
```
```  1076
```
```  1077 lemma dist_minus:
```
```  1078   fixes x y :: "'a::real_normed_vector"
```
```  1079   shows "dist (- x) (- y) = dist x y"
```
```  1080   unfolding dist_norm minus_diff_minus norm_minus_cancel ..
```
```  1081
```
```  1082 lemma uniformly_continuous_on_minus[continuous_intros]:
```
```  1083   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```  1084   shows "uniformly_continuous_on s f \<Longrightarrow> uniformly_continuous_on s (\<lambda>x. - f x)"
```
```  1085   unfolding uniformly_continuous_on_def dist_minus .
```
```  1086
```
```  1087 lemma uniformly_continuous_on_add[continuous_intros]:
```
```  1088   fixes f g :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```  1089   assumes "uniformly_continuous_on s f"
```
```  1090     and "uniformly_continuous_on s g"
```
```  1091   shows "uniformly_continuous_on s (\<lambda>x. f x + g x)"
```
```  1092   using assms
```
```  1093   unfolding uniformly_continuous_on_sequentially
```
```  1094   unfolding dist_norm tendsto_norm_zero_iff add_diff_add
```
```  1095   by (auto intro: tendsto_add_zero)
```
```  1096
```
```  1097 lemma uniformly_continuous_on_diff[continuous_intros]:
```
```  1098   fixes f :: "'a::metric_space \<Rightarrow> 'b::real_normed_vector"
```
```  1099   assumes "uniformly_continuous_on s f"
```
```  1100     and "uniformly_continuous_on s g"
```
```  1101   shows "uniformly_continuous_on s (\<lambda>x. f x - g x)"
```
```  1102   using assms uniformly_continuous_on_add [of s f "- g"]
```
```  1103     by (simp add: fun_Compl_def uniformly_continuous_on_minus)
```
```  1104
```
```  1105
```
```  1106 subsection%unimportant \<open>Topological properties of linear functions\<close>
```
```  1107
```
```  1108 lemma linear_lim_0:
```
```  1109   assumes "bounded_linear f"
```
```  1110   shows "(f \<longlongrightarrow> 0) (at (0))"
```
```  1111 proof -
```
```  1112   interpret f: bounded_linear f by fact
```
```  1113   have "(f \<longlongrightarrow> f 0) (at 0)"
```
```  1114     using tendsto_ident_at by (rule f.tendsto)
```
```  1115   then show ?thesis unfolding f.zero .
```
```  1116 qed
```
```  1117
```
```  1118 lemma linear_continuous_at:
```
```  1119   assumes "bounded_linear f"
```
```  1120   shows "continuous (at a) f"
```
```  1121   unfolding continuous_at using assms
```
```  1122   apply (rule bounded_linear.tendsto)
```
```  1123   apply (rule tendsto_ident_at)
```
```  1124   done
```
```  1125
```
```  1126 lemma linear_continuous_within:
```
```  1127   "bounded_linear f \<Longrightarrow> continuous (at x within s) f"
```
```  1128   using continuous_at_imp_continuous_within[of x f s] using linear_continuous_at[of f] by auto
```
```  1129
```
```  1130 lemma linear_continuous_on:
```
```  1131   "bounded_linear f \<Longrightarrow> continuous_on s f"
```
```  1132   using continuous_at_imp_continuous_on[of s f] using linear_continuous_at[of f] by auto
```
```  1133
```
```  1134 subsection%unimportant \<open>Arithmetic Preserves Topological Properties\<close>
```
```  1135
```
```  1136 lemma open_scaling[intro]:
```
```  1137   fixes s :: "'a::real_normed_vector set"
```
```  1138   assumes "c \<noteq> 0"
```
```  1139     and "open s"
```
```  1140   shows "open((\<lambda>x. c *\<^sub>R x) ` s)"
```
```  1141 proof -
```
```  1142   {
```
```  1143     fix x
```
```  1144     assume "x \<in> s"
```
```  1145     then obtain e where "e>0"
```
```  1146       and e:"\<forall>x'. dist x' x < e \<longrightarrow> x' \<in> s" using assms(2)[unfolded open_dist, THEN bspec[where x=x]]
```
```  1147       by auto
```
```  1148     have "e * \<bar>c\<bar> > 0"
```
```  1149       using assms(1)[unfolded zero_less_abs_iff[symmetric]] \<open>e>0\<close> by auto
```
```  1150     moreover
```
```  1151     {
```
```  1152       fix y
```
```  1153       assume "dist y (c *\<^sub>R x) < e * \<bar>c\<bar>"
```
```  1154       then have "norm ((1 / c) *\<^sub>R y - x) < e"
```
```  1155         unfolding dist_norm
```
```  1156         using norm_scaleR[of c "(1 / c) *\<^sub>R y - x", unfolded scaleR_right_diff_distrib, unfolded scaleR_scaleR] assms(1)
```
```  1157           assms(1)[unfolded zero_less_abs_iff[symmetric]] by (simp del:zero_less_abs_iff)
```
```  1158       then have "y \<in> (*\<^sub>R) c ` s"
```
```  1159         using rev_image_eqI[of "(1 / c) *\<^sub>R y" s y "(*\<^sub>R) c"]
```
```  1160         using e[THEN spec[where x="(1 / c) *\<^sub>R y"]]
```
```  1161         using assms(1)
```
```  1162         unfolding dist_norm scaleR_scaleR
```
```  1163         by auto
```
```  1164     }
```
```  1165     ultimately have "\<exists>e>0. \<forall>x'. dist x' (c *\<^sub>R x) < e \<longrightarrow> x' \<in> (*\<^sub>R) c ` s"
```
```  1166       apply (rule_tac x="e * \<bar>c\<bar>" in exI, auto)
```
```  1167       done
```
```  1168   }
```
```  1169   then show ?thesis unfolding open_dist by auto
```
```  1170 qed
```
```  1171
```
```  1172 lemma minus_image_eq_vimage:
```
```  1173   fixes A :: "'a::ab_group_add set"
```
```  1174   shows "(\<lambda>x. - x) ` A = (\<lambda>x. - x) -` A"
```
```  1175   by (auto intro!: image_eqI [where f="\<lambda>x. - x"])
```
```  1176
```
```  1177 lemma open_negations:
```
```  1178   fixes S :: "'a::real_normed_vector set"
```
```  1179   shows "open S \<Longrightarrow> open ((\<lambda>x. - x) ` S)"
```
```  1180   using open_scaling [of "- 1" S] by simp
```
```  1181
```
```  1182 lemma open_translation:
```
```  1183   fixes S :: "'a::real_normed_vector set"
```
```  1184   assumes "open S"
```
```  1185   shows "open((\<lambda>x. a + x) ` S)"
```
```  1186 proof -
```
```  1187   {
```
```  1188     fix x
```
```  1189     have "continuous (at x) (\<lambda>x. x - a)"
```
```  1190       by (intro continuous_diff continuous_ident continuous_const)
```
```  1191   }
```
```  1192   moreover have "{x. x - a \<in> S} = (+) a ` S"
```
```  1193     by force
```
```  1194   ultimately show ?thesis
```
```  1195     by (metis assms continuous_open_vimage vimage_def)
```
```  1196 qed
```
```  1197
```
```  1198 lemma open_neg_translation:
```
```  1199   fixes s :: "'a::real_normed_vector set"
```
```  1200   assumes "open s"
```
```  1201   shows "open((\<lambda>x. a - x) ` s)"
```
```  1202   using open_translation[OF open_negations[OF assms], of a]
```
```  1203   by (auto simp: image_image)
```
```  1204
```
```  1205 lemma open_affinity:
```
```  1206   fixes S :: "'a::real_normed_vector set"
```
```  1207   assumes "open S"  "c \<noteq> 0"
```
```  1208   shows "open ((\<lambda>x. a + c *\<^sub>R x) ` S)"
```
```  1209 proof -
```
```  1210   have *: "(\<lambda>x. a + c *\<^sub>R x) = (\<lambda>x. a + x) \<circ> (\<lambda>x. c *\<^sub>R x)"
```
```  1211     unfolding o_def ..
```
```  1212   have "(+) a ` (*\<^sub>R) c ` S = ((+) a \<circ> (*\<^sub>R) c) ` S"
```
```  1213     by auto
```
```  1214   then show ?thesis
```
```  1215     using assms open_translation[of "(*\<^sub>R) c ` S" a]
```
```  1216     unfolding *
```
```  1217     by auto
```
```  1218 qed
```
```  1219
```
```  1220 lemma interior_translation:
```
```  1221   "interior ((+) a ` S) = (+) a ` (interior S)" for S :: "'a::real_normed_vector set"
```
```  1222 proof (rule set_eqI, rule)
```
```  1223   fix x
```
```  1224   assume "x \<in> interior ((+) a ` S)"
```
```  1225   then obtain e where "e > 0" and e: "ball x e \<subseteq> (+) a ` S"
```
```  1226     unfolding mem_interior by auto
```
```  1227   then have "ball (x - a) e \<subseteq> S"
```
```  1228     unfolding subset_eq Ball_def mem_ball dist_norm
```
```  1229     by (auto simp: diff_diff_eq)
```
```  1230   then show "x \<in> (+) a ` interior S"
```
```  1231     unfolding image_iff
```
```  1232     apply (rule_tac x="x - a" in bexI)
```
```  1233     unfolding mem_interior
```
```  1234     using \<open>e > 0\<close>
```
```  1235     apply auto
```
```  1236     done
```
```  1237 next
```
```  1238   fix x
```
```  1239   assume "x \<in> (+) a ` interior S"
```
```  1240   then obtain y e where "e > 0" and e: "ball y e \<subseteq> S" and y: "x = a + y"
```
```  1241     unfolding image_iff Bex_def mem_interior by auto
```
```  1242   {
```
```  1243     fix z
```
```  1244     have *: "a + y - z = y + a - z" by auto
```
```  1245     assume "z \<in> ball x e"
```
```  1246     then have "z - a \<in> S"
```
```  1247       using e[unfolded subset_eq, THEN bspec[where x="z - a"]]
```
```  1248       unfolding mem_ball dist_norm y group_add_class.diff_diff_eq2 *
```
```  1249       by auto
```
```  1250     then have "z \<in> (+) a ` S"
```
```  1251       unfolding image_iff by (auto intro!: bexI[where x="z - a"])
```
```  1252   }
```
```  1253   then have "ball x e \<subseteq> (+) a ` S"
```
```  1254     unfolding subset_eq by auto
```
```  1255   then show "x \<in> interior ((+) a ` S)"
```
```  1256     unfolding mem_interior using \<open>e > 0\<close> by auto
```
```  1257 qed
```
```  1258
```
```  1259 lemma interior_translation_subtract:
```
```  1260   "interior ((\<lambda>x. x - a) ` S) = (\<lambda>x. x - a) ` interior S" for S :: "'a::real_normed_vector set"
```
```  1261   using interior_translation [of "- a"] by (simp cong: image_cong_simp)
```
```  1262
```
```  1263
```
```  1264 lemma compact_scaling:
```
```  1265   fixes s :: "'a::real_normed_vector set"
```
```  1266   assumes "compact s"
```
```  1267   shows "compact ((\<lambda>x. c *\<^sub>R x) ` s)"
```
```  1268 proof -
```
```  1269   let ?f = "\<lambda>x. scaleR c x"
```
```  1270   have *: "bounded_linear ?f" by (rule bounded_linear_scaleR_right)
```
```  1271   show ?thesis
```
```  1272     using compact_continuous_image[of s ?f] continuous_at_imp_continuous_on[of s ?f]
```
```  1273     using linear_continuous_at[OF *] assms
```
```  1274     by auto
```
```  1275 qed
```
```  1276
```
```  1277 lemma compact_negations:
```
```  1278   fixes s :: "'a::real_normed_vector set"
```
```  1279   assumes "compact s"
```
```  1280   shows "compact ((\<lambda>x. - x) ` s)"
```
```  1281   using compact_scaling [OF assms, of "- 1"] by auto
```
```  1282
```
```  1283 lemma compact_sums:
```
```  1284   fixes s t :: "'a::real_normed_vector set"
```
```  1285   assumes "compact s"
```
```  1286     and "compact t"
```
```  1287   shows "compact {x + y | x y. x \<in> s \<and> y \<in> t}"
```
```  1288 proof -
```
```  1289   have *: "{x + y | x y. x \<in> s \<and> y \<in> t} = (\<lambda>z. fst z + snd z) ` (s \<times> t)"
```
```  1290     apply auto
```
```  1291     unfolding image_iff
```
```  1292     apply (rule_tac x="(xa, y)" in bexI)
```
```  1293     apply auto
```
```  1294     done
```
```  1295   have "continuous_on (s \<times> t) (\<lambda>z. fst z + snd z)"
```
```  1296     unfolding continuous_on by (rule ballI) (intro tendsto_intros)
```
```  1297   then show ?thesis
```
```  1298     unfolding * using compact_continuous_image compact_Times [OF assms] by auto
```
```  1299 qed
```
```  1300
```
```  1301 lemma compact_differences:
```
```  1302   fixes s t :: "'a::real_normed_vector set"
```
```  1303   assumes "compact s"
```
```  1304     and "compact t"
```
```  1305   shows "compact {x - y | x y. x \<in> s \<and> y \<in> t}"
```
```  1306 proof-
```
```  1307   have "{x - y | x y. x\<in>s \<and> y \<in> t} =  {x + y | x y. x \<in> s \<and> y \<in> (uminus ` t)}"
```
```  1308     apply auto
```
```  1309     apply (rule_tac x= xa in exI, auto)
```
```  1310     done
```
```  1311   then show ?thesis
```
```  1312     using compact_sums[OF assms(1) compact_negations[OF assms(2)]] by auto
```
```  1313 qed
```
```  1314
```
```  1315 lemma compact_translation:
```
```  1316   "compact ((+) a ` s)" if "compact s" for s :: "'a::real_normed_vector set"
```
```  1317 proof -
```
```  1318   have "{x + y |x y. x \<in> s \<and> y \<in> {a}} = (\<lambda>x. a + x) ` s"
```
```  1319     by auto
```
```  1320   then show ?thesis
```
```  1321     using compact_sums [OF that compact_sing [of a]] by auto
```
```  1322 qed
```
```  1323
```
```  1324 lemma compact_translation_subtract:
```
```  1325   "compact ((\<lambda>x. x - a) ` s)" if "compact s" for s :: "'a::real_normed_vector set"
```
```  1326   using that compact_translation [of s "- a"] by (simp cong: image_cong_simp)
```
```  1327
```
```  1328 lemma compact_affinity:
```
```  1329   fixes s :: "'a::real_normed_vector set"
```
```  1330   assumes "compact s"
```
```  1331   shows "compact ((\<lambda>x. a + c *\<^sub>R x) ` s)"
```
```  1332 proof -
```
```  1333   have "(+) a ` (*\<^sub>R) c ` s = (\<lambda>x. a + c *\<^sub>R x) ` s"
```
```  1334     by auto
```
```  1335   then show ?thesis
```
```  1336     using compact_translation[OF compact_scaling[OF assms], of a c] by auto
```
```  1337 qed
```
```  1338
```
```  1339 lemma closed_scaling:
```
```  1340   fixes S :: "'a::real_normed_vector set"
```
```  1341   assumes "closed S"
```
```  1342   shows "closed ((\<lambda>x. c *\<^sub>R x) ` S)"
```
```  1343 proof (cases "c = 0")
```
```  1344   case True then show ?thesis
```
```  1345     by (auto simp: image_constant_conv)
```
```  1346 next
```
```  1347   case False
```
```  1348   from assms have "closed ((\<lambda>x. inverse c *\<^sub>R x) -` S)"
```
```  1349     by (simp add: continuous_closed_vimage)
```
```  1350   also have "(\<lambda>x. inverse c *\<^sub>R x) -` S = (\<lambda>x. c *\<^sub>R x) ` S"
```
```  1351     using \<open>c \<noteq> 0\<close> by (auto elim: image_eqI [rotated])
```
```  1352   finally show ?thesis .
```
```  1353 qed
```
```  1354
```
```  1355 lemma closed_negations:
```
```  1356   fixes S :: "'a::real_normed_vector set"
```
```  1357   assumes "closed S"
```
```  1358   shows "closed ((\<lambda>x. -x) ` S)"
```
```  1359   using closed_scaling[OF assms, of "- 1"] by simp
```
```  1360
```
```  1361 lemma compact_closed_sums:
```
```  1362   fixes S :: "'a::real_normed_vector set"
```
```  1363   assumes "compact S" and "closed T"
```
```  1364   shows "closed (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
```
```  1365 proof -
```
```  1366   let ?S = "{x + y |x y. x \<in> S \<and> y \<in> T}"
```
```  1367   {
```
```  1368     fix x l
```
```  1369     assume as: "\<forall>n. x n \<in> ?S"  "(x \<longlongrightarrow> l) sequentially"
```
```  1370     from as(1) obtain f where f: "\<forall>n. x n = fst (f n) + snd (f n)"  "\<forall>n. fst (f n) \<in> S"  "\<forall>n. snd (f n) \<in> T"
```
```  1371       using choice[of "\<lambda>n y. x n = (fst y) + (snd y) \<and> fst y \<in> S \<and> snd y \<in> T"] by auto
```
```  1372     obtain l' r where "l'\<in>S" and r: "strict_mono r" and lr: "(((\<lambda>n. fst (f n)) \<circ> r) \<longlongrightarrow> l') sequentially"
```
```  1373       using assms(1)[unfolded compact_def, THEN spec[where x="\<lambda> n. fst (f n)"]] using f(2) by auto
```
```  1374     have "((\<lambda>n. snd (f (r n))) \<longlongrightarrow> l - l') sequentially"
```
```  1375       using tendsto_diff[OF LIMSEQ_subseq_LIMSEQ[OF as(2) r] lr] and f(1)
```
```  1376       unfolding o_def
```
```  1377       by auto
```
```  1378     then have "l - l' \<in> T"
```
```  1379       using assms(2)[unfolded closed_sequential_limits,
```
```  1380         THEN spec[where x="\<lambda> n. snd (f (r n))"],
```
```  1381         THEN spec[where x="l - l'"]]
```
```  1382       using f(3)
```
```  1383       by auto
```
```  1384     then have "l \<in> ?S"
```
```  1385       using \<open>l' \<in> S\<close>
```
```  1386       apply auto
```
```  1387       apply (rule_tac x=l' in exI)
```
```  1388       apply (rule_tac x="l - l'" in exI, auto)
```
```  1389       done
```
```  1390   }
```
```  1391   moreover have "?S = (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
```
```  1392     by force
```
```  1393   ultimately show ?thesis
```
```  1394     unfolding closed_sequential_limits
```
```  1395     by (metis (no_types, lifting))
```
```  1396 qed
```
```  1397
```
```  1398 lemma closed_compact_sums:
```
```  1399   fixes S T :: "'a::real_normed_vector set"
```
```  1400   assumes "closed S" "compact T"
```
```  1401   shows "closed (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
```
```  1402 proof -
```
```  1403   have "(\<Union>x\<in> T. \<Union>y \<in> S. {x + y}) = (\<Union>x\<in> S. \<Union>y \<in> T. {x + y})"
```
```  1404     by auto
```
```  1405   then show ?thesis
```
```  1406     using compact_closed_sums[OF assms(2,1)] by simp
```
```  1407 qed
```
```  1408
```
```  1409 lemma compact_closed_differences:
```
```  1410   fixes S T :: "'a::real_normed_vector set"
```
```  1411   assumes "compact S" "closed T"
```
```  1412   shows "closed (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
```
```  1413 proof -
```
```  1414   have "(\<Union>x\<in> S. \<Union>y \<in> uminus ` T. {x + y}) = (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
```
```  1415     by force
```
```  1416   then show ?thesis
```
```  1417     using compact_closed_sums[OF assms(1) closed_negations[OF assms(2)]] by auto
```
```  1418 qed
```
```  1419
```
```  1420 lemma closed_compact_differences:
```
```  1421   fixes S T :: "'a::real_normed_vector set"
```
```  1422   assumes "closed S" "compact T"
```
```  1423   shows "closed (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
```
```  1424 proof -
```
```  1425   have "(\<Union>x\<in> S. \<Union>y \<in> uminus ` T. {x + y}) = {x - y |x y. x \<in> S \<and> y \<in> T}"
```
```  1426     by auto
```
```  1427  then show ?thesis
```
```  1428   using closed_compact_sums[OF assms(1) compact_negations[OF assms(2)]] by simp
```
```  1429 qed
```
```  1430
```
```  1431 lemma closed_translation:
```
```  1432   "closed ((+) a ` S)" if "closed S" for a :: "'a::real_normed_vector"
```
```  1433 proof -
```
```  1434   have "(\<Union>x\<in> {a}. \<Union>y \<in> S. {x + y}) = ((+) a ` S)" by auto
```
```  1435   then show ?thesis
```
```  1436     using compact_closed_sums [OF compact_sing [of a] that] by auto
```
```  1437 qed
```
```  1438
```
```  1439 lemma closed_translation_subtract:
```
```  1440   "closed ((\<lambda>x. x - a) ` S)" if "closed S" for a :: "'a::real_normed_vector"
```
```  1441   using that closed_translation [of S "- a"] by (simp cong: image_cong_simp)
```
```  1442
```
```  1443 lemma closure_translation:
```
```  1444   "closure ((+) a ` s) = (+) a ` closure s" for a :: "'a::real_normed_vector"
```
```  1445 proof -
```
```  1446   have *: "(+) a ` (- s) = - (+) a ` s"
```
```  1447     by (auto intro!: image_eqI [where x = "x - a" for x])
```
```  1448   show ?thesis
```
```  1449     using interior_translation [of a "- s", symmetric]
```
```  1450     by (simp add: closure_interior translation_Compl *)
```
```  1451 qed
```
```  1452
```
```  1453 lemma closure_translation_subtract:
```
```  1454   "closure ((\<lambda>x. x - a) ` s) = (\<lambda>x. x - a) ` closure s" for a :: "'a::real_normed_vector"
```
```  1455   using closure_translation [of "- a" s] by (simp cong: image_cong_simp)
```
```  1456
```
```  1457 lemma frontier_translation:
```
```  1458   "frontier ((+) a ` s) = (+) a ` frontier s" for a :: "'a::real_normed_vector"
```
```  1459   by (auto simp add: frontier_def translation_diff interior_translation closure_translation)
```
```  1460
```
```  1461 lemma frontier_translation_subtract:
```
```  1462   "frontier ((+) a ` s) = (+) a ` frontier s" for a :: "'a::real_normed_vector"
```
```  1463   by (auto simp add: frontier_def translation_diff interior_translation closure_translation)
```
```  1464
```
```  1465 lemma sphere_translation:
```
```  1466   "sphere (a + c) r = (+) a ` sphere c r" for a :: "'n::real_normed_vector"
```
```  1467   by (auto simp: dist_norm algebra_simps intro!: image_eqI [where x = "x - a" for x])
```
```  1468
```
```  1469 lemma sphere_translation_subtract:
```
```  1470   "sphere (c - a) r = (\<lambda>x. x - a) ` sphere c r" for a :: "'n::real_normed_vector"
```
```  1471   using sphere_translation [of "- a" c] by (simp cong: image_cong_simp)
```
```  1472
```
```  1473 lemma cball_translation:
```
```  1474   "cball (a + c) r = (+) a ` cball c r" for a :: "'n::real_normed_vector"
```
```  1475   by (auto simp: dist_norm algebra_simps intro!: image_eqI [where x = "x - a" for x])
```
```  1476
```
```  1477 lemma cball_translation_subtract:
```
```  1478   "cball (c - a) r = (\<lambda>x. x - a) ` cball c r" for a :: "'n::real_normed_vector"
```
```  1479   using cball_translation [of "- a" c] by (simp cong: image_cong_simp)
```
```  1480
```
```  1481 lemma ball_translation:
```
```  1482   "ball (a + c) r = (+) a ` ball c r" for a :: "'n::real_normed_vector"
```
```  1483   by (auto simp: dist_norm algebra_simps intro!: image_eqI [where x = "x - a" for x])
```
```  1484
```
```  1485 lemma ball_translation_subtract:
```
```  1486   "ball (c - a) r = (\<lambda>x. x - a) ` ball c r" for a :: "'n::real_normed_vector"
```
```  1487   using ball_translation [of "- a" c] by (simp cong: image_cong_simp)
```
```  1488
```
```  1489
```
```  1490 subsection%unimportant\<open>Homeomorphisms\<close>
```
```  1491
```
```  1492 lemma homeomorphic_scaling:
```
```  1493   fixes s :: "'a::real_normed_vector set"
```
```  1494   assumes "c \<noteq> 0"
```
```  1495   shows "s homeomorphic ((\<lambda>x. c *\<^sub>R x) ` s)"
```
```  1496   unfolding homeomorphic_minimal
```
```  1497   apply (rule_tac x="\<lambda>x. c *\<^sub>R x" in exI)
```
```  1498   apply (rule_tac x="\<lambda>x. (1 / c) *\<^sub>R x" in exI)
```
```  1499   using assms
```
```  1500   apply (auto simp: continuous_intros)
```
```  1501   done
```
```  1502
```
```  1503 lemma homeomorphic_translation:
```
```  1504   fixes s :: "'a::real_normed_vector set"
```
```  1505   shows "s homeomorphic ((\<lambda>x. a + x) ` s)"
```
```  1506   unfolding homeomorphic_minimal
```
```  1507   apply (rule_tac x="\<lambda>x. a + x" in exI)
```
```  1508   apply (rule_tac x="\<lambda>x. -a + x" in exI)
```
```  1509   using continuous_on_add [OF continuous_on_const continuous_on_id, of s a]
```
```  1510     continuous_on_add [OF continuous_on_const continuous_on_id, of "plus a ` s" "- a"]
```
```  1511   apply auto
```
```  1512   done
```
```  1513
```
```  1514 lemma homeomorphic_affinity:
```
```  1515   fixes s :: "'a::real_normed_vector set"
```
```  1516   assumes "c \<noteq> 0"
```
```  1517   shows "s homeomorphic ((\<lambda>x. a + c *\<^sub>R x) ` s)"
```
```  1518 proof -
```
```  1519   have *: "(+) a ` (*\<^sub>R) c ` s = (\<lambda>x. a + c *\<^sub>R x) ` s" by auto
```
```  1520   show ?thesis
```
```  1521     using homeomorphic_trans
```
```  1522     using homeomorphic_scaling[OF assms, of s]
```
```  1523     using homeomorphic_translation[of "(\<lambda>x. c *\<^sub>R x) ` s" a]
```
```  1524     unfolding *
```
```  1525     by auto
```
```  1526 qed
```
```  1527
```
```  1528 lemma homeomorphic_balls:
```
```  1529   fixes a b ::"'a::real_normed_vector"
```
```  1530   assumes "0 < d"  "0 < e"
```
```  1531   shows "(ball a d) homeomorphic  (ball b e)" (is ?th)
```
```  1532     and "(cball a d) homeomorphic (cball b e)" (is ?cth)
```
```  1533 proof -
```
```  1534   show ?th unfolding homeomorphic_minimal
```
```  1535     apply(rule_tac x="\<lambda>x. b + (e/d) *\<^sub>R (x - a)" in exI)
```
```  1536     apply(rule_tac x="\<lambda>x. a + (d/e) *\<^sub>R (x - b)" in exI)
```
```  1537     using assms
```
```  1538     apply (auto intro!: continuous_intros
```
```  1539       simp: dist_commute dist_norm pos_divide_less_eq mult_strict_left_mono)
```
```  1540     done
```
```  1541   show ?cth unfolding homeomorphic_minimal
```
```  1542     apply(rule_tac x="\<lambda>x. b + (e/d) *\<^sub>R (x - a)" in exI)
```
```  1543     apply(rule_tac x="\<lambda>x. a + (d/e) *\<^sub>R (x - b)" in exI)
```
```  1544     using assms
```
```  1545     apply (auto intro!: continuous_intros
```
```  1546       simp: dist_commute dist_norm pos_divide_le_eq mult_strict_left_mono)
```
```  1547     done
```
```  1548 qed
```
```  1549
```
```  1550 lemma homeomorphic_spheres:
```
```  1551   fixes a b ::"'a::real_normed_vector"
```
```  1552   assumes "0 < d"  "0 < e"
```
```  1553   shows "(sphere a d) homeomorphic (sphere b e)"
```
```  1554 unfolding homeomorphic_minimal
```
```  1555     apply(rule_tac x="\<lambda>x. b + (e/d) *\<^sub>R (x - a)" in exI)
```
```  1556     apply(rule_tac x="\<lambda>x. a + (d/e) *\<^sub>R (x - b)" in exI)
```
```  1557     using assms
```
```  1558     apply (auto intro!: continuous_intros
```
```  1559       simp: dist_commute dist_norm pos_divide_less_eq mult_strict_left_mono)
```
```  1560     done
```
```  1561
```
```  1562 lemma homeomorphic_ball01_UNIV:
```
```  1563   "ball (0::'a::real_normed_vector) 1 homeomorphic (UNIV:: 'a set)"
```
```  1564   (is "?B homeomorphic ?U")
```
```  1565 proof
```
```  1566   have "x \<in> (\<lambda>z. z /\<^sub>R (1 - norm z)) ` ball 0 1" for x::'a
```
```  1567     apply (rule_tac x="x /\<^sub>R (1 + norm x)" in image_eqI)
```
```  1568      apply (auto simp: divide_simps)
```
```  1569     using norm_ge_zero [of x] apply linarith+
```
```  1570     done
```
```  1571   then show "(\<lambda>z::'a. z /\<^sub>R (1 - norm z)) ` ?B = ?U"
```
```  1572     by blast
```
```  1573   have "x \<in> range (\<lambda>z. (1 / (1 + norm z)) *\<^sub>R z)" if "norm x < 1" for x::'a
```
```  1574     apply (rule_tac x="x /\<^sub>R (1 - norm x)" in image_eqI)
```
```  1575     using that apply (auto simp: divide_simps)
```
```  1576     done
```
```  1577   then show "(\<lambda>z::'a. z /\<^sub>R (1 + norm z)) ` ?U = ?B"
```
```  1578     by (force simp: divide_simps dest: add_less_zeroD)
```
```  1579   show "continuous_on (ball 0 1) (\<lambda>z. z /\<^sub>R (1 - norm z))"
```
```  1580     by (rule continuous_intros | force)+
```
```  1581   show "continuous_on UNIV (\<lambda>z. z /\<^sub>R (1 + norm z))"
```
```  1582     apply (intro continuous_intros)
```
```  1583     apply (metis le_add_same_cancel1 norm_ge_zero not_le zero_less_one)
```
```  1584     done
```
```  1585   show "\<And>x. x \<in> ball 0 1 \<Longrightarrow>
```
```  1586          x /\<^sub>R (1 - norm x) /\<^sub>R (1 + norm (x /\<^sub>R (1 - norm x))) = x"
```
```  1587     by (auto simp: divide_simps)
```
```  1588   show "\<And>y. y /\<^sub>R (1 + norm y) /\<^sub>R (1 - norm (y /\<^sub>R (1 + norm y))) = y"
```
```  1589     apply (auto simp: divide_simps)
```
```  1590     apply (metis le_add_same_cancel1 norm_ge_zero not_le zero_less_one)
```
```  1591     done
```
```  1592 qed
```
```  1593
```
```  1594 proposition homeomorphic_ball_UNIV:
```
```  1595   fixes a ::"'a::real_normed_vector"
```
```  1596   assumes "0 < r" shows "ball a r homeomorphic (UNIV:: 'a set)"
```
```  1597   using assms homeomorphic_ball01_UNIV homeomorphic_balls(1) homeomorphic_trans zero_less_one by blast
```
```  1598
```
```  1599
```
```  1600 subsection%unimportant \<open>Discrete\<close>
```
```  1601
```
```  1602 lemma finite_implies_discrete:
```
```  1603   fixes S :: "'a::topological_space set"
```
```  1604   assumes "finite (f ` S)"
```
```  1605   shows "(\<forall>x \<in> S. \<exists>e>0. \<forall>y. y \<in> S \<and> f y \<noteq> f x \<longrightarrow> e \<le> norm (f y - f x))"
```
```  1606 proof -
```
```  1607   have "\<exists>e>0. \<forall>y. y \<in> S \<and> f y \<noteq> f x \<longrightarrow> e \<le> norm (f y - f x)" if "x \<in> S" for x
```
```  1608   proof (cases "f ` S - {f x} = {}")
```
```  1609     case True
```
```  1610     with zero_less_numeral show ?thesis
```
```  1611       by (fastforce simp add: Set.image_subset_iff cong: conj_cong)
```
```  1612   next
```
```  1613     case False
```
```  1614     then obtain z where z: "z \<in> S" "f z \<noteq> f x"
```
```  1615       by blast
```
```  1616     have finn: "finite {norm (z - f x) |z. z \<in> f ` S - {f x}}"
```
```  1617       using assms by simp
```
```  1618     then have *: "0 < Inf{norm(z - f x) | z. z \<in> f ` S - {f x}}"
```
```  1619       apply (rule finite_imp_less_Inf)
```
```  1620       using z apply force+
```
```  1621       done
```
```  1622     show ?thesis
```
```  1623       by (force intro!: * cInf_le_finite [OF finn])
```
```  1624   qed
```
```  1625   with assms show ?thesis
```
```  1626     by blast
```
```  1627 qed
```
```  1628
```
```  1629
```
```  1630 subsection%unimportant \<open>Completeness of "Isometry" (up to constant bounds)\<close>
```
```  1631
```
```  1632 lemma cauchy_isometric:\<comment> \<open>TODO: rename lemma to \<open>Cauchy_isometric\<close>\<close>
```
```  1633   assumes e: "e > 0"
```
```  1634     and s: "subspace s"
```
```  1635     and f: "bounded_linear f"
```
```  1636     and normf: "\<forall>x\<in>s. norm (f x) \<ge> e * norm x"
```
```  1637     and xs: "\<forall>n. x n \<in> s"
```
```  1638     and cf: "Cauchy (f \<circ> x)"
```
```  1639   shows "Cauchy x"
```
```  1640 proof -
```
```  1641   interpret f: bounded_linear f by fact
```
```  1642   have "\<exists>N. \<forall>n\<ge>N. norm (x n - x N) < d" if "d > 0" for d :: real
```
```  1643   proof -
```
```  1644     from that obtain N where N: "\<forall>n\<ge>N. norm (f (x n) - f (x N)) < e * d"
```
```  1645       using cf[unfolded Cauchy_def o_def dist_norm, THEN spec[where x="e*d"]] e
```
```  1646       by auto
```
```  1647     have "norm (x n - x N) < d" if "n \<ge> N" for n
```
```  1648     proof -
```
```  1649       have "e * norm (x n - x N) \<le> norm (f (x n - x N))"
```
```  1650         using subspace_diff[OF s, of "x n" "x N"]
```
```  1651         using xs[THEN spec[where x=N]] and xs[THEN spec[where x=n]]
```
```  1652         using normf[THEN bspec[where x="x n - x N"]]
```
```  1653         by auto
```
```  1654       also have "norm (f (x n - x N)) < e * d"
```
```  1655         using \<open>N \<le> n\<close> N unfolding f.diff[symmetric] by auto
```
```  1656       finally show ?thesis
```
```  1657         using \<open>e>0\<close> by simp
```
```  1658     qed
```
```  1659     then show ?thesis by auto
```
```  1660   qed
```
```  1661   then show ?thesis
```
```  1662     by (simp add: Cauchy_altdef2 dist_norm)
```
```  1663 qed
```
```  1664
```
```  1665 lemma complete_isometric_image:
```
```  1666   assumes "0 < e"
```
```  1667     and s: "subspace s"
```
```  1668     and f: "bounded_linear f"
```
```  1669     and normf: "\<forall>x\<in>s. norm(f x) \<ge> e * norm(x)"
```
```  1670     and cs: "complete s"
```
```  1671   shows "complete (f ` s)"
```
```  1672 proof -
```
```  1673   have "\<exists>l\<in>f ` s. (g \<longlongrightarrow> l) sequentially"
```
```  1674     if as:"\<forall>n::nat. g n \<in> f ` s" and cfg:"Cauchy g" for g
```
```  1675   proof -
```
```  1676     from that obtain x where "\<forall>n. x n \<in> s \<and> g n = f (x n)"
```
```  1677       using choice[of "\<lambda> n xa. xa \<in> s \<and> g n = f xa"] by auto
```
```  1678     then have x: "\<forall>n. x n \<in> s" "\<forall>n. g n = f (x n)" by auto
```
```  1679     then have "f \<circ> x = g" by (simp add: fun_eq_iff)
```
```  1680     then obtain l where "l\<in>s" and l:"(x \<longlongrightarrow> l) sequentially"
```
```  1681       using cs[unfolded complete_def, THEN spec[where x=x]]
```
```  1682       using cauchy_isometric[OF \<open>0 < e\<close> s f normf] and cfg and x(1)
```
```  1683       by auto
```
```  1684     then show ?thesis
```
```  1685       using linear_continuous_at[OF f, unfolded continuous_at_sequentially, THEN spec[where x=x], of l]
```
```  1686       by (auto simp: \<open>f \<circ> x = g\<close>)
```
```  1687   qed
```
```  1688   then show ?thesis
```
```  1689     unfolding complete_def by auto
```
```  1690 qed
```
```  1691
```
```  1692 subsection \<open>Connected Normed Spaces\<close>
```
```  1693
```
```  1694 lemma compact_components:
```
```  1695   fixes s :: "'a::heine_borel set"
```
```  1696   shows "\<lbrakk>compact s; c \<in> components s\<rbrakk> \<Longrightarrow> compact c"
```
```  1697 by (meson bounded_subset closed_components in_components_subset compact_eq_bounded_closed)
```
```  1698
```
```  1699 lemma discrete_subset_disconnected:
```
```  1700   fixes S :: "'a::topological_space set"
```
```  1701   fixes t :: "'b::real_normed_vector set"
```
```  1702   assumes conf: "continuous_on S f"
```
```  1703       and no: "\<And>x. x \<in> S \<Longrightarrow> \<exists>e>0. \<forall>y. y \<in> S \<and> f y \<noteq> f x \<longrightarrow> e \<le> norm (f y - f x)"
```
```  1704    shows "f ` S \<subseteq> {y. connected_component_set (f ` S) y = {y}}"
```
```  1705 proof -
```
```  1706   { fix x assume x: "x \<in> S"
```
```  1707     then obtain e where "e>0" and ele: "\<And>y. \<lbrakk>y \<in> S; f y \<noteq> f x\<rbrakk> \<Longrightarrow> e \<le> norm (f y - f x)"
```
```  1708       using conf no [OF x] by auto
```
```  1709     then have e2: "0 \<le> e / 2"
```
```  1710       by simp
```
```  1711     have "f y = f x" if "y \<in> S" and ccs: "f y \<in> connected_component_set (f ` S) (f x)" for y
```
```  1712       apply (rule ccontr)
```
```  1713       using connected_closed [of "connected_component_set (f ` S) (f x)"] \<open>e>0\<close>
```
```  1714       apply (simp add: del: ex_simps)
```
```  1715       apply (drule spec [where x="cball (f x) (e / 2)"])
```
```  1716       apply (drule spec [where x="- ball(f x) e"])
```
```  1717       apply (auto simp: dist_norm open_closed [symmetric] simp del: le_divide_eq_numeral1 dest!: connected_component_in)
```
```  1718         apply (metis diff_self e2 ele norm_minus_commute norm_zero not_less)
```
```  1719        using centre_in_cball connected_component_refl_eq e2 x apply blast
```
```  1720       using ccs
```
```  1721       apply (force simp: cball_def dist_norm norm_minus_commute dest: ele [OF \<open>y \<in> S\<close>])
```
```  1722       done
```
```  1723     moreover have "connected_component_set (f ` S) (f x) \<subseteq> f ` S"
```
```  1724       by (auto simp: connected_component_in)
```
```  1725     ultimately have "connected_component_set (f ` S) (f x) = {f x}"
```
```  1726       by (auto simp: x)
```
```  1727   }
```
```  1728   with assms show ?thesis
```
```  1729     by blast
```
```  1730 qed
```
```  1731
```
```  1732 lemma continuous_disconnected_range_constant_eq:
```
```  1733       "(connected S \<longleftrightarrow>
```
```  1734            (\<forall>f::'a::topological_space \<Rightarrow> 'b::real_normed_algebra_1.
```
```  1735             \<forall>t. continuous_on S f \<and> f ` S \<subseteq> t \<and> (\<forall>y \<in> t. connected_component_set t y = {y})
```
```  1736             \<longrightarrow> f constant_on S))" (is ?thesis1)
```
```  1737   and continuous_discrete_range_constant_eq:
```
```  1738       "(connected S \<longleftrightarrow>
```
```  1739          (\<forall>f::'a::topological_space \<Rightarrow> 'b::real_normed_algebra_1.
```
```  1740           continuous_on S f \<and>
```
```  1741           (\<forall>x \<in> S. \<exists>e. 0 < e \<and> (\<forall>y. y \<in> S \<and> (f y \<noteq> f x) \<longrightarrow> e \<le> norm(f y - f x)))
```
```  1742           \<longrightarrow> f constant_on S))" (is ?thesis2)
```
```  1743   and continuous_finite_range_constant_eq:
```
```  1744       "(connected S \<longleftrightarrow>
```
```  1745          (\<forall>f::'a::topological_space \<Rightarrow> 'b::real_normed_algebra_1.
```
```  1746           continuous_on S f \<and> finite (f ` S)
```
```  1747           \<longrightarrow> f constant_on S))" (is ?thesis3)
```
```  1748 proof -
```
```  1749   have *: "\<And>s t u v. \<lbrakk>s \<Longrightarrow> t; t \<Longrightarrow> u; u \<Longrightarrow> v; v \<Longrightarrow> s\<rbrakk>
```
```  1750     \<Longrightarrow> (s \<longleftrightarrow> t) \<and> (s \<longleftrightarrow> u) \<and> (s \<longleftrightarrow> v)"
```
```  1751     by blast
```
```  1752   have "?thesis1 \<and> ?thesis2 \<and> ?thesis3"
```
```  1753     apply (rule *)
```
```  1754     using continuous_disconnected_range_constant apply metis
```
```  1755     apply clarify
```
```  1756     apply (frule discrete_subset_disconnected; blast)
```
```  1757     apply (blast dest: finite_implies_discrete)
```
```  1758     apply (blast intro!: finite_range_constant_imp_connected)
```
```  1759     done
```
```  1760   then show ?thesis1 ?thesis2 ?thesis3
```
```  1761     by blast+
```
```  1762 qed
```
```  1763
```
```  1764 lemma continuous_discrete_range_constant:
```
```  1765   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_algebra_1"
```
```  1766   assumes S: "connected S"
```
```  1767       and "continuous_on S f"
```
```  1768       and "\<And>x. x \<in> S \<Longrightarrow> \<exists>e>0. \<forall>y. y \<in> S \<and> f y \<noteq> f x \<longrightarrow> e \<le> norm (f y - f x)"
```
```  1769     shows "f constant_on S"
```
```  1770   using continuous_discrete_range_constant_eq [THEN iffD1, OF S] assms by blast
```
```  1771
```
```  1772 lemma continuous_finite_range_constant:
```
```  1773   fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_algebra_1"
```
```  1774   assumes "connected S"
```
```  1775       and "continuous_on S f"
```
```  1776       and "finite (f ` S)"
```
```  1777     shows "f constant_on S"
```
```  1778   using assms continuous_finite_range_constant_eq  by blast
```
```  1779
```
```  1780
```
`  1781 end`