src/HOL/Multivariate_Analysis/Linear_Algebra.thy
 author huffman Thu Sep 12 18:09:17 2013 -0700 (2013-09-12) changeset 53600 8fda7ad57466 parent 53596 d29d63460d84 child 53716 b42d9a71fc1a permissions -rw-r--r--
make 'linear' into a sublocale of 'bounded_linear';
replace 'linear_def' with 'linear_iff'
 huffman@44133 ` 1` ```(* Title: HOL/Multivariate_Analysis/Linear_Algebra.thy ``` huffman@44133 ` 2` ``` Author: Amine Chaieb, University of Cambridge ``` huffman@44133 ` 3` ```*) ``` huffman@44133 ` 4` huffman@44133 ` 5` ```header {* Elementary linear algebra on Euclidean spaces *} ``` huffman@44133 ` 6` huffman@44133 ` 7` ```theory Linear_Algebra ``` huffman@44133 ` 8` ```imports ``` huffman@44133 ` 9` ``` Euclidean_Space ``` huffman@44133 ` 10` ``` "~~/src/HOL/Library/Infinite_Set" ``` huffman@44133 ` 11` ```begin ``` huffman@44133 ` 12` huffman@44133 ` 13` ```lemma cond_application_beta: "(if b then f else g) x = (if b then f x else g x)" ``` huffman@44133 ` 14` ``` by auto ``` huffman@44133 ` 15` huffman@44133 ` 16` ```notation inner (infix "\" 70) ``` huffman@44133 ` 17` huffman@44133 ` 18` ```lemma square_bound_lemma: "(x::real) < (1 + x) * (1 + x)" ``` wenzelm@49522 ` 19` ```proof - ``` wenzelm@53406 ` 20` ``` have "(x + 1/2)\<^sup>2 + 3/4 > 0" ``` wenzelm@53406 ` 21` ``` using zero_le_power2[of "x+1/2"] by arith ``` wenzelm@53406 ` 22` ``` then show ?thesis ``` wenzelm@53406 ` 23` ``` by (simp add: field_simps power2_eq_square) ``` huffman@44133 ` 24` ```qed ``` huffman@44133 ` 25` wenzelm@53406 ` 26` ```lemma square_continuous: ``` wenzelm@53406 ` 27` ``` fixes e :: real ``` wenzelm@53406 ` 28` ``` shows "e > 0 \ \d. 0 < d \ (\y. abs (y - x) < d \ abs (y * y - x * x) < e)" ``` hoelzl@51478 ` 29` ``` using isCont_power[OF isCont_ident, of x, unfolded isCont_def LIM_eq, rule_format, of e 2] ``` wenzelm@49522 ` 30` ``` apply (auto simp add: power2_eq_square) ``` huffman@44133 ` 31` ``` apply (rule_tac x="s" in exI) ``` huffman@44133 ` 32` ``` apply auto ``` huffman@44133 ` 33` ``` apply (erule_tac x=y in allE) ``` huffman@44133 ` 34` ``` apply auto ``` huffman@44133 ` 35` ``` done ``` huffman@44133 ` 36` wenzelm@53406 ` 37` ```lemma real_le_lsqrt: "0 \ x \ 0 \ y \ x \ y\<^sup>2 \ sqrt x \ y" ``` wenzelm@53077 ` 38` ``` using real_sqrt_le_iff[of x "y\<^sup>2"] by simp ``` wenzelm@53077 ` 39` wenzelm@53077 ` 40` ```lemma real_le_rsqrt: "x\<^sup>2 \ y \ x \ sqrt y" ``` wenzelm@53077 ` 41` ``` using real_sqrt_le_mono[of "x\<^sup>2" y] by simp ``` wenzelm@53077 ` 42` wenzelm@53077 ` 43` ```lemma real_less_rsqrt: "x\<^sup>2 < y \ x < sqrt y" ``` wenzelm@53077 ` 44` ``` using real_sqrt_less_mono[of "x\<^sup>2" y] by simp ``` huffman@44133 ` 45` wenzelm@49522 ` 46` ```lemma sqrt_even_pow2: ``` wenzelm@49522 ` 47` ``` assumes n: "even n" ``` wenzelm@53406 ` 48` ``` shows "sqrt (2 ^ n) = 2 ^ (n div 2)" ``` wenzelm@49522 ` 49` ```proof - ``` wenzelm@53406 ` 50` ``` from n obtain m where m: "n = 2 * m" ``` wenzelm@53406 ` 51` ``` unfolding even_mult_two_ex .. ``` wenzelm@53406 ` 52` ``` from m have "sqrt (2 ^ n) = sqrt ((2 ^ m)\<^sup>2)" ``` huffman@44133 ` 53` ``` by (simp only: power_mult[symmetric] mult_commute) ``` wenzelm@53406 ` 54` ``` then show ?thesis ``` wenzelm@53406 ` 55` ``` using m by simp ``` huffman@44133 ` 56` ```qed ``` huffman@44133 ` 57` wenzelm@53406 ` 58` ```lemma real_div_sqrt: "0 \ x \ x / sqrt x = sqrt x" ``` wenzelm@53406 ` 59` ``` apply (cases "x = 0") ``` wenzelm@53406 ` 60` ``` apply simp_all ``` huffman@44133 ` 61` ``` using sqrt_divide_self_eq[of x] ``` huffman@44133 ` 62` ``` apply (simp add: inverse_eq_divide field_simps) ``` huffman@44133 ` 63` ``` done ``` huffman@44133 ` 64` huffman@44133 ` 65` ```text{* Hence derive more interesting properties of the norm. *} ``` huffman@44133 ` 66` wenzelm@53406 ` 67` ```lemma norm_eq_0_dot: "norm x = 0 \ x \ x = (0::real)" ``` huffman@44666 ` 68` ``` by simp (* TODO: delete *) ``` huffman@44133 ` 69` wenzelm@53406 ` 70` ```lemma norm_cauchy_schwarz: "x \ y \ norm x * norm y" ``` huffman@44666 ` 71` ``` (* TODO: move to Inner_Product.thy *) ``` huffman@44133 ` 72` ``` using Cauchy_Schwarz_ineq2[of x y] by auto ``` huffman@44133 ` 73` huffman@44133 ` 74` ```lemma norm_triangle_sub: ``` huffman@44133 ` 75` ``` fixes x y :: "'a::real_normed_vector" ``` wenzelm@53406 ` 76` ``` shows "norm x \ norm y + norm (x - y)" ``` huffman@44133 ` 77` ``` using norm_triangle_ineq[of "y" "x - y"] by (simp add: field_simps) ``` huffman@44133 ` 78` wenzelm@53406 ` 79` ```lemma norm_le: "norm x \ norm y \ x \ x \ y \ y" ``` huffman@44133 ` 80` ``` by (simp add: norm_eq_sqrt_inner) ``` huffman@44666 ` 81` wenzelm@53406 ` 82` ```lemma norm_lt: "norm x < norm y \ x \ x < y \ y" ``` wenzelm@53406 ` 83` ``` by (simp add: norm_eq_sqrt_inner) ``` wenzelm@53406 ` 84` wenzelm@53406 ` 85` ```lemma norm_eq: "norm x = norm y \ x \ x = y \ y" ``` wenzelm@49522 ` 86` ``` apply (subst order_eq_iff) ``` wenzelm@49522 ` 87` ``` apply (auto simp: norm_le) ``` wenzelm@49522 ` 88` ``` done ``` huffman@44666 ` 89` wenzelm@53406 ` 90` ```lemma norm_eq_1: "norm x = 1 \ x \ x = 1" ``` huffman@44666 ` 91` ``` by (simp add: norm_eq_sqrt_inner) ``` huffman@44133 ` 92` huffman@44133 ` 93` ```text{* Squaring equations and inequalities involving norms. *} ``` huffman@44133 ` 94` wenzelm@53077 ` 95` ```lemma dot_square_norm: "x \ x = (norm x)\<^sup>2" ``` huffman@44666 ` 96` ``` by (simp only: power2_norm_eq_inner) (* TODO: move? *) ``` huffman@44133 ` 97` wenzelm@53406 ` 98` ```lemma norm_eq_square: "norm x = a \ 0 \ a \ x \ x = a\<^sup>2" ``` huffman@44133 ` 99` ``` by (auto simp add: norm_eq_sqrt_inner) ``` huffman@44133 ` 100` wenzelm@53077 ` 101` ```lemma real_abs_le_square_iff: "\x\ \ \y\ \ (x::real)\<^sup>2 \ y\<^sup>2" ``` huffman@44133 ` 102` ```proof ``` huffman@44133 ` 103` ``` assume "\x\ \ \y\" ``` wenzelm@53015 ` 104` ``` then have "\x\\<^sup>2 \ \y\\<^sup>2" by (rule power_mono, simp) ``` wenzelm@53015 ` 105` ``` then show "x\<^sup>2 \ y\<^sup>2" by simp ``` huffman@44133 ` 106` ```next ``` wenzelm@53015 ` 107` ``` assume "x\<^sup>2 \ y\<^sup>2" ``` wenzelm@53015 ` 108` ``` then have "sqrt (x\<^sup>2) \ sqrt (y\<^sup>2)" by (rule real_sqrt_le_mono) ``` huffman@44133 ` 109` ``` then show "\x\ \ \y\" by simp ``` huffman@44133 ` 110` ```qed ``` huffman@44133 ` 111` wenzelm@53406 ` 112` ```lemma norm_le_square: "norm x \ a \ 0 \ a \ x \ x \ a\<^sup>2" ``` huffman@44133 ` 113` ``` apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric]) ``` huffman@44133 ` 114` ``` using norm_ge_zero[of x] ``` huffman@44133 ` 115` ``` apply arith ``` huffman@44133 ` 116` ``` done ``` huffman@44133 ` 117` wenzelm@53406 ` 118` ```lemma norm_ge_square: "norm x \ a \ a \ 0 \ x \ x \ a\<^sup>2" ``` huffman@44133 ` 119` ``` apply (simp add: dot_square_norm real_abs_le_square_iff[symmetric]) ``` huffman@44133 ` 120` ``` using norm_ge_zero[of x] ``` huffman@44133 ` 121` ``` apply arith ``` huffman@44133 ` 122` ``` done ``` huffman@44133 ` 123` wenzelm@53077 ` 124` ```lemma norm_lt_square: "norm(x) < a \ 0 < a \ x \ x < a\<^sup>2" ``` huffman@44133 ` 125` ``` by (metis not_le norm_ge_square) ``` wenzelm@53406 ` 126` wenzelm@53077 ` 127` ```lemma norm_gt_square: "norm(x) > a \ a < 0 \ x \ x > a\<^sup>2" ``` huffman@44133 ` 128` ``` by (metis norm_le_square not_less) ``` huffman@44133 ` 129` huffman@44133 ` 130` ```text{* Dot product in terms of the norm rather than conversely. *} ``` huffman@44133 ` 131` wenzelm@53406 ` 132` ```lemmas inner_simps = inner_add_left inner_add_right inner_diff_right inner_diff_left ``` wenzelm@49522 ` 133` ``` inner_scaleR_left inner_scaleR_right ``` huffman@44133 ` 134` wenzelm@53077 ` 135` ```lemma dot_norm: "x \ y = ((norm (x + y))\<^sup>2 - (norm x)\<^sup>2 - (norm y)\<^sup>2) / 2" ``` wenzelm@53406 ` 136` ``` unfolding power2_norm_eq_inner inner_simps inner_commute by auto ``` huffman@44133 ` 137` wenzelm@53077 ` 138` ```lemma dot_norm_neg: "x \ y = (((norm x)\<^sup>2 + (norm y)\<^sup>2) - (norm (x - y))\<^sup>2) / 2" ``` wenzelm@49525 ` 139` ``` unfolding power2_norm_eq_inner inner_simps inner_commute ``` wenzelm@49525 ` 140` ``` by (auto simp add: algebra_simps) ``` huffman@44133 ` 141` huffman@44133 ` 142` ```text{* Equality of vectors in terms of @{term "op \"} products. *} ``` huffman@44133 ` 143` wenzelm@53406 ` 144` ```lemma vector_eq: "x = y \ x \ x = x \ y \ y \ y = x \ x" ``` wenzelm@53406 ` 145` ``` (is "?lhs \ ?rhs") ``` huffman@44133 ` 146` ```proof ``` wenzelm@49652 ` 147` ``` assume ?lhs ``` wenzelm@49652 ` 148` ``` then show ?rhs by simp ``` huffman@44133 ` 149` ```next ``` huffman@44133 ` 150` ``` assume ?rhs ``` wenzelm@53406 ` 151` ``` then have "x \ x - x \ y = 0 \ x \ y - y \ y = 0" ``` wenzelm@53406 ` 152` ``` by simp ``` wenzelm@53406 ` 153` ``` then have "x \ (x - y) = 0 \ y \ (x - y) = 0" ``` wenzelm@53406 ` 154` ``` by (simp add: inner_diff inner_commute) ``` wenzelm@53406 ` 155` ``` then have "(x - y) \ (x - y) = 0" ``` wenzelm@53406 ` 156` ``` by (simp add: field_simps inner_diff inner_commute) ``` wenzelm@53406 ` 157` ``` then show "x = y" by simp ``` huffman@44133 ` 158` ```qed ``` huffman@44133 ` 159` huffman@44133 ` 160` ```lemma norm_triangle_half_r: ``` wenzelm@53406 ` 161` ``` "norm (y - x1) < e / 2 \ norm (y - x2) < e / 2 \ norm (x1 - x2) < e" ``` wenzelm@53406 ` 162` ``` using dist_triangle_half_r unfolding dist_norm[symmetric] by auto ``` huffman@44133 ` 163` wenzelm@49522 ` 164` ```lemma norm_triangle_half_l: ``` wenzelm@53406 ` 165` ``` assumes "norm (x - y) < e / 2" ``` wenzelm@53406 ` 166` ``` and "norm (x' - (y)) < e / 2" ``` huffman@44133 ` 167` ``` shows "norm (x - x') < e" ``` wenzelm@53406 ` 168` ``` using dist_triangle_half_l[OF assms[unfolded dist_norm[symmetric]]] ``` wenzelm@53406 ` 169` ``` unfolding dist_norm[symmetric] . ``` wenzelm@53406 ` 170` wenzelm@53406 ` 171` ```lemma norm_triangle_le: "norm x + norm y \ e \ norm (x + y) \ e" ``` huffman@44666 ` 172` ``` by (rule norm_triangle_ineq [THEN order_trans]) ``` huffman@44133 ` 173` wenzelm@53406 ` 174` ```lemma norm_triangle_lt: "norm x + norm y < e \ norm (x + y) < e" ``` huffman@44666 ` 175` ``` by (rule norm_triangle_ineq [THEN le_less_trans]) ``` huffman@44133 ` 176` huffman@44133 ` 177` ```lemma setsum_clauses: ``` huffman@44133 ` 178` ``` shows "setsum f {} = 0" ``` wenzelm@49525 ` 179` ``` and "finite S \ setsum f (insert x S) = (if x \ S then setsum f S else f x + setsum f S)" ``` huffman@44133 ` 180` ``` by (auto simp add: insert_absorb) ``` huffman@44133 ` 181` huffman@44133 ` 182` ```lemma setsum_norm_le: ``` huffman@44133 ` 183` ``` fixes f :: "'a \ 'b::real_normed_vector" ``` huffman@44176 ` 184` ``` assumes fg: "\x \ S. norm (f x) \ g x" ``` huffman@44133 ` 185` ``` shows "norm (setsum f S) \ setsum g S" ``` wenzelm@49522 ` 186` ``` by (rule order_trans [OF norm_setsum setsum_mono]) (simp add: fg) ``` huffman@44133 ` 187` huffman@44133 ` 188` ```lemma setsum_norm_bound: ``` huffman@44133 ` 189` ``` fixes f :: "'a \ 'b::real_normed_vector" ``` huffman@44133 ` 190` ``` assumes fS: "finite S" ``` wenzelm@49522 ` 191` ``` and K: "\x \ S. norm (f x) \ K" ``` huffman@44133 ` 192` ``` shows "norm (setsum f S) \ of_nat (card S) * K" ``` huffman@44176 ` 193` ``` using setsum_norm_le[OF K] setsum_constant[symmetric] ``` huffman@44133 ` 194` ``` by simp ``` huffman@44133 ` 195` huffman@44133 ` 196` ```lemma setsum_group: ``` huffman@44133 ` 197` ``` assumes fS: "finite S" and fT: "finite T" and fST: "f ` S \ T" ``` huffman@44133 ` 198` ``` shows "setsum (\y. setsum g {x. x\ S \ f x = y}) T = setsum g S" ``` huffman@44133 ` 199` ``` apply (subst setsum_image_gen[OF fS, of g f]) ``` huffman@44133 ` 200` ``` apply (rule setsum_mono_zero_right[OF fT fST]) ``` wenzelm@49522 ` 201` ``` apply (auto intro: setsum_0') ``` wenzelm@49522 ` 202` ``` done ``` huffman@44133 ` 203` huffman@44133 ` 204` ```lemma vector_eq_ldot: "(\x. x \ y = x \ z) \ y = z" ``` huffman@44133 ` 205` ```proof ``` huffman@44133 ` 206` ``` assume "\x. x \ y = x \ z" ``` wenzelm@53406 ` 207` ``` then have "\x. x \ (y - z) = 0" ``` wenzelm@53406 ` 208` ``` by (simp add: inner_diff) ``` wenzelm@49522 ` 209` ``` then have "(y - z) \ (y - z) = 0" .. ``` wenzelm@49652 ` 210` ``` then show "y = z" by simp ``` huffman@44133 ` 211` ```qed simp ``` huffman@44133 ` 212` huffman@44133 ` 213` ```lemma vector_eq_rdot: "(\z. x \ z = y \ z) \ x = y" ``` huffman@44133 ` 214` ```proof ``` huffman@44133 ` 215` ``` assume "\z. x \ z = y \ z" ``` wenzelm@53406 ` 216` ``` then have "\z. (x - y) \ z = 0" ``` wenzelm@53406 ` 217` ``` by (simp add: inner_diff) ``` wenzelm@49522 ` 218` ``` then have "(x - y) \ (x - y) = 0" .. ``` wenzelm@49652 ` 219` ``` then show "x = y" by simp ``` huffman@44133 ` 220` ```qed simp ``` huffman@44133 ` 221` wenzelm@49522 ` 222` wenzelm@49522 ` 223` ```subsection {* Orthogonality. *} ``` huffman@44133 ` 224` huffman@44133 ` 225` ```context real_inner ``` huffman@44133 ` 226` ```begin ``` huffman@44133 ` 227` huffman@44133 ` 228` ```definition "orthogonal x y \ (x \ y = 0)" ``` huffman@44133 ` 229` huffman@44133 ` 230` ```lemma orthogonal_clauses: ``` huffman@44133 ` 231` ``` "orthogonal a 0" ``` huffman@44133 ` 232` ``` "orthogonal a x \ orthogonal a (c *\<^sub>R x)" ``` huffman@44133 ` 233` ``` "orthogonal a x \ orthogonal a (-x)" ``` huffman@44133 ` 234` ``` "orthogonal a x \ orthogonal a y \ orthogonal a (x + y)" ``` huffman@44133 ` 235` ``` "orthogonal a x \ orthogonal a y \ orthogonal a (x - y)" ``` huffman@44133 ` 236` ``` "orthogonal 0 a" ``` huffman@44133 ` 237` ``` "orthogonal x a \ orthogonal (c *\<^sub>R x) a" ``` huffman@44133 ` 238` ``` "orthogonal x a \ orthogonal (-x) a" ``` huffman@44133 ` 239` ``` "orthogonal x a \ orthogonal y a \ orthogonal (x + y) a" ``` huffman@44133 ` 240` ``` "orthogonal x a \ orthogonal y a \ orthogonal (x - y) a" ``` huffman@44666 ` 241` ``` unfolding orthogonal_def inner_add inner_diff by auto ``` huffman@44666 ` 242` huffman@44133 ` 243` ```end ``` huffman@44133 ` 244` huffman@44133 ` 245` ```lemma orthogonal_commute: "orthogonal x y \ orthogonal y x" ``` huffman@44133 ` 246` ``` by (simp add: orthogonal_def inner_commute) ``` huffman@44133 ` 247` wenzelm@49522 ` 248` wenzelm@49522 ` 249` ```subsection {* Linear functions. *} ``` wenzelm@49522 ` 250` huffman@53600 ` 251` ```lemma linear_iff: ``` huffman@53600 ` 252` ``` "linear f \ (\x y. f(x + y) = f x + f y) \ (\c x. f(c *\<^sub>R x) = c *\<^sub>R f x)" ``` huffman@53600 ` 253` ``` (is "linear f \ ?rhs") ``` huffman@53600 ` 254` ```proof ``` huffman@53600 ` 255` ``` assume "linear f" then interpret f: linear f . ``` huffman@53600 ` 256` ``` show "?rhs" by (simp add: f.add f.scaleR) ``` huffman@53600 ` 257` ```next ``` huffman@53600 ` 258` ``` assume "?rhs" then show "linear f" by unfold_locales simp_all ``` huffman@53600 ` 259` ```qed ``` huffman@44133 ` 260` wenzelm@53406 ` 261` ```lemma linear_compose_cmul: "linear f \ linear (\x. c *\<^sub>R f x)" ``` huffman@53600 ` 262` ``` by (simp add: linear_iff algebra_simps) ``` huffman@44133 ` 263` wenzelm@53406 ` 264` ```lemma linear_compose_neg: "linear f \ linear (\x. - f x)" ``` huffman@53600 ` 265` ``` by (simp add: linear_iff) ``` huffman@44133 ` 266` wenzelm@53406 ` 267` ```lemma linear_compose_add: "linear f \ linear g \ linear (\x. f x + g x)" ``` huffman@53600 ` 268` ``` by (simp add: linear_iff algebra_simps) ``` huffman@44133 ` 269` wenzelm@53406 ` 270` ```lemma linear_compose_sub: "linear f \ linear g \ linear (\x. f x - g x)" ``` huffman@53600 ` 271` ``` by (simp add: linear_iff algebra_simps) ``` huffman@44133 ` 272` wenzelm@53406 ` 273` ```lemma linear_compose: "linear f \ linear g \ linear (g \ f)" ``` huffman@53600 ` 274` ``` by (simp add: linear_iff) ``` huffman@44133 ` 275` wenzelm@53406 ` 276` ```lemma linear_id: "linear id" ``` huffman@53600 ` 277` ``` by (simp add: linear_iff id_def) ``` wenzelm@53406 ` 278` wenzelm@53406 ` 279` ```lemma linear_zero: "linear (\x. 0)" ``` huffman@53600 ` 280` ``` by (simp add: linear_iff) ``` huffman@44133 ` 281` huffman@44133 ` 282` ```lemma linear_compose_setsum: ``` wenzelm@53406 ` 283` ``` assumes fS: "finite S" ``` wenzelm@53406 ` 284` ``` and lS: "\a \ S. linear (f a)" ``` huffman@44133 ` 285` ``` shows "linear(\x. setsum (\a. f a x) S)" ``` huffman@44133 ` 286` ``` using lS ``` huffman@44133 ` 287` ``` apply (induct rule: finite_induct[OF fS]) ``` wenzelm@49522 ` 288` ``` apply (auto simp add: linear_zero intro: linear_compose_add) ``` wenzelm@49522 ` 289` ``` done ``` huffman@44133 ` 290` huffman@44133 ` 291` ```lemma linear_0: "linear f \ f 0 = 0" ``` huffman@53600 ` 292` ``` unfolding linear_iff ``` huffman@44133 ` 293` ``` apply clarsimp ``` huffman@44133 ` 294` ``` apply (erule allE[where x="0::'a"]) ``` huffman@44133 ` 295` ``` apply simp ``` huffman@44133 ` 296` ``` done ``` huffman@44133 ` 297` wenzelm@53406 ` 298` ```lemma linear_cmul: "linear f \ f (c *\<^sub>R x) = c *\<^sub>R f x" ``` huffman@53600 ` 299` ``` by (simp add: linear_iff) ``` huffman@44133 ` 300` wenzelm@53406 ` 301` ```lemma linear_neg: "linear f \ f (- x) = - f x" ``` huffman@44133 ` 302` ``` using linear_cmul [where c="-1"] by simp ``` huffman@44133 ` 303` wenzelm@53406 ` 304` ```lemma linear_add: "linear f \ f(x + y) = f x + f y" ``` huffman@53600 ` 305` ``` by (metis linear_iff) ``` huffman@44133 ` 306` wenzelm@53406 ` 307` ```lemma linear_sub: "linear f \ f(x - y) = f x - f y" ``` huffman@44133 ` 308` ``` by (simp add: diff_minus linear_add linear_neg) ``` huffman@44133 ` 309` huffman@44133 ` 310` ```lemma linear_setsum: ``` wenzelm@53406 ` 311` ``` assumes lin: "linear f" ``` wenzelm@53406 ` 312` ``` and fin: "finite S" ``` wenzelm@53406 ` 313` ``` shows "f (setsum g S) = setsum (f \ g) S" ``` wenzelm@53406 ` 314` ``` using fin ``` wenzelm@53406 ` 315` ```proof induct ``` wenzelm@49522 ` 316` ``` case empty ``` wenzelm@53406 ` 317` ``` then show ?case ``` wenzelm@53406 ` 318` ``` by (simp add: linear_0[OF lin]) ``` huffman@44133 ` 319` ```next ``` wenzelm@49522 ` 320` ``` case (insert x F) ``` wenzelm@53406 ` 321` ``` have "f (setsum g (insert x F)) = f (g x + setsum g F)" ``` wenzelm@53406 ` 322` ``` using insert.hyps by simp ``` wenzelm@53406 ` 323` ``` also have "\ = f (g x) + f (setsum g F)" ``` wenzelm@53406 ` 324` ``` using linear_add[OF lin] by simp ``` wenzelm@53406 ` 325` ``` also have "\ = setsum (f \ g) (insert x F)" ``` wenzelm@53406 ` 326` ``` using insert.hyps by simp ``` huffman@44133 ` 327` ``` finally show ?case . ``` huffman@44133 ` 328` ```qed ``` huffman@44133 ` 329` huffman@44133 ` 330` ```lemma linear_setsum_mul: ``` wenzelm@53406 ` 331` ``` assumes lin: "linear f" ``` wenzelm@53406 ` 332` ``` and fin: "finite S" ``` huffman@44133 ` 333` ``` shows "f (setsum (\i. c i *\<^sub>R v i) S) = setsum (\i. c i *\<^sub>R f (v i)) S" ``` wenzelm@53406 ` 334` ``` using linear_setsum[OF lin fin, of "\i. c i *\<^sub>R v i" , unfolded o_def] linear_cmul[OF lin] ``` wenzelm@49522 ` 335` ``` by simp ``` huffman@44133 ` 336` huffman@44133 ` 337` ```lemma linear_injective_0: ``` wenzelm@53406 ` 338` ``` assumes lin: "linear f" ``` huffman@44133 ` 339` ``` shows "inj f \ (\x. f x = 0 \ x = 0)" ``` wenzelm@49663 ` 340` ```proof - ``` wenzelm@53406 ` 341` ``` have "inj f \ (\ x y. f x = f y \ x = y)" ``` wenzelm@53406 ` 342` ``` by (simp add: inj_on_def) ``` wenzelm@53406 ` 343` ``` also have "\ \ (\ x y. f x - f y = 0 \ x - y = 0)" ``` wenzelm@53406 ` 344` ``` by simp ``` huffman@44133 ` 345` ``` also have "\ \ (\ x y. f (x - y) = 0 \ x - y = 0)" ``` wenzelm@53406 ` 346` ``` by (simp add: linear_sub[OF lin]) ``` wenzelm@53406 ` 347` ``` also have "\ \ (\ x. f x = 0 \ x = 0)" ``` wenzelm@53406 ` 348` ``` by auto ``` huffman@44133 ` 349` ``` finally show ?thesis . ``` huffman@44133 ` 350` ```qed ``` huffman@44133 ` 351` wenzelm@49522 ` 352` wenzelm@49522 ` 353` ```subsection {* Bilinear functions. *} ``` huffman@44133 ` 354` wenzelm@53406 ` 355` ```definition "bilinear f \ (\x. linear (\y. f x y)) \ (\y. linear (\x. f x y))" ``` wenzelm@53406 ` 356` wenzelm@53406 ` 357` ```lemma bilinear_ladd: "bilinear h \ h (x + y) z = h x z + h y z" ``` huffman@53600 ` 358` ``` by (simp add: bilinear_def linear_iff) ``` wenzelm@49663 ` 359` wenzelm@53406 ` 360` ```lemma bilinear_radd: "bilinear h \ h x (y + z) = h x y + h x z" ``` huffman@53600 ` 361` ``` by (simp add: bilinear_def linear_iff) ``` huffman@44133 ` 362` wenzelm@53406 ` 363` ```lemma bilinear_lmul: "bilinear h \ h (c *\<^sub>R x) y = c *\<^sub>R h x y" ``` huffman@53600 ` 364` ``` by (simp add: bilinear_def linear_iff) ``` huffman@44133 ` 365` wenzelm@53406 ` 366` ```lemma bilinear_rmul: "bilinear h \ h x (c *\<^sub>R y) = c *\<^sub>R h x y" ``` huffman@53600 ` 367` ``` by (simp add: bilinear_def linear_iff) ``` huffman@44133 ` 368` wenzelm@53406 ` 369` ```lemma bilinear_lneg: "bilinear h \ h (- x) y = - h x y" ``` huffman@44133 ` 370` ``` by (simp only: scaleR_minus1_left [symmetric] bilinear_lmul) ``` huffman@44133 ` 371` wenzelm@53406 ` 372` ```lemma bilinear_rneg: "bilinear h \ h x (- y) = - h x y" ``` huffman@44133 ` 373` ``` by (simp only: scaleR_minus1_left [symmetric] bilinear_rmul) ``` huffman@44133 ` 374` wenzelm@53406 ` 375` ```lemma (in ab_group_add) eq_add_iff: "x = x + y \ y = 0" ``` huffman@44133 ` 376` ``` using add_imp_eq[of x y 0] by auto ``` huffman@44133 ` 377` wenzelm@53406 ` 378` ```lemma bilinear_lzero: ``` wenzelm@53406 ` 379` ``` assumes "bilinear h" ``` wenzelm@53406 ` 380` ``` shows "h 0 x = 0" ``` wenzelm@49663 ` 381` ``` using bilinear_ladd [OF assms, of 0 0 x] by (simp add: eq_add_iff field_simps) ``` wenzelm@49663 ` 382` wenzelm@53406 ` 383` ```lemma bilinear_rzero: ``` wenzelm@53406 ` 384` ``` assumes "bilinear h" ``` wenzelm@53406 ` 385` ``` shows "h x 0 = 0" ``` wenzelm@49663 ` 386` ``` using bilinear_radd [OF assms, of x 0 0 ] by (simp add: eq_add_iff field_simps) ``` huffman@44133 ` 387` wenzelm@53406 ` 388` ```lemma bilinear_lsub: "bilinear h \ h (x - y) z = h x z - h y z" ``` huffman@44133 ` 389` ``` by (simp add: diff_minus bilinear_ladd bilinear_lneg) ``` huffman@44133 ` 390` wenzelm@53406 ` 391` ```lemma bilinear_rsub: "bilinear h \ h z (x - y) = h z x - h z y" ``` huffman@44133 ` 392` ``` by (simp add: diff_minus bilinear_radd bilinear_rneg) ``` huffman@44133 ` 393` huffman@44133 ` 394` ```lemma bilinear_setsum: ``` wenzelm@49663 ` 395` ``` assumes bh: "bilinear h" ``` wenzelm@49663 ` 396` ``` and fS: "finite S" ``` wenzelm@49663 ` 397` ``` and fT: "finite T" ``` huffman@44133 ` 398` ``` shows "h (setsum f S) (setsum g T) = setsum (\(i,j). h (f i) (g j)) (S \ T) " ``` wenzelm@49522 ` 399` ```proof - ``` huffman@44133 ` 400` ``` have "h (setsum f S) (setsum g T) = setsum (\x. h (f x) (setsum g T)) S" ``` huffman@44133 ` 401` ``` apply (rule linear_setsum[unfolded o_def]) ``` wenzelm@53406 ` 402` ``` using bh fS ``` wenzelm@53406 ` 403` ``` apply (auto simp add: bilinear_def) ``` wenzelm@49522 ` 404` ``` done ``` huffman@44133 ` 405` ``` also have "\ = setsum (\x. setsum (\y. h (f x) (g y)) T) S" ``` huffman@44133 ` 406` ``` apply (rule setsum_cong, simp) ``` huffman@44133 ` 407` ``` apply (rule linear_setsum[unfolded o_def]) ``` wenzelm@49522 ` 408` ``` using bh fT ``` wenzelm@49522 ` 409` ``` apply (auto simp add: bilinear_def) ``` wenzelm@49522 ` 410` ``` done ``` wenzelm@53406 ` 411` ``` finally show ?thesis ``` wenzelm@53406 ` 412` ``` unfolding setsum_cartesian_product . ``` huffman@44133 ` 413` ```qed ``` huffman@44133 ` 414` wenzelm@49522 ` 415` wenzelm@49522 ` 416` ```subsection {* Adjoints. *} ``` huffman@44133 ` 417` huffman@44133 ` 418` ```definition "adjoint f = (SOME f'. \x y. f x \ y = x \ f' y)" ``` huffman@44133 ` 419` huffman@44133 ` 420` ```lemma adjoint_unique: ``` huffman@44133 ` 421` ``` assumes "\x y. inner (f x) y = inner x (g y)" ``` huffman@44133 ` 422` ``` shows "adjoint f = g" ``` wenzelm@49522 ` 423` ``` unfolding adjoint_def ``` huffman@44133 ` 424` ```proof (rule some_equality) ``` wenzelm@53406 ` 425` ``` show "\x y. inner (f x) y = inner x (g y)" ``` wenzelm@53406 ` 426` ``` by (rule assms) ``` huffman@44133 ` 427` ```next ``` wenzelm@53406 ` 428` ``` fix h ``` wenzelm@53406 ` 429` ``` assume "\x y. inner (f x) y = inner x (h y)" ``` wenzelm@53406 ` 430` ``` then have "\x y. inner x (g y) = inner x (h y)" ``` wenzelm@53406 ` 431` ``` using assms by simp ``` wenzelm@53406 ` 432` ``` then have "\x y. inner x (g y - h y) = 0" ``` wenzelm@53406 ` 433` ``` by (simp add: inner_diff_right) ``` wenzelm@53406 ` 434` ``` then have "\y. inner (g y - h y) (g y - h y) = 0" ``` wenzelm@53406 ` 435` ``` by simp ``` wenzelm@53406 ` 436` ``` then have "\y. h y = g y" ``` wenzelm@53406 ` 437` ``` by simp ``` wenzelm@49652 ` 438` ``` then show "h = g" by (simp add: ext) ``` huffman@44133 ` 439` ```qed ``` huffman@44133 ` 440` hoelzl@50526 ` 441` ```text {* TODO: The following lemmas about adjoints should hold for any ``` hoelzl@50526 ` 442` ```Hilbert space (i.e. complete inner product space). ``` hoelzl@50526 ` 443` ```(see \url{http://en.wikipedia.org/wiki/Hermitian_adjoint}) ``` hoelzl@50526 ` 444` ```*} ``` hoelzl@50526 ` 445` hoelzl@50526 ` 446` ```lemma adjoint_works: ``` hoelzl@50526 ` 447` ``` fixes f:: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@50526 ` 448` ``` assumes lf: "linear f" ``` hoelzl@50526 ` 449` ``` shows "x \ adjoint f y = f x \ y" ``` hoelzl@50526 ` 450` ```proof - ``` hoelzl@50526 ` 451` ``` have "\y. \w. \x. f x \ y = x \ w" ``` hoelzl@50526 ` 452` ``` proof (intro allI exI) ``` hoelzl@50526 ` 453` ``` fix y :: "'m" and x ``` hoelzl@50526 ` 454` ``` let ?w = "(\i\Basis. (f i \ y) *\<^sub>R i) :: 'n" ``` hoelzl@50526 ` 455` ``` have "f x \ y = f (\i\Basis. (x \ i) *\<^sub>R i) \ y" ``` hoelzl@50526 ` 456` ``` by (simp add: euclidean_representation) ``` hoelzl@50526 ` 457` ``` also have "\ = (\i\Basis. (x \ i) *\<^sub>R f i) \ y" ``` hoelzl@50526 ` 458` ``` unfolding linear_setsum[OF lf finite_Basis] ``` hoelzl@50526 ` 459` ``` by (simp add: linear_cmul[OF lf]) ``` hoelzl@50526 ` 460` ``` finally show "f x \ y = x \ ?w" ``` wenzelm@53406 ` 461` ``` by (simp add: inner_setsum_left inner_setsum_right mult_commute) ``` hoelzl@50526 ` 462` ``` qed ``` hoelzl@50526 ` 463` ``` then show ?thesis ``` hoelzl@50526 ` 464` ``` unfolding adjoint_def choice_iff ``` hoelzl@50526 ` 465` ``` by (intro someI2_ex[where Q="\f'. x \ f' y = f x \ y"]) auto ``` hoelzl@50526 ` 466` ```qed ``` hoelzl@50526 ` 467` hoelzl@50526 ` 468` ```lemma adjoint_clauses: ``` hoelzl@50526 ` 469` ``` fixes f:: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@50526 ` 470` ``` assumes lf: "linear f" ``` hoelzl@50526 ` 471` ``` shows "x \ adjoint f y = f x \ y" ``` hoelzl@50526 ` 472` ``` and "adjoint f y \ x = y \ f x" ``` hoelzl@50526 ` 473` ``` by (simp_all add: adjoint_works[OF lf] inner_commute) ``` hoelzl@50526 ` 474` hoelzl@50526 ` 475` ```lemma adjoint_linear: ``` hoelzl@50526 ` 476` ``` fixes f:: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@50526 ` 477` ``` assumes lf: "linear f" ``` hoelzl@50526 ` 478` ``` shows "linear (adjoint f)" ``` huffman@53600 ` 479` ``` by (simp add: lf linear_iff euclidean_eq_iff[where 'a='n] euclidean_eq_iff[where 'a='m] ``` hoelzl@50526 ` 480` ``` adjoint_clauses[OF lf] inner_simps) ``` hoelzl@50526 ` 481` hoelzl@50526 ` 482` ```lemma adjoint_adjoint: ``` hoelzl@50526 ` 483` ``` fixes f:: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@50526 ` 484` ``` assumes lf: "linear f" ``` hoelzl@50526 ` 485` ``` shows "adjoint (adjoint f) = f" ``` hoelzl@50526 ` 486` ``` by (rule adjoint_unique, simp add: adjoint_clauses [OF lf]) ``` hoelzl@50526 ` 487` wenzelm@53406 ` 488` wenzelm@49522 ` 489` ```subsection {* Interlude: Some properties of real sets *} ``` huffman@44133 ` 490` wenzelm@53406 ` 491` ```lemma seq_mono_lemma: ``` wenzelm@53406 ` 492` ``` assumes "\(n::nat) \ m. (d n :: real) < e n" ``` wenzelm@53406 ` 493` ``` and "\n \ m. e n \ e m" ``` huffman@44133 ` 494` ``` shows "\n \ m. d n < e m" ``` wenzelm@53406 ` 495` ``` using assms ``` wenzelm@53406 ` 496` ``` apply auto ``` huffman@44133 ` 497` ``` apply (erule_tac x="n" in allE) ``` huffman@44133 ` 498` ``` apply (erule_tac x="n" in allE) ``` huffman@44133 ` 499` ``` apply auto ``` huffman@44133 ` 500` ``` done ``` huffman@44133 ` 501` wenzelm@53406 ` 502` ```lemma infinite_enumerate: ``` wenzelm@53406 ` 503` ``` assumes fS: "infinite S" ``` huffman@44133 ` 504` ``` shows "\r. subseq r \ (\n. r n \ S)" ``` wenzelm@49525 ` 505` ``` unfolding subseq_def ``` wenzelm@49525 ` 506` ``` using enumerate_in_set[OF fS] enumerate_mono[of _ _ S] fS by auto ``` huffman@44133 ` 507` huffman@44133 ` 508` ```lemma approachable_lt_le: "(\(d::real)>0. \x. f x < d \ P x) \ (\d>0. \x. f x \ d \ P x)" ``` wenzelm@49522 ` 509` ``` apply auto ``` wenzelm@49522 ` 510` ``` apply (rule_tac x="d/2" in exI) ``` wenzelm@49522 ` 511` ``` apply auto ``` wenzelm@49522 ` 512` ``` done ``` huffman@44133 ` 513` huffman@44133 ` 514` ```lemma triangle_lemma: ``` wenzelm@53406 ` 515` ``` fixes x y z :: real ``` wenzelm@53406 ` 516` ``` assumes x: "0 \ x" ``` wenzelm@53406 ` 517` ``` and y: "0 \ y" ``` wenzelm@53406 ` 518` ``` and z: "0 \ z" ``` wenzelm@53406 ` 519` ``` and xy: "x\<^sup>2 \ y\<^sup>2 + z\<^sup>2" ``` wenzelm@53406 ` 520` ``` shows "x \ y + z" ``` wenzelm@49522 ` 521` ```proof - ``` wenzelm@53406 ` 522` ``` have "y\<^sup>2 + z\<^sup>2 \ y\<^sup>2 + 2 *y * z + z\<^sup>2" ``` wenzelm@53406 ` 523` ``` using z y by (simp add: mult_nonneg_nonneg) ``` wenzelm@53406 ` 524` ``` with xy have th: "x\<^sup>2 \ (y + z)\<^sup>2" ``` wenzelm@53406 ` 525` ``` by (simp add: power2_eq_square field_simps) ``` wenzelm@53406 ` 526` ``` from y z have yz: "y + z \ 0" ``` wenzelm@53406 ` 527` ``` by arith ``` huffman@44133 ` 528` ``` from power2_le_imp_le[OF th yz] show ?thesis . ``` huffman@44133 ` 529` ```qed ``` huffman@44133 ` 530` wenzelm@49522 ` 531` huffman@44133 ` 532` ```subsection {* A generic notion of "hull" (convex, affine, conic hull and closure). *} ``` huffman@44133 ` 533` wenzelm@53406 ` 534` ```definition hull :: "('a set \ bool) \ 'a set \ 'a set" (infixl "hull" 75) ``` wenzelm@53406 ` 535` ``` where "S hull s = \{t. S t \ s \ t}" ``` huffman@44170 ` 536` huffman@44170 ` 537` ```lemma hull_same: "S s \ S hull s = s" ``` huffman@44133 ` 538` ``` unfolding hull_def by auto ``` huffman@44133 ` 539` wenzelm@53406 ` 540` ```lemma hull_in: "(\T. Ball T S \ S (\T)) \ S (S hull s)" ``` wenzelm@49522 ` 541` ``` unfolding hull_def Ball_def by auto ``` huffman@44170 ` 542` wenzelm@53406 ` 543` ```lemma hull_eq: "(\T. Ball T S \ S (\T)) \ (S hull s) = s \ S s" ``` wenzelm@49522 ` 544` ``` using hull_same[of S s] hull_in[of S s] by metis ``` huffman@44133 ` 545` huffman@44133 ` 546` ```lemma hull_hull: "S hull (S hull s) = S hull s" ``` huffman@44133 ` 547` ``` unfolding hull_def by blast ``` huffman@44133 ` 548` huffman@44133 ` 549` ```lemma hull_subset[intro]: "s \ (S hull s)" ``` huffman@44133 ` 550` ``` unfolding hull_def by blast ``` huffman@44133 ` 551` wenzelm@53406 ` 552` ```lemma hull_mono: "s \ t \ (S hull s) \ (S hull t)" ``` huffman@44133 ` 553` ``` unfolding hull_def by blast ``` huffman@44133 ` 554` wenzelm@53406 ` 555` ```lemma hull_antimono: "\x. S x \ T x \ (T hull s) \ (S hull s)" ``` huffman@44133 ` 556` ``` unfolding hull_def by blast ``` huffman@44133 ` 557` wenzelm@53406 ` 558` ```lemma hull_minimal: "s \ t \ S t \ (S hull s) \ t" ``` huffman@44133 ` 559` ``` unfolding hull_def by blast ``` huffman@44133 ` 560` wenzelm@53406 ` 561` ```lemma subset_hull: "S t \ S hull s \ t \ s \ t" ``` huffman@44133 ` 562` ``` unfolding hull_def by blast ``` huffman@44133 ` 563` huffman@53596 ` 564` ```lemma hull_UNIV: "S hull UNIV = UNIV" ``` huffman@53596 ` 565` ``` unfolding hull_def by auto ``` huffman@53596 ` 566` wenzelm@53406 ` 567` ```lemma hull_unique: "s \ t \ S t \ (\t'. s \ t' \ S t' \ t \ t') \ (S hull s = t)" ``` wenzelm@49652 ` 568` ``` unfolding hull_def by auto ``` huffman@44133 ` 569` huffman@44133 ` 570` ```lemma hull_induct: "(\x. x\ S \ P x) \ Q {x. P x} \ \x\ Q hull S. P x" ``` huffman@44133 ` 571` ``` using hull_minimal[of S "{x. P x}" Q] ``` huffman@44170 ` 572` ``` by (auto simp add: subset_eq) ``` huffman@44133 ` 573` wenzelm@49522 ` 574` ```lemma hull_inc: "x \ S \ x \ P hull S" ``` wenzelm@49522 ` 575` ``` by (metis hull_subset subset_eq) ``` huffman@44133 ` 576` huffman@44133 ` 577` ```lemma hull_union_subset: "(S hull s) \ (S hull t) \ (S hull (s \ t))" ``` wenzelm@49522 ` 578` ``` unfolding Un_subset_iff by (metis hull_mono Un_upper1 Un_upper2) ``` wenzelm@49522 ` 579` wenzelm@49522 ` 580` ```lemma hull_union: ``` wenzelm@53406 ` 581` ``` assumes T: "\T. Ball T S \ S (\T)" ``` huffman@44133 ` 582` ``` shows "S hull (s \ t) = S hull (S hull s \ S hull t)" ``` wenzelm@49522 ` 583` ``` apply rule ``` wenzelm@49522 ` 584` ``` apply (rule hull_mono) ``` wenzelm@49522 ` 585` ``` unfolding Un_subset_iff ``` wenzelm@49522 ` 586` ``` apply (metis hull_subset Un_upper1 Un_upper2 subset_trans) ``` wenzelm@49522 ` 587` ``` apply (rule hull_minimal) ``` wenzelm@49522 ` 588` ``` apply (metis hull_union_subset) ``` wenzelm@49522 ` 589` ``` apply (metis hull_in T) ``` wenzelm@49522 ` 590` ``` done ``` huffman@44133 ` 591` huffman@44133 ` 592` ```lemma hull_redundant_eq: "a \ (S hull s) \ (S hull (insert a s) = S hull s)" ``` huffman@44133 ` 593` ``` unfolding hull_def by blast ``` huffman@44133 ` 594` wenzelm@53406 ` 595` ```lemma hull_redundant: "a \ (S hull s) \ (S hull (insert a s) = S hull s)" ``` wenzelm@49522 ` 596` ``` by (metis hull_redundant_eq) ``` wenzelm@49522 ` 597` huffman@44133 ` 598` huffman@44666 ` 599` ```subsection {* Archimedean properties and useful consequences *} ``` huffman@44133 ` 600` wenzelm@53406 ` 601` ```lemma real_arch_simple: "\n. x \ real (n::nat)" ``` huffman@44666 ` 602` ``` unfolding real_of_nat_def by (rule ex_le_of_nat) ``` huffman@44133 ` 603` huffman@44133 ` 604` ```lemma real_arch_inv: "0 < e \ (\n::nat. n \ 0 \ 0 < inverse (real n) \ inverse (real n) < e)" ``` huffman@44133 ` 605` ``` using reals_Archimedean ``` huffman@44133 ` 606` ``` apply (auto simp add: field_simps) ``` huffman@44133 ` 607` ``` apply (subgoal_tac "inverse (real n) > 0") ``` huffman@44133 ` 608` ``` apply arith ``` huffman@44133 ` 609` ``` apply simp ``` huffman@44133 ` 610` ``` done ``` huffman@44133 ` 611` wenzelm@53406 ` 612` ```lemma real_pow_lbound: "0 \ x \ 1 + real n * x \ (1 + x) ^ n" ``` wenzelm@49522 ` 613` ```proof (induct n) ``` wenzelm@49522 ` 614` ``` case 0 ``` wenzelm@49522 ` 615` ``` then show ?case by simp ``` huffman@44133 ` 616` ```next ``` huffman@44133 ` 617` ``` case (Suc n) ``` wenzelm@53406 ` 618` ``` then have h: "1 + real n * x \ (1 + x) ^ n" ``` wenzelm@53406 ` 619` ``` by simp ``` wenzelm@53406 ` 620` ``` from h have p: "1 \ (1 + x) ^ n" ``` wenzelm@53406 ` 621` ``` using Suc.prems by simp ``` wenzelm@53406 ` 622` ``` from h have "1 + real n * x + x \ (1 + x) ^ n + x" ``` wenzelm@53406 ` 623` ``` by simp ``` wenzelm@53406 ` 624` ``` also have "\ \ (1 + x) ^ Suc n" ``` wenzelm@53406 ` 625` ``` apply (subst diff_le_0_iff_le[symmetric]) ``` huffman@44133 ` 626` ``` apply (simp add: field_simps) ``` wenzelm@53406 ` 627` ``` using mult_left_mono[OF p Suc.prems] ``` wenzelm@53406 ` 628` ``` apply simp ``` wenzelm@49522 ` 629` ``` done ``` wenzelm@53406 ` 630` ``` finally show ?case ``` wenzelm@53406 ` 631` ``` by (simp add: real_of_nat_Suc field_simps) ``` huffman@44133 ` 632` ```qed ``` huffman@44133 ` 633` wenzelm@53406 ` 634` ```lemma real_arch_pow: ``` wenzelm@53406 ` 635` ``` fixes x :: real ``` wenzelm@53406 ` 636` ``` assumes x: "1 < x" ``` wenzelm@53406 ` 637` ``` shows "\n. y < x^n" ``` wenzelm@49522 ` 638` ```proof - ``` wenzelm@53406 ` 639` ``` from x have x0: "x - 1 > 0" ``` wenzelm@53406 ` 640` ``` by arith ``` huffman@44666 ` 641` ``` from reals_Archimedean3[OF x0, rule_format, of y] ``` wenzelm@53406 ` 642` ``` obtain n :: nat where n: "y < real n * (x - 1)" by metis ``` huffman@44133 ` 643` ``` from x0 have x00: "x- 1 \ 0" by arith ``` huffman@44133 ` 644` ``` from real_pow_lbound[OF x00, of n] n ``` huffman@44133 ` 645` ``` have "y < x^n" by auto ``` huffman@44133 ` 646` ``` then show ?thesis by metis ``` huffman@44133 ` 647` ```qed ``` huffman@44133 ` 648` wenzelm@53406 ` 649` ```lemma real_arch_pow2: ``` wenzelm@53406 ` 650` ``` fixes x :: real ``` wenzelm@53406 ` 651` ``` shows "\n. x < 2^ n" ``` huffman@44133 ` 652` ``` using real_arch_pow[of 2 x] by simp ``` huffman@44133 ` 653` wenzelm@49522 ` 654` ```lemma real_arch_pow_inv: ``` wenzelm@53406 ` 655` ``` fixes x y :: real ``` wenzelm@53406 ` 656` ``` assumes y: "y > 0" ``` wenzelm@53406 ` 657` ``` and x1: "x < 1" ``` huffman@44133 ` 658` ``` shows "\n. x^n < y" ``` wenzelm@53406 ` 659` ```proof (cases "x > 0") ``` wenzelm@53406 ` 660` ``` case True ``` wenzelm@53406 ` 661` ``` with x1 have ix: "1 < 1/x" by (simp add: field_simps) ``` wenzelm@53406 ` 662` ``` from real_arch_pow[OF ix, of "1/y"] ``` wenzelm@53406 ` 663` ``` obtain n where n: "1/y < (1/x)^n" by blast ``` wenzelm@53406 ` 664` ``` then show ?thesis using y `x > 0` ``` wenzelm@53406 ` 665` ``` by (auto simp add: field_simps power_divide) ``` wenzelm@53406 ` 666` ```next ``` wenzelm@53406 ` 667` ``` case False ``` wenzelm@53406 ` 668` ``` with y x1 show ?thesis ``` wenzelm@53406 ` 669` ``` apply auto ``` wenzelm@53406 ` 670` ``` apply (rule exI[where x=1]) ``` wenzelm@53406 ` 671` ``` apply auto ``` wenzelm@53406 ` 672` ``` done ``` huffman@44133 ` 673` ```qed ``` huffman@44133 ` 674` wenzelm@49522 ` 675` ```lemma forall_pos_mono: ``` wenzelm@53406 ` 676` ``` "(\d e::real. d < e \ P d \ P e) \ ``` wenzelm@53406 ` 677` ``` (\n::nat. n \ 0 \ P (inverse (real n))) \ (\e. 0 < e \ P e)" ``` huffman@44133 ` 678` ``` by (metis real_arch_inv) ``` huffman@44133 ` 679` wenzelm@49522 ` 680` ```lemma forall_pos_mono_1: ``` wenzelm@53406 ` 681` ``` "(\d e::real. d < e \ P d \ P e) \ ``` wenzelm@53406 ` 682` ``` (\n. P(inverse(real (Suc n)))) \ 0 < e \ P e" ``` huffman@44133 ` 683` ``` apply (rule forall_pos_mono) ``` huffman@44133 ` 684` ``` apply auto ``` huffman@44133 ` 685` ``` apply (atomize) ``` huffman@44133 ` 686` ``` apply (erule_tac x="n - 1" in allE) ``` huffman@44133 ` 687` ``` apply auto ``` huffman@44133 ` 688` ``` done ``` huffman@44133 ` 689` wenzelm@49522 ` 690` ```lemma real_archimedian_rdiv_eq_0: ``` wenzelm@53406 ` 691` ``` assumes x0: "x \ 0" ``` wenzelm@53406 ` 692` ``` and c: "c \ 0" ``` wenzelm@53406 ` 693` ``` and xc: "\(m::nat)>0. real m * x \ c" ``` huffman@44133 ` 694` ``` shows "x = 0" ``` wenzelm@53406 ` 695` ```proof (rule ccontr) ``` wenzelm@53406 ` 696` ``` assume "x \ 0" ``` wenzelm@53406 ` 697` ``` with x0 have xp: "x > 0" by arith ``` wenzelm@53406 ` 698` ``` from reals_Archimedean3[OF xp, rule_format, of c] ``` wenzelm@53406 ` 699` ``` obtain n :: nat where n: "c < real n * x" ``` wenzelm@53406 ` 700` ``` by blast ``` wenzelm@53406 ` 701` ``` with xc[rule_format, of n] have "n = 0" ``` wenzelm@53406 ` 702` ``` by arith ``` wenzelm@53406 ` 703` ``` with n c show False ``` wenzelm@53406 ` 704` ``` by simp ``` huffman@44133 ` 705` ```qed ``` huffman@44133 ` 706` wenzelm@49522 ` 707` huffman@44133 ` 708` ```subsection{* A bit of linear algebra. *} ``` huffman@44133 ` 709` wenzelm@49522 ` 710` ```definition (in real_vector) subspace :: "'a set \ bool" ``` wenzelm@49522 ` 711` ``` where "subspace S \ 0 \ S \ (\x\ S. \y \S. x + y \ S) \ (\c. \x \S. c *\<^sub>R x \S )" ``` huffman@44133 ` 712` huffman@44133 ` 713` ```definition (in real_vector) "span S = (subspace hull S)" ``` huffman@44133 ` 714` ```definition (in real_vector) "dependent S \ (\a \ S. a \ span(S - {a}))" ``` wenzelm@53406 ` 715` ```abbreviation (in real_vector) "independent s \ \ dependent s" ``` huffman@44133 ` 716` huffman@44133 ` 717` ```text {* Closure properties of subspaces. *} ``` huffman@44133 ` 718` wenzelm@53406 ` 719` ```lemma subspace_UNIV[simp]: "subspace UNIV" ``` wenzelm@53406 ` 720` ``` by (simp add: subspace_def) ``` wenzelm@53406 ` 721` wenzelm@53406 ` 722` ```lemma (in real_vector) subspace_0: "subspace S \ 0 \ S" ``` wenzelm@53406 ` 723` ``` by (metis subspace_def) ``` wenzelm@53406 ` 724` wenzelm@53406 ` 725` ```lemma (in real_vector) subspace_add: "subspace S \ x \ S \ y \ S \ x + y \ S" ``` huffman@44133 ` 726` ``` by (metis subspace_def) ``` huffman@44133 ` 727` huffman@44133 ` 728` ```lemma (in real_vector) subspace_mul: "subspace S \ x \ S \ c *\<^sub>R x \ S" ``` huffman@44133 ` 729` ``` by (metis subspace_def) ``` huffman@44133 ` 730` huffman@44133 ` 731` ```lemma subspace_neg: "subspace S \ x \ S \ - x \ S" ``` huffman@44133 ` 732` ``` by (metis scaleR_minus1_left subspace_mul) ``` huffman@44133 ` 733` huffman@44133 ` 734` ```lemma subspace_sub: "subspace S \ x \ S \ y \ S \ x - y \ S" ``` huffman@44133 ` 735` ``` by (metis diff_minus subspace_add subspace_neg) ``` huffman@44133 ` 736` huffman@44133 ` 737` ```lemma (in real_vector) subspace_setsum: ``` wenzelm@53406 ` 738` ``` assumes sA: "subspace A" ``` wenzelm@53406 ` 739` ``` and fB: "finite B" ``` wenzelm@49522 ` 740` ``` and f: "\x\ B. f x \ A" ``` huffman@44133 ` 741` ``` shows "setsum f B \ A" ``` huffman@44133 ` 742` ``` using fB f sA ``` wenzelm@49522 ` 743` ``` by (induct rule: finite_induct[OF fB]) ``` wenzelm@49522 ` 744` ``` (simp add: subspace_def sA, auto simp add: sA subspace_add) ``` huffman@44133 ` 745` huffman@44133 ` 746` ```lemma subspace_linear_image: ``` wenzelm@53406 ` 747` ``` assumes lf: "linear f" ``` wenzelm@53406 ` 748` ``` and sS: "subspace S" ``` wenzelm@53406 ` 749` ``` shows "subspace (f ` S)" ``` huffman@44133 ` 750` ``` using lf sS linear_0[OF lf] ``` huffman@53600 ` 751` ``` unfolding linear_iff subspace_def ``` huffman@44133 ` 752` ``` apply (auto simp add: image_iff) ``` wenzelm@53406 ` 753` ``` apply (rule_tac x="x + y" in bexI) ``` wenzelm@53406 ` 754` ``` apply auto ``` wenzelm@53406 ` 755` ``` apply (rule_tac x="c *\<^sub>R x" in bexI) ``` wenzelm@53406 ` 756` ``` apply auto ``` huffman@44133 ` 757` ``` done ``` huffman@44133 ` 758` huffman@44521 ` 759` ```lemma subspace_linear_vimage: "linear f \ subspace S \ subspace (f -` S)" ``` huffman@53600 ` 760` ``` by (auto simp add: subspace_def linear_iff linear_0[of f]) ``` huffman@44521 ` 761` wenzelm@53406 ` 762` ```lemma subspace_linear_preimage: "linear f \ subspace S \ subspace {x. f x \ S}" ``` huffman@53600 ` 763` ``` by (auto simp add: subspace_def linear_iff linear_0[of f]) ``` huffman@44133 ` 764` huffman@44133 ` 765` ```lemma subspace_trivial: "subspace {0}" ``` huffman@44133 ` 766` ``` by (simp add: subspace_def) ``` huffman@44133 ` 767` wenzelm@53406 ` 768` ```lemma (in real_vector) subspace_inter: "subspace A \ subspace B \ subspace (A \ B)" ``` huffman@44133 ` 769` ``` by (simp add: subspace_def) ``` huffman@44133 ` 770` wenzelm@53406 ` 771` ```lemma subspace_Times: "subspace A \ subspace B \ subspace (A \ B)" ``` huffman@44521 ` 772` ``` unfolding subspace_def zero_prod_def by simp ``` huffman@44521 ` 773` huffman@44521 ` 774` ```text {* Properties of span. *} ``` huffman@44521 ` 775` wenzelm@53406 ` 776` ```lemma (in real_vector) span_mono: "A \ B \ span A \ span B" ``` huffman@44133 ` 777` ``` by (metis span_def hull_mono) ``` huffman@44133 ` 778` wenzelm@53406 ` 779` ```lemma (in real_vector) subspace_span: "subspace (span S)" ``` huffman@44133 ` 780` ``` unfolding span_def ``` huffman@44170 ` 781` ``` apply (rule hull_in) ``` huffman@44133 ` 782` ``` apply (simp only: subspace_def Inter_iff Int_iff subset_eq) ``` huffman@44133 ` 783` ``` apply auto ``` huffman@44133 ` 784` ``` done ``` huffman@44133 ` 785` huffman@44133 ` 786` ```lemma (in real_vector) span_clauses: ``` wenzelm@53406 ` 787` ``` "a \ S \ a \ span S" ``` huffman@44133 ` 788` ``` "0 \ span S" ``` wenzelm@53406 ` 789` ``` "x\ span S \ y \ span S \ x + y \ span S" ``` huffman@44133 ` 790` ``` "x \ span S \ c *\<^sub>R x \ span S" ``` wenzelm@53406 ` 791` ``` by (metis span_def hull_subset subset_eq) (metis subspace_span subspace_def)+ ``` huffman@44133 ` 792` huffman@44521 ` 793` ```lemma span_unique: ``` wenzelm@49522 ` 794` ``` "S \ T \ subspace T \ (\T'. S \ T' \ subspace T' \ T \ T') \ span S = T" ``` huffman@44521 ` 795` ``` unfolding span_def by (rule hull_unique) ``` huffman@44521 ` 796` huffman@44521 ` 797` ```lemma span_minimal: "S \ T \ subspace T \ span S \ T" ``` huffman@44521 ` 798` ``` unfolding span_def by (rule hull_minimal) ``` huffman@44521 ` 799` huffman@44521 ` 800` ```lemma (in real_vector) span_induct: ``` wenzelm@49522 ` 801` ``` assumes x: "x \ span S" ``` wenzelm@49522 ` 802` ``` and P: "subspace P" ``` wenzelm@53406 ` 803` ``` and SP: "\x. x \ S \ x \ P" ``` huffman@44521 ` 804` ``` shows "x \ P" ``` wenzelm@49522 ` 805` ```proof - ``` wenzelm@53406 ` 806` ``` from SP have SP': "S \ P" ``` wenzelm@53406 ` 807` ``` by (simp add: subset_eq) ``` huffman@44170 ` 808` ``` from x hull_minimal[where S=subspace, OF SP' P, unfolded span_def[symmetric]] ``` wenzelm@53406 ` 809` ``` show "x \ P" ``` wenzelm@53406 ` 810` ``` by (metis subset_eq) ``` huffman@44133 ` 811` ```qed ``` huffman@44133 ` 812` huffman@44133 ` 813` ```lemma span_empty[simp]: "span {} = {0}" ``` huffman@44133 ` 814` ``` apply (simp add: span_def) ``` huffman@44133 ` 815` ``` apply (rule hull_unique) ``` huffman@44170 ` 816` ``` apply (auto simp add: subspace_def) ``` huffman@44133 ` 817` ``` done ``` huffman@44133 ` 818` huffman@44133 ` 819` ```lemma (in real_vector) independent_empty[intro]: "independent {}" ``` huffman@44133 ` 820` ``` by (simp add: dependent_def) ``` huffman@44133 ` 821` wenzelm@49522 ` 822` ```lemma dependent_single[simp]: "dependent {x} \ x = 0" ``` huffman@44133 ` 823` ``` unfolding dependent_def by auto ``` huffman@44133 ` 824` wenzelm@53406 ` 825` ```lemma (in real_vector) independent_mono: "independent A \ B \ A \ independent B" ``` huffman@44133 ` 826` ``` apply (clarsimp simp add: dependent_def span_mono) ``` huffman@44133 ` 827` ``` apply (subgoal_tac "span (B - {a}) \ span (A - {a})") ``` huffman@44133 ` 828` ``` apply force ``` huffman@44133 ` 829` ``` apply (rule span_mono) ``` huffman@44133 ` 830` ``` apply auto ``` huffman@44133 ` 831` ``` done ``` huffman@44133 ` 832` huffman@44133 ` 833` ```lemma (in real_vector) span_subspace: "A \ B \ B \ span A \ subspace B \ span A = B" ``` huffman@44170 ` 834` ``` by (metis order_antisym span_def hull_minimal) ``` huffman@44133 ` 835` wenzelm@49711 ` 836` ```lemma (in real_vector) span_induct': ``` wenzelm@49711 ` 837` ``` assumes SP: "\x \ S. P x" ``` wenzelm@49711 ` 838` ``` and P: "subspace {x. P x}" ``` wenzelm@49711 ` 839` ``` shows "\x \ span S. P x" ``` huffman@44133 ` 840` ``` using span_induct SP P by blast ``` huffman@44133 ` 841` huffman@44170 ` 842` ```inductive_set (in real_vector) span_induct_alt_help for S:: "'a set" ``` wenzelm@53406 ` 843` ```where ``` huffman@44170 ` 844` ``` span_induct_alt_help_0: "0 \ span_induct_alt_help S" ``` wenzelm@49522 ` 845` ```| span_induct_alt_help_S: ``` wenzelm@53406 ` 846` ``` "x \ S \ z \ span_induct_alt_help S \ ``` wenzelm@53406 ` 847` ``` (c *\<^sub>R x + z) \ span_induct_alt_help S" ``` huffman@44133 ` 848` huffman@44133 ` 849` ```lemma span_induct_alt': ``` wenzelm@53406 ` 850` ``` assumes h0: "h 0" ``` wenzelm@53406 ` 851` ``` and hS: "\c x y. x \ S \ h y \ h (c *\<^sub>R x + y)" ``` wenzelm@49522 ` 852` ``` shows "\x \ span S. h x" ``` wenzelm@49522 ` 853` ```proof - ``` wenzelm@53406 ` 854` ``` { ``` wenzelm@53406 ` 855` ``` fix x :: 'a ``` wenzelm@53406 ` 856` ``` assume x: "x \ span_induct_alt_help S" ``` huffman@44133 ` 857` ``` have "h x" ``` huffman@44133 ` 858` ``` apply (rule span_induct_alt_help.induct[OF x]) ``` huffman@44133 ` 859` ``` apply (rule h0) ``` wenzelm@53406 ` 860` ``` apply (rule hS) ``` wenzelm@53406 ` 861` ``` apply assumption ``` wenzelm@53406 ` 862` ``` apply assumption ``` wenzelm@53406 ` 863` ``` done ``` wenzelm@53406 ` 864` ``` } ``` huffman@44133 ` 865` ``` note th0 = this ``` wenzelm@53406 ` 866` ``` { ``` wenzelm@53406 ` 867` ``` fix x ``` wenzelm@53406 ` 868` ``` assume x: "x \ span S" ``` huffman@44170 ` 869` ``` have "x \ span_induct_alt_help S" ``` wenzelm@49522 ` 870` ``` proof (rule span_induct[where x=x and S=S]) ``` wenzelm@53406 ` 871` ``` show "x \ span S" by (rule x) ``` wenzelm@49522 ` 872` ``` next ``` wenzelm@53406 ` 873` ``` fix x ``` wenzelm@53406 ` 874` ``` assume xS: "x \ S" ``` wenzelm@53406 ` 875` ``` from span_induct_alt_help_S[OF xS span_induct_alt_help_0, of 1] ``` wenzelm@53406 ` 876` ``` show "x \ span_induct_alt_help S" ``` wenzelm@53406 ` 877` ``` by simp ``` wenzelm@49522 ` 878` ``` next ``` wenzelm@49522 ` 879` ``` have "0 \ span_induct_alt_help S" by (rule span_induct_alt_help_0) ``` wenzelm@49522 ` 880` ``` moreover ``` wenzelm@53406 ` 881` ``` { ``` wenzelm@53406 ` 882` ``` fix x y ``` wenzelm@49522 ` 883` ``` assume h: "x \ span_induct_alt_help S" "y \ span_induct_alt_help S" ``` wenzelm@49522 ` 884` ``` from h have "(x + y) \ span_induct_alt_help S" ``` wenzelm@49522 ` 885` ``` apply (induct rule: span_induct_alt_help.induct) ``` wenzelm@49522 ` 886` ``` apply simp ``` wenzelm@49522 ` 887` ``` unfolding add_assoc ``` wenzelm@49522 ` 888` ``` apply (rule span_induct_alt_help_S) ``` wenzelm@49522 ` 889` ``` apply assumption ``` wenzelm@49522 ` 890` ``` apply simp ``` wenzelm@53406 ` 891` ``` done ``` wenzelm@53406 ` 892` ``` } ``` wenzelm@49522 ` 893` ``` moreover ``` wenzelm@53406 ` 894` ``` { ``` wenzelm@53406 ` 895` ``` fix c x ``` wenzelm@49522 ` 896` ``` assume xt: "x \ span_induct_alt_help S" ``` wenzelm@49522 ` 897` ``` then have "(c *\<^sub>R x) \ span_induct_alt_help S" ``` wenzelm@49522 ` 898` ``` apply (induct rule: span_induct_alt_help.induct) ``` wenzelm@49522 ` 899` ``` apply (simp add: span_induct_alt_help_0) ``` wenzelm@49522 ` 900` ``` apply (simp add: scaleR_right_distrib) ``` wenzelm@49522 ` 901` ``` apply (rule span_induct_alt_help_S) ``` wenzelm@49522 ` 902` ``` apply assumption ``` wenzelm@49522 ` 903` ``` apply simp ``` wenzelm@49522 ` 904` ``` done } ``` wenzelm@53406 ` 905` ``` ultimately show "subspace (span_induct_alt_help S)" ``` wenzelm@49522 ` 906` ``` unfolding subspace_def Ball_def by blast ``` wenzelm@53406 ` 907` ``` qed ``` wenzelm@53406 ` 908` ``` } ``` huffman@44133 ` 909` ``` with th0 show ?thesis by blast ``` huffman@44133 ` 910` ```qed ``` huffman@44133 ` 911` huffman@44133 ` 912` ```lemma span_induct_alt: ``` wenzelm@53406 ` 913` ``` assumes h0: "h 0" ``` wenzelm@53406 ` 914` ``` and hS: "\c x y. x \ S \ h y \ h (c *\<^sub>R x + y)" ``` wenzelm@53406 ` 915` ``` and x: "x \ span S" ``` huffman@44133 ` 916` ``` shows "h x" ``` wenzelm@49522 ` 917` ``` using span_induct_alt'[of h S] h0 hS x by blast ``` huffman@44133 ` 918` huffman@44133 ` 919` ```text {* Individual closure properties. *} ``` huffman@44133 ` 920` huffman@44133 ` 921` ```lemma span_span: "span (span A) = span A" ``` huffman@44133 ` 922` ``` unfolding span_def hull_hull .. ``` huffman@44133 ` 923` wenzelm@53406 ` 924` ```lemma (in real_vector) span_superset: "x \ S \ x \ span S" ``` wenzelm@53406 ` 925` ``` by (metis span_clauses(1)) ``` wenzelm@53406 ` 926` wenzelm@53406 ` 927` ```lemma (in real_vector) span_0: "0 \ span S" ``` wenzelm@53406 ` 928` ``` by (metis subspace_span subspace_0) ``` huffman@44133 ` 929` huffman@44133 ` 930` ```lemma span_inc: "S \ span S" ``` huffman@44133 ` 931` ``` by (metis subset_eq span_superset) ``` huffman@44133 ` 932` wenzelm@53406 ` 933` ```lemma (in real_vector) dependent_0: ``` wenzelm@53406 ` 934` ``` assumes "0 \ A" ``` wenzelm@53406 ` 935` ``` shows "dependent A" ``` wenzelm@53406 ` 936` ``` unfolding dependent_def ``` wenzelm@53406 ` 937` ``` apply (rule_tac x=0 in bexI) ``` wenzelm@53406 ` 938` ``` using assms span_0 ``` wenzelm@53406 ` 939` ``` apply auto ``` wenzelm@53406 ` 940` ``` done ``` wenzelm@53406 ` 941` wenzelm@53406 ` 942` ```lemma (in real_vector) span_add: "x \ span S \ y \ span S \ x + y \ span S" ``` huffman@44133 ` 943` ``` by (metis subspace_add subspace_span) ``` huffman@44133 ` 944` wenzelm@53406 ` 945` ```lemma (in real_vector) span_mul: "x \ span S \ c *\<^sub>R x \ span S" ``` huffman@44133 ` 946` ``` by (metis subspace_span subspace_mul) ``` huffman@44133 ` 947` wenzelm@53406 ` 948` ```lemma span_neg: "x \ span S \ - x \ span S" ``` huffman@44133 ` 949` ``` by (metis subspace_neg subspace_span) ``` huffman@44133 ` 950` wenzelm@53406 ` 951` ```lemma span_sub: "x \ span S \ y \ span S \ x - y \ span S" ``` huffman@44133 ` 952` ``` by (metis subspace_span subspace_sub) ``` huffman@44133 ` 953` wenzelm@53406 ` 954` ```lemma (in real_vector) span_setsum: "finite A \ \x \ A. f x \ span S \ setsum f A \ span S" ``` huffman@44133 ` 955` ``` by (rule subspace_setsum, rule subspace_span) ``` huffman@44133 ` 956` huffman@44133 ` 957` ```lemma span_add_eq: "x \ span S \ x + y \ span S \ y \ span S" ``` huffman@44133 ` 958` ``` apply (auto simp only: span_add span_sub) ``` wenzelm@53406 ` 959` ``` apply (subgoal_tac "(x + y) - x \ span S") ``` wenzelm@53406 ` 960` ``` apply simp ``` wenzelm@49522 ` 961` ``` apply (simp only: span_add span_sub) ``` wenzelm@49522 ` 962` ``` done ``` huffman@44133 ` 963` huffman@44133 ` 964` ```text {* Mapping under linear image. *} ``` huffman@44133 ` 965` huffman@44521 ` 966` ```lemma image_subset_iff_subset_vimage: "f ` A \ B \ A \ f -` B" ``` huffman@44521 ` 967` ``` by auto (* TODO: move *) ``` huffman@44521 ` 968` huffman@44521 ` 969` ```lemma span_linear_image: ``` huffman@44521 ` 970` ``` assumes lf: "linear f" ``` huffman@44133 ` 971` ``` shows "span (f ` S) = f ` (span S)" ``` huffman@44521 ` 972` ```proof (rule span_unique) ``` huffman@44521 ` 973` ``` show "f ` S \ f ` span S" ``` huffman@44521 ` 974` ``` by (intro image_mono span_inc) ``` huffman@44521 ` 975` ``` show "subspace (f ` span S)" ``` huffman@44521 ` 976` ``` using lf subspace_span by (rule subspace_linear_image) ``` huffman@44521 ` 977` ```next ``` wenzelm@53406 ` 978` ``` fix T ``` wenzelm@53406 ` 979` ``` assume "f ` S \ T" and "subspace T" ``` wenzelm@49522 ` 980` ``` then show "f ` span S \ T" ``` huffman@44521 ` 981` ``` unfolding image_subset_iff_subset_vimage ``` huffman@44521 ` 982` ``` by (intro span_minimal subspace_linear_vimage lf) ``` huffman@44521 ` 983` ```qed ``` huffman@44521 ` 984` huffman@44521 ` 985` ```lemma span_union: "span (A \ B) = (\(a, b). a + b) ` (span A \ span B)" ``` huffman@44521 ` 986` ```proof (rule span_unique) ``` huffman@44521 ` 987` ``` show "A \ B \ (\(a, b). a + b) ` (span A \ span B)" ``` huffman@44521 ` 988` ``` by safe (force intro: span_clauses)+ ``` huffman@44521 ` 989` ```next ``` huffman@44521 ` 990` ``` have "linear (\(a, b). a + b)" ``` huffman@53600 ` 991` ``` by (simp add: linear_iff scaleR_add_right) ``` huffman@44521 ` 992` ``` moreover have "subspace (span A \ span B)" ``` huffman@44521 ` 993` ``` by (intro subspace_Times subspace_span) ``` huffman@44521 ` 994` ``` ultimately show "subspace ((\(a, b). a + b) ` (span A \ span B))" ``` huffman@44521 ` 995` ``` by (rule subspace_linear_image) ``` huffman@44521 ` 996` ```next ``` wenzelm@49711 ` 997` ``` fix T ``` wenzelm@49711 ` 998` ``` assume "A \ B \ T" and "subspace T" ``` wenzelm@49522 ` 999` ``` then show "(\(a, b). a + b) ` (span A \ span B) \ T" ``` huffman@44521 ` 1000` ``` by (auto intro!: subspace_add elim: span_induct) ``` huffman@44133 ` 1001` ```qed ``` huffman@44133 ` 1002` huffman@44133 ` 1003` ```text {* The key breakdown property. *} ``` huffman@44133 ` 1004` huffman@44521 ` 1005` ```lemma span_singleton: "span {x} = range (\k. k *\<^sub>R x)" ``` huffman@44521 ` 1006` ```proof (rule span_unique) ``` huffman@44521 ` 1007` ``` show "{x} \ range (\k. k *\<^sub>R x)" ``` huffman@44521 ` 1008` ``` by (fast intro: scaleR_one [symmetric]) ``` huffman@44521 ` 1009` ``` show "subspace (range (\k. k *\<^sub>R x))" ``` huffman@44521 ` 1010` ``` unfolding subspace_def ``` huffman@44521 ` 1011` ``` by (auto intro: scaleR_add_left [symmetric]) ``` wenzelm@53406 ` 1012` ```next ``` wenzelm@53406 ` 1013` ``` fix T ``` wenzelm@53406 ` 1014` ``` assume "{x} \ T" and "subspace T" ``` wenzelm@53406 ` 1015` ``` then show "range (\k. k *\<^sub>R x) \ T" ``` huffman@44521 ` 1016` ``` unfolding subspace_def by auto ``` huffman@44521 ` 1017` ```qed ``` huffman@44521 ` 1018` wenzelm@49522 ` 1019` ```lemma span_insert: "span (insert a S) = {x. \k. (x - k *\<^sub>R a) \ span S}" ``` huffman@44521 ` 1020` ```proof - ``` huffman@44521 ` 1021` ``` have "span ({a} \ S) = {x. \k. (x - k *\<^sub>R a) \ span S}" ``` huffman@44521 ` 1022` ``` unfolding span_union span_singleton ``` huffman@44521 ` 1023` ``` apply safe ``` huffman@44521 ` 1024` ``` apply (rule_tac x=k in exI, simp) ``` huffman@44521 ` 1025` ``` apply (erule rev_image_eqI [OF SigmaI [OF rangeI]]) ``` huffman@44521 ` 1026` ``` apply simp ``` huffman@44521 ` 1027` ``` apply (rule right_minus) ``` huffman@44521 ` 1028` ``` done ``` wenzelm@49522 ` 1029` ``` then show ?thesis by simp ``` huffman@44521 ` 1030` ```qed ``` huffman@44521 ` 1031` huffman@44133 ` 1032` ```lemma span_breakdown: ``` wenzelm@53406 ` 1033` ``` assumes bS: "b \ S" ``` wenzelm@53406 ` 1034` ``` and aS: "a \ span S" ``` huffman@44521 ` 1035` ``` shows "\k. a - k *\<^sub>R b \ span (S - {b})" ``` huffman@44521 ` 1036` ``` using assms span_insert [of b "S - {b}"] ``` huffman@44521 ` 1037` ``` by (simp add: insert_absorb) ``` huffman@44133 ` 1038` wenzelm@53406 ` 1039` ```lemma span_breakdown_eq: "x \ span (insert a S) \ (\k. x - k *\<^sub>R a \ span S)" ``` huffman@44521 ` 1040` ``` by (simp add: span_insert) ``` huffman@44133 ` 1041` huffman@44133 ` 1042` ```text {* Hence some "reversal" results. *} ``` huffman@44133 ` 1043` huffman@44133 ` 1044` ```lemma in_span_insert: ``` wenzelm@49711 ` 1045` ``` assumes a: "a \ span (insert b S)" ``` wenzelm@49711 ` 1046` ``` and na: "a \ span S" ``` huffman@44133 ` 1047` ``` shows "b \ span (insert a S)" ``` wenzelm@49663 ` 1048` ```proof - ``` huffman@44133 ` 1049` ``` from span_breakdown[of b "insert b S" a, OF insertI1 a] ``` huffman@44133 ` 1050` ``` obtain k where k: "a - k*\<^sub>R b \ span (S - {b})" by auto ``` wenzelm@53406 ` 1051` ``` show ?thesis ``` wenzelm@53406 ` 1052` ``` proof (cases "k = 0") ``` wenzelm@53406 ` 1053` ``` case True ``` huffman@44133 ` 1054` ``` with k have "a \ span S" ``` huffman@44133 ` 1055` ``` apply (simp) ``` huffman@44133 ` 1056` ``` apply (rule set_rev_mp) ``` huffman@44133 ` 1057` ``` apply assumption ``` huffman@44133 ` 1058` ``` apply (rule span_mono) ``` huffman@44133 ` 1059` ``` apply blast ``` huffman@44133 ` 1060` ``` done ``` wenzelm@53406 ` 1061` ``` with na show ?thesis by blast ``` wenzelm@53406 ` 1062` ``` next ``` wenzelm@53406 ` 1063` ``` case False ``` huffman@44133 ` 1064` ``` have eq: "b = (1/k) *\<^sub>R a - ((1/k) *\<^sub>R a - b)" by simp ``` wenzelm@53406 ` 1065` ``` from False have eq': "(1/k) *\<^sub>R (a - k*\<^sub>R b) = (1/k) *\<^sub>R a - b" ``` huffman@44133 ` 1066` ``` by (simp add: algebra_simps) ``` huffman@44133 ` 1067` ``` from k have "(1/k) *\<^sub>R (a - k*\<^sub>R b) \ span (S - {b})" ``` huffman@44133 ` 1068` ``` by (rule span_mul) ``` wenzelm@49652 ` 1069` ``` then have th: "(1/k) *\<^sub>R a - b \ span (S - {b})" ``` huffman@44133 ` 1070` ``` unfolding eq' . ``` wenzelm@53406 ` 1071` ``` from k show ?thesis ``` huffman@44133 ` 1072` ``` apply (subst eq) ``` huffman@44133 ` 1073` ``` apply (rule span_sub) ``` huffman@44133 ` 1074` ``` apply (rule span_mul) ``` huffman@44133 ` 1075` ``` apply (rule span_superset) ``` huffman@44133 ` 1076` ``` apply blast ``` huffman@44133 ` 1077` ``` apply (rule set_rev_mp) ``` huffman@44133 ` 1078` ``` apply (rule th) ``` huffman@44133 ` 1079` ``` apply (rule span_mono) ``` wenzelm@53406 ` 1080` ``` using na ``` wenzelm@53406 ` 1081` ``` apply blast ``` wenzelm@53406 ` 1082` ``` done ``` wenzelm@53406 ` 1083` ``` qed ``` huffman@44133 ` 1084` ```qed ``` huffman@44133 ` 1085` huffman@44133 ` 1086` ```lemma in_span_delete: ``` huffman@44133 ` 1087` ``` assumes a: "a \ span S" ``` wenzelm@49522 ` 1088` ``` and na: "a \ span (S-{b})" ``` huffman@44133 ` 1089` ``` shows "b \ span (insert a (S - {b}))" ``` huffman@44133 ` 1090` ``` apply (rule in_span_insert) ``` huffman@44133 ` 1091` ``` apply (rule set_rev_mp) ``` huffman@44133 ` 1092` ``` apply (rule a) ``` huffman@44133 ` 1093` ``` apply (rule span_mono) ``` huffman@44133 ` 1094` ``` apply blast ``` huffman@44133 ` 1095` ``` apply (rule na) ``` huffman@44133 ` 1096` ``` done ``` huffman@44133 ` 1097` huffman@44133 ` 1098` ```text {* Transitivity property. *} ``` huffman@44133 ` 1099` huffman@44521 ` 1100` ```lemma span_redundant: "x \ span S \ span (insert x S) = span S" ``` huffman@44521 ` 1101` ``` unfolding span_def by (rule hull_redundant) ``` huffman@44521 ` 1102` huffman@44133 ` 1103` ```lemma span_trans: ``` wenzelm@53406 ` 1104` ``` assumes x: "x \ span S" ``` wenzelm@53406 ` 1105` ``` and y: "y \ span (insert x S)" ``` huffman@44133 ` 1106` ``` shows "y \ span S" ``` huffman@44521 ` 1107` ``` using assms by (simp only: span_redundant) ``` huffman@44133 ` 1108` huffman@44133 ` 1109` ```lemma span_insert_0[simp]: "span (insert 0 S) = span S" ``` huffman@44521 ` 1110` ``` by (simp only: span_redundant span_0) ``` huffman@44133 ` 1111` huffman@44133 ` 1112` ```text {* An explicit expansion is sometimes needed. *} ``` huffman@44133 ` 1113` huffman@44133 ` 1114` ```lemma span_explicit: ``` huffman@44133 ` 1115` ``` "span P = {y. \S u. finite S \ S \ P \ setsum (\v. u v *\<^sub>R v) S = y}" ``` huffman@44133 ` 1116` ``` (is "_ = ?E" is "_ = {y. ?h y}" is "_ = {y. \S u. ?Q S u y}") ``` wenzelm@49663 ` 1117` ```proof - ``` wenzelm@53406 ` 1118` ``` { ``` wenzelm@53406 ` 1119` ``` fix x ``` wenzelm@53406 ` 1120` ``` assume x: "x \ ?E" ``` huffman@44133 ` 1121` ``` then obtain S u where fS: "finite S" and SP: "S\P" and u: "setsum (\v. u v *\<^sub>R v) S = x" ``` huffman@44133 ` 1122` ``` by blast ``` huffman@44133 ` 1123` ``` have "x \ span P" ``` huffman@44133 ` 1124` ``` unfolding u[symmetric] ``` huffman@44133 ` 1125` ``` apply (rule span_setsum[OF fS]) ``` huffman@44133 ` 1126` ``` using span_mono[OF SP] ``` wenzelm@49522 ` 1127` ``` apply (auto intro: span_superset span_mul) ``` wenzelm@53406 ` 1128` ``` done ``` wenzelm@53406 ` 1129` ``` } ``` huffman@44133 ` 1130` ``` moreover ``` huffman@44133 ` 1131` ``` have "\x \ span P. x \ ?E" ``` wenzelm@49522 ` 1132` ``` proof (rule span_induct_alt') ``` huffman@44170 ` 1133` ``` show "0 \ Collect ?h" ``` huffman@44170 ` 1134` ``` unfolding mem_Collect_eq ``` wenzelm@49522 ` 1135` ``` apply (rule exI[where x="{}"]) ``` wenzelm@49522 ` 1136` ``` apply simp ``` wenzelm@49522 ` 1137` ``` done ``` huffman@44133 ` 1138` ``` next ``` huffman@44133 ` 1139` ``` fix c x y ``` wenzelm@53406 ` 1140` ``` assume x: "x \ P" ``` wenzelm@53406 ` 1141` ``` assume hy: "y \ Collect ?h" ``` huffman@44133 ` 1142` ``` from hy obtain S u where fS: "finite S" and SP: "S\P" ``` huffman@44133 ` 1143` ``` and u: "setsum (\v. u v *\<^sub>R v) S = y" by blast ``` huffman@44133 ` 1144` ``` let ?S = "insert x S" ``` wenzelm@49522 ` 1145` ``` let ?u = "\y. if y = x then (if x \ S then u y + c else c) else u y" ``` wenzelm@53406 ` 1146` ``` from fS SP x have th0: "finite (insert x S)" "insert x S \ P" ``` wenzelm@53406 ` 1147` ``` by blast+ ``` wenzelm@53406 ` 1148` ``` have "?Q ?S ?u (c*\<^sub>R x + y)" ``` wenzelm@53406 ` 1149` ``` proof cases ``` wenzelm@53406 ` 1150` ``` assume xS: "x \ S" ``` huffman@44133 ` 1151` ``` have S1: "S = (S - {x}) \ {x}" ``` wenzelm@53406 ` 1152` ``` and Sss:"finite (S - {x})" "finite {x}" "(S -{x}) \ {x} = {}" ``` wenzelm@53406 ` 1153` ``` using xS fS by auto ``` huffman@44133 ` 1154` ``` have "setsum (\v. ?u v *\<^sub>R v) ?S =(\v\S - {x}. u v *\<^sub>R v) + (u x + c) *\<^sub>R x" ``` huffman@44133 ` 1155` ``` using xS ``` huffman@44133 ` 1156` ``` by (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]] ``` huffman@44133 ` 1157` ``` setsum_clauses(2)[OF fS] cong del: if_weak_cong) ``` huffman@44133 ` 1158` ``` also have "\ = (\v\S. u v *\<^sub>R v) + c *\<^sub>R x" ``` huffman@44133 ` 1159` ``` apply (simp add: setsum_Un_disjoint[OF Sss, unfolded S1[symmetric]]) ``` wenzelm@49522 ` 1160` ``` apply (simp add: algebra_simps) ``` wenzelm@49522 ` 1161` ``` done ``` huffman@44133 ` 1162` ``` also have "\ = c*\<^sub>R x + y" ``` huffman@44133 ` 1163` ``` by (simp add: add_commute u) ``` huffman@44133 ` 1164` ``` finally have "setsum (\v. ?u v *\<^sub>R v) ?S = c*\<^sub>R x + y" . ``` wenzelm@53406 ` 1165` ``` then show ?thesis using th0 by blast ``` wenzelm@53406 ` 1166` ``` next ``` wenzelm@53406 ` 1167` ``` assume xS: "x \ S" ``` wenzelm@49522 ` 1168` ``` have th00: "(\v\S. (if v = x then c else u v) *\<^sub>R v) = y" ``` wenzelm@49522 ` 1169` ``` unfolding u[symmetric] ``` wenzelm@49522 ` 1170` ``` apply (rule setsum_cong2) ``` wenzelm@53406 ` 1171` ``` using xS ``` wenzelm@53406 ` 1172` ``` apply auto ``` wenzelm@49522 ` 1173` ``` done ``` wenzelm@53406 ` 1174` ``` show ?thesis using fS xS th0 ``` wenzelm@53406 ` 1175` ``` by (simp add: th00 setsum_clauses add_commute cong del: if_weak_cong) ``` wenzelm@53406 ` 1176` ``` qed ``` huffman@44170 ` 1177` ``` then show "(c*\<^sub>R x + y) \ Collect ?h" ``` huffman@44170 ` 1178` ``` unfolding mem_Collect_eq ``` huffman@44133 ` 1179` ``` apply - ``` huffman@44133 ` 1180` ``` apply (rule exI[where x="?S"]) ``` wenzelm@49522 ` 1181` ``` apply (rule exI[where x="?u"]) ``` wenzelm@49522 ` 1182` ``` apply metis ``` wenzelm@49522 ` 1183` ``` done ``` huffman@44133 ` 1184` ``` qed ``` huffman@44133 ` 1185` ``` ultimately show ?thesis by blast ``` huffman@44133 ` 1186` ```qed ``` huffman@44133 ` 1187` huffman@44133 ` 1188` ```lemma dependent_explicit: ``` wenzelm@49522 ` 1189` ``` "dependent P \ (\S u. finite S \ S \ P \ (\v\S. u v \ 0 \ setsum (\v. u v *\<^sub>R v) S = 0))" ``` wenzelm@49522 ` 1190` ``` (is "?lhs = ?rhs") ``` wenzelm@49522 ` 1191` ```proof - ``` wenzelm@53406 ` 1192` ``` { ``` wenzelm@53406 ` 1193` ``` assume dP: "dependent P" ``` huffman@44133 ` 1194` ``` then obtain a S u where aP: "a \ P" and fS: "finite S" ``` huffman@44133 ` 1195` ``` and SP: "S \ P - {a}" and ua: "setsum (\v. u v *\<^sub>R v) S = a" ``` huffman@44133 ` 1196` ``` unfolding dependent_def span_explicit by blast ``` huffman@44133 ` 1197` ``` let ?S = "insert a S" ``` huffman@44133 ` 1198` ``` let ?u = "\y. if y = a then - 1 else u y" ``` huffman@44133 ` 1199` ``` let ?v = a ``` wenzelm@53406 ` 1200` ``` from aP SP have aS: "a \ S" ``` wenzelm@53406 ` 1201` ``` by blast ``` wenzelm@53406 ` 1202` ``` from fS SP aP have th0: "finite ?S" "?S \ P" "?v \ ?S" "?u ?v \ 0" ``` wenzelm@53406 ` 1203` ``` by auto ``` huffman@44133 ` 1204` ``` have s0: "setsum (\v. ?u v *\<^sub>R v) ?S = 0" ``` huffman@44133 ` 1205` ``` using fS aS ``` huffman@44133 ` 1206` ``` apply (simp add: setsum_clauses field_simps) ``` huffman@44133 ` 1207` ``` apply (subst (2) ua[symmetric]) ``` huffman@44133 ` 1208` ``` apply (rule setsum_cong2) ``` wenzelm@49522 ` 1209` ``` apply auto ``` wenzelm@49522 ` 1210` ``` done ``` huffman@44133 ` 1211` ``` with th0 have ?rhs ``` huffman@44133 ` 1212` ``` apply - ``` huffman@44133 ` 1213` ``` apply (rule exI[where x= "?S"]) ``` huffman@44133 ` 1214` ``` apply (rule exI[where x= "?u"]) ``` wenzelm@49522 ` 1215` ``` apply auto ``` wenzelm@49522 ` 1216` ``` done ``` wenzelm@49522 ` 1217` ``` } ``` huffman@44133 ` 1218` ``` moreover ``` wenzelm@53406 ` 1219` ``` { ``` wenzelm@53406 ` 1220` ``` fix S u v ``` wenzelm@49522 ` 1221` ``` assume fS: "finite S" ``` wenzelm@53406 ` 1222` ``` and SP: "S \ P" ``` wenzelm@53406 ` 1223` ``` and vS: "v \ S" ``` wenzelm@53406 ` 1224` ``` and uv: "u v \ 0" ``` wenzelm@49522 ` 1225` ``` and u: "setsum (\v. u v *\<^sub>R v) S = 0" ``` huffman@44133 ` 1226` ``` let ?a = v ``` huffman@44133 ` 1227` ``` let ?S = "S - {v}" ``` huffman@44133 ` 1228` ``` let ?u = "\i. (- u i) / u v" ``` wenzelm@53406 ` 1229` ``` have th0: "?a \ P" "finite ?S" "?S \ P" ``` wenzelm@53406 ` 1230` ``` using fS SP vS by auto ``` wenzelm@53406 ` 1231` ``` have "setsum (\v. ?u v *\<^sub>R v) ?S = ``` wenzelm@53406 ` 1232` ``` setsum (\v. (- (inverse (u ?a))) *\<^sub>R (u v *\<^sub>R v)) S - ?u v *\<^sub>R v" ``` wenzelm@49522 ` 1233` ``` using fS vS uv by (simp add: setsum_diff1 divide_inverse field_simps) ``` wenzelm@53406 ` 1234` ``` also have "\ = ?a" ``` wenzelm@53406 ` 1235` ``` unfolding scaleR_right.setsum [symmetric] u using uv by simp ``` wenzelm@53406 ` 1236` ``` finally have "setsum (\v. ?u v *\<^sub>R v) ?S = ?a" . ``` huffman@44133 ` 1237` ``` with th0 have ?lhs ``` huffman@44133 ` 1238` ``` unfolding dependent_def span_explicit ``` huffman@44133 ` 1239` ``` apply - ``` huffman@44133 ` 1240` ``` apply (rule bexI[where x= "?a"]) ``` huffman@44133 ` 1241` ``` apply (simp_all del: scaleR_minus_left) ``` huffman@44133 ` 1242` ``` apply (rule exI[where x= "?S"]) ``` wenzelm@49522 ` 1243` ``` apply (auto simp del: scaleR_minus_left) ``` wenzelm@49522 ` 1244` ``` done ``` wenzelm@49522 ` 1245` ``` } ``` huffman@44133 ` 1246` ``` ultimately show ?thesis by blast ``` huffman@44133 ` 1247` ```qed ``` huffman@44133 ` 1248` huffman@44133 ` 1249` huffman@44133 ` 1250` ```lemma span_finite: ``` huffman@44133 ` 1251` ``` assumes fS: "finite S" ``` huffman@44133 ` 1252` ``` shows "span S = {y. \u. setsum (\v. u v *\<^sub>R v) S = y}" ``` huffman@44133 ` 1253` ``` (is "_ = ?rhs") ``` wenzelm@49522 ` 1254` ```proof - ``` wenzelm@53406 ` 1255` ``` { ``` wenzelm@53406 ` 1256` ``` fix y ``` wenzelm@49711 ` 1257` ``` assume y: "y \ span S" ``` wenzelm@53406 ` 1258` ``` from y obtain S' u where fS': "finite S'" ``` wenzelm@53406 ` 1259` ``` and SS': "S' \ S" ``` wenzelm@53406 ` 1260` ``` and u: "setsum (\v. u v *\<^sub>R v) S' = y" ``` wenzelm@53406 ` 1261` ``` unfolding span_explicit by blast ``` huffman@44133 ` 1262` ``` let ?u = "\x. if x \ S' then u x else 0" ``` huffman@44133 ` 1263` ``` have "setsum (\v. ?u v *\<^sub>R v) S = setsum (\v. u v *\<^sub>R v) S'" ``` huffman@44133 ` 1264` ``` using SS' fS by (auto intro!: setsum_mono_zero_cong_right) ``` wenzelm@49522 ` 1265` ``` then have "setsum (\v. ?u v *\<^sub>R v) S = y" by (metis u) ``` wenzelm@53406 ` 1266` ``` then have "y \ ?rhs" by auto ``` wenzelm@53406 ` 1267` ``` } ``` huffman@44133 ` 1268` ``` moreover ``` wenzelm@53406 ` 1269` ``` { ``` wenzelm@53406 ` 1270` ``` fix y u ``` wenzelm@49522 ` 1271` ``` assume u: "setsum (\v. u v *\<^sub>R v) S = y" ``` wenzelm@53406 ` 1272` ``` then have "y \ span S" using fS unfolding span_explicit by auto ``` wenzelm@53406 ` 1273` ``` } ``` huffman@44133 ` 1274` ``` ultimately show ?thesis by blast ``` huffman@44133 ` 1275` ```qed ``` huffman@44133 ` 1276` huffman@44133 ` 1277` ```text {* This is useful for building a basis step-by-step. *} ``` huffman@44133 ` 1278` huffman@44133 ` 1279` ```lemma independent_insert: ``` wenzelm@53406 ` 1280` ``` "independent (insert a S) \ ``` wenzelm@53406 ` 1281` ``` (if a \ S then independent S else independent S \ a \ span S)" ``` wenzelm@53406 ` 1282` ``` (is "?lhs \ ?rhs") ``` wenzelm@53406 ` 1283` ```proof (cases "a \ S") ``` wenzelm@53406 ` 1284` ``` case True ``` wenzelm@53406 ` 1285` ``` then show ?thesis ``` wenzelm@53406 ` 1286` ``` using insert_absorb[OF True] by simp ``` wenzelm@53406 ` 1287` ```next ``` wenzelm@53406 ` 1288` ``` case False ``` wenzelm@53406 ` 1289` ``` show ?thesis ``` wenzelm@53406 ` 1290` ``` proof ``` wenzelm@53406 ` 1291` ``` assume i: ?lhs ``` wenzelm@53406 ` 1292` ``` then show ?rhs ``` wenzelm@53406 ` 1293` ``` using False ``` wenzelm@53406 ` 1294` ``` apply simp ``` wenzelm@53406 ` 1295` ``` apply (rule conjI) ``` wenzelm@53406 ` 1296` ``` apply (rule independent_mono) ``` wenzelm@53406 ` 1297` ``` apply assumption ``` wenzelm@53406 ` 1298` ``` apply blast ``` wenzelm@53406 ` 1299` ``` apply (simp add: dependent_def) ``` wenzelm@53406 ` 1300` ``` done ``` wenzelm@53406 ` 1301` ``` next ``` wenzelm@53406 ` 1302` ``` assume i: ?rhs ``` wenzelm@53406 ` 1303` ``` show ?lhs ``` wenzelm@53406 ` 1304` ``` using i False ``` wenzelm@53406 ` 1305` ``` apply simp ``` wenzelm@53406 ` 1306` ``` apply (auto simp add: dependent_def) ``` wenzelm@53406 ` 1307` ``` apply (case_tac "aa = a") ``` wenzelm@53406 ` 1308` ``` apply auto ``` wenzelm@53406 ` 1309` ``` apply (subgoal_tac "insert a S - {aa} = insert a (S - {aa})") ``` wenzelm@53406 ` 1310` ``` apply simp ``` wenzelm@53406 ` 1311` ``` apply (subgoal_tac "a \ span (insert aa (S - {aa}))") ``` wenzelm@53406 ` 1312` ``` apply (subgoal_tac "insert aa (S - {aa}) = S") ``` wenzelm@53406 ` 1313` ``` apply simp ``` wenzelm@53406 ` 1314` ``` apply blast ``` wenzelm@53406 ` 1315` ``` apply (rule in_span_insert) ``` wenzelm@53406 ` 1316` ``` apply assumption ``` wenzelm@53406 ` 1317` ``` apply blast ``` wenzelm@53406 ` 1318` ``` apply blast ``` wenzelm@53406 ` 1319` ``` done ``` wenzelm@53406 ` 1320` ``` qed ``` huffman@44133 ` 1321` ```qed ``` huffman@44133 ` 1322` huffman@44133 ` 1323` ```text {* The degenerate case of the Exchange Lemma. *} ``` huffman@44133 ` 1324` huffman@44133 ` 1325` ```lemma mem_delete: "x \ (A - {a}) \ x \ a \ x \ A" ``` huffman@44133 ` 1326` ``` by blast ``` huffman@44133 ` 1327` huffman@44133 ` 1328` ```lemma spanning_subset_independent: ``` wenzelm@49711 ` 1329` ``` assumes BA: "B \ A" ``` wenzelm@49711 ` 1330` ``` and iA: "independent A" ``` wenzelm@49522 ` 1331` ``` and AsB: "A \ span B" ``` huffman@44133 ` 1332` ``` shows "A = B" ``` huffman@44133 ` 1333` ```proof ``` wenzelm@49663 ` 1334` ``` show "B \ A" by (rule BA) ``` wenzelm@49663 ` 1335` huffman@44133 ` 1336` ``` from span_mono[OF BA] span_mono[OF AsB] ``` huffman@44133 ` 1337` ``` have sAB: "span A = span B" unfolding span_span by blast ``` huffman@44133 ` 1338` wenzelm@53406 ` 1339` ``` { ``` wenzelm@53406 ` 1340` ``` fix x ``` wenzelm@53406 ` 1341` ``` assume x: "x \ A" ``` huffman@44133 ` 1342` ``` from iA have th0: "x \ span (A - {x})" ``` huffman@44133 ` 1343` ``` unfolding dependent_def using x by blast ``` wenzelm@53406 ` 1344` ``` from x have xsA: "x \ span A" ``` wenzelm@53406 ` 1345` ``` by (blast intro: span_superset) ``` huffman@44133 ` 1346` ``` have "A - {x} \ A" by blast ``` wenzelm@53406 ` 1347` ``` then have th1: "span (A - {x}) \ span A" ``` wenzelm@53406 ` 1348` ``` by (metis span_mono) ``` wenzelm@53406 ` 1349` ``` { ``` wenzelm@53406 ` 1350` ``` assume xB: "x \ B" ``` wenzelm@53406 ` 1351` ``` from xB BA have "B \ A - {x}" ``` wenzelm@53406 ` 1352` ``` by blast ``` wenzelm@53406 ` 1353` ``` then have "span B \ span (A - {x})" ``` wenzelm@53406 ` 1354` ``` by (metis span_mono) ``` wenzelm@53406 ` 1355` ``` with th1 th0 sAB have "x \ span A" ``` wenzelm@53406 ` 1356` ``` by blast ``` wenzelm@53406 ` 1357` ``` with x have False ``` wenzelm@53406 ` 1358` ``` by (metis span_superset) ``` wenzelm@53406 ` 1359` ``` } ``` wenzelm@53406 ` 1360` ``` then have "x \ B" by blast ``` wenzelm@53406 ` 1361` ``` } ``` huffman@44133 ` 1362` ``` then show "A \ B" by blast ``` huffman@44133 ` 1363` ```qed ``` huffman@44133 ` 1364` huffman@44133 ` 1365` ```text {* The general case of the Exchange Lemma, the key to what follows. *} ``` huffman@44133 ` 1366` huffman@44133 ` 1367` ```lemma exchange_lemma: ``` wenzelm@49711 ` 1368` ``` assumes f:"finite t" ``` wenzelm@49711 ` 1369` ``` and i: "independent s" ``` wenzelm@49711 ` 1370` ``` and sp: "s \ span t" ``` wenzelm@53406 ` 1371` ``` shows "\t'. card t' = card t \ finite t' \ s \ t' \ t' \ s \ t \ s \ span t'" ``` wenzelm@49663 ` 1372` ``` using f i sp ``` wenzelm@49522 ` 1373` ```proof (induct "card (t - s)" arbitrary: s t rule: less_induct) ``` huffman@44133 ` 1374` ``` case less ``` huffman@44133 ` 1375` ``` note ft = `finite t` and s = `independent s` and sp = `s \ span t` ``` wenzelm@53406 ` 1376` ``` let ?P = "\t'. card t' = card t \ finite t' \ s \ t' \ t' \ s \ t \ s \ span t'" ``` huffman@44133 ` 1377` ``` let ?ths = "\t'. ?P t'" ``` wenzelm@53406 ` 1378` ``` { ``` wenzelm@53406 ` 1379` ``` assume st: "s \ t" ``` wenzelm@53406 ` 1380` ``` from st ft span_mono[OF st] ``` wenzelm@53406 ` 1381` ``` have ?ths ``` wenzelm@53406 ` 1382` ``` apply - ``` wenzelm@53406 ` 1383` ``` apply (rule exI[where x=t]) ``` wenzelm@49522 ` 1384` ``` apply (auto intro: span_superset) ``` wenzelm@53406 ` 1385` ``` done ``` wenzelm@53406 ` 1386` ``` } ``` huffman@44133 ` 1387` ``` moreover ``` wenzelm@53406 ` 1388` ``` { ``` wenzelm@53406 ` 1389` ``` assume st: "t \ s" ``` wenzelm@53406 ` 1390` ``` from spanning_subset_independent[OF st s sp] st ft span_mono[OF st] ``` wenzelm@53406 ` 1391` ``` have ?ths ``` wenzelm@53406 ` 1392` ``` apply - ``` wenzelm@53406 ` 1393` ``` apply (rule exI[where x=t]) ``` wenzelm@53406 ` 1394` ``` apply (auto intro: span_superset) ``` wenzelm@53406 ` 1395` ``` done ``` wenzelm@53406 ` 1396` ``` } ``` huffman@44133 ` 1397` ``` moreover ``` wenzelm@53406 ` 1398` ``` { ``` wenzelm@53406 ` 1399` ``` assume st: "\ s \ t" "\ t \ s" ``` wenzelm@53406 ` 1400` ``` from st(2) obtain b where b: "b \ t" "b \ s" ``` wenzelm@53406 ` 1401` ``` by blast ``` wenzelm@53406 ` 1402` ``` from b have "t - {b} - s \ t - s" ``` wenzelm@53406 ` 1403` ``` by blast ``` wenzelm@53406 ` 1404` ``` then have cardlt: "card (t - {b} - s) < card (t - s)" ``` wenzelm@53406 ` 1405` ``` using ft by (auto intro: psubset_card_mono) ``` wenzelm@53406 ` 1406` ``` from b ft have ct0: "card t \ 0" ``` wenzelm@53406 ` 1407` ``` by auto ``` wenzelm@53406 ` 1408` ``` have ?ths ``` wenzelm@53406 ` 1409` ``` proof cases ``` wenzelm@53406 ` 1410` ``` assume stb: "s \ span(t - {b})" ``` wenzelm@53406 ` 1411` ``` from ft have ftb: "finite (t -{b})" ``` wenzelm@53406 ` 1412` ``` by auto ``` huffman@44133 ` 1413` ``` from less(1)[OF cardlt ftb s stb] ``` wenzelm@49522 ` 1414` ``` obtain u where u: "card u = card (t-{b})" "s \ u" "u \ s \ (t - {b})" "s \ span u" ``` wenzelm@49522 ` 1415` ``` and fu: "finite u" by blast ``` huffman@44133 ` 1416` ``` let ?w = "insert b u" ``` wenzelm@53406 ` 1417` ``` have th0: "s \ insert b u" ``` wenzelm@53406 ` 1418` ``` using u by blast ``` wenzelm@53406 ` 1419` ``` from u(3) b have "u \ s \ t" ``` wenzelm@53406 ` 1420` ``` by blast ``` wenzelm@53406 ` 1421` ``` then have th1: "insert b u \ s \ t" ``` wenzelm@53406 ` 1422` ``` using u b by blast ``` wenzelm@53406 ` 1423` ``` have bu: "b \ u" ``` wenzelm@53406 ` 1424` ``` using b u by blast ``` wenzelm@53406 ` 1425` ``` from u(1) ft b have "card u = (card t - 1)" ``` wenzelm@53406 ` 1426` ``` by auto ``` wenzelm@49522 ` 1427` ``` then have th2: "card (insert b u) = card t" ``` huffman@44133 ` 1428` ``` using card_insert_disjoint[OF fu bu] ct0 by auto ``` huffman@44133 ` 1429` ``` from u(4) have "s \ span u" . ``` wenzelm@53406 ` 1430` ``` also have "\ \ span (insert b u)" ``` wenzelm@53406 ` 1431` ``` by (rule span_mono) blast ``` huffman@44133 ` 1432` ``` finally have th3: "s \ span (insert b u)" . ``` wenzelm@53406 ` 1433` ``` from th0 th1 th2 th3 fu have th: "?P ?w" ``` wenzelm@53406 ` 1434` ``` by blast ``` wenzelm@53406 ` 1435` ``` from th show ?thesis by blast ``` wenzelm@53406 ` 1436` ``` next ``` wenzelm@53406 ` 1437` ``` assume stb: "\ s \ span(t - {b})" ``` wenzelm@53406 ` 1438` ``` from stb obtain a where a: "a \ s" "a \ span (t - {b})" ``` wenzelm@53406 ` 1439` ``` by blast ``` wenzelm@53406 ` 1440` ``` have ab: "a \ b" ``` wenzelm@53406 ` 1441` ``` using a b by blast ``` wenzelm@53406 ` 1442` ``` have at: "a \ t" ``` wenzelm@53406 ` 1443` ``` using a ab span_superset[of a "t- {b}"] by auto ``` huffman@44133 ` 1444` ``` have mlt: "card ((insert a (t - {b})) - s) < card (t - s)" ``` huffman@44133 ` 1445` ``` using cardlt ft a b by auto ``` wenzelm@53406 ` 1446` ``` have ft': "finite (insert a (t - {b}))" ``` wenzelm@53406 ` 1447` ``` using ft by auto ``` wenzelm@53406 ` 1448` ``` { ``` wenzelm@53406 ` 1449` ``` fix x ``` wenzelm@53406 ` 1450` ``` assume xs: "x \ s" ``` wenzelm@53406 ` 1451` ``` have t: "t \ insert b (insert a (t - {b}))" ``` wenzelm@53406 ` 1452` ``` using b by auto ``` wenzelm@53406 ` 1453` ``` from b(1) have "b \ span t" ``` wenzelm@53406 ` 1454` ``` by (simp add: span_superset) ``` wenzelm@53406 ` 1455` ``` have bs: "b \ span (insert a (t - {b}))" ``` wenzelm@53406 ` 1456` ``` apply (rule in_span_delete) ``` wenzelm@53406 ` 1457` ``` using a sp unfolding subset_eq ``` wenzelm@53406 ` 1458` ``` apply auto ``` wenzelm@53406 ` 1459` ``` done ``` wenzelm@53406 ` 1460` ``` from xs sp have "x \ span t" ``` wenzelm@53406 ` 1461` ``` by blast ``` wenzelm@53406 ` 1462` ``` with span_mono[OF t] have x: "x \ span (insert b (insert a (t - {b})))" .. ``` wenzelm@53406 ` 1463` ``` from span_trans[OF bs x] have "x \ span (insert a (t - {b}))" . ``` wenzelm@53406 ` 1464` ``` } ``` wenzelm@53406 ` 1465` ``` then have sp': "s \ span (insert a (t - {b}))" ``` wenzelm@53406 ` 1466` ``` by blast ``` wenzelm@53406 ` 1467` ``` from less(1)[OF mlt ft' s sp'] obtain u where u: ``` wenzelm@53406 ` 1468` ``` "card u = card (insert a (t -{b}))" ``` wenzelm@53406 ` 1469` ``` "finite u" "s \ u" "u \ s \ insert a (t -{b})" ``` wenzelm@53406 ` 1470` ``` "s \ span u" by blast ``` wenzelm@53406 ` 1471` ``` from u a b ft at ct0 have "?P u" ``` wenzelm@53406 ` 1472` ``` by auto ``` wenzelm@53406 ` 1473` ``` then show ?thesis by blast ``` wenzelm@53406 ` 1474` ``` qed ``` huffman@44133 ` 1475` ``` } ``` wenzelm@49522 ` 1476` ``` ultimately show ?ths by blast ``` huffman@44133 ` 1477` ```qed ``` huffman@44133 ` 1478` huffman@44133 ` 1479` ```text {* This implies corresponding size bounds. *} ``` huffman@44133 ` 1480` huffman@44133 ` 1481` ```lemma independent_span_bound: ``` wenzelm@53406 ` 1482` ``` assumes f: "finite t" ``` wenzelm@53406 ` 1483` ``` and i: "independent s" ``` wenzelm@53406 ` 1484` ``` and sp: "s \ span t" ``` huffman@44133 ` 1485` ``` shows "finite s \ card s \ card t" ``` huffman@44133 ` 1486` ``` by (metis exchange_lemma[OF f i sp] finite_subset card_mono) ``` huffman@44133 ` 1487` huffman@44133 ` 1488` ```lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x\ (UNIV::'a::finite set)}" ``` wenzelm@49522 ` 1489` ```proof - ``` wenzelm@53406 ` 1490` ``` have eq: "{f x |x. x\ UNIV} = f ` UNIV" ``` wenzelm@53406 ` 1491` ``` by auto ``` huffman@44133 ` 1492` ``` show ?thesis unfolding eq ``` huffman@44133 ` 1493` ``` apply (rule finite_imageI) ``` huffman@44133 ` 1494` ``` apply (rule finite) ``` huffman@44133 ` 1495` ``` done ``` huffman@44133 ` 1496` ```qed ``` huffman@44133 ` 1497` wenzelm@53406 ` 1498` wenzelm@53406 ` 1499` ```subsection {* Euclidean Spaces as Typeclass *} ``` huffman@44133 ` 1500` hoelzl@50526 ` 1501` ```lemma independent_Basis: "independent Basis" ``` hoelzl@50526 ` 1502` ``` unfolding dependent_def ``` hoelzl@50526 ` 1503` ``` apply (subst span_finite) ``` hoelzl@50526 ` 1504` ``` apply simp ``` huffman@44133 ` 1505` ``` apply clarify ``` hoelzl@50526 ` 1506` ``` apply (drule_tac f="inner a" in arg_cong) ``` hoelzl@50526 ` 1507` ``` apply (simp add: inner_Basis inner_setsum_right eq_commute) ``` hoelzl@50526 ` 1508` ``` done ``` hoelzl@50526 ` 1509` hoelzl@50526 ` 1510` ```lemma span_Basis[simp]: "span Basis = (UNIV :: 'a::euclidean_space set)" ``` hoelzl@50526 ` 1511` ``` apply (subst span_finite) ``` hoelzl@50526 ` 1512` ``` apply simp ``` hoelzl@50526 ` 1513` ``` apply (safe intro!: UNIV_I) ``` hoelzl@50526 ` 1514` ``` apply (rule_tac x="inner x" in exI) ``` hoelzl@50526 ` 1515` ``` apply (simp add: euclidean_representation) ``` huffman@44133 ` 1516` ``` done ``` huffman@44133 ` 1517` hoelzl@50526 ` 1518` ```lemma in_span_Basis: "x \ span Basis" ``` hoelzl@50526 ` 1519` ``` unfolding span_Basis .. ``` hoelzl@50526 ` 1520` hoelzl@50526 ` 1521` ```lemma Basis_le_norm: "b \ Basis \ \x \ b\ \ norm x" ``` hoelzl@50526 ` 1522` ``` by (rule order_trans [OF Cauchy_Schwarz_ineq2]) simp ``` hoelzl@50526 ` 1523` hoelzl@50526 ` 1524` ```lemma norm_bound_Basis_le: "b \ Basis \ norm x \ e \ \x \ b\ \ e" ``` hoelzl@50526 ` 1525` ``` by (metis Basis_le_norm order_trans) ``` hoelzl@50526 ` 1526` hoelzl@50526 ` 1527` ```lemma norm_bound_Basis_lt: "b \ Basis \ norm x < e \ \x \ b\ < e" ``` huffman@53595 ` 1528` ``` by (metis Basis_le_norm le_less_trans) ``` hoelzl@50526 ` 1529` hoelzl@50526 ` 1530` ```lemma norm_le_l1: "norm x \ (\b\Basis. \x \ b\)" ``` hoelzl@50526 ` 1531` ``` apply (subst euclidean_representation[of x, symmetric]) ``` huffman@44176 ` 1532` ``` apply (rule order_trans[OF norm_setsum]) ``` wenzelm@49522 ` 1533` ``` apply (auto intro!: setsum_mono) ``` wenzelm@49522 ` 1534` ``` done ``` huffman@44133 ` 1535` huffman@44133 ` 1536` ```lemma setsum_norm_allsubsets_bound: ``` huffman@44133 ` 1537` ``` fixes f:: "'a \ 'n::euclidean_space" ``` wenzelm@53406 ` 1538` ``` assumes fP: "finite P" ``` wenzelm@53406 ` 1539` ``` and fPs: "\Q. Q \ P \ norm (setsum f Q) \ e" ``` hoelzl@50526 ` 1540` ``` shows "(\x\P. norm (f x)) \ 2 * real DIM('n) * e" ``` wenzelm@49522 ` 1541` ```proof - ``` hoelzl@50526 ` 1542` ``` have "(\x\P. norm (f x)) \ (\x\P. \b\Basis. \f x \ b\)" ``` hoelzl@50526 ` 1543` ``` by (rule setsum_mono) (rule norm_le_l1) ``` hoelzl@50526 ` 1544` ``` also have "(\x\P. \b\Basis. \f x \ b\) = (\b\Basis. \x\P. \f x \ b\)" ``` huffman@44133 ` 1545` ``` by (rule setsum_commute) ``` hoelzl@50526 ` 1546` ``` also have "\ \ of_nat (card (Basis :: 'n set)) * (2 * e)" ``` wenzelm@49522 ` 1547` ``` proof (rule setsum_bounded) ``` wenzelm@53406 ` 1548` ``` fix i :: 'n ``` wenzelm@53406 ` 1549` ``` assume i: "i \ Basis" ``` wenzelm@53406 ` 1550` ``` have "norm (\x\P. \f x \ i\) \ ``` hoelzl@50526 ` 1551` ``` norm ((\x\P \ - {x. f x \ i < 0}. f x) \ i) + norm ((\x\P \ {x. f x \ i < 0}. f x) \ i)" ``` hoelzl@50526 ` 1552` ``` by (simp add: abs_real_def setsum_cases[OF fP] setsum_negf uminus_add_conv_diff ``` wenzelm@53406 ` 1553` ``` norm_triangle_ineq4 inner_setsum_left del: real_norm_def) ``` wenzelm@53406 ` 1554` ``` also have "\ \ e + e" ``` wenzelm@53406 ` 1555` ``` unfolding real_norm_def ``` hoelzl@50526 ` 1556` ``` by (intro add_mono norm_bound_Basis_le i fPs) auto ``` hoelzl@50526 ` 1557` ``` finally show "(\x\P. \f x \ i\) \ 2*e" by simp ``` huffman@44133 ` 1558` ``` qed ``` hoelzl@50526 ` 1559` ``` also have "\ = 2 * real DIM('n) * e" ``` hoelzl@50526 ` 1560` ``` by (simp add: real_of_nat_def) ``` huffman@44133 ` 1561` ``` finally show ?thesis . ``` huffman@44133 ` 1562` ```qed ``` huffman@44133 ` 1563` wenzelm@53406 ` 1564` huffman@44133 ` 1565` ```subsection {* Linearity and Bilinearity continued *} ``` huffman@44133 ` 1566` huffman@44133 ` 1567` ```lemma linear_bounded: ``` huffman@44133 ` 1568` ``` fixes f:: "'a::euclidean_space \ 'b::real_normed_vector" ``` huffman@44133 ` 1569` ``` assumes lf: "linear f" ``` huffman@44133 ` 1570` ``` shows "\B. \x. norm (f x) \ B * norm x" ``` wenzelm@49522 ` 1571` ```proof - ``` hoelzl@50526 ` 1572` ``` let ?B = "\b\Basis. norm (f b)" ``` wenzelm@53406 ` 1573` ``` { ``` wenzelm@53406 ` 1574` ``` fix x :: 'a ``` hoelzl@50526 ` 1575` ``` let ?g = "\b. (x \ b) *\<^sub>R f b" ``` hoelzl@50526 ` 1576` ``` have "norm (f x) = norm (f (\b\Basis. (x \ b) *\<^sub>R b))" ``` hoelzl@50526 ` 1577` ``` unfolding euclidean_representation .. ``` hoelzl@50526 ` 1578` ``` also have "\ = norm (setsum ?g Basis)" ``` wenzelm@53406 ` 1579` ``` using linear_setsum[OF lf finite_Basis, of "\b. (x \ b) *\<^sub>R b", unfolded o_def] linear_cmul[OF lf] ``` wenzelm@53406 ` 1580` ``` by auto ``` hoelzl@50526 ` 1581` ``` finally have th0: "norm (f x) = norm (setsum ?g Basis)" . ``` wenzelm@53406 ` 1582` ``` { ``` wenzelm@53406 ` 1583` ``` fix i :: 'a ``` wenzelm@53406 ` 1584` ``` assume i: "i \ Basis" ``` hoelzl@50526 ` 1585` ``` from Basis_le_norm[OF i, of x] ``` hoelzl@50526 ` 1586` ``` have "norm (?g i) \ norm (f i) * norm x" ``` wenzelm@49663 ` 1587` ``` unfolding norm_scaleR ``` hoelzl@50526 ` 1588` ``` apply (subst mult_commute) ``` wenzelm@49663 ` 1589` ``` apply (rule mult_mono) ``` wenzelm@49663 ` 1590` ``` apply (auto simp add: field_simps) ``` wenzelm@53406 ` 1591` ``` done ``` wenzelm@53406 ` 1592` ``` } ``` hoelzl@50526 ` 1593` ``` then have th: "\b\Basis. norm (?g b) \ norm (f b) * norm x" ``` wenzelm@49522 ` 1594` ``` by metis ``` hoelzl@50526 ` 1595` ``` from setsum_norm_le[of _ ?g, OF th] ``` wenzelm@53406 ` 1596` ``` have "norm (f x) \ ?B * norm x" ``` wenzelm@53406 ` 1597` ``` unfolding th0 setsum_left_distrib by metis ``` wenzelm@53406 ` 1598` ``` } ``` huffman@44133 ` 1599` ``` then show ?thesis by blast ``` huffman@44133 ` 1600` ```qed ``` huffman@44133 ` 1601` huffman@44133 ` 1602` ```lemma linear_bounded_pos: ``` huffman@44133 ` 1603` ``` fixes f:: "'a::euclidean_space \ 'b::real_normed_vector" ``` huffman@44133 ` 1604` ``` assumes lf: "linear f" ``` huffman@44133 ` 1605` ``` shows "\B > 0. \x. norm (f x) \ B * norm x" ``` wenzelm@49663 ` 1606` ```proof - ``` huffman@44133 ` 1607` ``` from linear_bounded[OF lf] obtain B where ``` huffman@44133 ` 1608` ``` B: "\x. norm (f x) \ B * norm x" by blast ``` huffman@44133 ` 1609` ``` let ?K = "\B\ + 1" ``` huffman@44133 ` 1610` ``` have Kp: "?K > 0" by arith ``` wenzelm@53406 ` 1611` ``` { ``` wenzelm@53406 ` 1612` ``` assume C: "B < 0" ``` hoelzl@50526 ` 1613` ``` def One \ "\Basis ::'a" ``` hoelzl@50526 ` 1614` ``` then have "One \ 0" ``` hoelzl@50526 ` 1615` ``` unfolding euclidean_eq_iff[where 'a='a] ``` hoelzl@50526 ` 1616` ``` by (simp add: inner_setsum_left inner_Basis setsum_cases) ``` hoelzl@50526 ` 1617` ``` then have "norm One > 0" by auto ``` hoelzl@50526 ` 1618` ``` with C have "B * norm One < 0" ``` wenzelm@49663 ` 1619` ``` by (simp add: mult_less_0_iff) ``` hoelzl@50526 ` 1620` ``` with B[rule_format, of One] norm_ge_zero[of "f One"] ``` hoelzl@50526 ` 1621` ``` have False by simp ``` wenzelm@49663 ` 1622` ``` } ``` wenzelm@53406 ` 1623` ``` then have Bp: "B \ 0" ``` wenzelm@53406 ` 1624` ``` by (metis not_leE) ``` wenzelm@53406 ` 1625` ``` { ``` wenzelm@53406 ` 1626` ``` fix x::"'a" ``` wenzelm@49663 ` 1627` ``` have "norm (f x) \ ?K * norm x" ``` huffman@44133 ` 1628` ``` using B[rule_format, of x] norm_ge_zero[of x] norm_ge_zero[of "f x"] Bp ``` huffman@44133 ` 1629` ``` apply (auto simp add: field_simps split add: abs_split) ``` huffman@44133 ` 1630` ``` apply (erule order_trans, simp) ``` huffman@44133 ` 1631` ``` done ``` wenzelm@53406 ` 1632` ``` } ``` wenzelm@53406 ` 1633` ``` then show ?thesis ``` wenzelm@53406 ` 1634` ``` using Kp by blast ``` huffman@44133 ` 1635` ```qed ``` huffman@44133 ` 1636` huffman@44133 ` 1637` ```lemma linear_conv_bounded_linear: ``` huffman@44133 ` 1638` ``` fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" ``` huffman@44133 ` 1639` ``` shows "linear f \ bounded_linear f" ``` huffman@44133 ` 1640` ```proof ``` huffman@44133 ` 1641` ``` assume "linear f" ``` huffman@44133 ` 1642` ``` show "bounded_linear f" ``` huffman@44133 ` 1643` ``` proof ``` wenzelm@53406 ` 1644` ``` fix x y ``` wenzelm@53406 ` 1645` ``` show "f (x + y) = f x + f y" ``` huffman@53600 ` 1646` ``` using `linear f` unfolding linear_iff by simp ``` huffman@44133 ` 1647` ``` next ``` wenzelm@53406 ` 1648` ``` fix r x ``` wenzelm@53406 ` 1649` ``` show "f (scaleR r x) = scaleR r (f x)" ``` huffman@53600 ` 1650` ``` using `linear f` unfolding linear_iff by simp ``` huffman@44133 ` 1651` ``` next ``` huffman@44133 ` 1652` ``` have "\B. \x. norm (f x) \ B * norm x" ``` huffman@44133 ` 1653` ``` using `linear f` by (rule linear_bounded) ``` wenzelm@49522 ` 1654` ``` then show "\K. \x. norm (f x) \ norm x * K" ``` huffman@44133 ` 1655` ``` by (simp add: mult_commute) ``` huffman@44133 ` 1656` ``` qed ``` huffman@44133 ` 1657` ```next ``` huffman@44133 ` 1658` ``` assume "bounded_linear f" ``` huffman@44133 ` 1659` ``` then interpret f: bounded_linear f . ``` huffman@53600 ` 1660` ``` show "linear f" by (simp add: f.add f.scaleR linear_iff) ``` huffman@44133 ` 1661` ```qed ``` huffman@44133 ` 1662` wenzelm@49522 ` 1663` ```lemma bounded_linearI': ``` wenzelm@49522 ` 1664` ``` fixes f::"'a::euclidean_space \ 'b::real_normed_vector" ``` wenzelm@53406 ` 1665` ``` assumes "\x y. f (x + y) = f x + f y" ``` wenzelm@53406 ` 1666` ``` and "\c x. f (c *\<^sub>R x) = c *\<^sub>R f x" ``` wenzelm@49522 ` 1667` ``` shows "bounded_linear f" ``` wenzelm@53406 ` 1668` ``` unfolding linear_conv_bounded_linear[symmetric] ``` wenzelm@49522 ` 1669` ``` by (rule linearI[OF assms]) ``` huffman@44133 ` 1670` huffman@44133 ` 1671` ```lemma bilinear_bounded: ``` huffman@44133 ` 1672` ``` fixes h:: "'m::euclidean_space \ 'n::euclidean_space \ 'k::real_normed_vector" ``` huffman@44133 ` 1673` ``` assumes bh: "bilinear h" ``` huffman@44133 ` 1674` ``` shows "\B. \x y. norm (h x y) \ B * norm x * norm y" ``` hoelzl@50526 ` 1675` ```proof (clarify intro!: exI[of _ "\i\Basis. \j\Basis. norm (h i j)"]) ``` wenzelm@53406 ` 1676` ``` fix x :: 'm ``` wenzelm@53406 ` 1677` ``` fix y :: 'n ``` wenzelm@53406 ` 1678` ``` have "norm (h x y) = norm (h (setsum (\i. (x \ i) *\<^sub>R i) Basis) (setsum (\i. (y \ i) *\<^sub>R i) Basis))" ``` wenzelm@53406 ` 1679` ``` apply (subst euclidean_representation[where 'a='m]) ``` wenzelm@53406 ` 1680` ``` apply (subst euclidean_representation[where 'a='n]) ``` hoelzl@50526 ` 1681` ``` apply rule ``` hoelzl@50526 ` 1682` ``` done ``` wenzelm@53406 ` 1683` ``` also have "\ = norm (setsum (\ (i,j). h ((x \ i) *\<^sub>R i) ((y \ j) *\<^sub>R j)) (Basis \ Basis))" ``` hoelzl@50526 ` 1684` ``` unfolding bilinear_setsum[OF bh finite_Basis finite_Basis] .. ``` hoelzl@50526 ` 1685` ``` finally have th: "norm (h x y) = \" . ``` hoelzl@50526 ` 1686` ``` show "norm (h x y) \ (\i\Basis. \j\Basis. norm (h i j)) * norm x * norm y" ``` wenzelm@53406 ` 1687` ``` apply (auto simp add: setsum_left_distrib th setsum_cartesian_product) ``` wenzelm@53406 ` 1688` ``` apply (rule setsum_norm_le) ``` wenzelm@53406 ` 1689` ``` apply simp ``` wenzelm@53406 ` 1690` ``` apply (auto simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] ``` wenzelm@53406 ` 1691` ``` field_simps simp del: scaleR_scaleR) ``` wenzelm@53406 ` 1692` ``` apply (rule mult_mono) ``` wenzelm@53406 ` 1693` ``` apply (auto simp add: zero_le_mult_iff Basis_le_norm) ``` wenzelm@53406 ` 1694` ``` apply (rule mult_mono) ``` wenzelm@53406 ` 1695` ``` apply (auto simp add: zero_le_mult_iff Basis_le_norm) ``` wenzelm@53406 ` 1696` ``` done ``` huffman@44133 ` 1697` ```qed ``` huffman@44133 ` 1698` huffman@44133 ` 1699` ```lemma bilinear_bounded_pos: ``` huffman@44133 ` 1700` ``` fixes h:: "'a::euclidean_space \ 'b::euclidean_space \ 'c::real_normed_vector" ``` huffman@44133 ` 1701` ``` assumes bh: "bilinear h" ``` huffman@44133 ` 1702` ``` shows "\B > 0. \x y. norm (h x y) \ B * norm x * norm y" ``` wenzelm@49522 ` 1703` ```proof - ``` huffman@44133 ` 1704` ``` from bilinear_bounded[OF bh] obtain B where ``` huffman@44133 ` 1705` ``` B: "\x y. norm (h x y) \ B * norm x * norm y" by blast ``` huffman@44133 ` 1706` ``` let ?K = "\B\ + 1" ``` huffman@44133 ` 1707` ``` have Kp: "?K > 0" by arith ``` huffman@44133 ` 1708` ``` have KB: "B < ?K" by arith ``` wenzelm@53406 ` 1709` ``` { ``` wenzelm@53406 ` 1710` ``` fix x :: 'a ``` wenzelm@53406 ` 1711` ``` fix y :: 'b ``` wenzelm@53406 ` 1712` ``` from KB Kp have "B * norm x * norm y \ ?K * norm x * norm y" ``` huffman@44133 ` 1713` ``` apply - ``` huffman@44133 ` 1714` ``` apply (rule mult_right_mono, rule mult_right_mono) ``` wenzelm@49522 ` 1715` ``` apply auto ``` wenzelm@49522 ` 1716` ``` done ``` huffman@44133 ` 1717` ``` then have "norm (h x y) \ ?K * norm x * norm y" ``` wenzelm@53406 ` 1718` ``` using B[rule_format, of x y] by simp ``` wenzelm@53406 ` 1719` ``` } ``` huffman@44133 ` 1720` ``` with Kp show ?thesis by blast ``` huffman@44133 ` 1721` ```qed ``` huffman@44133 ` 1722` huffman@44133 ` 1723` ```lemma bilinear_conv_bounded_bilinear: ``` huffman@44133 ` 1724` ``` fixes h :: "'a::euclidean_space \ 'b::euclidean_space \ 'c::real_normed_vector" ``` huffman@44133 ` 1725` ``` shows "bilinear h \ bounded_bilinear h" ``` huffman@44133 ` 1726` ```proof ``` huffman@44133 ` 1727` ``` assume "bilinear h" ``` huffman@44133 ` 1728` ``` show "bounded_bilinear h" ``` huffman@44133 ` 1729` ``` proof ``` wenzelm@53406 ` 1730` ``` fix x y z ``` wenzelm@53406 ` 1731` ``` show "h (x + y) z = h x z + h y z" ``` huffman@53600 ` 1732` ``` using `bilinear h` unfolding bilinear_def linear_iff by simp ``` huffman@44133 ` 1733` ``` next ``` wenzelm@53406 ` 1734` ``` fix x y z ``` wenzelm@53406 ` 1735` ``` show "h x (y + z) = h x y + h x z" ``` huffman@53600 ` 1736` ``` using `bilinear h` unfolding bilinear_def linear_iff by simp ``` huffman@44133 ` 1737` ``` next ``` wenzelm@53406 ` 1738` ``` fix r x y ``` wenzelm@53406 ` 1739` ``` show "h (scaleR r x) y = scaleR r (h x y)" ``` huffman@53600 ` 1740` ``` using `bilinear h` unfolding bilinear_def linear_iff ``` huffman@44133 ` 1741` ``` by simp ``` huffman@44133 ` 1742` ``` next ``` wenzelm@53406 ` 1743` ``` fix r x y ``` wenzelm@53406 ` 1744` ``` show "h x (scaleR r y) = scaleR r (h x y)" ``` huffman@53600 ` 1745` ``` using `bilinear h` unfolding bilinear_def linear_iff ``` huffman@44133 ` 1746` ``` by simp ``` huffman@44133 ` 1747` ``` next ``` huffman@44133 ` 1748` ``` have "\B. \x y. norm (h x y) \ B * norm x * norm y" ``` huffman@44133 ` 1749` ``` using `bilinear h` by (rule bilinear_bounded) ``` wenzelm@49522 ` 1750` ``` then show "\K. \x y. norm (h x y) \ norm x * norm y * K" ``` huffman@44133 ` 1751` ``` by (simp add: mult_ac) ``` huffman@44133 ` 1752` ``` qed ``` huffman@44133 ` 1753` ```next ``` huffman@44133 ` 1754` ``` assume "bounded_bilinear h" ``` huffman@44133 ` 1755` ``` then interpret h: bounded_bilinear h . ``` huffman@44133 ` 1756` ``` show "bilinear h" ``` huffman@44133 ` 1757` ``` unfolding bilinear_def linear_conv_bounded_linear ``` wenzelm@49522 ` 1758` ``` using h.bounded_linear_left h.bounded_linear_right by simp ``` huffman@44133 ` 1759` ```qed ``` huffman@44133 ` 1760` wenzelm@49522 ` 1761` huffman@44133 ` 1762` ```subsection {* We continue. *} ``` huffman@44133 ` 1763` huffman@44133 ` 1764` ```lemma independent_bound: ``` huffman@44133 ` 1765` ``` fixes S:: "('a::euclidean_space) set" ``` hoelzl@50526 ` 1766` ``` shows "independent S \ finite S \ card S \ DIM('a::euclidean_space)" ``` hoelzl@50526 ` 1767` ``` using independent_span_bound[OF finite_Basis, of S] by auto ``` huffman@44133 ` 1768` wenzelm@49663 ` 1769` ```lemma dependent_biggerset: ``` wenzelm@53406 ` 1770` ``` "(finite (S::('a::euclidean_space) set) \ card S > DIM('a)) \ dependent S" ``` huffman@44133 ` 1771` ``` by (metis independent_bound not_less) ``` huffman@44133 ` 1772` huffman@44133 ` 1773` ```text {* Hence we can create a maximal independent subset. *} ``` huffman@44133 ` 1774` huffman@44133 ` 1775` ```lemma maximal_independent_subset_extend: ``` wenzelm@53406 ` 1776` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1777` ``` assumes sv: "S \ V" ``` wenzelm@49663 ` 1778` ``` and iS: "independent S" ``` huffman@44133 ` 1779` ``` shows "\B. S \ B \ B \ V \ independent B \ V \ span B" ``` huffman@44133 ` 1780` ``` using sv iS ``` wenzelm@49522 ` 1781` ```proof (induct "DIM('a) - card S" arbitrary: S rule: less_induct) ``` huffman@44133 ` 1782` ``` case less ``` huffman@44133 ` 1783` ``` note sv = `S \ V` and i = `independent S` ``` huffman@44133 ` 1784` ``` let ?P = "\B. S \ B \ B \ V \ independent B \ V \ span B" ``` huffman@44133 ` 1785` ``` let ?ths = "\x. ?P x" ``` huffman@44133 ` 1786` ``` let ?d = "DIM('a)" ``` wenzelm@53406 ` 1787` ``` show ?ths ``` wenzelm@53406 ` 1788` ``` proof (cases "V \ span S") ``` wenzelm@53406 ` 1789` ``` case True ``` wenzelm@53406 ` 1790` ``` then show ?thesis ``` wenzelm@53406 ` 1791` ``` using sv i by blast ``` wenzelm@53406 ` 1792` ``` next ``` wenzelm@53406 ` 1793` ``` case False ``` wenzelm@53406 ` 1794` ``` then obtain a where a: "a \ V" "a \ span S" ``` wenzelm@53406 ` 1795` ``` by blast ``` wenzelm@53406 ` 1796` ``` from a have aS: "a \ S" ``` wenzelm@53406 ` 1797` ``` by (auto simp add: span_superset) ``` wenzelm@53406 ` 1798` ``` have th0: "insert a S \ V" ``` wenzelm@53406 ` 1799` ``` using a sv by blast ``` huffman@44133 ` 1800` ``` from independent_insert[of a S] i a ``` wenzelm@53406 ` 1801` ``` have th1: "independent (insert a S)" ``` wenzelm@53406 ` 1802` ``` by auto ``` huffman@44133 ` 1803` ``` have mlt: "?d - card (insert a S) < ?d - card S" ``` wenzelm@49522 ` 1804` ``` using aS a independent_bound[OF th1] by auto ``` huffman@44133 ` 1805` huffman@44133 ` 1806` ``` from less(1)[OF mlt th0 th1] ``` huffman@44133 ` 1807` ``` obtain B where B: "insert a S \ B" "B \ V" "independent B" " V \ span B" ``` huffman@44133 ` 1808` ``` by blast ``` huffman@44133 ` 1809` ``` from B have "?P B" by auto ``` wenzelm@53406 ` 1810` ``` then show ?thesis by blast ``` wenzelm@53406 ` 1811` ``` qed ``` huffman@44133 ` 1812` ```qed ``` huffman@44133 ` 1813` huffman@44133 ` 1814` ```lemma maximal_independent_subset: ``` huffman@44133 ` 1815` ``` "\(B:: ('a::euclidean_space) set). B\ V \ independent B \ V \ span B" ``` wenzelm@49522 ` 1816` ``` by (metis maximal_independent_subset_extend[of "{}:: ('a::euclidean_space) set"] ``` wenzelm@49522 ` 1817` ``` empty_subsetI independent_empty) ``` huffman@44133 ` 1818` huffman@44133 ` 1819` huffman@44133 ` 1820` ```text {* Notion of dimension. *} ``` huffman@44133 ` 1821` wenzelm@53406 ` 1822` ```definition "dim V = (SOME n. \B. B \ V \ independent B \ V \ span B \ card B = n)" ``` huffman@44133 ` 1823` wenzelm@49522 ` 1824` ```lemma basis_exists: ``` wenzelm@49522 ` 1825` ``` "\B. (B :: ('a::euclidean_space) set) \ V \ independent B \ V \ span B \ (card B = dim V)" ``` wenzelm@49522 ` 1826` ``` unfolding dim_def some_eq_ex[of "\n. \B. B \ V \ independent B \ V \ span B \ (card B = n)"] ``` wenzelm@49522 ` 1827` ``` using maximal_independent_subset[of V] independent_bound ``` wenzelm@49522 ` 1828` ``` by auto ``` huffman@44133 ` 1829` huffman@44133 ` 1830` ```text {* Consequences of independence or spanning for cardinality. *} ``` huffman@44133 ` 1831` wenzelm@53406 ` 1832` ```lemma independent_card_le_dim: ``` wenzelm@53406 ` 1833` ``` fixes B :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1834` ``` assumes "B \ V" ``` wenzelm@53406 ` 1835` ``` and "independent B" ``` wenzelm@49522 ` 1836` ``` shows "card B \ dim V" ``` huffman@44133 ` 1837` ```proof - ``` huffman@44133 ` 1838` ``` from basis_exists[of V] `B \ V` ``` wenzelm@53406 ` 1839` ``` obtain B' where "independent B'" ``` wenzelm@53406 ` 1840` ``` and "B \ span B'" ``` wenzelm@53406 ` 1841` ``` and "card B' = dim V" ``` wenzelm@53406 ` 1842` ``` by blast ``` huffman@44133 ` 1843` ``` with independent_span_bound[OF _ `independent B` `B \ span B'`] independent_bound[of B'] ``` huffman@44133 ` 1844` ``` show ?thesis by auto ``` huffman@44133 ` 1845` ```qed ``` huffman@44133 ` 1846` wenzelm@49522 ` 1847` ```lemma span_card_ge_dim: ``` wenzelm@53406 ` 1848` ``` fixes B :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1849` ``` shows "B \ V \ V \ span B \ finite B \ dim V \ card B" ``` huffman@44133 ` 1850` ``` by (metis basis_exists[of V] independent_span_bound subset_trans) ``` huffman@44133 ` 1851` huffman@44133 ` 1852` ```lemma basis_card_eq_dim: ``` wenzelm@53406 ` 1853` ``` fixes V :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1854` ``` shows "B \ V \ V \ span B \ independent B \ finite B \ card B = dim V" ``` huffman@44133 ` 1855` ``` by (metis order_eq_iff independent_card_le_dim span_card_ge_dim independent_bound) ``` huffman@44133 ` 1856` wenzelm@53406 ` 1857` ```lemma dim_unique: ``` wenzelm@53406 ` 1858` ``` fixes B :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1859` ``` shows "B \ V \ V \ span B \ independent B \ card B = n \ dim V = n" ``` huffman@44133 ` 1860` ``` by (metis basis_card_eq_dim) ``` huffman@44133 ` 1861` huffman@44133 ` 1862` ```text {* More lemmas about dimension. *} ``` huffman@44133 ` 1863` wenzelm@53406 ` 1864` ```lemma dim_UNIV: "dim (UNIV :: 'a::euclidean_space set) = DIM('a)" ``` hoelzl@50526 ` 1865` ``` using independent_Basis ``` hoelzl@50526 ` 1866` ``` by (intro dim_unique[of Basis]) auto ``` huffman@44133 ` 1867` huffman@44133 ` 1868` ```lemma dim_subset: ``` wenzelm@53406 ` 1869` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1870` ``` shows "S \ T \ dim S \ dim T" ``` huffman@44133 ` 1871` ``` using basis_exists[of T] basis_exists[of S] ``` huffman@44133 ` 1872` ``` by (metis independent_card_le_dim subset_trans) ``` huffman@44133 ` 1873` wenzelm@53406 ` 1874` ```lemma dim_subset_UNIV: ``` wenzelm@53406 ` 1875` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1876` ``` shows "dim S \ DIM('a)" ``` huffman@44133 ` 1877` ``` by (metis dim_subset subset_UNIV dim_UNIV) ``` huffman@44133 ` 1878` huffman@44133 ` 1879` ```text {* Converses to those. *} ``` huffman@44133 ` 1880` huffman@44133 ` 1881` ```lemma card_ge_dim_independent: ``` wenzelm@53406 ` 1882` ``` fixes B :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1883` ``` assumes BV: "B \ V" ``` wenzelm@53406 ` 1884` ``` and iB: "independent B" ``` wenzelm@53406 ` 1885` ``` and dVB: "dim V \ card B" ``` huffman@44133 ` 1886` ``` shows "V \ span B" ``` wenzelm@53406 ` 1887` ```proof ``` wenzelm@53406 ` 1888` ``` fix a ``` wenzelm@53406 ` 1889` ``` assume aV: "a \ V" ``` wenzelm@53406 ` 1890` ``` { ``` wenzelm@53406 ` 1891` ``` assume aB: "a \ span B" ``` wenzelm@53406 ` 1892` ``` then have iaB: "independent (insert a B)" ``` wenzelm@53406 ` 1893` ``` using iB aV BV by (simp add: independent_insert) ``` wenzelm@53406 ` 1894` ``` from aV BV have th0: "insert a B \ V" ``` wenzelm@53406 ` 1895` ``` by blast ``` wenzelm@53406 ` 1896` ``` from aB have "a \B" ``` wenzelm@53406 ` 1897` ``` by (auto simp add: span_superset) ``` wenzelm@53406 ` 1898` ``` with independent_card_le_dim[OF th0 iaB] dVB independent_bound[OF iB] ``` wenzelm@53406 ` 1899` ``` have False by auto ``` wenzelm@53406 ` 1900` ``` } ``` wenzelm@53406 ` 1901` ``` then show "a \ span B" by blast ``` huffman@44133 ` 1902` ```qed ``` huffman@44133 ` 1903` huffman@44133 ` 1904` ```lemma card_le_dim_spanning: ``` wenzelm@49663 ` 1905` ``` assumes BV: "(B:: ('a::euclidean_space) set) \ V" ``` wenzelm@49663 ` 1906` ``` and VB: "V \ span B" ``` wenzelm@49663 ` 1907` ``` and fB: "finite B" ``` wenzelm@49663 ` 1908` ``` and dVB: "dim V \ card B" ``` huffman@44133 ` 1909` ``` shows "independent B" ``` wenzelm@49522 ` 1910` ```proof - ``` wenzelm@53406 ` 1911` ``` { ``` wenzelm@53406 ` 1912` ``` fix a ``` wenzelm@53406 ` 1913` ``` assume a: "a \ B" "a \ span (B -{a})" ``` wenzelm@53406 ` 1914` ``` from a fB have c0: "card B \ 0" ``` wenzelm@53406 ` 1915` ``` by auto ``` wenzelm@53406 ` 1916` ``` from a fB have cb: "card (B -{a}) = card B - 1" ``` wenzelm@53406 ` 1917` ``` by auto ``` wenzelm@53406 ` 1918` ``` from BV a have th0: "B -{a} \ V" ``` wenzelm@53406 ` 1919` ``` by blast ``` wenzelm@53406 ` 1920` ``` { ``` wenzelm@53406 ` 1921` ``` fix x ``` wenzelm@53406 ` 1922` ``` assume x: "x \ V" ``` wenzelm@53406 ` 1923` ``` from a have eq: "insert a (B -{a}) = B" ``` wenzelm@53406 ` 1924` ``` by blast ``` wenzelm@53406 ` 1925` ``` from x VB have x': "x \ span B" ``` wenzelm@53406 ` 1926` ``` by blast ``` huffman@44133 ` 1927` ``` from span_trans[OF a(2), unfolded eq, OF x'] ``` wenzelm@53406 ` 1928` ``` have "x \ span (B -{a})" . ``` wenzelm@53406 ` 1929` ``` } ``` wenzelm@53406 ` 1930` ``` then have th1: "V \ span (B -{a})" ``` wenzelm@53406 ` 1931` ``` by blast ``` wenzelm@53406 ` 1932` ``` have th2: "finite (B -{a})" ``` wenzelm@53406 ` 1933` ``` using fB by auto ``` huffman@44133 ` 1934` ``` from span_card_ge_dim[OF th0 th1 th2] ``` huffman@44133 ` 1935` ``` have c: "dim V \ card (B -{a})" . ``` wenzelm@53406 ` 1936` ``` from c c0 dVB cb have False by simp ``` wenzelm@53406 ` 1937` ``` } ``` wenzelm@53406 ` 1938` ``` then show ?thesis ``` wenzelm@53406 ` 1939` ``` unfolding dependent_def by blast ``` huffman@44133 ` 1940` ```qed ``` huffman@44133 ` 1941` wenzelm@53406 ` 1942` ```lemma card_eq_dim: ``` wenzelm@53406 ` 1943` ``` fixes B :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1944` ``` shows "B \ V \ card B = dim V \ finite B \ independent B \ V \ span B" ``` wenzelm@49522 ` 1945` ``` by (metis order_eq_iff card_le_dim_spanning card_ge_dim_independent) ``` huffman@44133 ` 1946` huffman@44133 ` 1947` ```text {* More general size bound lemmas. *} ``` huffman@44133 ` 1948` huffman@44133 ` 1949` ```lemma independent_bound_general: ``` wenzelm@53406 ` 1950` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1951` ``` shows "independent S \ finite S \ card S \ dim S" ``` huffman@44133 ` 1952` ``` by (metis independent_card_le_dim independent_bound subset_refl) ``` huffman@44133 ` 1953` wenzelm@49522 ` 1954` ```lemma dependent_biggerset_general: ``` wenzelm@53406 ` 1955` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1956` ``` shows "(finite S \ card S > dim S) \ dependent S" ``` huffman@44133 ` 1957` ``` using independent_bound_general[of S] by (metis linorder_not_le) ``` huffman@44133 ` 1958` wenzelm@53406 ` 1959` ```lemma dim_span: ``` wenzelm@53406 ` 1960` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1961` ``` shows "dim (span S) = dim S" ``` wenzelm@49522 ` 1962` ```proof - ``` huffman@44133 ` 1963` ``` have th0: "dim S \ dim (span S)" ``` huffman@44133 ` 1964` ``` by (auto simp add: subset_eq intro: dim_subset span_superset) ``` huffman@44133 ` 1965` ``` from basis_exists[of S] ``` wenzelm@53406 ` 1966` ``` obtain B where B: "B \ S" "independent B" "S \ span B" "card B = dim S" ``` wenzelm@53406 ` 1967` ``` by blast ``` wenzelm@53406 ` 1968` ``` from B have fB: "finite B" "card B = dim S" ``` wenzelm@53406 ` 1969` ``` using independent_bound by blast+ ``` wenzelm@53406 ` 1970` ``` have bSS: "B \ span S" ``` wenzelm@53406 ` 1971` ``` using B(1) by (metis subset_eq span_inc) ``` wenzelm@53406 ` 1972` ``` have sssB: "span S \ span B" ``` wenzelm@53406 ` 1973` ``` using span_mono[OF B(3)] by (simp add: span_span) ``` huffman@44133 ` 1974` ``` from span_card_ge_dim[OF bSS sssB fB(1)] th0 show ?thesis ``` wenzelm@49522 ` 1975` ``` using fB(2) by arith ``` huffman@44133 ` 1976` ```qed ``` huffman@44133 ` 1977` wenzelm@53406 ` 1978` ```lemma subset_le_dim: ``` wenzelm@53406 ` 1979` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 1980` ``` shows "S \ span T \ dim S \ dim T" ``` huffman@44133 ` 1981` ``` by (metis dim_span dim_subset) ``` huffman@44133 ` 1982` wenzelm@53406 ` 1983` ```lemma span_eq_dim: ``` wenzelm@53406 ` 1984` ``` fixes S:: "'a::euclidean_space set" ``` wenzelm@53406 ` 1985` ``` shows "span S = span T \ dim S = dim T" ``` huffman@44133 ` 1986` ``` by (metis dim_span) ``` huffman@44133 ` 1987` huffman@44133 ` 1988` ```lemma spans_image: ``` wenzelm@49663 ` 1989` ``` assumes lf: "linear f" ``` wenzelm@49663 ` 1990` ``` and VB: "V \ span B" ``` huffman@44133 ` 1991` ``` shows "f ` V \ span (f ` B)" ``` wenzelm@49522 ` 1992` ``` unfolding span_linear_image[OF lf] by (metis VB image_mono) ``` huffman@44133 ` 1993` huffman@44133 ` 1994` ```lemma dim_image_le: ``` huffman@44133 ` 1995` ``` fixes f :: "'a::euclidean_space \ 'b::euclidean_space" ``` wenzelm@49663 ` 1996` ``` assumes lf: "linear f" ``` wenzelm@49663 ` 1997` ``` shows "dim (f ` S) \ dim (S)" ``` wenzelm@49522 ` 1998` ```proof - ``` huffman@44133 ` 1999` ``` from basis_exists[of S] obtain B where ``` huffman@44133 ` 2000` ``` B: "B \ S" "independent B" "S \ span B" "card B = dim S" by blast ``` wenzelm@53406 ` 2001` ``` from B have fB: "finite B" "card B = dim S" ``` wenzelm@53406 ` 2002` ``` using independent_bound by blast+ ``` huffman@44133 ` 2003` ``` have "dim (f ` S) \ card (f ` B)" ``` huffman@44133 ` 2004` ``` apply (rule span_card_ge_dim) ``` wenzelm@53406 ` 2005` ``` using lf B fB ``` wenzelm@53406 ` 2006` ``` apply (auto simp add: span_linear_image spans_image subset_image_iff) ``` wenzelm@49522 ` 2007` ``` done ``` wenzelm@53406 ` 2008` ``` also have "\ \ dim S" ``` wenzelm@53406 ` 2009` ``` using card_image_le[OF fB(1)] fB by simp ``` huffman@44133 ` 2010` ``` finally show ?thesis . ``` huffman@44133 ` 2011` ```qed ``` huffman@44133 ` 2012` huffman@44133 ` 2013` ```text {* Relation between bases and injectivity/surjectivity of map. *} ``` huffman@44133 ` 2014` huffman@44133 ` 2015` ```lemma spanning_surjective_image: ``` huffman@44133 ` 2016` ``` assumes us: "UNIV \ span S" ``` wenzelm@53406 ` 2017` ``` and lf: "linear f" ``` wenzelm@53406 ` 2018` ``` and sf: "surj f" ``` huffman@44133 ` 2019` ``` shows "UNIV \ span (f ` S)" ``` wenzelm@49663 ` 2020` ```proof - ``` wenzelm@53406 ` 2021` ``` have "UNIV \ f ` UNIV" ``` wenzelm@53406 ` 2022` ``` using sf by (auto simp add: surj_def) ``` wenzelm@53406 ` 2023` ``` also have " \ \ span (f ` S)" ``` wenzelm@53406 ` 2024` ``` using spans_image[OF lf us] . ``` wenzelm@53406 ` 2025` ``` finally show ?thesis . ``` huffman@44133 ` 2026` ```qed ``` huffman@44133 ` 2027` huffman@44133 ` 2028` ```lemma independent_injective_image: ``` wenzelm@49663 ` 2029` ``` assumes iS: "independent S" ``` wenzelm@49663 ` 2030` ``` and lf: "linear f" ``` wenzelm@49663 ` 2031` ``` and fi: "inj f" ``` huffman@44133 ` 2032` ``` shows "independent (f ` S)" ``` wenzelm@49663 ` 2033` ```proof - ``` wenzelm@53406 ` 2034` ``` { ``` wenzelm@53406 ` 2035` ``` fix a ``` wenzelm@49663 ` 2036` ``` assume a: "a \ S" "f a \ span (f ` S - {f a})" ``` wenzelm@53406 ` 2037` ``` have eq: "f ` S - {f a} = f ` (S - {a})" ``` wenzelm@53406 ` 2038` ``` using fi by (auto simp add: inj_on_def) ``` huffman@44133 ` 2039` ``` from a have "f a \ f ` span (S -{a})" ``` wenzelm@53406 ` 2040` ``` unfolding eq span_linear_image[OF lf, of "S - {a}"] by blast ``` wenzelm@53406 ` 2041` ``` then have "a \ span (S -{a})" ``` wenzelm@53406 ` 2042` ``` using fi by (auto simp add: inj_on_def) ``` wenzelm@53406 ` 2043` ``` with a(1) iS have False ``` wenzelm@53406 ` 2044` ``` by (simp add: dependent_def) ``` wenzelm@53406 ` 2045` ``` } ``` wenzelm@53406 ` 2046` ``` then show ?thesis ``` wenzelm@53406 ` 2047` ``` unfolding dependent_def by blast ``` huffman@44133 ` 2048` ```qed ``` huffman@44133 ` 2049` huffman@44133 ` 2050` ```text {* Picking an orthogonal replacement for a spanning set. *} ``` huffman@44133 ` 2051` wenzelm@53406 ` 2052` ```(* FIXME : Move to some general theory ?*) ``` huffman@44133 ` 2053` ```definition "pairwise R S \ (\x \ S. \y\ S. x\y \ R x y)" ``` huffman@44133 ` 2054` wenzelm@53406 ` 2055` ```lemma vector_sub_project_orthogonal: ``` wenzelm@53406 ` 2056` ``` fixes b x :: "'a::euclidean_space" ``` wenzelm@53406 ` 2057` ``` shows "b \ (x - ((b \ x) / (b \ b)) *\<^sub>R b) = 0" ``` huffman@44133 ` 2058` ``` unfolding inner_simps by auto ``` huffman@44133 ` 2059` huffman@44528 ` 2060` ```lemma pairwise_orthogonal_insert: ``` huffman@44528 ` 2061` ``` assumes "pairwise orthogonal S" ``` wenzelm@49522 ` 2062` ``` and "\y. y \ S \ orthogonal x y" ``` huffman@44528 ` 2063` ``` shows "pairwise orthogonal (insert x S)" ``` huffman@44528 ` 2064` ``` using assms unfolding pairwise_def ``` huffman@44528 ` 2065` ``` by (auto simp add: orthogonal_commute) ``` huffman@44528 ` 2066` huffman@44133 ` 2067` ```lemma basis_orthogonal: ``` wenzelm@53406 ` 2068` ``` fixes B :: "'a::real_inner set" ``` huffman@44133 ` 2069` ``` assumes fB: "finite B" ``` huffman@44133 ` 2070` ``` shows "\C. finite C \ card C \ card B \ span C = span B \ pairwise orthogonal C" ``` huffman@44133 ` 2071` ``` (is " \C. ?P B C") ``` wenzelm@49522 ` 2072` ``` using fB ``` wenzelm@49522 ` 2073` ```proof (induct rule: finite_induct) ``` wenzelm@49522 ` 2074` ``` case empty ``` wenzelm@53406 ` 2075` ``` then show ?case ``` wenzelm@53406 ` 2076` ``` apply (rule exI[where x="{}"]) ``` wenzelm@53406 ` 2077` ``` apply (auto simp add: pairwise_def) ``` wenzelm@53406 ` 2078` ``` done ``` huffman@44133 ` 2079` ```next ``` wenzelm@49522 ` 2080` ``` case (insert a B) ``` huffman@44133 ` 2081` ``` note fB = `finite B` and aB = `a \ B` ``` huffman@44133 ` 2082` ``` from `\C. finite C \ card C \ card B \ span C = span B \ pairwise orthogonal C` ``` huffman@44133 ` 2083` ``` obtain C where C: "finite C" "card C \ card B" ``` huffman@44133 ` 2084` ``` "span C = span B" "pairwise orthogonal C" by blast ``` huffman@44133 ` 2085` ``` let ?a = "a - setsum (\x. (x \ a / (x \ x)) *\<^sub>R x) C" ``` huffman@44133 ` 2086` ``` let ?C = "insert ?a C" ``` wenzelm@53406 ` 2087` ``` from C(1) have fC: "finite ?C" ``` wenzelm@53406 ` 2088` ``` by simp ``` wenzelm@49522 ` 2089` ``` from fB aB C(1,2) have cC: "card ?C \ card (insert a B)" ``` wenzelm@49522 ` 2090` ``` by (simp add: card_insert_if) ``` wenzelm@53406 ` 2091` ``` { ``` wenzelm@53406 ` 2092` ``` fix x k ``` wenzelm@49522 ` 2093` ``` have th0: "\(a::'a) b c. a - (b - c) = c + (a - b)" ``` wenzelm@49522 ` 2094` ``` by (simp add: field_simps) ``` huffman@44133 ` 2095` ``` have "x - k *\<^sub>R (a - (\x\C. (x \ a / (x \ x)) *\<^sub>R x)) \ span C \ x - k *\<^sub>R a \ span C" ``` huffman@44133 ` 2096` ``` apply (simp only: scaleR_right_diff_distrib th0) ``` huffman@44133 ` 2097` ``` apply (rule span_add_eq) ``` huffman@44133 ` 2098` ``` apply (rule span_mul) ``` huffman@44133 ` 2099` ``` apply (rule span_setsum[OF C(1)]) ``` huffman@44133 ` 2100` ``` apply clarify ``` huffman@44133 ` 2101` ``` apply (rule span_mul) ``` wenzelm@49522 ` 2102` ``` apply (rule span_superset) ``` wenzelm@49522 ` 2103` ``` apply assumption ``` wenzelm@53406 ` 2104` ``` done ``` wenzelm@53406 ` 2105` ``` } ``` huffman@44133 ` 2106` ``` then have SC: "span ?C = span (insert a B)" ``` huffman@44133 ` 2107` ``` unfolding set_eq_iff span_breakdown_eq C(3)[symmetric] by auto ``` wenzelm@53406 ` 2108` ``` { ``` wenzelm@53406 ` 2109` ``` fix y ``` wenzelm@53406 ` 2110` ``` assume yC: "y \ C" ``` wenzelm@53406 ` 2111` ``` then have Cy: "C = insert y (C - {y})" ``` wenzelm@53406 ` 2112` ``` by blast ``` wenzelm@53406 ` 2113` ``` have fth: "finite (C - {y})" ``` wenzelm@53406 ` 2114` ``` using C by simp ``` huffman@44528 ` 2115` ``` have "orthogonal ?a y" ``` huffman@44528 ` 2116` ``` unfolding orthogonal_def ``` huffman@44528 ` 2117` ``` unfolding inner_diff inner_setsum_left diff_eq_0_iff_eq ``` huffman@44528 ` 2118` ``` unfolding setsum_diff1' [OF `finite C` `y \ C`] ``` huffman@44528 ` 2119` ``` apply (clarsimp simp add: inner_commute[of y a]) ``` huffman@44528 ` 2120` ``` apply (rule setsum_0') ``` huffman@44528 ` 2121` ``` apply clarsimp ``` huffman@44528 ` 2122` ``` apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format]) ``` wenzelm@53406 ` 2123` ``` using `y \ C` by auto ``` wenzelm@53406 ` 2124` ``` } ``` huffman@44528 ` 2125` ``` with `pairwise orthogonal C` have CPO: "pairwise orthogonal ?C" ``` huffman@44528 ` 2126` ``` by (rule pairwise_orthogonal_insert) ``` wenzelm@53406 ` 2127` ``` from fC cC SC CPO have "?P (insert a B) ?C" ``` wenzelm@53406 ` 2128` ``` by blast ``` huffman@44133 ` 2129` ``` then show ?case by blast ``` huffman@44133 ` 2130` ```qed ``` huffman@44133 ` 2131` huffman@44133 ` 2132` ```lemma orthogonal_basis_exists: ``` huffman@44133 ` 2133` ``` fixes V :: "('a::euclidean_space) set" ``` huffman@44133 ` 2134` ``` shows "\B. independent B \ B \ span V \ V \ span B \ (card B = dim V) \ pairwise orthogonal B" ``` wenzelm@49663 ` 2135` ```proof - ``` wenzelm@49522 ` 2136` ``` from basis_exists[of V] obtain B where ``` wenzelm@53406 ` 2137` ``` B: "B \ V" "independent B" "V \ span B" "card B = dim V" ``` wenzelm@53406 ` 2138` ``` by blast ``` wenzelm@53406 ` 2139` ``` from B have fB: "finite B" "card B = dim V" ``` wenzelm@53406 ` 2140` ``` using independent_bound by auto ``` huffman@44133 ` 2141` ``` from basis_orthogonal[OF fB(1)] obtain C where ``` wenzelm@53406 ` 2142` ``` C: "finite C" "card C \ card B" "span C = span B" "pairwise orthogonal C" ``` wenzelm@53406 ` 2143` ``` by blast ``` wenzelm@53406 ` 2144` ``` from C B have CSV: "C \ span V" ``` wenzelm@53406 ` 2145` ``` by (metis span_inc span_mono subset_trans) ``` wenzelm@53406 ` 2146` ``` from span_mono[OF B(3)] C have SVC: "span V \ span C" ``` wenzelm@53406 ` 2147` ``` by (simp add: span_span) ``` huffman@44133 ` 2148` ``` from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB ``` wenzelm@53406 ` 2149` ``` have iC: "independent C" ``` huffman@44133 ` 2150` ``` by (simp add: dim_span) ``` wenzelm@53406 ` 2151` ``` from C fB have "card C \ dim V" ``` wenzelm@53406 ` 2152` ``` by simp ``` wenzelm@53406 ` 2153` ``` moreover have "dim V \ card C" ``` wenzelm@53406 ` 2154` ``` using span_card_ge_dim[OF CSV SVC C(1)] ``` wenzelm@53406 ` 2155` ``` by (simp add: dim_span) ``` wenzelm@53406 ` 2156` ``` ultimately have CdV: "card C = dim V" ``` wenzelm@53406 ` 2157` ``` using C(1) by simp ``` wenzelm@53406 ` 2158` ``` from C B CSV CdV iC show ?thesis ``` wenzelm@53406 ` 2159` ``` by auto ``` huffman@44133 ` 2160` ```qed ``` huffman@44133 ` 2161` huffman@44133 ` 2162` ```lemma span_eq: "span S = span T \ S \ span T \ T \ span S" ``` huffman@44133 ` 2163` ``` using span_inc[unfolded subset_eq] using span_mono[of T "span S"] span_mono[of S "span T"] ``` wenzelm@49522 ` 2164` ``` by (auto simp add: span_span) ``` huffman@44133 ` 2165` huffman@44133 ` 2166` ```text {* Low-dimensional subset is in a hyperplane (weak orthogonal complement). *} ``` huffman@44133 ` 2167` wenzelm@49522 ` 2168` ```lemma span_not_univ_orthogonal: ``` wenzelm@53406 ` 2169` ``` fixes S :: "'a::euclidean_space set" ``` huffman@44133 ` 2170` ``` assumes sU: "span S \ UNIV" ``` huffman@44133 ` 2171` ``` shows "\(a::'a). a \0 \ (\x \ span S. a \ x = 0)" ``` wenzelm@49522 ` 2172` ```proof - ``` wenzelm@53406 ` 2173` ``` from sU obtain a where a: "a \ span S" ``` wenzelm@53406 ` 2174` ``` by blast ``` huffman@44133 ` 2175` ``` from orthogonal_basis_exists obtain B where ``` huffman@44133 ` 2176` ``` B: "independent B" "B \ span S" "S \ span B" "card B = dim S" "pairwise orthogonal B" ``` huffman@44133 ` 2177` ``` by blast ``` wenzelm@53406 ` 2178` ``` from B have fB: "finite B" "card B = dim S" ``` wenzelm@53406 ` 2179` ``` using independent_bound by auto ``` huffman@44133 ` 2180` ``` from span_mono[OF B(2)] span_mono[OF B(3)] ``` wenzelm@53406 ` 2181` ``` have sSB: "span S = span B" ``` wenzelm@53406 ` 2182` ``` by (simp add: span_span) ``` huffman@44133 ` 2183` ``` let ?a = "a - setsum (\b. (a \ b / (b \ b)) *\<^sub>R b) B" ``` huffman@44133 ` 2184` ``` have "setsum (\b. (a \ b / (b \ b)) *\<^sub>R b) B \ span S" ``` huffman@44133 ` 2185` ``` unfolding sSB ``` huffman@44133 ` 2186` ``` apply (rule span_setsum[OF fB(1)]) ``` huffman@44133 ` 2187` ``` apply clarsimp ``` huffman@44133 ` 2188` ``` apply (rule span_mul) ``` wenzelm@49522 ` 2189` ``` apply (rule span_superset) ``` wenzelm@49522 ` 2190` ``` apply assumption ``` wenzelm@49522 ` 2191` ``` done ``` wenzelm@53406 ` 2192` ``` with a have a0:"?a \ 0" ``` wenzelm@53406 ` 2193` ``` by auto ``` huffman@44133 ` 2194` ``` have "\x\span B. ?a \ x = 0" ``` wenzelm@49522 ` 2195` ``` proof (rule span_induct') ``` wenzelm@49522 ` 2196` ``` show "subspace {x. ?a \ x = 0}" ``` wenzelm@49522 ` 2197` ``` by (auto simp add: subspace_def inner_add) ``` wenzelm@49522 ` 2198` ``` next ``` wenzelm@53406 ` 2199` ``` { ``` wenzelm@53406 ` 2200` ``` fix x ``` wenzelm@53406 ` 2201` ``` assume x: "x \ B" ``` wenzelm@53406 ` 2202` ``` from x have B': "B = insert x (B - {x})" ``` wenzelm@53406 ` 2203` ``` by blast ``` wenzelm@53406 ` 2204` ``` have fth: "finite (B - {x})" ``` wenzelm@53406 ` 2205` ``` using fB by simp ``` huffman@44133 ` 2206` ``` have "?a \ x = 0" ``` wenzelm@53406 ` 2207` ``` apply (subst B') ``` wenzelm@53406 ` 2208` ``` using fB fth ``` huffman@44133 ` 2209` ``` unfolding setsum_clauses(2)[OF fth] ``` huffman@44133 ` 2210` ``` apply simp unfolding inner_simps ``` huffman@44527 ` 2211` ``` apply (clarsimp simp add: inner_add inner_setsum_left) ``` huffman@44133 ` 2212` ``` apply (rule setsum_0', rule ballI) ``` huffman@44133 ` 2213` ``` unfolding inner_commute ``` wenzelm@49711 ` 2214` ``` apply (auto simp add: x field_simps ``` wenzelm@49711 ` 2215` ``` intro: B(5)[unfolded pairwise_def orthogonal_def, rule_format]) ``` wenzelm@53406 ` 2216` ``` done ``` wenzelm@53406 ` 2217` ``` } ``` wenzelm@53406 ` 2218` ``` then show "\x \ B. ?a \ x = 0" ``` wenzelm@53406 ` 2219` ``` by blast ``` huffman@44133 ` 2220` ``` qed ``` wenzelm@53406 ` 2221` ``` with a0 show ?thesis ``` wenzelm@53406 ` 2222` ``` unfolding sSB by (auto intro: exI[where x="?a"]) ``` huffman@44133 ` 2223` ```qed ``` huffman@44133 ` 2224` huffman@44133 ` 2225` ```lemma span_not_univ_subset_hyperplane: ``` wenzelm@53406 ` 2226` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 2227` ``` assumes SU: "span S \ UNIV" ``` huffman@44133 ` 2228` ``` shows "\ a. a \0 \ span S \ {x. a \ x = 0}" ``` huffman@44133 ` 2229` ``` using span_not_univ_orthogonal[OF SU] by auto ``` huffman@44133 ` 2230` wenzelm@49663 ` 2231` ```lemma lowdim_subset_hyperplane: ``` wenzelm@53406 ` 2232` ``` fixes S :: "'a::euclidean_space set" ``` huffman@44133 ` 2233` ``` assumes d: "dim S < DIM('a)" ``` huffman@44133 ` 2234` ``` shows "\(a::'a). a \ 0 \ span S \ {x. a \ x = 0}" ``` wenzelm@49522 ` 2235` ```proof - ``` wenzelm@53406 ` 2236` ``` { ``` wenzelm@53406 ` 2237` ``` assume "span S = UNIV" ``` wenzelm@53406 ` 2238` ``` then have "dim (span S) = dim (UNIV :: ('a) set)" ``` wenzelm@53406 ` 2239` ``` by simp ``` wenzelm@53406 ` 2240` ``` then have "dim S = DIM('a)" ``` wenzelm@53406 ` 2241` ``` by (simp add: dim_span dim_UNIV) ``` wenzelm@53406 ` 2242` ``` with d have False by arith ``` wenzelm@53406 ` 2243` ``` } ``` wenzelm@53406 ` 2244` ``` then have th: "span S \ UNIV" ``` wenzelm@53406 ` 2245` ``` by blast ``` huffman@44133 ` 2246` ``` from span_not_univ_subset_hyperplane[OF th] show ?thesis . ``` huffman@44133 ` 2247` ```qed ``` huffman@44133 ` 2248` huffman@44133 ` 2249` ```text {* We can extend a linear basis-basis injection to the whole set. *} ``` huffman@44133 ` 2250` huffman@44133 ` 2251` ```lemma linear_indep_image_lemma: ``` wenzelm@49663 ` 2252` ``` assumes lf: "linear f" ``` wenzelm@49663 ` 2253` ``` and fB: "finite B" ``` wenzelm@49522 ` 2254` ``` and ifB: "independent (f ` B)" ``` wenzelm@49663 ` 2255` ``` and fi: "inj_on f B" ``` wenzelm@49663 ` 2256` ``` and xsB: "x \ span B" ``` wenzelm@49522 ` 2257` ``` and fx: "f x = 0" ``` huffman@44133 ` 2258` ``` shows "x = 0" ``` huffman@44133 ` 2259` ``` using fB ifB fi xsB fx ``` wenzelm@49522 ` 2260` ```proof (induct arbitrary: x rule: finite_induct[OF fB]) ``` wenzelm@49663 ` 2261` ``` case 1 ``` wenzelm@49663 ` 2262` ``` then show ?case by auto ``` huffman@44133 ` 2263` ```next ``` huffman@44133 ` 2264` ``` case (2 a b x) ``` huffman@44133 ` 2265` ``` have fb: "finite b" using "2.prems" by simp ``` huffman@44133 ` 2266` ``` have th0: "f ` b \ f ` (insert a b)" ``` wenzelm@53406 ` 2267` ``` apply (rule image_mono) ``` wenzelm@53406 ` 2268` ``` apply blast ``` wenzelm@53406 ` 2269` ``` done ``` huffman@44133 ` 2270` ``` from independent_mono[ OF "2.prems"(2) th0] ``` huffman@44133 ` 2271` ``` have ifb: "independent (f ` b)" . ``` huffman@44133 ` 2272` ``` have fib: "inj_on f b" ``` huffman@44133 ` 2273` ``` apply (rule subset_inj_on [OF "2.prems"(3)]) ``` wenzelm@49522 ` 2274` ``` apply blast ``` wenzelm@49522 ` 2275` ``` done ``` huffman@44133 ` 2276` ``` from span_breakdown[of a "insert a b", simplified, OF "2.prems"(4)] ``` wenzelm@53406 ` 2277` ``` obtain k where k: "x - k*\<^sub>R a \ span (b - {a})" ``` wenzelm@53406 ` 2278` ``` by blast ``` huffman@44133 ` 2279` ``` have "f (x - k*\<^sub>R a) \ span (f ` b)" ``` huffman@44133 ` 2280` ``` unfolding span_linear_image[OF lf] ``` huffman@44133 ` 2281` ``` apply (rule imageI) ``` wenzelm@53406 ` 2282` ``` using k span_mono[of "b-{a}" b] ``` wenzelm@53406 ` 2283` ``` apply blast ``` wenzelm@49522 ` 2284` ``` done ``` wenzelm@49522 ` 2285` ``` then have "f x - k*\<^sub>R f a \ span (f ` b)" ``` huffman@44133 ` 2286` ``` by (simp add: linear_sub[OF lf] linear_cmul[OF lf]) ``` wenzelm@49522 ` 2287` ``` then have th: "-k *\<^sub>R f a \ span (f ` b)" ``` huffman@44133 ` 2288` ``` using "2.prems"(5) by simp ``` wenzelm@53406 ` 2289` ``` have xsb: "x \ span b" ``` wenzelm@53406 ` 2290` ``` proof (cases "k = 0") ``` wenzelm@53406 ` 2291` ``` case True ``` wenzelm@53406 ` 2292` ``` with k have "x \ span (b -{a})" by simp ``` wenzelm@53406 ` 2293` ``` then show ?thesis using span_mono[of "b-{a}" b] ``` wenzelm@53406 ` 2294` ``` by blast ``` wenzelm@53406 ` 2295` ``` next ``` wenzelm@53406 ` 2296` ``` case False ``` wenzelm@53406 ` 2297` ``` with span_mul[OF th, of "- 1/ k"] ``` huffman@44133 ` 2298` ``` have th1: "f a \ span (f ` b)" ``` huffman@44133 ` 2299` ``` by auto ``` huffman@44133 ` 2300` ``` from inj_on_image_set_diff[OF "2.prems"(3), of "insert a b " "{a}", symmetric] ``` huffman@44133 ` 2301` ``` have tha: "f ` insert a b - f ` {a} = f ` (insert a b - {a})" by blast ``` huffman@44133 ` 2302` ``` from "2.prems"(2) [unfolded dependent_def bex_simps(8), rule_format, of "f a"] ``` huffman@44133 ` 2303` ``` have "f a \ span (f ` b)" using tha ``` huffman@44133 ` 2304` ``` using "2.hyps"(2) ``` huffman@44133 ` 2305` ``` "2.prems"(3) by auto ``` huffman@44133 ` 2306` ``` with th1 have False by blast ``` wenzelm@53406 ` 2307` ``` then show ?thesis by blast ``` wenzelm@53406 ` 2308` ``` qed ``` wenzelm@53406 ` 2309` ``` from "2.hyps"(3)[OF fb ifb fib xsb "2.prems"(5)] show "x = 0" . ``` huffman@44133 ` 2310` ```qed ``` huffman@44133 ` 2311` huffman@44133 ` 2312` ```text {* We can extend a linear mapping from basis. *} ``` huffman@44133 ` 2313` huffman@44133 ` 2314` ```lemma linear_independent_extend_lemma: ``` huffman@44133 ` 2315` ``` fixes f :: "'a::real_vector \ 'b::real_vector" ``` wenzelm@53406 ` 2316` ``` assumes fi: "finite B" ``` wenzelm@53406 ` 2317` ``` and ib: "independent B" ``` wenzelm@53406 ` 2318` ``` shows "\g. ``` wenzelm@53406 ` 2319` ``` (\x\ span B. \y\ span B. g (x + y) = g x + g y) \ ``` wenzelm@53406 ` 2320` ``` (\x\ span B. \c. g (c*\<^sub>R x) = c *\<^sub>R g x) \ ``` wenzelm@53406 ` 2321` ``` (\x\ B. g x = f x)" ``` wenzelm@49663 ` 2322` ``` using ib fi ``` wenzelm@49522 ` 2323` ```proof (induct rule: finite_induct[OF fi]) ``` wenzelm@49663 ` 2324` ``` case 1 ``` wenzelm@49663 ` 2325` ``` then show ?case by auto ``` huffman@44133 ` 2326` ```next ``` huffman@44133 ` 2327` ``` case (2 a b) ``` huffman@44133 ` 2328` ``` from "2.prems" "2.hyps" have ibf: "independent b" "finite b" ``` huffman@44133 ` 2329` ``` by (simp_all add: independent_insert) ``` huffman@44133 ` 2330` ``` from "2.hyps"(3)[OF ibf] obtain g where ``` huffman@44133 ` 2331` ``` g: "\x\span b. \y\span b. g (x + y) = g x + g y" ``` huffman@44133 ` 2332` ``` "\x\span b. \c. g (c *\<^sub>R x) = c *\<^sub>R g x" "\x\b. g x = f x" by blast ``` huffman@44133 ` 2333` ``` let ?h = "\z. SOME k. (z - k *\<^sub>R a) \ span b" ``` wenzelm@53406 ` 2334` ``` { ``` wenzelm@53406 ` 2335` ``` fix z ``` wenzelm@53406 ` 2336` ``` assume z: "z \ span (insert a b)" ``` huffman@44133 ` 2337` ``` have th0: "z - ?h z *\<^sub>R a \ span b" ``` huffman@44133 ` 2338` ``` apply (rule someI_ex) ``` huffman@44133 ` 2339` ``` unfolding span_breakdown_eq[symmetric] ``` wenzelm@53406 ` 2340` ``` apply (rule z) ``` wenzelm@53406 ` 2341` ``` done ``` wenzelm@53406 ` 2342` ``` { ``` wenzelm@53406 ` 2343` ``` fix k ``` wenzelm@53406 ` 2344` ``` assume k: "z - k *\<^sub>R a \ span b" ``` huffman@44133 ` 2345` ``` have eq: "z - ?h z *\<^sub>R a - (z - k*\<^sub>R a) = (k - ?h z) *\<^sub>R a" ``` huffman@44133 ` 2346` ``` by (simp add: field_simps scaleR_left_distrib [symmetric]) ``` wenzelm@53406 ` 2347` ``` from span_sub[OF th0 k] have khz: "(k - ?h z) *\<^sub>R a \ span b" ``` wenzelm@53406 ` 2348` ``` by (simp add: eq) ``` wenzelm@53406 ` 2349` ``` { ``` wenzelm@53406 ` 2350` ``` assume "k \ ?h z" ``` wenzelm@53406 ` 2351` ``` then have k0: "k - ?h z \ 0" by simp ``` huffman@44133 ` 2352` ``` from k0 span_mul[OF khz, of "1 /(k - ?h z)"] ``` huffman@44133 ` 2353` ``` have "a \ span b" by simp ``` huffman@44133 ` 2354` ``` with "2.prems"(1) "2.hyps"(2) have False ``` wenzelm@53406 ` 2355` ``` by (auto simp add: dependent_def) ``` wenzelm@53406 ` 2356` ``` } ``` wenzelm@53406 ` 2357` ``` then have "k = ?h z" by blast ``` wenzelm@53406 ` 2358` ``` } ``` wenzelm@53406 ` 2359` ``` with th0 have "z - ?h z *\<^sub>R a \ span b \ (\k. z - k *\<^sub>R a \ span b \ k = ?h z)" ``` wenzelm@53406 ` 2360` ``` by blast ``` wenzelm@53406 ` 2361` ``` } ``` huffman@44133 ` 2362` ``` note h = this ``` huffman@44133 ` 2363` ``` let ?g = "\z. ?h z *\<^sub>R f a + g (z - ?h z *\<^sub>R a)" ``` wenzelm@53406 ` 2364` ``` { ``` wenzelm@53406 ` 2365` ``` fix x y ``` wenzelm@53406 ` 2366` ``` assume x: "x \ span (insert a b)" ``` wenzelm@53406 ` 2367` ``` and y: "y \ span (insert a b)" ``` huffman@44133 ` 2368` ``` have tha: "\(x::'a) y a k l. (x + y) - (k + l) *\<^sub>R a = (x - k *\<^sub>R a) + (y - l *\<^sub>R a)" ``` huffman@44133 ` 2369` ``` by (simp add: algebra_simps) ``` huffman@44133 ` 2370` ``` have addh: "?h (x + y) = ?h x + ?h y" ``` huffman@44133 ` 2371` ``` apply (rule conjunct2[OF h, rule_format, symmetric]) ``` huffman@44133 ` 2372` ``` apply (rule span_add[OF x y]) ``` huffman@44133 ` 2373` ``` unfolding tha ``` wenzelm@53406 ` 2374` ``` apply (metis span_add x y conjunct1[OF h, rule_format]) ``` wenzelm@53406 ` 2375` ``` done ``` huffman@44133 ` 2376` ``` have "?g (x + y) = ?g x + ?g y" ``` huffman@44133 ` 2377` ``` unfolding addh tha ``` huffman@44133 ` 2378` ``` g(1)[rule_format,OF conjunct1[OF h, OF x] conjunct1[OF h, OF y]] ``` huffman@44133 ` 2379` ``` by (simp add: scaleR_left_distrib)} ``` huffman@44133 ` 2380` ``` moreover ``` wenzelm@53406 ` 2381` ``` { ``` wenzelm@53406 ` 2382` ``` fix x :: "'a" ``` wenzelm@53406 ` 2383` ``` fix c :: real ``` wenzelm@49522 ` 2384` ``` assume x: "x \ span (insert a b)" ``` huffman@44133 ` 2385` ``` have tha: "\(x::'a) c k a. c *\<^sub>R x - (c * k) *\<^sub>R a = c *\<^sub>R (x - k *\<^sub>R a)" ``` huffman@44133 ` 2386` ``` by (simp add: algebra_simps) ``` huffman@44133 ` 2387` ``` have hc: "?h (c *\<^sub>R x) = c * ?h x" ``` huffman@44133 ` 2388` ``` apply (rule conjunct2[OF h, rule_format, symmetric]) ``` huffman@44133 ` 2389` ``` apply (metis span_mul x) ``` wenzelm@49522 ` 2390` ``` apply (metis tha span_mul x conjunct1[OF h]) ``` wenzelm@49522 ` 2391` ``` done ``` huffman@44133 ` 2392` ``` have "?g (c *\<^sub>R x) = c*\<^sub>R ?g x" ``` huffman@44133 ` 2393` ``` unfolding hc tha g(2)[rule_format, OF conjunct1[OF h, OF x]] ``` wenzelm@53406 ` 2394` ``` by (simp add: algebra_simps) ``` wenzelm@53406 ` 2395` ``` } ``` huffman@44133 ` 2396` ``` moreover ``` wenzelm@53406 ` 2397` ``` { ``` wenzelm@53406 ` 2398` ``` fix x ``` wenzelm@53406 ` 2399` ``` assume x: "x \ insert a b" ``` wenzelm@53406 ` 2400` ``` { ``` wenzelm@53406 ` 2401` ``` assume xa: "x = a" ``` huffman@44133 ` 2402` ``` have ha1: "1 = ?h a" ``` huffman@44133 ` 2403` ``` apply (rule conjunct2[OF h, rule_format]) ``` huffman@44133 ` 2404` ``` apply (metis span_superset insertI1) ``` huffman@44133 ` 2405` ``` using conjunct1[OF h, OF span_superset, OF insertI1] ``` wenzelm@49522 ` 2406` ``` apply (auto simp add: span_0) ``` wenzelm@49522 ` 2407` ``` done ``` huffman@44133 ` 2408` ``` from xa ha1[symmetric] have "?g x = f x" ``` huffman@44133 ` 2409` ``` apply simp ``` huffman@44133 ` 2410` ``` using g(2)[rule_format, OF span_0, of 0] ``` wenzelm@49522 ` 2411` ``` apply simp ``` wenzelm@53406 ` 2412` ``` done ``` wenzelm@53406 ` 2413` ``` } ``` huffman@44133 ` 2414` ``` moreover ``` wenzelm@53406 ` 2415` ``` { ``` wenzelm@53406 ` 2416` ``` assume xb: "x \ b" ``` huffman@44133 ` 2417` ``` have h0: "0 = ?h x" ``` huffman@44133 ` 2418` ``` apply (rule conjunct2[OF h, rule_format]) ``` huffman@44133 ` 2419` ``` apply (metis span_superset x) ``` huffman@44133 ` 2420` ``` apply simp ``` huffman@44133 ` 2421` ``` apply (metis span_superset xb) ``` huffman@44133 ` 2422` ``` done ``` huffman@44133 ` 2423` ``` have "?g x = f x" ``` wenzelm@53406 ` 2424` ``` by (simp add: h0[symmetric] g(3)[rule_format, OF xb]) ``` wenzelm@53406 ` 2425` ``` } ``` wenzelm@53406 ` 2426` ``` ultimately have "?g x = f x" ``` wenzelm@53406 ` 2427` ``` using x by blast ``` wenzelm@53406 ` 2428` ``` } ``` wenzelm@49663 ` 2429` ``` ultimately show ?case ``` wenzelm@49663 ` 2430` ``` apply - ``` wenzelm@49663 ` 2431` ``` apply (rule exI[where x="?g"]) ``` wenzelm@49663 ` 2432` ``` apply blast ``` wenzelm@49663 ` 2433` ``` done ``` huffman@44133 ` 2434` ```qed ``` huffman@44133 ` 2435` huffman@44133 ` 2436` ```lemma linear_independent_extend: ``` wenzelm@53406 ` 2437` ``` fixes B :: "'a::euclidean_space set" ``` wenzelm@53406 ` 2438` ``` assumes iB: "independent B" ``` huffman@44133 ` 2439` ``` shows "\g. linear g \ (\x\B. g x = f x)" ``` wenzelm@49522 ` 2440` ```proof - ``` huffman@44133 ` 2441` ``` from maximal_independent_subset_extend[of B UNIV] iB ``` wenzelm@53406 ` 2442` ``` obtain C where C: "B \ C" "independent C" "\x. x \ span C" ``` wenzelm@53406 ` 2443` ``` by auto ``` huffman@44133 ` 2444` huffman@44133 ` 2445` ``` from C(2) independent_bound[of C] linear_independent_extend_lemma[of C f] ``` wenzelm@53406 ` 2446` ``` obtain g where g: ``` wenzelm@53406 ` 2447` ``` "(\x\ span C. \y\ span C. g (x + y) = g x + g y) \ ``` wenzelm@53406 ` 2448` ``` (\x\ span C. \c. g (c*\<^sub>R x) = c *\<^sub>R g x) \ ``` wenzelm@53406 ` 2449` ``` (\x\ C. g x = f x)" by blast ``` wenzelm@53406 ` 2450` ``` from g show ?thesis ``` huffman@53600 ` 2451` ``` unfolding linear_iff ``` wenzelm@53406 ` 2452` ``` using C ``` wenzelm@49663 ` 2453` ``` apply clarsimp ``` wenzelm@49663 ` 2454` ``` apply blast ``` wenzelm@49663 ` 2455` ``` done ``` huffman@44133 ` 2456` ```qed ``` huffman@44133 ` 2457` huffman@44133 ` 2458` ```text {* Can construct an isomorphism between spaces of same dimension. *} ``` huffman@44133 ` 2459` wenzelm@49522 ` 2460` ```lemma card_le_inj: ```