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