author | bulwahn |
Sat, 24 Oct 2009 16:55:43 +0200 | |
changeset 33146 | bf852ef586f2 |
parent 33142 | edab304696ec |
child 33149 | 2c8f1c450b47 |
permissions | -rw-r--r-- |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
1 |
(* Author: Lukas Bulwahn, TU Muenchen |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
2 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
3 |
*) |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
4 |
signature PREDICATE_COMPILE = |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
5 |
sig |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
6 |
val setup : theory -> theory |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
7 |
val preprocess : Predicate_Compile_Aux.options -> string -> theory -> theory |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
8 |
end; |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
9 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
10 |
structure Predicate_Compile : PREDICATE_COMPILE = |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
11 |
struct |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
12 |
|
33108
9d9afd478016
added test for higher-order function inductification; added debug messages
bulwahn
parents:
33107
diff
changeset
|
13 |
(* options *) |
33139
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
bulwahn
parents:
33134
diff
changeset
|
14 |
val fail_safe_mode = true |
33108
9d9afd478016
added test for higher-order function inductification; added debug messages
bulwahn
parents:
33107
diff
changeset
|
15 |
|
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
16 |
open Predicate_Compile_Aux; |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
17 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
18 |
val priority = tracing; |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
19 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
20 |
(* Some last processing *) |
33113 | 21 |
|
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
22 |
fun remove_pointless_clauses intro = |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
23 |
if Logic.strip_imp_prems (prop_of intro) = [@{prop "False"}] then |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
24 |
[] |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
25 |
else [intro] |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
26 |
|
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
27 |
fun tracing s = () |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
28 |
|
33125 | 29 |
fun print_intross options thy msg intross = |
30 |
if show_intermediate_results options then |
|
31 |
Output.tracing (msg ^ |
|
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
32 |
(space_implode "\n" (map |
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
33 |
(fn (c, intros) => "Introduction rule(s) of " ^ c ^ ":\n" ^ |
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
34 |
commas (map (Display.string_of_thm_global thy) intros)) intross))) |
33125 | 35 |
else () |
36 |
||
33122
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
37 |
fun print_specs thy specs = |
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
38 |
map (fn (c, thms) => "Constant " ^ c ^ " has specification:\n" |
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
39 |
^ (space_implode "\n" (map (Display.string_of_thm_global thy) thms)) ^ "\n") specs |
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
40 |
|
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
41 |
fun map_specs f specs = |
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
42 |
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
|
43 |
|
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
44 |
fun process_specification options specs thy' = |
33121
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
45 |
let |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
46 |
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
|
47 |
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
|
48 |
(fn th => if is_equationlike th then Predicate_Compile_Data.normalize_equation thy' th else th))) specs |
33121
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
49 |
val (intross1, thy'') = apfst flat (fold_map Predicate_Compile_Pred.preprocess specs thy') |
33125 | 50 |
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
|
51 |
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
|
52 |
val intross2 = |
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
53 |
if fail_safe_mode then |
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
54 |
case try (map_specs (maps (Predicate_Compile_Fun.rewrite_intro thy''))) intross1 of |
33121
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
55 |
SOME intross => intross |
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
56 |
| NONE => let val _ = warning "Function replacement failed!" in intross1 end |
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
57 |
else map_specs (maps (Predicate_Compile_Fun.rewrite_intro thy'')) intross1 |
33125 | 58 |
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
|
59 |
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
|
60 |
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
|
61 |
val (new_intross, thy'''') = |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
62 |
if not (null new_defs) then |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
63 |
let |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
64 |
val _ = print_step options "Recursively obtaining introduction rules for new definitions..." |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
65 |
in process_specification options new_defs thy''' end |
33121
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
66 |
else ([], thy''') |
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
67 |
in |
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
68 |
(intross3 @ new_intross, thy'''') |
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
69 |
end |
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
70 |
|
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
71 |
|
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
72 |
fun preprocess_strong_conn_constnames options gr constnames thy = |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
73 |
let |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
74 |
val get_specs = map (fn k => (k, Graph.get_node gr k)) |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
75 |
val _ = print_step options ("Preprocessing scc of " ^ commas constnames) |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
76 |
val (prednames, funnames) = List.partition (is_pred thy) constnames |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
77 |
(* untangle recursion by defining predicates for all functions *) |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
78 |
val _ = print_step options |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
79 |
("Compiling functions (" ^ commas funnames ^ ") to predicates...") |
33122
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
80 |
val (fun_pred_specs, thy') = |
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
81 |
if not (null funnames) then Predicate_Compile_Fun.define_predicates |
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
82 |
(get_specs funnames) thy else ([], thy) |
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
83 |
val _ = print_specs thy' fun_pred_specs |
7d01480cc8e3
added first support for higher-order function translation
bulwahn
parents:
33121
diff
changeset
|
84 |
val specs = (get_specs prednames) @ fun_pred_specs |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
85 |
val (intross3, thy''') = process_specification options specs thy' |
33125 | 86 |
val _ = print_intross options thy''' "Introduction rules with new constants: " intross3 |
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
87 |
val intross4 = map_specs (maps remove_pointless_clauses) intross3 |
33125 | 88 |
val _ = print_intross options thy''' "After removing pointless clauses: " intross4 |
33146
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
89 |
(*val intross5 = map (fn s, ths) => ( s, map (AxClass.overload thy''') ths)) intross4*) |
bf852ef586f2
now the predicate compilere handles the predicate without introduction rules better as before
bulwahn
parents:
33142
diff
changeset
|
90 |
val intross6 = map_specs (map (expand_tuples thy''')) intross4 |
33125 | 91 |
val _ = print_intross options thy''' "introduction rules before registering: " intross6 |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
92 |
val _ = print_step options "Registering introduction rules..." |
33121
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
93 |
val thy'''' = fold Predicate_Compile_Core.register_intros intross6 thy''' |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
94 |
in |
33121
9b10dc5da0e0
added to process higher-order arguments by adding new constants
bulwahn
parents:
33120
diff
changeset
|
95 |
thy'''' |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
96 |
end; |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
97 |
|
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
98 |
fun preprocess options const thy = |
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32669
diff
changeset
|
99 |
let |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
100 |
val _ = print_step options "Fetching definitions from theory..." |
33140
83951822bfd0
cleaning the signature of the predicate compiler core; renaming signature and structures to uniform long names
bulwahn
parents:
33139
diff
changeset
|
101 |
val table = Predicate_Compile_Data.make_const_spec_table thy |
83951822bfd0
cleaning the signature of the predicate compiler core; renaming signature and structures to uniform long names
bulwahn
parents:
33139
diff
changeset
|
102 |
val gr = Predicate_Compile_Data.obtain_specification_graph thy table const |
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32669
diff
changeset
|
103 |
val gr = Graph.subgraph (member (op =) (Graph.all_succs gr [const])) gr |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
104 |
in fold_rev (preprocess_strong_conn_constnames options gr) |
32672
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32669
diff
changeset
|
105 |
(Graph.strong_conn gr) thy |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32669
diff
changeset
|
106 |
end |
90f3ce5d27ae
added first version of quickcheck based on the predicate compiler; added a few quickcheck examples
bulwahn
parents:
32669
diff
changeset
|
107 |
|
33132
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
bulwahn
parents:
33131
diff
changeset
|
108 |
fun extract_options ((modes, raw_options), const) = |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
109 |
let |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
110 |
fun chk s = member (op =) raw_options s |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
111 |
in |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
112 |
Options { |
33132
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
bulwahn
parents:
33131
diff
changeset
|
113 |
expected_modes = Option.map (pair const) modes, |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
114 |
show_steps = chk "show_steps", |
33125 | 115 |
show_intermediate_results = chk "show_intermediate_results", |
33127 | 116 |
show_proof_trace = chk "show_proof_trace", |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
117 |
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
|
118 |
show_compilation = chk "show_compilation", |
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
bulwahn
parents:
33134
diff
changeset
|
119 |
skip_proof = chk "skip_proof", |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
120 |
inductify = chk "inductify", |
33132
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
bulwahn
parents:
33131
diff
changeset
|
121 |
rpred = chk "rpred", |
33134
88c9c3460fe7
renamed functions from sizelim to more natural name depth_limited for compilation of depth-limited search in the predicate compiler
bulwahn
parents:
33132
diff
changeset
|
122 |
depth_limited = chk "depth_limited" |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
123 |
} |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
124 |
end |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
125 |
|
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
126 |
fun code_pred_cmd ((modes, raw_options), raw_const) lthy = |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
127 |
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
|
128 |
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
|
129 |
val const = Code.read_const thy raw_const |
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
bulwahn
parents:
33131
diff
changeset
|
130 |
val options = extract_options ((modes, raw_options), const) |
07efd452a698
moved argument expected_modes into options; improved mode check to only check mode of the named predicate
bulwahn
parents:
33131
diff
changeset
|
131 |
in |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
132 |
if (is_inductify options) then |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
133 |
let |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
134 |
val lthy' = LocalTheory.theory (preprocess options const) lthy |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
135 |
|> LocalTheory.checkpoint |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
136 |
val const = case Predicate_Compile_Fun.pred_of_function (ProofContext.theory_of lthy') const of |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
137 |
SOME c => c |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
138 |
| NONE => const |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
139 |
val _ = print_step options "Starting Predicate Compile Core..." |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
140 |
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
|
141 |
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
|
142 |
end |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
143 |
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
|
144 |
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
|
145 |
end |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
146 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
147 |
val setup = Predicate_Compile_Fun.setup_oracle #> Predicate_Compile_Core.setup |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
148 |
|
33127 | 149 |
val bool_options = ["show_steps", "show_intermediate_results", "show_proof_trace", |
33139
9c01ee6f8ee9
added skip_proof option; playing with compilation of depth-limited predicates
bulwahn
parents:
33134
diff
changeset
|
150 |
"show_mode_inference", "show_compilation", "skip_proof", "inductify", "rpred", "depth_limited"] |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
151 |
|
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
152 |
local structure P = OuterParse |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
153 |
in |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
154 |
|
33114
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
bulwahn
parents:
33113
diff
changeset
|
155 |
val opt_modes = |
33142
edab304696ec
adapted parser for options in the predicate compiler
bulwahn
parents:
33140
diff
changeset
|
156 |
Scan.optional (P.$$$ "(" |-- Args.$$$ "mode" |-- P.$$$ ":" |-- |
33114
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
bulwahn
parents:
33113
diff
changeset
|
157 |
P.enum1 "," (P.$$$ "[" |-- P.enum "," P.nat --| P.$$$ "]") |
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
bulwahn
parents:
33113
diff
changeset
|
158 |
--| P.$$$ ")" >> SOME) NONE |
4785ef554dcc
added further examples; added mode to code_pred command; tuned; some temporary things in Predicate_Compile_ex
bulwahn
parents:
33113
diff
changeset
|
159 |
|
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
160 |
val scan_params = |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
161 |
let |
33142
edab304696ec
adapted parser for options in the predicate compiler
bulwahn
parents:
33140
diff
changeset
|
162 |
val scan_bool_param = foldl1 (op ||) (map Args.$$$ bool_options) |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
163 |
in |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
164 |
Scan.optional (P.$$$ "[" |-- P.enum1 "," scan_bool_param --| P.$$$ "]") [] |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
165 |
end |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
166 |
|
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
167 |
val _ = OuterSyntax.local_theory_to_proof "code_pred" |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
168 |
"prove equations for predicate specified by intro/elim rules" |
33123
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
169 |
OuterKeyword.thy_goal (opt_modes -- scan_params -- P.term_group >> |
3c7c4372f9ad
cleaned up debugging messages; added options to code_pred command
bulwahn
parents:
33122
diff
changeset
|
170 |
code_pred_cmd) |
32668
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
171 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
172 |
end |
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
173 |
|
b2de45007537
added first prototype of the extended predicate compiler
bulwahn
parents:
diff
changeset
|
174 |
end |