src/HOL/Analysis/Starlike.thy
changeset 69508 2a4c8a2a3f8e
parent 69325 4b6ddc5989fc
child 69516 09bb8f470959
equal deleted inserted replaced
69506:7d59af98af29 69508:2a4c8a2a3f8e
  3724     using at_within_interior assms by fastforce
  3724     using at_within_interior assms by fastforce
  3725 qed
  3725 qed
  3726 
  3726 
  3727 lemma affine_independent_convex_affine_hull:
  3727 lemma affine_independent_convex_affine_hull:
  3728   fixes s :: "'a::euclidean_space set"
  3728   fixes s :: "'a::euclidean_space set"
  3729   assumes "~affine_dependent s" "t \<subseteq> s"
  3729   assumes "\<not> affine_dependent s" "t \<subseteq> s"
  3730     shows "convex hull t = affine hull t \<inter> convex hull s"
  3730     shows "convex hull t = affine hull t \<inter> convex hull s"
  3731 proof -
  3731 proof -
  3732   have fin: "finite s" "finite t" using assms aff_independent_finite finite_subset by auto
  3732   have fin: "finite s" "finite t" using assms aff_independent_finite finite_subset by auto
  3733     { fix u v x
  3733     { fix u v x
  3734       assume uv: "sum u t = 1" "\<forall>x\<in>s. 0 \<le> v x" "sum v s = 1"
  3734       assume uv: "sum u t = 1" "\<forall>x\<in>s. 0 \<le> v x" "sum v s = 1"
  3762     by blast
  3762     by blast
  3763 qed
  3763 qed
  3764 
  3764 
  3765 lemma affine_independent_span_eq:
  3765 lemma affine_independent_span_eq:
  3766   fixes s :: "'a::euclidean_space set"
  3766   fixes s :: "'a::euclidean_space set"
  3767   assumes "~affine_dependent s" "card s = Suc (DIM ('a))"
  3767   assumes "\<not> affine_dependent s" "card s = Suc (DIM ('a))"
  3768     shows "affine hull s = UNIV"
  3768     shows "affine hull s = UNIV"
  3769 proof (cases "s = {}")
  3769 proof (cases "s = {}")
  3770   case True then show ?thesis
  3770   case True then show ?thesis
  3771     using assms by simp
  3771     using assms by simp
  3772 next
  3772 next
  3787       done
  3787       done
  3788 qed
  3788 qed
  3789 
  3789 
  3790 lemma affine_independent_span_gt:
  3790 lemma affine_independent_span_gt:
  3791   fixes s :: "'a::euclidean_space set"
  3791   fixes s :: "'a::euclidean_space set"
  3792   assumes ind: "~ affine_dependent s" and dim: "DIM ('a) < card s"
  3792   assumes ind: "\<not> affine_dependent s" and dim: "DIM ('a) < card s"
  3793     shows "affine hull s = UNIV"
  3793     shows "affine hull s = UNIV"
  3794   apply (rule affine_independent_span_eq [OF ind])
  3794   apply (rule affine_independent_span_eq [OF ind])
  3795   apply (rule antisym)
  3795   apply (rule antisym)
  3796   using assms
  3796   using assms
  3797   apply auto
  3797   apply auto
  3829              \<subseteq> rel_interior (convex hull s)"
  3829              \<subseteq> rel_interior (convex hull s)"
  3830   by (force simp add:  rel_interior_convex_hull_union [where S="\<lambda>x. {x}" and I=s, simplified])
  3830   by (force simp add:  rel_interior_convex_hull_union [where S="\<lambda>x. {x}" and I=s, simplified])
  3831 
  3831 
  3832 lemma rel_interior_convex_hull_explicit:
  3832 lemma rel_interior_convex_hull_explicit:
  3833   fixes s :: "'a::euclidean_space set"
  3833   fixes s :: "'a::euclidean_space set"
  3834   assumes "~ affine_dependent s"
  3834   assumes "\<not> affine_dependent s"
  3835   shows "rel_interior(convex hull s) =
  3835   shows "rel_interior(convex hull s) =
  3836          {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
  3836          {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
  3837          (is "?lhs = ?rhs")
  3837          (is "?lhs = ?rhs")
  3838 proof
  3838 proof
  3839   show "?rhs \<le> ?lhs"
  3839   show "?rhs \<le> ?lhs"
  3902 qed
  3902 qed
  3903 
  3903 
  3904 lemma interior_convex_hull_explicit_minimal:
  3904 lemma interior_convex_hull_explicit_minimal:
  3905   fixes s :: "'a::euclidean_space set"
  3905   fixes s :: "'a::euclidean_space set"
  3906   shows
  3906   shows
  3907    "~ affine_dependent s
  3907    "\<not> affine_dependent s
  3908         ==> interior(convex hull s) =
  3908         ==> interior(convex hull s) =
  3909              (if card(s) \<le> DIM('a) then {}
  3909              (if card(s) \<le> DIM('a) then {}
  3910               else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
  3910               else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
  3911   apply (simp add: aff_independent_finite empty_interior_convex_hull, clarify)
  3911   apply (simp add: aff_independent_finite empty_interior_convex_hull, clarify)
  3912   apply (rule trans [of _ "rel_interior(convex hull s)"])
  3912   apply (rule trans [of _ "rel_interior(convex hull s)"])
  3913   apply (simp add: affine_hull_convex_hull affine_independent_span_gt rel_interior_interior)
  3913   apply (simp add: affine_independent_span_gt rel_interior_interior)
  3914   by (simp add: rel_interior_convex_hull_explicit)
  3914   by (simp add: rel_interior_convex_hull_explicit)
  3915 
  3915 
  3916 lemma interior_convex_hull_explicit:
  3916 lemma interior_convex_hull_explicit:
  3917   fixes s :: "'a::euclidean_space set"
  3917   fixes s :: "'a::euclidean_space set"
  3918   assumes "~ affine_dependent s"
  3918   assumes "\<not> affine_dependent s"
  3919   shows
  3919   shows
  3920    "interior(convex hull s) =
  3920    "interior(convex hull s) =
  3921              (if card(s) \<le> DIM('a) then {}
  3921              (if card(s) \<le> DIM('a) then {}
  3922               else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x \<and> u x < 1) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
  3922               else {y. \<exists>u. (\<forall>x \<in> s. 0 < u x \<and> u x < 1) \<and> sum u s = 1 \<and> (\<Sum>x\<in>s. u x *\<^sub>R x) = y})"
  3923 proof -
  3923 proof -
  4080   shows "compact s ==> closure(convex hull s) = convex hull s"
  4080   shows "compact s ==> closure(convex hull s) = convex hull s"
  4081   by (simp add: compact_imp_closed compact_convex_hull)
  4081   by (simp add: compact_imp_closed compact_convex_hull)
  4082 
  4082 
  4083 lemma rel_frontier_convex_hull_explicit:
  4083 lemma rel_frontier_convex_hull_explicit:
  4084   fixes s :: "'a::euclidean_space set"
  4084   fixes s :: "'a::euclidean_space set"
  4085   assumes "~ affine_dependent s"
  4085   assumes "\<not> affine_dependent s"
  4086   shows "rel_frontier(convex hull s) =
  4086   shows "rel_frontier(convex hull s) =
  4087          {y. \<exists>u. (\<forall>x \<in> s. 0 \<le> u x) \<and> (\<exists>x \<in> s. u x = 0) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
  4087          {y. \<exists>u. (\<forall>x \<in> s. 0 \<le> u x) \<and> (\<exists>x \<in> s. u x = 0) \<and> sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
  4088 proof -
  4088 proof -
  4089   have fs: "finite s"
  4089   have fs: "finite s"
  4090     using assms by (simp add: aff_independent_finite)
  4090     using assms by (simp add: aff_independent_finite)
  4104     done
  4104     done
  4105 qed
  4105 qed
  4106 
  4106 
  4107 lemma frontier_convex_hull_explicit:
  4107 lemma frontier_convex_hull_explicit:
  4108   fixes s :: "'a::euclidean_space set"
  4108   fixes s :: "'a::euclidean_space set"
  4109   assumes "~ affine_dependent s"
  4109   assumes "\<not> affine_dependent s"
  4110   shows "frontier(convex hull s) =
  4110   shows "frontier(convex hull s) =
  4111          {y. \<exists>u. (\<forall>x \<in> s. 0 \<le> u x) \<and> (DIM ('a) < card s \<longrightarrow> (\<exists>x \<in> s. u x = 0)) \<and>
  4111          {y. \<exists>u. (\<forall>x \<in> s. 0 \<le> u x) \<and> (DIM ('a) < card s \<longrightarrow> (\<exists>x \<in> s. u x = 0)) \<and>
  4112              sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
  4112              sum u s = 1 \<and> sum (\<lambda>x. u x *\<^sub>R x) s = y}"
  4113 proof -
  4113 proof -
  4114   have fs: "finite s"
  4114   have fs: "finite s"
  4131   qed
  4131   qed
  4132 qed
  4132 qed
  4133 
  4133 
  4134 lemma rel_frontier_convex_hull_cases:
  4134 lemma rel_frontier_convex_hull_cases:
  4135   fixes s :: "'a::euclidean_space set"
  4135   fixes s :: "'a::euclidean_space set"
  4136   assumes "~ affine_dependent s"
  4136   assumes "\<not> affine_dependent s"
  4137   shows "rel_frontier(convex hull s) = \<Union>{convex hull (s - {x}) |x. x \<in> s}"
  4137   shows "rel_frontier(convex hull s) = \<Union>{convex hull (s - {x}) |x. x \<in> s}"
  4138 proof -
  4138 proof -
  4139   have fs: "finite s"
  4139   have fs: "finite s"
  4140     using assms by (simp add: aff_independent_finite)
  4140     using assms by (simp add: aff_independent_finite)
  4141   { fix u a
  4141   { fix u a
  4162     done
  4162     done
  4163 qed
  4163 qed
  4164 
  4164 
  4165 lemma frontier_convex_hull_eq_rel_frontier:
  4165 lemma frontier_convex_hull_eq_rel_frontier:
  4166   fixes s :: "'a::euclidean_space set"
  4166   fixes s :: "'a::euclidean_space set"
  4167   assumes "~ affine_dependent s"
  4167   assumes "\<not> affine_dependent s"
  4168   shows "frontier(convex hull s) =
  4168   shows "frontier(convex hull s) =
  4169            (if card s \<le> DIM ('a) then convex hull s else rel_frontier(convex hull s))"
  4169            (if card s \<le> DIM ('a) then convex hull s else rel_frontier(convex hull s))"
  4170   using assms
  4170   using assms
  4171   unfolding rel_frontier_def frontier_def
  4171   unfolding rel_frontier_def frontier_def
  4172   by (simp add: affine_independent_span_gt rel_interior_interior
  4172   by (simp add: affine_independent_span_gt rel_interior_interior
  4173                 finite_imp_compact empty_interior_convex_hull aff_independent_finite)
  4173                 finite_imp_compact empty_interior_convex_hull aff_independent_finite)
  4174 
  4174 
  4175 lemma frontier_convex_hull_cases:
  4175 lemma frontier_convex_hull_cases:
  4176   fixes s :: "'a::euclidean_space set"
  4176   fixes s :: "'a::euclidean_space set"
  4177   assumes "~ affine_dependent s"
  4177   assumes "\<not> affine_dependent s"
  4178   shows "frontier(convex hull s) =
  4178   shows "frontier(convex hull s) =
  4179            (if card s \<le> DIM ('a) then convex hull s else \<Union>{convex hull (s - {x}) |x. x \<in> s})"
  4179            (if card s \<le> DIM ('a) then convex hull s else \<Union>{convex hull (s - {x}) |x. x \<in> s})"
  4180 by (simp add: assms frontier_convex_hull_eq_rel_frontier rel_frontier_convex_hull_cases)
  4180 by (simp add: assms frontier_convex_hull_eq_rel_frontier rel_frontier_convex_hull_cases)
  4181 
  4181 
  4182 lemma in_frontier_convex_hull:
  4182 lemma in_frontier_convex_hull:
  4666 apply (simp add: algebra_simps)
  4666 apply (simp add: algebra_simps)
  4667 done
  4667 done
  4668 
  4668 
  4669 lemma interior_convex_hull_3_minimal:
  4669 lemma interior_convex_hull_3_minimal:
  4670   fixes a :: "'a::euclidean_space"
  4670   fixes a :: "'a::euclidean_space"
  4671   shows "\<lbrakk>~ collinear{a,b,c}; DIM('a) = 2\<rbrakk>
  4671   shows "\<lbrakk>\<not> collinear{a,b,c}; DIM('a) = 2\<rbrakk>
  4672          \<Longrightarrow> interior(convex hull {a,b,c}) =
  4672          \<Longrightarrow> interior(convex hull {a,b,c}) =
  4673                 {v. \<exists>x y z. 0 < x \<and> 0 < y \<and> 0 < z \<and> x + y + z = 1 \<and>
  4673                 {v. \<exists>x y z. 0 < x \<and> 0 < y \<and> 0 < z \<and> x + y + z = 1 \<and>
  4674                             x *\<^sub>R a + y *\<^sub>R b + z *\<^sub>R c = v}"
  4674                             x *\<^sub>R a + y *\<^sub>R b + z *\<^sub>R c = v}"
  4675 apply (simp add: collinear_3_eq_affine_dependent interior_convex_hull_explicit_minimal, safe)
  4675 apply (simp add: collinear_3_eq_affine_dependent interior_convex_hull_explicit_minimal, safe)
  4676 apply (rule_tac x="u a" in exI, simp)
  4676 apply (rule_tac x="u a" in exI, simp)
  5860     by (force simp add:span_zero insert_commute [of a] hull_inc aff_dim_eq_dim [of x] dim_insert)
  5860     by (force simp add:span_zero insert_commute [of a] hull_inc aff_dim_eq_dim [of x] dim_insert)
  5861 qed
  5861 qed
  5862 
  5862 
  5863 lemma affine_dependent_choose:
  5863 lemma affine_dependent_choose:
  5864   fixes a :: "'a :: euclidean_space"
  5864   fixes a :: "'a :: euclidean_space"
  5865   assumes "~(affine_dependent S)"
  5865   assumes "\<not>(affine_dependent S)"
  5866   shows "affine_dependent(insert a S) \<longleftrightarrow> a \<notin> S \<and> a \<in> affine hull S"
  5866   shows "affine_dependent(insert a S) \<longleftrightarrow> a \<notin> S \<and> a \<in> affine hull S"
  5867         (is "?lhs = ?rhs")
  5867         (is "?lhs = ?rhs")
  5868 proof safe
  5868 proof safe
  5869   assume "affine_dependent (insert a S)" and "a \<in> S"
  5869   assume "affine_dependent (insert a S)" and "a \<in> S"
  5870   then show "False"
  5870   then show "False"
  5885     by (simp add: \<open>a \<in> affine hull S\<close> \<open>a \<notin> S\<close> affine_dependent_def)
  5885     by (simp add: \<open>a \<in> affine hull S\<close> \<open>a \<notin> S\<close> affine_dependent_def)
  5886 qed
  5886 qed
  5887 
  5887 
  5888 lemma affine_independent_insert:
  5888 lemma affine_independent_insert:
  5889   fixes a :: "'a :: euclidean_space"
  5889   fixes a :: "'a :: euclidean_space"
  5890   shows "\<lbrakk>~(affine_dependent S); a \<notin> affine hull S\<rbrakk> \<Longrightarrow> ~(affine_dependent(insert a S))"
  5890   shows "\<lbrakk>\<not> affine_dependent S; a \<notin> affine hull S\<rbrakk> \<Longrightarrow> \<not> affine_dependent(insert a S)"
  5891   by (simp add: affine_dependent_choose)
  5891   by (simp add: affine_dependent_choose)
  5892 
  5892 
  5893 lemma subspace_bounded_eq_trivial:
  5893 lemma subspace_bounded_eq_trivial:
  5894   fixes S :: "'a::real_normed_vector set"
  5894   fixes S :: "'a::real_normed_vector set"
  5895   assumes "subspace S"
  5895   assumes "subspace S"
  6156 
  6156 
  6157 subsection%unimportant\<open> Some results on decomposing convex hulls: intersections, simplicial subdivision\<close>
  6157 subsection%unimportant\<open> Some results on decomposing convex hulls: intersections, simplicial subdivision\<close>
  6158 
  6158 
  6159 lemma
  6159 lemma
  6160   fixes s :: "'a::euclidean_space set"
  6160   fixes s :: "'a::euclidean_space set"
  6161   assumes "~ (affine_dependent(s \<union> t))"
  6161   assumes "\<not> affine_dependent(s \<union> t)"
  6162     shows convex_hull_Int_subset: "convex hull s \<inter> convex hull t \<subseteq> convex hull (s \<inter> t)" (is ?C)
  6162     shows convex_hull_Int_subset: "convex hull s \<inter> convex hull t \<subseteq> convex hull (s \<inter> t)" (is ?C)
  6163       and affine_hull_Int_subset: "affine hull s \<inter> affine hull t \<subseteq> affine hull (s \<inter> t)" (is ?A)
  6163       and affine_hull_Int_subset: "affine hull s \<inter> affine hull t \<subseteq> affine hull (s \<inter> t)" (is ?A)
  6164 proof -
  6164 proof -
  6165   have [simp]: "finite s" "finite t"
  6165   have [simp]: "finite s" "finite t"
  6166     using aff_independent_finite assms by blast+
  6166     using aff_independent_finite assms by blast+
  6199 qed
  6199 qed
  6200 
  6200 
  6201 
  6201 
  6202 proposition affine_hull_Int:
  6202 proposition affine_hull_Int:
  6203   fixes s :: "'a::euclidean_space set"
  6203   fixes s :: "'a::euclidean_space set"
  6204   assumes "~ (affine_dependent(s \<union> t))"
  6204   assumes "\<not> affine_dependent(s \<union> t)"
  6205     shows "affine hull (s \<inter> t) = affine hull s \<inter> affine hull t"
  6205     shows "affine hull (s \<inter> t) = affine hull s \<inter> affine hull t"
  6206 apply (rule subset_antisym)
  6206 apply (rule subset_antisym)
  6207 apply (simp add: hull_mono)
  6207 apply (simp add: hull_mono)
  6208 by (simp add: affine_hull_Int_subset assms)
  6208 by (simp add: affine_hull_Int_subset assms)
  6209 
  6209 
  6210 proposition convex_hull_Int:
  6210 proposition convex_hull_Int:
  6211   fixes s :: "'a::euclidean_space set"
  6211   fixes s :: "'a::euclidean_space set"
  6212   assumes "~ (affine_dependent(s \<union> t))"
  6212   assumes "\<not> affine_dependent(s \<union> t)"
  6213     shows "convex hull (s \<inter> t) = convex hull s \<inter> convex hull t"
  6213     shows "convex hull (s \<inter> t) = convex hull s \<inter> convex hull t"
  6214 apply (rule subset_antisym)
  6214 apply (rule subset_antisym)
  6215 apply (simp add: hull_mono)
  6215 apply (simp add: hull_mono)
  6216 by (simp add: convex_hull_Int_subset assms)
  6216 by (simp add: convex_hull_Int_subset assms)
  6217 
  6217 
  6218 proposition
  6218 proposition
  6219   fixes s :: "'a::euclidean_space set set"
  6219   fixes s :: "'a::euclidean_space set set"
  6220   assumes "~ (affine_dependent (\<Union>s))"
  6220   assumes "\<not> affine_dependent (\<Union>s)"
  6221     shows affine_hull_Inter: "affine hull (\<Inter>s) = (\<Inter>t\<in>s. affine hull t)" (is "?A")
  6221     shows affine_hull_Inter: "affine hull (\<Inter>s) = (\<Inter>t\<in>s. affine hull t)" (is "?A")
  6222       and convex_hull_Inter: "convex hull (\<Inter>s) = (\<Inter>t\<in>s. convex hull t)" (is "?C")
  6222       and convex_hull_Inter: "convex hull (\<Inter>s) = (\<Inter>t\<in>s. convex hull t)" (is "?C")
  6223 proof -
  6223 proof -
  6224   have "finite s"
  6224   have "finite s"
  6225     using aff_independent_finite assms finite_UnionD by blast
  6225     using aff_independent_finite assms finite_UnionD by blast
  6245     by auto
  6245     by auto
  6246 qed
  6246 qed
  6247 
  6247 
  6248 proposition in_convex_hull_exchange_unique:
  6248 proposition in_convex_hull_exchange_unique:
  6249   fixes S :: "'a::euclidean_space set"
  6249   fixes S :: "'a::euclidean_space set"
  6250   assumes naff: "~ affine_dependent S" and a: "a \<in> convex hull S"
  6250   assumes naff: "\<not> affine_dependent S" and a: "a \<in> convex hull S"
  6251       and S: "T \<subseteq> S" "T' \<subseteq> S"
  6251       and S: "T \<subseteq> S" "T' \<subseteq> S"
  6252       and x:  "x \<in> convex hull (insert a T)"
  6252       and x:  "x \<in> convex hull (insert a T)"
  6253       and x': "x \<in> convex hull (insert a T')"
  6253       and x': "x \<in> convex hull (insert a T')"
  6254     shows "x \<in> convex hull (insert a (T \<inter> T'))"
  6254     shows "x \<in> convex hull (insert a (T \<inter> T'))"
  6255 proof (cases "a \<in> S")
  6255 proof (cases "a \<in> S")
  6393   qed
  6393   qed
  6394 qed
  6394 qed
  6395 
  6395 
  6396 corollary convex_hull_exchange_Int:
  6396 corollary convex_hull_exchange_Int:
  6397   fixes a  :: "'a::euclidean_space"
  6397   fixes a  :: "'a::euclidean_space"
  6398   assumes "~ affine_dependent S" "a \<in> convex hull S" "T \<subseteq> S" "T' \<subseteq> S"
  6398   assumes "\<not> affine_dependent S" "a \<in> convex hull S" "T \<subseteq> S" "T' \<subseteq> S"
  6399   shows "(convex hull (insert a T)) \<inter> (convex hull (insert a T')) =
  6399   shows "(convex hull (insert a T)) \<inter> (convex hull (insert a T')) =
  6400          convex hull (insert a (T \<inter> T'))"
  6400          convex hull (insert a (T \<inter> T'))"
  6401 apply (rule subset_antisym)
  6401 apply (rule subset_antisym)
  6402   using in_convex_hull_exchange_unique assms apply blast
  6402   using in_convex_hull_exchange_unique assms apply blast
  6403   by (metis hull_mono inf_le1 inf_le2 insert_inter_insert le_inf_iff)
  6403   by (metis hull_mono inf_le1 inf_le2 insert_inter_insert le_inf_iff)
  6404 
  6404 
  6405 lemma Int_closed_segment:
  6405 lemma Int_closed_segment:
  6406   fixes b :: "'a::euclidean_space"
  6406   fixes b :: "'a::euclidean_space"
  6407   assumes "b \<in> closed_segment a c \<or> ~collinear{a,b,c}"
  6407   assumes "b \<in> closed_segment a c \<or> \<not> collinear{a,b,c}"
  6408     shows "closed_segment a b \<inter> closed_segment b c = {b}"
  6408     shows "closed_segment a b \<inter> closed_segment b c = {b}"
  6409 proof (cases "c = a")
  6409 proof (cases "c = a")
  6410   case True
  6410   case True
  6411   then show ?thesis
  6411   then show ?thesis
  6412     using assms collinear_3_eq_affine_dependent by fastforce
  6412     using assms collinear_3_eq_affine_dependent by fastforce
  7281 
  7281 
  7282 proposition affine_parallel_slice:
  7282 proposition affine_parallel_slice:
  7283   fixes S :: "'a :: euclidean_space set"
  7283   fixes S :: "'a :: euclidean_space set"
  7284   assumes "affine S"
  7284   assumes "affine S"
  7285       and "S \<inter> {x. a \<bullet> x \<le> b} \<noteq> {}"
  7285       and "S \<inter> {x. a \<bullet> x \<le> b} \<noteq> {}"
  7286       and "~ (S \<subseteq> {x. a \<bullet> x \<le> b})"
  7286       and "\<not> (S \<subseteq> {x. a \<bullet> x \<le> b})"
  7287   obtains a' b' where "a' \<noteq> 0"
  7287   obtains a' b' where "a' \<noteq> 0"
  7288                    "S \<inter> {x. a' \<bullet> x \<le> b'} = S \<inter> {x. a \<bullet> x \<le> b}"
  7288                    "S \<inter> {x. a' \<bullet> x \<le> b'} = S \<inter> {x. a \<bullet> x \<le> b}"
  7289                    "S \<inter> {x. a' \<bullet> x = b'} = S \<inter> {x. a \<bullet> x = b}"
  7289                    "S \<inter> {x. a' \<bullet> x = b'} = S \<inter> {x. a \<bullet> x = b}"
  7290                    "\<And>w. w \<in> S \<Longrightarrow> (w + a') \<in> S"
  7290                    "\<And>w. w \<in> S \<Longrightarrow> (w + a') \<in> S"
  7291 proof (cases "S \<inter> {x. a \<bullet> x = b} = {}")
  7291 proof (cases "S \<inter> {x. a \<bullet> x = b} = {}")
  7667 
  7667 
  7668 lemma continuous_on_cases_local_open:
  7668 lemma continuous_on_cases_local_open:
  7669   assumes opS: "openin (subtopology euclidean (S \<union> T)) S"
  7669   assumes opS: "openin (subtopology euclidean (S \<union> T)) S"
  7670       and opT: "openin (subtopology euclidean (S \<union> T)) T"
  7670       and opT: "openin (subtopology euclidean (S \<union> T)) T"
  7671       and contf: "continuous_on S f" and contg: "continuous_on T g"
  7671       and contf: "continuous_on S f" and contg: "continuous_on T g"
  7672       and fg: "\<And>x. x \<in> S \<and> ~P x \<or> x \<in> T \<and> P x \<Longrightarrow> f x = g x"
  7672       and fg: "\<And>x. x \<in> S \<and> \<not>P x \<or> x \<in> T \<and> P x \<Longrightarrow> f x = g x"
  7673     shows "continuous_on (S \<union> T) (\<lambda>x. if P x then f x else g x)"
  7673     shows "continuous_on (S \<union> T) (\<lambda>x. if P x then f x else g x)"
  7674 proof -
  7674 proof -
  7675   have "\<And>x. x \<in> S \<Longrightarrow> (if P x then f x else g x) = f x"  "\<And>x. x \<in> T \<Longrightarrow> (if P x then f x else g x) = g x"
  7675   have "\<And>x. x \<in> S \<Longrightarrow> (if P x then f x else g x) = f x"  "\<And>x. x \<in> T \<Longrightarrow> (if P x then f x else g x) = g x"
  7676     by (simp_all add: fg)
  7676     by (simp_all add: fg)
  7677   then have "continuous_on S (\<lambda>x. if P x then f x else g x)" "continuous_on T (\<lambda>x. if P x then f x else g x)"
  7677   then have "continuous_on S (\<lambda>x. if P x then f x else g x)" "continuous_on T (\<lambda>x. if P x then f x else g x)"