7 signature SLEDGEHAMMER_ISAR = |
7 signature SLEDGEHAMMER_ISAR = |
8 sig |
8 sig |
9 type params = Sledgehammer.params |
9 type params = Sledgehammer.params |
10 |
10 |
11 val auto : bool Unsynchronized.ref |
11 val auto : bool Unsynchronized.ref |
12 val atps : string Unsynchronized.ref |
12 val provers : string Unsynchronized.ref |
13 val timeout : int Unsynchronized.ref |
13 val timeout : int Unsynchronized.ref |
14 val full_types : bool Unsynchronized.ref |
14 val full_types : bool Unsynchronized.ref |
15 val default_params : theory -> (string * string) list -> params |
15 val default_params : theory -> (string * string) list -> params |
16 val setup : theory -> theory |
16 val setup : theory -> theory |
17 end; |
17 end; |
47 fun merge_relevance_overrides rs = |
47 fun merge_relevance_overrides rs = |
48 fold merge_relevance_override_pairwise rs (only_relevance_override []) |
48 fold merge_relevance_override_pairwise rs (only_relevance_override []) |
49 |
49 |
50 (*** parameters ***) |
50 (*** parameters ***) |
51 |
51 |
52 val atps = Unsynchronized.ref "" |
52 val provers = Unsynchronized.ref "" |
53 val timeout = Unsynchronized.ref 30 |
53 val timeout = Unsynchronized.ref 30 |
54 val full_types = Unsynchronized.ref false |
54 val full_types = Unsynchronized.ref false |
55 |
55 |
56 val _ = |
56 val _ = |
57 ProofGeneralPgip.add_preference Preferences.category_proof |
57 ProofGeneralPgip.add_preference Preferences.category_proof |
58 (Preferences.string_pref atps |
58 (Preferences.string_pref provers |
59 "Sledgehammer: ATPs" |
59 "Sledgehammer: Provers" |
60 "Default automatic provers (separated by whitespace)") |
60 "Default automatic provers (separated by whitespace)") |
61 |
61 |
62 val _ = |
62 val _ = |
63 ProofGeneralPgip.add_preference Preferences.category_proof |
63 ProofGeneralPgip.add_preference Preferences.category_proof |
64 (Preferences.int_pref timeout |
64 (Preferences.int_pref timeout |
82 ("max_relevant", "smart"), |
82 ("max_relevant", "smart"), |
83 ("isar_proof", "false"), |
83 ("isar_proof", "false"), |
84 ("isar_shrink_factor", "1")] |
84 ("isar_shrink_factor", "1")] |
85 |
85 |
86 val alias_params = |
86 val alias_params = |
87 [("atp", "atps")] |
87 [("prover", "provers"), |
|
88 ("atps", "provers"), (* FIXME: legacy *) |
|
89 ("atp", "provers")] (* FIXME: legacy *) |
88 val negated_alias_params = |
90 val negated_alias_params = |
89 [("non_blocking", "blocking"), |
91 [("non_blocking", "blocking"), |
90 ("no_debug", "debug"), |
92 ("no_debug", "debug"), |
91 ("quiet", "verbose"), |
93 ("quiet", "verbose"), |
92 ("no_overlord", "overlord"), |
94 ("no_overlord", "overlord"), |
96 |
98 |
97 val params_for_minimize = |
99 val params_for_minimize = |
98 ["debug", "verbose", "overlord", "full_types", "isar_proof", |
100 ["debug", "verbose", "overlord", "full_types", "isar_proof", |
99 "isar_shrink_factor", "timeout"] |
101 "isar_shrink_factor", "timeout"] |
100 |
102 |
101 val property_dependent_params = ["atps", "full_types", "timeout"] |
103 val property_dependent_params = ["provers", "full_types", "timeout"] |
102 |
104 |
103 fun is_known_raw_param s = |
105 fun is_known_raw_param s = |
104 AList.defined (op =) default_default_params s orelse |
106 AList.defined (op =) default_default_params s orelse |
105 AList.defined (op =) alias_params s orelse |
107 AList.defined (op =) alias_params s orelse |
106 AList.defined (op =) negated_alias_params s orelse |
108 AList.defined (op =) negated_alias_params s orelse |
126 type T = raw_param list |
128 type T = raw_param list |
127 val empty = default_default_params |> map (apsnd single) |
129 val empty = default_default_params |> map (apsnd single) |
128 val extend = I |
130 val extend = I |
129 fun merge p : T = AList.merge (op =) (K true) p) |
131 fun merge p : T = AList.merge (op =) (K true) p) |
130 |
132 |
|
133 fun maybe_remote_atp thy name = |
|
134 name |> not (is_atp_installed thy name) ? prefix remote_atp_prefix |
|
135 |
|
136 (* The first ATP of the list is used by Auto Sledgehammer. Because of the low |
|
137 timeout, it makes sense to put SPASS first. *) |
|
138 fun default_provers_param_value thy = |
|
139 (filter (is_atp_installed thy) [spassN] @ |
|
140 [maybe_remote_atp thy eN, |
|
141 if forall (is_atp_installed thy) [spassN, eN] then |
|
142 remote_atp_prefix ^ vampireN |
|
143 else |
|
144 maybe_remote_atp thy vampireN, |
|
145 remote_atp_prefix ^ sine_eN]) |
|
146 |> space_implode " " |
|
147 |
131 val set_default_raw_param = Data.map o AList.update (op =) o unalias_raw_param |
148 val set_default_raw_param = Data.map o AList.update (op =) o unalias_raw_param |
132 fun default_raw_params thy = |
149 fun default_raw_params thy = |
133 Data.get thy |
150 Data.get thy |
134 |> fold (AList.default (op =)) |
151 |> fold (AList.default (op =)) |
135 [("atps", [case !atps of "" => default_atps_param_value () | s => s]), |
152 [("provers", [case !provers of |
|
153 "" => default_provers_param_value thy |
|
154 | s => s]), |
136 ("full_types", [if !full_types then "true" else "false"]), |
155 ("full_types", [if !full_types then "true" else "false"]), |
137 ("timeout", let val timeout = !timeout in |
156 ("timeout", let val timeout = !timeout in |
138 [if timeout <= 0 then "none" |
157 [if timeout <= 0 then "none" |
139 else string_of_int timeout ^ " s"] |
158 else string_of_int timeout ^ " s"] |
140 end)] |
159 end)] |
178 | _ => SOME (lookup_int name) |
197 | _ => SOME (lookup_int name) |
179 val blocking = auto orelse lookup_bool "blocking" |
198 val blocking = auto orelse lookup_bool "blocking" |
180 val debug = not auto andalso lookup_bool "debug" |
199 val debug = not auto andalso lookup_bool "debug" |
181 val verbose = debug orelse (not auto andalso lookup_bool "verbose") |
200 val verbose = debug orelse (not auto andalso lookup_bool "verbose") |
182 val overlord = lookup_bool "overlord" |
201 val overlord = lookup_bool "overlord" |
183 val atps = lookup_string "atps" |> space_explode " " |> auto ? single o hd |
202 val provers = lookup_string "provers" |> space_explode " " |
|
203 |> auto ? single o hd |
184 val full_types = lookup_bool "full_types" |
204 val full_types = lookup_bool "full_types" |
185 val explicit_apply = lookup_bool "explicit_apply" |
205 val explicit_apply = lookup_bool "explicit_apply" |
186 val relevance_thresholds = |
206 val relevance_thresholds = |
187 lookup_int_pair "relevance_thresholds" |
207 lookup_int_pair "relevance_thresholds" |
188 |> pairself (fn n => 0.01 * Real.fromInt n) |
208 |> pairself (fn n => 0.01 * Real.fromInt n) |
191 val isar_shrink_factor = Int.max (1, lookup_int "isar_shrink_factor") |
211 val isar_shrink_factor = Int.max (1, lookup_int "isar_shrink_factor") |
192 val timeout = (if auto then NONE else lookup_time "timeout") |> the_timeout |
212 val timeout = (if auto then NONE else lookup_time "timeout") |> the_timeout |
193 val expect = lookup_string "expect" |
213 val expect = lookup_string "expect" |
194 in |
214 in |
195 {blocking = blocking, debug = debug, verbose = verbose, overlord = overlord, |
215 {blocking = blocking, debug = debug, verbose = verbose, overlord = overlord, |
196 atps = atps, full_types = full_types, explicit_apply = explicit_apply, |
216 provers = provers, full_types = full_types, |
|
217 explicit_apply = explicit_apply, |
197 relevance_thresholds = relevance_thresholds, max_relevant = max_relevant, |
218 relevance_thresholds = relevance_thresholds, max_relevant = max_relevant, |
198 isar_proof = isar_proof, isar_shrink_factor = isar_shrink_factor, |
219 isar_proof = isar_proof, isar_shrink_factor = isar_shrink_factor, |
199 timeout = timeout, expect = expect} |
220 timeout = timeout, expect = expect} |
200 end |
221 end |
201 |
222 |
208 val sledgehammer_paramsN = "sledgehammer_params" |
229 val sledgehammer_paramsN = "sledgehammer_params" |
209 |
230 |
210 val runN = "run" |
231 val runN = "run" |
211 val minimizeN = "minimize" |
232 val minimizeN = "minimize" |
212 val messagesN = "messages" |
233 val messagesN = "messages" |
213 val available_atpsN = "available_atps" |
234 val available_proversN = "available_provers" |
214 val running_atpsN = "running_atps" |
235 val running_proversN = "running_provers" |
215 val kill_atpsN = "kill_atps" |
236 val kill_proversN = "kill_provers" |
216 val refresh_tptpN = "refresh_tptp" |
237 val refresh_tptpN = "refresh_tptp" |
217 |
238 |
218 val is_raw_param_relevant_for_minimize = |
239 val is_raw_param_relevant_for_minimize = |
219 member (op =) params_for_minimize o fst o unalias_raw_param |
240 member (op =) params_for_minimize o fst o unalias_raw_param |
220 fun string_for_raw_param (key, values) = |
241 fun string_for_raw_param (key, values) = |
221 key ^ (case space_implode " " values of "" => "" | value => " = " ^ value) |
242 key ^ (case space_implode " " values of "" => "" | value => " = " ^ value) |
222 |
243 |
223 fun minimize_command override_params i atp_name fact_names = |
244 fun minimize_command override_params i prover_name fact_names = |
224 sledgehammerN ^ " " ^ minimizeN ^ " [atp = " ^ atp_name ^ |
245 sledgehammerN ^ " " ^ minimizeN ^ " [prover = " ^ prover_name ^ |
225 (override_params |> filter is_raw_param_relevant_for_minimize |
246 (override_params |> filter is_raw_param_relevant_for_minimize |
226 |> implode o map (prefix ", " o string_for_raw_param)) ^ |
247 |> implode o map (prefix ", " o string_for_raw_param)) ^ |
227 "] (" ^ space_implode " " fact_names ^ ")" ^ |
248 "] (" ^ space_implode " " fact_names ^ ")" ^ |
228 (if i = 1 then "" else " " ^ string_of_int i) |
249 (if i = 1 then "" else " " ^ string_of_int i) |
229 |
250 |
242 else if subcommand = minimizeN then |
263 else if subcommand = minimizeN then |
243 run_minimize (get_params false thy override_params) (the_default 1 opt_i) |
264 run_minimize (get_params false thy override_params) (the_default 1 opt_i) |
244 (#add relevance_override) state |
265 (#add relevance_override) state |
245 else if subcommand = messagesN then |
266 else if subcommand = messagesN then |
246 messages opt_i |
267 messages opt_i |
247 else if subcommand = available_atpsN then |
268 else if subcommand = available_proversN then |
248 available_atps thy |
269 available_provers thy |
249 else if subcommand = running_atpsN then |
270 else if subcommand = running_proversN then |
250 running_atps () |
271 running_provers () |
251 else if subcommand = kill_atpsN then |
272 else if subcommand = kill_proversN then |
252 kill_atps () |
273 kill_provers () |
253 else if subcommand = refresh_tptpN then |
274 else if subcommand = refresh_tptpN then |
254 refresh_systems_on_tptp () |
275 refresh_systems_on_tptp () |
255 else |
276 else |
256 error ("Unknown subcommand: " ^ quote subcommand ^ ".") |
277 error ("Unknown subcommand: " ^ quote subcommand ^ ".") |
257 end |
278 end |