src/HOL/Analysis/Linear_Algebra.thy
 author immler Mon Jan 07 14:06:54 2019 +0100 (4 months ago) changeset 69619 3f7d8e05e0f2 parent 69600 86e8e7347ac0 child 69674 fc252acb7100 permissions -rw-r--r--
split off Convex.thy: material that does not require Topology_Euclidean_Space
 hoelzl@63627 ` 1` ```(* Title: HOL/Analysis/Linear_Algebra.thy ``` huffman@44133 ` 2` ``` Author: Amine Chaieb, University of Cambridge ``` huffman@44133 ` 3` ```*) ``` huffman@44133 ` 4` nipkow@69517 ` 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 ``` wenzelm@66453 ` 10` ``` "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) ``` immler@68072 ` 26` ``` show "f (- a) = - f a" by (rule f.neg) ``` immler@68072 ` 27` ``` show "f (s *\<^sub>R v) = s *\<^sub>R (f v)" by (rule f.scale) ``` huffman@44133 ` 28` ```qed ``` huffman@44133 ` 29` lp15@68069 ` 30` ```lemma finite_Atleast_Atmost_nat[simp]: "finite {f x |x. x \ (UNIV::'a::finite set)}" ``` lp15@68069 ` 31` ``` using finite finite_image_set by blast ``` huffman@44133 ` 32` wenzelm@53406 ` 33` nipkow@68901 ` 34` ```subsection%unimportant \More interesting properties of the norm\ ``` hoelzl@63050 ` 35` hoelzl@63050 ` 36` ```notation inner (infix "\" 70) ``` hoelzl@63050 ` 37` wenzelm@69597 ` 38` ```text\Equality of vectors in terms of \<^term>\(\)\ products.\ ``` hoelzl@63050 ` 39` hoelzl@63050 ` 40` ```lemma linear_componentwise: ``` hoelzl@63050 ` 41` ``` fixes f:: "'a::euclidean_space \ 'b::real_inner" ``` hoelzl@63050 ` 42` ``` assumes lf: "linear f" ``` hoelzl@63050 ` 43` ``` shows "(f x) \ j = (\i\Basis. (x\i) * (f i\j))" (is "?lhs = ?rhs") ``` hoelzl@63050 ` 44` ```proof - ``` immler@68072 ` 45` ``` interpret linear f by fact ``` hoelzl@63050 ` 46` ``` have "?rhs = (\i\Basis. (x\i) *\<^sub>R (f i))\j" ``` nipkow@64267 ` 47` ``` by (simp add: inner_sum_left) ``` hoelzl@63050 ` 48` ``` then show ?thesis ``` immler@68072 ` 49` ``` by (simp add: euclidean_representation sum[symmetric] scale[symmetric]) ``` hoelzl@63050 ` 50` ```qed ``` hoelzl@63050 ` 51` hoelzl@63050 ` 52` ```lemma vector_eq: "x = y \ x \ x = x \ y \ y \ y = x \ x" ``` hoelzl@63050 ` 53` ``` (is "?lhs \ ?rhs") ``` hoelzl@63050 ` 54` ```proof ``` hoelzl@63050 ` 55` ``` assume ?lhs ``` hoelzl@63050 ` 56` ``` then show ?rhs by simp ``` hoelzl@63050 ` 57` ```next ``` hoelzl@63050 ` 58` ``` assume ?rhs ``` hoelzl@63050 ` 59` ``` then have "x \ x - x \ y = 0 \ x \ y - y \ y = 0" ``` hoelzl@63050 ` 60` ``` by simp ``` hoelzl@63050 ` 61` ``` then have "x \ (x - y) = 0 \ y \ (x - y) = 0" ``` hoelzl@63050 ` 62` ``` by (simp add: inner_diff inner_commute) ``` hoelzl@63050 ` 63` ``` then have "(x - y) \ (x - y) = 0" ``` hoelzl@63050 ` 64` ``` by (simp add: field_simps inner_diff inner_commute) ``` hoelzl@63050 ` 65` ``` then show "x = y" by simp ``` hoelzl@63050 ` 66` ```qed ``` hoelzl@63050 ` 67` hoelzl@63050 ` 68` ```lemma norm_triangle_half_r: ``` hoelzl@63050 ` 69` ``` "norm (y - x1) < e / 2 \ norm (y - x2) < e / 2 \ norm (x1 - x2) < e" ``` hoelzl@63050 ` 70` ``` using dist_triangle_half_r unfolding dist_norm[symmetric] by auto ``` hoelzl@63050 ` 71` hoelzl@63050 ` 72` ```lemma norm_triangle_half_l: ``` hoelzl@63050 ` 73` ``` assumes "norm (x - y) < e / 2" ``` hoelzl@63050 ` 74` ``` and "norm (x' - y) < e / 2" ``` hoelzl@63050 ` 75` ``` shows "norm (x - x') < e" ``` hoelzl@63050 ` 76` ``` using dist_triangle_half_l[OF assms[unfolded dist_norm[symmetric]]] ``` hoelzl@63050 ` 77` ``` unfolding dist_norm[symmetric] . ``` hoelzl@63050 ` 78` lp15@66420 ` 79` ```lemma abs_triangle_half_r: ``` lp15@66420 ` 80` ``` fixes y :: "'a::linordered_field" ``` lp15@66420 ` 81` ``` shows "abs (y - x1) < e / 2 \ abs (y - x2) < e / 2 \ abs (x1 - x2) < e" ``` lp15@66420 ` 82` ``` by linarith ``` lp15@66420 ` 83` lp15@66420 ` 84` ```lemma abs_triangle_half_l: ``` lp15@66420 ` 85` ``` fixes y :: "'a::linordered_field" ``` lp15@66420 ` 86` ``` assumes "abs (x - y) < e / 2" ``` lp15@66420 ` 87` ``` and "abs (x' - y) < e / 2" ``` lp15@66420 ` 88` ``` shows "abs (x - x') < e" ``` lp15@66420 ` 89` ``` using assms by linarith ``` lp15@66420 ` 90` nipkow@64267 ` 91` ```lemma sum_clauses: ``` nipkow@64267 ` 92` ``` shows "sum f {} = 0" ``` nipkow@64267 ` 93` ``` and "finite S \ sum f (insert x S) = (if x \ S then sum f S else f x + sum f S)" ``` hoelzl@63050 ` 94` ``` by (auto simp add: insert_absorb) ``` hoelzl@63050 ` 95` hoelzl@63050 ` 96` ```lemma vector_eq_ldot: "(\x. x \ y = x \ z) \ y = z" ``` hoelzl@63050 ` 97` ```proof ``` hoelzl@63050 ` 98` ``` assume "\x. x \ y = x \ z" ``` hoelzl@63050 ` 99` ``` then have "\x. x \ (y - z) = 0" ``` hoelzl@63050 ` 100` ``` by (simp add: inner_diff) ``` hoelzl@63050 ` 101` ``` then have "(y - z) \ (y - z) = 0" .. ``` hoelzl@63050 ` 102` ``` then show "y = z" by simp ``` hoelzl@63050 ` 103` ```qed simp ``` hoelzl@63050 ` 104` hoelzl@63050 ` 105` ```lemma vector_eq_rdot: "(\z. x \ z = y \ z) \ x = y" ``` hoelzl@63050 ` 106` ```proof ``` hoelzl@63050 ` 107` ``` assume "\z. x \ z = y \ z" ``` hoelzl@63050 ` 108` ``` then have "\z. (x - y) \ z = 0" ``` hoelzl@63050 ` 109` ``` by (simp add: inner_diff) ``` hoelzl@63050 ` 110` ``` then have "(x - y) \ (x - y) = 0" .. ``` hoelzl@63050 ` 111` ``` then show "x = y" by simp ``` hoelzl@63050 ` 112` ```qed simp ``` hoelzl@63050 ` 113` immler@69619 ` 114` ```subsection \Substandard Basis\ ``` immler@69619 ` 115` immler@69619 ` 116` ```lemma ex_card: ``` immler@69619 ` 117` ``` assumes "n \ card A" ``` immler@69619 ` 118` ``` shows "\S\A. card S = n" ``` immler@69619 ` 119` ```proof (cases "finite A") ``` immler@69619 ` 120` ``` case True ``` immler@69619 ` 121` ``` from ex_bij_betw_nat_finite[OF this] obtain f where f: "bij_betw f {0..n \ card A\ have "{..< n} \ {..< card A}" "inj_on f {..< n}" ``` immler@69619 ` 123` ``` by (auto simp: bij_betw_def intro: subset_inj_on) ``` immler@69619 ` 124` ``` ultimately have "f ` {..< n} \ A" "card (f ` {..< n}) = n" ``` immler@69619 ` 125` ``` by (auto simp: bij_betw_def card_image) ``` immler@69619 ` 126` ``` then show ?thesis by blast ``` immler@69619 ` 127` ```next ``` immler@69619 ` 128` ``` case False ``` immler@69619 ` 129` ``` with \n \ card A\ show ?thesis by force ``` immler@69619 ` 130` ```qed ``` immler@69619 ` 131` immler@69619 ` 132` ```lemma subspace_substandard: "subspace {x::'a::euclidean_space. (\i\Basis. P i \ x\i = 0)}" ``` immler@69619 ` 133` ``` by (auto simp: subspace_def inner_add_left) ``` immler@69619 ` 134` immler@69619 ` 135` ```lemma dim_substandard: ``` immler@69619 ` 136` ``` assumes d: "d \ Basis" ``` immler@69619 ` 137` ``` shows "dim {x::'a::euclidean_space. \i\Basis. i \ d \ x\i = 0} = card d" (is "dim ?A = _") ``` immler@69619 ` 138` ```proof (rule dim_unique) ``` immler@69619 ` 139` ``` from d show "d \ ?A" ``` immler@69619 ` 140` ``` by (auto simp: inner_Basis) ``` immler@69619 ` 141` ``` from d show "independent d" ``` immler@69619 ` 142` ``` by (rule independent_mono [OF independent_Basis]) ``` immler@69619 ` 143` ``` have "x \ span d" if "\i\Basis. i \ d \ x \ i = 0" for x ``` immler@69619 ` 144` ``` proof - ``` immler@69619 ` 145` ``` have "finite d" ``` immler@69619 ` 146` ``` by (rule finite_subset [OF d finite_Basis]) ``` immler@69619 ` 147` ``` then have "(\i\d. (x \ i) *\<^sub>R i) \ span d" ``` immler@69619 ` 148` ``` by (simp add: span_sum span_clauses) ``` immler@69619 ` 149` ``` also have "(\i\d. (x \ i) *\<^sub>R i) = (\i\Basis. (x \ i) *\<^sub>R i)" ``` immler@69619 ` 150` ``` by (rule sum.mono_neutral_cong_left [OF finite_Basis d]) (auto simp: that) ``` immler@69619 ` 151` ``` finally show "x \ span d" ``` immler@69619 ` 152` ``` by (simp only: euclidean_representation) ``` immler@69619 ` 153` ``` qed ``` immler@69619 ` 154` ``` then show "?A \ span d" by auto ``` immler@69619 ` 155` ```qed simp ``` immler@69619 ` 156` hoelzl@63050 ` 157` nipkow@68901 ` 158` ```subsection \Orthogonality\ ``` hoelzl@63050 ` 159` immler@67962 ` 160` ```definition%important (in real_inner) "orthogonal x y \ x \ y = 0" ``` immler@67962 ` 161` hoelzl@63050 ` 162` ```context real_inner ``` hoelzl@63050 ` 163` ```begin ``` hoelzl@63050 ` 164` lp15@63072 ` 165` ```lemma orthogonal_self: "orthogonal x x \ x = 0" ``` lp15@63072 ` 166` ``` by (simp add: orthogonal_def) ``` lp15@63072 ` 167` hoelzl@63050 ` 168` ```lemma orthogonal_clauses: ``` hoelzl@63050 ` 169` ``` "orthogonal a 0" ``` hoelzl@63050 ` 170` ``` "orthogonal a x \ orthogonal a (c *\<^sub>R x)" ``` hoelzl@63050 ` 171` ``` "orthogonal a x \ orthogonal a (- x)" ``` hoelzl@63050 ` 172` ``` "orthogonal a x \ orthogonal a y \ orthogonal a (x + y)" ``` hoelzl@63050 ` 173` ``` "orthogonal a x \ orthogonal a y \ orthogonal a (x - y)" ``` hoelzl@63050 ` 174` ``` "orthogonal 0 a" ``` hoelzl@63050 ` 175` ``` "orthogonal x a \ orthogonal (c *\<^sub>R x) a" ``` hoelzl@63050 ` 176` ``` "orthogonal x a \ orthogonal (- x) a" ``` hoelzl@63050 ` 177` ``` "orthogonal x a \ orthogonal y a \ orthogonal (x + y) a" ``` hoelzl@63050 ` 178` ``` "orthogonal x a \ orthogonal y a \ orthogonal (x - y) a" ``` hoelzl@63050 ` 179` ``` unfolding orthogonal_def inner_add inner_diff by auto ``` hoelzl@63050 ` 180` hoelzl@63050 ` 181` ```end ``` hoelzl@63050 ` 182` hoelzl@63050 ` 183` ```lemma orthogonal_commute: "orthogonal x y \ orthogonal y x" ``` hoelzl@63050 ` 184` ``` by (simp add: orthogonal_def inner_commute) ``` hoelzl@63050 ` 185` lp15@63114 ` 186` ```lemma orthogonal_scaleR [simp]: "c \ 0 \ orthogonal (c *\<^sub>R x) = orthogonal x" ``` lp15@63114 ` 187` ``` by (rule ext) (simp add: orthogonal_def) ``` lp15@63114 ` 188` lp15@63114 ` 189` ```lemma pairwise_ortho_scaleR: ``` lp15@63114 ` 190` ``` "pairwise (\i j. orthogonal (f i) (g j)) B ``` lp15@63114 ` 191` ``` \ pairwise (\i j. orthogonal (a i *\<^sub>R f i) (a j *\<^sub>R g j)) B" ``` lp15@63114 ` 192` ``` by (auto simp: pairwise_def orthogonal_clauses) ``` lp15@63114 ` 193` lp15@63114 ` 194` ```lemma orthogonal_rvsum: ``` nipkow@64267 ` 195` ``` "\finite s; \y. y \ s \ orthogonal x (f y)\ \ orthogonal x (sum f s)" ``` lp15@63114 ` 196` ``` by (induction s rule: finite_induct) (auto simp: orthogonal_clauses) ``` lp15@63114 ` 197` lp15@63114 ` 198` ```lemma orthogonal_lvsum: ``` nipkow@64267 ` 199` ``` "\finite s; \x. x \ s \ orthogonal (f x) y\ \ orthogonal (sum f s) y" ``` lp15@63114 ` 200` ``` by (induction s rule: finite_induct) (auto simp: orthogonal_clauses) ``` lp15@63114 ` 201` lp15@63114 ` 202` ```lemma norm_add_Pythagorean: ``` lp15@63114 ` 203` ``` assumes "orthogonal a b" ``` lp15@63114 ` 204` ``` shows "norm(a + b) ^ 2 = norm a ^ 2 + norm b ^ 2" ``` lp15@63114 ` 205` ```proof - ``` lp15@63114 ` 206` ``` from assms have "(a - (0 - b)) \ (a - (0 - b)) = a \ a - (0 - b \ b)" ``` lp15@63114 ` 207` ``` by (simp add: algebra_simps orthogonal_def inner_commute) ``` lp15@63114 ` 208` ``` then show ?thesis ``` lp15@63114 ` 209` ``` by (simp add: power2_norm_eq_inner) ``` lp15@63114 ` 210` ```qed ``` lp15@63114 ` 211` nipkow@64267 ` 212` ```lemma norm_sum_Pythagorean: ``` lp15@63114 ` 213` ``` assumes "finite I" "pairwise (\i j. orthogonal (f i) (f j)) I" ``` nipkow@64267 ` 214` ``` shows "(norm (sum f I))\<^sup>2 = (\i\I. (norm (f i))\<^sup>2)" ``` lp15@63114 ` 215` ```using assms ``` lp15@63114 ` 216` ```proof (induction I rule: finite_induct) ``` lp15@63114 ` 217` ``` case empty then show ?case by simp ``` lp15@63114 ` 218` ```next ``` lp15@63114 ` 219` ``` case (insert x I) ``` nipkow@64267 ` 220` ``` then have "orthogonal (f x) (sum f I)" ``` lp15@63114 ` 221` ``` by (metis pairwise_insert orthogonal_rvsum) ``` lp15@63114 ` 222` ``` with insert show ?case ``` lp15@63114 ` 223` ``` by (simp add: pairwise_insert norm_add_Pythagorean) ``` lp15@63114 ` 224` ```qed ``` lp15@63114 ` 225` hoelzl@63050 ` 226` nipkow@68901 ` 227` ```subsection \Bilinear functions\ ``` hoelzl@63050 ` 228` nipkow@69600 ` 229` ```definition%important ``` nipkow@69600 ` 230` ```bilinear :: "('a::real_vector \ 'b::real_vector \ 'c::real_vector) \ bool" where ``` nipkow@69600 ` 231` ```"bilinear f \ (\x. linear (\y. f x y)) \ (\y. linear (\x. f x y))" ``` hoelzl@63050 ` 232` hoelzl@63050 ` 233` ```lemma bilinear_ladd: "bilinear h \ h (x + y) z = h x z + h y z" ``` hoelzl@63050 ` 234` ``` by (simp add: bilinear_def linear_iff) ``` hoelzl@63050 ` 235` hoelzl@63050 ` 236` ```lemma bilinear_radd: "bilinear h \ h x (y + z) = h x y + h x z" ``` hoelzl@63050 ` 237` ``` by (simp add: bilinear_def linear_iff) ``` hoelzl@63050 ` 238` hoelzl@63050 ` 239` ```lemma bilinear_lmul: "bilinear h \ h (c *\<^sub>R x) y = c *\<^sub>R h x y" ``` hoelzl@63050 ` 240` ``` by (simp add: bilinear_def linear_iff) ``` hoelzl@63050 ` 241` hoelzl@63050 ` 242` ```lemma bilinear_rmul: "bilinear h \ h x (c *\<^sub>R y) = c *\<^sub>R h x y" ``` hoelzl@63050 ` 243` ``` by (simp add: bilinear_def linear_iff) ``` hoelzl@63050 ` 244` hoelzl@63050 ` 245` ```lemma bilinear_lneg: "bilinear h \ h (- x) y = - h x y" ``` hoelzl@63050 ` 246` ``` by (drule bilinear_lmul [of _ "- 1"]) simp ``` hoelzl@63050 ` 247` hoelzl@63050 ` 248` ```lemma bilinear_rneg: "bilinear h \ h x (- y) = - h x y" ``` hoelzl@63050 ` 249` ``` by (drule bilinear_rmul [of _ _ "- 1"]) simp ``` hoelzl@63050 ` 250` hoelzl@63050 ` 251` ```lemma (in ab_group_add) eq_add_iff: "x = x + y \ y = 0" ``` hoelzl@63050 ` 252` ``` using add_left_imp_eq[of x y 0] by auto ``` hoelzl@63050 ` 253` hoelzl@63050 ` 254` ```lemma bilinear_lzero: ``` hoelzl@63050 ` 255` ``` assumes "bilinear h" ``` hoelzl@63050 ` 256` ``` shows "h 0 x = 0" ``` hoelzl@63050 ` 257` ``` using bilinear_ladd [OF assms, of 0 0 x] by (simp add: eq_add_iff field_simps) ``` hoelzl@63050 ` 258` hoelzl@63050 ` 259` ```lemma bilinear_rzero: ``` hoelzl@63050 ` 260` ``` assumes "bilinear h" ``` hoelzl@63050 ` 261` ``` shows "h x 0 = 0" ``` hoelzl@63050 ` 262` ``` using bilinear_radd [OF assms, of x 0 0 ] by (simp add: eq_add_iff field_simps) ``` hoelzl@63050 ` 263` hoelzl@63050 ` 264` ```lemma bilinear_lsub: "bilinear h \ h (x - y) z = h x z - h y z" ``` hoelzl@63050 ` 265` ``` using bilinear_ladd [of h x "- y"] by (simp add: bilinear_lneg) ``` hoelzl@63050 ` 266` hoelzl@63050 ` 267` ```lemma bilinear_rsub: "bilinear h \ h z (x - y) = h z x - h z y" ``` hoelzl@63050 ` 268` ``` using bilinear_radd [of h _ x "- y"] by (simp add: bilinear_rneg) ``` hoelzl@63050 ` 269` nipkow@64267 ` 270` ```lemma bilinear_sum: ``` immler@68072 ` 271` ``` assumes "bilinear h" ``` nipkow@64267 ` 272` ``` shows "h (sum f S) (sum g T) = sum (\(i,j). h (f i) (g j)) (S \ T) " ``` hoelzl@63050 ` 273` ```proof - ``` immler@68072 ` 274` ``` interpret l: linear "\x. h x y" for y using assms by (simp add: bilinear_def) ``` immler@68072 ` 275` ``` interpret r: linear "\y. h x y" for x using assms by (simp add: bilinear_def) ``` nipkow@64267 ` 276` ``` have "h (sum f S) (sum g T) = sum (\x. h (f x) (sum g T)) S" ``` immler@68072 ` 277` ``` by (simp add: l.sum) ``` nipkow@64267 ` 278` ``` also have "\ = sum (\x. sum (\y. h (f x) (g y)) T) S" ``` immler@68072 ` 279` ``` by (rule sum.cong) (simp_all add: r.sum) ``` hoelzl@63050 ` 280` ``` finally show ?thesis ``` nipkow@64267 ` 281` ``` unfolding sum.cartesian_product . ``` hoelzl@63050 ` 282` ```qed ``` hoelzl@63050 ` 283` hoelzl@63050 ` 284` nipkow@68901 ` 285` ```subsection \Adjoints\ ``` hoelzl@63050 ` 286` nipkow@69600 ` 287` ```definition%important adjoint :: "(('a::real_inner) \ ('b::real_inner)) \ 'b \ 'a" where ``` nipkow@69600 ` 288` ```"adjoint f = (SOME f'. \x y. f x \ y = x \ f' y)" ``` hoelzl@63050 ` 289` hoelzl@63050 ` 290` ```lemma adjoint_unique: ``` hoelzl@63050 ` 291` ``` assumes "\x y. inner (f x) y = inner x (g y)" ``` hoelzl@63050 ` 292` ``` shows "adjoint f = g" ``` hoelzl@63050 ` 293` ``` unfolding adjoint_def ``` hoelzl@63050 ` 294` ```proof (rule some_equality) ``` hoelzl@63050 ` 295` ``` show "\x y. inner (f x) y = inner x (g y)" ``` hoelzl@63050 ` 296` ``` by (rule assms) ``` hoelzl@63050 ` 297` ```next ``` hoelzl@63050 ` 298` ``` fix h ``` hoelzl@63050 ` 299` ``` assume "\x y. inner (f x) y = inner x (h y)" ``` hoelzl@63050 ` 300` ``` then have "\x y. inner x (g y) = inner x (h y)" ``` hoelzl@63050 ` 301` ``` using assms by simp ``` hoelzl@63050 ` 302` ``` then have "\x y. inner x (g y - h y) = 0" ``` hoelzl@63050 ` 303` ``` by (simp add: inner_diff_right) ``` hoelzl@63050 ` 304` ``` then have "\y. inner (g y - h y) (g y - h y) = 0" ``` hoelzl@63050 ` 305` ``` by simp ``` hoelzl@63050 ` 306` ``` then have "\y. h y = g y" ``` hoelzl@63050 ` 307` ``` by simp ``` hoelzl@63050 ` 308` ``` then show "h = g" by (simp add: ext) ``` hoelzl@63050 ` 309` ```qed ``` hoelzl@63050 ` 310` hoelzl@63050 ` 311` ```text \TODO: The following lemmas about adjoints should hold for any ``` wenzelm@63680 ` 312` ``` Hilbert space (i.e. complete inner product space). ``` wenzelm@68224 ` 313` ``` (see \<^url>\https://en.wikipedia.org/wiki/Hermitian_adjoint\) ``` hoelzl@63050 ` 314` ```\ ``` hoelzl@63050 ` 315` hoelzl@63050 ` 316` ```lemma adjoint_works: ``` hoelzl@63050 ` 317` ``` fixes f :: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@63050 ` 318` ``` assumes lf: "linear f" ``` hoelzl@63050 ` 319` ``` shows "x \ adjoint f y = f x \ y" ``` hoelzl@63050 ` 320` ```proof - ``` immler@68072 ` 321` ``` interpret linear f by fact ``` hoelzl@63050 ` 322` ``` have "\y. \w. \x. f x \ y = x \ w" ``` hoelzl@63050 ` 323` ``` proof (intro allI exI) ``` hoelzl@63050 ` 324` ``` fix y :: "'m" and x ``` hoelzl@63050 ` 325` ``` let ?w = "(\i\Basis. (f i \ y) *\<^sub>R i) :: 'n" ``` hoelzl@63050 ` 326` ``` have "f x \ y = f (\i\Basis. (x \ i) *\<^sub>R i) \ y" ``` hoelzl@63050 ` 327` ``` by (simp add: euclidean_representation) ``` hoelzl@63050 ` 328` ``` also have "\ = (\i\Basis. (x \ i) *\<^sub>R f i) \ y" ``` immler@68072 ` 329` ``` by (simp add: sum scale) ``` hoelzl@63050 ` 330` ``` finally show "f x \ y = x \ ?w" ``` nipkow@64267 ` 331` ``` by (simp add: inner_sum_left inner_sum_right mult.commute) ``` hoelzl@63050 ` 332` ``` qed ``` hoelzl@63050 ` 333` ``` then show ?thesis ``` hoelzl@63050 ` 334` ``` unfolding adjoint_def choice_iff ``` hoelzl@63050 ` 335` ``` by (intro someI2_ex[where Q="\f'. x \ f' y = f x \ y"]) auto ``` hoelzl@63050 ` 336` ```qed ``` hoelzl@63050 ` 337` hoelzl@63050 ` 338` ```lemma adjoint_clauses: ``` hoelzl@63050 ` 339` ``` fixes f :: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@63050 ` 340` ``` assumes lf: "linear f" ``` hoelzl@63050 ` 341` ``` shows "x \ adjoint f y = f x \ y" ``` hoelzl@63050 ` 342` ``` and "adjoint f y \ x = y \ f x" ``` hoelzl@63050 ` 343` ``` by (simp_all add: adjoint_works[OF lf] inner_commute) ``` hoelzl@63050 ` 344` hoelzl@63050 ` 345` ```lemma adjoint_linear: ``` hoelzl@63050 ` 346` ``` fixes f :: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@63050 ` 347` ``` assumes lf: "linear f" ``` hoelzl@63050 ` 348` ``` shows "linear (adjoint f)" ``` hoelzl@63050 ` 349` ``` by (simp add: lf linear_iff euclidean_eq_iff[where 'a='n] euclidean_eq_iff[where 'a='m] ``` hoelzl@63050 ` 350` ``` adjoint_clauses[OF lf] inner_distrib) ``` hoelzl@63050 ` 351` hoelzl@63050 ` 352` ```lemma adjoint_adjoint: ``` hoelzl@63050 ` 353` ``` fixes f :: "'n::euclidean_space \ 'm::euclidean_space" ``` hoelzl@63050 ` 354` ``` assumes lf: "linear f" ``` hoelzl@63050 ` 355` ``` shows "adjoint (adjoint f) = f" ``` hoelzl@63050 ` 356` ``` by (rule adjoint_unique, simp add: adjoint_clauses [OF lf]) ``` hoelzl@63050 ` 357` hoelzl@63050 ` 358` hoelzl@63050 ` 359` ```subsection \Archimedean properties and useful consequences\ ``` hoelzl@63050 ` 360` hoelzl@63050 ` 361` ```text\Bernoulli's inequality\ ``` immler@68607 ` 362` ```proposition Bernoulli_inequality: ``` hoelzl@63050 ` 363` ``` fixes x :: real ``` hoelzl@63050 ` 364` ``` assumes "-1 \ x" ``` hoelzl@63050 ` 365` ``` shows "1 + n * x \ (1 + x) ^ n" ``` immler@68607 ` 366` ```proof (induct n) ``` hoelzl@63050 ` 367` ``` case 0 ``` hoelzl@63050 ` 368` ``` then show ?case by simp ``` hoelzl@63050 ` 369` ```next ``` hoelzl@63050 ` 370` ``` case (Suc n) ``` hoelzl@63050 ` 371` ``` have "1 + Suc n * x \ 1 + (Suc n)*x + n * x^2" ``` hoelzl@63050 ` 372` ``` by (simp add: algebra_simps) ``` hoelzl@63050 ` 373` ``` also have "... = (1 + x) * (1 + n*x)" ``` hoelzl@63050 ` 374` ``` by (auto simp: power2_eq_square algebra_simps of_nat_Suc) ``` hoelzl@63050 ` 375` ``` also have "... \ (1 + x) ^ Suc n" ``` hoelzl@63050 ` 376` ``` using Suc.hyps assms mult_left_mono by fastforce ``` hoelzl@63050 ` 377` ``` finally show ?case . ``` hoelzl@63050 ` 378` ```qed ``` hoelzl@63050 ` 379` hoelzl@63050 ` 380` ```corollary Bernoulli_inequality_even: ``` hoelzl@63050 ` 381` ``` fixes x :: real ``` hoelzl@63050 ` 382` ``` assumes "even n" ``` hoelzl@63050 ` 383` ``` shows "1 + n * x \ (1 + x) ^ n" ``` hoelzl@63050 ` 384` ```proof (cases "-1 \ x \ n=0") ``` hoelzl@63050 ` 385` ``` case True ``` hoelzl@63050 ` 386` ``` then show ?thesis ``` hoelzl@63050 ` 387` ``` by (auto simp: Bernoulli_inequality) ``` hoelzl@63050 ` 388` ```next ``` hoelzl@63050 ` 389` ``` case False ``` hoelzl@63050 ` 390` ``` then have "real n \ 1" ``` hoelzl@63050 ` 391` ``` by simp ``` hoelzl@63050 ` 392` ``` with False have "n * x \ -1" ``` hoelzl@63050 ` 393` ``` 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 ` 394` ``` then have "1 + n * x \ 0" ``` hoelzl@63050 ` 395` ``` by auto ``` hoelzl@63050 ` 396` ``` also have "... \ (1 + x) ^ n" ``` hoelzl@63050 ` 397` ``` using assms ``` hoelzl@63050 ` 398` ``` using zero_le_even_power by blast ``` hoelzl@63050 ` 399` ``` finally show ?thesis . ``` hoelzl@63050 ` 400` ```qed ``` hoelzl@63050 ` 401` hoelzl@63050 ` 402` ```corollary real_arch_pow: ``` hoelzl@63050 ` 403` ``` fixes x :: real ``` hoelzl@63050 ` 404` ``` assumes x: "1 < x" ``` hoelzl@63050 ` 405` ``` shows "\n. y < x^n" ``` hoelzl@63050 ` 406` ```proof - ``` hoelzl@63050 ` 407` ``` from x have x0: "x - 1 > 0" ``` hoelzl@63050 ` 408` ``` by arith ``` hoelzl@63050 ` 409` ``` from reals_Archimedean3[OF x0, rule_format, of y] ``` hoelzl@63050 ` 410` ``` obtain n :: nat where n: "y < real n * (x - 1)" by metis ``` hoelzl@63050 ` 411` ``` from x0 have x00: "x- 1 \ -1" by arith ``` hoelzl@63050 ` 412` ``` from Bernoulli_inequality[OF x00, of n] n ``` hoelzl@63050 ` 413` ``` have "y < x^n" by auto ``` hoelzl@63050 ` 414` ``` then show ?thesis by metis ``` hoelzl@63050 ` 415` ```qed ``` hoelzl@63050 ` 416` hoelzl@63050 ` 417` ```corollary real_arch_pow_inv: ``` hoelzl@63050 ` 418` ``` fixes x y :: real ``` hoelzl@63050 ` 419` ``` assumes y: "y > 0" ``` hoelzl@63050 ` 420` ``` and x1: "x < 1" ``` hoelzl@63050 ` 421` ``` shows "\n. x^n < y" ``` hoelzl@63050 ` 422` ```proof (cases "x > 0") ``` hoelzl@63050 ` 423` ``` case True ``` hoelzl@63050 ` 424` ``` with x1 have ix: "1 < 1/x" by (simp add: field_simps) ``` hoelzl@63050 ` 425` ``` from real_arch_pow[OF ix, of "1/y"] ``` hoelzl@63050 ` 426` ``` obtain n where n: "1/y < (1/x)^n" by blast ``` hoelzl@63050 ` 427` ``` then show ?thesis using y \x > 0\ ``` hoelzl@63050 ` 428` ``` by (auto simp add: field_simps) ``` hoelzl@63050 ` 429` ```next ``` hoelzl@63050 ` 430` ``` case False ``` hoelzl@63050 ` 431` ``` with y x1 show ?thesis ``` lp15@68069 ` 432` ``` by (metis less_le_trans not_less power_one_right) ``` hoelzl@63050 ` 433` ```qed ``` hoelzl@63050 ` 434` hoelzl@63050 ` 435` ```lemma forall_pos_mono: ``` hoelzl@63050 ` 436` ``` "(\d e::real. d < e \ P d \ P e) \ ``` hoelzl@63050 ` 437` ``` (\n::nat. n \ 0 \ P (inverse (real n))) \ (\e. 0 < e \ P e)" ``` hoelzl@63050 ` 438` ``` by (metis real_arch_inverse) ``` hoelzl@63050 ` 439` hoelzl@63050 ` 440` ```lemma forall_pos_mono_1: ``` hoelzl@63050 ` 441` ``` "(\d e::real. d < e \ P d \ P e) \ ``` hoelzl@63050 ` 442` ``` (\n. P (inverse (real (Suc n)))) \ 0 < e \ P e" ``` hoelzl@63050 ` 443` ``` apply (rule forall_pos_mono) ``` hoelzl@63050 ` 444` ``` apply auto ``` hoelzl@63050 ` 445` ``` apply (metis Suc_pred of_nat_Suc) ``` hoelzl@63050 ` 446` ``` done ``` hoelzl@63050 ` 447` hoelzl@63050 ` 448` immler@67962 ` 449` ```subsection%unimportant \Euclidean Spaces as Typeclass\ ``` huffman@44133 ` 450` hoelzl@50526 ` 451` ```lemma independent_Basis: "independent Basis" ``` immler@68072 ` 452` ``` by (rule independent_Basis) ``` hoelzl@50526 ` 453` huffman@53939 ` 454` ```lemma span_Basis [simp]: "span Basis = UNIV" ``` immler@68072 ` 455` ``` by (rule span_Basis) ``` huffman@44133 ` 456` hoelzl@50526 ` 457` ```lemma in_span_Basis: "x \ span Basis" ``` hoelzl@50526 ` 458` ``` unfolding span_Basis .. ``` hoelzl@50526 ` 459` wenzelm@53406 ` 460` immler@67962 ` 461` ```subsection%unimportant \Linearity and Bilinearity continued\ ``` huffman@44133 ` 462` huffman@44133 ` 463` ```lemma linear_bounded: ``` wenzelm@56444 ` 464` ``` fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" ``` huffman@44133 ` 465` ``` assumes lf: "linear f" ``` huffman@44133 ` 466` ``` shows "\B. \x. norm (f x) \ B * norm x" ``` huffman@53939 ` 467` ```proof ``` immler@68072 ` 468` ``` interpret linear f by fact ``` hoelzl@50526 ` 469` ``` let ?B = "\b\Basis. norm (f b)" ``` huffman@53939 ` 470` ``` show "\x. norm (f x) \ ?B * norm x" ``` huffman@53939 ` 471` ``` proof ``` wenzelm@53406 ` 472` ``` fix x :: 'a ``` hoelzl@50526 ` 473` ``` let ?g = "\b. (x \ b) *\<^sub>R f b" ``` hoelzl@50526 ` 474` ``` have "norm (f x) = norm (f (\b\Basis. (x \ b) *\<^sub>R b))" ``` hoelzl@50526 ` 475` ``` unfolding euclidean_representation .. ``` nipkow@64267 ` 476` ``` also have "\ = norm (sum ?g Basis)" ``` immler@68072 ` 477` ``` by (simp add: sum scale) ``` nipkow@64267 ` 478` ``` finally have th0: "norm (f x) = norm (sum ?g Basis)" . ``` lp15@64773 ` 479` ``` have th: "norm (?g i) \ norm (f i) * norm x" if "i \ Basis" for i ``` lp15@64773 ` 480` ``` proof - ``` lp15@64773 ` 481` ``` from Basis_le_norm[OF that, of x] ``` huffman@53939 ` 482` ``` show "norm (?g i) \ norm (f i) * norm x" ``` lp15@68069 ` 483` ``` unfolding norm_scaleR by (metis mult.commute mult_left_mono norm_ge_zero) ``` huffman@53939 ` 484` ``` qed ``` nipkow@64267 ` 485` ``` from sum_norm_le[of _ ?g, OF th] ``` huffman@53939 ` 486` ``` show "norm (f x) \ ?B * norm x" ``` nipkow@64267 ` 487` ``` unfolding th0 sum_distrib_right by metis ``` huffman@53939 ` 488` ``` qed ``` huffman@44133 ` 489` ```qed ``` huffman@44133 ` 490` huffman@44133 ` 491` ```lemma linear_conv_bounded_linear: ``` huffman@44133 ` 492` ``` fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" ``` huffman@44133 ` 493` ``` shows "linear f \ bounded_linear f" ``` huffman@44133 ` 494` ```proof ``` huffman@44133 ` 495` ``` assume "linear f" ``` huffman@53939 ` 496` ``` then interpret f: linear f . ``` huffman@44133 ` 497` ``` show "bounded_linear f" ``` huffman@44133 ` 498` ``` proof ``` huffman@44133 ` 499` ``` have "\B. \x. norm (f x) \ B * norm x" ``` wenzelm@60420 ` 500` ``` using \linear f\ by (rule linear_bounded) ``` wenzelm@49522 ` 501` ``` then show "\K. \x. norm (f x) \ norm x * K" ``` haftmann@57512 ` 502` ``` by (simp add: mult.commute) ``` huffman@44133 ` 503` ``` qed ``` huffman@44133 ` 504` ```next ``` huffman@44133 ` 505` ``` assume "bounded_linear f" ``` huffman@44133 ` 506` ``` then interpret f: bounded_linear f . ``` huffman@53939 ` 507` ``` show "linear f" .. ``` huffman@53939 ` 508` ```qed ``` huffman@53939 ` 509` paulson@61518 ` 510` ```lemmas linear_linear = linear_conv_bounded_linear[symmetric] ``` paulson@61518 ` 511` huffman@53939 ` 512` ```lemma linear_bounded_pos: ``` wenzelm@56444 ` 513` ``` fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" ``` huffman@53939 ` 514` ``` assumes lf: "linear f" ``` lp15@67982 ` 515` ``` obtains B where "B > 0" "\x. norm (f x) \ B * norm x" ``` huffman@53939 ` 516` ```proof - ``` huffman@53939 ` 517` ``` have "\B > 0. \x. norm (f x) \ norm x * B" ``` huffman@53939 ` 518` ``` using lf unfolding linear_conv_bounded_linear ``` huffman@53939 ` 519` ``` by (rule bounded_linear.pos_bounded) ``` lp15@67982 ` 520` ``` with that show ?thesis ``` lp15@67982 ` 521` ``` by (auto simp: mult.commute) ``` huffman@44133 ` 522` ```qed ``` huffman@44133 ` 523` lp15@67982 ` 524` ```lemma linear_invertible_bounded_below_pos: ``` lp15@67982 ` 525` ``` fixes f :: "'a::real_normed_vector \ 'b::euclidean_space" ``` lp15@67982 ` 526` ``` assumes "linear f" "linear g" "g \ f = id" ``` lp15@67982 ` 527` ``` obtains B where "B > 0" "\x. B * norm x \ norm(f x)" ``` lp15@67982 ` 528` ```proof - ``` lp15@67982 ` 529` ``` obtain B where "B > 0" and B: "\x. norm (g x) \ B * norm x" ``` lp15@67982 ` 530` ``` using linear_bounded_pos [OF \linear g\] by blast ``` lp15@67982 ` 531` ``` show thesis ``` lp15@67982 ` 532` ``` proof ``` lp15@67982 ` 533` ``` show "0 < 1/B" ``` lp15@67982 ` 534` ``` by (simp add: \B > 0\) ``` lp15@67982 ` 535` ``` show "1/B * norm x \ norm (f x)" for x ``` lp15@67982 ` 536` ``` proof - ``` lp15@67982 ` 537` ``` have "1/B * norm x = 1/B * norm (g (f x))" ``` lp15@67982 ` 538` ``` using assms by (simp add: pointfree_idE) ``` lp15@67982 ` 539` ``` also have "\ \ norm (f x)" ``` lp15@67982 ` 540` ``` using B [of "f x"] by (simp add: \B > 0\ mult.commute pos_divide_le_eq) ``` lp15@67982 ` 541` ``` finally show ?thesis . ``` lp15@67982 ` 542` ``` qed ``` lp15@67982 ` 543` ``` qed ``` lp15@67982 ` 544` ```qed ``` lp15@67982 ` 545` lp15@67982 ` 546` ```lemma linear_inj_bounded_below_pos: ``` lp15@67982 ` 547` ``` fixes f :: "'a::real_normed_vector \ 'b::euclidean_space" ``` lp15@67982 ` 548` ``` assumes "linear f" "inj f" ``` lp15@67982 ` 549` ``` obtains B where "B > 0" "\x. B * norm x \ norm(f x)" ``` immler@68072 ` 550` ``` using linear_injective_left_inverse [OF assms] ``` immler@68072 ` 551` ``` linear_invertible_bounded_below_pos assms by blast ``` lp15@67982 ` 552` wenzelm@49522 ` 553` ```lemma bounded_linearI': ``` wenzelm@56444 ` 554` ``` fixes f ::"'a::euclidean_space \ 'b::real_normed_vector" ``` wenzelm@53406 ` 555` ``` assumes "\x y. f (x + y) = f x + f y" ``` wenzelm@53406 ` 556` ``` and "\c x. f (c *\<^sub>R x) = c *\<^sub>R f x" ``` wenzelm@49522 ` 557` ``` shows "bounded_linear f" ``` immler@68072 ` 558` ``` using assms linearI linear_conv_bounded_linear by blast ``` huffman@44133 ` 559` huffman@44133 ` 560` ```lemma bilinear_bounded: ``` wenzelm@56444 ` 561` ``` fixes h :: "'m::euclidean_space \ 'n::euclidean_space \ 'k::real_normed_vector" ``` huffman@44133 ` 562` ``` assumes bh: "bilinear h" ``` huffman@44133 ` 563` ``` shows "\B. \x y. norm (h x y) \ B * norm x * norm y" ``` hoelzl@50526 ` 564` ```proof (clarify intro!: exI[of _ "\i\Basis. \j\Basis. norm (h i j)"]) ``` wenzelm@53406 ` 565` ``` fix x :: 'm ``` wenzelm@53406 ` 566` ``` fix y :: 'n ``` nipkow@64267 ` 567` ``` have "norm (h x y) = norm (h (sum (\i. (x \ i) *\<^sub>R i) Basis) (sum (\i. (y \ i) *\<^sub>R i) Basis))" ``` lp15@68069 ` 568` ``` by (simp add: euclidean_representation) ``` nipkow@64267 ` 569` ``` also have "\ = norm (sum (\ (i,j). h ((x \ i) *\<^sub>R i) ((y \ j) *\<^sub>R j)) (Basis \ Basis))" ``` immler@68072 ` 570` ``` unfolding bilinear_sum[OF bh] .. ``` hoelzl@50526 ` 571` ``` finally have th: "norm (h x y) = \" . ``` lp15@68069 ` 572` ``` have "\i j. \i \ Basis; j \ Basis\ ``` lp15@68069 ` 573` ``` \ \x \ i\ * (\y \ j\ * norm (h i j)) \ norm x * (norm y * norm (h i j))" ``` lp15@68069 ` 574` ``` by (auto simp add: zero_le_mult_iff Basis_le_norm mult_mono) ``` lp15@68069 ` 575` ``` then show "norm (h x y) \ (\i\Basis. \j\Basis. norm (h i j)) * norm x * norm y" ``` lp15@68069 ` 576` ``` unfolding sum_distrib_right th sum.cartesian_product ``` lp15@68069 ` 577` ``` by (clarsimp simp add: bilinear_rmul[OF bh] bilinear_lmul[OF bh] ``` lp15@68069 ` 578` ``` field_simps simp del: scaleR_scaleR intro!: sum_norm_le) ``` huffman@44133 ` 579` ```qed ``` huffman@44133 ` 580` huffman@44133 ` 581` ```lemma bilinear_conv_bounded_bilinear: ``` huffman@44133 ` 582` ``` fixes h :: "'a::euclidean_space \ 'b::euclidean_space \ 'c::real_normed_vector" ``` huffman@44133 ` 583` ``` shows "bilinear h \ bounded_bilinear h" ``` huffman@44133 ` 584` ```proof ``` huffman@44133 ` 585` ``` assume "bilinear h" ``` huffman@44133 ` 586` ``` show "bounded_bilinear h" ``` huffman@44133 ` 587` ``` proof ``` wenzelm@53406 ` 588` ``` fix x y z ``` wenzelm@53406 ` 589` ``` show "h (x + y) z = h x z + h y z" ``` wenzelm@60420 ` 590` ``` using \bilinear h\ unfolding bilinear_def linear_iff by simp ``` huffman@44133 ` 591` ``` next ``` wenzelm@53406 ` 592` ``` fix x y z ``` wenzelm@53406 ` 593` ``` show "h x (y + z) = h x y + h x z" ``` wenzelm@60420 ` 594` ``` using \bilinear h\ unfolding bilinear_def linear_iff by simp ``` huffman@44133 ` 595` ``` next ``` lp15@68069 ` 596` ``` show "h (scaleR r x) y = scaleR r (h x y)" "h x (scaleR r y) = scaleR r (h x y)" for r x y ``` wenzelm@60420 ` 597` ``` using \bilinear h\ unfolding bilinear_def linear_iff ``` lp15@68069 ` 598` ``` by simp_all ``` huffman@44133 ` 599` ``` next ``` huffman@44133 ` 600` ``` have "\B. \x y. norm (h x y) \ B * norm x * norm y" ``` wenzelm@60420 ` 601` ``` using \bilinear h\ by (rule bilinear_bounded) ``` wenzelm@49522 ` 602` ``` then show "\K. \x y. norm (h x y) \ norm x * norm y * K" ``` haftmann@57514 ` 603` ``` by (simp add: ac_simps) ``` huffman@44133 ` 604` ``` qed ``` huffman@44133 ` 605` ```next ``` huffman@44133 ` 606` ``` assume "bounded_bilinear h" ``` huffman@44133 ` 607` ``` then interpret h: bounded_bilinear h . ``` huffman@44133 ` 608` ``` show "bilinear h" ``` huffman@44133 ` 609` ``` unfolding bilinear_def linear_conv_bounded_linear ``` wenzelm@49522 ` 610` ``` using h.bounded_linear_left h.bounded_linear_right by simp ``` huffman@44133 ` 611` ```qed ``` huffman@44133 ` 612` huffman@53939 ` 613` ```lemma bilinear_bounded_pos: ``` wenzelm@56444 ` 614` ``` fixes h :: "'a::euclidean_space \ 'b::euclidean_space \ 'c::real_normed_vector" ``` huffman@53939 ` 615` ``` assumes bh: "bilinear h" ``` huffman@53939 ` 616` ``` shows "\B > 0. \x y. norm (h x y) \ B * norm x * norm y" ``` huffman@53939 ` 617` ```proof - ``` huffman@53939 ` 618` ``` have "\B > 0. \x y. norm (h x y) \ norm x * norm y * B" ``` huffman@53939 ` 619` ``` using bh [unfolded bilinear_conv_bounded_bilinear] ``` huffman@53939 ` 620` ``` by (rule bounded_bilinear.pos_bounded) ``` huffman@53939 ` 621` ``` then show ?thesis ``` haftmann@57514 ` 622` ``` by (simp only: ac_simps) ``` huffman@53939 ` 623` ```qed ``` huffman@53939 ` 624` immler@68072 ` 625` ```lemma bounded_linear_imp_has_derivative: "bounded_linear f \ (f has_derivative f) net" ``` immler@68072 ` 626` ``` by (auto simp add: has_derivative_def linear_diff linear_linear linear_def ``` immler@68072 ` 627` ``` dest: bounded_linear.linear) ``` lp15@63469 ` 628` lp15@63469 ` 629` ```lemma linear_imp_has_derivative: ``` lp15@63469 ` 630` ``` fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" ``` lp15@63469 ` 631` ``` shows "linear f \ (f has_derivative f) net" ``` immler@68072 ` 632` ``` by (simp add: bounded_linear_imp_has_derivative linear_conv_bounded_linear) ``` lp15@63469 ` 633` lp15@63469 ` 634` ```lemma bounded_linear_imp_differentiable: "bounded_linear f \ f differentiable net" ``` lp15@63469 ` 635` ``` using bounded_linear_imp_has_derivative differentiable_def by blast ``` lp15@63469 ` 636` lp15@63469 ` 637` ```lemma linear_imp_differentiable: ``` lp15@63469 ` 638` ``` fixes f :: "'a::euclidean_space \ 'b::real_normed_vector" ``` lp15@63469 ` 639` ``` shows "linear f \ f differentiable net" ``` immler@68072 ` 640` ``` by (metis linear_imp_has_derivative differentiable_def) ``` lp15@63469 ` 641` wenzelm@49522 ` 642` nipkow@68901 ` 643` ```subsection%unimportant \We continue\ ``` huffman@44133 ` 644` huffman@44133 ` 645` ```lemma independent_bound: ``` wenzelm@53716 ` 646` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53716 ` 647` ``` shows "independent S \ finite S \ card S \ DIM('a)" ``` immler@68072 ` 648` ``` by (metis dim_subset_UNIV finiteI_independent dim_span_eq_card_independent) ``` immler@68072 ` 649` immler@68072 ` 650` ```lemmas independent_imp_finite = finiteI_independent ``` huffman@44133 ` 651` lp15@61609 ` 652` ```corollary ``` paulson@60303 ` 653` ``` fixes S :: "'a::euclidean_space set" ``` paulson@60303 ` 654` ``` assumes "independent S" ``` immler@68072 ` 655` ``` shows independent_card_le:"card S \ DIM('a)" ``` immler@68072 ` 656` ``` using assms independent_bound by auto ``` lp15@63075 ` 657` wenzelm@49663 ` 658` ```lemma dependent_biggerset: ``` wenzelm@56444 ` 659` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@56444 ` 660` ``` shows "(finite S \ card S > DIM('a)) \ dependent S" ``` huffman@44133 ` 661` ``` by (metis independent_bound not_less) ``` huffman@44133 ` 662` wenzelm@60420 ` 663` ```text \Picking an orthogonal replacement for a spanning set.\ ``` huffman@44133 ` 664` wenzelm@53406 ` 665` ```lemma vector_sub_project_orthogonal: ``` wenzelm@53406 ` 666` ``` fixes b x :: "'a::euclidean_space" ``` wenzelm@53406 ` 667` ``` shows "b \ (x - ((b \ x) / (b \ b)) *\<^sub>R b) = 0" ``` huffman@44133 ` 668` ``` unfolding inner_simps by auto ``` huffman@44133 ` 669` huffman@44528 ` 670` ```lemma pairwise_orthogonal_insert: ``` huffman@44528 ` 671` ``` assumes "pairwise orthogonal S" ``` wenzelm@49522 ` 672` ``` and "\y. y \ S \ orthogonal x y" ``` huffman@44528 ` 673` ``` shows "pairwise orthogonal (insert x S)" ``` huffman@44528 ` 674` ``` using assms unfolding pairwise_def ``` huffman@44528 ` 675` ``` by (auto simp add: orthogonal_commute) ``` huffman@44528 ` 676` huffman@44133 ` 677` ```lemma basis_orthogonal: ``` wenzelm@53406 ` 678` ``` fixes B :: "'a::real_inner set" ``` huffman@44133 ` 679` ``` assumes fB: "finite B" ``` huffman@44133 ` 680` ``` shows "\C. finite C \ card C \ card B \ span C = span B \ pairwise orthogonal C" ``` huffman@44133 ` 681` ``` (is " \C. ?P B C") ``` wenzelm@49522 ` 682` ``` using fB ``` wenzelm@49522 ` 683` ```proof (induct rule: finite_induct) ``` wenzelm@49522 ` 684` ``` case empty ``` wenzelm@53406 ` 685` ``` then show ?case ``` wenzelm@53406 ` 686` ``` apply (rule exI[where x="{}"]) ``` wenzelm@53406 ` 687` ``` apply (auto simp add: pairwise_def) ``` wenzelm@53406 ` 688` ``` done ``` huffman@44133 ` 689` ```next ``` wenzelm@49522 ` 690` ``` case (insert a B) ``` wenzelm@60420 ` 691` ``` note fB = \finite B\ and aB = \a \ B\ ``` wenzelm@60420 ` 692` ``` from \\C. finite C \ card C \ card B \ span C = span B \ pairwise orthogonal C\ ``` huffman@44133 ` 693` ``` obtain C where C: "finite C" "card C \ card B" ``` huffman@44133 ` 694` ``` "span C = span B" "pairwise orthogonal C" by blast ``` nipkow@64267 ` 695` ``` let ?a = "a - sum (\x. (x \ a / (x \ x)) *\<^sub>R x) C" ``` huffman@44133 ` 696` ``` let ?C = "insert ?a C" ``` wenzelm@53406 ` 697` ``` from C(1) have fC: "finite ?C" ``` wenzelm@53406 ` 698` ``` by simp ``` wenzelm@49522 ` 699` ``` from fB aB C(1,2) have cC: "card ?C \ card (insert a B)" ``` wenzelm@49522 ` 700` ``` by (simp add: card_insert_if) ``` wenzelm@53406 ` 701` ``` { ``` wenzelm@53406 ` 702` ``` fix x k ``` wenzelm@49522 ` 703` ``` have th0: "\(a::'a) b c. a - (b - c) = c + (a - b)" ``` wenzelm@49522 ` 704` ``` by (simp add: field_simps) ``` huffman@44133 ` 705` ``` 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 ` 706` ``` apply (simp only: scaleR_right_diff_distrib th0) ``` huffman@44133 ` 707` ``` apply (rule span_add_eq) ``` immler@68072 ` 708` ``` apply (rule span_scale) ``` nipkow@64267 ` 709` ``` apply (rule span_sum) ``` immler@68072 ` 710` ``` apply (rule span_scale) ``` immler@68072 ` 711` ``` apply (rule span_base) ``` wenzelm@49522 ` 712` ``` apply assumption ``` wenzelm@53406 ` 713` ``` done ``` wenzelm@53406 ` 714` ``` } ``` huffman@44133 ` 715` ``` then have SC: "span ?C = span (insert a B)" ``` huffman@44133 ` 716` ``` unfolding set_eq_iff span_breakdown_eq C(3)[symmetric] by auto ``` wenzelm@53406 ` 717` ``` { ``` wenzelm@53406 ` 718` ``` fix y ``` wenzelm@53406 ` 719` ``` assume yC: "y \ C" ``` wenzelm@53406 ` 720` ``` then have Cy: "C = insert y (C - {y})" ``` wenzelm@53406 ` 721` ``` by blast ``` wenzelm@53406 ` 722` ``` have fth: "finite (C - {y})" ``` wenzelm@53406 ` 723` ``` using C by simp ``` huffman@44528 ` 724` ``` have "orthogonal ?a y" ``` huffman@44528 ` 725` ``` unfolding orthogonal_def ``` nipkow@64267 ` 726` ``` unfolding inner_diff inner_sum_left right_minus_eq ``` nipkow@64267 ` 727` ``` unfolding sum.remove [OF \finite C\ \y \ C\] ``` huffman@44528 ` 728` ``` apply (clarsimp simp add: inner_commute[of y a]) ``` nipkow@64267 ` 729` ``` apply (rule sum.neutral) ``` huffman@44528 ` 730` ``` apply clarsimp ``` huffman@44528 ` 731` ``` apply (rule C(4)[unfolded pairwise_def orthogonal_def, rule_format]) ``` wenzelm@60420 ` 732` ``` using \y \ C\ by auto ``` wenzelm@53406 ` 733` ``` } ``` wenzelm@60420 ` 734` ``` with \pairwise orthogonal C\ have CPO: "pairwise orthogonal ?C" ``` huffman@44528 ` 735` ``` by (rule pairwise_orthogonal_insert) ``` wenzelm@53406 ` 736` ``` from fC cC SC CPO have "?P (insert a B) ?C" ``` wenzelm@53406 ` 737` ``` by blast ``` huffman@44133 ` 738` ``` then show ?case by blast ``` huffman@44133 ` 739` ```qed ``` huffman@44133 ` 740` huffman@44133 ` 741` ```lemma orthogonal_basis_exists: ``` huffman@44133 ` 742` ``` fixes V :: "('a::euclidean_space) set" ``` immler@68072 ` 743` ``` shows "\B. independent B \ B \ span V \ V \ span B \ ``` immler@68072 ` 744` ``` (card B = dim V) \ pairwise orthogonal B" ``` wenzelm@49663 ` 745` ```proof - ``` wenzelm@49522 ` 746` ``` from basis_exists[of V] obtain B where ``` wenzelm@53406 ` 747` ``` B: "B \ V" "independent B" "V \ span B" "card B = dim V" ``` immler@68073 ` 748` ``` by force ``` wenzelm@53406 ` 749` ``` from B have fB: "finite B" "card B = dim V" ``` wenzelm@53406 ` 750` ``` using independent_bound by auto ``` huffman@44133 ` 751` ``` from basis_orthogonal[OF fB(1)] obtain C where ``` wenzelm@53406 ` 752` ``` C: "finite C" "card C \ card B" "span C = span B" "pairwise orthogonal C" ``` wenzelm@53406 ` 753` ``` by blast ``` wenzelm@53406 ` 754` ``` from C B have CSV: "C \ span V" ``` immler@68072 ` 755` ``` by (metis span_superset span_mono subset_trans) ``` wenzelm@53406 ` 756` ``` from span_mono[OF B(3)] C have SVC: "span V \ span C" ``` wenzelm@53406 ` 757` ``` by (simp add: span_span) ``` huffman@44133 ` 758` ``` from card_le_dim_spanning[OF CSV SVC C(1)] C(2,3) fB ``` wenzelm@53406 ` 759` ``` have iC: "independent C" ``` huffman@44133 ` 760` ``` by (simp add: dim_span) ``` wenzelm@53406 ` 761` ``` from C fB have "card C \ dim V" ``` wenzelm@53406 ` 762` ``` by simp ``` wenzelm@53406 ` 763` ``` moreover have "dim V \ card C" ``` wenzelm@53406 ` 764` ``` using span_card_ge_dim[OF CSV SVC C(1)] ``` immler@68072 ` 765` ``` by simp ``` wenzelm@53406 ` 766` ``` ultimately have CdV: "card C = dim V" ``` wenzelm@53406 ` 767` ``` using C(1) by simp ``` wenzelm@53406 ` 768` ``` from C B CSV CdV iC show ?thesis ``` wenzelm@53406 ` 769` ``` by auto ``` huffman@44133 ` 770` ```qed ``` huffman@44133 ` 771` wenzelm@60420 ` 772` ```text \Low-dimensional subset is in a hyperplane (weak orthogonal complement).\ ``` huffman@44133 ` 773` wenzelm@49522 ` 774` ```lemma span_not_univ_orthogonal: ``` wenzelm@53406 ` 775` ``` fixes S :: "'a::euclidean_space set" ``` huffman@44133 ` 776` ``` assumes sU: "span S \ UNIV" ``` wenzelm@56444 ` 777` ``` shows "\a::'a. a \ 0 \ (\x \ span S. a \ x = 0)" ``` wenzelm@49522 ` 778` ```proof - ``` wenzelm@53406 ` 779` ``` from sU obtain a where a: "a \ span S" ``` wenzelm@53406 ` 780` ``` by blast ``` huffman@44133 ` 781` ``` from orthogonal_basis_exists obtain B where ``` immler@68072 ` 782` ``` B: "independent B" "B \ span S" "S \ span B" ``` immler@68072 ` 783` ``` "card B = dim S" "pairwise orthogonal B" ``` huffman@44133 ` 784` ``` by blast ``` wenzelm@53406 ` 785` ``` from B have fB: "finite B" "card B = dim S" ``` wenzelm@53406 ` 786` ``` using independent_bound by auto ``` huffman@44133 ` 787` ``` from span_mono[OF B(2)] span_mono[OF B(3)] ``` wenzelm@53406 ` 788` ``` have sSB: "span S = span B" ``` wenzelm@53406 ` 789` ``` by (simp add: span_span) ``` nipkow@64267 ` 790` ``` let ?a = "a - sum (\b. (a \ b / (b \ b)) *\<^sub>R b) B" ``` nipkow@64267 ` 791` ``` have "sum (\b. (a \ b / (b \ b)) *\<^sub>R b) B \ span S" ``` huffman@44133 ` 792` ``` unfolding sSB ``` nipkow@64267 ` 793` ``` apply (rule span_sum) ``` immler@68072 ` 794` ``` apply (rule span_scale) ``` immler@68072 ` 795` ``` apply (rule span_base) ``` wenzelm@49522 ` 796` ``` apply assumption ``` wenzelm@49522 ` 797` ``` done ``` wenzelm@53406 ` 798` ``` with a have a0:"?a \ 0" ``` wenzelm@53406 ` 799` ``` by auto ``` lp15@68058 ` 800` ``` have "?a \ x = 0" if "x\span B" for x ``` lp15@68058 ` 801` ``` proof (rule span_induct [OF that]) ``` wenzelm@49522 ` 802` ``` show "subspace {x. ?a \ x = 0}" ``` wenzelm@49522 ` 803` ``` by (auto simp add: subspace_def inner_add) ``` wenzelm@49522 ` 804` ``` next ``` wenzelm@53406 ` 805` ``` { ``` wenzelm@53406 ` 806` ``` fix x ``` wenzelm@53406 ` 807` ``` assume x: "x \ B" ``` wenzelm@53406 ` 808` ``` from x have B': "B = insert x (B - {x})" ``` wenzelm@53406 ` 809` ``` by blast ``` wenzelm@53406 ` 810` ``` have fth: "finite (B - {x})" ``` wenzelm@53406 ` 811` ``` using fB by simp ``` huffman@44133 ` 812` ``` have "?a \ x = 0" ``` wenzelm@53406 ` 813` ``` apply (subst B') ``` wenzelm@53406 ` 814` ``` using fB fth ``` nipkow@64267 ` 815` ``` unfolding sum_clauses(2)[OF fth] ``` huffman@44133 ` 816` ``` apply simp unfolding inner_simps ``` nipkow@64267 ` 817` ``` apply (clarsimp simp add: inner_add inner_sum_left) ``` nipkow@64267 ` 818` ``` apply (rule sum.neutral, rule ballI) ``` wenzelm@63170 ` 819` ``` apply (simp only: inner_commute) ``` wenzelm@49711 ` 820` ``` apply (auto simp add: x field_simps ``` wenzelm@49711 ` 821` ``` intro: B(5)[unfolded pairwise_def orthogonal_def, rule_format]) ``` wenzelm@53406 ` 822` ``` done ``` wenzelm@53406 ` 823` ``` } ``` lp15@68058 ` 824` ``` then show "?a \ x = 0" if "x \ B" for x ``` lp15@68058 ` 825` ``` using that by blast ``` lp15@68058 ` 826` ``` qed ``` wenzelm@53406 ` 827` ``` with a0 show ?thesis ``` wenzelm@53406 ` 828` ``` unfolding sSB by (auto intro: exI[where x="?a"]) ``` huffman@44133 ` 829` ```qed ``` huffman@44133 ` 830` huffman@44133 ` 831` ```lemma span_not_univ_subset_hyperplane: ``` wenzelm@53406 ` 832` ``` fixes S :: "'a::euclidean_space set" ``` wenzelm@53406 ` 833` ``` assumes SU: "span S \ UNIV" ``` huffman@44133 ` 834` ``` shows "\ a. a \0 \ span S \ {x. a \ x = 0}" ``` huffman@44133 ` 835` ``` using span_not_univ_orthogonal[OF SU] by auto ``` huffman@44133 ` 836` wenzelm@49663 ` 837` ```lemma lowdim_subset_hyperplane: ``` wenzelm@53406 ` 838` ``` fixes S :: "'a::euclidean_space set" ``` huffman@44133 ` 839` ``` assumes d: "dim S < DIM('a)" ``` wenzelm@56444 ` 840` ``` shows "\a::'a. a \ 0 \ span S \ {x. a \ x = 0}" ``` wenzelm@49522 ` 841` ```proof - ``` wenzelm@53406 ` 842` ``` { ``` wenzelm@53406 ` 843` ``` assume "span S = UNIV" ``` wenzelm@53406 ` 844` ``` then have "dim (span S) = dim (UNIV :: ('a) set)" ``` wenzelm@53406 ` 845` ``` by simp ``` wenzelm@53406 ` 846` ``` then have "dim S = DIM('a)" ``` immler@68072 ` 847` ``` by (metis Euclidean_Space.dim_UNIV dim_span) ``` wenzelm@53406 ` 848` ``` with d have False by arith ``` wenzelm@53406 ` 849` ``` } ``` wenzelm@53406 ` 850` ``` then have th: "span S \ UNIV" ``` wenzelm@53406 ` 851` ``` by blast ``` huffman@44133 ` 852` ``` from span_not_univ_subset_hyperplane[OF th] show ?thesis . ``` huffman@44133 ` 853` ```qed ``` huffman@44133 ` 854` huffman@44133 ` 855` ```lemma linear_eq_stdbasis: ``` wenzelm@56444 ` 856` ``` fixes f :: "'a::euclidean_space \ _" ``` wenzelm@56444 ` 857` ``` assumes lf: "linear f" ``` wenzelm@49663 ` 858` ``` and lg: "linear g" ``` lp15@68058 ` 859` ``` and fg: "\b. b \ Basis \ f b = g b" ``` huffman@44133 ` 860` ``` shows "f = g" ``` immler@68072 ` 861` ``` using linear_eq_on_span[OF lf lg, of Basis] fg ``` immler@68072 ` 862` ``` by auto ``` immler@68072 ` 863` huffman@44133 ` 864` wenzelm@60420 ` 865` ```text \Similar results for bilinear functions.\ ``` huffman@44133 ` 866` huffman@44133 ` 867` ```lemma bilinear_eq: ``` huffman@44133 ` 868` ``` assumes bf: "bilinear f" ``` wenzelm@49522 ` 869` ``` and bg: "bilinear g" ``` wenzelm@53406 ` 870` ``` and SB: "S \ span B" ``` wenzelm@53406 ` 871` ``` and TC: "T \ span C" ``` lp15@68058 ` 872` ``` and "x\S" "y\T" ``` lp15@68058 ` 873` ``` and fg: "\x y. \x \ B; y\ C\ \ f x y = g x y" ``` lp15@68058 ` 874` ``` shows "f x y = g x y" ``` wenzelm@49663 ` 875` ```proof - ``` huffman@44170 ` 876` ``` let ?P = "{x. \y\ span C. f x y = g x y}" ``` huffman@44133 ` 877` ``` from bf bg have sp: "subspace ?P" ``` huffman@53600 ` 878` ``` unfolding bilinear_def linear_iff subspace_def bf bg ``` immler@68072 ` 879` ``` by (auto simp add: span_zero bilinear_lzero[OF bf] bilinear_lzero[OF bg] ``` immler@68072 ` 880` ``` span_add Ball_def ``` wenzelm@49663 ` 881` ``` intro: bilinear_ladd[OF bf]) ``` lp15@68058 ` 882` ``` have sfg: "\x. x \ B \ subspace {a. f x a = g x a}" ``` huffman@44133 ` 883` ``` apply (auto simp add: subspace_def) ``` huffman@53600 ` 884` ``` using bf bg unfolding bilinear_def linear_iff ``` immler@68072 ` 885` ``` apply (auto simp add: span_zero bilinear_rzero[OF bf] bilinear_rzero[OF bg] ``` immler@68072 ` 886` ``` span_add Ball_def ``` wenzelm@49663 ` 887` ``` intro: bilinear_ladd[OF bf]) ``` wenzelm@49522 ` 888` ``` done ``` lp15@68058 ` 889` ``` have "\y\ span C. f x y = g x y" if "x \ span B" for x ``` lp15@68058 ` 890` ``` apply (rule span_induct [OF that sp]) ``` lp15@68062 ` 891` ``` using fg sfg span_induct by blast ``` wenzelm@53406 ` 892` ``` then show ?thesis ``` lp15@68058 ` 893` ``` using SB TC assms by auto ``` huffman@44133 ` 894` ```qed ``` huffman@44133 ` 895` wenzelm@49522 ` 896` ```lemma bilinear_eq_stdbasis: ``` wenzelm@53406 ` 897` ``` fixes f :: "'a::euclidean_space \ 'b::euclidean_space \ _" ``` huffman@44133 ` 898` ``` assumes bf: "bilinear f" ``` wenzelm@49522 ` 899` ``` and bg: "bilinear g" ``` lp15@68058 ` 900` ``` and fg: "\i j. i \ Basis \ j \ Basis \ f i j = g i j" ``` huffman@44133 ` 901` ``` shows "f = g" ``` immler@68074 ` 902` ``` using bilinear_eq[OF bf bg equalityD2[OF span_Basis] equalityD2[OF span_Basis]] fg by blast ``` wenzelm@49522 ` 903` immler@69619 ` 904` wenzelm@60420 ` 905` ```subsection \Infinity norm\ ``` huffman@44133 ` 906` immler@67962 ` 907` ```definition%important "infnorm (x::'a::euclidean_space) = Sup {\x \ b\ |b. b \ Basis}" ``` huffman@44133 ` 908` huffman@44133 ` 909` ```lemma infnorm_set_image: ``` wenzelm@53716 ` 910` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@56444 ` 911` ``` shows "{\x \ i\ |i. i \ Basis} = (\i. \x \ i\) ` Basis" ``` hoelzl@50526 ` 912` ``` by blast ``` huffman@44133 ` 913` wenzelm@53716 ` 914` ```lemma infnorm_Max: ``` wenzelm@53716 ` 915` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@56444 ` 916` ``` shows "infnorm x = Max ((\i. \x \ i\) ` Basis)" ``` haftmann@62343 ` 917` ``` by (simp add: infnorm_def infnorm_set_image cSup_eq_Max) ``` hoelzl@51475 ` 918` huffman@44133 ` 919` ```lemma infnorm_set_lemma: ``` wenzelm@53716 ` 920` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@56444 ` 921` ``` shows "finite {\x \ i\ |i. i \ Basis}" ``` wenzelm@56444 ` 922` ``` and "{\x \ i\ |i. i \ Basis} \ {}" ``` huffman@44133 ` 923` ``` unfolding infnorm_set_image ``` huffman@44133 ` 924` ``` by auto ``` huffman@44133 ` 925` wenzelm@53406 ` 926` ```lemma infnorm_pos_le: ``` wenzelm@53406 ` 927` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@53406 ` 928` ``` shows "0 \ infnorm x" ``` hoelzl@51475 ` 929` ``` by (simp add: infnorm_Max Max_ge_iff ex_in_conv) ``` huffman@44133 ` 930` wenzelm@53406 ` 931` ```lemma infnorm_triangle: ``` wenzelm@53406 ` 932` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@53406 ` 933` ``` shows "infnorm (x + y) \ infnorm x + infnorm y" ``` wenzelm@49522 ` 934` ```proof - ``` hoelzl@51475 ` 935` ``` have *: "\a b c d :: real. \a\ \ c \ \b\ \ d \ \a + b\ \ c + d" ``` hoelzl@51475 ` 936` ``` by simp ``` huffman@44133 ` 937` ``` show ?thesis ``` hoelzl@51475 ` 938` ``` by (auto simp: infnorm_Max inner_add_left intro!: *) ``` huffman@44133 ` 939` ```qed ``` huffman@44133 ` 940` wenzelm@53406 ` 941` ```lemma infnorm_eq_0: ``` wenzelm@53406 ` 942` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@53406 ` 943` ``` shows "infnorm x = 0 \ x = 0" ``` wenzelm@49522 ` 944` ```proof - ``` hoelzl@51475 ` 945` ``` have "infnorm x \ 0 \ x = 0" ``` hoelzl@51475 ` 946` ``` unfolding infnorm_Max by (simp add: euclidean_all_zero_iff) ``` hoelzl@51475 ` 947` ``` then show ?thesis ``` hoelzl@51475 ` 948` ``` using infnorm_pos_le[of x] by simp ``` huffman@44133 ` 949` ```qed ``` huffman@44133 ` 950` huffman@44133 ` 951` ```lemma infnorm_0: "infnorm 0 = 0" ``` huffman@44133 ` 952` ``` by (simp add: infnorm_eq_0) ``` huffman@44133 ` 953` huffman@44133 ` 954` ```lemma infnorm_neg: "infnorm (- x) = infnorm x" ``` lp15@68062 ` 955` ``` unfolding infnorm_def by simp ``` huffman@44133 ` 956` huffman@44133 ` 957` ```lemma infnorm_sub: "infnorm (x - y) = infnorm (y - x)" ``` lp15@68062 ` 958` ``` by (metis infnorm_neg minus_diff_eq) ``` lp15@68062 ` 959` lp15@68062 ` 960` ```lemma absdiff_infnorm: "\infnorm x - infnorm y\ \ infnorm (x - y)" ``` wenzelm@49522 ` 961` ```proof - ``` lp15@68062 ` 962` ``` have *: "\(nx::real) n ny. nx \ n + ny \ ny \ n + nx \ \nx - ny\ \ n" ``` huffman@44133 ` 963` ``` by arith ``` lp15@68062 ` 964` ``` show ?thesis ``` lp15@68062 ` 965` ``` proof (rule *) ``` lp15@68062 ` 966` ``` from infnorm_triangle[of "x - y" " y"] infnorm_triangle[of "x - y" "-x"] ``` lp15@68062 ` 967` ``` show "infnorm x \ infnorm (x - y) + infnorm y" "infnorm y \ infnorm (x - y) + infnorm x" ``` lp15@68062 ` 968` ``` by (simp_all add: field_simps infnorm_neg) ``` lp15@68062 ` 969` ``` qed ``` huffman@44133 ` 970` ```qed ``` huffman@44133 ` 971` wenzelm@53406 ` 972` ```lemma real_abs_infnorm: "\infnorm x\ = infnorm x" ``` huffman@44133 ` 973` ``` using infnorm_pos_le[of x] by arith ``` huffman@44133 ` 974` hoelzl@50526 ` 975` ```lemma Basis_le_infnorm: ``` wenzelm@53406 ` 976` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@53406 ` 977` ``` shows "b \ Basis \ \x \ b\ \ infnorm x" ``` hoelzl@51475 ` 978` ``` by (simp add: infnorm_Max) ``` huffman@44133 ` 979` wenzelm@56444 ` 980` ```lemma infnorm_mul: "infnorm (a *\<^sub>R x) = \a\ * infnorm x" ``` hoelzl@51475 ` 981` ``` unfolding infnorm_Max ``` hoelzl@51475 ` 982` ```proof (safe intro!: Max_eqI) ``` hoelzl@51475 ` 983` ``` let ?B = "(\i. \x \ i\) ` Basis" ``` lp15@68062 ` 984` ``` { fix b :: 'a ``` wenzelm@53406 ` 985` ``` assume "b \ Basis" ``` wenzelm@53406 ` 986` ``` then show "\a *\<^sub>R x \ b\ \ \a\ * Max ?B" ``` wenzelm@53406 ` 987` ``` by (simp add: abs_mult mult_left_mono) ``` wenzelm@53406 ` 988` ``` next ``` wenzelm@53406 ` 989` ``` from Max_in[of ?B] obtain b where "b \ Basis" "Max ?B = \x \ b\" ``` wenzelm@53406 ` 990` ``` by (auto simp del: Max_in) ``` wenzelm@53406 ` 991` ``` then show "\a\ * Max ((\i. \x \ i\) ` Basis) \ (\i. \a *\<^sub>R x \ i\) ` Basis" ``` wenzelm@53406 ` 992` ``` by (intro image_eqI[where x=b]) (auto simp: abs_mult) ``` wenzelm@53406 ` 993` ``` } ``` hoelzl@51475 ` 994` ```qed simp ``` hoelzl@51475 ` 995` wenzelm@53406 ` 996` ```lemma infnorm_mul_lemma: "infnorm (a *\<^sub>R x) \ \a\ * infnorm x" ``` hoelzl@51475 ` 997` ``` unfolding infnorm_mul .. ``` huffman@44133 ` 998` huffman@44133 ` 999` ```lemma infnorm_pos_lt: "infnorm x > 0 \ x \ 0" ``` huffman@44133 ` 1000` ``` using infnorm_pos_le[of x] infnorm_eq_0[of x] by arith ``` huffman@44133 ` 1001` wenzelm@60420 ` 1002` ```text \Prove that it differs only up to a bound from Euclidean norm.\ ``` huffman@44133 ` 1003` huffman@44133 ` 1004` ```lemma infnorm_le_norm: "infnorm x \ norm x" ``` hoelzl@51475 ` 1005` ``` by (simp add: Basis_le_norm infnorm_Max) ``` hoelzl@50526 ` 1006` wenzelm@53716 ` 1007` ```lemma norm_le_infnorm: ``` wenzelm@53716 ` 1008` ``` fixes x :: "'a::euclidean_space" ``` wenzelm@53716 ` 1009` ``` shows "norm x \ sqrt DIM('a) * infnorm x" ``` lp15@68062 ` 1010` ``` unfolding norm_eq_sqrt_inner id_def ``` lp15@68062 ` 1011` ```proof (rule real_le_lsqrt[OF inner_ge_zero]) ``` lp15@68062 ` 1012` ``` show "sqrt DIM('a) * infnorm x \ 0" ``` huffman@44133 ` 1013` ``` by (simp add: zero_le_mult_iff infnorm_pos_le) ``` lp15@68062 ` 1014` ``` have "x \ x \ (\b\Basis. x \ b * (x \ b))" ``` lp15@68062 ` 1015` ``` by (metis euclidean_inner order_refl) ``` lp15@68062 ` 1016` ``` also have "... \ DIM('a) * \infnorm x\\<^sup>2" ``` lp15@68062 ` 1017` ``` by (rule sum_bounded_above) (metis Basis_le_infnorm abs_le_square_iff power2_eq_square real_abs_infnorm) ``` lp15@68062 ` 1018` ``` also have "... \ (sqrt DIM('a) * infnorm x)\<^sup>2" ``` lp15@68062 ` 1019` ``` by (simp add: power_mult_distrib) ``` lp15@68062 ` 1020` ``` finally show "x \ x \ (sqrt DIM('a) * infnorm x)\<^sup>2" . ``` huffman@44133 ` 1021` ```qed ``` huffman@44133 ` 1022` huffman@44646 ` 1023` ```lemma tendsto_infnorm [tendsto_intros]: ``` wenzelm@61973 ` 1024` ``` assumes "(f \ a) F" ``` wenzelm@61973 ` 1025` ``` shows "((\x. infnorm (f x)) \ infnorm a) F" ``` huffman@44646 ` 1026` ```proof (rule tendsto_compose [OF LIM_I assms]) ``` wenzelm@53406 ` 1027` ``` fix r :: real ``` wenzelm@53406 ` 1028` ``` assume "r > 0" ``` wenzelm@49522 ` 1029` ``` then show "\s>0. \x. x \ a \ norm (x - a) < s \ norm (infnorm x - infnorm a) < r" ``` lp15@68062 ` 1030` ``` by (metis real_norm_def le_less_trans absdiff_infnorm infnorm_le_norm) ``` huffman@44646 ` 1031` ```qed ``` huffman@44646 ` 1032` wenzelm@60420 ` 1033` ```text \Equality in Cauchy-Schwarz and triangle inequalities.\ ``` huffman@44133 ` 1034` wenzelm@53406 ` 1035` ```lemma norm_cauchy_schwarz_eq: "x \ y = norm x * norm y \ norm x *\<^sub>R y = norm y *\<^sub>R x" ``` wenzelm@53406 ` 1036` ``` (is "?lhs \ ?rhs") ``` lp15@68062 ` 1037` ```proof (cases "x=0") ``` lp15@68062 ` 1038` ``` case True ``` lp15@68062 ` 1039` ``` then show ?thesis ``` lp15@68062 ` 1040` ``` by auto ``` lp15@68062 ` 1041` ```next ``` lp15@68062 ` 1042` ``` case False ``` lp15@68062 ` 1043` ``` from inner_eq_zero_iff[of "norm y *\<^sub>R x - norm x *\<^sub>R y"] ``` lp15@68062 ` 1044` ``` have "?rhs \ ``` wenzelm@49522 ` 1045` ``` (norm y * (norm y * norm x * norm x - norm x * (x \ y)) - ``` wenzelm@49522 ` 1046` ``` norm x * (norm y * (y \ x) - norm x * norm y * norm y) = 0)" ``` lp15@68062 ` 1047` ``` using False unfolding inner_simps ``` lp15@68062 ` 1048` ``` by (auto simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute field_simps) ``` lp15@68062 ` 1049` ``` also have "\ \ (2 * norm x * norm y * (norm x * norm y - x \ y) = 0)" ``` lp15@68062 ` 1050` ``` using False by (simp add: field_simps inner_commute) ``` lp15@68062 ` 1051` ``` also have "\ \ ?lhs" ``` lp15@68062 ` 1052` ``` using False by auto ``` lp15@68062 ` 1053` ``` finally show ?thesis by metis ``` huffman@44133 ` 1054` ```qed ``` huffman@44133 ` 1055` huffman@44133 ` 1056` ```lemma norm_cauchy_schwarz_abs_eq: ``` wenzelm@56444 ` 1057` ``` "\x \ y\ = norm x * norm y \ ``` wenzelm@53716 ` 1058` ``` norm x *\<^sub>R y = norm y *\<^sub>R x \ norm x *\<^sub>R y = - norm y *\<^sub>R x" ``` wenzelm@53406 ` 1059` ``` (is "?lhs \ ?rhs") ``` wenzelm@49522 ` 1060` ```proof - ``` wenzelm@56444 ` 1061` ``` have th: "\(x::real) a. a \ 0 \ \x\ = a \ x = a \ x = - a" ``` wenzelm@53406 ` 1062` ``` by arith ``` huffman@44133 ` 1063` ``` have "?rhs \ norm x *\<^sub>R y = norm y *\<^sub>R x \ norm (- x) *\<^sub>R y = norm y *\<^sub>R (- x)" ``` huffman@44133 ` 1064` ``` by simp ``` lp15@68062 ` 1065` ``` also have "\ \ (x \ y = norm x * norm y \ (- x) \ y = norm x * norm y)" ``` huffman@44133 ` 1066` ``` unfolding norm_cauchy_schwarz_eq[symmetric] ``` huffman@44133 ` 1067` ``` unfolding norm_minus_cancel norm_scaleR .. ``` huffman@44133 ` 1068` ``` also have "\ \ ?lhs" ``` wenzelm@53406 ` 1069` ``` unfolding th[OF mult_nonneg_nonneg, OF norm_ge_zero[of x] norm_ge_zero[of y]] inner_simps ``` wenzelm@53406 ` 1070` ``` by auto ``` huffman@44133 ` 1071` ``` finally show ?thesis .. ``` huffman@44133 ` 1072` ```qed ``` huffman@44133 ` 1073` huffman@44133 ` 1074` ```lemma norm_triangle_eq: ``` huffman@44133 ` 1075` ``` fixes x y :: "'a::real_inner" ``` wenzelm@53406 ` 1076` ``` shows "norm (x + y) = norm x + norm y \ norm x *\<^sub>R y = norm y *\<^sub>R x" ``` lp15@68062 ` 1077` ```proof (cases "x = 0 \ y = 0") ``` lp15@68062 ` 1078` ``` case True ``` lp15@68062 ` 1079` ``` then show ?thesis ``` lp15@68062 ` 1080` ``` by force ``` lp15@68062 ` 1081` ```next ``` lp15@68062 ` 1082` ``` case False ``` lp15@68062 ` 1083` ``` then have n: "norm x > 0" "norm y > 0" ``` lp15@68062 ` 1084` ``` by auto ``` lp15@68062 ` 1085` ``` have "norm (x + y) = norm x + norm y \ (norm (x + y))\<^sup>2 = (norm x + norm y)\<^sup>2" ``` lp15@68062 ` 1086` ``` by simp ``` lp15@68062 ` 1087` ``` also have "\ \ norm x *\<^sub>R y = norm y *\<^sub>R x" ``` lp15@68062 ` 1088` ``` unfolding norm_cauchy_schwarz_eq[symmetric] ``` lp15@68062 ` 1089` ``` unfolding power2_norm_eq_inner inner_simps ``` lp15@68062 ` 1090` ``` by (simp add: power2_norm_eq_inner[symmetric] power2_eq_square inner_commute field_simps) ``` lp15@68062 ` 1091` ``` finally show ?thesis . ``` huffman@44133 ` 1092` ```qed ``` huffman@44133 ` 1093` wenzelm@49522 ` 1094` wenzelm@60420 ` 1095` ```subsection \Collinearity\ ``` huffman@44133 ` 1096` immler@67962 ` 1097` ```definition%important collinear :: "'a::real_vector set \ bool" ``` wenzelm@49522 ` 1098` ``` where "collinear S \ (\u. \x \ S. \ y \ S. \c. x - y = c *\<^sub>R u)" ``` huffman@44133 ` 1099` lp15@66287 ` 1100` ```lemma collinear_alt: ``` lp15@66287 ` 1101` ``` "collinear S \ (\u v. \x \ S. \c. x = u + c *\<^sub>R v)" (is "?lhs = ?rhs") ``` lp15@66287 ` 1102` ```proof ``` lp15@66287 ` 1103` ``` assume ?lhs ``` lp15@66287 ` 1104` ``` then show ?rhs ``` lp15@66287 ` 1105` ``` unfolding collinear_def by (metis Groups.add_ac(2) diff_add_cancel) ``` lp15@66287 ` 1106` ```next ``` lp15@66287 ` 1107` ``` assume ?rhs ``` lp15@66287 ` 1108` ``` then obtain u v where *: "\x. x \ S \ \c. x = u + c *\<^sub>R v" ``` lp15@66287 ` 1109` ``` by (auto simp: ) ``` lp15@66287 ` 1110` ``` have "\c. x - y = c *\<^sub>R v" if "x \ S" "y \ S" for x y ``` lp15@66287 ` 1111` ``` by (metis *[OF \x \ S\] *[OF \y \ S\] scaleR_left.diff add_diff_cancel_left) ``` lp15@66287 ` 1112` ``` then show ?lhs ``` lp15@66287 ` 1113` ``` using collinear_def by blast ``` lp15@66287 ` 1114` ```qed ``` lp15@66287 ` 1115` lp15@66287 ` 1116` ```lemma collinear: ``` lp15@66287 ` 1117` ``` fixes S :: "'a::{perfect_space,real_vector} set" ``` lp15@66287 ` 1118` ``` shows "collinear S \ (\u. u \ 0 \ (\x \ S. \ y \ S. \c. x - y = c *\<^sub>R u))" ``` lp15@66287 ` 1119` ```proof - ``` lp15@66287 ` 1120` ``` have "\v. v \ 0 \ (\x\S. \y\S. \c. x - y = c *\<^sub>R v)" ``` lp15@66287 ` 1121` ``` if "\x\S. \y\S. \c. x - y = c *\<^sub>R u" "u=0" for u ``` lp15@66287 ` 1122` ``` proof - ``` lp15@66287 ` 1123` ``` have "\x\S. \y\S. x = y" ``` lp15@66287 ` 1124` ``` using that by auto ``` lp15@66287 ` 1125` ``` moreover ``` lp15@66287 ` 1126` ``` obtain v::'a where "v \ 0" ``` lp15@66287 ` 1127` ``` using UNIV_not_singleton [of 0] by auto ``` lp15@66287 ` 1128` ``` ultimately have "\x\S. \y\S. \c. x - y = c *\<^sub>R v" ``` lp15@66287 ` 1129` ``` by auto ``` lp15@66287 ` 1130` ``` then show ?thesis ``` lp15@66287 ` 1131` ``` using \v \ 0\ by blast ``` lp15@66287 ` 1132` ``` qed ``` lp15@66287 ` 1133` ``` then show ?thesis ``` lp15@66287 ` 1134` ``` apply (clarsimp simp: collinear_def) ``` immler@68072 ` 1135` ``` by (metis scaleR_zero_right vector_fraction_eq_iff) ``` lp15@66287 ` 1136` ```qed ``` lp15@66287 ` 1137` lp15@63881 ` 1138` ```lemma collinear_subset: "\collinear T; S \ T\ \ collinear S" ``` lp15@63881 ` 1139` ``` by (meson collinear_def subsetCE) ``` lp15@63881 ` 1140` paulson@60762 ` 1141` ```lemma collinear_empty [iff]: "collinear {}" ``` wenzelm@53406 ` 1142` ``` by (simp add: collinear_def) ``` huffman@44133 ` 1143` paulson@60762 ` 1144` ```lemma collinear_sing [iff]: "collinear {x}" ``` huffman@44133 ` 1145` ``` by (simp add: collinear_def) ``` huffman@44133 ` 1146` paulson@60762 ` 1147` ```lemma collinear_2 [iff]: "collinear {x, y}" ``` huffman@44133 ` 1148` ``` apply (simp add: collinear_def) ``` huffman@44133 ` 1149` ``` apply (rule exI[where x="x - y"]) ``` lp15@68062 ` 1150` ``` by (metis minus_diff_eq scaleR_left.minus scaleR_one) ``` huffman@44133 ` 1151` wenzelm@56444 ` 1152` ```lemma collinear_lemma: "collinear {0, x, y} \ x = 0 \ y = 0 \ (\c. y = c *\<^sub>R x)" ``` wenzelm@53406 ` 1153` ``` (is "?lhs \ ?rhs") ``` lp15@68062 ` 1154` ```proof (cases "x = 0 \ y = 0") ``` lp15@68062 ` 1155` ``` case True ``` lp15@68062 ` 1156` ``` then show ?thesis ``` lp15@68062 ` 1157` ``` by (auto simp: insert_commute) ``` lp15@68062 ` 1158` ```next ``` lp15@68062 ` 1159` ``` case False ``` lp15@68062 ` 1160` ``` show ?thesis ``` lp15@68062 ` 1161` ``` proof ``` lp15@68062 ` 1162` ``` assume h: "?lhs" ``` lp15@68062 ` 1163` ``` then obtain u where u: "\ x\ {0,x,y}. \y\ {0,x,y}. \c. x - y = c *\<^sub>R u" ``` lp15@68062 ` 1164` ``` unfolding collinear_def by blast ``` lp15@68062 ` 1165` ``` from u[rule_format, of x 0] u[rule_format, of y 0] ``` lp15@68062 ` 1166` ``` obtain cx and cy where ``` lp15@68062 ` 1167` ``` cx: "x = cx *\<^sub>R u" and cy: "y = cy *\<^sub>R u" ``` lp15@68062 ` 1168` ``` by auto ``` lp15@68062 ` 1169` ``` from cx cy False have cx0: "cx \ 0" and cy0: "cy \ 0" by auto ``` lp15@68062 ` 1170` ``` let ?d = "cy / cx" ``` lp15@68062 ` 1171` ``` from cx cy cx0 have "y = ?d *\<^sub>R x" ``` lp15@68062 ` 1172` ``` by simp ``` lp15@68062 ` 1173` ``` then show ?rhs using False by blast ``` lp15@68062 ` 1174` ``` next ``` lp15@68062 ` 1175` ``` assume h: "?rhs" ``` lp15@68062 ` 1176` ``` then obtain c where c: "y = c *\<^sub>R x" ``` lp15@68062 ` 1177` ``` using False by blast ``` lp15@68062 ` 1178` ``` show ?lhs ``` lp15@68062 ` 1179` ``` unfolding collinear_def c ``` lp15@68062 ` 1180` ``` apply (rule exI[where x=x]) ``` lp15@68062 ` 1181` ``` apply auto ``` lp15@68062 ` 1182` ``` apply (rule exI[where x="- 1"], simp) ``` lp15@68062 ` 1183` ``` apply (rule exI[where x= "-c"], simp) ``` huffman@44133 ` 1184` ``` apply (rule exI[where x=1], simp) ``` lp15@68062 ` 1185` ``` apply (rule exI[where x="1 - c"], simp add: scaleR_left_diff_distrib) ``` lp15@68062 ` 1186` ``` apply (rule exI[where x="c - 1"], simp add: scaleR_left_diff_distrib) ``` lp15@68062 ` 1187` ``` done ``` lp15@68062 ` 1188` ``` qed ``` huffman@44133 ` 1189` ```qed ``` huffman@44133 ` 1190` wenzelm@56444 ` 1191` ```lemma norm_cauchy_schwarz_equal: "\x \ y\ = norm x * norm y \ collinear {0, x, y}" ``` lp15@68062 ` 1192` ```proof (cases "x=0") ``` lp15@68062 ` 1193` ``` case True ``` lp15@68062 ` 1194` ``` then show ?thesis ``` lp15@68062 ` 1195` ``` by (auto simp: insert_commute) ``` lp15@68062 ` 1196` ```next ``` lp15@68062 ` 1197` ``` case False ``` lp15@68062 ` 1198` ``` then have nnz: "norm x \ 0" ``` lp15@68062 ` 1199` ``` by auto ``` lp15@68062 ` 1200` ``` show ?thesis ``` lp15@68062 ` 1201` ``` proof ``` lp15@68062 ` 1202` ``` assume "\x \ y\ = norm x * norm y" ``` lp15@68062 ` 1203` ``` then show "collinear {0, x, y}" ``` lp15@68062 ` 1204` ``` unfolding norm_cauchy_schwarz_abs_eq collinear_lemma ``` lp15@68062 ` 1205` ``` by (meson eq_vector_fraction_iff nnz) ``` lp15@68062 ` 1206` ``` next ``` lp15@68062 ` 1207` ``` assume "collinear {0, x, y}" ``` lp15@68062 ` 1208` ``` with False show "\x \ y\ = norm x * norm y" ``` lp15@68062 ` 1209` ``` unfolding norm_cauchy_schwarz_abs_eq collinear_lemma by (auto simp: abs_if) ``` lp15@68062 ` 1210` ``` qed ``` lp15@68062 ` 1211` ```qed ``` wenzelm@49522 ` 1212` immler@54776 ` 1213` ```end ```