Parse.add_numeral_form : (char * string option) -> unit
A call to add_numeral_form(c,s) augments the global term grammar in two ways. Firstly, in common with the function add_bare_numeral_form (q.v.), it allows the user to write a single letter suffix after a numeral (the argument c). The presence of this character specifies s as the “injection function” which is to be applied to the natural number denoted by the preceding digits.
Secondly, the constant denoted by the s argument is overloaded to be one of the possible resolutions of an internal, overloaded operator, which is invisibly wrapped around all numerals that appear without a character suffix. After applying add_numeral_form, the function denoted by the argument s is now a possible resolution of this overloading, so numerals can now be seen as members of the range of the type of s.
Finally, if s is not NONE, the constant denoted by s is overloaded to be one of the possible resolutions of the string &. This operator is thus the standard way of writing the injection function from :num into other numeric types.
The injection function specifed by argument s is either the constant with name s0, if s is of the form SOME s0, or the identity function if s is NONE. Using add_numeral_form with NONE for this parameter is done in the development of arithmeticTheory, and should not be done subsequently.
val _ = add_numeral_form (#"n", NONE);
val _ = add_numeral_form(#"i", SOME "int_of_num");
- load "integerTheory"; > val it = () : unit - Term`3`; <<HOL message: more than one resolution of overloading was possible.>> > val it = `3` : term - type_of it; > val it = `:int` : hol_type
- Term`(SUC 3, 4 + ~x)`; > val it = `(SUC 3,4 + ~x)` : term - type_of it; > val it = `:num # int` : hol_type
- Term`f 3 /\ p`; <<HOL message: more than one resolution of overloading was possible.>> > val it = `f 3 /\ p` : term - Term`f 3n /\ p`; > val it = `f 3 /\ p` : term