remove trailing spaces
authorhuffman
Thu Mar 12 09:27:23 2009 -0700 (2009-03-12)
changeset 304895d7d0add1741
parent 30488 5c4c3a9e9102
child 30490 d09b7f0c2c14
remove trailing spaces
src/HOL/Library/Determinants.thy
src/HOL/Library/Euclidean_Space.thy
     1.1 --- a/src/HOL/Library/Determinants.thy	Thu Mar 12 08:57:03 2009 -0700
     1.2 +++ b/src/HOL/Library/Determinants.thy	Thu Mar 12 09:27:23 2009 -0700
     1.3 @@ -40,7 +40,7 @@
     1.4  lemma setprod_singleton_nat_seg: "setprod f {n..n} = f (n::'a::order)" by simp
     1.5  
     1.6  lemma setprod_numseg: "setprod f {m..0} = (if m=0 then f 0 else 1)"
     1.7 -  "setprod f {m .. Suc n} = (if m \<le> Suc n then f (Suc n) * setprod f {m..n} 
     1.8 +  "setprod f {m .. Suc n} = (if m \<le> Suc n then f (Suc n) * setprod f {m..n}
     1.9                               else setprod f {m..n})"
    1.10    by (auto simp add: atLeastAtMostSuc_conv)
    1.11  
    1.12 @@ -98,20 +98,20 @@
    1.13  (* A few general lemmas we need below.                                       *)
    1.14  (* ------------------------------------------------------------------------- *)
    1.15  
    1.16 -lemma Cart_lambda_beta_perm: assumes p: "p permutes {1..dimindex(UNIV::'n set)}" 
    1.17 -  and i: "i \<in> {1..dimindex(UNIV::'n set)}" 
    1.18 +lemma Cart_lambda_beta_perm: assumes p: "p permutes {1..dimindex(UNIV::'n set)}"
    1.19 +  and i: "i \<in> {1..dimindex(UNIV::'n set)}"
    1.20    shows "Cart_nth (Cart_lambda g ::'a^'n) (p i) = g(p i)"
    1.21    using permutes_in_image[OF p] i
    1.22    by (simp add:  Cart_lambda_beta permutes_in_image[OF p])
    1.23  
    1.24  lemma setprod_permute:
    1.25 -  assumes p: "p permutes S" 
    1.26 +  assumes p: "p permutes S"
    1.27    shows "setprod f S = setprod (f o p) S"
    1.28  proof-
    1.29    {assume "\<not> finite S" hence ?thesis by simp}
    1.30    moreover
    1.31    {assume fS: "finite S"
    1.32 -    then have ?thesis 
    1.33 +    then have ?thesis
    1.34        apply (simp add: setprod_def)
    1.35        apply (rule ab_semigroup_mult.fold_image_permute)
    1.36        apply (auto simp add: p)
    1.37 @@ -134,9 +134,9 @@
    1.38    have fU: "finite ?U" by blast
    1.39    {fix p assume p: "p \<in> {p. p permutes ?U}"
    1.40      from p have pU: "p permutes ?U" by blast
    1.41 -    have sth: "sign (inv p) = sign p" 
    1.42 +    have sth: "sign (inv p) = sign p"
    1.43        by (metis sign_inverse fU p mem_def Collect_def permutation_permutes)
    1.44 -    from permutes_inj[OF pU] 
    1.45 +    from permutes_inj[OF pU]
    1.46      have pi: "inj_on p ?U" by (blast intro: subset_inj_on)
    1.47      from permutes_image[OF pU]
    1.48      have "setprod (\<lambda>i. ?di (transp A) i (inv p i)) ?U = setprod (\<lambda>i. ?di (transp A) i (inv p i)) (p ` ?U)" by simp
    1.49 @@ -148,7 +148,7 @@
    1.50  	from i permutes_inv_o[OF pU] permutes_in_image[OF pU]
    1.51  	have "((\<lambda>i. ?di (transp A) i (inv p i)) o p) i = ?di A i (p i)"
    1.52  	  unfolding transp_def by (simp add: Cart_lambda_beta expand_fun_eq)}
    1.53 -      then show "setprod ((\<lambda>i. ?di (transp A) i (inv p i)) o p) ?U = setprod (\<lambda>i. ?di A i (p i)) ?U" by (auto intro: setprod_cong)  
    1.54 +      then show "setprod ((\<lambda>i. ?di (transp A) i (inv p i)) o p) ?U = setprod (\<lambda>i. ?di A i (p i)) ?U" by (auto intro: setprod_cong)
    1.55      qed
    1.56      finally have "of_int (sign (inv p)) * (setprod (\<lambda>i. ?di (transp A) i (inv p i)) ?U) = of_int (sign p) * (setprod (\<lambda>i. ?di A i (p i)) ?U)" using sth
    1.57        by simp}
    1.58 @@ -156,7 +156,7 @@
    1.59    apply (rule setsum_cong2) by blast
    1.60  qed
    1.61  
    1.62 -lemma det_lowerdiagonal: 
    1.63 +lemma det_lowerdiagonal:
    1.64    fixes A :: "'a::comm_ring_1^'n^'n"
    1.65    assumes ld: "\<And>i j. i \<in> {1 .. dimindex (UNIV:: 'n set)} \<Longrightarrow> j \<in> {1 .. dimindex(UNIV:: 'n set)} \<Longrightarrow> i < j \<Longrightarrow> A$i$j = 0"
    1.66    shows "det A = setprod (\<lambda>i. A$i$i) {1..dimindex(UNIV:: 'n set)}"
    1.67 @@ -179,7 +179,7 @@
    1.68      unfolding det_def by (simp add: sign_id)
    1.69  qed
    1.70  
    1.71 -lemma det_upperdiagonal: 
    1.72 +lemma det_upperdiagonal:
    1.73    fixes A :: "'a::comm_ring_1^'n^'n"
    1.74    assumes ld: "\<And>i j. i \<in> {1 .. dimindex (UNIV:: 'n set)} \<Longrightarrow> j \<in> {1 .. dimindex(UNIV:: 'n set)} \<Longrightarrow> i > j \<Longrightarrow> A$i$j = 0"
    1.75    shows "det A = setprod (\<lambda>i. A$i$i) {1..dimindex(UNIV:: 'n set)}"
    1.76 @@ -216,7 +216,7 @@
    1.77    then have "det ?A = setprod (\<lambda>i. ?f i i) ?U" using det_lowerdiagonal
    1.78      by blast
    1.79    also have "\<dots> = 1" unfolding th setprod_1 ..
    1.80 -  finally show ?thesis . 
    1.81 +  finally show ?thesis .
    1.82  qed
    1.83  
    1.84  lemma det_0: "det (mat 0 :: 'a::comm_ring_1^'n^'n) = 0"
    1.85 @@ -235,7 +235,7 @@
    1.86    then have "det ?A = setprod (\<lambda>i. ?f i i) ?U" using det_lowerdiagonal
    1.87      by blast
    1.88    also have "\<dots> = 0" unfolding th  ..
    1.89 -  finally show ?thesis . 
    1.90 +  finally show ?thesis .
    1.91  qed
    1.92  
    1.93  lemma det_permute_rows:
    1.94 @@ -243,7 +243,7 @@
    1.95    assumes p: "p permutes {1 .. dimindex (UNIV :: 'n set)}"
    1.96    shows "det(\<chi> i. A$p i :: 'a^'n^'n) = of_int (sign p) * det A"
    1.97    apply (simp add: det_def setsum_right_distrib mult_assoc[symmetric] del: One_nat_def)
    1.98 -  apply (subst sum_permutations_compose_right[OF p])  
    1.99 +  apply (subst sum_permutations_compose_right[OF p])
   1.100  proof(rule setsum_cong2)
   1.101    let ?U = "{1 .. dimindex (UNIV :: 'n set)}"
   1.102    let ?PU = "{p. p permutes ?U}"
   1.103 @@ -259,14 +259,14 @@
   1.104        have "?Ap$i$ (q o p) i = A $ p i $ (q o p) i " by simp}
   1.105      hence "setprod (\<lambda>i. ?Ap$i$ (q o p) i) ?U = setprod (\<lambda>i. A$p i$(q o p) i) ?U"
   1.106        by (auto intro: setprod_cong)
   1.107 -    also have "\<dots> = setprod ((\<lambda>i. A$p i$(q o p) i) o inv p) ?U" 
   1.108 +    also have "\<dots> = setprod ((\<lambda>i. A$p i$(q o p) i) o inv p) ?U"
   1.109        by (simp only: setprod_permute[OF ip, symmetric])
   1.110      also have "\<dots> = setprod (\<lambda>i. A $ (p o inv p) i $ (q o (p o inv p)) i) ?U"
   1.111        by (simp only: o_def)
   1.112      also have "\<dots> = setprod (\<lambda>i. A$i$q i) ?U" by (simp only: o_def permutes_inverses[OF p])
   1.113 -    finally   have thp: "setprod (\<lambda>i. ?Ap$i$ (q o p) i) ?U = setprod (\<lambda>i. A$i$q i) ?U" 
   1.114 +    finally   have thp: "setprod (\<lambda>i. ?Ap$i$ (q o p) i) ?U = setprod (\<lambda>i. A$i$q i) ?U"
   1.115        by blast
   1.116 -  show "of_int (sign (q o p)) * setprod (\<lambda>i. ?Ap$i$ (q o p) i) ?U = of_int (sign p) * of_int (sign q) * setprod (\<lambda>i. A$i$q i) ?U" 
   1.117 +  show "of_int (sign (q o p)) * setprod (\<lambda>i. ?Ap$i$ (q o p) i) ?U = of_int (sign p) * of_int (sign q) * setprod (\<lambda>i. A$i$q i) ?U"
   1.118      by (simp only: thp sign_compose[OF qp pp] mult_commute of_int_mult)
   1.119  qed
   1.120  
   1.121 @@ -282,18 +282,18 @@
   1.122    moreover
   1.123    have "?Ap = transp (\<chi> i. transp A $ p i)"
   1.124      by (simp add: transp_def Cart_eq Cart_lambda_beta Cart_lambda_beta_perm[OF p])
   1.125 -  ultimately show ?thesis by simp 
   1.126 +  ultimately show ?thesis by simp
   1.127  qed
   1.128  
   1.129  lemma det_identical_rows:
   1.130    fixes A :: "'a::ordered_idom^'n^'n"
   1.131 -  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}" 
   1.132 +  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}"
   1.133    and j: "j\<in>{1 .. dimindex (UNIV :: 'n set)}"
   1.134    and ij: "i \<noteq> j"
   1.135    and r: "row i A = row j A"
   1.136    shows	"det A = 0"
   1.137  proof-
   1.138 -  have tha: "\<And>(a::'a) b. a = b ==> b = - a ==> a = 0" 
   1.139 +  have tha: "\<And>(a::'a) b. a = b ==> b = - a ==> a = 0"
   1.140      by simp
   1.141    have th1: "of_int (-1) = - 1" by (metis of_int_1 of_int_minus number_of_Min)
   1.142    let ?p = "Fun.swap i j id"
   1.143 @@ -302,12 +302,12 @@
   1.144    hence "det A = det ?A" by simp
   1.145    moreover have "det A = - det ?A"
   1.146      by (simp add: det_permute_rows[OF permutes_swap_id[OF i j]] sign_swap_id ij th1)
   1.147 -  ultimately show "det A = 0" by (metis tha) 
   1.148 +  ultimately show "det A = 0" by (metis tha)
   1.149  qed
   1.150  
   1.151  lemma det_identical_columns:
   1.152    fixes A :: "'a::ordered_idom^'n^'n"
   1.153 -  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}" 
   1.154 +  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}"
   1.155    and j: "j\<in>{1 .. dimindex (UNIV :: 'n set)}"
   1.156    and ij: "i \<noteq> j"
   1.157    and r: "column i A = column j A"
   1.158 @@ -316,9 +316,9 @@
   1.159  apply (rule det_identical_rows[OF i j ij])
   1.160  by (metis row_transp i j r)
   1.161  
   1.162 -lemma det_zero_row: 
   1.163 +lemma det_zero_row:
   1.164    fixes A :: "'a::{idom, ring_char_0}^'n^'n"
   1.165 -  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}" 
   1.166 +  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}"
   1.167    and r: "row i A = 0"
   1.168    shows "det A = 0"
   1.169  using i r
   1.170 @@ -332,16 +332,16 @@
   1.171  apply (subgoal_tac "(0\<Colon>'a ^ 'n) $ a i = 0")
   1.172  apply simp
   1.173  apply (rule zero_index)
   1.174 -apply (drule permutes_in_image[of _ _ i]) 
   1.175 +apply (drule permutes_in_image[of _ _ i])
   1.176  apply simp
   1.177 -apply (drule permutes_in_image[of _ _ i]) 
   1.178 +apply (drule permutes_in_image[of _ _ i])
   1.179  apply simp
   1.180  apply simp
   1.181  done
   1.182  
   1.183  lemma det_zero_column:
   1.184    fixes A :: "'a::{idom,ring_char_0}^'n^'n"
   1.185 -  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}" 
   1.186 +  assumes i: "i\<in>{1 .. dimindex (UNIV :: 'n set)}"
   1.187    and r: "column i A = 0"
   1.188    shows "det A = 0"
   1.189    apply (subst det_transp[symmetric])
   1.190 @@ -361,7 +361,7 @@
   1.191  proof(rule setprod_cong[OF refl])
   1.192    let ?U = "{1 .. dimindex (UNIV :: 'n set)}"
   1.193    fix i assume i: "i \<in> ?U"
   1.194 -  from Cart_lambda_beta'[OF i, of g] have 
   1.195 +  from Cart_lambda_beta'[OF i, of g] have
   1.196      "((\<chi> i. g i) :: 'a^'n^'n) $ i = g i" .
   1.197    hence "((\<chi> i. g i) :: 'a^'n^'n) $ i $ f i = g i $ f i" by simp
   1.198    then
   1.199 @@ -369,7 +369,7 @@
   1.200  qed
   1.201  
   1.202  lemma det_row_add:
   1.203 -  assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}" 
   1.204 +  assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}"
   1.205    shows "det((\<chi> i. if i = k then a i + b i else c i)::'a::comm_ring_1^'n^'n) =
   1.206               det((\<chi> i. if i = k then a i else c i)::'a::comm_ring_1^'n^'n) +
   1.207               det((\<chi> i. if i = k then b i else c i)::'a::comm_ring_1^'n^'n)"
   1.208 @@ -387,7 +387,7 @@
   1.209    note pin[simp] = permutes_in_image[OF pU]
   1.210    have kU: "?U = insert k ?Uk" using k by blast
   1.211    {fix j assume j: "j \<in> ?Uk"
   1.212 -    from j have "?f j $ p j = ?g j $ p j" and "?f j $ p j= ?h j $ p j" 
   1.213 +    from j have "?f j $ p j = ?g j $ p j" and "?f j $ p j= ?h j $ p j"
   1.214        by simp_all}
   1.215    then have th1: "setprod (\<lambda>i. ?f i $ p i) ?Uk = setprod (\<lambda>i. ?g i $ p i) ?Uk"
   1.216      and th2: "setprod (\<lambda>i. ?f i $ p i) ?Uk = setprod (\<lambda>i. ?h i $ p i) ?Uk"
   1.217 @@ -411,7 +411,7 @@
   1.218  qed
   1.219  
   1.220  lemma det_row_mul:
   1.221 -  assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}" 
   1.222 +  assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}"
   1.223    shows "det((\<chi> i. if i = k then c *s a i else b i)::'a::comm_ring_1^'n^'n) =
   1.224               c* det((\<chi> i. if i = k then a i else b i)::'a::comm_ring_1^'n^'n)"
   1.225  
   1.226 @@ -451,7 +451,7 @@
   1.227  qed
   1.228  
   1.229  lemma det_row_0:
   1.230 -  assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}" 
   1.231 +  assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}"
   1.232    shows "det((\<chi> i. if i = k then 0 else b i)::'a::comm_ring_1^'n^'n) = 0"
   1.233  using det_row_mul[OF k, of 0 "\<lambda>i. 1" b]
   1.234  apply (simp)
   1.235 @@ -483,8 +483,8 @@
   1.236    let ?S = "{row j A |j. j\<in> ?U \<and> j\<noteq> i}"
   1.237    let ?d = "\<lambda>x. det (\<chi> k. if k = i then x else row k A)"
   1.238    let ?P = "\<lambda>x. ?d (row i A + x) = det A"
   1.239 -  {fix k 
   1.240 -    
   1.241 +  {fix k
   1.242 +
   1.243      have "(if k = i then row i A + 0 else row k A) = row k A" by simp}
   1.244    then have P0: "?P 0"
   1.245      apply -
   1.246 @@ -499,10 +499,10 @@
   1.247        apply (rule det_identical_rows[OF i j(2,3)])
   1.248        using i j by (vector row_def)
   1.249      have "?d (row i A + (c*s z + y)) = ?d (?w + c*s z)" unfolding th0 ..
   1.250 -    then have "?P (c*s z + y)" unfolding thz Py det_row_mul[OF i] det_row_add[OF i] 
   1.251 +    then have "?P (c*s z + y)" unfolding thz Py det_row_mul[OF i] det_row_add[OF i]
   1.252        by simp }
   1.253  
   1.254 -  ultimately show ?thesis 
   1.255 +  ultimately show ?thesis
   1.256      apply -
   1.257      apply (rule span_induct_alt[of ?P ?S, OF P0])
   1.258      apply blast
   1.259 @@ -524,7 +524,7 @@
   1.260    from d obtain i where i: "i \<in> ?U" "row i A \<in> span (rows A - {row i A})"
   1.261      unfolding dependent_def rows_def by blast
   1.262    {fix j k assume j: "j \<in>?U" and k: "k \<in> ?U" and jk: "j \<noteq> k"
   1.263 -    and c: "row j A = row k A" 
   1.264 +    and c: "row j A = row k A"
   1.265      from det_identical_rows[OF j k jk c] have ?thesis .}
   1.266    moreover
   1.267    {assume H: "\<And> i j. i\<in> ?U \<Longrightarrow> j \<in> ?U \<Longrightarrow> i \<noteq> j \<Longrightarrow> row i A \<noteq> row j A"
   1.268 @@ -537,7 +537,7 @@
   1.269      from det_row_span[OF i(1) th0]
   1.270      have "det A = det (\<chi> k. if k = i then 0 *s 1 else row k A)"
   1.271        unfolding right_minus vector_smult_lzero ..
   1.272 -    with det_row_mul[OF i(1), of "0::'a" "\<lambda>i. 1"] 
   1.273 +    with det_row_mul[OF i(1), of "0::'a" "\<lambda>i. 1"]
   1.274      have "det A = 0" by simp}
   1.275    ultimately show ?thesis by blast
   1.276  qed
   1.277 @@ -552,7 +552,7 @@
   1.278  lemma Cart_lambda_cong: "(\<And>x. x \<in> {1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> f x = g x) \<Longrightarrow> (Cart_lambda f::'a^'n) = (Cart_lambda g :: 'a^'n)"
   1.279    apply (rule iffD1[OF Cart_lambda_unique]) by vector
   1.280  
   1.281 -lemma det_linear_row_setsum: 
   1.282 +lemma det_linear_row_setsum:
   1.283    assumes fS: "finite S" and k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}"
   1.284    shows "det ((\<chi> i. if i = k then setsum (a i) S else c i)::'a::comm_ring_1^'n^'n) = setsum (\<lambda>j. det ((\<chi> i. if i = k then a  i j else c i)::'a^'n^'n)) S"
   1.285    using k
   1.286 @@ -567,7 +567,7 @@
   1.287    assumes fS: "finite S"
   1.288    shows "finite {f. (\<forall>i \<in> {1.. (k::nat)}. f i \<in> S) \<and> (\<forall>i. i \<notin> {1 .. k} \<longrightarrow> f i = i)}"
   1.289  proof(induct k)
   1.290 -  case 0 
   1.291 +  case 0
   1.292    have th: "{f. \<forall>i. f i = i} = {id}" by (auto intro: ext)
   1.293    show ?case by (auto simp add: th)
   1.294  next
   1.295 @@ -581,7 +581,7 @@
   1.296      apply (auto intro: ext)
   1.297      done
   1.298    with finite_imageI[OF finite_cartesian_product[OF fS Suc.hyps(1)], of ?f]
   1.299 -  show ?case by metis 
   1.300 +  show ?case by metis
   1.301  qed
   1.302  
   1.303  
   1.304 @@ -608,9 +608,9 @@
   1.305    from Suc.prems have k': "k \<le> dimindex (UNIV :: 'n set)" by arith
   1.306    have thif: "\<And>a b c d. (if b \<or> a then c else d) = (if a then c else if b then c else d)" by simp
   1.307    have thif2: "\<And>a b c d e. (if a then b else if c then d else e) =
   1.308 -     (if c then (if a then b else d) else (if a then b else e))" by simp 
   1.309 -  have "det (\<chi> i. if i \<le> Suc k then setsum (a i) S else c i) = 
   1.310 -        det (\<chi> i. if i = Suc k then setsum (a i) S 
   1.311 +     (if c then (if a then b else d) else (if a then b else e))" by simp
   1.312 +  have "det (\<chi> i. if i \<le> Suc k then setsum (a i) S else c i) =
   1.313 +        det (\<chi> i. if i = Suc k then setsum (a i) S
   1.314                   else if i \<le> k then setsum (a i) S else c i)"
   1.315      unfolding le_Suc_eq thif  ..
   1.316    also have "\<dots> = (\<Sum>j\<in>S. det (\<chi> i. if i \<le> k then setsum (a i) S
   1.317 @@ -618,14 +618,14 @@
   1.318      unfolding det_linear_row_setsum[OF fS Sk]
   1.319      apply (subst thif2)
   1.320      by (simp cong del: if_weak_cong cong add: if_cong)
   1.321 -  finally have tha: 
   1.322 -    "det (\<chi> i. if i \<le> Suc k then setsum (a i) S else c i) = 
   1.323 +  finally have tha:
   1.324 +    "det (\<chi> i. if i \<le> Suc k then setsum (a i) S else c i) =
   1.325       (\<Sum>(j, f)\<in>S \<times> ?F k. det (\<chi> i. if i \<le> k then a i (f i)
   1.326                                  else if i = Suc k then a i j
   1.327 -                                else c i))" 
   1.328 +                                else c i))"
   1.329      unfolding  Suc.hyps[OF k'] unfolding setsum_cartesian_product by blast
   1.330    show ?case unfolding tha
   1.331 -    apply(rule setsum_eq_general_reverses[where h= "?h" and k= "?k"], 
   1.332 +    apply(rule setsum_eq_general_reverses[where h= "?h" and k= "?k"],
   1.333        blast intro: finite_cartesian_product fS finite_bounded_functions[OF fS],
   1.334        blast intro: finite_cartesian_product fS finite_bounded_functions[OF fS], auto intro: ext)
   1.335      apply (rule cong[OF refl[of det]])
   1.336 @@ -637,7 +637,7 @@
   1.337    shows "det (\<chi> i. setsum (a i) S) = setsum (\<lambda>f. det (\<chi> i. a i (f i) :: 'a::comm_ring_1 ^ 'n^'n)) {f. (\<forall>i \<in> {1 .. dimindex (UNIV :: 'n set)}. f i \<in> S) \<and> (\<forall>i. i \<notin> {1.. dimindex (UNIV :: 'n set)} \<longrightarrow> f i = i)}"
   1.338  proof-
   1.339    have th0: "\<And>x y. ((\<chi> i. if i <= dimindex(UNIV:: 'n set) then x i else y i) :: 'a^'n^'n) = (\<chi> i. x i)" by vector
   1.340 -  
   1.341 +
   1.342    from det_linear_rows_setsum_lemma[OF fS, of "dimindex (UNIV :: 'n set)" a, unfolded th0, OF order_refl] show ?thesis by blast
   1.343  qed
   1.344  
   1.345 @@ -674,25 +674,25 @@
   1.346    have fU: "finite ?U" by simp
   1.347    have fF: "finite ?F"  using finite_bounded_functions[OF fU] .
   1.348    {fix p assume p: "p permutes ?U"
   1.349 -    
   1.350 +
   1.351      have "p \<in> ?F" unfolding mem_Collect_eq permutes_in_image[OF p]
   1.352        using p[unfolded permutes_def] by simp}
   1.353 -  then have PUF: "?PU \<subseteq> ?F"  by blast 
   1.354 +  then have PUF: "?PU \<subseteq> ?F"  by blast
   1.355    {fix f assume fPU: "f \<in> ?F - ?PU"
   1.356      have fUU: "f ` ?U \<subseteq> ?U" using fPU by auto
   1.357      from fPU have f: "\<forall>i \<in> ?U. f i \<in> ?U"
   1.358 -      "\<forall>i. i \<notin> ?U \<longrightarrow> f i = i" "\<not>(\<forall>y. \<exists>!x. f x = y)" unfolding permutes_def 
   1.359 +      "\<forall>i. i \<notin> ?U \<longrightarrow> f i = i" "\<not>(\<forall>y. \<exists>!x. f x = y)" unfolding permutes_def
   1.360        by auto
   1.361 -    
   1.362 +
   1.363      let ?A = "(\<chi> i. A$i$f i *s B$f i) :: 'a^'n^'n"
   1.364      let ?B = "(\<chi> i. B$f i) :: 'a^'n^'n"
   1.365      {assume fni: "\<not> inj_on f ?U"
   1.366        then obtain i j where ij: "i \<in> ?U" "j \<in> ?U" "f i = f j" "i \<noteq> j"
   1.367  	unfolding inj_on_def by blast
   1.368 -      from ij 
   1.369 +      from ij
   1.370        have rth: "row i ?B = row j ?B" by (vector row_def)
   1.371 -      from det_identical_rows[OF ij(1,2,4) rth] 
   1.372 -      have "det (\<chi> i. A$i$f i *s B$f i) = 0" 
   1.373 +      from det_identical_rows[OF ij(1,2,4) rth]
   1.374 +      have "det (\<chi> i. A$i$f i *s B$f i) = 0"
   1.375  	unfolding det_rows_mul by simp}
   1.376      moreover
   1.377      {assume fi: "inj_on f ?U"
   1.378 @@ -701,7 +701,7 @@
   1.379  	apply (case_tac "i \<in> ?U")
   1.380  	apply (case_tac "j \<in> ?U") by metis+
   1.381        note fs = fi[unfolded surjective_iff_injective_gen[OF fU fU refl fUU, symmetric]]
   1.382 -      
   1.383 +
   1.384        {fix y
   1.385  	from fs f have "\<exists>x. f x = y" by (cases "y \<in> ?U") blast+
   1.386  	then obtain x where x: "f x = y" by blast
   1.387 @@ -724,17 +724,17 @@
   1.388        fix q assume qU: "q \<in> ?PU"
   1.389        hence q: "q permutes ?U" by blast
   1.390        from p q have pp: "permutation p" and pq: "permutation q"
   1.391 -	unfolding permutation_permutes by auto 
   1.392 -      have th00: "of_int (sign p) * of_int (sign p) = (1::'a)" 
   1.393 -	"\<And>a. of_int (sign p) * (of_int (sign p) * a) = a" 
   1.394 -	unfolding mult_assoc[symmetric]	unfolding of_int_mult[symmetric] 
   1.395 +	unfolding permutation_permutes by auto
   1.396 +      have th00: "of_int (sign p) * of_int (sign p) = (1::'a)"
   1.397 +	"\<And>a. of_int (sign p) * (of_int (sign p) * a) = a"
   1.398 +	unfolding mult_assoc[symmetric]	unfolding of_int_mult[symmetric]
   1.399  	by (simp_all add: sign_idempotent)
   1.400        have ths: "?s q = ?s p * ?s (q o inv p)"
   1.401  	using pp pq permutation_inverse[OF pp] sign_inverse[OF pp]
   1.402  	by (simp add:  th00 mult_ac sign_idempotent sign_compose)
   1.403        have th001: "setprod (\<lambda>i. B$i$ q (inv p i)) ?U = setprod ((\<lambda>i. B$i$ q (inv p i)) o p) ?U"
   1.404  	by (rule setprod_permute[OF p])
   1.405 -      have thp: "setprod (\<lambda>i. (\<chi> i. A$i$p i *s B$p i :: 'a^'n^'n) $i $ q i) ?U = setprod (\<lambda>i. A$i$p i) ?U * setprod (\<lambda>i. B$i$ q (inv p i)) ?U" 
   1.406 +      have thp: "setprod (\<lambda>i. (\<chi> i. A$i$p i *s B$p i :: 'a^'n^'n) $i $ q i) ?U = setprod (\<lambda>i. A$i$p i) ?U * setprod (\<lambda>i. B$i$ q (inv p i)) ?U"
   1.407  	unfolding th001 setprod_timesf[symmetric] o_def permutes_inverses[OF p]
   1.408  	apply (rule setprod_cong[OF refl])
   1.409  	using permutes_in_image[OF q] by vector
   1.410 @@ -743,16 +743,16 @@
   1.411  	by (simp add: sign_nz th00 ring_simps sign_idempotent sign_compose)
   1.412      qed
   1.413    }
   1.414 -  then have th2: "setsum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU = det A * det B" 
   1.415 +  then have th2: "setsum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU = det A * det B"
   1.416      unfolding det_def setsum_product
   1.417 -    by (rule setsum_cong2) 
   1.418 +    by (rule setsum_cong2)
   1.419    have "det (A**B) = setsum (\<lambda>f.  det (\<chi> i. A $ i $ f i *s B $ f i)) ?F"
   1.420 -    unfolding matrix_mul_setsum_alt det_linear_rows_setsum[OF fU] .. 
   1.421 +    unfolding matrix_mul_setsum_alt det_linear_rows_setsum[OF fU] ..
   1.422    also have "\<dots> = setsum (\<lambda>f. det (\<chi> i. A$i$f i *s B$f i)) ?PU"
   1.423 -    using setsum_mono_zero_cong_left[OF fF PUF zth, symmetric] 
   1.424 +    using setsum_mono_zero_cong_left[OF fF PUF zth, symmetric]
   1.425      unfolding det_rows_mul by auto
   1.426    finally show ?thesis unfolding th2 .
   1.427 -qed  
   1.428 +qed
   1.429  
   1.430  (* ------------------------------------------------------------------------- *)
   1.431  (* Relation to invertibility.                                                *)
   1.432 @@ -768,7 +768,7 @@
   1.433    shows "invertible A \<longleftrightarrow> (\<exists>(B::real^'n^'n). A** B = mat 1)"
   1.434    by (metis invertible_def matrix_left_right_inverse)
   1.435  
   1.436 -lemma invertible_det_nz: 
   1.437 +lemma invertible_det_nz:
   1.438    fixes A::"real ^'n^'n"
   1.439    shows "invertible A \<longleftrightarrow> det A \<noteq> 0"
   1.440  proof-
   1.441 @@ -782,7 +782,7 @@
   1.442    {assume H: "\<not> invertible A"
   1.443      let ?U = "{1 .. dimindex(UNIV :: 'n set)}"
   1.444      have fU: "finite ?U" by simp
   1.445 -    from H obtain c i where c: "setsum (\<lambda>i. c i *s row i A) ?U = 0" 
   1.446 +    from H obtain c i where c: "setsum (\<lambda>i. c i *s row i A) ?U = 0"
   1.447        and iU: "i \<in> ?U" and ci: "c i \<noteq> 0"
   1.448        unfolding invertible_righ_inverse
   1.449        unfolding matrix_right_invertible_independent_rows by blast
   1.450 @@ -791,14 +791,14 @@
   1.451        apply (simp only: ab_left_minus add_assoc[symmetric])
   1.452        apply simp
   1.453        done
   1.454 -    from c ci 
   1.455 +    from c ci
   1.456      have thr0: "- row i A = setsum (\<lambda>j. (1/ c i) *s c j *s row j A) (?U - {i})"
   1.457 -      unfolding setsum_diff1'[OF fU iU] setsum_cmul 
   1.458 +      unfolding setsum_diff1'[OF fU iU] setsum_cmul
   1.459        apply (simp add: field_simps)
   1.460        apply (rule vector_mul_lcancel_imp[OF ci])
   1.461        apply (auto simp add: vector_smult_assoc vector_smult_rneg field_simps)
   1.462        unfolding stupid ..
   1.463 -    have thr: "- row i A \<in> span {row j A| j. j\<in> ?U \<and> j \<noteq> i}" 
   1.464 +    have thr: "- row i A \<in> span {row j A| j. j\<in> ?U \<and> j \<noteq> i}"
   1.465        unfolding thr0
   1.466        apply (rule span_setsum)
   1.467        apply simp
   1.468 @@ -808,8 +808,8 @@
   1.469        apply auto
   1.470        done
   1.471      let ?B = "(\<chi> k. if k = i then 0 else row k A) :: real ^'n^'n"
   1.472 -    have thrb: "row i ?B = 0" using iU by (vector row_def) 
   1.473 -    have "det A = 0" 
   1.474 +    have thrb: "row i ?B = 0" using iU by (vector row_def)
   1.475 +    have "det A = 0"
   1.476        unfolding det_row_span[OF iU thr, symmetric] right_minus
   1.477        unfolding  det_zero_row[OF iU thrb]  ..}
   1.478    ultimately show ?thesis by blast
   1.479 @@ -823,8 +823,8 @@
   1.480    fixes A:: "'a::ordered_idom^'n^'n" and x :: "'a ^'n"
   1.481    assumes k: "k \<in> {1 .. dimindex(UNIV ::'n set)}"
   1.482    shows "det ((\<chi> i. if i = k then setsum (\<lambda>i. x$i *s row i A) {1 .. dimindex(UNIV::'n set)}
   1.483 -                           else row i A)::'a^'n^'n) = x$k * det A" 
   1.484 -  (is "?lhs = ?rhs") 
   1.485 +                           else row i A)::'a^'n^'n) = x$k * det A"
   1.486 +  (is "?lhs = ?rhs")
   1.487  proof-
   1.488    let ?U = "{1 .. dimindex (UNIV :: 'n set)}"
   1.489    let ?Uk = "?U - {k}"
   1.490 @@ -835,7 +835,7 @@
   1.491      by (vector ring_simps)
   1.492    have th001: "\<And>f k . (\<lambda>x. if x = k then f k else f x) = f" by (auto intro: ext)
   1.493    have "(\<chi> i. row i A) = A" by (vector row_def)
   1.494 -  then have thd1: "det (\<chi> i. row i A) = det A"  by simp 
   1.495 +  then have thd1: "det (\<chi> i. row i A) = det A"  by simp
   1.496    have thd0: "det (\<chi> i. if i = k then row k A + (\<Sum>i \<in> ?Uk. x $ i *s row i A) else row i A) = det A"
   1.497      apply (rule det_row_span[OF k])
   1.498      apply (rule span_setsum[OF fUk])
   1.499 @@ -846,7 +846,7 @@
   1.500      done
   1.501    show "?lhs = x$k * det A"
   1.502      apply (subst U)
   1.503 -    unfolding setsum_insert[OF fUk kUk] 
   1.504 +    unfolding setsum_insert[OF fUk kUk]
   1.505      apply (subst th00)
   1.506      unfolding add_assoc
   1.507      apply (subst det_row_add[OF k])
   1.508 @@ -863,8 +863,8 @@
   1.509  proof-
   1.510    have stupid: "\<And>c. setsum (\<lambda>i. c i *s row i (transp A)) ?U = setsum (\<lambda>i. c i *s column i A) ?U"
   1.511      by (auto simp add: row_transp intro: setsum_cong2)
   1.512 -  show ?thesis 
   1.513 -  unfolding matrix_mult_vsum 
   1.514 +  show ?thesis
   1.515 +  unfolding matrix_mult_vsum
   1.516    unfolding cramer_lemma_transp[OF k, of x "transp A", unfolded det_transp, symmetric]
   1.517    unfolding stupid[of "\<lambda>i. x$i"]
   1.518    apply (subst det_transp[symmetric])
   1.519 @@ -873,10 +873,10 @@
   1.520  
   1.521  lemma cramer:
   1.522    fixes A ::"real^'n^'n"
   1.523 -  assumes d0: "det A \<noteq> 0" 
   1.524 +  assumes d0: "det A \<noteq> 0"
   1.525    shows "A *v x = b \<longleftrightarrow> x = (\<chi> k. det(\<chi> i j. if j=k then b$i else A$i$j :: real^'n^'n) / det A)"
   1.526  proof-
   1.527 -  from d0 obtain B where B: "A ** B = mat 1" "B ** A = mat 1"  
   1.528 +  from d0 obtain B where B: "A ** B = mat 1" "B ** A = mat 1"
   1.529      unfolding invertible_det_nz[symmetric] invertible_def by blast
   1.530    have "(A ** B) *v b = b" by (simp add: B matrix_vector_mul_lid)
   1.531    hence "A *v (B *v b) = b" by (simp add: matrix_vector_mul_assoc)
   1.532 @@ -896,10 +896,10 @@
   1.533  
   1.534  lemma orthogonal_transformation: "orthogonal_transformation f \<longleftrightarrow> linear f \<and> (\<forall>(v::real ^'n). norm (f v) = norm v)"
   1.535    unfolding orthogonal_transformation_def
   1.536 -  apply auto 
   1.537 +  apply auto
   1.538    apply (erule_tac x=v in allE)+
   1.539    apply (simp add: real_vector_norm_def)
   1.540 -  by (simp add: dot_norm  linear_add[symmetric]) 
   1.541 +  by (simp add: dot_norm  linear_add[symmetric])
   1.542  
   1.543  definition "orthogonal_matrix (Q::'a::semiring_1^'n^'n) \<longleftrightarrow> transp Q ** Q = mat 1 \<and> Q ** transp Q = mat 1"
   1.544  
   1.545 @@ -909,12 +909,12 @@
   1.546  lemma orthogonal_matrix_id: "orthogonal_matrix (mat 1)"
   1.547    by (simp add: orthogonal_matrix_def transp_mat matrix_mul_lid)
   1.548  
   1.549 -lemma orthogonal_matrix_mul: 
   1.550 +lemma orthogonal_matrix_mul:
   1.551    fixes A :: "real ^'n^'n"
   1.552    assumes oA : "orthogonal_matrix A"
   1.553 -  and oB: "orthogonal_matrix B" 
   1.554 +  and oB: "orthogonal_matrix B"
   1.555    shows "orthogonal_matrix(A ** B)"
   1.556 -  using oA oB 
   1.557 +  using oA oB
   1.558    unfolding orthogonal_matrix matrix_transp_mul
   1.559    apply (subst matrix_mul_assoc)
   1.560    apply (subst matrix_mul_assoc[symmetric])
   1.561 @@ -939,7 +939,7 @@
   1.562  	"\<And>b (x::'a::comm_ring_1). x*(if b then 1 else 0) = (if b then x else 0)"
   1.563  	by simp_all
   1.564        from fd[rule_format, of "basis i" "basis j", unfolded matrix_works[OF lf, symmetric] dot_matrix_vector_mul] i j
   1.565 -      have "?A$i$j = ?m1 $ i $ j" 
   1.566 +      have "?A$i$j = ?m1 $ i $ j"
   1.567  	by (simp add: Cart_lambda_beta' dot_def matrix_matrix_mult_def columnvector_def rowvector_def basis_def th0 setsum_delta[OF fU] mat_def del: One_nat_def)}
   1.568      hence "orthogonal_matrix ?mf" unfolding orthogonal_matrix by vector
   1.569      with lf have ?rhs by blast}
   1.570 @@ -953,17 +953,17 @@
   1.571    ultimately show ?thesis by blast
   1.572  qed
   1.573  
   1.574 -lemma det_orthogonal_matrix: 
   1.575 +lemma det_orthogonal_matrix:
   1.576    fixes Q:: "'a::ordered_idom^'n^'n"
   1.577    assumes oQ: "orthogonal_matrix Q"
   1.578    shows "det Q = 1 \<or> det Q = - 1"
   1.579  proof-
   1.580 -  
   1.581 -  have th: "\<And>x::'a. x = 1 \<or> x = - 1 \<longleftrightarrow> x*x = 1" (is "\<And>x::'a. ?ths x") 
   1.582 -  proof- 
   1.583 +
   1.584 +  have th: "\<And>x::'a. x = 1 \<or> x = - 1 \<longleftrightarrow> x*x = 1" (is "\<And>x::'a. ?ths x")
   1.585 +  proof-
   1.586      fix x:: 'a
   1.587      have th0: "x*x - 1 = (x - 1)*(x + 1)" by (simp add: ring_simps)
   1.588 -    have th1: "\<And>(x::'a) y. x = - y \<longleftrightarrow> x + y = 0" 
   1.589 +    have th1: "\<And>(x::'a) y. x = - y \<longleftrightarrow> x + y = 0"
   1.590        apply (subst eq_iff_diff_eq_0) by simp
   1.591      have "x*x = 1 \<longleftrightarrow> x*x - 1 = 0" by simp
   1.592      also have "\<dots> \<longleftrightarrow> x = 1 \<or> x = - 1" unfolding th0 th1 by simp
   1.593 @@ -972,27 +972,27 @@
   1.594    from oQ have "Q ** transp Q = mat 1" by (metis orthogonal_matrix_def)
   1.595    hence "det (Q ** transp Q) = det (mat 1:: 'a^'n^'n)" by simp
   1.596    hence "det Q * det Q = 1" by (simp add: det_mul det_I det_transp)
   1.597 -  then show ?thesis unfolding th . 
   1.598 +  then show ?thesis unfolding th .
   1.599  qed
   1.600  
   1.601  (* ------------------------------------------------------------------------- *)
   1.602  (* Linearity of scaling, and hence isometry, that preserves origin.          *)
   1.603  (* ------------------------------------------------------------------------- *)
   1.604 -lemma scaling_linear: 
   1.605 +lemma scaling_linear:
   1.606    fixes f :: "real ^'n \<Rightarrow> real ^'n"
   1.607    assumes f0: "f 0 = 0" and fd: "\<forall>x y. dist (f x) (f y) = c * dist x y"
   1.608    shows "linear f"
   1.609  proof-
   1.610 -  {fix v w 
   1.611 +  {fix v w
   1.612      {fix x note fd[rule_format, of x 0, unfolded dist_def f0 diff_0_right] }
   1.613      note th0 = this
   1.614 -    have "f v \<bullet> f w = c^2 * (v \<bullet> w)" 
   1.615 +    have "f v \<bullet> f w = c^2 * (v \<bullet> w)"
   1.616        unfolding dot_norm_neg dist_def[symmetric]
   1.617        unfolding th0 fd[rule_format] by (simp add: power2_eq_square field_simps)}
   1.618    note fc = this
   1.619    show ?thesis unfolding linear_def vector_eq
   1.620      by (simp add: dot_lmult dot_ladd dot_rmult dot_radd fc ring_simps)
   1.621 -qed    
   1.622 +qed
   1.623  
   1.624  lemma isometry_linear:
   1.625    "f (0:: real^'n) = (0:: real^'n) \<Longrightarrow> \<forall>x y. dist(f x) (f y) = dist x y
   1.626 @@ -1005,7 +1005,7 @@
   1.627  
   1.628  lemma orthogonal_transformation_isometry:
   1.629    "orthogonal_transformation f \<longleftrightarrow> f(0::real^'n) = (0::real^'n) \<and> (\<forall>x y. dist(f x) (f y) = dist x y)"
   1.630 -  unfolding orthogonal_transformation 
   1.631 +  unfolding orthogonal_transformation
   1.632    apply (rule iffI)
   1.633    apply clarify
   1.634    apply (clarsimp simp add: linear_0 linear_sub[symmetric] dist_def)
   1.635 @@ -1028,12 +1028,12 @@
   1.636    and fd1: "\<forall> x y. norm x = 1 \<longrightarrow> norm y = 1 \<longrightarrow> dist (f x) (f y) = dist x y"
   1.637    shows "\<exists>g. orthogonal_transformation g \<and> (\<forall>x. norm x = 1 \<longrightarrow> g x = f x)"
   1.638  proof-
   1.639 -  {fix x y x' y' x0 y0 x0' y0' :: "real ^'n" 
   1.640 +  {fix x y x' y' x0 y0 x0' y0' :: "real ^'n"
   1.641      assume H: "x = norm x *s x0" "y = norm y *s y0"
   1.642 -    "x' = norm x *s x0'" "y' = norm y *s y0'" 
   1.643 +    "x' = norm x *s x0'" "y' = norm y *s y0'"
   1.644      "norm x0 = 1" "norm x0' = 1" "norm y0 = 1" "norm y0' = 1"
   1.645      "norm(x0' - y0') = norm(x0 - y0)"
   1.646 -    
   1.647 +
   1.648      have "norm(x' - y') = norm(x - y)"
   1.649        apply (subst H(1))
   1.650        apply (subst H(2))
   1.651 @@ -1055,13 +1055,13 @@
   1.652        then have "dist (?g x) (?g y) = dist x y" by simp }
   1.653      moreover
   1.654      {assume "x = 0" "y \<noteq> 0"
   1.655 -      then have "dist (?g x) (?g y) = dist x y" 
   1.656 +      then have "dist (?g x) (?g y) = dist x y"
   1.657  	apply (simp add: dist_def norm_mul)
   1.658  	apply (rule f1[rule_format])
   1.659  	by(simp add: norm_mul field_simps)}
   1.660      moreover
   1.661      {assume "x \<noteq> 0" "y = 0"
   1.662 -      then have "dist (?g x) (?g y) = dist x y" 
   1.663 +      then have "dist (?g x) (?g y) = dist x y"
   1.664  	apply (simp add: dist_def norm_mul)
   1.665  	apply (rule f1[rule_format])
   1.666  	by(simp add: norm_mul field_simps)}
   1.667 @@ -1077,14 +1077,14 @@
   1.668  	norm (inverse (norm x) *s x - inverse (norm y) *s y)"
   1.669  	using z
   1.670  	by (auto simp add: vector_smult_assoc field_simps norm_mul intro: f1[rule_format] fd1[rule_format, unfolded dist_def])
   1.671 -      from z th0[OF th00] have "dist (?g x) (?g y) = dist x y" 
   1.672 +      from z th0[OF th00] have "dist (?g x) (?g y) = dist x y"
   1.673  	by (simp add: dist_def)}
   1.674      ultimately have "dist (?g x) (?g y) = dist x y" by blast}
   1.675    note thd = this
   1.676 -    show ?thesis 
   1.677 +    show ?thesis
   1.678      apply (rule exI[where x= ?g])
   1.679      unfolding orthogonal_transformation_isometry
   1.680 -      using  g0 thfg thd by metis 
   1.681 +      using  g0 thfg thd by metis
   1.682  qed
   1.683  
   1.684  (* ------------------------------------------------------------------------- *)
   1.685 @@ -1094,7 +1094,7 @@
   1.686  definition "rotation_matrix Q \<longleftrightarrow> orthogonal_matrix Q \<and> det Q = 1"
   1.687  definition "rotoinversion_matrix Q \<longleftrightarrow> orthogonal_matrix Q \<and> det Q = - 1"
   1.688  
   1.689 -lemma orthogonal_rotation_or_rotoinversion: 
   1.690 +lemma orthogonal_rotation_or_rotoinversion:
   1.691    fixes Q :: "'a::ordered_idom^'n^'n"
   1.692    shows " orthogonal_matrix Q \<longleftrightarrow> rotation_matrix Q \<or> rotoinversion_matrix Q"
   1.693    by (metis rotoinversion_matrix_def rotation_matrix_def det_orthogonal_matrix)
   1.694 @@ -1104,9 +1104,9 @@
   1.695  
   1.696  lemma setprod_1: "setprod f {(1::nat)..1} = f 1" by simp
   1.697  
   1.698 -lemma setprod_2: "setprod f {(1::nat)..2} = f 1 * f 2" 
   1.699 +lemma setprod_2: "setprod f {(1::nat)..2} = f 1 * f 2"
   1.700    by (simp add: nat_number setprod_numseg mult_commute)
   1.701 -lemma setprod_3: "setprod f {(1::nat)..3} = f 1 * f 2 * f 3" 
   1.702 +lemma setprod_3: "setprod f {(1::nat)..3} = f 1 * f 2 * f 3"
   1.703    by (simp add: nat_number setprod_numseg mult_commute)
   1.704  
   1.705  lemma det_1: "det (A::'a::comm_ring_1^1^1) = A$1$1"
   1.706 @@ -1116,7 +1116,7 @@
   1.707  proof-
   1.708    have f12: "finite {2::nat}" "1 \<notin> {2::nat}" by auto
   1.709    have th12: "{1 .. 2} = insert (1::nat) {2}" by auto
   1.710 -  show ?thesis 
   1.711 +  show ?thesis
   1.712    apply (simp add: det_def dimindex_def th12 del: One_nat_def)
   1.713    unfolding setsum_over_permutations_insert[OF f12]
   1.714    unfolding permutes_sing
   1.715 @@ -1124,7 +1124,7 @@
   1.716    by (simp add: arith_simps(31)[symmetric] of_int_minus of_int_1 del: arith_simps(31))
   1.717  qed
   1.718  
   1.719 -lemma det_3: "det (A::'a::comm_ring_1^3^3) = 
   1.720 +lemma det_3: "det (A::'a::comm_ring_1^3^3) =
   1.721    A$1$1 * A$2$2 * A$3$3 +
   1.722    A$1$2 * A$2$3 * A$3$1 +
   1.723    A$1$3 * A$2$1 * A$3$2 -
   1.724 @@ -1136,7 +1136,7 @@
   1.725    have f23: "finite {(3::nat)}" "2 \<notin> {(3::nat)}" by auto
   1.726    have th12: "{1 .. 3} = insert (1::nat) (insert 2 {3})" by auto
   1.727  
   1.728 -  show ?thesis 
   1.729 +  show ?thesis
   1.730    apply (simp add: det_def dimindex_def th12 del: One_nat_def)
   1.731    unfolding setsum_over_permutations_insert[OF f123]
   1.732    unfolding setsum_over_permutations_insert[OF f23]
     2.1 --- a/src/HOL/Library/Euclidean_Space.thy	Thu Mar 12 08:57:03 2009 -0700
     2.2 +++ b/src/HOL/Library/Euclidean_Space.thy	Thu Mar 12 09:27:23 2009 -0700
     2.3 @@ -5,7 +5,7 @@
     2.4  header {* (Real) Vectors in Euclidean space, and elementary linear algebra.*}
     2.5  
     2.6  theory Euclidean_Space
     2.7 -  imports "~~/src/HOL/Decision_Procs/Dense_Linear_Order" Complex_Main 
     2.8 +  imports "~~/src/HOL/Decision_Procs/Dense_Linear_Order" Complex_Main
     2.9    Finite_Cartesian_Product Glbs Infinite_Set Numeral_Type
    2.10    Inner_Product
    2.11    uses ("normarith.ML")
    2.12 @@ -31,26 +31,26 @@
    2.13  qed
    2.14  
    2.15  lemma setsum_singleton[simp]: "setsum f {x} = f x" by simp
    2.16 -lemma setsum_1: "setsum f {(1::'a::{order,one})..1} = f 1" 
    2.17 +lemma setsum_1: "setsum f {(1::'a::{order,one})..1} = f 1"
    2.18    by (simp add: atLeastAtMost_singleton)
    2.19  
    2.20 -lemma setsum_2: "setsum f {1::nat..2} = f 1 + f 2" 
    2.21 +lemma setsum_2: "setsum f {1::nat..2} = f 1 + f 2"
    2.22    by (simp add: nat_number  atLeastAtMostSuc_conv add_commute)
    2.23  
    2.24 -lemma setsum_3: "setsum f {1::nat..3} = f 1 + f 2 + f 3" 
    2.25 +lemma setsum_3: "setsum f {1::nat..3} = f 1 + f 2 + f 3"
    2.26    by (simp add: nat_number  atLeastAtMostSuc_conv add_commute)
    2.27  
    2.28  subsection{* Basic componentwise operations on vectors. *}
    2.29  
    2.30  instantiation "^" :: (plus,type) plus
    2.31  begin
    2.32 -definition  vector_add_def : "op + \<equiv> (\<lambda> x y.  (\<chi> i. (x$i) + (y$i)))" 
    2.33 +definition  vector_add_def : "op + \<equiv> (\<lambda> x y.  (\<chi> i. (x$i) + (y$i)))"
    2.34  instance ..
    2.35  end
    2.36  
    2.37  instantiation "^" :: (times,type) times
    2.38  begin
    2.39 -  definition vector_mult_def : "op * \<equiv> (\<lambda> x y.  (\<chi> i. (x$i) * (y$i)))" 
    2.40 +  definition vector_mult_def : "op * \<equiv> (\<lambda> x y.  (\<chi> i. (x$i) * (y$i)))"
    2.41    instance ..
    2.42  end
    2.43  
    2.44 @@ -64,12 +64,12 @@
    2.45  instance ..
    2.46  end
    2.47  instantiation "^" :: (zero,type) zero begin
    2.48 -  definition vector_zero_def : "0 \<equiv> (\<chi> i. 0)" 
    2.49 +  definition vector_zero_def : "0 \<equiv> (\<chi> i. 0)"
    2.50  instance ..
    2.51  end
    2.52  
    2.53  instantiation "^" :: (one,type) one begin
    2.54 -  definition vector_one_def : "1 \<equiv> (\<chi> i. 1)" 
    2.55 +  definition vector_one_def : "1 \<equiv> (\<chi> i. 1)"
    2.56  instance ..
    2.57  end
    2.58  
    2.59 @@ -80,13 +80,13 @@
    2.60    x$i <= y$i)"
    2.61  definition vector_less_def: "less (x :: 'a ^'b) y = (ALL i : {1 ..
    2.62    dimindex (UNIV :: 'b set)}. x$i < y$i)"
    2.63 - 
    2.64 +
    2.65  instance by (intro_classes)
    2.66  end
    2.67  
    2.68  instantiation "^" :: (scaleR, type) scaleR
    2.69  begin
    2.70 -definition vector_scaleR_def: "scaleR = (\<lambda> r x.  (\<chi> i. scaleR r (x$i)))" 
    2.71 +definition vector_scaleR_def: "scaleR = (\<lambda> r x.  (\<chi> i. scaleR r (x$i)))"
    2.72  instance ..
    2.73  end
    2.74  
    2.75 @@ -117,19 +117,19 @@
    2.76  lemmas Cart_lambda_beta' = Cart_lambda_beta[rule_format]
    2.77  method_setup vector = {*
    2.78  let
    2.79 -  val ss1 = HOL_basic_ss addsimps [@{thm dot_def}, @{thm setsum_addf} RS sym, 
    2.80 -  @{thm setsum_subtractf} RS sym, @{thm setsum_right_distrib}, 
    2.81 +  val ss1 = HOL_basic_ss addsimps [@{thm dot_def}, @{thm setsum_addf} RS sym,
    2.82 +  @{thm setsum_subtractf} RS sym, @{thm setsum_right_distrib},
    2.83    @{thm setsum_left_distrib}, @{thm setsum_negf} RS sym]
    2.84 -  val ss2 = @{simpset} addsimps 
    2.85 -             [@{thm vector_add_def}, @{thm vector_mult_def},  
    2.86 -              @{thm vector_minus_def}, @{thm vector_uminus_def}, 
    2.87 -              @{thm vector_one_def}, @{thm vector_zero_def}, @{thm vec_def}, 
    2.88 +  val ss2 = @{simpset} addsimps
    2.89 +             [@{thm vector_add_def}, @{thm vector_mult_def},
    2.90 +              @{thm vector_minus_def}, @{thm vector_uminus_def},
    2.91 +              @{thm vector_one_def}, @{thm vector_zero_def}, @{thm vec_def},
    2.92                @{thm vector_scaleR_def},
    2.93                @{thm Cart_lambda_beta'}, @{thm vector_scalar_mult_def}]
    2.94 - fun vector_arith_tac ths = 
    2.95 + fun vector_arith_tac ths =
    2.96     simp_tac ss1
    2.97     THEN' (fn i => rtac @{thm setsum_cong2} i
    2.98 -         ORELSE rtac @{thm setsum_0'} i 
    2.99 +         ORELSE rtac @{thm setsum_0'} i
   2.100           ORELSE simp_tac (HOL_basic_ss addsimps [@{thm "Cart_eq"}]) i)
   2.101     (* THEN' TRY o clarify_tac HOL_cs  THEN' (TRY o rtac @{thm iffI}) *)
   2.102     THEN' asm_full_simp_tac (ss2 addsimps ths)
   2.103 @@ -145,30 +145,30 @@
   2.104  
   2.105  text{* Obvious "component-pushing". *}
   2.106  
   2.107 -lemma vec_component: " i \<in> {1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (vec x :: 'a ^ 'n)$i = x" 
   2.108 -  by (vector vec_def) 
   2.109 -
   2.110 -lemma vector_add_component: 
   2.111 +lemma vec_component: " i \<in> {1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (vec x :: 'a ^ 'n)$i = x"
   2.112 +  by (vector vec_def)
   2.113 +
   2.114 +lemma vector_add_component:
   2.115    fixes x y :: "'a::{plus} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
   2.116    shows "(x + y)$i = x$i + y$i"
   2.117    using i by vector
   2.118  
   2.119 -lemma vector_minus_component: 
   2.120 +lemma vector_minus_component:
   2.121    fixes x y :: "'a::{minus} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
   2.122    shows "(x - y)$i = x$i - y$i"
   2.123    using i  by vector
   2.124  
   2.125 -lemma vector_mult_component: 
   2.126 +lemma vector_mult_component:
   2.127    fixes x y :: "'a::{times} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
   2.128    shows "(x * y)$i = x$i * y$i"
   2.129    using i by vector
   2.130  
   2.131 -lemma vector_smult_component: 
   2.132 +lemma vector_smult_component:
   2.133    fixes y :: "'a::{times} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
   2.134    shows "(c *s y)$i = c * (y$i)"
   2.135    using i by vector
   2.136  
   2.137 -lemma vector_uminus_component: 
   2.138 +lemma vector_uminus_component:
   2.139    fixes x :: "'a::{uminus} ^ 'n"  assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
   2.140    shows "(- x)$i = - (x$i)"
   2.141    using i by vector
   2.142 @@ -188,26 +188,26 @@
   2.143  
   2.144  subsection {* Some frequently useful arithmetic lemmas over vectors. *}
   2.145  
   2.146 -instance "^" :: (semigroup_add,type) semigroup_add 
   2.147 +instance "^" :: (semigroup_add,type) semigroup_add
   2.148    apply (intro_classes) by (vector add_assoc)
   2.149  
   2.150  
   2.151 -instance "^" :: (monoid_add,type) monoid_add 
   2.152 -  apply (intro_classes) by vector+ 
   2.153 -
   2.154 -instance "^" :: (group_add,type) group_add 
   2.155 -  apply (intro_classes) by (vector algebra_simps)+ 
   2.156 -
   2.157 -instance "^" :: (ab_semigroup_add,type) ab_semigroup_add 
   2.158 +instance "^" :: (monoid_add,type) monoid_add
   2.159 +  apply (intro_classes) by vector+
   2.160 +
   2.161 +instance "^" :: (group_add,type) group_add
   2.162 +  apply (intro_classes) by (vector algebra_simps)+
   2.163 +
   2.164 +instance "^" :: (ab_semigroup_add,type) ab_semigroup_add
   2.165    apply (intro_classes) by (vector add_commute)
   2.166  
   2.167  instance "^" :: (comm_monoid_add,type) comm_monoid_add
   2.168    apply (intro_classes) by vector
   2.169  
   2.170 -instance "^" :: (ab_group_add,type) ab_group_add 
   2.171 +instance "^" :: (ab_group_add,type) ab_group_add
   2.172    apply (intro_classes) by vector+
   2.173  
   2.174 -instance "^" :: (cancel_semigroup_add,type) cancel_semigroup_add 
   2.175 +instance "^" :: (cancel_semigroup_add,type) cancel_semigroup_add
   2.176    apply (intro_classes)
   2.177    by (vector Cart_eq)+
   2.178  
   2.179 @@ -218,30 +218,30 @@
   2.180  instance "^" :: (real_vector, type) real_vector
   2.181    by default (vector scaleR_left_distrib scaleR_right_distrib)+
   2.182  
   2.183 -instance "^" :: (semigroup_mult,type) semigroup_mult 
   2.184 +instance "^" :: (semigroup_mult,type) semigroup_mult
   2.185    apply (intro_classes) by (vector mult_assoc)
   2.186  
   2.187 -instance "^" :: (monoid_mult,type) monoid_mult 
   2.188 +instance "^" :: (monoid_mult,type) monoid_mult
   2.189    apply (intro_classes) by vector+
   2.190  
   2.191 -instance "^" :: (ab_semigroup_mult,type) ab_semigroup_mult 
   2.192 +instance "^" :: (ab_semigroup_mult,type) ab_semigroup_mult
   2.193    apply (intro_classes) by (vector mult_commute)
   2.194  
   2.195 -instance "^" :: (ab_semigroup_idem_mult,type) ab_semigroup_idem_mult 
   2.196 +instance "^" :: (ab_semigroup_idem_mult,type) ab_semigroup_idem_mult
   2.197    apply (intro_classes) by (vector mult_idem)
   2.198  
   2.199 -instance "^" :: (comm_monoid_mult,type) comm_monoid_mult 
   2.200 +instance "^" :: (comm_monoid_mult,type) comm_monoid_mult
   2.201    apply (intro_classes) by vector
   2.202  
   2.203  fun vector_power :: "('a::{one,times} ^'n) \<Rightarrow> nat \<Rightarrow> 'a^'n" where
   2.204    "vector_power x 0 = 1"
   2.205    | "vector_power x (Suc n) = x * vector_power x n"
   2.206  
   2.207 -instantiation "^" :: (recpower,type) recpower 
   2.208 +instantiation "^" :: (recpower,type) recpower
   2.209  begin
   2.210    definition vec_power_def: "op ^ \<equiv> vector_power"
   2.211 -  instance 
   2.212 -  apply (intro_classes) by (simp_all add: vec_power_def) 
   2.213 +  instance
   2.214 +  apply (intro_classes) by (simp_all add: vec_power_def)
   2.215  end
   2.216  
   2.217  instance "^" :: (semiring,type) semiring
   2.218 @@ -250,16 +250,16 @@
   2.219  instance "^" :: (semiring_0,type) semiring_0
   2.220    apply (intro_classes) by (vector ring_simps)+
   2.221  instance "^" :: (semiring_1,type) semiring_1
   2.222 -  apply (intro_classes) apply vector using dimindex_ge_1 by auto 
   2.223 +  apply (intro_classes) apply vector using dimindex_ge_1 by auto
   2.224  instance "^" :: (comm_semiring,type) comm_semiring
   2.225    apply (intro_classes) by (vector ring_simps)+
   2.226  
   2.227 -instance "^" :: (comm_semiring_0,type) comm_semiring_0 by (intro_classes) 
   2.228 +instance "^" :: (comm_semiring_0,type) comm_semiring_0 by (intro_classes)
   2.229  instance "^" :: (cancel_comm_monoid_add, type) cancel_comm_monoid_add ..
   2.230 -instance "^" :: (semiring_0_cancel,type) semiring_0_cancel by (intro_classes) 
   2.231 -instance "^" :: (comm_semiring_0_cancel,type) comm_semiring_0_cancel by (intro_classes) 
   2.232 -instance "^" :: (ring,type) ring by (intro_classes) 
   2.233 -instance "^" :: (semiring_1_cancel,type) semiring_1_cancel by (intro_classes) 
   2.234 +instance "^" :: (semiring_0_cancel,type) semiring_0_cancel by (intro_classes)
   2.235 +instance "^" :: (comm_semiring_0_cancel,type) comm_semiring_0_cancel by (intro_classes)
   2.236 +instance "^" :: (ring,type) ring by (intro_classes)
   2.237 +instance "^" :: (semiring_1_cancel,type) semiring_1_cancel by (intro_classes)
   2.238  instance "^" :: (comm_semiring_1,type) comm_semiring_1 by (intro_classes)
   2.239  
   2.240  instance "^" :: (ring_1,type) ring_1 ..
   2.241 @@ -273,31 +273,31 @@
   2.242  
   2.243  instance "^" :: (real_algebra_1,type) real_algebra_1 ..
   2.244  
   2.245 -lemma of_nat_index: 
   2.246 +lemma of_nat_index:
   2.247    "i\<in>{1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (of_nat n :: 'a::semiring_1 ^'n)$i = of_nat n"
   2.248    apply (induct n)
   2.249    apply vector
   2.250    apply vector
   2.251    done
   2.252 -lemma zero_index[simp]: 
   2.253 +lemma zero_index[simp]:
   2.254    "i\<in>{1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (0 :: 'a::zero ^'n)$i = 0" by vector
   2.255  
   2.256 -lemma one_index[simp]: 
   2.257 +lemma one_index[simp]:
   2.258    "i\<in>{1 .. dimindex (UNIV :: 'n set)} \<Longrightarrow> (1 :: 'a::one ^'n)$i = 1" by vector
   2.259  
   2.260  lemma one_plus_of_nat_neq_0: "(1::'a::semiring_char_0) + of_nat n \<noteq> 0"
   2.261  proof-
   2.262    have "(1::'a) + of_nat n = 0 \<longleftrightarrow> of_nat 1 + of_nat n = (of_nat 0 :: 'a)" by simp
   2.263 -  also have "\<dots> \<longleftrightarrow> 1 + n = 0" by (simp only: of_nat_add[symmetric] of_nat_eq_iff) 
   2.264 -  finally show ?thesis by simp 
   2.265 +  also have "\<dots> \<longleftrightarrow> 1 + n = 0" by (simp only: of_nat_add[symmetric] of_nat_eq_iff)
   2.266 +  finally show ?thesis by simp
   2.267  qed
   2.268  
   2.269 -instance "^" :: (semiring_char_0,type) semiring_char_0 
   2.270 -proof (intro_classes) 
   2.271 +instance "^" :: (semiring_char_0,type) semiring_char_0
   2.272 +proof (intro_classes)
   2.273    fix m n ::nat
   2.274    show "(of_nat m :: 'a^'b) = of_nat n \<longleftrightarrow> m = n"
   2.275    proof(induct m arbitrary: n)
   2.276 -    case 0 thus ?case apply vector 
   2.277 +    case 0 thus ?case apply vector
   2.278        apply (induct n,auto simp add: ring_simps)
   2.279        using dimindex_ge_1 apply auto
   2.280        apply vector
   2.281 @@ -323,24 +323,24 @@
   2.282  instance "^" :: (comm_ring_1,type) comm_ring_1 by intro_classes
   2.283  instance "^" :: (ring_char_0,type) ring_char_0 by intro_classes
   2.284  
   2.285 -lemma vector_smult_assoc: "a *s (b *s x) = ((a::'a::semigroup_mult) * b) *s x"  
   2.286 +lemma vector_smult_assoc: "a *s (b *s x) = ((a::'a::semigroup_mult) * b) *s x"
   2.287    by (vector mult_assoc)
   2.288 -lemma vector_sadd_rdistrib: "((a::'a::semiring) + b) *s x = a *s x + b *s x" 
   2.289 +lemma vector_sadd_rdistrib: "((a::'a::semiring) + b) *s x = a *s x + b *s x"
   2.290    by (vector ring_simps)
   2.291 -lemma vector_add_ldistrib: "(c::'a::semiring) *s (x + y) = c *s x + c *s y" 
   2.292 +lemma vector_add_ldistrib: "(c::'a::semiring) *s (x + y) = c *s x + c *s y"
   2.293    by (vector ring_simps)
   2.294  lemma vector_smult_lzero[simp]: "(0::'a::mult_zero) *s x = 0" by vector
   2.295  lemma vector_smult_lid[simp]: "(1::'a::monoid_mult) *s x = x" by vector
   2.296 -lemma vector_ssub_ldistrib: "(c::'a::ring) *s (x - y) = c *s x - c *s y" 
   2.297 +lemma vector_ssub_ldistrib: "(c::'a::ring) *s (x - y) = c *s x - c *s y"
   2.298    by (vector ring_simps)
   2.299  lemma vector_smult_rneg: "(c::'a::ring) *s -x = -(c *s x)" by vector
   2.300  lemma vector_smult_lneg: "- (c::'a::ring) *s x = -(c *s x)" by vector
   2.301  lemma vector_sneg_minus1: "-x = (- (1::'a::ring_1)) *s x" by vector
   2.302  lemma vector_smult_rzero[simp]: "c *s 0 = (0::'a::mult_zero ^ 'n)" by vector
   2.303 -lemma vector_sub_rdistrib: "((a::'a::ring) - b) *s x = a *s x - b *s x" 
   2.304 +lemma vector_sub_rdistrib: "((a::'a::ring) - b) *s x = a *s x - b *s x"
   2.305    by (vector ring_simps)
   2.306  
   2.307 -lemma vec_eq[simp]: "(vec m = vec n) \<longleftrightarrow> (m = n)" 
   2.308 +lemma vec_eq[simp]: "(vec m = vec n) \<longleftrightarrow> (m = n)"
   2.309    apply (auto simp add: vec_def Cart_eq vec_component Cart_lambda_beta )
   2.310    using dimindex_ge_1 apply auto done
   2.311  
   2.312 @@ -581,15 +581,15 @@
   2.313  
   2.314  subsection{* Properties of the dot product.  *}
   2.315  
   2.316 -lemma dot_sym: "(x::'a:: {comm_monoid_add, ab_semigroup_mult} ^ 'n) \<bullet> y = y \<bullet> x" 
   2.317 +lemma dot_sym: "(x::'a:: {comm_monoid_add, ab_semigroup_mult} ^ 'n) \<bullet> y = y \<bullet> x"
   2.318    by (vector mult_commute)
   2.319  lemma dot_ladd: "((x::'a::ring ^ 'n) + y) \<bullet> z = (x \<bullet> z) + (y \<bullet> z)"
   2.320    by (vector ring_simps)
   2.321 -lemma dot_radd: "x \<bullet> (y + (z::'a::ring ^ 'n)) = (x \<bullet> y) + (x \<bullet> z)" 
   2.322 +lemma dot_radd: "x \<bullet> (y + (z::'a::ring ^ 'n)) = (x \<bullet> y) + (x \<bullet> z)"
   2.323    by (vector ring_simps)
   2.324 -lemma dot_lsub: "((x::'a::ring ^ 'n) - y) \<bullet> z = (x \<bullet> z) - (y \<bullet> z)" 
   2.325 +lemma dot_lsub: "((x::'a::ring ^ 'n) - y) \<bullet> z = (x \<bullet> z) - (y \<bullet> z)"
   2.326    by (vector ring_simps)
   2.327 -lemma dot_rsub: "(x::'a::ring ^ 'n) \<bullet> (y - z) = (x \<bullet> y) - (x \<bullet> z)" 
   2.328 +lemma dot_rsub: "(x::'a::ring ^ 'n) \<bullet> (y - z) = (x \<bullet> y) - (x \<bullet> z)"
   2.329    by (vector ring_simps)
   2.330  lemma dot_lmult: "(c *s x) \<bullet> y = (c::'a::ring) * (x \<bullet> y)" by (vector ring_simps)
   2.331  lemma dot_rmult: "x \<bullet> (c *s y) = (c::'a::comm_ring) * (x \<bullet> y)" by (vector ring_simps)
   2.332 @@ -625,8 +625,8 @@
   2.333    ultimately show ?thesis by metis
   2.334  qed
   2.335  
   2.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] 
   2.337 -  by (auto simp add: le_less) 
   2.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]
   2.339 +  by (auto simp add: le_less)
   2.340  
   2.341  subsection{* The collapse of the general concepts to dimension one. *}
   2.342  
   2.343 @@ -642,13 +642,13 @@
   2.344  lemma norm_vector_1: "norm (x :: _^1) = norm (x$1)"
   2.345    by (simp add: vector_norm_def dimindex_def)
   2.346  
   2.347 -lemma norm_real: "norm(x::real ^ 1) = abs(x$1)" 
   2.348 +lemma norm_real: "norm(x::real ^ 1) = abs(x$1)"
   2.349    by (simp add: norm_vector_1)
   2.350  
   2.351  text{* Metric *}
   2.352  
   2.353  text {* FIXME: generalize to arbitrary @{text real_normed_vector} types *}
   2.354 -definition dist:: "real ^ 'n \<Rightarrow> real ^ 'n \<Rightarrow> real" where 
   2.355 +definition dist:: "real ^ 'n \<Rightarrow> real ^ 'n \<Rightarrow> real" where
   2.356    "dist x y = norm (x - y)"
   2.357  
   2.358  lemma dist_real: "dist(x::real ^ 1) y = abs((x$1) - (y$1))"
   2.359 @@ -667,14 +667,14 @@
   2.360    shows "\<exists>x \<ge> a. x <= b \<and> f x \<notin> e1 \<and> f x \<notin> e2" (is "\<exists> x. ?P x")
   2.361  proof-
   2.362    let ?S = "{c. \<forall>x \<ge> a. x <= c \<longrightarrow> f x \<in> e1}"
   2.363 -  have Se: " \<exists>x. x \<in> ?S" apply (rule exI[where x=a]) by (auto simp add: fa) 
   2.364 -  have Sub: "\<exists>y. isUb UNIV ?S y" 
   2.365 +  have Se: " \<exists>x. x \<in> ?S" apply (rule exI[where x=a]) by (auto simp add: fa)
   2.366 +  have Sub: "\<exists>y. isUb UNIV ?S y"
   2.367      apply (rule exI[where x= b])
   2.368 -    using ab fb e12 by (auto simp add: isUb_def setle_def)  
   2.369 -  from reals_complete[OF Se Sub] obtain l where 
   2.370 +    using ab fb e12 by (auto simp add: isUb_def setle_def)
   2.371 +  from reals_complete[OF Se Sub] obtain l where
   2.372      l: "isLub UNIV ?S l"by blast
   2.373    have alb: "a \<le> l" "l \<le> b" using l ab fa fb e12
   2.374 -    apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)    
   2.375 +    apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
   2.376      by (metis linorder_linear)
   2.377    have ale1: "\<forall>z \<ge> a. z < l \<longrightarrow> f z \<in> e1" using l
   2.378      apply (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
   2.379 @@ -685,11 +685,11 @@
   2.380      {assume le2: "f l \<in> e2"
   2.381        from le2 fa fb e12 alb have la: "l \<noteq> a" by metis
   2.382        hence lap: "l - a > 0" using alb by arith
   2.383 -      from e2[rule_format, OF le2] obtain e where 
   2.384 +      from e2[rule_format, OF le2] obtain e where
   2.385  	e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e2" by metis
   2.386 -      from dst[OF alb e(1)] obtain d where 
   2.387 +      from dst[OF alb e(1)] obtain d where
   2.388  	d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis
   2.389 -      have "\<exists>d'. d' < d \<and> d' >0 \<and> l - d' > a" using lap d(1) 
   2.390 +      have "\<exists>d'. d' < d \<and> d' >0 \<and> l - d' > a" using lap d(1)
   2.391  	apply ferrack by arith
   2.392        then obtain d' where d': "d' > 0" "d' < d" "l - d' > a" by metis
   2.393        from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e2" by metis
   2.394 @@ -701,16 +701,16 @@
   2.395      {assume le1: "f l \<in> e1"
   2.396      from le1 fa fb e12 alb have lb: "l \<noteq> b" by metis
   2.397        hence blp: "b - l > 0" using alb by arith
   2.398 -      from e1[rule_format, OF le1] obtain e where 
   2.399 +      from e1[rule_format, OF le1] obtain e where
   2.400  	e: "e > 0" "\<forall>y. dist y (f l) < e \<longrightarrow> y \<in> e1" by metis
   2.401 -      from dst[OF alb e(1)] obtain d where 
   2.402 +      from dst[OF alb e(1)] obtain d where
   2.403  	d: "d > 0" "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> dist (f y) (f l) < e" by metis
   2.404 -      have "\<exists>d'. d' < d \<and> d' >0" using d(1) by dlo 
   2.405 +      have "\<exists>d'. d' < d \<and> d' >0" using d(1) by dlo
   2.406        then obtain d' where d': "d' > 0" "d' < d" by metis
   2.407        from d e have th0: "\<forall>y. \<bar>y - l\<bar> < d \<longrightarrow> f y \<in> e1" by auto
   2.408        hence "\<forall>y. l \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" using d' by auto
   2.409        with ale1 have "\<forall>y. a \<le> y \<and> y \<le> l + d' \<longrightarrow> f y \<in> e1" by auto
   2.410 -      with l d' have False 
   2.411 +      with l d' have False
   2.412  	by (auto simp add: isLub_def isUb_def setle_def setge_def leastP_def) }
   2.413      ultimately show ?thesis using alb by metis
   2.414  qed
   2.415 @@ -719,7 +719,7 @@
   2.416  
   2.417  lemma square_bound_lemma: "(x::real) < (1 + x) * (1 + x)"
   2.418  proof-
   2.419 -  have "(x + 1/2)^2 + 3/4 > 0" using zero_le_power2[of "x+1/2"] by arith 
   2.420 +  have "(x + 1/2)^2 + 3/4 > 0" using zero_le_power2[of "x+1/2"] by arith
   2.421    thus ?thesis by (simp add: ring_simps power2_eq_square)
   2.422  qed
   2.423  
   2.424 @@ -740,14 +740,14 @@
   2.425  lemma real_less_rsqrt: "x^2 < y \<Longrightarrow> x < sqrt y"
   2.426    using real_sqrt_less_mono[of "x^2" y] by simp
   2.427  
   2.428 -lemma sqrt_even_pow2: assumes n: "even n" 
   2.429 +lemma sqrt_even_pow2: assumes n: "even n"
   2.430    shows "sqrt(2 ^ n) = 2 ^ (n div 2)"
   2.431  proof-
   2.432 -  from n obtain m where m: "n = 2*m" unfolding even_nat_equiv_def2 
   2.433 -    by (auto simp add: nat_number) 
   2.434 +  from n obtain m where m: "n = 2*m" unfolding even_nat_equiv_def2
   2.435 +    by (auto simp add: nat_number)
   2.436    from m  have "sqrt(2 ^ n) = sqrt ((2 ^ m) ^ 2)"
   2.437      by (simp only: power_mult[symmetric] mult_commute)
   2.438 -  then show ?thesis  using m by simp 
   2.439 +  then show ?thesis  using m by simp
   2.440  qed
   2.441  
   2.442  lemma real_div_sqrt: "0 <= x ==> x / sqrt(x) = sqrt(x)"
   2.443 @@ -786,7 +786,7 @@
   2.444    {assume "norm x = 0"
   2.445      hence ?thesis by (simp add: dot_lzero dot_rzero)}
   2.446    moreover
   2.447 -  {assume "norm y = 0" 
   2.448 +  {assume "norm y = 0"
   2.449      hence ?thesis by (simp add: dot_lzero dot_rzero)}
   2.450    moreover
   2.451    {assume h: "norm x \<noteq> 0" "norm y \<noteq> 0"
   2.452 @@ -829,7 +829,7 @@
   2.453  lemma norm_le_l1: "norm (x:: real ^'n) <= setsum(\<lambda>i. \<bar>x$i\<bar>) {1..dimindex(UNIV::'n set)}"
   2.454    by (simp add: vector_norm_def setL2_le_setsum)
   2.455  
   2.456 -lemma real_abs_norm[simp]: "\<bar> norm x\<bar> = norm (x :: real ^'n)" 
   2.457 +lemma real_abs_norm[simp]: "\<bar> norm x\<bar> = norm (x :: real ^'n)"
   2.458    by (rule abs_norm_cancel)
   2.459  lemma real_abs_sub_norm: "\<bar>norm(x::real ^'n) - norm y\<bar> <= norm(x - y)"
   2.460    by (rule norm_triangle_ineq3)
   2.461 @@ -863,7 +863,7 @@
   2.462    apply arith
   2.463    done
   2.464  
   2.465 -lemma norm_ge_square: "norm(x) >= a \<longleftrightarrow> a <= 0 \<or> x \<bullet> x >= a ^ 2" 
   2.466 +lemma norm_ge_square: "norm(x) >= a \<longleftrightarrow> a <= 0 \<or> x \<bullet> x >= a ^ 2"
   2.467    apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric])
   2.468    using norm_ge_zero[of x]
   2.469    apply arith
   2.470 @@ -891,7 +891,7 @@
   2.471  next
   2.472    assume ?rhs
   2.473    then have "x \<bullet> x - x \<bullet> y = 0 \<and> x \<bullet> y - y\<bullet> y = 0" by simp
   2.474 -  hence "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0" 
   2.475 +  hence "x \<bullet> (x - y) = 0 \<and> y \<bullet> (x - y) = 0"
   2.476      by (simp add: dot_rsub dot_lsub dot_sym)
   2.477    then have "(x - y) \<bullet> (x - y) = 0" by (simp add: ring_simps dot_lsub dot_rsub)
   2.478    then show "x = y" by (simp add: dot_eq_0)
   2.479 @@ -919,13 +919,13 @@
   2.480  lemma pth_4: "0 *s (x::real^'n) == 0" "c *s 0 = (0::real ^ 'n)" by vector+
   2.481  lemma pth_5: "c *s (d *s x) == (c * d) *s (x::real ^ 'n)" by (atomize (full)) vector
   2.482  lemma pth_6: "(c::real) *s (x + y) == c *s x + c *s y" by (atomize (full)) (vector ring_simps)
   2.483 -lemma pth_7: "0 + x == (x::real^'n)" "x + 0 == x" by simp_all 
   2.484 -lemma pth_8: "(c::real) *s x + d *s x == (c + d) *s x" by (atomize (full)) (vector ring_simps) 
   2.485 +lemma pth_7: "0 + x == (x::real^'n)" "x + 0 == x" by simp_all
   2.486 +lemma pth_8: "(c::real) *s x + d *s x == (c + d) *s x" by (atomize (full)) (vector ring_simps)
   2.487  lemma pth_9: "((c::real) *s x + z) + d *s x == (c + d) *s x + z"
   2.488    "c *s x + (d *s x + z) == (c + d) *s x + z"
   2.489    "(c *s x + w) + (d *s x + z) == (c + d) *s x + (w + z)" by ((atomize (full)), vector ring_simps)+
   2.490  lemma pth_a: "(0::real) *s x + y == y" by (atomize (full)) vector
   2.491 -lemma pth_b: "(c::real) *s x + d *s y == c *s x + d *s y" 
   2.492 +lemma pth_b: "(c::real) *s x + d *s y == c *s x + d *s y"
   2.493    "(c *s x + z) + d *s y == c *s x + (z + d *s y)"
   2.494    "c *s x + (d *s y + z) == c *s x + (d *s y + z)"
   2.495    "(c *s x + w) + (d *s y + z) == c *s x + (w + (d *s y + z))"
   2.496 @@ -941,7 +941,7 @@
   2.497  
   2.498  lemma real_eq_0_iff_le_ge_0: "(x::real) = 0 == x \<ge> 0 \<and> -x \<ge> 0" by arith
   2.499  
   2.500 -lemma norm_pths: 
   2.501 +lemma norm_pths:
   2.502    "(x::real ^'n) = y \<longleftrightarrow> norm (x - y) \<le> 0"
   2.503    "x \<noteq> y \<longleftrightarrow> \<not> (norm (x - y) \<le> 0)"
   2.504    using norm_ge_zero[of "x - y"] by auto
   2.505 @@ -967,26 +967,26 @@
   2.506  
   2.507  lemma dist_eq_0[simp]: "dist x y = 0 \<longleftrightarrow> x = y" by norm
   2.508  
   2.509 -lemma dist_pos_lt: "x \<noteq> y ==> 0 < dist x y" by norm 
   2.510 -lemma dist_nz:  "x \<noteq> y \<longleftrightarrow> 0 < dist x y" by norm 
   2.511 -
   2.512 -lemma dist_triangle_le: "dist x z + dist y z <= e \<Longrightarrow> dist x y <= e" by norm 
   2.513 -
   2.514 -lemma dist_triangle_lt: "dist x z + dist y z < e ==> dist x y < e" by norm 
   2.515 -
   2.516 -lemma dist_triangle_half_l: "dist x1 y < e / 2 \<Longrightarrow> dist x2 y < e / 2 ==> dist x1 x2 < e" by norm 
   2.517 -
   2.518 -lemma dist_triangle_half_r: "dist y x1 < e / 2 \<Longrightarrow> dist y x2 < e / 2 ==> dist x1 x2 < e" by norm 
   2.519 +lemma dist_pos_lt: "x \<noteq> y ==> 0 < dist x y" by norm
   2.520 +lemma dist_nz:  "x \<noteq> y \<longleftrightarrow> 0 < dist x y" by norm
   2.521 +
   2.522 +lemma dist_triangle_le: "dist x z + dist y z <= e \<Longrightarrow> dist x y <= e" by norm
   2.523 +
   2.524 +lemma dist_triangle_lt: "dist x z + dist y z < e ==> dist x y < e" by norm
   2.525 +
   2.526 +lemma dist_triangle_half_l: "dist x1 y < e / 2 \<Longrightarrow> dist x2 y < e / 2 ==> dist x1 x2 < e" by norm
   2.527 +
   2.528 +lemma dist_triangle_half_r: "dist y x1 < e / 2 \<Longrightarrow> dist y x2 < e / 2 ==> dist x1 x2 < e" by norm
   2.529  
   2.530  lemma dist_triangle_add: "dist (x + y) (x' + y') <= dist x x' + dist y y'"
   2.531 -  by norm 
   2.532 -
   2.533 -lemma dist_mul[simp]: "dist (c *s x) (c *s y) = \<bar>c\<bar> * dist x y" 
   2.534 -  unfolding dist_def vector_ssub_ldistrib[symmetric] norm_mul .. 
   2.535 -
   2.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 
   2.537 -
   2.538 -lemma dist_le_0[simp]: "dist x y <= 0 \<longleftrightarrow> x = y" by norm 
   2.539 +  by norm
   2.540 +
   2.541 +lemma dist_mul[simp]: "dist (c *s x) (c *s y) = \<bar>c\<bar> * dist x y"
   2.542 +  unfolding dist_def vector_ssub_ldistrib[symmetric] norm_mul ..
   2.543 +
   2.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
   2.545 +
   2.546 +lemma dist_le_0[simp]: "dist x y <= 0 \<longleftrightarrow> x = y" by norm
   2.547  
   2.548  lemma setsum_eq: "setsum f S = (\<chi> i. setsum (\<lambda>x. (f x)$i ) S)"
   2.549    apply vector
   2.550 @@ -996,24 +996,24 @@
   2.551    apply (auto simp add: vector_component zero_index)
   2.552    done
   2.553  
   2.554 -lemma setsum_clauses: 
   2.555 +lemma setsum_clauses:
   2.556    shows "setsum f {} = 0"
   2.557    and "finite S \<Longrightarrow> setsum f (insert x S) =
   2.558                   (if x \<in> S then setsum f S else f x + setsum f S)"
   2.559    by (auto simp add: insert_absorb)
   2.560  
   2.561 -lemma setsum_cmul: 
   2.562 +lemma setsum_cmul:
   2.563    fixes f:: "'c \<Rightarrow> ('a::semiring_1)^'n"
   2.564    shows "setsum (\<lambda>x. c *s f x) S = c *s setsum f S"
   2.565    by (simp add: setsum_eq Cart_eq Cart_lambda_beta vector_component setsum_right_distrib)
   2.566  
   2.567 -lemma setsum_component: 
   2.568 +lemma setsum_component:
   2.569    fixes f:: " 'a \<Rightarrow> ('b::semiring_1) ^'n"
   2.570    assumes i: "i \<in> {1 .. dimindex(UNIV:: 'n set)}"
   2.571    shows "(setsum f S)$i = setsum (\<lambda>x. (f x)$i) S"
   2.572    using i by (simp add: setsum_eq Cart_lambda_beta)
   2.573  
   2.574 -lemma setsum_norm: 
   2.575 +lemma setsum_norm:
   2.576    fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
   2.577    assumes fS: "finite S"
   2.578    shows "norm (setsum f S) <= setsum (\<lambda>x. norm(f x)) S"
   2.579 @@ -1027,7 +1027,7 @@
   2.580    finally  show ?case  using "2.hyps" by simp
   2.581  qed
   2.582  
   2.583 -lemma real_setsum_norm: 
   2.584 +lemma real_setsum_norm:
   2.585    fixes f :: "'a \<Rightarrow> real ^'n"
   2.586    assumes fS: "finite S"
   2.587    shows "norm (setsum f S) <= setsum (\<lambda>x. norm(f x)) S"
   2.588 @@ -1041,25 +1041,25 @@
   2.589    finally  show ?case  using "2.hyps" by simp
   2.590  qed
   2.591  
   2.592 -lemma setsum_norm_le: 
   2.593 +lemma setsum_norm_le:
   2.594    fixes f :: "'a \<Rightarrow> 'b::real_normed_vector"
   2.595    assumes fS: "finite S"
   2.596    and fg: "\<forall>x \<in> S. norm (f x) \<le> g x"
   2.597    shows "norm (setsum f S) \<le> setsum g S"
   2.598  proof-
   2.599 -  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S" 
   2.600 +  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
   2.601      by - (rule setsum_mono, simp)
   2.602    then show ?thesis using setsum_norm[OF fS, of f] fg
   2.603      by arith
   2.604  qed
   2.605  
   2.606 -lemma real_setsum_norm_le: 
   2.607 +lemma real_setsum_norm_le:
   2.608    fixes f :: "'a \<Rightarrow> real ^ 'n"
   2.609    assumes fS: "finite S"
   2.610    and fg: "\<forall>x \<in> S. norm (f x) \<le> g x"
   2.611    shows "norm (setsum f S) \<le> setsum g S"
   2.612  proof-
   2.613 -  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S" 
   2.614 +  from fg have "setsum (\<lambda>x. norm(f x)) S <= setsum g S"
   2.615      by - (rule setsum_mono, simp)
   2.616    then show ?thesis using real_setsum_norm[OF fS, of f] fg
   2.617      by arith
   2.618 @@ -1089,9 +1089,9 @@
   2.619    case 1 then show ?case by (simp add: vector_smult_lzero)
   2.620  next
   2.621    case (2 x F)
   2.622 -  from "2.hyps" have "setsum f (insert x F) *s v = (f x + setsum f F) *s v" 
   2.623 +  from "2.hyps" have "setsum f (insert x F) *s v = (f x + setsum f F) *s v"
   2.624      by simp
   2.625 -  also have "\<dots> = f x *s v + setsum f F *s v" 
   2.626 +  also have "\<dots> = f x *s v + setsum f F *s v"
   2.627      by (simp add: vector_sadd_rdistrib)
   2.628    also have "\<dots> = setsum (\<lambda>x. f x *s v) (insert x F)" using "2.hyps" by simp
   2.629    finally show ?case .
   2.630 @@ -1105,20 +1105,20 @@
   2.631  proof-
   2.632    let ?A = "{m .. n}"
   2.633    let ?B = "{n + 1 .. n + p}"
   2.634 -  have eq: "{m .. n+p} = ?A \<union> ?B" using mn by auto 
   2.635 +  have eq: "{m .. n+p} = ?A \<union> ?B" using mn by auto
   2.636    have d: "?A \<inter> ?B = {}" by auto
   2.637    from setsum_Un_disjoint[of "?A" "?B" f] eq d show ?thesis by auto
   2.638  qed
   2.639  
   2.640  lemma setsum_natinterval_left:
   2.641 -  assumes mn: "(m::nat) <= n" 
   2.642 +  assumes mn: "(m::nat) <= n"
   2.643    shows "setsum f {m..n} = f m + setsum f {m + 1..n}"
   2.644  proof-
   2.645    from mn have "{m .. n} = insert m {m+1 .. n}" by auto
   2.646    then show ?thesis by auto
   2.647  qed
   2.648  
   2.649 -lemma setsum_natinterval_difff: 
   2.650 +lemma setsum_natinterval_difff:
   2.651    fixes f:: "nat \<Rightarrow> ('a::ab_group_add)"
   2.652    shows  "setsum (\<lambda>k. f k - f(k + 1)) {(m::nat) .. n} =
   2.653            (if m <= n then f m - f(n + 1) else 0)"
   2.654 @@ -1136,8 +1136,8 @@
   2.655  proof-
   2.656    {fix x assume "x \<in> S" then have "{y. y\<in> f`S \<and> f x = y} = {f x}" by auto}
   2.657    note th0 = this
   2.658 -  have "setsum g S = setsum (\<lambda>x. setsum (\<lambda>y. g x) {y. y\<in> f`S \<and> f x = y}) S" 
   2.659 -    apply (rule setsum_cong2) 
   2.660 +  have "setsum g S = setsum (\<lambda>x. setsum (\<lambda>y. g x) {y. y\<in> f`S \<and> f x = y}) S"
   2.661 +    apply (rule setsum_cong2)
   2.662      by (simp add: th0)
   2.663    also have "\<dots> = setsum (\<lambda>y. setsum g {x. x \<in> S \<and> f x = y}) (f ` S)"
   2.664      apply (rule setsum_setsum_restrict[OF fS])
   2.665 @@ -1149,14 +1149,14 @@
   2.666  lemma setsum_group:
   2.667    assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \<subseteq> T"
   2.668    shows "setsum (\<lambda>y. setsum g {x. x\<in> S \<and> f x = y}) T = setsum g S"
   2.669 -  
   2.670 +
   2.671  apply (subst setsum_image_gen[OF fS, of g f])
   2.672  apply (rule setsum_mono_zero_right[OF fT fST])
   2.673  by (auto intro: setsum_0')
   2.674  
   2.675  lemma vsum_norm_allsubsets_bound:
   2.676    fixes f:: "'a \<Rightarrow> real ^'n"
   2.677 -  assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e" 
   2.678 +  assumes fP: "finite P" and fPs: "\<And>Q. Q \<subseteq> P \<Longrightarrow> norm (setsum f Q) \<le> e"
   2.679    shows "setsum (\<lambda>x. norm (f x)) P \<le> 2 * real (dimindex(UNIV :: 'n set)) *  e"
   2.680  proof-
   2.681    let ?d = "real (dimindex (UNIV ::'n set))"
   2.682 @@ -1183,9 +1183,9 @@
   2.683      have Pne: "setsum (\<lambda>x. \<bar>f x $ i\<bar>) ?Pn \<le> e"
   2.684        using i component_le_norm[OF i, of "setsum (\<lambda>x. - f x) ?Pn"]  fPs[OF PnP]
   2.685        by (auto simp add: setsum_negf setsum_component vector_component intro: abs_le_D1)
   2.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" 
   2.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"
   2.688        apply (subst thp)
   2.689 -      apply (rule setsum_Un_zero) 
   2.690 +      apply (rule setsum_Un_zero)
   2.691        using fP thp0 by auto
   2.692      also have "\<dots> \<le> 2*e" using Pne Ppe by arith
   2.693      finally show "setsum (\<lambda>x. \<bar>f x $ i\<bar>) P \<le> 2*e" .
   2.694 @@ -1204,13 +1204,13 @@
   2.695  
   2.696  definition "basis k = (\<chi> i. if i = k then 1 else 0)"
   2.697  
   2.698 -lemma delta_mult_idempotent: 
   2.699 +lemma delta_mult_idempotent:
   2.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)
   2.701  
   2.702  lemma norm_basis:
   2.703    assumes k: "k \<in> {1 .. dimindex (UNIV :: 'n set)}"
   2.704    shows "norm (basis k :: real ^'n) = 1"
   2.705 -  using k 
   2.706 +  using k
   2.707    apply (simp add: basis_def real_vector_norm_def dot_def)
   2.708    apply (vector delta_mult_idempotent)
   2.709    using setsum_delta[of "{1 .. dimindex (UNIV :: 'n set)}" "k" "\<lambda>k. 1::real"]
   2.710 @@ -1228,7 +1228,7 @@
   2.711    apply (rule exI[where x="c *s basis 1"])
   2.712    by (simp only: norm_mul norm_basis_1)
   2.713  
   2.714 -lemma vector_choose_dist: assumes e: "0 <= e" 
   2.715 +lemma vector_choose_dist: assumes e: "0 <= e"
   2.716    shows "\<exists>(y::real^'n). dist x y = e"
   2.717  proof-
   2.718    from vector_choose_size[OF e] obtain c:: "real ^'n"  where "norm c = e"
   2.719 @@ -1250,7 +1250,7 @@
   2.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 = _")
   2.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)
   2.722  
   2.723 -lemma basis_expansion_unique: 
   2.724 +lemma basis_expansion_unique:
   2.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)"
   2.726    by (simp add: Cart_eq setsum_component vector_component basis_component setsum_delta cond_value_iff cong del: if_weak_cong)
   2.727  
   2.728 @@ -1266,7 +1266,7 @@
   2.729  lemma basis_eq_0: "basis i = (0::'a::semiring_1^'n) \<longleftrightarrow> i \<notin> {1..dimindex(UNIV ::'n set)}"
   2.730    by (auto simp add: Cart_eq basis_component zero_index)
   2.731  
   2.732 -lemma basis_nonzero: 
   2.733 +lemma basis_nonzero:
   2.734    assumes k: "k \<in> {1 .. dimindex(UNIV ::'n set)}"
   2.735    shows "basis k \<noteq> (0:: 'a::semiring_1 ^'n)"
   2.736    using k by (simp add: basis_eq_0)
   2.737 @@ -1294,15 +1294,15 @@
   2.738  definition "orthogonal x y \<longleftrightarrow> (x \<bullet> y = 0)"
   2.739  
   2.740  lemma orthogonal_basis:
   2.741 -  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}" 
   2.742 +  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}"
   2.743    shows "orthogonal (basis i :: 'a^'n) x \<longleftrightarrow> x$i = (0::'a::ring_1)"
   2.744    using i
   2.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)
   2.746  
   2.747  lemma orthogonal_basis_basis:
   2.748 -  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}" 
   2.749 -  and j: "j \<in> {1 .. dimindex(UNIV ::'n set)}" 
   2.750 -  shows "orthogonal (basis i :: 'a::ring_1^'n) (basis j) \<longleftrightarrow> i \<noteq> j" 
   2.751 +  assumes i:"i \<in> {1 .. dimindex(UNIV ::'n set)}"
   2.752 +  and j: "j \<in> {1 .. dimindex(UNIV ::'n set)}"
   2.753 +  shows "orthogonal (basis i :: 'a::ring_1^'n) (basis j) \<longleftrightarrow> i \<noteq> j"
   2.754    unfolding orthogonal_basis[OF i] basis_component[OF i] by simp
   2.755  
   2.756    (* FIXME : Maybe some of these require less than comm_ring, but not all*)
   2.757 @@ -1443,14 +1443,14 @@
   2.758  
   2.759  lemma linear_neg: "linear (f :: 'a::ring_1 ^'n \<Rightarrow> _) ==> f (-x) = - f x"
   2.760    unfolding vector_sneg_minus1
   2.761 -  using linear_cmul[of f] by auto 
   2.762 -
   2.763 -lemma linear_add: "linear f ==> f(x + y) = f x + f y" by (metis linear_def) 
   2.764 +  using linear_cmul[of f] by auto
   2.765 +
   2.766 +lemma linear_add: "linear f ==> f(x + y) = f x + f y" by (metis linear_def)
   2.767  
   2.768  lemma linear_sub: "linear (f::'a::ring_1 ^'n \<Rightarrow> _) ==> f(x - y) = f x - f y"
   2.769    by (simp add: diff_def linear_add linear_neg)
   2.770  
   2.771 -lemma linear_setsum: 
   2.772 +lemma linear_setsum:
   2.773    fixes f:: "'a::semiring_1^'n \<Rightarrow> _"
   2.774    assumes lf: "linear f" and fS: "finite S"
   2.775    shows "f (setsum g S) = setsum (f o g) S"
   2.776 @@ -1470,7 +1470,7 @@
   2.777    assumes lf: "linear f" and fS: "finite S"
   2.778    shows "f (setsum (\<lambda>i. c i *s v i) S) = setsum (\<lambda>i. c i *s f (v i)) S"
   2.779    using linear_setsum[OF lf fS, of "\<lambda>i. c i *s v i" , unfolded o_def]
   2.780 -  linear_cmul[OF lf] by simp 
   2.781 +  linear_cmul[OF lf] by simp
   2.782  
   2.783  lemma linear_injective_0:
   2.784    assumes lf: "linear (f:: 'a::ring_1 ^ 'n \<Rightarrow> _)"
   2.785 @@ -1478,7 +1478,7 @@
   2.786  proof-
   2.787    have "inj f \<longleftrightarrow> (\<forall> x y. f x = f y \<longrightarrow> x = y)" by (simp add: inj_on_def)
   2.788    also have "\<dots> \<longleftrightarrow> (\<forall> x y. f x - f y = 0 \<longrightarrow> x - y = 0)" by simp
   2.789 -  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f (x - y) = 0 \<longrightarrow> x - y = 0)" 
   2.790 +  also have "\<dots> \<longleftrightarrow> (\<forall> x y. f (x - y) = 0 \<longrightarrow> x - y = 0)"
   2.791      by (simp add: linear_sub[OF lf])
   2.792    also have "\<dots> \<longleftrightarrow> (\<forall> x. f x = 0 \<longrightarrow> x = 0)" by auto
   2.793    finally show ?thesis .
   2.794 @@ -1518,7 +1518,7 @@
   2.795    assumes lf: "linear f"
   2.796    shows "\<exists>B > 0. \<forall>x. norm (f x) \<le> B * norm x"
   2.797  proof-
   2.798 -  from linear_bounded[OF lf] obtain B where 
   2.799 +  from linear_bounded[OF lf] obtain B where
   2.800      B: "\<forall>x. norm (f x) \<le> B * norm x" by blast
   2.801    let ?K = "\<bar>B\<bar> + 1"
   2.802    have Kp: "?K > 0" by arith
   2.803 @@ -1562,15 +1562,15 @@
   2.804  
   2.805  lemma  (in ab_group_add) eq_add_iff: "x = x + y \<longleftrightarrow> y = 0"
   2.806    using add_imp_eq[of x y 0] by auto
   2.807 -    
   2.808 -lemma bilinear_lzero: 
   2.809 +
   2.810 +lemma bilinear_lzero:
   2.811    fixes h :: "'a::ring^'n \<Rightarrow> _" assumes bh: "bilinear h" shows "h 0 x = 0"
   2.812 -  using bilinear_ladd[OF bh, of 0 0 x] 
   2.813 +  using bilinear_ladd[OF bh, of 0 0 x]
   2.814      by (simp add: eq_add_iff ring_simps)
   2.815  
   2.816 -lemma bilinear_rzero: 
   2.817 +lemma bilinear_rzero:
   2.818    fixes h :: "'a::ring^'n \<Rightarrow> _" assumes bh: "bilinear h" shows "h x 0 = 0"
   2.819 -  using bilinear_radd[OF bh, of x 0 0 ] 
   2.820 +  using bilinear_radd[OF bh, of x 0 0 ]
   2.821      by (simp add: eq_add_iff ring_simps)
   2.822  
   2.823  lemma bilinear_lsub: "bilinear h ==> h (x - (y:: 'a::ring_1 ^ 'n)) z = h x z - h y z"
   2.824 @@ -1583,7 +1583,7 @@
   2.825    fixes h:: "'a ^'n \<Rightarrow> 'a::semiring_1^'m \<Rightarrow> 'a ^ 'k"
   2.826    assumes bh: "bilinear h" and fS: "finite S" and fT: "finite T"
   2.827    shows "h (setsum f S) (setsum g T) = setsum (\<lambda>(i,j). h (f i) (g j)) (S \<times> T) "
   2.828 -proof- 
   2.829 +proof-
   2.830    have "h (setsum f S) (setsum g T) = setsum (\<lambda>x. h (f x) (setsum g T)) S"
   2.831      apply (rule linear_setsum[unfolded o_def])
   2.832      using bh fS by (auto simp add: bilinear_def)
   2.833 @@ -1598,7 +1598,7 @@
   2.834    fixes h:: "real ^'m \<Rightarrow> real^'n \<Rightarrow> real ^ 'k"
   2.835    assumes bh: "bilinear h"
   2.836    shows "\<exists>B. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
   2.837 -proof- 
   2.838 +proof-
   2.839    let ?M = "{1 .. dimindex (UNIV :: 'm set)}"
   2.840    let ?N = "{1 .. dimindex (UNIV :: 'n set)}"
   2.841    let ?B = "setsum (\<lambda>(i,j). norm (h (basis i) (basis j))) (?M \<times> ?N)"
   2.842 @@ -1626,7 +1626,7 @@
   2.843    assumes bh: "bilinear h"
   2.844    shows "\<exists>B > 0. \<forall>x y. norm (h x y) \<le> B * norm x * norm y"
   2.845  proof-
   2.846 -  from bilinear_bounded[OF bh] obtain B where 
   2.847 +  from bilinear_bounded[OF bh] obtain B where
   2.848      B: "\<forall>x y. norm (h x y) \<le> B * norm x * norm y" by blast
   2.849    let ?K = "\<bar>B\<bar> + 1"
   2.850    have Kp: "?K > 0" by arith
   2.851 @@ -1634,11 +1634,11 @@
   2.852    {fix x::"real ^'m" and y :: "real ^'n"
   2.853      from KB Kp
   2.854      have "B * norm x * norm y \<le> ?K * norm x * norm y"
   2.855 -      apply - 
   2.856 +      apply -
   2.857        apply (rule mult_right_mono, rule mult_right_mono)
   2.858        by (auto simp add: norm_ge_zero)
   2.859      then have "norm (h x y) \<le> ?K * norm x * norm y"
   2.860 -      using B[rule_format, of x y] by simp} 
   2.861 +      using B[rule_format, of x y] by simp}
   2.862    with Kp show ?thesis by blast
   2.863  qed
   2.864  
   2.865 @@ -1663,14 +1663,14 @@
   2.866        have "f x \<bullet> y = f (setsum (\<lambda>i. (x$i) *s basis i) ?N) \<bullet> y"
   2.867  	by (simp only: basis_expansion)
   2.868        also have "\<dots> = (setsum (\<lambda>i. (x$i) *s f (basis i)) ?N) \<bullet> y"
   2.869 -	unfolding linear_setsum[OF lf fN] 
   2.870 +	unfolding linear_setsum[OF lf fN]
   2.871  	by (simp add: linear_cmul[OF lf])
   2.872        finally have "f x \<bullet> y = x \<bullet> ?w"
   2.873  	apply (simp only: )
   2.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)
   2.875  	done}
   2.876    }
   2.877 -  then show ?thesis unfolding adjoint_def 
   2.878 +  then show ?thesis unfolding adjoint_def
   2.879      some_eq_ex[of "\<lambda>f'. \<forall>x y. f x \<bullet> y = x \<bullet> f' y"]
   2.880      using choice_iff[of "\<lambda>a b. \<forall>x. f x \<bullet> a = x \<bullet> b "]
   2.881      by metis
   2.882 @@ -1715,27 +1715,27 @@
   2.883  
   2.884  consts generic_mult :: "'a \<Rightarrow> 'b \<Rightarrow> 'c" (infixr "\<star>" 75)
   2.885  
   2.886 -defs (overloaded) 
   2.887 +defs (overloaded)
   2.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"
   2.889  
   2.890 -abbreviation 
   2.891 +abbreviation
   2.892    matrix_matrix_mult' :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'p^'n \<Rightarrow> 'a ^ 'p ^'m"  (infixl "**" 70)
   2.893    where "m ** m' == m\<star> m'"
   2.894  
   2.895 -defs (overloaded) 
   2.896 +defs (overloaded)
   2.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"
   2.898  
   2.899 -abbreviation 
   2.900 +abbreviation
   2.901    matrix_vector_mult' :: "('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n \<Rightarrow> 'a ^ 'm"  (infixl "*v" 70)
   2.902 -  where 
   2.903 +  where
   2.904    "m *v v == m \<star> v"
   2.905  
   2.906 -defs (overloaded) 
   2.907 +defs (overloaded)
   2.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"
   2.909  
   2.910 -abbreviation 
   2.911 +abbreviation
   2.912    vactor_matrix_mult' :: "'a ^ 'm \<Rightarrow> ('a::semiring_1) ^'n^'m \<Rightarrow> 'a ^'n "  (infixl "v*" 70)
   2.913 -  where 
   2.914 +  where
   2.915    "v v* m == v \<star> m"
   2.916  
   2.917  definition "(mat::'a::zero => 'a ^'n^'m) k = (\<chi> i j. if i = j then k else 0)"
   2.918 @@ -1749,11 +1749,11 @@
   2.919  lemma matrix_add_ldistrib: "(A ** (B + C)) = (A \<star> B) + (A \<star> C)"
   2.920    by (vector matrix_matrix_mult_def setsum_addf[symmetric] ring_simps)
   2.921  
   2.922 -lemma setsum_delta': 
   2.923 -  assumes fS: "finite S" shows 
   2.924 -  "setsum (\<lambda>k. if a = k then b k else 0) S = 
   2.925 +lemma setsum_delta':
   2.926 +  assumes fS: "finite S" shows
   2.927 +  "setsum (\<lambda>k. if a = k then b k else 0) S =
   2.928       (if a\<in> S then b a else 0)"
   2.929 -  using setsum_delta[OF fS, of a b, symmetric] 
   2.930 +  using setsum_delta[OF fS, of a b, symmetric]
   2.931    by (auto intro: setsum_cong)
   2.932  
   2.933  lemma matrix_mul_lid: "mat 1 ** A = A"
   2.934 @@ -1781,7 +1781,7 @@
   2.935  
   2.936  lemma matrix_vector_mul_lid: "mat 1 *v x = x"
   2.937    apply (vector matrix_vector_mult_def mat_def)
   2.938 -  by (simp add: cond_value_iff cond_application_beta 
   2.939 +  by (simp add: cond_value_iff cond_application_beta
   2.940      setsum_delta' cong del: if_weak_cong)
   2.941  
   2.942  lemma matrix_transp_mul: "transp(A ** B) = transp B ** transp (A::'a::comm_semiring_1^'m^'n)"
   2.943 @@ -1796,7 +1796,7 @@
   2.944    apply (erule_tac x="i" in ballE)
   2.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)
   2.946  
   2.947 -lemma matrix_vector_mul_component: 
   2.948 +lemma matrix_vector_mul_component:
   2.949    assumes k: "k \<in> {1.. dimindex (UNIV :: 'm set)}"
   2.950    shows "((A::'a::semiring_1^'n'^'m) *v x)$k = (A$k) \<bullet> x"
   2.951    using k
   2.952 @@ -1813,18 +1813,18 @@
   2.953  lemma transp_transp: "transp(transp A) = A"
   2.954    by (vector transp_def)
   2.955  
   2.956 -lemma row_transp: 
   2.957 +lemma row_transp:
   2.958    fixes A:: "'a::semiring_1^'n^'m"
   2.959    assumes i: "i \<in> {1.. dimindex (UNIV :: 'n set)}"
   2.960    shows "row i (transp A) = column i A"
   2.961 -  using i 
   2.962 +  using i
   2.963    by (simp add: row_def column_def transp_def Cart_eq Cart_lambda_beta)
   2.964  
   2.965  lemma column_transp:
   2.966    fixes A:: "'a::semiring_1^'n^'m"
   2.967    assumes i: "i \<in> {1.. dimindex (UNIV :: 'm set)}"
   2.968    shows "column i (transp A) = row i A"
   2.969 -  using i 
   2.970 +  using i
   2.971    by (simp add: row_def column_def transp_def Cart_eq Cart_lambda_beta)
   2.972  
   2.973  lemma rows_transp: "rows(transp (A::'a::semiring_1^'n^'m)) = columns A"
   2.974 @@ -1890,8 +1890,8 @@
   2.975  lemma matrix_of_matrix_vector_mul: "matrix(\<lambda>x. A *v (x :: 'a:: comm_ring_1 ^ 'n)) = A"
   2.976    by (simp add: matrix_eq matrix_vector_mul_linear matrix_works)
   2.977  
   2.978 -lemma matrix_compose: 
   2.979 -  assumes lf: "linear (f::'a::comm_ring_1^'n \<Rightarrow> _)" and lg: "linear g" 
   2.980 +lemma matrix_compose:
   2.981 +  assumes lf: "linear (f::'a::comm_ring_1^'n \<Rightarrow> _)" and lg: "linear g"
   2.982    shows "matrix (g o f) = matrix g ** matrix f"
   2.983    using lf lg linear_compose[OF lf lg] matrix_works[OF linear_compose[OF lf lg]]
   2.984    by (simp  add: matrix_eq matrix_works matrix_vector_mul_assoc[symmetric] o_def)
   2.985 @@ -1923,9 +1923,9 @@
   2.986    done
   2.987  
   2.988  
   2.989 -lemma real_convex_bound_lt: 
   2.990 +lemma real_convex_bound_lt:
   2.991    assumes xa: "(x::real) < a" and ya: "y < a" and u: "0 <= u" and v: "0 <= v"
   2.992 -  and uv: "u + v = 1" 
   2.993 +  and uv: "u + v = 1"
   2.994    shows "u * x + v * y < a"
   2.995  proof-
   2.996    have uv': "u = 0 \<longrightarrow> v \<noteq> 0" using u v uv by arith
   2.997 @@ -1937,7 +1937,7 @@
   2.998      apply (cases "u = 0", simp_all add: uv')
   2.999      apply(rule mult_strict_left_mono)
  2.1000      using uv' apply simp_all
  2.1001 -    
  2.1002 +
  2.1003      apply (rule add_less_le_mono)
  2.1004      apply(rule mult_strict_left_mono)
  2.1005      apply simp_all
  2.1006 @@ -1947,9 +1947,9 @@
  2.1007    thus ?thesis unfolding th .
  2.1008  qed
  2.1009  
  2.1010 -lemma real_convex_bound_le: 
  2.1011 +lemma real_convex_bound_le:
  2.1012    assumes xa: "(x::real) \<le> a" and ya: "y \<le> a" and u: "0 <= u" and v: "0 <= v"
  2.1013 -  and uv: "u + v = 1" 
  2.1014 +  and uv: "u + v = 1"
  2.1015    shows "u * x + v * y \<le> a"
  2.1016  proof-
  2.1017    from xa ya u v have "u * x + v * y \<le> u * a + v * a" by (simp add: add_mono mult_left_mono)
  2.1018 @@ -1969,7 +1969,7 @@
  2.1019  done
  2.1020  
  2.1021  
  2.1022 -lemma triangle_lemma: 
  2.1023 +lemma triangle_lemma:
  2.1024    assumes x: "0 <= (x::real)" and y:"0 <= y" and z: "0 <= z" and xy: "x^2 <= y^2 + z^2"
  2.1025    shows "x <= y + z"
  2.1026  proof-
  2.1027 @@ -1992,12 +1992,12 @@
  2.1028      let ?x = "(\<chi> i. (f i)) :: 'a ^ 'n"
  2.1029      {fix i assume i: "i \<in> ?S"
  2.1030        with f i have "P i (f i)" by metis
  2.1031 -      then have "P i (?x$i)" using Cart_lambda_beta[of f, rule_format, OF i] by auto 
  2.1032 +      then have "P i (?x$i)" using Cart_lambda_beta[of f, rule_format, OF i] by auto
  2.1033      }
  2.1034      hence "\<forall>i \<in> ?S. P i (?x$i)" by metis
  2.1035      hence ?rhs by metis }
  2.1036    ultimately show ?thesis by metis
  2.1037 -qed 
  2.1038 +qed
  2.1039  
  2.1040  (* Supremum and infimum of real sets *)
  2.1041  
  2.1042 @@ -2019,7 +2019,7 @@
  2.1043  lemma rsup_le: assumes Se: "S \<noteq> {}" and Sb: "S *<= b" shows "rsup S \<le> b"
  2.1044  proof-
  2.1045    from Sb have bu: "isUb UNIV S b" by (simp add: isUb_def setle_def)
  2.1046 -  from rsup[OF Se] Sb have "isLub UNIV S (rsup S)"  by blast 
  2.1047 +  from rsup[OF Se] Sb have "isLub UNIV S (rsup S)"  by blast
  2.1048    then show ?thesis using bu by (auto simp add: isLub_def leastP_def setle_def setge_def)
  2.1049  qed
  2.1050  
  2.1051 @@ -2030,12 +2030,12 @@
  2.1052    let ?m = "Max S"
  2.1053    from Max_ge[OF fS] have Sm: "\<forall> x\<in> S. x \<le> ?m" by metis
  2.1054    with rsup[OF Se] have lub: "isLub UNIV S (rsup S)" by (metis setle_def)
  2.1055 -  from Max_in[OF fS Se] lub have mrS: "?m \<le> rsup S" 
  2.1056 +  from Max_in[OF fS Se] lub have mrS: "?m \<le> rsup S"
  2.1057      by (auto simp add: isLub_def leastP_def setle_def setge_def isUb_def)
  2.1058 -  moreover 
  2.1059 +  moreover
  2.1060    have "rsup S \<le> ?m" using Sm lub
  2.1061      by (auto simp add: isLub_def leastP_def isUb_def setle_def setge_def)
  2.1062 -  ultimately  show ?thesis by arith 
  2.1063 +  ultimately  show ?thesis by arith
  2.1064  qed
  2.1065  
  2.1066  lemma rsup_finite_in: assumes fS: "finite S" and Se: "S \<noteq> {}"
  2.1067 @@ -2065,7 +2065,7 @@
  2.1068  
  2.1069  lemma rsup_unique: assumes b: "S *<= b" and S: "\<forall>b' < b. \<exists>x \<in> S. b' < x"
  2.1070    shows "rsup S = b"
  2.1071 -using b S  
  2.1072 +using b S
  2.1073  unfolding setle_def rsup_alt
  2.1074  apply -
  2.1075  apply (rule some_equality)
  2.1076 @@ -2104,7 +2104,7 @@
  2.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"
  2.1078  proof-
  2.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
  2.1080 -  show ?thesis using S b rsup_bounds[of S "l - e" "l+e"] unfolding th 
  2.1081 +  show ?thesis using S b rsup_bounds[of S "l - e" "l+e"] unfolding th
  2.1082      by  (auto simp add: setge_def setle_def)
  2.1083  qed
  2.1084  
  2.1085 @@ -2142,7 +2142,7 @@
  2.1086  lemma rinf_ge: assumes Se: "S \<noteq> {}" and Sb: "b <=* S" shows "rinf S \<ge> b"
  2.1087  proof-
  2.1088    from Sb have bu: "isLb UNIV S b" by (simp add: isLb_def setge_def)
  2.1089 -  from rinf[OF Se] Sb have "isGlb UNIV S (rinf S)"  by blast 
  2.1090 +  from rinf[OF Se] Sb have "isGlb UNIV S (rinf S)"  by blast
  2.1091    then show ?thesis using bu by (auto simp add: isGlb_def greatestP_def setle_def setge_def)
  2.1092  qed
  2.1093  
  2.1094 @@ -2153,12 +2153,12 @@
  2.1095    let ?m = "Min S"
  2.1096    from Min_le[OF fS] have Sm: "\<forall> x\<in> S. x \<ge> ?m" by metis
  2.1097    with rinf[OF Se] have glb: "isGlb UNIV S (rinf S)" by (metis setge_def)
  2.1098 -  from Min_in[OF fS Se] glb have mrS: "?m \<ge> rinf S" 
  2.1099 +  from Min_in[OF fS Se] glb have mrS: "?m \<ge> rinf S"
  2.1100      by (auto simp add: isGlb_def greatestP_def setle_def setge_def isLb_def)
  2.1101 -  moreover 
  2.1102 +  moreover
  2.1103    have "rinf S \<ge> ?m" using Sm glb
  2.1104      by (auto simp add: isGlb_def greatestP_def isLb_def setle_def setge_def)
  2.1105 -  ultimately  show ?thesis by arith 
  2.1106 +  ultimately  show ?thesis by arith
  2.1107  qed
  2.1108  
  2.1109  lemma rinf_finite_in: assumes fS: "finite S" and Se: "S \<noteq> {}"
  2.1110 @@ -2188,7 +2188,7 @@
  2.1111  
  2.1112  lemma rinf_unique: assumes b: "b <=* S" and S: "\<forall>b' > b. \<exists>x \<in> S. b' > x"
  2.1113    shows "rinf S = b"
  2.1114 -using b S  
  2.1115 +using b S
  2.1116  unfolding setge_def rinf_alt
  2.1117  apply -
  2.1118  apply (rule some_equality)
  2.1119 @@ -2226,7 +2226,7 @@
  2.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"
  2.1121  proof-
  2.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
  2.1123 -  show ?thesis using S b rinf_bounds[of S "l - e" "l+e"] unfolding th 
  2.1124 +  show ?thesis using S b rinf_bounds[of S "l - e" "l+e"] unfolding th
  2.1125      by  (auto simp add: setge_def setle_def)
  2.1126  qed
  2.1127  
  2.1128 @@ -2248,7 +2248,7 @@
  2.1129  
  2.1130    moreover
  2.1131    {assume H: ?lhs
  2.1132 -    from H[rule_format, of "basis 1"] 
  2.1133 +    from H[rule_format, of "basis 1"]
  2.1134      have bp: "b \<ge> 0" using norm_ge_zero[of "f (basis 1)"] dimindex_ge_1[of "UNIV:: 'n set"]
  2.1135        by (auto simp add: norm_basis elim: order_trans [OF norm_ge_zero])
  2.1136      {fix x :: "real ^'n"
  2.1137 @@ -2260,9 +2260,9 @@
  2.1138  	let ?c = "1/ norm x"
  2.1139  	have "norm (?c*s x) = 1" using x0 by (simp add: n0 norm_mul)
  2.1140  	with H have "norm (f(?c*s x)) \<le> b" by blast
  2.1141 -	hence "?c * norm (f x) \<le> b" 
  2.1142 +	hence "?c * norm (f x) \<le> b"
  2.1143  	  by (simp add: linear_cmul[OF lf] norm_mul)
  2.1144 -	hence "norm (f x) \<le> b * norm x" 
  2.1145 +	hence "norm (f x) \<le> b * norm x"
  2.1146  	  using n0 norm_ge_zero[of x] by (auto simp add: field_simps)}
  2.1147        ultimately have "norm (f x) \<le> b * norm x" by blast}
  2.1148      then have ?rhs by blast}
  2.1149 @@ -2278,16 +2278,16 @@
  2.1150    {
  2.1151      let ?S = "{norm (f x) |x. norm x = 1}"
  2.1152      have Se: "?S \<noteq> {}" using  norm_basis_1 by auto
  2.1153 -    from linear_bounded[OF lf] have b: "\<exists> b. ?S *<= b" 
  2.1154 +    from linear_bounded[OF lf] have b: "\<exists> b. ?S *<= b"
  2.1155        unfolding norm_bound_generalize[OF lf, symmetric] by (auto simp add: setle_def)
  2.1156      {from rsup[OF Se b, unfolded onorm_def[symmetric]]
  2.1157 -      show "norm (f x) <= onorm f * norm x" 
  2.1158 -	apply - 
  2.1159 +      show "norm (f x) <= onorm f * norm x"
  2.1160 +	apply -
  2.1161  	apply (rule spec[where x = x])
  2.1162  	unfolding norm_bound_generalize[OF lf, symmetric]
  2.1163  	by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)}
  2.1164      {
  2.1165 -      show "\<forall>x. norm (f x) <= b * norm x \<Longrightarrow> onorm f <= b"  
  2.1166 +      show "\<forall>x. norm (f x) <= b * norm x \<Longrightarrow> onorm f <= b"
  2.1167  	using rsup[OF Se b, unfolded onorm_def[symmetric]]
  2.1168  	unfolding norm_bound_generalize[OF lf, symmetric]
  2.1169  	by (auto simp add: isLub_def isUb_def leastP_def setge_def setle_def)}
  2.1170 @@ -2297,7 +2297,7 @@
  2.1171  lemma onorm_pos_le: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)" shows "0 <= onorm f"
  2.1172    using order_trans[OF norm_ge_zero onorm(1)[OF lf, of "basis 1"], unfolded norm_basis_1] by simp
  2.1173  
  2.1174 -lemma onorm_eq_0: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)" 
  2.1175 +lemma onorm_eq_0: assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'m)"
  2.1176    shows "onorm f = 0 \<longleftrightarrow> (\<forall>x. f x = 0)"
  2.1177    using onorm[OF lf]
  2.1178    apply (auto simp add: onorm_pos_le)
  2.1179 @@ -2317,7 +2317,7 @@
  2.1180      apply (rule rsup_unique) by (simp_all  add: setle_def)
  2.1181  qed
  2.1182  
  2.1183 -lemma onorm_pos_lt: assumes lf: "linear (f::real ^ 'n \<Rightarrow> real ^'m)" 
  2.1184 +lemma onorm_pos_lt: assumes lf: "linear (f::real ^ 'n \<Rightarrow> real ^'m)"
  2.1185    shows "0 < onorm f \<longleftrightarrow> ~(\<forall>x. f x = 0)"
  2.1186    unfolding onorm_eq_0[OF lf, symmetric]
  2.1187    using onorm_pos_le[OF lf] by arith
  2.1188 @@ -2374,7 +2374,7 @@
  2.1189  
  2.1190  definition vec1:: "'a \<Rightarrow> 'a ^ 1" where "vec1 x = (\<chi> i. x)"
  2.1191  
  2.1192 -definition dest_vec1:: "'a ^1 \<Rightarrow> 'a" 
  2.1193 +definition dest_vec1:: "'a ^1 \<Rightarrow> 'a"
  2.1194    where "dest_vec1 x = (x$1)"
  2.1195  
  2.1196  lemma vec1_component[simp]: "(vec1 x)$1 = x"
  2.1197 @@ -2385,7 +2385,7 @@
  2.1198  
  2.1199  lemma forall_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P (vec1 x))" by (metis vec1_dest_vec1)
  2.1200  
  2.1201 -lemma exists_vec1: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P(vec1 x))" by (metis vec1_dest_vec1) 
  2.1202 +lemma exists_vec1: "(\<exists>x. P x) \<longleftrightarrow> (\<exists>x. P(vec1 x))" by (metis vec1_dest_vec1)
  2.1203  
  2.1204  lemma forall_dest_vec1: "(\<forall>x. P x) \<longleftrightarrow> (\<forall>x. P(dest_vec1 x))"  by (metis vec1_dest_vec1)
  2.1205  
  2.1206 @@ -2446,7 +2446,7 @@
  2.1207  lemma abs_dest_vec1: "norm x = \<bar>dest_vec1 x\<bar>"
  2.1208    by (metis vec1_dest_vec1 norm_vec1)
  2.1209  
  2.1210 -lemma linear_vmul_dest_vec1: 
  2.1211 +lemma linear_vmul_dest_vec1:
  2.1212    fixes f:: "'a::semiring_1^'n \<Rightarrow> 'a^1"
  2.1213    shows "linear f \<Longrightarrow> linear (\<lambda>x. dest_vec1(f x) *s v)"
  2.1214    unfolding dest_vec1_def
  2.1215 @@ -2563,10 +2563,10 @@
  2.1216    have th_0: "1 \<le> ?n +1" by simp
  2.1217    have th0: "norm x = norm (pastecart (fstcart x) (sndcart x))"
  2.1218      by (simp add: pastecart_fst_snd)
  2.1219 -  have th1: "fstcart x \<bullet> fstcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)" 
  2.1220 +  have th1: "fstcart x \<bullet> fstcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
  2.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)
  2.1222    then show ?thesis
  2.1223 -    unfolding th0 
  2.1224 +    unfolding th0
  2.1225      unfolding real_vector_norm_def real_sqrt_le_iff id_def
  2.1226      by (simp add: dot_def dimindex_finite_sum Cart_lambda_beta)
  2.1227  qed
  2.1228 @@ -2592,13 +2592,13 @@
  2.1229      using dimindex_nonzero[of "UNIV :: 'n set"] dimindex_nonzero[of "UNIV :: 'm set"]
  2.1230      apply (simp add: Ball_def atLeastAtMost_iff inj_on_def dimindex_finite_sum del: One_nat_def)
  2.1231      by arith
  2.1232 -  have fS: "?f ` ?S = ?M" 
  2.1233 +  have fS: "?f ` ?S = ?M"
  2.1234      apply (rule set_ext)
  2.1235      apply (simp add: image_iff Bex_def) using dimindex_nonzero[of "UNIV :: 'n set"] dimindex_nonzero[of "UNIV :: 'm set"] by arith
  2.1236 -  have th1: "sndcart x \<bullet> sndcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)" 
  2.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)    
  2.1238 +  have th1: "sndcart x \<bullet> sndcart x \<le> pastecart (fstcart x) (sndcart x) \<bullet> pastecart (fstcart x) (sndcart x)"
  2.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)
  2.1240    then show ?thesis
  2.1241 -    unfolding th0 
  2.1242 +    unfolding th0
  2.1243      unfolding real_vector_norm_def real_sqrt_le_iff id_def
  2.1244      by (simp add: dot_def dimindex_finite_sum Cart_lambda_beta)
  2.1245  qed
  2.1246 @@ -2644,14 +2644,14 @@
  2.1247      done
  2.1248    let ?r = "\<lambda>n. n - ?n"
  2.1249    have rinj: "inj_on ?r ?S" apply (simp add: inj_on_def Ball_def thnm) by arith
  2.1250 -  have rS: "?r ` ?S = ?M" apply (rule set_ext) 
  2.1251 +  have rS: "?r ` ?S = ?M" apply (rule set_ext)
  2.1252      apply (simp add: thnm image_iff Bex_def) by arith
  2.1253    have "pastecart x1 x2 \<bullet> (pastecart y1 y2) = setsum ?g ?NM" by (simp add: dot_def)
  2.1254    also have "\<dots> = setsum ?g ?N + setsum ?g ?S"
  2.1255      by (simp add: dot_def thnm setsum_add_split[OF th_0, of _ ?m] del: One_nat_def)
  2.1256    also have "\<dots> = setsum (?f x1 y1) ?N + setsum (?f x2 y2) ?M"
  2.1257      unfolding setsum_reindex[OF rinj, unfolded rS o_def] th2 th3 ..
  2.1258 -  finally 
  2.1259 +  finally
  2.1260    show ?thesis by (simp add: dot_def)
  2.1261  qed
  2.1262  
  2.1263 @@ -2679,7 +2679,7 @@
  2.1264  unfolding hull_def subset_iff by auto
  2.1265  
  2.1266  lemma hull_eq: "(\<And>T. T \<subseteq> S ==> Inter T \<in> S) ==> (S hull s) = s \<longleftrightarrow> s \<in> S"
  2.1267 -using hull_same[of s S] hull_in[of S s] by metis  
  2.1268 +using hull_same[of s S] hull_in[of S s] by metis
  2.1269  
  2.1270  
  2.1271  lemma hull_hull: "S hull (S hull s) = S hull s"
  2.1272 @@ -2749,12 +2749,12 @@
  2.1273  lemma real_pow_lbound: "0 <= x ==> 1 + real n * x <= (1 + x) ^ n"
  2.1274  proof(induct n)
  2.1275    case 0 thus ?case by simp
  2.1276 -next 
  2.1277 +next
  2.1278    case (Suc n)
  2.1279    hence h: "1 + real n * x \<le> (1 + x) ^ n" by simp
  2.1280    from h have p: "1 \<le> (1 + x) ^ n" using Suc.prems by simp
  2.1281    from h have "1 + real n * x + x \<le> (1 + x) ^ n + x" by simp
  2.1282 -  also have "\<dots> \<le> (1 + x) ^ Suc n" apply (subst diff_le_0_iff_le[symmetric]) 
  2.1283 +  also have "\<dots> \<le> (1 + x) ^ Suc n" apply (subst diff_le_0_iff_le[symmetric])
  2.1284      apply (simp add: ring_simps)
  2.1285      using mult_left_mono[OF p Suc.prems] by simp
  2.1286    finally show ?case  by (simp add: real_of_nat_Suc ring_simps)
  2.1287 @@ -2763,13 +2763,13 @@
  2.1288  lemma real_arch_pow: assumes x: "1 < (x::real)" shows "\<exists>n. y < x^n"
  2.1289  proof-
  2.1290    from x have x0: "x - 1 > 0" by arith
  2.1291 -  from real_arch[OF x0, rule_format, of y] 
  2.1292 +  from real_arch[OF x0, rule_format, of y]
  2.1293    obtain n::nat where n:"y < real n * (x - 1)" by metis
  2.1294    from x0 have x00: "x- 1 \<ge> 0" by arith
  2.1295 -  from real_pow_lbound[OF x00, of n] n 
  2.1296 +  from real_pow_lbound[OF x00, of n] n
  2.1297    have "y < x^n" by auto
  2.1298    then show ?thesis by metis
  2.1299 -qed 
  2.1300 +qed
  2.1301  
  2.1302  lemma real_arch_pow2: "\<exists>n. (x::real) < 2^ n"
  2.1303    using real_arch_pow[of 2 x] by simp
  2.1304 @@ -2777,13 +2777,13 @@
  2.1305  lemma real_arch_pow_inv: assumes y: "(y::real) > 0" and x1: "x < 1"
  2.1306    shows "\<exists>n. x^n < y"
  2.1307  proof-
  2.1308 -  {assume x0: "x > 0" 
  2.1309 +  {assume x0: "x > 0"
  2.1310      from x0 x1 have ix: "1 < 1/x" by (simp add: field_simps)
  2.1311      from real_arch_pow[OF ix, of "1/y"]
  2.1312      obtain n where n: "1/y < (1/x)^n" by blast
  2.1313 -    then 
  2.1314 +    then
  2.1315      have ?thesis using y x0 by (auto simp add: field_simps power_divide) }
  2.1316 -  moreover 
  2.1317 +  moreover
  2.1318    {assume "\<not> x > 0" with y x1 have ?thesis apply auto by (rule exI[where x=1], auto)}
  2.1319    ultimately show ?thesis by metis
  2.1320  qed
  2.1321 @@ -2821,18 +2821,18 @@
  2.1322    have "max x y \<le> rsup {x,y}" using rsup_finite_ge_iff[OF f, of "max x y"]
  2.1323      by (simp add: linorder_linear)
  2.1324    ultimately show ?thesis by arith
  2.1325 -qed 
  2.1326 +qed
  2.1327  
  2.1328  lemma real_min_rinf: "min x y = rinf {x,y}"
  2.1329  proof-
  2.1330    have f: "finite {x, y}" "{x,y} \<noteq> {}"  by simp_all
  2.1331 -  from rinf_finite_le_iff[OF f, of "min x y"] have "rinf {x,y} \<le> min x y" 
  2.1332 +  from rinf_finite_le_iff[OF f, of "min x y"] have "rinf {x,y} \<le> min x y"
  2.1333      by (simp add: linorder_linear)
  2.1334    moreover
  2.1335    have "min x y \<le> rinf {x,y}" using rinf_finite_ge_iff[OF f, of "min x y"]
  2.1336      by simp
  2.1337    ultimately show ?thesis by arith
  2.1338 -qed 
  2.1339 +qed
  2.1340  
  2.1341  (* ------------------------------------------------------------------------- *)
  2.1342  (* Geometric progression.                                                    *)
  2.1343 @@ -2863,9 +2863,9 @@
  2.1344    from mn have mn': "n - m \<ge> 0" by arith
  2.1345    let ?f = "op + m"
  2.1346    have i: "inj_on ?f ?S" unfolding inj_on_def by auto
  2.1347 -  have f: "?f ` ?S = {m..n}" 
  2.1348 +  have f: "?f ` ?S = {m..n}"
  2.1349      using mn apply (auto simp add: image_iff Bex_def) by arith
  2.1350 -  have th: "op ^ x o op + m = (\<lambda>i. x^m * x^i)" 
  2.1351 +  have th: "op ^ x o op + m = (\<lambda>i. x^m * x^i)"
  2.1352      by (rule ext, simp add: power_add power_mult)
  2.1353    from setsum_reindex[OF i, of "op ^ x", unfolded f th setsum_right_distrib[symmetric]]
  2.1354    have "?lhs = x^m * ((1 - x) * setsum (op ^ x) {0..n - m})" by simp
  2.1355 @@ -2873,8 +2873,8 @@
  2.1356      by (simp add: ring_simps power_add[symmetric])
  2.1357  qed
  2.1358  
  2.1359 -lemma sum_gp: "setsum (op ^ (x::'a::{field, recpower})) {m .. n} = 
  2.1360 -   (if n < m then 0 else if x = 1 then of_nat ((n + 1) - m) 
  2.1361 +lemma sum_gp: "setsum (op ^ (x::'a::{field, recpower})) {m .. n} =
  2.1362 +   (if n < m then 0 else if x = 1 then of_nat ((n + 1) - m)
  2.1363                      else (x^ m - x^ (Suc n)) / (1 - x))"
  2.1364  proof-
  2.1365    {assume nm: "n < m" hence ?thesis by simp}
  2.1366 @@ -2889,7 +2889,7 @@
  2.1367    ultimately show ?thesis by metis
  2.1368  qed
  2.1369  
  2.1370 -lemma sum_gp_offset: "setsum (op ^ (x::'a::{field,recpower})) {m .. m+n} = 
  2.1371 +lemma sum_gp_offset: "setsum (op ^ (x::'a::{field,recpower})) {m .. m+n} =
  2.1372    (if x = 1 then of_nat n + 1 else x^m * (1 - x^Suc n) / (1 - x))"
  2.1373    unfolding sum_gp[of x m "m + n"] power_Suc
  2.1374    by (simp add: ring_simps power_add)
  2.1375 @@ -2908,7 +2908,7 @@
  2.1376  
  2.1377  lemma subspace_0: "subspace S ==> 0 \<in> S" by (metis subspace_def)
  2.1378  
  2.1379 -lemma subspace_add: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S ==> x + y \<in> S" 
  2.1380 +lemma subspace_add: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> y \<in> S ==> x + y \<in> S"
  2.1381    by (metis subspace_def)
  2.1382  
  2.1383  lemma subspace_mul: "subspace S \<Longrightarrow> x \<in> S \<Longrightarrow> c *s x \<in> S"
  2.1384 @@ -2926,10 +2926,10 @@
  2.1385    shows "setsum f B \<in> A"
  2.1386    using  fB f sA
  2.1387    apply(induct rule: finite_induct[OF fB])
  2.1388 -  by (simp add: subspace_def sA, auto simp add: sA subspace_add) 
  2.1389 -
  2.1390 -lemma subspace_linear_image: 
  2.1391 -  assumes lf: "linear (f::'a::semiring_1^'n \<Rightarrow> _)" and sS: "subspace S" 
  2.1392 +  by (simp add: subspace_def sA, auto simp add: sA subspace_add)
  2.1393 +
  2.1394 +lemma subspace_linear_image:
  2.1395 +  assumes lf: "linear (f::'a::semiring_1^'n \<Rightarrow> _)" and sS: "subspace S"
  2.1396    shows "subspace(f ` S)"
  2.1397    using lf sS linear_0[OF lf]
  2.1398    unfolding linear_def subspace_def
  2.1399 @@ -2986,7 +2986,7 @@
  2.1400    from SP have SP': "S \<subseteq> P" by (simp add: mem_def subset_eq)
  2.1401    from P have P': "P \<in> subspace" by (simp add: mem_def)
  2.1402    from x hull_minimal[OF SP' P', unfolded span_def[symmetric]]
  2.1403 -  show "P x" by (metis mem_def subset_eq) 
  2.1404 +  show "P x" by (metis mem_def subset_eq)
  2.1405  qed
  2.1406  
  2.1407  lemma span_empty: "span {} = {(0::'a::semiring_0 ^ 'n)}"
  2.1408 @@ -3016,11 +3016,11 @@
  2.1409    using span_induct SP P by blast
  2.1410  
  2.1411  inductive span_induct_alt_help for S:: "'a::semiring_1^'n \<Rightarrow> bool"
  2.1412 -  where 
  2.1413 +  where
  2.1414    span_induct_alt_help_0: "span_induct_alt_help S 0"
  2.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)"
  2.1416  
  2.1417 -lemma span_induct_alt': 
  2.1418 +lemma span_induct_alt':
  2.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"
  2.1420  proof-
  2.1421    {fix x:: "'a^'n" assume x: "span_induct_alt_help S x"
  2.1422 @@ -3031,7 +3031,7 @@
  2.1423        done}
  2.1424    note th0 = this
  2.1425    {fix x assume x: "x \<in> span S"
  2.1426 -    
  2.1427 +
  2.1428      have "span_induct_alt_help S x"
  2.1429        proof(rule span_induct[where x=x and S=S])
  2.1430  	show "x \<in> span S" using x .
  2.1431 @@ -3043,7 +3043,7 @@
  2.1432  	have "span_induct_alt_help S 0" by (rule span_induct_alt_help_0)
  2.1433  	moreover
  2.1434  	{fix x y assume h: "span_induct_alt_help S x" "span_induct_alt_help S y"
  2.1435 -	  from h 
  2.1436 +	  from h
  2.1437  	  have "span_induct_alt_help S (x + y)"
  2.1438  	    apply (induct rule: span_induct_alt_help.induct)
  2.1439  	    apply simp
  2.1440 @@ -3054,7 +3054,7 @@
  2.1441  	    done}
  2.1442  	moreover
  2.1443  	{fix c x assume xt: "span_induct_alt_help S x"
  2.1444 -	  then have "span_induct_alt_help S (c*s x)" 
  2.1445 +	  then have "span_induct_alt_help S (c*s x)"
  2.1446  	    apply (induct rule: span_induct_alt_help.induct)
  2.1447  	    apply (simp add: span_induct_alt_help_0)
  2.1448  	    apply (simp add: vector_smult_assoc vector_add_ldistrib)
  2.1449 @@ -3063,13 +3063,13 @@
  2.1450  	    apply simp
  2.1451  	    done
  2.1452  	}
  2.1453 -	ultimately show "subspace (span_induct_alt_help S)" 
  2.1454 +	ultimately show "subspace (span_induct_alt_help S)"
  2.1455  	  unfolding subspace_def mem_def Ball_def by blast
  2.1456        qed}
  2.1457    with th0 show ?thesis by blast
  2.1458 -qed 
  2.1459 -
  2.1460 -lemma span_induct_alt: 
  2.1461 +qed
  2.1462 +
  2.1463 +lemma span_induct_alt:
  2.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"
  2.1465    shows "h x"
  2.1466  using span_induct_alt'[of h S] h0 hS x by blast
  2.1467 @@ -3118,9 +3118,9 @@
  2.1468        apply (rule subspace_span)
  2.1469        apply (rule x)
  2.1470        done}
  2.1471 -  moreover 
  2.1472 +  moreover
  2.1473    {fix x assume x: "x \<in> span S"
  2.1474 -    have th0:"(\<lambda>a. f a \<in> span (f ` S)) = {x. f x \<in> span (f ` S)}" apply (rule set_ext) 
  2.1475 +    have th0:"(\<lambda>a. f a \<in> span (f ` S)) = {x. f x \<in> span (f ` S)}" apply (rule set_ext)
  2.1476        unfolding mem_def Collect_def ..
  2.1477      have "f x \<in> span (f ` S)"
  2.1478        apply (rule span_induct[where S=S])
  2.1479 @@ -3146,15 +3146,15 @@
  2.1480  	apply (rule exI[where x="1"], simp)
  2.1481  	by (rule span_0)}
  2.1482      moreover
  2.1483 -    {assume ab: "x \<noteq> b" 
  2.1484 +    {assume ab: "x \<noteq> b"
  2.1485        then have "?P x"  using xS
  2.1486  	apply -
  2.1487  	apply (rule exI[where x=0])
  2.1488  	apply (rule span_superset)
  2.1489  	by simp}
  2.1490      ultimately have "?P x" by blast}
  2.1491 -  moreover have "subspace ?P" 
  2.1492 -    unfolding subspace_def 
  2.1493 +  moreover have "subspace ?P"
  2.1494 +    unfolding subspace_def
  2.1495      apply auto
  2.1496      apply (simp add: mem_def)
  2.1497      apply (rule exI[where x=0])
  2.1498 @@ -3174,7 +3174,7 @@
  2.1499      apply (rule span_mul[unfolded mem_def])
  2.1500      apply assumption
  2.1501      by (vector ring_simps)
  2.1502 -  ultimately show "?P a" using aS span_induct[where S=S and P= "?P"] by metis 
  2.1503 +  ultimately show "?P a" using aS span_induct[where S=S and P= "?P"] by metis
  2.1504  qed
  2.1505  
  2.1506  lemma span_breakdown_eq:
  2.1507 @@ -3186,7 +3186,7 @@
  2.1508        apply (rule_tac x= "k" in exI)
  2.1509        apply (rule set_rev_mp[of _ "span (S - {a})" _])
  2.1510        apply assumption
  2.1511 -      apply (rule span_mono)      
  2.1512 +      apply (rule span_mono)
  2.1513        apply blast
  2.1514        done}
  2.1515    moreover
  2.1516 @@ -3196,7 +3196,7 @@
  2.1517        apply (rule span_add)
  2.1518        apply (rule set_rev_mp[of _ "span S" _])
  2.1519        apply (rule k)
  2.1520 -      apply (rule span_mono)      
  2.1521 +      apply (rule span_mono)
  2.1522        apply blast
  2.1523        apply (rule span_mul)
  2.1524        apply (rule span_superset)
  2.1525 @@ -3224,7 +3224,7 @@
  2.1526        done
  2.1527      with na  have ?thesis by blast}
  2.1528    moreover
  2.1529 -  {assume k0: "k \<noteq> 0" 
  2.1530 +  {assume k0: "k \<noteq> 0"
  2.1531      have eq: "b = (1/k) *s a - ((1/k) *s a - b)" by vector
  2.1532      from k0 have eq': "(1/k) *s (a - k*s b) = (1/k) *s a - b"
  2.1533        by (vector field_simps)
  2.1534 @@ -3247,8 +3247,8 @@
  2.1535    ultimately show ?thesis by blast
  2.1536  qed
  2.1537  
  2.1538 -lemma in_span_delete: 
  2.1539 -  assumes a: "(a::'a::field^'n) \<in> span S" 
  2.1540 +lemma in_span_delete:
  2.1541 +  assumes a: "(a::'a::field^'n) \<in> span S"
  2.1542    and na: "a \<notin> span (S-{b})"
  2.1543    shows "b \<in> span (insert a (S - {b}))"
  2.1544    apply (rule in_span_insert)
  2.1545 @@ -3268,7 +3268,7 @@
  2.1546    from span_breakdown[of x "insert x S" y, OF insertI1 y]
  2.1547    obtain k where k: "y -k*s x \<in> span (S - {x})" by auto
  2.1548    have eq: "y = (y - k *s x) + k *s x" by vector
  2.1549 -  show ?thesis 
  2.1550 +  show ?thesis
  2.1551      apply (subst eq)
  2.1552      apply (rule span_add)
  2.1553      apply (rule set_rev_mp)
  2.1554 @@ -3304,18 +3304,18 @@
  2.1555    next
  2.1556      fix c x y
  2.1557      assume x: "x \<in> P" and hy: "?h y"
  2.1558 -    from hy obtain S u where fS: "finite S" and SP: "S\<subseteq>P" 
  2.1559 +    from hy obtain S u where fS: "finite S" and SP: "S\<subseteq>P"
  2.1560        and u: "setsum (\<lambda>v. u v *s v) S = y" by blast
  2.1561      let ?S = "insert x S"
  2.1562      let ?u = "\<lambda>y. if y = x then (if x \<in> S then u y + c else c)
  2.1563                    else u y"
  2.1564      from fS SP x have th0: "finite (insert x S)" "insert x S \<subseteq> P" by blast+
  2.1565      {assume xS: "x \<in> S"
  2.1566 -      have S1: "S = (S - {x}) \<union> {x}" 
  2.1567 +      have S1: "S = (S - {x}) \<union> {x}"
  2.1568  	and Sss:"finite (S - {x})" "finite {x}" "(S -{x}) \<inter> {x} = {}" using xS fS by auto
  2.1569        have "setsum (\<lambda>v. ?u v *s v) ?S =(\<Sum>v\<in>S - {x}. u v *s v) + (u x + c) *s x"
  2.1570 -	using xS 
  2.1571 -	by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]] 
  2.1572 +	using xS
  2.1573 +	by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]
  2.1574  	  setsum_clauses(2)[OF fS] cong del: if_weak_cong)
  2.1575        also have "\<dots> = (\<Sum>v\<in>S. u v *s v) + c *s x"
  2.1576  	apply (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]])
  2.1577 @@ -3324,7 +3324,7 @@
  2.1578  	by (simp add: add_commute u)
  2.1579        finally have "setsum (\<lambda>v. ?u v *s v) ?S = c*s x + y" .
  2.1580      then have "?Q ?S ?u (c*s x + y)" using th0 by blast}
  2.1581 -  moreover 
  2.1582 +  moreover
  2.1583    {assume xS: "x \<notin> S"
  2.1584      have th00: "(\<Sum>v\<in>S. (if v = x then c else u v) *s v) = y"
  2.1585        unfolding u[symmetric]
  2.1586 @@ -3334,7 +3334,7 @@
  2.1587        by (simp add: th00 setsum_clauses add_commute cong del: if_weak_cong)}
  2.1588    ultimately have "?Q ?S ?u (c*s x + y)"
  2.1589      by (cases "x \<in> S", simp, simp)
  2.1590 -    then show "?h (c*s x + y)" 
  2.1591 +    then show "?h (c*s x + y)"
  2.1592        apply -
  2.1593        apply (rule exI[where x="?S"])
  2.1594        apply (rule exI[where x="?u"]) by metis
  2.1595 @@ -3346,11 +3346,11 @@
  2.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")
  2.1597  proof-
  2.1598    {assume dP: "dependent P"
  2.1599 -    then obtain a S u where aP: "a \<in> P" and fS: "finite S" 
  2.1600 -      and SP: "S \<subseteq> P - {a}" and ua: "setsum (\<lambda>v. u v *s v) S = a" 
  2.1601 +    then obtain a S u where aP: "a \<in> P" and fS: "finite S"
  2.1602 +      and SP: "S \<subseteq> P - {a}" and ua: "setsum (\<lambda>v. u v *s v) S = a"
  2.1603        unfolding dependent_def span_explicit by blast
  2.1604 -    let ?S = "insert a S" 
  2.1605 -    let ?u = "\<lambda>y. if y = a then - 1 else u y" 
  2.1606 +    let ?S = "insert a S"
  2.1607 +    let ?u = "\<lambda>y. if y = a then - 1 else u y"
  2.1608      let ?v = a
  2.1609      from aP SP have aS: "a \<notin> S" by blast
  2.1610      from fS SP aP have th0: "finite ?S" "?S \<subseteq> P" "?v \<in> ?S" "?u ?v \<noteq> 0" by auto
  2.1611 @@ -3366,16 +3366,16 @@
  2.1612        apply (rule exI[where x= "?u"])
  2.1613        by clarsimp}
  2.1614    moreover
  2.1615 -  {fix S u v assume fS: "finite S" 
  2.1616 -      and SP: "S \<subseteq> P" and vS: "v \<in> S" and uv: "u v \<noteq> 0" 
  2.1617 +  {fix S u v assume fS: "finite S"
  2.1618 +      and SP: "S \<subseteq> P" and vS: "v \<in> S" and uv: "u v \<noteq> 0"
  2.1619      and u: "setsum (\<lambda>v. u v *s v) S = 0"
  2.1620 -    let ?a = v 
  2.1621 +    let ?a = v
  2.1622      let ?S = "S - {v}"
  2.1623      let ?u = "\<lambda>i. (- u i) / u v"
  2.1624 -    have th0: "?a \<in> P" "finite ?S" "?S \<subseteq> P"       using fS SP vS by auto 
  2.1625 +    have th0: "?a \<in> P" "finite ?S" "?S \<subseteq> P"       using fS SP vS by auto
  2.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"
  2.1627 -      using fS vS uv 
  2.1628 -      by (simp add: setsum_diff1 vector_smult_lneg divide_inverse 
  2.1629 +      using fS vS uv
  2.1630 +      by (simp add: setsum_diff1 vector_smult_lneg divide_inverse
  2.1631  	vector_smult_assoc field_simps)
  2.1632      also have "\<dots> = ?a"
  2.1633        unfolding setsum_cmul u
  2.1634 @@ -3398,7 +3398,7 @@
  2.1635    (is "_ = ?rhs")
  2.1636  proof-
  2.1637    {fix y assume y: "y \<in> span S"
  2.1638 -    from y obtain S' u where fS': "finite S'" and SS': "S' \<subseteq> S" and 
  2.1639 +    from y obtain S' u where fS': "finite S'" and SS': "S' \<subseteq> S" and
  2.1640        u: "setsum (\<lambda>v. u v *s v) S' = y" unfolding span_explicit by blast
  2.1641      let ?u = "\<lambda>x. if x \<in> S' then u x else 0"
  2.1642      from setsum_restrict_set[OF fS, of "\<lambda>v. u v *s v" S', symmetric] SS'
  2.1643 @@ -3410,7 +3410,7 @@
  2.1644        done
  2.1645      hence "setsum (\<lambda>v. ?u v *s v) S = y" by (metis u)
  2.1646      hence "y \<in> ?rhs" by auto}
  2.1647 -  moreover 
  2.1648 +  moreover
  2.1649    {fix y u assume u: "setsum (\<lambda>v. u v *s v) S = y"
  2.1650      then have "y \<in> span S" using fS unfolding span_explicit by auto}
  2.1651    ultimately show ?thesis by blast
  2.1652 @@ -3431,7 +3431,7 @@
  2.1653  apply (auto simp add: Collect_def mem_def)
  2.1654  done
  2.1655  
  2.1656 -  
  2.1657 +
  2.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")
  2.1659  proof-
  2.1660    have eq: "?S = basis ` {1 .. ?n}" by blast
  2.1661 @@ -3461,10 +3461,10 @@
  2.1662   {fix x::"'a^'n" assume xS: "x\<in> ?B"
  2.1663     from xS have "?P x" by (auto simp add: basis_component)}
  2.1664   moreover
  2.1665 - have "subspace ?P" 
  2.1666 + have "subspace ?P"
  2.1667     by (auto simp add: subspace_def Collect_def mem_def zero_index vector_component)
  2.1668   ultimately show ?thesis
  2.1669 -   using x span_induct[of ?B ?P x] i iS by blast 
  2.1670 +   using x span_induct[of ?B ?P x] i iS by blast
  2.1671  qed
  2.1672  
  2.1673  lemma independent_stdbasis: "independent {basis i ::real^'n |i. i\<in> {1 .. dimindex(UNIV :: 'n set)}}"
  2.1674 @@ -3508,7 +3508,7 @@
  2.1675  	apply assumption
  2.1676  	apply blast
  2.1677  	by (simp add: dependent_def)}
  2.1678 -    moreover 
  2.1679 +    moreover
  2.1680      {assume i: ?rhs
  2.1681        have ?lhs using i aS
  2.1682  	apply simp
  2.1683 @@ -3541,7 +3541,7 @@
  2.1684    by (metis subset_eq span_superset)
  2.1685  
  2.1686  lemma spanning_subset_independent:
  2.1687 -  assumes BA: "B \<subseteq> A" and iA: "independent (A::('a::field ^'n) set)" 
  2.1688 +  assumes BA: "B \<subseteq> A" and iA: "independent (A::('a::field ^'n) set)"
  2.1689    and AsB: "A \<subseteq> span B"
  2.1690    shows "A = B"
  2.1691  proof
  2.1692 @@ -3569,7 +3569,7 @@
  2.1693  
  2.1694  lemma exchange_lemma:
  2.1695    assumes f:"finite (t:: ('a::field^'n) set)" and i: "independent s"
  2.1696 -  and sp:"s \<subseteq> span t" 
  2.1697 +  and sp:"s \<subseteq> span t"
  2.1698    shows "\<exists>t'. (t' hassize card t) \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'"
  2.1699  using f i sp
  2.1700  proof(induct c\<equiv>"card(t - s)" arbitrary: s t rule: nat_less_induct)
  2.1701 @@ -3584,15 +3584,15 @@
  2.1702      and ft: "finite t" and s: "independent s" and sp: "s \<subseteq> span t"
  2.1703      and n: "n = card (t - s)"
  2.1704    let ?P = "\<lambda>t'. (t' hassize card t) \<and> s \<subseteq> t' \<and> t' \<subseteq> s \<union> t \<and> s \<subseteq> span t'"
  2.1705 -  let ?ths = "\<exists>t'. ?P t'" 
  2.1706 -  {assume st: "s \<subseteq> t" 
  2.1707 -    from st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t]) 
  2.1708 +  let ?ths = "\<exists>t'. ?P t'"
  2.1709 +  {assume st: "s \<subseteq> t"
  2.1710 +    from st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
  2.1711        by (auto simp add: hassize_def intro: span_superset)}
  2.1712    moreover
  2.1713    {assume st: "t \<subseteq> s"
  2.1714 -    
  2.1715 -    from spanning_subset_independent[OF st s sp] 
  2.1716 -      st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t]) 
  2.1717 +
  2.1718 +    from spanning_subset_independent[OF st s sp]
  2.1719 +      st ft span_mono[OF st] have ?ths apply - apply (rule exI[where x=t])
  2.1720        by (auto simp add: hassize_def intro: span_superset)}
  2.1721    moreover
  2.1722    {assume st: "\<not> s \<subseteq> t" "\<not> t \<subseteq> s"
  2.1723 @@ -3603,28 +3603,28 @@
  2.1724        from b ft have ct0: "card t \<noteq> 0" by auto
  2.1725      {assume stb: "s \<subseteq> span(t -{b})"
  2.1726        from ft have ftb: "finite (t -{b})" by auto
  2.1727 -      from H[rule_format, OF cardlt ftb s stb] 
  2.1728 +      from H[rule_format, OF cardlt ftb s stb]
  2.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
  2.1730        let ?w = "insert b u"
  2.1731        have th0: "s \<subseteq> insert b u" using u by blast
  2.1732 -      from u(3) b have "u \<subseteq> s \<union> t" by blast 
  2.1733 +      from u(3) b have "u \<subseteq> s \<union> t" by blast
  2.1734        then have th1: "insert b u \<subseteq> s \<union> t" using u b by blast
  2.1735        have bu: "b \<notin> u" using b u by blast
  2.1736        from u(1) have fu: "finite u" by (simp add: hassize_def)
  2.1737        from u(1) ft b have "u hassize (card t - 1)" by auto
  2.1738 -      then 
  2.1739 -      have th2: "insert b u hassize card t" 
  2.1740 +      then
  2.1741 +      have th2: "insert b u hassize card t"
  2.1742  	using  card_insert_disjoint[OF fu bu] ct0 by (auto simp add: hassize_def)
  2.1743        from u(4) have "s \<subseteq> span u" .
  2.1744        also have "\<dots> \<subseteq> span (insert b u)" apply (rule span_mono) by blast
  2.1745        finally have th3: "s \<subseteq> span (insert b u)" .      from th0 th1 th2 th3 have th: "?P ?w"  by blast
  2.1746        from th have ?ths by blast}
  2.1747      moreover
  2.1748 -    {assume stb: "\<not> s \<subseteq> span(t -{b})" 
  2.1749 +    {assume stb: "\<not> s \<subseteq> span(t -{b})"
  2.1750        from stb obtain a where a: "a \<in> s" "a \<notin> span (t - {b})" by blast
  2.1751        have ab: "a \<noteq> b" using a b by blast
  2.1752        have at: "a \<notin> t" using a ab span_superset[of a "t- {b}"] by auto
  2.1753 -      have mlt: "card ((insert a (t - {b})) - s) < n" 
  2.1754 +      have mlt: "card ((insert a (t - {b})) - s) < n"
  2.1755  	using cardlt ft n  a b by auto
  2.1756        have ft': "finite (insert a (t - {b}))" using ft by auto
  2.1757        {fix x assume xs: "x \<in> s"
  2.1758 @@ -3637,15 +3637,15 @@
  2.1759  	have x: "x \<in> span (insert b (insert a (t - {b})))" ..
  2.1760  	from span_trans[OF bs x] have "x \<in> span (insert a (t - {b}))"  .}
  2.1761        then have sp': "s \<subseteq> span (insert a (t - {b}))" by blast
  2.1762 -      
  2.1763 -      from H[rule_format, OF mlt ft' s sp' refl] obtain u where 
  2.1764 +
  2.1765 +      from H[rule_format, OF mlt ft' s sp' refl] obtain u where
  2.1766  	u: "u hassize card (insert a (t -{b}))" "s \<subseteq> u" "u \<subseteq> s \<union> insert a (t -{b})"
  2.1767  	"s \<subseteq> span u" by blast
  2.1768        from u a b ft at ct0 have "?P u" by (auto simp add: hassize_def)
  2.1769        then have ?ths by blast }
  2.1770      ultimately have ?ths by blast
  2.1771    }
  2.1772 -  ultimately 
  2.1773 +  ultimately
  2.1774    show ?ths  by blast
  2.1775  qed
  2.1776  
  2.1777 @@ -3659,7 +3659,7 @@
  2.1778  lemma finite_Atleast_Atmost[simp]: "finite {f x |x. x\<in> {(i::'a::finite_intvl_succ) .. j}}"
  2.1779  proof-
  2.1780    have eq: "{f x |x. x\<in> {i .. j}} = f ` {i .. j}" by auto
  2.1781 -  show ?thesis unfolding eq 
  2.1782 +  show ?thesis unfolding eq
  2.1783      apply (rule finite_imageI)
  2.1784      apply (rule finite_intvl)
  2.1785      done
  2.1786 @@ -3668,7 +3668,7 @@
  2.1787  lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x\<in> {(i::nat) .. j}}"
  2.1788  proof-
  2.1789    have eq: "{f x |x. x\<in> {i .. j}} = f ` {i .. j}" by auto
  2.1790 -  show ?thesis unfolding eq 
  2.1791 +  show ?thesis unfolding eq
  2.1792      apply (rule finite_imageI)
  2.1793      apply (rule finite_atLeastAtMost)
  2.1794      done
  2.1795 @@ -3682,7 +3682,7 @@
  2.1796    apply (rule independent_span_bound)
  2.1797    apply (rule finite_Atleast_Atmost_nat)
  2.1798    apply assumption
  2.1799 -  unfolding span_stdbasis 
  2.1800 +  unfolding span_stdbasis
  2.1801    apply (rule subset_UNIV)
  2.1802    done
  2.1803  
  2.1804 @@ -3710,14 +3710,14 @@
  2.1805      from VS obtain a where a: "a \<in> V" "a \<notin> span S" by blast
  2.1806      from a have aS: "a \<notin> S" by (auto simp add: span_superset)
  2.1807      have th0: "insert a S \<subseteq> V" using a sv by blast
  2.1808 -    from independent_insert[of a S]  i a 
  2.1809 +    from independent_insert[of a S]  i a
  2.1810      have th1: "independent (insert a S)" by auto
  2.1811 -    have mlt: "?d - card (insert a S) < n" 
  2.1812 -      using aS a n independent_bound[OF th1] dimindex_ge_1[of "UNIV :: 'n set"] 
  2.1813 -      by auto 
  2.1814 -      
  2.1815 -    from H[rule_format, OF mlt th0 th1 refl] 
  2.1816 -    obtain B where B: "insert a S \<subseteq> B" "B \<subseteq> V" "independent B" " V \<subseteq> span B" 
  2.1817 +    have mlt: "?d - card (insert a S) < n"
  2.1818 +      using aS a n independent_bound[OF th1] dimindex_ge_1[of "UNIV :: 'n set"]
  2.1819 +      by auto
  2.1820 +
  2.1821 +    from H[rule_format, OF mlt th0 th1 refl]
  2.1822 +    obtain B where B: "insert a S \<subseteq> B" "B \<subseteq> V" "independent B" " V \<subseteq> span B"
  2.1823        by blast
  2.1824      from B have "?P B" by auto
  2.1825      then have ?ths by blast}
  2.1826 @@ -3732,7 +3732,7 @@
  2.1827  
  2.1828  definition "dim V = (SOME n. \<exists>B. B \<subseteq> V \<and> independent B \<and> V \<subseteq> span B \<and> (B hassize n))"
  2.1829  
  2.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)" 
  2.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)"
  2.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)"]
  2.1833  unfolding hassize_def
  2.1834  using maximal_independent_subset[of V] independent_bound
  2.1835 @@ -3784,7 +3784,7 @@
  2.1836  qed
  2.1837  
  2.1838  lemma card_le_dim_spanning:
  2.1839 -  assumes BV: "(B:: (real ^'n) set) \<subseteq> V" and VB: "V \<subseteq> span B" 
  2.1840 +  assumes BV: "(B:: (real ^'n) set) \<subseteq> V" and VB: "V \<subseteq> span B"
  2.1841    and fB: "finite B" and dVB: "dim V \<ge> card B"
  2.1842    shows "independent B"
  2.1843  proof-
  2.1844 @@ -3794,10 +3794,10 @@
  2.1845      from BV a have th0: "B -{a} \<subseteq> V" by blast
  2.1846      {fix x assume x: "x \<in> V"
  2.1847        from a have eq: "insert a (B -{a}) = B" by blast
  2.1848 -      from x VB have x': "x \<in> span B" by blast 
  2.1849 +      from x VB have x': "x \<in> span B" by blast
  2.1850        from span_trans[OF a(2), unfolded eq, OF x']
  2.1851        have "x \<in> span (B -{a})" . }
  2.1852 -    then have th1: "V \<subseteq> span (B -{a})" by blast 
  2.1853 +    then have th1: "V \<subseteq> span (B -{a})" by blast
  2.1854      have th2: "finite (B -{a})" using fB by auto
  2.1855      from span_card_ge_dim[OF th0 th1 th2]
  2.1856      have c: "dim V \<le> card (B -{a})" .
  2.1857 @@ -3806,7 +3806,7 @@
  2.1858  qed
  2.1859  
  2.1860  lemma card_eq_dim: "(B:: (real ^'n) set) \<subseteq> V \<Longrightarrow> B hassize dim V \<Longrightarrow> independent B \<longleftrightarrow> V \<subseteq> span B"
  2.1861 -  by (metis hassize_def order_eq_iff card_le_dim_spanning 
  2.1862 +  by (metis hassize_def order_eq_iff card_le_dim_spanning
  2.1863      card_ge_dim_independent)
  2.1864  
  2.1865  (* ------------------------------------------------------------------------- *)
  2.1866 @@ -3818,18 +3818,18 @@
  2.1867    by (metis independent_card_le_dim independent_bound subset_refl)
  2.1868  
  2.1869  lemma dependent_biggerset_general: "(finite (S:: (real^'n) set) \<Longrightarrow> card S > dim S) \<Longrightarrow> dependent S"
  2.1870 -  using independent_bound_general[of S] by (metis linorder_not_le) 
  2.1871 +  using independent_bound_general[of S] by (metis linorder_not_le)
  2.1872  
  2.1873  lemma dim_span: "dim (span (S:: (real ^'n) set)) = dim S"
  2.1874  proof-
  2.1875 -  have th0: "dim S \<le> dim (span S)" 
  2.1876 +  have th0: "dim S \<le> dim (span S)"
  2.1877      by (auto simp add: subset_eq intro: dim_subset span_superset)
  2.1878 -  from basis_exists[of S] 
  2.1879 +  from basis_exists[of S]
  2.1880    obtain B where B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "B hassize dim S" by blast
  2.1881    from B have fB: "finite B" "card B = dim S" unfolding hassize_def by blast+
  2.1882 -  have bSS: "B \<subseteq> span S" using B(1) by (metis subset_eq span_inc) 
  2.1883 -  have sssB: "span S \<subseteq> span B" using span_mono[OF B(3)] by (simp add: span_span) 
  2.1884 -  from span_card_ge_dim[OF bSS sssB fB(1)] th0 show ?thesis 
  2.1885 +  have bSS: "B \<subseteq> span S" using B(1) by (metis subset_eq span_inc)
  2.1886 +  have sssB: "span S \<subseteq> span B" using span_mono[OF B(3)] by (simp add: span_span)
  2.1887 +  from span_card_ge_dim[OF bSS sssB fB(1)] th0 show ?thesis
  2.1888      using fB(2)  by arith
  2.1889  qed
  2.1890  
  2.1891 @@ -3847,7 +3847,7 @@
  2.1892  
  2.1893  lemma dim_image_le: assumes lf: "linear f" shows "dim (f ` S) \<le> dim (S:: (real ^'n) set)"
  2.1894  proof-
  2.1895 -  from basis_exists[of S] obtain B where 
  2.1896 +  from basis_exists[of S] obtain B where
  2.1897      B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "B hassize dim S" by blast
  2.1898    from B have fB: "finite B" "card B = dim S" unfolding hassize_def by blast+
  2.1899    have "dim (f ` S) \<le> card (f ` B)"
  2.1900 @@ -3860,7 +3860,7 @@
  2.1901  (* Relation between bases and injectivity/surjectivity of map.               *)
  2.1902  
  2.1903  lemma spanning_surjective_image:
  2.1904 -  assumes us: "UNIV \<subseteq> span (S:: ('a::semiring_1 ^'n) set)" 
  2.1905 +  assumes us: "UNIV \<subseteq> span (S:: ('a::semiring_1 ^'n) set)"
  2.1906    and lf: "linear f" and sf: "surj f"
  2.1907    shows "UNIV \<subseteq> span (f ` S)"
  2.1908  proof-
  2.1909 @@ -3881,7 +3881,7 @@
  2.1910      hence "a \<in> span (S -{a})" using fi by (auto simp add: inj_on_def)
  2.1911      with a(1) iS  have False by (simp add: dependent_def) }
  2.1912    then show ?thesis unfolding dependent_def by blast
  2.1913 -qed 
  2.1914 +qed
  2.1915  
  2.1916  (* ------------------------------------------------------------------------- *)
  2.1917  (* Picking an orthogonal replacement for a spanning set.                     *)
  2.1918 @@ -3904,15 +3904,15 @@
  2.1919    case 1 thus ?case apply (rule exI[where x="{}"]) by (auto simp add: pairwise_def)
  2.1920  next
  2.1921    case (2 a B)
  2.1922 -  note fB = `finite B` and aB = `a \<notin> B` 
  2.1923 -  from `\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C` 
  2.1924 -  obtain C where C: "finite C" "card C \<le> card B" 
  2.1925 +  note fB = `finite B` and aB = `a \<notin> B`
  2.1926 +  from `\<exists>C. finite C \<and> card C \<le> card B \<and> span C = span B \<and> pairwise orthogonal C`
  2.1927 +  obtain C where C: "finite C" "card C \<le> card B"
  2.1928      "span C = span B" "pairwise orthogonal C" by blast
  2.1929    let ?a = "a - setsum (\<lambda>x. (x\<bullet>a / (x\<bullet>x)) *s x) C"
  2.1930    let ?C = "insert ?a C"
  2.1931    from C(1) have fC: "finite ?C" by simp
  2.1932    from fB aB C(1,2) have cC: "card ?C \<le> card (insert a B)" by (simp add: card_insert_if)
  2.1933 -  {fix x k 
  2.1934 +  {fix x k
  2.1935      have th0: "\<And>(a::'b::comm_ring) b c. a - (b - c) = c + (a - b)" by (simp add: ring_simps)
  2.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"
  2.1937        apply (simp only: vector_ssub_ldistrib th0)
  2.1938 @@ -3924,18 +3924,18 @@
  2.1939        by (rule span_superset)}
  2.1940    then have SC: "span ?C = span (insert a B)"
  2.1941      unfolding expand_set_eq span_breakdown_eq C(3)[symmetric] by auto
  2.1942 -  thm pairwise_def 
  2.1943 +  thm pairwise_def
  2.1944    {fix x y assume xC: "x \<in> ?C" and yC: "y \<in> ?C" and xy: "x \<noteq> y"
  2.1945 -    {assume xa: "x = ?a" and ya: "y = ?a" 
  2.1946 +    {assume xa: "x = ?a" and ya: "y = ?a"
  2.1947        have "orthogonal x y" using xa ya xy by blast}
  2.1948      moreover
  2.1949 -    {assume xa: "x = ?a" and ya: "y \<noteq> ?a" "y \<in> C" 
  2.1950 +    {assume xa: "x = ?a" and ya: "y \<noteq> ?a" "y \<in> C"
  2.1951        from ya have Cy: "C = insert y (C - {y})" by blast
  2.1952        have fth: "finite (C - {y})" using C by simp
  2.1953        have "orthogonal x y"
  2.1954  	using xa ya
  2.1955  	unfolding orthogonal_def xa dot_lsub dot_rsub diff_eq_0_iff_eq
  2.1956 -	apply simp 
  2.1957 +	apply simp
  2.1958  	apply (subst Cy)
  2.1959  	using C(1) fth
  2.1960  	apply (simp only: setsum_clauses)
  2.1961 @@ -3946,13 +3946,13 @@
  2.1962  	apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
  2.1963  	by auto}
  2.1964      moreover
  2.1965 -    {assume xa: "x \<noteq> ?a" "x \<in> C" and ya: "y = ?a" 
  2.1966 +    {assume xa: "x \<noteq> ?a" "x \<in> C" and ya: "y = ?a"
  2.1967        from xa have Cx: "C = insert x (C - {x})" by blast
  2.1968        have fth: "finite (C - {x})" using C by simp
  2.1969        have "orthogonal x y"
  2.1970  	using xa ya
  2.1971  	unfolding orthogonal_def ya dot_rsub dot_lsub diff_eq_0_iff_eq
  2.1972 -	apply simp 
  2.1973 +	apply simp
  2.1974  	apply (subst Cx)
  2.1975  	using C(1) fth
  2.1976  	apply (simp only: setsum_clauses)
  2.1977 @@ -3963,12 +3963,12 @@
  2.1978  	apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format])
  2.1979  	by auto}
  2.1980      moreover
  2.1981 -    {assume xa: "x \<in> C" and ya: "y \<in> C" 
  2.1982 +    {assume xa: "x \<in> C" and ya: "y \<in> C"
  2.1983        have "orthogonal x y" using xa ya xy C(4) unfolding pairwise_def by blast}
  2.1984      ultimately have "orthogonal x y" using xC yC by blast}
  2.1985    then have CPO: "pairwise orthogonal ?C" unfolding pairwise_def by blast
  2.1986    from fC cC SC CPO have "?P (insert a B) ?C" by blast
  2.1987 -  then show ?case by blast 
  2.1988 +  then show ?case by blast
  2.1989  qed
  2.1990  
  2.1991  lemma orthogonal_basis_exists:
  2.1992 @@ -3977,18 +3977,18 @@
  2.1993  proof-
  2.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
  2.1995    from B have fB: "finite B" "card B = dim V" by (simp_all add: hassize_def)
  2.1996 -  from basis_orthogonal[OF fB(1)] obtain C where 
  2.1997 +  from basis_orthogonal[OF fB(1)] obtain C where
  2.1998      C: "finite C" "card C \<le> card B" "span C = span B" "pairwise orthogonal C" by blast
  2.1999 -  from C B 
  2.2000 -  have CSV: "C \<subseteq> span V" by (metis span_inc span_mono subset_trans) 
  2.2001 +  from C B
  2.2002 +  have CSV: "C \<subseteq> span V" by (metis span_inc span_mono subset_trans)
  2.2003    from span_mono[OF B(3)]  C have SVC: "span V \<subseteq> span C" by (simp add: span_span)
  2.2004    from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB
  2.2005 -  have iC: "independent C" by (simp add: dim_span) 
  2.2006 +  have iC: "independent C" by (simp add: dim_span)
  2.2007    from C fB have "card C \<le> dim V" by simp
  2.2008    moreover have "dim V \<le> card C" using span_card_ge_dim[OF CSV SVC C(1)]
  2.2009      by (simp add: dim_span)
  2.2010    ultimately have CdV: "C hassize dim V" unfolding hassize_def using C(1) by simp
  2.2011 -  from C B CSV CdV iC show ?thesis by auto 
  2.2012 +  from C B CSV CdV iC show ?thesis by auto
  2.2013  qed
  2.2014  
  2.2015  lemma span_eq: "span S = span T \<longleftrightarrow> S \<subseteq> span T \<and> T \<subseteq> span S"
  2.2016 @@ -4003,8 +4003,8 @@
  2.2017    shows "\<exists>(a:: real ^'n). a \<noteq>0 \<and> (\<forall>x \<in> span S. a \<bullet> x = 0)"
  2.2018  proof-
  2.2019    from sU obtain a where a: "a \<notin> span S" by blast
  2.2020 -  from orthogonal_basis_exists obtain B where 
  2.2021 -    B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B" "B hassize dim S" "pairwise orthogonal B" 
  2.2022 +  from orthogonal_basis_exists obtain B where
  2.2023 +    B: "independent B" "B \<subseteq> span S" "S \<subseteq> span B" "B hassize dim S" "pairwise orthogonal B"
  2.2024      by blast
  2.2025    from B have fB: "finite B" "card B = dim S" by (simp_all add: hassize_def)
  2.2026    from span_mono[OF B(2)] span_mono[OF B(3)]
  2.2027 @@ -4020,12 +4020,12 @@
  2.2028    have "\<forall>x\<in>span B. ?a \<bullet> x = 0"
  2.2029    proof(rule span_induct')
  2.2030      show "subspace (\<lambda>x. ?a \<bullet> x = 0)"
  2.2031 -      by (auto simp add: subspace_def mem_def dot_radd dot_rmult) 
  2.2032 +      by (auto simp add: subspace_def mem_def dot_radd dot_rmult)
  2.2033    next
  2.2034      {fix x assume x: "x \<in> B"
  2.2035        from x have B': "B = insert x (B - {x})" by blast
  2.2036        have fth: "finite (B - {x})" using fB by simp
  2.2037 -      have "?a \<bullet> x = 0" 
  2.2038 +      have "?a \<bullet> x = 0"
  2.2039  	apply (subst B') using fB fth
  2.2040  	unfolding setsum_clauses(2)[OF fth]
  2.2041  	apply simp
  2.2042 @@ -4038,7 +4038,7 @@
  2.2043    with a0 show ?thesis unfolding sSB by (auto intro: exI[where x="?a"])
  2.2044  qed
  2.2045  
  2.2046 -lemma span_not_univ_subset_hyperplane: 
  2.2047 +lemma span_not_univ_subset_hyperplane:
  2.2048    assumes SU: "span S \<noteq> (UNIV ::(real^'n) set)"
  2.2049    shows "\<exists> a. a \<noteq>0 \<and> span S \<subseteq> {x. a \<bullet> x = 0}"
  2.2050    using span_not_univ_orthogonal[OF SU] by auto
  2.2051 @@ -4058,9 +4058,9 @@
  2.2052  (* We can extend a linear basis-basis injection to the whole set.            *)
  2.2053  
  2.2054  lemma linear_indep_image_lemma:
  2.2055 -  assumes lf: "linear f" and fB: "finite B" 
  2.2056 +  assumes lf: "linear f" and fB: "finite B"
  2.2057    and ifB: "independent (f ` B)"
  2.2058 -  and fi: "inj_on f B" and xsB: "x \<in> span B" 
  2.2059 +  and fi: "inj_on f B" and xsB: "x \<in> span B"
  2.2060    and fx: "f (x::'a::field^'n) = 0"
  2.2061    shows "x = 0"
  2.2062    using fB ifB fi xsB fx
  2.2063 @@ -4070,11 +4070,11 @@
  2.2064    case (2 a b x)
  2.2065    have fb: "finite b" using "2.prems" by simp
  2.2066    have th0: "f ` b \<subseteq> f ` (insert a b)"
  2.2067 -    apply (rule image_mono) by blast 
  2.2068 +    apply (rule image_mono) by blast
  2.2069    from independent_mono[ OF "2.prems"(2) th0]
  2.2070    have ifb: "independent (f ` b)"  .
  2.2071 -  have fib: "inj_on f b" 
  2.2072 -    apply (rule subset_inj_on [OF "2.prems"(3)]) 
  2.2073 +  have fib: "inj_on f b"
  2.2074 +    apply (rule subset_inj_on [OF "2.prems"(3)])
  2.2075      by blast
  2.2076    from span_breakdown[of a "insert a b", simplified, OF "2.prems"(4)]
  2.2077    obtain k where k: "x - k*s a \<in> span (b -{a})" by blast
  2.2078 @@ -4084,16 +4084,16 @@
  2.2079      using k span_mono[of "b-{a}" b] by blast
  2.2080    hence "f x - k*s f a \<in> span (f ` b)"
  2.2081      by (simp add: linear_sub[OF lf] linear_cmul[OF lf])
  2.2082 -  hence th: "-k *s f a \<in> span (f ` b)" 
  2.2083 +  hence th: "-k *s f a \<in> span (f ` b)"
  2.2084      using "2.prems"(5) by (simp add: vector_smult_lneg)
  2.2085 -  {assume k0: "k = 0" 
  2.2086 +  {assume k0: "k = 0"
  2.2087      from k0 k have "x \<in> span (b -{a})" by simp
  2.2088      then have "x \<in> span b" using span_mono[of "b-{a}" b]
  2.2089        by blast}
  2.2090    moreover
  2.2091    {assume k0: "k \<noteq> 0"
  2.2092      from span_mul[OF th, of "- 1/ k"] k0
  2.2093 -    have th1: "f a \<in> span (f ` b)" 
  2.2094 +    have th1: "f a \<in> span (f ` b)"
  2.2095        by (auto simp add: vector_smult_assoc)
  2.2096      from inj_on_image_set_diff[OF "2.prems"(3), of "insert a b " "{a}", symmetric]
  2.2097      have tha: "f ` insert a b - f ` {a} = f ` (insert a b - {a})" by blast
  2.2098 @@ -4112,17 +4112,17 @@
  2.2099  
  2.2100  lemma linear_independent_extend_lemma:
  2.2101    assumes fi: "finite B" and ib: "independent B"
  2.2102 -  shows "\<exists>g. (\<forall>x\<in> span B. \<forall>y\<in> span B. g ((x::'a::field^'n) + y) = g x + g y) 
  2.2103 +  shows "\<exists>g. (\<forall>x\<in> span B. \<forall>y\<in> span B. g ((x::'a::field^'n) + y) = g x + g y)
  2.2104             \<and> (\<forall>x\<in> span B. \<forall>c. g (c*s x) = c *s g x)
  2.2105             \<and> (\<forall>x\<in> B. g x = f x)"
  2.2106  using ib fi
  2.2107  proof(induct rule: finite_induct[OF fi])
  2.2108 -  case 1 thus ?case by (auto simp add: span_empty) 
  2.2109 +  case 1 thus ?case by (auto simp add: span_empty)
  2.2110  next
  2.2111    case (2 a b)
  2.2112    from "2.prems" "2.hyps" have ibf: "independent b" "finite b"
  2.2113      by (simp_all add: independent_insert)
  2.2114 -  from "2.hyps"(3)[OF ibf] obtain g where 
  2.2115 +  from "2.hyps"(3)[OF ibf] obtain g where
  2.2116      g: "\<forall>x\<in>span b. \<forall>y\<in>span b. g (x + y) = g x + g y"
  2.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
  2.2118    let ?h = "\<lambda>z. SOME k. (z - k *s a) \<in> span b"
  2.2119 @@ -4132,12 +4132,12 @@
  2.2120        unfolding span_breakdown_eq[symmetric]
  2.2121        using z .
  2.2122      {fix k assume k: "z - k *s a \<in> span b"
  2.2123 -      have eq: "z - ?h z *s a - (z - k*s a) = (k - ?h z) *s a" 
  2.2124 +      have eq: "z - ?h z *s a - (z - k*s a) = (k - ?h z) *s a"
  2.2125  	by (simp add: ring_simps vector_sadd_rdistrib[symmetric])
  2.2126        from span_sub[OF th0 k]
  2.2127        have khz: "(k - ?h z) *s a \<in> span b" by (simp add: eq)
  2.2128        {assume "k \<noteq> ?h z" hence k0: "k - ?h z \<noteq> 0" by simp
  2.2129 -	from k0 span_mul[OF khz, of "1 /(k - ?h z)"] 
  2.2130 +	from k0 span_mul[OF khz, of "1 /(k - ?h z)"]
  2.2131  	have "a \<in> span b" by (simp add: vector_smult_assoc)
  2.2132  	with "2.prems"(1) "2.hyps"(2) have False
  2.2133  	  by (auto simp add: dependent_def)}
  2.2134 @@ -4146,26 +4146,26 @@
  2.2135    note h = this
  2.2136    let ?g = "\<lambda>z. ?h z *s f a + g (z - ?h z *s a)"
  2.2137    {fix x y assume x: "x \<in> span (insert a b)" and y: "y \<in> span (insert a b)"
  2.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)" 
  2.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)"
  2.2140        by (vector ring_simps)
  2.2141      have addh: "?h (x + y) = ?h x + ?h y"
  2.2142        apply (rule conjunct2[OF h, rule_format, symmetric])
  2.2143        apply (rule span_add[OF x y])
  2.2144        unfolding tha
  2.2145        by (metis span_add x y conjunct1[OF h, rule_format])
  2.2146 -    have "?g (x + y) = ?g x + ?g y" 
  2.2147 +    have "?g (x + y) = ?g x + ?g y"
  2.2148        unfolding addh tha
  2.2149        g(1)[rule_format,OF conjunct1[OF h, OF x] conjunct1[OF h, OF y]]
  2.2150        by (simp add: vector_sadd_rdistrib)}
  2.2151    moreover
  2.2152    {fix x:: "'a^'n" and c:: 'a  assume x: "x \<in> span (insert a b)"
  2.2153 -    have tha: "\<And>(x::'a^'n) c k a. c *s x - (c * k) *s a = c *s (x - k *s a)" 
  2.2154 +    have tha: "\<And>(x::'a^'n) c k a. c *s x - (c * k) *s a = c *s (x - k *s a)"
  2.2155        by (vector ring_simps)
  2.2156 -    have hc: "?h (c *s x) = c * ?h x" 
  2.2157 +    have hc: "?h (c *s x) = c * ?h x"
  2.2158        apply (rule conjunct2[OF h, rule_format, symmetric])
  2.2159        apply (metis span_mul x)
  2.2160        by (metis tha span_mul x conjunct1[OF h])
  2.2161 -    have "?g (c *s x) = c*s ?g x" 
  2.2162 +    have "?g (c *s x) = c*s ?g x"
  2.2163        unfolding hc tha g(2)[rule_format, OF conjunct1[OF h, OF x]]
  2.2164        by (vector ring_simps)}
  2.2165    moreover
  2.2166 @@ -4177,7 +4177,7 @@
  2.2167  	using conjunct1[OF h, OF span_superset, OF insertI1]
  2.2168  	by (auto simp add: span_0)
  2.2169  
  2.2170 -      from xa ha1[symmetric] have "?g x = f x" 
  2.2171 +      from xa ha1[symmetric] have "?g x = f x"
  2.2172  	apply simp
  2.2173  	using g(2)[rule_format, OF span_0, of 0]
  2.2174  	by simp}
  2.2175 @@ -4201,12 +4201,12 @@
  2.2176  proof-
  2.2177    from maximal_independent_subset_extend[of B UNIV] iB
  2.2178    obtain C where C: "B \<subseteq> C" "independent C" "\<And>x. x \<in> span C" by auto
  2.2179 -  
  2.2180 +
  2.2181    from C(2) independent_bound[of C] linear_independent_extend_lemma[of C f]
  2.2182 -  obtain g where g: "(\<forall>x\<in> span C. \<forall>y\<in> span C. g (x + y) = g x + g y) 
  2.2183 +  obtain g where g: "(\<forall>x\<in> span C. \<forall>y\<in> span C. g (x + y) = g x + g y)
  2.2184             \<and> (\<forall>x\<in> span C. \<forall>c. g (c*s x) = c *s g x)
  2.2185             \<and> (\<forall>x\<in> C. g x = f x)" by blast
  2.2186 -  from g show ?thesis unfolding linear_def using C 
  2.2187 +  from g show ?thesis unfolding linear_def using C
  2.2188      apply clarsimp by blast
  2.2189  qed
  2.2190  
  2.2191 @@ -4218,7 +4218,7 @@
  2.2192  proof(induct arbitrary: B rule: finite_induct[OF fA])
  2.2193    case 1 thus ?case by simp
  2.2194  next
  2.2195 -  case (2 x s t) 
  2.2196 +  case (2 x s t)
  2.2197    thus ?case
  2.2198    proof(induct rule: finite_induct[OF "2.prems"(1)])
  2.2199      case 1    then show ?case by simp
  2.2200 @@ -4234,7 +4234,7 @@
  2.2201    qed
  2.2202  qed
  2.2203  
  2.2204 -lemma card_subset_eq: assumes fB: "finite B" and AB: "A \<subseteq> B" and 
  2.2205 +lemma card_subset_eq: assumes fB: "finite B" and AB: "A \<subseteq> B" and
  2.2206    c: "card A = card B"
  2.2207    shows "A = B"
  2.2208  proof-
  2.2209 @@ -4245,27 +4245,27 @@
  2.2210    from card_Un_disjoint[OF fA fBA e, unfolded eq c]
  2.2211    have "card (B - A) = 0" by arith
  2.2212    hence "B - A = {}" unfolding card_eq_0_iff using fA fB by simp
  2.2213 -  with AB show "A = B" by blast  
  2.2214 +  with AB show "A = B" by blast
  2.2215  qed
  2.2216  
  2.2217  lemma subspace_isomorphism:
  2.2218 -  assumes s: "subspace (S:: (real ^'n) set)" and t: "subspace T" 
  2.2219 +  assumes s: "subspace (S:: (real ^'n) set)" and t: "subspace T"
  2.2220    and d: "dim S = dim T"
  2.2221    shows "\<exists>f. linear f \<and> f ` S = T \<and> inj_on f S"
  2.2222  proof-
  2.2223 -  from basis_exists[of S] obtain B where 
  2.2224 +  from basis_exists[of S] obtain B where
  2.2225      B: "B \<subseteq> S" "independent B" "S \<subseteq> span B" "B hassize dim S" by blast
  2.2226 -  from basis_exists[of T] obtain C where 
  2.2227 +  from basis_exists[of T] obtain C where
  2.2228      C: "C \<subseteq> T" "independent C" "T \<subseteq> span C" "C hassize dim T" by blast
  2.2229    from B(4) C(4) card_le_inj[of B C] d obtain f where
  2.2230 -    f: "f ` B \<subseteq> C" "inj_on f B" unfolding hassize_def by auto 
  2.2231 +    f: "f ` B \<subseteq> C" "inj_on f B" unfolding hassize_def by auto
  2.2232    from linear_independent_extend[OF B(2)] obtain g where
  2.2233      g: "linear g" "\<forall>x\<in> B. g x = f x" by blast
  2.2234    from B(4) have fB: "finite B" by (simp add: hassize_def)
  2.2235    from C(4) have fC: "finite C" by (simp add: hassize_def)
  2.2236 -  from inj_on_iff_eq_card[OF fB, of f] f(2) 
  2.2237 +  from inj_on_iff_eq_card[OF fB, of f] f(2)
  2.2238    have "card (f ` B) = card B" by simp
  2.2239 -  with B(4) C(4) have ceq: "card (f ` B) = card C" using d 
  2.2240 +  with B(4) C(4) have ceq: "card (f ` B) = card C" using d
  2.2241      by (simp add: hassize_def)
  2.2242    have "g ` B = f ` B" using g(2)
  2.2243      by (auto simp add: image_iff)
  2.2244 @@ -4277,9 +4277,9 @@
  2.2245    {fix x y assume x: "x \<in> S" and y: "y \<in> S" and gxy:"g x = g y"
  2.2246      from B(3) x y have x': "x \<in> span B" and y': "y \<in> span B" by blast+
  2.2247      from gxy have th0: "g (x - y) = 0" by (simp add: linear_sub[OF g(1)])
  2.2248 -    have th1: "x - y \<in> span B" using x' y' by (metis span_sub) 
  2.2249 +    have th1: "x - y \<in> span B" using x' y' by (metis span_sub)
  2.2250      have "x=y" using g0[OF th1 th0] by simp }
  2.2251 -  then have giS: "inj_on g S" 
  2.2252 +  then have giS: "inj_on g S"
  2.2253      unfolding inj_on_def by blast
  2.2254    from span_subspace[OF B(1,3) s]
  2.2255    have "g ` S = span (g ` B)" by (simp add: span_linear_image[OF g(1)])
  2.2256 @@ -4308,20 +4308,20 @@
  2.2257  qed
  2.2258  
  2.2259  lemma linear_eq_0:
  2.2260 -  assumes lf: "linear f" and SB: "S \<subseteq> span B" and f0: "\<forall>x\<in>B. f x = 0" 
  2.2261 +  assumes lf: "linear f" and SB: "S \<subseteq> span B" and f0: "\<forall>x\<in>B. f x = 0"
  2.2262    shows "\<forall>x \<in> S. f x = (0::'a::semiring_1^'n)"
  2.2263    by (metis linear_eq_0_span[OF lf] subset_eq SB f0)
  2.2264  
  2.2265  lemma linear_eq:
  2.2266    assumes lf: "linear (f::'a::ring_1^'n \<Rightarrow> _)" and lg: "linear g" and S: "S \<subseteq> span B"
  2.2267 -  and fg: "\<forall> x\<in> B. f x = g x" 
  2.2268 +  and fg: "\<forall> x\<in> B. f x = g x"
  2.2269    shows "\<forall>x\<in> S. f x = g x"
  2.2270  proof-
  2.2271    let ?h = "\<lambda>x. f x - g x"
  2.2272    from fg have fg': "\<forall>x\<in> B. ?h x = 0" by simp
  2.2273    from linear_eq_0[OF linear_compose_sub[OF lf lg] S fg']
  2.2274    show ?thesis by simp
  2.2275 -qed    
  2.2276 +qed
  2.2277  
  2.2278  lemma linear_eq_stdbasis:
  2.2279    assumes lf: "linear (f::'a::ring_1^'m \<Rightarrow> 'a^'n)" and lg: "linear g"
  2.2280 @@ -4329,7 +4329,7 @@
  2.2281    shows "f = g"
  2.2282  proof-
  2.2283    let ?U = "UNIV :: 'm set"
  2.2284 -  let ?I = "{basis i:: 'a^'m|i. i \<in> {1 .. dimindex ?U}}" 
  2.2285 +  let ?I = "{basis i:: 'a^'m|i. i \<in> {1 .. dimindex ?U}}"
  2.2286    {fix x assume x: "x \<in> (UNIV :: ('a^'m) set)"
  2.2287      from equalityD2[OF span_stdbasis]
  2.2288      have IU: " (UNIV :: ('a^'m) set) \<subseteq> span ?I" by blast
  2.2289 @@ -4341,27 +4341,27 @@
  2.2290  (* Similar results for bilinear functions.                                   *)
  2.2291  
  2.2292  lemma bilinear_eq:
  2.2293 -  assumes bf: "bilinear (f:: 'a::ring^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)" 
  2.2294 +  assumes bf: "bilinear (f:: 'a::ring^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)"
  2.2295    and bg: "bilinear g"
  2.2296    and SB: "S \<subseteq> span B" and TC: "T \<subseteq> span C"
  2.2297    and fg: "\<forall>x\<in> B. \<forall>y\<in> C. f x y = g x y"
  2.2298    shows "\<forall>x\<in>S. \<forall>y\<in>T. f x y = g x y "
  2.2299  proof-
  2.2300    let ?P = "\<lambda>x. \<forall>y\<in> span C. f x y = g x y"
  2.2301 -  from bf bg have sp: "subspace ?P" 
  2.2302 -    unfolding bilinear_def linear_def subspace_def bf bg  
  2.2303 +  from bf bg have sp: "subspace ?P"
  2.2304 +    unfolding bilinear_def linear_def subspace_def bf bg
  2.2305      by(auto simp add: span_0 mem_def bilinear_lzero[OF bf] bilinear_lzero[OF bg] span_add Ball_def intro:  bilinear_ladd[OF bf])
  2.2306  
  2.2307 -  have "\<forall>x \<in> span B. \<forall>y\<in> span C. f x y = g x y" 
  2.2308 +  have "\<forall>x \<in> span B. \<forall>y\<in> span C. f x y = g x y"
  2.2309      apply -
  2.2310      apply (rule ballI)
  2.2311 -    apply (rule span_induct[of B ?P]) 
  2.2312 +    apply (rule span_induct[of B ?P])
  2.2313      defer
  2.2314      apply (rule sp)
  2.2315      apply assumption
  2.2316      apply (clarsimp simp add: Ball_def)
  2.2317      apply (rule_tac P="\<lambda>y. f xa y = g xa y" and S=C in span_induct)
  2.2318 -    using fg 
  2.2319 +    using fg
  2.2320      apply (auto simp add: subspace_def)
  2.2321      using bf bg unfolding bilinear_def linear_def
  2.2322      by(auto simp add: span_0 mem_def bilinear_rzero[OF bf] bilinear_rzero[OF bg] span_add Ball_def intro:  bilinear_ladd[OF bf])
  2.2323 @@ -4369,7 +4369,7 @@
  2.2324  qed
  2.2325  
  2.2326  lemma bilinear_eq_stdbasis:
  2.2327 -  assumes bf: "bilinear (f:: 'a::ring_1^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)" 
  2.2328 +  assumes bf: "bilinear (f:: 'a::ring_1^'m \<Rightarrow> 'a^'n \<Rightarrow> 'a^'p)"
  2.2329    and bg: "bilinear g"
  2.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)"
  2.2331    shows "f = g"
  2.2332 @@ -4394,16 +4394,16 @@
  2.2333  proof-
  2.2334    from linear_independent_extend[OF independent_injective_image, OF independent_stdbasis, OF lf fi]
  2.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
  2.2336 -  from h(2) 
  2.2337 +  from h(2)
  2.2338    have th: "\<forall>i\<in>{1..dimindex (UNIV::'n set)}. (h \<circ> f) (basis i) = id (basis i)"
  2.2339      using inv_o_cancel[OF fi, unfolded stupid_ext[symmetric] id_def o_def]
  2.2340      apply auto
  2.2341      apply (erule_tac x="basis i" in allE)
  2.2342      by auto
  2.2343 -  
  2.2344 +
  2.2345    from linear_eq_stdbasis[OF linear_compose[OF lf h(1)] linear_id th]
  2.2346    have "h o f = id" .
  2.2347 -  then show ?thesis using h(1) by blast  
  2.2348 +  then show ?thesis using h(1) by blast
  2.2349  qed
  2.2350  
  2.2351  lemma linear_surjective_right_inverse:
  2.2352 @@ -4411,18 +4411,18 @@
  2.2353    shows "\<exists>g. linear g \<and> f o g = id"
  2.2354  proof-
  2.2355    from linear_independent_extend[OF independent_stdbasis]
  2.2356 -  obtain h:: "real ^'n \<Rightarrow> real ^'m" where 
  2.2357 +  obtain h:: "real ^'n \<Rightarrow> real ^'m" where
  2.2358      h: "linear h" "\<forall> x\<in> {basis i| i. i\<in> {1 .. dimindex (UNIV :: 'n set)}}. h x = inv f x" by blast
  2.2359 -  from h(2) 
  2.2360 +  from h(2)
  2.2361    have th: "\<forall>i\<in>{1..dimindex (UNIV::'n set)}. (f o h) (basis i) = id (basis i)"
  2.2362      using sf
  2.2363      apply (auto simp add: surj_iff o_def stupid_ext[symmetric])
  2.2364      apply (erule_tac x="basis i" in allE)
  2.2365      by auto
  2.2366 -  
  2.2367 +
  2.2368    from linear_eq_stdbasis[OF linear_compose[OF h(1) lf] linear_id th]
  2.2369    have "f o h = id" .
  2.2370 -  then show ?thesis using h(1) by blast  
  2.2371 +  then show ?thesis using h(1) by blast
  2.2372  qed
  2.2373  
  2.2374  lemma matrix_left_invertible_injective:
  2.2375 @@ -4434,7 +4434,7 @@
  2.2376        unfolding matrix_vector_mul_assoc B matrix_vector_mul_lid .}
  2.2377    moreover
  2.2378    {assume A: "\<forall>x y. A *v x = A *v y \<longrightarrow> x = y"
  2.2379 -    hence i: "inj (op *v A)" unfolding inj_on_def by auto 
  2.2380 +    hence i: "inj (op *v A)" unfolding inj_on_def by auto
  2.2381      from linear_injective_left_inverse[OF matrix_vector_mul_linear i]
  2.2382      obtain g where g: "linear g" "g o op *v A = id" by blast
  2.2383      have "matrix g ** A = mat 1"
  2.2384 @@ -4454,25 +4454,25 @@
  2.2385  "(\<exists>B. (A::real^'n^'m) ** (B::real^'m^'n) = mat 1) \<longleftrightarrow> surj (\<lambda>x. A *v x)"
  2.2386  proof-
  2.2387    {fix B :: "real ^'m^'n"  assume AB: "A ** B = mat 1"
  2.2388 -    {fix x :: "real ^ 'm" 
  2.2389 +    {fix x :: "real ^ 'm"
  2.2390        have "A *v (B *v x) = x"
  2.2391  	by (simp add: matrix_vector_mul_lid matrix_vector_mul_assoc AB)}
  2.2392      hence "surj (op *v A)" unfolding surj_def by metis }
  2.2393    moreover
  2.2394    {assume sf: "surj (op *v A)"
  2.2395      from linear_surjective_right_inverse[OF matrix_vector_mul_linear sf]
  2.2396 -    obtain g:: "real ^'m \<Rightarrow> real ^'n" where g: "linear g" "op *v A o g = id" 
  2.2397 +    obtain g:: "real ^'m \<Rightarrow> real ^'n" where g: "linear g" "op *v A o g = id"
  2.2398        by blast
  2.2399  
  2.2400      have "A ** (matrix g) = mat 1"
  2.2401 -      unfolding matrix_eq  matrix_vector_mul_lid 
  2.2402 -	matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)] 
  2.2403 +      unfolding matrix_eq  matrix_vector_mul_lid
  2.2404 +	matrix_vector_mul_assoc[symmetric] matrix_works[OF g(1)]
  2.2405        using g(2) unfolding o_def stupid_ext[symmetric] id_def
  2.2406        .
  2.2407      hence "\<exists>B. A ** (B::real^'m^'n) = mat 1" by blast
  2.2408    }
  2.2409    ultimately show ?thesis unfolding surj_def by blast
  2.2410 -qed    
  2.2411 +qed
  2.2412  
  2.2413  lemma matrix_left_invertible_independent_columns:
  2.2414    fixes A :: "real^'n^'m"
  2.2415 @@ -4481,7 +4481,7 @@
  2.2416  proof-
  2.2417    let ?U = "{1 .. dimindex(UNIV :: 'n set)}"
  2.2418    {assume k: "\<forall>x. A *v x = 0 \<longrightarrow> x = 0"
  2.2419 -    {fix c i assume c: "setsum (\<lambda>i. c i *s column i A) ?U = 0" 
  2.2420 +    {fix c i assume c: "setsum (\<lambda>i. c i *s column i A) ?U = 0"
  2.2421        and i: "i \<in> ?U"
  2.2422        let ?x = "\<chi> i. c i"
  2.2423        have th0:"A *v ?x = 0"
  2.2424 @@ -4493,11 +4493,11 @@
  2.2425      hence ?rhs by blast}
  2.2426    moreover
  2.2427    {assume H: ?rhs
  2.2428 -    {fix x assume x: "A *v x = 0" 
  2.2429 +    {fix x assume x: "A *v x = 0"
  2.2430        let ?c = "\<lambda>i. ((x$i ):: real)"
  2.2431        from H[rule_format, of ?c, unfolded matrix_mult_vsum[symmetric], OF x]
  2.2432        have "x = 0" by vector}}
  2.2433 -  ultimately show ?thesis unfolding matrix_left_invertible_ker by blast 
  2.2434 +  ultimately show ?thesis unfolding matrix_left_invertible_ker by blast
  2.2435  qed
  2.2436  
  2.2437  lemma matrix_right_invertible_independent_rows:
  2.2438 @@ -4514,13 +4514,13 @@
  2.2439    have fU: "finite ?U" by simp
  2.2440    have lhseq: "?lhs \<longleftrightarrow> (\<forall>y. \<exists>(x::real^'m). setsum (\<lambda>i. (x$i) *s column i A) ?U = y)"
  2.2441      unfolding matrix_right_invertible_surjective matrix_mult_vsum surj_def
  2.2442 -    apply (subst eq_commute) ..    
  2.2443 +    apply (subst eq_commute) ..
  2.2444    have rhseq: "?rhs \<longleftrightarrow> (\<forall>x. x \<in> span (columns A))" by blast
  2.2445    {assume h: ?lhs
  2.2446 -    {fix x:: "real ^'n" 
  2.2447 +    {fix x:: "real ^'n"
  2.2448  	from h[unfolded lhseq, rule_format, of x] obtain y:: "real ^'m"
  2.2449  	  where y: "setsum (\<lambda>i. (y$i) *s column i A) ?U = x" by blast
  2.2450 -	have "x \<in> span (columns A)"  
  2.2451 +	have "x \<in> span (columns A)"
  2.2452  	  unfolding y[symmetric]
  2.2453  	  apply (rule span_setsum[OF fU])
  2.2454  	  apply clarify
  2.2455 @@ -4532,21 +4532,21 @@
  2.2456    moreover
  2.2457    {assume h:?rhs
  2.2458      let ?P = "\<lambda>(y::real ^'n). \<exists>(x::real^'m). setsum (\<lambda>i. (x$i) *s column i A) ?U = y"
  2.2459 -    {fix y have "?P y" 
  2.2460 +    {fix y have "?P y"
  2.2461        proof(rule span_induct_alt[of ?P "columns A"])
  2.2462  	show "\<exists>x\<Colon>real ^ 'm. setsum (\<lambda>i. (x$i) *s column i A) ?U = 0"
  2.2463  	  apply (rule exI[where x=0])
  2.2464  	  by (simp add: zero_index vector_smult_lzero)
  2.2465        next
  2.2466  	fix c y1 y2 assume y1: "y1 \<in> columns A" and y2: "?P y2"
  2.2467 -	from y1 obtain i where i: "i \<in> ?U" "y1 = column i A" 
  2.2468 +	from y1 obtain i where i: "i \<in> ?U" "y1 = column i A"
  2.2469  	  unfolding columns_def by blast
  2.2470 -	from y2 obtain x:: "real ^'m" where 
  2.2471 +	from y2 obtain x:: "real ^'m" where
  2.2472  	  x: "setsum (\<lambda>i. (x$i) *s column i A) ?U = y2" by blast
  2.2473  	let ?x = "(\<chi> j. if j = i then c + (x$i) else (x$j))::real^'m"
  2.2474  	show "?P (c*s y1 + y2)"
  2.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])
  2.2476 -	    fix j 
  2.2477 +	    fix j
  2.2478  	    have th: "\<forall>xa \<in> ?U. (if xa = i then (c + (x$i)) * ((column xa A)$j)
  2.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)
  2.2480  	      by (simp add: ring_simps)
  2.2481 @@ -4558,7 +4558,7 @@
  2.2482  	      by (simp add: setsum_addf)
  2.2483  	    also have "\<dots> = c * ((column i A)$j) + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U"
  2.2484  	      unfolding setsum_delta[OF fU]
  2.2485 -	      using i(1) by simp 
  2.2486 +	      using i(1) by simp
  2.2487  	    finally show "setsum (\<lambda>xa. if xa = i then (c + (x$i)) * ((column xa A)$j)
  2.2488             else (x$xa) * ((column xa A$j))) ?U = c * ((column i A)$j) + setsum (\<lambda>xa. ((x$xa) * ((column xa A)$j))) ?U" .
  2.2489  	  qed
  2.2490 @@ -4579,12 +4579,12 @@
  2.2491  (* An injective map real^'n->real^'n is also surjective.                       *)
  2.2492  
  2.2493  lemma linear_injective_imp_surjective:
  2.2494 -  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and fi: "inj f" 
  2.2495 +  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and fi: "inj f"
  2.2496    shows "surj f"
  2.2497  proof-
  2.2498    let ?U = "UNIV :: (real ^'n) set"
  2.2499 -  from basis_exists[of ?U] obtain B 
  2.2500 -    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U" 
  2.2501 +  from basis_exists[of ?U] obtain B
  2.2502 +    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U"
  2.2503      by blast
  2.2504    from B(4) have d: "dim ?U = card B" by (simp add: hassize_def)
  2.2505    have th: "?U \<subseteq> span (f ` B)"
  2.2506 @@ -4604,7 +4604,7 @@
  2.2507  
  2.2508  (* And vice versa.                                                           *)
  2.2509  
  2.2510 -lemma surjective_iff_injective_gen: 
  2.2511 +lemma surjective_iff_injective_gen:
  2.2512    assumes fS: "finite S" and fT: "finite T" and c: "card S = card T"
  2.2513    and ST: "f ` S \<subseteq> T"
  2.2514    shows "(\<forall>y \<in> T. \<exists>x \<in> S. f x = y) \<longleftrightarrow> inj_on f S" (is "?lhs \<longleftrightarrow> ?rhs")
  2.2515 @@ -4641,17 +4641,17 @@
  2.2516  qed
  2.2517  
  2.2518  lemma linear_surjective_imp_injective:
  2.2519 -  assumes lf: "linear (f::real ^'n => real ^'n)" and sf: "surj f" 
  2.2520 +  assumes lf: "linear (f::real ^'n => real ^'n)" and sf: "surj f"
  2.2521    shows "inj f"
  2.2522  proof-
  2.2523    let ?U = "UNIV :: (real ^'n) set"
  2.2524 -  from basis_exists[of ?U] obtain B 
  2.2525 -    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U" 
  2.2526 +  from basis_exists[of ?U] obtain B
  2.2527 +    where B: "B \<subseteq> ?U" "independent B" "?U \<subseteq> span B" "B hassize dim ?U"
  2.2528      by blast
  2.2529    {fix x assume x: "x \<in> span B" and fx: "f x = 0"
  2.2530      from B(4) have fB: "finite B" by (simp add: hassize_def)
  2.2531      from B(4) have d: "dim ?U = card B" by (simp add: hassize_def)
  2.2532 -    have fBi: "independent (f ` B)" 
  2.2533 +    have fBi: "independent (f ` B)"
  2.2534        apply (rule card_le_dim_spanning[of "f ` B" ?U])
  2.2535        apply blast
  2.2536        using sf B(3)
  2.2537 @@ -4676,12 +4676,12 @@
  2.2538      moreover have "card (f ` B) \<le> card B"
  2.2539        by (rule card_image_le, rule fB)
  2.2540      ultimately have th1: "card B = card (f ` B)" unfolding d by arith
  2.2541 -    have fiB: "inj_on f B" 
  2.2542 +    have fiB: "inj_on f B"
  2.2543        unfolding surjective_iff_injective_gen[OF fB finite_imageI[OF fB] th1 subset_refl, symmetric] by blast
  2.2544      from linear_indep_image_lemma[OF lf fB fBi fiB x] fx
  2.2545      have "x = 0" by blast}
  2.2546    note th = this
  2.2547 -  from th show ?thesis unfolding linear_injective_0[OF lf] 
  2.2548 +  from th show ?thesis unfolding linear_injective_0[OF lf]
  2.2549      using B(3) by blast
  2.2550  qed
  2.2551  
  2.2552 @@ -4689,7 +4689,7 @@
  2.2553  
  2.2554  lemma left_right_inverse_eq:
  2.2555    assumes fg: "f o g = id" and gh: "g o h = id"
  2.2556 -  shows "f = h" 
  2.2557 +  shows "f = h"
  2.2558  proof-
  2.2559    have "f = f o (g o h)" unfolding gh by simp
  2.2560    also have "\<dots> = (f o g) o h" by (simp add: o_assoc)
  2.2561 @@ -4723,7 +4723,7 @@
  2.2562    {fix f f':: "real ^'n \<Rightarrow> real ^'n"
  2.2563      assume lf: "linear f" "linear f'" and f: "f o f' = id"
  2.2564      from f have sf: "surj f"
  2.2565 -      
  2.2566 +
  2.2567        apply (auto simp add: o_def stupid_ext[symmetric] id_def surj_def)
  2.2568        by metis
  2.2569      from linear_surjective_isomorphism[OF lf(1) sf] lf f
  2.2570 @@ -4735,13 +4735,13 @@
  2.2571  (* Moreover, a one-sided inverse is automatically linear.                    *)
  2.2572  
  2.2573  lemma left_inverse_linear:
  2.2574 -  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'n)" and gf: "g o f = id" 
  2.2575 +  assumes lf: "linear (f::real ^'n \<Rightarrow> real ^'n)" and gf: "g o f = id"
  2.2576    shows "linear g"
  2.2577  proof-
  2.2578    from gf have fi: "inj f" apply (auto simp add: inj_on_def o_def id_def stupid_ext[symmetric])
  2.2579      by metis
  2.2580 -  from linear_injective_isomorphism[OF lf fi] 
  2.2581 -  obtain h:: "real ^'n \<Rightarrow> real ^'n" where 
  2.2582 +  from linear_injective_isomorphism[OF lf fi]
  2.2583 +  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
  2.2584      h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x" by blast
  2.2585    have "h = g" apply (rule ext) using gf h(2,3)
  2.2586      apply (simp add: o_def id_def stupid_ext[symmetric])
  2.2587 @@ -4750,13 +4750,13 @@
  2.2588  qed
  2.2589  
  2.2590  lemma right_inverse_linear:
  2.2591 -  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and gf: "f o g = id" 
  2.2592 +  assumes lf: "linear (f:: real ^'n \<Rightarrow> real ^'n)" and gf: "f o g = id"
  2.2593    shows "linear g"
  2.2594  proof-
  2.2595    from gf have fi: "surj f" apply (auto simp add: surj_def o_def id_def stupid_ext[symmetric])
  2.2596      by metis
  2.2597 -  from linear_surjective_isomorphism[OF lf fi] 
  2.2598 -  obtain h:: "real ^'n \<Rightarrow> real ^'n" where 
  2.2599 +  from linear_surjective_isomorphism[OF lf fi]
  2.2600 +  obtain h:: "real ^'n \<Rightarrow> real ^'n" where
  2.2601      h: "linear h" "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x" by blast
  2.2602    have "h = g" apply (rule ext) using gf h(2,3)
  2.2603      apply (simp add: o_def id_def stupid_ext[symmetric])
  2.2604 @@ -4767,7 +4767,7 @@
  2.2605  (* The same result in terms of square matrices.                              *)
  2.2606  
  2.2607  lemma matrix_left_right_inverse:
  2.2608 -  fixes A A' :: "real ^'n^'n" 
  2.2609 +  fixes A A' :: "real ^'n^'n"
  2.2610    shows "A ** A' = mat 1 \<longleftrightarrow> A' ** A = mat 1"
  2.2611  proof-
  2.2612    {fix A A' :: "real ^'n^'n" assume AA': "A ** A' = mat 1"
  2.2613 @@ -4779,7 +4779,7 @@
  2.2614      from linear_surjective_isomorphism[OF matrix_vector_mul_linear sA]
  2.2615      obtain f' :: "real ^'n \<Rightarrow> real ^'n"
  2.2616        where f': "linear f'" "\<forall>x. f' (A *v x) = x" "\<forall>x. A *v f' x = x" by blast
  2.2617 -    have th: "matrix f' ** A = mat 1" 
  2.2618 +    have th: "matrix f' ** A = mat 1"
  2.2619        by (simp add: matrix_eq matrix_works[OF f'(1)] matrix_vector_mul_assoc[symmetric] matrix_vector_mul_lid f'(2)[rule_format])
  2.2620      hence "(matrix f' ** A) ** A' = mat 1 ** A'" by simp
  2.2621      hence "matrix f' = A'" by (simp add: matrix_mul_assoc[symmetric] AA' matrix_mul_rid matrix_mul_lid)
  2.2622 @@ -4846,17 +4846,17 @@
  2.2623    have th: "\<And>x y (z::real). x - y <= z \<longleftrightarrow> x - z <= y" by arith
  2.2624    have th1: "\<And>S f. f ` S = { f i| i. i \<in> S}" by blast
  2.2625    have th2: "\<And>x (y::real). abs(x + y) - abs(x) <= abs(y)" by arith
  2.2626 -  show ?thesis 
  2.2627 +  show ?thesis
  2.2628    unfolding infnorm_def
  2.2629    unfolding rsup_finite_le_iff[ OF infnorm_set_lemma]
  2.2630    apply (subst diff_le_eq[symmetric])
  2.2631    unfolding rsup_finite_ge_iff[ OF infnorm_set_lemma]
  2.2632 -  unfolding infnorm_set_image bex_simps 
  2.2633 +  unfolding infnorm_set_image bex_simps
  2.2634    apply (subst th)
  2.2635 -  unfolding th1 
  2.2636 +  unfolding th1
  2.2637    unfolding rsup_finite_ge_iff[ OF infnorm_set_lemma]
  2.2638 -  
  2.2639 -  unfolding infnorm_set_image ball_simps bex_simps 
  2.2640 +
  2.2641 +  unfolding infnorm_set_image ball_simps bex_simps
  2.2642    apply (simp add: vector_add_component)
  2.2643    apply (metis numseg_dimindex_nonempty th2)
  2.2644    done
  2.2645 @@ -4885,7 +4885,7 @@
  2.2646    apply (simp add: vector_component)
  2.2647    done
  2.2648  
  2.2649 -lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)" 
  2.2650 +lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)"
  2.2651  proof-
  2.2652    have "y - x = - (x - y)" by simp
  2.2653    then show ?thesis  by (metis infnorm_neg)
  2.2654 @@ -4896,7 +4896,7 @@
  2.2655    have th: "\<And>(nx::real) n ny. nx <= n + ny \<Longrightarrow> ny <= n + nx ==> \<bar>nx - ny\<bar> <= n"
  2.2656      by arith
  2.2657    from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"]
  2.2658 -  have ths: "infnorm x \<le> infnorm (x - y) + infnorm y" 
  2.2659 +  have ths: "infnorm x \<le> infnorm (x - y) + infnorm y"
  2.2660      "infnorm y \<le> infnorm (x - y) + infnorm x"
  2.2661      by (simp_all add: ring_simps infnorm_neg diff_def[symmetric])
  2.2662    from th[OF ths]  show ?thesis .
  2.2663 @@ -4911,11 +4911,11 @@
  2.2664    let ?U = "{1 .. dimindex (UNIV :: 'n set)}"
  2.2665    let ?S = "{\<bar>x$i\<bar> |i. i\<in> ?U}"
  2.2666    have fS: "finite ?S" unfolding image_Collect[symmetric]
  2.2667 -    apply (rule finite_imageI) unfolding Collect_def mem_def by simp  
  2.2668 +    apply (rule finite_imageI) unfolding Collect_def mem_def by simp
  2.2669    have S0: "?S \<noteq> {}" using numseg_dimindex_nonempty by blast
  2.2670    have th1: "\<And>S f. f ` S = { f i| i. i \<in> S}" by blast
  2.2671    from rsup_finite_in[OF fS S0] rsup_finite_Ub[OF fS S0] i
  2.2672 -  show ?thesis unfolding infnorm_def isUb_def setle_def 
  2.2673 +  show ?thesis unfolding infnorm_def isUb_def setle_def
  2.2674      unfolding infnorm_set_image ball_simps by auto
  2.2675  qed
  2.2676  
  2.2677 @@ -4942,7 +4942,7 @@
  2.2678      have "infnorm x \<le> 1/\<bar>a\<bar> * infnorm (a*s x)"
  2.2679        unfolding th by simp
  2.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)
  2.2681 -    then have "\<bar>a\<bar> * infnorm x \<le> infnorm (a*s x)" 
  2.2682 +    then have "\<bar>a\<bar> * infnorm x \<le> infnorm (a*s x)"
  2.2683        using ap by (simp add: field_simps)
  2.2684      with infnorm_mul_lemma[of a x] have ?thesis by arith }
  2.2685    ultimately show ?thesis by blast
  2.2686 @@ -4954,7 +4954,7 @@
  2.2687  (* Prove that it differs only up to a bound from Euclidean norm.             *)
  2.2688  
  2.2689  lemma infnorm_le_norm: "infnorm x \<le> norm x"
  2.2690 -  unfolding infnorm_def rsup_finite_le_iff[OF infnorm_set_lemma] 
  2.2691 +  unfolding infnorm_def rsup_finite_le_iff[OF infnorm_set_lemma]
  2.2692    unfolding infnorm_set_image  ball_simps
  2.2693    by (metis component_le_norm)
  2.2694  lemma card_enum: "card {1 .. n} = n" by auto
  2.2695 @@ -4968,20 +4968,20 @@
  2.2696    have th: "sqrt (real ?d) * infnorm x \<ge> 0"
  2.2697      by (simp add: dimindex_ge_1 zero_le_mult_iff real_sqrt_ge_0_iff infnorm_pos_le)
  2.2698    have th1: "x\<bullet>x \<le> (sqrt (real ?d) * infnorm x)^2"
  2.2699 -    unfolding power_mult_distrib d2 
  2.2700 +    unfolding power_mult_distrib d2
  2.2701      apply (subst d)
  2.2702      apply (subst power2_abs[symmetric])
  2.2703      unfolding real_of_nat_def dot_def power2_eq_square[symmetric]
  2.2704      apply (subst power2_abs[symmetric])
  2.2705      apply (rule setsum_bounded)
  2.2706      apply (rule power_mono)
  2.2707 -    unfolding abs_of_nonneg[OF infnorm_pos_le] 
  2.2708 +    unfolding abs_of_nonneg[OF infnorm_pos_le]
  2.2709      unfolding infnorm_def  rsup_finite_ge_iff[OF infnorm_set_lemma]
  2.2710      unfolding infnorm_set_image bex_simps
  2.2711      apply blast
  2.2712      by (rule abs_ge_zero)
  2.2713    from real_le_lsqrt[OF dot_pos_le th th1]
  2.2714 -  show ?thesis unfolding real_vector_norm_def id_def . 
  2.2715 +  show ?thesis unfolding real_vector_norm_def id_def .
  2.2716  qed
  2.2717  
  2.2718  (* Equality in Cauchy-Schwarz and triangle inequalities.                     *)
  2.2719 @@ -5037,7 +5037,7 @@
  2.2720    {assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
  2.2721      hence "norm x \<noteq> 0" "norm y \<noteq> 0"
  2.2722        by simp_all
  2.2723 -    hence n: "norm x > 0" "norm y > 0" 
  2.2724 +    hence n: "norm x > 0" "norm y > 0"
  2.2725        using norm_ge_zero[of x] norm_ge_zero[of y]
  2.2726        by arith+
  2.2727      have th: "\<And>(a::real) b c. a + b + c \<noteq> 0 ==> (a = b + c \<longleftrightarrow> a^2 = (b + c)^2)" by algebra
  2.2728 @@ -5058,7 +5058,7 @@
  2.2729  
  2.2730  lemma collinear_empty:  "collinear {}" by (simp add: collinear_def)
  2.2731  
  2.2732 -lemma collinear_sing: "collinear {(x::'a::ring_1^'n)}" 
  2.2733 +lemma collinear_sing: "collinear {(x::'a::ring_1^'n)}"
  2.2734    apply (simp add: collinear_def)
  2.2735    apply (rule exI[where x=0])
  2.2736    by simp
  2.2737 @@ -5075,20 +5075,20 @@
  2.2738  
  2.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")
  2.2740  proof-
  2.2741 -  {assume "x=0 \<or> y = 0" hence ?thesis 
  2.2742 +  {assume "x=0 \<or> y = 0" hence ?thesis
  2.2743        by (cases "x = 0", simp_all add: collinear_2 insert_commute)}
  2.2744    moreover
  2.2745    {assume x: "x \<noteq> 0" and y: "y \<noteq> 0"
  2.2746      {assume h: "?lhs"
  2.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
  2.2748        from u[rule_format, of x 0] u[rule_format, of y 0]
  2.2749 -      obtain cx and cy where 
  2.2750 +      obtain cx and cy where
  2.2751  	cx: "x = cx*s u" and cy: "y = cy*s u"
  2.2752  	by auto
  2.2753        from cx x have cx0: "cx \<noteq> 0" by auto
  2.2754        from cy y have cy0: "cy \<noteq> 0" by auto
  2.2755        let ?d = "cy / cx"
  2.2756 -      from cx cy cx0 have "y = ?d *s x" 
  2.2757 +      from cx cy cx0 have "y = ?d *s x"
  2.2758  	by (simp add: vector_smult_assoc)
  2.2759        hence ?rhs using x y by blast}
  2.2760      moreover