| author | desharna | 
| Tue, 14 Oct 2014 16:17:34 +0200 | |
| changeset 58675 | 69571f0a93df | 
| parent 55628 | 8103021024c1 | 
| child 58823 | 513268cb2178 | 
| permissions | -rw-r--r-- | 
| 33265 | 1 | (* Title: HOL/Tools/Predicate_Compile/predicate_compile.ML | 
| 2 | Author: Lukas Bulwahn, TU Muenchen | |
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 3 | |
| 41941 | 4 | Entry point for the predicate compiler; definition of Toplevel | 
| 5 | commands code_pred and values. | |
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 6 | *) | 
| 33265 | 7 | |
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 8 | signature PREDICATE_COMPILE = | 
| 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 9 | sig | 
| 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 10 | val setup : theory -> theory | 
| 36050 
88203782cf12
activating the signature of Predicate_Compile again which was deactivated in changeset d93a3cb55068 for debugging purposes
 bulwahn parents: 
36032diff
changeset | 11 | val preprocess : Predicate_Compile_Aux.options -> term -> theory -> theory | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 12 | val present_graph : bool Unsynchronized.ref | 
| 36023 
d606ca1674a7
adding a hook for experiments in the predicate compilation process
 bulwahn parents: 
36022diff
changeset | 13 | val intro_hook : (theory -> thm -> unit) option Unsynchronized.ref | 
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 14 | end; | 
| 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 15 | |
| 36050 
88203782cf12
activating the signature of Predicate_Compile again which was deactivated in changeset d93a3cb55068 for debugging purposes
 bulwahn parents: 
36032diff
changeset | 16 | structure Predicate_Compile : PREDICATE_COMPILE = | 
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 17 | struct | 
| 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 18 | |
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 19 | val present_graph = Unsynchronized.ref false | 
| 33108 
9d9afd478016
added test for higher-order function inductification; added debug messages
 bulwahn parents: 
33107diff
changeset | 20 | |
| 36023 
d606ca1674a7
adding a hook for experiments in the predicate compilation process
 bulwahn parents: 
36022diff
changeset | 21 | val intro_hook = Unsynchronized.ref NONE : (theory -> thm -> unit) option Unsynchronized.ref | 
| 
d606ca1674a7
adding a hook for experiments in the predicate compilation process
 bulwahn parents: 
36022diff
changeset | 22 | |
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 23 | open Predicate_Compile_Aux; | 
| 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 24 | |
| 33125 | 25 | fun print_intross options thy msg intross = | 
| 26 | if show_intermediate_results options then | |
| 55437 | 27 | tracing (msg ^ | 
| 55628 | 28 | (cat_lines (map | 
| 33376 
5cb663aa48ee
predicate compiler creates code equations for predicates with full mode
 bulwahn parents: 
33375diff
changeset | 29 | (fn (c, intros) => "Introduction rule(s) of " ^ c ^ ":\n" ^ | 
| 
5cb663aa48ee
predicate compiler creates code equations for predicates with full mode
 bulwahn parents: 
33375diff
changeset | 30 | commas (map (Display.string_of_thm_global thy) intros)) intross))) | 
| 33125 | 31 | else () | 
| 55437 | 32 | |
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 33 | fun print_specs options thy specs = | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 34 | if show_intermediate_results options then | 
| 55437 | 35 | map (fn (c, thms) => | 
| 36 | "Constant " ^ c ^ " has specification:\n" ^ | |
| 55628 | 37 | (cat_lines (map (Display.string_of_thm_global thy) thms)) ^ "\n") specs | 
| 38 | |> cat_lines |> tracing | |
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 39 | else () | 
| 55437 | 40 | |
| 51685 
385ef6706252
more standard module name Axclass (according to file name);
 wenzelm parents: 
50056diff
changeset | 41 | fun overload_const thy s = the_default s (Option.map fst (Axclass.inst_of_param thy s)) | 
| 33404 | 42 | |
| 33146 
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
 bulwahn parents: 
