src/HOL/Library/Convex_Euclidean_Space.thy
changeset 33269 3b7e2dbbd684
parent 32960 69916a850301
equal deleted inserted replaced
33083:1fad3160d873 33269:3b7e2dbbd684
  1131   { fix x y assume "x\<in>s" "y\<in>s" and ?lhs
  1131   { fix x y assume "x\<in>s" "y\<in>s" and ?lhs
  1132     hence "2 *\<^sub>R x \<in>s" "2 *\<^sub>R y \<in> s" unfolding cone_def by auto
  1132     hence "2 *\<^sub>R x \<in>s" "2 *\<^sub>R y \<in> s" unfolding cone_def by auto
  1133     hence "x + y \<in> s" using `?lhs`[unfolded convex_def, THEN conjunct1]
  1133     hence "x + y \<in> s" using `?lhs`[unfolded convex_def, THEN conjunct1]
  1134       apply(erule_tac x="2*\<^sub>R x" in ballE) apply(erule_tac x="2*\<^sub>R y" in ballE)
  1134       apply(erule_tac x="2*\<^sub>R x" in ballE) apply(erule_tac x="2*\<^sub>R y" in ballE)
  1135       apply(erule_tac x="1/2" in allE) apply simp apply(erule_tac x="1/2" in allE) by auto  }
  1135       apply(erule_tac x="1/2" in allE) apply simp apply(erule_tac x="1/2" in allE) by auto  }
  1136   thus ?thesis unfolding convex_def cone_def by blast
  1136   thus ?thesis unfolding convex_def cone_def by auto
  1137 qed
  1137 qed
  1138 
  1138 
  1139 lemma affine_dependent_biggerset: fixes s::"(real^'n::finite) set"
  1139 lemma affine_dependent_biggerset: fixes s::"(real^'n::finite) set"
  1140   assumes "finite s" "card s \<ge> CARD('n) + 2"
  1140   assumes "finite s" "card s \<ge> CARD('n) + 2"
  1141   shows "affine_dependent s"
  1141   shows "affine_dependent s"
  1740   case False then obtain y where "y\<in>s" by auto
  1740   case False then obtain y where "y\<in>s" by auto
  1741   obtain a b where "0 < b" "\<forall>x\<in>{x - y |x y. x \<in> s \<and> y \<in> t}. b < inner a x"
  1741   obtain a b where "0 < b" "\<forall>x\<in>{x - y |x y. x \<in> s \<and> y \<in> t}. b < inner a x"
  1742     using separating_hyperplane_closed_point[OF convex_differences[OF assms(1,3)], of 0]
  1742     using separating_hyperplane_closed_point[OF convex_differences[OF assms(1,3)], of 0]
  1743     using closed_compact_differences[OF assms(2,4)] using assms(6) by(auto, blast)
  1743     using closed_compact_differences[OF assms(2,4)] using assms(6) by(auto, blast)
  1744   hence ab:"\<forall>x\<in>s. \<forall>y\<in>t. b + inner a y < inner a x" apply- apply(rule,rule) apply(erule_tac x="x - y" in ballE) by (auto simp add: inner_diff)
  1744   hence ab:"\<forall>x\<in>s. \<forall>y\<in>t. b + inner a y < inner a x" apply- apply(rule,rule) apply(erule_tac x="x - y" in ballE) by (auto simp add: inner_diff)
  1745   def k \<equiv> "rsup ((\<lambda>x. inner a x) ` t)"
  1745   def k \<equiv> "Sup ((\<lambda>x. inner a x) ` t)"
  1746   show ?thesis apply(rule_tac x="-a" in exI, rule_tac x="-(k + b / 2)" in exI)
  1746   show ?thesis apply(rule_tac x="-a" in exI, rule_tac x="-(k + b / 2)" in exI)
  1747     apply(rule,rule) defer apply(rule) unfolding inner_minus_left and neg_less_iff_less proof-
  1747     apply(rule,rule) defer apply(rule) unfolding inner_minus_left and neg_less_iff_less proof-
  1748     from ab have "((\<lambda>x. inner a x) ` t) *<= (inner a y - b)"
  1748     from ab have "((\<lambda>x. inner a x) ` t) *<= (inner a y - b)"
  1749       apply(erule_tac x=y in ballE) apply(rule setleI) using `y\<in>s` by auto
  1749       apply(erule_tac x=y in ballE) apply(rule setleI) using `y\<in>s` by auto
  1750     hence k:"isLub UNIV ((\<lambda>x. inner a x) ` t) k" unfolding k_def apply(rule_tac rsup) using assms(5) by auto
  1750     hence k:"isLub UNIV ((\<lambda>x. inner a x) ` t) k" unfolding k_def apply(rule_tac Sup) using assms(5) by auto
  1751     fix x assume "x\<in>t" thus "inner a x < (k + b / 2)" using `0<b` and isLubD2[OF k, of "inner a x"] by auto
  1751     fix x assume "x\<in>t" thus "inner a x < (k + b / 2)" using `0<b` and isLubD2[OF k, of "inner a x"] by auto
  1752   next
  1752   next
  1753     fix x assume "x\<in>s" 
  1753     fix x assume "x\<in>s" 
  1754     hence "k \<le> inner a x - b" unfolding k_def apply(rule_tac rsup_le) using assms(5)
  1754     hence "k \<le> inner a x - b" unfolding k_def apply(rule_tac Sup_least) using assms(5)
  1755       unfolding setle_def
       
  1756       using ab[THEN bspec[where x=x]] by auto
  1755       using ab[THEN bspec[where x=x]] by auto
  1757     thus "k + b / 2 < inner a x" using `0 < b` by auto
  1756     thus "k + b / 2 < inner a x" using `0 < b` by auto
  1758   qed
  1757   qed
  1759 qed
  1758 qed
  1760 
  1759 
  1792 
  1791 
  1793 lemma separating_hyperplane_sets:
  1792 lemma separating_hyperplane_sets:
  1794   assumes "convex s" "convex (t::(real^'n::finite) set)" "s \<noteq> {}" "t \<noteq> {}" "s \<inter> t = {}"
  1793   assumes "convex s" "convex (t::(real^'n::finite) set)" "s \<noteq> {}" "t \<noteq> {}" "s \<inter> t = {}"
  1795   shows "\<exists>a b. a \<noteq> 0 \<and> (\<forall>x\<in>s. inner a x \<le> b) \<and> (\<forall>x\<in>t. inner a x \<ge> b)"
  1794   shows "\<exists>a b. a \<noteq> 0 \<and> (\<forall>x\<in>s. inner a x \<le> b) \<and> (\<forall>x\<in>t. inner a x \<ge> b)"
  1796 proof- from separating_hyperplane_set_0[OF convex_differences[OF assms(2,1)]]
  1795 proof- from separating_hyperplane_set_0[OF convex_differences[OF assms(2,1)]]
  1797   obtain a where "a\<noteq>0" "\<forall>x\<in>{x - y |x y. x \<in> t \<and> y \<in> s}. 0 \<le> inner a x"  using assms(3-5) by auto 
  1796   obtain a where "a\<noteq>0" "\<forall>x\<in>{x - y |x y. x \<in> t \<and> y \<in> s}. 0 \<le> inner a x" 
  1798   hence "\<forall>x\<in>t. \<forall>y\<in>s. inner a y \<le> inner a x" apply- apply(rule, rule) apply(erule_tac x="x - y" in ballE) by (auto simp add: inner_diff)
  1797     using assms(3-5) by auto 
  1799   thus ?thesis apply(rule_tac x=a in exI, rule_tac x="rsup ((\<lambda>x. inner a x) ` s)" in exI) using `a\<noteq>0`
  1798   hence "\<forall>x\<in>t. \<forall>y\<in>s. inner a y \<le> inner a x"
  1800     apply(rule) apply(rule,rule) apply(rule rsup[THEN isLubD2]) prefer 4 apply(rule,rule rsup_le) unfolding setle_def
  1799     by (force simp add: inner_diff)
  1801     prefer 4 using assms(3-5) by blast+ qed
  1800   thus ?thesis
       
  1801     apply(rule_tac x=a in exI, rule_tac x="Sup ((\<lambda>x. inner a x) ` s)" in exI) using `a\<noteq>0`
       
  1802     apply auto
       
  1803     apply (rule Sup[THEN isLubD2]) 
       
  1804     prefer 4
       
  1805     apply (rule Sup_least) 
       
  1806      using assms(3-5) apply (auto simp add: setle_def)
       
  1807     apply (metis COMBC_def Collect_def Collect_mem_eq) 
       
  1808     done
       
  1809 qed
  1802 
  1810 
  1803 subsection {* More convexity generalities. *}
  1811 subsection {* More convexity generalities. *}
  1804 
  1812 
  1805 lemma convex_closure:
  1813 lemma convex_closure:
  1806   fixes s :: "'a::real_normed_vector set"
  1814   fixes s :: "'a::real_normed_vector set"
  2569     { fix i::'n have "x $ i - d \<le> y $ i"  "y $ i \<le> x $ i + d" 
  2577     { fix i::'n have "x $ i - d \<le> y $ i"  "y $ i \<le> x $ i + d" 
  2570         using order_trans[OF component_le_norm y[unfolded mem_cball dist_norm], of i] by(auto simp add: vector_component)  }
  2578         using order_trans[OF component_le_norm y[unfolded mem_cball dist_norm], of i] by(auto simp add: vector_component)  }
  2571     thus "f y \<le> k" apply(rule_tac k[rule_format]) unfolding mem_cball mem_interval dist_norm 
  2579     thus "f y \<le> k" apply(rule_tac k[rule_format]) unfolding mem_cball mem_interval dist_norm 
  2572       by(auto simp add: vector_component_simps) qed
  2580       by(auto simp add: vector_component_simps) qed
  2573   hence "continuous_on (ball x d) f" apply(rule_tac convex_on_bounded_continuous)
  2581   hence "continuous_on (ball x d) f" apply(rule_tac convex_on_bounded_continuous)
  2574     apply(rule open_ball, rule convex_on_subset[OF conv], rule ball_subset_cball) by auto
  2582     apply(rule open_ball, rule convex_on_subset[OF conv], rule ball_subset_cball)
  2575   thus "continuous (at x) f" unfolding continuous_on_eq_continuous_at[OF open_ball] using `d>0` by auto qed
  2583     apply force
  2576 
  2584     done
  2577 subsection {* Line segments, starlike sets etc.                                         *)
  2585   thus "continuous (at x) f" unfolding continuous_on_eq_continuous_at[OF open_ball]
  2578 (* Use the same overloading tricks as for intervals, so that                 *)
  2586     using `d>0` by auto 
  2579 (* segment[a,b] is closed and segment(a,b) is open relative to affine hull. *}
  2587 qed
       
  2588 
       
  2589 subsection {* Line segments, Starlike Sets, etc.*}
       
  2590 
       
  2591 (* Use the same overloading tricks as for intervals, so that 
       
  2592    segment[a,b] is closed and segment(a,b) is open relative to affine hull. *)
  2580 
  2593 
  2581 definition
  2594 definition
  2582   midpoint :: "real ^ 'n::finite \<Rightarrow> real ^ 'n \<Rightarrow> real ^ 'n" where
  2595   midpoint :: "real ^ 'n::finite \<Rightarrow> real ^ 'n \<Rightarrow> real ^ 'n" where
  2583   "midpoint a b = (inverse (2::real)) *\<^sub>R (a + b)"
  2596   "midpoint a b = (inverse (2::real)) *\<^sub>R (a + b)"
  2584 
  2597