| author | bulwahn | 
| Thu, 25 Feb 2010 15:36:38 +0100 | |
| changeset 35381 | 5038f36b5ea1 | 
| parent 35324 | c9f428269b38 | 
| child 35404 | de56579ae229 | 
| 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  | 
|
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
4  | 
Entry point for the predicate compiler; definition of Toplevel commands code_pred and values  | 
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
5  | 
*)  | 
| 33265 | 6  | 
|
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
7  | 
signature PREDICATE_COMPILE =  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
8  | 
sig  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
9  | 
val setup : theory -> theory  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
10  | 
val preprocess : Predicate_Compile_Aux.options -> string -> 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: 
34948 
diff
changeset
 | 
11  | 
val present_graph : bool Unsynchronized.ref  | 
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
12  | 
end;  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
13  | 
|
| 
33619
 
d93a3cb55068
first steps towards a new mode datastructure; new syntax for mode annotations and new output of modes
 
bulwahn 
parents: 
33481 
diff
changeset
 | 
14  | 
structure Predicate_Compile (*: PREDICATE_COMPILE*) =  | 
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
15  | 
struct  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
16  | 
|
| 
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: 
34948 
diff
changeset
 | 
17  | 
val present_graph = Unsynchronized.ref false  | 
| 
33108
 
9d9afd478016
added test for higher-order function inductification; added debug messages
 
bulwahn 
parents: 
33107 
diff
changeset
 | 
18  | 
|
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
19  | 
open Predicate_Compile_Aux;  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
20  | 
|
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
21  | 
(* Some last processing *)  | 
| 33113 | 22  | 
|
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
23  | 
fun remove_pointless_clauses intro =  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
24  | 
  if Logic.strip_imp_prems (prop_of intro) = [@{prop "False"}] then
 | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
25  | 
[]  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
26  | 
else [intro]  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
27  | 
|
| 33125 | 28  | 
fun print_intross options thy msg intross =  | 
29  | 
if show_intermediate_results options then  | 
|
| 
33376
 
5cb663aa48ee
predicate compiler creates code equations for predicates with full mode
 
bulwahn 
parents: 
33375 
diff
changeset
 | 
30  | 
tracing (msg ^  | 
| 
 
5cb663aa48ee
predicate compiler creates code equations for predicates with full mode
 
bulwahn 
parents: 
33375 
diff
changeset
 | 
31  | 
(space_implode "\n" (map  | 
| 
 
5cb663aa48ee
predicate compiler creates code equations for predicates with full mode
 
bulwahn 
parents: 
33375 
diff
changeset
 | 
32  | 
(fn (c, intros) => "Introduction rule(s) of " ^ c ^ ":\n" ^  | 
| 
 
5cb663aa48ee
predicate compiler creates code equations for predicates with full mode
 
bulwahn 
parents: 
33375 
diff
changeset
 | 
33  | 
commas (map (Display.string_of_thm_global thy) intros)) intross)))  | 
| 33125 | 34  | 
else ()  | 
35  | 
||
| 
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: 
34948 
diff
changeset
 | 
36  | 
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: 
34948 
diff
changeset
 | 
37  | 
if show_intermediate_results 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: 
34948 
diff
changeset
 | 
38  | 
map (fn (c, thms) => "Constant " ^ c ^ " has specification:\n"  | 
| 
 
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: 
34948 
diff
changeset
 | 
39  | 
^ (space_implode "\n" (map (Display.string_of_thm_global thy) thms)) ^ "\n") 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: 
34948 
diff
changeset
 | 
40  | 
|> space_implode "\n" |> tracing  | 
| 
 
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: 
34948 
diff
changeset
 | 
41  | 
else ()  | 
| 
33475
 
42fed8eac357
improved handling of overloaded constants; examples with numerals
 
bulwahn 
parents: 
33473 
diff
changeset
 | 
42  | 
fun overload_const thy s = the_default s (Option.map fst (AxClass.inst_of_param thy s))  | 
| 33404 | 43  | 
|
| 
33146
 
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
 
bulwahn 
parents: 
33142 
diff
changeset
 | 
