src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy
changeset 36362 06475a1547cb
parent 36360 9d8f7efd9289
child 36365 18bf20d0c2df
equal deleted inserted replaced
36361:1debc8e29f6a 36362:06475a1547cb
    46   fixes U :: "'a topology"
    46   fixes U :: "'a topology"
    47   shows "openin U {}"
    47   shows "openin U {}"
    48   "\<And>S T. openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S\<inter>T)"
    48   "\<And>S T. openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S\<inter>T)"
    49   "\<And>K. (\<forall>S \<in> K. openin U S) \<Longrightarrow> openin U (\<Union>K)"
    49   "\<And>K. (\<forall>S \<in> K. openin U S) \<Longrightarrow> openin U (\<Union>K)"
    50   using openin[of U] unfolding istopology_def Collect_def mem_def
    50   using openin[of U] unfolding istopology_def Collect_def mem_def
    51   by (metis mem_def subset_eq)+
    51   unfolding subset_eq Ball_def mem_def by auto
    52 
    52 
    53 lemma openin_subset[intro]: "openin U S \<Longrightarrow> S \<subseteq> topspace U"
    53 lemma openin_subset[intro]: "openin U S \<Longrightarrow> S \<subseteq> topspace U"
    54   unfolding topspace_def by blast
    54   unfolding topspace_def by blast
    55 lemma openin_empty[simp]: "openin U {}" by (simp add: openin_clauses)
    55 lemma openin_empty[simp]: "openin U {}" by (simp add: openin_clauses)
    56 
    56 
    57 lemma openin_Int[intro]: "openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S \<inter> T)"
    57 lemma openin_Int[intro]: "openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S \<inter> T)"
    58   by (simp add: openin_clauses)
    58   using openin_clauses by simp
    59 
    59 
    60 lemma openin_Union[intro]: "(\<forall>S \<in>K. openin U S) \<Longrightarrow> openin U (\<Union> K)" by (simp add: openin_clauses)
    60 lemma openin_Union[intro]: "(\<forall>S \<in>K. openin U S) \<Longrightarrow> openin U (\<Union> K)"
       
    61   using openin_clauses by simp
    61 
    62 
    62 lemma openin_Un[intro]: "openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S \<union> T)"
    63 lemma openin_Un[intro]: "openin U S \<Longrightarrow> openin U T \<Longrightarrow> openin U (S \<union> T)"
    63   using openin_Union[of "{S,T}" U] by auto
    64   using openin_Union[of "{S,T}" U] by auto
    64 
    65 
    65 lemma openin_topspace[intro, simp]: "openin U (topspace U)" by (simp add: openin_Union topspace_def)
    66 lemma openin_topspace[intro, simp]: "openin U (topspace U)" by (simp add: openin_Union topspace_def)
   944 
   945 
   945 lemma frontier_subset_closed: "closed S \<Longrightarrow> frontier S \<subseteq> S"
   946 lemma frontier_subset_closed: "closed S \<Longrightarrow> frontier S \<subseteq> S"
   946   by (metis frontier_def closure_closed Diff_subset)
   947   by (metis frontier_def closure_closed Diff_subset)
   947 
   948 
   948 lemma frontier_empty[simp]: "frontier {} = {}"
   949 lemma frontier_empty[simp]: "frontier {} = {}"
   949   by (simp add: frontier_def closure_empty)
   950   by (simp add: frontier_def)
   950 
   951 
   951 lemma frontier_subset_eq: "frontier S \<subseteq> S \<longleftrightarrow> closed S"
   952 lemma frontier_subset_eq: "frontier S \<subseteq> S \<longleftrightarrow> closed S"
   952 proof-
   953 proof-
   953   { assume "frontier S \<subseteq> S"
   954   { assume "frontier S \<subseteq> S"
   954     hence "closure S \<subseteq> S" using interior_subset unfolding frontier_def by auto
   955     hence "closure S \<subseteq> S" using interior_subset unfolding frontier_def by auto
   955     hence "closed S" using closure_subset_eq by auto
   956     hence "closed S" using closure_subset_eq by auto
   956   }
   957   }
   957   thus ?thesis using frontier_subset_closed[of S] by auto
   958   thus ?thesis using frontier_subset_closed[of S] ..
   958 qed
   959 qed
   959 
   960 
   960 lemma frontier_complement: "frontier(- S) = frontier S"
   961 lemma frontier_complement: "frontier(- S) = frontier S"
   961   by (auto simp add: frontier_def closure_complement interior_complement)
   962   by (auto simp add: frontier_def closure_complement interior_complement)
   962 
   963 
  1586 
  1587 
  1587 text{* A congruence rule allowing us to transform limits assuming not at point. *}
  1588 text{* A congruence rule allowing us to transform limits assuming not at point. *}
  1588 
  1589 
  1589 (* FIXME: Only one congruence rule for tendsto can be used at a time! *)
  1590 (* FIXME: Only one congruence rule for tendsto can be used at a time! *)
  1590 
  1591 
  1591 lemma Lim_cong_within[cong add]:
  1592 lemma Lim_cong_within(*[cong add]*):
  1592   fixes a :: "'a::metric_space"
  1593   fixes a :: "'a::metric_space"
  1593   fixes l :: "'b::metric_space" (* TODO: generalize *)
  1594   fixes l :: "'b::metric_space" (* TODO: generalize *)
  1594   shows "(\<And>x. x \<noteq> a \<Longrightarrow> f x = g x) ==> ((\<lambda>x. f x) ---> l) (at a within S) \<longleftrightarrow> ((g ---> l) (at a within S))"
  1595   shows "(\<And>x. x \<noteq> a \<Longrightarrow> f x = g x) ==> ((\<lambda>x. f x) ---> l) (at a within S) \<longleftrightarrow> ((g ---> l) (at a within S))"
  1595   by (simp add: Lim_within dist_nz[symmetric])
  1596   by (simp add: Lim_within dist_nz[symmetric])
  1596 
  1597 
  1665 lemma seq_harmonic: "((\<lambda>n. inverse (real n)) ---> 0) sequentially"
  1666 lemma seq_harmonic: "((\<lambda>n. inverse (real n)) ---> 0) sequentially"
  1666 proof-
  1667 proof-
  1667   { fix e::real assume "e>0"
  1668   { fix e::real assume "e>0"
  1668     hence "\<exists>N::nat. \<forall>n::nat\<ge>N. inverse (real n) < e"
  1669     hence "\<exists>N::nat. \<forall>n::nat\<ge>N. inverse (real n) < e"
  1669       using real_arch_inv[of e] apply auto apply(rule_tac x=n in exI)
  1670       using real_arch_inv[of e] apply auto apply(rule_tac x=n in exI)
  1670       by (metis not_le le_imp_inverse_le not_less real_of_nat_gt_zero_cancel_iff real_of_nat_less_iff xt1(7))
  1671       by (metis le_imp_inverse_le not_less real_of_nat_gt_zero_cancel_iff real_of_nat_less_iff xt1(7))
  1671   }
  1672   }
  1672   thus ?thesis unfolding Lim_sequentially dist_norm by simp
  1673   thus ?thesis unfolding Lim_sequentially dist_norm by simp
  1673 qed
  1674 qed
  1674 
  1675 
  1675 text{* More properties of closed balls. *}
  1676 text{* More properties of closed balls. *}
  1700 
  1701 
  1701 lemma mem_interior_cball: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S)"
  1702 lemma mem_interior_cball: "x \<in> interior S \<longleftrightarrow> (\<exists>e>0. cball x e \<subseteq> S)"
  1702   apply (simp add: interior_def, safe)
  1703   apply (simp add: interior_def, safe)
  1703   apply (force simp add: open_contains_cball)
  1704   apply (force simp add: open_contains_cball)
  1704   apply (rule_tac x="ball x e" in exI)
  1705   apply (rule_tac x="ball x e" in exI)
  1705   apply (simp add: open_ball centre_in_ball subset_trans [OF ball_subset_cball])
  1706   apply (simp add: subset_trans [OF ball_subset_cball])
  1706   done
  1707   done
  1707 
  1708 
  1708 lemma islimpt_ball:
  1709 lemma islimpt_ball:
  1709   fixes x y :: "'a::{real_normed_vector,perfect_space}"
  1710   fixes x y :: "'a::{real_normed_vector,perfect_space}"
  1710   shows "y islimpt ball x e \<longleftrightarrow> 0 < e \<and> y \<in> cball x e" (is "?lhs = ?rhs")
  1711   shows "y islimpt ball x e \<longleftrightarrow> 0 < e \<and> y \<in> cball x e" (is "?lhs = ?rhs")
  1875 qed
  1876 qed
  1876 
  1877 
  1877 lemma frontier_ball:
  1878 lemma frontier_ball:
  1878   fixes a :: "'a::real_normed_vector"
  1879   fixes a :: "'a::real_normed_vector"
  1879   shows "0 < e ==> frontier(ball a e) = {x. dist a x = e}"
  1880   shows "0 < e ==> frontier(ball a e) = {x. dist a x = e}"
  1880   apply (simp add: frontier_def closure_ball interior_open open_ball order_less_imp_le)
  1881   apply (simp add: frontier_def closure_ball interior_open order_less_imp_le)
  1881   apply (simp add: expand_set_eq)
  1882   apply (simp add: expand_set_eq)
  1882   by arith
  1883   by arith
  1883 
  1884 
  1884 lemma frontier_cball:
  1885 lemma frontier_cball:
  1885   fixes a :: "'a::{real_normed_vector, perfect_space}"
  1886   fixes a :: "'a::{real_normed_vector, perfect_space}"
  1886   shows "frontier(cball a e) = {x. dist a x = e}"
  1887   shows "frontier(cball a e) = {x. dist a x = e}"
  1887   apply (simp add: frontier_def interior_cball closed_cball closure_closed order_less_imp_le)
  1888   apply (simp add: frontier_def interior_cball closed_cball order_less_imp_le)
  1888   apply (simp add: expand_set_eq)
  1889   apply (simp add: expand_set_eq)
  1889   by arith
  1890   by arith
  1890 
  1891 
  1891 lemma cball_eq_empty: "(cball x e = {}) \<longleftrightarrow> e < 0"
  1892 lemma cball_eq_empty: "(cball x e = {}) \<longleftrightarrow> e < 0"
  1892   apply (simp add: expand_set_eq not_le)
  1893   apply (simp add: expand_set_eq not_le)
  2002   done
  2003   done
  2003 
  2004 
  2004 lemma bounded_ball[simp,intro]: "bounded(ball x e)"
  2005 lemma bounded_ball[simp,intro]: "bounded(ball x e)"
  2005   by (metis ball_subset_cball bounded_cball bounded_subset)
  2006   by (metis ball_subset_cball bounded_cball bounded_subset)
  2006 
  2007 
  2007 lemma finite_imp_bounded[intro]: assumes "finite S" shows "bounded S"
  2008 lemma finite_imp_bounded[intro]:
  2008 proof-
  2009   fixes S :: "'a::metric_space set" assumes "finite S" shows "bounded S"
  2009   { fix a F assume as:"bounded F"
  2010 proof-
       
  2011   { fix a and F :: "'a set" assume as:"bounded F"
  2010     then obtain x e where "\<forall>y\<in>F. dist x y \<le> e" unfolding bounded_def by auto
  2012     then obtain x e where "\<forall>y\<in>F. dist x y \<le> e" unfolding bounded_def by auto
  2011     hence "\<forall>y\<in>(insert a F). dist x y \<le> max e (dist x a)" by auto
  2013     hence "\<forall>y\<in>(insert a F). dist x y \<le> max e (dist x a)" by auto
  2012     hence "bounded (insert a F)" unfolding bounded_def by (intro exI)
  2014     hence "bounded (insert a F)" unfolding bounded_def by (intro exI)
  2013   }
  2015   }
  2014   thus ?thesis using finite_induct[of S bounded]  using bounded_empty assms by auto
  2016   thus ?thesis using finite_induct[of S bounded]  using bounded_empty assms by auto
  2214 apply (rule def_nat_rec_0, simp)
  2216 apply (rule def_nat_rec_0, simp)
  2215 apply (rule allI, rule def_nat_rec_Suc, simp)
  2217 apply (rule allI, rule def_nat_rec_Suc, simp)
  2216 apply (rule allI, rule impI, rule ext)
  2218 apply (rule allI, rule impI, rule ext)
  2217 apply (erule conjE)
  2219 apply (erule conjE)
  2218 apply (induct_tac x)
  2220 apply (induct_tac x)
  2219 apply (simp add: nat_rec_0)
  2221 apply simp
  2220 apply (erule_tac x="n" in allE)
  2222 apply (erule_tac x="n" in allE)
  2221 apply (simp)
  2223 apply (simp)
  2222 done
  2224 done
  2223 
  2225 
  2224 lemma convergent_bounded_increasing: fixes s ::"nat\<Rightarrow>real"
  2226 lemma convergent_bounded_increasing: fixes s ::"nat\<Rightarrow>real"
  2646     using assms(1)[THEN spec[where x="{t. \<exists>x. x\<in>s \<and> t = f x}"]] using f by auto
  2648     using assms(1)[THEN spec[where x="{t. \<exists>x. x\<in>s \<and> t = f x}"]] using f by auto
  2647   from g(1,3) have g':"\<forall>x\<in>g. \<exists>xa \<in> s. x = f xa" by auto
  2649   from g(1,3) have g':"\<forall>x\<in>g. \<exists>xa \<in> s. x = f xa" by auto
  2648   { fix x y assume "x\<in>t" "y\<in>t" "f x = f y"
  2650   { fix x y assume "x\<in>t" "y\<in>t" "f x = f y"
  2649     hence "x \<in> f x"  "y \<in> f x \<longrightarrow> y = x" using f[THEN bspec[where x=x]] and `t\<subseteq>s` by auto
  2651     hence "x \<in> f x"  "y \<in> f x \<longrightarrow> y = x" using f[THEN bspec[where x=x]] and `t\<subseteq>s` by auto
  2650     hence "x = y" using `f x = f y` and f[THEN bspec[where x=y]] and `y\<in>t` and `t\<subseteq>s` by auto  }
  2652     hence "x = y" using `f x = f y` and f[THEN bspec[where x=y]] and `y\<in>t` and `t\<subseteq>s` by auto  }
  2651   hence "infinite (f ` t)" using assms(2) using finite_imageD[unfolded inj_on_def, of f t] by auto
  2653   hence "inj_on f t" unfolding inj_on_def by simp
       
  2654   hence "infinite (f ` t)" using assms(2) using finite_imageD by auto
  2652   moreover
  2655   moreover
  2653   { fix x assume "x\<in>t" "f x \<notin> g"
  2656   { fix x assume "x\<in>t" "f x \<notin> g"
  2654     from g(3) assms(3) `x\<in>t` obtain h where "h\<in>g" and "x\<in>h" by auto
  2657     from g(3) assms(3) `x\<in>t` obtain h where "h\<in>g" and "x\<in>h" by auto
  2655     then obtain y where "y\<in>s" "h = f y" using g'[THEN bspec[where x=h]] by auto
  2658     then obtain y where "y\<in>s" "h = f y" using g'[THEN bspec[where x=h]] by auto
  2656     hence "y = x" using f[THEN bspec[where x=y]] and `x\<in>t` and `x\<in>h`[unfolded `h = f y`] by auto
  2659     hence "y = x" using f[THEN bspec[where x=y]] and `x\<in>t` and `x\<in>h`[unfolded `h = f y`] by auto
  3141   { fix e::real assume "e>0"
  3144   { fix e::real assume "e>0"
  3142     then obtain d where d: "d>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e"
  3145     then obtain d where d: "d>0" "\<forall>xa\<in>s. 0 < dist xa x \<and> dist xa x < d \<longrightarrow> dist (f xa) (f x) < e"
  3143       using `?lhs`[unfolded continuous_within Lim_within] by auto
  3146       using `?lhs`[unfolded continuous_within Lim_within] by auto
  3144     { fix y assume "y\<in>f ` (ball x d \<inter> s)"
  3147     { fix y assume "y\<in>f ` (ball x d \<inter> s)"
  3145       hence "y \<in> ball (f x) e" using d(2) unfolding dist_nz[THEN sym]
  3148       hence "y \<in> ball (f x) e" using d(2) unfolding dist_nz[THEN sym]
  3146         apply (auto simp add: dist_commute mem_ball) apply(erule_tac x=xa in ballE) apply auto using `e>0` by auto
  3149         apply (auto simp add: dist_commute) apply(erule_tac x=xa in ballE) apply auto using `e>0` by auto
  3147     }
  3150     }
  3148     hence "\<exists>d>0. f ` (ball x d \<inter> s) \<subseteq> ball (f x) e" using `d>0` unfolding subset_eq ball_def by (auto simp add: dist_commute)  }
  3151     hence "\<exists>d>0. f ` (ball x d \<inter> s) \<subseteq> ball (f x) e" using `d>0` unfolding subset_eq ball_def by (auto simp add: dist_commute)  }
  3149   thus ?rhs by auto
  3152   thus ?rhs by auto
  3150 next
  3153 next
  3151   assume ?rhs thus ?lhs unfolding continuous_within Lim_within ball_def subset_eq
  3154   assume ?rhs thus ?lhs unfolding continuous_within Lim_within ball_def subset_eq
  3873 
  3876 
  3874 lemma continuous_levelset_open:
  3877 lemma continuous_levelset_open:
  3875   fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* TODO: generalize *)
  3878   fixes f :: "'a::metric_space \<Rightarrow> 'b::metric_space" (* TODO: generalize *)
  3876   assumes "connected s"  "continuous_on s f"  "open {x \<in> s. f x = a}"  "\<exists>x \<in> s.  f x = a"
  3879   assumes "connected s"  "continuous_on s f"  "open {x \<in> s. f x = a}"  "\<exists>x \<in> s.  f x = a"
  3877   shows "\<forall>x \<in> s. f x = a"
  3880   shows "\<forall>x \<in> s. f x = a"
  3878 using continuous_levelset_open_in[OF assms(1,2), of a, unfolded openin_open] using assms (3,4) by auto
  3881 using continuous_levelset_open_in[OF assms(1,2), of a, unfolded openin_open] using assms (3,4) by fast
  3879 
  3882 
  3880 text{* Some arithmetical combinations (more to prove).                           *}
  3883 text{* Some arithmetical combinations (more to prove).                           *}
  3881 
  3884 
  3882 lemma open_scaling[intro]:
  3885 lemma open_scaling[intro]:
  3883   fixes s :: "'a::real_normed_vector set"
  3886   fixes s :: "'a::real_normed_vector set"
  4385     ultimately have "fstcart l \<in> s" "sndcart l \<in> t"
  4388     ultimately have "fstcart l \<in> s" "sndcart l \<in> t"
  4386       using assms(1)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. fstcart (x n)"], THEN spec[where x="fstcart l"]]
  4389       using assms(1)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. fstcart (x n)"], THEN spec[where x="fstcart l"]]
  4387       using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. sndcart (x n)"], THEN spec[where x="sndcart l"]]
  4390       using assms(2)[unfolded closed_sequential_limits, THEN spec[where x="\<lambda>n. sndcart (x n)"], THEN spec[where x="sndcart l"]]
  4388       unfolding Lim_sequentially by auto
  4391       unfolding Lim_sequentially by auto
  4389     hence "l \<in> {pastecart x y |x y. x \<in> s \<and> y \<in> t}" apply- unfolding mem_Collect_eq apply(rule_tac x="fstcart l" in exI,rule_tac x="sndcart l" in exI) by auto }
  4392     hence "l \<in> {pastecart x y |x y. x \<in> s \<and> y \<in> t}" apply- unfolding mem_Collect_eq apply(rule_tac x="fstcart l" in exI,rule_tac x="sndcart l" in exI) by auto }
  4390   thus ?thesis unfolding closed_sequential_limits by auto
  4393   thus ?thesis unfolding closed_sequential_limits by blast
  4391 qed
  4394 qed
  4392 
  4395 
  4393 lemma compact_pastecart:
  4396 lemma compact_pastecart:
  4394   fixes s t :: "(real ^ _) set"
  4397   fixes s t :: "(real ^ _) set"
  4395   shows "compact s \<Longrightarrow> compact t ==> compact {pastecart x y | x y . x \<in> s \<and> y \<in> t}"
  4398   shows "compact s \<Longrightarrow> compact t ==> compact {pastecart x y | x y . x \<in> s \<and> y \<in> t}"
  4476   shows "\<exists>x\<in>s. \<exists>y\<in>s. \<forall>u\<in>s. \<forall>v\<in>s. norm(u - v) \<le> norm(x - y)"
  4479   shows "\<exists>x\<in>s. \<exists>y\<in>s. \<forall>u\<in>s. \<forall>v\<in>s. norm(u - v) \<le> norm(x - y)"
  4477 proof-
  4480 proof-
  4478   have "{x - y | x y . x\<in>s \<and> y\<in>s} \<noteq> {}" using `s \<noteq> {}` by auto
  4481   have "{x - y | x y . x\<in>s \<and> y\<in>s} \<noteq> {}" using `s \<noteq> {}` by auto
  4479   then obtain x where x:"x\<in>{x - y |x y. x \<in> s \<and> y \<in> s}"  "\<forall>y\<in>{x - y |x y. x \<in> s \<and> y \<in> s}. norm y \<le> norm x"
  4482   then obtain x where x:"x\<in>{x - y |x y. x \<in> s \<and> y \<in> s}"  "\<forall>y\<in>{x - y |x y. x \<in> s \<and> y \<in> s}. norm y \<le> norm x"
  4480     using compact_differences[OF assms(1) assms(1)]
  4483     using compact_differences[OF assms(1) assms(1)]
  4481     using distance_attains_sup[where 'a="'a", unfolded dist_norm, of "{x - y | x y . x\<in>s \<and> y\<in>s}" 0] by(auto simp add: norm_minus_cancel)
  4484     using distance_attains_sup[where 'a="'a", unfolded dist_norm, of "{x - y | x y . x\<in>s \<and> y\<in>s}" 0] by auto
  4482   from x(1) obtain a b where "a\<in>s" "b\<in>s" "x = a - b" by auto
  4485   from x(1) obtain a b where "a\<in>s" "b\<in>s" "x = a - b" by auto
  4483   thus ?thesis using x(2)[unfolded `x = a - b`] by blast
  4486   thus ?thesis using x(2)[unfolded `x = a - b`] by blast
  4484 qed
  4487 qed
  4485 
  4488 
  4486 text{* We can state this in terms of diameter of a set.                          *}
  4489 text{* We can state this in terms of diameter of a set.                          *}
  4497   obtain a where a:"\<forall>x\<in>s. norm x \<le> a" using assms[unfolded bounded_iff] by auto
  4500   obtain a where a:"\<forall>x\<in>s. norm x \<le> a" using assms[unfolded bounded_iff] by auto
  4498   { fix x y assume "x \<in> s" "y \<in> s"
  4501   { fix x y assume "x \<in> s" "y \<in> s"
  4499     hence "norm (x - y) \<le> 2 * a" using norm_triangle_ineq[of x "-y", unfolded norm_minus_cancel] a[THEN bspec[where x=x]] a[THEN bspec[where x=y]] by (auto simp add: ring_simps)  }
  4502     hence "norm (x - y) \<le> 2 * a" using norm_triangle_ineq[of x "-y", unfolded norm_minus_cancel] a[THEN bspec[where x=x]] a[THEN bspec[where x=y]] by (auto simp add: ring_simps)  }
  4500   note * = this
  4503   note * = this
  4501   { fix x y assume "x\<in>s" "y\<in>s"  hence "s \<noteq> {}" by auto
  4504   { fix x y assume "x\<in>s" "y\<in>s"  hence "s \<noteq> {}" by auto
  4502     have "norm(x - y) \<le> diameter s" unfolding diameter_def using `s\<noteq>{}` *[OF `x\<in>s` `y\<in>s`] `x\<in>s` `y\<in>s`  
  4505     have "norm(x - y) \<le> diameter s" unfolding diameter_def using `s\<noteq>{}` *[OF `x\<in>s` `y\<in>s`] `x\<in>s` `y\<in>s`
  4503       by simp (blast intro!: Sup_upper *) }
  4506       by simp (blast intro!: Sup_upper *) }
  4504   moreover
  4507   moreover
  4505   { fix d::real assume "d>0" "d < diameter s"
  4508   { fix d::real assume "d>0" "d < diameter s"
  4506     hence "s\<noteq>{}" unfolding diameter_def by auto
  4509     hence "s\<noteq>{}" unfolding diameter_def by auto
  4507     have "\<exists>d' \<in> ?D. d' > d"
  4510     have "\<exists>d' \<in> ?D. d' > d"
  4528   assumes "compact s"  "s \<noteq> {}"
  4531   assumes "compact s"  "s \<noteq> {}"
  4529   shows "\<exists>x\<in>s. \<exists>y\<in>s. (norm(x - y) = diameter s)"
  4532   shows "\<exists>x\<in>s. \<exists>y\<in>s. (norm(x - y) = diameter s)"
  4530 proof-
  4533 proof-
  4531   have b:"bounded s" using assms(1) by (rule compact_imp_bounded)
  4534   have b:"bounded s" using assms(1) by (rule compact_imp_bounded)
  4532   then obtain x y where xys:"x\<in>s" "y\<in>s" and xy:"\<forall>u\<in>s. \<forall>v\<in>s. norm (u - v) \<le> norm (x - y)" using compact_sup_maxdistance[OF assms] by auto
  4535   then obtain x y where xys:"x\<in>s" "y\<in>s" and xy:"\<forall>u\<in>s. \<forall>v\<in>s. norm (u - v) \<le> norm (x - y)" using compact_sup_maxdistance[OF assms] by auto
  4533   hence "diameter s \<le> norm (x - y)" 
  4536   hence "diameter s \<le> norm (x - y)"
  4534     by (force simp add: diameter_def intro!: Sup_least) 
  4537     unfolding diameter_def by clarsimp (rule Sup_least, fast+)
  4535   thus ?thesis
  4538   thus ?thesis
  4536     by (metis b diameter_bounded_bound order_antisym xys) 
  4539     by (metis b diameter_bounded_bound order_antisym xys)
  4537 qed
  4540 qed
  4538 
  4541 
  4539 text{* Related results with closure as the conclusion.                           *}
  4542 text{* Related results with closure as the conclusion.                           *}
  4540 
  4543 
  4541 lemma closed_scaling:
  4544 lemma closed_scaling:
  4720   using interval[of a b] by(auto simp add: expand_set_eq vector_less_def vector_le_def)
  4723   using interval[of a b] by(auto simp add: expand_set_eq vector_less_def vector_le_def)
  4721 
  4724 
  4722 lemma mem_interval_1: fixes x :: "real^1" shows
  4725 lemma mem_interval_1: fixes x :: "real^1" shows
  4723  "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b)"
  4726  "(x \<in> {a .. b} \<longleftrightarrow> dest_vec1 a \<le> dest_vec1 x \<and> dest_vec1 x \<le> dest_vec1 b)"
  4724  "(x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
  4727  "(x \<in> {a<..<b} \<longleftrightarrow> dest_vec1 a < dest_vec1 x \<and> dest_vec1 x < dest_vec1 b)"
  4725 by(simp_all add: Cart_eq vector_less_def vector_le_def forall_1)
  4728 by(simp_all add: Cart_eq vector_less_def vector_le_def)
  4726 
  4729 
  4727 lemma vec1_interval:fixes a::"real" shows
  4730 lemma vec1_interval:fixes a::"real" shows
  4728   "vec1 ` {a .. b} = {vec1 a .. vec1 b}"
  4731   "vec1 ` {a .. b} = {vec1 a .. vec1 b}"
  4729   "vec1 ` {a<..<b} = {vec1 a<..<vec1 b}"
  4732   "vec1 ` {a<..<b} = {vec1 a<..<vec1 b}"
  4730   apply(rule_tac[!] set_ext) unfolding image_iff vector_less_def unfolding mem_interval
  4733   apply(rule_tac[!] set_ext) unfolding image_iff vector_less_def unfolding mem_interval
  4746     let ?x = "(1/2) *\<^sub>R (a + b)"
  4749     let ?x = "(1/2) *\<^sub>R (a + b)"
  4747     { fix i
  4750     { fix i
  4748       have "a$i < b$i" using as[THEN spec[where x=i]] by auto
  4751       have "a$i < b$i" using as[THEN spec[where x=i]] by auto
  4749       hence "a$i < ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i < b$i"
  4752       hence "a$i < ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i < b$i"
  4750         unfolding vector_smult_component and vector_add_component
  4753         unfolding vector_smult_component and vector_add_component
  4751         by (auto simp add: less_divide_eq_number_of1)  }
  4754         by auto  }
  4752     hence "{a <..< b} \<noteq> {}" using mem_interval(1)[of "?x" a b] by auto  }
  4755     hence "{a <..< b} \<noteq> {}" using mem_interval(1)[of "?x" a b] by auto  }
  4753   ultimately show ?th1 by blast
  4756   ultimately show ?th1 by blast
  4754 
  4757 
  4755   { fix i x assume as:"b$i < a$i" and x:"x\<in>{a .. b}"
  4758   { fix i x assume as:"b$i < a$i" and x:"x\<in>{a .. b}"
  4756     hence "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" unfolding mem_interval by auto
  4759     hence "a $ i \<le> x $ i \<and> x $ i \<le> b $ i" unfolding mem_interval by auto
  4761     let ?x = "(1/2) *\<^sub>R (a + b)"
  4764     let ?x = "(1/2) *\<^sub>R (a + b)"
  4762     { fix i
  4765     { fix i
  4763       have "a$i \<le> b$i" using as[THEN spec[where x=i]] by auto
  4766       have "a$i \<le> b$i" using as[THEN spec[where x=i]] by auto
  4764       hence "a$i \<le> ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i \<le> b$i"
  4767       hence "a$i \<le> ((1/2) *\<^sub>R (a+b)) $ i" "((1/2) *\<^sub>R (a+b)) $ i \<le> b$i"
  4765         unfolding vector_smult_component and vector_add_component
  4768         unfolding vector_smult_component and vector_add_component
  4766         by (auto simp add: less_divide_eq_number_of1)  }
  4769         by auto  }
  4767     hence "{a .. b} \<noteq> {}" using mem_interval(2)[of "?x" a b] by auto  }
  4770     hence "{a .. b} \<noteq> {}" using mem_interval(2)[of "?x" a b] by auto  }
  4768   ultimately show ?th2 by blast
  4771   ultimately show ?th2 by blast
  4769 qed
  4772 qed
  4770 
  4773 
  4771 lemma interval_ne_empty: fixes a :: "real^'n" shows
  4774 lemma interval_ne_empty: fixes a :: "real^'n" shows
  4824     { let ?x = "(\<chi> j. (if j=i then ((min (a$j) (d$j))+c$j)/2 else (c$j+d$j)/2))::real^'n"
  4827     { let ?x = "(\<chi> j. (if j=i then ((min (a$j) (d$j))+c$j)/2 else (c$j+d$j)/2))::real^'n"
  4825       assume as2: "a$i > c$i"
  4828       assume as2: "a$i > c$i"
  4826       { fix j
  4829       { fix j
  4827         have "c $ j < ?x $ j \<and> ?x $ j < d $ j" unfolding Cart_lambda_beta
  4830         have "c $ j < ?x $ j \<and> ?x $ j < d $ j" unfolding Cart_lambda_beta
  4828           apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4831           apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4829           by (auto simp add: less_divide_eq_number_of1 as2)  }
  4832           by (auto simp add: as2)  }
  4830       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4833       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4831       moreover
  4834       moreover
  4832       have "?x\<notin>{a .. b}"
  4835       have "?x\<notin>{a .. b}"
  4833         unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4836         unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4834         using as(2)[THEN spec[where x=i]] and as2
  4837         using as(2)[THEN spec[where x=i]] and as2
  4835         by (auto simp add: less_divide_eq_number_of1)
  4838         by auto
  4836       ultimately have False using as by auto  }
  4839       ultimately have False using as by auto  }
  4837     hence "a$i \<le> c$i" by(rule ccontr)auto
  4840     hence "a$i \<le> c$i" by(rule ccontr)auto
  4838     moreover
  4841     moreover
  4839     { let ?x = "(\<chi> j. (if j=i then ((max (b$j) (c$j))+d$j)/2 else (c$j+d$j)/2))::real^'n"
  4842     { let ?x = "(\<chi> j. (if j=i then ((max (b$j) (c$j))+d$j)/2 else (c$j+d$j)/2))::real^'n"
  4840       assume as2: "b$i < d$i"
  4843       assume as2: "b$i < d$i"
  4841       { fix j
  4844       { fix j
  4842         have "d $ j > ?x $ j \<and> ?x $ j > c $ j" unfolding Cart_lambda_beta
  4845         have "d $ j > ?x $ j \<and> ?x $ j > c $ j" unfolding Cart_lambda_beta
  4843           apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4846           apply(cases "j=i") using as(2)[THEN spec[where x=j]]
  4844           by (auto simp add: less_divide_eq_number_of1 as2)  }
  4847           by (auto simp add: as2)  }
  4845       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4848       hence "?x\<in>{c<..<d}" unfolding mem_interval by auto
  4846       moreover
  4849       moreover
  4847       have "?x\<notin>{a .. b}"
  4850       have "?x\<notin>{a .. b}"
  4848         unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4851         unfolding mem_interval apply auto apply(rule_tac x=i in exI)
  4849         using as(2)[THEN spec[where x=i]] and as2
  4852         using as(2)[THEN spec[where x=i]] and as2
  4850         by (auto simp add: less_divide_eq_number_of1)
  4853         by auto
  4851       ultimately have False using as by auto  }
  4854       ultimately have False using as by auto  }
  4852     hence "b$i \<ge> d$i" by(rule ccontr)auto
  4855     hence "b$i \<ge> d$i" by(rule ccontr)auto
  4853     ultimately
  4856     ultimately
  4854     have "a$i \<le> c$i \<and> d$i \<le> b$i" by auto
  4857     have "a$i \<le> c$i \<and> d$i \<le> b$i" by auto
  4855   } note part1 = this
  4858   } note part1 = this
  4876 qed
  4879 qed
  4877 
  4880 
  4878 lemma inter_interval: fixes a :: "'a::linorder^'n" shows
  4881 lemma inter_interval: fixes a :: "'a::linorder^'n" shows
  4879  "{a .. b} \<inter> {c .. d} =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
  4882  "{a .. b} \<inter> {c .. d} =  {(\<chi> i. max (a$i) (c$i)) .. (\<chi> i. min (b$i) (d$i))}"
  4880   unfolding expand_set_eq and Int_iff and mem_interval
  4883   unfolding expand_set_eq and Int_iff and mem_interval
  4881   by (auto simp add: less_divide_eq_number_of1 intro!: bexI)
  4884   by auto
  4882 
  4885 
  4883 (* Moved interval_open_subset_closed a bit upwards *)
  4886 (* Moved interval_open_subset_closed a bit upwards *)
  4884 
  4887 
  4885 lemma open_interval_lemma: fixes x :: "real" shows
  4888 lemma open_interval_lemma: fixes x :: "real" shows
  4886  "a < x \<Longrightarrow> x < b ==> (\<exists>d>0. \<forall>x'. abs(x' - x) < d --> a < x' \<and> x' < b)"
  4889  "a < x \<Longrightarrow> x < b ==> (\<exists>d>0. \<forall>x'. abs(x' - x) < d --> a < x' \<and> x' < b)"
  4916 
  4919 
  4917 lemma open_interval_real[intro]: fixes a :: "real" shows "open {a<..<b}"
  4920 lemma open_interval_real[intro]: fixes a :: "real" shows "open {a<..<b}"
  4918   using open_interval[of "vec1 a" "vec1 b"] unfolding open_contains_ball
  4921   using open_interval[of "vec1 a" "vec1 b"] unfolding open_contains_ball
  4919   apply-apply(rule,erule_tac x="vec1 x" in ballE) apply(erule exE,rule_tac x=e in exI)
  4922   apply-apply(rule,erule_tac x="vec1 x" in ballE) apply(erule exE,rule_tac x=e in exI)
  4920   unfolding subset_eq mem_ball apply(rule) defer apply(rule,erule conjE,erule_tac x="vec1 xa" in ballE)
  4923   unfolding subset_eq mem_ball apply(rule) defer apply(rule,erule conjE,erule_tac x="vec1 xa" in ballE)
  4921   by(auto simp add: vec1_dest_vec1_simps vector_less_def forall_1) 
  4924   by(auto simp add: dist_vec1 dist_real_def vector_less_def)
  4922 
  4925 
  4923 lemma closed_interval[intro]: fixes a :: "real^'n" shows "closed {a .. b}"
  4926 lemma closed_interval[intro]: fixes a :: "real^'n" shows "closed {a .. b}"
  4924 proof-
  4927 proof-
  4925   { fix x i assume as:"\<forall>e>0. \<exists>x'\<in>{a..b}. x' \<noteq> x \<and> dist x' x < e"(* and xab:"a$i > x$i \<or> b$i < x$i"*)
  4928   { fix x i assume as:"\<forall>e>0. \<exists>x'\<in>{a..b}. x' \<noteq> x \<and> dist x' x < e"(* and xab:"a$i > x$i \<or> b$i < x$i"*)
  4926     { assume xa:"a$i > x$i"
  4929     { assume xa:"a$i > x$i"
  4997 proof-
  5000 proof-
  4998   { fix i
  5001   { fix i
  4999     have "a $ i < ((1 / 2) *\<^sub>R (a + b)) $ i \<and> ((1 / 2) *\<^sub>R (a + b)) $ i < b $ i"
  5002     have "a $ i < ((1 / 2) *\<^sub>R (a + b)) $ i \<and> ((1 / 2) *\<^sub>R (a + b)) $ i < b $ i"
  5000       using assms[unfolded interval_ne_empty, THEN spec[where x=i]]
  5003       using assms[unfolded interval_ne_empty, THEN spec[where x=i]]
  5001       unfolding vector_smult_component and vector_add_component
  5004       unfolding vector_smult_component and vector_add_component
  5002       by(auto simp add: less_divide_eq_number_of1)  }
  5005       by auto  }
  5003   thus ?thesis unfolding mem_interval by auto
  5006   thus ?thesis unfolding mem_interval by auto
  5004 qed
  5007 qed
  5005 
  5008 
  5006 lemma open_closed_interval_convex: fixes x :: "real^'n"
  5009 lemma open_closed_interval_convex: fixes x :: "real^'n"
  5007   assumes x:"x \<in> {a<..<b}" and y:"y \<in> {a .. b}" and e:"0 < e" "e \<le> 1"
  5010   assumes x:"x \<in> {a<..<b}" and y:"y \<in> {a .. b}" and e:"0 < e" "e \<le> 1"
  5039       have *:"0 < inverse (real n + 1)" "inverse (real n + 1) \<le> 1" unfolding inverse_le_1_iff by auto
  5042       have *:"0 < inverse (real n + 1)" "inverse (real n + 1) \<le> 1" unfolding inverse_le_1_iff by auto
  5040       have "(inverse (real n + 1)) *\<^sub>R ((1 / 2) *\<^sub>R (a + b)) + (1 - inverse (real n + 1)) *\<^sub>R x =
  5043       have "(inverse (real n + 1)) *\<^sub>R ((1 / 2) *\<^sub>R (a + b)) + (1 - inverse (real n + 1)) *\<^sub>R x =
  5041         x + (inverse (real n + 1)) *\<^sub>R (((1 / 2) *\<^sub>R (a + b)) - x)"
  5044         x + (inverse (real n + 1)) *\<^sub>R (((1 / 2) *\<^sub>R (a + b)) - x)"
  5042         by (auto simp add: algebra_simps)
  5045         by (auto simp add: algebra_simps)
  5043       hence "f n < b" and "a < f n" using open_closed_interval_convex[OF open_interval_midpoint[OF assms] as *] unfolding f_def by auto
  5046       hence "f n < b" and "a < f n" using open_closed_interval_convex[OF open_interval_midpoint[OF assms] as *] unfolding f_def by auto
  5044       hence False using fn unfolding f_def using xc by(auto simp add: vector_mul_lcancel vector_ssub_ldistrib)  }
  5047       hence False using fn unfolding f_def using xc by(auto simp add: vector_ssub_ldistrib)  }
  5045     moreover
  5048     moreover
  5046     { assume "\<not> (f ---> x) sequentially"
  5049     { assume "\<not> (f ---> x) sequentially"
  5047       { fix e::real assume "e>0"
  5050       { fix e::real assume "e>0"
  5048         hence "\<exists>N::nat. inverse (real (N + 1)) < e" using real_arch_inv[of e] apply (auto simp add: Suc_pred') apply(rule_tac x="n - 1" in exI) by auto
  5051         hence "\<exists>N::nat. inverse (real (N + 1)) < e" using real_arch_inv[of e] apply (auto simp add: Suc_pred') apply(rule_tac x="n - 1" in exI) by auto
  5049         then obtain N::nat where "inverse (real (N + 1)) < e" by auto
  5052         then obtain N::nat where "inverse (real (N + 1)) < e" by auto
  5455     moreover
  5458     moreover
  5456     { assume "x\<in>g ` t"
  5459     { assume "x\<in>g ` t"
  5457       then obtain y where y:"y\<in>t" "g y = x" by auto
  5460       then obtain y where y:"y\<in>t" "g y = x" by auto
  5458       then obtain x' where x':"x'\<in>s" "f x' = y" using assms(3) by auto
  5461       then obtain x' where x':"x'\<in>s" "f x' = y" using assms(3) by auto
  5459       hence "x \<in> s" unfolding g_def using someI2[of "\<lambda>b. b\<in>s \<and> f b = y" x' "\<lambda>x. x\<in>s"] unfolding y(2)[THEN sym] and g_def by auto }
  5462       hence "x \<in> s" unfolding g_def using someI2[of "\<lambda>b. b\<in>s \<and> f b = y" x' "\<lambda>x. x\<in>s"] unfolding y(2)[THEN sym] and g_def by auto }
  5460     ultimately have "x\<in>s \<longleftrightarrow> x \<in> g ` t" by auto  }
  5463     ultimately have "x\<in>s \<longleftrightarrow> x \<in> g ` t" ..  }
  5461   hence "g ` t = s" by auto
  5464   hence "g ` t = s" by auto
  5462   ultimately
  5465   ultimately
  5463   show ?thesis unfolding homeomorphism_def homeomorphic_def
  5466   show ?thesis unfolding homeomorphism_def homeomorphic_def
  5464     apply(rule_tac x=g in exI) using g and assms(3) and continuous_on_inverse[OF assms(2,1), of g, unfolded assms(3)] and assms(2) by auto
  5467     apply(rule_tac x=g in exI) using g and assms(3) and continuous_on_inverse[OF assms(2,1), of g, unfolded assms(3)] and assms(2) by auto
  5465 qed
  5468 qed
  5597   from False have "s \<noteq> {}" by auto
  5600   from False have "s \<noteq> {}" by auto
  5598   let ?S = "{f x| x. (x \<in> s \<and> norm x = norm a)}"
  5601   let ?S = "{f x| x. (x \<in> s \<and> norm x = norm a)}"
  5599   let ?S' = "{x::real^'m. x\<in>s \<and> norm x = norm a}"
  5602   let ?S' = "{x::real^'m. x\<in>s \<and> norm x = norm a}"
  5600   let ?S'' = "{x::real^'m. norm x = norm a}"
  5603   let ?S'' = "{x::real^'m. norm x = norm a}"
  5601 
  5604 
  5602   have "?S'' = frontier(cball 0 (norm a))" unfolding frontier_cball and dist_norm by (auto simp add: norm_minus_cancel)
  5605   have "?S'' = frontier(cball 0 (norm a))" unfolding frontier_cball and dist_norm by auto
  5603   hence "compact ?S''" using compact_frontier[OF compact_cball, of 0 "norm a"] by auto
  5606   hence "compact ?S''" using compact_frontier[OF compact_cball, of 0 "norm a"] by auto
  5604   moreover have "?S' = s \<inter> ?S''" by auto
  5607   moreover have "?S' = s \<inter> ?S''" by auto
  5605   ultimately have "compact ?S'" using closed_inter_compact[of s ?S''] using s(1) by auto
  5608   ultimately have "compact ?S'" using closed_inter_compact[of s ?S''] using s(1) by auto
  5606   moreover have *:"f ` ?S' = ?S" by auto
  5609   moreover have *:"f ` ?S' = ?S" by auto
  5607   ultimately have "compact ?S" using compact_continuous_image[OF linear_continuous_on[OF f(1)], of ?S'] by auto
  5610   ultimately have "compact ?S" using compact_continuous_image[OF linear_continuous_on[OF f(1)], of ?S'] by auto
  5644 
  5647 
  5645 subsection{* Some properties of a canonical subspace.                                  *}
  5648 subsection{* Some properties of a canonical subspace.                                  *}
  5646 
  5649 
  5647 lemma subspace_substandard:
  5650 lemma subspace_substandard:
  5648  "subspace {x::real^_. (\<forall>i. P i \<longrightarrow> x$i = 0)}"
  5651  "subspace {x::real^_. (\<forall>i. P i \<longrightarrow> x$i = 0)}"
  5649   unfolding subspace_def by(auto simp add: vector_add_component vector_smult_component elim!: ballE)
  5652   unfolding subspace_def by auto
  5650 
  5653 
  5651 lemma closed_substandard:
  5654 lemma closed_substandard:
  5652  "closed {x::real^'n. \<forall>i. P i --> x$i = 0}" (is "closed ?A")
  5655  "closed {x::real^'n. \<forall>i. P i --> x$i = 0}" (is "closed ?A")
  5653 proof-
  5656 proof-
  5654   let ?D = "{i. P i}"
  5657   let ?D = "{i. P i}"
  5661     { assume x:"x\<in>\<Inter>?Bs"
  5664     { assume x:"x\<in>\<Inter>?Bs"
  5662       { fix i assume i:"i \<in> ?D"
  5665       { fix i assume i:"i \<in> ?D"
  5663         then obtain B where BB:"B \<in> ?Bs" and B:"B = {x::real^'n. inner (basis i) x = 0}" by auto
  5666         then obtain B where BB:"B \<in> ?Bs" and B:"B = {x::real^'n. inner (basis i) x = 0}" by auto
  5664         hence "x $ i = 0" unfolding B using x unfolding inner_basis by auto  }
  5667         hence "x $ i = 0" unfolding B using x unfolding inner_basis by auto  }
  5665       hence "x\<in>?A" by auto }
  5668       hence "x\<in>?A" by auto }
  5666     ultimately have "x\<in>?A \<longleftrightarrow> x\<in> \<Inter>?Bs" by auto }
  5669     ultimately have "x\<in>?A \<longleftrightarrow> x\<in> \<Inter>?Bs" .. }
  5667   hence "?A = \<Inter> ?Bs" by auto
  5670   hence "?A = \<Inter> ?Bs" by auto
  5668   thus ?thesis by(auto simp add: closed_Inter closed_hyperplane)
  5671   thus ?thesis by(auto simp add: closed_Inter closed_hyperplane)
  5669 qed
  5672 qed
  5670 
  5673 
  5671 lemma dim_substandard:
  5674 lemma dim_substandard:
  5837   ultimately show ?thesis by auto
  5840   ultimately show ?thesis by auto
  5838 next
  5841 next
  5839   case False
  5842   case False
  5840   { fix y assume "a \<le> y" "y \<le> b" "m > 0"
  5843   { fix y assume "a \<le> y" "y \<le> b" "m > 0"
  5841     hence "m *\<^sub>R a + c \<le> m *\<^sub>R y + c"  "m *\<^sub>R y + c \<le> m *\<^sub>R b + c"
  5844     hence "m *\<^sub>R a + c \<le> m *\<^sub>R y + c"  "m *\<^sub>R y + c \<le> m *\<^sub>R b + c"
  5842       unfolding vector_le_def by(auto simp add: vector_smult_component vector_add_component)
  5845       unfolding vector_le_def by auto
  5843   } moreover
  5846   } moreover
  5844   { fix y assume "a \<le> y" "y \<le> b" "m < 0"
  5847   { fix y assume "a \<le> y" "y \<le> b" "m < 0"
  5845     hence "m *\<^sub>R b + c \<le> m *\<^sub>R y + c"  "m *\<^sub>R y + c \<le> m *\<^sub>R a + c"
  5848     hence "m *\<^sub>R b + c \<le> m *\<^sub>R y + c"  "m *\<^sub>R y + c \<le> m *\<^sub>R a + c"
  5846       unfolding vector_le_def by(auto simp add: vector_smult_component vector_add_component mult_left_mono_neg elim!:ballE)
  5849       unfolding vector_le_def by(auto simp add: mult_left_mono_neg)
  5847   } moreover
  5850   } moreover
  5848   { fix y assume "m > 0"  "m *\<^sub>R a + c \<le> y"  "y \<le> m *\<^sub>R b + c"
  5851   { fix y assume "m > 0"  "m *\<^sub>R a + c \<le> y"  "y \<le> m *\<^sub>R b + c"
  5849     hence "y \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}"
  5852     hence "y \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}"
  5850       unfolding image_iff Bex_def mem_interval vector_le_def
  5853       unfolding image_iff Bex_def mem_interval vector_le_def
  5851       apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric]
  5854       apply(auto simp add: vector_smult_assoc pth_3[symmetric]
  5852         intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"])
  5855         intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"])
  5853       by(auto simp add: pos_le_divide_eq pos_divide_le_eq real_mult_commute diff_le_iff)
  5856       by(auto simp add: pos_le_divide_eq pos_divide_le_eq real_mult_commute diff_le_iff)
  5854   } moreover
  5857   } moreover
  5855   { fix y assume "m *\<^sub>R b + c \<le> y" "y \<le> m *\<^sub>R a + c" "m < 0"
  5858   { fix y assume "m *\<^sub>R b + c \<le> y" "y \<le> m *\<^sub>R a + c" "m < 0"
  5856     hence "y \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}"
  5859     hence "y \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}"
  5857       unfolding image_iff Bex_def mem_interval vector_le_def
  5860       unfolding image_iff Bex_def mem_interval vector_le_def
  5858       apply(auto simp add: vector_smult_component vector_add_component vector_minus_component vector_smult_assoc pth_3[symmetric]
  5861       apply(auto simp add: vector_smult_assoc pth_3[symmetric]
  5859         intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"])
  5862         intro!: exI[where x="(1 / m) *\<^sub>R (y - c)"])
  5860       by(auto simp add: neg_le_divide_eq neg_divide_le_eq real_mult_commute diff_le_iff)
  5863       by(auto simp add: neg_le_divide_eq neg_divide_le_eq real_mult_commute diff_le_iff)
  5861   }
  5864   }
  5862   ultimately show ?thesis using False by auto
  5865   ultimately show ?thesis using False by auto
  5863 qed
  5866 qed