Added specific code generator for number_of.
--- a/src/HOL/Integ/NatBin.thy Thu Feb 26 17:08:23 2004 +0100
+++ b/src/HOL/Integ/NatBin.thy Sun Feb 29 23:05:48 2004 +0100
@@ -841,4 +841,19 @@
"op <=" :: "int => int => bool" ("(_ <=/ _)")
"neg" ("(_ < 0)")
+ML {*
+fun number_of_codegen thy gr s b (Const ("Numeral.number_of",
+ Type ("fun", [_, Type ("IntDef.int", [])])) $ bin) =
+ (Some (gr, Pretty.str (string_of_int (HOLogic.dest_binum bin)))
+ handle TERM _ => None)
+ | number_of_codegen thy gr s b (Const ("Numeral.number_of",
+ Type ("fun", [_, Type ("nat", [])])) $ bin) =
+ Some (Codegen.invoke_codegen thy s b (gr,
+ Const ("IntDef.nat", HOLogic.intT --> HOLogic.natT) $
+ (Const ("Numeral.number_of", HOLogic.binT --> HOLogic.intT) $ bin)))
+ | number_of_codegen _ _ _ _ _ = None;
+*}
+
+setup {* [Codegen.add_codegen "number_of_codegen" number_of_codegen] *}
+
end