# HG changeset patch # User paulson # Date 1464014004 -3600 # Node ID 27afe7af737945931f9f387a72cc803b540f468e # Parent 932cf444f2fe6d661d3cae3b5d7dfd342f2c88ca Lots of new material for multivariate analysis diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Complex.thy --- a/src/HOL/Complex.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Complex.thy Mon May 23 15:33:24 2016 +0100 @@ -799,9 +799,15 @@ lemma exp_pi_i [simp]: "exp(of_real pi * ii) = -1" by (metis cis_conv_exp cis_pi mult.commute) +lemma exp_pi_i' [simp]: "exp(ii * of_real pi) = -1" + using cis_conv_exp cis_pi by auto + lemma exp_two_pi_i [simp]: "exp(2 * of_real pi * ii) = 1" by (simp add: exp_eq_polar complex_eq_iff) +lemma exp_two_pi_i' [simp]: "exp (\ * (of_real pi * 2)) = 1" + by (metis exp_two_pi_i mult.commute) + subsubsection \Complex argument\ definition arg :: "complex \ real" where diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy Mon May 23 15:33:24 2016 +0100 @@ -1,9 +1,8 @@ (* Title: HOL/Multivariate_Analysis/Convex_Euclidean_Space.thy - Author: Robert Himmelmann, TU Muenchen - Author: Bogdan Grechuk, University of Edinburgh + Authors: Robert Himmelmann, TU Muenchen; Bogdan Grechuk, University of Edinburgh; LCP *) -section \Convex sets, functions and related things.\ +section \Convex sets, functions and related things\ theory Convex_Euclidean_Space imports @@ -70,7 +69,7 @@ also have "\ \ (\x \ S. \y \ S. f (x - y) = 0 \ x - y = 0)" by (simp add: linear_sub[OF lf]) also have "\ \ (\x \ S. f x = 0 \ x = 0)" - using \subspace S\ subspace_def[of S] subspace_sub[of S] by auto + using \subspace S\ subspace_def[of S] subspace_diff[of S] by auto finally show ?thesis . qed @@ -426,6 +425,12 @@ lemma affine_Int[intro]: "affine s \ affine t \ affine (s \ t)" unfolding affine_def by auto +lemma affine_scaling: "affine s \ affine (image (\x. c *\<^sub>R x) s)" + apply (clarsimp simp add: affine_def) + apply (rule_tac x="u *\<^sub>R x + v *\<^sub>R y" in image_eqI) + apply (auto simp: algebra_simps) + done + lemma affine_affine_hull [simp]: "affine(affine hull s)" unfolding hull_def using affine_Inter[of "{t. affine t \ s \ t}"] by auto @@ -2915,11 +2920,16 @@ lemma aff_dim_subspace: fixes S :: "'n::euclidean_space set" - assumes "S \ {}" - and "subspace S" + assumes "subspace S" shows "aff_dim S = int (dim S)" - using aff_dim_affine[of S S] assms subspace_imp_affine[of S] affine_parallel_reflex[of S] - by auto +proof (cases "S={}") + case True with assms show ?thesis + by (simp add: subspace_affine) +next + case False + with aff_dim_affine[of S S] assms subspace_imp_affine[of S] affine_parallel_reflex[of S] subspace_affine + show ?thesis by auto +qed lemma aff_dim_zero: fixes S :: "'n::euclidean_space set" @@ -2964,6 +2974,41 @@ then show ?thesis by auto qed +lemma affine_independent_card_dim_diffs: + fixes S :: "'a :: euclidean_space set" + assumes "~ affine_dependent S" "a \ S" + shows "card S = dim {x - a|x. x \ S} + 1" +proof - + have 1: "{b - a|b. b \ (S - {a})} \ {x - a|x. x \ S}" by auto + have 2: "x - a \ span {b - a |b. b \ S - {a}}" if "x \ S" for x + proof (cases "x = a") + case True then show ?thesis by simp + next + case False then show ?thesis + using assms by (blast intro: span_superset that) + qed + have "\ affine_dependent (insert a S)" + by (simp add: assms insert_absorb) + then have 3: "independent {b - a |b. b \ S - {a}}" + using dependent_imp_affine_dependent by fastforce + have "{b - a |b. b \ S - {a}} = (\b. b-a) ` (S - {a})" + by blast + then have "card {b - a |b. b \ S - {a}} = card ((\b. b-a) ` (S - {a}))" + by simp + also have "... = card (S - {a})" + by (metis (no_types, lifting) card_image diff_add_cancel inj_onI) + also have "... = card S - 1" + by (simp add: aff_independent_finite assms) + finally have 4: "card {b - a |b. b \ S - {a}} = card S - 1" . + have "finite S" + by (meson assms aff_independent_finite) + with \a \ S\ have "card S \ 0" by auto + moreover have "dim {x - a |x. x \ S} = card S - 1" + using 2 by (blast intro: dim_unique [OF 1 _ 3 4]) + ultimately show ?thesis + by auto +qed + lemma independent_card_le_aff_dim: fixes B :: "'n::euclidean_space set" assumes "B \ V" @@ -3361,11 +3406,11 @@ lemma affine_hull_sing [simp]: "affine hull {a :: 'n::euclidean_space} = {a}" by (metis affine_hull_eq affine_sing) -lemma rel_interior_sing [simp]: "rel_interior {a :: 'n::euclidean_space} = {a}" - unfolding rel_interior_ball affine_hull_sing - apply auto - apply (rule_tac x = "1 :: real" in exI) - apply simp +lemma rel_interior_sing [simp]: + fixes a :: "'n::euclidean_space" shows "rel_interior {a} = {a}" + apply (auto simp: rel_interior_ball) + apply (rule_tac x=1 in exI) + apply force done lemma subset_rel_interior: @@ -3671,7 +3716,7 @@ ultimately show ?thesis by auto qed -lemma closure_aff_dim: +lemma closure_aff_dim [simp]: fixes S :: "'n::euclidean_space set" shows "aff_dim (closure S) = aff_dim S" proof - @@ -3911,7 +3956,7 @@ moreover have "f x - f xy = f (x - xy)" using assms linear_sub[of f x xy] linear_conv_bounded_linear[of f] by auto moreover have *: "x - xy \ span S" - using subspace_sub[of "span S" x xy] subspace_span \x \ S\ xy + using subspace_diff[of "span S" x xy] subspace_span \x \ S\ xy affine_hull_subset_span[of S] span_inc by auto moreover from * have "e1 * norm (x - xy) \ norm (f (x - xy))" @@ -6570,6 +6615,17 @@ "\linear f; inj f\ \ open_segment (f a) (f b) = f ` (open_segment a b)" by (force simp: open_segment_def closed_segment_linear_image inj_on_def) +lemma closed_segment_translation: + "closed_segment (c + a) (c + b) = image (\x. c + x) (closed_segment a b)" +apply safe +apply (rule_tac x="x-c" in image_eqI) +apply (auto simp: in_segment algebra_simps) +done + +lemma open_segment_translation: + "open_segment (c + a) (c + b) = image (\x. c + x) (open_segment a b)" +by (simp add: open_segment_def closed_segment_translation translation_diff) + lemma open_segment_PairD: "(x, x') \ open_segment (a, a') (b, b') \ (x \ open_segment a b \ a = b) \ (x' \ open_segment a' b' \ a' = b')" @@ -6782,6 +6838,118 @@ fixes u::real shows "closed_segment u v = (\x. (v - u) * x + u) ` {0..1}" by (simp add: add.commute [of u] image_affinity_atLeastAtMost [where c=u] closed_segment_eq_real_ivl) +lemma dist_in_closed_segment: + fixes a :: "'a :: euclidean_space" + assumes "x \ closed_segment a b" + shows "dist x a \ dist a b \ dist x b \ dist a b" +proof (intro conjI) + obtain u where u: "0 \ u" "u \ 1" and x: "x = (1 - u) *\<^sub>R a + u *\<^sub>R b" + using assms by (force simp: in_segment algebra_simps) + have "dist x a = u * dist a b" + apply (simp add: dist_norm algebra_simps x) + by (metis \0 \ u\ abs_of_nonneg norm_minus_commute norm_scaleR real_vector.scale_right_diff_distrib) + also have "... \ dist a b" + by (simp add: mult_left_le_one_le u) + finally show "dist x a \ dist a b" . + have "dist x b = norm ((1-u) *\<^sub>R a - (1-u) *\<^sub>R b)" + by (simp add: dist_norm algebra_simps x) + also have "... = (1-u) * dist a b" + proof - + have "norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)" + using \u \ 1\ by force + then show ?thesis + by (simp add: dist_norm real_vector.scale_right_diff_distrib) + qed + also have "... \ dist a b" + by (simp add: mult_left_le_one_le u) + finally show "dist x b \ dist a b" . +qed + +lemma dist_in_open_segment: + fixes a :: "'a :: euclidean_space" + assumes "x \ open_segment a b" + shows "dist x a < dist a b \ dist x b < dist a b" +proof (intro conjI) + obtain u where u: "0 < u" "u < 1" and x: "x = (1 - u) *\<^sub>R a + u *\<^sub>R b" + using assms by (force simp: in_segment algebra_simps) + have "dist x a = u * dist a b" + apply (simp add: dist_norm algebra_simps x) + by (metis abs_of_nonneg less_eq_real_def norm_minus_commute norm_scaleR real_vector.scale_right_diff_distrib \0 < u\) + also have *: "... < dist a b" + by (metis (no_types) assms dist_eq_0_iff dist_not_less_zero in_segment(2) linorder_neqE_linordered_idom mult.left_neutral real_mult_less_iff1 \u < 1\) + finally show "dist x a < dist a b" . + have ab_ne0: "dist a b \ 0" + using * by fastforce + have "dist x b = norm ((1-u) *\<^sub>R a - (1-u) *\<^sub>R b)" + by (simp add: dist_norm algebra_simps x) + also have "... = (1-u) * dist a b" + proof - + have "norm ((1 - 1 * u) *\<^sub>R (a - b)) = (1 - 1 * u) * norm (a - b)" + using \u < 1\ by force + then show ?thesis + by (simp add: dist_norm real_vector.scale_right_diff_distrib) + qed + also have "... < dist a b" + using ab_ne0 \0 < u\ by simp + finally show "dist x b < dist a b" . +qed + +lemma dist_decreases_open_segment_0: + fixes x :: "'a :: euclidean_space" + assumes "x \ open_segment 0 b" + shows "dist c x < dist c 0 \ dist c x < dist c b" +proof (rule ccontr, clarsimp simp: not_less) + obtain u where u: "0 \ b" "0 < u" "u < 1" and x: "x = u *\<^sub>R b" + using assms by (auto simp: in_segment) + have xb: "x \ b < b \ b" + using u x by auto + assume "norm c \ dist c x" + then have "c \ c \ (c - x) \ (c - x)" + by (simp add: dist_norm norm_le) + moreover have "0 < x \ b" + using u x by auto + ultimately have less: "c \ b < x \ b" + by (simp add: x algebra_simps inner_commute u) + assume "dist c b \ dist c x" + then have "(c - b) \ (c - b) \ (c - x) \ (c - x)" + by (simp add: dist_norm norm_le) + then have "(b \ b) * (1 - u*u) \ 2 * (b \ c) * (1-u)" + by (simp add: x algebra_simps inner_commute) + then have "(1+u) * (b \ b) * (1-u) \ 2 * (b \ c) * (1-u)" + by (simp add: algebra_simps) + then have "(1+u) * (b \ b) \ 2 * (b \ c)" + using \u < 1\ by auto + with xb have "c \ b \ x \ b" + by (auto simp: x algebra_simps inner_commute) + with less show False by auto +qed + +proposition dist_decreases_open_segment: + fixes a :: "'a :: euclidean_space" + assumes "x \ open_segment a b" + shows "dist c x < dist c a \ dist c x < dist c b" +proof - + have *: "x - a \ open_segment 0 (b - a)" using assms + by (metis diff_self open_segment_translation_eq uminus_add_conv_diff) + show ?thesis + using dist_decreases_open_segment_0 [OF *, of "c-a"] assms + by (simp add: dist_norm) +qed + +lemma dist_decreases_closed_segment: + fixes a :: "'a :: euclidean_space" + assumes "x \ closed_segment a b" + shows "dist c x \ dist c a \ dist c x \ dist c b" +apply (cases "x \ open_segment a b") + using dist_decreases_open_segment less_eq_real_def apply blast +by (metis DiffI assms empty_iff insertE open_segment_def order_refl) + +lemma convex_intermediate_ball: + fixes a :: "'a :: euclidean_space" + shows "\ball a r \ T; T \ cball a r\ \ convex T" +apply (simp add: convex_contains_open_segment, clarify) +by (metis (no_types, hide_lams) less_le_trans mem_ball mem_cball subsetCE dist_decreases_open_segment) + subsubsection\More lemmas, especially for working with the underlying formula\ lemma segment_eq_compose: @@ -8157,6 +8325,28 @@ definition "rel_frontier S = closure S - rel_interior S" +lemma rel_frontier_empty [simp]: "rel_frontier {} = {}" + by (simp add: rel_frontier_def) + +lemma rel_frontier_sing [simp]: + fixes a :: "'n::euclidean_space" + shows "rel_frontier {a} = {}" + by (simp add: rel_frontier_def) + +lemma rel_frontier_cball [simp]: + fixes a :: "'n::euclidean_space" + shows "rel_frontier(cball a r) = (if r = 0 then {} else sphere a r)" +proof (cases rule: linorder_cases [of r 0]) + case less then show ?thesis + by (force simp: sphere_def) +next + case equal then show ?thesis by simp +next + case greater then show ?thesis + apply simp + by (metis centre_in_ball empty_iff frontier_cball frontier_def interior_cball interior_rel_interior_gen rel_frontier_def) +qed + lemma closed_affine_hull: fixes S :: "'n::euclidean_space set" shows "closed (affine hull S)" @@ -8190,6 +8380,43 @@ done qed +lemma closed_rel_boundary: + fixes S :: "'n::euclidean_space set" + shows "closed S \ closed(S - rel_interior S)" +by (metis closed_rel_frontier closure_closed rel_frontier_def) + +lemma compact_rel_boundary: + fixes S :: "'n::euclidean_space set" + shows "compact S \ compact(S - rel_interior S)" +by (metis bounded_diff closed_rel_boundary closure_eq compact_closure compact_imp_closed) + +lemma bounded_rel_frontier: + fixes S :: "'n::euclidean_space set" + shows "bounded S \ bounded(rel_frontier S)" +by (simp add: bounded_closure bounded_diff rel_frontier_def) + +lemma compact_rel_frontier_bounded: + fixes S :: "'n::euclidean_space set" + shows "bounded S \ compact(rel_frontier S)" +using bounded_rel_frontier closed_rel_frontier compact_eq_bounded_closed by blast + +lemma compact_rel_frontier: + fixes S :: "'n::euclidean_space set" + shows "compact S \ compact(rel_frontier S)" +by (meson compact_eq_bounded_closed compact_rel_frontier_bounded) + +lemma convex_same_rel_interior_closure: + fixes S :: "'n::euclidean_space set" + shows "\convex S; convex T\ + \ rel_interior S = rel_interior T \ closure S = closure T" +by (simp add: closure_eq_rel_interior_eq) + +lemma convex_same_rel_interior_closure_straddle: + fixes S :: "'n::euclidean_space set" + shows "\convex S; convex T\ + \ rel_interior S = rel_interior T \ + rel_interior S \ T \ T \ closure S" +by (simp add: closure_eq_between convex_same_rel_interior_closure) lemma convex_rel_frontier_aff_dim: fixes S1 S2 :: "'n::euclidean_space set" @@ -10701,6 +10928,16 @@ shows "setdist s {x} = 0 \ s = {} \ x \ closure s" by (auto simp: setdist_eq_0_bounded) +lemma setdist_neq_0_sing_1: + fixes s :: "'a::euclidean_space set" + shows "\setdist {x} s = a; a \ 0\ \ s \ {} \ x \ closure s" +by auto + +lemma setdist_neq_0_sing_2: + fixes s :: "'a::euclidean_space set" + shows "\setdist s {x} = a; a \ 0\ \ s \ {} \ x \ closure s" +by auto + lemma setdist_sing_in_set: fixes s :: "'a::euclidean_space set" shows "x \ s \ setdist {x} s = 0" @@ -12046,6 +12283,42 @@ done qed +proposition orthonormal_basis_subspace: + fixes S :: "'a :: euclidean_space set" + assumes "subspace S" + obtains B where "B \ S" "pairwise orthogonal B" + and "\x. x \ B \ norm x = 1" + and "independent B" "card B = dim S" "span B = S" +proof - + obtain B where "0 \ B" "B \ S" + and orth: "pairwise orthogonal B" + and "independent B" "card B = dim S" "span B = S" + by (blast intro: orthogonal_basis_subspace [OF assms]) + have 1: "(\x. x /\<^sub>R norm x) ` B \ S" + using \span B = S\ span_clauses(1) span_mul by fastforce + have 2: "pairwise orthogonal ((\x. x /\<^sub>R norm x) ` B)" + using orth by (force simp: pairwise_def orthogonal_clauses) + have 3: "\x. x \ (\x. x /\<^sub>R norm x) ` B \ norm x = 1" + by (metis (no_types, lifting) \0 \ B\ image_iff norm_sgn sgn_div_norm) + have 4: "independent ((\x. x /\<^sub>R norm x) ` B)" + by (metis "2" "3" norm_zero pairwise_orthogonal_independent zero_neq_one) + have "inj_on (\x. x /\<^sub>R norm x) B" + proof + fix x y + assume "x \ B" "y \ B" "x /\<^sub>R norm x = y /\<^sub>R norm y" + moreover have "\i. i \ B \ norm (i /\<^sub>R norm i) = 1" + using 3 by blast + ultimately show "x = y" + by (metis norm_eq_1 orth orthogonal_clauses(7) orthogonal_commute orthogonal_def pairwise_def zero_neq_one) + qed + then have 5: "card ((\x. x /\<^sub>R norm x) ` B) = dim S" + by (metis \card B = dim S\ card_image) + have 6: "span ((\x. x /\<^sub>R norm x) ` B) = S" + by (metis "1" "4" "5" assms card_eq_dim independent_finite span_subspace) + show ?thesis + by (rule that [OF 1 2 3 4 5 6]) +qed + proposition orthogonal_subspace_decomp_exists: fixes S :: "'a :: euclidean_space set" obtains y z where "y \ span S" "\w. w \ span S \ orthogonal z w" "x = y + z" @@ -12078,6 +12351,7 @@ with assms show ?thesis by auto qed +subsection\Parallel slices, etc.\ text\ If we take a slice out of a set, we can do it perpendicularly, with the normal vector to the slice parallel to the affine hull.\ @@ -12139,4 +12413,167 @@ qed qed +lemma diffs_affine_hull_span: + assumes "a \ S" + shows "{x - a |x. x \ affine hull S} = span {x - a |x. x \ S}" +proof - + have *: "((\x. x - a) ` (S - {a})) = {x. x + a \ S} - {0}" + by (auto simp: algebra_simps) + show ?thesis + apply (simp add: affine_hull_span2 [OF assms] *) + apply (auto simp: algebra_simps) + done +qed + +lemma aff_dim_dim_affine_diffs: + fixes S :: "'a :: euclidean_space set" + assumes "affine S" "a \ S" + shows "aff_dim S = dim {x - a |x. x \ S}" +proof - + obtain B where aff: "affine hull B = affine hull S" + and ind: "\ affine_dependent B" + and card: "of_nat (card B) = aff_dim S + 1" + using aff_dim_basis_exists by blast + then have "B \ {}" using assms + by (metis affine_hull_eq_empty ex_in_conv) + then obtain c where "c \ B" by auto + then have "c \ S" + by (metis aff affine_hull_eq \affine S\ hull_inc) + have xy: "x - c = y - a \ y = x + 1 *\<^sub>R (a - c)" for x y c and a::'a + by (auto simp: algebra_simps) + have *: "{x - c |x. x \ S} = {x - a |x. x \ S}" + apply safe + apply (simp_all only: xy) + using mem_affine_3_minus [OF \affine S\] \a \ S\ \c \ S\ apply blast+ + done + have affS: "affine hull S = S" + by (simp add: \affine S\) + have "aff_dim S = of_nat (card B) - 1" + using card by simp + also have "... = dim {x - c |x. x \ B}" + by (simp add: affine_independent_card_dim_diffs [OF ind \c \ B\]) + also have "... = dim {x - c | x. x \ affine hull B}" + by (simp add: diffs_affine_hull_span \c \ B\) + also have "... = dim {x - a |x. x \ S}" + by (simp add: affS aff *) + finally show ?thesis . +qed + +lemma aff_dim_linear_image_le: + assumes "linear f" + shows "aff_dim(f ` S) \ aff_dim S" +proof - + have "aff_dim (f ` T) \ aff_dim T" if "affine T" for T + proof (cases "T = {}") + case True then show ?thesis by (simp add: aff_dim_geq) + next + case False + then obtain a where "a \ T" by auto + have 1: "((\x. x - f a) ` f ` T) = {x - f a |x. x \ f ` T}" + by auto + have 2: "{x - f a| x. x \ f ` T} = f ` {x - a| x. x \ T}" + by (force simp: linear_sub [OF assms]) + have "aff_dim (f ` T) = int (dim {x - f a |x. x \ f ` T})" + by (simp add: \a \ T\ hull_inc aff_dim_eq_dim [of "f a"] 1) + also have "... = int (dim (f ` {x - a| x. x \ T}))" + by (force simp: linear_sub [OF assms] 2) + also have "... \ int (dim {x - a| x. x \ T})" + by (simp add: dim_image_le [OF assms]) + also have "... \ aff_dim T" + by (simp add: aff_dim_dim_affine_diffs [symmetric] \a \ T\ \affine T\) + finally show ?thesis . + qed + then + have "aff_dim (f ` (affine hull S)) \ aff_dim (affine hull S)" + using affine_affine_hull [of S] by blast + then show ?thesis + using affine_hull_linear_image assms linear_conv_bounded_linear by fastforce +qed + +lemma aff_dim_injective_linear_image [simp]: + assumes "linear f" "inj f" + shows "aff_dim (f ` S) = aff_dim S" +proof (rule antisym) + show "aff_dim (f ` S) \ aff_dim S" + by (simp add: aff_dim_linear_image_le assms(1)) +next + obtain g where "linear g" "g \ f = id" + using linear_injective_left_inverse assms by blast + then have "aff_dim S \ aff_dim(g ` f ` S)" + by (simp add: image_comp) + also have "... \ aff_dim (f ` S)" + by (simp add: \linear g\ aff_dim_linear_image_le) + finally show "aff_dim S \ aff_dim (f ` S)" . +qed + +text\Choosing a subspace of a given dimension\ +proposition choose_subspace_of_subspace: + fixes S :: "'n::euclidean_space set" + assumes "n \ dim S" + obtains T where "subspace T" "T \ span S" "dim T = n" +proof - + have "\T. subspace T \ T \ span S \ dim T = n" + using assms + proof (induction n) + case 0 then show ?case by force + next + case (Suc n) + then obtain T where "subspace T" "T \ span S" "dim T = n" + by force + then show ?case + proof (cases "span S \ span T") + case True + have "dim S = dim T" + apply (rule span_eq_dim [OF subset_antisym [OF True]]) + by (simp add: \T \ span S\ span_minimal subspace_span) + then show ?thesis + using Suc.prems \dim T = n\ by linarith + next + case False + then obtain y where y: "y \ S" "y \ T" + by (meson span_mono subsetI) + then have "span (insert y T) \ span S" + by (metis (no_types) \T \ span S\ subsetD insert_subset span_inc span_mono span_span) + with \dim T = n\ \subspace T\ span_induct y show ?thesis + apply (rule_tac x="span(insert y T)" in exI) + apply (auto simp: subspace_span dim_insert) + done + qed + qed + with that show ?thesis by blast +qed + +lemma choose_affine_subset: + assumes "affine S" "-1 \ d" and dle: "d \ aff_dim S" + obtains T where "affine T" "T \ S" "aff_dim T = d" +proof (cases "d = -1 \ S={}") + case True with assms show ?thesis + by (metis aff_dim_empty affine_empty bot.extremum that eq_iff) +next + case False + with assms obtain a where "a \ S" "0 \ d" by auto + with assms have ss: "subspace (op + (- a) ` S)" + by (simp add: affine_diffs_subspace) + have "nat d \ dim (op + (- a) ` S)" + by (metis aff_dim_subspace aff_dim_translation_eq dle nat_int nat_mono ss) + then obtain T where "subspace T" and Tsb: "T \ span (op + (- a) ` S)" + and Tdim: "dim T = nat d" + using choose_subspace_of_subspace [of "nat d" "op + (- a) ` S"] by blast + then have "affine T" + using subspace_affine by blast + then have "affine (op + a ` T)" + by (metis affine_hull_eq affine_hull_translation) + moreover have "op + a ` T \ S" + proof - + have "T \ op + (- a) ` S" + by (metis (no_types) span_eq Tsb ss) + then show "op + a ` T \ S" + using add_ac by auto + qed + moreover have "aff_dim (op + a ` T) = d" + by (simp add: aff_dim_subspace Tdim \0 \ d\ \subspace T\ aff_dim_translation_eq) + ultimately show ?thesis + by (rule that) +qed + end diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Multivariate_Analysis/Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Mon May 23 15:33:24 2016 +0100 @@ -110,6 +110,18 @@ lemma DIM_ge_Suc0 [iff]: "Suc 0 \ card Basis" by (meson DIM_positive Suc_leI) + +lemma setsum_inner_Basis_scaleR [simp]: + fixes f :: "'a::euclidean_space \ 'b::real_vector" + assumes "b \ Basis" shows "(\i\Basis. (inner i b) *\<^sub>R f i) = f b" + by (simp add: comm_monoid_add_class.setsum.remove [OF finite_Basis assms] + assms inner_not_same_Basis comm_monoid_add_class.setsum.neutral) + +lemma setsum_inner_Basis_eq [simp]: + assumes "b \ Basis" shows "(\i\Basis. (inner i b) * f i) = f b" + by (simp add: comm_monoid_add_class.setsum.remove [OF finite_Basis assms] + assms inner_not_same_Basis comm_monoid_add_class.setsum.neutral) + subsection \Subclass relationships\ instance euclidean_space \ perfect_space diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Multivariate_Analysis/Linear_Algebra.thy --- a/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Mon May 23 15:33:24 2016 +0100 @@ -223,7 +223,7 @@ lemma subspace_neg: "subspace S \ x \ S \ - x \ S" by (metis scaleR_minus1_left subspace_mul) -lemma subspace_sub: "subspace S \ x \ S \ y \ S \ x - y \ S" +lemma subspace_diff: "subspace S \ x \ S \ y \ S \ x - y \ S" using subspace_add [of S x "- y"] by (simp add: subspace_neg) lemma (in real_vector) subspace_setsum: @@ -434,7 +434,7 @@ by (metis subspace_neg subspace_span) lemma span_sub: "x \ span S \ y \ span S \ x - y \ span S" - by (metis subspace_span subspace_sub) + by (metis subspace_span subspace_diff) lemma (in real_vector) span_setsum: "(\x. x \ A \ f x \ span S) \ setsum f A \ span S" by (rule subspace_setsum [OF subspace_span]) @@ -1524,6 +1524,46 @@ lemma orthogonal_commute: "orthogonal x y \ orthogonal y x" by (simp add: orthogonal_def inner_commute) +lemma orthogonal_scaleR [simp]: "c \ 0 \ orthogonal (c *\<^sub>R x) = orthogonal x" + by (rule ext) (simp add: orthogonal_def) + +lemma pairwise_ortho_scaleR: + "pairwise (\i j. orthogonal (f i) (g j)) B + \ pairwise (\i j. orthogonal (a i *\<^sub>R f i) (a j *\<^sub>R g j)) B" + by (auto simp: pairwise_def orthogonal_clauses) + +lemma orthogonal_rvsum: + "\finite s; \y. y \ s \ orthogonal x (f y)\ \ orthogonal x (setsum f s)" + by (induction s rule: finite_induct) (auto simp: orthogonal_clauses) + +lemma orthogonal_lvsum: + "\finite s; \x. x \ s \ orthogonal (f x) y\ \ orthogonal (setsum f s) y" + by (induction s rule: finite_induct) (auto simp: orthogonal_clauses) + +lemma norm_add_Pythagorean: + assumes "orthogonal a b" + shows "norm(a + b) ^ 2 = norm a ^ 2 + norm b ^ 2" +proof - + from assms have "(a - (0 - b)) \ (a - (0 - b)) = a \ a - (0 - b \ b)" + by (simp add: algebra_simps orthogonal_def inner_commute) + then show ?thesis + by (simp add: power2_norm_eq_inner) +qed + +lemma norm_setsum_Pythagorean: + assumes "finite I" "pairwise (\i j. orthogonal (f i) (f j)) I" + shows "(norm (setsum f I))\<^sup>2 = (\i\I. (norm (f i))\<^sup>2)" +using assms +proof (induction I rule: finite_induct) + case empty then show ?case by simp +next + case (insert x I) + then have "orthogonal (f x) (setsum f I)" + by (metis pairwise_insert orthogonal_rvsum) + with insert show ?case + by (simp add: pairwise_insert norm_add_Pythagorean) +qed + subsection \Bilinear functions.\ diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Multivariate_Analysis/Path_Connected.thy --- a/src/HOL/Multivariate_Analysis/Path_Connected.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Path_Connected.thy Mon May 23 15:33:24 2016 +0100 @@ -2109,6 +2109,79 @@ by (auto simp: closure_def) qed +lemma connected_disjoint_Union_open_pick: + assumes "pairwise disjnt B" + "\S. S \ A \ connected S \ S \ {}" + "\S. S \ B \ open S" + "\A \ \B" + "S \ A" + obtains T where "T \ B" "S \ T" "S \ \(B - {T}) = {}" +proof - + have "S \ \B" "connected S" "S \ {}" + using assms \S \ A\ by blast+ + then obtain T where "T \ B" "S \ T \ {}" + by (metis Sup_inf_eq_bot_iff inf.absorb_iff2 inf_commute) + have 1: "open T" by (simp add: \T \ B\ assms) + have 2: "open (\(B-{T}))" using assms by blast + have 3: "S \ T \ \(B - {T})" using \S \ \B\ by blast + have "T \ \(B - {T}) = {}" using \T \ B\ \pairwise disjnt B\ + by (auto simp: pairwise_def disjnt_def) + then have 4: "T \ \(B - {T}) \ S = {}" by auto + from connectedD [OF \connected S\ 1 2 3 4] + have "S \ \(B-{T}) = {}" + by (auto simp: Int_commute \S \ T \ {}\) + with \T \ B\ have "S \ T" + using "3" by auto + show ?thesis + using \S \ \(B - {T}) = {}\ \S \ T\ \T \ B\ that by auto +qed + +lemma connected_disjoint_Union_open_subset: + assumes A: "pairwise disjnt A" and B: "pairwise disjnt B" + and SA: "\S. S \ A \ open S \ connected S \ S \ {}" + and SB: "\S. S \ B \ open S \ connected S \ S \ {}" + and eq [simp]: "\A = \B" + shows "A \ B" +proof + fix S + assume "S \ A" + obtain T where "T \ B" "S \ T" "S \ \(B - {T}) = {}" + apply (rule connected_disjoint_Union_open_pick [OF B, of A]) + using SA SB \S \ A\ by auto + moreover obtain S' where "S' \ A" "T \ S'" "T \ \(A - {S'}) = {}" + apply (rule connected_disjoint_Union_open_pick [OF A, of B]) + using SA SB \T \ B\ by auto + ultimately have "S' = S" + by (metis A Int_subset_iff SA \S \ A\ disjnt_def inf.orderE pairwise_def) + with \T \ S'\ have "T \ S" by simp + with \S \ T\ have "S = T" by blast + with \T \ B\ show "S \ B" by simp +qed + +lemma connected_disjoint_Union_open_unique: + assumes A: "pairwise disjnt A" and B: "pairwise disjnt B" + and SA: "\S. S \ A \ open S \ connected S \ S \ {}" + and SB: "\S. S \ B \ open S \ connected S \ S \ {}" + and eq [simp]: "\A = \B" + shows "A = B" +by (rule subset_antisym; metis connected_disjoint_Union_open_subset assms) + +proposition components_open_unique: + fixes S :: "'a::real_normed_vector set" + assumes "pairwise disjnt A" "\A = S" + "\X. X \ A \ open X \ connected X \ X \ {}" + shows "components S = A" +proof - + have "open S" using assms by blast + show ?thesis + apply (rule connected_disjoint_Union_open_unique) + apply (simp add: components_eq disjnt_def pairwise_def) + using \open S\ + apply (simp_all add: assms open_components in_components_connected in_components_nonempty) + done +qed + + subsection\Existence of unbounded components\ lemma cobounded_unbounded_component: @@ -3742,14 +3815,13 @@ lemma homotopic_paths_linear: fixes g h :: "real \ 'a::real_normed_vector" assumes "path g" "path h" "pathstart h = pathstart g" "pathfinish h = pathfinish g" - "\t x. t \ {0..1} \ closed_segment (g t) (h t) \ s" + "\t. t \ {0..1} \ closed_segment (g t) (h t) \ s" shows "homotopic_paths s g h" using assms unfolding path_def apply (simp add: closed_segment_def pathstart_def pathfinish_def homotopic_paths_def homotopic_with_def) - apply (rule_tac x="\y. ((1 - (fst y)) *\<^sub>R g(snd y) + (fst y) *\<^sub>R h(snd y))" in exI) - apply (intro conjI subsetI continuous_intros) - apply (fastforce intro: continuous_intros continuous_on_compose2 [where g=g] continuous_on_compose2 [where g=h])+ + apply (rule_tac x="\y. ((1 - (fst y)) *\<^sub>R (g o snd) y + (fst y) *\<^sub>R (h o snd) y)" in exI) + apply (intro conjI subsetI continuous_intros; force) done lemma homotopic_loops_linear: @@ -5052,6 +5124,346 @@ apply (force simp: convex_Int convex_imp_path_connected) done +subsection\Components, continuity, openin, closedin\ + +lemma continuous_openin_preimage_eq: + "continuous_on S f \ + (\t. open t \ openin (subtopology euclidean S) {x. x \ S \ f x \ t})" +apply (auto simp: continuous_openin_preimage) +apply (fastforce simp add: continuous_on_open openin_open) +done + +lemma continuous_closedin_preimage_eq: + "continuous_on S f \ + (\t. closed t \ closedin (subtopology euclidean S) {x. x \ S \ f x \ t})" +apply safe +apply (simp add: continuous_closedin_preimage) +apply (fastforce simp add: continuous_on_closed closedin_closed) +done + +lemma continuous_on_components_gen: + fixes f :: "'a::topological_space \ 'b::topological_space" + assumes "\c. c \ components S \ + openin (subtopology euclidean S) c \ continuous_on c f" + shows "continuous_on S f" +proof (clarsimp simp: continuous_openin_preimage_eq) + fix t :: "'b set" + assume "open t" + have "{x. x \ S \ f x \ t} = \{{x. x \ c \ f x \ t} |c. c \ components S}" + apply auto + apply (metis (lifting) components_iff connected_component_refl_eq mem_Collect_eq) + using Union_components by blast + then show "openin (subtopology euclidean S) {x \ S. f x \ t}" + using \open t\ assms + by (fastforce intro: openin_trans continuous_openin_preimage) +qed + +lemma continuous_on_components: + fixes f :: "'a::topological_space \ 'b::topological_space" + assumes "locally connected S " + "\c. c \ components S \ continuous_on c f" + shows "continuous_on S f" +apply (rule continuous_on_components_gen) +apply (auto simp: assms intro: openin_components_locally_connected) +done + +lemma continuous_on_components_eq: + "locally connected S + \ (continuous_on S f \ (\c \ components S. continuous_on c f))" +by (meson continuous_on_components continuous_on_subset in_components_subset) + +lemma continuous_on_components_open: + fixes S :: "'a::real_normed_vector set" + assumes "open S " + "\c. c \ components S \ continuous_on c f" + shows "continuous_on S f" +using continuous_on_components open_imp_locally_connected assms by blast + +lemma continuous_on_components_open_eq: + fixes S :: "'a::real_normed_vector set" + shows "open S \ (continuous_on S f \ (\c \ components S. continuous_on c f))" +using continuous_on_subset in_components_subset +by (blast intro: continuous_on_components_open) + +lemma closedin_union_complement_components: + assumes u: "locally connected u" + and S: "closedin (subtopology euclidean u) S" + and cuS: "c \ components(u - S)" + shows "closedin (subtopology euclidean u) (S \ \c)" +proof - + have di: "(\S t. S \ c \ t \ c' \ disjnt S t) \ disjnt (\ c) (\ c')" for c' + by (simp add: disjnt_def) blast + have "S \ u" + using S closedin_imp_subset by blast + moreover have "u - S = \c \ \(components (u - S) - c)" + by (metis Diff_partition Topology_Euclidean_Space.Union_components Union_Un_distrib assms(3)) + moreover have "disjnt (\c) (\(components (u - S) - c))" + apply (rule di) + by (metis DiffD1 DiffD2 assms(3) components_nonoverlap disjnt_def subsetCE) + ultimately have eq: "S \ \c = u - (\(components(u - S) - c))" + by (auto simp: disjnt_def) + have *: "openin (subtopology euclidean u) (\(components (u - S) - c))" + apply (rule openin_Union) + apply (rule openin_trans [of "u - S"]) + apply (simp add: u S locally_diff_closed openin_components_locally_connected) + apply (simp add: openin_diff S) + done + have "openin (subtopology euclidean u) (u - (u - \(components (u - S) - c)))" + apply (rule openin_diff, simp) + apply (metis closedin_diff closedin_topspace topspace_euclidean_subtopology *) + done + then show ?thesis + by (force simp: eq closedin_def) +qed + +lemma closed_union_complement_components: + fixes S :: "'a::real_normed_vector set" + assumes S: "closed S" and c: "c \ components(- S)" + shows "closed(S \ \ c)" +proof - + have "closedin (subtopology euclidean UNIV) (S \ \c)" + apply (rule closedin_union_complement_components [OF locally_connected_UNIV]) + using S apply (simp add: closed_closedin) + using c apply (simp add: Compl_eq_Diff_UNIV) + done + then show ?thesis + by (simp add: closed_closedin) +qed + +lemma closedin_Un_complement_component: + fixes S :: "'a::real_normed_vector set" + assumes u: "locally connected u" + and S: "closedin (subtopology euclidean u) S" + and c: " c \ components(u - S)" + shows "closedin (subtopology euclidean u) (S \ c)" +proof - + have "closedin (subtopology euclidean u) (S \ \{c})" + using c by (blast intro: closedin_union_complement_components [OF u S]) + then show ?thesis + by simp +qed + +lemma closed_Un_complement_component: + fixes S :: "'a::real_normed_vector set" + assumes S: "closed S" and c: " c \ components(-S)" + shows "closed (S \ c)" +by (metis Compl_eq_Diff_UNIV S c closed_closedin closedin_Un_complement_component locally_connected_UNIV subtopology_UNIV) + + +subsection\Existence of isometry between subspaces of same dimension\ + +thm subspace_isomorphism +lemma isometry_subset_subspace: + fixes S :: "'a::euclidean_space set" + and T :: "'b::euclidean_space set" + assumes S: "subspace S" + and T: "subspace T" + and d: "dim S \ dim T" + obtains f where "linear f" "f ` S \ T" "\x. x \ S \ norm(f x) = norm x" +proof - + obtain B where "B \ S" and Borth: "pairwise orthogonal B" + and B1: "\x. x \ B \ norm x = 1" + and "independent B" "finite B" "card B = dim S" "span B = S" + by (metis orthonormal_basis_subspace [OF S] independent_finite) + obtain C where "C \ T" and Corth: "pairwise orthogonal C" + and C1:"\x. x \ C \ norm x = 1" + and "independent C" "finite C" "card C = dim T" "span C = T" + by (metis orthonormal_basis_subspace [OF T] independent_finite) + obtain fb where "fb ` B \ C" "inj_on fb B" + by (metis \card B = dim S\ \card C = dim T\ \finite B\ \finite C\ card_le_inj d) + then have pairwise_orth_fb: "pairwise (\v j. orthogonal (fb v) (fb j)) B" + using Corth + apply (auto simp: pairwise_def orthogonal_clauses) + by (meson subsetD image_eqI inj_on_def) + obtain f where "linear f" and ffb: "\x. x \ B \ f x = fb x" + using linear_independent_extend \independent B\ by fastforce + have "f ` S \ T" + by (metis ffb \fb ` B \ C\ \linear f\ \span B = S\ \span C = T\ image_cong span_linear_image span_mono) + have [simp]: "\x. x \ B \ norm (fb x) = norm x" + using B1 C1 \fb ` B \ C\ by auto + have "norm (f x) = norm x" if "x \ S" for x + proof - + obtain a where x: "x = (\v \ B. a v *\<^sub>R v)" + using \finite B\ \span B = S\ \x \ S\ span_finite by fastforce + have "f x = (\v \ B. f (a v *\<^sub>R v))" + using linear_setsum [OF \linear f\] x by auto + also have "... = (\v \ B. a v *\<^sub>R f v)" + using \linear f\ by (simp add: linear_setsum linear.scaleR) + also have "... = (\v \ B. a v *\<^sub>R fb v)" + by (simp add: ffb cong: setsum.cong) + finally have "norm (f x)^2 = norm (\v\B. a v *\<^sub>R fb v)^2" by simp + also have "... = (\v\B. norm ((a v *\<^sub>R fb v))^2)" + apply (rule norm_setsum_Pythagorean [OF \finite B\]) + apply (rule pairwise_ortho_scaleR [OF pairwise_orth_fb]) + done + also have "... = norm x ^2" + by (simp add: x pairwise_ortho_scaleR Borth norm_setsum_Pythagorean [OF \finite B\]) + finally show ?thesis + by (simp add: norm_eq_sqrt_inner) + qed + then show ?thesis + by (rule that [OF \linear f\ \f ` S \ T\]) +qed + +proposition isometries_subspaces: + fixes S :: "'a::euclidean_space set" + and T :: "'b::euclidean_space set" + assumes S: "subspace S" + and T: "subspace T" + and d: "dim S = dim T" + obtains f g where "linear f" "linear g" "f ` S = T" "g ` T = S" + "\x. x \ S \ norm(f x) = norm x" + "\x. x \ T \ norm(g x) = norm x" + "\x. x \ S \ g(f x) = x" + "\x. x \ T \ f(g x) = x" +proof - + obtain B where "B \ S" and Borth: "pairwise orthogonal B" + and B1: "\x. x \ B \ norm x = 1" + and "independent B" "finite B" "card B = dim S" "span B = S" + by (metis orthonormal_basis_subspace [OF S] independent_finite) + obtain C where "C \ T" and Corth: "pairwise orthogonal C" + and C1:"\x. x \ C \ norm x = 1" + and "independent C" "finite C" "card C = dim T" "span C = T" + by (metis orthonormal_basis_subspace [OF T] independent_finite) + obtain fb where "bij_betw fb B C" + by (metis \finite B\ \finite C\ bij_betw_iff_card \card B = dim S\ \card C = dim T\ d) + then have pairwise_orth_fb: "pairwise (\v j. orthogonal (fb v) (fb j)) B" + using Corth + apply (auto simp: pairwise_def orthogonal_clauses bij_betw_def) + by (meson subsetD image_eqI inj_on_def) + obtain f where "linear f" and ffb: "\x. x \ B \ f x = fb x" + using linear_independent_extend \independent B\ by fastforce + define gb where "gb \ inv_into B fb" + then have pairwise_orth_gb: "pairwise (\v j. orthogonal (gb v) (gb j)) C" + using Borth + apply (auto simp: pairwise_def orthogonal_clauses bij_betw_def) + by (metis \bij_betw fb B C\ bij_betw_imp_surj_on bij_betw_inv_into_right inv_into_into) + obtain g where "linear g" and ggb: "\x. x \ C \ g x = gb x" + using linear_independent_extend \independent C\ by fastforce + have "f ` S \ T" + by (metis \bij_betw fb B C\ bij_betw_imp_surj_on eq_iff ffb \linear f\ \span B = S\ \span C = T\ image_cong span_linear_image) + have [simp]: "\x. x \ B \ norm (fb x) = norm x" + using B1 C1 \bij_betw fb B C\ bij_betw_imp_surj_on by fastforce + have f [simp]: "norm (f x) = norm x" "g (f x) = x" if "x \ S" for x + proof - + obtain a where x: "x = (\v \ B. a v *\<^sub>R v)" + using \finite B\ \span B = S\ \x \ S\ span_finite by fastforce + have "f x = (\v \ B. f (a v *\<^sub>R v))" + using linear_setsum [OF \linear f\] x by auto + also have "... = (\v \ B. a v *\<^sub>R f v)" + using \linear f\ by (simp add: linear_setsum linear.scaleR) + also have "... = (\v \ B. a v *\<^sub>R fb v)" + by (simp add: ffb cong: setsum.cong) + finally have *: "f x = (\v\B. a v *\<^sub>R fb v)" . + then have "(norm (f x))\<^sup>2 = (norm (\v\B. a v *\<^sub>R fb v))\<^sup>2" by simp + also have "... = (\v\B. norm ((a v *\<^sub>R fb v))^2)" + apply (rule norm_setsum_Pythagorean [OF \finite B\]) + apply (rule pairwise_ortho_scaleR [OF pairwise_orth_fb]) + done + also have "... = (norm x)\<^sup>2" + by (simp add: x pairwise_ortho_scaleR Borth norm_setsum_Pythagorean [OF \finite B\]) + finally show "norm (f x) = norm x" + by (simp add: norm_eq_sqrt_inner) + have "g (f x) = g (\v\B. a v *\<^sub>R fb v)" by (simp add: *) + also have "... = (\v\B. g (a v *\<^sub>R fb v))" + using \linear g\ by (simp add: linear_setsum linear.scaleR) + also have "... = (\v\B. a v *\<^sub>R g (fb v))" + by (simp add: \linear g\ linear.scaleR) + also have "... = (\v\B. a v *\<^sub>R v)" + apply (rule setsum.cong [OF refl]) + using \bij_betw fb B C\ gb_def bij_betwE bij_betw_inv_into_left gb_def ggb by fastforce + also have "... = x" + using x by blast + finally show "g (f x) = x" . + qed + have [simp]: "\x. x \ C \ norm (gb x) = norm x" + by (metis B1 C1 \bij_betw fb B C\ bij_betw_imp_surj_on gb_def inv_into_into) + have g [simp]: "f (g x) = x" if "x \ T" for x + proof - + obtain a where x: "x = (\v \ C. a v *\<^sub>R v)" + using \finite C\ \span C = T\ \x \ T\ span_finite by fastforce + have "g x = (\v \ C. g (a v *\<^sub>R v))" + using linear_setsum [OF \linear g\] x by auto + also have "... = (\v \ C. a v *\<^sub>R g v)" + using \linear g\ by (simp add: linear_setsum linear.scaleR) + also have "... = (\v \ C. a v *\<^sub>R gb v)" + by (simp add: ggb cong: setsum.cong) + finally have "f (g x) = f (\v\C. a v *\<^sub>R gb v)" by simp + also have "... = (\v\C. f (a v *\<^sub>R gb v))" + using \linear f\ by (simp add: linear_setsum linear.scaleR) + also have "... = (\v\C. a v *\<^sub>R f (gb v))" + by (simp add: \linear f\ linear.scaleR) + also have "... = (\v\C. a v *\<^sub>R v)" + using \bij_betw fb B C\ + by (simp add: bij_betw_def gb_def bij_betw_inv_into_right ffb inv_into_into) + also have "... = x" + using x by blast + finally show "f (g x) = x" . + qed + have gim: "g ` T = S" + by (metis (no_types, lifting) \f ` S \ T\ \linear g\ \span B = S\ \span C = T\ d dim_eq_span dim_image_le f(2) image_subset_iff span_linear_image span_span subsetI) + have fim: "f ` S = T" + using \g ` T = S\ image_iff by fastforce + have [simp]: "norm (g x) = norm x" if "x \ T" for x + using fim that by auto + show ?thesis + apply (rule that [OF \linear f\ \linear g\]) + apply (simp_all add: fim gim) + done +qed + +(*REPLACE*) +lemma isometry_subspaces: + fixes S :: "'a::euclidean_space set" + and T :: "'b::euclidean_space set" + assumes S: "subspace S" + and T: "subspace T" + and d: "dim S = dim T" + obtains f where "linear f" "f ` S = T" "\x. x \ S \ norm(f x) = norm x" +using isometries_subspaces [OF assms] +by metis + +lemma homeomorphic_subspaces: + fixes S :: "'a::euclidean_space set" + and T :: "'b::euclidean_space set" + assumes S: "subspace S" + and T: "subspace T" + and d: "dim S = dim T" + shows "S homeomorphic T" +proof - + obtain f g where "linear f" "linear g" "f ` S = T" "g ` T = S" + "\x. x \ S \ g(f x) = x" "\x. x \ T \ f(g x) = x" + by (blast intro: isometries_subspaces [OF assms]) + then show ?thesis + apply (simp add: homeomorphic_def homeomorphism_def) + apply (rule_tac x=f in exI) + apply (rule_tac x=g in exI) + apply (auto simp: linear_continuous_on linear_conv_bounded_linear) + done +qed + +lemma homeomorphic_affine_sets: + assumes "affine S" "affine T" "aff_dim S = aff_dim T" + shows "S homeomorphic T" +proof (cases "S = {} \ T = {}") + case True with assms aff_dim_empty homeomorphic_empty show ?thesis + by metis +next + case False + then obtain a b where ab: "a \ S" "b \ T" by auto + then have ss: "subspace (op + (- a) ` S)" "subspace (op + (- b) ` T)" + using affine_diffs_subspace assms by blast+ + have dd: "dim (op + (- a) ` S) = dim (op + (- b) ` T)" + using assms ab by (simp add: aff_dim_eq_dim [OF hull_inc] image_def) + have "S homeomorphic (op + (- a) ` S)" + by (simp add: homeomorphic_translation) + also have "... homeomorphic (op + (- b) ` T)" + by (rule homeomorphic_subspaces [OF ss dd]) + also have "... homeomorphic T" + using homeomorphic_sym homeomorphic_translation by auto + finally show ?thesis . +qed + subsection\Retracts, in a general sense, preserve (co)homotopic triviality)\ locale Retracts = diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Mon May 23 15:33:24 2016 +0100 @@ -861,6 +861,11 @@ shows "x \ cball 0 e \ norm x \ e" by (simp add: dist_norm) +lemma mem_sphere_0 [simp]: + fixes x :: "'a::real_normed_vector" + shows "x \ sphere 0 e \ norm x = e" + by (simp add: dist_norm) + lemma centre_in_ball [simp]: "x \ ball x e \ 0 < e" by simp @@ -986,6 +991,22 @@ abbreviation One :: "'a::euclidean_space" where "One \ \Basis" +lemma One_non_0: assumes "One = (0::'a::euclidean_space)" shows False +proof - + have "dependent (Basis :: 'a set)" + apply (simp add: dependent_finite) + apply (rule_tac x="\i. 1" in exI) + using SOME_Basis apply (auto simp: assms) + done + with independent_Basis show False by force +qed + +corollary One_neq_0[iff]: "One \ 0" + by (metis One_non_0) + +corollary Zero_neq_One[iff]: "0 \ One" + by (metis One_non_0) + definition (in euclidean_space) eucl_less (infix " (\i\Basis. a \ i < b \ i)" @@ -5788,7 +5809,7 @@ unfolding continuous_on_closed_invariant closedin_closed Int_def vimage_def Int_commute by (simp add: imp_ex imageI conj_commute eq_commute cong: conj_cong) -text \Half-global and completely global cases.\ +subsection \Half-global and completely global cases.\ lemma continuous_openin_preimage: assumes "continuous_on s f" "open t" @@ -5874,7 +5895,7 @@ with \x = f y\ show "x \ f ` interior s" .. qed -text \Equality of continuous functions on closure and related results.\ +subsection \Equality of continuous functions on closure and related results.\ lemma continuous_closedin_preimage_constant: fixes f :: "_ \ 'b::t1_space" @@ -7238,6 +7259,11 @@ shows "(\x. a + x) ` (s - t) = ((\x. a + x) ` s) - ((\x. a + x) ` t)" by auto +lemma translation_Int: + fixes a :: "'a::ab_group_add" + shows "(\x. a + x) ` (s \ t) = ((\x. a + x) ` s) \ ((\x. a + x) ` t)" + by auto + lemma closure_translation: fixes a :: "'a::real_normed_vector" shows "closure ((\x. a + x) ` s) = (\x. a + x) ` (closure s)" @@ -7261,6 +7287,30 @@ unfolding frontier_def translation_diff interior_translation closure_translation by auto +lemma sphere_translation: + fixes a :: "'n::euclidean_space" + shows "sphere (a+c) r = op+a ` sphere c r" +apply safe +apply (rule_tac x="x-a" in image_eqI) +apply (auto simp: dist_norm algebra_simps) +done + +lemma cball_translation: + fixes a :: "'n::euclidean_space" + shows "cball (a+c) r = op+a ` cball c r" +apply safe +apply (rule_tac x="x-a" in image_eqI) +apply (auto simp: dist_norm algebra_simps) +done + +lemma ball_translation: + fixes a :: "'n::euclidean_space" + shows "ball (a+c) r = op+a ` ball c r" +apply safe +apply (rule_tac x="x-a" in image_eqI) +apply (auto simp: dist_norm algebra_simps) +done + subsection \Separation between points and sets\ @@ -8211,6 +8261,37 @@ apply auto done +lemma homeomorphicI [intro?]: + "\f ` S = T; g ` T = S; + continuous_on S f; continuous_on T g; + \x. x \ S \ g(f(x)) = x; + \y. y \ T \ f(g(y)) = y\ \ S homeomorphic T" +unfolding homeomorphic_def homeomorphism_def by metis + +lemma homeomorphism_of_subsets: + "\homeomorphism S T f g; S' \ S; T'' \ T; f ` S' = T'\ + \ homeomorphism S' T' f g" +apply (auto simp: homeomorphism_def elim!: continuous_on_subset) +by (metis contra_subsetD imageI) + +lemma homeomorphism_apply1: "\homeomorphism S T f g; x \ S\ \ g(f x) = x" + by (simp add: homeomorphism_def) + +lemma homeomorphism_apply2: "\homeomorphism S T f g; x \ T\ \ f(g x) = x" + by (simp add: homeomorphism_def) + +lemma homeomorphism_image1: "homeomorphism S T f g \ f ` S = T" + by (simp add: homeomorphism_def) + +lemma homeomorphism_image2: "homeomorphism S T f g \ g ` T = S" + by (simp add: homeomorphism_def) + +lemma homeomorphism_cont1: "homeomorphism S T f g \ continuous_on S f" + by (simp add: homeomorphism_def) + +lemma homeomorphism_cont2: "homeomorphism S T f g \ continuous_on T g" + by (simp add: homeomorphism_def) + text \Relatively weak hypotheses if a set is compact.\ lemma homeomorphism_compact: @@ -8332,7 +8413,109 @@ done qed -text\"Isometry" (up to constant bounds) of injective linear map etc.\ +subsection\Inverse function property for open/closed maps\ + +lemma continuous_on_inverse_open_map: + assumes contf: "continuous_on S f" + and imf: "f ` S = T" + and injf: "\x. x \ S \ g(f x) = x" + and oo: "\U. openin (subtopology euclidean S) U + \ openin (subtopology euclidean T) (f ` U)" + shows "continuous_on T g" +proof - + have gTS: "g ` T = S" + using imf injf by force + have fU: "U \ S \ (f ` U) = {x \ T. g x \ U}" for U + using imf injf by force + show ?thesis + apply (simp add: continuous_on_open [of T g] gTS) + apply (metis openin_imp_subset fU oo) + done +qed + +lemma continuous_on_inverse_closed_map: + assumes contf: "continuous_on S f" + and imf: "f ` S = T" + and injf: "\x. x \ S \ g(f x) = x" + and oo: "\U. closedin (subtopology euclidean S) U + \ closedin (subtopology euclidean T) (f ` U)" + shows "continuous_on T g" +proof - + have gTS: "g ` T = S" + using imf injf by force + have fU: "U \ S \ (f ` U) = {x \ T. g x \ U}" for U + using imf injf by force + show ?thesis + apply (simp add: continuous_on_closed [of T g] gTS) + apply (metis closedin_imp_subset fU oo) + done +qed + +lemma homeomorphism_injective_open_map: + assumes contf: "continuous_on S f" + and imf: "f ` S = T" + and injf: "inj_on f S" + and oo: "\U. openin (subtopology euclidean S) U + \ openin (subtopology euclidean T) (f ` U)" + obtains g where "homeomorphism S T f g" +proof - + have "continuous_on T (inv_into S f)" + by (metis contf continuous_on_inverse_open_map imf injf inv_into_f_f oo) + then show ?thesis + apply (rule_tac g = "inv_into S f" in that) + using imf injf contf apply (auto simp: homeomorphism_def) + done +qed + +lemma homeomorphism_injective_closed_map: + assumes contf: "continuous_on S f" + and imf: "f ` S = T" + and injf: "inj_on f S" + and oo: "\U. closedin (subtopology euclidean S) U + \ closedin (subtopology euclidean T) (f ` U)" + obtains g where "homeomorphism S T f g" +proof - + have "continuous_on T (inv_into S f)" + by (metis contf continuous_on_inverse_closed_map imf injf inv_into_f_f oo) + then show ?thesis + apply (rule_tac g = "inv_into S f" in that) + using imf injf contf apply (auto simp: homeomorphism_def) + done +qed + +lemma homeomorphism_imp_open_map: + assumes hom: "homeomorphism S T f g" + and oo: "openin (subtopology euclidean S) U" + shows "openin (subtopology euclidean T) (f ` U)" +proof - + have [simp]: "f ` U = {y. y \ T \ g y \ U}" + using assms openin_subset + by (fastforce simp: homeomorphism_def rev_image_eqI) + have "continuous_on T g" + using hom homeomorphism_def by blast + moreover have "g ` T = S" + by (metis hom homeomorphism_def) + ultimately show ?thesis + by (simp add: continuous_on_open oo) +qed + +lemma homeomorphism_imp_closed_map: + assumes hom: "homeomorphism S T f g" + and oo: "closedin (subtopology euclidean S) U" + shows "closedin (subtopology euclidean T) (f ` U)" +proof - + have [simp]: "f ` U = {y. y \ T \ g y \ U}" + using assms closedin_subset + by (fastforce simp: homeomorphism_def rev_image_eqI) + have "continuous_on T g" + using hom homeomorphism_def by blast + moreover have "g ` T = S" + by (metis hom homeomorphism_def) + ultimately show ?thesis + by (simp add: continuous_on_closed oo) +qed + +subsection\"Isometry" (up to constant bounds) of injective linear map etc.\ lemma cauchy_isometric: assumes e: "e > 0" @@ -8354,7 +8537,7 @@ fix n assume "n\N" have "e * norm (x n - x N) \ norm (f (x n - x N))" - using subspace_sub[OF s, of "x n" "x N"] + using subspace_diff[OF s, of "x n" "x N"] using xs[THEN spec[where x=N]] and xs[THEN spec[where x=n]] using normf[THEN bspec[where x="x n - x N"]] by auto diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Real_Vector_Spaces.thy --- a/src/HOL/Real_Vector_Spaces.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Real_Vector_Spaces.thy Mon May 23 15:33:24 2016 +0100 @@ -236,6 +236,18 @@ apply (simp_all add: algebra_simps) done +lemma vector_add_divide_simps : + fixes v :: "'a :: real_vector" + shows "v + (b / z) *\<^sub>R w = (if z = 0 then v else (z *\<^sub>R v + b *\<^sub>R w) /\<^sub>R z)" + "a *\<^sub>R v + (b / z) *\<^sub>R w = (if z = 0 then a *\<^sub>R v else ((a * z) *\<^sub>R v + b *\<^sub>R w) /\<^sub>R z)" + "(a / z) *\<^sub>R v + w = (if z = 0 then w else (a *\<^sub>R v + z *\<^sub>R w) /\<^sub>R z)" + "(a / z) *\<^sub>R v + b *\<^sub>R w = (if z = 0 then b *\<^sub>R w else (a *\<^sub>R v + (b * z) *\<^sub>R w) /\<^sub>R z)" + "v - (b / z) *\<^sub>R w = (if z = 0 then v else (z *\<^sub>R v - b *\<^sub>R w) /\<^sub>R z)" + "a *\<^sub>R v - (b / z) *\<^sub>R w = (if z = 0 then a *\<^sub>R v else ((a * z) *\<^sub>R v - b *\<^sub>R w) /\<^sub>R z)" + "(a / z) *\<^sub>R v - w = (if z = 0 then -w else (a *\<^sub>R v - z *\<^sub>R w) /\<^sub>R z)" + "(a / z) *\<^sub>R v - b *\<^sub>R w = (if z = 0 then -b *\<^sub>R w else (a *\<^sub>R v - (b * z) *\<^sub>R w) /\<^sub>R z)" +by (simp_all add: divide_inverse_commute scaleR_add_right real_vector.scale_right_diff_distrib) + lemma real_vector_affinity_eq: fixes x :: "'a :: real_vector" assumes m0: "m \ 0" @@ -769,6 +781,21 @@ by (rule norm_minus_cancel) thus ?thesis by simp qed + +lemma dist_add_cancel [simp]: + fixes a :: "'a::real_normed_vector" + shows "dist (a + b) (a + c) = dist b c" +by (simp add: dist_norm) + +lemma dist_add_cancel2 [simp]: + fixes a :: "'a::real_normed_vector" + shows "dist (b + a) (c + a) = dist b c" +by (simp add: dist_norm) + +lemma dist_scaleR [simp]: + fixes a :: "'a::real_normed_vector" + shows "dist (x *\<^sub>R a) (y *\<^sub>R a) = abs (x-y) * norm a" +by (metis dist_norm norm_scaleR scaleR_left.diff) lemma norm_uminus_minus: "norm (-x - y :: 'a :: real_normed_vector) = norm (x + y)" by (subst (2) norm_minus_cancel[symmetric], subst minus_add_distrib) simp diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Set.thy --- a/src/HOL/Set.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Set.thy Mon May 23 15:33:24 2016 +0100 @@ -1934,6 +1934,14 @@ lemma pairwise_singleton [simp]: "pairwise P {A}" by (simp add: pairwise_def) +lemma pairwise_insert: + "pairwise r (insert x s) \ (\y. y \ s \ y \ x \ r x y \ r y x) \ pairwise r s" +by (force simp: pairwise_def) + +lemma pairwise_image: + "pairwise r (f ` s) \ pairwise (\x y. (f x \ f y) \ r (f x) (f y)) s" +by (force simp: pairwise_def) + lemma Int_emptyI: "(\x. x \ A \ x \ B \ False) \ A \ B = {}" by blast diff -r 932cf444f2fe -r 27afe7af7379 src/HOL/Set_Interval.thy --- a/src/HOL/Set_Interval.thy Sat May 21 07:08:59 2016 +0200 +++ b/src/HOL/Set_Interval.thy Mon May 23 15:33:24 2016 +0100 @@ -1168,19 +1168,18 @@ by (rule finite_same_card_bij) auto lemma bij_betw_iff_card: - assumes FIN: "finite A" and FIN': "finite B" - shows BIJ: "(\f. bij_betw f A B) \ (card A = card B)" -using assms -proof(auto simp add: bij_betw_same_card) - assume *: "card A = card B" - obtain f where "bij_betw f A {0 ..< card A}" - using FIN ex_bij_betw_finite_nat by blast + assumes "finite A" "finite B" + shows "(\f. bij_betw f A B) \ (card A = card B)" +proof + assume "card A = card B" + moreover obtain f where "bij_betw f A {0 ..< card A}" + using assms ex_bij_betw_finite_nat by blast moreover obtain g where "bij_betw g {0 ..< card B} B" - using FIN' ex_bij_betw_nat_finite by blast + using assms ex_bij_betw_nat_finite by blast ultimately have "bij_betw (g o f) A B" - using * by (auto simp add: bij_betw_trans) + by (auto simp: bij_betw_trans) thus "(\f. bij_betw f A B)" by blast -qed +qed (auto simp: bij_betw_same_card) lemma inj_on_iff_card_le: assumes FIN: "finite A" and FIN': "finite B"