| author | wenzelm | 
| Fri, 23 Dec 2022 22:51:47 +0100 | |
| changeset 76767 | 540cd80c5af2 | 
| parent 74448 | 2fd74a2c4e1c | 
| child 81202 | 243f6bec771c | 
| permissions | -rw-r--r-- | 
| 42284 | 1 | (* Title: Pure/Syntax/syntax_trans.ML | 
| 548 | 2 | Author: Tobias Nipkow and Markus Wenzel, TU Muenchen | 
| 3 | ||
| 4 | Syntax translation functions. | |
| 5 | *) | |
| 6 | ||
| 42284 | 7 | signature BASIC_SYNTAX_TRANS = | 
| 8 | sig | |
| 9 | val eta_contract: bool Config.T | |
| 10 | end | |
| 11 | ||
| 12 | signature SYNTAX_TRANS = | |
| 2698 | 13 | sig | 
| 42284 | 14 | include BASIC_SYNTAX_TRANS | 
| 45057 
86c9b73158a8
default print mode for Isabelle/Scala, not just Isabelle/jEdit;
 wenzelm parents: 
44433diff
changeset | 15 | val bracketsN: string | 
| 
86c9b73158a8
default print mode for Isabelle/Scala, not just Isabelle/jEdit;
 wenzelm parents: 
44433diff
changeset | 16 | val no_bracketsN: string | 
| 42284 | 17 | val no_brackets: unit -> bool | 
| 45057 
86c9b73158a8
default print mode for Isabelle/Scala, not just Isabelle/jEdit;
 wenzelm parents: 
44433diff
changeset | 18 | val type_bracketsN: string | 
| 
86c9b73158a8
default print mode for Isabelle/Scala, not just Isabelle/jEdit;
 wenzelm parents: 
44433diff
changeset | 19 | val no_type_bracketsN: string | 
| 42284 | 20 | val no_type_brackets: unit -> bool | 
| 21 | val abs_tr: term list -> term | |
| 52143 | 22 | val mk_binder_tr: string * string -> string * (Proof.context -> term list -> term) | 
| 42284 | 23 | val antiquote_tr: string -> term -> term | 
| 24 | val quote_tr: string -> term -> term | |
| 52143 | 25 | val quote_antiquote_tr: string -> string -> string -> | 
| 26 | string * (Proof.context -> term list -> term) | |
| 27 | val non_typed_tr': (Proof.context -> term list -> term) -> | |
| 28 | Proof.context -> typ -> term list -> term | |
| 42284 | 29 | val tappl_ast_tr': Ast.ast * Ast.ast list -> Ast.ast | 
| 30 | val appl_ast_tr': Ast.ast * Ast.ast list -> Ast.ast | |
| 31 | val applC_ast_tr': Ast.ast * Ast.ast list -> Ast.ast | |
| 49660 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 32 | val mark_bound_abs: string * typ -> term | 
| 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 33 | val mark_bound_body: string * typ -> term | 
| 42284 | 34 | val bound_vars: (string * typ) list -> term -> term | 
| 35 | val abs_tr': Proof.context -> term -> term | |
| 13762 | 36 | val atomic_abs_tr': string * typ * term -> term * term | 
| 42086 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 37 | val const_abs_tr': term -> term | 
| 52143 | 38 | val mk_binder_tr': string * string -> string * (Proof.context -> term list -> term) | 
| 39 | val preserve_binder_abs_tr': string -> string -> string * (Proof.context -> term list -> term) | |
| 40 | val preserve_binder_abs2_tr': string -> string -> string * (Proof.context -> term list -> term) | |
| 74448 | 41 | val print_abs: string * typ * term -> string * term | 
| 548 | 42 | val dependent_tr': string * string -> term list -> term | 
| 8577 | 43 | val antiquote_tr': string -> term -> term | 
| 44 | val quote_tr': string -> term -> term | |
| 52143 | 45 | val quote_antiquote_tr': string -> string -> string -> | 
| 46 | string * (Proof.context -> term list -> term) | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 47 | val update_name_tr': term -> term | 
| 59152 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 48 |   val get_idents: Proof.context -> {structs: string list, fixes: string list}
 | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 49 |   val put_idents: {structs: string list, fixes: string list} -> Proof.context -> Proof.context
 | 
