First the user loads arithmeticTheory to augment the built-in
grammar with the ability to lex numerals and deal with symbols such as
+ and -:
- load "arithmeticTheory";
> val it = () : unit
- val t = Term`2 + 3`;
> val t = `2 + 3` : term
Then the parse_from_grammars function is used to make the
values Type and Term use the grammar present in the simpler theory
of booleans. Using this function fails to parse numerals or even the
+ infix:
- val (Type,Term) = parse_from_grammars boolTheory.bool_grammars;
> val Type = fn : hol_type frag list -> hol_type
val Term = fn : term frag list -> term
- Term`2 + 3`;
<<HOL message: No numerals currently allowed.>>
! Uncaught exception:
! HOL_ERR <poly>
- Term`x + y`;
<<HOL message: inventing new type variable names: 'a, 'b.>>
> val it = `x $+ y` : term
But, as the last example above also demonstrates, the installed
pretty-printer is still dependent on the global grammar, and the
global value of Term can still be accessed through the Parse
structure:
- t;
> val it = `2 + 3` : term
- Parse.Term`2 + 3`;
> val it = `2 + 3` : term