| author | blanchet | 
| Thu, 14 Apr 2011 11:24:05 +0200 | |
| changeset 42353 | 7797efa897a1 | 
| parent 42288 | 2074b31650e6 | 
| child 42476 | d0bc1268ef09 | 
| 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 | 
| 15 | val no_brackets: unit -> bool | |
| 16 | val no_type_brackets: unit -> bool | |
| 17 | val abs_tr: term list -> term | |
| 18 | val mk_binder_tr: string * string -> string * (term list -> term) | |
| 19 | val antiquote_tr: string -> term -> term | |
| 20 | val quote_tr: string -> term -> term | |
| 21 | val quote_antiquote_tr: string -> string -> string -> string * (term list -> term) | |
| 22 | val non_typed_tr': (term list -> term) -> typ -> term list -> term | |
| 23 |   val non_typed_tr'': ('a -> term list -> term) -> 'a -> typ -> term list -> term
 | |
| 24 | val tappl_ast_tr': Ast.ast * Ast.ast list -> Ast.ast | |
| 25 | val appl_ast_tr': Ast.ast * Ast.ast list -> Ast.ast | |
| 26 | val applC_ast_tr': Ast.ast * Ast.ast list -> Ast.ast | |
| 39128 
93a7365fb4ee
turned eta_contract into proper configuration option;
 wenzelm parents: 
37216diff
changeset | 27 | val eta_contract_default: bool Unsynchronized.ref | 
| 39163 
4d701c0388c3
more explicit indication of Config.raw options, which are only needed for bootstrapping Pure;
 wenzelm parents: 
39128diff
changeset | 28 | val eta_contract_raw: Config.raw | 
| 42284 | 29 | val mark_bound: string -> term | 
| 30 | val mark_boundT: string * typ -> term | |
| 31 | val bound_vars: (string * typ) list -> term -> term | |
| 32 | val abs_tr': Proof.context -> term -> term | |
| 13762 | 33 | 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 | 34 | val const_abs_tr': term -> term | 
| 42085 | 35 | val mk_binder_tr': string * string -> string * (term list -> term) | 
| 32120 
53a21a5e6889
attempt for more concise setup of non-etacontracting binders
 haftmann parents: 
31542diff
changeset | 36 | val preserve_binder_abs_tr': string -> string -> string * (term list -> term) | 
| 
53a21a5e6889
attempt for more concise setup of non-etacontracting binders
 haftmann parents: 
31542diff
changeset | 37 | val preserve_binder_abs2_tr': string -> string -> string * (term list -> term) | 
| 42284 | 38 | val prop_tr': term -> term | 
| 39 | val variant_abs: string * typ * term -> string * term | |
| 40 | val variant_abs': string * typ * term -> string * term | |
| 548 | 41 | val dependent_tr': string * string -> term list -> term | 
| 8577 | 42 | val antiquote_tr': string -> term -> term | 
| 43 | val quote_tr': string -> term -> term | |
| 5084 | 44 | val quote_antiquote_tr': string -> string -> string -> string * (term list -> term) | 
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 45 | val update_name_tr': term -> term | 
| 1511 | 46 | val pure_trfuns: | 
| 35429 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 47 | (string * (Ast.ast list -> Ast.ast)) list * | 
| 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 48 | (string * (term list -> term)) list * | 
| 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 49 | (string * (term list -> term)) list * | 
| 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 50 | (string * (Ast.ast list -> Ast.ast)) list | 
| 14697 | 51 | val struct_trfuns: string list -> | 
| 35429 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 52 | (string * (Ast.ast list -> Ast.ast)) list * | 
| 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 53 | (string * (term list -> term)) list * | 
| 42247 
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
 wenzelm parents: 
42245diff
changeset | 54 | (string * (typ -> term list -> term)) list * | 
| 35429 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 55 | (string * (Ast.ast list -> Ast.ast)) list | 
| 2698 | 56 | end; | 
| 548 | 57 | |
| 42284 | 58 | structure Syntax_Trans: SYNTAX_TRANS = | 
| 548 | 59 | struct | 
| 2698 | 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 | ||
| 89 | fun constify_ast_tr [Ast.Variable c] = Ast.Constant c | |
| 90 |   | constify_ast_tr asts = raise Ast.AST ("constify_ast_tr", asts);
 | |
| 91 | ||
| 92 | ||
| 42262 | 93 | (* type syntax *) | 
| 94 | ||
| 95 | fun tapp_ast_tr [ty, c] = Ast.Appl [c, ty] | |
| 96 |   | tapp_ast_tr asts = raise Ast.AST ("tapp_ast_tr", asts);
 | |
| 97 | ||
| 98 | fun tappl_ast_tr [ty, tys, c] = Ast.mk_appl c (ty :: Ast.unfold_ast "_types" tys) | |
| 99 |   | tappl_ast_tr asts = raise Ast.AST ("tappl_ast_tr", asts);
 | |
| 100 | ||
| 101 | fun bracket_ast_tr [dom, cod] = Ast.fold_ast_p "\\<^type>fun" (Ast.unfold_ast "_types" dom, cod) | |
| 102 |   | bracket_ast_tr asts = raise Ast.AST ("bracket_ast_tr", asts);
 | |
| 103 | ||
| 104 | ||
| 548 | 105 | (* application *) | 
| 106 | ||
| 5690 | 107 | fun appl_ast_tr [f, args] = Ast.Appl (f :: Ast.unfold_ast "_args" args) | 
| 108 |   | 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 | 109 | |
| 5690 | 110 | fun applC_ast_tr [f, args] = Ast.Appl (f :: Ast.unfold_ast "_cargs" args) | 
| 111 |   | applC_ast_tr asts = raise Ast.AST ("applC_ast_tr", asts);
 | |
| 548 | 112 | |
| 113 | ||
| 114 | (* abstraction *) | |
| 115 | ||
| 42278 | 116 | fun idtyp_ast_tr [x, ty] = Ast.Appl [Ast.Constant "_constrain", x, ty] | 
| 117 |   | idtyp_ast_tr asts = raise Ast.AST ("idtyp_ast_tr", asts);
 | |
| 548 | 118 | |
| 42278 | 119 | fun idtypdummy_ast_tr [ty] = Ast.Appl [Ast.Constant "_constrain", Ast.Constant "_idtdummy", ty] | 
| 120 |   | idtypdummy_ast_tr asts = raise Ast.AST ("idtyp_ast_tr", asts);
 | |
| 121 | ||
| 122 | fun lambda_ast_tr [pats, body] = Ast.fold_ast_p "_abs" (Ast.unfold_ast "_pttrns" pats, body) | |
| 123 |   | lambda_ast_tr asts = raise Ast.AST ("lambda_ast_tr", asts);
 | |
| 548 | 124 | |
| 21773 | 125 | fun absfree_proper (x, T, t) = | 
| 42048 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 126 | if can Name.dest_internal x | 
| 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 127 |   then error ("Illegal internal variable in abstraction: " ^ quote x)
 | 
| 21773 | 128 | else Term.absfree (x, T, t); | 
| 129 | ||
| 42048 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 130 | fun abs_tr [Free (x, T), t] = absfree_proper (x, T, t) | 
| 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 131 |   | abs_tr [Const ("_idtdummy", T), t] = Term.absdummy (T, t)
 | 
| 42284 | 132 |   | abs_tr [Const ("_constrain", _) $ x $ tT, t] =
 | 
| 133 | Lexicon.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 | 134 |   | abs_tr ts = raise TERM ("abs_tr", ts);
 | 
| 548 | 135 | |
| 136 | ||
| 137 | (* binder *) | |
| 138 | ||
| 21535 | 139 | fun mk_binder_tr (syn, name) = | 
| 548 | 140 | let | 
| 42055 | 141 |     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 | 142 |     fun binder_tr [Const ("_idts", _) $ idt $ idts, t] = binder_tr [idt, binder_tr [idts, t]]
 | 
| 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 143 | | binder_tr [x, t] = | 
| 42055 | 144 | let val abs = abs_tr [x, t] handle TERM _ => err [x, t] | 
| 42048 
afd11ca8e018
support for encoded positions (for id_position, longid_position) as pseudo type-constraints -- still inactive;
 wenzelm parents: 
42045diff
changeset | 145 | in Lexicon.const name $ abs end | 
| 42055 | 146 | | binder_tr ts = err ts; | 
| 21535 | 147 | in (syn, binder_tr) end; | 
| 548 | 148 | |
| 149 | ||
| 28628 | 150 | (* type propositions *) | 
| 151 | ||
| 35255 | 152 | fun mk_type ty = | 
| 153 | Lexicon.const "_constrain" $ | |
| 35429 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 154 | Lexicon.const "\\<^const>TYPE" $ (Lexicon.const "\\<^type>itself" $ ty); | 
| 28628 | 155 | |
| 42278 | 156 | fun ofclass_tr [ty, cls] = cls $ mk_type ty | 
| 157 |   | ofclass_tr ts = raise TERM ("ofclass_tr", ts);
 | |
| 28628 | 158 | |
| 42278 | 159 | fun sort_constraint_tr [ty] = Lexicon.const "\\<^const>Pure.sort_constraint" $ mk_type ty | 
| 160 |   | sort_constraint_tr ts = raise TERM ("sort_constraint_tr", ts);
 | |
| 28628 | 161 | |
| 162 | ||
| 548 | 163 | (* meta propositions *) | 
| 164 | ||
| 42278 | 165 | fun aprop_tr [t] = Lexicon.const "_constrain" $ t $ Lexicon.const "\\<^type>prop" | 
| 166 |   | aprop_tr ts = raise TERM ("aprop_tr", ts);
 | |
| 548 | 167 | |
| 168 | ||
| 169 | (* meta implication *) | |
| 170 | ||
| 42278 | 171 | fun bigimpl_ast_tr (asts as [asms, concl]) = | 
| 16612 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 172 | let val prems = | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 173 | (case Ast.unfold_ast_p "_asms" asms of | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 174 | (asms', Ast.Appl [Ast.Constant "_asm", asm']) => asms' @ [asm'] | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 175 |         | _ => raise Ast.AST ("bigimpl_ast_tr", asts))
 | 
