src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy
changeset 60974 6a6f15d8fbc4
parent 60809 457abb82fb9e
child 61076 bdc1e2f0a86a
equal deleted inserted replaced
60973:d94f3afd69b6 60974:6a6f15d8fbc4
  1224   then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` S = S)"
  1224   then have "0 \<in> S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` S = S)"
  1225     using cone_iff[of S] assms by auto
  1225     using cone_iff[of S] assms by auto
  1226   then have "0 \<in> closure S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` closure S = closure S)"
  1226   then have "0 \<in> closure S \<and> (\<forall>c. c > 0 \<longrightarrow> op *\<^sub>R c ` closure S = closure S)"
  1227     using closure_subset by (auto simp add: closure_scaleR)
  1227     using closure_subset by (auto simp add: closure_scaleR)
  1228   then show ?thesis
  1228   then show ?thesis
  1229     using cone_iff[of "closure S"] by auto
  1229     using False cone_iff[of "closure S"] by auto
  1230 qed
  1230 qed
  1231 
  1231 
  1232 
  1232 
  1233 subsection \<open>Affine dependence and consequential theorems (from Lars Schewe)\<close>
  1233 subsection \<open>Affine dependence and consequential theorems (from Lars Schewe)\<close>
  1234 
  1234 
  9543 apply (rename_tac uu x y z)
  9543 apply (rename_tac uu x y z)
  9544 apply (rule_tac x="\<lambda>r. (if r=a then x else if r=b then y else if r=c then z else 0)" in exI)
  9544 apply (rule_tac x="\<lambda>r. (if r=a then x else if r=b then y else if r=c then z else 0)" in exI)
  9545 apply simp
  9545 apply simp
  9546 done
  9546 done
  9547 
  9547 
       
  9548 subsection\<open>The infimum of the distance between two sets\<close>
       
  9549 
       
  9550 definition setdist :: "'a::metric_space set \<Rightarrow> 'a set \<Rightarrow> real" where
       
  9551   "setdist s t \<equiv>
       
  9552        (if s = {} \<or> t = {} then 0
       
  9553         else Inf {dist x y| x y. x \<in> s \<and> y \<in> t})"
       
  9554 
       
  9555 lemma setdist_empty1 [simp]: "setdist {} t = 0"
       
  9556   by (simp add: setdist_def)
       
  9557 
       
  9558 lemma setdist_empty2 [simp]: "setdist t {} = 0"
       
  9559   by (simp add: setdist_def)
       
  9560 
       
  9561 lemma setdist_pos_le: "0 \<le> setdist s t"
       
  9562   by (auto simp: setdist_def ex_in_conv [symmetric] intro: cInf_greatest)
       
  9563 
       
  9564 lemma le_setdistI:
       
  9565   assumes "s \<noteq> {}" "t \<noteq> {}" "\<And>x y. \<lbrakk>x \<in> s; y \<in> t\<rbrakk> \<Longrightarrow> d \<le> dist x y"
       
  9566     shows "d \<le> setdist s t"
       
  9567   using assms
       
  9568   by (auto simp: setdist_def Set.ex_in_conv [symmetric] intro: cInf_greatest)
       
  9569 
       
  9570 lemma setdist_le_dist: "\<lbrakk>x \<in> s; y \<in> t\<rbrakk> \<Longrightarrow> setdist s t \<le> dist x y"
       
  9571   unfolding setdist_def
       
  9572   by (auto intro!: bdd_belowI [where m=0] cInf_lower)
       
  9573 
       
  9574 lemma le_setdist_iff: 
       
  9575         "d \<le> setdist s t \<longleftrightarrow>
       
  9576         (\<forall>x \<in> s. \<forall>y \<in> t. d \<le> dist x y) \<and> (s = {} \<or> t = {} \<longrightarrow> d \<le> 0)"
       
  9577   apply (cases "s = {} \<or> t = {}")
       
  9578   apply (force simp add: setdist_def)
       
  9579   apply (intro iffI conjI)
       
  9580   using setdist_le_dist apply fastforce
       
  9581   apply (auto simp: intro: le_setdistI)
       
  9582   done
       
  9583 
       
  9584 lemma setdist_ltE: 
       
  9585   assumes "setdist s t < b" "s \<noteq> {}" "t \<noteq> {}"
       
  9586     obtains x y where "x \<in> s" "y \<in> t" "dist x y < b"
       
  9587 using assms
       
  9588 by (auto simp: not_le [symmetric] le_setdist_iff)
       
  9589 
       
  9590 lemma setdist_refl: "setdist s s = 0"
       
  9591   apply (cases "s = {}")
       
  9592   apply (force simp add: setdist_def)
       
  9593   apply (rule antisym [OF _ setdist_pos_le])
       
  9594   apply (metis all_not_in_conv dist_self setdist_le_dist)
       
  9595   done
       
  9596 
       
  9597 lemma setdist_sym: "setdist s t = setdist t s"
       
  9598   by (force simp: setdist_def dist_commute intro!: arg_cong [where f=Inf])
       
  9599 
       
  9600 lemma setdist_triangle: "setdist s t \<le> setdist s {a} + setdist {a} t"
       
  9601 proof (cases "s = {} \<or> t = {}")
       
  9602   case True then show ?thesis
       
  9603     using setdist_pos_le by fastforce
       
  9604 next
       
  9605   case False
       
  9606   have "\<And>x. x \<in> s \<Longrightarrow> setdist s t - dist x a \<le> setdist {a} t" 
       
  9607     apply (rule le_setdistI, blast)
       
  9608     using False apply (fastforce intro: le_setdistI)
       
  9609     apply (simp add: algebra_simps)
       
  9610     apply (metis dist_commute dist_triangle_alt order_trans [OF setdist_le_dist])
       
  9611     done
       
  9612   then have "setdist s t - setdist {a} t \<le> setdist s {a}"
       
  9613     using False by (fastforce intro: le_setdistI)
       
  9614   then show ?thesis
       
  9615     by (simp add: algebra_simps)
       
  9616 qed
       
  9617 
       
  9618 lemma setdist_singletons [simp]: "setdist {x} {y} = dist x y"
       
  9619   by (simp add: setdist_def)
       
  9620 
       
  9621 lemma setdist_Lipschitz: "abs(setdist {x} s - setdist {y} s) \<le> dist x y"
       
  9622   apply (subst setdist_singletons [symmetric])
       
  9623   by (metis abs_diff_le_iff diff_le_eq setdist_triangle setdist_sym)
       
  9624 
       
  9625 lemma continuous_at_setdist: "continuous (at x) (\<lambda>y. (setdist {y} s))"
       
  9626   by (force simp: continuous_at_eps_delta dist_real_def intro: le_less_trans [OF setdist_Lipschitz])
       
  9627 
       
  9628 lemma continuous_on_setdist: "continuous_on t (\<lambda>y. (setdist {y} s))"
       
  9629   by (metis continuous_at_setdist continuous_at_imp_continuous_on)
       
  9630 
       
  9631 lemma uniformly_continuous_on_setdist: "uniformly_continuous_on t (\<lambda>y. (setdist {y} s))"
       
  9632   by (force simp: uniformly_continuous_on_def dist_real_def intro: le_less_trans [OF setdist_Lipschitz])
       
  9633 
       
  9634 lemma setdist_subset_right: "\<lbrakk>t \<noteq> {}; t \<subseteq> u\<rbrakk> \<Longrightarrow> setdist s u \<le> setdist s t"
       
  9635   apply (cases "s = {} \<or> u = {}", force)
       
  9636   apply (auto simp: setdist_def intro!: bdd_belowI [where m=0] cInf_superset_mono)
       
  9637   done
       
  9638 
       
  9639 lemma setdist_subset_left: "\<lbrakk>s \<noteq> {}; s \<subseteq> t\<rbrakk> \<Longrightarrow> setdist t u \<le> setdist s u"
       
  9640   by (metis setdist_subset_right setdist_sym)
       
  9641 
       
  9642 lemma setdist_closure_1 [simp]: "setdist (closure s) t = setdist s t"
       
  9643 proof (cases "s = {} \<or> t = {}")
       
  9644   case True then show ?thesis by force
       
  9645 next
       
  9646   case False
       
  9647   { fix y
       
  9648     assume "y \<in> t"
       
  9649     have "continuous_on (closure s) (\<lambda>a. dist a y)"
       
  9650       by (auto simp: continuous_intros dist_norm)
       
  9651     then have *: "\<And>x. x \<in> closure s \<Longrightarrow> setdist s t \<le> dist x y"
       
  9652       apply (rule continuous_ge_on_closure)
       
  9653       apply assumption
       
  9654       apply (blast intro: setdist_le_dist `y \<in> t` )
       
  9655       done
       
  9656   } note * = this
       
  9657   show ?thesis
       
  9658     apply (rule antisym)
       
  9659      using False closure_subset apply (blast intro: setdist_subset_left)
       
  9660     using False *
       
  9661     apply (force simp add: closure_eq_empty intro!: le_setdistI)
       
  9662     done
       
  9663 qed
       
  9664 
       
  9665 lemma setdist_closure_2 [simp]: "setdist t (closure s) = setdist t s"
       
  9666 by (metis setdist_closure_1 setdist_sym)
       
  9667 
       
  9668 lemma setdist_compact_closed:
       
  9669   fixes s :: "'a::euclidean_space set"
       
  9670   assumes s: "compact s" and t: "closed t"
       
  9671       and "s \<noteq> {}" "t \<noteq> {}"
       
  9672     shows "\<exists>x \<in> s. \<exists>y \<in> t. dist x y = setdist s t"
       
  9673 proof -
       
  9674   have "{x - y |x y. x \<in> s \<and> y \<in> t} \<noteq> {}"
       
  9675     using assms by blast
       
  9676   then
       
  9677   have "\<exists>x \<in> s. \<exists>y \<in> t. dist x y \<le> setdist s t"
       
  9678     using  distance_attains_inf [where a=0, OF compact_closed_differences [OF s t]] assms
       
  9679     apply (clarsimp simp: dist_norm le_setdist_iff, blast)
       
  9680     done
       
  9681   then show ?thesis
       
  9682     by (blast intro!: antisym [OF _ setdist_le_dist] )
       
  9683 qed
       
  9684 
       
  9685 lemma setdist_closed_compact:
       
  9686   fixes s :: "'a::euclidean_space set"
       
  9687   assumes s: "closed s" and t: "compact t"
       
  9688       and "s \<noteq> {}" "t \<noteq> {}"
       
  9689     shows "\<exists>x \<in> s. \<exists>y \<in> t. dist x y = setdist s t"
       
  9690   using setdist_compact_closed [OF t s `t \<noteq> {}` `s \<noteq> {}`]
       
  9691   by (metis dist_commute setdist_sym)
       
  9692 
       
  9693 lemma setdist_eq_0I: "\<lbrakk>x \<in> s; x \<in> t\<rbrakk> \<Longrightarrow> setdist s t = 0"
       
  9694   by (metis antisym dist_self setdist_le_dist setdist_pos_le)
       
  9695 
       
  9696 lemma setdist_eq_0_compact_closed:
       
  9697   fixes s :: "'a::euclidean_space set"
       
  9698   assumes s: "compact s" and t: "closed t"
       
  9699     shows "setdist s t = 0 \<longleftrightarrow> s = {} \<or> t = {} \<or> s \<inter> t \<noteq> {}"
       
  9700   apply (cases "s = {} \<or> t = {}", force)
       
  9701   using setdist_compact_closed [OF s t]  
       
  9702   apply (force intro: setdist_eq_0I )
       
  9703   done
       
  9704 
       
  9705 corollary setdist_gt_0_compact_closed:
       
  9706   fixes s :: "'a::euclidean_space set"
       
  9707   assumes s: "compact s" and t: "closed t"
       
  9708     shows "setdist s t > 0 \<longleftrightarrow> (s \<noteq> {} \<and> t \<noteq> {} \<and> s \<inter> t = {})"
       
  9709   using setdist_pos_le [of s t] setdist_eq_0_compact_closed [OF assms]
       
  9710   by linarith
       
  9711 
       
  9712 lemma setdist_eq_0_closed_compact:
       
  9713   fixes s :: "'a::euclidean_space set"
       
  9714   assumes s: "closed s" and t: "compact t"
       
  9715     shows "setdist s t = 0 \<longleftrightarrow> s = {} \<or> t = {} \<or> s \<inter> t \<noteq> {}"
       
  9716   using setdist_eq_0_compact_closed [OF t s]
       
  9717   by (metis Int_commute setdist_sym)
       
  9718 
       
  9719 lemma setdist_eq_0_bounded:
       
  9720   fixes s :: "'a::euclidean_space set"
       
  9721   assumes "bounded s \<or> bounded t"
       
  9722     shows "setdist s t = 0 \<longleftrightarrow> s = {} \<or> t = {} \<or> closure s \<inter> closure t \<noteq> {}"
       
  9723   apply (cases "s = {} \<or> t = {}", force)
       
  9724   using setdist_eq_0_compact_closed [of "closure s" "closure t"] 
       
  9725         setdist_eq_0_closed_compact [of "closure s" "closure t"] assms 
       
  9726   apply (force simp add:  bounded_closure compact_eq_bounded_closed)
       
  9727   done
       
  9728 
       
  9729 lemma setdist_unique: 
       
  9730   "\<lbrakk>a \<in> s; b \<in> t; \<And>x y. x \<in> s \<and> y \<in> t ==> dist a b \<le> dist x y\<rbrakk>
       
  9731    \<Longrightarrow> setdist s t = dist a b"
       
  9732   by (force simp add: setdist_le_dist le_setdist_iff intro: antisym)
       
  9733 
       
  9734 lemma setdist_closest_point: 
       
  9735     "\<lbrakk>closed s; s \<noteq> {}\<rbrakk> \<Longrightarrow> setdist {a} s = dist a (closest_point s a)"
       
  9736   apply (rule setdist_unique)
       
  9737   using closest_point_le
       
  9738   apply (auto simp: closest_point_in_set)
       
  9739   done
       
  9740 
       
  9741 lemma setdist_eq_0_sing_1 [simp]: 
       
  9742   fixes s :: "'a::euclidean_space set"
       
  9743   shows "setdist {x} s = 0 \<longleftrightarrow> s = {} \<or> x \<in> closure s"
       
  9744 by (auto simp: setdist_eq_0_bounded)
       
  9745 
       
  9746 lemma setdist_eq_0_sing_2 [simp]: 
       
  9747   fixes s :: "'a::euclidean_space set"
       
  9748   shows "setdist s {x} = 0 \<longleftrightarrow> s = {} \<or> x \<in> closure s"
       
  9749 by (auto simp: setdist_eq_0_bounded)
       
  9750 
       
  9751 lemma setdist_sing_in_set:
       
  9752   fixes s :: "'a::euclidean_space set"
       
  9753   shows "x \<in> s \<Longrightarrow> setdist {x} s = 0"
       
  9754 using closure_subset by force
       
  9755 
       
  9756 lemma setdist_le_sing: "x \<in> s ==> setdist s t \<le> setdist {x} t"
       
  9757   using setdist_subset_left by auto
       
  9758 
       
  9759 
  9548 end
  9760 end