src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy
changeset 56536 aefb4a8da31f
parent 56480 093ea91498e6
child 56541 0e3abadbef39
equal deleted inserted replaced
56535:34023a586608 56536:aefb4a8da31f
  1171     fix c :: real
  1171     fix c :: real
  1172     assume c: "c \<ge> 0"
  1172     assume c: "c \<ge> 0"
  1173     then have "c *\<^sub>R x = (c * cx) *\<^sub>R xx"
  1173     then have "c *\<^sub>R x = (c * cx) *\<^sub>R xx"
  1174       using x by (simp add: algebra_simps)
  1174       using x by (simp add: algebra_simps)
  1175     moreover
  1175     moreover
  1176     have "c * cx \<ge> 0"
  1176     have "c * cx \<ge> 0" using c x by auto
  1177       using c x using mult_nonneg_nonneg by auto
       
  1178     ultimately
  1177     ultimately
  1179     have "c *\<^sub>R x \<in> ?rhs" using x by auto
  1178     have "c *\<^sub>R x \<in> ?rhs" using x by auto
  1180   }
  1179   }
  1181   then have "cone ?rhs"
  1180   then have "cone ?rhs"
  1182     unfolding cone_def by auto
  1181     unfolding cone_def by auto
  1601         using as(3) obt1(3) obt2(3) by (auto simp add: field_simps)
  1600         using as(3) obt1(3) obt2(3) by (auto simp add: field_simps)
  1602       also have "\<dots> = u * v1 + v * v2"
  1601       also have "\<dots> = u * v1 + v * v2"
  1603         by simp
  1602         by simp
  1604       finally have **:"1 - (u * u1 + v * u2) = u * v1 + v * v2" by auto
  1603       finally have **:"1 - (u * u1 + v * u2) = u * v1 + v * v2" by auto
  1605       have "0 \<le> u * v1 + v * v2" "0 \<le> u * v1" "0 \<le> u * v1 + v * v2" "0 \<le> v * v2"
  1604       have "0 \<le> u * v1 + v * v2" "0 \<le> u * v1" "0 \<le> u * v1 + v * v2" "0 \<le> v * v2"
  1606         apply (rule add_nonneg_nonneg)
  1605         using as(1,2) obt1(1,2) obt2(1,2) by auto
  1607         prefer 4
       
  1608         apply (rule add_nonneg_nonneg)
       
  1609         apply (rule_tac [!] mult_nonneg_nonneg)
       
  1610         using as(1,2) obt1(1,2) obt2(1,2)
       
  1611         apply auto
       
  1612         done
       
  1613       then show ?thesis
  1606       then show ?thesis
  1614         unfolding obt1(5) obt2(5)
  1607         unfolding obt1(5) obt2(5)
  1615         unfolding * and **
  1608         unfolding * and **
  1616         using False
  1609         using False
  1617         apply (rule_tac
  1610         apply (rule_tac
  1641       apply (rule conjI)
  1634       apply (rule conjI)
  1642       defer
  1635       defer
  1643       apply (rule_tac x="1 - u * u1 - v * u2" in exI)
  1636       apply (rule_tac x="1 - u * u1 - v * u2" in exI)
  1644       unfolding Bex_def
  1637       unfolding Bex_def
  1645       using as(1,2) obt1(1,2) obt2(1,2) **
  1638       using as(1,2) obt1(1,2) obt2(1,2) **
  1646       apply (auto intro!: mult_nonneg_nonneg add_nonneg_nonneg simp add: algebra_simps)
  1639       apply (auto simp add: algebra_simps)
  1647       done
  1640       done
  1648   qed
  1641   qed
  1649 qed
  1642 qed
  1650 
  1643 
  1651 
  1644 
  1726     show "0 \<le> (if i \<in> {1..k1} then u * u1 i else v * u2 (i - k1)) \<and>
  1719     show "0 \<le> (if i \<in> {1..k1} then u * u1 i else v * u2 (i - k1)) \<and>
  1727       (if i \<in> {1..k1} then x1 i else x2 (i - k1)) \<in> s"
  1720       (if i \<in> {1..k1} then x1 i else x2 (i - k1)) \<in> s"
  1728     proof (cases "i\<in>{1..k1}")
  1721     proof (cases "i\<in>{1..k1}")
  1729       case True
  1722       case True
  1730       then show ?thesis
  1723       then show ?thesis
  1731         using mult_nonneg_nonneg[of u "u1 i"] and uv(1) x(1)[THEN bspec[where x=i]]
  1724         using uv(1) x(1)[THEN bspec[where x=i]] by auto
  1732         by auto
       
  1733     next
  1725     next
  1734       case False
  1726       case False
  1735       def j \<equiv> "i - k1"
  1727       def j \<equiv> "i - k1"
  1736       from i False have "j \<in> {1..k2}"
  1728       from i False have "j \<in> {1..k2}"
  1737         unfolding j_def by auto
  1729         unfolding j_def by auto
  1738       then show ?thesis
  1730       then show ?thesis
  1739         unfolding j_def[symmetric]
  1731         using False uv(2) y(1)[THEN bspec[where x=j]]
  1740         using False
  1732         by (auto simp: j_def[symmetric])
  1741         using mult_nonneg_nonneg[of v "u2 j"] and uv(2) y(1)[THEN bspec[where x=j]]
       
  1742         apply auto
       
  1743         done
       
  1744     qed
  1733     qed
  1745   qed (auto simp add: not_le x(2,3) y(2,3) uv(3))
  1734   qed (auto simp add: not_le x(2,3) y(2,3) uv(3))
  1746 qed
  1735 qed
  1747 
  1736 
  1748 lemma convex_hull_finite:
  1737 lemma convex_hull_finite:
  1768   {
  1757   {
  1769     fix x
  1758     fix x
  1770     assume "x\<in>s"
  1759     assume "x\<in>s"
  1771     then have "0 \<le> u * ux x + v * uy x"
  1760     then have "0 \<le> u * ux x + v * uy x"
  1772       using ux(1)[THEN bspec[where x=x]] uy(1)[THEN bspec[where x=x]] and uv(1,2)
  1761       using ux(1)[THEN bspec[where x=x]] uy(1)[THEN bspec[where x=x]] and uv(1,2)
  1773       apply auto
  1762       by auto
  1774       apply (metis add_nonneg_nonneg mult_nonneg_nonneg uv(1) uv(2))
       
  1775       done
       
  1776   }
  1763   }
  1777   moreover
  1764   moreover
  1778   have "(\<Sum>x\<in>s. u * ux x + v * uy x) = 1"
  1765   have "(\<Sum>x\<in>s. u * ux x + v * uy x) = 1"
  1779     unfolding setsum_addf and setsum_right_distrib[symmetric] and ux(2) uy(2)
  1766     unfolding setsum_addf and setsum_right_distrib[symmetric] and ux(2) uy(2)
  1780     using uv(3) by auto
  1767     using uv(3) by auto
  2288       then have v: "0 \<le> u v"
  2275       then have v: "0 \<le> u v"
  2289         using obt(4)[THEN bspec[where x=v]] by auto
  2276         using obt(4)[THEN bspec[where x=v]] by auto
  2290       show "0 \<le> u v + t * w v"
  2277       show "0 \<le> u v + t * w v"
  2291       proof (cases "w v < 0")
  2278       proof (cases "w v < 0")
  2292         case False
  2279         case False
  2293         then show ?thesis
  2280         thus ?thesis using v `t\<ge>0` by auto
  2294           apply (rule_tac add_nonneg_nonneg)
       
  2295           using v
       
  2296           apply simp
       
  2297           apply (rule mult_nonneg_nonneg)
       
  2298           using `t\<ge>0`
       
  2299           apply auto
       
  2300           done
       
  2301       next
  2281       next
  2302         case True
  2282         case True
  2303         then have "t \<le> u v / (- w v)"
  2283         then have "t \<le> u v / (- w v)"
  2304           using `v\<in>s`
  2284           using `v\<in>s`
  2305           unfolding t_def i_def
  2285           unfolding t_def i_def
  4583       by auto
  4563       by auto
  4584     then have "\<exists>x. norm x = 1 \<and> (\<forall>y\<in>c. 0 \<le> inner y x)"
  4564     then have "\<exists>x. norm x = 1 \<and> (\<forall>y\<in>c. 0 \<le> inner y x)"
  4585       apply (rule_tac x = "inverse(norm a) *\<^sub>R a" in exI)
  4565       apply (rule_tac x = "inverse(norm a) *\<^sub>R a" in exI)
  4586       using hull_subset[of c convex]
  4566       using hull_subset[of c convex]
  4587       unfolding subset_eq and inner_scaleR
  4567       unfolding subset_eq and inner_scaleR
  4588       apply -
  4568       by (auto simp add: inner_commute del: ballE elim!: ballE)
  4589       apply rule
       
  4590       defer
       
  4591       apply rule
       
  4592       apply (rule mult_nonneg_nonneg)
       
  4593       apply (auto simp add: inner_commute del: ballE elim!: ballE)
       
  4594       done
       
  4595     then show "frontier (cball 0 1) \<inter> \<Inter>f \<noteq> {}"
  4569     then show "frontier (cball 0 1) \<inter> \<Inter>f \<noteq> {}"
  4596       unfolding c(1) frontier_cball dist_norm by auto
  4570       unfolding c(1) frontier_cball dist_norm by auto
  4597   qed (insert closed_halfspace_ge, auto)
  4571   qed (insert closed_halfspace_ge, auto)
  4598   then obtain x where "norm x = 1" "\<forall>y\<in>s. x\<in>?k y"
  4572   then obtain x where "norm x = 1" "\<forall>y\<in>s. x\<in>?k y"
  4599     unfolding frontier_cball dist_norm by auto
  4573     unfolding frontier_cball dist_norm by auto
  5979     assume as: "z\<in>cbox 0 (\<Sum>Basis)" "y = x - ?d + (2*d) *\<^sub>R z"
  5953     assume as: "z\<in>cbox 0 (\<Sum>Basis)" "y = x - ?d + (2*d) *\<^sub>R z"
  5980     have "\<And>i. i\<in>Basis \<Longrightarrow> 0 \<le> d * (z \<bullet> i) \<and> d * (z \<bullet> i) \<le> d"
  5954     have "\<And>i. i\<in>Basis \<Longrightarrow> 0 \<le> d * (z \<bullet> i) \<and> d * (z \<bullet> i) \<le> d"
  5981       using assms as(1)[unfolded mem_box]
  5955       using assms as(1)[unfolded mem_box]
  5982       apply (erule_tac x=i in ballE)
  5956       apply (erule_tac x=i in ballE)
  5983       apply rule
  5957       apply rule
  5984       apply (rule mult_nonneg_nonneg)
  5958       prefer 2
  5985       prefer 3
       
  5986       apply (rule mult_right_le_one_le)
  5959       apply (rule mult_right_le_one_le)
  5987       using assms
  5960       using assms
  5988       apply auto
  5961       apply auto
  5989       done
  5962       done
  5990     then show "y \<in> cbox (x - ?d) (x + ?d)"
  5963     then show "y \<in> cbox (x - ?d) (x + ?d)"
  8479     from xy obtain d t where
  8452     from xy obtain d t where
  8480       yc: "y = setsum (\<lambda>i. d i *\<^sub>R t i) I \<and> (\<forall>i\<in>I. d i \<ge> 0) \<and> setsum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)"
  8453       yc: "y = setsum (\<lambda>i. d i *\<^sub>R t i) I \<and> (\<forall>i\<in>I. d i \<ge> 0) \<and> setsum d I = 1 \<and> (\<forall>i\<in>I. t i \<in> S i)"
  8481       by auto
  8454       by auto
  8482     def e \<equiv> "\<lambda>i. u * c i + v * d i"
  8455     def e \<equiv> "\<lambda>i. u * c i + v * d i"
  8483     have ge0: "\<forall>i\<in>I. e i \<ge> 0"
  8456     have ge0: "\<forall>i\<in>I. e i \<ge> 0"
  8484       using e_def xc yc uv by (simp add: mult_nonneg_nonneg)
  8457       using e_def xc yc uv by simp
  8485     have "setsum (\<lambda>i. u * c i) I = u * setsum c I"
  8458     have "setsum (\<lambda>i. u * c i) I = u * setsum c I"
  8486       by (simp add: setsum_right_distrib)
  8459       by (simp add: setsum_right_distrib)
  8487     moreover have "setsum (\<lambda>i. v * d i) I = v * setsum d I"
  8460     moreover have "setsum (\<lambda>i. v * d i) I = v * setsum d I"
  8488       by (simp add: setsum_right_distrib)
  8461       by (simp add: setsum_right_distrib)
  8489     ultimately have sum1: "setsum e I = 1"
  8462     ultimately have sum1: "setsum e I = 1"
  8500         case False
  8473         case False
  8501         then show ?thesis
  8474         then show ?thesis
  8502           using mem_convex_alt[of "S i" "s i" "t i" "u * (c i)" "v * (d i)"]
  8475           using mem_convex_alt[of "S i" "s i" "t i" "u * (c i)" "v * (d i)"]
  8503             mult_nonneg_nonneg[of u "c i"] mult_nonneg_nonneg[of v "d i"]
  8476             mult_nonneg_nonneg[of u "c i"] mult_nonneg_nonneg[of v "d i"]
  8504             assms q_def e_def i False xc yc uv
  8477             assms q_def e_def i False xc yc uv
  8505           by auto
  8478           by (auto simp del: mult_nonneg_nonneg)
  8506       qed
  8479       qed
  8507     }
  8480     }
  8508     then have qs: "\<forall>i\<in>I. q i \<in> S i" by auto
  8481     then have qs: "\<forall>i\<in>I. q i \<in> S i" by auto
  8509     {
  8482     {
  8510       fix i
  8483       fix i
  8511       assume i: "i \<in> I"
  8484       assume i: "i \<in> I"
  8512       have "(u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i"
  8485       have "(u * c i) *\<^sub>R s i + (v * d i) *\<^sub>R t i = e i *\<^sub>R q i"
  8513       proof (cases "e i = 0")
  8486       proof (cases "e i = 0")
  8514         case True
  8487         case True
  8515         have ge: "u * (c i) \<ge> 0 \<and> v * d i \<ge> 0"
  8488         have ge: "u * (c i) \<ge> 0 \<and> v * d i \<ge> 0"
  8516           using xc yc uv i by (simp add: mult_nonneg_nonneg)
  8489           using xc yc uv i by simp
  8517         moreover from ge have "u * c i \<le> 0 \<and> v * d i \<le> 0"
  8490         moreover from ge have "u * c i \<le> 0 \<and> v * d i \<le> 0"
  8518           using True e_def i by simp
  8491           using True e_def i by simp
  8519         ultimately have "u * c i = 0 \<and> v * d i = 0" by auto
  8492         ultimately have "u * c i = 0 \<and> v * d i = 0" by auto
  8520         with True show ?thesis by auto
  8493         with True show ?thesis by auto
  8521       next
  8494       next