author | blanchet |
Tue, 24 Jun 2014 08:19:55 +0200 | |
changeset 57290 | bc06471cb7b7 |
parent 57245 | f6bf6d5341ee |
child 57704 | c0da3fc313e3 |
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 |
55287 | 15 |
type proof_method = Sledgehammer_Proof_Methods.proof_method |
16 |
type play_outcome = Sledgehammer_Proof_Methods.play_outcome |
|
17 |
type minimize_command = Sledgehammer_Proof_Methods.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, |
57245 | 39 |
compress : real, |
40 |
try0 : bool, |
|
55297
1dfcd49f5dcb
renamed 'smt' option 'smt_proofs' to avoid clash with 'smt' prover
blanchet
parents:
55288
diff
changeset
|
41 |
smt_proofs : bool option, |
48321 | 42 |
slice : bool, |
43 |
minimize : bool option, |
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
44 |
timeout : Time.time, |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
45 |
preplay_timeout : Time.time, |
48321 | 46 |
expect : string} |
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
47 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
48 |
type prover_problem = |
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
49 |
{comment : string, |
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
50 |
state : Proof.state, |
48321 | 51 |
goal : thm, |
52 |
subgoal : int, |
|
53 |
subgoal_count : int, |
|
51010 | 54 |
factss : (string * fact list) list} |
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
55 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
56 |
type prover_result = |
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53551
diff
changeset
|
57 |
{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
|
58 |
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
|
59 |
used_from : fact list, |
48321 | 60 |
run_time : Time.time, |
55285 | 61 |
preplay : (proof_method * play_outcome) Lazy.lazy, |
62 |
message : proof_method * play_outcome -> string, |
|
48321 | 63 |
message_tail : string} |
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
64 |
|
43051 | 65 |
type prover = |
57056 | 66 |
params -> ((string * string list) list -> string -> minimize_command) -> prover_problem -> |
67 |
prover_result |
|
35867 | 68 |
|
48319
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents:
48314
diff
changeset
|
69 |
val SledgehammerN : string |
57037 | 70 |
val str_of_mode : mode -> string |
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55308
diff
changeset
|
71 |
val smtN : string |
55205 | 72 |
val overlord_file_location_of_prover : string -> string * string |
73 |
val proof_banner : mode -> string -> string |
|
55285 | 74 |
val extract_proof_method : params -> proof_method -> string * (string * string list) list |
75 |
val is_proof_method : 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
|
76 |
val is_atp : theory -> string -> bool |
55288
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
77 |
val bunch_of_proof_methods : bool -> bool -> string -> proof_method list |
48798 | 78 |
val is_fact_chained : (('a * stature) * 'b) -> bool |
57056 | 79 |
val filter_used_facts : bool -> (''a * stature) list -> ((''a * stature) * 'b) list -> |
48798 | 80 |
((''a * stature) * 'b) list |
57054 | 81 |
val play_one_line_proof : mode -> bool -> Time.time -> ((string * 'a) * thm) list -> |
55285 | 82 |
Proof.state -> int -> proof_method -> proof_method list -> proof_method * play_outcome |
55205 | 83 |
val isar_supported_prover_of : theory -> string -> string |
84 |
val choose_minimize_command : theory -> params -> ((string * string list) list -> string -> 'a) -> |
|
55285 | 85 |
string -> proof_method * play_outcome -> 'a |
55205 | 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 |
|
57154 | 98 |
open ATP_Proof |
43085
0a2f5b86bdd7
first step in sharing more code between ATP and Metis translation
blanchet
parents:
43063
diff
changeset
|
99 |
open ATP_Util |
57154 | 100 |
open ATP_Systems |
38028 | 101 |
open ATP_Problem |
46320 | 102 |
open ATP_Problem_Generate |
103 |
open ATP_Proof_Reconstruct |
|
45521 | 104 |
open Metis_Tactic |
51005
ce4290c33d73
eliminated needless speed optimization -- and simplified code quite a bit
blanchet
parents:
50927
diff
changeset
|
105 |
open Sledgehammer_Fact |
55287 | 106 |
open Sledgehammer_Proof_Methods |
54000
9cfff7f61d0d
added experimental configuration options to tune use of builtin symbols in SMT
blanchet
parents:
53989
diff
changeset
|
107 |
|
45376 | 108 |
(* 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
|
109 |
"Async_Manager". *) |
48319
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents:
48314
diff
changeset
|
110 |
val SledgehammerN = "Sledgehammer" |
37585 | 111 |
|
57037 | 112 |
datatype mode = Auto_Try | Try | Normal | MaSh | Auto_Minimize | Minimize |
113 |
||
114 |
fun str_of_mode Auto_Try = "Auto Try" |
|
115 |
| str_of_mode Try = "Try" |
|
116 |
| str_of_mode Normal = "Normal" |
|
117 |
| str_of_mode MaSh = "MaSh" |
|
118 |
| str_of_mode Auto_Minimize = "Auto_Minimize" |
|
119 |
| str_of_mode Minimize = "Minimize" |
|
120 |
||
55323
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55308
diff
changeset
|
121 |
val smtN = "smt" |
253a029335a2
split 'linarith' and 'presburger' (to avoid annoying warnings + to speed up reconstruction when 'presburger' is needed)
blanchet
parents:
55308
diff
changeset
|
122 |
|
55285 | 123 |
val proof_method_names = [metisN, smtN] |
124 |
val is_proof_method = member (op =) proof_method_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
|
125 |
|
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
126 |
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
|
127 |
|
35969 | 128 |
type params = |
48321 | 129 |
{debug : bool, |
130 |
verbose : bool, |
|
131 |
overlord : bool, |
|
53800 | 132 |
spy : bool, |
48321 | 133 |
blocking : bool, |
134 |
provers : string list, |
|
135 |
type_enc : string option, |
|
136 |
strict : bool, |
|
137 |
lam_trans : string option, |
|
138 |
uncurried_aliases : bool option, |
|
139 |
learn : bool, |
|
140 |
fact_filter : string option, |
|
141 |
max_facts : int option, |
|
142 |
fact_thresholds : real * real, |
|
143 |
max_mono_iters : int option, |
|
144 |
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
|
145 |
isar_proofs : bool option, |
57245 | 146 |
compress : real, |
147 |
try0 : bool, |
|
55297
1dfcd49f5dcb
renamed 'smt' option 'smt_proofs' to avoid clash with 'smt' prover
blanchet
parents:
55288
diff
changeset
|
148 |
smt_proofs : bool option, |
48321 | 149 |
slice : bool, |
150 |
minimize : bool option, |
|
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
151 |
timeout : Time.time, |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
152 |
preplay_timeout : Time.time, |
48321 | 153 |
expect : string} |
35867 | 154 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
155 |
type prover_problem = |
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
156 |
{comment : string, |
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
157 |
state : Proof.state, |
48321 | 158 |
goal : thm, |
159 |
subgoal : int, |
|
160 |
subgoal_count : int, |
|
51010 | 161 |
factss : (string * fact list) list} |
35867 | 162 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
163 |
type prover_result = |
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53551
diff
changeset
|
164 |
{outcome : atp_failure option, |
48321 | 165 |
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
|
166 |
used_from : fact list, |
48321 | 167 |
run_time : Time.time, |
55285 | 168 |
preplay : (proof_method * play_outcome) Lazy.lazy, |
169 |
message : proof_method * play_outcome -> string, |
|
48321 | 170 |
message_tail : string} |
35867 | 171 |
|
43051 | 172 |
type prover = |
45520 | 173 |
params -> ((string * string list) list -> string -> minimize_command) |
174 |
-> prover_problem -> prover_result |
|
35867 | 175 |
|
55205 | 176 |
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
|
177 |
|
43052
8d6a4978cc65
automatically minimize with Metis when this can be done within a few seconds
blanchet
parents:
43051
diff
changeset
|
178 |
fun proof_banner mode name = |
55205 | 179 |
(case mode of |
43033 | 180 |
Auto_Try => "Auto Sledgehammer (" ^ quote name ^ ") found a proof" |
181 |
| Try => "Sledgehammer (" ^ quote name ^ ") found a proof" |
|
55205 | 182 |
| _ => "Try this") |
43033 | 183 |
|
55297
1dfcd49f5dcb
renamed 'smt' option 'smt_proofs' to avoid clash with 'smt' prover
blanchet
parents:
55288
diff
changeset
|
184 |
fun bunch_of_proof_methods smt_proofs needs_full_types desperate_lam_trans = |
55288
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
185 |
(if needs_full_types then |
55345 | 186 |
[Metis_Method (SOME full_typesN, NONE), |
55288
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
187 |
Metis_Method (SOME really_full_type_enc, NONE), |
55345 | 188 |
Metis_Method (SOME full_typesN, SOME desperate_lam_trans), |
189 |
Metis_Method (SOME really_full_type_enc, SOME desperate_lam_trans)] |
|
55288
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
190 |
else |
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
191 |
[Metis_Method (NONE, NONE), |
55345 | 192 |
Metis_Method (SOME full_typesN, NONE), |
193 |
Metis_Method (SOME no_typesN, SOME desperate_lam_trans), |
|
194 |
Metis_Method (SOME really_full_type_enc, SOME desperate_lam_trans)]) @ |
|
56081 | 195 |
(if smt_proofs then [SMT2_Method] else []) |
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
196 |
|
55285 | 197 |
fun extract_proof_method ({type_enc, lam_trans, ...} : params) |
198 |
(Metis_Method (type_enc', lam_trans')) = |
|
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
199 |
let |
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
200 |
val override_params = |
55285 | 201 |
(if is_none type_enc' andalso is_none type_enc then [] |
202 |
else [("type_enc", [hd (unalias_type_enc (type_enc' |> the_default partial_typesN))])]) @ |
|
203 |
(if is_none lam_trans' andalso is_none lam_trans then [] |
|
204 |
else [("lam_trans", [lam_trans' |> the_default default_metis_lam_trans])]) |
|
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
205 |
in (metisN, override_params) end |
56081 | 206 |
| extract_proof_method _ SMT2_Method = (smtN, []) |
45561
57227eedce81
don't propagate user-set "type_enc" or "lam_trans" to Metis calls
blanchet
parents:
45560
diff
changeset
|
207 |
|
43033 | 208 |
(* based on "Mirabelle.can_apply" and generalized *) |
43034
18259246abb5
try both "metis" and (on failure) "metisFT" in replay
blanchet
parents:
43033
diff
changeset
|
209 |
fun timed_apply timeout tac state i = |
43033 | 210 |
let |
211 |
val {context = ctxt, facts, goal} = Proof.goal state |
|
212 |
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
|
213 |
in |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
214 |
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
|
215 |
end |
43033 | 216 |
|
57054 | 217 |
fun timed_proof_method timeout ths meth = |
218 |
timed_apply timeout (fn ctxt => tac_of_proof_method ctxt ([], ths) meth) |
|
43033 | 219 |
|
48798 | 220 |
fun is_fact_chained ((_, (sc, _)), _) = sc = Chained |
221 |
||
222 |
fun filter_used_facts keep_chained used = |
|
54773 | 223 |
filter ((member (op =) used o fst) orf (if keep_chained then is_fact_chained else K false)) |
43033 | 224 |
|
57054 | 225 |
fun play_one_line_proof mode verbose timeout pairs state i preferred (meths as meth :: _) = |
43034
18259246abb5
try both "metis" and (on failure) "metisFT" in replay
blanchet
parents:
43033
diff
changeset
|
226 |
let |
56985
82c83978fbd9
correctly add extra facts to lemmas (cf. conjecture and hypotheses) in Z3 Isar proofs
blanchet
parents:
56983
diff
changeset
|
227 |
val ctxt = Proof.context_of state |
82c83978fbd9
correctly add extra facts to lemmas (cf. conjecture and hypotheses) in Z3 Isar proofs
blanchet
parents:
56983
diff
changeset
|
228 |
|
55288
1a4358d14ce2
added 'smt' option to control generation of 'by smt' proofs
blanchet
parents:
55287
diff
changeset
|
229 |
fun get_preferred meths = if member (op =) meths preferred then preferred else meth |
43034
18259246abb5
try both "metis" and (on failure) "metisFT" in replay
blanchet
parents:
43033
diff
changeset
|
230 |
in |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
231 |
if timeout = Time.zeroTime then |
56093 | 232 |
(get_preferred meths, Play_Timed_Out Time.zeroTime) |
45379
0147a4348ca1
try "smt" as a fallback for ATPs if "metis" fails/times out
blanchet
parents:
45378
diff
changeset
|
233 |
else |
50557 | 234 |
let |
54815 | 235 |
val _ = if mode = Minimize then Output.urgent_message "Preplaying proof..." else () |
50557 | 236 |
val ths = pairs |> sort_wrt (fst o fst) |> map snd |
55285 | 237 |
fun play [] [] = (get_preferred meths, Play_Failed) |
54824 | 238 |
| play timed_outs [] = (get_preferred timed_outs, Play_Timed_Out timeout) |
55285 | 239 |
| play timed_out (meth :: meths) = |
50557 | 240 |
let |
241 |
val _ = |
|
242 |
if verbose then |
|
56985
82c83978fbd9
correctly add extra facts to lemmas (cf. conjecture and hypotheses) in Z3 Isar proofs
blanchet
parents:
56983
diff
changeset
|
243 |
Output.urgent_message ("Trying \"" ^ string_of_proof_method ctxt [] meth ^ |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
244 |
"\" for " ^ string_of_time timeout ^ "...") |
50557 | 245 |
else |
246 |
() |
|
247 |
val timer = Timer.startRealTimer () |
|
248 |
in |
|
57054 | 249 |
(case timed_proof_method timeout ths meth state i of |
55285 | 250 |
SOME (SOME _) => (meth, Played (Timer.checkRealTimer timer)) |
55286 | 251 |
| _ => play timed_out meths) |
50557 | 252 |
end |
55285 | 253 |
handle TimeLimit.TimeOut => play (meth :: timed_out) meths |
54824 | 254 |
in |
55285 | 255 |
play [] meths |
54824 | 256 |
end |
43033 | 257 |
end |
258 |
||
55205 | 259 |
val canonical_isar_supported_prover = eN |
57208 | 260 |
val z3N = "z3" |
51013 | 261 |
|
55205 | 262 |
fun isar_supported_prover_of thy name = |
57208 | 263 |
if is_atp thy name orelse name = z3N then name |
55475
b8ebbcc5e49a
restored old 'remotify' logic -- too many bugs were introduced when refactoring the code
blanchet
parents:
55458
diff
changeset
|
264 |
else if is_atp_installed thy canonical_isar_supported_prover then canonical_isar_supported_prover |
b8ebbcc5e49a
restored old 'remotify' logic -- too many bugs were introduced when refactoring the code
blanchet
parents:
55458
diff
changeset
|
265 |
else name |
43051 | 266 |
|
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
267 |
(* 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
|
268 |
"sledgehammer_prover_minimize.ML". *) |
55205 | 269 |
fun choose_minimize_command thy (params as {isar_proofs, ...}) minimize_command name preplay = |
45520 | 270 |
let |
55205 | 271 |
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
|
272 |
val (min_name, override_params) = |
54824 | 273 |
(case preplay of |
56084
75c154e9f650
honor the fact that the new Z3 can generate Isar proofs
blanchet
parents:
56081
diff
changeset
|
274 |
(meth as Metis_Method _, Played _) => |
55285 | 275 |
if isar_proofs = SOME true then (maybe_isar_name, []) else extract_proof_method params meth |
54824 | 276 |
| _ => (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
|
277 |
in minimize_command override_params min_name end |
43051 | 278 |
|
53480
247817dbb990
limit the number of instances of a single theorem
blanchet
parents:
53478
diff
changeset
|
279 |
val max_fact_instances = 10 (* FUDGE *) |
247817dbb990
limit the number of instances of a single theorem
blanchet
parents:
53478
diff
changeset
|
280 |
|
55205 | 281 |
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
|
282 |
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
|
283 |
#> Config.put Monomorph.max_new_instances |
55205 | 284 |
(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
|
285 |
#> 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
|
286 |
|
55212 | 287 |
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
|
288 |
let |
55212 | 289 |
val thy = Proof_Context.theory_of ctxt |
290 |
val (remote_provers, local_provers) = |
|
55285 | 291 |
proof_method_names @ |
55212 | 292 |
sort_strings (supported_atps thy) @ |
56132
64eeda68e693
delayed construction of command (and of noncommercial check) + tuning
blanchet
parents:
56093
diff
changeset
|
293 |
sort_strings (SMT2_Config.available_solvers_of ctxt) |
55212 | 294 |
|> 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
|
295 |
in |
57056 | 296 |
Output.urgent_message ("Supported provers: " ^ 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
|
297 |
end |
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
298 |
|
55212 | 299 |
fun kill_provers () = Async_Manager.kill_threads SledgehammerN "prover" |
300 |
fun running_provers () = Async_Manager.running_threads SledgehammerN "prover" |
|
301 |
val messages = Async_Manager.thread_messages SledgehammerN "prover" |
|
302 |
||
28582 | 303 |
end; |