| 52143 | 50 | val pure_parse_ast_translation: (string * (Proof.context -> Ast.ast list -> Ast.ast)) list | 
| 51 | val pure_parse_translation: (string * (Proof.context -> term list -> term)) list | |
| 52 | val pure_print_ast_translation: (string * (Proof.context -> Ast.ast list -> Ast.ast)) list | |
| 2698 | 53 | end; | 
| 548 | 54 | |
| 42284 | 55 | structure Syntax_Trans: SYNTAX_TRANS = | 
| 548 | 56 | struct | 
| 2698 | 57 | |
| 42476 | 58 | structure Syntax = Lexicon.Syntax; | 
| 59 | ||
| 60 | ||
| 42262 | 61 | (* print mode *) | 
| 62 | ||
| 63 | val bracketsN = "brackets"; | |
| 64 | val no_bracketsN = "no_brackets"; | |
| 65 | ||
| 66 | fun no_brackets () = | |
| 67 | find_first (fn mode => mode = bracketsN orelse mode = no_bracketsN) | |
| 68 | (print_mode_value ()) = SOME no_bracketsN; | |
| 69 | ||
| 70 | val type_bracketsN = "type_brackets"; | |
| 71 | val no_type_bracketsN = "no_type_brackets"; | |
| 72 | ||
| 73 | fun no_type_brackets () = | |
| 74 | find_first (fn mode => mode = type_bracketsN orelse mode = no_type_bracketsN) | |
| 75 | (print_mode_value ()) <> SOME type_bracketsN; | |
| 76 | ||
| 77 | ||
| 2698 | 78 | |
| 548 | 79 | (** parse (ast) translations **) | 
| 80 | ||
| 42057 
3eba96ff3d3e
more selective strip_positions in case patterns -- reactivate translations based on "case _ of _" in HOL and special patterns in HOLCF;
 wenzelm parents: 
42055diff
changeset | 81 | (* strip_positions *) | 
| 
3eba96ff3d3e
more selective strip_positions in case patterns -- reactivate translations based on "case _ of _" in HOL and special patterns in HOLCF;
 wenzelm parents: 
42055diff
changeset | 82 | |
| 42264 | 83 | fun strip_positions_ast_tr [ast] = Ast.strip_positions ast | 
| 42057 
3eba96ff3d3e
more selective strip_positions in case patterns -- reactivate translations based on "case _ of _" in HOL and special patterns in HOLCF;
 wenzelm parents: 
42055diff
changeset | 84 |   | strip_positions_ast_tr asts = raise Ast.AST ("strip_positions_ast_tr", asts);
 | 
| 
3eba96ff3d3e
more selective strip_positions in case patterns -- reactivate translations based on "case _ of _" in HOL and special patterns in HOLCF;
 wenzelm parents: 
42055diff
changeset | 85 | |
| 
3eba96ff3d3e
more selective strip_positions in case patterns -- reactivate translations based on "case _ of _" in HOL and special patterns in HOLCF;
 wenzelm parents: 
42055diff
changeset | 86 | |
| 11491 | 87 | (* constify *) | 
| 88 | ||
| 46236 
ae79f2978a67
position constraints for numerals enable PIDE markup;
 wenzelm parents: 
45389diff
changeset | 89 | fun constify_ast_tr [Ast.Appl [c as Ast.Constant "_constrain", ast1, ast2]] = | 
| 
ae79f2978a67
position constraints for numerals enable PIDE markup;
 wenzelm parents: 
45389diff
changeset | 90 | Ast.Appl [c, constify_ast_tr [ast1], ast2] | 
| 
ae79f2978a67
position constraints for numerals enable PIDE markup;
 wenzelm parents: 
45389diff
changeset | 91 | | constify_ast_tr [Ast.Variable c] = Ast.Constant c | 
| 11491 | 92 |   | constify_ast_tr asts = raise Ast.AST ("constify_ast_tr", asts);
 | 
| 93 | ||
| 94 | ||
| 42262 | 95 | (* type syntax *) | 
| 96 | ||
| 97 | fun tapp_ast_tr [ty, c] = Ast.Appl [c, ty] | |
| 98 |   | tapp_ast_tr asts = raise Ast.AST ("tapp_ast_tr", asts);
 | |
| 99 | ||
| 100 | fun tappl_ast_tr [ty, tys, c] = Ast.mk_appl c (ty :: Ast.unfold_ast "_types" tys) | |
| 101 |   | tappl_ast_tr asts = raise Ast.AST ("tappl_ast_tr", asts);
 | |
| 102 | ||
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 103 | fun bracket_ast_tr [dom, cod] = Ast.fold_ast_p "\<^type>fun" (Ast.unfold_ast "_types" dom, cod) | 
| 42262 | 104 |   | bracket_ast_tr asts = raise Ast.AST ("bracket_ast_tr", asts);
 | 
| 105 | ||
| 106 | ||
| 548 | 107 | (* application *) | 
| 108 | ||
| 5690 | 109 | fun appl_ast_tr [f, args] = Ast.Appl (f :: Ast.unfold_ast "_args" args) | 
| 110 |   | appl_ast_tr asts = raise Ast.AST ("appl_ast_tr", asts);
 | |
| 922 
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
 clasohm parents: 
