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