| 35255 | 176 | in Ast.fold_ast_p "\\<^const>==>" (prems, concl) end | 
| 42278 | 177 |   | 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 | 178 | |
| 548 | 179 | |
| 23824 
8ad7131dbfcf
moved print_translations from Pure.thy to Syntax/syn_trans.ML;
 wenzelm parents: 
21773diff
changeset | 180 | (* type/term reflection *) | 
| 4148 | 181 | |
| 42278 | 182 | fun type_tr [ty] = mk_type ty | 
| 183 |   | type_tr ts = raise TERM ("type_tr", ts);
 | |
| 4148 | 184 | |
| 548 | 185 | |
| 6761 | 186 | (* dddot *) | 
| 187 | ||
| 42288 
2074b31650e6
discontinued special treatment of structure Syntax_Ext (formerly Syn_Ext);
 wenzelm parents: 
42284diff
changeset | 188 | fun dddot_tr ts = Term.list_comb (Lexicon.var Syntax_Ext.dddot_indexname, ts); | 
| 6761 | 189 | |
| 190 | ||
| 5084 | 191 | (* quote / antiquote *) | 
| 192 | ||
| 8577 | 193 | fun antiquote_tr name = | 
| 194 | let | |
| 195 | fun tr i ((t as Const (c, _)) $ u) = | |
| 196 | if c = name then tr i u $ Bound i | |
| 197 | else tr i t $ tr i u | |
| 198 | | tr i (t $ u) = tr i t $ tr i u | |
| 199 | | tr i (Abs (x, T, t)) = Abs (x, T, tr (i + 1) t) | |
| 200 | | tr _ a = a; | |
| 201 | in tr 0 end; | |
| 202 | ||
| 203 | fun quote_tr name t = Abs ("s", dummyT, antiquote_tr name (Term.incr_boundvars 1 t));
 | |
