src/HOL/HOL.thy
changeset 20713 823967ef47f1
parent 20698 cb910529d49d
child 20741 c8fdad2dc6e6
equal deleted inserted replaced
20712:b3cd1233167f 20713:823967ef47f1
   189   undefined
   189   undefined
   190 
   190 
   191 
   191 
   192 subsubsection {* Generic algebraic operations *}
   192 subsubsection {* Generic algebraic operations *}
   193 
   193 
   194 axclass zero \<subseteq> type
   194 class zero =
   195 axclass one \<subseteq> type
   195   fixes zero :: "'a"                       ("\<^loc>0")
       
   196 
       
   197 class one =
       
   198   fixes one  :: "'a"                       ("\<^loc>1")
       
   199 
       
   200 hide (open) const zero one
   196 
   201 
   197 class plus =
   202 class plus =
   198   fixes plus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>+" 65)
   203   fixes plus :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"   (infixl "\<^loc>+" 65)
   199 
   204 
   200 class minus =
   205 class minus =
   201   fixes uminus :: "'a \<Rightarrow> 'a" 
   206   fixes uminus :: "'a \<Rightarrow> 'a" 
   202   fixes minus  :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>-" 65)
   207   fixes minus  :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>-" 65)
   203   fixes abs    :: "'a \<Rightarrow> 'a"
   208   fixes abs    :: "'a \<Rightarrow> 'a"
   204 
   209 
   205 class times =
   210 class times =
   206   fixes times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>*" 70)
   211   fixes times :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixl "\<^loc>*" 70)
   207 
   212 
   208 class inverse = 
   213 class inverse = 
   209   fixes inverse :: "'a \<Rightarrow> 'a"
   214   fixes inverse :: "'a \<Rightarrow> 'a"
   210   fixes divide :: "'a \<Rightarrow> 'a => 'a" (infixl "\<^loc>'/" 70)
   215   fixes divide :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixl "\<^loc>'/" 70)
   211 
       
   212 global
       
   213 
       
   214 consts
       
   215   "0"           :: "'a::zero"                       ("0")
       
   216   "1"           :: "'a::one"                        ("1")
       
   217 
   216 
   218 syntax
   217 syntax
   219   "_index1"  :: index    ("\<^sub>1")
   218   "_index1"  :: index    ("\<^sub>1")
   220 translations
   219 translations
   221   (index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>"
   220   (index) "\<^sub>1" => (index) "\<^bsub>\<struct>\<^esub>"
   222 
   221 
   223 local
       
   224 
       
   225 typed_print_translation {*
   222 typed_print_translation {*
   226   let
   223 let
   227     fun tr' c = (c, fn show_sorts => fn T => fn ts =>
   224   fun tr' c = (c, fn show_sorts => fn T => fn ts =>
   228       if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
   225     if T = dummyT orelse not (! show_types) andalso can Term.dest_Type T then raise Match
   229       else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
   226     else Syntax.const Syntax.constrainC $ Syntax.const c $ Syntax.term_of_typ show_sorts T);
   230   in [tr' "0", tr' "1"] end;
   227 in
       
   228   map (tr' o prefix Syntax.constN) ["HOL.one", "HOL.zero"]
       
   229 end;
   231 *} -- {* show types that are presumably too general *}
   230 *} -- {* show types that are presumably too general *}
   232 
   231 
   233 syntax
   232 syntax
   234   uminus :: "'a\<Colon>minus \<Rightarrow> 'a" ("- _" [81] 80)
   233   uminus :: "'a\<Colon>minus \<Rightarrow> 'a" ("- _" [81] 80)
   235 
   234 
  1355 
  1354 
  1356 lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
  1355 lemmas induct_conj = induct_forall_conj induct_implies_conj induct_conj_curry
  1357 
  1356 
  1358 hide const induct_forall induct_implies induct_equal induct_conj
  1357 hide const induct_forall induct_implies induct_equal induct_conj
  1359 
  1358 
  1360 
       
  1361 text {* Method setup. *}
  1359 text {* Method setup. *}
  1362 
  1360 
  1363 ML {*
  1361 ML {*
  1364   structure InductMethod = InductMethodFun
  1362   structure InductMethod = InductMethodFun
  1365   (struct
  1363   (struct