| author | blanchet |
| Fri, 31 Jan 2014 16:41:54 +0100 | |
| changeset 55214 | 48a347b40629 |
| parent 55212 | 5832470d956e |
| child 55285 | e88ad20035f4 |
| permissions | -rw-r--r-- |
| 55201 | 1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer_prover.ML |
|
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
2 |
Author: Fabian Immler, TU Muenchen |
|
32996
d2e48879e65a
removed disjunctive group cancellation -- provers run independently;
wenzelm
parents:
32995
diff
changeset
|
3 |
Author: Makarius |
| 35969 | 4 |
Author: Jasmin Blanchette, TU Muenchen |
|
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
5 |
|
|
41087
d7b5fd465198
split "Sledgehammer" module into two parts, to resolve forthcoming dependency problems
blanchet
parents:
41066
diff
changeset
|
6 |
Generic prover abstraction for Sledgehammer. |
|
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
7 |
*) |
|
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
8 |
|
| 55201 | 9 |
signature SLEDGEHAMMER_PROVER = |
|
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
10 |
sig |
|
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53551
diff
changeset
|
11 |
type atp_failure = ATP_Proof.atp_failure |
| 46340 | 12 |
type stature = ATP_Problem_Generate.stature |
| 46320 | 13 |
type type_enc = ATP_Problem_Generate.type_enc |
|
51005
ce4290c33d73
eliminated needless speed optimization -- and simplified code quite a bit
blanchet
parents:
50927
diff
changeset
|
14 |
type fact = Sledgehammer_Fact.fact |
| 52555 | 15 |
type reconstructor = Sledgehammer_Reconstructor.reconstructor |
| 54824 | 16 |
type play_outcome = Sledgehammer_Reconstructor.play_outcome |
| 52555 | 17 |
type minimize_command = Sledgehammer_Reconstructor.minimize_command |
|
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
18 |
|
|
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
19 |
datatype mode = Auto_Try | Try | Normal | MaSh | Auto_Minimize | Minimize |
| 43021 | 20 |
|
| 35969 | 21 |
type params = |
| 48321 | 22 |
{debug : bool,
|
23 |
verbose : bool, |
|
24 |
overlord : bool, |
|
| 53800 | 25 |
spy : bool, |
| 48321 | 26 |
blocking : bool, |
27 |
provers : string list, |
|
28 |
type_enc : string option, |
|
29 |
strict : bool, |
|
30 |
lam_trans : string option, |
|
31 |
uncurried_aliases : bool option, |
|
32 |
learn : bool, |
|
33 |
fact_filter : string option, |
|
34 |
max_facts : int option, |
|
35 |
fact_thresholds : real * real, |
|
36 |
max_mono_iters : int option, |
|
37 |
max_new_mono_instances : int option, |
|
|
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51186
diff
changeset
|
38 |
isar_proofs : bool option, |
|
55183
17ec4a29ef71
renamed Sledgehammer options for symmetry between positive and negative versions
blanchet
parents:
55170
diff
changeset
|
39 |
compress_isar : real, |
|
17ec4a29ef71
renamed Sledgehammer options for symmetry between positive and negative versions
blanchet
parents:
55170
diff
changeset
|
40 |
try0_isar : bool, |
| 48321 | 41 |
slice : bool, |
42 |
minimize : bool option, |
|
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
43 |
timeout : Time.time, |
|
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
44 |
preplay_timeout : Time.time, |
| 48321 | 45 |
expect : string} |
|
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
46 |
|
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
47 |
type prover_problem = |
|
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
48 |
{comment : string,
|
|
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
49 |
state : Proof.state, |
| 48321 | 50 |
goal : thm, |
51 |
subgoal : int, |
|
52 |
subgoal_count : int, |
|
| 51010 | 53 |
factss : (string * fact list) list} |
|
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
54 |
|
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
55 |
type prover_result = |
|
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53551
diff
changeset
|
56 |
{outcome : atp_failure option,
|
|
51009
e8ff34a1fa9a
thread through fact triple component from which used facts come, for accurate index output
blanchet
parents:
51007
diff
changeset
|
57 |
used_facts : (string * stature) list, |
|
e8ff34a1fa9a
thread through fact triple component from which used facts come, for accurate index output
blanchet
parents:
51007
diff
changeset
|
58 |
used_from : fact list, |
| 48321 | 59 |
run_time : Time.time, |
| 54824 | 60 |
preplay : (reconstructor * play_outcome) Lazy.lazy, |
61 |
message : reconstructor * play_outcome -> string, |
|
| 48321 | 62 |
message_tail : string} |
|
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
63 |
|
| 43051 | 64 |
type prover = |
| 45520 | 65 |
params -> ((string * string list) list -> string -> minimize_command) |
66 |
-> prover_problem -> prover_result |
|
| 35867 | 67 |
|
|
48319
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents:
48314
diff
changeset
|
68 |
val SledgehammerN : string |
|
45519
cd6e78cb6ee8
make metis reconstruction handling more flexible
blanchet
parents:
45514
diff
changeset
|
69 |
val plain_metis : reconstructor |
| 55205 | 70 |
val overlord_file_location_of_prover : string -> string * string |
71 |
val proof_banner : mode -> string -> string |
|
| 54811 | 72 |
val extract_reconstructor : params -> reconstructor -> string * (string * string list) list |
|
45379
0147a4348ca1
try "smt" as a fallback for ATPs if "metis" fails/times out
blanchet
parents:
45378
diff
changeset
|
73 |
val is_reconstructor : string -> bool |
|
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
74 |
val is_atp : theory -> string -> bool |
| 55212 | 75 |
val bunch_of_reconstructors : bool -> (bool -> string) -> reconstructor list |
| 48798 | 76 |
val is_fact_chained : (('a * stature) * 'b) -> bool
|
77 |
val filter_used_facts : |
|
78 |
bool -> (''a * stature) list -> ((''a * stature) * 'b) list ->
|
|
79 |
((''a * stature) * 'b) list
|
|
| 55205 | 80 |
val play_one_line_proof : mode -> bool -> bool -> Time.time -> ((string * 'a) * thm) list -> |
81 |
Proof.state -> int -> reconstructor -> reconstructor list -> reconstructor * play_outcome |
|
82 |
val remotify_atp_if_not_installed : theory -> string -> string option |
|
83 |
val isar_supported_prover_of : theory -> string -> string |
|
84 |
val choose_minimize_command : theory -> params -> ((string * string list) list -> string -> 'a) -> |
|
85 |
string -> reconstructor * play_outcome -> 'a |
|
86 |
val repair_monomorph_context : int option -> int -> int option -> int -> Proof.context -> |
|
87 |
Proof.context |
|
| 55212 | 88 |
|
89 |
val supported_provers : Proof.context -> unit |
|
90 |
val kill_provers : unit -> unit |
|
91 |
val running_provers : unit -> unit |
|
92 |
val messages : int option -> unit |
|
|
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
93 |
end; |
|
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
94 |
|
| 55201 | 95 |
structure Sledgehammer_Prover : SLEDGEHAMMER_PROVER = |
|
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
96 |
struct |
|
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
97 |
|
|
43085
0a2f5b86bdd7
first step in sharing more code between ATP and Metis translation
blanchet
parents:
43063
diff
changeset
|
98 |
open ATP_Util |
| 38028 | 99 |
open ATP_Problem |
100 |
open ATP_Systems |
|
| 46320 | 101 |
open ATP_Problem_Generate |
102 |
open ATP_Proof_Reconstruct |
|
| 45521 | 103 |
open Metis_Tactic |
|
51005
ce4290c33d73
eliminated needless speed optimization -- and simplified code quite a bit
blanchet
parents:
50927
diff
changeset
|
104 |
open Sledgehammer_Fact |
| 52555 | 105 |
open Sledgehammer_Reconstructor |
|
54000
9cfff7f61d0d
added experimental configuration options to tune use of builtin symbols in SMT
blanchet
parents:
53989
diff
changeset
|
106 |
|
|
53052
a0db255af8c5
sledgehammer sendback always uses Markup.padding_command: sensible default for most practical applications -- old-style in-line replacement is superseded by auto mode or panel;
wenzelm
parents:
53047
diff
changeset
|
107 |
datatype mode = Auto_Try | Try | Normal | MaSh | Auto_Minimize | Minimize |
| 43021 | 108 |
|
| 45376 | 109 |
(* Identifier that distinguishes Sledgehammer from other tools that could use |
|
38102
019a49759829
fix bug in the newly introduced "bound concealing" code
blanchet
parents:
38100
diff
changeset
|
110 |
"Async_Manager". *) |
|
48319
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents:
48314
diff
changeset
|
111 |
val SledgehammerN = "Sledgehammer" |
| 37585 | 112 |
|
| 45520 | 113 |
val reconstructor_names = [metisN, smtN] |
| 46365 | 114 |
val plain_metis = Metis (hd partial_type_encs, combsN) |
|
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
115 |
val is_reconstructor = member (op =) reconstructor_names |
|
43228
2ed2f092e990
obsoleted "metisFT", and added "no_types" version of Metis as fallback to Sledgehammer after noticing how useful it can be
blanchet
parents:
43226
diff
changeset
|
116 |
|
|
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
117 |
val is_atp = member (op =) o supported_atps |
|
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
118 |
|
| 55205 | 119 |
fun remotify_atp_if_supported_and_not_already_remote thy name = |
|
51200
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
120 |
if String.isPrefix remote_prefix name then |
|
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
121 |
SOME name |
|
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
122 |
else |
|
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
123 |
let val remote_name = remote_prefix ^ name in |
| 55205 | 124 |
if is_atp thy remote_name then SOME remote_name else NONE |
|
51200
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
125 |
end |
|
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
126 |
|
| 55205 | 127 |
fun remotify_atp_if_not_installed thy name = |
| 55207 | 128 |
if is_atp thy name andalso is_atp_installed thy name then SOME name |
| 55205 | 129 |
else remotify_atp_if_supported_and_not_already_remote thy name |
|
40063
d086e3699e78
bring ATPs and SMT solvers more in line with each other
blanchet
parents:
40062
diff
changeset
|
130 |
|
| 35969 | 131 |
type params = |
| 48321 | 132 |
{debug : bool,
|
133 |
verbose : bool, |
|
134 |
overlord : bool, |
|
| 53800 | 135 |
spy : bool, |
| 48321 | 136 |
blocking : bool, |
137 |
provers : string list, |
|
138 |
type_enc : string option, |
|
139 |
strict : bool, |
|
140 |
lam_trans : string option, |
|
141 |
uncurried_aliases : bool option, |
|
142 |
learn : bool, |
|
143 |
fact_filter : string option, |
|
144 |
max_facts : int option, |
|
145 |
fact_thresholds : real * real, |
|
146 |
max_mono_iters : int option, |
|
147 |
max_new_mono_instances : int option, |
|
|
51190
2654b3965c8d
made "isar_proofs" a 3-way option, to provide a way to totally disable isar_proofs if desired
blanchet
parents:
51186
diff
changeset
|
148 |
isar_proofs : bool option, |
|
55183
17ec4a29ef71
renamed Sledgehammer options for symmetry between positive and negative versions
blanchet
parents:
55170
diff
changeset
|
149 |
compress_isar : real, |
|
17ec4a29ef71
renamed Sledgehammer options for symmetry between positive and negative versions
blanchet
parents:
55170
diff
changeset
|
150 |
try0_isar : bool, |
| 48321 | 151 |
slice : bool, |
152 |
minimize : bool option, |
|
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
153 |
timeout : Time.time, |
|
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
154 |
preplay_timeout : Time.time, |
| 48321 | 155 |
expect : string} |
| 35867 | 156 |
|
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
157 |
type prover_problem = |
|
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
158 |
{comment : string,
|
|
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
159 |
state : Proof.state, |
| 48321 | 160 |
goal : thm, |
161 |
subgoal : int, |
|
162 |
subgoal_count : int, |
|
| 51010 | 163 |
factss : (string * fact list) list} |
| 35867 | 164 |
|
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
165 |
type prover_result = |
|
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53551
diff
changeset
|
166 |
{outcome : atp_failure option,
|
| 48321 | 167 |
used_facts : (string * stature) list, |
|
51009
e8ff34a1fa9a
thread through fact triple component from which used facts come, for accurate index output
blanchet
parents:
51007
diff
changeset
|
168 |
used_from : fact list, |
| 48321 | 169 |
run_time : Time.time, |
| 54824 | 170 |
preplay : (reconstructor * play_outcome) Lazy.lazy, |
171 |
message : reconstructor * play_outcome -> string, |
|
| 48321 | 172 |
message_tail : string} |
| 35867 | 173 |
|
| 43051 | 174 |
type prover = |
| 45520 | 175 |
params -> ((string * string list) list -> string -> minimize_command) |
176 |
-> prover_problem -> prover_result |
|
| 35867 | 177 |
|
| 55205 | 178 |
fun overlord_file_location_of_prover prover = (getenv "ISABELLE_HOME_USER", "prob_" ^ prover) |
|
41313
a96ac4d180b7
optionally supply constant weights to E -- turned off by default until properly parameterized
blanchet
parents:
41259
diff
changeset
|
179 |
|
|
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
180 |
fun proof_banner mode name = |
| 55205 | 181 |
(case mode of |
| 43033 | 182 |
Auto_Try => "Auto Sledgehammer (" ^ quote name ^ ") found a proof"
|
183 |
| Try => "Sledgehammer (" ^ quote name ^ ") found a proof"
|
|
| 55205 | 184 |
| _ => "Try this") |
| 43033 | 185 |
|
|
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
186 |
fun bunch_of_reconstructors needs_full_types lam_trans = |
| 48800 | 187 |
if needs_full_types then |
| 48802 | 188 |
[Metis (full_type_enc, lam_trans false), |
189 |
Metis (really_full_type_enc, lam_trans false), |
|
190 |
Metis (full_type_enc, lam_trans true), |
|
191 |
Metis (really_full_type_enc, lam_trans true), |
|
192 |
SMT] |
|
193 |
else |
|
| 48800 | 194 |
[Metis (partial_type_enc, lam_trans false), |
195 |
Metis (full_type_enc, lam_trans false), |
|
196 |
Metis (no_typesN, lam_trans true), |
|
197 |
Metis (really_full_type_enc, lam_trans true), |
|
198 |
SMT] |
|
|
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
199 |
|
| 54824 | 200 |
fun extract_reconstructor ({type_enc, lam_trans, ...} : params) (Metis (type_enc', lam_trans')) =
|
|
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
201 |
let |
|
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
202 |
val override_params = |
| 54824 | 203 |
(if is_none type_enc andalso type_enc' = hd partial_type_encs then [] |
204 |
else [("type_enc", [hd (unalias_type_enc type_enc')])]) @
|
|
205 |
(if is_none lam_trans andalso lam_trans' = default_metis_lam_trans then [] |
|
206 |
else [("lam_trans", [lam_trans'])])
|
|
|
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
207 |
in (metisN, override_params) end |
|
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
208 |
| extract_reconstructor _ SMT = (smtN, []) |
|
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
209 |
|
| 43033 | 210 |
(* based on "Mirabelle.can_apply" and generalized *) |
|
43034
18259246abb5
try both "metis" and (on failure) "metisFT" in replay
blanchet
parents:
43033
diff
changeset
|
211 |
fun timed_apply timeout tac state i = |
| 43033 | 212 |
let |
213 |
val {context = ctxt, facts, goal} = Proof.goal state
|
|
214 |
val full_tac = Method.insert_tac facts i THEN tac ctxt i |
|
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
215 |
in |
|
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
216 |
TimeLimit.timeLimit timeout (try (Seq.pull o full_tac)) goal |
|
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
217 |
end |
| 43033 | 218 |
|
| 54824 | 219 |
fun tac_of_reconstructor (Metis (type_enc, lam_trans)) = metis_tac [type_enc] lam_trans |
|
51998
f732a674db1b
renamed Sledgehammer functions with 'for' in their names to 'of'
blanchet
parents:
51879
diff
changeset
|
220 |
| tac_of_reconstructor SMT = SMT_Solver.smt_tac |
|
43034
18259246abb5
try both "metis" and (on failure) "metisFT" in replay
blanchet
parents:
43033
diff
changeset
|
221 |
|
| 45520 | 222 |
fun timed_reconstructor reconstr debug timeout ths = |
| 55170 | 223 |
timed_apply timeout (silence_reconstructors debug |
224 |
#> (fn ctxt => tac_of_reconstructor reconstr ctxt ths)) |
|
| 43033 | 225 |
|
| 48798 | 226 |
fun is_fact_chained ((_, (sc, _)), _) = sc = Chained |
227 |
||
228 |
fun filter_used_facts keep_chained used = |
|
| 54773 | 229 |
filter ((member (op =) used o fst) orf (if keep_chained then is_fact_chained else K false)) |
| 43033 | 230 |
|
| 54815 | 231 |
fun play_one_line_proof mode debug verbose timeout pairs state i preferred reconstrs = |
|
43034
18259246abb5
try both "metis" and (on failure) "metisFT" in replay
blanchet
parents:
43033
diff
changeset
|
232 |
let |
| 45520 | 233 |
fun get_preferred reconstrs = |
234 |
if member (op =) reconstrs preferred then preferred |
|
235 |
else List.last reconstrs |
|
|
43034
18259246abb5
try both "metis" and (on failure) "metisFT" in replay
blanchet
parents:
43033
diff
changeset
|
236 |
in |
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
237 |
if timeout = Time.zeroTime then |
| 54824 | 238 |
(get_preferred reconstrs, Not_Played) |
|
45379
0147a4348ca1
try "smt" as a fallback for ATPs if "metis" fails/times out
blanchet
parents:
45378
diff
changeset
|
239 |
else |
| 50557 | 240 |
let |
| 54815 | 241 |
val _ = if mode = Minimize then Output.urgent_message "Preplaying proof..." else () |
| 50557 | 242 |
val ths = pairs |> sort_wrt (fst o fst) |> map snd |
| 54824 | 243 |
fun play [] [] = (get_preferred reconstrs, Play_Failed) |
244 |
| play timed_outs [] = (get_preferred timed_outs, Play_Timed_Out timeout) |
|
| 50557 | 245 |
| play timed_out (reconstr :: reconstrs) = |
246 |
let |
|
247 |
val _ = |
|
248 |
if verbose then |
|
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
249 |
Output.urgent_message ("Trying \"" ^ string_of_reconstructor reconstr ^
|
|
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
250 |
"\" for " ^ string_of_time timeout ^ "...") |
| 50557 | 251 |
else |
252 |
() |
|
253 |
val timer = Timer.startRealTimer () |
|
254 |
in |
|
255 |
case timed_reconstructor reconstr debug timeout ths state i of |
|
| 54824 | 256 |
SOME (SOME _) => (reconstr, Played (Timer.checkRealTimer timer)) |
| 50557 | 257 |
| _ => play timed_out reconstrs |
258 |
end |
|
259 |
handle TimeLimit.TimeOut => play (reconstr :: timed_out) reconstrs |
|
| 54824 | 260 |
in |
261 |
play [] reconstrs |
|
262 |
end |
|
| 43033 | 263 |
end |
264 |
||
| 55205 | 265 |
val canonical_isar_supported_prover = eN |
| 51013 | 266 |
|
| 55205 | 267 |
fun isar_supported_prover_of thy name = |
268 |
if is_atp thy name then name |
|
269 |
else the_default name (remotify_atp_if_not_installed thy canonical_isar_supported_prover) |
|
| 43051 | 270 |
|
|
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
271 |
(* FIXME: See the analogous logic in the function "maybe_minimize" in |
|
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
272 |
"sledgehammer_prover_minimize.ML". *) |
| 55205 | 273 |
fun choose_minimize_command thy (params as {isar_proofs, ...}) minimize_command name preplay =
|
| 45520 | 274 |
let |
| 55205 | 275 |
val maybe_isar_name = name |> isar_proofs = SOME true ? isar_supported_prover_of thy |
|
51200
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
276 |
val (min_name, override_params) = |
| 54824 | 277 |
(case preplay of |
278 |
(reconstr, Played _) => |
|
|
51200
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
279 |
if isar_proofs = SOME true then (maybe_isar_name, []) |
|
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
280 |
else extract_reconstructor params reconstr |
| 54824 | 281 |
| _ => (maybe_isar_name, [])) |
|
51200
260cb10aac4b
minimize SMT proofs with E if Isar proofs are desired and Metis managed to preplay
blanchet
parents:
51190
diff
changeset
|
282 |
in minimize_command override_params min_name end |
| 43051 | 283 |
|
|
53480
247817dbb990
limit the number of instances of a single theorem
blanchet
parents:
53478
diff
changeset
|
284 |
val max_fact_instances = 10 (* FUDGE *) |
|
247817dbb990
limit the number of instances of a single theorem
blanchet
parents:
53478
diff
changeset
|
285 |
|
| 55205 | 286 |
fun repair_monomorph_context max_iters best_max_iters max_new_instances best_max_new_instances = |
|
52034
11b48e7a4e7e
correctly 'repair' the monomorphization context for SMT solvers from Sledgehammer
blanchet
parents:
52031
diff
changeset
|
287 |
Config.put Monomorph.max_rounds (max_iters |> the_default best_max_iters) |
|
11b48e7a4e7e
correctly 'repair' the monomorphization context for SMT solvers from Sledgehammer
blanchet
parents:
52031
diff
changeset
|
288 |
#> Config.put Monomorph.max_new_instances |
| 55205 | 289 |
(max_new_instances |> the_default best_max_new_instances) |
|
53480
247817dbb990
limit the number of instances of a single theorem
blanchet
parents:
53478
diff
changeset
|
290 |
#> Config.put Monomorph.max_thm_instances max_fact_instances |
|
52034
11b48e7a4e7e
correctly 'repair' the monomorphization context for SMT solvers from Sledgehammer
blanchet
parents:
52031
diff
changeset
|
291 |
|
| 55212 | 292 |
fun supported_provers ctxt = |
|
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
293 |
let |
| 55212 | 294 |
val thy = Proof_Context.theory_of ctxt |
295 |
val (remote_provers, local_provers) = |
|
296 |
reconstructor_names @ |
|
297 |
sort_strings (supported_atps thy) @ |
|
298 |
sort_strings (SMT_Solver.available_solvers_of ctxt) |
|
299 |
|> List.partition (String.isPrefix remote_prefix) |
|
|
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
300 |
in |
| 55212 | 301 |
Output.urgent_message ("Supported provers: " ^
|
302 |
commas (local_provers @ remote_provers) ^ ".") |
|
|
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
303 |
end |
|
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
304 |
|
| 55212 | 305 |
fun kill_provers () = Async_Manager.kill_threads SledgehammerN "prover" |
306 |
fun running_provers () = Async_Manager.running_threads SledgehammerN "prover" |
|
307 |
val messages = Async_Manager.thread_messages SledgehammerN "prover" |
|
308 |
||
| 28582 | 309 |
end; |