| 204 | ||
| 5084 | 205 | fun quote_antiquote_tr quoteN antiquoteN name = | 
| 206 | let | |
| 8577 | 207 | fun tr [t] = Lexicon.const name $ quote_tr antiquoteN t | 
| 208 |       | tr ts = raise TERM ("quote_tr", ts);
 | |
| 209 | in (quoteN, tr) end; | |
| 5084 | 210 | |
| 211 | ||
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 212 | (* corresponding updates *) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 213 | |
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 214 | 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 | 215 | | 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 | 216 |   | update_name_tr (((c as Const ("_constrain", _)) $ t $ ty) :: ts) =
 | 
| 42264 | 217 | 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 | 218 | else | 
| 
006095137a81
update_name_tr: more precise handling of explicit constraints, including positions;
 wenzelm parents: 
42048diff
changeset | 219 | 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 | 220 | (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 | 221 | (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 | 222 |   | 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 | 223 | |
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 224 | |
| 14697 | 225 | (* indexed syntax *) | 
| 226 | ||
| 42278 | 227 | fun struct_ast_tr [Ast.Appl [Ast.Constant "_index", ast]] = ast | 
| 228 | | struct_ast_tr asts = Ast.mk_appl (Ast.Constant "_struct") asts; | |
| 14697 | 229 | |
| 230 | fun index_ast_tr ast = | |
| 231 | Ast.mk_appl (Ast.Constant "_index") [Ast.mk_appl (Ast.Constant "_struct") [ast]]; | |
| 232 | ||
| 42278 | 233 | fun indexdefault_ast_tr [] = index_ast_tr (Ast.Constant "_indexdefault") | 
| 234 |   | indexdefault_ast_tr asts = raise Ast.AST ("indexdefault_ast_tr", asts);
 | |
| 235 | ||
| 236 | fun indexnum_ast_tr [ast] = index_ast_tr (Ast.mk_appl (Ast.Constant "_indexnum") [ast]) | |
| 237 |   | indexnum_ast_tr asts = raise Ast.AST ("indexnum_ast_tr", asts);
 | |
| 14697 | 238 | |
| 42278 | 239 | fun indexvar_ast_tr [] = Ast.mk_appl (Ast.Constant "_index") [Ast.Variable "some_index"] | 
| 240 |   | indexvar_ast_tr asts = raise Ast.AST ("indexvar_ast_tr", asts);
 | |
| 12122 | 241 | |
| 42278 | 242 | fun index_tr [t] = t | 
| 243 |   | index_tr ts = raise TERM ("index_tr", ts);
 | |
| 14697 | 244 | |
| 245 | ||
| 246 | (* implicit structures *) | |
| 247 | ||
| 248 | fun the_struct structs i = | |
| 30146 | 249 | if 1 <= i andalso i <= length structs then nth structs (i - 1) | 
| 31542 
3371a3c19bb1
reraise exceptions to preserve position information;
 wenzelm parents: 
30146diff
changeset | 250 |   else error ("Illegal reference to implicit structure #" ^ string_of_int i);
 | 
| 14697 | 251 | |
| 42278 | 252 | fun struct_tr structs [Const ("_indexdefault", _)] =
 | 
| 14697 | 253 | Lexicon.free (the_struct structs 1) | 
| 42278 | 254 |   | struct_tr structs [t as (Const ("_indexnum", _) $ Const (s, _))] =
 | 
| 14697 | 255 | Lexicon.free (the_struct structs | 
| 15531 | 256 |         (case Lexicon.read_nat s of SOME n => n | NONE => raise TERM ("struct_tr", [t])))
 | 
| 42278 | 257 |   | struct_tr _ ts = raise TERM ("struct_tr", ts);
 | 
| 12122 | 258 | |
| 259 | ||
| 5084 | 260 | |
| 548 | 261 | (** print (ast) translations **) | 
| 262 | ||
| 14647 | 263 | (* types *) | 
| 264 | ||
| 42247 
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
 wenzelm parents: 
42245diff
changeset | 265 | fun non_typed_tr' f _ ts = f ts; | 
| 
12fe41a92cd5
typed_print_translation: discontinued show_sorts argument;
 wenzelm parents: 
42245diff
changeset | 266 | fun non_typed_tr'' f x _ ts = f x ts; | 
| 14647 | 267 | |
| 268 | ||
| 42262 | 269 | (* type syntax *) | 
| 270 | ||
| 271 | fun tappl_ast_tr' (f, []) = raise Ast.AST ("tappl_ast_tr'", [f])
 | |
| 272 | | tappl_ast_tr' (f, [ty]) = Ast.Appl [Ast.Constant "_tapp", ty, f] | |
| 273 | | tappl_ast_tr' (f, ty :: tys) = | |
| 274 | Ast.Appl [Ast.Constant "_tappl", ty, Ast.fold_ast "_types" tys, f]; | |
| 275 | ||
| 276 | fun fun_ast_tr' asts = | |
| 277 | if no_brackets () orelse no_type_brackets () then raise Match | |
| 278 | else | |
| 279 | (case Ast.unfold_ast_p "\\<^type>fun" (Ast.Appl (Ast.Constant "\\<^type>fun" :: asts)) of | |
| 280 | (dom as _ :: _ :: _, cod) | |
| 281 | => Ast.Appl [Ast.Constant "_bracket", Ast.fold_ast "_types" dom, cod] | |
| 282 | | _ => raise Match); | |
| 283 | ||
| 284 | ||
| 548 | 285 | (* application *) | 
| 286 | ||
| 5690 | 287 | fun appl_ast_tr' (f, []) = raise Ast.AST ("appl_ast_tr'", [f])
 | 
| 288 | | appl_ast_tr' (f, args) = Ast.Appl [Ast.Constant "_appl", f, Ast.fold_ast "_args" args]; | |
| 548 | 289 | |
| 5690 | 290 | fun applC_ast_tr' (f, []) = raise Ast.AST ("applC_ast_tr'", [f])
 | 
| 291 | | 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 | 292 | |
| 548 | 293 | |
| 42085 | 294 | (* partial eta-contraction before printing *) | 
| 295 | ||
| 296 | fun eta_abs (Abs (a, T, t)) = | |
| 297 | (case eta_abs t of | |
| 298 |         t' as Const ("_aprop", _) $ _ => Abs (a, T, t')
 | |
| 299 | | t' as f $ u => | |
| 300 | (case eta_abs u of | |
| 301 | Bound 0 => | |
| 302 | if Term.is_dependent f then Abs (a, T, t') | |
| 303 | else incr_boundvars ~1 f | |
| 304 | | _ => Abs (a, T, t')) | |
| 305 | | t' => Abs (a, T, t')) | |
| 306 | | eta_abs t = t; | |
| 307 | ||
| 308 | val eta_contract_default = Unsynchronized.ref true; | |
| 309 | val eta_contract_raw = Config.declare "eta_contract" (fn _ => Config.Bool (! eta_contract_default)); | |
| 310 | val eta_contract = Config.bool eta_contract_raw; | |
| 311 | ||
| 312 | fun eta_contr ctxt tm = | |
| 313 | if Config.get ctxt eta_contract then eta_abs tm else tm; | |
| 314 | ||
| 315 | ||
| 548 | 316 | (* abstraction *) | 
| 317 | ||
| 19311 | 318 | fun mark_boundT (x, T) = Const ("_bound", T --> T) $ Free (x, T);
 | 
| 2698 | 319 | fun mark_bound x = mark_boundT (x, dummyT); | 
| 320 | ||
| 18958 | 321 | fun bound_vars vars body = | 
| 322 | subst_bounds (map mark_boundT (Term.rename_wrt_term body vars), body); | |
| 323 | ||
| 548 | 324 | fun strip_abss vars_of body_of tm = | 
| 325 | let | |
| 326 | val vars = vars_of tm; | |
| 327 | val body = body_of tm; | |
| 29276 | 328 | val rev_new_vars = Term.rename_wrt_term body vars; | 
| 21750 | 329 | fun subst (x, T) b = | 
| 42083 
e1209fc7ecdc
added Term.is_open and Term.is_dependent convenience, to cover common situations of loose bounds;
 wenzelm parents: 
42080diff
changeset | 330 | if can Name.dest_internal x andalso not (Term.is_dependent b) | 
| 21750 | 331 |       then (Const ("_idtdummy", T), incr_boundvars ~1 b)
 | 
| 332 | else (mark_boundT (x, T), Term.subst_bound (mark_bound x, b)); | |
| 333 | val (rev_vars', body') = fold_map subst rev_new_vars body; | |
| 334 | in (rev rev_vars', body') end; | |
| 548 | 335 | |
| 3928 
787d2659ce4a
no longer tries bogus eta-contract involving aprops;
 wenzelm parents: 
3777diff
changeset | 336 | |
| 39128 
93a7365fb4ee
turned eta_contract into proper configuration option;
 wenzelm parents: 
37216diff
changeset | 337 | fun abs_tr' ctxt tm = | 
| 19473 | 338 | uncurry (fold_rev (fn x => fn t => Lexicon.const "_abs" $ x $ t)) | 
| 39128 
93a7365fb4ee
turned eta_contract into proper configuration option;
 wenzelm parents: 
37216diff
changeset | 339 | (strip_abss strip_abs_vars strip_abs_body (eta_contr ctxt tm)); | 
| 548 | 340 | |
| 14697 | 341 | fun atomic_abs_tr' (x, T, t) = | 
| 29276 | 342 | let val [xT] = Term.rename_wrt_term t [(x, T)] | 
| 14697 | 343 | in (mark_boundT xT, subst_bound (mark_bound (fst xT), t)) end; | 
| 13762 | 344 | |
| 42085 | 345 | fun abs_ast_tr' asts = | 
| 5690 | 346 | (case Ast.unfold_ast_p "_abs" (Ast.Appl (Ast.Constant "_abs" :: asts)) of | 
| 347 |     ([], _) => raise Ast.AST ("abs_ast_tr'", asts)
 | |
| 348 | | (xs, body) => Ast.Appl [Ast.Constant "_lambda", Ast.fold_ast "_pttrns" xs, body]); | |
| 548 | 349 | |
| 42086 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 350 | fun const_abs_tr' t = | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 351 | (case eta_abs t of | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 352 | Abs (_, _, t') => | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 353 | 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 | 354 | else incr_boundvars ~1 t' | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 355 | | _ => raise Match); | 
| 
74bf78db0d87
added Syntax.const_abs_tr' with proper eta_abs and Term.is_dependent;
 wenzelm parents: 
42085diff
changeset | 356 | |
| 32120 
53a21a5e6889
attempt for more concise setup of non-etacontracting binders
 haftmann parents: 
31542diff
changeset | 357 | |
| 42085 | 358 | (* binders *) | 
| 548 | 359 | |
| 21535 | 360 | fun mk_binder_tr' (name, syn) = | 
| 548 | 361 | let | 
| 362 | fun mk_idts [] = raise Match (*abort translation*) | |
| 363 | | mk_idts [idt] = idt | |
| 5690 | 364 | | mk_idts (idt :: idts) = Lexicon.const "_idts" $ idt $ mk_idts idts; | 
| 548 | 365 | |
| 366 | fun tr' t = | |
| 367 | let | |
| 368 | val (xs, bd) = strip_abss (strip_qnt_vars name) (strip_qnt_body name) t; | |
| 21535 | 369 | in Lexicon.const syn $ mk_idts xs $ bd end; | 
| 548 | 370 | |
| 21535 | 371 | fun binder_tr' (t :: ts) = Term.list_comb (tr' (Lexicon.const name $ t), ts) | 
| 372 | | binder_tr' [] = raise Match; | |
| 373 | in (name, binder_tr') end; | |
| 548 | 374 | |
| 42085 | 375 | fun preserve_binder_abs_tr' name syn = (name, fn Abs abs :: ts => | 
| 376 | let val (x, t) = atomic_abs_tr' abs | |
| 377 | in list_comb (Lexicon.const syn $ x $ t, ts) end); | |
| 378 | ||
| 379 | fun preserve_binder_abs2_tr' name syn = (name, fn A :: Abs abs :: ts => | |
| 380 | let val (x, t) = atomic_abs_tr' abs | |
| 381 | in list_comb (Lexicon.const syn $ x $ A $ t, ts) end); | |
| 382 | ||
| 548 | 383 | |
| 3691 
f0396ac63e12
tuned lambda_ast_tr, idtyp_ast_tr' to accomodate fix of idt/idts
 wenzelm parents: 
