src/HOL/Integ/IntDef.thy
changeset 19601 299d4cd2ef51
parent 19535 e4fdeb32eadf
child 19656 09be06943252
equal deleted inserted replaced
19600:2d969d9a233b 19601:299d4cd2ef51
   888   by (auto simp add: nat_aux_def nat_eq_iff linorder_not_le order_less_imp_le
   888   by (auto simp add: nat_aux_def nat_eq_iff linorder_not_le order_less_imp_le
   889     dest: zless_imp_add1_zle)
   889     dest: zless_imp_add1_zle)
   890 lemma [code]: "nat i = nat_aux 0 i"
   890 lemma [code]: "nat i = nat_aux 0 i"
   891   by (simp add: nat_aux_def)
   891   by (simp add: nat_aux_def)
   892 
   892 
       
   893 lemma [code unfolt]:
       
   894   "neg k = (k < 0)"
       
   895   unfolding neg_def ..
       
   896 
   893 consts_code
   897 consts_code
   894   "0" :: "int"                       ("0")
   898   "0" :: "int"                       ("0")
   895   "1" :: "int"                       ("1")
   899   "1" :: "int"                       ("1")
   896   "HOL.uminus" :: "int => int"       ("~")
   900   "HOL.uminus" :: "int => int"       ("~")
   897   "HOL.plus" :: "int => int => int"  ("(_ +/ _)")
   901   "HOL.plus" :: "int => int => int"  ("(_ +/ _)")
   906 
   910 
   907 code_syntax_const
   911 code_syntax_const
   908   "0 :: int"
   912   "0 :: int"
   909     ml (target_atom "(0:IntInf.int)")
   913     ml (target_atom "(0:IntInf.int)")
   910     haskell (target_atom "0")
   914     haskell (target_atom "0")
   911   "1 :: int"
       
   912     ml (target_atom "(1:IntInf.int)")
       
   913     haskell (target_atom "1")
       
   914   "op + :: int \<Rightarrow> int \<Rightarrow> int"
   915   "op + :: int \<Rightarrow> int \<Rightarrow> int"
   915     ml (infixl 8 "+")
   916     ml (infixl 8 "+")
   916     haskell (infixl 6 "+")
   917     haskell (infixl 6 "+")
   917   "op * :: int \<Rightarrow> int \<Rightarrow> int"
   918   "op * :: int \<Rightarrow> int \<Rightarrow> int"
   918     ml (infixl 9 "*")
   919     ml (infixl 9 "*")
   927     ml (infix 6 "<")
   928     ml (infix 6 "<")
   928     haskell (infix 4 "<")
   929     haskell (infix 4 "<")
   929   "op <= :: int \<Rightarrow> int \<Rightarrow> bool"
   930   "op <= :: int \<Rightarrow> int \<Rightarrow> bool"
   930     ml (infix 6 "<=")
   931     ml (infix 6 "<=")
   931     haskell (infix 4 "<=")
   932     haskell (infix 4 "<=")
   932   "neg :: int \<Rightarrow> bool"
       
   933     ml ("_/ </ 0")
       
   934     haskell ("_/ </ 0")
       
   935 
   933 
   936 ML {*
   934 ML {*
   937 fun mk_int_to_nat bin =
   935 fun mk_int_to_nat bin =
   938   Const ("IntDef.nat", HOLogic.intT --> HOLogic.natT)
   936   Const ("IntDef.nat", HOLogic.intT --> HOLogic.natT)
   939   $ (Const ("Numeral.number_of", HOLogic.binT --> HOLogic.intT) $ bin);
   937   $ (Const ("Numeral.number_of", HOLogic.binT --> HOLogic.intT) $ bin);
   954   | number_of_codegen _ _ _ _ _ _ _ = NONE;
   952   | number_of_codegen _ _ _ _ _ _ _ = NONE;
   955 
   953 
   956 *}
   954 *}
   957 
   955 
   958 setup {*
   956 setup {*
   959   Codegen.add_codegen "number_of_codegen" number_of_codegen #>
   957   Codegen.add_codegen "number_of_codegen" number_of_codegen
   960   CodegenPackage.add_appconst
   958   #> CodegenPackage.add_appconst
   961     ("Numeral.number_of", ((1, 1), CodegenPackage.appgen_number_of mk_int_to_nat bin_to_int "IntDef.int" "nat")) #>
   959        ("Numeral.number_of", ((1, 1),
   962   CodegenPackage.set_int_tyco "IntDef.int"
   960           CodegenPackage.appgen_number_of bin_to_int))
       
   961   #> CodegenPackage.set_int_tyco "IntDef.int"
   963 *}
   962 *}
   964 
   963 
   965 quickcheck_params [default_type = int]
   964 quickcheck_params [default_type = int]
   966 
   965 
   967 
   966