1 (* Title: HOL/Library/Code_Integer.thy
3 Author: Florian Haftmann, TU Muenchen
6 header {* Pretty integer literals for code generation *}
13 HOL numeral expressions are mapped to integer literals
14 in target languages, using predefined target language
15 operations for abstract integer operations.
20 (OCaml "Big'_int.big'_int")
23 code_instance int :: eq
27 fold (Numeral.add_code @{const_name number_int_inst.number_of_int}
28 true true) ["SML", "OCaml", "Haskell"]
31 code_const "Int.Pls" and "Int.Min" and "Int.Bit"
32 (SML "raise/ Fail/ \"Pls\""
33 and "raise/ Fail/ \"Min\""
34 and "!((_);/ (_);/ raise/ Fail/ \"Bit\")")
35 (OCaml "failwith/ \"Pls\""
36 and "failwith/ \"Min\""
37 and "!((_);/ (_);/ failwith/ \"Bit\")")
38 (Haskell "error/ \"Pls\""
43 (SML "IntInf.- ((_), 1)")
44 (OCaml "Big'_int.pred'_big'_int")
45 (Haskell "!(_/ -/ 1)")
48 (SML "IntInf.+ ((_), 1)")
49 (OCaml "Big'_int.succ'_big'_int")
50 (Haskell "!(_/ +/ 1)")
52 code_const "op + \<Colon> int \<Rightarrow> int \<Rightarrow> int"
53 (SML "IntInf.+ ((_), (_))")
54 (OCaml "Big'_int.add'_big'_int")
55 (Haskell infixl 6 "+")
57 code_const "uminus \<Colon> int \<Rightarrow> int"
59 (OCaml "Big'_int.minus'_big'_int")
62 code_const "op - \<Colon> int \<Rightarrow> int \<Rightarrow> int"
63 (SML "IntInf.- ((_), (_))")
64 (OCaml "Big'_int.sub'_big'_int")
65 (Haskell infixl 6 "-")
67 code_const "op * \<Colon> int \<Rightarrow> int \<Rightarrow> int"
68 (SML "IntInf.* ((_), (_))")
69 (OCaml "Big'_int.mult'_big'_int")
70 (Haskell infixl 7 "*")
72 code_const "op = \<Colon> int \<Rightarrow> int \<Rightarrow> bool"
73 (SML "!((_ : IntInf.int) = _)")
74 (OCaml "Big'_int.eq'_big'_int")
75 (Haskell infixl 4 "==")
77 code_const "op \<le> \<Colon> int \<Rightarrow> int \<Rightarrow> bool"
78 (SML "IntInf.<= ((_), (_))")
79 (OCaml "Big'_int.le'_big'_int")
80 (Haskell infix 4 "<=")
82 code_const "op < \<Colon> int \<Rightarrow> int \<Rightarrow> bool"
83 (SML "IntInf.< ((_), (_))")
84 (OCaml "Big'_int.lt'_big'_int")
87 code_reserved SML IntInf
88 code_reserved OCaml Big_int