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