src/HOL/Real/RealVector.thy
author huffman
Tue Sep 12 06:44:45 2006 +0200 (2006-09-12)
changeset 20504 6342e872e71d
child 20533 49442b3024bb
permissions -rw-r--r--
formalization of vector spaces and algebras over the real numbers
huffman@20504
     1
(*  Title       : RealVector.thy
huffman@20504
     2
    ID:         $Id$
huffman@20504
     3
    Author      : Brian Huffman
huffman@20504
     4
*)
huffman@20504
     5
huffman@20504
     6
header {* Vector Spaces and Algebras over the Reals *}
huffman@20504
     7
huffman@20504
     8
theory RealVector
huffman@20504
     9
imports RealDef
huffman@20504
    10
begin
huffman@20504
    11
huffman@20504
    12
subsection {* Locale for additive functions *}
huffman@20504
    13
huffman@20504
    14
locale additive =
huffman@20504
    15
  fixes f :: "'a::ab_group_add \<Rightarrow> 'b::ab_group_add"
huffman@20504
    16
  assumes add: "f (x + y) = f x + f y"
huffman@20504
    17
huffman@20504
    18
lemma (in additive) zero: "f 0 = 0"
huffman@20504
    19
proof -
huffman@20504
    20
  have "f 0 = f (0 + 0)" by simp
huffman@20504
    21
  also have "\<dots> = f 0 + f 0" by (rule add)
huffman@20504
    22
  finally show "f 0 = 0" by simp
huffman@20504
    23
qed
huffman@20504
    24
huffman@20504
    25
lemma (in additive) minus: "f (- x) = - f x"
huffman@20504
    26
proof -
huffman@20504
    27
  have "f (- x) + f x = f (- x + x)" by (rule add [symmetric])
huffman@20504
    28
  also have "\<dots> = - f x + f x" by (simp add: zero)
huffman@20504
    29
  finally show "f (- x) = - f x" by (rule add_right_imp_eq)
huffman@20504
    30
qed
huffman@20504
    31
huffman@20504
    32
lemma (in additive) diff: "f (x - y) = f x - f y"
huffman@20504
    33
by (simp add: diff_def add minus)
huffman@20504
    34
huffman@20504
    35
huffman@20504
    36
subsection {* Real vector spaces *}
huffman@20504
    37
huffman@20504
    38
axclass scaleR < type
huffman@20504
    39
huffman@20504
    40
consts
huffman@20504
    41
  scaleR :: "real \<Rightarrow> 'a \<Rightarrow> 'a::scaleR" (infixr "*#" 75)
huffman@20504
    42
huffman@20504
    43
syntax (xsymbols)
huffman@20504
    44
  scaleR :: "real \<Rightarrow> 'a \<Rightarrow> 'a::scaleR" (infixr "*\<^sub>R" 75)
huffman@20504
    45
huffman@20504
    46
axclass real_vector < scaleR, ab_group_add
huffman@20504
    47
  scaleR_right_distrib: "a *# (x + y) = a *# x + a *# y"
huffman@20504
    48
  scaleR_left_distrib: "(a + b) *# x = a *# x + b *# x"
huffman@20504
    49
  scaleR_assoc: "(a * b) *# x = a *# b *# x"
huffman@20504
    50
  scaleR_one [simp]: "1 *# x = x"
huffman@20504
    51
huffman@20504
    52
axclass real_algebra < real_vector, ring
huffman@20504
    53
  mult_scaleR_left: "a *# x * y = a *# (x * y)"
huffman@20504
    54
  mult_scaleR_right: "x * a *# y = a *# (x * y)"
huffman@20504
    55
huffman@20504
    56
lemmas scaleR_scaleR = scaleR_assoc [symmetric]
huffman@20504
    57
huffman@20504
    58
lemma scaleR_left_commute:
huffman@20504
    59
  fixes x :: "'a::real_vector"
huffman@20504
    60
  shows "a *# b *# x = b *# a *# x"
huffman@20504
    61
by (simp add: scaleR_scaleR mult_commute)
huffman@20504
    62
huffman@20504
    63
lemma additive_scaleR_right: "additive (\<lambda>x. a *# x :: 'a::real_vector)"
huffman@20504
    64
by (rule additive.intro, rule scaleR_right_distrib)
huffman@20504
    65
huffman@20504
    66
lemma additive_scaleR_left: "additive (\<lambda>a. a *# x :: 'a::real_vector)"
huffman@20504
    67
by (rule additive.intro, rule scaleR_left_distrib)
huffman@20504
    68
huffman@20504
    69