639diff
changeset | 111 | |
| 5690 | 112 | fun applC_ast_tr [f, args] = Ast.Appl (f :: Ast.unfold_ast "_cargs" args) | 
| 113 |   | applC_ast_tr asts = raise Ast.AST ("applC_ast_tr", asts);
 | |
| 548 | 114 | |
| 115 | ||
| 116 | (* abstraction *) | |
| 117 | ||
| 42278 | 118 | fun idtyp_ast_tr [x, ty] = Ast.Appl [Ast.Constant "_constrain", x, ty] | 
| 119 |   | idtyp_ast_tr asts = raise Ast.AST ("idtyp_ast_tr", asts);
 | |
| 548 | 120 | |
| 42278 | 121 | fun lambda_ast_tr [pats, body] = Ast.fold_ast_p "_abs" (Ast.unfold_ast "_pttrns" pats, body) | 
| 122 |   | lambda_ast_tr asts = raise Ast.AST ("lambda_ast_tr", asts);
 | |
| 548 | 123 | |
| 44241 | 124 | fun absfree_proper (x, T) t = | 
| 55948 | 125 | if Name.is_internal x | 
| 42048 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 126 |   then error ("Illegal internal variable in abstraction: " ^ quote x)
 | 
| 44241 | 127 | else absfree (x, T) t; | 
| 21773 | 128 | |
| 44241 | 129 | fun abs_tr [Free x, t] = absfree_proper x t | 
| 130 |   | abs_tr [Const ("_idtdummy", T), t] = absdummy T t
 | |
| 74442 | 131 |   | abs_tr [Const ("_constrain", _) $ x $ tT, t] = Syntax.const "_constrainAbs" $ abs_tr [x, t] $ tT
 | 
| 42048 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 132 |   | abs_tr ts = raise TERM ("abs_tr", ts);
 | 
| 548 | 133 | |
| 134 | ||
| 135 | (* binder *) | |
| 136 | ||
| 21535 | 137 | fun mk_binder_tr (syn, name) = | 
| 548 | 138 | let | 
| 42055 | 139 |     fun err ts = raise TERM ("binder_tr: " ^ syn, ts)
 | 
| 42048 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 140 |     fun binder_tr [Const ("_idts", _) $ idt $ idts, t] = binder_tr [idt, binder_tr [idts, t]]
 | 
| 74442 | 141 | | binder_tr [x, t] = Syntax.const name $ (abs_tr [x, t] handle TERM _ => err [x, t]) | 
| 42055 | 142 | | binder_tr ts = err ts; | 
| 52143 | 143 | in (syn, fn _ => binder_tr) end; | 
| 548 | 144 | |
| 145 | ||
| 28628 | 146 | (* type propositions *) | 
| 147 | ||
| 35255 | 148 | fun mk_type ty = | 
| 42476 | 149 | Syntax.const "_constrain" $ | 
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 150 | Syntax.const "\<^const>Pure.type" $ (Syntax.const "\<^type>itself" $ ty); | 
| 28628 | 151 | |
| 42278 | 152 | fun ofclass_tr [ty, cls] = cls $ mk_type ty | 
| 153 |   | ofclass_tr ts = raise TERM ("ofclass_tr", ts);
 | |
| 28628 | 154 | |
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 155 | fun sort_constraint_tr [ty] = Syntax.const "\<^const>Pure.sort_constraint" $ mk_type ty | 
| 42278 | 156 |   | sort_constraint_tr ts = raise TERM ("sort_constraint_tr", ts);
 | 
| 28628 | 157 | |
| 158 | ||
| 548 | 159 | (* meta propositions *) | 
| 160 | ||
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 161 | fun aprop_tr [t] = Syntax.const "_constrain" $ t $ Syntax.const "\<^type>prop" | 
| 42278 | 162 |   | aprop_tr ts = raise TERM ("aprop_tr", ts);
 | 
| 548 | 163 | |
| 164 | ||
| 165 | (* meta implication *) | |
| 166 | ||
| 42278 | 167 | fun bigimpl_ast_tr (asts as [asms, concl]) = | 
| 16612 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 168 | let val prems = | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 169 | (case Ast.unfold_ast_p "_asms" asms of | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 170 | (asms', Ast.Appl [Ast.Constant "_asm", asm']) => asms' @ [asm'] | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 171 |         | _ => raise Ast.AST ("bigimpl_ast_tr", asts))
 | 
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 172 | in Ast.fold_ast_p "\<^const>Pure.imp" (prems, concl) end | 
| 42278 | 173 |   | bigimpl_ast_tr asts = raise Ast.AST ("bigimpl_ast_tr", asts);
 | 
| 15421 
fcf747c0b6b8
Syntax: last premise of "_bigimpl" is wrapped with "_asm", to have a hook for
 schirmer parents: 