2698diff
changeset | 384 | (* idtyp constraints *) | 
| 548 | 385 | |
| 42045 | 386 | fun idtyp_ast_tr' a [Ast.Appl [Ast.Constant "_constrain", x, ty], xs] = | 
| 387 | 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 | 388 | | idtyp_ast_tr' _ _ = raise Match; | 
| 548 | 389 | |
| 390 | ||
| 391 | (* meta propositions *) | |
| 392 | ||
| 4148 | 393 | fun prop_tr' tm = | 
| 548 | 394 | let | 
| 5690 | 395 | fun aprop t = Lexicon.const "_aprop" $ t; | 
| 548 | 396 | |
| 2698 | 397 | fun is_prop Ts t = | 
| 398 | fastype_of1 (Ts, t) = propT handle TERM _ => false; | |
| 548 | 399 | |
| 35429 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 400 |     fun is_term (Const ("Pure.term", _) $ _) = true
 | 
| 19848 | 401 | | is_term _ = false; | 
| 402 | ||
| 548 | 403 | fun tr' _ (t as Const _) = t | 
| 18478 
29a5070b517c
prop_tr': proper handling of aprop marked as bound;
 wenzelm parents: 
18342diff
changeset | 404 |       | tr' Ts (t as Const ("_bound", _) $ u) =
 | 
