diff -r ee0f7cfb7bba -r f944ae8c80a3 src/HOL/Multivariate_Analysis/Linear_Algebra.thy --- a/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Sun Apr 06 19:16:34 2014 +0200 +++ b/src/HOL/Multivariate_Analysis/Linear_Algebra.thy Sun Apr 06 19:35:35 2014 +0200 @@ -27,7 +27,7 @@ lemma square_continuous: fixes e :: real - shows "e > 0 \ \d. 0 < d \ (\y. abs (y - x) < d \ abs (y * y - x * x) < e)" + shows "e > 0 \ \d. 0 < d \ (\y. \y - x\ < d \ \y * y - x * x\ < e)" using isCont_power[OF isCont_ident, of x, unfolded isCont_def LIM_eq, rule_format, of e 2] apply (auto simp add: power2_eq_square) apply (rule_tac x="s" in exI) @@ -221,10 +221,12 @@ "linear f \ (\x y. f (x + y) = f x + f y) \ (\c x. f (c *\<^sub>R x) = c *\<^sub>R f x)" (is "linear f \ ?rhs") proof - assume "linear f" then interpret f: linear f . + assume "linear f" + then interpret f: linear f . show "?rhs" by (simp add: f.add f.scaleR) next - assume "?rhs" then show "linear f" by unfold_locales simp_all + assume "?rhs" + then show "linear f" by unfold_locales simp_all qed lemma linear_compose_cmul: "linear f \ linear (\x. c *\<^sub>R f x)" @@ -255,7 +257,11 @@ case True then show ?thesis using lS by induct (simp_all add: linear_zero linear_compose_add) -qed (simp add: linear_zero) +next + case False + then show ?thesis + by (simp add: linear_zero) +qed lemma linear_0: "linear f \ f 0 = 0" unfolding linear_iff @@ -283,7 +289,11 @@ case True then show ?thesis by induct (simp_all add: linear_0 [OF f] linear_add [OF f]) -qed (simp add: linear_0 [OF f]) +next + case False + then show ?thesis + by (simp add: linear_0 [OF f]) +qed lemma linear_setsum_mul: assumes lin: "linear f" @@ -401,7 +411,7 @@ *} lemma adjoint_works: - fixes f:: "'n::euclidean_space \ 'm::euclidean_space" + fixes f :: "'n::euclidean_space \ 'm::euclidean_space" assumes lf: "linear f" shows "x \ adjoint f y = f x \ y" proof - @@ -423,21 +433,21 @@ qed lemma adjoint_clauses: - fixes f:: "'n::euclidean_space \ 'm::euclidean_space" + fixes f :: "'n::euclidean_space \ 'm::euclidean_space" assumes lf: "linear f" shows "x \ adjoint f y = f x \ y" and "adjoint f y \ x = y \ f x" by (simp_all add: adjoint_works[OF lf] inner_commute) lemma adjoint_linear: - fixes f:: "'n::euclidean_space \ 'm::euclidean_space" + fixes f :: "'n::euclidean_space \ 'm::euclidean_space" assumes lf: "linear f" shows "linear (adjoint f)" by (simp add: lf linear_iff euclidean_eq_iff[where 'a='n] euclidean_eq_iff[where 'a='m] adjoint_clauses[OF lf] inner_distrib) lemma adjoint_adjoint: - fixes f:: "'n::euclidean_space \ 'm::euclidean_space" + fixes f :: "'n::euclidean_space \ 'm::euclidean_space" assumes lf: "linear f" shows "adjoint (adjoint f) = f" by (rule adjoint_unique, simp add: adjoint_clauses [OF lf]) @@ -462,7 +472,7 @@ unfolding subseq_def using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto -lemma approachable_lt_le: "(\(d::real)>0. \x. f x < d \ P x) \ (\d>0. \x. f x \ d \ P x)" +lemma approachable_lt_le: "(\(d::real) > 0. \x. f x < d \ P x) \ (\d>0. \x. f x \ d \ P x)" apply auto apply (rule_tac x="d/2" in exI) apply auto @@ -476,7 +486,7 @@ and xy: "x\<^sup>2 \ y\<^sup>2 + z\<^sup>2" shows "x \ y + z" proof - - have "y\<^sup>2 + z\<^sup>2 \ y\<^sup>2 + 2 *y * z + z\<^sup>2" + have "y\<^sup>2 + z\<^sup>2 \ y\<^sup>2 + 2 * y * z + z\<^sup>2" using z y by (simp add: mult_nonneg_nonneg) with xy have th: "x\<^sup>2 \ (y + z)\<^sup>2" by (simp add: power2_eq_square field_simps) @@ -546,16 +556,16 @@ apply (metis hull_in T) done -lemma hull_redundant_eq: "a \ (S hull s) \ (S hull (insert a s) = S hull s)" +lemma hull_redundant_eq: "a \ (S hull s) \ S hull (insert a s) = S hull s" unfolding hull_def by blast -lemma hull_redundant: "a \ (S hull s) \ (S hull (insert a s) = S hull s)" +lemma hull_redundant: "a \ (S hull s) \ S hull (insert a s) = S hull s" by (metis hull_redundant_eq) subsection {* Archimedean properties and useful consequences *} -lemma real_arch_simple: "\n. x \ real (n::nat)" +lemma real_arch_simple: "\n::nat. x \ real n" unfolding real_of_nat_def by (rule ex_le_of_nat) lemma real_arch_inv: "0 < e \ (\n::nat. n \ 0 \ 0 < inverse (real n) \ inverse (real n) < e)" @@ -647,7 +657,7 @@ lemma real_archimedian_rdiv_eq_0: assumes x0: "x \ 0" and c: "c \ 0" - and xc: "\(m::nat)>0. real m * x \ c" + and xc: "\(m::nat) > 0. real m * x \ c" shows "x = 0" proof (rule ccontr) assume "x \ 0" @@ -665,7 +675,7 @@ subsection{* A bit of linear algebra. *} definition (in real_vector) subspace :: "'a set \ bool" - where "subspace S \ 0 \ S \ (\x\ S. \y \S. x + y \ S) \ (\c. \x \S. c *\<^sub>R x \S )" + where "subspace S \ 0 \ S \ (\x \ S. \y \ S. x + y \ S) \ (\c. \x \ S. c *\<^sub>R x \ S)" definition (in real_vector) "span S = (subspace hull S)" definition (in real_vector) "dependent S \ (\a \ S. a \ span (S - {a}))" @@ -797,7 +807,7 @@ shows "\x \ span S. P x" using span_induct SP P by blast -inductive_set (in real_vector) span_induct_alt_help for S:: "'a set" +inductive_set (in real_vector) span_induct_alt_help for S :: "'a set" where span_induct_alt_help_0: "0 \ span_induct_alt_help S" | span_induct_alt_help_S: @@ -919,7 +929,7 @@ lemma span_linear_image: assumes lf: "linear f" - shows "span (f ` S) = f ` (span S)" + shows "span (f ` S) = f ` span S" proof (rule span_unique) show "f ` S \ f ` span S" by (intro image_mono span_inc) @@ -1414,7 +1424,7 @@ done lemma setsum_norm_allsubsets_bound: - fixes f:: "'a \ 'n::euclidean_space" + fixes f :: "'a \ 'n::euclidean_space" assumes fP: "finite P" and fPs: "\Q. Q \ P \ norm (setsum f Q) \ e" shows "(\x\P. norm (f x)) \ 2 * real DIM('n) * e" @@ -1429,7 +1439,8 @@ assume i: "i \ Basis" have "norm (\x\P. \f x \ i\) \ norm ((\x\P \ - {x. f x \ i < 0}. f x) \ i) + norm ((\x\P \ {x. f x \ i < 0}. f x) \ i)" - by (simp add: abs_real_def setsum_cases[OF fP] setsum_negf norm_triangle_ineq4 inner_setsum_left del: real_norm_def) + by (simp add: abs_real_def setsum_cases[OF fP] setsum_negf norm_triangle_ineq4 inner_setsum_left + del: real_norm_def) also have "\ \ e + e" unfolding real_norm_def by (intro add_mono norm_bound_Basis_le i fPs) auto @@ -1444,7 +1455,7 @@ subsection {* Linearity and Bilinearity continued *} lemma linear_bounded: - fixes f:: "'a::euclidean_space \ 'b::real_normed_vector" + fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" assumes lf: "linear f" shows "\B. \x. norm (f x) \ B * norm x" proof @@ -1496,7 +1507,7 @@ qed lemma linear_bounded_pos: - fixes f:: "'a::euclidean_space \ 'b::real_normed_vector" + fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" assumes lf: "linear f" shows "\B > 0. \x. norm (f x) \ B * norm x" proof - @@ -1508,7 +1519,7 @@ qed lemma bounded_linearI': - fixes f::"'a::euclidean_space \ 'b::real_normed_vector" + fixes f ::"'a::euclidean_space \ 'b::real_normed_vector" assumes "\x y. f (x + y) = f x + f y" and "\c x. f (c *\<^sub>R x) = c *\<^sub>R f x" shows "bounded_linear f" @@ -1516,7 +1527,7 @@ by (rule linearI[OF assms]) lemma bilinear_bounded: - fixes h:: "'m::euclidean_space \ 'n::euclidean_space \ 'k::real_normed_vector" + fixes h :: "'m::euclidean_space \ 'n::euclidean_space \ 'k::real_normed_vector" assumes bh: "bilinear h" shows "\B. \x y. norm (h x y) \ B * norm x * norm y" proof (clarify intro!: exI[of _ "\i\Basis. \j\Basis. norm (h i j)"]) @@ -1582,7 +1593,7 @@ qed lemma bilinear_bounded_pos: - fixes h:: "'a::euclidean_space \ 'b::euclidean_space \ 'c::real_normed_vector" + fixes h :: "'a::euclidean_space \ 'b::euclidean_space \ 'c::real_normed_vector" assumes bh: "bilinear h" shows "\B > 0. \x y. norm (h x y) \ B * norm x * norm y" proof - @@ -1602,7 +1613,8 @@ using independent_span_bound[OF finite_Basis, of S] by auto lemma dependent_biggerset: - "(finite (S::('a::euclidean_space) set) \ card S > DIM('a)) \ dependent S" + fixes S :: "'a::euclidean_space set" + shows "(finite S \ card S > DIM('a)) \ dependent S" by (metis independent_bound not_less) text {* Hence we can create a maximal independent subset. *} @@ -1816,7 +1828,7 @@ by (metis dim_span dim_subset) lemma span_eq_dim: - fixes S:: "'a::euclidean_space set" + fixes S :: "'a::euclidean_space set" shows "span S = span T \ dim S = dim T" by (metis dim_span) @@ -2003,7 +2015,7 @@ lemma span_not_univ_orthogonal: fixes S :: "'a::euclidean_space set" assumes sU: "span S \ UNIV" - shows "\(a::'a). a \0 \ (\x \ span S. a \ x = 0)" + shows "\a::'a. a \ 0 \ (\x \ span S. a \ x = 0)" proof - from sU obtain a where a: "a \ span S" by blast @@ -2066,7 +2078,7 @@ 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}" + shows "\a::'a. a \ 0 \ span S \ {x. a \ x = 0}" proof - { assume "span S = UNIV" @@ -2382,7 +2394,8 @@ qed lemma linear_eq_stdbasis: - assumes lf: "linear (f::'a::euclidean_space \ _)" + fixes f :: "'a::euclidean_space \ _" + assumes lf: "linear f" and lg: "linear g" and fg: "\b\Basis. f b = g b" shows "f = g" @@ -2429,18 +2442,19 @@ text {* Detailed theorems about left and right invertibility in general case. *} lemma linear_injective_left_inverse: - fixes f::"'a::euclidean_space \ 'b::euclidean_space" - assumes lf: "linear f" and fi: "inj f" - shows "\g. linear g \ g o f = id" + fixes f :: "'a::euclidean_space \ 'b::euclidean_space" + assumes lf: "linear f" + and fi: "inj f" + shows "\g. linear g \ g \ 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. h x = inv f x" + obtain h :: "'b \ 'a" where h: "linear h" "\x \ f ` Basis. h x = inv f x" by blast from h(2) have th: "\i\Basis. (h \ f) i = id i" using inv_o_cancel[OF fi, unfolded fun_eq_iff id_def o_def] by auto from linear_eq_stdbasis[OF linear_compose[OF lf h(1)] linear_id th] - have "h o f = id" . + have "h \ f = id" . then show ?thesis using h(1) by blast qed @@ -2449,15 +2463,15 @@ fixes f :: "'a::euclidean_space \ 'b::euclidean_space" assumes lf: "linear f" and sf: "surj f" - shows "\g. linear g \ f o g = id" + shows "\g. linear g \ f \ g = id" proof - from linear_independent_extend[OF independent_Basis[where 'a='b],of "inv f"] - obtain h:: "'b \ 'a" where h: "linear h" "\x\Basis. h x = inv f x" + obtain h :: "'b \ 'a" where h: "linear h" "\x\Basis. h x = inv f x" by blast - from h(2) have th: "\i\Basis. (f o h) i = id i" + from h(2) have th: "\i\Basis. (f \ h) i = id i" using sf by (auto simp add: surj_iff_all) from linear_eq_stdbasis[OF linear_compose[OF h(1) lf] linear_id th] - have "f o h = id" . + have "f \ h = id" . then show ?thesis using h(1) by blast qed @@ -2465,7 +2479,7 @@ text {* An injective map @{typ "'a::euclidean_space \ 'b::euclidean_space"} is also surjective. *} lemma linear_injective_imp_surjective: - fixes f::"'a::euclidean_space \ 'a::euclidean_space" + fixes f :: "'a::euclidean_space \ 'a::euclidean_space" assumes lf: "linear f" and fi: "inj f" shows "surj f" @@ -2617,7 +2631,7 @@ by (simp add: fun_eq_iff o_def id_def) lemma linear_injective_isomorphism: - fixes f::"'a::euclidean_space \ 'a::euclidean_space" + fixes f :: "'a::euclidean_space \ 'a::euclidean_space" assumes lf: "linear f" and fi: "inj f" shows "\f'. linear f' \ (\x. f' (f x) = x) \ (\x. f (f' x) = x)" @@ -2687,22 +2701,22 @@ subsection {* Infinity norm *} -definition "infnorm (x::'a::euclidean_space) = Sup {abs (x \ b) |b. b \ Basis}" +definition "infnorm (x::'a::euclidean_space) = Sup {\x \ b\ |b. b \ Basis}" lemma infnorm_set_image: fixes x :: "'a::euclidean_space" - shows "{abs (x \ i) |i. i \ Basis} = (\i. abs (x \ i)) ` Basis" + shows "{\x \ i\ |i. i \ Basis} = (\i. \x \ i\) ` Basis" by blast lemma infnorm_Max: fixes x :: "'a::euclidean_space" - shows "infnorm x = Max ((\i. abs (x \ i)) ` Basis)" + shows "infnorm x = Max ((\i. \x \ i\) ` Basis)" by (simp add: infnorm_def infnorm_set_image cSup_eq_Max del: Sup_image_eq) lemma infnorm_set_lemma: fixes x :: "'a::euclidean_space" - shows "finite {abs (x \ i) |i. i \ Basis}" - and "{abs (x \ i) |i. i \ Basis} \ {}" + shows "finite {\x \ i\ |i. i \ Basis}" + and "{\x \ i\ |i. i \ Basis} \ {}" unfolding infnorm_set_image by auto @@ -2750,7 +2764,7 @@ lemma real_abs_sub_infnorm: "\infnorm x - infnorm y\ \ infnorm (x - y)" proof - - have th: "\(nx::real) n ny. nx \ n + ny \ ny <= n + nx \ \nx - ny\ \ n" + have th: "\(nx::real) n ny. nx \ n + ny \ ny \ n + nx \ \nx - ny\ \ n" by arith from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"] have ths: "infnorm x \ infnorm (x - y) + infnorm y" @@ -2767,7 +2781,7 @@ shows "b \ Basis \ \x \ b\ \ infnorm x" by (simp add: infnorm_Max) -lemma infnorm_mul: "infnorm (a *\<^sub>R x) = abs a * infnorm x" +lemma infnorm_mul: "infnorm (a *\<^sub>R x) = \a\ * infnorm x" unfolding infnorm_Max proof (safe intro!: Max_eqI) let ?B = "(\i. \x \ i\) ` Basis" @@ -2876,11 +2890,11 @@ qed lemma norm_cauchy_schwarz_abs_eq: - "abs (x \ y) = norm x * norm y \ + "\x \ y\ = norm x * norm y \ norm x *\<^sub>R y = norm y *\<^sub>R x \ norm x *\<^sub>R y = - norm y *\<^sub>R x" (is "?lhs \ ?rhs") proof - - have th: "\(x::real) a. a \ 0 \ abs x = a \ x = a \ x = - a" + have th: "\(x::real) a. a \ 0 \ \x\ = a \ x = a \ x = - a" by arith have "?rhs \ norm x *\<^sub>R y = norm y *\<^sub>R x \ norm (- x) *\<^sub>R y = norm y *\<^sub>R (- x)" by simp @@ -2945,7 +2959,7 @@ apply (rule exI[where x="- 1"], simp) done -lemma collinear_lemma: "collinear {0,x,y} \ x = 0 \ y = 0 \ (\c. y = c *\<^sub>R x)" +lemma collinear_lemma: "collinear {0, x, y} \ x = 0 \ y = 0 \ (\c. y = c *\<^sub>R x)" (is "?lhs \ ?rhs") proof - { @@ -2990,7 +3004,7 @@ ultimately show ?thesis by blast qed -lemma norm_cauchy_schwarz_equal: "abs (x \ y) = norm x * norm y \ collinear {0, x, y}" +lemma norm_cauchy_schwarz_equal: "\x \ y\ = norm x * norm y \ collinear {0, x, y}" unfolding norm_cauchy_schwarz_abs_eq apply (cases "x=0", simp_all add: collinear_2) apply (cases "y=0", simp_all add: collinear_2 insert_commute)