src/HOL/RealVector.thy
 author huffman Sun Jun 07 12:00:03 2009 -0700 (2009-06-07) changeset 31490 c350f3ad6b0d parent 31446 2d91b2416de8 child 31492 5400beeddb55 permissions -rw-r--r--
move definitions of open, closed to RealVector.thy
```     1 (*  Title:      HOL/RealVector.thy
```
```     2     Author:     Brian Huffman
```
```     3 *)
```
```     4
```
```     5 header {* Vector Spaces and Algebras over the Reals *}
```
```     6
```
```     7 theory RealVector
```
```     8 imports RealPow
```
```     9 begin
```
```    10
```
```    11 subsection {* Locale for additive functions *}
```
```    12
```
```    13 locale additive =
```
```    14   fixes f :: "'a::ab_group_add \<Rightarrow> 'b::ab_group_add"
```
```    15   assumes add: "f (x + y) = f x + f y"
```
```    16 begin
```
```    17
```
```    18 lemma zero: "f 0 = 0"
```
```    19 proof -
```
```    20   have "f 0 = f (0 + 0)" by simp
```
```    21   also have "\<dots> = f 0 + f 0" by (rule add)
```
```    22   finally show "f 0 = 0" by simp
```
```    23 qed
```
```    24
```
```    25 lemma minus: "f (- x) = - f x"
```
```    26 proof -
```
```    27   have "f (- x) + f x = f (- x + x)" by (rule add [symmetric])
```
```    28   also have "\<dots> = - f x + f x" by (simp add: zero)
```
```    29   finally show "f (- x) = - f x" by (rule add_right_imp_eq)
```
```    30 qed
```
```    31
```
```    32 lemma diff: "f (x - y) = f x - f y"
```
```    33 by (simp add: diff_def add minus)
```
```    34
```
```    35 lemma setsum: "f (setsum g A) = (\<Sum>x\<in>A. f (g x))"
```
```    36 apply (cases "finite A")
```
```    37 apply (induct set: finite)
```
```    38 apply (simp add: zero)
```
```    39 apply (simp add: add)
```
```    40 apply (simp add: zero)
```
```    41 done
```
```    42
```
```    43 end
```
```    44
```
```    45 subsection {* Vector spaces *}
```
```    46
```
```    47 locale vector_space =
```
```    48   fixes scale :: "'a::field \<Rightarrow> 'b::ab_group_add \<Rightarrow> 'b"
```
```    49   assumes scale_right_distrib [algebra_simps]:
```
```    50     "scale a (x + y) = scale a x + scale a y"
```
```    51   and scale_left_distrib [algebra_simps]:
```
```    52     "scale (a + b) x = scale a x + scale b x"
```
```    53   and scale_scale [simp]: "scale a (scale b x) = scale (a * b) x"
```
```    54   and scale_one [simp]: "scale 1 x = x"
```
```    55 begin
```
```    56
```
```    57 lemma scale_left_commute:
```
```    58   "scale a (scale b x) = scale b (scale a x)"
```
```    59 by (simp add: mult_commute)
```
```    60
```
```    61 lemma scale_zero_left [simp]: "scale 0 x = 0"
```
```    62   and scale_minus_left [simp]: "scale (- a) x = - (scale a x)"
```
```    63   and scale_left_diff_distrib [algebra_simps]:
```
```    64         "scale (a - b) x = scale a x - scale b x"
```
```    65 proof -
```
```    66   interpret s: additive "\<lambda>a. scale a x"
```
```    67     proof qed (rule scale_left_distrib)
```
```    68   show "scale 0 x = 0" by (rule s.zero)
```
```    69   show "scale (- a) x = - (scale a x)" by (rule s.minus)
```
```    70   show "scale (a - b) x = scale a x - scale b x" by (rule s.diff)
```
```    71 qed
```
```    72
```
```    73 lemma scale_zero_right [simp]: "scale a 0 = 0"
```
```    74   and scale_minus_right [simp]: "scale a (- x) = - (scale a x)"
```
```    75   and scale_right_diff_distrib [algebra_simps]:
```
```    76         "scale a (x - y) = scale a x - scale a y"
```
```    77 proof -
```
```    78   interpret s: additive "\<lambda>x. scale a x"
```
```    79     proof qed (rule scale_right_distrib)
```
```    80   show "scale a 0 = 0" by (rule s.zero)
```
```    81   show "scale a (- x) = - (scale a x)" by (rule s.minus)
```
```    82   show "scale a (x - y) = scale a x - scale a y" by (rule s.diff)
```
```    83 qed
```
```    84
```
```    85 lemma scale_eq_0_iff [simp]:
```
```    86   "scale a x = 0 \<longleftrightarrow> a = 0 \<or> x = 0"
```
```    87 proof cases
```
```    88   assume "a = 0" thus ?thesis by simp
```
```    89 next
```
```    90   assume anz [simp]: "a \<noteq> 0"
```
```    91   { assume "scale a x = 0"
```
```    92     hence "scale (inverse a) (scale a x) = 0" by simp
```
```    93     hence "x = 0" by simp }
```
```    94   thus ?thesis by force
```
```    95 qed
```
```    96
```
```    97 lemma scale_left_imp_eq:
```
```    98   "\<lbrakk>a \<noteq> 0; scale a x = scale a y\<rbrakk> \<Longrightarrow> x = y"
```
```    99 proof -
```
```   100   assume nonzero: "a \<noteq> 0"
```
```   101   assume "scale a x = scale a y"
```
```   102   hence "scale a (x - y) = 0"
```
```   103      by (simp add: scale_right_diff_distrib)
```
```   104   hence "x - y = 0" by (simp add: nonzero)
```
```   105   thus "x = y" by (simp only: right_minus_eq)
```
```   106 qed
```
```   107
```
```   108 lemma scale_right_imp_eq:
```
```   109   "\<lbrakk>x \<noteq> 0; scale a x = scale b x\<rbrakk> \<Longrightarrow> a = b"
```
```   110 proof -
```
```   111   assume nonzero: "x \<noteq> 0"
```
```   112   assume "scale a x = scale b x"
```
```   113   hence "scale (a - b) x = 0"
```
```   114      by (simp add: scale_left_diff_distrib)
```
```   115   hence "a - b = 0" by (simp add: nonzero)
```
```   116   thus "a = b" by (simp only: right_minus_eq)
```
```   117 qed
```
```   118
```
```   119 lemma scale_cancel_left:
```
```   120   "scale a x = scale a y \<longleftrightarrow> x = y \<or> a = 0"
```
```   121 by (auto intro: scale_left_imp_eq)
```
```   122
```
```   123 lemma scale_cancel_right:
```
```   124   "scale a x = scale b x \<longleftrightarrow> a = b \<or> x = 0"
```
```   125 by (auto intro: scale_right_imp_eq)
```
```   126
```
```   127 end
```
```   128
```
```   129 subsection {* Real vector spaces *}
```
```   130
```
```   131 class scaleR =
```
```   132   fixes scaleR :: "real \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "*\<^sub>R" 75)
```
```   133 begin
```
```   134
```
```   135 abbreviation
```
```   136   divideR :: "'a \<Rightarrow> real \<Rightarrow> 'a" (infixl "'/\<^sub>R" 70)
```
```   137 where
```
```   138   "x /\<^sub>R r == scaleR (inverse r) x"
```
```   139
```
```   140 end
```
```   141
```
```   142 class real_vector = scaleR + ab_group_add +
```
```   143   assumes scaleR_right_distrib: "scaleR a (x + y) = scaleR a x + scaleR a y"
```
```   144   and scaleR_left_distrib: "scaleR (a + b) x = scaleR a x + scaleR b x"
```
```   145   and scaleR_scaleR: "scaleR a (scaleR b x) = scaleR (a * b) x"
```
```   146   and scaleR_one: "scaleR 1 x = x"
```
```   147
```
```   148 interpretation real_vector:
```
```   149   vector_space "scaleR :: real \<Rightarrow> 'a \<Rightarrow> 'a::real_vector"
```
```   150 apply unfold_locales
```
```   151 apply (rule scaleR_right_distrib)
```
```   152 apply (rule scaleR_left_distrib)
```
```   153 apply (rule scaleR_scaleR)
```
```   154 apply (rule scaleR_one)
```
```   155 done
```
```   156
```
```   157 text {* Recover original theorem names *}
```
```   158
```
```   159 lemmas scaleR_left_commute = real_vector.scale_left_commute
```
```   160 lemmas scaleR_zero_left = real_vector.scale_zero_left
```
```   161 lemmas scaleR_minus_left = real_vector.scale_minus_left
```
```   162 lemmas scaleR_left_diff_distrib = real_vector.scale_left_diff_distrib
```
```   163 lemmas scaleR_zero_right = real_vector.scale_zero_right
```
```   164 lemmas scaleR_minus_right = real_vector.scale_minus_right
```
```   165 lemmas scaleR_right_diff_distrib = real_vector.scale_right_diff_distrib
```
```   166 lemmas scaleR_eq_0_iff = real_vector.scale_eq_0_iff
```
```   167 lemmas scaleR_left_imp_eq = real_vector.scale_left_imp_eq
```
```   168 lemmas scaleR_right_imp_eq = real_vector.scale_right_imp_eq
```
```   169 lemmas scaleR_cancel_left = real_vector.scale_cancel_left
```
```   170 lemmas scaleR_cancel_right = real_vector.scale_cancel_right
```
```   171
```
```   172 lemma scaleR_minus1_left [simp]:
```
```   173   fixes x :: "'a::real_vector"
```
```   174   shows "scaleR (-1) x = - x"
```
```   175   using scaleR_minus_left [of 1 x] by simp
```
```   176
```
```   177 class real_algebra = real_vector + ring +
```
```   178   assumes mult_scaleR_left [simp]: "scaleR a x * y = scaleR a (x * y)"
```
```   179   and mult_scaleR_right [simp]: "x * scaleR a y = scaleR a (x * y)"
```
```   180
```
```   181 class real_algebra_1 = real_algebra + ring_1
```
```   182
```
```   183 class real_div_algebra = real_algebra_1 + division_ring
```
```   184
```
```   185 class real_field = real_div_algebra + field
```
```   186
```
```   187 instantiation real :: real_field
```
```   188 begin
```
```   189
```
```   190 definition
```
```   191   real_scaleR_def [simp]: "scaleR a x = a * x"
```
```   192
```
```   193 instance proof
```
```   194 qed (simp_all add: algebra_simps)
```
```   195
```
```   196 end
```
```   197
```
```   198 interpretation scaleR_left: additive "(\<lambda>a. scaleR a x::'a::real_vector)"
```
```   199 proof qed (rule scaleR_left_distrib)
```
```   200
```
```   201 interpretation scaleR_right: additive "(\<lambda>x. scaleR a x::'a::real_vector)"
```
```   202 proof qed (rule scaleR_right_distrib)
```
```   203
```
```   204 lemma nonzero_inverse_scaleR_distrib:
```
```   205   fixes x :: "'a::real_div_algebra" shows
```
```   206   "\<lbrakk>a \<noteq> 0; x \<noteq> 0\<rbrakk> \<Longrightarrow> inverse (scaleR a x) = scaleR (inverse a) (inverse x)"
```
```   207 by (rule inverse_unique, simp)
```
```   208
```
```   209 lemma inverse_scaleR_distrib:
```
```   210   fixes x :: "'a::{real_div_algebra,division_by_zero}"
```
```   211   shows "inverse (scaleR a x) = scaleR (inverse a) (inverse x)"
```
```   212 apply (case_tac "a = 0", simp)
```
```   213 apply (case_tac "x = 0", simp)
```
```   214 apply (erule (1) nonzero_inverse_scaleR_distrib)
```
```   215 done
```
```   216
```
```   217
```
```   218 subsection {* Embedding of the Reals into any @{text real_algebra_1}:
```
```   219 @{term of_real} *}
```
```   220
```
```   221 definition
```
```   222   of_real :: "real \<Rightarrow> 'a::real_algebra_1" where
```
```   223   "of_real r = scaleR r 1"
```
```   224
```
```   225 lemma scaleR_conv_of_real: "scaleR r x = of_real r * x"
```
```   226 by (simp add: of_real_def)
```
```   227
```
```   228 lemma of_real_0 [simp]: "of_real 0 = 0"
```
```   229 by (simp add: of_real_def)
```
```   230
```
```   231 lemma of_real_1 [simp]: "of_real 1 = 1"
```
```   232 by (simp add: of_real_def)
```
```   233
```
```   234 lemma of_real_add [simp]: "of_real (x + y) = of_real x + of_real y"
```
```   235 by (simp add: of_real_def scaleR_left_distrib)
```
```   236
```
```   237 lemma of_real_minus [simp]: "of_real (- x) = - of_real x"
```
```   238 by (simp add: of_real_def)
```
```   239
```
```   240 lemma of_real_diff [simp]: "of_real (x - y) = of_real x - of_real y"
```
```   241 by (simp add: of_real_def scaleR_left_diff_distrib)
```
```   242
```
```   243 lemma of_real_mult [simp]: "of_real (x * y) = of_real x * of_real y"
```
```   244 by (simp add: of_real_def mult_commute)
```
```   245
```
```   246 lemma nonzero_of_real_inverse:
```
```   247   "x \<noteq> 0 \<Longrightarrow> of_real (inverse x) =
```
```   248    inverse (of_real x :: 'a::real_div_algebra)"
```
```   249 by (simp add: of_real_def nonzero_inverse_scaleR_distrib)
```
```   250
```
```   251 lemma of_real_inverse [simp]:
```
```   252   "of_real (inverse x) =
```
```   253    inverse (of_real x :: 'a::{real_div_algebra,division_by_zero})"
```
```   254 by (simp add: of_real_def inverse_scaleR_distrib)
```
```   255
```
```   256 lemma nonzero_of_real_divide:
```
```   257   "y \<noteq> 0 \<Longrightarrow> of_real (x / y) =
```
```   258    (of_real x / of_real y :: 'a::real_field)"
```
```   259 by (simp add: divide_inverse nonzero_of_real_inverse)
```
```   260
```
```   261 lemma of_real_divide [simp]:
```
```   262   "of_real (x / y) =
```
```   263    (of_real x / of_real y :: 'a::{real_field,division_by_zero})"
```
```   264 by (simp add: divide_inverse)
```
```   265
```
```   266 lemma of_real_power [simp]:
```
```   267   "of_real (x ^ n) = (of_real x :: 'a::{real_algebra_1}) ^ n"
```
```   268 by (induct n) simp_all
```
```   269
```
```   270 lemma of_real_eq_iff [simp]: "(of_real x = of_real y) = (x = y)"
```
```   271 by (simp add: of_real_def scaleR_cancel_right)
```
```   272
```
```   273 lemmas of_real_eq_0_iff [simp] = of_real_eq_iff [of _ 0, simplified]
```
```   274
```
```   275 lemma of_real_eq_id [simp]: "of_real = (id :: real \<Rightarrow> real)"
```
```   276 proof
```
```   277   fix r
```
```   278   show "of_real r = id r"
```
```   279     by (simp add: of_real_def)
```
```   280 qed
```
```   281
```
```   282 text{*Collapse nested embeddings*}
```
```   283 lemma of_real_of_nat_eq [simp]: "of_real (of_nat n) = of_nat n"
```
```   284 by (induct n) auto
```
```   285
```
```   286 lemma of_real_of_int_eq [simp]: "of_real (of_int z) = of_int z"
```
```   287 by (cases z rule: int_diff_cases, simp)
```
```   288
```
```   289 lemma of_real_number_of_eq:
```
```   290   "of_real (number_of w) = (number_of w :: 'a::{number_ring,real_algebra_1})"
```
```   291 by (simp add: number_of_eq)
```
```   292
```
```   293 text{*Every real algebra has characteristic zero*}
```
```   294 instance real_algebra_1 < ring_char_0
```
```   295 proof
```
```   296   fix m n :: nat
```
```   297   have "(of_real (of_nat m) = (of_real (of_nat n)::'a)) = (m = n)"
```
```   298     by (simp only: of_real_eq_iff of_nat_eq_iff)
```
```   299   thus "(of_nat m = (of_nat n::'a)) = (m = n)"
```
```   300     by (simp only: of_real_of_nat_eq)
```
```   301 qed
```
```   302
```
```   303 instance real_field < field_char_0 ..
```
```   304
```
```   305
```
```   306 subsection {* The Set of Real Numbers *}
```
```   307
```
```   308 definition
```
```   309   Reals :: "'a::real_algebra_1 set" where
```
```   310   [code del]: "Reals = range of_real"
```
```   311
```
```   312 notation (xsymbols)
```
```   313   Reals  ("\<real>")
```
```   314
```
```   315 lemma Reals_of_real [simp]: "of_real r \<in> Reals"
```
```   316 by (simp add: Reals_def)
```
```   317
```
```   318 lemma Reals_of_int [simp]: "of_int z \<in> Reals"
```
```   319 by (subst of_real_of_int_eq [symmetric], rule Reals_of_real)
```
```   320
```
```   321 lemma Reals_of_nat [simp]: "of_nat n \<in> Reals"
```
```   322 by (subst of_real_of_nat_eq [symmetric], rule Reals_of_real)
```
```   323
```
```   324 lemma Reals_number_of [simp]:
```
```   325   "(number_of w::'a::{number_ring,real_algebra_1}) \<in> Reals"
```
```   326 by (subst of_real_number_of_eq [symmetric], rule Reals_of_real)
```
```   327
```
```   328 lemma Reals_0 [simp]: "0 \<in> Reals"
```
```   329 apply (unfold Reals_def)
```
```   330 apply (rule range_eqI)
```
```   331 apply (rule of_real_0 [symmetric])
```
```   332 done
```
```   333
```
```   334 lemma Reals_1 [simp]: "1 \<in> Reals"
```
```   335 apply (unfold Reals_def)
```
```   336 apply (rule range_eqI)
```
```   337 apply (rule of_real_1 [symmetric])
```
```   338 done
```
```   339
```
```   340 lemma Reals_add [simp]: "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a + b \<in> Reals"
```
```   341 apply (auto simp add: Reals_def)
```
```   342 apply (rule range_eqI)
```
```   343 apply (rule of_real_add [symmetric])
```
```   344 done
```
```   345
```
```   346 lemma Reals_minus [simp]: "a \<in> Reals \<Longrightarrow> - a \<in> Reals"
```
```   347 apply (auto simp add: Reals_def)
```
```   348 apply (rule range_eqI)
```
```   349 apply (rule of_real_minus [symmetric])
```
```   350 done
```
```   351
```
```   352 lemma Reals_diff [simp]: "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a - b \<in> Reals"
```
```   353 apply (auto simp add: Reals_def)
```
```   354 apply (rule range_eqI)
```
```   355 apply (rule of_real_diff [symmetric])
```
```   356 done
```
```   357
```
```   358 lemma Reals_mult [simp]: "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a * b \<in> Reals"
```
```   359 apply (auto simp add: Reals_def)
```
```   360 apply (rule range_eqI)
```
```   361 apply (rule of_real_mult [symmetric])
```
```   362 done
```
```   363
```
```   364 lemma nonzero_Reals_inverse:
```
```   365   fixes a :: "'a::real_div_algebra"
```
```   366   shows "\<lbrakk>a \<in> Reals; a \<noteq> 0\<rbrakk> \<Longrightarrow> inverse a \<in> Reals"
```
```   367 apply (auto simp add: Reals_def)
```
```   368 apply (rule range_eqI)
```
```   369 apply (erule nonzero_of_real_inverse [symmetric])
```
```   370 done
```
```   371
```
```   372 lemma Reals_inverse [simp]:
```
```   373   fixes a :: "'a::{real_div_algebra,division_by_zero}"
```
```   374   shows "a \<in> Reals \<Longrightarrow> inverse a \<in> Reals"
```
```   375 apply (auto simp add: Reals_def)
```
```   376 apply (rule range_eqI)
```
```   377 apply (rule of_real_inverse [symmetric])
```
```   378 done
```
```   379
```
```   380 lemma nonzero_Reals_divide:
```
```   381   fixes a b :: "'a::real_field"
```
```   382   shows "\<lbrakk>a \<in> Reals; b \<in> Reals; b \<noteq> 0\<rbrakk> \<Longrightarrow> a / b \<in> Reals"
```
```   383 apply (auto simp add: Reals_def)
```
```   384 apply (rule range_eqI)
```
```   385 apply (erule nonzero_of_real_divide [symmetric])
```
```   386 done
```
```   387
```
```   388 lemma Reals_divide [simp]:
```
```   389   fixes a b :: "'a::{real_field,division_by_zero}"
```
```   390   shows "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a / b \<in> Reals"
```
```   391 apply (auto simp add: Reals_def)
```
```   392 apply (rule range_eqI)
```
```   393 apply (rule of_real_divide [symmetric])
```
```   394 done
```
```   395
```
```   396 lemma Reals_power [simp]:
```
```   397   fixes a :: "'a::{real_algebra_1}"
```
```   398   shows "a \<in> Reals \<Longrightarrow> a ^ n \<in> Reals"
```
```   399 apply (auto simp add: Reals_def)
```
```   400 apply (rule range_eqI)
```
```   401 apply (rule of_real_power [symmetric])
```
```   402 done
```
```   403
```
```   404 lemma Reals_cases [cases set: Reals]:
```
```   405   assumes "q \<in> \<real>"
```
```   406   obtains (of_real) r where "q = of_real r"
```
```   407   unfolding Reals_def
```
```   408 proof -
```
```   409   from `q \<in> \<real>` have "q \<in> range of_real" unfolding Reals_def .
```
```   410   then obtain r where "q = of_real r" ..
```
```   411   then show thesis ..
```
```   412 qed
```
```   413
```
```   414 lemma Reals_induct [case_names of_real, induct set: Reals]:
```
```   415   "q \<in> \<real> \<Longrightarrow> (\<And>r. P (of_real r)) \<Longrightarrow> P q"
```
```   416   by (rule Reals_cases) auto
```
```   417
```
```   418
```
```   419 subsection {* Topological spaces *}
```
```   420
```
```   421 class topo =
```
```   422   fixes topo :: "'a set set"
```
```   423
```
```   424 text {*
```
```   425   The syntactic class uses @{term topo} instead of @{text "open"}
```
```   426   so that @{text "open"} and @{text closed} will have the same type.
```
```   427   Maybe we could use extra type constraints instead, like with
```
```   428   @{text dist} and @{text norm}?
```
```   429 *}
```
```   430
```
```   431 class topological_space = topo +
```
```   432   assumes topo_UNIV: "UNIV \<in> topo"
```
```   433   assumes topo_Int: "A \<in> topo \<Longrightarrow> B \<in> topo \<Longrightarrow> A \<inter> B \<in> topo"
```
```   434   assumes topo_Union: "T \<subseteq> topo \<Longrightarrow> \<Union>T \<in> topo"
```
```   435 begin
```
```   436
```
```   437 definition
```
```   438   "open" :: "'a set \<Rightarrow> bool" where
```
```   439   "open S \<longleftrightarrow> S \<in> topo"
```
```   440
```
```   441 definition
```
```   442   closed :: "'a set \<Rightarrow> bool" where
```
```   443   "closed S \<longleftrightarrow> open (- S)"
```
```   444
```
```   445 lemma open_UNIV [intro, simp]:  "open UNIV"
```
```   446   unfolding open_def by (rule topo_UNIV)
```
```   447
```
```   448 lemma open_Int [intro]: "open S \<Longrightarrow> open T \<Longrightarrow> open (S \<inter> T)"
```
```   449   unfolding open_def by (rule topo_Int)
```
```   450
```
```   451 lemma open_Union [intro]: "\<forall>S\<in>K. open S \<Longrightarrow> open (\<Union> K)"
```
```   452   unfolding open_def subset_eq [symmetric] by (rule topo_Union)
```
```   453
```
```   454 lemma open_empty [intro, simp]: "open {}"
```
```   455   using open_Union [of "{}"] by simp
```
```   456
```
```   457 lemma open_Un [intro]: "open S \<Longrightarrow> open T \<Longrightarrow> open (S \<union> T)"
```
```   458   using open_Union [of "{S, T}"] by simp
```
```   459
```
```   460 lemma open_UN [intro]: "\<forall>x\<in>A. open (B x) \<Longrightarrow> open (\<Union>x\<in>A. B x)"
```
```   461   unfolding UN_eq by (rule open_Union) auto
```
```   462
```
```   463 lemma open_INT [intro]: "finite A \<Longrightarrow> \<forall>x\<in>A. open (B x) \<Longrightarrow> open (\<Inter>x\<in>A. B x)"
```
```   464   by (induct set: finite) auto
```
```   465
```
```   466 lemma open_Inter [intro]: "finite S \<Longrightarrow> \<forall>T\<in>S. open T \<Longrightarrow> open (\<Inter>S)"
```
```   467   unfolding Inter_def by (rule open_INT)
```
```   468
```
```   469 lemma closed_empty [intro, simp]:  "closed {}"
```
```   470   unfolding closed_def by simp
```
```   471
```
```   472 lemma closed_Un [intro]: "closed S \<Longrightarrow> closed T \<Longrightarrow> closed (S \<union> T)"
```
```   473   unfolding closed_def by auto
```
```   474
```
```   475 lemma closed_Inter [intro]: "\<forall>S\<in>K. closed S \<Longrightarrow> closed (\<Inter> K)"
```
```   476   unfolding closed_def Inter_def by auto
```
```   477
```
```   478 lemma closed_UNIV [intro, simp]: "closed UNIV"
```
```   479   unfolding closed_def by simp
```
```   480
```
```   481 lemma closed_Int [intro]: "closed S \<Longrightarrow> closed T \<Longrightarrow> closed (S \<inter> T)"
```
```   482   unfolding closed_def by auto
```
```   483
```
```   484 lemma closed_INT [intro]: "\<forall>x\<in>A. closed (B x) \<Longrightarrow> closed (\<Inter>x\<in>A. B x)"
```
```   485   unfolding closed_def by auto
```
```   486
```
```   487 lemma closed_UN [intro]: "finite A \<Longrightarrow> \<forall>x\<in>A. closed (B x) \<Longrightarrow> closed (\<Union>x\<in>A. B x)"
```
```   488   by (induct set: finite) auto
```
```   489
```
```   490 lemma closed_Union [intro]: "finite S \<Longrightarrow> \<forall>T\<in>S. closed T \<Longrightarrow> closed (\<Union>S)"
```
```   491   unfolding Union_def by (rule closed_UN)
```
```   492
```
```   493 lemma open_closed: "open S \<longleftrightarrow> closed (- S)"
```
```   494   unfolding closed_def by simp
```
```   495
```
```   496 lemma closed_open: "closed S \<longleftrightarrow> open (- S)"
```
```   497   unfolding closed_def by simp
```
```   498
```
```   499 lemma open_Diff [intro]: "open S \<Longrightarrow> closed T \<Longrightarrow> open (S - T)"
```
```   500   unfolding closed_open Diff_eq by (rule open_Int)
```
```   501
```
```   502 lemma closed_Diff [intro]: "closed S \<Longrightarrow> open T \<Longrightarrow> closed (S - T)"
```
```   503   unfolding open_closed Diff_eq by (rule closed_Int)
```
```   504
```
```   505 lemma open_Compl [intro]: "closed S \<Longrightarrow> open (- S)"
```
```   506   unfolding closed_open .
```
```   507
```
```   508 lemma closed_Compl [intro]: "open S \<Longrightarrow> closed (- S)"
```
```   509   unfolding open_closed .
```
```   510
```
```   511 end
```
```   512
```
```   513
```
```   514 subsection {* Metric spaces *}
```
```   515
```
```   516 class dist =
```
```   517   fixes dist :: "'a \<Rightarrow> 'a \<Rightarrow> real"
```
```   518
```
```   519 class topo_dist = topo + dist +
```
```   520   assumes topo_dist: "topo = {S. \<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S}"
```
```   521
```
```   522 class metric_space = topo_dist +
```
```   523   assumes dist_eq_0_iff [simp]: "dist x y = 0 \<longleftrightarrow> x = y"
```
```   524   assumes dist_triangle2: "dist x y \<le> dist x z + dist y z"
```
```   525 begin
```
```   526
```
```   527 lemma dist_self [simp]: "dist x x = 0"
```
```   528 by simp
```
```   529
```
```   530 lemma zero_le_dist [simp]: "0 \<le> dist x y"
```
```   531 using dist_triangle2 [of x x y] by simp
```
```   532
```
```   533 lemma zero_less_dist_iff: "0 < dist x y \<longleftrightarrow> x \<noteq> y"
```
```   534 by (simp add: less_le)
```
```   535
```
```   536 lemma dist_not_less_zero [simp]: "\<not> dist x y < 0"
```
```   537 by (simp add: not_less)
```
```   538
```
```   539 lemma dist_le_zero_iff [simp]: "dist x y \<le> 0 \<longleftrightarrow> x = y"
```
```   540 by (simp add: le_less)
```
```   541
```
```   542 lemma dist_commute: "dist x y = dist y x"
```
```   543 proof (rule order_antisym)
```
```   544   show "dist x y \<le> dist y x"
```
```   545     using dist_triangle2 [of x y x] by simp
```
```   546   show "dist y x \<le> dist x y"
```
```   547     using dist_triangle2 [of y x y] by simp
```
```   548 qed
```
```   549
```
```   550 lemma dist_triangle: "dist x z \<le> dist x y + dist y z"
```
```   551 using dist_triangle2 [of x z y] by (simp add: dist_commute)
```
```   552
```
```   553 subclass topological_space
```
```   554 proof
```
```   555   have "\<exists>e::real. 0 < e"
```
```   556     by (fast intro: zero_less_one)
```
```   557   then show "UNIV \<in> topo"
```
```   558     unfolding topo_dist by simp
```
```   559 next
```
```   560   fix A B assume "A \<in> topo" "B \<in> topo"
```
```   561   then show "A \<inter> B \<in> topo"
```
```   562     unfolding topo_dist
```
```   563     apply clarify
```
```   564     apply (drule (1) bspec)+
```
```   565     apply (clarify, rename_tac r s)
```
```   566     apply (rule_tac x="min r s" in exI, simp)
```
```   567     done
```
```   568 next
```
```   569   fix T assume "T \<subseteq> topo" thus "\<Union>T \<in> topo"
```
```   570     unfolding topo_dist by fast
```
```   571 qed
```
```   572
```
```   573 end
```
```   574
```
```   575
```
```   576 subsection {* Real normed vector spaces *}
```
```   577
```
```   578 class norm =
```
```   579   fixes norm :: "'a \<Rightarrow> real"
```
```   580
```
```   581 class sgn_div_norm = scaleR + norm + sgn +
```
```   582   assumes sgn_div_norm: "sgn x = x /\<^sub>R norm x"
```
```   583
```
```   584 class dist_norm = dist + norm + minus +
```
```   585   assumes dist_norm: "dist x y = norm (x - y)"
```
```   586
```
```   587 class real_normed_vector = real_vector + sgn_div_norm + dist_norm + topo_dist +
```
```   588   assumes norm_ge_zero [simp]: "0 \<le> norm x"
```
```   589   and norm_eq_zero [simp]: "norm x = 0 \<longleftrightarrow> x = 0"
```
```   590   and norm_triangle_ineq: "norm (x + y) \<le> norm x + norm y"
```
```   591   and norm_scaleR: "norm (scaleR a x) = \<bar>a\<bar> * norm x"
```
```   592
```
```   593 class real_normed_algebra = real_algebra + real_normed_vector +
```
```   594   assumes norm_mult_ineq: "norm (x * y) \<le> norm x * norm y"
```
```   595
```
```   596 class real_normed_algebra_1 = real_algebra_1 + real_normed_algebra +
```
```   597   assumes norm_one [simp]: "norm 1 = 1"
```
```   598
```
```   599 class real_normed_div_algebra = real_div_algebra + real_normed_vector +
```
```   600   assumes norm_mult: "norm (x * y) = norm x * norm y"
```
```   601
```
```   602 class real_normed_field = real_field + real_normed_div_algebra
```
```   603
```
```   604 instance real_normed_div_algebra < real_normed_algebra_1
```
```   605 proof
```
```   606   fix x y :: 'a
```
```   607   show "norm (x * y) \<le> norm x * norm y"
```
```   608     by (simp add: norm_mult)
```
```   609 next
```
```   610   have "norm (1 * 1::'a) = norm (1::'a) * norm (1::'a)"
```
```   611     by (rule norm_mult)
```
```   612   thus "norm (1::'a) = 1" by simp
```
```   613 qed
```
```   614
```
```   615 instantiation real :: real_normed_field
```
```   616 begin
```
```   617
```
```   618 definition real_norm_def [simp]:
```
```   619   "norm r = \<bar>r\<bar>"
```
```   620
```
```   621 definition dist_real_def:
```
```   622   "dist x y = \<bar>x - y\<bar>"
```
```   623
```
```   624 definition topo_real_def [code del]:
```
```   625   "topo = {S::real set. \<forall>x\<in>S. \<exists>e>0. \<forall>y. dist y x < e \<longrightarrow> y \<in> S}"
```
```   626
```
```   627 instance
```
```   628 apply (intro_classes, unfold real_norm_def real_scaleR_def)
```
```   629 apply (rule dist_real_def)
```
```   630 apply (simp add: real_sgn_def)
```
```   631 apply (rule topo_real_def)
```
```   632 apply (rule abs_ge_zero)
```
```   633 apply (rule abs_eq_0)
```
```   634 apply (rule abs_triangle_ineq)
```
```   635 apply (rule abs_mult)
```
```   636 apply (rule abs_mult)
```
```   637 done
```
```   638
```
```   639 end
```
```   640
```
```   641 lemma norm_zero [simp]: "norm (0::'a::real_normed_vector) = 0"
```
```   642 by simp
```
```   643
```
```   644 lemma zero_less_norm_iff [simp]:
```
```   645   fixes x :: "'a::real_normed_vector"
```
```   646   shows "(0 < norm x) = (x \<noteq> 0)"
```
```   647 by (simp add: order_less_le)
```
```   648
```
```   649 lemma norm_not_less_zero [simp]:
```
```   650   fixes x :: "'a::real_normed_vector"
```
```   651   shows "\<not> norm x < 0"
```
```   652 by (simp add: linorder_not_less)
```
```   653
```
```   654 lemma norm_le_zero_iff [simp]:
```
```   655   fixes x :: "'a::real_normed_vector"
```
```   656   shows "(norm x \<le> 0) = (x = 0)"
```
```   657 by (simp add: order_le_less)
```
```   658
```
```   659 lemma norm_minus_cancel [simp]:
```
```   660   fixes x :: "'a::real_normed_vector"
```
```   661   shows "norm (- x) = norm x"
```
```   662 proof -
```
```   663   have "norm (- x) = norm (scaleR (- 1) x)"
```
```   664     by (simp only: scaleR_minus_left scaleR_one)
```
```   665   also have "\<dots> = \<bar>- 1\<bar> * norm x"
```
```   666     by (rule norm_scaleR)
```
```   667   finally show ?thesis by simp
```
```   668 qed
```
```   669
```
```   670 lemma norm_minus_commute:
```
```   671   fixes a b :: "'a::real_normed_vector"
```
```   672   shows "norm (a - b) = norm (b - a)"
```
```   673 proof -
```
```   674   have "norm (- (b - a)) = norm (b - a)"
```
```   675     by (rule norm_minus_cancel)
```
```   676   thus ?thesis by simp
```
```   677 qed
```
```   678
```
```   679 lemma norm_triangle_ineq2:
```
```   680   fixes a b :: "'a::real_normed_vector"
```
```   681   shows "norm a - norm b \<le> norm (a - b)"
```
```   682 proof -
```
```   683   have "norm (a - b + b) \<le> norm (a - b) + norm b"
```
```   684     by (rule norm_triangle_ineq)
```
```   685   thus ?thesis by simp
```
```   686 qed
```
```   687
```
```   688 lemma norm_triangle_ineq3:
```
```   689   fixes a b :: "'a::real_normed_vector"
```
```   690   shows "\<bar>norm a - norm b\<bar> \<le> norm (a - b)"
```
```   691 apply (subst abs_le_iff)
```
```   692 apply auto
```
```   693 apply (rule norm_triangle_ineq2)
```
```   694 apply (subst norm_minus_commute)
```
```   695 apply (rule norm_triangle_ineq2)
```
```   696 done
```
```   697
```
```   698 lemma norm_triangle_ineq4:
```
```   699   fixes a b :: "'a::real_normed_vector"
```
```   700   shows "norm (a - b) \<le> norm a + norm b"
```
```   701 proof -
```
```   702   have "norm (a + - b) \<le> norm a + norm (- b)"
```
```   703     by (rule norm_triangle_ineq)
```
```   704   thus ?thesis
```
```   705     by (simp only: diff_minus norm_minus_cancel)
```
```   706 qed
```
```   707
```
```   708 lemma norm_diff_ineq:
```
```   709   fixes a b :: "'a::real_normed_vector"
```
```   710   shows "norm a - norm b \<le> norm (a + b)"
```
```   711 proof -
```
```   712   have "norm a - norm (- b) \<le> norm (a - - b)"
```
```   713     by (rule norm_triangle_ineq2)
```
```   714   thus ?thesis by simp
```
```   715 qed
```
```   716
```
```   717 lemma norm_diff_triangle_ineq:
```
```   718   fixes a b c d :: "'a::real_normed_vector"
```
```   719   shows "norm ((a + b) - (c + d)) \<le> norm (a - c) + norm (b - d)"
```
```   720 proof -
```
```   721   have "norm ((a + b) - (c + d)) = norm ((a - c) + (b - d))"
```
```   722     by (simp add: diff_minus add_ac)
```
```   723   also have "\<dots> \<le> norm (a - c) + norm (b - d)"
```
```   724     by (rule norm_triangle_ineq)
```
```   725   finally show ?thesis .
```
```   726 qed
```
```   727
```
```   728 lemma abs_norm_cancel [simp]:
```
```   729   fixes a :: "'a::real_normed_vector"
```
```   730   shows "\<bar>norm a\<bar> = norm a"
```
```   731 by (rule abs_of_nonneg [OF norm_ge_zero])
```
```   732
```
```   733 lemma norm_add_less:
```
```   734   fixes x y :: "'a::real_normed_vector"
```
```   735   shows "\<lbrakk>norm x < r; norm y < s\<rbrakk> \<Longrightarrow> norm (x + y) < r + s"
```
```   736 by (rule order_le_less_trans [OF norm_triangle_ineq add_strict_mono])
```
```   737
```
```   738 lemma norm_mult_less:
```
```   739   fixes x y :: "'a::real_normed_algebra"
```
```   740   shows "\<lbrakk>norm x < r; norm y < s\<rbrakk> \<Longrightarrow> norm (x * y) < r * s"
```
```   741 apply (rule order_le_less_trans [OF norm_mult_ineq])
```
```   742 apply (simp add: mult_strict_mono')
```
```   743 done
```
```   744
```
```   745 lemma norm_of_real [simp]:
```
```   746   "norm (of_real r :: 'a::real_normed_algebra_1) = \<bar>r\<bar>"
```
```   747 unfolding of_real_def by (simp add: norm_scaleR)
```
```   748
```
```   749 lemma norm_number_of [simp]:
```
```   750   "norm (number_of w::'a::{number_ring,real_normed_algebra_1})
```
```   751     = \<bar>number_of w\<bar>"
```
```   752 by (subst of_real_number_of_eq [symmetric], rule norm_of_real)
```
```   753
```
```   754 lemma norm_of_int [simp]:
```
```   755   "norm (of_int z::'a::real_normed_algebra_1) = \<bar>of_int z\<bar>"
```
```   756 by (subst of_real_of_int_eq [symmetric], rule norm_of_real)
```
```   757
```
```   758 lemma norm_of_nat [simp]:
```
```   759   "norm (of_nat n::'a::real_normed_algebra_1) = of_nat n"
```
```   760 apply (subst of_real_of_nat_eq [symmetric])
```
```   761 apply (subst norm_of_real, simp)
```
```   762 done
```
```   763
```
```   764 lemma nonzero_norm_inverse:
```
```   765   fixes a :: "'a::real_normed_div_algebra"
```
```   766   shows "a \<noteq> 0 \<Longrightarrow> norm (inverse a) = inverse (norm a)"
```
```   767 apply (rule inverse_unique [symmetric])
```
```   768 apply (simp add: norm_mult [symmetric])
```
```   769 done
```
```   770
```
```   771 lemma norm_inverse:
```
```   772   fixes a :: "'a::{real_normed_div_algebra,division_by_zero}"
```
```   773   shows "norm (inverse a) = inverse (norm a)"
```
```   774 apply (case_tac "a = 0", simp)
```
```   775 apply (erule nonzero_norm_inverse)
```
```   776 done
```
```   777
```
```   778 lemma nonzero_norm_divide:
```
```   779   fixes a b :: "'a::real_normed_field"
```
```   780   shows "b \<noteq> 0 \<Longrightarrow> norm (a / b) = norm a / norm b"
```
```   781 by (simp add: divide_inverse norm_mult nonzero_norm_inverse)
```
```   782
```
```   783 lemma norm_divide:
```
```   784   fixes a b :: "'a::{real_normed_field,division_by_zero}"
```
```   785   shows "norm (a / b) = norm a / norm b"
```
```   786 by (simp add: divide_inverse norm_mult norm_inverse)
```
```   787
```
```   788 lemma norm_power_ineq:
```
```   789   fixes x :: "'a::{real_normed_algebra_1}"
```
```   790   shows "norm (x ^ n) \<le> norm x ^ n"
```
```   791 proof (induct n)
```
```   792   case 0 show "norm (x ^ 0) \<le> norm x ^ 0" by simp
```
```   793 next
```
```   794   case (Suc n)
```
```   795   have "norm (x * x ^ n) \<le> norm x * norm (x ^ n)"
```
```   796     by (rule norm_mult_ineq)
```
```   797   also from Suc have "\<dots> \<le> norm x * norm x ^ n"
```
```   798     using norm_ge_zero by (rule mult_left_mono)
```
```   799   finally show "norm (x ^ Suc n) \<le> norm x ^ Suc n"
```
```   800     by simp
```
```   801 qed
```
```   802
```
```   803 lemma norm_power:
```
```   804   fixes x :: "'a::{real_normed_div_algebra}"
```
```   805   shows "norm (x ^ n) = norm x ^ n"
```
```   806 by (induct n) (simp_all add: norm_mult)
```
```   807
```
```   808 text {* Every normed vector space is a metric space. *}
```
```   809
```
```   810 instance real_normed_vector < metric_space
```
```   811 proof
```
```   812   fix x y :: 'a show "dist x y = 0 \<longleftrightarrow> x = y"
```
```   813     unfolding dist_norm by simp
```
```   814 next
```
```   815   fix x y z :: 'a show "dist x y \<le> dist x z + dist y z"
```
```   816     unfolding dist_norm
```
```   817     using norm_triangle_ineq4 [of "x - z" "y - z"] by simp
```
```   818 qed
```
```   819
```
```   820 subsection {* Extra type constraints *}
```
```   821
```
```   822 text {* Only allow @{term dist} in class @{text metric_space}. *}
```
```   823
```
```   824 setup {* Sign.add_const_constraint
```
```   825   (@{const_name dist}, SOME @{typ "'a::metric_space \<Rightarrow> 'a \<Rightarrow> real"}) *}
```
```   826
```
```   827 text {* Only allow @{term norm} in class @{text real_normed_vector}. *}
```
```   828
```
```   829 setup {* Sign.add_const_constraint
```
```   830   (@{const_name norm}, SOME @{typ "'a::real_normed_vector \<Rightarrow> real"}) *}
```
```   831
```
```   832
```
```   833 subsection {* Sign function *}
```
```   834
```
```   835 lemma norm_sgn:
```
```   836   "norm (sgn(x::'a::real_normed_vector)) = (if x = 0 then 0 else 1)"
```
```   837 by (simp add: sgn_div_norm norm_scaleR)
```
```   838
```
```   839 lemma sgn_zero [simp]: "sgn(0::'a::real_normed_vector) = 0"
```
```   840 by (simp add: sgn_div_norm)
```
```   841
```
```   842 lemma sgn_zero_iff: "(sgn(x::'a::real_normed_vector) = 0) = (x = 0)"
```
```   843 by (simp add: sgn_div_norm)
```
```   844
```
```   845 lemma sgn_minus: "sgn (- x) = - sgn(x::'a::real_normed_vector)"
```
```   846 by (simp add: sgn_div_norm)
```
```   847
```
```   848 lemma sgn_scaleR:
```
```   849   "sgn (scaleR r x) = scaleR (sgn r) (sgn(x::'a::real_normed_vector))"
```
```   850 by (simp add: sgn_div_norm norm_scaleR mult_ac)
```
```   851
```
```   852 lemma sgn_one [simp]: "sgn (1::'a::real_normed_algebra_1) = 1"
```
```   853 by (simp add: sgn_div_norm)
```
```   854
```
```   855 lemma sgn_of_real:
```
```   856   "sgn (of_real r::'a::real_normed_algebra_1) = of_real (sgn r)"
```
```   857 unfolding of_real_def by (simp only: sgn_scaleR sgn_one)
```
```   858
```
```   859 lemma sgn_mult:
```
```   860   fixes x y :: "'a::real_normed_div_algebra"
```
```   861   shows "sgn (x * y) = sgn x * sgn y"
```
```   862 by (simp add: sgn_div_norm norm_mult mult_commute)
```
```   863
```
```   864 lemma real_sgn_eq: "sgn (x::real) = x / \<bar>x\<bar>"
```
```   865 by (simp add: sgn_div_norm divide_inverse)
```
```   866
```
```   867 lemma real_sgn_pos: "0 < (x::real) \<Longrightarrow> sgn x = 1"
```
```   868 unfolding real_sgn_eq by simp
```
```   869
```
```   870 lemma real_sgn_neg: "(x::real) < 0 \<Longrightarrow> sgn x = -1"
```
```   871 unfolding real_sgn_eq by simp
```
```   872
```
```   873
```
```   874 subsection {* Bounded Linear and Bilinear Operators *}
```
```   875
```
```   876 locale bounded_linear = additive +
```
```   877   constrains f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
```
```   878   assumes scaleR: "f (scaleR r x) = scaleR r (f x)"
```
```   879   assumes bounded: "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K"
```
```   880 begin
```
```   881
```
```   882 lemma pos_bounded:
```
```   883   "\<exists>K>0. \<forall>x. norm (f x) \<le> norm x * K"
```
```   884 proof -
```
```   885   obtain K where K: "\<And>x. norm (f x) \<le> norm x * K"
```
```   886     using bounded by fast
```
```   887   show ?thesis
```
```   888   proof (intro exI impI conjI allI)
```
```   889     show "0 < max 1 K"
```
```   890       by (rule order_less_le_trans [OF zero_less_one le_maxI1])
```
```   891   next
```
```   892     fix x
```
```   893     have "norm (f x) \<le> norm x * K" using K .
```
```   894     also have "\<dots> \<le> norm x * max 1 K"
```
```   895       by (rule mult_left_mono [OF le_maxI2 norm_ge_zero])
```
```   896     finally show "norm (f x) \<le> norm x * max 1 K" .
```
```   897   qed
```
```   898 qed
```
```   899
```
```   900 lemma nonneg_bounded:
```
```   901   "\<exists>K\<ge>0. \<forall>x. norm (f x) \<le> norm x * K"
```
```   902 proof -
```
```   903   from pos_bounded
```
```   904   show ?thesis by (auto intro: order_less_imp_le)
```
```   905 qed
```
```   906
```
```   907 end
```
```   908
```
```   909 locale bounded_bilinear =
```
```   910   fixes prod :: "['a::real_normed_vector, 'b::real_normed_vector]
```
```   911                  \<Rightarrow> 'c::real_normed_vector"
```
```   912     (infixl "**" 70)
```
```   913   assumes add_left: "prod (a + a') b = prod a b + prod a' b"
```
```   914   assumes add_right: "prod a (b + b') = prod a b + prod a b'"
```
```   915   assumes scaleR_left: "prod (scaleR r a) b = scaleR r (prod a b)"
```
```   916   assumes scaleR_right: "prod a (scaleR r b) = scaleR r (prod a b)"
```
```   917   assumes bounded: "\<exists>K. \<forall>a b. norm (prod a b) \<le> norm a * norm b * K"
```
```   918 begin
```
```   919
```
```   920 lemma pos_bounded:
```
```   921   "\<exists>K>0. \<forall>a b. norm (a ** b) \<le> norm a * norm b * K"
```
```   922 apply (cut_tac bounded, erule exE)
```
```   923 apply (rule_tac x="max 1 K" in exI, safe)
```
```   924 apply (rule order_less_le_trans [OF zero_less_one le_maxI1])
```
```   925 apply (drule spec, drule spec, erule order_trans)
```
```   926 apply (rule mult_left_mono [OF le_maxI2])
```
```   927 apply (intro mult_nonneg_nonneg norm_ge_zero)
```
```   928 done
```
```   929
```
```   930 lemma nonneg_bounded:
```
```   931   "\<exists>K\<ge>0. \<forall>a b. norm (a ** b) \<le> norm a * norm b * K"
```
```   932 proof -
```
```   933   from pos_bounded
```
```   934   show ?thesis by (auto intro: order_less_imp_le)
```
```   935 qed
```
```   936
```
```   937 lemma additive_right: "additive (\<lambda>b. prod a b)"
```
```   938 by (rule additive.intro, rule add_right)
```
```   939
```
```   940 lemma additive_left: "additive (\<lambda>a. prod a b)"
```
```   941 by (rule additive.intro, rule add_left)
```
```   942
```
```   943 lemma zero_left: "prod 0 b = 0"
```
```   944 by (rule additive.zero [OF additive_left])
```
```   945
```
```   946 lemma zero_right: "prod a 0 = 0"
```
```   947 by (rule additive.zero [OF additive_right])
```
```   948
```
```   949 lemma minus_left: "prod (- a) b = - prod a b"
```
```   950 by (rule additive.minus [OF additive_left])
```
```   951
```
```   952 lemma minus_right: "prod a (- b) = - prod a b"
```
```   953 by (rule additive.minus [OF additive_right])
```
```   954
```
```   955 lemma diff_left:
```
```   956   "prod (a - a') b = prod a b - prod a' b"
```
```   957 by (rule additive.diff [OF additive_left])
```
```   958
```
```   959 lemma diff_right:
```
```   960   "prod a (b - b') = prod a b - prod a b'"
```
```   961 by (rule additive.diff [OF additive_right])
```
```   962
```
```   963 lemma bounded_linear_left:
```
```   964   "bounded_linear (\<lambda>a. a ** b)"
```
```   965 apply (unfold_locales)
```
```   966 apply (rule add_left)
```
```   967 apply (rule scaleR_left)
```
```   968 apply (cut_tac bounded, safe)
```
```   969 apply (rule_tac x="norm b * K" in exI)
```
```   970 apply (simp add: mult_ac)
```
```   971 done
```
```   972
```
```   973 lemma bounded_linear_right:
```
```   974   "bounded_linear (\<lambda>b. a ** b)"
```
```   975 apply (unfold_locales)
```
```   976 apply (rule add_right)
```
```   977 apply (rule scaleR_right)
```
```   978 apply (cut_tac bounded, safe)
```
```   979 apply (rule_tac x="norm a * K" in exI)
```
```   980 apply (simp add: mult_ac)
```
```   981 done
```
```   982
```
```   983 lemma prod_diff_prod:
```
```   984   "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)"
```
```   985 by (simp add: diff_left diff_right)
```
```   986
```
```   987 end
```
```   988
```
```   989 interpretation mult:
```
```   990   bounded_bilinear "op * :: 'a \<Rightarrow> 'a \<Rightarrow> 'a::real_normed_algebra"
```
```   991 apply (rule bounded_bilinear.intro)
```
```   992 apply (rule left_distrib)
```
```   993 apply (rule right_distrib)
```
```   994 apply (rule mult_scaleR_left)
```
```   995 apply (rule mult_scaleR_right)
```
```   996 apply (rule_tac x="1" in exI)
```
```   997 apply (simp add: norm_mult_ineq)
```
```   998 done
```
```   999
```
```  1000 interpretation mult_left:
```
```  1001   bounded_linear "(\<lambda>x::'a::real_normed_algebra. x * y)"
```
```  1002 by (rule mult.bounded_linear_left)
```
```  1003
```
```  1004 interpretation mult_right:
```
```  1005   bounded_linear "(\<lambda>y::'a::real_normed_algebra. x * y)"
```
```  1006 by (rule mult.bounded_linear_right)
```
```  1007
```
```  1008 interpretation divide:
```
```  1009   bounded_linear "(\<lambda>x::'a::real_normed_field. x / y)"
```
```  1010 unfolding divide_inverse by (rule mult.bounded_linear_left)
```
```  1011
```
```  1012 interpretation scaleR: bounded_bilinear "scaleR"
```
```  1013 apply (rule bounded_bilinear.intro)
```
```  1014 apply (rule scaleR_left_distrib)
```
```  1015 apply (rule scaleR_right_distrib)
```
```  1016 apply simp
```
```  1017 apply (rule scaleR_left_commute)
```
```  1018 apply (rule_tac x="1" in exI)
```
```  1019 apply (simp add: norm_scaleR)
```
```  1020 done
```
```  1021
```
```  1022 interpretation scaleR_left: bounded_linear "\<lambda>r. scaleR r x"
```
```  1023 by (rule scaleR.bounded_linear_left)
```
```  1024
```
```  1025 interpretation scaleR_right: bounded_linear "\<lambda>x. scaleR r x"
```
```  1026 by (rule scaleR.bounded_linear_right)
```
```  1027
```
```  1028 interpretation of_real: bounded_linear "\<lambda>r. of_real r"
```
```  1029 unfolding of_real_def by (rule scaleR.bounded_linear_left)
```
```  1030
```
```  1031 end
```