src/HOL/ex/Classpackage.thy
changeset 24282 9b64aa297524
parent 24249 1f60b45c5f97
child 24348 c708ea5b109a
equal deleted inserted replaced
24281:7d0334b69711 24282:9b64aa297524
   141 using nat_pow_mult by (induct n) simp_all
   141 using nat_pow_mult by (induct n) simp_all
   142 
   142 
   143 end
   143 end
   144 
   144 
   145 instance * :: (monoid, monoid) monoid
   145 instance * :: (monoid, monoid) monoid
   146 by default (simp_all add: split_paired_all mult_prod_def one_prod_def monoid_class.mult_one.neutr)
   146 by default (simp_all add: split_paired_all mult_prod_def one_prod_def neutr)
   147 
   147 
   148 instance list :: (type) monoid
   148 instance list :: (type) monoid
   149 proof
   149 proof
   150   fix xs :: "'a list"
   150   fix xs :: "'a list"
   151   show "xs \<otimes> \<one> = xs"
   151   show "xs \<otimes> \<one> = xs"
   218 instance advanced group < monoid
   218 instance advanced group < monoid
   219 proof unfold_locales
   219 proof unfold_locales
   220   fix x
   220   fix x
   221   from neutr show "x \<^loc>\<otimes> \<^loc>\<one> = x" .
   221   from neutr show "x \<^loc>\<otimes> \<^loc>\<one> = x" .
   222 qed
   222 qed
   223 hide const npow
   223 
       
   224 hide const npow (*FIXME*)
       
   225 lemmas neutr = monoid_class.mult_one.neutr
       
   226 lemmas inv_obtain = monoid_class.inv_obtain
       
   227 lemmas inv_unique = monoid_class.inv_unique
       
   228 lemmas nat_pow_mult = monoid_class.nat_pow_mult
       
   229 lemmas nat_pow_one = monoid_class.nat_pow_one
       
   230 lemmas nat_pow_pow = monoid_class.nat_pow_pow
       
   231 lemmas units_def = monoid_class.units_def
       
   232 lemmas mult_one_def = monoid_class.units_inv_comm
   224 
   233 
   225 context group
   234 context group
   226 begin
   235 begin
   227 
   236 
   228 lemma all_inv [intro]:
   237 lemma all_inv [intro]:
   283   pow :: "int \<Rightarrow> 'a \<Rightarrow> 'a"
   292   pow :: "int \<Rightarrow> 'a \<Rightarrow> 'a"
   284 where
   293 where
   285   "pow k x = (if k < 0 then \<^loc>\<div> (npow (nat (-k)) x)
   294   "pow k x = (if k < 0 then \<^loc>\<div> (npow (nat (-k)) x)
   286     else (npow (nat k) x))"
   295     else (npow (nat k) x))"
   287 
   296 
   288 end context group begin
   297 end
       
   298 
       
   299 (*FIXME*)
       
   300 lemmas pow_def [code func] = pow_def [folded monoid_class.npow]
       
   301 
       
   302 context group begin
   289 
   303 
   290 abbreviation
   304 abbreviation
   291   pow_syn :: "'a \<Rightarrow> int \<Rightarrow> 'a" (infix "\<^loc>\<up>\<up>" 75)
   305   pow_syn :: "'a \<Rightarrow> int \<Rightarrow> 'a" (infix "\<^loc>\<up>\<up>" 75)
   292 where
   306 where
   293   "x \<^loc>\<up>\<up> k \<equiv> pow k x"
   307   "x \<^loc>\<up>\<up> k \<equiv> pow k x"
   320 
   334 
   321 definition
   335 definition
   322   "X a b c = (a \<otimes> \<one> \<otimes> b, a \<otimes> \<one> \<otimes> b, npow 3 [a, b] \<otimes> \<one> \<otimes> [a, b, c])"
   336   "X a b c = (a \<otimes> \<one> \<otimes> b, a \<otimes> \<one> \<otimes> b, npow 3 [a, b] \<otimes> \<one> \<otimes> [a, b, c])"
   323 
   337 
   324 definition
   338 definition
   325   "Y a b c = (a, \<div> a) \<otimes> \<one> \<otimes> \<div> (b, \<div> c)"
   339   "Y a b c = (a, \<div> a) \<otimes> \<one> \<otimes> \<div> (b, \<div> pow (-3) c)"
   326 
   340 
   327 definition "x1 = X (1::nat) 2 3"
   341 definition "x1 = X (1::nat) 2 3"
   328 definition "x2 = X (1::int) 2 3"
   342 definition "x2 = X (1::int) 2 3"
   329 definition "y2 = Y (1::int) 2 3"
   343 definition "y2 = Y (1::int) 2 3"
   330 
   344