equal
deleted
inserted
replaced
21 val eqns: code_graph -> string -> (thm * bool) list |
21 val eqns: code_graph -> string -> (thm * bool) list |
22 val typ: code_graph -> string -> (string * sort) list * typ |
22 val typ: code_graph -> string -> (string * sort) list * typ |
23 val all: code_graph -> string list |
23 val all: code_graph -> string list |
24 val pretty: theory -> code_graph -> Pretty.T |
24 val pretty: theory -> code_graph -> Pretty.T |
25 val obtain: theory -> string list -> term list -> code_algebra * code_graph |
25 val obtain: theory -> string list -> term list -> code_algebra * code_graph |
26 val eval_conv: theory -> (sort -> sort) |
26 val resubst_triv_consts: theory -> term -> term |
|
27 val eval_conv: theory |
27 -> (code_algebra -> code_graph -> (string * sort) list -> term -> cterm -> thm) -> cterm -> thm |
28 -> (code_algebra -> code_graph -> (string * sort) list -> term -> cterm -> thm) -> cterm -> thm |
28 val eval: theory -> (sort -> sort) -> ((term -> term) -> 'a -> 'a) |
29 val eval: theory -> ((term -> term) -> 'a -> 'a) |
29 -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a |
30 -> (code_algebra -> code_graph -> (string * sort) list -> term -> 'a) -> term -> 'a |
30 |
31 |
31 val setup: theory -> theory |
32 val setup: theory -> theory |
32 end |
33 end |
33 |
34 |
159 ct |
160 ct |
160 |> AxClass.overload_conv thy |
161 |> AxClass.overload_conv thy |
161 |> rhs_conv (Simplifier.rewrite post) |
162 |> rhs_conv (Simplifier.rewrite post) |
162 end; |
163 end; |
163 |
164 |
164 fun postprocess_term thy = term_of_conv thy (postprocess_conv thy); |
165 fun resubst_triv_consts thy = map_aterms (fn t as Const (c, ty) => Const (Code.resubst_alias thy c, ty) |
|
166 | t => t); |
|
167 |
|
168 fun postprocess_term thy = term_of_conv thy (postprocess_conv thy) #> resubst_triv_consts thy; |
165 |
169 |
166 fun print_codeproc thy = |
170 fun print_codeproc thy = |
167 let |
171 let |
168 val ctxt = ProofContext.init thy; |
172 val ctxt = ProofContext.init thy; |
169 val pre = (#pre o the_thmproc) thy; |
173 val pre = (#pre o the_thmproc) thy; |
493 prepare_sorts prep_sort t1 $ prepare_sorts prep_sort t2 |
497 prepare_sorts prep_sort t1 $ prepare_sorts prep_sort t2 |
494 | prepare_sorts prep_sort (Abs (v, ty, t)) = |
498 | prepare_sorts prep_sort (Abs (v, ty, t)) = |
495 Abs (v, prepare_sorts_typ prep_sort ty, prepare_sorts prep_sort t) |
499 Abs (v, prepare_sorts_typ prep_sort ty, prepare_sorts prep_sort t) |
496 | prepare_sorts _ (t as Bound _) = t; |
500 | prepare_sorts _ (t as Bound _) = t; |
497 |
501 |
498 fun gen_eval thy cterm_of conclude_evaluation prep_sort evaluator proto_ct = |
502 fun gen_eval thy cterm_of conclude_evaluation evaluator proto_ct = |
499 let |
503 let |
500 val pp = Syntax.pp_global thy; |
504 val pp = Syntax.pp_global thy; |
501 val ct = cterm_of proto_ct; |
505 val ct = cterm_of proto_ct; |
502 val _ = (Sign.no_frees pp o map_types (K dummyT) o Sign.no_vars pp) |
506 val _ = (Sign.no_frees pp o map_types (K dummyT) o Sign.no_vars pp) |
503 (Thm.term_of ct); |
507 (Thm.term_of ct); |
505 val ct' = Thm.rhs_of thm; |
509 val ct' = Thm.rhs_of thm; |
506 val t' = Thm.term_of ct'; |
510 val t' = Thm.term_of ct'; |
507 val vs = Term.add_tfrees t' []; |
511 val vs = Term.add_tfrees t' []; |
508 val consts = fold_aterms |
512 val consts = fold_aterms |
509 (fn Const (c, _) => insert (op =) c | _ => I) t' []; |
513 (fn Const (c, _) => insert (op =) c | _ => I) t' []; |
510 |
514 |
511 val t'' = prepare_sorts prep_sort t'; |
515 val add_triv_classes = curry (Sorts.inter_sort (Sign.classes_of thy)) |
|
516 (Code.triv_classes thy); |
|
517 val t'' = prepare_sorts add_triv_classes t'; |
512 val (algebra', eqngr') = obtain thy consts [t'']; |
518 val (algebra', eqngr') = obtain thy consts [t'']; |
513 in conclude_evaluation (evaluator algebra' eqngr' vs t'' ct') thm end; |
519 in conclude_evaluation (evaluator algebra' eqngr' vs t'' ct') thm end; |
514 |
520 |
515 fun simple_evaluator evaluator algebra eqngr vs t ct = |
521 fun simple_evaluator evaluator algebra eqngr vs t ct = |
516 evaluator algebra eqngr vs t; |
522 evaluator algebra eqngr vs t; |
525 error ("could not construct evaluation proof:\n" |
531 error ("could not construct evaluation proof:\n" |
526 ^ (cat_lines o map Display.string_of_thm) [thm1, thm2, thm3]) |
532 ^ (cat_lines o map Display.string_of_thm) [thm1, thm2, thm3]) |
527 end; |
533 end; |
528 in gen_eval thy I conclude_evaluation end; |
534 in gen_eval thy I conclude_evaluation end; |
529 |
535 |
530 fun eval thy prep_sort postproc evaluator = gen_eval thy (Thm.cterm_of thy) |
536 fun eval thy postproc evaluator = gen_eval thy (Thm.cterm_of thy) |
531 (K o postproc (postprocess_term thy)) prep_sort (simple_evaluator evaluator); |
537 (K o postproc (postprocess_term thy)) (simple_evaluator evaluator); |
532 |
538 |
533 |
539 |
534 (** setup **) |
540 (** setup **) |
535 |
541 |
536 val setup = |
542 val setup = |