author | nipkow |
Thu, 17 Jul 2025 21:06:22 +0100 | |
changeset 82885 | 5d2a599f88af |
parent 82620 | 2d854f1cd830 |
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 |
|
75026 | 17 |
type base_slice = Sledgehammer_ATP_Systems.base_slice |
75025 | 18 |
type atp_slice = Sledgehammer_ATP_Systems.atp_slice |
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
19 |
|
58085 | 20 |
datatype mode = Auto_Try | Try | Normal | Minimize | MaSh |
43021 | 21 |
|
73940
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
22 |
datatype induction_rules = Include | Exclude | Instantiate |
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
23 |
val induction_rules_of_string : string -> induction_rules option |
74951
0b6f795d3b78
proper filtering inf induction rules in Mirabelle
desharna
parents:
74948
diff
changeset
|
24 |
val maybe_filter_out_induction_rules : induction_rules -> fact list -> fact list |
73940
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
25 |
|
35969 | 26 |
type params = |
48321 | 27 |
{debug : bool, |
28 |
verbose : bool, |
|
29 |
overlord : bool, |
|
53800 | 30 |
spy : bool, |
48321 | 31 |
provers : string list, |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
32 |
abduce : int option, |
77428 | 33 |
falsify : bool option, |
48321 | 34 |
type_enc : string option, |
35 |
strict : bool, |
|
36 |
lam_trans : string option, |
|
37 |
uncurried_aliases : bool option, |
|
38 |
learn : bool, |
|
39 |
fact_filter : string option, |
|
73939
9231ea46e041
promoted "sledgehammer_instantiate_inducts" to proper option "induction_rules"
desharna
parents:
72798
diff
changeset
|
40 |
induction_rules : induction_rules option, |
48321 | 41 |
max_facts : int option, |
42 |
fact_thresholds : real * real, |
|
43 |
max_mono_iters : int option, |
|
44 |
max_new_mono_instances : int option, |
|
75031 | 45 |
max_proofs : int, |
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
|
46 |
isar_proofs : bool option, |
57783 | 47 |
compress : real option, |
57245 | 48 |
try0 : bool, |
71931
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
63692
diff
changeset
|
49 |
smt_proofs : bool, |
81746 | 50 |
instantiate : bool option, |
57721 | 51 |
minimize : bool, |
75023 | 52 |
slices : int, |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
53 |
timeout : Time.time, |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
54 |
preplay_timeout : Time.time, |
81610 | 55 |
expect : string, |
56 |
cache_dir : Path.T option} |
|
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
57 |
|
74948
15ce207f69c8
added support for initialization messages to Mirabelle
desharna
parents:
74897
diff
changeset
|
58 |
val string_of_params : params -> string |
75340
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
59 |
val slice_timeout : int -> int -> Time.time -> Time.time |
74897
8b1ab558e3ee
reused Sledgehammer code to parse parameters of sledgehammer action in Mirabelle
desharna
parents:
74370
diff
changeset
|
60 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
61 |
type prover_problem = |
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
62 |
{comment : string, |
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
63 |
state : Proof.state, |
48321 | 64 |
goal : thm, |
65 |
subgoal : int, |
|
66 |
subgoal_count : int, |
|
75025 | 67 |
factss : (string * fact list) list, |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
68 |
has_already_found_something : unit -> bool, |
81610 | 69 |
found_something : string -> unit, |
70 |
memoize_fun_call : (string -> string) -> string -> string} |
|
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
71 |
|
75063
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
72 |
datatype prover_slice_extra = |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
73 |
ATP_Slice of atp_slice |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
74 |
| SMT_Slice of string list |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81746
diff
changeset
|
75 |
| No_Slice |
75063
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
76 |
|
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
77 |
type prover_slice = base_slice * prover_slice_extra |
75025 | 78 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
79 |
type prover_result = |
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53551
diff
changeset
|
80 |
{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
|
81 |
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
|
82 |
used_from : fact list, |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57732
diff
changeset
|
83 |
preferred_methss : proof_method * proof_method list list, |
48321 | 84 |
run_time : Time.time, |
82620
2d854f1cd830
clarify Sledgehammer instantiations without preplay (dont_preplay option and tactic provers)
Lukas Bartl <lukas.bartl@uni-a.de>
parents:
82202
diff
changeset
|
85 |
message : ((Pretty.T * stature) list * (proof_method * play_outcome)) option -> string} |
39493
cb2208f2c07d
move SPASS's Flotter hack to "Sledgehammer_Reconstruct"
blanchet
parents:
39492
diff
changeset
|
86 |
|
75025 | 87 |
type prover = params -> prover_problem -> prover_slice -> prover_result |
35867 | 88 |
|
48319
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents:
48314
diff
changeset
|
89 |
val SledgehammerN : string |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
90 |
val default_abduce_max_candidates : int |
57037 | 91 |
val str_of_mode : mode -> string |
55205 | 92 |
val overlord_file_location_of_prover : string -> string * string |
93 |
val proof_banner : mode -> string -> string |
|
75036 | 94 |
val is_atp : string -> bool |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
95 |
val bunches_of_metis_methods : Proof.context -> bool -> bool -> proof_method list list |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
96 |
val bunches_of_smt_methods : Proof.context -> proof_method list list |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
97 |
val bunches_of_proof_methods : Proof.context -> bool -> bool -> bool -> proof_method list list |
75060
789e0e1a9e33
more precise slicing computation and output when not enough lemmas are available (e.g. with the 'only' syntax 'sledgehammer (lem1 lem2 lem3)')
blanchet
parents:
75040
diff
changeset
|
98 |
val facts_of_filter : string -> (string * fact list) list -> fact list |
75069
455d886009b1
uniformized fact selection for ATP and SMT in Sledgehammer
desharna
parents:
75063
diff
changeset
|
99 |
val facts_of_basic_slice : base_slice -> (string * fact list) list -> fact list |
48798 | 100 |
val is_fact_chained : (('a * stature) * 'b) -> bool |
57056 | 101 |
val filter_used_facts : bool -> (''a * stature) list -> ((''a * stature) * 'b) list -> |
48798 | 102 |
((''a * stature) * 'b) list |
55205 | 103 |
val repair_monomorph_context : int option -> int -> int option -> int -> Proof.context -> |
104 |
Proof.context |
|
55212 | 105 |
val supported_provers : Proof.context -> unit |
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
106 |
end; |
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
107 |
|
55201 | 108 |
structure Sledgehammer_Prover : SLEDGEHAMMER_PROVER = |
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
109 |
struct |
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
110 |
|
57154 | 111 |
open ATP_Proof |
43085
0a2f5b86bdd7
first step in sharing more code between ATP and Metis translation
blanchet
parents:
43063
diff
changeset
|
112 |
open ATP_Util |
38028 | 113 |
open ATP_Problem |
46320 | 114 |
open ATP_Problem_Generate |
115 |
open ATP_Proof_Reconstruct |
|
51005
ce4290c33d73
eliminated needless speed optimization -- and simplified code quite a bit
blanchet
parents:
50927
diff
changeset
|
116 |
open Sledgehammer_Fact |
55287 | 117 |
open Sledgehammer_Proof_Methods |
72400 | 118 |
open Sledgehammer_ATP_Systems |
54000
9cfff7f61d0d
added experimental configuration options to tune use of builtin symbols in SMT
blanchet
parents:
53989
diff
changeset
|
119 |
|
58085 | 120 |
(* Identifier that distinguishes Sledgehammer from other tools that could use "Async_Manager". *) |
48319
340187063d84
use async manager to manage MaSh learners to make sure they get killed cleanly
blanchet
parents:
48314
diff
changeset
|
121 |
val SledgehammerN = "Sledgehammer" |
37585 | 122 |
|
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
123 |
val default_abduce_max_candidates = 1 |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
124 |
|
58085 | 125 |
datatype mode = Auto_Try | Try | Normal | Minimize | MaSh |
57037 | 126 |
|
127 |
fun str_of_mode Auto_Try = "Auto Try" |
|
128 |
| str_of_mode Try = "Try" |
|
129 |
| str_of_mode Normal = "Normal" |
|
58085 | 130 |
| str_of_mode Minimize = "Minimize" |
57037 | 131 |
| str_of_mode MaSh = "MaSh" |
132 |
||
73940
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
133 |
datatype induction_rules = Include | Exclude | Instantiate |
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
134 |
|
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
135 |
fun induction_rules_of_string "include" = SOME Include |
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
136 |
| induction_rules_of_string "exclude" = SOME Exclude |
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
137 |
| induction_rules_of_string "instantiate" = SOME Instantiate |
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
138 |
| induction_rules_of_string _ = NONE |
f58108b7a60c
refactored Sledgehammer option "induction_rules"
desharna
parents:
73939
diff
changeset
|
139 |
|
75465
d9b23902692d
excluded dummy ATPs from Sledgehammer's default provers
desharna
parents:
75340
diff
changeset
|
140 |
val is_atp = member (op =) all_atps |
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
141 |
|
35969 | 142 |
type params = |
48321 | 143 |
{debug : bool, |
144 |
verbose : bool, |
|
145 |
overlord : bool, |
|
53800 | 146 |
spy : bool, |
48321 | 147 |
provers : string list, |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
148 |
abduce : int option, |
77428 | 149 |
falsify : bool option, |
48321 | 150 |
type_enc : string option, |
151 |
strict : bool, |
|
152 |
lam_trans : string option, |
|
153 |
uncurried_aliases : bool option, |
|
154 |
learn : bool, |
|
155 |
fact_filter : string option, |
|
73939
9231ea46e041
promoted "sledgehammer_instantiate_inducts" to proper option "induction_rules"
desharna
parents:
72798
diff
changeset
|
156 |
induction_rules : induction_rules option, |
48321 | 157 |
max_facts : int option, |
158 |
fact_thresholds : real * real, |
|
159 |
max_mono_iters : int option, |
|
160 |
max_new_mono_instances : int option, |
|
75031 | 161 |
max_proofs : int, |
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
|
162 |
isar_proofs : bool option, |
57783 | 163 |
compress : real option, |
57245 | 164 |
try0 : bool, |
71931
0c8a9c028304
simplified 'smt_proofs' option to be a binary option (instead of ternary), now that SMT proofs are accepted in the AFP (done with Martin Desharnais)
blanchet
parents:
63692
diff
changeset
|
165 |
smt_proofs : bool, |
81746 | 166 |
instantiate : bool option, |
57721 | 167 |
minimize : bool, |
75023 | 168 |
slices : int, |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
169 |
timeout : Time.time, |
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54815
diff
changeset
|
170 |
preplay_timeout : Time.time, |
81610 | 171 |
expect : string, |
172 |
cache_dir : Path.T option} |
|
35867 | 173 |
|
74948
15ce207f69c8
added support for initialization messages to Mirabelle
desharna
parents:
74897
diff
changeset
|
174 |
fun string_of_params (params : params) = |
80874
9af593e9e454
prefer Pretty.pure_string_of to produce output without markup, instead of cleaning output afterwards;
wenzelm
parents:
80820
diff
changeset
|
175 |
Pretty.pure_string_of (Pretty.from_ML (ML_system_pretty (params, 100))) |
74948
15ce207f69c8
added support for initialization messages to Mirabelle
desharna
parents:
74897
diff
changeset
|
176 |
|
74951
0b6f795d3b78
proper filtering inf induction rules in Mirabelle
desharna
parents:
74948
diff
changeset
|
177 |
fun maybe_filter_out_induction_rules induction_rules : fact list -> fact list = |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
178 |
induction_rules = Exclude ? |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
179 |
filter_out (fn ((_, (_, ATP_Problem_Generate.Induction)), _) => true | _ => false) |
74951
0b6f795d3b78
proper filtering inf induction rules in Mirabelle
desharna
parents:
74948
diff
changeset
|
180 |
|
75340
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
181 |
fun slice_timeout slice_size slices timeout = |
75034 | 182 |
let |
183 |
val max_threads = Multithreading.max_threads () |
|
184 |
val batches = (slices + max_threads - 1) div max_threads |
|
185 |
in |
|
75340
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
186 |
seconds (Real.fromInt slice_size * Time.toReal timeout / Real.fromInt batches) |
75034 | 187 |
end |
75023 | 188 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
189 |
type prover_problem = |
54141
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
190 |
{comment : string, |
f57f8e7a879f
generate a comment storing the goal nickname in "learn_prover"
blanchet
parents:
54126
diff
changeset
|
191 |
state : Proof.state, |
48321 | 192 |
goal : thm, |
193 |
subgoal : int, |
|
194 |
subgoal_count : int, |
|
75025 | 195 |
factss : (string * fact list) list, |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
196 |
has_already_found_something : unit -> bool, |
81610 | 197 |
found_something : string -> unit, |
198 |
memoize_fun_call : (string -> string) -> string -> string} |
|
35867 | 199 |
|
75063
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
200 |
datatype prover_slice_extra = |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
201 |
ATP_Slice of atp_slice |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
202 |
| SMT_Slice of string list |
82202
a1f85f579a07
initial work on Magnushammer-inspured tactic hammer (from Jasmin)
desharna
parents:
81746
diff
changeset
|
203 |
| No_Slice |
75063
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
204 |
|
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
205 |
type prover_slice = base_slice * prover_slice_extra |
75025 | 206 |
|
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
207 |
type prover_result = |
53586
bd5fa6425993
prefixed types and some functions with "atp_" for disambiguation
blanchet
parents:
53551
diff
changeset
|
208 |
{outcome : atp_failure option, |
48321 | 209 |
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
|
210 |
used_from : fact list, |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57732
diff
changeset
|
211 |
preferred_methss : proof_method * proof_method list list, |
48321 | 212 |
run_time : Time.time, |
82620
2d854f1cd830
clarify Sledgehammer instantiations without preplay (dont_preplay option and tactic provers)
Lukas Bartl <lukas.bartl@uni-a.de>
parents:
82202
diff
changeset
|
213 |
message : ((Pretty.T * stature) list * (proof_method * play_outcome)) option -> string} |
35867 | 214 |
|
75025 | 215 |
type prover = params -> prover_problem -> prover_slice -> prover_result |
35867 | 216 |
|
55205 | 217 |
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
|
218 |
|
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75017
diff
changeset
|
219 |
fun proof_banner mode prover_name = |
55205 | 220 |
(case mode of |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
221 |
Auto_Try => "Auto Sledgehammer (" ^ prover_name ^ ") found a proof:" |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
222 |
| Try => "Sledgehammer (" ^ prover_name ^ ") found a proof:" |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
223 |
| _ => "Try this:") |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
224 |
|
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
225 |
fun bunches_of_metis_methods ctxt needs_full_types needs_lam_defs = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
226 |
let |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
227 |
(* metis without options (preferred) *) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
228 |
val preferred_method = Metis_Method (NONE, NONE, []) |
43033 | 229 |
|
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
230 |
(* metis with different options *) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
231 |
val desperate_lam_trans = if needs_lam_defs then liftingN else opaque_liftingN |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
232 |
val option_methods = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
233 |
Metis_Method (SOME full_typesN, NONE, []) :: |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
234 |
Metis_Method (NONE, SOME liftingN, []) :: |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
235 |
Metis_Method (SOME really_full_type_enc, SOME desperate_lam_trans, []) :: |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
236 |
(if needs_full_types then |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
237 |
[Metis_Method (SOME really_full_type_enc, NONE, []), |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
238 |
Metis_Method (SOME full_typesN, SOME desperate_lam_trans, [])] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
239 |
else |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
240 |
[Metis_Method (SOME no_typesN, SOME desperate_lam_trans, [])]) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
241 |
|
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
242 |
(* metis with extensionality (often needed for lifting) *) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
243 |
val ext_facts = [short_thm_name ctxt ext] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
244 |
val ext_methods = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
245 |
Metis_Method (NONE, SOME liftingN, ext_facts) :: |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
246 |
(if not needs_lam_defs then |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
247 |
[] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
248 |
else if needs_full_types then |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
249 |
[Metis_Method (SOME full_typesN, SOME liftingN, ext_facts)] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
250 |
else |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
251 |
[Metis_Method (SOME no_typesN, SOME liftingN, ext_facts)]) |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
252 |
in |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
253 |
[[preferred_method], option_methods, ext_methods] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
254 |
end |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
255 |
|
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
256 |
fun bunches_of_smt_methods ctxt = |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
257 |
[map (SMT_Method o SMT_Verit) (Verit_Strategies.all_veriT_stgies (Context.Proof ctxt)), |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
258 |
[SMT_Method SMT_Z3]] |
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
259 |
|
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
260 |
fun bunches_of_proof_methods ctxt smt_proofs needs_full_types needs_lam_defs = |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
261 |
let |
75868
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75465
diff
changeset
|
262 |
val misc_methodss = |
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75465
diff
changeset
|
263 |
[[Simp_Method, Auto_Method, Blast_Method, Linarith_Method, Meson_Method, |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
264 |
Metis_Method (NONE, NONE, []), Fastforce_Method, Force_Method, Presburger_Method, |
79942
7793e3161d2b
try proof method "order" in Sledgehammer's proof reconstruction
desharna
parents:
78695
diff
changeset
|
265 |
Argo_Method, Order_Method]] |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
266 |
|
75868
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75465
diff
changeset
|
267 |
val metis_methodss = |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
268 |
tl (bunches_of_metis_methods ctxt needs_full_types needs_lam_defs) |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
269 |
|
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
270 |
val smt_methodss = |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
271 |
if smt_proofs then |
81254
d3c0734059ee
variable instantiation in Sledgehammer and Metis
blanchet
parents:
80874
diff
changeset
|
272 |
bunches_of_smt_methods ctxt |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
273 |
else |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
274 |
[] |
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
275 |
in |
75868
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75465
diff
changeset
|
276 |
misc_methodss @ metis_methodss @ smt_methodss |
72518
4be6ae020fc4
Added smt (verit) to Sledgehammer's proof preplay.
desharna
parents:
72400
diff
changeset
|
277 |
end |
43033 | 278 |
|
75060
789e0e1a9e33
more precise slicing computation and output when not enough lemmas are available (e.g. with the 'only' syntax 'sledgehammer (lem1 lem2 lem3)')
blanchet
parents:
75040
diff
changeset
|
279 |
fun facts_of_filter fact_filter factss = |
75025 | 280 |
(case AList.lookup (op =) factss fact_filter of |
281 |
SOME facts => facts |
|
282 |
| NONE => snd (hd factss)) |
|
283 |
||
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
284 |
fun facts_of_basic_slice (_, _, _, num_facts, fact_filter) factss = |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
285 |
let |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
286 |
val facts = facts_of_filter fact_filter factss |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
287 |
val (goal_facts, nongoal_facts) = |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
288 |
List.partition (equal sledgehammer_goal_as_fact o fst o fst) facts |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
289 |
in |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
290 |
goal_facts @ take num_facts nongoal_facts |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76052
diff
changeset
|
291 |
end |
75069
455d886009b1
uniformized fact selection for ATP and SMT in Sledgehammer
desharna
parents:
75063
diff
changeset
|
292 |
|
48798 | 293 |
fun is_fact_chained ((_, (sc, _)), _) = sc = Chained |
294 |
||
295 |
fun filter_used_facts keep_chained used = |
|
58654
3e1cad27fc2f
special treatment of extensionality in minimizer
blanchet
parents:
58498
diff
changeset
|
296 |
filter ((member (eq_fst (op =)) used o fst) orf |
3e1cad27fc2f
special treatment of extensionality in minimizer
blanchet
parents:
58498
diff
changeset
|
297 |
(if keep_chained then is_fact_chained else K false)) |
43033 | 298 |
|
53480
247817dbb990
limit the number of instances of a single theorem
blanchet
parents:
53478
diff
changeset
|
299 |
val max_fact_instances = 10 (* FUDGE *) |
76052
6a20d0ebd5b3
added a bound in SMT on the number of schematic constants considered -- the code (in for_schematics) is exponential in that number
blanchet
parents:
75956
diff
changeset
|
300 |
val max_schematics = 20 (* FUDGE *) |
53480
247817dbb990
limit the number of instances of a single theorem
blanchet
parents:
53478
diff
changeset
|
301 |
|
55205 | 302 |
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
|
303 |
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
|
304 |
#> Config.put Monomorph.max_new_instances |
55205 | 305 |
(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
|
306 |
#> Config.put Monomorph.max_thm_instances max_fact_instances |
76052
6a20d0ebd5b3
added a bound in SMT on the number of schematic constants considered -- the code (in for_schematics) is exponential in that number
blanchet
parents:
75956
diff
changeset
|
307 |
#> Config.put Monomorph.max_schematics max_schematics |
52034
11b48e7a4e7e
correctly 'repair' the monomorphization context for SMT solvers from Sledgehammer
blanchet
parents:
52031
diff
changeset
|
308 |
|
55212 | 309 |
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
|
310 |
let |
75036 | 311 |
val local_provers = sort_strings (local_atps @ SMT_Config.available_solvers_of ctxt) |
312 |
val remote_provers = sort_strings remote_atps |
|
43050
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
313 |
in |
63692 | 314 |
writeln ("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
|
315 |
end |
59284a13abc4
support "metis" and "metisFT" as provers in the architecture, so they can be used for minimizing
blanchet
parents:
43044
diff
changeset
|
316 |
|
28582 | 317 |
end; |