author | wenzelm |
Sun, 31 Dec 2023 19:24:37 +0100 | |
changeset 79409 | e1895596e1b9 |
parent 79399 | 11b53e039f6f |
child 80910 | 406a85a25189 |
permissions | -rw-r--r-- |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
1 |
(* Title: HOL/Tools/Sledgehammer/sledgehammer.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 |
|
38021
e024504943d1
rename "ATP_Manager" ML module to "Sledgehammer";
blanchet
parents:
38020
diff
changeset
|
6 |
Sledgehammer's heart. |
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 |
|
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
9 |
signature SLEDGEHAMMER = |
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
10 |
sig |
60612
79d71bfea310
removed chained facts from preplaying -- and careful about extra chained facts when removing 'proof -' and 'qed' from one-line Isar proofs
blanchet
parents:
60549
diff
changeset
|
11 |
type stature = ATP_Problem_Generate.stature |
51008 | 12 |
type fact = Sledgehammer_Fact.fact |
48292 | 13 |
type fact_override = Sledgehammer_Fact.fact_override |
57755 | 14 |
type proof_method = Sledgehammer_Proof_Methods.proof_method |
15 |
type play_outcome = Sledgehammer_Proof_Methods.play_outcome |
|
55201 | 16 |
type mode = Sledgehammer_Prover.mode |
17 |
type params = Sledgehammer_Prover.params |
|
74951
0b6f795d3b78
proper filtering inf induction rules in Mirabelle
desharna
parents:
74950
diff
changeset
|
18 |
type induction_rules = Sledgehammer_Prover.induction_rules |
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
19 |
type prover_problem = Sledgehammer_Prover.prover_problem |
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
20 |
type prover_result = Sledgehammer_Prover.prover_result |
40061
71cc5aac8b76
generalization of the Sledgehammer minimizer, to make it possible to handle SMT solvers as well
blanchet
parents:
40060
diff
changeset
|
21 |
|
76524
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
22 |
type preplay_result = proof_method * (play_outcome * (string * stature) list) |
75372 | 23 |
|
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
24 |
datatype sledgehammer_outcome = |
75372 | 25 |
SH_Some of prover_result * preplay_result list |
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
26 |
| SH_Unknown |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
27 |
| SH_TimeOut |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
28 |
| SH_ResourcesOut |
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
29 |
| SH_None |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
30 |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
31 |
val short_string_of_sledgehammer_outcome : sledgehammer_outcome -> string |
51010 | 32 |
val string_of_factss : (string * fact list) list -> string |
54816
10d48c2a3e32
made timeouts in Sledgehammer not be 'option's -- simplified lots of code
blanchet
parents:
54799
diff
changeset
|
33 |
val run_sledgehammer : params -> mode -> (string -> unit) option -> int -> fact_override -> |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
34 |
Proof.state -> bool * (sledgehammer_outcome * string) |
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
35 |
end; |
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
36 |
|
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
37 |
structure Sledgehammer : SLEDGEHAMMER = |
28477
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
38 |
struct |
9339d4dcec8b
version of sledgehammer using threads instead of processes, misc cleanup;
wenzelm
parents:
diff
changeset
|
39 |
|
43085
0a2f5b86bdd7
first step in sharing more code between ATP and Metis translation
blanchet
parents:
43064
diff
changeset
|
40 |
open ATP_Util |
75029 | 41 |
open ATP_Problem |
55212 | 42 |
open ATP_Proof |
46320 | 43 |
open ATP_Problem_Generate |
38023 | 44 |
open Sledgehammer_Util |
48250
1065c307fafe
further ML structure split to permit finer-grained loading/reordering (problem to solve: MaSh needs most of Sledgehammer)
blanchet
parents:
47904
diff
changeset
|
45 |
open Sledgehammer_Fact |
55287 | 46 |
open Sledgehammer_Proof_Methods |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57557
diff
changeset
|
47 |
open Sledgehammer_Isar_Proof |
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57557
diff
changeset
|
48 |
open Sledgehammer_Isar_Preplay |
57740 | 49 |
open Sledgehammer_Isar_Minimize |
75029 | 50 |
open Sledgehammer_ATP_Systems |
55201 | 51 |
open Sledgehammer_Prover |
55212 | 52 |
open Sledgehammer_Prover_ATP |
55202
824c48a539c9
renamed many Sledgehammer ML files to clarify structure
blanchet
parents:
55201
diff
changeset
|
53 |
open Sledgehammer_Prover_Minimize |
48381 | 54 |
open Sledgehammer_MaSh |
40072
27f2a45b0aab
more robust handling of "remote_" vs. non-"remote_" provers
blanchet
parents:
40071
diff
changeset
|
55 |
|
76524
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
56 |
type preplay_result = proof_method * (play_outcome * (string * stature) list) |
75372 | 57 |
|
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
58 |
datatype sledgehammer_outcome = |
75372 | 59 |
SH_Some of prover_result * preplay_result list |
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
60 |
| SH_Unknown |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
61 |
| SH_TimeOut |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
62 |
| SH_ResourcesOut |
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
63 |
| SH_None |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
64 |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
65 |
fun short_string_of_sledgehammer_outcome (SH_Some _) = "some" |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
66 |
| short_string_of_sledgehammer_outcome SH_Unknown = "unknown" |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
67 |
| short_string_of_sledgehammer_outcome SH_TimeOut = "timeout" |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
68 |
| short_string_of_sledgehammer_outcome SH_ResourcesOut = "resources_out" |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
69 |
| short_string_of_sledgehammer_outcome SH_None = "none" |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
70 |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
71 |
fun alternative f (SOME x) (SOME y) = SOME (f (x, y)) |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
72 |
| alternative _ (x as SOME _) NONE = x |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
73 |
| alternative _ NONE (y as SOME _) = y |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
74 |
| alternative _ NONE NONE = NONE |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
75 |
|
79399 | 76 |
fun varify_nonfixed_terms_global nonfixeds tm = |
79409 | 77 |
tm |> Term.map_aterms |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
78 |
(fn Free (x, T) => if member (op =) nonfixeds x then Var ((x, 0), T) else raise Same.SAME |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
79 |
| Var (xi, _) => raise TERM (Logic.bad_schematic xi, [tm]) |
79399 | 80 |
| _ => raise Same.SAME) |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
81 |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
82 |
fun max_outcome outcomes = |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
83 |
let |
75046 | 84 |
val some = find_first (fn (SH_Some _, _) => true | _ => false) outcomes |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
85 |
val timeout = find_first (fn (SH_TimeOut, _) => true | _ => false) outcomes |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
86 |
val resources_out = find_first (fn (SH_ResourcesOut, _) => true | _ => false) outcomes |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
87 |
val unknown = find_first (fn (SH_Unknown, _) => true | _ => false) outcomes |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
88 |
val none = find_first (fn (SH_None, _) => true | _ => false) outcomes |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
89 |
in |
75046 | 90 |
some |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
91 |
|> alternative snd unknown |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
92 |
|> alternative snd timeout |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
93 |
|> alternative snd resources_out |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
94 |
|> alternative snd none |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
95 |
|> the_default (SH_Unknown, "") |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
96 |
end |
43020
abb5d1f907e4
added "try" command, to launch Solve Direct, Quickcheck, Nitpick, Sledgehammer, and Try Methods
blanchet
parents:
43006
diff
changeset
|
97 |
|
77420 | 98 |
fun play_one_line_proofs minimize timeout used_facts state goal i methss = |
63311
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
99 |
(if timeout = Time.zeroTime then |
75372 | 100 |
[] |
63311
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
101 |
else |
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
102 |
let |
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
103 |
val ctxt = Proof.context_of state |
75372 | 104 |
val used_facts = filter_out (fn (_, (sc, _)) => sc = Chained) used_facts |
105 |
val fact_names = map fst used_facts |
|
77420 | 106 |
val {facts = chained, ...} = Proof.goal state |
63311
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
107 |
val goal_t = Logic.get_goal (Thm.prop_of goal) i |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57557
diff
changeset
|
108 |
|
75372 | 109 |
fun try_methss ress [] = ress |
63311
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
110 |
| try_methss ress (meths :: methss) = |
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
111 |
let |
75372 | 112 |
fun mk_step meths = |
72584 | 113 |
Prove { |
114 |
qualifiers = [], |
|
115 |
obtains = [], |
|
116 |
label = ("", 0), |
|
117 |
goal = goal_t, |
|
118 |
subproofs = [], |
|
119 |
facts = ([], fact_names), |
|
120 |
proof_methods = meths, |
|
121 |
comment = ""} |
|
75372 | 122 |
val ress' = |
123 |
preplay_isar_step ctxt chained timeout [] (mk_step meths) |
|
75868
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75664
diff
changeset
|
124 |
|> map (fn (meth, play_outcome) => |
75372 | 125 |
(case (minimize, play_outcome) of |
126 |
(true, Played time) => |
|
127 |
let |
|
128 |
val (time', used_names') = |
|
129 |
minimized_isar_step ctxt chained time (mk_step [meth]) |
|
130 |
||> (facts_of_isar_step #> snd) |
|
131 |
val used_facts' = filter (member (op =) used_names' o fst) used_facts |
|
132 |
in |
|
133 |
(meth, Played time', used_facts') |
|
134 |
end |
|
135 |
| _ => (meth, play_outcome, used_facts))) |
|
136 |
val any_succeeded = exists (fn (_, Played _, _) => true | _ => false) ress' |
|
63311
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
137 |
in |
75372 | 138 |
try_methss (ress' @ ress) (if any_succeeded then [] else methss) |
63311
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
139 |
end |
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
140 |
in |
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
141 |
try_methss [] methss |
540cfb14a751
be more careful before filtering out chained facts in Sledgehammer
blanchet
parents:
63097
diff
changeset
|
142 |
end) |
76524
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
143 |
|> map (fn (meth, play_outcome, used_facts) => |
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
144 |
(meth, (play_outcome, filter_out (fn (_, (sc, _)) => sc = Chained) used_facts))) |
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
145 |
|> sort (play_outcome_ord o apply2 (fn (_, (play_outcome, _)) => play_outcome)) |
75372 | 146 |
|
147 |
fun select_one_line_proof used_facts preferred_meth preplay_results = |
|
148 |
(case preplay_results of |
|
75374
6e8ca4959334
tuned sledehammer to return best succeeding preplay method
desharna
parents:
75373
diff
changeset
|
149 |
(* Select best method if preplay succeeded *) |
76524
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
150 |
(best_meth, (best_outcome as Played _, best_used_facts)) :: _ => |
75374
6e8ca4959334
tuned sledehammer to return best succeeding preplay method
desharna
parents:
75373
diff
changeset
|
151 |
(best_used_facts, (best_meth, best_outcome)) |
75868
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75664
diff
changeset
|
152 |
(* Otherwise select preferred method *) |
76524
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
153 |
| _ => |
75868
e7b04452eef3
revived 'try0' and 'smart' Isar proofs in Sledgehammer
blanchet
parents:
75664
diff
changeset
|
154 |
(used_facts, (preferred_meth, |
76524
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
155 |
(case AList.lookup (op =) preplay_results preferred_meth of |
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
156 |
SOME (outcome, _) => outcome |
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
157 |
| NONE => Play_Timed_Out Time.zeroTime)))) |
75372 | 158 |
|> apfst (filter_out (fn (_, (sc, _)) => sc = Chained)) |
57734
18bb3e1ff6f6
rationalized preplaying by eliminating (now superfluous) laziness
blanchet
parents:
57557
diff
changeset
|
159 |
|
75035 | 160 |
fun launch_prover (params as {verbose, spy, slices, timeout, ...}) mode learn |
75033 | 161 |
(problem as {state, subgoal, factss, ...} : prover_problem) |
77428 | 162 |
(slice as ((slice_size, abduce, falsify, num_facts, fact_filter), _)) name = |
41089 | 163 |
let |
164 |
val ctxt = Proof.context_of state |
|
53800 | 165 |
|
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
166 |
val _ = spying spy (fn () => (state, subgoal, name, |
77428 | 167 |
"Launched" ^ (if abduce then " (abduce)" else "") ^ (if falsify then " (falsify)" else ""))) |
53800 | 168 |
|
75033 | 169 |
val _ = |
170 |
if verbose then |
|
171 |
writeln (name ^ " with " ^ string_of_int num_facts ^ " " ^ fact_filter ^ " fact" ^ |
|
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
|
172 |
plural_s num_facts ^ " for " ^ string_of_time (slice_timeout slice_size slices timeout) ^ |
77428 | 173 |
(if abduce then " (abduce)" else "") ^ (if falsify then " (falsify)" else "") ^ "...") |
75033 | 174 |
else |
175 |
() |
|
176 |
||
51009
e8ff34a1fa9a
thread through fact triple component from which used facts come, for accurate index output
blanchet
parents:
51008
diff
changeset
|
177 |
fun print_used_facts used_facts used_from = |
e8ff34a1fa9a
thread through fact triple component from which used facts come, for accurate index output
blanchet
parents:
51008
diff
changeset
|
178 |
tag_list 1 used_from |
51005
ce4290c33d73
eliminated needless speed optimization -- and simplified code quite a bit
blanchet
parents:
51004
diff
changeset
|
179 |
|> map (fn (j, fact) => fact |> apsnd (K j)) |
48798 | 180 |
|> filter_used_facts false used_facts |
48394
82fc8c956cdc
fixed various issues with MaSh's file handling + tune output + generate local facts again + handle nameless facts gracefully
blanchet
parents:
48384
diff
changeset
|
181 |
|> map (fn ((name, _), j) => name ^ "@" ^ string_of_int j) |
82fc8c956cdc
fixed various issues with MaSh's file handling + tune output + generate local facts again + handle nameless facts gracefully
blanchet
parents:
48384
diff
changeset
|
182 |
|> commas |
77428 | 183 |
|> prefix ("Facts in " ^ name ^ " " ^ (if falsify then "falsification" else "proof") ^ ": ") |
58843 | 184 |
|> writeln |
53800 | 185 |
|
54062 | 186 |
fun spying_str_of_res ({outcome = NONE, used_facts, used_from, ...} : prover_result) = |
187 |
let |
|
188 |
val num_used_facts = length used_facts |
|
54063 | 189 |
|
190 |
fun find_indices facts = |
|
191 |
tag_list 1 facts |
|
54062 | 192 |
|> map (fn (j, fact) => fact |> apsnd (K j)) |
193 |
|> filter_used_facts false used_facts |
|
54773 | 194 |
|> distinct (eq_fst (op =)) |
54062 | 195 |
|> map (prefix "@" o string_of_int o snd) |
54063 | 196 |
|
197 |
fun filter_info (fact_filter, facts) = |
|
198 |
let |
|
199 |
val indices = find_indices facts |
|
75033 | 200 |
(* "Int.max" is there for robustness *) |
54773 | 201 |
val unknowns = replicate (Int.max (0, num_used_facts - length indices)) "?" |
202 |
in |
|
203 |
(commas (indices @ unknowns), fact_filter) |
|
204 |
end |
|
54063 | 205 |
|
206 |
val filter_infos = |
|
75025 | 207 |
map filter_info (("actual", used_from) :: factss) |
54063 | 208 |
|> AList.group (op =) |
209 |
|> map (fn (indices, fact_filters) => commas fact_filters ^ ": " ^ indices) |
|
54062 | 210 |
in |
77428 | 211 |
"Success: Found " ^ (if falsify then "falsification" else "proof") ^ " with " ^ |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
212 |
string_of_int num_used_facts ^ " fact" ^ plural_s num_used_facts ^ |
54063 | 213 |
(if num_used_facts = 0 then "" else ": " ^ commas filter_infos) |
53800 | 214 |
end |
215 |
| spying_str_of_res {outcome = SOME failure, ...} = |
|
54062 | 216 |
"Failure: " ^ string_of_atp_failure failure |
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
217 |
in |
75033 | 218 |
get_minimizing_prover ctxt mode learn name params problem slice |
219 |
|> verbose ? tap (fn {outcome = NONE, used_facts as _ :: _, used_from, ...} => |
|
220 |
print_used_facts used_facts used_from |
|
221 |
| _ => ()) |
|
222 |
|> spy ? tap (fn res => spying spy (fn () => (state, subgoal, name, spying_str_of_res res))) |
|
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
223 |
end |
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
224 |
|
77420 | 225 |
fun preplay_prover_result ({minimize, preplay_timeout, ...} : params) state goal subgoal |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
226 |
(result as {outcome, used_facts, preferred_methss, message, ...} : prover_result) = |
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
227 |
let |
75372 | 228 |
val (output, chosen_preplay_outcome) = |
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
229 |
if outcome = SOME ATP_Proof.TimedOut then |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
230 |
(SH_TimeOut, select_one_line_proof used_facts (fst preferred_methss) []) |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
231 |
else if outcome = SOME ATP_Proof.OutOfResources then |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
232 |
(SH_ResourcesOut, select_one_line_proof used_facts (fst preferred_methss) []) |
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
233 |
else if is_some outcome then |
75372 | 234 |
(SH_None, select_one_line_proof used_facts (fst preferred_methss) []) |
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
235 |
else |
75372 | 236 |
let |
237 |
val preplay_results = |
|
77420 | 238 |
play_one_line_proofs minimize preplay_timeout used_facts state goal subgoal |
75372 | 239 |
(snd preferred_methss) |
240 |
val chosen_preplay_outcome = |
|
241 |
select_one_line_proof used_facts (fst preferred_methss) preplay_results |
|
242 |
in |
|
243 |
(SH_Some (result, preplay_results), chosen_preplay_outcome) |
|
244 |
end |
|
245 |
fun output_message () = message (fn () => chosen_preplay_outcome) |
|
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
246 |
in |
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
247 |
(output, output_message) |
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
248 |
end |
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
249 |
|
77423 | 250 |
fun analyze_prover_result_for_inconsistency (result as {outcome, used_facts, ...} : prover_result) = |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
251 |
if outcome = SOME ATP_Proof.TimedOut then |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
252 |
(SH_TimeOut, K "") |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
253 |
else if outcome = SOME ATP_Proof.OutOfResources then |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
254 |
(SH_ResourcesOut, K "") |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
255 |
else if is_some outcome then |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
256 |
(SH_None, K "") |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
257 |
else |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
258 |
(SH_Some (result, []), fn () => |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
259 |
(if member (op = o apsnd fst) used_facts sledgehammer_goal_as_fact then |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
260 |
(case map fst (filter_out (equal sledgehammer_goal_as_fact o fst) used_facts) of |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
261 |
[] => "The goal is inconsistent" |
77428 | 262 |
| facts => "The goal is falsified by these facts: " ^ commas facts) |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
263 |
else |
77432 | 264 |
"Derived \"False\" from these facts alone: " ^ |
78645 | 265 |
space_implode " " (map fst used_facts))) |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
266 |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
267 |
fun check_expected_outcome ctxt prover_name expect outcome = |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
268 |
let |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
269 |
val outcome_code = short_string_of_sledgehammer_outcome outcome |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
270 |
in |
75027
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
271 |
(* The "expect" argument is deliberately ignored if the prover is missing so that |
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
272 |
"Metis_Examples" can be processed on any machine. *) |
75373
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
273 |
if expect = "" orelse not (is_prover_installed ctxt prover_name) then |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
274 |
() |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
275 |
else |
75373
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
276 |
(case (expect, outcome) of |
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
277 |
("some", SH_Some _) => () |
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
278 |
| ("some_preplayed", SH_Some (_, preplay_results)) => |
76524
87217c655984
correctly show '(> 2 s, timed out)' or similar in Sledgehammer's output
blanchet
parents:
75874
diff
changeset
|
279 |
if exists (fn (_, (Played _, _)) => true | _ => false) preplay_results then |
75373
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
280 |
() |
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
281 |
else |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
282 |
error ("Unexpected outcome: the external prover found a proof but preplay failed") |
75373
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
283 |
| ("unknown", SH_Unknown) => () |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
284 |
| ("timeout", SH_TimeOut) => () |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
285 |
| ("resources_out", SH_ResourcesOut) => () |
75373
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
286 |
| ("none", SH_None) => () |
48736d743e8c
expanded sledgehammer's expect option with some_preplayed
desharna
parents:
75372
diff
changeset
|
287 |
| _ => error ("Unexpected outcome: " ^ quote outcome_code)) |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
288 |
end |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
289 |
|
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
290 |
fun launch_prover_and_preplay (params as {debug, timeout, expect, ...}) mode |
77489
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
291 |
has_already_found_something found_something massage_message writeln_result learn |
77428 | 292 |
(problem as {state, subgoal, ...}) (slice as ((_, _, falsify, _, _), _)) prover_name = |
74952
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
293 |
let |
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
294 |
val ctxt = Proof.context_of state |
ae2185967e67
exported Sledgehammer.launch_prover and use it in Mirabelle
desharna
parents:
74951
diff
changeset
|
295 |
val hard_timeout = Time.scale 5.0 timeout |
53800 | 296 |
|
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
297 |
fun flip_problem {comment, state, goal, subgoal, factss = factss, ...} = |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
298 |
let |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
299 |
val thy = Proof_Context.theory_of ctxt |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
300 |
val assms = Assumption.all_assms_of ctxt |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
301 |
val assm_ts = map Thm.term_of assms |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
302 |
val subgoal_t = Logic.get_goal (Thm.prop_of goal) subgoal |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
303 |
val polymorphic_subgoal_t = (Logic.list_implies (assm_ts, subgoal_t)) |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
304 |
|> Logic.varify_global |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
305 |
val nonfixeds = |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
306 |
subtract (op =) (fold Term.add_free_names assm_ts []) (Term.add_free_names subgoal_t []) |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
307 |
val monomorphic_subgoal_t = subgoal_t |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
308 |
|> varify_nonfixed_terms_global nonfixeds |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
309 |
val subgoal_thms = map (Skip_Proof.make_thm thy) |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
310 |
[polymorphic_subgoal_t, monomorphic_subgoal_t] |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
311 |
val new_facts = |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
312 |
map (fn thm => (((sledgehammer_goal_as_fact, (Assum, General)), thm))) subgoal_thms |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
313 |
in |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
314 |
{comment = comment, state = state, goal = Thm.trivial @{cprop False}, subgoal = 1, |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
315 |
subgoal_count = 1, factss = map (apsnd (append new_facts)) factss, |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
316 |
has_already_found_something = has_already_found_something, |
77489
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
317 |
found_something = found_something "a falsification"} |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
318 |
end |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
319 |
|
77428 | 320 |
val problem as {goal, ...} = problem |> falsify ? flip_problem |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
321 |
|
41255
a80024d7b71b
added debugging option to find out how good the relevance filter was at identifying relevant facts
blanchet
parents:
41245
diff
changeset
|
322 |
fun really_go () = |
75027
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
323 |
launch_prover params mode learn problem slice prover_name |
77428 | 324 |
|> (if falsify then analyze_prover_result_for_inconsistency else |
77420 | 325 |
preplay_prover_result params state goal subgoal) |
53800 | 326 |
|
41089 | 327 |
fun go () = |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
328 |
if debug then |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
329 |
really_go () |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
330 |
else |
78709 | 331 |
\<^try>\<open>really_go () |
332 |
catch ERROR msg => (SH_Unknown, fn () => msg ^ "\n") |
|
333 |
| exn => (SH_Unknown, fn () => Runtime.exn_message exn ^ "\n")\<close> |
|
57056 | 334 |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
335 |
val (outcome, message) = Timeout.apply hard_timeout go () |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
336 |
val () = check_expected_outcome ctxt prover_name expect outcome |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
337 |
|
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
338 |
val message = message () |
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
339 |
val () = |
75040 | 340 |
if mode = Auto_Try then |
341 |
() |
|
342 |
else |
|
343 |
(case outcome of |
|
77489
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
344 |
SH_Some _ => |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
345 |
the_default writeln writeln_result (prover_name ^ ": " ^ |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
346 |
massage_message (if falsify then "falsification" else "proof") message) |
75040 | 347 |
| _ => ()) |
41089 | 348 |
in |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
349 |
(outcome, message) |
41089 | 350 |
end |
351 |
||
75034 | 352 |
fun string_of_facts filter facts = |
353 |
"Selected " ^ string_of_int (length facts) ^ " " ^ (if filter = "" then "" else filter ^ " ") ^ |
|
354 |
"fact" ^ plural_s (length facts) ^ ": " ^ (space_implode " " (map (fst o fst) facts)) |
|
51008 | 355 |
|
51010 | 356 |
fun string_of_factss factss = |
57464 | 357 |
if forall (null o snd) factss then |
63692 | 358 |
"Found no relevant facts" |
57464 | 359 |
else |
75034 | 360 |
cat_lines (map (fn (filter, facts) => string_of_facts filter facts) factss) |
51008 | 361 |
|
75029 | 362 |
val default_slice_schedule = |
75872
8bfad7bc74cb
tweak Sledgehammer's slicing mechanism -- updated Zipperposition's slices and make them half as long as other provers' to pack more of them in 30 s
blanchet
parents:
75868
diff
changeset
|
363 |
(* FUDGE (loosely inspired by Seventeen evaluation) *) |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
364 |
[cvc4N, zipperpositionN, vampireN, veritN, spassN, zipperpositionN, eN, cvc4N, zipperpositionN, |
77423 | 365 |
cvc4N, eN, zipperpositionN, vampireN, cvc4N, cvc4N, vampireN, cvc4N, iproverN, zipperpositionN, |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
366 |
spassN, vampireN, zipperpositionN, vampireN, zipperpositionN, z3N, zipperpositionN, vampireN, |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
367 |
iproverN, spassN, zipperpositionN, vampireN, cvc4N, zipperpositionN, z3N, z3N, cvc4N, |
75874 | 368 |
zipperpositionN] |
75029 | 369 |
|
370 |
fun schedule_of_provers provers num_slices = |
|
371 |
let |
|
75032
8d08bc7e8f98
tweak padding of prover slice schedule to include all provers
blanchet
parents:
75031
diff
changeset
|
372 |
val (known_provers, unknown_provers) = |
8d08bc7e8f98
tweak padding of prover slice schedule to include all provers
blanchet
parents:
75031
diff
changeset
|
373 |
List.partition (member (op =) default_slice_schedule) provers |
75029 | 374 |
|
75034 | 375 |
val default_slice_schedule = filter (member (op =) known_provers) default_slice_schedule |
376 |
val num_default_slices = length default_slice_schedule |
|
377 |
||
75029 | 378 |
fun round_robin _ [] = [] |
379 |
| round_robin 0 _ = [] |
|
380 |
| round_robin n (prover :: provers) = prover :: round_robin (n - 1) (provers @ [prover]) |
|
381 |
in |
|
382 |
if num_slices <= num_default_slices then |
|
383 |
take num_slices default_slice_schedule |
|
384 |
else |
|
75032
8d08bc7e8f98
tweak padding of prover slice schedule to include all provers
blanchet
parents:
75031
diff
changeset
|
385 |
default_slice_schedule |
8d08bc7e8f98
tweak padding of prover slice schedule to include all provers
blanchet
parents:
75031
diff
changeset
|
386 |
@ round_robin (num_slices - num_default_slices) (unknown_provers @ known_provers) |
75029 | 387 |
end |
388 |
||
77419
a15f0fcff041
don't apply abduction and consistency checking to goals of the form 'False'
blanchet
parents:
77418
diff
changeset
|
389 |
fun prover_slices_of_schedule ctxt goal subgoal factss |
77428 | 390 |
({abduce, falsify, max_facts, fact_filter, type_enc, lam_trans, uncurried_aliases, |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
391 |
...} : params) |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
392 |
schedule = |
75029 | 393 |
let |
394 |
fun triplicate_slices original = |
|
395 |
let |
|
396 |
val shift = |
|
77428 | 397 |
map (apfst (fn (slice_size, abduce, falsify, num_facts, fact_filter) => |
398 |
(slice_size, abduce, falsify, num_facts, |
|
75339
d9bb81999d2c
first step in making time slicing more flexible in Sledgehammer: label slices with 'slice size'
blanchet
parents:
75076
diff
changeset
|
399 |
if fact_filter = mashN then mepoN |
d9bb81999d2c
first step in making time slicing more flexible in Sledgehammer: label slices with 'slice size'
blanchet
parents:
75076
diff
changeset
|
400 |
else if fact_filter = mepoN then meshN |
d9bb81999d2c
first step in making time slicing more flexible in Sledgehammer: label slices with 'slice size'
blanchet
parents:
75076
diff
changeset
|
401 |
else mashN))) |
75029 | 402 |
|
403 |
val shifted_once = shift original |
|
404 |
val shifted_twice = shift shifted_once |
|
405 |
in |
|
406 |
original @ shifted_once @ shifted_twice |
|
407 |
end |
|
408 |
||
75063
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
409 |
fun adjust_extra (ATP_Slice (format0, type_enc0, lam_trans0, uncurried_aliases0, |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
410 |
extra_extra0)) = |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
411 |
ATP_Slice (format0, the_default type_enc0 type_enc, the_default lam_trans0 lam_trans, |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
412 |
the_default uncurried_aliases0 uncurried_aliases, extra_extra0) |
7ff39293e265
added possibility of extra options to SMT slices
blanchet
parents:
75060
diff
changeset
|
413 |
| adjust_extra (extra as SMT_Slice _) = extra |
75034 | 414 |
|
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
415 |
fun adjust_slice max_slice_size |
77428 | 416 |
((slice_size0, abduce0, falsify0, num_facts0, fact_filter0), extra) = |
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:
75056
diff
changeset
|
417 |
let |
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
|
418 |
val slice_size = Int.min (max_slice_size, slice_size0) |
77601 | 419 |
val the_subgoal = Logic.get_goal (Thm.prop_of goal) subgoal |
420 |
val goal_not_False = not (the_subgoal aconv @{prop False}) |
|
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
421 |
val abduce = |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
422 |
(case abduce of |
77419
a15f0fcff041
don't apply abduction and consistency checking to goals of the form 'False'
blanchet
parents:
77418
diff
changeset
|
423 |
NONE => abduce0 andalso goal_not_False |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
424 |
| SOME max_candidates => max_candidates > 0) |
77428 | 425 |
val falsify = |
426 |
(case falsify of |
|
427 |
NONE => falsify0 andalso goal_not_False |
|
428 |
| SOME falsify => falsify) |
|
77601 | 429 |
andalso not (Term.is_schematic the_subgoal) |
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:
75056
diff
changeset
|
430 |
val fact_filter = fact_filter |> the_default fact_filter0 |
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:
75056
diff
changeset
|
431 |
val max_facts = max_facts |> the_default num_facts0 |
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:
75056
diff
changeset
|
432 |
val num_facts = Int.min (max_facts, length (facts_of_filter fact_filter factss)) |
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:
75056
diff
changeset
|
433 |
in |
77428 | 434 |
((slice_size, abduce, falsify, num_facts, fact_filter), adjust_extra extra) |
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:
75056
diff
changeset
|
435 |
end |
75034 | 436 |
|
75029 | 437 |
val provers = distinct (op =) schedule |
438 |
val prover_slices = |
|
75034 | 439 |
map (fn prover => (prover, |
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
|
440 |
(is_none fact_filter ? triplicate_slices) (get_slices ctxt prover))) |
75034 | 441 |
provers |
75029 | 442 |
|
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
|
443 |
val max_threads = Multithreading.max_threads () |
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
444 |
|
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
445 |
fun translate_schedule _ 0 _ = [] |
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
446 |
| translate_schedule _ _ [] = [] |
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
447 |
| translate_schedule prover_slices slices_left (prover :: schedule) = |
75029 | 448 |
(case AList.lookup (op =) prover_slices prover of |
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
|
449 |
SOME (slice0 :: slices) => |
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
450 |
let |
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
451 |
val prover_slices' = AList.update (op =) (prover, slices) prover_slices |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
452 |
val slice as ((slice_size, _, _, _, _), _) = |
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
|
453 |
adjust_slice ((slices_left + max_threads - 1) div max_threads) slice0 |
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
454 |
in |
e1aa703c8cce
second and last step in making time slicing more flexible in Sledgehammer: try to honor desired slice size
blanchet
parents:
75339
diff
changeset
|
455 |
(prover, slice) :: translate_schedule prover_slices' (slices_left - slice_size) schedule |
75029 | 456 |
end |
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
|
457 |
| _ => translate_schedule prover_slices slices_left schedule) |
75029 | 458 |
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
|
459 |
translate_schedule prover_slices (length schedule) schedule |
75034 | 460 |
|> distinct (op =) |
75029 | 461 |
end |
462 |
||
77428 | 463 |
fun run_sledgehammer (params as {verbose, spy, provers, falsify, induction_rules, max_facts, |
78644 | 464 |
max_proofs, slices, timeout, ...}) mode writeln_result i (fact_override as {only, ...}) state = |
40059
6ad9081665db
use consistent terminology in Sledgehammer: "prover = ATP or SMT solver or ..."
blanchet
parents:
39494
diff
changeset
|
465 |
if null provers then |
63692 | 466 |
error "No prover is set" |
55286 | 467 |
else |
468 |
(case subgoal_count state of |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
469 |
0 => (error "No subgoal!"; (false, (SH_None, ""))) |
55286 | 470 |
| n => |
471 |
let |
|
472 |
val _ = Proof.assert_backward state |
|
62735 | 473 |
val print = if mode = Normal andalso is_none writeln_result then writeln else K () |
474 |
||
77428 | 475 |
val found_proofs_and_falsifications = Synchronized.var "found_proofs_and_falsifications" 0 |
75030 | 476 |
|
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
477 |
fun has_already_found_something () = |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
478 |
if mode = Normal then |
77428 | 479 |
Synchronized.value found_proofs_and_falsifications > 0 |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
480 |
else |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
481 |
false |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
482 |
|
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
483 |
fun found_something a_proof_or_inconsistency prover_name = |
75030 | 484 |
if mode = Normal then |
77428 | 485 |
(Synchronized.change found_proofs_and_falsifications (fn n => n + 1); |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
486 |
(the_default writeln writeln_result) (prover_name ^ " found " ^ |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
487 |
a_proof_or_inconsistency ^ "...")) |
75030 | 488 |
else |
489 |
() |
|
62735 | 490 |
|
77489
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
491 |
val seen_messages = Synchronized.var "seen_messages" ([] : string list) |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
492 |
|
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
493 |
fun strip_until_left_paren "" = "" |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
494 |
| strip_until_left_paren s = |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
495 |
let |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
496 |
val n = String.size s |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
497 |
val s' = String.substring (s, 0, n - 1) |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
498 |
in |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
499 |
s' |> String.substring (s, n - 1, 1) <> "(" ? strip_until_left_paren |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
500 |
end |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
501 |
|
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
502 |
(* Remove the measured preplay time when looking for duplicates. This is |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
503 |
admittedly rather ad hoc. *) |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
504 |
fun strip_time s = |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
505 |
if String.isSuffix " s)" s orelse String.isSuffix " ms)" s then |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
506 |
strip_until_left_paren s |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
507 |
else |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
508 |
s |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
509 |
|
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
510 |
fun massage_message proof_or_inconsistency s = |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
511 |
let val s' = strip_time s in |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
512 |
if member (op =) (Synchronized.value seen_messages) s' then |
78645 | 513 |
"Duplicate " ^ proof_or_inconsistency |
77489
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
514 |
else |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
515 |
(Synchronized.change seen_messages (cons s'); s) |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
516 |
end |
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
517 |
|
55286 | 518 |
val ctxt = Proof.context_of state |
74950
b350a1f2115d
added nearly_all_facts_of_context and uniformized its usage in Sledgehammer and Mirabelle
desharna
parents:
73975
diff
changeset
|
519 |
val inst_inducts = induction_rules = SOME Instantiate |
b350a1f2115d
added nearly_all_facts_of_context and uniformized its usage in Sledgehammer and Mirabelle
desharna
parents:
73975
diff
changeset
|
520 |
val {facts = chained_thms, goal, ...} = Proof.goal state |
55286 | 521 |
val (_, hyp_ts, concl_t) = strip_subgoal goal i ctxt |
522 |
val _ = |
|
523 |
(case find_first (not o is_prover_supported ctxt) provers of |
|
63692 | 524 |
SOME name => error ("No such prover: " ^ name) |
55286 | 525 |
| NONE => ()) |
526 |
val _ = print "Sledgehammering..." |
|
57037 | 527 |
val _ = spying spy (fn () => (state, i, "***", "Starting " ^ str_of_mode mode ^ " mode")) |
75002 | 528 |
val ({elapsed, ...}, all_facts) = Timing.timing |
529 |
(nearly_all_facts_of_context ctxt inst_inducts fact_override chained_thms hyp_ts) concl_t |
|
530 |
val _ = spying spy (fn () => (state, i, "All", |
|
531 |
"Extracting " ^ string_of_int (length all_facts) ^ " facts from background theory in " ^ |
|
532 |
string_of_int (Time.toMilliseconds elapsed) ^ " ms")) |
|
54090
a28992e35032
run relevance filter only once for ATPs and SMT solvers, since it should now yield the same results anyway
blanchet
parents:
54063
diff
changeset
|
533 |
|
55286 | 534 |
val spying_str_of_factss = |
535 |
commas o map (fn (filter, facts) => filter ^ ": " ^ string_of_int (length facts)) |
|
53800 | 536 |
|
55286 | 537 |
fun get_factss provers = |
538 |
let |
|
539 |
val max_max_facts = |
|
540 |
(case max_facts of |
|
541 |
SOME n => n |
|
542 |
| NONE => |
|
75029 | 543 |
fold (fn prover => |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
544 |
fold (fn ((_, _, _, max_facts, _), _) => Integer.max max_facts) |
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
545 |
(get_slices ctxt prover)) |
75029 | 546 |
provers 0) |
75034 | 547 |
* 51 div 50 (* some slack to account for filtering of induction facts below *) |
75027
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
548 |
|
74998
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
549 |
val ({elapsed, ...}, factss) = Timing.timing |
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
550 |
(relevant_facts ctxt params (hd provers) max_max_facts fact_override hyp_ts concl_t) |
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
551 |
all_facts |
75027
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
552 |
|
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
553 |
val induction_rules = the_default (if only then Include else Exclude) induction_rules |
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
554 |
val factss = map (apsnd (maybe_filter_out_induction_rules induction_rules)) factss |
a8efa30c380d
take 'induction_rules' into consideration, as well as 'max_facts' even when 'only' is set
blanchet
parents:
75026
diff
changeset
|
555 |
|
74998
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
556 |
val () = spying spy (fn () => (state, i, "All", |
75002 | 557 |
"Filtering facts in " ^ string_of_int (Time.toMilliseconds elapsed) ^ |
558 |
" ms (MaSh algorithm: " ^ str_of_mash_algorithm (the_mash_algorithm ()) ^ ")")); |
|
74998
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
559 |
val () = if verbose then print (string_of_factss factss) else () |
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
560 |
val () = spying spy (fn () => |
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
561 |
(state, i, "All", "Selected facts: " ^ spying_str_of_factss factss)) |
55286 | 562 |
in |
74998
fe14ceff1cfd
added syping of fact filtering time to sledgehammer
desharna
parents:
74953
diff
changeset
|
563 |
factss |
55286 | 564 |
end |
53800 | 565 |
|
58892
20aa19ecf2cc
eliminated obsolete Proof.goal_message -- print outcome more directly;
wenzelm
parents:
58843
diff
changeset
|
566 |
fun launch_provers () = |
55286 | 567 |
let |
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:
75056
diff
changeset
|
568 |
val factss = get_factss provers |
55286 | 569 |
val problem = |
570 |
{comment = "", state = state, goal = goal, subgoal = i, subgoal_count = n, |
|
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
571 |
factss = factss, has_already_found_something = has_already_found_something, |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
572 |
found_something = found_something "a proof"} |
69706
6d6235b828fc
get rid of visibility in MaSh -- it slows it down more than it helps
blanchet
parents:
63697
diff
changeset
|
573 |
val learn = mash_learn_proof ctxt params (Thm.prop_of goal) |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
574 |
val launch = launch_prover_and_preplay params mode has_already_found_something |
77489
8a28ab58d155
detect duplicates in Sledgehammer output -- suggested by Larry Paulson
blanchet
parents:
77432
diff
changeset
|
575 |
found_something massage_message writeln_result learn |
75029 | 576 |
|
78644 | 577 |
val timer = Timer.startRealTimer () |
578 |
||
75029 | 579 |
val schedule = |
75036 | 580 |
if mode = Auto_Try then provers |
581 |
else schedule_of_provers provers slices |
|
77419
a15f0fcff041
don't apply abduction and consistency checking to goals of the form 'False'
blanchet
parents:
77418
diff
changeset
|
582 |
val prover_slices = prover_slices_of_schedule ctxt goal i factss params schedule |
75037 | 583 |
|
584 |
val _ = |
|
585 |
if verbose then |
|
586 |
writeln ("Running " ^ commas (map fst prover_slices) ^ "...") |
|
587 |
else |
|
588 |
() |
|
55286 | 589 |
in |
590 |
if mode = Auto_Try then |
|
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
591 |
(SH_Unknown, "") |
75029 | 592 |
|> fold (fn (prover, slice) => |
75025 | 593 |
fn accum as (SH_Some _, _) => accum |
75029 | 594 |
| _ => launch problem slice prover) |
595 |
prover_slices |
|
55286 | 596 |
else |
74950
b350a1f2115d
added nearly_all_facts_of_context and uniformized its usage in Sledgehammer and Mirabelle
desharna
parents:
73975
diff
changeset
|
597 |
(learn chained_thms; |
75031 | 598 |
Par_List.map (fn (prover, slice) => |
78644 | 599 |
if Synchronized.value found_proofs_and_falsifications < max_proofs |
600 |
andalso Timer.checkRealTimer timer < timeout then |
|
75031 | 601 |
launch problem slice prover |
602 |
else |
|
75056
04a4881ff0fd
propagate right result when enough proofs have been found
blanchet
parents:
75054
diff
changeset
|
603 |
(SH_None, "")) |
75031 | 604 |
prover_slices |
74953
aade20a03edb
tuned run_sledgehammer and called it directly from Mirabelle
desharna
parents:
74952
diff
changeset
|
605 |
|> max_outcome) |
55286 | 606 |
end |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
607 |
|
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
608 |
fun normal_failure () = |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
609 |
(the_default writeln writeln_result |
77428 | 610 |
("No " ^ (if falsify = SOME true then "falsification" else "proof") ^ |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
611 |
" found"); |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
612 |
false) |
55286 | 613 |
in |
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
614 |
(launch_provers () |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
615 |
handle Timeout.TIMEOUT _ => (SH_TimeOut, "")) |
75054 | 616 |
|> `(fn (outcome, message) => |
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
617 |
(case outcome of |
77269
bc43f86c9598
added refute mode to Sledgehammer to find 'counterexamples'
blanchet
parents:
76524
diff
changeset
|
618 |
SH_Some _ => (the_default writeln writeln_result "Done"; true) |
77418
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
619 |
| SH_Unknown => |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
620 |
if message = "" then normal_failure () |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
621 |
else (the_default writeln writeln_result ("Warning: " ^ message); false) |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
622 |
| SH_TimeOut => normal_failure () |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
623 |
| SH_ResourcesOut => normal_failure () |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
624 |
| SH_None => |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
625 |
if message = "" then normal_failure () |
a8458f0df4ee
implemented ad hoc abduction in Sledgehammer with E
blanchet
parents:
77269
diff
changeset
|
626 |
else (the_default writeln writeln_result ("Warning: " ^ message); false))) |
75020
b087610592b4
rationalized output for forthcoming slicing model
blanchet
parents:
75019
diff
changeset
|
627 |
end) |
38044 | 628 |
|
28582 | 629 |
end; |