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