14981diff
changeset | 174 | |
| 548 | 175 | |
| 23824 
8ad7131dbfcf
moved print_translations from Pure.thy to Syntax/syn_trans.ML;
 wenzelm parents: 
21773diff
changeset | 176 | (* type/term reflection *) | 
| 4148 | 177 | |
| 42278 | 178 | fun type_tr [ty] = mk_type ty | 
| 179 |   | type_tr ts = raise TERM ("type_tr", ts);
 | |
| 4148 | 180 | |
| 548 | 181 | |
| 5084 | 182 | (* quote / antiquote *) | 
| 183 | ||
| 8577 | 184 | fun antiquote_tr name = | 
| 185 | let | |
| 186 | fun tr i ((t as Const (c, _)) $ u) = | |
| 187 | if c = name then tr i u $ Bound i | |
| 188 | else tr i t $ tr i u | |
| 189 | | tr i (t $ u) = tr i t $ tr i u | |
| 190 | | tr i (Abs (x, T, t)) = Abs (x, T, tr (i + 1) t) | |
| 191 | | tr _ a = a; | |
| 192 | in tr 0 end; | |
| 193 | ||
| 194 | fun quote_tr name t = Abs ("s", dummyT, antiquote_tr name (Term.incr_boundvars 1 t));
 | |
| 195 | ||
| 5084 | 196 | fun quote_antiquote_tr quoteN antiquoteN name = | 
| 197 | let | |
| 42476 | 198 | fun tr [t] = Syntax.const name $ quote_tr antiquoteN t | 
| 8577 | 199 |       | tr ts = raise TERM ("quote_tr", ts);
 | 
| 52143 | 200 | in (quoteN, fn _ => tr) end; | 
| 5084 | 201 | |
| 202 | ||
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 203 | (* corresponding updates *) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 204 | |
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 205 | fun update_name_tr (Free (x, T) :: ts) = list_comb (Free (suffix "_update" x, T), ts) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 206 | | update_name_tr (Const (x, T) :: ts) = list_comb (Const (suffix "_update" x, T), ts) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 207 |   | update_name_tr (((c as Const ("_constrain", _)) $ t $ ty) :: ts) =
 | 
| 42264 | 208 | if Term_Position.is_position ty then list_comb (c $ update_name_tr [t] $ ty, ts) | 
| 42053 
006095137a81
update_name_tr: more precise handling of explicit constraints, including positions;
 wenzelm parents: 
42048diff
changeset | 209 | else | 
| 
006095137a81
update_name_tr: more precise handling of explicit constraints, including positions;
 wenzelm parents: 
42048diff
changeset | 210 | list_comb (c $ update_name_tr [t] $ | 
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 211 | (Lexicon.fun_type $ | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 212 | (Lexicon.fun_type $ Lexicon.dummy_type $ ty) $ Lexicon.dummy_type), ts) | 
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 213 |   | update_name_tr ts = raise TERM ("update_name_tr", ts);
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 214 | |
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 215 | |
| 14697 | 216 | (* indexed syntax *) | 
| 217 | ||
| 59152 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 218 | structure Idents = Proof_Data | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 219 | ( | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 220 |   type T = {structs: string list, fixes: string list};
 | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 221 |   fun init _ : T = {structs = [], fixes = []};
 | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 222 | ); | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 223 | |
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 224 | val get_idents = Idents.get; | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 225 | val put_idents = Idents.put; | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 226 | |
| 45389 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 227 | fun indexdefault_ast_tr [] = | 
| 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 228 | Ast.Appl [Ast.Constant "_index", | 
| 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 229 | Ast.Appl [Ast.Constant "_struct", Ast.Constant "_indexdefault"]] | 
| 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 230 |   | indexdefault_ast_tr asts = raise Ast.AST ("indexdefault_ast_tr", asts);
 | 
| 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 231 | |
| 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 232 | fun indexvar_ast_tr [] = Ast.Appl [Ast.Constant "_index", Ast.Variable "some_index"] | 
| 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 233 |   | indexvar_ast_tr asts = raise Ast.AST ("indexvar_ast_tr", asts);
 | 
| 
bc0d50f8ae19
discontinued numbered structure indexes (legacy feature);
 wenzelm parents: 
45057diff
changeset | 234 | |
| 42278 | 235 | fun struct_ast_tr [Ast.Appl [Ast.Constant "_index", ast]] = ast | 
| 236 | | struct_ast_tr asts = Ast.mk_appl (Ast.Constant "_struct") asts; | |
| 14697 | 237 | |
| 42278 | 238 | fun index_tr [t] = t | 
| 239 |   | index_tr ts = raise TERM ("index_tr", ts);
 | |
