src/HOL/Library/Euclidean_Space.thy
 changeset 30489 5d7d0add1741 parent 30305 720226bedc4d child 30510 4120fc59dd85
```     1.1 --- a/src/HOL/Library/Euclidean_Space.thy	Thu Mar 12 08:57:03 2009 -0700
1.2 +++ b/src/HOL/Library/Euclidean_Space.thy	Thu Mar 12 09:27:23 2009 -0700
1.3 @@ -5,7 +5,7 @@
1.4  header {* (Real) Vectors in Euclidean space, and elementary linear algebra.*}
1.5
1.6  theory Euclidean_Space
1.7 -  imports "~~/src/HOL/Decision_Procs/Dense_Linear_Order" Complex_Main
1.8 +  imports "~~/src/HOL/Decision_Procs/Dense_Linear_Order" Complex_Main
1.9    Finite_Cartesian_Product Glbs Infinite_Set Numeral_Type
1.10    Inner_Product
1.11    uses ("normarith.ML")
1.12 @@ -31,26 +31,26 @@
1.13  qed
1.14
1.15  lemma setsum_singleton[simp]: "setsum f {x} = f x" by simp
1.16 -lemma setsum_1: "setsum f {(1::'a::{order,one})..1} = f 1"
1.17 +lemma setsum_1: "setsum f {(1::'a::{order,one})..1} = f 1"
1.19
1.20 -lemma setsum_2: "setsum f {1::nat..2} = f 1 + f 2"
1.21 +lemma setsum_2: "setsum f {1::nat..2} = f 1 + f 2"
1.23
1.24 -lemma setsum_3: "setsum f {1::nat..3} = f 1 + f 2 + f 3"
1.25 +lemma setsum_3: "setsum f {1::nat..3} = f 1 + f 2 + f 3"
1.27
1.28  subsection{* Basic componentwise operations on vectors. *}
1.29
1.30  instantiation "^" :: (plus,type) plus
1.31  begin
1.32 -definition  vector_add_def : "op + \<equiv> (\<lambda> x y.  (\<chi> i. (x\$i) + (y\$i)))"
1.33 +definition  vector_add_def : "op + \<equiv> (\<lambda> x y.  (\<chi> i. (x\$i) + (y\$i)))"
1.34  instance ..
1.35  end
1.36
1.37  instantiation "^" :: (times,type) times
1.38  begin
1.39 -  definition vector_mult_def : "op * \<equiv> (\<lambda> x y.  (\<chi> i. (x\$i) * (y\$i)))"
1.40 +  definition vector_mult_def : "op * \<equiv> (\<lambda> x y.  (\<chi> i. (x\$i) * (y\$i)))"
1.41    instance ..
1.42  end
1.43
1.44 @@ -64,12 +64,12 @@
1.45  instance ..
1.46  end
1.47  instantiation "^" :: (zero,type) zero begin
1.48 -  definition vector_zero_def : "0 \<equiv> (\<chi> i. 0)"
1.49 +  definition vector_zero_def : "0 \<equiv> (\<chi> i. 0)"
1.50  instance ..
1.51  end
1.52
1.53  instantiation "^" :: (one,type) one begin
1.54 -  definition vector_one_def : "1 \<equiv> (\<chi> i. 1)"
1.55 +  definition vector_one_def : "1 \<equiv> (\<chi> i. 1)"
1.56  instance ..
1.57  end
1.58
1.59 @@ -80,13 +80,13 @@
1.60    x\$i <= y\$i)"
1.61  definition vector_less_def: "less (x :: 'a ^'b) y = (ALL i : {1 ..
1.62    dimindex (UNIV :: 'b set)}. x\$i < y\$i)"
1.63 -
1.64 +
1.65  instance by (intro_classes)
1.66  end
1.67
1.68  instantiation "^" :: (scaleR, type) scaleR
1.69  begin
1.70 -definition vector_scaleR_def: "scaleR = (\<lambda> r x.  (\<chi> i. scaleR r (x\$i)))"
1.71 +definition vector_scaleR_def: "scaleR = (\<lambda> r x.  (\<chi> i. scaleR r (x\$i)))"
1.72  instance ..
1.73  end
1.74
1.75 @@ -117,19 +117,19 @@
1.76  lemmas Cart_lambda_beta' = Cart_lambda_beta[rule_format]
1.77  method_setup vector = {*
1.78  let
1.79 -  val ss1 = HOL_basic_ss addsimps [@{thm dot_def}, @{thm setsum_addf} RS sym,
1.80 -  @{thm setsum_subtractf} RS sym, @{thm setsum_right_distrib},
1.81 +  val ss1 = HOL_basic_ss addsimps [@{thm dot_def}, @{thm setsum_addf} RS sym,
1.82 +  @{thm setsum_subtractf} RS sym, @{thm setsum_right_distrib},
1.83    @{thm setsum_left_distrib}, @{thm setsum_negf} RS sym]
1.84 -  val ss2 = @{simpset} addsimps
1.85 -             [@{thm vector_add_def}, @{thm vector_mult_def},
1.86 -              @{thm vector_minus_def}, @{thm vector_uminus_def},
1.87 -              @{thm vector_one_def}, @{thm vector_zero_def}, @{thm vec_def},
1.88 +  val ss2 = @{simpset} addsimps
1.89 +             [@{thm vector_add_def}, @{thm vector_mult_def},
1.90 +              @{thm vector_minus_def}, @{thm vector_uminus_def},
1.91 +              @{thm vector_one_def}, @{thm vector_zero_def}, @{thm vec_def},
1.92                @{thm vector_scaleR_def},
1.93                @{thm Cart_lambda_beta'}, @{thm vector_scalar_mult_def}]
1.94 - fun vector_arith_tac ths =
1.95 + fun vector_arith_tac ths =
1.96     simp_tac ss1
1.97     THEN' (fn i => rtac @{thm setsum_cong2} i
1.98 -         ORELSE rtac @{thm setsum_0'} i
1.99 +         ORELSE rtac @{thm setsum_0'} i
1.100           ORELSE simp_tac (HOL_basic_ss addsimps [@{thm "Cart_eq"}]) i)
1.101     (* THEN' TRY o clarify_tac HOL_cs  THEN' (TRY o rtac @{thm iffI}) *)
1.102     THEN' asm_full_simp_tac (ss2 addsimps ths)
1.103 @@ -145,30 +145,30 @@
1.104
1.105  text{* Obvious "component-pushing". *}
1.106
1.107 -lemma vec_component: " i \<in> {1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (vec x :: 'a ^ 'n)\$i = x"
1.108 -  by (vector vec_def)
1.109 -
1.111 +lemma vec_component: " i \<in> {1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (vec x :: 'a ^ 'n)\$i = x"
1.112 +  by (vector vec_def)
1.113 +
1.115    fixes x y :: "'a::{plus} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
1.116    shows "(x + y)\$i = x\$i + y\$i"
1.117    using i by vector
1.118
1.119 -lemma vector_minus_component:
1.120 +lemma vector_minus_component:
1.121    fixes x y :: "'a::{minus} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
1.122    shows "(x - y)\$i = x\$i - y\$i"
1.123    using i  by vector
1.124
1.125 -lemma vector_mult_component:
1.126 +lemma vector_mult_component:
1.127    fixes x y :: "'a::{times} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
1.128    shows "(x * y)\$i = x\$i * y\$i"
1.129    using i by vector
1.130
1.131 -lemma vector_smult_component:
1.132 +lemma vector_smult_component:
1.133    fixes y :: "'a::{times} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
1.134    shows "(c *s y)\$i = c * (y\$i)"
1.135    using i by vector
1.136
1.137 -lemma vector_uminus_component:
1.138 +lemma vector_uminus_component:
1.139    fixes x :: "'a::{uminus} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
1.140    shows "(- x)\$i = - (x\$i)"
1.141    using i by vector
1.142 @@ -188,26 +188,26 @@
1.143
1.144  subsection {* Some frequently useful arithmetic lemmas over vectors. *}
1.145
1.148    apply (intro_classes) by (vector add_assoc)
1.149
1.150
1.152 -  apply (intro_classes) by vector+
1.153 -
1.155 -  apply (intro_classes) by (vector algebra_simps)+
1.156 -
1.159 +  apply (intro_classes) by vector+
1.160 +
1.162 +  apply (intro_classes) by (vector algebra_simps)+
1.163 +
1.165    apply (intro_classes) by (vector add_commute)
1.166
1.168    apply (intro_classes) by vector
1.169
1.172    apply (intro_classes) by vector+
1.173
1.176    apply (intro_classes)
1.177    by (vector Cart_eq)+
1.178
1.179 @@ -218,30 +218,30 @@
1.180  instance "^" :: (real_vector, type) real_vector
1.181    by default (vector scaleR_left_distrib scaleR_right_distrib)+
1.182
1.183 -instance "^" :: (semigroup_mult,type) semigroup_mult
1.184 +instance "^" :: (semigroup_mult,type) semigroup_mult
1.185    apply (intro_classes) by (vector mult_assoc)
1.186
1.187 -instance "^" :: (monoid_mult,type) monoid_mult
1.188 +instance "^" :: (monoid_mult,type) monoid_mult
1.189    apply (intro_classes) by vector+
1.190
1.191 -instance "^" :: (ab_semigroup_mult,type) ab_semigroup_mult
1.192 +instance "^" :: (ab_semigroup_mult,type) ab_semigroup_mult
1.193    apply (intro_classes) by (vector mult_commute)
1.194
1.195 -instance "^" :: (ab_semigroup_idem_mult,type) ab_semigroup_idem_mult
1.196 +instance "^" :: (ab_semigroup_idem_mult,type) ab_semigroup_idem_mult
1.197    apply (intro_classes) by (vector mult_idem)
1.198
1.199 -instance "^" :: (comm_monoid_mult,type) comm_monoid_mult
1.200 +instance "^" :: (comm_monoid_mult,type) comm_monoid_mult
1.201    apply (intro_classes) by vector
1.202
1.203  fun vector_power :: "('a::{one,times} ^'n) \<Rightarrow> nat \<Rightarrow> 'a^'n" where
1.204    "vector_power x 0 = 1"
1.205    | "vector_power x (Suc n) = x * vector_power x n"
1.206
1.207 -instantiation "^" :: (recpower,type) recpower
1.208 +instantiation "^" :: (recpower,type) recpower
1.209  begin
1.210    definition vec_power_def: "op ^ \<equiv> vector_power"
1.211 -  instance
1.212 -  apply (intro_classes) by (simp_all add: vec_power_def)
1.213 +  instance
1.214 +  apply (intro_classes) by (simp_all add: vec_power_def)
1.215  end
1.216
1.217  instance "^" :: (semiring,type) semiring
1.218 @@ -250,16 +250,16 @@
1.219  instance "^" :: (semiring_0,type) semiring_0
1.220    apply (intro_classes) by (vector ring_simps)+
1.221  instance "^" :: (semiring_1,type) semiring_1
1.222 -  apply (intro_classes) apply vector using dimindex_ge_1 by auto
1.223 +  apply (intro_classes) apply vector using dimindex_ge_1 by auto
1.224  instance "^" :: (comm_semiring,type) comm_semiring
1.225    apply (intro_classes) by (vector ring_simps)+
1.226
1.227 -instance "^" :: (comm_semiring_0,type) comm_semiring_0 by (intro_classes)
1.228 +instance "^" :: (comm_semiring_0,type) comm_semiring_0 by (intro_classes)
1.230 -instance "^" :: (semiring_0_cancel,type) semiring_0_cancel by (intro_classes)
1.231 -instance "^" :: (comm_semiring_0_cancel,type) comm_semiring_0_cancel by (intro_classes)
1.232 -instance "^" :: (ring,type) ring by (intro_classes)
1.233 -instance "^" :: (semiring_1_cancel,type) semiring_1_cancel by (intro_classes)
1.234 +instance "^" :: (semiring_0_cancel,type) semiring_0_cancel by (intro_classes)
1.235 +instance "^" :: (comm_semiring_0_cancel,type) comm_semiring_0_cancel by (intro_classes)
1.236 +instance "^" :: (ring,type) ring by (intro_classes)
1.237 +instance "^" :: (semiring_1_cancel,type) semiring_1_cancel by (intro_classes)
1.238  instance "^" :: (comm_semiring_1,type) comm_semiring_1 by (intro_classes)
1.239
1.240  instance "^" :: (ring_1,type) ring_1 ..
1.241 @@ -273,31 +273,31 @@
1.242
1.243  instance "^" :: (real_algebra_1,type) real_algebra_1 ..
1.244
1.245 -lemma of_nat_index:
1.246 +lemma of_nat_index:
1.247    "i\<in>{1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (of_nat n :: 'a::semiring_1 ^'n)\$i = of_nat n"
1.248    apply (induct n)
1.249    apply vector
1.250    apply vector
1.251    done
1.252 -lemma zero_index[simp]:
1.253 +lemma zero_index[simp]:
1.254    "i\<in>{1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (0 :: 'a::zero ^'n)\$i = 0" by vector
1.255
1.256 -lemma one_index[simp]:
1.257 +lemma one_index[simp]:
1.258    "i\<in>{1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (1 :: 'a::one ^'n)\$i = 1" by vector
1.259
1.260  lemma one_plus_of_nat_neq_0: "(1::'a::semiring_char_0) + of_nat n \<noteq> 0"
1.261  proof-
1.262    have "(1::'a) + of_nat n = 0 \<longleftrightarrow> of_nat 1 + of_nat n = (of_nat 0 :: 'a)" by simp
1.263 -  also have "\<dots> \<longleftrightarrow> 1 + n = 0" by (simp only: of_nat_add[symmetric] of_nat_eq_iff)
1.264 -  finally show ?thesis by simp
1.265 +  also have "\<dots> \<longleftrightarrow> 1 + n = 0" by (simp only: of_nat_add[symmetric] of_nat_eq_iff)
1.266 +  finally show ?thesis by simp
1.267  qed
1.268
1.269 -instance "^" :: (semiring_char_0,type) semiring_char_0
1.270 -proof (intro_classes)
1.271 +instance "^" :: (semiring_char_0,type) semiring_char_0
1.272 +proof (intro_classes)
1.273    fix m n ::nat
1.274    show "(of_nat m :: 'a^'b) = of_nat n \<longleftrightarrow> m = n"
1.275    proof(induct m arbitrary: n)
1.276 -    case 0 thus ?case apply vector
1.277 +    case 0 thus ?case apply vector
1.278        apply (induct n,auto simp add: ring_simps)
1.279        using dimindex_ge_1 apply auto
1.280        apply vector
1.281 @@ -323,24 +323,24 @@
1.282  instance "^" :: (comm_ring_1,type) comm_ring_1 by intro_classes
1.283  instance "^" :: (ring_char_0,type) ring_char_0 by intro_classes
1.284
1.285 -lemma vector_smult_assoc: "a *s (b *s x) = ((a::'a::semigroup_mult) * b) *s x"
1.286 +lemma vector_smult_assoc: "a *s (b *s x) = ((a::'a::semigroup_mult) * b) *s x"
1.287    by (vector mult_assoc)
1.288 -lemma vector_sadd_rdistrib: "((a::'a::semiring) + b) *s x = a *s x + b *s x"
1.289 +lemma vector_sadd_rdistrib: "((a::'a::semiring) + b) *s x = a *s x + b *s x"
1.290    by (vector ring_simps)
1.291 -lemma vector_add_ldistrib: "(c::'a::semiring) *s (x + y) = c *s x + c *s y"
1.292 +lemma vector_add_ldistrib: "(c::'a::semiring) *s (x + y) = c *s x + c *s y"
1.293    by (vector ring_simps)
1.294  lemma vector_smult_lzero[simp]: "(0::'a::mult_zero) *s x = 0" by vector
1.295  lemma vector_smult_lid[simp]: "(1::'a::monoid_mult) *s x = x" by vector
1.296 -lemma vector_ssub_ldistrib: "(c::'a::ring) *s (x - y) = c *s x - c *s y"
1.297 +lemma vector_ssub_ldistrib: "(c::'a::ring) *s (x - y) = c *s x - c *s y"
1.298    by (vector ring_simps)
1.299  lemma vector_smult_rneg: "(c::'a::ring) *s -x = -(c *s x)" by vector
1.300  lemma vector_smult_lneg: "- (c::'a::ring) *s x = -(c *s x)" by vector
1.301  lemma vector_sneg_minus1: "-x = (- (1::'a::ring_1)) *s x" by vector
1.302  lemma vector_smult_rzero[simp]: "c *s 0 = (0::'a::mult_zero ^ 'n)" by vector
1.303 -lemma vector_sub_rdistrib: "((a::'a::ring) - b) *s x = a *s x - b *s x"
1.304 +lemma vector_sub_rdistrib: "((a::'a::ring) - b) *s x = a *s x - b *s x"
1.305    by (vector ring_simps)
1.306
1.307 -lemma vec_eq[simp]: "(vec m = vec n) \<longleftrightarrow> (m = n)"
1.308 +lemma vec_eq[simp]: "(vec m = vec n) \<longleftrightarrow> (m = n)"
1.309    apply (auto simp add: vec_def Cart_eq vec_component Cart_lambda_beta )
1.310    using dimindex_ge_1 apply auto done
1.311
1.312 @@ -581,15 +581,15 @@
1.313
1.314  subsection{* Properties of the dot product.  *}
1.315
1.316 -lemma dot_sym: "(x::'a:: {comm_monoid_add, ab_semigroup_mult} ^ 'n) \<bullet> y = y \<bullet> x"
1.317 +lemma dot_sym: "(x::'a:: {comm_monoid_add, ab_semigroup_mult} ^ 'n) \<bullet> y = y \<bullet> x"
1.318    by (vector mult_commute)
1.319  lemma dot_ladd: "((x::'a::ring ^ 'n) + y) \<bullet> z = (x \<bullet> z) + (y \<bullet> z)"
1.320    by (vector ring_simps)
1.321 -lemma dot_radd: "x \<bullet> (y + (z::'a::ring ^ 'n)) = (x \<bullet> y) + (x \<bullet> z)"
1.322 +lemma dot_radd: "x \<bullet> (y + (z::'a::ring ^ 'n)) = (x \<bullet> y) + (x \<bullet> z)"
1.323    by (vector ring_simps)
1.324 -lemma dot_lsub: "((x::'a::ring ^ 'n) - y) \<bullet> z = (x \<bullet> z) - (y \<bullet> z)"
1.325 +lemma dot_lsub: "((x::'a::ring ^ 'n) - y) \<bullet> z = (x \<bullet> z) - (y \<bullet> z)"
1.326    by (vector ring_simps)
1.327 -lemma dot_rsub: "(x::'a::ring ^ 'n) \<bullet> (y - z) = (x \<bullet> y) - (x \<bullet> z)"
1.328 +lemma dot_rsub: "(x::'a::ring ^ 'n) \<bullet> (y - z) = (x \<bullet> y) - (x \<bullet> z)"
1.329    by (vector ring_simps)
1.330  lemma dot_lmult: "(c *s x) \<bullet> y = (c::'a::ring) * (x \<bullet> y)" by (vector ring_simps)
1.331  lemma dot_rmult: "x \<bullet> (c *s y) = (c::'a::comm_ring) * (x \<bullet> y)" by (vector ring_simps)
1.332 @@ -625,8 +625,8 @@
1.333    ultimately show ?thesis by metis
1.334  qed
1.335
1.336 -lemma dot_pos_lt[simp]: "(0 < x \<bullet> x) \<longleftrightarrow> (x::'a::{ordered_ring_strict,ring_no_zero_divisors} ^ 'n) \<noteq> 0" using dot_eq_0[of x] dot_pos_le[of x]
1.337 -  by (auto simp add: le_less)
1.338 +lemma dot_pos_lt[simp]: "(0 < x \<bullet> x) \<longleftrightarrow> (x::'a::{ordered_ring_strict,ring_no_zero_divisors} ^ 'n) \<noteq> 0" using dot_eq_0[of x] dot_pos_le[of x]
1.339 +  by (auto simp add: le_less)
1.340
1.341  subsection{* The collapse of the general concepts to dimension one. *}
1.342
1.343 @@ -642,13 +642,13 @@
1.344  lemma norm_vector_1: "norm (x :: _^1) = norm (x\$1)"
1.345    by (simp add: vector_norm_def dimindex_def)
1.346
1.347 -lemma norm_real: "norm(x::real ^ 1) = abs(x\$1)"
1.348 +lemma norm_real: "norm(x::real ^ 1) = abs(x\$1)"
1.350
1.351  text{* Metric *}
1.352
1.353  text {* FIXME: generalize to arbitrary @{text real_normed_vector} types *}
1.354 -definition dist:: "real ^ 'n \<Rightarrow> real ^ 'n \<Rightarrow> real" where
1.355 +definition dist:: "real ^ 'n \<Rightarrow> real ^ 'n \<Rightarrow> real" where
1.356    "dist x y = norm (x - y)"
1.357
1.358  lemma dist_real: "dist(x::real ^ 1) y = abs((x\$1) - (y\$1))"
1.359 @@ -667,14 +667,14 @@
1.360    shows "\<exists>x \<ge> a. x <= b \<and> f x \<notin> e1 \<and> f x \<notin> e2" (is "\<exists> x. ?P x")
1.361  proof-
1.362    let ?S = "{c. \<forall>x \<ge> a. x <= c \<longrightarrow> f x \<in> e1}"
1.363 -  have Se: " \<exists>x. x \<in> ?S" apply (rule exI[where x=a]) by (auto simp add: fa)
1.364 -  have Sub: "\<exists>y. isUb UNIV ?S y"
1.365 +  have Se: " \<exists>x. x \<in> ?S" apply (rule exI[where x=a]) by (auto simp add: fa)
1.366 +  have Sub: "\<exists>y. isUb UNIV ?S y"
1.367      apply (rule exI[where x= b])
1.368 -    using ab fb e12 by (auto simp add: isUb_def setle_def)
1.369 -  from reals_complete[OF Se Sub] obtain l where
1.370 +    using ab fb e12 by (auto simp add: isUb_def setle_def)
1.371 +  from reals_complete[OF Se Sub] obtain l where
1.372      l: "isLub UNIV ?S l"by blast
1.373    have alb: "a \<le> l" "l \<le> b" using l ab fa fb e12
1.374 -    apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
1.375 +    apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
1.376      by (metis linorder_linear)
1.377    have ale1: "\<forall>z \<ge> a. z < l \<longrightarrow> f z \<in> e1" using l
1.378      apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
1.379 @@ -685,11 +685,11 @@
1.380      {assume le2: "f l \<in> e2"
1.381        from le2 fa fb e12 alb have la: "l \<noteq> a" by metis
1.382        hence lap: "l - a > 0" using alb by arith
1.383 -      from e2[rule_format, OF le2] obtain e where
1.384 +      from e2[rule_format, OF le2] obtain e where
1.385  	e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e2" by metis
1.386 -      from dst[OF alb e(1)] obtain d where
1.387 +      from dst[OF alb e(1)] obtain d where
1.388  	d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis
1.389 -      have "\<exists>d'. d' < d \<and> d' >0 \<and> l - d' > a" using lap d(1)
1.390 +      have "\<exists>d'. d' < d \<and> d' >0 \<and> l - d' > a" using lap d(1)
1.391  	apply ferrack by arith
1.392        then obtain d' where d': "d' > 0" "d' < d" "l - d' > a" by metis
1.393        from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e2" by metis
1.394 @@ -701,16 +701,16 @@
1.395      {assume le1: "f l \<in> e1"
1.396      from le1 fa fb e12 alb have lb: "l \<noteq> b" by metis
1.397        hence blp: "b - l > 0" using alb by arith
1.398 -      from e1[rule_format, OF le1] obtain e where
1.399 +      from e1[rule_format, OF le1] obtain e where
1.400  	e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e1" by metis
1.401 -      from dst[OF alb e(1)] obtain d where
1.402 +      from dst[OF alb e(1)] obtain d where
1.403  	d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis
1.404 -      have "\<exists>d'. d' < d \<and> d' >0" using d(1) by dlo
1.405 +      have "\<exists>d'. d' < d \<and> d' >0" using d(1) by dlo
1.406        then obtain d' where d': "d' > 0" "d' < d" by metis
1.407        from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e1" by auto
1.408        hence "\<forall>y. l \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" using d' by auto
1.409        with ale1 have "\<forall>y. a \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" by auto
1.410 -      with l d' have False
1.411 +      with l d' have False
1.412  	by (auto simp add: isLub_def isUb_def setle_def setge_def leastP_def) }
1.413      ultimately show ?thesis using alb by metis
1.414  qed
1.415 @@ -719,7 +719,7 @@
1.416
1.417  lemma square_bound_lemma: "(x::real) < (1 + x) * (1 + x)"
1.418  proof-
1.419 -  have "(x + 1/2)^2 + 3/4 > 0" using zero_le_power2[of "x+1/2"] by arith
1.420 +  have "(x + 1/2)^2 + 3/4 > 0" using zero_le_power2[of "x+1/2"] by arith
1.421    thus ?thesis by (simp add: ring_simps power2_eq_square)
1.422  qed
1.423
1.424 @@ -740,14 +740,14 @@
1.425  lemma real_less_rsqrt: "x^2 < y \<Longrightarrow> x < sqrt y"
1.426    using real_sqrt_less_mono[of "x^2" y] by simp
1.427
1.428 -lemma sqrt_even_pow2: assumes n: "even n"
1.429 +lemma sqrt_even_pow2: assumes n: "even n"
1.430    shows "sqrt(2 ^ n) = 2 ^ (n div 2)"
1.431  proof-
1.432 -  from n obtain m where m: "n = 2*m" unfolding even_nat_equiv_def2
1.433 -    by (auto simp add: nat_number)
1.434 +  from n obtain m where m: "n = 2*m" unfolding even_nat_equiv_def2
1.435 +    by (auto simp add: nat_number)
1.436    from m  have "sqrt(2 ^ n) = sqrt ((2 ^ m) ^ 2)"
1.437      by (simp only: power_mult[symmetric] mult_commute)
1.438 -  then show ?thesis  using m by simp
1.439 +  then show ?thesis  using m by simp
1.440  qed
1.441
1.442  lemma real_div_sqrt: "0 <= x ==> x / sqrt(x) = sqrt(x)"
1.443 @@ -786,7 +786,7 @@
1.444    {assume "norm x = 0"
1.445      hence ?thesis by (simp add: dot_lzero dot_rzero)}
1.446    moreover
1.447 -  {assume "norm y = 0"
1.448 +  {assume "norm y = 0"
1.449      hence ?thesis by (simp add: dot_lzero dot_rzero)}
1.450    moreover
1.451    {assume h: "norm x \<noteq> 0" "norm y \<noteq> 0"
1.452 @@ -829,7 +829,7 @@
1.453  lemma norm_le_l1: "norm (x:: real ^'n) <= setsum(\<lambda>i. \<bar>x\$i\<bar>) {1..dimindex(UNIV::'n set)}"
1.454    by (simp add: vector_norm_def setL2_le_setsum)
1.455
1.456 -lemma real_abs_norm[simp]: "\<bar> norm x\<bar> = norm (x :: real ^'n)"
1.457 +lemma real_abs_norm[simp]: "\<bar> norm x\<bar> = norm (x :: real ^'n)"
1.458    by (rule abs_norm_cancel)
1.459  lemma real_abs_sub_norm: "\<bar>norm(x::real ^'n) - norm y\<bar> <= norm(x - y)"
1.460    by (rule norm_triangle_ineq3)
1.461 @@ -863,7 +863,7 @@
1.462    apply arith
1.463    done
1.464
1.465 -lemma norm_ge_square: "norm(x) >= a \<longleftrightarrow> a <= 0 \<or> x \<bullet> x >= a ^ 2"
1.466 +lemma norm_ge_square: "norm(x) >= a \<longleftrightarrow> a <= 0 \<or> x \<bullet> x >= a ^ 2"
1.467    apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric])
1.468    using norm_ge_zero[of x]
1.469    apply arith
1.470 @@ -891,7 +891,7 @@
1.471  next
1.472    assume ?rhs
1.473    then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y\<bullet> y = 0" by simp
1.474 -  hence "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0"
1.475 +  hence "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0"
1.476      by (simp add: dot_rsub dot_lsub dot_sym)
1.477    then have "(x - y) \<bullet> (x - y) = 0" by (simp add: ring_simps dot_lsub dot_rsub)
1.478    then show "x = y" by (simp add: dot_eq_0)
1.479 @@ -919,13 +919,13 @@
1.480  lemma pth_4: "0 *s (x::real^'n) == 0" "c *s 0 = (0::real ^ 'n)" by vector+
1.481  lemma pth_5: "c *s (d *s x) == (c * d) *s (x::real ^ 'n)" by (atomize (full)) vector
1.482  lemma pth_6: "(c::real) *s (x + y) == c *s x + c *s y" by (atomize (full)) (vector ring_simps)
1.483 -lemma pth_7: "0 + x == (x::real^'n)" "x + 0 == x" by simp_all
1.484 -lemma pth_8: "(c::real) *s x + d *s x == (c + d) *s x" by (atomize (full)) (vector ring_simps)
1.485 +lemma pth_7: "0 + x == (x::real^'n)" "x + 0 == x" by simp_all
1.486 +lemma pth_8: "(c::real) *s x + d *s x == (c + d) *s x" by (atomize (full)) (vector ring_simps)
1.487  lemma pth_9: "((c::real) *s x + z) + d *s x == (c + d) *s x + z"
1.488    "c *s x + (d *s x + z) == (c + d) *s x + z"
1.489    "(c *s x + w) + (d *s x + z) == (c + d) *s x + (w + z)" by ((atomize (full)), vector ring_simps)+
1.490  lemma pth_a: "(0::real) *s x + y == y" by (atomize (full)) vector
1.491 -lemma pth_b: "(c::real) *s x + d *s y == c *s x + d *s y"
1.492 +lemma pth_b: "(c::real) *s x + d *s y == c *s x + d *s y"
1.493    "(c *s x + z) + d *s y == c *s x + (z + d *s y)"
1.494    "c *s x + (d *s y + z) == c *s x + (d *s y + z)"
1.495    "(c *s x + w) + (d *s y + z) == c *s x + (w + (d *s y + z))"
1.496 @@ -941,7 +941,7 @@
1.497
1.498  lemma real_eq_0_iff_le_ge_0: "(x::real) = 0 == x \<ge> 0 \<and> -x \<ge> 0" by arith
1.499
1.500 -lemma norm_pths:
1.501 +lemma norm_pths:
1.502    "(x::real ^'n) = y \<longleftrightarrow> norm (x - y) \<le> 0"
1.503    "x \<noteq> y \<longleftrightarrow> \<not> (norm (x - y) \<le> 0)"
1.504    using norm_ge_zero[of "x - y"] by auto
1.505 @@ -967,26 +967,26 @@
1.506
1.507  lemma dist_eq_0[simp]: "dist x y = 0 \<longleftrightarrow> x = y" by norm
1.508
1.509 -lemma dist_pos_lt: "x \<noteq> y ==> 0 < dist x y" by norm
1.510 -lemma dist_nz:  "x \<noteq> y \<longleftrightarrow> 0 < dist x y" by norm
1.511 -
1.512 -lemma dist_triangle_le: "dist x z + dist y z <= e \<Longrightarrow> dist x y <= e" by norm
1.513 -
1.514 -lemma dist_triangle_lt: "dist x z + dist y z < e ==> dist x y < e" by norm
1.515 -
1.516 -lemma dist_triangle_half_l: "dist x1 y < e / 2 \<Longrightarrow> dist x2 y < e / 2 ==> dist x1 x2 < e" by norm
1.517 -
1.518 -lemma dist_triangle_half_r: "dist y x1 < e / 2 \<Longrightarrow> dist y x2 < e / 2 ==> dist x1 x2 < e" by norm
1.519 +lemma dist_pos_lt: "x \<noteq> y ==> 0 < dist x y" by norm
1.520 +lemma dist_nz:  "x \<noteq> y \<longleftrightarrow> 0 < dist x y" by norm
1.521 +
1.522 +lemma dist_triangle_le: "dist x z + dist y z <= e \<Longrightarrow> dist x y <= e" by norm
1.523 +
1.524 +lemma dist_triangle_lt: "dist x z + dist y z < e ==> dist x y < e" by norm
1.525 +
1.526 +lemma dist_triangle_half_l: "dist x1 y < e / 2 \<Longrightarrow> dist x2 y < e / 2 ==> dist x1 x2 < e" by norm
1.527 +
1.528 +lemma dist_triangle_half_r: "dist y x1 < e / 2 \<Longrightarrow> dist y x2 < e / 2 ==> dist x1 x2 < e" by norm
1.529
1.530  lemma dist_triangle_add: "dist (x + y) (x' + y') <= dist x x' + dist y y'"
1.531 -  by norm
1.532 -
1.533 -lemma dist_mul[simp]: "dist (c *s x) (c *s y) = \<bar>c\<bar> * dist x y"
1.534 -  unfolding dist_def vector_ssub_ldistrib[symmetric] norm_mul ..
1.535 -
1.536 -lemma dist_triangle_add_half: " dist x x' < e / 2 \<Longrightarrow> dist y y' < e / 2 ==> dist(x + y) (x' + y') < e" by norm
1.537 -
1.538 -lemma dist_le_0[simp]: "dist x y <= 0 \<longleftrightarrow> x = y" by norm
1.539 +  by norm
1.540 +
1.541 +lemma dist_mul[simp]: "dist (c *s x) (c *s y) = \<bar>c\<bar> * dist x y"
1.542 +  unfolding dist_def vector_ssub_ldistrib[symmetric] norm_mul ..
1.543 +
1.544 +lemma dist_triangle_add_half: " dist x x' < e / 2 \<Longrightarrow> dist y y' < e / 2 ==> dist(x + y) (x' + y') < e" by norm
1.545 +
1.546 +lemma dist_le_0[simp]: "dist x y <= 0 \<longleftrightarrow> x = y" by norm
1.547
1.548  lemma setsum_eq: "setsum f S = (\<chi> i. setsum (\<lambda>x. (f x)\$i ) S)"
1.549    apply vector
1.550 @@ -996,24 +996,24 @@
1.551    apply (auto simp add: vector_component zero_index)
1.552    done
1.553
1.554 -lemma setsum_clauses:
1.555 +lemma setsum_clauses:
1.556    shows "setsum f {} = 0"
1.557    and "finite S \<Longrightarrow> setsum f (insert x S) =
1.558                   (if x \<in> S then setsum f S else f x + setsum f S)"
1.559    by (auto simp add: insert_absorb)
1.560
1.561 -lemma setsum_cmul:
1.562 +lemma setsum_cmul:
1.563    fixes f:: "'c \<Rightarrow> ('a::semiring_1)^'n"
1.564    shows "setsum (\<lambda>x. c *s f x) S = c *s setsum f S"
1.565    by (simp add: setsum_eq Cart_eq Cart_lambda_beta vector_component setsum_right_distrib)
1.566
1.567 -lemma setsum_component:
1.568 +lemma setsum_component:
1.569    fixes f:: " 'a \<Rightarrow> ('b::semiring_1) ^'n"
1.570    assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
1.571    shows "(setsum f S)\$i = setsum (\<lambda>x. (f x)\$i) S"
1.572    using i by (simp add: setsum_eq Cart_lambda_beta)
1.573
1.574 -lemma setsum_norm:
1.575 +lemma setsum_norm:
1.576    fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
1.577    assumes fS: "finite S"
1.578    shows "norm (setsum f S) <= setsum (\<lambda>x. norm(f x)) S"
1.579 @@ -1027,7 +1027,7 @@
1.580    finally  show ?case  using "2.hyps" by simp
1.581  qed
1.582
1.583 -lemma real_setsum_norm:
1.584 +lemma real_setsum_norm:
1.585    fixes f :: "'a \<Rightarrow> real ^'n"
1.586    assumes fS: "finite S"
1.587    shows "norm (setsum f S) <= setsum (\<lambda>x. norm(f x)) S"
1.588 @@ -1041,25 +1041,25 @@
1.589    finally  show ?case  using "2.hyps" by simp
1.590  qed
1.591
1.592 -lemma setsum_norm_le:
1.593 +lemma setsum_norm_le:
1.594    fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
1.595    assumes fS: "finite S"
1.596    and fg: "\<forall>x \<in> S. norm (f x) \<le> g x"
1.597    shows "norm (setsum f S) \<le> setsum g S"
1.598  proof-
1.599 -  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
1.600 +  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
1.601      by - (rule setsum_mono, simp)
1.602    then show ?thesis using setsum_norm[OF fS, of f] fg
1.603      by arith
1.604  qed
1.605
1.606 -lemma real_setsum_norm_le:
1.607 +lemma real_setsum_norm_le:
1.608    fixes f :: "'a \<Rightarrow> real ^ 'n"
1.609    assumes fS: "finite S"
1.610    and fg: "\<forall>x \<in> S. norm (f x) \<le> g x"
1.611    shows "norm (setsum f S) \<le> setsum g S"
1.612  proof-
1.613 -  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
1.614 +  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
1.615      by - (rule setsum_mono, simp)
1.616    then show ?thesis using real_setsum_norm[OF fS, of f] fg
1.617      by arith
1.618 @@ -1089,9 +1089,9 @@
1.619    case 1 then show ?case by (simp add: vector_smult_lzero)
1.620  next
1.621    case (2 x F)
1.622 -  from "2.hyps" have "setsum f (insert x F) *s v = (f x + setsum f F) *s v"
1.623 +  from "2.hyps" have "setsum f (insert x F) *s v = (f x + setsum f F) *s v"
1.624      by simp
1.625 -  also have "\<dots> = f x *s v + setsum f F *s v"
1.626 +  also have "\<dots> = f x *s v + setsum f F *s v"
1.628    also have "\<dots> = setsum (\<lambda>x. f x *s v) (insert x F)" using "2.hyps" by simp
1.629    finally show ?case .
1.630 @@ -1105,20 +1105,20 @@
1.631  proof-
1.632    let ?A = "{m .. n}"
1.633    let ?B = "{n + 1 .. n + p}"
1.634 -  have eq: "{m .. n+p} = ?A \<union> ?B" using mn by auto
1.635 +  have eq: "{m .. n+p} = ?A \<union> ?B" using mn by auto
1.636    have d: "?A \<inter> ?B = {}" by auto
1.637    from setsum_Un_disjoint[of "?A" "?B" f] eq d show ?thesis by auto
1.638  qed
1.639
1.640  lemma setsum_natinterval_left:
1.641 -  assumes mn: "(m::nat) <= n"
1.642 +  assumes mn: "(m::nat) <= n"
1.643    shows "setsum f {m..n} = f m + setsum f {m + 1..n}"
1.644  proof-
1.645    from mn have "{m .. n} = insert m {m+1 .. n}" by auto
1.646    then show ?thesis by auto
1.647  qed
1.648
1.649 -lemma setsum_natinterval_difff:
1.650 +lemma setsum_natinterval_difff:
1.651    fixes f:: "nat \<Rightarrow> ('a::ab_group_add)"
1.652    shows  "setsum (\<lambda>k. f k - f(k + 1)) {(m::nat) .. n} =
1.653            (if m <= n then f m - f(n + 1) else 0)"
1.654 @@ -1136,8 +1136,8 @@
1.655  proof-
1.656    {fix x assume "x \<in> S" then have "{y. y\<in> f`S \<and> f x = y} = {f x}" by auto}
1.657    note th0 = this
1.658 -  have "setsum g S = setsum (\<lambda>x. setsum (\<lambda>y. g x) {y. y\<in> f`S \<and> f x = y}) S"
1.659 -    apply (rule setsum_cong2)
1.660 +  have "setsum g S = setsum (\<lambda>x. setsum (\<lambda>y. g x) {y. y\<in> f`S \<and> f x = y}) S"
1.661 +    apply (rule setsum_cong2)
1.663    also have "\<dots> = setsum (\<lambda>y. setsum g {x. x \<in> S \<and> f x = y}) (f ` S)"
1.664      apply (rule setsum_setsum_restrict[OF fS])
1.665 @@ -1149,14 +1149,14 @@
1.666  lemma setsum_group:
1.667    assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \<subseteq> T"
1.668    shows "setsum (\<lambda>y. setsum g {x. x\<in> S \<and> f x = y}) T = setsum g S"
1.669 -
1.670 +
1.671  apply (subst setsum_image_gen[OF fS, of g f])
1.672  apply (rule setsum_mono_zero_right[OF fT fST])
1.673  by (auto intro: setsum_0')
1.674
1.675  lemma vsum_norm_allsubsets_bound:
1.676    fixes f:: "'a \<Rightarrow> real ^'n"
1.677 -  assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e"
1.678 +  assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e"
1.679    shows "setsum (\<lambda>x. norm (f x)) P \<le> 2 * real (dimindex(UNIV :: 'n set)) *  e"
1.680  proof-
1.681    let ?d = "real (dimindex (UNIV ::'n set))"
1.682 @@ -1183,9 +1183,9 @@
1.683      have Pne: "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pn \<le> e"
1.684        using i component_le_norm[OF i, of "setsum (\<lambda>x. - f x) ?Pn"]  fPs[OF PnP]
1.685        by (auto simp add: setsum_negf setsum_component vector_component intro: abs_le_D1)
1.686 -    have "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P = setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pp + setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pn"
1.687 +    have "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P = setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pp + setsum (\<lambda>x. \<bar>f x \$ i\<bar>) ?Pn"
1.688        apply (subst thp)
1.689 -      apply (rule setsum_Un_zero)
1.690 +      apply (rule setsum_Un_zero)
1.691        using fP thp0 by auto
1.692      also have "\<dots> \<le> 2*e" using Pne Ppe by arith
1.693      finally show "setsum (\<lambda>x. \<bar>f x \$ i\<bar>) P \<le> 2*e" .
1.694 @@ -1204,13 +1204,13 @@
1.695
1.696  definition "basis k = (\<chi> i. if i = k then 1 else 0)"
1.697
1.698 -lemma delta_mult_idempotent:
1.699 +lemma delta_mult_idempotent:
1.700    "(if k=a then 1 else (0::'a::semiring_1)) * (if k=a then 1 else 0) = (if k=a then 1 else 0)" by (cases "k=a", auto)
1.701
1.702  lemma norm_basis:
1.703    assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}"
1.704    shows "norm (basis k :: real ^'n) = 1"
1.705 -  using k
1.706 +  using k
1.707    apply (simp add: basis_def real_vector_norm_def dot_def)
1.708    apply (vector delta_mult_idempotent)
1.709    using setsum_delta[of "{1 .. dimindex (UNIV :: 'n set)}" "k" "\<lambda>k. 1::real"]
1.710 @@ -1228,7 +1228,7 @@
1.711    apply (rule exI[where x="c *s basis 1"])
1.712    by (simp only: norm_mul norm_basis_1)
1.713
1.714 -lemma vector_choose_dist: assumes e: "0 <= e"
1.715 +lemma vector_choose_dist: assumes e: "0 <= e"
1.716    shows "\<exists>(y::real^'n). dist x y = e"
1.717  proof-
1.718    from vector_choose_size[OF e] obtain c:: "real ^'n"  where "norm c = e"
1.719 @@ -1250,7 +1250,7 @@
1.720    "setsum (\<lambda>i. (x\$i) *s basis i) {1 .. dimindex (UNIV :: 'n set)} = (x::('a::ring_1) ^'n)" (is "?lhs = ?rhs" is "setsum ?f ?S = _")
1.721    by (auto simp add: Cart_eq basis_component[where ?'n = "'n"] setsum_component vector_component cond_value_iff setsum_delta[of "?S", where ?'b = "'a", simplified] cong del: if_weak_cong)
1.722
1.723 -lemma basis_expansion_unique:
1.724 +lemma basis_expansion_unique:
1.725    "setsum (\<lambda>i. f i *s basis i) {1 .. dimindex (UNIV :: 'n set)} = (x::('a::comm_ring_1) ^'n) \<longleftrightarrow> (\<forall>i\<in>{1 .. dimindex(UNIV:: 'n set)}. f i = x\$i)"
1.726    by (simp add: Cart_eq setsum_component vector_component basis_component setsum_delta cond_value_iff cong del: if_weak_cong)
1.727
1.728 @@ -1266,7 +1266,7 @@
1.729  lemma basis_eq_0: "basis i = (0::'a::semiring_1^'n) \<longleftrightarrow> i \<notin> {1..dimindex(UNIV ::'n set)}"
1.730    by (auto simp add: Cart_eq basis_component zero_index)
1.731
1.732 -lemma basis_nonzero:
1.733 +lemma basis_nonzero:
1.734    assumes k: "k \<in> {1 .. dimindex(UNIV ::'n set)}"
1.735    shows "basis k \<noteq> (0:: 'a::semiring_1 ^'n)"
1.736    using k by (simp add: basis_eq_0)
1.737 @@ -1294,15 +1294,15 @@
1.738  definition "orthogonal x y \<longleftrightarrow> (x \<bullet> y = 0)"
1.739
1.740  lemma orthogonal_basis:
1.741 -  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}"
1.742 +  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}"
1.743    shows "orthogonal (basis i :: 'a^'n) x \<longleftrightarrow> x\$i = (0::'a::ring_1)"
1.744    using i
1.745    by (auto simp add: orthogonal_def dot_def basis_def Cart_lambda_beta cond_value_iff cond_application_beta setsum_delta cong del: if_weak_cong)
1.746
1.747  lemma orthogonal_basis_basis:
1.748 -  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}"
1.749 -  and j: "j \<in> {1 .. dimindex(UNIV ::'n set)}"
1.750 -  shows "orthogonal (basis i :: 'a::ring_1^'n) (basis j) \<longleftrightarrow> i \<noteq> j"
1.751 +  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}"
1.752 +  and j: "j \<in> {1 .. dimindex(UNIV ::'n set)}"
1.753 +  shows "orthogonal (basis i :: 'a::ring_1^'n) (basis j) \<longleftrightarrow> i \<noteq> j"
1.754    unfolding orthogonal_basis[OF i] basis_component[OF i] by simp
1.755
1.756    (* FIXME : Maybe some of these require less than comm_ring, but not all*)
1.757 @@ -1443,14 +1443,14 @@
1.758
1.759  lemma linear_neg: "linear (f :: 'a::ring_1 ^'n \<Rightarrow> _) ==> f (-x) = - f x"
1.760    unfolding vector_sneg_minus1
1.761 -  using linear_cmul[of f] by auto
1.762 -
1.763 -lemma linear_add: "linear f ==> f(x + y) = f x + f y" by (metis linear_def)
1.764 +  using linear_cmul[of f] by auto
1.765 +
1.766 +lemma linear_add: "linear f ==> f(x + y) = f x + f y" by (metis linear_def)
1.767
1.768  lemma linear_sub: "linear (f::'a::ring_1 ^'n \<Rightarrow> _) ==> f(x - y) = f x - f y"
1.770
1.771 -lemma linear_setsum:
1.772 +lemma linear_setsum:
1.773    fixes f:: "'a::semiring_1^'n \<Rightarrow> _"
1.774    assumes lf: "linear f" and fS: "finite S"
1.775    shows "f (setsum g S) = setsum (f o g) S"
1.776 @@ -1470,7 +1470,7 @@
1.777    assumes lf: "linear f" and fS: "finite S"
1.778    shows "f (setsum (\<lambda>i. c i *s v i) S) = setsum (\<lambda>i. c i *s f (v i)) S"
1.779    using linear_setsum[OF lf fS, of "\<lambda>i. c i *s v i" , unfolded o_def]
1.780 -  linear_cmul[OF lf] by simp
1.781 +  linear_cmul[OF lf] by simp
1.782
1.783  lemma linear_injective_0:
1.784    assumes lf: "linear (f:: 'a::ring_1 ^ 'n \<Rightarrow> _)"
1.785 @@ -1478,7 +1478,7 @@
1.786  proof-
1.787    have "inj f \<longleftrightarrow> (\<forall> x y. f x = f y \<longrightarrow> x = y)" by (simp add: inj_on_def)
1.788    also have "\<dots> \<longleftrightarrow> (\<forall> x y. f x - f y = 0 \<longrightarrow> x - y = 0)" by simp
1.789 -  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f (x - y) = 0 \<longrightarrow> x - y = 0)"
1.790 +  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f (x - y) = 0 \<longrightarrow> x - y = 0)"
1.791      by (simp add: linear_sub[OF lf])
1.792    also have "\<dots> \<longleftrightarrow> (\<forall> x. f x = 0 \<longrightarrow> x = 0)" by auto
1.793    finally show ?thesis .
1.794 @@ -1518,7 +1518,7 @@
1.795    assumes lf: "linear f"
1.796    shows "\<exists>B > 0. \<forall>x. norm (f x) \<le> B * norm x"
1.797  proof-
1.798 -  from linear_bounded[OF lf] obtain B where
1.799 +  from linear_bounded[OF lf] obtain B where
1.800      B: "\<forall>x. norm (f x) \<le> B * norm x" by blast
1.801    let ?K = "\<bar>B\<bar> + 1"
1.802    have Kp: "?K > 0" by arith
1.803 @@ -1562,15 +1562,15 @@
1.804
1.805  lemma  (in ab_group_add) eq_add_iff: "x = x + y \<longleftrightarrow> y = 0"
1.806    using add_imp_eq[of x y 0] by auto
1.807 -
1.808 -lemma bilinear_lzero:
1.809 +
1.810 +lemma bilinear_lzero:
1.811    fixes h :: "'a::ring^'n \<Rightarrow> _" assumes bh: "bilinear h" shows "h 0 x = 0"
1.812 -  using bilinear_ladd[OF bh, of 0 0 x]
1.813 +  using bilinear_ladd[OF bh, of 0 0 x]
1.815
1.816 -lemma bilinear_rzero:
1.817 +lemma bilinear_rzero:
1.818    fixes h :: "'a::ring^'n \<Rightarrow> _" assumes bh: "bilinear h" shows "h x 0 = 0"
1.819 -  using bilinear_radd[OF bh, of x 0 0 ]
1.820 +  using bilinear_radd[OF bh, of x 0 0 ]
1.822
1.823  lemma bilinear_lsub: "bilinear h ==> h (x - (y:: 'a::ring_1 ^ 'n)) z = h x z - h y z"
1.824 @@ -1583,7 +1583,7 @@
1.825    fixes h:: "'a ^'n \<Rightarrow> 'a::semiring_1^'m \<Rightarrow> 'a ^ 'k"
1.826    assumes bh: "bilinear h" and fS: "finite S" and fT: "finite T"
1.827    shows "h (setsum f S) (setsum g T) = setsum (\<lambda>(i,j). h (f i) (g j)) (S \<times> T) "
1.828 -proof-
1.829 +proof-
1.830    have "h (setsum f S) (setsum g T) = setsum (\<lambda>x. h (f x) (setsum g T)) S"
1.831      apply (rule linear_setsum[unfolded o_def])
1.832      using bh fS by (auto simp add: bilinear_def)
1.833 @@ -1598,7 +1598,7 @@
1.834    fixes h:: "real ^'m \<Rightarrow> real^'n \<Rightarrow> real ^ 'k"
1.835    assumes bh: "bilinear h"
1.836    shows "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
1.837 -proof-
1.838 +proof-
1.839    let ?M = "{1 .. dimindex (UNIV :: 'm set)}"
1.840    let ?N = "{1 .. dimindex (UNIV :: 'n set)}"
1.841    let ?B = "setsum (\<lambda>(i,j). norm (h (basis i) (basis j))) (?M \<times> ?N)"
1.842 @@ -1626,7 +1626,7 @@
1.843    assumes bh: "bilinear h"
1.844    shows "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
1.845  proof-
1.846 -  from bilinear_bounded[OF bh] obtain B where
1.847 +  from bilinear_bounded[OF bh] obtain B where
1.848      B: "\<forall>x y. norm (h x y) \<le> B * norm x * norm y" by blast
1.849    let ?K = "\<bar>B\<bar> + 1"
1.850    have Kp: "?K > 0" by arith
1.851 @@ -1634,11 +1634,11 @@
1.852    {fix x::"real ^'m" and y :: "real ^'n"
1.853      from KB Kp
1.854      have "B * norm x * norm y \<le> ?K * norm x * norm y"
1.855 -      apply -
1.856 +      apply -
1.857        apply (rule mult_right_mono, rule mult_right_mono)
1.858        by (auto simp add: norm_ge_zero)
1.859      then have "norm (h x y) \<le> ?K * norm x * norm y"
1.860 -      using B[rule_format, of x y] by simp}
1.861 +      using B[rule_format, of x y] by simp}
1.862    with Kp show ?thesis by blast
1.863  qed
1.864
1.865 @@ -1663,14 +1663,14 @@
1.866        have "f x \<bullet> y = f (setsum (\<lambda>i. (x\$i) *s basis i) ?N) \<bullet> y"
1.867  	by (simp only: basis_expansion)
1.868        also have "\<dots> = (setsum (\<lambda>i. (x\$i) *s f (basis i)) ?N) \<bullet> y"
1.869 -	unfolding linear_setsum[OF lf fN]
1.870 +	unfolding linear_setsum[OF lf fN]
1.871  	by (simp add: linear_cmul[OF lf])
1.872        finally have "f x \<bullet> y = x \<bullet> ?w"
1.873  	apply (simp only: )
1.874  	apply (simp add: dot_def setsum_component Cart_lambda_beta setsum_left_distrib setsum_right_distrib vector_component setsum_commute[of _ ?M ?N] ring_simps del: One_nat_def)
1.875  	done}
1.876    }
1.877 -  then show ?thesis unfolding adjoint_def
1.878 +  then show ?thesis unfolding adjoint_def
1.879      some_eq_ex[of "\<lambda>f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y"]
1.880      using choice_iff[of "\<lambda>a b. \<forall>x. f x \<bullet> a = x \<bullet> b "]
1.881      by metis
1.882 @@ -1715,27 +1715,27 @@
1.883
1.884  consts generic_mult :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" (infixr "\<star>" 75)
1.885
1.888  matrix_matrix_mult_def: "(m:: ('a::semiring_1) ^'n^'m) \<star> (m' :: 'a ^'p^'n) \<equiv> (\<chi> i j. setsum (\<lambda>k. ((m\$i)\$k) * ((m'\$k)\$j)) {1 .. dimindex (UNIV :: 'n set)}) ::'a ^ 'p ^'m"
1.889
1.890 -abbreviation
1.891 +abbreviation
1.892    matrix_matrix_mult' :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'p^'n \<Rightarrow> 'a ^ 'p ^'m"  (infixl "**" 70)
1.893    where "m ** m' == m\<star> m'"
1.894
1.897    matrix_vector_mult_def: "(m::('a::semiring_1) ^'n^'m) \<star> (x::'a ^'n) \<equiv> (\<chi> i. setsum (\<lambda>j. ((m\$i)\$j) * (x\$j)) {1..dimindex(UNIV ::'n set)}) :: 'a^'m"
1.898
1.899 -abbreviation
1.900 +abbreviation
1.901    matrix_vector_mult' :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n \<Rightarrow> 'a ^ 'm"  (infixl "*v" 70)
1.902 -  where
1.903 +  where
1.904    "m *v v == m \<star> v"
1.905
1.908    vector_matrix_mult_def: "(x::'a^'m) \<star> (m::('a::semiring_1) ^'n^'m) \<equiv> (\<chi> j. setsum (\<lambda>i. ((m\$i)\$j) * (x\$i)) {1..dimindex(UNIV :: 'm set)}) :: 'a^'n"
1.909
1.910 -abbreviation
1.911 +abbreviation
1.912    vactor_matrix_mult' :: "'a ^ 'm \<Rightarrow> ('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n "  (infixl "v*" 70)
1.913 -  where
1.914 +  where
1.915    "v v* m == v \<star> m"
1.916
1.917  definition "(mat::'a::zero => 'a ^'n^'m) k = (\<chi> i j. if i = j then k else 0)"
1.918 @@ -1749,11 +1749,11 @@
1.919  lemma matrix_add_ldistrib: "(A ** (B + C)) = (A \<star> B) + (A \<star> C)"
1.920    by (vector matrix_matrix_mult_def setsum_addf[symmetric] ring_simps)
1.921
1.922 -lemma setsum_delta':
1.923 -  assumes fS: "finite S" shows
1.924 -  "setsum (\<lambda>k. if a = k then b k else 0) S =
1.925 +lemma setsum_delta':
1.926 +  assumes fS: "finite S" shows
1.927 +  "setsum (\<lambda>k. if a = k then b k else 0) S =
1.928       (if a\<in> S then b a else 0)"
1.929 -  using setsum_delta[OF fS, of a b, symmetric]
1.930 +  using setsum_delta[OF fS, of a b, symmetric]
1.931    by (auto intro: setsum_cong)
1.932
1.933  lemma matrix_mul_lid: "mat 1 ** A = A"
1.934 @@ -1781,7 +1781,7 @@
1.935
1.936  lemma matrix_vector_mul_lid: "mat 1 *v x = x"
1.937    apply (vector matrix_vector_mult_def mat_def)
1.938 -  by (simp add: cond_value_iff cond_application_beta
1.939 +  by (simp add: cond_value_iff cond_application_beta
1.940      setsum_delta' cong del: if_weak_cong)
1.941
1.942  lemma matrix_transp_mul: "transp(A ** B) = transp B ** transp (A::'a::comm_semiring_1^'m^'n)"
1.943 @@ -1796,7 +1796,7 @@
1.944    apply (erule_tac x="i" in ballE)
1.945    by (auto simp add: basis_def cond_value_iff cond_application_beta Cart_lambda_beta setsum_delta[OF finite_atLeastAtMost] cong del: if_weak_cong)
1.946
1.947 -lemma matrix_vector_mul_component:
1.948 +lemma matrix_vector_mul_component:
1.949    assumes k: "k \<in> {1.. dimindex (UNIV :: 'm set)}"
1.950    shows "((A::'a::semiring_1^'n'^'m) *v x)\$k = (A\$k) \<bullet> x"
1.951    using k
1.952 @@ -1813,18 +1813,18 @@
1.953  lemma transp_transp: "transp(transp A) = A"
1.954    by (vector transp_def)
1.955
1.956 -lemma row_transp:
1.957 +lemma row_transp:
1.958    fixes A:: "'a::semiring_1^'n^'m"
1.959    assumes i: "i \<in> {1.. dimindex (UNIV :: 'n set)}"
1.960    shows "row i (transp A) = column i A"
1.961 -  using i
1.962 +  using i
1.963    by (simp add: row_def column_def transp_def Cart_eq Cart_lambda_beta)
1.964
1.965  lemma column_transp:
1.966    fixes A:: "'a::semiring_1^'n^'m"
1.967    assumes i: "i \<in> {1.. dimindex (UNIV :: 'm set)}"
1.968    shows "column i (transp A) = row i A"
1.969 -  using i
1.970 +  using i
1.971    by (simp add: row_def column_def transp_def Cart_eq Cart_lambda_beta)
1.972
1.973  lemma rows_transp: "rows(transp (A::'a::semiring_1^'n^'m)) = columns A"
1.974 @@ -1890,8 +1890,8 @@
1.975  lemma matrix_of_matrix_vector_mul: "matrix(\<lambda>x. A *v (x :: 'a:: comm_ring_1 ^ 'n)) = A"
1.976    by (simp add: matrix_eq matrix_vector_mul_linear matrix_works)
1.977
1.978 -lemma matrix_compose:
1.979 -  assumes lf: "linear (f::'a::comm_ring_1^'n \<Rightarrow> _)" and lg: "linear g"
1.980 +lemma matrix_compose:
1.981 +  assumes lf: "linear (f::'a::comm_ring_1^'n \<Rightarrow> _)" and lg: "linear g"
1.982    shows "matrix (g o f) = matrix g ** matrix f"
1.983    using lf lg linear_compose[OF lf lg] matrix_works[OF linear_compose[OF lf lg]]
1.984    by (simp  add: matrix_eq matrix_works matrix_vector_mul_assoc[symmetric] o_def)
1.985 @@ -1923,9 +1923,9 @@
1.986    done
1.987
1.988
1.989 -lemma real_convex_bound_lt:
1.990 +lemma real_convex_bound_lt:
1.991    assumes xa: "(x::real) < a" and ya: "y < a" and u: "0 <= u" and v: "0 <= v"
1.992 -  and uv: "u + v = 1"
1.993 +  and uv: "u + v = 1"
1.994    shows "u * x + v * y < a"
1.995  proof-
1.996    have uv': "u = 0 \<longrightarrow> v \<noteq> 0" using u v uv by arith
1.997 @@ -1937,7 +1937,7 @@
1.998      apply (cases "u = 0", simp_all add: uv')
1.999      apply(rule mult_strict_left_mono)
1.1000      using uv' apply simp_all
1.1001 -
1.1002 +
1.1004      apply(rule mult_strict_left_mono)
1.1005      apply simp_all
1.1006 @@ -1947,9 +1947,9 @@
1.1007    thus ?thesis unfolding th .
1.1008  qed
1.1009
1.1010 -lemma real_convex_bound_le:
1.1011 +lemma real_convex_bound_le:
1.1012    assumes xa: "(x::real) \<le> a" and ya: "y \<le> a" and u: "0 <= u" and v: "0 <= v"
1.1013 -  and uv: "u + v = 1"
1.1014 +  and uv: "u + v = 1"
1.1015    shows "u * x + v * y \<le> a"
1.1016  proof-
1.1017    from xa ya u v have "u * x + v * y \<le> u * a + v * a" by (simp add: add_mono mult_left_mono)
1.1018 @@ -1969,7 +1969,7 @@
1.1019  done
1.1020
1.1021
1.1022 -lemma triangle_lemma:
1.1023 +lemma triangle_lemma:
1.1024    assumes x: "0 <= (x::real)" and y:"0 <= y" and z: "0 <= z" and xy: "x^2 <= y^2 + z^2"
1.1025    shows "x <= y + z"
1.1026  proof-
1.1027 @@ -1992,12 +1992,12 @@
1.1028      let ?x = "(\<chi> i. (f i)) :: 'a ^ 'n"
1.1029      {fix i assume i: "i \<in> ?S"
1.1030        with f i have "P i (f i)" by metis
1.1031 -      then have "P i (?x\$i)" using Cart_lambda_beta[of f, rule_format, OF i] by auto
1.1032 +      then have "P i (?x\$i)" using Cart_lambda_beta[of f, rule_format, OF i] by auto
1.1033      }
1.1034      hence "\<forall>i \<in> ?S. P i (?x\$i)" by metis
1.1035      hence ?rhs by metis }
1.1036    ultimately show ?thesis by metis
1.1037 -qed
1.1038 +qed
1.1039
1.1040  (* Supremum and infimum of real sets *)
1.1041
1.1042 @@ -2019,7 +2019,7 @@
1.1043  lemma rsup_le: assumes Se: "S \<noteq> {}" and Sb: "S *<= b" shows "rsup S \<le> b"
1.1044  proof-
1.1045    from Sb have bu: "isUb UNIV S b" by (simp add: isUb_def setle_def)
1.1046 -  from rsup[OF Se] Sb have "isLub UNIV S (rsup S)"  by blast
1.1047 +  from rsup[OF Se] Sb have "isLub UNIV S (rsup S)"  by blast
1.1048    then show ?thesis using bu by (auto simp add: isLub_def leastP_def setle_def setge_def)
1.1049  qed
1.1050
1.1051 @@ -2030,12 +2030,12 @@
1.1052    let ?m = "Max S"
1.1053    from Max_ge[OF fS] have Sm: "\<forall> x\<in> S. x \<le> ?m" by metis
1.1054    with rsup[OF Se] have lub: "isLub UNIV S (rsup S)" by (metis setle_def)
1.1055 -  from Max_in[OF fS Se] lub have mrS: "?m \<le> rsup S"
1.1056 +  from Max_in[OF fS Se] lub have mrS: "?m \<le> rsup S"
1.1057      by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def)
1.1058 -  moreover
1.1059 +  moreover
1.1060    have "rsup S \<le> ?m" using Sm lub
1.1061      by (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
1.1062 -  ultimately  show ?thesis by arith
1.1063 +  ultimately  show ?thesis by arith
1.1064  qed
1.1065
1.1066  lemma rsup_finite_in: assumes fS: "finite S" and Se: "S \<noteq> {}"
1.1067 @@ -2065,7 +2065,7 @@
1.1068
1.1069  lemma rsup_unique: assumes b: "S *<= b" and S: "\<forall>b' < b. \<exists>x \<in> S. b' < x"
1.1070    shows "rsup S = b"
1.1071 -using b S
1.1072 +using b S
1.1073  unfolding setle_def rsup_alt
1.1074  apply -
1.1075  apply (rule some_equality)
1.1076 @@ -2104,7 +2104,7 @@
1.1077  lemma rsup_asclose: assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>rsup S - l\<bar> \<le> e"
1.1078  proof-
1.1079    have th: "\<And>(x::real) l e. \<bar>x - l\<bar> \<le> e \<longleftrightarrow> l - e \<le> x \<and> x \<le> l + e" by arith
1.1080 -  show ?thesis using S b rsup_bounds[of S "l - e" "l+e"] unfolding th
1.1081 +  show ?thesis using S b rsup_bounds[of S "l - e" "l+e"] unfolding th
1.1082      by  (auto simp add: setge_def setle_def)
1.1083  qed
1.1084
1.1085 @@ -2142,7 +2142,7 @@
1.1086  lemma rinf_ge: assumes Se: "S \<noteq> {}" and Sb: "b <=* S" shows "rinf S \<ge> b"
1.1087  proof-
1.1088    from Sb have bu: "isLb UNIV S b" by (simp add: isLb_def setge_def)
1.1089 -  from rinf[OF Se] Sb have "isGlb UNIV S (rinf S)"  by blast
1.1090 +  from rinf[OF Se] Sb have "isGlb UNIV S (rinf S)"  by blast
1.1091    then show ?thesis using bu by (auto simp add: isGlb_def greatestP_def setle_def setge_def)
1.1092  qed
1.1093
1.1094 @@ -2153,12 +2153,12 @@
1.1095    let ?m = "Min S"
1.1096    from Min_le[OF fS] have Sm: "\<forall> x\<in> S. x \<ge> ?m" by metis
1.1097    with rinf[OF Se] have glb: "isGlb UNIV S (rinf S)" by (metis setge_def)
1.1098 -  from Min_in[OF fS Se] glb have mrS: "?m \<ge> rinf S"
1.1099 +  from Min_in[OF fS Se] glb have mrS: "?m \<ge> rinf S"
1.1100      by (auto simp add: isGlb_def greatestP_def setle_def setge_def isLb_def)
1.1101 -  moreover
1.1102 +  moreover
1.1103    have "rinf S \<ge> ?m" using Sm glb
1.1104      by (auto simp add: isGlb_def greatestP_def isLb_def setle_def setge_def)
1.1105 -  ultimately  show ?thesis by arith
1.1106 +  ultimately  show ?thesis by arith
1.1107  qed
1.1108
1.1109  lemma rinf_finite_in: assumes fS: "finite S" and Se: "S \<noteq> {}"
1.1110 @@ -2188,7 +2188,7 @@
1.1111
1.1112  lemma rinf_unique: assumes b: "b <=* S" and S: "\<forall>b' > b. \<exists>x \<in> S. b' > x"
1.1113    shows "rinf S = b"
1.1114 -using b S
1.1115 +using b S
1.1116  unfolding setge_def rinf_alt
1.1117  apply -
1.1118  apply (rule some_equality)
1.1119 @@ -2226,7 +2226,7 @@
1.1120  lemma rinf_asclose: assumes S:"S \<noteq> {}" and b: "\<forall>x\<in>S. \<bar>x - l\<bar> \<le> e" shows "\<bar>rinf S - l\<bar> \<le> e"
1.1121  proof-
1.1122    have th: "\<And>(x::real) l e. \<bar>x - l\<bar> \<le> e \<longleftrightarrow> l - e \<le> x \<and> x \<le> l + e" by arith
1.1123 -  show ?thesis using S b rinf_bounds[of S "l - e" "l+e"] unfolding th
1.1124 +  show ?thesis using S b rinf_bounds[of S "l - e" "l+e"] unfolding th
1.1125      by  (auto simp add: setge_def setle_def)
1.1126  qed
1.1127
1.1128 @@ -2248,7 +2248,7 @@
1.1129
1.1130    moreover
1.1131    {assume H: ?lhs
1.1132 -    from H[rule_format, of "basis 1"]
1.1133 +    from H[rule_format, of "basis 1"]
1.1134      have bp: "b \<ge> 0" using norm_ge_zero[of "f (basis 1)"] dimindex_ge_1[of "UNIV:: 'n set"]
1.1135        by (auto simp add: norm_basis elim: order_trans [OF norm_ge_zero])
1.1136      {fix x :: "real ^'n"
1.1137 @@ -2260,9 +2260,9 @@
1.1138  	let ?c = "1/ norm x"
1.1139  	have "norm (?c*s x) = 1" using x0 by (simp add: n0 norm_mul)
1.1140  	with H have "norm (f(?c*s x)) \<le> b" by blast
1.1141 -	hence "?c * norm (f x) \<le> b"
1.1142 +	hence "?c * norm (f x) \<le> b"
1.1143  	  by (simp add: linear_cmul[OF lf] norm_mul)
1.1144 -	hence "norm (f x) \<le> b * norm x"
1.1145 +	hence "norm (f x) \<le> b * norm x"
1.1146  	  using n0 norm_ge_zero[of x] by (auto simp add: field_simps)}
1.1147        ultimately have "norm (f x) \<le> b * norm x" by blast}
1.1148      then have ?rhs by blast}
1.1149 @@ -2278,16 +2278,16 @@
1.1150    {
1.1151      let ?S = "{norm (f x) |x. norm x = 1}"
1.1152      have Se: "?S \<noteq> {}" using  norm_basis_1 by auto
1.1153 -    from linear_bounded[OF lf] have b: "\<exists> b. ?S *<= b"
1.1154 +    from linear_bounded[OF lf] have b: "\<exists> b. ?S *<= b"
1.1155        unfolding norm_bound_generalize[OF lf, symmetric] by (auto simp add: setle_def)
1.1156      {from rsup[OF Se b, unfolded onorm_def[symmetric]]
1.1157 -      show "norm (f x) <= onorm f * norm x"
1.1158 -	apply -
1.1159 +      show "norm (f x) <= onorm f * norm x"
1.1160 +	apply -
1.1161  	apply (rule spec[where x = x])
1.1162  	unfolding norm_bound_generalize[OF lf, symmetric]
1.1163  	by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)}
1.1164      {
1.1165 -      show "\<forall>x. norm (f x) <= b * norm x \<Longrightarrow> onorm f <= b"
1.1166 +      show "\<forall>x. norm (f x) <= b * norm x \<Longrightarrow> onorm f <= b"
1.1167  	using rsup[OF Se b, unfolded onorm_def[symmetric]]
1.1168  	unfolding norm_bound_generalize[OF lf, symmetric]
1.1169  	by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)}
1.1170 @@ -2297,7 +2297,7 @@
1.1171  lemma onorm_pos_le: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)" shows "0 <= onorm f"
1.1172    using order_trans[OF norm_ge_zero onorm(1)[OF lf, of "basis 1"], unfolded norm_basis_1] by simp
1.1173
1.1174 -lemma onorm_eq_0: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)"
1.1175 +lemma onorm_eq_0: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)"
1.1176    shows "onorm f = 0 \<longleftrightarrow> (\<forall>x. f x = 0)"
1.1177    using onorm[OF lf]
1.1178    apply (auto simp add: onorm_pos_le)
1.1179 @@ -2317,7 +2317,7 @@
1.1180      apply (rule rsup_unique) by (simp_all  add: setle_def)
1.1181  qed
1.1182
1.1183 -lemma onorm_pos_lt: assumes lf: "linear (f::real ^ 'n \<Rightarrow> real ^'m)"
1.1184 +lemma onorm_pos_lt: assumes lf: "linear (f::real ^ 'n \<Rightarrow> real ^'m)"
1.1185    shows "0 < onorm f \<longleftrightarrow> ~(\<forall>x. f x = 0)"
1.1186    unfolding onorm_eq_0[OF lf, symmetric]
1.1187    using onorm_pos_le[OF lf] by arith
1.1188 @@ -2374,7 +2374,7 @@
1.1189
1.1190  definition vec1:: "'a \<Rightarrow> 'a ^ 1" where "vec1 x = (\<chi> i. x)"
1.1191
1.1192 -definition dest_vec1:: "'a ^1 \<Rightarrow> 'a"
1.1193 +definition dest_vec1:: "'a ^1 \<Rightarrow> 'a"
1.1194    where "dest_vec1 x = (x\$1)"
1.1195
1.1196  lemma vec1_component[simp]: "(vec1 x)\$1 = x"
1.1197 @@ -2385,7 +2385,7 @@
1.1198
1.1199  lemma forall_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (vec1 x))" by (metis vec1_dest_vec1)
1.1200
1.1201 -lemma exists_vec1: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P(vec1 x))" by (metis vec1_dest_vec1)
1.1202 +lemma exists_vec1: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P(vec1 x))" by (metis vec1_dest_vec1)
1.1203
1.1204  lemma forall_dest_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P(dest_vec1 x))"  by (metis vec1_dest_vec1)
1.1205
1.1206 @@ -2446,7 +2446,7 @@
1.1207  lemma abs_dest_vec1: "norm x = \<bar>dest_vec1 x\<bar>"
1.1208    by (metis vec1_dest_vec1 norm_vec1)
1.1209
1.1210 -lemma linear_vmul_dest_vec1:
1.1211 +lemma linear_vmul_dest_vec1:
1.1212    fixes f:: "'a::semiring_1^'n \<Rightarrow> 'a^1"
1.1213    shows "linear f \<Longrightarrow> linear (\<lambda>x. dest_vec1(f x) *s v)"
1.1214    unfolding dest_vec1_def
1.1215 @@ -2563,10 +2563,10 @@
1.1216    have th_0: "1 \<le> ?n +1" by simp
1.1217    have th0: "norm x = norm (pastecart (fstcart x) (sndcart x))"
1.1219 -  have th1: "fstcart x \<bullet> fstcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
1.1220 +  have th1: "fstcart x \<bullet> fstcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
1.1221      by (simp add: dot_def setsum_add_split[OF th_0, of _ ?m] pastecart_def dimindex_finite_sum Cart_lambda_beta setsum_nonneg zero_le_square del: One_nat_def)
1.1222    then show ?thesis
1.1223 -    unfolding th0
1.1224 +    unfolding th0
1.1225      unfolding real_vector_norm_def real_sqrt_le_iff id_def
1.1226      by (simp add: dot_def dimindex_finite_sum Cart_lambda_beta)
1.1227  qed
1.1228 @@ -2592,13 +2592,13 @@
1.1229      using dimindex_nonzero[of "UNIV :: 'n set"] dimindex_nonzero[of "UNIV :: 'm set"]
1.1230      apply (simp add: Ball_def atLeastAtMost_iff inj_on_def dimindex_finite_sum del: One_nat_def)
1.1231      by arith
1.1232 -  have fS: "?f ` ?S = ?M"
1.1233 +  have fS: "?f ` ?S = ?M"
1.1234      apply (rule set_ext)
1.1235      apply (simp add: image_iff Bex_def) using dimindex_nonzero[of "UNIV :: 'n set"] dimindex_nonzero[of "UNIV :: 'm set"] by arith
1.1236 -  have th1: "sndcart x \<bullet> sndcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
1.1237 -    by (simp add: dot_def setsum_add_split[OF th_0, of _ ?m] pastecart_def dimindex_finite_sum Cart_lambda_beta setsum_nonneg zero_le_square setsum_reindex[OF finj, unfolded fS] del: One_nat_def)
1.1238 +  have th1: "sndcart x \<bullet> sndcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
1.1239 +    by (simp add: dot_def setsum_add_split[OF th_0, of _ ?m] pastecart_def dimindex_finite_sum Cart_lambda_beta setsum_nonneg zero_le_square setsum_reindex[OF finj, unfolded fS] del: One_nat_def)
1.1240    then show ?thesis
1.1241 -    unfolding th0
1.1242 +    unfolding th0
1.1243      unfolding real_vector_norm_def real_sqrt_le_iff id_def
1.1244      by (simp add: dot_def dimindex_finite_sum Cart_lambda_beta)
1.1245  qed
1.1246 @@ -2644,14 +2644,14 @@
1.1247      done
1.1248    let ?r = "\<lambda>n. n - ?n"
1.1249    have rinj: "inj_on ?r ?S" apply (simp add: inj_on_def Ball_def thnm) by arith
1.1250 -  have rS: "?r ` ?S = ?M" apply (rule set_ext)
1.1251 +  have rS: "?r ` ?S = ?M" apply (rule set_ext)
1.1252      apply (simp add: thnm image_iff Bex_def) by arith
1.1253    have "pastecart x1 x2 \<bullet> (pastecart y1 y2) = setsum ?g ?NM" by (simp add: dot_def)
1.1254    also have "\<dots> = setsum ?g ?N + setsum ?g ?S"
1.1255      by (simp add: dot_def thnm setsum_add_split[OF th_0, of _ ?m] del: One_nat_def)
1.1256    also have "\<dots> = setsum (?f x1 y1) ?N + setsum (?f x2 y2) ?M"
1.1257      unfolding setsum_reindex[OF rinj, unfolded rS o_def] th2 th3 ..
1.1258 -  finally
1.1259 +  finally
1.1260    show ?thesis by (simp add: dot_def)
1.1261  qed
1.1262
1.1263 @@ -2679,7 +2679,7 @@
1.1264  unfolding hull_def subset_iff by auto
1.1265
1.1266  lemma hull_eq: "(\<And>T. T \<subseteq> S ==> Inter T \<in> S) ==> (S hull s) = s \<longleftrightarrow> s \<in> S"
1.1267 -using hull_same[of s S] hull_in[of S s] by metis
1.1268 +using hull_same[of s S] hull_in[of S s] by metis
1.1269
1.1270
1.1271  lemma hull_hull: "S hull (S hull s) = S hull s"
1.1272 @@ -2749,12 +2749,12 @@
1.1273  lemma real_pow_lbound: "0 <= x ==> 1 + real n * x <= (1 + x) ^ n"
1.1274  proof(induct n)
1.1275    case 0 thus ?case by simp
1.1276 -next
1.1277 +next
1.1278    case (Suc n)
1.1279    hence h: "1 + real n * x \<le> (1 + x) ^ n" by simp
1.1280    from h have p: "1 \<le> (1 + x) ^ n" using Suc.prems by simp
1.1281    from h have "1 + real n * x + x \<le> (1 + x) ^ n + x" by simp
1.1282 -  also have "\<dots> \<le> (1 + x) ^ Suc n" apply (subst diff_le_0_iff_le[symmetric])
1.1283 +  also have "\<dots> \<le> (1 + x) ^ Suc n" apply (subst diff_le_0_iff_le[symmetric])
1.1285      using mult_left_mono[OF p Suc.prems] by simp
1.1286    finally show ?case  by (simp add: real_of_nat_Suc ring_simps)
1.1287 @@ -2763,13 +2763,13 @@
1.1288  lemma real_arch_pow: assumes x: "1 < (x::real)" shows "\<exists>n. y < x^n"
1.1289  proof-
1.1290    from x have x0: "x - 1 > 0" by arith
1.1291 -  from real_arch[OF x0, rule_format, of y]
1.1292 +  from real_arch[OF x0, rule_format, of y]
1.1293    obtain n::nat where n:"y < real n * (x - 1)" by metis
1.1294    from x0 have x00: "x- 1 \<ge> 0" by arith
1.1295 -  from real_pow_lbound[OF x00, of n] n
1.1296 +  from real_pow_lbound[OF x00, of n] n
1.1297    have "y < x^n" by auto
1.1298    then show ?thesis by metis
1.1299 -qed
1.1300 +qed
1.1301
1.1302  lemma real_arch_pow2: "\<exists>n. (x::real) < 2^ n"
1.1303    using real_arch_pow[of 2 x] by simp
1.1304 @@ -2777,13 +2777,13 @@
1.1305  lemma real_arch_pow_inv: assumes y: "(y::real) > 0" and x1: "x < 1"
1.1306    shows "\<exists>n. x^n < y"
1.1307  proof-
1.1308 -  {assume x0: "x > 0"
1.1309 +  {assume x0: "x > 0"
1.1310      from x0 x1 have ix: "1 < 1/x" by (simp add: field_simps)
1.1311      from real_arch_pow[OF ix, of "1/y"]
1.1312      obtain n where n: "1/y < (1/x)^n" by blast
1.1313 -    then
1.1314 +    then
1.1315      have ?thesis using y x0 by (auto simp add: field_simps power_divide) }
1.1316 -  moreover
1.1317 +  moreover
1.1318    {assume "\<not> x > 0" with y x1 have ?thesis apply auto by (rule exI[where x=1], auto)}
1.1319    ultimately show ?thesis by metis
1.1320  qed
1.1321 @@ -2821,18 +2821,18 @@
1.1322    have "max x y \<le> rsup {x,y}" using rsup_finite_ge_iff[OF f, of "max x y"]
1.1324    ultimately show ?thesis by arith
1.1325 -qed
1.1326 +qed
1.1327
1.1328  lemma real_min_rinf: "min x y = rinf {x,y}"
1.1329  proof-
1.1330    have f: "finite {x, y}" "{x,y} \<noteq> {}"  by simp_all
1.1331 -  from rinf_finite_le_iff[OF f, of "min x y"] have "rinf {x,y} \<le> min x y"
1.1332 +  from rinf_finite_le_iff[OF f, of "min x y"] have "rinf {x,y} \<le> min x y"
1.1334    moreover
1.1335    have "min x y \<le> rinf {x,y}" using rinf_finite_ge_iff[OF f, of "min x y"]
1.1336      by simp
1.1337    ultimately show ?thesis by arith
1.1338 -qed
1.1339 +qed
1.1340
1.1341  (* ------------------------------------------------------------------------- *)
1.1342  (* Geometric progression.                                                    *)
1.1343 @@ -2863,9 +2863,9 @@
1.1344    from mn have mn': "n - m \<ge> 0" by arith
1.1345    let ?f = "op + m"
1.1346    have i: "inj_on ?f ?S" unfolding inj_on_def by auto
1.1347 -  have f: "?f ` ?S = {m..n}"
1.1348 +  have f: "?f ` ?S = {m..n}"
1.1349      using mn apply (auto simp add: image_iff Bex_def) by arith
1.1350 -  have th: "op ^ x o op + m = (\<lambda>i. x^m * x^i)"
1.1351 +  have th: "op ^ x o op + m = (\<lambda>i. x^m * x^i)"
1.1353    from setsum_reindex[OF i, of "op ^ x", unfolded f th setsum_right_distrib[symmetric]]
1.1354    have "?lhs = x^m * ((1 - x) * setsum (op ^ x) {0..n - m})" by simp
1.1355 @@ -2873,8 +2873,8 @@
1.1357  qed
1.1358
1.1359 -lemma sum_gp: "setsum (op ^ (x::'a::{field, recpower})) {m .. n} =
1.1360 -   (if n < m then 0 else if x = 1 then of_nat ((n + 1) - m)
1.1361 +lemma sum_gp: "setsum (op ^ (x::'a::{field, recpower})) {m .. n} =
1.1362 +   (if n < m then 0 else if x = 1 then of_nat ((n + 1) - m)
1.1363                      else (x^ m - x^ (Suc n)) / (1 - x))"
1.1364  proof-
1.1365    {assume nm: "n < m" hence ?thesis by simp}
1.1366 @@ -2889,7 +2889,7 @@
1.1367    ultimately show ?thesis by metis
1.1368  qed
1.1369
1.1370 -lemma sum_gp_offset: "setsum (op ^ (x::'a::{field,recpower})) {m .. m+n} =
1.1371 +lemma sum_gp_offset: "setsum (op ^ (x::'a::{field,recpower})) {m .. m+n} =
1.1372    (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))"
1.1373    unfolding sum_gp[of x m "m + n"] power_Suc
1.1375 @@ -2908,7 +2908,7 @@
1.1376
1.1377  lemma subspace_0: "subspace S ==> 0 \<in> S" by (metis subspace_def)
1.1378
1.1379 -lemma subspace_add: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S ==> x + y \<in> S"
1.1380 +lemma subspace_add: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S ==> x + y \<in> S"
1.1381    by (metis subspace_def)
1.1382
1.1383  lemma subspace_mul: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> c *s x \<in> S"
1.1384 @@ -2926,10 +2926,10 @@
1.1385    shows "setsum f B \<in> A"
1.1386    using  fB f sA
1.1387    apply(induct rule: finite_induct[OF fB])
1.1389 -
1.1390 -lemma subspace_linear_image:
1.1391 -  assumes lf: "linear (f::'a::semiring_1^'n \<Rightarrow> _)" and sS: "subspace S"
1.1393 +
1.1394 +lemma subspace_linear_image:
1.1395 +  assumes lf: "linear (f::'a::semiring_1^'n \<Rightarrow> _)" and sS: "subspace S"
1.1396    shows "subspace(f ` S)"
1.1397    using lf sS linear_0[OF lf]
1.1398    unfolding linear_def subspace_def
1.1399 @@ -2986,7 +2986,7 @@
1.1400    from SP have SP': "S \<subseteq> P" by (simp add: mem_def subset_eq)
1.1401    from P have P': "P \<in> subspace" by (simp add: mem_def)
1.1402    from x hull_minimal[OF SP' P', unfolded span_def[symmetric]]
1.1403 -  show "P x" by (metis mem_def subset_eq)
1.1404 +  show "P x" by (metis mem_def subset_eq)
1.1405  qed
1.1406
1.1407  lemma span_empty: "span {} = {(0::'a::semiring_0 ^ 'n)}"
1.1408 @@ -3016,11 +3016,11 @@
1.1409    using span_induct SP P by blast
1.1410
1.1411  inductive span_induct_alt_help for S:: "'a::semiring_1^'n \<Rightarrow> bool"
1.1412 -  where
1.1413 +  where
1.1414    span_induct_alt_help_0: "span_induct_alt_help S 0"
1.1415    | span_induct_alt_help_S: "x \<in> S \<Longrightarrow> span_induct_alt_help S z \<Longrightarrow> span_induct_alt_help S (c *s x + z)"
1.1416
1.1417 -lemma span_induct_alt':
1.1418 +lemma span_induct_alt':
1.1419    assumes h0: "h (0::'a::semiring_1^'n)" and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c*s x + y)" shows "\<forall>x \<in> span S. h x"
1.1420  proof-
1.1421    {fix x:: "'a^'n" assume x: "span_induct_alt_help S x"
1.1422 @@ -3031,7 +3031,7 @@
1.1423        done}
1.1424    note th0 = this
1.1425    {fix x assume x: "x \<in> span S"
1.1426 -
1.1427 +
1.1428      have "span_induct_alt_help S x"
1.1429        proof(rule span_induct[where x=x and S=S])
1.1430  	show "x \<in> span S" using x .
1.1431 @@ -3043,7 +3043,7 @@
1.1432  	have "span_induct_alt_help S 0" by (rule span_induct_alt_help_0)
1.1433  	moreover
1.1434  	{fix x y assume h: "span_induct_alt_help S x" "span_induct_alt_help S y"
1.1435 -	  from h
1.1436 +	  from h
1.1437  	  have "span_induct_alt_help S (x + y)"
1.1438  	    apply (induct rule: span_induct_alt_help.induct)
1.1439  	    apply simp
1.1440 @@ -3054,7 +3054,7 @@
1.1441  	    done}
1.1442  	moreover
1.1443  	{fix c x assume xt: "span_induct_alt_help S x"
1.1444 -	  then have "span_induct_alt_help S (c*s x)"
1.1445 +	  then have "span_induct_alt_help S (c*s x)"
1.1446  	    apply (induct rule: span_induct_alt_help.induct)
1.1449 @@ -3063,13 +3063,13 @@
1.1450  	    apply simp
1.1451  	    done
1.1452  	}
1.1453 -	ultimately show "subspace (span_induct_alt_help S)"
1.1454 +	ultimately show "subspace (span_induct_alt_help S)"
1.1455  	  unfolding subspace_def mem_def Ball_def by blast
1.1456        qed}
1.1457    with th0 show ?thesis by blast
1.1458 -qed
1.1459 -
1.1460 -lemma span_induct_alt:
1.1461 +qed
1.1462 +
1.1463 +lemma span_induct_alt:
1.1464    assumes h0: "h (0::'a::semiring_1^'n)" and hS: "\<And>c x y. x \<in> S \<Longrightarrow> h y \<Longrightarrow> h (c*s x + y)" and x: "x \<in> span S"
1.1465    shows "h x"
1.1466  using span_induct_alt'[of h S] h0 hS x by blast
1.1467 @@ -3118,9 +3118,9 @@
1.1468        apply (rule subspace_span)
1.1469        apply (rule x)
1.1470        done}
1.1471 -  moreover
1.1472 +  moreover
1.1473    {fix x assume x: "x \<in> span S"
1.1474 -    have th0:"(\<lambda>a. f a \<in> span (f ` S)) = {x. f x \<in> span (f ` S)}" apply (rule set_ext)
1.1475 +    have th0:"(\<lambda>a. f a \<in> span (f ` S)) = {x. f x \<in> span (f ` S)}" apply (rule set_ext)
1.1476        unfolding mem_def Collect_def ..
1.1477      have "f x \<in> span (f ` S)"
1.1478        apply (rule span_induct[where S=S])
1.1479 @@ -3146,15 +3146,15 @@
1.1480  	apply (rule exI[where x="1"], simp)
1.1481  	by (rule span_0)}
1.1482      moreover
1.1483 -    {assume ab: "x \<noteq> b"
1.1484 +    {assume ab: "x \<noteq> b"
1.1485        then have "?P x"  using xS
1.1486  	apply -
1.1487  	apply (rule exI[where x=0])
1.1488  	apply (rule span_superset)
1.1489  	by simp}
1.1490      ultimately have "?P x" by blast}
1.1491 -  moreover have "subspace ?P"
1.1492 -    unfolding subspace_def
1.1493 +  moreover have "subspace ?P"
1.1494 +    unfolding subspace_def
1.1495      apply auto
1.1497      apply (rule exI[where x=0])
1.1498 @@ -3174,7 +3174,7 @@
1.1499      apply (rule span_mul[unfolded mem_def])
1.1500      apply assumption
1.1501      by (vector ring_simps)
1.1502 -  ultimately show "?P a" using aS span_induct[where S=S and P= "?P"] by metis
1.1503 +  ultimately show "?P a" using aS span_induct[where S=S and P= "?P"] by metis
1.1504  qed
1.1505
1.1506  lemma span_breakdown_eq:
1.1507 @@ -3186,7 +3186,7 @@
1.1508        apply (rule_tac x= "k" in exI)
1.1509        apply (rule set_rev_mp[of _ "span (S - {a})" _])
1.1510        apply assumption
1.1511 -      apply (rule span_mono)
1.1512 +      apply (rule span_mono)
1.1513        apply blast
1.1514        done}
1.1515    moreover
1.1516 @@ -3196,7 +3196,7 @@
1.1518        apply (rule set_rev_mp[of _ "span S" _])
1.1519        apply (rule k)
1.1520 -      apply (rule span_mono)
1.1521 +      apply (rule span_mono)
1.1522        apply blast
1.1523        apply (rule span_mul)
1.1524        apply (rule span_superset)
1.1525 @@ -3224,7 +3224,7 @@
1.1526        done
1.1527      with na  have ?thesis by blast}
1.1528    moreover
1.1529 -  {assume k0: "k \<noteq> 0"
1.1530 +  {assume k0: "k \<noteq> 0"
1.1531      have eq: "b = (1/k) *s a - ((1/k) *s a - b)" by vector
1.1532      from k0 have eq': "(1/k) *s (a - k*s b) = (1/k) *s a - b"
1.1533        by (vector field_simps)
1.1534 @@ -3247,8 +3247,8 @@
1.1535    ultimately show ?thesis by blast
1.1536  qed
1.1537
1.1538 -lemma in_span_delete:
1.1539 -  assumes a: "(a::'a::field^'n) \<in> span S"
1.1540 +lemma in_span_delete:
1.1541 +  assumes a: "(a::'a::field^'n) \<in> span S"
1.1542    and na: "a \<notin> span (S-{b})"
1.1543    shows "b \<in> span (insert a (S - {b}))"
1.1544    apply (rule in_span_insert)
1.1545 @@ -3268,7 +3268,7 @@
1.1546    from span_breakdown[of x "insert x S" y, OF insertI1 y]
1.1547    obtain k where k: "y -k*s x \<in> span (S - {x})" by auto
1.1548    have eq: "y = (y - k *s x) + k *s x" by vector
1.1549 -  show ?thesis
1.1550 +  show ?thesis
1.1551      apply (subst eq)
1.1553      apply (rule set_rev_mp)
1.1554 @@ -3304,18 +3304,18 @@
1.1555    next
1.1556      fix c x y
1.1557      assume x: "x \<in> P" and hy: "?h y"
1.1558 -    from hy obtain S u where fS: "finite S" and SP: "S\<subseteq>P"
1.1559 +    from hy obtain S u where fS: "finite S" and SP: "S\<subseteq>P"
1.1560        and u: "setsum (\<lambda>v. u v *s v) S = y" by blast
1.1561      let ?S = "insert x S"
1.1562      let ?u = "\<lambda>y. if y = x then (if x \<in> S then u y + c else c)
1.1563                    else u y"
1.1564      from fS SP x have th0: "finite (insert x S)" "insert x S \<subseteq> P" by blast+
1.1565      {assume xS: "x \<in> S"
1.1566 -      have S1: "S = (S - {x}) \<union> {x}"
1.1567 +      have S1: "S = (S - {x}) \<union> {x}"
1.1568  	and Sss:"finite (S - {x})" "finite {x}" "(S -{x}) \<inter> {x} = {}" using xS fS by auto
1.1569        have "setsum (\<lambda>v. ?u v *s v) ?S =(\<Sum>v\<in>S - {x}. u v *s v) + (u x + c) *s x"
1.1570 -	using xS
1.1571 -	by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]
1.1572 +	using xS
1.1573 +	by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]
1.1574  	  setsum_clauses(2)[OF fS] cong del: if_weak_cong)
1.1575        also have "\<dots> = (\<Sum>v\<in>S. u v *s v) + c *s x"
1.1576  	apply (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]])
1.1577 @@ -3324,7 +3324,7 @@
1.1579        finally have "setsum (\<lambda>v. ?u v *s v) ?S = c*s x + y" .
1.1580      then have "?Q ?S ?u (c*s x + y)" using th0 by blast}
1.1581 -  moreover
1.1582 +  moreover
1.1583    {assume xS: "x \<notin> S"
1.1584      have th00: "(\<Sum>v\<in>S. (if v = x then c else u v) *s v) = y"
1.1585        unfolding u[symmetric]
1.1586 @@ -3334,7 +3334,7 @@
1.1588    ultimately have "?Q ?S ?u (c*s x + y)"
1.1589      by (cases "x \<in> S", simp, simp)
1.1590 -    then show "?h (c*s x + y)"
1.1591 +    then show "?h (c*s x + y)"
1.1592        apply -
1.1593        apply (rule exI[where x="?S"])
1.1594        apply (rule exI[where x="?u"]) by metis
1.1595 @@ -3346,11 +3346,11 @@
1.1596    "dependent P \<longleftrightarrow> (\<exists>S u. finite S \<and> S \<subseteq> P \<and> (\<exists>(v::'a::{idom,field}^'n) \<in>S. u v \<noteq> 0 \<and> setsum (\<lambda>v. u v *s v) S = 0))" (is "?lhs = ?rhs")
1.1597  proof-
1.1598    {assume dP: "dependent P"
1.1599 -    then obtain a S u where aP: "a \<in> P" and fS: "finite S"
1.1600 -      and SP: "S \<subseteq> P - {a}" and ua: "setsum (\<lambda>v. u v *s v) S = a"
1.1601 +    then obtain a S u where aP: "a \<in> P" and fS: "finite S"
1.1602 +      and SP: "S \<subseteq> P - {a}" and ua: "setsum (\<lambda>v. u v *s v) S = a"
1.1603        unfolding dependent_def span_explicit by blast
1.1604 -    let ?S = "insert a S"
1.1605 -    let ?u = "\<lambda>y. if y = a then - 1 else u y"
1.1606 +    let ?S = "insert a S"
1.1607 +    let ?u = "\<lambda>y. if y = a then - 1 else u y"
1.1608      let ?v = a
1.1609      from aP SP have aS: "a \<notin> S" by blast
1.1610      from fS SP aP have th0: "finite ?S" "?S \<subseteq> P" "?v \<in> ?S" "?u ?v \<noteq> 0" by auto
1.1611 @@ -3366,16 +3366,16 @@
1.1612        apply (rule exI[where x= "?u"])
1.1613        by clarsimp}
1.1614    moreover
1.1615 -  {fix S u v assume fS: "finite S"
1.1616 -      and SP: "S \<subseteq> P" and vS: "v \<in> S" and uv: "u v \<noteq> 0"
1.1617 +  {fix S u v assume fS: "finite S"
1.1618 +      and SP: "S \<subseteq> P" and vS: "v \<in> S" and uv: "u v \<noteq> 0"
1.1619      and u: "setsum (\<lambda>v. u v *s v) S = 0"
1.1620 -    let ?a = v
1.1621 +    let ?a = v
1.1622      let ?S = "S - {v}"
1.1623      let ?u = "\<lambda>i. (- u i) / u v"
1.1624 -    have th0: "?a \<in> P" "finite ?S" "?S \<subseteq> P"       using fS SP vS by auto
1.1625 +    have th0: "?a \<in> P" "finite ?S" "?S \<subseteq> P"       using fS SP vS by auto
1.1626      have "setsum (\<lambda>v. ?u v *s v) ?S = setsum (\<lambda>v. (- (inverse (u ?a))) *s (u v *s v)) S - ?u v *s v"
1.1627 -      using fS vS uv
1.1628 -      by (simp add: setsum_diff1 vector_smult_lneg divide_inverse
1.1629 +      using fS vS uv
1.1630 +      by (simp add: setsum_diff1 vector_smult_lneg divide_inverse
1.1631  	vector_smult_assoc field_simps)
1.1632      also have "\<dots> = ?a"
1.1633        unfolding setsum_cmul u
1.1634 @@ -3398,7 +3398,7 @@
1.1635    (is "_ = ?rhs")
1.1636  proof-
1.1637    {fix y assume y: "y \<in> span S"
1.1638 -    from y obtain S' u where fS': "finite S'" and SS': "S' \<subseteq> S" and
1.1639 +    from y obtain S' u where fS': "finite S'" and SS': "S' \<subseteq> S" and
1.1640        u: "setsum (\<lambda>v. u v *s v) S' = y" unfolding span_explicit by blast
1.1641      let ?u = "\<lambda>x. if x \<in> S' then u x else 0"
1.1642      from setsum_restrict_set[OF fS, of "\<lambda>v. u v *s v" S', symmetric] SS'
1.1643 @@ -3410,7 +3410,7 @@
1.1644        done
1.1645      hence "setsum (\<lambda>v. ?u v *s v) S = y" by (metis u)
1.1646      hence "y \<in> ?rhs" by auto}
1.1647 -  moreover
1.1648 +  moreover
1.1649    {fix y u assume u: "setsum (\<lambda>v. u v *s v) S = y"
1.1650      then have "y \<in> span S" using fS unfolding span_explicit by auto}
1.1651    ultimately show ?thesis by blast
1.1652 @@ -3431,7 +3431,7 @@
1.1653  apply (auto simp add: Collect_def mem_def)
1.1654  done
1.1655
1.1656 -
1.1657 +
1.1658  lemma has_size_stdbasis: "{basis i ::real ^'n | i. i \<in> {1 .. dimindex (UNIV :: 'n set)}} hassize (dimindex(UNIV :: 'n set))" (is "?S hassize ?n")
1.1659  proof-
1.1660    have eq: "?S = basis ` {1 .. ?n}" by blast
1.1661 @@ -3461,10 +3461,10 @@
1.1662   {fix x::"'a^'n" assume xS: "x\<in> ?B"
1.1663     from xS have "?P x" by (auto simp add: basis_component)}
1.1664   moreover
1.1665 - have "subspace ?P"
1.1666 + have "subspace ?P"
1.1667     by (auto simp add: subspace_def Collect_def mem_def zero_index vector_component)
1.1668   ultimately show ?thesis
1.1669 -   using x span_induct[of ?B ?P x] i iS by blast
1.1670 +   using x span_induct[of ?B ?P x] i iS by blast
1.1671  qed
1.1672
1.1673  lemma independent_stdbasis: "independent {basis i ::real^'n |i. i\<in> {1 .. dimindex(UNIV :: 'n set)}}"
1.1674 @@ -3508,7 +3508,7 @@
1.1675  	apply assumption
1.1676  	apply blast
1.1678 -    moreover
1.1679 +    moreover
1.1680      {assume i: ?rhs
1.1681        have ?lhs using i aS
1.1682  	apply simp
1.1683 @@ -3541,7 +3541,7 @@
1.1684    by (metis subset_eq span_superset)
1.1685
1.1686  lemma spanning_subset_independent:
1.1687 -  assumes BA: "B \<subseteq> A" and iA: "independent (A::('a::field ^'n) set)"
1.1688 +  assumes BA: "B \<subseteq> A" and iA: "independent (A::('a::field ^'n) set)"
1.1689    and AsB: "A \<subseteq> span B"
1.1690    shows "A = B"
1.1691  proof
1.1692 @@ -3569,7 +3569,7 @@
1.1693
1.1694  lemma exchange_lemma:
1.1695    assumes f:"finite (t:: ('a::field^'n) set)" and i: "independent s"
1.1696 -  and sp:"s \<subseteq> span t"
1.1697 +  and sp:"s \<subseteq> span t"
1.1698    shows "\<exists>t'. (t' hassize card t) \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'"
1.1699  using f i sp
1.1700  proof(induct c\<equiv>"card(t - s)" arbitrary: s t rule: nat_less_induct)
1.1701 @@ -3584,15 +3584,15 @@
1.1702      and ft: "finite t" and s: "independent s" and sp: "s \<subseteq> span t"
1.1703      and n: "n = card (t - s)"
1.1704    let ?P = "\<lambda>t'. (t' hassize card t) \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'"
1.1705 -  let ?ths = "\<exists>t'. ?P t'"
1.1706 -  {assume st: "s \<subseteq> t"
1.1707 -    from st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
1.1708 +  let ?ths = "\<exists>t'. ?P t'"
1.1709 +  {assume st: "s \<subseteq> t"
1.1710 +    from st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
1.1711        by (auto simp add: hassize_def intro: span_superset)}
1.1712    moreover
1.1713    {assume st: "t \<subseteq> s"
1.1714 -
1.1715 -    from spanning_subset_independent[OF st s sp]
1.1716 -      st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
1.1717 +
1.1718 +    from spanning_subset_independent[OF st s sp]
1.1719 +      st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
1.1720        by (auto simp add: hassize_def intro: span_superset)}
1.1721    moreover
1.1722    {assume st: "\<not> s \<subseteq> t" "\<not> t \<subseteq> s"
1.1723 @@ -3603,28 +3603,28 @@
1.1724        from b ft have ct0: "card t \<noteq> 0" by auto
1.1725      {assume stb: "s \<subseteq> span(t -{b})"
1.1726        from ft have ftb: "finite (t -{b})" by auto
1.1727 -      from H[rule_format, OF cardlt ftb s stb]
1.1728 +      from H[rule_format, OF cardlt ftb s stb]
1.1729        obtain u where u: "u hassize card (t-{b})" "s \<subseteq> u" "u \<subseteq> s \<union> (t - {b})" "s \<subseteq> span u" by blast
1.1730        let ?w = "insert b u"
1.1731        have th0: "s \<subseteq> insert b u" using u by blast
1.1732 -      from u(3) b have "u \<subseteq> s \<union> t" by blast
1.1733 +      from u(3) b have "u \<subseteq> s \<union> t" by blast
1.1734        then have th1: "insert b u \<subseteq> s \<union> t" using u b by blast
1.1735        have bu: "b \<notin> u" using b u by blast
1.1736        from u(1) have fu: "finite u" by (simp add: hassize_def)
1.1737        from u(1) ft b have "u hassize (card t - 1)" by auto
1.1738 -      then
1.1739 -      have th2: "insert b u hassize card t"
1.1740 +      then
1.1741 +      have th2: "insert b u hassize card t"
1.1742  	using  card_insert_disjoint[OF fu bu] ct0 by (auto simp add: hassize_def)
1.1743        from u(4) have "s \<subseteq> span u" .
1.1744        also have "\<dots> \<subseteq> span (insert b u)" apply (rule span_mono) by blast
1.1745        finally have th3: "s \<subseteq> span (insert b u)" .      from th0 th1 th2 th3 have th: "?P ?w"  by blast
1.1746        from th have ?ths by blast}
1.1747      moreover
1.1748 -    {assume stb: "\<not> s \<subseteq> span(t -{b})"
1.1749 +    {assume stb: "\<not> s \<subseteq> span(t -{b})"
1.1750        from stb obtain a where a: "a \<in> s" "a \<notin> span (t - {b})" by blast
1.1751        have ab: "a \<noteq> b" using a b by blast
1.1752        have at: "a \<notin> t" using a ab span_superset[of a "t- {b}"] by auto
1.1753 -      have mlt: "card ((insert a (t - {b})) - s) < n"
1.1754 +      have mlt: "card ((insert a (t - {b})) - s) < n"
1.1755  	using cardlt ft n  a b by auto
1.1756        have ft': "finite (insert a (t - {b}))" using ft by auto
1.1757        {fix x assume xs: "x \<in> s"
1.1758 @@ -3637,15 +3637,15 @@
1.1759  	have x: "x \<in> span (insert b (insert a (t - {b})))" ..
1.1760  	from span_trans[OF bs x] have "x \<in> span (insert a (t - {b}))"  .}
1.1761        then have sp': "s \<subseteq> span (insert a (t - {b}))" by blast
1.1762 -
1.1763 -      from H[rule_format, OF mlt ft' s sp' refl] obtain u where
1.1764 +
1.1765 +      from H[rule_format, OF mlt ft' s sp' refl] obtain u where
1.1766  	u: "u hassize card (insert a (t -{b}))" "s \<subseteq> u" "u \<subseteq> s \<union> insert a (t -{b})"
1.1767  	"s \<subseteq> span u" by blast
1.1768        from u a b ft at ct0 have "?P u" by (auto simp add: hassize_def)
1.1769        then have ?ths by blast }
1.1770      ultimately have ?ths by blast
1.1771    }
1.1772 -  ultimately
1.1773 +  ultimately
1.1774    show ?ths  by blast
1.1775  qed
1.1776
1.1777 @@ -3659,7 +3659,7 @@
1.1778  lemma finite_Atleast_Atmost[simp]: "finite {f x |x. x\<in> {(i::'a::finite_intvl_succ) .. j}}"
1.1779  proof-
1.1780    have eq: "{f x |x. x\<in> {i .. j}} = f ` {i .. j}" by auto
1.1781 -  show ?thesis unfolding eq
1.1782 +  show ?thesis unfolding eq
1.1783      apply (rule finite_imageI)
1.1784      apply (rule finite_intvl)
1.1785      done
1.1786 @@ -3668,7 +3668,7 @@
1.1787  lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x\<in> {(i::nat) .. j}}"
1.1788  proof-
1.1789    have eq: "{f x |x. x\<in> {i .. j}} = f ` {i .. j}" by auto
1.1790 -  show ?thesis unfolding eq
1.1791 +  show ?thesis unfolding eq
1.1792      apply (rule finite_imageI)
1.1793      apply (rule finite_atLeastAtMost)
1.1794      done
1.1795 @@ -3682,7 +3682,7 @@
1.1796    apply (rule independent_span_bound)
1.1797    apply (rule finite_Atleast_Atmost_nat)
1.1798    apply assumption
1.1799 -  unfolding span_stdbasis
1.1800 +  unfolding span_stdbasis
1.1801    apply (rule subset_UNIV)
1.1802    done
1.1803
1.1804 @@ -3710,14 +3710,14 @@
1.1805      from VS obtain a where a: "a \<in> V" "a \<notin> span S" by blast
1.1806      from a have aS: "a \<notin> S" by (auto simp add: span_superset)
1.1807      have th0: "insert a S \<subseteq> V" using a sv by blast
1.1808 -    from independent_insert[of a S]  i a
1.1809 +    from independent_insert[of a S]  i a
1.1810      have th1: "independent (insert a S)" by auto
1.1811 -    have mlt: "?d - card (insert a S) < n"
1.1812 -      using aS a n independent_bound[OF th1] dimindex_ge_1[of "UNIV :: 'n set"]
1.1813 -      by auto
1.1814 -
1.1815 -    from H[rule_format, OF mlt th0 th1 refl]
1.1816 -    obtain B where B: "insert a S \<subseteq> B" "B \<subseteq> V" "independent B" " V \<subseteq> span B"
1.1817 +    have mlt: "?d - card (insert a S) < n"
1.1818 +      using aS a n independent_bound[OF th1] dimindex_ge_1[of "UNIV :: 'n set"]
1.1819 +      by auto
1.1820 +
1.1821 +    from H[rule_format, OF mlt th0 th1 refl]
1.1822 +    obtain B where B: "insert a S \<subseteq> B" "B \<subseteq> V" "independent B" " V \<subseteq> span B"
1.1823        by blast
1.1824      from B have "?P B" by auto
1.1825      then have ?ths by blast}
1.1826 @@ -3732,7 +3732,7 @@
1.1827
1.1828  definition "dim V = (SOME n. \<exists>B. B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (B hassize n))"
1.1829
1.1830 -lemma basis_exists:  "\<exists>B. (B :: (real ^'n) set) \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (B hassize dim V)"
1.1831 +lemma basis_exists:  "\<exists>B. (B :: (real ^'n) set) \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (B hassize dim V)"
1.1832  unfolding dim_def some_eq_ex[of "\<lambda>n. \<exists>B. B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (B hassize n)"]
1.1833  unfolding hassize_def
1.1834  using maximal_independent_subset[of V] independent_bound
1.1835 @@ -3784,7 +3784,7 @@
1.1836  qed
1.1837
1.1838  lemma card_le_dim_spanning:
1.1839 -  assumes BV: "(B:: (real ^'n) set) \<subseteq> V" and VB: "V \<subseteq> span B"
1.1840 +  assumes BV: "(B:: (real ^'n) set) \<subseteq> V" and VB: "V \<subseteq> span B"
1.1841    and fB: "finite B" and dVB: "dim V \<ge> card B"
1.1842    shows "independent B"
1.1843  proof-
1.1844 @@ -3794,10 +3794,10 @@
1.1845      from BV a have th0: "B -{a} \<subseteq> V" by blast
1.1846      {fix x assume x: "x \<in> V"
1.1847        from a have eq: "insert a (B -{a}) = B" by blast
1.1848 -      from x VB have x': "x \<in> span B" by blast
1.1849 +      from x VB have x': "x \<in> span B" by blast
1.1850        from span_trans[OF a(2), unfolded eq, OF x']
1.1851        have "x \<in> span (B -{a})" . }
1.1852 -    then have th1: "V \<subseteq> span (B -{a})" by blast
1.1853 +    then have th1: "V \<subseteq> span (B -{a})" by blast
1.1854      have th2: "finite (B -{a})" using fB by auto
1.1855      from span_card_ge_dim[OF th0 th1 th2]
1.1856      have c: "dim V \<le> card (B -{a})" .
1.1857 @@ -3806,7 +3806,7 @@
1.1858  qed
1.1859
1.1860  lemma card_eq_dim: "(B:: (real ^'n) set) \<subseteq> V \<Longrightarrow> B hassize dim V \<Longrightarrow> independent B \<longleftrightarrow> V \<subseteq> span B"
1.1861 -  by (metis hassize_def order_eq_iff card_le_dim_spanning
1.1862 +  by (metis hassize_def order_eq_iff card_le_dim_spanning
1.1863      card_ge_dim_independent)
1.1864
1.1865  (* ------------------------------------------------------------------------- *)
1.1866 @@ -3818,18 +3818,18 @@
1.1867    by (metis independent_card_le_dim independent_bound subset_refl)
1.1868
1.1869  lemma dependent_biggerset_general: "(finite (S:: (real^'n) set) \<Longrightarrow> card S > dim S) \<Longrightarrow> dependent S"
1.1870 -  using independent_bound_general[of S] by (metis linorder_not_le)
1.1871 +  using independent_bound_general[of S] by (metis linorder_not_le)
1.1872
1.1873  lemma dim_span: "dim (span (S:: (real ^'n) set)) = dim S"
1.1874  proof-
1.1875 -  have th0: "dim S \<le> dim (span S)"
1.1876 +  have th0: "dim S \<le> dim (span S)"
1.1877      by (auto simp add: subset_eq intro: dim_subset span_superset)
1.1878 -  from basis_exists[of S]
1.1879 +  from basis_exists[of S]
1.1880    obtain B where B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "B hassize dim S" by blast
1.1881    from B have fB: "finite B" "card B = dim S" unfolding hassize_def by blast+
1.1882 -  have bSS: "B \<subseteq> span S" using B(1) by (metis subset_eq span_inc)
1.1883 -  have sssB: "span S \<subseteq> span B" using span_mono[OF B(3)] by (simp add: span_span)
1.1884 -  from span_card_ge_dim[OF bSS sssB fB(1)] th0 show ?thesis
1.1885 +  have bSS: "B \<subseteq> span S" using B(1) by (metis subset_eq span_inc)
1.1886 +  have sssB: "span S \<subseteq> span B" using span_mono[OF B(3)] by (simp add: span_span)
1.1887 +  from span_card_ge_dim[OF bSS sssB fB(1)] th0 show ?thesis
1.1888      using fB(2)  by arith
1.1889  qed
1.1890
1.1891 @@ -3847,7 +3847,7 @@
1.1892
1.1893  lemma dim_image_le: assumes lf: "linear f" shows "dim (f ` S) \<le> dim (S:: (real ^'n) set)"
1.1894  proof-
1.1895 -  from basis_exists[of S] obtain B where
1.1896 +  from basis_exists[of S] obtain B where
1.1897      B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "B hassize dim S" by blast
1.1898    from B have fB: "finite B" "card B = dim S" unfolding hassize_def by blast+
1.1899    have "dim (f ` S) \<le> card (f ` B)"
1.1900 @@ -3860,7 +3860,7 @@
1.1901  (* Relation between bases and injectivity/surjectivity of map.               *)
1.1902
1.1903  lemma spanning_surjective_image:
1.1904 -  assumes us: "UNIV \<subseteq> span (S:: ('a::semiring_1 ^'n) set)"
1.1905 +  assumes us: "UNIV \<subseteq> span (S:: ('a::semiring_1 ^'n) set)"
1.1906    and lf: "linear f" and sf: "surj f"
1.1907    shows "UNIV \<subseteq> span (f ` S)"
1.1908  proof-
1.1909 @@ -3881,7 +3881,7 @@
1.1910      hence "a \<in> span (S -{a})" using fi by (auto simp add: inj_on_def)
1.1911      with a(1) iS  have False by (simp add: dependent_def) }
1.1912    then show ?thesis unfolding dependent_def by blast
1.1913 -qed
1.1914 +qed
1.1915
1.1916  (* ------------------------------------------------------------------------- *)
1.1917  (* Picking an orthogonal replacement for a spanning set.                     *)
1.1918 @@ -3904,15 +3904,15 @@
1.1919    case 1 thus ?case apply (rule exI[where x="{}"]) by (auto simp add: pairwise_def)
1.1920  next
1.1921    case (2 a B)
1.1922 -  note fB = `finite B` and aB = `a \<notin> B`
1.1923 -  from `\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C`
1.1924 -  obtain C where C: "finite C" "card C \<le> card B"
1.1925 +  note fB = `finite B` and aB = `a \<notin> B`
1.1926 +  from `\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C`
1.1927 +  obtain C where C: "finite C" "card C \<le> card B"
1.1928      "span C = span B" "pairwise orthogonal C" by blast
1.1929    let ?a = "a - setsum (\<lambda>x. (x\<bullet>a / (x\<bullet>x)) *s x) C"
1.1930    let ?C = "insert ?a C"
1.1931    from C(1) have fC: "finite ?C" by simp
1.1932    from fB aB C(1,2) have cC: "card ?C \<le> card (insert a B)" by (simp add: card_insert_if)
1.1933 -  {fix x k
1.1934 +  {fix x k
1.1935      have th0: "\<And>(a::'b::comm_ring) b c. a - (b - c) = c + (a - b)" by (simp add: ring_simps)
1.1936      have "x - k *s (a - (\<Sum>x\<in>C. (x \<bullet> a / (x \<bullet> x)) *s x)) \<in> span C \<longleftrightarrow> x - k *s a \<in> span C"
1.1937        apply (simp only: vector_ssub_ldistrib th0)
1.1938 @@ -3924,18 +3924,18 @@
1.1939        by (rule span_superset)}
1.1940    then have SC: "span ?C = span (insert a B)"
1.1941      unfolding expand_set_eq span_breakdown_eq C(3)[symmetric] by auto
1.1942 -  thm pairwise_def
1.1943 +  thm pairwise_def
1.1944    {fix x y assume xC: "x \<in> ?C" and yC: "y \<in> ?C" and xy: "x \<noteq> y"
1.1945 -    {assume xa: "x = ?a" and ya: "y = ?a"
1.1946 +    {assume xa: "x = ?a" and ya: "y = ?a"
1.1947        have "orthogonal x y" using xa ya xy by blast}
1.1948      moreover
1.1949 -    {assume xa: "x = ?a" and ya: "y \<noteq> ?a" "y \<in> C"
1.1950 +    {assume xa: "x = ?a" and ya: "y \<noteq> ?a" "y \<in> C"
1.1951        from ya have Cy: "C = insert y (C - {y})" by blast
1.1952        have fth: "finite (C - {y})" using C by simp
1.1953        have "orthogonal x y"
1.1954  	using xa ya
1.1955  	unfolding orthogonal_def xa dot_lsub dot_rsub diff_eq_0_iff_eq
1.1956 -	apply simp
1.1957 +	apply simp
1.1958  	apply (subst Cy)
1.1959  	using C(1) fth
1.1960  	apply (simp only: setsum_clauses)
1.1961 @@ -3946,13 +3946,13 @@
1.1962  	apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
1.1963  	by auto}
1.1964      moreover
1.1965 -    {assume xa: "x \<noteq> ?a" "x \<in> C" and ya: "y = ?a"
1.1966 +    {assume xa: "x \<noteq> ?a" "x \<in> C" and ya: "y = ?a"
1.1967        from xa have Cx: "C = insert x (C - {x})" by blast
1.1968        have fth: "finite (C - {x})" using C by simp
1.1969        have "orthogonal x y"
1.1970  	using xa ya
1.1971  	unfolding orthogonal_def ya dot_rsub dot_lsub diff_eq_0_iff_eq
1.1972 -	apply simp
1.1973 +	apply simp
1.1974  	apply (subst Cx)
1.1975  	using C(1) fth
1.1976  	apply (simp only: setsum_clauses)
1.1977 @@ -3963,12 +3963,12 @@
1.1978  	apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
1.1979  	by auto}
1.1980      moreover
1.1981 -    {assume xa: "x \<in> C" and ya: "y \<in> C"
1.1982 +    {assume xa: "x \<in> C" and ya: "y \<in> C"
1.1983        have "orthogonal x y" using xa ya xy C(4) unfolding pairwise_def by blast}
1.1984      ultimately have "orthogonal x y" using xC yC by blast}
1.1985    then have CPO: "pairwise orthogonal ?C" unfolding pairwise_def by blast
1.1986    from fC cC SC CPO have "?P (insert a B) ?C" by blast
1.1987 -  then show ?case by blast
1.1988 +  then show ?case by blast
1.1989  qed
1.1990
1.1991  lemma orthogonal_basis_exists:
1.1992 @@ -3977,18 +3977,18 @@
1.1993  proof-
1.1994    from basis_exists[of V] obtain B where B: "B \<subseteq> V" "independent B" "V \<subseteq> span B" "B hassize dim V" by blast
1.1995    from B have fB: "finite B" "card B = dim V" by (simp_all add: hassize_def)
1.1996 -  from basis_orthogonal[OF fB(1)] obtain C where
1.1997 +  from basis_orthogonal[OF fB(1)] obtain C where
1.1998      C: "finite C" "card C \<le> card B" "span C = span B" "pairwise orthogonal C" by blast
1.1999 -  from C B
1.2000 -  have CSV: "C \<subseteq> span V" by (metis span_inc span_mono subset_trans)
1.2001 +  from C B
1.2002 +  have CSV: "C \<subseteq> span V" by (metis span_inc span_mono subset_trans)
1.2003    from span_mono[OF B(3)]  C have SVC: "span V \<subseteq> span C" by (simp add: span_span)
1.2004    from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB
1.2005 -  have iC: "independent C" by (simp add: dim_span)
1.2006 +  have iC: "independent C" by (simp add: dim_span)
1.2007    from C fB have "card C \<le> dim V" by simp
1.2008    moreover have "dim V \<le> card C" using span_card_ge_dim[OF CSV SVC C(1)]
1.2010    ultimately have CdV: "C hassize dim V" unfolding hassize_def using C(1) by simp
1.2011 -  from C B CSV CdV iC show ?thesis by auto
1.2012 +  from C B CSV CdV iC show ?thesis by auto
1.2013  qed
1.2014
1.2015  lemma span_eq: "span S = span T \<longleftrightarrow> S \<subseteq> span T \<and> T \<subseteq> span S"
1.2016 @@ -4003,8 +4003,8 @@
1.2017    shows "\<exists>(a:: real ^'n). a \<noteq>0 \<and> (\<forall>x \<in> span S. a \<bullet> x = 0)"
1.2018  proof-
1.2019    from sU obtain a where a: "a \<notin> span S" by blast
1.2020 -  from orthogonal_basis_exists obtain B where
1.2021 -    B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B" "B hassize dim S" "pairwise orthogonal B"
1.2022 +  from orthogonal_basis_exists obtain B where
1.2023 +    B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B" "B hassize dim S" "pairwise orthogonal B"
1.2024      by blast
1.2025    from B have fB: "finite B" "card B = dim S" by (simp_all add: hassize_def)
1.2026    from span_mono[OF B(2)] span_mono[OF B(3)]
1.2027 @@ -4020,12 +4020,12 @@
1.2028    have "\<forall>x\<in>span B. ?a \<bullet> x = 0"
1.2029    proof(rule span_induct')
1.2030      show "subspace (\<lambda>x. ?a \<bullet> x = 0)"
1.2033    next
1.2034      {fix x assume x: "x \<in> B"
1.2035        from x have B': "B = insert x (B - {x})" by blast
1.2036        have fth: "finite (B - {x})" using fB by simp
1.2037 -      have "?a \<bullet> x = 0"
1.2038 +      have "?a \<bullet> x = 0"
1.2039  	apply (subst B') using fB fth
1.2040  	unfolding setsum_clauses(2)[OF fth]
1.2041  	apply simp
1.2042 @@ -4038,7 +4038,7 @@
1.2043    with a0 show ?thesis unfolding sSB by (auto intro: exI[where x="?a"])
1.2044  qed
1.2045
1.2046 -lemma span_not_univ_subset_hyperplane:
1.2047 +lemma span_not_univ_subset_hyperplane:
1.2048    assumes SU: "span S \<noteq> (UNIV ::(real^'n) set)"
1.2049    shows "\<exists> a. a \<noteq>0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
1.2050    using span_not_univ_orthogonal[OF SU] by auto
1.2051 @@ -4058,9 +4058,9 @@
1.2052  (* We can extend a linear basis-basis injection to the whole set.            *)
1.2053
1.2054  lemma linear_indep_image_lemma:
1.2055 -  assumes lf: "linear f" and fB: "finite B"
1.2056 +  assumes lf: "linear f" and fB: "finite B"
1.2057    and ifB: "independent (f ` B)"
1.2058 -  and fi: "inj_on f B" and xsB: "x \<in> span B"
1.2059 +  and fi: "inj_on f B" and xsB: "x \<in> span B"
1.2060    and fx: "f (x::'a::field^'n) = 0"
1.2061    shows "x = 0"
1.2062    using fB ifB fi xsB fx
1.2063 @@ -4070,11 +4070,11 @@
1.2064    case (2 a b x)
1.2065    have fb: "finite b" using "2.prems" by simp
1.2066    have th0: "f ` b \<subseteq> f ` (insert a b)"
1.2067 -    apply (rule image_mono) by blast
1.2068 +    apply (rule image_mono) by blast
1.2069    from independent_mono[ OF "2.prems"(2) th0]
1.2070    have ifb: "independent (f ` b)"  .
1.2071 -  have fib: "inj_on f b"
1.2072 -    apply (rule subset_inj_on [OF "2.prems"(3)])
1.2073 +  have fib: "inj_on f b"
1.2074 +    apply (rule subset_inj_on [OF "2.prems"(3)])
1.2075      by blast
1.2076    from span_breakdown[of a "insert a b", simplified, OF "2.prems"(4)]
1.2077    obtain k where k: "x - k*s a \<in> span (b -{a})" by blast
1.2078 @@ -4084,16 +4084,16 @@
1.2079      using k span_mono[of "b-{a}" b] by blast
1.2080    hence "f x - k*s f a \<in> span (f ` b)"
1.2081      by (simp add: linear_sub[OF lf] linear_cmul[OF lf])
1.2082 -  hence th: "-k *s f a \<in> span (f ` b)"
1.2083 +  hence th: "-k *s f a \<in> span (f ` b)"
1.2084      using "2.prems"(5) by (simp add: vector_smult_lneg)
1.2085 -  {assume k0: "k = 0"
1.2086 +  {assume k0: "k = 0"
1.2087      from k0 k have "x \<in> span (b -{a})" by simp
1.2088      then have "x \<in> span b" using span_mono[of "b-{a}" b]
1.2089        by blast}
1.2090    moreover
1.2091    {assume k0: "k \<noteq> 0"
1.2092      from span_mul[OF th, of "- 1/ k"] k0
1.2093 -    have th1: "f a \<in> span (f ` b)"
1.2094 +    have th1: "f a \<in> span (f ` b)"
1.2095        by (auto simp add: vector_smult_assoc)
1.2096      from inj_on_image_set_diff[OF "2.prems"(3), of "insert a b " "{a}", symmetric]
1.2097      have tha: "f ` insert a b - f ` {a} = f ` (insert a b - {a})" by blast
1.2098 @@ -4112,17 +4112,17 @@
1.2099
1.2100  lemma linear_independent_extend_lemma:
1.2101    assumes fi: "finite B" and ib: "independent B"
1.2102 -  shows "\<exists>g. (\<forall>x\<in> span B. \<forall>y\<in> span B. g ((x::'a::field^'n) + y) = g x + g y)
1.2103 +  shows "\<exists>g. (\<forall>x\<in> span B. \<forall>y\<in> span B. g ((x::'a::field^'n) + y) = g x + g y)
1.2104             \<and> (\<forall>x\<in> span B. \<forall>c. g (c*s x) = c *s g x)
1.2105             \<and> (\<forall>x\<in> B. g x = f x)"
1.2106  using ib fi
1.2107  proof(induct rule: finite_induct[OF fi])
1.2108 -  case 1 thus ?case by (auto simp add: span_empty)
1.2109 +  case 1 thus ?case by (auto simp add: span_empty)
1.2110  next
1.2111    case (2 a b)
1.2112    from "2.prems" "2.hyps" have ibf: "independent b" "finite b"
1.2114 -  from "2.hyps"(3)[OF ibf] obtain g where
1.2115 +  from "2.hyps"(3)[OF ibf] obtain g where
1.2116      g: "\<forall>x\<in>span b. \<forall>y\<in>span b. g (x + y) = g x + g y"
1.2117      "\<forall>x\<in>span b. \<forall>c. g (c *s x) = c *s g x" "\<forall>x\<in>b. g x = f x" by blast
1.2118    let ?h = "\<lambda>z. SOME k. (z - k *s a) \<in> span b"
1.2119 @@ -4132,12 +4132,12 @@
1.2120        unfolding span_breakdown_eq[symmetric]
1.2121        using z .
1.2122      {fix k assume k: "z - k *s a \<in> span b"
1.2123 -      have eq: "z - ?h z *s a - (z - k*s a) = (k - ?h z) *s a"
1.2124 +      have eq: "z - ?h z *s a - (z - k*s a) = (k - ?h z) *s a"
1.2126        from span_sub[OF th0 k]
1.2127        have khz: "(k - ?h z) *s a \<in> span b" by (simp add: eq)
1.2128        {assume "k \<noteq> ?h z" hence k0: "k - ?h z \<noteq> 0" by simp
1.2129 -	from k0 span_mul[OF khz, of "1 /(k - ?h z)"]
1.2130 +	from k0 span_mul[OF khz, of "1 /(k - ?h z)"]
1.2131  	have "a \<in> span b" by (simp add: vector_smult_assoc)
1.2132  	with "2.prems"(1) "2.hyps"(2) have False
1.2133  	  by (auto simp add: dependent_def)}
1.2134 @@ -4146,26 +4146,26 @@
1.2135    note h = this
1.2136    let ?g = "\<lambda>z. ?h z *s f a + g (z - ?h z *s a)"
1.2137    {fix x y assume x: "x \<in> span (insert a b)" and y: "y \<in> span (insert a b)"
1.2138 -    have tha: "\<And>(x::'a^'n) y a k l. (x + y) - (k + l) *s a = (x - k *s a) + (y - l *s a)"
1.2139 +    have tha: "\<And>(x::'a^'n) y a k l. (x + y) - (k + l) *s a = (x - k *s a) + (y - l *s a)"
1.2140        by (vector ring_simps)
1.2141      have addh: "?h (x + y) = ?h x + ?h y"
1.2142        apply (rule conjunct2[OF h, rule_format, symmetric])
1.2143        apply (rule span_add[OF x y])
1.2144        unfolding tha
1.2145        by (metis span_add x y conjunct1[OF h, rule_format])
1.2146 -    have "?g (x + y) = ?g x + ?g y"
1.2147 +    have "?g (x + y) = ?g x + ?g y"
1.2149        g(1)[rule_format,OF conjunct1[OF h, OF x] conjunct1[OF h, OF y]]
1.2151    moreover
1.2152    {fix x:: "'a^'n" and c:: 'a  assume x: "x \<in> span (insert a b)"
1.2153 -    have tha: "\<And>(x::'a^'n) c k a. c *s x - (c * k) *s a = c *s (x - k *s a)"
1.2154 +    have tha: "\<And>(x::'a^'n) c k a. c *s x - (c * k) *s a = c *s (x - k *s a)"
1.2155        by (vector ring_simps)
1.2156 -    have hc: "?h (c *s x) = c * ?h x"
1.2157 +    have hc: "?h (c *s x) = c * ?h x"
1.2158        apply (rule conjunct2[OF h, rule_format, symmetric])
1.2159        apply (metis span_mul x)
1.2160        by (metis tha span_mul x conjunct1[OF h])
1.2161 -    have "?g (c *s x) = c*s ?g x"
1.2162 +    have "?g (c *s x) = c*s ?g x"
1.2163        unfolding hc tha g(2)[rule_format, OF conjunct1[OF h, OF x]]
1.2164        by (vector ring_simps)}
1.2165    moreover
1.2166 @@ -4177,7 +4177,7 @@
1.2167  	using conjunct1[OF h, OF span_superset, OF insertI1]
1.2168  	by (auto simp add: span_0)
1.2169
1.2170 -      from xa ha1[symmetric] have "?g x = f x"
1.2171 +      from xa ha1[symmetric] have "?g x = f x"
1.2172  	apply simp
1.2173  	using g(2)[rule_format, OF span_0, of 0]
1.2174  	by simp}
1.2175 @@ -4201,12 +4201,12 @@
1.2176  proof-
1.2177    from maximal_independent_subset_extend[of B UNIV] iB
1.2178    obtain C where C: "B \<subseteq> C" "independent C" "\<And>x. x \<in> span C" by auto
1.2179 -
1.2180 +
1.2181    from C(2) independent_bound[of C] linear_independent_extend_lemma[of C f]
1.2182 -  obtain g where g: "(\<forall>x\<in> span C. \<forall>y\<in> span C. g (x + y) = g x + g y)
1.2183 +  obtain g where g: "(\<forall>x\<in> span C. \<forall>y\<in> span C. g (x + y) = g x + g y)
1.2184             \<and> (\<forall>x\<in> span C. \<forall>c. g (c*s x) = c *s g x)
1.2185             \<and> (\<forall>x\<in> C. g x = f x)" by blast
1.2186 -  from g show ?thesis unfolding linear_def using C
1.2187 +  from g show ?thesis unfolding linear_def using C
1.2188      apply clarsimp by blast
1.2189  qed
1.2190
1.2191 @@ -4218,7 +4218,7 @@
1.2192  proof(induct arbitrary: B rule: finite_induct[OF fA])
1.2193    case 1 thus ?case by simp
1.2194  next
1.2195 -  case (2 x s t)
1.2196 +  case (2 x s t)
1.2197    thus ?case
1.2198    proof(induct rule: finite_induct[OF "2.prems"(1)])
1.2199      case 1    then show ?case by simp
1.2200 @@ -4234,7 +4234,7 @@
1.2201    qed
1.2202  qed
1.2203
1.2204 -lemma card_subset_eq: assumes fB: "finite B" and AB: "A \<subseteq> B" and
1.2205 +lemma card_subset_eq: assumes fB: "finite B" and AB: "A \<subseteq> B" and
1.2206    c: "card A = card B"
1.2207    shows "A = B"
1.2208  proof-
1.2209 @@ -4245,27 +4245,27 @@
1.2210    from card_Un_disjoint[OF fA fBA e, unfolded eq c]
1.2211    have "card (B - A) = 0" by arith
1.2212    hence "B - A = {}" unfolding card_eq_0_iff using fA fB by simp
1.2213 -  with AB show "A = B" by blast
1.2214 +  with AB show "A = B" by blast
1.2215  qed
1.2216
1.2217  lemma subspace_isomorphism:
1.2218 -  assumes s: "subspace (S:: (real ^'n) set)" and t: "subspace T"
1.2219 +  assumes s: "subspace (S:: (real ^'n) set)" and t: "subspace T"
1.2220    and d: "dim S = dim T"
1.2221    shows "\<exists>f. linear f \<and> f ` S = T \<and> inj_on f S"
1.2222  proof-
1.2223 -  from basis_exists[of S] obtain B where
1.2224 +  from basis_exists[of S] obtain B where
1.2225      B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "B hassize dim S" by blast
1.2226 -  from basis_exists[of T] obtain C where
1.2227 +  from basis_exists[of T] obtain C where
1.2228      C: "C \<subseteq> T" "independent C" "T \<subseteq> span C" "C hassize dim T" by blast
1.2229    from B(4) C(4) card_le_inj[of B C] d obtain f where
1.2230 -    f: "f ` B \<subseteq> C" "inj_on f B" unfolding hassize_def by auto
1.2231 +    f: "f ` B \<subseteq> C" "inj_on f B" unfolding hassize_def by auto
1.2232    from linear_independent_extend[OF B(2)] obtain g where
1.2233      g: "linear g" "\<forall>x\<in> B. g x = f x" by blast
1.2234    from B(4) have fB: "finite B" by (simp add: hassize_def)
1.2235    from C(4) have fC: "finite C" by (simp add: hassize_def)
1.2236 -  from inj_on_iff_eq_card[OF fB, of f] f(2)
1.2237 +  from inj_on_iff_eq_card[OF fB, of f] f(2)
1.2238    have "card (f ` B) = card B" by simp
1.2239 -  with B(4) C(4) have ceq: "card (f ` B) = card C" using d
1.2240 +  with B(4) C(4) have ceq: "card (f ` B) = card C" using d
1.2242    have "g ` B = f ` B" using g(2)
1.2243      by (auto simp add: image_iff)
1.2244 @@ -4277,9 +4277,9 @@
1.2245    {fix x y assume x: "x \<in> S" and y: "y \<in> S" and gxy:"g x = g y"
1.2246      from B(3) x y have x': "x \<in> span B" and y': "y \<in> span B" by blast+
1.2247      from gxy have th0: "g (x - y) = 0" by (simp add: linear_sub[OF g(1)])
1.2248 -    have th1: "x - y \<in> span B" using x' y' by (metis span_sub)
1.2249 +    have th1: "x - y \<in> span B" using x' y' by (metis span_sub)
1.2250      have "x=y" using g0[OF th1 th0] by simp }
1.2251 -  then have giS: "inj_on g S"
1.2252 +  then have giS: "inj_on g S"
1.2253      unfolding inj_on_def by blast
1.2254    from span_subspace[OF B(1,3) s]
1.2255    have "g ` S = span (g ` B)" by (simp add: span_linear_image[OF g(1)])
1.2256 @@ -4308,20 +4308,20 @@
1.2257  qed
1.2258
1.2259  lemma linear_eq_0:
1.2260 -  assumes lf: "linear f" and SB: "S \<subseteq> span B" and f0: "\<forall>x\<in>B. f x = 0"
1.2261 +  assumes lf: "linear f" and SB: "S \<subseteq> span B" and f0: "\<forall>x\<in>B. f x = 0"
1.2262    shows "\<forall>x \<in> S. f x = (0::'a::semiring_1^'n)"
1.2263    by (metis linear_eq_0_span[OF lf] subset_eq SB f0)
1.2264
1.2265  lemma linear_eq:
1.2266    assumes lf: "linear (f::'a::ring_1^'n \<Rightarrow> _)" and lg: "linear g" and S: "S \<subseteq> span B"
1.2267 -  and fg: "\<forall> x\<in> B. f x = g x"
1.2268 +  and fg: "\<forall> x\<in> B. f x = g x"
1.2269    shows "\<forall>x\<in> S. f x = g x"
1.2270  proof-
1.2271    let ?h = "\<lambda>x. f x - g x"
1.2272    from fg have fg': "\<forall>x\<in> B. ?h x = 0" by simp
1.2273    from linear_eq_0[OF linear_compose_sub[OF lf lg] S fg']
1.2274    show ?thesis by simp
1.2275 -qed
1.2276 +qed
1.2277
1.2278  lemma linear_eq_stdbasis:
1.2279    assumes lf: "linear (f::'a::ring_1^'m \<Rightarrow> 'a^'n)" and lg: "linear g"
1.2280 @@ -4329,7 +4329,7 @@
1.2281    shows "f = g"
1.2282  proof-
1.2283    let ?U = "UNIV :: 'm set"
1.2284 -  let ?I = "{basis i:: 'a^'m|i. i \<in> {1 .. dimindex ?U}}"
1.2285 +  let ?I = "{basis i:: 'a^'m|i. i \<in> {1 .. dimindex ?U}}"
1.2286    {fix x assume x: "x \<in> (UNIV :: ('a^'m) set)"
1.2287      from equalityD2[OF span_stdbasis]
1.2288      have IU: " (UNIV :: ('a^'m) set) \<subseteq> span ?I" by blast
1.2289 @@ -4341,27 +4341,27 @@
1.2290  (* Similar results for bilinear functions.                                   *)
1.2291
1.2292  lemma bilinear_eq:
1.2293 -  assumes bf: "bilinear (f:: 'a::ring^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)"
1.2294 +  assumes bf: "bilinear (f:: 'a::ring^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)"
1.2295    and bg: "bilinear g"
1.2296    and SB: "S \<subseteq> span B" and TC: "T \<subseteq> span C"
1.2297    and fg: "\<forall>x\<in> B. \<forall>y\<in> C. f x y = g x y"
1.2298    shows "\<forall>x\<in>S. \<forall>y\<in>T. f x y = g x y "
1.2299  proof-
1.2300    let ?P = "\<lambda>x. \<forall>y\<in> span C. f x y = g x y"
1.2301 -  from bf bg have sp: "subspace ?P"
1.2302 -    unfolding bilinear_def linear_def subspace_def bf bg
1.2303 +  from bf bg have sp: "subspace ?P"
1.2304 +    unfolding bilinear_def linear_def subspace_def bf bg
1.2306
1.2307 -  have "\<forall>x \<in> span B. \<forall>y\<in> span C. f x y = g x y"
1.2308 +  have "\<forall>x \<in> span B. \<forall>y\<in> span C. f x y = g x y"
1.2309      apply -
1.2310      apply (rule ballI)
1.2311 -    apply (rule span_induct[of B ?P])
1.2312 +    apply (rule span_induct[of B ?P])
1.2313      defer
1.2314      apply (rule sp)
1.2315      apply assumption
1.2316      apply (clarsimp simp add: Ball_def)
1.2317      apply (rule_tac P="\<lambda>y. f xa y = g xa y" and S=C in span_induct)
1.2318 -    using fg
1.2319 +    using fg
1.2320      apply (auto simp add: subspace_def)
1.2321      using bf bg unfolding bilinear_def linear_def
1.2323 @@ -4369,7 +4369,7 @@
1.2324  qed
1.2325
1.2326  lemma bilinear_eq_stdbasis:
1.2327 -  assumes bf: "bilinear (f:: 'a::ring_1^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)"
1.2328 +  assumes bf: "bilinear (f:: 'a::ring_1^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)"
1.2329    and bg: "bilinear g"
1.2330    and fg: "\<forall>i\<in> {1 .. dimindex (UNIV :: 'm set)}. \<forall>j\<in>  {1 .. dimindex (UNIV :: 'n set)}. f (basis i) (basis j) = g (basis i) (basis j)"
1.2331    shows "f = g"
1.2332 @@ -4394,16 +4394,16 @@
1.2333  proof-
1.2334    from linear_independent_extend[OF independent_injective_image, OF independent_stdbasis, OF lf fi]
1.2335    obtain h:: "real ^'m \<Rightarrow> real ^'n" where h: "linear h" " \<forall>x \<in> f ` {basis i|i. i \<in> {1 .. dimindex (UNIV::'n set)}}. h x = inv f x" by blast
1.2336 -  from h(2)
1.2337 +  from h(2)
1.2338    have th: "\<forall>i\<in>{1..dimindex (UNIV::'n set)}. (h \<circ> f) (basis i) = id (basis i)"
1.2339      using inv_o_cancel[OF fi, unfolded stupid_ext[symmetric] id_def o_def]
1.2340      apply auto
1.2341      apply (erule_tac x="basis i" in allE)
1.2342      by auto
1.2343 -
1.2344 +
1.2345    from linear_eq_stdbasis[OF linear_compose[OF lf h(1)] linear_id th]
1.2346    have "h o f = id" .
1.2347 -  then show ?thesis using h(1) by blast
1.2348 +  then show ?thesis using h(1) by blast
1.2349  qed
1.2350
1.2351  lemma linear_surjective_right_inverse:
1.2352 @@ -4411,18 +4411,18 @@
1.2353    shows "\<exists>g. linear g \<and> f o g = id"
1.2354  proof-
1.2355    from linear_independent_extend[OF independent_stdbasis]
1.2356 -  obtain h:: "real ^'n \<Rightarrow> real ^'m" where
1.2357 +  obtain h:: "real ^'n \<Rightarrow> real ^'m" where
1.2358      h: "linear h" "\<forall> x\<in> {basis i| i. i\<in> {1 .. dimindex (UNIV :: 'n set)}}. h x = inv f x" by blast
1.2359 -  from h(2)
1.2360 +  from h(2)
1.2361    have th: "\<forall>i\<in>{1..dimindex (UNIV::'n set)}. (f o h) (basis i) = id (basis i)"
1.2362      using sf
1.2363      apply (auto simp add: surj_iff o_def stupid_ext[symmetric])
1.2364      apply (erule_tac x="basis i" in allE)
1.2365      by auto
1.2366 -
1.2367 +
1.2368    from linear_eq_stdbasis[OF linear_compose[OF h(1) lf] linear_id th]
1.2369    have "f o h = id" .
1.2370 -  then show ?thesis using h(1) by blast
1.2371 +  then show ?thesis using h(1) by blast
1.2372  qed
1.2373
1.2374  lemma matrix_left_invertible_injective:
1.2375 @@ -4434,7 +4434,7 @@
1.2376        unfolding matrix_vector_mul_assoc B matrix_vector_mul_lid .}
1.2377    moreover
1.2378    {assume A: "\<forall>x y. A *v x = A *v y \<longrightarrow> x = y"
1.2379 -    hence i: "inj (op *v A)" unfolding inj_on_def by auto
1.2380 +    hence i: "inj (op *v A)" unfolding inj_on_def by auto
1.2381      from linear_injective_left_inverse[OF matrix_vector_mul_linear i]
1.2382      obtain g where g: "linear g" "g o op *v A = id" by blast
1.2383      have "matrix g ** A = mat 1"
1.2384 @@ -4454,25 +4454,25 @@
1.2385  "(\<exists>B. (A::real^'n^'m) ** (B::real^'m^'n) = mat 1) \<longleftrightarrow> surj (\<lambda>x. A *v x)"
1.2386  proof-
1.2387    {fix B :: "real ^'m^'n"  assume AB: "A ** B = mat 1"
1.2388 -    {fix x :: "real ^ 'm"
1.2389 +    {fix x :: "real ^ 'm"
1.2390        have "A *v (B *v x) = x"
1.2391  	by (simp add: matrix_vector_mul_lid matrix_vector_mul_assoc AB)}
1.2392      hence "surj (op *v A)" unfolding surj_def by metis }
1.2393    moreover
1.2394    {assume sf: "surj (op *v A)"
1.2395      from linear_surjective_right_inverse[OF matrix_vector_mul_linear sf]
1.2396 -    obtain g:: "real ^'m \<Rightarrow> real ^'n" where g: "linear g" "op *v A o g = id"
1.2397 +    obtain g:: "real ^'m \<Rightarrow> real ^'n" where g: "linear g" "op *v A o g = id"
1.2398        by blast
1.2399
1.2400      have "A ** (matrix g) = mat 1"
1.2401 -      unfolding matrix_eq  matrix_vector_mul_lid
1.2402 -	matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)]
1.2403 +      unfolding matrix_eq  matrix_vector_mul_lid
1.2404 +	matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)]
1.2405        using g(2) unfolding o_def stupid_ext[symmetric] id_def
1.2406        .
1.2407      hence "\<exists>B. A ** (B::real^'m^'n) = mat 1" by blast
1.2408    }
1.2409    ultimately show ?thesis unfolding surj_def by blast
1.2410 -qed
1.2411 +qed
1.2412
1.2413  lemma matrix_left_invertible_independent_columns:
1.2414    fixes A :: "real^'n^'m"
1.2415 @@ -4481,7 +4481,7 @@
1.2416  proof-
1.2417    let ?U = "{1 .. dimindex(UNIV :: 'n set)}"
1.2418    {assume k: "\<forall>x. A *v x = 0 \<longrightarrow> x = 0"
1.2419 -    {fix c i assume c: "setsum (\<lambda>i. c i *s column i A) ?U = 0"
1.2420 +    {fix c i assume c: "setsum (\<lambda>i. c i *s column i A) ?U = 0"
1.2421        and i: "i \<in> ?U"
1.2422        let ?x = "\<chi> i. c i"
1.2423        have th0:"A *v ?x = 0"
1.2424 @@ -4493,11 +4493,11 @@
1.2425      hence ?rhs by blast}
1.2426    moreover
1.2427    {assume H: ?rhs
1.2428 -    {fix x assume x: "A *v x = 0"
1.2429 +    {fix x assume x: "A *v x = 0"
1.2430        let ?c = "\<lambda>i. ((x\$i ):: real)"
1.2431        from H[rule_format, of ?c, unfolded matrix_mult_vsum[symmetric], OF x]
1.2432        have "x = 0" by vector}}
1.2433 -  ultimately show ?thesis unfolding matrix_left_invertible_ker by blast
1.2434 +  ultimately show ?thesis unfolding matrix_left_invertible_ker by blast
1.2435  qed
1.2436
1.2437  lemma matrix_right_invertible_independent_rows:
1.2438 @@ -4514,13 +4514,13 @@
1.2439    have fU: "finite ?U" by simp
1.2440    have lhseq: "?lhs \<longleftrightarrow> (\<forall>y. \<exists>(x::real^'m). setsum (\<lambda>i. (x\$i) *s column i A) ?U = y)"
1.2441      unfolding matrix_right_invertible_surjective matrix_mult_vsum surj_def
1.2442 -    apply (subst eq_commute) ..
1.2443 +    apply (subst eq_commute) ..
1.2444    have rhseq: "?rhs \<longleftrightarrow> (\<forall>x. x \<in> span (columns A))" by blast
1.2445    {assume h: ?lhs
1.2446 -    {fix x:: "real ^'n"
1.2447 +    {fix x:: "real ^'n"
1.2448  	from h[unfolded lhseq, rule_format, of x] obtain y:: "real ^'m"
1.2449  	  where y: "setsum (\<lambda>i. (y\$i) *s column i A) ?U = x" by blast
1.2450 -	have "x \<in> span (columns A)"
1.2451 +	have "x \<in> span (columns A)"
1.2452  	  unfolding y[symmetric]
1.2453  	  apply (rule span_setsum[OF fU])
1.2454  	  apply clarify
1.2455 @@ -4532,21 +4532,21 @@
1.2456    moreover
1.2457    {assume h:?rhs
1.2458      let ?P = "\<lambda>(y::real ^'n). \<exists>(x::real^'m). setsum (\<lambda>i. (x\$i) *s column i A) ?U = y"
1.2459 -    {fix y have "?P y"
1.2460 +    {fix y have "?P y"
1.2461        proof(rule span_induct_alt[of ?P "columns A"])
1.2462  	show "\<exists>x\<Colon>real ^ 'm. setsum (\<lambda>i. (x\$i) *s column i A) ?U = 0"
1.2463  	  apply (rule exI[where x=0])
1.2464  	  by (simp add: zero_index vector_smult_lzero)
1.2465        next
1.2466  	fix c y1 y2 assume y1: "y1 \<in> columns A" and y2: "?P y2"
1.2467 -	from y1 obtain i where i: "i \<in> ?U" "y1 = column i A"
1.2468 +	from y1 obtain i where i: "i \<in> ?U" "y1 = column i A"
1.2469  	  unfolding columns_def by blast
1.2470 -	from y2 obtain x:: "real ^'m" where
1.2471 +	from y2 obtain x:: "real ^'m" where
1.2472  	  x: "setsum (\<lambda>i. (x\$i) *s column i A) ?U = y2" by blast
1.2473  	let ?x = "(\<chi> j. if j = i then c + (x\$i) else (x\$j))::real^'m"
1.2474  	show "?P (c*s y1 + y2)"
1.2475  	  proof(rule exI[where x= "?x"], vector, auto simp add: i x[symmetric]Cart_lambda_beta setsum_component cond_value_iff right_distrib cond_application_beta vector_component cong del: if_weak_cong, simp only: One_nat_def[symmetric])
1.2476 -	    fix j
1.2477 +	    fix j
1.2478  	    have th: "\<forall>xa \<in> ?U. (if xa = i then (c + (x\$i)) * ((column xa A)\$j)
1.2479             else (x\$xa) * ((column xa A\$j))) = (if xa = i then c * ((column i A)\$j) else 0) + ((x\$xa) * ((column xa A)\$j))" using i(1)
1.2481 @@ -4558,7 +4558,7 @@
1.2483  	    also have "\<dots> = c * ((column i A)\$j) + setsum (\<lambda>xa. ((x\$xa) * ((column xa A)\$j))) ?U"
1.2484  	      unfolding setsum_delta[OF fU]
1.2485 -	      using i(1) by simp
1.2486 +	      using i(1) by simp
1.2487  	    finally show "setsum (\<lambda>xa. if xa = i then (c + (x\$i)) * ((column xa A)\$j)
1.2488             else (x\$xa) * ((column xa A\$j))) ?U = c * ((column i A)\$j) + setsum (\<lambda>xa. ((x\$xa) * ((column xa A)\$j))) ?U" .
1.2489  	  qed
1.2490 @@ -4579,12 +4579,12 @@
1.2491  (* An injective map real^'n->real^'n is also surjective.                       *)
1.2492
1.2493  lemma linear_injective_imp_surjective:
1.2494 -  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and fi: "inj f"
1.2495 +  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and fi: "inj f"
1.2496    shows "surj f"
1.2497  proof-
1.2498    let ?U = "UNIV :: (real ^'n) set"
1.2499 -  from basis_exists[of ?U] obtain B
1.2500 -    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U"
1.2501 +  from basis_exists[of ?U] obtain B
1.2502 +    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U"
1.2503      by blast
1.2504    from B(4) have d: "dim ?U = card B" by (simp add: hassize_def)
1.2505    have th: "?U \<subseteq> span (f ` B)"
1.2506 @@ -4604,7 +4604,7 @@
1.2507
1.2508  (* And vice versa.                                                           *)
1.2509
1.2510 -lemma surjective_iff_injective_gen:
1.2511 +lemma surjective_iff_injective_gen:
1.2512    assumes fS: "finite S" and fT: "finite T" and c: "card S = card T"
1.2513    and ST: "f ` S \<subseteq> T"
1.2514    shows "(\<forall>y \<in> T. \<exists>x \<in> S. f x = y) \<longleftrightarrow> inj_on f S" (is "?lhs \<longleftrightarrow> ?rhs")
1.2515 @@ -4641,17 +4641,17 @@
1.2516  qed
1.2517
1.2518  lemma linear_surjective_imp_injective:
1.2519 -  assumes lf: "linear (f::real ^'n => real ^'n)" and sf: "surj f"
1.2520 +  assumes lf: "linear (f::real ^'n => real ^'n)" and sf: "surj f"
1.2521    shows "inj f"
1.2522  proof-
1.2523    let ?U = "UNIV :: (real ^'n) set"
1.2524 -  from basis_exists[of ?U] obtain B
1.2525 -    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U"
1.2526 +  from basis_exists[of ?U] obtain B
1.2527 +    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U"
1.2528      by blast
1.2529    {fix x assume x: "x \<in> span B" and fx: "f x = 0"
1.2530      from B(4) have fB: "finite B" by (simp add: hassize_def)
1.2531      from B(4) have d: "dim ?U = card B" by (simp add: hassize_def)
1.2532 -    have fBi: "independent (f ` B)"
1.2533 +    have fBi: "independent (f ` B)"
1.2534        apply (rule card_le_dim_spanning[of "f ` B" ?U])
1.2535        apply blast
1.2536        using sf B(3)
1.2537 @@ -4676,12 +4676,12 @@
1.2538      moreover have "card (f ` B) \<le> card B"
1.2539        by (rule card_image_le, rule fB)
1.2540      ultimately have th1: "card B = card (f ` B)" unfolding d by arith
1.2541 -    have fiB: "inj_on f B"
1.2542 +    have fiB: "inj_on f B"
1.2543        unfolding surjective_iff_injective_gen[OF fB finite_imageI[OF fB] th1 subset_refl, symmetric] by blast
1.2544      from linear_indep_image_lemma[OF lf fB fBi fiB x] fx
1.2545      have "x = 0" by blast}
1.2546    note th = this
1.2547 -  from th show ?thesis unfolding linear_injective_0[OF lf]
1.2548 +  from th show ?thesis unfolding linear_injective_0[OF lf]
1.2549      using B(3) by blast
1.2550  qed
1.2551
1.2552 @@ -4689,7 +4689,7 @@
1.2553
1.2554  lemma left_right_inverse_eq:
1.2555    assumes fg: "f o g = id" and gh: "g o h = id"
1.2556 -  shows "f = h"
1.2557 +  shows "f = h"
1.2558  proof-
1.2559    have "f = f o (g o h)" unfolding gh by simp
1.2560    also have "\<dots> = (f o g) o h" by (simp add: o_assoc)
1.2561 @@ -4723,7 +4723,7 @@
1.2562    {fix f f':: "real ^'n \<Rightarrow> real ^'n"
1.2563      assume lf: "linear f" "linear f'" and f: "f o f' = id"
1.2564      from f have sf: "surj f"
1.2565 -
1.2566 +
1.2567        apply (auto simp add: o_def stupid_ext[symmetric] id_def surj_def)
1.2568        by metis
1.2569      from linear_surjective_isomorphism[OF lf(1) sf] lf f
1.2570 @@ -4735,13 +4735,13 @@
1.2571  (* Moreover, a one-sided inverse is automatically linear.                    *)
1.2572
1.2573  lemma left_inverse_linear:
1.2574 -  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'n)" and gf: "g o f = id"
1.2575 +  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'n)" and gf: "g o f = id"
1.2576    shows "linear g"
1.2577  proof-
1.2578    from gf have fi: "inj f" apply (auto simp add: inj_on_def o_def id_def stupid_ext[symmetric])
1.2579      by metis
1.2580 -  from linear_injective_isomorphism[OF lf fi]
1.2581 -  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
1.2582 +  from linear_injective_isomorphism[OF lf fi]
1.2583 +  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
1.2584      h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x" by blast
1.2585    have "h = g" apply (rule ext) using gf h(2,3)
1.2586      apply (simp add: o_def id_def stupid_ext[symmetric])
1.2587 @@ -4750,13 +4750,13 @@
1.2588  qed
1.2589
1.2590  lemma right_inverse_linear:
1.2591 -  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and gf: "f o g = id"
1.2592 +  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and gf: "f o g = id"
1.2593    shows "linear g"
1.2594  proof-
1.2595    from gf have fi: "surj f" apply (auto simp add: surj_def o_def id_def stupid_ext[symmetric])
1.2596      by metis
1.2597 -  from linear_surjective_isomorphism[OF lf fi]
1.2598 -  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
1.2599 +  from linear_surjective_isomorphism[OF lf fi]
1.2600 +  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
1.2601      h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x" by blast
1.2602    have "h = g" apply (rule ext) using gf h(2,3)
1.2603      apply (simp add: o_def id_def stupid_ext[symmetric])
1.2604 @@ -4767,7 +4767,7 @@
1.2605  (* The same result in terms of square matrices.                              *)
1.2606
1.2607  lemma matrix_left_right_inverse:
1.2608 -  fixes A A' :: "real ^'n^'n"
1.2609 +  fixes A A' :: "real ^'n^'n"
1.2610    shows "A ** A' = mat 1 \<longleftrightarrow> A' ** A = mat 1"
1.2611  proof-
1.2612    {fix A A' :: "real ^'n^'n" assume AA': "A ** A' = mat 1"
1.2613 @@ -4779,7 +4779,7 @@
1.2614      from linear_surjective_isomorphism[OF matrix_vector_mul_linear sA]
1.2615      obtain f' :: "real ^'n \<Rightarrow> real ^'n"
1.2616        where f': "linear f'" "\<forall>x. f' (A *v x) = x" "\<forall>x. A *v f' x = x" by blast
1.2617 -    have th: "matrix f' ** A = mat 1"
1.2618 +    have th: "matrix f' ** A = mat 1"
1.2619        by (simp add: matrix_eq matrix_works[OF f'(1)] matrix_vector_mul_assoc[symmetric] matrix_vector_mul_lid f'(2)[rule_format])
1.2620      hence "(matrix f' ** A) ** A' = mat 1 ** A'" by simp
1.2621      hence "matrix f' = A'" by (simp add: matrix_mul_assoc[symmetric] AA' matrix_mul_rid matrix_mul_lid)
1.2622 @@ -4846,17 +4846,17 @@
1.2623    have th: "\<And>x y (z::real). x - y <= z \<longleftrightarrow> x - z <= y" by arith
1.2624    have th1: "\<And>S f. f ` S = { f i| i. i \<in> S}" by blast
1.2625    have th2: "\<And>x (y::real). abs(x + y) - abs(x) <= abs(y)" by arith
1.2626 -  show ?thesis
1.2627 +  show ?thesis
1.2628    unfolding infnorm_def
1.2629    unfolding rsup_finite_le_iff[ OF infnorm_set_lemma]
1.2630    apply (subst diff_le_eq[symmetric])
1.2631    unfolding rsup_finite_ge_iff[ OF infnorm_set_lemma]
1.2632 -  unfolding infnorm_set_image bex_simps
1.2633 +  unfolding infnorm_set_image bex_simps
1.2634    apply (subst th)
1.2635 -  unfolding th1
1.2636 +  unfolding th1
1.2637    unfolding rsup_finite_ge_iff[ OF infnorm_set_lemma]
1.2638 -
1.2639 -  unfolding infnorm_set_image ball_simps bex_simps
1.2640 +
1.2641 +  unfolding infnorm_set_image ball_simps bex_simps
1.2643    apply (metis numseg_dimindex_nonempty th2)
1.2644    done
1.2645 @@ -4885,7 +4885,7 @@
1.2647    done
1.2648
1.2649 -lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)"
1.2650 +lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)"
1.2651  proof-
1.2652    have "y - x = - (x - y)" by simp
1.2653    then show ?thesis  by (metis infnorm_neg)
1.2654 @@ -4896,7 +4896,7 @@
1.2655    have th: "\<And>(nx::real) n ny. nx <= n + ny \<Longrightarrow> ny <= n + nx ==> \<bar>nx - ny\<bar> <= n"
1.2656      by arith
1.2657    from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"]
1.2658 -  have ths: "infnorm x \<le> infnorm (x - y) + infnorm y"
1.2659 +  have ths: "infnorm x \<le> infnorm (x - y) + infnorm y"
1.2660      "infnorm y \<le> infnorm (x - y) + infnorm x"
1.2661      by (simp_all add: ring_simps infnorm_neg diff_def[symmetric])
1.2662    from th[OF ths]  show ?thesis .
1.2663 @@ -4911,11 +4911,11 @@
1.2664    let ?U = "{1 .. dimindex (UNIV :: 'n set)}"
1.2665    let ?S = "{\<bar>x\$i\<bar> |i. i\<in> ?U}"
1.2666    have fS: "finite ?S" unfolding image_Collect[symmetric]
1.2667 -    apply (rule finite_imageI) unfolding Collect_def mem_def by simp
1.2668 +    apply (rule finite_imageI) unfolding Collect_def mem_def by simp
1.2669    have S0: "?S \<noteq> {}" using numseg_dimindex_nonempty by blast
1.2670    have th1: "\<And>S f. f ` S = { f i| i. i \<in> S}" by blast
1.2671    from rsup_finite_in[OF fS S0] rsup_finite_Ub[OF fS S0] i
1.2672 -  show ?thesis unfolding infnorm_def isUb_def setle_def
1.2673 +  show ?thesis unfolding infnorm_def isUb_def setle_def
1.2674      unfolding infnorm_set_image ball_simps by auto
1.2675  qed
1.2676
1.2677 @@ -4942,7 +4942,7 @@
1.2678      have "infnorm x \<le> 1/\<bar>a\<bar> * infnorm (a*s x)"
1.2679        unfolding th by simp
1.2680      with ap have "\<bar>a\<bar> * infnorm x \<le> \<bar>a\<bar> * (1/\<bar>a\<bar> * infnorm (a *s x))" by (simp add: field_simps)
1.2681 -    then have "\<bar>a\<bar> * infnorm x \<le> infnorm (a*s x)"
1.2682 +    then have "\<bar>a\<bar> * infnorm x \<le> infnorm (a*s x)"
1.2683        using ap by (simp add: field_simps)
1.2684      with infnorm_mul_lemma[of a x] have ?thesis by arith }
1.2685    ultimately show ?thesis by blast
1.2686 @@ -4954,7 +4954,7 @@
1.2687  (* Prove that it differs only up to a bound from Euclidean norm.             *)
1.2688
1.2689  lemma infnorm_le_norm: "infnorm x \<le> norm x"
1.2690 -  unfolding infnorm_def rsup_finite_le_iff[OF infnorm_set_lemma]
1.2691 +  unfolding infnorm_def rsup_finite_le_iff[OF infnorm_set_lemma]
1.2692    unfolding infnorm_set_image  ball_simps
1.2693    by (metis component_le_norm)
1.2694  lemma card_enum: "card {1 .. n} = n" by auto
1.2695 @@ -4968,20 +4968,20 @@
1.2696    have th: "sqrt (real ?d) * infnorm x \<ge> 0"
1.2697      by (simp add: dimindex_ge_1 zero_le_mult_iff real_sqrt_ge_0_iff infnorm_pos_le)
1.2698    have th1: "x\<bullet>x \<le> (sqrt (real ?d) * infnorm x)^2"
1.2699 -    unfolding power_mult_distrib d2
1.2700 +    unfolding power_mult_distrib d2
1.2701      apply (subst d)
1.2702      apply (subst power2_abs[symmetric])
1.2703      unfolding real_of_nat_def dot_def power2_eq_square[symmetric]
1.2704      apply (subst power2_abs[symmetric])
1.2705      apply (rule setsum_bounded)
1.2706      apply (rule power_mono)
1.2707 -    unfolding abs_of_nonneg[OF infnorm_pos_le]
1.2708 +    unfolding abs_of_nonneg[OF infnorm_pos_le]
1.2709      unfolding infnorm_def  rsup_finite_ge_iff[OF infnorm_set_lemma]
1.2710      unfolding infnorm_set_image bex_simps
1.2711      apply blast
1.2712      by (rule abs_ge_zero)
1.2713    from real_le_lsqrt[OF dot_pos_le th th1]
1.2714 -  show ?thesis unfolding real_vector_norm_def id_def .
1.2715 +  show ?thesis unfolding real_vector_norm_def id_def .
1.2716  qed
1.2717
1.2718  (* Equality in Cauchy-Schwarz and triangle inequalities.                     *)
1.2719 @@ -5037,7 +5037,7 @@
1.2720    {assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
1.2721      hence "norm x \<noteq> 0" "norm y \<noteq> 0"
1.2722        by simp_all
1.2723 -    hence n: "norm x > 0" "norm y > 0"
1.2724 +    hence n: "norm x > 0" "norm y > 0"
1.2725        using norm_ge_zero[of x] norm_ge_zero[of y]
1.2726        by arith+
1.2727      have th: "\<And>(a::real) b c. a + b + c \<noteq> 0 ==> (a = b + c \<longleftrightarrow> a^2 = (b + c)^2)" by algebra
1.2728 @@ -5058,7 +5058,7 @@
1.2729
1.2730  lemma collinear_empty:  "collinear {}" by (simp add: collinear_def)
1.2731
1.2732 -lemma collinear_sing: "collinear {(x::'a::ring_1^'n)}"
1.2733 +lemma collinear_sing: "collinear {(x::'a::ring_1^'n)}"
1.2735    apply (rule exI[where x=0])
1.2736    by simp
1.2737 @@ -5075,20 +5075,20 @@
1.2738
1.2739  lemma collinear_lemma: "collinear {(0::real^'n),x,y} \<longleftrightarrow> x = 0 \<or> y = 0 \<or> (\<exists>c. y = c *s x)" (is "?lhs \<longleftrightarrow> ?rhs")
1.2740  proof-
1.2741 -  {assume "x=0 \<or> y = 0" hence ?thesis
1.2742 +  {assume "x=0 \<or> y = 0" hence ?thesis
1.2743        by (cases "x = 0", simp_all add: collinear_2 insert_commute)}
1.2744    moreover
1.2745    {assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
1.2746      {assume h: "?lhs"
1.2747        then obtain u where u: "\<forall> x\<in> {0,x,y}. \<forall>y\<in> {0,x,y}. \<exists>c. x - y = c *s u" unfolding collinear_def by blast
1.2748        from u[rule_format, of x 0] u[rule_format, of y 0]
1.2749 -      obtain cx and cy where
1.2750 +      obtain cx and cy where
1.2751  	cx: "x = cx*s u" and cy: "y = cy*s u"
1.2752  	by auto
1.2753        from cx x have cx0: "cx \<noteq> 0" by auto
1.2754        from cy y have cy0: "cy \<noteq> 0" by auto
1.2755        let ?d = "cy / cx"
1.2756 -      from cx cy cx0 have "y = ?d *s x"
1.2757 +      from cx cy cx0 have "y = ?d *s x"