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