| 14697 | 240 | |
| 59152 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 241 | fun struct_tr ctxt [Const ("_indexdefault", _)] =
 | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 242 | (case #structs (get_idents ctxt) of | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 243 | x :: _ => Syntax.const (Lexicon.mark_fixed x) | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 244 | | _ => error "Illegal reference to implicit structure") | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 245 |   | struct_tr _ ts = raise TERM ("struct_tr", ts);
 | 
| 12122 | 246 | |
| 247 | ||
| 5084 | 248 | |
| 548 | 249 | (** print (ast) translations **) | 
| 250 | ||
| 14647 | 251 | (* types *) | 
| 252 | ||
| 52143 | 253 | fun non_typed_tr' f ctxt _ ts = f ctxt ts; | 
| 14647 | 254 | |
| 255 | ||
| 42262 | 256 | (* type syntax *) | 
| 257 | ||
| 258 | fun tappl_ast_tr' (f, []) = raise Ast.AST ("tappl_ast_tr'", [f])
 | |
| 259 | | tappl_ast_tr' (f, [ty]) = Ast.Appl [Ast.Constant "_tapp", ty, f] | |
| 260 | | tappl_ast_tr' (f, ty :: tys) = | |
| 261 | Ast.Appl [Ast.Constant "_tappl", ty, Ast.fold_ast "_types" tys, f]; | |
| 262 | ||
| 263 | fun fun_ast_tr' asts = | |
| 264 | if no_brackets () orelse no_type_brackets () then raise Match | |
| 265 | else | |
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 266 | (case Ast.unfold_ast_p "\<^type>fun" (Ast.Appl (Ast.Constant "\<^type>fun" :: asts)) of | 
| 42262 | 267 | (dom as _ :: _ :: _, cod) | 
| 268 | => Ast.Appl [Ast.Constant "_bracket", Ast.fold_ast "_types" dom, cod] | |
| 269 | | _ => raise Match); | |
| 270 | ||
| 271 | ||
| 548 | 272 | (* application *) | 
| 273 | ||
| 5690 | 274 | fun appl_ast_tr' (f, []) = raise Ast.AST ("appl_ast_tr'", [f])
 | 
| 275 | | appl_ast_tr' (f, args) = Ast.Appl [Ast.Constant "_appl", f, Ast.fold_ast "_args" args]; | |
| 548 | 276 | |
| 5690 | 277 | fun applC_ast_tr' (f, []) = raise Ast.AST ("applC_ast_tr'", [f])
 | 
| 278 | | applC_ast_tr' (f, args) = Ast.Appl [Ast.Constant "_applC", f, Ast.fold_ast "_cargs" args]; | |
| 922 
196ca0973a6d
added CPure (curried functions) and ProtoPure (ancestor of Pure and CPure)
 clasohm parents: 
639diff
changeset | 279 | |
| 548 | 280 | |
| 42085 | 281 | (* partial eta-contraction before printing *) | 
| 282 | ||
| 283 | fun eta_abs (Abs (a, T, t)) = | |
| 284 | (case eta_abs t of | |
| 285 |         t' as Const ("_aprop", _) $ _ => Abs (a, T, t')
 | |
| 286 | | t' as f $ u => | |
| 287 | (case eta_abs u of | |
| 288 | Bound 0 => | |
| 289 | if Term.is_dependent f then Abs (a, T, t') | |
| 290 | else incr_boundvars ~1 f | |
| 291 | | _ => Abs (a, T, t')) | |
| 292 | | t' => Abs (a, T, t')) | |
| 293 | | eta_abs t = t; | |
| 294 | ||
| 69575 | 295 | val eta_contract = Config.declare_option_bool ("eta_contract", \<^here>);
 | 
| 69577 | 296 | fun eta_contr ctxt = Config.get ctxt eta_contract ? eta_abs; | 
| 42085 | 297 | |
| 298 | ||
| 548 | 299 | (* abstraction *) | 
| 300 | ||
| 49660 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 301 | fun mark_bound_abs (x, T) = Const ("_bound", T --> T) $ Free (x, T);
 | 
| 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 302 | fun mark_bound_body (x, T) = Const ("_bound", dummyT) $ Free (x, T);
 | 
| 2698 | 303 | |
| 18958 | 304 | fun bound_vars vars body = | 
| 49660 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 305 | subst_bounds (map mark_bound_abs (Term.rename_wrt_term body vars), body); | 
| 18958 | 306 | |
| 548 | 307 | fun strip_abss vars_of body_of tm = | 
| 308 | let | |
| 309 | val vars = vars_of tm; | |
| 310 | val body = body_of tm; | |
| 29276 | 311 | val rev_new_vars = Term.rename_wrt_term body vars; | 
| 21750 | 312 | fun subst (x, T) b = | 
| 55948 | 313 | if Name.is_internal x andalso not (Term.is_dependent b) | 
| 21750 | 314 |       then (Const ("_idtdummy", T), incr_boundvars ~1 b)
 | 
| 49660 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 315 | else (mark_bound_abs (x, T), Term.subst_bound (mark_bound_body (x, T), b)); | 
| 21750 | 316 | val (rev_vars', body') = fold_map subst rev_new_vars body; | 
| 317 | in (rev rev_vars', body') end; | |
| 548 | 318 | |
| 3928 
787d2659ce4a
no longer tries bogus eta-contract involving aprops;
 wenzelm parents: 
3777diff
changeset | 319 | |
| 39128 
93a7365fb4ee
turned eta_contract into proper configuration option;
 wenzelm parents: 
37216diff
changeset | 320 | fun abs_tr' ctxt tm = | 
| 42476 | 321 | uncurry (fold_rev (fn x => fn t => Syntax.const "_abs" $ x $ t)) | 
| 39128 
93a7365fb4ee
turned eta_contract into proper configuration option;
 wenzelm parents: 
37216diff
changeset | 322 | (strip_abss strip_abs_vars strip_abs_body (eta_contr ctxt tm)); | 
| 548 | 323 | |
| 14697 | 324 | fun atomic_abs_tr' (x, T, t) = | 
| 29276 | 325 | let val [xT] = Term.rename_wrt_term t [(x, T)] | 
| 49660 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 326 | in (mark_bound_abs xT, subst_bound (mark_bound_body xT, t)) end; | 
| 13762 | 327 | |
| 42085 | 328 | fun abs_ast_tr' asts = | 
| 5690 | 329 | (case Ast.unfold_ast_p "_abs" (Ast.Appl (Ast.Constant "_abs" :: asts)) of | 
| 330 |     ([], _) => raise Ast.AST ("abs_ast_tr'", asts)
 | |
| 331 | | (xs, body) => Ast.Appl [Ast.Constant "_lambda", Ast.fold_ast "_pttrns" xs, body]); | |
| 548 | 332 | |
| 42086 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 333 | fun const_abs_tr' t = | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 334 | (case eta_abs t of | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 335 | Abs (_, _, t') => | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 336 | if Term.is_dependent t' then raise Match | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 337 | else incr_boundvars ~1 t' | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 338 | | _ => raise Match); | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 339 | |
| 32120 
53a21a5e6889
attempt for more concise setup of non-etacontracting binders
 haftmann parents: 
