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