# HG changeset patch # User wenzelm # Date 1348946660 -7200 # Node ID b84fafaea4bb84d9c42c5148a4f0d39db8036824 # Parent de6be6922c19aa381feea366baf275e7eb614dec tuned proofs; diff -r de6be6922c19 -r b84fafaea4bb src/HOL/Multivariate_Analysis/Linear_Algebra.thy --- a/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Sat Sep 29 20:13:50 2012 +0200 +++ b/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Sat Sep 29 21:24:20 2012 +0200 @@ -312,7 +312,7 @@ lemma linear_injective_0: assumes lf: "linear f" shows "inj f \ (\x. f x = 0 \ x = 0)" -proof- +proof - have "inj f \ (\ x y. f x = f y \ x = y)" by (simp add: inj_on_def) also have "\ \ (\ x y. f x - f y = 0 \ x - y = 0)" by simp also have "\ \ (\ x y. f (x - y) = 0 \ x - y = 0)" @@ -328,6 +328,7 @@ lemma bilinear_ladd: "bilinear h ==> h (x + y) z = (h x z) + (h y z)" by (simp add: bilinear_def linear_def) + lemma bilinear_radd: "bilinear h ==> h x (y + z) = (h x y) + (h x z)" by (simp add: bilinear_def linear_def) @@ -346,13 +347,11 @@ lemma (in ab_group_add) eq_add_iff: "x = x + y \ y = 0" using add_imp_eq[of x y 0] by auto -lemma bilinear_lzero: - assumes bh: "bilinear h" shows "h 0 x = 0" - using bilinear_ladd[OF bh, of 0 0 x] by (simp add: eq_add_iff field_simps) - -lemma bilinear_rzero: - assumes bh: "bilinear h" shows "h x 0 = 0" - using bilinear_radd[OF bh, of x 0 0 ] by (simp add: eq_add_iff field_simps) +lemma bilinear_lzero: assumes "bilinear h" shows "h 0 x = 0" + using bilinear_ladd [OF assms, of 0 0 x] by (simp add: eq_add_iff field_simps) + +lemma bilinear_rzero: assumes "bilinear h" shows "h x 0 = 0" + using bilinear_radd [OF assms, of x 0 0 ] by (simp add: eq_add_iff field_simps) lemma bilinear_lsub: "bilinear h ==> h (x - y) z = h x z - h y z" by (simp add: diff_minus bilinear_ladd bilinear_lneg) @@ -361,7 +360,9 @@ by (simp add: diff_minus bilinear_radd bilinear_rneg) lemma bilinear_setsum: - assumes bh: "bilinear h" and fS: "finite S" and fT: "finite T" + assumes bh: "bilinear h" + and fS: "finite S" + and fT: "finite T" shows "h (setsum f S) (setsum g T) = setsum (\(i,j). h (f i) (g j)) (S \ T) " proof - have "h (setsum f S) (setsum g T) = setsum (\x. h (f x) (setsum g T)) S" @@ -886,7 +887,7 @@ lemma in_span_insert: assumes a: "a \ span (insert b S)" and na: "a \ span S" shows "b \ span (insert a S)" -proof- +proof - from span_breakdown[of b "insert b S" a, OF insertI1 a] obtain k where k: "a - k*\<^sub>R b \ span (S - {b})" by auto { assume k0: "k = 0" @@ -952,7 +953,7 @@ lemma span_explicit: "span P = {y. \S u. finite S \ S \ P \ setsum (\v. u v *\<^sub>R v) S = y}" (is "_ = ?E" is "_ = {y. ?h y}" is "_ = {y. \S u. ?Q S u y}") -proof- +proof - { fix x assume x: "x \ ?E" then obtain S u where fS: "finite S" and SP: "S\P" and u: "setsum (\v. u v *\<^sub>R v) S = x" by blast @@ -1138,8 +1139,8 @@ and AsB: "A \ span B" shows "A = B" proof - from BA show "B \ A" . -next + show "B \ A" by (rule BA) + from span_mono[OF BA] span_mono[OF AsB] have sAB: "span A = span B" unfolding span_span by blast @@ -1164,7 +1165,7 @@ assumes f:"finite t" and i: "independent s" and sp:"s \ span t" shows "\t'. (card t' = card t) \ finite t' \ s \ t' \ t' \ s \ t \ s \ span t'" -using f i sp + using f i sp proof (induct "card (t - s)" arbitrary: s t rule: less_induct) case less note ft = `finite t` and s = `independent s` and sp = `s \ span t` @@ -1255,11 +1256,12 @@ subsection{* Euclidean Spaces as Typeclass*} lemma independent_eq_inj_on: - fixes D :: nat and f :: "nat \ 'c::real_vector" - assumes *: "inj_on f {.. 'c::real_vector" + assumes "inj_on f {.. (\a u. a < D \ (\i\{..R f i) \ f a)" proof - - from * have eq: "\i. i < D \ f ` {..i. i < D \ f ` {..i. inj_on f ({..i. finite (f ` {.. {DIM('a)..}" by auto show ?thesis unfolding * image_Un basis_finite by auto qed -lemma (in euclidean_space) range_basis_finite[intro]: - "finite (range basis)" +lemma (in euclidean_space) range_basis_finite[intro]: "finite (range basis)" unfolding range_basis by auto lemma span_basis: "span (range basis) = (UNIV :: 'a::euclidean_space set)" @@ -1306,10 +1306,15 @@ qed lemma span_basis'[simp]:"span ((basis::nat=>'a) ` {..'a) ` {.. span (basis ` {.. setsum (\x. setsum (\i. \f x $$ i\) ?U) P" - apply (rule setsum_mono) by (rule norm_le_l1) + by (rule setsum_mono) (rule norm_le_l1) also have "\ \ 2 * ?d * e" unfolding th0 th1 proof (rule setsum_bounded) @@ -1369,7 +1374,7 @@ lemma lambda_skolem': "(\ix. P i x) \ (\x::'a. \i ?rhs") -proof- +proof - let ?S = "{..i. (x$$i) *\<^sub>R (basis i)) ?S))" - apply(subst euclidean_representation[of x]) apply rule done + apply (subst euclidean_representation[of x]) + apply rule + done also have "\ = norm (setsum (\ i. (x$$i) *\<^sub>R f (basis i)) ?S)" using linear_setsum[OF lf fS, of ?g, unfolded o_def] linear_cmul[OF lf] by auto finally have th0: "norm (f x) = norm (setsum (\i. (x$$i) *\<^sub>R f (basis i))?S)" . { fix i assume i: "i \ ?S" from component_le_norm[of x i] have "norm ((x$$i) *\<^sub>R f (basis i :: 'a)) \ norm (f (basis i)) * norm x" - unfolding norm_scaleR - apply (simp only: mult_commute) - apply (rule mult_mono) - apply (auto simp add: field_simps) - done } + unfolding norm_scaleR + apply (simp only: mult_commute) + apply (rule mult_mono) + apply (auto simp add: field_simps) + done } then have th: "\i\ ?S. norm ((x$$i) *\<^sub>R f (basis i :: 'a)) \ norm (f (basis i)) * norm x" by metis from setsum_norm_le[of _ "\i. (x$$i) *\<^sub>R (f (basis i))", OF th] @@ -1422,28 +1429,27 @@ fixes f:: "'a::euclidean_space \ 'b::real_normed_vector" assumes lf: "linear f" shows "\B > 0. \x. norm (f x) \ B * norm x" -proof- +proof - from linear_bounded[OF lf] obtain B where B: "\x. norm (f x) \ B * norm x" by blast let ?K = "\B\ + 1" have Kp: "?K > 0" by arith - { assume C: "B < 0" - have "((\\ i. 1)::'a) \ 0" unfolding euclidean_eq[where 'a='a] - by(auto intro!:exI[where x=0]) - then have "norm ((\\ i. 1)::'a) > 0" by auto - with C have "B * norm ((\\ i. 1)::'a) < 0" - by (simp add: mult_less_0_iff) - with B[rule_format, of "(\\ i. 1)::'a"] norm_ge_zero[of "f ((\\ i. 1)::'a)"] have False by simp - } - then have Bp: "B \ 0" by (metis not_leE) - { fix x::"'a" - have "norm (f x) \ ?K * norm x" + { assume C: "B < 0" + have "((\\ i. 1)::'a) \ 0" unfolding euclidean_eq[where 'a='a] + by(auto intro!:exI[where x=0]) + then have "norm ((\\ i. 1)::'a) > 0" by auto + with C have "B * norm ((\\ i. 1)::'a) < 0" + by (simp add: mult_less_0_iff) + with B[rule_format, of "(\\ i. 1)::'a"] norm_ge_zero[of "f ((\\ i. 1)::'a)"] have False by simp + } + then have Bp: "B \ 0" by (metis not_leE) + { fix x::"'a" + have "norm (f x) \ ?K * norm x" using B[rule_format, of x] norm_ge_zero[of x] norm_ge_zero[of "f x"] Bp apply (auto simp add: field_simps split add: abs_split) apply (erule order_trans, simp) done - } - then show ?thesis using Kp by blast + } then show ?thesis using Kp by blast qed lemma linear_conv_bounded_linear: @@ -1575,13 +1581,15 @@ shows "independent S \ finite S \ card S <= DIM('a::euclidean_space)" using independent_span_bound[of "(basis::nat=>'a) ` {.. card S > DIM('a)) ==> dependent S" +lemma dependent_biggerset: + "(finite (S::('a::euclidean_space) set) ==> 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: - assumes sv: "(S::('a::euclidean_space) set) \ V" and iS: "independent S" + assumes sv: "(S::('a::euclidean_space) set) \ 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) @@ -1684,8 +1692,10 @@ qed lemma card_le_dim_spanning: - assumes BV: "(B:: ('a::euclidean_space) set) \ V" and VB: "V \ span B" - and fB: "finite B" and dVB: "dim V \ card B" + assumes BV: "(B:: ('a::euclidean_space) set) \ V" + and VB: "V \ span B" + and fB: "finite B" + and dVB: "dim V \ card B" shows "independent B" proof - { fix a assume a: "a \ B" "a \ span (B -{a})" @@ -1739,13 +1749,15 @@ by (metis dim_span) lemma spans_image: - assumes lf: "linear f" and VB: "V \ span B" + assumes lf: "linear f" + and VB: "V \ span B" shows "f ` V \ span (f ` B)" unfolding span_linear_image[OF lf] by (metis VB image_mono) lemma dim_image_le: fixes f :: "'a::euclidean_space \ 'b::euclidean_space" - assumes lf: "linear f" shows "dim (f ` S) \ dim (S)" + assumes lf: "linear f" + shows "dim (f ` S) \ dim (S)" proof - from basis_exists[of S] obtain B where B: "B \ S" "independent B" "S \ span B" "card B = dim S" by blast @@ -1764,17 +1776,20 @@ assumes us: "UNIV \ span S" and lf: "linear f" and sf: "surj f" shows "UNIV \ span (f ` S)" -proof- +proof - have "UNIV \ f ` UNIV" using sf by (auto simp add: surj_def) also have " \ \ span (f ` S)" using spans_image[OF lf us] . finally show ?thesis . qed lemma independent_injective_image: - assumes iS: "independent S" and lf: "linear f" and fi: "inj f" + assumes iS: "independent S" + and lf: "linear f" + and fi: "inj f" shows "independent (f ` S)" -proof- - { fix a assume a: "a \ S" "f a \ span (f ` S - {f a})" +proof - + { fix a + assume a: "a \ S" "f a \ span (f ` S - {f a})" have eq: "f ` S - {f a} = f ` (S - {a})" using fi by (auto simp add: inj_on_def) from a have "f a \ f ` span (S -{a})" @@ -1855,7 +1870,7 @@ lemma orthogonal_basis_exists: fixes V :: "('a::euclidean_space) set" shows "\B. independent B \ B \ span V \ V \ span B \ (card B = dim V) \ pairwise orthogonal B" -proof- +proof - from basis_exists[of V] obtain B where B: "B \ V" "independent B" "V \ span B" "card B = dim V" by blast from B have fB: "finite B" "card B = dim V" using independent_bound by auto @@ -1927,7 +1942,8 @@ shows "\ a. a \0 \ span S \ {x. a \ x = 0}" using span_not_univ_orthogonal[OF SU] by auto -lemma lowdim_subset_hyperplane: fixes S::"('a::euclidean_space) set" +lemma lowdim_subset_hyperplane: + fixes S::"('a::euclidean_space) set" assumes d: "dim S < DIM('a)" shows "\(a::'a). a \ 0 \ span S \ {x. a \ x = 0}" proof - @@ -1942,14 +1958,17 @@ text {* We can extend a linear basis-basis injection to the whole set. *} lemma linear_indep_image_lemma: - assumes lf: "linear f" and fB: "finite B" + assumes lf: "linear f" + and fB: "finite B" and ifB: "independent (f ` B)" - and fi: "inj_on f B" and xsB: "x \ span B" + and fi: "inj_on f B" + and xsB: "x \ span B" and fx: "f x = 0" shows "x = 0" using fB ifB fi xsB fx proof (induct arbitrary: x rule: finite_induct[OF fB]) - case 1 then show ?case by auto + case 1 + then show ?case by auto next case (2 a b x) have fb: "finite b" using "2.prems" by simp @@ -2002,9 +2021,10 @@ shows "\g. (\x\ span B. \y\ span B. g (x + y) = g x + g y) \ (\x\ span B. \c. g (c*\<^sub>R x) = c *\<^sub>R g x) \ (\x\ B. g x = f x)" -using ib fi + using ib fi proof (induct rule: finite_induct[OF fi]) - case 1 then show ?case by auto + case 1 + then show ?case by auto next case (2 a b) from "2.prems" "2.hyps" have ibf: "independent b" "finite b" @@ -2083,7 +2103,11 @@ have "?g x = f x" by (simp add: h0[symmetric] g(3)[rule_format, OF xb]) } ultimately have "?g x = f x" using x by blast } - ultimately show ?case apply - apply (rule exI[where x="?g"]) apply blast done + ultimately show ?case + apply - + apply (rule exI[where x="?g"]) + apply blast + done qed lemma linear_independent_extend: @@ -2098,15 +2122,18 @@ \ (\x\ span C. \c. g (c*\<^sub>R x) = c *\<^sub>R g x) \ (\x\ C. g x = f x)" by blast from g show ?thesis unfolding linear_def using C - apply clarsimp apply blast done + apply clarsimp + apply blast + done qed text {* Can construct an isomorphism between spaces of same dimension. *} lemma card_le_inj: - assumes fA: "finite A" and fB: "finite B" + assumes fA: "finite A" + and fB: "finite B" and c: "card A \ card B" - shows "(\f. f ` A \ B \ inj_on f A)" + shows "\f. f ` A \ B \ inj_on f A" using fA fB c proof (induct arbitrary: B rule: finite_induct) case empty @@ -2131,7 +2158,9 @@ qed lemma card_subset_eq: - assumes fB: "finite B" and AB: "A \ B" and c: "card A = card B" + assumes fB: "finite B" + and AB: "A \ B" + and c: "card A = card B" shows "A = B" proof - from fB AB have fA: "finite A" by (auto intro: finite_subset) @@ -2200,15 +2229,19 @@ by (rule span_induct') lemma linear_eq_0: - assumes lf: "linear f" and SB: "S \ span B" and f0: "\x\B. f x = 0" + assumes lf: "linear f" + and SB: "S \ span B" + and f0: "\x\B. f x = 0" shows "\x \ S. f x = 0" by (metis linear_eq_0_span[OF lf] subset_eq SB f0) lemma linear_eq: - assumes lf: "linear f" and lg: "linear g" and S: "S \ span B" + assumes lf: "linear f" + and lg: "linear g" + and S: "S \ span B" and fg: "\ x\ B. f x = g x" shows "\x\ S. f x = g x" -proof- +proof - let ?h = "\x. f x - g x" from fg have fg': "\x\ B. ?h x = 0" by simp from linear_eq_0[OF linear_compose_sub[OF lf lg] S fg'] @@ -2216,17 +2249,21 @@ qed lemma linear_eq_stdbasis: - assumes lf: "linear (f::'a::euclidean_space \ _)" and lg: "linear g" + assumes lf: "linear (f::'a::euclidean_space \ _)" + and lg: "linear g" and fg: "\i (UNIV :: 'a set)" from equalityD2[OF span_basis'[where 'a='a]] have IU: " (UNIV :: 'a set) \ span ?I" by blast - have "f x = g x" apply(rule linear_eq[OF lf lg IU,rule_format]) using fg x by auto } - then show ?thesis by auto + have "f x = g x" + apply (rule linear_eq[OF lf lg IU,rule_format]) + using fg x apply auto + done + } then show ?thesis by auto qed text {* Similar results for bilinear functions. *} @@ -2237,11 +2274,12 @@ and SB: "S \ span B" and TC: "T \ span C" and fg: "\x\ B. \y\ C. f x y = g x y" shows "\x\S. \y\T. f x y = g x y " -proof- +proof - let ?P = "{x. \y\ span C. f x y = g x y}" from bf bg have sp: "subspace ?P" unfolding bilinear_def linear_def subspace_def bf bg - by(auto simp add: span_0 bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def intro: bilinear_ladd[OF bf]) + by (auto simp add: span_0 bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def + intro: bilinear_ladd[OF bf]) have "\x \ span B. \y\ span C. f x y = g x y" apply (rule span_induct' [OF _ sp]) @@ -2251,7 +2289,7 @@ apply (auto simp add: subspace_def) using bf bg unfolding bilinear_def linear_def apply (auto simp add: span_0 bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add Ball_def - intro: bilinear_ladd[OF bf]) + intro: bilinear_ladd[OF bf]) done then show ?thesis using SB TC by auto qed @@ -2277,8 +2315,8 @@ shows "\g. linear g \ g o f = id" proof - from linear_independent_extend[OF independent_injective_image, OF independent_basis, OF lf fi] - obtain h:: "'b => 'a" where h: "linear h" - "\x \ f ` basis ` {.. 'a" where + h: "linear h" "\x \ f ` basis ` {..i f) (basis i) = id (basis i)" using inv_o_cancel[OF fi, unfolded fun_eq_iff id_def o_def] by auto @@ -2335,12 +2373,15 @@ text {* And vice versa. *} lemma surjective_iff_injective_gen: - assumes fS: "finite S" and fT: "finite T" and c: "card S = card T" + assumes fS: "finite S" + and fT: "finite T" + and c: "card S = card T" and ST: "f ` S \ T" shows "(\y \ T. \x \ S. f x = y) \ inj_on f S" (is "?lhs \ ?rhs") proof - { assume h: "?lhs" - { fix x y assume x: "x \ S" and y: "y \ S" and f: "f x = f y" + { fix x y + assume x: "x \ S" and y: "y \ S" and f: "f x = f y" from x fS have S0: "card S \ 0" by auto { assume xy: "x \ y" have th: "card S \ card (f ` (S - {y}))" @@ -2538,8 +2579,9 @@ unfolding infnorm_def unfolding Sup_finite_le_iff[OF infnorm_set_lemma] unfolding infnorm_set_image ball_simps - apply(subst (1) euclidean_eq) - by auto + apply (subst (1) euclidean_eq) + apply auto + done then show ?thesis using infnorm_pos_le[of x] by simp qed @@ -2638,12 +2680,13 @@ unfolding power_mult_distrib d2 unfolding real_of_nat_def apply(subst euclidean_inner) apply (subst power2_abs[symmetric]) - apply(rule order_trans[OF setsum_bounded[where K="\infnorm x\\"]]) - apply(auto simp add: power2_eq_square[symmetric]) + apply (rule order_trans[OF setsum_bounded[where K="\infnorm x\\"]]) + apply (auto simp add: power2_eq_square[symmetric]) apply (subst power2_abs[symmetric]) apply (rule power_mono) unfolding infnorm_def Sup_finite_ge_iff[OF infnorm_set_lemma] - unfolding infnorm_set_image bex_simps apply(rule_tac x=i in bexI) + unfolding infnorm_set_image bex_simps + apply (rule_tac x=i in bexI) apply auto done from real_le_lsqrt[OF inner_ge_zero th th1]