31542diff
changeset | 340 | |
| 42085 | 341 | (* binders *) | 
| 548 | 342 | |
| 21535 | 343 | fun mk_binder_tr' (name, syn) = | 
| 548 | 344 | let | 
| 345 | fun mk_idts [] = raise Match (*abort translation*) | |
| 346 | | mk_idts [idt] = idt | |
| 42476 | 347 | | mk_idts (idt :: idts) = Syntax.const "_idts" $ idt $ mk_idts idts; | 
| 548 | 348 | |
| 349 | fun tr' t = | |
| 350 | let | |
| 351 | val (xs, bd) = strip_abss (strip_qnt_vars name) (strip_qnt_body name) t; | |
| 42476 | 352 | in Syntax.const syn $ mk_idts xs $ bd end; | 
| 548 | 353 | |
| 42476 | 354 | fun binder_tr' (t :: ts) = Term.list_comb (tr' (Syntax.const name $ t), ts) | 
| 21535 | 355 | | binder_tr' [] = raise Match; | 
| 52143 | 356 | in (name, fn _ => binder_tr') end; | 
| 548 | 357 | |
| 52143 | 358 | fun preserve_binder_abs_tr' name syn = (name, fn _ => fn Abs abs :: ts => | 
| 42085 | 359 | let val (x, t) = atomic_abs_tr' abs | 
| 42476 | 360 | in list_comb (Syntax.const syn $ x $ t, ts) end); | 
| 42085 | 361 | |
| 52143 | 362 | fun preserve_binder_abs2_tr' name syn = (name, fn _ => fn A :: Abs abs :: ts => | 
| 42085 | 363 | let val (x, t) = atomic_abs_tr' abs | 
| 42476 | 364 | in list_comb (Syntax.const syn $ x $ A $ t, ts) end); | 
| 42085 | 365 | |
| 548 | 366 | |
| 3691 
f0396ac63e12
tuned lambda_ast_tr, idtyp_ast_tr' to accomodate fix of idt/idts
 wenzelm parents: 
2698diff
changeset | 367 | (* idtyp constraints *) | 
| 548 | 368 | |
| 42045 | 369 | fun idtyp_ast_tr' a [Ast.Appl [Ast.Constant "_constrain", x, ty], xs] = | 
| 370 | Ast.Appl [Ast.Constant a, Ast.Appl [Ast.Constant "_idtyp", x, ty], xs] | |
| 3691 
f0396ac63e12
tuned lambda_ast_tr, idtyp_ast_tr' to accomodate fix of idt/idts
 wenzelm parents: 