lemmas scaleR_zero_left [simp] =
huffman@20504
    70
  additive.zero [OF additive_scaleR_left, standard]
huffman@20504
    71
huffman@20504
    72
lemmas scaleR_zero_right [simp] =
huffman@20504
    73
  additive.zero [OF additive_scaleR_right, standard]
huffman@20504
    74
huffman@20504
    75
lemmas scaleR_minus_left [simp] =
huffman@20504
    76
  additive.minus [OF additive_scaleR_left, standard]
huffman@20504
    77
huffman@20504
    78
lemmas scaleR_minus_right [simp] =
huffman@20504
    79
  additive.minus [OF additive_scaleR_right, standard]
huffman@20504
    80
huffman@20504
    81
lemmas scaleR_left_diff_distrib =
huffman@20504
    82
  additive.diff [OF additive_scaleR_left, standard]
huffman@20504
    83
huffman@20504
    84
lemmas scaleR_right_diff_distrib =
huffman@20504
    85
  additive.diff [OF additive_scaleR_right, standard]
huffman@20504
    86
huffman@20504
    87
huffman@20504
    88
subsection {* Real normed vector spaces *}
huffman@20504
    89
huffman@20504
    90
axclass norm < type
huffman@20504
    91
consts norm :: "'a::norm \<Rightarrow> real" ("\<parallel>_\<parallel>")
huffman@20504
    92
huffman@20504
    93
axclass real_normed_vector < real_vector, norm
huffman@20504
    94
  norm_ge_zero [simp]: "0 \<le> \<parallel>x\<parallel>"
huffman@20504
    95
  norm_eq_zero [simp]: "(\<parallel>x\<parallel> = 0) = (x = 0)"
huffman@20504
    96
  norm_triangle_ineq: "\<parallel>x + y\<parallel> \<le> \<parallel>x\<parallel> + \<parallel>y\<parallel>"
huffman@20504
    97
  norm_scaleR: "\<parallel>a *# x\<parallel> = \<bar>a\<bar> * \<parallel>x\<parallel>"
huffman@20504
    98
huffman@20504
    99
axclass real_normed_algebra < real_normed_vector, real_algebra
huffman@20504
   100
  norm_mult_ineq: "\<parallel>x * y\<parallel> \<le> \<parallel>x\<parallel> * \<parallel>y\<parallel>"
huffman@20504
   101
huffman@20504
   102
axclass real_normed_div_algebra
huffman@20504
   103
          < real_normed_vector, real_algebra, division_ring
huffman@20504
   104
  norm_mult: "\<parallel>x * y\<parallel> = \<parallel>x\<parallel> * \<parallel>y\<parallel>"
huffman@20504
   105
  norm_one [simp]: "\<parallel>1\<parallel> = 1"
huffman@20504
   106
huffman@20504
   107
instance real_normed_div_algebra < real_normed_algebra
huffman@20504
   108
by (intro_classes, simp add: norm_mult)
huffman@20504
   109
huffman@20504
   110
lemma norm_zero [simp]: "\<parallel>0::'a::real_normed_vector\<parallel> = 0"
huffman@20504
   111
by simp
huffman@20504
   112
huffman@20504
   113
lemma zero_less_norm_iff [simp]:
huffman@20504
   114
  fixes x :: "'a::real_normed_vector" shows "(0 < \<parallel>x\<parallel>) = (x \<noteq> 0)"
huffman@20504
   115
by (simp add: order_less_le)
huffman@20504
   116
huffman@20504
   117
lemma norm_minus_cancel [simp]:
huffman@20504
   118
  fixes x :: "'a::real_normed_vector" shows "\<parallel>- x\<parallel> = \<parallel>x\<parallel>"
huffman@20504
   119
proof -
huffman@20504
   120
  have "\<parallel>- x\<parallel> = \<parallel>- 1 *# x\<parallel>"
huffman@20504
   121
    by (simp only: scaleR_minus_left scaleR_one)
huffman@20504
   122
  also have "\<dots> = \<bar>- 1\<bar> * \<parallel>x\<parallel>"
huffman@20504
   123
    by (rule norm_scaleR)
huffman@20504
   124
  finally show ?thesis by simp
huffman@20504
   125
qed
huffman@20504
   126
huffman@20504
   127
lemma norm_minus_commute:
huffman@20504
   128
  fixes a b :: "'a::real_normed_vector" shows "\<parallel>a - b\<parallel> = \<parallel>b - a\<parallel>"
huffman@20504
   129
proof -
huffman@20504
   130
  have "\<parallel>a - b\<parallel> = \<parallel>-(a - b)\<parallel>" by (simp only: norm_minus_cancel)
