src/HOL/Real_Vector_Spaces.thy
 author hoelzl Tue Mar 26 12:20:57 2013 +0100 (2013-03-26) changeset 51524 7cb5ac44ca9e parent 51518 src/HOL/RealVector.thy@6a56b7088a6a child 51531 f415febf4234 permissions -rw-r--r--
rename RealVector.thy to Real_Vector_Spaces.thy
 hoelzl@51524 ` 1` ```(* Title: HOL/Real_Vector_Spaces.thy ``` haftmann@27552 ` 2` ``` Author: Brian Huffman ``` huffman@20504 ` 3` ```*) ``` huffman@20504 ` 4` huffman@20504 ` 5` ```header {* Vector Spaces and Algebras over the Reals *} ``` huffman@20504 ` 6` hoelzl@51524 ` 7` ```theory Real_Vector_Spaces ``` hoelzl@51518 ` 8` ```imports Metric_Spaces ``` huffman@20504 ` 9` ```begin ``` huffman@20504 ` 10` huffman@20504 ` 11` ```subsection {* Locale for additive functions *} ``` huffman@20504 ` 12` huffman@20504 ` 13` ```locale additive = ``` huffman@20504 ` 14` ``` fixes f :: "'a::ab_group_add \ 'b::ab_group_add" ``` huffman@20504 ` 15` ``` assumes add: "f (x + y) = f x + f y" ``` huffman@27443 ` 16` ```begin ``` huffman@20504 ` 17` huffman@27443 ` 18` ```lemma zero: "f 0 = 0" ``` huffman@20504 ` 19` ```proof - ``` huffman@20504 ` 20` ``` have "f 0 = f (0 + 0)" by simp ``` huffman@20504 ` 21` ``` also have "\ = f 0 + f 0" by (rule add) ``` huffman@20504 ` 22` ``` finally show "f 0 = 0" by simp ``` huffman@20504 ` 23` ```qed ``` huffman@20504 ` 24` huffman@27443 ` 25` ```lemma minus: "f (- x) = - f x" ``` huffman@20504 ` 26` ```proof - ``` huffman@20504 ` 27` ``` have "f (- x) + f x = f (- x + x)" by (rule add [symmetric]) ``` huffman@20504 ` 28` ``` also have "\ = - f x + f x" by (simp add: zero) ``` huffman@20504 ` 29` ``` finally show "f (- x) = - f x" by (rule add_right_imp_eq) ``` huffman@20504 ` 30` ```qed ``` huffman@20504 ` 31` huffman@27443 ` 32` ```lemma diff: "f (x - y) = f x - f y" ``` haftmann@37887 ` 33` ```by (simp add: add minus diff_minus) ``` huffman@20504 ` 34` huffman@27443 ` 35` ```lemma setsum: "f (setsum g A) = (\x\A. f (g x))" ``` huffman@22942 ` 36` ```apply (cases "finite A") ``` huffman@22942 ` 37` ```apply (induct set: finite) ``` huffman@22942 ` 38` ```apply (simp add: zero) ``` huffman@22942 ` 39` ```apply (simp add: add) ``` huffman@22942 ` 40` ```apply (simp add: zero) ``` huffman@22942 ` 41` ```done ``` huffman@22942 ` 42` huffman@27443 ` 43` ```end ``` huffman@20504 ` 44` huffman@28029 ` 45` ```subsection {* Vector spaces *} ``` huffman@28029 ` 46` huffman@28029 ` 47` ```locale vector_space = ``` huffman@28029 ` 48` ``` fixes scale :: "'a::field \ 'b::ab_group_add \ 'b" ``` huffman@30070 ` 49` ``` assumes scale_right_distrib [algebra_simps]: ``` huffman@30070 ` 50` ``` "scale a (x + y) = scale a x + scale a y" ``` huffman@30070 ` 51` ``` and scale_left_distrib [algebra_simps]: ``` huffman@30070 ` 52` ``` "scale (a + b) x = scale a x + scale b x" ``` huffman@28029 ` 53` ``` and scale_scale [simp]: "scale a (scale b x) = scale (a * b) x" ``` huffman@28029 ` 54` ``` and scale_one [simp]: "scale 1 x = x" ``` huffman@28029 ` 55` ```begin ``` huffman@28029 ` 56` huffman@28029 ` 57` ```lemma scale_left_commute: ``` huffman@28029 ` 58` ``` "scale a (scale b x) = scale b (scale a x)" ``` huffman@28029 ` 59` ```by (simp add: mult_commute) ``` huffman@28029 ` 60` huffman@28029 ` 61` ```lemma scale_zero_left [simp]: "scale 0 x = 0" ``` huffman@28029 ` 62` ``` and scale_minus_left [simp]: "scale (- a) x = - (scale a x)" ``` huffman@30070 ` 63` ``` and scale_left_diff_distrib [algebra_simps]: ``` huffman@30070 ` 64` ``` "scale (a - b) x = scale a x - scale b x" ``` huffman@44282 ` 65` ``` and scale_setsum_left: "scale (setsum f A) x = (\a\A. scale (f a) x)" ``` huffman@28029 ` 66` ```proof - ``` ballarin@29229 ` 67` ``` interpret s: additive "\a. scale a x" ``` haftmann@28823 ` 68` ``` proof qed (rule scale_left_distrib) ``` huffman@28029 ` 69` ``` show "scale 0 x = 0" by (rule s.zero) ``` huffman@28029 ` 70` ``` show "scale (- a) x = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 71` ``` show "scale (a - b) x = scale a x - scale b x" by (rule s.diff) ``` huffman@44282 ` 72` ``` show "scale (setsum f A) x = (\a\A. scale (f a) x)" by (rule s.setsum) ``` huffman@28029 ` 73` ```qed ``` huffman@28029 ` 74` huffman@28029 ` 75` ```lemma scale_zero_right [simp]: "scale a 0 = 0" ``` huffman@28029 ` 76` ``` and scale_minus_right [simp]: "scale a (- x) = - (scale a x)" ``` huffman@30070 ` 77` ``` and scale_right_diff_distrib [algebra_simps]: ``` huffman@30070 ` 78` ``` "scale a (x - y) = scale a x - scale a y" ``` huffman@44282 ` 79` ``` and scale_setsum_right: "scale a (setsum f A) = (\x\A. scale a (f x))" ``` huffman@28029 ` 80` ```proof - ``` ballarin@29229 ` 81` ``` interpret s: additive "\x. scale a x" ``` haftmann@28823 ` 82` ``` proof qed (rule scale_right_distrib) ``` huffman@28029 ` 83` ``` show "scale a 0 = 0" by (rule s.zero) ``` huffman@28029 ` 84` ``` show "scale a (- x) = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 85` ``` show "scale a (x - y) = scale a x - scale a y" by (rule s.diff) ``` huffman@44282 ` 86` ``` show "scale a (setsum f A) = (\x\A. scale a (f x))" by (rule s.setsum) ``` huffman@28029 ` 87` ```qed ``` huffman@28029 ` 88` huffman@28029 ` 89` ```lemma scale_eq_0_iff [simp]: ``` huffman@28029 ` 90` ``` "scale a x = 0 \ a = 0 \ x = 0" ``` huffman@28029 ` 91` ```proof cases ``` huffman@28029 ` 92` ``` assume "a = 0" thus ?thesis by simp ``` huffman@28029 ` 93` ```next ``` huffman@28029 ` 94` ``` assume anz [simp]: "a \ 0" ``` huffman@28029 ` 95` ``` { assume "scale a x = 0" ``` huffman@28029 ` 96` ``` hence "scale (inverse a) (scale a x) = 0" by simp ``` huffman@28029 ` 97` ``` hence "x = 0" by simp } ``` huffman@28029 ` 98` ``` thus ?thesis by force ``` huffman@28029 ` 99` ```qed ``` huffman@28029 ` 100` huffman@28029 ` 101` ```lemma scale_left_imp_eq: ``` huffman@28029 ` 102` ``` "\a \ 0; scale a x = scale a y\ \ x = y" ``` huffman@28029 ` 103` ```proof - ``` huffman@28029 ` 104` ``` assume nonzero: "a \ 0" ``` huffman@28029 ` 105` ``` assume "scale a x = scale a y" ``` huffman@28029 ` 106` ``` hence "scale a (x - y) = 0" ``` huffman@28029 ` 107` ``` by (simp add: scale_right_diff_distrib) ``` huffman@28029 ` 108` ``` hence "x - y = 0" by (simp add: nonzero) ``` huffman@28029 ` 109` ``` thus "x = y" by (simp only: right_minus_eq) ``` huffman@28029 ` 110` ```qed ``` huffman@28029 ` 111` huffman@28029 ` 112` ```lemma scale_right_imp_eq: ``` huffman@28029 ` 113` ``` "\x \ 0; scale a x = scale b x\ \ a = b" ``` huffman@28029 ` 114` ```proof - ``` huffman@28029 ` 115` ``` assume nonzero: "x \ 0" ``` huffman@28029 ` 116` ``` assume "scale a x = scale b x" ``` huffman@28029 ` 117` ``` hence "scale (a - b) x = 0" ``` huffman@28029 ` 118` ``` by (simp add: scale_left_diff_distrib) ``` huffman@28029 ` 119` ``` hence "a - b = 0" by (simp add: nonzero) ``` huffman@28029 ` 120` ``` thus "a = b" by (simp only: right_minus_eq) ``` huffman@28029 ` 121` ```qed ``` huffman@28029 ` 122` huffman@31586 ` 123` ```lemma scale_cancel_left [simp]: ``` huffman@28029 ` 124` ``` "scale a x = scale a y \ x = y \ a = 0" ``` huffman@28029 ` 125` ```by (auto intro: scale_left_imp_eq) ``` huffman@28029 ` 126` huffman@31586 ` 127` ```lemma scale_cancel_right [simp]: ``` huffman@28029 ` 128` ``` "scale a x = scale b x \ a = b \ x = 0" ``` huffman@28029 ` 129` ```by (auto intro: scale_right_imp_eq) ``` huffman@28029 ` 130` huffman@28029 ` 131` ```end ``` huffman@28029 ` 132` huffman@20504 ` 133` ```subsection {* Real vector spaces *} ``` huffman@20504 ` 134` haftmann@29608 ` 135` ```class scaleR = ``` haftmann@25062 ` 136` ``` fixes scaleR :: "real \ 'a \ 'a" (infixr "*\<^sub>R" 75) ``` haftmann@24748 ` 137` ```begin ``` huffman@20504 ` 138` huffman@20763 ` 139` ```abbreviation ``` haftmann@25062 ` 140` ``` divideR :: "'a \ real \ 'a" (infixl "'/\<^sub>R" 70) ``` haftmann@24748 ` 141` ```where ``` haftmann@25062 ` 142` ``` "x /\<^sub>R r == scaleR (inverse r) x" ``` haftmann@24748 ` 143` haftmann@24748 ` 144` ```end ``` haftmann@24748 ` 145` haftmann@24588 ` 146` ```class real_vector = scaleR + ab_group_add + ``` huffman@44282 ` 147` ``` assumes scaleR_add_right: "scaleR a (x + y) = scaleR a x + scaleR a y" ``` huffman@44282 ` 148` ``` and scaleR_add_left: "scaleR (a + b) x = scaleR a x + scaleR b x" ``` huffman@30070 ` 149` ``` and scaleR_scaleR: "scaleR a (scaleR b x) = scaleR (a * b) x" ``` huffman@30070 ` 150` ``` and scaleR_one: "scaleR 1 x = x" ``` huffman@20504 ` 151` wenzelm@30729 ` 152` ```interpretation real_vector: ``` ballarin@29229 ` 153` ``` vector_space "scaleR :: real \ 'a \ 'a::real_vector" ``` huffman@28009 ` 154` ```apply unfold_locales ``` huffman@44282 ` 155` ```apply (rule scaleR_add_right) ``` huffman@44282 ` 156` ```apply (rule scaleR_add_left) ``` huffman@28009 ` 157` ```apply (rule scaleR_scaleR) ``` huffman@28009 ` 158` ```apply (rule scaleR_one) ``` huffman@28009 ` 159` ```done ``` huffman@28009 ` 160` huffman@28009 ` 161` ```text {* Recover original theorem names *} ``` huffman@28009 ` 162` huffman@28009 ` 163` ```lemmas scaleR_left_commute = real_vector.scale_left_commute ``` huffman@28009 ` 164` ```lemmas scaleR_zero_left = real_vector.scale_zero_left ``` huffman@28009 ` 165` ```lemmas scaleR_minus_left = real_vector.scale_minus_left ``` huffman@44282 ` 166` ```lemmas scaleR_diff_left = real_vector.scale_left_diff_distrib ``` huffman@44282 ` 167` ```lemmas scaleR_setsum_left = real_vector.scale_setsum_left ``` huffman@28009 ` 168` ```lemmas scaleR_zero_right = real_vector.scale_zero_right ``` huffman@28009 ` 169` ```lemmas scaleR_minus_right = real_vector.scale_minus_right ``` huffman@44282 ` 170` ```lemmas scaleR_diff_right = real_vector.scale_right_diff_distrib ``` huffman@44282 ` 171` ```lemmas scaleR_setsum_right = real_vector.scale_setsum_right ``` huffman@28009 ` 172` ```lemmas scaleR_eq_0_iff = real_vector.scale_eq_0_iff ``` huffman@28009 ` 173` ```lemmas scaleR_left_imp_eq = real_vector.scale_left_imp_eq ``` huffman@28009 ` 174` ```lemmas scaleR_right_imp_eq = real_vector.scale_right_imp_eq ``` huffman@28009 ` 175` ```lemmas scaleR_cancel_left = real_vector.scale_cancel_left ``` huffman@28009 ` 176` ```lemmas scaleR_cancel_right = real_vector.scale_cancel_right ``` huffman@28009 ` 177` huffman@44282 ` 178` ```text {* Legacy names *} ``` huffman@44282 ` 179` huffman@44282 ` 180` ```lemmas scaleR_left_distrib = scaleR_add_left ``` huffman@44282 ` 181` ```lemmas scaleR_right_distrib = scaleR_add_right ``` huffman@44282 ` 182` ```lemmas scaleR_left_diff_distrib = scaleR_diff_left ``` huffman@44282 ` 183` ```lemmas scaleR_right_diff_distrib = scaleR_diff_right ``` huffman@44282 ` 184` huffman@31285 ` 185` ```lemma scaleR_minus1_left [simp]: ``` huffman@31285 ` 186` ``` fixes x :: "'a::real_vector" ``` huffman@31285 ` 187` ``` shows "scaleR (-1) x = - x" ``` huffman@31285 ` 188` ``` using scaleR_minus_left [of 1 x] by simp ``` huffman@31285 ` 189` haftmann@24588 ` 190` ```class real_algebra = real_vector + ring + ``` haftmann@25062 ` 191` ``` assumes mult_scaleR_left [simp]: "scaleR a x * y = scaleR a (x * y)" ``` haftmann@25062 ` 192` ``` and mult_scaleR_right [simp]: "x * scaleR a y = scaleR a (x * y)" ``` huffman@20504 ` 193` haftmann@24588 ` 194` ```class real_algebra_1 = real_algebra + ring_1 ``` huffman@20554 ` 195` haftmann@24588 ` 196` ```class real_div_algebra = real_algebra_1 + division_ring ``` huffman@20584 ` 197` haftmann@24588 ` 198` ```class real_field = real_div_algebra + field ``` huffman@20584 ` 199` huffman@30069 ` 200` ```instantiation real :: real_field ``` huffman@30069 ` 201` ```begin ``` huffman@30069 ` 202` huffman@30069 ` 203` ```definition ``` huffman@30069 ` 204` ``` real_scaleR_def [simp]: "scaleR a x = a * x" ``` huffman@30069 ` 205` huffman@30070 ` 206` ```instance proof ``` huffman@30070 ` 207` ```qed (simp_all add: algebra_simps) ``` huffman@20554 ` 208` huffman@30069 ` 209` ```end ``` huffman@30069 ` 210` wenzelm@30729 ` 211` ```interpretation scaleR_left: additive "(\a. scaleR a x::'a::real_vector)" ``` haftmann@28823 ` 212` ```proof qed (rule scaleR_left_distrib) ``` huffman@20504 ` 213` wenzelm@30729 ` 214` ```interpretation scaleR_right: additive "(\x. scaleR a x::'a::real_vector)" ``` haftmann@28823 ` 215` ```proof qed (rule scaleR_right_distrib) ``` huffman@20504 ` 216` huffman@20584 ` 217` ```lemma nonzero_inverse_scaleR_distrib: ``` huffman@21809 ` 218` ``` fixes x :: "'a::real_div_algebra" shows ``` huffman@21809 ` 219` ``` "\a \ 0; x \ 0\ \ inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` huffman@20763 ` 220` ```by (rule inverse_unique, simp) ``` huffman@20584 ` 221` huffman@20584 ` 222` ```lemma inverse_scaleR_distrib: ``` haftmann@36409 ` 223` ``` fixes x :: "'a::{real_div_algebra, division_ring_inverse_zero}" ``` huffman@21809 ` 224` ``` shows "inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` huffman@20584 ` 225` ```apply (case_tac "a = 0", simp) ``` huffman@20584 ` 226` ```apply (case_tac "x = 0", simp) ``` huffman@20584 ` 227` ```apply (erule (1) nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 228` ```done ``` huffman@20584 ` 229` huffman@20554 ` 230` huffman@20554 ` 231` ```subsection {* Embedding of the Reals into any @{text real_algebra_1}: ``` huffman@20554 ` 232` ```@{term of_real} *} ``` huffman@20554 ` 233` huffman@20554 ` 234` ```definition ``` wenzelm@21404 ` 235` ``` of_real :: "real \ 'a::real_algebra_1" where ``` huffman@21809 ` 236` ``` "of_real r = scaleR r 1" ``` huffman@20554 ` 237` huffman@21809 ` 238` ```lemma scaleR_conv_of_real: "scaleR r x = of_real r * x" ``` huffman@20763 ` 239` ```by (simp add: of_real_def) ``` huffman@20763 ` 240` huffman@20554 ` 241` ```lemma of_real_0 [simp]: "of_real 0 = 0" ``` huffman@20554 ` 242` ```by (simp add: of_real_def) ``` huffman@20554 ` 243` huffman@20554 ` 244` ```lemma of_real_1 [simp]: "of_real 1 = 1" ``` huffman@20554 ` 245` ```by (simp add: of_real_def) ``` huffman@20554 ` 246` huffman@20554 ` 247` ```lemma of_real_add [simp]: "of_real (x + y) = of_real x + of_real y" ``` huffman@20554 ` 248` ```by (simp add: of_real_def scaleR_left_distrib) ``` huffman@20554 ` 249` huffman@20554 ` 250` ```lemma of_real_minus [simp]: "of_real (- x) = - of_real x" ``` huffman@20554 ` 251` ```by (simp add: of_real_def) ``` huffman@20554 ` 252` huffman@20554 ` 253` ```lemma of_real_diff [simp]: "of_real (x - y) = of_real x - of_real y" ``` huffman@20554 ` 254` ```by (simp add: of_real_def scaleR_left_diff_distrib) ``` huffman@20554 ` 255` huffman@20554 ` 256` ```lemma of_real_mult [simp]: "of_real (x * y) = of_real x * of_real y" ``` huffman@20763 ` 257` ```by (simp add: of_real_def mult_commute) ``` huffman@20554 ` 258` huffman@20584 ` 259` ```lemma nonzero_of_real_inverse: ``` huffman@20584 ` 260` ``` "x \ 0 \ of_real (inverse x) = ``` huffman@20584 ` 261` ``` inverse (of_real x :: 'a::real_div_algebra)" ``` huffman@20584 ` 262` ```by (simp add: of_real_def nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 263` huffman@20584 ` 264` ```lemma of_real_inverse [simp]: ``` huffman@20584 ` 265` ``` "of_real (inverse x) = ``` haftmann@36409 ` 266` ``` inverse (of_real x :: 'a::{real_div_algebra, division_ring_inverse_zero})" ``` huffman@20584 ` 267` ```by (simp add: of_real_def inverse_scaleR_distrib) ``` huffman@20584 ` 268` huffman@20584 ` 269` ```lemma nonzero_of_real_divide: ``` huffman@20584 ` 270` ``` "y \ 0 \ of_real (x / y) = ``` huffman@20584 ` 271` ``` (of_real x / of_real y :: 'a::real_field)" ``` huffman@20584 ` 272` ```by (simp add: divide_inverse nonzero_of_real_inverse) ``` huffman@20722 ` 273` huffman@20722 ` 274` ```lemma of_real_divide [simp]: ``` huffman@20584 ` 275` ``` "of_real (x / y) = ``` haftmann@36409 ` 276` ``` (of_real x / of_real y :: 'a::{real_field, field_inverse_zero})" ``` huffman@20584 ` 277` ```by (simp add: divide_inverse) ``` huffman@20584 ` 278` huffman@20722 ` 279` ```lemma of_real_power [simp]: ``` haftmann@31017 ` 280` ``` "of_real (x ^ n) = (of_real x :: 'a::{real_algebra_1}) ^ n" ``` huffman@30273 ` 281` ```by (induct n) simp_all ``` huffman@20722 ` 282` huffman@20554 ` 283` ```lemma of_real_eq_iff [simp]: "(of_real x = of_real y) = (x = y)" ``` huffman@35216 ` 284` ```by (simp add: of_real_def) ``` huffman@20554 ` 285` haftmann@38621 ` 286` ```lemma inj_of_real: ``` haftmann@38621 ` 287` ``` "inj of_real" ``` haftmann@38621 ` 288` ``` by (auto intro: injI) ``` haftmann@38621 ` 289` huffman@20584 ` 290` ```lemmas of_real_eq_0_iff [simp] = of_real_eq_iff [of _ 0, simplified] ``` huffman@20554 ` 291` huffman@20554 ` 292` ```lemma of_real_eq_id [simp]: "of_real = (id :: real \ real)" ``` huffman@20554 ` 293` ```proof ``` huffman@20554 ` 294` ``` fix r ``` huffman@20554 ` 295` ``` show "of_real r = id r" ``` huffman@22973 ` 296` ``` by (simp add: of_real_def) ``` huffman@20554 ` 297` ```qed ``` huffman@20554 ` 298` huffman@20554 ` 299` ```text{*Collapse nested embeddings*} ``` huffman@20554 ` 300` ```lemma of_real_of_nat_eq [simp]: "of_real (of_nat n) = of_nat n" ``` wenzelm@20772 ` 301` ```by (induct n) auto ``` huffman@20554 ` 302` huffman@20554 ` 303` ```lemma of_real_of_int_eq [simp]: "of_real (of_int z) = of_int z" ``` huffman@20554 ` 304` ```by (cases z rule: int_diff_cases, simp) ``` huffman@20554 ` 305` huffman@47108 ` 306` ```lemma of_real_numeral: "of_real (numeral w) = numeral w" ``` huffman@47108 ` 307` ```using of_real_of_int_eq [of "numeral w"] by simp ``` huffman@47108 ` 308` huffman@47108 ` 309` ```lemma of_real_neg_numeral: "of_real (neg_numeral w) = neg_numeral w" ``` huffman@47108 ` 310` ```using of_real_of_int_eq [of "neg_numeral w"] by simp ``` huffman@20554 ` 311` huffman@22912 ` 312` ```text{*Every real algebra has characteristic zero*} ``` haftmann@38621 ` 313` huffman@22912 ` 314` ```instance real_algebra_1 < ring_char_0 ``` huffman@22912 ` 315` ```proof ``` haftmann@38621 ` 316` ``` from inj_of_real inj_of_nat have "inj (of_real \ of_nat)" by (rule inj_comp) ``` haftmann@38621 ` 317` ``` then show "inj (of_nat :: nat \ 'a)" by (simp add: comp_def) ``` huffman@22912 ` 318` ```qed ``` huffman@22912 ` 319` huffman@27553 ` 320` ```instance real_field < field_char_0 .. ``` huffman@27553 ` 321` huffman@20554 ` 322` huffman@20554 ` 323` ```subsection {* The Set of Real Numbers *} ``` huffman@20554 ` 324` haftmann@37767 ` 325` ```definition Reals :: "'a::real_algebra_1 set" where ``` haftmann@37767 ` 326` ``` "Reals = range of_real" ``` huffman@20554 ` 327` wenzelm@21210 ` 328` ```notation (xsymbols) ``` huffman@20554 ` 329` ``` Reals ("\") ``` huffman@20554 ` 330` huffman@21809 ` 331` ```lemma Reals_of_real [simp]: "of_real r \ Reals" ``` huffman@20554 ` 332` ```by (simp add: Reals_def) ``` huffman@20554 ` 333` huffman@21809 ` 334` ```lemma Reals_of_int [simp]: "of_int z \ Reals" ``` huffman@21809 ` 335` ```by (subst of_real_of_int_eq [symmetric], rule Reals_of_real) ``` huffman@20718 ` 336` huffman@21809 ` 337` ```lemma Reals_of_nat [simp]: "of_nat n \ Reals" ``` huffman@21809 ` 338` ```by (subst of_real_of_nat_eq [symmetric], rule Reals_of_real) ``` huffman@21809 ` 339` huffman@47108 ` 340` ```lemma Reals_numeral [simp]: "numeral w \ Reals" ``` huffman@47108 ` 341` ```by (subst of_real_numeral [symmetric], rule Reals_of_real) ``` huffman@47108 ` 342` huffman@47108 ` 343` ```lemma Reals_neg_numeral [simp]: "neg_numeral w \ Reals" ``` huffman@47108 ` 344` ```by (subst of_real_neg_numeral [symmetric], rule Reals_of_real) ``` huffman@20718 ` 345` huffman@20554 ` 346` ```lemma Reals_0 [simp]: "0 \ Reals" ``` huffman@20554 ` 347` ```apply (unfold Reals_def) ``` huffman@20554 ` 348` ```apply (rule range_eqI) ``` huffman@20554 ` 349` ```apply (rule of_real_0 [symmetric]) ``` huffman@20554 ` 350` ```done ``` huffman@20554 ` 351` huffman@20554 ` 352` ```lemma Reals_1 [simp]: "1 \ Reals" ``` huffman@20554 ` 353` ```apply (unfold Reals_def) ``` huffman@20554 ` 354` ```apply (rule range_eqI) ``` huffman@20554 ` 355` ```apply (rule of_real_1 [symmetric]) ``` huffman@20554 ` 356` ```done ``` huffman@20554 ` 357` huffman@20584 ` 358` ```lemma Reals_add [simp]: "\a \ Reals; b \ Reals\ \ a + b \ Reals" ``` huffman@20554 ` 359` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 360` ```apply (rule range_eqI) ``` huffman@20554 ` 361` ```apply (rule of_real_add [symmetric]) ``` huffman@20554 ` 362` ```done ``` huffman@20554 ` 363` huffman@20584 ` 364` ```lemma Reals_minus [simp]: "a \ Reals \ - a \ Reals" ``` huffman@20584 ` 365` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 366` ```apply (rule range_eqI) ``` huffman@20584 ` 367` ```apply (rule of_real_minus [symmetric]) ``` huffman@20584 ` 368` ```done ``` huffman@20584 ` 369` huffman@20584 ` 370` ```lemma Reals_diff [simp]: "\a \ Reals; b \ Reals\ \ a - b \ Reals" ``` huffman@20584 ` 371` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 372` ```apply (rule range_eqI) ``` huffman@20584 ` 373` ```apply (rule of_real_diff [symmetric]) ``` huffman@20584 ` 374` ```done ``` huffman@20584 ` 375` huffman@20584 ` 376` ```lemma Reals_mult [simp]: "\a \ Reals; b \ Reals\ \ a * b \ Reals" ``` huffman@20554 ` 377` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 378` ```apply (rule range_eqI) ``` huffman@20554 ` 379` ```apply (rule of_real_mult [symmetric]) ``` huffman@20554 ` 380` ```done ``` huffman@20554 ` 381` huffman@20584 ` 382` ```lemma nonzero_Reals_inverse: ``` huffman@20584 ` 383` ``` fixes a :: "'a::real_div_algebra" ``` huffman@20584 ` 384` ``` shows "\a \ Reals; a \ 0\ \ inverse a \ Reals" ``` huffman@20584 ` 385` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 386` ```apply (rule range_eqI) ``` huffman@20584 ` 387` ```apply (erule nonzero_of_real_inverse [symmetric]) ``` huffman@20584 ` 388` ```done ``` huffman@20584 ` 389` huffman@20584 ` 390` ```lemma Reals_inverse [simp]: ``` haftmann@36409 ` 391` ``` fixes a :: "'a::{real_div_algebra, division_ring_inverse_zero}" ``` huffman@20584 ` 392` ``` shows "a \ Reals \ inverse a \ Reals" ``` huffman@20584 ` 393` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 394` ```apply (rule range_eqI) ``` huffman@20584 ` 395` ```apply (rule of_real_inverse [symmetric]) ``` huffman@20584 ` 396` ```done ``` huffman@20584 ` 397` huffman@20584 ` 398` ```lemma nonzero_Reals_divide: ``` huffman@20584 ` 399` ``` fixes a b :: "'a::real_field" ``` huffman@20584 ` 400` ``` shows "\a \ Reals; b \ Reals; b \ 0\ \ a / b \ Reals" ``` huffman@20584 ` 401` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 402` ```apply (rule range_eqI) ``` huffman@20584 ` 403` ```apply (erule nonzero_of_real_divide [symmetric]) ``` huffman@20584 ` 404` ```done ``` huffman@20584 ` 405` huffman@20584 ` 406` ```lemma Reals_divide [simp]: ``` haftmann@36409 ` 407` ``` fixes a b :: "'a::{real_field, field_inverse_zero}" ``` huffman@20584 ` 408` ``` shows "\a \ Reals; b \ Reals\ \ a / b \ Reals" ``` huffman@20584 ` 409` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 410` ```apply (rule range_eqI) ``` huffman@20584 ` 411` ```apply (rule of_real_divide [symmetric]) ``` huffman@20584 ` 412` ```done ``` huffman@20584 ` 413` huffman@20722 ` 414` ```lemma Reals_power [simp]: ``` haftmann@31017 ` 415` ``` fixes a :: "'a::{real_algebra_1}" ``` huffman@20722 ` 416` ``` shows "a \ Reals \ a ^ n \ Reals" ``` huffman@20722 ` 417` ```apply (auto simp add: Reals_def) ``` huffman@20722 ` 418` ```apply (rule range_eqI) ``` huffman@20722 ` 419` ```apply (rule of_real_power [symmetric]) ``` huffman@20722 ` 420` ```done ``` huffman@20722 ` 421` huffman@20554 ` 422` ```lemma Reals_cases [cases set: Reals]: ``` huffman@20554 ` 423` ``` assumes "q \ \" ``` huffman@20554 ` 424` ``` obtains (of_real) r where "q = of_real r" ``` huffman@20554 ` 425` ``` unfolding Reals_def ``` huffman@20554 ` 426` ```proof - ``` huffman@20554 ` 427` ``` from `q \ \` have "q \ range of_real" unfolding Reals_def . ``` huffman@20554 ` 428` ``` then obtain r where "q = of_real r" .. ``` huffman@20554 ` 429` ``` then show thesis .. ``` huffman@20554 ` 430` ```qed ``` huffman@20554 ` 431` huffman@20554 ` 432` ```lemma Reals_induct [case_names of_real, induct set: Reals]: ``` huffman@20554 ` 433` ``` "q \ \ \ (\r. P (of_real r)) \ P q" ``` huffman@20554 ` 434` ``` by (rule Reals_cases) auto ``` huffman@20554 ` 435` huffman@20504 ` 436` huffman@20504 ` 437` ```subsection {* Real normed vector spaces *} ``` huffman@20504 ` 438` haftmann@29608 ` 439` ```class norm = ``` huffman@22636 ` 440` ``` fixes norm :: "'a \ real" ``` huffman@20504 ` 441` huffman@24520 ` 442` ```class sgn_div_norm = scaleR + norm + sgn + ``` haftmann@25062 ` 443` ``` assumes sgn_div_norm: "sgn x = x /\<^sub>R norm x" ``` nipkow@24506 ` 444` huffman@31289 ` 445` ```class dist_norm = dist + norm + minus + ``` huffman@31289 ` 446` ``` assumes dist_norm: "dist x y = norm (x - y)" ``` huffman@31289 ` 447` huffman@31492 ` 448` ```class real_normed_vector = real_vector + sgn_div_norm + dist_norm + open_dist + ``` hoelzl@51002 ` 449` ``` assumes norm_eq_zero [simp]: "norm x = 0 \ x = 0" ``` haftmann@25062 ` 450` ``` and norm_triangle_ineq: "norm (x + y) \ norm x + norm y" ``` huffman@31586 ` 451` ``` and norm_scaleR [simp]: "norm (scaleR a x) = \a\ * norm x" ``` hoelzl@51002 ` 452` ```begin ``` hoelzl@51002 ` 453` hoelzl@51002 ` 454` ```lemma norm_ge_zero [simp]: "0 \ norm x" ``` hoelzl@51002 ` 455` ```proof - ``` hoelzl@51002 ` 456` ``` have "0 = norm (x + -1 *\<^sub>R x)" ``` hoelzl@51002 ` 457` ``` using scaleR_add_left[of 1 "-1" x] norm_scaleR[of 0 x] by (simp add: scaleR_one) ``` hoelzl@51002 ` 458` ``` also have "\ \ norm x + norm (-1 *\<^sub>R x)" by (rule norm_triangle_ineq) ``` hoelzl@51002 ` 459` ``` finally show ?thesis by simp ``` hoelzl@51002 ` 460` ```qed ``` hoelzl@51002 ` 461` hoelzl@51002 ` 462` ```end ``` huffman@20504 ` 463` haftmann@24588 ` 464` ```class real_normed_algebra = real_algebra + real_normed_vector + ``` haftmann@25062 ` 465` ``` assumes norm_mult_ineq: "norm (x * y) \ norm x * norm y" ``` huffman@20504 ` 466` haftmann@24588 ` 467` ```class real_normed_algebra_1 = real_algebra_1 + real_normed_algebra + ``` haftmann@25062 ` 468` ``` assumes norm_one [simp]: "norm 1 = 1" ``` huffman@22852 ` 469` haftmann@24588 ` 470` ```class real_normed_div_algebra = real_div_algebra + real_normed_vector + ``` haftmann@25062 ` 471` ``` assumes norm_mult: "norm (x * y) = norm x * norm y" ``` huffman@20504 ` 472` haftmann@24588 ` 473` ```class real_normed_field = real_field + real_normed_div_algebra ``` huffman@20584 ` 474` huffman@22852 ` 475` ```instance real_normed_div_algebra < real_normed_algebra_1 ``` huffman@20554 ` 476` ```proof ``` huffman@20554 ` 477` ``` fix x y :: 'a ``` huffman@20554 ` 478` ``` show "norm (x * y) \ norm x * norm y" ``` huffman@20554 ` 479` ``` by (simp add: norm_mult) ``` huffman@22852 ` 480` ```next ``` huffman@22852 ` 481` ``` have "norm (1 * 1::'a) = norm (1::'a) * norm (1::'a)" ``` huffman@22852 ` 482` ``` by (rule norm_mult) ``` huffman@22852 ` 483` ``` thus "norm (1::'a) = 1" by simp ``` huffman@20554 ` 484` ```qed ``` huffman@20554 ` 485` huffman@22852 ` 486` ```lemma norm_zero [simp]: "norm (0::'a::real_normed_vector) = 0" ``` huffman@20504 ` 487` ```by simp ``` huffman@20504 ` 488` huffman@22852 ` 489` ```lemma zero_less_norm_iff [simp]: ``` huffman@22852 ` 490` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 491` ``` shows "(0 < norm x) = (x \ 0)" ``` huffman@20504 ` 492` ```by (simp add: order_less_le) ``` huffman@20504 ` 493` huffman@22852 ` 494` ```lemma norm_not_less_zero [simp]: ``` huffman@22852 ` 495` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 496` ``` shows "\ norm x < 0" ``` huffman@20828 ` 497` ```by (simp add: linorder_not_less) ``` huffman@20828 ` 498` huffman@22852 ` 499` ```lemma norm_le_zero_iff [simp]: ``` huffman@22852 ` 500` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 501` ``` shows "(norm x \ 0) = (x = 0)" ``` huffman@20828 ` 502` ```by (simp add: order_le_less) ``` huffman@20828 ` 503` huffman@20504 ` 504` ```lemma norm_minus_cancel [simp]: ``` huffman@20584 ` 505` ``` fixes x :: "'a::real_normed_vector" ``` huffman@20584 ` 506` ``` shows "norm (- x) = norm x" ``` huffman@20504 ` 507` ```proof - ``` huffman@21809 ` 508` ``` have "norm (- x) = norm (scaleR (- 1) x)" ``` huffman@20504 ` 509` ``` by (simp only: scaleR_minus_left scaleR_one) ``` huffman@20533 ` 510` ``` also have "\ = \- 1\ * norm x" ``` huffman@20504 ` 511` ``` by (rule norm_scaleR) ``` huffman@20504 ` 512` ``` finally show ?thesis by simp ``` huffman@20504 ` 513` ```qed ``` huffman@20504 ` 514` huffman@20504 ` 515` ```lemma norm_minus_commute: ``` huffman@20584 ` 516` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 517` ``` shows "norm (a - b) = norm (b - a)" ``` huffman@20504 ` 518` ```proof - ``` huffman@22898 ` 519` ``` have "norm (- (b - a)) = norm (b - a)" ``` huffman@22898 ` 520` ``` by (rule norm_minus_cancel) ``` huffman@22898 ` 521` ``` thus ?thesis by simp ``` huffman@20504 ` 522` ```qed ``` huffman@20504 ` 523` huffman@20504 ` 524` ```lemma norm_triangle_ineq2: ``` huffman@20584 ` 525` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 526` ``` shows "norm a - norm b \ norm (a - b)" ``` huffman@20504 ` 527` ```proof - ``` huffman@20533 ` 528` ``` have "norm (a - b + b) \ norm (a - b) + norm b" ``` huffman@20504 ` 529` ``` by (rule norm_triangle_ineq) ``` huffman@22898 ` 530` ``` thus ?thesis by simp ``` huffman@20504 ` 531` ```qed ``` huffman@20504 ` 532` huffman@20584 ` 533` ```lemma norm_triangle_ineq3: ``` huffman@20584 ` 534` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 535` ``` shows "\norm a - norm b\ \ norm (a - b)" ``` huffman@20584 ` 536` ```apply (subst abs_le_iff) ``` huffman@20584 ` 537` ```apply auto ``` huffman@20584 ` 538` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 539` ```apply (subst norm_minus_commute) ``` huffman@20584 ` 540` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 541` ```done ``` huffman@20584 ` 542` huffman@20504 ` 543` ```lemma norm_triangle_ineq4: ``` huffman@20584 ` 544` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 545` ``` shows "norm (a - b) \ norm a + norm b" ``` huffman@20504 ` 546` ```proof - ``` huffman@22898 ` 547` ``` have "norm (a + - b) \ norm a + norm (- b)" ``` huffman@20504 ` 548` ``` by (rule norm_triangle_ineq) ``` huffman@22898 ` 549` ``` thus ?thesis ``` huffman@22898 ` 550` ``` by (simp only: diff_minus norm_minus_cancel) ``` huffman@22898 ` 551` ```qed ``` huffman@22898 ` 552` huffman@22898 ` 553` ```lemma norm_diff_ineq: ``` huffman@22898 ` 554` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@22898 ` 555` ``` shows "norm a - norm b \ norm (a + b)" ``` huffman@22898 ` 556` ```proof - ``` huffman@22898 ` 557` ``` have "norm a - norm (- b) \ norm (a - - b)" ``` huffman@22898 ` 558` ``` by (rule norm_triangle_ineq2) ``` huffman@22898 ` 559` ``` thus ?thesis by simp ``` huffman@20504 ` 560` ```qed ``` huffman@20504 ` 561` huffman@20551 ` 562` ```lemma norm_diff_triangle_ineq: ``` huffman@20551 ` 563` ``` fixes a b c d :: "'a::real_normed_vector" ``` huffman@20551 ` 564` ``` shows "norm ((a + b) - (c + d)) \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 565` ```proof - ``` huffman@20551 ` 566` ``` have "norm ((a + b) - (c + d)) = norm ((a - c) + (b - d))" ``` huffman@20551 ` 567` ``` by (simp add: diff_minus add_ac) ``` huffman@20551 ` 568` ``` also have "\ \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 569` ``` by (rule norm_triangle_ineq) ``` huffman@20551 ` 570` ``` finally show ?thesis . ``` huffman@20551 ` 571` ```qed ``` huffman@20551 ` 572` huffman@22857 ` 573` ```lemma abs_norm_cancel [simp]: ``` huffman@22857 ` 574` ``` fixes a :: "'a::real_normed_vector" ``` huffman@22857 ` 575` ``` shows "\norm a\ = norm a" ``` huffman@22857 ` 576` ```by (rule abs_of_nonneg [OF norm_ge_zero]) ``` huffman@22857 ` 577` huffman@22880 ` 578` ```lemma norm_add_less: ``` huffman@22880 ` 579` ``` fixes x y :: "'a::real_normed_vector" ``` huffman@22880 ` 580` ``` shows "\norm x < r; norm y < s\ \ norm (x + y) < r + s" ``` huffman@22880 ` 581` ```by (rule order_le_less_trans [OF norm_triangle_ineq add_strict_mono]) ``` huffman@22880 ` 582` huffman@22880 ` 583` ```lemma norm_mult_less: ``` huffman@22880 ` 584` ``` fixes x y :: "'a::real_normed_algebra" ``` huffman@22880 ` 585` ``` shows "\norm x < r; norm y < s\ \ norm (x * y) < r * s" ``` huffman@22880 ` 586` ```apply (rule order_le_less_trans [OF norm_mult_ineq]) ``` huffman@22880 ` 587` ```apply (simp add: mult_strict_mono') ``` huffman@22880 ` 588` ```done ``` huffman@22880 ` 589` huffman@22857 ` 590` ```lemma norm_of_real [simp]: ``` huffman@22857 ` 591` ``` "norm (of_real r :: 'a::real_normed_algebra_1) = \r\" ``` huffman@31586 ` 592` ```unfolding of_real_def by simp ``` huffman@20560 ` 593` huffman@47108 ` 594` ```lemma norm_numeral [simp]: ``` huffman@47108 ` 595` ``` "norm (numeral w::'a::real_normed_algebra_1) = numeral w" ``` huffman@47108 ` 596` ```by (subst of_real_numeral [symmetric], subst norm_of_real, simp) ``` huffman@47108 ` 597` huffman@47108 ` 598` ```lemma norm_neg_numeral [simp]: ``` huffman@47108 ` 599` ``` "norm (neg_numeral w::'a::real_normed_algebra_1) = numeral w" ``` huffman@47108 ` 600` ```by (subst of_real_neg_numeral [symmetric], subst norm_of_real, simp) ``` huffman@22876 ` 601` huffman@22876 ` 602` ```lemma norm_of_int [simp]: ``` huffman@22876 ` 603` ``` "norm (of_int z::'a::real_normed_algebra_1) = \of_int z\" ``` huffman@22876 ` 604` ```by (subst of_real_of_int_eq [symmetric], rule norm_of_real) ``` huffman@22876 ` 605` huffman@22876 ` 606` ```lemma norm_of_nat [simp]: ``` huffman@22876 ` 607` ``` "norm (of_nat n::'a::real_normed_algebra_1) = of_nat n" ``` huffman@22876 ` 608` ```apply (subst of_real_of_nat_eq [symmetric]) ``` huffman@22876 ` 609` ```apply (subst norm_of_real, simp) ``` huffman@22876 ` 610` ```done ``` huffman@22876 ` 611` huffman@20504 ` 612` ```lemma nonzero_norm_inverse: ``` huffman@20504 ` 613` ``` fixes a :: "'a::real_normed_div_algebra" ``` huffman@20533 ` 614` ``` shows "a \ 0 \ norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 615` ```apply (rule inverse_unique [symmetric]) ``` huffman@20504 ` 616` ```apply (simp add: norm_mult [symmetric]) ``` huffman@20504 ` 617` ```done ``` huffman@20504 ` 618` huffman@20504 ` 619` ```lemma norm_inverse: ``` haftmann@36409 ` 620` ``` fixes a :: "'a::{real_normed_div_algebra, division_ring_inverse_zero}" ``` huffman@20533 ` 621` ``` shows "norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 622` ```apply (case_tac "a = 0", simp) ``` huffman@20504 ` 623` ```apply (erule nonzero_norm_inverse) ``` huffman@20504 ` 624` ```done ``` huffman@20504 ` 625` huffman@20584 ` 626` ```lemma nonzero_norm_divide: ``` huffman@20584 ` 627` ``` fixes a b :: "'a::real_normed_field" ``` huffman@20584 ` 628` ``` shows "b \ 0 \ norm (a / b) = norm a / norm b" ``` huffman@20584 ` 629` ```by (simp add: divide_inverse norm_mult nonzero_norm_inverse) ``` huffman@20584 ` 630` huffman@20584 ` 631` ```lemma norm_divide: ``` haftmann@36409 ` 632` ``` fixes a b :: "'a::{real_normed_field, field_inverse_zero}" ``` huffman@20584 ` 633` ``` shows "norm (a / b) = norm a / norm b" ``` huffman@20584 ` 634` ```by (simp add: divide_inverse norm_mult norm_inverse) ``` huffman@20584 ` 635` huffman@22852 ` 636` ```lemma norm_power_ineq: ``` haftmann@31017 ` 637` ``` fixes x :: "'a::{real_normed_algebra_1}" ``` huffman@22852 ` 638` ``` shows "norm (x ^ n) \ norm x ^ n" ``` huffman@22852 ` 639` ```proof (induct n) ``` huffman@22852 ` 640` ``` case 0 show "norm (x ^ 0) \ norm x ^ 0" by simp ``` huffman@22852 ` 641` ```next ``` huffman@22852 ` 642` ``` case (Suc n) ``` huffman@22852 ` 643` ``` have "norm (x * x ^ n) \ norm x * norm (x ^ n)" ``` huffman@22852 ` 644` ``` by (rule norm_mult_ineq) ``` huffman@22852 ` 645` ``` also from Suc have "\ \ norm x * norm x ^ n" ``` huffman@22852 ` 646` ``` using norm_ge_zero by (rule mult_left_mono) ``` huffman@22852 ` 647` ``` finally show "norm (x ^ Suc n) \ norm x ^ Suc n" ``` huffman@30273 ` 648` ``` by simp ``` huffman@22852 ` 649` ```qed ``` huffman@22852 ` 650` huffman@20684 ` 651` ```lemma norm_power: ``` haftmann@31017 ` 652` ``` fixes x :: "'a::{real_normed_div_algebra}" ``` huffman@20684 ` 653` ``` shows "norm (x ^ n) = norm x ^ n" ``` huffman@30273 ` 654` ```by (induct n) (simp_all add: norm_mult) ``` huffman@20684 ` 655` huffman@31289 ` 656` ```text {* Every normed vector space is a metric space. *} ``` huffman@31285 ` 657` huffman@31289 ` 658` ```instance real_normed_vector < metric_space ``` huffman@31289 ` 659` ```proof ``` huffman@31289 ` 660` ``` fix x y :: 'a show "dist x y = 0 \ x = y" ``` huffman@31289 ` 661` ``` unfolding dist_norm by simp ``` huffman@31289 ` 662` ```next ``` huffman@31289 ` 663` ``` fix x y z :: 'a show "dist x y \ dist x z + dist y z" ``` huffman@31289 ` 664` ``` unfolding dist_norm ``` huffman@31289 ` 665` ``` using norm_triangle_ineq4 [of "x - z" "y - z"] by simp ``` huffman@31289 ` 666` ```qed ``` huffman@31285 ` 667` huffman@31564 ` 668` ```subsection {* Class instances for real numbers *} ``` huffman@31564 ` 669` huffman@31564 ` 670` ```instantiation real :: real_normed_field ``` huffman@31564 ` 671` ```begin ``` huffman@31564 ` 672` huffman@31564 ` 673` ```definition real_norm_def [simp]: ``` huffman@31564 ` 674` ``` "norm r = \r\" ``` huffman@31564 ` 675` huffman@31564 ` 676` ```instance ``` huffman@31564 ` 677` ```apply (intro_classes, unfold real_norm_def real_scaleR_def) ``` huffman@31564 ` 678` ```apply (rule dist_real_def) ``` huffman@36795 ` 679` ```apply (simp add: sgn_real_def) ``` huffman@31564 ` 680` ```apply (rule abs_eq_0) ``` huffman@31564 ` 681` ```apply (rule abs_triangle_ineq) ``` huffman@31564 ` 682` ```apply (rule abs_mult) ``` huffman@31564 ` 683` ```apply (rule abs_mult) ``` huffman@31564 ` 684` ```done ``` huffman@31564 ` 685` huffman@31564 ` 686` ```end ``` huffman@31564 ` 687` hoelzl@51518 ` 688` ```instance real :: linear_continuum_topology .. ``` hoelzl@51518 ` 689` huffman@31446 ` 690` ```subsection {* Extra type constraints *} ``` huffman@31446 ` 691` huffman@31492 ` 692` ```text {* Only allow @{term "open"} in class @{text topological_space}. *} ``` huffman@31492 ` 693` huffman@31492 ` 694` ```setup {* Sign.add_const_constraint ``` huffman@31492 ` 695` ``` (@{const_name "open"}, SOME @{typ "'a::topological_space set \ bool"}) *} ``` huffman@31492 ` 696` huffman@31446 ` 697` ```text {* Only allow @{term dist} in class @{text metric_space}. *} ``` huffman@31446 ` 698` huffman@31446 ` 699` ```setup {* Sign.add_const_constraint ``` huffman@31446 ` 700` ``` (@{const_name dist}, SOME @{typ "'a::metric_space \ 'a \ real"}) *} ``` huffman@31446 ` 701` huffman@31446 ` 702` ```text {* Only allow @{term norm} in class @{text real_normed_vector}. *} ``` huffman@31446 ` 703` huffman@31446 ` 704` ```setup {* Sign.add_const_constraint ``` huffman@31446 ` 705` ``` (@{const_name norm}, SOME @{typ "'a::real_normed_vector \ real"}) *} ``` huffman@31446 ` 706` huffman@22972 ` 707` ```subsection {* Sign function *} ``` huffman@22972 ` 708` nipkow@24506 ` 709` ```lemma norm_sgn: ``` nipkow@24506 ` 710` ``` "norm (sgn(x::'a::real_normed_vector)) = (if x = 0 then 0 else 1)" ``` huffman@31586 ` 711` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 712` nipkow@24506 ` 713` ```lemma sgn_zero [simp]: "sgn(0::'a::real_normed_vector) = 0" ``` nipkow@24506 ` 714` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 715` nipkow@24506 ` 716` ```lemma sgn_zero_iff: "(sgn(x::'a::real_normed_vector) = 0) = (x = 0)" ``` nipkow@24506 ` 717` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 718` nipkow@24506 ` 719` ```lemma sgn_minus: "sgn (- x) = - sgn(x::'a::real_normed_vector)" ``` nipkow@24506 ` 720` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 721` nipkow@24506 ` 722` ```lemma sgn_scaleR: ``` nipkow@24506 ` 723` ``` "sgn (scaleR r x) = scaleR (sgn r) (sgn(x::'a::real_normed_vector))" ``` huffman@31586 ` 724` ```by (simp add: sgn_div_norm mult_ac) ``` huffman@22973 ` 725` huffman@22972 ` 726` ```lemma sgn_one [simp]: "sgn (1::'a::real_normed_algebra_1) = 1" ``` nipkow@24506 ` 727` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 728` huffman@22972 ` 729` ```lemma sgn_of_real: ``` huffman@22972 ` 730` ``` "sgn (of_real r::'a::real_normed_algebra_1) = of_real (sgn r)" ``` huffman@22972 ` 731` ```unfolding of_real_def by (simp only: sgn_scaleR sgn_one) ``` huffman@22972 ` 732` huffman@22973 ` 733` ```lemma sgn_mult: ``` huffman@22973 ` 734` ``` fixes x y :: "'a::real_normed_div_algebra" ``` huffman@22973 ` 735` ``` shows "sgn (x * y) = sgn x * sgn y" ``` nipkow@24506 ` 736` ```by (simp add: sgn_div_norm norm_mult mult_commute) ``` huffman@22973 ` 737` huffman@22972 ` 738` ```lemma real_sgn_eq: "sgn (x::real) = x / \x\" ``` nipkow@24506 ` 739` ```by (simp add: sgn_div_norm divide_inverse) ``` huffman@22972 ` 740` huffman@22972 ` 741` ```lemma real_sgn_pos: "0 < (x::real) \ sgn x = 1" ``` huffman@22972 ` 742` ```unfolding real_sgn_eq by simp ``` huffman@22972 ` 743` huffman@22972 ` 744` ```lemma real_sgn_neg: "(x::real) < 0 \ sgn x = -1" ``` huffman@22972 ` 745` ```unfolding real_sgn_eq by simp ``` huffman@22972 ` 746` hoelzl@51474 ` 747` ```lemma norm_conv_dist: "norm x = dist x 0" ``` hoelzl@51474 ` 748` ``` unfolding dist_norm by simp ``` huffman@22972 ` 749` huffman@22442 ` 750` ```subsection {* Bounded Linear and Bilinear Operators *} ``` huffman@22442 ` 751` wenzelm@46868 ` 752` ```locale bounded_linear = additive f for f :: "'a::real_normed_vector \ 'b::real_normed_vector" + ``` huffman@22442 ` 753` ``` assumes scaleR: "f (scaleR r x) = scaleR r (f x)" ``` huffman@22442 ` 754` ``` assumes bounded: "\K. \x. norm (f x) \ norm x * K" ``` huffman@27443 ` 755` ```begin ``` huffman@22442 ` 756` huffman@27443 ` 757` ```lemma pos_bounded: ``` huffman@22442 ` 758` ``` "\K>0. \x. norm (f x) \ norm x * K" ``` huffman@22442 ` 759` ```proof - ``` huffman@22442 ` 760` ``` obtain K where K: "\x. norm (f x) \ norm x * K" ``` huffman@22442 ` 761` ``` using bounded by fast ``` huffman@22442 ` 762` ``` show ?thesis ``` huffman@22442 ` 763` ``` proof (intro exI impI conjI allI) ``` huffman@22442 ` 764` ``` show "0 < max 1 K" ``` huffman@22442 ` 765` ``` by (rule order_less_le_trans [OF zero_less_one le_maxI1]) ``` huffman@22442 ` 766` ``` next ``` huffman@22442 ` 767` ``` fix x ``` huffman@22442 ` 768` ``` have "norm (f x) \ norm x * K" using K . ``` huffman@22442 ` 769` ``` also have "\ \ norm x * max 1 K" ``` huffman@22442 ` 770` ``` by (rule mult_left_mono [OF le_maxI2 norm_ge_zero]) ``` huffman@22442 ` 771` ``` finally show "norm (f x) \ norm x * max 1 K" . ``` huffman@22442 ` 772` ``` qed ``` huffman@22442 ` 773` ```qed ``` huffman@22442 ` 774` huffman@27443 ` 775` ```lemma nonneg_bounded: ``` huffman@22442 ` 776` ``` "\K\0. \x. norm (f x) \ norm x * K" ``` huffman@22442 ` 777` ```proof - ``` huffman@22442 ` 778` ``` from pos_bounded ``` huffman@22442 ` 779` ``` show ?thesis by (auto intro: order_less_imp_le) ``` huffman@22442 ` 780` ```qed ``` huffman@22442 ` 781` huffman@27443 ` 782` ```end ``` huffman@27443 ` 783` huffman@44127 ` 784` ```lemma bounded_linear_intro: ``` huffman@44127 ` 785` ``` assumes "\x y. f (x + y) = f x + f y" ``` huffman@44127 ` 786` ``` assumes "\r x. f (scaleR r x) = scaleR r (f x)" ``` huffman@44127 ` 787` ``` assumes "\x. norm (f x) \ norm x * K" ``` huffman@44127 ` 788` ``` shows "bounded_linear f" ``` huffman@44127 ` 789` ``` by default (fast intro: assms)+ ``` huffman@44127 ` 790` huffman@22442 ` 791` ```locale bounded_bilinear = ``` huffman@22442 ` 792` ``` fixes prod :: "['a::real_normed_vector, 'b::real_normed_vector] ``` huffman@22442 ` 793` ``` \ 'c::real_normed_vector" ``` huffman@22442 ` 794` ``` (infixl "**" 70) ``` huffman@22442 ` 795` ``` assumes add_left: "prod (a + a') b = prod a b + prod a' b" ``` huffman@22442 ` 796` ``` assumes add_right: "prod a (b + b') = prod a b + prod a b'" ``` huffman@22442 ` 797` ``` assumes scaleR_left: "prod (scaleR r a) b = scaleR r (prod a b)" ``` huffman@22442 ` 798` ``` assumes scaleR_right: "prod a (scaleR r b) = scaleR r (prod a b)" ``` huffman@22442 ` 799` ``` assumes bounded: "\K. \a b. norm (prod a b) \ norm a * norm b * K" ``` huffman@27443 ` 800` ```begin ``` huffman@22442 ` 801` huffman@27443 ` 802` ```lemma pos_bounded: ``` huffman@22442 ` 803` ``` "\K>0. \a b. norm (a ** b) \ norm a * norm b * K" ``` huffman@22442 ` 804` ```apply (cut_tac bounded, erule exE) ``` huffman@22442 ` 805` ```apply (rule_tac x="max 1 K" in exI, safe) ``` huffman@22442 ` 806` ```apply (rule order_less_le_trans [OF zero_less_one le_maxI1]) ``` huffman@22442 ` 807` ```apply (drule spec, drule spec, erule order_trans) ``` huffman@22442 ` 808` ```apply (rule mult_left_mono [OF le_maxI2]) ``` huffman@22442 ` 809` ```apply (intro mult_nonneg_nonneg norm_ge_zero) ``` huffman@22442 ` 810` ```done ``` huffman@22442 ` 811` huffman@27443 ` 812` ```lemma nonneg_bounded: ``` huffman@22442 ` 813` ``` "\K\0. \a b. norm (a ** b) \ norm a * norm b * K" ``` huffman@22442 ` 814` ```proof - ``` huffman@22442 ` 815` ``` from pos_bounded ``` huffman@22442 ` 816` ``` show ?thesis by (auto intro: order_less_imp_le) ``` huffman@22442 ` 817` ```qed ``` huffman@22442 ` 818` huffman@27443 ` 819` ```lemma additive_right: "additive (\b. prod a b)" ``` huffman@22442 ` 820` ```by (rule additive.intro, rule add_right) ``` huffman@22442 ` 821` huffman@27443 ` 822` ```lemma additive_left: "additive (\a. prod a b)" ``` huffman@22442 ` 823` ```by (rule additive.intro, rule add_left) ``` huffman@22442 ` 824` huffman@27443 ` 825` ```lemma zero_left: "prod 0 b = 0" ``` huffman@22442 ` 826` ```by (rule additive.zero [OF additive_left]) ``` huffman@22442 ` 827` huffman@27443 ` 828` ```lemma zero_right: "prod a 0 = 0" ``` huffman@22442 ` 829` ```by (rule additive.zero [OF additive_right]) ``` huffman@22442 ` 830` huffman@27443 ` 831` ```lemma minus_left: "prod (- a) b = - prod a b" ``` huffman@22442 ` 832` ```by (rule additive.minus [OF additive_left]) ``` huffman@22442 ` 833` huffman@27443 ` 834` ```lemma minus_right: "prod a (- b) = - prod a b" ``` huffman@22442 ` 835` ```by (rule additive.minus [OF additive_right]) ``` huffman@22442 ` 836` huffman@27443 ` 837` ```lemma diff_left: ``` huffman@22442 ` 838` ``` "prod (a - a') b = prod a b - prod a' b" ``` huffman@22442 ` 839` ```by (rule additive.diff [OF additive_left]) ``` huffman@22442 ` 840` huffman@27443 ` 841` ```lemma diff_right: ``` huffman@22442 ` 842` ``` "prod a (b - b') = prod a b - prod a b'" ``` huffman@22442 ` 843` ```by (rule additive.diff [OF additive_right]) ``` huffman@22442 ` 844` huffman@27443 ` 845` ```lemma bounded_linear_left: ``` huffman@22442 ` 846` ``` "bounded_linear (\a. a ** b)" ``` huffman@44127 ` 847` ```apply (cut_tac bounded, safe) ``` huffman@44127 ` 848` ```apply (rule_tac K="norm b * K" in bounded_linear_intro) ``` huffman@22442 ` 849` ```apply (rule add_left) ``` huffman@22442 ` 850` ```apply (rule scaleR_left) ``` huffman@22442 ` 851` ```apply (simp add: mult_ac) ``` huffman@22442 ` 852` ```done ``` huffman@22442 ` 853` huffman@27443 ` 854` ```lemma bounded_linear_right: ``` huffman@22442 ` 855` ``` "bounded_linear (\b. a ** b)" ``` huffman@44127 ` 856` ```apply (cut_tac bounded, safe) ``` huffman@44127 ` 857` ```apply (rule_tac K="norm a * K" in bounded_linear_intro) ``` huffman@22442 ` 858` ```apply (rule add_right) ``` huffman@22442 ` 859` ```apply (rule scaleR_right) ``` huffman@22442 ` 860` ```apply (simp add: mult_ac) ``` huffman@22442 ` 861` ```done ``` huffman@22442 ` 862` huffman@27443 ` 863` ```lemma prod_diff_prod: ``` huffman@22442 ` 864` ``` "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)" ``` huffman@22442 ` 865` ```by (simp add: diff_left diff_right) ``` huffman@22442 ` 866` huffman@27443 ` 867` ```end ``` huffman@27443 ` 868` huffman@44282 ` 869` ```lemma bounded_bilinear_mult: ``` huffman@44282 ` 870` ``` "bounded_bilinear (op * :: 'a \ 'a \ 'a::real_normed_algebra)" ``` huffman@22442 ` 871` ```apply (rule bounded_bilinear.intro) ``` webertj@49962 ` 872` ```apply (rule distrib_right) ``` webertj@49962 ` 873` ```apply (rule distrib_left) ``` huffman@22442 ` 874` ```apply (rule mult_scaleR_left) ``` huffman@22442 ` 875` ```apply (rule mult_scaleR_right) ``` huffman@22442 ` 876` ```apply (rule_tac x="1" in exI) ``` huffman@22442 ` 877` ```apply (simp add: norm_mult_ineq) ``` huffman@22442 ` 878` ```done ``` huffman@22442 ` 879` huffman@44282 ` 880` ```lemma bounded_linear_mult_left: ``` huffman@44282 ` 881` ``` "bounded_linear (\x::'a::real_normed_algebra. x * y)" ``` huffman@44282 ` 882` ``` using bounded_bilinear_mult ``` huffman@44282 ` 883` ``` by (rule bounded_bilinear.bounded_linear_left) ``` huffman@22442 ` 884` huffman@44282 ` 885` ```lemma bounded_linear_mult_right: ``` huffman@44282 ` 886` ``` "bounded_linear (\y::'a::real_normed_algebra. x * y)" ``` huffman@44282 ` 887` ``` using bounded_bilinear_mult ``` huffman@44282 ` 888` ``` by (rule bounded_bilinear.bounded_linear_right) ``` huffman@23127 ` 889` huffman@44282 ` 890` ```lemma bounded_linear_divide: ``` huffman@44282 ` 891` ``` "bounded_linear (\x::'a::real_normed_field. x / y)" ``` huffman@44282 ` 892` ``` unfolding divide_inverse by (rule bounded_linear_mult_left) ``` huffman@23120 ` 893` huffman@44282 ` 894` ```lemma bounded_bilinear_scaleR: "bounded_bilinear scaleR" ``` huffman@22442 ` 895` ```apply (rule bounded_bilinear.intro) ``` huffman@22442 ` 896` ```apply (rule scaleR_left_distrib) ``` huffman@22442 ` 897` ```apply (rule scaleR_right_distrib) ``` huffman@22973 ` 898` ```apply simp ``` huffman@22442 ` 899` ```apply (rule scaleR_left_commute) ``` huffman@31586 ` 900` ```apply (rule_tac x="1" in exI, simp) ``` huffman@22442 ` 901` ```done ``` huffman@22442 ` 902` huffman@44282 ` 903` ```lemma bounded_linear_scaleR_left: "bounded_linear (\r. scaleR r x)" ``` huffman@44282 ` 904` ``` using bounded_bilinear_scaleR ``` huffman@44282 ` 905` ``` by (rule bounded_bilinear.bounded_linear_left) ``` huffman@23127 ` 906` huffman@44282 ` 907` ```lemma bounded_linear_scaleR_right: "bounded_linear (\x. scaleR r x)" ``` huffman@44282 ` 908` ``` using bounded_bilinear_scaleR ``` huffman@44282 ` 909` ``` by (rule bounded_bilinear.bounded_linear_right) ``` huffman@23127 ` 910` huffman@44282 ` 911` ```lemma bounded_linear_of_real: "bounded_linear (\r. of_real r)" ``` huffman@44282 ` 912` ``` unfolding of_real_def by (rule bounded_linear_scaleR_left) ``` huffman@22625 ` 913` huffman@44571 ` 914` ```instance real_normed_algebra_1 \ perfect_space ``` huffman@44571 ` 915` ```proof ``` huffman@44571 ` 916` ``` fix x::'a ``` huffman@44571 ` 917` ``` show "\ open {x}" ``` huffman@44571 ` 918` ``` unfolding open_dist dist_norm ``` huffman@44571 ` 919` ``` by (clarsimp, rule_tac x="x + of_real (e/2)" in exI, simp) ``` huffman@44571 ` 920` ```qed ``` huffman@44571 ` 921` huffman@20504 ` 922` ```end ```