0
|
1 |
(* Title: Pure/Syntax/sextension
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow and Markus Wenzel, TU Muenchen
|
|
4 |
|
|
5 |
Syntax extensions: mixfix declarations, syntax rules, infixes, binders and
|
|
6 |
the Pure syntax.
|
|
7 |
|
|
8 |
Changes:
|
|
9 |
SEXTENSION: added Ast, xrule
|
|
10 |
changed sext
|
|
11 |
added ast_to_term
|
|
12 |
ext_of_sext: added xconsts
|
|
13 |
SEXTENSION1: added empty_sext, appl_ast_tr'
|
|
14 |
SEXTENSION1: removed appl_tr'
|
|
15 |
TODO:
|
|
16 |
*)
|
|
17 |
|
|
18 |
|
|
19 |
infix |-> <-| <->;
|
|
20 |
|
|
21 |
signature SEXTENSION0 =
|
|
22 |
sig
|
|
23 |
structure Ast: AST
|
|
24 |
local open Ast in
|
|
25 |
datatype mixfix =
|
|
26 |
Mixfix of string * string * string * int list * int |
|
|
27 |
Delimfix of string * string * string |
|
|
28 |
Infixl of string * string * int |
|
|
29 |
Infixr of string * string * int |
|
|
30 |
Binder of string * string * string * int * int |
|
|
31 |
TInfixl of string * string * int |
|
|
32 |
TInfixr of string * string * int
|
|
33 |
datatype xrule =
|
|
34 |
op |-> of (string * string) * (string * string) |
|
|
35 |
op <-| of (string * string) * (string * string) |
|
|
36 |
op <-> of (string * string) * (string * string)
|
|
37 |
datatype sext =
|
|
38 |
Sext of {
|
|
39 |
mixfix: mixfix list,
|
|
40 |
parse_translation: (string * (term list -> term)) list,
|
|
41 |
print_translation: (string * (term list -> term)) list} |
|
|
42 |
NewSext of {
|
|
43 |
mixfix: mixfix list,
|
|
44 |
xrules: xrule list,
|
|
45 |
parse_ast_translation: (string * (ast list -> ast)) list,
|
|
46 |
parse_preproc: (ast -> ast) option,
|
|
47 |
parse_postproc: (ast -> ast) option,
|
|
48 |
parse_translation: (string * (term list -> term)) list,
|
|
49 |
print_translation: (string * (term list -> term)) list,
|
|
50 |
print_preproc: (ast -> ast) option,
|
|
51 |
print_postproc: (ast -> ast) option,
|
|
52 |
print_ast_translation: (string * (ast list -> ast)) list}
|
|
53 |
val eta_contract: bool ref
|
|
54 |
val mk_binder_tr: string * string -> string * (term list -> term)
|
|
55 |
val mk_binder_tr': string * string -> string * (term list -> term)
|
|
56 |
val ndependent_tr: string -> term list -> term
|
|
57 |
val dependent_tr': string * string -> term list -> term
|
|
58 |
val max_pri: int
|
|
59 |
end
|
|
60 |
end;
|
|
61 |
|
|
62 |
signature SEXTENSION1 =
|
|
63 |
sig
|
|
64 |
include SEXTENSION0
|
|
65 |
val empty_sext: sext
|
|
66 |
val simple_sext: mixfix list -> sext
|
|
67 |
val constants: sext -> (string list * string) list
|
|
68 |
val pure_sext: sext
|
|
69 |
val syntax_types: string list
|
|
70 |
val constrainAbsC: string
|
|
71 |
end;
|
|
72 |
|
|
73 |
signature SEXTENSION =
|
|
74 |
sig
|
|
75 |
include SEXTENSION1
|
|
76 |
structure Extension: EXTENSION
|
|
77 |
sharing Extension.XGram.Ast = Ast
|
|
78 |
local open Extension Ast in
|
|
79 |
val xrules_of: sext -> xrule list
|
|
80 |
val abs_tr': term -> term
|
|
81 |
val appl_ast_tr': ast * ast list -> ast
|
|
82 |
val ext_of_sext: string list -> string list -> (string -> typ) -> sext -> ext
|
|
83 |
val ast_to_term: (string -> (term list -> term) option) -> ast -> term
|
|
84 |
val constrainIdtC: string
|
|
85 |
val apropC: string
|
|
86 |
end
|
|
87 |
end;
|
|
88 |
|
|
89 |
functor SExtensionFun(structure TypeExt: TYPE_EXT and Lexicon: LEXICON)(*: SEXTENSION *) = (* FIXME *)
|
|
90 |
struct
|
|
91 |
|
|
92 |
structure Extension = TypeExt.Extension;
|
|
93 |
structure Ast = Extension.XGram.Ast;
|
|
94 |
open Extension Ast;
|
|
95 |
|
|
96 |
|
|
97 |
(** datatype sext **)
|
|
98 |
|
|
99 |
datatype mixfix =
|
|
100 |
Mixfix of string * string * string * int list * int |
|
|
101 |
Delimfix of string * string * string |
|
|
102 |
Infixl of string * string * int |
|
|
103 |
Infixr of string * string * int |
|
|
104 |
Binder of string * string * string * int * int |
|
|
105 |
TInfixl of string * string * int |
|
|
106 |
TInfixr of string * string * int;
|
|
107 |
|
|
108 |
datatype xrule =
|
|
109 |
op |-> of (string * string) * (string * string) |
|
|
110 |
op <-| of (string * string) * (string * string) |
|
|
111 |
op <-> of (string * string) * (string * string);
|
|
112 |
|
|
113 |
datatype sext =
|
|
114 |
Sext of {
|
|
115 |
mixfix: mixfix list,
|
|
116 |
parse_translation: (string * (term list -> term)) list,
|
|
117 |
print_translation: (string * (term list -> term)) list} |
|
|
118 |
NewSext of {
|
|
119 |
mixfix: mixfix list,
|
|
120 |
xrules: xrule list,
|
|
121 |
parse_ast_translation: (string * (ast list -> ast)) list,
|
|
122 |
parse_preproc: (ast -> ast) option,
|
|
123 |
parse_postproc: (ast -> ast) option,
|
|
124 |
parse_translation: (string * (term list -> term)) list,
|
|
125 |
print_translation: (string * (term list -> term)) list,
|
|
126 |
print_preproc: (ast -> ast) option,
|
|
127 |
print_postproc: (ast -> ast) option,
|
|
128 |
print_ast_translation: (string * (ast list -> ast)) list};
|
|
129 |
|
|
130 |
|
|
131 |
(* simple_sext *)
|
|
132 |
|
|
133 |
fun simple_sext mixfix =
|
|
134 |
Sext {mixfix = mixfix, parse_translation = [], print_translation = []};
|
|
135 |
|
|
136 |
|
|
137 |
(* empty_sext *)
|
|
138 |
|
|
139 |
val empty_sext = simple_sext [];
|
|
140 |
|
|
141 |
|
|
142 |
(* sext_components *)
|
|
143 |
|
|
144 |
fun sext_components (Sext {mixfix, parse_translation, print_translation}) =
|
|
145 |
{mixfix = mixfix,
|
|
146 |
xrules = [],
|
|
147 |
parse_ast_translation = [],
|
|
148 |
parse_preproc = None,
|
|
149 |
parse_postproc = None,
|
|
150 |
parse_translation = parse_translation,
|
|
151 |
print_translation = print_translation,
|
|
152 |
print_preproc = None,
|
|
153 |
print_postproc = None,
|
|
154 |
print_ast_translation = []}
|
|
155 |
| sext_components (NewSext cmps) = cmps;
|
|
156 |
|
|
157 |
|
|
158 |
(* mixfix_of *)
|
|
159 |
|
|
160 |
fun mixfix_of (Sext {mixfix, ...}) = mixfix
|
|
161 |
| mixfix_of (NewSext {mixfix, ...}) = mixfix;
|
|
162 |
|
|
163 |
|
|
164 |
(* xrules_of *)
|
|
165 |
|
|
166 |
fun xrules_of (Sext _) = []
|
|
167 |
| xrules_of (NewSext {xrules, ...}) = xrules;
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
(** parse translations **)
|
|
172 |
|
|
173 |
(* application *)
|
|
174 |
|
|
175 |
fun appl_ast_tr (*"_appl"*) [f, args] = Appl (f :: unfold_ast "_args" args)
|
|
176 |
| appl_ast_tr (*"_appl"*) asts = raise_ast "appl_ast_tr" asts;
|
|
177 |
|
|
178 |
|
|
179 |
(* abstraction *)
|
|
180 |
|
|
181 |
fun idtyp_ast_tr (*"_idtyp"*) [x, ty] = Appl [Constant constrainC, x, ty]
|
|
182 |
| idtyp_ast_tr (*"_idtyp"*) asts = raise_ast "idtyp_ast_tr" asts;
|
|
183 |
|
|
184 |
fun lambda_ast_tr (*"_lambda"*) [idts, body] =
|
|
185 |
fold_ast_p "_%" (unfold_ast "_idts" idts, body)
|
|
186 |
| lambda_ast_tr (*"_lambda"*) asts = raise_ast "lambda_ast_tr" asts;
|
|
187 |
|
|
188 |
fun abs_tr (*"_%"*) [Free (x, T), body] = absfree (x, T, body)
|
|
189 |
| abs_tr (*"_%"*) (ts as [Const (c, _) $ Free (x, T) $ tT, body]) =
|
|
190 |
if c = constrainC then
|
|
191 |
Const ("_constrainAbs", dummyT) $ absfree (x, T, body) $ tT
|
|
192 |
else raise (TERM ("abs_tr", ts))
|
|
193 |
| abs_tr (*"_%"*) ts = raise (TERM ("abs_tr", ts));
|
|
194 |
|
|
195 |
|
|
196 |
(* binder *) (* FIXME check *) (* FIXME check *)
|
|
197 |
|
|
198 |
fun mk_binder_tr (sy, name) =
|
|
199 |
let
|
|
200 |
val const = Const (name, dummyT);
|
|
201 |
|
|
202 |
fun tr (Free (x, T), t) = const $ absfree (x, T, t)
|
|
203 |
| tr (Const ("_idts", _) $ idt $ idts, t) = tr (idt, tr (idts, t))
|
|
204 |
| tr (t1 as (Const (c, _) $ Free (x, T) $ tT), t) = (* FIXME *)
|
|
205 |
if c = constrainC then
|
|
206 |
const $ (Const ("_constrainAbs", dummyT) $ absfree (x, T, t) $ tT)
|
|
207 |
else raise (TERM ("binder_tr", [t1, t]))
|
|
208 |
| tr (t1, t2) = raise (TERM ("binder_tr", [t1, t2]));
|
|
209 |
|
|
210 |
fun binder_tr (*sy*) [idts, body] = tr (idts, body)
|
|
211 |
| binder_tr (*sy*) ts = raise (TERM ("binder_tr", ts));
|
|
212 |
in
|
|
213 |
(sy, binder_tr)
|
|
214 |
end;
|
|
215 |
|
|
216 |
|
|
217 |
(* atomic props *)
|
|
218 |
|
|
219 |
fun aprop_ast_tr (*"_aprop"*) [ast] = ast
|
|
220 |
| aprop_ast_tr (*"_aprop"*) asts = raise_ast "aprop_ast_tr" asts;
|
|
221 |
|
|
222 |
|
|
223 |
(* meta implication *)
|
|
224 |
|
|
225 |
fun bigimpl_ast_tr (*"_bigimpl"*) [asms, concl] =
|
|
226 |
fold_ast_p "==>" (unfold_ast "_asms" asms, concl)
|
|
227 |
| bigimpl_ast_tr (*"_bigimpl"*) asts = raise_ast "bigimpl_ast_tr" asts;
|
|
228 |
|
|
229 |
|
|
230 |
(* 'dependent' type operators *)
|
|
231 |
|
|
232 |
fun ndependent_tr q [A, B] =
|
|
233 |
Const (q, dummyT) $ A $ Abs ("x", dummyT, incr_boundvars 1 B)
|
|
234 |
| ndependent_tr _ _ = raise Match;
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
(** print translations **)
|
|
239 |
|
|
240 |
(* application *)
|
|
241 |
|
|
242 |
fun appl_ast_tr' (f, []) = raise_ast "appl_ast_tr'" [f]
|
|
243 |
| appl_ast_tr' (f, args) = Appl [Constant "_appl", f, fold_ast "_args" args];
|
|
244 |
|
|
245 |
|
|
246 |
(* abstraction *) (* FIXME check *)
|
|
247 |
|
|
248 |
fun strip_abss vars_of body_of tm =
|
|
249 |
let
|
|
250 |
val vars = vars_of tm;
|
|
251 |
val body = body_of tm;
|
|
252 |
val rev_new_vars = rename_wrt_term body vars;
|
|
253 |
in
|
|
254 |
(map Free (rev rev_new_vars),
|
|
255 |
subst_bounds (map (fn (x, _) => Free (x, dummyT)) rev_new_vars, body))
|
|
256 |
end;
|
|
257 |
|
|
258 |
(*do (partial) eta-contraction before printing*)
|
|
259 |
|
|
260 |
val eta_contract = ref false;
|
|
261 |
|
|
262 |
fun eta_contr tm =
|
|
263 |
let
|
|
264 |
fun eta_abs (Abs (a, T, t)) =
|
|
265 |
(case eta_abs t of
|
|
266 |
t' as (f $ u) =>
|
|
267 |
(case eta_abs u of
|
|
268 |
Bound 0 =>
|
|
269 |
if not (0 mem loose_bnos f) then incr_boundvars ~1 f
|
|
270 |
else Abs (a, T, t')
|
|
271 |
| _ => Abs (a, T, t'))
|
|
272 |
| t' => Abs (a, T, t'))
|
|
273 |
| eta_abs t = t;
|
|
274 |
in
|
|
275 |
if ! eta_contract then eta_abs tm else tm
|
|
276 |
end;
|
|
277 |
|
|
278 |
|
|
279 |
fun abs_tr' tm =
|
|
280 |
foldr (fn (x, t) => Const ("_%", dummyT) $ x $ t)
|
|
281 |
(strip_abss strip_abs_vars strip_abs_body (eta_contr tm));
|
|
282 |
|
|
283 |
|
|
284 |
fun lambda_ast_tr' (*"_%"*) asts =
|
|
285 |
(case unfold_ast_p "_%" (Appl (Constant "_%" :: asts)) of
|
|
286 |
([], _) => raise_ast "lambda_ast_tr'" asts
|
|
287 |
| (xs, body) => Appl [Constant "_lambda", fold_ast "_idts" xs, body]);
|
|
288 |
|
|
289 |
|
|
290 |
(* binder *) (* FIXME check *)
|
|
291 |
|
|
292 |
fun mk_binder_tr' (name, sy) =
|
|
293 |
let
|
|
294 |
fun mk_idts [] = raise Match (*abort translation*)
|
|
295 |
| mk_idts [idt] = idt
|
|
296 |
| mk_idts (idt :: idts) = Const ("_idts", dummyT) $ idt $ mk_idts idts;
|
|
297 |
|
|
298 |
fun tr' t =
|
|
299 |
let
|
|
300 |
val (xs, bd) = strip_abss (strip_qnt_vars name) (strip_qnt_body name) t;
|
|
301 |
in
|
|
302 |
Const (sy, dummyT) $ mk_idts xs $ bd
|
|
303 |
end;
|
|
304 |
|
|
305 |
fun binder_tr' (*name*) (t :: ts) =
|
|
306 |
list_comb (tr' (Const (name, dummyT) $ t), ts)
|
|
307 |
| binder_tr' (*name*) [] = raise Match;
|
|
308 |
in
|
|
309 |
(name, binder_tr')
|
|
310 |
end;
|
|
311 |
|
|
312 |
|
|
313 |
(* idts *)
|
|
314 |
|
|
315 |
fun idts_ast_tr' (*"_idts"*) [Appl [Constant c, x, ty], xs] =
|
|
316 |
if c = constrainC then
|
|
317 |
Appl [Constant "_idts", Appl [Constant "_idtyp", x, ty], xs]
|
|
318 |
else raise Match
|
|
319 |
| idts_ast_tr' (*"_idts"*) _ = raise Match;
|
|
320 |
|
|
321 |
|
|
322 |
(* meta implication *)
|
|
323 |
|
|
324 |
fun impl_ast_tr' (*"==>"*) asts =
|
|
325 |
(case unfold_ast_p "==>" (Appl (Constant "==>" :: asts)) of
|
|
326 |
(asms as (_ :: _ :: _), concl)
|
|
327 |
=> Appl [Constant "_bigimpl", fold_ast "_asms" asms, concl]
|
|
328 |
| _ => raise Match);
|
|
329 |
|
|
330 |
|
|
331 |
(* 'dependent' type operators *)
|
|
332 |
|
|
333 |
fun dependent_tr' (q, r) [A, Abs (x, T, B)] =
|
|
334 |
if 0 mem (loose_bnos B) then
|
|
335 |
let val (x', B') = variant_abs (x, dummyT, B);
|
|
336 |
in Const (q, dummyT) $ Free (x', T) $ A $ B' end
|
|
337 |
else Const (r, dummyT) $ A $ B
|
|
338 |
| dependent_tr' _ _ = raise Match;
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
(** constants **)
|
|
343 |
|
|
344 |
(* FIXME opn, clean: move *)
|
|
345 |
val clean =
|
|
346 |
let
|
|
347 |
fun q ("'" :: c :: cs) = c ^ q cs
|
|
348 |
| q (c :: cs) = c ^ q cs
|
|
349 |
| q ([]) = ""
|
|
350 |
in q o explode end;
|
|
351 |
|
|
352 |
val opn = "op ";
|
|
353 |
|
|
354 |
|
|
355 |
fun constants sext =
|
|
356 |
let
|
|
357 |
fun consts (Delimfix (_, ty, c)) = ([c], ty)
|
|
358 |
| consts (Mixfix (_, ty, c, _, _)) = ([c], ty)
|
|
359 |
| consts (Infixl (c, ty, _)) = ([opn ^ clean c], ty)
|
|
360 |
| consts (Infixr (c, ty, _)) = ([opn ^ clean c], ty)
|
|
361 |
| consts (Binder (_, ty, c, _, _)) = ([c], ty)
|
|
362 |
| consts _ = ([""], ""); (*is filtered out below*)
|
|
363 |
in
|
|
364 |
distinct (filter_out (fn (l, _) => l = [""]) (map consts (mixfix_of sext)))
|
|
365 |
end;
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
(** ext_of_sext **) (* FIXME check, clean *)
|
|
370 |
|
|
371 |
fun ext_of_sext roots xconsts read_typ sext =
|
|
372 |
let
|
|
373 |
val
|
|
374 |
{mixfix, parse_ast_translation, parse_preproc, parse_postproc,
|
|
375 |
parse_translation, print_translation, print_preproc, print_postproc,
|
|
376 |
print_ast_translation, ...} = sext_components sext;
|
|
377 |
|
|
378 |
val infixT = [typeT, typeT] ---> typeT;
|
|
379 |
|
|
380 |
fun binder (Binder (sy, _, name, _, _)) = Some (sy, name)
|
|
381 |
| binder _ = None;
|
|
382 |
|
|
383 |
fun binder_typ ty =
|
|
384 |
(case read_typ ty of
|
|
385 |
Type ("fun", [Type ("fun", [_, T2]), T3]) =>
|
|
386 |
[Type ("idts", []), T2] ---> T3
|
|
387 |
| _ => error (quote ty ^ " is not a valid binder type."));
|
|
388 |
|
|
389 |
fun mfix_of (Mixfix (sy, ty, c, pl, p)) = [Mfix (sy, read_typ ty, c, pl, p)]
|
|
390 |
| mfix_of (Delimfix (sy, ty, c)) = [Mfix (sy, read_typ ty, c, [], max_pri)]
|
|
391 |
| mfix_of (Infixl (sy, ty, p)) =
|
|
392 |
let val T = read_typ ty and c = opn ^ sy and c' = opn ^ clean sy
|
|
393 |
in
|
|
394 |
[Mfix (c, T, c', [], max_pri),
|
|
395 |
Mfix("(_ " ^ sy ^ "/ _)", T, c', [p, p + 1], p)]
|
|
396 |
end
|
|
397 |
| mfix_of (Infixr (sy, ty, p)) =
|
|
398 |
let val T = read_typ ty and c = opn ^ sy and c' = opn ^ clean sy
|
|
399 |
in
|
|
400 |
[Mfix(c, T, c', [], max_pri),
|
|
401 |
Mfix("(_ " ^ sy ^ "/ _)", T, c', [p + 1, p], p)]
|
|
402 |
end
|
|
403 |
| mfix_of (Binder (sy, ty, _, p, q)) =
|
|
404 |
[Mfix ("(3" ^ sy ^ "_./ _)", binder_typ ty, sy, [0, p], q)]
|
|
405 |
| mfix_of (TInfixl (s, c, p)) =
|
|
406 |
[Mfix ("(_ " ^ s ^ "/ _)", infixT, c, [p, p + 1], p)]
|
|
407 |
| mfix_of (TInfixr (s, c, p)) =
|
|
408 |
[Mfix ("(_ " ^ s ^ "/ _)", infixT, c, [p + 1, p], p)];
|
|
409 |
|
|
410 |
val mfix = flat (map mfix_of mixfix);
|
|
411 |
val mfix_consts = map (fn (Mfix (_, _, c, _, _)) => c) mfix;
|
|
412 |
val bs = mapfilter binder mixfix;
|
|
413 |
val bparses = map mk_binder_tr bs;
|
|
414 |
val bprints = map (mk_binder_tr' o (fn (x, y) => (y, x))) bs;
|
|
415 |
in
|
|
416 |
Ext {
|
|
417 |
roots = roots, mfix = mfix,
|
|
418 |
extra_consts = distinct (filter Lexicon.is_identifier (xconsts @ mfix_consts)),
|
|
419 |
parse_ast_translation = parse_ast_translation,
|
|
420 |
parse_preproc = parse_preproc,
|
|
421 |
parse_postproc = parse_postproc,
|
|
422 |
parse_translation = bparses @ parse_translation,
|
|
423 |
print_translation = bprints @ print_translation,
|
|
424 |
print_preproc = print_preproc,
|
|
425 |
print_postproc = print_postproc,
|
|
426 |
print_ast_translation = print_ast_translation}
|
|
427 |
end;
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
(** ast_to_term **)
|
|
432 |
|
|
433 |
fun ast_to_term trf ast =
|
|
434 |
let
|
|
435 |
fun scan_vname prfx cs =
|
|
436 |
(case Lexicon.scan_varname cs of
|
|
437 |
((x, i), []) => Var ((prfx ^ x, i), dummyT)
|
|
438 |
| _ => error ("ast_to_term: bad variable name " ^ quote (implode cs)));
|
|
439 |
|
|
440 |
fun vname_to_var v =
|
|
441 |
(case explode v of
|
|
442 |
"?" :: "'" :: cs => scan_vname "'" cs
|
|
443 |
| "?" :: cs => scan_vname "" cs
|
|
444 |
| _ => Free (v, dummyT));
|
|
445 |
|
|
446 |
fun trans a args =
|
|
447 |
(case trf a of
|
|
448 |
None => list_comb (Const (a, dummyT), args)
|
|
449 |
| Some f => ((f args)
|
|
450 |
handle _ => error ("ast_to_term: error in translation for " ^ quote a)));
|
|
451 |
|
|
452 |
fun trav (Constant a) = trans a []
|
|
453 |
| trav (Appl (Constant a :: (asts as _ :: _))) = trans a (map trav asts)
|
|
454 |
| trav (Appl (ast :: (asts as _ :: _))) =
|
|
455 |
list_comb (trav ast, map trav asts)
|
|
456 |
| trav (ast as (Appl _)) = raise_ast "ast_to_term: malformed ast" [ast]
|
|
457 |
| trav (Variable x) = vname_to_var x;
|
|
458 |
in
|
|
459 |
trav ast
|
|
460 |
end;
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
(** the Pure syntax **)
|
|
465 |
|
|
466 |
val pure_sext =
|
|
467 |
NewSext {
|
|
468 |
mixfix = [
|
|
469 |
Mixfix ("(3%_./ _)", "[idts, 'a] => ('b => 'a)", "_lambda", [0], 0),
|
|
470 |
Delimfix ("_", "'a => " ^ args, ""),
|
|
471 |
Delimfix ("_,/ _", "['a, " ^ args ^ "] => " ^ args, "_args"),
|
|
472 |
Delimfix ("_", "id => idt", ""),
|
|
473 |
Mixfix ("_::_", "[id, type] => idt", "_idtyp", [0, 0], 0),
|
|
474 |
Delimfix ("'(_')", "idt => idt", ""),
|
|
475 |
Delimfix ("_", "idt => idts", ""),
|
|
476 |
Mixfix ("_/ _", "[idt, idts] => idts", "_idts", [1, 0], 0),
|
|
477 |
Delimfix ("_", "id => aprop", ""),
|
|
478 |
Delimfix ("_", "var => aprop", ""),
|
|
479 |
Mixfix ("_'(_')", "[('b => 'a), " ^ args ^ "] => aprop", applC, [max_pri, 0], 0),
|
|
480 |
Delimfix ("PROP _", "aprop => prop", "_aprop"),
|
|
481 |
Delimfix ("_", "prop => asms", ""),
|
|
482 |
Delimfix ("_;/ _", "[prop, asms] => asms", "_asms"),
|
|
483 |
Mixfix ("((3[| _ |]) ==>/ _)", "[asms, prop] => prop", "_bigimpl", [0, 1], 1),
|
|
484 |
Mixfix ("(_ ==/ _)", "['a::{}, 'a] => prop", "==", [3, 2], 2),
|
|
485 |
Mixfix ("(_ =?=/ _)", "['a::{}, 'a] => prop", "=?=", [3, 2], 2),
|
|
486 |
Mixfix ("(_ ==>/ _)", "[prop, prop] => prop", "==>", [2, 1], 1),
|
|
487 |
Binder ("!!", "('a::logic => prop) => prop", "all", 0, 0)],
|
|
488 |
xrules = [],
|
|
489 |
parse_ast_translation =
|
|
490 |
[(applC, appl_ast_tr), ("_lambda", lambda_ast_tr), ("_idtyp", idtyp_ast_tr),
|
|
491 |
("_aprop", aprop_ast_tr), ("_bigimpl", bigimpl_ast_tr)],
|
|
492 |
parse_preproc = None,
|
|
493 |
parse_postproc = None,
|
|
494 |
parse_translation = [("_%", abs_tr)],
|
|
495 |
print_translation = [],
|
|
496 |
print_preproc = None,
|
|
497 |
print_postproc = None,
|
|
498 |
print_ast_translation = [("_%", lambda_ast_tr'), ("_idts", idts_ast_tr'),
|
|
499 |
("==>", impl_ast_tr')]};
|
|
500 |
|
|
501 |
val syntax_types = (* FIXME clean, check *)
|
|
502 |
[logic, "aprop", args, "asms", id, "idt", "idts", tfree, tvar, "type", "types",
|
|
503 |
var, "sort", "classes"]
|
|
504 |
|
|
505 |
val constrainIdtC = "_idtyp";
|
|
506 |
val constrainAbsC = "_constrainAbs";
|
|
507 |
val apropC = "_aprop";
|
|
508 |
|
|
509 |
|
|
510 |
end;
|
|
511 |
|