| 
29a5070b517c
prop_tr': proper handling of aprop marked as bound;
 wenzelm parents: 
18342diff
changeset | 405 | if is_prop Ts u then aprop t else t | 
| 2698 | 406 | | tr' _ (t as Free (x, T)) = | 
| 5690 | 407 | if T = propT then aprop (Lexicon.free x) else t | 
| 2698 | 408 | | tr' _ (t as Var (xi, T)) = | 
| 5690 | 409 | if T = propT then aprop (Lexicon.var xi) else t | 
| 2698 | 410 | | tr' Ts (t as Bound _) = | 
| 411 | if is_prop Ts t then aprop t else t | |
| 412 | | tr' Ts (Abs (x, T, t)) = Abs (x, T, tr' (T :: Ts) t) | |
| 35429 
afa8cf9e63d8
authentic syntax for classes and type constructors;
 wenzelm parents: 
35255diff
changeset | 413 |       | tr' Ts (t as t1 $ (t2 as Const ("TYPE", Type ("itself", [T])))) =
 | 
| 28628 | 414 |           if is_prop Ts t andalso not (is_term t) then Const ("_type_prop", T) $ tr' Ts t1
 | 
| 2698 | 415 | else tr' Ts t1 $ tr' Ts t2 | 
| 416 | | tr' Ts (t as t1 $ t2) = | |
| 5690 | 417 | (if is_Const (Term.head_of t) orelse not (is_prop Ts t) | 
| 2698 | 418 | then I else aprop) (tr' Ts t1 $ tr' Ts t2); | 
| 16612 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 419 | in tr' [] tm end; | 
| 548 | 420 | |
| 2698 | 421 | |
| 548 | 422 | (* meta implication *) | 
| 423 | ||
| 42278 | 424 | fun impl_ast_tr' asts = | 
| 42262 | 425 | if no_brackets () then raise Match | 
| 10572 | 426 | else | 
| 35255 | 427 | (case Ast.unfold_ast_p "\\<^const>==>" (Ast.Appl (Ast.Constant "\\<^const>==>" :: asts)) of | 
| 16612 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 428 | (prems as _ :: _ :: _, concl) => | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 429 | let | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 430 | val (asms, asm) = split_last prems; | 
| 
48be8ef738df
transform_failure in translation functions: TRANSLATION_FAIL;
 wenzelm parents: 
15570diff
changeset | 431 | 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 | 432 | 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 | 433 | | _ => raise Match); | 
| 
fcf747c0b6b8
Syntax: last premise of "_bigimpl" is wrapped with "_asm", to have a hook for
 schirmer parents: 
