src/HOL/Real/RealVector.thy
 author wenzelm Fri Nov 17 02:20:03 2006 +0100 (2006-11-17) changeset 21404 eb85850d3eb7 parent 21210 c17fd2df4e9e child 21809 4b93e949ac33 permissions -rw-r--r--
more robust syntax for definition/abbreviation/notation;
 huffman@20504 ` 1` ```(* Title : RealVector.thy ``` huffman@20504 ` 2` ``` ID: \$Id\$ ``` huffman@20504 ` 3` ``` Author : Brian Huffman ``` huffman@20504 ` 4` ```*) ``` huffman@20504 ` 5` huffman@20504 ` 6` ```header {* Vector Spaces and Algebras over the Reals *} ``` huffman@20504 ` 7` huffman@20504 ` 8` ```theory RealVector ``` huffman@20684 ` 9` ```imports RealPow ``` huffman@20504 ` 10` ```begin ``` huffman@20504 ` 11` huffman@20504 ` 12` ```subsection {* Locale for additive functions *} ``` huffman@20504 ` 13` huffman@20504 ` 14` ```locale additive = ``` huffman@20504 ` 15` ``` fixes f :: "'a::ab_group_add \ 'b::ab_group_add" ``` huffman@20504 ` 16` ``` assumes add: "f (x + y) = f x + f y" ``` huffman@20504 ` 17` huffman@20504 ` 18` ```lemma (in additive) 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@20504 ` 25` ```lemma (in additive) 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@20504 ` 32` ```lemma (in additive) diff: "f (x - y) = f x - f y" ``` huffman@20504 ` 33` ```by (simp add: diff_def add minus) ``` huffman@20504 ` 34` huffman@20504 ` 35` huffman@20504 ` 36` ```subsection {* Real vector spaces *} ``` huffman@20504 ` 37` huffman@20504 ` 38` ```axclass scaleR < type ``` huffman@20504 ` 39` huffman@20504 ` 40` ```consts ``` huffman@20504 ` 41` ``` scaleR :: "real \ 'a \ 'a::scaleR" (infixr "*#" 75) ``` huffman@20504 ` 42` huffman@20763 ` 43` ```abbreviation ``` wenzelm@21404 ` 44` ``` divideR :: "'a \ real \ 'a::scaleR" (infixl "'/#" 70) where ``` huffman@20763 ` 45` ``` "x /# r == inverse r *# x" ``` huffman@20763 ` 46` wenzelm@21210 ` 47` ```notation (xsymbols) ``` wenzelm@21404 ` 48` ``` scaleR (infixr "*\<^sub>R" 75) and ``` huffman@20763 ` 49` ``` divideR (infixl "'/\<^sub>R" 70) ``` huffman@20504 ` 50` huffman@20554 ` 51` ```instance real :: scaleR .. ``` huffman@20554 ` 52` huffman@20554 ` 53` ```defs (overloaded) ``` huffman@20554 ` 54` ``` real_scaleR_def: "a *# x \ a * x" ``` huffman@20554 ` 55` huffman@20504 ` 56` ```axclass real_vector < scaleR, ab_group_add ``` huffman@20504 ` 57` ``` scaleR_right_distrib: "a *# (x + y) = a *# x + a *# y" ``` huffman@20504 ` 58` ``` scaleR_left_distrib: "(a + b) *# x = a *# x + b *# x" ``` huffman@20763 ` 59` ``` scaleR_scaleR [simp]: "a *# b *# x = (a * b) *# x" ``` huffman@20504 ` 60` ``` scaleR_one [simp]: "1 *# x = x" ``` huffman@20504 ` 61` huffman@20504 ` 62` ```axclass real_algebra < real_vector, ring ``` huffman@20763 ` 63` ``` mult_scaleR_left [simp]: "a *# x * y = a *# (x * y)" ``` huffman@20763 ` 64` ``` mult_scaleR_right [simp]: "x * a *# y = a *# (x * y)" ``` huffman@20504 ` 65` huffman@20554 ` 66` ```axclass real_algebra_1 < real_algebra, ring_1 ``` huffman@20554 ` 67` huffman@20584 ` 68` ```axclass real_div_algebra < real_algebra_1, division_ring ``` huffman@20584 ` 69` huffman@20584 ` 70` ```axclass real_field < real_div_algebra, field ``` huffman@20584 ` 71` huffman@20584 ` 72` ```instance real :: real_field ``` huffman@20554 ` 73` ```apply (intro_classes, unfold real_scaleR_def) ``` huffman@20554 ` 74` ```apply (rule right_distrib) ``` huffman@20554 ` 75` ```apply (rule left_distrib) ``` huffman@20763 ` 76` ```apply (rule mult_assoc [symmetric]) ``` huffman@20554 ` 77` ```apply (rule mult_1_left) ``` huffman@20554 ` 78` ```apply (rule mult_assoc) ``` huffman@20554 ` 79` ```apply (rule mult_left_commute) ``` huffman@20554 ` 80` ```done ``` huffman@20554 ` 81` huffman@20504 ` 82` ```lemma scaleR_left_commute: ``` huffman@20504 ` 83` ``` fixes x :: "'a::real_vector" ``` huffman@20504 ` 84` ``` shows "a *# b *# x = b *# a *# x" ``` huffman@20763 ` 85` ```by (simp add: mult_commute) ``` huffman@20504 ` 86` huffman@20504 ` 87` ```lemma additive_scaleR_right: "additive (\x. a *# x :: 'a::real_vector)" ``` huffman@20504 ` 88` ```by (rule additive.intro, rule scaleR_right_distrib) ``` huffman@20504 ` 89` huffman@20504 ` 90` ```lemma additive_scaleR_left: "additive (\a. a *# x :: 'a::real_vector)" ``` huffman@20504 ` 91` ```by (rule additive.intro, rule scaleR_left_distrib) ``` huffman@20504 ` 92` huffman@20504 ` 93` ```lemmas scaleR_zero_left [simp] = ``` huffman@20504 ` 94` ``` additive.zero [OF additive_scaleR_left, standard] ``` huffman@20504 ` 95` huffman@20504 ` 96` ```lemmas scaleR_zero_right [simp] = ``` huffman@20504 ` 97` ``` additive.zero [OF additive_scaleR_right, standard] ``` huffman@20504 ` 98` huffman@20504 ` 99` ```lemmas scaleR_minus_left [simp] = ``` huffman@20504 ` 100` ``` additive.minus [OF additive_scaleR_left, standard] ``` huffman@20504 ` 101` huffman@20504 ` 102` ```lemmas scaleR_minus_right [simp] = ``` huffman@20504 ` 103` ``` additive.minus [OF additive_scaleR_right, standard] ``` huffman@20504 ` 104` huffman@20504 ` 105` ```lemmas scaleR_left_diff_distrib = ``` huffman@20504 ` 106` ``` additive.diff [OF additive_scaleR_left, standard] ``` huffman@20504 ` 107` huffman@20504 ` 108` ```lemmas scaleR_right_diff_distrib = ``` huffman@20504 ` 109` ``` additive.diff [OF additive_scaleR_right, standard] ``` huffman@20504 ` 110` huffman@20554 ` 111` ```lemma scaleR_eq_0_iff: ``` huffman@20554 ` 112` ``` fixes x :: "'a::real_vector" ``` huffman@20554 ` 113` ``` shows "(a *# x = 0) = (a = 0 \ x = 0)" ``` huffman@20554 ` 114` ```proof cases ``` huffman@20554 ` 115` ``` assume "a = 0" thus ?thesis by simp ``` huffman@20554 ` 116` ```next ``` huffman@20554 ` 117` ``` assume anz [simp]: "a \ 0" ``` huffman@20554 ` 118` ``` { assume "a *# x = 0" ``` huffman@20554 ` 119` ``` hence "inverse a *# a *# x = 0" by simp ``` huffman@20763 ` 120` ``` hence "x = 0" by simp } ``` huffman@20554 ` 121` ``` thus ?thesis by force ``` huffman@20554 ` 122` ```qed ``` huffman@20554 ` 123` huffman@20554 ` 124` ```lemma scaleR_left_imp_eq: ``` huffman@20554 ` 125` ``` fixes x y :: "'a::real_vector" ``` huffman@20554 ` 126` ``` shows "\a \ 0; a *# x = a *# y\ \ x = y" ``` huffman@20554 ` 127` ```proof - ``` huffman@20554 ` 128` ``` assume nonzero: "a \ 0" ``` huffman@20554 ` 129` ``` assume "a *# x = a *# y" ``` huffman@20554 ` 130` ``` hence "a *# (x - y) = 0" ``` huffman@20554 ` 131` ``` by (simp add: scaleR_right_diff_distrib) ``` huffman@20554 ` 132` ``` hence "x - y = 0" ``` huffman@20554 ` 133` ``` by (simp add: scaleR_eq_0_iff nonzero) ``` huffman@20554 ` 134` ``` thus "x = y" by simp ``` huffman@20554 ` 135` ```qed ``` huffman@20554 ` 136` huffman@20554 ` 137` ```lemma scaleR_right_imp_eq: ``` huffman@20554 ` 138` ``` fixes x y :: "'a::real_vector" ``` huffman@20554 ` 139` ``` shows "\x \ 0; a *# x = b *# x\ \ a = b" ``` huffman@20554 ` 140` ```proof - ``` huffman@20554 ` 141` ``` assume nonzero: "x \ 0" ``` huffman@20554 ` 142` ``` assume "a *# x = b *# x" ``` huffman@20554 ` 143` ``` hence "(a - b) *# x = 0" ``` huffman@20554 ` 144` ``` by (simp add: scaleR_left_diff_distrib) ``` huffman@20554 ` 145` ``` hence "a - b = 0" ``` huffman@20554 ` 146` ``` by (simp add: scaleR_eq_0_iff nonzero) ``` huffman@20554 ` 147` ``` thus "a = b" by simp ``` huffman@20554 ` 148` ```qed ``` huffman@20554 ` 149` huffman@20554 ` 150` ```lemma scaleR_cancel_left: ``` huffman@20554 ` 151` ``` fixes x y :: "'a::real_vector" ``` huffman@20554 ` 152` ``` shows "(a *# x = a *# y) = (x = y \ a = 0)" ``` huffman@20554 ` 153` ```by (auto intro: scaleR_left_imp_eq) ``` huffman@20554 ` 154` huffman@20554 ` 155` ```lemma scaleR_cancel_right: ``` huffman@20554 ` 156` ``` fixes x y :: "'a::real_vector" ``` huffman@20554 ` 157` ``` shows "(a *# x = b *# x) = (a = b \ x = 0)" ``` huffman@20554 ` 158` ```by (auto intro: scaleR_right_imp_eq) ``` huffman@20554 ` 159` huffman@20584 ` 160` ```lemma nonzero_inverse_scaleR_distrib: ``` huffman@20584 ` 161` ``` fixes x :: "'a::real_div_algebra" ``` huffman@20584 ` 162` ``` shows "\a \ 0; x \ 0\ \ inverse (a *# x) = inverse a *# inverse x" ``` huffman@20763 ` 163` ```by (rule inverse_unique, simp) ``` huffman@20584 ` 164` huffman@20584 ` 165` ```lemma inverse_scaleR_distrib: ``` huffman@20584 ` 166` ``` fixes x :: "'a::{real_div_algebra,division_by_zero}" ``` huffman@20584 ` 167` ``` shows "inverse (a *# x) = inverse a *# inverse x" ``` huffman@20584 ` 168` ```apply (case_tac "a = 0", simp) ``` huffman@20584 ` 169` ```apply (case_tac "x = 0", simp) ``` huffman@20584 ` 170` ```apply (erule (1) nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 171` ```done ``` huffman@20584 ` 172` huffman@20554 ` 173` huffman@20554 ` 174` ```subsection {* Embedding of the Reals into any @{text real_algebra_1}: ``` huffman@20554 ` 175` ```@{term of_real} *} ``` huffman@20554 ` 176` huffman@20554 ` 177` ```definition ``` wenzelm@21404 ` 178` ``` of_real :: "real \ 'a::real_algebra_1" where ``` huffman@20554 ` 179` ``` "of_real r = r *# 1" ``` huffman@20554 ` 180` huffman@20763 ` 181` ```lemma scaleR_conv_of_real: "r *# x = of_real r * x" ``` huffman@20763 ` 182` ```by (simp add: of_real_def) ``` huffman@20763 ` 183` huffman@20554 ` 184` ```lemma of_real_0 [simp]: "of_real 0 = 0" ``` huffman@20554 ` 185` ```by (simp add: of_real_def) ``` huffman@20554 ` 186` huffman@20554 ` 187` ```lemma of_real_1 [simp]: "of_real 1 = 1" ``` huffman@20554 ` 188` ```by (simp add: of_real_def) ``` huffman@20554 ` 189` huffman@20554 ` 190` ```lemma of_real_add [simp]: "of_real (x + y) = of_real x + of_real y" ``` huffman@20554 ` 191` ```by (simp add: of_real_def scaleR_left_distrib) ``` huffman@20554 ` 192` huffman@20554 ` 193` ```lemma of_real_minus [simp]: "of_real (- x) = - of_real x" ``` huffman@20554 ` 194` ```by (simp add: of_real_def) ``` huffman@20554 ` 195` huffman@20554 ` 196` ```lemma of_real_diff [simp]: "of_real (x - y) = of_real x - of_real y" ``` huffman@20554 ` 197` ```by (simp add: of_real_def scaleR_left_diff_distrib) ``` huffman@20554 ` 198` huffman@20554 ` 199` ```lemma of_real_mult [simp]: "of_real (x * y) = of_real x * of_real y" ``` huffman@20763 ` 200` ```by (simp add: of_real_def mult_commute) ``` huffman@20554 ` 201` huffman@20584 ` 202` ```lemma nonzero_of_real_inverse: ``` huffman@20584 ` 203` ``` "x \ 0 \ of_real (inverse x) = ``` huffman@20584 ` 204` ``` inverse (of_real x :: 'a::real_div_algebra)" ``` huffman@20584 ` 205` ```by (simp add: of_real_def nonzero_inverse_scaleR_distrib) ``` huffman@20584 ` 206` huffman@20584 ` 207` ```lemma of_real_inverse [simp]: ``` huffman@20584 ` 208` ``` "of_real (inverse x) = ``` huffman@20584 ` 209` ``` inverse (of_real x :: 'a::{real_div_algebra,division_by_zero})" ``` huffman@20584 ` 210` ```by (simp add: of_real_def inverse_scaleR_distrib) ``` huffman@20584 ` 211` huffman@20584 ` 212` ```lemma nonzero_of_real_divide: ``` huffman@20584 ` 213` ``` "y \ 0 \ of_real (x / y) = ``` huffman@20584 ` 214` ``` (of_real x / of_real y :: 'a::real_field)" ``` huffman@20584 ` 215` ```by (simp add: divide_inverse nonzero_of_real_inverse) ``` huffman@20722 ` 216` huffman@20722 ` 217` ```lemma of_real_divide [simp]: ``` huffman@20584 ` 218` ``` "of_real (x / y) = ``` huffman@20584 ` 219` ``` (of_real x / of_real y :: 'a::{real_field,division_by_zero})" ``` huffman@20584 ` 220` ```by (simp add: divide_inverse) ``` huffman@20584 ` 221` huffman@20722 ` 222` ```lemma of_real_power [simp]: ``` huffman@20722 ` 223` ``` "of_real (x ^ n) = (of_real x :: 'a::{real_algebra_1,recpower}) ^ n" ``` wenzelm@20772 ` 224` ```by (induct n) (simp_all add: power_Suc) ``` huffman@20722 ` 225` huffman@20554 ` 226` ```lemma of_real_eq_iff [simp]: "(of_real x = of_real y) = (x = y)" ``` huffman@20554 ` 227` ```by (simp add: of_real_def scaleR_cancel_right) ``` huffman@20554 ` 228` huffman@20584 ` 229` ```lemmas of_real_eq_0_iff [simp] = of_real_eq_iff [of _ 0, simplified] ``` huffman@20554 ` 230` huffman@20554 ` 231` ```lemma of_real_eq_id [simp]: "of_real = (id :: real \ real)" ``` huffman@20554 ` 232` ```proof ``` huffman@20554 ` 233` ``` fix r ``` huffman@20554 ` 234` ``` show "of_real r = id r" ``` huffman@20554 ` 235` ``` by (simp add: of_real_def real_scaleR_def) ``` huffman@20554 ` 236` ```qed ``` huffman@20554 ` 237` huffman@20554 ` 238` ```text{*Collapse nested embeddings*} ``` huffman@20554 ` 239` ```lemma of_real_of_nat_eq [simp]: "of_real (of_nat n) = of_nat n" ``` wenzelm@20772 ` 240` ```by (induct n) auto ``` huffman@20554 ` 241` huffman@20554 ` 242` ```lemma of_real_of_int_eq [simp]: "of_real (of_int z) = of_int z" ``` huffman@20554 ` 243` ```by (cases z rule: int_diff_cases, simp) ``` huffman@20554 ` 244` huffman@20554 ` 245` ```lemma of_real_number_of_eq: ``` huffman@20554 ` 246` ``` "of_real (number_of w) = (number_of w :: 'a::{number_ring,real_algebra_1})" ``` huffman@20554 ` 247` ```by (simp add: number_of_eq) ``` huffman@20554 ` 248` huffman@20554 ` 249` huffman@20554 ` 250` ```subsection {* The Set of Real Numbers *} ``` huffman@20554 ` 251` wenzelm@20772 ` 252` ```definition ``` wenzelm@21404 ` 253` ``` Reals :: "'a::real_algebra_1 set" where ``` wenzelm@20772 ` 254` ``` "Reals \ range of_real" ``` huffman@20554 ` 255` wenzelm@21210 ` 256` ```notation (xsymbols) ``` huffman@20554 ` 257` ``` Reals ("\") ``` huffman@20554 ` 258` huffman@20554 ` 259` ```lemma of_real_in_Reals [simp]: "of_real r \ Reals" ``` huffman@20554 ` 260` ```by (simp add: Reals_def) ``` huffman@20554 ` 261` huffman@20718 ` 262` ```lemma of_int_in_Reals [simp]: "of_int z \ Reals" ``` huffman@20718 ` 263` ```by (subst of_real_of_int_eq [symmetric], rule of_real_in_Reals) ``` huffman@20718 ` 264` huffman@20718 ` 265` ```lemma of_nat_in_Reals [simp]: "of_nat n \ Reals" ``` huffman@20718 ` 266` ```by (subst of_real_of_nat_eq [symmetric], rule of_real_in_Reals) ``` huffman@20718 ` 267` huffman@20554 ` 268` ```lemma Reals_0 [simp]: "0 \ Reals" ``` huffman@20554 ` 269` ```apply (unfold Reals_def) ``` huffman@20554 ` 270` ```apply (rule range_eqI) ``` huffman@20554 ` 271` ```apply (rule of_real_0 [symmetric]) ``` huffman@20554 ` 272` ```done ``` huffman@20554 ` 273` huffman@20554 ` 274` ```lemma Reals_1 [simp]: "1 \ Reals" ``` huffman@20554 ` 275` ```apply (unfold Reals_def) ``` huffman@20554 ` 276` ```apply (rule range_eqI) ``` huffman@20554 ` 277` ```apply (rule of_real_1 [symmetric]) ``` huffman@20554 ` 278` ```done ``` huffman@20554 ` 279` huffman@20584 ` 280` ```lemma Reals_add [simp]: "\a \ Reals; b \ Reals\ \ a + b \ Reals" ``` huffman@20554 ` 281` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 282` ```apply (rule range_eqI) ``` huffman@20554 ` 283` ```apply (rule of_real_add [symmetric]) ``` huffman@20554 ` 284` ```done ``` huffman@20554 ` 285` huffman@20584 ` 286` ```lemma Reals_minus [simp]: "a \ Reals \ - a \ Reals" ``` huffman@20584 ` 287` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 288` ```apply (rule range_eqI) ``` huffman@20584 ` 289` ```apply (rule of_real_minus [symmetric]) ``` huffman@20584 ` 290` ```done ``` huffman@20584 ` 291` huffman@20584 ` 292` ```lemma Reals_diff [simp]: "\a \ Reals; b \ Reals\ \ a - b \ Reals" ``` huffman@20584 ` 293` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 294` ```apply (rule range_eqI) ``` huffman@20584 ` 295` ```apply (rule of_real_diff [symmetric]) ``` huffman@20584 ` 296` ```done ``` huffman@20584 ` 297` huffman@20584 ` 298` ```lemma Reals_mult [simp]: "\a \ Reals; b \ Reals\ \ a * b \ Reals" ``` huffman@20554 ` 299` ```apply (auto simp add: Reals_def) ``` huffman@20554 ` 300` ```apply (rule range_eqI) ``` huffman@20554 ` 301` ```apply (rule of_real_mult [symmetric]) ``` huffman@20554 ` 302` ```done ``` huffman@20554 ` 303` huffman@20584 ` 304` ```lemma nonzero_Reals_inverse: ``` huffman@20584 ` 305` ``` fixes a :: "'a::real_div_algebra" ``` huffman@20584 ` 306` ``` shows "\a \ Reals; a \ 0\ \ inverse a \ Reals" ``` huffman@20584 ` 307` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 308` ```apply (rule range_eqI) ``` huffman@20584 ` 309` ```apply (erule nonzero_of_real_inverse [symmetric]) ``` huffman@20584 ` 310` ```done ``` huffman@20584 ` 311` huffman@20584 ` 312` ```lemma Reals_inverse [simp]: ``` huffman@20584 ` 313` ``` fixes a :: "'a::{real_div_algebra,division_by_zero}" ``` huffman@20584 ` 314` ``` shows "a \ Reals \ inverse a \ Reals" ``` huffman@20584 ` 315` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 316` ```apply (rule range_eqI) ``` huffman@20584 ` 317` ```apply (rule of_real_inverse [symmetric]) ``` huffman@20584 ` 318` ```done ``` huffman@20584 ` 319` huffman@20584 ` 320` ```lemma nonzero_Reals_divide: ``` huffman@20584 ` 321` ``` fixes a b :: "'a::real_field" ``` huffman@20584 ` 322` ``` shows "\a \ Reals; b \ Reals; b \ 0\ \ a / b \ Reals" ``` huffman@20584 ` 323` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 324` ```apply (rule range_eqI) ``` huffman@20584 ` 325` ```apply (erule nonzero_of_real_divide [symmetric]) ``` huffman@20584 ` 326` ```done ``` huffman@20584 ` 327` huffman@20584 ` 328` ```lemma Reals_divide [simp]: ``` huffman@20584 ` 329` ``` fixes a b :: "'a::{real_field,division_by_zero}" ``` huffman@20584 ` 330` ``` shows "\a \ Reals; b \ Reals\ \ a / b \ Reals" ``` huffman@20584 ` 331` ```apply (auto simp add: Reals_def) ``` huffman@20584 ` 332` ```apply (rule range_eqI) ``` huffman@20584 ` 333` ```apply (rule of_real_divide [symmetric]) ``` huffman@20584 ` 334` ```done ``` huffman@20584 ` 335` huffman@20722 ` 336` ```lemma Reals_power [simp]: ``` huffman@20722 ` 337` ``` fixes a :: "'a::{real_algebra_1,recpower}" ``` huffman@20722 ` 338` ``` shows "a \ Reals \ a ^ n \ Reals" ``` huffman@20722 ` 339` ```apply (auto simp add: Reals_def) ``` huffman@20722 ` 340` ```apply (rule range_eqI) ``` huffman@20722 ` 341` ```apply (rule of_real_power [symmetric]) ``` huffman@20722 ` 342` ```done ``` huffman@20722 ` 343` huffman@20554 ` 344` ```lemma Reals_cases [cases set: Reals]: ``` huffman@20554 ` 345` ``` assumes "q \ \" ``` huffman@20554 ` 346` ``` obtains (of_real) r where "q = of_real r" ``` huffman@20554 ` 347` ``` unfolding Reals_def ``` huffman@20554 ` 348` ```proof - ``` huffman@20554 ` 349` ``` from `q \ \` have "q \ range of_real" unfolding Reals_def . ``` huffman@20554 ` 350` ``` then obtain r where "q = of_real r" .. ``` huffman@20554 ` 351` ``` then show thesis .. ``` huffman@20554 ` 352` ```qed ``` huffman@20554 ` 353` huffman@20554 ` 354` ```lemma Reals_induct [case_names of_real, induct set: Reals]: ``` huffman@20554 ` 355` ``` "q \ \ \ (\r. P (of_real r)) \ P q" ``` huffman@20554 ` 356` ``` by (rule Reals_cases) auto ``` huffman@20554 ` 357` huffman@20504 ` 358` huffman@20504 ` 359` ```subsection {* Real normed vector spaces *} ``` huffman@20504 ` 360` huffman@20504 ` 361` ```axclass norm < type ``` huffman@20533 ` 362` ```consts norm :: "'a::norm \ real" ``` huffman@20504 ` 363` huffman@20554 ` 364` ```instance real :: norm .. ``` huffman@20554 ` 365` huffman@20554 ` 366` ```defs (overloaded) ``` huffman@20694 ` 367` ``` real_norm_def [simp]: "norm r \ \r\" ``` huffman@20554 ` 368` huffman@20554 ` 369` ```axclass normed < plus, zero, norm ``` huffman@20533 ` 370` ``` norm_ge_zero [simp]: "0 \ norm x" ``` huffman@20533 ` 371` ``` norm_eq_zero [simp]: "(norm x = 0) = (x = 0)" ``` huffman@20533 ` 372` ``` norm_triangle_ineq: "norm (x + y) \ norm x + norm y" ``` huffman@20554 ` 373` huffman@20554 ` 374` ```axclass real_normed_vector < real_vector, normed ``` huffman@20533 ` 375` ``` norm_scaleR: "norm (a *# x) = \a\ * norm x" ``` huffman@20504 ` 376` huffman@20584 ` 377` ```axclass real_normed_algebra < real_algebra, real_normed_vector ``` huffman@20533 ` 378` ``` norm_mult_ineq: "norm (x * y) \ norm x * norm y" ``` huffman@20504 ` 379` huffman@20584 ` 380` ```axclass real_normed_div_algebra < real_div_algebra, normed ``` huffman@20554 ` 381` ``` norm_of_real: "norm (of_real r) = abs r" ``` huffman@20533 ` 382` ``` norm_mult: "norm (x * y) = norm x * norm y" ``` huffman@20504 ` 383` huffman@20584 ` 384` ```axclass real_normed_field < real_field, real_normed_div_algebra ``` huffman@20584 ` 385` huffman@20504 ` 386` ```instance real_normed_div_algebra < real_normed_algebra ``` huffman@20554 ` 387` ```proof ``` huffman@20554 ` 388` ``` fix a :: real and x :: 'a ``` huffman@20554 ` 389` ``` have "norm (a *# x) = norm (of_real a * x)" ``` huffman@20554 ` 390` ``` by (simp add: of_real_def mult_scaleR_left) ``` huffman@20554 ` 391` ``` also have "\ = abs a * norm x" ``` huffman@20554 ` 392` ``` by (simp add: norm_mult norm_of_real) ``` huffman@20554 ` 393` ``` finally show "norm (a *# x) = abs a * norm x" . ``` huffman@20554 ` 394` ```next ``` huffman@20554 ` 395` ``` fix x y :: 'a ``` huffman@20554 ` 396` ``` show "norm (x * y) \ norm x * norm y" ``` huffman@20554 ` 397` ``` by (simp add: norm_mult) ``` huffman@20554 ` 398` ```qed ``` huffman@20554 ` 399` huffman@20584 ` 400` ```instance real :: real_normed_field ``` huffman@20554 ` 401` ```apply (intro_classes, unfold real_norm_def) ``` huffman@20554 ` 402` ```apply (rule abs_ge_zero) ``` huffman@20554 ` 403` ```apply (rule abs_eq_0) ``` huffman@20554 ` 404` ```apply (rule abs_triangle_ineq) ``` huffman@20554 ` 405` ```apply simp ``` huffman@20554 ` 406` ```apply (rule abs_mult) ``` huffman@20554 ` 407` ```done ``` huffman@20504 ` 408` huffman@20828 ` 409` ```lemma norm_zero [simp]: "norm (0::'a::normed) = 0" ``` huffman@20504 ` 410` ```by simp ``` huffman@20504 ` 411` huffman@20828 ` 412` ```lemma zero_less_norm_iff [simp]: "(0 < norm x) = (x \ (0::'a::normed))" ``` huffman@20504 ` 413` ```by (simp add: order_less_le) ``` huffman@20504 ` 414` huffman@20828 ` 415` ```lemma norm_not_less_zero [simp]: "\ norm (x::'a::normed) < 0" ``` huffman@20828 ` 416` ```by (simp add: linorder_not_less) ``` huffman@20828 ` 417` huffman@20828 ` 418` ```lemma norm_le_zero_iff [simp]: "(norm x \ 0) = (x = (0::'a::normed))" ``` huffman@20828 ` 419` ```by (simp add: order_le_less) ``` huffman@20828 ` 420` huffman@20504 ` 421` ```lemma norm_minus_cancel [simp]: ``` huffman@20584 ` 422` ``` fixes x :: "'a::real_normed_vector" ``` huffman@20584 ` 423` ``` shows "norm (- x) = norm x" ``` huffman@20504 ` 424` ```proof - ``` huffman@20533 ` 425` ``` have "norm (- x) = norm (- 1 *# x)" ``` huffman@20504 ` 426` ``` by (simp only: scaleR_minus_left scaleR_one) ``` huffman@20533 ` 427` ``` also have "\ = \- 1\ * norm x" ``` huffman@20504 ` 428` ``` by (rule norm_scaleR) ``` huffman@20504 ` 429` ``` finally show ?thesis by simp ``` huffman@20504 ` 430` ```qed ``` huffman@20504 ` 431` huffman@20504 ` 432` ```lemma norm_minus_commute: ``` huffman@20584 ` 433` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 434` ``` shows "norm (a - b) = norm (b - a)" ``` huffman@20504 ` 435` ```proof - ``` huffman@20533 ` 436` ``` have "norm (a - b) = norm (- (a - b))" ``` huffman@20533 ` 437` ``` by (simp only: norm_minus_cancel) ``` huffman@20533 ` 438` ``` also have "\ = norm (b - a)" by simp ``` huffman@20504 ` 439` ``` finally show ?thesis . ``` huffman@20504 ` 440` ```qed ``` huffman@20504 ` 441` huffman@20504 ` 442` ```lemma norm_triangle_ineq2: ``` huffman@20584 ` 443` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 444` ``` shows "norm a - norm b \ norm (a - b)" ``` huffman@20504 ` 445` ```proof - ``` huffman@20533 ` 446` ``` have "norm (a - b + b) \ norm (a - b) + norm b" ``` huffman@20504 ` 447` ``` by (rule norm_triangle_ineq) ``` huffman@20504 ` 448` ``` also have "(a - b + b) = a" ``` huffman@20504 ` 449` ``` by simp ``` huffman@20504 ` 450` ``` finally show ?thesis ``` huffman@20504 ` 451` ``` by (simp add: compare_rls) ``` huffman@20504 ` 452` ```qed ``` huffman@20504 ` 453` huffman@20584 ` 454` ```lemma norm_triangle_ineq3: ``` huffman@20584 ` 455` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20584 ` 456` ``` shows "\norm a - norm b\ \ norm (a - b)" ``` huffman@20584 ` 457` ```apply (subst abs_le_iff) ``` huffman@20584 ` 458` ```apply auto ``` huffman@20584 ` 459` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 460` ```apply (subst norm_minus_commute) ``` huffman@20584 ` 461` ```apply (rule norm_triangle_ineq2) ``` huffman@20584 ` 462` ```done ``` huffman@20584 ` 463` huffman@20504 ` 464` ```lemma norm_triangle_ineq4: ``` huffman@20584 ` 465` ``` fixes a b :: "'a::real_normed_vector" ``` huffman@20533 ` 466` ``` shows "norm (a - b) \ norm a + norm b" ``` huffman@20504 ` 467` ```proof - ``` huffman@20533 ` 468` ``` have "norm (a - b) = norm (a + - b)" ``` huffman@20504 ` 469` ``` by (simp only: diff_minus) ``` huffman@20533 ` 470` ``` also have "\ \ norm a + norm (- b)" ``` huffman@20504 ` 471` ``` by (rule norm_triangle_ineq) ``` huffman@20504 ` 472` ``` finally show ?thesis ``` huffman@20504 ` 473` ``` by simp ``` huffman@20504 ` 474` ```qed ``` huffman@20504 ` 475` huffman@20551 ` 476` ```lemma norm_diff_triangle_ineq: ``` huffman@20551 ` 477` ``` fixes a b c d :: "'a::real_normed_vector" ``` huffman@20551 ` 478` ``` shows "norm ((a + b) - (c + d)) \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 479` ```proof - ``` huffman@20551 ` 480` ``` have "norm ((a + b) - (c + d)) = norm ((a - c) + (b - d))" ``` huffman@20551 ` 481` ``` by (simp add: diff_minus add_ac) ``` huffman@20551 ` 482` ``` also have "\ \ norm (a - c) + norm (b - d)" ``` huffman@20551 ` 483` ``` by (rule norm_triangle_ineq) ``` huffman@20551 ` 484` ``` finally show ?thesis . ``` huffman@20551 ` 485` ```qed ``` huffman@20551 ` 486` huffman@20560 ` 487` ```lemma norm_one [simp]: "norm (1::'a::real_normed_div_algebra) = 1" ``` huffman@20560 ` 488` ```proof - ``` huffman@20560 ` 489` ``` have "norm (of_real 1 :: 'a) = abs 1" ``` huffman@20560 ` 490` ``` by (rule norm_of_real) ``` huffman@20560 ` 491` ``` thus ?thesis by simp ``` huffman@20560 ` 492` ```qed ``` huffman@20560 ` 493` huffman@20504 ` 494` ```lemma nonzero_norm_inverse: ``` huffman@20504 ` 495` ``` fixes a :: "'a::real_normed_div_algebra" ``` huffman@20533 ` 496` ``` shows "a \ 0 \ norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 497` ```apply (rule inverse_unique [symmetric]) ``` huffman@20504 ` 498` ```apply (simp add: norm_mult [symmetric]) ``` huffman@20504 ` 499` ```done ``` huffman@20504 ` 500` huffman@20504 ` 501` ```lemma norm_inverse: ``` huffman@20504 ` 502` ``` fixes a :: "'a::{real_normed_div_algebra,division_by_zero}" ``` huffman@20533 ` 503` ``` shows "norm (inverse a) = inverse (norm a)" ``` huffman@20504 ` 504` ```apply (case_tac "a = 0", simp) ``` huffman@20504 ` 505` ```apply (erule nonzero_norm_inverse) ``` huffman@20504 ` 506` ```done ``` huffman@20504 ` 507` huffman@20584 ` 508` ```lemma nonzero_norm_divide: ``` huffman@20584 ` 509` ``` fixes a b :: "'a::real_normed_field" ``` huffman@20584 ` 510` ``` shows "b \ 0 \ norm (a / b) = norm a / norm b" ``` huffman@20584 ` 511` ```by (simp add: divide_inverse norm_mult nonzero_norm_inverse) ``` huffman@20584 ` 512` huffman@20584 ` 513` ```lemma norm_divide: ``` huffman@20584 ` 514` ``` fixes a b :: "'a::{real_normed_field,division_by_zero}" ``` huffman@20584 ` 515` ``` shows "norm (a / b) = norm a / norm b" ``` huffman@20584 ` 516` ```by (simp add: divide_inverse norm_mult norm_inverse) ``` huffman@20584 ` 517` huffman@20684 ` 518` ```lemma norm_power: ``` huffman@20684 ` 519` ``` fixes x :: "'a::{real_normed_div_algebra,recpower}" ``` huffman@20684 ` 520` ``` shows "norm (x ^ n) = norm x ^ n" ``` wenzelm@20772 ` 521` ```by (induct n) (simp_all add: power_Suc norm_mult) ``` huffman@20684 ` 522` huffman@20504 ` 523` ```end ```