# HG changeset patch # User huffman # Date 1272566464 25200 # Node ID fb69c8cd27bdf4ea1dc786961254c5f06498b45f # Parent eacded3b05f71fa9160e013789940d68c3c351eb define linear algebra concepts using scaleR instead of (op *s); generalized many lemmas, though a few theorems that used to work on type int^'n are a bit less general diff -r eacded3b05f7 -r fb69c8cd27bd src/HOL/Multivariate_Analysis/Derivative.thy --- a/src/HOL/Multivariate_Analysis/Derivative.thy Thu Apr 29 09:29:47 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Derivative.thy Thu Apr 29 11:41:04 2010 -0700 @@ -1090,7 +1090,7 @@ show "bounded_linear (g' x)" unfolding linear_linear linear_def apply(rule,rule,rule) defer proof(rule,rule) fix x' y z::"real^'m" and c::real note lin = assms(2)[rule_format,OF `x\s`,THEN derivative_linear] - show "g' x (c *s x') = c *s g' x x'" apply(rule Lim_unique[OF trivial_limit_sequentially]) + show "g' x (c *\<^sub>R x') = c *\<^sub>R g' x x'" apply(rule Lim_unique[OF trivial_limit_sequentially]) apply(rule lem3[rule_format]) unfolding smult_conv_scaleR unfolding lin[unfolded bounded_linear_def bounded_linear_axioms_def,THEN conjunct2,THEN conjunct1,rule_format] apply(rule Lim_cmul) by(rule lem3[rule_format]) diff -r eacded3b05f7 -r fb69c8cd27bd src/HOL/Multivariate_Analysis/Determinants.thy --- a/src/HOL/Multivariate_Analysis/Determinants.thy Thu Apr 29 09:29:47 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Determinants.thy Thu Apr 29 11:41:04 2010 -0700 @@ -421,7 +421,7 @@ qed lemma det_row_span: - fixes A :: "'a:: linordered_idom^'n^'n" + fixes A :: "real^'n^'n" assumes x: "x \ span {row j A |j. j \ i}" shows "det (\ k. if k = i then row i A + x else row k A) = det A" proof- @@ -450,7 +450,7 @@ ultimately show ?thesis apply - - apply (rule span_induct_alt[of ?P ?S, OF P0]) + apply (rule span_induct_alt[of ?P ?S, OF P0, folded smult_conv_scaleR]) apply blast apply (rule x) done @@ -462,7 +462,7 @@ (* ------------------------------------------------------------------------- *) lemma det_dependent_rows: - fixes A:: "'a::linordered_idom^'n^'n" + fixes A:: "real^'n^'n" assumes d: "dependent (rows A)" shows "det A = 0" proof- @@ -483,12 +483,12 @@ from det_row_span[OF th0] have "det A = det (\ k. if k = i then 0 *s 1 else row k A)" unfolding right_minus vector_smult_lzero .. - with det_row_mul[of i "0::'a" "\i. 1"] + with det_row_mul[of i "0::real" "\i. 1"] have "det A = 0" by simp} ultimately show ?thesis by blast qed -lemma det_dependent_columns: assumes d: "dependent(columns (A::'a::linordered_idom^'n^'n))" shows "det A = 0" +lemma det_dependent_columns: assumes d: "dependent(columns (A::real^'n^'n))" shows "det A = 0" by (metis d det_dependent_rows rows_transpose det_transpose) (* ------------------------------------------------------------------------- *) @@ -744,7 +744,7 @@ apply (rule span_setsum) apply simp apply (rule ballI) - apply (rule span_mul)+ + apply (rule span_mul [where 'a="real^'n", folded smult_conv_scaleR])+ apply (rule span_superset) apply auto done @@ -761,9 +761,9 @@ (* ------------------------------------------------------------------------- *) lemma cramer_lemma_transpose: - fixes A:: "'a::linordered_idom^'n^'n" and x :: "'a ^'n" + fixes A:: "real^'n^'n" and x :: "real^'n" shows "det ((\ i. if i = k then setsum (\i. x$i *s row i A) (UNIV::'n set) - else row i A)::'a^'n^'n) = x$k * det A" + else row i A)::real^'n^'n) = x$k * det A" (is "?lhs = ?rhs") proof- let ?U = "UNIV :: 'n set" @@ -780,7 +780,7 @@ apply (rule det_row_span) apply (rule span_setsum[OF fUk]) apply (rule ballI) - apply (rule span_mul) + apply (rule span_mul [where 'a="real^'n", folded smult_conv_scaleR])+ apply (rule span_superset) apply auto done @@ -797,8 +797,8 @@ qed lemma cramer_lemma: - fixes A :: "'a::linordered_idom ^'n^'n" - shows "det((\ i j. if j = k then (A *v x)$i else A$i$j):: 'a^'n^'n) = x$k * det A" + fixes A :: "real^'n^'n" + shows "det((\ i j. if j = k then (A *v x)$i else A$i$j):: real^'n^'n) = x$k * det A" proof- let ?U = "UNIV :: 'n set" have stupid: "\c. setsum (\i. c i *s row i (transpose A)) ?U = setsum (\i. c i *s column i A) ?U" diff -r eacded3b05f7 -r fb69c8cd27bd src/HOL/Multivariate_Analysis/Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Thu Apr 29 09:29:47 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Thu Apr 29 11:41:04 2010 -0700 @@ -753,6 +753,13 @@ "setsum (\i. (x$i) *s basis i) UNIV = (x::('a::ring_1) ^'n)" (is "?lhs = ?rhs" is "setsum ?f ?S = _") by (auto simp add: Cart_eq cond_value_iff setsum_delta[of "?S", where ?'b = "'a", simplified] cong del: if_weak_cong) +lemma smult_conv_scaleR: "c *s x = scaleR c x" + unfolding vector_scalar_mult_def vector_scaleR_def by simp + +lemma basis_expansion': + "setsum (\i. (x$i) *\<^sub>R basis i) UNIV = x" + by (rule basis_expansion [where 'a=real, unfolded smult_conv_scaleR]) + lemma basis_expansion_unique: "setsum (\i. f i *s basis i) UNIV = (x::('a::comm_ring_1) ^'n) \ (\i. f i = x$i)" by (simp add: Cart_eq setsum_delta cond_value_iff cong del: if_weak_cong) @@ -824,64 +831,63 @@ subsection{* Linear functions. *} -definition "linear f \ (\x y. f(x + y) = f x + f y) \ (\c x. f(c *s x) = c *s f x)" - -lemma linearI: assumes "\x y. f (x + y) = f x + f y" "\c x. f (c *s x) = c *s f x" +definition + linear :: "('a::real_vector \ 'b::real_vector) \ bool" where + "linear f \ (\x y. f(x + y) = f x + f y) \ (\c x. f(c *\<^sub>R x) = c *\<^sub>R f x)" + +lemma linearI: assumes "\x y. f (x + y) = f x + f y" "\c x. f (c *\<^sub>R x) = c *\<^sub>R f x" shows "linear f" using assms unfolding linear_def by auto -lemma linear_compose_cmul: "linear f ==> linear (\x. (c::'a::comm_semiring) *s f x)" - by (vector linear_def Cart_eq field_simps) - -lemma linear_compose_neg: "linear (f :: 'a ^'n \ 'a::comm_ring ^'m) ==> linear (\x. -(f(x)))" by (vector linear_def Cart_eq) - -lemma linear_compose_add: "linear (f :: 'a ^'n \ 'a::semiring_1 ^'m) \ linear g ==> linear (\x. f(x) + g(x))" - by (vector linear_def Cart_eq field_simps) - -lemma linear_compose_sub: "linear (f :: 'a ^'n \ 'a::ring_1 ^'m) \ linear g ==> linear (\x. f x - g x)" - by (vector linear_def Cart_eq field_simps) +lemma linear_compose_cmul: "linear f ==> linear (\x. c *\<^sub>R f x)" + by (simp add: linear_def algebra_simps) + +lemma linear_compose_neg: "linear f ==> linear (\x. -(f(x)))" + by (simp add: linear_def) + +lemma linear_compose_add: "linear f \ linear g ==> linear (\x. f(x) + g(x))" + by (simp add: linear_def algebra_simps) + +lemma linear_compose_sub: "linear f \ linear g ==> linear (\x. f x - g x)" + by (simp add: linear_def algebra_simps) lemma linear_compose: "linear f \ linear g ==> linear (g o f)" by (simp add: linear_def) lemma linear_id: "linear id" by (simp add: linear_def id_def) -lemma linear_zero: "linear (\x. 0::'a::semiring_1 ^ 'n)" by (simp add: linear_def) +lemma linear_zero: "linear (\x. 0)" by (simp add: linear_def) lemma linear_compose_setsum: - assumes fS: "finite S" and lS: "\a \ S. linear (f a :: 'a::semiring_1 ^ 'n \ 'a ^'m)" - shows "linear(\x. setsum (\a. f a x :: 'a::semiring_1 ^'m) S)" + assumes fS: "finite S" and lS: "\a \ S. linear (f a)" + shows "linear(\x. setsum (\a. f a x) S)" using lS apply (induct rule: finite_induct[OF fS]) by (auto simp add: linear_zero intro: linear_compose_add) lemma linear_vmul_component: - fixes f:: "'a::semiring_1^'m \ 'a^'n" assumes lf: "linear f" - shows "linear (\x. f x $ k *s v)" + shows "linear (\x. f x $ k *\<^sub>R v)" using lf - apply (auto simp add: linear_def ) - by (vector field_simps)+ - -lemma linear_0: "linear f ==> f 0 = (0::'a::semiring_1 ^'n)" + by (auto simp add: linear_def algebra_simps) + +lemma linear_0: "linear f ==> f 0 = 0" unfolding linear_def apply clarsimp apply (erule allE[where x="0::'a"]) apply simp done -lemma linear_cmul: "linear f ==> f(c*s x) = c *s f x" by (simp add: linear_def) - -lemma linear_neg: "linear (f :: 'a::ring_1 ^'n \ _) ==> f (-x) = - f x" - unfolding vector_sneg_minus1 - using linear_cmul[of f] by auto +lemma linear_cmul: "linear f ==> f(c *\<^sub>R x) = c *\<^sub>R f x" by (simp add: linear_def) + +lemma linear_neg: "linear f ==> f (-x) = - f x" + using linear_cmul [where c="-1"] by simp lemma linear_add: "linear f ==> f(x + y) = f x + f y" by (metis linear_def) -lemma linear_sub: "linear (f::'a::ring_1 ^'n \ _) ==> f(x - y) = f x - f y" +lemma linear_sub: "linear f ==> f(x - y) = f x - f y" by (simp add: diff_def linear_add linear_neg) lemma linear_setsum: - fixes f:: "'a::semiring_1^'n \ _" assumes lf: "linear f" and fS: "finite S" shows "f (setsum g S) = setsum (f o g) S" proof (induct rule: finite_induct[OF fS]) @@ -896,14 +902,13 @@ qed lemma linear_setsum_mul: - fixes f:: "'a ^'n \ 'a::semiring_1^'m" assumes lf: "linear f" and fS: "finite S" - shows "f (setsum (\i. c i *s v i) S) = setsum (\i. c i *s f (v i)) S" - using linear_setsum[OF lf fS, of "\i. c i *s v i" , unfolded o_def] + shows "f (setsum (\i. c i *\<^sub>R v i) S) = setsum (\i. c i *\<^sub>R f (v i)) S" + using linear_setsum[OF lf fS, of "\i. c i *\<^sub>R v i" , unfolded o_def] linear_cmul[OF lf] by simp lemma linear_injective_0: - assumes lf: "linear (f:: 'a::ring_1 ^ 'n \ _)" + assumes lf: "linear f" shows "inj f \ (\x. f x = 0 \ x = 0)" proof- have "inj f \ (\ x y. f x = f y \ x = y)" by (simp add: inj_on_def) @@ -923,22 +928,22 @@ let ?B = "setsum (\i. norm(f(basis i))) ?S" have fS: "finite ?S" by simp {fix x:: "real ^ 'm" - let ?g = "(\i. (x$i) *s (basis i) :: real ^ 'm)" - have "norm (f x) = norm (f (setsum (\i. (x$i) *s (basis i)) ?S))" - by (simp only: basis_expansion) - also have "\ = norm (setsum (\i. (x$i) *s f (basis i))?S)" + let ?g = "(\i. (x$i) *\<^sub>R (basis i) :: real ^ 'm)" + have "norm (f x) = norm (f (setsum (\i. (x$i) *\<^sub>R (basis i)) ?S))" + by (simp add: basis_expansion') + 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) *s f (basis i))?S)" . + 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) *s f (basis i :: real ^'m)) \ norm (f (basis i)) * norm x" - unfolding norm_mul + have "norm ((x$i) *\<^sub>R f (basis i :: real ^'m)) \ norm (f (basis i)) * norm x" + unfolding norm_scaleR apply (simp only: mult_commute) apply (rule mult_mono) by (auto simp add: field_simps) } - then have th: "\i\ ?S. norm ((x$i) *s f (basis i :: real ^'m)) \ norm (f (basis i)) * norm x" by metis - from setsum_norm_le[OF fS, of "\i. (x$i) *s (f (basis i))", OF th] + then have th: "\i\ ?S. norm ((x$i) *\<^sub>R f (basis i :: real ^'m)) \ norm (f (basis i)) * norm x" by metis + from setsum_norm_le[OF fS, of "\i. (x$i) *\<^sub>R (f (basis i))", OF th] have "norm (f x) \ ?B * norm x" unfolding th0 setsum_left_distrib by metis} then show ?thesis by blast qed @@ -969,9 +974,6 @@ then show ?thesis using Kp by blast qed -lemma smult_conv_scaleR: "c *s x = scaleR c x" - unfolding vector_scalar_mult_def vector_scaleR_def by simp - lemma linear_conv_bounded_linear: fixes f :: "real ^ _ \ real ^ _" shows "linear f \ bounded_linear f" @@ -1000,7 +1002,7 @@ qed lemma bounded_linearI': fixes f::"real^'n \ real^'m" - assumes "\x y. f (x + y) = f x + f y" "\c x. f (c *s x) = c *s f x" + assumes "\x y. f (x + y) = f x + f y" "\c x. f (c *\<^sub>R x) = c *\<^sub>R f x" shows "bounded_linear f" unfolding linear_conv_bounded_linear[THEN sym] by(rule linearI[OF assms]) @@ -1013,39 +1015,38 @@ lemma bilinear_radd: "bilinear h ==> h x (y + z) = (h x y) + (h x z)" by (simp add: bilinear_def linear_def) -lemma bilinear_lmul: "bilinear h ==> h (c *s x) y = c *s (h x y)" +lemma bilinear_lmul: "bilinear h ==> h (c *\<^sub>R x) y = c *\<^sub>R (h x y)" by (simp add: bilinear_def linear_def) -lemma bilinear_rmul: "bilinear h ==> h x (c *s y) = c *s (h x y)" +lemma bilinear_rmul: "bilinear h ==> h x (c *\<^sub>R y) = c *\<^sub>R (h x y)" by (simp add: bilinear_def linear_def) -lemma bilinear_lneg: "bilinear h ==> h (- (x:: 'a::ring_1 ^ 'n)) y = -(h x y)" - by (simp only: vector_sneg_minus1 bilinear_lmul) - -lemma bilinear_rneg: "bilinear h ==> h x (- (y:: 'a::ring_1 ^ 'n)) = - h x y" - by (simp only: vector_sneg_minus1 bilinear_rmul) +lemma bilinear_lneg: "bilinear h ==> h (- x) y = -(h x y)" + by (simp only: scaleR_minus1_left [symmetric] bilinear_lmul) + +lemma bilinear_rneg: "bilinear h ==> h x (- y) = - h x y" + by (simp only: scaleR_minus1_left [symmetric] bilinear_rmul) 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: - fixes h :: "'a::ring^'n \ _" assumes bh: "bilinear h" shows "h 0 x = 0" + 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: - fixes h :: "'a::ring^_ \ _" assumes bh: "bilinear h" shows "h x 0 = 0" + 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_lsub: "bilinear h ==> h (x - (y:: 'a::ring_1 ^ _)) z = h x z - h y z" +lemma bilinear_lsub: "bilinear h ==> h (x - y) z = h x z - h y z" by (simp add: diff_def bilinear_ladd bilinear_lneg) -lemma bilinear_rsub: "bilinear h ==> h z (x - (y:: 'a::ring_1 ^ _)) = h z x - h z y" +lemma bilinear_rsub: "bilinear h ==> h z (x - y) = h z x - h z y" by (simp add: diff_def bilinear_radd bilinear_rneg) lemma bilinear_setsum: - fixes h:: "'a ^_ \ 'a::semiring_1^_\ 'a ^ _" 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- @@ -1069,15 +1070,15 @@ let ?B = "setsum (\(i,j). norm (h (basis i) (basis j))) (?M \ ?N)" have fM: "finite ?M" and fN: "finite ?N" by simp_all {fix x:: "real ^ 'm" and y :: "real^'n" - have "norm (h x y) = norm (h (setsum (\i. (x$i) *s basis i) ?M) (setsum (\i. (y$i) *s basis i) ?N))" unfolding basis_expansion .. - also have "\ = norm (setsum (\ (i,j). h ((x$i) *s basis i) ((y$j) *s basis j)) (?M \ ?N))" unfolding bilinear_setsum[OF bh fM fN] .. + have "norm (h x y) = norm (h (setsum (\i. (x$i) *\<^sub>R basis i) ?M) (setsum (\i. (y$i) *\<^sub>R basis i) ?N))" unfolding basis_expansion' .. + also have "\ = norm (setsum (\ (i,j). h ((x$i) *\<^sub>R basis i) ((y$j) *\<^sub>R basis j)) (?M \ ?N))" unfolding bilinear_setsum[OF bh fM fN] .. finally have th: "norm (h x y) = \" . have "norm (h x y) \ ?B * norm x * norm y" apply (simp add: setsum_left_distrib th) apply (rule setsum_norm_le) using fN fM apply simp - apply (auto simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] field_simps) + apply (auto simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] field_simps simp del: scaleR_scaleR) apply (rule mult_mono) apply (auto simp add: zero_le_mult_iff component_le_norm) apply (rule mult_mono) @@ -1148,6 +1149,11 @@ lemma choice_iff: "(\x. \y. P x y) \ (\f. \x. P x (f x))" by metis +text {* TODO: The following lemmas about adjoints should hold for any +Hilbert space (i.e. complete inner product space). +(see http://en.wikipedia.org/wiki/Hermitian_adjoint) +*} + lemma adjoint_works_lemma: fixes f:: "real ^'n \ real ^'m" assumes lf: "linear f" @@ -1160,9 +1166,9 @@ {fix y:: "real ^ 'm" let ?w = "(\ i. (f (basis i) \ y)) :: real ^ 'n" {fix x - have "f x \ y = f (setsum (\i. (x$i) *s basis i) ?N) \ y" - by (simp only: basis_expansion) - also have "\ = (setsum (\i. (x$i) *s f (basis i)) ?N) \ y" + have "f x \ y = f (setsum (\i. (x$i) *\<^sub>R basis i) ?N) \ y" + by (simp only: basis_expansion') + also have "\ = (setsum (\i. (x$i) *\<^sub>R f (basis i)) ?N) \ y" unfolding linear_setsum[OF lf fN] by (simp add: linear_cmul[OF lf]) finally have "f x \ y = x \ ?w" @@ -1326,18 +1332,18 @@ by (vector Cart_eq setsum_component) lemma linear_componentwise: - fixes f:: "'a::ring_1 ^'m \ 'a ^ _" + fixes f:: "real ^'m \ real ^ _" assumes lf: "linear f" shows "(f x)$j = setsum (\i. (x$i) * (f (basis i)$j)) (UNIV :: 'm set)" (is "?lhs = ?rhs") proof- let ?M = "(UNIV :: 'm set)" let ?N = "(UNIV :: 'n set)" have fM: "finite ?M" by simp - have "?rhs = (setsum (\i.(x$i) *s f (basis i) ) ?M)$j" - unfolding vector_smult_component[symmetric] - unfolding setsum_component[of "(\i.(x$i) *s f (basis i :: 'a^'m))" ?M] + have "?rhs = (setsum (\i.(x$i) *\<^sub>R f (basis i) ) ?M)$j" + unfolding vector_smult_component[symmetric] smult_conv_scaleR + unfolding setsum_component[of "(\i.(x$i) *\<^sub>R f (basis i :: real^'m))" ?M] .. - then show ?thesis unfolding linear_setsum_mul[OF lf fM, symmetric] basis_expansion .. + then show ?thesis unfolding linear_setsum_mul[OF lf fM, symmetric] basis_expansion' .. qed text{* Inverse matrices (not necessarily square) *} @@ -1352,23 +1358,23 @@ definition matrix:: "('a::{plus,times, one, zero}^'m \ 'a ^ 'n) \ 'a^'m^'n" where "matrix f = (\ i j. (f(basis j))$i)" -lemma matrix_vector_mul_linear: "linear(\x. A *v (x::'a::comm_semiring_1 ^ _))" +lemma matrix_vector_mul_linear: "linear(\x. A *v (x::real ^ _))" by (simp add: linear_def matrix_vector_mult_def Cart_eq field_simps setsum_right_distrib setsum_addf) -lemma matrix_works: assumes lf: "linear f" shows "matrix f *v x = f (x::'a::comm_ring_1 ^ 'n)" +lemma matrix_works: assumes lf: "linear f" shows "matrix f *v x = f (x::real ^ 'n)" apply (simp add: matrix_def matrix_vector_mult_def Cart_eq mult_commute) apply clarify apply (rule linear_componentwise[OF lf, symmetric]) done -lemma matrix_vector_mul: "linear f ==> f = (\x. matrix f *v (x::'a::comm_ring_1 ^ 'n))" by (simp add: ext matrix_works) - -lemma matrix_of_matrix_vector_mul: "matrix(\x. A *v (x :: 'a:: comm_ring_1 ^ 'n)) = A" +lemma matrix_vector_mul: "linear f ==> f = (\x. matrix f *v (x::real ^ 'n))" by (simp add: ext matrix_works) + +lemma matrix_of_matrix_vector_mul: "matrix(\x. A *v (x :: real ^ 'n)) = A" by (simp add: matrix_eq matrix_vector_mul_linear matrix_works) lemma matrix_compose: - assumes lf: "linear (f::'a::comm_ring_1^'n \ 'a^'m)" - and lg: "linear (g::'a::comm_ring_1^'m \ 'a^_)" + assumes lf: "linear (f::real^'n \ real^'m)" + and lg: "linear (g::real^'m \ real^_)" shows "matrix (g o f) = matrix g ** matrix f" using lf lg linear_compose[OF lf lg] matrix_works[OF linear_compose[OF lf lg]] by (simp add: matrix_eq matrix_works matrix_vector_mul_assoc[symmetric] o_def) @@ -1718,7 +1724,10 @@ subsection{* A bit of linear algebra. *} -definition "subspace S \ 0 \ S \ (\x\ S. \y \S. x + y \ S) \ (\c. \x \S. c *s x \S )" +definition + subspace :: "'a::real_vector set \ bool" where + "subspace S \ 0 \ S \ (\x\ S. \y \S. x + y \ S) \ (\c. \x \S. c *\<^sub>R x \S )" + definition "span S = (subspace hull S)" definition "dependent S \ (\a \ S. a \ span(S - {a}))" abbreviation "independent s == ~(dependent s)" @@ -1732,13 +1741,13 @@ lemma subspace_add: "subspace S \ x \ S \ y \ S ==> x + y \ S" by (metis subspace_def) -lemma subspace_mul: "subspace S \ x \ S \ c *s x \ S" +lemma subspace_mul: "subspace S \ x \ S \ c *\<^sub>R x \ S" by (metis subspace_def) -lemma subspace_neg: "subspace S \ (x::'a::ring_1^_) \ S \ - x \ S" - by (metis vector_sneg_minus1 subspace_mul) - -lemma subspace_sub: "subspace S \ (x::'a::ring_1^_) \ S \ y \ S \ x - y \ S" +lemma subspace_neg: "subspace S \ x \ S \ - x \ S" + by (metis scaleR_minus1_left subspace_mul) + +lemma subspace_sub: "subspace S \ x \ S \ y \ S \ x - y \ S" by (metis diff_def subspace_add subspace_neg) lemma subspace_setsum: @@ -1750,19 +1759,19 @@ by (simp add: subspace_def sA, auto simp add: sA subspace_add) lemma subspace_linear_image: - assumes lf: "linear (f::'a::semiring_1^_ \ _)" and sS: "subspace S" + assumes lf: "linear f" and sS: "subspace S" shows "subspace(f ` S)" using lf sS linear_0[OF lf] unfolding linear_def subspace_def apply (auto simp add: image_iff) apply (rule_tac x="x + y" in bexI, auto) - apply (rule_tac x="c*s x" in bexI, auto) + apply (rule_tac x="c *\<^sub>R x" in bexI, auto) done -lemma subspace_linear_preimage: "linear (f::'a::semiring_1^_ \ _) ==> subspace S ==> subspace {x. f x \ S}" +lemma subspace_linear_preimage: "linear f ==> subspace S ==> subspace {x. f x \ S}" by (auto simp add: subspace_def linear_def linear_0[of f]) -lemma subspace_trivial: "subspace {0::'a::semiring_1 ^_}" +lemma subspace_trivial: "subspace {0}" by (simp add: subspace_def) lemma subspace_inter: "subspace A \ subspace B ==> subspace (A \ B)" @@ -1798,7 +1807,7 @@ "a \ S ==> a \ span S" "0 \ span S" "x\ span S \ y \ span S ==> x + y \ span S" - "x \ span S \ c *s x \ span S" + "x \ span S \ c *\<^sub>R x \ span S" by (metis span_def hull_subset subset_eq) (metis subspace_span subspace_def)+ @@ -1811,11 +1820,11 @@ show "P x" by (metis mem_def subset_eq) qed -lemma span_empty: "span {} = {(0::'a::semiring_0 ^ _)}" +lemma span_empty: "span {} = {0}" apply (simp add: span_def) apply (rule hull_unique) apply (auto simp add: mem_def subspace_def) - unfolding mem_def[of "0::'a^_", symmetric] + unfolding mem_def[of "0::'a", symmetric] apply simp done @@ -1837,15 +1846,15 @@ and P: "subspace P" shows "\x \ span S. P x" using span_induct SP P by blast -inductive span_induct_alt_help for S:: "'a::semiring_1^_ \ bool" +inductive span_induct_alt_help for S:: "'a::real_vector \ bool" where span_induct_alt_help_0: "span_induct_alt_help S 0" - | span_induct_alt_help_S: "x \ S \ span_induct_alt_help S z \ span_induct_alt_help S (c *s x + z)" + | span_induct_alt_help_S: "x \ S \ span_induct_alt_help S z \ span_induct_alt_help S (c *\<^sub>R x + z)" lemma span_induct_alt': - assumes h0: "h (0::'a::semiring_1^'n)" and hS: "\c x y. x \ S \ h y \ h (c*s x + y)" shows "\x \ span S. h x" + assumes h0: "h 0" and hS: "\c x y. x \ S \ h y \ h (c *\<^sub>R x + y)" shows "\x \ span S. h x" proof- - {fix x:: "'a^'n" assume x: "span_induct_alt_help S x" + {fix x:: "'a" assume x: "span_induct_alt_help S x" have "h x" apply (rule span_induct_alt_help.induct[OF x]) apply (rule h0) @@ -1876,10 +1885,10 @@ done} moreover {fix c x assume xt: "span_induct_alt_help S x" - then have "span_induct_alt_help S (c*s x)" + then have "span_induct_alt_help S (c *\<^sub>R x)" apply (induct rule: span_induct_alt_help.induct) apply (simp add: span_induct_alt_help_0) - apply (simp add: vector_smult_assoc vector_add_ldistrib) + apply (simp add: scaleR_right_distrib) apply (rule span_induct_alt_help_S) apply assumption apply simp @@ -1892,7 +1901,7 @@ qed lemma span_induct_alt: - assumes h0: "h (0::'a::semiring_1^'n)" and hS: "\c x y. x \ S \ h y \ h (c*s x + y)" and x: "x \ span S" + assumes h0: "h 0" and hS: "\c x y. x \ S \ h y \ h (c *\<^sub>R x + y)" and x: "x \ span S" shows "h x" using span_induct_alt'[of h S] h0 hS x by blast @@ -1905,26 +1914,26 @@ lemma span_add: "x \ span S \ y \ span S ==> x + y \ span S" by (metis subspace_add subspace_span) -lemma span_mul: "x \ span S ==> (c *s x) \ span S" +lemma span_mul: "x \ span S ==> (c *\<^sub>R x) \ span S" by (metis subspace_span subspace_mul) -lemma span_neg: "x \ span S ==> - (x::'a::ring_1^_) \ span S" +lemma span_neg: "x \ span S ==> - x \ span S" by (metis subspace_neg subspace_span) -lemma span_sub: "(x::'a::ring_1^_) \ span S \ y \ span S ==> x - y \ span S" +lemma span_sub: "x \ span S \ y \ span S ==> x - y \ span S" by (metis subspace_span subspace_sub) lemma span_setsum: "finite A \ \x \ A. f x \ span S ==> setsum f A \ span S" by (rule subspace_setsum, rule subspace_span) -lemma span_add_eq: "(x::'a::ring_1^_) \ span S \ x + y \ span S \ y \ span S" +lemma span_add_eq: "x \ span S \ x + y \ span S \ y \ span S" apply (auto simp only: span_add span_sub) apply (subgoal_tac "(x + y) - x \ span S", simp) by (simp only: span_add span_sub) (* Mapping under linear image. *) -lemma span_linear_image: assumes lf: "linear (f::'a::semiring_1 ^ _ => _)" +lemma span_linear_image: assumes lf: "linear f" shows "span (f ` S) = f ` (span S)" proof- {fix x @@ -1957,8 +1966,8 @@ (* The key breakdown property. *) lemma span_breakdown: - assumes bS: "(b::'a::ring_1 ^ _) \ S" and aS: "a \ span S" - shows "\k. a - k*s b \ span (S - {b})" (is "?P a") + assumes bS: "b \ S" and aS: "a \ span S" + shows "\k. a - k *\<^sub>R b \ span (S - {b})" (is "?P a") proof- {fix x assume xS: "x \ S" {assume ab: "x = b" @@ -1983,23 +1992,23 @@ apply (simp add: mem_def) apply (clarsimp simp add: mem_def) apply (rule_tac x="k + ka" in exI) - apply (subgoal_tac "x + y - (k + ka) *s b = (x - k*s b) + (y - ka *s b)") + apply (subgoal_tac "x + y - (k + ka) *\<^sub>R b = (x - k*\<^sub>R b) + (y - ka *\<^sub>R b)") apply (simp only: ) apply (rule span_add[unfolded mem_def]) apply assumption+ - apply (vector field_simps) + apply (simp add: algebra_simps) apply (clarsimp simp add: mem_def) apply (rule_tac x= "c*k" in exI) - apply (subgoal_tac "c *s x - (c * k) *s b = c*s (x - k*s b)") + apply (subgoal_tac "c *\<^sub>R x - (c * k) *\<^sub>R b = c*\<^sub>R (x - k*\<^sub>R b)") apply (simp only: ) apply (rule span_mul[unfolded mem_def]) apply assumption - by (vector field_simps) + by (simp add: algebra_simps) ultimately show "?P a" using aS span_induct[where S=S and P= "?P"] by metis qed lemma span_breakdown_eq: - "(x::'a::ring_1^_) \ span (insert a S) \ (\k. (x - k *s a) \ span S)" (is "?lhs \ ?rhs") + "x \ span (insert a S) \ (\k. (x - k *\<^sub>R a) \ span S)" (is "?lhs \ ?rhs") proof- {assume x: "x \ span (insert a S)" from x span_breakdown[of "a" "insert a S" "x"] @@ -2011,9 +2020,9 @@ apply blast done} moreover - { fix k assume k: "x - k *s a \ span S" - have eq: "x = (x - k *s a) + k *s a" by vector - have "(x - k *s a) + k *s a \ span (insert a S)" + { fix k assume k: "x - k *\<^sub>R a \ span S" + have eq: "x = (x - k *\<^sub>R a) + k *\<^sub>R a" by vector + have "(x - k *\<^sub>R a) + k *\<^sub>R a \ span (insert a S)" apply (rule span_add) apply (rule set_rev_mp[of _ "span S" _]) apply (rule k) @@ -2030,11 +2039,11 @@ (* Hence some "reversal" results.*) lemma in_span_insert: - assumes a: "(a::'a::field^_) \ span (insert b S)" and na: "a \ span S" + assumes a: "a \ span (insert b S)" and na: "a \ span S" shows "b \ span (insert a S)" proof- from span_breakdown[of b "insert b S" a, OF insertI1 a] - obtain k where k: "a - k*s b \ span (S - {b})" by auto + obtain k where k: "a - k*\<^sub>R b \ span (S - {b})" by auto {assume k0: "k = 0" with k have "a \ span S" apply (simp) @@ -2046,12 +2055,12 @@ with na have ?thesis by blast} moreover {assume k0: "k \ 0" - have eq: "b = (1/k) *s a - ((1/k) *s a - b)" by vector - from k0 have eq': "(1/k) *s (a - k*s b) = (1/k) *s a - b" - by (vector field_simps) - from k have "(1/k) *s (a - k*s b) \ span (S - {b})" + have eq: "b = (1/k) *\<^sub>R a - ((1/k) *\<^sub>R a - b)" by vector + from k0 have eq': "(1/k) *\<^sub>R (a - k*\<^sub>R b) = (1/k) *\<^sub>R a - b" + by (simp add: algebra_simps) + from k have "(1/k) *\<^sub>R (a - k*\<^sub>R b) \ span (S - {b})" by (rule span_mul) - hence th: "(1/k) *s a - b \ span (S - {b})" + hence th: "(1/k) *\<^sub>R a - b \ span (S - {b})" unfolding eq' . from k @@ -2069,7 +2078,7 @@ qed lemma in_span_delete: - assumes a: "(a::'a::field^_) \ span S" + assumes a: "a \ span S" and na: "a \ span (S-{b})" shows "b \ span (insert a (S - {b}))" apply (rule in_span_insert) @@ -2083,12 +2092,12 @@ (* Transitivity property. *) lemma span_trans: - assumes x: "(x::'a::ring_1^_) \ span S" and y: "y \ span (insert x S)" + assumes x: "x \ span S" and y: "y \ span (insert x S)" shows "y \ span S" proof- from span_breakdown[of x "insert x S" y, OF insertI1 y] - obtain k where k: "y -k*s x \ span (S - {x})" by auto - have eq: "y = (y - k *s x) + k *s x" by vector + obtain k where k: "y -k*\<^sub>R x \ span (S - {x})" by auto + have eq: "y = (y - k *\<^sub>R x) + k *\<^sub>R x" by vector show ?thesis apply (subst eq) apply (rule span_add) @@ -2105,11 +2114,11 @@ (* ------------------------------------------------------------------------- *) lemma span_explicit: - "span P = {y::'a::semiring_1^_. \S u. finite S \ S \ P \ setsum (\v. u v *s v) S = y}" + "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- {fix x assume x: "x \ ?E" - then obtain S u where fS: "finite S" and SP: "S\P" and u: "setsum (\v. u v *s v) S = x" + 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 have "x \ span P" unfolding u[symmetric] @@ -2126,7 +2135,7 @@ fix c x y assume x: "x \ P" and hy: "?h y" from hy obtain S u where fS: "finite S" and SP: "S\P" - and u: "setsum (\v. u v *s v) S = y" by blast + and u: "setsum (\v. u v *\<^sub>R v) S = y" by blast let ?S = "insert x S" let ?u = "\y. if y = x then (if x \ S then u y + c else c) else u y" @@ -2134,28 +2143,28 @@ {assume xS: "x \ S" have S1: "S = (S - {x}) \ {x}" and Sss:"finite (S - {x})" "finite {x}" "(S -{x}) \ {x} = {}" using xS fS by auto - have "setsum (\v. ?u v *s v) ?S =(\v\S - {x}. u v *s v) + (u x + c) *s x" + have "setsum (\v. ?u v *\<^sub>R v) ?S =(\v\S - {x}. u v *\<^sub>R v) + (u x + c) *\<^sub>R x" using xS by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]] setsum_clauses(2)[OF fS] cong del: if_weak_cong) - also have "\ = (\v\S. u v *s v) + c *s x" + also have "\ = (\v\S. u v *\<^sub>R v) + c *\<^sub>R x" apply (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]) - by (vector field_simps) - also have "\ = c*s x + y" + by (simp add: algebra_simps) + also have "\ = c*\<^sub>R x + y" by (simp add: add_commute u) - finally have "setsum (\v. ?u v *s v) ?S = c*s x + y" . - then have "?Q ?S ?u (c*s x + y)" using th0 by blast} + finally have "setsum (\v. ?u v *\<^sub>R v) ?S = c*\<^sub>R x + y" . + then have "?Q ?S ?u (c*\<^sub>R x + y)" using th0 by blast} moreover {assume xS: "x \ S" - have th00: "(\v\S. (if v = x then c else u v) *s v) = y" + have th00: "(\v\S. (if v = x then c else u v) *\<^sub>R v) = y" unfolding u[symmetric] apply (rule setsum_cong2) using xS by auto - have "?Q ?S ?u (c*s x + y)" using fS xS th0 + have "?Q ?S ?u (c*\<^sub>R x + y)" using fS xS th0 by (simp add: th00 setsum_clauses add_commute cong del: if_weak_cong)} - ultimately have "?Q ?S ?u (c*s x + y)" + ultimately have "?Q ?S ?u (c*\<^sub>R x + y)" by (cases "x \ S", simp, simp) - then show "?h (c*s x + y)" + then show "?h (c*\<^sub>R x + y)" apply - apply (rule exI[where x="?S"]) apply (rule exI[where x="?u"]) by metis @@ -2164,18 +2173,18 @@ qed lemma dependent_explicit: - "dependent P \ (\S u. finite S \ S \ P \ (\(v::'a::{idom,field}^_) \S. u v \ 0 \ setsum (\v. u v *s v) S = 0))" (is "?lhs = ?rhs") + "dependent P \ (\S u. finite S \ S \ P \ (\v\S. u v \ 0 \ setsum (\v. u v *\<^sub>R v) S = 0))" (is "?lhs = ?rhs") proof- {assume dP: "dependent P" then obtain a S u where aP: "a \ P" and fS: "finite S" - and SP: "S \ P - {a}" and ua: "setsum (\v. u v *s v) S = a" + and SP: "S \ P - {a}" and ua: "setsum (\v. u v *\<^sub>R v) S = a" unfolding dependent_def span_explicit by blast let ?S = "insert a S" let ?u = "\y. if y = a then - 1 else u y" let ?v = a from aP SP have aS: "a \ S" by blast from fS SP aP have th0: "finite ?S" "?S \ P" "?v \ ?S" "?u ?v \ 0" by auto - have s0: "setsum (\v. ?u v *s v) ?S = 0" + have s0: "setsum (\v. ?u v *\<^sub>R v) ?S = 0" using fS aS apply (simp add: vector_smult_lneg setsum_clauses field_simps) apply (subst (2) ua[symmetric]) @@ -2189,47 +2198,47 @@ moreover {fix S u v assume fS: "finite S" and SP: "S \ P" and vS: "v \ S" and uv: "u v \ 0" - and u: "setsum (\v. u v *s v) S = 0" + and u: "setsum (\v. u v *\<^sub>R v) S = 0" let ?a = v let ?S = "S - {v}" let ?u = "\i. (- u i) / u v" have th0: "?a \ P" "finite ?S" "?S \ P" using fS SP vS by auto - have "setsum (\v. ?u v *s v) ?S = setsum (\v. (- (inverse (u ?a))) *s (u v *s v)) S - ?u v *s v" + have "setsum (\v. ?u v *\<^sub>R v) ?S = setsum (\v. (- (inverse (u ?a))) *\<^sub>R (u v *\<^sub>R v)) S - ?u v *\<^sub>R v" using fS vS uv by (simp add: setsum_diff1 vector_smult_lneg divide_inverse vector_smult_assoc field_simps) also have "\ = ?a" - unfolding setsum_cmul u - using uv by (simp add: vector_smult_lneg) - finally have "setsum (\v. ?u v *s v) ?S = ?a" . + unfolding scaleR_right.setsum [symmetric] u + using uv by simp + finally have "setsum (\v. ?u v *\<^sub>R v) ?S = ?a" . with th0 have ?lhs unfolding dependent_def span_explicit apply - apply (rule bexI[where x= "?a"]) - apply simp_all + apply (simp_all del: scaleR_minus_left) apply (rule exI[where x= "?S"]) - by auto} + by (auto simp del: scaleR_minus_left)} ultimately show ?thesis by blast qed lemma span_finite: assumes fS: "finite S" - shows "span S = {(y::'a::semiring_1^_). \u. setsum (\v. u v *s v) S = y}" + 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 *s v) S' = y" unfolding span_explicit by blast + 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" - from setsum_restrict_set[OF fS, of "\v. u v *s v" S', symmetric] SS' - have "setsum (\v. ?u v *s v) S = setsum (\v. u v *s v) S'" + from setsum_restrict_set[OF fS, of "\v. u v *\<^sub>R v" S', symmetric] SS' + have "setsum (\v. ?u v *\<^sub>R v) S = setsum (\v. u v *\<^sub>R v) S'" unfolding cond_value_iff cond_application_beta by (simp add: cond_value_iff inf_absorb2 cong del: if_weak_cong) - hence "setsum (\v. ?u v *s v) S = y" by (metis u) + hence "setsum (\v. ?u v *\<^sub>R v) S = y" by (metis u) hence "y \ ?rhs" by auto} moreover - {fix y u assume u: "setsum (\v. u v *s v) S = y" + {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 @@ -2237,10 +2246,10 @@ (* Standard bases are a spanning set, and obviously finite. *) -lemma span_stdbasis:"span {basis i :: 'a::ring_1^'n | i. i \ (UNIV :: 'n set)} = UNIV" +lemma span_stdbasis:"span {basis i :: real^'n | i. i \ (UNIV :: 'n set)} = UNIV" apply (rule set_ext) apply auto -apply (subst basis_expansion[symmetric]) +apply (subst basis_expansion'[symmetric]) apply (rule span_setsum) apply simp apply auto @@ -2263,14 +2272,14 @@ lemma independent_stdbasis_lemma: - assumes x: "(x::'a::semiring_1 ^ _) \ span (basis ` S)" + assumes x: "(x::real ^ 'n) \ span (basis ` S)" and iS: "i \ S" shows "(x$i) = 0" proof- let ?U = "UNIV :: 'n set" let ?B = "basis ` S" - let ?P = "\(x::'a^_). \i\ ?U. i \ S \ x$i =0" - {fix x::"'a^_" assume xS: "x\ ?B" + let ?P = "\(x::real^_). \i\ ?U. i \ S \ x$i =0" + {fix x::"real^_" assume xS: "x\ ?B" from xS have "?P x" by auto} moreover have "subspace ?P" @@ -2303,7 +2312,7 @@ (* This is useful for building a basis step-by-step. *) lemma independent_insert: - "independent(insert (a::'a::field ^_) S) \ + "independent(insert a S) \ (if a \ S then independent S else independent S \ a \ span S)" (is "?lhs \ ?rhs") proof- @@ -2352,7 +2361,7 @@ by (metis subset_eq span_superset) lemma spanning_subset_independent: - assumes BA: "B \ A" and iA: "independent (A::('a::field ^_) set)" + assumes BA: "B \ A" and iA: "independent A" and AsB: "A \ span B" shows "A = B" proof @@ -2379,7 +2388,7 @@ (* The general case of the Exchange Lemma, the key to what follows. *) lemma exchange_lemma: - assumes f:"finite (t:: ('a::field^'n) set)" and i: "independent s" + 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 @@ -2455,7 +2464,7 @@ (* This implies corresponding size bounds. *) lemma independent_span_bound: - assumes f: "finite t" and i: "independent (s::('a::field^_) set)" and sp:"s \ span t" + assumes f: "finite t" and i: "independent s" and sp:"s \ span t" shows "finite s \ card s \ card t" by (metis exchange_lemma[OF f i sp] finite_subset card_mono) @@ -2638,7 +2647,7 @@ by (metis dim_span) lemma spans_image: - assumes lf: "linear (f::'a::semiring_1^_ \ _)" 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) @@ -2660,7 +2669,7 @@ (* Relation between bases and injectivity/surjectivity of map. *) lemma spanning_surjective_image: - assumes us: "UNIV \ span (S:: ('a::semiring_1 ^_) set)" + assumes us: "UNIV \ span S" and lf: "linear f" and sf: "surj f" shows "UNIV \ span (f ` S)" proof- @@ -2670,7 +2679,7 @@ qed lemma independent_injective_image: - assumes iS: "independent (S::('a::semiring_1^_) set)" 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})" @@ -2705,14 +2714,14 @@ from `\C. finite C \ card C \ card B \ span C = span B \ pairwise orthogonal C` obtain C where C: "finite C" "card C \ card B" "span C = span B" "pairwise orthogonal C" by blast - let ?a = "a - setsum (\x. (x \ a / (x \ x)) *s x) C" + let ?a = "a - setsum (\x. (x \ a / (x \ x)) *\<^sub>R x) C" let ?C = "insert ?a C" from C(1) have fC: "finite ?C" by simp from fB aB C(1,2) have cC: "card ?C \ card (insert a B)" by (simp add: card_insert_if) {fix x k have th0: "\(a::'b::comm_ring) b c. a - (b - c) = c + (a - b)" by (simp add: field_simps) - have "x - k *s (a - (\x\C. (x \ a / (x \ x)) *s x)) \ span C \ x - k *s a \ span C" - apply (simp only: vector_ssub_ldistrib th0) + have "x - k *\<^sub>R (a - (\x\C. (x \ a / (x \ x)) *\<^sub>R x)) \ span C \ x - k *\<^sub>R a \ span C" + apply (simp only: scaleR_right_diff_distrib th0) apply (rule span_add_eq) apply (rule span_mul) apply (rule span_setsum[OF C(1)]) @@ -2806,8 +2815,8 @@ from B have fB: "finite B" "card B = dim S" using independent_bound by auto from span_mono[OF B(2)] span_mono[OF B(3)] have sSB: "span S = span B" by (simp add: span_span) - let ?a = "a - setsum (\b. (a \ b / (b \ b)) *s b) B" - have "setsum (\b. (a \ b / (b \ b)) *s b) B \ span S" + let ?a = "a - setsum (\b. (a \ b / (b \ b)) *\<^sub>R b) B" + have "setsum (\b. (a \ b / (b \ b)) *\<^sub>R b) B \ span S" unfolding sSB apply (rule span_setsum[OF fB(1)]) apply clarsimp @@ -2858,7 +2867,7 @@ 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 fx: "f (x::'a::field^_) = 0" + and fx: "f x = 0" shows "x = 0" using fB ifB fi xsB fx proof(induct arbitrary: x rule: finite_induct[OF fB]) @@ -2874,14 +2883,14 @@ apply (rule subset_inj_on [OF "2.prems"(3)]) by blast from span_breakdown[of a "insert a b", simplified, OF "2.prems"(4)] - obtain k where k: "x - k*s a \ span (b -{a})" by blast - have "f (x - k*s a) \ span (f ` b)" + obtain k where k: "x - k*\<^sub>R a \ span (b -{a})" by blast + have "f (x - k*\<^sub>R a) \ span (f ` b)" unfolding span_linear_image[OF lf] apply (rule imageI) using k span_mono[of "b-{a}" b] by blast - hence "f x - k*s f a \ span (f ` b)" + hence "f x - k*\<^sub>R f a \ span (f ` b)" by (simp add: linear_sub[OF lf] linear_cmul[OF lf]) - hence th: "-k *s f a \ span (f ` b)" + hence th: "-k *\<^sub>R f a \ span (f ` b)" using "2.prems"(5) by (simp add: vector_smult_lneg) {assume k0: "k = 0" from k0 k have "x \ span (b -{a})" by simp @@ -2908,9 +2917,10 @@ (* We can extend a linear mapping from basis. *) lemma linear_independent_extend_lemma: + fixes f :: "'a::real_vector \ 'b::real_vector" assumes fi: "finite B" and ib: "independent B" - shows "\g. (\x\ span B. \y\ span B. g ((x::'a::field^'n) + y) = g x + g y) - \ (\x\ span B. \c. g (c*s x) = c *s g x) + 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 proof(induct rule: finite_induct[OF fi]) @@ -2921,30 +2931,30 @@ by (simp_all add: independent_insert) from "2.hyps"(3)[OF ibf] obtain g where g: "\x\span b. \y\span b. g (x + y) = g x + g y" - "\x\span b. \c. g (c *s x) = c *s g x" "\x\b. g x = f x" by blast - let ?h = "\z. SOME k. (z - k *s a) \ span b" + "\x\span b. \c. g (c *\<^sub>R x) = c *\<^sub>R g x" "\x\b. g x = f x" by blast + let ?h = "\z. SOME k. (z - k *\<^sub>R a) \ span b" {fix z assume z: "z \ span (insert a b)" - have th0: "z - ?h z *s a \ span b" + have th0: "z - ?h z *\<^sub>R a \ span b" apply (rule someI_ex) unfolding span_breakdown_eq[symmetric] using z . - {fix k assume k: "z - k *s a \ span b" - have eq: "z - ?h z *s a - (z - k*s a) = (k - ?h z) *s a" - by (simp add: field_simps vector_sadd_rdistrib[symmetric]) + {fix k assume k: "z - k *\<^sub>R a \ span b" + have eq: "z - ?h z *\<^sub>R a - (z - k*\<^sub>R a) = (k - ?h z) *\<^sub>R a" + by (simp add: field_simps scaleR_left_distrib [symmetric]) from span_sub[OF th0 k] - have khz: "(k - ?h z) *s a \ span b" by (simp add: eq) + have khz: "(k - ?h z) *\<^sub>R a \ span b" by (simp add: eq) {assume "k \ ?h z" hence k0: "k - ?h z \ 0" by simp from k0 span_mul[OF khz, of "1 /(k - ?h z)"] have "a \ span b" by (simp add: vector_smult_assoc) with "2.prems"(1) "2.hyps"(2) have False by (auto simp add: dependent_def)} then have "k = ?h z" by blast} - with th0 have "z - ?h z *s a \ span b \ (\k. z - k *s a \ span b \ k = ?h z)" by blast} + with th0 have "z - ?h z *\<^sub>R a \ span b \ (\k. z - k *\<^sub>R a \ span b \ k = ?h z)" by blast} note h = this - let ?g = "\z. ?h z *s f a + g (z - ?h z *s a)" + let ?g = "\z. ?h z *\<^sub>R f a + g (z - ?h z *\<^sub>R a)" {fix x y assume x: "x \ span (insert a b)" and y: "y \ span (insert a b)" - have tha: "\(x::'a^'n) y a k l. (x + y) - (k + l) *s a = (x - k *s a) + (y - l *s a)" - by (vector field_simps) + have tha: "\(x::'a) y a k l. (x + y) - (k + l) *\<^sub>R a = (x - k *\<^sub>R a) + (y - l *\<^sub>R a)" + by (simp add: algebra_simps) have addh: "?h (x + y) = ?h x + ?h y" apply (rule conjunct2[OF h, rule_format, symmetric]) apply (rule span_add[OF x y]) @@ -2953,18 +2963,18 @@ have "?g (x + y) = ?g x + ?g y" unfolding addh tha g(1)[rule_format,OF conjunct1[OF h, OF x] conjunct1[OF h, OF y]] - by (simp add: vector_sadd_rdistrib)} + by (simp add: scaleR_left_distrib)} moreover - {fix x:: "'a^'n" and c:: 'a assume x: "x \ span (insert a b)" - have tha: "\(x::'a^'n) c k a. c *s x - (c * k) *s a = c *s (x - k *s a)" - by (vector field_simps) - have hc: "?h (c *s x) = c * ?h x" + {fix x:: "'a" and c:: real assume x: "x \ span (insert a b)" + have tha: "\(x::'a) c k a. c *\<^sub>R x - (c * k) *\<^sub>R a = c *\<^sub>R (x - k *\<^sub>R a)" + by (simp add: algebra_simps) + have hc: "?h (c *\<^sub>R x) = c * ?h x" apply (rule conjunct2[OF h, rule_format, symmetric]) apply (metis span_mul x) by (metis tha span_mul x conjunct1[OF h]) - have "?g (c *s x) = c*s ?g x" + have "?g (c *\<^sub>R x) = c*\<^sub>R ?g x" unfolding hc tha g(2)[rule_format, OF conjunct1[OF h, OF x]] - by (vector field_simps)} + by (simp add: algebra_simps)} moreover {fix x assume x: "x \ (insert a b)" {assume xa: "x = a" @@ -3001,7 +3011,7 @@ from C(2) independent_bound[of C] linear_independent_extend_lemma[of C f] obtain g where g: "(\x\ span C. \y\ span C. g (x + y) = g x + g y) - \ (\x\ span C. \c. g (c*s x) = c *s g x) + \ (\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 by blast @@ -3088,14 +3098,14 @@ (* linear functions are equal on a subspace if they are on a spanning set. *) lemma subspace_kernel: - assumes lf: "linear (f::'a::semiring_1 ^_ \ _)" + assumes lf: "linear f" shows "subspace {x. f x = 0}" apply (simp add: subspace_def) by (simp add: linear_add[OF lf] linear_cmul[OF lf] linear_0[OF lf]) lemma linear_eq_0_span: assumes lf: "linear f" and f0: "\x\B. f x = 0" - shows "\x \ span B. f x = (0::'a::semiring_1 ^_)" + shows "\x \ span B. f x = 0" proof fix x assume x: "x \ span B" let ?P = "\x. f x = 0" @@ -3105,11 +3115,11 @@ lemma linear_eq_0: assumes lf: "linear f" and SB: "S \ span B" and f0: "\x\B. f x = 0" - shows "\x \ S. f x = (0::'a::semiring_1^_)" + 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::'a::ring_1^_ \ _)" 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- @@ -3120,15 +3130,15 @@ qed lemma linear_eq_stdbasis: - assumes lf: "linear (f::'a::ring_1^'m \ 'a^'n)" and lg: "linear g" + assumes lf: "linear (f::real^'m \ _)" and lg: "linear g" and fg: "\i. f (basis i) = g(basis i)" shows "f = g" proof- let ?U = "UNIV :: 'm set" - let ?I = "{basis i:: 'a^'m|i. i \ ?U}" - {fix x assume x: "x \ (UNIV :: ('a^'m) set)" + let ?I = "{basis i:: real^'m|i. i \ ?U}" + {fix x assume x: "x \ (UNIV :: (real^'m) set)" from equalityD2[OF span_stdbasis] - have IU: " (UNIV :: ('a^'m) set) \ span ?I" by blast + have IU: " (UNIV :: (real^'m) set) \ span ?I" by blast from linear_eq[OF lf lg IU] fg x have "f x = g x" unfolding Collect_def Ball_def mem_def by metis} then show ?thesis by (auto intro: ext) @@ -3137,7 +3147,7 @@ (* Similar results for bilinear functions. *) lemma bilinear_eq: - assumes bf: "bilinear (f:: 'a::ring^_ \ 'a^_ \ 'a^_)" + assumes bf: "bilinear f" and bg: "bilinear g" and SB: "S \ span B" and TC: "T \ span C" and fg: "\x\ B. \y\ C. f x y = g x y" @@ -3165,7 +3175,7 @@ qed lemma bilinear_eq_stdbasis: - assumes bf: "bilinear (f:: 'a::ring_1^'m \ 'a^'n \ 'a^_)" + assumes bf: "bilinear (f:: real^'m \ real^'n \ _)" and bg: "bilinear g" and fg: "\i j. f (basis i) (basis j) = g (basis i) (basis j)" shows "f = g" @@ -3318,6 +3328,7 @@ unfolding y[symmetric] apply (rule span_setsum[OF fU]) apply clarify + unfolding smult_conv_scaleR apply (rule span_mul) apply (rule span_superset) unfolding columns_def @@ -3327,7 +3338,7 @@ {assume h:?rhs let ?P = "\(y::real ^'n). \(x::real^'m). setsum (\i. (x$i) *s column i A) ?U = y" {fix y have "?P y" - proof(rule span_induct_alt[of ?P "columns A"]) + proof(rule span_induct_alt[of ?P "columns A", folded smult_conv_scaleR]) show "\x\real ^ 'm. setsum (\i. (x$i) *s column i A) ?U = 0" by (rule exI[where x=0], simp) next @@ -3770,7 +3781,7 @@ (* Equality in Cauchy-Schwarz and triangle inequalities. *) -lemma norm_cauchy_schwarz_eq: "(x::real ^'n) \ y = norm x * norm y \ norm x *s y = norm y *s x" (is "?lhs \ ?rhs") +lemma norm_cauchy_schwarz_eq: "x \ y = norm x * norm y \ norm x *\<^sub>R y = norm y *\<^sub>R x" (is "?lhs \ ?rhs") proof- {assume h: "x = 0" hence ?thesis by simp} @@ -3779,7 +3790,7 @@ hence ?thesis by simp} moreover {assume x: "x \ 0" and y: "y \ 0" - from inner_eq_zero_iff[of "norm y *s x - norm x *s y"] + from inner_eq_zero_iff[of "norm y *\<^sub>R x - norm x *\<^sub>R y"] have "?rhs \ (norm y * (norm y * norm x * norm x - norm x * (x \ y)) - norm x * (norm y * (y \ x) - norm x * norm y * norm y) = 0)" using x y unfolding inner_simps smult_conv_scaleR @@ -3795,26 +3806,24 @@ qed lemma norm_cauchy_schwarz_abs_eq: - fixes x y :: "real ^ 'n" shows "abs(x \ y) = norm x * norm y \ - norm x *s y = norm y *s x \ norm(x) *s y = - norm y *s x" (is "?lhs \ ?rhs") + 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" by arith - have "?rhs \ norm x *s y = norm y *s x \ norm (- x) *s y = norm y *s (- x)" - apply simp by vector + have "?rhs \ norm x *\<^sub>R y = norm y *\<^sub>R x \ norm (- x) *\<^sub>R y = norm y *\<^sub>R (- x)" + by simp also have "\ \(x \ y = norm x * norm y \ (-x) \ y = norm x * norm y)" unfolding norm_cauchy_schwarz_eq[symmetric] - unfolding norm_minus_cancel - norm_mul by blast + unfolding norm_minus_cancel norm_scaleR .. also have "\ \ ?lhs" unfolding th[OF mult_nonneg_nonneg, OF norm_ge_zero[of x] norm_ge_zero[of y]] inner_simps by auto finally show ?thesis .. qed lemma norm_triangle_eq: - fixes x y :: "real ^ 'n" - shows "norm(x + y) = norm x + norm y \ norm x *s y = norm y *s x" + fixes x y :: "'a::real_inner" + shows "norm(x + y) = norm x + norm y \ norm x *\<^sub>R y = norm y *\<^sub>R x" proof- {assume x: "x =0 \ y =0" hence ?thesis by (cases "x=0", simp_all)} @@ -3829,7 +3838,7 @@ have "norm(x + y) = norm x + norm y \ norm(x + y)^ 2 = (norm x + norm y) ^2" apply (rule th) using n norm_ge_zero[of "x + y"] by arith - also have "\ \ norm x *s y = norm y *s x" + also have "\ \ norm x *\<^sub>R y = norm y *\<^sub>R x" unfolding norm_cauchy_schwarz_eq[symmetric] unfolding power2_norm_eq_inner inner_simps by (simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute field_simps) @@ -3839,62 +3848,59 @@ (* Collinearity.*) -definition "collinear S \ (\u. \x \ S. \ y \ S. \c. x - y = c *s u)" +definition + collinear :: "'a::real_vector set \ bool" where + "collinear S \ (\u. \x \ S. \ y \ S. \c. x - y = c *\<^sub>R u)" lemma collinear_empty: "collinear {}" by (simp add: collinear_def) -lemma collinear_sing: "collinear {(x::'a::ring_1^_)}" - apply (simp add: collinear_def) - apply (rule exI[where x=0]) - by simp - -lemma collinear_2: "collinear {(x::'a::ring_1^_),y}" +lemma collinear_sing: "collinear {x}" + by (simp add: collinear_def) + +lemma collinear_2: "collinear {x, y}" apply (simp add: collinear_def) apply (rule exI[where x="x - y"]) apply auto - apply (rule exI[where x=0], simp) apply (rule exI[where x=1], simp) - apply (rule exI[where x="- 1"], simp add: vector_sneg_minus1[symmetric]) - apply (rule exI[where x=0], simp) + apply (rule exI[where x="- 1"], simp) done -lemma collinear_lemma: "collinear {(0::real^_),x,y} \ x = 0 \ y = 0 \ (\c. y = c *s x)" (is "?lhs \ ?rhs") +lemma collinear_lemma: "collinear {0,x,y} \ x = 0 \ y = 0 \ (\c. y = c *\<^sub>R x)" (is "?lhs \ ?rhs") proof- {assume "x=0 \ y = 0" hence ?thesis by (cases "x = 0", simp_all add: collinear_2 insert_commute)} moreover {assume x: "x \ 0" and y: "y \ 0" {assume h: "?lhs" - then obtain u where u: "\ x\ {0,x,y}. \y\ {0,x,y}. \c. x - y = c *s u" unfolding collinear_def by blast + then obtain u where u: "\ x\ {0,x,y}. \y\ {0,x,y}. \c. x - y = c *\<^sub>R u" unfolding collinear_def by blast from u[rule_format, of x 0] u[rule_format, of y 0] obtain cx and cy where - cx: "x = cx*s u" and cy: "y = cy*s u" + cx: "x = cx *\<^sub>R u" and cy: "y = cy *\<^sub>R u" by auto from cx x have cx0: "cx \ 0" by auto from cy y have cy0: "cy \ 0" by auto let ?d = "cy / cx" - from cx cy cx0 have "y = ?d *s x" + from cx cy cx0 have "y = ?d *\<^sub>R x" by (simp add: vector_smult_assoc) hence ?rhs using x y by blast} moreover {assume h: "?rhs" - then obtain c where c: "y = c*s x" using x y by blast + then obtain c where c: "y = c *\<^sub>R x" using x y by blast have ?lhs unfolding collinear_def c apply (rule exI[where x=x]) apply auto - apply (rule exI[where x="- 1"], simp only: vector_smult_lneg vector_smult_lid) - apply (rule exI[where x= "-c"], simp only: vector_smult_lneg) + apply (rule exI[where x="- 1"], simp) + apply (rule exI[where x= "-c"], simp) apply (rule exI[where x=1], simp) - apply (rule exI[where x="1 - c"], simp add: vector_smult_lneg vector_sub_rdistrib) - apply (rule exI[where x="c - 1"], simp add: vector_smult_lneg vector_sub_rdistrib) + apply (rule exI[where x="1 - c"], simp add: scaleR_left_diff_distrib) + apply (rule exI[where x="c - 1"], simp add: scaleR_left_diff_distrib) done} ultimately have ?thesis by blast} ultimately show ?thesis by blast qed lemma norm_cauchy_schwarz_equal: - fixes x y :: "real ^ 'n" - shows "abs(x \ y) = norm x * norm y \ collinear {(0::real^'n),x,y}" + shows "abs(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) @@ -3903,20 +3909,20 @@ apply (subgoal_tac "norm x \ 0") apply (subgoal_tac "norm y \ 0") apply (rule iffI) -apply (cases "norm x *s y = norm y *s x") +apply (cases "norm x *\<^sub>R y = norm y *\<^sub>R x") apply (rule exI[where x="(1/norm x) * norm y"]) apply (drule sym) -unfolding vector_smult_assoc[symmetric] +unfolding scaleR_scaleR[symmetric] apply (simp add: vector_smult_assoc field_simps) apply (rule exI[where x="(1/norm x) * - norm y"]) apply clarify apply (drule sym) -unfolding vector_smult_assoc[symmetric] +unfolding scaleR_scaleR[symmetric] apply (simp add: vector_smult_assoc field_simps) apply (erule exE) apply (erule ssubst) -unfolding vector_smult_assoc -unfolding norm_mul +unfolding scaleR_scaleR +unfolding norm_scaleR apply (subgoal_tac "norm x * c = \c\ * norm x \ norm x * c = - \c\ * norm x") apply (case_tac "c <= 0", simp add: field_simps) apply (simp add: field_simps) diff -r eacded3b05f7 -r fb69c8cd27bd src/HOL/Multivariate_Analysis/Fashoda.thy --- a/src/HOL/Multivariate_Analysis/Fashoda.thy Thu Apr 29 09:29:47 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Fashoda.thy Thu Apr 29 11:41:04 2010 -0700 @@ -47,7 +47,7 @@ apply(rule continuous_on_mul ) apply(rule continuous_at_imp_continuous_on,rule) apply(rule continuous_at_inv[unfolded o_def]) apply(rule continuous_at_infnorm) unfolding infnorm_eq_0 defer apply(rule continuous_on_id) apply(rule linear_continuous_on) proof- show "bounded_linear negatex" apply(rule bounded_linearI') unfolding Cart_eq proof(rule_tac[!] allI) fix i::2 and x y::"real^2" and c::real - show "negatex (x + y) $ i = (negatex x + negatex y) $ i" "negatex (c *s x) $ i = (c *s negatex x) $ i" + show "negatex (x + y) $ i = (negatex x + negatex y) $ i" "negatex (c *\<^sub>R x) $ i = (c *\<^sub>R negatex x) $ i" apply-apply(case_tac[!] "i\1") prefer 3 apply(drule_tac[1-2] 21) unfolding negatex_def by(auto simp add:vector_2 ) qed qed(insert x0, auto) have 3:"(negatex \ sqprojection \ ?F) ` {- 1..1} \ {- 1..1}" unfolding subset_eq apply rule proof- diff -r eacded3b05f7 -r fb69c8cd27bd src/HOL/Multivariate_Analysis/Operator_Norm.thy --- a/src/HOL/Multivariate_Analysis/Operator_Norm.thy Thu Apr 29 09:29:47 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Operator_Norm.thy Thu Apr 29 11:41:04 2010 -0700 @@ -32,8 +32,8 @@ {assume x0: "x \ 0" hence n0: "norm x \ 0" by (metis norm_eq_zero) let ?c = "1/ norm x" - have "norm (?c*s x) = 1" using x0 by (simp add: n0) - with H have "norm (f(?c*s x)) \ b" by blast + have "norm (?c *\<^sub>R x) = 1" using x0 by (simp add: n0) + with H have "norm (f (?c *\<^sub>R x)) \ b" by blast hence "?c * norm (f x) \ b" by (simp add: linear_cmul[OF lf]) hence "norm (f x) \ b * norm x" diff -r eacded3b05f7 -r fb69c8cd27bd src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Thu Apr 29 09:29:47 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Thu Apr 29 11:41:04 2010 -0700 @@ -5515,7 +5515,7 @@ moreover have "basis k \ span (?bas ` (insert k F))" by(rule span_superset, auto) hence "x$k *\<^sub>R basis k \ span (?bas ` (insert k F))" - using span_mul [where 'a=real, unfolded smult_conv_scaleR] by auto + using span_mul by auto ultimately have "y + x$k *\<^sub>R basis k \ span (?bas ` (insert k F))" using span_add by auto diff -r eacded3b05f7 -r fb69c8cd27bd src/HOL/Multivariate_Analysis/Vec1.thy --- a/src/HOL/Multivariate_Analysis/Vec1.thy Thu Apr 29 09:29:47 2010 -0700 +++ b/src/HOL/Multivariate_Analysis/Vec1.thy Thu Apr 29 11:41:04 2010 -0700 @@ -205,14 +205,15 @@ apply(rule conjI) defer apply(rule conjI) defer apply(rule_tac x=1 in exI) by auto lemma linear_vmul_dest_vec1: - fixes f:: "'a::semiring_1^_ \ 'a^1" + fixes f:: "real^_ \ real^1" shows "linear f \ linear (\x. dest_vec1(f x) *s v)" - apply (rule linear_vmul_component) - by auto + unfolding smult_conv_scaleR + by (rule linear_vmul_component) lemma linear_from_scalars: - assumes lf: "linear (f::'a::comm_ring_1 ^1 \ 'a^_)" + assumes lf: "linear (f::real^1 \ real^_)" shows "f = (\x. dest_vec1 x *s column 1 (matrix f))" + unfolding smult_conv_scaleR apply (rule ext) apply (subst matrix_works[OF lf, symmetric]) apply (auto simp add: Cart_eq matrix_vector_mult_def column_def mult_commute)