14981diff
changeset | 434 | |
| 548 | 435 | |
| 436 | (* dependent / nondependent quantifiers *) | |
| 437 | ||
| 20202 | 438 | fun var_abs mark (x, T, b) = | 
| 439 | let val ([x'], _) = Name.variants [x] (Term.declare_term_names b Name.context) | |
| 440 | in (x', subst_bound (mark (x', T), b)) end; | |
| 441 | ||
| 442 | val variant_abs = var_abs Free; | |
| 443 | val variant_abs' = var_abs mark_boundT; | |
| 2698 | 444 | |
| 548 | 445 | 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 | 446 | if Term.is_dependent B then | 
| 2698 | 447 | let val (x', B') = variant_abs' (x, dummyT, B); | 
| 5690 | 448 | in Term.list_comb (Lexicon.const q $ mark_boundT (x', T) $ A $ B', ts) end | 
| 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 | 449 | else Term.list_comb (Lexicon.const r $ A $ incr_boundvars ~1 B, ts) | 
| 548 | 450 | | dependent_tr' _ _ = raise Match; | 
| 451 | ||
| 452 | ||
| 5084 | 453 | (* quote / antiquote *) | 
| 454 | ||
| 8577 | 455 | fun antiquote_tr' name = | 
| 456 | let | |
| 457 | fun tr' i (t $ u) = | |
| 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 | 458 | if u aconv Bound i then Lexicon.const name $ tr' i t | 
| 
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 | 459 | else tr' i t $ tr' i u | 
| 8577 | 460 | | tr' i (Abs (x, T, t)) = Abs (x, T, tr' (i + 1) t) | 
| 18139 | 461 | | tr' i a = if a aconv Bound i then raise Match else a; | 
| 8577 | 462 | in tr' 0 end; | 
| 463 | ||
| 464 | fun quote_tr' name (Abs (_, _, t)) = Term.incr_boundvars ~1 (antiquote_tr' name t) | |
| 465 | | quote_tr' _ _ = raise Match; | |
| 466 | ||
| 5084 | 467 | fun quote_antiquote_tr' quoteN antiquoteN name = | 
| 468 | let | |
| 8577 | 469 | fun tr' (t :: ts) = Term.list_comb (Lexicon.const quoteN $ quote_tr' antiquoteN t, ts) | 
| 470 | | tr' _ = raise Match; | |
| 471 | in (name, tr') end; | |
| 5084 | 472 | |
| 473 | ||
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 474 | (* corresponding updates *) | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 475 | |
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 476 | local | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 477 | |
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 478 | 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 | 479 | | 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 | 480 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 481 | fun upd_tr' (x_upd, T) = | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 482 | (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 | 483 | SOME x => (x, upd_type T) | 
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 484 | | NONE => raise Match); | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 485 | |
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 486 | in | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 487 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 488 | 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 | 489 |   | 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 | 490 | | 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 | 491 | | update_name_tr' _ = raise Match; | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 492 | |
| 42080 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 493 | end; | 
| 
58b465952287
update_name: more uniform treatment of type constraints (NB: type equality is hard to establish in parse trees);
 wenzelm parents: 
