equal
deleted
inserted
replaced
21 type code_graph |
21 type code_graph |
22 val cert: code_graph -> string -> Code.cert |
22 val cert: code_graph -> string -> Code.cert |
23 val sortargs: code_graph -> string -> sort list |
23 val sortargs: code_graph -> string -> sort list |
24 val all: code_graph -> string list |
24 val all: code_graph -> string list |
25 val pretty: theory -> code_graph -> Pretty.T |
25 val pretty: theory -> code_graph -> Pretty.T |
26 val obtain: theory -> string list -> term list -> code_algebra * code_graph |
26 val obtain: bool -> theory -> string list -> term list -> code_algebra * code_graph |
27 val dynamic_eval_conv: theory |
27 val dynamic_eval_conv: theory |
28 -> (code_algebra -> code_graph -> (string * sort) list -> term -> conv) -> conv |
28 -> (code_algebra -> code_graph -> (string * sort) list -> term -> conv) -> conv |
29 val dynamic_eval_value: theory -> ((term -> term) -> 'a -> 'a) |
29 val dynamic_eval_value: theory -> ((term -> term) -> 'a -> 'a) |
30 -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a |
30 -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a |
31 val static_eval_conv: theory -> string list |
31 val static_eval_conv: theory -> string list |
420 ); |
420 ); |
421 |
421 |
422 |
422 |
423 (** retrieval and evaluation interfaces **) |
423 (** retrieval and evaluation interfaces **) |
424 |
424 |
425 fun obtain thy consts ts = apsnd snd |
425 fun obtain ignore_cache thy consts ts = apsnd snd |
426 (Wellsorted.change_yield thy (extend_arities_eqngr thy consts ts)); |
426 (Wellsorted.change_yield (if ignore_cache then NONE else SOME thy) (extend_arities_eqngr thy consts ts)); |
427 |
427 |
428 fun dest_cterm ct = let val t = Thm.term_of ct in (Term.add_tfrees t [], t) end; |
428 fun dest_cterm ct = let val t = Thm.term_of ct in (Term.add_tfrees t [], t) end; |
429 |
429 |
430 fun dynamic_eval thy cterm_of conclude_evaluation evaluator proto_ct = |
430 fun dynamic_eval thy cterm_of conclude_evaluation evaluator proto_ct = |
431 let |
431 let |
435 val thm = preprocess_conv thy ct; |
435 val thm = preprocess_conv thy ct; |
436 val ct' = Thm.rhs_of thm; |
436 val ct' = Thm.rhs_of thm; |
437 val (vs', t') = dest_cterm ct'; |
437 val (vs', t') = dest_cterm ct'; |
438 val consts = fold_aterms |
438 val consts = fold_aterms |
439 (fn Const (c, _) => insert (op =) c | _ => I) t' []; |
439 (fn Const (c, _) => insert (op =) c | _ => I) t' []; |
440 val (algebra', eqngr') = obtain thy consts [t']; |
440 val (algebra', eqngr') = obtain false thy consts [t']; |
441 in conclude_evaluation (evaluator algebra' eqngr' vs' t' ct') thm end; |
441 in conclude_evaluation (evaluator algebra' eqngr' vs' t' ct') thm end; |
442 |
442 |
443 fun dynamic_eval_conv thy = |
443 fun dynamic_eval_conv thy = |
444 let |
444 let |
445 fun conclude_evaluation thm2 thm1 = |
445 fun conclude_evaluation thm2 thm1 = |
455 fun dynamic_eval_value thy postproc evaluator = dynamic_eval thy (Thm.cterm_of thy) |
455 fun dynamic_eval_value thy postproc evaluator = dynamic_eval thy (Thm.cterm_of thy) |
456 (K o postproc (postprocess_term thy)) (K oooo evaluator); |
456 (K o postproc (postprocess_term thy)) (K oooo evaluator); |
457 |
457 |
458 fun static_eval_conv thy consts conv = |
458 fun static_eval_conv thy consts conv = |
459 let |
459 let |
460 val (algebra, eqngr) = obtain thy consts []; |
460 val (algebra, eqngr) = obtain true thy consts []; |
461 fun conv' ct = |
461 in |
462 let |
462 Conv.tap_thy (fn thy => (preprocess_conv thy) |
463 val (vs, t) = dest_cterm ct; |
463 then_conv (fn ct => uncurry (conv algebra eqngr) (dest_cterm ct) ct) |
464 in |
464 then_conv (postprocess_conv thy)) |
465 Conv.tap_thy (fn thy => (preprocess_conv thy) |
465 end; |
466 then_conv (conv algebra eqngr vs t) then_conv (postprocess_conv thy)) ct |
|
467 end; |
|
468 in conv' end; |
|
469 |
466 |
470 |
467 |
471 (** setup **) |
468 (** setup **) |
472 |
469 |
473 val setup = |
470 val setup = |