44  | 
fun map_specs f specs =  | 
| 
 
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
 
bulwahn 
parents: 
33142 
diff
changeset
 | 
45  | 
map (fn (s, ths) => (s, f ths)) specs  | 
| 
 
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
 
bulwahn 
parents: 
33142 
diff
changeset
 | 
46  | 
|
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
47  | 
fun process_specification options specs thy' =  | 
| 
33121
 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 
bulwahn 
parents: 
33120 
diff
changeset
 | 
48  | 
let  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
49  | 
val _ = print_step options "Compiling predicates to flat introrules..."  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
50  | 
val specs = map (apsnd (map  | 
| 
33140
 
83951822bfd0
cleaning the signature of the predicate compiler core; renaming signature and structures to uniform long names
 
bulwahn 
parents: 
33139 
diff
changeset
 | 
51  | 
(fn th => if is_equationlike th then Predicate_Compile_Data.normalize_equation thy' th else th))) 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: 
34948 
diff
changeset
 | 
52  | 
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: 
34948 
diff
changeset
 | 
53  | 
apfst flat (fold_map (Predicate_Compile_Pred.preprocess options) specs thy')  | 
| 33125 | 54  | 
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: 
33127 
diff
changeset
 | 
55  | 
val _ = print_step options "Replacing functions in introrules..."  | 
| 
33121
 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 
bulwahn 
parents: 
33120 
diff
changeset
 | 
56  | 
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: 
34948 
diff
changeset
 | 
57  | 
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: 
34948 
diff
changeset
 | 
58  | 
if fail_safe_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: 
34948 
diff
changeset
 | 
59  | 
case try (map_specs (maps (Predicate_Compile_Fun.rewrite_intro thy''))) intross1 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: 
34948 
diff
changeset
 | 
60  | 
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: 
34948 
diff
changeset
 | 
61  | 
| 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: 
34948 
diff
changeset
 | 
62  | 
(if show_caught_failures options then tracing "Function replacement failed!" 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: 
34948 
diff
changeset
 | 
63  | 
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: 
34948 
diff
changeset
 | 
64  | 
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: 
34948 
diff
changeset
 | 
65  | 
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: 
34948 
diff
changeset
 | 
66  | 
intross1  | 
| 33125 | 67  | 
val _ = print_intross options thy'' "Introduction rules with replaced functions: " intross2  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
68  | 
val _ = print_step options "Introducing new constants for abstractions at higher-order argument positions..."  | 
| 
33121
 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 
bulwahn 
parents: 
33120 
diff
changeset
 | 
69  | 
val (intross3, (new_defs, thy''')) = Predicate_Compile_Pred.flat_higher_order_arguments (intross2, thy'')  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
70  | 
val (new_intross, thy'''') =  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
71  | 
if not (null new_defs) then  | 
| 33404 | 72  | 
let  | 
73  | 
val _ = print_step options "Recursively obtaining introduction rules for new definitions..."  | 
|
74  | 
in process_specification options new_defs thy''' end  | 
|
75  | 
else ([], thy''')  | 
|
| 
33121
 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 
bulwahn 
parents: 
33120 
diff
changeset
 | 
76  | 
in  | 
| 
 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 
bulwahn 
parents: 
33120 
diff
changeset
 | 
77  | 
(intross3 @ new_intross, thy'''')  | 
| 
 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 
bulwahn 
parents: 
33120 
diff
changeset
 | 
78  | 
end  | 
| 
 
9b10dc5da0e0
added to process higher-order arguments by adding new constants
 
bulwahn 
parents: 
33120 
diff
changeset
 | 
79  | 
|
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
80  | 
fun preprocess_strong_conn_constnames options gr ts 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: 
34948 
diff
changeset
 | 
81  | 
if forall (fn (Const (c, _)) => Predicate_Compile_Core.is_registered thy c) ts 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: 
34948 
diff
changeset
 | 
82  | 
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: 
34948 
diff
changeset
 | 
83  | 
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: 
34948 
diff
changeset
 | 
84  | 
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: 
34948 
diff
changeset
 | 
85  | 
fun get_specs ts = map_filter (fn t =>  | 
| 
 
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: 
34948 
diff
changeset
 | 
86  | 
TermGraph.get_node gr t |>  | 
| 
 
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: 
34948 
diff
changeset
 | 
87  | 
(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: 
34948 
diff
changeset
 | 
88  | 
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: 
34948 
diff
changeset
 | 
89  | 
      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: 
34948 
diff
changeset
 | 
90  | 
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: 
34948 
diff
changeset
 | 
91  | 
      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: 
34948 
diff
changeset
 | 
92  | 
(* 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: 
34948 
diff
changeset
 | 
93  | 
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: 
34948 
diff
changeset
 | 
94  | 
        ("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: 
34948 
diff
changeset
 | 
95  | 
") to predicates...")  | 
| 
 
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: 
34948 
diff
changeset
 | 
96  | 
val (fun_pred_specs, 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: 
34948 
diff
changeset
 | 
97  | 
(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: 
34948 
diff
changeset
 | 
98  | 
if fail_safe_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: 
34948 
diff
changeset
 | 
99  | 
case try (Predicate_Compile_Fun.define_predicates (get_specs funnames)) thy 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: 
34948 
diff
changeset
 | 
100  | 
SOME (intross, thy) => (intross, 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: 
34948 
diff
changeset
 | 
101  | 
| NONE => ([], 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: 
34948 
diff
changeset
 | 
102  | 
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: 
34948 
diff
changeset
 | 
103  | 
else ([], 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: 
34948 
diff
changeset
 | 
104  | 
(*||> Theory.checkpoint*)  | 
| 
 
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: 
34948 
diff
changeset
 | 
105  | 
val _ = print_specs options thy' fun_pred_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: 
34948 
diff
changeset
 | 
106  | 
val specs = (get_specs prednames) @ fun_pred_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: 
34948 
diff
changeset
 | 
107  | 
val (intross3, thy''') = process_specification options specs 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: 
34948 
diff
changeset
 | 
108  | 
val _ = print_intross options thy''' "Introduction rules with new constants: " intross3  | 
| 
 
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: 
34948 
diff
changeset
 | 
109  | 
val intross4 = map_specs (maps remove_pointless_clauses) intross3  | 
| 
 
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: 
34948 
diff
changeset
 | 
110  | 
val _ = print_intross options thy''' "After removing pointless clauses: " intross4  | 
| 
 
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: 
34948 
diff
changeset
 | 
111  | 
val intross5 =  | 
| 
 
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: 
34948 
diff
changeset
 | 
112  | 
map (fn (s, ths) => (overload_const thy''' s, map (AxClass.overload thy''') ths)) intross4  | 
| 
 
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: 
34948 
diff
changeset
 | 
113  | 
val intross6 = map_specs (map (expand_tuples thy''')) intross5  | 
| 
 
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: 
34948 
diff
changeset
 | 
114  | 
val _ = print_intross options thy''' "introduction rules before registering: " intross6  | 
| 
 
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: 
34948 
diff
changeset
 | 
115  | 
val _ = print_step options "Registering introduction rules..."  | 
| 
 
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: 
34948 
diff
changeset
 | 
116  | 
val thy'''' = fold Predicate_Compile_Core.register_intros intross6 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: 
34948 
diff
changeset
 | 
117  | 
in  | 
| 
 
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: 
34948 
diff
changeset
 | 
118  | 
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: 
34948 
diff
changeset
 | 
119  | 
end;  | 
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
120  | 
|
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
121  | 
fun preprocess options t thy =  | 
| 
32672
 
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
 
bulwahn 
parents: 
32669 
diff
changeset
 | 
122  | 
let  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
123  | 
val _ = print_step options "Fetching definitions from theory..."  | 
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
124  | 
val gr = Output.cond_timeit (!Quickcheck.timing) "preprocess-obtain graph"  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
125  | 
(fn () => Predicate_Compile_Data.obtain_specification_graph options thy t  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
126  | 
|> (fn gr => TermGraph.subgraph (member (op =) (TermGraph.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: 
34948 
diff
changeset
 | 
127  | 
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: 
33752 
diff
changeset
 | 
128  | 
in  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
129  | 
Output.cond_timeit (!Quickcheck.timing) "preprocess-process"  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
130  | 
(fn () => (fold_rev (preprocess_strong_conn_constnames options gr)  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
131  | 
(TermGraph.strong_conn gr) thy))  | 
| 
32672
 
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
 
bulwahn 
parents: 
32669 
diff
changeset
 | 
132  | 
end  | 
| 
 
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
 
bulwahn 
parents: 
32669 
diff
changeset
 | 
133  | 
|
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
134  | 
fun extract_options (((expected_modes, proposed_modes), (compilation, raw_options)), const) =  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
135  | 
let  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
136  | 
fun chk s = member (op =) raw_options s  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
137  | 
in  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
138  | 
    Options {
 | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
139  | 
expected_modes = Option.map (pair const) expected_modes,  | 
| 
33752
 
9aa8e961f850
adopting proposed_modes; adding a new dimension of complexity for nicer error messages; tuned
 
bulwahn 
parents: 
33671 
diff
changeset
 | 
140  | 
proposed_modes = Option.map (pair const o map fst) proposed_modes,  | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
141  | 
proposed_names =  | 
| 
33752
 
9aa8e961f850
adopting proposed_modes; adding a new dimension of complexity for nicer error messages; tuned
 
bulwahn 
parents: 
33671 
diff
changeset
 | 
142  | 
the_default [] (Option.map (map_filter  | 
| 
 
9aa8e961f850
adopting proposed_modes; adding a new dimension of complexity for nicer error messages; tuned
 
bulwahn 
parents: 
33671 
diff
changeset
 | 
143  | 
(fn (m, NONE) => NONE | (m, SOME name) => SOME ((const, m), name))) proposed_modes),  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
144  | 
show_steps = chk "show_steps",  | 
| 33125 | 145  | 
show_intermediate_results = chk "show_intermediate_results",  | 
| 33127 | 146  | 
show_proof_trace = chk "show_proof_trace",  | 
| 33251 | 147  | 
show_modes = chk "show_modes",  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
148  | 
show_mode_inference = chk "show_mode_inference",  | 
| 
33139
 
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
 
bulwahn 
parents: 
33134 
diff
changeset
 | 
149  | 
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: 
34948 
diff
changeset
 | 
150  | 
show_caught_failures = false,  | 
| 
33139
 
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
 
bulwahn 
parents: 
33134 
diff
changeset
 | 
151  | 
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: 
34948 
diff
changeset
 | 
152  | 
function_flattening = not (chk "no_function_flattening"),  | 
| 
 
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: 
34948 
diff
changeset
 | 
153  | 
fail_safe_function_flattening = false,  | 
| 
35381
 
5038f36b5ea1
adding no_topmost_reordering as new option to the code_pred command
 
bulwahn 
parents: 
35324 
diff
changeset
 | 
154  | 
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: 
34948 
diff
changeset
 | 
155  | 
no_higher_order_predicate = [],  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
156  | 
inductify = chk "inductify",  | 
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
157  | 
compilation = compilation  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
158  | 
}  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
159  | 
end  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
160  | 
|
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
161  | 
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: 
33122 
diff
changeset
 | 
162  | 
let  | 
| 
33132
 
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
 
bulwahn 
parents: 
33131 
diff
changeset
 | 
163  | 
val thy = ProofContext.theory_of lthy  | 
| 
 
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
 
bulwahn 
parents: 
33131 
diff
changeset
 | 
164  | 
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: 
33752 
diff
changeset
 | 
165  | 
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: 
33752 
diff
changeset
 | 
166  | 
val t = Const (const, T)  | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
167  | 
val options = extract_options (((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: 
33131 
diff
changeset
 | 
168  | 
in  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
169  | 
if (is_inductify options) then  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
170  | 
let  | 
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
171  | 
val lthy' = Local_Theory.theory (preprocess options t) lthy  | 
| 33671 | 172  | 
|> Local_Theory.checkpoint  | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
173  | 
val const =  | 
| 
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
174  | 
case Predicate_Compile_Fun.pred_of_function (ProofContext.theory_of lthy') const of  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
175  | 
SOME c => c  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
176  | 
| NONE => const  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
177  | 
val _ = print_step options "Starting Predicate Compile Core..."  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
178  | 
in  | 
| 
33132
 
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
 
bulwahn 
parents: 
33131 
diff
changeset
 | 
179  | 
Predicate_Compile_Core.code_pred options const lthy'  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
180  | 
end  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
181  | 
else  | 
| 
33132
 
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
 
bulwahn 
parents: 
33131 
diff
changeset
 | 
182  | 
Predicate_Compile_Core.code_pred_cmd options raw_const lthy  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
183  | 
end  | 
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
184  | 
|
| 
33630
 
68e058d061f5
removed unnecessary oracle in the predicate compiler
 
bulwahn 
parents: 
33625 
diff
changeset
 | 
185  | 
val setup = Predicate_Compile_Core.setup  | 
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
186  | 
|
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
187  | 
local structure P = OuterParse  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
188  | 
in  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
189  | 
|
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
190  | 
(* Parser for mode annotations *)  | 
| 33327 | 191  | 
|
| 
33625
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
192  | 
fun parse_mode_basic_expr xs =  | 
| 
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
193  | 
(Args.$$$ "i" >> K Input || Args.$$$ "o" >> K Output ||  | 
| 
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
194  | 
    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: 
33623 
diff
changeset
 | 
195  | 
and parse_mode_tuple_expr xs =  | 
| 
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
196  | 
(parse_mode_basic_expr --| Args.$$$ "*" -- parse_mode_tuple_expr >> Pair || parse_mode_basic_expr)  | 
| 
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
197  | 
xs  | 
| 
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
198  | 
and parse_mode_expr xs =  | 
| 
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
199  | 
(parse_mode_tuple_expr --| Args.$$$ "=>" -- parse_mode_expr >> Fun || 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: 
33481 
diff
changeset
 | 
200  | 
|
| 
33625
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
201  | 
val mode_and_opt_proposal = parse_mode_expr --  | 
| 
33620
 
b6bf2dc5aed7
added interface of user proposals for names of generated constants
 
bulwahn 
parents: 
33619 
diff
changeset
 | 
202  | 
Scan.optional (Args.$$$ "as" |-- P.xname >> SOME) NONE  | 
| 
 
b6bf2dc5aed7
added interface of user proposals for names of generated constants
 
bulwahn 
parents: 
33619 
diff
changeset
 | 
203  | 
|
| 
33114
 
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
 
bulwahn 
parents: 
33113 
diff
changeset
 | 
204  | 
val opt_modes =  | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
205  | 
  Scan.optional (P.$$$ "(" |-- Args.$$$ "modes" |-- P.$$$ ":" |--
 | 
| 
33752
 
9aa8e961f850
adopting proposed_modes; adding a new dimension of complexity for nicer error messages; tuned
 
bulwahn 
parents: 
33671 
diff
changeset
 | 
206  | 
P.enum "," mode_and_opt_proposal --| P.$$$ ")" >> SOME) NONE  | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
207  | 
|
| 
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
208  | 
val opt_expected_modes =  | 
| 
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
209  | 
  Scan.optional (P.$$$ "(" |-- Args.$$$ "expected_modes" |-- P.$$$ ":" |--
 | 
| 
33625
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
210  | 
P.enum "," parse_mode_expr --| P.$$$ ")" >> SOME) NONE  | 
| 
33114
 
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
 
bulwahn 
parents: 
33113 
diff
changeset
 | 
211  | 
|
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
212  | 
(* Parser for options *)  | 
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
213  | 
|
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
214  | 
val scan_options =  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
215  | 
let  | 
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
216  | 
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: 
33752 
diff
changeset
 | 
217  | 
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: 
33122 
diff
changeset
 | 
218  | 
in  | 
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
219  | 
Scan.optional (P.$$$ "[" |-- Scan.optional scan_compilation Pred  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
220  | 
-- P.enum "," scan_bool_option --| P.$$$ "]")  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
221  | 
(Pred, [])  | 
| 
33123
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
222  | 
end  | 
| 
 
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
 
bulwahn 
parents: 
33122 
diff
changeset
 | 
223  | 
|
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
224  | 
val opt_print_modes = Scan.optional (P.$$$ "(" |-- P.!!! (Scan.repeat1 P.xname --| P.$$$ ")")) [];
 | 
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
225  | 
|
| 
33625
 
eefee41ede3a
removed deprecated mode annotation parser; renamed accepted mode annotation parser to nicer naming
 
bulwahn 
parents: 
33623 
diff
changeset
 | 
226  | 
val opt_mode = (P.$$$ "_" >> K NONE) || (parse_mode_expr >> SOME)  | 
| 
33479
 
428ddcc16e7b
added optional mode annotations for parameters in the values command
 
bulwahn 
parents: 
33478 
diff
changeset
 | 
227  | 
|
| 33481 | 228  | 
val opt_param_modes = Scan.optional (P.$$$ "[" |-- Args.$$$ "mode" |-- P.$$$ ":" |--  | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
229  | 
P.enum ", " opt_mode --| P.$$$ "]" >> SOME) NONE  | 
| 
33479
 
428ddcc16e7b
added optional mode annotations for parameters in the values command
 
bulwahn 
parents: 
33478 
diff
changeset
 | 
230  | 
|
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
231  | 
val value_options =  | 
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
232  | 
let  | 
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
233  | 
val expected_values = Scan.optional (Args.$$$ "expected" |-- P.term >> SOME) NONE  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
234  | 
val scan_compilation =  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
235  | 
Scan.optional  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
236  | 
(foldl1 (op ||)  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
237  | 
(map (fn (s, c) => Args.$$$ s -- P.enum "," P.int >> (fn (_, ps) => (c, ps)))  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
238  | 
compilation_names))  | 
| 
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
239  | 
(Pred, [])  | 
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
240  | 
in  | 
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
241  | 
Scan.optional (P.$$$ "[" |-- expected_values -- scan_compilation --| P.$$$ "]") (NONE, (Pred, []))  | 
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
242  | 
end  | 
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
243  | 
|
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
244  | 
(* code_pred command and values command *)  | 
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
245  | 
|
| 
32668
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
246  | 
val _ = OuterSyntax.local_theory_to_proof "code_pred"  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
247  | 
"prove equations for predicate specified by intro/elim rules"  | 
| 
33623
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
248  | 
OuterKeyword.thy_goal  | 
| 
 
4ec42d38224f
changed modes to expected_modes; added UNION to code_pred_inlining; fixed some examples; tuned
 
bulwahn 
parents: 
33620 
diff
changeset
 | 
249  | 
(opt_expected_modes -- opt_modes -- scan_options -- P.term_group >> code_pred_cmd)  | 
| 
33478
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
250  | 
|
| 
 
b70fe083694d
moved values command from core to predicate compile
 
bulwahn 
parents: 
33475 
diff
changeset
 | 
251  | 
val _ = OuterSyntax.improper_command "values" "enumerate and print comprehensions" OuterKeyword.diag  | 
| 
33479
 
428ddcc16e7b
added optional mode annotations for parameters in the values command
 
bulwahn 
parents: 
33478 
diff
changeset
 | 
252  | 
(opt_print_modes -- opt_param_modes -- value_options -- Scan.optional P.nat ~1 -- P.term  | 
| 
34948
 
2d5f2a9f7601
refactoring the predicate compiler; adding theories for Sequences; adding retrieval to Spec_Rules; adding timing to Quickcheck
 
bulwahn 
parents: 
33752 
diff
changeset
 | 
253  | 
>> (fn ((((print_modes, param_modes), options), k), t) => Toplevel.keep  | 
| 
33479
 
428ddcc16e7b
added optional mode annotations for parameters in the values command
 
bulwahn 
parents: 
33478 
diff
changeset
 | 
254  | 
(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
 | 
255  | 
|
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
256  | 
end  | 
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
257  | 
|
| 
 
b2de45007537
added first prototype of the extended predicate compiler
 
bulwahn 
parents:  
diff
changeset
 | 
258  | 
end  |