2698diff
changeset | 371 | | idtyp_ast_tr' _ _ = raise Match; | 
| 548 | 372 | |
| 373 | ||
| 374 | (* meta implication *) | |
| 375 | ||
| 42278 | 376 | fun impl_ast_tr' asts = | 
| 42262 | 377 | if no_brackets () then raise Match | 
| 10572 | 378 | else | 
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 379 | (case Ast.unfold_ast_p "\<^const>Pure.imp" | 
| 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 380 | (Ast.Appl (Ast.Constant "\<^const>Pure.imp" :: asts)) of | 
| 16612 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 381 | (prems as _ :: _ :: _, concl) => | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 382 | let | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 383 | val (asms, asm) = split_last prems; | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 384 | val asms' = Ast.fold_ast_p "_asms" (asms, Ast.Appl [Ast.Constant "_asm", asm]); | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 385 | in Ast.Appl [Ast.Constant "_bigimpl", asms', concl] end | 
| 15421 
fcf747c0b6b8
Syntax: last premise of "_bigimpl" is wrapped with "_asm", to have a hook for
 schirmer parents: 
14981diff
changeset | 386 | | _ => raise Match); | 
| 
fcf747c0b6b8
Syntax: last premise of "_bigimpl" is wrapped with "_asm", to have a hook for
 schirmer parents: 
14981diff
changeset | 387 | |
| 548 | 388 | |
| 389 | (* dependent / nondependent quantifiers *) | |
| 390 | ||
| 74448 | 391 | fun print_abs (x, T, b) = | 
| 43326 
47cf4bc789aa
simplified Name.variant -- discontinued builtin fold_map;
 wenzelm parents: 
42476diff
changeset | 392 | let val (x', _) = Name.variant x (Term.declare_term_names b Name.context) | 
| 74448 | 393 | in (x', subst_bound (mark_bound_abs (x', T), b)) end; | 
| 2698 | 394 | |
| 548 | 395 | fun dependent_tr' (q, r) (A :: Abs (x, T, B) :: ts) = | 
| 42083 
e1209fc7ecdc
added Term.is_open and Term.is_dependent convenience, to cover common situations of loose bounds;
 wenzelm parents: 
42080diff
changeset | 396 | if Term.is_dependent B then | 
| 74448 | 397 | let val (x', B') = print_abs (x, dummyT, B); | 
| 49660 
de49d9b4d7bc
more explicit Syntax_Trans.mark_bound_abs/mark_bound_body: preserve type information for show_markup;
 wenzelm parents: 
