src/HOL/RealVector.thy
 author haftmann Tue Apr 28 15:50:30 2009 +0200 (2009-04-28) changeset 31017 2c227493ea56 parent 30729 461ee3e49ad3 child 31285 0a3f9ee4117c permissions -rw-r--r--
stripped class recpower further
 haftmann@29197 ` 1` ```(* Title: HOL/RealVector.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` huffman@20504 ` 7` ```theory RealVector ``` haftmann@29197 ` 8` ```imports RealPow ``` 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" ``` huffman@20504 ` 33` ```by (simp add: diff_def add 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@28029 ` 65` ```proof - ``` ballarin@29229 ` 66` ``` interpret s: additive "\a. scale a x" ``` haftmann@28823 ` 67` ``` proof qed (rule scale_left_distrib) ``` huffman@28029 ` 68` ``` show "scale 0 x = 0" by (rule s.zero) ``` huffman@28029 ` 69` ``` show "scale (- a) x = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 70` ``` show "scale (a - b) x = scale a x - scale b x" by (rule s.diff) ``` huffman@28029 ` 71` ```qed ``` huffman@28029 ` 72` huffman@28029 ` 73` ```lemma scale_zero_right [simp]: "scale a 0 = 0" ``` huffman@28029 ` 74` ``` and scale_minus_right [simp]: "scale a (- x) = - (scale a x)" ``` huffman@30070 ` 75` ``` and scale_right_diff_distrib [algebra_simps]: ``` huffman@30070 ` 76` ``` "scale a (x - y) = scale a x - scale a y" ``` huffman@28029 ` 77` ```proof - ``` ballarin@29229 ` 78` ``` interpret s: additive "\x. scale a x" ``` haftmann@28823 ` 79` ``` proof qed (rule scale_right_distrib) ``` huffman@28029 ` 80` ``` show "scale a 0 = 0" by (rule s.zero) ``` huffman@28029 ` 81` ``` show "scale a (- x) = - (scale a x)" by (rule s.minus) ``` huffman@28029 ` 82` ``` show "scale a (x - y) = scale a x - scale a y" by (rule s.diff) ``` huffman@28029 ` 83` ```qed ``` huffman@28029 ` 84` huffman@28029 ` 85` ```lemma scale_eq_0_iff [simp]: ``` huffman@28029 ` 86` ``` "scale a x = 0 \ a = 0 \ x = 0" ``` huffman@28029 ` 87` ```proof cases ``` huffman@28029 ` 88` ``` assume "a = 0" thus ?thesis by simp ``` huffman@28029 ` 89` ```next ``` huffman@28029 ` 90` ``` assume anz [simp]: "a \ 0" ``` huffman@28029 ` 91` ``` { assume "scale a x = 0" ``` huffman@28029 ` 92` ``` hence "scale (inverse a) (scale a x) = 0" by simp ``` huffman@28029 ` 93` ``` hence "x = 0" by simp } ``` huffman@28029 ` 94` ``` thus ?thesis by force ``` huffman@28029 ` 95` ```qed ``` huffman@28029 ` 96` huffman@28029 ` 97` ```lemma scale_left_imp_eq: ``` huffman@28029 ` 98` ``` "\a \ 0; scale a x = scale a y\ \ x = y" ``` huffman@28029 ` 99` ```proof - ``` huffman@28029 ` 100` ``` assume nonzero: "a \ 0" ``` huffman@28029 ` 101` ``` assume "scale a x = scale a y" ``` huffman@28029 ` 102` ``` hence "scale a (x - y) = 0" ``` huffman@28029 ` 103` ``` by (simp add: scale_right_diff_distrib) ``` huffman@28029 ` 104` ``` hence "x - y = 0" by (simp add: nonzero) ``` huffman@28029 ` 105` ``` thus "x = y" by (simp only: right_minus_eq) ``` huffman@28029 ` 106` ```qed ``` huffman@28029 ` 107` huffman@28029 ` 108` ```lemma scale_right_imp_eq: ``` huffman@28029 ` 109` ``` "\x \ 0; scale a x = scale b x\ \ a = b" ``` huffman@28029 ` 110` ```proof - ``` huffman@28029 ` 111` ``` assume nonzero: "x \ 0" ``` huffman@28029 ` 112` ``` assume "scale a x = scale b x" ``` huffman@28029 ` 113` ``` hence "scale (a - b) x = 0" ``` huffman@28029 ` 114` ``` by (simp add: scale_left_diff_distrib) ``` huffman@28029 ` 115` ``` hence "a - b = 0" by (simp add: nonzero) ``` huffman@28029 ` 116` ``` thus "a = b" by (simp only: right_minus_eq) ``` huffman@28029 ` 117` ```qed ``` huffman@28029 ` 118` huffman@28029 ` 119` ```lemma scale_cancel_left: ``` huffman@28029 ` 120` ``` "scale a x = scale a y \ x = y \ a = 0" ``` huffman@28029 ` 121` ```by (auto intro: scale_left_imp_eq) ``` huffman@28029 ` 122` huffman@28029 ` 123` ```lemma scale_cancel_right: ``` huffman@28029 ` 124` ``` "scale a x = scale b x \ a = b \ x = 0" ``` huffman@28029 ` 125` ```by (auto intro: scale_right_imp_eq) ``` huffman@28029 ` 126` huffman@28029 ` 127` ```end ``` huffman@28029 ` 128` huffman@20504 ` 129` ```subsection {* Real vector spaces *} ``` huffman@20504 ` 130` haftmann@29608 ` 131` ```class scaleR = ``` haftmann@25062 ` 132` ``` fixes scaleR :: "real \ 'a \ 'a" (infixr "*\<^sub>R" 75) ``` haftmann@24748 ` 133` ```begin ``` huffman@20504 ` 134` huffman@20763 ` 135` ```abbreviation ``` haftmann@25062 ` 136` ``` divideR :: "'a \ real \ 'a" (infixl "'/\<^sub>R" 70) ``` haftmann@24748 ` 137` ```where ``` haftmann@25062 ` 138` ``` "x /\<^sub>R r == scaleR (inverse r) x" ``` haftmann@24748 ` 139` haftmann@24748 ` 140` ```end ``` haftmann@24748 ` 141` haftmann@24588 ` 142` ```class real_vector = scaleR + ab_group_add + ``` haftmann@25062 ` 143` ``` assumes scaleR_right_distrib: "scaleR a (x + y) = scaleR a x + scaleR a y" ``` haftmann@25062 ` 144` ``` and scaleR_left_distrib: "scaleR (a + b) x = scaleR a x + scaleR b x" ``` huffman@30070 ` 145` ``` and scaleR_scaleR: "scaleR a (scaleR b x) = scaleR (a * b) x" ``` huffman@30070 ` 146` ``` and scaleR_one: "scaleR 1 x = x" ``` huffman@20504 ` 147` wenzelm@30729 ` 148` ```interpretation real_vector: ``` ballarin@29229 ` 149` ``` vector_space "scaleR :: real \ 'a \ 'a::real_vector" ``` huffman@28009 ` 150` ```apply unfold_locales ``` huffman@28009 ` 151` ```apply (rule scaleR_right_distrib) ``` huffman@28009 ` 152` ```apply (rule scaleR_left_distrib) ``` huffman@28009 ` 153` ```apply (rule scaleR_scaleR) ``` huffman@28009 ` 154` ```apply (rule scaleR_one) ``` huffman@28009 ` 155` ```done ``` huffman@28009 ` 156` huffman@28009 ` 157` ```text {* Recover original theorem names *} ``` huffman@28009 ` 158` huffman@28009 ` 159` ```lemmas scaleR_left_commute = real_vector.scale_left_commute ``` huffman@28009 ` 160` ```lemmas scaleR_zero_left = real_vector.scale_zero_left ``` huffman@28009 ` 161` ```lemmas scaleR_minus_left = real_vector.scale_minus_left ``` huffman@28009 ` 162` ```lemmas scaleR_left_diff_distrib = real_vector.scale_left_diff_distrib ``` huffman@28009 ` 163` ```lemmas scaleR_zero_right = real_vector.scale_zero_right ``` huffman@28009 ` 164` ```lemmas scaleR_minus_right = real_vector.scale_minus_right ``` huffman@28009 ` 165` ```lemmas scaleR_right_diff_distrib = real_vector.scale_right_diff_distrib ``` huffman@28009 ` 166` ```lemmas scaleR_eq_0_iff = real_vector.scale_eq_0_iff ``` huffman@28009 ` 167` ```lemmas scaleR_left_imp_eq = real_vector.scale_left_imp_eq ``` huffman@28009 ` 168` ```lemmas scaleR_right_imp_eq = real_vector.scale_right_imp_eq ``` huffman@28009 ` 169` ```lemmas scaleR_cancel_left = real_vector.scale_cancel_left ``` huffman@28009 ` 170` ```lemmas scaleR_cancel_right = real_vector.scale_cancel_right ``` huffman@28009 ` 171` haftmann@24588 ` 172` ```class real_algebra = real_vector + ring + ``` haftmann@25062 ` 173` ``` assumes mult_scaleR_left [simp]: "scaleR a x * y = scaleR a (x * y)" ``` haftmann@25062 ` 174` ``` and mult_scaleR_right [simp]: "x * scaleR a y = scaleR a (x * y)" ``` huffman@20504 ` 175` haftmann@24588 ` 176` ```class real_algebra_1 = real_algebra + ring_1 ``` huffman@20554 ` 177` haftmann@24588 ` 178` ```class real_div_algebra = real_algebra_1 + division_ring ``` huffman@20584 ` 179` haftmann@24588 ` 180` ```class real_field = real_div_algebra + field ``` huffman@20584 ` 181` huffman@30069 ` 182` ```instantiation real :: real_field ``` huffman@30069 ` 183` ```begin ``` huffman@30069 ` 184` huffman@30069 ` 185` ```definition ``` huffman@30069 ` 186` ``` real_scaleR_def [simp]: "scaleR a x = a * x" ``` huffman@30069 ` 187` huffman@30070 ` 188` ```instance proof ``` huffman@30070 ` 189` ```qed (simp_all add: algebra_simps) ``` huffman@20554 ` 190` huffman@30069 ` 191` ```end ``` huffman@30069 ` 192` wenzelm@30729 ` 193` ```interpretation scaleR_left: additive "(\a. scaleR a x::'a::real_vector)" ``` haftmann@28823 ` 194` ```proof qed (rule scaleR_left_distrib) ``` huffman@20504 ` 195` wenzelm@30729 ` 196` ```interpretation scaleR_right: additive "(\x. scaleR a x::'a::real_vector)" ``` haftmann@28823 ` 197` ```proof qed (rule scaleR_right_distrib) ``` huffman@20504 ` 198` huffman@20584 ` 199` ```lemma nonzero_inverse_scaleR_distrib: ``` huffman@21809 ` 200` ``` fixes x :: "'a::real_div_algebra" shows ``` huffman@21809 ` 201` ``` "\a \ 0; x \ 0\ \ inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` huffman@20763 ` 202` ```by (rule inverse_unique, simp) ``` huffman@20584 ` 203` huffman@20584 ` 204` ```lemma inverse_scaleR_distrib: ``` huffman@20584 ` 205` ``` fixes x :: "'a::{real_div_algebra,division_by_zero}" ``` huffman@21809 ` 206` ``` shows "inverse (scaleR a x) = scaleR (inverse a) (inverse x)" ``` huffman@20584 ` 207` ```apply (case_tac "a = 0", simp) ``` huffman@20584 ` 208` ```apply (case_tac "x = 0", simp) ``` huffman@20584 ` 209` ```apply (erule (1) nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 210` ```done ``` huffman@20584 ` 211` huffman@20554 ` 212` huffman@20554 ` 213` ```subsection {* Embedding of the Reals into any @{text real_algebra_1}: ``` huffman@20554 ` 214` ```@{term of_real} *} ``` huffman@20554 ` 215` huffman@20554 ` 216` ```definition ``` wenzelm@21404 ` 217` ``` of_real :: "real \ 'a::real_algebra_1" where ``` huffman@21809 ` 218` ``` "of_real r = scaleR r 1" ``` huffman@20554 ` 219` huffman@21809 ` 220` ```lemma scaleR_conv_of_real: "scaleR r x = of_real r * x" ``` huffman@20763 ` 221` ```by (simp add: of_real_def) ``` huffman@20763 ` 222` huffman@20554 ` 223` ```lemma of_real_0 [simp]: "of_real 0 = 0" ``` huffman@20554 ` 224` ```by (simp add: of_real_def) ``` huffman@20554 ` 225` huffman@20554 ` 226` ```lemma of_real_1 [simp]: "of_real 1 = 1" ``` huffman@20554 ` 227` ```by (simp add: of_real_def) ``` huffman@20554 ` 228` huffman@20554 ` 229` ```lemma of_real_add [simp]: "of_real (x + y) = of_real x + of_real y" ``` huffman@20554 ` 230` ```by (simp add: of_real_def scaleR_left_distrib) ``` huffman@20554 ` 231` huffman@20554 ` 232` ```lemma of_real_minus [simp]: "of_real (- x) = - of_real x" ``` huffman@20554 ` 233` ```by (simp add: of_real_def) ``` huffman@20554 ` 234` huffman@20554 ` 235` ```lemma of_real_diff [simp]: "of_real (x - y) = of_real x - of_real y" ``` huffman@20554 ` 236` ```by (simp add: of_real_def scaleR_left_diff_distrib) ``` huffman@20554 ` 237` huffman@20554 ` 238` ```lemma of_real_mult [simp]: "of_real (x * y) = of_real x * of_real y" ``` huffman@20763 ` 239` ```by (simp add: of_real_def mult_commute) ``` huffman@20554 ` 240` huffman@20584 ` 241` ```lemma nonzero_of_real_inverse: ``` huffman@20584 ` 242` ``` "x \ 0 \ of_real (inverse x) = ``` huffman@20584 ` 243` ``` inverse (of_real x :: 'a::real_div_algebra)" ``` huffman@20584 ` 244` ```by (simp add: of_real_def nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 245` huffman@20584 ` 246` ```lemma of_real_inverse [simp]: ``` huffman@20584 ` 247` ``` "of_real (inverse x) = ``` huffman@20584 ` 248` ``` inverse (of_real x :: 'a::{real_div_algebra,division_by_zero})" ``` huffman@20584 ` 249` ```by (simp add: of_real_def inverse_scaleR_distrib) ``` huffman@20584 ` 250` huffman@20584 ` 251` ```lemma nonzero_of_real_divide: ``` huffman@20584 ` 252` ``` "y \ 0 \ of_real (x / y) = ``` huffman@20584 ` 253` ``` (of_real x / of_real y :: 'a::real_field)" ``` huffman@20584 ` 254` ```by (simp add: divide_inverse nonzero_of_real_inverse) ``` huffman@20722 ` 255` huffman@20722 ` 256` ```lemma of_real_divide [simp]: ``` huffman@20584 ` 257` ``` "of_real (x / y) = ``` huffman@20584 ` 258` ``` (of_real x / of_real y :: 'a::{real_field,division_by_zero})" ``` huffman@20584 ` 259` ```by (simp add: divide_inverse) ``` huffman@20584 ` 260` huffman@20722 ` 261` ```lemma of_real_power [simp]: ``` haftmann@31017 ` 262` ``` "of_real (x ^ n) = (of_real x :: 'a::{real_algebra_1}) ^ n" ``` huffman@30273 ` 263` ```by (induct n) simp_all ``` huffman@20722 ` 264` huffman@20554 ` 265` ```lemma of_real_eq_iff [simp]: "(of_real x = of_real y) = (x = y)" ``` huffman@20554 ` 266` ```by (simp add: of_real_def scaleR_cancel_right) ``` huffman@20554 ` 267` huffman@20584 ` 268` ```lemmas of_real_eq_0_iff [simp] = of_real_eq_iff [of _ 0, simplified] ``` huffman@20554 ` 269` huffman@20554 ` 270` ```lemma of_real_eq_id [simp]: "of_real = (id :: real \ real)" ``` huffman@20554 ` 271` ```proof ``` huffman@20554 ` 272` ``` fix r ``` huffman@20554 ` 273` ``` show "of_real r = id r" ``` huffman@22973 ` 274` ``` by (simp add: of_real_def) ``` huffman@20554 ` 275` ```qed ``` huffman@20554 ` 276` huffman@20554 ` 277` ```text{*Collapse nested embeddings*} ``` huffman@20554 ` 278` ```lemma of_real_of_nat_eq [simp]: "of_real (of_nat n) = of_nat n" ``` wenzelm@20772 ` 279` ```by (induct n) auto ``` huffman@20554 ` 280` huffman@20554 ` 281` ```lemma of_real_of_int_eq [simp]: "of_real (of_int z) = of_int z" ``` huffman@20554 ` 282` ```by (cases z rule: int_diff_cases, simp) ``` huffman@20554 ` 283` huffman@20554 ` 284` ```lemma of_real_number_of_eq: ``` huffman@20554 ` 285` ``` "of_real (number_of w) = (number_of w :: 'a::{number_ring,real_algebra_1})" ``` huffman@20554 ` 286` ```by (simp add: number_of_eq) ``` huffman@20554 ` 287` huffman@22912 ` 288` ```text{*Every real algebra has characteristic zero*} ``` huffman@22912 ` 289` ```instance real_algebra_1 < ring_char_0 ``` huffman@22912 ` 290` ```proof ``` huffman@23282 ` 291` ``` fix m n :: nat ``` huffman@23282 ` 292` ``` have "(of_real (of_nat m) = (of_real (of_nat n)::'a)) = (m = n)" ``` huffman@23282 ` 293` ``` by (simp only: of_real_eq_iff of_nat_eq_iff) ``` huffman@23282 ` 294` ``` thus "(of_nat m = (of_nat n::'a)) = (m = n)" ``` huffman@23282 ` 295` ``` by (simp only: of_real_of_nat_eq) ``` huffman@22912 ` 296` ```qed ``` huffman@22912 ` 297` huffman@27553 ` 298` ```instance real_field < field_char_0 .. ``` huffman@27553 ` 299` huffman@20554 ` 300` huffman@20554 ` 301` ```subsection {* The Set of Real Numbers *} ``` huffman@20554 ` 302` wenzelm@20772 ` 303` ```definition ``` wenzelm@21404 ` 304` ``` Reals :: "'a::real_algebra_1 set" where ``` huffman@30070 ` 305` ``` [code del]: "Reals = range of_real" ``` huffman@20554 ` 306` wenzelm@21210 ` 307` ```notation (xsymbols) ``` huffman@20554 ` 308` ``` Reals ("\") ``` huffman@20554 ` 309` huffman@21809 ` 310` ```lemma Reals_of_real [simp]: "of_real r \ Reals" ``` huffman@20554 ` 311` ```by (simp add: Reals_def) ``` huffman@20554 ` 312` huffman@21809 ` 313` ```lemma Reals_of_int [simp]: "of_int z \ Reals" ``` huffman@21809 ` 314` ```by (subst of_real_of_int_eq [symmetric], rule Reals_of_real) ``` huffman@20718 ` 315` huffman@21809 ` 316` ```lemma Reals_of_nat [simp]: "of_nat n \ Reals" ``` huffman@21809 ` 317` ```by (subst of_real_of_nat_eq [symmetric], rule Reals_of_real) ``` huffman@21809 ` 318` huffman@21809 ` 319` ```lemma Reals_number_of [simp]: ``` huffman@21809 ` 320` ``` "(number_of w::'a::{number_ring,real_algebra_1}) \ Reals" ``` huffman@21809 ` 321` ```by (subst of_real_number_of_eq [symmetric], rule Reals_of_real) ``` huffman@20718 ` 322` huffman@20554 ` 323` ```lemma Reals_0 [simp]: "0 \ Reals" ``` huffman@20554 ` 324` ```apply (unfold Reals_def) ``` huffman@20554 ` 325` ```apply (rule range_eqI) ``` huffman@20554 ` 326` ```apply (rule of_real_0 [symmetric]) ``` huffman@20554 ` 327` ```done ``` huffman@20554 ` 328` huffman@20554 ` 329` ```lemma Reals_1 [simp]: "1 \ Reals" ``` huffman@20554 ` 330` ```apply (unfold Reals_def) ``` huffman@20554 ` 331` ```apply (rule range_eqI) ``` huffman@20554 ` 332` ```apply (rule of_real_1 [symmetric]) ``` huffman@20554 ` 333` ```done ``` huffman@20554 ` 334` huffman@20584 ` 335` ```lemma Reals_add [simp]: "\a \ Reals; b \ Reals\ \ a + b \ Reals" ``` huffman@20554 ` 336` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 337` ```apply (rule range_eqI) ``` huffman@20554 ` 338` ```apply (rule of_real_add [symmetric]) ``` huffman@20554 ` 339` ```done ``` huffman@20554 ` 340` huffman@20584 ` 341` ```lemma Reals_minus [simp]: "a \ Reals \ - a \ Reals" ``` huffman@20584 ` 342` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 343` ```apply (rule range_eqI) ``` huffman@20584 ` 344` ```apply (rule of_real_minus [symmetric]) ``` huffman@20584 ` 345` ```done ``` huffman@20584 ` 346` huffman@20584 ` 347` ```lemma Reals_diff [simp]: "\a \ Reals; b \ Reals\ \ a - b \ Reals" ``` huffman@20584 ` 348` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 349` ```apply (rule range_eqI) ``` huffman@20584 ` 350` ```apply (rule of_real_diff [symmetric]) ``` huffman@20584 ` 351` ```done ``` huffman@20584 ` 352` huffman@20584 ` 353` ```lemma Reals_mult [simp]: "\a \ Reals; b \ Reals\ \ a * b \ Reals" ``` huffman@20554 ` 354` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 355` ```apply (rule range_eqI) ``` huffman@20554 ` 356` ```apply (rule of_real_mult [symmetric]) ``` huffman@20554 ` 357` ```done ``` huffman@20554 ` 358` huffman@20584 ` 359` ```lemma nonzero_Reals_inverse: ``` huffman@20584 ` 360` ``` fixes a :: "'a::real_div_algebra" ``` huffman@20584 ` 361` ``` shows "\a \ Reals; a \ 0\ \ inverse a \ Reals" ``` huffman@20584 ` 362` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 363` ```apply (rule range_eqI) ``` huffman@20584 ` 364` ```apply (erule nonzero_of_real_inverse [symmetric]) ``` huffman@20584 ` 365` ```done ``` huffman@20584 ` 366` huffman@20584 ` 367` ```lemma Reals_inverse [simp]: ``` huffman@20584 ` 368` ``` fixes a :: "'a::{real_div_algebra,division_by_zero}" ``` huffman@20584 ` 369` ``` shows "a \ Reals \ inverse a \ Reals" ``` huffman@20584 ` 370` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 371` ```apply (rule range_eqI) ``` huffman@20584 ` 372` ```apply (rule of_real_inverse [symmetric]) ``` huffman@20584 ` 373` ```done ``` huffman@20584 ` 374` huffman@20584 ` 375` ```lemma nonzero_Reals_divide: ``` huffman@20584 ` 376` ``` fixes a b :: "'a::real_field" ``` huffman@20584 ` 377` ``` shows "\a \ Reals; b \ Reals; b \ 0\ \ a / b \ Reals" ``` huffman@20584 ` 378` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 379` ```apply (rule range_eqI) ``` huffman@20584 ` 380` ```apply (erule nonzero_of_real_divide [symmetric]) ``` huffman@20584 ` 381` ```done ``` huffman@20584 ` 382` huffman@20584 ` 383` ```lemma Reals_divide [simp]: ``` huffman@20584 ` 384` ``` fixes a b :: "'a::{real_field,division_by_zero}" ``` huffman@20584 ` 385` ``` shows "\a \ Reals; b \ Reals\ \ a / b \ Reals" ``` huffman@20584 ` 386` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 387` ```apply (rule range_eqI) ``` huffman@20584 ` 388` ```apply (rule of_real_divide [symmetric]) ``` huffman@20584 ` 389` ```done ``` huffman@20584 ` 390` huffman@20722 ` 391` ```lemma Reals_power [simp]: ``` haftmann@31017 ` 392` ``` fixes a :: "'a::{real_algebra_1}" ``` huffman@20722 ` 393` ``` shows "a \ Reals \ a ^ n \ Reals" ``` huffman@20722 ` 394` ```apply (auto simp add: Reals_def) ``` huffman@20722 ` 395` ```apply (rule range_eqI) ``` huffman@20722 ` 396` ```apply (rule of_real_power [symmetric]) ``` huffman@20722 ` 397` ```done ``` huffman@20722 ` 398` huffman@20554 ` 399` ```lemma Reals_cases [cases set: Reals]: ``` huffman@20554 ` 400` ``` assumes "q \ \" ``` huffman@20554 ` 401` ``` obtains (of_real) r where "q = of_real r" ``` huffman@20554 ` 402` ``` unfolding Reals_def ``` huffman@20554 ` 403` ```proof - ``` huffman@20554 ` 404` ``` from `q \ \` have "q \ range of_real" unfolding Reals_def . ``` huffman@20554 ` 405` ``` then obtain r where "q = of_real r" .. ``` huffman@20554 ` 406` ``` then show thesis .. ``` huffman@20554 ` 407` ```qed ``` huffman@20554 ` 408` huffman@20554 ` 409` ```lemma Reals_induct [case_names of_real, induct set: Reals]: ``` huffman@20554 ` 410` ``` "q \ \ \ (\r. P (of_real r)) \ P q" ``` huffman@20554 ` 411` ``` by (rule Reals_cases) auto ``` huffman@20554 ` 412` huffman@20504 ` 413` huffman@20504 ` 414` ```subsection {* Real normed vector spaces *} ``` huffman@20504 ` 415` haftmann@29608 ` 416` ```class norm = ``` huffman@22636 ` 417` ``` fixes norm :: "'a \ real" ``` huffman@20504 ` 418` huffman@24520 ` 419` ```class sgn_div_norm = scaleR + norm + sgn + ``` haftmann@25062 ` 420` ``` assumes sgn_div_norm: "sgn x = x /\<^sub>R norm x" ``` nipkow@24506 ` 421` haftmann@24588 ` 422` ```class real_normed_vector = real_vector + sgn_div_norm + ``` haftmann@24588 ` 423` ``` assumes norm_ge_zero [simp]: "0 \ norm x" ``` haftmann@25062 ` 424` ``` and norm_eq_zero [simp]: "norm x = 0 \ x = 0" ``` haftmann@25062 ` 425` ``` and norm_triangle_ineq: "norm (x + y) \ norm x + norm y" ``` haftmann@24588 ` 426` ``` and norm_scaleR: "norm (scaleR a x) = \a\ * norm x" ``` huffman@20504 ` 427` haftmann@24588 ` 428` ```class real_normed_algebra = real_algebra + real_normed_vector + ``` haftmann@25062 ` 429` ``` assumes norm_mult_ineq: "norm (x * y) \ norm x * norm y" ``` huffman@20504 ` 430` haftmann@24588 ` 431` ```class real_normed_algebra_1 = real_algebra_1 + real_normed_algebra + ``` haftmann@25062 ` 432` ``` assumes norm_one [simp]: "norm 1 = 1" ``` huffman@22852 ` 433` haftmann@24588 ` 434` ```class real_normed_div_algebra = real_div_algebra + real_normed_vector + ``` haftmann@25062 ` 435` ``` assumes norm_mult: "norm (x * y) = norm x * norm y" ``` huffman@20504 ` 436` haftmann@24588 ` 437` ```class real_normed_field = real_field + real_normed_div_algebra ``` huffman@20584 ` 438` huffman@22852 ` 439` ```instance real_normed_div_algebra < real_normed_algebra_1 ``` huffman@20554 ` 440` ```proof ``` huffman@20554 ` 441` ``` fix x y :: 'a ``` huffman@20554 ` 442` ``` show "norm (x * y) \ norm x * norm y" ``` huffman@20554 ` 443` ``` by (simp add: norm_mult) ``` huffman@22852 ` 444` ```next ``` huffman@22852 ` 445` ``` have "norm (1 * 1::'a) = norm (1::'a) * norm (1::'a)" ``` huffman@22852 ` 446` ``` by (rule norm_mult) ``` huffman@22852 ` 447` ``` thus "norm (1::'a) = 1" by simp ``` huffman@20554 ` 448` ```qed ``` huffman@20554 ` 449` huffman@30069 ` 450` ```instantiation real :: real_normed_field ``` huffman@30069 ` 451` ```begin ``` huffman@30069 ` 452` huffman@30069 ` 453` ```definition ``` huffman@30069 ` 454` ``` real_norm_def [simp]: "norm r = \r\" ``` huffman@30069 ` 455` huffman@30069 ` 456` ```instance ``` huffman@22852 ` 457` ```apply (intro_classes, unfold real_norm_def real_scaleR_def) ``` nipkow@24506 ` 458` ```apply (simp add: real_sgn_def) ``` huffman@20554 ` 459` ```apply (rule abs_ge_zero) ``` huffman@20554 ` 460` ```apply (rule abs_eq_0) ``` huffman@20554 ` 461` ```apply (rule abs_triangle_ineq) ``` huffman@22852 ` 462` ```apply (rule abs_mult) ``` huffman@20554 ` 463` ```apply (rule abs_mult) ``` huffman@20554 ` 464` ```done ``` huffman@20504 ` 465` huffman@30069 ` 466` ```end ``` huffman@30069 ` 467` huffman@22852 ` 468` ```lemma norm_zero [simp]: "norm (0::'a::real_normed_vector) = 0" ``` huffman@20504 ` 469` ```by simp ``` huffman@20504 ` 470` huffman@22852 ` 471` ```lemma zero_less_norm_iff [simp]: ``` huffman@22852 ` 472` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 473` ``` shows "(0 < norm x) = (x \ 0)" ``` huffman@20504 ` 474` ```by (simp add: order_less_le) ``` huffman@20504 ` 475` huffman@22852 ` 476` ```lemma norm_not_less_zero [simp]: ``` huffman@22852 ` 477` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 478` ``` shows "\ norm x < 0" ``` huffman@20828 ` 479` ```by (simp add: linorder_not_less) ``` huffman@20828 ` 480` huffman@22852 ` 481` ```lemma norm_le_zero_iff [simp]: ``` huffman@22852 ` 482` ``` fixes x :: "'a::real_normed_vector" ``` huffman@22852 ` 483` ``` shows "(norm x \ 0) = (x = 0)" ``` huffman@20828 ` 484` ```by (simp add: order_le_less) ``` huffman@20828 ` 485` huffman@20504 ` 486` ```lemma norm_minus_cancel [simp]: ``` huffman@20584 ` 487` ``` fixes x :: "'a::real_normed_vector" ``` huffman@20584 ` 488` ``` shows "norm (- x) = norm x" ``` huffman@20504 ` 489` ```proof - ``` huffman@21809 ` 490` ``` have "norm (- x) = norm (scaleR (- 1) x)" ``` huffman@20504 ` 491` ``` by (simp only: scaleR_minus_left scaleR_one) ``` huffman@20533 ` 492` ``` also have "\ = \- 1\ * norm x" ``` huffman@20504 ` 493` ``` by (rule norm_scaleR) ``` huffman@20504 ` 494` ``` finally show ?thesis by simp ``` huffman@20504 ` 495` ```qed ``` huffman@20504 ` 496` huffman@20504 ` 497` ```lemma norm_minus_commute: ``` huffman@20584 ` 498` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 499` ``` shows "norm (a - b) = norm (b - a)" ``` huffman@20504 ` 500` ```proof - ``` huffman@22898 ` 501` ``` have "norm (- (b - a)) = norm (b - a)" ``` huffman@22898 ` 502` ``` by (rule norm_minus_cancel) ``` huffman@22898 ` 503` ``` thus ?thesis by simp ``` huffman@20504 ` 504` ```qed ``` huffman@20504 ` 505` huffman@20504 ` 506` ```lemma norm_triangle_ineq2: ``` huffman@20584 ` 507` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 508` ``` shows "norm a - norm b \ norm (a - b)" ``` huffman@20504 ` 509` ```proof - ``` huffman@20533 ` 510` ``` have "norm (a - b + b) \ norm (a - b) + norm b" ``` huffman@20504 ` 511` ``` by (rule norm_triangle_ineq) ``` huffman@22898 ` 512` ``` thus ?thesis by simp ``` huffman@20504 ` 513` ```qed ``` huffman@20504 ` 514` huffman@20584 ` 515` ```lemma norm_triangle_ineq3: ``` huffman@20584 ` 516` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 517` ``` shows "\norm a - norm b\ \ norm (a - b)" ``` huffman@20584 ` 518` ```apply (subst abs_le_iff) ``` huffman@20584 ` 519` ```apply auto ``` huffman@20584 ` 520` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 521` ```apply (subst norm_minus_commute) ``` huffman@20584 ` 522` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 523` ```done ``` huffman@20584 ` 524` huffman@20504 ` 525` ```lemma norm_triangle_ineq4: ``` huffman@20584 ` 526` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 527` ``` shows "norm (a - b) \ norm a + norm b" ``` huffman@20504 ` 528` ```proof - ``` huffman@22898 ` 529` ``` have "norm (a + - b) \ norm a + norm (- b)" ``` huffman@20504 ` 530` ``` by (rule norm_triangle_ineq) ``` huffman@22898 ` 531` ``` thus ?thesis ``` huffman@22898 ` 532` ``` by (simp only: diff_minus norm_minus_cancel) ``` huffman@22898 ` 533` ```qed ``` huffman@22898 ` 534` huffman@22898 ` 535` ```lemma norm_diff_ineq: ``` huffman@22898 ` 536` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@22898 ` 537` ``` shows "norm a - norm b \ norm (a + b)" ``` huffman@22898 ` 538` ```proof - ``` huffman@22898 ` 539` ``` have "norm a - norm (- b) \ norm (a - - b)" ``` huffman@22898 ` 540` ``` by (rule norm_triangle_ineq2) ``` huffman@22898 ` 541` ``` thus ?thesis by simp ``` huffman@20504 ` 542` ```qed ``` huffman@20504 ` 543` huffman@20551 ` 544` ```lemma norm_diff_triangle_ineq: ``` huffman@20551 ` 545` ``` fixes a b c d :: "'a::real_normed_vector" ``` huffman@20551 ` 546` ``` shows "norm ((a + b) - (c + d)) \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 547` ```proof - ``` huffman@20551 ` 548` ``` have "norm ((a + b) - (c + d)) = norm ((a - c) + (b - d))" ``` huffman@20551 ` 549` ``` by (simp add: diff_minus add_ac) ``` huffman@20551 ` 550` ``` also have "\ \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 551` ``` by (rule norm_triangle_ineq) ``` huffman@20551 ` 552` ``` finally show ?thesis . ``` huffman@20551 ` 553` ```qed ``` huffman@20551 ` 554` huffman@22857 ` 555` ```lemma abs_norm_cancel [simp]: ``` huffman@22857 ` 556` ``` fixes a :: "'a::real_normed_vector" ``` huffman@22857 ` 557` ``` shows "\norm a\ = norm a" ``` huffman@22857 ` 558` ```by (rule abs_of_nonneg [OF norm_ge_zero]) ``` huffman@22857 ` 559` huffman@22880 ` 560` ```lemma norm_add_less: ``` huffman@22880 ` 561` ``` fixes x y :: "'a::real_normed_vector" ``` huffman@22880 ` 562` ``` shows "\norm x < r; norm y < s\ \ norm (x + y) < r + s" ``` huffman@22880 ` 563` ```by (rule order_le_less_trans [OF norm_triangle_ineq add_strict_mono]) ``` huffman@22880 ` 564` huffman@22880 ` 565` ```lemma norm_mult_less: ``` huffman@22880 ` 566` ``` fixes x y :: "'a::real_normed_algebra" ``` huffman@22880 ` 567` ``` shows "\norm x < r; norm y < s\ \ norm (x * y) < r * s" ``` huffman@22880 ` 568` ```apply (rule order_le_less_trans [OF norm_mult_ineq]) ``` huffman@22880 ` 569` ```apply (simp add: mult_strict_mono') ``` huffman@22880 ` 570` ```done ``` huffman@22880 ` 571` huffman@22857 ` 572` ```lemma norm_of_real [simp]: ``` huffman@22857 ` 573` ``` "norm (of_real r :: 'a::real_normed_algebra_1) = \r\" ``` huffman@22852 ` 574` ```unfolding of_real_def by (simp add: norm_scaleR) ``` huffman@20560 ` 575` huffman@22876 ` 576` ```lemma norm_number_of [simp]: ``` huffman@22876 ` 577` ``` "norm (number_of w::'a::{number_ring,real_normed_algebra_1}) ``` huffman@22876 ` 578` ``` = \number_of w\" ``` huffman@22876 ` 579` ```by (subst of_real_number_of_eq [symmetric], rule norm_of_real) ``` huffman@22876 ` 580` huffman@22876 ` 581` ```lemma norm_of_int [simp]: ``` huffman@22876 ` 582` ``` "norm (of_int z::'a::real_normed_algebra_1) = \of_int z\" ``` huffman@22876 ` 583` ```by (subst of_real_of_int_eq [symmetric], rule norm_of_real) ``` huffman@22876 ` 584` huffman@22876 ` 585` ```lemma norm_of_nat [simp]: ``` huffman@22876 ` 586` ``` "norm (of_nat n::'a::real_normed_algebra_1) = of_nat n" ``` huffman@22876 ` 587` ```apply (subst of_real_of_nat_eq [symmetric]) ``` huffman@22876 ` 588` ```apply (subst norm_of_real, simp) ``` huffman@22876 ` 589` ```done ``` huffman@22876 ` 590` huffman@20504 ` 591` ```lemma nonzero_norm_inverse: ``` huffman@20504 ` 592` ``` fixes a :: "'a::real_normed_div_algebra" ``` huffman@20533 ` 593` ``` shows "a \ 0 \ norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 594` ```apply (rule inverse_unique [symmetric]) ``` huffman@20504 ` 595` ```apply (simp add: norm_mult [symmetric]) ``` huffman@20504 ` 596` ```done ``` huffman@20504 ` 597` huffman@20504 ` 598` ```lemma norm_inverse: ``` huffman@20504 ` 599` ``` fixes a :: "'a::{real_normed_div_algebra,division_by_zero}" ``` huffman@20533 ` 600` ``` shows "norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 601` ```apply (case_tac "a = 0", simp) ``` huffman@20504 ` 602` ```apply (erule nonzero_norm_inverse) ``` huffman@20504 ` 603` ```done ``` huffman@20504 ` 604` huffman@20584 ` 605` ```lemma nonzero_norm_divide: ``` huffman@20584 ` 606` ``` fixes a b :: "'a::real_normed_field" ``` huffman@20584 ` 607` ``` shows "b \ 0 \ norm (a / b) = norm a / norm b" ``` huffman@20584 ` 608` ```by (simp add: divide_inverse norm_mult nonzero_norm_inverse) ``` huffman@20584 ` 609` huffman@20584 ` 610` ```lemma norm_divide: ``` huffman@20584 ` 611` ``` fixes a b :: "'a::{real_normed_field,division_by_zero}" ``` huffman@20584 ` 612` ``` shows "norm (a / b) = norm a / norm b" ``` huffman@20584 ` 613` ```by (simp add: divide_inverse norm_mult norm_inverse) ``` huffman@20584 ` 614` huffman@22852 ` 615` ```lemma norm_power_ineq: ``` haftmann@31017 ` 616` ``` fixes x :: "'a::{real_normed_algebra_1}" ``` huffman@22852 ` 617` ``` shows "norm (x ^ n) \ norm x ^ n" ``` huffman@22852 ` 618` ```proof (induct n) ``` huffman@22852 ` 619` ``` case 0 show "norm (x ^ 0) \ norm x ^ 0" by simp ``` huffman@22852 ` 620` ```next ``` huffman@22852 ` 621` ``` case (Suc n) ``` huffman@22852 ` 622` ``` have "norm (x * x ^ n) \ norm x * norm (x ^ n)" ``` huffman@22852 ` 623` ``` by (rule norm_mult_ineq) ``` huffman@22852 ` 624` ``` also from Suc have "\ \ norm x * norm x ^ n" ``` huffman@22852 ` 625` ``` using norm_ge_zero by (rule mult_left_mono) ``` huffman@22852 ` 626` ``` finally show "norm (x ^ Suc n) \ norm x ^ Suc n" ``` huffman@30273 ` 627` ``` by simp ``` huffman@22852 ` 628` ```qed ``` huffman@22852 ` 629` huffman@20684 ` 630` ```lemma norm_power: ``` haftmann@31017 ` 631` ``` fixes x :: "'a::{real_normed_div_algebra}" ``` huffman@20684 ` 632` ``` shows "norm (x ^ n) = norm x ^ n" ``` huffman@30273 ` 633` ```by (induct n) (simp_all add: norm_mult) ``` huffman@20684 ` 634` huffman@22442 ` 635` huffman@22972 ` 636` ```subsection {* Sign function *} ``` huffman@22972 ` 637` nipkow@24506 ` 638` ```lemma norm_sgn: ``` nipkow@24506 ` 639` ``` "norm (sgn(x::'a::real_normed_vector)) = (if x = 0 then 0 else 1)" ``` nipkow@24506 ` 640` ```by (simp add: sgn_div_norm norm_scaleR) ``` huffman@22972 ` 641` nipkow@24506 ` 642` ```lemma sgn_zero [simp]: "sgn(0::'a::real_normed_vector) = 0" ``` nipkow@24506 ` 643` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 644` nipkow@24506 ` 645` ```lemma sgn_zero_iff: "(sgn(x::'a::real_normed_vector) = 0) = (x = 0)" ``` nipkow@24506 ` 646` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 647` nipkow@24506 ` 648` ```lemma sgn_minus: "sgn (- x) = - sgn(x::'a::real_normed_vector)" ``` nipkow@24506 ` 649` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 650` nipkow@24506 ` 651` ```lemma sgn_scaleR: ``` nipkow@24506 ` 652` ``` "sgn (scaleR r x) = scaleR (sgn r) (sgn(x::'a::real_normed_vector))" ``` nipkow@24506 ` 653` ```by (simp add: sgn_div_norm norm_scaleR mult_ac) ``` huffman@22973 ` 654` huffman@22972 ` 655` ```lemma sgn_one [simp]: "sgn (1::'a::real_normed_algebra_1) = 1" ``` nipkow@24506 ` 656` ```by (simp add: sgn_div_norm) ``` huffman@22972 ` 657` huffman@22972 ` 658` ```lemma sgn_of_real: ``` huffman@22972 ` 659` ``` "sgn (of_real r::'a::real_normed_algebra_1) = of_real (sgn r)" ``` huffman@22972 ` 660` ```unfolding of_real_def by (simp only: sgn_scaleR sgn_one) ``` huffman@22972 ` 661` huffman@22973 ` 662` ```lemma sgn_mult: ``` huffman@22973 ` 663` ``` fixes x y :: "'a::real_normed_div_algebra" ``` huffman@22973 ` 664` ``` shows "sgn (x * y) = sgn x * sgn y" ``` nipkow@24506 ` 665` ```by (simp add: sgn_div_norm norm_mult mult_commute) ``` huffman@22973 ` 666` huffman@22972 ` 667` ```lemma real_sgn_eq: "sgn (x::real) = x / \x\" ``` nipkow@24506 ` 668` ```by (simp add: sgn_div_norm divide_inverse) ``` huffman@22972 ` 669` huffman@22972 ` 670` ```lemma real_sgn_pos: "0 < (x::real) \ sgn x = 1" ``` huffman@22972 ` 671` ```unfolding real_sgn_eq by simp ``` huffman@22972 ` 672` huffman@22972 ` 673` ```lemma real_sgn_neg: "(x::real) < 0 \ sgn x = -1" ``` huffman@22972 ` 674` ```unfolding real_sgn_eq by simp ``` huffman@22972 ` 675` huffman@22972 ` 676` huffman@22442 ` 677` ```subsection {* Bounded Linear and Bilinear Operators *} ``` huffman@22442 ` 678` huffman@22442 ` 679` ```locale bounded_linear = additive + ``` huffman@22442 ` 680` ``` constrains f :: "'a::real_normed_vector \ 'b::real_normed_vector" ``` huffman@22442 ` 681` ``` assumes scaleR: "f (scaleR r x) = scaleR r (f x)" ``` huffman@22442 ` 682` ``` assumes bounded: "\K. \x. norm (f x) \ norm x * K" ``` huffman@27443 ` 683` ```begin ``` huffman@22442 ` 684` huffman@27443 ` 685` ```lemma pos_bounded: ``` huffman@22442 ` 686` ``` "\K>0. \x. norm (f x) \ norm x * K" ``` huffman@22442 ` 687` ```proof - ``` huffman@22442 ` 688` ``` obtain K where K: "\x. norm (f x) \ norm x * K" ``` huffman@22442 ` 689` ``` using bounded by fast ``` huffman@22442 ` 690` ``` show ?thesis ``` huffman@22442 ` 691` ``` proof (intro exI impI conjI allI) ``` huffman@22442 ` 692` ``` show "0 < max 1 K" ``` huffman@22442 ` 693` ``` by (rule order_less_le_trans [OF zero_less_one le_maxI1]) ``` huffman@22442 ` 694` ``` next ``` huffman@22442 ` 695` ``` fix x ``` huffman@22442 ` 696` ``` have "norm (f x) \ norm x * K" using K . ``` huffman@22442 ` 697` ``` also have "\ \ norm x * max 1 K" ``` huffman@22442 ` 698` ``` by (rule mult_left_mono [OF le_maxI2 norm_ge_zero]) ``` huffman@22442 ` 699` ``` finally show "norm (f x) \ norm x * max 1 K" . ``` huffman@22442 ` 700` ``` qed ``` huffman@22442 ` 701` ```qed ``` huffman@22442 ` 702` huffman@27443 ` 703` ```lemma nonneg_bounded: ``` huffman@22442 ` 704` ``` "\K\0. \x. norm (f x) \ norm x * K" ``` huffman@22442 ` 705` ```proof - ``` huffman@22442 ` 706` ``` from pos_bounded ``` huffman@22442 ` 707` ``` show ?thesis by (auto intro: order_less_imp_le) ``` huffman@22442 ` 708` ```qed ``` huffman@22442 ` 709` huffman@27443 ` 710` ```end ``` huffman@27443 ` 711` huffman@22442 ` 712` ```locale bounded_bilinear = ``` huffman@22442 ` 713` ``` fixes prod :: "['a::real_normed_vector, 'b::real_normed_vector] ``` huffman@22442 ` 714` ``` \ 'c::real_normed_vector" ``` huffman@22442 ` 715` ``` (infixl "**" 70) ``` huffman@22442 ` 716` ``` assumes add_left: "prod (a + a') b = prod a b + prod a' b" ``` huffman@22442 ` 717` ``` assumes add_right: "prod a (b + b') = prod a b + prod a b'" ``` huffman@22442 ` 718` ``` assumes scaleR_left: "prod (scaleR r a) b = scaleR r (prod a b)" ``` huffman@22442 ` 719` ``` assumes scaleR_right: "prod a (scaleR r b) = scaleR r (prod a b)" ``` huffman@22442 ` 720` ``` assumes bounded: "\K. \a b. norm (prod a b) \ norm a * norm b * K" ``` huffman@27443 ` 721` ```begin ``` huffman@22442 ` 722` huffman@27443 ` 723` ```lemma pos_bounded: ``` huffman@22442 ` 724` ``` "\K>0. \a b. norm (a ** b) \ norm a * norm b * K" ``` huffman@22442 ` 725` ```apply (cut_tac bounded, erule exE) ``` huffman@22442 ` 726` ```apply (rule_tac x="max 1 K" in exI, safe) ``` huffman@22442 ` 727` ```apply (rule order_less_le_trans [OF zero_less_one le_maxI1]) ``` huffman@22442 ` 728` ```apply (drule spec, drule spec, erule order_trans) ``` huffman@22442 ` 729` ```apply (rule mult_left_mono [OF le_maxI2]) ``` huffman@22442 ` 730` ```apply (intro mult_nonneg_nonneg norm_ge_zero) ``` huffman@22442 ` 731` ```done ``` huffman@22442 ` 732` huffman@27443 ` 733` ```lemma nonneg_bounded: ``` huffman@22442 ` 734` ``` "\K\0. \a b. norm (a ** b) \ norm a * norm b * K" ``` huffman@22442 ` 735` ```proof - ``` huffman@22442 ` 736` ``` from pos_bounded ``` huffman@22442 ` 737` ``` show ?thesis by (auto intro: order_less_imp_le) ``` huffman@22442 ` 738` ```qed ``` huffman@22442 ` 739` huffman@27443 ` 740` ```lemma additive_right: "additive (\b. prod a b)" ``` huffman@22442 ` 741` ```by (rule additive.intro, rule add_right) ``` huffman@22442 ` 742` huffman@27443 ` 743` ```lemma additive_left: "additive (\a. prod a b)" ``` huffman@22442 ` 744` ```by (rule additive.intro, rule add_left) ``` huffman@22442 ` 745` huffman@27443 ` 746` ```lemma zero_left: "prod 0 b = 0" ``` huffman@22442 ` 747` ```by (rule additive.zero [OF additive_left]) ``` huffman@22442 ` 748` huffman@27443 ` 749` ```lemma zero_right: "prod a 0 = 0" ``` huffman@22442 ` 750` ```by (rule additive.zero [OF additive_right]) ``` huffman@22442 ` 751` huffman@27443 ` 752` ```lemma minus_left: "prod (- a) b = - prod a b" ``` huffman@22442 ` 753` ```by (rule additive.minus [OF additive_left]) ``` huffman@22442 ` 754` huffman@27443 ` 755` ```lemma minus_right: "prod a (- b) = - prod a b" ``` huffman@22442 ` 756` ```by (rule additive.minus [OF additive_right]) ``` huffman@22442 ` 757` huffman@27443 ` 758` ```lemma diff_left: ``` huffman@22442 ` 759` ``` "prod (a - a') b = prod a b - prod a' b" ``` huffman@22442 ` 760` ```by (rule additive.diff [OF additive_left]) ``` huffman@22442 ` 761` huffman@27443 ` 762` ```lemma diff_right: ``` huffman@22442 ` 763` ``` "prod a (b - b') = prod a b - prod a b'" ``` huffman@22442 ` 764` ```by (rule additive.diff [OF additive_right]) ``` huffman@22442 ` 765` huffman@27443 ` 766` ```lemma bounded_linear_left: ``` huffman@22442 ` 767` ``` "bounded_linear (\a. a ** b)" ``` huffman@22442 ` 768` ```apply (unfold_locales) ``` huffman@22442 ` 769` ```apply (rule add_left) ``` huffman@22442 ` 770` ```apply (rule scaleR_left) ``` huffman@22442 ` 771` ```apply (cut_tac bounded, safe) ``` huffman@22442 ` 772` ```apply (rule_tac x="norm b * K" in exI) ``` huffman@22442 ` 773` ```apply (simp add: mult_ac) ``` huffman@22442 ` 774` ```done ``` huffman@22442 ` 775` huffman@27443 ` 776` ```lemma bounded_linear_right: ``` huffman@22442 ` 777` ``` "bounded_linear (\b. a ** b)" ``` huffman@22442 ` 778` ```apply (unfold_locales) ``` huffman@22442 ` 779` ```apply (rule add_right) ``` huffman@22442 ` 780` ```apply (rule scaleR_right) ``` huffman@22442 ` 781` ```apply (cut_tac bounded, safe) ``` huffman@22442 ` 782` ```apply (rule_tac x="norm a * K" in exI) ``` huffman@22442 ` 783` ```apply (simp add: mult_ac) ``` huffman@22442 ` 784` ```done ``` huffman@22442 ` 785` huffman@27443 ` 786` ```lemma prod_diff_prod: ``` huffman@22442 ` 787` ``` "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)" ``` huffman@22442 ` 788` ```by (simp add: diff_left diff_right) ``` huffman@22442 ` 789` huffman@27443 ` 790` ```end ``` huffman@27443 ` 791` wenzelm@30729 ` 792` ```interpretation mult: ``` ballarin@29229 ` 793` ``` bounded_bilinear "op * :: 'a \ 'a \ 'a::real_normed_algebra" ``` huffman@22442 ` 794` ```apply (rule bounded_bilinear.intro) ``` huffman@22442 ` 795` ```apply (rule left_distrib) ``` huffman@22442 ` 796` ```apply (rule right_distrib) ``` huffman@22442 ` 797` ```apply (rule mult_scaleR_left) ``` huffman@22442 ` 798` ```apply (rule mult_scaleR_right) ``` huffman@22442 ` 799` ```apply (rule_tac x="1" in exI) ``` huffman@22442 ` 800` ```apply (simp add: norm_mult_ineq) ``` huffman@22442 ` 801` ```done ``` huffman@22442 ` 802` wenzelm@30729 ` 803` ```interpretation mult_left: ``` ballarin@29229 ` 804` ``` bounded_linear "(\x::'a::real_normed_algebra. x * y)" ``` huffman@23127 ` 805` ```by (rule mult.bounded_linear_left) ``` huffman@22442 ` 806` wenzelm@30729 ` 807` ```interpretation mult_right: ``` ballarin@29229 ` 808` ``` bounded_linear "(\y::'a::real_normed_algebra. x * y)" ``` huffman@23127 ` 809` ```by (rule mult.bounded_linear_right) ``` huffman@23127 ` 810` wenzelm@30729 ` 811` ```interpretation divide: ``` ballarin@29229 ` 812` ``` bounded_linear "(\x::'a::real_normed_field. x / y)" ``` huffman@23127 ` 813` ```unfolding divide_inverse by (rule mult.bounded_linear_left) ``` huffman@23120 ` 814` wenzelm@30729 ` 815` ```interpretation scaleR: bounded_bilinear "scaleR" ``` huffman@22442 ` 816` ```apply (rule bounded_bilinear.intro) ``` huffman@22442 ` 817` ```apply (rule scaleR_left_distrib) ``` huffman@22442 ` 818` ```apply (rule scaleR_right_distrib) ``` huffman@22973 ` 819` ```apply simp ``` huffman@22442 ` 820` ```apply (rule scaleR_left_commute) ``` huffman@22442 ` 821` ```apply (rule_tac x="1" in exI) ``` huffman@22442 ` 822` ```apply (simp add: norm_scaleR) ``` huffman@22442 ` 823` ```done ``` huffman@22442 ` 824` wenzelm@30729 ` 825` ```interpretation scaleR_left: bounded_linear "\r. scaleR r x" ``` huffman@23127 ` 826` ```by (rule scaleR.bounded_linear_left) ``` huffman@23127 ` 827` wenzelm@30729 ` 828` ```interpretation scaleR_right: bounded_linear "\x. scaleR r x" ``` huffman@23127 ` 829` ```by (rule scaleR.bounded_linear_right) ``` huffman@23127 ` 830` wenzelm@30729 ` 831` ```interpretation of_real: bounded_linear "\r. of_real r" ``` huffman@23127 ` 832` ```unfolding of_real_def by (rule scaleR.bounded_linear_left) ``` huffman@22625 ` 833` huffman@20504 ` 834` ```end ```