huffman@20504
   131
  also have "\<dots> = \<parallel>b - a\<parallel>" by simp
huffman@20504
   132
  finally show ?thesis .
huffman@20504
   133
qed
huffman@20504
   134
huffman@20504
   135
lemma norm_triangle_ineq2:
huffman@20504
   136
  fixes a :: "'a::real_normed_vector" shows "\<parallel>a\<parallel> - \<parallel>b\<parallel> \<le> \<parallel>a - b\<parallel>"
huffman@20504
   137
proof -
huffman@20504
   138
  have "\<parallel>a - b + b\<parallel> \<le> \<parallel>a - b\<parallel> + \<parallel>b\<parallel>"
huffman@20504
   139
    by (rule norm_triangle_ineq)
huffman@20504
   140
  also have "(a - b + b) = a"
huffman@20504
   141
    by simp
huffman@20504
   142
  finally show ?thesis
huffman@20504
   143
    by (simp add: compare_rls)
huffman@20504
   144
qed
huffman@20504
   145
huffman@20504
   146
lemma norm_triangle_ineq4:
huffman@20504
   147
  fixes a :: "'a::real_normed_vector" shows "\<parallel>a - b\<parallel> \<le> \<parallel>a\<parallel> + \<parallel>b\<parallel>"
huffman@20504
   148
proof -
huffman@20504
   149
  have "\<parallel>a - b\<parallel> = \<parallel>a + - b\<parallel>"
huffman@20504
   150
    by (simp only: diff_minus)
huffman@20504
   151
  also have "\<dots> \<le> \<parallel>a\<parallel> + \<parallel>- b\<parallel>"
huffman@20504
   152
    by (rule norm_triangle_ineq)
huffman@20504
   153
  finally show ?thesis
huffman@20504
   154
    by simp
huffman@20504
   155
qed
huffman@20504
   156
huffman@20504
   157
lemma nonzero_norm_inverse:
huffman@20504
   158
  fixes a :: "'a::real_normed_div_algebra"
huffman@20504
   159
  shows "a \<noteq> 0 \<Longrightarrow> \<parallel>inverse a\<parallel> = inverse \<parallel>a\<parallel>"
huffman@20504
   160
apply (rule inverse_unique [symmetric])
huffman@20504
   161
apply (simp add: norm_mult [symmetric])
huffman@20504
   162
done
huffman@20504
   163
huffman@20504
   164
lemma norm_inverse:
huffman@20504
   165
  fixes a :: "'a::{real_normed_div_algebra,division_by_zero}"
huffman@20504
   166
  shows "\<parallel>inverse a\<parallel> = inverse \<parallel>a\<parallel>"
huffman@20504
   167
apply (case_tac "a = 0", simp)
huffman@20504
   168
apply (erule nonzero_norm_inverse)
huffman@20504
   169
done
huffman@20504
   170
huffman@20504
   171
huffman@20504
   172
subsection {* Instances for type @{typ real} *}
huffman@20504
   173
huffman@20504
   174
instance real :: scaleR ..
huffman@20504
   175
huffman@20504
   176
defs (overloaded)
huffman@20504
   177
  real_scaleR_def: "a *# x \<equiv> a * x"
huffman@20504
   178
huffman@20504
   179
instance real :: real_algebra
huffman@20504
   180
apply (intro_classes, unfold real_scaleR_def)
huffman@20504
   181
apply (rule right_distrib)
huffman@20504
   182
apply (rule left_distrib)
huffman@20504
   183
apply (rule mult_assoc)
huffman@20504
   184
apply (rule mult_1_left)
huffman@20504
   185
apply (rule mult_assoc)
huffman@20504
   186
apply (rule mult_left_commute)
huffman@20504
   187
done
huffman@20504
   188
huffman@20504
   189
instance real :: norm ..
huffman@20504
   190
huffman@20504
   191
defs (overloaded)
huffman@20504
   192
  real_norm_def: "\<parallel>r\<parallel> \<equiv> \<bar>r\<bar>"
huffman@20504
   193
huffman@20504
   194
instance real :: real_normed_div_algebra
huffman@20504
   195
apply (intro_classes, unfold real_norm_def real_scaleR_def)
huffman@20504
   196
apply (rule abs_ge_zero)
huffman@20504
   197
apply (rule abs_eq_0)
huffman@20504
   198
apply (rule abs_triangle_ineq)
huffman@20504
   199
apply (rule abs_mult)
huffman@20504
   200
apply (rule abs_mult)
huffman@20504
   201
apply (rule abs_one)
huffman@20504
   202
done
huffman@20504
   203
huffman@20504
   204
end