src/HOL/Real/RealVector.thy
author huffman
Tue Apr 10 21:51:08 2007 +0200 (2007-04-10)
changeset 22625 a2967023d674
parent 22442 15d9ed9b5051
child 22636 c40465deaf20
permissions -rw-r--r--
interpretation bounded_linear_of_real
     1 (*  Title       : RealVector.thy
     2     ID:         $Id$
     3     Author      : Brian Huffman
     4 *)
     5 
     6 header {* Vector Spaces and Algebras over the Reals *}
     7 
     8 theory RealVector
     9 imports RealPow
    10 begin
    11 
    12 subsection {* Locale for additive functions *}
    13 
    14 locale additive =
    15   fixes f :: "'a::ab_group_add \<Rightarrow> 'b::ab_group_add"
    16   assumes add: "f (x + y) = f x + f y"
    17 
    18 lemma (in additive) 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 (in additive) 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 (in additive) diff: "f (x - y) = f x - f y"
    33 by (simp add: diff_def add minus)
    34 
    35 
    36 subsection {* Real vector spaces *}
    37 
    38 axclass scaleR < type
    39 
    40 consts
    41   scaleR :: "real \<Rightarrow> 'a \<Rightarrow> 'a::scaleR" (infixr "*#" 75)
    42 
    43 abbreviation
    44   divideR :: "'a \<Rightarrow> real \<Rightarrow> 'a::scaleR" (infixl "'/#" 70) where
    45   "x /# r == scaleR (inverse r) x"
    46 
    47 notation (xsymbols)
    48   scaleR (infixr "*\<^sub>R" 75) and
    49   divideR (infixl "'/\<^sub>R" 70)
    50 
    51 instance real :: scaleR ..
    52 
    53 defs (overloaded)
    54   real_scaleR_def: "scaleR a x \<equiv> a * x"
    55 
    56 axclass real_vector < scaleR, ab_group_add
    57   scaleR_right_distrib: "scaleR a (x + y) = scaleR a x + scaleR a y"
    58   scaleR_left_distrib: "scaleR (a + b) x = scaleR a x + scaleR b x"
    59   scaleR_scaleR [simp]: "scaleR a (scaleR b x) = scaleR (a * b) x"
    60   scaleR_one [simp]: "scaleR 1 x = x"
    61 
    62 axclass real_algebra < real_vector, ring
    63   mult_scaleR_left [simp]: "scaleR a x * y = scaleR a (x * y)"
    64   mult_scaleR_right [simp]: "x * scaleR a y = scaleR a (x * y)"
    65 
    66 axclass real_algebra_1 < real_algebra, ring_1
    67 
    68 axclass real_div_algebra < real_algebra_1, division_ring
    69 
    70 axclass real_field < real_div_algebra, field
    71 
    72 instance real :: real_field
    73 apply (intro_classes, unfold real_scaleR_def)
    74 apply (rule right_distrib)
    75 apply (rule left_distrib)
    76 apply (rule mult_assoc [symmetric])
    77 apply (rule mult_1_left)
    78 apply (rule mult_assoc)
    79 apply (rule mult_left_commute)
    80 done
    81 
    82 lemma scaleR_left_commute:
    83   fixes x :: "'a::real_vector"
    84   shows "scaleR a (scaleR b x) = scaleR b (scaleR a x)"
    85 by (simp add: mult_commute)
    86 
    87 lemma additive_scaleR_right: "additive (\<lambda>x. scaleR a x::'a::real_vector)"
    88 by (rule additive.intro, rule scaleR_right_distrib)
    89 
    90 lemma additive_scaleR_left: "additive (\<lambda>a. scaleR a x::'a::real_vector)"
    91 by (rule additive.intro, rule scaleR_left_distrib)
    92 
    93 lemmas scaleR_zero_left [simp] =
    94   additive.zero [OF additive_scaleR_left, standard]
    95 
    96 lemmas scaleR_zero_right [simp] =
    97   additive.zero [OF additive_scaleR_right, standard]
    98 
    99 lemmas scaleR_minus_left [simp] =
   100   additive.minus [OF additive_scaleR_left, standard]
   101 
   102 lemmas scaleR_minus_right [simp] =
   103   additive.minus [OF additive_scaleR_right, standard]
   104 
   105 lemmas scaleR_left_diff_distrib =
   106   additive.diff [OF additive_scaleR_left, standard]
   107 
   108 lemmas scaleR_right_diff_distrib =
   109   additive.diff [OF additive_scaleR_right, standard]
   110 
   111 lemma scaleR_eq_0_iff:
   112   fixes x :: "'a::real_vector"
   113   shows "(scaleR a x = 0) = (a = 0 \<or> x = 0)"
   114 proof cases
   115   assume "a = 0" thus ?thesis by simp
   116 next
   117   assume anz [simp]: "a \<noteq> 0"
   118   { assume "scaleR a x = 0"
   119     hence "scaleR (inverse a) (scaleR a x) = 0" by simp
   120     hence "x = 0" by simp }
   121   thus ?thesis by force
   122 qed
   123 
   124 lemma scaleR_left_imp_eq:
   125   fixes x y :: "'a::real_vector"
   126   shows "\<lbrakk>a \<noteq> 0; scaleR a x = scaleR a y\<rbrakk> \<Longrightarrow> x = y"
   127 proof -
   128   assume nonzero: "a \<noteq> 0"
   129   assume "scaleR a x = scaleR a y"
   130   hence "scaleR a (x - y) = 0"
   131      by (simp add: scaleR_right_diff_distrib)
   132   hence "x - y = 0"
   133      by (simp add: scaleR_eq_0_iff nonzero)
   134   thus "x = y" by simp
   135 qed
   136 
   137 lemma scaleR_right_imp_eq:
   138   fixes x y :: "'a::real_vector"
   139   shows "\<lbrakk>x \<noteq> 0; scaleR a x = scaleR b x\<rbrakk> \<Longrightarrow> a = b"
   140 proof -
   141   assume nonzero: "x \<noteq> 0"
   142   assume "scaleR a x = scaleR b x"
   143   hence "scaleR (a - b) x = 0"
   144      by (simp add: scaleR_left_diff_distrib)
   145   hence "a - b = 0"
   146      by (simp add: scaleR_eq_0_iff nonzero)
   147   thus "a = b" by simp
   148 qed
   149 
   150 lemma scaleR_cancel_left:
   151   fixes x y :: "'a::real_vector"
   152   shows "(scaleR a x = scaleR a y) = (x = y \<or> a = 0)"
   153 by (auto intro: scaleR_left_imp_eq)
   154 
   155 lemma scaleR_cancel_right:
   156   fixes x y :: "'a::real_vector"
   157   shows "(scaleR a x = scaleR b x) = (a = b \<or> x = 0)"
   158 by (auto intro: scaleR_right_imp_eq)
   159 
   160 lemma nonzero_inverse_scaleR_distrib:
   161   fixes x :: "'a::real_div_algebra" shows
   162   "\<lbrakk>a \<noteq> 0; x \<noteq> 0\<rbrakk> \<Longrightarrow> inverse (scaleR a x) = scaleR (inverse a) (inverse x)"
   163 by (rule inverse_unique, simp)
   164 
   165 lemma inverse_scaleR_distrib:
   166   fixes x :: "'a::{real_div_algebra,division_by_zero}"
   167   shows "inverse (scaleR a x) = scaleR (inverse a) (inverse x)"
   168 apply (case_tac "a = 0", simp)
   169 apply (case_tac "x = 0", simp)
   170 apply (erule (1) nonzero_inverse_scaleR_distrib)
   171 done
   172 
   173 
   174 subsection {* Embedding of the Reals into any @{text real_algebra_1}:
   175 @{term of_real} *}
   176 
   177 definition
   178   of_real :: "real \<Rightarrow> 'a::real_algebra_1" where
   179   "of_real r = scaleR r 1"
   180 
   181 lemma scaleR_conv_of_real: "scaleR r x = of_real r * x"
   182 by (simp add: of_real_def)
   183 
   184 lemma of_real_0 [simp]: "of_real 0 = 0"
   185 by (simp add: of_real_def)
   186 
   187 lemma of_real_1 [simp]: "of_real 1 = 1"
   188 by (simp add: of_real_def)
   189 
   190 lemma of_real_add [simp]: "of_real (x + y) = of_real x + of_real y"
   191 by (simp add: of_real_def scaleR_left_distrib)
   192 
   193 lemma of_real_minus [simp]: "of_real (- x) = - of_real x"
   194 by (simp add: of_real_def)
   195 
   196 lemma of_real_diff [simp]: "of_real (x - y) = of_real x - of_real y"
   197 by (simp add: of_real_def scaleR_left_diff_distrib)
   198 
   199 lemma of_real_mult [simp]: "of_real (x * y) = of_real x * of_real y"
   200 by (simp add: of_real_def mult_commute)
   201 
   202 lemma nonzero_of_real_inverse:
   203   "x \<noteq> 0 \<Longrightarrow> of_real (inverse x) =
   204    inverse (of_real x :: 'a::real_div_algebra)"
   205 by (simp add: of_real_def nonzero_inverse_scaleR_distrib)
   206 
   207 lemma of_real_inverse [simp]:
   208   "of_real (inverse x) =
   209    inverse (of_real x :: 'a::{real_div_algebra,division_by_zero})"
   210 by (simp add: of_real_def inverse_scaleR_distrib)
   211 
   212 lemma nonzero_of_real_divide:
   213   "y \<noteq> 0 \<Longrightarrow> of_real (x / y) =
   214    (of_real x / of_real y :: 'a::real_field)"
   215 by (simp add: divide_inverse nonzero_of_real_inverse)
   216 
   217 lemma of_real_divide [simp]:
   218   "of_real (x / y) =
   219    (of_real x / of_real y :: 'a::{real_field,division_by_zero})"
   220 by (simp add: divide_inverse)
   221 
   222 lemma of_real_power [simp]:
   223   "of_real (x ^ n) = (of_real x :: 'a::{real_algebra_1,recpower}) ^ n"
   224 by (induct n) (simp_all add: power_Suc)
   225 
   226 lemma of_real_eq_iff [simp]: "(of_real x = of_real y) = (x = y)"
   227 by (simp add: of_real_def scaleR_cancel_right)
   228 
   229 lemmas of_real_eq_0_iff [simp] = of_real_eq_iff [of _ 0, simplified]
   230 
   231 lemma of_real_eq_id [simp]: "of_real = (id :: real \<Rightarrow> real)"
   232 proof
   233   fix r
   234   show "of_real r = id r"
   235     by (simp add: of_real_def real_scaleR_def)
   236 qed
   237 
   238 text{*Collapse nested embeddings*}
   239 lemma of_real_of_nat_eq [simp]: "of_real (of_nat n) = of_nat n"
   240 by (induct n) auto
   241 
   242 lemma of_real_of_int_eq [simp]: "of_real (of_int z) = of_int z"
   243 by (cases z rule: int_diff_cases, simp)
   244 
   245 lemma of_real_number_of_eq:
   246   "of_real (number_of w) = (number_of w :: 'a::{number_ring,real_algebra_1})"
   247 by (simp add: number_of_eq)
   248 
   249 
   250 subsection {* The Set of Real Numbers *}
   251 
   252 definition
   253   Reals :: "'a::real_algebra_1 set" where
   254   "Reals \<equiv> range of_real"
   255 
   256 notation (xsymbols)
   257   Reals  ("\<real>")
   258 
   259 lemma Reals_of_real [simp]: "of_real r \<in> Reals"
   260 by (simp add: Reals_def)
   261 
   262 lemma Reals_of_int [simp]: "of_int z \<in> Reals"
   263 by (subst of_real_of_int_eq [symmetric], rule Reals_of_real)
   264 
   265 lemma Reals_of_nat [simp]: "of_nat n \<in> Reals"
   266 by (subst of_real_of_nat_eq [symmetric], rule Reals_of_real)
   267 
   268 lemma Reals_number_of [simp]:
   269   "(number_of w::'a::{number_ring,real_algebra_1}) \<in> Reals"
   270 by (subst of_real_number_of_eq [symmetric], rule Reals_of_real)
   271 
   272 lemma Reals_0 [simp]: "0 \<in> Reals"
   273 apply (unfold Reals_def)
   274 apply (rule range_eqI)
   275 apply (rule of_real_0 [symmetric])
   276 done
   277 
   278 lemma Reals_1 [simp]: "1 \<in> Reals"
   279 apply (unfold Reals_def)
   280 apply (rule range_eqI)
   281 apply (rule of_real_1 [symmetric])
   282 done
   283 
   284 lemma Reals_add [simp]: "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a + b \<in> Reals"
   285 apply (auto simp add: Reals_def)
   286 apply (rule range_eqI)
   287 apply (rule of_real_add [symmetric])
   288 done
   289 
   290 lemma Reals_minus [simp]: "a \<in> Reals \<Longrightarrow> - a \<in> Reals"
   291 apply (auto simp add: Reals_def)
   292 apply (rule range_eqI)
   293 apply (rule of_real_minus [symmetric])
   294 done
   295 
   296 lemma Reals_diff [simp]: "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a - b \<in> Reals"
   297 apply (auto simp add: Reals_def)
   298 apply (rule range_eqI)
   299 apply (rule of_real_diff [symmetric])
   300 done
   301 
   302 lemma Reals_mult [simp]: "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a * b \<in> Reals"
   303 apply (auto simp add: Reals_def)
   304 apply (rule range_eqI)
   305 apply (rule of_real_mult [symmetric])
   306 done
   307 
   308 lemma nonzero_Reals_inverse:
   309   fixes a :: "'a::real_div_algebra"
   310   shows "\<lbrakk>a \<in> Reals; a \<noteq> 0\<rbrakk> \<Longrightarrow> inverse a \<in> Reals"
   311 apply (auto simp add: Reals_def)
   312 apply (rule range_eqI)
   313 apply (erule nonzero_of_real_inverse [symmetric])
   314 done
   315 
   316 lemma Reals_inverse [simp]:
   317   fixes a :: "'a::{real_div_algebra,division_by_zero}"
   318   shows "a \<in> Reals \<Longrightarrow> inverse a \<in> Reals"
   319 apply (auto simp add: Reals_def)
   320 apply (rule range_eqI)
   321 apply (rule of_real_inverse [symmetric])
   322 done
   323 
   324 lemma nonzero_Reals_divide:
   325   fixes a b :: "'a::real_field"
   326   shows "\<lbrakk>a \<in> Reals; b \<in> Reals; b \<noteq> 0\<rbrakk> \<Longrightarrow> a / b \<in> Reals"
   327 apply (auto simp add: Reals_def)
   328 apply (rule range_eqI)
   329 apply (erule nonzero_of_real_divide [symmetric])
   330 done
   331 
   332 lemma Reals_divide [simp]:
   333   fixes a b :: "'a::{real_field,division_by_zero}"
   334   shows "\<lbrakk>a \<in> Reals; b \<in> Reals\<rbrakk> \<Longrightarrow> a / b \<in> Reals"
   335 apply (auto simp add: Reals_def)
   336 apply (rule range_eqI)
   337 apply (rule of_real_divide [symmetric])
   338 done
   339 
   340 lemma Reals_power [simp]:
   341   fixes a :: "'a::{real_algebra_1,recpower}"
   342   shows "a \<in> Reals \<Longrightarrow> a ^ n \<in> Reals"
   343 apply (auto simp add: Reals_def)
   344 apply (rule range_eqI)
   345 apply (rule of_real_power [symmetric])
   346 done
   347 
   348 lemma Reals_cases [cases set: Reals]:
   349   assumes "q \<in> \<real>"
   350   obtains (of_real) r where "q = of_real r"
   351   unfolding Reals_def
   352 proof -
   353   from `q \<in> \<real>` have "q \<in> range of_real" unfolding Reals_def .
   354   then obtain r where "q = of_real r" ..
   355   then show thesis ..
   356 qed
   357 
   358 lemma Reals_induct [case_names of_real, induct set: Reals]:
   359   "q \<in> \<real> \<Longrightarrow> (\<And>r. P (of_real r)) \<Longrightarrow> P q"
   360   by (rule Reals_cases) auto
   361 
   362 
   363 subsection {* Real normed vector spaces *}
   364 
   365 axclass norm < type
   366 consts norm :: "'a::norm \<Rightarrow> real"
   367 
   368 instance real :: norm ..
   369 
   370 defs (overloaded)
   371   real_norm_def [simp]: "norm r \<equiv> \<bar>r\<bar>"
   372 
   373 axclass normed < plus, zero, norm
   374   norm_ge_zero [simp]: "0 \<le> norm x"
   375   norm_eq_zero [simp]: "(norm x = 0) = (x = 0)"
   376   norm_triangle_ineq: "norm (x + y) \<le> norm x + norm y"
   377 
   378 axclass real_normed_vector < real_vector, normed
   379   norm_scaleR: "norm (scaleR a x) = \<bar>a\<bar> * norm x"
   380 
   381 axclass real_normed_algebra < real_algebra, real_normed_vector
   382   norm_mult_ineq: "norm (x * y) \<le> norm x * norm y"
   383 
   384 axclass real_normed_div_algebra < real_div_algebra, normed
   385   norm_of_real: "norm (of_real r) = abs r"
   386   norm_mult: "norm (x * y) = norm x * norm y"
   387 
   388 axclass real_normed_field < real_field, real_normed_div_algebra
   389 
   390 instance real_normed_div_algebra < real_normed_algebra
   391 proof
   392   fix a :: real and x :: 'a
   393   have "norm (scaleR a x) = norm (of_real a * x)"
   394     by (simp add: of_real_def)
   395   also have "\<dots> = abs a * norm x"
   396     by (simp add: norm_mult norm_of_real)
   397   finally show "norm (scaleR a x) = abs a * norm x" .
   398 next
   399   fix x y :: 'a
   400   show "norm (x * y) \<le> norm x * norm y"
   401     by (simp add: norm_mult)
   402 qed
   403 
   404 instance real :: real_normed_field
   405 apply (intro_classes, unfold real_norm_def)
   406 apply (rule abs_ge_zero)
   407 apply (rule abs_eq_0)
   408 apply (rule abs_triangle_ineq)
   409 apply simp
   410 apply (rule abs_mult)
   411 done
   412 
   413 lemma norm_zero [simp]: "norm (0::'a::normed) = 0"
   414 by simp
   415 
   416 lemma zero_less_norm_iff [simp]: "(0 < norm x) = (x \<noteq> (0::'a::normed))"
   417 by (simp add: order_less_le)
   418 
   419 lemma norm_not_less_zero [simp]: "\<not> norm (x::'a::normed) < 0"
   420 by (simp add: linorder_not_less)
   421 
   422 lemma norm_le_zero_iff [simp]: "(norm x \<le> 0) = (x = (0::'a::normed))"
   423 by (simp add: order_le_less)
   424 
   425 lemma norm_minus_cancel [simp]:
   426   fixes x :: "'a::real_normed_vector"
   427   shows "norm (- x) = norm x"
   428 proof -
   429   have "norm (- x) = norm (scaleR (- 1) x)"
   430     by (simp only: scaleR_minus_left scaleR_one)
   431   also have "\<dots> = \<bar>- 1\<bar> * norm x"
   432     by (rule norm_scaleR)
   433   finally show ?thesis by simp
   434 qed
   435 
   436 lemma norm_minus_commute:
   437   fixes a b :: "'a::real_normed_vector"
   438   shows "norm (a - b) = norm (b - a)"
   439 proof -
   440   have "norm (a - b) = norm (- (a - b))"
   441     by (simp only: norm_minus_cancel)
   442   also have "\<dots> = norm (b - a)" by simp
   443   finally show ?thesis .
   444 qed
   445 
   446 lemma norm_triangle_ineq2:
   447   fixes a b :: "'a::real_normed_vector"
   448   shows "norm a - norm b \<le> norm (a - b)"
   449 proof -
   450   have "norm (a - b + b) \<le> norm (a - b) + norm b"
   451     by (rule norm_triangle_ineq)
   452   also have "(a - b + b) = a"
   453     by simp
   454   finally show ?thesis
   455     by (simp add: compare_rls)
   456 qed
   457 
   458 lemma norm_triangle_ineq3:
   459   fixes a b :: "'a::real_normed_vector"
   460   shows "\<bar>norm a - norm b\<bar> \<le> norm (a - b)"
   461 apply (subst abs_le_iff)
   462 apply auto
   463 apply (rule norm_triangle_ineq2)
   464 apply (subst norm_minus_commute)
   465 apply (rule norm_triangle_ineq2)
   466 done
   467 
   468 lemma norm_triangle_ineq4:
   469   fixes a b :: "'a::real_normed_vector"
   470   shows "norm (a - b) \<le> norm a + norm b"
   471 proof -
   472   have "norm (a - b) = norm (a + - b)"
   473     by (simp only: diff_minus)
   474   also have "\<dots> \<le> norm a + norm (- b)"
   475     by (rule norm_triangle_ineq)
   476   finally show ?thesis
   477     by simp
   478 qed
   479 
   480 lemma norm_diff_triangle_ineq:
   481   fixes a b c d :: "'a::real_normed_vector"
   482   shows "norm ((a + b) - (c + d)) \<le> norm (a - c) + norm (b - d)"
   483 proof -
   484   have "norm ((a + b) - (c + d)) = norm ((a - c) + (b - d))"
   485     by (simp add: diff_minus add_ac)
   486   also have "\<dots> \<le> norm (a - c) + norm (b - d)"
   487     by (rule norm_triangle_ineq)
   488   finally show ?thesis .
   489 qed
   490 
   491 lemma norm_one [simp]: "norm (1::'a::real_normed_div_algebra) = 1"
   492 proof -
   493   have "norm (of_real 1 :: 'a) = abs 1"
   494     by (rule norm_of_real)
   495   thus ?thesis by simp
   496 qed
   497 
   498 lemma nonzero_norm_inverse:
   499   fixes a :: "'a::real_normed_div_algebra"
   500   shows "a \<noteq> 0 \<Longrightarrow> norm (inverse a) = inverse (norm a)"
   501 apply (rule inverse_unique [symmetric])
   502 apply (simp add: norm_mult [symmetric])
   503 done
   504 
   505 lemma norm_inverse:
   506   fixes a :: "'a::{real_normed_div_algebra,division_by_zero}"
   507   shows "norm (inverse a) = inverse (norm a)"
   508 apply (case_tac "a = 0", simp)
   509 apply (erule nonzero_norm_inverse)
   510 done
   511 
   512 lemma nonzero_norm_divide:
   513   fixes a b :: "'a::real_normed_field"
   514   shows "b \<noteq> 0 \<Longrightarrow> norm (a / b) = norm a / norm b"
   515 by (simp add: divide_inverse norm_mult nonzero_norm_inverse)
   516 
   517 lemma norm_divide:
   518   fixes a b :: "'a::{real_normed_field,division_by_zero}"
   519   shows "norm (a / b) = norm a / norm b"
   520 by (simp add: divide_inverse norm_mult norm_inverse)
   521 
   522 lemma norm_power:
   523   fixes x :: "'a::{real_normed_div_algebra,recpower}"
   524   shows "norm (x ^ n) = norm x ^ n"
   525 by (induct n) (simp_all add: power_Suc norm_mult)
   526 
   527 
   528 subsection {* Bounded Linear and Bilinear Operators *}
   529 
   530 locale bounded_linear = additive +
   531   constrains f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
   532   assumes scaleR: "f (scaleR r x) = scaleR r (f x)"
   533   assumes bounded: "\<exists>K. \<forall>x. norm (f x) \<le> norm x * K"
   534 
   535 lemma (in bounded_linear) pos_bounded:
   536   "\<exists>K>0. \<forall>x. norm (f x) \<le> norm x * K"
   537 proof -
   538   obtain K where K: "\<And>x. norm (f x) \<le> norm x * K"
   539     using bounded by fast
   540   show ?thesis
   541   proof (intro exI impI conjI allI)
   542     show "0 < max 1 K"
   543       by (rule order_less_le_trans [OF zero_less_one le_maxI1])
   544   next
   545     fix x
   546     have "norm (f x) \<le> norm x * K" using K .
   547     also have "\<dots> \<le> norm x * max 1 K"
   548       by (rule mult_left_mono [OF le_maxI2 norm_ge_zero])
   549     finally show "norm (f x) \<le> norm x * max 1 K" .
   550   qed
   551 qed
   552 
   553 lemma (in bounded_linear) nonneg_bounded:
   554   "\<exists>K\<ge>0. \<forall>x. norm (f x) \<le> norm x * K"
   555 proof -
   556   from pos_bounded
   557   show ?thesis by (auto intro: order_less_imp_le)
   558 qed
   559 
   560 locale bounded_bilinear =
   561   fixes prod :: "['a::real_normed_vector, 'b::real_normed_vector]
   562                  \<Rightarrow> 'c::real_normed_vector"
   563     (infixl "**" 70)
   564   assumes add_left: "prod (a + a') b = prod a b + prod a' b"
   565   assumes add_right: "prod a (b + b') = prod a b + prod a b'"
   566   assumes scaleR_left: "prod (scaleR r a) b = scaleR r (prod a b)"
   567   assumes scaleR_right: "prod a (scaleR r b) = scaleR r (prod a b)"
   568   assumes bounded: "\<exists>K. \<forall>a b. norm (prod a b) \<le> norm a * norm b * K"
   569 
   570 lemma (in bounded_bilinear) pos_bounded:
   571   "\<exists>K>0. \<forall>a b. norm (a ** b) \<le> norm a * norm b * K"
   572 apply (cut_tac bounded, erule exE)
   573 apply (rule_tac x="max 1 K" in exI, safe)
   574 apply (rule order_less_le_trans [OF zero_less_one le_maxI1])
   575 apply (drule spec, drule spec, erule order_trans)
   576 apply (rule mult_left_mono [OF le_maxI2])
   577 apply (intro mult_nonneg_nonneg norm_ge_zero)
   578 done
   579 
   580 lemma (in bounded_bilinear) nonneg_bounded:
   581   "\<exists>K\<ge>0. \<forall>a b. norm (a ** b) \<le> norm a * norm b * K"
   582 proof -
   583   from pos_bounded
   584   show ?thesis by (auto intro: order_less_imp_le)
   585 qed
   586 
   587 lemma (in bounded_bilinear) additive_right: "additive (\<lambda>b. prod a b)"
   588 by (rule additive.intro, rule add_right)
   589 
   590 lemma (in bounded_bilinear) additive_left: "additive (\<lambda>a. prod a b)"
   591 by (rule additive.intro, rule add_left)
   592 
   593 lemma (in bounded_bilinear) zero_left: "prod 0 b = 0"
   594 by (rule additive.zero [OF additive_left])
   595 
   596 lemma (in bounded_bilinear) zero_right: "prod a 0 = 0"
   597 by (rule additive.zero [OF additive_right])
   598 
   599 lemma (in bounded_bilinear) minus_left: "prod (- a) b = - prod a b"
   600 by (rule additive.minus [OF additive_left])
   601 
   602 lemma (in bounded_bilinear) minus_right: "prod a (- b) = - prod a b"
   603 by (rule additive.minus [OF additive_right])
   604 
   605 lemma (in bounded_bilinear) diff_left:
   606   "prod (a - a') b = prod a b - prod a' b"
   607 by (rule additive.diff [OF additive_left])
   608 
   609 lemma (in bounded_bilinear) diff_right:
   610   "prod a (b - b') = prod a b - prod a b'"
   611 by (rule additive.diff [OF additive_right])
   612 
   613 lemma (in bounded_bilinear) bounded_linear_left:
   614   "bounded_linear (\<lambda>a. a ** b)"
   615 apply (unfold_locales)
   616 apply (rule add_left)
   617 apply (rule scaleR_left)
   618 apply (cut_tac bounded, safe)
   619 apply (rule_tac x="norm b * K" in exI)
   620 apply (simp add: mult_ac)
   621 done
   622 
   623 lemma (in bounded_bilinear) bounded_linear_right:
   624   "bounded_linear (\<lambda>b. a ** b)"
   625 apply (unfold_locales)
   626 apply (rule add_right)
   627 apply (rule scaleR_right)
   628 apply (cut_tac bounded, safe)
   629 apply (rule_tac x="norm a * K" in exI)
   630 apply (simp add: mult_ac)
   631 done
   632 
   633 lemma (in bounded_bilinear) prod_diff_prod:
   634   "(x ** y - a ** b) = (x - a) ** (y - b) + (x - a) ** b + a ** (y - b)"
   635 by (simp add: diff_left diff_right)
   636 
   637 interpretation bounded_bilinear_mult:
   638   bounded_bilinear ["op * :: 'a \<Rightarrow> 'a \<Rightarrow> 'a::real_normed_algebra"]
   639 apply (rule bounded_bilinear.intro)
   640 apply (rule left_distrib)
   641 apply (rule right_distrib)
   642 apply (rule mult_scaleR_left)
   643 apply (rule mult_scaleR_right)
   644 apply (rule_tac x="1" in exI)
   645 apply (simp add: norm_mult_ineq)
   646 done
   647 
   648 interpretation bounded_linear_mult_left:
   649   bounded_linear ["(\<lambda>x::'a::real_normed_algebra. x * y)"]
   650 by (rule bounded_bilinear_mult.bounded_linear_left)
   651 
   652 interpretation bounded_linear_mult_right:
   653   bounded_linear ["(\<lambda>y::'a::real_normed_algebra. x * y)"]
   654 by (rule bounded_bilinear_mult.bounded_linear_right)
   655 
   656 interpretation bounded_bilinear_scaleR:
   657   bounded_bilinear ["scaleR"]
   658 apply (rule bounded_bilinear.intro)
   659 apply (rule scaleR_left_distrib)
   660 apply (rule scaleR_right_distrib)
   661 apply (simp add: real_scaleR_def)
   662 apply (rule scaleR_left_commute)
   663 apply (rule_tac x="1" in exI)
   664 apply (simp add: norm_scaleR)
   665 done
   666 
   667 interpretation bounded_linear_of_real:
   668   bounded_linear ["\<lambda>r. of_real r"]
   669 apply (unfold of_real_def)
   670 apply (rule bounded_bilinear_scaleR.bounded_linear_left)
   671 done
   672 
   673 end