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