src/HOL/RealVector.thy
changeset 30070 76cee7c62782
parent 30069 e2fe62de0925
child 30242 aea5d7fa7ef5
equal deleted inserted replaced
30069:e2fe62de0925 30070:76cee7c62782
    44 
    44 
    45 subsection {* Vector spaces *}
    45 subsection {* Vector spaces *}
    46 
    46 
    47 locale vector_space =
    47 locale vector_space =
    48   fixes scale :: "'a::field \<Rightarrow> 'b::ab_group_add \<Rightarrow> 'b"
    48   fixes scale :: "'a::field \<Rightarrow> 'b::ab_group_add \<Rightarrow> 'b"
    49   assumes scale_right_distrib: "scale a (x + y) = scale a x + scale a y"
    49   assumes scale_right_distrib [algebra_simps]:
    50   and scale_left_distrib: "scale (a + b) x = scale a x + scale b x"
    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"
    51   and scale_scale [simp]: "scale a (scale b x) = scale (a * b) x"
    53   and scale_scale [simp]: "scale a (scale b x) = scale (a * b) x"
    52   and scale_one [simp]: "scale 1 x = x"
    54   and scale_one [simp]: "scale 1 x = x"
    53 begin
    55 begin
    54 
    56 
    55 lemma scale_left_commute:
    57 lemma scale_left_commute:
    56   "scale a (scale b x) = scale b (scale a x)"
    58   "scale a (scale b x) = scale b (scale a x)"
    57 by (simp add: mult_commute)
    59 by (simp add: mult_commute)
    58 
    60 
    59 lemma scale_zero_left [simp]: "scale 0 x = 0"
    61 lemma scale_zero_left [simp]: "scale 0 x = 0"
    60   and scale_minus_left [simp]: "scale (- a) x = - (scale a x)"
    62   and scale_minus_left [simp]: "scale (- a) x = - (scale a x)"
    61   and scale_left_diff_distrib: "scale (a - b) x = scale a x - scale b x"
    63   and scale_left_diff_distrib [algebra_simps]:
       
    64         "scale (a - b) x = scale a x - scale b x"
    62 proof -
    65 proof -
    63   interpret s: additive "\<lambda>a. scale a x"
    66   interpret s: additive "\<lambda>a. scale a x"
    64     proof qed (rule scale_left_distrib)
    67     proof qed (rule scale_left_distrib)
    65   show "scale 0 x = 0" by (rule s.zero)
    68   show "scale 0 x = 0" by (rule s.zero)
    66   show "scale (- a) x = - (scale a x)" by (rule s.minus)
    69   show "scale (- a) x = - (scale a x)" by (rule s.minus)
    67   show "scale (a - b) x = scale a x - scale b x" by (rule s.diff)
    70   show "scale (a - b) x = scale a x - scale b x" by (rule s.diff)
    68 qed
    71 qed
    69 
    72 
    70 lemma scale_zero_right [simp]: "scale a 0 = 0"
    73 lemma scale_zero_right [simp]: "scale a 0 = 0"
    71   and scale_minus_right [simp]: "scale a (- x) = - (scale a x)"
    74   and scale_minus_right [simp]: "scale a (- x) = - (scale a x)"
    72   and scale_right_diff_distrib: "scale a (x - y) = scale a x - scale a y"
    75   and scale_right_diff_distrib [algebra_simps]:
       
    76         "scale a (x - y) = scale a x - scale a y"
    73 proof -
    77 proof -
    74   interpret s: additive "\<lambda>x. scale a x"
    78   interpret s: additive "\<lambda>x. scale a x"
    75     proof qed (rule scale_right_distrib)
    79     proof qed (rule scale_right_distrib)
    76   show "scale a 0 = 0" by (rule s.zero)
    80   show "scale a 0 = 0" by (rule s.zero)
    77   show "scale a (- x) = - (scale a x)" by (rule s.minus)
    81   show "scale a (- x) = - (scale a x)" by (rule s.minus)
   136 end
   140 end
   137 
   141 
   138 class real_vector = scaleR + ab_group_add +
   142 class real_vector = scaleR + ab_group_add +
   139   assumes scaleR_right_distrib: "scaleR a (x + y) = scaleR a x + scaleR a y"
   143   assumes scaleR_right_distrib: "scaleR a (x + y) = scaleR a x + scaleR a y"
   140   and scaleR_left_distrib: "scaleR (a + b) x = scaleR a x + scaleR b x"
   144   and scaleR_left_distrib: "scaleR (a + b) x = scaleR a x + scaleR b x"
   141   and scaleR_scaleR [simp]: "scaleR a (scaleR b x) = scaleR (a * b) x"
   145   and scaleR_scaleR: "scaleR a (scaleR b x) = scaleR (a * b) x"
   142   and scaleR_one [simp]: "scaleR 1 x = x"
   146   and scaleR_one: "scaleR 1 x = x"
   143 
   147 
   144 interpretation real_vector!:
   148 interpretation real_vector!:
   145   vector_space "scaleR :: real \<Rightarrow> 'a \<Rightarrow> 'a::real_vector"
   149   vector_space "scaleR :: real \<Rightarrow> 'a \<Rightarrow> 'a::real_vector"
   146 apply unfold_locales
   150 apply unfold_locales
   147 apply (rule scaleR_right_distrib)
   151 apply (rule scaleR_right_distrib)
   179 begin
   183 begin
   180 
   184 
   181 definition
   185 definition
   182   real_scaleR_def [simp]: "scaleR a x = a * x"
   186   real_scaleR_def [simp]: "scaleR a x = a * x"
   183 
   187 
   184 instance
   188 instance proof
   185 apply (intro_classes, unfold real_scaleR_def)
   189 qed (simp_all add: algebra_simps)
   186 apply (rule right_distrib)
       
   187 apply (rule left_distrib)
       
   188 apply (rule mult_assoc [symmetric])
       
   189 apply (rule mult_1_left)
       
   190 apply (rule mult_assoc)
       
   191 apply (rule mult_left_commute)
       
   192 done
       
   193 
   190 
   194 end
   191 end
   195 
   192 
   196 interpretation scaleR_left!: additive "(\<lambda>a. scaleR a x::'a::real_vector)"
   193 interpretation scaleR_left!: additive "(\<lambda>a. scaleR a x::'a::real_vector)"
   197 proof qed (rule scaleR_left_distrib)
   194 proof qed (rule scaleR_left_distrib)
   303 
   300 
   304 subsection {* The Set of Real Numbers *}
   301 subsection {* The Set of Real Numbers *}
   305 
   302 
   306 definition
   303 definition
   307   Reals :: "'a::real_algebra_1 set" where
   304   Reals :: "'a::real_algebra_1 set" where
   308   [code del]: "Reals \<equiv> range of_real"
   305   [code del]: "Reals = range of_real"
   309 
   306 
   310 notation (xsymbols)
   307 notation (xsymbols)
   311   Reals  ("\<real>")
   308   Reals  ("\<real>")
   312 
   309 
   313 lemma Reals_of_real [simp]: "of_real r \<in> Reals"
   310 lemma Reals_of_real [simp]: "of_real r \<in> Reals"