42057diff
changeset | 494 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 495 | |
| 14697 | 496 | (* indexed syntax *) | 
| 548 | 497 | |
| 42278 | 498 | fun index_ast_tr' [Ast.Appl [Ast.Constant "_struct", ast]] = ast | 
| 14697 | 499 | | index_ast_tr' _ = raise Match; | 
| 500 | ||
| 501 | ||
| 502 | (* implicit structures *) | |
| 503 | ||
| 504 | fun the_struct' structs s = | |
| 505 | [(case Lexicon.read_nat s of | |
| 18678 | 506 | SOME i => Ast.Variable (the_struct structs i handle ERROR _ => raise Match) | 
| 15531 | 507 | | NONE => raise Match)] |> Ast.mk_appl (Ast.Constant "_free"); | 
| 14697 | 508 | |
| 42278 | 509 | fun struct_ast_tr' structs [Ast.Constant "_indexdefault"] = the_struct' structs "1" | 
| 510 | | struct_ast_tr' structs [Ast.Appl [Ast.Constant "_indexnum", Ast.Constant s]] = | |
| 14697 | 511 | the_struct' structs s | 
| 512 | | struct_ast_tr' _ _ = raise Match; | |
| 513 | ||
| 514 | ||
| 515 | ||
| 516 | (** Pure translations **) | |
| 548 | 517 | |
| 518 | val pure_trfuns = | |
| 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 | 519 |   ([("_strip_positions", strip_positions_ast_tr),
 | 
| 
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 | 520 |     ("_constify", constify_ast_tr),
 | 
| 42262 | 521 |     ("_tapp", tapp_ast_tr),
 | 
| 522 |     ("_tappl", tappl_ast_tr),
 | |
| 523 |     ("_bracket", bracket_ast_tr),
 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 524 |     ("_appl", appl_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 525 |     ("_applC", applC_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 526 |     ("_lambda", lambda_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 527 |     ("_idtyp", idtyp_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 528 |     ("_idtypdummy", idtypdummy_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 529 |     ("_bigimpl", bigimpl_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 530 |     ("_indexdefault", indexdefault_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 531 |     ("_indexnum", indexnum_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 532 |     ("_indexvar", indexvar_ast_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 533 |     ("_struct", struct_ast_tr)],
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 534 |    [("_abs", abs_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 535 |     ("_aprop", aprop_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 536 |     ("_ofclass", ofclass_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 537 |     ("_sort_constraint", sort_constraint_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 538 |     ("_TYPE", type_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 539 |     ("_DDDOT", dddot_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 540 |     ("_update_name", update_name_tr),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 541 |     ("_index", index_tr)],
 | 
| 35198 | 542 | ([]: (string * (term list -> term)) list), | 
| 42262 | 543 |    [("\\<^type>fun", fun_ast_tr'),
 | 
| 544 |     ("_abs", abs_ast_tr'),
 | |
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 545 |     ("_idts", idtyp_ast_tr' "_idts"),
 | 
| 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 546 |     ("_pttrns", idtyp_ast_tr' "_pttrns"),
 | 
| 35255 | 547 |     ("\\<^const>==>", impl_ast_tr'),
 | 
| 35145 
f132a4fd8679
moved generic update_name to Pure syntax -- not specific to HOL/record;
 wenzelm parents: 
32786diff
changeset | 548 |     ("_index", index_ast_tr')]);
 | 
| 548 | 549 | |
| 14697 | 550 | fun struct_trfuns structs = | 
| 551 |   ([], [("_struct", struct_tr structs)], [], [("_struct", struct_ast_tr' structs)]);
 | |
| 552 | ||
| 548 | 553 | end; | 
| 42284 | 554 | |
| 555 | structure Basic_Syntax_Trans: BASIC_SYNTAX_TRANS = Syntax_Trans; | |
| 556 | open Basic_Syntax_Trans; |