33142diff
changeset | 43 | fun map_specs f specs = | 
| 
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
 bulwahn parents: 
33142diff
changeset | 44 | map (fn (s, ths) => (s, f ths)) specs | 
| 
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
 bulwahn parents: 
33142diff
changeset | 45 | |
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 46 | fun process_specification options specs thy' = | 
| 33121 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 bulwahn parents: 
33120diff
changeset | 47 | let | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 48 | val _ = print_step options "Compiling predicates to flat introrules..." | 
| 55437 | 49 | val specs = | 
| 50 | map | |
| 51 | (apsnd (map | |
| 52 | (fn th => | |
| 53 | if is_equationlike th then Predicate_Compile_Data.normalize_equation thy' th else th))) | |
| 54 | specs | |
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 55 | val (intross1, thy'') = | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 56 | apfst flat (fold_map (Predicate_Compile_Pred.preprocess options) specs thy') | 
| 33125 | 57 | val _ = print_intross options thy'' "Flattened introduction rules: " intross1 | 
| 33129 
3085da75ed54
changed import_intros to handle parameters differently; changed handling of higher-order function compilation; reverted MicroJava change; tuned
 bulwahn parents: 
33127diff
changeset | 58 | val _ = print_step options "Replacing functions in introrules..." | 
| 33121 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 bulwahn parents: 
33120diff
changeset | 59 | val intross2 = | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 60 | if function_flattening options then | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 61 | if fail_safe_function_flattening options then | 
| 55437 | 62 | (case try (map_specs (maps (Predicate_Compile_Fun.rewrite_intro thy''))) intross1 of | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 63 | SOME intross => intross | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 64 | | NONE => | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 65 | (if show_caught_failures options then tracing "Function replacement failed!" else (); | 
| 55437 | 66 | intross1)) | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 67 | else map_specs (maps (Predicate_Compile_Fun.rewrite_intro thy'')) intross1 | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 68 | else | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 69 | intross1 | 
| 33125 | 70 | val _ = print_intross options thy'' "Introduction rules with replaced functions: " intross2 | 
| 55437 | 71 | val _ = print_step options | 
| 72 | "Introducing new constants for abstractions at higher-order argument positions..." | |
| 73 | val (intross3, (new_defs, thy''')) = | |
| 74 | Predicate_Compile_Pred.flat_higher_order_arguments (intross2, thy'') | |
| 75 | val (new_intross, thy'''') = | |
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 76 | if not (null new_defs) then | 
| 33404 | 77 | let | 
| 55437 | 78 | val _ = | 
| 79 | print_step options "Recursively obtaining introduction rules for new definitions..." | |
| 33404 | 80 | in process_specification options new_defs thy''' end | 
| 81 | else ([], thy''') | |
| 33121 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 bulwahn parents: 
33120diff
changeset | 82 | in | 
| 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 bulwahn parents: 
33120diff
changeset | 83 | (intross3 @ new_intross, thy'''') | 
| 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 bulwahn parents: 
33120diff
changeset | 84 | end | 
| 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 bulwahn parents: 
33120diff
changeset | 85 | |
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 86 | fun preprocess_strong_conn_constnames options gr ts thy = | 
| 55437 | 87 | if forall (fn (Const (c, _)) => Core_Data.is_registered (Proof_Context.init_global thy) c) ts | 
| 88 | then thy | |
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 89 | else | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 90 | let | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 91 | fun get_specs ts = map_filter (fn t => | 
| 35404 | 92 | Term_Graph.get_node gr t |> | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 93 | (fn ths => if null ths then NONE else SOME (fst (dest_Const t), ths))) | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 94 | ts | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 95 |       val _ = print_step options ("Preprocessing scc of " ^
 | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 96 | commas (map (Syntax.string_of_term_global thy) ts)) | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 97 |       val (prednames, funnames) = List.partition (fn t => body_type (fastype_of t) = @{typ bool}) ts
 | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 98 | (* untangle recursion by defining predicates for all functions *) | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 99 | val _ = print_step options | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 100 |         ("Compiling functions (" ^ commas (map (Syntax.string_of_term_global thy) funnames) ^
 | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 101 | ") to predicates...") | 
| 36032 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 102 | val (fun_pred_specs, thy1) = | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 103 | (if function_flattening options andalso (not (null funnames)) then | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 104 | if fail_safe_function_flattening options then | 
| 55437 | 105 | (case try (Predicate_Compile_Fun.define_predicates (get_specs funnames)) thy of | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 106 | SOME (intross, thy) => (intross, thy) | 
| 55437 | 107 | | NONE => ([], thy)) | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 108 | else Predicate_Compile_Fun.define_predicates (get_specs funnames) thy | 
| 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 109 | else ([], thy)) | 
| 36032 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 110 | val _ = print_specs options thy1 fun_pred_specs | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 111 | val specs = (get_specs prednames) @ fun_pred_specs | 
| 36032 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 112 | val (intross3, thy2) = process_specification options specs thy1 | 
| 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 113 | val _ = print_intross options thy2 "Introduction rules with new constants: " intross3 | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 114 | val intross4 = map_specs (maps remove_pointless_clauses) intross3 | 
| 36032 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 115 | val _ = print_intross options thy2 "After removing pointless clauses: " intross4 | 
| 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 116 | val intross5 = map_specs (map (remove_equalities thy2)) intross4 | 
| 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 117 | val _ = print_intross options thy2 "After removing equality premises:" intross5 | 
| 36022 
c0fa8499e366
removing simple equalities in introduction rules in the predicate compiler
 bulwahn parents: 
36004diff
changeset | 118 | val intross6 = | 
| 51685 
385ef6706252
more standard module name Axclass (according to file name);
 wenzelm parents: 
50056diff
changeset | 119 | map (fn (s, ths) => (overload_const thy2 s, map (Axclass.overload thy2) ths)) intross5 | 
| 36032 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 120 | val intross7 = map_specs (map (expand_tuples thy2)) intross6 | 
| 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 121 | val intross8 = map_specs (map (eta_contract_ho_arguments thy2)) intross7 | 
| 55437 | 122 | val _ = (case !intro_hook of NONE => () | SOME f => (map_specs (map (f thy2)) intross8; ())) | 
| 123 | val _ = | |
| 124 |         print_step options ("Looking for specialisations in " ^ commas (map fst intross8) ^ "...")
 | |
| 36248 
9ed1a37de465
added option for specialisation to the predicate compiler
 bulwahn parents: 
36246diff
changeset | 125 | val (intross9, thy3) = | 
| 
9ed1a37de465
added option for specialisation to the predicate compiler
 bulwahn parents: 
36246diff
changeset | 126 | if specialise options then | 
| 
9ed1a37de465
added option for specialisation to the predicate compiler
 bulwahn parents: 
36246diff
changeset | 127 | Predicate_Compile_Specialisation.find_specialisations [] intross8 thy2 | 
| 
9ed1a37de465
added option for specialisation to the predicate compiler
 bulwahn parents: 
36246diff
changeset | 128 | else (intross8, thy2) | 
| 36246 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 bulwahn parents: 
36050diff
changeset | 129 | val _ = print_intross options thy3 "introduction rules after specialisations: " intross9 | 
| 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 bulwahn parents: 
36050diff
changeset | 130 | val intross10 = map_specs (map_filter (peephole_optimisation thy3)) intross9 | 
| 
43fecedff8cf
added peephole optimisations to the predicate compiler; added structure Predicate_Compile_Simps for peephole optimisations
 bulwahn parents: 
36050diff
changeset | 131 | val _ = print_intross options thy3 "introduction rules before registering: " intross10 | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 132 | val _ = print_step options "Registering introduction rules..." | 
| 40053 
3fa49ea76cbb
using a signature in core_data and moving some more functions to core_data
 bulwahn parents: 
40048diff
changeset | 133 | val thy4 = fold Core_Data.register_intros intross10 thy3 | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 134 | in | 
| 36032 
dfd30b5b4e73
adding specialisation of predicates to the predicate compiler
 bulwahn parents: 
36027diff
changeset | 135 | thy4 | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 136 | end; | 
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 137 | |
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 138 | fun preprocess options t thy = | 
| 32672 
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
 bulwahn parents: 
32669diff
changeset | 139 | let | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 140 | val _ = print_step options "Fetching definitions from theory..." | 
| 55437 | 141 | val gr = | 
| 142 | cond_timeit (Config.get_global thy Quickcheck.timing) "preprocess-obtain graph" | |
| 143 | (fn () => | |
| 144 | Predicate_Compile_Data.obtain_specification_graph options thy t | |
| 46614 
165886a4fe64
clarified Graph.restrict (formerly Graph.subgraph) based on public graph operations;
 wenzelm parents: 
42361diff
changeset | 145 | |> (fn gr => Term_Graph.restrict (member (op =) (Term_Graph.all_succs gr [t])) gr)) | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 146 | val _ = if !present_graph then Predicate_Compile_Data.present_graph gr else () | 
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 147 | in | 
| 42088 
8d00484551fe
making quickcheck's result value more formal; allowing more result information to be returned after timeout; adding output of timing information in quickcheck
 bulwahn parents: 
42011diff
changeset | 148 | cond_timeit (Config.get_global thy Quickcheck.timing) "preprocess-process" | 
| 55437 | 149 | (fn () => | 
| 150 | fold_rev (preprocess_strong_conn_constnames options gr) | |
| 151 | (Term_Graph.strong_conn gr) thy) | |
| 32672 
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
 bulwahn parents: 
32669diff
changeset | 152 | end | 
| 
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
 bulwahn parents: 
32669diff
changeset | 153 | |
| 39382 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 154 | datatype proposed_modes = Multiple_Preds of (string * (mode * string option) list) list | 
| 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 155 | | Single_Pred of (mode * string option) list | 
| 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 156 | |
| 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 157 | fun extract_options lthy (((expected_modes, proposed_modes), (compilation, raw_options)), const) = | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 158 | let | 
| 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 159 | fun chk s = member (op =) raw_options s | 
| 55437 | 160 | val proposed_modes = | 
| 161 | (case proposed_modes of | |
| 162 | Single_Pred proposed_modes => [(const, proposed_modes)] | |
| 163 | | Multiple_Preds proposed_modes => | |
| 164 | map (apfst (Code.read_const (Proof_Context.theory_of lthy))) proposed_modes) | |
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 165 | in | 
| 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 166 |     Options {
 | 
| 33623 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 bulwahn parents: 
33620diff
changeset | 167 | expected_modes = Option.map (pair const) expected_modes, | 
| 55437 | 168 | proposed_modes = | 
| 39382 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 169 | map (apsnd (map fst)) proposed_modes, | 
| 33623 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 bulwahn parents: 
33620diff
changeset | 170 | proposed_names = | 
| 39382 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 171 | maps (fn (predname, ms) => (map_filter | 
| 50056 | 172 | (fn (_, NONE) => NONE | (m, SOME name) => SOME ((predname, m), name))) ms) proposed_modes, | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 173 | show_steps = chk "show_steps", | 
| 33125 | 174 | show_intermediate_results = chk "show_intermediate_results", | 
| 33127 | 175 | show_proof_trace = chk "show_proof_trace", | 
| 33251 | 176 | show_modes = chk "show_modes", | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 177 | show_mode_inference = chk "show_mode_inference", | 
| 33139 
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
 bulwahn parents: 
33134diff
changeset | 178 | show_compilation = chk "show_compilation", | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 179 | show_caught_failures = false, | 
| 39383 
ddfafa97da2f
adding option show_invalid_clauses for a more detailed message when modes are not inferred
 bulwahn parents: 
39382diff
changeset | 180 | show_invalid_clauses = chk "show_invalid_clauses", | 
| 33139 
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
 bulwahn parents: 
33134diff
changeset | 181 | skip_proof = chk "skip_proof", | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 182 | function_flattening = not (chk "no_function_flattening"), | 
| 36248 
9ed1a37de465
added option for specialisation to the predicate compiler
 bulwahn parents: 
36246diff
changeset | 183 | specialise = chk "specialise", | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 184 | fail_safe_function_flattening = false, | 
| 35381 
5038f36b5ea1
adding no_topmost_reordering as new option to the code_pred command
 bulwahn parents: 
35324diff
changeset | 185 | no_topmost_reordering = (chk "no_topmost_reordering"), | 
| 35324 
c9f428269b38
adopting mutabelle and quickcheck to return timing information; exporting make_case_combs in datatype package for predicate compiler; adding Spec_Rules declaration for tail recursive functions; improving the predicate compiler and function flattening
 bulwahn parents: 
34948diff
changeset | 186 | no_higher_order_predicate = [], | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 187 | inductify = chk "inductify", | 
| 36254 | 188 | detect_switches = chk "detect_switches", | 
| 40048 
f3a46d524101
adding option smart_depth_limiting to predicate compiler
 bulwahn parents: 
39383diff
changeset | 189 | smart_depth_limiting = chk "smart_depth_limiting", | 
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 190 | compilation = compilation | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 191 | } | 
| 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 192 | end | 
| 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 193 | |
| 33623 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 bulwahn parents: 
33620diff
changeset | 194 | fun code_pred_cmd (((expected_modes, proposed_modes), raw_options), raw_const) lthy = | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 195 | let | 
| 42361 | 196 | val thy = Proof_Context.theory_of lthy | 
| 33132 
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
 bulwahn parents: 
33131diff
changeset | 197 | val const = Code.read_const thy raw_const | 
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 198 | val T = Sign.the_const_type thy const | 
| 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 199 | val t = Const (const, T) | 
| 39382 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 200 | val options = extract_options lthy (((expected_modes, proposed_modes), raw_options), const) | 
| 33132 
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
 bulwahn parents: 
33131diff
changeset | 201 | in | 
| 38757 
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
 wenzelm parents: 
38664diff
changeset | 202 | if is_inductify options then | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 203 | let | 
| 38757 
2b3e054ae6fc
renamed Local_Theory.theory(_result) to Local_Theory.background_theory(_result) to emphasize that this belongs to the infrastructure and is rarely appropriate in user-space tools;
 wenzelm parents: 
38664diff
changeset | 204 | val lthy' = Local_Theory.background_theory (preprocess options t) lthy | 
| 33623 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 bulwahn parents: 
33620diff
changeset | 205 | val const = | 
| 55437 | 206 | (case Predicate_Compile_Fun.pred_of_function (Proof_Context.theory_of lthy') const of | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 207 | SOME c => c | 
| 55437 | 208 | | NONE => const) | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 209 | val _ = print_step options "Starting Predicate Compile Core..." | 
| 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 210 | in | 
| 33132 
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
 bulwahn parents: 
33131diff
changeset | 211 | Predicate_Compile_Core.code_pred options const lthy' | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 212 | end | 
| 55437 | 213 | else Predicate_Compile_Core.code_pred_cmd options raw_const lthy | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 214 | end | 
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 215 | |
| 33630 
68e058d061f5
removed unnecessary oracle in the predicate compiler
 bulwahn parents: 
33625diff
changeset | 216 | val setup = Predicate_Compile_Core.setup | 
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 217 | |
| 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 218 | |
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 219 | (* Parser for mode annotations *) | 
| 33327 | 220 | |
| 33625 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 bulwahn parents: 
33623diff
changeset | 221 | fun parse_mode_basic_expr xs = | 
| 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 bulwahn parents: 
33623diff
changeset | 222 | (Args.$$$ "i" >> K Input || Args.$$$ "o" >> K Output || | 
| 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 bulwahn parents: 
33623diff
changeset | 223 |     Args.$$$ "bool" >> K Bool || Args.$$$ "(" |-- parse_mode_expr --| Args.$$$ ")") xs
 | 
| 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 bulwahn parents: 
33623diff
changeset | 224 | and parse_mode_tuple_expr xs = | 
| 55437 | 225 | (parse_mode_basic_expr --| (Args.$$$ "*" || Args.$$$ "\<times>") -- parse_mode_tuple_expr >> Pair || | 
| 226 | parse_mode_basic_expr) xs | |
| 33625 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 bulwahn parents: 
33623diff
changeset | 227 | and parse_mode_expr xs = | 
| 55437 | 228 | (parse_mode_tuple_expr --| (Args.$$$ "=>" || Args.$$$ "\<Rightarrow>") -- parse_mode_expr >> Fun || | 
| 229 | parse_mode_tuple_expr) xs | |
| 33619 
d93a3cb55068
first steps towards a new mode datastructure; new syntax for mode annotations and new output of modes
 bulwahn parents: 
33481diff
changeset | 230 | |
| 33625 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 bulwahn parents: 
33623diff
changeset | 231 | val mode_and_opt_proposal = parse_mode_expr -- | 
| 36960 
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
 wenzelm parents: 
36254diff
changeset | 232 | Scan.optional (Args.$$$ "as" |-- Parse.xname >> SOME) NONE | 
| 33620 
b6bf2dc5aed7
added interface of user proposals for names of generated constants
 bulwahn parents: 
33619diff
changeset | 233 | |
| 39382 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 234 | |
| 33114 
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
 bulwahn parents: 
33113diff
changeset | 235 | val opt_modes = | 
| 46949 | 236 |   Scan.optional (@{keyword "("} |-- Args.$$$ "modes" |-- @{keyword ":"} |--
 | 
| 237 |     (((Parse.enum1 "and" (Parse.xname --| @{keyword ":"} --
 | |
| 39382 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 238 | (Parse.enum "," mode_and_opt_proposal))) >> Multiple_Preds) | 
| 
c797f3ab2ae1
proposed modes for code_pred now supports modes for mutual predicates
 bulwahn parents: 
38757diff
changeset | 239 | || ((Parse.enum "," mode_and_opt_proposal) >> Single_Pred)) | 
| 46949 | 240 |     --| @{keyword ")"}) (Multiple_Preds [])
 | 
| 33623 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 bulwahn parents: 
33620diff
changeset | 241 | |
| 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 bulwahn parents: 
33620diff
changeset | 242 | val opt_expected_modes = | 
| 46949 | 243 |   Scan.optional (@{keyword "("} |-- Args.$$$ "expected_modes" |-- @{keyword ":"} |--
 | 
| 244 |     Parse.enum "," parse_mode_expr --| @{keyword ")"} >> SOME) NONE
 | |
| 33114 
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
 bulwahn parents: 
33113diff
changeset | 245 | |
| 55437 | 246 | |
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 247 | (* Parser for options *) | 
| 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 248 | |
| 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 249 | val scan_options = | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 250 | let | 
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 251 | val scan_bool_option = foldl1 (op ||) (map Args.$$$ bool_options) | 
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 252 | val scan_compilation = foldl1 (op ||) (map (fn (s, c) => Args.$$$ s >> K c) compilation_names) | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 253 | in | 
| 46949 | 254 |     Scan.optional (@{keyword "["} |-- Scan.optional scan_compilation Pred
 | 
| 255 |       -- Parse.enum "," scan_bool_option --| @{keyword "]"})
 | |
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 256 | (Pred, []) | 
| 33123 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 257 | end | 
| 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 bulwahn parents: 
33122diff
changeset | 258 | |
| 36960 
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
 wenzelm parents: 
36254diff
changeset | 259 | val opt_print_modes = | 
| 55437 | 260 |   Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) []
 | 
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 261 | |
| 46949 | 262 | val opt_mode = (Args.$$$ "_" >> K NONE) || (parse_mode_expr >> SOME) | 
| 33479 
428ddcc16e7b
added optional mode annotations for parameters in the values command
 bulwahn parents: 
33478diff
changeset | 263 | |
| 46949 | 264 | val opt_param_modes = Scan.optional (@{keyword "["} |-- Args.$$$ "mode" |-- @{keyword ":"} |--
 | 
| 265 |   Parse.enum ", " opt_mode --| @{keyword "]"} >> SOME) NONE
 | |
| 33479 
428ddcc16e7b
added optional mode annotations for parameters in the values command
 bulwahn parents: 
33478diff
changeset | 266 | |
| 36027 
29a15da9c63d
added statistics to values command for random generation
 bulwahn parents: 
36023diff
changeset | 267 | val stats = Scan.optional (Args.$$$ "stats" >> K true) false | 
| 
29a15da9c63d
added statistics to values command for random generation
 bulwahn parents: 
36023diff
changeset | 268 | |
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 269 | val value_options = | 
| 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 270 | let | 
| 36960 
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
 wenzelm parents: 
36254diff
changeset | 271 | val expected_values = Scan.optional (Args.$$$ "expected" |-- Parse.term >> SOME) NONE | 
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 272 | val scan_compilation = | 
| 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 273 | Scan.optional | 
| 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 274 | (foldl1 (op ||) | 
| 36960 
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
 wenzelm parents: 
36254diff
changeset | 275 | (map (fn (s, c) => Args.$$$ s -- Parse.enum "," Parse.int >> (fn (_, ps) => (c, ps))) | 
| 34948 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 276 | compilation_names)) | 
| 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 bulwahn parents: 
33752diff
changeset | 277 | (Pred, []) | 
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 278 | in | 
| 36960 
01594f816e3a
prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
 wenzelm parents: 
36254diff
changeset | 279 | Scan.optional | 
| 46949 | 280 |       (@{keyword "["} |-- (expected_values -- stats) -- scan_compilation --| @{keyword "]"})
 | 
| 36027 
29a15da9c63d
added statistics to values command for random generation
 bulwahn parents: 
36023diff
changeset | 281 | ((NONE, false), (Pred, [])) | 
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 282 | end | 
| 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 283 | |
| 55437 | 284 | |
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 285 | (* code_pred command and values command *) | 
| 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 286 | |
| 46961 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 287 | val _ = | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 288 |   Outer_Syntax.local_theory_to_proof @{command_spec "code_pred"}
 | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 289 | "prove equations for predicate specified by intro/elim rules" | 
| 52801 | 290 | (opt_expected_modes -- opt_modes -- scan_options -- Parse.term >> code_pred_cmd) | 
| 33478 
b70fe083694d
moved values command from core to predicate compile
 bulwahn parents: 
33475diff
changeset | 291 | |
| 46961 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 292 | val _ = | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 293 |   Outer_Syntax.improper_command @{command_spec "values"}
 | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 294 | "enumerate and print comprehensions" | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 295 | (opt_print_modes -- opt_param_modes -- value_options -- Scan.optional Parse.nat ~1 -- Parse.term | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 296 | >> (fn ((((print_modes, param_modes), options), k), t) => Toplevel.keep | 
| 
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
 wenzelm parents: 
46949diff
changeset | 297 | (Predicate_Compile_Core.values_cmd print_modes param_modes options k t))) | 
| 32668 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 298 | |
| 
b2de45007537
added first prototype of the extended predicate compiler
 bulwahn parents: diff
changeset | 299 | end |