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