# HG changeset patch # User paulson # Date 1466002344 -3600 # Node ID 3b69758756331faf4c267e4051862fe7f0eef9dc # Parent 00a135c0a17fe1c9215dc4119ed19a95feaad171 Urysohn's lemma, Dugundji extension theorem and many other proofs diff -r 00a135c0a17f -r 3b6975875633 src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy --- a/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy Tue Jun 14 20:48:42 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Brouwer_Fixpoint.thy Wed Jun 15 15:52:24 2016 +0100 @@ -1,5 +1,5 @@ (* Author: John Harrison - Author: Robert Himmelmann, TU Muenchen (Translation from HOL light) + Author: Robert Himmelmann, TU Muenchen (Translation from HOL light) and LCP *) (* ========================================================================= *) @@ -2293,4 +2293,1073 @@ by blast qed +subsection\Absolute retracts, Etc.\ + +text\Absolute retracts (AR), absolute neighbourhood retracts (ANR) and also + Euclidean neighbourhood retracts (ENR). We define AR and ANR by + specializing the standard definitions for a set to embedding in +spaces of higher dimension. This turns out to be sufficient (since any set in +R^n can be embedded as a closed subset of a convex subset of R^{n+1}) to +derive the usual definitions, but we need to split them into two +implications because of the lack of type quantifiers. Then ENR turns out +to be equivalent to ANR plus local compactness.\ + +definition AR :: "'a::topological_space set => bool" + where + "AR S \ \U. \S'::('a * real) set. S homeomorphic S' \ closedin (subtopology euclidean U) S' + \ S' retract_of U" + +definition ANR :: "'a::topological_space set => bool" + where + "ANR S \ \U. \S'::('a * real) set. S homeomorphic S' \ closedin (subtopology euclidean U) S' + \ (\T. openin (subtopology euclidean U) T \ + S' retract_of T)" + +definition ENR :: "'a::topological_space set => bool" + where "ENR S \ \U. open U \ S retract_of U" + +text\ First, show that we do indeed get the "usual" properties of ARs and ANRs.\ + +proposition AR_imp_absolute_extensor: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "AR S" and contf: "continuous_on T f" and "f ` T \ S" + and cloUT: "closedin (subtopology euclidean U) T" + obtains g where "continuous_on U g" "g ` U \ S" "\x. x \ T \ g x = f x" +proof - + have "aff_dim S < int (DIM('b \ real))" + using aff_dim_le_DIM [of S] by simp + then obtain C and S' :: "('b * real) set" + where C: "convex C" "C \ {}" + and cloCS: "closedin (subtopology euclidean C) S'" + and hom: "S homeomorphic S'" + by (metis that homeomorphic_closedin_convex) + then have "S' retract_of C" + using \AR S\ by (simp add: AR_def) + then obtain r where "S' \ C" and contr: "continuous_on C r" + and "r ` C \ S'" and rid: "\x. x\S' \ r x = x" + by (auto simp: retraction_def retract_of_def) + obtain g h where "homeomorphism S S' g h" + using hom by (force simp: homeomorphic_def) + then have "continuous_on (f ` T) g" + by (meson \f ` T \ S\ continuous_on_subset homeomorphism_def) + then have contgf: "continuous_on T (g o f)" + by (metis continuous_on_compose contf) + have gfTC: "(g \ f) ` T \ C" + proof - + have "g ` S = S'" + by (metis (no_types) \homeomorphism S S' g h\ homeomorphism_def) + with \S' \ C\ \f ` T \ S\ show ?thesis by force + qed + obtain f' where f': "continuous_on U f'" "f' ` U \ C" + "\x. x \ T \ f' x = (g \ f) x" + by (metis Dugundji [OF C cloUT contgf gfTC]) + show ?thesis + proof (rule_tac g = "h o r o f'" in that) + show "continuous_on U (h \ r \ f')" + apply (intro continuous_on_compose f') + using continuous_on_subset contr f' apply blast + by (meson \homeomorphism S S' g h\ \r ` C \ S'\ continuous_on_subset \f' ` U \ C\ homeomorphism_def image_mono) + show "(h \ r \ f') ` U \ S" + using \homeomorphism S S' g h\ \r ` C \ S'\ \f' ` U \ C\ + by (fastforce simp: homeomorphism_def) + show "\x. x \ T \ (h \ r \ f') x = f x" + using \homeomorphism S S' g h\ \f ` T \ S\ f' + by (auto simp: rid homeomorphism_def) + qed +qed + +lemma AR_imp_absolute_retract: + fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" + assumes "AR S" "S homeomorphic S'" + and clo: "closedin (subtopology euclidean U) S'" + shows "S' retract_of U" +proof - + obtain g h where hom: "homeomorphism S S' g h" + using assms by (force simp: homeomorphic_def) + have h: "continuous_on S' h" " h ` S' \ S" + using hom homeomorphism_def apply blast + apply (metis hom equalityE homeomorphism_def) + done + obtain h' where h': "continuous_on U h'" "h' ` U \ S" + and h'h: "\x. x \ S' \ h' x = h x" + by (blast intro: AR_imp_absolute_extensor [OF \AR S\ h clo]) + have [simp]: "S' \ U" using clo closedin_limpt by blast + show ?thesis + proof (simp add: retraction_def retract_of_def, intro exI conjI) + show "continuous_on U (g o h')" + apply (intro continuous_on_compose h') + apply (meson hom continuous_on_subset h' homeomorphism_cont1) + done + show "(g \ h') ` U \ S'" + using h' by clarsimp (metis hom subsetD homeomorphism_def imageI) + show "\x\S'. (g \ h') x = x" + by clarsimp (metis h'h hom homeomorphism_def) + qed +qed + +lemma AR_imp_absolute_retract_UNIV: + fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" + assumes "AR S" and hom: "S homeomorphic S'" + and clo: "closed S'" + shows "S' retract_of UNIV" +apply (rule AR_imp_absolute_retract [OF \AR S\ hom]) +using clo closed_closedin by auto + +lemma absolute_extensor_imp_AR: + fixes S :: "'a::euclidean_space set" + assumes "\f :: 'a * real \ 'a. + \U T. \continuous_on T f; f ` T \ S; + closedin (subtopology euclidean U) T\ + \ \g. continuous_on U g \ g ` U \ S \ (\x \ T. g x = f x)" + shows "AR S" +proof (clarsimp simp: AR_def) + fix U and T :: "('a * real) set" + assume "S homeomorphic T" and clo: "closedin (subtopology euclidean U) T" + then obtain g h where hom: "homeomorphism S T g h" + by (force simp: homeomorphic_def) + have h: "continuous_on T h" " h ` T \ S" + using hom homeomorphism_def apply blast + apply (metis hom equalityE homeomorphism_def) + done + obtain h' where h': "continuous_on U h'" "h' ` U \ S" + and h'h: "\x\T. h' x = h x" + using assms [OF h clo] by blast + have [simp]: "T \ U" + using clo closedin_imp_subset by auto + show "T retract_of U" + proof (simp add: retraction_def retract_of_def, intro exI conjI) + show "continuous_on U (g o h')" + apply (intro continuous_on_compose h') + apply (meson hom continuous_on_subset h' homeomorphism_cont1) + done + show "(g \ h') ` U \ T" + using h' by clarsimp (metis hom subsetD homeomorphism_def imageI) + show "\x\T. (g \ h') x = x" + by clarsimp (metis h'h hom homeomorphism_def) + qed +qed + +lemma AR_eq_absolute_extensor: + fixes S :: "'a::euclidean_space set" + shows "AR S \ + (\f :: 'a * real \ 'a. + \U T. continuous_on T f \ f ` T \ S \ + closedin (subtopology euclidean U) T \ + (\g. continuous_on U g \ g ` U \ S \ (\x \ T. g x = f x)))" +apply (rule iffI) + apply (metis AR_imp_absolute_extensor) +apply (simp add: absolute_extensor_imp_AR) +done + +lemma AR_imp_retract: + fixes S :: "'a::euclidean_space set" + assumes "AR S \ closedin (subtopology euclidean U) S" + shows "S retract_of U" +using AR_imp_absolute_retract assms homeomorphic_refl by blast + +lemma AR_homeomorphic_AR: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "AR T" "S homeomorphic T" + shows "AR S" +unfolding AR_def +by (metis assms AR_imp_absolute_retract homeomorphic_trans [of _ S] homeomorphic_sym) + +lemma homeomorphic_AR_iff_AR: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + shows "S homeomorphic T \ AR S \ AR T" +by (metis AR_homeomorphic_AR homeomorphic_sym) + + +proposition ANR_imp_absolute_neighbourhood_extensor: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "ANR S" and contf: "continuous_on T f" and "f ` T \ S" + and cloUT: "closedin (subtopology euclidean U) T" + obtains V g where "T \ V" "openin (subtopology euclidean U) V" + "continuous_on V g" + "g ` V \ S" "\x. x \ T \ g x = f x" +proof - + have "aff_dim S < int (DIM('b \ real))" + using aff_dim_le_DIM [of S] by simp + then obtain C and S' :: "('b * real) set" + where C: "convex C" "C \ {}" + and cloCS: "closedin (subtopology euclidean C) S'" + and hom: "S homeomorphic S'" + by (metis that homeomorphic_closedin_convex) + then obtain D where opD: "openin (subtopology euclidean C) D" and "S' retract_of D" + using \ANR S\ by (auto simp: ANR_def) + then obtain r where "S' \ D" and contr: "continuous_on D r" + and "r ` D \ S'" and rid: "\x. x \ S' \ r x = x" + by (auto simp: retraction_def retract_of_def) + obtain g h where homgh: "homeomorphism S S' g h" + using hom by (force simp: homeomorphic_def) + have "continuous_on (f ` T) g" + by (meson \f ` T \ S\ continuous_on_subset homeomorphism_def homgh) + then have contgf: "continuous_on T (g o f)" + by (intro continuous_on_compose contf) + have gfTC: "(g \ f) ` T \ C" + proof - + have "g ` S = S'" + by (metis (no_types) homeomorphism_def homgh) + then show ?thesis + by (metis (no_types) assms(3) cloCS closedin_def image_comp image_mono order.trans topspace_euclidean_subtopology) + qed + obtain f' where contf': "continuous_on U f'" + and "f' ` U \ C" + and eq: "\x. x \ T \ f' x = (g \ f) x" + by (metis Dugundji [OF C cloUT contgf gfTC]) + show ?thesis + proof (rule_tac V = "{x \ U. f' x \ D}" and g = "h o r o f'" in that) + show "T \ {x \ U. f' x \ D}" + using cloUT closedin_imp_subset \S' \ D\ \f ` T \ S\ eq homeomorphism_image1 homgh + by fastforce + show ope: "openin (subtopology euclidean U) {x \ U. f' x \ D}" + using \f' ` U \ C\ by (auto simp: opD contf' continuous_openin_preimage) + have conth: "continuous_on (r ` f' ` {x \ U. f' x \ D}) h" + apply (rule continuous_on_subset [of S']) + using homeomorphism_def homgh apply blast + using \r ` D \ S'\ by blast + show "continuous_on {x \ U. f' x \ D} (h \ r \ f')" + apply (intro continuous_on_compose conth + continuous_on_subset [OF contr] continuous_on_subset [OF contf'], auto) + done + show "(h \ r \ f') ` {x \ U. f' x \ D} \ S" + using \homeomorphism S S' g h\ \f' ` U \ C\ \r ` D \ S'\ + by (auto simp: homeomorphism_def) + show "\x. x \ T \ (h \ r \ f') x = f x" + using \homeomorphism S S' g h\ \f ` T \ S\ eq + by (auto simp: rid homeomorphism_def) + qed +qed + + +corollary ANR_imp_absolute_neighbourhood_retract: + fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" + assumes "ANR S" "S homeomorphic S'" + and clo: "closedin (subtopology euclidean U) S'" + obtains V where "openin (subtopology euclidean U) V" "S' retract_of V" +proof - + obtain g h where hom: "homeomorphism S S' g h" + using assms by (force simp: homeomorphic_def) + have h: "continuous_on S' h" " h ` S' \ S" + using hom homeomorphism_def apply blast + apply (metis hom equalityE homeomorphism_def) + done + from ANR_imp_absolute_neighbourhood_extensor [OF \ANR S\ h clo] + obtain V h' where "S' \ V" and opUV: "openin (subtopology euclidean U) V" + and h': "continuous_on V h'" "h' ` V \ S" + and h'h:"\x. x \ S' \ h' x = h x" + by (blast intro: ANR_imp_absolute_neighbourhood_extensor [OF \ANR S\ h clo]) + have "S' retract_of V" + proof (simp add: retraction_def retract_of_def, intro exI conjI \S' \ V\) + show "continuous_on V (g o h')" + apply (intro continuous_on_compose h') + apply (meson hom continuous_on_subset h' homeomorphism_cont1) + done + show "(g \ h') ` V \ S'" + using h' by clarsimp (metis hom subsetD homeomorphism_def imageI) + show "\x\S'. (g \ h') x = x" + by clarsimp (metis h'h hom homeomorphism_def) + qed + then show ?thesis + by (rule that [OF opUV]) +qed + +corollary ANR_imp_absolute_neighbourhood_retract_UNIV: + fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" + assumes "ANR S" and hom: "S homeomorphic S'" and clo: "closed S'" + obtains V where "open V" "S' retract_of V" + using ANR_imp_absolute_neighbourhood_retract [OF \ANR S\ hom] +by (metis clo closed_closedin open_openin subtopology_UNIV) + +lemma absolute_neighbourhood_extensor_imp_ANR: + fixes S :: "'a::euclidean_space set" + assumes "\f :: 'a * real \ 'a. + \U T. \continuous_on T f; f ` T \ S; + closedin (subtopology euclidean U) T\ + \ \V g. T \ V \ openin (subtopology euclidean U) V \ + continuous_on V g \ g ` V \ S \ (\x \ T. g x = f x)" + shows "ANR S" +proof (clarsimp simp: ANR_def) + fix U and T :: "('a * real) set" + assume "S homeomorphic T" and clo: "closedin (subtopology euclidean U) T" + then obtain g h where hom: "homeomorphism S T g h" + by (force simp: homeomorphic_def) + have h: "continuous_on T h" " h ` T \ S" + using hom homeomorphism_def apply blast + apply (metis hom equalityE homeomorphism_def) + done + obtain V h' where "T \ V" and opV: "openin (subtopology euclidean U) V" + and h': "continuous_on V h'" "h' ` V \ S" + and h'h: "\x\T. h' x = h x" + using assms [OF h clo] by blast + have [simp]: "T \ U" + using clo closedin_imp_subset by auto + have "T retract_of V" + proof (simp add: retraction_def retract_of_def, intro exI conjI \T \ V\) + show "continuous_on V (g o h')" + apply (intro continuous_on_compose h') + apply (meson hom continuous_on_subset h' homeomorphism_cont1) + done + show "(g \ h') ` V \ T" + using h' by clarsimp (metis hom subsetD homeomorphism_def imageI) + show "\x\T. (g \ h') x = x" + by clarsimp (metis h'h hom homeomorphism_def) + qed + then show "\V. openin (subtopology euclidean U) V \ T retract_of V" + using opV by blast +qed + +lemma ANR_eq_absolute_neighbourhood_extensor: + fixes S :: "'a::euclidean_space set" + shows "ANR S \ + (\f :: 'a * real \ 'a. + \U T. continuous_on T f \ f ` T \ S \ + closedin (subtopology euclidean U) T \ + (\V g. T \ V \ openin (subtopology euclidean U) V \ + continuous_on V g \ g ` V \ S \ (\x \ T. g x = f x)))" +apply (rule iffI) + apply (metis ANR_imp_absolute_neighbourhood_extensor) +apply (simp add: absolute_neighbourhood_extensor_imp_ANR) +done + +lemma ANR_imp_neighbourhood_retract: + fixes S :: "'a::euclidean_space set" + assumes "ANR S" "closedin (subtopology euclidean U) S" + obtains V where "openin (subtopology euclidean U) V" "S retract_of V" +using ANR_imp_absolute_neighbourhood_retract assms homeomorphic_refl by blast + +lemma ANR_imp_absolute_closed_neighbourhood_retract: + fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" + assumes "ANR S" "S homeomorphic S'" and US': "closedin (subtopology euclidean U) S'" + obtains V W + where "openin (subtopology euclidean U) V" + "closedin (subtopology euclidean U) W" + "S' \ V" "V \ W" "S' retract_of W" +proof - + obtain Z where "openin (subtopology euclidean U) Z" and S'Z: "S' retract_of Z" + by (blast intro: assms ANR_imp_absolute_neighbourhood_retract) + then have UUZ: "closedin (subtopology euclidean U) (U - Z)" + by auto + have "S' \ (U - Z) = {}" + using \S' retract_of Z\ closedin_retract closedin_subtopology by fastforce + then obtain V W + where "openin (subtopology euclidean U) V" + and "openin (subtopology euclidean U) W" + and "S' \ V" "U - Z \ W" "V \ W = {}" + using separation_normal_local [OF US' UUZ] by auto + moreover have "S' retract_of U - W" + apply (rule retract_of_subset [OF S'Z]) + using US' \S' \ V\ \V \ W = {}\ closedin_subset apply fastforce + using Diff_subset_conv \U - Z \ W\ by blast + ultimately show ?thesis + apply (rule_tac V=V and W = "U-W" in that) + using openin_imp_subset apply (force simp:)+ + done +qed + +lemma ANR_imp_closed_neighbourhood_retract: + fixes S :: "'a::euclidean_space set" + assumes "ANR S" "closedin (subtopology euclidean U) S" + obtains V W where "openin (subtopology euclidean U) V" + "closedin (subtopology euclidean U) W" + "S \ V" "V \ W" "S retract_of W" +by (meson ANR_imp_absolute_closed_neighbourhood_retract assms homeomorphic_refl) + +lemma ANR_homeomorphic_ANR: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "ANR T" "S homeomorphic T" + shows "ANR S" +unfolding ANR_def +by (metis assms ANR_imp_absolute_neighbourhood_retract homeomorphic_trans [of _ S] homeomorphic_sym) + +lemma homeomorphic_ANR_iff_ANR: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + shows "S homeomorphic T \ ANR S \ ANR T" +by (metis ANR_homeomorphic_ANR homeomorphic_sym) + +subsection\ Analogous properties of ENRs.\ + +proposition ENR_imp_absolute_neighbourhood_retract: + fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" + assumes "ENR S" and hom: "S homeomorphic S'" + and "S' \ U" + obtains V where "openin (subtopology euclidean U) V" "S' retract_of V" +proof - + obtain X where "open X" "S retract_of X" + using \ENR S\ by (auto simp: ENR_def) + then obtain r where "retraction X S r" + by (auto simp: retract_of_def) + have "locally compact S'" + using retract_of_locally_compact open_imp_locally_compact + homeomorphic_local_compactness \S retract_of X\ \open X\ hom by blast + then obtain W where UW: "openin (subtopology euclidean U) W" + and WS': "closedin (subtopology euclidean W) S'" + apply (rule locally_compact_closedin_open) + apply (rename_tac W) + apply (rule_tac W = "U \ W" in that, blast) + by (simp add: \S' \ U\ closedin_limpt) + obtain f g where hom: "homeomorphism S S' f g" + using assms by (force simp: homeomorphic_def) + have contg: "continuous_on S' g" + using hom homeomorphism_def by blast + moreover have "g ` S' \ S" by (metis hom equalityE homeomorphism_def) + ultimately obtain h where conth: "continuous_on W h" and hg: "\x. x \ S' \ h x = g x" + using Tietze_unbounded [of S' g W] WS' by blast + have "W \ U" using UW openin_open by auto + have "S' \ W" using WS' closedin_closed by auto + have him: "\x. x \ S' \ h x \ X" + by (metis (no_types) \S retract_of X\ hg hom homeomorphism_def image_insert insert_absorb insert_iff retract_of_imp_subset subset_eq) + have "S' retract_of {x \ W. h x \ X}" + proof (simp add: retraction_def retract_of_def, intro exI conjI) + show "S' \ {x \ W. h x \ X}" + using him WS' closedin_imp_subset by blast + show "continuous_on {x \ W. h x \ X} (f o r o h)" + proof (intro continuous_on_compose) + show "continuous_on {x \ W. h x \ X} h" + by (metis (no_types) Collect_restrict conth continuous_on_subset) + show "continuous_on (h ` {x \ W. h x \ X}) r" + proof - + have "h ` {b \ W. h b \ X} \ X" + by blast + then show "continuous_on (h ` {b \ W. h b \ X}) r" + by (meson \retraction X S r\ continuous_on_subset retraction) + qed + show "continuous_on (r ` h ` {x \ W. h x \ X}) f" + apply (rule continuous_on_subset [of S]) + using hom homeomorphism_def apply blast + apply clarify + apply (meson \retraction X S r\ subsetD imageI retraction_def) + done + qed + show "(f \ r \ h) ` {x \ W. h x \ X} \ S'" + using \retraction X S r\ hom + by (auto simp: retraction_def homeomorphism_def) + show "\x\S'. (f \ r \ h) x = x" + using \retraction X S r\ hom by (auto simp: retraction_def homeomorphism_def hg) + qed + then show ?thesis + apply (rule_tac V = "{x. x \ W \ h x \ X}" in that) + apply (rule openin_trans [OF _ UW]) + using \continuous_on W h\ \open X\ continuous_openin_preimage_eq apply blast+ + done +qed + +corollary ENR_imp_absolute_neighbourhood_retract_UNIV: + fixes S :: "'a::euclidean_space set" and S' :: "'b::euclidean_space set" + assumes "ENR S" "S homeomorphic S'" + obtains T' where "open T'" "S' retract_of T'" +by (metis ENR_imp_absolute_neighbourhood_retract UNIV_I assms(1) assms(2) open_openin subsetI subtopology_UNIV) + +lemma ENR_homeomorphic_ENR: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "ENR T" "S homeomorphic T" + shows "ENR S" +unfolding ENR_def +by (meson ENR_imp_absolute_neighbourhood_retract_UNIV assms homeomorphic_sym) + +lemma homeomorphic_ENR_iff_ENR: + fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set" + assumes "S homeomorphic T" + shows "ENR S \ ENR T" +by (meson ENR_homeomorphic_ENR assms homeomorphic_sym) + +lemma ENR_translation: + fixes S :: "'a::euclidean_space set" + shows "ENR(image (\x. a + x) S) \ ENR S" +by (meson homeomorphic_sym homeomorphic_translation homeomorphic_ENR_iff_ENR) + +lemma ENR_linear_image_eq: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "linear f" "inj f" + shows "ENR (image f S) \ ENR S" +apply (rule homeomorphic_ENR_iff_ENR) +using assms homeomorphic_sym linear_homeomorphic_image by auto + +subsection\Some relations among the concepts\ + +text\We also relate AR to being a retract of UNIV, which is often a more convenient proxy in the closed case.\ + +lemma AR_imp_ANR: "AR S \ ANR S" + using ANR_def AR_def by fastforce + +lemma ENR_imp_ANR: + fixes S :: "'a::euclidean_space set" + shows "ENR S \ ANR S" +apply (simp add: ANR_def) +by (metis ENR_imp_absolute_neighbourhood_retract closedin_imp_subset) + +lemma ENR_ANR: + fixes S :: "'a::euclidean_space set" + shows "ENR S \ ANR S \ locally compact S" +proof + assume "ENR S" + then have "locally compact S" + using ENR_def open_imp_locally_compact retract_of_locally_compact by auto + then show "ANR S \ locally compact S" + using ENR_imp_ANR \ENR S\ by blast +next + assume "ANR S \ locally compact S" + then have "ANR S" "locally compact S" by auto + then obtain T :: "('a * real) set" where "closed T" "S homeomorphic T" + using locally_compact_homeomorphic_closed + by (metis DIM_prod DIM_real Suc_eq_plus1 lessI) + then show "ENR S" + using \ANR S\ + apply (simp add: ANR_def) + apply (drule_tac x=UNIV in spec) + apply (drule_tac x=T in spec) + apply (auto simp: closed_closedin) + apply (meson ENR_def ENR_homeomorphic_ENR open_openin) + done +qed + + +proposition AR_ANR: + fixes S :: "'a::euclidean_space set" + shows "AR S \ ANR S \ contractible S \ S \ {}" + (is "?lhs = ?rhs") +proof + assume ?lhs + obtain C and S' :: "('a * real) set" + where "convex C" "C \ {}" "closedin (subtopology euclidean C) S'" "S homeomorphic S'" + apply (rule homeomorphic_closedin_convex [of S, where 'n = "'a * real"]) + using aff_dim_le_DIM [of S] by auto + with \AR S\ have "contractible S" + apply (simp add: AR_def) + apply (drule_tac x=C in spec) + apply (drule_tac x="S'" in spec, simp) + using convex_imp_contractible homeomorphic_contractible_eq retract_of_contractible by fastforce + with \AR S\ show ?rhs + apply (auto simp: AR_imp_ANR) + apply (force simp: AR_def) + done +next + assume ?rhs + then obtain a and h:: "real \ 'a \ 'a" + where conth: "continuous_on ({0..1} \ S) h" + and hS: "h ` ({0..1} \ S) \ S" + and [simp]: "\x. h(0, x) = x" + and [simp]: "\x. h(1, x) = a" + and "ANR S" "S \ {}" + by (auto simp: contractible_def homotopic_with_def) + then have "a \ S" + by (metis all_not_in_conv atLeastAtMost_iff image_subset_iff mem_Sigma_iff order_refl zero_le_one) + have "\g. continuous_on W g \ g ` W \ S \ (\x\T. g x = f x)" + if f: "continuous_on T f" "f ` T \ S" + and WT: "closedin (subtopology euclidean W) T" + for W T and f :: "'a \ real \ 'a" + proof - + obtain U g + where "T \ U" and WU: "openin (subtopology euclidean W) U" + and contg: "continuous_on U g" + and "g ` U \ S" and gf: "\x. x \ T \ g x = f x" + using iffD1 [OF ANR_eq_absolute_neighbourhood_extensor \ANR S\, rule_format, OF f WT] + by auto + have WWU: "closedin (subtopology euclidean W) (W - U)" + using WU closedin_diff by fastforce + moreover have "(W - U) \ T = {}" + using \T \ U\ by auto + ultimately obtain V V' + where WV': "openin (subtopology euclidean W) V'" + and WV: "openin (subtopology euclidean W) V" + and "W - U \ V'" "T \ V" "V' \ V = {}" + using separation_normal_local [of W "W-U" T] WT by blast + then have WVT: "T \ (W - V) = {}" + by auto + have WWV: "closedin (subtopology euclidean W) (W - V)" + using WV closedin_diff by fastforce + obtain j :: " 'a \ real \ real" + where contj: "continuous_on W j" + and j: "\x. x \ W \ j x \ {0..1}" + and j0: "\x. x \ W - V \ j x = 1" + and j1: "\x. x \ T \ j x = 0" + by (rule Urysohn_local [OF WT WWV WVT, of 0 "1::real"]) (auto simp: in_segment) + have Weq: "W = (W - V) \ (W - V')" + using \V' \ V = {}\ by force + show ?thesis + proof (intro conjI exI) + have *: "continuous_on (W - V') (\x. h (j x, g x))" + apply (rule continuous_on_compose2 [OF conth continuous_on_Pair]) + apply (rule continuous_on_subset [OF contj Diff_subset]) + apply (rule continuous_on_subset [OF contg]) + apply (metis Diff_subset_conv Un_commute \W - U \ V'\) + using j \g ` U \ S\ \W - U \ V'\ apply fastforce + done + show "continuous_on W (\x. if x \ W - V then a else h (j x, g x))" + apply (subst Weq) + apply (rule continuous_on_cases_local) + apply (simp_all add: Weq [symmetric] WWV continuous_on_const *) + using WV' closedin_diff apply fastforce + apply (auto simp: j0 j1) + done + next + have "h (j (x, y), g (x, y)) \ S" if "(x, y) \ W" "(x, y) \ V" for x y + proof - + have "j(x, y) \ {0..1}" + using j that by blast + moreover have "g(x, y) \ S" + using \V' \ V = {}\ \W - U \ V'\ \g ` U \ S\ that by fastforce + ultimately show ?thesis + using hS by blast + qed + with \a \ S\ \g ` U \ S\ + show "(\x. if x \ W - V then a else h (j x, g x)) ` W \ S" + by auto + next + show "\x\T. (if x \ W - V then a else h (j x, g x)) = f x" + using \T \ V\ by (auto simp: j0 j1 gf) + qed + qed + then show ?lhs + by (simp add: AR_eq_absolute_extensor) +qed + + +lemma ANR_retract_of_ANR: + fixes S :: "'a::euclidean_space set" + assumes "ANR T" "S retract_of T" + shows "ANR S" +using assms +apply (simp add: ANR_eq_absolute_neighbourhood_extensor retract_of_def retraction_def) +apply (clarsimp elim!: all_forward) +apply (erule impCE, metis subset_trans) +apply (clarsimp elim!: ex_forward) +apply (rule_tac x="r o g" in exI) +by (metis comp_apply continuous_on_compose continuous_on_subset subsetD imageI image_comp image_mono subset_trans) + +lemma AR_retract_of_AR: + fixes S :: "'a::euclidean_space set" + shows "\AR T; S retract_of T\ \ AR S" +using ANR_retract_of_ANR AR_ANR retract_of_contractible by fastforce + +lemma ENR_retract_of_ENR: + "\ENR T; S retract_of T\ \ ENR S" +by (meson ENR_def retract_of_trans) + +lemma retract_of_UNIV: + fixes S :: "'a::euclidean_space set" + shows "S retract_of UNIV \ AR S \ closed S" +by (metis AR_ANR AR_imp_retract ENR_def ENR_imp_ANR closed_UNIV closed_closedin contractible_UNIV empty_not_UNIV open_UNIV retract_of_closed retract_of_contractible retract_of_empty(1) subtopology_UNIV) + +lemma compact_AR [simp]: + fixes S :: "'a::euclidean_space set" + shows "compact S \ AR S \ compact S \ S retract_of UNIV" +using compact_imp_closed retract_of_UNIV by blast + +subsection\More properties of ARs, ANRs and ENRs\ + +lemma not_AR_empty [simp]: "~ AR({})" + by (auto simp: AR_def) + +lemma ENR_empty [simp]: "ENR {}" + by (simp add: ENR_def) + +lemma ANR_empty [simp]: "ANR ({} :: 'a::euclidean_space set)" + by (simp add: ENR_imp_ANR) + +lemma convex_imp_AR: + fixes S :: "'a::euclidean_space set" + shows "\convex S; S \ {}\ \ AR S" +apply (rule absolute_extensor_imp_AR) +apply (rule Dugundji, assumption+) +by blast + +lemma convex_imp_ANR: + fixes S :: "'a::euclidean_space set" + shows "convex S \ ANR S" +using ANR_empty AR_imp_ANR convex_imp_AR by blast + +lemma ENR_convex_closed: + fixes S :: "'a::euclidean_space set" + shows "\closed S; convex S\ \ ENR S" +using ENR_def ENR_empty convex_imp_AR retract_of_UNIV by blast + +lemma AR_UNIV [simp]: "AR (UNIV :: 'a::euclidean_space set)" + using retract_of_UNIV by auto + +lemma ANR_UNIV [simp]: "ANR (UNIV :: 'a::euclidean_space set)" + by (simp add: AR_imp_ANR) + +lemma ENR_UNIV [simp]:"ENR UNIV" + using ENR_def by blast + +lemma AR_singleton: + fixes a :: "'a::euclidean_space" + shows "AR {a}" + using retract_of_UNIV by blast + +lemma ANR_singleton: + fixes a :: "'a::euclidean_space" + shows "ANR {a}" + by (simp add: AR_imp_ANR AR_singleton) + +lemma ENR_singleton: "ENR {a}" + using ENR_def by blast + +subsection\ARs closed under union\ + +lemma AR_closed_Un_local_aux: + fixes U :: "'a::euclidean_space set" + assumes "closedin (subtopology euclidean U) S" + "closedin (subtopology euclidean U) T" + "AR S" "AR T" "AR(S \ T)" + shows "(S \ T) retract_of U" +proof - + have "S \ T \ {}" + using assms AR_def by fastforce + have "S \ U" "T \ U" + using assms by (auto simp: closedin_imp_subset) + define S' where "S' \ {x \ U. setdist {x} S \ setdist {x} T}" + define T' where "T' \ {x \ U. setdist {x} T \ setdist {x} S}" + define W where "W \ {x \ U. setdist {x} S = setdist {x} T}" + have US': "closedin (subtopology euclidean U) S'" + using continuous_closedin_preimage [of U "\x. setdist {x} S - setdist {x} T" "{..0}"] + by (simp add: S'_def continuous_intros) + have UT': "closedin (subtopology euclidean U) T'" + using continuous_closedin_preimage [of U "\x. setdist {x} T - setdist {x} S" "{..0}"] + by (simp add: T'_def continuous_intros) + have "S \ S'" + using S'_def \S \ U\ setdist_sing_in_set by fastforce + have "T \ T'" + using T'_def \T \ U\ setdist_sing_in_set by fastforce + have "S \ T \ W" "W \ U" + using \S \ U\ by (auto simp: W_def setdist_sing_in_set) + have "(S \ T) retract_of W" + apply (rule AR_imp_absolute_retract [OF \AR(S \ T)\]) + apply (simp add: homeomorphic_refl) + apply (rule closedin_subset_trans [of U]) + apply (simp_all add: assms closedin_Int \S \ T \ W\ \W \ U\) + done + then obtain r0 + where "S \ T \ W" and contr0: "continuous_on W r0" + and "r0 ` W \ S \ T" + and r0 [simp]: "\x. x \ S \ T \ r0 x = x" + by (auto simp: retract_of_def retraction_def) + have ST: "x \ W \ x \ S \ x \ T" for x + using setdist_eq_0_closedin \S \ T \ {}\ assms + by (force simp: W_def setdist_sing_in_set) + have "S' \ T' = W" + by (auto simp: S'_def T'_def W_def) + then have cloUW: "closedin (subtopology euclidean U) W" + using closedin_Int US' UT' by blast + define r where "r \ \x. if x \ W then r0 x else x" + have "r ` (W \ S) \ S" "r ` (W \ T) \ T" + using \r0 ` W \ S \ T\ r_def by auto + have contr: "continuous_on (W \ (S \ T)) r" + unfolding r_def + proof (rule continuous_on_cases_local [OF _ _ contr0 continuous_on_id]) + show "closedin (subtopology euclidean (W \ (S \ T))) W" + using \S \ U\ \T \ U\ \W \ U\ \closedin (subtopology euclidean U) W\ closedin_subset_trans by fastforce + show "closedin (subtopology euclidean (W \ (S \ T))) (S \ T)" + by (meson \S \ U\ \T \ U\ \W \ U\ assms closedin_Un closedin_subset_trans sup.bounded_iff sup.cobounded2) + show "\x. x \ W \ x \ W \ x \ S \ T \ x \ W \ r0 x = x" + by (auto simp: ST) + qed + have cloUWS: "closedin (subtopology euclidean U) (W \ S)" + by (simp add: cloUW assms closedin_Un) + obtain g where contg: "continuous_on U g" + and "g ` U \ S" and geqr: "\x. x \ W \ S \ g x = r x" + apply (rule AR_imp_absolute_extensor [OF \AR S\ _ _ cloUWS]) + apply (rule continuous_on_subset [OF contr]) + using \r ` (W \ S) \ S\ apply auto + done + have cloUWT: "closedin (subtopology euclidean U) (W \ T)" + by (simp add: cloUW assms closedin_Un) + obtain h where conth: "continuous_on U h" + and "h ` U \ T" and heqr: "\x. x \ W \ T \ h x = r x" + apply (rule AR_imp_absolute_extensor [OF \AR T\ _ _ cloUWT]) + apply (rule continuous_on_subset [OF contr]) + using \r ` (W \ T) \ T\ apply auto + done + have "U = S' \ T'" + by (force simp: S'_def T'_def) + then have cont: "continuous_on U (\x. if x \ S' then g x else h x)" + apply (rule ssubst) + apply (rule continuous_on_cases_local) + using US' UT' \S' \ T' = W\ \U = S' \ T'\ + contg conth continuous_on_subset geqr heqr apply auto + done + have UST: "(\x. if x \ S' then g x else h x) ` U \ S \ T" + using \g ` U \ S\ \h ` U \ T\ by auto + show ?thesis + apply (simp add: retract_of_def retraction_def \S \ U\ \T \ U\) + apply (rule_tac x="\x. if x \ S' then g x else h x" in exI) + apply (intro conjI cont UST) + by (metis IntI ST Un_iff \S \ S'\ \S' \ T' = W\ \T \ T'\ subsetD geqr heqr r0 r_def) +qed + + +proposition AR_closed_Un_local: + fixes S :: "'a::euclidean_space set" + assumes STS: "closedin (subtopology euclidean (S \ T)) S" + and STT: "closedin (subtopology euclidean (S \ T)) T" + and "AR S" "AR T" "AR(S \ T)" + shows "AR(S \ T)" +proof - + have "C retract_of U" + if hom: "S \ T homeomorphic C" and UC: "closedin (subtopology euclidean U) C" + for U and C :: "('a * real) set" + proof - + obtain f g where hom: "homeomorphism (S \ T) C f g" + using hom by (force simp: homeomorphic_def) + have US: "closedin (subtopology euclidean U) {x \ C. g x \ S}" + apply (rule closedin_trans [OF _ UC]) + apply (rule continuous_closedin_preimage_gen [OF _ _ STS]) + using hom homeomorphism_def apply blast + apply (metis hom homeomorphism_def set_eq_subset) + done + have UT: "closedin (subtopology euclidean U) {x \ C. g x \ T}" + apply (rule closedin_trans [OF _ UC]) + apply (rule continuous_closedin_preimage_gen [OF _ _ STT]) + using hom homeomorphism_def apply blast + apply (metis hom homeomorphism_def set_eq_subset) + done + have ARS: "AR {x \ C. g x \ S}" + apply (rule AR_homeomorphic_AR [OF \AR S\]) + apply (simp add: homeomorphic_def) + apply (rule_tac x=g in exI) + apply (rule_tac x=f in exI) + using hom apply (auto simp: homeomorphism_def elim!: continuous_on_subset) + apply (rule_tac x="f x" in image_eqI, auto) + done + have ART: "AR {x \ C. g x \ T}" + apply (rule AR_homeomorphic_AR [OF \AR T\]) + apply (simp add: homeomorphic_def) + apply (rule_tac x=g in exI) + apply (rule_tac x=f in exI) + using hom apply (auto simp: homeomorphism_def elim!: continuous_on_subset) + apply (rule_tac x="f x" in image_eqI, auto) + done + have ARI: "AR ({x \ C. g x \ S} \ {x \ C. g x \ T})" + apply (rule AR_homeomorphic_AR [OF \AR (S \ T)\]) + apply (simp add: homeomorphic_def) + apply (rule_tac x=g in exI) + apply (rule_tac x=f in exI) + using hom + apply (auto simp: homeomorphism_def elim!: continuous_on_subset) + apply (rule_tac x="f x" in image_eqI, auto) + done + have "C = {x \ C. g x \ S} \ {x \ C. g x \ T}" + using hom by (auto simp: homeomorphism_def) + then show ?thesis + by (metis AR_closed_Un_local_aux [OF US UT ARS ART ARI]) + qed + then show ?thesis + by (force simp: AR_def) +qed + +corollary AR_closed_Un: + fixes S :: "'a::euclidean_space set" + shows "\closed S; closed T; AR S; AR T; AR (S \ T)\ \ AR (S \ T)" +by (metis AR_closed_Un_local_aux closed_closedin retract_of_UNIV subtopology_UNIV) + +subsection\ANRs closed under union\ + +lemma ANR_closed_Un_local_aux: + fixes U :: "'a::euclidean_space set" + assumes US: "closedin (subtopology euclidean U) S" + and UT: "closedin (subtopology euclidean U) T" + and "ANR S" "ANR T" "ANR(S \ T)" + obtains V where "openin (subtopology euclidean U) V" "(S \ T) retract_of V" +proof (cases "S = {} \ T = {}") + case True with assms that show ?thesis + by (auto simp: intro: ANR_imp_neighbourhood_retract) +next + case False + then have [simp]: "S \ {}" "T \ {}" by auto + have "S \ U" "T \ U" + using assms by (auto simp: closedin_imp_subset) + define S' where "S' \ {x \ U. setdist {x} S \ setdist {x} T}" + define T' where "T' \ {x \ U. setdist {x} T \ setdist {x} S}" + define W where "W \ {x \ U. setdist {x} S = setdist {x} T}" + have cloUS': "closedin (subtopology euclidean U) S'" + using continuous_closedin_preimage [of U "\x. setdist {x} S - setdist {x} T" "{..0}"] + by (simp add: S'_def continuous_intros) + have cloUT': "closedin (subtopology euclidean U) T'" + using continuous_closedin_preimage [of U "\x. setdist {x} T - setdist {x} S" "{..0}"] + by (simp add: T'_def continuous_intros) + have "S \ S'" + using S'_def \S \ U\ setdist_sing_in_set by fastforce + have "T \ T'" + using T'_def \T \ U\ setdist_sing_in_set by fastforce + have "S' \ T' = U" + by (auto simp: S'_def T'_def) + have "W \ S'" + by (simp add: Collect_mono S'_def W_def) + have "W \ T'" + by (simp add: Collect_mono T'_def W_def) + have ST_W: "S \ T \ W" and "W \ U" + using \S \ U\ by (force simp: W_def setdist_sing_in_set)+ + have "S' \ T' = W" + by (auto simp: S'_def T'_def W_def) + then have cloUW: "closedin (subtopology euclidean U) W" + using closedin_Int cloUS' cloUT' by blast + obtain W' W0 where "openin (subtopology euclidean W) W'" + and cloWW0: "closedin (subtopology euclidean W) W0" + and "S \ T \ W'" "W' \ W0" + and ret: "(S \ T) retract_of W0" + apply (rule ANR_imp_closed_neighbourhood_retract [OF \ANR(S \ T)\]) + apply (rule closedin_subset_trans [of U, OF _ ST_W \W \ U\]) + apply (blast intro: assms)+ + done + then obtain U0 where opeUU0: "openin (subtopology euclidean U) U0" + and U0: "S \ T \ U0" "U0 \ W \ W0" + unfolding openin_open using \W \ U\ by blast + have "W0 \ U" + using \W \ U\ cloWW0 closedin_subset by fastforce + obtain r0 + where "S \ T \ W0" and contr0: "continuous_on W0 r0" and "r0 ` W0 \ S \ T" + and r0 [simp]: "\x. x \ S \ T \ r0 x = x" + using ret by (force simp add: retract_of_def retraction_def) + have ST: "x \ W \ x \ S \ x \ T" for x + using assms by (auto simp: W_def setdist_sing_in_set dest!: setdist_eq_0_closedin) + define r where "r \ \x. if x \ W0 then r0 x else x" + have "r ` (W0 \ S) \ S" "r ` (W0 \ T) \ T" + using \r0 ` W0 \ S \ T\ r_def by auto + have contr: "continuous_on (W0 \ (S \ T)) r" + unfolding r_def + proof (rule continuous_on_cases_local [OF _ _ contr0 continuous_on_id]) + show "closedin (subtopology euclidean (W0 \ (S \ T))) W0" + apply (rule closedin_subset_trans [of U]) + using cloWW0 cloUW closedin_trans \W0 \ U\ \S \ U\ \T \ U\ apply blast+ + done + show "closedin (subtopology euclidean (W0 \ (S \ T))) (S \ T)" + by (meson \S \ U\ \T \ U\ \W0 \ U\ assms closedin_Un closedin_subset_trans sup.bounded_iff sup.cobounded2) + show "\x. x \ W0 \ x \ W0 \ x \ S \ T \ x \ W0 \ r0 x = x" + using ST cloWW0 closedin_subset by fastforce + qed + have cloS'WS: "closedin (subtopology euclidean S') (W0 \ S)" + by (meson closedin_subset_trans US cloUS' \S \ S'\ \W \ S'\ cloUW cloWW0 + closedin_Un closedin_imp_subset closedin_trans) + obtain W1 g where "W0 \ S \ W1" and contg: "continuous_on W1 g" + and opeSW1: "openin (subtopology euclidean S') W1" + and "g ` W1 \ S" and geqr: "\x. x \ W0 \ S \ g x = r x" + apply (rule ANR_imp_absolute_neighbourhood_extensor [OF \ANR S\ _ \r ` (W0 \ S) \ S\ cloS'WS]) + apply (rule continuous_on_subset [OF contr]) + apply (blast intro: elim: )+ + done + have cloT'WT: "closedin (subtopology euclidean T') (W0 \ T)" + by (meson closedin_subset_trans UT cloUT' \T \ T'\ \W \ T'\ cloUW cloWW0 + closedin_Un closedin_imp_subset closedin_trans) + obtain W2 h where "W0 \ T \ W2" and conth: "continuous_on W2 h" + and opeSW2: "openin (subtopology euclidean T') W2" + and "h ` W2 \ T" and heqr: "\x. x \ W0 \ T \ h x = r x" + apply (rule ANR_imp_absolute_neighbourhood_extensor [OF \ANR T\ _ \r ` (W0 \ T) \ T\ cloT'WT]) + apply (rule continuous_on_subset [OF contr]) + apply (blast intro: elim: )+ + done + have "S' \ T' = W" + by (force simp: S'_def T'_def W_def) + obtain O1 O2 where "open O1" "W1 = S' \ O1" "open O2" "W2 = T' \ O2" + using opeSW1 opeSW2 by (force simp add: openin_open) + show ?thesis + proof + have eq: "W1 - (W - U0) \ (W2 - (W - U0)) = + ((U - T') \ O1 \ (U - S') \ O2 \ U \ O1 \ O2) - (W - U0)" + using \U0 \ W \ W0\ \W0 \ S \ W1\ \W0 \ T \ W2\ + by (auto simp: \S' \ T' = U\ [symmetric] \S' \ T' = W\ [symmetric] \W1 = S' \ O1\ \W2 = T' \ O2\) + show "openin (subtopology euclidean U) (W1 - (W - U0) \ (W2 - (W - U0)))" + apply (subst eq) + apply (intro openin_Un openin_Int_open openin_diff closedin_diff cloUW opeUU0 cloUS' cloUT' \open O1\ \open O2\) + apply simp_all + done + have cloW1: "closedin (subtopology euclidean (W1 - (W - U0) \ (W2 - (W - U0)))) (W1 - (W - U0))" + using cloUS' apply (simp add: closedin_closed) + apply (erule ex_forward) + using U0 \W0 \ S \ W1\ + apply (auto simp add: \W1 = S' \ O1\ \W2 = T' \ O2\ \S' \ T' = U\ [symmetric]\S' \ T' = W\ [symmetric]) + done + have cloW2: "closedin (subtopology euclidean (W1 - (W - U0) \ (W2 - (W - U0)))) (W2 - (W - U0))" + using cloUT' apply (simp add: closedin_closed) + apply (erule ex_forward) + using U0 \W0 \ T \ W2\ + apply (auto simp add: \W1 = S' \ O1\ \W2 = T' \ O2\ \S' \ T' = U\ [symmetric]\S' \ T' = W\ [symmetric]) + done + have *: "\x\S \ T. (if x \ S' then g x else h x) = x" + using ST \S' \ T' = W\ cloT'WT closedin_subset geqr heqr + apply (auto simp: r_def) + apply fastforce + using \S \ S'\ \T \ T'\ \W0 \ S \ W1\ \W1 = S' \ O1\ by auto + have "\r. continuous_on (W1 - (W - U0) \ (W2 - (W - U0))) r \ + r ` (W1 - (W - U0) \ (W2 - (W - U0))) \ S \ T \ + (\x\S \ T. r x = x)" + apply (rule_tac x = "\x. if x \ S' then g x else h x" in exI) + apply (intro conjI *) + apply (rule continuous_on_cases_local + [OF cloW1 cloW2 continuous_on_subset [OF contg] continuous_on_subset [OF conth]]) + using \W1 = S' \ O1\ \W2 = T' \ O2\ \S' \ T' = W\ + \g ` W1 \ S\ \h ` W2 \ T\ apply auto + using \U0 \ W \ W0\ \W0 \ S \ W1\ apply (fastforce simp add: geqr heqr)+ + done + then show "S \ T retract_of W1 - (W - U0) \ (W2 - (W - U0))" + using \W0 \ S \ W1\ \W0 \ T \ W2\ ST opeUU0 U0 + by (auto simp add: retract_of_def retraction_def) + qed +qed + + +proposition ANR_closed_Un_local: + fixes S :: "'a::euclidean_space set" + assumes STS: "closedin (subtopology euclidean (S \ T)) S" + and STT: "closedin (subtopology euclidean (S \ T)) T" + and "ANR S" "ANR T" "ANR(S \ T)" + shows "ANR(S \ T)" +proof - + have "\T. openin (subtopology euclidean U) T \ C retract_of T" + if hom: "S \ T homeomorphic C" and UC: "closedin (subtopology euclidean U) C" + for U and C :: "('a * real) set" + proof - + obtain f g where hom: "homeomorphism (S \ T) C f g" + using hom by (force simp: homeomorphic_def) + have US: "closedin (subtopology euclidean U) {x \ C. g x \ S}" + apply (rule closedin_trans [OF _ UC]) + apply (rule continuous_closedin_preimage_gen [OF _ _ STS]) + using hom [unfolded homeomorphism_def] apply blast + apply (metis hom homeomorphism_def set_eq_subset) + done + have UT: "closedin (subtopology euclidean U) {x \ C. g x \ T}" + apply (rule closedin_trans [OF _ UC]) + apply (rule continuous_closedin_preimage_gen [OF _ _ STT]) + using hom [unfolded homeomorphism_def] apply blast + apply (metis hom homeomorphism_def set_eq_subset) + done + have ANRS: "ANR {x \ C. g x \ S}" + apply (rule ANR_homeomorphic_ANR [OF \ANR S\]) + apply (simp add: homeomorphic_def) + apply (rule_tac x=g in exI) + apply (rule_tac x=f in exI) + using hom apply (auto simp: homeomorphism_def elim!: continuous_on_subset) + apply (rule_tac x="f x" in image_eqI, auto) + done + have ANRT: "ANR {x \ C. g x \ T}" + apply (rule ANR_homeomorphic_ANR [OF \ANR T\]) + apply (simp add: homeomorphic_def) + apply (rule_tac x=g in exI) + apply (rule_tac x=f in exI) + using hom apply (auto simp: homeomorphism_def elim!: continuous_on_subset) + apply (rule_tac x="f x" in image_eqI, auto) + done + have ANRI: "ANR ({x \ C. g x \ S} \ {x \ C. g x \ T})" + apply (rule ANR_homeomorphic_ANR [OF \ANR (S \ T)\]) + apply (simp add: homeomorphic_def) + apply (rule_tac x=g in exI) + apply (rule_tac x=f in exI) + using hom + apply (auto simp: homeomorphism_def elim!: continuous_on_subset) + apply (rule_tac x="f x" in image_eqI, auto) + done + have "C = {x. x \ C \ g x \ S} \ {x. x \ C \ g x \ T}" + by auto (metis Un_iff hom homeomorphism_def imageI) + then show ?thesis + by (metis ANR_closed_Un_local_aux [OF US UT ANRS ANRT ANRI]) + qed + then show ?thesis + by (auto simp: ANR_def) +qed + +corollary ANR_closed_Un: + fixes S :: "'a::euclidean_space set" + shows "\closed S; closed T; ANR S; ANR T; ANR (S \ T)\ \ ANR (S \ T)" +by (simp add: ANR_closed_Un_local closedin_def diff_eq open_Compl openin_open_Int) + end diff -r 00a135c0a17f -r 3b6975875633 src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Tue Jun 14 20:48:42 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Wed Jun 15 15:52:24 2016 +0100 @@ -11,6 +11,25 @@ "~~/src/HOL/Library/Set_Algebras" begin +(*FIXME move up e.g. to Library/Convex.thy, but requires the "support" primitive*) +lemma convex_supp_setsum: + assumes "convex S" and 1: "supp_setsum u I = 1" + and "\i. i \ I \ 0 \ u i \ (u i = 0 \ f i \ S)" + shows "supp_setsum (\i. u i *\<^sub>R f i) I \ S" +proof - + have fin: "finite {i \ I. u i \ 0}" + using 1 setsum.infinite by (force simp: supp_setsum_def support_def) + then have eq: "supp_setsum(\i. u i *\<^sub>R f i) I = + setsum (\i. u i *\<^sub>R f i) {i \ I. u i \ 0}" + by (force intro: setsum.mono_neutral_left simp: supp_setsum_def support_def) + show ?thesis + apply (simp add: eq) + apply (rule convex_setsum [OF fin \convex S\]) + using 1 assms apply (auto simp: supp_setsum_def support_def) + done +qed + + lemma dim_image_eq: fixes f :: "'n::euclidean_space \ 'm::euclidean_space" assumes lf: "linear f" diff -r 00a135c0a17f -r 3b6975875633 src/HOL/Multivariate_Analysis/Extension.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Multivariate_Analysis/Extension.thy Wed Jun 15 15:52:24 2016 +0100 @@ -0,0 +1,547 @@ +(* Title: HOL/Multivariate_Analysis/Extension.thy + Authors: LC Paulson, based on material from HOL Light +*) + +section \Continuous extensions of functions: Urysohn's lemma, Dugundji extension theorem, Tietze\ + +theory Extension +imports Convex_Euclidean_Space +begin + +subsection\Partitions of unity subordinate to locally finite open coverings\ + +text\A difference from HOL Light: all summations over infinite sets equal zero, + so the "support" must be made explicit in the summation below!\ + +proposition subordinate_partition_of_unity: + fixes S :: "'a :: euclidean_space set" + assumes "S \ \\" and opC: "\T. T \ \ \ open T" + and fin: "\x. x \ S \ \V. open V \ x \ V \ finite {U \ \. U \ V \ {}}" + obtains F :: "['a set, 'a] \ real" + where "\U. U \ \ \ continuous_on S (F U) \ (\x \ S. 0 \ F U x)" + and "\x U. \U \ \; x \ S; x \ U\ \ F U x = 0" + and "\x. x \ S \ supp_setsum (\W. F W x) \ = 1" + and "\x. x \ S \ \V. open V \ x \ V \ finite {U \ \. \x\V. F U x \ 0}" +proof (cases "\W. W \ \ \ S \ W") + case True + then obtain W where "W \ \" "S \ W" by metis + then show ?thesis + apply (rule_tac F = "\V x. if V = W then 1 else 0" in that) + apply (auto simp: continuous_on_const supp_setsum_def support_def) + done +next + case False + have nonneg: "0 \ supp_setsum (\V. setdist {x} (S - V)) \" for x + by (simp add: supp_setsum_def setsum_nonneg) + have sd_pos: "0 < setdist {x} (S - V)" if "V \ \" "x \ S" "x \ V" for V x + proof - + have "closedin (subtopology euclidean S) (S - V)" + by (simp add: Diff_Diff_Int Diff_subset closedin_def opC openin_open_Int \V \ \\) + with that False setdist_eq_0_closedin [of S "S-V" x] setdist_pos_le [of "{x}" "S - V"] + show ?thesis + by (simp add: order_class.order.order_iff_strict) + qed + have ss_pos: "0 < supp_setsum (\V. setdist {x} (S - V)) \" if "x \ S" for x + proof - + obtain U where "U \ \" "x \ U" using \x \ S\ \S \ \\\ + by blast + obtain V where "open V" "x \ V" "finite {U \ \. U \ V \ {}}" + using \x \ S\ fin by blast + then have *: "finite {A \ \. \ S \ A \ x \ closure (S - A)}" + using closure_def that by (blast intro: rev_finite_subset) + have "x \ closure (S - U)" + by (metis \U \ \\ \x \ U\ less_irrefl sd_pos setdist_eq_0_sing_1 that) + then show ?thesis + apply (simp add: setdist_eq_0_sing_1 supp_setsum_def support_def) + apply (rule ordered_comm_monoid_add_class.setsum_pos2 [OF *, of U]) + using \U \ \\ \x \ U\ False + apply (auto simp: setdist_pos_le sd_pos that) + done + qed + define F where + "F \ \W x. if x \ S then setdist {x} (S - W) / supp_setsum (\V. setdist {x} (S - V)) \ + else 0" + show ?thesis + proof (rule_tac F = F in that) + have "continuous_on S (F U)" if "U \ \" for U + proof - + have *: "continuous_on S (\x. supp_setsum (\V. setdist {x} (S - V)) \)" + proof (clarsimp simp add: continuous_on_eq_continuous_within) + fix x assume "x \ S" + then obtain X where "open X" and x: "x \ S \ X" and finX: "finite {U \ \. U \ X \ {}}" + using assms by blast + then have OSX: "openin (subtopology euclidean S) (S \ X)" by blast + have sumeq: "\x. x \ S \ X \ + (\V | V \ \ \ V \ X \ {}. setdist {x} (S - V)) + = supp_setsum (\V. setdist {x} (S - V)) \" + apply (simp add: supp_setsum_def) + apply (rule setsum.mono_neutral_right [OF finX]) + apply (auto simp: setdist_eq_0_sing_1 support_def subset_iff) + apply (meson DiffI closure_subset disjoint_iff_not_equal subsetCE) + done + show "continuous (at x within S) (\x. supp_setsum (\V. setdist {x} (S - V)) \)" + apply (rule continuous_transform_within_openin + [where f = "\x. (setsum (\V. setdist {x} (S - V)) {V \ \. V \ X \ {}})" + and S ="S \ X"]) + apply (rule continuous_intros continuous_at_setdist continuous_at_imp_continuous_at_within OSX x)+ + apply (simp add: sumeq) + done + qed + show ?thesis + apply (simp add: F_def) + apply (rule continuous_intros *)+ + using ss_pos apply force + done + qed + moreover have "\U \ \; x \ S\ \ 0 \ F U x" for U x + using nonneg [of x] by (simp add: F_def divide_simps setdist_pos_le) + ultimately show "\U. U \ \ \ continuous_on S (F U) \ (\x\S. 0 \ F U x)" + by metis + next + show "\x U. \U \ \; x \ S; x \ U\ \ F U x = 0" + by (simp add: setdist_eq_0_sing_1 closure_def F_def) + next + show "supp_setsum (\W. F W x) \ = 1" if "x \ S" for x + using that ss_pos [OF that] + by (simp add: F_def divide_simps supp_setsum_divide_distrib [symmetric]) + next + show "\V. open V \ x \ V \ finite {U \ \. \x\V. F U x \ 0}" if "x \ S" for x + using fin [OF that] that + by (fastforce simp: setdist_eq_0_sing_1 closure_def F_def elim!: rev_finite_subset) + qed +qed + + +subsection\Urysohn's lemma (for real^N, where the proof is easy using distances)\ + +lemma Urysohn_both_ne: + assumes US: "closedin (subtopology euclidean U) S" + and UT: "closedin (subtopology euclidean U) T" + and "S \ T = {}" "S \ {}" "T \ {}" "a \ b" + obtains f :: "'a::euclidean_space \ 'b::real_normed_vector" + where "continuous_on U f" + "\x. x \ U \ f x \ closed_segment a b" + "\x. x \ U \ (f x = a \ x \ S)" + "\x. x \ U \ (f x = b \ x \ T)" +proof - + have S0: "\x. x \ U \ setdist {x} S = 0 \ x \ S" + using \S \ {}\ US setdist_eq_0_closedin by auto + have T0: "\x. x \ U \ setdist {x} T = 0 \ x \ T" + using \T \ {}\ UT setdist_eq_0_closedin by auto + have sdpos: "0 < setdist {x} S + setdist {x} T" if "x \ U" for x + proof - + have "~ (setdist {x} S = 0 \ setdist {x} T = 0)" + using assms by (metis IntI empty_iff setdist_eq_0_closedin that) + then show ?thesis + by (metis add.left_neutral add.right_neutral add_pos_pos linorder_neqE_linordered_idom not_le setdist_pos_le) + qed + define f where "f \ \x. a + (setdist {x} S / (setdist {x} S + setdist {x} T)) *\<^sub>R (b - a)" + show ?thesis + proof (rule_tac f = f in that) + show "continuous_on U f" + using sdpos unfolding f_def + by (intro continuous_intros | force)+ + show "f x \ closed_segment a b" if "x \ U" for x + unfolding f_def + apply (simp add: closed_segment_def) + apply (rule_tac x="(setdist {x} S / (setdist {x} S + setdist {x} T))" in exI) + using sdpos that apply (simp add: algebra_simps) + done + show "\x. x \ U \ (f x = a \ x \ S)" + using S0 \a \ b\ f_def sdpos by force + show "(f x = b \ x \ T)" if "x \ U" for x + proof - + have "f x = b \ (setdist {x} S / (setdist {x} S + setdist {x} T)) = 1" + unfolding f_def + apply (rule iffI) + apply (metis \a \ b\ add_diff_cancel_left' eq_iff_diff_eq_0 pth_1 real_vector.scale_right_imp_eq, force) + done + also have "... \ setdist {x} T = 0 \ setdist {x} S \ 0" + using sdpos that + by (simp add: divide_simps) linarith + also have "... \ x \ T" + using \S \ {}\ \T \ {}\ \S \ T = {}\ that + by (force simp: S0 T0) + finally show ?thesis . + qed + qed +qed + +proposition Urysohn_local_strong: + assumes US: "closedin (subtopology euclidean U) S" + and UT: "closedin (subtopology euclidean U) T" + and "S \ T = {}" "a \ b" + obtains f :: "'a::euclidean_space \ 'b::euclidean_space" + where "continuous_on U f" + "\x. x \ U \ f x \ closed_segment a b" + "\x. x \ U \ (f x = a \ x \ S)" + "\x. x \ U \ (f x = b \ x \ T)" +proof (cases "S = {}") + case True show ?thesis + proof (cases "T = {}") + case True show ?thesis + proof (rule_tac f = "\x. midpoint a b" in that) + show "continuous_on U (\x. midpoint a b)" + by (intro continuous_intros) + show "midpoint a b \ closed_segment a b" + using csegment_midpoint_subset by blast + show "(midpoint a b = a) = (x \ S)" for x + using \S = {}\ \a \ b\ by simp + show "(midpoint a b = b) = (x \ T)" for x + using \T = {}\ \a \ b\ by simp + qed + next + case False + show ?thesis + proof (cases "T = U") + case True with \S = {}\ \a \ b\ show ?thesis + by (rule_tac f = "\x. b" in that) (auto simp: continuous_on_const) + next + case False + with UT closedin_subset obtain c where c: "c \ U" "c \ T" + by fastforce + obtain f where f: "continuous_on U f" + "\x. x \ U \ f x \ closed_segment (midpoint a b) b" + "\x. x \ U \ (f x = midpoint a b \ x = c)" + "\x. x \ U \ (f x = b \ x \ T)" + apply (rule Urysohn_both_ne [of U "{c}" T "midpoint a b" "b"]) + using c \T \ {}\ assms apply simp_all + done + show ?thesis + apply (rule_tac f=f in that) + using \S = {}\ \T \ {}\ f csegment_midpoint_subset notin_segment_midpoint [OF \a \ b\] + apply force+ + done + qed + qed +next + case False + show ?thesis + proof (cases "T = {}") + case True show ?thesis + proof (cases "S = U") + case True with \T = {}\ \a \ b\ show ?thesis + by (rule_tac f = "\x. a" in that) (auto simp: continuous_on_const) + next + case False + with US closedin_subset obtain c where c: "c \ U" "c \ S" + by fastforce + obtain f where f: "continuous_on U f" + "\x. x \ U \ f x \ closed_segment a (midpoint a b)" + "\x. x \ U \ (f x = midpoint a b \ x = c)" + "\x. x \ U \ (f x = a \ x \ S)" + apply (rule Urysohn_both_ne [of U S "{c}" a "midpoint a b"]) + using c \S \ {}\ assms apply simp_all + apply (metis midpoint_eq_endpoint) + done + show ?thesis + apply (rule_tac f=f in that) + using \S \ {}\ \T = {}\ f \a \ b\ + apply simp_all + apply (metis (no_types) closed_segment_commute csegment_midpoint_subset midpoint_sym subset_iff) + apply (metis closed_segment_commute midpoint_sym notin_segment_midpoint) + done + qed + next + case False + show ?thesis + using Urysohn_both_ne [OF US UT \S \ T = {}\ \S \ {}\ \T \ {}\ \a \ b\] that + by blast + qed +qed + +lemma Urysohn_local: + assumes US: "closedin (subtopology euclidean U) S" + and UT: "closedin (subtopology euclidean U) T" + and "S \ T = {}" + obtains f :: "'a::euclidean_space \ 'b::euclidean_space" + where "continuous_on U f" + "\x. x \ U \ f x \ closed_segment a b" + "\x. x \ S \ f x = a" + "\x. x \ T \ f x = b" +proof (cases "a = b") + case True then show ?thesis + by (rule_tac f = "\x. b" in that) (auto simp: continuous_on_const) +next + case False + then show ?thesis + apply (rule Urysohn_local_strong [OF assms]) + apply (erule that, assumption) + apply (meson US closedin_singleton closedin_trans) + apply (meson UT closedin_singleton closedin_trans) + done +qed + +lemma Urysohn_strong: + assumes US: "closed S" + and UT: "closed T" + and "S \ T = {}" "a \ b" + obtains f :: "'a::euclidean_space \ 'b::euclidean_space" + where "continuous_on UNIV f" + "\x. f x \ closed_segment a b" + "\x. f x = a \ x \ S" + "\x. f x = b \ x \ T" +apply (rule Urysohn_local_strong [of UNIV S T]) +using assms +apply (auto simp: closed_closedin) +done + +proposition Urysohn: + assumes US: "closed S" + and UT: "closed T" + and "S \ T = {}" + obtains f :: "'a::euclidean_space \ 'b::euclidean_space" + where "continuous_on UNIV f" + "\x. f x \ closed_segment a b" + "\x. x \ S \ f x = a" + "\x. x \ T \ f x = b" +apply (rule Urysohn_local [of UNIV S T a b]) +using assms +apply (auto simp: closed_closedin) +done + + +subsection\ The Dugundji extension theorem, and Tietze variants as corollaries.\ + +text\J. Dugundji. An extension of Tietze's theorem. Pacific J. Math. Volume 1, Number 3 (1951), 353-367. +http://projecteuclid.org/euclid.pjm/1103052106\ + +theorem Dugundji: + fixes f :: "'a::euclidean_space \ 'b::real_inner" + assumes "convex C" "C \ {}" + and cloin: "closedin (subtopology euclidean U) S" + and contf: "continuous_on S f" and "f ` S \ C" + obtains g where "continuous_on U g" "g ` U \ C" + "\x. x \ S \ g x = f x" +proof (cases "S = {}") + case True then show thesis + apply (rule_tac g="\x. @y. y \ C" in that) + apply (rule continuous_intros) + apply (meson all_not_in_conv \C \ {}\ image_subsetI someI_ex, simp) + done +next + case False + then have sd_pos: "\x. \x \ U; x \ S\ \ 0 < setdist {x} S" + using setdist_eq_0_closedin [OF cloin] le_less setdist_pos_le by fastforce + define \ where "\ = {ball x (setdist {x} S / 2) |x. x \ U - S}" + have [simp]: "\T. T \ \ \ open T" + by (auto simp: \_def) + have USS: "U - S \ \\" + by (auto simp: sd_pos \_def) + obtain \ where USsub: "U - S \ \\" + and nbrhd: "\U. U \ \ \ open U \ (\T. T \ \ \ U \ T)" + and fin: "\x. x \ U - S + \ \V. open V \ x \ V \ finite {U. U \ \ \ U \ V \ {}}" + using paracompact [OF USS] by auto + have "\v a. v \ U \ v \ S \ a \ S \ + T \ ball v (setdist {v} S / 2) \ + dist v a \ 2 * setdist {v} S" if "T \ \" for T + proof - + obtain v where v: "T \ ball v (setdist {v} S / 2)" "v \ U" "v \ S" + using \T \ \\ nbrhd by (force simp: \_def) + then obtain a where "a \ S" "dist v a < 2 * setdist {v} S" + using setdist_ltE [of "{v}" S "2 * setdist {v} S"] + using False sd_pos by force + with v show ?thesis + apply (rule_tac x=v in exI) + apply (rule_tac x=a in exI, auto) + done + qed + then obtain \ \ where + VA: "\T. T \ \ \ \ T \ U \ \ T \ S \ \ T \ S \ + T \ ball (\ T) (setdist {\ T} S / 2) \ + dist (\ T) (\ T) \ 2 * setdist {\ T} S" + by metis + have sdle: "setdist {\ T} S \ 2 * setdist {v} S" if "T \ \" "v \ T" for T v + using setdist_Lipschitz [of "\ T" S v] VA [OF \T \ \\] \v \ T\ by auto + have d6: "dist a (\ T) \ 6 * dist a v" if "T \ \" "v \ T" "a \ S" for T v a + proof - + have "dist (\ T) v < setdist {\ T} S / 2" + using that VA mem_ball by blast + also have "... \ setdist {v} S" + using sdle [OF \T \ \\ \v \ T\] by simp + also have vS: "setdist {v} S \ dist a v" + by (simp add: setdist_le_dist setdist_sym \a \ S\) + finally have VTV: "dist (\ T) v < dist a v" . + have VTS: "setdist {\ T} S \ 2 * dist a v" + using sdle that vS by force + have "dist a (\ T) \ dist a v + dist v (\ T) + dist (\ T) (\ T)" + by (metis add.commute add_le_cancel_left dist_commute dist_triangle2 dist_triangle_le) + also have "... \ dist a v + dist a v + dist (\ T) (\ T)" + using VTV by (simp add: dist_commute) + also have "... \ 2 * dist a v + 2 * setdist {\ T} S" + using VA [OF \T \ \\] by auto + finally show ?thesis + using VTS by linarith + qed + obtain H :: "['a set, 'a] \ real" + where Hcont: "\Z. Z \ \ \ continuous_on (U-S) (H Z)" + and Hge0: "\Z x. \Z \ \; x \ U-S\ \ 0 \ H Z x" + and Heq0: "\x Z. \Z \ \; x \ U-S; x \ Z\ \ H Z x = 0" + and H1: "\x. x \ U-S \ supp_setsum (\W. H W x) \ = 1" + and Hfin: "\x. x \ U-S \ \V. open V \ x \ V \ finite {U \ \. \x\V. H U x \ 0}" + apply (rule subordinate_partition_of_unity [OF USsub _ fin]) + using nbrhd by auto + define g where "g \ \x. if x \ S then f x else supp_setsum (\T. H T x *\<^sub>R f(\ T)) \" + show ?thesis + proof (rule that) + show "continuous_on U g" + proof (clarsimp simp: continuous_on_eq_continuous_within) + fix a assume "a \ U" + show "continuous (at a within U) g" + proof (cases "a \ S") + case True show ?thesis + proof (clarsimp simp add: continuous_within_topological) + fix W + assume "open W" "g a \ W" + then obtain e where "0 < e" and e: "ball (f a) e \ W" + using openE True g_def by auto + have "continuous (at a within S) f" + using True contf continuous_on_eq_continuous_within by blast + then obtain d where "0 < d" + and d: "\x. \x \ S; dist x a < d\ \ dist (f x) (f a) < e" + using continuous_within_eps_delta \0 < e\ by force + have "g y \ ball (f a) e" if "y \ U" and y: "y \ ball a (d / 6)" for y + proof (cases "y \ S") + case True + then have "dist (f a) (f y) < e" + by (metis ball_divide_subset_numeral dist_commute in_mono mem_ball y d) + then show ?thesis + by (simp add: True g_def) + next + case False + have *: "dist (f (\ T)) (f a) < e" if "T \ \" "H T y \ 0" for T + proof - + have "y \ T" + using Heq0 that False \y \ U\ by blast + have "dist (\ T) a < d" + using d6 [OF \T \ \\ \y \ T\ \a \ S\] y + by (simp add: dist_commute mult.commute) + then show ?thesis + using VA [OF \T \ \\] by (auto simp: d) + qed + have "supp_setsum (\T. H T y *\<^sub>R f (\ T)) \ \ ball (f a) e" + apply (rule convex_supp_setsum [OF convex_ball]) + apply (simp_all add: False H1 Hge0 \y \ U\) + by (metis dist_commute *) + then show ?thesis + by (simp add: False g_def) + qed + then show "\A. open A \ a \ A \ (\y\U. y \ A \ g y \ W)" + apply (rule_tac x = "ball a (d / 6)" in exI) + using e \0 < d\ by fastforce + qed + next + case False + obtain N where N: "open N" "a \ N" + and finN: "finite {U \ \. \a\N. H U a \ 0}" + using Hfin False \a \ U\ by auto + have oUS: "openin (subtopology euclidean U) (U - S)" + using cloin by (simp add: openin_diff) + have HcontU: "continuous (at a within U) (H T)" if "T \ \" for T + using Hcont [OF \T \ \\] False \a \ U\ \T \ \\ + apply (simp add: continuous_on_eq_continuous_within continuous_within) + apply (rule Lim_transform_within_set) + using oUS + apply (force simp: eventually_at openin_contains_ball dist_commute dest!: bspec)+ + done + show ?thesis + proof (rule continuous_transform_within_openin [OF _ oUS]) + show "continuous (at a within U) (\x. supp_setsum (\T. H T x *\<^sub>R f (\ T)) \)" + proof (rule continuous_transform_within_openin) + show "continuous (at a within U) + (\x. \T\{U \ \. \x\N. H U x \ 0}. H T x *\<^sub>R f (\ T))" + by (force intro: continuous_intros HcontU)+ + next + show "openin (subtopology euclidean U) ((U - S) \ N)" + using N oUS openin_trans by blast + next + show "a \ (U - S) \ N" using False \a \ U\ N by blast + next + show "\x. x \ (U - S) \ N \ + (\T \ {U \ \. \x\N. H U x \ 0}. H T x *\<^sub>R f (\ T)) + = supp_setsum (\T. H T x *\<^sub>R f (\ T)) \" + by (auto simp: supp_setsum_def support_def + intro: setsum.mono_neutral_right [OF finN]) + qed + next + show "a \ U - S" using False \a \ U\ by blast + next + show "\x. x \ U - S \ supp_setsum (\T. H T x *\<^sub>R f (\ T)) \ = g x" + by (simp add: g_def) + qed + qed + qed + show "g ` U \ C" + using \f ` S \ C\ VA + by (fastforce simp: g_def Hge0 intro!: convex_supp_setsum [OF \convex C\] H1) + show "\x. x \ S \ g x = f x" + by (simp add: g_def) + qed +qed + + +corollary Tietze: + fixes f :: "'a::euclidean_space \ 'b::real_inner" + assumes "continuous_on S f" + and "closedin (subtopology euclidean U) S" + and "0 \ B" + and "\x. x \ S \ norm(f x) \ B" + obtains g where "continuous_on U g" "\x. x \ S \ g x = f x" + "\x. x \ U \ norm(g x) \ B" +using assms +by (auto simp: image_subset_iff intro: Dugundji [of "cball 0 B" U S f]) + +corollary Tietze_closed_interval: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "continuous_on S f" + and "closedin (subtopology euclidean U) S" + and "cbox a b \ {}" + and "\x. x \ S \ f x \ cbox a b" + obtains g where "continuous_on U g" "\x. x \ S \ g x = f x" + "\x. x \ U \ g x \ cbox a b" +apply (rule Dugundji [of "cbox a b" U S f]) +using assms by auto + +corollary Tietze_closed_interval_1: + fixes f :: "'a::euclidean_space \ real" + assumes "continuous_on S f" + and "closedin (subtopology euclidean U) S" + and "a \ b" + and "\x. x \ S \ f x \ cbox a b" + obtains g where "continuous_on U g" "\x. x \ S \ g x = f x" + "\x. x \ U \ g x \ cbox a b" +apply (rule Dugundji [of "cbox a b" U S f]) +using assms by (auto simp: image_subset_iff) + +corollary Tietze_open_interval: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "continuous_on S f" + and "closedin (subtopology euclidean U) S" + and "box a b \ {}" + and "\x. x \ S \ f x \ box a b" + obtains g where "continuous_on U g" "\x. x \ S \ g x = f x" + "\x. x \ U \ g x \ box a b" +apply (rule Dugundji [of "box a b" U S f]) +using assms by auto + +corollary Tietze_open_interval_1: + fixes f :: "'a::euclidean_space \ real" + assumes "continuous_on S f" + and "closedin (subtopology euclidean U) S" + and "a < b" + and no: "\x. x \ S \ f x \ box a b" + obtains g where "continuous_on U g" "\x. x \ S \ g x = f x" + "\x. x \ U \ g x \ box a b" +apply (rule Dugundji [of "box a b" U S f]) +using assms by (auto simp: image_subset_iff) + +corollary Tietze_unbounded: + fixes f :: "'a::euclidean_space \ 'b::real_inner" + assumes "continuous_on S f" + and "closedin (subtopology euclidean U) S" + obtains g where "continuous_on U g" "\x. x \ S \ g x = f x" +apply (rule Dugundji [of UNIV U S f]) +using assms by auto + +end diff -r 00a135c0a17f -r 3b6975875633 src/HOL/Multivariate_Analysis/Integration.thy --- a/src/HOL/Multivariate_Analysis/Integration.thy Tue Jun 14 20:48:42 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Integration.thy Wed Jun 15 15:52:24 2016 +0100 @@ -11,173 +11,6 @@ "~~/src/HOL/Library/Indicator_Function" begin -(*FIXME: move elsewhere and use the existing locales*) - -subsection \Using additivity of lifted function to encode definedness.\ - -definition "neutral opp = (SOME x. \y. opp x y = y \ opp y x = y)" - -fun lifted where - "lifted (opp :: 'a \ 'a \ 'b) (Some x) (Some y) = Some (opp x y)" -| "lifted opp None _ = (None::'b option)" -| "lifted opp _ None = None" - -lemma lifted_simp_1[simp]: "lifted opp v None = None" - by (induct v) auto - -definition "monoidal opp \ - (\x y. opp x y = opp y x) \ - (\x y z. opp x (opp y z) = opp (opp x y) z) \ - (\x. opp (neutral opp) x = x)" - -lemma monoidalI: - assumes "\x y. opp x y = opp y x" - and "\x y z. opp x (opp y z) = opp (opp x y) z" - and "\x. opp (neutral opp) x = x" - shows "monoidal opp" - unfolding monoidal_def using assms by fastforce - -lemma monoidal_ac: - assumes "monoidal opp" - shows [simp]: "opp (neutral opp) a = a" - and [simp]: "opp a (neutral opp) = a" - and "opp a b = opp b a" - and "opp (opp a b) c = opp a (opp b c)" - and "opp a (opp b c) = opp b (opp a c)" - using assms unfolding monoidal_def by metis+ - -lemma neutral_lifted [cong]: - assumes "monoidal opp" - shows "neutral (lifted opp) = Some (neutral opp)" -proof - - { fix x - assume "\y. lifted opp x y = y \ lifted opp y x = y" - then have "Some (neutral opp) = x" - apply (induct x) - apply force - by (metis assms lifted.simps(1) monoidal_ac(2) option.inject) } - note [simp] = this - show ?thesis - apply (subst neutral_def) - apply (intro some_equality allI) - apply (induct_tac y) - apply (auto simp add:monoidal_ac[OF assms]) - done -qed - -lemma monoidal_lifted[intro]: - assumes "monoidal opp" - shows "monoidal (lifted opp)" - unfolding monoidal_def split_option_all neutral_lifted[OF assms] - using monoidal_ac[OF assms] - by auto - -definition "support opp f s = {x. x\s \ f x \ neutral opp}" -definition "fold' opp e s = (if finite s then Finite_Set.fold opp e s else e)" -definition "iterate opp s f = fold' (\x a. opp (f x) a) (neutral opp) (support opp f s)" - -lemma support_subset[intro]: "support opp f s \ s" - unfolding support_def by auto - -lemma support_empty[simp]: "support opp f {} = {}" - using support_subset[of opp f "{}"] by auto - -lemma comp_fun_commute_monoidal[intro]: - assumes "monoidal opp" - shows "comp_fun_commute opp" - unfolding comp_fun_commute_def - using monoidal_ac[OF assms] - by auto - -lemma support_clauses: - "\f g s. support opp f {} = {}" - "\f g s. support opp f (insert x s) = - (if f(x) = neutral opp then support opp f s else insert x (support opp f s))" - "\f g s. support opp f (s - {x}) = (support opp f s) - {x}" - "\f g s. support opp f (s \ t) = (support opp f s) \ (support opp f t)" - "\f g s. support opp f (s \ t) = (support opp f s) \ (support opp f t)" - "\f g s. support opp f (s - t) = (support opp f s) - (support opp f t)" - "\f g s. support opp g (f ` s) = f ` (support opp (g \ f) s)" - unfolding support_def by auto - -lemma finite_support[intro]: "finite s \ finite (support opp f s)" - unfolding support_def by auto - -lemma iterate_empty[simp]: "iterate opp {} f = neutral opp" - unfolding iterate_def fold'_def by auto - -lemma iterate_insert[simp]: - assumes "monoidal opp" - and "finite s" - shows "iterate opp (insert x s) f = - (if x \ s then iterate opp s f else opp (f x) (iterate opp s f))" -proof (cases "x \ s") - case True - then show ?thesis by (auto simp: insert_absorb iterate_def) -next - case False - note * = comp_fun_commute.comp_comp_fun_commute [OF comp_fun_commute_monoidal[OF assms(1)]] - show ?thesis - proof (cases "f x = neutral opp") - case True - then show ?thesis - using assms \x \ s\ - by (auto simp: iterate_def support_clauses) - next - case False - with \x \ s\ \finite s\ support_subset show ?thesis - apply (simp add: iterate_def fold'_def support_clauses) - apply (subst comp_fun_commute.fold_insert[OF * finite_support, simplified comp_def]) - apply (force simp add: )+ - done - qed -qed - -lemma iterate_some: - "\monoidal opp; finite s\ \ iterate (lifted opp) s (\x. Some(f x)) = Some (iterate opp s f)" - by (erule finite_induct) (auto simp: monoidal_lifted) - -lemma neutral_add[simp]: "neutral op + = (0::'a::comm_monoid_add)" - unfolding neutral_def - by (force elim: allE [where x=0]) - -lemma support_if: "a \ neutral opp \ support opp (\x. if P x then a else neutral opp) A = {x \ A. P x}" -unfolding support_def -by (force intro: Collect_cong) - -lemma support_if_subset: "support opp (\x. if P x then a else neutral opp) A \ {x \ A. P x}" -by (simp add: subset_iff support_def) - -definition supp_setsum where "supp_setsum f A \ setsum f (support op+ f A)" - -lemma supp_setsum_divide_distrib: - "supp_setsum f A / (r::'a::field) = supp_setsum (\n. f n / r) A" -apply (cases "r = 0") -apply (simp add: supp_setsum_def) -apply (simp add: supp_setsum_def setsum_divide_distrib support_def) -done - -(*FIXME move up e.g. to Library/Convex.thy*) -lemma convex_supp_setsum: - assumes "convex S" and 1: "supp_setsum u I = 1" - and "\i. i \ I \ 0 \ u i \ (u i = 0 \ f i \ S)" - shows "supp_setsum (\i. u i *\<^sub>R f i) I \ S" -proof - - have fin: "finite {i \ I. u i \ 0}" - using 1 setsum.infinite by (force simp: supp_setsum_def support_def) - then have eq: "supp_setsum(\i. u i *\<^sub>R f i) I = - setsum (\i. u i *\<^sub>R f i) {i \ I. u i \ 0}" - by (force intro: setsum.mono_neutral_left simp: supp_setsum_def support_def) - show ?thesis - apply (simp add: eq) - apply (rule convex_setsum [OF fin \convex S\]) - using 1 assms apply (auto simp: supp_setsum_def support_def) - done -qed - -(*END OF SUPPORT, ETC.*) - - lemmas scaleR_simps = scaleR_zero_left scaleR_minus_left scaleR_left_diff_distrib scaleR_zero_right scaleR_minus_right scaleR_right_diff_distrib scaleR_eq_0_iff scaleR_cancel_left scaleR_cancel_right scaleR_add_right scaleR_add_left real_vector_class.scaleR_one diff -r 00a135c0a17f -r 3b6975875633 src/HOL/Multivariate_Analysis/Path_Connected.thy --- a/src/HOL/Multivariate_Analysis/Path_Connected.thy Tue Jun 14 20:48:42 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Path_Connected.thy Wed Jun 15 15:52:24 2016 +0100 @@ -5,7 +5,7 @@ section \Continuous paths and path-connected sets\ theory Path_Connected -imports Convex_Euclidean_Space +imports Extension begin subsection \Paths and Arcs\ @@ -5763,4 +5763,251 @@ "S homeomorphic T \ (simply_connected S \ simply_connected T)" by (metis homeomorphic_simply_connected homeomorphic_sym) +subsection\Homotopy equivalence\ + +definition homotopy_eqv :: "'a::topological_space set \ 'b::topological_space set \ bool" + (infix "homotopy'_eqv" 50) + where "S homotopy_eqv T \ + \f g. continuous_on S f \ f ` S \ T \ + continuous_on T g \ g ` T \ S \ + homotopic_with (\x. True) S S (g o f) id \ + homotopic_with (\x. True) T T (f o g) id" + +lemma homeomorphic_imp_homotopy_eqv: "S homeomorphic T \ S homotopy_eqv T" + unfolding homeomorphic_def homotopy_eqv_def homeomorphism_def + by (fastforce intro!: homotopic_with_equal continuous_on_compose) + +lemma homotopy_eqv_refl: "S homotopy_eqv S" + by (rule homeomorphic_imp_homotopy_eqv homeomorphic_refl)+ + +lemma homotopy_eqv_sym: "S homotopy_eqv T \ T homotopy_eqv S" + by (auto simp: homotopy_eqv_def) + +lemma homotopy_eqv_trans [trans]: + fixes S :: "'a::real_normed_vector set" and U :: "'c::real_normed_vector set" + assumes ST: "S homotopy_eqv T" and TU: "T homotopy_eqv U" + shows "S homotopy_eqv U" +proof - + obtain f1 g1 where f1: "continuous_on S f1" "f1 ` S \ T" + and g1: "continuous_on T g1" "g1 ` T \ S" + and hom1: "homotopic_with (\x. True) S S (g1 o f1) id" + "homotopic_with (\x. True) T T (f1 o g1) id" + using ST by (auto simp: homotopy_eqv_def) + obtain f2 g2 where f2: "continuous_on T f2" "f2 ` T \ U" + and g2: "continuous_on U g2" "g2 ` U \ T" + and hom2: "homotopic_with (\x. True) T T (g2 o f2) id" + "homotopic_with (\x. True) U U (f2 o g2) id" + using TU by (auto simp: homotopy_eqv_def) + have "homotopic_with (\f. True) S T (g2 \ f2 \ f1) (id \ f1)" + by (rule homotopic_with_compose_continuous_right hom2 f1)+ + then have "homotopic_with (\f. True) S T (g2 \ (f2 \ f1)) (id \ f1)" + by (simp add: o_assoc) + then have "homotopic_with (\x. True) S S + (g1 \ (g2 \ (f2 \ f1))) (g1 o (id o f1))" + by (simp add: g1 homotopic_with_compose_continuous_left) + moreover have "homotopic_with (\x. True) S S (g1 o id o f1) id" + using hom1 by simp + ultimately have SS: "homotopic_with (\x. True) S S (g1 \ g2 \ (f2 \ f1)) id" + apply (simp add: o_assoc) + apply (blast intro: homotopic_with_trans) + done + have "homotopic_with (\f. True) U T (f1 \ g1 \ g2) (id \ g2)" + by (rule homotopic_with_compose_continuous_right hom1 g2)+ + then have "homotopic_with (\f. True) U T (f1 \ (g1 \ g2)) (id \ g2)" + by (simp add: o_assoc) + then have "homotopic_with (\x. True) U U + (f2 \ (f1 \ (g1 \ g2))) (f2 o (id o g2))" + by (simp add: f2 homotopic_with_compose_continuous_left) + moreover have "homotopic_with (\x. True) U U (f2 o id o g2) id" + using hom2 by simp + ultimately have UU: "homotopic_with (\x. True) U U (f2 \ f1 \ (g1 \ g2)) id" + apply (simp add: o_assoc) + apply (blast intro: homotopic_with_trans) + done + show ?thesis + unfolding homotopy_eqv_def + apply (rule_tac x = "f2 \ f1" in exI) + apply (rule_tac x = "g1 \ g2" in exI) + apply (intro conjI continuous_on_compose SS UU) + using f1 f2 g1 g2 apply (force simp: elim!: continuous_on_subset)+ + done +qed + +lemma homotopy_eqv_inj_linear_image: + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes "linear f" "inj f" + shows "(f ` S) homotopy_eqv S" +apply (rule homeomorphic_imp_homotopy_eqv) +using assms homeomorphic_sym linear_homeomorphic_image by auto + +lemma homotopy_eqv_translation: + fixes S :: "'a::real_normed_vector set" + shows "op + a ` S homotopy_eqv S" + apply (rule homeomorphic_imp_homotopy_eqv) + using homeomorphic_translation homeomorphic_sym by blast + +lemma homotopy_eqv_homotopic_triviality_imp: + fixes S :: "'a::real_normed_vector set" + and T :: "'b::real_normed_vector set" + and U :: "'c::real_normed_vector set" + assumes "S homotopy_eqv T" + and f: "continuous_on U f" "f ` U \ T" + and g: "continuous_on U g" "g ` U \ T" + and homUS: "\f g. \continuous_on U f; f ` U \ S; + continuous_on U g; g ` U \ S\ + \ homotopic_with (\x. True) U S f g" + shows "homotopic_with (\x. True) U T f g" +proof - + obtain h k where h: "continuous_on S h" "h ` S \ T" + and k: "continuous_on T k" "k ` T \ S" + and hom: "homotopic_with (\x. True) S S (k o h) id" + "homotopic_with (\x. True) T T (h o k) id" + using assms by (auto simp: homotopy_eqv_def) + have "homotopic_with (\f. True) U S (k \ f) (k \ g)" + apply (rule homUS) + using f g k + apply (safe intro!: continuous_on_compose h k f elim!: continuous_on_subset) + apply (force simp: o_def)+ + done + then have "homotopic_with (\x. True) U T (h o (k o f)) (h o (k o g))" + apply (rule homotopic_with_compose_continuous_left) + apply (simp_all add: h) + done + moreover have "homotopic_with (\x. True) U T (h o k o f) (id o f)" + apply (rule homotopic_with_compose_continuous_right [where X=T and Y=T]) + apply (auto simp: hom f) + done + moreover have "homotopic_with (\x. True) U T (h o k o g) (id o g)" + apply (rule homotopic_with_compose_continuous_right [where X=T and Y=T]) + apply (auto simp: hom g) + done + ultimately show "homotopic_with (\x. True) U T f g" + apply (simp add: o_assoc) + using homotopic_with_trans homotopic_with_sym by blast +qed + +lemma homotopy_eqv_homotopic_triviality: + fixes S :: "'a::real_normed_vector set" + and T :: "'b::real_normed_vector set" + and U :: "'c::real_normed_vector set" + assumes "S homotopy_eqv T" + shows "(\f g. continuous_on U f \ f ` U \ S \ + continuous_on U g \ g ` U \ S + \ homotopic_with (\x. True) U S f g) \ + (\f g. continuous_on U f \ f ` U \ T \ + continuous_on U g \ g ` U \ T + \ homotopic_with (\x. True) U T f g)" +apply (rule iffI) +apply (metis assms homotopy_eqv_homotopic_triviality_imp) +by (metis (no_types) assms homotopy_eqv_homotopic_triviality_imp homotopy_eqv_sym) + + +lemma homotopy_eqv_cohomotopic_triviality_null_imp: + fixes S :: "'a::real_normed_vector set" + and T :: "'b::real_normed_vector set" + and U :: "'c::real_normed_vector set" + assumes "S homotopy_eqv T" + and f: "continuous_on T f" "f ` T \ U" + and homSU: "\f. \continuous_on S f; f ` S \ U\ + \ \c. homotopic_with (\x. True) S U f (\x. c)" + obtains c where "homotopic_with (\x. True) T U f (\x. c)" +proof - + obtain h k where h: "continuous_on S h" "h ` S \ T" + and k: "continuous_on T k" "k ` T \ S" + and hom: "homotopic_with (\x. True) S S (k o h) id" + "homotopic_with (\x. True) T T (h o k) id" + using assms by (auto simp: homotopy_eqv_def) + obtain c where "homotopic_with (\x. True) S U (f \ h) (\x. c)" + apply (rule exE [OF homSU [of "f \ h"]]) + apply (intro continuous_on_compose h) + using h f apply (force elim!: continuous_on_subset)+ + done + then have "homotopic_with (\x. True) T U ((f o h) o k) ((\x. c) o k)" + apply (rule homotopic_with_compose_continuous_right [where X=S]) + using k by auto + moreover have "homotopic_with (\x. True) T U (f \ id) (f \ (h \ k))" + apply (rule homotopic_with_compose_continuous_left [where Y=T]) + apply (simp add: hom homotopic_with_symD) + using f apply auto + done + ultimately show ?thesis + apply (rule_tac c=c in that) + apply (simp add: o_def) + using homotopic_with_trans by blast +qed + +lemma homotopy_eqv_cohomotopic_triviality_null: + fixes S :: "'a::real_normed_vector set" + and T :: "'b::real_normed_vector set" + and U :: "'c::real_normed_vector set" + assumes "S homotopy_eqv T" + shows "(\f. continuous_on S f \ f ` S \ U + \ (\c. homotopic_with (\x. True) S U f (\x. c))) \ + (\f. continuous_on T f \ f ` T \ U + \ (\c. homotopic_with (\x. True) T U f (\x. c)))" +apply (rule iffI) +apply (metis assms homotopy_eqv_cohomotopic_triviality_null_imp) +by (metis assms homotopy_eqv_cohomotopic_triviality_null_imp homotopy_eqv_sym) + + +lemma homotopy_eqv_contractible_sets: + fixes S :: "'a::real_normed_vector set" + and T :: "'b::real_normed_vector set" + assumes "contractible S" "contractible T" "S = {} \ T = {}" + shows "S homotopy_eqv T" +proof (cases "S = {}") + case True with assms show ?thesis + by (simp add: homeomorphic_imp_homotopy_eqv) +next + case False + with assms obtain a b where "a \ S" "b \ T" + by auto + then show ?thesis + unfolding homotopy_eqv_def + apply (rule_tac x="\x. b" in exI) + apply (rule_tac x="\x. a" in exI) + apply (intro assms conjI continuous_on_id' homotopic_into_contractible) + apply (auto simp: o_def continuous_on_const) + done +qed + +lemma homotopy_eqv_empty1 [simp]: + fixes S :: "'a::real_normed_vector set" + shows "S homotopy_eqv ({}::'b::real_normed_vector set) \ S = {}" +apply (rule iffI) +using homotopy_eqv_def apply fastforce +by (simp add: homotopy_eqv_contractible_sets contractible_empty) + +lemma homotopy_eqv_empty2 [simp]: + fixes S :: "'a::real_normed_vector set" + shows "({}::'b::real_normed_vector set) homotopy_eqv S \ S = {}" +by (metis homotopy_eqv_empty1 homotopy_eqv_sym) + +lemma homotopy_eqv_contractibility: + fixes S :: "'a::real_normed_vector set" and T :: "'b::real_normed_vector set" + shows "S homotopy_eqv T \ (contractible S \ contractible T)" +unfolding homotopy_eqv_def +by (blast intro: homotopy_dominated_contractibility) + +lemma homotopy_eqv_sing: + fixes S :: "'a::real_normed_vector set" and a :: "'b::real_normed_vector" + shows "S homotopy_eqv {a} \ S \ {} \ contractible S" +proof (cases "S = {}") + case True then show ?thesis + by simp +next + case False then show ?thesis + by (metis contractible_sing empty_not_insert homotopy_eqv_contractibility homotopy_eqv_contractible_sets) +qed + +lemma homeomorphic_contractible_eq: + fixes S :: "'a::real_normed_vector set" and T :: "'b::real_normed_vector set" + shows "S homeomorphic T \ (contractible S \ contractible T)" +by (simp add: homeomorphic_imp_homotopy_eqv homotopy_eqv_contractibility) + +lemma homeomorphic_contractible: + fixes S :: "'a::real_normed_vector set" and T :: "'b::real_normed_vector set" + shows "\contractible S; S homeomorphic T\ \ contractible T" +by (metis homeomorphic_contractible_eq) + end diff -r 00a135c0a17f -r 3b6975875633 src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Tue Jun 14 20:48:42 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Wed Jun 15 15:52:24 2016 +0100 @@ -15,6 +15,157 @@ Norm_Arith begin + +(*FIXME: move elsewhere and use the existing locales*) + +subsection \Using additivity of lifted function to encode definedness.\ + +definition "neutral opp = (SOME x. \y. opp x y = y \ opp y x = y)" + +fun lifted where + "lifted (opp :: 'a \ 'a \ 'b) (Some x) (Some y) = Some (opp x y)" +| "lifted opp None _ = (None::'b option)" +| "lifted opp _ None = None" + +lemma lifted_simp_1[simp]: "lifted opp v None = None" + by (induct v) auto + +definition "monoidal opp \ + (\x y. opp x y = opp y x) \ + (\x y z. opp x (opp y z) = opp (opp x y) z) \ + (\x. opp (neutral opp) x = x)" + +lemma monoidalI: + assumes "\x y. opp x y = opp y x" + and "\x y z. opp x (opp y z) = opp (opp x y) z" + and "\x. opp (neutral opp) x = x" + shows "monoidal opp" + unfolding monoidal_def using assms by fastforce + +lemma monoidal_ac: + assumes "monoidal opp" + shows [simp]: "opp (neutral opp) a = a" + and [simp]: "opp a (neutral opp) = a" + and "opp a b = opp b a" + and "opp (opp a b) c = opp a (opp b c)" + and "opp a (opp b c) = opp b (opp a c)" + using assms unfolding monoidal_def by metis+ + +lemma neutral_lifted [cong]: + assumes "monoidal opp" + shows "neutral (lifted opp) = Some (neutral opp)" +proof - + { fix x + assume "\y. lifted opp x y = y \ lifted opp y x = y" + then have "Some (neutral opp) = x" + apply (induct x) + apply force + by (metis assms lifted.simps(1) monoidal_ac(2) option.inject) } + note [simp] = this + show ?thesis + apply (subst neutral_def) + apply (intro some_equality allI) + apply (induct_tac y) + apply (auto simp add:monoidal_ac[OF assms]) + done +qed + +lemma monoidal_lifted[intro]: + assumes "monoidal opp" + shows "monoidal (lifted opp)" + unfolding monoidal_def split_option_all neutral_lifted[OF assms] + using monoidal_ac[OF assms] + by auto + +definition "support opp f s = {x. x\s \ f x \ neutral opp}" +definition "fold' opp e s = (if finite s then Finite_Set.fold opp e s else e)" +definition "iterate opp s f = fold' (\x a. opp (f x) a) (neutral opp) (support opp f s)" + +lemma support_subset[intro]: "support opp f s \ s" + unfolding support_def by auto + +lemma support_empty[simp]: "support opp f {} = {}" + using support_subset[of opp f "{}"] by auto + +lemma comp_fun_commute_monoidal[intro]: + assumes "monoidal opp" + shows "comp_fun_commute opp" + unfolding comp_fun_commute_def + using monoidal_ac[OF assms] + by auto + +lemma support_clauses: + "\f g s. support opp f {} = {}" + "\f g s. support opp f (insert x s) = + (if f(x) = neutral opp then support opp f s else insert x (support opp f s))" + "\f g s. support opp f (s - {x}) = (support opp f s) - {x}" + "\f g s. support opp f (s \ t) = (support opp f s) \ (support opp f t)" + "\f g s. support opp f (s \ t) = (support opp f s) \ (support opp f t)" + "\f g s. support opp f (s - t) = (support opp f s) - (support opp f t)" + "\f g s. support opp g (f ` s) = f ` (support opp (g \ f) s)" + unfolding support_def by auto + +lemma finite_support[intro]: "finite s \ finite (support opp f s)" + unfolding support_def by auto + +lemma iterate_empty[simp]: "iterate opp {} f = neutral opp" + unfolding iterate_def fold'_def by auto + +lemma iterate_insert[simp]: + assumes "monoidal opp" + and "finite s" + shows "iterate opp (insert x s) f = + (if x \ s then iterate opp s f else opp (f x) (iterate opp s f))" +proof (cases "x \ s") + case True + then show ?thesis by (auto simp: insert_absorb iterate_def) +next + case False + note * = comp_fun_commute.comp_comp_fun_commute [OF comp_fun_commute_monoidal[OF assms(1)]] + show ?thesis + proof (cases "f x = neutral opp") + case True + then show ?thesis + using assms \x \ s\ + by (auto simp: iterate_def support_clauses) + next + case False + with \x \ s\ \finite s\ support_subset show ?thesis + apply (simp add: iterate_def fold'_def support_clauses) + apply (subst comp_fun_commute.fold_insert[OF * finite_support, simplified comp_def]) + apply (force simp add: )+ + done + qed +qed + +lemma iterate_some: + "\monoidal opp; finite s\ \ iterate (lifted opp) s (\x. Some(f x)) = Some (iterate opp s f)" + by (erule finite_induct) (auto simp: monoidal_lifted) + +lemma neutral_add[simp]: "neutral op + = (0::'a::comm_monoid_add)" + unfolding neutral_def + by (force elim: allE [where x=0]) + +lemma support_if: "a \ neutral opp \ support opp (\x. if P x then a else neutral opp) A = {x \ A. P x}" +unfolding support_def +by (force intro: Collect_cong) + +lemma support_if_subset: "support opp (\x. if P x then a else neutral opp) A \ {x \ A. P x}" +by (simp add: subset_iff support_def) + +definition supp_setsum where "supp_setsum f A \ setsum f (support op+ f A)" + +lemma supp_setsum_divide_distrib: + "supp_setsum f A / (r::'a::field) = supp_setsum (\n. f n / r) A" +apply (cases "r = 0") +apply (simp add: supp_setsum_def) +apply (simp add: supp_setsum_def setsum_divide_distrib support_def) +done + +(*END OF SUPPORT, ETC.*) + + + lemma image_affinity_interval: fixes c :: "'a::ordered_real_vector" shows "((\x. m *\<^sub>R x + c) ` {a..b}) = (if {a..b}={} then {} @@ -691,6 +842,11 @@ lemma openin_open: "openin (subtopology euclidean U) S \ (\T. open T \ (S = U \ T))" by (auto simp add: openin_subtopology open_openin[symmetric]) +lemma openin_Int_open: + "\openin (subtopology euclidean U) S; open T\ + \ openin (subtopology euclidean U) (S \ T)" +by (metis open_Int Int_assoc openin_open) + lemma openin_open_Int[intro]: "open S \ openin (subtopology euclidean U) (U \ S)" by (auto simp add: openin_open) @@ -714,6 +870,11 @@ lemma closed_subset: "S \ T \ closed S \ closedin (subtopology euclidean T) S" by (auto simp add: closedin_closed) +lemma closedin_singleton [simp]: + fixes a :: "'a::t1_space" + shows "closedin (subtopology euclidean U) {a} \ a \ U" +using closedin_subset by (force intro: closed_subset) + lemma openin_euclidean_subtopology_iff: fixes S U :: "'a::metric_space set" shows "openin (subtopology euclidean U) S \