226 lemma subspace_sub: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x - y \<in> S" |
226 lemma subspace_sub: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S \<Longrightarrow> x - y \<in> S" |
227 using subspace_add [of S x "- y"] by (simp add: subspace_neg) |
227 using subspace_add [of S x "- y"] by (simp add: subspace_neg) |
228 |
228 |
229 lemma (in real_vector) subspace_setsum: |
229 lemma (in real_vector) subspace_setsum: |
230 assumes sA: "subspace A" |
230 assumes sA: "subspace A" |
231 and f: "\<forall>x\<in>B. f x \<in> A" |
231 and f: "\<And>x. x \<in> B \<Longrightarrow> f x \<in> A" |
232 shows "setsum f B \<in> A" |
232 shows "setsum f B \<in> A" |
233 proof (cases "finite B") |
233 proof (cases "finite B") |
234 case True |
234 case True |
235 then show ?thesis |
235 then show ?thesis |
236 using f by induct (simp_all add: subspace_0 [OF sA] subspace_add [OF sA]) |
236 using f by induct (simp_all add: subspace_0 [OF sA] subspace_add [OF sA]) |
237 qed (simp add: subspace_0 [OF sA]) |
237 qed (simp add: subspace_0 [OF sA]) |
238 |
238 |
239 lemma subspace_trivial: "subspace {0}" |
239 lemma subspace_trivial [iff]: "subspace {0}" |
240 by (simp add: subspace_def) |
240 by (simp add: subspace_def) |
241 |
241 |
242 lemma (in real_vector) subspace_inter: "subspace A \<Longrightarrow> subspace B \<Longrightarrow> subspace (A \<inter> B)" |
242 lemma (in real_vector) subspace_inter: "subspace A \<Longrightarrow> subspace B \<Longrightarrow> subspace (A \<inter> B)" |
243 by (simp add: subspace_def) |
243 by (simp add: subspace_def) |
244 |
244 |
245 lemma subspace_Times: "subspace A \<Longrightarrow> subspace B \<Longrightarrow> subspace (A \<times> B)" |
245 lemma subspace_Times: "subspace A \<Longrightarrow> subspace B \<Longrightarrow> subspace (A \<times> B)" |
246 unfolding subspace_def zero_prod_def by simp |
246 unfolding subspace_def zero_prod_def by simp |
247 |
247 |
248 text \<open>Properties of span.\<close> |
248 lemma subspace_sums: "\<lbrakk>subspace S; subspace T\<rbrakk> \<Longrightarrow> subspace {x + y|x y. x \<in> S \<and> y \<in> T}" |
|
249 apply (simp add: subspace_def) |
|
250 apply (intro conjI impI allI) |
|
251 using add.right_neutral apply blast |
|
252 apply clarify |
|
253 apply (metis add.assoc add.left_commute) |
|
254 using scaleR_add_right by blast |
|
255 |
|
256 subsection \<open>Properties of span\<close> |
249 |
257 |
250 lemma (in real_vector) span_mono: "A \<subseteq> B \<Longrightarrow> span A \<subseteq> span B" |
258 lemma (in real_vector) span_mono: "A \<subseteq> B \<Longrightarrow> span A \<subseteq> span B" |
251 by (metis span_def hull_mono) |
259 by (metis span_def hull_mono) |
252 |
260 |
253 lemma (in real_vector) subspace_span: "subspace (span S)" |
261 lemma (in real_vector) subspace_span: "subspace (span S)" |
397 unfolding span_def hull_hull .. |
405 unfolding span_def hull_hull .. |
398 |
406 |
399 lemma (in real_vector) span_superset: "x \<in> S \<Longrightarrow> x \<in> span S" |
407 lemma (in real_vector) span_superset: "x \<in> S \<Longrightarrow> x \<in> span S" |
400 by (metis span_clauses(1)) |
408 by (metis span_clauses(1)) |
401 |
409 |
402 lemma (in real_vector) span_0: "0 \<in> span S" |
410 lemma (in real_vector) span_0 [simp]: "0 \<in> span S" |
403 by (metis subspace_span subspace_0) |
411 by (metis subspace_span subspace_0) |
404 |
412 |
405 lemma span_inc: "S \<subseteq> span S" |
413 lemma span_inc: "S \<subseteq> span S" |
406 by (metis subset_eq span_superset) |
414 by (metis subset_eq span_superset) |
407 |
415 |
412 lemma (in real_vector) dependent_0: |
420 lemma (in real_vector) dependent_0: |
413 assumes "0 \<in> A" |
421 assumes "0 \<in> A" |
414 shows "dependent A" |
422 shows "dependent A" |
415 unfolding dependent_def |
423 unfolding dependent_def |
416 using assms span_0 |
424 using assms span_0 |
417 by auto |
425 by blast |
418 |
426 |
419 lemma (in real_vector) span_add: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x + y \<in> span S" |
427 lemma (in real_vector) span_add: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x + y \<in> span S" |
420 by (metis subspace_add subspace_span) |
428 by (metis subspace_add subspace_span) |
421 |
429 |
422 lemma (in real_vector) span_mul: "x \<in> span S \<Longrightarrow> c *\<^sub>R x \<in> span S" |
430 lemma (in real_vector) span_mul: "x \<in> span S \<Longrightarrow> c *\<^sub>R x \<in> span S" |
426 by (metis subspace_neg subspace_span) |
434 by (metis subspace_neg subspace_span) |
427 |
435 |
428 lemma span_sub: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x - y \<in> span S" |
436 lemma span_sub: "x \<in> span S \<Longrightarrow> y \<in> span S \<Longrightarrow> x - y \<in> span S" |
429 by (metis subspace_span subspace_sub) |
437 by (metis subspace_span subspace_sub) |
430 |
438 |
431 lemma (in real_vector) span_setsum: "\<forall>x\<in>A. f x \<in> span S \<Longrightarrow> setsum f A \<in> span S" |
439 lemma (in real_vector) span_setsum: "(\<And>x. x \<in> A \<Longrightarrow> f x \<in> span S) \<Longrightarrow> setsum f A \<in> span S" |
432 by (rule subspace_setsum [OF subspace_span]) |
440 by (rule subspace_setsum [OF subspace_span]) |
433 |
441 |
434 lemma span_add_eq: "x \<in> span S \<Longrightarrow> x + y \<in> span S \<longleftrightarrow> y \<in> span S" |
442 lemma span_add_eq: "x \<in> span S \<Longrightarrow> x + y \<in> span S \<longleftrightarrow> y \<in> span S" |
435 by (metis add_minus_cancel scaleR_minus1_left subspace_def subspace_span) |
443 by (metis add_minus_cancel scaleR_minus1_left subspace_def subspace_span) |
436 |
444 |
693 apply (rule exI[where x= "?S"]) |
701 apply (rule exI[where x= "?S"]) |
694 apply (auto simp del: scaleR_minus_left) |
702 apply (auto simp del: scaleR_minus_left) |
695 done |
703 done |
696 } |
704 } |
697 ultimately show ?thesis by blast |
705 ultimately show ?thesis by blast |
|
706 qed |
|
707 |
|
708 lemma dependent_finite: |
|
709 assumes "finite S" |
|
710 shows "dependent S \<longleftrightarrow> (\<exists>u. (\<exists>v \<in> S. u v \<noteq> 0) \<and> (\<Sum>v\<in>S. u v *\<^sub>R v) = 0)" |
|
711 (is "?lhs = ?rhs") |
|
712 proof |
|
713 assume ?lhs |
|
714 then obtain T u v |
|
715 where "finite T" "T \<subseteq> S" "v\<in>T" "u v \<noteq> 0" "(\<Sum>v\<in>T. u v *\<^sub>R v) = 0" |
|
716 by (force simp: dependent_explicit) |
|
717 with assms show ?rhs |
|
718 apply (rule_tac x="\<lambda>v. if v \<in> T then u v else 0" in exI) |
|
719 apply (auto simp: setsum.mono_neutral_right) |
|
720 done |
|
721 next |
|
722 assume ?rhs with assms show ?lhs |
|
723 by (fastforce simp add: dependent_explicit) |
698 qed |
724 qed |
699 |
725 |
700 lemma span_alt: |
726 lemma span_alt: |
701 "span B = {(\<Sum>x | f x \<noteq> 0. f x *\<^sub>R x) | f. {x. f x \<noteq> 0} \<subseteq> B \<and> finite {x. f x \<noteq> 0}}" |
727 "span B = {(\<Sum>x | f x \<noteq> 0. f x *\<^sub>R x) | f. {x. f x \<noteq> 0} \<subseteq> B \<and> finite {x. f x \<noteq> 0}}" |
702 unfolding span_explicit |
728 unfolding span_explicit |
2005 fixes S :: "'a::euclidean_space set" |
2031 fixes S :: "'a::euclidean_space set" |
2006 assumes "independent S" |
2032 assumes "independent S" |
2007 shows independent_imp_finite: "finite S" and independent_card_le:"card S \<le> DIM('a)" |
2033 shows independent_imp_finite: "finite S" and independent_card_le:"card S \<le> DIM('a)" |
2008 using assms independent_bound by auto |
2034 using assms independent_bound by auto |
2009 |
2035 |
|
2036 lemma independent_explicit: |
|
2037 fixes B :: "'a::euclidean_space set" |
|
2038 shows "independent B \<longleftrightarrow> |
|
2039 finite B \<and> (\<forall>c. (\<Sum>v\<in>B. c v *\<^sub>R v) = 0 \<longrightarrow> (\<forall>v \<in> B. c v = 0))" |
|
2040 apply (cases "finite B") |
|
2041 apply (force simp: dependent_finite) |
|
2042 using independent_bound |
|
2043 apply auto |
|
2044 done |
|
2045 |
2010 lemma dependent_biggerset: |
2046 lemma dependent_biggerset: |
2011 fixes S :: "'a::euclidean_space set" |
2047 fixes S :: "'a::euclidean_space set" |
2012 shows "(finite S \<Longrightarrow> card S > DIM('a)) \<Longrightarrow> dependent S" |
2048 shows "(finite S \<Longrightarrow> card S > DIM('a)) \<Longrightarrow> dependent S" |
2013 by (metis independent_bound not_less) |
2049 by (metis independent_bound not_less) |
2014 |
2050 |
2249 have "x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C \<longleftrightarrow> x - k *\<^sub>R a \<in> span C" |
2285 have "x - k *\<^sub>R (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *\<^sub>R x)) \<in> span C \<longleftrightarrow> x - k *\<^sub>R a \<in> span C" |
2250 apply (simp only: scaleR_right_diff_distrib th0) |
2286 apply (simp only: scaleR_right_diff_distrib th0) |
2251 apply (rule span_add_eq) |
2287 apply (rule span_add_eq) |
2252 apply (rule span_mul) |
2288 apply (rule span_mul) |
2253 apply (rule span_setsum) |
2289 apply (rule span_setsum) |
2254 apply clarify |
|
2255 apply (rule span_mul) |
2290 apply (rule span_mul) |
2256 apply (rule span_superset) |
2291 apply (rule span_superset) |
2257 apply assumption |
2292 apply assumption |
2258 done |
2293 done |
2259 } |
2294 } |
2332 by (simp add: span_span) |
2367 by (simp add: span_span) |
2333 let ?a = "a - setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B" |
2368 let ?a = "a - setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B" |
2334 have "setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B \<in> span S" |
2369 have "setsum (\<lambda>b. (a \<bullet> b / (b \<bullet> b)) *\<^sub>R b) B \<in> span S" |
2335 unfolding sSB |
2370 unfolding sSB |
2336 apply (rule span_setsum) |
2371 apply (rule span_setsum) |
2337 apply clarsimp |
|
2338 apply (rule span_mul) |
2372 apply (rule span_mul) |
2339 apply (rule span_superset) |
2373 apply (rule span_superset) |
2340 apply assumption |
2374 apply assumption |
2341 done |
2375 done |
2342 with a have a0:"?a \<noteq> 0" |
2376 with a have a0:"?a \<noteq> 0" |
3093 ultimately show ?thesis by blast |
3127 ultimately show ?thesis by blast |
3094 qed |
3128 qed |
3095 |
3129 |
3096 lemma norm_cauchy_schwarz_equal: "\<bar>x \<bullet> y\<bar> = norm x * norm y \<longleftrightarrow> collinear {0, x, y}" |
3130 lemma norm_cauchy_schwarz_equal: "\<bar>x \<bullet> y\<bar> = norm x * norm y \<longleftrightarrow> collinear {0, x, y}" |
3097 unfolding norm_cauchy_schwarz_abs_eq |
3131 unfolding norm_cauchy_schwarz_abs_eq |
3098 apply (cases "x=0", simp_all add: collinear_2) |
3132 apply (cases "x=0", simp_all) |
3099 apply (cases "y=0", simp_all add: collinear_2 insert_commute) |
3133 apply (cases "y=0", simp_all add: insert_commute) |
3100 unfolding collinear_lemma |
3134 unfolding collinear_lemma |
3101 apply simp |
3135 apply simp |
3102 apply (subgoal_tac "norm x \<noteq> 0") |
3136 apply (subgoal_tac "norm x \<noteq> 0") |
3103 apply (subgoal_tac "norm y \<noteq> 0") |
3137 apply (subgoal_tac "norm y \<noteq> 0") |
3104 apply (rule iffI) |
3138 apply (rule iffI) |