diff -r b80c4a5cd018 -r db6bedfba498 src/HOL/Integ/IntDef.thy --- a/src/HOL/Integ/IntDef.thy Tue Sep 19 15:21:55 2006 +0200 +++ b/src/HOL/Integ/IntDef.thy Tue Sep 19 15:21:58 2006 +0200 @@ -264,7 +264,7 @@ by (cases w, cases z, simp add: le) (* Axiom 'order_less_le' of class 'order': *) -lemma zless_le: "((w::int) < z) = (w \ z & w \ z)" +lemma zless_le [code func]: "((w::int) < z) = (w \ z & w \ z)" by (simp add: less_int_def) instance int :: order @@ -869,11 +869,11 @@ fun gen_int i = one_of [~1, 1] * random_range 0 i; *} -constdefs +definition int_aux :: "int \ nat \ int" - "int_aux i n == (i + int n)" + "int_aux i n = (i + int n)" nat_aux :: "nat \ int \ nat" - "nat_aux n i == (n + nat i)" + "nat_aux n i = (n + nat i)" lemma [code]: "int_aux i 0 = i" @@ -892,6 +892,10 @@ "neg k = (k < 0)" unfolding neg_def .. +lemma [code func]: + "\k\int\ = (if k \ 0 then - k else k)" + unfolding zabs_def by auto + consts_code "0" :: "int" ("0") "1" :: "int" ("1") @@ -902,30 +906,43 @@ "Orderings.less_eq" :: "int => int => bool" ("(_ <=/ _)") "neg" ("(_ < 0)") +instance int :: eq .. + code_type int (SML target_atom "IntInf.int") (Haskell target_atom "Integer") -code_const "op + :: int \ int \ int" +code_instance int :: eq + (Haskell -) + +code_const "OperationalEquality.eq \ int \ int \ bool" + (SML "(op =) (_ : IntInf.int, _)") + (Haskell infixl 4 "==") + +code_const "op <= \ int \ int \ bool" + (SML "IntInf.<= (_, _)") + (Haskell infix 4 "<=") + +code_const "op < \ int \ int \ bool" + (SML "IntInf.< (_, _)") + (Haskell infix 4 "<") + +code_const "op + \ int \ int \ int" (SML "IntInf.+ (_, _)") (Haskell infixl 6 "+") -code_const "op * :: int \ int \ int" +code_const "op - \ int \ int \ int" + (SML "IntInf.- (_, _)") + (Haskell infixl 6 "-") + +code_const "op * \ int \ int \ int" (SML "IntInf.* (_, _)") (Haskell infixl 7 "*") -code_const "uminus :: int \ int" +code_const "uminus \ int \ int" (SML target_atom "IntInf.~") (Haskell target_atom "negate") -code_const "op = :: int \ int \ bool" - (SML "(op =) (_ : IntInf.int, _)") - (Haskell infixl 4 "==") - -code_const "op <= :: int \ int \ bool" - (SML "IntInf.<= (_, _)") - (Haskell infix 4 "<=") - ML {* fun number_of_codegen thy defs gr dep module b (Const ("Numeral.number_of", Type ("fun", [_, T as Type ("IntDef.int", [])])) $ bin) =