src/HOL/Real_Vector_Spaces.thy
 author wenzelm Tue Sep 26 20:54:40 2017 +0200 (22 months ago) changeset 66695 91500c024c7f parent 66422 2891f33ed4c8 child 66793 deabce3ccf1f permissions -rw-r--r--
tuned;
 hoelzl@51524 ` 1` ```(* Title: HOL/Real_Vector_Spaces.thy ``` haftmann@27552 ` 2` ``` Author: Brian Huffman ``` hoelzl@51531 ` 3` ``` Author: Johannes Hölzl ``` huffman@20504 ` 4` ```*) ``` huffman@20504 ` 5` wenzelm@60758 ` 6` ```section \Vector Spaces and Algebras over the Reals\ ``` huffman@20504 ` 7` hoelzl@51524 ` 8` ```theory Real_Vector_Spaces ``` hoelzl@51531 ` 9` ```imports Real Topological_Spaces ``` huffman@20504 ` 10` ```begin ``` huffman@20504 ` 11` wenzelm@60758 ` 12` ```subsection \Locale for additive functions\ ``` huffman@20504 ` 13` huffman@20504 ` 14` ```locale additive = ``` huffman@20504 ` 15` ``` fixes f :: "'a::ab_group_add \ 'b::ab_group_add" ``` huffman@20504 ` 16` ``` assumes add: "f (x + y) = f x + f y" ``` huffman@27443 ` 17` ```begin ``` huffman@20504 ` 18` huffman@27443 ` 19` ```lemma zero: "f 0 = 0" ``` huffman@20504 ` 20` ```proof - ``` huffman@20504 ` 21` ``` have "f 0 = f (0 + 0)" by simp ``` huffman@20504 ` 22` ``` also have "\ = f 0 + f 0" by (rule add) ``` huffman@20504 ` 23` ``` finally show "f 0 = 0" by simp ``` huffman@20504 ` 24` ```qed ``` huffman@20504 ` 25` huffman@27443 ` 26` ```lemma minus: "f (- x) = - f x" ``` huffman@20504 ` 27` ```proof - ``` huffman@20504 ` 28` ``` have "f (- x) + f x = f (- x + x)" by (rule add [symmetric]) ``` huffman@20504 ` 29` ``` also have "\ = - f x + f x" by (simp add: zero) ``` huffman@20504 ` 30` ``` finally show "f (- x) = - f x" by (rule add_right_imp_eq) ``` huffman@20504 ` 31` ```qed ``` huffman@20504 ` 32` huffman@27443 ` 33` ```lemma diff: "f (x - y) = f x - f y" ``` haftmann@54230 ` 34` ``` using add [of x "- y"] by (simp add: minus) ``` huffman@20504 ` 35` nipkow@64267 ` 36` ```lemma sum: "f (sum g A) = (\x\A. f (g x))" ``` wenzelm@63915 ` 37` ``` by (induct A rule: infinite_finite_induct) (simp_all add: zero add) ``` huffman@22942 ` 38` huffman@27443 ` 39` ```end ``` huffman@20504 ` 40` wenzelm@63545 ` 41` wenzelm@60758 ` 42` ```subsection \Vector spaces\ ``` huffman@28029 ` 43` huffman@28029 ` 44` ```locale vector_space = ``` huffman@28029 ` 45` ``` fixes scale :: "'a::field \ 'b::ab_group_add \ 'b" ``` wenzelm@63545 ` 46` ``` assumes scale_right_distrib [algebra_simps]: "scale a (x + y) = scale a x + scale a y" ``` wenzelm@63545 ` 47` ``` and scale_left_distrib [algebra_simps]: "scale (a + b) x = scale a x + scale b x" ``` wenzelm@63545 ` 48` ``` and scale_scale [simp]: "scale a (scale b x) = scale (a * b) x" ``` wenzelm@63545 ` 49` ``` and scale_one [simp]: "scale 1 x = x" ``` huffman@28029 ` 50` ```begin ``` huffman@28029 ` 51` wenzelm@63545 ` 52` ```lemma scale_left_commute: "scale a (scale b x) = scale b (scale a x)" ``` wenzelm@63545 ` 53` ``` by (simp add: mult.commute) ``` huffman@28029 ` 54` huffman@28029 ` 55` ```lemma scale_zero_left [simp]: "scale 0 x = 0" ``` huffman@28029 ` 56` ``` and scale_minus_left [simp]: "scale (- a) x = - (scale a x)" ``` wenzelm@63545 ` 57` ``` and scale_left_diff_distrib [algebra_simps]: "scale (a - b) x = scale a x - scale b x" ``` nipkow@64267 ` 58` ``` and scale_sum_left: "scale (sum f A) x = (\a\A. scale (f a) x)" ``` huffman@28029 ` 59` ```proof - ``` ballarin@29229 ` 60` ``` interpret s: additive "\a. scale a x" ``` wenzelm@63545 ` 61` ``` by standard (rule scale_left_distrib) ``` huffman@28029 ` 62` ``` show "scale 0 x = 0" by (rule s.zero) ``` huffman@28029 ` 63` ``` show "scale (- a) x = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 64` ``` show "scale (a - b) x = scale a x - scale b x" by (rule s.diff) ``` nipkow@64267 ` 65` ``` show "scale (sum f A) x = (\a\A. scale (f a) x)" by (rule s.sum) ``` huffman@28029 ` 66` ```qed ``` huffman@28029 ` 67` huffman@28029 ` 68` ```lemma scale_zero_right [simp]: "scale a 0 = 0" ``` huffman@28029 ` 69` ``` and scale_minus_right [simp]: "scale a (- x) = - (scale a x)" ``` wenzelm@63545 ` 70` ``` and scale_right_diff_distrib [algebra_simps]: "scale a (x - y) = scale a x - scale a y" ``` nipkow@64267 ` 71` ``` and scale_sum_right: "scale a (sum f A) = (\x\A. scale a (f x))" ``` huffman@28029 ` 72` ```proof - ``` ballarin@29229 ` 73` ``` interpret s: additive "\x. scale a x" ``` wenzelm@63545 ` 74` ``` by standard (rule scale_right_distrib) ``` huffman@28029 ` 75` ``` show "scale a 0 = 0" by (rule s.zero) ``` huffman@28029 ` 76` ``` show "scale a (- x) = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 77` ``` show "scale a (x - y) = scale a x - scale a y" by (rule s.diff) ``` nipkow@64267 ` 78` ``` show "scale a (sum f A) = (\x\A. scale a (f x))" by (rule s.sum) ``` huffman@28029 ` 79` ```qed ``` huffman@28029 ` 80` wenzelm@63545 ` 81` ```lemma scale_eq_0_iff [simp]: "scale a x = 0 \ a = 0 \ x = 0" ``` wenzelm@63545 ` 82` ```proof (cases "a = 0") ``` wenzelm@63545 ` 83` ``` case True ``` wenzelm@63545 ` 84` ``` then show ?thesis by simp ``` huffman@28029 ` 85` ```next ``` wenzelm@63545 ` 86` ``` case False ``` wenzelm@63545 ` 87` ``` have "x = 0" if "scale a x = 0" ``` wenzelm@63545 ` 88` ``` proof - ``` wenzelm@63545 ` 89` ``` from False that have "scale (inverse a) (scale a x) = 0" by simp ``` wenzelm@63545 ` 90` ``` with False show ?thesis by simp ``` wenzelm@63545 ` 91` ``` qed ``` wenzelm@63545 ` 92` ``` then show ?thesis by force ``` huffman@28029 ` 93` ```qed ``` huffman@28029 ` 94` huffman@28029 ` 95` ```lemma scale_left_imp_eq: ``` wenzelm@63545 ` 96` ``` assumes nonzero: "a \ 0" ``` wenzelm@63545 ` 97` ``` and scale: "scale a x = scale a y" ``` wenzelm@63545 ` 98` ``` shows "x = y" ``` huffman@28029 ` 99` ```proof - ``` wenzelm@63545 ` 100` ``` from scale have "scale a (x - y) = 0" ``` huffman@28029 ` 101` ``` by (simp add: scale_right_diff_distrib) ``` wenzelm@63545 ` 102` ``` with nonzero have "x - y = 0" by simp ``` wenzelm@63545 ` 103` ``` then show "x = y" by (simp only: right_minus_eq) ``` huffman@28029 ` 104` ```qed ``` huffman@28029 ` 105` huffman@28029 ` 106` ```lemma scale_right_imp_eq: ``` wenzelm@63545 ` 107` ``` assumes nonzero: "x \ 0" ``` wenzelm@63545 ` 108` ``` and scale: "scale a x = scale b x" ``` wenzelm@63545 ` 109` ``` shows "a = b" ``` huffman@28029 ` 110` ```proof - ``` wenzelm@63545 ` 111` ``` from scale have "scale (a - b) x = 0" ``` huffman@28029 ` 112` ``` by (simp add: scale_left_diff_distrib) ``` wenzelm@63545 ` 113` ``` with nonzero have "a - b = 0" by simp ``` wenzelm@63545 ` 114` ``` then show "a = b" by (simp only: right_minus_eq) ``` huffman@28029 ` 115` ```qed ``` huffman@28029 ` 116` wenzelm@63545 ` 117` ```lemma scale_cancel_left [simp]: "scale a x = scale a y \ x = y \ a = 0" ``` wenzelm@63545 ` 118` ``` by (auto intro: scale_left_imp_eq) ``` huffman@28029 ` 119` wenzelm@63545 ` 120` ```lemma scale_cancel_right [simp]: "scale a x = scale b x \ a = b \ x = 0" ``` wenzelm@63545 ` 121` ``` by (auto intro: scale_right_imp_eq) ``` huffman@28029 ` 122` huffman@28029 ` 123` ```end ``` huffman@28029 ` 124` wenzelm@63545 ` 125` wenzelm@60758 ` 126` ```subsection \Real vector spaces\ ``` huffman@20504 ` 127` haftmann@29608 ` 128` ```class scaleR = ``` haftmann@25062 ` 129` ``` fixes scaleR :: "real \ 'a \ 'a" (infixr "*\<^sub>R" 75) ``` haftmann@24748 ` 130` ```begin ``` huffman@20504 ` 131` wenzelm@63545 ` 132` ```abbreviation divideR :: "'a \ real \ 'a" (infixl "'/\<^sub>R" 70) ``` wenzelm@63545 ` 133` ``` where "x /\<^sub>R r \ scaleR (inverse r) x" ``` haftmann@24748 ` 134` haftmann@24748 ` 135` ```end ``` haftmann@24748 ` 136` haftmann@24588 ` 137` ```class real_vector = scaleR + ab_group_add + ``` huffman@44282 ` 138` ``` assumes scaleR_add_right: "scaleR a (x + y) = scaleR a x + scaleR a y" ``` huffman@44282 ` 139` ``` and scaleR_add_left: "scaleR (a + b) x = scaleR a x + scaleR b x" ``` huffman@30070 ` 140` ``` and scaleR_scaleR: "scaleR a (scaleR b x) = scaleR (a * b) x" ``` huffman@30070 ` 141` ``` and scaleR_one: "scaleR 1 x = x" ``` huffman@20504 ` 142` wenzelm@63545 ` 143` ```interpretation real_vector: vector_space "scaleR :: real \ 'a \ 'a::real_vector" ``` wenzelm@63545 ` 144` ``` apply unfold_locales ``` wenzelm@63545 ` 145` ``` apply (rule scaleR_add_right) ``` wenzelm@63545 ` 146` ``` apply (rule scaleR_add_left) ``` wenzelm@63545 ` 147` ``` apply (rule scaleR_scaleR) ``` wenzelm@63545 ` 148` ``` apply (rule scaleR_one) ``` wenzelm@63545 ` 149` ``` done ``` huffman@28009 ` 150` wenzelm@60758 ` 151` ```text \Recover original theorem names\ ``` huffman@28009 ` 152` huffman@28009 ` 153` ```lemmas scaleR_left_commute = real_vector.scale_left_commute ``` huffman@28009 ` 154` ```lemmas scaleR_zero_left = real_vector.scale_zero_left ``` huffman@28009 ` 155` ```lemmas scaleR_minus_left = real_vector.scale_minus_left ``` huffman@44282 ` 156` ```lemmas scaleR_diff_left = real_vector.scale_left_diff_distrib ``` nipkow@64267 ` 157` ```lemmas scaleR_sum_left = real_vector.scale_sum_left ``` huffman@28009 ` 158` ```lemmas scaleR_zero_right = real_vector.scale_zero_right ``` huffman@28009 ` 159` ```lemmas scaleR_minus_right = real_vector.scale_minus_right ``` huffman@44282 ` 160` ```lemmas scaleR_diff_right = real_vector.scale_right_diff_distrib ``` nipkow@64267 ` 161` ```lemmas scaleR_sum_right = real_vector.scale_sum_right ``` huffman@28009 ` 162` ```lemmas scaleR_eq_0_iff = real_vector.scale_eq_0_iff ``` huffman@28009 ` 163` ```lemmas scaleR_left_imp_eq = real_vector.scale_left_imp_eq ``` huffman@28009 ` 164` ```lemmas scaleR_right_imp_eq = real_vector.scale_right_imp_eq ``` huffman@28009 ` 165` ```lemmas scaleR_cancel_left = real_vector.scale_cancel_left ``` huffman@28009 ` 166` ```lemmas scaleR_cancel_right = real_vector.scale_cancel_right ``` huffman@28009 ` 167` wenzelm@60758 ` 168` ```text \Legacy names\ ``` huffman@44282 ` 169` huffman@44282 ` 170` ```lemmas scaleR_left_distrib = scaleR_add_left ``` huffman@44282 ` 171` ```lemmas scaleR_right_distrib = scaleR_add_right ``` huffman@44282 ` 172` ```lemmas scaleR_left_diff_distrib = scaleR_diff_left ``` huffman@44282 ` 173` ```lemmas scaleR_right_diff_distrib = scaleR_diff_right ``` huffman@44282 ` 174` wenzelm@63545 ` 175` ```lemma scaleR_minus1_left [simp]: "scaleR (-1) x = - x" ``` wenzelm@63545 ` 176` ``` for x :: "'a::real_vector" ``` huffman@31285 ` 177` ``` using scaleR_minus_left [of 1 x] by simp ``` hoelzl@62101 ` 178` lp15@64788 ` 179` ```lemma scaleR_2: ``` lp15@64788 ` 180` ``` fixes x :: "'a::real_vector" ``` lp15@64788 ` 181` ``` shows "scaleR 2 x = x + x" ``` lp15@64788 ` 182` ``` unfolding one_add_one [symmetric] scaleR_left_distrib by simp ``` lp15@64788 ` 183` lp15@64788 ` 184` ```lemma scaleR_half_double [simp]: ``` lp15@64788 ` 185` ``` fixes a :: "'a::real_vector" ``` lp15@64788 ` 186` ``` shows "(1 / 2) *\<^sub>R (a + a) = a" ``` lp15@64788 ` 187` ```proof - ``` lp15@64788 ` 188` ``` have "\r. r *\<^sub>R (a + a) = (r * 2) *\<^sub>R a" ``` lp15@64788 ` 189` ``` by (metis scaleR_2 scaleR_scaleR) ``` lp15@64788 ` 190` ``` then show ?thesis ``` lp15@64788 ` 191` ``` by simp ``` lp15@64788 ` 192` ```qed ``` lp15@64788 ` 193` haftmann@24588 ` 194` ```class real_algebra = real_vector + ring + ``` haftmann@25062 ` 195` ``` assumes mult_scaleR_left [simp]: "scaleR a x * y = scaleR a (x * y)" ``` wenzelm@63545 ` 196` ``` and mult_scaleR_right [simp]: "x * scaleR a y = scaleR a (x * y)" ``` huffman@20504 ` 197` haftmann@24588 ` 198` ```class real_algebra_1 = real_algebra + ring_1 ``` huffman@20554 ` 199` haftmann@24588 ` 200` ```class real_div_algebra = real_algebra_1 + division_ring ``` huffman@20584 ` 201` haftmann@24588 ` 202` ```class real_field = real_div_algebra + field ``` huffman@20584 ` 203` huffman@30069 ` 204` ```instantiation real :: real_field ``` huffman@30069 ` 205` ```begin ``` huffman@30069 ` 206` wenzelm@63545 ` 207` ```definition real_scaleR_def [simp]: "scaleR a x = a * x" ``` huffman@30069 ` 208` wenzelm@63545 ` 209` ```instance ``` wenzelm@63545 ` 210` ``` by standard (simp_all add: algebra_simps) ``` huffman@20554 ` 211` huffman@30069 ` 212` ```end ``` huffman@30069 ` 213` wenzelm@63545 ` 214` ```interpretation scaleR_left: additive "(\a. scaleR a x :: 'a::real_vector)" ``` wenzelm@63545 ` 215` ``` by standard (rule scaleR_left_distrib) ``` huffman@20504 ` 216` wenzelm@63545 ` 217` ```interpretation scaleR_right: additive "(\x. scaleR a x :: 'a::real_vector)" ``` wenzelm@63545 ` 218` ``` by standard (rule scaleR_right_distrib) ``` huffman@20504 ` 219` huffman@20584 ` 220` ```lemma nonzero_inverse_scaleR_distrib: ``` wenzelm@63545 ` 221` ``` "a \ 0 \ x \ 0 \ inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` wenzelm@63545 ` 222` ``` for x :: "'a::real_div_algebra" ``` wenzelm@63545 ` 223` ``` by (rule inverse_unique) simp ``` huffman@20584 ` 224` wenzelm@63545 ` 225` ```lemma inverse_scaleR_distrib: "inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` wenzelm@63545 ` 226` ``` for x :: "'a::{real_div_algebra,division_ring}" ``` wenzelm@63545 ` 227` ``` apply (cases "a = 0") ``` wenzelm@63545 ` 228` ``` apply simp ``` wenzelm@63545 ` 229` ``` apply (cases "x = 0") ``` wenzelm@63545 ` 230` ``` apply simp ``` wenzelm@63545 ` 231` ``` apply (erule (1) nonzero_inverse_scaleR_distrib) ``` eberlm@61531 ` 232` ``` done ``` eberlm@61531 ` 233` nipkow@64267 ` 234` ```lemma sum_constant_scaleR: "(\x\A. y) = of_nat (card A) *\<^sub>R y" ``` wenzelm@63545 ` 235` ``` for y :: "'a::real_vector" ``` wenzelm@63915 ` 236` ``` by (induct A rule: infinite_finite_induct) (simp_all add: algebra_simps) ``` wenzelm@63545 ` 237` lp15@63927 ` 238` ```named_theorems vector_add_divide_simps "to simplify sums of scaled vectors" ``` lp15@63927 ` 239` lp15@63927 ` 240` ```lemma [vector_add_divide_simps]: ``` wenzelm@63545 ` 241` ``` "v + (b / z) *\<^sub>R w = (if z = 0 then v else (z *\<^sub>R v + b *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 242` ``` "a *\<^sub>R v + (b / z) *\<^sub>R w = (if z = 0 then a *\<^sub>R v else ((a * z) *\<^sub>R v + b *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 243` ``` "(a / z) *\<^sub>R v + w = (if z = 0 then w else (a *\<^sub>R v + z *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 244` ``` "(a / z) *\<^sub>R v + b *\<^sub>R w = (if z = 0 then b *\<^sub>R w else (a *\<^sub>R v + (b * z) *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 245` ``` "v - (b / z) *\<^sub>R w = (if z = 0 then v else (z *\<^sub>R v - b *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 246` ``` "a *\<^sub>R v - (b / z) *\<^sub>R w = (if z = 0 then a *\<^sub>R v else ((a * z) *\<^sub>R v - b *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 247` ``` "(a / z) *\<^sub>R v - w = (if z = 0 then -w else (a *\<^sub>R v - z *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 248` ``` "(a / z) *\<^sub>R v - b *\<^sub>R w = (if z = 0 then -b *\<^sub>R w else (a *\<^sub>R v - (b * z) *\<^sub>R w) /\<^sub>R z)" ``` wenzelm@63545 ` 249` ``` for v :: "'a :: real_vector" ``` wenzelm@63545 ` 250` ``` by (simp_all add: divide_inverse_commute scaleR_add_right real_vector.scale_right_diff_distrib) ``` lp15@63114 ` 251` lp15@63927 ` 252` lp15@63927 ` 253` ```lemma eq_vector_fraction_iff [vector_add_divide_simps]: ``` lp15@63927 ` 254` ``` fixes x :: "'a :: real_vector" ``` lp15@63927 ` 255` ``` shows "(x = (u / v) *\<^sub>R a) \ (if v=0 then x = 0 else v *\<^sub>R x = u *\<^sub>R a)" ``` lp15@63927 ` 256` ```by auto (metis (no_types) divide_eq_1_iff divide_inverse_commute scaleR_one scaleR_scaleR) ``` lp15@63927 ` 257` lp15@63927 ` 258` ```lemma vector_fraction_eq_iff [vector_add_divide_simps]: ``` lp15@63927 ` 259` ``` fixes x :: "'a :: real_vector" ``` lp15@63927 ` 260` ``` shows "((u / v) *\<^sub>R a = x) \ (if v=0 then x = 0 else u *\<^sub>R a = v *\<^sub>R x)" ``` lp15@63927 ` 261` ```by (metis eq_vector_fraction_iff) ``` lp15@63927 ` 262` lp15@60800 ` 263` ```lemma real_vector_affinity_eq: ``` lp15@60800 ` 264` ``` fixes x :: "'a :: real_vector" ``` lp15@60800 ` 265` ``` assumes m0: "m \ 0" ``` lp15@60800 ` 266` ``` shows "m *\<^sub>R x + c = y \ x = inverse m *\<^sub>R y - (inverse m *\<^sub>R c)" ``` wenzelm@63545 ` 267` ``` (is "?lhs \ ?rhs") ``` lp15@60800 ` 268` ```proof ``` wenzelm@63545 ` 269` ``` assume ?lhs ``` wenzelm@63545 ` 270` ``` then have "m *\<^sub>R x = y - c" by (simp add: field_simps) ``` wenzelm@63545 ` 271` ``` then have "inverse m *\<^sub>R (m *\<^sub>R x) = inverse m *\<^sub>R (y - c)" by simp ``` lp15@60800 ` 272` ``` then show "x = inverse m *\<^sub>R y - (inverse m *\<^sub>R c)" ``` lp15@60800 ` 273` ``` using m0 ``` lp15@60800 ` 274` ``` by (simp add: real_vector.scale_right_diff_distrib) ``` lp15@60800 ` 275` ```next ``` wenzelm@63545 ` 276` ``` assume ?rhs ``` wenzelm@63545 ` 277` ``` with m0 show "m *\<^sub>R x + c = y" ``` wenzelm@63545 ` 278` ``` by (simp add: real_vector.scale_right_diff_distrib) ``` lp15@60800 ` 279` ```qed ``` lp15@60800 ` 280` wenzelm@63545 ` 281` ```lemma real_vector_eq_affinity: "m \ 0 \ y = m *\<^sub>R x + c \ inverse m *\<^sub>R y - (inverse m *\<^sub>R c) = x" ``` wenzelm@63545 ` 282` ``` for x :: "'a::real_vector" ``` lp15@60800 ` 283` ``` using real_vector_affinity_eq[where m=m and x=x and y=y and c=c] ``` lp15@60800 ` 284` ``` by metis ``` lp15@60800 ` 285` wenzelm@63545 ` 286` ```lemma scaleR_eq_iff [simp]: "b + u *\<^sub>R a = a + u *\<^sub>R b \ a = b \ u = 1" ``` wenzelm@63545 ` 287` ``` for a :: "'a::real_vector" ``` wenzelm@63545 ` 288` ```proof (cases "u = 1") ``` wenzelm@63545 ` 289` ``` case True ``` wenzelm@63545 ` 290` ``` then show ?thesis by auto ``` lp15@62948 ` 291` ```next ``` lp15@62948 ` 292` ``` case False ``` wenzelm@63545 ` 293` ``` have "a = b" if "b + u *\<^sub>R a = a + u *\<^sub>R b" ``` wenzelm@63545 ` 294` ``` proof - ``` wenzelm@63545 ` 295` ``` from that have "(u - 1) *\<^sub>R a = (u - 1) *\<^sub>R b" ``` lp15@62948 ` 296` ``` by (simp add: algebra_simps) ``` wenzelm@63545 ` 297` ``` with False show ?thesis ``` lp15@62948 ` 298` ``` by auto ``` wenzelm@63545 ` 299` ``` qed ``` lp15@62948 ` 300` ``` then show ?thesis by auto ``` lp15@62948 ` 301` ```qed ``` lp15@62948 ` 302` wenzelm@63545 ` 303` ```lemma scaleR_collapse [simp]: "(1 - u) *\<^sub>R a + u *\<^sub>R a = a" ``` wenzelm@63545 ` 304` ``` for a :: "'a::real_vector" ``` wenzelm@63545 ` 305` ``` by (simp add: algebra_simps) ``` lp15@62948 ` 306` huffman@20554 ` 307` wenzelm@63545 ` 308` ```subsection \Embedding of the Reals into any \real_algebra_1\: \of_real\\ ``` huffman@20554 ` 309` wenzelm@63545 ` 310` ```definition of_real :: "real \ 'a::real_algebra_1" ``` wenzelm@63545 ` 311` ``` where "of_real r = scaleR r 1" ``` huffman@20554 ` 312` huffman@21809 ` 313` ```lemma scaleR_conv_of_real: "scaleR r x = of_real r * x" ``` wenzelm@63545 ` 314` ``` by (simp add: of_real_def) ``` huffman@20763 ` 315` huffman@20554 ` 316` ```lemma of_real_0 [simp]: "of_real 0 = 0" ``` wenzelm@63545 ` 317` ``` by (simp add: of_real_def) ``` huffman@20554 ` 318` huffman@20554 ` 319` ```lemma of_real_1 [simp]: "of_real 1 = 1" ``` wenzelm@63545 ` 320` ``` by (simp add: of_real_def) ``` huffman@20554 ` 321` huffman@20554 ` 322` ```lemma of_real_add [simp]: "of_real (x + y) = of_real x + of_real y" ``` wenzelm@63545 ` 323` ``` by (simp add: of_real_def scaleR_left_distrib) ``` huffman@20554 ` 324` huffman@20554 ` 325` ```lemma of_real_minus [simp]: "of_real (- x) = - of_real x" ``` wenzelm@63545 ` 326` ``` by (simp add: of_real_def) ``` huffman@20554 ` 327` huffman@20554 ` 328` ```lemma of_real_diff [simp]: "of_real (x - y) = of_real x - of_real y" ``` wenzelm@63545 ` 329` ``` by (simp add: of_real_def scaleR_left_diff_distrib) ``` huffman@20554 ` 330` huffman@20554 ` 331` ```lemma of_real_mult [simp]: "of_real (x * y) = of_real x * of_real y" ``` wenzelm@63545 ` 332` ``` by (simp add: of_real_def mult.commute) ``` huffman@20554 ` 333` nipkow@64267 ` 334` ```lemma of_real_sum[simp]: "of_real (sum f s) = (\x\s. of_real (f x))" ``` hoelzl@56889 ` 335` ``` by (induct s rule: infinite_finite_induct) auto ``` hoelzl@56889 ` 336` nipkow@64272 ` 337` ```lemma of_real_prod[simp]: "of_real (prod f s) = (\x\s. of_real (f x))" ``` hoelzl@56889 ` 338` ``` by (induct s rule: infinite_finite_induct) auto ``` hoelzl@56889 ` 339` huffman@20584 ` 340` ```lemma nonzero_of_real_inverse: ``` wenzelm@63545 ` 341` ``` "x \ 0 \ of_real (inverse x) = inverse (of_real x :: 'a::real_div_algebra)" ``` wenzelm@63545 ` 342` ``` by (simp add: of_real_def nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 343` huffman@20584 ` 344` ```lemma of_real_inverse [simp]: ``` wenzelm@63545 ` 345` ``` "of_real (inverse x) = inverse (of_real x :: 'a::{real_div_algebra,division_ring})" ``` wenzelm@63545 ` 346` ``` by (simp add: of_real_def inverse_scaleR_distrib) ``` huffman@20584 ` 347` huffman@20584 ` 348` ```lemma nonzero_of_real_divide: ``` wenzelm@63545 ` 349` ``` "y \ 0 \ of_real (x / y) = (of_real x / of_real y :: 'a::real_field)" ``` wenzelm@63545 ` 350` ``` by (simp add: divide_inverse nonzero_of_real_inverse) ``` huffman@20722 ` 351` huffman@20722 ` 352` ```lemma of_real_divide [simp]: ``` paulson@62131 ` 353` ``` "of_real (x / y) = (of_real x / of_real y :: 'a::real_div_algebra)" ``` wenzelm@63545 ` 354` ``` by (simp add: divide_inverse) ``` huffman@20584 ` 355` huffman@20722 ` 356` ```lemma of_real_power [simp]: ``` haftmann@31017 ` 357` ``` "of_real (x ^ n) = (of_real x :: 'a::{real_algebra_1}) ^ n" ``` wenzelm@63545 ` 358` ``` by (induct n) simp_all ``` huffman@20722 ` 359` wenzelm@63545 ` 360` ```lemma of_real_eq_iff [simp]: "of_real x = of_real y \ x = y" ``` wenzelm@63545 ` 361` ``` by (simp add: of_real_def) ``` huffman@20554 ` 362` wenzelm@63545 ` 363` ```lemma inj_of_real: "inj of_real" ``` haftmann@38621 ` 364` ``` by (auto intro: injI) ``` haftmann@38621 ` 365` huffman@20584 ` 366` ```lemmas of_real_eq_0_iff [simp] = of_real_eq_iff [of _ 0, simplified] ``` lp15@65578 ` 367` ```lemmas of_real_eq_1_iff [simp] = of_real_eq_iff [of _ 1, simplified] ``` huffman@20554 ` 368` huffman@20554 ` 369` ```lemma of_real_eq_id [simp]: "of_real = (id :: real \ real)" ``` wenzelm@63545 ` 370` ``` by (rule ext) (simp add: of_real_def) ``` huffman@20554 ` 371` wenzelm@63545 ` 372` ```text \Collapse nested embeddings.\ ``` huffman@20554 ` 373` ```lemma of_real_of_nat_eq [simp]: "of_real (of_nat n) = of_nat n" ``` wenzelm@63545 ` 374` ``` by (induct n) auto ``` huffman@20554 ` 375` huffman@20554 ` 376` ```lemma of_real_of_int_eq [simp]: "of_real (of_int z) = of_int z" ``` wenzelm@63545 ` 377` ``` by (cases z rule: int_diff_cases) simp ``` huffman@20554 ` 378` lp15@60155 ` 379` ```lemma of_real_numeral [simp]: "of_real (numeral w) = numeral w" ``` wenzelm@63545 ` 380` ``` using of_real_of_int_eq [of "numeral w"] by simp ``` huffman@47108 ` 381` lp15@60155 ` 382` ```lemma of_real_neg_numeral [simp]: "of_real (- numeral w) = - numeral w" ``` wenzelm@63545 ` 383` ``` using of_real_of_int_eq [of "- numeral w"] by simp ``` huffman@20554 ` 384` wenzelm@63545 ` 385` ```text \Every real algebra has characteristic zero.\ ``` huffman@22912 ` 386` ```instance real_algebra_1 < ring_char_0 ``` huffman@22912 ` 387` ```proof ``` wenzelm@63545 ` 388` ``` from inj_of_real inj_of_nat have "inj (of_real \ of_nat)" ``` wenzelm@63545 ` 389` ``` by (rule inj_comp) ``` wenzelm@63545 ` 390` ``` then show "inj (of_nat :: nat \ 'a)" ``` wenzelm@63545 ` 391` ``` by (simp add: comp_def) ``` huffman@22912 ` 392` ```qed ``` huffman@22912 ` 393` lp15@63967 ` 394` ```lemma fraction_scaleR_times [simp]: ``` lp15@63967 ` 395` ``` fixes a :: "'a::real_algebra_1" ``` lp15@63967 ` 396` ``` shows "(numeral u / numeral v) *\<^sub>R (numeral w * a) = (numeral u * numeral w / numeral v) *\<^sub>R a" ``` lp15@63967 ` 397` ```by (metis (no_types, lifting) of_real_numeral scaleR_conv_of_real scaleR_scaleR times_divide_eq_left) ``` lp15@63967 ` 398` lp15@63967 ` 399` ```lemma inverse_scaleR_times [simp]: ``` lp15@63967 ` 400` ``` fixes a :: "'a::real_algebra_1" ``` lp15@63967 ` 401` ``` shows "(1 / numeral v) *\<^sub>R (numeral w * a) = (numeral w / numeral v) *\<^sub>R a" ``` lp15@63967 ` 402` ```by (metis divide_inverse_commute inverse_eq_divide of_real_numeral scaleR_conv_of_real scaleR_scaleR) ``` lp15@63967 ` 403` lp15@63967 ` 404` ```lemma scaleR_times [simp]: ``` lp15@63967 ` 405` ``` fixes a :: "'a::real_algebra_1" ``` lp15@63967 ` 406` ``` shows "(numeral u) *\<^sub>R (numeral w * a) = (numeral u * numeral w) *\<^sub>R a" ``` lp15@63967 ` 407` ```by (simp add: scaleR_conv_of_real) ``` lp15@63967 ` 408` huffman@27553 ` 409` ```instance real_field < field_char_0 .. ``` huffman@27553 ` 410` huffman@20554 ` 411` wenzelm@60758 ` 412` ```subsection \The Set of Real Numbers\ ``` huffman@20554 ` 413` wenzelm@61070 ` 414` ```definition Reals :: "'a::real_algebra_1 set" ("\") ``` wenzelm@61070 ` 415` ``` where "\ = range of_real" ``` huffman@20554 ` 416` wenzelm@61070 ` 417` ```lemma Reals_of_real [simp]: "of_real r \ \" ``` wenzelm@63545 ` 418` ``` by (simp add: Reals_def) ``` huffman@20554 ` 419` wenzelm@61070 ` 420` ```lemma Reals_of_int [simp]: "of_int z \ \" ``` wenzelm@63545 ` 421` ``` by (subst of_real_of_int_eq [symmetric], rule Reals_of_real) ``` huffman@20718 ` 422` wenzelm@61070 ` 423` ```lemma Reals_of_nat [simp]: "of_nat n \ \" ``` wenzelm@63545 ` 424` ``` by (subst of_real_of_nat_eq [symmetric], rule Reals_of_real) ``` huffman@21809 ` 425` wenzelm@61070 ` 426` ```lemma Reals_numeral [simp]: "numeral w \ \" ``` wenzelm@63545 ` 427` ``` by (subst of_real_numeral [symmetric], rule Reals_of_real) ``` huffman@47108 ` 428` wenzelm@61070 ` 429` ```lemma Reals_0 [simp]: "0 \ \" ``` wenzelm@63545 ` 430` ``` apply (unfold Reals_def) ``` wenzelm@63545 ` 431` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 432` ``` apply (rule of_real_0 [symmetric]) ``` wenzelm@63545 ` 433` ``` done ``` huffman@20554 ` 434` wenzelm@61070 ` 435` ```lemma Reals_1 [simp]: "1 \ \" ``` wenzelm@63545 ` 436` ``` apply (unfold Reals_def) ``` wenzelm@63545 ` 437` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 438` ``` apply (rule of_real_1 [symmetric]) ``` wenzelm@63545 ` 439` ``` done ``` huffman@20554 ` 440` wenzelm@63545 ` 441` ```lemma Reals_add [simp]: "a \ \ \ b \ \ \ a + b \ \" ``` wenzelm@63545 ` 442` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 443` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 444` ``` apply (rule of_real_add [symmetric]) ``` wenzelm@63545 ` 445` ``` done ``` huffman@20554 ` 446` wenzelm@61070 ` 447` ```lemma Reals_minus [simp]: "a \ \ \ - a \ \" ``` wenzelm@63545 ` 448` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 449` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 450` ``` apply (rule of_real_minus [symmetric]) ``` wenzelm@63545 ` 451` ``` done ``` huffman@20584 ` 452` wenzelm@63545 ` 453` ```lemma Reals_diff [simp]: "a \ \ \ b \ \ \ a - b \ \" ``` wenzelm@63545 ` 454` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 455` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 456` ``` apply (rule of_real_diff [symmetric]) ``` wenzelm@63545 ` 457` ``` done ``` huffman@20584 ` 458` wenzelm@63545 ` 459` ```lemma Reals_mult [simp]: "a \ \ \ b \ \ \ a * b \ \" ``` wenzelm@63545 ` 460` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 461` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 462` ``` apply (rule of_real_mult [symmetric]) ``` wenzelm@63545 ` 463` ``` done ``` huffman@20554 ` 464` wenzelm@63545 ` 465` ```lemma nonzero_Reals_inverse: "a \ \ \ a \ 0 \ inverse a \ \" ``` wenzelm@63545 ` 466` ``` for a :: "'a::real_div_algebra" ``` wenzelm@63545 ` 467` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 468` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 469` ``` apply (erule nonzero_of_real_inverse [symmetric]) ``` wenzelm@63545 ` 470` ``` done ``` huffman@20584 ` 471` wenzelm@63545 ` 472` ```lemma Reals_inverse: "a \ \ \ inverse a \ \" ``` wenzelm@63545 ` 473` ``` for a :: "'a::{real_div_algebra,division_ring}" ``` wenzelm@63545 ` 474` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 475` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 476` ``` apply (rule of_real_inverse [symmetric]) ``` wenzelm@63545 ` 477` ``` done ``` huffman@20584 ` 478` wenzelm@63545 ` 479` ```lemma Reals_inverse_iff [simp]: "inverse x \ \ \ x \ \" ``` wenzelm@63545 ` 480` ``` for x :: "'a::{real_div_algebra,division_ring}" ``` wenzelm@63545 ` 481` ``` by (metis Reals_inverse inverse_inverse_eq) ``` lp15@55719 ` 482` wenzelm@63545 ` 483` ```lemma nonzero_Reals_divide: "a \ \ \ b \ \ \ b \ 0 \ a / b \ \" ``` wenzelm@63545 ` 484` ``` for a b :: "'a::real_field" ``` wenzelm@63545 ` 485` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 486` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 487` ``` apply (erule nonzero_of_real_divide [symmetric]) ``` wenzelm@63545 ` 488` ``` done ``` huffman@20584 ` 489` wenzelm@63545 ` 490` ```lemma Reals_divide [simp]: "a \ \ \ b \ \ \ a / b \ \" ``` wenzelm@63545 ` 491` ``` for a b :: "'a::{real_field,field}" ``` wenzelm@63545 ` 492` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 493` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 494` ``` apply (rule of_real_divide [symmetric]) ``` wenzelm@63545 ` 495` ``` done ``` huffman@20584 ` 496` wenzelm@63545 ` 497` ```lemma Reals_power [simp]: "a \ \ \ a ^ n \ \" ``` wenzelm@63545 ` 498` ``` for a :: "'a::real_algebra_1" ``` wenzelm@63545 ` 499` ``` apply (auto simp add: Reals_def) ``` wenzelm@63545 ` 500` ``` apply (rule range_eqI) ``` wenzelm@63545 ` 501` ``` apply (rule of_real_power [symmetric]) ``` wenzelm@63545 ` 502` ``` done ``` huffman@20722 ` 503` huffman@20554 ` 504` ```lemma Reals_cases [cases set: Reals]: ``` huffman@20554 ` 505` ``` assumes "q \ \" ``` huffman@20554 ` 506` ``` obtains (of_real) r where "q = of_real r" ``` huffman@20554 ` 507` ``` unfolding Reals_def ``` huffman@20554 ` 508` ```proof - ``` wenzelm@60758 ` 509` ``` from \q \ \\ have "q \ range of_real" unfolding Reals_def . ``` huffman@20554 ` 510` ``` then obtain r where "q = of_real r" .. ``` huffman@20554 ` 511` ``` then show thesis .. ``` huffman@20554 ` 512` ```qed ``` huffman@20554 ` 513` nipkow@64267 ` 514` ```lemma sum_in_Reals [intro,simp]: "(\i. i \ s \ f i \ \) \ sum f s \ \" ``` wenzelm@63915 ` 515` ```proof (induct s rule: infinite_finite_induct) ``` wenzelm@63915 ` 516` ``` case infinite ``` nipkow@64267 ` 517` ``` then show ?case by (metis Reals_0 sum.infinite) ``` wenzelm@63915 ` 518` ```qed simp_all ``` lp15@55719 ` 519` nipkow@64272 ` 520` ```lemma prod_in_Reals [intro,simp]: "(\i. i \ s \ f i \ \) \ prod f s \ \" ``` wenzelm@63915 ` 521` ```proof (induct s rule: infinite_finite_induct) ``` wenzelm@63915 ` 522` ``` case infinite ``` nipkow@64272 ` 523` ``` then show ?case by (metis Reals_1 prod.infinite) ``` wenzelm@63915 ` 524` ```qed simp_all ``` lp15@55719 ` 525` huffman@20554 ` 526` ```lemma Reals_induct [case_names of_real, induct set: Reals]: ``` huffman@20554 ` 527` ``` "q \ \ \ (\r. P (of_real r)) \ P q" ``` huffman@20554 ` 528` ``` by (rule Reals_cases) auto ``` huffman@20554 ` 529` wenzelm@63545 ` 530` wenzelm@60758 ` 531` ```subsection \Ordered real vector spaces\ ``` immler@54778 ` 532` immler@54778 ` 533` ```class ordered_real_vector = real_vector + ordered_ab_group_add + ``` immler@54778 ` 534` ``` assumes scaleR_left_mono: "x \ y \ 0 \ a \ a *\<^sub>R x \ a *\<^sub>R y" ``` wenzelm@63545 ` 535` ``` and scaleR_right_mono: "a \ b \ 0 \ x \ a *\<^sub>R x \ b *\<^sub>R x" ``` immler@54778 ` 536` ```begin ``` immler@54778 ` 537` wenzelm@63545 ` 538` ```lemma scaleR_mono: "a \ b \ x \ y \ 0 \ b \ 0 \ x \ a *\<^sub>R x \ b *\<^sub>R y" ``` wenzelm@63545 ` 539` ``` apply (erule scaleR_right_mono [THEN order_trans]) ``` wenzelm@63545 ` 540` ``` apply assumption ``` wenzelm@63545 ` 541` ``` apply (erule scaleR_left_mono) ``` wenzelm@63545 ` 542` ``` apply assumption ``` wenzelm@63545 ` 543` ``` done ``` immler@54778 ` 544` wenzelm@63545 ` 545` ```lemma scaleR_mono': "a \ b \ c \ d \ 0 \ a \ 0 \ c \ a *\<^sub>R c \ b *\<^sub>R d" ``` immler@54778 ` 546` ``` by (rule scaleR_mono) (auto intro: order.trans) ``` immler@54778 ` 547` immler@54785 ` 548` ```lemma pos_le_divideRI: ``` immler@54785 ` 549` ``` assumes "0 < c" ``` wenzelm@63545 ` 550` ``` and "c *\<^sub>R a \ b" ``` immler@54785 ` 551` ``` shows "a \ b /\<^sub>R c" ``` immler@54785 ` 552` ```proof - ``` immler@54785 ` 553` ``` from scaleR_left_mono[OF assms(2)] assms(1) ``` immler@54785 ` 554` ``` have "c *\<^sub>R a /\<^sub>R c \ b /\<^sub>R c" ``` immler@54785 ` 555` ``` by simp ``` immler@54785 ` 556` ``` with assms show ?thesis ``` immler@54785 ` 557` ``` by (simp add: scaleR_one scaleR_scaleR inverse_eq_divide) ``` immler@54785 ` 558` ```qed ``` immler@54785 ` 559` immler@54785 ` 560` ```lemma pos_le_divideR_eq: ``` immler@54785 ` 561` ``` assumes "0 < c" ``` immler@54785 ` 562` ``` shows "a \ b /\<^sub>R c \ c *\<^sub>R a \ b" ``` wenzelm@63545 ` 563` ``` (is "?lhs \ ?rhs") ``` wenzelm@63545 ` 564` ```proof ``` wenzelm@63545 ` 565` ``` assume ?lhs ``` wenzelm@63545 ` 566` ``` from scaleR_left_mono[OF this] assms have "c *\<^sub>R a \ c *\<^sub>R (b /\<^sub>R c)" ``` immler@54785 ` 567` ``` by simp ``` wenzelm@63545 ` 568` ``` with assms show ?rhs ``` immler@54785 ` 569` ``` by (simp add: scaleR_one scaleR_scaleR inverse_eq_divide) ``` wenzelm@63545 ` 570` ```next ``` wenzelm@63545 ` 571` ``` assume ?rhs ``` wenzelm@63545 ` 572` ``` with assms show ?lhs by (rule pos_le_divideRI) ``` wenzelm@63545 ` 573` ```qed ``` immler@54785 ` 574` wenzelm@63545 ` 575` ```lemma scaleR_image_atLeastAtMost: "c > 0 \ scaleR c ` {x..y} = {c *\<^sub>R x..c *\<^sub>R y}" ``` immler@54785 ` 576` ``` apply (auto intro!: scaleR_left_mono) ``` immler@54785 ` 577` ``` apply (rule_tac x = "inverse c *\<^sub>R xa" in image_eqI) ``` wenzelm@63545 ` 578` ``` apply (simp_all add: pos_le_divideR_eq[symmetric] scaleR_scaleR scaleR_one) ``` immler@54785 ` 579` ``` done ``` immler@54785 ` 580` immler@54778 ` 581` ```end ``` immler@54778 ` 582` paulson@60303 ` 583` ```lemma neg_le_divideR_eq: ``` paulson@60303 ` 584` ``` fixes a :: "'a :: ordered_real_vector" ``` paulson@60303 ` 585` ``` assumes "c < 0" ``` paulson@60303 ` 586` ``` shows "a \ b /\<^sub>R c \ b \ c *\<^sub>R a" ``` wenzelm@63545 ` 587` ``` using pos_le_divideR_eq [of "-c" a "-b"] assms by simp ``` paulson@60303 ` 588` wenzelm@63545 ` 589` ```lemma scaleR_nonneg_nonneg: "0 \ a \ 0 \ x \ 0 \ a *\<^sub>R x" ``` wenzelm@63545 ` 590` ``` for x :: "'a::ordered_real_vector" ``` wenzelm@63545 ` 591` ``` using scaleR_left_mono [of 0 x a] by simp ``` immler@54778 ` 592` wenzelm@63545 ` 593` ```lemma scaleR_nonneg_nonpos: "0 \ a \ x \ 0 \ a *\<^sub>R x \ 0" ``` wenzelm@63545 ` 594` ``` for x :: "'a::ordered_real_vector" ``` immler@54778 ` 595` ``` using scaleR_left_mono [of x 0 a] by simp ``` immler@54778 ` 596` wenzelm@63545 ` 597` ```lemma scaleR_nonpos_nonneg: "a \ 0 \ 0 \ x \ a *\<^sub>R x \ 0" ``` wenzelm@63545 ` 598` ``` for x :: "'a::ordered_real_vector" ``` immler@54778 ` 599` ``` using scaleR_right_mono [of a 0 x] by simp ``` immler@54778 ` 600` wenzelm@63545 ` 601` ```lemma split_scaleR_neg_le: "(0 \ a \ x \ 0) \ (a \ 0 \ 0 \ x) \ a *\<^sub>R x \ 0" ``` wenzelm@63545 ` 602` ``` for x :: "'a::ordered_real_vector" ``` immler@54778 ` 603` ``` by (auto simp add: scaleR_nonneg_nonpos scaleR_nonpos_nonneg) ``` immler@54778 ` 604` wenzelm@63545 ` 605` ```lemma le_add_iff1: "a *\<^sub>R e + c \ b *\<^sub>R e + d \ (a - b) *\<^sub>R e + c \ d" ``` wenzelm@63545 ` 606` ``` for c d e :: "'a::ordered_real_vector" ``` immler@54778 ` 607` ``` by (simp add: algebra_simps) ``` immler@54778 ` 608` wenzelm@63545 ` 609` ```lemma le_add_iff2: "a *\<^sub>R e + c \ b *\<^sub>R e + d \ c \ (b - a) *\<^sub>R e + d" ``` wenzelm@63545 ` 610` ``` for c d e :: "'a::ordered_real_vector" ``` immler@54778 ` 611` ``` by (simp add: algebra_simps) ``` immler@54778 ` 612` wenzelm@63545 ` 613` ```lemma scaleR_left_mono_neg: "b \ a \ c \ 0 \ c *\<^sub>R a \ c *\<^sub>R b" ``` wenzelm@63545 ` 614` ``` for a b :: "'a::ordered_real_vector" ``` immler@54778 ` 615` ``` apply (drule scaleR_left_mono [of _ _ "- c"]) ``` wenzelm@63545 ` 616` ``` apply simp_all ``` immler@54778 ` 617` ``` done ``` immler@54778 ` 618` wenzelm@63545 ` 619` ```lemma scaleR_right_mono_neg: "b \ a \ c \ 0 \ a *\<^sub>R c \ b *\<^sub>R c" ``` wenzelm@63545 ` 620` ``` for c :: "'a::ordered_real_vector" ``` immler@54778 ` 621` ``` apply (drule scaleR_right_mono [of _ _ "- c"]) ``` wenzelm@63545 ` 622` ``` apply simp_all ``` immler@54778 ` 623` ``` done ``` immler@54778 ` 624` wenzelm@63545 ` 625` ```lemma scaleR_nonpos_nonpos: "a \ 0 \ b \ 0 \ 0 \ a *\<^sub>R b" ``` wenzelm@63545 ` 626` ``` for b :: "'a::ordered_real_vector" ``` wenzelm@63545 ` 627` ``` using scaleR_right_mono_neg [of a 0 b] by simp ``` immler@54778 ` 628` wenzelm@63545 ` 629` ```lemma split_scaleR_pos_le: "(0 \ a \ 0 \ b) \ (a \ 0 \ b \ 0) \ 0 \ a *\<^sub>R b" ``` wenzelm@63545 ` 630` ``` for b :: "'a::ordered_real_vector" ``` immler@54778 ` 631` ``` by (auto simp add: scaleR_nonneg_nonneg scaleR_nonpos_nonpos) ``` immler@54778 ` 632` immler@54778 ` 633` ```lemma zero_le_scaleR_iff: ``` wenzelm@63545 ` 634` ``` fixes b :: "'a::ordered_real_vector" ``` wenzelm@63545 ` 635` ``` shows "0 \ a *\<^sub>R b \ 0 < a \ 0 \ b \ a < 0 \ b \ 0 \ a = 0" ``` wenzelm@63545 ` 636` ``` (is "?lhs = ?rhs") ``` wenzelm@63545 ` 637` ```proof (cases "a = 0") ``` wenzelm@63545 ` 638` ``` case True ``` wenzelm@63545 ` 639` ``` then show ?thesis by simp ``` wenzelm@63545 ` 640` ```next ``` wenzelm@63545 ` 641` ``` case False ``` immler@54778 ` 642` ``` show ?thesis ``` immler@54778 ` 643` ``` proof ``` wenzelm@63545 ` 644` ``` assume ?lhs ``` wenzelm@63545 ` 645` ``` from \a \ 0\ consider "a > 0" | "a < 0" by arith ``` wenzelm@63545 ` 646` ``` then show ?rhs ``` wenzelm@63545 ` 647` ``` proof cases ``` wenzelm@63545 ` 648` ``` case 1 ``` wenzelm@63545 ` 649` ``` with \?lhs\ have "inverse a *\<^sub>R 0 \ inverse a *\<^sub>R (a *\<^sub>R b)" ``` immler@54778 ` 650` ``` by (intro scaleR_mono) auto ``` wenzelm@63545 ` 651` ``` with 1 show ?thesis ``` immler@54778 ` 652` ``` by simp ``` wenzelm@63545 ` 653` ``` next ``` wenzelm@63545 ` 654` ``` case 2 ``` wenzelm@63545 ` 655` ``` with \?lhs\ have "- inverse a *\<^sub>R 0 \ - inverse a *\<^sub>R (a *\<^sub>R b)" ``` immler@54778 ` 656` ``` by (intro scaleR_mono) auto ``` wenzelm@63545 ` 657` ``` with 2 show ?thesis ``` immler@54778 ` 658` ``` by simp ``` wenzelm@63545 ` 659` ``` qed ``` wenzelm@63545 ` 660` ``` next ``` wenzelm@63545 ` 661` ``` assume ?rhs ``` wenzelm@63545 ` 662` ``` then show ?lhs ``` wenzelm@63545 ` 663` ``` by (auto simp: not_le \a \ 0\ intro!: split_scaleR_pos_le) ``` wenzelm@63545 ` 664` ``` qed ``` wenzelm@63545 ` 665` ```qed ``` immler@54778 ` 666` wenzelm@63545 ` 667` ```lemma scaleR_le_0_iff: "a *\<^sub>R b \ 0 \ 0 < a \ b \ 0 \ a < 0 \ 0 \ b \ a = 0" ``` wenzelm@63545 ` 668` ``` for b::"'a::ordered_real_vector" ``` immler@54778 ` 669` ``` by (insert zero_le_scaleR_iff [of "-a" b]) force ``` immler@54778 ` 670` wenzelm@63545 ` 671` ```lemma scaleR_le_cancel_left: "c *\<^sub>R a \ c *\<^sub>R b \ (0 < c \ a \ b) \ (c < 0 \ b \ a)" ``` wenzelm@63545 ` 672` ``` for b :: "'a::ordered_real_vector" ``` immler@54778 ` 673` ``` by (auto simp add: neq_iff scaleR_left_mono scaleR_left_mono_neg ``` wenzelm@63545 ` 674` ``` dest: scaleR_left_mono[where a="inverse c"] scaleR_left_mono_neg[where c="inverse c"]) ``` immler@54778 ` 675` wenzelm@63545 ` 676` ```lemma scaleR_le_cancel_left_pos: "0 < c \ c *\<^sub>R a \ c *\<^sub>R b \ a \ b" ``` wenzelm@63545 ` 677` ``` for b :: "'a::ordered_real_vector" ``` immler@54778 ` 678` ``` by (auto simp: scaleR_le_cancel_left) ``` immler@54778 ` 679` wenzelm@63545 ` 680` ```lemma scaleR_le_cancel_left_neg: "c < 0 \ c *\<^sub>R a \ c *\<^sub>R b \ b \ a" ``` wenzelm@63545 ` 681` ``` for b :: "'a::ordered_real_vector" ``` immler@54778 ` 682` ``` by (auto simp: scaleR_le_cancel_left) ``` immler@54778 ` 683` wenzelm@63545 ` 684` ```lemma scaleR_left_le_one_le: "0 \ x \ a \ 1 \ a *\<^sub>R x \ x" ``` wenzelm@63545 ` 685` ``` for x :: "'a::ordered_real_vector" and a :: real ``` immler@54778 ` 686` ``` using scaleR_right_mono[of a 1 x] by simp ``` immler@54778 ` 687` huffman@20504 ` 688` wenzelm@60758 ` 689` ```subsection \Real normed vector spaces\ ``` huffman@20504 ` 690` hoelzl@51531 ` 691` ```class dist = ``` hoelzl@51531 ` 692` ``` fixes dist :: "'a \ 'a \ real" ``` hoelzl@51531 ` 693` haftmann@29608 ` 694` ```class norm = ``` huffman@22636 ` 695` ``` fixes norm :: "'a \ real" ``` huffman@20504 ` 696` huffman@24520 ` 697` ```class sgn_div_norm = scaleR + norm + sgn + ``` haftmann@25062 ` 698` ``` assumes sgn_div_norm: "sgn x = x /\<^sub>R norm x" ``` nipkow@24506 ` 699` huffman@31289 ` 700` ```class dist_norm = dist + norm + minus + ``` huffman@31289 ` 701` ``` assumes dist_norm: "dist x y = norm (x - y)" ``` huffman@31289 ` 702` hoelzl@62101 ` 703` ```class uniformity_dist = dist + uniformity + ``` hoelzl@62101 ` 704` ``` assumes uniformity_dist: "uniformity = (INF e:{0 <..}. principal {(x, y). dist x y < e})" ``` hoelzl@62101 ` 705` ```begin ``` hoelzl@51531 ` 706` hoelzl@62101 ` 707` ```lemma eventually_uniformity_metric: ``` hoelzl@62101 ` 708` ``` "eventually P uniformity \ (\e>0. \x y. dist x y < e \ P (x, y))" ``` hoelzl@62101 ` 709` ``` unfolding uniformity_dist ``` hoelzl@62101 ` 710` ``` by (subst eventually_INF_base) ``` hoelzl@62101 ` 711` ``` (auto simp: eventually_principal subset_eq intro: bexI[of _ "min _ _"]) ``` hoelzl@62101 ` 712` hoelzl@62101 ` 713` ```end ``` hoelzl@62101 ` 714` hoelzl@62101 ` 715` ```class real_normed_vector = real_vector + sgn_div_norm + dist_norm + uniformity_dist + open_uniformity + ``` hoelzl@51002 ` 716` ``` assumes norm_eq_zero [simp]: "norm x = 0 \ x = 0" ``` wenzelm@63545 ` 717` ``` and norm_triangle_ineq: "norm (x + y) \ norm x + norm y" ``` wenzelm@63545 ` 718` ``` and norm_scaleR [simp]: "norm (scaleR a x) = \a\ * norm x" ``` hoelzl@51002 ` 719` ```begin ``` hoelzl@51002 ` 720` hoelzl@51002 ` 721` ```lemma norm_ge_zero [simp]: "0 \ norm x" ``` hoelzl@51002 ` 722` ```proof - ``` lp15@60026 ` 723` ``` have "0 = norm (x + -1 *\<^sub>R x)" ``` hoelzl@51002 ` 724` ``` using scaleR_add_left[of 1 "-1" x] norm_scaleR[of 0 x] by (simp add: scaleR_one) ``` hoelzl@51002 ` 725` ``` also have "\ \ norm x + norm (-1 *\<^sub>R x)" by (rule norm_triangle_ineq) ``` hoelzl@51002 ` 726` ``` finally show ?thesis by simp ``` hoelzl@51002 ` 727` ```qed ``` hoelzl@51002 ` 728` hoelzl@51002 ` 729` ```end ``` huffman@20504 ` 730` haftmann@24588 ` 731` ```class real_normed_algebra = real_algebra + real_normed_vector + ``` haftmann@25062 ` 732` ``` assumes norm_mult_ineq: "norm (x * y) \ norm x * norm y" ``` huffman@20504 ` 733` haftmann@24588 ` 734` ```class real_normed_algebra_1 = real_algebra_1 + real_normed_algebra + ``` haftmann@25062 ` 735` ``` assumes norm_one [simp]: "norm 1 = 1" ``` hoelzl@62101 ` 736` wenzelm@63545 ` 737` ```lemma (in real_normed_algebra_1) scaleR_power [simp]: "(scaleR x y) ^ n = scaleR (x^n) (y^n)" ``` wenzelm@63545 ` 738` ``` by (induct n) (simp_all add: scaleR_one scaleR_scaleR mult_ac) ``` huffman@22852 ` 739` haftmann@24588 ` 740` ```class real_normed_div_algebra = real_div_algebra + real_normed_vector + ``` haftmann@25062 ` 741` ``` assumes norm_mult: "norm (x * y) = norm x * norm y" ``` huffman@20504 ` 742` haftmann@24588 ` 743` ```class real_normed_field = real_field + real_normed_div_algebra ``` huffman@20584 ` 744` huffman@22852 ` 745` ```instance real_normed_div_algebra < real_normed_algebra_1 ``` huffman@20554 ` 746` ```proof ``` wenzelm@63545 ` 747` ``` show "norm (x * y) \ norm x * norm y" for x y :: 'a ``` huffman@20554 ` 748` ``` by (simp add: norm_mult) ``` huffman@22852 ` 749` ```next ``` huffman@22852 ` 750` ``` have "norm (1 * 1::'a) = norm (1::'a) * norm (1::'a)" ``` huffman@22852 ` 751` ``` by (rule norm_mult) ``` wenzelm@63545 ` 752` ``` then show "norm (1::'a) = 1" by simp ``` huffman@20554 ` 753` ```qed ``` huffman@20554 ` 754` huffman@22852 ` 755` ```lemma norm_zero [simp]: "norm (0::'a::real_normed_vector) = 0" ``` wenzelm@63545 ` 756` ``` by simp ``` huffman@20504 ` 757` wenzelm@63545 ` 758` ```lemma zero_less_norm_iff [simp]: "norm x > 0 \ x \ 0" ``` wenzelm@63545 ` 759` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 760` ``` by (simp add: order_less_le) ``` huffman@20504 ` 761` wenzelm@63545 ` 762` ```lemma norm_not_less_zero [simp]: "\ norm x < 0" ``` wenzelm@63545 ` 763` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 764` ``` by (simp add: linorder_not_less) ``` huffman@20828 ` 765` wenzelm@63545 ` 766` ```lemma norm_le_zero_iff [simp]: "norm x \ 0 \ x = 0" ``` wenzelm@63545 ` 767` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 768` ``` by (simp add: order_le_less) ``` huffman@20828 ` 769` wenzelm@63545 ` 770` ```lemma norm_minus_cancel [simp]: "norm (- x) = norm x" ``` wenzelm@63545 ` 771` ``` for x :: "'a::real_normed_vector" ``` huffman@20504 ` 772` ```proof - ``` huffman@21809 ` 773` ``` have "norm (- x) = norm (scaleR (- 1) x)" ``` huffman@20504 ` 774` ``` by (simp only: scaleR_minus_left scaleR_one) ``` huffman@20533 ` 775` ``` also have "\ = \- 1\ * norm x" ``` huffman@20504 ` 776` ``` by (rule norm_scaleR) ``` huffman@20504 ` 777` ``` finally show ?thesis by simp ``` huffman@20504 ` 778` ```qed ``` huffman@20504 ` 779` wenzelm@63545 ` 780` ```lemma norm_minus_commute: "norm (a - b) = norm (b - a)" ``` wenzelm@63545 ` 781` ``` for a b :: "'a::real_normed_vector" ``` huffman@20504 ` 782` ```proof - ``` huffman@22898 ` 783` ``` have "norm (- (b - a)) = norm (b - a)" ``` huffman@22898 ` 784` ``` by (rule norm_minus_cancel) ``` wenzelm@63545 ` 785` ``` then show ?thesis by simp ``` huffman@20504 ` 786` ```qed ``` wenzelm@63545 ` 787` wenzelm@63545 ` 788` ```lemma dist_add_cancel [simp]: "dist (a + b) (a + c) = dist b c" ``` wenzelm@63545 ` 789` ``` for a :: "'a::real_normed_vector" ``` wenzelm@63545 ` 790` ``` by (simp add: dist_norm) ``` lp15@63114 ` 791` wenzelm@63545 ` 792` ```lemma dist_add_cancel2 [simp]: "dist (b + a) (c + a) = dist b c" ``` wenzelm@63545 ` 793` ``` for a :: "'a::real_normed_vector" ``` wenzelm@63545 ` 794` ``` by (simp add: dist_norm) ``` lp15@63114 ` 795` wenzelm@63545 ` 796` ```lemma dist_scaleR [simp]: "dist (x *\<^sub>R a) (y *\<^sub>R a) = \x - y\ * norm a" ``` wenzelm@63545 ` 797` ``` for a :: "'a::real_normed_vector" ``` wenzelm@63545 ` 798` ``` by (metis dist_norm norm_scaleR scaleR_left.diff) ``` huffman@20504 ` 799` wenzelm@63545 ` 800` ```lemma norm_uminus_minus: "norm (- x - y :: 'a :: real_normed_vector) = norm (x + y)" ``` eberlm@61524 ` 801` ``` by (subst (2) norm_minus_cancel[symmetric], subst minus_add_distrib) simp ``` eberlm@61524 ` 802` wenzelm@63545 ` 803` ```lemma norm_triangle_ineq2: "norm a - norm b \ norm (a - b)" ``` wenzelm@63545 ` 804` ``` for a b :: "'a::real_normed_vector" ``` huffman@20504 ` 805` ```proof - ``` huffman@20533 ` 806` ``` have "norm (a - b + b) \ norm (a - b) + norm b" ``` huffman@20504 ` 807` ``` by (rule norm_triangle_ineq) ``` wenzelm@63545 ` 808` ``` then show ?thesis by simp ``` huffman@20504 ` 809` ```qed ``` huffman@20504 ` 810` wenzelm@63545 ` 811` ```lemma norm_triangle_ineq3: "\norm a - norm b\ \ norm (a - b)" ``` wenzelm@63545 ` 812` ``` for a b :: "'a::real_normed_vector" ``` wenzelm@63545 ` 813` ``` apply (subst abs_le_iff) ``` wenzelm@63545 ` 814` ``` apply auto ``` wenzelm@63545 ` 815` ``` apply (rule norm_triangle_ineq2) ``` wenzelm@63545 ` 816` ``` apply (subst norm_minus_commute) ``` wenzelm@63545 ` 817` ``` apply (rule norm_triangle_ineq2) ``` wenzelm@63545 ` 818` ``` done ``` huffman@20584 ` 819` wenzelm@63545 ` 820` ```lemma norm_triangle_ineq4: "norm (a - b) \ norm a + norm b" ``` wenzelm@63545 ` 821` ``` for a b :: "'a::real_normed_vector" ``` huffman@20504 ` 822` ```proof - ``` huffman@22898 ` 823` ``` have "norm (a + - b) \ norm a + norm (- b)" ``` huffman@20504 ` 824` ``` by (rule norm_triangle_ineq) ``` haftmann@54230 ` 825` ``` then show ?thesis by simp ``` huffman@22898 ` 826` ```qed ``` huffman@22898 ` 827` lp15@66422 ` 828` ```lemma norm_triangle_le_diff: ``` lp15@66422 ` 829` ``` fixes x y :: "'a::real_normed_vector" ``` lp15@66422 ` 830` ``` shows "norm x + norm y \ e \ norm (x - y) \ e" ``` lp15@66422 ` 831` ``` by (meson norm_triangle_ineq4 order_trans) ``` lp15@66420 ` 832` wenzelm@63545 ` 833` ```lemma norm_diff_ineq: "norm a - norm b \ norm (a + b)" ``` wenzelm@63545 ` 834` ``` for a b :: "'a::real_normed_vector" ``` huffman@22898 ` 835` ```proof - ``` huffman@22898 ` 836` ``` have "norm a - norm (- b) \ norm (a - - b)" ``` huffman@22898 ` 837` ``` by (rule norm_triangle_ineq2) ``` wenzelm@63545 ` 838` ``` then show ?thesis by simp ``` huffman@20504 ` 839` ```qed ``` huffman@20504 ` 840` wenzelm@63545 ` 841` ```lemma norm_add_leD: "norm (a + b) \ c \ norm b \ norm a + c" ``` wenzelm@63545 ` 842` ``` for a b :: "'a::real_normed_vector" ``` wenzelm@63545 ` 843` ``` by (metis add.commute diff_le_eq norm_diff_ineq order.trans) ``` lp15@61762 ` 844` wenzelm@63545 ` 845` ```lemma norm_diff_triangle_ineq: "norm ((a + b) - (c + d)) \ norm (a - c) + norm (b - d)" ``` wenzelm@63545 ` 846` ``` for a b c d :: "'a::real_normed_vector" ``` huffman@20551 ` 847` ```proof - ``` huffman@20551 ` 848` ``` have "norm ((a + b) - (c + d)) = norm ((a - c) + (b - d))" ``` haftmann@54230 ` 849` ``` by (simp add: algebra_simps) ``` huffman@20551 ` 850` ``` also have "\ \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 851` ``` by (rule norm_triangle_ineq) ``` huffman@20551 ` 852` ``` finally show ?thesis . ``` huffman@20551 ` 853` ```qed ``` huffman@20551 ` 854` lp15@60800 ` 855` ```lemma norm_diff_triangle_le: ``` lp15@60800 ` 856` ``` fixes x y z :: "'a::real_normed_vector" ``` lp15@60800 ` 857` ``` assumes "norm (x - y) \ e1" "norm (y - z) \ e2" ``` wenzelm@63545 ` 858` ``` shows "norm (x - z) \ e1 + e2" ``` lp15@60800 ` 859` ``` using norm_diff_triangle_ineq [of x y y z] assms by simp ``` lp15@60800 ` 860` lp15@60800 ` 861` ```lemma norm_diff_triangle_less: ``` lp15@60800 ` 862` ``` fixes x y z :: "'a::real_normed_vector" ``` lp15@60800 ` 863` ``` assumes "norm (x - y) < e1" "norm (y - z) < e2" ``` wenzelm@63545 ` 864` ``` shows "norm (x - z) < e1 + e2" ``` lp15@60800 ` 865` ``` using norm_diff_triangle_ineq [of x y y z] assms by simp ``` lp15@60800 ` 866` lp15@60026 ` 867` ```lemma norm_triangle_mono: ``` lp15@55719 ` 868` ``` fixes a b :: "'a::real_normed_vector" ``` wenzelm@63545 ` 869` ``` shows "norm a \ r \ norm b \ s \ norm (a + b) \ r + s" ``` wenzelm@63545 ` 870` ``` by (metis add_mono_thms_linordered_semiring(1) norm_triangle_ineq order.trans) ``` lp15@55719 ` 871` nipkow@64267 ` 872` ```lemma norm_sum: ``` hoelzl@56194 ` 873` ``` fixes f :: "'a \ 'b::real_normed_vector" ``` nipkow@64267 ` 874` ``` shows "norm (sum f A) \ (\i\A. norm (f i))" ``` hoelzl@56194 ` 875` ``` by (induct A rule: infinite_finite_induct) (auto intro: norm_triangle_mono) ``` hoelzl@56194 ` 876` nipkow@64267 ` 877` ```lemma sum_norm_le: ``` hoelzl@56369 ` 878` ``` fixes f :: "'a \ 'b::real_normed_vector" ``` lp15@65680 ` 879` ``` assumes fg: "\x. x \ S \ norm (f x) \ g x" ``` nipkow@64267 ` 880` ``` shows "norm (sum f S) \ sum g S" ``` nipkow@64267 ` 881` ``` by (rule order_trans [OF norm_sum sum_mono]) (simp add: fg) ``` hoelzl@56369 ` 882` wenzelm@63545 ` 883` ```lemma abs_norm_cancel [simp]: "\norm a\ = norm a" ``` wenzelm@63545 ` 884` ``` for a :: "'a::real_normed_vector" ``` wenzelm@63545 ` 885` ``` by (rule abs_of_nonneg [OF norm_ge_zero]) ``` huffman@22857 ` 886` wenzelm@63545 ` 887` ```lemma norm_add_less: "norm x < r \ norm y < s \ norm (x + y) < r + s" ``` wenzelm@63545 ` 888` ``` for x y :: "'a::real_normed_vector" ``` wenzelm@63545 ` 889` ``` by (rule order_le_less_trans [OF norm_triangle_ineq add_strict_mono]) ``` huffman@22880 ` 890` wenzelm@63545 ` 891` ```lemma norm_mult_less: "norm x < r \ norm y < s \ norm (x * y) < r * s" ``` wenzelm@63545 ` 892` ``` for x y :: "'a::real_normed_algebra" ``` wenzelm@63545 ` 893` ``` by (rule order_le_less_trans [OF norm_mult_ineq]) (simp add: mult_strict_mono') ``` huffman@22880 ` 894` wenzelm@63545 ` 895` ```lemma norm_of_real [simp]: "norm (of_real r :: 'a::real_normed_algebra_1) = \r\" ``` wenzelm@63545 ` 896` ``` by (simp add: of_real_def) ``` huffman@20560 ` 897` wenzelm@63545 ` 898` ```lemma norm_numeral [simp]: "norm (numeral w::'a::real_normed_algebra_1) = numeral w" ``` wenzelm@63545 ` 899` ``` by (subst of_real_numeral [symmetric], subst norm_of_real, simp) ``` huffman@47108 ` 900` wenzelm@63545 ` 901` ```lemma norm_neg_numeral [simp]: "norm (- numeral w::'a::real_normed_algebra_1) = numeral w" ``` wenzelm@63545 ` 902` ``` by (subst of_real_neg_numeral [symmetric], subst norm_of_real, simp) ``` huffman@22876 ` 903` wenzelm@63545 ` 904` ```lemma norm_of_real_add1 [simp]: "norm (of_real x + 1 :: 'a :: real_normed_div_algebra) = \x + 1\" ``` lp15@62379 ` 905` ``` by (metis norm_of_real of_real_1 of_real_add) ``` lp15@62379 ` 906` lp15@62379 ` 907` ```lemma norm_of_real_addn [simp]: ``` wenzelm@63545 ` 908` ``` "norm (of_real x + numeral b :: 'a :: real_normed_div_algebra) = \x + numeral b\" ``` lp15@62379 ` 909` ``` by (metis norm_of_real of_real_add of_real_numeral) ``` lp15@62379 ` 910` wenzelm@63545 ` 911` ```lemma norm_of_int [simp]: "norm (of_int z::'a::real_normed_algebra_1) = \of_int z\" ``` wenzelm@63545 ` 912` ``` by (subst of_real_of_int_eq [symmetric], rule norm_of_real) ``` huffman@22876 ` 913` wenzelm@63545 ` 914` ```lemma norm_of_nat [simp]: "norm (of_nat n::'a::real_normed_algebra_1) = of_nat n" ``` wenzelm@63545 ` 915` ``` apply (subst of_real_of_nat_eq [symmetric]) ``` wenzelm@63545 ` 916` ``` apply (subst norm_of_real, simp) ``` wenzelm@63545 ` 917` ``` done ``` huffman@22876 ` 918` wenzelm@63545 ` 919` ```lemma nonzero_norm_inverse: "a \ 0 \ norm (inverse a) = inverse (norm a)" ``` wenzelm@63545 ` 920` ``` for a :: "'a::real_normed_div_algebra" ``` wenzelm@63545 ` 921` ``` apply (rule inverse_unique [symmetric]) ``` wenzelm@63545 ` 922` ``` apply (simp add: norm_mult [symmetric]) ``` wenzelm@63545 ` 923` ``` done ``` huffman@20504 ` 924` wenzelm@63545 ` 925` ```lemma norm_inverse: "norm (inverse a) = inverse (norm a)" ``` wenzelm@63545 ` 926` ``` for a :: "'a::{real_normed_div_algebra,division_ring}" ``` wenzelm@63545 ` 927` ``` apply (cases "a = 0") ``` wenzelm@63545 ` 928` ``` apply simp ``` wenzelm@63545 ` 929` ``` apply (erule nonzero_norm_inverse) ``` wenzelm@63545 ` 930` ``` done ``` huffman@20504 ` 931` wenzelm@63545 ` 932` ```lemma nonzero_norm_divide: "b \ 0 \ norm (a / b) = norm a / norm b" ``` wenzelm@63545 ` 933` ``` for a b :: "'a::real_normed_field" ``` wenzelm@63545 ` 934` ``` by (simp add: divide_inverse norm_mult nonzero_norm_inverse) ``` huffman@20584 ` 935` wenzelm@63545 ` 936` ```lemma norm_divide: "norm (a / b) = norm a / norm b" ``` wenzelm@63545 ` 937` ``` for a b :: "'a::{real_normed_field,field}" ``` wenzelm@63545 ` 938` ``` by (simp add: divide_inverse norm_mult norm_inverse) ``` huffman@20584 ` 939` wenzelm@63545 ` 940` ```lemma norm_power_ineq: "norm (x ^ n) \ norm x ^ n" ``` wenzelm@63545 ` 941` ``` for x :: "'a::real_normed_algebra_1" ``` huffman@22852 ` 942` ```proof (induct n) ``` wenzelm@63545 ` 943` ``` case 0 ``` wenzelm@63545 ` 944` ``` show "norm (x ^ 0) \ norm x ^ 0" by simp ``` huffman@22852 ` 945` ```next ``` huffman@22852 ` 946` ``` case (Suc n) ``` huffman@22852 ` 947` ``` have "norm (x * x ^ n) \ norm x * norm (x ^ n)" ``` huffman@22852 ` 948` ``` by (rule norm_mult_ineq) ``` huffman@22852 ` 949` ``` also from Suc have "\ \ norm x * norm x ^ n" ``` huffman@22852 ` 950` ``` using norm_ge_zero by (rule mult_left_mono) ``` huffman@22852 ` 951` ``` finally show "norm (x ^ Suc n) \ norm x ^ Suc n" ``` huffman@30273 ` 952` ``` by simp ``` huffman@22852 ` 953` ```qed ``` huffman@22852 ` 954` wenzelm@63545 ` 955` ```lemma norm_power: "norm (x ^ n) = norm x ^ n" ``` wenzelm@63545 ` 956` ``` for x :: "'a::real_normed_div_algebra" ``` wenzelm@63545 ` 957` ``` by (induct n) (simp_all add: norm_mult) ``` huffman@20684 ` 958` lp15@62948 ` 959` ```lemma power_eq_imp_eq_norm: ``` lp15@62948 ` 960` ``` fixes w :: "'a::real_normed_div_algebra" ``` lp15@62948 ` 961` ``` assumes eq: "w ^ n = z ^ n" and "n > 0" ``` lp15@62948 ` 962` ``` shows "norm w = norm z" ``` lp15@62948 ` 963` ```proof - ``` lp15@62948 ` 964` ``` have "norm w ^ n = norm z ^ n" ``` lp15@62948 ` 965` ``` by (metis (no_types) eq norm_power) ``` lp15@62948 ` 966` ``` then show ?thesis ``` lp15@62948 ` 967` ``` using assms by (force intro: power_eq_imp_eq_base) ``` lp15@62948 ` 968` ```qed ``` lp15@62948 ` 969` wenzelm@63545 ` 970` ```lemma norm_mult_numeral1 [simp]: "norm (numeral w * a) = numeral w * norm a" ``` wenzelm@63545 ` 971` ``` for a b :: "'a::{real_normed_field,field}" ``` wenzelm@63545 ` 972` ``` by (simp add: norm_mult) ``` paulson@60762 ` 973` wenzelm@63545 ` 974` ```lemma norm_mult_numeral2 [simp]: "norm (a * numeral w) = norm a * numeral w" ``` wenzelm@63545 ` 975` ``` for a b :: "'a::{real_normed_field,field}" ``` wenzelm@63545 ` 976` ``` by (simp add: norm_mult) ``` paulson@60762 ` 977` wenzelm@63545 ` 978` ```lemma norm_divide_numeral [simp]: "norm (a / numeral w) = norm a / numeral w" ``` wenzelm@63545 ` 979` ``` for a b :: "'a::{real_normed_field,field}" ``` wenzelm@63545 ` 980` ``` by (simp add: norm_divide) ``` paulson@60762 ` 981` paulson@60762 ` 982` ```lemma norm_of_real_diff [simp]: ``` wenzelm@63545 ` 983` ``` "norm (of_real b - of_real a :: 'a::real_normed_algebra_1) \ \b - a\" ``` paulson@60762 ` 984` ``` by (metis norm_of_real of_real_diff order_refl) ``` paulson@60762 ` 985` wenzelm@63545 ` 986` ```text \Despite a superficial resemblance, \norm_eq_1\ is not relevant.\ ``` lp15@59613 ` 987` ```lemma square_norm_one: ``` lp15@59613 ` 988` ``` fixes x :: "'a::real_normed_div_algebra" ``` wenzelm@63545 ` 989` ``` assumes "x\<^sup>2 = 1" ``` wenzelm@63545 ` 990` ``` shows "norm x = 1" ``` lp15@59613 ` 991` ``` by (metis assms norm_minus_cancel norm_one power2_eq_1_iff) ``` lp15@59613 ` 992` wenzelm@63545 ` 993` ```lemma norm_less_p1: "norm x < norm (of_real (norm x) + 1 :: 'a)" ``` wenzelm@63545 ` 994` ``` for x :: "'a::real_normed_algebra_1" ``` lp15@59658 ` 995` ```proof - ``` lp15@59658 ` 996` ``` have "norm x < norm (of_real (norm x + 1) :: 'a)" ``` lp15@59658 ` 997` ``` by (simp add: of_real_def) ``` lp15@59658 ` 998` ``` then show ?thesis ``` lp15@59658 ` 999` ``` by simp ``` lp15@59658 ` 1000` ```qed ``` lp15@59658 ` 1001` nipkow@64272 ` 1002` ```lemma prod_norm: "prod (\x. norm (f x)) A = norm (prod f A)" ``` wenzelm@63545 ` 1003` ``` for f :: "'a \ 'b::{comm_semiring_1,real_normed_div_algebra}" ``` hoelzl@57275 ` 1004` ``` by (induct A rule: infinite_finite_induct) (auto simp: norm_mult) ``` hoelzl@57275 ` 1005` nipkow@64272 ` 1006` ```lemma norm_prod_le: ``` nipkow@64272 ` 1007` ``` "norm (prod f A) \ (\a\A. norm (f a :: 'a :: {real_normed_algebra_1,comm_monoid_mult}))" ``` wenzelm@63545 ` 1008` ```proof (induct A rule: infinite_finite_induct) ``` wenzelm@63545 ` 1009` ``` case empty ``` wenzelm@63545 ` 1010` ``` then show ?case by simp ``` wenzelm@63545 ` 1011` ```next ``` hoelzl@57275 ` 1012` ``` case (insert a A) ``` nipkow@64272 ` 1013` ``` then have "norm (prod f (insert a A)) \ norm (f a) * norm (prod f A)" ``` hoelzl@57275 ` 1014` ``` by (simp add: norm_mult_ineq) ``` nipkow@64272 ` 1015` ``` also have "norm (prod f A) \ (\a\A. norm (f a))" ``` hoelzl@57275 ` 1016` ``` by (rule insert) ``` hoelzl@57275 ` 1017` ``` finally show ?case ``` hoelzl@57275 ` 1018` ``` by (simp add: insert mult_left_mono) ``` wenzelm@63545 ` 1019` ```next ``` wenzelm@63545 ` 1020` ``` case infinite ``` wenzelm@63545 ` 1021` ``` then show ?case by simp ``` wenzelm@63545 ` 1022` ```qed ``` hoelzl@57275 ` 1023` nipkow@64272 ` 1024` ```lemma norm_prod_diff: ``` hoelzl@57275 ` 1025` ``` fixes z w :: "'i \ 'a::{real_normed_algebra_1, comm_monoid_mult}" ``` hoelzl@57275 ` 1026` ``` shows "(\i. i \ I \ norm (z i) \ 1) \ (\i. i \ I \ norm (w i) \ 1) \ ``` lp15@60026 ` 1027` ``` norm ((\i\I. z i) - (\i\I. w i)) \ (\i\I. norm (z i - w i))" ``` hoelzl@57275 ` 1028` ```proof (induction I rule: infinite_finite_induct) ``` wenzelm@63545 ` 1029` ``` case empty ``` wenzelm@63545 ` 1030` ``` then show ?case by simp ``` wenzelm@63545 ` 1031` ```next ``` hoelzl@57275 ` 1032` ``` case (insert i I) ``` hoelzl@57275 ` 1033` ``` note insert.hyps[simp] ``` hoelzl@57275 ` 1034` hoelzl@57275 ` 1035` ``` have "norm ((\i\insert i I. z i) - (\i\insert i I. w i)) = ``` hoelzl@57275 ` 1036` ``` norm ((\i\I. z i) * (z i - w i) + ((\i\I. z i) - (\i\I. w i)) * w i)" ``` hoelzl@57275 ` 1037` ``` (is "_ = norm (?t1 + ?t2)") ``` hoelzl@57275 ` 1038` ``` by (auto simp add: field_simps) ``` wenzelm@63545 ` 1039` ``` also have "\ \ norm ?t1 + norm ?t2" ``` hoelzl@57275 ` 1040` ``` by (rule norm_triangle_ineq) ``` hoelzl@57275 ` 1041` ``` also have "norm ?t1 \ norm (\i\I. z i) * norm (z i - w i)" ``` hoelzl@57275 ` 1042` ``` by (rule norm_mult_ineq) ``` hoelzl@57275 ` 1043` ``` also have "\ \ (\i\I. norm (z i)) * norm(z i - w i)" ``` nipkow@64272 ` 1044` ``` by (rule mult_right_mono) (auto intro: norm_prod_le) ``` hoelzl@57275 ` 1045` ``` also have "(\i\I. norm (z i)) \ (\i\I. 1)" ``` nipkow@64272 ` 1046` ``` by (intro prod_mono) (auto intro!: insert) ``` hoelzl@57275 ` 1047` ``` also have "norm ?t2 \ norm ((\i\I. z i) - (\i\I. w i)) * norm (w i)" ``` hoelzl@57275 ` 1048` ``` by (rule norm_mult_ineq) ``` hoelzl@57275 ` 1049` ``` also have "norm (w i) \ 1" ``` hoelzl@57275 ` 1050` ``` by (auto intro: insert) ``` hoelzl@57275 ` 1051` ``` also have "norm ((\i\I. z i) - (\i\I. w i)) \ (\i\I. norm (z i - w i))" ``` hoelzl@57275 ` 1052` ``` using insert by auto ``` hoelzl@57275 ` 1053` ``` finally show ?case ``` haftmann@57514 ` 1054` ``` by (auto simp add: ac_simps mult_right_mono mult_left_mono) ``` wenzelm@63545 ` 1055` ```next ``` wenzelm@63545 ` 1056` ``` case infinite ``` wenzelm@63545 ` 1057` ``` then show ?case by simp ``` wenzelm@63545 ` 1058` ```qed ``` hoelzl@57275 ` 1059` lp15@60026 ` 1060` ```lemma norm_power_diff: ``` hoelzl@57275 ` 1061` ``` fixes z w :: "'a::{real_normed_algebra_1, comm_monoid_mult}" ``` hoelzl@57275 ` 1062` ``` assumes "norm z \ 1" "norm w \ 1" ``` hoelzl@57275 ` 1063` ``` shows "norm (z^m - w^m) \ m * norm (z - w)" ``` hoelzl@57275 ` 1064` ```proof - ``` hoelzl@57275 ` 1065` ``` have "norm (z^m - w^m) = norm ((\ i < m. z) - (\ i < m. w))" ``` nipkow@64272 ` 1066` ``` by (simp add: prod_constant) ``` hoelzl@57275 ` 1067` ``` also have "\ \ (\i = m * norm (z - w)" ``` lp15@61609 ` 1070` ``` by simp ``` hoelzl@57275 ` 1071` ``` finally show ?thesis . ``` lp15@55719 ` 1072` ```qed ``` lp15@55719 ` 1073` wenzelm@63545 ` 1074` wenzelm@60758 ` 1075` ```subsection \Metric spaces\ ``` hoelzl@51531 ` 1076` hoelzl@62101 ` 1077` ```class metric_space = uniformity_dist + open_uniformity + ``` hoelzl@51531 ` 1078` ``` assumes dist_eq_0_iff [simp]: "dist x y = 0 \ x = y" ``` wenzelm@63545 ` 1079` ``` and dist_triangle2: "dist x y \ dist x z + dist y z" ``` hoelzl@51531 ` 1080` ```begin ``` hoelzl@51531 ` 1081` hoelzl@51531 ` 1082` ```lemma dist_self [simp]: "dist x x = 0" ``` wenzelm@63545 ` 1083` ``` by simp ``` hoelzl@51531 ` 1084` hoelzl@51531 ` 1085` ```lemma zero_le_dist [simp]: "0 \ dist x y" ``` wenzelm@63545 ` 1086` ``` using dist_triangle2 [of x x y] by simp ``` hoelzl@51531 ` 1087` hoelzl@51531 ` 1088` ```lemma zero_less_dist_iff: "0 < dist x y \ x \ y" ``` wenzelm@63545 ` 1089` ``` by (simp add: less_le) ``` hoelzl@51531 ` 1090` hoelzl@51531 ` 1091` ```lemma dist_not_less_zero [simp]: "\ dist x y < 0" ``` wenzelm@63545 ` 1092` ``` by (simp add: not_less) ``` hoelzl@51531 ` 1093` hoelzl@51531 ` 1094` ```lemma dist_le_zero_iff [simp]: "dist x y \ 0 \ x = y" ``` wenzelm@63545 ` 1095` ``` by (simp add: le_less) ``` hoelzl@51531 ` 1096` hoelzl@51531 ` 1097` ```lemma dist_commute: "dist x y = dist y x" ``` hoelzl@51531 ` 1098` ```proof (rule order_antisym) ``` hoelzl@51531 ` 1099` ``` show "dist x y \ dist y x" ``` hoelzl@51531 ` 1100` ``` using dist_triangle2 [of x y x] by simp ``` hoelzl@51531 ` 1101` ``` show "dist y x \ dist x y" ``` hoelzl@51531 ` 1102` ``` using dist_triangle2 [of y x y] by simp ``` hoelzl@51531 ` 1103` ```qed ``` hoelzl@51531 ` 1104` lp15@62533 ` 1105` ```lemma dist_commute_lessI: "dist y x < e \ dist x y < e" ``` lp15@62533 ` 1106` ``` by (simp add: dist_commute) ``` lp15@62533 ` 1107` hoelzl@51531 ` 1108` ```lemma dist_triangle: "dist x z \ dist x y + dist y z" ``` lp15@62533 ` 1109` ``` using dist_triangle2 [of x z y] by (simp add: dist_commute) ``` hoelzl@51531 ` 1110` hoelzl@51531 ` 1111` ```lemma dist_triangle3: "dist x y \ dist a x + dist a y" ``` lp15@62533 ` 1112` ``` using dist_triangle2 [of x y a] by (simp add: dist_commute) ``` hoelzl@51531 ` 1113` wenzelm@63545 ` 1114` ```lemma dist_pos_lt: "x \ y \ 0 < dist x y" ``` wenzelm@63545 ` 1115` ``` by (simp add: zero_less_dist_iff) ``` hoelzl@51531 ` 1116` wenzelm@63545 ` 1117` ```lemma dist_nz: "x \ y \ 0 < dist x y" ``` wenzelm@63545 ` 1118` ``` by (simp add: zero_less_dist_iff) ``` hoelzl@51531 ` 1119` paulson@62087 ` 1120` ```declare dist_nz [symmetric, simp] ``` paulson@62087 ` 1121` wenzelm@63545 ` 1122` ```lemma dist_triangle_le: "dist x z + dist y z \ e \ dist x y \ e" ``` wenzelm@63545 ` 1123` ``` by (rule order_trans [OF dist_triangle2]) ``` hoelzl@51531 ` 1124` wenzelm@63545 ` 1125` ```lemma dist_triangle_lt: "dist x z + dist y z < e \ dist x y < e" ``` wenzelm@63545 ` 1126` ``` by (rule le_less_trans [OF dist_triangle2]) ``` hoelzl@51531 ` 1127` wenzelm@63545 ` 1128` ```lemma dist_triangle_less_add: "dist x1 y < e1 \ dist x2 y < e2 \ dist x1 x2 < e1 + e2" ``` wenzelm@63545 ` 1129` ``` by (rule dist_triangle_lt [where z=y]) simp ``` lp15@62948 ` 1130` wenzelm@63545 ` 1131` ```lemma dist_triangle_half_l: "dist x1 y < e / 2 \ dist x2 y < e / 2 \ dist x1 x2 < e" ``` wenzelm@63545 ` 1132` ``` by (rule dist_triangle_lt [where z=y]) simp ``` hoelzl@51531 ` 1133` wenzelm@63545 ` 1134` ```lemma dist_triangle_half_r: "dist y x1 < e / 2 \ dist y x2 < e / 2 \ dist x1 x2 < e" ``` wenzelm@63545 ` 1135` ``` by (rule dist_triangle_half_l) (simp_all add: dist_commute) ``` hoelzl@51531 ` 1136` lp15@65036 ` 1137` ```lemma dist_triangle_third: ``` lp15@65036 ` 1138` ``` assumes "dist x1 x2 < e/3" "dist x2 x3 < e/3" "dist x3 x4 < e/3" ``` lp15@65036 ` 1139` ``` shows "dist x1 x4 < e" ``` lp15@65036 ` 1140` ```proof - ``` lp15@65036 ` 1141` ``` have "dist x1 x3 < e/3 + e/3" ``` lp15@65036 ` 1142` ``` by (metis assms(1) assms(2) dist_commute dist_triangle_less_add) ``` lp15@65036 ` 1143` ``` then have "dist x1 x4 < (e/3 + e/3) + e/3" ``` lp15@65036 ` 1144` ``` by (metis assms(3) dist_commute dist_triangle_less_add) ``` lp15@65036 ` 1145` ``` then show ?thesis ``` lp15@65036 ` 1146` ``` by simp ``` lp15@65036 ` 1147` ```qed ``` lp15@65036 ` 1148` hoelzl@62101 ` 1149` ```subclass uniform_space ``` hoelzl@51531 ` 1150` ```proof ``` wenzelm@63545 ` 1151` ``` fix E x ``` wenzelm@63545 ` 1152` ``` assume "eventually E uniformity" ``` hoelzl@62101 ` 1153` ``` then obtain e where E: "0 < e" "\x y. dist x y < e \ E (x, y)" ``` wenzelm@63545 ` 1154` ``` by (auto simp: eventually_uniformity_metric) ``` hoelzl@62101 ` 1155` ``` then show "E (x, x)" "\\<^sub>F (x, y) in uniformity. E (y, x)" ``` wenzelm@63545 ` 1156` ``` by (auto simp: eventually_uniformity_metric dist_commute) ``` hoelzl@62101 ` 1157` ``` show "\D. eventually D uniformity \ (\x y z. D (x, y) \ D (y, z) \ E (x, z))" ``` wenzelm@63545 ` 1158` ``` using E dist_triangle_half_l[where e=e] ``` wenzelm@63545 ` 1159` ``` unfolding eventually_uniformity_metric ``` hoelzl@62101 ` 1160` ``` by (intro exI[of _ "\(x, y). dist x y < e / 2"] exI[of _ "e/2"] conjI) ``` wenzelm@63545 ` 1161` ``` (auto simp: dist_commute) ``` hoelzl@51531 ` 1162` ```qed ``` hoelzl@51531 ` 1163` hoelzl@62101 ` 1164` ```lemma open_dist: "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" ``` wenzelm@63545 ` 1165` ``` by (simp add: dist_commute open_uniformity eventually_uniformity_metric) ``` hoelzl@62101 ` 1166` hoelzl@51531 ` 1167` ```lemma open_ball: "open {y. dist x y < d}" ``` wenzelm@63545 ` 1168` ``` unfolding open_dist ``` wenzelm@63545 ` 1169` ```proof (intro ballI) ``` wenzelm@63545 ` 1170` ``` fix y ``` wenzelm@63545 ` 1171` ``` assume *: "y \ {y. dist x y < d}" ``` hoelzl@51531 ` 1172` ``` then show "\e>0. \z. dist z y < e \ z \ {y. dist x y < d}" ``` hoelzl@51531 ` 1173` ``` by (auto intro!: exI[of _ "d - dist x y"] simp: field_simps dist_triangle_lt) ``` hoelzl@51531 ` 1174` ```qed ``` hoelzl@51531 ` 1175` hoelzl@51531 ` 1176` ```subclass first_countable_topology ``` hoelzl@51531 ` 1177` ```proof ``` lp15@60026 ` 1178` ``` fix x ``` hoelzl@51531 ` 1179` ``` show "\A::nat \ 'a set. (\i. x \ A i \ open (A i)) \ (\S. open S \ x \ S \ (\i. A i \ S))" ``` hoelzl@51531 ` 1180` ``` proof (safe intro!: exI[of _ "\n. {y. dist x y < inverse (Suc n)}"]) ``` wenzelm@63545 ` 1181` ``` fix S ``` wenzelm@63545 ` 1182` ``` assume "open S" "x \ S" ``` wenzelm@53374 ` 1183` ``` then obtain e where e: "0 < e" and "{y. dist x y < e} \ S" ``` hoelzl@51531 ` 1184` ``` by (auto simp: open_dist subset_eq dist_commute) ``` hoelzl@51531 ` 1185` ``` moreover ``` wenzelm@53374 ` 1186` ``` from e obtain i where "inverse (Suc i) < e" ``` hoelzl@51531 ` 1187` ``` by (auto dest!: reals_Archimedean) ``` hoelzl@51531 ` 1188` ``` then have "{y. dist x y < inverse (Suc i)} \ {y. dist x y < e}" ``` hoelzl@51531 ` 1189` ``` by auto ``` hoelzl@51531 ` 1190` ``` ultimately show "\i. {y. dist x y < inverse (Suc i)} \ S" ``` hoelzl@51531 ` 1191` ``` by blast ``` hoelzl@51531 ` 1192` ``` qed (auto intro: open_ball) ``` hoelzl@51531 ` 1193` ```qed ``` hoelzl@51531 ` 1194` hoelzl@51531 ` 1195` ```end ``` hoelzl@51531 ` 1196` hoelzl@51531 ` 1197` ```instance metric_space \ t2_space ``` hoelzl@51531 ` 1198` ```proof ``` hoelzl@51531 ` 1199` ``` fix x y :: "'a::metric_space" ``` hoelzl@51531 ` 1200` ``` assume xy: "x \ y" ``` hoelzl@51531 ` 1201` ``` let ?U = "{y'. dist x y' < dist x y / 2}" ``` hoelzl@51531 ` 1202` ``` let ?V = "{x'. dist y x' < dist x y / 2}" ``` wenzelm@63545 ` 1203` ``` have *: "d x z \ d x y + d y z \ d y z = d z y \ \ (d x y * 2 < d x z \ d z y * 2 < d x z)" ``` wenzelm@63545 ` 1204` ``` for d :: "'a \ 'a \ real" and x y z :: 'a ``` wenzelm@63545 ` 1205` ``` by arith ``` hoelzl@51531 ` 1206` ``` have "open ?U \ open ?V \ x \ ?U \ y \ ?V \ ?U \ ?V = {}" ``` wenzelm@63545 ` 1207` ``` using dist_pos_lt[OF xy] *[of dist, OF dist_triangle dist_commute] ``` hoelzl@51531 ` 1208` ``` using open_ball[of _ "dist x y / 2"] by auto ``` hoelzl@51531 ` 1209` ``` then show "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" ``` hoelzl@51531 ` 1210` ``` by blast ``` hoelzl@51531 ` 1211` ```qed ``` hoelzl@51531 ` 1212` wenzelm@60758 ` 1213` ```text \Every normed vector space is a metric space.\ ``` huffman@31289 ` 1214` ```instance real_normed_vector < metric_space ``` huffman@31289 ` 1215` ```proof ``` wenzelm@63545 ` 1216` ``` fix x y z :: 'a ``` wenzelm@63545 ` 1217` ``` show "dist x y = 0 \ x = y" ``` wenzelm@63545 ` 1218` ``` by (simp add: dist_norm) ``` wenzelm@63545 ` 1219` ``` show "dist x y \ dist x z + dist y z" ``` wenzelm@63545 ` 1220` ``` using norm_triangle_ineq4 [of "x - z" "y - z"] by (simp add: dist_norm) ``` huffman@31289 ` 1221` ```qed ``` huffman@31285 ` 1222` wenzelm@63545 ` 1223` wenzelm@60758 ` 1224` ```subsection \Class instances for real numbers\ ``` huffman@31564 ` 1225` huffman@31564 ` 1226` ```instantiation real :: real_normed_field ``` huffman@31564 ` 1227` ```begin ``` huffman@31564 ` 1228` wenzelm@63545 ` 1229` ```definition dist_real_def: "dist x y = \x - y\" ``` hoelzl@51531 ` 1230` hoelzl@62101 ` 1231` ```definition uniformity_real_def [code del]: ``` hoelzl@62101 ` 1232` ``` "(uniformity :: (real \ real) filter) = (INF e:{0 <..}. principal {(x, y). dist x y < e})" ``` hoelzl@62101 ` 1233` haftmann@52381 ` 1234` ```definition open_real_def [code del]: ``` hoelzl@62101 ` 1235` ``` "open (U :: real set) \ (\x\U. eventually (\(x', y). x' = x \ y \ U) uniformity)" ``` hoelzl@51531 ` 1236` wenzelm@63545 ` 1237` ```definition real_norm_def [simp]: "norm r = \r\" ``` huffman@31564 ` 1238` huffman@31564 ` 1239` ```instance ``` wenzelm@63545 ` 1240` ``` apply intro_classes ``` wenzelm@63545 ` 1241` ``` apply (unfold real_norm_def real_scaleR_def) ``` wenzelm@63545 ` 1242` ``` apply (rule dist_real_def) ``` wenzelm@63545 ` 1243` ``` apply (simp add: sgn_real_def) ``` wenzelm@63545 ` 1244` ``` apply (rule uniformity_real_def) ``` wenzelm@63545 ` 1245` ``` apply (rule open_real_def) ``` wenzelm@63545 ` 1246` ``` apply (rule abs_eq_0) ``` wenzelm@63545 ` 1247` ``` apply (rule abs_triangle_ineq) ``` wenzelm@63545 ` 1248` ``` apply (rule abs_mult) ``` wenzelm@63545 ` 1249` ``` apply (rule abs_mult) ``` wenzelm@63545 ` 1250` ``` done ``` huffman@31564 ` 1251` huffman@31564 ` 1252` ```end ``` huffman@31564 ` 1253` hoelzl@62102 ` 1254` ```declare uniformity_Abort[where 'a=real, code] ``` hoelzl@62102 ` 1255` wenzelm@63545 ` 1256` ```lemma dist_of_real [simp]: "dist (of_real x :: 'a) (of_real y) = dist x y" ``` wenzelm@63545 ` 1257` ``` for a :: "'a::real_normed_div_algebra" ``` wenzelm@63545 ` 1258` ``` by (metis dist_norm norm_of_real of_real_diff real_norm_def) ``` lp15@60800 ` 1259` haftmann@54890 ` 1260` ```declare [[code abort: "open :: real set \ bool"]] ``` haftmann@52381 ` 1261` hoelzl@51531 ` 1262` ```instance real :: linorder_topology ``` hoelzl@51531 ` 1263` ```proof ``` hoelzl@51531 ` 1264` ``` show "(open :: real set \ bool) = generate_topology (range lessThan \ range greaterThan)" ``` hoelzl@51531 ` 1265` ``` proof (rule ext, safe) ``` wenzelm@63545 ` 1266` ``` fix S :: "real set" ``` wenzelm@63545 ` 1267` ``` assume "open S" ``` wenzelm@53381 ` 1268` ``` then obtain f where "\x\S. 0 < f x \ (\y. dist y x < f x \ y \ S)" ``` hoelzl@62101 ` 1269` ``` unfolding open_dist bchoice_iff .. ``` hoelzl@51531 ` 1270` ``` then have *: "S = (\x\S. {x - f x <..} \ {..< x + f x})" ``` hoelzl@51531 ` 1271` ``` by (fastforce simp: dist_real_def) ``` hoelzl@51531 ` 1272` ``` show "generate_topology (range lessThan \ range greaterThan) S" ``` hoelzl@51531 ` 1273` ``` apply (subst *) ``` hoelzl@51531 ` 1274` ``` apply (intro generate_topology_Union generate_topology.Int) ``` wenzelm@63545 ` 1275` ``` apply (auto intro: generate_topology.Basis) ``` hoelzl@51531 ` 1276` ``` done ``` hoelzl@51531 ` 1277` ``` next ``` wenzelm@63545 ` 1278` ``` fix S :: "real set" ``` wenzelm@63545 ` 1279` ``` assume "generate_topology (range lessThan \ range greaterThan) S" ``` hoelzl@51531 ` 1280` ``` moreover have "\a::real. open {.. (\y. \y - x\ < a - x \ y \ {..e>0. \y. \y - x\ < e \ y \ {..a::real. open {a <..}" ``` hoelzl@62101 ` 1289` ``` unfolding open_dist dist_real_def ``` hoelzl@51531 ` 1290` ``` proof clarify ``` wenzelm@63545 ` 1291` ``` fix x a :: real ``` wenzelm@63545 ` 1292` ``` assume "a < x" ``` wenzelm@63545 ` 1293` ``` then have "0 < x - a \ (\y. \y - x\ < x - a \ y \ {a<..})" by auto ``` wenzelm@63545 ` 1294` ``` then show "\e>0. \y. \y - x\ < e \ y \ {a<..}" .. ``` hoelzl@51531 ` 1295` ``` qed ``` hoelzl@51531 ` 1296` ``` ultimately show "open S" ``` hoelzl@51531 ` 1297` ``` by induct auto ``` hoelzl@51531 ` 1298` ``` qed ``` hoelzl@51531 ` 1299` ```qed ``` hoelzl@51531 ` 1300` hoelzl@51775 ` 1301` ```instance real :: linear_continuum_topology .. ``` hoelzl@51518 ` 1302` hoelzl@51531 ` 1303` ```lemmas open_real_greaterThan = open_greaterThan[where 'a=real] ``` hoelzl@51531 ` 1304` ```lemmas open_real_lessThan = open_lessThan[where 'a=real] ``` hoelzl@51531 ` 1305` ```lemmas open_real_greaterThanLessThan = open_greaterThanLessThan[where 'a=real] ``` hoelzl@51531 ` 1306` ```lemmas closed_real_atMost = closed_atMost[where 'a=real] ``` hoelzl@51531 ` 1307` ```lemmas closed_real_atLeast = closed_atLeast[where 'a=real] ``` hoelzl@51531 ` 1308` ```lemmas closed_real_atLeastAtMost = closed_atLeastAtMost[where 'a=real] ``` hoelzl@51531 ` 1309` wenzelm@63545 ` 1310` wenzelm@60758 ` 1311` ```subsection \Extra type constraints\ ``` huffman@31446 ` 1312` wenzelm@61799 ` 1313` ```text \Only allow @{term "open"} in class \topological_space\.\ ``` wenzelm@60758 ` 1314` ```setup \Sign.add_const_constraint ``` wenzelm@60758 ` 1315` ``` (@{const_name "open"}, SOME @{typ "'a::topological_space set \ bool"})\ ``` huffman@31492 ` 1316` hoelzl@62101 ` 1317` ```text \Only allow @{term "uniformity"} in class \uniform_space\.\ ``` hoelzl@62101 ` 1318` ```setup \Sign.add_const_constraint ``` hoelzl@62101 ` 1319` ``` (@{const_name "uniformity"}, SOME @{typ "('a::uniformity \ 'a) filter"})\ ``` hoelzl@62101 ` 1320` wenzelm@61799 ` 1321` ```text \Only allow @{term dist} in class \metric_space\.\ ``` wenzelm@60758 ` 1322` ```setup \Sign.add_const_constraint ``` wenzelm@60758 ` 1323` ``` (@{const_name dist}, SOME @{typ "'a::metric_space \ 'a \ real"})\ ``` huffman@31446 ` 1324` wenzelm@61799 ` 1325` ```text \Only allow @{term norm} in class \real_normed_vector\.\ ``` wenzelm@60758 ` 1326` ```setup \Sign.add_const_constraint ``` wenzelm@60758 ` 1327` ``` (@{const_name norm}, SOME @{typ "'a::real_normed_vector \ real"})\ ``` huffman@31446 ` 1328` wenzelm@63545 ` 1329` wenzelm@60758 ` 1330` ```subsection \Sign function\ ``` huffman@22972 ` 1331` wenzelm@63545 ` 1332` ```lemma norm_sgn: "norm (sgn x) = (if x = 0 then 0 else 1)" ``` wenzelm@63545 ` 1333` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 1334` ``` by (simp add: sgn_div_norm) ``` huffman@22972 ` 1335` wenzelm@63545 ` 1336` ```lemma sgn_zero [simp]: "sgn (0::'a::real_normed_vector) = 0" ``` wenzelm@63545 ` 1337` ``` by (simp add: sgn_div_norm) ``` huffman@22972 ` 1338` wenzelm@63545 ` 1339` ```lemma sgn_zero_iff: "sgn x = 0 \ x = 0" ``` wenzelm@63545 ` 1340` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 1341` ``` by (simp add: sgn_div_norm) ``` huffman@22972 ` 1342` wenzelm@63545 ` 1343` ```lemma sgn_minus: "sgn (- x) = - sgn x" ``` wenzelm@63545 ` 1344` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 1345` ``` by (simp add: sgn_div_norm) ``` huffman@22972 ` 1346` wenzelm@63545 ` 1347` ```lemma sgn_scaleR: "sgn (scaleR r x) = scaleR (sgn r) (sgn x)" ``` wenzelm@63545 ` 1348` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 1349` ``` by (simp add: sgn_div_norm ac_simps) ``` huffman@22973 ` 1350` huffman@22972 ` 1351` ```lemma sgn_one [simp]: "sgn (1::'a::real_normed_algebra_1) = 1" ``` wenzelm@63545 ` 1352` ``` by (simp add: sgn_div_norm) ``` huffman@22972 ` 1353` wenzelm@63545 ` 1354` ```lemma sgn_of_real: "sgn (of_real r :: 'a::real_normed_algebra_1) = of_real (sgn r)" ``` wenzelm@63545 ` 1355` ``` unfolding of_real_def by (simp only: sgn_scaleR sgn_one) ``` huffman@22972 ` 1356` wenzelm@63545 ` 1357` ```lemma sgn_mult: "sgn (x * y) = sgn x * sgn y" ``` wenzelm@63545 ` 1358` ``` for x y :: "'a::real_normed_div_algebra" ``` wenzelm@63545 ` 1359` ``` by (simp add: sgn_div_norm norm_mult mult.commute) ``` huffman@22973 ` 1360` haftmann@64240 ` 1361` ```hide_fact (open) sgn_mult ``` haftmann@64240 ` 1362` wenzelm@63545 ` 1363` ```lemma real_sgn_eq: "sgn x = x / \x\" ``` wenzelm@63545 ` 1364` ``` for x :: real ``` lp15@61649 ` 1365` ``` by (simp add: sgn_div_norm divide_inverse) ``` huffman@22972 ` 1366` wenzelm@63545 ` 1367` ```lemma zero_le_sgn_iff [simp]: "0 \ sgn x \ 0 \ x" ``` wenzelm@63545 ` 1368` ``` for x :: real ``` hoelzl@56889 ` 1369` ``` by (cases "0::real" x rule: linorder_cases) simp_all ``` lp15@60026 ` 1370` wenzelm@63545 ` 1371` ```lemma sgn_le_0_iff [simp]: "sgn x \ 0 \ x \ 0" ``` wenzelm@63545 ` 1372` ``` for x :: real ``` hoelzl@56889 ` 1373` ``` by (cases "0::real" x rule: linorder_cases) simp_all ``` lp15@60026 ` 1374` hoelzl@51474 ` 1375` ```lemma norm_conv_dist: "norm x = dist x 0" ``` hoelzl@51474 ` 1376` ``` unfolding dist_norm by simp ``` huffman@22972 ` 1377` lp15@62379 ` 1378` ```declare norm_conv_dist [symmetric, simp] ``` lp15@62379 ` 1379` wenzelm@63545 ` 1380` ```lemma dist_0_norm [simp]: "dist 0 x = norm x" ``` wenzelm@63545 ` 1381` ``` for x :: "'a::real_normed_vector" ``` wenzelm@63545 ` 1382` ``` by (simp add: dist_norm) ``` lp15@62397 ` 1383` lp15@60307 ` 1384` ```lemma dist_diff [simp]: "dist a (a - b) = norm b" "dist (a - b) a = norm b" ``` lp15@60307 ` 1385` ``` by (simp_all add: dist_norm) ``` lp15@61609 ` 1386` eberlm@61524 ` 1387` ```lemma dist_of_int: "dist (of_int m) (of_int n :: 'a :: real_normed_algebra_1) = of_int \m - n\" ``` eberlm@61524 ` 1388` ```proof - ``` eberlm@61524 ` 1389` ``` have "dist (of_int m) (of_int n :: 'a) = dist (of_int m :: 'a) (of_int m - (of_int (m - n)))" ``` eberlm@61524 ` 1390` ``` by simp ``` eberlm@61524 ` 1391` ``` also have "\ = of_int \m - n\" by (subst dist_diff, subst norm_of_int) simp ``` eberlm@61524 ` 1392` ``` finally show ?thesis . ``` eberlm@61524 ` 1393` ```qed ``` eberlm@61524 ` 1394` lp15@61609 ` 1395` ```lemma dist_of_nat: ``` eberlm@61524 ` 1396` ``` "dist (of_nat m) (of_nat n :: 'a :: real_normed_algebra_1) = of_int \int m - int n\" ``` eberlm@61524 ` 1397` ``` by (subst (1 2) of_int_of_nat_eq [symmetric]) (rule dist_of_int) ``` lp15@61609 ` 1398` wenzelm@63545 ` 1399` wenzelm@60758 ` 1400` ```subsection \Bounded Linear and Bilinear Operators\ ``` huffman@22442 ` 1401` huffman@53600 ` 1402` ```locale linear = additive f for f :: "'a::real_vector \ 'b::real_vector" + ``` huffman@22442 ` 1403` ``` assumes scaleR: "f (scaleR r x) = scaleR r (f x)" ``` huffman@53600 ` 1404` lp15@60800 ` 1405` ```lemma linear_imp_scaleR: ``` wenzelm@63545 ` 1406` ``` assumes "linear D" ``` wenzelm@63545 ` 1407` ``` obtains d where "D = (\x. x *\<^sub>R d)" ``` lp15@60800 ` 1408` ``` by (metis assms linear.scaleR mult.commute mult.left_neutral real_scaleR_def) ``` lp15@60800 ` 1409` lp15@62533 ` 1410` ```corollary real_linearD: ``` lp15@62533 ` 1411` ``` fixes f :: "real \ real" ``` lp15@62533 ` 1412` ``` assumes "linear f" obtains c where "f = op* c" ``` wenzelm@63545 ` 1413` ``` by (rule linear_imp_scaleR [OF assms]) (force simp: scaleR_conv_of_real) ``` lp15@62533 ` 1414` lp15@65583 ` 1415` ```lemma linear_times_of_real: "linear (\x. a * of_real x)" ``` lp15@65583 ` 1416` ``` apply (simp add: linear_def Real_Vector_Spaces.additive_def linear_axioms_def) ``` lp15@65583 ` 1417` ``` by (metis distrib_left mult_scaleR_right scaleR_conv_of_real) ``` lp15@65583 ` 1418` huffman@53600 ` 1419` ```lemma linearI: ``` huffman@53600 ` 1420` ``` assumes "\x y. f (x + y) = f x + f y" ``` wenzelm@63545 ` 1421` ``` and "\c x. f (c *\<^sub>R x) = c *\<^sub>R f x" ``` huffman@53600 ` 1422` ``` shows "linear f" ``` wenzelm@61169 ` 1423` ``` by standard (rule assms)+ ``` huffman@53600 ` 1424` huffman@53600 ` 1425` ```locale bounded_linear = linear f for f :: "'a::real_normed_vector \ 'b::real_normed_vector" + ``` huffman@22442 ` 1426` ``` assumes bounded: "\K. \x. norm (f x) \ norm x * K" ``` huffman@27443 ` 1427` ```begin ``` huffman@22442 ` 1428` wenzelm@63545 ` 1429` ```lemma pos_bounded: "\K>0. \x. norm (f x) \ norm x * K" ``` huffman@22442 ` 1430` ```proof - ``` huffman@22442 ` 1431` ``` obtain K where K: "\x. norm (f x) \ norm x * K" ``` lp15@61649 ` 1432` ``` using bounded by blast ``` huffman@22442 ` 1433` ``` show ?thesis ``` huffman@22442 ` 1434` ``` proof (intro exI impI conjI allI) ``` huffman@22442 ` 1435` ``` show "0 < max 1 K" ``` haftmann@54863 ` 1436` ``` by (rule order_less_le_trans [OF zero_less_one max.cobounded1]) ``` huffman@22442 ` 1437` ``` next ``` huffman@22442 ` 1438` ``` fix x ``` huffman@22442 ` 1439` ``` have "norm (f x) \ norm x * K" using K . ``` huffman@22442 ` 1440` ``` also have "\ \ norm x * max 1 K" ``` haftmann@54863 ` 1441` ``` by (rule mult_left_mono [OF max.cobounded2 norm_ge_zero]) ``` huffman@22442 ` 1442` ``` finally show "norm (f x) \ norm x * max 1 K" . ``` huffman@22442 ` 1443` ``` qed ``` huffman@22442 ` 1444` ```qed ``` huffman@22442 ` 1445` wenzelm@63545 ` 1446` ```lemma nonneg_bounded: "\K\0. \x. norm (f x) \ norm x * K" ``` wenzelm@63545 ` 1447` ``` using pos_bounded by (auto intro: order_less_imp_le) ``` huffman@22442 ` 1448` wenzelm@63545 ` 1449` ```lemma linear: "linear f" ``` lp15@63469 ` 1450` ``` by (fact local.linear_axioms) ``` hoelzl@56369 ` 1451` huffman@27443 ` 1452` ```end ``` huffman@27443 ` 1453` huffman@44127 ` 1454` ```lemma bounded_linear_intro: ``` huffman@44127 ` 1455` ``` assumes "\x y. f (x + y) = f x + f y" ``` wenzelm@63545 ` 1456` ``` and "\r x. f (scaleR r x) = scaleR r (f x)" ``` wenzelm@63545 ` 1457` ``` and "\x. norm (f x) \ norm x * K" ``` huffman@44127 ` 1458` ``` shows "bounded_linear f" ``` lp15@61649 ` 1459` ``` by standard (blast intro: assms)+ ``` huffman@44127 ` 1460` huffman@22442 ` 1461` ```locale bounded_bilinear = ``` wenzelm@63545 ` 1462` ``` fixes prod :: "'a::real_normed_vector \ 'b::real_normed_vector \ 'c::real_normed_vector" ``` huffman@22442 ` 1463` ``` (infixl "**" 70) ``` huffman@22442 ` 1464` ``` assumes add_left: "prod (a + a') b = prod a b + prod a' b" ``` wenzelm@63545 ` 1465` ``` and add_right: "prod a (b + b') = prod a b + prod a b'" ``` wenzelm@63545 ` 1466` ``` and scaleR_left: "prod (scaleR r a) b = scaleR r (prod a b)" ``` wenzelm@63545 ` 1467` ``` and scaleR_right: "prod a (scaleR r b) = scaleR r (prod a b)" ``` wenzelm@63545 ` 1468` ``` and bounded: "\K. \a b. norm (prod a b) \ norm a * norm b * K" ``` huffman@27443 ` 1469` ```begin ``` huffman@22442 ` 1470` wenzelm@63545 ` 1471` ```lemma pos_bounded: "\K>0. \a b. norm (a ** b) \ norm a * norm b * K" ``` wenzelm@63545 ` 1472` ``` apply (insert bounded) ``` wenzelm@63545 ` 1473` ``` apply (erule exE) ``` wenzelm@63545 ` 1474` ``` apply (rule_tac x="max 1 K" in exI) ``` wenzelm@63545 ` 1475` ``` apply safe ``` wenzelm@63545 ` 1476` ``` apply (rule order_less_le_trans [OF zero_less_one max.cobounded1]) ``` wenzelm@63545 ` 1477` ``` apply (drule spec) ``` wenzelm@63545 ` 1478` ``` apply (drule spec) ``` wenzelm@63545 ` 1479` ``` apply (erule order_trans) ``` wenzelm@63545 ` 1480` ``` apply (rule mult_left_mono [OF max.cobounded2]) ``` wenzelm@63545 ` 1481` ``` apply (intro mult_nonneg_nonneg norm_ge_zero) ``` wenzelm@63545 ` 1482` ``` done ``` huffman@22442 ` 1483` wenzelm@63545 ` 1484` ```lemma nonneg_bounded: "\K\0. \a b. norm (a ** b) \ norm a * norm b * K" ``` wenzelm@63545 ` 1485` ``` using pos_bounded by (auto intro: order_less_imp_le) ``` huffman@22442 ` 1486` huffman@27443 ` 1487` ```lemma additive_right: "additive (\b. prod a b)" ``` wenzelm@63545 ` 1488` ``` by (rule additive.intro, rule add_right) ``` huffman@22442 ` 1489` huffman@27443 ` 1490` ```lemma additive_left: "additive (\a. prod a b)" ``` wenzelm@63545 ` 1491` ``` by (rule additive.intro, rule add_left) ``` huffman@22442 ` 1492` huffman@27443 ` 1493` ```lemma zero_left: "prod 0 b = 0" ``` wenzelm@63545 ` 1494` ``` by (rule additive.zero [OF additive_left]) ``` huffman@22442 ` 1495` huffman@27443 ` 1496` ```lemma zero_right: "prod a 0 = 0" ``` wenzelm@63545 ` 1497` ``` by (rule additive.zero [OF additive_right]) ``` huffman@22442 ` 1498` huffman@27443 ` 1499` ```lemma minus_left: "prod (- a) b = - prod a b" ``` wenzelm@63545 ` 1500` ``` by (rule additive.minus [OF additive_left]) ``` huffman@22442 ` 1501` huffman@27443 ` 1502` ```lemma minus_right: "prod a (- b) = - prod a b" ``` wenzelm@63545 ` 1503` ``` by (rule additive.minus [OF additive_right]) ``` huffman@22442 ` 1504` wenzelm@63545 ` 1505` ```lemma diff_left: "prod (a - a') b = prod a b - prod a' b" ``` wenzelm@63545 ` 1506` ``` by (rule additive.diff [OF additive_left]) ``` huffman@22442 ` 1507` wenzelm@63545 ` 1508` ```lemma diff_right: "prod a (b - b') = prod a b - prod a b'" ``` wenzelm@63545 ` 1509` ``` by (rule additive.diff [OF additive_right]) ``` huffman@22442 ` 1510` nipkow@64267 ` 1511` ```lemma sum_left: "prod (sum g S) x = sum ((\i. prod (g i) x)) S" ``` nipkow@64267 ` 1512` ``` by (rule additive.sum [OF additive_left]) ``` immler@61915 ` 1513` nipkow@64267 ` 1514` ```lemma sum_right: "prod x (sum g S) = sum ((\i. (prod x (g i)))) S" ``` nipkow@64267 ` 1515` ``` by (rule additive.sum [OF additive_right]) ``` immler@61915 ` 1516` immler@61915 ` 1517` wenzelm@63545 ` 1518` ```lemma bounded_linear_left: "bounded_linear (\a. a ** b)" ``` wenzelm@63545 ` 1519` ``` apply (insert bounded) ``` wenzelm@63545 ` 1520` ``` apply safe ``` wenzelm@63545 ` 1521` ``` apply (rule_tac K="norm b * K" in bounded_linear_intro) ``` wenzelm@63545 ` 1522` ``` apply (rule add_left) ``` wenzelm@63545 ` 1523` ``` apply (rule scaleR_left) ``` wenzelm@63545 ` 1524` ``` apply (simp add: ac_simps) ``` wenzelm@63545 ` 1525` ``` done ``` huffman@22442 ` 1526` wenzelm@63545 ` 1527` ```lemma bounded_linear_right: "bounded_linear (\b. a ** b)" ``` wenzelm@63545 ` 1528` ``` apply (insert bounded) ``` wenzelm@63545 ` 1529` ``` apply safe ``` wenzelm@63545 ` 1530` ``` apply (rule_tac K="norm a * K" in bounded_linear_intro) ``` wenzelm@63545 ` 1531` ``` apply (rule add_right) ``` wenzelm@63545 ` 1532` ``` apply (rule scaleR_right) ``` wenzelm@63545 ` 1533` ``` apply (simp add: ac_simps) ``` wenzelm@63545 ` 1534` ``` done ``` huffman@22442 ` 1535` wenzelm@63545 ` 1536` ```lemma prod_diff_prod: "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)" ``` wenzelm@63545 ` 1537` ``` by (simp add: diff_left diff_right) ``` huffman@22442 ` 1538` immler@61916 ` 1539` ```lemma flip: "bounded_bilinear (\x y. y ** x)" ``` immler@61916 ` 1540` ``` apply standard ``` wenzelm@63545 ` 1541` ``` apply (rule add_right) ``` wenzelm@63545 ` 1542` ``` apply (rule add_left) ``` wenzelm@63545 ` 1543` ``` apply (rule scaleR_right) ``` wenzelm@63545 ` 1544` ``` apply (rule scaleR_left) ``` immler@61916 ` 1545` ``` apply (subst mult.commute) ``` wenzelm@63545 ` 1546` ``` apply (insert bounded) ``` immler@61916 ` 1547` ``` apply blast ``` immler@61916 ` 1548` ``` done ``` immler@61916 ` 1549` immler@61916 ` 1550` ```lemma comp1: ``` immler@61916 ` 1551` ``` assumes "bounded_linear g" ``` immler@61916 ` 1552` ``` shows "bounded_bilinear (\x. op ** (g x))" ``` immler@61916 ` 1553` ```proof unfold_locales ``` immler@61916 ` 1554` ``` interpret g: bounded_linear g by fact ``` immler@61916 ` 1555` ``` show "\a a' b. g (a + a') ** b = g a ** b + g a' ** b" ``` immler@61916 ` 1556` ``` "\a b b'. g a ** (b + b') = g a ** b + g a ** b'" ``` immler@61916 ` 1557` ``` "\r a b. g (r *\<^sub>R a) ** b = r *\<^sub>R (g a ** b)" ``` immler@61916 ` 1558` ``` "\a r b. g a ** (r *\<^sub>R b) = r *\<^sub>R (g a ** b)" ``` immler@61916 ` 1559` ``` by (auto simp: g.add add_left add_right g.scaleR scaleR_left scaleR_right) ``` wenzelm@63545 ` 1560` ``` from g.nonneg_bounded nonneg_bounded obtain K L ``` wenzelm@63545 ` 1561` ``` where nn: "0 \ K" "0 \ L" ``` wenzelm@63545 ` 1562` ``` and K: "\x. norm (g x) \ norm x * K" ``` wenzelm@63545 ` 1563` ``` and L: "\a b. norm (a ** b) \ norm a * norm b * L" ``` immler@61916 ` 1564` ``` by auto ``` immler@61916 ` 1565` ``` have "norm (g a ** b) \ norm a * K * norm b * L" for a b ``` immler@61916 ` 1566` ``` by (auto intro!: order_trans[OF K] order_trans[OF L] mult_mono simp: nn) ``` immler@61916 ` 1567` ``` then show "\K. \a b. norm (g a ** b) \ norm a * norm b * K" ``` immler@61916 ` 1568` ``` by (auto intro!: exI[where x="K * L"] simp: ac_simps) ``` immler@61916 ` 1569` ```qed ``` immler@61916 ` 1570` wenzelm@63545 ` 1571` ```lemma comp: "bounded_linear f \ bounded_linear g \ bounded_bilinear (\x y. f x ** g y)" ``` immler@61916 ` 1572` ``` by (rule bounded_bilinear.flip[OF bounded_bilinear.comp1[OF bounded_bilinear.flip[OF comp1]]]) ``` immler@61916 ` 1573` huffman@27443 ` 1574` ```end ``` huffman@27443 ` 1575` hoelzl@51642 ` 1576` ```lemma bounded_linear_ident[simp]: "bounded_linear (\x. x)" ``` wenzelm@61169 ` 1577` ``` by standard (auto intro!: exI[of _ 1]) ``` hoelzl@51642 ` 1578` hoelzl@51642 ` 1579` ```lemma bounded_linear_zero[simp]: "bounded_linear (\x. 0)" ``` wenzelm@61169 ` 1580` ``` by standard (auto intro!: exI[of _ 1]) ``` hoelzl@51642 ` 1581` hoelzl@51642 ` 1582` ```lemma bounded_linear_add: ``` hoelzl@51642 ` 1583` ``` assumes "bounded_linear f" ``` wenzelm@63545 ` 1584` ``` and "bounded_linear g" ``` hoelzl@51642 ` 1585` ``` shows "bounded_linear (\x. f x + g x)" ``` hoelzl@51642 ` 1586` ```proof - ``` hoelzl@51642 ` 1587` ``` interpret f: bounded_linear f by fact ``` hoelzl@51642 ` 1588` ``` interpret g: bounded_linear g by fact ``` hoelzl@51642 ` 1589` ``` show ?thesis ``` hoelzl@51642 ` 1590` ``` proof ``` wenzelm@63545 ` 1591` ``` from f.bounded obtain Kf where Kf: "norm (f x) \ norm x * Kf" for x ``` wenzelm@63545 ` 1592` ``` by blast ``` wenzelm@63545 ` 1593` ``` from g.bounded obtain Kg where Kg: "norm (g x) \ norm x * Kg" for x ``` wenzelm@63545 ` 1594` ``` by blast ``` hoelzl@51642 ` 1595` ``` show "\K. \x. norm (f x + g x) \ norm x * K" ``` hoelzl@51642 ` 1596` ``` using add_mono[OF Kf Kg] ``` hoelzl@51642 ` 1597` ``` by (intro exI[of _ "Kf + Kg"]) (auto simp: field_simps intro: norm_triangle_ineq order_trans) ``` hoelzl@51642 ` 1598` ``` qed (simp_all add: f.add g.add f.scaleR g.scaleR scaleR_right_distrib) ``` hoelzl@51642 ` 1599` ```qed ``` hoelzl@51642 ` 1600` hoelzl@51642 ` 1601` ```lemma bounded_linear_minus: ``` hoelzl@51642 ` 1602` ``` assumes "bounded_linear f" ``` hoelzl@51642 ` 1603` ``` shows "bounded_linear (\x. - f x)" ``` hoelzl@51642 ` 1604` ```proof - ``` hoelzl@51642 ` 1605` ``` interpret f: bounded_linear f by fact ``` wenzelm@63545 ` 1606` ``` show ?thesis ``` wenzelm@63545 ` 1607` ``` apply unfold_locales ``` wenzelm@63545 ` 1608` ``` apply (simp add: f.add) ``` wenzelm@63545 ` 1609` ``` apply (simp add: f.scaleR) ``` hoelzl@51642 ` 1610` ``` apply (simp add: f.bounded) ``` hoelzl@51642 ` 1611` ``` done ``` hoelzl@51642 ` 1612` ```qed ``` hoelzl@51642 ` 1613` immler@61915 ` 1614` ```lemma bounded_linear_sub: "bounded_linear f \ bounded_linear g \ bounded_linear (\x. f x - g x)" ``` immler@61915 ` 1615` ``` using bounded_linear_add[of f "\x. - g x"] bounded_linear_minus[of g] ``` immler@61915 ` 1616` ``` by (auto simp add: algebra_simps) ``` immler@61915 ` 1617` nipkow@64267 ` 1618` ```lemma bounded_linear_sum: ``` immler@61915 ` 1619` ``` fixes f :: "'i \ 'a::real_normed_vector \ 'b::real_normed_vector" ``` wenzelm@63915 ` 1620` ``` shows "(\i. i \ I \ bounded_linear (f i)) \ bounded_linear (\x. \i\I. f i x)" ``` wenzelm@63915 ` 1621` ``` by (induct I rule: infinite_finite_induct) (auto intro!: bounded_linear_add) ``` immler@61915 ` 1622` hoelzl@51642 ` 1623` ```lemma bounded_linear_compose: ``` hoelzl@51642 ` 1624` ``` assumes "bounded_linear f" ``` wenzelm@63545 ` 1625` ``` and "bounded_linear g" ``` hoelzl@51642 ` 1626` ``` shows "bounded_linear (\x. f (g x))" ``` hoelzl@51642 ` 1627` ```proof - ``` hoelzl@51642 ` 1628` ``` interpret f: bounded_linear f by fact ``` hoelzl@51642 ` 1629` ``` interpret g: bounded_linear g by fact ``` wenzelm@63545 ` 1630` ``` show ?thesis ``` wenzelm@63545 ` 1631` ``` proof unfold_locales ``` wenzelm@63545 ` 1632` ``` show "f (g (x + y)) = f (g x) + f (g y)" for x y ``` hoelzl@51642 ` 1633` ``` by (simp only: f.add g.add) ``` wenzelm@63545 ` 1634` ``` show "f (g (scaleR r x)) = scaleR r (f (g x))" for r x ``` hoelzl@51642 ` 1635` ``` by (simp only: f.scaleR g.scaleR) ``` wenzelm@63545 ` 1636` ``` from f.pos_bounded obtain Kf where f: "\x. norm (f x) \ norm x * Kf" and Kf: "0 < Kf" ``` wenzelm@63545 ` 1637` ``` by blast ``` wenzelm@63545 ` 1638` ``` from g.pos_bounded obtain Kg where g: "\x. norm (g x) \ norm x * Kg" ``` wenzelm@63545 ` 1639` ``` by blast ``` hoelzl@51642 ` 1640` ``` show "\K. \x. norm (f (g x)) \ norm x * K" ``` hoelzl@51642 ` 1641` ``` proof (intro exI allI) ``` hoelzl@51642 ` 1642` ``` fix x ``` hoelzl@51642 ` 1643` ``` have "norm (f (g x)) \ norm (g x) * Kf" ``` hoelzl@51642 ` 1644` ``` using f . ``` hoelzl@51642 ` 1645` ``` also have "\ \ (norm x * Kg) * Kf" ``` hoelzl@51642 ` 1646` ``` using g Kf [THEN order_less_imp_le] by (rule mult_right_mono) ``` hoelzl@51642 ` 1647` ``` also have "(norm x * Kg) * Kf = norm x * (Kg * Kf)" ``` haftmann@57512 ` 1648` ``` by (rule mult.assoc) ``` hoelzl@51642 ` 1649` ``` finally show "norm (f (g x)) \ norm x * (Kg * Kf)" . ``` hoelzl@51642 ` 1650` ``` qed ``` hoelzl@51642 ` 1651` ``` qed ``` hoelzl@51642 ` 1652` ```qed ``` hoelzl@51642 ` 1653` wenzelm@63545 ` 1654` ```lemma bounded_bilinear_mult: "bounded_bilinear (op * :: 'a \ 'a \ 'a::real_normed_algebra)" ``` wenzelm@63545 ` 1655` ``` apply (rule bounded_bilinear.intro) ``` wenzelm@63545 ` 1656` ``` apply (rule distrib_right) ``` wenzelm@63545 ` 1657` ``` apply (rule distrib_left) ``` wenzelm@63545 ` 1658` ``` apply (rule mult_scaleR_left) ``` wenzelm@63545 ` 1659` ``` apply (rule mult_scaleR_right) ``` wenzelm@63545 ` 1660` ``` apply (rule_tac x="1" in exI) ``` wenzelm@63545 ` 1661` ``` apply (simp add: norm_mult_ineq) ``` wenzelm@63545 ` 1662` ``` done ``` huffman@22442 ` 1663` wenzelm@63545 ` 1664` ```lemma bounded_linear_mult_left: "bounded_linear (\x::'a::real_normed_algebra. x * y)" ``` huffman@44282 ` 1665` ``` using bounded_bilinear_mult ``` huffman@44282 ` 1666` ``` by (rule bounded_bilinear.bounded_linear_left) ``` huffman@22442 ` 1667` wenzelm@63545 ` 1668` ```lemma bounded_linear_mult_right: "bounded_linear (\y::'a::real_normed_algebra. x * y)" ``` huffman@44282 ` 1669` ``` using bounded_bilinear_mult ``` huffman@44282 ` 1670` ``` by (rule bounded_bilinear.bounded_linear_right) ``` huffman@23127 ` 1671` hoelzl@51642 ` 1672` ```lemmas bounded_linear_mult_const = ``` hoelzl@51642 ` 1673` ``` bounded_linear_mult_left [THEN bounded_linear_compose] ``` hoelzl@51642 ` 1674` hoelzl@51642 ` 1675` ```lemmas bounded_linear_const_mult = ``` hoelzl@51642 ` 1676` ``` bounded_linear_mult_right [THEN bounded_linear_compose] ``` hoelzl@51642 ` 1677` wenzelm@63545 ` 1678` ```lemma bounded_linear_divide: "bounded_linear (\x. x / y)" ``` wenzelm@63545 ` 1679` ``` for y :: "'a::real_normed_field" ``` huffman@44282 ` 1680` ``` unfolding divide_inverse by (rule bounded_linear_mult_left) ``` huffman@23120 ` 1681` huffman@44282 ` 1682` ```lemma bounded_bilinear_scaleR: "bounded_bilinear scaleR" ``` wenzelm@63545 ` 1683` ``` apply (rule bounded_bilinear.intro) ``` wenzelm@63545 ` 1684` ``` apply (rule scaleR_left_distrib) ``` wenzelm@63545 ` 1685` ``` apply (rule scaleR_right_distrib) ``` wenzelm@63545 ` 1686` ``` apply simp ``` wenzelm@63545 ` 1687` ``` apply (rule scaleR_left_commute) ``` wenzelm@63545 ` 1688` ``` apply (rule_tac x="1" in exI) ``` wenzelm@63545 ` 1689` ``` apply simp ``` wenzelm@63545 ` 1690` ``` done ``` huffman@22442 ` 1691` huffman@44282 ` 1692` ```lemma bounded_linear_scaleR_left: "bounded_linear (\r. scaleR r x)" ``` huffman@44282 ` 1693` ``` using bounded_bilinear_scaleR ``` huffman@44282 ` 1694` ``` by (rule bounded_bilinear.bounded_linear_left) ``` huffman@23127 ` 1695` huffman@44282 ` 1696` ```lemma bounded_linear_scaleR_right: "bounded_linear (\x. scaleR r x)" ``` huffman@44282 ` 1697` ``` using bounded_bilinear_scaleR ``` huffman@44282 ` 1698` ``` by (rule bounded_bilinear.bounded_linear_right) ``` huffman@23127 ` 1699` immler@61915 ` 1700` ```lemmas bounded_linear_scaleR_const = ``` immler@61915 ` 1701` ``` bounded_linear_scaleR_left[THEN bounded_linear_compose] ``` immler@61915 ` 1702` immler@61915 ` 1703` ```lemmas bounded_linear_const_scaleR = ``` immler@61915 ` 1704` ``` bounded_linear_scaleR_right[THEN bounded_linear_compose] ``` immler@61915 ` 1705` huffman@44282 ` 1706` ```lemma bounded_linear_of_real: "bounded_linear (\r. of_real r)" ``` huffman@44282 ` 1707` ``` unfolding of_real_def by (rule bounded_linear_scaleR_left) ``` huffman@22625 ` 1708` wenzelm@63545 ` 1709` ```lemma real_bounded_linear: "bounded_linear f \ (\c::real. f = (\x. x * c))" ``` wenzelm@63545 ` 1710` ``` for f :: "real \ real" ``` hoelzl@51642 ` 1711` ```proof - ``` wenzelm@63545 ` 1712` ``` { ``` wenzelm@63545 ` 1713` ``` fix x ``` wenzelm@63545 ` 1714` ``` assume "bounded_linear f" ``` hoelzl@51642 ` 1715` ``` then interpret bounded_linear f . ``` hoelzl@51642 ` 1716` ``` from scaleR[of x 1] have "f x = x * f 1" ``` wenzelm@63545 ` 1717` ``` by simp ``` wenzelm@63545 ` 1718` ``` } ``` hoelzl@51642 ` 1719` ``` then show ?thesis ``` hoelzl@51642 ` 1720` ``` by (auto intro: exI[of _ "f 1"] bounded_linear_mult_left) ``` hoelzl@51642 ` 1721` ```qed ``` hoelzl@51642 ` 1722` wenzelm@63545 ` 1723` ```lemma bij_linear_imp_inv_linear: "linear f \ bij f \ linear (inv f)" ``` wenzelm@63545 ` 1724` ``` by (auto simp: linear_def linear_axioms_def additive_def bij_is_surj bij_is_inj surj_f_inv_f ``` wenzelm@63545 ` 1725` ``` intro!: Hilbert_Choice.inv_f_eq) ``` lp15@61609 ` 1726` huffman@44571 ` 1727` ```instance real_normed_algebra_1 \ perfect_space ``` huffman@44571 ` 1728` ```proof ``` wenzelm@63545 ` 1729` ``` show "\ open {x}" for x :: 'a ``` wenzelm@63545 ` 1730` ``` apply (simp only: open_dist dist_norm) ``` wenzelm@63545 ` 1731` ``` apply clarsimp ``` wenzelm@63545 ` 1732` ``` apply (rule_tac x = "x + of_real (e/2)" in exI) ``` wenzelm@63545 ` 1733` ``` apply simp ``` wenzelm@63545 ` 1734` ``` done ``` huffman@44571 ` 1735` ```qed ``` huffman@44571 ` 1736` wenzelm@63545 ` 1737` wenzelm@60758 ` 1738` ```subsection \Filters and Limits on Metric Space\ ``` hoelzl@51531 ` 1739` hoelzl@57448 ` 1740` ```lemma (in metric_space) nhds_metric: "nhds x = (INF e:{0 <..}. principal {y. dist y x < e})" ``` hoelzl@57448 ` 1741` ``` unfolding nhds_def ``` hoelzl@57448 ` 1742` ```proof (safe intro!: INF_eq) ``` wenzelm@63545 ` 1743` ``` fix S ``` wenzelm@63545 ` 1744` ``` assume "open S" "x \ S" ``` hoelzl@57448 ` 1745` ``` then obtain e where "{y. dist y x < e} \ S" "0 < e" ``` hoelzl@57448 ` 1746` ``` by (auto simp: open_dist subset_eq) ``` hoelzl@57448 ` 1747` ``` then show "\e\{0<..}. principal {y. dist y x < e} \ principal S" ``` hoelzl@57448 ` 1748` ``` by auto ``` hoelzl@57448 ` 1749` ```qed (auto intro!: exI[of _ "{y. dist x y < e}" for e] open_ball simp: dist_commute) ``` hoelzl@57448 ` 1750` wenzelm@63545 ` 1751` ```lemma (in metric_space) tendsto_iff: "(f \ l) F \ (\e>0. eventually (\x. dist (f x) l < e) F)" ``` hoelzl@57448 ` 1752` ``` unfolding nhds_metric filterlim_INF filterlim_principal by auto ``` hoelzl@57448 ` 1753` wenzelm@63545 ` 1754` ```lemma (in metric_space) tendstoI [intro?]: ``` wenzelm@63545 ` 1755` ``` "(\e. 0 < e \ eventually (\x. dist (f x) l < e) F) \ (f \ l) F" ``` hoelzl@57448 ` 1756` ``` by (auto simp: tendsto_iff) ``` hoelzl@57448 ` 1757` wenzelm@61973 ` 1758` ```lemma (in metric_space) tendstoD: "(f \ l) F \ 0 < e \ eventually (\x. dist (f x) l < e) F" ``` hoelzl@57448 ` 1759` ``` by (auto simp: tendsto_iff) ``` hoelzl@57448 ` 1760` hoelzl@57448 ` 1761` ```lemma (in metric_space) eventually_nhds_metric: ``` hoelzl@57448 ` 1762` ``` "eventually P (nhds a) \ (\d>0. \x. dist x a < d \ P x)" ``` hoelzl@57448 ` 1763` ``` unfolding nhds_metric ``` hoelzl@57448 ` 1764` ``` by (subst eventually_INF_base) ``` hoelzl@57448 ` 1765` ``` (auto simp: eventually_principal Bex_def subset_eq intro: exI[of _ "min a b" for a b]) ``` hoelzl@51531 ` 1766` wenzelm@63545 ` 1767` ```lemma eventually_at: "eventually P (at a within S) \ (\d>0. \x\S. x \ a \ dist x a < d \ P x)" ``` wenzelm@63545 ` 1768` ``` for a :: "'a :: metric_space" ``` wenzelm@63545 ` 1769` ``` by (auto simp: eventually_at_filter eventually_nhds_metric) ``` hoelzl@51531 ` 1770` wenzelm@63545 ` 1771` ```lemma eventually_at_le: "eventually P (at a within S) \ (\d>0. \x\S. x \ a \ dist x a \ d \ P x)" ``` wenzelm@63545 ` 1772` ``` for a :: "'a::metric_space" ``` wenzelm@63545 ` 1773` ``` apply (simp only: eventually_at_filter eventually_nhds_metric) ``` hoelzl@51641 ` 1774` ``` apply auto ``` hoelzl@51641 ` 1775` ``` apply (rule_tac x="d / 2" in exI) ``` hoelzl@51641 ` 1776` ``` apply auto ``` hoelzl@51641 ` 1777` ``` done ``` hoelzl@51531 ` 1778` eberlm@61531 ` 1779` ```lemma eventually_at_left_real: "a > (b :: real) \ eventually (\x. x \ {b<.. eventually (\x. x \ {a<.. a) F" ``` wenzelm@63545 ` 1789` ``` and le: "eventually (\x. dist (g x) b \ dist (f x) a) F" ``` wenzelm@61973 ` 1790` ``` shows "(g \ b) F" ``` hoelzl@51531 ` 1791` ```proof (rule tendstoI) ``` wenzelm@63545 ` 1792` ``` fix e :: real ``` wenzelm@63545 ` 1793` ``` assume "0 < e" ``` hoelzl@51531 ` 1794` ``` with f have "eventually (\x. dist (f x) a < e) F" by (rule tendstoD) ``` hoelzl@51531 ` 1795` ``` with le show "eventually (\x. dist (g x) b < e) F" ``` hoelzl@51531 ` 1796` ``` using le_less_trans by (rule eventually_elim2) ``` hoelzl@51531 ` 1797` ```qed ``` hoelzl@51531 ` 1798` hoelzl@51531 ` 1799` ```lemma filterlim_real_sequentially: "LIM x sequentially. real x :> at_top" ``` wenzelm@63545 ` 1800` ``` apply (simp only: filterlim_at_top) ``` hoelzl@51531 ` 1801` ``` apply (intro allI) ``` wenzelm@61942 ` 1802` ``` apply (rule_tac c="nat \Z + 1\" in eventually_sequentiallyI) ``` wenzelm@61942 ` 1803` ``` apply linarith ``` wenzelm@61942 ` 1804` ``` done ``` wenzelm@61942 ` 1805` immler@63556 ` 1806` ```lemma filterlim_nat_sequentially: "filterlim nat sequentially at_top" ``` immler@63556 ` 1807` ``` unfolding filterlim_at_top ``` immler@63556 ` 1808` ``` apply (rule allI) ``` immler@63556 ` 1809` ``` subgoal for Z by (auto intro!: eventually_at_top_linorderI[where c="int Z"]) ``` immler@63556 ` 1810` ``` done ``` immler@63556 ` 1811` immler@63556 ` 1812` ```lemma filterlim_floor_sequentially: "filterlim floor at_top at_top" ``` immler@63556 ` 1813` ``` unfolding filterlim_at_top ``` immler@63556 ` 1814` ``` apply (rule allI) ``` immler@63556 ` 1815` ``` subgoal for Z by (auto simp: le_floor_iff intro!: eventually_at_top_linorderI[where c="of_int Z"]) ``` immler@63556 ` 1816` ``` done ``` immler@63556 ` 1817` immler@63556 ` 1818` ```lemma filterlim_sequentially_iff_filterlim_real: ``` immler@63556 ` 1819` ``` "filterlim f sequentially F \ filterlim (\x. real (f x)) at_top F" ``` immler@63556 ` 1820` ``` apply (rule iffI) ``` immler@63556 ` 1821` ``` subgoal using filterlim_compose filterlim_real_sequentially by blast ``` immler@63556 ` 1822` ``` subgoal premises prems ``` immler@63556 ` 1823` ``` proof - ``` immler@63556 ` 1824` ``` have "filterlim (\x. nat (floor (real (f x)))) sequentially F" ``` immler@63556 ` 1825` ``` by (intro filterlim_compose[OF filterlim_nat_sequentially] ``` immler@63556 ` 1826` ``` filterlim_compose[OF filterlim_floor_sequentially] prems) ``` immler@63556 ` 1827` ``` then show ?thesis by simp ``` immler@63556 ` 1828` ``` qed ``` immler@63556 ` 1829` ``` done ``` immler@63556 ` 1830` hoelzl@51531 ` 1831` wenzelm@60758 ` 1832` ```subsubsection \Limits of Sequences\ ``` hoelzl@51531 ` 1833` wenzelm@63545 ` 1834` ```lemma lim_sequentially: "X \ L \ (\r>0. \no. \n\no. dist (X n) L < r)" ``` wenzelm@63545 ` 1835` ``` for L :: "'a::metric_space" ``` hoelzl@51531 ` 1836` ``` unfolding tendsto_iff eventually_sequentially .. ``` hoelzl@51531 ` 1837` lp15@60026 ` 1838` ```lemmas LIMSEQ_def = lim_sequentially (*legacy binding*) ``` lp15@60026 ` 1839` wenzelm@63545 ` 1840` ```lemma LIMSEQ_iff_nz: "X \ L \ (\r>0. \no>0. \n\no. dist (X n) L < r)" ``` wenzelm@63545 ` 1841` ``` for L :: "'a::metric_space" ``` lp15@60017 ` 1842` ``` unfolding lim_sequentially by (metis Suc_leD zero_less_Suc) ``` hoelzl@51531 ` 1843` wenzelm@63545 ` 1844` ```lemma metric_LIMSEQ_I: "(\r. 0 < r \ \no. \n\no. dist (X n) L < r) \ X \ L" ``` wenzelm@63545 ` 1845` ``` for L :: "'a::metric_space" ``` wenzelm@63545 ` 1846` ``` by (simp add: lim_sequentially) ``` hoelzl@51531 ` 1847` wenzelm@63545 ` 1848` ```lemma metric_LIMSEQ_D: "X \ L \ 0 < r \ \no. \n\no. dist (X n) L < r" ``` wenzelm@63545 ` 1849` ``` for L :: "'a::metric_space" ``` wenzelm@63545 ` 1850` ``` by (simp add: lim_sequentially) ``` hoelzl@51531 ` 1851` hoelzl@51531 ` 1852` wenzelm@60758 ` 1853` ```subsubsection \Limits of Functions\ ``` hoelzl@51531 ` 1854` wenzelm@63545 ` 1855` ```lemma LIM_def: "f \a\ L \ (\r > 0. \s > 0. \x. x \ a \ dist x a < s \ dist (f x) L < r)" ``` wenzelm@63545 ` 1856` ``` for a :: "'a::metric_space" and L :: "'b::metric_space" ``` hoelzl@51641 ` 1857` ``` unfolding tendsto_iff eventually_at by simp ``` hoelzl@51531 ` 1858` hoelzl@51531 ` 1859` ```lemma metric_LIM_I: ``` wenzelm@63545 ` 1860` ``` "(\r. 0 < r \ \s>0. \x. x \ a \ dist x a < s \ dist (f x) L < r) \ f \a\ L" ``` wenzelm@63545 ` 1861` ``` for a :: "'a::metric_space" and L :: "'b::metric_space" ``` wenzelm@63545 ` 1862` ``` by (simp add: LIM_def) ``` hoelzl@51531 ` 1863` wenzelm@63545 ` 1864` ```lemma metric_LIM_D: "f \a\ L \ 0 < r \ \s>0. \x. x \ a \ dist x a < s \ dist (f x) L < r" ``` wenzelm@63545 ` 1865` ``` for a :: "'a::metric_space" and L :: "'b::metric_space" ``` wenzelm@63545 ` 1866` ``` by (simp add: LIM_def) ``` hoelzl@51531 ` 1867` hoelzl@51531 ` 1868` ```lemma metric_LIM_imp_LIM: ``` wenzelm@63545 ` 1869` ``` fixes l :: "'a::metric_space" ``` wenzelm@63545 ` 1870` ``` and m :: "'b::metric_space" ``` wenzelm@63545 ` 1871` ``` assumes f: "f \a\ l" ``` wenzelm@63545 ` 1872` ``` and le: "\x. x \ a \ dist (g x) m \ dist (f x) l" ``` wenzelm@63545 ` 1873` ``` shows "g \a\ m" ``` hoelzl@51531 ` 1874` ``` by (rule metric_tendsto_imp_tendsto [OF f]) (auto simp add: eventually_at_topological le) ``` hoelzl@51531 ` 1875` hoelzl@51531 ` 1876` ```lemma metric_LIM_equal2: ``` wenzelm@63545 ` 1877` ``` fixes a :: "'a::metric_space" ``` wenzelm@63545 ` 1878` ``` assumes "0 < R" ``` wenzelm@63545 ` 1879` ``` and "\x. x \ a \ dist x a < R \ f x = g x" ``` wenzelm@63545 ` 1880` ``` shows "g \a\ l \ f \a\ l" ``` wenzelm@63545 ` 1881` ``` apply (rule topological_tendstoI) ``` wenzelm@63545 ` 1882` ``` apply (drule (2) topological_tendstoD) ``` wenzelm@63545 ` 1883` ``` apply (simp add: eventually_at) ``` wenzelm@63545 ` 1884` ``` apply safe ``` wenzelm@63545 ` 1885` ``` apply (rule_tac x="min d R" in exI) ``` wenzelm@63545 ` 1886` ``` apply safe ``` wenzelm@63545 ` 1887` ``` apply (simp add: assms(1)) ``` wenzelm@63545 ` 1888` ``` apply (simp add: assms(2)) ``` wenzelm@63545 ` 1889` ``` done ``` hoelzl@51531 ` 1890` hoelzl@51531 ` 1891` ```lemma metric_LIM_compose2: ``` wenzelm@63545 ` 1892` ``` fixes a :: "'a::metric_space" ``` wenzelm@63545 ` 1893` ``` assumes f: "f \a\ b" ``` wenzelm@63545 ` 1894` ``` and g: "g \b\ c" ``` wenzelm@63545 ` 1895` ``` and inj: "\d>0. \x. x \ a \ dist x a < d \ f x \ b" ``` wenzelm@61976 ` 1896` ``` shows "(\x. g (f x)) \a\ c" ``` wenzelm@63545 ` 1897` ``` using inj by (intro tendsto_compose_eventually[OF g f]) (auto simp: eventually_at) ``` hoelzl@51531 ` 1898` hoelzl@51531 ` 1899` ```lemma metric_isCont_LIM_compose2: ``` hoelzl@51531 ` 1900` ``` fixes f :: "'a :: metric_space \ _" ``` hoelzl@51531 ` 1901` ``` assumes f [unfolded isCont_def]: "isCont f a" ``` wenzelm@63545 ` 1902` ``` and g: "g \f a\ l" ``` wenzelm@63545 ` 1903` ``` and inj: "\d>0. \x. x \ a \ dist x a < d \ f x \ f a" ``` wenzelm@61976 ` 1904` ``` shows "(\x. g (f x)) \a\ l" ``` wenzelm@63545 ` 1905` ``` by (rule metric_LIM_compose2 [OF f g inj]) ``` wenzelm@63545 ` 1906` hoelzl@51531 ` 1907` wenzelm@60758 ` 1908` ```subsection \Complete metric spaces\ ``` hoelzl@51531 ` 1909` wenzelm@60758 ` 1910` ```subsection \Cauchy sequences\ ``` hoelzl@51531 ` 1911` hoelzl@62101 ` 1912` ```lemma (in metric_space) Cauchy_def: "Cauchy X = (\e>0. \M. \m\M. \n\M. dist (X m) (X n) < e)" ``` hoelzl@62101 ` 1913` ```proof - ``` wenzelm@63545 ` 1914` ``` have *: "eventually P (INF M. principal {(X m, X n) | n m. m \ M \ n \ M}) \ ``` hoelzl@62101 ` 1915` ``` (\M. \m\M. \n\M. P (X m, X n))" for P ``` wenzelm@63545 ` 1916` ``` apply (subst eventually_INF_base) ``` wenzelm@63545 ` 1917` ``` subgoal by simp ``` wenzelm@63545 ` 1918` ``` subgoal for a b ``` hoelzl@62101 ` 1919` ``` by (intro bexI[of _ "max a b"]) (auto simp: eventually_principal subset_eq) ``` wenzelm@63545 ` 1920` ``` subgoal by (auto simp: eventually_principal, blast) ``` wenzelm@63545 ` 1921` ``` done ``` hoelzl@62101 ` 1922` ``` have "Cauchy X \ (INF M. principal {(X m, X n) | n m. m \ M \ n \ M}) \ uniformity" ``` hoelzl@62101 ` 1923` ``` unfolding Cauchy_uniform_iff le_filter_def * .. ``` hoelzl@62101 ` 1924` ``` also have "\ = (\e>0. \M. \m\M. \n\M. dist (X m) (X n) < e)" ``` hoelzl@62101 ` 1925` ``` unfolding uniformity_dist le_INF_iff by (auto simp: * le_principal) ``` hoelzl@62101 ` 1926` ``` finally show ?thesis . ``` hoelzl@62101 ` 1927` ```qed ``` hoelzl@51531 ` 1928` wenzelm@63545 ` 1929` ```lemma (in metric_space) Cauchy_altdef: "Cauchy f \ (\e>0. \M. \m\M. \n>m. dist (f m) (f n) < e)" ``` wenzelm@63545 ` 1930` ``` (is "?lhs \ ?rhs") ``` eberlm@61531 ` 1931` ```proof ``` wenzelm@63545 ` 1932` ``` assume ?rhs ``` wenzelm@63545 ` 1933` ``` show ?lhs ``` wenzelm@63545 ` 1934` ``` unfolding Cauchy_def ``` eberlm@61531 ` 1935` ``` proof (intro allI impI) ``` eberlm@61531 ` 1936` ``` fix e :: real assume e: "e > 0" ``` wenzelm@63545 ` 1937` ``` with \?rhs\ obtain M where M: "m \ M \ n > m \ dist (f m) (f n) < e" for m n ``` wenzelm@63545 ` 1938` ``` by blast ``` eberlm@61531 ` 1939` ``` have "dist (f m) (f n) < e" if "m \ M" "n \ M" for m n ``` eberlm@61531 ` 1940` ``` using M[of m n] M[of n m] e that by (cases m n rule: linorder_cases) (auto simp: dist_commute) ``` wenzelm@63545 ` 1941` ``` then show "\M. \m\M. \n\M. dist (f m) (f n) < e" ``` wenzelm@63545 ` 1942` ``` by blast ``` eberlm@61531 ` 1943` ``` qed ``` eberlm@61531 ` 1944` ```next ``` wenzelm@63545 ` 1945` ``` assume ?lhs ``` wenzelm@63545 ` 1946` ``` show ?rhs ``` eberlm@61531 ` 1947` ``` proof (intro allI impI) ``` wenzelm@63545 ` 1948` ``` fix e :: real ``` wenzelm@63545 ` 1949` ``` assume e: "e > 0" ``` wenzelm@61799 ` 1950` ``` with \Cauchy f\ obtain M where "\m n. m \ M \ n \ M \ dist (f m) (f n) < e" ``` lp15@61649 ` 1951` ``` unfolding Cauchy_def by blast ``` wenzelm@63545 ` 1952` ``` then show "\M. \m\M. \n>m. dist (f m) (f n) < e" ``` wenzelm@63545 ` 1953` ``` by (intro exI[of _ M]) force ``` eberlm@61531 ` 1954` ``` qed ``` eberlm@61531 ` 1955` ```qed ``` hoelzl@51531 ` 1956` lp15@66089 ` 1957` ```lemma (in metric_space) Cauchy_altdef2: "Cauchy s \ (\e>0. \N::nat. \n\N. dist(s n)(s N) < e)" (is "?lhs = ?rhs") ``` lp15@66089 ` 1958` ```proof ``` lp15@66089 ` 1959` ``` assume "Cauchy s" ``` lp15@66089 ` 1960` ``` then show ?rhs by (force simp add: Cauchy_def) ``` lp15@66089 ` 1961` ```next ``` lp15@66089 ` 1962` ``` assume ?rhs ``` lp15@66089 ` 1963` ``` { ``` lp15@66089 ` 1964` ``` fix e::real ``` lp15@66089 ` 1965` ``` assume "e>0" ``` lp15@66089 ` 1966` ``` with \?rhs\ obtain N where N: "\n\N. dist (s n) (s N) < e/2" ``` lp15@66089 ` 1967` ``` by (erule_tac x="e/2" in allE) auto ``` lp15@66089 ` 1968` ``` { ``` lp15@66089 ` 1969` ``` fix n m ``` lp15@66089 ` 1970` ``` assume nm: "N \ m \ N \ n" ``` lp15@66089 ` 1971` ``` then have "dist (s m) (s n) < e" using N ``` lp15@66089 ` 1972` ``` using dist_triangle_half_l[of "s m" "s N" "e" "s n"] ``` lp15@66089 ` 1973` ``` by blast ``` lp15@66089 ` 1974` ``` } ``` lp15@66089 ` 1975` ``` then have "\N. \m n. N \ m \ N \ n \ dist (s m) (s n) < e" ``` lp15@66089 ` 1976` ``` by blast ``` lp15@66089 ` 1977` ``` } ``` lp15@66089 ` 1978` ``` then have ?lhs ``` lp15@66089 ` 1979` ``` unfolding Cauchy_def by blast ``` lp15@66089 ` 1980` ``` then show ?lhs ``` lp15@66089 ` 1981` ``` by blast ``` lp15@66089 ` 1982` ```qed ``` lp15@66089 ` 1983` hoelzl@62101 ` 1984` ```lemma (in metric_space) metric_CauchyI: ``` hoelzl@51531 ` 1985` ``` "(\e. 0 < e \ \M. \m\M. \n\M. dist (X m) (X n) < e) \ Cauchy X" ``` hoelzl@51531 ` 1986` ``` by (simp add: Cauchy_def) ``` hoelzl@51531 ` 1987` wenzelm@63545 ` 1988` ```lemma (in metric_space) CauchyI': ``` wenzelm@63545 ` 1989` ``` "(\e. 0 < e \ \M. \m\M. \n>m. dist (X m) (X n) < e) \ Cauchy X" ``` eberlm@61531 ` 1990` ``` unfolding Cauchy_altdef by blast ``` eberlm@61531 ` 1991` hoelzl@62101 ` 1992` ```lemma (in metric_space) metric_CauchyD: ``` hoelzl@51531 ` 1993` ``` "Cauchy X \ 0 < e \ \M. \m\M. \n\M. dist (X m) (X n) < e" ``` hoelzl@51531 ` 1994` ``` by (simp add: Cauchy_def) ``` hoelzl@51531 ` 1995` hoelzl@62101 ` 1996` ```lemma (in metric_space) metric_Cauchy_iff2: ``` hoelzl@51531 ` 1997` ``` "Cauchy X = (\j. (\M. \m \ M. \n \ M. dist (X m) (X n) < inverse(real (Suc j))))" ``` wenzelm@63545 ` 1998` ``` apply (simp add: Cauchy_def) ``` wenzelm@63545 ` 1999` ``` apply auto ``` wenzelm@63545 ` 2000` ``` apply (drule reals_Archimedean) ``` wenzelm@63545 ` 2001` ``` apply safe ``` wenzelm@63545 ` 2002` ``` apply (drule_tac x = n in spec) ``` wenzelm@63545 ` 2003` ``` apply auto ``` wenzelm@63545 ` 2004` ``` apply (rule_tac x = M in exI) ``` wenzelm@63545 ` 2005` ``` apply auto ``` wenzelm@63545 ` 2006` ``` apply (drule_tac x = m in spec) ``` wenzelm@63545 ` 2007` ``` apply simp ``` wenzelm@63545 ` 2008` ``` apply (drule_tac x = na in spec) ``` wenzelm@63545 ` 2009` ``` apply auto ``` wenzelm@63545 ` 2010` ``` done ``` hoelzl@51531 ` 2011` wenzelm@63545 ` 2012` ```lemma Cauchy_iff2: "Cauchy X \ (\j. (\M. \m \ M. \n \ M. \X m - X n\ < inverse (real (Suc j))))" ``` wenzelm@63545 ` 2013` ``` by (simp only: metric_Cauchy_iff2 dist_real_def) ``` hoelzl@51531 ` 2014` hoelzl@62101 ` 2015` ```lemma lim_1_over_n: "((\n. 1 / of_nat n) \ (0::'a::real_normed_field)) sequentially" ``` hoelzl@62101 ` 2016` ```proof (subst lim_sequentially, intro allI impI exI) ``` wenzelm@63545 ` 2017` ``` fix e :: real ``` wenzelm@63545 ` 2018` ``` assume e: "e > 0" ``` wenzelm@63545 ` 2019` ``` fix n :: nat ``` wenzelm@63545 ` 2020` ``` assume n: "n \ nat \inverse e + 1\" ``` hoelzl@62101 ` 2021` ``` have "inverse e < of_nat (nat \inverse e + 1\)" by linarith ``` hoelzl@62101 ` 2022` ``` also note n ``` wenzelm@63545 ` 2023` ``` finally show "dist (1 / of_nat n :: 'a) 0 < e" ``` wenzelm@63545 ` 2024` ``` using e by (simp add: divide_simps mult.commute norm_divide) ``` hoelzl@51531 ` 2025` ```qed ``` hoelzl@51531 ` 2026` hoelzl@62101 ` 2027` ```lemma (in metric_space) complete_def: ``` hoelzl@62101 ` 2028` ``` shows "complete S = (\f. (\n. f n \ S) \ Cauchy f \ (\l\S. f \ l))" ``` hoelzl@62101 ` 2029` ``` unfolding complete_uniform ``` hoelzl@62101 ` 2030` ```proof safe ``` wenzelm@63545 ` 2031` ``` fix f :: "nat \ 'a" ``` wenzelm@63545 ` 2032` ``` assume f: "\n. f n \ S" "Cauchy f" ``` hoelzl@62101 ` 2033` ``` and *: "\F\principal S. F \ bot \ cauchy_filter F \ (\x\S. F \ nhds x)" ``` hoelzl@62101 ` 2034` ``` then show "\l\S. f \ l" ``` hoelzl@62101 ` 2035` ``` unfolding filterlim_def using f ``` hoelzl@62101 ` 2036` ``` by (intro *[rule_format]) ``` hoelzl@62101 ` 2037` ``` (auto simp: filtermap_sequentually_ne_bot le_principal eventually_filtermap Cauchy_uniform) ``` hoelzl@62101 ` 2038` ```next ``` wenzelm@63545 ` 2039` ``` fix F :: "'a filter" ``` wenzelm@63545 ` 2040` ``` assume "F \ principal S" "F \ bot" "cauchy_filter F" ``` hoelzl@62101 ` 2041` ``` assume seq: "\f. (\n. f n \ S) \ Cauchy f \ (\l\S. f \ l)" ``` hoelzl@62101 ` 2042` wenzelm@63545 ` 2043` ``` from \F \ principal S\ \cauchy_filter F\ ``` wenzelm@63545 ` 2044` ``` have FF_le: "F \\<^sub>F F \ uniformity_on S" ``` hoelzl@62101 ` 2045` ``` by (simp add: cauchy_filter_def principal_prod_principal[symmetric] prod_filter_mono) ``` hoelzl@62101 ` 2046` hoelzl@62101 ` 2047` ``` let ?P = "\P e. eventually P F \ (\x. P x \ x \ S) \ (\x y. P x \ P y \ dist x y < e)" ``` wenzelm@63545 ` 2048` ``` have P: "\P. ?P P \" if "0 < \" for \ :: real ``` wenzelm@63545 ` 2049` ``` proof - ``` wenzelm@63545 ` 2050` ``` from that have "eventually (\(x, y). x \ S \ y \ S \ dist x y < \) (uniformity_on S)" ``` wenzelm@63545 ` 2051` ``` by (auto simp: eventually_inf_principal eventually_uniformity_metric) ``` wenzelm@63545 ` 2052` ``` from filter_leD[OF FF_le this] show ?thesis ``` wenzelm@63545 ` 2053` ``` by (auto simp: eventually_prod_same) ``` wenzelm@63545 ` 2054` ``` qed ``` hoelzl@62101 ` 2055` hoelzl@62101 ` 2056` ``` have "\P. \n. ?P (P n) (1 / Suc n) \ P (Suc n) \ P n" ``` hoelzl@62101 ` 2057` ``` proof (rule dependent_nat_choice) ``` hoelzl@62101 ` 2058` ``` show "\P. ?P P (1 / Suc 0)" ``` hoelzl@62101 ` 2059` ``` using P[of 1] by auto ``` hoelzl@62101 ` 2060` ``` next ``` hoelzl@62101 ` 2061` ``` fix P n assume "?P P (1/Suc n)" ``` hoelzl@62101 ` 2062` ``` moreover obtain Q where "?P Q (1 / Suc (Suc n))" ``` hoelzl@62101 ` 2063` ``` using P[of "1/Suc (Suc n)"] by auto ``` hoelzl@62101 ` 2064` ``` ultimately show "\Q. ?P Q (1 / Suc (Suc n)) \ Q \ P" ``` hoelzl@62101 ` 2065` ``` by (intro exI[of _ "\x. P x \ Q x"]) (auto simp: eventually_conj_iff) ``` hoelzl@62101 ` 2066` ``` qed ``` wenzelm@63545 ` 2067` ``` then obtain P where P: "eventually (P n) F" "P n x \ x \ S" ``` wenzelm@63545 ` 2068` ``` "P n x \ P n y \ dist x y < 1 / Suc n" "P (Suc n) \ P n" ``` wenzelm@63545 ` 2069` ``` for n x y ``` hoelzl@62101 ` 2070` ``` by metis ``` hoelzl@62101 ` 2071` ``` have "antimono P" ``` hoelzl@62101 ` 2072` ``` using P(4) unfolding decseq_Suc_iff le_fun_def by blast ``` hoelzl@62101 ` 2073` wenzelm@63545 ` 2074` ``` obtain X where X: "P n (X n)" for n ``` hoelzl@62101 ` 2075` ``` using P(1)[THEN eventually_happens'[OF \F \ bot\]] by metis ``` hoelzl@62101 ` 2076` ``` have "Cauchy X" ``` hoelzl@62101 ` 2077` ``` unfolding metric_Cauchy_iff2 inverse_eq_divide ``` hoelzl@62101 ` 2078` ``` proof (intro exI allI impI) ``` wenzelm@63545 ` 2079` ``` fix j m n :: nat ``` wenzelm@63545 ` 2080` ``` assume "j \ m" "j \ n" ``` hoelzl@62101 ` 2081` ``` with \antimono P\ X have "P j (X m)" "P j (X n)" ``` hoelzl@62101 ` 2082` ``` by (auto simp: antimono_def) ``` hoelzl@62101 ` 2083` ``` then show "dist (X m) (X n) < 1 / Suc j" ``` hoelzl@62101 ` 2084` ``` by (rule P) ``` hoelzl@62101 ` 2085` ``` qed ``` hoelzl@62101 ` 2086` ``` moreover have "\n. X n \ S" ``` hoelzl@62101 ` 2087` ``` using P(2) X by auto ``` hoelzl@62101 ` 2088` ``` ultimately obtain x where "X \ x" "x \ S" ``` hoelzl@62101 ` 2089` ``` using seq by blast ``` hoelzl@62101 ` 2090` hoelzl@62101 ` 2091` ``` show "\x\S. F \ nhds x" ``` hoelzl@62101 ` 2092` ``` proof (rule bexI) ``` wenzelm@63545 ` 2093` ``` have "eventually (\y. dist y x < e) F" if "0 < e" for e :: real ``` wenzelm@63545 ` 2094` ``` proof - ``` wenzelm@63545 ` 2095` ``` from that have "(\n. 1 / Suc n :: real) \ 0 \ 0 < e / 2" ``` hoelzl@62101 ` 2096` ``` by (subst LIMSEQ_Suc_iff) (auto intro!: lim_1_over_n) ``` hoelzl@62101 ` 2097` ``` then have "\\<^sub>F n in sequentially. dist (X n) x < e / 2 \ 1 / Suc n < e / 2" ``` wenzelm@63545 ` 2098` ``` using \X \ x\ ``` wenzelm@63545 ` 2099` ``` unfolding tendsto_iff order_tendsto_iff[where 'a=real] eventually_conj_iff ``` wenzelm@63545 ` 2100` ``` by blast ``` hoelzl@62101 ` 2101` ``` then obtain n where "dist x (X n) < e / 2" "1 / Suc n < e / 2" ``` hoelzl@62101 ` 2102` ``` by (auto simp: eventually_sequentially dist_commute) ``` wenzelm@63545 ` 2103` ``` show ?thesis ``` hoelzl@62101 ` 2104` ``` using \eventually (P n) F\ ``` hoelzl@62101 ` 2105` ``` proof eventually_elim ``` wenzelm@63545 ` 2106` ``` case (elim y) ``` hoelzl@62101 ` 2107` ``` then have "dist y (X n) < 1 / Suc n" ``` hoelzl@62101 ` 2108` ``` by (intro X P) ``` hoelzl@62101 ` 2109` ``` also have "\ < e / 2" by fact ``` hoelzl@62101 ` 2110` ``` finally show "dist y x < e" ``` hoelzl@62101 ` 2111` ``` by (rule dist_triangle_half_l) fact ``` wenzelm@63545 ` 2112` ``` qed ``` wenzelm@63545 ` 2113` ``` qed ``` hoelzl@62101 ` 2114` ``` then show "F \ nhds x" ``` hoelzl@62101 ` 2115` ``` unfolding nhds_metric le_INF_iff le_principal by auto ``` hoelzl@62101 ` 2116` ``` qed fact ``` hoelzl@62101 ` 2117` ```qed ``` hoelzl@62101 ` 2118` hoelzl@62101 ` 2119` ```lemma (in metric_space) totally_bounded_metric: ``` hoelzl@62101 ` 2120` ``` "totally_bounded S \ (\e>0. \k. finite k \ S \ (\x\k. {y. dist x y < e}))" ``` wenzelm@63545 ` 2121` ``` apply (simp only: totally_bounded_def eventually_uniformity_metric imp_ex) ``` hoelzl@62101 ` 2122` ``` apply (subst all_comm) ``` hoelzl@62101 ` 2123` ``` apply (intro arg_cong[where f=All] ext) ``` hoelzl@62101 ` 2124` ``` apply safe ``` hoelzl@62101 ` 2125` ``` subgoal for e ``` hoelzl@62101 ` 2126` ``` apply (erule allE[of _ "\(x, y). dist x y < e"]) ``` hoelzl@62101 ` 2127` ``` apply auto ``` hoelzl@62101 ` 2128` ``` done ``` hoelzl@62101 ` 2129` ``` subgoal for e P k ``` hoelzl@62101 ` 2130` ``` apply (intro exI[of _ k]) ``` hoelzl@62101 ` 2131` ``` apply (force simp: subset_eq) ``` hoelzl@62101 ` 2132` ``` done ``` hoelzl@62101 ` 2133` ``` done ``` hoelzl@51531 ` 2134` wenzelm@63545 ` 2135` wenzelm@60758 ` 2136` ```subsubsection \Cauchy Sequences are Convergent\ ``` hoelzl@51531 ` 2137` hoelzl@62101 ` 2138` ```(* TODO: update to uniform_space *) ``` hoelzl@51531 ` 2139` ```class complete_space = metric_space + ``` hoelzl@51531 ` 2140` ``` assumes Cauchy_convergent: "Cauchy X \ convergent X" ``` hoelzl@51531 ` 2141` wenzelm@63545 ` 2142` ```lemma Cauchy_convergent_iff: "Cauchy X \ convergent X" ``` wenzelm@63545 ` 2143` ``` for X :: "nat \ 'a::complete_space" ``` wenzelm@63545 ` 2144` ``` by (blast intro: Cauchy_convergent convergent_Cauchy) ``` wenzelm@63545 ` 2145` hoelzl@51531 ` 2146` wenzelm@60758 ` 2147` ```subsection \The set of real numbers is a complete metric space\ ``` hoelzl@51531 ` 2148` wenzelm@60758 ` 2149` ```text \ ``` wenzelm@63545 ` 2150` ``` Proof that Cauchy sequences converge based on the one from ``` wenzelm@63680 ` 2151` ``` \<^url>\http://pirate.shu.edu/~wachsmut/ira/numseq/proofs/cauconv.html\ ``` wenzelm@60758 ` 2152` ```\ ``` hoelzl@51531 ` 2153` wenzelm@60758 ` 2154` ```text \ ``` hoelzl@51531 ` 2155` ``` If sequence @{term "X"} is Cauchy, then its limit is the lub of ``` hoelzl@51531 ` 2156` ``` @{term "{r::real. \N. \n\N. r < X n}"} ``` wenzelm@60758 ` 2157` ```\ ``` hoelzl@51531 ` 2158` ```lemma increasing_LIMSEQ: ``` hoelzl@51531 ` 2159` ``` fixes f :: "nat \ real" ``` hoelzl@51531 ` 2160` ``` assumes inc: "\n. f n \ f (Suc n)" ``` wenzelm@63545 ` 2161` ``` and bdd: "\n. f n \ l" ``` wenzelm@63545 ` 2162` ``` and en: "\e. 0 < e \ \n. l \ f n + e" ``` wenzelm@61969 ` 2163` ``` shows "f \ l" ``` hoelzl@51531 ` 2164` ```proof (rule increasing_tendsto) ``` wenzelm@63545 ` 2165` ``` fix x ``` wenzelm@63545 ` 2166` ``` assume "x < l" ``` hoelzl@51531 ` 2167` ``` with dense[of 0 "l - x"] obtain e where "0 < e" "e < l - x" ``` hoelzl@51531 ` 2168` ``` by auto ``` wenzelm@60758 ` 2169` ``` from en[OF \0 < e\] obtain n where "l - e \ f n" ``` hoelzl@51531 ` 2170` ``` by (auto simp: field_simps) ``` wenzelm@63545 ` 2171` ``` with \e < l - x\ \0 < e\ have "x < f n" ``` wenzelm@63545 ` 2172` ``` by simp ``` hoelzl@51531 ` 2173` ``` with incseq_SucI[of f, OF inc] show "eventually (\n. x < f n) sequentially" ``` hoelzl@51531 ` 2174` ``` by (auto simp: eventually_sequentially incseq_def intro: less_le_trans) ``` wenzelm@63545 ` 2175` ```qed (use bdd in auto) ``` hoelzl@51531 ` 2176` hoelzl@51531 ` 2177` ```lemma real_Cauchy_convergent: ``` hoelzl@51531 ` 2178` ``` fixes X :: "nat \ real" ``` hoelzl@51531 ` 2179` ``` assumes X: "Cauchy X" ``` hoelzl@51531 ` 2180` ``` shows "convergent X" ``` hoelzl@51531 ` 2181` ```proof - ``` wenzelm@63040 ` 2182` ``` define S :: "real set" where "S = {x. \N. \n\N. x < X n}" ``` wenzelm@63545 ` 2183` ``` then have mem_S: "\N x. \n\N. x < X n \ x \ S" ``` wenzelm@63545 ` 2184` ``` by auto ``` hoelzl@51531 ` 2185` wenzelm@63545 ` 2186` ``` have bound_isUb: "y \ x" if N: "\n\N. X n < x" and "y \ S" for N and x y :: real ``` wenzelm@63545 ` 2187` ``` proof - ``` wenzelm@63545 ` 2188` ``` from that have "\M. \n\M. y < X n" ``` wenzelm@63545 ` 2189` ``` by (simp add: S_def) ``` wenzelm@63545 ` 2190` ``` then obtain M where "\n\M. y < X n" .. ``` wenzelm@63545 ` 2191` ``` then have "y < X (max M N)" by simp ``` wenzelm@63545 ` 2192` ``` also have "\ < x" using N by simp ``` wenzelm@63545 ` 2193` ``` finally show ?thesis by (rule order_less_imp_le) ``` wenzelm@63545 ` 2194` ``` qed ``` hoelzl@51531 ` 2195` hoelzl@51531 ` 2196` ``` obtain N where "\m\N. \n\N. dist (X m) (X n) < 1" ``` hoelzl@51531 ` 2197` ``` using X[THEN metric_CauchyD, OF zero_less_one] by auto ``` wenzelm@63545 ` 2198` ``` then have N: "\n\N. dist (X n) (X N) < 1" by simp ``` hoelzl@54263 ` 2199` ``` have [simp]: "S \ {}" ``` hoelzl@54263 ` 2200` ``` proof (intro exI ex_in_conv[THEN iffD1]) ``` hoelzl@51531 ` 2201` ``` from N have "\n\N. X N - 1 < X n" ``` hoelzl@51531 ` 2202` ``` by (simp add: abs_diff_less_iff dist_real_def) ``` wenzelm@63545 ` 2203` ``` then show "X N - 1 \ S" by (rule mem_S) ``` hoelzl@51531 ` 2204` ``` qed ``` hoelzl@54263 ` 2205` ``` have [simp]: "bdd_above S" ``` hoelzl@51531 ` 2206` ``` proof ``` hoelzl@51531 ` 2207` ``` from N have "\n\N. X n < X N + 1" ``` hoelzl@51531 ` 2208` ``` by (simp add: abs_diff_less_iff dist_real_def) ``` wenzelm@63545 ` 2209` ``` then show "\s. s \ S \ s \ X N + 1" ``` hoelzl@51531 ` 2210` ``` by (rule bound_isUb) ``` hoelzl@51531 ` 2211` ``` qed ``` wenzelm@61969 ` 2212` ``` have "X \ Sup S" ``` hoelzl@51531 ` 2213` ``` proof (rule metric_LIMSEQ_I) ``` wenzelm@63545 ` 2214` ``` fix r :: real ``` wenzelm@63545 ` 2215` ``` assume "0 < r" ``` wenzelm@63545 ` 2216` ``` then have r: "0 < r/2" by simp ``` wenzelm@63545 ` 2217` ``` obtain N where "\n\N. \m\N. dist (X n) (X m) < r/2" ``` wenzelm@63545 ` 2218` ``` using metric_CauchyD [OF X r] by auto ``` wenzelm@63545 ` 2219` ``` then have "\n\N. dist (X n) (X N) < r/2" by simp ``` wenzelm@63545 ` 2220` ``` then have N: "\n\N. X N - r/2 < X n \ X n < X N + r/2" ``` wenzelm@63545 ` 2221` ``` by (simp only: dist_real_def abs_diff_less_iff) ``` hoelzl@51531 ` 2222` wenzelm@63545 ` 2223` ``` from N have "\n\N. X N - r/2 < X n" by blast ``` wenzelm@63545 ` 2224` ``` then have "X N - r/2 \ S" by (rule mem_S) ``` wenzelm@63545 ` 2225` ``` then have 1: "X N - r/2 \ Sup S" by (simp add: cSup_upper) ``` hoelzl@51531 ` 2226` wenzelm@63545 ` 2227` ``` from N have "\n\N. X n < X N + r/2" by blast ``` wenzelm@63545 ` 2228` ``` from bound_isUb[OF this] ``` wenzelm@63545 ` 2229` ``` have 2: "Sup S \ X N + r/2" ``` wenzelm@63545 ` 2230` ``` by (intro cSup_least) simp_all ``` hoelzl@51531 ` 2231` wenzelm@63545 ` 2232` ``` show "\N. \n\N. dist (X n) (Sup S) < r" ``` wenzelm@63545 ` 2233` ``` proof (intro exI allI impI) ``` wenzelm@63545 ` 2234` ``` fix n ``` wenzelm@63545 ` 2235` ``` assume n: "N \ n" ``` wenzelm@63545 ` 2236` ``` from N n have "X n < X N + r/2" and "X N - r/2 < X n" ``` wenzelm@63545 ` 2237` ``` by simp_all ``` wenzelm@63545 ` 2238` ``` then show "dist (X n) (Sup S) < r" using 1 2 ``` wenzelm@63545 ` 2239` ``` by (simp add: abs_diff_less_iff dist_real_def) ``` wenzelm@63545 ` 2240` ``` qed ``` hoelzl@51531 ` 2241` ``` qed ``` wenzelm@63545 ` 2242` ``` then show ?thesis by (auto simp: convergent_def) ``` hoelzl@51531 ` 2243` ```qed ``` hoelzl@51531 ` 2244` hoelzl@51531 ` 2245` ```instance real :: complete_space ``` hoelzl@51531 ` 2246` ``` by intro_classes (rule real_Cauchy_convergent) ``` hoelzl@51531 ` 2247` hoelzl@51531 ` 2248` ```class banach = real_normed_vector + complete_space ``` hoelzl@51531 ` 2249` wenzelm@61169 ` 2250` ```instance real :: banach .. ``` hoelzl@51531 ` 2251` hoelzl@51531 ` 2252` ```lemma tendsto_at_topI_sequentially: ``` hoelzl@57275 ` 2253` ``` fixes f :: "real \ 'b::first_countable_topology" ``` wenzelm@61969 ` 2254` ``` assumes *: "\X. filterlim X at_top sequentially \ (\n. f (X n)) \ y" ``` wenzelm@61973 ` 2255` ``` shows "(f \ y) at_top" ``` hoelzl@57448 ` 2256` ```proof - ``` wenzelm@63545 ` 2257` ``` obtain A where A: "decseq A" "open (A n)" "y \ A n" "nhds y = (INF n. principal (A n))" for n ``` wenzelm@63545 ` 2258` ``` by (rule nhds_countable[of y]) (rule that) ``` hoelzl@57275 ` 2259` hoelzl@57448 ` 2260` ``` have "\m. \k. \x\k. f x \ A m" ``` hoelzl@57448 ` 2261` ``` proof (rule ccontr) ``` hoelzl@57448 ` 2262` ``` assume "\ (\m. \k. \x\k. f x \ A m)" ``` hoelzl@57448 ` 2263` ``` then obtain m where "\k. \x\k. f x \ A m" ``` hoelzl@57448 ` 2264` ``` by auto ``` hoelzl@57448 ` 2265` ``` then have "\X. \n. (f (X n) \ A m) \ max n (X n) + 1 \ X (Suc n)" ``` hoelzl@57448 ` 2266` ``` by (intro dependent_nat_choice) (auto simp del: max.bounded_iff) ``` hoelzl@57448 ` 2267` ``` then obtain X where X: "\n. f (X n) \ A m" "\n. max n (X n) + 1 \ X (Suc n)" ``` hoelzl@57448 ` 2268` ``` by auto ``` wenzelm@63545 ` 2269` ``` have "1 \ n \ real n \ X n" for n ``` wenzelm@63545 ` 2270` ``` using X[of "n - 1"] by auto ``` hoelzl@57448 ` 2271` ``` then have "filterlim X at_top sequentially" ``` hoelzl@57448 ` 2272` ``` by (force intro!: filterlim_at_top_mono[OF filterlim_real_sequentially] ``` wenzelm@63545 ` 2273` ``` simp: eventually_sequentially) ``` hoelzl@57448 ` 2274` ``` from topological_tendstoD[OF *[OF this] A(2, 3), of m] X(1) show False ``` hoelzl@57448 ` 2275` ``` by auto ``` hoelzl@57275 ` 2276` ``` qed ``` wenzelm@63545 ` 2277` ``` then obtain k where "k m \ x \ f x \ A m" for m x ``` hoelzl@57448 ` 2278` ``` by metis ``` hoelzl@57448 ` 2279` ``` then show ?thesis ``` wenzelm@63545 ` 2280` ``` unfolding at_top_def A by (intro filterlim_base[where i=k]) auto ``` hoelzl@57275 ` 2281` ```qed ``` hoelzl@57275 ` 2282` hoelzl@57275 ` 2283` ```lemma tendsto_at_topI_sequentially_real: ``` hoelzl@51531 ` 2284` ``` fixes f :: "real \ real" ``` hoelzl@51531 ` 2285` ``` assumes mono: "mono f" ``` wenzelm@63545 ` 2286` ``` and limseq: "(\n. f (real n)) \ y" ``` wenzelm@61973 ` 2287` ``` shows "(f \ y) at_top" ``` hoelzl@51531 ` 2288` ```proof (rule tendstoI) ``` wenzelm@63545 ` 2289` ``` fix e :: real ``` wenzelm@63545 ` 2290` ``` assume "0 < e" ``` wenzelm@63545 ` 2291` ``` with limseq obtain N :: nat where N: "N \ n \ \f (real n) - y\ < e" for n ``` lp15@60017 ` 2292` ``` by (auto simp: lim_sequentially dist_real_def) ``` wenzelm@63545 ` 2293` ``` have le: "f x \ y" for x :: real ``` wenzelm@63545 ` 2294` ``` proof - ``` wenzelm@53381 ` 2295` ``` obtain n where "x \ real_of_nat n" ``` lp15@62623 ` 2296` ``` using real_arch_simple[of x] .. ``` hoelzl@51531 ` 2297` ``` note monoD[OF mono this] ``` hoelzl@51531 ` 2298` ``` also have "f (real_of_nat n) \ y" ``` lp15@61649 ` 2299` ``` by (rule LIMSEQ_le_const[OF limseq]) (auto intro!: exI[of _ n] monoD[OF mono]) ``` wenzelm@63545 ` 2300` ``` finally show ?thesis . ``` wenzelm@63545 ` 2301` ``` qed ``` hoelzl@51531 ` 2302` ``` have "eventually (\x. real N \ x) at_top" ``` hoelzl@51531 ` 2303` ``` by (rule eventually_ge_at_top) ``` hoelzl@51531 ` 2304` ``` then show "eventually (\x. dist (f x) y < e) at_top" ``` hoelzl@51531 ` 2305` ``` proof eventually_elim ``` wenzelm@63545 ` 2306` ``` case (elim x) ``` hoelzl@51531 ` 2307` ``` with N[of N] le have "y - f (real N) < e" by auto ``` wenzelm@63545 ` 2308` ``` moreover note monoD[OF mono elim] ``` hoelzl@51531 ` 2309` ``` ultimately show "dist (f x) y < e" ``` hoelzl@51531 ` 2310` ``` using le[of x] by (auto simp: dist_real_def field_simps) ``` hoelzl@51531 ` 2311` ``` qed ``` hoelzl@51531 ` 2312` ```qed ``` hoelzl@51531 ` 2313` huffman@20504 ` 2314` ```end ```