# HG changeset patch # User hoelzl # Date 1461319023 -7200 # Node ID e5e69206d52d17da49e736500b47e2fce56f7732 # Parent ca4cce24c75d408f7c2c9bbff33138ed260ffff1 Linear_Algebra: alternative representation of linear combination diff -r ca4cce24c75d -r e5e69206d52d src/HOL/Multivariate_Analysis/Linear_Algebra.thy --- a/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Apr 22 11:43:47 2016 +0200 +++ b/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Fri Apr 22 11:57:03 2016 +0200 @@ -681,31 +681,65 @@ ultimately show ?thesis by blast qed -lemma span_finite: - assumes fS: "finite S" - shows "span S = {y. \u. setsum (\v. u v *\<^sub>R v) S = y}" - (is "_ = ?rhs") +lemma span_alt: + "span B = {(\x | f x \ 0. f x *\<^sub>R x) | f. {x. f x \ 0} \ B \ finite {x. f x \ 0}}" + unfolding span_explicit + apply safe + subgoal for x S u + by (intro exI[of _ "\x. if x \ S then u x else 0"]) + (auto intro!: setsum.mono_neutral_cong_right) + apply auto + done + +lemma dependent_alt: + "dependent B \ + (\X. finite {x. X x \ 0} \ {x. X x \ 0} \ B \ (\x|X x \ 0. X x *\<^sub>R x) = 0 \ (\x. X x \ 0))" + unfolding dependent_explicit + apply safe + subgoal for S u v + apply (intro exI[of _ "\x. if x \ S then u x else 0"]) + apply (subst setsum.mono_neutral_cong_left[where T=S]) + apply (auto intro!: setsum.mono_neutral_cong_right cong: rev_conj_cong) + done + apply auto + done + +lemma independent_alt: + "independent B \ + (\X. finite {x. X x \ 0} \ {x. X x \ 0} \ B \ (\x|X x \ 0. X x *\<^sub>R x) = 0 \ (\x. X x = 0))" + unfolding dependent_alt by auto + +lemma independentD_alt: + "independent B \ finite {x. X x \ 0} \ {x. X x \ 0} \ B \ (\x|X x \ 0. X x *\<^sub>R x) = 0 \ X x = 0" + unfolding independent_alt by blast + +lemma independentD_unique: + assumes B: "independent B" + and X: "finite {x. X x \ 0}" "{x. X x \ 0} \ B" + and Y: "finite {x. Y x \ 0}" "{x. Y x \ 0} \ B" + and "(\x | X x \ 0. X x *\<^sub>R x) = (\x| Y x \ 0. Y x *\<^sub>R x)" + shows "X = Y" proof - - { - fix y - assume y: "y \ span S" - from y obtain S' u where fS': "finite S'" - and SS': "S' \ S" - and u: "setsum (\v. u v *\<^sub>R v) S' = y" - unfolding span_explicit by blast - let ?u = "\x. if x \ S' then u x else 0" - have "setsum (\v. ?u v *\<^sub>R v) S = setsum (\v. u v *\<^sub>R v) S'" - using SS' fS by (auto intro!: setsum.mono_neutral_cong_right) - then have "setsum (\v. ?u v *\<^sub>R v) S = y" by (metis u) - then have "y \ ?rhs" by auto - } - moreover - { - fix y u - assume u: "setsum (\v. u v *\<^sub>R v) S = y" - then have "y \ span S" using fS unfolding span_explicit by auto - } - ultimately show ?thesis by blast + have "X x - Y x = 0" for x + using B + proof (rule independentD_alt) + have "{x. X x - Y x \ 0} \ {x. X x \ 0} \ {x. Y x \ 0}" + by auto + then show "finite {x. X x - Y x \ 0}" "{x. X x - Y x \ 0} \ B" + using X Y by (auto dest: finite_subset) + then have "(\x | X x - Y x \ 0. (X x - Y x) *\<^sub>R x) = (\v\{S. X S \ 0} \ {S. Y S \ 0}. (X v - Y v) *\<^sub>R v)" + using X Y by (intro setsum.mono_neutral_cong_left) auto + also have "\ = (\v\{S. X S \ 0} \ {S. Y S \ 0}. X v *\<^sub>R v) - (\v\{S. X S \ 0} \ {S. Y S \ 0}. Y v *\<^sub>R v)" + by (simp add: scaleR_diff_left setsum_subtractf assms) + also have "(\v\{S. X S \ 0} \ {S. Y S \ 0}. X v *\<^sub>R v) = (\v\{S. X S \ 0}. X v *\<^sub>R v)" + using X Y by (intro setsum.mono_neutral_cong_right) auto + also have "(\v\{S. X S \ 0} \ {S. Y S \ 0}. Y v *\<^sub>R v) = (\v\{S. Y S \ 0}. Y v *\<^sub>R v)" + using X Y by (intro setsum.mono_neutral_cong_right) auto + finally show "(\x | X x - Y x \ 0. (X x - Y x) *\<^sub>R x) = 0" + using assms by simp + qed + then show ?thesis + by auto qed text \This is useful for building a basis step-by-step.\ @@ -741,6 +775,117 @@ qed qed +lemma independent_Union_directed: + assumes directed: "\c d. c \ C \ d \ C \ c \ d \ d \ c" + assumes indep: "\c. c \ C \ independent c" + shows "independent (\C)" +proof + assume "dependent (\C)" + then obtain u v S where S: "finite S" "S \ \C" "v \ S" "u v \ 0" "(\v\S. u v *\<^sub>R v) = 0" + by (auto simp: dependent_explicit) + + have "S \ {}" + using \v \ S\ by auto + have "\c\C. S \ c" + using \finite S\ \S \ {}\ \S \ \C\ + proof (induction rule: finite_ne_induct) + case (insert i I) + then obtain c d where cd: "c \ C" "d \ C" and iI: "I \ c" "i \ d" + by blast + from directed[OF cd] cd have "c \ d \ C" + by (auto simp: sup.absorb1 sup.absorb2) + with iI show ?case + by (intro bexI[of _ "c \ d"]) auto + qed auto + then obtain c where "c \ C" "S \ c" + by auto + have "dependent c" + unfolding dependent_explicit + by (intro exI[of _ S] exI[of _ u] bexI[of _ v] conjI) fact+ + with indep[OF \c \ C\] show False + by auto +qed + +text \Hence we can create a maximal independent subset.\ + +lemma maximal_independent_subset_extend: + assumes "S \ V" "independent S" + shows "\B. S \ B \ B \ V \ independent B \ V \ span B" +proof - + let ?C = "{B. S \ B \ independent B \ B \ V}" + have "\M\?C. \X\?C. M \ X \ X = M" + proof (rule subset_Zorn) + fix C :: "'a set set" assume "subset.chain ?C C" + then have C: "\c. c \ C \ c \ V" "\c. c \ C \ S \ c" "\c. c \ C \ independent c" + "\c d. c \ C \ d \ C \ c \ d \ d \ c" + unfolding subset.chain_def by blast+ + + show "\U\?C. \X\C. X \ U" + proof cases + assume "C = {}" with assms show ?thesis + by (auto intro!: exI[of _ S]) + next + assume "C \ {}" + with C(2) have "S \ \C" + by auto + moreover have "independent (\C)" + by (intro independent_Union_directed C) + moreover have "\C \ V" + using C by auto + ultimately show ?thesis + by auto + qed + qed + then obtain B where B: "independent B" "B \ V" "S \ B" + and max: "\S. independent S \ S \ V \ B \ S \ S = B" + by auto + moreover + { assume "\ V \ span B" + then obtain v where "v \ V" "v \ span B" + by auto + with B have "independent (insert v B)" + unfolding independent_insert by auto + from max[OF this] \v \ V\ \B \ V\ + have "v \ B" + by auto + with \v \ span B\ have False + by (auto intro: span_superset) } + ultimately show ?thesis + by (auto intro!: exI[of _ B]) +qed + + +lemma maximal_independent_subset: + "\B. B \ V \ independent B \ V \ span B" + by (metis maximal_independent_subset_extend[of "{}"] empty_subsetI independent_empty) + +lemma span_finite: + assumes fS: "finite S" + shows "span S = {y. \u. setsum (\v. u v *\<^sub>R v) S = y}" + (is "_ = ?rhs") +proof - + { + fix y + assume y: "y \ span S" + from y obtain S' u where fS': "finite S'" + and SS': "S' \ S" + and u: "setsum (\v. u v *\<^sub>R v) S' = y" + unfolding span_explicit by blast + let ?u = "\x. if x \ S' then u x else 0" + have "setsum (\v. ?u v *\<^sub>R v) S = setsum (\v. u v *\<^sub>R v) S'" + using SS' fS by (auto intro!: setsum.mono_neutral_cong_right) + then have "setsum (\v. ?u v *\<^sub>R v) S = y" by (metis u) + then have "y \ ?rhs" by auto + } + moreover + { + fix y u + assume u: "setsum (\v. u v *\<^sub>R v) S = y" + then have "y \ span S" using fS unfolding span_explicit by auto + } + ultimately show ?thesis by blast +qed + text \The degenerate case of the Exchange Lemma.\ lemma spanning_subset_independent: @@ -1622,53 +1767,6 @@ shows "(finite S \ card S > DIM('a)) \ dependent S" by (metis independent_bound not_less) -text \Hence we can create a maximal independent subset.\ - -lemma maximal_independent_subset_extend: - fixes S :: "'a::euclidean_space set" - assumes sv: "S \ V" - and iS: "independent S" - shows "\B. S \ B \ B \ V \ independent B \ V \ span B" - using sv iS -proof (induct "DIM('a) - card S" arbitrary: S rule: less_induct) - case less - note sv = \S \ V\ and i = \independent S\ - let ?P = "\B. S \ B \ B \ V \ independent B \ V \ span B" - let ?ths = "\x. ?P x" - let ?d = "DIM('a)" - show ?ths - proof (cases "V \ span S") - case True - then show ?thesis - using sv i by blast - next - case False - then obtain a where a: "a \ V" "a \ span S" - by blast - from a have aS: "a \ S" - by (auto simp add: span_superset) - have th0: "insert a S \ V" - using a sv by blast - from independent_insert[of a S] i a - have th1: "independent (insert a S)" - by auto - have mlt: "?d - card (insert a S) < ?d - card S" - using aS a independent_bound[OF th1] by auto - - from less(1)[OF mlt th0 th1] - obtain B where B: "insert a S \ B" "B \ V" "independent B" " V \ span B" - by blast - from B have "?P B" by auto - then show ?thesis by blast - qed -qed - -lemma maximal_independent_subset: - "\(B:: ('a::euclidean_space) set). B\ V \ independent B \ V \ span B" - by (metis maximal_independent_subset_extend[of "{}:: ('a::euclidean_space) set"] - empty_subsetI independent_empty) - - text \Notion of dimension.\ definition "dim V = (SOME n. \B. B \ V \ independent B \ V \ span B \ card B = n)"