diff -r c61c957b0439 -r ff2e0115fea4 src/HOL/Analysis/Starlike.thy --- a/src/HOL/Analysis/Starlike.thy Fri Sep 08 11:09:56 2017 +0200 +++ b/src/HOL/Analysis/Starlike.thy Fri Sep 08 12:49:40 2017 +0100 @@ -7041,6 +7041,70 @@ by (rule that [OF 1 2 3 4 5 6]) qed + +proposition orthogonal_to_subspace_exists_gen: + fixes S :: "'a :: euclidean_space set" + assumes "span S \ span T" + obtains x where "x \ 0" "x \ span T" "\y. y \ span S \ orthogonal x y" +proof - + obtain B where "B \ span S" and orthB: "pairwise orthogonal B" + and "\x. x \ B \ norm x = 1" + and "independent B" "card B = dim S" "span B = span S" + by (rule orthonormal_basis_subspace [of "span S"]) auto + with assms obtain u where spanBT: "span B \ span T" and "u \ span B" "u \ span T" + by auto + obtain C where orthBC: "pairwise orthogonal (B \ C)" and spanBC: "span (B \ C) = span (B \ {u})" + by (blast intro: orthogonal_extension [OF orthB]) + show thesis + proof (cases "C \ insert 0 B") + case True + then have "C \ span B" + using Linear_Algebra.span_eq + by (metis span_insert_0 subset_trans) + moreover have "u \ span (B \ C)" + using \span (B \ C) = span (B \ {u})\ span_inc by force + ultimately show ?thesis + by (metis \u \ span B\ span_Un span_span sup.orderE) + next + case False + then obtain x where "x \ C" "x \ 0" "x \ B" + by blast + then have "x \ span T" + by (metis (no_types, lifting) Un_insert_right Un_upper2 \u \ span T\ spanBT spanBC \u \ span T\ insert_subset span_inc span_mono span_span subsetCE subset_trans sup_bot.comm_neutral) + moreover have "orthogonal x y" if "y \ span B" for y + using that + proof (rule span_induct) + show "subspace {a. orthogonal x a}" + by (simp add: subspace_orthogonal_to_vector) + show "\b. b \ B \ orthogonal x b" + by (metis Un_iff \x \ C\ \x \ B\ orthBC pairwise_def) + qed + ultimately show ?thesis + using \x \ 0\ that \span B = span S\ by auto + qed +qed + +corollary orthogonal_to_subspace_exists: + fixes S :: "'a :: euclidean_space set" + assumes "dim S < DIM('a)" + obtains x where "x \ 0" "\y. y \ span S \ orthogonal x y" +proof - +have "span S \ UNIV" + by (metis assms dim_eq_full less_irrefl top.not_eq_extremum) + with orthogonal_to_subspace_exists_gen [of S UNIV] that show ?thesis by auto +qed + +corollary orthogonal_to_vector_exists: + fixes x :: "'a :: euclidean_space" + assumes "2 \ DIM('a)" + obtains y where "y \ 0" "orthogonal x y" +proof - + have "dim {x} < DIM('a)" + using assms by auto + then show thesis + by (rule orthogonal_to_subspace_exists) (simp add: orthogonal_commute span_clauses(1) that) +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" @@ -7202,6 +7266,119 @@ finally show "dim T \ dim S" by simp qed +subsection\Lower-dimensional affine subsets are nowhere dense.\ + +proposition dense_complement_subspace: + fixes S :: "'a :: euclidean_space set" + assumes dim_less: "dim T < dim S" and "subspace S" shows "closure(S - T) = S" +proof - + have "closure(S - U) = S" if "dim U < dim S" "U \ S" for U + proof - + have "span U \ span S" + by (metis neq_iff psubsetI span_eq_dim span_mono that) + then obtain a where "a \ 0" "a \ span S" and a: "\y. y \ span U \ orthogonal a y" + using orthogonal_to_subspace_exists_gen by metis + show ?thesis + proof + have "closed S" + by (simp add: \subspace S\ closed_subspace) + then show "closure (S - U) \ S" + by (simp add: Diff_subset closure_minimal) + show "S \ closure (S - U)" + proof (clarsimp simp: closure_approachable) + fix x and e::real + assume "x \ S" "0 < e" + show "\y\S - U. dist y x < e" + proof (cases "x \ U") + case True + let ?y = "x + (e/2 / norm a) *\<^sub>R a" + show ?thesis + proof + show "dist ?y x < e" + using \0 < e\ by (simp add: dist_norm) + next + have "?y \ S" + by (metis span_eq \a \ span S\ \x \ S\ \subspace S\ subspace_add subspace_mul) + moreover have "?y \ U" + proof - + have "e/2 / norm a \ 0" + using \0 < e\ \a \ 0\ by auto + then show ?thesis + by (metis True \a \ 0\ a orthogonal_scaleR orthogonal_self real_vector.scale_eq_0_iff span_add_eq span_clauses(1)) + qed + ultimately show "?y \ S - U" by blast + qed + next + case False + with \0 < e\ \x \ S\ show ?thesis by force + qed + qed + qed + qed + moreover have "S - S \ T = S-T" + by blast + moreover have "dim (S \ T) < dim S" + by (metis dim_less dim_subset inf.cobounded2 inf.orderE inf.strict_boundedE not_le) + ultimately show ?thesis + by force +qed + +corollary dense_complement_affine: + fixes S :: "'a :: euclidean_space set" + assumes less: "aff_dim T < aff_dim S" and "affine S" shows "closure(S - T) = S" +proof (cases "S \ T = {}") + case True + then show ?thesis + by (metis Diff_triv affine_hull_eq \affine S\ closure_same_affine_hull closure_subset hull_subset subset_antisym) +next + case False + then obtain z where z: "z \ S \ T" by blast + then have "subspace (op + (- z) ` S)" + by (meson IntD1 affine_diffs_subspace \affine S\) + moreover have "int (dim (op + (- z) ` T)) < int (dim (op + (- z) ` S))" + using z less by (simp add: aff_dim_eq_dim [symmetric] hull_inc) + ultimately have "closure((op + (- z) ` S) - (op + (- z) ` T)) = (op + (- z) ` S)" + by (simp add: dense_complement_subspace) + then show ?thesis + by (metis closure_translation translation_diff translation_invert) +qed + +corollary dense_complement_openin_affine_hull: + fixes S :: "'a :: euclidean_space set" + assumes less: "aff_dim T < aff_dim S" + and ope: "openin (subtopology euclidean (affine hull S)) S" + shows "closure(S - T) = closure S" +proof - + have "affine hull S - T \ affine hull S" + by blast + then have "closure (S \ closure (affine hull S - T)) = closure (S \ (affine hull S - T))" + by (rule closure_openin_Int_closure [OF ope]) + then show ?thesis + by (metis Int_Diff aff_dim_affine_hull affine_affine_hull dense_complement_affine hull_subset inf.orderE less) +qed + +corollary dense_complement_convex: + fixes S :: "'a :: euclidean_space set" + assumes "aff_dim T < aff_dim S" "convex S" + shows "closure(S - T) = closure S" +proof + show "closure (S - T) \ closure S" + by (simp add: Diff_subset closure_mono) + have "closure (rel_interior S - T) = closure (rel_interior S)" + apply (rule dense_complement_openin_affine_hull) + apply (simp add: assms rel_interior_aff_dim) + using \convex S\ rel_interior_rel_open rel_open by blast + then show "closure S \ closure (S - T)" + by (metis Diff_mono \convex S\ closure_mono convex_closure_rel_interior order_refl rel_interior_subset) +qed + +corollary dense_complement_convex_closed: + fixes S :: "'a :: euclidean_space set" + assumes "aff_dim T < aff_dim S" "convex S" "closed S" + shows "closure(S - T) = S" + by (simp add: assms dense_complement_convex) + + subsection\Parallel slices, etc.\ text\ If we take a slice out of a set, we can do it perpendicularly,