src/HOL/Real_Vector_Spaces.thy
 author wenzelm Tue Sep 01 22:32:58 2015 +0200 (2015-09-01) changeset 61076 bdc1e2f0a86a parent 61070 b72a990adfe2 child 61169 4de9ff3ea29a permissions -rw-r--r--
eliminated \<Colon>;
 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` huffman@27443 ` 36` ```lemma setsum: "f (setsum g A) = (\x\A. f (g x))" ``` huffman@22942 ` 37` ```apply (cases "finite A") ``` huffman@22942 ` 38` ```apply (induct set: finite) ``` huffman@22942 ` 39` ```apply (simp add: zero) ``` huffman@22942 ` 40` ```apply (simp add: add) ``` huffman@22942 ` 41` ```apply (simp add: zero) ``` huffman@22942 ` 42` ```done ``` huffman@22942 ` 43` huffman@27443 ` 44` ```end ``` huffman@20504 ` 45` wenzelm@60758 ` 46` ```subsection \Vector spaces\ ``` huffman@28029 ` 47` huffman@28029 ` 48` ```locale vector_space = ``` huffman@28029 ` 49` ``` fixes scale :: "'a::field \ 'b::ab_group_add \ 'b" ``` huffman@30070 ` 50` ``` assumes scale_right_distrib [algebra_simps]: ``` huffman@30070 ` 51` ``` "scale a (x + y) = scale a x + scale a y" ``` huffman@30070 ` 52` ``` and scale_left_distrib [algebra_simps]: ``` huffman@30070 ` 53` ``` "scale (a + b) x = scale a x + scale b x" ``` huffman@28029 ` 54` ``` and scale_scale [simp]: "scale a (scale b x) = scale (a * b) x" ``` huffman@28029 ` 55` ``` and scale_one [simp]: "scale 1 x = x" ``` huffman@28029 ` 56` ```begin ``` huffman@28029 ` 57` huffman@28029 ` 58` ```lemma scale_left_commute: ``` huffman@28029 ` 59` ``` "scale a (scale b x) = scale b (scale a x)" ``` haftmann@57512 ` 60` ```by (simp add: mult.commute) ``` huffman@28029 ` 61` huffman@28029 ` 62` ```lemma scale_zero_left [simp]: "scale 0 x = 0" ``` huffman@28029 ` 63` ``` and scale_minus_left [simp]: "scale (- a) x = - (scale a x)" ``` huffman@30070 ` 64` ``` and scale_left_diff_distrib [algebra_simps]: ``` huffman@30070 ` 65` ``` "scale (a - b) x = scale a x - scale b x" ``` huffman@44282 ` 66` ``` and scale_setsum_left: "scale (setsum f A) x = (\a\A. scale (f a) x)" ``` huffman@28029 ` 67` ```proof - ``` ballarin@29229 ` 68` ``` interpret s: additive "\a. scale a x" ``` haftmann@28823 ` 69` ``` proof qed (rule scale_left_distrib) ``` huffman@28029 ` 70` ``` show "scale 0 x = 0" by (rule s.zero) ``` huffman@28029 ` 71` ``` show "scale (- a) x = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 72` ``` show "scale (a - b) x = scale a x - scale b x" by (rule s.diff) ``` huffman@44282 ` 73` ``` show "scale (setsum f A) x = (\a\A. scale (f a) x)" by (rule s.setsum) ``` huffman@28029 ` 74` ```qed ``` huffman@28029 ` 75` huffman@28029 ` 76` ```lemma scale_zero_right [simp]: "scale a 0 = 0" ``` huffman@28029 ` 77` ``` and scale_minus_right [simp]: "scale a (- x) = - (scale a x)" ``` huffman@30070 ` 78` ``` and scale_right_diff_distrib [algebra_simps]: ``` huffman@30070 ` 79` ``` "scale a (x - y) = scale a x - scale a y" ``` huffman@44282 ` 80` ``` and scale_setsum_right: "scale a (setsum f A) = (\x\A. scale a (f x))" ``` huffman@28029 ` 81` ```proof - ``` ballarin@29229 ` 82` ``` interpret s: additive "\x. scale a x" ``` haftmann@28823 ` 83` ``` proof qed (rule scale_right_distrib) ``` huffman@28029 ` 84` ``` show "scale a 0 = 0" by (rule s.zero) ``` huffman@28029 ` 85` ``` show "scale a (- x) = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 86` ``` show "scale a (x - y) = scale a x - scale a y" by (rule s.diff) ``` huffman@44282 ` 87` ``` show "scale a (setsum f A) = (\x\A. scale a (f x))" by (rule s.setsum) ``` huffman@28029 ` 88` ```qed ``` huffman@28029 ` 89` huffman@28029 ` 90` ```lemma scale_eq_0_iff [simp]: ``` huffman@28029 ` 91` ``` "scale a x = 0 \ a = 0 \ x = 0" ``` huffman@28029 ` 92` ```proof cases ``` huffman@28029 ` 93` ``` assume "a = 0" thus ?thesis by simp ``` huffman@28029 ` 94` ```next ``` huffman@28029 ` 95` ``` assume anz [simp]: "a \ 0" ``` huffman@28029 ` 96` ``` { assume "scale a x = 0" ``` huffman@28029 ` 97` ``` hence "scale (inverse a) (scale a x) = 0" by simp ``` huffman@28029 ` 98` ``` hence "x = 0" by simp } ``` huffman@28029 ` 99` ``` thus ?thesis by force ``` huffman@28029 ` 100` ```qed ``` huffman@28029 ` 101` huffman@28029 ` 102` ```lemma scale_left_imp_eq: ``` huffman@28029 ` 103` ``` "\a \ 0; scale a x = scale a y\ \ x = y" ``` huffman@28029 ` 104` ```proof - ``` huffman@28029 ` 105` ``` assume nonzero: "a \ 0" ``` huffman@28029 ` 106` ``` assume "scale a x = scale a y" ``` huffman@28029 ` 107` ``` hence "scale a (x - y) = 0" ``` huffman@28029 ` 108` ``` by (simp add: scale_right_diff_distrib) ``` huffman@28029 ` 109` ``` hence "x - y = 0" by (simp add: nonzero) ``` huffman@28029 ` 110` ``` thus "x = y" by (simp only: right_minus_eq) ``` huffman@28029 ` 111` ```qed ``` huffman@28029 ` 112` huffman@28029 ` 113` ```lemma scale_right_imp_eq: ``` huffman@28029 ` 114` ``` "\x \ 0; scale a x = scale b x\ \ a = b" ``` huffman@28029 ` 115` ```proof - ``` huffman@28029 ` 116` ``` assume nonzero: "x \ 0" ``` huffman@28029 ` 117` ``` assume "scale a x = scale b x" ``` huffman@28029 ` 118` ``` hence "scale (a - b) x = 0" ``` huffman@28029 ` 119` ``` by (simp add: scale_left_diff_distrib) ``` huffman@28029 ` 120` ``` hence "a - b = 0" by (simp add: nonzero) ``` huffman@28029 ` 121` ``` thus "a = b" by (simp only: right_minus_eq) ``` huffman@28029 ` 122` ```qed ``` huffman@28029 ` 123` huffman@31586 ` 124` ```lemma scale_cancel_left [simp]: ``` huffman@28029 ` 125` ``` "scale a x = scale a y \ x = y \ a = 0" ``` huffman@28029 ` 126` ```by (auto intro: scale_left_imp_eq) ``` huffman@28029 ` 127` huffman@31586 ` 128` ```lemma scale_cancel_right [simp]: ``` huffman@28029 ` 129` ``` "scale a x = scale b x \ a = b \ x = 0" ``` huffman@28029 ` 130` ```by (auto intro: scale_right_imp_eq) ``` huffman@28029 ` 131` huffman@28029 ` 132` ```end ``` huffman@28029 ` 133` wenzelm@60758 ` 134` ```subsection \Real vector spaces\ ``` huffman@20504 ` 135` haftmann@29608 ` 136` ```class scaleR = ``` haftmann@25062 ` 137` ``` fixes scaleR :: "real \ 'a \ 'a" (infixr "*\<^sub>R" 75) ``` haftmann@24748 ` 138` ```begin ``` huffman@20504 ` 139` huffman@20763 ` 140` ```abbreviation ``` haftmann@25062 ` 141` ``` divideR :: "'a \ real \ 'a" (infixl "'/\<^sub>R" 70) ``` haftmann@24748 ` 142` ```where ``` haftmann@25062 ` 143` ``` "x /\<^sub>R r == scaleR (inverse r) x" ``` haftmann@24748 ` 144` haftmann@24748 ` 145` ```end ``` haftmann@24748 ` 146` haftmann@24588 ` 147` ```class real_vector = scaleR + ab_group_add + ``` huffman@44282 ` 148` ``` assumes scaleR_add_right: "scaleR a (x + y) = scaleR a x + scaleR a y" ``` huffman@44282 ` 149` ``` and scaleR_add_left: "scaleR (a + b) x = scaleR a x + scaleR b x" ``` huffman@30070 ` 150` ``` and scaleR_scaleR: "scaleR a (scaleR b x) = scaleR (a * b) x" ``` huffman@30070 ` 151` ``` and scaleR_one: "scaleR 1 x = x" ``` huffman@20504 ` 152` wenzelm@30729 ` 153` ```interpretation real_vector: ``` ballarin@29229 ` 154` ``` vector_space "scaleR :: real \ 'a \ 'a::real_vector" ``` huffman@28009 ` 155` ```apply unfold_locales ``` huffman@44282 ` 156` ```apply (rule scaleR_add_right) ``` huffman@44282 ` 157` ```apply (rule scaleR_add_left) ``` huffman@28009 ` 158` ```apply (rule scaleR_scaleR) ``` huffman@28009 ` 159` ```apply (rule scaleR_one) ``` huffman@28009 ` 160` ```done ``` huffman@28009 ` 161` wenzelm@60758 ` 162` ```text \Recover original theorem names\ ``` huffman@28009 ` 163` huffman@28009 ` 164` ```lemmas scaleR_left_commute = real_vector.scale_left_commute ``` huffman@28009 ` 165` ```lemmas scaleR_zero_left = real_vector.scale_zero_left ``` huffman@28009 ` 166` ```lemmas scaleR_minus_left = real_vector.scale_minus_left ``` huffman@44282 ` 167` ```lemmas scaleR_diff_left = real_vector.scale_left_diff_distrib ``` huffman@44282 ` 168` ```lemmas scaleR_setsum_left = real_vector.scale_setsum_left ``` huffman@28009 ` 169` ```lemmas scaleR_zero_right = real_vector.scale_zero_right ``` huffman@28009 ` 170` ```lemmas scaleR_minus_right = real_vector.scale_minus_right ``` huffman@44282 ` 171` ```lemmas scaleR_diff_right = real_vector.scale_right_diff_distrib ``` huffman@44282 ` 172` ```lemmas scaleR_setsum_right = real_vector.scale_setsum_right ``` huffman@28009 ` 173` ```lemmas scaleR_eq_0_iff = real_vector.scale_eq_0_iff ``` huffman@28009 ` 174` ```lemmas scaleR_left_imp_eq = real_vector.scale_left_imp_eq ``` huffman@28009 ` 175` ```lemmas scaleR_right_imp_eq = real_vector.scale_right_imp_eq ``` huffman@28009 ` 176` ```lemmas scaleR_cancel_left = real_vector.scale_cancel_left ``` huffman@28009 ` 177` ```lemmas scaleR_cancel_right = real_vector.scale_cancel_right ``` huffman@28009 ` 178` wenzelm@60758 ` 179` ```text \Legacy names\ ``` huffman@44282 ` 180` huffman@44282 ` 181` ```lemmas scaleR_left_distrib = scaleR_add_left ``` huffman@44282 ` 182` ```lemmas scaleR_right_distrib = scaleR_add_right ``` huffman@44282 ` 183` ```lemmas scaleR_left_diff_distrib = scaleR_diff_left ``` huffman@44282 ` 184` ```lemmas scaleR_right_diff_distrib = scaleR_diff_right ``` huffman@44282 ` 185` huffman@31285 ` 186` ```lemma scaleR_minus1_left [simp]: ``` huffman@31285 ` 187` ``` fixes x :: "'a::real_vector" ``` huffman@31285 ` 188` ``` shows "scaleR (-1) x = - x" ``` huffman@31285 ` 189` ``` using scaleR_minus_left [of 1 x] by simp ``` huffman@31285 ` 190` haftmann@24588 ` 191` ```class real_algebra = real_vector + ring + ``` haftmann@25062 ` 192` ``` assumes mult_scaleR_left [simp]: "scaleR a x * y = scaleR a (x * y)" ``` haftmann@25062 ` 193` ``` and mult_scaleR_right [simp]: "x * scaleR a y = scaleR a (x * y)" ``` huffman@20504 ` 194` haftmann@24588 ` 195` ```class real_algebra_1 = real_algebra + ring_1 ``` huffman@20554 ` 196` haftmann@24588 ` 197` ```class real_div_algebra = real_algebra_1 + division_ring ``` huffman@20584 ` 198` haftmann@24588 ` 199` ```class real_field = real_div_algebra + field ``` huffman@20584 ` 200` huffman@30069 ` 201` ```instantiation real :: real_field ``` huffman@30069 ` 202` ```begin ``` huffman@30069 ` 203` huffman@30069 ` 204` ```definition ``` huffman@30069 ` 205` ``` real_scaleR_def [simp]: "scaleR a x = a * x" ``` huffman@30069 ` 206` huffman@30070 ` 207` ```instance proof ``` huffman@30070 ` 208` ```qed (simp_all add: algebra_simps) ``` huffman@20554 ` 209` huffman@30069 ` 210` ```end ``` huffman@30069 ` 211` wenzelm@30729 ` 212` ```interpretation scaleR_left: additive "(\a. scaleR a x::'a::real_vector)" ``` haftmann@28823 ` 213` ```proof qed (rule scaleR_left_distrib) ``` huffman@20504 ` 214` wenzelm@30729 ` 215` ```interpretation scaleR_right: additive "(\x. scaleR a x::'a::real_vector)" ``` haftmann@28823 ` 216` ```proof qed (rule scaleR_right_distrib) ``` huffman@20504 ` 217` huffman@20584 ` 218` ```lemma nonzero_inverse_scaleR_distrib: ``` huffman@21809 ` 219` ``` fixes x :: "'a::real_div_algebra" shows ``` huffman@21809 ` 220` ``` "\a \ 0; x \ 0\ \ inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` huffman@20763 ` 221` ```by (rule inverse_unique, simp) ``` huffman@20584 ` 222` huffman@20584 ` 223` ```lemma inverse_scaleR_distrib: ``` haftmann@59867 ` 224` ``` fixes x :: "'a::{real_div_algebra, division_ring}" ``` huffman@21809 ` 225` ``` shows "inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` huffman@20584 ` 226` ```apply (case_tac "a = 0", simp) ``` huffman@20584 ` 227` ```apply (case_tac "x = 0", simp) ``` huffman@20584 ` 228` ```apply (erule (1) nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 229` ```done ``` huffman@20584 ` 230` lp15@60800 ` 231` ```lemma real_vector_affinity_eq: ``` lp15@60800 ` 232` ``` fixes x :: "'a :: real_vector" ``` lp15@60800 ` 233` ``` assumes m0: "m \ 0" ``` lp15@60800 ` 234` ``` shows "m *\<^sub>R x + c = y \ x = inverse m *\<^sub>R y - (inverse m *\<^sub>R c)" ``` lp15@60800 ` 235` ```proof ``` lp15@60800 ` 236` ``` assume h: "m *\<^sub>R x + c = y" ``` lp15@60800 ` 237` ``` hence "m *\<^sub>R x = y - c" by (simp add: field_simps) ``` lp15@60800 ` 238` ``` hence "inverse m *\<^sub>R (m *\<^sub>R x) = inverse m *\<^sub>R (y - c)" by simp ``` lp15@60800 ` 239` ``` then show "x = inverse m *\<^sub>R y - (inverse m *\<^sub>R c)" ``` lp15@60800 ` 240` ``` using m0 ``` lp15@60800 ` 241` ``` by (simp add: real_vector.scale_right_diff_distrib) ``` lp15@60800 ` 242` ```next ``` lp15@60800 ` 243` ``` assume h: "x = inverse m *\<^sub>R y - (inverse m *\<^sub>R c)" ``` lp15@60800 ` 244` ``` show "m *\<^sub>R x + c = y" unfolding h ``` lp15@60800 ` 245` ``` using m0 by (simp add: real_vector.scale_right_diff_distrib) ``` lp15@60800 ` 246` ```qed ``` lp15@60800 ` 247` lp15@60800 ` 248` ```lemma real_vector_eq_affinity: ``` lp15@60800 ` 249` ``` fixes x :: "'a :: real_vector" ``` lp15@60800 ` 250` ``` shows "m \ 0 ==> (y = m *\<^sub>R x + c \ inverse m *\<^sub>R y - (inverse m *\<^sub>R c) = x)" ``` lp15@60800 ` 251` ``` using real_vector_affinity_eq[where m=m and x=x and y=y and c=c] ``` lp15@60800 ` 252` ``` by metis ``` lp15@60800 ` 253` huffman@20554 ` 254` wenzelm@60758 ` 255` ```subsection \Embedding of the Reals into any @{text real_algebra_1}: ``` wenzelm@60758 ` 256` ```@{term of_real}\ ``` huffman@20554 ` 257` huffman@20554 ` 258` ```definition ``` wenzelm@21404 ` 259` ``` of_real :: "real \ 'a::real_algebra_1" where ``` huffman@21809 ` 260` ``` "of_real r = scaleR r 1" ``` huffman@20554 ` 261` huffman@21809 ` 262` ```lemma scaleR_conv_of_real: "scaleR r x = of_real r * x" ``` huffman@20763 ` 263` ```by (simp add: of_real_def) ``` huffman@20763 ` 264` huffman@20554 ` 265` ```lemma of_real_0 [simp]: "of_real 0 = 0" ``` huffman@20554 ` 266` ```by (simp add: of_real_def) ``` huffman@20554 ` 267` huffman@20554 ` 268` ```lemma of_real_1 [simp]: "of_real 1 = 1" ``` huffman@20554 ` 269` ```by (simp add: of_real_def) ``` huffman@20554 ` 270` huffman@20554 ` 271` ```lemma of_real_add [simp]: "of_real (x + y) = of_real x + of_real y" ``` huffman@20554 ` 272` ```by (simp add: of_real_def scaleR_left_distrib) ``` huffman@20554 ` 273` huffman@20554 ` 274` ```lemma of_real_minus [simp]: "of_real (- x) = - of_real x" ``` huffman@20554 ` 275` ```by (simp add: of_real_def) ``` huffman@20554 ` 276` huffman@20554 ` 277` ```lemma of_real_diff [simp]: "of_real (x - y) = of_real x - of_real y" ``` huffman@20554 ` 278` ```by (simp add: of_real_def scaleR_left_diff_distrib) ``` huffman@20554 ` 279` huffman@20554 ` 280` ```lemma of_real_mult [simp]: "of_real (x * y) = of_real x * of_real y" ``` haftmann@57512 ` 281` ```by (simp add: of_real_def mult.commute) ``` huffman@20554 ` 282` hoelzl@56889 ` 283` ```lemma of_real_setsum[simp]: "of_real (setsum f s) = (\x\s. of_real (f x))" ``` hoelzl@56889 ` 284` ``` by (induct s rule: infinite_finite_induct) auto ``` hoelzl@56889 ` 285` hoelzl@56889 ` 286` ```lemma of_real_setprod[simp]: "of_real (setprod f s) = (\x\s. of_real (f x))" ``` hoelzl@56889 ` 287` ``` by (induct s rule: infinite_finite_induct) auto ``` hoelzl@56889 ` 288` huffman@20584 ` 289` ```lemma nonzero_of_real_inverse: ``` huffman@20584 ` 290` ``` "x \ 0 \ of_real (inverse x) = ``` huffman@20584 ` 291` ``` inverse (of_real x :: 'a::real_div_algebra)" ``` huffman@20584 ` 292` ```by (simp add: of_real_def nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 293` huffman@20584 ` 294` ```lemma of_real_inverse [simp]: ``` huffman@20584 ` 295` ``` "of_real (inverse x) = ``` haftmann@59867 ` 296` ``` inverse (of_real x :: 'a::{real_div_algebra, division_ring})" ``` huffman@20584 ` 297` ```by (simp add: of_real_def inverse_scaleR_distrib) ``` huffman@20584 ` 298` huffman@20584 ` 299` ```lemma nonzero_of_real_divide: ``` huffman@20584 ` 300` ``` "y \ 0 \ of_real (x / y) = ``` huffman@20584 ` 301` ``` (of_real x / of_real y :: 'a::real_field)" ``` huffman@20584 ` 302` ```by (simp add: divide_inverse nonzero_of_real_inverse) ``` huffman@20722 ` 303` huffman@20722 ` 304` ```lemma of_real_divide [simp]: ``` huffman@20584 ` 305` ``` "of_real (x / y) = ``` haftmann@59867 ` 306` ``` (of_real x / of_real y :: 'a::{real_field, field})" ``` huffman@20584 ` 307` ```by (simp add: divide_inverse) ``` huffman@20584 ` 308` huffman@20722 ` 309` ```lemma of_real_power [simp]: ``` haftmann@31017 ` 310` ``` "of_real (x ^ n) = (of_real x :: 'a::{real_algebra_1}) ^ n" ``` huffman@30273 ` 311` ```by (induct n) simp_all ``` huffman@20722 ` 312` huffman@20554 ` 313` ```lemma of_real_eq_iff [simp]: "(of_real x = of_real y) = (x = y)" ``` huffman@35216 ` 314` ```by (simp add: of_real_def) ``` huffman@20554 ` 315` haftmann@38621 ` 316` ```lemma inj_of_real: ``` haftmann@38621 ` 317` ``` "inj of_real" ``` haftmann@38621 ` 318` ``` by (auto intro: injI) ``` haftmann@38621 ` 319` huffman@20584 ` 320` ```lemmas of_real_eq_0_iff [simp] = of_real_eq_iff [of _ 0, simplified] ``` huffman@20554 ` 321` huffman@20554 ` 322` ```lemma of_real_eq_id [simp]: "of_real = (id :: real \ real)" ``` huffman@20554 ` 323` ```proof ``` huffman@20554 ` 324` ``` fix r ``` huffman@20554 ` 325` ``` show "of_real r = id r" ``` huffman@22973 ` 326` ``` by (simp add: of_real_def) ``` huffman@20554 ` 327` ```qed ``` huffman@20554 ` 328` wenzelm@60758 ` 329` ```text\Collapse nested embeddings\ ``` huffman@20554 ` 330` ```lemma of_real_of_nat_eq [simp]: "of_real (of_nat n) = of_nat n" ``` wenzelm@20772 ` 331` ```by (induct n) auto ``` huffman@20554 ` 332` huffman@20554 ` 333` ```lemma of_real_of_int_eq [simp]: "of_real (of_int z) = of_int z" ``` huffman@20554 ` 334` ```by (cases z rule: int_diff_cases, simp) ``` huffman@20554 ` 335` hoelzl@56889 ` 336` ```lemma of_real_real_of_nat_eq [simp]: "of_real (real n) = of_nat n" ``` hoelzl@56889 ` 337` ``` by (simp add: real_of_nat_def) ``` hoelzl@56889 ` 338` hoelzl@56889 ` 339` ```lemma of_real_real_of_int_eq [simp]: "of_real (real z) = of_int z" ``` hoelzl@56889 ` 340` ``` by (simp add: real_of_int_def) ``` hoelzl@56889 ` 341` lp15@60155 ` 342` ```lemma of_real_numeral [simp]: "of_real (numeral w) = numeral w" ``` huffman@47108 ` 343` ```using of_real_of_int_eq [of "numeral w"] by simp ``` huffman@47108 ` 344` lp15@60155 ` 345` ```lemma of_real_neg_numeral [simp]: "of_real (- numeral w) = - numeral w" ``` haftmann@54489 ` 346` ```using of_real_of_int_eq [of "- numeral w"] by simp ``` huffman@20554 ` 347` wenzelm@60758 ` 348` ```text\Every real algebra has characteristic zero\ ``` haftmann@38621 ` 349` huffman@22912 ` 350` ```instance real_algebra_1 < ring_char_0 ``` huffman@22912 ` 351` ```proof ``` haftmann@38621 ` 352` ``` from inj_of_real inj_of_nat have "inj (of_real \ of_nat)" by (rule inj_comp) ``` haftmann@38621 ` 353` ``` then show "inj (of_nat :: nat \ 'a)" by (simp add: comp_def) ``` huffman@22912 ` 354` ```qed ``` huffman@22912 ` 355` huffman@27553 ` 356` ```instance real_field < field_char_0 .. ``` huffman@27553 ` 357` huffman@20554 ` 358` wenzelm@60758 ` 359` ```subsection \The Set of Real Numbers\ ``` huffman@20554 ` 360` wenzelm@61070 ` 361` ```definition Reals :: "'a::real_algebra_1 set" ("\") ``` wenzelm@61070 ` 362` ``` where "\ = range of_real" ``` huffman@20554 ` 363` wenzelm@61070 ` 364` ```lemma Reals_of_real [simp]: "of_real r \ \" ``` huffman@20554 ` 365` ```by (simp add: Reals_def) ``` huffman@20554 ` 366` wenzelm@61070 ` 367` ```lemma Reals_of_int [simp]: "of_int z \ \" ``` huffman@21809 ` 368` ```by (subst of_real_of_int_eq [symmetric], rule Reals_of_real) ``` huffman@20718 ` 369` wenzelm@61070 ` 370` ```lemma Reals_of_nat [simp]: "of_nat n \ \" ``` huffman@21809 ` 371` ```by (subst of_real_of_nat_eq [symmetric], rule Reals_of_real) ``` huffman@21809 ` 372` wenzelm@61070 ` 373` ```lemma Reals_numeral [simp]: "numeral w \ \" ``` huffman@47108 ` 374` ```by (subst of_real_numeral [symmetric], rule Reals_of_real) ``` huffman@47108 ` 375` wenzelm@61070 ` 376` ```lemma Reals_0 [simp]: "0 \ \" ``` huffman@20554 ` 377` ```apply (unfold Reals_def) ``` huffman@20554 ` 378` ```apply (rule range_eqI) ``` huffman@20554 ` 379` ```apply (rule of_real_0 [symmetric]) ``` huffman@20554 ` 380` ```done ``` huffman@20554 ` 381` wenzelm@61070 ` 382` ```lemma Reals_1 [simp]: "1 \ \" ``` huffman@20554 ` 383` ```apply (unfold Reals_def) ``` huffman@20554 ` 384` ```apply (rule range_eqI) ``` huffman@20554 ` 385` ```apply (rule of_real_1 [symmetric]) ``` huffman@20554 ` 386` ```done ``` huffman@20554 ` 387` wenzelm@61070 ` 388` ```lemma Reals_add [simp]: "\a \ \; b \ \\ \ a + b \ \" ``` huffman@20554 ` 389` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 390` ```apply (rule range_eqI) ``` huffman@20554 ` 391` ```apply (rule of_real_add [symmetric]) ``` huffman@20554 ` 392` ```done ``` huffman@20554 ` 393` wenzelm@61070 ` 394` ```lemma Reals_minus [simp]: "a \ \ \ - a \ \" ``` huffman@20584 ` 395` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 396` ```apply (rule range_eqI) ``` huffman@20584 ` 397` ```apply (rule of_real_minus [symmetric]) ``` huffman@20584 ` 398` ```done ``` huffman@20584 ` 399` wenzelm@61070 ` 400` ```lemma Reals_diff [simp]: "\a \ \; b \ \\ \ a - b \ \" ``` huffman@20584 ` 401` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 402` ```apply (rule range_eqI) ``` huffman@20584 ` 403` ```apply (rule of_real_diff [symmetric]) ``` huffman@20584 ` 404` ```done ``` huffman@20584 ` 405` wenzelm@61070 ` 406` ```lemma Reals_mult [simp]: "\a \ \; b \ \\ \ a * b \ \" ``` huffman@20554 ` 407` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 408` ```apply (rule range_eqI) ``` huffman@20554 ` 409` ```apply (rule of_real_mult [symmetric]) ``` huffman@20554 ` 410` ```done ``` huffman@20554 ` 411` huffman@20584 ` 412` ```lemma nonzero_Reals_inverse: ``` huffman@20584 ` 413` ``` fixes a :: "'a::real_div_algebra" ``` wenzelm@61070 ` 414` ``` shows "\a \ \; a \ 0\ \ inverse a \ \" ``` huffman@20584 ` 415` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 416` ```apply (rule range_eqI) ``` huffman@20584 ` 417` ```apply (erule nonzero_of_real_inverse [symmetric]) ``` huffman@20584 ` 418` ```done ``` huffman@20584 ` 419` lp15@55719 ` 420` ```lemma Reals_inverse: ``` haftmann@59867 ` 421` ``` fixes a :: "'a::{real_div_algebra, division_ring}" ``` wenzelm@61070 ` 422` ``` shows "a \ \ \ inverse a \ \" ``` huffman@20584 ` 423` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 424` ```apply (rule range_eqI) ``` huffman@20584 ` 425` ```apply (rule of_real_inverse [symmetric]) ``` huffman@20584 ` 426` ```done ``` huffman@20584 ` 427` lp15@60026 ` 428` ```lemma Reals_inverse_iff [simp]: ``` haftmann@59867 ` 429` ``` fixes x:: "'a :: {real_div_algebra, division_ring}" ``` lp15@55719 ` 430` ``` shows "inverse x \ \ \ x \ \" ``` lp15@55719 ` 431` ```by (metis Reals_inverse inverse_inverse_eq) ``` lp15@55719 ` 432` huffman@20584 ` 433` ```lemma nonzero_Reals_divide: ``` huffman@20584 ` 434` ``` fixes a b :: "'a::real_field" ``` wenzelm@61070 ` 435` ``` shows "\a \ \; b \ \; b \ 0\ \ a / b \ \" ``` huffman@20584 ` 436` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 437` ```apply (rule range_eqI) ``` huffman@20584 ` 438` ```apply (erule nonzero_of_real_divide [symmetric]) ``` huffman@20584 ` 439` ```done ``` huffman@20584 ` 440` huffman@20584 ` 441` ```lemma Reals_divide [simp]: ``` haftmann@59867 ` 442` ``` fixes a b :: "'a::{real_field, field}" ``` wenzelm@61070 ` 443` ``` shows "\a \ \; b \ \\ \ a / b \ \" ``` huffman@20584 ` 444` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 445` ```apply (rule range_eqI) ``` huffman@20584 ` 446` ```apply (rule of_real_divide [symmetric]) ``` huffman@20584 ` 447` ```done ``` huffman@20584 ` 448` huffman@20722 ` 449` ```lemma Reals_power [simp]: ``` haftmann@31017 ` 450` ``` fixes a :: "'a::{real_algebra_1}" ``` wenzelm@61070 ` 451` ``` shows "a \ \ \ a ^ n \ \" ``` huffman@20722 ` 452` ```apply (auto simp add: Reals_def) ``` huffman@20722 ` 453` ```apply (rule range_eqI) ``` huffman@20722 ` 454` ```apply (rule of_real_power [symmetric]) ``` huffman@20722 ` 455` ```done ``` huffman@20722 ` 456` huffman@20554 ` 457` ```lemma Reals_cases [cases set: Reals]: ``` huffman@20554 ` 458` ``` assumes "q \ \" ``` huffman@20554 ` 459` ``` obtains (of_real) r where "q = of_real r" ``` huffman@20554 ` 460` ``` unfolding Reals_def ``` huffman@20554 ` 461` ```proof - ``` wenzelm@60758 ` 462` ``` from \q \ \\ have "q \ range of_real" unfolding Reals_def . ``` huffman@20554 ` 463` ``` then obtain r where "q = of_real r" .. ``` huffman@20554 ` 464` ``` then show thesis .. ``` huffman@20554 ` 465` ```qed ``` huffman@20554 ` 466` lp15@59741 ` 467` ```lemma setsum_in_Reals [intro,simp]: ``` lp15@59741 ` 468` ``` assumes "\i. i \ s \ f i \ \" shows "setsum f s \ \" ``` lp15@55719 ` 469` ```proof (cases "finite s") ``` lp15@55719 ` 470` ``` case True then show ?thesis using assms ``` lp15@55719 ` 471` ``` by (induct s rule: finite_induct) auto ``` lp15@55719 ` 472` ```next ``` lp15@55719 ` 473` ``` case False then show ?thesis using assms ``` haftmann@57418 ` 474` ``` by (metis Reals_0 setsum.infinite) ``` lp15@55719 ` 475` ```qed ``` lp15@55719 ` 476` lp15@60026 ` 477` ```lemma setprod_in_Reals [intro,simp]: ``` lp15@59741 ` 478` ``` assumes "\i. i \ s \ f i \ \" shows "setprod f s \ \" ``` lp15@55719 ` 479` ```proof (cases "finite s") ``` lp15@55719 ` 480` ``` case True then show ?thesis using assms ``` lp15@55719 ` 481` ``` by (induct s rule: finite_induct) auto ``` lp15@55719 ` 482` ```next ``` lp15@55719 ` 483` ``` case False then show ?thesis using assms ``` haftmann@57418 ` 484` ``` by (metis Reals_1 setprod.infinite) ``` lp15@55719 ` 485` ```qed ``` lp15@55719 ` 486` huffman@20554 ` 487` ```lemma Reals_induct [case_names of_real, induct set: Reals]: ``` huffman@20554 ` 488` ``` "q \ \ \ (\r. P (of_real r)) \ P q" ``` huffman@20554 ` 489` ``` by (rule Reals_cases) auto ``` huffman@20554 ` 490` wenzelm@60758 ` 491` ```subsection \Ordered real vector spaces\ ``` immler@54778 ` 492` immler@54778 ` 493` ```class ordered_real_vector = real_vector + ordered_ab_group_add + ``` immler@54778 ` 494` ``` assumes scaleR_left_mono: "x \ y \ 0 \ a \ a *\<^sub>R x \ a *\<^sub>R y" ``` immler@54778 ` 495` ``` assumes scaleR_right_mono: "a \ b \ 0 \ x \ a *\<^sub>R x \ b *\<^sub>R x" ``` immler@54778 ` 496` ```begin ``` immler@54778 ` 497` immler@54778 ` 498` ```lemma scaleR_mono: ``` immler@54778 ` 499` ``` "a \ b \ x \ y \ 0 \ b \ 0 \ x \ a *\<^sub>R x \ b *\<^sub>R y" ``` immler@54778 ` 500` ```apply (erule scaleR_right_mono [THEN order_trans], assumption) ``` immler@54778 ` 501` ```apply (erule scaleR_left_mono, assumption) ``` immler@54778 ` 502` ```done ``` immler@54778 ` 503` immler@54778 ` 504` ```lemma scaleR_mono': ``` immler@54778 ` 505` ``` "a \ b \ c \ d \ 0 \ a \ 0 \ c \ a *\<^sub>R c \ b *\<^sub>R d" ``` immler@54778 ` 506` ``` by (rule scaleR_mono) (auto intro: order.trans) ``` immler@54778 ` 507` immler@54785 ` 508` ```lemma pos_le_divideRI: ``` immler@54785 ` 509` ``` assumes "0 < c" ``` immler@54785 ` 510` ``` assumes "c *\<^sub>R a \ b" ``` immler@54785 ` 511` ``` shows "a \ b /\<^sub>R c" ``` immler@54785 ` 512` ```proof - ``` immler@54785 ` 513` ``` from scaleR_left_mono[OF assms(2)] assms(1) ``` immler@54785 ` 514` ``` have "c *\<^sub>R a /\<^sub>R c \ b /\<^sub>R c" ``` immler@54785 ` 515` ``` by simp ``` immler@54785 ` 516` ``` with assms show ?thesis ``` immler@54785 ` 517` ``` by (simp add: scaleR_one scaleR_scaleR inverse_eq_divide) ``` immler@54785 ` 518` ```qed ``` immler@54785 ` 519` immler@54785 ` 520` ```lemma pos_le_divideR_eq: ``` immler@54785 ` 521` ``` assumes "0 < c" ``` immler@54785 ` 522` ``` shows "a \ b /\<^sub>R c \ c *\<^sub>R a \ b" ``` immler@54785 ` 523` ```proof rule ``` immler@54785 ` 524` ``` assume "a \ b /\<^sub>R c" ``` immler@54785 ` 525` ``` from scaleR_left_mono[OF this] assms ``` immler@54785 ` 526` ``` have "c *\<^sub>R a \ c *\<^sub>R (b /\<^sub>R c)" ``` immler@54785 ` 527` ``` by simp ``` immler@54785 ` 528` ``` with assms show "c *\<^sub>R a \ b" ``` immler@54785 ` 529` ``` by (simp add: scaleR_one scaleR_scaleR inverse_eq_divide) ``` immler@54785 ` 530` ```qed (rule pos_le_divideRI[OF assms]) ``` immler@54785 ` 531` immler@54785 ` 532` ```lemma scaleR_image_atLeastAtMost: ``` immler@54785 ` 533` ``` "c > 0 \ scaleR c ` {x..y} = {c *\<^sub>R x..c *\<^sub>R y}" ``` immler@54785 ` 534` ``` apply (auto intro!: scaleR_left_mono) ``` immler@54785 ` 535` ``` apply (rule_tac x = "inverse c *\<^sub>R xa" in image_eqI) ``` immler@54785 ` 536` ``` apply (simp_all add: pos_le_divideR_eq[symmetric] scaleR_scaleR scaleR_one) ``` immler@54785 ` 537` ``` done ``` immler@54785 ` 538` immler@54778 ` 539` ```end ``` immler@54778 ` 540` paulson@60303 ` 541` ```lemma neg_le_divideR_eq: ``` paulson@60303 ` 542` ``` fixes a :: "'a :: ordered_real_vector" ``` paulson@60303 ` 543` ``` assumes "c < 0" ``` paulson@60303 ` 544` ``` shows "a \ b /\<^sub>R c \ b \ c *\<^sub>R a" ``` paulson@60303 ` 545` ``` using pos_le_divideR_eq [of "-c" a "-b"] assms ``` paulson@60303 ` 546` ``` by simp ``` paulson@60303 ` 547` immler@54778 ` 548` ```lemma scaleR_nonneg_nonneg: "0 \ a \ 0 \ (x::'a::ordered_real_vector) \ 0 \ a *\<^sub>R x" ``` immler@54778 ` 549` ``` using scaleR_left_mono [of 0 x a] ``` immler@54778 ` 550` ``` by simp ``` immler@54778 ` 551` immler@54778 ` 552` ```lemma scaleR_nonneg_nonpos: "0 \ a \ (x::'a::ordered_real_vector) \ 0 \ a *\<^sub>R x \ 0" ``` immler@54778 ` 553` ``` using scaleR_left_mono [of x 0 a] by simp ``` immler@54778 ` 554` immler@54778 ` 555` ```lemma scaleR_nonpos_nonneg: "a \ 0 \ 0 \ (x::'a::ordered_real_vector) \ a *\<^sub>R x \ 0" ``` immler@54778 ` 556` ``` using scaleR_right_mono [of a 0 x] by simp ``` immler@54778 ` 557` immler@54778 ` 558` ```lemma split_scaleR_neg_le: "(0 \ a & x \ 0) | (a \ 0 & 0 \ x) \ ``` immler@54778 ` 559` ``` a *\<^sub>R (x::'a::ordered_real_vector) \ 0" ``` immler@54778 ` 560` ``` by (auto simp add: scaleR_nonneg_nonpos scaleR_nonpos_nonneg) ``` immler@54778 ` 561` immler@54778 ` 562` ```lemma le_add_iff1: ``` immler@54778 ` 563` ``` fixes c d e::"'a::ordered_real_vector" ``` immler@54778 ` 564` ``` shows "a *\<^sub>R e + c \ b *\<^sub>R e + d \ (a - b) *\<^sub>R e + c \ d" ``` immler@54778 ` 565` ``` by (simp add: algebra_simps) ``` immler@54778 ` 566` immler@54778 ` 567` ```lemma le_add_iff2: ``` immler@54778 ` 568` ``` fixes c d e::"'a::ordered_real_vector" ``` immler@54778 ` 569` ``` shows "a *\<^sub>R e + c \ b *\<^sub>R e + d \ c \ (b - a) *\<^sub>R e + d" ``` immler@54778 ` 570` ``` by (simp add: algebra_simps) ``` immler@54778 ` 571` immler@54778 ` 572` ```lemma scaleR_left_mono_neg: ``` immler@54778 ` 573` ``` fixes a b::"'a::ordered_real_vector" ``` immler@54778 ` 574` ``` shows "b \ a \ c \ 0 \ c *\<^sub>R a \ c *\<^sub>R b" ``` immler@54778 ` 575` ``` apply (drule scaleR_left_mono [of _ _ "- c"]) ``` immler@54778 ` 576` ``` apply simp_all ``` immler@54778 ` 577` ``` done ``` immler@54778 ` 578` immler@54778 ` 579` ```lemma scaleR_right_mono_neg: ``` immler@54778 ` 580` ``` fixes c::"'a::ordered_real_vector" ``` immler@54778 ` 581` ``` shows "b \ a \ c \ 0 \ a *\<^sub>R c \ b *\<^sub>R c" ``` immler@54778 ` 582` ``` apply (drule scaleR_right_mono [of _ _ "- c"]) ``` immler@54778 ` 583` ``` apply simp_all ``` immler@54778 ` 584` ``` done ``` immler@54778 ` 585` immler@54778 ` 586` ```lemma scaleR_nonpos_nonpos: "a \ 0 \ (b::'a::ordered_real_vector) \ 0 \ 0 \ a *\<^sub>R b" ``` immler@54778 ` 587` ```using scaleR_right_mono_neg [of a 0 b] by simp ``` immler@54778 ` 588` immler@54778 ` 589` ```lemma split_scaleR_pos_le: ``` immler@54778 ` 590` ``` fixes b::"'a::ordered_real_vector" ``` immler@54778 ` 591` ``` shows "(0 \ a \ 0 \ b) \ (a \ 0 \ b \ 0) \ 0 \ a *\<^sub>R b" ``` immler@54778 ` 592` ``` by (auto simp add: scaleR_nonneg_nonneg scaleR_nonpos_nonpos) ``` immler@54778 ` 593` immler@54778 ` 594` ```lemma zero_le_scaleR_iff: ``` immler@54778 ` 595` ``` fixes b::"'a::ordered_real_vector" ``` immler@54778 ` 596` ``` shows "0 \ a *\<^sub>R b \ 0 < a \ 0 \ b \ a < 0 \ b \ 0 \ a = 0" (is "?lhs = ?rhs") ``` immler@54778 ` 597` ```proof cases ``` immler@54778 ` 598` ``` assume "a \ 0" ``` immler@54778 ` 599` ``` show ?thesis ``` immler@54778 ` 600` ``` proof ``` immler@54778 ` 601` ``` assume lhs: ?lhs ``` immler@54778 ` 602` ``` { ``` immler@54778 ` 603` ``` assume "0 < a" ``` immler@54778 ` 604` ``` with lhs have "inverse a *\<^sub>R 0 \ inverse a *\<^sub>R (a *\<^sub>R b)" ``` immler@54778 ` 605` ``` by (intro scaleR_mono) auto ``` wenzelm@60758 ` 606` ``` hence ?rhs using \0 < a\ ``` immler@54778 ` 607` ``` by simp ``` immler@54778 ` 608` ``` } moreover { ``` immler@54778 ` 609` ``` assume "0 > a" ``` immler@54778 ` 610` ``` with lhs have "- inverse a *\<^sub>R 0 \ - inverse a *\<^sub>R (a *\<^sub>R b)" ``` immler@54778 ` 611` ``` by (intro scaleR_mono) auto ``` wenzelm@60758 ` 612` ``` hence ?rhs using \0 > a\ ``` immler@54778 ` 613` ``` by simp ``` wenzelm@60758 ` 614` ``` } ultimately show ?rhs using \a \ 0\ by arith ``` wenzelm@60758 ` 615` ``` qed (auto simp: not_le \a \ 0\ intro!: split_scaleR_pos_le) ``` immler@54778 ` 616` ```qed simp ``` immler@54778 ` 617` immler@54778 ` 618` ```lemma scaleR_le_0_iff: ``` immler@54778 ` 619` ``` fixes b::"'a::ordered_real_vector" ``` immler@54778 ` 620` ``` shows "a *\<^sub>R b \ 0 \ 0 < a \ b \ 0 \ a < 0 \ 0 \ b \ a = 0" ``` immler@54778 ` 621` ``` by (insert zero_le_scaleR_iff [of "-a" b]) force ``` immler@54778 ` 622` immler@54778 ` 623` ```lemma scaleR_le_cancel_left: ``` immler@54778 ` 624` ``` fixes b::"'a::ordered_real_vector" ``` immler@54778 ` 625` ``` shows "c *\<^sub>R a \ c *\<^sub>R b \ (0 < c \ a \ b) \ (c < 0 \ b \ a)" ``` immler@54778 ` 626` ``` by (auto simp add: neq_iff scaleR_left_mono scaleR_left_mono_neg ``` immler@54778 ` 627` ``` dest: scaleR_left_mono[where a="inverse c"] scaleR_left_mono_neg[where c="inverse c"]) ``` immler@54778 ` 628` immler@54778 ` 629` ```lemma scaleR_le_cancel_left_pos: ``` immler@54778 ` 630` ``` fixes b::"'a::ordered_real_vector" ``` immler@54778 ` 631` ``` shows "0 < c \ c *\<^sub>R a \ c *\<^sub>R b \ a \ b" ``` immler@54778 ` 632` ``` by (auto simp: scaleR_le_cancel_left) ``` immler@54778 ` 633` immler@54778 ` 634` ```lemma scaleR_le_cancel_left_neg: ``` immler@54778 ` 635` ``` fixes b::"'a::ordered_real_vector" ``` immler@54778 ` 636` ``` shows "c < 0 \ c *\<^sub>R a \ c *\<^sub>R b \ b \ a" ``` immler@54778 ` 637` ``` by (auto simp: scaleR_le_cancel_left) ``` immler@54778 ` 638` immler@54778 ` 639` ```lemma scaleR_left_le_one_le: ``` immler@54778 ` 640` ``` fixes x::"'a::ordered_real_vector" and a::real ``` immler@54778 ` 641` ``` shows "0 \ x \ a \ 1 \ a *\<^sub>R x \ x" ``` immler@54778 ` 642` ``` using scaleR_right_mono[of a 1 x] by simp ``` immler@54778 ` 643` huffman@20504 ` 644` wenzelm@60758 ` 645` ```subsection \Real normed vector spaces\ ``` huffman@20504 ` 646` hoelzl@51531 ` 647` ```class dist = ``` hoelzl@51531 ` 648` ``` fixes dist :: "'a \ 'a \ real" ``` hoelzl@51531 ` 649` haftmann@29608 ` 650` ```class norm = ``` huffman@22636 ` 651` ``` fixes norm :: "'a \ real" ``` huffman@20504 ` 652` huffman@24520 ` 653` ```class sgn_div_norm = scaleR + norm + sgn + ``` haftmann@25062 ` 654` ``` assumes sgn_div_norm: "sgn x = x /\<^sub>R norm x" ``` nipkow@24506 ` 655` huffman@31289 ` 656` ```class dist_norm = dist + norm + minus + ``` huffman@31289 ` 657` ``` assumes dist_norm: "dist x y = norm (x - y)" ``` huffman@31289 ` 658` hoelzl@51531 ` 659` ```class open_dist = "open" + dist + ``` hoelzl@51531 ` 660` ``` assumes open_dist: "open S \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" ``` hoelzl@51531 ` 661` huffman@31492 ` 662` ```class real_normed_vector = real_vector + sgn_div_norm + dist_norm + open_dist + ``` hoelzl@51002 ` 663` ``` assumes norm_eq_zero [simp]: "norm x = 0 \ x = 0" ``` haftmann@25062 ` 664` ``` and norm_triangle_ineq: "norm (x + y) \ norm x + norm y" ``` huffman@31586 ` 665` ``` and norm_scaleR [simp]: "norm (scaleR a x) = \a\ * norm x" ``` hoelzl@51002 ` 666` ```begin ``` hoelzl@51002 ` 667` hoelzl@51002 ` 668` ```lemma norm_ge_zero [simp]: "0 \ norm x" ``` hoelzl@51002 ` 669` ```proof - ``` lp15@60026 ` 670` ``` have "0 = norm (x + -1 *\<^sub>R x)" ``` hoelzl@51002 ` 671` ``` using scaleR_add_left[of 1 "-1" x] norm_scaleR[of 0 x] by (simp add: scaleR_one) ``` hoelzl@51002 ` 672` ``` also have "\ \ norm x + norm (-1 *\<^sub>R x)" by (rule norm_triangle_ineq) ``` hoelzl@51002 ` 673` ``` finally show ?thesis by simp ``` hoelzl@51002 ` 674` ```qed ``` hoelzl@51002 ` 675` hoelzl@51002 ` 676` ```end ``` huffman@20504 ` 677` haftmann@24588 ` 678` ```class real_normed_algebra = real_algebra + real_normed_vector + ``` haftmann@25062 ` 679` ``` assumes norm_mult_ineq: "norm (x * y) \ norm x * norm y" ``` huffman@20504 ` 680` haftmann@24588 ` 681` ```class real_normed_algebra_1 = real_algebra_1 + real_normed_algebra + ``` haftmann@25062 ` 682` ``` assumes norm_one [simp]: "norm 1 = 1" ``` huffman@22852 ` 683` haftmann@24588 ` 684` ```class real_normed_div_algebra = real_div_algebra + real_normed_vector + ``` haftmann@25062 ` 685` ``` assumes norm_mult: "norm (x * y) = norm x * norm y" ``` huffman@20504 ` 686` haftmann@24588 ` 687` ```class real_normed_field = real_field + real_normed_div_algebra ``` huffman@20584 ` 688` huffman@22852 ` 689` ```instance real_normed_div_algebra < real_normed_algebra_1 ``` huffman@20554 ` 690` ```proof ``` huffman@20554 ` 691` ``` fix x y :: 'a ``` huffman@20554 ` 692` ``` show "norm (x * y) \ norm x * norm y" ``` huffman@20554 ` 693` ``` by (simp add: norm_mult) ``` huffman@22852 ` 694` ```next ``` huffman@22852 ` 695` ``` have "norm (1 * 1::'a) = norm (1::'a) * norm (1::'a)" ``` huffman@22852 ` 696` ``` by (rule norm_mult) ``` huffman@22852 ` 697` ``` thus "norm (1::'a) = 1" by simp ``` huffman@20554 ` 698` ```qed ``` huffman@20554 ` 699` huffman@22852 ` 700` ```lemma norm_zero [simp]: "norm (0::'a::real_normed_vector) = 0" ``` huffman@20504 ` 701` ```by simp ``` huffman@20504 ` 702` huffman@22852 ` 703` ```lemma zero_less_norm_iff [simp]: ``` huffman@22852 ` 704` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 705` ``` shows "(0 < norm x) = (x \ 0)" ``` huffman@20504 ` 706` ```by (simp add: order_less_le) ``` huffman@20504 ` 707` huffman@22852 ` 708` ```lemma norm_not_less_zero [simp]: ``` huffman@22852 ` 709` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 710` ``` shows "\ norm x < 0" ``` huffman@20828 ` 711` ```by (simp add: linorder_not_less) ``` huffman@20828 ` 712` huffman@22852 ` 713` ```lemma norm_le_zero_iff [simp]: ``` huffman@22852 ` 714` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 715` ``` shows "(norm x \ 0) = (x = 0)" ``` huffman@20828 ` 716` ```by (simp add: order_le_less) ``` huffman@20828 ` 717` huffman@20504 ` 718` ```lemma norm_minus_cancel [simp]: ``` huffman@20584 ` 719` ``` fixes x :: "'a::real_normed_vector" ``` huffman@20584 ` 720` ``` shows "norm (- x) = norm x" ``` huffman@20504 ` 721` ```proof - ``` huffman@21809 ` 722` ``` have "norm (- x) = norm (scaleR (- 1) x)" ``` huffman@20504 ` 723` ``` by (simp only: scaleR_minus_left scaleR_one) ``` huffman@20533 ` 724` ``` also have "\ = \- 1\ * norm x" ``` huffman@20504 ` 725` ``` by (rule norm_scaleR) ``` huffman@20504 ` 726` ``` finally show ?thesis by simp ``` huffman@20504 ` 727` ```qed ``` huffman@20504 ` 728` huffman@20504 ` 729` ```lemma norm_minus_commute: ``` huffman@20584 ` 730` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 731` ``` shows "norm (a - b) = norm (b - a)" ``` huffman@20504 ` 732` ```proof - ``` huffman@22898 ` 733` ``` have "norm (- (b - a)) = norm (b - a)" ``` huffman@22898 ` 734` ``` by (rule norm_minus_cancel) ``` huffman@22898 ` 735` ``` thus ?thesis by simp ``` huffman@20504 ` 736` ```qed ``` huffman@20504 ` 737` huffman@20504 ` 738` ```lemma norm_triangle_ineq2: ``` huffman@20584 ` 739` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 740` ``` shows "norm a - norm b \ norm (a - b)" ``` huffman@20504 ` 741` ```proof - ``` huffman@20533 ` 742` ``` have "norm (a - b + b) \ norm (a - b) + norm b" ``` huffman@20504 ` 743` ``` by (rule norm_triangle_ineq) ``` huffman@22898 ` 744` ``` thus ?thesis by simp ``` huffman@20504 ` 745` ```qed ``` huffman@20504 ` 746` huffman@20584 ` 747` ```lemma norm_triangle_ineq3: ``` huffman@20584 ` 748` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 749` ``` shows "\norm a - norm b\ \ norm (a - b)" ``` huffman@20584 ` 750` ```apply (subst abs_le_iff) ``` huffman@20584 ` 751` ```apply auto ``` huffman@20584 ` 752` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 753` ```apply (subst norm_minus_commute) ``` huffman@20584 ` 754` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 755` ```done ``` huffman@20584 ` 756` huffman@20504 ` 757` ```lemma norm_triangle_ineq4: ``` huffman@20584 ` 758` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 759` ``` shows "norm (a - b) \ norm a + norm b" ``` huffman@20504 ` 760` ```proof - ``` huffman@22898 ` 761` ``` have "norm (a + - b) \ norm a + norm (- b)" ``` huffman@20504 ` 762` ``` by (rule norm_triangle_ineq) ``` haftmann@54230 ` 763` ``` then show ?thesis by simp ``` huffman@22898 ` 764` ```qed ``` huffman@22898 ` 765` huffman@22898 ` 766` ```lemma norm_diff_ineq: ``` huffman@22898 ` 767` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@22898 ` 768` ``` shows "norm a - norm b \ norm (a + b)" ``` huffman@22898 ` 769` ```proof - ``` huffman@22898 ` 770` ``` have "norm a - norm (- b) \ norm (a - - b)" ``` huffman@22898 ` 771` ``` by (rule norm_triangle_ineq2) ``` huffman@22898 ` 772` ``` thus ?thesis by simp ``` huffman@20504 ` 773` ```qed ``` huffman@20504 ` 774` huffman@20551 ` 775` ```lemma norm_diff_triangle_ineq: ``` huffman@20551 ` 776` ``` fixes a b c d :: "'a::real_normed_vector" ``` huffman@20551 ` 777` ``` shows "norm ((a + b) - (c + d)) \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 778` ```proof - ``` huffman@20551 ` 779` ``` have "norm ((a + b) - (c + d)) = norm ((a - c) + (b - d))" ``` haftmann@54230 ` 780` ``` by (simp add: algebra_simps) ``` huffman@20551 ` 781` ``` also have "\ \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 782` ``` by (rule norm_triangle_ineq) ``` huffman@20551 ` 783` ``` finally show ?thesis . ``` huffman@20551 ` 784` ```qed ``` huffman@20551 ` 785` lp15@60800 ` 786` ```lemma norm_diff_triangle_le: ``` lp15@60800 ` 787` ``` fixes x y z :: "'a::real_normed_vector" ``` lp15@60800 ` 788` ``` assumes "norm (x - y) \ e1" "norm (y - z) \ e2" ``` lp15@60800 ` 789` ``` shows "norm (x - z) \ e1 + e2" ``` lp15@60800 ` 790` ``` using norm_diff_triangle_ineq [of x y y z] assms by simp ``` lp15@60800 ` 791` lp15@60800 ` 792` ```lemma norm_diff_triangle_less: ``` lp15@60800 ` 793` ``` fixes x y z :: "'a::real_normed_vector" ``` lp15@60800 ` 794` ``` assumes "norm (x - y) < e1" "norm (y - z) < e2" ``` lp15@60800 ` 795` ``` shows "norm (x - z) < e1 + e2" ``` lp15@60800 ` 796` ``` using norm_diff_triangle_ineq [of x y y z] assms by simp ``` lp15@60800 ` 797` lp15@60026 ` 798` ```lemma norm_triangle_mono: ``` lp15@55719 ` 799` ``` fixes a b :: "'a::real_normed_vector" ``` lp15@55719 ` 800` ``` shows "\norm a \ r; norm b \ s\ \ norm (a + b) \ r + s" ``` lp15@55719 ` 801` ```by (metis add_mono_thms_linordered_semiring(1) norm_triangle_ineq order.trans) ``` lp15@55719 ` 802` hoelzl@56194 ` 803` ```lemma norm_setsum: ``` hoelzl@56194 ` 804` ``` fixes f :: "'a \ 'b::real_normed_vector" ``` hoelzl@56194 ` 805` ``` shows "norm (setsum f A) \ (\i\A. norm (f i))" ``` hoelzl@56194 ` 806` ``` by (induct A rule: infinite_finite_induct) (auto intro: norm_triangle_mono) ``` hoelzl@56194 ` 807` hoelzl@56369 ` 808` ```lemma setsum_norm_le: ``` hoelzl@56369 ` 809` ``` fixes f :: "'a \ 'b::real_normed_vector" ``` hoelzl@56369 ` 810` ``` assumes fg: "\x \ S. norm (f x) \ g x" ``` hoelzl@56369 ` 811` ``` shows "norm (setsum f S) \ setsum g S" ``` hoelzl@56369 ` 812` ``` by (rule order_trans [OF norm_setsum setsum_mono]) (simp add: fg) ``` hoelzl@56369 ` 813` huffman@22857 ` 814` ```lemma abs_norm_cancel [simp]: ``` huffman@22857 ` 815` ``` fixes a :: "'a::real_normed_vector" ``` huffman@22857 ` 816` ``` shows "\norm a\ = norm a" ``` huffman@22857 ` 817` ```by (rule abs_of_nonneg [OF norm_ge_zero]) ``` huffman@22857 ` 818` huffman@22880 ` 819` ```lemma norm_add_less: ``` huffman@22880 ` 820` ``` fixes x y :: "'a::real_normed_vector" ``` huffman@22880 ` 821` ``` shows "\norm x < r; norm y < s\ \ norm (x + y) < r + s" ``` huffman@22880 ` 822` ```by (rule order_le_less_trans [OF norm_triangle_ineq add_strict_mono]) ``` huffman@22880 ` 823` huffman@22880 ` 824` ```lemma norm_mult_less: ``` huffman@22880 ` 825` ``` fixes x y :: "'a::real_normed_algebra" ``` huffman@22880 ` 826` ``` shows "\norm x < r; norm y < s\ \ norm (x * y) < r * s" ``` huffman@22880 ` 827` ```apply (rule order_le_less_trans [OF norm_mult_ineq]) ``` huffman@22880 ` 828` ```apply (simp add: mult_strict_mono') ``` huffman@22880 ` 829` ```done ``` huffman@22880 ` 830` huffman@22857 ` 831` ```lemma norm_of_real [simp]: ``` huffman@22857 ` 832` ``` "norm (of_real r :: 'a::real_normed_algebra_1) = \r\" ``` huffman@31586 ` 833` ```unfolding of_real_def by simp ``` huffman@20560 ` 834` huffman@47108 ` 835` ```lemma norm_numeral [simp]: ``` huffman@47108 ` 836` ``` "norm (numeral w::'a::real_normed_algebra_1) = numeral w" ``` huffman@47108 ` 837` ```by (subst of_real_numeral [symmetric], subst norm_of_real, simp) ``` huffman@47108 ` 838` huffman@47108 ` 839` ```lemma norm_neg_numeral [simp]: ``` haftmann@54489 ` 840` ``` "norm (- numeral w::'a::real_normed_algebra_1) = numeral w" ``` huffman@47108 ` 841` ```by (subst of_real_neg_numeral [symmetric], subst norm_of_real, simp) ``` huffman@22876 ` 842` huffman@22876 ` 843` ```lemma norm_of_int [simp]: ``` huffman@22876 ` 844` ``` "norm (of_int z::'a::real_normed_algebra_1) = \of_int z\" ``` huffman@22876 ` 845` ```by (subst of_real_of_int_eq [symmetric], rule norm_of_real) ``` huffman@22876 ` 846` huffman@22876 ` 847` ```lemma norm_of_nat [simp]: ``` huffman@22876 ` 848` ``` "norm (of_nat n::'a::real_normed_algebra_1) = of_nat n" ``` huffman@22876 ` 849` ```apply (subst of_real_of_nat_eq [symmetric]) ``` huffman@22876 ` 850` ```apply (subst norm_of_real, simp) ``` huffman@22876 ` 851` ```done ``` huffman@22876 ` 852` huffman@20504 ` 853` ```lemma nonzero_norm_inverse: ``` huffman@20504 ` 854` ``` fixes a :: "'a::real_normed_div_algebra" ``` huffman@20533 ` 855` ``` shows "a \ 0 \ norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 856` ```apply (rule inverse_unique [symmetric]) ``` huffman@20504 ` 857` ```apply (simp add: norm_mult [symmetric]) ``` huffman@20504 ` 858` ```done ``` huffman@20504 ` 859` huffman@20504 ` 860` ```lemma norm_inverse: ``` haftmann@59867 ` 861` ``` fixes a :: "'a::{real_normed_div_algebra, division_ring}" ``` huffman@20533 ` 862` ``` shows "norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 863` ```apply (case_tac "a = 0", simp) ``` huffman@20504 ` 864` ```apply (erule nonzero_norm_inverse) ``` huffman@20504 ` 865` ```done ``` huffman@20504 ` 866` huffman@20584 ` 867` ```lemma nonzero_norm_divide: ``` huffman@20584 ` 868` ``` fixes a b :: "'a::real_normed_field" ``` huffman@20584 ` 869` ``` shows "b \ 0 \ norm (a / b) = norm a / norm b" ``` huffman@20584 ` 870` ```by (simp add: divide_inverse norm_mult nonzero_norm_inverse) ``` huffman@20584 ` 871` huffman@20584 ` 872` ```lemma norm_divide: ``` haftmann@59867 ` 873` ``` fixes a b :: "'a::{real_normed_field, field}" ``` huffman@20584 ` 874` ``` shows "norm (a / b) = norm a / norm b" ``` huffman@20584 ` 875` ```by (simp add: divide_inverse norm_mult norm_inverse) ``` huffman@20584 ` 876` huffman@22852 ` 877` ```lemma norm_power_ineq: ``` haftmann@31017 ` 878` ``` fixes x :: "'a::{real_normed_algebra_1}" ``` huffman@22852 ` 879` ``` shows "norm (x ^ n) \ norm x ^ n" ``` huffman@22852 ` 880` ```proof (induct n) ``` huffman@22852 ` 881` ``` case 0 show "norm (x ^ 0) \ norm x ^ 0" by simp ``` huffman@22852 ` 882` ```next ``` huffman@22852 ` 883` ``` case (Suc n) ``` huffman@22852 ` 884` ``` have "norm (x * x ^ n) \ norm x * norm (x ^ n)" ``` huffman@22852 ` 885` ``` by (rule norm_mult_ineq) ``` huffman@22852 ` 886` ``` also from Suc have "\ \ norm x * norm x ^ n" ``` huffman@22852 ` 887` ``` using norm_ge_zero by (rule mult_left_mono) ``` huffman@22852 ` 888` ``` finally show "norm (x ^ Suc n) \ norm x ^ Suc n" ``` huffman@30273 ` 889` ``` by simp ``` huffman@22852 ` 890` ```qed ``` huffman@22852 ` 891` huffman@20684 ` 892` ```lemma norm_power: ``` haftmann@31017 ` 893` ``` fixes x :: "'a::{real_normed_div_algebra}" ``` huffman@20684 ` 894` ``` shows "norm (x ^ n) = norm x ^ n" ``` huffman@30273 ` 895` ```by (induct n) (simp_all add: norm_mult) ``` huffman@20684 ` 896` paulson@60762 ` 897` ```lemma norm_mult_numeral1 [simp]: ``` paulson@60762 ` 898` ``` fixes a b :: "'a::{real_normed_field, field}" ``` paulson@60762 ` 899` ``` shows "norm (numeral w * a) = numeral w * norm a" ``` paulson@60762 ` 900` ```by (simp add: norm_mult) ``` paulson@60762 ` 901` paulson@60762 ` 902` ```lemma norm_mult_numeral2 [simp]: ``` paulson@60762 ` 903` ``` fixes a b :: "'a::{real_normed_field, field}" ``` paulson@60762 ` 904` ``` shows "norm (a * numeral w) = norm a * numeral w" ``` paulson@60762 ` 905` ```by (simp add: norm_mult) ``` paulson@60762 ` 906` paulson@60762 ` 907` ```lemma norm_divide_numeral [simp]: ``` paulson@60762 ` 908` ``` fixes a b :: "'a::{real_normed_field, field}" ``` paulson@60762 ` 909` ``` shows "norm (a / numeral w) = norm a / numeral w" ``` paulson@60762 ` 910` ```by (simp add: norm_divide) ``` paulson@60762 ` 911` paulson@60762 ` 912` ```lemma norm_of_real_diff [simp]: ``` paulson@60762 ` 913` ``` "norm (of_real b - of_real a :: 'a::real_normed_algebra_1) \ \b - a\" ``` paulson@60762 ` 914` ``` by (metis norm_of_real of_real_diff order_refl) ``` paulson@60762 ` 915` wenzelm@60758 ` 916` ```text\Despite a superficial resemblance, @{text norm_eq_1} is not relevant.\ ``` lp15@59613 ` 917` ```lemma square_norm_one: ``` lp15@59613 ` 918` ``` fixes x :: "'a::real_normed_div_algebra" ``` lp15@59613 ` 919` ``` assumes "x^2 = 1" shows "norm x = 1" ``` lp15@59613 ` 920` ``` by (metis assms norm_minus_cancel norm_one power2_eq_1_iff) ``` lp15@59613 ` 921` lp15@59658 ` 922` ```lemma norm_less_p1: ``` lp15@59658 ` 923` ``` fixes x :: "'a::real_normed_algebra_1" ``` lp15@59658 ` 924` ``` shows "norm x < norm (of_real (norm x) + 1 :: 'a)" ``` lp15@59658 ` 925` ```proof - ``` lp15@59658 ` 926` ``` have "norm x < norm (of_real (norm x + 1) :: 'a)" ``` lp15@59658 ` 927` ``` by (simp add: of_real_def) ``` lp15@59658 ` 928` ``` then show ?thesis ``` lp15@59658 ` 929` ``` by simp ``` lp15@59658 ` 930` ```qed ``` lp15@59658 ` 931` lp15@55719 ` 932` ```lemma setprod_norm: ``` lp15@55719 ` 933` ``` fixes f :: "'a \ 'b::{comm_semiring_1,real_normed_div_algebra}" ``` lp15@55719 ` 934` ``` shows "setprod (\x. norm(f x)) A = norm (setprod f A)" ``` hoelzl@57275 ` 935` ``` by (induct A rule: infinite_finite_induct) (auto simp: norm_mult) ``` hoelzl@57275 ` 936` lp15@60026 ` 937` ```lemma norm_setprod_le: ``` hoelzl@57275 ` 938` ``` "norm (setprod f A) \ (\a\A. norm (f a :: 'a :: {real_normed_algebra_1, comm_monoid_mult}))" ``` hoelzl@57275 ` 939` ```proof (induction A rule: infinite_finite_induct) ``` hoelzl@57275 ` 940` ``` case (insert a A) ``` hoelzl@57275 ` 941` ``` then have "norm (setprod f (insert a A)) \ norm (f a) * norm (setprod f A)" ``` hoelzl@57275 ` 942` ``` by (simp add: norm_mult_ineq) ``` hoelzl@57275 ` 943` ``` also have "norm (setprod f A) \ (\a\A. norm (f a))" ``` hoelzl@57275 ` 944` ``` by (rule insert) ``` hoelzl@57275 ` 945` ``` finally show ?case ``` hoelzl@57275 ` 946` ``` by (simp add: insert mult_left_mono) ``` hoelzl@57275 ` 947` ```qed simp_all ``` hoelzl@57275 ` 948` hoelzl@57275 ` 949` ```lemma norm_setprod_diff: ``` hoelzl@57275 ` 950` ``` fixes z w :: "'i \ 'a::{real_normed_algebra_1, comm_monoid_mult}" ``` hoelzl@57275 ` 951` ``` shows "(\i. i \ I \ norm (z i) \ 1) \ (\i. i \ I \ norm (w i) \ 1) \ ``` lp15@60026 ` 952` ``` norm ((\i\I. z i) - (\i\I. w i)) \ (\i\I. norm (z i - w i))" ``` hoelzl@57275 ` 953` ```proof (induction I rule: infinite_finite_induct) ``` hoelzl@57275 ` 954` ``` case (insert i I) ``` hoelzl@57275 ` 955` ``` note insert.hyps[simp] ``` hoelzl@57275 ` 956` hoelzl@57275 ` 957` ``` have "norm ((\i\insert i I. z i) - (\i\insert i I. w i)) = ``` hoelzl@57275 ` 958` ``` norm ((\i\I. z i) * (z i - w i) + ((\i\I. z i) - (\i\I. w i)) * w i)" ``` hoelzl@57275 ` 959` ``` (is "_ = norm (?t1 + ?t2)") ``` hoelzl@57275 ` 960` ``` by (auto simp add: field_simps) ``` hoelzl@57275 ` 961` ``` also have "... \ norm ?t1 + norm ?t2" ``` hoelzl@57275 ` 962` ``` by (rule norm_triangle_ineq) ``` hoelzl@57275 ` 963` ``` also have "norm ?t1 \ norm (\i\I. z i) * norm (z i - w i)" ``` hoelzl@57275 ` 964` ``` by (rule norm_mult_ineq) ``` hoelzl@57275 ` 965` ``` also have "\ \ (\i\I. norm (z i)) * norm(z i - w i)" ``` hoelzl@57275 ` 966` ``` by (rule mult_right_mono) (auto intro: norm_setprod_le) ``` hoelzl@57275 ` 967` ``` also have "(\i\I. norm (z i)) \ (\i\I. 1)" ``` hoelzl@57275 ` 968` ``` by (intro setprod_mono) (auto intro!: insert) ``` hoelzl@57275 ` 969` ``` also have "norm ?t2 \ norm ((\i\I. z i) - (\i\I. w i)) * norm (w i)" ``` hoelzl@57275 ` 970` ``` by (rule norm_mult_ineq) ``` hoelzl@57275 ` 971` ``` also have "norm (w i) \ 1" ``` hoelzl@57275 ` 972` ``` by (auto intro: insert) ``` hoelzl@57275 ` 973` ``` also have "norm ((\i\I. z i) - (\i\I. w i)) \ (\i\I. norm (z i - w i))" ``` hoelzl@57275 ` 974` ``` using insert by auto ``` hoelzl@57275 ` 975` ``` finally show ?case ``` haftmann@57514 ` 976` ``` by (auto simp add: ac_simps mult_right_mono mult_left_mono) ``` hoelzl@57275 ` 977` ```qed simp_all ``` hoelzl@57275 ` 978` lp15@60026 ` 979` ```lemma norm_power_diff: ``` hoelzl@57275 ` 980` ``` fixes z w :: "'a::{real_normed_algebra_1, comm_monoid_mult}" ``` hoelzl@57275 ` 981` ``` assumes "norm z \ 1" "norm w \ 1" ``` hoelzl@57275 ` 982` ``` shows "norm (z^m - w^m) \ m * norm (z - w)" ``` hoelzl@57275 ` 983` ```proof - ``` hoelzl@57275 ` 984` ``` have "norm (z^m - w^m) = norm ((\ i < m. z) - (\ i < m. w))" ``` hoelzl@57275 ` 985` ``` by (simp add: setprod_constant) ``` hoelzl@57275 ` 986` ``` also have "\ \ (\i = m * norm (z - w)" ``` hoelzl@57275 ` 989` ``` by (simp add: real_of_nat_def) ``` hoelzl@57275 ` 990` ``` finally show ?thesis . ``` lp15@55719 ` 991` ```qed ``` lp15@55719 ` 992` wenzelm@60758 ` 993` ```subsection \Metric spaces\ ``` hoelzl@51531 ` 994` hoelzl@51531 ` 995` ```class metric_space = open_dist + ``` hoelzl@51531 ` 996` ``` assumes dist_eq_0_iff [simp]: "dist x y = 0 \ x = y" ``` hoelzl@51531 ` 997` ``` assumes dist_triangle2: "dist x y \ dist x z + dist y z" ``` hoelzl@51531 ` 998` ```begin ``` hoelzl@51531 ` 999` hoelzl@51531 ` 1000` ```lemma dist_self [simp]: "dist x x = 0" ``` hoelzl@51531 ` 1001` ```by simp ``` hoelzl@51531 ` 1002` hoelzl@51531 ` 1003` ```lemma zero_le_dist [simp]: "0 \ dist x y" ``` hoelzl@51531 ` 1004` ```using dist_triangle2 [of x x y] by simp ``` hoelzl@51531 ` 1005` hoelzl@51531 ` 1006` ```lemma zero_less_dist_iff: "0 < dist x y \ x \ y" ``` hoelzl@51531 ` 1007` ```by (simp add: less_le) ``` hoelzl@51531 ` 1008` hoelzl@51531 ` 1009` ```lemma dist_not_less_zero [simp]: "\ dist x y < 0" ``` hoelzl@51531 ` 1010` ```by (simp add: not_less) ``` hoelzl@51531 ` 1011` hoelzl@51531 ` 1012` ```lemma dist_le_zero_iff [simp]: "dist x y \ 0 \ x = y" ``` hoelzl@51531 ` 1013` ```by (simp add: le_less) ``` hoelzl@51531 ` 1014` hoelzl@51531 ` 1015` ```lemma dist_commute: "dist x y = dist y x" ``` hoelzl@51531 ` 1016` ```proof (rule order_antisym) ``` hoelzl@51531 ` 1017` ``` show "dist x y \ dist y x" ``` hoelzl@51531 ` 1018` ``` using dist_triangle2 [of x y x] by simp ``` hoelzl@51531 ` 1019` ``` show "dist y x \ dist x y" ``` hoelzl@51531 ` 1020` ``` using dist_triangle2 [of y x y] by simp ``` hoelzl@51531 ` 1021` ```qed ``` hoelzl@51531 ` 1022` hoelzl@51531 ` 1023` ```lemma dist_triangle: "dist x z \ dist x y + dist y z" ``` hoelzl@51531 ` 1024` ```using dist_triangle2 [of x z y] by (simp add: dist_commute) ``` hoelzl@51531 ` 1025` hoelzl@51531 ` 1026` ```lemma dist_triangle3: "dist x y \ dist a x + dist a y" ``` hoelzl@51531 ` 1027` ```using dist_triangle2 [of x y a] by (simp add: dist_commute) ``` hoelzl@51531 ` 1028` hoelzl@51531 ` 1029` ```lemma dist_triangle_alt: ``` hoelzl@51531 ` 1030` ``` shows "dist y z <= dist x y + dist x z" ``` hoelzl@51531 ` 1031` ```by (rule dist_triangle3) ``` hoelzl@51531 ` 1032` hoelzl@51531 ` 1033` ```lemma dist_pos_lt: ``` hoelzl@51531 ` 1034` ``` shows "x \ y ==> 0 < dist x y" ``` hoelzl@51531 ` 1035` ```by (simp add: zero_less_dist_iff) ``` hoelzl@51531 ` 1036` hoelzl@51531 ` 1037` ```lemma dist_nz: ``` hoelzl@51531 ` 1038` ``` shows "x \ y \ 0 < dist x y" ``` hoelzl@51531 ` 1039` ```by (simp add: zero_less_dist_iff) ``` hoelzl@51531 ` 1040` hoelzl@51531 ` 1041` ```lemma dist_triangle_le: ``` hoelzl@51531 ` 1042` ``` shows "dist x z + dist y z <= e \ dist x y <= e" ``` hoelzl@51531 ` 1043` ```by (rule order_trans [OF dist_triangle2]) ``` hoelzl@51531 ` 1044` hoelzl@51531 ` 1045` ```lemma dist_triangle_lt: ``` hoelzl@51531 ` 1046` ``` shows "dist x z + dist y z < e ==> dist x y < e" ``` hoelzl@51531 ` 1047` ```by (rule le_less_trans [OF dist_triangle2]) ``` hoelzl@51531 ` 1048` hoelzl@51531 ` 1049` ```lemma dist_triangle_half_l: ``` hoelzl@51531 ` 1050` ``` shows "dist x1 y < e / 2 \ dist x2 y < e / 2 \ dist x1 x2 < e" ``` hoelzl@51531 ` 1051` ```by (rule dist_triangle_lt [where z=y], simp) ``` hoelzl@51531 ` 1052` hoelzl@51531 ` 1053` ```lemma dist_triangle_half_r: ``` hoelzl@51531 ` 1054` ``` shows "dist y x1 < e / 2 \ dist y x2 < e / 2 \ dist x1 x2 < e" ``` hoelzl@51531 ` 1055` ```by (rule dist_triangle_half_l, simp_all add: dist_commute) ``` hoelzl@51531 ` 1056` hoelzl@51531 ` 1057` ```subclass topological_space ``` hoelzl@51531 ` 1058` ```proof ``` hoelzl@51531 ` 1059` ``` have "\e::real. 0 < e" ``` hoelzl@51531 ` 1060` ``` by (fast intro: zero_less_one) ``` hoelzl@51531 ` 1061` ``` then show "open UNIV" ``` hoelzl@51531 ` 1062` ``` unfolding open_dist by simp ``` hoelzl@51531 ` 1063` ```next ``` hoelzl@51531 ` 1064` ``` fix S T assume "open S" "open T" ``` hoelzl@51531 ` 1065` ``` then show "open (S \ T)" ``` hoelzl@51531 ` 1066` ``` unfolding open_dist ``` hoelzl@51531 ` 1067` ``` apply clarify ``` hoelzl@51531 ` 1068` ``` apply (drule (1) bspec)+ ``` hoelzl@51531 ` 1069` ``` apply (clarify, rename_tac r s) ``` hoelzl@51531 ` 1070` ``` apply (rule_tac x="min r s" in exI, simp) ``` hoelzl@51531 ` 1071` ``` done ``` hoelzl@51531 ` 1072` ```next ``` hoelzl@51531 ` 1073` ``` fix K assume "\S\K. open S" thus "open (\K)" ``` hoelzl@51531 ` 1074` ``` unfolding open_dist by fast ``` hoelzl@51531 ` 1075` ```qed ``` hoelzl@51531 ` 1076` hoelzl@51531 ` 1077` ```lemma open_ball: "open {y. dist x y < d}" ``` hoelzl@51531 ` 1078` ```proof (unfold open_dist, intro ballI) ``` hoelzl@51531 ` 1079` ``` fix y assume *: "y \ {y. dist x y < d}" ``` hoelzl@51531 ` 1080` ``` then show "\e>0. \z. dist z y < e \ z \ {y. dist x y < d}" ``` hoelzl@51531 ` 1081` ``` by (auto intro!: exI[of _ "d - dist x y"] simp: field_simps dist_triangle_lt) ``` hoelzl@51531 ` 1082` ```qed ``` hoelzl@51531 ` 1083` hoelzl@51531 ` 1084` ```subclass first_countable_topology ``` hoelzl@51531 ` 1085` ```proof ``` lp15@60026 ` 1086` ``` fix x ``` hoelzl@51531 ` 1087` ``` show "\A::nat \ 'a set. (\i. x \ A i \ open (A i)) \ (\S. open S \ x \ S \ (\i. A i \ S))" ``` hoelzl@51531 ` 1088` ``` proof (safe intro!: exI[of _ "\n. {y. dist x y < inverse (Suc n)}"]) ``` hoelzl@51531 ` 1089` ``` fix S assume "open S" "x \ S" ``` wenzelm@53374 ` 1090` ``` then obtain e where e: "0 < e" and "{y. dist x y < e} \ S" ``` hoelzl@51531 ` 1091` ``` by (auto simp: open_dist subset_eq dist_commute) ``` hoelzl@51531 ` 1092` ``` moreover ``` wenzelm@53374 ` 1093` ``` from e obtain i where "inverse (Suc i) < e" ``` hoelzl@51531 ` 1094` ``` by (auto dest!: reals_Archimedean) ``` hoelzl@51531 ` 1095` ``` then have "{y. dist x y < inverse (Suc i)} \ {y. dist x y < e}" ``` hoelzl@51531 ` 1096` ``` by auto ``` hoelzl@51531 ` 1097` ``` ultimately show "\i. {y. dist x y < inverse (Suc i)} \ S" ``` hoelzl@51531 ` 1098` ``` by blast ``` hoelzl@51531 ` 1099` ``` qed (auto intro: open_ball) ``` hoelzl@51531 ` 1100` ```qed ``` hoelzl@51531 ` 1101` hoelzl@51531 ` 1102` ```end ``` hoelzl@51531 ` 1103` hoelzl@51531 ` 1104` ```instance metric_space \ t2_space ``` hoelzl@51531 ` 1105` ```proof ``` hoelzl@51531 ` 1106` ``` fix x y :: "'a::metric_space" ``` hoelzl@51531 ` 1107` ``` assume xy: "x \ y" ``` hoelzl@51531 ` 1108` ``` let ?U = "{y'. dist x y' < dist x y / 2}" ``` hoelzl@51531 ` 1109` ``` let ?V = "{x'. dist y x' < dist x y / 2}" ``` hoelzl@51531 ` 1110` ``` have th0: "\d x y z. (d x z :: real) \ d x y + d y z \ d y z = d z y ``` hoelzl@51531 ` 1111` ``` \ \(d x y * 2 < d x z \ d z y * 2 < d x z)" by arith ``` hoelzl@51531 ` 1112` ``` have "open ?U \ open ?V \ x \ ?U \ y \ ?V \ ?U \ ?V = {}" ``` hoelzl@51531 ` 1113` ``` using dist_pos_lt[OF xy] th0[of dist, OF dist_triangle dist_commute] ``` hoelzl@51531 ` 1114` ``` using open_ball[of _ "dist x y / 2"] by auto ``` hoelzl@51531 ` 1115` ``` then show "\U V. open U \ open V \ x \ U \ y \ V \ U \ V = {}" ``` hoelzl@51531 ` 1116` ``` by blast ``` hoelzl@51531 ` 1117` ```qed ``` hoelzl@51531 ` 1118` wenzelm@60758 ` 1119` ```text \Every normed vector space is a metric space.\ ``` huffman@31285 ` 1120` huffman@31289 ` 1121` ```instance real_normed_vector < metric_space ``` huffman@31289 ` 1122` ```proof ``` huffman@31289 ` 1123` ``` fix x y :: 'a show "dist x y = 0 \ x = y" ``` huffman@31289 ` 1124` ``` unfolding dist_norm by simp ``` huffman@31289 ` 1125` ```next ``` huffman@31289 ` 1126` ``` fix x y z :: 'a show "dist x y \ dist x z + dist y z" ``` huffman@31289 ` 1127` ``` unfolding dist_norm ``` huffman@31289 ` 1128` ``` using norm_triangle_ineq4 [of "x - z" "y - z"] by simp ``` huffman@31289 ` 1129` ```qed ``` huffman@31285 ` 1130` wenzelm@60758 ` 1131` ```subsection \Class instances for real numbers\ ``` huffman@31564 ` 1132` huffman@31564 ` 1133` ```instantiation real :: real_normed_field ``` huffman@31564 ` 1134` ```begin ``` huffman@31564 ` 1135` hoelzl@51531 ` 1136` ```definition dist_real_def: ``` hoelzl@51531 ` 1137` ``` "dist x y = \x - y\" ``` hoelzl@51531 ` 1138` haftmann@52381 ` 1139` ```definition open_real_def [code del]: ``` hoelzl@51531 ` 1140` ``` "open (S :: real set) \ (\x\S. \e>0. \y. dist y x < e \ y \ S)" ``` hoelzl@51531 ` 1141` huffman@31564 ` 1142` ```definition real_norm_def [simp]: ``` huffman@31564 ` 1143` ``` "norm r = \r\" ``` huffman@31564 ` 1144` huffman@31564 ` 1145` ```instance ``` huffman@31564 ` 1146` ```apply (intro_classes, unfold real_norm_def real_scaleR_def) ``` huffman@31564 ` 1147` ```apply (rule dist_real_def) ``` hoelzl@51531 ` 1148` ```apply (rule open_real_def) ``` huffman@36795 ` 1149` ```apply (simp add: sgn_real_def) ``` huffman@31564 ` 1150` ```apply (rule abs_eq_0) ``` huffman@31564 ` 1151` ```apply (rule abs_triangle_ineq) ``` huffman@31564 ` 1152` ```apply (rule abs_mult) ``` huffman@31564 ` 1153` ```apply (rule abs_mult) ``` huffman@31564 ` 1154` ```done ``` huffman@31564 ` 1155` huffman@31564 ` 1156` ```end ``` huffman@31564 ` 1157` lp15@60800 ` 1158` ```lemma dist_of_real [simp]: ``` lp15@60800 ` 1159` ``` fixes a :: "'a::real_normed_div_algebra" ``` lp15@60800 ` 1160` ``` shows "dist (of_real x :: 'a) (of_real y) = dist x y" ``` lp15@60800 ` 1161` ```by (metis dist_norm norm_of_real of_real_diff real_norm_def) ``` lp15@60800 ` 1162` haftmann@54890 ` 1163` ```declare [[code abort: "open :: real set \ bool"]] ``` haftmann@52381 ` 1164` hoelzl@51531 ` 1165` ```instance real :: linorder_topology ``` hoelzl@51531 ` 1166` ```proof ``` hoelzl@51531 ` 1167` ``` show "(open :: real set \ bool) = generate_topology (range lessThan \ range greaterThan)" ``` hoelzl@51531 ` 1168` ``` proof (rule ext, safe) ``` hoelzl@51531 ` 1169` ``` fix S :: "real set" assume "open S" ``` wenzelm@53381 ` 1170` ``` then obtain f where "\x\S. 0 < f x \ (\y. dist y x < f x \ y \ S)" ``` wenzelm@53381 ` 1171` ``` unfolding open_real_def bchoice_iff .. ``` hoelzl@51531 ` 1172` ``` then have *: "S = (\x\S. {x - f x <..} \ {..< x + f x})" ``` hoelzl@51531 ` 1173` ``` by (fastforce simp: dist_real_def) ``` hoelzl@51531 ` 1174` ``` show "generate_topology (range lessThan \ range greaterThan) S" ``` hoelzl@51531 ` 1175` ``` apply (subst *) ``` hoelzl@51531 ` 1176` ``` apply (intro generate_topology_Union generate_topology.Int) ``` hoelzl@51531 ` 1177` ``` apply (auto intro: generate_topology.Basis) ``` hoelzl@51531 ` 1178` ``` done ``` hoelzl@51531 ` 1179` ``` next ``` hoelzl@51531 ` 1180` ``` fix S :: "real set" assume "generate_topology (range lessThan \ range greaterThan) S" ``` hoelzl@51531 ` 1181` ``` moreover have "\a::real. open {.. (\y. \y - x\ < a - x \ y \ {..e>0. \y. \y - x\ < e \ y \ {..a::real. open {a <..}" ``` hoelzl@51531 ` 1189` ``` unfolding open_real_def dist_real_def ``` hoelzl@51531 ` 1190` ``` proof clarify ``` hoelzl@51531 ` 1191` ``` fix x a :: real assume "a < x" ``` hoelzl@51531 ` 1192` ``` hence "0 < x - a \ (\y. \y - x\ < x - a \ y \ {a<..})" by auto ``` hoelzl@51531 ` 1193` ``` thus "\e>0. \y. \y - x\ < e \ y \ {a<..}" .. ``` hoelzl@51531 ` 1194` ``` qed ``` hoelzl@51531 ` 1195` ``` ultimately show "open S" ``` hoelzl@51531 ` 1196` ``` by induct auto ``` hoelzl@51531 ` 1197` ``` qed ``` hoelzl@51531 ` 1198` ```qed ``` hoelzl@51531 ` 1199` hoelzl@51775 ` 1200` ```instance real :: linear_continuum_topology .. ``` hoelzl@51518 ` 1201` hoelzl@51531 ` 1202` ```lemmas open_real_greaterThan = open_greaterThan[where 'a=real] ``` hoelzl@51531 ` 1203` ```lemmas open_real_lessThan = open_lessThan[where 'a=real] ``` hoelzl@51531 ` 1204` ```lemmas open_real_greaterThanLessThan = open_greaterThanLessThan[where 'a=real] ``` hoelzl@51531 ` 1205` ```lemmas closed_real_atMost = closed_atMost[where 'a=real] ``` hoelzl@51531 ` 1206` ```lemmas closed_real_atLeast = closed_atLeast[where 'a=real] ``` hoelzl@51531 ` 1207` ```lemmas closed_real_atLeastAtMost = closed_atLeastAtMost[where 'a=real] ``` hoelzl@51531 ` 1208` wenzelm@60758 ` 1209` ```subsection \Extra type constraints\ ``` huffman@31446 ` 1210` wenzelm@60758 ` 1211` ```text \Only allow @{term "open"} in class @{text topological_space}.\ ``` huffman@31492 ` 1212` wenzelm@60758 ` 1213` ```setup \Sign.add_const_constraint ``` wenzelm@60758 ` 1214` ``` (@{const_name "open"}, SOME @{typ "'a::topological_space set \ bool"})\ ``` huffman@31492 ` 1215` wenzelm@60758 ` 1216` ```text \Only allow @{term dist} in class @{text metric_space}.\ ``` huffman@31446 ` 1217` wenzelm@60758 ` 1218` ```setup \Sign.add_const_constraint ``` wenzelm@60758 ` 1219` ``` (@{const_name dist}, SOME @{typ "'a::metric_space \ 'a \ real"})\ ``` huffman@31446 ` 1220` wenzelm@60758 ` 1221` ```text \Only allow @{term norm} in class @{text real_normed_vector}.\ ``` huffman@31446 ` 1222` wenzelm@60758 ` 1223` ```setup \Sign.add_const_constraint ``` wenzelm@60758 ` 1224` ``` (@{const_name norm}, SOME @{typ "'a::real_normed_vector \ real"})\ ``` huffman@31446 ` 1225` wenzelm@60758 ` 1226` ```subsection \Sign function\ ``` huffman@22972 ` 1227` nipkow@24506 ` 1228` ```lemma norm_sgn: ``` nipkow@24506 ` 1229` ``` "norm (sgn(x::'a::real_normed_vector)) = (if x = 0 then 0 else 1)" ``` huffman@31586 ` 1230` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 1231` nipkow@24506 ` 1232` ```lemma sgn_zero [simp]: "sgn(0::'a::real_normed_vector) = 0" ``` nipkow@24506 ` 1233` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 1234` nipkow@24506 ` 1235` ```lemma sgn_zero_iff: "(sgn(x::'a::real_normed_vector) = 0) = (x = 0)" ``` nipkow@24506 ` 1236` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 1237` nipkow@24506 ` 1238` ```lemma sgn_minus: "sgn (- x) = - sgn(x::'a::real_normed_vector)" ``` nipkow@24506 ` 1239` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 1240` nipkow@24506 ` 1241` ```lemma sgn_scaleR: ``` nipkow@24506 ` 1242` ``` "sgn (scaleR r x) = scaleR (sgn r) (sgn(x::'a::real_normed_vector))" ``` haftmann@57514 ` 1243` ```by (simp add: sgn_div_norm ac_simps) ``` huffman@22973 ` 1244` huffman@22972 ` 1245` ```lemma sgn_one [simp]: "sgn (1::'a::real_normed_algebra_1) = 1" ``` nipkow@24506 ` 1246` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 1247` huffman@22972 ` 1248` ```lemma sgn_of_real: ``` huffman@22972 ` 1249` ``` "sgn (of_real r::'a::real_normed_algebra_1) = of_real (sgn r)" ``` huffman@22972 ` 1250` ```unfolding of_real_def by (simp only: sgn_scaleR sgn_one) ``` huffman@22972 ` 1251` huffman@22973 ` 1252` ```lemma sgn_mult: ``` huffman@22973 ` 1253` ``` fixes x y :: "'a::real_normed_div_algebra" ``` huffman@22973 ` 1254` ``` shows "sgn (x * y) = sgn x * sgn y" ``` haftmann@57512 ` 1255` ```by (simp add: sgn_div_norm norm_mult mult.commute) ``` huffman@22973 ` 1256` huffman@22972 ` 1257` ```lemma real_sgn_eq: "sgn (x::real) = x / \x\" ``` nipkow@24506 ` 1258` ```by (simp add: sgn_div_norm divide_inverse) ``` huffman@22972 ` 1259` huffman@22972 ` 1260` ```lemma real_sgn_pos: "0 < (x::real) \ sgn x = 1" ``` hoelzl@56479 ` 1261` ```unfolding real_sgn_eq by simp ``` huffman@22972 ` 1262` huffman@22972 ` 1263` ```lemma real_sgn_neg: "(x::real) < 0 \ sgn x = -1" ``` hoelzl@56479 ` 1264` ```unfolding real_sgn_eq by simp ``` huffman@22972 ` 1265` hoelzl@56889 ` 1266` ```lemma zero_le_sgn_iff [simp]: "0 \ sgn x \ 0 \ (x::real)" ``` hoelzl@56889 ` 1267` ``` by (cases "0::real" x rule: linorder_cases) simp_all ``` lp15@60026 ` 1268` hoelzl@56889 ` 1269` ```lemma zero_less_sgn_iff [simp]: "0 < sgn x \ 0 < (x::real)" ``` hoelzl@56889 ` 1270` ``` by (cases "0::real" x rule: linorder_cases) simp_all ``` hoelzl@56889 ` 1271` hoelzl@56889 ` 1272` ```lemma sgn_le_0_iff [simp]: "sgn x \ 0 \ (x::real) \ 0" ``` hoelzl@56889 ` 1273` ``` by (cases "0::real" x rule: linorder_cases) simp_all ``` lp15@60026 ` 1274` hoelzl@56889 ` 1275` ```lemma sgn_less_0_iff [simp]: "sgn x < 0 \ (x::real) < 0" ``` hoelzl@56889 ` 1276` ``` by (cases "0::real" x rule: linorder_cases) simp_all ``` hoelzl@56889 ` 1277` hoelzl@51474 ` 1278` ```lemma norm_conv_dist: "norm x = dist x 0" ``` hoelzl@51474 ` 1279` ``` unfolding dist_norm by simp ``` huffman@22972 ` 1280` lp15@60307 ` 1281` ```lemma dist_diff [simp]: "dist a (a - b) = norm b" "dist (a - b) a = norm b" ``` lp15@60307 ` 1282` ``` by (simp_all add: dist_norm) ``` lp15@60307 ` 1283` ``` ``` wenzelm@60758 ` 1284` ```subsection \Bounded Linear and Bilinear Operators\ ``` huffman@22442 ` 1285` huffman@53600 ` 1286` ```locale linear = additive f for f :: "'a::real_vector \ 'b::real_vector" + ``` huffman@22442 ` 1287` ``` assumes scaleR: "f (scaleR r x) = scaleR r (f x)" ``` huffman@53600 ` 1288` lp15@60800 ` 1289` ```lemma linear_imp_scaleR: ``` lp15@60800 ` 1290` ``` assumes "linear D" obtains d where "D = (\x. x *\<^sub>R d)" ``` lp15@60800 ` 1291` ``` by (metis assms linear.scaleR mult.commute mult.left_neutral real_scaleR_def) ``` lp15@60800 ` 1292` huffman@53600 ` 1293` ```lemma linearI: ``` huffman@53600 ` 1294` ``` assumes "\x y. f (x + y) = f x + f y" ``` huffman@53600 ` 1295` ``` assumes "\c x. f (c *\<^sub>R x) = c *\<^sub>R f x" ``` huffman@53600 ` 1296` ``` shows "linear f" ``` huffman@53600 ` 1297` ``` by default (rule assms)+ ``` huffman@53600 ` 1298` huffman@53600 ` 1299` ```locale bounded_linear = linear f for f :: "'a::real_normed_vector \ 'b::real_normed_vector" + ``` huffman@22442 ` 1300` ``` assumes bounded: "\K. \x. norm (f x) \ norm x * K" ``` huffman@27443 ` 1301` ```begin ``` huffman@22442 ` 1302` huffman@27443 ` 1303` ```lemma pos_bounded: ``` huffman@22442 ` 1304` ``` "\K>0. \x. norm (f x) \ norm x * K" ``` huffman@22442 ` 1305` ```proof - ``` huffman@22442 ` 1306` ``` obtain K where K: "\x. norm (f x) \ norm x * K" ``` huffman@22442 ` 1307` ``` using bounded by fast ``` huffman@22442 ` 1308` ``` show ?thesis ``` huffman@22442 ` 1309` ``` proof (intro exI impI conjI allI) ``` huffman@22442 ` 1310` ``` show "0 < max 1 K" ``` haftmann@54863 ` 1311` ``` by (rule order_less_le_trans [OF zero_less_one max.cobounded1]) ``` huffman@22442 ` 1312` ``` next ``` huffman@22442 ` 1313` ``` fix x ``` huffman@22442 ` 1314` ``` have "norm (f x) \ norm x * K" using K . ``` huffman@22442 ` 1315` ``` also have "\ \ norm x * max 1 K" ``` haftmann@54863 ` 1316` ``` by (rule mult_left_mono [OF max.cobounded2 norm_ge_zero]) ``` huffman@22442 ` 1317` ``` finally show "norm (f x) \ norm x * max 1 K" . ``` huffman@22442 ` 1318` ``` qed ``` huffman@22442 ` 1319` ```qed ``` huffman@22442 ` 1320` huffman@27443 ` 1321` ```lemma nonneg_bounded: ``` huffman@22442 ` 1322` ``` "\K\0. \x. norm (f x) \ norm x * K" ``` huffman@22442 ` 1323` ```proof - ``` huffman@22442 ` 1324` ``` from pos_bounded ``` huffman@22442 ` 1325` ``` show ?thesis by (auto intro: order_less_imp_le) ``` huffman@22442 ` 1326` ```qed ``` huffman@22442 ` 1327` hoelzl@56369 ` 1328` ```lemma linear: "linear f" .. ``` hoelzl@56369 ` 1329` huffman@27443 ` 1330` ```end ``` huffman@27443 ` 1331` huffman@44127 ` 1332` ```lemma bounded_linear_intro: ``` huffman@44127 ` 1333` ``` assumes "\x y. f (x + y) = f x + f y" ``` huffman@44127 ` 1334` ``` assumes "\r x. f (scaleR r x) = scaleR r (f x)" ``` huffman@44127 ` 1335` ``` assumes "\x. norm (f x) \ norm x * K" ``` huffman@44127 ` 1336` ``` shows "bounded_linear f" ``` huffman@44127 ` 1337` ``` by default (fast intro: assms)+ ``` huffman@44127 ` 1338` huffman@22442 ` 1339` ```locale bounded_bilinear = ``` huffman@22442 ` 1340` ``` fixes prod :: "['a::real_normed_vector, 'b::real_normed_vector] ``` huffman@22442 ` 1341` ``` \ 'c::real_normed_vector" ``` huffman@22442 ` 1342` ``` (infixl "**" 70) ``` huffman@22442 ` 1343` ``` assumes add_left: "prod (a + a') b = prod a b + prod a' b" ``` huffman@22442 ` 1344` ``` assumes add_right: "prod a (b + b') = prod a b + prod a b'" ``` huffman@22442 ` 1345` ``` assumes scaleR_left: "prod (scaleR r a) b = scaleR r (prod a b)" ``` huffman@22442 ` 1346` ``` assumes scaleR_right: "prod a (scaleR r b) = scaleR r (prod a b)" ``` huffman@22442 ` 1347` ``` assumes bounded: "\K. \a b. norm (prod a b) \ norm a * norm b * K" ``` huffman@27443 ` 1348` ```begin ``` huffman@22442 ` 1349` huffman@27443 ` 1350` ```lemma pos_bounded: ``` huffman@22442 ` 1351` ``` "\K>0. \a b. norm (a ** b) \ norm a * norm b * K" ``` huffman@22442 ` 1352` ```apply (cut_tac bounded, erule exE) ``` huffman@22442 ` 1353` ```apply (rule_tac x="max 1 K" in exI, safe) ``` haftmann@54863 ` 1354` ```apply (rule order_less_le_trans [OF zero_less_one max.cobounded1]) ``` huffman@22442 ` 1355` ```apply (drule spec, drule spec, erule order_trans) ``` haftmann@54863 ` 1356` ```apply (rule mult_left_mono [OF max.cobounded2]) ``` huffman@22442 ` 1357` ```apply (intro mult_nonneg_nonneg norm_ge_zero) ``` huffman@22442 ` 1358` ```done ``` huffman@22442 ` 1359` huffman@27443 ` 1360` ```lemma nonneg_bounded: ``` huffman@22442 ` 1361` ``` "\K\0. \a b. norm (a ** b) \ norm a * norm b * K" ``` huffman@22442 ` 1362` ```proof - ``` huffman@22442 ` 1363` ``` from pos_bounded ``` huffman@22442 ` 1364` ``` show ?thesis by (auto intro: order_less_imp_le) ``` huffman@22442 ` 1365` ```qed ``` huffman@22442 ` 1366` huffman@27443 ` 1367` ```lemma additive_right: "additive (\b. prod a b)" ``` huffman@22442 ` 1368` ```by (rule additive.intro, rule add_right) ``` huffman@22442 ` 1369` huffman@27443 ` 1370` ```lemma additive_left: "additive (\a. prod a b)" ``` huffman@22442 ` 1371` ```by (rule additive.intro, rule add_left) ``` huffman@22442 ` 1372` huffman@27443 ` 1373` ```lemma zero_left: "prod 0 b = 0" ``` huffman@22442 ` 1374` ```by (rule additive.zero [OF additive_left]) ``` huffman@22442 ` 1375` huffman@27443 ` 1376` ```lemma zero_right: "prod a 0 = 0" ``` huffman@22442 ` 1377` ```by (rule additive.zero [OF additive_right]) ``` huffman@22442 ` 1378` huffman@27443 ` 1379` ```lemma minus_left: "prod (- a) b = - prod a b" ``` huffman@22442 ` 1380` ```by (rule additive.minus [OF additive_left]) ``` huffman@22442 ` 1381` huffman@27443 ` 1382` ```lemma minus_right: "prod a (- b) = - prod a b" ``` huffman@22442 ` 1383` ```by (rule additive.minus [OF additive_right]) ``` huffman@22442 ` 1384` huffman@27443 ` 1385` ```lemma diff_left: ``` huffman@22442 ` 1386` ``` "prod (a - a') b = prod a b - prod a' b" ``` huffman@22442 ` 1387` ```by (rule additive.diff [OF additive_left]) ``` huffman@22442 ` 1388` huffman@27443 ` 1389` ```lemma diff_right: ``` huffman@22442 ` 1390` ``` "prod a (b - b') = prod a b - prod a b'" ``` huffman@22442 ` 1391` ```by (rule additive.diff [OF additive_right]) ``` huffman@22442 ` 1392` huffman@27443 ` 1393` ```lemma bounded_linear_left: ``` huffman@22442 ` 1394` ``` "bounded_linear (\a. a ** b)" ``` huffman@44127 ` 1395` ```apply (cut_tac bounded, safe) ``` huffman@44127 ` 1396` ```apply (rule_tac K="norm b * K" in bounded_linear_intro) ``` huffman@22442 ` 1397` ```apply (rule add_left) ``` huffman@22442 ` 1398` ```apply (rule scaleR_left) ``` haftmann@57514 ` 1399` ```apply (simp add: ac_simps) ``` huffman@22442 ` 1400` ```done ``` huffman@22442 ` 1401` huffman@27443 ` 1402` ```lemma bounded_linear_right: ``` huffman@22442 ` 1403` ``` "bounded_linear (\b. a ** b)" ``` huffman@44127 ` 1404` ```apply (cut_tac bounded, safe) ``` huffman@44127 ` 1405` ```apply (rule_tac K="norm a * K" in bounded_linear_intro) ``` huffman@22442 ` 1406` ```apply (rule add_right) ``` huffman@22442 ` 1407` ```apply (rule scaleR_right) ``` haftmann@57514 ` 1408` ```apply (simp add: ac_simps) ``` huffman@22442 ` 1409` ```done ``` huffman@22442 ` 1410` huffman@27443 ` 1411` ```lemma prod_diff_prod: ``` huffman@22442 ` 1412` ``` "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)" ``` huffman@22442 ` 1413` ```by (simp add: diff_left diff_right) ``` huffman@22442 ` 1414` huffman@27443 ` 1415` ```end ``` huffman@27443 ` 1416` hoelzl@51642 ` 1417` ```lemma bounded_linear_ident[simp]: "bounded_linear (\x. x)" ``` hoelzl@51642 ` 1418` ``` by default (auto intro!: exI[of _ 1]) ``` hoelzl@51642 ` 1419` hoelzl@51642 ` 1420` ```lemma bounded_linear_zero[simp]: "bounded_linear (\x. 0)" ``` hoelzl@51642 ` 1421` ``` by default (auto intro!: exI[of _ 1]) ``` hoelzl@51642 ` 1422` hoelzl@51642 ` 1423` ```lemma bounded_linear_add: ``` hoelzl@51642 ` 1424` ``` assumes "bounded_linear f" ``` hoelzl@51642 ` 1425` ``` assumes "bounded_linear g" ``` hoelzl@51642 ` 1426` ``` shows "bounded_linear (\x. f x + g x)" ``` hoelzl@51642 ` 1427` ```proof - ``` hoelzl@51642 ` 1428` ``` interpret f: bounded_linear f by fact ``` hoelzl@51642 ` 1429` ``` interpret g: bounded_linear g by fact ``` hoelzl@51642 ` 1430` ``` show ?thesis ``` hoelzl@51642 ` 1431` ``` proof ``` hoelzl@51642 ` 1432` ``` from f.bounded obtain Kf where Kf: "\x. norm (f x) \ norm x * Kf" by blast ``` hoelzl@51642 ` 1433` ``` from g.bounded obtain Kg where Kg: "\x. norm (g x) \ norm x * Kg" by blast ``` hoelzl@51642 ` 1434` ``` show "\K. \x. norm (f x + g x) \ norm x * K" ``` hoelzl@51642 ` 1435` ``` using add_mono[OF Kf Kg] ``` hoelzl@51642 ` 1436` ``` by (intro exI[of _ "Kf + Kg"]) (auto simp: field_simps intro: norm_triangle_ineq order_trans) ``` hoelzl@51642 ` 1437` ``` qed (simp_all add: f.add g.add f.scaleR g.scaleR scaleR_right_distrib) ``` hoelzl@51642 ` 1438` ```qed ``` hoelzl@51642 ` 1439` hoelzl@51642 ` 1440` ```lemma bounded_linear_minus: ``` hoelzl@51642 ` 1441` ``` assumes "bounded_linear f" ``` hoelzl@51642 ` 1442` ``` shows "bounded_linear (\x. - f x)" ``` hoelzl@51642 ` 1443` ```proof - ``` hoelzl@51642 ` 1444` ``` interpret f: bounded_linear f by fact ``` hoelzl@51642 ` 1445` ``` show ?thesis apply (unfold_locales) ``` hoelzl@51642 ` 1446` ``` apply (simp add: f.add) ``` hoelzl@51642 ` 1447` ``` apply (simp add: f.scaleR) ``` hoelzl@51642 ` 1448` ``` apply (simp add: f.bounded) ``` hoelzl@51642 ` 1449` ``` done ``` hoelzl@51642 ` 1450` ```qed ``` hoelzl@51642 ` 1451` hoelzl@51642 ` 1452` ```lemma bounded_linear_compose: ``` hoelzl@51642 ` 1453` ``` assumes "bounded_linear f" ``` hoelzl@51642 ` 1454` ``` assumes "bounded_linear g" ``` hoelzl@51642 ` 1455` ``` shows "bounded_linear (\x. f (g x))" ``` hoelzl@51642 ` 1456` ```proof - ``` hoelzl@51642 ` 1457` ``` interpret f: bounded_linear f by fact ``` hoelzl@51642 ` 1458` ``` interpret g: bounded_linear g by fact ``` hoelzl@51642 ` 1459` ``` show ?thesis proof (unfold_locales) ``` hoelzl@51642 ` 1460` ``` fix x y show "f (g (x + y)) = f (g x) + f (g y)" ``` hoelzl@51642 ` 1461` ``` by (simp only: f.add g.add) ``` hoelzl@51642 ` 1462` ``` next ``` hoelzl@51642 ` 1463` ``` fix r x show "f (g (scaleR r x)) = scaleR r (f (g x))" ``` hoelzl@51642 ` 1464` ``` by (simp only: f.scaleR g.scaleR) ``` hoelzl@51642 ` 1465` ``` next ``` hoelzl@51642 ` 1466` ``` from f.pos_bounded ``` hoelzl@51642 ` 1467` ``` obtain Kf where f: "\x. norm (f x) \ norm x * Kf" and Kf: "0 < Kf" by fast ``` hoelzl@51642 ` 1468` ``` from g.pos_bounded ``` hoelzl@51642 ` 1469` ``` obtain Kg where g: "\x. norm (g x) \ norm x * Kg" by fast ``` hoelzl@51642 ` 1470` ``` show "\K. \x. norm (f (g x)) \ norm x * K" ``` hoelzl@51642 ` 1471` ``` proof (intro exI allI) ``` hoelzl@51642 ` 1472` ``` fix x ``` hoelzl@51642 ` 1473` ``` have "norm (f (g x)) \ norm (g x) * Kf" ``` hoelzl@51642 ` 1474` ``` using f . ``` hoelzl@51642 ` 1475` ``` also have "\ \ (norm x * Kg) * Kf" ``` hoelzl@51642 ` 1476` ``` using g Kf [THEN order_less_imp_le] by (rule mult_right_mono) ``` hoelzl@51642 ` 1477` ``` also have "(norm x * Kg) * Kf = norm x * (Kg * Kf)" ``` haftmann@57512 ` 1478` ``` by (rule mult.assoc) ``` hoelzl@51642 ` 1479` ``` finally show "norm (f (g x)) \ norm x * (Kg * Kf)" . ``` hoelzl@51642 ` 1480` ``` qed ``` hoelzl@51642 ` 1481` ``` qed ``` hoelzl@51642 ` 1482` ```qed ``` hoelzl@51642 ` 1483` huffman@44282 ` 1484` ```lemma bounded_bilinear_mult: ``` huffman@44282 ` 1485` ``` "bounded_bilinear (op * :: 'a \ 'a \ 'a::real_normed_algebra)" ``` huffman@22442 ` 1486` ```apply (rule bounded_bilinear.intro) ``` webertj@49962 ` 1487` ```apply (rule distrib_right) ``` webertj@49962 ` 1488` ```apply (rule distrib_left) ``` huffman@22442 ` 1489` ```apply (rule mult_scaleR_left) ``` huffman@22442 ` 1490` ```apply (rule mult_scaleR_right) ``` huffman@22442 ` 1491` ```apply (rule_tac x="1" in exI) ``` huffman@22442 ` 1492` ```apply (simp add: norm_mult_ineq) ``` huffman@22442 ` 1493` ```done ``` huffman@22442 ` 1494` huffman@44282 ` 1495` ```lemma bounded_linear_mult_left: ``` huffman@44282 ` 1496` ``` "bounded_linear (\x::'a::real_normed_algebra. x * y)" ``` huffman@44282 ` 1497` ``` using bounded_bilinear_mult ``` huffman@44282 ` 1498` ``` by (rule bounded_bilinear.bounded_linear_left) ``` huffman@22442 ` 1499` huffman@44282 ` 1500` ```lemma bounded_linear_mult_right: ``` huffman@44282 ` 1501` ``` "bounded_linear (\y::'a::real_normed_algebra. x * y)" ``` huffman@44282 ` 1502` ``` using bounded_bilinear_mult ``` huffman@44282 ` 1503` ``` by (rule bounded_bilinear.bounded_linear_right) ``` huffman@23127 ` 1504` hoelzl@51642 ` 1505` ```lemmas bounded_linear_mult_const = ``` hoelzl@51642 ` 1506` ``` bounded_linear_mult_left [THEN bounded_linear_compose] ``` hoelzl@51642 ` 1507` hoelzl@51642 ` 1508` ```lemmas bounded_linear_const_mult = ``` hoelzl@51642 ` 1509` ``` bounded_linear_mult_right [THEN bounded_linear_compose] ``` hoelzl@51642 ` 1510` huffman@44282 ` 1511` ```lemma bounded_linear_divide: ``` huffman@44282 ` 1512` ``` "bounded_linear (\x::'a::real_normed_field. x / y)" ``` huffman@44282 ` 1513` ``` unfolding divide_inverse by (rule bounded_linear_mult_left) ``` huffman@23120 ` 1514` huffman@44282 ` 1515` ```lemma bounded_bilinear_scaleR: "bounded_bilinear scaleR" ``` huffman@22442 ` 1516` ```apply (rule bounded_bilinear.intro) ``` huffman@22442 ` 1517` ```apply (rule scaleR_left_distrib) ``` huffman@22442 ` 1518` ```apply (rule scaleR_right_distrib) ``` huffman@22973 ` 1519` ```apply simp ``` huffman@22442 ` 1520` ```apply (rule scaleR_left_commute) ``` huffman@31586 ` 1521` ```apply (rule_tac x="1" in exI, simp) ``` huffman@22442 ` 1522` ```done ``` huffman@22442 ` 1523` huffman@44282 ` 1524` ```lemma bounded_linear_scaleR_left: "bounded_linear (\r. scaleR r x)" ``` huffman@44282 ` 1525` ``` using bounded_bilinear_scaleR ``` huffman@44282 ` 1526` ``` by (rule bounded_bilinear.bounded_linear_left) ``` huffman@23127 ` 1527` huffman@44282 ` 1528` ```lemma bounded_linear_scaleR_right: "bounded_linear (\x. scaleR r x)" ``` huffman@44282 ` 1529` ``` using bounded_bilinear_scaleR ``` huffman@44282 ` 1530` ``` by (rule bounded_bilinear.bounded_linear_right) ``` huffman@23127 ` 1531` huffman@44282 ` 1532` ```lemma bounded_linear_of_real: "bounded_linear (\r. of_real r)" ``` huffman@44282 ` 1533` ``` unfolding of_real_def by (rule bounded_linear_scaleR_left) ``` huffman@22625 ` 1534` hoelzl@51642 ` 1535` ```lemma real_bounded_linear: ``` hoelzl@51642 ` 1536` ``` fixes f :: "real \ real" ``` hoelzl@51642 ` 1537` ``` shows "bounded_linear f \ (\c::real. f = (\x. x * c))" ``` hoelzl@51642 ` 1538` ```proof - ``` hoelzl@51642 ` 1539` ``` { fix x assume "bounded_linear f" ``` hoelzl@51642 ` 1540` ``` then interpret bounded_linear f . ``` hoelzl@51642 ` 1541` ``` from scaleR[of x 1] have "f x = x * f 1" ``` hoelzl@51642 ` 1542` ``` by simp } ``` hoelzl@51642 ` 1543` ``` then show ?thesis ``` hoelzl@51642 ` 1544` ``` by (auto intro: exI[of _ "f 1"] bounded_linear_mult_left) ``` hoelzl@51642 ` 1545` ```qed ``` hoelzl@51642 ` 1546` lp15@60800 ` 1547` ```lemma bij_linear_imp_inv_linear: ``` lp15@60800 ` 1548` ``` assumes "linear f" "bij f" shows "linear (inv f)" ``` lp15@60800 ` 1549` ``` using assms unfolding linear_def linear_axioms_def additive_def ``` lp15@60800 ` 1550` ``` by (auto simp: bij_is_surj bij_is_inj surj_f_inv_f intro!: Hilbert_Choice.inv_f_eq) ``` lp15@60800 ` 1551` ``` ``` huffman@44571 ` 1552` ```instance real_normed_algebra_1 \ perfect_space ``` huffman@44571 ` 1553` ```proof ``` huffman@44571 ` 1554` ``` fix x::'a ``` huffman@44571 ` 1555` ``` show "\ open {x}" ``` huffman@44571 ` 1556` ``` unfolding open_dist dist_norm ``` huffman@44571 ` 1557` ``` by (clarsimp, rule_tac x="x + of_real (e/2)" in exI, simp) ``` huffman@44571 ` 1558` ```qed ``` huffman@44571 ` 1559` wenzelm@60758 ` 1560` ```subsection \Filters and Limits on Metric Space\ ``` hoelzl@51531 ` 1561` hoelzl@57448 ` 1562` ```lemma (in metric_space) nhds_metric: "nhds x = (INF e:{0 <..}. principal {y. dist y x < e})" ``` hoelzl@57448 ` 1563` ``` unfolding nhds_def ``` hoelzl@57448 ` 1564` ```proof (safe intro!: INF_eq) ``` hoelzl@57448 ` 1565` ``` fix S assume "open S" "x \ S" ``` hoelzl@57448 ` 1566` ``` then obtain e where "{y. dist y x < e} \ S" "0 < e" ``` hoelzl@57448 ` 1567` ``` by (auto simp: open_dist subset_eq) ``` hoelzl@57448 ` 1568` ``` then show "\e\{0<..}. principal {y. dist y x < e} \ principal S" ``` hoelzl@57448 ` 1569` ``` by auto ``` hoelzl@57448 ` 1570` ```qed (auto intro!: exI[of _ "{y. dist x y < e}" for e] open_ball simp: dist_commute) ``` hoelzl@57448 ` 1571` hoelzl@57448 ` 1572` ```lemma (in metric_space) tendsto_iff: ``` hoelzl@57448 ` 1573` ``` "(f ---> l) F \ (\e>0. eventually (\x. dist (f x) l < e) F)" ``` hoelzl@57448 ` 1574` ``` unfolding nhds_metric filterlim_INF filterlim_principal by auto ``` hoelzl@57448 ` 1575` hoelzl@57448 ` 1576` ```lemma (in metric_space) tendstoI: "(\e. 0 < e \ eventually (\x. dist (f x) l < e) F) \ (f ---> l) F" ``` hoelzl@57448 ` 1577` ``` by (auto simp: tendsto_iff) ``` hoelzl@57448 ` 1578` hoelzl@57448 ` 1579` ```lemma (in metric_space) tendstoD: "(f ---> l) F \ 0 < e \ eventually (\x. dist (f x) l < e) F" ``` hoelzl@57448 ` 1580` ``` by (auto simp: tendsto_iff) ``` hoelzl@57448 ` 1581` hoelzl@57448 ` 1582` ```lemma (in metric_space) eventually_nhds_metric: ``` hoelzl@57448 ` 1583` ``` "eventually P (nhds a) \ (\d>0. \x. dist x a < d \ P x)" ``` hoelzl@57448 ` 1584` ``` unfolding nhds_metric ``` hoelzl@57448 ` 1585` ``` by (subst eventually_INF_base) ``` hoelzl@57448 ` 1586` ``` (auto simp: eventually_principal Bex_def subset_eq intro: exI[of _ "min a b" for a b]) ``` hoelzl@51531 ` 1587` hoelzl@51531 ` 1588` ```lemma eventually_at: ``` hoelzl@51641 ` 1589` ``` fixes a :: "'a :: metric_space" ``` hoelzl@51641 ` 1590` ``` shows "eventually P (at a within S) \ (\d>0. \x\S. x \ a \ dist x a < d \ P x)" ``` hoelzl@51641 ` 1591` ``` unfolding eventually_at_filter eventually_nhds_metric by (auto simp: dist_nz) ``` hoelzl@51531 ` 1592` hoelzl@51641 ` 1593` ```lemma eventually_at_le: ``` hoelzl@51641 ` 1594` ``` fixes a :: "'a::metric_space" ``` hoelzl@51641 ` 1595` ``` shows "eventually P (at a within S) \ (\d>0. \x\S. x \ a \ dist x a \ d \ P x)" ``` hoelzl@51641 ` 1596` ``` unfolding eventually_at_filter eventually_nhds_metric ``` hoelzl@51641 ` 1597` ``` apply auto ``` hoelzl@51641 ` 1598` ``` apply (rule_tac x="d / 2" in exI) ``` hoelzl@51641 ` 1599` ``` apply auto ``` hoelzl@51641 ` 1600` ``` done ``` hoelzl@51531 ` 1601` hoelzl@51531 ` 1602` ```lemma metric_tendsto_imp_tendsto: ``` hoelzl@51531 ` 1603` ``` fixes a :: "'a :: metric_space" and b :: "'b :: metric_space" ``` hoelzl@51531 ` 1604` ``` assumes f: "(f ---> a) F" ``` hoelzl@51531 ` 1605` ``` assumes le: "eventually (\x. dist (g x) b \ dist (f x) a) F" ``` hoelzl@51531 ` 1606` ``` shows "(g ---> b) F" ``` hoelzl@51531 ` 1607` ```proof (rule tendstoI) ``` hoelzl@51531 ` 1608` ``` fix e :: real assume "0 < e" ``` hoelzl@51531 ` 1609` ``` with f have "eventually (\x. dist (f x) a < e) F" by (rule tendstoD) ``` hoelzl@51531 ` 1610` ``` with le show "eventually (\x. dist (g x) b < e) F" ``` hoelzl@51531 ` 1611` ``` using le_less_trans by (rule eventually_elim2) ``` hoelzl@51531 ` 1612` ```qed ``` hoelzl@51531 ` 1613` hoelzl@51531 ` 1614` ```lemma filterlim_real_sequentially: "LIM x sequentially. real x :> at_top" ``` hoelzl@51531 ` 1615` ``` unfolding filterlim_at_top ``` hoelzl@51531 ` 1616` ``` apply (intro allI) ``` nipkow@59587 ` 1617` ``` apply (rule_tac c="nat(ceiling (Z + 1))" in eventually_sequentiallyI) ``` nipkow@59587 ` 1618` ``` by linarith ``` hoelzl@51531 ` 1619` wenzelm@60758 ` 1620` ```subsubsection \Limits of Sequences\ ``` hoelzl@51531 ` 1621` lp15@60017 ` 1622` ```lemma lim_sequentially: "X ----> (L::'a::metric_space) \ (\r>0. \no. \n\no. dist (X n) L < r)" ``` hoelzl@51531 ` 1623` ``` unfolding tendsto_iff eventually_sequentially .. ``` hoelzl@51531 ` 1624` lp15@60026 ` 1625` ```lemmas LIMSEQ_def = lim_sequentially (*legacy binding*) ``` lp15@60026 ` 1626` hoelzl@51531 ` 1627` ```lemma LIMSEQ_iff_nz: "X ----> (L::'a::metric_space) = (\r>0. \no>0. \n\no. dist (X n) L < r)" ``` lp15@60017 ` 1628` ``` unfolding lim_sequentially by (metis Suc_leD zero_less_Suc) ``` hoelzl@51531 ` 1629` hoelzl@51531 ` 1630` ```lemma metric_LIMSEQ_I: ``` hoelzl@51531 ` 1631` ``` "(\r. 0 < r \ \no. \n\no. dist (X n) L < r) \ X ----> (L::'a::metric_space)" ``` lp15@60017 ` 1632` ```by (simp add: lim_sequentially) ``` hoelzl@51531 ` 1633` hoelzl@51531 ` 1634` ```lemma metric_LIMSEQ_D: ``` hoelzl@51531 ` 1635` ``` "\X ----> (L::'a::metric_space); 0 < r\ \ \no. \n\no. dist (X n) L < r" ``` lp15@60017 ` 1636` ```by (simp add: lim_sequentially) ``` hoelzl@51531 ` 1637` hoelzl@51531 ` 1638` wenzelm@60758 ` 1639` ```subsubsection \Limits of Functions\ ``` hoelzl@51531 ` 1640` hoelzl@51531 ` 1641` ```lemma LIM_def: "f -- (a::'a::metric_space) --> (L::'b::metric_space) = ``` hoelzl@51531 ` 1642` ``` (\r > 0. \s > 0. \x. x \ a & dist x a < s ``` hoelzl@51531 ` 1643` ``` --> dist (f x) L < r)" ``` hoelzl@51641 ` 1644` ``` unfolding tendsto_iff eventually_at by simp ``` hoelzl@51531 ` 1645` hoelzl@51531 ` 1646` ```lemma metric_LIM_I: ``` hoelzl@51531 ` 1647` ``` "(\r. 0 < r \ \s>0. \x. x \ a \ dist x a < s \ dist (f x) L < r) ``` hoelzl@51531 ` 1648` ``` \ f -- (a::'a::metric_space) --> (L::'b::metric_space)" ``` hoelzl@51531 ` 1649` ```by (simp add: LIM_def) ``` hoelzl@51531 ` 1650` hoelzl@51531 ` 1651` ```lemma metric_LIM_D: ``` hoelzl@51531 ` 1652` ``` "\f -- (a::'a::metric_space) --> (L::'b::metric_space); 0 < r\ ``` hoelzl@51531 ` 1653` ``` \ \s>0. \x. x \ a \ dist x a < s \ dist (f x) L < r" ``` hoelzl@51531 ` 1654` ```by (simp add: LIM_def) ``` hoelzl@51531 ` 1655` hoelzl@51531 ` 1656` ```lemma metric_LIM_imp_LIM: ``` hoelzl@51531 ` 1657` ``` assumes f: "f -- a --> (l::'a::metric_space)" ``` hoelzl@51531 ` 1658` ``` assumes le: "\x. x \ a \ dist (g x) m \ dist (f x) l" ``` hoelzl@51531 ` 1659` ``` shows "g -- a --> (m::'b::metric_space)" ``` hoelzl@51531 ` 1660` ``` by (rule metric_tendsto_imp_tendsto [OF f]) (auto simp add: eventually_at_topological le) ``` hoelzl@51531 ` 1661` hoelzl@51531 ` 1662` ```lemma metric_LIM_equal2: ``` hoelzl@51531 ` 1663` ``` assumes 1: "0 < R" ``` hoelzl@51531 ` 1664` ``` assumes 2: "\x. \x \ a; dist x a < R\ \ f x = g x" ``` hoelzl@51531 ` 1665` ``` shows "g -- a --> l \ f -- (a::'a::metric_space) --> l" ``` hoelzl@51531 ` 1666` ```apply (rule topological_tendstoI) ``` hoelzl@51531 ` 1667` ```apply (drule (2) topological_tendstoD) ``` hoelzl@51531 ` 1668` ```apply (simp add: eventually_at, safe) ``` hoelzl@51531 ` 1669` ```apply (rule_tac x="min d R" in exI, safe) ``` hoelzl@51531 ` 1670` ```apply (simp add: 1) ``` hoelzl@51531 ` 1671` ```apply (simp add: 2) ``` hoelzl@51531 ` 1672` ```done ``` hoelzl@51531 ` 1673` hoelzl@51531 ` 1674` ```lemma metric_LIM_compose2: ``` hoelzl@51531 ` 1675` ``` assumes f: "f -- (a::'a::metric_space) --> b" ``` hoelzl@51531 ` 1676` ``` assumes g: "g -- b --> c" ``` hoelzl@51531 ` 1677` ``` assumes inj: "\d>0. \x. x \ a \ dist x a < d \ f x \ b" ``` hoelzl@51531 ` 1678` ``` shows "(\x. g (f x)) -- a --> c" ``` hoelzl@51641 ` 1679` ``` using inj ``` hoelzl@51641 ` 1680` ``` by (intro tendsto_compose_eventually[OF g f]) (auto simp: eventually_at) ``` hoelzl@51531 ` 1681` hoelzl@51531 ` 1682` ```lemma metric_isCont_LIM_compose2: ``` hoelzl@51531 ` 1683` ``` fixes f :: "'a :: metric_space \ _" ``` hoelzl@51531 ` 1684` ``` assumes f [unfolded isCont_def]: "isCont f a" ``` hoelzl@51531 ` 1685` ``` assumes g: "g -- f a --> l" ``` hoelzl@51531 ` 1686` ``` assumes inj: "\d>0. \x. x \ a \ dist x a < d \ f x \ f a" ``` hoelzl@51531 ` 1687` ``` shows "(\x. g (f x)) -- a --> l" ``` hoelzl@51531 ` 1688` ```by (rule metric_LIM_compose2 [OF f g inj]) ``` hoelzl@51531 ` 1689` wenzelm@60758 ` 1690` ```subsection \Complete metric spaces\ ``` hoelzl@51531 ` 1691` wenzelm@60758 ` 1692` ```subsection \Cauchy sequences\ ``` hoelzl@51531 ` 1693` hoelzl@51531 ` 1694` ```definition (in metric_space) Cauchy :: "(nat \ 'a) \ bool" where ``` hoelzl@51531 ` 1695` ``` "Cauchy X = (\e>0. \M. \m \ M. \n \ M. dist (X m) (X n) < e)" ``` hoelzl@51531 ` 1696` wenzelm@60758 ` 1697` ```subsection \Cauchy Sequences\ ``` hoelzl@51531 ` 1698` hoelzl@51531 ` 1699` ```lemma metric_CauchyI: ``` hoelzl@51531 ` 1700` ``` "(\e. 0 < e \ \M. \m\M. \n\M. dist (X m) (X n) < e) \ Cauchy X" ``` hoelzl@51531 ` 1701` ``` by (simp add: Cauchy_def) ``` hoelzl@51531 ` 1702` hoelzl@51531 ` 1703` ```lemma metric_CauchyD: ``` hoelzl@51531 ` 1704` ``` "Cauchy X \ 0 < e \ \M. \m\M. \n\M. dist (X m) (X n) < e" ``` hoelzl@51531 ` 1705` ``` by (simp add: Cauchy_def) ``` hoelzl@51531 ` 1706` hoelzl@51531 ` 1707` ```lemma metric_Cauchy_iff2: ``` hoelzl@51531 ` 1708` ``` "Cauchy X = (\j. (\M. \m \ M. \n \ M. dist (X m) (X n) < inverse(real (Suc j))))" ``` hoelzl@51531 ` 1709` ```apply (simp add: Cauchy_def, auto) ``` hoelzl@51531 ` 1710` ```apply (drule reals_Archimedean, safe) ``` hoelzl@51531 ` 1711` ```apply (drule_tac x = n in spec, auto) ``` hoelzl@51531 ` 1712` ```apply (rule_tac x = M in exI, auto) ``` hoelzl@51531 ` 1713` ```apply (drule_tac x = m in spec, simp) ``` hoelzl@51531 ` 1714` ```apply (drule_tac x = na in spec, auto) ``` hoelzl@51531 ` 1715` ```done ``` hoelzl@51531 ` 1716` hoelzl@51531 ` 1717` ```lemma Cauchy_iff2: ``` hoelzl@51531 ` 1718` ``` "Cauchy X = (\j. (\M. \m \ M. \n \ M. \X m - X n\ < inverse(real (Suc j))))" ``` hoelzl@51531 ` 1719` ``` unfolding metric_Cauchy_iff2 dist_real_def .. ``` hoelzl@51531 ` 1720` hoelzl@51531 ` 1721` ```lemma Cauchy_subseq_Cauchy: ``` hoelzl@51531 ` 1722` ``` "\ Cauchy X; subseq f \ \ Cauchy (X o f)" ``` hoelzl@51531 ` 1723` ```apply (auto simp add: Cauchy_def) ``` hoelzl@51531 ` 1724` ```apply (drule_tac x=e in spec, clarify) ``` hoelzl@51531 ` 1725` ```apply (rule_tac x=M in exI, clarify) ``` hoelzl@51531 ` 1726` ```apply (blast intro: le_trans [OF _ seq_suble] dest!: spec) ``` hoelzl@51531 ` 1727` ```done ``` hoelzl@51531 ` 1728` hoelzl@51531 ` 1729` ```theorem LIMSEQ_imp_Cauchy: ``` hoelzl@51531 ` 1730` ``` assumes X: "X ----> a" shows "Cauchy X" ``` hoelzl@51531 ` 1731` ```proof (rule metric_CauchyI) ``` hoelzl@51531 ` 1732` ``` fix e::real assume "0 < e" ``` hoelzl@51531 ` 1733` ``` hence "0 < e/2" by simp ``` hoelzl@51531 ` 1734` ``` with X have "\N. \n\N. dist (X n) a < e/2" by (rule metric_LIMSEQ_D) ``` hoelzl@51531 ` 1735` ``` then obtain N where N: "\n\N. dist (X n) a < e/2" .. ``` hoelzl@51531 ` 1736` ``` show "\N. \m\N. \n\N. dist (X m) (X n) < e" ``` hoelzl@51531 ` 1737` ``` proof (intro exI allI impI) ``` hoelzl@51531 ` 1738` ``` fix m assume "N \ m" ``` hoelzl@51531 ` 1739` ``` hence m: "dist (X m) a < e/2" using N by fast ``` hoelzl@51531 ` 1740` ``` fix n assume "N \ n" ``` hoelzl@51531 ` 1741` ``` hence n: "dist (X n) a < e/2" using N by fast ``` hoelzl@51531 ` 1742` ``` have "dist (X m) (X n) \ dist (X m) a + dist (X n) a" ``` hoelzl@51531 ` 1743` ``` by (rule dist_triangle2) ``` hoelzl@51531 ` 1744` ``` also from m n have "\ < e" by simp ``` hoelzl@51531 ` 1745` ``` finally show "dist (X m) (X n) < e" . ``` hoelzl@51531 ` 1746` ``` qed ``` hoelzl@51531 ` 1747` ```qed ``` hoelzl@51531 ` 1748` hoelzl@51531 ` 1749` ```lemma convergent_Cauchy: "convergent X \ Cauchy X" ``` hoelzl@51531 ` 1750` ```unfolding convergent_def ``` hoelzl@51531 ` 1751` ```by (erule exE, erule LIMSEQ_imp_Cauchy) ``` hoelzl@51531 ` 1752` wenzelm@60758 ` 1753` ```subsubsection \Cauchy Sequences are Convergent\ ``` hoelzl@51531 ` 1754` hoelzl@51531 ` 1755` ```class complete_space = metric_space + ``` hoelzl@51531 ` 1756` ``` assumes Cauchy_convergent: "Cauchy X \ convergent X" ``` hoelzl@51531 ` 1757` hoelzl@51531 ` 1758` ```lemma Cauchy_convergent_iff: ``` hoelzl@51531 ` 1759` ``` fixes X :: "nat \ 'a::complete_space" ``` hoelzl@51531 ` 1760` ``` shows "Cauchy X = convergent X" ``` hoelzl@51531 ` 1761` ```by (fast intro: Cauchy_convergent convergent_Cauchy) ``` hoelzl@51531 ` 1762` wenzelm@60758 ` 1763` ```subsection \The set of real numbers is a complete metric space\ ``` hoelzl@51531 ` 1764` wenzelm@60758 ` 1765` ```text \ ``` hoelzl@51531 ` 1766` ```Proof that Cauchy sequences converge based on the one from ``` wenzelm@54703 ` 1767` ```@{url "http://pirate.shu.edu/~wachsmut/ira/numseq/proofs/cauconv.html"} ``` wenzelm@60758 ` 1768` ```\ ``` hoelzl@51531 ` 1769` wenzelm@60758 ` 1770` ```text \ ``` hoelzl@51531 ` 1771` ``` If sequence @{term "X"} is Cauchy, then its limit is the lub of ``` hoelzl@51531 ` 1772` ``` @{term "{r::real. \N. \n\N. r < X n}"} ``` wenzelm@60758 ` 1773` ```\ ``` hoelzl@51531 ` 1774` hoelzl@51531 ` 1775` ```lemma increasing_LIMSEQ: ``` hoelzl@51531 ` 1776` ``` fixes f :: "nat \ real" ``` hoelzl@51531 ` 1777` ``` assumes inc: "\n. f n \ f (Suc n)" ``` hoelzl@51531 ` 1778` ``` and bdd: "\n. f n \ l" ``` hoelzl@51531 ` 1779` ``` and en: "\e. 0 < e \ \n. l \ f n + e" ``` hoelzl@51531 ` 1780` ``` shows "f ----> l" ``` hoelzl@51531 ` 1781` ```proof (rule increasing_tendsto) ``` hoelzl@51531 ` 1782` ``` fix x assume "x < l" ``` hoelzl@51531 ` 1783` ``` with dense[of 0 "l - x"] obtain e where "0 < e" "e < l - x" ``` hoelzl@51531 ` 1784` ``` by auto ``` wenzelm@60758 ` 1785` ``` from en[OF \0 < e\] obtain n where "l - e \ f n" ``` hoelzl@51531 ` 1786` ``` by (auto simp: field_simps) ``` wenzelm@60758 ` 1787` ``` with \e < l - x\ \0 < e\ have "x < f n" by simp ``` hoelzl@51531 ` 1788` ``` with incseq_SucI[of f, OF inc] show "eventually (\n. x < f n) sequentially" ``` hoelzl@51531 ` 1789` ``` by (auto simp: eventually_sequentially incseq_def intro: less_le_trans) ``` hoelzl@51531 ` 1790` ```qed (insert bdd, auto) ``` hoelzl@51531 ` 1791` hoelzl@51531 ` 1792` ```lemma real_Cauchy_convergent: ``` hoelzl@51531 ` 1793` ``` fixes X :: "nat \ real" ``` hoelzl@51531 ` 1794` ``` assumes X: "Cauchy X" ``` hoelzl@51531 ` 1795` ``` shows "convergent X" ``` hoelzl@51531 ` 1796` ```proof - ``` hoelzl@51531 ` 1797` ``` def S \ "{x::real. \N. \n\N. x < X n}" ``` hoelzl@51531 ` 1798` ``` then have mem_S: "\N x. \n\N. x < X n \ x \ S" by auto ``` hoelzl@51531 ` 1799` hoelzl@51531 ` 1800` ``` { fix N x assume N: "\n\N. X n < x" ``` hoelzl@51531 ` 1801` ``` fix y::real assume "y \ S" ``` hoelzl@51531 ` 1802` ``` hence "\M. \n\M. y < X n" ``` hoelzl@51531 ` 1803` ``` by (simp add: S_def) ``` hoelzl@51531 ` 1804` ``` then obtain M where "\n\M. y < X n" .. ``` hoelzl@51531 ` 1805` ``` hence "y < X (max M N)" by simp ``` hoelzl@51531 ` 1806` ``` also have "\ < x" using N by simp ``` hoelzl@54263 ` 1807` ``` finally have "y \ x" ``` hoelzl@54263 ` 1808` ``` by (rule order_less_imp_le) } ``` lp15@60026 ` 1809` ``` note bound_isUb = this ``` hoelzl@51531 ` 1810` hoelzl@51531 ` 1811` ``` obtain N where "\m\N. \n\N. dist (X m) (X n) < 1" ``` hoelzl@51531 ` 1812` ``` using X[THEN metric_CauchyD, OF zero_less_one] by auto ``` hoelzl@51531 ` 1813` ``` hence N: "\n\N. dist (X n) (X N) < 1" by simp ``` hoelzl@54263 ` 1814` ``` have [simp]: "S \ {}" ``` hoelzl@54263 ` 1815` ``` proof (intro exI ex_in_conv[THEN iffD1]) ``` hoelzl@51531 ` 1816` ``` from N have "\n\N. X N - 1 < X n" ``` hoelzl@51531 ` 1817` ``` by (simp add: abs_diff_less_iff dist_real_def) ``` hoelzl@51531 ` 1818` ``` thus "X N - 1 \ S" by (rule mem_S) ``` hoelzl@51531 ` 1819` ``` qed ``` hoelzl@54263 ` 1820` ``` have [simp]: "bdd_above S" ``` hoelzl@51531 ` 1821` ``` proof ``` hoelzl@51531 ` 1822` ``` from N have "\n\N. X n < X N + 1" ``` hoelzl@51531 ` 1823` ``` by (simp add: abs_diff_less_iff dist_real_def) ``` hoelzl@54263 ` 1824` ``` thus "\s. s \ S \ s \ X N + 1" ``` hoelzl@51531 ` 1825` ``` by (rule bound_isUb) ``` hoelzl@51531 ` 1826` ``` qed ``` hoelzl@54263 ` 1827` ``` have "X ----> Sup S" ``` hoelzl@51531 ` 1828` ``` proof (rule metric_LIMSEQ_I) ``` hoelzl@51531 ` 1829` ``` fix r::real assume "0 < r" ``` hoelzl@51531 ` 1830` ``` hence r: "0 < r/2" by simp ``` hoelzl@51531 ` 1831` ``` obtain N where "\n\N. \m\N. dist (X n) (X m) < r/2" ``` hoelzl@51531 ` 1832` ``` using metric_CauchyD [OF X r] by auto ``` hoelzl@51531 ` 1833` ``` hence "\n\N. dist (X n) (X N) < r/2" by simp ``` hoelzl@51531 ` 1834` ``` hence N: "\n\N. X N - r/2 < X n \ X n < X N + r/2" ``` hoelzl@51531 ` 1835` ``` by (simp only: dist_real_def abs_diff_less_iff) ``` hoelzl@51531 ` 1836` hoelzl@51531 ` 1837` ``` from N have "\n\N. X N - r/2 < X n" by fast ``` hoelzl@51531 ` 1838` ``` hence "X N - r/2 \ S" by (rule mem_S) ``` hoelzl@54263 ` 1839` ``` hence 1: "X N - r/2 \ Sup S" by (simp add: cSup_upper) ``` hoelzl@51531 ` 1840` hoelzl@51531 ` 1841` ``` from N have "\n\N. X n < X N + r/2" by fast ``` hoelzl@54263 ` 1842` ``` from bound_isUb[OF this] ``` hoelzl@54263 ` 1843` ``` have 2: "Sup S \ X N + r/2" ``` hoelzl@54263 ` 1844` ``` by (intro cSup_least) simp_all ``` hoelzl@51531 ` 1845` hoelzl@54263 ` 1846` ``` show "\N. \n\N. dist (X n) (Sup S) < r" ``` hoelzl@51531 ` 1847` ``` proof (intro exI allI impI) ``` hoelzl@51531 ` 1848` ``` fix n assume n: "N \ n" ``` hoelzl@51531 ` 1849` ``` from N n have "X n < X N + r/2" and "X N - r/2 < X n" by simp+ ``` hoelzl@54263 ` 1850` ``` thus "dist (X n) (Sup S) < r" using 1 2 ``` hoelzl@51531 ` 1851` ``` by (simp add: abs_diff_less_iff dist_real_def) ``` hoelzl@51531 ` 1852` ``` qed ``` hoelzl@51531 ` 1853` ``` qed ``` hoelzl@51531 ` 1854` ``` then show ?thesis unfolding convergent_def by auto ``` hoelzl@51531 ` 1855` ```qed ``` hoelzl@51531 ` 1856` hoelzl@51531 ` 1857` ```instance real :: complete_space ``` hoelzl@51531 ` 1858` ``` by intro_classes (rule real_Cauchy_convergent) ``` hoelzl@51531 ` 1859` hoelzl@51531 ` 1860` ```class banach = real_normed_vector + complete_space ``` hoelzl@51531 ` 1861` hoelzl@51531 ` 1862` ```instance real :: banach by default ``` hoelzl@51531 ` 1863` hoelzl@51531 ` 1864` ```lemma tendsto_at_topI_sequentially: ``` hoelzl@57275 ` 1865` ``` fixes f :: "real \ 'b::first_countable_topology" ``` hoelzl@57275 ` 1866` ``` assumes *: "\X. filterlim X at_top sequentially \ (\n. f (X n)) ----> y" ``` hoelzl@57275 ` 1867` ``` shows "(f ---> y) at_top" ``` hoelzl@57448 ` 1868` ```proof - ``` hoelzl@57448 ` 1869` ``` from nhds_countable[of y] guess A . note A = this ``` hoelzl@57275 ` 1870` hoelzl@57448 ` 1871` ``` have "\m. \k. \x\k. f x \ A m" ``` hoelzl@57448 ` 1872` ``` proof (rule ccontr) ``` hoelzl@57448 ` 1873` ``` assume "\ (\m. \k. \x\k. f x \ A m)" ``` hoelzl@57448 ` 1874` ``` then obtain m where "\k. \x\k. f x \ A m" ``` hoelzl@57448 ` 1875` ``` by auto ``` hoelzl@57448 ` 1876` ``` then have "\X. \n. (f (X n) \ A m) \ max n (X n) + 1 \ X (Suc n)" ``` hoelzl@57448 ` 1877` ``` by (intro dependent_nat_choice) (auto simp del: max.bounded_iff) ``` hoelzl@57448 ` 1878` ``` then obtain X where X: "\n. f (X n) \ A m" "\n. max n (X n) + 1 \ X (Suc n)" ``` hoelzl@57448 ` 1879` ``` by auto ``` hoelzl@57448 ` 1880` ``` { fix n have "1 \ n \ real n \ X n" ``` hoelzl@57448 ` 1881` ``` using X[of "n - 1"] by auto } ``` hoelzl@57448 ` 1882` ``` then have "filterlim X at_top sequentially" ``` hoelzl@57448 ` 1883` ``` by (force intro!: filterlim_at_top_mono[OF filterlim_real_sequentially] ``` hoelzl@57448 ` 1884` ``` simp: eventually_sequentially) ``` hoelzl@57448 ` 1885` ``` from topological_tendstoD[OF *[OF this] A(2, 3), of m] X(1) show False ``` hoelzl@57448 ` 1886` ``` by auto ``` hoelzl@57275 ` 1887` ``` qed ``` hoelzl@57448 ` 1888` ``` then obtain k where "\m x. k m \ x \ f x \ A m" ``` hoelzl@57448 ` 1889` ``` by metis ``` hoelzl@57448 ` 1890` ``` then show ?thesis ``` hoelzl@57448 ` 1891` ``` unfolding at_top_def A ``` hoelzl@57448 ` 1892` ``` by (intro filterlim_base[where i=k]) auto ``` hoelzl@57275 ` 1893` ```qed ``` hoelzl@57275 ` 1894` hoelzl@57275 ` 1895` ```lemma tendsto_at_topI_sequentially_real: ``` hoelzl@51531 ` 1896` ``` fixes f :: "real \ real" ``` hoelzl@51531 ` 1897` ``` assumes mono: "mono f" ``` hoelzl@51531 ` 1898` ``` assumes limseq: "(\n. f (real n)) ----> y" ``` hoelzl@51531 ` 1899` ``` shows "(f ---> y) at_top" ``` hoelzl@51531 ` 1900` ```proof (rule tendstoI) ``` hoelzl@51531 ` 1901` ``` fix e :: real assume "0 < e" ``` hoelzl@51531 ` 1902` ``` with limseq obtain N :: nat where N: "\n. N \ n \ \f (real n) - y\ < e" ``` lp15@60017 ` 1903` ``` by (auto simp: lim_sequentially dist_real_def) ``` hoelzl@51531 ` 1904` ``` { fix x :: real ``` wenzelm@53381 ` 1905` ``` obtain n where "x \ real_of_nat n" ``` wenzelm@53381 ` 1906` ``` using ex_le_of_nat[of x] .. ``` hoelzl@51531 ` 1907` ``` note monoD[OF mono this] ``` hoelzl@51531 ` 1908` ``` also have "f (real_of_nat n) \ y" ``` hoelzl@51531 ` 1909` ``` by (rule LIMSEQ_le_const[OF limseq]) ``` hoelzl@51531 ` 1910` ``` (auto intro: exI[of _ n] monoD[OF mono] simp: real_eq_of_nat[symmetric]) ``` hoelzl@51531 ` 1911` ``` finally have "f x \ y" . } ``` hoelzl@51531 ` 1912` ``` note le = this ``` hoelzl@51531 ` 1913` ``` have "eventually (\x. real N \ x) at_top" ``` hoelzl@51531 ` 1914` ``` by (rule eventually_ge_at_top) ``` hoelzl@51531 ` 1915` ``` then show "eventually (\x. dist (f x) y < e) at_top" ``` hoelzl@51531 ` 1916` ``` proof eventually_elim ``` hoelzl@51531 ` 1917` ``` fix x assume N': "real N \ x" ``` hoelzl@51531 ` 1918` ``` with N[of N] le have "y - f (real N) < e" by auto ``` hoelzl@51531 ` 1919` ``` moreover note monoD[OF mono N'] ``` hoelzl@51531 ` 1920` ``` ultimately show "dist (f x) y < e" ``` hoelzl@51531 ` 1921` ``` using le[of x] by (auto simp: dist_real_def field_simps) ``` hoelzl@51531 ` 1922` ``` qed ``` hoelzl@51531 ` 1923` ```qed ``` hoelzl@51531 ` 1924` huffman@20504 ` 1925` ```end ``` hoelzl@57276 ` 1926`