theory Scratch imports Main begin ML \ fun mark_term (Const (c, T)) = Const (Lexicon.mark_const c, T) | mark_term (Free (x, T)) = Const (Lexicon.mark_fixed x, T) | mark_term (t $ u) = mark_term t $ mark_term u | mark_term (Abs (x, T, b)) = Abs (x, T, mark_term b) | mark_term a = a; \ syntax "_Tag" :: "logic" ("\<^tag>") parse_translation \ [(\<^syntax_const>\_Tag\, fn ctxt => fn _ => mark_term (Syntax.read_term ctxt "hd"))] \ definition hd where "hd = 1" term hd \ \\Scratch.hd\\ term \\<^tag>\ \ \\Scratch.hd\\ term \\hd. \<^tag>\ \ \\\hda. Scratch.hd\\ experiment begin definition hd where "hd = 1" term hd \ \\local.hd\\ term \\<^tag>\ \ \\local.hd\\ term \\hdd. \<^tag>\ \ \\\hda. local.hd\\ end end