# HG changeset patch # User huffman # Date 1312961371 25200 # Node ID 286bd57858b9f40c45ee0feaa66a6c021b28ed48 # Parent e6c6ca74d81beb38d2259323d2d51ea78a259210 simplified definition of class euclidean_space; removed classes real_basis and real_basis_with_inner diff -r e6c6ca74d81b -r 286bd57858b9 src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy Tue Aug 09 13:09:35 2011 -0700 +++ b/src/HOL/Multivariate_Analysis/Cartesian_Euclidean_Space.thy Wed Aug 10 00:29:31 2011 -0700 @@ -355,9 +355,11 @@ lemma \_inj_on: "inj_on (\::nat\'n::finite) {.. j::'b. if j = \(i div DIM('a)) then basis (i mod DIM('a)) else 0) @@ -417,133 +419,84 @@ finally show ?thesis by simp qed -instance -proof - let ?b = "basis :: nat \ 'a^'b" - let ?b' = "basis :: nat \ 'a" +lemma DIM_cart[simp]: "DIM('a^'b) = CARD('b) * DIM('a)" + by (rule dimension_cart_def) - have setsum_basis: - "\f. (\x\range basis. f (x::'a)) = f 0 + (\ii (\x::'b. \i' x * DIM('a)))" +unfolding DIM_cart +apply safe +apply (drule spec, erule mp, erule linear_less_than_times [OF pi'_range]) +apply (erule split_CARD_DIM, simp) +done - have inj: "inj_on ?b {.. real" assume "j < DIM('a)" - let ?x = "j + \' i * DIM('a)" - show "(\k\{..R ?b k) \ ?b ?x" - unfolding Cart_eq not_all - proof - have "(\j. j + \' i*DIM('a))`({..' i*DIM('a)..' i) * DIM('a)} - {?x}"(is "?S = ?I - _") - proof safe - fix y assume "y \ ?I" - moreover def k \ "y - \' i*DIM('a)" - ultimately have "k < DIM('a)" and "y = k + \' i * DIM('a)" by auto - moreover assume "y \ ?S" - ultimately show "y = j + \' i * DIM('a)" by auto - qed auto +lemma eq_pi_iff: + fixes x :: "'c::finite" + shows "i < CARD('c::finite) \ x = \ i \ \' x = i" + by auto + +lemma all_less_mult: + fixes m n :: nat + shows "(\i<(m * n). P i) \ (\ijk\{..R ?b k) $ i = - (\k\{..R ?b k $ i)" by simp - also have "\ = (\k\?S. u(?b k) *\<^sub>R ?b k $ i)" - unfolding `?S = ?I - {?x}` - proof (safe intro!: setsum_mono_zero_cong_right) - fix y assume "y \ {\' i*DIM('a)..' i) * DIM('a)}" - moreover have "Suc (\' i) * DIM('a) \ CARD('b) * DIM('a)" - unfolding mult_le_cancel2 using pi'_range[of i] by simp - ultimately show "y < CARD('b) * DIM('a)" by simp - next - fix y assume "y < CARD('b) * DIM('a)" - with split_CARD_DIM guess l k . note y = this - moreover assume "u (?b y) *\<^sub>R ?b y $ i \ 0" - ultimately show "y \ {\' i*DIM('a)..' i) * DIM('a)}" - by (auto simp: basis_eq_pi' split: split_if_asm) - qed simp - also have "\ = (\k\{..' i*DIM('a))) *\<^sub>R (?b' k))" - by (subst setsum_reindex) (auto simp: basis_eq_pi' intro!: inj_onI) - also have "\ \ ?b ?x $ i" - proof - - note independent_eq_inj_on[THEN iffD1, OF basis_inj independent_basis, rule_format] - note this[of j "\v. u (\ ka::'b. if ka = i then v else (0\'a))"] - thus ?thesis by (simp add: `j < DIM('a)` basis_eq pi'_range) - qed - finally show "(\k\{..R ?b k) $ i \ ?b ?x $ i" . - qed - qed - ultimately - show "\d>0. ?b ` {d..} = {0} \ independent (?b ` {.. inj_on ?b {.. ?b ` {..i j. j < DIM('a) \ (THE k. (?if i j) $ k \ 0) = i" - by (rule the_equality) (simp_all split: split_if_asm add: basis_neq_0) - { fix x :: 'a - have "x \ span (range basis)" - using span_basis by (auto simp: range_basis) - hence "\u. (\xR ?b' x) = x" - by (subst (asm) span_finite) (auto simp: setsum_basis) } - hence "\i. \u. (\xR ?b' x) = i" by auto - then obtain u where u: "\i. (\xR ?b' x) = i" - by (auto dest: choice) - have "\u. \i. (\jR ?b' j) = x $ i" - apply (rule exI[of _ "\v. let i = (THE i. v$i \ 0) in u (x$i) (v$i)"]) - using The_if u by simp } - moreover - have "\i::'b. {.. {x. i = \ x} = {\' i}" - using pi'_range[where 'n='b] by auto - moreover - have "range ?b = {0} \ ?b ` {.. i" thus "basis i = (0::'a^'b)" + unfolding dimension_cart_def basis_cart_def + by simp +next + show "\ij basis j = (if i = j then 1 else 0)" + apply (simp add: inner_vector_def) + apply safe + apply (erule split_CARD_DIM, simp add: basis_eq_pi') + apply (simp add: inner_if setsum_delta cong: if_cong) + apply (simp add: basis_orthonormal) + apply (elim split_CARD_DIM, simp add: basis_eq_pi') + apply (simp add: inner_if setsum_delta cong: if_cong) + apply (clarsimp simp add: basis_orthonormal) + done +next + fix x :: "'a ^ 'b" + show "(\i x = 0" + unfolding all_less_DIM_cart + unfolding inner_vector_def + apply (simp add: basis_eq_pi') + apply (simp add: inner_if setsum_delta cong: if_cong) + apply (simp add: euclidean_all_zero) + apply (simp add: Cart_eq) + done qed end -lemma DIM_cart[simp]: "DIM('a^'b) = CARD('b) * DIM('a::real_basis)" -proof (safe intro!: dimension_eq elim!: split_times_into_modulo del: notI) - fix i j assume *: "i < CARD('b)" "j < DIM('a)" - hence A: "(i * DIM('a) + j) div DIM('a) = i" - by (subst div_add1_eq) simp - from * have B: "(i * DIM('a) + j) mod DIM('a) = j" - unfolding mod_mult_self3 by simp - show "basis (j + i * DIM('a)) \ (0::'a^'b)" unfolding basis_cart_def - using * basis_finite[where 'a='a] - linear_less_than_times[of i "CARD('b)" j "DIM('a)"] - by (auto simp: A B field_simps Cart_eq basis_eq_0_iff) -qed (auto simp: basis_cart_def) - lemma if_distr: "(if P then f else g) $ i = (if P then f $ i else g $ i)" by simp lemma split_dimensions'[consumes 1]: - assumes "k < DIM('a::real_basis^'b)" - obtains i j where "i < CARD('b::finite)" and "j < DIM('a::real_basis)" and "k = j + i * DIM('a::real_basis)" + assumes "k < DIM('a::euclidean_space^'b)" + obtains i j where "i < CARD('b::finite)" and "j < DIM('a::euclidean_space)" and "k = j + i * DIM('a::euclidean_space)" using split_times_into_modulo[OF assms[simplified]] . lemma cart_euclidean_bound[intro]: - assumes j:"j < DIM('a::{real_basis})" - shows "j + \' (i::'b::finite) * DIM('a) < CARD('b) * DIM('a::real_basis)" + assumes j:"j < DIM('a::euclidean_space)" + shows "j + \' (i::'b::finite) * DIM('a) < CARD('b) * DIM('a::euclidean_space)" using linear_less_than_times[OF pi'_range j, of i] . -instance cart :: (real_basis_with_inner,finite) real_basis_with_inner .. - -lemma (in real_basis) forall_CARD_DIM: +lemma (in euclidean_space) forall_CARD_DIM: "(\i (\(i::'b::finite) j. j P (j + \' i * DIM('a)))" (is "?l \ ?r") proof (safe elim!: split_times_into_modulo) @@ -557,7 +510,7 @@ show "P (j + i * DIM('a))" by simp qed -lemma (in real_basis) exists_CARD_DIM: +lemma (in euclidean_space) exists_CARD_DIM: "(\i (\i::'b::finite. \j' i * DIM('a)))" using forall_CARD_DIM[where 'b='b, of "\x. \ P x"] by blast @@ -572,7 +525,7 @@ lemmas cart_simps = forall_CARD_DIM exists_CARD_DIM forall_CARD exists_CARD lemma cart_euclidean_nth[simp]: - fixes x :: "('a::real_basis_with_inner, 'b::finite) cart" + fixes x :: "('a::euclidean_space, 'b::finite) cart" assumes j:"j < DIM('a)" shows "x $$ (j + \' i * DIM('a)) = x $ i $$ j" unfolding euclidean_component_def inner_vector_def basis_eq_pi'[OF j] if_distrib cond_application_beta @@ -606,22 +559,6 @@ thus "x = y \ i = j" using * by simp qed simp -instance cart :: (euclidean_space,finite) euclidean_space -proof (default, safe elim!: split_dimensions') - let ?b = "basis :: nat \ 'a^'b" - have if_distrib_op: "\f P Q a b c d. - f (if P then a else b) (if Q then c else d) = - (if P then if Q then f a c else f a d else if Q then f b c else f b d)" - by simp - - fix i j k l - assume "i < CARD('b)" "k < CARD('b)" "j < DIM('a)" "l < DIM('a)" - thus "?b (j + i * DIM('a)) \ ?b (l + k * DIM('a)) = - (if j + i * DIM('a) = l + k * DIM('a) then 1 else 0)" - using inj_on_iff[OF \_inj_on[where 'n='b], of k i] - by (auto simp add: basis_eq inner_vector_def if_distrib_op[of inner] setsum_cases basis_orthonormal mult_split_eq) -qed - instance cart :: (ordered_euclidean_space,finite) ordered_euclidean_space proof fix x y::"'a^'b" diff -r e6c6ca74d81b -r 286bd57858b9 src/HOL/Multivariate_Analysis/Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Tue Aug 09 13:09:35 2011 -0700 +++ b/src/HOL/Multivariate_Analysis/Euclidean_Space.thy Wed Aug 10 00:29:31 2011 -0700 @@ -1582,119 +1582,50 @@ subsection{* Euclidean Spaces as Typeclass*} -class real_basis = real_vector + +class euclidean_space = real_inner + + fixes dimension :: "'a itself \ nat" fixes basis :: "nat \ 'a" - assumes span_basis: "span (range basis) = UNIV" - assumes dimension_exists: "\d>0. - basis ` {d..} = {0} \ - independent (basis ` {.. - inj_on basis {.. nat" where - "dimension x = - (THE d. basis ` {d..} = {0} \ independent (basis ` {.. inj_on basis {.. i \ basis i = 0" + assumes basis_orthonormal: + "\iji (x = 0)" syntax "_type_dimension" :: "type => nat" ("(1DIM/(1'(_')))") translations "DIM('t)" == "CONST dimension (TYPE('t))" -lemma (in real_basis) dimensionI: - assumes "\d. \ 0 < d; basis ` {d..} = {0}; independent (basis ` {.. \ P d" - shows "P DIM('a)" -proof - - obtain d where "0 < d" and d: "basis ` {d..} = {0} \ - independent (basis ` {.. inj_on basis {.. basis d \ 0" - "d' < d \ basis d' \ 0" - using dependent_0 by auto - thus "d' = d" by (cases rule: linorder_cases) auto - moreover have "P d" using assms[of d] `0 < d` d by auto - ultimately show "P d'" by simp - next show "?P d" using `?P d` . - qed -qed - -lemma (in real_basis) dimension_eq: - assumes "\i. i < d \ basis i \ 0" - assumes "\i. d \ i \ basis i = 0" - shows "DIM('a) = d" -proof (rule dimensionI) - let ?b = "basis :: nat \ 'a" - fix d' assume *: "?b ` {d'..} = {0}" "independent (?b ` {.. 0" using assms by auto - with * show ?thesis by auto - next - assume "d < d'" hence "basis d \ 0" using * dependent_0 by auto - with assms(2) `d < d'` show ?thesis by auto - qed +lemma (in euclidean_space) dot_basis: + "inner (basis i) (basis j) = (if i = j \ i < DIM('a) then 1 else 0)" +proof (cases "(i < DIM('a) \ j < DIM('a))") + case False + hence "inner (basis i) (basis j) = 0" by auto + thus ?thesis using False by auto +next + case True thus ?thesis using basis_orthonormal by auto qed -lemma (in real_basis) - shows basis_finite: "basis ` {DIM('a)..} = {0}" - and independent_basis: "independent (basis ` {.. 0" - and basis_inj[simp, intro]: "inj_on basis {.. DIM('a) \ j" -proof - show "DIM('a) \ j \ basis j = 0" using basis_finite by auto -next - have "j < DIM('a) \ basis j \ 0" - using independent_basis by (auto intro!: dependent_0) - thus "basis j = 0 \ DIM('a) \ j" unfolding not_le[symmetric] by blast -qed - -lemma (in real_basis) range_basis: - "range basis = insert 0 (basis ` {.. DIM('a) \ i" proof - - have *: "UNIV = {.. {DIM('a)..}" by auto - show ?thesis unfolding * image_Un basis_finite by auto + have "inner (basis i) (basis i) = 0 \ DIM('a) \ i" + by (simp add: dot_basis) + thus ?thesis by simp qed -lemma (in real_basis) range_basis_finite[intro]: - "finite (range basis)" - unfolding range_basis by auto - -lemma (in real_basis) basis_neq_0[intro]: - assumes "i 0" -proof(rule ccontr) assume "\ basis i \ (0::'a)" - hence "(0::'a) \ basis ` {.. DIM('a)" shows "basis i = 0" -proof- - have "(basis i::'a) \ basis ` {DIM('a)..}" using assms by auto - thus ?thesis unfolding basis_finite by fastsimp -qed - -lemma basis_representation: - "\u. x = (\v\basis ` {..R (v\'a\real_basis))" -proof - - have "x\UNIV" by auto from this[unfolded span_basis[THEN sym]] - have "\u. (\v\basis ` {..R v) = x" - unfolding range_basis span_insert_0 apply(subst (asm) span_finite) by auto - thus ?thesis by fastsimp -qed - -lemma span_basis'[simp]:"span ((basis::nat=>'a) ` {..'a) ` {.. span (basis ` {.. 'c::real_vector" assumes *: "inj_on f {..\ " 10) where - "(\\ i. f i) = (\iR basis i)" - -lemma basis_at_neq_0[intro]: +lemma independent_basis: + "independent (basis ` {..d. \ 0 < d; basis ` {d..} = {0::'a::euclidean_space}; + independent (basis ` {.. 'a) {.. \ P d" + shows "P DIM('a::euclidean_space)" + using DIM_positive basis_finite independent_basis basis_inj + by (rule assms) + +lemma (in euclidean_space) dimension_eq: + assumes "\i. i < d \ basis i \ 0" + assumes "\i. d \ i \ basis i = 0" + shows "DIM('a) = d" +proof (rule linorder_cases [of "DIM('a)" d]) + assume "DIM('a) < d" + hence "basis DIM('a) \ 0" by (rule assms) + thus ?thesis by simp +next + assume "d < DIM('a)" + hence "basis d \ 0" by simp + thus ?thesis by (simp add: assms) +next + assume "DIM('a) = d" thus ?thesis . +qed + +lemma (in euclidean_space) range_basis: + "range basis = insert 0 (basis ` {.. {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)" + unfolding range_basis by auto + +lemma (in euclidean_space) basis_neq_0 [intro]: + assumes "i 0" + using assms by simp + +subsubsection {* Projecting components *} + +definition (in euclidean_space) euclidean_component (infixl "$$" 90) + where "x $$ i = inner (basis i) x" + +lemma bounded_linear_euclidean_component: + "bounded_linear (\x. euclidean_component x i)" + unfolding euclidean_component_def + by (rule inner.bounded_linear_right) + +interpretation euclidean_component: + bounded_linear "\x. euclidean_component x i" + by (rule bounded_linear_euclidean_component) + +lemma euclidean_eqI: + fixes x y :: "'a::euclidean_space" + assumes "\i. i < DIM('a) \ x $$ i = y $$ i" shows "x = y" +proof - + from assms have "\i (\i i < DIM('a) then 1 else 0)" + unfolding euclidean_component_def dot_basis by auto + +lemma (in euclidean_space) basis_at_neq_0 [intro]: "i < DIM('a) \ basis i $$ i \ 0" - unfolding euclidean_component_def by (auto intro!: basis_neq_0) - -lemma euclidean_component_ge[simp]: + by simp + +lemma (in euclidean_space) euclidean_component_ge [simp]: assumes "i \ DIM('a)" shows "x $$ i = 0" - unfolding euclidean_component_def basis_zero[OF assms] by auto + unfolding euclidean_component_def basis_zero[OF assms] by simp lemma euclidean_scaleR: shows "(a *\<^sub>R x) $$ i = a * (x$$i)" unfolding euclidean_component_def by auto -end - -interpretation euclidean_component: - bounded_linear "\x. euclidean_component x i" - unfolding euclidean_component_def - by (rule inner.bounded_linear_right) - -subsection{* Euclidean Spaces as Typeclass *} - -class euclidean_space = real_basis_with_inner + - assumes basis_orthonormal: "\ij i j < DIM('a))") - case False - hence "basis i = 0 \ basis j = 0" - using basis_finite by fastsimp - hence "inner (basis i) (basis j) = 0" by (rule disjE) simp_all - thus ?thesis using False by auto -next - case True thus ?thesis using basis_orthonormal by auto -qed - -lemma (in euclidean_space) basis_component[simp]: - "basis i $$ j = (if i = j \ i < DIM('a) then 1 else 0)" - unfolding euclidean_component_def dot_basis by auto - lemmas euclidean_simps = euclidean_component.add euclidean_component.diff @@ -1767,34 +1740,22 @@ basis_component lemma euclidean_representation: - "(x\'a\euclidean_space) = (\i\{..R basis i)" -proof- - from basis_representation[of x] guess u .. - hence *:"x = (\i\{..R (basis i))" - by (simp add: setsum_reindex) - show ?thesis apply(subst *) - proof(safe intro!: setsum_cong2) - fix i assume i: "i < DIM('a)" - hence "x$$i = (\xR basis i = x $$ i *\<^sub>R basis i" by simp - qed -qed - -lemma euclidean_eq: - fixes x y :: "'a\euclidean_space" - shows "x = y \ (\iiiR basis i)" + apply (rule euclidean_eqI) + apply (simp add: euclidean_component.setsum euclidean_component.scaleR) + apply (simp add: if_distrib setsum_delta cong: if_cong) + done + +subsubsection {* Binder notation for vectors *} + +definition (in euclidean_space) Chi (binder "\\ " 10) where + "(\\ i. f i) = (\iR basis i)" + +lemma euclidean_lambda_beta [simp]: "((\\ i. f i)::'a::euclidean_space) $$ j = (if j < DIM('a) then f j else 0)" - by (auto simp: euclidean_simps Chi_def if_distrib setsum_cases - intro!: setsum_cong) + by (auto simp: euclidean_component.setsum euclidean_component.scaleR + Chi_def if_distrib setsum_cases intro!: setsum_cong) lemma euclidean_lambda_beta': "j < DIM('a) \ ((\\ i. f i)::'a::euclidean_space) $$ j = f j" @@ -1805,7 +1766,7 @@ lemma euclidean_beta_reduce[simp]: "(\\ i. x $$ i) = (x::'a::euclidean_space)" - by (subst euclidean_eq) (simp add: euclidean_lambda_beta) + by (simp add: euclidean_eq) lemma euclidean_lambda_beta_0[simp]: "((\\ i. f i)::'a::euclidean_space) $$ 0 = f 0" @@ -1823,6 +1784,34 @@ finally show ?thesis . qed +lemma span_basis: "span (range basis) = (UNIV :: 'a::euclidean_space set)" +proof - + { fix x :: 'a + have "(\iR basis i) \ span (range basis :: 'a set)" + by (simp add: span_setsum span_mul span_superset) + hence "x \ span (range basis)" + by (simp only: euclidean_representation [symmetric]) + } thus ?thesis by auto +qed + +lemma basis_representation: + "\u. x = (\v\basis ` {..R (v\'a\euclidean_space))" +proof - + have "x\UNIV" by auto from this[unfolded span_basis[THEN sym]] + have "\u. (\v\basis ` {..R v) = x" + unfolding range_basis span_insert_0 apply(subst (asm) span_finite) by auto + thus ?thesis by fastsimp +qed + +lemma span_basis'[simp]:"span ((basis::nat=>'a) ` {..'a) ` {.. span (basis ` {..d>0. ?b ` {d..} = {0} \ independent (?b ` {.. inj_on ?b {.. span (range ?b)" - using span_mul[of 1 "range ?b" x] span_clauses(1)[of 1 "range ?b"] - by auto } - thus "span (range ?b) = UNIV" by auto -qed -end - -lemma DIM_real[simp]: "DIM(real) = 1" - by (rule dimension_eq) (auto simp: basis_real_def) - -instance real::ordered_euclidean_space proof qed(auto simp add:euclidean_component_def) +instance real::ordered_euclidean_space + by default (auto simp add: euclidean_component_def) lemma Eucl_real_simps[simp]: "(x::real) $$ 0 = x" @@ -3335,177 +3320,89 @@ unfolding euclidean_lambda_beta' unfolding euclidean_component_def by auto -instantiation complex :: real_basis_with_inner +instantiation complex :: euclidean_space begin -definition "basis i = (if i = 0 then 1 else if i = 1 then ii else 0)" - -lemma complex_basis[simp]:"basis 0 = (1::complex)" "basis 1 = ii" "basis (Suc 0) = ii" + +definition + "dimension (t::complex itself) = 2" + +definition + "basis i = (if i = 0 then 1 else if i = 1 then ii else 0)" + +lemma all_less_Suc: "(\i (\i P n" + by (auto simp add: less_Suc_eq) + +instance proof + show "0 < DIM(complex)" + unfolding dimension_complex_def by simp +next + fix i :: nat + assume "DIM(complex) \ i" thus "basis i = (0::complex)" + unfolding dimension_complex_def basis_complex_def by simp +next + show "\iji x = 0" + unfolding dimension_complex_def basis_complex_def inner_complex_def + by (simp add: numeral_2_eq_2 all_less_Suc complex_eq_iff) +qed + +end + +lemma complex_basis[simp]: + shows "basis 0 = (1::complex)" and "basis 1 = ii" and "basis (Suc 0) = ii" unfolding basis_complex_def by auto -instance -proof - let ?b = "basis::nat \ complex" - have [simp]: "(range ?b) = {0, basis 0, basis 1}" - by (auto simp: basis_complex_def split: split_if_asm) - { fix z::complex - have "z \ span (range ?b)" - by (auto simp: span_finite complex_equality - intro!: exI[of _ "\i. if i = 1 then Re z else if i = ii then Im z else 0"]) } - thus "span (range ?b) = UNIV" by auto - - have "{..<2} = {0, 1::nat}" by auto - hence *: "?b ` {..<2} = {1, ii}" - by (auto simp add: basis_complex_def) - moreover have "1 \ span {\}" - by (simp add: span_finite complex_equality complex_scaleR_def) - hence "independent (?b ` {..<2})" - by (simp add: * basis_complex_def independent_empty independent_insert) - ultimately show "\d>0. ?b ` {d..} = {0} \ independent (?b ` {.. inj_on ?b {.. {DIM('a).. (?b_b ` {.. {0}" - unfolding image_range image_image basis_prod_def_raw range_basis - by (auto simp: zero_prod_def basis_eq_0_iff) - hence b_split: - "?b ` {.. {0} \ {0} \ (?b_b ` {.. {DIM('b)+DIM('a)..}" - by auto - - have range_b: "range ?b = ?prod \ {0}" - by (subst split_UNIV) (simp add: image_Un b_split b_0) - - have prod: "\f A B. setsum f (A \ B) = (\a\A. \b\B. f (a, b))" - by (simp add: setsum_cartesian_product) - - show "span (range ?b) = UNIV" - unfolding span_explicit range_b - proof safe - fix a::'a and b::'b - from in_span_basis[of a] in_span_basis[of b] - obtain Sa ua Sb ub where span: - "finite Sa" "Sa \ basis ` {..v\Sa. ua v *\<^sub>R v)" - "finite Sb" "Sb \ basis ` {..v\Sb. ub v *\<^sub>R v)" - unfolding span_explicit by auto - - let ?S = "((Sa - {0}) \ {0} \ {0} \ (Sb - {0}))" - have *: - "?S \ {v. fst v = 0} \ {v. snd v = 0} = {}" - "?S \ - {v. fst v = 0} \ {v. snd v = 0} = (Sa - {0}) \ {0}" - "?S \ {v. fst v = 0} \ - {v. snd v = 0} = {0} \ (Sb - {0})" - by (auto simp: zero_prod_def) - show "\S u. finite S \ S \ ?prod \ {0} \ (\v\S. u v *\<^sub>R v) = (a, b)" - apply (rule exI[of _ ?S]) - apply (rule exI[of _ "\(v, w). (if w = 0 then ua v else 0) + (if v = 0 then ub w else 0)"]) - using span - apply (simp add: prod_case_unfold setsum_addf if_distrib cond_application_beta setsum_cases prod *) - by (auto simp add: setsum_prod intro!: setsum_mono_zero_cong_left) - qed simp - - show "\d>0. ?b ` {d..} = {0} \ independent (?b ` {.. inj_on ?b {..j\{..R ?b j) = ?b i" (is "?SUM = _") - let ?left = "{.. = (\j\?left - {i}. u (?b j) *\<^sub>R ?b j) + - (\j\?right. u (?b j) *\<^sub>R ?b j)" - using `i < DIM('a)` by (subst setsum_Un_disjoint[symmetric]) (auto intro!: setsum_cong) - also have "\ = (\j\?left - {i}. u (?b_a j, 0) *\<^sub>R (?b_a j, 0)) + - (\j\?right. u (0, ?b_b (j-DIM('a))) *\<^sub>R (0, ?b_b (j-DIM('a))))" - unfolding basis_prod_def by auto - finally have "basis i = (\j\?left - {i}. u (?b_a j, 0) *\<^sub>R ?b_a j)" - by (simp add: setsum_prod) - moreover - note independent_basis[where 'a='a, unfolded independent_eq_inj_on[OF basis_inj]] - note this[rule_format, of i "\v. u (v, 0)"] - ultimately show False using `i < DIM('a)` by auto - next - let ?i = "i - DIM('a)" - assume not: "\ i < DIM('a)" hence "DIM('a) \ i" by auto - hence "?i < DIM('b)" using `i < DIM('b) + DIM('a)` by auto - - have inj_on: "inj_on (\j. j - DIM('a)) {DIM('a)..j. j-DIM('a))`(?right - {i})" - by (auto simp: inj_on_image_set_diff image_minus_const_atLeastLessThan_nat) - - have "(0, basis ?i) = ?SUM" unfolding `?SUM = ?b i` - unfolding basis_prod_def using not `?i < DIM('b)` by auto - also have "\ = (\j\?left. u (?b j) *\<^sub>R ?b j) + - (\j\?right - {i}. u (?b j) *\<^sub>R ?b j)" - using not by (subst setsum_Un_disjoint[symmetric]) (auto intro!: setsum_cong) - also have "\ = (\j\?left. u (?b_a j, 0) *\<^sub>R (?b_a j, 0)) + - (\j\?right - {i}. u (0, ?b_b (j-DIM('a))) *\<^sub>R (0, ?b_b (j-DIM('a))))" - unfolding basis_prod_def by auto - finally have "basis ?i = (\j\{..R ?b_b j)" - unfolding * - by (subst setsum_reindex[OF inj_on[THEN subset_inj_on]]) - (auto simp: setsum_prod) - moreover - note independent_basis[where 'a='b, unfolded independent_eq_inj_on[OF basis_inj]] - note this[rule_format, of ?i "\v. u (0, v)"] - ultimately show False using `?i < DIM('b)` by auto - qed - qed - qed +definition + "dimension (t::('a \ 'b) itself) = DIM('a) + DIM('b)" + +definition + "basis i = (if i < DIM('a) then (basis i, 0) else (0, basis (i - DIM('a))))" + +lemma all_less_sum: + fixes m n :: nat + shows "(\i<(m + n). P i) \ (\i (\i 'b)" + unfolding dimension_prod_def by (intro add_pos_pos DIM_positive) +next + fix i :: nat + assume "DIM('a \ 'b) \ i" thus "basis i = (0::'a \ 'b)" + unfolding dimension_prod_def basis_prod_def zero_prod_def + by simp +next + show "\i 'b). \j 'b). + inner (basis i::'a \ 'b) (basis j) = (if i = j then 1 else 0)" + unfolding dimension_prod_def basis_prod_def inner_prod_def + unfolding all_less_sum prod_eq_iff + by (simp add: basis_orthonormal) +next + fix x :: "'a \ 'b" + show "(\i 'b). inner (basis i) x = 0) \ x = 0" + unfolding dimension_prod_def basis_prod_def inner_prod_def + unfolding all_less_sum prod_eq_iff + by (simp add: euclidean_all_zero) qed + end -lemma DIM_prod[simp]: "DIM('a \ 'b) = DIM('b::real_basis) + DIM('a::real_basis)" - by (rule dimension_eq) (auto simp: basis_prod_def zero_prod_def basis_eq_0_iff) - -instance prod :: (euclidean_space, euclidean_space) euclidean_space -proof (default, safe) - let ?b = "basis :: nat \ 'a \ 'b" - fix i j assume "i < DIM('a \ 'b)" "j < DIM('a \ 'b)" - thus "?b i \ ?b j = (if i = j then 1 else 0)" - unfolding basis_prod_def by (auto simp: dot_basis) -qed +lemma DIM_prod[simp]: "DIM('a \ 'b) = DIM('b::euclidean_space) + DIM('a::euclidean_space)" + (* FIXME: why this orientation? Why not "DIM('a) + DIM('b)" ? *) + unfolding dimension_prod_def by (rule add_commute) instantiation prod :: (ordered_euclidean_space, ordered_euclidean_space) ordered_euclidean_space begin diff -r e6c6ca74d81b -r 286bd57858b9 src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy --- a/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Tue Aug 09 13:09:35 2011 -0700 +++ b/src/HOL/Multivariate_Analysis/Topology_Euclidean_Space.thy Wed Aug 10 00:29:31 2011 -0700 @@ -473,7 +473,7 @@ using islimpt_UNIV [of x] by (simp add: islimpt_approachable) -instance real_basis_with_inner \ perfect_space +instance euclidean_space \ perfect_space proof fix x :: 'a { fix e :: real assume "0 < e"