46236diff
changeset | 398 | in Term.list_comb (Syntax.const q $ mark_bound_abs (x', T) $ A $ B', ts) end | 
| 42476 | 399 | else Term.list_comb (Syntax.const r $ A $ incr_boundvars ~1 B, ts) | 
| 548 | 400 | | dependent_tr' _ _ = raise Match; | 
| 401 | ||
| 402 | ||
| 5084 | 403 | (* quote / antiquote *) | 
| 404 | ||
| 8577 | 405 | fun antiquote_tr' name = | 
| 406 | let | |
| 407 | fun tr' i (t $ u) = | |
| 42476 | 408 | if u aconv Bound i then Syntax.const name $ tr' i t | 
| 42084 
532b3a76103f
dependent_tr': formal treatment of bounds after stripping Abs, although it should only happen for malformed terms, since print_translations work top-down;
 wenzelm parents: 
42083diff
changeset | 409 | else tr' i t $ tr' i u | 
| 8577 | 410 | | tr' i (Abs (x, T, t)) = Abs (x, T, tr' (i + 1) t) | 
| 18139 | 411 | | tr' i a = if a aconv Bound i then raise Match else a; | 
| 8577 | 412 | in tr' 0 end; | 
| 413 | ||
| 414 | fun quote_tr' name (Abs (_, _, t)) = Term.incr_boundvars ~1 (antiquote_tr' name t) | |
| 415 | | quote_tr' _ _ = raise Match; | |
| 416 | ||
| 5084 | 417 | fun quote_antiquote_tr' quoteN antiquoteN name = | 
| 418 | let | |
| 42476 | 419 | fun tr' (t :: ts) = Term.list_comb (Syntax.const quoteN $ quote_tr' antiquoteN t, ts) | 
| 8577 | 420 | | tr' _ = raise Match; | 
| 52143 | 421 | in (name, fn _ => tr') end; | 
| 5084 | 422 | |
| 423 | ||
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 424 | (* corresponding updates *) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 425 | |
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 426 | local | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 427 | |
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 428 | fun upd_type (Type ("fun", [Type ("fun", [_, T]), _])) = T
 | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 429 | | upd_type _ = dummyT; | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 430 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 431 | fun upd_tr' (x_upd, T) = | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 432 | (case try (unsuffix "_update") x_upd of | 
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 433 | SOME x => (x, upd_type T) | 
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 434 | | NONE => raise Match); | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 435 | |
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 436 | in | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 437 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 438 | fun update_name_tr' (Free x) = Free (upd_tr' x) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 439 |   | update_name_tr' ((c as Const ("_free", _)) $ Free x) = c $ Free (upd_tr' x)
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 440 | | update_name_tr' (Const x) = Const (upd_tr' x) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 441 | | update_name_tr' _ = raise Match; | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 442 | |
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 443 | end; | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 444 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 445 | |
| 14697 | 446 | (* indexed syntax *) | 
| 548 | 447 | |
| 42278 | 448 | fun index_ast_tr' [Ast.Appl [Ast.Constant "_struct", ast]] = ast | 
| 14697 | 449 | | index_ast_tr' _ = raise Match; | 
| 450 | ||
| 59152 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 451 | fun struct_ast_tr' ctxt [Ast.Constant "_indexdefault"] = | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 452 | (case #structs (get_idents ctxt) of | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 453 | x :: _ => Ast.Appl [Ast.Constant "_free", Ast.Variable x] | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 454 | | _ => raise Match) | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 455 | | struct_ast_tr' _ _ = raise Match; | 
| 14697 | 456 | |
| 457 | ||
| 458 | ||
| 459 | (** Pure translations **) | |
| 548 | 460 | |
| 52143 | 461 | val pure_parse_ast_translation = | 
| 462 |  [("_strip_positions", fn _ => strip_positions_ast_tr),
 | |
| 463 |   ("_constify", fn _ => constify_ast_tr),
 | |
| 464 |   ("_tapp", fn _ => tapp_ast_tr),
 | |
| 465 |   ("_tappl", fn _ => tappl_ast_tr),
 | |
| 466 |   ("_bracket", fn _ => bracket_ast_tr),
 | |
| 467 |   ("_appl", fn _ => appl_ast_tr),
 | |
| 468 |   ("_applC", fn _ => applC_ast_tr),
 | |
| 469 |   ("_lambda", fn _ => lambda_ast_tr),
 | |
| 470 |   ("_idtyp", fn _ => idtyp_ast_tr),
 | |
| 471 |   ("_bigimpl", fn _ => bigimpl_ast_tr),
 | |
| 472 |   ("_indexdefault", fn _ => indexdefault_ast_tr),
 | |
| 473 |   ("_indexvar", fn _ => indexvar_ast_tr),
 | |
| 474 |   ("_struct", fn _ => struct_ast_tr)];
 | |
| 548 | 475 | |
| 52143 | 476 | val pure_parse_translation = | 
| 477 |  [("_abs", fn _ => abs_tr),
 | |
| 478 |   ("_aprop", fn _ => aprop_tr),
 | |
| 479 |   ("_ofclass", fn _ => ofclass_tr),
 | |
| 480 |   ("_sort_constraint", fn _ => sort_constraint_tr),
 | |
| 481 |   ("_TYPE", fn _ => type_tr),
 | |
| 482 |   ("_update_name", fn _ => update_name_tr),
 | |
| 59152 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 483 |   ("_index", fn _ => index_tr),
 | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 484 |   ("_struct", struct_tr)];
 | 
| 52143 | 485 | |
| 486 | val pure_print_ast_translation = | |
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 487 |  [("\<^type>fun", fn _ => fun_ast_tr'),
 | 
| 52143 | 488 |   ("_abs", fn _ => abs_ast_tr'),
 | 
| 489 |   ("_idts", fn _ => idtyp_ast_tr' "_idts"),
 | |
| 490 |   ("_pttrns", fn _ => idtyp_ast_tr' "_pttrns"),
 | |
| 62529 
8b7bdfc09f3b
clarified treatment of fragments of Isabelle symbols during bootstrap;
 wenzelm parents: 
59152diff
changeset | 491 |   ("\<^const>Pure.imp", fn _ => impl_ast_tr'),
 | 
| 59152 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 492 |   ("_index", fn _ => index_ast_tr'),
 | 
| 
66e6c539a36d
more frugal Local_Syntax.init -- maintain idents within context;
 wenzelm parents: 
56438diff
changeset | 493 |   ("_struct", struct_ast_tr')];
 | 
| 52143 | 494 | |
| 548 | 495 | end; | 
| 42284 | 496 | |
| 497 | structure Basic_Syntax_Trans: BASIC_SYNTAX_TRANS = Syntax_Trans; | |
| 498 | open Basic_Syntax_Trans; |